// modules are defined as an array
// [ module function, map of requires ]
//
// map of requires is short require name -> numeric require
//
// anything defined in a previous bundle is accessed via the
// orig method which is the require for previous bundles

(function(modules, cache, entry, mainEntry, parcelRequireName, globalName) {
  /* eslint-disable no-undef */
  var globalObject =
    typeof globalThis !== 'undefined'
      ? globalThis
      : typeof self !== 'undefined'
      ? self
      : typeof window !== 'undefined'
      ? window
      : typeof global !== 'undefined'
      ? global
      : {};
  /* eslint-enable no-undef */

  // Save the require from previous bundle to this closure if any
  var previousRequire =
    typeof globalObject[parcelRequireName] === 'function' &&
    globalObject[parcelRequireName];
  // Do not use `require` to prevent Webpack from trying to bundle this call
  var nodeRequire =
    typeof module !== 'undefined' &&
    typeof module.require === 'function' &&
    module.require.bind(module);

  function newRequire(name, jumped) {
    if (!cache[name]) {
      if (!modules[name]) {
        // if we cannot find the module within our internal map or
        // cache jump to the current global require ie. the last bundle
        // that was added to the page.
        var currentRequire =
          typeof globalObject[parcelRequireName] === 'function' &&
          globalObject[parcelRequireName];
        if (!jumped && currentRequire) {
          return currentRequire(name, true);
        }

        // If there are other bundles on this page the require from the
        // previous one is saved to 'previousRequire'. Repeat this as
        // many times as there are bundles until the module is found or
        // we exhaust the require chain.
        if (previousRequire) {
          return previousRequire(name, true);
        }

        // Try the node require function if it exists.
        if (nodeRequire && typeof name === 'string') {
          return nodeRequire(name);
        }

        var err = new Error("Cannot find module '" + name + "'");
        err.code = 'MODULE_NOT_FOUND';
        throw err;
      }

      localRequire.resolve = resolve;
      localRequire.cache = {};

      var module = (cache[name] = new newRequire.Module(name));

      modules[name][0].call(
        module.exports,
        localRequire,
        module,
        module.exports,
        this
      );
    }

    return cache[name].exports;

    function localRequire(x) {
      return newRequire(localRequire.resolve(x));
    }

    function resolve(x) {
      return modules[name][1][x] || x;
    }
  }

  function Module(moduleName) {
    this.id = moduleName;
    this.bundle = newRequire;
    this.exports = {};
  }

  newRequire.isParcelRequire = true;
  newRequire.Module = Module;
  newRequire.modules = modules;
  newRequire.cache = cache;
  newRequire.parent = previousRequire;
  newRequire.register = function(id, exports) {
    modules[id] = [
      function(require, module) {
        module.exports = exports;
      },
      {},
    ];
  };

  Object.defineProperty(newRequire, 'root', {
    get: function() {
      return globalObject[parcelRequireName];
    },
  });

  globalObject[parcelRequireName] = newRequire;

  for (var i = 0; i < entry.length; i++) {
    newRequire(entry[i]);
  }

  if (mainEntry) {
    // Expose entry point to Node, AMD or browser globals
    // Based on https://github.com/ForbesLindesay/umd/blob/master/template.js
    var mainExports = newRequire(mainEntry);

    // CommonJS
    if (typeof exports === 'object' && typeof module !== 'undefined') {
      module.exports = mainExports;

      // RequireJS
    } else if (typeof define === 'function' && define.amd) {
      define(function() {
        return mainExports;
      });

      // <script>
    } else if (globalName) {
      this[globalName] = mainExports;
    }
  }
})({"5KyeU":[function(require,module,exports) {
var HMR_HOST = null;
var HMR_PORT = 1234;
var HMR_ENV_HASH = "d751713988987e9331980363e24189ce";
module.bundle.HMR_BUNDLE_ID = "0b9eaa696c0a67ab3eafffda65c0ba6f";
/* global HMR_HOST, HMR_PORT, HMR_ENV_HASH */

var OVERLAY_ID = '__parcel__error__overlay__';
var OldModule = module.bundle.Module;

function Module(moduleName) {
  OldModule.call(this, moduleName);
  this.hot = {
    data: module.bundle.hotData,
    _acceptCallbacks: [],
    _disposeCallbacks: [],
    accept: function (fn) {
      this._acceptCallbacks.push(fn || function () {});
    },
    dispose: function (fn) {
      this._disposeCallbacks.push(fn);
    }
  };
  module.bundle.hotData = null;
}

module.bundle.Module = Module;
var checkedAssets, assetsToAccept, acceptedAssets;

function getHostname() {
  return HMR_HOST || (location.protocol.indexOf('http') === 0 ? location.hostname : 'localhost');
}

function getPort() {
  return HMR_PORT || location.port;
} // eslint-disable-next-line no-redeclare


var parent = module.bundle.parent;

if ((!parent || !parent.isParcelRequire) && typeof WebSocket !== 'undefined') {
  var hostname = getHostname();
  var port = getPort();
  var protocol = location.protocol === 'https:' ? 'wss' : 'ws';
  var ws = new WebSocket(protocol + '://' + hostname + (port ? ':' + port : '') + '/');

  ws.onmessage = function (event) {
    checkedAssets = {};
    assetsToAccept = [];
    acceptedAssets = {};
    var data = JSON.parse(event.data);

    if (data.type === 'update') {
      // Remove error overlay if there is one
      removeErrorOverlay();
      let assets = data.assets.filter(asset => asset.envHash === HMR_ENV_HASH); // Handle HMR Update

      var handled = false;
      assets.forEach(asset => {
        var didAccept = asset.type === 'css' || hmrAcceptCheck(module.bundle.root, asset.id);

        if (didAccept) {
          handled = true;
        }
      });

      if (handled) {
        console.clear();
        assets.forEach(function (asset) {
          hmrApply(module.bundle.root, asset);
        });

        for (var i = 0; i < assetsToAccept.length; i++) {
          var id = assetsToAccept[i][1];

          if (!acceptedAssets[id]) {
            hmrAcceptRun(assetsToAccept[i][0], id);
          }
        }
      } else {
        window.location.reload();
      }
    }

    if (data.type === 'error') {
      // Log parcel errors to console
      for (let ansiDiagnostic of data.diagnostics.ansi) {
        let stack = ansiDiagnostic.codeframe ? ansiDiagnostic.codeframe : ansiDiagnostic.stack;
        console.error('🚨 [parcel]: ' + ansiDiagnostic.message + '\n' + stack + '\n\n' + ansiDiagnostic.hints.join('\n'));
      } // Render the fancy html overlay


      removeErrorOverlay();
      var overlay = createErrorOverlay(data.diagnostics.html);
      document.body.appendChild(overlay);
    }
  };

  ws.onerror = function (e) {
    console.error(e.message);
  };

  ws.onclose = function (e) {
    console.warn('[parcel] 🚨 Connection to the HMR server was lost');
  };
}

function removeErrorOverlay() {
  var overlay = document.getElementById(OVERLAY_ID);

  if (overlay) {
    overlay.remove();
    console.log('[parcel] ✨ Error resolved');
  }
}

function createErrorOverlay(diagnostics) {
  var overlay = document.createElement('div');
  overlay.id = OVERLAY_ID;
  let errorHTML = '<div style="background: black; opacity: 0.85; font-size: 16px; color: white; position: fixed; height: 100%; width: 100%; top: 0px; left: 0px; padding: 30px; font-family: Menlo, Consolas, monospace; z-index: 9999;">';

  for (let diagnostic of diagnostics) {
    let stack = diagnostic.codeframe ? diagnostic.codeframe : diagnostic.stack;
    errorHTML += "\n      <div>\n        <div style=\"font-size: 18px; font-weight: bold; margin-top: 20px;\">\n          \uD83D\uDEA8 ".concat(diagnostic.message, "\n        </div>\n        <pre>\n          ").concat(stack, "\n        </pre>\n        <div>\n          ").concat(diagnostic.hints.map(hint => '<div>' + hint + '</div>').join(''), "\n        </div>\n      </div>\n    ");
  }

  errorHTML += '</div>';
  overlay.innerHTML = errorHTML;
  return overlay;
}

function getParents(bundle, id) {
  var modules = bundle.modules;

  if (!modules) {
    return [];
  }

  var parents = [];
  var k, d, dep;

  for (k in modules) {
    for (d in modules[k][1]) {
      dep = modules[k][1][d];

      if (dep === id || Array.isArray(dep) && dep[dep.length - 1] === id) {
        parents.push([bundle, k]);
      }
    }
  }

  if (bundle.parent) {
    parents = parents.concat(getParents(bundle.parent, id));
  }

  return parents;
}

function updateLink(link) {
  var newLink = link.cloneNode();

  newLink.onload = function () {
    if (link.parentNode !== null) {
      link.parentNode.removeChild(link);
    }
  };

  newLink.setAttribute('href', link.getAttribute('href').split('?')[0] + '?' + Date.now());
  link.parentNode.insertBefore(newLink, link.nextSibling);
}

var cssTimeout = null;

function reloadCSS() {
  if (cssTimeout) {
    return;
  }

  cssTimeout = setTimeout(function () {
    var links = document.querySelectorAll('link[rel="stylesheet"]');

    for (var i = 0; i < links.length; i++) {
      var href = links[i].getAttribute('href');
      var hostname = getHostname();
      var servedFromHMRServer = hostname === 'localhost' ? new RegExp('^(https?:\\/\\/(0.0.0.0|127.0.0.1)|localhost):' + getPort()).test(href) : href.indexOf(hostname + ':' + getPort());
      var absolute = /^https?:\/\//i.test(href) && href.indexOf(window.location.origin) !== 0 && !servedFromHMRServer;

      if (!absolute) {
        updateLink(links[i]);
      }
    }

    cssTimeout = null;
  }, 50);
}

function hmrApply(bundle, asset) {
  var modules = bundle.modules;

  if (!modules) {
    return;
  }

  if (modules[asset.id] || !bundle.parent) {
    if (asset.type === 'css') {
      reloadCSS();
    } else {
      var fn = new Function('require', 'module', 'exports', asset.output);
      modules[asset.id] = [fn, asset.depsByBundle[bundle.HMR_BUNDLE_ID]];
    }
  } else if (bundle.parent) {
    hmrApply(bundle.parent, asset);
  }
}

function hmrAcceptCheck(bundle, id) {
  var modules = bundle.modules;

  if (!modules) {
    return;
  }

  if (!modules[id] && bundle.parent) {
    return hmrAcceptCheck(bundle.parent, id);
  }

  if (checkedAssets[id]) {
    return;
  }

  checkedAssets[id] = true;
  var cached = bundle.cache[id];
  assetsToAccept.push([bundle, id]);

  if (cached && cached.hot && cached.hot._acceptCallbacks.length) {
    return true;
  }

  return getParents(module.bundle.root, id).some(function (v) {
    return hmrAcceptCheck(v[0], v[1]);
  });
}

function hmrAcceptRun(bundle, id) {
  var cached = bundle.cache[id];
  bundle.hotData = {};

  if (cached && cached.hot) {
    cached.hot.data = bundle.hotData;
  }

  if (cached && cached.hot && cached.hot._disposeCallbacks.length) {
    cached.hot._disposeCallbacks.forEach(function (cb) {
      cb(bundle.hotData);
    });
  }

  delete bundle.cache[id];
  bundle(id);
  cached = bundle.cache[id];

  if (cached && cached.hot && cached.hot._acceptCallbacks.length) {
    cached.hot._acceptCallbacks.forEach(function (cb) {
      var assetsToAlsoAccept = cb(function () {
        return getParents(module.bundle.root, id);
      });

      if (assetsToAlsoAccept && assetsToAccept.length) {
        assetsToAccept.push.apply(assetsToAccept, assetsToAlsoAccept);
      }
    });
  }

  acceptedAssets[id] = true;
}
},{}],"6Ewdz":[function(require,module,exports) {
"use strict";

var _ui = _interopRequireDefault(require("../../ui"));

var _App = _interopRequireDefault(require("./App"));

require("./css/qeeq-std.css");

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

window.addEventListener('load', () => _ui.default.mount(_App.default, document.getElementById('root')));
},{"../../ui":"4uGQj","./App":"7v5Ej","./css/qeeq-std.css":"5hW4H"}],"4uGQj":[function(require,module,exports) {
const View = require("./view_base");

require("./view");

const VNode = require("./vnode_base");

require("./vnode");

const mount = require("./mount");
/**
 * @type {View.create}
 */


const createComponent = View.create;
/**
 * @type {function(*, *=): [VNode]}
 */

const jsx = VNode.create;
/**
 *
 * @type {{createComponent: View.create, View: View, mount: function(*=, *=): void, jsx: (function(*, *=): VNode[])}}
 */

module.exports = {
  View,
  createComponent,
  jsx,
  mount
};
},{"./view":"3eX0e","./vnode":"tDSLT","./mount":"zeW0D","./view_base":"4uAoY","./vnode_base":"6Oqbo"}],"3eX0e":[function(require,module,exports) {
const normalizeNodes = require("./normalizeNodes");

const {
  updateViewRoot
} = require("./patch");

const View = require("./view_base");

const {
  sameProps
} = require("./util");

const {
  isObj
} = require("../core/types");

const {
  deepClone,
  concat
} = require("../core/collections");

const {
  randomId
} = require("./util");

const {
  debounce
} = require("../core/functions");

View.prototype.$update = debounce(() => {
  this.$isDirty = true;

  if (window.requestAnimationFrame) {
    requestAnimationFrame(() => {
      // if (!this.$isDirty) return;
      updateViewRoot(this);
    });
  } else {
    updateViewRoot(this);
  } // console.log('done')

}, 20);

View.prototype.$createInstance = function (props, children) {
  const construct = this.$constructor;
  const name = this.$name;
  let inst = new View(construct, construct);
  inst.$name = name;
  inst.$instanceId = randomId();
  Object.keys(inst).forEach(pname => {
    if (inst[pname] instanceof Function) {
      inst[pname] = inst[pname].bind(inst);
    }
  });
  inst.$useStateCount = 0;
  inst.$useStates = [];
  return inst.$updateInstance(props, children);
};

View.prototype.$updateInstance = function (props, children, parent) {
  if (!this.props) this.props = {};

  if (props) {
    concat(this.props, props, true);
  }

  if (children) children = normalizeNodes(children, parent, this, false);
  this.$children = children;
  this.$instanceId = randomId(); // this.$isDirty = false;
  // console.warn("$update "+this.$instanceId+" "+name, this.state)

  this.$update = debounce(() => {
    this.$isDirty = true;

    if (window.requestAnimationFrame) {
      requestAnimationFrame(() => {
        // if (!this.$isDirty) return;
        updateViewRoot(this);
      });
    } else {
      updateViewRoot(this);
    } // console.log('done')

  }, 20);
  return this;
};

View.prototype.$render = function (parent, view, initial = true) {
  if (initial && !this.$raw) return this;
  let rendered = View.$callRender(this); // if (rendered.length === 0) {
  //     rendered = [VNode.create('slot', {})];
  // }

  View.$setNodes(this, rendered, true); // console.log(this.$name, this.$nodes)

  this.$parent = parent;
  this.$view = view;
  this.$raw = false;
  return this;
};

View.$setNodes = function (view, nodes, normalize) {
  // if (nodes.length === 0) nodes = [VNode.createTag('slot')];
  if (normalize) view.$nodes = normalizeNodes(nodes, view, view, true);else view.$nodes = nodes;
  view.$count = view.$nodes.length;

  if (!(view.$empty = view.$count === 0)) {
    view.$first = view.$nodes[0];
  }

  if (view.$count === 1) {
    view.$single = true;
  }
};

View.$shouldUpdateDefault = function (viewInstance, newProps) {
  return viewInstance.$isDirty || !sameProps(viewInstance.props, newProps);
};

View.prototype.shouldUpdate = function (newProps) {
  return View.$shouldUpdateDefault(this, newProps);
};

View.prototype.$ref = function (ref) {
  if (!this.$refs) {
    this.$refs = {};
  }

  let refChild = this.$refs[ref];
  if (this.props && this.props.ref === ref) return this;

  if (this.$nodes) {
    for (let index = 0; index < this.$nodes.length && refChild === undefined; index++) {
      refChild = this.$nodes[index].$ref(ref);
    }
  }

  this.$refs[ref] = refChild;
  return refChild;
};

View.prototype.$removeDom = function (rootRemoved) {
  if (this.$single) {
    this.$element.remove();
    rootRemoved = true;
  }

  this.$nodes.forEach(n => n.$removeDom(rootRemoved));
  this.$dispatchLifeCycle('onDestroy');
};

View.prototype.$renderDom = function (targetElement, parent) {
  this.$parent = parent;
  this.$rootElement = targetElement;

  for (let i = 0; i < this.$count; i++) {
    targetElement.append(this.$nodes[i].$renderDom());
  }
};

View.prototype.$clone = function (parent, view) {
  let cl = this.$createInstance(deepClone(this.props), this.$children.map(ch => ch.$clone()));
  return cl.$render(parent, view || cl);
};

View.prototype.$serialize = function () {
  return deepClone(this, {
    excludeKeys: ['$parent', '$first', '$view', '$element', '$rootElement']
  });
};

View.prototype.$dispatchLifeCycle = function (name, ...args) {
  let lifecycleMethod = this[name];

  if (lifecycleMethod instanceof Function) {
    setTimeout(lifecycleMethod, 1, ...args);
  }
};

View.prototype.setState = function (setter) {
  if (setter instanceof Function) setter = setter.call(this, this.state);

  if (isObj(setter)) {
    concat(this.state, setter, true);
  }

  this.$update();
};

View.prototype.useState = function useState(initial) {
  let index = this.$useStateIndex;

  if (index === this.$useStateCount) {
    this.$useStates.push(initial);
    this.$useStateCount += 1;
  }

  this.$useStateIndex += 1;
  return [this.$useStates[index], val => {
    this.$useStates[index] = val;
    this.$isDirty = true;
    this.$update();
  }];
};

View.prototype.useEffect = function useEffect(func) {
  this.onUpdate = func;
};
/**
 * @type {View}
 */


module.exports = View;
},{"./normalizeNodes":"6bvsv","./patch":"2x5EZ","../core/functions":"45TqM","./view_base":"4uAoY","../core/collections":"5lqP4","./util":"3ujPW","../core/types":"5jEMv"}],"6bvsv":[function(require,module,exports) {
const {
  isPrim,
  isVal
} = require("../core/types");

const {
  error
} = require("../core/logging");

const View = require("./view_base");

const VNode = require("./vnode_base");

module.exports = function normalizeNodes(nodes = [], parent, view, render = false) {
  let normalizedNodes = []; // console.error(parent, nodes)

  if (!(nodes instanceof Array)) nodes = [nodes];

  try {
    for (let i = 0; i < nodes.length; i++) {
      let node = nodes[i]; // replace text

      if (!isVal(node)) node = "" + node;

      if (isPrim(node)) {
        let n = VNode.createText(node.toString());
        n.$parent = parent;
        normalizedNodes.push(n);
        continue;
      }

      if (node.$isView) {
        normalizedNodes.push(render ? node.$render(parent, node) : node);
        continue;
      } // skip fragments


      if (node.$frag) node = node.$nodes; // flatten array or non-view fragment

      if (node instanceof Array) {
        let nn = normalizeNodes(node, parent, view, render);

        for (let j = 0; j < nn.length; j++) {
          normalizedNodes.push(render ? nn[j].$render(parent, view) : nn[j]);
        }
      } else {
        if (!node.$isView && node instanceof Function) {
          node = View.create(node.name, {
            render: node
          });
          node.$parent = parent;
        } else if (!node.$isNode) {
          node = VNode.createText("" + node);
          node.$parent = parent;
        }

        normalizedNodes.push(render ? node.$render(parent, view) : node);
      }
    }

    return normalizedNodes;
  } catch (e) {
    if ("development" === 'development') {
      let n = VNode.createTag('div', {
        style: "color: red!important; border: 3px dashed orange!important"
      }, e.toString());
      n.$parent = parent;
      return [n];
    } else {
      error(e);
      return [];
    }
  }
};
},{"../core/types":"5jEMv","../core/logging":"2ERs7","./view_base":"4uAoY","./vnode_base":"6Oqbo"}],"5jEMv":[function(require,module,exports) {
/**
 * @module core/types
 * @memberOf core
 */

/**
 * If is class or function return class/function name else returns typeof
 * @param x
 * @return {"undefined"|"object"|"boolean"|"number"|"string"|"function"|"symbol"|"bigint"|*}
 */
function typeName(x) {
  if (x.hasOwnProperty('constructor')) {
    return x.constructor.name;
  }

  return typeof x;
}
/** Is undefined
 * @param x
 * @returns {boolean}
 */


function isUnd(x) {
  return x !== null && x === undefined;
}
/** Is null
 * @param x
 * @return {boolean}
 */


function isNull(x) {
  return x === null;
}
/** Is value !null && !undefined
 * @param x
 * @return {boolean|boolean}
 */


function isVal(x) {
  return !isUnd(x) && !isNull(x);
}
/** Is number
 * @param x
 * @return {boolean}
 */


function isNum(x) {
  return typeof x === "number";
}
/** Is string|String
 * @param x
 * @return {boolean}
 */


function isStr(x) {
  return typeof x === "string" || x instanceof String;
}
/** Is function
 * @param x
 * @return {boolean}
 */


function isFun(x) {
  return typeof x === "function";
}
/** Is object
 * @param x
 * @return {boolean|boolean}
 */


function isObj(x) {
  return x !== null && typeof x === "object";
}
/** Is Array
 * @param x
 * @return {boolean}
 */


function isArr(x) {
  return x instanceof Array;
}
/** Is primitive isVal && !isObj && !isFun
 * @param x
 * @return {boolean}
 */


function isPrim(x) {
  return isVal(x) && !isObj(x) && !isFun(x) || typeof x === 'symbol';
}
/** Is List (has length property and item() function)
 * @param x
 * @return {boolean|boolean}
 */


function isList(x) {
  return isVal(x.length) && isFun(x.item);
}
/** Is MutableList (has length property, item() and add() functions)
 * @param x
 * @return {boolean}
 */


function isMutableList(x) {
  return isVal(x.length) && isFun(x.item) && isFun(x.add);
}
/** Is Set type
 * @param x
 * @return {boolean}
 */


function isSet(x) {
  return x instanceof Set;
}
/** Is Map type
 * @param x
 * @return {boolean}
 */


function isMap(x) {
  return x instanceof Map;
}
/** Is Error type
 * @param x
 * @return {boolean}
 */


function isError(x) {
  return x instanceof Error;
}
/** Is Element/Node
 * @param x
 * @return {boolean}
 */


function isEl(x) {
  return x instanceof Element || x instanceof HTMLElement || x instanceof Node;
}
/** Is NodeList || HTMLCollection
 * @param x
 * @return {boolean}
 */


function isEls(x) {
  return x instanceof HTMLCollection || x instanceof NodeList;
}
/**
 * Object has field
 * @param {Object} obj - source object
 * @param {String} field - field/property name
 * @param {Function} [pred] - optional predicate function to check field
 * @return {boolean}
 */


function hasField(obj, field, pred) {
  if (!isVal(obj)) return false;

  if (isFun(pred)) {
    return pred(obj[field]);
  }

  return obj.hasOwnProperty(field);
}
/** Is Empty Array/List/Object/String
 * @param x
 * @return {boolean}
 */


function isEmpty(x) {
  if (hasField(x, 'length')) return x.length <= 0;
  if (isFun(x)) return false;
  if (isObj(x)) return Object.keys(x).length <= 0;
  return true;
}
/**
 * Custom Enum implementation
 *
 * @param src {Object | String[]}
 * @return {Object}
 * @constructor
 */


function Enum(src) {
  let c = 0;
  let MAP = {};

  for (let i of Object.keys(src)) {
    MAP[MAP[c] = i] = c++;
  }

  return MAP;
}
/**
 * Deserialize sequence of key values (key, value, ...) into an object
 *
 * @param {any} args - key{String}, value{*} sequence
 * @return {Object}
 */


function dict(...args) {
  let o = {};

  for (let i = 0; i < args.length; i++) {
    if (i % 2 !== 0) continue;
    o[args[i]] = args[i + 1];
  }

  return o;
}

module.exports = {
  typeName,
  isUnd,
  isNull,
  isVal,
  isNum,
  isStr,
  isFun,
  isObj,
  isArr,
  isPrim,
  isList,
  isMutableList,
  isSet,
  isMap,
  isError,
  isEl,
  isEls,
  hasField,
  isEmpty,
  Enum,
  dict
};
},{}],"2ERs7":[function(require,module,exports) {
// const {Enum} = require("./types");

/**
 * @module core/logging
 * @memberOf core
 */

/** @private */
function _logTime() {
  let t = new Date();
  return `${t.getHours()}:${t.getMinutes()}:${t.getSeconds()}:${t.getMilliseconds()}`;
}
/** @private */


function _logTitle(flag) {
  return `[${flag}] [${_logTime()}]`;
}
/** @private */


function _prepareLog(args, lt) {
  args.reverse();
  args.push("display: inline-block; font-weight: bold; color: black", "%c" + lt);
  args.reverse();
}
/**
 * @type {Object}
 */


const LogLevels = {
  TRACE: 0,
  INFO: 1,
  WARN: 2,
  ERROR: 3,
  SILENT: -1
};
/**
 * Log config
 * @type {{LogLevel: *}}
 */

const Config = {
  LogLevel: LogLevels.TRACE
};
/** Set `Config.LogLevel` to TRACE */

function showTrace() {
  Config.LogLevel = LogLevels.TRACE;
}
/** Set `Config.LogLevel` to INFO */


function showInfo() {
  Config.LogLevel = LogLevels.INFO;
}
/** Set `Config.LogLevel` to WARN */


function showWarn() {
  Config.LogLevel = LogLevels.WARN;
}
/** Set `Config.LogLevel` to ERROR */


function showError() {
  Config.LogLevel = LogLevels.ERROR;
}
/** Set `Config.LogLevel` to SILENT */


function silent() {
  Config.LogLevel = LogLevels.SILENT;
}
/** Set Config.LogLevel
 * @param l - LogLevel */


function lvl(l) {
  return Config.LogLevel !== LogLevels.SILENT && Config.LogLevel <= l;
}
/**
 * Log Trace
 * @param {any} args
 */


function trace(...args) {
  if (!lvl(LogLevels.TRACE)) return;
  args.reverse();
  args.push(_logTitle("🔍 TRACE"));
  args.reverse(); // args.push("\n");

  console.trace.apply(this, args);
}
/**
 * Log Info
 * @param {any} args
 */


function info(...args) {
  if (!lvl(LogLevels.INFO)) return;

  _prepareLog(args, _logTitle("🔵 INFO"));

  console.log.apply(this, args);
}
/**
 * Log Warning
 * @param {any} args
 */


function warn(...args) {
  if (!lvl(LogLevels.WARN)) return;

  _prepareLog(args, _logTitle("🚨 WARN"));

  console.warn.apply(this, args);
}
/**
 * Log Error
 * @param {any} args
 */


function error(...args) {
  if (!lvl(LogLevels.ERROR)) return;

  _prepareLog(args, _logTitle("💥 ERROR"));

  console.error.apply(this, args);
}

module.exports = {
  Config,
  LogLevels,
  showTrace,
  showInfo,
  showWarn,
  showError,
  silent,
  trace,
  info,
  warn,
  error
};
},{}],"4uAoY":[function(require,module,exports) {
// import VNode, {NodeType} from "./vnode";
const NodeType = require("./nodetype"); // const VNode = require("./vnode");
// import {concat, deepClone} from "../core/collections";


const {
  deepClone
} = require("../core/collections"); // import { error, info, showError, showInfo} from "../core/logging";
// import {debounce} from "../core/functions";
// const {debounce} = require("../core/functions");
// import {normalizeNodes, randomId, sameProps} from "./util";
// const {randomId, sameProps} = require("./util");
// import {updateViewRoot} from "./patch";
// import {isObj} from "../core/types";
// const {isObj} = require("../core/types");


function View(opt = {}, construct = opt) {
  this.$type = NodeType.VIEW; // derived class

  this.$name = this.constructor.name;
  this.$isView = true;
  this.$nodes = undefined;
  this.$isDirty = true;
  this.$raw = true;
  this.$constructor = construct;
  let cons = Object.getOwnPropertyNames(this.$constructor);

  for (let i = 0; i < cons.length; i++) {
    const prop = cons[i];

    if (this.$constructor[prop] instanceof Function) {
      this[prop] = this.$constructor[prop];
    } else {
      this[prop] = deepClone(this.$constructor[prop]);
    }
  } // Object.defineProperty(this, '$update', {
  //     value: ,
  //     enumerable: false,
  //     configurable: false,
  //     writable: false
  // })

}

View.create = function (name, opt) {
  let c = new View(opt);
  if (!opt.render) console.warn("render method is not defined");
  c.$name = name;
  return c;
};

View.$callRender = function (view) {
  view.$useStateIndex = 0;
  return view.render.call(view, view.props);
};

module.exports = View; // export default View
},{"./nodetype":"4z0fH","../core/collections":"5lqP4"}],"4z0fH":[function(require,module,exports) {
const NodeType = {
  VNODE: 0,
  VIEW: 1,
  TEXT: 2
};
module.exports = NodeType;
},{}],"5lqP4":[function(require,module,exports) {
var global = arguments[3];

/**
 * @module core/collections
 * @memberOf core
 */
const T = require("./types");

if (!global._X_LOOP_BREAK_) {
  global._X_LOOP_BREAK_ = Symbol("BREAK_LOOP");
  global._X_ANY_ = Symbol("ANY");
  global._X_ALL_ = Symbol("ALL");
}
/**
 * Break from functional loops: forEach, filter, ...
 * @type {symbol}
 */


const BREAK = global._X_LOOP_BREAK_;
/**
 * Match Any: Used as value in predicate object
 * @type {symbol}
 */

const ANY = global._X_ANY_;
const ALL = global._X_ALL_;
const UNSAFE_PROPS = ['__proto__', 'constructor', '__defineGetter__', '__defineSetter__', 'prototype'];
/**
 * Get item by index from multiple source types
 *
 * @param {Array|Object|String|NodeList|HTMLCollection} s - source
 * @param {Number|String} i - item index
 * @returns {any|null|undefined}
 */

function item(s, i) {
  if (!T.isVal(s)) return undefined;
  if (T.isObj(s)) return s[i];
  if (T.isStr(s)) return s[i];
  if (T.isArr(s)) return s[i];else return s.item(i);
}
/**
 * Source contains value or key:value
 *
 * @param {Array|Object|String} src
 * @param {any} value
 * @param {String|undefined} [key]
 * @returns {boolean}
 */


function contains(src, value, key) {
  if (!T.isVal(src)) return false;
  if (!T.isArr(src) && T.isObj(src)) return src[key] === value;
  return src.indexOf(value) >= 0;
}
/**
 * Add item(s) to source
 *
 * @param {Array|{add:Function}} src - source
 * @param {any} v - values
 */


function add(src, ...v) {
  if (T.isArr(src)) {
    forEach(v, vi => src.push(vi));
  } else if (T.isMutableList(src)) {
    src.add(v);
  }
}
/**
 * Remove item(s) from source
 *
 * @param {Array|String} src
 * @param {...any} it
 * @returns {boolean}
 */


function remove(src, ...it) {
  it = flatMap(it);
  let any = false;
  forEach(it, item => {
    let idx = src.indexOf(item);

    if (idx >= 0) {
      any = true;
      src.splice(idx, 1);
    }
  });
  return any;
}
/**
 * Toggles items in source
 *
 * @param {Array} src
 * @param {...any} c
 */


function toggle(src, ...c) {
  if (c.length === 0) return;
  c = flatMap(c);
  let idx = undefined;

  if (c.length === 1) {
    if (!remove(src, c)) {
      add(src, c[0]);
    }
  } else {
    c.push(c[0]);
    let any = false;
    forEach(src, (cl, i) => {
      idx = c.indexOf(cl);

      if (idx >= 0 && c.length > idx + 1) {
        any = true;
        src[i] = c[idx + 1];
      }
    });

    if (!any) {
      src.push(c[0]);
    }
  }
}

function objMatchOne(o, match) {
  let m = Object.keys(match);

  for (let k of m) {
    // if (!T.isObj(o[k])) continue;
    if (match[k] === ANY && o.hasOwnProperty(k)) return true;
    if (match[k] === o[k]) return true;
  }

  return false;
}

function objMatchAll(o, match) {
  let m = Object.keys(match);

  for (let k of m) {
    // if (!T.isObj(o[k])) return false;
    if (match[k] === ANY) continue;
    if (match[k] !== o[k]) return false;
  }

  return true;
}

function predicate(f, def = () => true, inc = true) {
  if (T.isUnd(f)) return def;
  if (T.isFun(f)) return f;else if (f instanceof RegExp) return (v, k, i, s) => !T.isObj(v) ? f.test(v.toString()) : false;else if (T.isObj(f)) {
    if (Object.keys(f).length === 0) return def;
    return inc ? (v, k, i, s) => objMatchOne(v, f) : (v, k, i, s) => objMatchAll(v, f);
  } else return (v, k, i, s) => v === f;
}

function funOrKey(f) {
  if (T.isUnd(f)) return v => v;
  if (T.isFun(f)) return f;

  if (T.isStr(f)) {
    const key = f;

    f = v => v[key];
  }

  throw Error(`Predicate ${f} cannot be of type ${typeof f}`);
}
/**
 * Create empty instance of given source
 *
 * @param {any} src - source object
 * @param {any} def - default value for primitives
 * @returns {any} empty instance of src
 */


function emptyOf(src, def = {}) {
  if (T.isStr(src)) return "";
  if (T.isList(src) || T.isArr(src)) return [];

  if (T.isObj(src)) {
    if (T.isEl(src)) {
      if (src.nodeType === 3 || src.nodeType === 8) {
        return document.createTextNode(src.textContent);
      } else {
        return document.createElement(src.tagName);
      }
    }

    if (src.__proto__) return Object.create(src.__proto__);
    return {};
  }

  return def;
}
/**
 * Type-agnostic concat. !!Mutates target!!
 *
 * @param {Array|String|Object} target
 * @param {Array|String|Object} source
 * @returns {Array|String|Object}
 */


function concat(target, source, override = false) {
  if (T.isStr(target)) {
    return target.concat(source);
  }

  if (T.isArr(target)) {
    return target.concat(source);
  }

  for (let k of Object.keys(source)) {
    if (!target[k] || override) target[k] = source[k];
  }

  return target;
}
/**
 * Polyfill-like for Object.values (uses native method if available)
 *
 * @param {Object} obj
 * @returns {Array|undefined} - array of values
 */


function objectValues(obj) {
  if (Object.values) {
    return Object.values(obj);
  } else {
    return map(obj, v => v);
  }
}
/**
 * Index for loop from "init" to "finish"(included) by "step"
 *
 * @param {Function} func
 * @param {Number} init
 * @param {Number} finish
 * @param {Number} [step]
 */


function forN(func, init = 0, finish = 0, step = init < finish ? 1 : -1) {
  if (step > 0) {
    for (; init <= finish; init += step) {
      func(init);
    }
  }

  for (; init >= finish; init += step) {
    func(init);
  }
}
/**
 * forEach(left) with limited range
 *
 * @param {Array|Object|NodeList|HTMLCollection} src
 * @param {Function} func
 * @param {Number} [start]
 * @param {Number?} [end]
 * @returns {*|number}
 */


function forEachRange(src, func, start = 0, end) {
  if (!T.isArr(src) || !T.isStr(src)) {
    let keys = Object.keys(src);
    end = end || keys.length - 1;

    for (let i = start; i <= end; i++) {
      let r = func(src[keys[i]], keys[i], i, src);
      if (r === BREAK) return i;
    }

    return end;
  }

  end = end || src.length;

  for (let i = start; i < end; i++) {
    let r = func(item(src, i), i, i, src);
    if (r === BREAK) return i;
  }

  return end;
}
/**
 * Type-agnostic forEach loop
 *
 * @param src
 * @param func
 * @returns {number|*}
 */


function forEach(src, func) {
  if (!T.isVal(src)) return -1;

  if (!T.isArr(src) || !T.isStr(src) || !T.isList(src)) {
    let i = 0;
    let keys = Object.keys(src);
    const len = keys.length;

    for (; i < len; i++) {
      // let r = ;
      const k = keys[i],
            v = src[k];
      if (func(v, k, i, src) === BREAK) return i;
    }

    return i;
  }

  const len = src.length;

  if (!T.isArr(src)) {
    for (let i = 0; i < len; i++) {
      const v = src[i];
      let r = func(v, i, i, src);
      if (r === BREAK) return i;
    }
  } else {
    for (let i = 0; i < len; i++) {
      const v = item(src, i);
      let r = func(v, i, i, src);
      if (r === BREAK) return i;
    }
  }

  return src.length;
}
/**
 * Type-agnostic forEachRight loop
 *
 * @param src
 * @param func
 * @param range
 * @returns {number|*}
 */


function forEachRight(src, func, range = []) {
  if (!T.isArr(src) || !T.isStr(src)) {
    let i = 0;
    let keys = Object.keys(src);

    for (let i = keys.length - 1; i >= 0; i--) {
      if (i < range[1]) continue;
      if (i >= range[0]) return i;
      let r = func(src[keys[i]], keys[i], i, src);
      if (r === BREAK) return i;
    }

    return i;
  }

  for (let i = src.length - 1; i >= 0; i--) {
    let r = func(item(src, i), i, i, src);
    if (r === BREAK) return i;
  }

  return src.length;
}
/**
 * Extended version of native indexOf method, using {@link forEach}
 * @see forEach
 * @param {Array|Object|String|NodeList|HTMLCollection} src
 * @param {Function|Object|Array} pred - predicate function/{key:value}/[keys]
 * @returns {number}
 */


function firstIndex(src, pred) {
  pred = predicate(pred, () => true);
  let r = -1;
  forEach(src, function (v, k, i) {
    r = pred(v, k, i, src);

    if (r === true) {
      r = i;
      return BREAK;
    }
  });
  return r;
}
/**
 * Extended version of native first method, using {@link firstIndex}
 * @see firstIndex
 * @param {Array|Object|String|NodeList|HTMLCollection} src
 * @param {Function|Object|Array} [pred] - predicate function/{key:value}/[keys]
 * @returns {*}
 */


function first(src, pred) {
  return item(src, firstIndex(src, pred));
}
/**
 * Returns true if first item matches predicate
 *
 * @param {Array|Object|String|NodeList|HTMLCollection} src
 * @param {Function|Object|Array} [pred] - predicate function/{key:value}/[keys] pred
 * @returns {boolean|*}
 */


function startsWith(src, pred) {
  if (T.isStr(src) && T.isStr(pred)) {
    return src.indexOf(pred) === 0;
  }

  pred = predicate(pred, () => true);
  return pred(first(src));
}
/**
 *
 * @param {Array|Object|String|NodeList|HTMLCollection} src
 * @param {Function|Array|Object} pred
 * @returns {number}
 */


function lastIndex(src, pred) {
  pred = predicate(pred, () => true);
  let r = -1;
  forEachRight(src, function (v, k, i) {
    r = pred(v, k, i);

    if (r === true) {
      r = i;
      return BREAK;
    }
  });
  return r;
}
/**
 *
 * @param {Array|Object|String|NodeList|HTMLCollection} src
 * @param {Function|Array|Object} [pred]
 * @returns {*}
 */


function last(src, pred) {
  return src[lastIndex(src, pred)];
}
/**
 *
 * @param {Array|Object|String|NodeList|HTMLCollection} src
 * @param {Function|Array|Object} pred
 * @returns {boolean|*}
 */


function endsWith(src, pred) {
  if (T.isStr(src) && T.isStr(pred)) {
    return src.indexOf(pred) === src.length - pred.length;
  }

  pred = predicate(pred, () => true);
  return pred(last(src));
}
/**
 * Reverse array-like src
 *
 * @param {Array|Object|String|NodeList|HTMLCollection} src
 * @returns {Array|Object|String|NodeList|HTMLCollection} - reversed src
 */


function reverse(src) {
  if (T.isArr(src)) return src.reverse();
  let rev = "";
  forEachRight(src, function (it) {
    rev += it;
  });
  return rev;
}
/**
 * A more versatile alternative to native "some" method
 *
 * @param {Array|Object|String|NodeList|HTMLCollection} src
 * @param {Function|Array|Object} pred
 * @returns {boolean}
 */


function any(src, pred) {
  // if (!func){
  //     if (T.isArr(src) || T.isStr(src)) return src.length>0;
  //     return Object.keys(src).length>0;
  // }
  let fn = predicate(pred);
  let r = false;
  forEach(src, function (v, k, i, src) {
    r = fn(v, k, i, src);
    if (r === true) return BREAK;
  });
  return r;
}
/**
 * A more versatile alternative to native "every" method
 *
 * @param {Array|Object|String|NodeList|HTMLCollection} src
 * @param {Function|Array|Object} pred
 * @returns {boolean}
 */


function all(src, pred) {
  pred = predicate(pred, () => true);
  let r = true;
  forEach(src, function (v, k, i, src) {
    r = pred(v, k, i, src);
    if (r === false) return BREAK;
  });
  return r;
}

function filterStr(src, pred, right = false, omit = false) {
  pred = predicate(pred, () => true);
  let res = "";
  let loop = right ? forEachRight : forEach;
  loop(src, function (v, k, i) {
    if (!pred || pred(v, k, i, src) === omit) res += v;
  });
  return res;
}

function filterObj(src, pred, right = false, omit = false) {
  if (T.isArr(pred)) {
    let a = Object.assign({}, pred);
    if (omit) pred = (v, k) => !any(a, k);else pred = (v, k) => any(a, k);
  } else pred = predicate(pred, () => true);

  let res = {}; // let loop = right ? ForEachRight : ForEach;

  const keys = Object.keys(src);
  const len = keys.length;

  if (!right) {
    for (let i = 0; i < len; i++) {
      const k = keys[i];
      const v = src[k];
      if (pred(v, k, i, src) !== omit) res[k] = v;
    }
  } else {
    for (let i = len - 1; i >= 0; i--) {
      const k = keys[i];
      const v = src[k];
      if (pred(v, k, i, src) !== omit) res[k] = v;
    }
  } // loop(src, function (v, k, i) {
  //     if (pred(v, k, i, src) !== omit) res[k] = v;
  // });


  return res;
}

function filterArr(src, pred, right = false, omit = false) {
  if (T.isArr(pred)) {
    let a = Object.assign([], pred);
    if (omit) pred = (v, k, i) => !any(a, i);else pred = (v, k, i) => any(a, i);
  } else pred = predicate(pred, () => true);

  let res = [];
  const len = src.length;

  if (!right) {
    for (let i = 0; i < len; i++) {
      const v = src[i];

      if (pred(v, i, i, src) !== omit) {
        res.push(v);
      }
    }
  } else {
    for (let i = len - 1; i >= 0; i--) {
      const v = src[i];

      if (!pred(v, i, i, src) !== omit) {
        res.push(v);
      }
    }
  }

  return res;
}
/**
 * A more versatile alternative to native "filter" method
 *
 * @param {Array|Object|String|NodeList|HTMLCollection} src - source
 * @param {Function|Array|Object} pred - predicate function/{key:value}/[keys]
 * @param {boolean} [right] - reverse loop
 * @returns {Array|Object|String}
 */


function filter(src, pred, right = false) {
  if (T.isStr(src)) return filterStr(src, pred, right);
  if (T.isArr(src) || T.isList(src)) return filterArr(src, pred, right);
  return filterObj(src, pred, right);
}
/**
 * Opposite of filter, returns items not matching predicate
 *
 * @param {Array|Object|String|NodeList|HTMLCollection} src - source
 * @param {Function|Array|Object} pred - predicate function/{key:value}/[keys]
 * @param {boolean} [right] - reverse loop
 * @returns {Array|Object|String}
 */


function omit(src, pred, right = false) {
  if (T.isStr(src)) return filterStr(src, pred, right, true);
  if (T.isArr(src) || T.isList(src)) return filterArr(src, pred, right, true);
  return filterObj(src, pred, right, true);
}
/**
 * {@link filter} in reverse order (right)
 *
 * @param {Array|Object|String|NodeList|HTMLCollection} src - source
 * @param {Function|Array|Object} pred - predicate function/{key:value}/[keys]
 * @returns {Array|Object|String}
 */


function filterRight(src, pred) {
  return filter(src, pred, true);
}
/**
 * Find max index
 *
 * @param {Array|Object|String|NodeList|HTMLCollection} list
 * @param {Function|String} pred - predicate function/key
 * @return {number}
 */


function maxIndex(list, pred) {
  pred = funOrKey(pred);
  let mx;
  let index = -1;
  forEach(list, function (i, ix) {
    let x = pred(i, ix);

    if (!mx) {
      mx = x;
      index = ix;
    } else if (x >= mx) {
      mx = x;
      index = ix;
    }
  });
  return index;
}
/**
 * Find max
 *
 * @param {Array|Object|String|NodeList|HTMLCollection} list
 * @param {Function|String} pred - predicate function/key
 * @return {number}
 */


function max(list, pred) {
  return list[maxIndex(list, pred)];
}
/**
 * Find min index
 *
 * @param {Array|Object|String|NodeList|HTMLCollection} list
 * @param {Function|String} pred - predicate function/key
 * @return {number}
 */


function minIndex(list, pred) {
  pred = funOrKey(pred);
  let mn;
  let index = -1;
  forEach(list, function (i, ix) {
    let x = pred(i, ix);

    if (!mn) {
      mn = x;
      index = ix;
    } else if (x <= mn) {
      mn = x;
      index = ix;
    }
  });
  return index;
}
/**
 * Find min
 *
 * @param {Array|Object|String|NodeList|HTMLCollection} list
 * @param {Function|String} pred - predicate function/key
 * @return {number}
 */


function min(list, pred) {
  return list[minIndex(list, pred)];
}

function mapArr(src, func, right = false) {
  let res = []; // let loop = right ? ForEachRight : ForEach;

  const len = src.length;

  if (!right) {
    for (let i = 0; i < len; i++) {
      let r = func(src[i], i, src);
      if (r === BREAK) break;
      if (!T.isUnd(r)) res.push(r);
    }
  } else {
    for (let i = len; i >= 0; i--) {
      let r = func(src[i], i, src);
      if (r === BREAK) break;
      if (!T.isUnd(r)) res.push(r);
    }
  } // loop(src, function (a, i) {
  //     let r = func(a, i, src);
  //     if (!T.isUnd(r))
  //         res.push(r);
  // });


  return res;
}

function mapObj(src, func, right = false) {
  let res = {}; // let loop = right ? ForEachRight : ForEach;

  const keys = Object.keys(src);
  const len = src.length;

  if (!right) {
    for (let i = 0; i < len; i++) {
      const k = keys[i];
      const v = src[k];
      let r = func(v, k, i, src);
      if (r === BREAK) break;
      if (!T.isUnd(r)) res[k] = r;
    }
  } else {
    for (let i = len; i >= 0; i--) {
      const k = keys[i];
      const v = src[k];
      let r = func(v, k, i, src);
      if (r === BREAK) break;
      if (!T.isUnd(r)) res[k] = r;
    }
  } // loop(src, function (v, k, i) {
  //     let r = func(v, k, i, src);
  //     if (!T.isUnd(r))
  //         res[k] = r
  // });


  return res;
}
/**
 * A more versatile alternative to native "map" method
 *
 * @param {Array|Object|String|NodeList|HTMLCollection} src - source
 * @param {Function|Array|Object} transform - transformer function
 * @param {boolean} [right] - reverse loop
 * @returns {Array|Object|String}
 */


function map(src, transform, right = false) {
  transform = predicate(transform, v => v);
  if (T.isArr(src)) return mapArr(src, transform, right);else if (T.isObj(src)) return mapObj(src, transform, right);
}
/**
 * A more versatile alternative to native "flatMap" method, flattens first level items
 *
 * @param {Array|Object|String|NodeList|HTMLCollection} src - source
 * @param {Function|Array|Object} [transform] - transformer function
 * @returns {Array|Object|String}
 */


function flatMap(src, transform) {
  let res;
  if (T.isStr(src)) res = "";else if (T.isArr(src)) res = [];else res = {};
  forEach(src, function (a, i) {
    let f;

    if (!!transform) {
      f = transform(a, i, src);
    } else {
      if (!T.isArr(res) && T.isObj(res)) {
        f = {};
        f[i] = a;
      } else {
        f = a;
      }
    }

    res = concat(res, f);
  });
  return res;
}
/**
 * A more versatile alternative to native "reduce" method
 *
 * @param {any} src - source
 * @param {Function|Array|Object} func - reducer function
 * @param {any} [acc] - accumulator
 * @returns {any}
 */


function reduce(src, func, acc = src) {
  if (T.isUnd(func)) {
    func = (rs, v) => rs + v;
  }

  forEach(src, (v, k, src) => {
    acc = func(acc, v, k, src);
  });
  return acc;
}
/**
 * {@link reduce} in reverse
 * @see reduce
 * @param {any} src - source
 * @param {Function|Array|Object} func - reducer function
 * @param {any} [acc] - accumulator
 * @returns {any}
 */


function reduceRight(src, func, acc = src) {
  forEachRight(src, (v, k, src) => {
    acc = func(acc, v, k, src);
  });
}
/**
 * Randomly shuffle array's items
 * @param {ArrayLike} arrayLike
 */


function shuffle(arrayLike) {
  return Array.prototype.sort.call(arrayLike, () => Math.random() - 0.5);
}
/**
 * Sort array ascending with optional field parameter
 * @param {ArrayLike} arrayLike
 * @param {Function} [fieldFn]
 * @param {String} [locale]
 */


function sortAsc(arrayLike, fieldFn, locale = 'en') {
  let compare = fieldFn ? function (a, b) {
    return ('' + fieldFn(a)).localeCompare('' + fieldFn(b), locale);
  } : undefined;
  return Array.prototype.sort.call(arrayLike, compare);
}
/**
 * Sort array descending with optional field parameter
 * @param {ArrayLike} arrayLike
 * @param {Function} [fieldFn]
 * @param {String} [locale]
 */


function sortDesc(arrayLike, fieldFn, locale = 'en') {
  let compare = fieldFn ? function (a, b) {
    return ('' + fieldFn(b)).localeCompare('' + fieldFn(a), locale);
  } : undefined;
  return Array.prototype.sort.call(arrayLike, compare);
}
/**
 * Extract single key-value pairs from object
 *
 * @param object
 * @return {Object[]}
 */


function keyValuePairs(object) {
  let entries = [];
  forEach(object, (v, k) => {
    entries.push(T.dict(k, v));
  });
  return entries;
}
/**
 * Like Object.entries extracts key-value pairs as [[key1,value1],[key2,value2],...]
 *
 * @param {Object} object
 * @return {Array[]}
 */


function entries(object) {
  let entries = [];
  forEach(object, (v, k) => {
    entries.push([k, v]);
  });
  return entries;
}
/**
 * Translate(rename) object fields using dict parameter, omitting undefined keys
 * @param {Object} source
 * @param {Object|Array} dict
 * @return {Array|Object|String}
 */


function translateObject(source, dict) {
  if (T.isArr(dict)) {
    filter(source, dict);
  }

  const keys = Object.keys(dict);
  let res = filter(source, keys);

  for (let key of keys) {
    res[dict[key]] = res[key];
    delete res[key];
  }

  return res;
}
/**
 * Recursive deep merge {@param target} with {@param source}
 *
 * @param {Object|Array} target
 * @param {Object|Array} source
 * @param {Array} excludeKeys - keys to be skipped while merging
 * @param maxDepth - maximum recursive depth
 * @param allowUnsafeProps - allow unsafe properties like __proto__
 * @return {Object|Array}
 */


function deepMerge(target, source, {
  excludeKeys = [],
  maxDepth = 999,
  allowUnsafeProps = false
} = {
  excludeKeys: [],
  maxDepth: 999,
  allowUnsafeProps: false
}, depth = 0) {
  if (depth >= maxDepth) return target;
  forEach(source, (v, k) => {
    if (excludeKeys && contains(excludeKeys, k)) return;
    if (allowUnsafeProps && contains(UNSAFE_PROPS, k)) return;

    if (T.isObj(source[k])) {
      target[k] = deepMerge(emptyOf(source[k]), source[k], {
        excludeKeys,
        maxDepth,
        depth: depth + 1
      });
    } else target[k] = v;
  });
  return target;
}
/**
 * Recursive deep clone {@param source}
 * @see deepMerge
 *
 * @param {Object|Array} source
 * @param {Array} excludeKeys - keys to be skipped while merging
 * @param {Number} [maxDepth] - maximum recursive depth
 * @param {boolean} [allowUnsafeProps] - allow unsafe properties like __proto__
 * @return {Object|Array}
 */


function deepClone(source, {
  excludeKeys = [],
  maxDepth = 999,
  allowUnsafeProps = false
} = {
  excludeKeys: [],
  maxDepth: 999,
  allowUnsafeProps: false
}) {
  return deepMerge(emptyOf(source), source, {
    excludeKeys,
    maxDepth,
    allowUnsafeProps
  });
}

function _keyGen(key, fnName) {
  let keyGen = key;

  if (T.isStr(key)) {
    keyGen = item => item[key];
  } else if (T.isArr(key)) {
    keyGen = item => reduce(item, (res, v, k) => {
      if (contains(key, k)) {
        return res + v;
      }
    }, "");
  } else if (!T.isFun(key)) {
    throw Error(`${fnName} key only accepts: String, [String,...], Function`);
  }

  return keyGen;
}
/**
 * Join arrays of objects based on a generated or static key
 *
 * @param {Function|String} key
 * @param {Object[]} lists
 * @return {Object}
 */


function join(key, ...lists) {
  if (lists.length === 0) return [];
  if (!all(lists, T.isArr)) throw Error("Join only accepts arrays of data!");

  let keyGen = _keyGen(key, "Join");

  const joined = {};
  forEach(lists, list => {
    forEach(list, item => {
      const joinKey = keyGen(item);
      const presentValue = joined[joinKey];

      if (!presentValue) {
        joined[joinKey] = item;
      } else {
        joined[joinKey] = concat(presentValue, item);
      }
    });
  });
  return joined;
}
/**
 * Group arrays based on generated or static key(s)
 *
 * @param {Function|String} key
 * @param {Object[]} lists
 * @return {Object}
 */


function groupBy(key, ...lists) {
  if (lists.length === 0) return {};
  if (!all(lists, T.isArr)) throw Error("GroupBy only accepts arrays of data!");

  let keyGen = _keyGen(key, "GroupBy");

  const group = {};
  forEach(lists, list => {
    forEach(list, item => {
      const joinKey = keyGen(item);
      const presentValue = group[joinKey];

      if (!presentValue) {
        group[joinKey] = [item];
      } else {
        group[joinKey] = concat(presentValue, item);
      }
    });
  });
  return group;
} // noinspection JSUnusedGlobalSymbols


module.exports = {
  ANY,
  ALL,
  BREAK,
  item,
  contains,
  add,
  remove,
  toggle,
  concat,
  emptyOf,
  objMatchOne,
  objMatchAll,
  deepMerge,
  deepClone,
  forN,
  forEachRange,
  forEach,
  forEachRight,
  firstIndex,
  first,
  startsWith,
  lastIndex,
  last,
  endsWith,
  reverse,
  any,
  all,
  filter,
  filterRight,
  reduce,
  reduceRight,
  map,
  flatMap,
  keyValuePairs,
  entries,
  maxIndex,
  max,
  minIndex,
  min,
  shuffle,
  sortAsc,
  sortDesc,
  translateObject,
  omit,
  join,
  groupBy,
  objectValues
};
},{"./types":"5jEMv"}],"6Oqbo":[function(require,module,exports) {
const View = require("./view_base");

const NodeType = require("./nodetype");

function VNode(tag, props = {}, nodes) {
  this.$type = NodeType.VNODE;
  this.$tag = tag;

  if (tag === null) {
    this.$frag = true;
  } else {
    if (tag === '#text') {
      this.$isText = true;
      this.$text = props;
      return;
    }

    this.$isNode = true;
    let compiled = VNode.compileProps(props);
    this.events = compiled.events;
    this.attrs = compiled.attrs;
    this.$element = undefined;
  }

  this.$raw = true; // this.$nodes = nodes

  this.$resetNodes(nodes);
}

VNode.create = function (type, props = {}, ...nodes) {
  if (props === null) props = {};
  if (type === null) return new VNode(type, props, nodes); // View class instance

  if (type.$isView) {
    return type.$createInstance(props, nodes);
  } // View class


  if (type.prototype && type.prototype instanceof View) {
    return new type().$updateInstance(props, nodes);
  } // Function component


  if (!type.$type && type instanceof Function) {
    return View.create(type.name, {
      render: type
    }).$createInstance(props, nodes);
  } // create VNode instance


  return VNode.createTag(type, props, nodes);
};

VNode.createText = function (text) {
  return new VNode('#text', text);
};

VNode.createTag = function (tag, props, nodes) {
  return new VNode(tag, props, nodes);
};

module.exports = VNode;
},{"./view_base":"4uAoY","./nodetype":"4z0fH"}],"2x5EZ":[function(require,module,exports) {
// import {updateAttributes, updateEventListeners} from "./update-element";
// import renderDom, {renderDomView} from "./render";
// import View from "./view";
// import {error, trace, warn} from "../core/logging";
// import {normalizeNodes} from "./util";
const {
  updateAttributes,
  updateEventListeners
} = require("./update-element");

const {
  renderDom,
  renderDomView
} = require("./render");

const {
  error,
  trace,
  warn
} = require("../core/logging");

const normalizeNodes = require("./normalizeNodes");

const View = require("./view_base");

function updateViewRoot(view) {
  let newNodes = normalizeNodes(View.$callRender(view), view, view, true);
  patchNodes(view, newNodes, view.$rootElement);
  View.$setNodes(view, newNodes, false);
  view.$isDirty = false;
  view.$dispatchLifeCycle('onUpdate', view.props);
}

function isViewDirty(view, props) {
  if (view.$isView) {
    return view.shouldUpdate(props);
  } else return true;
}

function digElement(currentNode) {
  let element = undefined;

  if (currentNode.$element) {
    return currentNode.$element;
  } else {
    let nodes = currentNode.$nodes;

    for (let i = 0; i < nodes.length; i++) {
      if (element) {
        nodes[i].$removeDom();
      } else {
        element = digElement(nodes[i]);
        if (element) nodes[i].$element = undefined;
      }
    }
  }

  return element;
}

function patchNodes(current, newNodes, rootElement) {
  let parentElement = current.$isNode ? current.$element : rootElement;
  let currentNodes = current.$nodes;
  let newLen = newNodes.length;
  let curLen = current.$nodes.length;
  let added = newLen >= curLen;
  let len = added ? curLen : newLen;
  let lastElement;
  let index = 0;

  for (; index < len; index++) {
    let curNode = currentNodes[index];
    let newNode = newNodes[index];

    if (newNode.$isText) {
      if (curNode.$isText && !newNode.$element) {
        // Text - Text
        if (curNode.$text !== newNode.$text) {
          curNode.$element.textContent = newNode.$text;
        }

        newNode.$element = curNode.$element;
      } else {
        // Text - VNode/View
        newNode.$element = document.createTextNode(newNode.$text);
        let curElement = digElement(curNode);
        parentElement.insertBefore(newNode.$element, curElement); // curElement.insertAdjacentElement('beforeBegin', newNode.$element)

        curElement.remove();
      }

      continue;
    }

    if (newNode.$isNode) {
      if (curNode.$isNode && curNode.$tag === newNode.$tag && !newNode.$element) {
        // VNode - VNode
        newNode.$element = curNode.$element;
        newNode.$element.__node__ = newNode;
        newNode.$view = curNode.$view;
        lastElement = newNode.$element;
        updateAttributes(newNode.attrs, curNode.attrs, curNode.$element);
        updateEventListeners(newNode.events, curNode.events, lastElement);

        if (!newNode.$element) {
          error('Fatal: current node has no $element', curNode, newNode);
        } // VNode children


        patchNodes(curNode, newNode.$nodes, curNode.$element);
      } else {
        // VNode - Different
        let curElement = lastElement || digElement(curNode);
        if (!newNode.$element) newNode.$element = renderDom(newNode, curElement);else {
          warn('Do not store and reuse tags, ' + 'instead generate them dynamically from state or other sources of data.', newNode.$element);
        }

        if (!curElement) {
          // warn('NO CURRENT ELEMENT', newNode)
          rootElement.append(newNode.$element);
        } else {
          parentElement.replaceChild(newNode.$element, curElement); // parentElement.insertBefore(newNode.$element, curElement)
          // curElement.insertAdjacentElement('afterEnd', newNode.$element)
          // curElement.remove()
        }
      }

      lastElement = newNode.$element;
      continue;
    }

    if (newNode.$isView) {
      if (curNode.$isView && curNode.$name === newNode.$name) {
        // View - View
        newNodes[index] = curNode;
        curNode.$parent = current;

        if (isViewDirty(curNode, newNode.props)) {
          // View is dirty -> update instance & patch nodes
          // apply new props & children
          curNode.$updateInstance(newNode.props, newNode.$children);
          updateViewRoot(curNode);
        }
      } else {
        // requestAnimationFrame(()=>{
        newNode.$nodes = renderDomView(newNode, rootElement);
        let curElement = digElement(curNode);
        curElement.replaceWith(newNode.$element); // })
      }
    } else {
      trace('Unexpected node', newNode);
      throw Error('Illegal node');
    }
  }

  if (added) {
    if (newLen - index > 50) {
      // requestAnimationFrame(()=>{
      let ch = [];

      for (let i = index; i < newLen; i++) {
        let render = renderDom(newNodes[i], current.$rootElement);
        ch.push(render);
      }

      let temp = document.createElement('slot');
      temp.style.display = 'none';
      parentElement.append(temp);
      temp.replaceWith.apply(temp, ch); // })
    } else {
      for (let i = index; i < newLen; i++) {
        let render = renderDom(newNodes[i], current.$rootElement);
        parentElement.append(render);
      }
    }
  }

  if (curLen > newLen) {
    let nodes = current.$nodes;

    for (let i = index; i < curLen; i++) {
      nodes[i].$removeDom();
    }
  }
}

module.exports = {
  updateViewRoot,
  patchNodes
};
},{"./update-element":"5F40s","./render":"4Vdtv","../core/logging":"2ERs7","./view_base":"4uAoY","./normalizeNodes":"6bvsv"}],"5F40s":[function(require,module,exports) {
// import {forEach} from "../core/collections";
// import {clearEvent, hasEvent, setEvent} from "../dom/event";
// import {compileStyles} from "./util";
const {
  forEach
} = require("../core/collections");

const {
  clearEvent,
  hasEvent,
  setEvent
} = require("../dom/event");

const {
  compileStyles
} = require("./util");

function updateAttributes(newAttrs, currentAttrs, element) {
  const newKeys = Object.keys(newAttrs);
  const currentKeys = Object.keys(currentAttrs);
  const keys = Object.keys(newAttrs); // const len = keys.length
  // console.log(newAttrs, currentAttrs)

  for (let key of keys) {
    const newVal = newAttrs[key]; // if (currentKeys.indexOf(key) < 0) {
    //     element.setAttribute(key, newVal)
    // } else {

    const curVal = currentAttrs[key];

    if (key === 'style') {
      const newStyle = compileStyles(newVal, ' ');
      const currentStyle = compileStyles(curVal, ' ');

      if (newStyle !== currentStyle) {
        //     console.log()
        element.setAttribute('style', newStyle);
      }
    } else if (key === 'className') {
      element.setAttribute('class', newVal);
    } else {
      element.setAttribute(key, newVal);
    } // }

  }

  for (let key of currentKeys) {
    if (newKeys.indexOf(key) < 0) {
      element.removeAttribute(key);
    }
  }
}

function updateEventListeners(newEvents = {}, oldEvents = {}, element) {
  forEach(oldEvents, function (listener, event) {
    if (newEvents[event] !== listener) {
      clearEvent(element, event);
    }
  });
  forEach(newEvents, function (listener, event) {
    // console.log(event, listener)
    setEvent(element, event, listener);
  });
}

module.exports = {
  updateAttributes,
  updateEventListeners
};
},{"../core/collections":"5lqP4","../dom/event":"6wQPW","./util":"3ujPW"}],"6wQPW":[function(require,module,exports) {
/**
 * @module DOM
 * @memberOf dom
 */
const scope = require("../core/scope");

const {
  isArr,
  hasField,
  isEmpty
} = require("../core/types");

const {
  contains,
  forEach,
  filter
} = require("../core/collections");

const {
  error
} = require("../core/logging");

const {
  funcBodyEquals
} = require("../core/functions");
/**
 * Set listener for event type(s) on element, removes identical event listeners to avoid duplication
 *
 * @param {HTMLElement|Element|Node} target - target element
 * @param {String|Array} event - event type(s)
 * @param {Function} listener
 * @param {AddEventListenerOptions?} [options]
 */


function setEvent(target, event, listener, options) {
  if (!scope.isBrowser()) {
    error("Events are browser only!");
    return;
  }

  if (!isArr(event)) {
    if (contains(event, ' ')) {
      event = event.split(' ').Map(it => it.trim());
    } else event = [event];
  }

  target.__EVENTS__ = target.__EVENTS__ || {};
  forEach(event, ev => {
    target.__EVENTS__[ev] = target.__EVENTS__[ev] || [];

    let f = function (e) {
      listener(e, target);
    };

    if (!hasField(options, 'duplicates', a => a)) {
      target.__EVENTS__[ev] = filter(target.__EVENTS__[ev], fl => {
        if (funcBodyEquals(fl.l, listener)) {
          target.removeEventListener(ev, fl.f, fl.o);
          return false;
        } // else {
        //     console.log('notEqual',fl.l.toString(), listener.toString())
        // }

      });
    }

    target.__EVENTS__[ev].push({
      f: f,
      l: listener,
      o: options
    });

    target.addEventListener(ev, f, options);
  });
}
/**
 * Clear all event listeners of type from element
 *
 * @param {HTMLElement|Element|Node} target - target element
 * @param {String|Array} event - event type(s)
 */


function clearEvent(target, event) {
  if (!scope.isBrowser()) {
    error("Events are browser only!");
    return;
  }

  if (!isArr(event)) {
    if (contains(event, ' ')) {
      event = event.split(' ').Map(it => it.trim());
    } else event = [event];
  }

  target.__EVENTS__ = target.__EVENTS__ || {};
  if (isEmpty(target.__EVENTS__)) return;
  forEach(event, function (ev) {
    target.__EVENTS__[ev] = target.__EVENTS__[ev] || [];
    if (isEmpty(target.__EVENTS__[ev])) return;
    forEach(target.__EVENTS__[ev], fl => {
      target.removeEventListener(ev, fl.f, fl.o);
      return false;
    });
    target.__EVENTS__[ev] = [];
  });
}
/**
 * Target has event listener for event type
 *
 * @param {HTMLElement|Element|Node} target - target element
 * @param {String} type - event type
 * @return {boolean}
 */


function hasEvent(target, type) {
  return target.__EVENTS__ && target.__EVENTS__[type] && !isEmpty(target.__EVENTS__[type]);
}

module.exports = {
  setEvent,
  clearEvent,
  hasEvent
};
},{"../core/scope":"7A8qL","../core/types":"5jEMv","../core/collections":"5lqP4","../core/logging":"2ERs7","../core/functions":"45TqM"}],"7A8qL":[function(require,module,exports) {
var global = arguments[3];

/**
 * Merges an object with global namespace
 * @private
 * @param {Object} obj
 */
function setGlobal(obj) {
  for (let key of Object.keys(obj)) {
    global[key] = obj[key];
  }
}
/**
 * Code generator for prototype modification, used in polyfills
 */


class Extension {
  /**
   * @constructor
   * @param {any[]} types - Array of prototypes
   */
  constructor(types) {
    this.types = types;
    this.types = [];
    /** Generated code */

    this.pcode = "\n";
  }
  /**
   * Defines a new function for given prototypes
   *
   * @param {Function} namedFunc A named function
   * @return {string}
   */


  define(namedFunc) {
    if (!namedFunc.name) {
      let err = `Function must have a name [Extension.define(f)]\n<<${namedFunc}>>`;
      console.error(err);
      return `\n/**\n *${err}\n */`;
    }

    let code = "\n";

    for (let p of this.types) {
      if (p !== undefined) code += `${p.name || p}.prototype.${namedFunc.name} = `;
    }

    code += namedFunc.toString() + ";\n";
    this.pcode += code;
    return code;
  }

  polyfill(namedFunc) {
    if (!namedFunc.name) {
      let err = `Extension function must have a name:\n<<${namedFunc}>>`;
      console.error(err);
      return `\n/**\n *${err}\n */`;
    }

    let code = "\n";

    for (let p of this.types) {
      code += `if (${p.name || p}.prototype.${namedFunc.name} === undefined) ${p.name || p}.prototype.${namedFunc.name} = ${namedFunc.toString()};\n`;
    }

    this.pcode += code;
  }

}

function isBrowser() {
  return global.window !== undefined && global.document !== undefined && global.navigator !== undefined;
}

if (!isBrowser()) {
  // -------------
  global.HTMLElement = !global.HTMLElement ? function HTMLElement() {} : global.HTMLElement;
  global.Element = !global.Element ? function Element() {} : global.Element;
  global.Node = !global.Node ? function Node() {} : global.Node;
  global.HTMLCollection = !global.HTMLCollection ? function HTMLCollection() {} : global.HTMLCollection;
  global.NodeList = !global.NodeList ? function NodeList() {} : global.NodeList; // -------------
}

module.exports = {
  setGlobal,
  Extension,
  isBrowser
};
},{}],"45TqM":[function(require,module,exports) {
/**
 * @module
 * @memberOf core
 */
function bodyOf(func) {
  let match = func.toString().match(/{[\w\W]*}/);
  return match === null ? func.toString() : match[0];
}
/**
 * Check if function bodies are equal
 * @param {Function} f1
 * @param {Function} f2
 * @return {boolean}
 */


function funcBodyEquals(f1, f2) {
  return bodyOf(f1) === bodyOf(f2);
}
/**
 * Throttle function execution.
 * {@link https://css-tricks.com/debouncing-throttling-explained-examples/}
 *
 * @param {Function} func - function
 * @param {Number} intervalMs
 * @return {Function} - throttled function
 */


function throttle(func, intervalMs) {
  var ___last___ = new Date().getTime();

  function throttled(args) {
    if (new Date().getTime() - ___last___ >= intervalMs) {
      ___last___ = new Date().getTime();
      func.call(this, args);
    }
  }

  return throttled;
}
/**
 * Debounce function execution.
 * {@link https://css-tricks.com/debouncing-throttling-explained-examples/}
 *
 * @param {Function} func - function
 * @param {Number} afterMs - milliseconds after last call
 * @return {Function} - debounced function
 */


function debounce(func, afterMs) {
  var ___timeout___ = null;

  function debounced(...args) {
    clearTimeout(___timeout___);
    ___timeout___ = setTimeout(function (_this) {
      return func.apply(_this, args);
    }, afterMs, this);
  }

  debounced.flush = function (...args) {
    clearTimeout(___timeout___);
    return func.apply(this, args);
  };

  return debounced;
}
/**
 * Bind args to function and return a no-arg function
 * @param {Function} func - source function
 * @param {any[]} args - array of arguments to bind
 * @return {Function}
 */


function bindArgs(func, args) {
  return function () {
    return func.apply(this, args);
  };
}

function once(func) {
  var called = false;
  return function () {
    if (!called) {
      called = true;
      return func.apply(this, arguments);
    }
  };
}

module.exports = {
  funcBodyEquals,
  throttle,
  debounce,
  bindArgs,
  once
};
},{}],"3ujPW":[function(require,module,exports) {
// import {error, forEach, isArr, isPrim, isStr, isVal} from "../core";
// import JSS from "./jss";
// import View from "./view";
// import VNode from "./vnode";
const {
  isArr,
  isStr,
  isVal
} = require("../core/types");

const {
  forEach
} = require("../core/collections");

const JSS = require("./jss");

function isEventPropKey(key) {
  return /on[A-Z]+/.test(key);
}

function normalizeEventName(eventName) {
  return eventName.slice(2).toLowerCase();
}

function randomId() {
  return Date.now().toString(24).slice(2) + Math.random().toString(24).slice(6);
}

function randomHexColor() {
  return '#' + Math.random().toString(16).slice(2, 8);
}

function compileProps(props) {
  const cats = {
    events: {},
    attrs: {}
  };
  forEach(props, (v, k) => {
    if (isEventPropKey(k)) cats.events[normalizeEventName(k)] = v;else cats.attrs[k] = v;
  });
  return cats;
}

function compileStyles(styles, joinWith) {
  if (!isVal(styles)) return '';else if (isStr(styles)) return styles;else if (isArr(styles)) return styles.join(joinWith);
  return JSS.generateCss(styles, joinWith);
}

function sameProps(currentProps = {}, newProps = {}) {
  const curKeys = Object.keys(currentProps);
  const newKeys = Object.keys(newProps);
  if (curKeys.length !== newKeys.length) return false;

  for (let curKey of curKeys) {
    if (newProps[curKey] !== currentProps[curKey]) return false;
  }

  return true;
}

module.exports = {
  isEventPropKey,
  normalizeEventName,
  randomId,
  randomHexColor,
  compileProps,
  compileStyles,
  sameProps
};
},{"../core/types":"5jEMv","../core/collections":"5lqP4","./jss":"1fSfj"}],"1fSfj":[function(require,module,exports) {
const {
  kebab
} = require("../core/cases");

const {
  forEach
} = require("../core/collections");

function generateStyles(jss) {
  let styles = [];
  forEach(jss, (val, prop) => {
    styles.push(`${kebab(prop)}: ${val};`);
  });
  return styles;
}

function generateCss(jss, joinWith = '\n') {
  return generateStyles(jss).sort((a, b) => a[0].localeCompare(b[0])).join(joinWith);
}

module.exports = {
  generateStyles,
  generateCss
};
},{"../core/cases":"3AZSM","../core/collections":"5lqP4"}],"3AZSM":[function(require,module,exports) {
/**
 * @module
 * @memberOf core
 */

/**
 * @static
 * @param name
 * @returns {string}
 */
function kebab(name) {
  let kb = "";
  let pres = false;

  for (let i = 0; i < name.length; i++) {
    let c = name.charAt(i);

    if (c === '_') {
      kb += '-';
      pres = true;
      continue;
    }

    if (c >= 'A' && c <= 'Z') {
      if (i > 0 && !pres) {
        kb += '-';
      }
    }

    kb += c.toLowerCase();
    pres = false;
  }

  return kb;
}
/**
 * @static
 * @param name
 * @returns {string}
 */


function snake(name) {
  let snk = "";
  let pres = false;

  for (let i = 0; i < name.length; i++) {
    let c = name.charAt(i);

    if (c === '-') {
      snk += '_';
      pres = true;
      continue;
    }

    if (c >= 'A' && c <= 'Z') {
      if (i > 0 && !pres) {
        snk += '_';
      }
    }

    snk += c.toLowerCase();
    pres = false;
  }

  return snk;
}
/**
 * @static
 * @param name
 * @returns {string}
 */


function camel(name) {
  let cml = "";
  let pres = false;

  for (let i = 0; i < name.length; i++) {
    let c = name.charAt(i);

    if (c === '-' || c === '_') {
      pres = true;
    } else if (pres === true) {
      cml += c.toUpperCase();
      pres = false;
    } else {
      if (i === 0) {
        cml += c.toLowerCase();
      } else {
        cml += c;
      }
    }
  }

  return cml;
}
/**
 * @static
 * @param name
 * @returns {string}
 */


function pascal(name) {
  let psc = "";
  let pres = false;

  for (let i = 0; i < name.length; i++) {
    let c = name.charAt(i);

    if (c === '-' || c === '_') {
      pres = true;
    } else if (pres === true) {
      psc += c.toUpperCase();
      pres = false;
    } else {
      if (i === 0) {
        psc += c.toUpperCase();
      } else {
        psc += c;
      }
    }
  }

  return psc;
}

module.exports = {
  kebab,
  camel,
  pascal,
  snake
};
},{}],"4Vdtv":[function(require,module,exports) {
// import {isArr, isStr, isVal} from "../core/types";
// import {info, warn, error, trace} from "../core/logging";
// import {forEach} from "../core/collections";
// import {setEvent} from "../dom/event";
// import JSS from "./jss";
// import VNode from "./vnode";
const {
  isArr,
  isStr,
  isVal
} = require("../core/types");

const {
  info,
  warn,
  error,
  trace
} = require("../core/logging");

const {
  forEach
} = require("../core/collections");

const {
  setEvent
} = require("../dom/event");

const JSS = require("./jss");

const VNode = require("./vnode");

function compileStyles(styles, joinWith) {
  if (!isVal(styles)) return '';else if (isStr(styles)) return styles;else if (isArr(styles)) return styles.join(joinWith);
  return JSS.generateCss(styles, joinWith);
}

function setElementProps(element, node, view) {
  if (node.attrs) {
    forEach(node.attrs, (val, key) => {
      if (key === 'style') {
        val = compileStyles(val, ' ');
      } else if (key === 'className') {
        key = 'class';
      }

      element.setAttribute(key, val);
    });
  }

  if (node.events) {
    forEach(node.events, (v, k) => {
      if (view) v = v.bind(view);
      setEvent(element, k, v);
    });
  }
}

function renderDomChildren(node, parentElement) {
  let nodes = [];

  for (let i = 0; i < node.$count; i++) {
    const curNode = node.$nodes[i];

    if (curNode.$isText) {
      nodes.push(renderDomText(curNode));
    } else {
      let childDom = undefined;
      if (curNode.$raw) curNode.$render(curNode, curNode.$view);

      if (curNode.$isView) {
        curNode.$dispatchLifeCycle('onCreate', curNode.props);
        childDom = renderDomView(curNode, node.$element || parentElement);
        curNode.$dispatchLifeCycle('onMount', curNode.props);
      } else if (curNode.$isNode) {
        childDom = renderDom(curNode);
      } else {
        error('Illegal node', curNode);
        throw Error(`Illegal child node`);
      }

      if (childDom instanceof Array) {
        childDom.forEach(c => nodes.push(c));
      } else {
        nodes.push(childDom);
      }
    }
  }

  return nodes;
}

function renderDomView(node, parentElement, isRoot = false) {
  if (node.$raw) {
    node.$render(node.$parent, node.$view);
  } // if (node.$empty) {
  //     View.$setNodes(node, [VNode.create('slot')], false)
  //     node.$element = renderDom(node.$first)
  //     node.$element.__view__ = node
  //     node.$element.__node__ = node.$first
  //     return [node.$element]
  // }


  let children = renderDomChildren(node, parentElement);
  let currentElement = !node.$parent ? parentElement : undefined;

  if (node.$single) {
    currentElement = children[0];
  }

  if (currentElement && !node.$single) {
    // console.log('not single', children)
    children.forEach(c => currentElement.append(c));
    children = [currentElement];
    currentElement.__view__ = node;
  } // warn(node, currentElement,node.$parent&& node.$parent.$rootElement)


  node.$element = currentElement;
  node.$rootElement = node.$rootElement || parentElement || node.$parent && node.$parent.$element || node.$parent && node.$parent.$rootElement;

  if (!node.$rootElement) {
    info('no root', node);
  } else {
    if (node.$element === parentElement) {
      info('Parent is the same element');
    } else if (parentElement) {
      children.forEach(c => parentElement.append(c));
    } else {
      children.forEach(c => node.$rootElement.append(c)); // console.log(node)
    }

    node.$rootElement.__view__ = node;
  }

  node.$isDirty = false;
  return node.$element || children;
}

function renderDomText(node) {
  let textNode = document.createTextNode(node.$text);
  node.$element = textNode;
  textNode.__node__ = node;
  return textNode;
}

function renderDom(node, parentElement, replaceParent) {
  if (!node) console.trace(node);
  let currentElement = undefined;
  if (node.$isText) return renderDomText(node);

  if (node.$isNode || node.$frag && parentElement) {
    //#region Done
    let id = undefined; // if (!node.$parent) {

    if (replaceParent) {
      id = parentElement.id;
      currentElement = parentElement;
    } else {
      currentElement = document.createElement(node.$tag);
    }

    setElementProps(currentElement, node, node.$view);
    if (id) currentElement.id = id;
    currentElement.__node__ = node;
    node.$element = currentElement; //#endregion A

    let children = renderDomChildren(node, currentElement);

    try {
      children.forEach(c => {
        try {
          currentElement.append(c);
        } catch (ee) {
          console.error(c, ee);
        }
      });
    } catch (e) {
      console.error(node, e);
    }

    return currentElement;
  }

  if (node instanceof Array) {
    node = VNode.create(null, undefined, node);
    node.$render();
  }

  if (node.$frag) {
    if (!parentElement) {
      warn('Rendering fragment without rootElement', node);
      return renderDomChildren(node);
    } else {
      let children = renderDomChildren(node, parentElement);
      children.forEach(ch => {
        parentElement.append(ch);
      });
      return parentElement;
    }
  }

  node.$dispatchLifeCycle('onCreate', node.props);
  let rendered = renderDomView(node, parentElement);
  node.$dispatchLifeCycle('onMount', node.props);
  return rendered;
}

module.exports = {
  renderDom,
  renderDomView
}; // export default renderDom
},{"../core/types":"5jEMv","../core/logging":"2ERs7","../core/collections":"5lqP4","../dom/event":"6wQPW","./jss":"1fSfj","./vnode":"tDSLT"}],"tDSLT":[function(require,module,exports) {
const {
  deepClone,
  forEach
} = require("../core/collections");

const {
  isEventPropKey,
  normalizeEventName
} = require("./util");

const normalizeNodes = require("./normalizeNodes");

const VNode = require("./vnode_base");

VNode.compileProps = function (props) {
  const cats = {
    events: {},
    attrs: {}
  };
  forEach(props, (v, k) => {
    if (isEventPropKey(k)) cats.events[normalizeEventName(k)] = v;else cats.attrs[k] = v;
  });
  return cats;
};

VNode.prototype.$render = function (parent, view) {
  this.$parent = parent;
  this.$view = view;

  for (let i = 0; i < this.$count; i++) {
    let curNode = this.$nodes[i];

    if (curNode.$isText) {
      curNode.$parent = this;
    } else {
      try {
        curNode = curNode.$render(this, view);
      } catch (e) {
        console.error(e, curNode);
      }
    }
  }

  this.$raw = false; // this.$resetNodes(this.$nodes)

  return this;
};

VNode.prototype.$resetNodes = function (nodes) {
  try {
    this.$nodes = normalizeNodes(nodes, this, this.$view, false);
  } catch (e) {
    console.log(e, this.$nodes);
  }

  this.$count = this.$nodes.length;

  if (!(this.$empty = this.$count === 0)) {
    this.$first = this.$nodes[0];
  } else if (this.$count === 1) {
    this.$single = true;
  }
};

VNode.prototype.$removeDom = function (rootRemoved) {
  // try {
  if (!rootRemoved) this.$element.remove();
  if (!this.$isText) this.$nodes.forEach(ch => ch.$removeDom(rootRemoved)); // } catch (e) {}
};

VNode.prototype.$clone = function (parent, view) {
  let cl = VNode.createTag(this.$tag, {
    attrs: deepClone(this.attrs),
    events: this.events
  }, this.$nodes.map(n => n.$clone(this, view)));
  return cl.$render(parent, view);
};

VNode.prototype.$ref = function (ref) {
  if (!this.$refs) {
    this.$refs = {};
  }

  let refChild = this.$refs[ref];
  if (this.attrs && this.attrs.ref === ref) return this;

  if (this.$nodes) {
    for (let index = 0; index < this.$nodes.length && refChild === undefined; index++) {
      refChild = this.$nodes[index].$ref(ref);
    }
  }

  return refChild;
};
/**
 * @type {View}
 */


module.exports = VNode;
},{"../core/collections":"5lqP4","./util":"3ujPW","./normalizeNodes":"6bvsv","./vnode_base":"6Oqbo"}],"zeW0D":[function(require,module,exports) {
// import {renderDom} from "./render";
const {
  renderDom
} = require("./render"); // import VNode from "./vnode";


const VNode = require("./vnode");

function mount(template, element) {
  if (!element) throw Error('mount: target element is undefined');
  if (!template.$isNode) template = VNode.create(template).$render();
  renderDom(template, element, true);
}

module.exports = mount;
},{"./render":"4Vdtv","./vnode":"tDSLT"}],"7v5Ej":[function(require,module,exports) {
"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = App;

var _ui = _interopRequireDefault(require("../../ui"));

var _TodoList = _interopRequireDefault(require("./TodoList"));

var _util = require("../../ui/util");

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function App() {
  const [count, setCount] = this.useState(0);
  this.useEffect(() => {
    console.log('Effect', count);
  });
  return _ui.default.jsx("div", {
    className: "container-fluid",
    style: {
      margin: 'auto',
      textAlign: 'center'
    }
  }, "Todo Example ", count, _ui.default.jsx("button", {
    onClick: function () {
      setCount(count + 1);
    }
  }, "AddCount"), _ui.default.jsx(_TodoList.default, null));
}
/*Exir.createComponent('App', {
    render() {
        return <div style={{margin: 'auto', textAlign: 'center'}}>
            Todo Example
            <TodoList/>
        </div>
    }
})
*/
},{"../../ui":"4uGQj","./TodoList":"5jEGL","../../ui/util":"3ujPW"}],"5jEGL":[function(require,module,exports) {
"use strict";

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

var _ui = _interopRequireDefault(require("../../ui"));

var _TodoItem = _interopRequireDefault(require("./TodoItem"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

// import View from "../../ui/view";
class TodoList extends _ui.default.View {
  constructor() {
    super();
    this.state = {
      text: "",
      items: ["ABC", "DEF"]
    };
  }

  render() {
    return _ui.default.jsx(null, null, _ui.default.jsx("div", {
      className: "row"
    }, _ui.default.jsx("div", {
      className: "container",
      style: {
        maxWidth: '250px'
      }
    }, _ui.default.jsx("div", {
      className: "row"
    }, _ui.default.jsx("input", {
      className: "",
      style: "min-width: 80%",
      value: this.state.text,
      type: "text",
      onChange: (_, el) => this.state.text = el.value
    }), _ui.default.jsx("button", {
      className: "btn green-o w-50",
      style: {
        maxWidth: '20%'
      },
      onClick: () => this.setState(s => s.items.push(this.state.text))
    }, "Add")), _ui.default.jsx(null, null, _ui.default.jsx("ul", {
      className: "column"
    }, _ui.default.jsx(null, null, this.state.items.map(it => _ui.default.jsx(_TodoItem.default, {
      text: it
    }))))))));
  }

}

exports.default = TodoList;
},{"../../ui":"4uGQj","./TodoItem":"7pPT9"}],"7pPT9":[function(require,module,exports) {
"use strict";

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

var _ui = _interopRequireDefault(require("../../ui"));

var _logging = require("../../core/logging");

var _util = require("../../ui/util");

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var _default = _ui.default.createComponent('TodoItem', {
  props: {
    text: ""
  },
  state: {
    done: false
  },

  render(props) {
    return _ui.default.jsx("li", {
      style: {
        backgroundColor: (0, _util.randomHexColor)(),
        color: (0, _util.randomHexColor)(),
        display: 'block',
        padding: '15px',
        margin: '15px',
        border: '3px solid ' + (0, _util.randomHexColor)()
      },
      onClick: () => this.setState(s => s.done = !s.done)
    }, this.state.done ? _ui.default.jsx("s", null, props.text) : _ui.default.jsx("b", null, props.text));
  },

  onCreate(props) {
    (0, _logging.info)('Created item with', props);
  },

  onDestroy(props) {
    (0, _logging.info)('Destroyed item, with', props);
  },

  onUpdate(props) {
    (0, _logging.info)('Updated item, with ', props);
  }

});

exports.default = _default;
},{"../../ui":"4uGQj","../../core/logging":"2ERs7","../../ui/util":"3ujPW"}],"5hW4H":[function() {},{}]},{},["5KyeU","6Ewdz"], "6Ewdz", "parcelRequire430d")

//# sourceMappingURL=index.65c0ba6f.js.map
