// 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;
    }
  }
})({"5kQFr":[function(require,module,exports) {
var HMR_HOST = null;
var HMR_PORT = 1234;
var HMR_ENV_HASH = "d751713988987e9331980363e24189ce";
module.bundle.HMR_BUNDLE_ID = "13797de45cd4785af698376ca09910ec";
/* 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;
}
},{}],"1kpA9":[function(require,module,exports) {
"use strict";

var _client = require("../../http/client");

var _collections = require("../../core/collections");

const client = new _client.XHttpClient('http://httpbin.org', {
  ratePerMinute: 60,
  timeout: 100,
  defaultHeaders: {
    '901230123jsadlمکشسی1': 'asdaw'
  },
  defaultParams: {
    '901230123jsadlمکشسی1': 'asdaw'
  }
});
client.interceptors.response.use(function (ajax) {
  ajax.rs.touched = true;
  return ajax;
});
;

(async () => {
  try {
    let get_params = {
      params: {
        user_id: 'user1',
        limit: 10,
        start: 11
      },
      headers: {
        'X-Custom-Header': 'some value',
        Authorization: 'Bearer TOKENTOKENTOKENTOKENTOKEN'
      }
    };
    let post_params = {
      params: {
        user_id: 'user1',
        limit: 10,
        start: 11
      },
      headers: {
        'X-Custom-Header': 'custom header',
        Authorization: 'Bearer TOKENTOKENTOKENTOKENTOKEN'
      },
      content: {
        type: 'json',
        data: {
          category: 'posts',
          post: {
            id: 123,
            text: 'some text'
          }
        }
      }
    };
    let ajax;

    for (let i = 0; i < 3; i++) {
      // Send GET request to http://httpbin.org/get
      // ajax = client.get('get', get_params).then((a)=>console.log(a)).catch((e)=>{console.error(e)})
      ajax = await client.get('get', get_params).then((a, e) => a).catch((a, e) => a);
      console.log(ajax, 1); // Send POST request to http://httpbin.org/post

      ajax = await client.post('post', post_params).then((a, e) => a).catch((a, e) => a);
      console.log(ajax, 2);
    }
  } catch (e) {
    console.error('EX', e);
  }
})();
},{"../../http/client":"dssZ8","../../core/collections":"5lqP4"}],"dssZ8":[function(require,module,exports) {
/**
 * Asynchronous Http Client using XHR
 * @module http/client
 * @memberOf http
 */
const http = require('./methods');

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

const {
  Ajax
} = require("./ajax");

const {
  startsWith,
  endsWith,
  filter,
  forEach
} = require('../core/collections');

class InterceptorStore {
  constructor() {
    this.all = [];
    this.any = false;
  }

  use(interceptor) {
    this.all.push(interceptor);
    this.any = true;
  }

  async intercept(ajax) {
    for (let i = 0; i < this.all.length; i++) {
      ajax = await this.all[i](ajax);
    }

    return ajax;
  }

}
/**
 * Async Http Client using XHR
 * @class
 */


class XHttpClient {
  /**
   *
   * @param {String} host - Server host address
   * @param {Number} [ratePerMinute] - Maximum requests allowed per minute (default 300)
   * @param {Object} [defaultParams] - Default params set on every request
   * @param {Object} [defaultHeaders] - Default headers set on every request
   * @param {Number} [timeout=3000]
   * @param {Number} [retries]
   */
  constructor(host = '', {
    ratePerMinute = 300,
    defaultParams,
    defaultHeaders,
    timeout,
    retries
  } = {}) {
    if (endsWith(host, '/')) {
      host = host.split('').splice(host.length - 1).join();
    }
    /**
     * Interceptors
     * @type {{request: InterceptorStore, response: InterceptorStore}}
     */


    this.interceptors = {
      request: new InterceptorStore(),
      response: new InterceptorStore()
    };
    this.host = host;
    this.__queue = [];
    this.__sending = [];
    this.__interval = undefined;
    this.__ratePerMinute = ratePerMinute;
    this.__timeBetween = 60000 / ratePerMinute;
    this.__lastRequestTime = new Date().getTime() - this.__timeBetween;
    this.timeout = timeout || 60000;
    this.retries = retries || 0;
    this.defaultHeaders = defaultHeaders || {};
    this.defaultParams = defaultParams || {};
  }
  /**
   *
   * @param client
   * @private
   */


  _intervalSend(client) {
    if (client.__queue.length === 0) {
      clearInterval(client.__interval);
      client.__interval = undefined;
      return;
    }

    let now = new Date().getTime();

    if (now - client.__lastRequestTime > client.__timeBetween) {
      let ajax = client.__queue.shift();

      client._sendImmediately(ajax, now);
    }
  }

  _sendImmediately(ajax, now) {
    if (this.interceptors.request.any) {
      this.interceptors.request.intercept(ajax).then(() => {
        ajax.send();

        this.__sending.push(ajax);

        this.__lastRequestTime = now;
      }).catch(e => {
        console.error(e);
      });
    } else {
      ajax.send();

      this.__sending.push(ajax);

      this.__lastRequestTime = now;
    }
  }

  _removeSendingRequest(request) {
    let rqi = this.__sending.indexOf(request);

    if (rqi >= 0) {
      this.__sending.splice(rqi);
    }
  }
  /**
   *
   * @param ajax
   * @param responseType
   * @param cancelToken
   * @return {Promise<Ajax>}
   * @private
   */


  _addRequest(ajax, {
    responseType,
    cancelToken
  }) {
    this.__queue.push(ajax);

    if (!this.__interval) {
      this.__interval = setInterval(this._intervalSend, 1, this);
    }

    ajax.cancelToken = cancelToken;
    if (responseType) ajax.xhr.responseType = responseType;
    ajax.RETRIES = 0;
    ajax.xhr.timeout = this.timeout;

    if (this.defaultHeaders) {
      ajax.headers(this.defaultHeaders);
    }

    if (this.defaultParams) {
      forEach(this.defaultParams, (val, key) => {
        ajax.rq.setArg(key, val);
      });
    }

    let promise = http.makePromise(ajax, {
      default(ajax, res, rej, client) {
        client._removeSendingRequest(ajax);
      },

      onSuccess(ajax, res, rej, client) {
        if (client.interceptors.response.any) {
          client.interceptors.response.intercept(ajax).then(() => res(ajax)).catch(e => rej(e));
        } else res(ajax);
      },

      onFail(ajax, res, rej, client) {
        if (client.interceptors.response.any) {
          client.interceptors.response.intercept(ajax).then(() => rej(ajax)).catch((ajax, err) => rej(ajax, err));
        } else rej(ajax);

        return rej(ajax, Error('Request failed.'));
      },

      onTimeout(ajax, res, rej, client) {
        if (ajax.RETRIES >= client.retries) {
          return rej(ajax, Error('Request timed out after ' + ajax.RETRIES + ' retries.'));
        }

        client.__sending.push(ajax.resend());

        ajax.RETRIES += 1;
      }

    }, this);
    ajax._promise_ = promise;
    return promise;
  }
  /**
   * Add ajax request to queue
   * @param {Ajax} ajax
   */


  send(ajax) {
    return this._addRequest(ajax);
  }
  /**
   *
   * @param method
   * @param route
   * @param params
   * @param headers
   * @param content
   * @param responseType
   * @param cancelToken
   * @return {Promise<Ajax>}
   * @private
   */


  _contentRequest(method, route, {
    params,
    headers,
    content,
    responseType,
    cancelToken
  }) {
    if (!startsWith(route, '/') && route.length > 1) {
      route = '/' + route;
    }

    return this._addRequest(method(this.host + route, params || {}).headers(headers || {}).withContent(content || {
      type: '',
      data: ''
    }), {
      responseType,
      cancelToken
    });
  }
  /**
   * Enqueue http GET request
   *
   * @param {String} route - request route - appends to host address
   * @param {Object} [params] - request params(args)
   * @param {Object} [headers] - request headers
   * @param {String} [responseType] - "text"|"json"|"xml"|"document"|"arraybuffer"|"blob"|"ms-stream"|""
   * @param {String} [cancelToken] - A token used to cancel a group of requests
   * @return {Promise<Ajax>}
   */


  get(route, {
    params,
    headers,
    responseType,
    cancelToken
  } = {}) {
    if (!startsWith(route, '/') && route.length > 1) {
      route = '/' + route;
    }

    return this._addRequest(http.Get(this.host + route, params).headers(headers), {
      responseType,
      cancelToken
    });
  }
  /**
   * Enqueue http POST request
   *
   * @param {String} route - request route - appends to host address
   * @param {Object} [params] - request params(args)
   * @param {Object} [headers] - request headers
   * @param {http.HttpContent|Object} [content] - request content. example: {type:'json', data={count: 13}}
   * @param {String} [responseType] - "text"|"json"|"xml"|"document"|"arraybuffer"|"blob"|"ms-stream"|""
   * @param {String} [cancelToken] - A token used to cancel a group of requests
   * @return {Promise<Ajax>}
   */


  post(route, {
    params,
    headers,
    content,
    responseType,
    cancelToken
  } = {}) {
    return this._contentRequest(http.Post, route, {
      params,
      headers,
      content,
      responseType,
      cancelToken
    });
  }
  /**
   * Enqueue http PUT request
   *
   * @param {String} route - request route - appends to host address
   * @param {Object} [params] - request params(args)
   * @param {Object} [headers] - request headers
   * @param {http.HttpContent} [content] - request content. example: {type:'json', data={count: 13}}
   * @param {String} [responseType] - "text"|"json"|"xml"|"document"|"arraybuffer"|"blob"|"ms-stream"|""
   * @param {String} [cancelToken] - A token used to cancel a group of requests
   * @return {Promise<Ajax>}
   */


  put(route, {
    params,
    headers,
    content,
    responseType,
    cancelToken
  } = {}) {
    return this._contentRequest(http.Put, route, {
      params,
      headers,
      content,
      responseType,
      cancelToken
    });
  }
  /**
   * Enqueue http PATCH request
   *
   * @param {String} route - request route - appends to host address
   * @param {Object} [params] - request params(args)
   * @param {Object} [headers] - request headers
   * @param {http.HttpContent} [content] - request content. example: {type:'json', data={count: 13}}
   * @param {String} [responseType] - "text"|"json"|"xml"|"document"|"arraybuffer"|"blob"|"ms-stream"|""
   * @param {String} [cancelToken] - A token used to cancel a group of requests
   * @return {Promise<Ajax>}
   */


  patch(route, {
    params,
    headers,
    content,
    responseType,
    cancelToken
  } = {}) {
    return this._contentRequest(http.Patch, route, {
      params,
      headers,
      content,
      responseType,
      cancelToken
    });
  }
  /**
   * Enqueue http DELETE request
   *
   * @param {String} route - request route - appends to host address
   * @param {Object} [params] - request params(args)
   * @param {Object} [headers] - request headers
   * @param {http.HttpContent} [content] - request content. example: {type:'json', data={count: 13}}
   * @param {String} [responseType] - "text"|"json"|"xml"|"document"|"arraybuffer"|"blob"|"ms-stream"|""
   * @param {String} [cancelToken] - A token used to cancel a group of requests
   * @return {Promise<Ajax>}
   */


  delete(route, {
    params,
    headers,
    content,
    responseType,
    cancelToken
  } = {}) {
    return this._contentRequest(http.Delete, route, {
      params,
      headers,
      content,
      responseType,
      cancelToken
    });
  }
  /**
   * Cancel all requests(sending or enqueued) with given token
   * @param {String} token
   */


  cancel(token) {
    this.__queue = filter(this.__queue, a => a.cancelToken !== token);
    let sending = filter(this.__sending, a => a.cancelToken === token);
    forEach(sending, ajax => {
      try {
        ajax.xhr.abort();
      } catch (e) {
        console.error(e);
      }
    });
    this.__sending = filter(this.__sending, a => a.cancelToken !== token);
  }

  cancelAll() {
    forEach(this.__sending, function (a) {
      try {
        a.xhr.abort();
      } catch (e) {}
    });
    if (this.__interval >= 0) clearInterval(this.__interval);
    this.__queue = [];
  }

}

module.exports = {
  XHttpClient
};
},{"./methods":"7n4Ls","./ajax":"43XEv","../core/collections":"5lqP4","../core/logging":"2ERs7"}],"7n4Ls":[function(require,module,exports) {
/**
 * @fileOverview
 *
 * @module http/methods
 * @memberOf http
 */
const {
  Ajax
} = require("./ajax");

const {
  HttpContent
} = require("./request");
/**
 * A factory for {@link http.Ajax}
 * @private
 * @param {HttpMethod} method - {@link HttpMethod}
 * @param {String} url
 * @param {Object} params
 * @param {Object} headers
 * @param {HttpContent} content
 * @param {Object} callbacks - {success:Function?, fail: Function?, progress: Function?, prepare: Function?,uploadProgress: Function?, uploadFinish: Function?}
 * @return {http.Ajax}
 */


function makeHttpRequest(method, url, params, headers, content, callbacks) {
  let ajax = new Ajax(method.toUpperCase(), url, params, headers);

  if (content && content.type) {
    if (content.type.toLowerCase() === 'json') {
      ajax.jsonData(content.data);
    } else if (content.type.toLowerCase() === 'urlencoded') {
      ajax.urlEncodedData(content.data);
    } else if (content.type.toLowerCase() === 'form') {
      ajax.formData(content.data);
    } else {
      ajax.Rq.setContent(content.type, content.data);
    }
  }

  callbacks.success && ajax.onSuccess(callbacks.success);
  callbacks.fail && ajax.onFail(callbacks.fail);
  callbacks.progress && ajax.onProgress(callbacks.progress);
  callbacks.prepare && (ajax.preparedCallback = callbacks.prepare);
  callbacks.uploadProgress && (ajax.uploadProgressCallback = callbacks.uploadProgress);
  callbacks.uploadFinish && (ajax.uploadFinishCallback = callbacks.uploadFinish);
  return ajax;
} //{method, url, args, headers, type, data, success, fail, progress, prepare, uploadProgress, uploadFinish}

/**
 * A factory for {@link http.Ajax}. creates Ajax request with supplied {@link HttpRequestOptions}
 *
 * @param {HttpRequestOptions} opts
 * @return {http.Ajax}
 */


function makeRequest(opts) {
  return makeHttpRequest(opts.method || 'OPTIONS', opts.url, opts.params, opts.headers, new HttpContent(opts.type, opts.data), {
    success: opts.success,
    fail: opts.fail,
    progress: opts.progress,
    prepare: opts.prepare,
    uploadProgress: opts.uploadProgress,
    uploadFinish: opts.uploadFinish
  });
}
/**
 * @private
 * @param {Ajax} ajax - Ajax request
 * @param {Object} callbacks - ajax event listeners
 * @param {any} extra - passed to callbacks
 * @returns {Promise<Ajax>}
 */


function makePromise(ajax, callbacks = {}, extra = {}) {
  return new Promise((resolve, reject) => {
    ajax.onSuccess(async () => {
      if (callbacks.default) {
        callbacks.default(ajax, resolve, reject, extra);
      }

      let callback = callbacks.onSuccess;
      if (callback) try {
        callback(ajax, resolve, reject, extra);
      } catch (e) {} else resolve(ajax);
    });
    ajax.onFail(async () => {
      if (callbacks.default) {
        callbacks.default(ajax, resolve, reject, extra);
      }

      let callback = callbacks.onFail;
      if (callback) try {
        callback(ajax, resolve, reject, extra);
      } catch (e) {} else reject(ajax);
    });
    ajax.onAbort(async () => {
      if (callbacks.default) {
        callbacks.default(ajax, resolve, reject, extra);
      }

      let callback = callbacks.onAbort;
      if (callback) try {
        callback(ajax, resolve, reject, extra);
      } catch (e) {} else reject(ajax);
    });
    ajax.onTimeout(async () => {
      if (callbacks.default) {
        callbacks.default(ajax, resolve, reject, extra);
      }

      let callback = callbacks.onTimeout;
      if (callback) try {
        callback(ajax, resolve, reject, extra);
      } catch (e) {} else reject(ajax);
    });
  });
}
/**
 * Send request asynchronously
 *
 * @param {HttpRequestOptions} opts
 * @return {Promise<any>}
 */


async function sendRequest(opts) {
  let r = makeRequest(opts);
  r.send(opts.finish);
  return await makePromise(r);
}
/**
 * Create Ajax GET request
 *
 * @param {String} url - server url
 * @param {Object} [params] - query string params
 * @returns {http.Ajax}
 */


function Get(url, params) {
  return new Ajax('GET', url, params);
}
/**
 * Create Ajax POST request
 *
 * @param {String} url - server url
 * @param {Object} [params] - query string params
 */


function Post(url, params) {
  return new Ajax('POST', url, params);
}
/**
 * Create Ajax DELETE request
 *
 * @param {String} url - server url
 * @param {Object} [params] - query string params
 * @returns {http.Ajax}
 */


function Delete(url, params) {
  return new Ajax('DELETE', url, params);
}
/**
 * Create Ajax PUT request
 *
 * @param {String} url - server url
 * @param {Object} [params] - query string params
 * @returns {Ajax}
 */


function Put(url, params) {
  return new Ajax('PUT', url, params);
}
/**
 * Create Ajax PATCH request
 *
 * @param {String} url - server url
 * @param {Object} [params] - query string params
 * @returns {http.Ajax}
 */


function Patch(url, params) {
  return new Ajax('PATCH', url, params);
}
/**
 * Create and send GET request
 *
 * @param {HttpRequestOptions} opt
 * @return {Promise<http.Ajax>}
 */


function sendGet(opt) {
  opt.method = 'GET';
  opt.type = undefined;
  opt.data = undefined;
  return sendRequest(opt);
}
/**
 * Create and send DELETE request
 *
 * @param {HttpRequestOptions} opt
 * @return {Promise<http.Ajax>}
 */


function sendDelete(opt) {
  opt.method = 'DELETE';
  return sendRequest(opt);
}
/**
 * Create and send POST request
 *
 * @param {HttpRequestOptions} opt
 * @return {Promise<http.Ajax>}
 */


function sendPost(opt) {
  opt.method = 'POST';
  return sendRequest(opt);
}
/**
 * Create and send PUT request
 *
 * @param {HttpRequestOptions} opt
 * @return {Promise<http.Ajax>}
 */


function sendPut(opt) {
  opt.method = 'PUT';
  return sendRequest(opt);
}
/**
 * Create and send PATCH request
 *
 * @param {HttpRequestOptions} opt
 * @return {Promise<http.Ajax>}
 */


function sendPatch(opt) {
  opt.method = 'PATCH';
  return sendRequest(opt);
}

module.exports = {
  makeHttpRequest,
  makeRequest,
  makePromise,
  sendRequest,
  Get,
  Post,
  Delete,
  Put,
  Patch,
  sendGet,
  sendDelete,
  sendPost,
  sendPut,
  sendPatch
};
},{"./ajax":"43XEv","./request":"4NLzo"}],"43XEv":[function(require,module,exports) {
/**
 * Wrapper class for XHR
 * @module http/ajax
 * @memberOf http
 */
const {
  HttpRq,
  HttpContent
} = require("./request");

const {
  HttpRs
} = require("./response");

const T = require("../core/types");

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

const {
  forEach,
  deepClone
} = require("../core/collections");
/**
 * A wrapper class for {@link XMLHttpRequest} to facilitate sending requests and handling events
 * @class
 * @property {Response} rs
 * @property {Request} rq
 */


class Ajax {
  /**
   * @constructor
   * @param {HttpMethod|HttpRq} m - Request method string or {@link http.HttpRq}
   * @param {String} [url]
   * @param {Object} [params] - Request parameters object
   * @param {Object?} [headers] - Headers object
   * @param {HttpContent?} [content] - Optional http content {@link HttpContent}
   */
  constructor(m, url, params = {}, headers = {}, content = new HttpContent()) {
    /** @type {HttpRq}
     * @see {http.HttpRq}
     */
    this.rq = {};
    /** @type {http.HttpRs}
     * @see {http.HttpRs}
     */

    this.rs = {};

    if (m instanceof HttpRq) {
      this.rq = m;
    } else {
      this.rq = new HttpRq(m, url, params, headers, content);
    } // Fields


    this.rs = {
      readyState: 0
    };
    this.xhr = new XMLHttpRequest();

    this.preparedCallback = function (ajax) {};

    this.progressCallback = function (ajax, event) {};

    this.uploadProgressCallback = function (ajax, event) {};

    this.successCallback = function (ajax) {};

    this.uploadFinishCallback = function (ajax) {};

    this.failCallback = function (ajax, error) {};

    this.timeoutCallback = function (ajax) {};

    this.abortCallback = function (ajax) {};

    Object.defineProperty(this, 'xhr', {
      enumerable: false
    });
  } // Methods

  /**
   * Set header
   * @param {String} n - header name
   * @param {String} [v] - header value
   * @returns {Ajax}
   */


  header(n, v) {
    this.rq.setHeader(n, v);
    return this;
  }

  /**
   * Add/Set headers
   * @param {Object} hdrs - headers object
   * @returns {Ajax}
   */
  headers(hdrs = {}) {
    forEach(hdrs, (v, k) => {
      this.rq.setHeader(k, v);
    });
    return this;
  }

  /**
   * @param {Function} callback
   * @returns {Ajax}
   */
  onSuccess(callback) {
    this.successCallback = callback;
    return this;
  }

  /**
   * @param {Function} callback
   * @returns {Ajax}
   */
  onUploadSuccess(callback) {
    this.uploadFinishCallback = callback;
    return this;
  }

  /**
   * @param {Function} callback
   * @returns {Ajax}
   */
  onFail(callback) {
    this.failCallback = callback;
    return this;
  }

  onTimeout(callback) {
    this.timeoutCallback = callback;
    return this;
  }

  onAbort(callback) {
    this.abortCallback = callback;
    return this;
  }
  /**
   * @param {Function} callback
   * @returns {Ajax}
   */


  onProgress(callback) {
    this.progressCallback = callback;
    return this;
  }

  /**
   * @param {Function} callback
   * @returns {Ajax}
   */
  onUploadProgress(callback) {
    this.uploadProgressCallback = callback;
    return this;
  }

  /**
   * Set custom content {@link HttpContent}
   * @param {HttpContent} content
   * @returns {Ajax}
   */
  withContent(content = {}) {
    switch (content.type) {
      case 'json':
        this.rq.jsonContent(content.data);
        break;

      case 'xml':
        this.rq.xmlContent(content.data);
        break;

      case 'form':
        this.rq.formContent(content.data);
        break;

      case 'form_multipart':
        this.rq.formMultiPartContent(content.data);
        break;

      case 'form_urlencoded':
        this.rq.formUrlEncodedContent(content.data);
        break;

      default:
        this.rq.setContent(content.type, content.data);
    }

    return this;
  }
  /**
   * Set xml request data
   * @param {XMLDocument} data
   * @returns {Ajax}
   */


  xmlData(data) {
    this.rq.xmlContent(data);
    return this;
  }
  /**
   * Set form-data request data
   * @param {String|Node} form
   * @returns {Ajax}
   */


  formData(form) {
    this.rq.formContent(form);
    return this;
  }

  /**
   * Set json request data
   * @param {String|Object} data
   * @returns {Ajax}
   */
  jsonData(data) {
    this.rq.jsonContent(data);
    return this;
  }

  /**
   * Set url-encoded request data
   * @param {Object} data - simple data object
   * @returns {Ajax}
   */
  urlEncodedData(data) {
    this.rq.formUrlEncodedContent(data);
    return this;
  }

  prepare(reset) {
    if (this.isPrepared && !reset) {
      // self.onprepare && self.onprepare(self.rq);
      return this;
    } // prepare url


    let url = this.rq.url;

    if (this.rq.args && !T.isEmpty(this.rq.args)) {
      url.indexOf('?') >= 0 || (url += '?');
      url += this.rq.buildUrlEncoded();
    }

    this.rs = {
      readyState: 0
    };
    reset && (this.xhr = new XMLHttpRequest());
    this.xhr.open(this.rq.method, url); // prepare headers

    forEach(this.rq.headers, (val, key) => {
      try {
        this.xhr.setRequestHeader(key, this.rq.headers[val]);
      } catch (e) {
        error('Error while setting default header \n>>(', key, ')<< Non-standard header name.');
      }
    });
    let ajax = this;
    let xhr = this.xhr;

    this.xhr.onreadystatechange = function (ev) {
      // onloadend
      if (xhr.readyState === 4 && xhr.status !== 0) {
        let callback = ajax.failCallback;

        if (xhr.status >= 200 && xhr.status <= 399) {
          callback = ajax.successCallback;
        }

        ajax.rs = new HttpRs(xhr);
        callback && callback(ajax);
      }
    };

    this.xhr.onerror = function (ev) {
      ajax.failCallback && ajax.failCallback(ajax, ev);
    };

    this.xhr.onprogress = function (ev) {
      ajax.progressCallback && ajax.progressCallback(ajax, ev);
    };

    this.xhr.upload.onprogress = function (ev) {
      ajax.uploadProgressCallback && ajax.uploadProgressCallback(ajax, ev);
    };

    this.xhr.upload.onloadend = function (ev) {
      ajax.uploadFinishCallback && ajax.uploadFinishCallback(ajax, ev);
    };

    this.xhr.ontimeout = function (ev) {
      ajax.timeoutCallback && ajax.timeoutCallback(ajax, ev);
    };

    this.xhr.onabort = function (ev) {
      ajax.abortCallback && ajax.abortCallback(ajax, ev);
    };

    this.isPrepared = true;
    this.preparedCallback && this.preparedCallback(this.rq); // preparedCallback && preparedCallback();

    return this;
  }

  /**
   * Send XHR request
   * @returns {Ajax}
   */
  send() {
    this.prepare();

    try {
      this.xhr.send(this.rq.content.data);
    } catch (e) {
      this.failCallback(this, e);
    }

    return this;
  }

  resend() {
    return this.prepare(true).send();
  }
  /**
   * Send request with Promise
   * @return {Promise<Ajax>}
   */


  async sendAsync() {
    const ajax = this;
    const promise = new Promise((res, rej) => {
      ajax.onSuccess(() => {
        return res(ajax);
      });
      ajax.onFail(() => {
        rej(ajax);
      });
    });
    ajax.send();
    return promise;
  }

}

module.exports = {
  Ajax: Ajax
};
},{"./request":"4NLzo","./response":"6yscX","../core/types":"5jEMv","../core/collections":"5lqP4","../core/logging":"2ERs7"}],"4NLzo":[function(require,module,exports) {
const T = require("../core/types");

const {
  $,
  $$
} = require("../dom/query");
/**
 * Http Content class
 */


class HttpContent {
  constructor(type, data) {
    /**
     * @type {String}
     */
    this.type = type;
    /**
     * @type {String|Object|Element}
     */

    this.data = data;
  }

}
/**
 * Http request class
 * @class
 */


class HttpRq {
  /**
   * @param {HttpMethod} m
   */
  setMethod(m) {
    this.method = m.toUpperCase();
  }

  /**
   * @param {String} u
   */
  setUrl(u) {
    this.url = encodeURI(u);
  }

  /**
   * Set request param/arg
   * @param {String} n - name
   * @param {String} v - value
   */
  setArg(n, v) {
    this.args[n] = v;
  }

  buildUrlEncoded(args) {
    let ue = "";
    args = args || this.args;
    let argNames = Object.keys(args);

    if (argNames.length > 0) {
      for (let i = 0; i < argNames.length; i++) {
        ue += encodeURIComponent(argNames[i]) + '=' + encodeURIComponent(args[argNames[i]]);

        if (i < argNames.length - 1) {
          ue += '&';
        }
      }
    }

    return ue;
  }

  /**
   * Set request header
   * @param {String} n - name
   * @param {String} v - value
   */
  setHeader(n, v) {
    this.headers[n] = v.toString();
  }

  /**
   * Get request header
   * @param {String} n - name
   */
  getHeader(n) {
    return this.headers[n];
  }

  /**
   * Set request content
   * @param {String} contentType
   * @param {any} data
   */
  setContent(contentType, data) {
    this.content.type = contentType.toLowerCase();
    this.content.data = data;
  }

  /**
   * Set request json content
   * @param {String|Object} data
   */
  jsonContent(data) {
    let str = "";

    if (typeof data === "string") {
      str = data;
    } else {
      str = JSON.stringify(data);
    }

    this.setContent('json', str);
    this.setHeader('Content-Type', 'application/json');
  }

  /**
   * Set request xml content
   * @param {String|Node} data
   */
  xmlContent(data) {
    if (T.isStr(data)) this.setContent('xml', data);else this.setContent('xml', data.outerHTML);
    this.setHeader('Content-Type', 'application/xml');
  }

  /**
   * Set request multipart data from Form element
   * @param {String|Node|Element} form - form element/id
   */
  formContent(form) {
    let formElement = $$(form)[0];
    let frm = new FormData(formElement);
    this.formMultiPartContent(frm);
  }

  /**
   * Set request multipart data from FormData object
   * @param {FormData} frm - custom form data object
   */
  formMultiPartContent(frm) {
    this.setContent('form_multipart', frm); // this.setHeader('Content-Type', 'multipart/form-data; boundary=' + frm.boundary)
  }

  /**
   * Set request data as urlencoded
   * @param {Object} data
   */
  formUrlEncodedContent(data) {
    this.setContent('form_urlencoded', this.buildUrlEncoded(data));
    this.setHeader('Content-Type', 'application/x-www-form-urlencoded');
  }

  /**
   *
   * @param {HttpMethod} method
   * @param {String} url
   * @param {Object} args
   * @param {Object} headers
   * @param {HttpContent} content
   */
  constructor(method = 'GET', url, args, headers, content) {
    this.args = args || {};
    this.headers = headers || {};
    this.content = content || new HttpContent('#urlencoded', {});
    this.setMethod(method);
    this.setUrl(url);
  }

}

module.exports = {
  HttpContent,
  HttpRq
};
},{"../core/types":"5jEMv","../dom/query":"64qtq"}],"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
};
},{}],"64qtq":[function(require,module,exports) {
/**
 * @module DOM
 * @memberOf dom
 */
const {
  isEl,
  isEls,
  isStr,
  isVal
} = require("../core/types");

const L = require("../core/logging");

const {
  cls
} = require("../dom/classes"); //
// import {isEl, isEls, isStr, isVal} from "../core/types";
// import {error} from "../core/logging";
// import {cls} from "../dom/classes";
//

/**
 * jQuery-like select "all" by query accepts element, nodes or query
 * @param {String|HTMLElement|Element|Node|HTMLCollection|NodeList} q - query string
 * @param {HTMLElement|Element|Node} [root] - root which query is issued from
 * @return {Array}
 */


function $(q, root = document) {
  if (isEl(q)) return Array.of(q);
  if (isEls(q)) return Array.from(q);

  if (!isStr(q)) {
    L.error(`Query is not string nor element X.$(${q})`);
    return null;
  }

  if (!isEl(root)) {
    L.error(`Query root is not a node!\t[X.$(${q}, ${root})]`);
    return null;
  }

  return Array.from(root.querySelectorAll(q));
}
/**
 * jQuery-like select "one" by query accepts element, node or query
 * @param {String|HTMLElement|Element|Node} q - query string
 * @param {HTMLElement|Element|Node} [root] - root which query is issued from
 * @return {Array} - returns array of length=1
 */


function $$(q, root = document) {
  if (isEl(q)) return Array.of(q);

  if (!isStr(q)) {
    L.error(`Query is not string nor element X.$$(${q})`);
    return null;
  }

  if (!isEl(root)) {
    L.error(`Query root is not a node!\t[X.$(${q}, ${root})]`);
    return null;
  }

  return Array.of(root.querySelector(q));
}
/**
 * Generate relative query of given element/node
 * @param {HTMLElement|Element|Node} e - element/node
 * @param {HTMLElement|Element|Node} maxParent - parent where the query relates to
 * @return {String} - query relative to maxParent
 */


function queryOf(e, maxParent, q) {
  if (!isVal(e) || !isEl(e)) {
    L.error(`\nQuery generator's first parameter must be Element/Node! CAUSE: X.queryOf(${e}, ${maxParent})`);
    return null;
  }

  maxParent = maxParent || document.body;
  let gen = e.tagName;
  q = q || "";

  if (e.id) {
    gen += e.id ? '#' + e.id : "";
    return gen + (!(q === "") ? ' ' + q : "");
  }

  cls(e).items.forEach(function (value) {
    gen = gen + (value !== '' ? '.' + value : '');
  });

  if (gen) {
    let sibs = $(gen, e.parentElement);

    if (sibs.length > 1) {
      let idx = Array.from(e.parentElement.children).findIndex(function (i) {
        return e === i;
      });

      if (idx > 0) {
        gen = gen + ":nth-child(" + (idx + 1) + ")";
      }
    }
  }

  if (e.parentElement && e.parentElement !== maxParent && e.parentElement !== document) {
    return queryOf(e.parentElement, maxParent) + " > " + gen + (!(q === "") ? ' ' + q : "");
  } else {
    return gen + (!(q === "") ? ' ' + q : "");
  }
}

module.exports = {
  $,
  $$,
  queryOf
};
},{"../core/types":"5jEMv","../core/logging":"2ERs7","../dom/classes":"3SYwY"}],"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
};
},{}],"3SYwY":[function(require,module,exports) {
/**
 * @module DOM
 * @memberOf dom
 */
const T = require("../core/types");

const {
  toggle,
  any,
  all,
  contains,
  filter,
  flatMap,
  forEach
} = require("../core/collections");
/**
 * Element classes CRUD wrapper
 * @memberOf dom
 */


class Classes {
  /**
   * Split element `className`
   * @param className
   * @return {String[]}
   */
  static split(className) {
    return className.trim().replace(/\s+/, ' ').split(' ');
  }
  /**
   * @param {HTMLElement|Element|Node} e - element
   */


  constructor(e) {
    this.element = e;
    Object.defineProperty(this, 'items', {
      get() {
        return this.classes;
      },

      set(v) {
        let upd = false;
        if (this.classes) upd = true;
        if (!T.isVal(v) || T.isEmpty(v)) this.classes = [];else if (T.isArr(v)) this.classes = v;else if (T.isStr(v)) this.classes = Classes.split(v);else if (v instanceof DOMTokenList) this.classes = Array.from(v);
        if (upd) this.__update__();
      }

    });
    this.items = e.getAttribute('class');
  }
  /**
   * Equivalent of `new Classes(e)`
   * @param e
   * @return {dom.Classes}
   */


  static of(e) {
    return new Classes(e);
  }

  __update__() {
    this.element.setAttribute('class', this.classes.join(' '));
  }
  /**
   * Element has class(es)
   * @param {String} c - class(es)
   * @return {boolean}
   */


  contains(...c) {
    c = flatMap(c);
    return all(c, it => contains(this.classes, it));
  }
  /**
   * Add class(es)
   * @param {String} c - class(es)
   */


  add(...c) {
    c = flatMap(c);
    forEach(c, it => {
      if (!this.contains(it)) {
        this.classes.push(it.toString());
      }
    });

    this.__update__();
  }
  /**
   * Remove class(es)
   * @param {String} c - class(es)
   * @return {boolean}
   */


  remove(...c) {
    c = flatMap(c);
    let l = this.classes.length;
    this.classes = filter(this.classes, it => {
      return !any(c, ci => ci.endsWith('*') ? it.startsWith(ci.replace('*', '')) : it === ci);
    });

    this.__update__();

    return l !== this.classes.length;
  }
  /**
   * Toggle class(es) - if exists toggle else adds
   * @param {String} c - class(es)
   */


  toggle(...c) {
    toggle(this.classes, c);

    this.__update__();
  }

}

Object.seal(Classes);
/**
 * Equivalent of `[new Classes(e)]{@link dom.Classes}`
 * @param e
 * @return {dom.Classes}
 */

function cls(e) {
  return Classes.of(e);
}
/**
 * Add class(es) [cls(e).add()]{@link dom.Classes#add}
 * @param {HTMLElement|Element|Node} e - element
 * @param c
 */


function addClass(e, ...c) {
  Classes.of(e).add(c);
}
/**
 * Remove class(es) [cls(e).remove()]{@link dom.Classes#remove}
 * @param {HTMLElement|Element|Node} e - element
 * @param c
 */


function removeClass(e, ...c) {
  Classes.of(e).remove(c);
}
/**
 * Has class(es) [cls(e).contains()]{@link dom.Classes#contains}
 * @param {HTMLElement|Element|Node} e - element
 * @param c
 */


function hasClass(e, ...c) {
  Classes.of(e).contains(c);
}
/**
 * Toggle classes [cls(e).toggle()]{@link dom.Classes#toggle}
 * @param {HTMLElement|Element|Node} e - element
 * @param c
 */


function toggleClass(e, ...c) {
  Classes.of(e).toggle(c);
}

module.exports = {
  Classes,
  cls,
  addClass,
  hasClass,
  removeClass,
  toggleClass
};
},{"../core/types":"5jEMv","../core/collections":"5lqP4"}],"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"}],"6yscX":[function(require,module,exports) {
/**
 * Http Response class
 * @property json {Object}
 * @property xml {XMLDocument}
 *
 */
class HttpRs {
  /**
   * @constructor
   * @param {XMLHttpRequest} xhr
   */
  constructor(xhr) {
    this.xhr = xhr;
    this.status = {
      code: xhr.status,
      text: xhr.statusText
    };
    this.headers = xhr.getAllResponseHeaders();
    this.contentLength = xhr.response.length || 0;
    this.data = xhr.response;
    this.json = undefined;
    this.xml = undefined;
    if (xhr.responseType === 'text' || xhr.responseType === '') this.text = xhr.responseText;
    Object.defineProperty(this, 'json', {
      get() {
        try {
          if (!xhr.responseJSON) {
            xhr.responseJSON = JSON.parse(this.xhr.responseText);
          }
        } catch (e) {
          console.log(e);
        }

        return xhr.responseJSON;
      }

    });
    Object.defineProperty(this, 'xml', {
      get() {
        try {
          if (!xhr.responseXML && !xhr.responseXml) {
            let parser = new DOMParser();
            xhr.responseXml = parser.parseFromString(self.text, "text/xml");
          }
        } catch (e) {
          console.log(e);
        }

        return xhr.responseXml;
      }

    });
  }

}

module.exports = {
  HttpRs
};
},{}]},{},["5kQFr","1kpA9"], "1kpA9", "parcelRequire430d")

//# sourceMappingURL=index2.a09910ec.js.map
