var L=Object.defineProperty;var I=Object.getOwnPropertySymbols;var k=Object.prototype.hasOwnProperty,y=Object.prototype.propertyIsEnumerable;var w=(n,s,t)=>s in n?L(n,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[s]=t,N=(n,s)=>{for(var t in s||(s={}))k.call(s,t)&&w(n,t,s[t]);if(I)for(var t of I(s))y.call(s,t)&&w(n,t,s[t]);return n};import{r,j as e,_ as x,L as _,aL as z,c as A,v as R,w as P,a as B,S as T,B as E,x as $}from"./main-40.js";/* empty css          */import{B as H}from"./bf-586-70.js";import{T as q,S as D}from"./bf-679-136.js";import{b as G}from"./bf-132-75.js";import{I as J}from"./bf-94-335.js";import{t as v}from"./bf-892-199.js";import{A as K}from"./bf-541-403.js";import{N as O}from"./bf-504-404.js";import{F as Q,c as U,r as V}from"./bf-504-386.js";import"./bf-141-80.js";import"./bf-860-126.js";import"./bf-528-128.js";import"./bf-200-122.js";import"./bf-689-131.js";function W({fluentCrmConf:n,setFluentCrmConf:s,step:t,nextPage:g,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,p]=r.useState(!0);r.useEffect(()=>()=>{p(!1)},[]);const c=()=>{a("auth"),A({},"bitforms_fluent_crm_authorize").then(l=>{h&&(l!=null&&l.success&&(d(!0),j({show:!0,msg:x("Connect Successfully")})),S(!0),a(!1))})},M=l=>{const b=N({},n),F=N({},C);F[l.target.name]="",b[l.target.name]=l.target.value,o(F),s(b)};return e.jsxs(e.Fragment,{children:[e.jsx(q,{title:v.fluentCRM.title,youTubeLink:v.fluentCRM.link}),e.jsxs("div",{className:"btcd-stp-page",style:{width:t===1&&900,height:t===1&&"100%"},children:[e.jsx("div",{className:"mt-3",children:e.jsx("b",{children:x("Integration Name:")})}),e.jsx("input",{className:"btcd-paper-inp w-5 mt-1",onChange:M,name:"name",value:n.name,type:"text",placeholder:x("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(K,{isAuthorized:u,isLoading:i,handleAuthorize:()=>c()}),e.jsx("br",{}),e.jsx(O,{nextPageHandler:()=>g(2),disabled:!u})]})]})}function he({formFields:n,setIntegration:s,integrations:t,allIntegURL:g}){const j=R(),{formID:m}=P(),[u,d]=r.useState(!1),{css:C}=B(),[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:{}}),p=c=>{if(setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),c===3){if(!U(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&&V(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(D,{step:3,active:o})}),e.jsx(W,{formID:m,fluentCrmConf:a,setFluentCrmConf:h,step:o,nextPage:p,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(Q,{formID:m,formFields:n,fluentCrmConf:a,setFluentCrmConf:h,setisLoading:d,setSnackbar:i}),e.jsx("br",{}),e.jsx("br",{}),e.jsx("br",{}),e.jsxs(E,{onClick:()=>p(3),disabled:!a.list_id||a.field_map.length<1,className:C($.ftRight),children:[x("Next"),e.jsx(H,{className:"ml-1 rev-icn"})]})]}),e.jsx(J,{step:o,saveConfig:()=>G(t,s,g,a,j)})]})}export{he as default};
