@carto/meridian-ds 1.4.3-alpha-codemirror.5 → 1.4.3-alpha-codemirror.6

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