(()=>{(function(){if(window.aipkitHeaderButtonsInitialized)return;window.aipkitHeaderButtonsInitialized=!0;let a="aipkit-inline-actions",c="aipkitHeaderButtons",d=15e3,u=250;function f(){try{return Array.isArray(window[c])?window[c]:[]}catch{return[]}}function p(){let e=document.querySelector("."+a);if(e)return e;let t=document.querySelector(".wp-header-end, .wrap h1.wp-heading-inline");if(!t)return null;let n=document.querySelector(".wrap .page-title-action"),r=document.createElement("span");return r.className=a,n&&n.parentNode?n.parentNode.insertBefore(r,n.nextSibling):t.parentNode&&t.parentNode.insertBefore(r,t.nextSibling),r}function s(e){return!!document.getElementById(e)}function w(e){let t=document.createElement("a");return t.id=e.id,t.className="page-title-action",t.href=e.href?e.href:"javascript:void(0)",t.textContent=e.label||e.id,e.title&&(t.title=e.title),e.dataset&&Object.keys(e.dataset).forEach(n=>{t.dataset[n]=e.dataset[n]}),e.onClick&&t.addEventListener("click",function(n){e.href===void 0&&n.preventDefault();try{new Function(e.onClick).call(this,n)}catch(r){console.error(r)}}),t}function o(){let e=f();if(!e.length)return!1;let t=p();if(!t)return!1;let n=0;return e.forEach(i=>{if(!i.id||s(i.id))return;let m=w(i);t.appendChild(m),n++}),e.every(i=>i.id&&s(i.id))}function l(){o();let e=Date.now(),t=document.querySelector("#wpbody-content")||document.querySelector(".wrap")||document.body,n=new MutationObserver(()=>{(o()||Date.now()-e>d)&&n.disconnect()});t&&n.observe(t,{childList:!0,subtree:!0});let r=setInterval(()=>{(o()||Date.now()-e>d)&&clearInterval(r)},u);window.addEventListener("load",o)}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",l):l()})();})();
