/******/ (function(modules) { // webpackBootstrap
/******/ 	// The module cache
/******/ 	var installedModules = {};
/******/
/******/ 	// The require function
/******/ 	function __webpack_require__(moduleId) {
/******/
/******/ 		// Check if module is in cache
/******/ 		if(installedModules[moduleId]) {
/******/ 			return installedModules[moduleId].exports;
/******/ 		}
/******/ 		// Create a new module (and put it into the cache)
/******/ 		var module = installedModules[moduleId] = {
/******/ 			i: moduleId,
/******/ 			l: false,
/******/ 			exports: {}
/******/ 		};
/******/
/******/ 		// Execute the module function
/******/ 		modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ 		// Flag the module as loaded
/******/ 		module.l = true;
/******/
/******/ 		// Return the exports of the module
/******/ 		return module.exports;
/******/ 	}
/******/
/******/
/******/ 	// expose the modules object (__webpack_modules__)
/******/ 	__webpack_require__.m = modules;
/******/
/******/ 	// expose the module cache
/******/ 	__webpack_require__.c = installedModules;
/******/
/******/ 	// define getter function for harmony exports
/******/ 	__webpack_require__.d = function(exports, name, getter) {
/******/ 		if(!__webpack_require__.o(exports, name)) {
/******/ 			Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ 		}
/******/ 	};
/******/
/******/ 	// define __esModule on exports
/******/ 	__webpack_require__.r = function(exports) {
/******/ 		if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ 			Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ 		}
/******/ 		Object.defineProperty(exports, '__esModule', { value: true });
/******/ 	};
/******/
/******/ 	// create a fake namespace object
/******/ 	// mode & 1: value is a module id, require it
/******/ 	// mode & 2: merge all properties of value into the ns
/******/ 	// mode & 4: return value when already ns object
/******/ 	// mode & 8|1: behave like require
/******/ 	__webpack_require__.t = function(value, mode) {
/******/ 		if(mode & 1) value = __webpack_require__(value);
/******/ 		if(mode & 8) return value;
/******/ 		if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ 		var ns = Object.create(null);
/******/ 		__webpack_require__.r(ns);
/******/ 		Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ 		if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ 		return ns;
/******/ 	};
/******/
/******/ 	// getDefaultExport function for compatibility with non-harmony modules
/******/ 	__webpack_require__.n = function(module) {
/******/ 		var getter = module && module.__esModule ?
/******/ 			function getDefault() { return module['default']; } :
/******/ 			function getModuleExports() { return module; };
/******/ 		__webpack_require__.d(getter, 'a', getter);
/******/ 		return getter;
/******/ 	};
/******/
/******/ 	// Object.prototype.hasOwnProperty.call
/******/ 	__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ 	// __webpack_public_path__
/******/ 	__webpack_require__.p = "";
/******/
/******/
/******/ 	// Load entry module and return exports
/******/ 	return __webpack_require__(__webpack_require__.s = 12);
/******/ })
/************************************************************************/
/******/ ({

/***/ 0:
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return __extends; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return __assign; });
/* unused harmony export __rest */
/* unused harmony export __decorate */
/* unused harmony export __param */
/* unused harmony export __metadata */
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return __awaiter; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return __generator; });
/* unused harmony export __createBinding */
/* unused harmony export __exportStar */
/* unused harmony export __values */
/* unused harmony export __read */
/* unused harmony export __spread */
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return __spreadArrays; });
/* unused harmony export __await */
/* unused harmony export __asyncGenerator */
/* unused harmony export __asyncDelegator */
/* unused harmony export __asyncValues */
/* unused harmony export __makeTemplateObject */
/* unused harmony export __importStar */
/* unused harmony export __importDefault */
/* unused harmony export __classPrivateFieldGet */
/* unused harmony export __classPrivateFieldSet */
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
/* global Reflect, Promise */

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);
};

function __extends(d, b) {
    extendStatics(d, b);
    function __() { this.constructor = d; }
    d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
}

var __assign = function() {
    __assign = Object.assign || function __assign(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);
}

function __rest(s, e) {
    var t = {};
    for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
        t[p] = s[p];
    if (s != null && typeof Object.getOwnPropertySymbols === "function")
        for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
            if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
                t[p[i]] = s[p[i]];
        }
    return t;
}

function __decorate(decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
}

function __param(paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
}

function __metadata(metadataKey, metadataValue) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
}

function __awaiter(thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
}

