function t(t){return function(t){if(Array.isArray(t))return e(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,o){if(t){if("string"==typeof t)return e(t,o);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?e(t,o):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function e(t,e){(null==e||e>t.length)&&(e=t.length);for(var o=0,n=Array(e);o<e;o++)n[o]=t[o];return n}function o(t){return o="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},o(t)}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(t,e,n,r){var a=this,c={method:n,mode:"cors",cache:"no-cache",credentials:"same-origin",headers:r,body:this.prepareRequestData(e)};return fetch(t,c).then(function(t){if(!t.ok)throw Error(t.statusText);return t.json()}).then(function(t){try{"object"===o(t)&&null!==t?"success"in t&&!1===t.success?(console.log("PVC: Request error."),console.log(t.data)):(a.saveCookieData(t.storage),a.triggerEvent("pvcCheckPost",t)):(console.log("PVC: Invalid object."),console.log(t))}catch(e){console.log("PVC: Invalid JSON data."),console.log(e)}}).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)},getCookiePath:function(){var t="string"==typeof this.args.path?this.args.path.trim():"";if(!t||"/"===t)return"/";var e=t.replace(/\/{2,}/g,"/").replace(/^\/+|\/+$/g,"");return e?"/".concat(e,"/"):"/"},saveCookieData:function(e){var o=this;if(e&&Object.prototype.hasOwnProperty.call(e,"name")){var n=t(new Set(e.name.map(function(t){return t.replace(/\[\d+\]$/,"")}))),r="";"https:"===document.location.protocol&&(r=";secure"),n.forEach(function(t){document.cookie.split(";").forEach(function(e){if(e&&e.trim()){var n=e.split("=")[0];if(n){var a=n.trim();new RegExp("^".concat(t,"\\[(\\d+)\\]$")).test(a)&&(document.cookie="".concat(a,"=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=").concat(o.getCookiePath(),";domain=").concat(o.args.domain).concat(r,";SameSite=Lax"))}}})});for(var a=0;a<e.name.length;a++){var c=new Date,i=parseInt(e.expiry[a],10),s=e.value[a];"string"!=typeof s&&(s=String(null!=s?s:"")),i?i*=1e3:i=c.getTime()+864e5,c.setTime(i),document.cookie="".concat(e.name[a],"=").concat(encodeURIComponent(s),";expires=").concat(c.toUTCString(),";path=").concat(this.getCookiePath(),";domain=").concat(this.args.domain).concat(r,";SameSite=Lax")}}},readCookieData:function(t){var e=[];document.cookie.split(";").forEach(function(o){if(o&&o.trim()){var n=o.split("="),r=n[0],a=n.slice(1).join("=");if(r){var c=r.trim(),i=new RegExp("^".concat(t,"\\[(\\d+)\\]$")),s=c.match(i);if(s){var u=a||"";try{u=decodeURIComponent(u)}catch(l){u=a||""}e.push({index:parseInt(s[1],10),value:u})}}}}),e.sort(function(t,e){return t.index-e.index});var n=e.map(function(t){return t.value}),r=n.join("");if(r)try{var a=JSON.parse(r);if(a&&"object"===o(a)&&1===a.version)return r}catch(c){}return n.join("a")}};var n=function(){return window.PostViewsCounter.init(pvcArgsFrontend)};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",n):n();