import{isEmpty,humanSize}from"../../base/helpers.mjs";import{MenuController}from"../menu.mjs";import{MergeModelsFormView}from"../../forms/enfugue/models.mjs";class MergeModelsController extends MenuController{static modelMergeWindowWidth=400;static modelMergeWindowHeight=575;static menuName="Merge Models";static menuIcon="fa-solid fa-code-merge";static menuShortcut="e";async onClick(){this.showModelMerger()}async showModelMerger(){if(!isEmpty(this.modelMergerWindow))return void this.modelMergeWindow.focus();let e=new MergeModelsFormView(this.config);e.onSubmit((async o=>{e.clearError();try{let e=await this.model.post("/model-merge",null,null,o),r=`Wrote ${humanSize(e.size)} to ${e.path}`;this.notify("info","Models Successfully Merged",r),this.modelMergeWindow.remove(),this.modelMergeWindow=null}catch(o){e.setError(o),e.enable()}})),this.modelMergeWindow=await this.spawnWindow("Merge Models",e,this.constructor.modelMergeWindowWidth,this.constructor.modelMergeWindowHeight)}}export{MergeModelsController as MenuController};
