@australiangreens/ag-internal-components 0.0.81 → 0.0.82
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.
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/components/SessionExpiryDialog/index.comp.test.d.ts +2 -0
- package/dist/components/SessionExpiryDialog/index.comp.test.d.ts.map +1 -0
- package/dist/esm/index.js +13 -4
- package/dist/esm/index.js.map +1 -1
- package/dist/layouts/AppLayout/TopBar.d.ts.map +1 -1
- package/dist/layouts/AppLayout/defaults.d.ts +1 -1
- package/package.json +1 -1
- package/dist/components/SessionExpiryDialog/index.unit.test.d.ts +0 -2
- package/dist/components/SessionExpiryDialog/index.unit.test.d.ts.map +0 -1
package/dist/cjs/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var ut=Object.defineProperty,pt=Object.defineProperties;var ht=Object.getOwnPropertyDescriptors;var Y=Object.getOwnPropertySymbols;var be=Object.prototype.hasOwnProperty,je=Object.prototype.propertyIsEnumerable;var ae=(e,t,o)=>t in e?ut(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,l=(e,t)=>{for(var o in t||(t={}))be.call(t,o)&&ae(e,o,t[o]);if(Y)for(var o of Y(t))je.call(t,o)&&ae(e,o,t[o]);return e},j=(e,t)=>pt(e,ht(t));var De=(e,t)=>{var o={};for(var i in e)be.call(e,i)&&t.indexOf(i)<0&&(o[i]=e[i]);if(e!=null&&Y)for(var i of Y(e))t.indexOf(i)<0&&je.call(e,i)&&(o[i]=e[i]);return o};var Be=(e,t,o)=>(ae(e,typeof t!="symbol"?t+"":t,o),o);var O=(e,t,o)=>new Promise((i,a)=>{var s=c=>{try{u(o.next(c))}catch(p){a(p)}},d=c=>{try{u(o.throw(c))}catch(p){a(p)}},u=c=>c.done?i(c.value):Promise.resolve(c.value).then(s,d);u((o=o.apply(e,t)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),g=require("react"),r=require("@mui/material"),gt=require("@mui/material/CssBaseline"),T=require("@mui/material/styles"),xt=require("@australiangreens/ag-error"),G=require("souvlaki"),ft=require("@mui/material/List"),W=require("@mui/icons-material"),mt=require("autosuggest-highlight/match"),Ct=require("autosuggest-highlight/parse"),ce=require("@tanstack/react-query"),Me=require("@auth0/auth0-react"),vt=require("buffer"),At=require("@mui/material/Skeleton"),y=require("jotai"),He=require("jotai/utils"),V=e=>e&&e.__esModule?e:{default:e},wt=V(gt),Re=V(ft),St=V(mt),yt=V(Ct),bt=V(At);function jt({text:e}){const[t,o]=g.useState(0);return n.jsxs(n.Fragment,{children:[n.jsx(r.Typography,{variant:"h6",color:"inherit",component:"div",sx:{fontSize:"22px"},children:"Hello world"}),n.jsx(r.Typography,{variant:"caption",display:"block",children:n.jsx("span",{children:"Just ensuring MUI is working as planned as a peer dependency. v0.0.11"})}),n.jsx(r.Button,{variant:"outlined",onClick:()=>o(i=>i+1),"aria-label":"Increment",children:"Hello I am a button"}),n.jsxs("p",{children:["This is some text: ",n.jsx("span",{children:e})]}),n.jsxs(r.Paper,{children:["This number will incremember when button pressed: ",t]})]})}const de=330,ue=73,H="Navbar",q={root:`${H}-root`,menuButton:`${H}-menuButton`,hide:`${H}-hide`,content:`${H}-content`,userInfoHolder:`${H}-userInfoHolder`,settings:`${H}-settings`,pieChartIcon:`${H}-pieChartIcon`},Dt=T.styled(r.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)},[`& .${q.userInfoHolder}`]:{height:"148px",marginTop:"64px",marginBottom:"16px"}})),qe=()=>({position:"absolute",height:"100%",overflowX:"hidden",overflowY:"hidden",color:"white",backgroundColor:"black"}),Bt=()=>l({width:de},qe()),kt=()=>l({width:ue},qe()),Tt=T.styled(r.Drawer,{shouldForwardProp:e=>e!=="open"})(({theme:e,open:t})=>l(l({width:t?de:ue,flexShrink:0,whiteSpace:"nowrap",boxSizing:"border-box",zIndex:e.zIndex.drawer+100},t&&{"& .MuiDrawer-paper":Bt()}),!t&&{"& .MuiDrawer-paper":kt()}));class te extends xt.AgError{}Be(te,"errorName","ContextError");const We=g.createContext(null),It={},Et={},ze=({overrideState:e=It,overrideActions:t=Et,children:o})=>{const[{open:i},a]=g.useState({open:!0}),s=g.useCallback(c=>{a({open:c})},[]),d=g.useCallback(()=>{a(c=>j(l({},c),{open:!c.open}))},[]),u=l(l({open:i,setOpen:s,toggleOpen:d},e),t);return n.jsx(We.Provider,{value:u,children:o})},Ue=()=>{const e=g.useContext(We);if(e===null)throw new te("Error: Tried to useNavBar outside of a <NavBarProvider>");return e},Ge=(e={})=>l({open:!0},e),$t=G.createHelper((e=Ge(),t={})=>({children:o})=>n.jsx(ze,{overrideState:e,overrideActions:t,children:o})),ke=7,Ot=T.styled(Re.default)(({theme:e})=>({backgroundColor:"black",color:"white","& .MuiListItem-root":{padding:"unset"},"& .MuiListItemButton-root":{" .MuiListItemIcon-root":{color:"white",padding:`${ke}px`},"&.Mui-focusVisible":{backgroundColor:e.palette.grey[700]},"&.Mui-selected":{borderLeftStyle:"solid",borderLeftWidth:"7px",borderLeftColor:e.palette.primary.main,paddingLeft:`calc(${e.spacing(2)} - ${ke}px)`},"&:hover":{backgroundColor:e.palette.primary.dark},"&.Mui-selected.Mui-focusVisible":{backgroundColor:e.palette.grey[700]},"&.Mui-selected:hover":{backgroundColor:e.palette.primary.dark}}})),Te=7,Ft=T.styled(Re.default)(({theme:e})=>({backgroundColor:"#e8e8e8",color:"inherit","& .MuiListItem-root":{padding:"unset"},"& .MuiListItemButton-root":{" .MuiListItemIcon-root":{color:"inherit",padding:`${Te}px`},"&.Mui-focusVisible":{backgroundColor:e.palette.grey[700]},"&.Mui-selected":{borderLeftStyle:"solid",borderLeftWidth:"7px",borderLeftColor:e.palette.primary.main,paddingLeft:`calc(${e.spacing(2)} - ${Te}px)`},"&:hover":{backgroundColor:e.palette.primary.dark},"&.Mui-selected.Mui-focusVisible":{backgroundColor:e.palette.grey[700]},"&.Mui-selected:hover":{backgroundColor:e.palette.primary.dark}}}));function Pt({"data-testid":e,children:t}){const{open:o}=Ue();return n.jsxs(Dt,{className:q.root,"data-testid":e,children:[n.jsx(wt.default,{}),n.jsx(Tt,{variant:"permanent",anchor:"left",transitionDuration:null,open:o,children:t})]})}const pe=({isOpen:e,dialogTitle:t,children:o,maxWidth:i,primaryButton:a,secondaryButton:s,onClose:d,sx:u,"data-testid":c,disableCloseOnBackdropOrEscape:p=!1})=>{var w,x;const[C,A]=g.useState(!1);return n.jsxs(r.Dialog,{open:e,onClose:(b,D)=>O(exports,null,function*(){p&&(D==="backdropClick"||D==="escapeKeyDown")||C||(s!=null&&s.onClick?yield s.onClick():d())}),fullWidth:!0,maxWidth:i!=null?i:"xs","data-testid":c,sx:u,children:[n.jsx(r.DialogTitle,{children:t}),n.jsx(r.DialogContent,{sx:{"& > :last-child":{marginBottom:0}},children:o}),n.jsxs(r.DialogActions,{children:[n.jsx(r.Button,{onClick:(w=s==null?void 0:s.onClick)!=null?w:d,"data-testid":s==null?void 0:s.testId,disabled:(s==null?void 0:s.disabled)||C,color:s==null?void 0:s.buttonColor,children:(x=s==null?void 0:s.text)!=null?x:"Cancel"}),a&&n.jsx(r.Button,{onClick:()=>O(exports,null,function*(){var b;A(!0),yield(b=a.onClick)==null?void 0:b.call(a),A(!1)}),"data-testid":a.testId,disabled:a.disabled||C,color:a==null?void 0:a.buttonColor,children:a.text})]})]})},he=({minLength:e,preLoadedOptions:t,lookup:o,label:i,inputValue:a})=>ce.useQuery({queryFn:()=>e&&a.length<e?t!=null?t:[]:t?t.filter(s=>s.label.toLowerCase().includes(a.toLowerCase())):o(a),queryKey:["autocomplete",i,a]});function Nt({lookup:e=()=>O(this,null,function*(){}),enableHighlighting:t=!0,onChange:o,minLength:i=0,label:a,value:s,"data-testid":d,sx:u,textFieldColor:c,textFieldVariant:p="filled",loadingText:C="Loading...",noOptionsText:A="No options",popupIcon:w=n.jsx(W.ArrowDropDown,{}),error:x=!1,helperText:b="",preLoadedOptions:D=void 0,disablePortal:k=!1}){const[f,B]=g.useState(""),L=(h,m)=>{const $=s.filter(P=>P.id!==m);o($,"delete",h)},{data:F,isLoading:N}=he({inputValue:f,label:a,lookup:e,minLength:i,preLoadedOptions:D}),I=f.length>=i;return n.jsxs("div",{"data-testid":d,children:[n.jsx(r.Autocomplete,{sx:u,"data-testid":d?`${d}:Autocomplete`:void 0,disablePortal:k,multiple:!0,getOptionLabel:h=>typeof h=="string"?h:h.label,loading:I?N:!1,options:[...s,...F!=null?F:[]],filterSelectedOptions:!0,includeInputInList:!0,value:s,onChange:(h,m,$)=>{o(m,$,h)},onInputChange:(h,m)=>B(m),noOptionsText:I?A:"Start typing to search",loadingText:C,popupIcon:w,renderInput:h=>n.jsx(r.TextField,j(l({},h),{label:a,fullWidth:!0,variant:p,error:x,helperText:b,InputProps:j(l({},h.InputProps),{endAdornment:n.jsxs(n.Fragment,{children:[N?n.jsx(r.CircularProgress,{color:"inherit",size:20}):null,h.InputProps.endAdornment]})}),"data-testid":d?`${d}:Autocomplete:TextField`:void 0,onKeyDown:m=>{(m.key==="Backspace"||m.key==="Delete")&&m.stopPropagation()},color:c})),renderTags:()=>null,isOptionEqualToValue:(h,m)=>h.id===m.id,renderOption:(h,m,$)=>{if(t){const P=St.default(m.label,$.inputValue,{insideWords:!0,findAllOccurrences:!0}),S=yt.default(m.label,P);return g.createElement("li",j(l({},h),{key:m.id,"data-testid":d?`${d}:Autocomplete:option(${m.id.toString()})`:void 0}),n.jsx("div",{children:S.map((v,_)=>n.jsx("span",{style:{fontWeight:v.highlight?700:400},children:v.text},_))}))}else return g.createElement("li",j(l({},h),{key:m.id,"data-testid":d?`${d}:option(${m.id.toString()})`:void 0}),m.label)}}),s.length>0&&n.jsx(r.Box,{children:s.map(h=>n.jsx(r.Chip,{sx:{marginTop:1,marginRight:1,height:"auto"},label:n.jsx(r.Tooltip,{title:h.tooltipContent||"",placement:"bottom-start",PopperProps:{modifiers:[{name:"offset",options:{offset:[115,-15]}}]},children:n.jsx(r.Typography,{style:{whiteSpace:"normal"},children:h.chipLabel?h.chipLabel:h.label})}),"data-testid":d?`${d}:Chip(${h.id.toString()})`:void 0,onDelete:m=>L(m,h.id),deleteIcon:n.jsx(W.Cancel,{"data-testid":d?`${d}:Chip(${h.id.toString()}):deleteIcon`:void 0})},h.id))})]})}const _t=({lookup:e=()=>O(exports,null,function*(){}),onChange:t,label:o,value:i,sx:a,textFieldColor:s,textFieldVariant:d="filled","data-testid":u,noOptionsText:c="No options",minLength:p=3,disablePortal:C=!1,preLoadedOptions:A})=>{const[w,x]=g.useState(""),{data:b,isLoading:D}=he({inputValue:w,label:o,lookup:e,minLength:p!=null?p:0,preLoadedOptions:A}),k=w.length>=p;return n.jsx("div",{"data-testid":u,children:n.jsx(r.Stack,{direction:"row",spacing:1,children:n.jsx(r.Autocomplete,{sx:a,"data-testid":u?`${u}:Autocomplete`:void 0,loading:k?D:!1,options:b!=null?b:[],onChange:(f,B)=>{t(f,B)},disablePortal:C,filterOptions:f=>f,value:i,noOptionsText:k?c:"Start typing to search",getOptionLabel:f=>f.label,renderInput:f=>n.jsx(r.TextField,j(l({"data-testid":u?`${u}:Autocomplete:TextField`:void 0},f),{variant:d,label:o,color:s})),isOptionEqualToValue:(f,B)=>f.id===B.id,onInputChange:(f,B)=>{x(B)},renderOption:(f,B)=>g.createElement("li",j(l({},f),{key:B.id,"data-testid":u?`${u}:Autocomplete:option(${B.id.toString()})`:void 0}),B.label)})})})},Ve=e=>{if(!e)return-1;try{const o=e.split(".")[1].replace(/-/g,"+").replace(/_/g,"/"),i=decodeURIComponent(vt.Buffer.from(o,"base64").toString("utf8").split("").map(function(s){return"%"+("00"+s.charCodeAt(0).toString(16)).slice(-2)}).join("")),a=JSON.parse(i);return a!=null&&a.exp?a.exp:-1}catch(t){return-1}},Lt=({open:e=!1,closeHandler:t,setAuth0ExpiryTime:o})=>{const{logout:i,getAccessTokenSilently:a}=Me.useAuth0(),[s,d]=g.useState(0),u=()=>O(exports,null,function*(){i({logoutParams:{returnTo:`${window.location.origin}`}})}),c=()=>O(exports,null,function*(){d(s+1),t()});g.useEffect(()=>{(()=>O(exports,null,function*(){if(s>0){const w=yield a({cacheMode:"off"}),x=Ve(w)*1e3;o(x)}}))()},[s,a,o]);const p={text:"Continue",onClick:c,disabled:!1,testId:"PreferencesDialog",buttonColor:"secondary"},C={text:"Log out",onClick:u,disabled:!1,testId:"PreferencesDialog",buttonColor:"secondary"};return n.jsx(pe,{isOpen:e,primaryButton:p,secondaryButton:C,onClose:t,dialogTitle:"Session expiry",disableCloseOnBackdropOrEscape:!0,children:n.jsx("p",{style:{marginBottom:0},children:"Your session is about to time out due to inactivity. Do you want to continue?"})})};function Mt(e){return"error"in e}function Ht(e){return e.error==="access_denied"}function Rt(e){var i;const t=e.error,o=(i=e==null?void 0:e.error_description)!=null?i:"";return t==="access_denied"&&o.startsWith("You do not have the required authorization")}function qt(e){var i;const t=e.error,o=(i=e==null?void 0:e.error_description)!=null?i:"";return t==="access_denied"&&o.startsWith("User did not authorize the request")}function Wt({children:e,appName:t="the app"}){const{isAuthenticated:o,isLoading:i,error:a,loginWithRedirect:s,logout:d}=Me.useAuth0();if(g.useEffect(()=>{if(i||o||a)return;const u={appState:{returnTo:`${window.location.pathname}${window.location.search}`}};s(u)},[i,o,a,s]),a&&Mt(a)){let u="Auth error",c="An unknown Auth0 error occurred.";return Rt(a)?(u="Unauthorised",c=`You are not authorised to access ${t}.`):qt(a)?(u="App not authorised",c=`You have not authorised ${t} to access your user profile. This is necessary to use ${t}.`):Ht(a)&&(u="Unauthorised",c="Authorisation with auth0 failed for an unknown reason."),n.jsxs(r.Dialog,{open:!0,children:[n.jsx(r.DialogTitle,{children:u}),n.jsx(r.DialogContent,{children:n.jsx(r.Typography,{children:c})}),n.jsx(r.DialogActions,{children:n.jsx(r.Button,{onClick:()=>d({logoutParams:{returnTo:window.location.origin}}),children:"Logout"})})]})}return o?n.jsx(n.Fragment,{children:e}):n.jsx(bt.default,{variant:"rectangular",animation:"pulse",height:"100vh",width:"100vw"})}const zt=24,Ut=64,R="TopBar",E={topStripe:`${R}-topStripe`,titleBar:`${R}-titleBar`,titleSlider:`${R}-titleSlider`,titleText:`${R}-titleText`,leftPanelButton:`${R}-leftPanelButton`,rightPanelButton:`${R}-leftPanelButton`},Gt=r.styled("div",{shouldForwardProp:e=>!["leftPanel","rightPanel"].includes(e),name:R})(({theme:e,leftPanel:t,rightPanel:o})=>{var i,a;return{width:"100%",[`& .${E.topStripe}`]:{width:"100%",height:`${zt}px`,backgroundColor:e.palette.primary.main},[`& .${E.titleBar}`]:{backgroundColor:e.palette.primary.light,height:`${Ut}px`,padding:e.spacing(0,3),width:"100%"},[`& .${E.titleSlider}`]:l(l({height:"100%",display:"flex",alignItems:"center",color:"white",transition:e.transitions.create("margin",{easing:e.transitions.easing.sharp,duration:e.transitions.duration.leavingScreen}),[`& .${E.leftPanelButton}`]:{marginRight:e.spacing(2),flexGrow:0},[`& .${E.titleText}`]:{flexGrow:1},[`& .${E.rightPanelButton}`]:{flexGrow:0}},(t==null?void 0:t.open)&&{transition:e.transitions.create("margin",{easing:e.transitions.easing.easeOut,duration:e.transitions.duration.enteringScreen}),marginLeft:`${(i=t==null?void 0:t.width)!=null?i:0}px`}),(o==null?void 0:o.open)&&{transition:e.transitions.create("margin",{easing:e.transitions.easing.easeOut,duration:e.transitions.duration.enteringScreen}),marginRight:`${(a=o==null?void 0:o.width)!=null?a:0}px`})}});function Vt({titleText:e="",leftPanel:t,rightPanel:o,"data-testid":i}){return n.jsxs(Gt,{leftPanel:t,rightPanel:o,"data-testid":i,children:[n.jsx("div",{className:E.topStripe}),n.jsx("div",{className:E.titleBar,children:n.jsxs(r.Box,{className:E.titleSlider,children:[t!==void 0&&!t.open&&t.showOpenArrow&&n.jsxs(r.IconButton,{className:E.leftPanelButton,color:"inherit","aria-label":"Open left side panel",onClick:t==null?void 0:t.onOpen,edge:"start",size:"large",children:[" ",n.jsx(W.ArrowForward,{})]}),n.jsx(r.Typography,{className:E.titleText,variant:"h6",noWrap:!0,children:e}),o!==void 0&&!o.open&&o.showOpenArrow&&n.jsxs(r.IconButton,{className:E.rightPanelButton,color:"inherit","aria-label":"Open right side panel",onClick:o==null?void 0:o.onOpen,edge:"end",size:"large",children:[" ",n.jsx(W.ArrowBack,{})]})]})})]})}const Qe=400,Qt=r.styled(r.Drawer,{shouldForwardProp:e=>!["width","debug","debugOpacity","navBarOpen","navBarWidthOpen","navBarWidthClosed"].includes(e),name:"SidePanelDrawer"})(({width:e,debugOpacity:t=!1,anchor:o,navBarOpen:i,navBarWidthOpen:a,navBarWidthClosed:s})=>({width:e,"& .MuiDrawer-paper":l(l({position:"absolute",width:e,boxSizing:"border-box",border:"unset",boxShadow:"0px 4px 5px rgba(0, 0, 0, 0.14), 0px 1px 10px rgba(0, 0, 0, 0.12), 0px 2px 4px rgba(0, 0, 0, 0.2)"},t&&{opacity:"50%"}),o==="left"&&l({marginLeft:`${s}px`},i&&{marginLeft:`${a}px`}))})),Xt=r.styled(r.Box,{shouldForwardProp:e=>!["anchor"].includes(e)})(({theme:e,anchor:t})=>j(l({display:"flex",alignItems:"center",padding:e.spacing(2)},e.mixins.toolbar),{justifyContent:t==="left"?"space-between":"flex-start",backgroundColor:e.palette.primary.light,height:"88px","&,*":{color:"white"}," .MuiTypography-root":{fontSize:"22px"}," .MuiButtonBase-root":{marginRight:t==="right"?e.spacing(2):0}}));function Ie({children:e,anchor:t="left",open:o,onClose:i=()=>{},titleText:a="",width:s=Qe,showCloseArrow:d=!0,debugOpacity:u=!1,headerBoxProps:c={},onOpened:p,onClosed:C,"data-testid":A,navBarOpen:w=!1,navBarWidthOpen:x=0,navBarWidthClosed:b=0}){return n.jsxs(Qt,{SlideProps:{onEntered:()=>p==null?void 0:p(),onExited:()=>C==null?void 0:C()},variant:"persistent",anchor:t,open:o,width:s,debugOpacity:u,"data-testid":A,navBarOpen:w,navBarWidthOpen:x,navBarWidthClosed:b,children:[n.jsx(Xt,j(l({anchor:t},c),{children:t==="left"?n.jsxs(n.Fragment,{children:[n.jsx(r.Typography,{variant:"h6",color:"inherit",component:"div",children:a}),d&&n.jsxs(r.IconButton,{onClick:i,size:"large","aria-label":"Close left side panel",children:[n.jsx(W.ArrowBack,{"data-testid":"arrowbackicon"})," "]})]}):n.jsxs(n.Fragment,{children:[d&&n.jsxs(r.IconButton,{onClick:i,size:"large","aria-label":"Close right side panel",children:[n.jsx(W.ArrowForward,{})," "]}),n.jsx(r.Typography,{variant:"h6",color:"inherit",component:"div",children:a})]})})),e]})}const Yt=T.styled(r.Box,{shouldForwardProp:e=>!["leftPanel","rightPanel"].includes(e),name:"PanelAwareMargins"})(({theme:e,leftPanel:t,rightPanel:o})=>{var i,a;return l(l({transition:e.transitions.create("margin",{easing:e.transitions.easing.sharp,duration:e.transitions.duration.leavingScreen})},(t==null?void 0:t.open)&&{transition:e.transitions.create("margin",{easing:e.transitions.easing.easeOut,duration:e.transitions.duration.enteringScreen}),marginLeft:`${(i=t==null?void 0:t.width)!=null?i:0}px`}),(o==null?void 0:o.open)&&{transition:e.transitions.create("margin",{easing:e.transitions.easing.easeOut,duration:e.transitions.duration.enteringScreen}),marginRight:`${(a=o==null?void 0:o.width)!=null?a:0}px`})}),Kt=T.styled(r.Container,{name:"PageContainer"})(({theme:e})=>({paddingTop:e.spacing(3),paddingBottom:e.spacing(3)})),se=!1,le=!1,K={titleText:"",flavour:"push",width:Qe,arrowButtons:"both",startOpen:!1,open:void 0,onChangeOpen:void 0,content:n.jsx(n.Fragment,{}),onOpened:void 0,onClosed:void 0,dataTestId:void 0};function Jt({children:e,titleText:t="",leftPanel:o,rightPanel:i,sidePanelsAreMutuallyExclusive:a=!0,debugOpacity:s=!1,pageContainerProps:d,pageContentDataTestId:u,topBarDataTestId:c,navBarOpen:p,navBarWidthOpen:C,navBarWidthClosed:A}){const[w,x]=g.useState(se),[b,D]=g.useState(le),[k,f]=g.useState(se),[B,L]=g.useState(le),F=o!==void 0,N=i!==void 0,{titleText:I,content:h,flavour:m,open:$,onChangeOpen:P,width:S,arrowButtons:v,startOpen:_,onOpened:ot,onClosed:rt,dataTestId:it}=o?l(l({},K),o):l({},K),{titleText:at,content:st,flavour:Ae,open:ne,onChangeOpen:we,width:oe,arrowButtons:Q,startOpen:X,onOpened:lt,onClosed:ct,dataTestId:dt}=i?l(l({},K),i):l({},K);g.useEffect(()=>{_!==se&&(x(_),f(_))},[_]),g.useEffect(()=>{X!==le&&(D(X),L(X))},[X]);const re=$===void 0?w:$,ie=ne===void 0?b:ne,Se=M=>{$===void 0&&(x(M),a&&N&&(M?(D(!1),L(b)):D(B))),P&&P(M)},ye=M=>{ne===void 0&&(D(M),a&&F&&(M?(x(!1),f(w)):x(k))),we&&we(M)};return n.jsxs(r.Box,{children:[F&&n.jsx(Ie,{"data-testid":it,anchor:"left",open:re,onClose:()=>Se(!1),width:S,titleText:I,debugOpacity:s,showCloseArrow:v==="both"||v==="close",onOpened:ot,onClosed:rt,navBarOpen:p,navBarWidthOpen:C,navBarWidthClosed:A,children:h}),N&&n.jsx(Ie,{"data-testid":dt,anchor:"right",open:ie,onClose:()=>ye(!1),width:oe,titleText:at,debugOpacity:s,showCloseArrow:Q==="both"||Q==="close",onOpened:lt,onClosed:ct,navBarOpen:p,navBarWidthOpen:C,navBarWidthClosed:A,children:st}),n.jsx(Vt,l(l({titleText:t,"data-testid":c},F&&m==="push"?{leftPanel:{open:re,width:S,onOpen:()=>Se(!0),showOpenArrow:v==="both"||v==="open"}}:{}),N&&Ae==="push"?{rightPanel:{open:ie,width:oe,onOpen:()=>ye(!0),showOpenArrow:Q==="both"||Q==="open"}}:{})),n.jsx(Yt,j(l(l({},m==="push"?{leftPanel:{open:re,width:S}}:{}),Ae==="push"?{rightPanel:{open:ie,width:oe}}:{}),{children:n.jsx(Kt,j(l({"data-testid":u},d),{children:e}))}))]})}const Xe=()=>{const e=r.useTheme();return r.useMediaQuery(e.breakpoints.down("sm"))},Zt=64,en=64,tn=256,z=y.atom(!0),ge=y.atom(tn),xe=y.atom(en),Z=y.atom(""),Ye=y.atom(void 0),fe=y.atom(Zt),me=y.atom(void 0);function nn({links:e}){return n.jsx("div",{children:"LinksMenu not implemented yet"})}const J="Navbar",U={root:`${J}-root`,menuButton:`${J}-menuButton`,hide:`${J}-hide`,content:`${J}-content`},on=T.styled(r.Box,{name:"NavBar"})(({theme:e})=>({[`&.${U.root}`]:{display:"flex"},[`& .${U.menuButton}`]:{marginRight:36},[`& .${U.hide}`]:{display:"none"},[`& .${U.content}`]:{flexGrow:1,padding:e.spacing(3)}})),ee=(e,t,o)=>e.transitions.create(t,{easing:e.transitions.easing.sharp,duration:o==="leaving"?e.transitions.duration.leavingScreen:e.transitions.duration.enteringScreen}),rn=e=>{const t=r.useTheme();return n.jsx(r.Collapse,l({easing:t.transitions.easing.sharp,timeout:{enter:t.transitions.duration.enteringScreen,exit:t.transitions.duration.leavingScreen}},e))},Ke=e=>{var t,o;return{overflowX:"hidden",color:"inherit",backgroundColor:(o=(t=e==null?void 0:e.navBar)==null?void 0:t.backgroundColor)!=null?o:"white"}},Ee=(e,t)=>l({width:t,transition:ee(e,"width","entering")},Ke(e)),$e=(e,t)=>l({width:t,transition:ee(e,"width","leaving")},Ke(e)),an=T.styled(r.Drawer,{shouldForwardProp:e=>!["widthOpen","widthClosed","isSmallScreen"].includes(e)})(({theme:e,open:t,widthOpen:o,widthClosed:i,isSmallScreen:a})=>l(l({flexShrink:0,whiteSpace:"nowrap",boxSizing:"border-box",display:"flex",flexDirection:"column"},t&&j(l({},Ee(e,o)),{backgroundColor:"","& .MuiDrawer-paper":Ee(e,o)})),!t&&j(l({},$e(e,a?o:i)),{backgroundColor:"","& .MuiDrawer-paper":$e(e,a?o:i)})));function sn(e){let t=0;for(let o=0,i=e.length;o<i;o++){const a=e.charCodeAt(o);t=(t<<5)-t+a,t|=0}return t}const Oe=["#A62A21","#7e3794","#0B51C1","#3A6024","#A81563","#B3003C"],ln=e=>e.split(/\s/).map(t=>t.substring(0,1).toUpperCase()).filter(t=>!!t).slice(0,2).join("").toUpperCase();function cn({user:e,domainCode:t,open:o}){const i=r.useTheme();return n.jsxs(r.Box,{sx:{paddingTop:3,display:"flex",alignItems:"center",flexDirection:"column",gap:"0.5rem"},children:[n.jsx(r.Box,{sx:{width:o?"5rem":"2rem",transition:o?ee(i,["width","height"],"entering"):ee(i,["width","height"],"leaving"),aspectRatio:1},children:e!=null&&e.name?n.jsx(r.Avatar,{src:e==null?void 0:e.picture,sx:{width:"100%",height:"100%",bgcolor:Oe[Math.abs(sn(e.name))%Oe.length]},children:ln(e.name)}):n.jsx(r.Avatar,{sx:{width:"100%",height:"100%"}})}),n.jsx(rn,{sx:{width:"100%"},in:o,children:n.jsx(r.Fade,{in:o,children:n.jsxs(r.Box,{width:"100%",display:"flex",flexDirection:"column",alignItems:"center",children:[e!=null&&e.name?n.jsx(r.Typography,{children:e.name}):n.jsx(r.Skeleton,{animation:!1,width:"50%"}),t?n.jsx(r.Typography,{children:t.toUpperCase()}):n.jsx(r.Skeleton,{animation:!1,width:"25%"})]})})})]})}function dn({open:e,widthClosed:t,widthOpen:o,"data-testid":i,top:a,middle:s,bottom:d,user:u,domainCode:c}){const p=Xe(),C=y.useSetAtom(z);return n.jsx(on,{className:U.root,"data-testid":i,children:n.jsxs(an,{open:e,widthOpen:o,widthClosed:t,anchor:"left",variant:p?"temporary":"permanent",PaperProps:{component:"nav"},onClose:()=>{C(!1)},isSmallScreen:p,children:[!p&&n.jsx(r.Toolbar,{}),a&&n.jsxs(r.Box,{flexGrow:"0",children:[a,n.jsx(r.Divider,{variant:"middle"})]}),n.jsx(r.Box,{flexGrow:"1",children:Array.isArray(s)?n.jsx(nn,{links:s}):s}),n.jsxs(r.Box,{flexGrow:"0",children:[n.jsx(r.Divider,{variant:"middle"}),n.jsx(cn,{user:u,domainCode:c,open:e}),d&&n.jsx(n.Fragment,{children:d})]})]})})}function un({children:e,topBarHeight:t,maxWidth:o=!1}){return n.jsx(r.Box,{sx:{overflow:"auto",height:`calc(100vh - ${t}px)`,scrollbarGutter:"stable",flexGrow:1},children:n.jsx(r.Container,{component:"main",id:"main-content",maxWidth:o,sx:{paddingTop:3,paddingBottom:3,flexGrow:1},children:e})})}const pn="TopBar",hn={titleText:`${pn}-titleText`};function gn({titleText:e="",height:t,"data-testid":o,middle:i}){const a=y.useSetAtom(z),s=()=>a(c=>!c),d=r.useTheme(),u=Xe();return n.jsx("header",{"data-testid":o,children:n.jsxs(r.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:t,zIndex:u?0:d.zIndex.drawer+1},children:[n.jsx(r.IconButton,{size:"medium",color:"inherit",sx:{padding:1.5},onClick:s,children:n.jsx(W.ViewHeadline,{fontSize:"medium"})}),n.jsx(r.Typography,{className:hn.titleText,variant:"h6",children:e}),i]})})}function xn({children:e,initialTitleText:t,initialNavBarOpen:o,pageContainerProps:i,pageContentDataTestId:a,topBarDataTestId:s,navBarDataTestId:d,navBarMiddle:u,navBarBottom:c,user:p,domainCode:C}){He.useHydrateAtoms([[z,o!=null?o:!0],[Z,t!=null?t:""]]);const A=y.useAtomValue(z),[w]=y.useAtom(ge),[x]=y.useAtom(xe),b=y.useAtomValue(Z),[D]=y.useAtom(fe),[k]=y.useAtom(Ye),[f]=y.useAtom(me);return n.jsxs(r.Box,{children:[n.jsx(r.CssBaseline,{}),n.jsx(gn,{titleText:b,"data-testid":s,height:D,middle:k}),n.jsxs(r.Box,{sx:{display:"flex"},children:[n.jsx(dn,{open:A,top:f,middle:u,bottom:c,user:p,domainCode:C,widthOpen:w,widthClosed:x,offsetTop:D,"data-testid":d}),n.jsx(un,j(l({"data-testid":a,topBarHeight:D},i),{children:e}))]})]})}const fn={autoHideDuration:6e3,anchorOrigin:{vertical:"top",horizontal:"center"},disableWindowBlurListener:!1},mn={shouldClose:(e,t)=>t!=="clickaway"},Fe={message:"",severity:"info",variant:"standard",progressIndicator:void 0},Pe=100,Ne=2e3,Cn=2e3,vn=(()=>{let e=0;return()=>(e+=1,e)})(),An={borderBottomLeftRadius:"0px",borderBottomRightRadius:"0px"},wn={},Sn={},Ce=g.createContext(null);function Je(s){var d=s,{overrideState:e=wn,overrideActions:t=Sn,shouldClose:o=mn.shouldClose,children:i}=d,a=De(d,["overrideState","overrideActions","shouldClose","children"]);var P;const[{open:u},c]=g.useState({open:!1}),p=g.useRef([]),C=g.useRef(Date.now()),A=g.useRef(0),w=g.useCallback(S=>{c({open:S})},[]),x=g.useCallback((S={})=>{A.current+=1,p.current.length>=Pe&&Date.now()-C.current>=Ne&&(C.current=Date.now(),console.error(`SaladBarProvider: MAX_QUEUE_LENGTH (${Pe}) hit ${A.current} times in last ${Ne}ms)`),A.current=0);const v=l(j(l({},Fe),{key:vn()}),S);return p.current.push(v),p.current.length===1&&c({open:!0}),v.key},[]),b=(S="",v={})=>x(l({message:S,severity:"success"},v)),D=(S="",v={})=>x(l({message:S,severity:"info"},v)),k=(S="",v={})=>x(l({message:S,severity:"warning"},v)),f=(S="",v={})=>x(l({message:S,severity:"error"},v)),B=S=>{const v=p.current.findIndex(_=>_.key===S);if(v!==-1)return v===0?(c({open:!1}),p.current[0]):p.current.splice(v,1)},L=(S,v)=>{o(S,v)&&c({open:!1})},F=()=>{},N=()=>{p.current.shift(),p.current.length>0&&c({open:!0})},I=(P=p.current[0])!=null?P:l({},Fe),h={};"autoHideDuration"in I&&(h.autoHideDuration=I.autoHideDuration);const m=l(l({},fn),a),$=l(l({open:u,setOpen:w,enqueueNotification:x,enqueueSuccessNotification:b,enqueueInfoNotification:D,enqueueWarningNotification:k,enqueueErrorNotification:f,removeNotification:B},e),t);return n.jsxs(Ce.Provider,{value:$,children:[i,n.jsx(r.Snackbar,j(l(l({},m),h),{open:u,onClose:L,TransitionProps:{onExited:N,onExit:F},sx:{zIndex:Cn},children:n.jsxs("div",{children:[n.jsx(r.Alert,{onClose:S=>L(S,"closeAlert"),severity:I.severity,variant:"filled",icon:I.progressIndicator==="circular"?n.jsx(r.CircularProgress,{size:"1em"}):void 0,style:I.progressIndicator==="linear"?An:void 0,children:I.message}),I.progressIndicator==="linear"&&n.jsx(r.LinearProgress,{color:"primary"})]})}))]})}function Ze(){const e=g.useContext(Ce);if(e===null)throw new te("Error: Tried to useSaladBar outside of a <SaladBarProvider>");return e}const yn=G.createHelper((e={autoHideDuration:1},t={},o={})=>({children:i})=>n.jsx(Je,j(l({},e),{overrideState:t,overrideActions:o,children:i}))),et=y.getDefaultStore(),bn=({children:e,store:t})=>n.jsx(y.Provider,{store:t!=null?t:et,children:e}),tt="domainCode";var Le;const _e=y.atom(JSON.parse((Le=localStorage.getItem(tt))!=null?Le:'{"domainCode": ""}').domainCode),ve=y.atom(e=>e(_e),(e,t,o)=>{t(_e,o),localStorage.setItem(tt,JSON.stringify({domainCode:o}))}),jn={act:"ACT",nsw:"NSW",nt:"NT",qld:"QLD",sa:"SA",tas:"TAS",vic:"VIC",wa:"WA",ag:"AG",fedmps:"Fedmps","":""},Dn=e=>{var t;return e===null?"N/A":(t=jn[e])!=null?t:""},Bn=({isLoading:e,isOpen:t,onClose:o,domainOptions:i,applicationName:a,handleLogout:s})=>{const[d,u]=y.useAtom(ve),[c,p]=g.useState(d),{enqueueSuccessNotification:C}=Ze(),A=i.length===0,w=!!d&&!i.includes(d)&&!i.includes(c),x=!d||A||w,b=()=>O(exports,null,function*(){c?(u(c),C(`Set domain to ${c}`),o()):u("")}),D=()=>O(exports,null,function*(){d&&!A&&!w?(p(d),o()):x&&s()});let k;return A?k="Unable to retrieve your active organisations. Try logging in again.":w&&(k="You no longer have any roles in your chosen organisation. Please choose another."),n.jsxs(pe,{isOpen:t,dialogTitle:"Select an organisation",primaryButton:{text:"Confirm",onClick:b,disabled:!c||A||w,buttonColor:"primary"},secondaryButton:{text:x?"Logout":"Cancel",onClick:D},onClose:x?()=>{}:o,children:[n.jsxs(r.Typography,{marginBottom:2,children:["Select the default organisation that you want to use with the ",a,"."]}),n.jsx(r.Autocomplete,{loading:e,multiple:!1,disableClearable:!1,value:c!==""?c:null,onChange:(f,B)=>p(B!=null?B:""),getOptionLabel:Dn,options:[...i],renderInput:f=>n.jsx(r.TextField,j(l({},f),{variant:"filled",label:"Select organisation",InputProps:j(l({},f.InputProps),{endAdornment:n.jsxs(n.Fragment,{children:[e?n.jsx(r.CircularProgress,{color:"inherit",size:20,sx:{marginTop:"-20px"}}):null,f.InputProps.endAdornment]})})}))}),k&&n.jsx(r.FormHelperText,{error:!0,children:k})]})},kn=T.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"}}),Tn=T.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:T.alpha(e.palette.secondary.main,e.palette.action.selectedOpacity),"&:hover":{backgroundColor:T.alpha(e.palette.secondary.main,e.palette.action.selectedOpacity)},"&.Mui-focusVisible":{backgroundColor:T.alpha(e.palette.secondary.main,e.palette.action.focusOpacity)}}})}}},typography:{explainer:{fontSize:"14px",marginBlockStart:"1em"},h3:{fontSize:"1rem",fontWeight:700}},navBar:{backgroundColor:"#E8E8E8"}}),In={domainCode:ve,navBarOpen:z,navBarWidthOpen:ge,navBarWidthClosed:xe,titleText:Z,topBarHeight:fe,navBarTop:me},En=G.createHelper(()=>({children:e})=>n.jsx(y.Provider,{children:e})),nt=({initialValues:e,children:t})=>(He.useHydrateAtoms(e),n.jsx(n.Fragment,{children:t})),$n=G.createHelper(e=>({children:t})=>n.jsx(nt,{initialValues:Object.entries(e).map(([o,i])=>[In[o],i]),children:t})),On=G.createHelper(()=>({children:e})=>{const t=new ce.QueryClient;return n.jsx(ce.QueryClientProvider,{client:t,children:e})});exports.AgDialog=pe;exports.AppLayout=xn;exports.AtomProvider=bn;exports.AuthGuard=Wt;exports.Context=Ce;exports.ContextError=te;exports.DomainCodeDialog=Bn;exports.ExampleComponent=jt;exports.FetchAutocomplete=Nt;exports.HydrateAtoms=nt;exports.NAVBAR_WIDTH_CLOSED=ue;exports.NAVBAR_WIDTH_OPENED=de;exports.NavBar=Pt;exports.NavBarDarkStyledList=Ot;exports.NavBarLightStyledList=Ft;exports.NavBarProvider=ze;exports.PageLayout=Jt;exports.SaladBarProvider=Je;exports.SessionExpiryDialog=Lt;exports.SingleAutocomplete=_t;exports.atomStore=et;exports.buildNavBarState=Ge;exports.domainCodeAtom=ve;exports.fed21Theme=kn;exports.getAuth0Expiry=Ve;exports.internalAgSystemsTheme=Tn;exports.navBarClasses=q;exports.navBarOpenAtom=z;exports.navBarTopAtom=me;exports.navBarWidthClosedAtom=xe;exports.navBarWidthOpenAtom=ge;exports.titleTextAtom=Z;exports.topBarHeightAtom=fe;exports.topBarMiddleAtom=Ye;exports.useAutocompleteOptions=he;exports.useNavBar=Ue;exports.useSaladBar=Ze;exports.withAtomProvider=En;exports.withNavBarProvider=$t;exports.withOverrideDefaults=$n;exports.withQueryClient=On;exports.withSaladBarProvider=yn;
|
|
1
|
+
"use strict";var ut=Object.defineProperty,pt=Object.defineProperties;var ht=Object.getOwnPropertyDescriptors;var Y=Object.getOwnPropertySymbols;var be=Object.prototype.hasOwnProperty,je=Object.prototype.propertyIsEnumerable;var ae=(e,t,o)=>t in e?ut(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,l=(e,t)=>{for(var o in t||(t={}))be.call(t,o)&&ae(e,o,t[o]);if(Y)for(var o of Y(t))je.call(t,o)&&ae(e,o,t[o]);return e},j=(e,t)=>pt(e,ht(t));var De=(e,t)=>{var o={};for(var i in e)be.call(e,i)&&t.indexOf(i)<0&&(o[i]=e[i]);if(e!=null&&Y)for(var i of Y(e))t.indexOf(i)<0&&je.call(e,i)&&(o[i]=e[i]);return o};var Be=(e,t,o)=>(ae(e,typeof t!="symbol"?t+"":t,o),o);var O=(e,t,o)=>new Promise((i,a)=>{var s=c=>{try{u(o.next(c))}catch(p){a(p)}},d=c=>{try{u(o.throw(c))}catch(p){a(p)}},u=c=>c.done?i(c.value):Promise.resolve(c.value).then(s,d);u((o=o.apply(e,t)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),g=require("react"),r=require("@mui/material"),gt=require("@mui/material/CssBaseline"),T=require("@mui/material/styles"),xt=require("@australiangreens/ag-error"),G=require("souvlaki"),ft=require("@mui/material/List"),W=require("@mui/icons-material"),mt=require("autosuggest-highlight/match"),Ct=require("autosuggest-highlight/parse"),ce=require("@tanstack/react-query"),Me=require("@auth0/auth0-react"),vt=require("buffer"),At=require("@mui/material/Skeleton"),y=require("jotai"),He=require("jotai/utils"),V=e=>e&&e.__esModule?e:{default:e},wt=V(gt),Re=V(ft),St=V(mt),yt=V(Ct),bt=V(At);function jt({text:e}){const[t,o]=g.useState(0);return n.jsxs(n.Fragment,{children:[n.jsx(r.Typography,{variant:"h6",color:"inherit",component:"div",sx:{fontSize:"22px"},children:"Hello world"}),n.jsx(r.Typography,{variant:"caption",display:"block",children:n.jsx("span",{children:"Just ensuring MUI is working as planned as a peer dependency. v0.0.11"})}),n.jsx(r.Button,{variant:"outlined",onClick:()=>o(i=>i+1),"aria-label":"Increment",children:"Hello I am a button"}),n.jsxs("p",{children:["This is some text: ",n.jsx("span",{children:e})]}),n.jsxs(r.Paper,{children:["This number will incremember when button pressed: ",t]})]})}const de=330,ue=73,H="Navbar",q={root:`${H}-root`,menuButton:`${H}-menuButton`,hide:`${H}-hide`,content:`${H}-content`,userInfoHolder:`${H}-userInfoHolder`,settings:`${H}-settings`,pieChartIcon:`${H}-pieChartIcon`},Dt=T.styled(r.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)},[`& .${q.userInfoHolder}`]:{height:"148px",marginTop:"64px",marginBottom:"16px"}})),qe=()=>({position:"absolute",height:"100%",overflowX:"hidden",overflowY:"hidden",color:"white",backgroundColor:"black"}),Bt=()=>l({width:de},qe()),kt=()=>l({width:ue},qe()),Tt=T.styled(r.Drawer,{shouldForwardProp:e=>e!=="open"})(({theme:e,open:t})=>l(l({width:t?de:ue,flexShrink:0,whiteSpace:"nowrap",boxSizing:"border-box",zIndex:e.zIndex.drawer+100},t&&{"& .MuiDrawer-paper":Bt()}),!t&&{"& .MuiDrawer-paper":kt()}));class te extends xt.AgError{}Be(te,"errorName","ContextError");const We=g.createContext(null),It={},Et={},ze=({overrideState:e=It,overrideActions:t=Et,children:o})=>{const[{open:i},a]=g.useState({open:!0}),s=g.useCallback(c=>{a({open:c})},[]),d=g.useCallback(()=>{a(c=>j(l({},c),{open:!c.open}))},[]),u=l(l({open:i,setOpen:s,toggleOpen:d},e),t);return n.jsx(We.Provider,{value:u,children:o})},Ue=()=>{const e=g.useContext(We);if(e===null)throw new te("Error: Tried to useNavBar outside of a <NavBarProvider>");return e},Ge=(e={})=>l({open:!0},e),$t=G.createHelper((e=Ge(),t={})=>({children:o})=>n.jsx(ze,{overrideState:e,overrideActions:t,children:o})),ke=7,Ot=T.styled(Re.default)(({theme:e})=>({backgroundColor:"black",color:"white","& .MuiListItem-root":{padding:"unset"},"& .MuiListItemButton-root":{" .MuiListItemIcon-root":{color:"white",padding:`${ke}px`},"&.Mui-focusVisible":{backgroundColor:e.palette.grey[700]},"&.Mui-selected":{borderLeftStyle:"solid",borderLeftWidth:"7px",borderLeftColor:e.palette.primary.main,paddingLeft:`calc(${e.spacing(2)} - ${ke}px)`},"&:hover":{backgroundColor:e.palette.primary.dark},"&.Mui-selected.Mui-focusVisible":{backgroundColor:e.palette.grey[700]},"&.Mui-selected:hover":{backgroundColor:e.palette.primary.dark}}})),Te=7,Ft=T.styled(Re.default)(({theme:e})=>({backgroundColor:"#e8e8e8",color:"inherit","& .MuiListItem-root":{padding:"unset"},"& .MuiListItemButton-root":{" .MuiListItemIcon-root":{color:"inherit",padding:`${Te}px`},"&.Mui-focusVisible":{backgroundColor:e.palette.grey[700]},"&.Mui-selected":{borderLeftStyle:"solid",borderLeftWidth:"7px",borderLeftColor:e.palette.primary.main,paddingLeft:`calc(${e.spacing(2)} - ${Te}px)`},"&:hover":{backgroundColor:e.palette.primary.dark},"&.Mui-selected.Mui-focusVisible":{backgroundColor:e.palette.grey[700]},"&.Mui-selected:hover":{backgroundColor:e.palette.primary.dark}}}));function Pt({"data-testid":e,children:t}){const{open:o}=Ue();return n.jsxs(Dt,{className:q.root,"data-testid":e,children:[n.jsx(wt.default,{}),n.jsx(Tt,{variant:"permanent",anchor:"left",transitionDuration:null,open:o,children:t})]})}const pe=({isOpen:e,dialogTitle:t,children:o,maxWidth:i,primaryButton:a,secondaryButton:s,onClose:d,sx:u,"data-testid":c,disableCloseOnBackdropOrEscape:p=!1})=>{var w,x;const[C,A]=g.useState(!1);return n.jsxs(r.Dialog,{open:e,onClose:(b,D)=>O(exports,null,function*(){p&&(D==="backdropClick"||D==="escapeKeyDown")||C||(s!=null&&s.onClick?yield s.onClick():d())}),fullWidth:!0,maxWidth:i!=null?i:"xs","data-testid":c,sx:u,children:[n.jsx(r.DialogTitle,{children:t}),n.jsx(r.DialogContent,{sx:{"& > :last-child":{marginBottom:0}},children:o}),n.jsxs(r.DialogActions,{children:[n.jsx(r.Button,{onClick:(w=s==null?void 0:s.onClick)!=null?w:d,"data-testid":s==null?void 0:s.testId,disabled:(s==null?void 0:s.disabled)||C,color:s==null?void 0:s.buttonColor,children:(x=s==null?void 0:s.text)!=null?x:"Cancel"}),a&&n.jsx(r.Button,{onClick:()=>O(exports,null,function*(){var b;A(!0),yield(b=a.onClick)==null?void 0:b.call(a),A(!1)}),"data-testid":a.testId,disabled:a.disabled||C,color:a==null?void 0:a.buttonColor,children:a.text})]})]})},he=({minLength:e,preLoadedOptions:t,lookup:o,label:i,inputValue:a})=>ce.useQuery({queryFn:()=>e&&a.length<e?t!=null?t:[]:t?t.filter(s=>s.label.toLowerCase().includes(a.toLowerCase())):o(a),queryKey:["autocomplete",i,a]});function Nt({lookup:e=()=>O(this,null,function*(){}),enableHighlighting:t=!0,onChange:o,minLength:i=0,label:a,value:s,"data-testid":d,sx:u,textFieldColor:c,textFieldVariant:p="filled",loadingText:C="Loading...",noOptionsText:A="No options",popupIcon:w=n.jsx(W.ArrowDropDown,{}),error:x=!1,helperText:b="",preLoadedOptions:D=void 0,disablePortal:k=!1}){const[f,B]=g.useState(""),L=(h,m)=>{const $=s.filter(P=>P.id!==m);o($,"delete",h)},{data:F,isLoading:N}=he({inputValue:f,label:a,lookup:e,minLength:i,preLoadedOptions:D}),I=f.length>=i;return n.jsxs("div",{"data-testid":d,children:[n.jsx(r.Autocomplete,{sx:u,"data-testid":d?`${d}:Autocomplete`:void 0,disablePortal:k,multiple:!0,getOptionLabel:h=>typeof h=="string"?h:h.label,loading:I?N:!1,options:[...s,...F!=null?F:[]],filterSelectedOptions:!0,includeInputInList:!0,value:s,onChange:(h,m,$)=>{o(m,$,h)},onInputChange:(h,m)=>B(m),noOptionsText:I?A:"Start typing to search",loadingText:C,popupIcon:w,renderInput:h=>n.jsx(r.TextField,j(l({},h),{label:a,fullWidth:!0,variant:p,error:x,helperText:b,InputProps:j(l({},h.InputProps),{endAdornment:n.jsxs(n.Fragment,{children:[N?n.jsx(r.CircularProgress,{color:"inherit",size:20}):null,h.InputProps.endAdornment]})}),"data-testid":d?`${d}:Autocomplete:TextField`:void 0,onKeyDown:m=>{(m.key==="Backspace"||m.key==="Delete")&&m.stopPropagation()},color:c})),renderTags:()=>null,isOptionEqualToValue:(h,m)=>h.id===m.id,renderOption:(h,m,$)=>{if(t){const P=St.default(m.label,$.inputValue,{insideWords:!0,findAllOccurrences:!0}),S=yt.default(m.label,P);return g.createElement("li",j(l({},h),{key:m.id,"data-testid":d?`${d}:Autocomplete:option(${m.id.toString()})`:void 0}),n.jsx("div",{children:S.map((v,_)=>n.jsx("span",{style:{fontWeight:v.highlight?700:400},children:v.text},_))}))}else return g.createElement("li",j(l({},h),{key:m.id,"data-testid":d?`${d}:option(${m.id.toString()})`:void 0}),m.label)}}),s.length>0&&n.jsx(r.Box,{children:s.map(h=>n.jsx(r.Chip,{sx:{marginTop:1,marginRight:1,height:"auto"},label:n.jsx(r.Tooltip,{title:h.tooltipContent||"",placement:"bottom-start",PopperProps:{modifiers:[{name:"offset",options:{offset:[115,-15]}}]},children:n.jsx(r.Typography,{style:{whiteSpace:"normal"},children:h.chipLabel?h.chipLabel:h.label})}),"data-testid":d?`${d}:Chip(${h.id.toString()})`:void 0,onDelete:m=>L(m,h.id),deleteIcon:n.jsx(W.Cancel,{"data-testid":d?`${d}:Chip(${h.id.toString()}):deleteIcon`:void 0})},h.id))})]})}const _t=({lookup:e=()=>O(exports,null,function*(){}),onChange:t,label:o,value:i,sx:a,textFieldColor:s,textFieldVariant:d="filled","data-testid":u,noOptionsText:c="No options",minLength:p=3,disablePortal:C=!1,preLoadedOptions:A})=>{const[w,x]=g.useState(""),{data:b,isLoading:D}=he({inputValue:w,label:o,lookup:e,minLength:p!=null?p:0,preLoadedOptions:A}),k=w.length>=p;return n.jsx("div",{"data-testid":u,children:n.jsx(r.Stack,{direction:"row",spacing:1,children:n.jsx(r.Autocomplete,{sx:a,"data-testid":u?`${u}:Autocomplete`:void 0,loading:k?D:!1,options:b!=null?b:[],onChange:(f,B)=>{t(f,B)},disablePortal:C,filterOptions:f=>f,value:i,noOptionsText:k?c:"Start typing to search",getOptionLabel:f=>f.label,renderInput:f=>n.jsx(r.TextField,j(l({"data-testid":u?`${u}:Autocomplete:TextField`:void 0},f),{variant:d,label:o,color:s})),isOptionEqualToValue:(f,B)=>f.id===B.id,onInputChange:(f,B)=>{x(B)},renderOption:(f,B)=>g.createElement("li",j(l({},f),{key:B.id,"data-testid":u?`${u}:Autocomplete:option(${B.id.toString()})`:void 0}),B.label)})})})},Ve=e=>{if(!e)return-1;try{const o=e.split(".")[1].replace(/-/g,"+").replace(/_/g,"/"),i=decodeURIComponent(vt.Buffer.from(o,"base64").toString("utf8").split("").map(function(s){return"%"+("00"+s.charCodeAt(0).toString(16)).slice(-2)}).join("")),a=JSON.parse(i);return a!=null&&a.exp?a.exp:-1}catch(t){return-1}},Lt=({open:e=!1,closeHandler:t,setAuth0ExpiryTime:o})=>{const{logout:i,getAccessTokenSilently:a}=Me.useAuth0(),[s,d]=g.useState(0),u=()=>O(exports,null,function*(){i({logoutParams:{returnTo:`${window.location.origin}`}})}),c=()=>O(exports,null,function*(){d(s+1),t()});g.useEffect(()=>{(()=>O(exports,null,function*(){if(s>0){const w=yield a({cacheMode:"off"}),x=Ve(w)*1e3;o(x)}}))()},[s,a,o]);const p={text:"Continue",onClick:c,disabled:!1,testId:"PreferencesDialog",buttonColor:"secondary"},C={text:"Log out",onClick:u,disabled:!1,testId:"PreferencesDialog",buttonColor:"secondary"};return n.jsx(pe,{isOpen:e,primaryButton:p,secondaryButton:C,onClose:t,dialogTitle:"Session expiry",disableCloseOnBackdropOrEscape:!0,children:n.jsx("p",{style:{marginBottom:0},children:"Your session is about to time out due to inactivity. Do you want to continue?"})})};function Mt(e){return"error"in e}function Ht(e){return e.error==="access_denied"}function Rt(e){var i;const t=e.error,o=(i=e==null?void 0:e.error_description)!=null?i:"";return t==="access_denied"&&o.startsWith("You do not have the required authorization")}function qt(e){var i;const t=e.error,o=(i=e==null?void 0:e.error_description)!=null?i:"";return t==="access_denied"&&o.startsWith("User did not authorize the request")}function Wt({children:e,appName:t="the app"}){const{isAuthenticated:o,isLoading:i,error:a,loginWithRedirect:s,logout:d}=Me.useAuth0();if(g.useEffect(()=>{if(i||o||a)return;const u={appState:{returnTo:`${window.location.pathname}${window.location.search}`}};s(u)},[i,o,a,s]),a&&Mt(a)){let u="Auth error",c="An unknown Auth0 error occurred.";return Rt(a)?(u="Unauthorised",c=`You are not authorised to access ${t}.`):qt(a)?(u="App not authorised",c=`You have not authorised ${t} to access your user profile. This is necessary to use ${t}.`):Ht(a)&&(u="Unauthorised",c="Authorisation with auth0 failed for an unknown reason."),n.jsxs(r.Dialog,{open:!0,children:[n.jsx(r.DialogTitle,{children:u}),n.jsx(r.DialogContent,{children:n.jsx(r.Typography,{children:c})}),n.jsx(r.DialogActions,{children:n.jsx(r.Button,{onClick:()=>d({logoutParams:{returnTo:window.location.origin}}),children:"Logout"})})]})}return o?n.jsx(n.Fragment,{children:e}):n.jsx(bt.default,{variant:"rectangular",animation:"pulse",height:"100vh",width:"100vw"})}const zt=24,Ut=64,R="TopBar",E={topStripe:`${R}-topStripe`,titleBar:`${R}-titleBar`,titleSlider:`${R}-titleSlider`,titleText:`${R}-titleText`,leftPanelButton:`${R}-leftPanelButton`,rightPanelButton:`${R}-leftPanelButton`},Gt=r.styled("div",{shouldForwardProp:e=>!["leftPanel","rightPanel"].includes(e),name:R})(({theme:e,leftPanel:t,rightPanel:o})=>{var i,a;return{width:"100%",[`& .${E.topStripe}`]:{width:"100%",height:`${zt}px`,backgroundColor:e.palette.primary.main},[`& .${E.titleBar}`]:{backgroundColor:e.palette.primary.light,height:`${Ut}px`,padding:e.spacing(0,3),width:"100%"},[`& .${E.titleSlider}`]:l(l({height:"100%",display:"flex",alignItems:"center",color:"white",transition:e.transitions.create("margin",{easing:e.transitions.easing.sharp,duration:e.transitions.duration.leavingScreen}),[`& .${E.leftPanelButton}`]:{marginRight:e.spacing(2),flexGrow:0},[`& .${E.titleText}`]:{flexGrow:1},[`& .${E.rightPanelButton}`]:{flexGrow:0}},(t==null?void 0:t.open)&&{transition:e.transitions.create("margin",{easing:e.transitions.easing.easeOut,duration:e.transitions.duration.enteringScreen}),marginLeft:`${(i=t==null?void 0:t.width)!=null?i:0}px`}),(o==null?void 0:o.open)&&{transition:e.transitions.create("margin",{easing:e.transitions.easing.easeOut,duration:e.transitions.duration.enteringScreen}),marginRight:`${(a=o==null?void 0:o.width)!=null?a:0}px`})}});function Vt({titleText:e="",leftPanel:t,rightPanel:o,"data-testid":i}){return n.jsxs(Gt,{leftPanel:t,rightPanel:o,"data-testid":i,children:[n.jsx("div",{className:E.topStripe}),n.jsx("div",{className:E.titleBar,children:n.jsxs(r.Box,{className:E.titleSlider,children:[t!==void 0&&!t.open&&t.showOpenArrow&&n.jsxs(r.IconButton,{className:E.leftPanelButton,color:"inherit","aria-label":"Open left side panel",onClick:t==null?void 0:t.onOpen,edge:"start",size:"large",children:[" ",n.jsx(W.ArrowForward,{})]}),n.jsx(r.Typography,{className:E.titleText,variant:"h6",noWrap:!0,children:e}),o!==void 0&&!o.open&&o.showOpenArrow&&n.jsxs(r.IconButton,{className:E.rightPanelButton,color:"inherit","aria-label":"Open right side panel",onClick:o==null?void 0:o.onOpen,edge:"end",size:"large",children:[" ",n.jsx(W.ArrowBack,{})]})]})})]})}const Qe=400,Qt=r.styled(r.Drawer,{shouldForwardProp:e=>!["width","debug","debugOpacity","navBarOpen","navBarWidthOpen","navBarWidthClosed"].includes(e),name:"SidePanelDrawer"})(({width:e,debugOpacity:t=!1,anchor:o,navBarOpen:i,navBarWidthOpen:a,navBarWidthClosed:s})=>({width:e,"& .MuiDrawer-paper":l(l({position:"absolute",width:e,boxSizing:"border-box",border:"unset",boxShadow:"0px 4px 5px rgba(0, 0, 0, 0.14), 0px 1px 10px rgba(0, 0, 0, 0.12), 0px 2px 4px rgba(0, 0, 0, 0.2)"},t&&{opacity:"50%"}),o==="left"&&l({marginLeft:`${s}px`},i&&{marginLeft:`${a}px`}))})),Xt=r.styled(r.Box,{shouldForwardProp:e=>!["anchor"].includes(e)})(({theme:e,anchor:t})=>j(l({display:"flex",alignItems:"center",padding:e.spacing(2)},e.mixins.toolbar),{justifyContent:t==="left"?"space-between":"flex-start",backgroundColor:e.palette.primary.light,height:"88px","&,*":{color:"white"}," .MuiTypography-root":{fontSize:"22px"}," .MuiButtonBase-root":{marginRight:t==="right"?e.spacing(2):0}}));function Ie({children:e,anchor:t="left",open:o,onClose:i=()=>{},titleText:a="",width:s=Qe,showCloseArrow:d=!0,debugOpacity:u=!1,headerBoxProps:c={},onOpened:p,onClosed:C,"data-testid":A,navBarOpen:w=!1,navBarWidthOpen:x=0,navBarWidthClosed:b=0}){return n.jsxs(Qt,{SlideProps:{onEntered:()=>p==null?void 0:p(),onExited:()=>C==null?void 0:C()},variant:"persistent",anchor:t,open:o,width:s,debugOpacity:u,"data-testid":A,navBarOpen:w,navBarWidthOpen:x,navBarWidthClosed:b,children:[n.jsx(Xt,j(l({anchor:t},c),{children:t==="left"?n.jsxs(n.Fragment,{children:[n.jsx(r.Typography,{variant:"h6",color:"inherit",component:"div",children:a}),d&&n.jsxs(r.IconButton,{onClick:i,size:"large","aria-label":"Close left side panel",children:[n.jsx(W.ArrowBack,{"data-testid":"arrowbackicon"})," "]})]}):n.jsxs(n.Fragment,{children:[d&&n.jsxs(r.IconButton,{onClick:i,size:"large","aria-label":"Close right side panel",children:[n.jsx(W.ArrowForward,{})," "]}),n.jsx(r.Typography,{variant:"h6",color:"inherit",component:"div",children:a})]})})),e]})}const Yt=T.styled(r.Box,{shouldForwardProp:e=>!["leftPanel","rightPanel"].includes(e),name:"PanelAwareMargins"})(({theme:e,leftPanel:t,rightPanel:o})=>{var i,a;return l(l({transition:e.transitions.create("margin",{easing:e.transitions.easing.sharp,duration:e.transitions.duration.leavingScreen})},(t==null?void 0:t.open)&&{transition:e.transitions.create("margin",{easing:e.transitions.easing.easeOut,duration:e.transitions.duration.enteringScreen}),marginLeft:`${(i=t==null?void 0:t.width)!=null?i:0}px`}),(o==null?void 0:o.open)&&{transition:e.transitions.create("margin",{easing:e.transitions.easing.easeOut,duration:e.transitions.duration.enteringScreen}),marginRight:`${(a=o==null?void 0:o.width)!=null?a:0}px`})}),Kt=T.styled(r.Container,{name:"PageContainer"})(({theme:e})=>({paddingTop:e.spacing(3),paddingBottom:e.spacing(3)})),se=!1,le=!1,K={titleText:"",flavour:"push",width:Qe,arrowButtons:"both",startOpen:!1,open:void 0,onChangeOpen:void 0,content:n.jsx(n.Fragment,{}),onOpened:void 0,onClosed:void 0,dataTestId:void 0};function Jt({children:e,titleText:t="",leftPanel:o,rightPanel:i,sidePanelsAreMutuallyExclusive:a=!0,debugOpacity:s=!1,pageContainerProps:d,pageContentDataTestId:u,topBarDataTestId:c,navBarOpen:p,navBarWidthOpen:C,navBarWidthClosed:A}){const[w,x]=g.useState(se),[b,D]=g.useState(le),[k,f]=g.useState(se),[B,L]=g.useState(le),F=o!==void 0,N=i!==void 0,{titleText:I,content:h,flavour:m,open:$,onChangeOpen:P,width:S,arrowButtons:v,startOpen:_,onOpened:ot,onClosed:rt,dataTestId:it}=o?l(l({},K),o):l({},K),{titleText:at,content:st,flavour:Ae,open:ne,onChangeOpen:we,width:oe,arrowButtons:Q,startOpen:X,onOpened:lt,onClosed:ct,dataTestId:dt}=i?l(l({},K),i):l({},K);g.useEffect(()=>{_!==se&&(x(_),f(_))},[_]),g.useEffect(()=>{X!==le&&(D(X),L(X))},[X]);const re=$===void 0?w:$,ie=ne===void 0?b:ne,Se=M=>{$===void 0&&(x(M),a&&N&&(M?(D(!1),L(b)):D(B))),P&&P(M)},ye=M=>{ne===void 0&&(D(M),a&&F&&(M?(x(!1),f(w)):x(k))),we&&we(M)};return n.jsxs(r.Box,{children:[F&&n.jsx(Ie,{"data-testid":it,anchor:"left",open:re,onClose:()=>Se(!1),width:S,titleText:I,debugOpacity:s,showCloseArrow:v==="both"||v==="close",onOpened:ot,onClosed:rt,navBarOpen:p,navBarWidthOpen:C,navBarWidthClosed:A,children:h}),N&&n.jsx(Ie,{"data-testid":dt,anchor:"right",open:ie,onClose:()=>ye(!1),width:oe,titleText:at,debugOpacity:s,showCloseArrow:Q==="both"||Q==="close",onOpened:lt,onClosed:ct,navBarOpen:p,navBarWidthOpen:C,navBarWidthClosed:A,children:st}),n.jsx(Vt,l(l({titleText:t,"data-testid":c},F&&m==="push"?{leftPanel:{open:re,width:S,onOpen:()=>Se(!0),showOpenArrow:v==="both"||v==="open"}}:{}),N&&Ae==="push"?{rightPanel:{open:ie,width:oe,onOpen:()=>ye(!0),showOpenArrow:Q==="both"||Q==="open"}}:{})),n.jsx(Yt,j(l(l({},m==="push"?{leftPanel:{open:re,width:S}}:{}),Ae==="push"?{rightPanel:{open:ie,width:oe}}:{}),{children:n.jsx(Kt,j(l({"data-testid":u},d),{children:e}))}))]})}const Xe=()=>{const e=r.useTheme();return r.useMediaQuery(e.breakpoints.down("sm"))},Zt=64,en=72,tn=256,z=y.atom(!0),ge=y.atom(tn),xe=y.atom(en),Z=y.atom(""),Ye=y.atom(void 0),fe=y.atom(Zt),me=y.atom(void 0);function nn({links:e}){return n.jsx("div",{children:"LinksMenu not implemented yet"})}const J="Navbar",U={root:`${J}-root`,menuButton:`${J}-menuButton`,hide:`${J}-hide`,content:`${J}-content`},on=T.styled(r.Box,{name:"NavBar"})(({theme:e})=>({[`&.${U.root}`]:{display:"flex"},[`& .${U.menuButton}`]:{marginRight:36},[`& .${U.hide}`]:{display:"none"},[`& .${U.content}`]:{flexGrow:1,padding:e.spacing(3)}})),ee=(e,t,o)=>e.transitions.create(t,{easing:e.transitions.easing.sharp,duration:o==="leaving"?e.transitions.duration.leavingScreen:e.transitions.duration.enteringScreen}),rn=e=>{const t=r.useTheme();return n.jsx(r.Collapse,l({easing:t.transitions.easing.sharp,timeout:{enter:t.transitions.duration.enteringScreen,exit:t.transitions.duration.leavingScreen}},e))},Ke=e=>{var t,o;return{overflowX:"hidden",color:"inherit",backgroundColor:(o=(t=e==null?void 0:e.navBar)==null?void 0:t.backgroundColor)!=null?o:"white"}},Ee=(e,t)=>l({width:t,transition:ee(e,"width","entering")},Ke(e)),$e=(e,t)=>l({width:t,transition:ee(e,"width","leaving")},Ke(e)),an=T.styled(r.Drawer,{shouldForwardProp:e=>!["widthOpen","widthClosed","isSmallScreen"].includes(e)})(({theme:e,open:t,widthOpen:o,widthClosed:i,isSmallScreen:a})=>l(l({flexShrink:0,whiteSpace:"nowrap",boxSizing:"border-box",display:"flex",flexDirection:"column"},t&&j(l({},Ee(e,o)),{backgroundColor:"","& .MuiDrawer-paper":Ee(e,o)})),!t&&j(l({},$e(e,a?o:i)),{backgroundColor:"","& .MuiDrawer-paper":$e(e,a?o:i)})));function sn(e){let t=0;for(let o=0,i=e.length;o<i;o++){const a=e.charCodeAt(o);t=(t<<5)-t+a,t|=0}return t}const Oe=["#A62A21","#7e3794","#0B51C1","#3A6024","#A81563","#B3003C"],ln=e=>e.split(/\s/).map(t=>t.substring(0,1).toUpperCase()).filter(t=>!!t).slice(0,2).join("").toUpperCase();function cn({user:e,domainCode:t,open:o}){const i=r.useTheme();return n.jsxs(r.Box,{sx:{paddingTop:3,display:"flex",alignItems:"center",flexDirection:"column",gap:"0.5rem"},children:[n.jsx(r.Box,{sx:{width:o?"5rem":"2rem",transition:o?ee(i,["width","height"],"entering"):ee(i,["width","height"],"leaving"),aspectRatio:1},children:e!=null&&e.name?n.jsx(r.Avatar,{src:e==null?void 0:e.picture,sx:{width:"100%",height:"100%",bgcolor:Oe[Math.abs(sn(e.name))%Oe.length]},children:ln(e.name)}):n.jsx(r.Avatar,{sx:{width:"100%",height:"100%"}})}),n.jsx(rn,{sx:{width:"100%"},in:o,children:n.jsx(r.Fade,{in:o,children:n.jsxs(r.Box,{width:"100%",display:"flex",flexDirection:"column",alignItems:"center",children:[e!=null&&e.name?n.jsx(r.Typography,{children:e.name}):n.jsx(r.Skeleton,{animation:!1,width:"50%"}),t?n.jsx(r.Typography,{children:t.toUpperCase()}):n.jsx(r.Skeleton,{animation:!1,width:"25%"})]})})})]})}function dn({open:e,widthClosed:t,widthOpen:o,"data-testid":i,top:a,middle:s,bottom:d,user:u,domainCode:c}){const p=Xe(),C=y.useSetAtom(z);return n.jsx(on,{className:U.root,"data-testid":i,children:n.jsxs(an,{open:e,widthOpen:o,widthClosed:t,anchor:"left",variant:p?"temporary":"permanent",PaperProps:{component:"nav"},onClose:()=>{C(!1)},isSmallScreen:p,children:[!p&&n.jsx(r.Toolbar,{}),a&&n.jsxs(r.Box,{flexGrow:"0",children:[a,n.jsx(r.Divider,{variant:"middle",sx:{marginY:"0.5rem"}})]}),n.jsx(r.Box,{flexGrow:"1",children:Array.isArray(s)?n.jsx(nn,{links:s}):s}),n.jsxs(r.Box,{flexGrow:"0",children:[n.jsx(r.Divider,{variant:"middle",sx:{marginY:"0.5rem"}}),n.jsx(cn,{user:u,domainCode:c,open:e}),d&&n.jsx(n.Fragment,{children:d})]})]})})}function un({children:e,topBarHeight:t,maxWidth:o=!1}){return n.jsx(r.Box,{sx:{overflow:"auto",height:`calc(100vh - ${t}px)`,scrollbarGutter:"stable",flexGrow:1},children:n.jsx(r.Container,{component:"main",id:"main-content",maxWidth:o,sx:{paddingTop:3,paddingBottom:3,flexGrow:1},children:e})})}const pn="TopBar",hn={titleText:`${pn}-titleText`};function gn({titleText:e="",height:t,"data-testid":o,middle:i}){const a=y.useSetAtom(z),s=()=>a(c=>!c),d=r.useTheme(),u=Xe();return n.jsx("header",{"data-testid":o,children:n.jsxs(r.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:t,zIndex:u?0:d.zIndex.drawer+1},children:[n.jsx(r.IconButton,{size:"medium",color:"inherit",sx:{padding:1.5,marginLeft:"12px"},onClick:s,children:n.jsx(W.ViewHeadline,{fontSize:"medium"})}),n.jsx(r.Typography,{className:hn.titleText,variant:"h6",children:e}),i]})})}function xn({children:e,initialTitleText:t,initialNavBarOpen:o,pageContainerProps:i,pageContentDataTestId:a,topBarDataTestId:s,navBarDataTestId:d,navBarMiddle:u,navBarBottom:c,user:p,domainCode:C}){He.useHydrateAtoms([[z,o!=null?o:!0],[Z,t!=null?t:""]]);const A=y.useAtomValue(z),[w]=y.useAtom(ge),[x]=y.useAtom(xe),b=y.useAtomValue(Z),[D]=y.useAtom(fe),[k]=y.useAtom(Ye),[f]=y.useAtom(me);return n.jsxs(r.Box,{children:[n.jsx(r.CssBaseline,{}),n.jsx(gn,{titleText:b,"data-testid":s,height:D,middle:k}),n.jsxs(r.Box,{sx:{display:"flex"},children:[n.jsx(dn,{open:A,top:f,middle:u,bottom:c,user:p,domainCode:C,widthOpen:w,widthClosed:x,offsetTop:D,"data-testid":d}),n.jsx(un,j(l({"data-testid":a,topBarHeight:D},i),{children:e}))]})]})}const fn={autoHideDuration:6e3,anchorOrigin:{vertical:"top",horizontal:"center"},disableWindowBlurListener:!1},mn={shouldClose:(e,t)=>t!=="clickaway"},Fe={message:"",severity:"info",variant:"standard",progressIndicator:void 0},Pe=100,Ne=2e3,Cn=2e3,vn=(()=>{let e=0;return()=>(e+=1,e)})(),An={borderBottomLeftRadius:"0px",borderBottomRightRadius:"0px"},wn={},Sn={},Ce=g.createContext(null);function Je(s){var d=s,{overrideState:e=wn,overrideActions:t=Sn,shouldClose:o=mn.shouldClose,children:i}=d,a=De(d,["overrideState","overrideActions","shouldClose","children"]);var P;const[{open:u},c]=g.useState({open:!1}),p=g.useRef([]),C=g.useRef(Date.now()),A=g.useRef(0),w=g.useCallback(S=>{c({open:S})},[]),x=g.useCallback((S={})=>{A.current+=1,p.current.length>=Pe&&Date.now()-C.current>=Ne&&(C.current=Date.now(),console.error(`SaladBarProvider: MAX_QUEUE_LENGTH (${Pe}) hit ${A.current} times in last ${Ne}ms)`),A.current=0);const v=l(j(l({},Fe),{key:vn()}),S);return p.current.push(v),p.current.length===1&&c({open:!0}),v.key},[]),b=(S="",v={})=>x(l({message:S,severity:"success"},v)),D=(S="",v={})=>x(l({message:S,severity:"info"},v)),k=(S="",v={})=>x(l({message:S,severity:"warning"},v)),f=(S="",v={})=>x(l({message:S,severity:"error"},v)),B=S=>{const v=p.current.findIndex(_=>_.key===S);if(v!==-1)return v===0?(c({open:!1}),p.current[0]):p.current.splice(v,1)},L=(S,v)=>{o(S,v)&&c({open:!1})},F=()=>{},N=()=>{p.current.shift(),p.current.length>0&&c({open:!0})},I=(P=p.current[0])!=null?P:l({},Fe),h={};"autoHideDuration"in I&&(h.autoHideDuration=I.autoHideDuration);const m=l(l({},fn),a),$=l(l({open:u,setOpen:w,enqueueNotification:x,enqueueSuccessNotification:b,enqueueInfoNotification:D,enqueueWarningNotification:k,enqueueErrorNotification:f,removeNotification:B},e),t);return n.jsxs(Ce.Provider,{value:$,children:[i,n.jsx(r.Snackbar,j(l(l({},m),h),{open:u,onClose:L,TransitionProps:{onExited:N,onExit:F},sx:{zIndex:Cn},children:n.jsxs("div",{children:[n.jsx(r.Alert,{onClose:S=>L(S,"closeAlert"),severity:I.severity,variant:"filled",icon:I.progressIndicator==="circular"?n.jsx(r.CircularProgress,{size:"1em"}):void 0,style:I.progressIndicator==="linear"?An:void 0,children:I.message}),I.progressIndicator==="linear"&&n.jsx(r.LinearProgress,{color:"primary"})]})}))]})}function Ze(){const e=g.useContext(Ce);if(e===null)throw new te("Error: Tried to useSaladBar outside of a <SaladBarProvider>");return e}const yn=G.createHelper((e={autoHideDuration:1},t={},o={})=>({children:i})=>n.jsx(Je,j(l({},e),{overrideState:t,overrideActions:o,children:i}))),et=y.getDefaultStore(),bn=({children:e,store:t})=>n.jsx(y.Provider,{store:t!=null?t:et,children:e}),tt="domainCode";var Le;const _e=y.atom(JSON.parse((Le=localStorage.getItem(tt))!=null?Le:'{"domainCode": ""}').domainCode),ve=y.atom(e=>e(_e),(e,t,o)=>{t(_e,o),localStorage.setItem(tt,JSON.stringify({domainCode:o}))}),jn={act:"ACT",nsw:"NSW",nt:"NT",qld:"QLD",sa:"SA",tas:"TAS",vic:"VIC",wa:"WA",ag:"AG",fedmps:"Fedmps","":""},Dn=e=>{var t;return e===null?"N/A":(t=jn[e])!=null?t:""},Bn=({isLoading:e,isOpen:t,onClose:o,domainOptions:i,applicationName:a,handleLogout:s})=>{const[d,u]=y.useAtom(ve),[c,p]=g.useState(d),{enqueueSuccessNotification:C}=Ze(),A=i.length===0,w=!!d&&!i.includes(d)&&!i.includes(c),x=!d||A||w,b=()=>O(exports,null,function*(){c?(u(c),C(`Set domain to ${c}`),o()):u("")}),D=()=>O(exports,null,function*(){d&&!A&&!w?(p(d),o()):x&&s()});let k;return A?k="Unable to retrieve your active organisations. Try logging in again.":w&&(k="You no longer have any roles in your chosen organisation. Please choose another."),n.jsxs(pe,{isOpen:t,dialogTitle:"Select an organisation",primaryButton:{text:"Confirm",onClick:b,disabled:!c||A||w,buttonColor:"primary"},secondaryButton:{text:x?"Logout":"Cancel",onClick:D},onClose:x?()=>{}:o,children:[n.jsxs(r.Typography,{marginBottom:2,children:["Select the default organisation that you want to use with the ",a,"."]}),n.jsx(r.Autocomplete,{loading:e,multiple:!1,disableClearable:!1,value:c!==""?c:null,onChange:(f,B)=>p(B!=null?B:""),getOptionLabel:Dn,options:[...i],renderInput:f=>n.jsx(r.TextField,j(l({},f),{variant:"filled",label:"Select organisation",InputProps:j(l({},f.InputProps),{endAdornment:n.jsxs(n.Fragment,{children:[e?n.jsx(r.CircularProgress,{color:"inherit",size:20,sx:{marginTop:"-20px"}}):null,f.InputProps.endAdornment]})})}))}),k&&n.jsx(r.FormHelperText,{error:!0,children:k})]})},kn=T.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"}}),Tn=T.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:T.alpha(e.palette.secondary.main,e.palette.action.selectedOpacity),"&:hover":{backgroundColor:T.alpha(e.palette.secondary.main,e.palette.action.selectedOpacity)},"&.Mui-focusVisible":{backgroundColor:T.alpha(e.palette.secondary.main,e.palette.action.focusOpacity)}}})}}},typography:{explainer:{fontSize:"14px",marginBlockStart:"1em"},h3:{fontSize:"1rem",fontWeight:700}},navBar:{backgroundColor:"#E8E8E8"}}),In={domainCode:ve,navBarOpen:z,navBarWidthOpen:ge,navBarWidthClosed:xe,titleText:Z,topBarHeight:fe,navBarTop:me},En=G.createHelper(()=>({children:e})=>n.jsx(y.Provider,{children:e})),nt=({initialValues:e,children:t})=>(He.useHydrateAtoms(e),n.jsx(n.Fragment,{children:t})),$n=G.createHelper(e=>({children:t})=>n.jsx(nt,{initialValues:Object.entries(e).map(([o,i])=>[In[o],i]),children:t})),On=G.createHelper(()=>({children:e})=>{const t=new ce.QueryClient;return n.jsx(ce.QueryClientProvider,{client:t,children:e})});exports.AgDialog=pe;exports.AppLayout=xn;exports.AtomProvider=bn;exports.AuthGuard=Wt;exports.Context=Ce;exports.ContextError=te;exports.DomainCodeDialog=Bn;exports.ExampleComponent=jt;exports.FetchAutocomplete=Nt;exports.HydrateAtoms=nt;exports.NAVBAR_WIDTH_CLOSED=ue;exports.NAVBAR_WIDTH_OPENED=de;exports.NavBar=Pt;exports.NavBarDarkStyledList=Ot;exports.NavBarLightStyledList=Ft;exports.NavBarProvider=ze;exports.PageLayout=Jt;exports.SaladBarProvider=Je;exports.SessionExpiryDialog=Lt;exports.SingleAutocomplete=_t;exports.atomStore=et;exports.buildNavBarState=Ge;exports.domainCodeAtom=ve;exports.fed21Theme=kn;exports.getAuth0Expiry=Ve;exports.internalAgSystemsTheme=Tn;exports.navBarClasses=q;exports.navBarOpenAtom=z;exports.navBarTopAtom=me;exports.navBarWidthClosedAtom=xe;exports.navBarWidthOpenAtom=ge;exports.titleTextAtom=Z;exports.topBarHeightAtom=fe;exports.topBarMiddleAtom=Ye;exports.useAutocompleteOptions=he;exports.useNavBar=Ue;exports.useSaladBar=Ze;exports.withAtomProvider=En;exports.withNavBarProvider=$t;exports.withOverrideDefaults=$n;exports.withQueryClient=On;exports.withSaladBarProvider=yn;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|