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GAnCpD,KACf,MACM,EAAU,IADC,SAAS,iBAAiB,wBACb,KAAI,GACzB,UAAU,EAAQ,MAG3B,EAAQ,MAAO,0BAA0B,mBAAmB,KAAK,UAAU,CAAE,IAAK,CAAE,IAAO,SACxF,MAAK,GAAY,EAAS,SAC1B,MAAK,EAAG,cACP,IAAK,MAAM,KAAO,EAAS,CACzB,MAAM,EAAS,EAAQ,MAAK,GAAQ,EAAK,MAAQ,IACjD,EAAkB,GAAK,UAAY,EAAS,EAAO,KAAO,CAC5D,KAED,OAAM,IACL,QAAQ,MAAM,0BAA2B,EAAM,GAC/C,EAoBF,CAAS,EACX,EAGI,EAAkC,cAArB,EAAO,OAAO,GAAqB,WAAW,EAAO,MAAM,EAAG,GAAG,oCAAsC,EAE1H,SAAS,iBAAiB,eAAe,KACnC,EACF,EAAU,GAEV,MAAM,iDAAiD,KACpD,MAAK,GAAY,EAAS,SAC1B,MAAK,EAAG,iBACP,EAAU,WAAW,IAAa,GAExC,GAEH,CAlGD","file":"/npm/hexo-theme-next@8.10.0/source/js/third-party/statistics/lean-analytics.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/hexo-theme-next@8.10.0/source/js/third-party/statistics/lean-analytics.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","/* global CONFIG */\n/* eslint-disable no-console */\n\n(function() {\n  const leancloudSelector = url => {\n    url = encodeURI(url);\n    return document.getElementById(url).querySelector('.leancloud-visitors-count');\n  };\n\n  const addCount = Counter => {\n    const visitors = document.querySelector('.leancloud_visitors');\n    const url = decodeURI(visitors.id);\n    const title = visitors.dataset.flagTitle;\n\n    Counter('get', `/classes/Counter?where=${encodeURIComponent(JSON.stringify({ url }))}`)\n      .then(response => response.json())\n      .then(({ results }) => {\n        if (results.length > 0) {\n          const counter = results[0];\n          leancloudSelector(url).innerText = counter.time + 1;\n          Counter('put', '/classes/Counter/' + counter.objectId, {\n            time: {\n              '__op'  : 'Increment',\n              'amount': 1\n            }\n          })\n            .catch(error => {\n              console.error('Failed to save visitor count', error);\n            });\n        } else if (CONFIG.leancloud_visitors.security) {\n          leancloudSelector(url).innerText = 'Counter not initialized! More info at console err msg.';\n          console.error('ATTENTION! LeanCloud counter has security bug, see how to solve it here: https://github.com/theme-next/hexo-leancloud-counter-security. \\n However, you can still use LeanCloud without security, by setting `security` option to `false`.');\n        } else {\n          Counter('post', '/classes/Counter', { title, url, time: 1 })\n            .then(response => response.json())\n            .then(() => {\n              leancloudSelector(url).innerText = 1;\n            })\n            .catch(error => {\n              console.error('Failed to create', error);\n            });\n        }\n      })\n      .catch(error => {\n        console.error('LeanCloud Counter Error', error);\n      });\n  };\n\n  const showTime = Counter => {\n    const visitors = document.querySelectorAll('.leancloud_visitors');\n    const entries = [...visitors].map(element => {\n      return decodeURI(element.id);\n    });\n\n    Counter('get', `/classes/Counter?where=${encodeURIComponent(JSON.stringify({ url: { '$in': entries } }))}`)\n      .then(response => response.json())\n      .then(({ results }) => {\n        for (const url of entries) {\n          const target = results.find(item => item.url === url);\n          leancloudSelector(url).innerText = target ? target.time : 0;\n        }\n      })\n      .catch(error => {\n        console.error('LeanCloud Counter Error', error);\n      });\n  };\n\n  const { app_id, app_key, server_url } = CONFIG.leancloud_visitors;\n  const fetchData = api_server => {\n    const Counter = (method, url, data) => {\n      return fetch(`${api_server}/1.1${url}`, {\n        method,\n        headers: {\n          'X-LC-Id'     : app_id,\n          'X-LC-Key'    : app_key,\n          'Content-Type': 'application/json'\n        },\n        body: JSON.stringify(data)\n      });\n    };\n    if (CONFIG.page.isPost) {\n      if (CONFIG.hostname !== location.hostname) return;\n      addCount(Counter);\n    } else if (document.querySelectorAll('.post-title-link').length >= 1) {\n      showTime(Counter);\n    }\n  };\n\n  const api_server = app_id.slice(-9) === '-MdYXbMMI' ? `https://${app_id.slice(0, 8).toLowerCase()}.api.lncldglobal.com` : server_url;\n\n  document.addEventListener('page:loaded', () => {\n    if (api_server) {\n      fetchData(api_server);\n    } else {\n      fetch(`https://app-router.leancloud.cn/2/route?appId=${app_id}`)\n        .then(response => response.json())\n        .then(({ api_server }) => {\n          fetchData(`https://${api_server}`);\n        });\n    }\n  });\n})();\n"]}