var url="assets/json/",allmaillist="";const loader=document.querySelector("#elmLoader");var getJSON=function(e,t){var a=new XMLHttpRequest;a.open("GET",url+e,!0),a.responseType="json",a.onload=function(){var e=a.status;200===e?(document.getElementById("elmLoader").innerHTML="",t(null,a.response)):t(e,a.response)},a.send()};function loadMailData(e){document.querySelector('#mail-filter-navlist button[data-bs-target="#pills-primary"]').click(),document.querySelector("#mail-list").innerHTML="",Array.from(e).forEach(function(e,t){var a=e.readed?"":"unread",l=e.starred?"active":"",c=e.counted?"("+e.counted+")":"";document.querySelector("#mail-list").innerHTML+='
  • '+e.name+" "+c+'
    '+e.title+''+e.description+'
    '+e.date+"
  • ",favouriteBtn(),emailDetailShow(),emailDetailChange(),checkBoxAll()})}function loadSocialMailData(e){Array.from(e).forEach(function(e,t){var a=e.readed?"":"unread",l=e.starred?"active":"",c=e.counted?"("+e.counted+")":"";document.getElementById("social-mail-list").innerHTML+='
  • '+e.name+" "+c+'
    '+e.title+''+e.description+'
    '+e.date+"
  • ",emailDetailShow(),emailDetailChange(),checkBoxAll()})}function loadPromotionsMailData(e){Array.from(e).forEach(function(e,t){var a=e.readed?"":"unread",l=e.starred?"active":"",c=e.counted?"("+e.counted+")":"";document.getElementById("promotions-mail-list").innerHTML+='
  • '+e.name+" "+c+'
    '+e.title+''+e.description+'
    '+e.date+"
  • ",emailDetailShow(),emailDetailChange(),checkBoxAll()})}function favouriteBtn(){Array.from(document.querySelectorAll(".favourite-btn")).forEach(function(e){e.addEventListener("click",function(){e.classList.contains("active")?e.classList.remove("active"):e.classList.add("active")})})}function emailDetailShow(){var a=document.getElementsByTagName("body")[0],t=(Array.from(document.querySelectorAll(".message-list a")).forEach(function(e){e.addEventListener("click",function(t){a.classList.add("email-detail-show"),Array.from(document.querySelectorAll(".message-list li.unread")).forEach(function(e){e.classList.contains("unread")&&t.target.closest("li").classList.remove("unread")})})}),Array.from(document.querySelectorAll(".close-btn-email")).forEach(function(e){e.addEventListener("click",function(){a.classList.remove("email-detail-show")})}),!1),l=document.getElementsByClassName("email-menu-sidebar");Array.from(document.querySelectorAll(".email-menu-btn")).forEach(function(e){e.addEventListener("click",function(){Array.from(l).forEach(function(e){e.classList.add("menubar-show"),t=!0})})}),window.addEventListener("click",function(e){document.querySelector(".email-menu-sidebar").classList.contains("menubar-show")&&(t||document.querySelector(".email-menu-sidebar").classList.remove("menubar-show"),t=!1)}),favouriteBtn()}function checkBoxAll(){Array.from(document.querySelectorAll(".checkbox-wrapper-mail input")).forEach(function(e){e.addEventListener("click",function(e){1==e.target.checked?e.target.closest("li").classList.add("active"):e.target.closest("li").classList.remove("active")})});var e=document.querySelectorAll(".tab-pane.show .checkbox-wrapper-mail input");function a(){var e=document.querySelectorAll(".tab-pane.show .checkbox-wrapper-mail input"),t=document.querySelectorAll(".tab-pane.show .checkbox-wrapper-mail input:checked").length;Array.from(e).forEach(function(e){e.checked=!0,e.parentNode.parentNode.parentNode.classList.add("active")}),document.getElementById("email-topbar-actions").style.display=0e.labeltype===t)):(t=l.querySelector(".mail-list-link").innerHTML,document.getElementById("mail-list").innerHTML="",e="All"!=t?allmaillist.filter(e=>e.tabtype===t):allmaillist,document.getElementById("mail-filter-navlist").style.display="All"!=t&&"Inbox"!=t?"none":"block"),loadMailData(e),favouriteBtn()})}),favouriteBtn(),ClassicEditor.create(document.querySelector("#email-editor")).then(function(e){e.ui.view.editable.element.style.height="200px"}).catch(function(e){console.error(e)});var currentChatId="users-chat";function scrollToBottom(e){setTimeout(()=>{new SimpleBar(document.getElementById("chat-conversation")).getScrollElement().scrollTop=document.getElementById("users-conversation").scrollHeight},100)}function removeItems(){document.getElementById("removeItemModal").addEventListener("show.bs.modal",function(e){document.getElementById("delete-record").addEventListener("click",function(){Array.from(document.querySelectorAll(".message-list li")).forEach(function(e){var t,a;e.classList.contains("active")&&(t=e.querySelector(".form-check-input").value,a=t,allmaillist=allmaillist.filter(function(e){return e.id!=a}),e.remove())}),document.getElementById("btn-close").click(),document.getElementById("email-topbar-actions")&&(document.getElementById("email-topbar-actions").style.display="none"),checkall.indeterminate=!1,checkall.checked=!1})})}function removeSingleItem(){var a;document.querySelectorAll(".remove-mail").forEach(function(t){t.addEventListener("click",function(e){a=t.getAttribute("data-remove-id"),document.getElementById("delete-record").addEventListener("click",function(){var t;t=a,loadMailData(allmaillist=allmaillist.filter(function(e){return e.id!=t})),document.getElementById("close-btn-email").click()})})})}scrollToBottom(currentChatId),removeItems(),removeSingleItem();var markAllReadBtn=document.getElementById("mark-all-read"),dummyUserImage=(markAllReadBtn.addEventListener("click",function(e){0===document.querySelectorAll(".message-list li.unread").length&&(document.getElementById("unreadConversations").style.display="block",setTimeout(function(){document.getElementById("unreadConversations").style.display="none"},1e3)),Array.from(document.querySelectorAll(".message-list li.unread")).forEach(function(e){e.classList.contains("unread")&&e.classList.remove("unread")})}),"assets/images/users/user-dummy-img.jpg"),mailChatDetailElm=!1;function emailDetailChange(){Array.from(document.querySelectorAll(".message-list li")).forEach(function(c){c.addEventListener("click",function(){var e=c.querySelector(".checkbox-wrapper-mail .form-check-input").value,e=(document.querySelector(".remove-mail").setAttribute("data-remove-id",e),c.querySelector(".subject-title").innerHTML),a=(document.querySelector(".email-subject-title").innerHTML=e,c.querySelector(".title-name").innerHTML),t=(Array.from(document.querySelectorAll(".accordion-item.left")).forEach(function(e){e.querySelector(".email-user-name").innerHTML=a;var t=c.querySelector(".mail-userimg").value;e.querySelector("img").setAttribute("src",t)}),document.querySelector(".user-name-text").innerHTML),l=document.querySelector(".header-profile-user").getAttribute("src");Array.from(document.querySelectorAll(".accordion-item.right")).forEach(function(e){e.querySelector(".email-user-name-right").innerHTML=t,e.querySelector("img").setAttribute("src",l)})})})}document.querySelectorAll(".email-chat-list a").forEach(function(l){var e,t;l.classList.contains("active")&&(document.getElementById("emailchat-detailElem").style.display="block",e=document.querySelector(".email-chat-list a.active").querySelector(".chatlist-user-name").innerHTML,t=document.querySelector(".email-chat-list a.active").querySelector(".chatlist-user-image img").getAttribute("src"),document.querySelector(".email-chat-detail .profile-username").innerHTML=e,document.getElementById("users-conversation").querySelectorAll(".left .chat-avatar").forEach(function(e){t?e.querySelector("img").setAttribute("src",t):e.querySelector("img").setAttribute("src",dummyUserImage)})),l.addEventListener("click",function(e){document.getElementById("emailchat-detailElem").style.display="block",mailChatDetailElm=!0;var t=document.querySelector(".email-chat-list a.active"),t=(t&&t.classList.remove("active"),this.classList.add("active"),scrollToBottom("users-chat"),l.querySelector(".chatlist-user-name").innerHTML),a=l.querySelector(".chatlist-user-image img").getAttribute("src"),t=(document.querySelector(".email-chat-detail .profile-username").innerHTML=t,document.getElementById("users-conversation"));Array.from(t.querySelectorAll(".left .chat-avatar")).forEach(function(e){a?e.querySelector("img").setAttribute("src",a):e.querySelector("img").setAttribute("src",dummyUserImage)})})}),document.getElementById("emailchat-btn-close").addEventListener("click",function(){document.getElementById("emailchat-detailElem").style.display="none",mailChatDetailElm=!1,document.querySelector(".email-chat-list a.active").classList.remove("active")});const triggerTabList=document.querySelectorAll("#mail-filter-navlist .nav-tabs button");function resizeEvent(){var e;document.documentElement.clientWidth<767&&((e=document.querySelector(".email-chat-list a.active"))&&e.classList.remove("active"),document.getElementById("emailchat-detailElem").style.display="none")}triggerTabList.forEach(e=>{const t=new bootstrap.Tab(e);e.addEventListener("click",e=>{e.preventDefault();document.querySelector(".tab-content .tab-pane.show");t.show()})}),resizeEvent(),window.onresize=resizeEvent;