import{isEmpty}from"../../base/helpers.mjs";import{Controller}from"../base.mjs";import{DenoisingFormView}from"../../forms/enfugue/denoising.mjs";class DenoisingController extends Controller{getState(i=!0){return{denoising:this.denoisingForm.values}}getDefaultState(){return{denoising:{strength:1}}}setState(i){isEmpty(i.denoising)||this.denoisingForm.setValues(i.denoising).then((()=>this.denoisingForm.submit()))}async initialize(){this.denoisingForm=new DenoisingFormView(this.config),this.denoisingForm.hide(),this.denoisingForm.onSubmit((async i=>{this.engine.strength=i.strength})),this.application.sidebar.addChild(this.denoisingForm);let i=!1,e=!1,s=()=>{i||e?this.denoisingForm.show():this.denoisingForm.hide()};this.subscribe("layersChanged",(e=>{i=e.reduce(((i,e)=>i||"invisible"!==e.visibility),!1),s()})),this.subscribe("inpaintEnabled",(()=>{e=!0,s()})),this.subscribe("inpaintDisabled",(()=>{e=!1,s()}))}}export{DenoisingController as SidebarController};
