@australiangreens/ag-internal-components 0.5.0 → 0.6.0

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.
@@ -1,2 +1,2 @@
1
- "use strict";var Xe=Object.defineProperty,Qe=Object.defineProperties;var Je=Object.getOwnPropertyDescriptors;var te=Object.getOwnPropertySymbols;var xe=Object.prototype.hasOwnProperty,me=Object.prototype.propertyIsEnumerable;var re=(e,o,n)=>o in e?Xe(e,o,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[o]=n,c=(e,o)=>{for(var n in o||(o={}))xe.call(o,n)&&re(e,n,o[n]);if(te)for(var n of te(o))me.call(o,n)&&re(e,n,o[n]);return e},w=(e,o)=>Qe(e,Je(o));var X=(e,o)=>{var n={};for(var r in e)xe.call(e,r)&&o.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&te)for(var r of te(e))o.indexOf(r)<0&&me.call(e,r)&&(n[r]=e[r]);return n};var ge=(e,o,n)=>re(e,typeof o!="symbol"?o+"":o,n);var N=(e,o,n)=>new Promise((r,s)=>{var l=d=>{try{a(n.next(d))}catch(p){s(p)}},u=d=>{try{a(n.throw(d))}catch(p){s(p)}},a=d=>d.done?r(d.value):Promise.resolve(d.value).then(l,u);a((n=n.apply(e,o)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),_=require("react"),i=require("@mui/material"),J=require("@mui/icons-material"),Fe=require("@tanstack/react-query"),Ze=require("autosuggest-highlight/match"),et=require("autosuggest-highlight/parse"),le=require("@auth0/auth0-react"),tt=require("buffer"),ot=require("@mui/material/Skeleton"),T=require("jotai"),ie=require("react-router"),nt=require("@mui/material/Stack"),rt=require("@mui/x-data-grid"),it=require("souvlaki"),st=require("@mui/material/CssBaseline"),at=require("@mui/material/Box"),lt=require("jotai/utils"),H=require("@mui/material/styles"),ct=require("react-avatar"),U=e=>e&&e.__esModule?e:{default:e},dt=U(Ze),ut=U(et),pt=U(ot),Ae=U(nt),ht=U(st),Se=U(at),Ce=U(ct);function ft({text:e}){const[o,n]=_.useState(0);return t.jsxs(t.Fragment,{children:[t.jsx(i.Typography,{variant:"h6",color:"inherit",component:"div",sx:{fontSize:"22px"},children:"Hello world"}),t.jsx(i.Typography,{variant:"caption",display:"block",children:t.jsx("span",{children:"Just ensuring MUI is working as planned as a peer dependency. v0.0.11"})}),t.jsx(i.Button,{variant:"outlined",onClick:()=>n(r=>r+1),"aria-label":"Increment",children:"Hello I am a button"}),t.jsxs("p",{children:["This is some text: ",t.jsx("span",{children:e})]}),t.jsxs(i.Paper,{children:["This number will incremember when button pressed: ",o]})]})}const ce=({isOpen:e,dialogTitle:o,children:n,maxWidth:r,primaryButton:s,secondaryButton:l,additionalButtons:u,onClose:a,sx:d,"data-testid":p,disableCloseOnBackdropOrEscape:m=!1,isLoading:f=!1})=>{var S,y;const[C,g]=_.useState(!1);return t.jsxs(i.Dialog,{open:e,onClose:(x,j)=>N(null,null,function*(){m&&(j==="backdropClick"||j==="escapeKeyDown")||C||(l!=null&&l.onClick?yield l.onClick():a())}),fullWidth:!0,maxWidth:r!=null?r:"xs","data-testid":p,sx:d,children:[f&&t.jsx(i.LinearProgress,{sx:{height:"4px",marginBottom:"-4px"}}),t.jsx(i.DialogTitle,{children:o}),t.jsx(i.DialogContent,{sx:{"& > :last-child":{marginBottom:0}},children:n}),t.jsxs(i.DialogActions,{children:[t.jsx(i.Button,{onClick:(S=l==null?void 0:l.onClick)!=null?S:a,"data-testid":l==null?void 0:l.testId,disabled:(l==null?void 0:l.disabled)||C,color:l==null?void 0:l.buttonColor,children:(y=l==null?void 0:l.text)!=null?y:"Cancel"}),u&&u.map((x,j)=>{var k;return t.jsx(i.Button,{onClick:x==null?void 0:x.onClick,"data-testid":x==null?void 0:x.testId,disabled:(x==null?void 0:x.disabled)||C,color:x==null?void 0:x.buttonColor,children:(k=x.text)!=null?k:`Button ${j}`},j)}),s&&t.jsx(i.Button,{onClick:()=>N(null,null,function*(){var x;g(!0),yield(x=s.onClick)==null?void 0:x.call(s),g(!1)}),"data-testid":s.testId,disabled:s.disabled||C,color:s==null?void 0:s.buttonColor,children:s.text})]})]})},xt={popper:{modifiers:[{name:"offset",options:{offset:[115,-15]}}]}},Pe={right:2},de=({minLength:e,preLoadedOptions:o,lookup:n,label:r,inputValue:s})=>Fe.useQuery({queryFn:()=>e&&s.length<e?o!=null?o:[]:o?o.filter(l=>l.label.toLowerCase().includes(s.toLowerCase())):n(s),queryKey:["autocomplete",r,s]});function mt({lookup:e=()=>N(null,null,function*(){}),enableHighlighting:o=!0,onChange:n,onInputChange:r,minLength:s=0,label:l,value:u,"data-testid":a,sx:d,boxSx:p,textFieldColor:m,textFieldVariant:f="filled",textFieldFocused:C,textFieldSx:g,loadingText:S="Loading...",noOptionsText:y="No options",popupIcon:x=t.jsx(J.ArrowDropDown,{}),error:j=!1,helperText:k="",preLoadedOptions:F=void 0,disablePortal:M=!1,disableIconFlip:v=!1,chipToolTipSlotProps:P=xt,placeholderText:I=void 0,onRightClick:G=()=>{},disableDefaultRightClickBehaviour:R=!1,readOnly:O,hideInputEndAdornment:D}){const[b,$]=_.useState(""),W=(h,E)=>{const L=u.filter(V=>V.id!==E);n(L,"delete",h)},{data:A,isLoading:B}=de({inputValue:b,label:l,lookup:e,minLength:s,preLoadedOptions:F}),q=b.length>=s;return t.jsxs("div",{"data-testid":a,children:[t.jsx(i.Autocomplete,{sx:c(c({},d),v?{".MuiAutocomplete-popupIndicatorOpen":{transform:"rotate(0deg)"}}:{}),"data-testid":a?`${a}:Autocomplete`:void 0,disablePortal:M,multiple:!0,getOptionLabel:h=>typeof h=="string"?h:h.label,loading:q?B:!1,options:[...u,...A!=null?A:[]],filterSelectedOptions:!0,includeInputInList:!0,value:u,onChange:(h,E,L)=>{n(E,L,h)},onInputChange:(h,E,L)=>{$(E),r&&r(u,L,h)},noOptionsText:q?y:"Start typing to search",loadingText:S,popupIcon:x,renderInput:h=>t.jsx(i.TextField,w(c({},h),{label:l,fullWidth:!0,variant:f,error:j,helperText:k,autoComplete:"off",slotProps:{input:w(c({},h.InputProps),{endAdornment:D?void 0:t.jsxs(t.Fragment,{children:[B?t.jsx(i.CircularProgress,{color:"inherit",size:20}):null,h.InputProps.endAdornment]})})},"data-testid":a?`${a}:Autocomplete:TextField`:void 0,onKeyDown:E=>{(E.key==="Backspace"||E.key==="Delete")&&E.stopPropagation()},color:m,placeholder:I,sx:g,focused:C})),renderValue:()=>null,isOptionEqualToValue:(h,E)=>h.id===E.id,renderOption:(h,E,L)=>{if(o){const V=dt.default(E.label,L.inputValue,{insideWords:!0,findAllOccurrences:!0}),Z=ut.default(E.label,V);return _.createElement("li",w(c({},h),{key:E.id,"data-testid":a?`${a}:Autocomplete:option(${E.id.toString()})`:void 0}),t.jsx("div",{children:Z.map((K,ee)=>t.jsx("span",{style:{fontWeight:K.highlight?700:400},children:K.text},ee))}))}else return _.createElement("li",w(c({},h),{key:E.id,"data-testid":a?`${a}:option(${E.id.toString()})`:void 0}),E.label)},onMouseDownCapture:h=>{h.button===Pe.right&&R&&(h.preventDefault(),h.stopPropagation())},onContextMenuCapture:h=>{R&&(h.preventDefault(),h.stopPropagation()),G(h)},readOnly:O}),u.length>0&&t.jsx(i.Box,{sx:p,children:u.map(h=>{var E;return t.jsx(i.Chip,{sx:{marginTop:1,marginRight:1,height:"auto"},label:t.jsx(i.Tooltip,{title:(E=h.tooltipContent)!=null?E:"",placement:"bottom-start",slotProps:P,children:t.jsx(i.Typography,{style:{whiteSpace:"normal"},children:h.chipLabel?h.chipLabel:h.label})}),"data-testid":a?`${a}:Chip(${h.id.toString()})`:void 0,onDelete:L=>W(L,h.id),deleteIcon:t.jsx(J.Cancel,{"data-testid":a?`${a}:Chip(${h.id.toString()}):deleteIcon`:void 0})},h.id)})})]})}const gt=/MUI: The value provided to.*is invalid/i,At=({lookup:e=()=>N(null,null,function*(){}),onChange:o,onInputChange:n,label:r,value:s,sx:l,textFieldColor:u,textFieldVariant:a="filled",textFieldFocused:d,textFieldSx:p,error:m=!1,"data-testid":f,loadingText:C="Loading...",noOptionsText:g="No options",minLength:S=3,disablePortal:y=!1,preLoadedOptions:x,helperText:j="",disabled:k,popupIcon:F,disableIconFlip:M,placeholderText:v=void 0,onRightClick:P=()=>{},disableDefaultRightClickBehaviour:I=!1,readOnly:G,hideInputEndAdornment:R})=>{const[O,D]=_.useState(""),{data:b,isLoading:$}=de({inputValue:O,label:r,lookup:e,minLength:S!=null?S:0,preLoadedOptions:x}),W=O.length>=S;return t.jsx("div",{"data-testid":f,children:t.jsx(i.Stack,{direction:"row",spacing:1,onMouseDownCapture:A=>{A.button===Pe.right&&I&&(A.preventDefault(),A.stopPropagation())},onContextMenuCapture:A=>{I&&(A.preventDefault(),A.stopPropagation()),P(A)},children:t.jsx(i.Autocomplete,{sx:c(c({},l),M?{".MuiAutocomplete-popupIndicatorOpen":{transform:"rotate(0deg)"}}:{}),"data-testid":f?`${f}:Autocomplete`:void 0,loading:W?$:!1,options:b!=null?b:[],onChange:(A,B,q)=>{o(A,B,q)},disablePortal:y,filterOptions:A=>A,value:s,noOptionsText:W?g:"Start typing to search",loadingText:C,getOptionLabel:A=>A.label,popupIcon:F,renderInput:A=>t.jsx(i.TextField,w(c({"data-testid":f?`${f}:Autocomplete:TextField`:void 0},A),{variant:a,label:r,color:u,error:m,helperText:j,autoComplete:"off",slotProps:{input:w(c({},A.InputProps),{endAdornment:R?void 0:t.jsxs(t.Fragment,{children:[$?t.jsx(i.CircularProgress,{color:"inherit",size:20}):null,A.InputProps.endAdornment]})})},placeholder:v,sx:p,focused:d})),isOptionEqualToValue:(A,B)=>A.id===B.id,onInputChange:(A,B,q)=>{D(B),n&&n(B,q,A)},renderOption:(A,B)=>_.createElement("li",w(c({},A),{key:B.id,"data-testid":f?`${f}:Autocomplete:option(${B.id.toString()})`:void 0}),B.label),disabled:k,readOnly:G})})})},Be=e=>{if(!e)return-1;try{const n=e.split(".")[1].replace(/-/g,"+").replace(/_/g,"/"),r=decodeURIComponent(tt.Buffer.from(n,"base64").toString("utf8").split("").map(function(l){return"%"+("00"+l.charCodeAt(0).toString(16)).slice(-2)}).join("")),s=JSON.parse(r);return s!=null&&s.exp?s.exp:-1}catch(o){return-1}},St=({open:e=!1,closeHandler:o,setAuth0ExpiryTime:n})=>{const{logout:r,getAccessTokenSilently:s}=le.useAuth0(),l=()=>N(null,null,function*(){r({logoutParams:{returnTo:`${window.location.origin}`}})}),a={text:"Continue",onClick:()=>N(null,null,function*(){const p=yield s({cacheMode:"off"}),m=Be(p)*1e3;n(m),o()}),disabled:!1,testId:"PreferencesDialog",buttonColor:"secondary"},d={text:"Log out",onClick:l,disabled:!1,testId:"PreferencesDialog",buttonColor:"secondary"};return t.jsx(ce,{isOpen:e,primaryButton:a,secondaryButton:d,onClose:o,dialogTitle:"Session expiry",disableCloseOnBackdropOrEscape:!0,children:t.jsx("p",{style:{marginBottom:0},children:"Your session is about to time out due to inactivity. Do you want to continue?"})})};function Ct(e){return"error"in e}function yt(e){var r;const o=e.error,n=(r=e==null?void 0:e.error_description)!=null?r:"";return o==="access_denied"&&n.startsWith("You do not have the required authorization")}function jt(e){var r;const o=e.error,n=(r=e==null?void 0:e.error_description)!=null?r:"";return o==="access_denied"&&n.startsWith("User did not authorize the request")}function vt(e){var r;const o=e.error,n=(r=e==null?void 0:e.error_description)!=null?r:"";return o==="access_denied"&&n.match(/Script.*time.*exceeded/)}function Dt({children:e,appName:o="the app",throwErrors:n="none",disableConsoleLogging:r=!1,onError:s=()=>{}}){var f,C;const{isAuthenticated:l,isLoading:u,error:a,loginWithRedirect:d,logout:p}=le.useAuth0();_.useEffect(()=>{a&&s(a)},[a,s]);const m=_.useMemo(()=>({appState:{returnTo:`${window.location.pathname}${window.location.search}`}}),[]);if(_.useEffect(()=>{u||l||a||d(m)},[u,l,a,d,s,m]),a){if(r||console.error(`Error detected in AuthGuard [isAuthenticated=${l},isLoading=${u}]`,a),n==="all")throw a;if(Ct(a)){let g="Auth error",S="An unknown Auth0 error occurred.";if(yt(a))g="Unauthorised",S=`You are not authorised to access ${o}.`;else if(jt(a))g="App not authorised",S=`You have not authorised ${o} to access your user profile. This is necessary to use ${o}.`;else if(vt(a))g="Auth0 script execution time exceeded",S="The Auth0 login flow exceeded the time limit (20s). Try again in a minute by clicking the RELOAD button below.";else if(a.message==="Invalid state"){const y=localStorage.getItem("auth0_redirect_count");y?y&&parseInt(y)<2&&(localStorage.setItem("auth0_redirect_count",String(parseInt(y)+1)),d(m)):(localStorage.setItem("auth0_redirect_count","1"),d(m))}else if(n==="unknown")throw a;return t.jsxs(i.Dialog,{open:!0,children:[t.jsx(i.DialogTitle,{children:g}),t.jsxs(i.DialogContent,{children:[t.jsx(i.Typography,{children:S}),t.jsx("br",{}),t.jsx(i.Typography,{variant:"subtitle2",children:"Details from Auth0"}),t.jsxs(i.Typography,{variant:"body2",children:["error: ",(f=a==null?void 0:a.error)!=null?f:"N/A"]}),t.jsxs(i.Typography,{variant:"body2",children:["description: ",(C=a==null?void 0:a.error_description)!=null?C:"N/A"]})]}),t.jsxs(i.DialogActions,{children:[g==="Auth0 script execution time exceeded"&&t.jsx(i.Button,{href:window.location.origin+window.location.pathname,children:"Reload"}),t.jsx(i.Button,{onClick:()=>p({logoutParams:{returnTo:window.location.origin}}),children:"Logout"})]})]})}else if(n==="unknown")throw a}return l?(localStorage.removeItem("auth0_redirect_count"),t.jsx(t.Fragment,{children:e})):t.jsx(pt.default,{variant:"rectangular",animation:"pulse",height:"100vh",width:"100vw"})}const ue=()=>{const e=i.useTheme();return i.useMediaQuery(e.breakpoints.down("sm"))},bt=64,Et=72,wt=256,Y=T.atom(!0),Le=T.atom(wt),Oe=T.atom(Et),se=T.atom(""),Ne=T.atom(void 0),Me=T.atom(bt),Ie=T.atom(void 0),Re=({label:e,to:o,icon:n,subMenu:r,subMenuInitialOpen:s,onClick:l,closeOnSmallScreen:u,disabled:a=!1,openInNewWindow:d=!1,extraSubIndentSpace:p=0,tooltip:m="",tooltipMenuOpen:f="",tooltipMenuClosed:C=""})=>{const[g,S]=_.useState(s),[y,x]=T.useAtom(Y),{pathname:j}=ie.useLocation(),k=ue(),F="  ".repeat(p),M=d?{rel:"noopener noreferrer",target:"_blank"}:{};return t.jsxs(t.Fragment,{children:[t.jsx(i.Tooltip,{title:m||(f&&y?f:C&&!y?C:""),arrow:!0,placement:"right",children:t.jsxs(i.ListItemButton,w(c({component:o?ie.Link:"button",sx:{width:"100%"},to:o,onClick:()=>{l==null||l(),y?(S(v=>!v),u&&k&&x(!1)):r&&(S(!0),x(!0))},"aria-label":e,selected:j===o,disabled:a},M),{children:[t.jsx(i.ListItemIcon,{sx:{padding:"8px"},children:n}),t.jsx(i.Fade,{in:y,unmountOnExit:!0,children:t.jsxs(i.Box,{children:[t.jsx(i.ListItemText,{primary:e}),r&&t.jsx(i.ListItemSecondaryAction,{children:g?t.jsx(J.ExpandLess,{}):t.jsx(J.ExpandMore,{})})]})})]}))}),r&&t.jsx(i.Collapse,{in:g&&y,timeout:"auto",unmountOnExit:!0,children:t.jsx(i.List,{component:"div",disablePadding:!0,children:r.map(v=>t.jsx(i.ListItemButton,{onClick:()=>{v.onClick&&(v==null||v.onClick()),y&&v!=null&&v.closeOnSmallScreen&&k&&x(!1)},to:v.to,component:v.to?ie.Link:"button",sx:{width:"100%"},selected:j===v.to,disabled:v.disabled,children:t.jsx(i.ListItemText,{primary:F+v.label,inset:!0,slotProps:{primary:{variant:"body2"}}})},v.label))})})]})},_t=n=>{var r=n,{subMenuInitialOpen:e}=r,o=X(r,["subMenuInitialOpen"]);const s=e===void 0?"initial-undefined":String(e);return t.jsx(Re,c({subMenuInitialOpen:e},o),s)},Tt=.11,ae=10,kt=40,Ft={marginLeft:"3px",marginRight:"3px",borderRadius:2},ye={display:"flex",flexDirection:"row"},Pt={},Bt=(e,o,n,r)=>{const s=`rgba(0, 0, 0, ${Tt*((ae-e)/ae)})`;return t.jsx(t.Fragment,{children:o.map((l,u)=>t.jsx(i.Skeleton,{variant:"rectangular",height:n,sx:c({bgcolor:s,flex:l,marginTop:-1,marginBottom:-1},r)},u))})},$e=({numberOfRows:e,firstRowStyle:o=Pt,rowHeight:n=kt,columnWidths:r,columnStyles:s=Ft})=>{const l=Array(Math.min(e,ae)).fill(1);return t.jsx(i.Box,{sx:{display:"flex",flexDirection:"column"},children:l.map((u,a)=>{const d=a===0?c(c({},ye),o):ye;return t.jsx("p",{style:d,children:Bt(a,r,n,s)},a)})})},Lt={name:"shiftDataGridPanelAboveColumnHeaders",enabled:!0,phase:"main",requires:["popperOffsets"],fn({state:e}){const o=e.elements.reference;if(!(o instanceof HTMLElement))return;const n=o.closest(".MuiDataGrid-root");if(!n)return;const r=n.querySelector(".MuiDataGrid-columnHeaders"),s=o.getBoundingClientRect();let u=o.getAttribute("data-id")==="gridPanelAnchor";if(!u&&r instanceof HTMLElement){const C=r.getBoundingClientRect().bottom;u=s.top>=C-1}if(!u)return;const a=getComputedStyle(n).getPropertyValue("--DataGrid-headersTotalHeight").trim(),d=parseFloat(a),m=(Number.isFinite(d)&&d>0?d:56)+8,f=e.modifiersData.popperOffsets;f&&(f.y-=m)}},Ot=111,Nt={backgroundColor:"white","&.MuiDataGrid-root .MuiDataGrid-cell:focus":{outline:"none"},"&.MuiDataGrid-root .MuiDataGrid-columnHeader:focus":{outline:"none"},"&.MuiDataGrid-root .MuiDataGrid-cell:focus-within":{outline:"none"},"&.MuiDataGrid-root .MuiDataGrid-columnHeader:focus-within":{outline:"none"}},Mt=process.env.NODE_ENV==="test",It=k=>{var F=k,{loading:e,skeletonColumnWidths:o,paginationModel:n,onPaginationModelChange:r,autoTableHeight:s=!1,noRowsMessage:l="No rows",noResultsMessage:u="No results",rowHeight:a=52,paginationMode:d="client",filterMode:p="client",pageSizeOptions:m=[5,10,25,50,100],rows:f,sx:C,"aria-label":g,"aria-labelledby":S,"aria-describedby":y,slotProps:x}=F,j=X(F,["loading","skeletonColumnWidths","paginationModel","onPaginationModelChange","autoTableHeight","noRowsMessage","noResultsMessage","rowHeight","paginationMode","filterMode","pageSizeOptions","rows","sx","aria-label","aria-labelledby","aria-describedby","slotProps"]);var L,V,Z,K;const E=x!=null?x:{},{main:M}=E,v=X(E,["main"]),P=(L=v.panel)!=null?L:{},[I,G]=_.useState(n),R=r!==void 0,O=R?n:I,{pageSize:D}=O,b=Ot+D*a,$=s&&f&&f.length!==0&&O.page!==Math.floor(f.length/D),W=ee=>{R?r==null||r(ee):G(ee)},A=()=>t.jsx($e,{numberOfRows:D,columnWidths:o}),B=()=>t.jsx(Ae.default,{height:"100%",alignItems:"center",justifyContent:"center",children:e?"":l}),q=()=>t.jsx(Ae.default,{height:"100%",alignItems:"center",justifyContent:"center",children:e?"":u}),h=i.useTheme();return t.jsx(i.Box,{height:$?"auto":b,width:"100%",children:t.jsx(rt.DataGrid,c({slots:{loadingOverlay:A,noRowsOverlay:B,noResultsOverlay:q},slotProps:w(c({},v),{panel:w(c({},P),{placement:(V=P.placement)!=null?V:"top-end",popperOptions:w(c({},P.popperOptions),{modifiers:[Lt,...(K=(Z=P.popperOptions)==null?void 0:Z.modifiers)!=null?K:[]]})}),filterPanel:c({filterFormProps:{columnInputProps:{"aria-label":"Filter by column"},operatorInputProps:{"aria-label":"Filter operator"},valueInputProps:{"aria-label":"Filter value"}}},v.filterPanel),main:c(c(c(c({},M),g!=null?{"aria-label":g}:{}),S!=null?{"aria-labelledby":S}:{}),y!=null?{"aria-describedby":y}:{})}),disableRowSelectionOnClick:!0,rowHeight:a,autoHeight:$,sx:w(c(c({},Nt),C),{"&.MuiDataGrid-root .Mui-selected":{backgroundColor:`${h.palette.secondary.main}15`,"&:hover":{backgroundColor:`${h.palette.secondary.main}1E`}}}),disableVirtualization:Mt,loading:e,rows:f,paginationModel:O,onPaginationModelChange:W,paginationMode:d,filterMode:p,pageSizeOptions:m},j))})},Rt={autoHideDuration:6e3,anchorOrigin:{vertical:"top",horizontal:"center"},disableWindowBlurListener:!1},$t={shouldClose:(e,o)=>o!=="clickaway"},je={message:"",severity:"info",variant:"standard",progressIndicator:void 0},ve=100,De=2e3,qt=2e3,Gt=(()=>{let e=0;return()=>(e+=1,e)})(),Ht={borderBottomLeftRadius:"0px",borderBottomRightRadius:"0px"},Ut={},Wt={},pe=_.createContext(null);function qe(l){var u=l,{overrideState:e=Ut,overrideActions:o=Wt,shouldClose:n=$t.shouldClose,children:r}=u,s=X(u,["overrideState","overrideActions","shouldClose","children"]);var O;const[{open:a},d]=_.useState({open:!1}),p=_.useRef([]),m=_.useRef(Date.now()),f=_.useRef(0),C=_.useCallback(D=>{d({open:D})},[]),g=_.useCallback((D={})=>{f.current+=1,p.current.length>=ve&&Date.now()-m.current>=De&&(m.current=Date.now(),console.error(`SaladBarProvider: MAX_QUEUE_LENGTH (${ve}) hit ${f.current} times in last ${De}ms)`),f.current=0);const b=c(w(c({},je),{key:Gt()}),D);return p.current.push(b),p.current.length===1&&d({open:!0}),b.key},[]),S=(D="",b={})=>g(c({message:D,severity:"success"},b)),y=(D="",b={})=>g(c({message:D,severity:"info"},b)),x=(D="",b={})=>g(c({message:D,severity:"warning"},b)),j=(D="",b={})=>g(c({message:D,severity:"error"},b)),k=D=>{const b=p.current.findIndex($=>$.key===D);if(b!==-1)return b===0?(d({open:!1}),p.current[0]):p.current.splice(b,1)},F=(D,b)=>{n(D,b)&&d({open:!1})},M=()=>{},v=()=>{p.current.shift(),p.current.length>0&&d({open:!0})},P=(O=p.current[0])!=null?O:c({},je),I={};"autoHideDuration"in P&&(I.autoHideDuration=P.autoHideDuration);const G=c(c({},Rt),s),R=c(c({open:a,setOpen:C,enqueueNotification:g,enqueueSuccessNotification:S,enqueueInfoNotification:y,enqueueWarningNotification:x,enqueueErrorNotification:j,removeNotification:k},e),o);return t.jsxs(pe.Provider,{value:R,children:[r,t.jsx(i.Snackbar,w(c(c({},G),I),{open:a,onClose:F,TransitionProps:{onExited:v,onExit:M},sx:{zIndex:qt},children:t.jsxs("div",{children:[t.jsx(i.Alert,{onClose:D=>F(D,"closeAlert"),severity:P.severity,variant:"filled",icon:P.progressIndicator==="circular"?t.jsx(i.CircularProgress,{size:"1em"}):void 0,style:P.progressIndicator==="linear"?Ht:void 0,children:P.message}),P.progressIndicator==="linear"&&t.jsx(i.LinearProgress,{color:"primary"})]})}))]})}class he extends Error{}ge(he,"errorName","ContextError");function Ge(){const e=_.useContext(pe);if(e===null)throw new he("Error: Tried to useSaladBar outside of a <SaladBarProvider>");return e}const Vt=it.createHelper((e={autoHideDuration:1},o={},n={})=>({children:r})=>t.jsx(qe,w(c({},e),{overrideState:o,overrideActions:n,children:t.jsx(t.Fragment,{children:r})}))),He={act:"ACT",nsw:"NSW",nt:"NT",qld:"QLD",sa:"SA",tas:"TAS",vic:"VIC",wa:"WA",ag:"AG",fedmps:"FedMPs","":""},Ue="domainCode";var ke;const be=T.atom(JSON.parse((ke=localStorage.getItem(Ue))!=null?ke:'{"domainCode": ""}').domainCode),We=T.atom(e=>e(be),(e,o,n)=>{o(be,n),localStorage.setItem(Ue,JSON.stringify({domainCode:n}))}),fe=e=>{var o;return e===null?"N/A":(o=He[e])!=null?o:""},zt=({isLoading:e,isOpen:o,onClose:n,onDomainChange:r,domainOptions:s,applicationName:l,handleLogout:u})=>{const[a,d]=T.useAtom(We),[p,m]=_.useState(a),{enqueueSuccessNotification:f}=Ge(),C=s.length===0,g=!!a&&!s.includes(a)&&!s.includes(p),S=!a||C||g,y=()=>N(null,null,function*(){p?(d(p),r==null||r(p),f(`Set organisation to ${p}`),n()):(d(""),r==null||r(""))}),x=()=>N(null,null,function*(){a&&!C&&!g?(m(a),n()):S&&u()});let j;return C?j="Unable to retrieve your active organisations. Try logging in again.":g&&(j="You no longer have any roles in your chosen organisation. Please choose another."),t.jsxs(ce,{isOpen:o,dialogTitle:"Select an organisation",primaryButton:{text:"Confirm",onClick:y,disabled:!p||C||g,buttonColor:"primary"},secondaryButton:{text:S?"Logout":"Cancel",onClick:x},onClose:S?()=>{}:n,children:[t.jsxs(i.Typography,{marginBottom:2,children:["Select the default organisation that you want to use with the ",l,"."]}),t.jsx(i.Autocomplete,{loading:e,multiple:!1,disableClearable:!1,value:p!==""?p:null,onChange:(k,F)=>m(F!=null?F:""),getOptionLabel:fe,options:[...s.toSorted()],renderInput:k=>t.jsx(i.TextField,w(c({},k),{variant:"filled",label:"Select organisation",InputProps:w(c({},k.InputProps),{endAdornment:t.jsxs(t.Fragment,{children:[e?t.jsx(i.CircularProgress,{color:"inherit",size:20,sx:{marginTop:"-20px"}}):null,k.InputProps.endAdornment]})})}))}),j&&t.jsx(i.FormHelperText,{error:!0,children:j})]})};function Yt({links:e}){return t.jsx("div",{children:"LinksMenu not implemented yet"})}const oe="Navbar",Q={root:`${oe}-root`,menuButton:`${oe}-menuButton`,hide:`${oe}-hide`,content:`${oe}-content`},Kt=H.styled(i.Box,{name:"NavBar"})(({theme:e})=>({[`&.${Q.root}`]:{display:"flex"},[`& .${Q.menuButton}`]:{marginRight:36},[`& .${Q.hide}`]:{display:"none"},[`& .${Q.content}`]:{flexGrow:1,padding:e.spacing(3)}})),z=(e,o,n)=>e.transitions.create(o,{easing:e.transitions.easing.sharp,duration:n==="leaving"?e.transitions.duration.leavingScreen:e.transitions.duration.enteringScreen}),Xt=e=>{const o=i.useTheme();return t.jsx(i.Collapse,c({easing:o.transitions.easing.sharp,timeout:{enter:o.transitions.duration.enteringScreen,exit:o.transitions.duration.leavingScreen}},e))},Ve=e=>{var o,n;return{overflowX:"hidden",color:"inherit",backgroundColor:(n=(o=e==null?void 0:e.navBar)==null?void 0:o.backgroundColor)!=null?n:"white"}},Ee=(e,o)=>c({width:o,transition:z(e,"width","entering")},Ve(e)),we=(e,o)=>c({width:o,transition:z(e,"width","leaving")},Ve(e)),Qt=H.styled(i.Drawer,{shouldForwardProp:e=>!["widthOpen","widthClosed","isSmallScreen"].includes(e)})(({theme:e,open:o,widthOpen:n,widthClosed:r,isSmallScreen:s})=>c(c({flexShrink:0,whiteSpace:"nowrap",boxSizing:"border-box",display:"flex",flexDirection:"column"},o&&w(c({},Ee(e,n)),{backgroundColor:"","& .MuiDrawer-paper":Ee(e,n)})),!o&&w(c({},we(e,s?n:r)),{backgroundColor:"","& .MuiDrawer-paper":we(e,s?n:r)})));function ze(e){return e.replace(/(^|-)([a-z])/g,(o,n,r)=>n==="-"?" "+r.toUpperCase():r.toUpperCase())}function Jt(e,o,n,r){var u;if(!e)return"None";const s=e["https://greens.org.au/roles"];if(!s)return"None";const l=Object.entries(s).filter(([,a])=>a.includes(o)).map(([a])=>ze(a));return(u=r.find(a=>n[a].some(d=>l.includes(d))))!=null?u:"None"}function Ye(e,o){return Object.entries(e).reduce((n,[r,s])=>{const l=ze(r),u=o.includes(l)?s:[];return[...new Set([...n,...u])]},[])}const Zt=e=>{const{getIdTokenClaims:o,user:n}=le.useAuth0();return Fe.useQuery({queryKey:["availableDomains",n==null?void 0:n.sub],queryFn:()=>N(null,null,function*(){const r=yield o();if(!r)return[];const s=r["https://greens.org.au/roles"];return s?Ye(s,e):[]})})},eo=e=>Object.values(e).reduce((o,n)=>[...new Set([...o,...n])],[]),ne={log:console.warn.bind(console),error:console.error.bind(console),warn:console.warn.bind(console),info:console.info.bind(console),debug:console.debug.bind(console)};function to(e,o){console[e]=(...n)=>{for(const r of o)if(typeof r=="function"){if(r(...n))return}else if(r instanceof RegExp&&n.length>0){for(const s of n)if(typeof s=="string"&&r.test(s))return}ne[e](n)}}function oo(e){if(e)console[e]=ne[e];else for(const o of Object.keys(ne))console[o]=ne[o]}function no(e,o){return e!=null&&typeof e=="object"&&"error"in e&&e.error===o}function ro(e,o){const n=o==null?void 0:o.originalException;return no(n,"login_required")?null:e}function Ke(e){let o=0;for(let n=0,r=e.length;n<r;n++){const s=e.charCodeAt(n);o=(o<<5)-o+s,o|=0}return o}const _e=["#A62A21","#7e3794","#0B51C1","#3A6024","#A81563","#B3003C"],Te=e=>e.split(/\s/).map(o=>o.substring(0,1).toUpperCase()).filter(o=>!!o).slice(0,2).join("").toUpperCase();function io({user:e,domainCode:o,open:n,useNewAvatar:r=!1}){const s=i.useTheme();return t.jsxs(i.Box,{sx:{paddingTop:3,display:"flex",alignItems:"center",flexDirection:"column",gap:"0.5rem"},children:[!r&&t.jsx(i.Box,{sx:{width:n?"5rem":"2rem",transition:n?z(s,["width","height"],"entering"):z(s,["width","height"],"leaving"),aspectRatio:1},children:e!=null&&e.name?t.jsx(t.Fragment,{children:t.jsx(i.Avatar,{src:e==null?void 0:e.picture,sx:{width:"100%",height:"100%",bgcolor:_e[Math.abs(Ke(e==null?void 0:e.name))%_e.length]},children:Te(e==null?void 0:e.name)})}):t.jsx(i.Avatar,{sx:{width:"100%",height:"100%"}})}),r&&t.jsx(i.Box,{sx:{width:n?"5rem":"2rem",transition:n?z(s,["width","height"],"entering"):z(s,["width","height"],"leaving"),aspectRatio:1},children:e!=null&&e.name?t.jsx(t.Fragment,{children:t.jsxs(Ce.default,{src:e==null?void 0:e.picture,name:e==null?void 0:e.name,round:!0,size:n?"80":"32",children:[" ",Te(e==null?void 0:e.name)," ","ab"]})}):t.jsx(Ce.default,{})}),t.jsx(Xt,{sx:{width:"100%"},in:n,children:t.jsx(i.Fade,{in:n,children:t.jsxs(i.Box,{width:"100%",display:"flex",flexDirection:"column",alignItems:"center",children:[e!=null&&e.name?t.jsx(i.Typography,{children:e==null?void 0:e.name}):t.jsx(i.Skeleton,{animation:!1,width:"50%"}),o?t.jsx(i.Typography,{children:fe(o)}):t.jsx(i.Skeleton,{animation:!1,width:"25%"})]})})})]})}function so({open:e,widthClosed:o,widthOpen:n,"data-testid":r,top:s,middle:l,bottom:u,user:a,domainCode:d,useNewAvatar:p=!1}){const m=ue(),f=T.useSetAtom(Y);return t.jsx(Kt,{className:Q.root,"data-testid":r,children:t.jsxs(Qt,{open:e,widthOpen:n,widthClosed:o,anchor:"left",variant:m?"temporary":"permanent",PaperProps:{component:"nav"},onClose:()=>{f(!1)},isSmallScreen:m,children:[!m&&t.jsx(i.Toolbar,{}),s&&t.jsxs(i.Box,{flexGrow:"0",children:[s,t.jsx(i.Divider,{variant:"middle",sx:{marginY:"0.5rem"}})]}),t.jsx(i.Box,{flexGrow:"1",children:Array.isArray(l)?t.jsx(Yt,{links:l}):l}),t.jsxs(i.Box,{flexGrow:"0",children:[t.jsx(i.Divider,{variant:"middle",sx:{marginY:"0.5rem"}}),t.jsx(io,{user:a,domainCode:d,open:e,useNewAvatar:p}),u&&t.jsx(t.Fragment,{children:u})]})]})})}function ao({children:e,topBarHeight:o,maxWidth:n=!1,noPadding:r}){return t.jsx(i.Box,{tabIndex:0,sx:{overflow:"auto",height:`calc(100vh - ${o}px)`,flexGrow:1},children:r?t.jsx(i.Box,{height:"inherit",children:e}):t.jsx(i.Container,{maxWidth:n,sx:{paddingTop:3,paddingBottom:3,flexGrow:1},children:e})})}const lo="TopBar",co={titleText:`${lo}-titleText`};function uo({titleText:e="",height:o,"data-testid":n,middle:r,menuButtonAriaLabel:s="Open navigation menu"}){const l=T.useSetAtom(Y),u=()=>l(p=>!p),a=i.useTheme(),d=ue();return t.jsx("header",{"data-testid":n,children:t.jsxs(i.Paper,{square:!0,elevation:0,sx:{width:"100%",position:"sticky",color:"primary.contrastText",backgroundColor:"primary.main",display:"flex",alignItems:"center",gap:2,flexShrink:0,height:o,zIndex:d?0:a.zIndex.drawer+99},children:[t.jsx(i.IconButton,{size:"medium",color:"inherit",sx:{padding:1.5,marginLeft:"12px"},onClick:u,"aria-label":s,children:t.jsx(J.ViewHeadline,{fontSize:"medium"})}),t.jsx(i.Typography,{className:co.titleText,variant:"h6",component:"h1",children:e}),r]})})}function po({children:e,initialTitleText:o,initialNavBarOpen:n,pageContainerProps:r,pageContentDataTestId:s,topBarDataTestId:l,menuButtonAriaLabel:u,navBarDataTestId:a,navBarMiddle:d,navBarBottom:p,user:m,domainCode:f,useNewAvatar:C=!1}){lt.useHydrateAtoms([[Y,n!=null?n:!0],[se,o!=null?o:""]]);const g=T.useAtomValue(Y),[S]=T.useAtom(Le),[y]=T.useAtom(Oe),x=T.useAtomValue(se),[j]=T.useAtom(Me),[k]=T.useAtom(Ne),[F]=T.useAtom(Ie);return t.jsxs(Se.default,{children:[t.jsx(ht.default,{}),t.jsx(uo,{titleText:x,"data-testid":l,height:j,middle:k,menuButtonAriaLabel:u}),t.jsxs(Se.default,{sx:{display:"flex"},children:[t.jsx(so,{open:g,top:F,middle:d,bottom:p,user:m,domainCode:f,widthOpen:S,widthClosed:y,offsetTop:j,"data-testid":a,useNewAvatar:C}),t.jsx(ao,w(c({"data-testid":s,topBarHeight:j},r),{children:e}))]})]})}const ho=H.createTheme({palette:{primary:{dark:"#00A651",light:"#A3D39C",main:"#007236",contrastText:"#FFF"},warning:{main:"#F5871F",light:"#FCC589",dark:"#A2590A",contrastText:"#FFF"},secondary:{main:"#662D91",light:"#BD8CBF",dark:"#440E62",contrastText:"#FFF"},error:{main:"#D43C95",light:"#8F2064",dark:"#F9CDE0",contrastText:"#FFF"},info:{main:"#00A88D",light:"#ADDCCF",dark:"#005243",contrastText:"#FFF"},success:{main:"#00A651",light:"#A3D39C",dark:"#007236",contrastText:"#FFF"}},typography:{explainer:{fontSize:"14px",marginBlockStart:"1em"}},navBar:{backgroundColor:"#E8E8E8"}}),fo=H.createTheme({palette:{primary:{main:"#007236",dark:"#005221",light:"#00A04E",contrastText:"#FFFFFF"},secondary:{main:"#662D91",dark:"#440E62",light:"#93268F",contrastText:"#FFFFFF"},error:{main:"#D32F2F",dark:"#C62828",light:"#EF5350"},info:{main:"#0288D1",dark:"#01579B",light:"#03A9F4"},success:{main:"#0288D1",dark:"#01579B",light:"#03A9F4"}},components:{MuiTextField:{defaultProps:{color:"secondary"}},MuiToggleButtonGroup:{defaultProps:{color:"secondary"}},MuiCheckbox:{defaultProps:{color:"secondary"}},MuiSelect:{defaultProps:{color:"secondary"}},MuiSwitch:{defaultProps:{color:"secondary"}},MuiFormControl:{defaultProps:{color:"secondary"}},MuiMenuItem:{styleOverrides:{root:({theme:e})=>({"&.Mui-selected":{backgroundColor:H.alpha(e.palette.secondary.main,e.palette.action.selectedOpacity),"&:hover":{backgroundColor:H.alpha(e.palette.secondary.main,e.palette.action.selectedOpacity)},"&.Mui-focusVisible":{backgroundColor:H.alpha(e.palette.secondary.main,e.palette.action.focusOpacity)}}})}}},typography:{h4:{fontSize:"1.88rem",fontWeight:500},h5:{fontWeight:500},explainer:{fontSize:"14px",marginBlockStart:"1em"}},navBar:{backgroundColor:"#E8E8E8"}});exports.AgDataGrid=It;exports.AgDialog=ce;exports.AppLayout=po;exports.AuthGuard=Dt;exports.Context=pe;exports.ContextError=he;exports.DOMAIN_CODE_LABELS=He;exports.DomainCodeDialog=zt;exports.ExampleComponent=ft;exports.FetchAutocomplete=mt;exports.MUI_AUTOCOMPLETE_VALUE_WARNING_REGEX=gt;exports.NavBarLink=_t;exports.NavBarLinkInner=Re;exports.SaladBarProvider=qe;exports.SessionExpiryDialog=St;exports.SingleAutocomplete=At;exports.TableLoadingSkeleton=$e;exports.determineUserLevelFromClaims=Jt;exports.domainCodeAtom=We;exports.fed21Theme=ho;exports.getAuth0Expiry=Be;exports.getDomainOptionLabel=fe;exports.getDomainsFromRolesClaim=Ye;exports.getValidBusinessRoles=eo;exports.internalAgSystemsTheme=fo;exports.navBarOpenAtom=Y;exports.navBarTopAtom=Ie;exports.navBarWidthClosedAtom=Oe;exports.navBarWidthOpenAtom=Le;exports.sentryBeforeSend=ro;exports.simpleHashCode=Ke;exports.suppressConsole=to;exports.titleTextAtom=se;exports.topBarHeightAtom=Me;exports.topBarMiddleAtom=Ne;exports.unsuppressConsole=oo;exports.useAutocompleteOptions=de;exports.useSaladBar=Ge;exports.useValidDomains=Zt;exports.withSaladBarProvider=Vt;
1
+ "use strict";var dt=Object.defineProperty,ut=Object.defineProperties;var pt=Object.getOwnPropertyDescriptors;var te=Object.getOwnPropertySymbols;var je=Object.prototype.hasOwnProperty,De=Object.prototype.propertyIsEnumerable;var ie=(e,o,n)=>o in e?dt(e,o,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[o]=n,c=(e,o)=>{for(var n in o||(o={}))je.call(o,n)&&ie(e,n,o[n]);if(te)for(var n of te(o))De.call(o,n)&&ie(e,n,o[n]);return e},w=(e,o)=>ut(e,pt(o));var X=(e,o)=>{var n={};for(var r in e)je.call(e,r)&&o.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&te)for(var r of te(e))o.indexOf(r)<0&&De.call(e,r)&&(n[r]=e[r]);return n};var Ee=(e,o,n)=>ie(e,typeof o!="symbol"?o+"":o,n);var N=(e,o,n)=>new Promise((r,s)=>{var l=d=>{try{a(n.next(d))}catch(p){s(p)}},u=d=>{try{a(n.throw(d))}catch(p){s(p)}},a=d=>d.done?r(d.value):Promise.resolve(d.value).then(l,u);a((n=n.apply(e,o)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),T=require("react"),i=require("@mui/material"),J=require("@mui/icons-material"),Me=require("@tanstack/react-query"),ht=require("autosuggest-highlight/match"),ft=require("autosuggest-highlight/parse"),ce=require("@auth0/auth0-react"),xt=require("buffer"),mt=require("@mui/material/Skeleton"),k=require("jotai"),se=require("react-router"),gt=require("@mui/material/Stack"),At=require("@mui/x-data-grid"),St=require("souvlaki"),Ct=require("@mui/material/CssBaseline"),yt=require("@mui/material/Box"),vt=require("jotai/utils"),U=require("@mui/material/styles"),jt=require("react-avatar"),q=e=>e&&e.__esModule?e:{default:e},Dt=q(ht),Et=q(ft),bt=q(mt),be=q(gt),_t=q(Ct),_e=q(yt),we=q(jt);function wt({text:e}){const[o,n]=T.useState(0);return t.jsxs(t.Fragment,{children:[t.jsx(i.Typography,{variant:"h6",color:"inherit",component:"div",sx:{fontSize:"22px"},children:"Hello world"}),t.jsx(i.Typography,{variant:"caption",display:"block",children:t.jsx("span",{children:"Just ensuring MUI is working as planned as a peer dependency. v0.0.11"})}),t.jsx(i.Button,{variant:"outlined",onClick:()=>n(r=>r+1),"aria-label":"Increment",children:"Hello I am a button"}),t.jsxs("p",{children:["This is some text: ",t.jsx("span",{children:e})]}),t.jsxs(i.Paper,{children:["This number will incremember when button pressed: ",o]})]})}const de=({isOpen:e,dialogTitle:o,children:n,maxWidth:r,primaryButton:s,secondaryButton:l,additionalButtons:u,onClose:a,sx:d,"data-testid":p,disableCloseOnBackdropOrEscape:m=!1,isLoading:f=!1})=>{var v,A;const[y,g]=T.useState(!1);return t.jsxs(i.Dialog,{open:e,onClose:(x,E)=>N(null,null,function*(){m&&(E==="backdropClick"||E==="escapeKeyDown")||y||(l!=null&&l.onClick?yield l.onClick():a())}),fullWidth:!0,maxWidth:r!=null?r:"xs","data-testid":p,sx:d,children:[f&&t.jsx(i.LinearProgress,{sx:{height:"4px",marginBottom:"-4px"}}),t.jsx(i.DialogTitle,{children:o}),t.jsx(i.DialogContent,{sx:{"& > :last-child":{marginBottom:0}},children:n}),t.jsxs(i.DialogActions,{children:[t.jsx(i.Button,{onClick:(v=l==null?void 0:l.onClick)!=null?v:a,"data-testid":l==null?void 0:l.testId,disabled:(l==null?void 0:l.disabled)||y,color:l==null?void 0:l.buttonColor,children:(A=l==null?void 0:l.text)!=null?A:"Cancel"}),u&&u.map((x,E)=>{var j;return t.jsx(i.Button,{onClick:x==null?void 0:x.onClick,"data-testid":x==null?void 0:x.testId,disabled:(x==null?void 0:x.disabled)||y,color:x==null?void 0:x.buttonColor,children:(j=x.text)!=null?j:`Button ${E}`},E)}),s&&t.jsx(i.Button,{onClick:()=>N(null,null,function*(){var x;g(!0),yield(x=s.onClick)==null?void 0:x.call(s),g(!1)}),"data-testid":s.testId,disabled:s.disabled||y,color:s==null?void 0:s.buttonColor,children:s.text})]})]})},Tt={popper:{modifiers:[{name:"offset",options:{offset:[115,-15]}}]}},Ge={right:2},ue=({minLength:e,preLoadedOptions:o,lookup:n,label:r,inputValue:s})=>Me.useQuery({queryFn:()=>e&&s.length<e?o!=null?o:[]:o?o.filter(l=>l.label.toLowerCase().includes(s.toLowerCase())):n(s),queryKey:["autocomplete",r,s]});function kt({lookup:e=()=>N(null,null,function*(){}),enableHighlighting:o=!0,onChange:n,onInputChange:r,minLength:s=0,label:l,value:u,"data-testid":a,sx:d,boxSx:p,textFieldColor:m,textFieldVariant:f="filled",textFieldFocused:y,textFieldSx:g,loadingText:v="Loading...",noOptionsText:A="No options",popupIcon:x=t.jsx(J.ArrowDropDown,{}),error:E=!1,helperText:j="",preLoadedOptions:F=void 0,disablePortal:O=!1,disableIconFlip:_=!1,chipToolTipSlotProps:L=Tt,placeholderText:I=void 0,onRightClick:W=()=>{},disableDefaultRightClickBehaviour:R=!1,readOnly:M,hideInputEndAdornment:b}){const[C,G]=T.useState(""),z=(h,D)=>{const B=u.filter(V=>V.id!==D);n(B,"delete",h)},{data:S,isLoading:P}=ue({inputValue:C,label:l,lookup:e,minLength:s,preLoadedOptions:F}),H=C.length>=s;return t.jsxs("div",{"data-testid":a,children:[t.jsx(i.Autocomplete,{sx:c(c({},d),_?{".MuiAutocomplete-popupIndicatorOpen":{transform:"rotate(0deg)"}}:{}),"data-testid":a?`${a}:Autocomplete`:void 0,disablePortal:O,multiple:!0,getOptionLabel:h=>typeof h=="string"?h:h.label,loading:H?P:!1,options:[...u,...S!=null?S:[]],filterSelectedOptions:!0,includeInputInList:!0,value:u,onChange:(h,D,B)=>{n(D,B,h)},onInputChange:(h,D,B)=>{G(D),r&&r(u,B,h)},noOptionsText:H?A:"Start typing to search",loadingText:v,popupIcon:x,renderInput:h=>t.jsx(i.TextField,w(c({},h),{label:l,fullWidth:!0,variant:f,error:E,helperText:j,autoComplete:"off",slotProps:{input:w(c({},h.InputProps),{endAdornment:b?void 0:t.jsxs(t.Fragment,{children:[P?t.jsx(i.CircularProgress,{color:"inherit",size:20}):null,h.InputProps.endAdornment]})})},"data-testid":a?`${a}:Autocomplete:TextField`:void 0,onKeyDown:D=>{(D.key==="Backspace"||D.key==="Delete")&&D.stopPropagation()},color:m,placeholder:I,sx:g,focused:y})),renderValue:()=>null,isOptionEqualToValue:(h,D)=>h.id===D.id,renderOption:(h,D,B)=>{if(o){const V=Dt.default(D.label,B.inputValue,{insideWords:!0,findAllOccurrences:!0}),Z=Et.default(D.label,V);return T.createElement("li",w(c({},h),{key:D.id,"data-testid":a?`${a}:Autocomplete:option(${D.id.toString()})`:void 0}),t.jsx("div",{children:Z.map(($,re)=>t.jsx("span",{style:{fontWeight:$.highlight?700:400},children:$.text},re))}))}else return T.createElement("li",w(c({},h),{key:D.id,"data-testid":a?`${a}:option(${D.id.toString()})`:void 0}),D.label)},onMouseDownCapture:h=>{h.button===Ge.right&&R&&(h.preventDefault(),h.stopPropagation())},onContextMenuCapture:h=>{R&&(h.preventDefault(),h.stopPropagation()),W(h)},readOnly:M}),u.length>0&&t.jsx(i.Box,{sx:p,children:u.map(h=>{var D;return t.jsx(i.Chip,{sx:{marginTop:1,marginRight:1,height:"auto"},label:t.jsx(i.Tooltip,{title:(D=h.tooltipContent)!=null?D:"",placement:"bottom-start",slotProps:L,children:t.jsx(i.Typography,{style:{whiteSpace:"normal"},children:h.chipLabel?h.chipLabel:h.label})}),"data-testid":a?`${a}:Chip(${h.id.toString()})`:void 0,onDelete:B=>z(B,h.id),deleteIcon:t.jsx(J.Cancel,{"data-testid":a?`${a}:Chip(${h.id.toString()}):deleteIcon`:void 0})},h.id)})})]})}const Ft=/MUI: The value provided to.*is invalid/i,Pt=({lookup:e=()=>N(null,null,function*(){}),onChange:o,onInputChange:n,label:r,value:s,sx:l,textFieldColor:u,textFieldVariant:a="filled",textFieldFocused:d,textFieldSx:p,error:m=!1,"data-testid":f,loadingText:y="Loading...",noOptionsText:g="No options",minLength:v=3,disablePortal:A=!1,preLoadedOptions:x,helperText:E="",disabled:j,popupIcon:F,disableIconFlip:O,placeholderText:_=void 0,onRightClick:L=()=>{},disableDefaultRightClickBehaviour:I=!1,readOnly:W,hideInputEndAdornment:R})=>{const[M,b]=T.useState(""),{data:C,isLoading:G}=ue({inputValue:M,label:r,lookup:e,minLength:v!=null?v:0,preLoadedOptions:x}),z=M.length>=v;return t.jsx("div",{"data-testid":f,children:t.jsx(i.Stack,{direction:"row",spacing:1,onMouseDownCapture:S=>{S.button===Ge.right&&I&&(S.preventDefault(),S.stopPropagation())},onContextMenuCapture:S=>{I&&(S.preventDefault(),S.stopPropagation()),L(S)},children:t.jsx(i.Autocomplete,{sx:c(c({},l),O?{".MuiAutocomplete-popupIndicatorOpen":{transform:"rotate(0deg)"}}:{}),"data-testid":f?`${f}:Autocomplete`:void 0,loading:z?G:!1,options:C!=null?C:[],onChange:(S,P,H)=>{o(S,P,H)},disablePortal:A,filterOptions:S=>S,value:s,noOptionsText:z?g:"Start typing to search",loadingText:y,getOptionLabel:S=>S.label,popupIcon:F,renderInput:S=>t.jsx(i.TextField,w(c({"data-testid":f?`${f}:Autocomplete:TextField`:void 0},S),{variant:a,label:r,color:u,error:m,helperText:E,autoComplete:"off",slotProps:{input:w(c({},S.InputProps),{endAdornment:R?void 0:t.jsxs(t.Fragment,{children:[G?t.jsx(i.CircularProgress,{color:"inherit",size:20}):null,S.InputProps.endAdornment]})})},placeholder:_,sx:p,focused:d})),isOptionEqualToValue:(S,P)=>S.id===P.id,onInputChange:(S,P,H)=>{b(P),n&&n(P,H,S)},renderOption:(S,P)=>T.createElement("li",w(c({},S),{key:P.id,"data-testid":f?`${f}:Autocomplete:option(${P.id.toString()})`:void 0}),P.label),disabled:j,readOnly:W})})})},He=e=>{if(!e)return-1;try{const n=e.split(".")[1].replace(/-/g,"+").replace(/_/g,"/"),r=decodeURIComponent(xt.Buffer.from(n,"base64").toString("utf8").split("").map(function(l){return"%"+("00"+l.charCodeAt(0).toString(16)).slice(-2)}).join("")),s=JSON.parse(r);return s!=null&&s.exp?s.exp:-1}catch(o){return-1}},Lt=({open:e=!1,closeHandler:o,setAuth0ExpiryTime:n})=>{const{logout:r,getAccessTokenSilently:s}=ce.useAuth0(),l=()=>N(null,null,function*(){r({logoutParams:{returnTo:`${window.location.origin}`}})}),a={text:"Continue",onClick:()=>N(null,null,function*(){const p=yield s({cacheMode:"off"}),m=He(p)*1e3;n(m),o()}),disabled:!1,testId:"PreferencesDialog",buttonColor:"secondary"},d={text:"Log out",onClick:l,disabled:!1,testId:"PreferencesDialog",buttonColor:"secondary"};return t.jsx(de,{isOpen:e,primaryButton:a,secondaryButton:d,onClose:o,dialogTitle:"Session expiry",disableCloseOnBackdropOrEscape:!0,children:t.jsx("p",{style:{marginBottom:0},children:"Your session is about to time out due to inactivity. Do you want to continue?"})})};function Bt(e){return"error"in e}function Ot(e){var r;const o=e.error,n=(r=e==null?void 0:e.error_description)!=null?r:"";return o==="access_denied"&&n.startsWith("You do not have the required authorization")}function Nt(e){var r;const o=e.error,n=(r=e==null?void 0:e.error_description)!=null?r:"";return o==="access_denied"&&n.startsWith("User did not authorize the request")}function It(e){var r;const o=e.error,n=(r=e==null?void 0:e.error_description)!=null?r:"";return o==="access_denied"&&n.match(/Script.*time.*exceeded/)}function Rt({children:e,appName:o="the app",throwErrors:n="none",disableConsoleLogging:r=!1,onError:s=()=>{}}){var f,y;const{isAuthenticated:l,isLoading:u,error:a,loginWithRedirect:d,logout:p}=ce.useAuth0();T.useEffect(()=>{a&&s(a)},[a,s]);const m=T.useMemo(()=>({appState:{returnTo:`${window.location.pathname}${window.location.search}`}}),[]);if(T.useEffect(()=>{u||l||a||d(m)},[u,l,a,d,s,m]),a){if(r||console.error(`Error detected in AuthGuard [isAuthenticated=${l},isLoading=${u}]`,a),n==="all")throw a;if(Bt(a)){let g="Auth error",v="An unknown Auth0 error occurred.";if(Ot(a))g="Unauthorised",v=`You are not authorised to access ${o}.`;else if(Nt(a))g="App not authorised",v=`You have not authorised ${o} to access your user profile. This is necessary to use ${o}.`;else if(It(a))g="Auth0 script execution time exceeded",v="The Auth0 login flow exceeded the time limit (20s). Try again in a minute by clicking the RELOAD button below.";else if(a.message==="Invalid state"){const A=localStorage.getItem("auth0_redirect_count");A?A&&parseInt(A)<2&&(localStorage.setItem("auth0_redirect_count",String(parseInt(A)+1)),d(m)):(localStorage.setItem("auth0_redirect_count","1"),d(m))}else if(n==="unknown")throw a;return t.jsxs(i.Dialog,{open:!0,children:[t.jsx(i.DialogTitle,{children:g}),t.jsxs(i.DialogContent,{children:[t.jsx(i.Typography,{children:v}),t.jsx("br",{}),t.jsx(i.Typography,{variant:"subtitle2",children:"Details from Auth0"}),t.jsxs(i.Typography,{variant:"body2",children:["error: ",(f=a==null?void 0:a.error)!=null?f:"N/A"]}),t.jsxs(i.Typography,{variant:"body2",children:["description: ",(y=a==null?void 0:a.error_description)!=null?y:"N/A"]})]}),t.jsxs(i.DialogActions,{children:[g==="Auth0 script execution time exceeded"&&t.jsx(i.Button,{href:window.location.origin+window.location.pathname,children:"Reload"}),t.jsx(i.Button,{onClick:()=>p({logoutParams:{returnTo:window.location.origin}}),children:"Logout"})]})]})}else if(n==="unknown")throw a}return l?(localStorage.removeItem("auth0_redirect_count"),t.jsx(t.Fragment,{children:e})):t.jsx(bt.default,{variant:"rectangular",animation:"pulse",height:"100vh",width:"100vw"})}const pe=()=>{const e=i.useTheme();return i.useMediaQuery(e.breakpoints.down("sm"))},Mt=64,Gt=72,Ht=256,Y=k.atom(!0),$e=k.atom(Ht),Ue=k.atom(Gt),ae=k.atom(""),qe=k.atom(void 0),We=k.atom(Mt),ze=k.atom(void 0),Ve=({label:e,to:o,icon:n,subMenu:r,subMenuInitialOpen:s,onClick:l,closeOnSmallScreen:u,disabled:a=!1,openInNewWindow:d=!1,extraSubIndentSpace:p=0,tooltip:m="",tooltipMenuOpen:f="",tooltipMenuClosed:y=""})=>{const[g,v]=T.useState(s),[A,x]=k.useAtom(Y),{pathname:E}=se.useLocation(),j=pe(),F="  ".repeat(p),O=d?{rel:"noopener noreferrer",target:"_blank"}:{};return t.jsxs(t.Fragment,{children:[t.jsx(i.Tooltip,{title:m||(f&&A?f:y&&!A?y:""),arrow:!0,placement:"right",children:t.jsxs(i.ListItemButton,w(c({component:o?se.Link:"button",sx:{width:"100%"},to:o,onClick:()=>{l==null||l(),A?(v(_=>!_),u&&j&&x(!1)):r&&(v(!0),x(!0))},"aria-label":e,selected:E===o,disabled:a},O),{children:[t.jsx(i.ListItemIcon,{sx:{padding:"8px"},children:n}),t.jsx(i.Fade,{in:A,unmountOnExit:!0,children:t.jsxs(i.Box,{children:[t.jsx(i.ListItemText,{primary:e}),r&&t.jsx(i.ListItemSecondaryAction,{children:g?t.jsx(J.ExpandLess,{}):t.jsx(J.ExpandMore,{})})]})})]}))}),r&&t.jsx(i.Collapse,{in:g&&A,timeout:"auto",unmountOnExit:!0,children:t.jsx(i.List,{component:"div",disablePadding:!0,children:r.map(_=>t.jsx(i.ListItemButton,{onClick:()=>{_.onClick&&(_==null||_.onClick()),A&&_!=null&&_.closeOnSmallScreen&&j&&x(!1)},to:_.to,component:_.to?se.Link:"button",sx:{width:"100%"},selected:E===_.to,disabled:_.disabled,children:t.jsx(i.ListItemText,{primary:F+_.label,inset:!0,slotProps:{primary:{variant:"body2"}}})},_.label))})})]})},$t=n=>{var r=n,{subMenuInitialOpen:e}=r,o=X(r,["subMenuInitialOpen"]);const s=e===void 0?"initial-undefined":String(e);return t.jsx(Ve,c({subMenuInitialOpen:e},o),s)},Ut=.11,le=10,qt=40,Wt={marginLeft:"3px",marginRight:"3px",borderRadius:2},Te={display:"flex",flexDirection:"row"},zt={},Vt=(e,o,n,r)=>{const s=`rgba(0, 0, 0, ${Ut*((le-e)/le)})`;return t.jsx(t.Fragment,{children:o.map((l,u)=>t.jsx(i.Skeleton,{variant:"rectangular",height:n,sx:c({bgcolor:s,flex:l,marginTop:-1,marginBottom:-1},r)},u))})},Ke=({numberOfRows:e,firstRowStyle:o=zt,rowHeight:n=qt,columnWidths:r,columnStyles:s=Wt})=>{const l=Array(Math.min(e,le)).fill(1);return t.jsx(i.Box,{sx:{display:"flex",flexDirection:"column"},children:l.map((u,a)=>{const d=a===0?c(c({},Te),o):Te;return t.jsx("p",{style:d,children:Vt(a,r,n,s)},a)})})},Kt={name:"shiftDataGridPanelAboveColumnHeaders",enabled:!0,phase:"main",requires:["popperOffsets"],fn({state:e}){const o=e.elements.reference;if(!(o instanceof HTMLElement))return;const n=o.closest(".MuiDataGrid-root");if(!n)return;const r=n.querySelector(".MuiDataGrid-columnHeaders"),s=o.getBoundingClientRect();let u=o.getAttribute("data-id")==="gridPanelAnchor";if(!u&&r instanceof HTMLElement){const y=r.getBoundingClientRect().bottom;u=s.top>=y-1}if(!u)return;const a=getComputedStyle(n).getPropertyValue("--DataGrid-headersTotalHeight").trim(),d=parseFloat(a),m=(Number.isFinite(d)&&d>0?d:56)+8,f=e.modifiersData.popperOffsets;f&&(f.y-=m)}},Yt=111,Xt=10,Qt=[10],Jt={backgroundColor:"white","&.MuiDataGrid-root .MuiDataGrid-cell:focus":{outline:"none"},"&.MuiDataGrid-root .MuiDataGrid-columnHeader:focus":{outline:"none"},"&.MuiDataGrid-root .MuiDataGrid-cell:focus-within":{outline:"none"},"&.MuiDataGrid-root .MuiDataGrid-columnHeader:focus-within":{outline:"none"}},Zt=process.env.NODE_ENV==="test",eo=W=>{var R=W,{loading:e=!1,skeletonColumnWidths:o=Qt,paginationModel:n,onPaginationModelChange:r,layout:s="fixed",footer:l="standard",loadingVariant:u="skeleton",autoTableHeight:a=!1,maxHeight:d,noRowsMessage:p="No rows",noResultsMessage:m="No results",rowHeight:f=52,paginationMode:y="client",filterMode:g="client",pageSizeOptions:v=[5,10,25,50,100],rows:A,sx:x,hideFooter:E,slots:j,"aria-label":F,"aria-labelledby":O,"aria-describedby":_,slotProps:L}=R,I=X(R,["loading","skeletonColumnWidths","paginationModel","onPaginationModelChange","layout","footer","loadingVariant","autoTableHeight","maxHeight","noRowsMessage","noResultsMessage","rowHeight","paginationMode","filterMode","pageSizeOptions","rows","sx","hideFooter","slots","aria-label","aria-labelledby","aria-describedby","slotProps"]);var Ae,Se,Ce,ye;const ge=L!=null?L:{},{main:M}=ge,b=X(ge,["main"]),C=(Ae=b.panel)!=null?Ae:{},G={page:0,pageSize:Xt},[z,S]=T.useState(n!=null?n:G),P=n!==void 0,H=l==="standard"||l==="custom"||P,h=P?n:z,{pageSize:D}=h,B=Yt+D*f,V=s==="fixed"&&a&&A&&A.length!==0&&h.page!==Math.floor(A.length/D),Z=s==="auto",$=d!=null,re=$?d:Z||V?"auto":B,rt=!$&&(Z||V),it=l==="hidden"||E===!0,st=ve=>{P||S(ve),r==null||r(ve)},at=()=>t.jsx(Ke,{numberOfRows:D,columnWidths:o}),lt=()=>t.jsx(be.default,{height:"100%",alignItems:"center",justifyContent:"center",children:e?"":p}),ct=()=>t.jsx(be.default,{height:"100%",alignItems:"center",justifyContent:"center",children:e?"":m}),ee={};u==="skeleton"&&(ee.loadingOverlay=at),j!=null&&j.noRowsOverlay||(ee.noRowsOverlay=lt),j!=null&&j.noResultsOverlay||(ee.noResultsOverlay=ct);const me=i.useTheme();return t.jsx(i.Box,{height:re,width:"100%",sx:$?{display:"flex",flexDirection:"column",minHeight:0}:void 0,children:t.jsx(At.DataGrid,c(w(c({slots:c(c({},ee),j),slotProps:w(c({},b),{panel:w(c({},C),{placement:(Se=C.placement)!=null?Se:"top-end",popperOptions:w(c({},C.popperOptions),{modifiers:[Kt,...(ye=(Ce=C.popperOptions)==null?void 0:Ce.modifiers)!=null?ye:[]]})}),filterPanel:c({filterFormProps:{columnInputProps:{"aria-label":"Filter by column"},operatorInputProps:{"aria-label":"Filter operator"},valueInputProps:{"aria-label":"Filter value"}}},b.filterPanel),main:c(c(c(c({},M),F!=null?{"aria-label":F}:{}),O!=null?{"aria-labelledby":O}:{}),_!=null?{"aria-describedby":_}:{})}),disableRowSelectionOnClick:!0,rowHeight:f,autoHeight:rt,hideFooter:it,sx:w(c(c(c({},Jt),$?{height:"100%"}:{}),x),{"&.MuiDataGrid-root .Mui-selected":{backgroundColor:`${me.palette.secondary.main}15`,"&:hover":{backgroundColor:`${me.palette.secondary.main}1E`}}}),disableVirtualization:Zt,loading:e,rows:A},H?{paginationModel:h,onPaginationModelChange:st}:{}),{paginationMode:y,filterMode:g,pageSizeOptions:v}),I))})},to={autoHideDuration:6e3,anchorOrigin:{vertical:"top",horizontal:"center"},disableWindowBlurListener:!1},oo={shouldClose:(e,o)=>o!=="clickaway"},ke={message:"",severity:"info",variant:"standard",progressIndicator:void 0},Fe=100,Pe=2e3,no=2e3,ro=(()=>{let e=0;return()=>(e+=1,e)})(),io={borderBottomLeftRadius:"0px",borderBottomRightRadius:"0px"},so={},ao={},he=T.createContext(null);function Ye(l){var u=l,{overrideState:e=so,overrideActions:o=ao,shouldClose:n=oo.shouldClose,children:r}=u,s=X(u,["overrideState","overrideActions","shouldClose","children"]);var M;const[{open:a},d]=T.useState({open:!1}),p=T.useRef([]),m=T.useRef(Date.now()),f=T.useRef(0),y=T.useCallback(b=>{d({open:b})},[]),g=T.useCallback((b={})=>{f.current+=1,p.current.length>=Fe&&Date.now()-m.current>=Pe&&(m.current=Date.now(),console.error(`SaladBarProvider: MAX_QUEUE_LENGTH (${Fe}) hit ${f.current} times in last ${Pe}ms)`),f.current=0);const C=c(w(c({},ke),{key:ro()}),b);return p.current.push(C),p.current.length===1&&d({open:!0}),C.key},[]),v=(b="",C={})=>g(c({message:b,severity:"success"},C)),A=(b="",C={})=>g(c({message:b,severity:"info"},C)),x=(b="",C={})=>g(c({message:b,severity:"warning"},C)),E=(b="",C={})=>g(c({message:b,severity:"error"},C)),j=b=>{const C=p.current.findIndex(G=>G.key===b);if(C!==-1)return C===0?(d({open:!1}),p.current[0]):p.current.splice(C,1)},F=(b,C)=>{n(b,C)&&d({open:!1})},O=()=>{},_=()=>{p.current.shift(),p.current.length>0&&d({open:!0})},L=(M=p.current[0])!=null?M:c({},ke),I={};"autoHideDuration"in L&&(I.autoHideDuration=L.autoHideDuration);const W=c(c({},to),s),R=c(c({open:a,setOpen:y,enqueueNotification:g,enqueueSuccessNotification:v,enqueueInfoNotification:A,enqueueWarningNotification:x,enqueueErrorNotification:E,removeNotification:j},e),o);return t.jsxs(he.Provider,{value:R,children:[r,t.jsx(i.Snackbar,w(c(c({},W),I),{open:a,onClose:F,TransitionProps:{onExited:_,onExit:O},sx:{zIndex:no},children:t.jsxs("div",{children:[t.jsx(i.Alert,{onClose:b=>F(b,"closeAlert"),severity:L.severity,variant:"filled",icon:L.progressIndicator==="circular"?t.jsx(i.CircularProgress,{size:"1em"}):void 0,style:L.progressIndicator==="linear"?io:void 0,children:L.message}),L.progressIndicator==="linear"&&t.jsx(i.LinearProgress,{color:"primary"})]})}))]})}class fe extends Error{}Ee(fe,"errorName","ContextError");function Xe(){const e=T.useContext(he);if(e===null)throw new fe("Error: Tried to useSaladBar outside of a <SaladBarProvider>");return e}const lo=St.createHelper((e={autoHideDuration:1},o={},n={})=>({children:r})=>t.jsx(Ye,w(c({},e),{overrideState:o,overrideActions:n,children:t.jsx(t.Fragment,{children:r})}))),Qe={act:"ACT",nsw:"NSW",nt:"NT",qld:"QLD",sa:"SA",tas:"TAS",vic:"VIC",wa:"WA",ag:"AG",fedmps:"FedMPs","":""},Je="domainCode";var Re;const Le=k.atom(JSON.parse((Re=localStorage.getItem(Je))!=null?Re:'{"domainCode": ""}').domainCode),Ze=k.atom(e=>e(Le),(e,o,n)=>{o(Le,n),localStorage.setItem(Je,JSON.stringify({domainCode:n}))}),xe=e=>{var o;return e===null?"N/A":(o=Qe[e])!=null?o:""},co=({isLoading:e,isOpen:o,onClose:n,onDomainChange:r,domainOptions:s,applicationName:l,handleLogout:u})=>{const[a,d]=k.useAtom(Ze),[p,m]=T.useState(a),{enqueueSuccessNotification:f}=Xe(),y=s.length===0,g=!!a&&!s.includes(a)&&!s.includes(p),v=!a||y||g,A=()=>N(null,null,function*(){p?(d(p),r==null||r(p),f(`Set organisation to ${p}`),n()):(d(""),r==null||r(""))}),x=()=>N(null,null,function*(){a&&!y&&!g?(m(a),n()):v&&u()});let E;return y?E="Unable to retrieve your active organisations. Try logging in again.":g&&(E="You no longer have any roles in your chosen organisation. Please choose another."),t.jsxs(de,{isOpen:o,dialogTitle:"Select an organisation",primaryButton:{text:"Confirm",onClick:A,disabled:!p||y||g,buttonColor:"primary"},secondaryButton:{text:v?"Logout":"Cancel",onClick:x},onClose:v?()=>{}:n,children:[t.jsxs(i.Typography,{marginBottom:2,children:["Select the default organisation that you want to use with the ",l,"."]}),t.jsx(i.Autocomplete,{loading:e,multiple:!1,disableClearable:!1,value:p!==""?p:null,onChange:(j,F)=>m(F!=null?F:""),getOptionLabel:xe,options:[...s.toSorted()],renderInput:j=>t.jsx(i.TextField,w(c({},j),{variant:"filled",label:"Select organisation",InputProps:w(c({},j.InputProps),{endAdornment:t.jsxs(t.Fragment,{children:[e?t.jsx(i.CircularProgress,{color:"inherit",size:20,sx:{marginTop:"-20px"}}):null,j.InputProps.endAdornment]})})}))}),E&&t.jsx(i.FormHelperText,{error:!0,children:E})]})};function uo({links:e}){return t.jsx("div",{children:"LinksMenu not implemented yet"})}const oe="Navbar",Q={root:`${oe}-root`,menuButton:`${oe}-menuButton`,hide:`${oe}-hide`,content:`${oe}-content`},po=U.styled(i.Box,{name:"NavBar"})(({theme:e})=>({[`&.${Q.root}`]:{display:"flex"},[`& .${Q.menuButton}`]:{marginRight:36},[`& .${Q.hide}`]:{display:"none"},[`& .${Q.content}`]:{flexGrow:1,padding:e.spacing(3)}})),K=(e,o,n)=>e.transitions.create(o,{easing:e.transitions.easing.sharp,duration:n==="leaving"?e.transitions.duration.leavingScreen:e.transitions.duration.enteringScreen}),ho=e=>{const o=i.useTheme();return t.jsx(i.Collapse,c({easing:o.transitions.easing.sharp,timeout:{enter:o.transitions.duration.enteringScreen,exit:o.transitions.duration.leavingScreen}},e))},et=e=>{var o,n;return{overflowX:"hidden",color:"inherit",backgroundColor:(n=(o=e==null?void 0:e.navBar)==null?void 0:o.backgroundColor)!=null?n:"white"}},Be=(e,o)=>c({width:o,transition:K(e,"width","entering")},et(e)),Oe=(e,o)=>c({width:o,transition:K(e,"width","leaving")},et(e)),fo=U.styled(i.Drawer,{shouldForwardProp:e=>!["widthOpen","widthClosed","isSmallScreen"].includes(e)})(({theme:e,open:o,widthOpen:n,widthClosed:r,isSmallScreen:s})=>c(c({flexShrink:0,whiteSpace:"nowrap",boxSizing:"border-box",display:"flex",flexDirection:"column"},o&&w(c({},Be(e,n)),{backgroundColor:"","& .MuiDrawer-paper":Be(e,n)})),!o&&w(c({},Oe(e,s?n:r)),{backgroundColor:"","& .MuiDrawer-paper":Oe(e,s?n:r)})));function tt(e){return e.replace(/(^|-)([a-z])/g,(o,n,r)=>n==="-"?" "+r.toUpperCase():r.toUpperCase())}function xo(e,o,n,r){var u;if(!e)return"None";const s=e["https://greens.org.au/roles"];if(!s)return"None";const l=Object.entries(s).filter(([,a])=>a.includes(o)).map(([a])=>tt(a));return(u=r.find(a=>n[a].some(d=>l.includes(d))))!=null?u:"None"}function ot(e,o){return Object.entries(e).reduce((n,[r,s])=>{const l=tt(r),u=o.includes(l)?s:[];return[...new Set([...n,...u])]},[])}const mo=e=>{const{getIdTokenClaims:o,user:n}=ce.useAuth0();return Me.useQuery({queryKey:["availableDomains",n==null?void 0:n.sub],queryFn:()=>N(null,null,function*(){const r=yield o();if(!r)return[];const s=r["https://greens.org.au/roles"];return s?ot(s,e):[]})})},go=e=>Object.values(e).reduce((o,n)=>[...new Set([...o,...n])],[]),ne={log:console.warn.bind(console),error:console.error.bind(console),warn:console.warn.bind(console),info:console.info.bind(console),debug:console.debug.bind(console)};function Ao(e,o){console[e]=(...n)=>{for(const r of o)if(typeof r=="function"){if(r(...n))return}else if(r instanceof RegExp&&n.length>0){for(const s of n)if(typeof s=="string"&&r.test(s))return}ne[e](n)}}function So(e){if(e)console[e]=ne[e];else for(const o of Object.keys(ne))console[o]=ne[o]}function Co(e,o){return e!=null&&typeof e=="object"&&"error"in e&&e.error===o}function yo(e,o){const n=o==null?void 0:o.originalException;return Co(n,"login_required")?null:e}function nt(e){let o=0;for(let n=0,r=e.length;n<r;n++){const s=e.charCodeAt(n);o=(o<<5)-o+s,o|=0}return o}const Ne=["#A62A21","#7e3794","#0B51C1","#3A6024","#A81563","#B3003C"],Ie=e=>e.split(/\s/).map(o=>o.substring(0,1).toUpperCase()).filter(o=>!!o).slice(0,2).join("").toUpperCase();function vo({user:e,domainCode:o,open:n,useNewAvatar:r=!1}){const s=i.useTheme();return t.jsxs(i.Box,{sx:{paddingTop:3,display:"flex",alignItems:"center",flexDirection:"column",gap:"0.5rem"},children:[!r&&t.jsx(i.Box,{sx:{width:n?"5rem":"2rem",transition:n?K(s,["width","height"],"entering"):K(s,["width","height"],"leaving"),aspectRatio:1},children:e!=null&&e.name?t.jsx(t.Fragment,{children:t.jsx(i.Avatar,{src:e==null?void 0:e.picture,sx:{width:"100%",height:"100%",bgcolor:Ne[Math.abs(nt(e==null?void 0:e.name))%Ne.length]},children:Ie(e==null?void 0:e.name)})}):t.jsx(i.Avatar,{sx:{width:"100%",height:"100%"}})}),r&&t.jsx(i.Box,{sx:{width:n?"5rem":"2rem",transition:n?K(s,["width","height"],"entering"):K(s,["width","height"],"leaving"),aspectRatio:1},children:e!=null&&e.name?t.jsx(t.Fragment,{children:t.jsxs(we.default,{src:e==null?void 0:e.picture,name:e==null?void 0:e.name,round:!0,size:n?"80":"32",children:[" ",Ie(e==null?void 0:e.name)," ","ab"]})}):t.jsx(we.default,{})}),t.jsx(ho,{sx:{width:"100%"},in:n,children:t.jsx(i.Fade,{in:n,children:t.jsxs(i.Box,{width:"100%",display:"flex",flexDirection:"column",alignItems:"center",children:[e!=null&&e.name?t.jsx(i.Typography,{children:e==null?void 0:e.name}):t.jsx(i.Skeleton,{animation:!1,width:"50%"}),o?t.jsx(i.Typography,{children:xe(o)}):t.jsx(i.Skeleton,{animation:!1,width:"25%"})]})})})]})}function jo({open:e,widthClosed:o,widthOpen:n,"data-testid":r,top:s,middle:l,bottom:u,user:a,domainCode:d,useNewAvatar:p=!1}){const m=pe(),f=k.useSetAtom(Y);return t.jsx(po,{className:Q.root,"data-testid":r,children:t.jsxs(fo,{open:e,widthOpen:n,widthClosed:o,anchor:"left",variant:m?"temporary":"permanent",PaperProps:{component:"nav"},onClose:()=>{f(!1)},isSmallScreen:m,children:[!m&&t.jsx(i.Toolbar,{}),s&&t.jsxs(i.Box,{flexGrow:"0",children:[s,t.jsx(i.Divider,{variant:"middle",sx:{marginY:"0.5rem"}})]}),t.jsx(i.Box,{flexGrow:"1",children:Array.isArray(l)?t.jsx(uo,{links:l}):l}),t.jsxs(i.Box,{flexGrow:"0",children:[t.jsx(i.Divider,{variant:"middle",sx:{marginY:"0.5rem"}}),t.jsx(vo,{user:a,domainCode:d,open:e,useNewAvatar:p}),u&&t.jsx(t.Fragment,{children:u})]})]})})}function Do({children:e,topBarHeight:o,maxWidth:n=!1,noPadding:r}){return t.jsx(i.Box,{tabIndex:0,sx:{overflow:"auto",height:`calc(100vh - ${o}px)`,flexGrow:1},children:r?t.jsx(i.Box,{height:"inherit",children:e}):t.jsx(i.Container,{maxWidth:n,sx:{paddingTop:3,paddingBottom:3,flexGrow:1},children:e})})}const Eo="TopBar",bo={titleText:`${Eo}-titleText`};function _o({titleText:e="",height:o,"data-testid":n,middle:r,menuButtonAriaLabel:s="Open navigation menu"}){const l=k.useSetAtom(Y),u=()=>l(p=>!p),a=i.useTheme(),d=pe();return t.jsx("header",{"data-testid":n,children:t.jsxs(i.Paper,{square:!0,elevation:0,sx:{width:"100%",position:"sticky",color:"primary.contrastText",backgroundColor:"primary.main",display:"flex",alignItems:"center",gap:2,flexShrink:0,height:o,zIndex:d?0:a.zIndex.drawer+99},children:[t.jsx(i.IconButton,{size:"medium",color:"inherit",sx:{padding:1.5,marginLeft:"12px"},onClick:u,"aria-label":s,children:t.jsx(J.ViewHeadline,{fontSize:"medium"})}),t.jsx(i.Typography,{className:bo.titleText,variant:"h6",component:"h1",children:e}),r]})})}function wo({children:e,initialTitleText:o,initialNavBarOpen:n,pageContainerProps:r,pageContentDataTestId:s,topBarDataTestId:l,menuButtonAriaLabel:u,navBarDataTestId:a,navBarMiddle:d,navBarBottom:p,user:m,domainCode:f,useNewAvatar:y=!1}){vt.useHydrateAtoms([[Y,n!=null?n:!0],[ae,o!=null?o:""]]);const g=k.useAtomValue(Y),[v]=k.useAtom($e),[A]=k.useAtom(Ue),x=k.useAtomValue(ae),[E]=k.useAtom(We),[j]=k.useAtom(qe),[F]=k.useAtom(ze);return t.jsxs(_e.default,{children:[t.jsx(_t.default,{}),t.jsx(_o,{titleText:x,"data-testid":l,height:E,middle:j,menuButtonAriaLabel:u}),t.jsxs(_e.default,{sx:{display:"flex"},children:[t.jsx(jo,{open:g,top:F,middle:d,bottom:p,user:m,domainCode:f,widthOpen:v,widthClosed:A,offsetTop:E,"data-testid":a,useNewAvatar:y}),t.jsx(Do,w(c({"data-testid":s,topBarHeight:E},r),{children:e}))]})]})}const To=U.createTheme({palette:{primary:{dark:"#00A651",light:"#A3D39C",main:"#007236",contrastText:"#FFF"},warning:{main:"#F5871F",light:"#FCC589",dark:"#A2590A",contrastText:"#FFF"},secondary:{main:"#662D91",light:"#BD8CBF",dark:"#440E62",contrastText:"#FFF"},error:{main:"#D43C95",light:"#8F2064",dark:"#F9CDE0",contrastText:"#FFF"},info:{main:"#00A88D",light:"#ADDCCF",dark:"#005243",contrastText:"#FFF"},success:{main:"#00A651",light:"#A3D39C",dark:"#007236",contrastText:"#FFF"}},typography:{explainer:{fontSize:"14px",marginBlockStart:"1em"}},navBar:{backgroundColor:"#E8E8E8"}}),ko=U.createTheme({palette:{primary:{main:"#007236",dark:"#005221",light:"#00A04E",contrastText:"#FFFFFF"},secondary:{main:"#662D91",dark:"#440E62",light:"#93268F",contrastText:"#FFFFFF"},error:{main:"#D32F2F",dark:"#C62828",light:"#EF5350"},info:{main:"#0288D1",dark:"#01579B",light:"#03A9F4"},success:{main:"#0288D1",dark:"#01579B",light:"#03A9F4"}},components:{MuiTextField:{defaultProps:{color:"secondary"}},MuiToggleButtonGroup:{defaultProps:{color:"secondary"}},MuiCheckbox:{defaultProps:{color:"secondary"}},MuiSelect:{defaultProps:{color:"secondary"}},MuiSwitch:{defaultProps:{color:"secondary"}},MuiFormControl:{defaultProps:{color:"secondary"}},MuiMenuItem:{styleOverrides:{root:({theme:e})=>({"&.Mui-selected":{backgroundColor:U.alpha(e.palette.secondary.main,e.palette.action.selectedOpacity),"&:hover":{backgroundColor:U.alpha(e.palette.secondary.main,e.palette.action.selectedOpacity)},"&.Mui-focusVisible":{backgroundColor:U.alpha(e.palette.secondary.main,e.palette.action.focusOpacity)}}})}}},typography:{h4:{fontSize:"1.88rem",fontWeight:500},h5:{fontWeight:500},explainer:{fontSize:"14px",marginBlockStart:"1em"}},navBar:{backgroundColor:"#E8E8E8"}});exports.AgDataGrid=eo;exports.AgDialog=de;exports.AppLayout=wo;exports.AuthGuard=Rt;exports.Context=he;exports.ContextError=fe;exports.DOMAIN_CODE_LABELS=Qe;exports.DomainCodeDialog=co;exports.ExampleComponent=wt;exports.FetchAutocomplete=kt;exports.MUI_AUTOCOMPLETE_VALUE_WARNING_REGEX=Ft;exports.NavBarLink=$t;exports.NavBarLinkInner=Ve;exports.SaladBarProvider=Ye;exports.SessionExpiryDialog=Lt;exports.SingleAutocomplete=Pt;exports.TableLoadingSkeleton=Ke;exports.determineUserLevelFromClaims=xo;exports.domainCodeAtom=Ze;exports.fed21Theme=To;exports.getAuth0Expiry=He;exports.getDomainOptionLabel=xe;exports.getDomainsFromRolesClaim=ot;exports.getValidBusinessRoles=go;exports.internalAgSystemsTheme=ko;exports.navBarOpenAtom=Y;exports.navBarTopAtom=ze;exports.navBarWidthClosedAtom=Ue;exports.navBarWidthOpenAtom=$e;exports.sentryBeforeSend=yo;exports.simpleHashCode=nt;exports.suppressConsole=Ao;exports.titleTextAtom=ae;exports.topBarHeightAtom=We;exports.topBarMiddleAtom=qe;exports.unsuppressConsole=So;exports.useAutocompleteOptions=ue;exports.useSaladBar=Xe;exports.useValidDomains=mo;exports.withSaladBarProvider=lo;
2
2
  //# sourceMappingURL=index.cjs.map