//!wrt $BSPEC:{"icn":"apps/wm","cpr":"Copyright (C) Windows 96 Team 2021.","dsc":"Window Manager Settings","frn":"WM Setting Mgr","ver":1,"ssy":"gui"}

const{Theme:Theme,DialogCreator:DialogCreator}=w96.ui,{CheckBox:CheckBox,GroupBox:GroupBox,TabControl:TabControl}=w96.ui.components,{WindowSystem:WindowSystem,sysConf:SCM}=w96;class WMSMApp extends WApplication{constructor(){super(),this.wmConfig=WindowSystem.getConfig()}async syncConfig(){await SCM.setAndSync("System/WndMan",this.wmConfig)}async main(e){super.main(e),this.wmConfig={...WindowSystem.getConfig()};const n=this.createWindow({title:"96WM Settings Manager",initialWidth:370,initialHeight:443,resizable:!1,controlBoxStyle:"WS_CBX_CLOSE",bodyClass:"wmsm-app",icon:await Theme.getIconUrl("apps/wm","16x16"),body:'<div class="tabc"></div>\n            <div class="buttons">\n                <button class="w96-button apply" disabled>Apply</button>\n                <button class="w96-button cancel">Cancel</button>\n                <button class="w96-button ok">OK</button>\n            </div>',center:!0,taskbar:!0,mobResize:!0}),t=n.getBodyContainer();t.classList.add("applet-base");const i=new TabControl;i.openPage(i.addPage("Basic",(async e=>{e.style.padding="10px",e.style.boxSizing="border-box",e.innerHTML=`\n                <div class="icon-box">\n                    <div class="icon" style="background-image: url(${await Theme.getIconUrl("apps/wm")});"></div>\n                    <div class="text">\n                        Windows 96 includes a reasonable Window Manager (WM) which can be customized with this utility.<br><br>\n                        <span class="bold-noaa">Important! </span>Themes can override some of these settings!\n                    </div>\n                </div>\n                <div class="grpbx1"></div>\n                <div class="grpbx2"></div>\n            `;const n=new GroupBox({title:"Window Dragging",body:""}),t=new GroupBox({title:"Appearence",body:""}),i=n.getElement().querySelector(".content"),o=t.getElement().querySelector(".content");i.appendChild(new CheckBox({label:"Hide window contents on drag",checked:this.wmConfig.dragging.hideWindow,onchange:e=>this.wmConfig.dragging.hideWindow=e.checked,displayAsBlock:!0}).getElement()),i.appendChild(new CheckBox({label:"Allow window snapping on edge drag",checked:this.wmConfig.features.windowSnap,onchange:e=>this.wmConfig.features.windowSnap=e.checked,displayAsBlock:!0}).getElement()),o.appendChild(new CheckBox({label:"Enable ClearFix for sharper pixel fonts on the titlebar (experimental)",checked:this.wmConfig.features.enableClearFix,onchange:async e=>{for(var n in this.wmConfig.features.enableClearFix=e.checked,w96.WindowSystem.windows)(n=w96.WindowSystem.windows[n])&&(n.setWindowIcon(n.windowIcon),n.setTitle(n.title))},displayAsBlock:!0}).getElement()),o.appendChild(new CheckBox({label:"Use 12 hour time instead of 24 hour time in the clock",checked:this.wmConfig.features.use12hTime,onchange:async e=>{this.wmConfig.features.use12hTime=e.checked,w96.wmem.clockUpdate()},displayAsBlock:!0}).getElement()),e.querySelector(".grpbx1").replaceWith(n.getElement()),e.querySelector(".grpbx2").replaceWith(t.getElement())}))),i.addPage("Performance",(async e=>{e.style.padding="10px",e.style.boxSizing="border-box",e.innerHTML=`\n                <div class="icon-box">\n                    <div class="icon" style="background-image: url(${await Theme.getIconUrl("devices/card")});"></div>\n                    <div class="text">\n                        You can modify the Window Manager to match your system performance below.\n                    </div>\n                </div>\n                <div class="grpbx1"></div>\n            `;const n=new GroupBox({title:"Graphical Tweaks",body:""}),t=n.getElement().querySelector(".content");t.appendChild(new CheckBox({label:"Disable animations",checked:this.wmConfig.features.disableAllAnimations,onchange:e=>this.wmConfig.features.disableAllAnimations=e.checked,displayAsBlock:!0}).getElement()),t.appendChild(new CheckBox({label:"Use simple window dragging outline",checked:this.wmConfig.dragging.simpleDragBox,onchange:e=>this.wmConfig.dragging.simpleDragBox=e.checked,displayAsBlock:!0}).getElement()),e.querySelector(".grpbx1").replaceWith(n.getElement())})),t.querySelector(".tabc").replaceWith(i.getElement()),t.querySelector("button.cancel").addEventListener("click",(()=>n.close())),t.querySelector("button.ok").addEventListener("click",(()=>{this.applySettings(),n.close()})),n.show(),SCM.get("Software/WMSM/Started")||(DialogCreator.create({title:"WMSM",icon:"info",body:"This tool allows you to configure the window manager to your liking.<br><br>Please note that you can revert to the default settings by removing c:/system/config/wm.json"}),await SCM.setAndSync("Software/WMSM/Started",!0))}async applySettings(){await this.syncConfig(),WindowSystem.setConfig(this.wmConfig)}}

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