import{isEmpty}from"../../base/helpers.mjs";import{Controller}from"../base.mjs";import{TweaksFormView}from"../../forms/enfugue/tweaks.mjs";class TweaksController extends Controller{getState(e=!0){return{tweaks:this.tweaksForm.values}}setState(e){isEmpty(e.tweaks)||this.tweaksForm.setValues(e.tweaks).then((()=>this.tweaksForm.submit()))}getDefaultState(){return{tweaks:{guidanceScale:this.config.model.invocation.guidanceScale,inferenceSteps:this.config.model.invocation.inferenceSteps,scheduler:null}}}async initialize(){this.tweaksForm=new TweaksFormView(this.config),this.tweaksForm.onSubmit((async e=>{this.engine.guidanceScale=e.guidanceScale,this.engine.inferenceSteps=e.inferenceSteps,this.engine.scheduler=e.scheduler})),this.subscribe("modelPickerChange",(e=>{if(!isEmpty(e)){let s=e.defaultConfiguration,t={};isEmpty(s.guidance_scale)||(t.guidanceScale=s.guidance_scale),isEmpty(s.inference_steps)||(t.inferenceSteps=s.inference_steps),isEmpty(e.scheduler)||(t.scheduler=e.scheduler[0].name),isEmpty(t)||this.tweaksForm.setValues(t)}})),this.application.sidebar.addChild(this.tweaksForm)}}export{TweaksController as SidebarController};
