import{Shadowbox}from"../common/shadowbox.mjs";import{isEmpty,titleCase}from"../base/helpers.mjs";import{ElementBuilder}from"../base/builder.mjs";import{Index as ToolIndex}from"./tools/index.autogenerated.mjs";const E=new ElementBuilder;class Controller{static Directory;constructor(o){this.application=o,this.initialize()}async initialize(){this.menu={file:await this.application.menu.addCategory("File"),edit:await this.application.menu.addCategory("Edit"),tools:await this.application.menu.addCategory("Tools")},this.initializeTools()}async initializeTools(){let o=[];for(let t of ToolIndex){let i=(await import(`./tools/${t}`)).ToolController;isEmpty(i)?console.warn("tool module at",t,"does not provide a ToolController export."):isEmpty(i.toolName)||o.push(i)}o.sort(((o,t)=>o.toolName>t.toolName?-1:o.toolName<t.toolName?1:0));for(let t of o){let o=new t(this);await o.initialize()}}async popState(o){let t=o.state,i=t.controller,e=t.viewController,a=t.viewControllerScope,l=this.getStateTitle(t);this.activateController(i,e,a,!1),document.title=l}get windows(){return this.application.windows}spawnWindow(){return this.application.windows.spawnWindow.apply(this.application.windows,Array.from(arguments))}notify(o,t,i){return this.application.notifications.push(o,t,i)}}export{Controller};
