import{b as a,i as m}from"./useflows-BpG3C9m1.js";import{s as r,e as s}from"./main-few-lands-burn.js";import{s as l}from"./machine.-BRuqPpdF.js";import"./mutative-C6xjlr6O.js";import"./lodash-YpNkAOPN.js";const f=async()=>r("wpforms/get-forms",void 0,void 0,"GET"),i=async t=>{t.setComponent("form-id",o=>{o.loading=!0});const{data:e,status:n}=await f();if(n==="error"){t.setComponent("form-id",o=>{t.util.isSelectComponent(o)&&(o.status=n,o.loading=!1,o.invalidMessage=e)}),console.error("Failed to fetch form");return}t.setComponent("form-id",o=>{t.util.isSelectComponent(o)&&(o.options=e,o.loading=!1,o.status=void 0)})},F=a(({helpers:t})=>({actions:{ON_MACHINE_LOAD:async({$:e})=>{l(e,[{db:"formId",id:"form-id"}]),await i(e)},REFETCH_FORMS:async({$:e})=>i(e),SELECT_FORM:async({$:e,e:n})=>{e.setThisComponent(o=>{o.value=n}),e.setDb({formId:n})}},states:{components:[{componentName:t.componentName.select,fieldType:"config",id:"form-id",label:s("Forms"),onChange:"SELECT_FORM",onRefetch:"REFETCH_FORMS",options:[],placeholder:s("Select a form"),render:!0,value:void 0},{componentName:t.componentName.hookListener,fieldType:"config",id:"hook-listener",label:s("Listen Hook"),render:({$:e})=>m(e.getComponent("form-id")?.value)}]}}));export{F as default};
