import{r as i,a as b,j as e,_ as p,L as v,bm as N,U as I,h as C,c as y,A as k,G as L,g as W,S as _}from"./main-343.js";import"./bf-649-79.js";import{S as z}from"./bf-149-261.js";import{a5 as F,a7 as A}from"./bf-659-81.js";import{I as T}from"./bf-58-184.js";import{N as S}from"./bf-713-109.js";import{t as w}from"./bf-974-82.js";import{W as B,h as P}from"./bf-819-214.js";import"./bf-594-113.js";function E({wcConf:m,setWcConf:g,step:l,setStep:f,setSnackbar:x}){const[o,d]=i.useState(!1),[n,s]=i.useState(!1),[h,j]=i.useState(!1),{css:r}=b(),t=()=>{s("auth"),y({},"bitforms_wc_authorize").then(a=>{a!=null&&a.success&&(d(!0),x({show:!0,msg:p("Connected with WooCommerce Successfully")})),s(!1),j(!0)})},c=a=>{const u=k(m);u[a.target.name]=a.target.value,g(u)};return e.jsxs(e.Fragment,{children:[e.jsx(F,{title:w.wooCommerce.title,youTubeLink:w.wooCommerce.link}),e.jsxs("div",{className:"btcd-stp-page",style:{width:l===1&&900,height:l===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-6 mt-1",onChange:c,name:"name",value:m.name,type:"text",placeholder:p("Integration Name...")}),n==="auth"&&e.jsxs("div",{className:"flx mt-5",children:[e.jsx(v,{size:25,clr:"#022217",className:"mr-2"}),"Checking if WooCommerce is active!!!"]}),h&&!o&&!n&&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(N,{size:"15"})}),"WooCommerce plugin must be activated to integrate with Bit Form."]}),!o&&e.jsx(I,{variant:o?"disabled":"success",onClick:t,className:r(C.mt3,C.mb3,{ml:3}),children:p("Connect")}),o&&e.jsx(S,{nextPageHandler:()=>f(2),disabled:!o})]})]})}function K({formFields:m,setIntegration:g,integrations:l,allIntegURL:f}){const x=L(),{formID:o}=W(),[d,n]=i.useState(!1),[s,h]=i.useState(1),[j,r]=i.useState({show:!1}),[t,c]=i.useState({name:"WooCommerce Integration",type:"WooCommerce",field_map:[{formField:"",wcField:""}],upload_field_map:[{formField:"",wcField:""}],actions:{}}),a=()=>{setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),t.workspace!==""&&t.table!==""&&t.field_map.length>0&&h(3)};return e.jsxs("div",{children:[e.jsx(_,{snack:j,setSnackbar:r}),e.jsx("div",{className:"txt-center w-9 mt-2 cal-width",children:e.jsx(z,{step:3,active:s})}),e.jsx(E,{formID:o,wcConf:t,setWcConf:c,step:s,setStep:h,isLoading:d,setisLoading:n,setSnackbar:r}),e.jsxs("div",{className:"btcd-stp-page",style:{width:s===2&&900,height:s===2&&"100%"},children:[e.jsx(B,{wcConf:t,setWcConf:c,formFields:m,handleInput:u=>P(u,t,c,n,r),isLoading:d,setisLoading:n}),e.jsx(S,{nextPageHandler:()=>a(),disabled:t.workspace===""||t.table===""||t.field_map.length<1})]}),e.jsx(T,{step:s,saveConfig:()=>A(l,g,f,t,x)})]})}export{K as default};
