import{aa as c,ab as n}from"./_applist-tangy-colts-beg-36.js";import{aR as r,_ as s}from"./main-tangy-colts-beg.js";import{s as h}from"./machine.-tangy-colts-beg-869.js";import"./lodash-tangy-colts-beg-516.js";globalThis.jotaiAtomCache=globalThis.jotaiAtomCache||{cache:new Map,get(t,e){return this.cache.has(t)?this.cache.get(t):(this.cache.set(t,e),e)}};const l=async()=>r("bit-form/get-forms");globalThis.jotaiAtomCache=globalThis.jotaiAtomCache||{cache:new Map,get(t,e){return this.cache.has(t)?this.cache.get(t):(this.cache.set(t,e),e)}};const i=async t=>{t.setComponent("form-id",o=>{o.loading=!0});const{data:e,status:a}=await l();if(a==="error"){t.setComponent("form-id",o=>{t.util.isSelectComponent(o)&&(o.status=a,o.loading=!1,o.invalidMessage=e)});return}t.setComponent("form-id",o=>{t.util.isSelectComponent(o)&&(o.options=e,o.loading=!1,o.status=void 0)})};globalThis.jotaiAtomCache=globalThis.jotaiAtomCache||{cache:new Map,get(t,e){return this.cache.has(t)?this.cache.get(t):(this.cache.set(t,e),e)}};const g=c(({helpers:t})=>({states:{components:[{componentName:t.componentName.select,fieldType:"config",id:"form-id",label:s("Forms"),onChange:"SELECT_FORM",onRefetch:"REFETCH_FORMS",optionFilterProp:"label",options:[],placeholder:s("Select a form"),render:!0,showSearch:!0,value:void 0},{componentName:t.componentName.hookListener,fieldType:"config",id:"hook-listener",label:s("Listen Hook"),render:({$:e})=>{var a;return n((a=e.getComponent("form-id"))==null?void 0:a.value)}}]},actions:{ON_MACHINE_LOAD:async({$:e})=>{h(e,[{db:"formId",id:"form-id"}]),await i(e)},REFETCH_FORMS:async({$:e})=>i(e),SELECT_FORM:async({$:e,e:a})=>{e.setThisComponent(o=>{o.value=a}),e.setDb({formId:a})}}}));export{g as default};
