var P=Object.defineProperty,T=Object.defineProperties;var I=Object.getOwnPropertyDescriptors;var v=Object.getOwnPropertySymbols;var M=Object.prototype.hasOwnProperty,C=Object.prototype.propertyIsEnumerable;var j=(a,s,n)=>s in a?P(a,s,{enumerable:!0,configurable:!0,writable:!0,value:n}):a[s]=n,p=(a,s)=>{for(var n in s||(s={}))M.call(s,n)&&j(a,n,s[n]);if(v)for(var n of v(s))C.call(s,n)&&j(a,n,s[n]);return a},f=(a,s)=>T(a,I(s));import{k as $,f as E,j as t,_ as o}from"./main.2.9.0.js";import{b as m,u as B}from"./react-router.DMwpH23k.js";import"./CopyIcn.CEA_lFLo.js";import{C as W,g as z}from"./Integrations.DL8wqGct.js";import{a9 as D,y as H}from"./Note.NSUdvR3c.js";import{c as y,g as K}from"./ProUtilHelpers.CHf_DzPf.js";import{S as q}from"./SnackMsg.DYSD96P4.js";import{b as G}from"./Table.BfF8RYFZ.js";import{T as J}from"./TutorialLink.CFG7bS5c.js";import{g,i as O,a as Q,r as V,U as X,C as Y,R as Z,c as ee}from"./UserMetaField.DPhVCG7I.js";import"./react-vendor.P7K3d6op.js";import"./index.DpWdl9V1.js";import"./TagifyInput.KPPRQJ1B.js";import"./lodash.DCvQBX3r.js";function xe({formFields:a,setFlow:s,flow:n,allIntegURL:w}){var _,x;const[k,d]=m.useState({show:!1}),N=B(),{isPro:u}=$(E),[h,b]=m.useState(!1),[e,c]=m.useState({name:"WP User Registration",type:"WP User Registration",action_type:"new_user",user_map:g("new_user"),meta_map:[{}],condition:{action_behavior:"",actions:[{field:"",action:"value"}],logics:[{field:"",logic:"",val:""},"or",{field:"",logic:"",val:""}]}});m.useEffect(()=>{var l,r;const i=p({},e);i.action_type||(i.action_type="new_user"),(r=(l=i==null?void 0:i.user_map)==null?void 0:l[0])!=null&&r.userField||(i.user_map=g(i.action_type)),c(i)},[]);const R=i=>{const l=i||"new_user";c(r=>f(p({},r),{action_type:l,user_map:g(l)}))},S=O(e==null?void 0:e.action_type),U=Q((e==null?void 0:e.action_type)||"new_user"),A=()=>{if(!e.action_type){d({show:!0,msg:o("Please select action type","bit-integrations")});return}if(e.action_type==="new_user"&&!e.user_role){d({show:!0,msg:o("User Role can't be empty","bit-integrations")});return}if(!ee(e)&&e.action_type!=="updated_user"){d({show:!0,msg:o("Please map mandatory fields","bit-integrations")});return}b(!0),z(n,s,w,e,N,"","",b)},L=(i,l)=>{const r=p({},e);l?r.condition.action_behavior=i:r.condition.action_behavior="",c(r)},F=i=>{i.target.value&&R(i.target.value)};return t.jsxs("div",{style:{width:900},children:[t.jsx(q,{snack:k,setSnackbar:d}),t.jsx(J,{linkKey:"registration"}),t.jsx("br",{})," ",t.jsxs("div",{children:[t.jsx("div",{className:"mt-3",children:t.jsx("b",{children:o("Select Action","bit-integrations")})}),t.jsx("div",{className:"mt-2",children:t.jsxs("select",{className:"btcd-paper-inp w-5",value:(e==null?void 0:e.action_type)||"new_user",onChange:F,children:[t.jsx("option",{value:"",children:o("Select Action","bit-integrations")}),V.map(i=>t.jsx("option",{value:i.value,disabled:!y(u,i.is_pro),children:y(u,i.is_pro)?i.label:K(i.label)},i.value))]})})]}),t.jsx("br",{}),t.jsx("div",{children:t.jsx(X,{formFields:a,userConf:e,setUserConf:c,userFields:U})}),S&&t.jsxs(t.Fragment,{children:[t.jsx("div",{children:t.jsx(Y,{formFields:a,userConf:e,setUserConf:c})}),t.jsx("div",{className:"mt-4",children:t.jsx("b",{className:"wdt-100",children:o("Utilities","bit-integrations")})}),t.jsx("div",{className:"btcd-hr mt-1"}),t.jsx(Z,{userConf:e,setUserConf:c}),t.jsx("br",{}),t.jsx(D,{note:(e==null?void 0:e.action_type)==="updated_user"?te:ie})]}),(e==null?void 0:e.condition)&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"flx",children:t.jsx(G,{onChange:i=>L(i.target.value,i.target.checked),checked:((_=e==null?void 0:e.condition)==null?void 0:_.action_behavior)==="cond",className:"wdt-200 mt-4 mr-2",value:"cond",title:o("Conditional Logics","bit_integration")})}),t.jsx("br",{}),((x=e==null?void 0:e.condition)==null?void 0:x.action_behavior)==="cond"&&t.jsx(W,{formFields:a,dataConf:e,setDataConf:c})]}),t.jsxs("button",{className:"btn f-left btcd-btn-lg purple sh-sm flx",type:"button",onClick:()=>A(),disabled:h,children:[o("Save","bit-integrations"),h&&t.jsx(H,{size:20,clr:"#022217",className:"ml-2"})]})]})}const te=`
  <ul>
  <li>${o("The user must be logged in when updating profile","bit-integrations")}</li>
  <li>${o("The user cannot change the value of the username field when updating the user profile.","bit-integrations")}</li>
     
  </ul>`,ie=`
  <ul>
  <li>${o("If the Username and Password fields are blank then the user will take the value of the email field as the field and the password will be auto-generated.","bit-integrations")}</li>
  </ul>`;export{xe as default};
