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AAW,KAAK,EACnC,EAYF,CAvnBkC,CAunBhC,SAAU,SAAU,UAAU,WAEV,iBAAX,QAAiD,iBAAnB,OAAO,UAC5C,OAAO,QAAU","file":"/npm/instantclick2@1.1.0/src/instantclick.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.37.0.\n * Original file: /npm/instantclick2@1.1.0/src/instantclick.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","/* InstantClick 3.1.0 | (C) 2014-2015 Alexandre Dieulot | http://instantclick.io/license */\n\nvar instantClick\n  , InstantClick = instantClick = function(document, location, $userAgent) {\n  // Internal variables\n  var $isChromeForIOS = $userAgent.indexOf(' CriOS/') > -1\n    , $currentLocationWithoutHash\n    , $urlToPreload\n    , $preloadTimer\n    , $lastTouchTimestamp\n    , $preloadCacheTimeLimit = 30000 //how long to cache preloaded pages for\n    , $preloadTimeDict = {} //dict of last time a url was preloaded\n    , $xhrDict = {} //cache of preloaded xhr objects\n\n  // Preloading-related variables\n    , $history = {}\n    , $xhr\n    , $url = false\n    , $title = false\n    , $mustRedirect = false\n    , $body = false\n    , $timing = {}\n    , $isPreloading = false\n    , $isWaitingForCompletion = false\n    , $trackedAssets = []\n\n  // Variables defined by public functions\n    , $preloadOnMousedown\n    , $delayBeforePreload\n    , $eventsCallbacks = {\n        fetch: [],\n        receive: [],\n        wait: [],\n        change: [],\n        restore: []\n      }\n\n\n  ////////// HELPERS //////////\n\n\n  function removeHash(url) {\n    var index = url.indexOf('#')\n    if (index < 0) {\n      return url\n    }\n    return url.substr(0, index)\n  }\n\n  function getLinkTarget(target) {\n    while (target && target.nodeName != 'A') {\n      target = target.parentNode\n    }\n    return target\n  }\n\n  function isBlacklisted(elem) {\n    do {\n      if (!elem.hasAttribute) { // Parent of <html>\n        break\n      }\n      if (elem.hasAttribute('data-instant')) {\n        return false\n      }\n      if (elem.hasAttribute('data-no-instant')) {\n        return true\n      }\n    }\n    while (elem = elem.parentNode)\n    return false\n  }\n\n  function isPreloadable(a) {\n    var domain = location.protocol + '//' + location.host\n\n    if (a.target // target=\"_blank\" etc.\n        || a.hasAttribute('download')\n        || a.href.indexOf(domain + '/') != 0 // Another domain, or no href attribute\n        || (a.href.indexOf('#') > -1\n            && removeHash(a.href) == $currentLocationWithoutHash) // Anchor\n        || isBlacklisted(a)\n       ) {\n      return false\n    }\n    return true\n  }\n\n  function triggerPageEvent(eventType, arg1, arg2, arg3) {\n    var returnValue = false\n    for (var i = 0; i < $eventsCallbacks[eventType].length; i++) {\n      if (eventType == 'receive') {\n        var altered = $eventsCallbacks[eventType][i](arg1, arg2, arg3)\n        if (altered) {\n          /* Update args for the next iteration of the loop. */\n          if ('body' in altered) {\n            arg2 = altered.body\n          }\n          if ('title' in altered) {\n            arg3 = altered.title\n          }\n\n          returnValue = altered\n        }\n      }\n      else {\n        $eventsCallbacks[eventType][i](arg1, arg2, arg3)\n      }\n    }\n    return returnValue\n  }\n\n  function changePage(title, body, newUrl, scrollY, pop) {\n    document.documentElement.replaceChild(body, document.body)\n    /* We cannot just use `document.body = doc.body`, it causes Safari (tested\n       5.1, 6.0 and Mobile 7.0) to execute script tags directly.\n    */\n    if (newUrl) {\n      if (location.href !== newUrl){\n          history.pushState(null, null, newUrl)\n      }\n      var hashIndex = newUrl.indexOf('#')\n        , hashElem = hashIndex > -1\n                     && document.getElementById(newUrl.substr(hashIndex + 1))\n        , offset = 0\n\n      if (hashElem) {\n        while (hashElem.offsetParent) {\n          offset += hashElem.offsetTop\n\n          hashElem = hashElem.offsetParent\n        }\n      }\n      scrollTo(0, offset)\n\n      $currentLocationWithoutHash = removeHash(newUrl)\n    }\n    else {\n      scrollTo(0, scrollY)\n    }\n\n    if ($isChromeForIOS && document.title == title) {\n      /* Chrome for iOS:\n       *\n       * 1. Removes title on pushState, so the title needs to be set after.\n       *\n       * 2. Will not set the title if it's identical when trimmed, so\n       *    appending a space won't do; but a non-breaking space works.\n       */\n      document.title = title + String.fromCharCode(160)\n    }\n    else {\n      document.title = title\n    }\n\n    instantanize()\n    if (pop) {\n      triggerPageEvent('restore')\n    }\n    else {\n      triggerPageEvent('change', false)\n    }\n  }\n\n  function setPreloadingAsHalted() {\n    $isPreloading = false\n    $isWaitingForCompletion = false\n  }\n\n  function removeNoscriptTags(html) {\n    /* Must be done on text, not on a node's innerHTML, otherwise strange\n     * things happen with implicitly closed elements (see the Noscript test).\n     */\n    return html.replace(/<noscript[\\s\\S]+?<\\/noscript>/gi, '')\n  }\n\n\n  ////////// EVENT LISTENERS //////////\n\n\n  function mousedownListener(e) {\n    if ($lastTouchTimestamp > (+new Date - 500)) {\n      return // Otherwise, click doesn't fire\n    }\n\n    var a = getLinkTarget(e.target)\n\n    if (!a || !isPreloadable(a)) {\n      return\n    }\n\n    preload(a.href)\n  }\n\n  function mouseoverListener(e) {\n    if ($lastTouchTimestamp > (+new Date - 500)) {\n      return // Otherwise, click doesn't fire\n    }\n\n    var a = getLinkTarget(e.target)\n\n    if (!a || !isPreloadable(a)) {\n      return\n    }\n\n    a.addEventListener('mouseout', mouseoutListener)\n\n    if (!$delayBeforePreload) {\n      preload(a.href)\n    }\n    else {\n      $urlToPreload = a.href\n      $preloadTimer = setTimeout(preload, $delayBeforePreload)\n    }\n  }\n\n  function touchstartListener(e) {\n    $lastTouchTimestamp = +new Date\n\n    var a = getLinkTarget(e.target)\n\n    if (!a || !isPreloadable(a)) {\n      return\n    }\n\n    if ($preloadOnMousedown) {\n      a.removeEventListener('mousedown', mousedownListener)\n    }\n    else {\n      a.removeEventListener('mouseover', mouseoverListener)\n    }\n    preload(a.href)\n  }\n\n  function clickListener(e) {\n    var a = getLinkTarget(e.target)\n\n    if (!a || !isPreloadable(a)) {\n      return\n    }\n\n    if (e.which > 1 || e.metaKey || e.ctrlKey) { // Opening in new tab\n      return\n    }\n    e.preventDefault()\n    display(a.href)\n  }\n\n  function mouseoutListener() {\n    if ($preloadTimer) {\n      clearTimeout($preloadTimer)\n      $preloadTimer = false\n      return\n    }\n\n    if (!$isPreloading || $isWaitingForCompletion) {\n      return\n    }\n    \n    $xhr.abort()\n    setPreloadingAsHalted()\n  }\n\n  function cloneXhr(xhr) {\n    var clone = {};\n    var responseHeader = xhr.getResponseHeader('Content-Type')\n\n    clone.isFromCache = true; //variable to identify cached Xhr\n    clone.readyState = xhr.readyState;\n    clone.status = xhr.status;\n    clone.responseText = xhr.responseText;\n    clone.getResponseHeader = function(arg) {\n      return responseHeader;\n    }\n\n    return clone;\n  }\n\n  function readystatechangeListener(xhr) {\n    if (xhr.readyState < 4) {\n      return\n    }\n    if (xhr.status == 0) {\n      /* Request aborted */\n      return\n    }\n\n    $timing.ready = +new Date - $timing.start\n\n    if (!xhr.isFromCache) {\n      $xhrDict[$url] = cloneXhr(xhr);\n      $preloadTimeDict[$url] = new Date().getTime();\n    }\n    \n    if (xhr.getResponseHeader('Content-Type').match(/\\/(x|ht|xht)ml/)) {\n      var doc = document.implementation.createHTMLDocument('')\n      doc.documentElement.innerHTML = removeNoscriptTags(xhr.responseText)\n      $title = doc.title\n      $body = doc.body\n\n      var alteredOnReceive = triggerPageEvent('receive', $url, $body, $title)\n      if (alteredOnReceive) {\n        if ('body' in alteredOnReceive) {\n          $body = alteredOnReceive.body\n        }\n        if ('title' in alteredOnReceive) {\n          $title = alteredOnReceive.title\n        }\n      }\n\n      var urlWithoutHash = removeHash($url)\n      $history[urlWithoutHash] = {\n        body: $body,\n        title: $title,\n        scrollY: urlWithoutHash in $history ? $history[urlWithoutHash].scrollY : 0\n      }\n\n      var elems = doc.head.children\n        , found = 0\n        , elem\n        , data\n\n      for (var i = 0; i < elems.length; i++) {\n        elem = elems[i]\n        if (elem.hasAttribute('data-instant-track')) {\n          data = elem.getAttribute('href') || elem.getAttribute('src') || elem.innerHTML\n          for (var j = 0; j < $trackedAssets.length; j++) {\n            if ($trackedAssets[j] == data) {\n              found++\n            }\n          }\n        }\n      }\n      if (found != $trackedAssets.length) {\n        $mustRedirect = true // Assets have changed\n      }\n    }\n    else {\n      $mustRedirect = true // Not an HTML document\n    }\n\n    if ($isWaitingForCompletion) {\n      $isWaitingForCompletion = false\n      display($url)\n    }\n  }\n\n  function popstateListener() {\n    var loc = removeHash(location.href)\n    if (loc == $currentLocationWithoutHash) {\n      return\n    }\n\n    if (!(loc in $history)) {\n      location.href = location.href\n      /* Reloads the page while using cache for scripts, styles and images,\n         unlike `location.reload()` */\n      return\n    }\n\n    $history[$currentLocationWithoutHash].scrollY = pageYOffset\n    $currentLocationWithoutHash = loc\n    changePage($history[loc].title, $history[loc].body, false, $history[loc].scrollY, true)\n  }\n\n\n  ////////// MAIN FUNCTIONS //////////\n\n\n  function instantanize(isInitializing) {\n    document.body.addEventListener('touchstart', touchstartListener, true)\n    if ($preloadOnMousedown) {\n      document.body.addEventListener('mousedown', mousedownListener, true)\n    }\n    else {\n      document.body.addEventListener('mouseover', mouseoverListener, true)\n    }\n    document.body.addEventListener('click', clickListener, true)\n\n    if (!isInitializing) {\n      var scripts = document.body.getElementsByTagName('script')\n        , script\n        , copy\n        , parentNode\n        , nextSibling\n\n      for (var i = 0, j = scripts.length; i < j; i++) {\n        script = scripts[i]\n        if (script.hasAttribute('data-no-instant')) {\n          continue\n        }\n        copy = document.createElement('script')\n        if (script.src) {\n          copy.src = script.src\n        }\n        if (script.innerHTML) {\n          copy.innerHTML = script.innerHTML\n        }\n        parentNode = script.parentNode\n        nextSibling = script.nextSibling\n        parentNode.removeChild(script)\n        parentNode.insertBefore(copy, nextSibling)\n      }\n    }\n  }\n\n  function preload(url) {\n    if (!$preloadOnMousedown\n        && 'display' in $timing\n        && +new Date - ($timing.start + $timing.display) < 100) {\n      /* After a page is displayed, if the user's cursor happens to be above\n         a link a mouseover event will be in most browsers triggered\n         automatically, and in other browsers it will be triggered when the\n         user moves his mouse by 1px.\n\n         Here are the behavior I noticed, all on Windows:\n         - Safari 5.1: auto-triggers after 0 ms\n         - IE 11: auto-triggers after 30-80 ms (depends on page's size?)\n         - Firefox: auto-triggers after 10 ms\n         - Opera 18: auto-triggers after 10 ms\n\n         - Chrome: triggers when cursor moved\n         - Opera 12.16: triggers when cursor moved\n\n         To remedy to this, we do not start preloading if last display\n         occurred less than 100 ms ago.\n      */\n\n      return\n    }\n\n    if ($preloadTimer) {\n      clearTimeout($preloadTimer)\n      $preloadTimer = false\n    }\n\n    if (!url) {\n      url = $urlToPreload\n    }\n    \n    if ($isPreloading && (url == $url || $isWaitingForCompletion)) {\n      return\n    }\n    $isPreloading = true\n    $isWaitingForCompletion = false\n\n    $url = url\n\n    $body = false\n    $mustRedirect = false\n    $timing = {\n      start: +new Date\n    }\n    triggerPageEvent('fetch')\n\n    if ($xhrDict[$url] && $preloadTimeDict[$url] + $preloadCacheTimeLimit > new Date().getTime()) {\n      readystatechangeListener($xhrDict[$url])\n    } else {\n      $xhr.open('GET', url)\n      $xhr.send()\n    }\n  }\n\n  function display(url) {\n    if (!('display' in $timing)) {\n      $timing.display = +new Date - $timing.start\n    }\n    if ($preloadTimer || !$isPreloading) {\n      /* $preloadTimer:\n         Happens when there's a delay before preloading and that delay\n         hasn't expired (preloading didn't kick in).\n\n         !$isPreloading:\n         A link has been clicked, and preloading hasn't been initiated.\n         It happens with touch devices when a user taps *near* the link,\n         Safari/Chrome will trigger mousedown, mouseover, click (and others),\n         but when that happens we ignore mousedown/mouseover (otherwise click\n         doesn't fire). Maybe there's a way to make the click event fire, but\n         that's not worth it as mousedown/over happen just 1ms before click\n         in this situation.\n\n         It also happens when a user uses his keyboard to navigate (with Tab\n         and Return), and possibly in other non-mainstream ways to navigate\n         a website.\n      */\n      if ($preloadTimer && $url && $url != url) {\n        /* Happens when the user clicks on a link before preloading\n           kicks in while another link is already preloading.\n        */\n\n        location.href = url\n        return\n      }\n\n      preload(url)\n      triggerPageEvent('wait')\n      $isWaitingForCompletion = true // Must be set *after* calling `preload`\n      return\n    }\n    if ($isWaitingForCompletion) {\n      /* The user clicked on a link while a page was preloading. Either on\n         the same link or on another link. If it's the same link something\n         might have gone wrong (or he could have double clicked, we don't\n         handle that case), so we send him to the page without pjax.\n         If it's another link, it hasn't been preloaded, so we redirect the\n         user to it.\n      */\n      location.href = url\n      return\n    }\n    if ($mustRedirect) {\n      location.href = $url\n      return\n    }\n    if (!$body) {\n      triggerPageEvent('wait')\n      $isWaitingForCompletion = true\n      return\n    }\n    $history[$currentLocationWithoutHash].scrollY = pageYOffset\n    setPreloadingAsHalted()\n    changePage($title, $body, $url)\n  }\n\n\n  ////////// PUBLIC VARIABLE AND FUNCTIONS //////////\n\n  var supported = 'pushState' in history\n                  && (!$userAgent.match('Android') || $userAgent.match('Chrome/'))\n                  && location.protocol != \"file:\"\n\n  /* The (sad) state of Android's AOSP browsers:\n\n     2.3.7: pushState appears to work correctly, but\n            `doc.documentElement.innerHTML = body` is buggy.\n            Update: InstantClick doesn't use that anymore, but it may\n            fail where 3.0 do, this needs testing again.\n\n     3.0:   pushState appears to work correctly (though the address bar is\n            only updated on focus), but\n            `document.documentElement.replaceChild(doc.body, document.body)`\n            throws DOMException: WRONG_DOCUMENT_ERR.\n\n     4.0.2: Doesn't support pushState.\n\n     4.0.4,\n     4.1.1,\n     4.2,\n     4.3:   Claims support for pushState, but doesn't update the address bar.\n\n     4.4:   Works correctly. Claims to be 'Chrome/30.0.0.0'.\n\n     All androids tested with Android SDK's Emulator.\n     Version numbers are from the browser's user agent.\n\n     Because of this mess, the only whitelisted browser on Android is Chrome.\n  */\n\n  function init(options) {\n    var preloadingMode;\n\n    if (typeof options !== 'object') {\n      //legacy parameters\n      preloadingMode = options;\n    } else {\n      preloadingMode = options.preloadingMode || 0;\n\n      if (options.preloadCacheTimeLimit !== undefined) {\n        $preloadCacheTimeLimit = options.preloadCacheTimeLimit;\n      }\n    }\n\n    if ($currentLocationWithoutHash) {\n      /* Already initialized */\n      return\n    }\n    if (!supported) {\n      triggerPageEvent('change', true)\n      return\n    }\n\n    if (preloadingMode == 'mousedown') {\n      $preloadOnMousedown = true\n    }\n    else if (typeof preloadingMode == 'number') {\n      $delayBeforePreload = preloadingMode\n    }\n\n    $currentLocationWithoutHash = removeHash(location.href)\n    $history[$currentLocationWithoutHash] = {\n      body: document.body,\n      title: document.title,\n      scrollY: pageYOffset\n    }\n\n    var elems = document.head.children\n      , elem\n      , data\n    for (var i = 0; i < elems.length; i++) {\n      elem = elems[i]\n      if (elem.hasAttribute('data-instant-track')) {\n        data = elem.getAttribute('href') || elem.getAttribute('src') || elem.innerHTML\n        /* We can't use just `elem.href` and `elem.src` because we can't\n           retrieve `href`s and `src`s from the Ajax response.\n        */\n        $trackedAssets.push(data)\n      }\n    }\n\n    $xhr = new XMLHttpRequest()\n    $xhr.addEventListener('readystatechange', function() {\n      readystatechangeListener($xhr);\n    })\n\n    instantanize(true)\n\n    triggerPageEvent('change', true)\n\n    addEventListener('popstate', popstateListener)\n  }\n\n  function on(eventType, callback) {\n    $eventsCallbacks[eventType].push(callback)\n  }\n\n\n  ////////////////////\n\n\n  return {\n    supported: supported,\n    init: init,\n    on: on\n  }\n\n}(document, location, navigator.userAgent);\n\nif (typeof module === 'object' && typeof module.exports === 'object') {\n    module.exports = InstantClick;\n}"]}