var k=Object.defineProperty;var I=Object.getOwnPropertySymbols;var y=Object.prototype.hasOwnProperty,L=Object.prototype.propertyIsEnumerable;var w=(n,t,s)=>t in n?k(n,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):n[t]=s,N=(n,t)=>{for(var s in t||(t={}))y.call(t,s)&&w(n,s,t[s]);if(I)for(var s of I(t))L.call(t,s)&&w(n,s,t[s]);return n};import{r,j as e,_ as p,L as _,bs as z,c as A,D as R,g as P,a as E,S as T,W as B,h as $}from"./main-634.js";import{m as D}from"./bf-25-81.js";import{S as H}from"./bf-54-258.js";import{a5 as q,a6 as W,a7 as G}from"./bf-746-82.js";import{I as J}from"./bf-942-184.js";import{t as M}from"./bf-275-83.js";import{N as K}from"./bf-123-109.js";import{F as O,c as Q,r as U}from"./bf-812-217.js";import"./bf-822-108.js";import"./bf-438-114.js";function V({fluentCrmConf:n,setFluentCrmConf:t,step:s,nextPage:x,setSnackbar:j,isInfo:m}){const[u,d]=r.useState(!1),[C,o]=r.useState({integrationName:""}),[f,S]=r.useState(!1),[i,a]=r.useState(!1),[h,g]=r.useState(!0);r.useEffect(()=>()=>{g(!1)},[]);const c=()=>{a("auth"),A({},"bitforms_fluent_crm_authorize").then(l=>{h&&(l!=null&&l.success&&(d(!0),j({show:!0,msg:p("Connect Successfully")})),S(!0),a(!1))})},v=l=>{const b=N({},n),F=N({},C);F[l.target.name]="",b[l.target.name]=l.target.value,o(F),t(b)};return e.jsxs(e.Fragment,{children:[e.jsx(q,{title:M.fluentCRM.title,youTubeLink:M.fluentCRM.link}),e.jsxs("div",{className:"btcd-stp-page",style:{width:s===1&&900,height:s===1&&"100%"},children:[e.jsx("div",{className:"mt-3",children:e.jsx("b",{children:p("Integration Name:")})}),e.jsx("input",{className:"btcd-paper-inp w-5 mt-1",onChange:v,name:"name",value:n.name,type:"text",placeholder:p("Integration Name..."),disabled:m}),i==="auth"&&e.jsxs("div",{className:"flx mt-5",children:[e.jsx(_,{size:25,clr:"#022217",className:"mr-2"}),"Checking if Fluent CRM is active!!!"]}),f&&!u&&!i&&e.jsxs("div",{className:"flx mt-5",style:{color:"red"},children:[e.jsx("span",{className:"mr-2",style:{fontSize:30,marginTop:-5},children:e.jsx(z,{size:"15"})}),"Please! First Install Fluent CRM Plugins"]}),e.jsx(W,{isAuthorized:u,isLoading:i,handleAuthorize:()=>c()}),e.jsx("br",{}),e.jsx(K,{nextPageHandler:()=>x(2),disabled:!u})]})]})}function le({formFields:n,setIntegration:t,integrations:s,allIntegURL:x}){const j=R(),{formID:m}=P(),[u,d]=r.useState(!1),{css:C}=E(),[o,f]=r.useState(1),[S,i]=r.useState({show:!1}),[a,h]=r.useState({name:"Fluent CRM API",type:"Fluent CRM",field_map:[{formField:"",fluentCRMField:""}],actions:{}}),g=c=>{if(setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),c===3){if(!Q(a)){i({show:!0,msg:"Please map all required fields to continue."});return}if(!a.list_id){i({show:!0,msg:"Please select list to continue."});return}a.name!==""&&a.field_map.length>0&&f(c)}else f(c),c===2&&a.name&&U(m,a,h,d,i)};return e.jsxs("div",{children:[e.jsx(T,{snack:S,setSnackbar:i}),e.jsx("div",{className:"txt-center w-9 mt-2 cal-width",children:e.jsx(H,{step:3,active:o})}),e.jsx(V,{formID:m,fluentCrmConf:a,setFluentCrmConf:h,step:o,nextPage:g,isLoading:u,setisLoading:d,setSnackbar:i}),e.jsxs("div",{className:"btcd-stp-page",style:{width:o===2&&900,height:o===2&&"100%",minHeight:o===2&&"200px"},children:[e.jsx(O,{formID:m,formFields:n,fluentCrmConf:a,setFluentCrmConf:h,setisLoading:d,setSnackbar:i}),e.jsx("br",{}),e.jsx("br",{}),e.jsx("br",{}),e.jsxs(B,{onClick:()=>g(3),disabled:!a.list_id||a.field_map.length<1,className:C($.ftRight),children:[p("Next"),e.jsx(D,{className:"ml-1 rev-icn"})]})]}),e.jsx(J,{step:o,saveConfig:()=>G(s,t,x,a,j)})]})}export{le as default};
