@elastic-suite/gally-admin-components
Version:
Components package for gally admin BO
1 lines • 350 kB
JavaScript
var Jf=Object.defineProperty,Xf=Object.defineProperties;var $f=Object.getOwnPropertyDescriptors;var Zr=Object.getOwnPropertySymbols;var Vl=Object.prototype.hasOwnProperty,Rl=Object.prototype.propertyIsEnumerable;var Ul=Math.pow,zl=(e,o,t)=>o in e?Jf(e,o,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[o]=t,u=(e,o)=>{for(var t in o||(o={}))Vl.call(o,t)&&zl(e,t,o[t]);if(Zr)for(var t of Zr(o))Rl.call(o,t)&&zl(e,t,o[t]);return e},x=(e,o)=>Xf(e,$f(o));var M=(e,o)=>{var t={};for(var r in e)Vl.call(e,r)&&o.indexOf(r)<0&&(t[r]=e[r]);if(e!=null&&Zr)for(var r of Zr(e))o.indexOf(r)<0&&Rl.call(e,r)&&(t[r]=e[r]);return t};var Y=(e,o,t)=>new Promise((r,n)=>{var i=l=>{try{a(t.next(l))}catch(p){n(p)}},s=l=>{try{a(t.throw(l))}catch(p){n(p)}},a=l=>l.done?r(l.value):Promise.resolve(l.value).then(i,s);a((t=t.apply(e,o)).next())});import ki,{forwardRef as Yf}from"react";import{IconButton as Qf,Alert as Zf}from"@mui/material";import{styled as eg}from"@mui/system";import{useTranslation as og}from"next-i18next";import Ai from"react";var Wl="|";function jf(e){let o=e.filter(t=>t);return o.length>0?`${Wl}${o.join(Wl)}`:""}function S(e,...o){return`${e}${jf(o)}`}typeof window!="undefined"&&import("ionicons/dist/cjs/ionicons.cjs");var Oi={dashboard:"home2",arrow:"arrow",telescope:"telescope-outline","push-pin":"push-pin"},Ni={analyze:"analytics",informationCircle:"information-circle-outline",merchandize:"funnel-outline",minus:"remove-circle",monitoring:"list",more:"add-circle",settings:"settings-outline",import_export:"swap-vertical-outline"},BA=[...Object.keys(Oi),...Object.keys(Ni)];function Di(e,o){return`/images/ionicons/${o?"custom/":""}${e}.svg`}function Kf(e){let a=e,{name:o,tooltip:t,componentId:r}=a,n=M(a,["name","tooltip","componentId"]),i=t?{color:"#8187B9",width:"20px",height:"20px",display:"flex"}:{},s=x(u({},n),{style:u(u({},i),n.style)});return o in Oi?Ai.createElement("ion-icon",u({src:Di(Oi[o],!0),"data-testid":S("ionicon",r)},s)):o in Ni?Ai.createElement("ion-icon",u({src:Di(Ni[o]),"data-testid":S("ionicon",r)},s)):Ai.createElement("ion-icon",u({src:Di(o),"data-testid":S("ionicon",r)},s))}var B=Kf;var tg=eg(Zf)(({severity:e,theme:o})=>x(u(u(u({padding:`6px ${o.spacing(2)}`,background:o.palette.colors.neutral[200],border:`1px solid ${o.palette.colors.neutral[300]}`,color:o.palette.colors.neutral[600],borderRadius:8,alignItems:"center"},e==="success"&&{background:o.palette.success.light,color:o.palette.success.main}),e==="warning"&&{background:o.palette.warning.light,color:o.palette.warning.main}),e==="error"&&{background:o.palette.error.light,color:o.palette.error.main}),{"& .MuiAlert-icon":{color:"inherit",marginRight:o.spacing(1)},"& .MuiAlert-message":{padding:0,fontWeight:400,fontSize:"12px",lineHeight:"18px",whiteSpace:"pre-line"},"& .MuiAlert-action":{paddingLeft:"10px",paddingTop:0,paddingBottom:0,paddingRight:0}}));function rg(e,o){let{id:t,message:r,onShut:n,variant:i="info",mb:s=2,children:a}=e,{t:l}=og("alert");function p(){n==null||n(t)}let m=a||l(r);return ki.createElement(tg,{action:ki.createElement(Qf,{"aria-label":"close",color:"inherit",size:"small",onClick:p},ki.createElement(B,{name:"close",style:{fontSize:18,padding:"0px"}})),ref:o,severity:i,sx:{mb:s},"data-testid":S("alert",i)},m)}var Te=Yf(rg);import en from"react";import{Box as Bi}from"@mui/system";import{useTranslation as ng}from"next-i18next";function ig(e,o,t,r){let n=r("boost",{count:o});switch(e){case"up":return{boostText:` x${t} ( ${o} ${n}) `,boostColor:"success.light",boostTextColor:"success.main",boostIconName:"trending-up-outline"};case"down":return{boostText:` x${t} ( ${o} ${n}) `,boostColor:"error.light",boostTextColor:"error.main",boostIconName:"trending-down-outline"};case"straight":return{boostText:"no boost",boostColor:"neutral.light",boostTextColor:"colors.neutral.600",boostIconName:"arrow-forward-outline"}}}function ag(e){let{type:o,boostNumber:t,boostMultiplicator:r}=e,{t:n}=ng("boost"),i=ig(o,t,r,n);return en.createElement(Bi,{sx:{display:"flex",gap:"4px"}},en.createElement(Bi,{sx:{backgroundColor:i.boostColor,color:i.boostTextColor,height:"20px",width:"20px",borderRadius:"50%",display:"flex",justifyContent:"center",alignItems:"center"}},en.createElement(B,{name:i.boostIconName,style:o==="straight"?{width:"14px",height:"14px"}:{width:"14px",height:"8px"}})),t!==void 0&&r!==void 0&&en.createElement(Bi,{sx:{color:i.boostTextColor,fontFamily:"var(--gally-font)",fontWeight:"500",fontSize:"12px",lineHeight:"18px"}},i.boostText))}var _i=ag;import Gl from"react";import{Typography as sg}from"@mui/material";import{styled as Mi}from"@mui/system";var ql=Mi("span")({fontWeight:"500",fontSize:"12px",lineHeight:"18px"}),lg=Mi(ql)(({theme:e})=>({color:e.palette.colors.neutral[500]})),pg=Mi(ql)(({theme:e})=>({color:e.palette.colors.neutral[800]}));function dg(e){let{label:o,last:t}=e;return Gl.createElement(sg,null,Gl.createElement(t?pg:lg,null,o))}var Hi=dg;import Jl from"react";import{Breadcrumbs as ug}from"@mui/material";import{findBreadcrumbLabel as mg,getSlugArray as cg}from"@elastic-suite/gally-admin-shared";function fg(e){let{menu:o,slug:t}=e;if(!t||t.length===0||o.hierarchy.length===0)return null;let r=cg(t).map((n,i,s)=>({key:n,label:mg(i,s,o.hierarchy),last:s.length<=i+1})).filter(({label:n})=>n);return Jl.createElement(ug,{"aria-label":"breadcrumb",sx:{color:"colors.neutral.500"},"data-testid":S("breadcrumbs")},r.map(s=>{var a=s,{key:n}=a,i=M(a,["key"]);return Jl.createElement(Hi,u({key:n},i))}))}var zi=fg;import Vi from"react";import{styled as gg}from"@mui/system";import{IconButton as hg,Chip as bg}from"@mui/material";var Ig=gg(bg)(({theme:e,disabled:o})=>({display:"inline-flex",height:"26px",color:e.palette.colors.neutral[900],fontFamily:"var(--gally-font)",fontWeight:o?400:600,fontSize:o?14:12,lineHeight:"18px",textAlign:"center",alignItems:"center",padding:`2px ${e.spacing(1)}`,background:e.palette.colors.neutral[300],borderRadius:"13px",cursor:"default","&.MuiChip-colorPrimary":{color:e.palette.colors.secondary[600],background:e.palette.colors.secondary[100]},"&.MuiChip-colorSuccess":{color:e.palette.success.main,background:e.palette.success.light},"&.MuiChip-colorWarning":{color:e.palette.warning.main,background:e.palette.warning.light},"&.MuiChip-colorError":{color:e.palette.error.main,background:e.palette.error.light},"&.MuiChip-sizeSmall":{height:"20px"},"& .MuiChip-label":{padding:0},"& .MuiChip-deleteIcon":{color:"inherit",margin:`0 0 0 ${e.spacing(.5)}`,padding:0,fontSize:"14px","&:hover":{color:"inherit",opacity:.5}}}));function xg(e){let{disabled:o,componentId:t}=e,r=S("chip",t);return Vi.createElement(Ig,x(u({disabled:o,"data-testid":r},e),{style:{opacity:1},deleteIcon:Vi.createElement(hg,null,Vi.createElement(B,{name:"close",componentId:S("chipDeleteIcon",r)}))}))}var Le=xg;import yg from"react";import{Box as Tg}from"@mui/material";function Cg({onClose:e}){return yg.createElement(Tg,{sx:{position:"fixed",width:"100vw",height:"100vh",zIndex:99,left:"0",top:"0"},onClick:e})}var Ri=Cg;import ur,{forwardRef as Sg}from"react";import{FormControlLabel as vg,FormHelperText as Eg,Checkbox as Pg}from"@mui/material";function wg(e,o){let b=e,{error:t,helperIcon:r,helperText:n,disabled:i,label:s,list:a,onChange:l,onClick:p,small:m,componentId:d}=b,c=M(b,["error","helperIcon","helperText","disabled","label","list","onChange","onClick","small","componentId"]);function g(h){l&&l(h.target.checked,h)}return ur.createElement(vg,{componentsProps:{typography:{variant:a?"caption":"body2"}},control:ur.createElement(Pg,x(u({},c),{inputRef:o,onChange:g,sx:u(u({},Boolean(a)&&{marginBottom:"-9px",marginTop:"-9px",fontSize:"12px"}),Boolean(m)&&{padding:0,marginLeft:"6px",marginRight:"6px"})})),onClick:p,disabled:i,label:ur.createElement("div",null,s,Boolean(n)&&ur.createElement(Eg,{error:t,"data-testid":S("helperText",d)},Boolean(r)&&ur.createElement(B,{name:r,style:{fontSize:18,marginRight:2}}),n)),sx:u({},Boolean(m)&&{marginLeft:"-6px"}),"data-testid":S("checkbox",d)})}var Fo=Sg(wg);import Eb,{useCallback as Pb}from"react";import{useCallback as ho,useLayoutEffect as Yg,useMemo as cr,useRef as Qg,useState as Zg}from"react";import eh from"next/router";import{useTranslation as mp}from"next-i18next";import qi from"lodash.debounce";import{AuthError as oh,LoadStatus as mr,defaultPageSize as cp,fetchApi as th,fetchApiUsingPagination as rh,getListApiParameters as nh,isError as Ji,storageRemove as ih,tokenStorageKey as ah}from"@elastic-suite/gally-admin-shared";import{useCallback as Fg}from"react";import{closeSnackbar as Lg,enqueueSnackbar as Ag}from"notistack";import{log as Dg}from"@elastic-suite/gally-admin-shared";function Oe(e="error"){return Fg(o=>Dg(o,t=>Ag(t,{onShut:Lg,variant:e,preventDuplicate:!0})),[e])}import{useCallback as nn,useMemo as Gi}from"react";import{useRouter as Xg}from"next/router";import{IMainContext as $g,Method as an,contentTypeHeader as dp,getApiUrl as jg,getResource as Kg,updatePropertiesAccordingToPath as up}from"@elastic-suite/gally-admin-shared";import{createSlice as Og}from"@reduxjs/toolkit";var Ng={api:null,bundles:null,configurations:null},Xl=Og({name:"data",initialState:Ng,reducers:{setData(e,o){e.api=o.payload.api,e.bundles=o.payload.bundles,e.configurations=o.payload.configurations}}}),{setData:$l}=Xl.actions,jl=Xl.reducer,_t=e=>e.data.api,go=e=>e.data.bundles,Ro=e=>e.data.configurations;import{useDispatch as kg,useSelector as Bg}from"react-redux";var Uo=()=>kg(),K=Bg;import{createSlice as _g}from"@reduxjs/toolkit";var Mg={language:"en"},Kl=_g({name:"i18n",initialState:Mg,reducers:{setLanguage(e,o){e.language=o.payload}}}),{setLanguage:Yl}=Kl.actions,Ql=Kl.reducer,Mt=e=>e.i18n.language;import{createSlice as Hg}from"@reduxjs/toolkit";import{LoadStatus as zg}from"@elastic-suite/gally-admin-shared";var Vg={menu:{status:zg.IDLE,data:{hierarchy:[]}},menuItemActive:"",sidebarState:!0,sidebarStateTimeout:!1,childrenState:{}},Zl=Hg({name:"menu",initialState:Vg,reducers:{setChildState(e,o){e.childrenState[o.payload.code]=o.payload.value},setMenu(e,o){e.menu=u(u({},e.menu),o.payload)},setMenuItemActive(e,o){e.menuItemActive=o.payload},setSidebarState(e,o){e.sidebarState=o.payload},setSidebarStateTimeout(e,o){e.sidebarStateTimeout=o.payload}}}),{setChildState:ep,setMenu:on,setMenuItemActive:op,setSidebarState:Ui,setSidebarStateTimeout:tp}=Zl.actions,rp=Zl.reducer,np=e=>e.menu.childrenState,tn=e=>e.menu.menu.data,ip=e=>e.menu.menuItemActive,rn=e=>e.menu.sidebarState,ap=e=>e.menu.sidebarStateTimeout;import{combineReducers as Wg,configureStore as Gg}from"@reduxjs/toolkit";import qg from"redux-thunk";import{createSlice as Rg}from"@reduxjs/toolkit";var Ug={requestedPath:null},sp=Rg({name:"user",initialState:Ug,reducers:{setRequestedPath(e,o){e.requestedPath=o.payload}}}),{setRequestedPath:Wi}=sp.actions,lp=sp.reducer,Ht=e=>e.user.requestedPath;var Jg=Wg({data:jl,i18n:Ql,menu:rp,user:lp}),pp=e=>Gg({middleware:o=>process.env.NODE_ENV==="development"?o({serializableCheck:{ignoredActionPaths:["payload.error"],ignoredPaths:["menu.menu.error"]}}):[qg],preloadedState:e,reducer:Jg});function $(e,o=$g.GRID){let t=K(_t),{asPath:r}=Xg(),n=Gi(()=>r==null?void 0:r.split("?")[0],[r]);return Gi(()=>{let i=Kg(t,e);return x(u({},i),{supportedProperty:(i==null?void 0:i.supportedProperty)instanceof Array?i==null?void 0:i.supportedProperty.map(s=>up(s,n,o)):i!=null&&i.supportedProperty?[up(i.supportedProperty,n,o)]:i==null?void 0:i.supportedProperty})},[t,n,o,e])}function io(e){let{supportedOperation:o}=e,t=ie(),r=jg(e.url),n=nn((l,p)=>t(`${r}/${l}`,void 0,{body:JSON.stringify(p),method:an.PATCH,headers:{[dp]:"application/merge-patch+json"}}),[r,t]),i=nn(l=>{let p=l instanceof FormData,m={body:p?l:JSON.stringify(l),method:an.POST,headers:{[dp]:p?"":"application/ld+json"}};return t(r,void 0,m)},[r,t]),s=nn(l=>t(`${r}/${l.id}`,void 0,{body:JSON.stringify(l),method:an.PUT}),[r,t]),a=nn(l=>t(`${r}/${l}`,void 0,{method:an.DELETE}),[r,t]);return Gi(()=>o.reduce((l,p)=>(typeof p["@type"]=="string"?l.update=n:p["@type"]instanceof Array&&p["@type"].length===2&&typeof p["@type"][1]=="string"&&(p["@type"][1].indexOf("//schema.org/CreateAction")!==-1?l.create=i:p["@type"][1].indexOf("//schema.org/ReplaceAction")!==-1?l.replace=s:p["@type"][1].indexOf("//schema.org/DeleteAction")!==-1&&(l.remove=a)),l),{}),[i,a,s,o,n])}var Xi=1e3;function ie(e=!0){let{i18n:o}=mp("common"),t=Oe(),{t:r}=mp("alert");return ho((n,i,s,a)=>Y(this,null,function*(){try{return yield th(o.language,n,i,s,e)}catch(l){return a!==!1&&(e&&l instanceof oh?(ih(ah),eh.push("/login"),t(r("Expired JWT Token"))):t(l)),{error:l}}}),[o.language,t,e,r])}function ge(e,o,t,r=!0,n=!0,i=!1,s){let a=ie(r),[l,p]=Zg({status:mr.IDLE}),m=ho(g=>{p(b=>x(u({},b),{data:g instanceof Function?g(b.data):g}))},[]),d=ho(()=>{if(n){if(p(g=>({data:g.data,status:mr.LOADING})),!e)return p({data:null,status:mr.SUCCEEDED});s?rh(a,e,o,t,s).then(g=>{p(g)}):a(e,o,t).then(g=>{Ji(g)?p({error:g.error,status:mr.FAILED}):p({data:g,status:mr.SUCCEEDED})})}},[n,a,t,e,o,s]),c=cr(()=>qi(g=>g(),Xi),[]);return Yg(()=>{i?c(d):d()},[d,c,i]),[l,m,d]}function fe(e,o=0,t=cp,r,n,i=!1,s=!1,a=!0){let l=cr(()=>nh(o,t,r,n),[o,t,r,n]),[p,m,d]=ge(e,l,void 0,!0,a,i,s?t:void 0),c=ho(g=>{m(b=>x(u({},b),{"hydra:member":g instanceof Function?g(b["hydra:member"]):g}))},[m]);return[p,c,d]}function fp(e,o=0,t=cp,r,n,i,s=!1){let[a,l,p]=fe(i||e,o,t,r,n,s),{create:m,remove:d,replace:c,update:g}=io(e),b=Qg({}),h=cr(()=>qi((w=!0)=>Y(this,null,function*(){if(w){let O=Object.entries(b.current).map(([L,y])=>(delete b.current[L],g(L,y)));yield Promise.all(O),p()}}),Xi),[p,g]),T=ho((w,O,L=!0)=>{w in b.current?b.current[w]=u(u({},b.current[w]),O):b.current[w]=O,l(y=>y.map(A=>A.id===w?u(u({},A),O):A)),h(L)},[h,l]),E=ho((w,O)=>Y(this,null,function*(){l(y=>y.map(A=>w.includes(A.id)?u(u({},A),O):A));let L=w.map(y=>g(y,O));yield Promise.all(L),p()}),[p,g,l]),C=ho((w,O)=>Y(this,null,function*(){l(y=>y.map(A=>w.includes(A.id)?u(u({},A),O):A));let L=w.map(y=>c(u({id:y},O)));yield Promise.all(L),p()}),[p,c,l]),P=ho(w=>Y(this,null,function*(){let O=yield m(w);!Ji(O)&&a.data["hydra:member"].length<t&&p()}),[m,p,a,t]),I=cr(()=>qi((w=!0)=>Y(this,null,function*(){if(w){let O=Object.entries(b.current).map(([L,y])=>(delete b.current[L],c(y)));yield Promise.all(O),p()}}),Xi),[p,c]),v=ho((w,O=!0)=>{let L=w.id;L in b.current?b.current[L]=u(u({},b.current[L]),w):b.current[L]=w,l(y=>y.map(A=>A.id===w.id?u(u({},A),w):A)),I(O)},[I,l]),D=ho(w=>Y(this,null,function*(){l(L=>L.filter(y=>y.id!==w));let O=yield d(w);(Ji(O)||a.data["hydra:member"].length===t)&&p()}),[p,d,a,t,l]),F=cr(()=>{let w={};return g&&(w.update=T,w.massUpdate=E),m&&(w.create=P),c&&(w.replace=v,w.massReplace=C),d&&(w.remove=D),w},[m,P,D,v,T,E,C,d,c,g]);return[a,F,l]}import{useMemo as gp}from"react";import{useTranslation as sh}from"next-i18next";import{getFilter as lh,getMappings as ph}from"@elastic-suite/gally-admin-shared";function hp(e,o){let{t}=sh("api"),r=gp(()=>ph(e,o),[e,o]);return gp(()=>r.map(n=>lh(n,t)),[r,t])}import{useTranslation as uh}from"next-i18next";import{useMemo as ji}from"react";import{getFieldHeader as mh}from"@elastic-suite/gally-admin-shared";import{useMemo as dh}from"react";function bp(e){return dh(()=>{let t=e.supportedProperty.map(r=>{var n;return((n=r==null?void 0:r.gally)==null?void 0:n.input)==="rangeDate"?x(u({},r),{title:"doubleDatePicker"}):r}).reduce((r,n)=>{var s;let i=(s=n==null?void 0:n.gally)==null?void 0:s.rangeDateId;return r.some(a=>{var l,p;return((l=a==null?void 0:a.gally)==null?void 0:l.rangeDateId)===i&&((p=a==null?void 0:a.gally)==null?void 0:p.rangeDateId)})||r.push(n),r},[]);return x(u({},e),{supportedProperty:t})},[e])}function Ki(e){let{t:o}=uh("api"),t=bp(e);return ji(()=>t.supportedProperty.filter(r=>{var n;return(n=r.gally)==null?void 0:n.visible}).sort((r,n)=>{var i,s;return((i=r.gally)==null?void 0:i.position)-((s=n.gally)==null?void 0:s.position)}).map(r=>mh(r,o)),[o,t])}var $i="_other";function Ip(e){let o=Ki(e);return ji(()=>{let t=o.reduce((r,s)=>{var a=s,{gridHeaderInfoTooltip:n}=a,i=M(a,["gridHeaderInfoTooltip"]);var m,d;let l=i.fieldset,p=(d=(m=e.gally)==null?void 0:m.fieldset)==null?void 0:d[l];return l&&p?l in r?r[l].children.push(i):r[l]=x(u({},p),{code:l,children:[i]}):r[$i].children.push(i),r},{[$i]:{code:$i,children:[],position:1/0}});return Object.values(t).sort((r,n)=>(r==null?void 0:r.position)-(n==null?void 0:n.position))},[o,e])}function xp(e){return ji(()=>e.supportedProperty.filter(o=>{var t,r;return((t=o.gally)==null?void 0:t.visible)&&((r=o.gally)==null?void 0:r.editable)&&o.writeable}).map(o=>({id:o.title,label:o.property.label,value:o})),[e])}import{getLocalizedCatalog as ch}from"@elastic-suite/gally-admin-shared";import{useMemo as sn,useState as yp}from"react";function Tp(e){let[o,t]=yp(-1),[r,n]=yp(-1),i=sn(()=>e.find(l=>l.id===o),[o,e]),s=sn(()=>i==null?void 0:i.localizedCatalogs.find(l=>l.id===r),[i,r]),a=sn(()=>e?ch(e,i,s):null,[i,e,s]);return sn(()=>({catalog:i,catalogId:o,catalogs:e,localizedCatalog:s,localizedCatalogId:r,localizedCatalogWithDefault:a,localizedCatalogIdWithDefault:a?String(a==null?void 0:a.id):"",setCatalogId:t,setLocalizedCatalogId:n}),[i,o,e,s,r,a,t,n])}import{useEffect as fh}from"react";import{LoadStatus as Yi,useSchemaLoader as gh}from"@elastic-suite/gally-admin-shared";function Cp(){let e=Uo(),o=Oe(),t=gh(),[r]=ge("extra_bundles",void 0,void 0,!1),[n]=ge("public_configurations",void 0,void 0,!1);fh(()=>{t.status===Yi.FAILED&&o(t.error),r.status===Yi.FAILED&&o(r.error),n.status===Yi.FAILED&&o(n.error),t.data&&r.data&&n.data&&e($l({api:t.data,bundles:r.data["hydra:member"].map(i=>i.name),configurations:Object.fromEntries(n.data["hydra:member"].map(i=>[i.path,i.value]))}))},[t,r,n,e,o])}import{useEffect as hh,useMemo as bh,useState as Qi}from"react";import{useRouter as ln}from"next/router";import{getApiFilters as Ih,getAppUrl as xh,getFilterParameters as yh,getPageParameter as Th,getParametersFromUrl as Zi,getRouterUrl as ea,getSearchParameter as Ch}from"@elastic-suite/gally-admin-shared";function pn(e=0,o,t,r=!0,n){let i=ln();hh(()=>{if(r){let s=xh(i.asPath,e,o,t,n);i.asPath!==s.pathname+s.search&&i.push(s.href,void 0,{shallow:!0})}},[r,o,e,i,t,n])}function Sp(e){let o=ln(),[t,r]=Qi(()=>{let n=ea(o.asPath),i=Zi(n,e);return Th(i,e)});return[t,r]}function Re(e,o){var s;let t=ln(),r=o!=null?o:(s=e==null?void 0:e.title)==null?void 0:s.toLowerCase(),[n,i]=Qi(()=>{let a=ea(t.asPath),l=Zi(a,r);return yh(e,l)});return[n,i]}function vp(e){let o=ln(),[t,r]=Qi(()=>{let n=ea(o.asPath),i=Zi(n,e);return Ch(i,e)});return[t,r]}function Ep(...e){return bh(()=>Ih(Object.assign({},...e)),e)}import{useCallback as Pp,useEffect as Sh,useMemo as vh,useRef as Eh,useState as wp}from"react";import{useTranslation as Ph}from"next-i18next";import{getFormValidityError as wh}from"@elastic-suite/gally-admin-shared";function ye(e,o,t=!1,r,n=!1,i){let[s,a]=wp(""),l=Eh(null),{t:p}=Ph("common"),[m,d]=wp(!1),c=Pp((b,h,T)=>{var C,P;let E=null;if(r&&(E=r(b,h),(C=l.current)==null||C.setCustomValidity(E!=null?E:"")),(E===null||E==="")&&((h==null?void 0:h.target)||T&&l.current)){let I=T&&l.current?l.current.validity:(P=h==null?void 0:h.target)==null?void 0:P.validity;I!=null&&I.valid||(E=wh(I))}return a(E||""),E===null||E===""},[l,r]);Sh(()=>{m||c(o,void 0,!0)},[c,o,m]);let g=Pp((b,h)=>{m||d(!0),c(b,h),e&&e(b,h)},[e,c,m]);return vh(()=>{let b={error:n?!1:t?Boolean(s):!1,onChange:g,ref:l};return n?(b.helperIcon="",b.helperText=""):s&&t&&(b.helperIcon="close",b.helperText=p(`formError.${(i==null?void 0:i[s])||s}`)),[b,h=>{var T;a(h),(T=l.current)==null||T.setCustomValidity(h!=null?h:"")}]},[s,g,p,n,t,i])}import{useCallback as oa,useEffect as Fh,useState as Lh}from"react";import Ah from"next/router";import{useTranslation as Fp}from"next-i18next";import{AuthError as Dh,LoadStatus as dn,fetchGraphql as Oh,isError as Nh,storageRemove as kh,tokenStorageKey as Bh}from"@elastic-suite/gally-admin-shared";function ta(e=!0){let{i18n:o}=Fp("common"),t=Oe(),{t:r}=Fp("alert");return oa((n,i,s)=>Y(this,null,function*(){try{return yield Oh(o.language,n,i,s,e)}catch(a){return e&&a instanceof Dh?(kh(Bh),Ah.push("/login"),t(r("Expired JWT Token"))):t(a),{error:a}}}),[o.language,t,e,r])}function bo(e,o,t,r=!0){let n=ta(),[i,s]=Lh({status:dn.IDLE}),a=oa(p=>{s(m=>x(u({},m),{data:p instanceof Function?p(m.data):p}))},[]),l=oa(()=>{r&&(s(p=>({data:p.data,status:dn.LOADING})),n(e,o,t).then(p=>{Nh(p)?s({error:p.error,status:dn.FAILED}):s({data:p,status:dn.SUCCEEDED})}))},[r,n,t,e,o]);return Fh(()=>{l()},[l]),[i,a,l]}import{useLayoutEffect as _h,useState as ra}from"react";var Lp=e=>{let[o,t]=ra(!1),[r,n]=ra(!1),[i,s]=ra(!1);return _h(()=>{function a(){if(e){let l=e.scrollWidth>e.clientWidth;if(t(l),l){let p=m=>{let d=m.target,{clientWidth:c,scrollLeft:g,scrollWidth:b}=d;n(g>0),s(g+c>=b-20)};return e.addEventListener("scroll",p),()=>e.removeEventListener("scroll",p)}}}a()},[e]),{isAtEnd:i,isOverflow:o,shadow:r}};import{useTranslation as zh}from"next-i18next";import{useCallback as Vh,useMemo as Rh}from"react";import{getOptionsFromApiSchema as Uh,getOptionsFromResource as Wh,getReferencedResource as Gh,hasFieldOptions as qh,isDropdownStaticOptions as Jh,isError as Dp,isReferenceField as Xh}from"@elastic-suite/gally-admin-shared";import{useCallback as Ap,useRef as Mh,useState as Hh}from"react";import{LoadStatus as na}from"@elastic-suite/gally-admin-shared";function un(e=new Map){let o=ie(),[t,r]=Hh(e),n=Mh(new Map),i=Oe(),s=Ap((l,p)=>{n.current.set(l,na.SUCCEEDED),r(m=>{let d=new Map(m);return d.set(l,p),d})},[]);return{fetch:Ap((l,p)=>Y(this,null,function*(){if(!n.current.get(l)){n.current.set(l,na.LOADING);try{let d=yield p(o);s(l,d)}catch(d){i(d),n.current.set(l,na.FAILED)}}}),[o,s,i]),map:t,setMap:r,statuses:n}}function Op(){let{fetch:e,map:o,statuses:t}=un(),r=K(_t),{t:n}=zh("options"),i=Vh(s=>{let a=s.property["@id"];return e(a,l=>Y(this,null,function*(){var p,m;if(qh(s)){if(Jh((p=s.gally)==null?void 0:p.options))return s.gally.options.values.map(c=>x(u({},c),{label:c==null?void 0:c.label}));let d=yield l(s.gally.options.api_rest);if(!Dp(d))return Uh(d);throw new Error("error")}else if(Xh(s)){let d=yield l((m=Gh(r,s))==null?void 0:m.url);if(!Dp(d))return Wh(d);throw new Error("error")}}))},[r,e]);return Rh(()=>{let s=new Map(o);return s.forEach(a=>a.forEach(l=>{l.label=n(l.label)})),{fieldOptions:s,load:i,statuses:t}},[i,o,t,n])}import{useEffect as $h,useMemo as Np,useState as jh}from"react";import Kh from"lodash.debounce";import{isError as Yh,isRuleValid as Qh,isVirtualCategoryEnabled as Zh,serializeRule as eb}from"@elastic-suite/gally-admin-shared";var ob=200;function WO(e,o){let t=K(go),r=ie(),[n,i]=jh(null),s=Zh(t),a=!(e!=null&&e.isVirtual)||Qh(e==null?void 0:e.virtualRule),l=Np(()=>Kh(m=>Y(this,null,function*(){let d=yield r("rule_engine_graphql_filters",void 0,{body:JSON.stringify({rule:m}),method:"POST"});Yh(d)||i(d.graphQlFilters)}),ob),[r]);return $h(()=>{s&&(e==null?void 0:e.isVirtual)&&(e==null?void 0:e.virtualRule)&&a&&l(JSON.stringify(eb(e.virtualRule,o)))},[t,e==null?void 0:e.isVirtual,e==null?void 0:e.virtualRule,l,s,a,o]),[Np(()=>s&&(e==null?void 0:e.isVirtual)&&n?n:null,[e,s,n]),i]}import{useEffect as tb,useState as rb}from"react";import{isError as nb,isVirtualCategoryEnabled as ib}from"@elastic-suite/gally-admin-shared";function zt(e){let[o,t]=rb(),r=K(go),n=ie();return tb(()=>{ib(r)&&!e&&n("rule_engine_operators").then(i=>{nb(i)||t(i)})},[r,n,e]),e!=null?e:o}import{useCallback as cb,useContext as fb}from"react";import gb,{useRouter as hb}from"next/router";import{getRouterPath as bb}from"@elastic-suite/gally-admin-shared";import{createContext as ab}from"react";var W=ab(null);import{createContext as sb}from"react";var se=sb(null);import{createContext as lb}from"react";var kp=lb(null);import{createContext as pb}from"react";var Wo=pb([]);import{createContext as db}from"react";var Io=db(null);import{createContext as ub}from"react";var mn=ub(null);import{createContext as mb}from"react";var Vt=mb(!0);var Bp=(t=>(t[t.EXACT=0]="EXACT",t[t.PARTIAL=1]="PARTIAL",t))(Bp||{});function Go(e,o=0){var a;let{asPath:t}=hb(),r=bb(t),n=fb(Vt),i=(a=e.find(l=>o===0?l.url===r:r===l.url||r.startsWith(`${l.url}/`)))!=null?a:e.find(l=>l.default),s=cb(l=>{let p=e.find(m=>m.id===l);p&&n&&gb.push(p.url,void 0,{shallow:!0})},[e,n]);return[i,s]}import{getUser as Ib,storageGet as xb,tokenStorageKey as yb}from"@elastic-suite/gally-admin-shared";import{useMemo as Tb}from"react";function ve(){let e=xb(yb);try{return Tb(()=>Ib(e),[e])}catch(o){return null}}import{useEffect as Cb,useRef as Sb,useState as vb}from"react";var _p=()=>{let e=Sb(null),[o,t]=vb(!1);return Cb(()=>{let r=new MutationObserver(()=>{var n;t(Boolean((n=e.current)==null?void 0:n.checkValidity()))});return r.observe(e.current,{childList:!0,subtree:!0,attributes:!0}),()=>r.disconnect()},[e]),{formRef:e,formIsValid:o}};function wb(e){let l=e,{onChange:o,showError:t,additionalValidator:r}=l,n=M(l,["onChange","showError","additionalValidator"]),i=Pb((d,c)=>r?r(d,c):"",[r]),[p]=ye(o,n.checked,t,i,n.disabled),m=p,{ref:s}=m,a=M(m,["ref"]);return Eb.createElement(Fo,x(u(u({},n),a),{error:(n==null?void 0:n.error)||(a==null?void 0:a.error),helperIcon:(n==null?void 0:n.helperIcon)||(a==null?void 0:a.helperIcon),helperText:(n==null?void 0:n.helperText)||(a==null?void 0:a.helperText),ref:s}))}var Fb=wb;import hr,{forwardRef as Jb}from"react";import{DatePicker as Xb}from"@mui/x-date-pickers/DatePicker";import{PickersDay as $b,pickersDayClasses as Wp}from"@mui/x-date-pickers/PickersDay";import{styled as jb}from"@mui/system";import Jo,{forwardRef as Ub}from"react";import{FormHelperText as Wb,InputLabel as Gb}from"@mui/material";function Mp(e,o){let t;function r(n){return n.id===e.id?(t=n,!0):n.children&&n.children.length>0?n.children.some(r):!1}return o.some(r),t!=null?t:o[0]}function Rt(e){let o=[],t=e.filter(r=>r.sticky).length;return e.filter(r=>r.sticky).map((r,n)=>o.push(u({isLastSticky:!(n<t-1)},r))),o}function cn(e,o,t,r){t(e.target.checked?r.concat(o):r.filter(n=>n!==o))}function qo(e){return u({borderBottomColor:"colors.neutral.300",borderRight:"2px solid",borderRightColor:"colors.neutral.600"},e&&{boxShadow:"5px 0 460px -10px",clipPath:"inset(0px -15px 0px 0px)"})}import{concatenateValuesWithLineBreaks as Lb}from"@elastic-suite/gally-admin-shared";import{closeSnackbar as Hp,enqueueSnackbar as zp}from"notistack";function fr(e,o){let{required:t,type:r}=o;return r==="number"?e===""&&!t?null:Number(e):e}function Ab(e){switch(e){case"fromDate":case"toDate":return"doubleDatePicker";default:return e}}function Db(e){return{fromDate:e==null?void 0:e.fromDate,toDate:e==null?void 0:e.toDate}}function fn(e,o){var r;if(!e)return null;let t={};return(r=o==null?void 0:o.data)==null||r["hydra:member"].forEach(n=>{var i;t[`${n.value}Limitations`]=(i=e[`${n.value}Limitations`])!=null?i:[]}),x(u({},t),{requestTypes:e.requestTypes})}function gn(e,o){var r;let t={fields:{},global:[]};return(r=e==null?void 0:e.violations)==null||r.forEach(n=>{(n==null?void 0:n.propertyPath)&&(n==null?void 0:n.message)?t.fields[Ab(n==null?void 0:n.propertyPath)]=n.message:n!=null&&n.message&&t.global.push(n.message)}),zp(o("error.form"),{onShut:Hp,variant:"error"}),t.global.length!==0&&zp(Lb(t.global),{onShut:Hp,variant:"error",style:{whiteSpace:"pre-line"},autoHideDuration:1/0}),t}function Vp(e,o){var r,n;let[t]=fe(e&&(e==null?void 0:e.input)==="requestType"?(n=(r=e==null?void 0:e.requestTypeConfigurations)==null?void 0:r.limitationTypeOptionsApi)!=null?n:"boost_limitation_type_options":e&&typeof e=="string"?e:void 0);if(!e)return null;if(typeof e=="string")return fn(o,t);switch(e==null?void 0:e.input){case"requestType":return fn(o,t);case"date":case"rangeDate":return Db(o);default:return o==null?void 0:o[e.name]}}import{DataContentType as Rp,reorderingColumnWidth as Ob,stickyColumnMaxWidth as Nb,stickyColumnWidth as kb}from"@elastic-suite/gally-admin-shared";function hn(e,o,t,r){return x(u(u({minWidth:`${Ob}px`},!e&&{borderRight:"none"}),e&&t&&qo(r)),{backgroundColor:"colors.white",zIndex:"1",left:`${o}px`})}var Up={fontSize:"x-large",position:"absolute",left:"18.75%",right:"18.75%",top:"36.33%",bottom:"36.33%",color:"colors.white",display:"flex",alignItems:"center","&:hover":{color:"colors.neutral.500",cursor:"grab"}};function bn(e,o,t,r){return u(u({zIndex:"1",minWidth:`${kb}px`,maxWidth:`${Nb}px`,left:`${e}px`,borderBottomColor:"colors.neutral.300",backgroundColor:"colors.white"},t&&qo(o)),r===Rp.SELECT&&{overflow:"visible"})}function In(e,o,t,r){return u({left:`${o}px`,borderBottomColor:"colors.neutral.300",backgroundColor:"colors.white",zIndex:"1"},e&&r===0&&qo(t))}function xn(e){return u({backgroundColor:"colors.white",borderBottomColor:"colors.neutral.300"},e===Rp.SELECT&&{overflow:"visible"})}import yn from"react";import Bb from"react";import{Tooltip as _b}from"@mui/material";function Mb(e){let r=e,{className:o}=r,t=M(r,["className"]);return Bb.createElement(_b,x(u({},t),{arrow:!0,classes:{popper:o}}))}var at=Mb;function Hb({title:e,children:o,noStyle:t,withHTMLTitle:r}){return yn.createElement(at,{title:typeof e=="string"&&r?yn.createElement("span",{dangerouslySetInnerHTML:{__html:e}}):e,placement:"right"},yn.createElement("span",{style:{display:"inline-block",paddingLeft:t?"":"10px",marginBottom:t?"":"-5px"}},o||yn.createElement(B,{name:"informationCircle",tooltip:!0})))}var re=Hb;import{FormControl as zb,InputBase as Vb}from"@mui/material";import{styled as Tn}from"@mui/system";var xo=Tn(zb)(({fullWidth:e,theme:o})=>u({"& .MuiFormLabel-root":{color:o.palette.colors.neutral[900]},"& .MuiFormLabel-root.Mui-error":{color:o.palette.colors.neutral[900]},"& label":{position:"relative"}},e&&{".MuiInputBase-root":{width:"100%",maxWidth:"initial"}})),Rb=["dirty","small","transparent"],gr=Tn(Vb,{shouldForwardProp:e=>!Rb.includes(e)})(({dirty:e,inputProps:o,small:t,theme:r,transparent:n,type:i,value:s})=>{let a;return i==="number"&&(a="3em"),o!=null&&o.max&&(a=`${Math.max(String(o.max).length,3)}em`),o!=null&&o.maxLength&&(a=`${Math.max(o.maxLength,3)}em`),x(u(u(u(u(u({minHeight:"40px",borderRadius:8,borderStyle:"solid",borderWidth:"1px",borderColor:r.palette.colors.neutral[300],padding:`3px ${r.spacing(2)}`,minWidth:a?"unset":180,backgroundColor:r.palette.colors.white,color:r.palette.colors.neutral[900],fontSize:14,lineHeight:0,fontWeight:400,transition:"border-color 0.3s linear"},Boolean(s)&&{borderColor:r.palette.colors.neutral[400]}),t===!1&&{".MuiAutocomplete-input":{width:"auto!important"}}),Boolean(t)&&{minHeight:"26px",minWidth:"initial",width:"max-content",paddingTop:0,paddingBottom:0,paddingLeft:r.spacing(1),paddingRight:r.spacing(1),borderRadius:"13px"}),Boolean(n)&&{background:"transparent",border:"0"}),Boolean(e)&&{fontWeight:"bold"}),{"& .MuiInputBase-input":u(u({padding:0,width:a,"&::placeholder":{color:r.palette.colors.neutral[600],opacity:1},"&.Mui-disabled":{color:r.palette.colors.neutral[600],WebkitTextFillColor:r.palette.colors.neutral[600],"&.MuiInputBase-inputAdornedEnd":{color:r.palette.colors.neutral[500],WebkitTextFillColor:r.palette.colors.neutral[500]}}},Boolean(t)&&{width:"72px",fontSize:"12px",fontWeight:"bold"}),t===!1&&{fontWeight:"bold",fontSize:"12px"}),"&:hover":{borderColor:r.palette.colors.neutral[400]},"&:focus-within":u({borderColor:r.palette.colors.neutral[600]},Boolean(n)&&{backgroundColor:"rgba(0, 0, 0, 0.075)"}),"& .MuiInputBase-input::placeholder":u({color:r.palette.colors.neutral[600],opacity:1},Boolean(t)&&{fontWeight:"normal"}),"&.MuiInputBase-colorSuccess":{borderColor:r.palette.success.main},"&.MuiInputBase-colorError":{borderColor:r.palette.error.main},"&.Mui-error":{borderColor:r.palette.error.main},"&.Mui-disabled":{borderColor:r.palette.colors.neutral[300],backgroundColor:r.palette.colors.neutral[300]},"& .MuiInputAdornment-root":{fontSize:14,color:r.palette.colors.neutral[900]},"&.MuiAutocomplete-inputRoot":{maxWidth:"400px"},"& .MuiAutocomplete-endAdornment":{top:0,right:"12px",height:"100%",display:"flex",alignItems:"center"},"& .MuiAutocomplete-popupIndicator ion-icon, & .MuiAutocomplete-clearIndicator ion-icon":{fontSize:14,color:r.palette.colors.neutral[900]},"& .MuiAutocomplete-tag":{marginTop:"2px",marginBottom:"2px"}})}),Cn=Tn("div")(({theme:e})=>({alignItems:"center",display:"flex","label + &":{marginTop:e.spacing(.5)}})),Sn=Tn("span")(({theme:e})=>({fontFamily:"var(--gally-font)",fontSize:"14px",fontWeight:400,lineHeight:"20px",textAlign:"center",color:e.palette.colors.neutral[600],marginLeft:e.spacing(1)}));function qb(e,o){let P=e,{error:t,fullWidth:r,helperText:n,helperIcon:i,id:s,infoTooltip:a,label:l,margin:p,onChange:m,required:d,suffix:c,value:g,requiredLabel:b,componentId:h,inputProps:T}=P,E=M(P,["error","fullWidth","helperText","helperIcon","id","infoTooltip","label","margin","onChange","required","suffix","value","requiredLabel","componentId","inputProps"]);function C(I){let{value:v}=I.target;m&&m(fr(v,e),I)}return Jo.createElement(xo,{error:t,fullWidth:r,margin:p,variant:"standard"},Boolean(l||a)&&Jo.createElement(Gb,{shrink:!0,htmlFor:s,required:b||d},l,a?Jo.createElement(re,{title:a}):null),Jo.createElement(Cn,{className:"InputText__Wrapper"},Jo.createElement(gr,u({id:s,onChange:C,required:d,ref:o,value:(g!=null?g:"").toString(),inputProps:u({"data-testid":S("inputText",h)},T)},E)),Boolean(c)&&Jo.createElement(Sn,null,c)),Boolean(n)&&Jo.createElement(Wb,{"data-testid":S("helperText",h)},Boolean(i)&&Jo.createElement(B,{name:i,style:{fontSize:18,marginRight:2}}),n))}var Ae=Ub(qb);import{useTranslation as Kb}from"next-i18next";import{createUTCDateSafe as Yb}from"@elastic-suite/gally-admin-shared";var Qb=jb($b,{shouldForwardProp:e=>e!=="dayIsBetween"&&e!=="isFirstDay"&&e!=="isLastDay"})(({theme:e})=>({fontWeight:500,[`&&.${Wp.selected}`]:{backgroundColor:e.palette.colors.primary[400],color:"white"},[`&&.${Wp.selected}, &:hover, &:focus`]:{backgroundColor:e.palette.colors.primary[400],color:"white"}}));function Zb(){return hr.createElement(B,{name:"calendar-outline",style:{fontSize:18,padding:"0px"}})}function eI(){return hr.createElement(B,{name:"chevron-down-outline",style:{fontSize:18,padding:"0px"}})}function oI(e,o){let{t}=Kb("common"),m=e,{value:r,onChange:n,onError:i,componentId:s}=m,a=M(m,["value","onChange","onError","componentId"]);function l(d){let c=d;d instanceof Date&&(c=Yb(d)),n(c)}return hr.createElement(Xb,{value:r,onChange:l,onError:i,renderDay:(d,c,g)=>hr.createElement(Qb,u({},g)),components:{OpenPickerIcon:Zb,SwitchViewIcon:eI},inputRef:o,renderInput:d=>{let P=d,{InputProps:c,inputProps:g}=P,b=M(P,["InputProps","inputProps"]),{onChange:h,readOnly:T,type:E,value:C}=g;return hr.createElement(Ae,x(u(u(u({},c),b),a),{onChange:(I,v)=>h(v),placeholder:t("date.placeholder"),readOnly:T,ref:d.ref,type:E,value:C,componentId:s}))}})}var Ut=Jb(oI);import tI,{useCallback as rI}from"react";import{isValid as nI}from"date-fns";function vn(e,o,t,r){return r?r(e,o):!e&&t?"valueMissing":!e||nI(e)?"":"invalidDate"}function iI(e){let m=e,{onChange:o,showError:t,additionalValidator:r}=m,n=M(m,["onChange","showError","additionalValidator"]),i=rI((b,h)=>vn(b,h,n.required,r),[r,n.required]),[d,...c]=ye(o,n.value,t,i,n.disabled),g=d,{ref:s}=g,a=M(g,["ref"]),[l]=c;function p(b){l(b)}return tI.createElement(Ut,x(u(u({},n),a),{error:(n==null?void 0:n.error)||(a==null?void 0:a.error),helperIcon:(n==null?void 0:n.helperIcon)||(a==null?void 0:a.helperIcon),helperText:(n==null?void 0:n.helperText)||(a==null?void 0:a.helperText),onError:p,ref:s}))}var ia=iI;import Ye,{forwardRef as sI}from"react";import{Box as lI,FormHelperText as pI,Grid as aa,InputLabel as dI}from"@mui/material";import{useTranslation as uI}from"next-i18next";import{styled as mI}from"@mui/system";import{styled as aI}from"@mui/system";var Xo=aI("div")(({fullWidth:e,margin:o,theme:t})=>u(u(u(u({display:"inline-flex",flexDirection:"column",position:"relative",minWidth:0,padding:0,margin:0,border:0,verticalAlign:"top","& .MuiFormLabel-root":{color:t.palette.colors.neutral[900],fontFamily:"var(--gally-font)",padding:0,display:"block",transformOrigin:"top left",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:"133%",position:"relative",left:0,top:0,transform:"none",fontWeight:500,lineHeight:"20px",fontSize:"14px"},"& .MuiFormLabel-root.Mui-error":{color:t.palette.colors.neutral[900]}},o==="normal"&&{marginTop:16,marginBottom:8}),o==="dense"&&{marginTop:8,marginBottom:4}),e&&{width:"100%"}),e&&{".MuiInputBase-root":{width:"100%",maxWidth:"initial"}}));var Gp=mI(lI)(({theme:e})=>({fontWeight:500,fontFamily:"var(--gally-font)",fontSize:"14px",lineHeight:"20px",color:e.palette.colors.neutral[600]}));function cI(e,o){let F=e,{value:t,error:r,errors:n,fullWidth:i,helperText:s,helperIcon:a,id:l,infoTooltip:p,inputProps:m,label:d,margin:c,onChange:g,onError:b,required:h,componentId:T}=F,E=M(F,["value","error","errors","fullWidth","helperText","helperIcon","id","infoTooltip","inputProps","label","margin","onChange","onError","required","componentId"]),{t:C}=uI("common");function P(w){g(x(u({},t),{fromDate:w}))}function I(w){g(x(u({},t),{toDate:w}))}function v(w){b&&b(x(u({},n),{from:w}))}function D(w){b&&b(x(u({},n),{to:w}))}return Ye.createElement(Xo,{error:r,fullWidth:i,margin:c},Boolean(d||p)&&Ye.createElement(dI,{shrink:!0,htmlFor:l,required:h},d,p?Ye.createElement(re,{title:p}):null),Ye.createElement(aa,{justifyContent:"flex-start",alignItems:"center",container:!0,sx:{marginTop:d?"4px":"0px"}},Ye.createElement(Gp,{sx:{paddingRight:"20px"}}," ",C("form.from")," "),Ye.createElement(aa,{item:!0,xs:!0},Ye.createElement(Ut,x(u({},E),{required:h,error:r,fullWidth:i,inputProps:m,value:t==null?void 0:t.fromDate,onChange:P,onError:v,ref:o,componentId:S("rangeDateFrom",T)}))),Ye.createElement(Gp,{sx:{paddingRight:"20px",paddingLeft:"20px"}},C("form.to")),Ye.createElement(aa,{item:!0,xs:!0},Ye.createElement(Ut,x(u({},E),{required:h,error:r,fullWidth:i,inputProps:m,value:t==null?void 0:t.toDate,onChange:I,onError:D,componentId:S("rangeDateTo",T)})))),Boolean(s)&&Ye.createElement(pI,{error:r,"data-testid":S("helperText",T)},Boolean(a)&&Ye.createElement(B,{name:a,style:{fontSize:18,marginRight:2}}),s))}var sa=sI(cI);import fI,{useCallback as gI}from"react";function hI(e,o,t,r){if(r)return r(e,o);if(t&&(!e.fromDate||!e.toDate))return"valueMissing";let n=typeof e.fromDate=="string"?new Date(e.fromDate):e.fromDate,i=typeof e.toDate=="string"?new Date(e.toDate):e.toDate,s=vn(n);if(s)return s;let a=vn(i);return a||(!e.toDate||!e.fromDate||n<=i?"":"doubleDatePickerRange")}function bI(e){let p=e,{onChange:o,showError:t,additionalValidator:r,replacementErrorsMessages:n}=p,i=M(p,["onChange","showError","additionalValidator","replacementErrorsMessages"]),s=gI((c,g)=>hI(c,g,i.required,r),[r,i.required]),[m]=ye(o,i.value,t,s,i.disabled,n),d=m,{ref:a}=d,l=M(d,["ref"]);return fI.createElement(sa,x(u(u({},i),l),{ref:a}))}var Wt=bI;import Qe,{forwardRef as xI,useMemo as yI,useRef as TI}from"react";import{Autocomplete as CI,FormControl as SI,ListItem as vI,ListSubheader as EI}from"@mui/material";import{useTranslation as PI}from"next-i18next";import{styled as qp}from"@mui/system";import{getCustomScrollBarStyles as II}from"@elastic-suite/gally-admin-shared";var br=qp("div")(({theme:e})=>x(u({minWidth:"180px",background:e.palette.colors.white,border:`1px solid ${e.palette.colors.neutral[300]}`,borderRadius:8,margin:"4px 0",overflow:"auto"},II(e)),{"& .MuiAutocomplete-listbox":{padding:0},"& .MuiAutocomplete-listbox .MuiAutocomplete-option":{listStyle:"none",padding:"8px 12px",cursor:"default",fontWeight:400,fontSize:12,lineHeight:"18px",color:e.palette.colors.neutral[800],'&[aria-selected="true"]':{backgroundColor:"transparent",fontWeight:"bold"},"&.Mui-focused":{backgroundColor:e.palette.colors.neutral[200]},'&[aria-disabled="true"]':{color:e.palette.colors.neutral[400]},'&.Mui-focused:not([aria-disabled="true"])':{backgroundColor:e.palette.colors.neutral[200]}}})),En=qp(br)({"& .MuiAutocomplete-listbox .MuiAutocomplete-option":{padding:"5px 12px"}});function wI(e,o){var A,k;let y=e,{disabled:t,fullWidth:r,limitTags:n,multiple:i,onChange:s,options:a,style:l,value:p,useGroups:m,objectKeyValue:d,componentId:c}=y,g=M(y,["disabled","fullWidth","limitTags","multiple","onChange","options","style","value","useGroups","objectKeyValue","componentId"]),{required:b,small:h}=g,{t:T}=PI("common"),E=TI(null),C=yI(()=>new Map(a.map(N=>[N.value,N])),[a]),P=S("dropdown",c),I=p instanceof Array?p.map(N=>typeof N=="object"?C.get(N[d]):C.get(N)):p instanceof Object&&d?(A=C.get(p[d]))!=null?A:null:(k=C.get(p))!=null?k:null;function v(N,_){let H=x(u({},N),{target:(o||E).current});setTimeout(()=>{!_&&!b?s(null,H):_ instanceof Array?s(_.map(({value:V})=>d?{[d]:V}:V),H):_&&s(d?{[d]:_.value}:_.value,H)},0)}let D=T("form.clear"),F=T("form.close"),w=T("form.open"),O,L;return i?(O=(N,{label:_},{selected:H})=>Qe.createElement("li",x(u({},N),{"data-testid":S("dropdownOption",P)}),Qe.createElement(Fo,{checked:H,label:_,list:!0,onClick:V=>V.preventDefault(),componentId:S("dropdownOption",P)})),L=(N,_)=>N.filter(H=>H).map((H,V)=>{var U;return Qe.createElement(Le,u({key:(U=H.id)!=null?U:String(H.value),label:H.label,size:h?"small":"medium",componentId:P},_({index:V})))})):O=(N,_)=>Qe.createElement(vI,x(u({},N),{"data-testid":S("dropdownOption",P)}),_.label),Qe.createElement(SI,{fullWidth:r,variant:"standard"},Qe.createElement(CI,{PaperComponent:h?En:br,clearIcon:Qe.createElement(B,{"data-testid":S("dropdownClearIcon",P),name:"close"}),clearText:D,closeText:F,componentsProps:{popper:{placement:"bottom-start"}},disableClearable:b,disableCloseOnSelect:i,disabled:t,getOptionDisabled:N=>N.disabled,limitTags:n,multiple:i,onChange:v,openText:w,options:a,groupBy:m?N=>N.id:void 0,getOptionLabel:m?N=>N.label:void 0,popupIcon:Qe.createElement(B,{componentId:S("dropdownCollapsingIcon",P),name:"chevron-down"}),renderGroup:N=>Qe.createElement("li",{key:N.key},Qe.createElement(EI,{component:"div","data-testid":S("dropdownOptionGroupTitle",P)},N.group),Qe.createElement("ul",{style:{padding:0}},N.children)),renderInput:N=>{let U=N,{InputLabelProps:_,InputProps:H}=U,V=M(U,["InputLabelProps","InputProps"]);return Qe.createElement(Ae,x(u(u(u({},x(u({},g),{required:!1})),V),H),{fullWidth:r,inputRef:o||E,requiredLabel:b,componentId:P}))},renderOption:O,renderTags:L,style:u({width:"fit-content"},l),value:I,selectOnFocus:!1,"data-testid":P}))}var Ne=xI(wI);import FI,{useCallback as LI}from"react";function AI(e){let p=e,{onChange:o,showError:t,additionalValidator:r,replacementErrorsMessages:n}=p,i=M(p,["onChange","showError","additionalValidator","replacementErrorsMessages"]),s=LI((c,g)=>r?r(c,g):i.required&&(c===void 0||c===""||c.length===0)?"valueMissing":"",[r,i.required]),[m]=ye(o,i.value,t,s,i.disabled,n),d=m,{ref:a}=d,l=M(d,["ref"]);return FI.createElement(Ne,x(u(u({},i),l),{error:(i==null?void 0:i.error)||(l==null?void 0:l.error),helperIcon:(i==null?void 0:i.helperIcon)||(l==null?void 0:l.helperIcon),helperText:(i==null?void 0:i.helperText)||(l==null?void 0:l.helperText),ref:a}))}var he=AI;import DI,{useCallback as OI}from"react";function NI(e){let p=e,{onChange:o,showError:t,additionalValidator:r,replacementErrorsMessages:n}=p,i=M(p,["onChange","showError","additionalValidator","replacementErrorsMessages"]),s=OI((c,g)=>r?r(c,g):"",[r]),[m]=ye(o,i.value,t,s,i.disabled,n),d=m,{ref:a}=d,l=M(d,["ref"]);return DI.createElement(Ae,x(u(u({},i),l),{error:(i==null?void 0:i.error)||(l==null?void 0:l.error),helperIcon:(i==null?void 0:i.helperIcon)||(l==null?void 0:l.helperIcon),helperText:(i==null?void 0:i.helperText)||(l==null?void 0:l.helperText),inputRef:a,ref:null}))}var me=NI;import $o from"react";import{FormControl as kI,FormControlLabel as BI,FormHelperText as _I,InputLabel as MI,Radio as HI,RadioGroup as zI}from"@mui/material";function VI(e){let d=e,{error:o,helperText:t,helperIcon:r,options:n,onChange:i,infoTooltip:s,label:a,defaultValue:l}=d,p=M(d,["error","helperText","helperIcon","options","onChange","infoTooltip","label","defaultValue"]),m=n.find(c=>c.default);return $o.createElement(kI,{variant:"standard",margin:"normal"},Boolean(a||s)&&$o.createElement(MI,{shrink:!0,style:{position:"relative"},required:p.required},a,Boolean(s)&&$o.createElement(re,{title:s})),$o.createElement(zI,x(u({},p),{onChange:(c,g)=>{i(g,c)},defaultValue:l||(p.defaultChecked?m==null?void 0:m.value:null)}),n.map(c=>$o.createElement(BI,{disabled:c.disabled,key:c.label,value:c.value,control:$o.createElement(HI,null),label:c.label}))),Boolean(t)&&$o.createElement(_I,{error:o,sx:{marginTop:"-5px"}},Boolean(r)&&$o.createElement(B,{name:r,style:{fontSize:18,marginRight:2}}),t))}var la=VI;import Pn,{useCallback as RI}from"react";function UI(e){let p=e,{onChange:o,showError:t,additionalValidator:r,replacementErrorsMessages:n}=p,i=M(p,["onChange","showError","additionalValidator","replacementErrorsMessages"]),s=RI((c,g)=>r?r(c,g):i.required&&!c?"valueMissing":"",[r,i.required]),[m]=ye(o,i.value,t,s,!1,n),d=m,{ref:a}=d,l=M(d,["ref"]);return Pn.createElement(Pn.Fragment,null,Pn.createElement(la,x(u(u({},i),l),{error:(i==null?void 0:i.error)||(l==null?void 0:l.error),helperIcon:(i==null?void 0:i.helperIcon)||(l==null?void 0:l.helperIcon),helperText:(i==null?void 0:i.helperText)||(l==null?void 0:l.helperText)})),Pn.createElement(Ae,{style:{display:"none"},inputRef:a}))}var pa=UI;import KI,{useCallback as YI}from"react";import Lo,{forwardRef as qI}from"react";import{FormHelperText as JI,InputLabel as XI}from"@mui/material";import{useTranslation as $I}from"next-i18next";import WI from"react";import{styled as da}from"@mui/system";function GI(e){let r=e,{margin:o}=r,t=M(r,["margin"]);return WI.createElement("div",u({},t))}var DM=da(GI)(({margin:e,theme:o})=>x(u(u({position:"relative"},e==="dense"&&{marginTop:o.spacing(1),marginBottom:o.spacing(.5)}),e==="normal"&&{marginTop:o.spacing(2),marginBottom:o.spacing(1)}),{"& label":{position:"absolute",left:0,top:0},"& .MuiFormLabel-root":{color:o.palette.colors.neutral[900]},"& .MuiFormLabel-root.Mui-error":{color:o.palette.colors.neutral[900]}})),Jp=da(gr)({margin:"0 0.5em"}),Xp=da(gr)({margin:"0 0 0 0.5em"});function jI(e,o){let{t}=$I("common"),L=e,{error:r,fullWidth:n,helperText:i,helperIcon:s,id:a,infoTooltip:l,inputProps:p,label:m,margin:d="none",onChange:c,placeholder:g=[],required:b,suffix:h,value:T,type:E="number",componentId:C}=L,P=M(L,["error","fullWidth","helperText","helperIcon","id","infoTooltip","inputProps","label","margin","onChange","placeholder","required","suffix","value","type","componentId"]),[I,v]=g,[D,F]=T;function w(y){let{value:A}=y.target;c&&c([fr(A,e),F],y)}function O(y){let{value:A}=y.target;c&&c([D,fr(A,e)],y)}return Lo.createElement(Xo,{fullWidth:n,margin:d},Boolean(m||l)&&Lo.createElement(XI,{shrink:!0,htmlFor:a,required:b},m,l?Lo.createElement(re,{title:l}):null),Lo.createElement(Cn,{className:"InputText__Wrapper"},t("form.from"),Lo.createElement(Jp,x(u({error:r,id:a,onChange:w,required:b},P),{type:E,inputProps:x(u({},p),{max:F,"data-testid":S("rangeFromInput",C)}),placeholder:I,value:D?String(D):"",inputRef:o})),t("form.to"),Lo.createElement(Xp,x(u({error:r,onChange:O,required:b},P),{type:E,inputProps:x(u({},p),{min:D,"data-testid":S("rangeToInput",C)}),placeholder:v,value:F?String(F):""})),Boolean(h)&&Lo.createElement(Sn,null,h)),Boolean(i)&&Lo.createElement(JI,{error:r,"data-testid":S("helperText",C)},Boolean(s)&&Lo.createElement(B,{name:s,style:{fontSize:18,marginRight:2}}),i))}var ua=qI(jI);function QI(e){let p=e,{onChange:o,showError:t,additionalValidator:r,replacementErrorsMessages:n}=p,i=M(p,["onChange","showError","additionalValidator","replacementErrorsMessages"]),s=YI((c,g)=>r?r(c,g):i.required&&(!c[0]&&c[0]!==0||!c[1]&&c[1]!==0)?"valueMissing":"",[r,i.required]),[m]=ye(o,i.value,t,s,i.disabled,n),d=m,{ref:a}=d,l=M(d,["ref"]);return KI.createElement(ua,x(u(u({},i),l),{error:(i==null?void 0:i.error)||(l==null?void 0:l.error),helperIcon:(i==null?void 0:i.helperIcon)||(l==null?void 0:l.helperIcon),helperText:(i==null?void 0:i.helperText)||(l==null?void 0:l.helperText),ref:a}))}var ma=QI;import Ao from"react";import ex from"@mui/material/Box";import{styled as $p}from"@mui/system";import ZI from"@mui/material/Slider";var jp=$p(ZI)(({theme:e})=>({".MuiSlider-root":{height:"10px!important"},".MuiSlider-rail":{height:"7px",border:"1px solid",boxSizing:"border-box",borderColor:e.palette.colors.neutral[400],backgroundColor:e.palette.colors.neutral[300],"::after":{content:"''",position:"absolute",top:-1,height:"100%",background:e.palette.colors.primary[400],borderRadius:e.spacing(1),border:"1px solid",borderColor:e.palette.colors.primary[500]}},".MuiSlider-track":{display:"none"},".MuiSlider-valueLabelOpen":{borderRadius:e.spacing(1),backgroundColor:e.palette.colors.primary[100],border:"1px solid",borderColor:e.palette.colors.primary[200],color:e.palette.colors.neutral[900],paddingRight:0,paddingLeft:0,paddingTop:2,paddingBottom:2,fontSize:"14px",width:"34px",fontWeight:"600",top:"-6px","::before":{display:"none"}},".MuiSlider-thumb":{color:e.palette.colors.primary[500],border:"1px solid",borderColor:e.palette.colors.primary[100]}})),Kp=$p("div")(({theme:e})=>({display:"flex",flexDirection:"row",justifyContent:"space-between",color:e.palette.colors.neutral[900],fontWeight:"400",lineHeight:"18px",fontSize:"12px"}));import{FormHelperText as ox,InputLabel as tx}from"@mui/material";var rx=[-99,0,100];function Yp(e){let{error:o,fullWidth:t,helperText:r,helperIcon:n,infoTooltip:i,label:s,margin:a,onChange:l,required:p,value:m,width:d,componentId:c}=e;function g(b,h){l&&l(h)}return Ao.createElement(xo,{error:o,fullWidth:t,margin:a,variant:"standard"},Boolean(s||i)&&Ao.createElement(tx,{shrink:!0,required:p},s,i?Ao.createElement(re,{title:i}):null),Ao.createElement(ex,{width:t?void 0:d,sx:{marginTop:s?"4px":0}},Ao.createElement(Kp,null,rx.map(b=>Ao.createElement("div",{key:b},b))),Ao.createElement(jp,{valueLabelDisplay