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

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


var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.withHitbox = void 0;
var Game_1 = __importDefault(__webpack_require__(513));
var common_types_1 = __webpack_require__(475);
function drawObjectWithHitbox(shape) {
    return function (canvas) {
        var _a = this.state, _b = _a.sprite, imageX = _b.imageX, imageY = _b.imageY, realImageWidth = _b.realImageWidth, realImageHeight = _b.realImageHeight, imageWidth = _b.imageWidth, imageHeight = _b.imageHeight, _c = _b.hitboxWidth, hitboxWidth = _c === void 0 ? imageWidth : _c, _d = _b.hitboxHeight, hitboxHeight = _d === void 0 ? imageHeight : _d, _e = _b.hitboxLeft, hitboxLeft = _e === void 0 ? 0 : _e, _f = _b.hitboxTop, hitboxTop = _f === void 0 ? 0 : _f, x = _a.x, y = _a.y;
        if (shape === common_types_1.EHitboxShape.Rect) {
            this.object = canvas.drawRect({
                fillStyle: 'transparent',
                strokeStyle: Game_1.default.isShowHitbox ? this.gridColor : 'transparent',
                x: x,
                y: y,
                width: hitboxWidth,
                height: hitboxHeight,
            });
        }
        if (shape === common_types_1.EHitboxShape.Ellipse) {
            this.object = canvas.drawEllipse({
                fillStyle: 'transparent',
                strokeStyle: Game_1.default.isShowHitbox ? this.gridColor : 'transparent',
                x: x + imageWidth / 2,
                y: y + imageHeight / 2,
                radiusX: hitboxWidth / 2,
                radiusY: hitboxHeight / 2,
                startAngle: 0,
                endAngle: 180,
                rotation: 0,
            });
        }
        canvas.drawImage(this.sprite, imageX, imageY, realImageWidth, realImageHeight, x - hitboxLeft, y - hitboxTop, imageWidth, imageHeight);
    };
}
/**
 *
 * @param CanvasObjectClass
 * @description Класс должен иметь поле sprite, стейт sprite со свойствами imageX, imageY, realImageWidth, realImageHeight, imageWidth, imageHeight, hitboxWidth, hitboxHeight, hitboxLeft, hitboxTop
 */
var withHitbox = function (CanvasObjectClass, shape) {
    if (shape === void 0) { shape = common_types_1.EHitboxShape.Rect; }
    return /** @class */ (function (_super) {
        __extends(CanvasObjectWithHitbox, _super);
        function CanvasObjectWithHitbox() {
            var args = [];
            for (var _i = 0; _i < arguments.length; _i++) {
                args[_i] = arguments[_i];
            }
            var _this = _super.apply(this, args) || this;
            _this.draw = drawObjectWithHitbox.bind(_this)(shape);
            return _this;
        }
        return CanvasObjectWithHitbox;
    }(CanvasObjectClass));
};
exports.withHitbox = withHitbox;


/***/ }),

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


Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.EHitboxShape = exports.ECanvasEventType = exports.ActionTypes = void 0;
var ActionTypes;
(function (ActionTypes) {
    ActionTypes["MouseDown"] = "mousedown";
    ActionTypes["MouseUp"] = "mouseup";
    ActionTypes["MouseOver"] = "mouseover";
    ActionTypes["MouseOut"] = "mouseout";
})(ActionTypes = exports.ActionTypes || (exports.ActionTypes = {}));
var ECanvasEventType;
(function (ECanvasEventType) {
    ECanvasEventType["Click"] = "click";
})(ECanvasEventType = exports.ECanvasEventType || (exports.ECanvasEventType = {}));
var EHitboxShape;
(function (EHitboxShape) {
    EHitboxShape["Rect"] = "rect";
    EHitboxShape["Ellipse"] = "ellipse";
})(EHitboxShape = exports.EHitboxShape || (exports.EHitboxShape = {}));


/***/ }),

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


Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.Game = void 0;
var Game = /** @class */ (function () {
    function Game() {
        var _this = this;
        this.showToolbox = function (root) {
            var form = document.createElement('form');
            form.style.padding = '10px 5px';
            form.style.background = '#2f2f2f';
            form.style.color = 'white';
            form.style.position = 'fixed';
            form.style.top = '50vh';
            form.style.left = '0';
            form.style.display = 'flex';
            form.style.flexDirection = 'column';
            var isShowHitboxCheckbox = _this.createCheckbox('Хитбокс', 'isShowHitbox');
            var isShowGridCheckbox = _this.createCheckbox('Сетка', 'isShowGrid');
            var isShowHitboxGridCheckbox = _this.createCheckbox('Сетка хитбокса', 'isShowHitboxGrid');
            form.append(isShowHitboxCheckbox);
            form.append(isShowGridCheckbox);
            form.append(isShowHitboxGridCheckbox);
            document.querySelector(root || 'body').append(form);
        };
        this.createCheckbox = function (innerText, name) {
            var checkbox = document.createElement('input');
            checkbox.name = name;
            checkbox.type = 'checkbox';
            // @ts-ignore
            checkbox.onchange = function () { return Game[name] = !Game[name]; };
            var label = document.createElement('label');
            label.innerText = innerText;
            label.append(checkbox);
            return label;
        };
        if (!Game.instance) {
            Game.instance = this;
        }
        return Game.instance;
    }
    return Game;
}());
exports.Game = Game;
exports["default"] = Game;


/***/ })

/******/ 	});
/************************************************************************/
/******/ 	// 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__(799);
/******/ 	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 });
/******/ 	
/******/ })()
;