function __generator(thisArg, body) {
    var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
    return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
    function verb(n) { return function (v) { return step([n, v]); }; }
    function step(op) {
        if (f) throw new TypeError("Generator is already executing.");
        while (_) try {
            if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
            if (y = 0, t) op = [op[0] & 2, t.value];
            switch (op[0]) {
                case 0: case 1: t = op; break;
                case 4: _.label++; return { value: op[1], done: false };
                case 5: _.label++; y = op[1]; op = [0]; continue;
                case 7: op = _.ops.pop(); _.trys.pop(); continue;
                default:
                    if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
                    if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
                    if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
                    if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
                    if (t[2]) _.ops.pop();
                    _.trys.pop(); continue;
            }
            op = body.call(thisArg, _);
        } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
        if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
    }
}

var __createBinding = Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
});

function __exportStar(m, o) {
    for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);
}

function __values(o) {
    var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
    if (m) return m.call(o);
    if (o && typeof o.length === "number") return {
        next: function () {
            if (o && i >= o.length) o = void 0;
            return { value: o && o[i++], done: !o };
        }
    };
    throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
}

function __read(o, n) {
    var m = typeof Symbol === "function" && o[Symbol.iterator];
    if (!m) return o;
    var i = m.call(o), r, ar = [], e;
    try {
        while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
    }
    catch (error) { e = { error: error }; }
    finally {
        try {
            if (r && !r.done && (m = i["return"])) m.call(i);
        }
        finally { if (e) throw e.error; }
    }
    return ar;
}

function __spread() {
    for (var ar = [], i = 0; i < arguments.length; i++)
        ar = ar.concat(__read(arguments[i]));
    return ar;
}

function __spreadArrays() {
    for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
    for (var r = Array(s), k = 0, i = 0; i < il; i++)
        for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
            r[k] = a[j];
    return r;
};

function __await(v) {
    return this instanceof __await ? (this.v = v, this) : new __await(v);
}

function __asyncGenerator(thisArg, _arguments, generator) {
    if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
    var g = generator.apply(thisArg, _arguments || []), i, q = [];
    return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
    function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
    function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
    function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
    function fulfill(value) { resume("next", value); }
    function reject(value) { resume("throw", value); }
    function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
}

function __asyncDelegator(o) {
    var i, p;
    return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
    function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
}

function __asyncValues(o) {
    if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
    var m = o[Symbol.asyncIterator], i;
    return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
    function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
    function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
}

function __makeTemplateObject(cooked, raw) {
    if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
    return cooked;
};

var __setModuleDefault = Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
};

function __importStar(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;
}

function __importDefault(mod) {
    return (mod && mod.__esModule) ? mod : { default: mod };
}

function __classPrivateFieldGet(receiver, privateMap) {
    if (!privateMap.has(receiver)) {
        throw new TypeError("attempted to get private field on non-instance");
    }
    return privateMap.get(receiver);
}

function __classPrivateFieldSet(receiver, privateMap, value) {
    if (!privateMap.has(receiver)) {
        throw new TypeError("attempted to set private field on non-instance");
    }
    privateMap.set(receiver, value);
    return value;
}


/***/ }),

/***/ 1:
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
/* unused harmony export isObject */
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return isString; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return isCommonArray; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return isTypedArray; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return isArray; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return isNumber; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return isEqual; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "i", function() { return removeFromArray; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "h", function() { return parametrizeString; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "g", function() { return noop; });
var isObject = function (obj) {
    return obj === Object(obj);
};
var isString = function (s) {
    var _a;
    return ((_a = s) === null || _a === void 0 ? void 0 : _a.substr) !== undefined;
};
var isCommonArray = function (a) {
    return !!(a.splice);
};
var isTypedArray = function (a) {
    return !!(a.buffer);
};
var isArray = function (a) {
    return isCommonArray(a) || isTypedArray(a);
};
var isNumber = function (value) {
    return value.toFixed !== undefined;
};
var isEqualArray = function (a, b) {
    for (var i = 0, max = a.length; i < max; i++) {
        if (a[i] !== b[i])
            return false;
    }
    return true;
};
var isEqualObject = function (a, b) {
    throw new Error('not implemented');
};
var isEqual = function (a, b) {
    if (a === null || a === undefined)
        return false;
    if (isArray(a) && isArray(b))
        return isEqualArray(a, b);
    else if (isObject(a) && isObject(b))
        return isEqualObject(a, b);
    return a === b;
};
var removeFromArray = function (arr, predicate) {
    var i = arr.length;
    var cnt = 0;
    while (i--) {
        if (predicate(arr[i])) {
            arr.splice(i, 1);
            cnt++;
        }
    }
    return cnt;
};
var parametrizeString = function (source, args) {
    Object.keys(args).forEach(function (key) {
        source = source.split(key).join('' + args[key]);
    });
    return source;
};
var noop = function (arg) { };


/***/ }),

