var I=Object.defineProperty;var b=Object.getOwnPropertySymbols;var N=Object.prototype.hasOwnProperty,_=Object.prototype.propertyIsEnumerable;var x=(s,e,t)=>e in s?I(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,w=(s,e)=>{for(var t in e||(e={}))N.call(e,t)&&x(s,t,e[t]);if(b)for(var t of b(e))_.call(e,t)&&x(s,t,e[t]);return s};import{j as o,_ as v,z as h}from"./main.2.8.1.js";import{u as H,d as r}from"./react-router-dom.9mCuUg3q.js";import{S as E}from"./SnackMsg.S8DrwLlT.js";import{S as T}from"./Steps.1hz7v9Vj.js";import{I as W,g as F}from"./Integrations.D2bgBas2.js";import L from"./ZohoSheetAuthorization.PaQ7AqO6.js";import{s as M,c as j}from"./ZohoSheetCommonFunc.Mi59-eT_.js";import{Z as P}from"./ZohoSheetIntegLayout.C8rVzJEw.js";import"./Note.BeM7sN-p.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 se({formFields:s,setFlow:e,flow:t,allIntegURL:m}){const p=H(),[C,l]=r.useState(!1),[i,f]=r.useState({auth:!1,header:!1,workbooks:!1,worksheets:!1,workSheetHeaders:!1}),[n,S]=r.useState(1),[Z,u]=r.useState({show:!1}),[a,d]=r.useState({name:"Zoho Sheet",type:"Zoho Sheet",dataCenter:"",clientId:"",clientSecret:"",field_map:[{formField:"",zohoSheetFormField:""}],workbooks:[],worksheets:[],workSheetHeaders:[],selectedWorkbook:"",selectedWorksheet:"",headerRow:1,actions:{}});r.useEffect(()=>{window.opener&&M("zohoSheet")},[]);const y=()=>{l(!0),F(t,e,m,a,p,"","",l).then(c=>{var k;c.success?(h.success((k=c.data)==null?void 0:k.msg),p(m)):h.error(c.data||c)})},z=g=>{if(setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),!j(a)){h.error(v("Please map mandatory workSheetHeaders","bit-integrations"));return}a.field_map.length>0&&S(g)};return o.jsxs("div",{children:[o.jsx(E,{snack:Z,setSnackbar:u}),o.jsx("div",{className:"txt-center mt-2",children:o.jsx(T,{step:3,active:n})}),o.jsx(L,{zohoSheetConf:a,setZohoSheetConf:d,step:n,setStep:S,loading:i,setLoading:f,setSnackbar:u}),o.jsxs("div",{className:"btcd-stp-page",style:w({},n===2&&{width:900,height:"auto",overflow:"visible"}),children:[o.jsx(P,{formFields:s,zohoSheetConf:a,setZohoSheetConf:d,loading:i,setLoading:f}),i.workSheetHeaders&&a.selectedWorksheet&&o.jsxs("button",{onClick:()=>z(3),disabled:!j(a),className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",children:[v("Next","bit-integrations"),"  ",o.jsx("div",{className:"btcd-icn icn-arrow_back rev-icn d-in-b"})]})]}),i.workSheetHeaders&&a.selectedWorksheet&&o.jsx(W,{step:n,saveConfig:()=>y(),isLoading:C,dataConf:a,setDataConf:d,formFields:s})]})}export{se as default};
