!function(){let e=JSON.parse(iawmlfArchivedLinks.links);const t=iawmlfArchivedLinks.linkDelayInDays,r={nonce:iawmlfArchivedLinks.linkCheckNonce,url:iawmlfArchivedLinks.restUrl,fixerOption:iawmlfArchivedLinks.fixerOption},n=[];let i=[];const l=()=>(document.querySelectorAll(".__iawmlf-post-loop-links[data-iawmlf-links]").forEach((t=>{try{null!=(r=JSON.parse(t.getAttribute("data-iawmlf-links")))&&0!==r.length&&r.forEach((t=>{e.some((e=>e.id===t.id))||e.push(t)}))}catch(e){}var r})),e),a=new IntersectionObserver(((t,r)=>{e=l(),t.forEach((e=>{e.isIntersecting&&s(e.target.href)}))}),{root:null,rootMargin:"0px",threshold:0}),c=()=>({width:window.innerWidth||document.documentElement.clientWidth,height:window.innerHeight||document.documentElement.clientHeight}),o=(c().width,c().height,e=>null===e||""===e||"/"!==e.slice(-1)?e:e.replace(/\/$/,"")),h=e=>{const t=o(e.href);for(let n=0;n<i.length;n++){let l=i[n];o(l.href)===t&&(l.setAttribute("data-iawmlf-archived-url",e.archived_href),l.setAttribute("data-iawmlf-current-url",t),l.setAttribute("data-iawmlf-archived-broken",e.broken),null!==e.last_checked&&null!==e.last_checked.date&&l.setAttribute("data-iawmlf-archived-last-checked",e.last_checked.date),e.broken&&"do_nothing"!==r.fixerOption&&(l.classList.add("iawmlf-broken-link"),l.href=""!==e.archived_href?e.archived_href:t))}},s=r=>{if((e=>n.includes(e))(r))return;(e=>{n.push(e)})(r);const i=(t=>{for(let r=0;r<e.length;r++){let n=e[r];if(o(n.href)===o(t))return n}return null})(r);null!==i&&null!==i.archived_href&&""!==i.archived_href&&(null===i.last_checked||(e=>{const t=new Date-new Date(e);return Math.ceil(t/864e5)})(i.last_checked.date)>t?d(r).then((e=>{e&&e.link?h(e.link):h(i)})):h(i))},d=async e=>{const t=r,n=await fetch(t.url,{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":t.nonce},body:JSON.stringify({link:e})}).then((e=>e.json())).then((e=>e)).catch((e=>{console.error("Error:",e)}));return await n};(()=>{const t=document.querySelectorAll("a");t.forEach((e=>{a.observe(e)})),i=t,new MutationObserver((t=>{for(const r of t)"childList"===r.type&&r.addedNodes.forEach((t=>{if(t.nodeType===Node.ELEMENT_NODE){e=l(),"A"===t.tagName&&a.observe(t);const r=t.querySelectorAll?t.querySelectorAll("a"):[];r.forEach((e=>{a.observe(e)})),i=[...i,...r]}}))})).observe(document.body,{childList:!0,subtree:!0})})()}();