var T=Object.defineProperty;var j=Object.getOwnPropertySymbols;var L=Object.prototype.hasOwnProperty,F=Object.prototype.propertyIsEnumerable;var k=(s,t,a)=>t in s?T(s,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):s[t]=a,_=(s,t)=>{for(var a in t||(t={}))L.call(t,a)&&k(s,a,t[a]);if(j)for(var a of j(t))F.call(t,a)&&k(s,a,t[a]);return s};import{j as i,_ as o,z as r}from"./main.2.9.0.js";import{u as P,b as n}from"./react-router.DMwpH23k.js";import"./CopyIcn.CEA_lFLo.js";import{S as q}from"./SnackMsg.DYSD96P4.js";import{S as z}from"./Steps.BYe8zHkm.js";import{I as E,g as M}from"./Integrations.DL8wqGct.js";import A from"./SmartSuiteAuthorization.x-YTN2Di.js";import{d as B,c as y}from"./SmartSuiteCommonFunc.BODPe02n.js";import{S as D}from"./SmartSuiteIntegLayout.Bwm3H-rV.js";import"./react-vendor.P7K3d6op.js";import"./Note.NSUdvR3c.js";import"./Table.BfF8RYFZ.js";import"./index.DpWdl9V1.js";import"./TutorialLink.CFG7bS5c.js";import"./FieldMapHelper.D-WuI2oA.js";import"./TagifyInput.KPPRQJ1B.js";import"./lodash.DCvQBX3r.js";import"./ProUtilHelpers.CHf_DzPf.js";function ce({formFields:s,setFlow:t,flow:a,allIntegURL:u}){const b=P(),[g,m]=n.useState(!1),[f,S]=n.useState({}),[c,x]=n.useState(1),[C,p]=n.useState({show:!1}),h=[],[e,d]=n.useState({name:"SmartSuite",type:"SmartSuite",workspaceId:"",apiToken:"",field_map:B(h),actionName:"",smartSuiteFields:h,solutionFields:R,tableFields:G,actionLists:H}),I=()=>{m(!0),M(a,t,u,e,b,"","",m).then(l=>{var v;l.success?(r.success((v=l.data)==null?void 0:v.msg),b(u)):r.error(l.data||l)})},w=N=>{if(setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),!y(e)){r.error(o("Please map mandatory fields","bit-integrations"));return}if((e.actionName==="table"||e.actionName==="record")&&!e.selectedSolution){r.error(o("Please select a solution","bit-integrations"));return}if(e.actionName==="record"&&!e.selectedTable){r.error(o("Please select a table","bit-integrations"));return}e.field_map.length>0&&x(N)};return i.jsxs("div",{children:[i.jsx(q,{snack:C,setSnackbar:p}),i.jsx("div",{className:"txt-center mt-2",children:i.jsx(z,{step:3,active:c})}),i.jsx(A,{smartSuiteConf:e,setSmartSuiteConf:d,step:c,setStep:x,loading:f,setLoading:S,setSnackbar:p}),i.jsxs("div",{className:"btcd-stp-page",style:_({},c===2&&{width:900,height:"auto",overflow:"visible"}),children:[i.jsx(D,{formFields:s,smartSuiteConf:e,setSmartSuiteConf:d,loading:f,setLoading:S,isLoading:g,setIsLoading:m,setSnackbar:p}),(e==null?void 0:e.actionName)&&i.jsxs("button",{onClick:()=>w(3),disabled:!y(e),className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",children:[o("Next","bit-integrations"),"  ",i.jsx("div",{className:"btcd-icn icn-arrow_back rev-icn d-in-b"})]})]}),(e==null?void 0:e.actionName)&&i.jsx(E,{step:c,saveConfig:()=>I(),isLoading:g,dataConf:e,setDataConf:d,formFields:s})]})}const R=[{label:"Name",key:"name",required:!0},{label:"Logo Icon",key:"logo_icon",required:!1}],G=[{label:"Name",key:"name",required:!0}],H=[{name:"solution",label:o("Create Solution","bit-integrations"),is_pro:!1},{name:"table",label:o("Create Table","bit-integrations"),is_pro:!0},{name:"record",label:o("Create Record","bit-integrations"),is_pro:!0}];export{ce as default};
