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