var S=Object.defineProperty;var p=Object.getOwnPropertySymbols;var M=Object.prototype.hasOwnProperty,N=Object.prototype.propertyIsEnumerable;var f=(a,t,s)=>t in a?S(a,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):a[t]=s,b=(a,t)=>{for(var s in t||(t={}))M.call(t,s)&&f(a,s,t[s]);if(p)for(var s of p(t))N.call(t,s)&&f(a,s,t[s]);return a};import{u as T,k as G,h as P,r as d,j as i}from"./main-406.js";import{k as F,d as C,_ as E,I as L,s as U}from"./bi.394.85.js";import{S as D}from"./bi.68.941.js";import R from"./bi.835.268.js";import{h as z,c as B,b as O}from"./bi.158.792.js";import{G as Z}from"./bi.884.793.js";import"./bi.46.744.js";import"./bi.150.760.js";import"./bi.285.720.js";import"./bi.840.704.js";import"./bi.704.707.js";import"./bi.701.708.js";function ie({formFields:a,setFlow:t,flow:s,allIntegURL:g}){var u;const h=T(),{formID:y}=G(),k=P(F),{siteURL:_}=k,[o,c]=d.useState(!1),[n,m]=d.useState(1),[x,r]=d.useState({show:!1}),A=[{key:"email",label:"Email",required:!0},{key:"first_name",label:"First Name",required:!1},{key:"last_name",label:"Last Name",required:!1},{key:"user_id",label:"User Id",required:!1},{key:"owner_id",label:"Owner Id",required:!1},{key:"note",label:"Note",required:!1}],w=[{key:"primary_phone",label:"Primary Phone",required:!1},{key:"street_address_1",label:"Street Address 1",required:!1},{key:"street_address_2",label:"Street Address 2",required:!1},{key:"postal_zip",label:"Postal Zip",required:!1},{key:"city",label:"City",required:!1},{key:"country",label:"Country",required:!1}],j=[{key:"1",label:"Create Contact"},{key:"2",label:"Add tag to user"}],[e,l]=d.useState({name:"Groundhogg",type:"Groundhogg",domainName:_,token:"",public_key:"",id:"",mainAction:"",addTagToUser:"",emailAddress:"",showMeta:!1,optin_status:"1",field_map:[{formField:"",GroundhoggMapField:""}],field_map_meta:[{formField:"",GroundhoggMetaMapField:""}],contactsFields:A,contactMetaFields:w,allActions:j,address_field:[],actions:{}}),q=()=>{if(setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),e.mainAction==="1"&&!B(e)){r({show:!0,msg:"Please map fields to continue."});return}if(e.showMeta&&!O(e)){r({show:!0,msg:"Please map fields to continue."});return}if(e.mainAction==="2"&&(e==null?void 0:e.emailAddress)===""){r({show:!0,msg:"Please select Email field to continue."});return}if(e.mainAction==="2"&&(e==null?void 0:e.addTagToUser)===""){r({show:!0,msg:"Please select All Tags field to continue."});return}e.listId!==""&&m(3)},v=!(e.mainAction==="2"&&e.addTagToUser!=="");return i.jsxs("div",{children:[i.jsx(C,{snack:x,setSnackbar:r}),i.jsx("div",{className:"txt-center mt-2",children:i.jsx(D,{step:3,active:n})}),i.jsx(R,{formID:y,groundhoggConf:e,setGroundhoggConf:l,step:n,setstep:m,isLoading:o,setIsLoading:c,setSnackbar:r}),i.jsxs("div",{className:"btcd-stp-page",style:b({},n===2&&{width:900,height:"auto",overflow:"visible"}),children:[i.jsx(Z,{formFields:a,handleInput:I=>z(I,e,l),groundhoggConf:e,setGroundhoggConf:l,isLoading:o,setIsLoading:c,setSnackbar:r}),i.jsxs("button",{onClick:()=>q(),disabled:(e.mainAction==="2"?v:!(((u=e.field_map)==null?void 0:u.length)>=1))||o,className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",children:[E("Next","bit-integrations")," "," ",i.jsx("div",{className:"btcd-icn icn-arrow_back rev-icn d-in-b"})]})]}),i.jsx(L,{step:n,saveConfig:()=>U({flow:s,setFlow:t,allIntegURL:g,navigate:h,conf:e,setIsLoading:c,setSnackbar:r}),isLoading:o,dataConf:e,setDataConf:l,formFields:a})]})}export{ie as default};
