//!wrt $BSPEC:{"icn":"apps/notron","cpr":"Copyright (C) Windows 96 Team 2023.","dsc":"AntiVirus for Windows 96","frn":"noTRON AV","ver":1,"ssy":"gui"}

const{Theme:Theme,MsgBoxSimple:MsgBoxSimple,MenuBar:MenuBar}=w96.ui,{WindowSystem:WindowSystem}=w96,{execCmd:execCmd}=w96.sys;class NoTronApplication extends WApplication{constructor(){super()}async main(e){super.main(e);const s=this.createWindow({taskbar:!0,icon:await Theme.getIconUrl("apps/notron","16x16"),bodyClass:"notron-app",title:"noTRON Anti-Virus: Professional Deluxe Edition",initialHeight:410,initialWidth:505,body:`<div class="appbar"></div>\n            <div class="container">\n                <div class="progress-box">\n                    <span>Operation in progress, please wait...</span>\n                </div>\n                <span class="htext">How may we help you today?</span> \n                <div class="nav-options">\n                    <div class="option item-scan">\n                        <div class="icon" style="background-image: url(${await Theme.getIconUrl("actions/search")});"></div>\n                        <div class="text">\n                            <span class="title">Perform Scan</span>\n                            <span class="desc">Check your system for malware, viruses, etc.</span>\n                        </div>\n                    </div>\n                    <div class="option close-active">\n                        <div class="icon" style="background-image: url(${await Theme.getIconUrl("devices/memory")});"></div>\n                        <div class="text">\n                            <span class="title">Close all active apps</span>\n                            <span class="desc">Free up computer memory by closing everything</span>\n                        </div>\n                    </div>\n                    <div class="option clear-boot">\n                        <div class="icon" style="background-image: url(${await Theme.getIconUrl("places/trash-full")});"></div>\n                        <div class="text">\n                            <span class="title">Clear boot items</span>\n                            <span class="desc">Permanently remove all boot scripts/stylesheets.</span>\n                        </div>\n                    </div>\n                    <div class="option del-win96">\n                        <div class="icon" style="background-image: url(${await Theme.getIconUrl("objects/skull")});"></div>\n                        <div class="text">\n                            <span class="title">Delete Windows 96</span>\n                            <span class="desc">Completely wipe your installation.</span>\n                        </div>\n                    </div>\n                </div>\n            </div>`},!0),t=s.getBodyContainer(),n=new MenuBar;n.addRoot("File",[{type:"normal",label:"Exit",onclick:()=>{this.terminate()}}]),n.addRoot("Help",[{type:"normal",label:"About",onclick:()=>{MsgBoxSimple.info("About noTRON AV PRO",'<span class="bold-noaa">noTRON AV Pro Deluxe Edition</span><br>Version 1.0<br>',"OK")}}]),t.querySelector(".appbar").replaceWith(n.getMenuDiv()),t.querySelector(".close-active").addEventListener("click",(()=>{this.setBusy(!0),WindowSystem.closeAllWindows(!1),this.setBusy(!1)})),t.querySelector(".clear-boot").addEventListener("click",(()=>{this.setBusy(!0),MsgBoxSimple.confirm("Are you sure you want to do this?",(async e=>{if(!e)return this.setBusy(!1);try{await FS.rmdir("c:/system/boot"),await FS.mkdir("c:/system/boot"),await FS.mkdir("c:/system/boot/apps"),MsgBoxSimple.info("Done","/system/boot has successfully been cleared.","Thanks")}catch(e){MsgBoxSimple.error("Error",e.toString(),"OK")}this.setBusy(!1)}))})),t.querySelector(".item-scan").addEventListener("click",(async()=>{execCmd("scanwiz",[])})),t.querySelector(".del-win96").addEventListener("click",(()=>{this.setBusy(!0),MsgBoxSimple.confirm("Are you sure? YOU WILL LOSE EVERYTHING WITHOUT RECOVERY.",(async e=>{if(!e)return this.setBusy(!1);try{for(let e of await FS.readdir("C:/"))try{0==await FS.filetype(e)?await FS.rm(e):await FS.rmdir(e)}catch(s){console.error("Failed to delete: "+e)}MsgBoxSimple.info("Done","System has been wiped, reboot will occur in 5 seconds.","Thanks"),setTimeout((()=>document.location.reload()),5e3)}catch(e){MsgBoxSimple.error("Error",e.toString(),"OK")}this.setBusy(!1)}))})),s.show(),this.appWnd=s}setBusy(e){e?this.appWnd.getBodyContainer().querySelector(".container").classList.add("busy"):this.appWnd.getBodyContainer().querySelector(".container").classList.remove("busy")}}

return await WApplication.execAsync(new NoTronApplication(), this.boxedEnv.args, this);