var P=Object.defineProperty;var j=Object.getOwnPropertySymbols;var T=Object.prototype.hasOwnProperty,$=Object.prototype.propertyIsEnumerable;var v=(o,n,i)=>n in o?P(o,n,{enumerable:!0,configurable:!0,writable:!0,value:i}):o[n]=i,h=(o,n)=>{for(var i in n||(n={}))T.call(n,i)&&v(o,i,n[i]);if(j)for(var i of j(n))$.call(n,i)&&v(o,i,n[i]);return o};import{u as q,k as A,r as m,d as w,h as B,j as t}from"./main-406.js";import{$ as D,h as z,g as G,b as H,d as O,i as J,_ as c,n as K,F as Q,N as k,L as V,s as W}from"./bi.394.85.js";import{u as y,U as X,C as Y,c as Z}from"./bi.442.761.js";import{C as F}from"./bi.492.719.js";import"./bi.704.707.js";import"./bi.701.708.js";function re({allIntegURL:o}){var _,b;const n=q(),{formID:i}=A(),[C,l]=m.useState({show:!1}),[U,N]=m.useState([]),[g,S]=m.useState(!1),[f,E]=w(D),p=B(z),[e,u]=w(G);m.useEffect(()=>{var d,r;const a=h({},e);H({},"role/list",null,"GET").then(s=>{s!=null&&s.success&&s!==void 0&&N(Object.values(s==null?void 0:s.data))}),(r=(d=a==null?void 0:a.user_map)==null?void 0:d[0])!=null&&r.userField||(a.user_map=y.filter(s=>s.required).map(s=>({formField:"",userField:s.key,required:s.required}))),u(a)},[]);const I=()=>{if(!e.action_type){l({show:!0,msg:c("Please select action type","bit-integrations")});return}if(!e.user_role&&e.action_type!=="updated_user"){l({show:!0,msg:c("User Role can't be empty","bit-integrations")});return}if(!Z(e)&&e.action_type!=="updated_user"){l({show:!0,msg:c("Please map mandatory fields","bit-integrations")});return}W({flow:f,setFlow:E,allIntegURL:o,conf:e,navigate:n,edit:1,setIsLoading:S,setSnackbar:l})},L=(a,d)=>{const r=h({},e);d?r.condition.action_behavior=a:r.condition.action_behavior="",u(r)},x=a=>{const d=h({},e),{name:r,value:s}=a.target;a.target.checked&&(d[r]=s),u(h({},d))},R=`
  <ul>
  <li>The user must be logged in when updating profile</li>
  <li>The user cannot change the value of the username field when updating the user profile.</li>
     
  </ul>`,M=`
  <ul>
  <li>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.</li>
     
  </ul>`;return t.jsxs("div",{children:[t.jsx(O,{snack:C,setSnackbar:l}),t.jsx("br",{}),t.jsx(J,{entity:f.triggered_entity,setSnackbar:l}),t.jsx("div",{className:"font-w-m mt-3",children:c("Action type","bit-integrations")}),t.jsxs("div",{children:[t.jsx(F,{radio:!0,name:"action_type",onChange:x,checked:(e==null?void 0:e.action_type)==="new_user",value:"new_user",title:c("New User Create","bit-integrations")}),t.jsx(F,{radio:!0,name:"action_type",onChange:x,checked:(e==null?void 0:e.action_type)==="updated_user",value:"updated_user",title:c("Updated User","bit-integrations")})]}),t.jsx("div",{children:t.jsx(X,{formFields:p,formID:i,userConf:e,setUserConf:u,roles:U,userFields:y})}),t.jsxs("div",{children:[t.jsx(Y,{formFields:p,formID:i,userConf:e,setUserConf:u}),t.jsx("br",{})]}),(e==null?void 0:e.condition)&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"flx",children:t.jsx(K,{onChange:a=>L(a.target.value,a.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:c("Conditional Logics","bit_integration")})}),t.jsx("br",{}),((b=e==null?void 0:e.condition)==null?void 0:b.action_behavior)==="cond"&&t.jsx(Q,{formFields:p,dataConf:e,setDataConf:u})]}),(e==null?void 0:e.action_type)==="updated_user"?t.jsx(k,{note:R}):t.jsx(k,{note:M}),t.jsxs("button",{className:"btn f-left btcd-btn-lg purple sh-sm flx",type:"button",onClick:I,disabled:g,children:[c("Update","bit-integrations"),g&&t.jsx(V,{size:20,clr:"#022217",className:"ml-2"})]})]})}export{re as default};
