var w=Object.defineProperty;var j=Object.getOwnPropertySymbols;var P=Object.prototype.hasOwnProperty,q=Object.prototype.propertyIsEnumerable;var k=(a,t,s)=>t in a?w(a,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):a[t]=s,v=(a,t)=>{for(var s in t||(t={}))P.call(t,s)&&k(a,s,t[s]);if(j)for(var s of j(t))q.call(t,s)&&k(a,s,t[s]);return a};import{u as C,r as i,j as n}from"./main-406.js";import{d as F,_ as D,I as E,G as L,c as o}from"./bi.394.85.js";import{S as T}from"./bi.68.941.js";import M from"./bi.371.310.js";import{h as z,c as N}from"./bi.266.878.js";import{A as B}from"./bi.334.879.js";import"./bi.150.760.js";function W({formFields:a,setFlow:t,flow:s,allIntegURL:u}){const p=C(),[S,f]=i.useState(!1),[g,b]=i.useState({}),[r,h]=i.useState(1),[y,m]=i.useState({show:!1}),_=[{key:"name",label:"Name",required:!0},{key:"due_at",label:"Due At",required:!1},{key:"due_on",label:"Due On",required:!1},{key:"notes",label:"Notes",required:!1}],[e,c]=i.useState({name:"Asana",type:"Asana",api_key:"",field_map:[{formField:"",asanaFormField:""}],actionName:"",taskFields:_,actions:{}}),A=()=>{f(!0),L(s,t,u,e,p,"","",f).then(d=>{var x;d.success?(o.success((x=d.data)==null?void 0:x.msg),p(u)):o.error(d.data||d)})},I=l=>{if(setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),!N(e)){o.error("Please map mandatory fields");return}if(e.actionName==="task"){if(!e.selectedProject){o.error("Please select a project");return}if(!e.selectedSections&&e.actionName==="task"){o.error("Please select a Section");return}}e.field_map.length>0&&h(l)};return n.jsxs("div",{children:[n.jsx(F,{snack:y,setSnackbar:m}),n.jsx("div",{className:"txt-center mt-2",children:n.jsx(T,{step:3,active:r})}),n.jsx(M,{asanaConf:e,setAsanaConf:c,step:r,setStep:h,loading:g,setLoading:b,setSnackbar:m}),n.jsxs("div",{className:"btcd-stp-page",style:v({},r===2&&{width:900,height:"auto",overflow:"visible"}),children:[n.jsx(B,{formFields:a,handleInput:l=>z(l,e,c),asanaConf:e,setAsanaConf:c,loading:g,setLoading:b,setSnackbar:m}),(e==null?void 0:e.actionName)&&n.jsxs("button",{onClick:()=>I(3),disabled:!N(e),className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",children:[D("Next","bit-integrations")," "," ",n.jsx("div",{className:"btcd-icn icn-arrow_back rev-icn d-in-b"})]})]}),(e==null?void 0:e.actionName)&&n.jsx(E,{step:r,saveConfig:()=>A(),isLoading:S,dataConf:e,setDataConf:c,formFields:a})]})}export{W as default};