/***/ 12:
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
// ESM COMPAT FLAG
__webpack_require__.r(__webpack_exports__);

// EXTERNAL MODULE: ./node_modules/tslib/tslib.es6.js
var tslib_es6 = __webpack_require__(0);

// EXTERNAL MODULE: ./engine/misc/object.ts
var object = __webpack_require__(1);

// CONCATENATED MODULE: ./engine/debug/httpClient.ts

var objectToQuery = function (o) {
    if (o === undefined || o === null)
        return '';
    if (o instanceof FormData)
        return o;
    var paramsArr = [];
    if (typeof o === 'string' || typeof o === 'number')
        return o.toString();
    Object.keys(o).forEach(function (key) {
        paramsArr.push([key, encodeURIComponent(o[key])]);
    });
    return paramsArr.map(function (item) { return [item[0] + '=' + item[1]]; }).join('&');
};
var request = function (data) {
    var abortTmr;
    var resolved = false;
    data.method = data.method || 'get';
    if (data.data && data.method === 'get')
        data.url += '?' + objectToQuery(data.data);
    var xhr = new XMLHttpRequest();
    var resolveFn = object["g" /* noop */], rejectFn = object["g" /* noop */];
    var promise;
    if (window.Promise) {
        promise = new Promise(function (resolve, reject) {
            resolveFn = resolve;
            rejectFn = reject;
        });
    }
    xhr.onreadystatechange = function () {
        if (xhr.readyState === 4) {
            if ((xhr.status >= 200 && xhr.status <= 299) || xhr.status === 0) {
                var resp = xhr.responseText;
                var contentType = xhr.getResponseHeader("Content-Type") || '';
                if (contentType.toLowerCase().indexOf('json') > -1 && resp && resp.substr !== undefined)
                    resp = JSON.parse(resp);
                if (data.success) {
                    data.success(resp);
                }
                resolveFn(resp);
            }
            else {
                if (data.error)
                    data.error({ status: xhr.status, error: xhr.statusText });
                rejectFn(xhr.statusText);
            }
            clearTimeout(abortTmr);
            resolved = true;
        }
    };
    xhr.open(data.method, data.url, true);
    if (data.setup)
        data.setup(xhr);
    if (data.requestType) {
        if (data.requestType !== 'multipart/form-data')
            xhr.setRequestHeader("Content-Type", data.requestType);
    }
    else {
        xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    }
    if (data.requestType === 'application/json')
        data.data = data.data && JSON.stringify(data.data);
    xhr.send(data.data);
    if (data.timeout) {
        abortTmr = setTimeout(function () {
            if (resolved)
                return;
            xhr.abort();
            if (data.ontimeout)
                data.ontimeout();
            rejectFn('timeout');
        }, data.timeout);
    }
    return promise;
};
var httpClient;
(function (httpClient) {
    httpClient.get = function (url, data, success, error, setup) {
        return request({
            method: 'get',
            url: url,
            data: data,
            success: success,
            error: error,
            setup: setup,
        });
    };
    httpClient.post = function (url, data, success, error, setup) {
        return request({
            method: 'post',
            url: url,
            data: data,
            requestType: 'application/json',
            success: success,
            error: error,
            setup: setup,
        });
    };
    httpClient.postMultiPart = function (url, file, data, success, error, setup) {
        var formData = new FormData();
        Object.keys(data).forEach(function (key) {
            formData.append(key, data[key]);
        });
        formData.append('file', file);
        formData.append('fileName', file.name);
        return request({
            method: 'post',
            url: url,
            data: formData,
            requestType: 'multipart/form-data',
            success: success,
            error: error,
            setup: setup,
        });
    };
})(httpClient || (httpClient = {}));

// CONCATENATED MODULE: ./engine/renderable/tsx/genetic/vEngineTsxComponent.ts
var VEngineTsxComponent = (function () {
    function VEngineTsxComponent(tsxDOMRenderer) {
        this.tsxDOMRenderer = tsxDOMRenderer;
    }
    VEngineTsxComponent.prototype.setState = function (newState) {
        var _this = this;
        Object.keys(newState).forEach(function (k) {
            _this.state[k] = newState[k];
        });
        if (this.rootNativeElement !== undefined)
            this.tsxDOMRenderer.render(this, this.rootNativeElement);
    };
    VEngineTsxComponent.prototype.triggerRendering = function () {
        this.tsxDOMRenderer.render(this, this.rootNativeElement);
    };
    VEngineTsxComponent.prototype.mountTo = function (root) {
        root.removeChildren();
        this.tsxDOMRenderer.render(this, root);
    };
    return VEngineTsxComponent;
}());


