(()=>{var c=`${window.getGenie.config.assetsUrl}dist/admin/images/genie-chat.svg`;(()=>{let e=history.pushState;history.pushState=function(){let a=e.apply(this,arguments);return window.dispatchEvent(new Event("pushstate")),window.dispatchEvent(new Event("locationchange")),a};let t=history.replaceState;history.replaceState=function(){let a=t.apply(this,arguments);return window.dispatchEvent(new Event("replacestate")),window.dispatchEvent(new Event("locationchange")),a},window.addEventListener("popstate",()=>{window.dispatchEvent(new Event("locationchange"))})})();var i,o=0;window.addEventListener("locationchange",function(){if(location.href.match(/email\/templates\/.*/)||location.href.match(/email\/campaigns\/.*/)){if(i!==location.href){i=location.href;let e=setInterval(()=>{o+=1;let t=document.querySelector(".fluentcrm_visual_editor");t&&(l(t),clearInterval(e)),o>40&&clearInterval(e)},500)}}else i=location.href});var r=()=>{let e=window.wp.data.select("getgenie").sidebar(),t=!e.open,n=window.wp.data.dispatch("getgenie").setSidebar;n({open:t,component:"GenieChat",currentTemplate:"genieChat",analyzeKeyword:{...e.analyzeKeyword,open:!1},generatedOutlines:{...e.generatedOutlines,open:!1},chatPersonality:"email-copywriter"})};function s(){let e=document.createElement("button");return e.type="button",e.className="genie-chat-opener-btn",e.innerHTML=`<img src="${c}" alt="genie-chat" width="25"><span>Write Email with AI</span>`,e.addEventListener("click",r),e}function l(e){let t=e.querySelector(".fluentcrm-actions");if(t){t.id="getgenie-fluentcrm-btn";let n=s();t.insertBefore(n,t.firstChild)}}})();
