/******/ (() => { // webpackBootstrap
/******/ 	"use strict";
/******/ 	var __webpack_modules__ = ({

/***/ 117:
/***/ ((__unused_webpack_module, exports) => {


Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.INTERVAL = void 0;
exports.INTERVAL = 50;


/***/ }),

/***/ 814:
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __assign = (this && this.__assign) || function () {
    __assign = Object.assign || function(t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                t[p] = s[p];
        }
        return t;
    };
    return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
var constants_1 = __webpack_require__(117);
var runDiagonal = function (changeStateFields) {
    return function (_a) {
        var _this = this;
        var toX = _a.x, toY = _a.y;
        if (this._interval) {
            clearInterval(this._interval);
        }
        var yPath = toY - this.state.y;
        var xPath = toX - this.state.x;
        var xSign = xPath / Math.abs(xPath) * this.step;
        var ySign = yPath / Math.abs(yPath) * this.step;
        this._interval = setInterval(function () {
            _this.setState(function (currentState) {
                var newState = {};
                if (Math.abs(yPath) > Math.abs(xPath)) {
                    if (Math.abs(toY - _this.state.y) >= _this.step) {
                        newState = __assign({ y: currentState.y + ySign, x: currentState.x + Math.abs(xPath / yPath) * xSign }, changeStateFields({ dX: xSign, dY: ySign }));
                    }
                    else {
                        newState = __assign({ y: toY, x: toX }, changeStateFields({ dX: xSign, dY: ySign, isLast: true }));
                        clearInterval(_this._interval);
                    }
                }
                else {
                    if (Math.abs(toX - _this.state.x) >= _this.step) {
                        newState = __assign({ x: currentState.x + xSign, y: currentState.y + Math.abs(yPath / xPath) * ySign }, changeStateFields({ dX: xSign, dY: ySign }));
                    }
                    else {
                        newState = __assign({ y: toY, x: toX }, changeStateFields({ dX: xSign, dY: ySign, isLast: true }));
                        clearInterval(_this._interval);
                    }
                }
                return newState;
            });
        }, constants_1.INTERVAL);
    };
};
exports["default"] = runDiagonal;


/***/ })

/******/ 	});
/************************************************************************/
/******/ 	// The module cache
/******/ 	var __webpack_module_cache__ = {};
/******/ 	
/******/ 	// The require function
/******/ 	function __webpack_require__(moduleId) {
/******/ 		// Check if module is in cache
/******/ 		var cachedModule = __webpack_module_cache__[moduleId];
/******/ 		if (cachedModule !== undefined) {
/******/ 			return cachedModule.exports;
/******/ 		}
/******/ 		// Create a new module (and put it into the cache)
/******/ 		var module = __webpack_module_cache__[moduleId] = {
/******/ 			// no module.id needed
/******/ 			// no module.loaded needed
/******/ 			exports: {}
/******/ 		};
/******/ 	
/******/ 		// Execute the module function
/******/ 		__webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/ 	
/******/ 		// Return the exports of the module
/******/ 		return module.exports;
/******/ 	}
/******/ 	
/************************************************************************/
/******/ 	
/******/ 	// startup
/******/ 	// Load entry module and return exports
/******/ 	// This entry module is referenced by other modules so it can't be inlined
/******/ 	var __webpack_exports__ = __webpack_require__(814);
/******/ 	var __webpack_export_target__ = exports;
/******/ 	for(var i in __webpack_exports__) __webpack_export_target__[i] = __webpack_exports__[i];
/******/ 	if(__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, "__esModule", { value: true });
/******/ 	
/******/ })()
;