var w=Object.defineProperty;var S=Object.getOwnPropertySymbols;var D=Object.prototype.hasOwnProperty,F=Object.prototype.propertyIsEnumerable;var v=(a,t,s)=>t in a?w(a,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):a[t]=s,j=(a,t)=>{for(var s in t||(t={}))D.call(t,s)&&v(a,s,t[s]);if(S)for(var s of S(t))F.call(t,s)&&v(a,s,t[s]);return a};import{_ as i,j as r,z as n}from"./main.2.8.10.js";import{u as q,b as o}from"./react-router.DMwpH23k.js";import"./CopyIcn.BnhKHfEP.js";import{S as L}from"./SnackMsg.7BjcJK1j.js";import{S as T}from"./Steps.B84Ui3GU.js";import{I as z,g as E}from"./Integrations.BFhED4ck.js";import M from"./ClickupAuthorization.CGfmWHVJ.js";import{h as A,c as y}from"./ClickupCommonFunc.-eeBvG2k.js";import{C as B}from"./ClickupIntegLayout.CBwMsp9C.js";import"./react-vendor.P7K3d6op.js";import"./Note.DalStCGz.js";import"./Table.DSsAy4VI.js";import"./index.DpWdl9V1.js";import"./TutorialLink.D6K_DiHL.js";import"./TagifyInput.C4ilRm4k.js";import"./lodash.DCvQBX3r.js";function ae({formFields:a,setFlow:t,flow:s,allIntegURL:u}){const f=q(),[C,g]=o.useState(!1),[b,h]=o.useState({}),[c,x]=o.useState(1),[N,m]=o.useState({show:!1}),_=[{key:"name",label:i("Name","bit-integrations"),required:!0},{key:"description",label:i("Description","bit-integrations"),required:!1},{key:"start_date",label:i("Start Date","bit-integrations"),required:!1},{key:"due_date",label:i("Due Date","bit-integrations"),required:!1}],[e,l]=o.useState({name:"Clickup",type:"Clickup",api_key:"",field_map:[{formField:"",clickupFormField:""}],actionName:"",taskFields:_,actions:{}}),I=()=>{g(!0),E(s,t,u,e,f,"","",g).then(p=>{var k;p.success?(n.success((k=p.data)==null?void 0:k.msg),f(u)):n.error(p.data||p)})},P=d=>{if(setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),!y(e)){n.error(i("Please map mandatory fields","bit-integrations"));return}if(e.actionName==="task"){if(!e.selectedTeam){n.error(i("Please select a team","bit-integrations"));return}if(!e.selectedSpace){n.error(i("Please select a space","bit-integrations"));return}if(!e.selectedFolder){n.error(i("Please select a folder","bit-integrations"));return}if(!e.selectedList){n.error(i("Please select a list","bit-integrations"));return}}e.field_map.length>0&&x(d)};return r.jsxs("div",{children:[r.jsx(L,{snack:N,setSnackbar:m}),r.jsx("div",{className:"txt-center mt-2",children:r.jsx(T,{step:3,active:c})}),r.jsx(M,{clickupConf:e,setClickupConf:l,step:c,setStep:x,loading:b,setLoading:h,setSnackbar:m}),r.jsxs("div",{className:"btcd-stp-page",style:j({},c===2&&{width:900,height:"auto",overflow:"visible"}),children:[r.jsx(B,{formFields:a,handleInput:d=>A(d,e,l),clickupConf:e,setClickupConf:l,loading:b,setLoading:h,setSnackbar:m}),(e==null?void 0:e.actionName)&&r.jsxs("button",{onClick:()=>P(3),disabled:!y(e),className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",children:[i("Next","bit-integrations"),"  ",r.jsx("div",{className:"btcd-icn icn-arrow_back rev-icn d-in-b"})]})]}),(e==null?void 0:e.actionName)&&r.jsx(z,{step:c,saveConfig:()=>I(),isLoading:C,dataConf:e,setDataConf:l,formFields:a})]})}export{ae as default};
