"use strict";(self.webpackChunkweb_app=self.webpackChunkweb_app||[]).push([[5128],{12848:(e,t,n)=>{n.d(t,{A:()=>r});var l=n(65043),a=n(33097),o=n.n(a),s=n(89923),i=n(70579);const r=e=>{let{elements:t,name:n,label:a,tooltip:r="",commonPlaceholder:c="",onChange:d,withBorder:h=!1}=e;const[u,m]=(0,l.useState)([""]),f=(0,l.createRef)();(0,l.useEffect)((()=>{if(1===u.length&&""===u[0]&&t&&""!==t){const e=t.split(",");e.push(""),m(e)}}),[t,u]),(0,l.useEffect)((()=>{if(u.length>1){const e=f.current;e&&e.scrollIntoView(!1)}}),[u,f]);const p=(0,l.useCallback)((e=>{d(e)}),[d]),x=(0,l.useRef)(!0);(0,l.useEffect)((()=>{if(x.current)return void(x.current=!1);const e=u.filter((e=>""!==e.trim())).join(",");p(e)}),[u]);const v=e=>{e.persist();let t=[...u];const n=o()(e.target,"dataset.index","0");t[parseInt(n)]=e.target.value,m(t)},g=u.map(((e,t)=>(0,i.jsx)(s.cl_,{id:`${n}-${t.toString()}`,label:"",name:`${n}-${t.toString()}`,value:u[t],onChange:v,index:t,placeholder:c,overlayIcon:t===u.length-1?(0,i.jsx)(s.REV,{}):null,overlayAction:()=>{(e=>{if(""!==e[e.length-1].trim()){const t=[...e];t.push(""),m(t)}})(u)}},`csv-multi-${n}-${t.toString()}`)));return(0,i.jsx)(l.Fragment,{children:(0,i.jsxs)(s.azJ,{sx:{display:"flex"},className:"inputItem",children:[(0,i.jsxs)(s.l1Y,{sx:{alignItems:"flex-start"},children:[(0,i.jsx)("span",{children:a}),""!==r&&(0,i.jsx)(s.azJ,{sx:{marginLeft:5,display:"flex",alignItems:"center","& .min-icon":{width:13}},children:(0,i.jsx)(s.m_M,{tooltip:r,placement:"top",children:(0,i.jsx)(s.azJ,{className:r,children:(0,i.jsx)(s.NTw,{})})})})]}),(0,i.jsxs)(s.azJ,{withBorders:h,sx:{width:"100%",overflowY:"auto",height:150,position:"relative"},children:[g,(0,i.jsx)("div",{ref:f})]})]})})}},5128:(e,t,n)=>{n.r(t),n.d(t,{default:()=>r});var l=n(65043),a=n(89923),o=n(12848),s=n(70579);const i=(e,t,n)=>{let l="on|off"===t?"off":"";if(n.length>0){const t=n.find((t=>t.key===e));t&&(l=t.value||"")}return l},r=e=>{let{onChange:t,fields:n,defaultVals:r,overrideEnv:c}=e;const[d,h]=(0,l.useState)([]),u=n||[],m=r||[];(0,l.useEffect)((()=>{const e=n.map((e=>({key:e.name,value:i(e.name,e.type,m)})));h(e)}),[n,r]),(0,l.useEffect)((()=>{t(d)}),[d]);const f=(e,t,n)=>{const l=[...d];t=t.trim(),l[n]={key:e,value:t},h(l)},p=(e,t)=>{const n=d[t];if(n){const t=null===c||void 0===c?void 0:c[`${n.key}`];if(t)return(0,s.jsx)(a.EmB,{label:e.label,actionButton:(0,s.jsx)(a.xA9,{item:!0,sx:{display:"flex",justifyContent:"flex-end",paddingRight:"10px"},children:(0,s.jsx)(a.m_M,{tooltip:`This value is set from the ${t.overrideEnv} environment variable`,placement:"left",children:(0,s.jsx)(a.D0K,{style:{width:20}})})}),sx:{width:"100%"},children:t.value})}switch(e.type){case"on|off":const l=n?n.value:"off";return(0,s.jsx)(a.dOG,{onChange:n=>{const l=n.target.checked?"on":"off";f(e.name,l,t)},id:e.name,name:e.name,label:e.label,value:"switch_on",tooltip:e.tooltip,checked:"on"===l});case"csv":return(0,s.jsx)(o.A,{elements:n?n.value:"",label:e.label,name:e.name,onChange:n=>{let l="";l=Array.isArray(n)?n.join(","):n,f(e.name,l,t)},tooltip:e.tooltip,commonPlaceholder:e.placeholder,withBorder:!0});case"comment":return(0,s.jsx)(a.hFj,{id:e.name,name:e.name,label:e.label,tooltip:e.tooltip,value:n?n.value:"",onChange:n=>f(e.name,n.target.value,t),placeholder:e.placeholder});default:return(0,s.jsx)(a.cl_,{id:e.name,name:e.name,label:e.label,tooltip:e.tooltip,value:n?n.value:"",onChange:n=>f(e.name,n.target.value,t),placeholder:e.placeholder})}};return(0,s.jsx)(a.Hbc,{withBorders:!1,containerPadding:!1,children:u.map(((e,t)=>(0,s.jsx)(l.Fragment,{children:p(e,t)},e.name)))})}}}]);
//# sourceMappingURL=5128.a4f856c7.chunk.js.map