(()=>{var e={};(()=>{"use strict";function e(e){"undefined"!=typeof document&&("complete"!==document.readyState&&"interactive"!==document.readyState?document.addEventListener("DOMContentLoaded",e):e())}let t=!1;const n=[],o=()=>{t||(t=!0,n.forEach(e=>e()))},i=()=>{if(!t)return null!==document.body?o():void setTimeout(i,100)};i(),e(o);let d=!1;const a=new MutationObserver(function(){for(const[e,t]of s){const n=document.querySelector(e);n&&(t.forEach(t=>t(n,c(e))),s.delete(e))}0===s.size&&(a.disconnect(),d=!1)}),c=e=>t=>{const n=document.createElement("style");n.textContent=`${e} {\n${r(t)}\n}`,document.head?.appendChild(n)},r=(e="")=>e.replace(/^\s*/,"").replace(/\s*$/,""),s=new Map;let p,l=!1;if((u=window)&&"object"==typeof u&&"nabQuickActionSettings"in u)p=window.nabQuickActionSettings,e(()=>{const e=document.querySelector("#wp-admin-bar-nelio-ab-testing-experiment-create a"),t=document.querySelector("#wp-admin-bar-nelio-ab-testing-heatmap-create a");e&&e.addEventListener("click",m),t&&t.addEventListener("click",y)});else{const e=document.getElementById("wp-admin-bar-nelio-ab-testing");e?.parentNode?.removeChild(e)}var u;function m(e){e.preventDefault();const{postId:t,postType:n,experimentType:o,root:i,nonce:d}=p??{};t&&n&&o&&i&&d&&(l||(l=!0,fetch(`${i}nab/v1/experiment`,{headers:{"content-type":"application/json","x-wp-nonce":d},method:"POST",body:JSON.stringify({type:o,addTestedPostScopeRule:!0})}).then(e=>e.json()).then(e=>{fetch(`${i}nab/v1/experiment/${e.id}`,{headers:{"content-type":"application/json","x-wp-nonce":d},method:"PUT",body:JSON.stringify({...e,alternatives:[{id:"control",attributes:{postId:t,postType:n}}]})}).then(e=>e.json()).then(e=>{window.location.href=e.links.edit})})))}function y(e){if(e.preventDefault(),l)return;l=!0;const{postId:t,postType:n,currentUrl:o,root:i,nonce:d}=p??{};i&&d&&fetch(`${i}nab/v1/experiment`,{headers:{"content-type":"application/json","x-wp-nonce":d},method:"POST",body:JSON.stringify({type:"nab/heatmap",addTestedPostScopeRule:!1})}).then(e=>e.json()).then(e=>{const a={id:e.id,type:"nab/heatmap",trackingMode:t?"post":"url",trackedPostId:t||void 0,trackedPostType:t?n:void 0,trackedUrl:t?void 0:o};fetch(`${i}nab/v1/experiment/${a.id}`,{headers:{"content-type":"application/json","x-wp-nonce":d},method:"PUT",body:JSON.stringify(a)}).then(e=>e.json()).then(e=>{window.location.href=e.links.edit})})}})();var t=nab="undefined"==typeof nab?{}:nab;for(var n in e)t[n]=e[n];e.__esModule&&Object.defineProperty(t,"__esModule",{value:!0})})();