function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t(e)}window.PostViewsCounter={promise:null,args:{},init:function(t){this.args=t;var e={storage_type:"cookies",storage_data:this.readCookieData("pvc_visits".concat(!1!==t.multisite?"_".concat(parseInt(t.multisite,10)):""))};"rest_api"===t.mode?this.promise=this.request(t.requestURL,e,"POST",{"Content-Type":"application/x-www-form-urlencoded; charset=utf-8","X-WP-Nonce":t.nonce}):(e.action="pvc-check-post",e.pvc_nonce=t.nonce,e.id=t.postID,this.promise=this.request(t.requestURL,e,"POST",{"Content-Type":"application/x-www-form-urlencoded; charset=utf-8"}))},request:function(e,o,n,c){var a=this,r={method:n,mode:"cors",cache:"no-cache",credentials:"same-origin",headers:c,body:this.prepareRequestData(o)};return fetch(e,r).then(function(t){if(!t.ok)throw Error(t.statusText);return t.json()}).then(function(e){try{"object"===t(e)&&null!==e?"success"in e&&!1===e.success?(console.log("PVC: Request error."),console.log(e.data)):(a.saveCookieData(e.storage),a.triggerEvent("pvcCheckPost",e)):(console.log("PVC: Invalid object."),console.log(e))}catch(o){console.log("PVC: Invalid JSON data."),console.log(o)}}).catch(function(t){console.log("PVC: Invalid response."),console.log(t)})},prepareRequestData:function(t){return Object.keys(t).map(function(e){return"".concat(encodeURIComponent(e),"=").concat(encodeURIComponent(t[e]))}).join("&").replace(/%20/g,"+")},triggerEvent:function(t,e){var o=new CustomEvent(t,{bubbles:!0,detail:e});document.dispatchEvent(o)},saveCookieData:function(t){if(t&&Object.prototype.hasOwnProperty.call(t,"name")){var e="";"https:"===document.location.protocol&&(e=";secure");for(var o=0;o<t.name.length;o++){var n=new Date,c=parseInt(t.expiry[o],10);c?c*=1e3:c=n.getTime()+864e5,n.setTime(c),document.cookie="".concat(t.name[o],"=").concat(t.value[o],";expires=").concat(n.toUTCString(),";path=/").concat("/"===this.args.path?"":this.args.path,";domain=").concat(this.args.domain).concat(e,";SameSite=Lax")}}},readCookieData:function(t){var e=[];return document.cookie.split(";").forEach(function(o){if(o&&o.trim()){var n=o.split("="),c=n[0],a=n.slice(1).join("=");if(c){var r=c.trim();new RegExp("".concat(t,"\\[\\d+\\]")).test(r)&&e.push(a||"")}}}),e.join("a")}};var e=function(){return window.PostViewsCounter.init(pvcArgsFrontend)};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",e):e();
