HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/SBogers10/demo.komma.pro/wwwroot/js/site/core.js
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }

/*! Hammer.JS - v2.0.8 - 2016-04-23
 * http://hammerjs.github.io/
 *
 * Copyright (c) 2016 Jorik Tangelder;
 * Licensed under the MIT license */
!function (a, b, c, d) {
  "use strict";

  function e(a, b, c) {
    return setTimeout(j(a, c), b);
  }

  function f(a, b, c) {
    return Array.isArray(a) ? (g(a, c[b], c), !0) : !1;
  }

  function g(a, b, c) {
    var e;
    if (a) if (a.forEach) a.forEach(b, c);else if (a.length !== d) for (e = 0; e < a.length;) {
      b.call(c, a[e], e, a), e++;
    } else for (e in a) {
      a.hasOwnProperty(e) && b.call(c, a[e], e, a);
    }
  }

  function h(b, c, d) {
    var e = "DEPRECATED METHOD: " + c + "\n" + d + " AT \n";
    return function () {
      var c = new Error("get-stack-trace"),
          d = c && c.stack ? c.stack.replace(/^[^\(]+?[\n$]/gm, "").replace(/^\s+at\s+/gm, "").replace(/^Object.<anonymous>\s*\(/gm, "{anonymous}()@") : "Unknown Stack Trace",
          f = a.console && (a.console.warn || a.console.log);
      return f && f.call(a.console, e, d), b.apply(this, arguments);
    };
  }

  function i(a, b, c) {
    var d,
        e = b.prototype;
    d = a.prototype = Object.create(e), d.constructor = a, d._super = e, c && la(d, c);
  }

  function j(a, b) {
    return function () {
      return a.apply(b, arguments);
    };
  }

  function k(a, b) {
    return _typeof(a) == oa ? a.apply(b ? b[0] || d : d, b) : a;
  }

  function l(a, b) {
    return a === d ? b : a;
  }

  function m(a, b, c) {
    g(q(b), function (b) {
      a.addEventListener(b, c, !1);
    });
  }

  function n(a, b, c) {
    g(q(b), function (b) {
      a.removeEventListener(b, c, !1);
    });
  }

  function o(a, b) {
    for (; a;) {
      if (a == b) return !0;
      a = a.parentNode;
    }

    return !1;
  }

  function p(a, b) {
    return a.indexOf(b) > -1;
  }

  function q(a) {
    return a.trim().split(/\s+/g);
  }

  function r(a, b, c) {
    if (a.indexOf && !c) return a.indexOf(b);

    for (var d = 0; d < a.length;) {
      if (c && a[d][c] == b || !c && a[d] === b) return d;
      d++;
    }

    return -1;
  }

  function s(a) {
    return Array.prototype.slice.call(a, 0);
  }

  function t(a, b, c) {
    for (var d = [], e = [], f = 0; f < a.length;) {
      var g = b ? a[f][b] : a[f];
      r(e, g) < 0 && d.push(a[f]), e[f] = g, f++;
    }

    return c && (d = b ? d.sort(function (a, c) {
      return a[b] > c[b];
    }) : d.sort()), d;
  }

  function u(a, b) {
    for (var c, e, f = b[0].toUpperCase() + b.slice(1), g = 0; g < ma.length;) {
      if (c = ma[g], e = c ? c + f : b, e in a) return e;
      g++;
    }

    return d;
  }

  function v() {
    return ua++;
  }

  function w(b) {
    var c = b.ownerDocument || b;
    return c.defaultView || c.parentWindow || a;
  }

  function x(a, b) {
    var c = this;
    this.manager = a, this.callback = b, this.element = a.element, this.target = a.options.inputTarget, this.domHandler = function (b) {
      k(a.options.enable, [a]) && c.handler(b);
    }, this.init();
  }

  function y(a) {
    var b,
        c = a.options.inputClass;
    return new (b = c ? c : xa ? M : ya ? P : wa ? R : L)(a, z);
  }

  function z(a, b, c) {
    var d = c.pointers.length,
        e = c.changedPointers.length,
        f = b & Ea && d - e === 0,
        g = b & (Ga | Ha) && d - e === 0;
    c.isFirst = !!f, c.isFinal = !!g, f && (a.session = {}), c.eventType = b, A(a, c), a.emit("hammer.input", c), a.recognize(c), a.session.prevInput = c;
  }

  function A(a, b) {
    var c = a.session,
        d = b.pointers,
        e = d.length;
    c.firstInput || (c.firstInput = D(b)), e > 1 && !c.firstMultiple ? c.firstMultiple = D(b) : 1 === e && (c.firstMultiple = !1);
    var f = c.firstInput,
        g = c.firstMultiple,
        h = g ? g.center : f.center,
        i = b.center = E(d);
    b.timeStamp = ra(), b.deltaTime = b.timeStamp - f.timeStamp, b.angle = I(h, i), b.distance = H(h, i), B(c, b), b.offsetDirection = G(b.deltaX, b.deltaY);
    var j = F(b.deltaTime, b.deltaX, b.deltaY);
    b.overallVelocityX = j.x, b.overallVelocityY = j.y, b.overallVelocity = qa(j.x) > qa(j.y) ? j.x : j.y, b.scale = g ? K(g.pointers, d) : 1, b.rotation = g ? J(g.pointers, d) : 0, b.maxPointers = c.prevInput ? b.pointers.length > c.prevInput.maxPointers ? b.pointers.length : c.prevInput.maxPointers : b.pointers.length, C(c, b);
    var k = a.element;
    o(b.srcEvent.target, k) && (k = b.srcEvent.target), b.target = k;
  }

  function B(a, b) {
    var c = b.center,
        d = a.offsetDelta || {},
        e = a.prevDelta || {},
        f = a.prevInput || {};
    b.eventType !== Ea && f.eventType !== Ga || (e = a.prevDelta = {
      x: f.deltaX || 0,
      y: f.deltaY || 0
    }, d = a.offsetDelta = {
      x: c.x,
      y: c.y
    }), b.deltaX = e.x + (c.x - d.x), b.deltaY = e.y + (c.y - d.y);
  }

  function C(a, b) {
    var c,
        e,
        f,
        g,
        h = a.lastInterval || b,
        i = b.timeStamp - h.timeStamp;

    if (b.eventType != Ha && (i > Da || h.velocity === d)) {
      var j = b.deltaX - h.deltaX,
          k = b.deltaY - h.deltaY,
          l = F(i, j, k);
      e = l.x, f = l.y, c = qa(l.x) > qa(l.y) ? l.x : l.y, g = G(j, k), a.lastInterval = b;
    } else c = h.velocity, e = h.velocityX, f = h.velocityY, g = h.direction;

    b.velocity = c, b.velocityX = e, b.velocityY = f, b.direction = g;
  }

  function D(a) {
    for (var b = [], c = 0; c < a.pointers.length;) {
      b[c] = {
        clientX: pa(a.pointers[c].clientX),
        clientY: pa(a.pointers[c].clientY)
      }, c++;
    }

    return {
      timeStamp: ra(),
      pointers: b,
      center: E(b),
      deltaX: a.deltaX,
      deltaY: a.deltaY
    };
  }

  function E(a) {
    var b = a.length;
    if (1 === b) return {
      x: pa(a[0].clientX),
      y: pa(a[0].clientY)
    };

    for (var c = 0, d = 0, e = 0; b > e;) {
      c += a[e].clientX, d += a[e].clientY, e++;
    }

    return {
      x: pa(c / b),
      y: pa(d / b)
    };
  }

  function F(a, b, c) {
    return {
      x: b / a || 0,
      y: c / a || 0
    };
  }

  function G(a, b) {
    return a === b ? Ia : qa(a) >= qa(b) ? 0 > a ? Ja : Ka : 0 > b ? La : Ma;
  }

  function H(a, b, c) {
    c || (c = Qa);
    var d = b[c[0]] - a[c[0]],
        e = b[c[1]] - a[c[1]];
    return Math.sqrt(d * d + e * e);
  }

  function I(a, b, c) {
    c || (c = Qa);
    var d = b[c[0]] - a[c[0]],
        e = b[c[1]] - a[c[1]];
    return 180 * Math.atan2(e, d) / Math.PI;
  }

  function J(a, b) {
    return I(b[1], b[0], Ra) + I(a[1], a[0], Ra);
  }

  function K(a, b) {
    return H(b[0], b[1], Ra) / H(a[0], a[1], Ra);
  }

  function L() {
    this.evEl = Ta, this.evWin = Ua, this.pressed = !1, x.apply(this, arguments);
  }

  function M() {
    this.evEl = Xa, this.evWin = Ya, x.apply(this, arguments), this.store = this.manager.session.pointerEvents = [];
  }

  function N() {
    this.evTarget = $a, this.evWin = _a, this.started = !1, x.apply(this, arguments);
  }

  function O(a, b) {
    var c = s(a.touches),
        d = s(a.changedTouches);
    return b & (Ga | Ha) && (c = t(c.concat(d), "identifier", !0)), [c, d];
  }

  function P() {
    this.evTarget = bb, this.targetIds = {}, x.apply(this, arguments);
  }

  function Q(a, b) {
    var c = s(a.touches),
        d = this.targetIds;
    if (b & (Ea | Fa) && 1 === c.length) return d[c[0].identifier] = !0, [c, c];
    var e,
        f,
        g = s(a.changedTouches),
        h = [],
        i = this.target;
    if (f = c.filter(function (a) {
      return o(a.target, i);
    }), b === Ea) for (e = 0; e < f.length;) {
      d[f[e].identifier] = !0, e++;
    }

    for (e = 0; e < g.length;) {
      d[g[e].identifier] && h.push(g[e]), b & (Ga | Ha) && delete d[g[e].identifier], e++;
    }

    return h.length ? [t(f.concat(h), "identifier", !0), h] : void 0;
  }

  function R() {
    x.apply(this, arguments);
    var a = j(this.handler, this);
    this.touch = new P(this.manager, a), this.mouse = new L(this.manager, a), this.primaryTouch = null, this.lastTouches = [];
  }

  function S(a, b) {
    a & Ea ? (this.primaryTouch = b.changedPointers[0].identifier, T.call(this, b)) : a & (Ga | Ha) && T.call(this, b);
  }

  function T(a) {
    var b = a.changedPointers[0];

    if (b.identifier === this.primaryTouch) {
      var c = {
        x: b.clientX,
        y: b.clientY
      };
      this.lastTouches.push(c);

      var d = this.lastTouches,
          e = function e() {
        var a = d.indexOf(c);
        a > -1 && d.splice(a, 1);
      };

      setTimeout(e, cb);
    }
  }

  function U(a) {
    for (var b = a.srcEvent.clientX, c = a.srcEvent.clientY, d = 0; d < this.lastTouches.length; d++) {
      var e = this.lastTouches[d],
          f = Math.abs(b - e.x),
          g = Math.abs(c - e.y);
      if (db >= f && db >= g) return !0;
    }

    return !1;
  }

  function V(a, b) {
    this.manager = a, this.set(b);
  }

  function W(a) {
    if (p(a, jb)) return jb;
    var b = p(a, kb),
        c = p(a, lb);
    return b && c ? jb : b || c ? b ? kb : lb : p(a, ib) ? ib : hb;
  }

  function X() {
    if (!fb) return !1;
    var b = {},
        c = a.CSS && a.CSS.supports;
    return ["auto", "manipulation", "pan-y", "pan-x", "pan-x pan-y", "none"].forEach(function (d) {
      b[d] = c ? a.CSS.supports("touch-action", d) : !0;
    }), b;
  }

  function Y(a) {
    this.options = la({}, this.defaults, a || {}), this.id = v(), this.manager = null, this.options.enable = l(this.options.enable, !0), this.state = nb, this.simultaneous = {}, this.requireFail = [];
  }

  function Z(a) {
    return a & sb ? "cancel" : a & qb ? "end" : a & pb ? "move" : a & ob ? "start" : "";
  }

  function $(a) {
    return a == Ma ? "down" : a == La ? "up" : a == Ja ? "left" : a == Ka ? "right" : "";
  }

  function _(a, b) {
    var c = b.manager;
    return c ? c.get(a) : a;
  }

  function aa() {
    Y.apply(this, arguments);
  }

  function ba() {
    aa.apply(this, arguments), this.pX = null, this.pY = null;
  }

  function ca() {
    aa.apply(this, arguments);
  }

  function da() {
    Y.apply(this, arguments), this._timer = null, this._input = null;
  }

  function ea() {
    aa.apply(this, arguments);
  }

  function fa() {
    aa.apply(this, arguments);
  }

  function ga() {
    Y.apply(this, arguments), this.pTime = !1, this.pCenter = !1, this._timer = null, this._input = null, this.count = 0;
  }

  function ha(a, b) {
    return b = b || {}, b.recognizers = l(b.recognizers, ha.defaults.preset), new ia(a, b);
  }

  function ia(a, b) {
    this.options = la({}, ha.defaults, b || {}), this.options.inputTarget = this.options.inputTarget || a, this.handlers = {}, this.session = {}, this.recognizers = [], this.oldCssProps = {}, this.element = a, this.input = y(this), this.touchAction = new V(this, this.options.touchAction), ja(this, !0), g(this.options.recognizers, function (a) {
      var b = this.add(new a[0](a[1]));
      a[2] && b.recognizeWith(a[2]), a[3] && b.requireFailure(a[3]);
    }, this);
  }

  function ja(a, b) {
    var c = a.element;

    if (c.style) {
      var d;
      g(a.options.cssProps, function (e, f) {
        d = u(c.style, f), b ? (a.oldCssProps[d] = c.style[d], c.style[d] = e) : c.style[d] = a.oldCssProps[d] || "";
      }), b || (a.oldCssProps = {});
    }
  }

  function ka(a, c) {
    var d = b.createEvent("Event");
    d.initEvent(a, !0, !0), d.gesture = c, c.target.dispatchEvent(d);
  }

  var la,
      ma = ["", "webkit", "Moz", "MS", "ms", "o"],
      na = b.createElement("div"),
      oa = "function",
      pa = Math.round,
      qa = Math.abs,
      ra = Date.now;
  la = "function" != typeof Object.assign ? function (a) {
    if (a === d || null === a) throw new TypeError("Cannot convert undefined or null to object");

    for (var b = Object(a), c = 1; c < arguments.length; c++) {
      var e = arguments[c];
      if (e !== d && null !== e) for (var f in e) {
        e.hasOwnProperty(f) && (b[f] = e[f]);
      }
    }

    return b;
  } : Object.assign;
  var sa = h(function (a, b, c) {
    for (var e = Object.keys(b), f = 0; f < e.length;) {
      (!c || c && a[e[f]] === d) && (a[e[f]] = b[e[f]]), f++;
    }

    return a;
  }, "extend", "Use `assign`."),
      ta = h(function (a, b) {
    return sa(a, b, !0);
  }, "merge", "Use `assign`."),
      ua = 1,
      va = /mobile|tablet|ip(ad|hone|od)|android/i,
      wa = "ontouchstart" in a,
      xa = u(a, "PointerEvent") !== d,
      ya = wa && va.test(navigator.userAgent),
      za = "touch",
      Aa = "pen",
      Ba = "mouse",
      Ca = "kinect",
      Da = 25,
      Ea = 1,
      Fa = 2,
      Ga = 4,
      Ha = 8,
      Ia = 1,
      Ja = 2,
      Ka = 4,
      La = 8,
      Ma = 16,
      Na = Ja | Ka,
      Oa = La | Ma,
      Pa = Na | Oa,
      Qa = ["x", "y"],
      Ra = ["clientX", "clientY"];
  x.prototype = {
    handler: function handler() {},
    init: function init() {
      this.evEl && m(this.element, this.evEl, this.domHandler), this.evTarget && m(this.target, this.evTarget, this.domHandler), this.evWin && m(w(this.element), this.evWin, this.domHandler);
    },
    destroy: function destroy() {
      this.evEl && n(this.element, this.evEl, this.domHandler), this.evTarget && n(this.target, this.evTarget, this.domHandler), this.evWin && n(w(this.element), this.evWin, this.domHandler);
    }
  };
  var Sa = {
    mousedown: Ea,
    mousemove: Fa,
    mouseup: Ga
  },
      Ta = "mousedown",
      Ua = "mousemove mouseup";
  i(L, x, {
    handler: function handler(a) {
      var b = Sa[a.type];
      b & Ea && 0 === a.button && (this.pressed = !0), b & Fa && 1 !== a.which && (b = Ga), this.pressed && (b & Ga && (this.pressed = !1), this.callback(this.manager, b, {
        pointers: [a],
        changedPointers: [a],
        pointerType: Ba,
        srcEvent: a
      }));
    }
  });
  var Va = {
    pointerdown: Ea,
    pointermove: Fa,
    pointerup: Ga,
    pointercancel: Ha,
    pointerout: Ha
  },
      Wa = {
    2: za,
    3: Aa,
    4: Ba,
    5: Ca
  },
      Xa = "pointerdown",
      Ya = "pointermove pointerup pointercancel";
  a.MSPointerEvent && !a.PointerEvent && (Xa = "MSPointerDown", Ya = "MSPointerMove MSPointerUp MSPointerCancel"), i(M, x, {
    handler: function handler(a) {
      var b = this.store,
          c = !1,
          d = a.type.toLowerCase().replace("ms", ""),
          e = Va[d],
          f = Wa[a.pointerType] || a.pointerType,
          g = f == za,
          h = r(b, a.pointerId, "pointerId");
      e & Ea && (0 === a.button || g) ? 0 > h && (b.push(a), h = b.length - 1) : e & (Ga | Ha) && (c = !0), 0 > h || (b[h] = a, this.callback(this.manager, e, {
        pointers: b,
        changedPointers: [a],
        pointerType: f,
        srcEvent: a
      }), c && b.splice(h, 1));
    }
  });
  var Za = {
    touchstart: Ea,
    touchmove: Fa,
    touchend: Ga,
    touchcancel: Ha
  },
      $a = "touchstart",
      _a = "touchstart touchmove touchend touchcancel";
  i(N, x, {
    handler: function handler(a) {
      var b = Za[a.type];

      if (b === Ea && (this.started = !0), this.started) {
        var c = O.call(this, a, b);
        b & (Ga | Ha) && c[0].length - c[1].length === 0 && (this.started = !1), this.callback(this.manager, b, {
          pointers: c[0],
          changedPointers: c[1],
          pointerType: za,
          srcEvent: a
        });
      }
    }
  });
  var ab = {
    touchstart: Ea,
    touchmove: Fa,
    touchend: Ga,
    touchcancel: Ha
  },
      bb = "touchstart touchmove touchend touchcancel";
  i(P, x, {
    handler: function handler(a) {
      var b = ab[a.type],
          c = Q.call(this, a, b);
      c && this.callback(this.manager, b, {
        pointers: c[0],
        changedPointers: c[1],
        pointerType: za,
        srcEvent: a
      });
    }
  });
  var cb = 2500,
      db = 25;
  i(R, x, {
    handler: function handler(a, b, c) {
      var d = c.pointerType == za,
          e = c.pointerType == Ba;

      if (!(e && c.sourceCapabilities && c.sourceCapabilities.firesTouchEvents)) {
        if (d) S.call(this, b, c);else if (e && U.call(this, c)) return;
        this.callback(a, b, c);
      }
    },
    destroy: function destroy() {
      this.touch.destroy(), this.mouse.destroy();
    }
  });
  var eb = u(na.style, "touchAction"),
      fb = eb !== d,
      gb = "compute",
      hb = "auto",
      ib = "manipulation",
      jb = "none",
      kb = "pan-x",
      lb = "pan-y",
      mb = X();
  V.prototype = {
    set: function set(a) {
      a == gb && (a = this.compute()), fb && this.manager.element.style && mb[a] && (this.manager.element.style[eb] = a), this.actions = a.toLowerCase().trim();
    },
    update: function update() {
      this.set(this.manager.options.touchAction);
    },
    compute: function compute() {
      var a = [];
      return g(this.manager.recognizers, function (b) {
        k(b.options.enable, [b]) && (a = a.concat(b.getTouchAction()));
      }), W(a.join(" "));
    },
    preventDefaults: function preventDefaults(a) {
      var b = a.srcEvent,
          c = a.offsetDirection;
      if (this.manager.session.prevented) return void b.preventDefault();
      var d = this.actions,
          e = p(d, jb) && !mb[jb],
          f = p(d, lb) && !mb[lb],
          g = p(d, kb) && !mb[kb];

      if (e) {
        var h = 1 === a.pointers.length,
            i = a.distance < 2,
            j = a.deltaTime < 250;
        if (h && i && j) return;
      }

      return g && f ? void 0 : e || f && c & Na || g && c & Oa ? this.preventSrc(b) : void 0;
    },
    preventSrc: function preventSrc(a) {
      this.manager.session.prevented = !0, a.preventDefault();
    }
  };
  var nb = 1,
      ob = 2,
      pb = 4,
      qb = 8,
      rb = qb,
      sb = 16,
      tb = 32;
  Y.prototype = {
    defaults: {},
    set: function set(a) {
      return la(this.options, a), this.manager && this.manager.touchAction.update(), this;
    },
    recognizeWith: function recognizeWith(a) {
      if (f(a, "recognizeWith", this)) return this;
      var b = this.simultaneous;
      return a = _(a, this), b[a.id] || (b[a.id] = a, a.recognizeWith(this)), this;
    },
    dropRecognizeWith: function dropRecognizeWith(a) {
      return f(a, "dropRecognizeWith", this) ? this : (a = _(a, this), delete this.simultaneous[a.id], this);
    },
    requireFailure: function requireFailure(a) {
      if (f(a, "requireFailure", this)) return this;
      var b = this.requireFail;
      return a = _(a, this), -1 === r(b, a) && (b.push(a), a.requireFailure(this)), this;
    },
    dropRequireFailure: function dropRequireFailure(a) {
      if (f(a, "dropRequireFailure", this)) return this;
      a = _(a, this);
      var b = r(this.requireFail, a);
      return b > -1 && this.requireFail.splice(b, 1), this;
    },
    hasRequireFailures: function hasRequireFailures() {
      return this.requireFail.length > 0;
    },
    canRecognizeWith: function canRecognizeWith(a) {
      return !!this.simultaneous[a.id];
    },
    emit: function emit(a) {
      function b(b) {
        c.manager.emit(b, a);
      }

      var c = this,
          d = this.state;
      qb > d && b(c.options.event + Z(d)), b(c.options.event), a.additionalEvent && b(a.additionalEvent), d >= qb && b(c.options.event + Z(d));
    },
    tryEmit: function tryEmit(a) {
      return this.canEmit() ? this.emit(a) : void (this.state = tb);
    },
    canEmit: function canEmit() {
      for (var a = 0; a < this.requireFail.length;) {
        if (!(this.requireFail[a].state & (tb | nb))) return !1;
        a++;
      }

      return !0;
    },
    recognize: function recognize(a) {
      var b = la({}, a);
      return k(this.options.enable, [this, b]) ? (this.state & (rb | sb | tb) && (this.state = nb), this.state = this.process(b), void (this.state & (ob | pb | qb | sb) && this.tryEmit(b))) : (this.reset(), void (this.state = tb));
    },
    process: function process(a) {},
    getTouchAction: function getTouchAction() {},
    reset: function reset() {}
  }, i(aa, Y, {
    defaults: {
      pointers: 1
    },
    attrTest: function attrTest(a) {
      var b = this.options.pointers;
      return 0 === b || a.pointers.length === b;
    },
    process: function process(a) {
      var b = this.state,
          c = a.eventType,
          d = b & (ob | pb),
          e = this.attrTest(a);
      return d && (c & Ha || !e) ? b | sb : d || e ? c & Ga ? b | qb : b & ob ? b | pb : ob : tb;
    }
  }), i(ba, aa, {
    defaults: {
      event: "pan",
      threshold: 10,
      pointers: 1,
      direction: Pa
    },
    getTouchAction: function getTouchAction() {
      var a = this.options.direction,
          b = [];
      return a & Na && b.push(lb), a & Oa && b.push(kb), b;
    },
    directionTest: function directionTest(a) {
      var b = this.options,
          c = !0,
          d = a.distance,
          e = a.direction,
          f = a.deltaX,
          g = a.deltaY;
      return e & b.direction || (b.direction & Na ? (e = 0 === f ? Ia : 0 > f ? Ja : Ka, c = f != this.pX, d = Math.abs(a.deltaX)) : (e = 0 === g ? Ia : 0 > g ? La : Ma, c = g != this.pY, d = Math.abs(a.deltaY))), a.direction = e, c && d > b.threshold && e & b.direction;
    },
    attrTest: function attrTest(a) {
      return aa.prototype.attrTest.call(this, a) && (this.state & ob || !(this.state & ob) && this.directionTest(a));
    },
    emit: function emit(a) {
      this.pX = a.deltaX, this.pY = a.deltaY;
      var b = $(a.direction);
      b && (a.additionalEvent = this.options.event + b), this._super.emit.call(this, a);
    }
  }), i(ca, aa, {
    defaults: {
      event: "pinch",
      threshold: 0,
      pointers: 2
    },
    getTouchAction: function getTouchAction() {
      return [jb];
    },
    attrTest: function attrTest(a) {
      return this._super.attrTest.call(this, a) && (Math.abs(a.scale - 1) > this.options.threshold || this.state & ob);
    },
    emit: function emit(a) {
      if (1 !== a.scale) {
        var b = a.scale < 1 ? "in" : "out";
        a.additionalEvent = this.options.event + b;
      }

      this._super.emit.call(this, a);
    }
  }), i(da, Y, {
    defaults: {
      event: "press",
      pointers: 1,
      time: 251,
      threshold: 9
    },
    getTouchAction: function getTouchAction() {
      return [hb];
    },
    process: function process(a) {
      var b = this.options,
          c = a.pointers.length === b.pointers,
          d = a.distance < b.threshold,
          f = a.deltaTime > b.time;
      if (this._input = a, !d || !c || a.eventType & (Ga | Ha) && !f) this.reset();else if (a.eventType & Ea) this.reset(), this._timer = e(function () {
        this.state = rb, this.tryEmit();
      }, b.time, this);else if (a.eventType & Ga) return rb;
      return tb;
    },
    reset: function reset() {
      clearTimeout(this._timer);
    },
    emit: function emit(a) {
      this.state === rb && (a && a.eventType & Ga ? this.manager.emit(this.options.event + "up", a) : (this._input.timeStamp = ra(), this.manager.emit(this.options.event, this._input)));
    }
  }), i(ea, aa, {
    defaults: {
      event: "rotate",
      threshold: 0,
      pointers: 2
    },
    getTouchAction: function getTouchAction() {
      return [jb];
    },
    attrTest: function attrTest(a) {
      return this._super.attrTest.call(this, a) && (Math.abs(a.rotation) > this.options.threshold || this.state & ob);
    }
  }), i(fa, aa, {
    defaults: {
      event: "swipe",
      threshold: 10,
      velocity: .3,
      direction: Na | Oa,
      pointers: 1
    },
    getTouchAction: function getTouchAction() {
      return ba.prototype.getTouchAction.call(this);
    },
    attrTest: function attrTest(a) {
      var b,
          c = this.options.direction;
      return c & (Na | Oa) ? b = a.overallVelocity : c & Na ? b = a.overallVelocityX : c & Oa && (b = a.overallVelocityY), this._super.attrTest.call(this, a) && c & a.offsetDirection && a.distance > this.options.threshold && a.maxPointers == this.options.pointers && qa(b) > this.options.velocity && a.eventType & Ga;
    },
    emit: function emit(a) {
      var b = $(a.offsetDirection);
      b && this.manager.emit(this.options.event + b, a), this.manager.emit(this.options.event, a);
    }
  }), i(ga, Y, {
    defaults: {
      event: "tap",
      pointers: 1,
      taps: 1,
      interval: 300,
      time: 250,
      threshold: 9,
      posThreshold: 10
    },
    getTouchAction: function getTouchAction() {
      return [ib];
    },
    process: function process(a) {
      var b = this.options,
          c = a.pointers.length === b.pointers,
          d = a.distance < b.threshold,
          f = a.deltaTime < b.time;
      if (this.reset(), a.eventType & Ea && 0 === this.count) return this.failTimeout();

      if (d && f && c) {
        if (a.eventType != Ga) return this.failTimeout();
        var g = this.pTime ? a.timeStamp - this.pTime < b.interval : !0,
            h = !this.pCenter || H(this.pCenter, a.center) < b.posThreshold;
        this.pTime = a.timeStamp, this.pCenter = a.center, h && g ? this.count += 1 : this.count = 1, this._input = a;
        var i = this.count % b.taps;
        if (0 === i) return this.hasRequireFailures() ? (this._timer = e(function () {
          this.state = rb, this.tryEmit();
        }, b.interval, this), ob) : rb;
      }

      return tb;
    },
    failTimeout: function failTimeout() {
      return this._timer = e(function () {
        this.state = tb;
      }, this.options.interval, this), tb;
    },
    reset: function reset() {
      clearTimeout(this._timer);
    },
    emit: function emit() {
      this.state == rb && (this._input.tapCount = this.count, this.manager.emit(this.options.event, this._input));
    }
  }), ha.VERSION = "2.0.8", ha.defaults = {
    domEvents: !1,
    touchAction: gb,
    enable: !0,
    inputTarget: null,
    inputClass: null,
    preset: [[ea, {
      enable: !1
    }], [ca, {
      enable: !1
    }, ["rotate"]], [fa, {
      direction: Na
    }], [ba, {
      direction: Na
    }, ["swipe"]], [ga], [ga, {
      event: "doubletap",
      taps: 2
    }, ["tap"]], [da]],
    cssProps: {
      userSelect: "none",
      touchSelect: "none",
      touchCallout: "none",
      contentZooming: "none",
      userDrag: "none",
      tapHighlightColor: "rgba(0,0,0,0)"
    }
  };
  var ub = 1,
      vb = 2;
  ia.prototype = {
    set: function set(a) {
      return la(this.options, a), a.touchAction && this.touchAction.update(), a.inputTarget && (this.input.destroy(), this.input.target = a.inputTarget, this.input.init()), this;
    },
    stop: function stop(a) {
      this.session.stopped = a ? vb : ub;
    },
    recognize: function recognize(a) {
      var b = this.session;

      if (!b.stopped) {
        this.touchAction.preventDefaults(a);
        var c,
            d = this.recognizers,
            e = b.curRecognizer;
        (!e || e && e.state & rb) && (e = b.curRecognizer = null);

        for (var f = 0; f < d.length;) {
          c = d[f], b.stopped === vb || e && c != e && !c.canRecognizeWith(e) ? c.reset() : c.recognize(a), !e && c.state & (ob | pb | qb) && (e = b.curRecognizer = c), f++;
        }
      }
    },
    get: function get(a) {
      if (a instanceof Y) return a;

      for (var b = this.recognizers, c = 0; c < b.length; c++) {
        if (b[c].options.event == a) return b[c];
      }

      return null;
    },
    add: function add(a) {
      if (f(a, "add", this)) return this;
      var b = this.get(a.options.event);
      return b && this.remove(b), this.recognizers.push(a), a.manager = this, this.touchAction.update(), a;
    },
    remove: function remove(a) {
      if (f(a, "remove", this)) return this;

      if (a = this.get(a)) {
        var b = this.recognizers,
            c = r(b, a);
        -1 !== c && (b.splice(c, 1), this.touchAction.update());
      }

      return this;
    },
    on: function on(a, b) {
      if (a !== d && b !== d) {
        var c = this.handlers;
        return g(q(a), function (a) {
          c[a] = c[a] || [], c[a].push(b);
        }), this;
      }
    },
    off: function off(a, b) {
      if (a !== d) {
        var c = this.handlers;
        return g(q(a), function (a) {
          b ? c[a] && c[a].splice(r(c[a], b), 1) : delete c[a];
        }), this;
      }
    },
    emit: function emit(a, b) {
      this.options.domEvents && ka(a, b);
      var c = this.handlers[a] && this.handlers[a].slice();

      if (c && c.length) {
        b.type = a, b.preventDefault = function () {
          b.srcEvent.preventDefault();
        };

        for (var d = 0; d < c.length;) {
          c[d](b), d++;
        }
      }
    },
    destroy: function destroy() {
      this.element && ja(this, !1), this.handlers = {}, this.session = {}, this.input.destroy(), this.element = null;
    }
  }, la(ha, {
    INPUT_START: Ea,
    INPUT_MOVE: Fa,
    INPUT_END: Ga,
    INPUT_CANCEL: Ha,
    STATE_POSSIBLE: nb,
    STATE_BEGAN: ob,
    STATE_CHANGED: pb,
    STATE_ENDED: qb,
    STATE_RECOGNIZED: rb,
    STATE_CANCELLED: sb,
    STATE_FAILED: tb,
    DIRECTION_NONE: Ia,
    DIRECTION_LEFT: Ja,
    DIRECTION_RIGHT: Ka,
    DIRECTION_UP: La,
    DIRECTION_DOWN: Ma,
    DIRECTION_HORIZONTAL: Na,
    DIRECTION_VERTICAL: Oa,
    DIRECTION_ALL: Pa,
    Manager: ia,
    Input: x,
    TouchAction: V,
    TouchInput: P,
    MouseInput: L,
    PointerEventInput: M,
    TouchMouseInput: R,
    SingleTouchInput: N,
    Recognizer: Y,
    AttrRecognizer: aa,
    Tap: ga,
    Pan: ba,
    Swipe: fa,
    Pinch: ca,
    Rotate: ea,
    Press: da,
    on: m,
    off: n,
    each: g,
    merge: ta,
    extend: sa,
    assign: la,
    inherit: i,
    bindFn: j,
    prefixed: u
  });
  var wb = "undefined" != typeof a ? a : "undefined" != typeof self ? self : {};
  wb.Hammer = ha, "function" == typeof define && define.amd ? define(function () {
    return ha;
  }) : "undefined" != typeof module && module.exports ? module.exports = ha : a[c] = ha;
}(window, document, "Hammer");

(function (f) {
  if ((typeof exports === "undefined" ? "undefined" : _typeof(exports)) === "object" && typeof module !== "undefined") {
    module.exports = f();
  } else if (typeof define === "function" && define.amd) {
    define([], f);
  } else {
    var g;

    if (typeof window !== "undefined") {
      g = window;
    } else if (typeof global !== "undefined") {
      g = global;
    } else if (typeof self !== "undefined") {
      g = self;
    } else {
      g = this;
    }

    g.Pjax = f();
  }
})(function () {
  var define, module, exports;
  return function () {
    function r(e, n, t) {
      function o(i, f) {
        if (!n[i]) {
          if (!e[i]) {
            var c = "function" == typeof require && require;
            if (!f && c) return c(i, !0);
            if (u) return u(i, !0);
            var a = new Error("Cannot find module '" + i + "'");
            throw a.code = "MODULE_NOT_FOUND", a;
          }

          var p = n[i] = {
            exports: {}
          };
          e[i][0].call(p.exports, function (r) {
            var n = e[i][1][r];
            return o(n || r);
          }, p, p.exports, r, e, n, t);
        }

        return n[i].exports;
      }

      for (var u = "function" == typeof require && require, i = 0; i < t.length; i++) {
        o(t[i]);
      }

      return o;
    }

    return r;
  }()({
    1: [function (require, module, exports) {
      var executeScripts = require("./lib/execute-scripts.js");

      var forEachEls = require("./lib/foreach-els.js");

      var parseOptions = require("./lib/parse-options.js");

      var switches = require("./lib/switches");

      var newUid = require("./lib/uniqueid.js");

      var on = require("./lib/events/on.js");

      var trigger = require("./lib/events/trigger.js");

      var clone = require("./lib/util/clone.js");

      var contains = require("./lib/util/contains.js");

      var extend = require("./lib/util/extend.js");

      var noop = require("./lib/util/noop");

      var Pjax = function Pjax(options) {
        this.state = {
          numPendingSwitches: 0,
          href: null,
          options: null
        };
        this.options = parseOptions(options);
        this.log("Pjax options", this.options);

        if (this.options.scrollRestoration && "scrollRestoration" in history) {
          history.scrollRestoration = "manual";
        }

        this.maxUid = this.lastUid = newUid();
        this.parseDOM(document);
        on(window, "popstate", function (st) {
          if (st.state) {
            var opt = clone(this.options);
            opt.url = st.state.url;
            opt.title = st.state.title;
            opt.history = false;
            opt.scrollPos = st.state.scrollPos;

            if (st.state.uid < this.lastUid) {
              opt.backward = true;
            } else {
              opt.forward = true;
            }

            this.lastUid = st.state.uid;
            this.loadUrl(st.state.url, opt);
          }
        }.bind(this));
      };

      Pjax.switches = switches;
      Pjax.prototype = {
        log: require("./lib/proto/log.js"),
        getElements: function getElements(el) {
          return el.querySelectorAll(this.options.elements);
        },
        parseDOM: function parseDOM(el) {
          var parseElement = require("./lib/proto/parse-element");

          forEachEls(this.getElements(el), parseElement, this);
        },
        refresh: function refresh(el) {
          this.parseDOM(el || document);
        },
        reload: function reload() {
          window.location.reload();
        },
        attachLink: require("./lib/proto/attach-link.js"),
        attachForm: require("./lib/proto/attach-form.js"),
        forEachSelectors: function forEachSelectors(cb, context, DOMcontext) {
          return require("./lib/foreach-selectors.js").bind(this)(this.options.selectors, cb, context, DOMcontext);
        },
        switchSelectors: function switchSelectors(selectors, fromEl, toEl, options) {
          return require("./lib/switches-selectors.js").bind(this)(this.options.switches, this.options.switchesOptions, selectors, fromEl, toEl, options);
        },
        latestChance: function latestChance(href) {
          window.location = href;
        },
        onSwitch: function onSwitch() {
          trigger(window, "resize scroll");
          this.state.numPendingSwitches--;

          if (this.state.numPendingSwitches === 0) {
            this.afterAllSwitches();
          }
        },
        loadContent: function loadContent(html, options) {
          var tmpEl = document.implementation.createHTMLDocument("pjax");
          var htmlRegex = /<html[^>]+>/gi;
          var htmlAttribsRegex = /\s?[a-z:]+(?:\=(?:\'|\")[^\'\">]+(?:\'|\"))*/gi;
          var matches = html.match(htmlRegex);

          if (matches && matches.length) {
            matches = matches[0].match(htmlAttribsRegex);

            if (matches.length) {
              matches.shift();
              matches.forEach(function (htmlAttrib) {
                var attr = htmlAttrib.trim().split("=");

                if (attr.length === 1) {
                  tmpEl.documentElement.setAttribute(attr[0], true);
                } else {
                  tmpEl.documentElement.setAttribute(attr[0], attr[1].slice(1, -1));
                }
              });
            }
          }

          tmpEl.documentElement.innerHTML = html;
          this.log("load content", tmpEl.documentElement.attributes, tmpEl.documentElement.innerHTML.length);

          if (document.activeElement && contains(document, this.options.selectors, document.activeElement)) {
            try {
              document.activeElement.blur();
            } catch (e) {}
          }

          this.switchSelectors(this.options.selectors, tmpEl, document, options);
        },
        abortRequest: require("./lib/abort-request.js"),
        doRequest: require("./lib/send-request.js"),
        handleResponse: require("./lib/proto/handle-response.js"),
        loadUrl: function loadUrl(href, options) {
          options = _typeof(options) === "object" ? extend({}, this.options, options) : clone(this.options);
          this.log("load href", href, options);
          this.abortRequest(this.request);
          trigger(document, "pjax:send", options);
          this.request = this.doRequest(href, options, this.handleResponse.bind(this));
        },
        afterAllSwitches: function afterAllSwitches() {
          var autofocusEl = Array.prototype.slice.call(document.querySelectorAll("[autofocus]")).pop();

          if (autofocusEl && document.activeElement !== autofocusEl) {
            autofocusEl.focus();
          }

          this.options.selectors.forEach(function (selector) {
            forEachEls(document.querySelectorAll(selector), function (el) {
              executeScripts(el);
            });
          });
          var state = this.state;

          if (state.options.history) {
            if (!window.history.state) {
              this.lastUid = this.maxUid = newUid();
              window.history.replaceState({
                url: window.location.href,
                title: document.title,
                uid: this.maxUid,
                scrollPos: [0, 0]
              }, document.title);
            }

            this.lastUid = this.maxUid = newUid();
            window.history.pushState({
              url: state.href,
              title: state.options.title,
              uid: this.maxUid,
              scrollPos: [0, 0]
            }, state.options.title, state.href);
          }

          this.forEachSelectors(function (el) {
            this.parseDOM(el);
          }, this);
          trigger(document, "pjax:complete pjax:success", state.options);

          if (typeof state.options.analytics === "function") {
            state.options.analytics();
          }

          if (state.options.history) {
            var a = document.createElement("a");
            a.href = this.state.href;

            if (a.hash) {
              var name = a.hash.slice(1);
              name = decodeURIComponent(name);
              var curtop = 0;
              var target = document.getElementById(name) || document.getElementsByName(name)[0];

              if (target) {
                if (target.offsetParent) {
                  do {
                    curtop += target.offsetTop;
                    target = target.offsetParent;
                  } while (target);
                }
              }

              window.scrollTo(0, curtop);
            } else if (state.options.scrollTo !== false) {
              if (state.options.scrollTo.length > 1) {
                window.scrollTo(state.options.scrollTo[0], state.options.scrollTo[1]);
              } else {
                window.scrollTo(0, state.options.scrollTo);
              }
            }
          } else if (state.options.scrollRestoration && state.options.scrollPos) {
            window.scrollTo(state.options.scrollPos[0], state.options.scrollPos[1]);
          }

          this.state = {
            numPendingSwitches: 0,
            href: null,
            options: null
          };
        }
      };
      Pjax.isSupported = require("./lib/is-supported.js");

      if (Pjax.isSupported()) {
        module.exports = Pjax;
      } else {
        var stupidPjax = noop;

        for (var key in Pjax.prototype) {
          if (Pjax.prototype.hasOwnProperty(key) && typeof Pjax.prototype[key] === "function") {
            stupidPjax[key] = noop;
          }
        }

        module.exports = stupidPjax;
      }
    }, {
      "./lib/abort-request.js": 2,
      "./lib/events/on.js": 4,
      "./lib/events/trigger.js": 5,
      "./lib/execute-scripts.js": 6,
      "./lib/foreach-els.js": 7,
      "./lib/foreach-selectors.js": 8,
      "./lib/is-supported.js": 9,
      "./lib/parse-options.js": 10,
      "./lib/proto/attach-form.js": 11,
      "./lib/proto/attach-link.js": 12,
      "./lib/proto/handle-response.js": 13,
      "./lib/proto/log.js": 14,
      "./lib/proto/parse-element": 15,
      "./lib/send-request.js": 16,
      "./lib/switches": 18,
      "./lib/switches-selectors.js": 17,
      "./lib/uniqueid.js": 19,
      "./lib/util/clone.js": 20,
      "./lib/util/contains.js": 21,
      "./lib/util/extend.js": 22,
      "./lib/util/noop": 23
    }],
    2: [function (require, module, exports) {
      var noop = require("./util/noop");

      module.exports = function (request) {
        if (request && request.readyState < 4) {
          request.onreadystatechange = noop;
          request.abort();
        }
      };
    }, {
      "./util/noop": 23
    }],
    3: [function (require, module, exports) {
      module.exports = function (el) {
        var code = el.text || el.textContent || el.innerHTML || "";
        var src = el.src || "";
        var parent = el.parentNode || document.querySelector("head") || document.documentElement;
        var script = document.createElement("script");

        if (code.match("document.write")) {
          if (console && console.log) {
            console.log("Script contains document.write. Can’t be executed correctly. Code skipped ", el);
          }

          return false;
        }

        script.type = "text/javascript";

        if (src !== "") {
          script.src = src;
          script.async = false;
        }

        if (code !== "") {
          try {
            script.appendChild(document.createTextNode(code));
          } catch (e) {
            script.text = code;
          }
        }

        parent.appendChild(script);

        if (parent instanceof HTMLHeadElement || parent instanceof HTMLBodyElement) {
          parent.removeChild(script);
        }

        return true;
      };
    }, {}],
    4: [function (require, module, exports) {
      var forEachEls = require("../foreach-els");

      module.exports = function (els, events, listener, useCapture) {
        events = typeof events === "string" ? events.split(" ") : events;
        events.forEach(function (e) {
          forEachEls(els, function (el) {
            el.addEventListener(e, listener, useCapture);
          });
        });
      };
    }, {
      "../foreach-els": 7
    }],
    5: [function (require, module, exports) {
      var forEachEls = require("../foreach-els");

      module.exports = function (els, events, opts) {
        events = typeof events === "string" ? events.split(" ") : events;
        events.forEach(function (e) {
          var event;
          event = document.createEvent("HTMLEvents");
          event.initEvent(e, true, true);
          event.eventName = e;

          if (opts) {
            Object.keys(opts).forEach(function (key) {
              event[key] = opts[key];
            });
          }

          forEachEls(els, function (el) {
            var domFix = false;

            if (!el.parentNode && el !== document && el !== window) {
              domFix = true;
              document.body.appendChild(el);
            }

            el.dispatchEvent(event);

            if (domFix) {
              el.parentNode.removeChild(el);
            }
          });
        });
      };
    }, {
      "../foreach-els": 7
    }],
    6: [function (require, module, exports) {
      var forEachEls = require("./foreach-els");

      var evalScript = require("./eval-script");

      module.exports = function (el) {
        if (el.tagName.toLowerCase() === "script") {
          evalScript(el);
        }

        forEachEls(el.querySelectorAll("script"), function (script) {
          if (!script.type || script.type.toLowerCase() === "text/javascript") {
            if (script.parentNode) {
              script.parentNode.removeChild(script);
            }

            evalScript(script);
          }
        });
      };
    }, {
      "./eval-script": 3,
      "./foreach-els": 7
    }],
    7: [function (require, module, exports) {
      module.exports = function (els, fn, context) {
        if (els instanceof HTMLCollection || els instanceof NodeList || els instanceof Array) {
          return Array.prototype.forEach.call(els, fn, context);
        }

        return fn.call(context, els);
      };
    }, {}],
    8: [function (require, module, exports) {
      var forEachEls = require("./foreach-els");

      module.exports = function (selectors, cb, context, DOMcontext) {
        DOMcontext = DOMcontext || document;
        selectors.forEach(function (selector) {
          forEachEls(DOMcontext.querySelectorAll(selector), cb, context);
        });
      };
    }, {
      "./foreach-els": 7
    }],
    9: [function (require, module, exports) {
      module.exports = function () {
        return window.history && window.history.pushState && window.history.replaceState && !navigator.userAgent.match(/((iPod|iPhone|iPad).+\bOS\s+[1-4]\D|WebApps\/.+CFNetwork)/);
      };
    }, {}],
    10: [function (require, module, exports) {
      var defaultSwitches = require("./switches");

      module.exports = function (options) {
        options = options || {};
        options.elements = options.elements || "a[href], form[action]";
        options.selectors = options.selectors || ["title", ".js-Pjax"];
        options.switches = options.switches || {};
        options.switchesOptions = options.switchesOptions || {};
        options.history = typeof options.history === "undefined" ? true : options.history;
        options.analytics = typeof options.analytics === "function" || options.analytics === false ? options.analytics : defaultAnalytics;
        options.scrollTo = typeof options.scrollTo === "undefined" ? 0 : options.scrollTo;
        options.scrollRestoration = typeof options.scrollRestoration !== "undefined" ? options.scrollRestoration : true;
        options.cacheBust = typeof options.cacheBust === "undefined" ? true : options.cacheBust;
        options.debug = options.debug || false;
        options.timeout = options.timeout || 0;
        options.currentUrlFullReload = typeof options.currentUrlFullReload === "undefined" ? false : options.currentUrlFullReload;

        if (!options.switches.head) {
          options.switches.head = defaultSwitches.switchElementsAlt;
        }

        if (!options.switches.body) {
          options.switches.body = defaultSwitches.switchElementsAlt;
        }

        return options;
      };

      function defaultAnalytics() {
        if (window._gaq) {
          _gaq.push(["_trackPageview"]);
        }

        if (window.ga) {
          ga("send", "pageview", {
            page: location.pathname,
            title: document.title
          });
        }
      }
    }, {
      "./switches": 18
    }],
    11: [function (require, module, exports) {
      var on = require("../events/on");

      var clone = require("../util/clone");

      var attrState = "data-pjax-state";

      var formAction = function formAction(el, event) {
        if (isDefaultPrevented(event)) {
          return;
        }

        var options = clone(this.options);
        options.requestOptions = {
          requestUrl: el.getAttribute("action") || window.location.href,
          requestMethod: el.getAttribute("method") || "GET"
        };
        var virtLinkElement = document.createElement("a");
        virtLinkElement.setAttribute("href", options.requestOptions.requestUrl);
        var attrValue = checkIfShouldAbort(virtLinkElement, options);

        if (attrValue) {
          el.setAttribute(attrState, attrValue);
          return;
        }

        event.preventDefault();

        if (el.enctype === "multipart/form-data") {
          options.requestOptions.formData = new FormData(el);
        } else {
          options.requestOptions.requestParams = parseFormElements(el);
        }

        el.setAttribute(attrState, "submit");
        options.triggerElement = el;
        this.loadUrl(virtLinkElement.href, options);
      };

      function parseFormElements(el) {
        var requestParams = [];

        for (var elementKey in el.elements) {
          if (Number.isNaN(Number(elementKey))) {
            continue;
          }

          var element = el.elements[elementKey];
          var tagName = element.tagName.toLowerCase();

          if (!!element.name && element.attributes !== undefined && tagName !== "button") {
            var type = element.attributes.type;

            if (!type || type.value !== "checkbox" && type.value !== "radio" || element.checked) {
              var values = [];

              if (tagName === "select") {
                var opt;

                for (var i = 0; i < element.options.length; i++) {
                  opt = element.options[i];

                  if (opt.selected && !opt.disabled) {
                    values.push(opt.hasAttribute("value") ? opt.value : opt.text);
                  }
                }
              } else {
                values.push(element.value);
              }

              for (var j = 0; j < values.length; j++) {
                requestParams.push({
                  name: encodeURIComponent(element.name),
                  value: encodeURIComponent(values[j])
                });
              }
            }
          }
        }

        return requestParams;
      }

      function checkIfShouldAbort(virtLinkElement, options) {
        if (virtLinkElement.protocol !== window.location.protocol || virtLinkElement.host !== window.location.host) {
          return "external";
        }

        if (virtLinkElement.hash && virtLinkElement.href.replace(virtLinkElement.hash, "") === window.location.href.replace(location.hash, "")) {
          return "anchor";
        }

        if (virtLinkElement.href === window.location.href.split("#")[0] + "#") {
          return "anchor-empty";
        }

        if (options.currentUrlFullReload && virtLinkElement.href === window.location.href.split("#")[0]) {
          return "reload";
        }
      }

      var isDefaultPrevented = function isDefaultPrevented(event) {
        return event.defaultPrevented || event.returnValue === false;
      };

      module.exports = function (el) {
        var that = this;
        el.setAttribute(attrState, "");
        on(el, "submit", function (event) {
          formAction.call(that, el, event);
        });
        on(el, "keyup", function (event) {
          if (event.keyCode === 13) {
            formAction.call(that, el, event);
          }
        }.bind(this));
      };
    }, {
      "../events/on": 4,
      "../util/clone": 20
    }],
    12: [function (require, module, exports) {
      var on = require("../events/on");

      var clone = require("../util/clone");

      var attrState = "data-pjax-state";

      var linkAction = function linkAction(el, event) {
        if (isDefaultPrevented(event)) {
          return;
        }

        var options = clone(this.options);
        var attrValue = checkIfShouldAbort(el, event);

        if (attrValue) {
          el.setAttribute(attrState, attrValue);
          return;
        }

        event.preventDefault();

        if (this.options.currentUrlFullReload && el.href === window.location.href.split("#")[0]) {
          el.setAttribute(attrState, "reload");
          this.reload();
          return;
        }

        el.setAttribute(attrState, "load");
        options.triggerElement = el;
        this.loadUrl(el.href, options);
      };

      function checkIfShouldAbort(el, event) {
        if (event.which > 1 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) {
          return "modifier";
        }

        if (el.protocol !== window.location.protocol || el.host !== window.location.host) {
          return "external";
        }

        if (el.hash && el.href.replace(el.hash, "") === window.location.href.replace(location.hash, "")) {
          return "anchor";
        }

        if (el.href === window.location.href.split("#")[0] + "#") {
          return "anchor-empty";
        }
      }

      var isDefaultPrevented = function isDefaultPrevented(event) {
        return event.defaultPrevented || event.returnValue === false;
      };

      module.exports = function (el) {
        var that = this;
        el.setAttribute(attrState, "");
        on(el, "click", function (event) {
          linkAction.call(that, el, event);
        });
        on(el, "keyup", function (event) {
          if (event.keyCode === 13) {
            linkAction.call(that, el, event);
          }
        }.bind(this));
      };
    }, {
      "../events/on": 4,
      "../util/clone": 20
    }],
    13: [function (require, module, exports) {
      var clone = require("../util/clone.js");

      var newUid = require("../uniqueid.js");

      var trigger = require("../events/trigger.js");

      module.exports = function (responseText, request, href, options) {
        options = clone(options || this.options);
        options.request = request;

        if (responseText === false) {
          trigger(document, "pjax:complete pjax:error", options);
          return;
        }

        var currentState = window.history.state || {};
        window.history.replaceState({
          url: currentState.url || window.location.href,
          title: currentState.title || document.title,
          uid: currentState.uid || newUid(),
          scrollPos: [document.documentElement.scrollLeft || document.body.scrollLeft, document.documentElement.scrollTop || document.body.scrollTop]
        }, document.title, window.location);
        var oldHref = href;

        if (request.responseURL) {
          if (href !== request.responseURL) {
            href = request.responseURL;
          }
        } else if (request.getResponseHeader("X-PJAX-URL")) {
          href = request.getResponseHeader("X-PJAX-URL");
        } else if (request.getResponseHeader("X-XHR-Redirected-To")) {
          href = request.getResponseHeader("X-XHR-Redirected-To");
        }

        var a = document.createElement("a");
        a.href = oldHref;
        var oldHash = a.hash;
        a.href = href;

        if (oldHash && !a.hash) {
          a.hash = oldHash;
          href = a.href;
        }

        this.state.href = href;
        this.state.options = options;

        try {
          this.loadContent(responseText, options);
        } catch (e) {
          trigger(document, "pjax:error", options);

          if (!this.options.debug) {
            if (console && console.error) {
              console.error("Pjax switch fail: ", e);
            }

            return this.latestChance(href);
          } else {
            throw e;
          }
        }
      };
    }, {
      "../events/trigger.js": 5,
      "../uniqueid.js": 19,
      "../util/clone.js": 20
    }],
    14: [function (require, module, exports) {
      module.exports = function () {
        if (this.options.debug && console) {
          if (typeof console.log === "function") {
            console.log.apply(console, arguments);
          } else if (console.log) {
            console.log(arguments);
          }
        }
      };
    }, {}],
    15: [function (require, module, exports) {
      var attrState = "data-pjax-state";

      module.exports = function (el) {
        switch (el.tagName.toLowerCase()) {
          case "a":
            if (!el.hasAttribute(attrState)) {
              this.attachLink(el);
            }

            break;

          case "form":
            if (!el.hasAttribute(attrState)) {
              this.attachForm(el);
            }

            break;

          default:
            throw "Pjax can only be applied on <a> or <form> submit";
        }
      };
    }, {}],
    16: [function (require, module, exports) {
      var updateQueryString = require("./util/update-query-string");

      module.exports = function (location, options, callback) {
        options = options || {};
        var queryString;
        var requestOptions = options.requestOptions || {};
        var requestMethod = (requestOptions.requestMethod || "GET").toUpperCase();
        var requestParams = requestOptions.requestParams || null;
        var formData = requestOptions.formData || null;
        var requestPayload = null;
        var request = new XMLHttpRequest();
        var timeout = options.timeout || 0;

        request.onreadystatechange = function () {
          if (request.readyState === 4) {
            if (request.status === 200) {
              callback(request.responseText, request, location, options);
            } else if (request.status !== 0) {
              callback(null, request, location, options);
            }
          }
        };

        request.onerror = function (e) {
          console.log(e);
          callback(null, request, location, options);
        };

        request.ontimeout = function () {
          callback(null, request, location, options);
        };

        if (requestParams && requestParams.length) {
          queryString = requestParams.map(function (param) {
            return param.name + "=" + param.value;
          }).join("&");

          switch (requestMethod) {
            case "GET":
              location = location.split("?")[0];
              location += "?" + queryString;
              break;

            case "POST":
              requestPayload = queryString;
              break;
          }
        } else if (formData) {
          requestPayload = formData;
        }

        if (options.cacheBust) {
          location = updateQueryString(location, "t", Date.now());
        }

        request.open(requestMethod, location, true);
        request.timeout = timeout;
        request.setRequestHeader("X-Requested-With", "XMLHttpRequest");
        request.setRequestHeader("X-PJAX", "true");
        request.setRequestHeader("X-PJAX-Selectors", JSON.stringify(options.selectors));

        if (requestPayload && requestMethod === "POST" && !formData) {
          request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        }

        request.send(requestPayload);
        return request;
      };
    }, {
      "./util/update-query-string": 24
    }],
    17: [function (require, module, exports) {
      var forEachEls = require("./foreach-els");

      var defaultSwitches = require("./switches");

      module.exports = function (switches, switchesOptions, selectors, fromEl, toEl, options) {
        var switchesQueue = [];
        selectors.forEach(function (selector) {
          var newEls = fromEl.querySelectorAll(selector);
          var oldEls = toEl.querySelectorAll(selector);

          if (this.log) {
            this.log("Pjax switch", selector, newEls, oldEls);
          }

          if (newEls.length !== oldEls.length) {
            throw "DOM doesn’t look the same on new loaded page: ’" + selector + "’ - new " + newEls.length + ", old " + oldEls.length;
          }

          forEachEls(newEls, function (newEl, i) {
            var oldEl = oldEls[i];

            if (this.log) {
              this.log("newEl", newEl, "oldEl", oldEl);
            }

            var callback = switches[selector] ? switches[selector].bind(this, oldEl, newEl, options, switchesOptions[selector]) : defaultSwitches.outerHTML.bind(this, oldEl, newEl, options);
            switchesQueue.push(callback);
          }, this);
        }, this);
        this.state.numPendingSwitches = switchesQueue.length;
        switchesQueue.forEach(function (queuedSwitch) {
          queuedSwitch();
        });
      };
    }, {
      "./foreach-els": 7,
      "./switches": 18
    }],
    18: [function (require, module, exports) {
      var on = require("./events/on.js");

      module.exports = {
        outerHTML: function outerHTML(oldEl, newEl) {
          oldEl.outerHTML = newEl.outerHTML;
          this.onSwitch();
        },
        innerHTML: function innerHTML(oldEl, newEl) {
          oldEl.innerHTML = newEl.innerHTML;

          if (newEl.className === "") {
            oldEl.removeAttribute("class");
          } else {
            oldEl.className = newEl.className;
          }

          this.onSwitch();
        },
        switchElementsAlt: function switchElementsAlt(oldEl, newEl) {
          oldEl.innerHTML = newEl.innerHTML;

          if (newEl.hasAttributes()) {
            var attrs = newEl.attributes;

            for (var i = 0; i < attrs.length; i++) {
              oldEl.attributes.setNamedItem(attrs[i].cloneNode());
            }
          }

          this.onSwitch();
        },
        replaceNode: function replaceNode(oldEl, newEl) {
          oldEl.parentNode.replaceChild(newEl, oldEl);
          this.onSwitch();
        },
        sideBySide: function sideBySide(oldEl, newEl, options, switchOptions) {
          var forEach = Array.prototype.forEach;
          var elsToRemove = [];
          var elsToAdd = [];
          var fragToAppend = document.createDocumentFragment();
          var animationEventNames = "animationend webkitAnimationEnd MSAnimationEnd oanimationend";
          var animatedElsNumber = 0;

          var sexyAnimationEnd = function (e) {
            if (e.target !== e.currentTarget) {
              return;
            }

            animatedElsNumber--;

            if (animatedElsNumber <= 0 && elsToRemove) {
              elsToRemove.forEach(function (el) {
                if (el.parentNode) {
                  el.parentNode.removeChild(el);
                }
              });
              elsToAdd.forEach(function (el) {
                el.className = el.className.replace(el.getAttribute("data-pjax-classes"), "");
                el.removeAttribute("data-pjax-classes");
              });
              elsToAdd = null;
              elsToRemove = null;
              this.onSwitch();
            }
          }.bind(this);

          switchOptions = switchOptions || {};
          forEach.call(oldEl.childNodes, function (el) {
            elsToRemove.push(el);

            if (el.classList && !el.classList.contains("js-Pjax-remove")) {
              if (el.hasAttribute("data-pjax-classes")) {
                el.className = el.className.replace(el.getAttribute("data-pjax-classes"), "");
                el.removeAttribute("data-pjax-classes");
              }

              el.classList.add("js-Pjax-remove");

              if (switchOptions.callbacks && switchOptions.callbacks.removeElement) {
                switchOptions.callbacks.removeElement(el);
              }

              if (switchOptions.classNames) {
                el.className += " " + switchOptions.classNames.remove + " " + (options.backward ? switchOptions.classNames.backward : switchOptions.classNames.forward);
              }

              animatedElsNumber++;
              on(el, animationEventNames, sexyAnimationEnd, true);
            }
          });
          forEach.call(newEl.childNodes, function (el) {
            if (el.classList) {
              var addClasses = "";

              if (switchOptions.classNames) {
                addClasses = " js-Pjax-add " + switchOptions.classNames.add + " " + (options.backward ? switchOptions.classNames.forward : switchOptions.classNames.backward);
              }

              if (switchOptions.callbacks && switchOptions.callbacks.addElement) {
                switchOptions.callbacks.addElement(el);
              }

              el.className += addClasses;
              el.setAttribute("data-pjax-classes", addClasses);
              elsToAdd.push(el);
              fragToAppend.appendChild(el);
              animatedElsNumber++;
              on(el, animationEventNames, sexyAnimationEnd, true);
            }
          });
          oldEl.className = newEl.className;
          oldEl.appendChild(fragToAppend);
        }
      };
    }, {
      "./events/on.js": 4
    }],
    19: [function (require, module, exports) {
      module.exports = function () {
        var counter = 0;
        return function () {
          var id = "pjax" + new Date().getTime() + "_" + counter;
          counter++;
          return id;
        };
      }();
    }, {}],
    20: [function (require, module, exports) {
      module.exports = function (obj) {
        if (null === obj || "object" !== _typeof(obj)) {
          return obj;
        }

        var copy = obj.constructor();

        for (var attr in obj) {
          if (obj.hasOwnProperty(attr)) {
            copy[attr] = obj[attr];
          }
        }

        return copy;
      };
    }, {}],
    21: [function (require, module, exports) {
      module.exports = function contains(doc, selectors, el) {
        for (var i = 0; i < selectors.length; i++) {
          var selectedEls = doc.querySelectorAll(selectors[i]);

          for (var j = 0; j < selectedEls.length; j++) {
            if (selectedEls[j].contains(el)) {
              return true;
            }
          }
        }

        return false;
      };
    }, {}],
    22: [function (require, module, exports) {
      module.exports = function (target) {
        if (target == null) {
          return null;
        }

        var to = Object(target);

        for (var i = 1; i < arguments.length; i++) {
          var source = arguments[i];

          if (source != null) {
            for (var key in source) {
              if (Object.prototype.hasOwnProperty.call(source, key)) {
                to[key] = source[key];
              }
            }
          }
        }

        return to;
      };
    }, {}],
    23: [function (require, module, exports) {
      module.exports = function () {};
    }, {}],
    24: [function (require, module, exports) {
      module.exports = function (uri, key, value) {
        var re = new RegExp("([?&])" + key + "=.*?(&|$)", "i");
        var separator = uri.indexOf("?") !== -1 ? "&" : "?";

        if (uri.match(re)) {
          return uri.replace(re, "$1" + key + "=" + value + "$2");
        } else {
          return uri + separator + key + "=" + value;
        }
      };
    }, {}]
  }, {}, [1])(1);
});
/**
 * Event semi polyfill. IE does not support new event. But does support document.createEvent.
 * Same thing for dispatching events. But then with createEvent and fireEvent.
 */


function createNewEvent(eventName) {
  var event;

  if (typeof Event === 'function') {
    //On ie it is typeOf object.
    event = new Event(eventName); //Non-ie
  } else {
    event = document.createEvent('Event'); //ie

    event.initEvent(eventName, true, true);
  }

  return event;
}

function dispatchEventForElement(element, event) {
  if (document.createEvent) {
    element.dispatchEvent(event);
  } else {
    element.fireEvent("on" + event.eventType, event);
  }
}

Number.isInteger = Number.isInteger || function (value) {
  return typeof value === "number" && isFinite(value) && Math.floor(value) === value;
};

!function () {
  "use strict";

  if ("undefined" != typeof window) {
    var t = window.navigator.userAgent.match(/Edge\/(\d{2})\./),
        n = !!t && 16 <= parseInt(t[1], 10);

    if (!("objectFit" in document.documentElement.style != !1) || n) {
      var o = function o(t, e, i) {
        var n, o, l, a, d;
        if ((i = i.split(" ")).length < 2 && (i[1] = i[0]), "x" === t) n = i[0], o = i[1], l = "left", a = "right", d = e.clientWidth;else {
          if ("y" !== t) return;
          n = i[1], o = i[0], l = "top", a = "bottom", d = e.clientHeight;
        }

        if (n !== l && o !== l) {
          if (n !== a && o !== a) return "center" === n || "50%" === n ? (e.style[l] = "50%", void (e.style["margin-" + l] = d / -2 + "px")) : void (0 <= n.indexOf("%") ? (n = parseInt(n)) < 50 ? (e.style[l] = n + "%", e.style["margin-" + l] = d * (n / -100) + "px") : (n = 100 - n, e.style[a] = n + "%", e.style["margin-" + a] = d * (n / -100) + "px") : e.style[l] = n);
          e.style[a] = "0";
        } else e.style[l] = "0";
      },
          l = function l(t) {
        var e = t.dataset ? t.dataset.objectFit : t.getAttribute("data-object-fit"),
            i = t.dataset ? t.dataset.objectPosition : t.getAttribute("data-object-position");
        e = e || "cover", i = i || "50% 50%";
        var n = t.parentNode;
        return function (t) {
          var e = window.getComputedStyle(t, null),
              i = e.getPropertyValue("position"),
              n = e.getPropertyValue("overflow"),
              o = e.getPropertyValue("display");
          i && "static" !== i || (t.style.position = "relative"), "hidden" !== n && (t.style.overflow = "hidden"), o && "inline" !== o || (t.style.display = "block"), 0 === t.clientHeight && (t.style.height = "100%"), -1 === t.className.indexOf("object-fit-polyfill") && (t.className = t.className + " object-fit-polyfill");
        }(n), function (t) {
          var e = window.getComputedStyle(t, null),
              i = {
            "max-width": "none",
            "max-height": "none",
            "min-width": "0px",
            "min-height": "0px",
            top: "auto",
            right: "auto",
            bottom: "auto",
            left: "auto",
            "margin-top": "0px",
            "margin-right": "0px",
            "margin-bottom": "0px",
            "margin-left": "0px"
          };

          for (var n in i) {
            e.getPropertyValue(n) !== i[n] && (t.style[n] = i[n]);
          }
        }(t), t.style.position = "absolute", t.style.width = "auto", t.style.height = "auto", "scale-down" === e && (e = t.clientWidth < n.clientWidth && t.clientHeight < n.clientHeight ? "none" : "contain"), "none" === e ? (o("x", t, i), void o("y", t, i)) : "fill" === e ? (t.style.width = "100%", t.style.height = "100%", o("x", t, i), void o("y", t, i)) : (t.style.height = "100%", void ("cover" === e && t.clientWidth > n.clientWidth || "contain" === e && t.clientWidth < n.clientWidth ? (t.style.top = "0", t.style.marginTop = "0", o("x", t, i)) : (t.style.width = "100%", t.style.height = "auto", t.style.left = "0", t.style.marginLeft = "0", o("y", t, i))));
      },
          e = function e(t) {
        if (void 0 === t || t instanceof Event) t = document.querySelectorAll("[data-object-fit]");else if (t && t.nodeName) t = [t];else {
          if ("object" != _typeof(t) || !t.length || !t[0].nodeName) return !1;
          t = t;
        }

        for (var e = 0; e < t.length; e++) {
          if (t[e].nodeName) {
            var i = t[e].nodeName.toLowerCase();
            "img" !== i || n ? "video" === i ? 0 < t[e].readyState ? l(t[e]) : t[e].addEventListener("loadedmetadata", function () {
              l(this);
            }) : l(t[e]) : t[e].complete ? l(t[e]) : t[e].addEventListener("load", function () {
              l(this);
            });
          }
        }

        return !0;
      };

      document.addEventListener("DOMContentLoaded", e), window.addEventListener("resize", e), window.objectFitPolyfill = e;
    } else window.objectFitPolyfill = function () {
      return !1;
    };
  }
}();

(function (global, factory) {
  (typeof exports === "undefined" ? "undefined" : _typeof(exports)) === 'object' && typeof module !== 'undefined' ? factory() : typeof define === 'function' && define.amd ? define(factory) : factory();
})(this, function () {
  'use strict';
  /**
   * @this {Promise}
   */

  function finallyConstructor(callback) {
    var constructor = this.constructor;
    return this.then(function (value) {
      return constructor.resolve(callback()).then(function () {
        return value;
      });
    }, function (reason) {
      return constructor.resolve(callback()).then(function () {
        return constructor.reject(reason);
      });
    });
  } // Store setTimeout reference so promise-polyfill will be unaffected by
  // other code modifying setTimeout (like sinon.useFakeTimers())


  var setTimeoutFunc = setTimeout;

  function noop() {} // Polyfill for Function.prototype.bind


  function bind(fn, thisArg) {
    return function () {
      fn.apply(thisArg, arguments);
    };
  }
  /**
   * @constructor
   * @param {Function} fn
   */


  function Promise(fn) {
    if (!(this instanceof Promise)) throw new TypeError('Promises must be constructed via new');
    if (typeof fn !== 'function') throw new TypeError('not a function');
    /** @type {!number} */

    this._state = 0;
    /** @type {!boolean} */

    this._handled = false;
    /** @type {Promise|undefined} */

    this._value = undefined;
    /** @type {!Array<!Function>} */

    this._deferreds = [];
    doResolve(fn, this);
  }

  function handle(self, deferred) {
    while (self._state === 3) {
      self = self._value;
    }

    if (self._state === 0) {
      self._deferreds.push(deferred);

      return;
    }

    self._handled = true;

    Promise._immediateFn(function () {
      var cb = self._state === 1 ? deferred.onFulfilled : deferred.onRejected;

      if (cb === null) {
        (self._state === 1 ? resolve : reject)(deferred.promise, self._value);
        return;
      }

      var ret;

      try {
        ret = cb(self._value);
      } catch (e) {
        reject(deferred.promise, e);
        return;
      }

      resolve(deferred.promise, ret);
    });
  }

  function resolve(self, newValue) {
    try {
      // Promise Resolution Procedure: https://github.com/promises-aplus/promises-spec#the-promise-resolution-procedure
      if (newValue === self) throw new TypeError('A promise cannot be resolved with itself.');

      if (newValue && (_typeof(newValue) === 'object' || typeof newValue === 'function')) {
        var then = newValue.then;

        if (newValue instanceof Promise) {
          self._state = 3;
          self._value = newValue;
          finale(self);
          return;
        } else if (typeof then === 'function') {
          doResolve(bind(then, newValue), self);
          return;
        }
      }

      self._state = 1;
      self._value = newValue;
      finale(self);
    } catch (e) {
      reject(self, e);
    }
  }

  function reject(self, newValue) {
    self._state = 2;
    self._value = newValue;
    finale(self);
  }

  function finale(self) {
    if (self._state === 2 && self._deferreds.length === 0) {
      Promise._immediateFn(function () {
        if (!self._handled) {
          Promise._unhandledRejectionFn(self._value);
        }
      });
    }

    for (var i = 0, len = self._deferreds.length; i < len; i++) {
      handle(self, self._deferreds[i]);
    }

    self._deferreds = null;
  }
  /**
   * @constructor
   */


  function Handler(onFulfilled, onRejected, promise) {
    this.onFulfilled = typeof onFulfilled === 'function' ? onFulfilled : null;
    this.onRejected = typeof onRejected === 'function' ? onRejected : null;
    this.promise = promise;
  }
  /**
   * Take a potentially misbehaving resolver function and make sure
   * onFulfilled and onRejected are only called once.
   *
   * Makes no guarantees about asynchrony.
   */


  function doResolve(fn, self) {
    var done = false;

    try {
      fn(function (value) {
        if (done) return;
        done = true;
        resolve(self, value);
      }, function (reason) {
        if (done) return;
        done = true;
        reject(self, reason);
      });
    } catch (ex) {
      if (done) return;
      done = true;
      reject(self, ex);
    }
  }

  Promise.prototype['catch'] = function (onRejected) {
    return this.then(null, onRejected);
  };

  Promise.prototype.then = function (onFulfilled, onRejected) {
    // @ts-ignore
    var prom = new this.constructor(noop);
    handle(this, new Handler(onFulfilled, onRejected, prom));
    return prom;
  };

  Promise.prototype['finally'] = finallyConstructor;

  Promise.all = function (arr) {
    return new Promise(function (resolve, reject) {
      if (!arr || typeof arr.length === 'undefined') throw new TypeError('Promise.all accepts an array');
      var args = Array.prototype.slice.call(arr);
      if (args.length === 0) return resolve([]);
      var remaining = args.length;

      function res(i, val) {
        try {
          if (val && (_typeof(val) === 'object' || typeof val === 'function')) {
            var then = val.then;

            if (typeof then === 'function') {
              then.call(val, function (val) {
                res(i, val);
              }, reject);
              return;
            }
          }

          args[i] = val;

          if (--remaining === 0) {
            resolve(args);
          }
        } catch (ex) {
          reject(ex);
        }
      }

      for (var i = 0; i < args.length; i++) {
        res(i, args[i]);
      }
    });
  };

  Promise.resolve = function (value) {
    if (value && _typeof(value) === 'object' && value.constructor === Promise) {
      return value;
    }

    return new Promise(function (resolve) {
      resolve(value);
    });
  };

  Promise.reject = function (value) {
    return new Promise(function (resolve, reject) {
      reject(value);
    });
  };

  Promise.race = function (values) {
    return new Promise(function (resolve, reject) {
      for (var i = 0, len = values.length; i < len; i++) {
        values[i].then(resolve, reject);
      }
    });
  }; // Use polyfill for setImmediate for performance gains


  Promise._immediateFn = typeof setImmediate === 'function' && function (fn) {
    setImmediate(fn);
  } || function (fn) {
    setTimeoutFunc(fn, 0);
  };

  Promise._unhandledRejectionFn = function _unhandledRejectionFn(err) {
    if (typeof console !== 'undefined' && console) {
      console.warn('Possible Unhandled Promise Rejection:', err); // eslint-disable-line no-console
    }
  };
  /** @suppress {undefinedVars} */


  var globalNS = function () {
    // the only reliable means to get the global object is
    // `Function('return this')()`
    // However, this causes CSP violations in Chrome apps.
    if (typeof self !== 'undefined') {
      return self;
    }

    if (typeof window !== 'undefined') {
      return window;
    }

    if (typeof global !== 'undefined') {
      return global;
    }

    throw new Error('unable to locate global object');
  }();

  if (!('Promise' in globalNS)) {
    globalNS['Promise'] = Promise;
  } else if (!globalNS.Promise.prototype['finally']) {
    globalNS.Promise.prototype['finally'] = finallyConstructor;
  }
});

!function (global, factory) {
  "use strict";

  "object" == (typeof module === "undefined" ? "undefined" : _typeof(module)) && "object" == _typeof(module.exports) ? module.exports = factory(global) : factory(global);
}("undefined" != typeof window ? window : global, function (global) {
  "use strict";

  var defineProperty = Object.defineProperty,
      defineProperties = Object.defineProperties,
      symbolHiddenCounter = 0,
      globalSymbolRegistry = [],
      slice = Array.prototype.slice,
      ES6 = "object" == _typeof(global.ES6) ? global.ES6 : global.ES6 = {},
      isArray = Array.isArray,
      objectToString = Object.prototype.toString,
      push = Array.prototype.push,
      emptyFunction = function emptyFunction() {},
      simpleFunction = function simpleFunction(arg) {
    return arg;
  },
      isCallable = function isCallable(fn) {
    return "function" == typeof fn;
  },
      Iterator = function Iterator() {},
      ArrayIterator = function ArrayIterator(array, flag) {
    this._array = array, this._flag = flag, this._nextIndex = 0;
  },
      StringIterator = function StringIterator(string, flag) {
    this._string = string, this._flag = flag, this._nextIndex = 0;
  },
      isObject = function isObject(value) {
    return null !== value && ("object" == _typeof(value) || "function" == typeof value);
  },
      setupSymbolInternals = function setupSymbolInternals(symbol, desc) {
    return defineProperties(symbol, {
      _description: {
        value: desc
      },
      _isSymbol: {
        value: !0
      },
      _id: {
        value: symbolHiddenCounter++
      }
    }), symbol;
  },
      appendArray = function appendArray(array1, array2) {
    if ("number" == typeof array1.length && array1.length >= 0 && "number" == typeof array2.length && array2.length >= 0) {
      var length1 = Math.floor(array1.length),
          length2 = Math.floor(array2.length),
          i = 0;

      for (array1.length = length1 + length2; i < length2; ++i) {
        array2.hasOwnProperty(i) && (array1[length1 + i] = array2[i]);
      }
    }
  },
      simpleInheritance = function simpleInheritance(child, parent) {
    if ("function" != typeof child || "function" != typeof parent) throw new TypeError("Child and Parent must be function type");
    child.prototype = Object.create(parent.prototype), child.prototype.constructor = child;
  },
      _Symbol = function _Symbol2(desc) {
    if (desc = void 0 === desc ? "" : String(desc), this instanceof _Symbol2) throw new TypeError("Symbol is not a constructor");
    return setupSymbolInternals(Object.create(_Symbol2.prototype), desc);
  };

  defineProperties(_Symbol, {
    "for": {
      value: function value(key) {
        key = String(key);

        for (var record, registryLength = globalSymbolRegistry.length, i = 0; i < registryLength; ++i) {
          if ((record = globalSymbolRegistry[i]).key === key) return record.symbol;
        }

        return record = {
          key: key,
          symbol: _Symbol(key)
        }, globalSymbolRegistry.push(record), record.symbol;
      },
      writable: !0,
      configurable: !0
    },
    keyFor: {
      value: function value(symbol) {
        if (!ES6.isSymbol(symbol)) throw new TypeError(String(symbol) + " is not a symbol");

        for (var record, registryLength = globalSymbolRegistry.length, i = 0; i < registryLength; ++i) {
          if ((record = globalSymbolRegistry[i]).symbol === symbol) return record.key;
        }
      },
      writable: !0,
      configurable: !0
    },
    hasInstance: {
      value: _Symbol("Symbol.hasInstance")
    },
    isConcatSpreadable: {
      value: _Symbol("Symbol.isConcatSpreadable")
    },
    iterator: {
      value: _Symbol("Symbol.iterator")
    },
    toStringTag: {
      value: _Symbol("Symbol.toStringTag")
    }
  }), _Symbol.prototype.toString = function () {
    return "@@_____" + this._id + "_____";
  }, _Symbol.prototype.valueOf = function () {
    return this;
  }, defineProperty(Iterator.prototype, _Symbol.iterator.toString(), {
    value: function value() {
      return this;
    },
    writable: !0,
    configurable: !0
  }), simpleInheritance(ArrayIterator, Iterator), simpleInheritance(StringIterator, Iterator), defineProperty(ArrayIterator.prototype, _Symbol.toStringTag.toString(), {
    value: "Array Iterator",
    configurable: !0
  }), defineProperty(StringIterator.prototype, _Symbol.toStringTag.toString(), {
    value: "String Iterator",
    configurable: !0
  }), ArrayIterator.prototype.next = function () {
    if (!(this instanceof ArrayIterator)) throw new TypeError("Method Array Iterator.prototype.next called on incompatible receiver " + String(this));
    var nextValue;
    return -1 === this._nextIndex ? {
      done: !0,
      value: void 0
    } : "number" == typeof this._array.length && this._array.length >= 0 && this._nextIndex < Math.floor(this._array.length) ? (1 === this._flag ? nextValue = [this._nextIndex, this._array[this._nextIndex]] : 2 === this._flag ? nextValue = this._array[this._nextIndex] : 3 === this._flag && (nextValue = this._nextIndex), this._nextIndex++, {
      done: !1,
      value: nextValue
    }) : (this._nextIndex = -1, {
      done: !0,
      value: void 0
    });
  }, StringIterator.prototype.next = function () {
    if (!(this instanceof StringIterator)) throw new TypeError("Method String Iterator.prototype.next called on incompatible receiver " + String(this));
    var nextValue,
        stringObject = new String(this._string);
    return -1 === this._nextIndex ? {
      done: !0,
      value: void 0
    } : this._nextIndex < stringObject.length ? (nextValue = stringObject[this._nextIndex], this._nextIndex++, {
      done: !1,
      value: nextValue
    }) : (this._nextIndex = -1, {
      done: !0,
      value: void 0
    });
  };

  var SpreadOperatorImpl = function SpreadOperatorImpl(target, thisArg) {
    this._target = target, this._values = [], this._thisArg = thisArg;
  };

  SpreadOperatorImpl.prototype.spread = function () {
    var self = this;
    return slice.call(arguments).forEach(function (iterable) {
      ES6.forOf(iterable, function (value) {
        self._values.push(value);
      });
    }), self;
  }, SpreadOperatorImpl.prototype.add = function () {
    var self = this;
    return slice.call(arguments).forEach(function (value) {
      self._values.push(value);
    }), self;
  }, SpreadOperatorImpl.prototype.call = function (thisArg) {
    if ("function" != typeof this._target) throw new TypeError("Target is not a function");
    return thisArg = arguments.length <= 0 ? this._thisArg : thisArg, this._target.apply(thisArg, this._values);
  }, SpreadOperatorImpl.prototype["new"] = function () {
    if ("function" != typeof this._target) throw new TypeError("Target is not a constructor");
    var temp, returnValue;
    return temp = Object.create(this._target.prototype), returnValue = this._target.apply(temp, this._values), isObject(returnValue) ? returnValue : temp;
  }, SpreadOperatorImpl.prototype.array = function () {
    if (!isArray(this._target)) throw new TypeError("Target is not a array");
    return push.apply(this._target, this._values), this._target;
  };
  return defineProperties(ES6, {
    isSymbol: {
      value: function value(symbol) {
        return symbol instanceof _Symbol && function (symbol) {
          return !0 === symbol._isSymbol && "number" == typeof symbol._id && "string" == typeof symbol._description;
        }(symbol);
      },
      writable: !0,
      configurable: !0
    },
    instanceOf: {
      value: function value(object, constructor) {
        if (!isObject(constructor)) throw new TypeError("Right-hand side of 'instanceof' is not an object");
        var hasInstanceSymbolProp = constructor[_Symbol.hasInstance];
        if (void 0 === hasInstanceSymbolProp) return object instanceof constructor;
        if ("function" != typeof hasInstanceSymbolProp) throw new TypeError(_typeof(hasInstanceSymbolProp) + " is not a function");
        return hasInstanceSymbolProp.call(constructor, object);
      },
      writable: !0,
      configurable: !0
    },
    forOf: {
      value: function value(iterable, callback, thisArg) {
        if (callback = "function" != typeof callback ? emptyFunction : callback, "function" != typeof iterable[_Symbol.iterator]) throw new TypeError("Iterable[Symbol.iterator] is not a function");

        var iterationResult,
            iterator = iterable[_Symbol.iterator]();

        if ("function" != typeof iterator.next) throw new TypeError(".iterator.next is not a function");

        for (;;) {
          if (iterationResult = iterator.next(), !isObject(iterationResult)) throw new TypeError("Iterator result " + iterationResult + " is not an object");
          if (iterationResult.done) break;
          callback.call(thisArg, iterationResult.value);
        }
      },
      writable: !0,
      configurable: !0
    },
    spreadOperator: {
      value: function value(target, thisArg) {
        if ("function" != typeof target && !isArray(target)) throw new TypeError("Spread operator only supports on array and function objects at this moment");
        return new SpreadOperatorImpl(target, thisArg);
      },
      writable: !0,
      configurable: !0
    }
  }), defineProperty(global, "Symbol", {
    value: _Symbol,
    writable: !0,
    configurable: !0
  }), defineProperty(Function.prototype, _Symbol.hasInstance.toString(), {
    value: function value(instance) {
      return "function" == typeof this && instance instanceof this;
    }
  }), defineProperty(Array.prototype, "concat", {
    value: function value() {
      if (void 0 === this || null === this) throw new TypeError("Array.prototype.concat called on null or undefined");
      var self = Object(this),
          targets = slice.call(arguments),
          outputs = [];
      return targets.unshift(self), targets.forEach(function (target) {
        isObject(target) ? void 0 !== target[_Symbol.isConcatSpreadable] ? target[_Symbol.isConcatSpreadable] ? appendArray(outputs, target) : outputs.push(target) : isArray(target) ? appendArray(outputs, target) : outputs.push(target) : outputs.push(target);
      }), outputs;
    },
    writable: !0,
    configurable: !0
  }), defineProperty(Object.prototype, "toString", {
    value: function value() {
      return void 0 === this || null === this ? objectToString.call(this) : "string" == typeof this[_Symbol.toStringTag] ? "[object " + this[_Symbol.toStringTag] + "]" : objectToString.call(this);
    },
    writable: !0,
    configurable: !0
  }), defineProperty(Array.prototype, _Symbol.iterator.toString(), {
    value: function value() {
      if (void 0 === this || null === this) throw new TypeError("Cannot convert undefined or null to object");
      var self = Object(this);
      return new ArrayIterator(self, 2);
    },
    writable: !0,
    configurable: !0
  }), defineProperty(Array, "from", {
    value: function value(arrayLike, mapFn, thisArg) {
      var constructor,
          length,
          outputs,
          i = 0;
      if (constructor = isCallable(this) ? this : Array, void 0 === arrayLike || null === arrayLike) throw new TypeError("Cannot convert undefined or null to object");
      if (arrayLike = Object(arrayLike), void 0 === mapFn) mapFn = simpleFunction;else if (!isCallable(mapFn)) throw new TypeError(mapFn + " is not a function");

      if (void 0 === arrayLike[_Symbol.iterator]) {
        if (!("number" == typeof arrayLike.length && arrayLike.length >= 0)) return (outputs = new constructor(0)).length = 0, outputs;

        for (length = Math.floor(arrayLike.length), (outputs = new constructor(length)).length = length; i < length; ++i) {
          outputs[i] = mapFn.call(thisArg, arrayLike[i]);
        }
      } else (outputs = new constructor()).length = 0, ES6.forOf(arrayLike, function (value) {
        outputs.length++, outputs[outputs.length - 1] = mapFn.call(thisArg, value);
      });

      return outputs;
    },
    writable: !0,
    configurable: !0
  }), defineProperty(Array.prototype, "entries", {
    value: function value() {
      if (void 0 === this || null === this) throw new TypeError("Cannot convert undefined or null to object");
      var self = Object(this);
      return new ArrayIterator(self, 1);
    },
    writable: !0,
    configurable: !0
  }), defineProperty(Array.prototype, "keys", {
    value: function value() {
      if (void 0 === this || null === this) throw new TypeError("Cannot convert undefined or null to object");
      var self = Object(this);
      return new ArrayIterator(self, 3);
    },
    writable: !0,
    configurable: !0
  }), defineProperty(String.prototype, _Symbol.iterator.toString(), {
    value: function value() {
      if (void 0 === this || null === this) throw new TypeError("String.prototype[Symbol.iterator] called on null or undefined");
      return new StringIterator(String(this), 0);
    },
    writable: !0,
    configurable: !0
  }), ES6;
});
/* ==========================================================================
    Helper functions
 ========================================================================== */

/*
 * Simple isset method for this does not exist in javascript
 */

var isset = function isset(obj) {
  return typeof obj !== 'undefined' && obj !== null;
};
/*
 * Easing Functions - inspired from http://gizma.com/easing/
 * only considering the t value for the range [0, 1] => [0, 1]
 */


var EasingFunctions = {
  // no easing, no acceleration
  linear: function linear(t) {
    return t;
  },
  // accelerating from zero velocity
  easeInQuad: function easeInQuad(t) {
    return t * t;
  },
  // decelerating to zero velocity
  easeOutQuad: function easeOutQuad(t) {
    return t * (2 - t);
  },
  // acceleration until halfway, then deceleration
  easeInOutQuad: function easeInOutQuad(t) {
    return t < .5 ? 2 * t * t : -1 + (4 - 2 * t) * t;
  },
  // accelerating from zero velocity
  easeInCubic: function easeInCubic(t) {
    return t * t * t;
  },
  // decelerating to zero velocity
  easeOutCubic: function easeOutCubic(t) {
    return --t * t * t + 1;
  },
  // acceleration until halfway, then deceleration
  easeInOutCubic: function easeInOutCubic(t) {
    return t < .5 ? 4 * t * t * t : (t - 1) * (2 * t - 2) * (2 * t - 2) + 1;
  },
  // accelerating from zero velocity
  easeInQuart: function easeInQuart(t) {
    return t * t * t * t;
  },
  // decelerating to zero velocity
  easeOutQuart: function easeOutQuart(t) {
    return 1 - --t * t * t * t;
  },
  // acceleration until halfway, then deceleration
  easeInOutQuart: function easeInOutQuart(t) {
    return t < .5 ? 8 * t * t * t * t : 1 - 8 * --t * t * t * t;
  },
  // accelerating from zero velocity
  easeInQuint: function easeInQuint(t) {
    return t * t * t * t * t;
  },
  // decelerating to zero velocity
  easeOutQuint: function easeOutQuint(t) {
    return 1 + --t * t * t * t * t;
  },
  // acceleration until halfway, then deceleration
  easeInOutQuint: function easeInOutQuint(t) {
    return t < .5 ? 16 * t * t * t * t * t : 1 + 16 * --t * t * t * t * t;
  }
};
/*
 * Vanilla version of the $.getScript
 */

var getScript = function getScript(source, callback) {
  var script = document.createElement('script');
  script.async = 1;
  var scripts = document.getElementsByTagName('script');
  var prior = scripts[scripts.length - 1];

  script.onload = script.onreadystatechange = function (_, isAbort) {
    if (isAbort || !script.readyState || /loaded|complete/.test(script.readyState)) {
      script.onload = script.onreadystatechange = null;
      script = undefined;

      if (!isAbort) {
        if (callback) callback();
      }
    }
  };

  script.src = source;
  prior.parentNode.insertBefore(script, prior);
};
/**
 * Returns a function, that, as long as it continues to be invoked, will not
 * be triggered. The function will be called after it stops being called for
 * N milliseconds. If `immediate` is passed, trigger the function on the
 * leading edge, instead of the trailing.
 * @param func
 * @param wait
 * @param immediate
 * @returns {Function}
 */


var debounce = function debounce(func, wait, immediate) {
  var timeout;
  return function () {
    var context = this,
        args = arguments;

    var later = function later() {
      timeout = null;
      if (!immediate) func.apply(context, args);
    };

    var callNow = immediate && !timeout;
    clearTimeout(timeout);
    timeout = setTimeout(later, wait);
    if (callNow) func.apply(context, args);
  };
};
/*
 * Cookie helper class
 */


var Cookie = {
  set: function set(name, value, days) {
    var domain, domainParts, date, expires, host;

    if (days) {
      date = new Date();
      date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);
      expires = "; expires=" + date.toGMTString();
    } else {
      expires = "";
    }

    host = location.host;

    if (host.split('.').length === 1) {
      // no "." in a domain - it's localhost or something similar
      document.cookie = name + "=" + value + expires + "; path=/";
    } else {
      // Remember the cookie on all sub domains.
      //
      // Start with trying to set cookie to the top domain.
      // (example: if user is on foo.com, try to set
      //  cookie to domain ".com")
      //
      // If the cookie will not be set, it means ".com"
      // is a top level domain and we need to
      // set the cookie to ".foo.com"
      domainParts = host.split('.');
      domainParts.shift();
      domain = '.' + domainParts.join('.'); // For development purpose, remove this when moving to production
      // domain = '.komma.pro';

      document.cookie = name + "=" + value + expires + "; path=/; domain=" + domain; // check if cookie was successfuly set to the given domain
      // (otherwise it was a Top-Level Domain)

      if (Cookie.get(name) == null || Cookie.get(name) != value) {
        // append "." to current domain
        domain = '.' + host;
        document.cookie = name + "=" + value + expires + "; path=/; domain=" + domain;
      }
    }
  },
  get: function get(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');

    for (var i = 0; i < ca.length; i++) {
      var c = ca[i];

      while (c.charAt(0) === ' ') {
        c = c.substring(1, c.length);
      }

      if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length, c.length);
    }

    return null;
  },
  erase: function erase(name) {
    Cookie.set(name, '', -1);
  }
};
/*
 * Javascript version of the number_format method of PHP
 */

var number_format = function number_format(number, decimals, dec_point, thousands_sep) {
  // Strip all characters but numerical ones.
  number = (number + '').replace(/[^0-9+\-Ee.]/g, '');

  var n = !isFinite(+number) ? 0 : +number,
      prec = !isFinite(+decimals) ? 0 : Math.abs(decimals),
      sep = typeof thousands_sep === 'undefined' ? ',' : thousands_sep,
      dec = typeof dec_point === 'undefined' ? '.' : dec_point,
      s = '',
      toFixedFix = function toFixedFix(n, prec) {
    var k = Math.pow(10, prec);
    return '' + Math.round(n * k) / k;
  }; // Fix for IE parseFloat(0.55).toFixed(0) = 0;


  s = (prec ? toFixedFix(n, prec) : '' + Math.round(n)).split('.');

  if (s[0].length > 3) {
    s[0] = s[0].replace(/\B(?=(?:\d{3})+(?!\d))/g, sep);
  }

  if ((s[1] || '').length < prec) {
    s[1] = s[1] || '';
    s[1] += new Array(prec - s[1].length + 1).join('0');
  }

  return s.join(dec);
};
/**
 * Element.closest() polyfill
 * https://developer.mozilla.org/en-US/docs/Web/API/Element/closest#Polyfill
 */


if (!Element.prototype.closest) {
  if (!Element.prototype.matches) {
    Element.prototype.matches = Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector;
  }

  Element.prototype.closest = function (s) {
    var el = this;
    var ancestor = this;
    if (!document.documentElement.contains(el)) return null;

    do {
      if (ancestor.matches(s)) return ancestor;
      ancestor = ancestor.parentElement;
    } while (ancestor !== null);

    return null;
  };
}

var Ajax = {
  //TODO: Can we create a prepare request function ??
  get: function get(url, callback) {
    var xhr = new XMLHttpRequest();
    var token = document.querySelector('meta[name="csrf-token"]').content;
    xhr.open('get', url, true);
    xhr.setRequestHeader('Content-Type', 'application/json');
    xhr.setRequestHeader('X-CSRF-TOKEN', token);
    xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');

    xhr.onreadystatechange = function () {
      if (xhr.readyState === 4) {
        callback(xhr);
      }
    };

    xhr.send();
  },
  post: function post(url, data, callback) {
    var xhr = new XMLHttpRequest();
    var token = document.querySelector('meta[name="csrf-token"]').content;
    xhr.open('post', url, true);
    xhr.setRequestHeader('Content-Type', 'application/json');
    xhr.setRequestHeader('X-CSRF-TOKEN', token);
    xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');

    xhr.onreadystatechange = function () {
      if (xhr.readyState === 4) {
        callback(xhr);
      }
    };

    xhr.send(JSON.stringify(data));
  }
};
/**
 * Capitalize the first letter of the string
 * @param string
 * @returns {string}
 */

var capitalizeFirstLetter = function capitalizeFirstLetter(string) {
  return string.charAt(0).toUpperCase() + string.slice(1);
};
/**
 * Convert snake case into camelcase
 *
 * @param string
 * @returns {*}
 */


function snakeToCamel(string) {
  return string.replace(/(\-\w)/g, function (m) {
    return m[1].toUpperCase();
  });
}
/**
 * Get the index of an element inside its parent
 */


function indexInParent(node) {
  var children = node.parentNode.childNodes;
  var num = 0;

  for (var i = 0; i < children.length; i++) {
    if (children[i] == node) return num;
    if (children[i].nodeType == 1) num++;
  }

  return -1;
}
/**
 * For security reasons iOS Safari only allows document.execCommand('copy') for text within a contentEditable container.
 * The workaround is to detect iOS Safari and quickly toggle contentEditable before executing document.execCommand('copy').
 * Wheb input or textarea is READONLY you can prevent the unwanted popup with copy/paste functions and the input keyboard
 * Code from: https://stackoverflow.com/a/46981847
 */


function copyToClipboard(el) {
  // resolve the element
  el = typeof el === 'string' ? document.querySelector(el) : el; // handle iOS as a special case

  if (navigator.userAgent.match(/ipad|ipod|iphone/i)) {
    // save current contentEditable/readOnly status
    var editable = el.contentEditable;
    var readOnly = el.readOnly; // convert to editable with readonly to stop iOS keyboard opening

    el.contentEditable = true;
    el.readOnly = true; // create a selectable range

    var range = document.createRange();
    range.selectNodeContents(el); // select the range

    var selection = window.getSelection();
    selection.removeAllRanges();
    selection.addRange(range);
    el.setSelectionRange(0, 999999); // restore contentEditable/readOnly to original state

    el.contentEditable = editable;
    el.readOnly = readOnly;
  } else {
    el.select();
  } // execute copy command


  document.execCommand('copy');
}