"undefined"!=typeof document&&document.addEventListener("click",function(t){const e=t.target;if(!(e instanceof Element))return;const n=e.closest(".acrossai-mcp-adapter-notice .notice-dismiss");if(!n)return;const o=n.closest(".acrossai-mcp-adapter-notice");if(!o)return;const a=o.dataset.nonce;if(!a)return;if("undefined"==typeof ajaxurl)return;const s=new URLSearchParams;s.set("action","acrossai_mcp_dismiss_adapter_notice"),s.set("_ajax_nonce",a),fetch(ajaxurl,{method:"POST",credentials:"same-origin",body:s}).catch(function(){})}),"undefined"!=typeof document&&document.addEventListener("click",function(t){const e=t.target;if(!(e instanceof Element))return;const n=e.closest("[data-acrossai-confirm]");if(!n)return;const o=n.getAttribute("data-acrossai-confirm");o&&(window.confirm(o)||(t.preventDefault(),t.stopPropagation()))},!0),function(){function t(t,e,n){if(!t)return;t.textContent="";const o=document.createElement("span");o.className="notice notice-"+("success"===n?"success":"error")+" inline",o.style.display="inline-block",o.style.marginLeft="1em",o.style.padding="2px 8px",o.textContent=e,t.appendChild(o)}"undefined"!=typeof document&&document.addEventListener("click",function(e){const n=e.target;if(!(n instanceof Element))return;const o=n.closest(".generate-app-password");if(!o||o.disabled)return;e.preventDefault();const a=o.getAttribute("data-endpoint"),s=o.getAttribute("data-nonce"),r=parseInt(o.getAttribute("data-server-id")||"0",10),c=o.getAttribute("data-client-slug")||"";if(!a||!s)return;const i=o.parentNode?o.parentNode.querySelector(".acrossai-generate-app-password-status"):null,d=o.textContent;o.disabled=!0,o.textContent="Generating…",fetch(a,{method:"POST",credentials:"same-origin",headers:{"Content-Type":"application/json","X-WP-Nonce":s},body:JSON.stringify({server_id:r})}).then(t=>t.json().then(e=>({ok:t.ok,body:e}))).then(({ok:e,body:n})=>{if(!e||!n||!n.password){const e=n&&(n.message||n.data?.message)||"Failed to generate password.";return t(i,e,"error"),void(o.textContent=d)}const a=function(t,e){const n=document.getElementById(t);if(!n||!n.value)return!1;try{const t=JSON.parse(n.value);let o=!1;return Object.values(t).forEach(t=>{t&&"object"==typeof t&&Object.values(t).forEach(t=>{t&&t.env&&"object"==typeof t.env&&("(paste generated password here)"!==t.env.WP_API_PASSWORD&&""!==t.env.WP_API_PASSWORD||(t.env.WP_API_PASSWORD=e,o=!0))})}),o&&(n.value=JSON.stringify(t,null,2)),o}catch(t){return!1}}("acrossai-mcp-"+c+"-config-"+r,n.password)?"Password: "+n.password+" (also injected into the config below — shown only once).":"Password: "+n.password+" (shown only once — copy it now).";t(i,a,"success"),o.textContent="Regenerate Application Password",o.classList.add("has-password")}).catch(e=>{t(i,"Network error: "+e.message,"error"),o.textContent=d}).finally(()=>{o.disabled=!1})})}(),function(){function t(t){const e=document.createElement("textarea");e.value=t,e.style.position="fixed",e.style.top="0",e.style.left="0",e.style.width="2em",e.style.height="2em",e.style.opacity="0",document.body.appendChild(e),e.focus(),e.select();let n=!1;try{n=document.execCommand("copy")}catch(t){n=!1}return document.body.removeChild(e),n}function e(t){t.dataset.originalLabel||(t.dataset.originalLabel=t.textContent||""),t.textContent="✓ Copied!",t.disabled=!0,setTimeout(function(){t.textContent=t.dataset.originalLabel,t.disabled=!1},2e3)}"undefined"!=typeof document&&document.addEventListener("click",function(n){const o=n.target;if(!(o instanceof Element))return;const a=o.closest(".copy-to-clipboard, [data-copy-target]");if(!a)return;const s=function(t){const e=t.getAttribute("data-field");if(e)return document.getElementById(e);const n=t.getAttribute("data-copy-target");return n?document.querySelector(n):null}(a);if(!s)return;const r=function(t){return t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement?t.value:t.textContent||""}(s);r&&(n.preventDefault(),navigator.clipboard&&"function"==typeof navigator.clipboard.writeText?navigator.clipboard.writeText(r).then(function(){e(a)},function(){t(r)&&e(a)}):t(r)&&e(a))})}();