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 x,L as _,bm as z,c as A,G as R,g as P,a as B,S as E,U as T,h as $}from"./main-343.js";import{B as H}from"./bf-649-79.js";import{S as q}from"./bf-149-261.js";import{a5 as D,a6 as G,a7 as U}from"./bf-659-81.js";import{I as J}from"./bf-58-184.js";import{t as M}from"./bf-974-82.js";import{N as K}from"./bf-713-109.js";import{F as O,c as Q,r as V}from"./bf-48-217.js";import"./bf-594-113.js";function W({fluentCrmConf:n,setFluentCrmConf:t,step:s,nextPage:p,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:x("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(D,{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:x("Integration Name:")})}),e.jsx("input",{className:"btcd-paper-inp w-5 mt-1",onChange:v,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(G,{isAuthorized:u,isLoading:i,handleAuthorize:()=>c()}),e.jsx("br",{}),e.jsx(K,{nextPageHandler:()=>p(2),disabled:!u})]})]})}function oe({formFields:n,setIntegration:t,integrations:s,allIntegURL:p}){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:{}}),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&&V(m,a,h,d,i)};return e.jsxs("div",{children:[e.jsx(E,{snack:S,setSnackbar:i}),e.jsx("div",{className:"txt-center w-9 mt-2 cal-width",children:e.jsx(q,{step:3,active:o})}),e.jsx(W,{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(T,{onClick:()=>g(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:()=>U(s,t,p,a,j)})]})}export{oe as default};
