import{isEmpty}from"../../base/helpers.mjs";import{Controller}from"../base.mjs";import{PromptsFormView}from"../../forms/enfugue/prompts.mjs";class PromptsController extends Controller{getState(t=!0){return{prompts:this.promptsForm.values}}getDefaultState(){return{prompts:{prompt:null,negativePrompt:null,usePromptTravel:!1}}}setState(t){this.promptsForm.setValues(t.prompts).then((()=>this.promptsForm.submit()))}async initialize(){let t=!1;this.promptsForm=new PromptsFormView(this.config),this.promptsForm.onSubmit((async r=>{this.engine.prompt=r.prompt,this.engine.negativePrompt=r.negativePrompt,r.usePromptTravel&&t?(this.publish("promptTravelEnabled"),this.promptsForm.addClass("use-prompt-travel")):(this.publish("promptTravelDisabled"),this.promptsForm.removeClass("use-prompt-travel"))})),this.promptsForm.onShortcutSubmit((()=>{this.application.publish("tryInvoke")})),this.application.sidebar.addChild(this.promptsForm),this.subscribe("engineAnimationFramesChange",(r=>{t=!isEmpty(r)&&r>0,t?(this.promptsForm.addClass("show-prompt-travel"),this.promptsForm.values.usePromptTravel?(this.publish("promptTravelEnabled"),this.promptsForm.addClass("use-prompt-travel")):(this.publish("promptTravelDisabled"),this.promptsForm.removeClass("use-prompt-travel"))):(this.promptsForm.removeClass("show-prompt-travel"),this.promptsForm.removeClass("use-prompt-travel"),this.publish("promptTravelDisabled"))}))}}export{PromptsController as SidebarController};
