var y=Object.defineProperty;var v=Object.getOwnPropertySymbols;var N=Object.prototype.hasOwnProperty,T=Object.prototype.propertyIsEnumerable;var j=(s,e,t)=>e in s?y(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,S=(s,e)=>{for(var t in e||(e={}))N.call(e,t)&&j(s,t,e[t]);if(v)for(var t of v(e))T.call(e,t)&&j(s,t,e[t]);return s};import{j as i,_ as F,z as p}from"./main.2.8.10.js";import{u as w,b as o}from"./react-router.DMwpH23k.js";import{S as z}from"./SnackMsg.7BjcJK1j.js";import{S as E}from"./Steps.B84Ui3GU.js";import{I as L,g as B}from"./Integrations.BFhED4ck.js";import M from"./AirtableAuthorization.EzvzfRGF.js";import{h as P,c as A}from"./AirtableCommonFunc.dlV-hVGI.js";import{A as D}from"./AirtableIntegLayout.DJL_9Qmi.js";import"./react-vendor.P7K3d6op.js";import"./Note.DalStCGz.js";import"./CopyIcn.BnhKHfEP.js";import"./Table.DSsAy4VI.js";import"./index.DpWdl9V1.js";import"./TutorialLink.D6K_DiHL.js";import"./TagifyInput.C4ilRm4k.js";import"./lodash.DCvQBX3r.js";function se({formFields:s,setFlow:e,flow:t,allIntegURL:b}){const f=w(),[C,u]=o.useState(!1),[r,g]=o.useState({auth:!1,customFields:!1,bases:!1,tables:!1,airtableFields:!1}),[n,h]=o.useState(1),[k,m]=o.useState({show:!1}),[a,l]=o.useState({name:"Airtable",type:"Airtable",auth_token:"",field_map:[{formField:"",airtableFormField:""}],airtableFields:[],bases:[],selectedBase:"",selectedTable:"",actions:{}}),I=()=>{u(!0),B(t,e,b,a,f,"","",u).then(d=>{var x;d.success?(p.success((x=d.data)==null?void 0:x.msg),f(b)):p.error(d.data||d)})},_=c=>{if(setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),!A(a)){p.error(F("Please map mandatory airtableFields","bit-integrations"));return}a.field_map.length>0&&h(c)};return i.jsxs("div",{children:[i.jsx(z,{snack:k,setSnackbar:m}),i.jsx("div",{className:"txt-center mt-2",children:i.jsx(E,{step:3,active:n})}),i.jsx(M,{airtableConf:a,setAirtableConf:l,step:n,setStep:h,loading:r,setLoading:g,setSnackbar:m}),i.jsxs("div",{className:"btcd-stp-page",style:S({},n===2&&{width:900,height:"auto",overflow:"visible"}),children:[i.jsx(D,{formFields:s,handleInput:c=>P(c,a,l),airtableConf:a,setAirtableConf:l,loading:r,setLoading:g,setSnackbar:m}),r.airtableFields&&a.selectedTable&&i.jsxs("button",{onClick:()=>_(3),disabled:!A(a),className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",children:[F("Next","bit-integrations"),"  ",i.jsx("div",{className:"btcd-icn icn-arrow_back rev-icn d-in-b"})]})]}),r.airtableFields&&a.selectedTable&&i.jsx(L,{step:n,saveConfig:()=>I(),isLoading:C,dataConf:a,setDataConf:l,formFields:s})]})}export{se as default};
