(()=>{"use strict";let e,t;const n=[],s={busy:!1,addItem:(e,i)=>{if(s.busy)return void n.push({fn:s.addItem,args:[e,i]});s.busy=!0,["error","info","success"].includes(i)||(i="info");const o=document.createElement("div");o.className=`item item-${i}`,o.innerHTML='<div class="item-inner"><div class="content"><p>__MSG__</p></div><div class="sep"></div><div class="dismiss"><span class="dashicons"></span></div></div>'.replace("__MSG__",e),t.append(o),o.style.left="auto";const a=new window.Animation(new window.KeyframeEffect(o,[{right:-o.clientWidth-30+"px"},{right:0}],{duration:500,easing:"ease-in-out",iterations:1}));a.onfinish=()=>{s.unlockPositions(),"error"!==i&&setTimeout(()=>s.dismiss(o),5e3),s.busy=!1,s.checkQueue()},a.play()},unlockPositions:()=>{t.querySelectorAll(".item").forEach(e=>{e.style="position:relative;left:0;top:0;margin:0;right:auto;"})},lockPositions:()=>{const e=[],n=t.querySelectorAll(".item");n.forEach(t=>{e.push(t.offsetTop)}),n.forEach((t,n)=>{t.style=`position:absolute;top:${e[n]}px;right:0;`})},checkQueue:()=>{if(!n.length)return;const e=n.shift();e.fn.apply(null,e.args)},dismiss:e=>{if(s.busy)return void n.push({fn:s.dismiss,args:[e]});if(s.busy=!0,!document.contains(e))return s.busy=!1,void s.checkQueue();const i=[...t.querySelectorAll(".item")].filter(t=>!t.isEqualNode(e)&&t.offsetTop>e.offsetTop);s.lockPositions();const o=new window.Animation(new window.KeyframeEffect(e,[{right:`-${e.querySelector(".item-inner").clientWidth+60}px`}],{duration:500,easing:"ease-in-out",iterations:1,fill:"forwards"}));o.onfinish=()=>{i.length?s.moveOtherItems(e.clientHeight,i,s.endOfDismiss,e):s.endOfDismiss(e)},o.play()},endOfDismiss:e=>{e.remove(),s.unlockPositions(),s.busy=!1,s.checkQueue()},moveOtherItems:(e,t,n,s)=>{let i=0;t.forEach((o,a)=>{((t,o)=>{const a=new window.Animation(new window.KeyframeEffect(t[o],[{marginTop:`-${e}px`}],{duration:200,easing:"ease-in-out",iterations:1}));a.onfinish=()=>{"function"==typeof n&&(i++,t.length===i&&n.call(null,s))},a.play()})(t,a)})}},i={addError:e=>{s.addItem(e,"error")},addInfo:e=>{s.addItem(e,"info")},addSuccess:e=>{s.addItem(e,"success")}};document.addEventListener("DOMContentLoaded",()=>{e=document.createElement("div"),e.id="advads-notifications",t=document.createElement("div"),e.append(t),document.getElementById("wpwrap").append(e),document.addEventListener("click",e=>{const t=e.target;t.closest("#advads-notifications")&&t.classList&&(t.classList.contains("dismiss")||t.parentNode.classList&&t.parentNode.classList.contains("dismiss"))&&s.dismiss(t.closest(".item"))}),"notifications"===new URLSearchParams(window.location.search).get("aa-debug")&&(()=>{const e=document.createElement("div");e.id="qwerty",e.style=`position:fixed;z-index:99999;bottom:20px;left:${document.getElementById("adminmenuwrap").clientWidth+22}px`;const t=document.createElement("div");t.style="height:0;overflow:hidden;";const n=document.createElement("div");n.style="width:640px;height:322px;background-color:#f0f0f0;border:1px solid #a6a6a6;padding:20px";const s=document.createElement("i");s.style="position:absolute;top:-35px;left:5px;cursor:pointer",s.className="dashicons dashicons-plus-alt2",s.id="show-tester";const i=document.createElement("p");i.style="background-color:#fbfbfb;padding:1em",i.innerHTML='<i class="dashicons dashicons-info"></i>Please don\'t use HTML tags other than links';const o=document.createElement("textarea");o.style="resize:none;width:100%;height:210px";const a=document.createElement("select");a.innerHTML='<option value="addError">Error</option><option value="addInfo">Info</option><option value="addSuccess">Success</option>';const d=document.createElement("label");d.innerText="Type: ",d.className="alignleft",d.append(a);const c=document.createElement("button");c.className="button button-primary alignright",c.innerText="Create notification",c.addEventListener("click",()=>r(o.value));const r=e=>{e.length&&window.advancedAds.notifications[a.value](e)};e.append(s),t.append(n),n.append(i),n.append(o),n.append(d),n.append(c),e.append(t);let l=!1;s.addEventListener("click",e=>{if(l)return;l=!0,e.target.classList.toggle("dashicons-plus-alt2"),e.target.classList.toggle("dashicons-minus");const n=new window.Animation(new window.KeyframeEffect(t,{height:0===t.clientHeight?"365px":0},{duration:250,easing:"ease-in-out",iterations:1,fill:"forwards"}));n.onfinish=()=>{l=!1},n.play()}),document.getElementById("wpwrap").append(e)})(),(()=>{const e=document.getElementById("message");e&&i.addSuccess(e.querySelector("p").innerHTML);const t=window.localStorage.getItem("advadsUpdateMessage");if(t){const e=JSON.parse(t);s.addItem(e.message,e.type),window.localStorage.removeItem("advadsUpdateMessage")}})(),(()=>{const e=document.getElementById("setting-error-settings_updated");e&&i.addSuccess(e.querySelector("p").innerHTML)})(),window.advancedAds.notifications=i})})();