var E=Object.defineProperty;var _=Object.getOwnPropertySymbols;var M=Object.prototype.hasOwnProperty,W=Object.prototype.propertyIsEnumerable;var k=(o,s,n)=>s in o?E(o,s,{enumerable:!0,configurable:!0,writable:!0,value:n}):o[s]=n,m=(o,s)=>{for(var n in s||(s={}))M.call(s,n)&&k(o,n,s[n]);if(_)for(var n of _(s))W.call(s,n)&&k(o,n,s[n]);return o};import{d as q,_ as r,j as t}from"./main.2.8.1.js";import{h as $,d as p,u as z}from"./react-router-dom.9mCuUg3q.js";import{a9 as B,z as D}from"./Note.BeM7sN-p.js";import{S as A}from"./SnackMsg.S8DrwLlT.js";import{C as G,g as H}from"./Integrations.D2bgBas2.js";import{u as w,U as O,C as J,R as K,c as Q}from"./RegistrationActions.D8rEUqfJ.js";import{b as V}from"./Table.DAL7rcPQ.js";import{C as y}from"./CheckBox.Dg5Lw38s.js";import{t as X}from"./tutorialLinks.kMkIDzcD.js";import{T as U}from"./TutorialLink.BAFX--T3.js";import"./CopyIcn.3gZpHton.js";import"./index.wO-AxluA.js";import"./TagifyInput.Cu0YIRbG.js";import"./tagify.YxUZd8Ix.js";function pe({formFields:o,setFlow:s,flow:n,allIntegURL:L}){var j,v;const{formID:g}=$(),[C,h]=p.useState({show:!1}),[N,R]=p.useState([]),S=z(),[b,f]=p.useState(!1),{registration:u}=X,[e,l]=p.useState({name:"WP User Registration",type:"WP User Registration",user_map:[{}],meta_map:[{}],condition:{action_behavior:"",actions:[{field:"",action:"value"}],logics:[{field:"",logic:"",val:""},"or",{field:"",logic:"",val:""}]}});p.useEffect(()=>{var d,c;const a=m({},e);q({},"role/list",null,"GET").then(i=>{i!=null&&i.success&&i!==void 0&&R(Object.values(i==null?void 0:i.data))}),(c=(d=a==null?void 0:a.user_map)==null?void 0:d[0])!=null&&c.userField||(a.user_map=w.filter(i=>i.required).map(i=>({formField:"",userField:i.key,required:i.required}))),l(a)},[]);const P=()=>{if(!e.action_type){h({show:!0,msg:r("Please select action type","bit-integrations")});return}if(!e.user_role&&e.action_type!=="updated_user"){h({show:!0,msg:r("User Role can't be empty","bit-integrations")});return}if(!Q(e)&&e.action_type!=="updated_user"){h({show:!0,msg:r("Please map mandatory fields","bit-integrations")});return}f(!0),H(n,s,L,e,S,"","",f)},T=(a,d)=>{const c=m({},e);d?c.condition.action_behavior=a:c.condition.action_behavior="",l(c)},x=a=>{const d=m({},e),{name:c,value:i}=a.target;a.target.checked&&(d[c]=i),l(m({},d))},F=`
  <ul>
  <li>${r("The user must be logged in when updating profile","bit-integrations")}</li>
  <li>${r("The user cannot change the value of the username field when updating the user profile.","bit-integrations")}</li>
     
  </ul>`,I=`
  <ul>
  <li>${r("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>`;return t.jsxs("div",{style:{width:900},children:[t.jsx(A,{snack:C,setSnackbar:h}),t.jsx(U,{title:"WP User Registration",youTubeLink:u==null?void 0:u.youTubeLink}),t.jsx(U,{title:"WP User Registration",docLink:u==null?void 0:u.docLink}),t.jsx("br",{})," ",t.jsxs("div",{children:[t.jsx(y,{radio:!0,name:"action_type",onChange:x,checked:(e==null?void 0:e.action_type)==="new_user",value:"new_user",title:r("New User Create","bit-integrations")}),t.jsx(y,{radio:!0,name:"action_type",onChange:x,checked:(e==null?void 0:e.action_type)==="updated_user",value:"updated_user",title:r("Updated User","bit-integrations")})]}),t.jsx("br",{}),t.jsx("div",{children:t.jsx(O,{formFields:o,formID:g,userConf:e,setUserConf:l,roles:N,userFields:w})}),t.jsx("div",{children:t.jsx(J,{formFields:o,formID:g,userConf:e,setUserConf:l})}),t.jsx("div",{className:"mt-4",children:t.jsx("b",{className:"wdt-100",children:r("Utilities","bit-integrations")})}),t.jsx("div",{className:"btcd-hr mt-1"}),t.jsx(K,{userConf:e,setUserConf:l}),t.jsx("br",{}),t.jsx(B,{note:(e==null?void 0:e.action_type)==="updated_user"?F:I}),(e==null?void 0:e.condition)&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"flx",children:t.jsx(V,{onChange:a=>T(a.target.value,a.target.checked),checked:((j=e==null?void 0:e.condition)==null?void 0:j.action_behavior)==="cond",className:"wdt-200 mt-4 mr-2",value:"cond",title:r("Conditional Logics","bit_integration")})}),t.jsx("br",{}),((v=e==null?void 0:e.condition)==null?void 0:v.action_behavior)==="cond"&&t.jsx(G,{formFields:o,dataConf:e,setDataConf:l})]}),t.jsxs("button",{className:"btn f-left btcd-btn-lg purple sh-sm flx",type:"button",onClick:()=>P(),disabled:b,children:[r("Save","bit-integrations"),b&&t.jsx(D,{size:20,clr:"#022217",className:"ml-2"})]})]})}export{pe as default};
