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.1.js";import{u as q,d as o}from"./react-router-dom.9mCuUg3q.js";import"./Note.BeM7sN-p.js";import{S as L}from"./SnackMsg.S8DrwLlT.js";import{S as T}from"./Steps.1hz7v9Vj.js";import{I as z,g as E}from"./Integrations.D2bgBas2.js";import M from"./ClickupAuthorization.D3ucK-Gz.js";import{h as A,c as y}from"./ClickupCommonFunc.CRon7DBn.js";import{C as B}from"./ClickupIntegLayout.DkdxIejK.js";import"./CopyIcn.3gZpHton.js";import"./Table.DAL7rcPQ.js";import"./index.wO-AxluA.js";import"./tutorialLinks.kMkIDzcD.js";import"./TutorialLink.BAFX--T3.js";import"./TagifyInput.Cu0YIRbG.js";import"./tagify.YxUZd8Ix.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};