// CONCATENATED MODULE: ./engine/renderable/tsx/genetic/virtualNode.ts
var VirtualNode = (function () {
    function VirtualNode(props, tagName) {
        this.props = props;
        this.tagName = tagName;
        this.index = 0;
        this.loopIndex = undefined;
        this.type = 'virtualNode';
    }
    return VirtualNode;
}());


// CONCATENATED MODULE: ./engine/renderable/tsx/genetic/vEngineTsxFactory.h.ts

var flattenDeep = function (arr) {
    var res = arr.reduce(function (acc, val) {
        if (Array.isArray(val)) {
            val.forEach(function (v, i) { return v.loopIndex = i; });
            return acc.concat(flattenDeep(val));
        }
        else
            return acc.concat(val);
    }, []);
    return res;
};
var vEngineTsxFactory_h_VEngineTsxFactory = (function () {
    function VEngineTsxFactory() {
    }
    VEngineTsxFactory.createElement = function (item, props) {
        var children = [];
        for (var _i = 2; _i < arguments.length; _i++) {
            children[_i - 2] = arguments[_i];
        }
        if (props === null)
            props = {};
        if (item.call !== undefined) {
            return item(props);
        }
        var element = new VirtualNode(props, item);
        element.children =
            flattenDeep(children).
                map(function (it, i) {
                var _a, _b;
                if (((_a = it) === null || _a === void 0 ? void 0 : _a.substr) !== undefined || ((_b = it) === null || _b === void 0 ? void 0 : _b.toFixed) !== undefined) {
                    var textNode = new VirtualNode({}, undefined);
                    textNode.text = String(it);
                    return textNode;
                }
                else
                    return it;
            }).filter(function (it) { return !!it; });
        return element;
    };
    return VEngineTsxFactory;
}());


// CONCATENATED MODULE: ./engine/renderable/tsx/genetic/abstractTsxDOMRenderer.ts

