import{isEmpty}from"../../base/helpers.mjs";import{Controller}from"../base.mjs";import{IPAdapterFormView}from"../../forms/enfugue/ip-adapter.mjs";class IPAdapterController extends Controller{getState(e=!0){return{ip:this.ipAdapterForm.values}}getDefaultState(){return{ip:{ipAdapterModel:"default"}}}setState(e){isEmpty(e.ip)||this.ipAdapterForm.setValues(e.ip).then((()=>this.ipAdapterForm.submit()))}async initialize(){this.ipAdapterForm=new IPAdapterFormView(this.config),this.ipAdapterForm.hide(),this.ipAdapterForm.onSubmit((async e=>{this.engine.ipAdapterModel=e.ipAdapterModel})),this.application.sidebar.addChild(this.ipAdapterForm),this.subscribe("layersChanged",(e=>{e.reduce(((e,t)=>e||t.imagePrompt),!1)?this.ipAdapterForm.show():this.ipAdapterForm.hide()}))}}export{IPAdapterController as SidebarController};
