@carto/meridian-ds 1.4.3-alpha-tag.1 → 1.4.3-alpha-tag.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/dist/Alert--QYebQp3.js +134 -0
  3. package/dist/Alert-DFaAeTZf.cjs +133 -0
  4. package/dist/ArrowDown-8fLj23Ge.cjs +31 -0
  5. package/dist/ArrowDown-CY_wMVJT.js +32 -0
  6. package/dist/MenuItem-Br2jY2lt.cjs +164 -0
  7. package/dist/MenuItem-CXnnE5lK.js +165 -0
  8. package/dist/SwatchSquare-DDi0beUM.js +51 -0
  9. package/dist/SwatchSquare-w-U8-O-P.cjs +50 -0
  10. package/dist/TablePaginationActions-BG2gWq0M.cjs +5643 -0
  11. package/dist/{TablePaginationActions-WZ3P4O35.js → TablePaginationActions-Dit3VW-A.js} +1065 -653
  12. package/dist/components/index.cjs +3540 -1
  13. package/dist/components/index.js +2324 -1965
  14. package/dist/custom-icons/index.cjs +5908 -1
  15. package/dist/custom-icons/index.js +2681 -2298
  16. package/dist/paletteUtils-B9ybmwiI.cjs +304 -0
  17. package/dist/paletteUtils-BHqJlHm9.js +288 -0
  18. package/dist/theme/index.cjs +3135 -1
  19. package/dist/theme/index.js +1050 -1011
  20. package/dist/types/utils/chartConstants.d.ts +3 -3
  21. package/dist/types/utils/chartConstants.d.ts.map +1 -1
  22. package/dist/types/widgets/CategoryWidgetUI/CategoryWidgetUI.d.ts +2 -2
  23. package/dist/types/widgets/CategoryWidgetUI/CategoryWidgetUI.d.ts.map +1 -1
  24. package/dist/types/widgets/PieWidgetUI/PieWidgetUI.d.ts +2 -2
  25. package/dist/types/widgets/PieWidgetUI/PieWidgetUI.d.ts.map +1 -1
  26. package/dist/types/widgets/PieWidgetUI/usePieCategories.d.ts +2 -2
  27. package/dist/types/widgets/PieWidgetUI/usePieCategories.d.ts.map +1 -1
  28. package/dist/types/widgets/comparative/ComparativeCategoryWidgetUI/ComparativeCategoryWidgetUI.d.ts +2 -2
  29. package/dist/types/widgets/comparative/ComparativeCategoryWidgetUI/ComparativeCategoryWidgetUI.d.ts.map +1 -1
  30. package/dist/types/widgets/comparative/ComparativeCategoryWidgetUI/transposeCategoryData.d.ts +2 -2
  31. package/dist/types/widgets/comparative/ComparativeCategoryWidgetUI/transposeCategoryData.d.ts.map +1 -1
  32. package/dist/types/widgets/index.d.ts +1 -0
  33. package/dist/types/widgets/index.d.ts.map +1 -1
  34. package/dist/widgets/index.cjs +7180 -21
  35. package/dist/widgets/index.js +5159 -3791
  36. package/package.json +1 -1
  37. package/dist/Alert-BAvr1f31.js +0 -130
  38. package/dist/Alert-DPGMxifE.cjs +0 -4
  39. package/dist/ArrowDown-BD0WmQR3.cjs +0 -1
  40. package/dist/ArrowDown-CMhYkZ2p.js +0 -31
  41. package/dist/MenuItem-Cd34y6F3.js +0 -165
  42. package/dist/MenuItem-Dbss-WG1.cjs +0 -1
  43. package/dist/SwatchSquare-C34ayL4L.cjs +0 -1
  44. package/dist/SwatchSquare-CVpwEFFV.js +0 -48
  45. package/dist/TablePaginationActions-Bp1DCaIE.cjs +0 -9
  46. package/dist/paletteUtils-BEwZhrLg.js +0 -262
  47. package/dist/paletteUtils-DLQVT9qo.cjs +0 -1