var debug = false;
var abstractTsxDOMRenderer_AbstractTsxDOMRenderer = (function () {
    function AbstractTsxDOMRenderer(elementCreator) {
        this.elementCreator = elementCreator;
    }
    AbstractTsxDOMRenderer.prototype.render = function (component, root) {
        component.rootNativeElement = root;
        if (debug)
            console.log('before render');
        var newVirtualDom = component.render();
        var oldVirtualDom = component.oldVirtualDom;
        if (debug)
            console.log('erendere', { component: component, oldVirtualDom: oldVirtualDom, newVirtualDom: newVirtualDom });
        this.compareAndRenderElement(newVirtualDom, oldVirtualDom, root.getChildAt(0), root);
        component.oldVirtualDom = newVirtualDom;
    };
    AbstractTsxDOMRenderer.prototype.removeNode = function (node) {
        if (debug)
            console.log('remove', node);
        node.removeSelf();
    };
    AbstractTsxDOMRenderer.prototype.replaceNode = function (node, newVirtualNode, parent) {
        if (debug)
            console.log('replacing', newVirtualNode);
        var newNode = this.elementCreator.createElementByTagName(newVirtualNode);
        this.setGenericProps(newNode, newVirtualNode);
        parent.replaceChild(node, newNode);
        return newNode;
    };
    AbstractTsxDOMRenderer.prototype.updateNode = function (node, newVirtualNode) {
        if (debug)
            console.log('updating', newVirtualNode);
        this.setGenericProps(node, newVirtualNode);
    };
    AbstractTsxDOMRenderer.prototype.createNode = function (newVirtualNode, parent) {
        if (debug)
            console.log('created node', newVirtualNode);
        var node = this.elementCreator.createElementByTagName(newVirtualNode);
        this.setGenericProps(node, newVirtualNode);
        parent.appendChild(node);
        return node;
    };
    AbstractTsxDOMRenderer.prototype.compareAndRenderElement = function (newVirtualNode, oldVirtualNode, realNode, parent) {
        var newRealNode = realNode;
        if (newVirtualNode === undefined && oldVirtualNode !== undefined) {
            if (newRealNode !== undefined)
                this.removeNode(newRealNode);
        }
        else if (newVirtualNode !== undefined && oldVirtualNode !== undefined && newRealNode !== undefined) {
            if (newVirtualNode.index !== oldVirtualNode.index ||
                newVirtualNode.loopIndex !== oldVirtualNode.loopIndex ||
                newVirtualNode.tagName !== oldVirtualNode.tagName) {
                newRealNode = this.replaceNode(newRealNode, newVirtualNode, parent);
            }
            else {
                this.updateNode(newRealNode, newVirtualNode);
            }
        }
        else if (newVirtualNode !== undefined && (oldVirtualNode === undefined || newRealNode === undefined)) {
            newRealNode = this.createNode(newVirtualNode, parent);
        }
        if (newRealNode !== undefined)
            this.compareAndRenderChildren(newVirtualNode, oldVirtualNode, newRealNode);
        return newRealNode;
    };
    AbstractTsxDOMRenderer.prototype.compareAndRenderChildren = function (newVirtualNode, oldVirtualNode, parent) {
        var _a, _b, _c, _d, _e;
        var maxNumOfChild = ((_a = newVirtualNode === null || newVirtualNode === void 0 ? void 0 : newVirtualNode.children) === null || _a === void 0 ? void 0 : _a.length) || 0;
        if (oldVirtualNode) {
            var l = (_c = (_b = oldVirtualNode.children) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : 0;
            if (l > maxNumOfChild)
                maxNumOfChild = l;
        }
        var children = Object(tslib_es6["e" /* __spreadArrays */])(parent.getChildren());
        for (var i = 0; i < maxNumOfChild; i++) {
            var newVirtualChild = (_d = newVirtualNode === null || newVirtualNode === void 0 ? void 0 : newVirtualNode.children) === null || _d === void 0 ? void 0 : _d[i];
            var oldVirtualChild = (_e = oldVirtualNode === null || oldVirtualNode === void 0 ? void 0 : oldVirtualNode.children) === null || _e === void 0 ? void 0 : _e[i];
            this.compareAndRenderElement(newVirtualChild, oldVirtualChild, children[i], parent);
        }
    };
    AbstractTsxDOMRenderer.prototype.setGenericProps = function (model, virtualNode) {
        if (virtualNode.props.ref !== undefined)
            virtualNode.props.ref(model);
        this.elementCreator.setProps(model, virtualNode);
    };
    return AbstractTsxDOMRenderer;
}());


// CONCATENATED MODULE: ./engine/renderable/tsx/genetic/abstractElementCreator.ts
var AbstractElementCreator = (function () {
    function AbstractElementCreator() {
    }
    return AbstractElementCreator;
}());


// CONCATENATED MODULE: ./engine/renderable/tsx/dom/HTMLElementWrap.ts

var HTMLElementWrap_HTMLElementWrap = (function () {
    function HTMLElementWrap(htmlElement) {
        this.htmlElement = htmlElement;
        this.attributes = {};
    }
    HTMLElementWrap.prototype.appendChild = function (child) {
        if (this.htmlElement.styleSheet && !this.htmlElement.sheet) {
            this.htmlElement.styleSheet.cssText = child.htmlElement.data;
        }
        else
            this.htmlElement.appendChild(child.htmlElement);
    };
    HTMLElementWrap.prototype.removeSelf = function () {
        this.htmlElement.parentNode.removeChild(this.htmlElement);
        domElementCreator_ElementFactory.getInstance().onElementRemoved(this.htmlElement);
    };
    HTMLElementWrap.prototype.replaceChild = function (oldNode, newNode) {
        domElementCreator_ElementFactory.getInstance().onElementRemoved(oldNode.htmlElement);
        this.htmlElement.replaceChild(newNode.htmlElement, oldNode.htmlElement);
    };
    HTMLElementWrap.prototype.getChildAt = function (index) {
        if (this.htmlElement.nodeType === 3)
            return undefined;
        return wrap(this.htmlElement.childNodes[index]);
    };
    HTMLElementWrap.prototype.getChildren = function () {
        var arr = [];
        if (this.htmlElement.nodeType === 3)
            return arr;
        for (var i = 0, l = this.htmlElement.childNodes.length; i < l; i++) {
            var c = this.htmlElement.childNodes[i];
            arr.push(wrap(c));
        }
        return arr;
    };
    HTMLElementWrap.prototype.getParentNode = function () {
        return wrap(this.htmlElement.parentElement);
    };
    HTMLElementWrap.prototype.removeChildren = function () {
        if (this.htmlElement.nodeType === 3) {
            this.htmlElement.data = '';
        }
        this.htmlElement.innerHTML = '';
    };
    return HTMLElementWrap;
}());

var wrap = function (htmlElement) {
    return domElementCreator_ElementFactory.getInstance().getWrapByElement(htmlElement);
};

// CONCATENATED MODULE: ./engine/renderable/tsx/dom/domElementCreator.ts



var domElementCreator_ElementFactory = (function () {
    function ElementFactory() {
        this.elements = [];
        this.wrappers = [];
    }
    ElementFactory.getInstance = function () {
        return ElementFactory.instance;
    };
    ElementFactory.prototype.onElementCreated = function (el) {
        this.elements.push(el);
    };
    ElementFactory.prototype.onElementRemoved = function (el) {
        var indexOf = this.elements.indexOf(el);
        this.elements.splice(indexOf, 1);
        this.wrappers.splice(indexOf, 1);
    };
    ElementFactory.prototype.getWrapByElement = function (el) {
        var indexOf = this.elements.indexOf(el);
        this.wrappers[indexOf] = this.wrappers[indexOf] || new HTMLElementWrap_HTMLElementWrap(el);
        return this.wrappers[indexOf];
    };
    ElementFactory.instance = new ElementFactory();
    return ElementFactory;
}());

var domElementCreator_DomElementCreator = (function (_super) {
    Object(tslib_es6["c" /* __extends */])(DomElementCreator, _super);
    function DomElementCreator() {
        return _super.call(this) || this;
    }
    DomElementCreator.prototype.createElementByTagName = function (node) {
        var htmlNode;
        if (node.tagName === undefined) {
            htmlNode = document.createTextNode(node.text);
        }
        else {
            htmlNode = document.createElement(node.tagName);
        }
        domElementCreator_ElementFactory.getInstance().onElementCreated(htmlNode);
        return new HTMLElementWrap_HTMLElementWrap(htmlNode);
    };
    DomElementCreator.prototype.setProps = function (model, virtualNode) {
        var props = virtualNode.props;
        var el = model.htmlElement;
        if (el.nodeType === 3) {
            if (virtualNode.text !== model.attributes.text) {
                model.attributes.text = virtualNode.text;
                el.data = virtualNode.text;
            }
        }
        else {
            var htmlEl = el;
            for (var _i = 0, _a = Object.keys(props); _i < _a.length; _i++) {
                var key = _a[_i];
                if (key.indexOf('on') === 0) {
                    htmlEl[key] = props[key];
                }
                else if (model.attributes[key] !== props[key]) {
                    model.attributes[key] = props[key];
                    var attrName = key.toLowerCase();
                    if (key === 'htmlFor')
                        attrName = 'for';
                    else if (key === 'className')
                        attrName = 'class';
                    else if (key === 'ref') {
                        virtualNode.props.ref(el);
                        continue;
                    }
                    var value = props[key];
                    if (value === null || value === undefined)
                        htmlEl.removeAttribute(attrName);
                    else
                        htmlEl.setAttribute(attrName, props[key]);
                }
            }
        }
    };
    return DomElementCreator;
}(AbstractElementCreator));


// CONCATENATED MODULE: ./engine/renderable/tsx/dom/htmlTsxDOMRenderer.ts



var htmlTsxDOMRenderer_HtmlTsxDOMRenderer = (function (_super) {
    Object(tslib_es6["c" /* __extends */])(HtmlTsxDOMRenderer, _super);
    function HtmlTsxDOMRenderer() {
        return _super.call(this, new domElementCreator_DomElementCreator()) || this;
    }
    return HtmlTsxDOMRenderer;
}(abstractTsxDOMRenderer_AbstractTsxDOMRenderer));


// CONCATENATED MODULE: ./engine/debug/errorWidget.tsx





var css = "\n    .errorHeader {text-align: center;}\n    .errorText {\n        color: #ff8882;\n        white-space: pre-wrap;\n    }\n    .errorCol {color: #f30000;text-decoration: underline;}\n    .errorRow {\n        color: #bf1313;\n        font-weight: bold;\n    }\n    .errorBlockHolder {\n        background: #615f5fb8;\n        height: 100%;\n        bottom: 0;\n        left: 0;\n        right: 0;\n        top: 0;\n        position: absolute;\n    }\n    ::selection {\n            color: #efff00;\n            background-color: #127315;\n    }\n    .errorBlock {\n        border: 1px solid grey;\n        background-color: rgba(21, 15, 121, 0.88);\n        font-family: monospace;\n        -webkit-touch-callout: default;\n        color: #fffef8;\n    }\n    .errorBlock, .errorBlock * {\n        user-select: text;\n    }\n    .errorBlockInternal {\n        position: relative;\n        padding: 5px;\n        margin: 5px;\n        border: 1px solid #8f9624;\n        user-select: text;\n    }\n    .errorClose {\n        position: absolute;\n        top: 15px;\n        right: 5px;\n        content: 'x';\n        width: 20px;\n        height: 20px;\n        cursor: pointer;\n        color: white;\n    }\n";
var prettifyDebugInfo = function (debugInfo) {
    if (!debugInfo)
        return undefined;
    var strings = debugInfo.file.split('\n');
    var linesAfter = 5;
    var linesBefore = 5;
    var errorLine = strings[debugInfo.lineNum - 1] || '';
    var stringsBefore = strings.slice(Math.max(debugInfo.lineNum - 1 - linesBefore, 0), debugInfo.lineNum - 1);
    var stringsAfter = strings.slice(debugInfo.lineNum, debugInfo.lineNum + linesAfter);
    return (vEngineTsxFactory_h_VEngineTsxFactory.createElement("div", null,
        stringsBefore.map(function (s) { return vEngineTsxFactory_h_VEngineTsxFactory.createElement("div", null, s); }),
        vEngineTsxFactory_h_VEngineTsxFactory.createElement("div", { className: "errorRow" },
            vEngineTsxFactory_h_VEngineTsxFactory.createElement("span", null, errorLine.substr(0, debugInfo.colNum - 1)),
            vEngineTsxFactory_h_VEngineTsxFactory.createElement("span", { className: "errorCol" }, errorLine[debugInfo.colNum - 1]),
            vEngineTsxFactory_h_VEngineTsxFactory.createElement("span", null, errorLine.substr(debugInfo.colNum))),
        stringsAfter.map(function (s) { return vEngineTsxFactory_h_VEngineTsxFactory.createElement("div", null, s); })));
};
var errorWidget_ErrorWidget = (function (_super) {
    Object(tslib_es6["c" /* __extends */])(ErrorWidget, _super);
    function ErrorWidget() {
        var _this = _super.call(this, new htmlTsxDOMRenderer_HtmlTsxDOMRenderer()) || this;
        _this.state = {
            errors: []
        };
        return _this;
    }
    ErrorWidget.prototype.addError = function (err) {
        this.state.errors.push(err);
        this.setState(Object(tslib_es6["a" /* __assign */])({}, this.state));
    };
    ErrorWidget.prototype.removeItem = function (i) {
        this.state.errors.splice(i, 1);
        this.setState(Object(tslib_es6["a" /* __assign */])({}, this.state));
    };
    ErrorWidget.prototype.render = function () {
        var _this = this;
        return (vEngineTsxFactory_h_VEngineTsxFactory.createElement("div", null,
            vEngineTsxFactory_h_VEngineTsxFactory.createElement("style", null, css),
            vEngineTsxFactory_h_VEngineTsxFactory.createElement("div", { className: this.state.errors.length > 0 ? 'errorBlockHolder' : '' }, this.state.errors.map(function (err, i) {
                return vEngineTsxFactory_h_VEngineTsxFactory.createElement("div", { className: "errorBlock" },
                    vEngineTsxFactory_h_VEngineTsxFactory.createElement("div", { className: "errorBlockInternal" },
                        vEngineTsxFactory_h_VEngineTsxFactory.createElement("div", { className: "errorClose", onclick: function () { return _this.removeItem(i); } }, "x"),
                        vEngineTsxFactory_h_VEngineTsxFactory.createElement("h3", { className: "errorText" }, err.runtimeInfo),
                        vEngineTsxFactory_h_VEngineTsxFactory.createElement("div", null, err.filename),
                        vEngineTsxFactory_h_VEngineTsxFactory.createElement("div", null, "-------------------"),
                        vEngineTsxFactory_h_VEngineTsxFactory.createElement("pre", null, prettifyDebugInfo(err.debugInfo))));
            }))));
    };
    return ErrorWidget;
}(VEngineTsxComponent));

var errorWidget;
var renderError = function (error) {
    if (errorWidget === undefined) {
        errorWidget = new errorWidget_ErrorWidget();
        var errDiv = document.createElement('div');
        document.body.appendChild(errDiv);
        errorWidget.mountTo(new HTMLElementWrap_HTMLElementWrap(errDiv));
    }
    errorWidget.addError(error);
};

// CONCATENATED MODULE: ./engine/debug/debug.ts



var devConsole = document.createElement('div');
var debug_css = {
    "position": 'absolute',
    "right": 0,
    "top": 0,
    'background-color': 'black',
    'min-width': '20px',
    'min-height': '20px',
    'opacity': 0.5,
    'pointer-events': 'none',
    'display': 'block',
    'z-index': 1000
};
Object.keys(debug_css).forEach(function (key) { return devConsole.style.setProperty(key, '' + debug_css[key]); });
var fpsLabel = document.createElement('span');
fpsLabel.style.cssText = 'color:white;user-select: none;';
devConsole.appendChild(fpsLabel);
var tmr;
var onLoad = function (fn) {
    if (document.readyState === 'complete')
        fn();
    else {
        window.addEventListener('load', function (e) {
            fn();
        });
    }
};
onLoad(function () {
    document.body.appendChild(devConsole);
    tmr = setInterval(function () {
        var game = window.game;
        if (!game)
            return;
        fpsLabel.textContent = 'fps:' + ("" + game.fps) || false;
    }, 1000);
});
var prepareMessage = function (e, lineNum) {
    var msg;
    if (typeof e === 'string') {
        msg = e;
    }
    else
        msg = e.message || e.reason || e.error;
    if (msg && msg.message)
        msg = msg.message;
    if (!msg) {
        if (e.target) {
            ['img', 'audio', 'link', 'script'].some(function (it) {
                if (e.target.tagName && e.target.tagName.toLowerCase() === it) {
                    msg = "can not load " + it + " with location " + (e.target.src || e.target.href);
                    return true;
                }
                return false;
            });
        }
    }
    if (!msg)
        msg = '';
    if (msg.indexOf('Uncaught') === 0)
        msg = msg.replace('Uncaught', '').trim();
    if (!msg) {
        msg = 'Unknown error: ' + e.toString();
    }
    if (lineNum)
        msg = "error in line " + lineNum + ":  " + msg;
    return msg;
};
var stopGame = function () {
    clearInterval(tmr);
    var game = window.game;
    if (game) {
        try {
            game.destroy();
        }
        catch (e) {
            console.error(e);
        }
    }
};
var handleCatchError = function (e) { return Object(tslib_es6["b" /* __awaiter */])(void 0, void 0, void 0, function () {
    var lineNum, runtimeInfo, colNum, filename, file, e_1;
    return Object(tslib_es6["d" /* __generator */])(this, function (_a) {
        switch (_a.label) {
            case 0:
                lineNum = e.lineno;
                runtimeInfo = prepareMessage(e, lineNum);
                colNum = e.colno;
                filename = e.filename;
                if (!filename) return [3, 5];
                _a.label = 1;
            case 1:
                _a.trys.push([1, 3, , 4]);
                return [4, httpClient.get(filename, { r: Math.random() })];
            case 2:
                file = _a.sent();
                if (file)
                    renderError({ filename: filename, runtimeInfo: runtimeInfo, debugInfo: { file: file, colNum: colNum, lineNum: lineNum } });
                else
                    renderError({ runtimeInfo: runtimeInfo });
                return [3, 4];
            case 3:
                e_1 = _a.sent();
                renderError({ runtimeInfo: runtimeInfo });
                return [3, 4];
            case 4: return [3, 6];
            case 5:
                renderError({ runtimeInfo: runtimeInfo });
                _a.label = 6;
            case 6: return [2];
        }
    });
}); };
var extractPromiseError = function (e) {
    var r = 'Async error\n';
    if (e.substr !== undefined)
        r += e;
    if (e.message)
        r += e.message + "\n";
    if (e.stack)
        r += e.stack;
    return r;
};
window.addEventListener('error', function (e) { return Object(tslib_es6["b" /* __awaiter */])(void 0, void 0, void 0, function () {
    return Object(tslib_es6["d" /* __generator */])(this, function (_a) {
        switch (_a.label) {
            case 0:
                console.error(e);
                stopGame();
                return [4, handleCatchError(e)];
            case 1:
                _a.sent();
                return [2];
        }
    });
}); }, true);
window.addEventListener('unhandledrejection', function (e) {
    console.error(e);
    stopGame();
    renderError({ filename: '', runtimeInfo: extractPromiseError(e.reason) });
});


/***/ })

/******/ });