!function(){"use strict";var t={n:function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,{a:n}),n},d:function(e,n){for(var o in n)t.o(n,o)&&!t.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:n[o]})},o:function(t,e){return Object.prototype.hasOwnProperty.call(t,e)}},e=window.wp.domReady,n=t.n(e);const o=window.requestIdleCallback?t=>window.requestIdleCallback(t,{timeout:500}):t=>setTimeout(t,100),r="wpjm-stat-";function c(t){if(!t)return!0;const e=parseInt(t,10);return!!Number.isNaN(e)||e<Date.now()}const a={stats:[],actions:[],init(t){a.stats=t,t.forEach((t=>{a.types[t.type]?.(t)})),a.doAction("page-load"),o((function(){for(let t=0;t<localStorage.length;t++){const e=localStorage.key(t);e.startsWith(r)&&c(localStorage.getItem(e))&&localStorage.removeItem(e)}}))},doAction(t){const e=a.actions[t];e&&a.log(e)},types:{action(t){const{action:e}=t;a.actions[e]||(a.actions[e]=[]),a.actions[e].push(t)},domEvent(t){const{args:e}=t;if(e.element&&e.event){const n=document.querySelector(e.element),o=t.action?()=>a.doAction(t.action):()=>a.log(t);n?.addEventListener(e.event,o)}},impression:async function(t){const{args:e}=t,{queueLogStat:n}=function(t){const e={};let n=[];function o(){const t=n.map((t=>(e[t.post_id]=!0,t)));n=[],window.WPJMStats.log(t)}const r=function(t,e){let n;return function(){for(var e=arguments.length,o=new Array(e),r=0;r<e;r++)o[r]=arguments[r];clearTimeout(n),n=setTimeout((()=>{t(...o)}),1e3)}}(o);return{queueLogStat:function(c){e[c]||(n.push({name:t,post_id:c}),n.length>=10?o():r())}}}(t.name),o=await(r=e.container,new Promise((function(t){let e=document.querySelector(r);if(e)return t(e);const n=new MutationObserver((function(){e=document.querySelector(r),e&&(n.disconnect(),t(e))}));n.observe(document.documentElement,{childList:!0,subtree:!0})})));var r;const c=function(t,e){const n={},o=new IntersectionObserver((t=>{t.forEach((t=>{if(t.isIntersecting&&t.intersectionRatio>.99){const r=t.target,c=function(t){return+t.className.match(/\bpost-(\d+)\b/)?.[1]||0}(r);c>0&&!n[c]&&(n[c]=!0,e(c)),o.unobserve(r)}}))}),{root:null,rootMargin:"0px",threshold:1});return o}(0,n);o.querySelectorAll(e.item).forEach((t=>c.observe(t))),function(t,e){let{selector:n,onAdded:o,onRemoved:r}=e;new MutationObserver((t=>{t.forEach((t=>{t.removedNodes.forEach((t=>{t.matches?.(n)&&r(t)})),t.addedNodes.forEach((t=>{t.matches?.(n)&&o(t)}))}))})).observe(t,{childList:!0})}(o,{selector:e.item,onAdded:t=>c.observe(t),onRemoved:t=>c.unobserve(t)})}},async log(t){t.name&&(t=[t]);const{ajaxUrl:e,ajaxNonce:n,postId:o}=window.job_manager_stats;if(!(t=function(t){return t.filter((t=>{if(function(t){return!!t.unique_key}(t)){if(function(t){const e=`${r}${t.unique_key}`;return!c(window.localStorage[e])}(t))return!1;!function(t){const e=`${r}${t.unique_key}`,n=Date.now()+864e5;window.localStorage[e]=n}(t)}return!0}))}(t)).length)return!1;const a=t.map((t=>["name","group","post_id"].reduce(((e,n)=>(t[n]&&(e[n]=t[n]),e)),{}))),s=new URLSearchParams({_ajax_nonce:n,post_id:o,action:"job_manager_log_stat",stats:JSON.stringify(a)});return fetch(e,{method:"POST",credentials:"same-origin",body:s})}};window.WPJMStats=a,n()((()=>{o((()=>{const{stats:t}=window.job_manager_stats;a.init(t)}))}))}();