@@ -1 +1,3540 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),b=require("react"),a=require("@mui/material"),h=require("../TablePaginationActions-Bp1DCaIE.cjs"),w=require("react-intl"),S=require("@mui/icons-material"),_=require("../Alert-DPGMxifE.cjs");require("cartocolor");const H=require("../MenuItem-Dbss-WG1.cjs"),P=require("../ArrowDown-BD0WmQR3.cjs"),xt=require("@mui/x-date-pickers/DatePicker"),ft=require("@mui/x-date-pickers"),mt=require("@mui/x-date-pickers/TimePicker"),bt=require("@mui/x-date-pickers/DateTimePicker"),yt=require("@mui/material/ClickAwayListener"),ht=a.styled(a.Box)({position:"absolute",top:0,left:0,right:0,bottom:0,display:"flex",alignItems:"center",justifyContent:"center"}),jt=a.styled(a.Box)({visibility:"hidden",pointerEvents:"none"});function Mt({children:t,loading:e,disabled:o,startIcon:r,endIcon:i,loadingPosition:l,...s},d){const c=n.jsx(a.CircularProgress,{size:18,color:"inherit"}),p=e&&l===void 0,x=()=>p?n.jsxs(a.Box,{sx:{position:"relative"},children:[n.jsx(ht,{children:c}),n.jsx(jt,{children:t})]}):t,u=m=>{if(!p)return e&&l!==void 0?l===m?c:void 0:m==="start"?r:i};return n.jsx(a.Button,{disabled:e||o,startIcon:u("start"),endIcon:u("end"),...s,role:s.href?"link":"button",ref:d,children:n.jsx(h.Typography,{variant:"inherit",color:"inherit",noWrap:!0,component:"span",children:x()})})}const Ct=b.forwardRef(Mt),It=a.styled(a.Box)(({theme:t})=>({display:"flex",alignItems:"center",gap:t.spacing(.5)})),vt=a.styled(h.Typography)(({theme:t})=>({".Mui-disabled &":{color:t.palette.text.disabled}})),Tt=a.styled(a.Box)(({theme:t})=>({display:"flex",svg:{width:h.ICON_SIZE_SMALL,height:h.ICON_SIZE_SMALL,fontSize:h.ICON_SIZE_SMALL,path:{fill:t.palette.text.secondary,".Mui-disabled &":{fill:t.palette.text.disabled}}}}));function O({label:t,type:e,icon:o,inheritSize:r}){return n.jsxs(It,{children:[t,e&&n.jsx(vt,{component:"span",variant:r?"inherit":"caption",color:"textSecondary",weight:"regular",children:e==="required"?"(required)":"(optional)"}),o&&n.jsx(Tt,{children:o})]})}function Bt({InputProps:t,size:e="small",...o},r){const i=w.useIntl(),l=h.useImperativeIntl(i),[s,d]=b.useState(!1),c=()=>d(!s);return n.jsx(a.TextField,{...o,ref:r,type:s?"text":"password",size:e,InputProps:{...t,endAdornment:n.jsx(a.InputAdornment,{position:"end",children:n.jsx(a.IconButton,{size:e,onClick:c,children:n.jsx(a.Tooltip,{title:l.formatMessage({id:`c4r.form.${s?"hidePassword":"showPassword"}`}),children:s?n.jsx(S.VisibilityOffOutlined,{}):n.jsx(S.VisibilityOutlined,{})})})})}})}const kt=b.forwardRef(Bt),L={};function Dt(t="$lodash$"){L[t]||(L[t]=0);const e=++L[t];return t==="$lodash$"?`${e}`:`${t}${e}`}const St=a.styled(a.Select)(({theme:t})=>({"& .MuiInputAdornment-positionStart":{paddingLeft:t.spacing(2),"&.MuiInputAdornment-sizeSmall":{paddingLeft:t.spacing(1.5)}},"& .MuiInputBase-inputAdornedStart":{paddingLeft:"0px !important"},"& .MuiSelect-select .MuiMenuItem-root:hover":{backgroundColor:"transparent"},"&.MuiInputBase-root .MuiSelect-select.MuiSelect-multiple":{paddingRight:t.spacing(7)}})),wt=a.styled(a.MenuItem)(()=>({display:"none"}));function At({children:t,placeholder:e,size:o="small",displayEmpty:r,menuProps:i,inputProps:l,labelId:s,label:d,labelSecondary:c,helperText:p,name:x,error:u,focused:m,disabled:g,fullWidth:f,required:M,"aria-label":y,...T},I){const v=o==="small",[j]=b.useState(()=>Dt("select-label-")),C=d?s??j:void 0;return n.jsxs(a.FormControl,{size:o,error:u,focused:m,disabled:g,fullWidth:f,required:M,"data-name":"select-field","data-size":o,children:[n.jsxs(a.Box,{display:"flex",alignItems:"center",justifyContent:"space-between",children:[d&&n.jsx(a.InputLabel,{shrink:!0,id:C,children:d}),c&&n.jsx(a.Box,{display:"flex",alignItems:"center",ml:2,mb:.5,children:c})]}),n.jsxs(St,{...T,labelId:C,name:x,ref:I,size:o,fullWidth:f,displayEmpty:r??!!e,inputProps:{...l,"aria-label":y},MenuProps:{...i,PopoverClasses:{paper:v?"MuiMenu-paper-sizeSmall":void 0},anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:0,horizontal:"left"}},children:[e&&n.jsx(wt,{disabled:!0,value:"",children:n.jsx(h.Typography,{variant:v?"body2":"body1",color:"text.hint",component:"span",children:e})}),t]}),p&&n.jsx(a.FormHelperText,{"aria-label":`${x}-helper`,children:p})]})}const tt=b.forwardRef(At),Rt=a.styled(a.ToggleButtonGroup,{shouldForwardProp:t=>t!=="variant"&&t!=="backgroundColor"})(({variant:t,backgroundColor:e,theme:o})=>({...t==="contained"&&{boxShadow:"none"},...t==="unbounded"&&{boxShadow:"none",borderRadius:o.spacing(.5),"& .MuiDivider-root":{height:o.spacing(4),"&.MuiToggleButtonGroup-groupedHorizontal":{height:o.spacing(4)},"&.MuiToggleButtonGroup-groupedVertical":{height:"auto",width:o.spacing(4),margin:`${o.spacing(.5,0,1)} !important`,borderRadius:"0 !important"}},"& .MuiToggleButton-sizeSmall":{margin:0,"&.MuiToggleButtonGroup-grouped:not(.MuiDivider-root)":{margin:0},"& + .MuiDivider-root.MuiToggleButtonGroup-groupedHorizontal":{height:o.spacing(3)},"& + .MuiDivider-root.MuiToggleButtonGroup-groupedVertical":{height:"auto",width:o.spacing(3)}},".MuiToggleButtonGroup-grouped:not(.MuiDivider-root)":{margin:0,"&:first-of-type":{marginLeft:0},"&:not(:last-of-type)":{marginRight:o.spacing(.5)}},"&.MuiToggleButtonGroup-horizontal:not(.MuiDivider-root)":{".MuiToggleButtonGroup-grouped":{margin:o.spacing(0,.5)}},"&.MuiToggleButtonGroup-vertical:not(.MuiDivider-root)":{".MuiToggleButtonGroup-grouped":{margin:o.spacing(0,0,.5),"&:not(:last-of-type)":{marginRight:0},"&:last-of-type":{marginBottom:0}}}},...e==="primary"&&{backgroundColor:o.palette.background.paper},...e==="secondary"&&{backgroundColor:o.palette.background.default},...e==="transparent"&&{backgroundColor:"transparent"}}));function Ft({children:t,variant:e="floating",backgroundColor:o,...r}){const l=e==="unbounded"?"transparent":"primary";return n.jsx(Rt,{...r,variant:e,backgroundColor:o??l,children:t})}const Ot=a.styled("div")(({theme:t})=>({position:"relative",display:"inline-flex","& + &, & + .optionIconButton":{marginLeft:t.spacing(.5)}})),Lt=a.styled(a.IconButton,{shouldForwardProp:t=>!["active"].includes(t)})(({active:t,theme:e})=>({...t&&{color:e.palette.primary.main,backgroundColor:e.palette.primary.background,"& svg:not(.doNotFillIcon) path":{fill:e.palette.primary.main}}}));function $t({tooltip:t,tooltipPlacement:e="top",icon:o,size:r="medium",variant:i="icon",color:l="default",sx:s,className:d,loading:c,disabled:p,active:x,...u},m){return n.jsx(a.Tooltip,{placement:e,title:t??"",children:n.jsx(Ot,{className:`optionIconButton ${d??""}`,sx:s,"data-testid":"icon-button",children:n.jsx(Lt,{...u,ref:m,size:r,variant:i,color:l,active:x,disabled:p||c,role:"button",children:c?n.jsx(a.CircularProgress,{size:18,color:"inherit"}):o})})})}const N=b.forwardRef($t),Et=a.styled(a.Menu,{shouldForwardProp:t=>!["extended","width","height"].includes(t)})(({theme:t,extended:e,width:o,height:r})=>({...e&&{".MuiMenuItem-root":{minHeight:t.spacing(6)}},...o&&{".MuiList-root":{width:o,minWidth:o}},...r&&{".MuiMenu-paper":{overflow:"hidden"},".MuiList-root":{maxHeight:r}}}));function Wt({extended:t,width:e,height:o,MenuListProps:r,...i},l){return n.jsx(Et,{...i,ref:l,"data-name":"menu",width:e,height:o,extended:t,MenuListProps:{...r,"data-width":e,"data-height":o,"data-extended":t}})}const _t=b.forwardRef(Wt),Ht=a.styled(a.MenuList,{shouldForwardProp:t=>!["extended","width","height"].includes(t)})(({theme:t,extended:e,width:o,height:r})=>({...e&&{".MuiMenuItem-root":{minHeight:t.spacing(6)}},"&.MuiList-root":{...o&&{width:o,minWidth:o},...r&&{maxHeight:r}}}));function Pt({extended:t,width:e,height:o,...r},i){return n.jsx(Ht,{...r,ref:i,width:e,height:o,extended:t,"data-name":"menu-list","data-width":e,"data-height":o,"data-extended":t})}const Nt=b.forwardRef(Pt),qt=a.styled(H.MenuItem)(()=>({marginTop:"0 !important"})),Gt=a.styled(a.Link)(({disabled:t,theme:e})=>({display:"flex",alignItems:"center",gap:e.spacing(1),width:"100%",textAlign:"initial",...t&&{pointerEvents:"none",color:e.palette.text.disabled}}));function Vt({areAllSelected:t,areAnySelected:e,selectAll:o,selectAllDisabled:r,"aria-label":i,"data-testid":l},s){const d=w.useIntl(),c=h.useImperativeIntl(d);return n.jsx(qt,{ref:s,fixed:!0,"data-name":"menu-filter","aria-label":i,"data-testid":l,children:n.jsxs(Gt,{variant:"body2",color:"textPrimary",component:"button",underline:"none",disabled:!!r,onClick:o,tabIndex:0,children:[n.jsx(a.Checkbox,{checked:t,indeterminate:e&&!t,disabled:r}),c.formatMessage({id:"c4r.form.selectAll"})]})})}const q=b.forwardRef(Vt);function Ut({selectedOptions:t,options:e,onChange:o}){const[r,i]=b.useState(t??[]),l=e.length===r.length,s=r.length>0;return b.useEffect(()=>{r!==t&&i(r)},[t]),{areAllSelected:l,areAnySelected:s,currentOptions:r,handleChange:x=>{const{target:{value:u}}=x,m=typeof u=="string"?u.split(","):u.filter(g=>g!==void 0);i(m),o(m)},selectAll:()=>{const x=e==null?void 0:e.filter(({disabled:u})=>!u).map(({value:u})=>u);x&&(x.every(m=>r.includes(m))?(i([]),o([])):(i(x),o(x)))},unselectAll:()=>{i([]),o([])}}}const Zt=a.styled(a.MenuItem)(({theme:t})=>({"&.Mui-disabled":{pointerEvents:"auto","&:hover":{backgroundColor:`${t.palette.background.default} !important`}}})),zt=a.styled(a.InputAdornment,{shouldForwardProp:t=>t!=="size"})(({theme:t,size:e})=>({display:"none",position:"absolute",top:t.spacing(2),right:t.spacing(3.5),".MuiInputBase-root:hover &, .MuiInputBase-root.Mui-focused &":{display:"flex"},".MuiSvgIcon-root":{color:t.palette.text.hint},...e==="medium"&&{top:t.spacing(3),right:t.spacing(5)}})),Yt=[],Jt=()=>{};function Xt({options:t=Yt,selectedOptions:e,size:o="small",placeholder:r,showCounter:i,showFilters:l=!0,onChange:s=Jt,selectAllDisabled:d,tooltipPlacement:c,variant:p,...x},u){const{areAllSelected:m,areAnySelected:g,currentOptions:f,handleChange:M,selectAll:y,unselectAll:T}=Ut({options:t,selectedOptions:e,onChange:s}),I=o==="small",v=I||p==="standard"?0:2,j=w.useIntl(),C=h.useImperativeIntl(j),D=`${f.length} ${C.formatMessage({id:"c4r.form.selected"})}`,A=b.useMemo(()=>m?n.jsx(h.Typography,{component:"span",variant:I?"body2":"body1",color:"textPrimary",ml:v,children:C.formatMessage({id:"c4r.form.allSelected"})}):g?n.jsx(h.Typography,{component:"span",variant:I?"body2":"body1",color:"textPrimary",ml:v,children:i&&f.length>1?D:f.join(", ")}):n.jsx(h.Typography,{component:"span",variant:I?"body2":"body1",color:"text.hint",ml:v,children:r??C.formatMessage({id:"c4r.form.noneSelected"})}),[m,g,D,f,C,I,v,r,i]);return n.jsxs(tt,{...x,ref:u,multiple:!0,displayEmpty:!0,placeholder:r,value:f,renderValue:()=>A,onChange:M,size:o,variant:p,endAdornment:l&&g&&n.jsx(zt,{position:"end",size:o,children:n.jsx(a.IconButton,{onClick:T,size:o,children:n.jsx(S.Cancel,{})})}),menuProps:{PaperProps:{sx:{".MuiList-root":{paddingTop:0}}}},children:[l&&n.jsx(q,{areAllSelected:m,areAnySelected:g,selectAll:y,selectAllDisabled:d}),t==null?void 0:t.map(k=>{const F=n.jsxs(Zt,{value:k.value,disabled:k.disabled,tabIndex:0,children:[n.jsx(a.Checkbox,{disabled:k.disabled,checked:f.includes(k.value)}),n.jsx(a.ListItemText,{primary:k.label})]},k.value);return k.tooltip?n.jsx(a.Tooltip,{title:k.tooltip,placement:c,children:F},k.value):F})]})}const Kt=b.forwardRef(Xt),Qt=a.styled(a.TextField,{shouldForwardProp:t=>t!=="cursor"})(({cursor:t,theme:e})=>({"&.MuiTextField-root .MuiInputBase-root":{cursor:t,paddingRight:e.spacing(1),"& input":{cursor:t},"&.Mui-disabled":{pointerEvents:"none","& .MuiButtonBase-root":{color:e.palette.text.disabled}},"&.MuiInputBase-sizeSmall":{paddingRight:e.spacing(.5)}},"& .MuiFormLabel-root":{cursor:t,"&.Mui-disabled":{pointerEvents:"none"}}}));function te({buttonText:t,hasFiles:e,size:o,error:r,disabled:i,handleReset:l,handleOpen:s,inProgress:d}){return n.jsx(a.InputAdornment,{position:"end",children:d?n.jsx(a.IconButton,{"aria-label":"Loading",disabled:!0,size:o,children:n.jsx(a.CircularProgress,{size:18})}):e?n.jsx(a.IconButton,{onClick:l,size:o,"aria-label":"Delete",disabled:i,children:n.jsx(S.Cancel,{})}):n.jsx(a.Button,{onClick:s,size:o,variant:"text",color:r?"default":"primary",disabled:i,children:t})})}function et({name:t,multiple:e,handleReset:o,handleOpen:r,dragOver:i,error:l,placeholder:s,focused:d,buttonText:c="Browse",inProgress:p,InputProps:x,size:u="small",hasFiles:m,cursor:g="pointer",...f}){return n.jsx(Qt,{...f,size:u,error:l,placeholder:s,focused:d??i,cursor:g,InputProps:{...x,name:t,readOnly:!0,endAdornment:n.jsx(te,{buttonText:c,hasFiles:m,size:u,error:l,disabled:!!i,handleReset:o,handleOpen:r,inProgress:p})}})}function ee({onChange:t,files:e,multiple:o,placeholder:r,uploadInputRef:i}){const l=w.useIntl(),s=h.useImperativeIntl(l),[d,c]=b.useState(""),[p,x]=b.useState(!1);b.useEffect(()=>{!e||e.length===0?c(""):e.length===1?c(e[0].name):c(s.formatMessage({id:"c4r.form.filesSelected"},{count:e.length}))},[e,s]);const u=()=>{var j;(j=i.current)==null||j.click()},m=j=>{j.preventDefault(),x(!0)},g=j=>{j.preventDefault(),x(!1)},f=j=>{j.preventDefault(),x(!1);const C=j.dataTransfer.items,D=M(C);t==null||t(D)},M=j=>{const C=[];for(const D of Array.from(j))if(D.kind==="file"){const A=D.getAsFile();C.push(A)}return C},y=j=>{const C=Array.from(j.target.files);t==null||t(C)},T=j=>{j.stopPropagation(),c("")},I=b.useMemo(()=>{const j=s.formatMessage({id:"c4r.form.dragPlaceholder"},{count:o?0:1}),C=s.formatMessage({id:"c4r.form.dragActivePlaceholder"},{count:o?0:1});let D="";return p?D=C:D=r??j,D},[p,o,r,s]);return{filesText:d,getPlaceholder:I,dragOver:p,inputEvents:{onDragOver:m,onDragLeave:g,onDrop:f,onClick:u},handleFiles:y,handleReset:T}}const oe=["application/JSON"];function ne({name:t,buttonText:e,accept:o,files:r,inProgress:i,onChange:l,multiple:s,placeholder:d,error:c,focused:p,nativeInputProps:x,...u}){const m=o??oe,g=b.useRef(null),{filesText:f,getPlaceholder:M,dragOver:y,inputEvents:T,handleFiles:I,handleReset:v}=ee({uploadInputRef:g,files:r,onChange:l,multiple:s,placeholder:d});return n.jsxs(n.Fragment,{children:[n.jsx(et,{...u,placeholder:M,value:f,error:c,focused:p??y,handleReset:v,dragOver:y,inProgress:i,hasFiles:!!f,InputProps:T,buttonText:e}),n.jsx("input",{...x,ref:g,style:{display:"none"},type:"file","aria-label":t,name:t,accept:String(m),multiple:s,onChange:I})]})}function re({disabled:t,loading:e,...o},r){return n.jsx(a.Autocomplete,{...o,ref:r,disabled:t||e,popupIcon:e?n.jsx(a.CircularProgress,{size:18,color:"inherit"}):n.jsx(P.ArrowDown,{}),"data-name":"autocomplete",ListboxProps:{"aria-multiselectable":!1,...o.ListboxProps}})}const ae=b.forwardRef(re),ot=t=>t&&typeof t=="object"?t.title??String(t):String(t),nt=(t,e)=>typeof t!="object"||t===null?{value:t,multiple:e}:{...t,multiple:e},rt=t=>n.jsx("span",{"data-testid":"more-options-tag",children:`+${t}`});function at(){return{renderOption:(e,o,r,i,l)=>{const{title:s,inputValue:d,divider:c,fixed:p,extended:x,dense:u,destructive:m,disabled:g,subtitle:f,iconColor:M,startAdornment:y,endAdornment:T,alternativeTitle:I,secondaryText:v,multiple:j}=o,{key:C,...D}=e,A=typeof o=="string"||typeof o=="number",k=(F,B,R,z)=>R||z||(B&&typeof B=="object"&&"value"in B?String(B.value):F(B));return n.jsx(b.Fragment,{children:c?n.jsx(a.Divider,{}):n.jsxs(n.Fragment,{children:[d&&n.jsx(a.Divider,{}),n.jsxs(H.MenuItem,{...D,...!A&&{fixed:p,extended:x,dense:u,destructive:m,disabled:g,subtitle:f,iconColor:M},"aria-disabled":f||g,"aria-selected":r.selected,children:[!f&&(y||j||l)&&n.jsxs(a.ListItemIcon,{children:[l||j&&n.jsx(a.Checkbox,{checked:r.selected}),y]}),n.jsxs(a.ListItemText,{children:[k(i??ot,o,I,s),v&&n.jsx(h.Typography,{component:"p",variant:"caption",color:"text.secondary",children:v})]}),!f&&T]})]})},C)}}}function ie({getOptionLabel:t,newItemLabel:e,newItemIcon:o,multiple:r}){const i=w.useIntl(),l=h.useImperativeIntl(i),s=a.createFilterOptions(),{renderOption:d}=at();return{creatableFilterOptions:(u,m)=>{const g=s(u,m),{inputValue:f}=m,M=u.some(y=>f===t(y));if(f.length>1&&f!==""&&!M){let y;typeof e=="function"?y=e(f):e?y=`${e} "${f}"`:y=`${l.formatMessage({id:"c4r.form.add"})} "${f}"`,g.push({inputValue:f,title:y})}return g},creatableOptionLabel:u=>typeof u=="string"?u:u.inputValue?u.inputValue:t(u),creatableRenderOption:(u,m,g)=>{const f=m.inputValue?o??n.jsx(S.AddCircleOutlineOutlined,{}):void 0,M=nt(m,!!r);return d(u,M,g,t,f)}}}function it({options:t,value:e,onChange:o,getOptionLabel:r}){const[i,l]=b.useState(Array.isArray(e)?e:e?[e]:[]),{renderOption:s}=at();b.useEffect(()=>{const m=Array.isArray(e)?e:e?[e]:[];l(m)},[e]);const d=i.length===t.length,c=i.length>0&&i.length<t.length;return{multipleValue:i,allSelected:d,someSelected:c,handleSelectAll:m=>{const g=d?[]:[...t];l(g),o==null||o(m,g,"selectOption")},handleChange:(m,g,f)=>{l(g===null?[]:g),o==null||o(m,g,f)},multipleRenderOption:(m,g,f)=>{const M=nt(g,!0);return s(m,M,f,r)}}}function le({children:t,showFilters:e,allSelected:o,someSelected:r,handleSelectAll:i=()=>{},multiple:l,...s},d){return n.jsxs("ul",{ref:d,...s,role:"listbox","aria-multiselectable":l,children:[e&&l&&n.jsx(q,{areAllSelected:!!o,areAnySelected:!!r,selectAll:i}),t]})}const lt=b.forwardRef(le);function se({newItemLabel:t,newItemIcon:e,getOptionLabel:o=ot,multiple:r,disableCloseOnSelect:i,disabled:l,loading:s,showFilters:d,options:c=[],value:p,onChange:x,getLimitTagsText:u,...m},g){const{freeSolo:f=!0,...M}=m,{multipleValue:y,allSelected:T,someSelected:I,handleSelectAll:v,handleChange:j}=it({options:c,value:p,onChange:x}),{creatableFilterOptions:C,creatableOptionLabel:D,creatableRenderOption:A}=ie({getOptionLabel:o,newItemLabel:t,newItemIcon:e,multiple:r});return n.jsx(a.Autocomplete,{...M,ref:g,options:c,value:r?y:p,onChange:j,filterOptions:C,getOptionLabel:D,renderOption:A,freeSolo:f,forcePopupIcon:!0,multiple:r,disableCloseOnSelect:i??r,ListboxComponent:lt,ListboxProps:{showFilters:d,allSelected:T,someSelected:I,handleSelectAll:v,multiple:r},getLimitTagsText:u??rt,disabled:l||s,popupIcon:s?n.jsx(a.CircularProgress,{size:18,color:"inherit"}):n.jsx(P.ArrowDown,{}),"data-name":"creatable-autocomplete"})}const ce=b.forwardRef(se);function de({renderOption:t,disableCloseOnSelect:e=!0,disabled:o,loading:r,showFilters:i,options:l,value:s,onChange:d,getOptionLabel:c,getLimitTagsText:p,...x},u){const{multipleValue:m,allSelected:g,someSelected:f,handleSelectAll:M,handleChange:y,multipleRenderOption:T}=it({options:l,value:s,onChange:d,getOptionLabel:c});return n.jsx(a.Autocomplete,{...x,ref:u,options:l,value:m,onChange:y,getOptionLabel:c,renderOption:t??T,ListboxComponent:lt,ListboxProps:{showFilters:i,allSelected:g,someSelected:f,handleSelectAll:M,multiple:!0},multiple:!0,getLimitTagsText:p??rt,disableCloseOnSelect:e,disabled:o||r,popupIcon:r?n.jsx(a.CircularProgress,{size:18,color:"inherit"}):n.jsx(P.ArrowDown,{}),"data-name":"multiple-autocomplete"})}const ue=b.forwardRef(de),pe=({children:t,disabled:e,value:o,onCopied:r,copyText:i="c4r.button.copy",copiedText:l="c4r.notifications.copiedToClipboard",button:s,buttonLabel:d,buttonProps:c,ariaLabel:p,dataTestId:x,tooltipPlacement:u="top",...m},g)=>{const f=w.useIntl(),M=h.useImperativeIntl(f),[y,T]=b.useState(!1),{copy:I}=ct(i,l),v=j=>{j.preventDefault(),I(o).then(()=>{r==null||r(),T(!0)}).catch(console.error)};return n.jsxs(n.Fragment,{children:[n.jsx(a.Tooltip,{title:M.formatMessage({id:i}),leaveDelay:0,placement:u,children:n.jsxs(a.Box,{...m,sx:{cursor:e?void 0:"pointer"},onClick:v,"data-name":"copiable",ref:g,children:[t,s&&n.jsx(N,{...c,disabled:e,icon:n.jsx(S.ContentCopyOutlined,{}),"data-testid":x,"aria-label":p||d,sx:{display:"flex"}})]})}),n.jsx(ut,{open:y,autoWidth:!0,closeable:!1,autoHideDuration:4e3,onClose:()=>T(!1),children:M.formatMessage({id:l})})]})},ge=b.forwardRef(pe);async function st(t){return await navigator.clipboard.writeText(t)}const ct=(t="c4r.button.copy",e="c4r.notifications.copiedToClipboard")=>{const[o,r]=b.useState(t);return{message:o,copy:async l=>{await st(l),r(e),setTimeout(()=>r(t),1e3)}}},xe=a.styled("div",{shouldForwardProp:t=>t!=="variant"})(({variant:t,theme:e})=>({width:"100%",borderRadius:e.spacing(.5),...t==="outlined"&&{backgroundColor:e.palette.background.paper,boxShadow:`inset 0 0 0 1px ${e.palette.divider}`}}));function fe({variant:t="standard",items:e,...o}){return n.jsx(xe,{...o,variant:t,children:e.map((r,i)=>n.jsxs(a.Accordion,{disabled:r.disabled,defaultExpanded:r.defaultExpanded,onChange:r.onChange,children:[n.jsx(a.AccordionSummary,{"aria-controls":`${i}-content`,id:`${i}-header`,children:r.summary}),n.jsx(a.AccordionDetails,{children:r.content})]},i))})}const Y={large:5,medium:4,small:3,xsmall:2.25},me=a.styled(a.Avatar,{shouldForwardProp:t=>t!=="size"&&t!=="disabled"})(({theme:t,size:e="medium",disabled:o=!1})=>({width:t.spacing(Y[e]),height:t.spacing(Y[e]),...t.typography.subtitle1,...e==="large"&&{...t.typography.h6},...e==="small"&&{...t.typography.caption,fontWeight:500},...e==="xsmall"&&{...t.typography.caption,fontWeight:500,svg:{width:h.ICON_SIZE_SMALL,height:h.ICON_SIZE_SMALL}},...o&&{opacity:.6}}));function be(t){return n.jsx(me,{...t})}const dt=480,ye=a.styled(a.Snackbar)(({theme:t})=>({bottom:t.spacing(2),right:t.spacing(2),left:t.spacing(2),[t.breakpoints.up("sm")]:{bottom:t.spacing(4),right:"auto",left:"50%",width:"100%",maxWidth:`${dt}px`}})),he=a.styled(a.Box,{shouldForwardProp:t=>t!=="autoWidth"})(({autoWidth:t,theme:e})=>({minWidth:"100%",maxWidth:`${dt}px`,margin:e.spacing(0,1),...t&&{minWidth:"auto"},[e.breakpoints.up("sm")]:{minWidth:e.spacing(40),...t&&{minWidth:"auto"}}})),je=a.styled(_.Alert,{shouldForwardProp:t=>!["hasActions","closeable"].includes(t)})(({hasActions:t,closeable:e,icon:o,theme:r})=>({position:"relative",display:"flex",flexWrap:"wrap",columnGap:r.spacing(1),rowGap:r.spacing(.25),padding:r.spacing(1),paddingLeft:r.spacing(2),color:r.palette.common.white,backgroundColor:r.palette.common.black,".MuiAlert-message":{padding:r.spacing(.75,0)},".MuiAlert-message .MuiTypography-root, .MuiAlert-icon":{color:r.palette.common.white},".MuiAlert-message .MuiTypography-root:not(.MuiAlertTitle-root)":{...r.typography.body2},".MuiAlert-message .MuiCircularProgress-circle":{color:r.palette.common.white},".MuiAlert-icon":{position:"absolute",top:r.spacing(1),left:r.spacing(1.5),display:"flex",alignItems:"center",justifyContent:"center",width:r.spacing(3),marginTop:r.spacing(.5)},"&.MuiAlert-standardError":{backgroundColor:r.palette.error.main},...o!==!1&&{paddingLeft:r.spacing(5.5)},...e&&{paddingRight:r.spacing(6)},...!e&&!t&&{paddingRight:r.spacing(1.5)},...t&&{".MuiAlert-message":{minWidth:"fit-content",padding:r.spacing(.75,0)}}})),Me=a.styled(a.Box)(({theme:t})=>({position:"absolute",top:t.spacing(1),right:t.spacing(1),"& button:hover, & button:focus-visible":{backgroundColor:t.palette.white[8]},svg:{color:t.palette.white[60]}}));function ut({severity:t="neutral",autoHideDuration:e=h.NOTIFICATION_DURATION_IN_MS,closeable:o=!0,children:r,title:i,action:l,open:s,onClose:d=()=>{},autoWidth:c,icon:p,...x}){const u=w.useIntl(),m=h.useImperativeIntl(u),f=p===!1||t==="neutral"&&!p,y=e===null?null:e||h.NOTIFICATION_DURATION_IN_MS;return n.jsx(a.Portal,{children:n.jsx(ye,{...x,open:s,autoHideDuration:y,onClose:d,TransitionComponent:c?a.Fade:a.Slide,"data-auto-width":c,children:n.jsxs(he,{sx:{position:"relative"},autoWidth:c,children:[n.jsx(je,{severity:t,action:l,icon:f?!1:p,elevation:6,hasActions:!!l,closeable:o,title:i,children:r}),o&&n.jsx(Me,{children:n.jsx(N,{color:"default",onClick:T=>d(T,"timeout"),icon:n.jsx(S.CloseOutlined,{}),tooltip:m.formatMessage({id:"c4r.button.close"})})})]})})})}function Ce(t,e,o,r){if(r)return e==="outlined"?{color:o.palette.text.disabled,backgroundColor:o.palette.black[4],borderColor:o.palette.action.focus}:{color:o.palette.text.disabled,backgroundColor:o.palette.action.disabledBackground,borderColor:"transparent"};switch(t){case"default":return e==="outlined"?{color:o.palette.text.secondary,backgroundColor:o.palette.black[4],borderColor:o.palette.divider}:{color:o.palette.text.primary,backgroundColor:o.palette.default.main,borderColor:"transparent"};case"primary":return e==="outlined"?{color:o.palette.primary.main,backgroundColor:o.palette.primary.relatedLight,borderColor:o.palette.primary.main}:{color:o.palette.primary.contrastText,backgroundColor:o.palette.primary.main,borderColor:"transparent"};case"secondary":return e==="outlined"?{color:o.palette.secondary.main,backgroundColor:o.palette.secondary.relatedLight,borderColor:o.palette.secondary.main}:{color:o.palette.text.primary,backgroundColor:o.palette.secondary.main,borderColor:"transparent"};case"success":return e==="outlined"?{color:o.palette.success.main,backgroundColor:o.palette.success.relatedLight,borderColor:o.palette.success.main}:{color:o.palette.success.main,backgroundColor:o.palette.success.relatedLight,borderColor:"transparent"};case"warning":return e==="outlined"?{color:o.palette.warning.main,backgroundColor:o.palette.warning.relatedLight,borderColor:o.palette.warning.main}:{color:o.palette.text.primary,backgroundColor:o.palette.warning.main,borderColor:"transparent"};case"error":return e==="outlined"?{color:o.palette.error.main,backgroundColor:o.palette.error.relatedLight,borderColor:o.palette.error.main}:{color:o.palette.primary.contrastText,backgroundColor:o.palette.error.main,borderColor:"transparent"}}}const Ie=a.styled("div",{shouldForwardProp:t=>!["color","variant","disabled"].includes(t)})(({color:t,variant:e,disabled:o,theme:r})=>({display:"inline-flex",flexDirection:"row",flexWrap:"nowrap",alignItems:"center",padding:r.spacing(0,.5),borderRadius:r.spacing(.25),gap:r.spacing(.5),height:r.spacing(2),borderWidth:"1px",borderStyle:"solid",...Ce(t??"primary",e??"filled",r,o)})),ve=a.styled("div")(({theme:t})=>({display:"flex",justifyContent:"center",alignItems:"center","& svg":{width:t.spacing(h.ICON_SIZE_SMALL),height:t.spacing(h.ICON_SIZE_SMALL),"& g":{fill:"currentColor"}}})),Te=a.styled("span",{shouldForwardProp:t=>!["type","icon"].includes(t)})(({type:t,icon:e,theme:o})=>({display:"flex",alignItems:"center",paddingTop:t==="code"||e?o.spacing(.25):void 0}));function Be({label:t,color:e="primary",variant:o="filled",icon:r,type:i="default",typographyProps:l,noWrap:s=!0,disabled:d,...c},p){const x=i==="code";return n.jsxs(Ie,{ref:p,className:"CartoTag-root",color:e,variant:o,disabled:d,"aria-disabled":d,"data-color":e,"data-variant":o,"data-type":i,"data-name":"tag",...c,children:[r&&n.jsx(ve,{children:r}),n.jsx(Te,{icon:!!r,type:i,children:n.jsx(h.Typography,{component:"span",color:"inherit",variant:x?"code3":"caption",weight:x?"strong":"medium",noWrap:s,...l,children:t})})]})}const ke=b.forwardRef(Be),De=a.styled("div")(({theme:t})=>({display:"flex",alignItems:"center",height:h.APPBAR_SIZE,marginRight:t.spacing(1.5)})),Se=a.styled(a.IconButton)(({theme:t})=>({marginRight:t.spacing(1),"&.MuiButtonBase-root svg path":{fill:t.palette.brand.appBarContrastText}})),we=a.styled(a.Divider)(({theme:t})=>({borderColor:a.alpha(t.palette.brand.appBarContrastText,.12)}));function Ae({onClickMenu:t}){return n.jsx(a.Box,{sx:{display:{md:"none",xs:"block"}},children:n.jsxs(De,{children:[n.jsx(Se,{onClick:t,children:n.jsx(S.MenuOutlined,{})}),n.jsx(we,{orientation:"vertical",flexItem:!0})]})})}const Re=a.styled("div")(({theme:t})=>({display:"flex",marginRight:t.spacing(1.5),"& a":{display:"flex"},"& svg, & img":{width:t.spacing(4),height:t.spacing(4)}}));function Fe({logo:t}){return n.jsx(Re,{children:t})}const Oe=a.styled(h.Typography)({display:"flex",alignItems:"center",whiteSpace:"nowrap"});function Le({text:t}){const e=a.useTheme();return n.jsx(Oe,{component:"span",variant:"subtitle1",color:e.palette.brand.appBarContrastText,children:t})}const $e=a.styled(h.Typography)(({theme:t})=>({display:"flex",alignItems:"center","&::before":{content:'"/"',margin:t.spacing(0,1),opacity:.6,color:t.palette.brand.appBarContrastText}}));function Ee({text:t}){const e=a.useTheme();return n.jsx($e,{component:"span",variant:"body2",weight:"strong",color:e.palette.brand.appBarContrastText,children:t})}const We=a.styled(a.AppBar)(({theme:t})=>({backgroundColor:t.palette.brand.appBarMain,"& .MuiTypography-root":{color:t.palette.brand.appBarContrastText},"& .MuiIconButton-root path":{fill:t.palette.brand.appBarContrastText}})),_e=a.styled("div")(({theme:t})=>({display:"flex",alignItems:"center",maxWidth:"calc(100% - 300px)",overflow:"hidden",[t.breakpoints.down("sm")]:{minWidth:"192px"}})),He=a.styled("div")(({theme:t})=>({display:"flex",alignItems:"center",justifyContent:"space-between",flex:1,marginLeft:t.spacing(1)}));function Pe({children:t,brandLogo:e,brandText:o,secondaryText:r,showBurgerMenu:i=!1,onClickMenu:l,...s}){return n.jsx(We,{...s,children:n.jsxs(a.Toolbar,{children:[n.jsxs(_e,{children:[i&&n.jsx(Ae,{onClickMenu:l}),e&&n.jsx(Fe,{logo:e}),o&&n.jsx(Le,{text:o}),r&&n.jsx(Ee,{text:r})]}),n.jsx(He,{children:t})]})})}const Ne=a.styled(a.Box,{shouldForwardProp:t=>!["size","variant"].includes(t)})(({size:t,variant:e,theme:o})=>({position:"absolute",right:o.spacing(5.75),...t==="small"&&{right:o.spacing(4),top:"3px"},...e==="standard"&&{right:o.spacing(4.75),...t==="small"&&{right:o.spacing(3.5)}}}));function G({size:t,variant:e,...o}){const r=w.useIntl(),i=h.useImperativeIntl(r);return n.jsx(Ne,{size:t,variant:e,children:n.jsx(a.IconButton,{...o,size:t,"aria-label":i.formatMessage({id:"c4r.form.clearSelection"})})})}const qe=a.styled(a.Box,{shouldForwardProp:t=>!["size","variant","readOnly"].includes(t)})(({size:t,variant:e,readOnly:o,theme:r})=>({".MuiInputBase-root":{"& .clearButton svg":{color:r.palette.text.hint},...t==="small"&&{paddingRight:`${r.spacing(1)} !important`},...t==="medium"&&{"& .MuiInputAdornment-root":{"& .MuiIconButton-edgeEnd":{marginRight:r.spacing(-1)}}},...e==="standard"&&{paddingRight:`${r.spacing(1)} !important`,...t==="small"&&{paddingRight:`${r.spacing(.5)} !important`}},...o&&{"& .MuiInputAdornment-root":{"& svg":{color:r.palette.text.disabled}}}}}));function V({children:t,size:e,variant:o,readOnly:r,...i}){return n.jsx(qe,{...i,size:e,variant:o,readOnly:r,children:t})}function $({handleClear:t,variant:e="outlined",size:o="small",label:r,labelHelpTooltip:i,type:l,helperText:s,placeholder:d,slotProps:c,slots:p,error:x,showCalendar:u=!0,readOnly:m,"aria-label":g,"data-testid":f,...M}){const y=w.useIntl(),T=h.useImperativeIntl(y);return n.jsx(a.Box,{className:"CartoDatePicker-root","data-testid":"date-picker",children:n.jsx(V,{size:o,variant:e,readOnly:m,"data-name":"date-picker","aria-label":g,"data-testid":f,children:n.jsx(xt.DatePicker,{...M,label:r&&n.jsx(O,{label:r,type:l,icon:i&&n.jsx(a.Tooltip,{title:i,children:n.jsx(S.HelpOutline,{htmlColor:"text.secondary"})})}),slotProps:{textField:{variant:e,helperText:s,placeholder:d,size:o,error:x??void 0,inputProps:{"data-testid":"date-picker-input"}},field:{clearable:!!t,onClear:t},...c},slots:{clearButton:I=>n.jsx(G,{...I,size:o,variant:e}),openPickerButton:I=>n.jsx(a.IconButton,{...I,size:o,"aria-label":T.formatMessage({id:"c4r.form.chooseDate"})}),...p},disableOpenPicker:!u,readOnly:m})})})}const Ge=a.styled(a.Box,{shouldForwardProp:t=>!["isSelected","isStartDate","isEndDate","isSelectedMonth","isLastDay","isFirstDay"].includes(t)})(({theme:t,isSelected:e,isStartDate:o,isEndDate:r,isSelectedMonth:i,isLastDay:l,isFirstDay:s})=>({position:"relative",margin:t.spacing(.25),"& .MuiPickersDay-root":{margin:0},...e&&i&&{"&::before":{content:'""',position:"absolute",top:0,right:"-2px",bottom:0,left:"-2px",backgroundColor:t.palette.primary.background,...(o||s)&&{left:0,borderRadius:`${t.shape.borderRadius}px 0 0 ${t.shape.borderRadius}px`},...(r||l)&&{right:0,borderRadius:`0 ${t.shape.borderRadius}px ${t.shape.borderRadius}px 0`}},"&:first-of-type::before":{left:0,borderRadius:`${t.shape.borderRadius}px 0 0 ${t.shape.borderRadius}px`},"&:last-of-type::before":{right:0,borderRadius:`0 ${t.shape.borderRadius}px ${t.shape.borderRadius}px 0`},...s&&{"&:last-of-type::before":{left:0,right:0,borderRadius:t.shape.borderRadius}},...l&&{"&:first-of-type::before":{left:0,right:0,borderRadius:t.shape.borderRadius}},"& .MuiPickersDay-today":{borderColor:`${t.palette.default.outlinedBorder} !important`,...(o||r)&&{boxShadow:`0 0 0 1px inset ${t.palette.background.paper}`}},"&::after":{content:'""',position:"absolute",top:0,right:0,bottom:0,left:0,backgroundColor:t.palette.background.paper,borderRadius:t.shape.borderRadius,transition:"background-color 300ms cubic-bezier(0.4, 0, 0.2, 1) 0ms"},"&:hover::after":{backgroundColor:t.palette.primary.relatedLight}}})),Ve=a.styled(ft.PickersDay,{shouldForwardProp:t=>t!=="isDateRangeLimit"})(({theme:t,isDateRangeLimit:e})=>({"&.MuiPickersDay-root":{position:"relative",zIndex:1,"&.Mui-selected":{color:t.palette.text.primary},...e&&{"&.Mui-selected":{backgroundColor:`${t.palette.primary.main} !important`,color:t.palette.primary.contrastText,"&:hover":{backgroundColor:`${t.palette.primary.dark} !important`}}}}})),J=(t,e)=>!t||!e?!1:t.getFullYear()===e.getFullYear()&&t.getMonth()===e.getMonth()&&t.getDate()===e.getDate();function X({day:t,startDate:e,endDate:o,selectedMonth:r,...i}){const l=!!(e&&J(e,t)),s=!!(o&&J(o,t)),d=!!(e&&o&&t.getTime()>=e.getTime()&&t.getTime()<=o.getTime()),c=t.getDate()===1,p=t.getDate()===new Date(t.getFullYear(),t.getMonth()+1,0).getDate(),x=!!(r&&t.getMonth()===r.getMonth());return n.jsx(Ge,{isSelected:d,isStartDate:l,isEndDate:s,isSelectedMonth:x,isLastDay:p,isFirstDay:c,children:n.jsx(Ve,{...i,day:t,selected:d||l||s,isDateRangeLimit:l||s,"data-name":"pickers-day"})})}const Ue=a.styled(a.Box,{shouldForwardProp:t=>!["variant"].includes(t)})(({variant:t,theme:e})=>({display:"flex",gap:t==="standard"?e.spacing(1):"1px","& .CartoDatePicker-root":{"&:first-of-type":{".MuiInputBase-root":{borderRadius:e.spacing(.5,0,0,.5),boxShadow:`1px 0 0 0 ${e.palette.default.outlinedBorder}`,...t==="outlined"&&{"&:not(:hover):not(.Mui-focused):not(.Mui-error) .MuiOutlinedInput-notchedOutline":{borderRightColor:"transparent"}},...t==="filled"&&{"&::before, &::after":{borderRadius:e.spacing(.5,0,0,.5)}},...t==="standard"&&{boxShadow:"none",borderRadius:0}}},"&:last-of-type":{".MuiInputBase-root":{borderRadius:e.spacing(0,.5,.5,0),...t==="outlined"&&{"&:not(:hover):not(.Mui-focused):not(.Mui-error) .MuiOutlinedInput-notchedOutline":{borderLeftColor:"transparent"}},...t==="filled"&&{"&::before, &::after":{borderRadius:e.spacing(0,.5,.5,0)}},...t==="standard"&&{borderRadius:0}}}}}));function Ze({globalHelperText:t,error:e,variant:o="outlined",startProps:r,endProps:i,"aria-label":l,"data-testid":s,...d}){const c=w.useIntl(),p=h.useImperativeIntl(c),[x,u]=b.useState(!1),[m,g]=b.useState(!1),[f,M]=b.useState((r==null?void 0:r.value)||null),[y,T]=b.useState((i==null?void 0:i.value)||null),[I,v]=b.useState((i==null?void 0:i.value)??(r==null?void 0:r.value)??new Date),j=e??(r==null?void 0:r.error)??(i==null?void 0:i.error),C=(B,R)=>{M(B),r!=null&&r.onChange&&r.onChange(B,R),B&&R.validationError===null&&!m&&R.trigger===null&&(g(!1),u(!0))},D=(B,R)=>{T(B),i!=null&&i.onChange&&i.onChange(B,R)},A=()=>{g(!0),u(!1),setTimeout(()=>{v(f??new Date)},120)},k=()=>{g(!1),u(!0),setTimeout(()=>{v(y??f??new Date)},120)},F=()=>{g(!1),u(!0),setTimeout(()=>{v(y??f??new Date)},120)};return n.jsxs(a.Box,{children:[n.jsxs(Ue,{variant:o,"data-name":"date-range-picker","aria-label":l,"data-testid":s,children:[n.jsx($,{...d,...r,value:(r==null?void 0:r.value)??f,maxDate:y??void 0,label:(r==null?void 0:r.label)??p.formatMessage({id:"c4r.form.startDate"}),slotProps:{popper:{placement:"bottom-start","aria-label":p.formatMessage({id:"c4r.form.startDateCalendar"})},...r==null?void 0:r.slotProps},slots:{openPickerIcon:S.TodayOutlined,day:B=>n.jsx(X,{...B,startDate:f,endDate:y,selectedMonth:I}),...r==null?void 0:r.slots},error:(r==null?void 0:r.error)??e,open:m,onChange:C,onOpen:A,onClose:k,onMonthChange:B=>v(B),variant:o}),n.jsx($,{...d,...i,value:(i==null?void 0:i.value)??y,minDate:f??void 0,slotProps:{popper:{"aria-label":p.formatMessage({id:"c4r.form.endDateCalendar"})},...i==null?void 0:i.slotProps},slots:{day:B=>n.jsx(X,{...B,startDate:f,endDate:y,selectedMonth:I}),...i==null?void 0:i.slots},label:(i==null?void 0:i.label)??p.formatMessage({id:"c4r.form.endDate"}),error:(i==null?void 0:i.error)??e,open:x,onOpen:F,onClose:()=>u(!1),onChange:D,onMonthChange:B=>v(B),variant:o})]}),t&&n.jsx(a.FormHelperText,{error:j,children:t})]})}const pt=(t,e,o,r)=>{const i=t==null?void 0:t.includes("hours"),l=t==null?void 0:t.includes("seconds"),s=t==null?void 0:t.includes("minutes"),d=(t==null?void 0:t.length)===1&&t[0]==="hours";if(r)return r;const c=[];return e&&c.push("MM/dd/yyyy "),i&&c.push(o?"hh":"HH"),d||c.push(":"),s&&c.push("mm"),l&&c.push(":ss"),o&&c.push(" a"),c.join("")};function ze({handleClear:t,variant:e="outlined",size:o="small",label:r,labelHelpTooltip:i,type:l,helperText:s,placeholder:d,error:c,showClock:p=!0,readOnly:x,slotProps:u,slots:m,ampm:g=!0,views:f=["hours","minutes"],format:M,"data-testid":y,"aria-label":T,...I}){const v=w.useIntl(),j=h.useImperativeIntl(v),C=b.useRef(null),[D,A]=b.useState(0);return b.useEffect(()=>{if(!C.current)return;const k=new ResizeObserver(F=>{var R;const B=(R=F[0])==null?void 0:R.contentRect.width;B&&A(B)});return k.observe(C.current),()=>{k.disconnect()}},[]),n.jsx(V,{size:o,variant:e,readOnly:x,"data-name":"time-picker","data-testid":y??"time-picker","aria-label":T,children:n.jsx(mt.TimePicker,{...I,ref:C,label:n.jsx(O,{label:r??j.formatMessage({id:"c4r.form.time"}),type:l,icon:i&&n.jsx(a.Tooltip,{title:i,children:n.jsx(S.HelpOutline,{htmlColor:"text.secondary"})})}),views:["hours"],format:pt(f,!1,g,M),slotProps:{textField:{variant:e,helperText:s,placeholder:d,size:o,error:c??void 0,inputProps:{"data-testid":"time-picker-input"}},field:{clearable:!!t,onClear:t},popper:{placement:"bottom-end"},layout:{sx:{width:D}},...u},slots:{clearButton:k=>n.jsx(G,{...k,size:o,variant:e}),openPickerButton:k=>n.jsx(a.IconButton,{...k,size:o,"aria-label":j.formatMessage({id:"c4r.form.chooseDate"})}),...m},disableOpenPicker:!p,readOnly:x,ampm:g})})}function Ye({handleClear:t,variant:e="outlined",size:o="small",label:r,labelHelpTooltip:i,type:l,helperText:s,placeholder:d,error:c,showCalendar:p=!0,readOnly:x,slotProps:u,slots:m,ampm:g=!0,views:f=["hours","minutes"],format:M,"data-testid":y,"aria-label":T,...I}){const v=w.useIntl(),j=h.useImperativeIntl(v);return n.jsx(V,{size:o,variant:e,readOnly:x,"data-name":"date-time-picker","data-testid":y??"date-time-picker","aria-label":T,children:n.jsx(bt.DateTimePicker,{...I,label:n.jsx(O,{label:r??j.formatMessage({id:"c4r.form.time"}),type:l,icon:i&&n.jsx(a.Tooltip,{title:i,children:n.jsx(S.HelpOutline,{htmlColor:"text.secondary"})})}),views:["year","month","day","hours"],format:pt(f,!0,g,M),slotProps:{textField:{variant:e,helperText:s,placeholder:d,size:o,error:c??void 0,inputProps:{"data-testid":"date-time-picker-input"}},field:{clearable:!!t,onClear:t},...u},slots:{clearButton:C=>n.jsx(G,{...C,size:o,variant:e}),openPickerButton:C=>n.jsx(a.IconButton,{...C,size:o,"aria-label":j.formatMessage({id:"c4r.form.chooseDate"})}),...m},disableOpenPicker:!p,readOnly:x,ampm:g})})}const Je=[{outlinedBullet:!1,value:""}],Xe=a.styled("ul")(({theme:t})=>({listStyle:"none",paddingLeft:0,margin:t.spacing(.5,0,0,0)})),Ke=a.styled("li")(({theme:t})=>({display:"flex",alignItems:"center",justifyContent:"space-between","&:not(:last-child)":{marginBottom:t.spacing(.5)}})),Qe=a.styled("span")(({theme:t})=>({width:t.spacing(1),height:t.spacing(1),marginRight:t.spacing(.5),border:`2px solid ${t.palette.qualitative.bold[1]}`,borderRadius:"50%",backgroundColor:t.palette.qualitative.bold[1]})),to=a.styled(h.Typography)(({theme:t})=>({minWidth:t.spacing(10),marginRight:t.spacing(1.5)}));function eo({items:t=Je,title:e}){return n.jsxs(n.Fragment,{children:[e&&n.jsx(h.Typography,{color:"inherit",variant:"caption",weight:"medium",children:e}),n.jsx(Xe,{children:t.map((o,r)=>n.jsxs(Ke,{children:[n.jsx(Qe,{style:{backgroundColor:`${o.outlinedBullet?"transparent":o.color}`,borderColor:o.color}}),o.category&&n.jsx(to,{color:"inherit",variant:"caption",children:o.category}),n.jsx(h.Typography,{color:"inherit",variant:"caption",weight:"medium",children:o.value})]},r))})]})}const K={small:"480px",medium:"640px",large:"640px",xlarge:"720px"},E={small:{width:"432px",maxWidth:"432px"},medium:{width:"592px",maxWidth:"592px"},large:{width:"768px",maxWidth:"768px",minHeight:"576px"},xlarge:{width:"calc(100vw - 80px)",height:"calc(100vh - 80px)",maxWidth:"960px"}},W=a.styled(a.Paper,{shouldForwardProp:t=>!["fullScreen","height","width","hasForm"].includes(t)})(({fullScreen:t,height:e,width:o,hasForm:r,size:i="small",theme:l})=>({"&.MuiPaper-root":{position:"relative",display:"flex",flexDirection:"column",margin:l.spacing(5),borderRadius:l.spacing(1),...E[i],maxHeight:K[i],[`@media (max-height:${K[i]})`]:{maxHeight:"calc(100vh - 80px)",...i==="large"&&{minHeight:e!=="auto"?"calc(100vh - 80px)":"auto"}},...t&&{width:"100vw",maxWidth:`calc(100vw - ${l.spacing(10)})`,height:"100vh",maxHeight:`calc(100vh - ${l.spacing(10)})`,margin:l.spacing(5),borderRadius:l.spacing(1)},...e&&{height:e,minHeight:e},...o&&{width:o},[l.breakpoints.down("sm")]:{position:"absolute",width:"100%",maxWidth:"100%",height:"100vh",maxHeight:"100vh",top:0,bottom:0,left:0,right:0,margin:0,borderRadius:0,...e&&{top:"auto",borderRadius:l.spacing(1,1,0,0),height:e,minHeight:e}},...r&&{maxHeight:`calc(100vh - ${l.spacing(10)})`,form:{flex:1,display:"flex",flexDirection:"column",justifyContent:"space-between",overflow:"hidden",...E[i],maxWidth:"100%",...t&&{width:"100%",maxWidth:"100%",height:"100%",maxHeight:"100%"},...e&&{height:e,minHeight:e},...o&&{width:o},[l.breakpoints.down("sm")]:{width:"100%",maxWidth:"100%",height:"100vh",maxHeight:"100vh",...e&&{top:"auto",borderRadius:l.spacing(1,1,0,0),height:e,minHeight:e}}}}}}));function oo({nonModal:t,children:e,size:o="small",PaperProps:r,fullScreen:i,height:l,width:s,hasForm:d,"aria-label":c,"data-testid":p,...x},u){return t?n.jsx(W,{size:o,fullScreen:i,height:l,width:s,hasForm:d,"aria-label":c,"data-testid":p,"data-name":"dialog",...x,ref:u,children:e}):n.jsx(a.Dialog,{PaperComponent:W,PaperProps:{...r,size:o,fullScreen:i,height:l,width:s,hasForm:d},fullScreen:i,role:"section","aria-label":c,"data-testid":p,"data-size":o,"data-width":s,"data-height":l,"data-name":"dialog",...x,ref:u,children:e})}const no=b.forwardRef(oo),ro=a.styled(a.DialogTitle)(()=>({padding:0,zIndex:10})),ao=a.styled(a.Box)(({theme:t})=>({display:"flex",alignItems:"center",justifyContent:"space-between",padding:t.spacing(2),minHeight:t.spacing(8)})),Q=a.styled(a.Box)(({theme:t})=>({display:"flex",alignItems:"center",gap:t.spacing(1),overflow:"hidden"})),io=a.styled(S.CloseOutlined)(({theme:t})=>({color:t.palette.text.secondary})),lo=a.styled(a.Divider)(()=>({"+ .MuiDialogContent-root":{borderTop:"none !important"}}));function so({title:t,chipLabel:e,chipProps:o,children:r,onClose:i,secondaryActions:l,"aria-label":s,closeIcon:d,...c}){const p=w.useIntl(),x=h.useImperativeIntl(p);return n.jsxs(n.Fragment,{children:[n.jsxs(ro,{component:"div","data-name":"dialog-header",...c,children:[n.jsxs(ao,{children:[n.jsxs(Q,{flex:1,maxWidth:.8,children:[n.jsx(h.Typography,{component:"h2",variant:"inherit",noWrap:!0,"aria-label":s,role:"heading",children:t}),e&&n.jsx(a.Chip,{color:"default",label:e,...o})]}),n.jsxs(Q,{children:[l,i&&n.jsx(a.Tooltip,{title:x.formatMessage({id:"c4r.button.close"}),placement:"left",children:n.jsx(a.IconButton,{onClick:i,children:d||n.jsx(io,{"data-testid":"CloseIcon"})})})]})]}),r]}),r&&n.jsx(lo,{})]})}const co=a.styled(a.DialogContent,{shouldForwardProp:t=>!["scrollableContent","withGutter","withBottomGutter"].includes(t)})(({theme:t,scrollableContent:e,withGutter:o,withBottomGutter:r})=>({display:"flex",flexDirection:"column",gap:t.spacing(3),padding:0,...t.typography.body2,color:t.palette.text.secondary,".MuiAlert-root":{minHeight:"auto"},...e&&{borderBottom:`1px solid ${t.palette.divider}`,"+ .MuiDivider-root":{display:"none"}},...o&&{padding:` ${t.spacing(1,2,0)} !important`,".MuiDialog-paperFullScreen &":{padding:`${t.spacing(2,2,0)} !important`}},...r&&{paddingBottom:`${t.spacing(3)} !important`,".MuiDialog-paperFullScreen &":{paddingBottom:`${t.spacing(3)} !important`}}}));function uo({children:t,scrollableContent:e,hasFooterAlert:o,withGutter:r=!0,withBottomGutter:i=!0,onScroll:l,...s},d){const c=a.useTheme(),[p,x]=b.useState(null);b.useImperativeHandle(d,()=>p,[p]);const u=b.useCallback(g=>{const f=Math.abs(g.scrollHeight-g.clientHeight-g.scrollTop)<1,M=g.scrollTop===0,y=`1px solid ${c.palette.divider}`;g.style.borderTop=M?"none":y,g.style.borderBottom=f&&!o?"none":y},[c.palette.divider,o]),m=b.useCallback(g=>{u(g.target),l==null||l(g)},[u,l]);return b.useEffect(()=>{p&&u(p)},[p,u]),b.useEffect(()=>{if(!p||typeof ResizeObserver>"u")return;const g=new ResizeObserver(()=>{u(p)});return g.observe(p),()=>g.disconnect()},[p,u]),n.jsx(co,{ref:x,onScroll:m,scrollableContent:e,withGutter:r,withBottomGutter:i&&r,"data-name":"dialog-content",...s,children:t})}const gt=b.forwardRef(uo),po=a.styled(gt,{shouldForwardProp:t=>t!=="withAlert"})(({withAlert:t,theme:e})=>({padding:`${e.spacing(0,2)} !important`,...t&&{paddingBottom:`${e.spacing(3)} !important`}})),go=a.styled(_.Alert)(({theme:t})=>({minHeight:"auto",padding:0,backgroundColor:"transparent","& .MuiTypography-root":{color:t.palette.text.secondary,a:{color:t.palette.primary.main}},"& .MuiAlertTitle-root":{color:t.palette.text.primary}}));function U({children:t,severity:e="neutral",...o}){return n.jsx(go,{severity:e,...o,"data-name":"dialog-alert",children:t})}const xo=a.styled(a.Box,{shouldForwardProp:t=>!["dark","hasChildren"].includes(t)})(({dark:t,hasChildren:e,theme:o})=>({flex:"0 0 auto",display:"block",minHeight:e?o.spacing(8):"auto",zIndex:10,...t&&{backgroundColor:o.palette.common.black,color:o.palette.white[60],".MuiAlert-root":{".MuiTypography-root, .MuiAlert-message :not(.MuiAlertTitle-root)":{color:o.palette.white[60],a:{color:`${o.palette.secondary.main} !important`}},".MuiAlert-icon":{color:o.palette.white[60]}}}})),fo=a.styled(a.Box)(()=>({display:"flex",alignItems:"center",justifyContent:"space-between","& > div:empty":{padding:0}})),mo=a.styled(a.Box,{shouldForwardProp:t=>t!=="hasAlert"})(({hasAlert:t,theme:e})=>({display:"flex",alignItems:"center",gap:e.spacing(1),padding:e.spacing(2),paddingTop:t?0:e.spacing(2)})),Z=a.styled(a.DialogActions,{shouldForwardProp:t=>t!=="hasAlert"})(({hasAlert:t,theme:e})=>({gap:e.spacing(1),padding:e.spacing(2),paddingTop:t?0:e.spacing(2),margin:0,".MuiButton-root + .MuiButton-root":{marginLeft:0}})),bo=a.styled(a.Divider)(()=>({marginTop:"-1px"}));function yo({children:t,secondaryActions:e,alertContent:o,alertProps:r,dark:i,topContent:l,...s}){return n.jsxs(n.Fragment,{children:[l,!!o&&n.jsx(bo,{}),n.jsxs(xo,{...s,dark:i,"data-theme":i?"dark":"light","data-name":"dialog-footer",hasChildren:!!t,children:[!!o&&n.jsx(a.Box,{sx:{p:2,pt:1.5,pb:1},children:n.jsx(U,{...r,children:o})}),n.jsxs(fo,{children:[n.jsx(mo,{hasAlert:!!o,children:e}),n.jsx(Z,{hasAlert:!!o,children:t})]})]})]})}const ho=a.styled(a.Box)(({theme:t})=>({position:"absolute",width:"100%",zIndex:100,top:0,bottom:0,left:0,right:0,overflow:"hidden",display:"flex",boxSizing:"border-box",alignItems:"flex-end",background:t.palette.white[60]})),jo=a.styled("div")(()=>({width:"100%"})),Mo=a.styled(a.Box)(({theme:t})=>({width:"100%",padding:t.spacing(1.5,2,2),backgroundColor:t.palette.background.paper,borderTop:`1px solid ${t.palette.divider}`,".MuiDialogActions-root":{padding:0,marginTop:t.spacing(1)}}));function Co({children:t,onClickAway:e,actions:o,severity:r="warning",opened:i,"data-testid":l,"aria-label":s,...d}){const c=b.useRef(null),p=a.useTheme(),x=()=>{e&&e()};return n.jsx(ho,{ref:c,"data-testid":l,"aria-label":s,role:"presentation","data-name":"dialog-confirmation",children:n.jsx(yt,{onClickAway:x,children:n.jsx(a.Slide,{direction:"up",in:i,container:c.current,mountOnEnter:!0,unmountOnExit:!0,easing:p.transitions.easing.easeOut,timeout:350,children:n.jsx(jo,{children:n.jsxs(Mo,{children:[n.jsx(U,{severity:r,...d,children:t}),n.jsx(Z,{children:o})]})})})})})}const Io=a.styled(a.Box)(({theme:t})=>({display:"flex",alignItems:"center",justifyContent:"center",height:t.spacing(8),marginBottom:t.spacing(2),"& > div":{flex:1}})),vo=a.styled(a.Box)(({theme:t})=>({display:"flex",flex:1,flexDirection:"column",justifyContent:"center",alignItems:"center",position:"relative","&:before, &:after":{content:'""',background:t.palette.divider,position:"absolute",top:t.spacing(1.25),height:t.spacing(.25),width:`calc(50% - ${t.spacing(2.5)})`},"&:before":{left:0},"&:after":{right:0},"&:first-of-type:before":{content:"none"},"&:last-of-type:after":{content:"none"}}));function To({theme:t,completed:e,current:o}){return e?{background:t.palette.success.main,borderColor:t.palette.success.main,color:t.palette.common.white}:o?{background:t.palette.text.primary,borderColor:t.palette.text.primary,color:t.palette.common.white}:{borderColor:t.palette.text.secondary,color:t.palette.text.secondary}}const Bo=a.styled("span",{shouldForwardProp:t=>t!=="completed"&&t!=="current"})(({theme:t,completed:e,current:o})=>({display:"flex",justifyContent:"center",alignItems:"center",height:t.spacing(3),width:t.spacing(3),marginBottom:t.spacing(1),borderRadius:"50%",border:`${t.spacing(.25)} solid currentColor`,...t.typography.caption,...To({theme:t,completed:e,current:o})}));function ko({currentStep:t,stepsLabels:e,...o}){return n.jsx(Io,{...o,"data-name":"dialog-stepper",children:n.jsx(a.Box,{sx:{display:"flex"},children:e.map((r,i)=>{const l=i+1,s=l===t,d=l<t,c=d?"success.main":s?"textPrimary":"textSecondary";return n.jsxs(vo,{"data-state":d?"completed":s?"current":"uncompleted",children:[n.jsx(Bo,{completed:d,current:s,children:d?n.jsx(S.Check,{fontSize:"small","aria-label":"Completed step"}):l}),n.jsx(h.Typography,{variant:"caption",component:"div",color:c,children:r})]},i)})})})}exports.TablePaginationActions=h.TablePaginationActions;exports.Typography=h.Typography;exports.Alert=_.Alert;exports.MenuItem=H.MenuItem;exports.AccordionGroup=fe;exports.AppBar=Pe;exports.Autocomplete=ae;exports.Avatar=be;exports.Button=Ct;exports.CopiableComponent=ge;exports.CreatableAutocomplete=ce;exports.DatePicker=$;exports.DateRangePicker=Ze;exports.DateTimePicker=Ye;exports.Dialog=no;exports.DialogActions=Z;exports.DialogAlert=U;exports.DialogConfirmation=Co;exports.DialogContent=gt;exports.DialogContentPadded=po;exports.DialogFooter=yo;exports.DialogHeader=so;exports.DialogPaper=W;exports.DialogStepper=ko;exports.IconButton=N;exports.LabelWithIndicator=O;exports.Menu=_t;exports.MenuItemFilter=q;exports.MenuList=Nt;exports.MultipleAutocomplete=ue;exports.MultipleSelectField=Kt;exports.PasswordField=kt;exports.SelectField=tt;exports.Snackbar=ut;exports.Tag=ke;exports.TimePicker=ze;exports.ToggleButtonGroup=Ft;exports.TooltipData=eo;exports.UploadField=ne;exports.UploadFieldBase=et;exports.copyString=st;exports.dialogDimensionsBySize=E;exports.useCopyValue=ct;
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const jsxRuntime = require("react/jsx-runtime");
4
+ const React = require("react");
5
+ const material = require("@mui/material");
6
+ const TablePaginationActions = require("../TablePaginationActions-BG2gWq0M.cjs");
7
+ const reactIntl = require("react-intl");
8
+ const iconsMaterial = require("@mui/icons-material");
9
+ const Alert$1 = require("../Alert-DFaAeTZf.cjs");
10
+ require("cartocolor");
11
+ const MenuItem = require("../MenuItem-Br2jY2lt.cjs");
12
+ const ArrowDown = require("../ArrowDown-8fLj23Ge.cjs");
13
+ const DatePicker$1 = require("@mui/x-date-pickers/DatePicker");
14
+ const xDatePickers = require("@mui/x-date-pickers");
15
+ const TimePicker$1 = require("@mui/x-date-pickers/TimePicker");
16
+ const DateTimePicker$1 = require("@mui/x-date-pickers/DateTimePicker");
17
+ const ClickAwayListener = require("@mui/material/ClickAwayListener");
18
+ const IndicatorIcon = material.styled(material.Box)({
19
+ position: "absolute",
20
+ top: 0,
21
+ left: 0,
22
+ right: 0,
23
+ bottom: 0,
24
+ display: "flex",
25
+ alignItems: "center",
26
+ justifyContent: "center"
27
+ });
28
+ const HiddenText = material.styled(material.Box)({
29
+ visibility: "hidden",
30
+ pointerEvents: "none"
31
+ });
32
+ function _Button({
33
+ children,
34
+ loading,
35
+ disabled,
36
+ startIcon,
37
+ endIcon,
38
+ loadingPosition,
39
+ ...otherProps
40
+ }, ref) {
41
+ const defaultIconLoader = /* @__PURE__ */ jsxRuntime.jsx(material.CircularProgress, { size: 18, color: "inherit" });
42
+ const isDefaultLoading = loading && loadingPosition === void 0;
43
+ const renderContent = () => {
44
+ if (isDefaultLoading) {
45
+ return /* @__PURE__ */ jsxRuntime.jsxs(material.Box, { sx: { position: "relative" }, children: [
46
+ /* @__PURE__ */ jsxRuntime.jsx(IndicatorIcon, { children: defaultIconLoader }),
47
+ /* @__PURE__ */ jsxRuntime.jsx(HiddenText, { children })
48
+ ] });
49
+ }
50
+ return children;
51
+ };
52
+ const getIconForPosition = (position) => {
53
+ if (isDefaultLoading) {
54
+ return void 0;
55
+ }
56
+ if (loading && loadingPosition !== void 0) {
57
+ if (loadingPosition === position) {
58
+ return defaultIconLoader;
59
+ }
60
+ return void 0;
61
+ }
62
+ return position === "start" ? startIcon : endIcon;
63
+ };
64
+ return /* @__PURE__ */ jsxRuntime.jsx(
65
+ material.Button,
66
+ {
67
+ disabled: loading || disabled,
68
+ startIcon: getIconForPosition("start"),
69
+ endIcon: getIconForPosition("end"),
70
+ ...otherProps,
71
+ role: otherProps.href ? "link" : "button",
72
+ ref,
73
+ children: /* @__PURE__ */ jsxRuntime.jsx(TablePaginationActions.Typography, { variant: "inherit", color: "inherit", noWrap: true, component: "span", children: renderContent() })
74
+ }
75
+ );
76
+ }
77
+ const Button = React.forwardRef(_Button);
78
+ const Root$4 = material.styled(material.Box)(({ theme }) => ({
79
+ display: "flex",
80
+ alignItems: "center",
81
+ gap: theme.spacing(0.5)
82
+ }));
83
+ const Indicator = material.styled(TablePaginationActions.Typography)(({ theme }) => ({
84
+ ".Mui-disabled &": {
85
+ color: theme.palette.text.disabled
86
+ }
87
+ }));
88
+ const Icon = material.styled(material.Box)(({ theme }) => ({
89
+ display: "flex",
90
+ svg: {
91
+ width: TablePaginationActions.ICON_SIZE_SMALL,
92
+ height: TablePaginationActions.ICON_SIZE_SMALL,
93
+ fontSize: TablePaginationActions.ICON_SIZE_SMALL,
94
+ path: {
95
+ fill: theme.palette.text.secondary,
96
+ ".Mui-disabled &": {
97
+ fill: theme.palette.text.disabled
98
+ }
99
+ }
100
+ }
101
+ }));
102
+ function LabelWithIndicator({
103
+ label,
104
+ type,
105
+ icon,
106
+ inheritSize
107
+ }) {
108
+ return /* @__PURE__ */ jsxRuntime.jsxs(Root$4, { children: [
109
+ label,
110
+ type && /* @__PURE__ */ jsxRuntime.jsx(
111
+ Indicator,
112
+ {
113
+ component: "span",
114
+ variant: inheritSize ? "inherit" : "caption",
115
+ color: "textSecondary",
116
+ weight: "regular",
117
+ children: type === "required" ? "(required)" : "(optional)"
118
+ }
119
+ ),
120
+ icon && /* @__PURE__ */ jsxRuntime.jsx(Icon, { children: icon })
121
+ ] });
122
+ }
123
+ function _PasswordField({ InputProps, size = "small", ...otherProps }, ref) {
124
+ const intl = reactIntl.useIntl();
125
+ const intlConfig = TablePaginationActions.useImperativeIntl(intl);
126
+ const [showPassword, setShowPassword] = React.useState(false);
127
+ const handleClickShowPassword = () => setShowPassword(!showPassword);
128
+ return /* @__PURE__ */ jsxRuntime.jsx(
129
+ material.TextField,
130
+ {
131
+ ...otherProps,
132
+ ref,
133
+ type: showPassword ? "text" : "password",
134
+ size,
135
+ InputProps: {
136
+ ...InputProps,
137
+ endAdornment: /* @__PURE__ */ jsxRuntime.jsx(material.InputAdornment, { position: "end", children: /* @__PURE__ */ jsxRuntime.jsx(material.IconButton, { size, onClick: handleClickShowPassword, children: /* @__PURE__ */ jsxRuntime.jsx(
138
+ material.Tooltip,
139
+ {
140
+ title: intlConfig.formatMessage({
141
+ id: `c4r.form.${showPassword ? "hidePassword" : "showPassword"}`
142
+ }),
143
+ children: showPassword ? /* @__PURE__ */ jsxRuntime.jsx(iconsMaterial.VisibilityOffOutlined, {}) : /* @__PURE__ */ jsxRuntime.jsx(iconsMaterial.VisibilityOutlined, {})
144
+ }
145
+ ) }) })
146
+ }
147
+ }
148
+ );
149
+ }
150
+ const PasswordField = React.forwardRef(_PasswordField);
151
+ const idCounter = {};
152
+ function uniqueId(prefix = "$lodash$") {
153
+ if (!idCounter[prefix]) {
154
+ idCounter[prefix] = 0;
155
+ }
156
+ const id = ++idCounter[prefix];
157
+ if (prefix === "$lodash$") {
158
+ return `${id}`;
159
+ }
160
+ return `${prefix}${id}`;
161
+ }
162
+ const StyledSelect = material.styled(material.Select)(({ theme }) => ({
163
+ "& .MuiInputAdornment-positionStart": {
164
+ paddingLeft: theme.spacing(2),
165
+ "&.MuiInputAdornment-sizeSmall": {
166
+ paddingLeft: theme.spacing(1.5)
167
+ }
168
+ },
169
+ "& .MuiInputBase-inputAdornedStart": {
170
+ paddingLeft: "0px !important"
171
+ },
172
+ "& .MuiSelect-select .MuiMenuItem-root:hover": {
173
+ backgroundColor: "transparent"
174
+ },
175
+ "&.MuiInputBase-root .MuiSelect-select.MuiSelect-multiple": {
176
+ paddingRight: theme.spacing(7)
177
+ }
178
+ }));
179
+ const PlaceholderItem = material.styled(material.MenuItem)(() => ({
180
+ display: "none"
181
+ }));
182
+ function _SelectField({
183
+ children,
184
+ placeholder,
185
+ size = "small",
186
+ displayEmpty,
187
+ menuProps,
188
+ inputProps,
189
+ labelId,
190
+ label,
191
+ labelSecondary,
192
+ helperText,
193
+ name,
194
+ error,
195
+ focused,
196
+ disabled,
197
+ fullWidth,
198
+ required,
199
+ "aria-label": ariaLabel,
200
+ ...otherProps
201
+ }, ref) {
202
+ const isSmall = size === "small";
203
+ const [defaultId] = React.useState(() => uniqueId("select-label-"));
204
+ const ariaLabelledBy = label ? labelId ?? defaultId : void 0;
205
+ return /* @__PURE__ */ jsxRuntime.jsxs(
206
+ material.FormControl,
207
+ {
208
+ size,
209
+ error,
210
+ focused,
211
+ disabled,
212
+ fullWidth,
213
+ required,
214
+ "data-name": "select-field",
215
+ "data-size": size,
216
+ children: [
217
+ /* @__PURE__ */ jsxRuntime.jsxs(material.Box, { display: "flex", alignItems: "center", justifyContent: "space-between", children: [
218
+ label && /* @__PURE__ */ jsxRuntime.jsx(material.InputLabel, { shrink: true, id: ariaLabelledBy, children: label }),
219
+ labelSecondary && /* @__PURE__ */ jsxRuntime.jsx(material.Box, { display: "flex", alignItems: "center", ml: 2, mb: 0.5, children: labelSecondary })
220
+ ] }),
221
+ /* @__PURE__ */ jsxRuntime.jsxs(
222
+ StyledSelect,
223
+ {
224
+ ...otherProps,
225
+ labelId: ariaLabelledBy,
226
+ name,
227
+ ref,
228
+ size,
229
+ fullWidth,
230
+ displayEmpty: displayEmpty ?? !!placeholder,
231
+ inputProps: {
232
+ ...inputProps,
233
+ "aria-label": ariaLabel
234
+ },
235
+ MenuProps: {
236
+ ...menuProps,
237
+ PopoverClasses: {
238
+ paper: isSmall ? "MuiMenu-paper-sizeSmall" : void 0
239
+ },
240
+ anchorOrigin: {
241
+ vertical: "bottom",
242
+ horizontal: "left"
243
+ },
244
+ transformOrigin: {
245
+ vertical: 0,
246
+ horizontal: "left"
247
+ }
248
+ },
249
+ children: [
250
+ placeholder && /* @__PURE__ */ jsxRuntime.jsx(PlaceholderItem, { disabled: true, value: "", children: /* @__PURE__ */ jsxRuntime.jsx(
251
+ TablePaginationActions.Typography,
252
+ {
253
+ variant: isSmall ? "body2" : "body1",
254
+ color: "text.hint",
255
+ component: "span",
256
+ children: placeholder
257
+ }
258
+ ) }),
259
+ children
260
+ ]
261
+ }
262
+ ),
263
+ helperText && /* @__PURE__ */ jsxRuntime.jsx(material.FormHelperText, { "aria-label": `${name}-helper`, children: helperText })
264
+ ]
265
+ }
266
+ );
267
+ }
268
+ const SelectField = React.forwardRef(_SelectField);
269
+ const StyledToggleButtonGroup = material.styled(material.ToggleButtonGroup, {
270
+ shouldForwardProp: (prop) => prop !== "variant" && prop !== "backgroundColor"
271
+ })(({ variant, backgroundColor, theme }) => ({
272
+ // Variants
273
+ ...variant === "contained" && {
274
+ boxShadow: "none"
275
+ },
276
+ ...variant === "unbounded" && {
277
+ boxShadow: "none",
278
+ borderRadius: theme.spacing(0.5),
279
+ "& .MuiDivider-root": {
280
+ height: theme.spacing(4),
281
+ "&.MuiToggleButtonGroup-groupedHorizontal": {
282
+ height: theme.spacing(4)
283
+ },
284
+ "&.MuiToggleButtonGroup-groupedVertical": {
285
+ height: "auto",
286
+ width: theme.spacing(4),
287
+ margin: `${theme.spacing(0.5, 0, 1)} !important`,
288
+ borderRadius: "0 !important"
289
+ }
290
+ },
291
+ "& .MuiToggleButton-sizeSmall": {
292
+ margin: 0,
293
+ "&.MuiToggleButtonGroup-grouped:not(.MuiDivider-root)": {
294
+ margin: 0
295
+ },
296
+ "& + .MuiDivider-root.MuiToggleButtonGroup-groupedHorizontal": {
297
+ height: theme.spacing(3)
298
+ },
299
+ "& + .MuiDivider-root.MuiToggleButtonGroup-groupedVertical": {
300
+ height: "auto",
301
+ width: theme.spacing(3)
302
+ }
303
+ },
304
+ ".MuiToggleButtonGroup-grouped:not(.MuiDivider-root)": {
305
+ margin: 0,
306
+ "&:first-of-type": {
307
+ marginLeft: 0
308
+ },
309
+ "&:not(:last-of-type)": {
310
+ marginRight: theme.spacing(0.5)
311
+ }
312
+ },
313
+ "&.MuiToggleButtonGroup-horizontal:not(.MuiDivider-root)": {
314
+ ".MuiToggleButtonGroup-grouped": {
315
+ margin: theme.spacing(0, 0.5)
316
+ }
317
+ },
318
+ "&.MuiToggleButtonGroup-vertical:not(.MuiDivider-root)": {
319
+ ".MuiToggleButtonGroup-grouped": {
320
+ margin: theme.spacing(0, 0, 0.5),
321
+ "&:not(:last-of-type)": {
322
+ marginRight: 0
323
+ },
324
+ "&:last-of-type": {
325
+ marginBottom: 0
326
+ }
327
+ }
328
+ }
329
+ },
330
+ // Colors
331
+ ...backgroundColor === "primary" && {
332
+ backgroundColor: theme.palette.background.paper
333
+ },
334
+ ...backgroundColor === "secondary" && {
335
+ backgroundColor: theme.palette.background.default
336
+ },
337
+ ...backgroundColor === "transparent" && {
338
+ backgroundColor: "transparent"
339
+ }
340
+ }));
341
+ function ToggleButtonGroup({
342
+ children,
343
+ variant = "floating",
344
+ backgroundColor,
345
+ ...rest
346
+ }) {
347
+ const isUnbounded = variant === "unbounded";
348
+ const defaultColor = isUnbounded ? "transparent" : "primary";
349
+ return /* @__PURE__ */ jsxRuntime.jsx(
350
+ StyledToggleButtonGroup,
351
+ {
352
+ ...rest,
353
+ variant,
354
+ backgroundColor: backgroundColor ?? defaultColor,
355
+ children
356
+ }
357
+ );
358
+ }
359
+ const Option = material.styled("div")(({ theme }) => ({
360
+ position: "relative",
361
+ display: "inline-flex",
362
+ // TODO: Remove this once we have a better way to handle the spacing between icon buttons:
363
+ // https://app.shortcut.com/cartoteam/story/471284/create-iconbuttongroup-component-to-properly-group-several-icons
364
+ "& + &, & + .optionIconButton": {
365
+ marginLeft: theme.spacing(0.5)
366
+ }
367
+ }));
368
+ const StyledIconButton = material.styled(material.IconButton, {
369
+ shouldForwardProp: (prop) => !["active"].includes(prop)
370
+ })(({ active, theme }) => ({
371
+ ...active && {
372
+ color: theme.palette.primary.main,
373
+ backgroundColor: theme.palette.primary.background,
374
+ "& svg:not(.doNotFillIcon) path": {
375
+ fill: theme.palette.primary.main
376
+ }
377
+ }
378
+ }));
379
+ function _IconButton({
380
+ tooltip,
381
+ tooltipPlacement = "top",
382
+ icon,
383
+ size = "medium",
384
+ variant = "icon",
385
+ color = "default",
386
+ sx,
387
+ className,
388
+ loading,
389
+ disabled,
390
+ active,
391
+ ...props
392
+ }, ref) {
393
+ return /* @__PURE__ */ jsxRuntime.jsx(material.Tooltip, { placement: tooltipPlacement, title: tooltip ?? "", children: /* @__PURE__ */ jsxRuntime.jsx(
394
+ Option,
395
+ {
396
+ className: `optionIconButton ${className ?? ""}`,
397
+ sx,
398
+ "data-testid": "icon-button",
399
+ children: /* @__PURE__ */ jsxRuntime.jsx(
400
+ StyledIconButton,
401
+ {
402
+ ...props,
403
+ ref,
404
+ size,
405
+ variant,
406
+ color,
407
+ active,
408
+ disabled: disabled || loading,
409
+ role: "button",
410
+ children: loading ? /* @__PURE__ */ jsxRuntime.jsx(material.CircularProgress, { size: 18, color: "inherit" }) : icon
411
+ }
412
+ )
413
+ }
414
+ ) });
415
+ }
416
+ const IconButton = React.forwardRef(_IconButton);
417
+ const StyledMenu = material.styled(material.Menu, {
418
+ shouldForwardProp: (prop) => !["extended", "width", "height"].includes(prop)
419
+ })(({ theme, extended, width, height }) => ({
420
+ ...extended && {
421
+ ".MuiMenuItem-root": {
422
+ minHeight: theme.spacing(6)
423
+ }
424
+ },
425
+ ...width && {
426
+ ".MuiList-root": {
427
+ width,
428
+ minWidth: width
429
+ }
430
+ },
431
+ ...height && {
432
+ ".MuiMenu-paper": {
433
+ overflow: "hidden"
434
+ },
435
+ ".MuiList-root": {
436
+ maxHeight: height
437
+ }
438
+ }
439
+ }));
440
+ function _Menu({ extended, width, height, MenuListProps, ...otherProps }, ref) {
441
+ return /* @__PURE__ */ jsxRuntime.jsx(
442
+ StyledMenu,
443
+ {
444
+ ...otherProps,
445
+ ref,
446
+ "data-name": "menu",
447
+ width,
448
+ height,
449
+ extended,
450
+ MenuListProps: {
451
+ ...MenuListProps,
452
+ "data-width": width,
453
+ "data-height": height,
454
+ "data-extended": extended
455
+ }
456
+ }
457
+ );
458
+ }
459
+ const Menu$1 = React.forwardRef(_Menu);
460
+ const StyledMenuList = material.styled(material.MenuList, {
461
+ shouldForwardProp: (prop) => !["extended", "width", "height"].includes(prop)
462
+ })(({ theme, extended, width, height }) => ({
463
+ ...extended && {
464
+ ".MuiMenuItem-root": {
465
+ minHeight: theme.spacing(6)
466
+ }
467
+ },
468
+ "&.MuiList-root": {
469
+ ...width && {
470
+ width,
471
+ minWidth: width
472
+ },
473
+ ...height && {
474
+ maxHeight: height
475
+ }
476
+ }
477
+ }));
478
+ function _MenuList({ extended, width, height, ...otherProps }, ref) {
479
+ return /* @__PURE__ */ jsxRuntime.jsx(
480
+ StyledMenuList,
481
+ {
482
+ ...otherProps,
483
+ ref,
484
+ width,
485
+ height,
486
+ extended,
487
+ "data-name": "menu-list",
488
+ "data-width": width,
489
+ "data-height": height,
490
+ "data-extended": extended
491
+ }
492
+ );
493
+ }
494
+ const MenuList = React.forwardRef(_MenuList);
495
+ const StyledMenuItem$1 = material.styled(MenuItem.MenuItem)(() => ({
496
+ marginTop: "0 !important"
497
+ }));
498
+ const LinkFilter = material.styled(material.Link)(
499
+ ({ disabled, theme }) => ({
500
+ display: "flex",
501
+ alignItems: "center",
502
+ gap: theme.spacing(1),
503
+ width: "100%",
504
+ textAlign: "initial",
505
+ ...disabled && {
506
+ pointerEvents: "none",
507
+ color: theme.palette.text.disabled
508
+ }
509
+ })
510
+ );
511
+ function _MenuItemFilter({
512
+ areAllSelected,
513
+ areAnySelected,
514
+ selectAll,
515
+ selectAllDisabled,
516
+ "aria-label": ariaLabel,
517
+ "data-testid": dataTestId
518
+ }, ref) {
519
+ const intl = reactIntl.useIntl();
520
+ const intlConfig = TablePaginationActions.useImperativeIntl(intl);
521
+ return /* @__PURE__ */ jsxRuntime.jsx(
522
+ StyledMenuItem$1,
523
+ {
524
+ ref,
525
+ fixed: true,
526
+ "data-name": "menu-filter",
527
+ "aria-label": ariaLabel,
528
+ "data-testid": dataTestId,
529
+ children: /* @__PURE__ */ jsxRuntime.jsxs(
530
+ LinkFilter,
531
+ {
532
+ variant: "body2",
533
+ color: "textPrimary",
534
+ component: "button",
535
+ underline: "none",
536
+ disabled: !!selectAllDisabled,
537
+ onClick: selectAll,
538
+ tabIndex: 0,
539
+ children: [
540
+ /* @__PURE__ */ jsxRuntime.jsx(
541
+ material.Checkbox,
542
+ {
543
+ checked: areAllSelected,
544
+ indeterminate: areAnySelected && !areAllSelected,
545
+ disabled: selectAllDisabled
546
+ }
547
+ ),
548
+ intlConfig.formatMessage({ id: "c4r.form.selectAll" })
549
+ ]
550
+ }
551
+ )
552
+ }
553
+ );
554
+ }
555
+ const MenuItemFilter = React.forwardRef(_MenuItemFilter);
556
+ function useMultipleSelectField({
557
+ selectedOptions,
558
+ options,
559
+ onChange
560
+ }) {
561
+ const [currentOptions, setCurrentOptions] = React.useState(selectedOptions ?? []);
562
+ const areAllSelected = options.length === currentOptions.length;
563
+ const areAnySelected = currentOptions.length > 0;
564
+ React.useEffect(() => {
565
+ if (currentOptions !== selectedOptions) {
566
+ setCurrentOptions(currentOptions);
567
+ }
568
+ }, [selectedOptions]);
569
+ const handleChange = (event) => {
570
+ const {
571
+ target: { value }
572
+ } = event;
573
+ const options2 = typeof value === "string" ? value.split(",") : value.filter((v) => v !== void 0);
574
+ setCurrentOptions(options2);
575
+ onChange(options2);
576
+ };
577
+ const selectAll = () => {
578
+ const optionsValues = options == null ? void 0 : options.filter(({ disabled }) => !disabled).map(({ value }) => value);
579
+ if (optionsValues) {
580
+ const allSelected = optionsValues.every(
581
+ (value) => currentOptions.includes(value)
582
+ );
583
+ if (allSelected) {
584
+ setCurrentOptions([]);
585
+ onChange([]);
586
+ } else {
587
+ setCurrentOptions(optionsValues);
588
+ onChange(optionsValues);
589
+ }
590
+ }
591
+ };
592
+ const unselectAll = () => {
593
+ setCurrentOptions([]);
594
+ onChange([]);
595
+ };
596
+ return {
597
+ areAllSelected,
598
+ areAnySelected,
599
+ currentOptions,
600
+ handleChange,
601
+ selectAll,
602
+ unselectAll
603
+ };
604
+ }
605
+ const StyledMenuItem = material.styled(material.MenuItem)(({ theme }) => ({
606
+ "&.Mui-disabled": {
607
+ pointerEvents: "auto",
608
+ "&:hover": {
609
+ backgroundColor: `${theme.palette.background.default} !important`
610
+ }
611
+ }
612
+ }));
613
+ const UnselectButton = material.styled(material.InputAdornment, {
614
+ shouldForwardProp: (prop) => prop !== "size"
615
+ })(({ theme, size }) => ({
616
+ display: "none",
617
+ position: "absolute",
618
+ top: theme.spacing(2),
619
+ right: theme.spacing(3.5),
620
+ ".MuiInputBase-root:hover &, .MuiInputBase-root.Mui-focused &": {
621
+ display: "flex"
622
+ },
623
+ ".MuiSvgIcon-root": {
624
+ color: theme.palette.text.hint
625
+ },
626
+ ...size === "medium" && {
627
+ top: theme.spacing(3),
628
+ right: theme.spacing(5)
629
+ }
630
+ }));
631
+ const EMPTY_ARRAY = [];
632
+ const EMPTY_FN = () => void 0;
633
+ function _MultipleSelectField({
634
+ options = EMPTY_ARRAY,
635
+ selectedOptions,
636
+ size = "small",
637
+ placeholder,
638
+ showCounter,
639
+ showFilters = true,
640
+ onChange = EMPTY_FN,
641
+ selectAllDisabled,
642
+ tooltipPlacement,
643
+ variant,
644
+ ...props
645
+ }, ref) {
646
+ const {
647
+ areAllSelected,
648
+ areAnySelected,
649
+ currentOptions,
650
+ handleChange,
651
+ selectAll,
652
+ unselectAll
653
+ } = useMultipleSelectField({
654
+ options,
655
+ selectedOptions,
656
+ onChange
657
+ });
658
+ const isSmall = size === "small";
659
+ const paddingSize = isSmall || variant === "standard" ? 0 : 2;
660
+ const intl = reactIntl.useIntl();
661
+ const intlConfig = TablePaginationActions.useImperativeIntl(intl);
662
+ const counterText = `${currentOptions.length} ${intlConfig.formatMessage({
663
+ id: "c4r.form.selected"
664
+ })}`;
665
+ const renderValue = React.useMemo(() => {
666
+ if (areAllSelected) {
667
+ return /* @__PURE__ */ jsxRuntime.jsx(
668
+ TablePaginationActions.Typography,
669
+ {
670
+ component: "span",
671
+ variant: isSmall ? "body2" : "body1",
672
+ color: "textPrimary",
673
+ ml: paddingSize,
674
+ children: intlConfig.formatMessage({ id: "c4r.form.allSelected" })
675
+ }
676
+ );
677
+ }
678
+ if (areAnySelected) {
679
+ return /* @__PURE__ */ jsxRuntime.jsx(
680
+ TablePaginationActions.Typography,
681
+ {
682
+ component: "span",
683
+ variant: isSmall ? "body2" : "body1",
684
+ color: "textPrimary",
685
+ ml: paddingSize,
686
+ children: showCounter && currentOptions.length > 1 ? counterText : currentOptions.join(", ")
687
+ }
688
+ );
689
+ }
690
+ return /* @__PURE__ */ jsxRuntime.jsx(
691
+ TablePaginationActions.Typography,
692
+ {
693
+ component: "span",
694
+ variant: isSmall ? "body2" : "body1",
695
+ color: "text.hint",
696
+ ml: paddingSize,
697
+ children: placeholder ?? intlConfig.formatMessage({ id: "c4r.form.noneSelected" })
698
+ }
699
+ );
700
+ }, [
701
+ areAllSelected,
702
+ areAnySelected,
703
+ counterText,
704
+ currentOptions,
705
+ intlConfig,
706
+ isSmall,
707
+ paddingSize,
708
+ placeholder,
709
+ showCounter
710
+ ]);
711
+ return /* @__PURE__ */ jsxRuntime.jsxs(
712
+ SelectField,
713
+ {
714
+ ...props,
715
+ ref,
716
+ multiple: true,
717
+ displayEmpty: true,
718
+ placeholder,
719
+ value: currentOptions,
720
+ renderValue: () => renderValue,
721
+ onChange: handleChange,
722
+ size,
723
+ variant,
724
+ endAdornment: showFilters && areAnySelected && /* @__PURE__ */ jsxRuntime.jsx(UnselectButton, { position: "end", size, children: /* @__PURE__ */ jsxRuntime.jsx(material.IconButton, { onClick: unselectAll, size, children: /* @__PURE__ */ jsxRuntime.jsx(iconsMaterial.Cancel, {}) }) }),
725
+ menuProps: {
726
+ PaperProps: {
727
+ sx: {
728
+ ".MuiList-root": {
729
+ paddingTop: 0
730
+ }
731
+ }
732
+ }
733
+ },
734
+ children: [
735
+ showFilters && /* @__PURE__ */ jsxRuntime.jsx(
736
+ MenuItemFilter,
737
+ {
738
+ areAllSelected,
739
+ areAnySelected,
740
+ selectAll,
741
+ selectAllDisabled
742
+ }
743
+ ),
744
+ options == null ? void 0 : options.map((option) => {
745
+ const item = /* @__PURE__ */ jsxRuntime.jsxs(
746
+ StyledMenuItem,
747
+ {
748
+ value: option.value,
749
+ disabled: option.disabled,
750
+ tabIndex: 0,
751
+ children: [
752
+ /* @__PURE__ */ jsxRuntime.jsx(
753
+ material.Checkbox,
754
+ {
755
+ disabled: option.disabled,
756
+ checked: currentOptions.includes(option.value)
757
+ }
758
+ ),
759
+ /* @__PURE__ */ jsxRuntime.jsx(material.ListItemText, { primary: option.label })
760
+ ]
761
+ },
762
+ option.value
763
+ );
764
+ const content = option.tooltip ? /* @__PURE__ */ jsxRuntime.jsx(
765
+ material.Tooltip,
766
+ {
767
+ title: option.tooltip,
768
+ placement: tooltipPlacement,
769
+ children: item
770
+ },
771
+ option.value
772
+ ) : item;
773
+ return content;
774
+ })
775
+ ]
776
+ }
777
+ );
778
+ }
779
+ const MultipleSelectField = React.forwardRef(_MultipleSelectField);
780
+ const StyledUploadField = material.styled(material.TextField, {
781
+ shouldForwardProp: (prop) => prop !== "cursor"
782
+ })(
783
+ ({ cursor, theme }) => ({
784
+ "&.MuiTextField-root .MuiInputBase-root": {
785
+ cursor,
786
+ paddingRight: theme.spacing(1),
787
+ "& input": {
788
+ cursor
789
+ },
790
+ "&.Mui-disabled": {
791
+ pointerEvents: "none",
792
+ "& .MuiButtonBase-root": {
793
+ color: theme.palette.text.disabled
794
+ }
795
+ },
796
+ "&.MuiInputBase-sizeSmall": {
797
+ paddingRight: theme.spacing(0.5)
798
+ }
799
+ },
800
+ "& .MuiFormLabel-root": {
801
+ cursor,
802
+ "&.Mui-disabled": {
803
+ pointerEvents: "none"
804
+ }
805
+ }
806
+ })
807
+ );
808
+ function FilesAction({
809
+ buttonText,
810
+ hasFiles,
811
+ size,
812
+ error,
813
+ disabled,
814
+ handleReset,
815
+ handleOpen,
816
+ inProgress
817
+ }) {
818
+ return /* @__PURE__ */ jsxRuntime.jsx(material.InputAdornment, { position: "end", children: inProgress ? /* @__PURE__ */ jsxRuntime.jsx(material.IconButton, { "aria-label": "Loading", disabled: true, size, children: /* @__PURE__ */ jsxRuntime.jsx(material.CircularProgress, { size: 18 }) }) : !hasFiles ? /* @__PURE__ */ jsxRuntime.jsx(
819
+ material.Button,
820
+ {
821
+ onClick: handleOpen,
822
+ size,
823
+ variant: "text",
824
+ color: error ? "default" : "primary",
825
+ disabled,
826
+ children: buttonText
827
+ }
828
+ ) : /* @__PURE__ */ jsxRuntime.jsx(
829
+ material.IconButton,
830
+ {
831
+ onClick: handleReset,
832
+ size,
833
+ "aria-label": "Delete",
834
+ disabled,
835
+ children: /* @__PURE__ */ jsxRuntime.jsx(iconsMaterial.Cancel, {})
836
+ }
837
+ ) });
838
+ }
839
+ function UploadFieldBase({
840
+ name,
841
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
842
+ multiple,
843
+ // multiple prop defined here for compatibility with cloud-native but not used in the component
844
+ handleReset,
845
+ handleOpen,
846
+ dragOver,
847
+ error,
848
+ placeholder,
849
+ focused,
850
+ buttonText = "Browse",
851
+ inProgress,
852
+ InputProps,
853
+ size = "small",
854
+ hasFiles,
855
+ cursor = "pointer",
856
+ ...props
857
+ }) {
858
+ return /* @__PURE__ */ jsxRuntime.jsx(
859
+ StyledUploadField,
860
+ {
861
+ ...props,
862
+ size,
863
+ error,
864
+ placeholder,
865
+ focused: focused ?? dragOver,
866
+ cursor,
867
+ InputProps: {
868
+ ...InputProps,
869
+ name,
870
+ // multiple prop cannot be used here because it is not a valid prop for TextField InputProps
871
+ // not used for any UI logic
872
+ readOnly: true,
873
+ endAdornment: /* @__PURE__ */ jsxRuntime.jsx(
874
+ FilesAction,
875
+ {
876
+ buttonText,
877
+ hasFiles,
878
+ size,
879
+ error,
880
+ disabled: !!dragOver,
881
+ handleReset,
882
+ handleOpen,
883
+ inProgress
884
+ }
885
+ )
886
+ }
887
+ }
888
+ );
889
+ }
890
+ function useFileUpload({
891
+ onChange,
892
+ files,
893
+ multiple,
894
+ placeholder,
895
+ uploadInputRef
896
+ }) {
897
+ const intl = reactIntl.useIntl();
898
+ const intlConfig = TablePaginationActions.useImperativeIntl(intl);
899
+ const [filesText, setFilesText] = React.useState("");
900
+ const [dragOver, setDragOver] = React.useState(false);
901
+ React.useEffect(() => {
902
+ if (!files || files.length === 0) {
903
+ setFilesText("");
904
+ } else if (files.length === 1) {
905
+ setFilesText(files[0].name);
906
+ } else {
907
+ setFilesText(
908
+ intlConfig.formatMessage(
909
+ { id: "c4r.form.filesSelected" },
910
+ { count: files.length }
911
+ )
912
+ );
913
+ }
914
+ }, [files, intlConfig]);
915
+ const handleBrowse = () => {
916
+ var _a;
917
+ (_a = uploadInputRef.current) == null ? void 0 : _a.click();
918
+ };
919
+ const handleDragOver = (event) => {
920
+ event.preventDefault();
921
+ setDragOver(true);
922
+ };
923
+ const handleDragLeave = (event) => {
924
+ event.preventDefault();
925
+ setDragOver(false);
926
+ };
927
+ const handleDrop = (event) => {
928
+ event.preventDefault();
929
+ setDragOver(false);
930
+ const items = event.dataTransfer.items;
931
+ const newFiles = getAllFiles(items);
932
+ onChange == null ? void 0 : onChange(newFiles);
933
+ };
934
+ const getAllFiles = (items) => {
935
+ const newFiles = [];
936
+ for (const item of Array.from(items)) {
937
+ if (item.kind === "file") {
938
+ const file = item.getAsFile();
939
+ newFiles.push(file);
940
+ }
941
+ }
942
+ return newFiles;
943
+ };
944
+ const handleFiles = (event) => {
945
+ const newFiles = Array.from(event.target.files);
946
+ onChange == null ? void 0 : onChange(newFiles);
947
+ };
948
+ const handleReset = (event) => {
949
+ event.stopPropagation();
950
+ setFilesText("");
951
+ };
952
+ const getPlaceholder = React.useMemo(() => {
953
+ const defaultPlaceholder = intlConfig.formatMessage(
954
+ { id: `c4r.form.dragPlaceholder` },
955
+ { count: multiple ? 0 : 1 }
956
+ );
957
+ const dragPlaceholder = intlConfig.formatMessage(
958
+ { id: `c4r.form.dragActivePlaceholder` },
959
+ { count: multiple ? 0 : 1 }
960
+ );
961
+ let placeholderText = "";
962
+ if (dragOver) {
963
+ placeholderText = dragPlaceholder;
964
+ } else {
965
+ placeholderText = placeholder ?? defaultPlaceholder;
966
+ }
967
+ return placeholderText;
968
+ }, [dragOver, multiple, placeholder, intlConfig]);
969
+ const inputEvents = {
970
+ onDragOver: handleDragOver,
971
+ onDragLeave: handleDragLeave,
972
+ onDrop: handleDrop,
973
+ onClick: handleBrowse
974
+ };
975
+ return {
976
+ filesText,
977
+ getPlaceholder,
978
+ dragOver,
979
+ inputEvents,
980
+ handleFiles,
981
+ handleReset
982
+ };
983
+ }
984
+ const DEFAULT_ACCEPT = ["application/JSON"];
985
+ function UploadField({
986
+ name,
987
+ buttonText,
988
+ accept: _accept,
989
+ files,
990
+ inProgress,
991
+ onChange,
992
+ multiple,
993
+ placeholder,
994
+ error,
995
+ focused,
996
+ nativeInputProps,
997
+ ...props
998
+ }) {
999
+ const accept = _accept ?? DEFAULT_ACCEPT;
1000
+ const uploadInputRef = React.useRef(null);
1001
+ const {
1002
+ filesText,
1003
+ getPlaceholder,
1004
+ dragOver,
1005
+ inputEvents,
1006
+ handleFiles,
1007
+ handleReset
1008
+ } = useFileUpload({
1009
+ uploadInputRef,
1010
+ files,
1011
+ onChange,
1012
+ multiple,
1013
+ placeholder
1014
+ });
1015
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1016
+ /* @__PURE__ */ jsxRuntime.jsx(
1017
+ UploadFieldBase,
1018
+ {
1019
+ ...props,
1020
+ placeholder: getPlaceholder,
1021
+ value: filesText,
1022
+ error,
1023
+ focused: focused ?? dragOver,
1024
+ handleReset,
1025
+ dragOver,
1026
+ inProgress,
1027
+ hasFiles: Boolean(filesText),
1028
+ InputProps: inputEvents,
1029
+ buttonText
1030
+ }
1031
+ ),
1032
+ /* @__PURE__ */ jsxRuntime.jsx(
1033
+ "input",
1034
+ {
1035
+ ...nativeInputProps,
1036
+ ref: uploadInputRef,
1037
+ style: { display: "none" },
1038
+ type: "file",
1039
+ "aria-label": name,
1040
+ name,
1041
+ accept: String(accept),
1042
+ multiple,
1043
+ onChange: handleFiles
1044
+ }
1045
+ )
1046
+ ] });
1047
+ }
1048
+ function _Autocomplete({
1049
+ disabled,
1050
+ loading,
1051
+ ...props
1052
+ }, ref) {
1053
+ return /* @__PURE__ */ jsxRuntime.jsx(
1054
+ material.Autocomplete,
1055
+ {
1056
+ ...props,
1057
+ ref,
1058
+ disabled: disabled || loading,
1059
+ popupIcon: loading ? /* @__PURE__ */ jsxRuntime.jsx(material.CircularProgress, { size: 18, color: "inherit" }) : /* @__PURE__ */ jsxRuntime.jsx(ArrowDown.ArrowDown, {}),
1060
+ "data-name": "autocomplete",
1061
+ ListboxProps: {
1062
+ "aria-multiselectable": false,
1063
+ ...props.ListboxProps
1064
+ }
1065
+ }
1066
+ );
1067
+ }
1068
+ const Autocomplete = React.forwardRef(_Autocomplete);
1069
+ const getDefaultOptionLabel = (option) => {
1070
+ return option && typeof option === "object" ? option.title ?? String(option) : String(option);
1071
+ };
1072
+ const createOptionWithMultiple = (option, multiple) => {
1073
+ return typeof option !== "object" || option === null ? { value: option, multiple } : { ...option, multiple };
1074
+ };
1075
+ const getDefaultLimitTagsText = (more) => /* @__PURE__ */ jsxRuntime.jsx("span", { "data-testid": "more-options-tag", children: `+${more}` });
1076
+ function useAutocompleteRenderOption() {
1077
+ const renderOption = (props, option, state, getOptionLabel, customIcon) => {
1078
+ const {
1079
+ title,
1080
+ inputValue,
1081
+ divider,
1082
+ fixed,
1083
+ extended,
1084
+ dense,
1085
+ destructive,
1086
+ disabled,
1087
+ subtitle,
1088
+ iconColor,
1089
+ startAdornment,
1090
+ endAdornment,
1091
+ alternativeTitle,
1092
+ secondaryText,
1093
+ multiple
1094
+ } = option;
1095
+ const { key, ...otherProps } = props;
1096
+ const isPrimitiveOptionType = typeof option === "string" || typeof option === "number";
1097
+ const getOptionLabelText = (getOptionLabel2, option2, alternativeTitle2, title2) => {
1098
+ if (alternativeTitle2) return alternativeTitle2;
1099
+ if (title2) return title2;
1100
+ if (option2 && typeof option2 === "object" && "value" in option2) {
1101
+ return String(option2.value);
1102
+ }
1103
+ return getOptionLabel2(option2);
1104
+ };
1105
+ return /* @__PURE__ */ jsxRuntime.jsx(React.Fragment, { children: divider ? /* @__PURE__ */ jsxRuntime.jsx(material.Divider, {}) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1106
+ inputValue && /* @__PURE__ */ jsxRuntime.jsx(material.Divider, {}),
1107
+ /* @__PURE__ */ jsxRuntime.jsxs(
1108
+ MenuItem.MenuItem,
1109
+ {
1110
+ ...otherProps,
1111
+ ...!isPrimitiveOptionType && {
1112
+ fixed,
1113
+ extended,
1114
+ dense,
1115
+ destructive,
1116
+ disabled,
1117
+ subtitle,
1118
+ iconColor
1119
+ },
1120
+ ...{ "aria-disabled": subtitle || disabled },
1121
+ ...{ "aria-selected": state.selected },
1122
+ children: [
1123
+ !subtitle && (startAdornment || multiple || customIcon) && /* @__PURE__ */ jsxRuntime.jsxs(material.ListItemIcon, { children: [
1124
+ customIcon || multiple && /* @__PURE__ */ jsxRuntime.jsx(material.Checkbox, { checked: state.selected }),
1125
+ startAdornment
1126
+ ] }),
1127
+ /* @__PURE__ */ jsxRuntime.jsxs(material.ListItemText, { children: [
1128
+ getOptionLabelText(
1129
+ getOptionLabel ?? getDefaultOptionLabel,
1130
+ option,
1131
+ alternativeTitle,
1132
+ title
1133
+ ),
1134
+ secondaryText && /* @__PURE__ */ jsxRuntime.jsx(
1135
+ TablePaginationActions.Typography,
1136
+ {
1137
+ component: "p",
1138
+ variant: "caption",
1139
+ color: "text.secondary",
1140
+ children: secondaryText
1141
+ }
1142
+ )
1143
+ ] }),
1144
+ !subtitle && endAdornment
1145
+ ]
1146
+ }
1147
+ )
1148
+ ] }) }, key);
1149
+ };
1150
+ return { renderOption };
1151
+ }
1152
+ function useCreatableAutocomplete({
1153
+ getOptionLabel,
1154
+ newItemLabel,
1155
+ newItemIcon,
1156
+ multiple
1157
+ }) {
1158
+ const intl = reactIntl.useIntl();
1159
+ const intlConfig = TablePaginationActions.useImperativeIntl(intl);
1160
+ const filter = material.createFilterOptions();
1161
+ const { renderOption: autocompleteRenderOption } = useAutocompleteRenderOption();
1162
+ const creatableFilterOptions = (options, params) => {
1163
+ const filtered = filter(
1164
+ options,
1165
+ params
1166
+ );
1167
+ const { inputValue } = params;
1168
+ const isExisting = options.some(
1169
+ (option) => inputValue === getOptionLabel(option)
1170
+ );
1171
+ if (inputValue.length > 1 && inputValue !== "" && !isExisting) {
1172
+ let newItemText;
1173
+ if (typeof newItemLabel === "function") {
1174
+ newItemText = newItemLabel(inputValue);
1175
+ } else if (newItemLabel) {
1176
+ newItemText = `${newItemLabel} "${inputValue}"`;
1177
+ } else {
1178
+ newItemText = `${intlConfig.formatMessage({ id: "c4r.form.add" })} "${inputValue}"`;
1179
+ }
1180
+ filtered.push({
1181
+ inputValue,
1182
+ title: newItemText
1183
+ });
1184
+ }
1185
+ return filtered;
1186
+ };
1187
+ const creatableOptionLabel = (option) => {
1188
+ if (typeof option === "string") {
1189
+ return option;
1190
+ }
1191
+ if (option.inputValue) {
1192
+ return option.inputValue;
1193
+ }
1194
+ return getOptionLabel(option);
1195
+ };
1196
+ const creatableRenderOption = (props, option, state) => {
1197
+ const customIcon = option.inputValue ? newItemIcon ?? /* @__PURE__ */ jsxRuntime.jsx(iconsMaterial.AddCircleOutlineOutlined, {}) : void 0;
1198
+ const optionWithMultiple = createOptionWithMultiple(option, !!multiple);
1199
+ return autocompleteRenderOption(
1200
+ props,
1201
+ optionWithMultiple,
1202
+ state,
1203
+ getOptionLabel,
1204
+ customIcon
1205
+ );
1206
+ };
1207
+ return {
1208
+ creatableFilterOptions,
1209
+ creatableOptionLabel,
1210
+ creatableRenderOption
1211
+ };
1212
+ }
1213
+ function useMultipleAutocomplete({
1214
+ options,
1215
+ value,
1216
+ onChange,
1217
+ getOptionLabel
1218
+ }) {
1219
+ const [multipleValue, setMultipleValue] = React.useState(
1220
+ Array.isArray(value) ? value : value ? [value] : []
1221
+ );
1222
+ const { renderOption: autocompleteRenderOption } = useAutocompleteRenderOption();
1223
+ React.useEffect(() => {
1224
+ const newValue = Array.isArray(value) ? value : value ? [value] : [];
1225
+ setMultipleValue(newValue);
1226
+ }, [value]);
1227
+ const allSelected = multipleValue.length === options.length;
1228
+ const someSelected = multipleValue.length > 0 && multipleValue.length < options.length;
1229
+ const handleSelectAll = (event) => {
1230
+ const newValue = allSelected ? [] : [...options];
1231
+ setMultipleValue(newValue);
1232
+ onChange == null ? void 0 : onChange(
1233
+ event,
1234
+ newValue,
1235
+ "selectOption"
1236
+ );
1237
+ };
1238
+ const handleChange = (event, newValue, reason) => {
1239
+ const multipleNewValue = newValue === null ? [] : newValue;
1240
+ setMultipleValue(multipleNewValue);
1241
+ onChange == null ? void 0 : onChange(event, newValue, reason);
1242
+ };
1243
+ const multipleRenderOption = (props, option, state) => {
1244
+ const optionWithMultiple = createOptionWithMultiple(option, true);
1245
+ return autocompleteRenderOption(
1246
+ props,
1247
+ optionWithMultiple,
1248
+ state,
1249
+ getOptionLabel
1250
+ );
1251
+ };
1252
+ return {
1253
+ multipleValue,
1254
+ allSelected,
1255
+ someSelected,
1256
+ handleSelectAll,
1257
+ handleChange,
1258
+ multipleRenderOption
1259
+ };
1260
+ }
1261
+ function _ListboxWithFilter({
1262
+ children,
1263
+ showFilters,
1264
+ allSelected,
1265
+ someSelected,
1266
+ handleSelectAll = () => void 0,
1267
+ multiple,
1268
+ ...otherProps
1269
+ }, ref) {
1270
+ return /* @__PURE__ */ jsxRuntime.jsxs(
1271
+ "ul",
1272
+ {
1273
+ ref,
1274
+ ...otherProps,
1275
+ role: "listbox",
1276
+ "aria-multiselectable": multiple,
1277
+ children: [
1278
+ showFilters && multiple && /* @__PURE__ */ jsxRuntime.jsx(
1279
+ MenuItemFilter,
1280
+ {
1281
+ areAllSelected: !!allSelected,
1282
+ areAnySelected: !!someSelected,
1283
+ selectAll: handleSelectAll
1284
+ }
1285
+ ),
1286
+ children
1287
+ ]
1288
+ }
1289
+ );
1290
+ }
1291
+ const ListboxWithFilter = React.forwardRef(_ListboxWithFilter);
1292
+ function _CreatableAutocomplete({
1293
+ newItemLabel,
1294
+ newItemIcon,
1295
+ getOptionLabel = getDefaultOptionLabel,
1296
+ multiple,
1297
+ disableCloseOnSelect,
1298
+ disabled,
1299
+ loading,
1300
+ showFilters,
1301
+ options = [],
1302
+ value,
1303
+ onChange,
1304
+ getLimitTagsText,
1305
+ ...props
1306
+ }, ref) {
1307
+ const { freeSolo = true, ...otherProps } = props;
1308
+ const {
1309
+ multipleValue,
1310
+ allSelected,
1311
+ someSelected,
1312
+ handleSelectAll,
1313
+ handleChange
1314
+ } = useMultipleAutocomplete({
1315
+ options,
1316
+ value,
1317
+ onChange
1318
+ });
1319
+ const {
1320
+ creatableFilterOptions,
1321
+ creatableOptionLabel,
1322
+ creatableRenderOption
1323
+ } = useCreatableAutocomplete({
1324
+ getOptionLabel,
1325
+ newItemLabel,
1326
+ newItemIcon,
1327
+ multiple
1328
+ });
1329
+ return /* @__PURE__ */ jsxRuntime.jsx(
1330
+ material.Autocomplete,
1331
+ {
1332
+ ...otherProps,
1333
+ ref,
1334
+ options,
1335
+ value: multiple ? multipleValue : value,
1336
+ onChange: handleChange,
1337
+ filterOptions: creatableFilterOptions,
1338
+ getOptionLabel: creatableOptionLabel,
1339
+ renderOption: creatableRenderOption,
1340
+ freeSolo,
1341
+ forcePopupIcon: true,
1342
+ multiple,
1343
+ disableCloseOnSelect: disableCloseOnSelect ?? multiple,
1344
+ ListboxComponent: ListboxWithFilter,
1345
+ ListboxProps: {
1346
+ showFilters,
1347
+ allSelected,
1348
+ someSelected,
1349
+ handleSelectAll,
1350
+ multiple
1351
+ },
1352
+ getLimitTagsText: getLimitTagsText ?? getDefaultLimitTagsText,
1353
+ disabled: disabled || loading,
1354
+ popupIcon: loading ? /* @__PURE__ */ jsxRuntime.jsx(material.CircularProgress, { size: 18, color: "inherit" }) : /* @__PURE__ */ jsxRuntime.jsx(ArrowDown.ArrowDown, {}),
1355
+ "data-name": "creatable-autocomplete"
1356
+ }
1357
+ );
1358
+ }
1359
+ const CreatableAutocomplete = React.forwardRef(_CreatableAutocomplete);
1360
+ function _MultipleAutocomplete({
1361
+ renderOption,
1362
+ disableCloseOnSelect = true,
1363
+ disabled,
1364
+ loading,
1365
+ showFilters,
1366
+ options,
1367
+ value,
1368
+ onChange,
1369
+ getOptionLabel,
1370
+ getLimitTagsText,
1371
+ ...props
1372
+ }, ref) {
1373
+ const {
1374
+ multipleValue,
1375
+ allSelected,
1376
+ someSelected,
1377
+ handleSelectAll,
1378
+ handleChange,
1379
+ multipleRenderOption
1380
+ } = useMultipleAutocomplete({
1381
+ options,
1382
+ value,
1383
+ onChange,
1384
+ getOptionLabel
1385
+ });
1386
+ return /* @__PURE__ */ jsxRuntime.jsx(
1387
+ material.Autocomplete,
1388
+ {
1389
+ ...props,
1390
+ ref,
1391
+ options,
1392
+ value: multipleValue,
1393
+ onChange: handleChange,
1394
+ getOptionLabel,
1395
+ renderOption: renderOption ?? multipleRenderOption,
1396
+ ListboxComponent: ListboxWithFilter,
1397
+ ListboxProps: {
1398
+ showFilters,
1399
+ allSelected,
1400
+ someSelected,
1401
+ handleSelectAll,
1402
+ multiple: true
1403
+ },
1404
+ multiple: true,
1405
+ getLimitTagsText: getLimitTagsText ?? getDefaultLimitTagsText,
1406
+ disableCloseOnSelect,
1407
+ disabled: disabled || loading,
1408
+ popupIcon: loading ? /* @__PURE__ */ jsxRuntime.jsx(material.CircularProgress, { size: 18, color: "inherit" }) : /* @__PURE__ */ jsxRuntime.jsx(ArrowDown.ArrowDown, {}),
1409
+ "data-name": "multiple-autocomplete"
1410
+ }
1411
+ );
1412
+ }
1413
+ const MultipleAutocomplete = React.forwardRef(_MultipleAutocomplete);
1414
+ const _CopiableComponent = ({
1415
+ children,
1416
+ disabled,
1417
+ value,
1418
+ onCopied,
1419
+ copyText = "c4r.button.copy",
1420
+ copiedText = "c4r.notifications.copiedToClipboard",
1421
+ button,
1422
+ buttonLabel,
1423
+ buttonProps,
1424
+ ariaLabel,
1425
+ dataTestId,
1426
+ tooltipPlacement = "top",
1427
+ ...props
1428
+ }, ref) => {
1429
+ const intl = reactIntl.useIntl();
1430
+ const intlConfig = TablePaginationActions.useImperativeIntl(intl);
1431
+ const [open, setOpen] = React.useState(false);
1432
+ const { copy } = useCopyValue(copyText, copiedText);
1433
+ const handleClick = (e) => {
1434
+ e.preventDefault();
1435
+ copy(value).then(() => {
1436
+ onCopied == null ? void 0 : onCopied();
1437
+ setOpen(true);
1438
+ }).catch(console.error);
1439
+ };
1440
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1441
+ /* @__PURE__ */ jsxRuntime.jsx(
1442
+ material.Tooltip,
1443
+ {
1444
+ title: intlConfig.formatMessage({ id: copyText }),
1445
+ leaveDelay: 0,
1446
+ placement: tooltipPlacement,
1447
+ children: /* @__PURE__ */ jsxRuntime.jsxs(
1448
+ material.Box,
1449
+ {
1450
+ ...props,
1451
+ sx: { cursor: disabled ? void 0 : "pointer" },
1452
+ onClick: handleClick,
1453
+ "data-name": "copiable",
1454
+ ref,
1455
+ children: [
1456
+ children,
1457
+ button && /* @__PURE__ */ jsxRuntime.jsx(
1458
+ IconButton,
1459
+ {
1460
+ ...buttonProps,
1461
+ disabled,
1462
+ icon: /* @__PURE__ */ jsxRuntime.jsx(iconsMaterial.ContentCopyOutlined, {}),
1463
+ "data-testid": dataTestId,
1464
+ "aria-label": ariaLabel || buttonLabel,
1465
+ sx: {
1466
+ display: "flex"
1467
+ }
1468
+ }
1469
+ )
1470
+ ]
1471
+ }
1472
+ )
1473
+ }
1474
+ ),
1475
+ /* @__PURE__ */ jsxRuntime.jsx(
1476
+ Snackbar,
1477
+ {
1478
+ open,
1479
+ autoWidth: true,
1480
+ closeable: false,
1481
+ autoHideDuration: 4e3,
1482
+ onClose: () => setOpen(false),
1483
+ children: intlConfig.formatMessage({ id: copiedText })
1484
+ }
1485
+ )
1486
+ ] });
1487
+ };
1488
+ const CopiableComponent = React.forwardRef(_CopiableComponent);
1489
+ async function copyString(value) {
1490
+ return await navigator.clipboard.writeText(value);
1491
+ }
1492
+ const useCopyValue = (msg = "c4r.button.copy", copiedMsg = "c4r.notifications.copiedToClipboard") => {
1493
+ const [message, setMessage] = React.useState(msg);
1494
+ const copy = async (text) => {
1495
+ await copyString(text);
1496
+ setMessage(copiedMsg);
1497
+ setTimeout(() => setMessage(msg), 1e3);
1498
+ };
1499
+ return {
1500
+ message,
1501
+ copy
1502
+ };
1503
+ };
1504
+ const AccordionContainer = material.styled("div", {
1505
+ shouldForwardProp: (prop) => prop !== "variant"
1506
+ })(({ variant, theme }) => ({
1507
+ width: "100%",
1508
+ borderRadius: theme.spacing(0.5),
1509
+ ...variant === "outlined" && {
1510
+ backgroundColor: theme.palette.background.paper,
1511
+ boxShadow: `inset 0 0 0 1px ${theme.palette.divider}`
1512
+ }
1513
+ }));
1514
+ function AccordionGroup({
1515
+ variant = "standard",
1516
+ items,
1517
+ ...otherProps
1518
+ }) {
1519
+ return /* @__PURE__ */ jsxRuntime.jsx(AccordionContainer, { ...otherProps, variant, children: items.map((item, index) => /* @__PURE__ */ jsxRuntime.jsxs(
1520
+ material.Accordion,
1521
+ {
1522
+ disabled: item.disabled,
1523
+ defaultExpanded: item.defaultExpanded,
1524
+ onChange: item.onChange,
1525
+ children: [
1526
+ /* @__PURE__ */ jsxRuntime.jsx(
1527
+ material.AccordionSummary,
1528
+ {
1529
+ "aria-controls": `${index}-content`,
1530
+ id: `${index}-header`,
1531
+ children: item.summary
1532
+ }
1533
+ ),
1534
+ /* @__PURE__ */ jsxRuntime.jsx(material.AccordionDetails, { children: item.content })
1535
+ ]
1536
+ },
1537
+ index
1538
+ )) });
1539
+ }
1540
+ const sizes = {
1541
+ large: 5,
1542
+ medium: 4,
1543
+ small: 3,
1544
+ xsmall: 2.25
1545
+ };
1546
+ const StyledAvatar = material.styled(material.Avatar, {
1547
+ shouldForwardProp: (prop) => prop !== "size" && prop !== "disabled"
1548
+ })(({ theme, size = "medium", disabled = false }) => ({
1549
+ width: theme.spacing(sizes[size]),
1550
+ height: theme.spacing(sizes[size]),
1551
+ ...theme.typography.subtitle1,
1552
+ ...size === "large" && {
1553
+ ...theme.typography.h6
1554
+ },
1555
+ ...size === "small" && {
1556
+ ...theme.typography.caption,
1557
+ fontWeight: 500
1558
+ },
1559
+ ...size === "xsmall" && {
1560
+ ...theme.typography.caption,
1561
+ fontWeight: 500,
1562
+ svg: {
1563
+ width: TablePaginationActions.ICON_SIZE_SMALL,
1564
+ height: TablePaginationActions.ICON_SIZE_SMALL
1565
+ }
1566
+ },
1567
+ ...disabled && {
1568
+ opacity: 0.6
1569
+ }
1570
+ }));
1571
+ function Avatar(props) {
1572
+ return /* @__PURE__ */ jsxRuntime.jsx(StyledAvatar, { ...props });
1573
+ }
1574
+ const MAX_WIDTH = 480;
1575
+ const SnackbarRoot = material.styled(material.Snackbar)(({ theme }) => ({
1576
+ bottom: theme.spacing(2),
1577
+ right: theme.spacing(2),
1578
+ left: theme.spacing(2),
1579
+ [theme.breakpoints.up("sm")]: {
1580
+ bottom: theme.spacing(4),
1581
+ right: "auto",
1582
+ left: "50%",
1583
+ width: "100%",
1584
+ maxWidth: `${MAX_WIDTH}px`
1585
+ }
1586
+ }));
1587
+ const Content$3 = material.styled(material.Box, {
1588
+ shouldForwardProp: (prop) => prop !== "autoWidth"
1589
+ })(({ autoWidth, theme }) => ({
1590
+ minWidth: "100%",
1591
+ maxWidth: `${MAX_WIDTH}px`,
1592
+ margin: theme.spacing(0, 1),
1593
+ ...autoWidth && {
1594
+ minWidth: "auto"
1595
+ },
1596
+ [theme.breakpoints.up("sm")]: {
1597
+ minWidth: theme.spacing(40),
1598
+ ...autoWidth && {
1599
+ minWidth: "auto"
1600
+ }
1601
+ }
1602
+ }));
1603
+ const Alert = material.styled(Alert$1.Alert, {
1604
+ shouldForwardProp: (prop) => !["hasActions", "closeable"].includes(prop)
1605
+ })(({ hasActions, closeable, icon, theme }) => ({
1606
+ position: "relative",
1607
+ display: "flex",
1608
+ flexWrap: "wrap",
1609
+ columnGap: theme.spacing(1),
1610
+ rowGap: theme.spacing(0.25),
1611
+ padding: theme.spacing(1),
1612
+ paddingLeft: theme.spacing(2),
1613
+ color: theme.palette.common.white,
1614
+ backgroundColor: theme.palette.common.black,
1615
+ ".MuiAlert-message": {
1616
+ padding: theme.spacing(0.75, 0)
1617
+ },
1618
+ ".MuiAlert-message .MuiTypography-root, .MuiAlert-icon": {
1619
+ color: theme.palette.common.white
1620
+ },
1621
+ ".MuiAlert-message .MuiTypography-root:not(.MuiAlertTitle-root)": {
1622
+ ...theme.typography.body2
1623
+ },
1624
+ ".MuiAlert-message .MuiCircularProgress-circle": {
1625
+ color: theme.palette.common.white
1626
+ },
1627
+ ".MuiAlert-icon": {
1628
+ position: "absolute",
1629
+ top: theme.spacing(1),
1630
+ left: theme.spacing(1.5),
1631
+ display: "flex",
1632
+ alignItems: "center",
1633
+ justifyContent: "center",
1634
+ width: theme.spacing(3),
1635
+ marginTop: theme.spacing(0.5)
1636
+ },
1637
+ "&.MuiAlert-standardError": {
1638
+ backgroundColor: theme.palette.error.main
1639
+ },
1640
+ ...icon !== false && {
1641
+ paddingLeft: theme.spacing(5.5)
1642
+ },
1643
+ ...closeable && {
1644
+ paddingRight: theme.spacing(6)
1645
+ },
1646
+ ...!closeable && !hasActions && {
1647
+ paddingRight: theme.spacing(1.5)
1648
+ },
1649
+ ...hasActions && {
1650
+ ".MuiAlert-message": {
1651
+ minWidth: "fit-content",
1652
+ padding: theme.spacing(0.75, 0)
1653
+ }
1654
+ }
1655
+ }));
1656
+ const CloseButtonWrapper = material.styled(material.Box)(({ theme }) => ({
1657
+ position: "absolute",
1658
+ top: theme.spacing(1),
1659
+ right: theme.spacing(1),
1660
+ "& button:hover, & button:focus-visible": {
1661
+ backgroundColor: theme.palette.white[8]
1662
+ },
1663
+ svg: {
1664
+ color: theme.palette.white[60]
1665
+ }
1666
+ }));
1667
+ function Snackbar({
1668
+ severity = "neutral",
1669
+ autoHideDuration = TablePaginationActions.NOTIFICATION_DURATION_IN_MS,
1670
+ closeable = true,
1671
+ children,
1672
+ title,
1673
+ action,
1674
+ open,
1675
+ onClose = () => void 0,
1676
+ autoWidth,
1677
+ icon,
1678
+ ...rest
1679
+ }) {
1680
+ const intl = reactIntl.useIntl();
1681
+ const intlConfig = TablePaginationActions.useImperativeIntl(intl);
1682
+ const isNeutral = severity === "neutral";
1683
+ const disabledIcon = icon === false || isNeutral && !icon;
1684
+ const disabledAutoHide = autoHideDuration === null;
1685
+ const duration = disabledAutoHide ? null : autoHideDuration || TablePaginationActions.NOTIFICATION_DURATION_IN_MS;
1686
+ return /* @__PURE__ */ jsxRuntime.jsx(material.Portal, { children: /* @__PURE__ */ jsxRuntime.jsx(
1687
+ SnackbarRoot,
1688
+ {
1689
+ ...rest,
1690
+ open,
1691
+ autoHideDuration: duration,
1692
+ onClose,
1693
+ TransitionComponent: autoWidth ? material.Fade : material.Slide,
1694
+ "data-auto-width": autoWidth,
1695
+ children: /* @__PURE__ */ jsxRuntime.jsxs(
1696
+ Content$3,
1697
+ {
1698
+ sx: {
1699
+ position: "relative"
1700
+ },
1701
+ autoWidth,
1702
+ children: [
1703
+ /* @__PURE__ */ jsxRuntime.jsx(
1704
+ Alert,
1705
+ {
1706
+ severity,
1707
+ action,
1708
+ icon: disabledIcon ? false : icon,
1709
+ elevation: 6,
1710
+ hasActions: !!action,
1711
+ closeable,
1712
+ title,
1713
+ children
1714
+ }
1715
+ ),
1716
+ closeable && /* @__PURE__ */ jsxRuntime.jsx(CloseButtonWrapper, { children: /* @__PURE__ */ jsxRuntime.jsx(
1717
+ IconButton,
1718
+ {
1719
+ color: "default",
1720
+ onClick: (e) => onClose(e, "timeout"),
1721
+ icon: /* @__PURE__ */ jsxRuntime.jsx(iconsMaterial.CloseOutlined, {}),
1722
+ tooltip: intlConfig.formatMessage({
1723
+ id: "c4r.button.close"
1724
+ })
1725
+ }
1726
+ ) })
1727
+ ]
1728
+ }
1729
+ )
1730
+ }
1731
+ ) });
1732
+ }
1733
+ function colorProps(color, variant, theme, disabled) {
1734
+ if (disabled) {
1735
+ if (variant === "outlined") {
1736
+ return {
1737
+ color: theme.palette.text.disabled,
1738
+ backgroundColor: theme.palette.black[4],
1739
+ borderColor: theme.palette.action.focus
1740
+ };
1741
+ }
1742
+ return {
1743
+ color: theme.palette.text.disabled,
1744
+ backgroundColor: theme.palette.action.disabledBackground,
1745
+ borderColor: "transparent"
1746
+ };
1747
+ }
1748
+ switch (color) {
1749
+ case "default":
1750
+ if (variant === "outlined") {
1751
+ return {
1752
+ color: theme.palette.text.secondary,
1753
+ backgroundColor: theme.palette.black["4"],
1754
+ borderColor: theme.palette.divider
1755
+ };
1756
+ }
1757
+ return {
1758
+ color: theme.palette.text.primary,
1759
+ backgroundColor: theme.palette.default.main,
1760
+ borderColor: "transparent"
1761
+ };
1762
+ case "primary":
1763
+ if (variant === "outlined") {
1764
+ return {
1765
+ color: theme.palette.primary.main,
1766
+ backgroundColor: theme.palette.primary.relatedLight,
1767
+ borderColor: theme.palette.primary.main
1768
+ };
1769
+ }
1770
+ return {
1771
+ color: theme.palette.primary.contrastText,
1772
+ backgroundColor: theme.palette.primary.main,
1773
+ borderColor: "transparent"
1774
+ };
1775
+ case "secondary":
1776
+ if (variant === "outlined") {
1777
+ return {
1778
+ color: theme.palette.secondary.main,
1779
+ backgroundColor: theme.palette.secondary.relatedLight,
1780
+ borderColor: theme.palette.secondary.main
1781
+ };
1782
+ }
1783
+ return {
1784
+ color: theme.palette.text.primary,
1785
+ backgroundColor: theme.palette.secondary.main,
1786
+ borderColor: "transparent"
1787
+ };
1788
+ case "success":
1789
+ if (variant === "outlined") {
1790
+ return {
1791
+ color: theme.palette.success.main,
1792
+ backgroundColor: theme.palette.success.relatedLight,
1793
+ borderColor: theme.palette.success.main
1794
+ };
1795
+ }
1796
+ return {
1797
+ color: theme.palette.success.main,
1798
+ backgroundColor: theme.palette.success.relatedLight,
1799
+ borderColor: "transparent"
1800
+ };
1801
+ case "warning":
1802
+ if (variant === "outlined") {
1803
+ return {
1804
+ color: theme.palette.warning.main,
1805
+ backgroundColor: theme.palette.warning.relatedLight,
1806
+ borderColor: theme.palette.warning.main
1807
+ };
1808
+ }
1809
+ return {
1810
+ color: theme.palette.text.primary,
1811
+ backgroundColor: theme.palette.warning.main,
1812
+ borderColor: "transparent"
1813
+ };
1814
+ case "error":
1815
+ if (variant === "outlined") {
1816
+ return {
1817
+ color: theme.palette.error.main,
1818
+ backgroundColor: theme.palette.error.relatedLight,
1819
+ borderColor: theme.palette.error.main
1820
+ };
1821
+ }
1822
+ return {
1823
+ color: theme.palette.primary.contrastText,
1824
+ backgroundColor: theme.palette.error.main,
1825
+ borderColor: "transparent"
1826
+ };
1827
+ }
1828
+ }
1829
+ const TagRoot = material.styled("div", {
1830
+ shouldForwardProp: (prop) => !["color", "variant", "disabled"].includes(prop)
1831
+ })(({
1832
+ color,
1833
+ variant,
1834
+ disabled,
1835
+ theme
1836
+ }) => {
1837
+ return {
1838
+ display: "inline-flex",
1839
+ flexDirection: "row",
1840
+ flexWrap: "nowrap",
1841
+ alignItems: "center",
1842
+ padding: theme.spacing(0, 0.5),
1843
+ borderRadius: theme.spacing(0.25),
1844
+ gap: theme.spacing(0.5),
1845
+ height: theme.spacing(2),
1846
+ borderWidth: "1px",
1847
+ borderStyle: "solid",
1848
+ ...colorProps(color ?? "primary", variant ?? "filled", theme, disabled)
1849
+ };
1850
+ });
1851
+ const TagIcon = material.styled("div")(({ theme }) => ({
1852
+ display: "flex",
1853
+ justifyContent: "center",
1854
+ alignItems: "center",
1855
+ "& svg": {
1856
+ width: theme.spacing(TablePaginationActions.ICON_SIZE_SMALL),
1857
+ height: theme.spacing(TablePaginationActions.ICON_SIZE_SMALL),
1858
+ "& g": {
1859
+ fill: "currentColor"
1860
+ }
1861
+ }
1862
+ }));
1863
+ const TagLabel = material.styled("span", {
1864
+ shouldForwardProp: (prop) => !["type", "icon"].includes(prop)
1865
+ })(({ type, icon, theme }) => ({
1866
+ display: "flex",
1867
+ alignItems: "center",
1868
+ paddingTop: type === "code" || icon ? theme.spacing(0.25) : void 0
1869
+ }));
1870
+ function _Tag({
1871
+ label,
1872
+ color = "primary",
1873
+ variant = "filled",
1874
+ icon,
1875
+ type = "default",
1876
+ typographyProps,
1877
+ noWrap = true,
1878
+ disabled,
1879
+ ...otherProps
1880
+ }, ref) {
1881
+ const typeCode = type === "code";
1882
+ return /* @__PURE__ */ jsxRuntime.jsxs(
1883
+ TagRoot,
1884
+ {
1885
+ ref,
1886
+ className: "CartoTag-root",
1887
+ color,
1888
+ variant,
1889
+ disabled,
1890
+ "aria-disabled": disabled,
1891
+ "data-color": color,
1892
+ "data-variant": variant,
1893
+ "data-type": type,
1894
+ "data-name": "tag",
1895
+ ...otherProps,
1896
+ children: [
1897
+ icon && /* @__PURE__ */ jsxRuntime.jsx(TagIcon, { children: icon }),
1898
+ /* @__PURE__ */ jsxRuntime.jsx(TagLabel, { icon: !!icon, type, children: /* @__PURE__ */ jsxRuntime.jsx(
1899
+ TablePaginationActions.Typography,
1900
+ {
1901
+ component: "span",
1902
+ color: "inherit",
1903
+ variant: typeCode ? "code3" : "caption",
1904
+ weight: typeCode ? "strong" : "medium",
1905
+ noWrap,
1906
+ ...typographyProps,
1907
+ children: label
1908
+ }
1909
+ ) })
1910
+ ]
1911
+ }
1912
+ );
1913
+ }
1914
+ const Tag = React.forwardRef(_Tag);
1915
+ const Menu = material.styled("div")(({ theme }) => ({
1916
+ display: "flex",
1917
+ alignItems: "center",
1918
+ height: TablePaginationActions.APPBAR_SIZE,
1919
+ marginRight: theme.spacing(1.5)
1920
+ }));
1921
+ const MenuButton = material.styled(material.IconButton)(({ theme }) => ({
1922
+ marginRight: theme.spacing(1),
1923
+ "&.MuiButtonBase-root svg path": {
1924
+ fill: theme.palette.brand.appBarContrastText
1925
+ }
1926
+ }));
1927
+ const MenuDivider = material.styled(material.Divider)(({ theme }) => ({
1928
+ borderColor: material.alpha(theme.palette.brand.appBarContrastText, 0.12)
1929
+ }));
1930
+ function BurgerMenu({
1931
+ onClickMenu
1932
+ }) {
1933
+ return (
1934
+ // replacing deprecated `<Hidden />` with sx following this MUI5 guide:
1935
+ // https://mui.com/material-ui/migration/v5-component-changes/#hidden
1936
+ /* @__PURE__ */ jsxRuntime.jsx(
1937
+ material.Box,
1938
+ {
1939
+ sx: {
1940
+ display: { md: "none", xs: "block" }
1941
+ },
1942
+ children: /* @__PURE__ */ jsxRuntime.jsxs(Menu, { children: [
1943
+ /* @__PURE__ */ jsxRuntime.jsx(MenuButton, { onClick: onClickMenu, children: /* @__PURE__ */ jsxRuntime.jsx(iconsMaterial.MenuOutlined, {}) }),
1944
+ /* @__PURE__ */ jsxRuntime.jsx(MenuDivider, { orientation: "vertical", flexItem: true })
1945
+ ] })
1946
+ }
1947
+ )
1948
+ );
1949
+ }
1950
+ const Logo = material.styled("div")(({ theme }) => ({
1951
+ display: "flex",
1952
+ marginRight: theme.spacing(1.5),
1953
+ "& a": {
1954
+ display: "flex"
1955
+ },
1956
+ "& svg, & img": {
1957
+ width: theme.spacing(4),
1958
+ height: theme.spacing(4)
1959
+ }
1960
+ }));
1961
+ function BrandLogo({ logo }) {
1962
+ return /* @__PURE__ */ jsxRuntime.jsx(Logo, { children: logo });
1963
+ }
1964
+ const Text$1 = material.styled(TablePaginationActions.Typography)({
1965
+ display: "flex",
1966
+ alignItems: "center",
1967
+ whiteSpace: "nowrap"
1968
+ });
1969
+ function BrandText({ text }) {
1970
+ const theme = material.useTheme();
1971
+ return /* @__PURE__ */ jsxRuntime.jsx(
1972
+ Text$1,
1973
+ {
1974
+ component: "span",
1975
+ variant: "subtitle1",
1976
+ color: theme.palette.brand.appBarContrastText,
1977
+ children: text
1978
+ }
1979
+ );
1980
+ }
1981
+ const Text = material.styled(TablePaginationActions.Typography)(({ theme }) => ({
1982
+ display: "flex",
1983
+ alignItems: "center",
1984
+ "&::before": {
1985
+ content: '"/"',
1986
+ margin: theme.spacing(0, 1),
1987
+ opacity: 0.6,
1988
+ color: theme.palette.brand.appBarContrastText
1989
+ }
1990
+ }));
1991
+ function SecondaryText({ text }) {
1992
+ const theme = material.useTheme();
1993
+ return /* @__PURE__ */ jsxRuntime.jsx(
1994
+ Text,
1995
+ {
1996
+ component: "span",
1997
+ variant: "body2",
1998
+ weight: "strong",
1999
+ color: theme.palette.brand.appBarContrastText,
2000
+ children: text
2001
+ }
2002
+ );
2003
+ }
2004
+ const Root$3 = material.styled(material.AppBar)(({ theme }) => ({
2005
+ backgroundColor: theme.palette.brand.appBarMain,
2006
+ "& .MuiTypography-root": {
2007
+ color: theme.palette.brand.appBarContrastText
2008
+ },
2009
+ "& .MuiIconButton-root path": {
2010
+ fill: theme.palette.brand.appBarContrastText
2011
+ }
2012
+ }));
2013
+ const BrandElements = material.styled("div")(({ theme }) => ({
2014
+ display: "flex",
2015
+ alignItems: "center",
2016
+ maxWidth: "calc(100% - 300px)",
2017
+ overflow: "hidden",
2018
+ [theme.breakpoints.down("sm")]: {
2019
+ minWidth: "192px"
2020
+ }
2021
+ }));
2022
+ const Content$2 = material.styled("div")(({ theme }) => ({
2023
+ display: "flex",
2024
+ alignItems: "center",
2025
+ justifyContent: "space-between",
2026
+ flex: 1,
2027
+ marginLeft: theme.spacing(1)
2028
+ }));
2029
+ function AppBar({
2030
+ children,
2031
+ brandLogo,
2032
+ brandText,
2033
+ secondaryText,
2034
+ showBurgerMenu = false,
2035
+ onClickMenu,
2036
+ ...otherProps
2037
+ }) {
2038
+ return /* @__PURE__ */ jsxRuntime.jsx(Root$3, { ...otherProps, children: /* @__PURE__ */ jsxRuntime.jsxs(material.Toolbar, { children: [
2039
+ /* @__PURE__ */ jsxRuntime.jsxs(BrandElements, { children: [
2040
+ showBurgerMenu && /* @__PURE__ */ jsxRuntime.jsx(BurgerMenu, { onClickMenu }),
2041
+ brandLogo && /* @__PURE__ */ jsxRuntime.jsx(BrandLogo, { logo: brandLogo }),
2042
+ brandText && /* @__PURE__ */ jsxRuntime.jsx(BrandText, { text: brandText }),
2043
+ secondaryText && /* @__PURE__ */ jsxRuntime.jsx(SecondaryText, { text: secondaryText })
2044
+ ] }),
2045
+ /* @__PURE__ */ jsxRuntime.jsx(Content$2, { children })
2046
+ ] }) });
2047
+ }
2048
+ const Container = material.styled(material.Box, {
2049
+ shouldForwardProp: (prop) => !["size", "variant"].includes(prop)
2050
+ })(({ size, variant, theme }) => ({
2051
+ position: "absolute",
2052
+ right: theme.spacing(5.75),
2053
+ ...size === "small" && {
2054
+ right: theme.spacing(4),
2055
+ top: "3px"
2056
+ // to align with design specs
2057
+ },
2058
+ ...variant === "standard" && {
2059
+ right: theme.spacing(4.75),
2060
+ ...size === "small" && {
2061
+ right: theme.spacing(3.5)
2062
+ }
2063
+ }
2064
+ }));
2065
+ function ClearButton({
2066
+ size,
2067
+ variant,
2068
+ ...props
2069
+ }) {
2070
+ const intl = reactIntl.useIntl();
2071
+ const intlConfig = TablePaginationActions.useImperativeIntl(intl);
2072
+ return /* @__PURE__ */ jsxRuntime.jsx(Container, { size, variant, children: /* @__PURE__ */ jsxRuntime.jsx(
2073
+ material.IconButton,
2074
+ {
2075
+ ...props,
2076
+ size,
2077
+ "aria-label": intlConfig.formatMessage({
2078
+ id: "c4r.form.clearSelection"
2079
+ })
2080
+ }
2081
+ ) });
2082
+ }
2083
+ const Root$2 = material.styled(material.Box, {
2084
+ shouldForwardProp: (prop) => !["size", "variant", "readOnly"].includes(prop)
2085
+ })(({ size, variant, readOnly, theme }) => ({
2086
+ // There is no specific slot to change TextField styles at DatePicker level, so we need to wrap our component to isolate this override. https://mui.com/x/react-date-pickers/date-picker/#customization
2087
+ ".MuiInputBase-root": {
2088
+ "& .clearButton svg": {
2089
+ color: theme.palette.text.hint
2090
+ },
2091
+ ...size === "small" && {
2092
+ paddingRight: `${theme.spacing(1)} !important`
2093
+ },
2094
+ ...size === "medium" && {
2095
+ "& .MuiInputAdornment-root": {
2096
+ "& .MuiIconButton-edgeEnd": {
2097
+ marginRight: theme.spacing(-1)
2098
+ }
2099
+ }
2100
+ },
2101
+ ...variant === "standard" && {
2102
+ paddingRight: `${theme.spacing(1)} !important`,
2103
+ ...size === "small" && {
2104
+ paddingRight: `${theme.spacing(0.5)} !important`
2105
+ }
2106
+ },
2107
+ ...readOnly && {
2108
+ "& .MuiInputAdornment-root": {
2109
+ "& svg": {
2110
+ color: theme.palette.text.disabled
2111
+ }
2112
+ }
2113
+ }
2114
+ }
2115
+ }));
2116
+ function DateFieldContainer({
2117
+ children,
2118
+ size,
2119
+ variant,
2120
+ readOnly,
2121
+ ...props
2122
+ }) {
2123
+ return /* @__PURE__ */ jsxRuntime.jsx(Root$2, { ...props, size, variant, readOnly, children });
2124
+ }
2125
+ function DatePicker({
2126
+ handleClear,
2127
+ variant = "outlined",
2128
+ size = "small",
2129
+ label,
2130
+ labelHelpTooltip,
2131
+ type,
2132
+ helperText,
2133
+ placeholder,
2134
+ slotProps,
2135
+ slots,
2136
+ error,
2137
+ showCalendar = true,
2138
+ readOnly,
2139
+ "aria-label": ariaLabel,
2140
+ "data-testid": dataTestId,
2141
+ ...props
2142
+ }) {
2143
+ const intl = reactIntl.useIntl();
2144
+ const intlConfig = TablePaginationActions.useImperativeIntl(intl);
2145
+ return (
2146
+ // Don't remove className, it's used for styling
2147
+ /* @__PURE__ */ jsxRuntime.jsx(material.Box, { className: "CartoDatePicker-root", "data-testid": "date-picker", children: /* @__PURE__ */ jsxRuntime.jsx(
2148
+ DateFieldContainer,
2149
+ {
2150
+ size,
2151
+ variant,
2152
+ readOnly,
2153
+ "data-name": "date-picker",
2154
+ "aria-label": ariaLabel,
2155
+ "data-testid": dataTestId,
2156
+ children: /* @__PURE__ */ jsxRuntime.jsx(
2157
+ DatePicker$1.DatePicker,
2158
+ {
2159
+ ...props,
2160
+ label: label && /* @__PURE__ */ jsxRuntime.jsx(
2161
+ LabelWithIndicator,
2162
+ {
2163
+ label,
2164
+ type,
2165
+ icon: labelHelpTooltip && /* @__PURE__ */ jsxRuntime.jsx(material.Tooltip, { title: labelHelpTooltip, children: /* @__PURE__ */ jsxRuntime.jsx(iconsMaterial.HelpOutline, { htmlColor: "text.secondary" }) })
2166
+ }
2167
+ ),
2168
+ slotProps: {
2169
+ // https://mui.com/x/api/date-pickers/date-picker/#slots
2170
+ textField: {
2171
+ variant,
2172
+ helperText,
2173
+ placeholder,
2174
+ size,
2175
+ error: error ?? void 0,
2176
+ // undefined is needed to allow the component to control the error state for the default validation
2177
+ inputProps: {
2178
+ "data-testid": "date-picker-input"
2179
+ }
2180
+ },
2181
+ field: {
2182
+ clearable: !!handleClear,
2183
+ onClear: handleClear
2184
+ },
2185
+ ...slotProps
2186
+ },
2187
+ slots: {
2188
+ clearButton: (props2) => /* @__PURE__ */ jsxRuntime.jsx(ClearButton, { ...props2, size, variant }),
2189
+ openPickerButton: (props2) => /* @__PURE__ */ jsxRuntime.jsx(
2190
+ material.IconButton,
2191
+ {
2192
+ ...props2,
2193
+ size,
2194
+ "aria-label": intlConfig.formatMessage({
2195
+ id: "c4r.form.chooseDate"
2196
+ })
2197
+ }
2198
+ ),
2199
+ ...slots
2200
+ },
2201
+ disableOpenPicker: !showCalendar,
2202
+ readOnly
2203
+ }
2204
+ )
2205
+ }
2206
+ ) })
2207
+ );
2208
+ }
2209
+ const PickersDayWrapper = material.styled(material.Box, {
2210
+ shouldForwardProp: (prop) => ![
2211
+ "isSelected",
2212
+ "isStartDate",
2213
+ "isEndDate",
2214
+ "isSelectedMonth",
2215
+ "isLastDay",
2216
+ "isFirstDay"
2217
+ ].includes(prop)
2218
+ })(
2219
+ ({
2220
+ theme,
2221
+ isSelected,
2222
+ isStartDate,
2223
+ isEndDate,
2224
+ isSelectedMonth,
2225
+ isLastDay,
2226
+ isFirstDay
2227
+ }) => ({
2228
+ position: "relative",
2229
+ margin: theme.spacing(0.25),
2230
+ "& .MuiPickersDay-root": {
2231
+ margin: 0
2232
+ },
2233
+ // Highlight the selected date range
2234
+ ...isSelected && isSelectedMonth && {
2235
+ // Creates a continuous background color between start and end date
2236
+ "&::before": {
2237
+ content: '""',
2238
+ position: "absolute",
2239
+ top: 0,
2240
+ right: "-2px",
2241
+ bottom: 0,
2242
+ left: "-2px",
2243
+ backgroundColor: theme.palette.primary.background,
2244
+ // Selected start date OR first day of the month
2245
+ ...(isStartDate || isFirstDay) && {
2246
+ left: 0,
2247
+ borderRadius: `${theme.shape.borderRadius}px 0 0 ${theme.shape.borderRadius}px`
2248
+ },
2249
+ // Selected end date OR last day of the month
2250
+ ...(isEndDate || isLastDay) && {
2251
+ right: 0,
2252
+ borderRadius: `0 ${theme.shape.borderRadius}px ${theme.shape.borderRadius}px 0`
2253
+ }
2254
+ },
2255
+ // First selected day
2256
+ "&:first-of-type::before": {
2257
+ left: 0,
2258
+ borderRadius: `${theme.shape.borderRadius}px 0 0 ${theme.shape.borderRadius}px`
2259
+ },
2260
+ // Last selected day
2261
+ "&:last-of-type::before": {
2262
+ right: 0,
2263
+ borderRadius: `0 ${theme.shape.borderRadius}px ${theme.shape.borderRadius}px 0`
2264
+ },
2265
+ // First day of month and last selected day in a week
2266
+ ...isFirstDay && {
2267
+ "&:last-of-type::before": {
2268
+ left: 0,
2269
+ right: 0,
2270
+ borderRadius: theme.shape.borderRadius
2271
+ }
2272
+ },
2273
+ // Last day of month and first selected day in a week
2274
+ ...isLastDay && {
2275
+ "&:first-of-type::before": {
2276
+ left: 0,
2277
+ right: 0,
2278
+ borderRadius: theme.shape.borderRadius
2279
+ }
2280
+ },
2281
+ "& .MuiPickersDay-today": {
2282
+ borderColor: `${theme.palette.default.outlinedBorder} !important`,
2283
+ ...(isStartDate || isEndDate) && {
2284
+ boxShadow: `0 0 0 1px inset ${theme.palette.background.paper}`
2285
+ }
2286
+ },
2287
+ // Always having a solid background color below to avoid color blending
2288
+ "&::after": {
2289
+ content: '""',
2290
+ position: "absolute",
2291
+ top: 0,
2292
+ right: 0,
2293
+ bottom: 0,
2294
+ left: 0,
2295
+ backgroundColor: theme.palette.background.paper,
2296
+ borderRadius: theme.shape.borderRadius,
2297
+ transition: "background-color 300ms cubic-bezier(0.4, 0, 0.2, 1) 0ms"
2298
+ },
2299
+ "&:hover::after": {
2300
+ backgroundColor: theme.palette.primary.relatedLight
2301
+ }
2302
+ }
2303
+ })
2304
+ );
2305
+ const CustomPickersDay = material.styled(xDatePickers.PickersDay, {
2306
+ shouldForwardProp: (prop) => prop !== "isDateRangeLimit"
2307
+ })(({ theme, isDateRangeLimit }) => ({
2308
+ "&.MuiPickersDay-root": {
2309
+ position: "relative",
2310
+ zIndex: 1,
2311
+ "&.Mui-selected": {
2312
+ color: theme.palette.text.primary
2313
+ },
2314
+ // Is selected date within the range
2315
+ ...isDateRangeLimit && {
2316
+ "&.Mui-selected": {
2317
+ backgroundColor: `${theme.palette.primary.main} !important`,
2318
+ color: theme.palette.primary.contrastText,
2319
+ "&:hover": {
2320
+ backgroundColor: `${theme.palette.primary.dark} !important`
2321
+ }
2322
+ }
2323
+ }
2324
+ }
2325
+ }));
2326
+ const isSameDay = (d1, d2) => {
2327
+ if (!d1 || !d2) return false;
2328
+ return d1.getFullYear() === d2.getFullYear() && d1.getMonth() === d2.getMonth() && d1.getDate() === d2.getDate();
2329
+ };
2330
+ function PickersDay({
2331
+ day,
2332
+ startDate,
2333
+ endDate,
2334
+ selectedMonth,
2335
+ ...otherProps
2336
+ }) {
2337
+ const isStartDate = Boolean(startDate && isSameDay(startDate, day));
2338
+ const isEndDate = Boolean(endDate && isSameDay(endDate, day));
2339
+ const isInsideRange = Boolean(
2340
+ startDate && endDate && day.getTime() >= startDate.getTime() && day.getTime() <= endDate.getTime()
2341
+ );
2342
+ const isFirstDayOfMonth = Boolean(day.getDate() === 1);
2343
+ const isLastDayOfMonth = Boolean(
2344
+ day.getDate() === new Date(day.getFullYear(), day.getMonth() + 1, 0).getDate()
2345
+ );
2346
+ const isDayInSelectedMonth = Boolean(
2347
+ selectedMonth && day.getMonth() === selectedMonth.getMonth()
2348
+ );
2349
+ return /* @__PURE__ */ jsxRuntime.jsx(
2350
+ PickersDayWrapper,
2351
+ {
2352
+ isSelected: isInsideRange,
2353
+ isStartDate,
2354
+ isEndDate,
2355
+ isSelectedMonth: isDayInSelectedMonth,
2356
+ isLastDay: isLastDayOfMonth,
2357
+ isFirstDay: isFirstDayOfMonth,
2358
+ children: /* @__PURE__ */ jsxRuntime.jsx(
2359
+ CustomPickersDay,
2360
+ {
2361
+ ...otherProps,
2362
+ day,
2363
+ selected: isInsideRange || isStartDate || isEndDate,
2364
+ isDateRangeLimit: isStartDate || isEndDate,
2365
+ "data-name": "pickers-day"
2366
+ }
2367
+ )
2368
+ }
2369
+ );
2370
+ }
2371
+ const FieldsWrapper = material.styled(material.Box, {
2372
+ shouldForwardProp: (prop) => !["variant"].includes(prop)
2373
+ })(({ variant, theme }) => ({
2374
+ display: "flex",
2375
+ gap: variant === "standard" ? theme.spacing(1) : "1px",
2376
+ "& .CartoDatePicker-root": {
2377
+ // Start date field
2378
+ "&:first-of-type": {
2379
+ ".MuiInputBase-root": {
2380
+ borderRadius: theme.spacing(0.5, 0, 0, 0.5),
2381
+ boxShadow: `1px 0 0 0 ${theme.palette.default.outlinedBorder}`,
2382
+ ...variant === "outlined" && {
2383
+ // Remove border from the right side only in its default state. Nested negation selector to target only specific Mui rules, otherwise it would force us to rewrite the state styles.
2384
+ "&:not(:hover):not(.Mui-focused):not(.Mui-error) .MuiOutlinedInput-notchedOutline": {
2385
+ borderRightColor: "transparent"
2386
+ }
2387
+ },
2388
+ ...variant === "filled" && {
2389
+ "&::before, &::after": {
2390
+ borderRadius: theme.spacing(0.5, 0, 0, 0.5)
2391
+ }
2392
+ },
2393
+ ...variant === "standard" && {
2394
+ boxShadow: "none",
2395
+ borderRadius: 0
2396
+ }
2397
+ }
2398
+ },
2399
+ // End date field
2400
+ "&:last-of-type": {
2401
+ ".MuiInputBase-root": {
2402
+ borderRadius: theme.spacing(0, 0.5, 0.5, 0),
2403
+ ...variant === "outlined" && {
2404
+ // Remove border from the left side only in its default state
2405
+ "&:not(:hover):not(.Mui-focused):not(.Mui-error) .MuiOutlinedInput-notchedOutline": {
2406
+ borderLeftColor: "transparent"
2407
+ }
2408
+ },
2409
+ ...variant === "filled" && {
2410
+ "&::before, &::after": {
2411
+ borderRadius: theme.spacing(0, 0.5, 0.5, 0)
2412
+ }
2413
+ },
2414
+ ...variant === "standard" && {
2415
+ borderRadius: 0
2416
+ }
2417
+ }
2418
+ }
2419
+ }
2420
+ }));
2421
+ function DateRangePicker({
2422
+ globalHelperText,
2423
+ error,
2424
+ variant = "outlined",
2425
+ startProps,
2426
+ endProps,
2427
+ "aria-label": ariaLabel,
2428
+ "data-testid": dataTestId,
2429
+ ...props
2430
+ }) {
2431
+ const intl = reactIntl.useIntl();
2432
+ const intlConfig = TablePaginationActions.useImperativeIntl(intl);
2433
+ const [isEndDateOpen, setIsEndDateOpen] = React.useState(false);
2434
+ const [isStartDateOpen, setIsStartDateOpen] = React.useState(false);
2435
+ const [startDate, setStartDate] = React.useState(
2436
+ (startProps == null ? void 0 : startProps.value) || null
2437
+ );
2438
+ const [endDate, setEndDate] = React.useState((endProps == null ? void 0 : endProps.value) || null);
2439
+ const [selectedMonth, setSelectedMonth] = React.useState(
2440
+ (endProps == null ? void 0 : endProps.value) ?? (startProps == null ? void 0 : startProps.value) ?? /* @__PURE__ */ new Date()
2441
+ );
2442
+ const hasError = error ?? (startProps == null ? void 0 : startProps.error) ?? (endProps == null ? void 0 : endProps.error);
2443
+ const handleStartDateChange = (value, context) => {
2444
+ setStartDate(value);
2445
+ if (startProps == null ? void 0 : startProps.onChange) {
2446
+ startProps.onChange(value, context);
2447
+ }
2448
+ if (value && context.validationError === null && !isStartDateOpen && context.trigger === null) {
2449
+ setIsStartDateOpen(false);
2450
+ setIsEndDateOpen(true);
2451
+ }
2452
+ };
2453
+ const handleEndDateChange = (value, context) => {
2454
+ setEndDate(value);
2455
+ if (endProps == null ? void 0 : endProps.onChange) {
2456
+ endProps.onChange(value, context);
2457
+ }
2458
+ };
2459
+ const handleStartDateOpen = () => {
2460
+ setIsStartDateOpen(true);
2461
+ setIsEndDateOpen(false);
2462
+ setTimeout(() => {
2463
+ setSelectedMonth(startDate ?? /* @__PURE__ */ new Date());
2464
+ }, 120);
2465
+ };
2466
+ const handleStartDateClose = () => {
2467
+ setIsStartDateOpen(false);
2468
+ setIsEndDateOpen(true);
2469
+ setTimeout(() => {
2470
+ setSelectedMonth(endDate ?? startDate ?? /* @__PURE__ */ new Date());
2471
+ }, 120);
2472
+ };
2473
+ const handleEndDateOpen = () => {
2474
+ setIsStartDateOpen(false);
2475
+ setIsEndDateOpen(true);
2476
+ setTimeout(() => {
2477
+ setSelectedMonth(endDate ?? startDate ?? /* @__PURE__ */ new Date());
2478
+ }, 120);
2479
+ };
2480
+ return /* @__PURE__ */ jsxRuntime.jsxs(material.Box, { children: [
2481
+ /* @__PURE__ */ jsxRuntime.jsxs(
2482
+ FieldsWrapper,
2483
+ {
2484
+ variant,
2485
+ "data-name": "date-range-picker",
2486
+ "aria-label": ariaLabel,
2487
+ "data-testid": dataTestId,
2488
+ children: [
2489
+ /* @__PURE__ */ jsxRuntime.jsx(
2490
+ DatePicker,
2491
+ {
2492
+ ...props,
2493
+ ...startProps,
2494
+ value: (startProps == null ? void 0 : startProps.value) ?? startDate,
2495
+ maxDate: endDate ?? void 0,
2496
+ label: (startProps == null ? void 0 : startProps.label) ?? intlConfig.formatMessage({ id: "c4r.form.startDate" }),
2497
+ slotProps: {
2498
+ popper: {
2499
+ placement: "bottom-start",
2500
+ "aria-label": intlConfig.formatMessage({
2501
+ id: "c4r.form.startDateCalendar"
2502
+ })
2503
+ },
2504
+ ...startProps == null ? void 0 : startProps.slotProps
2505
+ },
2506
+ slots: {
2507
+ openPickerIcon: iconsMaterial.TodayOutlined,
2508
+ day: (props2) => /* @__PURE__ */ jsxRuntime.jsx(
2509
+ PickersDay,
2510
+ {
2511
+ ...props2,
2512
+ startDate,
2513
+ endDate,
2514
+ selectedMonth
2515
+ }
2516
+ ),
2517
+ ...startProps == null ? void 0 : startProps.slots
2518
+ },
2519
+ error: (startProps == null ? void 0 : startProps.error) ?? error,
2520
+ open: isStartDateOpen,
2521
+ onChange: handleStartDateChange,
2522
+ onOpen: handleStartDateOpen,
2523
+ onClose: handleStartDateClose,
2524
+ onMonthChange: (month) => setSelectedMonth(month),
2525
+ variant
2526
+ }
2527
+ ),
2528
+ /* @__PURE__ */ jsxRuntime.jsx(
2529
+ DatePicker,
2530
+ {
2531
+ ...props,
2532
+ ...endProps,
2533
+ value: (endProps == null ? void 0 : endProps.value) ?? endDate,
2534
+ minDate: startDate ?? void 0,
2535
+ slotProps: {
2536
+ popper: {
2537
+ "aria-label": intlConfig.formatMessage({
2538
+ id: "c4r.form.endDateCalendar"
2539
+ })
2540
+ },
2541
+ ...endProps == null ? void 0 : endProps.slotProps
2542
+ },
2543
+ slots: {
2544
+ day: (props2) => /* @__PURE__ */ jsxRuntime.jsx(
2545
+ PickersDay,
2546
+ {
2547
+ ...props2,
2548
+ startDate,
2549
+ endDate,
2550
+ selectedMonth
2551
+ }
2552
+ ),
2553
+ ...endProps == null ? void 0 : endProps.slots
2554
+ },
2555
+ label: (endProps == null ? void 0 : endProps.label) ?? intlConfig.formatMessage({ id: "c4r.form.endDate" }),
2556
+ error: (endProps == null ? void 0 : endProps.error) ?? error,
2557
+ open: isEndDateOpen,
2558
+ onOpen: handleEndDateOpen,
2559
+ onClose: () => setIsEndDateOpen(false),
2560
+ onChange: handleEndDateChange,
2561
+ onMonthChange: (month) => setSelectedMonth(month),
2562
+ variant
2563
+ }
2564
+ )
2565
+ ]
2566
+ }
2567
+ ),
2568
+ globalHelperText && /* @__PURE__ */ jsxRuntime.jsx(material.FormHelperText, { error: hasError, children: globalHelperText })
2569
+ ] });
2570
+ }
2571
+ const getDateTimeFormat = (views, includeDate, ampm, format) => {
2572
+ const hasHours = views == null ? void 0 : views.includes("hours");
2573
+ const hasSeconds = views == null ? void 0 : views.includes("seconds");
2574
+ const hasMinutes = views == null ? void 0 : views.includes("minutes");
2575
+ const hasOnlyHours = (views == null ? void 0 : views.length) === 1 && views[0] === "hours";
2576
+ if (format) return format;
2577
+ const timeFormatParts = [];
2578
+ if (includeDate) {
2579
+ timeFormatParts.push("MM/dd/yyyy ");
2580
+ }
2581
+ if (hasHours) {
2582
+ timeFormatParts.push(ampm ? "hh" : "HH");
2583
+ }
2584
+ if (!hasOnlyHours) {
2585
+ timeFormatParts.push(":");
2586
+ }
2587
+ if (hasMinutes) {
2588
+ timeFormatParts.push("mm");
2589
+ }
2590
+ if (hasSeconds) {
2591
+ timeFormatParts.push(":ss");
2592
+ }
2593
+ if (ampm) {
2594
+ timeFormatParts.push(" a");
2595
+ }
2596
+ return timeFormatParts.join("");
2597
+ };
2598
+ function TimePicker({
2599
+ handleClear,
2600
+ variant = "outlined",
2601
+ size = "small",
2602
+ label,
2603
+ labelHelpTooltip,
2604
+ type,
2605
+ helperText,
2606
+ placeholder,
2607
+ error,
2608
+ showClock = true,
2609
+ readOnly,
2610
+ slotProps,
2611
+ slots,
2612
+ ampm = true,
2613
+ views = ["hours", "minutes"],
2614
+ format,
2615
+ "data-testid": dataTestId,
2616
+ "aria-label": ariaLabel,
2617
+ ...props
2618
+ }) {
2619
+ const intl = reactIntl.useIntl();
2620
+ const intlConfig = TablePaginationActions.useImperativeIntl(intl);
2621
+ const inputRef = React.useRef(null);
2622
+ const [inputWidth, setInputWidth] = React.useState(0);
2623
+ React.useEffect(() => {
2624
+ if (!inputRef.current) return;
2625
+ const resizeObserver = new ResizeObserver((entries) => {
2626
+ var _a;
2627
+ const width = (_a = entries[0]) == null ? void 0 : _a.contentRect.width;
2628
+ if (width) {
2629
+ setInputWidth(width);
2630
+ }
2631
+ });
2632
+ resizeObserver.observe(inputRef.current);
2633
+ return () => {
2634
+ resizeObserver.disconnect();
2635
+ };
2636
+ }, []);
2637
+ return /* @__PURE__ */ jsxRuntime.jsx(
2638
+ DateFieldContainer,
2639
+ {
2640
+ size,
2641
+ variant,
2642
+ readOnly,
2643
+ "data-name": "time-picker",
2644
+ "data-testid": dataTestId ?? "time-picker",
2645
+ "aria-label": ariaLabel,
2646
+ children: /* @__PURE__ */ jsxRuntime.jsx(
2647
+ TimePicker$1.TimePicker,
2648
+ {
2649
+ ...props,
2650
+ ref: inputRef,
2651
+ label: /* @__PURE__ */ jsxRuntime.jsx(
2652
+ LabelWithIndicator,
2653
+ {
2654
+ label: label ?? intlConfig.formatMessage({ id: "c4r.form.time" }),
2655
+ type,
2656
+ icon: labelHelpTooltip && /* @__PURE__ */ jsxRuntime.jsx(material.Tooltip, { title: labelHelpTooltip, children: /* @__PURE__ */ jsxRuntime.jsx(iconsMaterial.HelpOutline, { htmlColor: "text.secondary" }) })
2657
+ }
2658
+ ),
2659
+ views: ["hours"],
2660
+ format: getDateTimeFormat(views, false, ampm, format),
2661
+ slotProps: {
2662
+ textField: {
2663
+ variant,
2664
+ helperText,
2665
+ placeholder,
2666
+ size,
2667
+ error: error ?? void 0,
2668
+ // undefined is needed to allow the component to control the error state for the default validation
2669
+ inputProps: {
2670
+ "data-testid": "time-picker-input"
2671
+ }
2672
+ },
2673
+ field: {
2674
+ clearable: !!handleClear,
2675
+ onClear: handleClear
2676
+ },
2677
+ popper: {
2678
+ placement: "bottom-end"
2679
+ },
2680
+ layout: {
2681
+ sx: {
2682
+ width: inputWidth
2683
+ }
2684
+ },
2685
+ ...slotProps
2686
+ },
2687
+ slots: {
2688
+ clearButton: (props2) => /* @__PURE__ */ jsxRuntime.jsx(ClearButton, { ...props2, size, variant }),
2689
+ openPickerButton: (props2) => /* @__PURE__ */ jsxRuntime.jsx(
2690
+ material.IconButton,
2691
+ {
2692
+ ...props2,
2693
+ size,
2694
+ "aria-label": intlConfig.formatMessage({
2695
+ id: "c4r.form.chooseDate"
2696
+ })
2697
+ }
2698
+ ),
2699
+ ...slots
2700
+ },
2701
+ disableOpenPicker: !showClock,
2702
+ readOnly,
2703
+ ampm
2704
+ }
2705
+ )
2706
+ }
2707
+ );
2708
+ }
2709
+ function DateTimePicker({
2710
+ handleClear,
2711
+ variant = "outlined",
2712
+ size = "small",
2713
+ label,
2714
+ labelHelpTooltip,
2715
+ type,
2716
+ helperText,
2717
+ placeholder,
2718
+ error,
2719
+ showCalendar = true,
2720
+ readOnly,
2721
+ slotProps,
2722
+ slots,
2723
+ ampm = true,
2724
+ views = ["hours", "minutes"],
2725
+ format,
2726
+ "data-testid": dataTestId,
2727
+ "aria-label": ariaLabel,
2728
+ ...props
2729
+ }) {
2730
+ const intl = reactIntl.useIntl();
2731
+ const intlConfig = TablePaginationActions.useImperativeIntl(intl);
2732
+ return /* @__PURE__ */ jsxRuntime.jsx(
2733
+ DateFieldContainer,
2734
+ {
2735
+ size,
2736
+ variant,
2737
+ readOnly,
2738
+ "data-name": "date-time-picker",
2739
+ "data-testid": dataTestId ?? "date-time-picker",
2740
+ "aria-label": ariaLabel,
2741
+ children: /* @__PURE__ */ jsxRuntime.jsx(
2742
+ DateTimePicker$1.DateTimePicker,
2743
+ {
2744
+ ...props,
2745
+ label: /* @__PURE__ */ jsxRuntime.jsx(
2746
+ LabelWithIndicator,
2747
+ {
2748
+ label: label ?? intlConfig.formatMessage({ id: "c4r.form.time" }),
2749
+ type,
2750
+ icon: labelHelpTooltip && /* @__PURE__ */ jsxRuntime.jsx(material.Tooltip, { title: labelHelpTooltip, children: /* @__PURE__ */ jsxRuntime.jsx(iconsMaterial.HelpOutline, { htmlColor: "text.secondary" }) })
2751
+ }
2752
+ ),
2753
+ views: ["year", "month", "day", "hours"],
2754
+ format: getDateTimeFormat(views, true, ampm, format),
2755
+ slotProps: {
2756
+ textField: {
2757
+ variant,
2758
+ helperText,
2759
+ placeholder,
2760
+ size,
2761
+ error: error ?? void 0,
2762
+ // undefined is needed to allow the component to control the error state for the default validation
2763
+ inputProps: {
2764
+ "data-testid": "date-time-picker-input"
2765
+ }
2766
+ },
2767
+ field: {
2768
+ clearable: !!handleClear,
2769
+ onClear: handleClear
2770
+ },
2771
+ ...slotProps
2772
+ },
2773
+ slots: {
2774
+ clearButton: (props2) => /* @__PURE__ */ jsxRuntime.jsx(ClearButton, { ...props2, size, variant }),
2775
+ openPickerButton: (props2) => /* @__PURE__ */ jsxRuntime.jsx(
2776
+ material.IconButton,
2777
+ {
2778
+ ...props2,
2779
+ size,
2780
+ "aria-label": intlConfig.formatMessage({
2781
+ id: "c4r.form.chooseDate"
2782
+ })
2783
+ }
2784
+ ),
2785
+ ...slots
2786
+ },
2787
+ disableOpenPicker: !showCalendar,
2788
+ readOnly,
2789
+ ampm
2790
+ }
2791
+ )
2792
+ }
2793
+ );
2794
+ }
2795
+ const DEFAULT_ITEMS = [{ outlinedBullet: false, value: "" }];
2796
+ const Content$1 = material.styled("ul")(({ theme }) => ({
2797
+ listStyle: "none",
2798
+ paddingLeft: 0,
2799
+ margin: theme.spacing(0.5, 0, 0, 0)
2800
+ }));
2801
+ const Entry = material.styled("li")(({ theme }) => ({
2802
+ display: "flex",
2803
+ alignItems: "center",
2804
+ justifyContent: "space-between",
2805
+ "&:not(:last-child)": {
2806
+ marginBottom: theme.spacing(0.5)
2807
+ }
2808
+ }));
2809
+ const Bullet = material.styled("span")(({ theme }) => ({
2810
+ width: theme.spacing(1),
2811
+ height: theme.spacing(1),
2812
+ marginRight: theme.spacing(0.5),
2813
+ border: `2px solid ${theme.palette.qualitative.bold[1]}`,
2814
+ borderRadius: "50%",
2815
+ backgroundColor: theme.palette.qualitative.bold[1]
2816
+ }));
2817
+ const Category = material.styled(TablePaginationActions.Typography)(({ theme }) => ({
2818
+ minWidth: theme.spacing(10),
2819
+ marginRight: theme.spacing(1.5)
2820
+ }));
2821
+ function TooltipData({
2822
+ items = DEFAULT_ITEMS,
2823
+ title
2824
+ }) {
2825
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2826
+ title && /* @__PURE__ */ jsxRuntime.jsx(TablePaginationActions.Typography, { color: "inherit", variant: "caption", weight: "medium", children: title }),
2827
+ /* @__PURE__ */ jsxRuntime.jsx(Content$1, { children: items.map((item, index) => /* @__PURE__ */ jsxRuntime.jsxs(Entry, { children: [
2828
+ /* @__PURE__ */ jsxRuntime.jsx(
2829
+ Bullet,
2830
+ {
2831
+ style: {
2832
+ backgroundColor: `${item.outlinedBullet ? "transparent" : item.color}`,
2833
+ borderColor: item.color
2834
+ }
2835
+ }
2836
+ ),
2837
+ item.category && /* @__PURE__ */ jsxRuntime.jsx(Category, { color: "inherit", variant: "caption", children: item.category }),
2838
+ /* @__PURE__ */ jsxRuntime.jsx(TablePaginationActions.Typography, { color: "inherit", variant: "caption", weight: "medium", children: item.value })
2839
+ ] }, index)) })
2840
+ ] });
2841
+ }
2842
+ const sizesHeight = {
2843
+ [
2844
+ "small"
2845
+ /* Small */
2846
+ ]: "480px",
2847
+ [
2848
+ "medium"
2849
+ /* Medium */
2850
+ ]: "640px",
2851
+ [
2852
+ "large"
2853
+ /* Large */
2854
+ ]: "640px",
2855
+ [
2856
+ "xlarge"
2857
+ /* XLarge */
2858
+ ]: "720px"
2859
+ };
2860
+ const dialogDimensionsBySize = {
2861
+ [
2862
+ "small"
2863
+ /* Small */
2864
+ ]: {
2865
+ width: "432px",
2866
+ maxWidth: "432px"
2867
+ },
2868
+ [
2869
+ "medium"
2870
+ /* Medium */
2871
+ ]: {
2872
+ width: "592px",
2873
+ maxWidth: "592px"
2874
+ },
2875
+ [
2876
+ "large"
2877
+ /* Large */
2878
+ ]: {
2879
+ width: "768px",
2880
+ maxWidth: "768px",
2881
+ minHeight: "576px"
2882
+ },
2883
+ [
2884
+ "xlarge"
2885
+ /* XLarge */
2886
+ ]: {
2887
+ width: "calc(100vw - 80px)",
2888
+ height: "calc(100vh - 80px)",
2889
+ maxWidth: "960px"
2890
+ }
2891
+ };
2892
+ const DialogPaper = material.styled(material.Paper, {
2893
+ shouldForwardProp: (prop) => !["fullScreen", "height", "width", "hasForm"].includes(prop)
2894
+ })(
2895
+ ({
2896
+ fullScreen,
2897
+ height,
2898
+ width,
2899
+ hasForm,
2900
+ size = "small",
2901
+ theme
2902
+ }) => ({
2903
+ "&.MuiPaper-root": {
2904
+ position: "relative",
2905
+ display: "flex",
2906
+ flexDirection: "column",
2907
+ margin: theme.spacing(5),
2908
+ borderRadius: theme.spacing(1),
2909
+ ...dialogDimensionsBySize[size],
2910
+ maxHeight: sizesHeight[size],
2911
+ [`@media (max-height:${sizesHeight[size]})`]: {
2912
+ maxHeight: "calc(100vh - 80px)",
2913
+ ...size === "large" && {
2914
+ minHeight: height !== "auto" ? "calc(100vh - 80px)" : "auto"
2915
+ }
2916
+ },
2917
+ ...fullScreen && {
2918
+ width: "100vw",
2919
+ maxWidth: `calc(100vw - ${theme.spacing(10)})`,
2920
+ height: "100vh",
2921
+ maxHeight: `calc(100vh - ${theme.spacing(10)})`,
2922
+ margin: theme.spacing(5),
2923
+ borderRadius: theme.spacing(1)
2924
+ },
2925
+ ...height && {
2926
+ height,
2927
+ minHeight: height
2928
+ },
2929
+ ...width && {
2930
+ width
2931
+ },
2932
+ [theme.breakpoints.down("sm")]: {
2933
+ position: "absolute",
2934
+ width: "100%",
2935
+ maxWidth: "100%",
2936
+ height: "100vh",
2937
+ maxHeight: "100vh",
2938
+ top: 0,
2939
+ bottom: 0,
2940
+ left: 0,
2941
+ right: 0,
2942
+ margin: 0,
2943
+ borderRadius: 0,
2944
+ ...height && {
2945
+ top: "auto",
2946
+ borderRadius: theme.spacing(1, 1, 0, 0),
2947
+ height,
2948
+ minHeight: height
2949
+ }
2950
+ },
2951
+ // Special case for Dialogs wrapped in Form
2952
+ ...hasForm && {
2953
+ maxHeight: `calc(100vh - ${theme.spacing(10)})`,
2954
+ form: {
2955
+ flex: 1,
2956
+ display: "flex",
2957
+ flexDirection: "column",
2958
+ justifyContent: "space-between",
2959
+ overflow: "hidden",
2960
+ ...dialogDimensionsBySize[size],
2961
+ maxWidth: "100%",
2962
+ ...fullScreen && {
2963
+ width: "100%",
2964
+ maxWidth: "100%",
2965
+ height: "100%",
2966
+ maxHeight: "100%"
2967
+ },
2968
+ ...height && {
2969
+ height,
2970
+ minHeight: height
2971
+ },
2972
+ ...width && {
2973
+ width
2974
+ },
2975
+ [theme.breakpoints.down("sm")]: {
2976
+ width: "100%",
2977
+ maxWidth: "100%",
2978
+ height: "100vh",
2979
+ maxHeight: "100vh",
2980
+ ...height && {
2981
+ top: "auto",
2982
+ borderRadius: theme.spacing(1, 1, 0, 0),
2983
+ height,
2984
+ minHeight: height
2985
+ }
2986
+ }
2987
+ }
2988
+ }
2989
+ }
2990
+ })
2991
+ );
2992
+ function _Dialog({
2993
+ nonModal,
2994
+ children,
2995
+ size = "small",
2996
+ PaperProps,
2997
+ fullScreen,
2998
+ height,
2999
+ width,
3000
+ hasForm,
3001
+ "aria-label": ariaLabel,
3002
+ "data-testid": dataTestId,
3003
+ ...props
3004
+ }, ref) {
3005
+ if (nonModal) {
3006
+ return /* @__PURE__ */ jsxRuntime.jsx(
3007
+ DialogPaper,
3008
+ {
3009
+ size,
3010
+ fullScreen,
3011
+ height,
3012
+ width,
3013
+ hasForm,
3014
+ "aria-label": ariaLabel,
3015
+ "data-testid": dataTestId,
3016
+ "data-name": "dialog",
3017
+ ...props,
3018
+ ref,
3019
+ children
3020
+ }
3021
+ );
3022
+ }
3023
+ return /* @__PURE__ */ jsxRuntime.jsx(
3024
+ material.Dialog,
3025
+ {
3026
+ PaperComponent: DialogPaper,
3027
+ PaperProps: {
3028
+ ...PaperProps,
3029
+ size,
3030
+ fullScreen,
3031
+ height,
3032
+ width,
3033
+ hasForm
3034
+ },
3035
+ fullScreen,
3036
+ role: "section",
3037
+ "aria-label": ariaLabel,
3038
+ "data-testid": dataTestId,
3039
+ "data-size": size,
3040
+ "data-width": width,
3041
+ "data-height": height,
3042
+ "data-name": "dialog",
3043
+ ...props,
3044
+ ref,
3045
+ children
3046
+ }
3047
+ );
3048
+ }
3049
+ const Dialog = React.forwardRef(_Dialog);
3050
+ const DialogTitle = material.styled(material.DialogTitle)(() => ({
3051
+ padding: 0,
3052
+ zIndex: 10
3053
+ }));
3054
+ const Main$1 = material.styled(material.Box)(({ theme }) => ({
3055
+ display: "flex",
3056
+ alignItems: "center",
3057
+ justifyContent: "space-between",
3058
+ padding: theme.spacing(2),
3059
+ minHeight: theme.spacing(8)
3060
+ }));
3061
+ const ItemsWrapper$1 = material.styled(material.Box)(({ theme }) => ({
3062
+ display: "flex",
3063
+ alignItems: "center",
3064
+ gap: theme.spacing(1),
3065
+ overflow: "hidden"
3066
+ }));
3067
+ const CloseIcon = material.styled(iconsMaterial.CloseOutlined)(({ theme }) => ({
3068
+ color: theme.palette.text.secondary
3069
+ }));
3070
+ const DividerBottom = material.styled(material.Divider)(() => ({
3071
+ "+ .MuiDialogContent-root": {
3072
+ borderTop: "none !important"
3073
+ }
3074
+ }));
3075
+ function DialogHeader({
3076
+ title,
3077
+ chipLabel,
3078
+ chipProps,
3079
+ children,
3080
+ onClose,
3081
+ secondaryActions,
3082
+ "aria-label": ariaLabel,
3083
+ closeIcon,
3084
+ ...otherProps
3085
+ }) {
3086
+ const intl = reactIntl.useIntl();
3087
+ const intlConfig = TablePaginationActions.useImperativeIntl(intl);
3088
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
3089
+ /* @__PURE__ */ jsxRuntime.jsxs(DialogTitle, { component: "div", "data-name": "dialog-header", ...otherProps, children: [
3090
+ /* @__PURE__ */ jsxRuntime.jsxs(Main$1, { children: [
3091
+ /* @__PURE__ */ jsxRuntime.jsxs(ItemsWrapper$1, { flex: 1, maxWidth: 0.8, children: [
3092
+ /* @__PURE__ */ jsxRuntime.jsx(
3093
+ TablePaginationActions.Typography,
3094
+ {
3095
+ component: "h2",
3096
+ variant: "inherit",
3097
+ noWrap: true,
3098
+ "aria-label": ariaLabel,
3099
+ role: "heading",
3100
+ children: title
3101
+ }
3102
+ ),
3103
+ chipLabel && /* @__PURE__ */ jsxRuntime.jsx(material.Chip, { color: "default", label: chipLabel, ...chipProps })
3104
+ ] }),
3105
+ /* @__PURE__ */ jsxRuntime.jsxs(ItemsWrapper$1, { children: [
3106
+ secondaryActions,
3107
+ onClose && /* @__PURE__ */ jsxRuntime.jsx(
3108
+ material.Tooltip,
3109
+ {
3110
+ title: intlConfig.formatMessage({ id: "c4r.button.close" }),
3111
+ placement: "left",
3112
+ children: /* @__PURE__ */ jsxRuntime.jsx(material.IconButton, { onClick: onClose, children: closeIcon || /* @__PURE__ */ jsxRuntime.jsx(CloseIcon, { "data-testid": "CloseIcon" }) })
3113
+ }
3114
+ )
3115
+ ] })
3116
+ ] }),
3117
+ children
3118
+ ] }),
3119
+ children && /* @__PURE__ */ jsxRuntime.jsx(DividerBottom, {})
3120
+ ] });
3121
+ }
3122
+ const Content = material.styled(material.DialogContent, {
3123
+ shouldForwardProp: (prop) => !["scrollableContent", "withGutter", "withBottomGutter"].includes(prop)
3124
+ })(({ theme, scrollableContent, withGutter, withBottomGutter }) => ({
3125
+ display: "flex",
3126
+ flexDirection: "column",
3127
+ gap: theme.spacing(3),
3128
+ padding: 0,
3129
+ ...theme.typography.body2,
3130
+ color: theme.palette.text.secondary,
3131
+ ".MuiAlert-root": {
3132
+ minHeight: "auto"
3133
+ },
3134
+ ...scrollableContent && {
3135
+ borderBottom: `1px solid ${theme.palette.divider}`,
3136
+ "+ .MuiDivider-root": {
3137
+ display: "none"
3138
+ }
3139
+ },
3140
+ ...withGutter && {
3141
+ padding: ` ${theme.spacing(1, 2, 0)} !important`,
3142
+ ".MuiDialog-paperFullScreen &": {
3143
+ padding: `${theme.spacing(2, 2, 0)} !important`
3144
+ }
3145
+ },
3146
+ ...withBottomGutter && {
3147
+ paddingBottom: `${theme.spacing(3)} !important`,
3148
+ ".MuiDialog-paperFullScreen &": {
3149
+ paddingBottom: `${theme.spacing(3)} !important`
3150
+ }
3151
+ }
3152
+ }));
3153
+ function _DialogContent({
3154
+ children,
3155
+ scrollableContent,
3156
+ hasFooterAlert,
3157
+ withGutter = true,
3158
+ withBottomGutter = true,
3159
+ onScroll,
3160
+ ...props
3161
+ }, ref) {
3162
+ const theme = material.useTheme();
3163
+ const [contentRef, setContentRef] = React.useState(null);
3164
+ React.useImperativeHandle(
3165
+ ref,
3166
+ () => contentRef,
3167
+ [contentRef]
3168
+ );
3169
+ const updateBorders = React.useCallback(
3170
+ (node) => {
3171
+ const bottom = Math.abs(node.scrollHeight - node.clientHeight - node.scrollTop) < 1;
3172
+ const top = node.scrollTop === 0;
3173
+ const borderStyle = `1px solid ${theme.palette.divider}`;
3174
+ node.style.borderTop = top ? "none" : borderStyle;
3175
+ node.style.borderBottom = bottom && !hasFooterAlert ? "none" : borderStyle;
3176
+ },
3177
+ [theme.palette.divider, hasFooterAlert]
3178
+ );
3179
+ const handleScroll = React.useCallback(
3180
+ (event) => {
3181
+ updateBorders(event.target);
3182
+ onScroll == null ? void 0 : onScroll(event);
3183
+ },
3184
+ [updateBorders, onScroll]
3185
+ );
3186
+ React.useEffect(() => {
3187
+ if (!contentRef) return;
3188
+ updateBorders(contentRef);
3189
+ }, [contentRef, updateBorders]);
3190
+ React.useEffect(() => {
3191
+ if (!contentRef || typeof ResizeObserver === "undefined") return;
3192
+ const resizeObserver = new ResizeObserver(() => {
3193
+ updateBorders(contentRef);
3194
+ });
3195
+ resizeObserver.observe(contentRef);
3196
+ return () => resizeObserver.disconnect();
3197
+ }, [contentRef, updateBorders]);
3198
+ return /* @__PURE__ */ jsxRuntime.jsx(
3199
+ Content,
3200
+ {
3201
+ ref: setContentRef,
3202
+ onScroll: handleScroll,
3203
+ scrollableContent,
3204
+ withGutter,
3205
+ withBottomGutter: withBottomGutter && withGutter,
3206
+ "data-name": "dialog-content",
3207
+ ...props,
3208
+ children
3209
+ }
3210
+ );
3211
+ }
3212
+ const DialogContent = React.forwardRef(_DialogContent);
3213
+ const DialogContentPadded = material.styled(DialogContent, {
3214
+ shouldForwardProp: (prop) => prop !== "withAlert"
3215
+ })(({ withAlert, theme }) => ({
3216
+ padding: `${theme.spacing(0, 2)} !important`,
3217
+ ...withAlert && {
3218
+ paddingBottom: `${theme.spacing(3)} !important`
3219
+ }
3220
+ }));
3221
+ const StyledAlert = material.styled(Alert$1.Alert)(({ theme }) => ({
3222
+ minHeight: "auto",
3223
+ padding: 0,
3224
+ backgroundColor: "transparent",
3225
+ "& .MuiTypography-root": {
3226
+ color: theme.palette.text.secondary,
3227
+ a: {
3228
+ color: theme.palette.primary.main
3229
+ }
3230
+ },
3231
+ "& .MuiAlertTitle-root": {
3232
+ color: theme.palette.text.primary
3233
+ }
3234
+ }));
3235
+ function DialogAlert({
3236
+ children,
3237
+ severity = "neutral",
3238
+ ...otherProps
3239
+ }) {
3240
+ return /* @__PURE__ */ jsxRuntime.jsx(StyledAlert, { severity, ...otherProps, "data-name": "dialog-alert", children });
3241
+ }
3242
+ const Root$1 = material.styled(material.Box, {
3243
+ shouldForwardProp: (prop) => !["dark", "hasChildren"].includes(prop)
3244
+ })(({ dark, hasChildren, theme }) => ({
3245
+ flex: "0 0 auto",
3246
+ display: "block",
3247
+ minHeight: hasChildren ? theme.spacing(8) : "auto",
3248
+ zIndex: 10,
3249
+ ...dark && {
3250
+ backgroundColor: theme.palette.common.black,
3251
+ color: theme.palette.white[60],
3252
+ ".MuiAlert-root": {
3253
+ ".MuiTypography-root, .MuiAlert-message :not(.MuiAlertTitle-root)": {
3254
+ color: theme.palette.white[60],
3255
+ a: {
3256
+ color: `${theme.palette.secondary.main} !important`
3257
+ }
3258
+ },
3259
+ ".MuiAlert-icon": {
3260
+ color: theme.palette.white[60]
3261
+ }
3262
+ }
3263
+ }
3264
+ }));
3265
+ const Main = material.styled(material.Box)(() => ({
3266
+ display: "flex",
3267
+ alignItems: "center",
3268
+ justifyContent: "space-between",
3269
+ "& > div:empty": {
3270
+ padding: 0
3271
+ }
3272
+ }));
3273
+ const ItemsWrapper = material.styled(material.Box, {
3274
+ shouldForwardProp: (prop) => prop !== "hasAlert"
3275
+ })(({ hasAlert, theme }) => ({
3276
+ display: "flex",
3277
+ alignItems: "center",
3278
+ gap: theme.spacing(1),
3279
+ padding: theme.spacing(2),
3280
+ paddingTop: hasAlert ? 0 : theme.spacing(2)
3281
+ }));
3282
+ const DialogActions = material.styled(material.DialogActions, {
3283
+ shouldForwardProp: (prop) => prop !== "hasAlert"
3284
+ })(({ hasAlert, theme }) => ({
3285
+ gap: theme.spacing(1),
3286
+ padding: theme.spacing(2),
3287
+ paddingTop: hasAlert ? 0 : theme.spacing(2),
3288
+ margin: 0,
3289
+ ".MuiButton-root + .MuiButton-root": {
3290
+ marginLeft: 0
3291
+ }
3292
+ }));
3293
+ const DividerTop = material.styled(material.Divider)(() => ({
3294
+ // To prevent double border in the top when content is scrollable
3295
+ marginTop: "-1px"
3296
+ }));
3297
+ function DialogFooter({
3298
+ children,
3299
+ secondaryActions,
3300
+ alertContent,
3301
+ alertProps,
3302
+ dark,
3303
+ topContent,
3304
+ ...otherProps
3305
+ }) {
3306
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
3307
+ topContent,
3308
+ !!alertContent && /* @__PURE__ */ jsxRuntime.jsx(DividerTop, {}),
3309
+ /* @__PURE__ */ jsxRuntime.jsxs(
3310
+ Root$1,
3311
+ {
3312
+ ...otherProps,
3313
+ dark,
3314
+ "data-theme": dark ? "dark" : "light",
3315
+ "data-name": "dialog-footer",
3316
+ hasChildren: !!children,
3317
+ children: [
3318
+ !!alertContent && /* @__PURE__ */ jsxRuntime.jsx(material.Box, { sx: { p: 2, pt: 1.5, pb: 1 }, children: /* @__PURE__ */ jsxRuntime.jsx(DialogAlert, { ...alertProps, children: alertContent }) }),
3319
+ /* @__PURE__ */ jsxRuntime.jsxs(Main, { children: [
3320
+ /* @__PURE__ */ jsxRuntime.jsx(ItemsWrapper, { hasAlert: !!alertContent, children: secondaryActions }),
3321
+ /* @__PURE__ */ jsxRuntime.jsx(DialogActions, { hasAlert: !!alertContent, children })
3322
+ ] })
3323
+ ]
3324
+ }
3325
+ )
3326
+ ] });
3327
+ }
3328
+ const Backdrop = material.styled(material.Box)(({ theme }) => ({
3329
+ position: "absolute",
3330
+ width: "100%",
3331
+ zIndex: 100,
3332
+ top: 0,
3333
+ bottom: 0,
3334
+ left: 0,
3335
+ right: 0,
3336
+ overflow: "hidden",
3337
+ display: "flex",
3338
+ boxSizing: "border-box",
3339
+ alignItems: "flex-end",
3340
+ background: theme.palette.white[60]
3341
+ }));
3342
+ const AnimationWrapper = material.styled("div")(() => ({
3343
+ width: "100%"
3344
+ }));
3345
+ const BackdropContent = material.styled(material.Box)(({ theme }) => ({
3346
+ width: "100%",
3347
+ padding: theme.spacing(1.5, 2, 2),
3348
+ backgroundColor: theme.palette.background.paper,
3349
+ borderTop: `1px solid ${theme.palette.divider}`,
3350
+ ".MuiDialogActions-root": {
3351
+ padding: 0,
3352
+ marginTop: theme.spacing(1)
3353
+ }
3354
+ }));
3355
+ function DialogConfirmation({
3356
+ children,
3357
+ onClickAway,
3358
+ actions,
3359
+ severity = "warning",
3360
+ opened,
3361
+ "data-testid": dataTestId,
3362
+ "aria-label": ariaLabel,
3363
+ ...alertProps
3364
+ }) {
3365
+ const containerRef = React.useRef(null);
3366
+ const theme = material.useTheme();
3367
+ const handleClickAway = () => {
3368
+ if (onClickAway) {
3369
+ onClickAway();
3370
+ }
3371
+ };
3372
+ return /* @__PURE__ */ jsxRuntime.jsx(
3373
+ Backdrop,
3374
+ {
3375
+ ref: containerRef,
3376
+ "data-testid": dataTestId,
3377
+ "aria-label": ariaLabel,
3378
+ role: "presentation",
3379
+ "data-name": "dialog-confirmation",
3380
+ children: /* @__PURE__ */ jsxRuntime.jsx(ClickAwayListener, { onClickAway: handleClickAway, children: /* @__PURE__ */ jsxRuntime.jsx(
3381
+ material.Slide,
3382
+ {
3383
+ direction: "up",
3384
+ in: opened,
3385
+ container: containerRef.current,
3386
+ mountOnEnter: true,
3387
+ unmountOnExit: true,
3388
+ easing: theme.transitions.easing.easeOut,
3389
+ timeout: 350,
3390
+ children: /* @__PURE__ */ jsxRuntime.jsx(AnimationWrapper, { children: /* @__PURE__ */ jsxRuntime.jsxs(BackdropContent, { children: [
3391
+ /* @__PURE__ */ jsxRuntime.jsx(DialogAlert, { severity, ...alertProps, children }),
3392
+ /* @__PURE__ */ jsxRuntime.jsx(DialogActions, { children: actions })
3393
+ ] }) })
3394
+ }
3395
+ ) })
3396
+ }
3397
+ );
3398
+ }
3399
+ const Root = material.styled(material.Box)(({ theme }) => ({
3400
+ display: "flex",
3401
+ alignItems: "center",
3402
+ justifyContent: "center",
3403
+ height: theme.spacing(8),
3404
+ marginBottom: theme.spacing(2),
3405
+ "& > div": {
3406
+ flex: 1
3407
+ }
3408
+ }));
3409
+ const StepContainer = material.styled(material.Box)(({ theme }) => ({
3410
+ display: "flex",
3411
+ flex: 1,
3412
+ flexDirection: "column",
3413
+ justifyContent: "center",
3414
+ alignItems: "center",
3415
+ position: "relative",
3416
+ "&:before, &:after": {
3417
+ content: '""',
3418
+ background: theme.palette.divider,
3419
+ position: "absolute",
3420
+ top: theme.spacing(1.25),
3421
+ height: theme.spacing(0.25),
3422
+ width: `calc(50% - ${theme.spacing(2.5)})`
3423
+ },
3424
+ "&:before": {
3425
+ left: 0
3426
+ },
3427
+ "&:after": {
3428
+ right: 0
3429
+ },
3430
+ "&:first-of-type:before": {
3431
+ content: "none"
3432
+ },
3433
+ "&:last-of-type:after": {
3434
+ content: "none"
3435
+ }
3436
+ }));
3437
+ function getStepNumberColors({
3438
+ theme,
3439
+ completed,
3440
+ current
3441
+ }) {
3442
+ if (completed) {
3443
+ return {
3444
+ background: theme.palette.success.main,
3445
+ borderColor: theme.palette.success.main,
3446
+ color: theme.palette.common.white
3447
+ };
3448
+ } else if (current) {
3449
+ return {
3450
+ background: theme.palette.text.primary,
3451
+ borderColor: theme.palette.text.primary,
3452
+ color: theme.palette.common.white
3453
+ };
3454
+ } else {
3455
+ return {
3456
+ borderColor: theme.palette.text.secondary,
3457
+ color: theme.palette.text.secondary
3458
+ };
3459
+ }
3460
+ }
3461
+ const StepNumber = material.styled("span", {
3462
+ shouldForwardProp: (prop) => prop !== "completed" && prop !== "current"
3463
+ })(({ theme, completed, current }) => ({
3464
+ display: "flex",
3465
+ justifyContent: "center",
3466
+ alignItems: "center",
3467
+ height: theme.spacing(3),
3468
+ width: theme.spacing(3),
3469
+ marginBottom: theme.spacing(1),
3470
+ borderRadius: "50%",
3471
+ border: `${theme.spacing(0.25)} solid currentColor`,
3472
+ ...theme.typography.caption,
3473
+ ...getStepNumberColors({ theme, completed, current })
3474
+ }));
3475
+ function DialogStepper({
3476
+ currentStep,
3477
+ stepsLabels,
3478
+ ...props
3479
+ }) {
3480
+ return /* @__PURE__ */ jsxRuntime.jsx(Root, { ...props, "data-name": "dialog-stepper", children: /* @__PURE__ */ jsxRuntime.jsx(material.Box, { sx: { display: "flex" }, children: stepsLabels.map((stepLabel, idx) => {
3481
+ const step = idx + 1;
3482
+ const isCurrent = step === currentStep;
3483
+ const isCompleted = step < currentStep;
3484
+ const labelColor = isCompleted ? "success.main" : isCurrent ? "textPrimary" : "textSecondary";
3485
+ return /* @__PURE__ */ jsxRuntime.jsxs(
3486
+ StepContainer,
3487
+ {
3488
+ "data-state": isCompleted ? "completed" : isCurrent ? "current" : "uncompleted",
3489
+ children: [
3490
+ /* @__PURE__ */ jsxRuntime.jsx(StepNumber, { completed: isCompleted, current: isCurrent, children: isCompleted ? /* @__PURE__ */ jsxRuntime.jsx(iconsMaterial.Check, { fontSize: "small", "aria-label": "Completed step" }) : step }),
3491
+ /* @__PURE__ */ jsxRuntime.jsx(TablePaginationActions.Typography, { variant: "caption", component: "div", color: labelColor, children: stepLabel })
3492
+ ]
3493
+ },
3494
+ idx
3495
+ );
3496
+ }) }) });
3497
+ }
3498
+ exports.TablePaginationActions = TablePaginationActions.TablePaginationActions;
3499
+ exports.Typography = TablePaginationActions.Typography;
3500
+ exports.Alert = Alert$1.Alert;
3501
+ exports.MenuItem = MenuItem.MenuItem;
3502
+ exports.AccordionGroup = AccordionGroup;
3503
+ exports.AppBar = AppBar;
3504
+ exports.Autocomplete = Autocomplete;
3505
+ exports.Avatar = Avatar;
3506
+ exports.Button = Button;
3507
+ exports.CopiableComponent = CopiableComponent;
3508
+ exports.CreatableAutocomplete = CreatableAutocomplete;
3509
+ exports.DatePicker = DatePicker;
3510
+ exports.DateRangePicker = DateRangePicker;
3511
+ exports.DateTimePicker = DateTimePicker;
3512
+ exports.Dialog = Dialog;
3513
+ exports.DialogActions = DialogActions;
3514
+ exports.DialogAlert = DialogAlert;
3515
+ exports.DialogConfirmation = DialogConfirmation;
3516
+ exports.DialogContent = DialogContent;
3517
+ exports.DialogContentPadded = DialogContentPadded;
3518
+ exports.DialogFooter = DialogFooter;
3519
+ exports.DialogHeader = DialogHeader;
3520
+ exports.DialogPaper = DialogPaper;
3521
+ exports.DialogStepper = DialogStepper;
3522
+ exports.IconButton = IconButton;
3523
+ exports.LabelWithIndicator = LabelWithIndicator;
3524
+ exports.Menu = Menu$1;
3525
+ exports.MenuItemFilter = MenuItemFilter;
3526
+ exports.MenuList = MenuList;
3527
+ exports.MultipleAutocomplete = MultipleAutocomplete;
3528
+ exports.MultipleSelectField = MultipleSelectField;
3529
+ exports.PasswordField = PasswordField;
3530
+ exports.SelectField = SelectField;
3531
+ exports.Snackbar = Snackbar;
3532
+ exports.Tag = Tag;
3533
+ exports.TimePicker = TimePicker;
3534
+ exports.ToggleButtonGroup = ToggleButtonGroup;
3535
+ exports.TooltipData = TooltipData;
3536
+ exports.UploadField = UploadField;
3537
+ exports.UploadFieldBase = UploadFieldBase;
3538
+ exports.copyString = copyString;
3539
+ exports.dialogDimensionsBySize = dialogDimensionsBySize;
3540
+ exports.useCopyValue = useCopyValue;