@australiangreens/ag-internal-components 0.1.3 → 0.1.4
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
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,l=(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},T=(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 c=s=>{try{p(o.next(s))}catch(u){a(u)}},d=s=>{try{p(o.throw(s))}catch(u){a(u)}},p=s=>s.done?r(s.value):Promise.resolve(s.value).then(c,d);p((o=o.apply(e,t)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),g=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"),b=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"),V=e=>e&&e.__esModule?e:{default:e},bt=V(ft),Ue=V(vt),Ie=V(At),Bt=V(wt),Dt=V(St),Tt=V(jt);function kt({text:e}){const[t,o]=g.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=()=>l({width:pe},Ge()),Et=()=>l({width:he},Ge()),Ft=$.styled(i.Drawer,{shouldForwardProp:e=>e!=="open"})(({theme:e,open:t})=>l(l({width:t?pe:he,flexShrink:0,whiteSpace:"nowrap",boxSizing:"border-box",zIndex:e.zIndex.drawer+100},t&&{"& .MuiDrawer-paper":$t()}),!t&&{"& .MuiDrawer-paper":Et()}));class ne extends mt.AgError{}ke(ne,"errorName","ContextError");const Ve=g.createContext(null),Ot={},Pt={},Qe=({overrideState:e=Ot,overrideActions:t=Pt,children:o})=>{const[{open:r},a]=g.useState({open:!0}),c=g.useCallback(s=>{a({open:s})},[]),d=g.useCallback(()=>{a(s=>T(l({},s),{open:!s.open}))},[]),p=l(l({open:r,setOpen:c,toggleOpen:d},e),t);return n.jsx(Ve.Provider,{value:p,children:o})},Xe=()=>{const e=g.useContext(Ve);if(e===null)throw new ne("Error: Tried to useNavBar outside of a <NavBarProvider>");return e},Ye=(e={})=>l({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}}})),Ee=7,Mt=$.styled(Ue.default)(({theme:e})=>({backgroundColor:"#e8e8e8",color:"inherit","& .MuiListItem-root":{padding:"unset"},"& .MuiListItemButton-root":{" .MuiListItemIcon-root":{color:"inherit",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}}}));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",E={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%",[`& .${E.topStripe}`]:{width:"100%",height:`${Ht}px`,backgroundColor:e.palette.primary.main},[`& .${E.titleBar}`]:{backgroundColor:e.palette.primary.light,height:`${qt}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:`${(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:E.topStripe}),n.jsx("div",{className:E.titleBar,children:n.jsxs(i.Box,{className:E.titleSlider,children:[t!==void 0&&!t.open&&t.showOpenArrow&&n.jsxs(i.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(i.Typography,{className:E.titleText,variant:"h6",noWrap:!0,children:e}),o!==void 0&&!o.open&&o.showOpenArrow&&n.jsxs(i.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 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:c})=>({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:`${c}px`},r&&{marginLeft:`${a}px`}))})),Gt=i.styled(i.Box,{shouldForwardProp:e=>!["anchor"].includes(e)})(({theme:e,anchor:t})=>T(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 Fe({children:e,anchor:t="left",open:o,onClose:r=()=>{},titleText:a="",width:c=Ke,showCloseArrow:d=!0,debugOpacity:p=!1,headerBoxProps:s={},onOpened:u,onClosed:f,"data-testid":m,navBarOpen:A=!1,navBarWidthOpen:x=0,navBarWidthClosed:S=0}){return n.jsxs(Ut,{SlideProps:{onEntered:()=>u==null?void 0:u(),onExited:()=>f==null?void 0:f()},variant:"persistent",anchor:t,open:o,width:c,debugOpacity:p,"data-testid":m,navBarOpen:A,navBarWidthOpen:x,navBarWidthClosed:S,children:[n.jsx(Gt,T(l({anchor:t},s),{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 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:`${(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:c=!1,pageContainerProps:d,pageContentDataTestId:p,topBarDataTestId:s,navBarOpen:u,navBarWidthOpen:f,navBarWidthClosed:m}){const[A,x]=g.useState(ce),[S,y]=g.useState(de),[B,k]=g.useState(ce),[I,F]=g.useState(de),O=o!==void 0,D=r!==void 0,{titleText:j,content:_,flavour:L,open:h,onChangeOpen:C,width:v,arrowButtons:w,startOpen:N,onOpened:X,onClosed:oe,dataTestId:st}=o?l(l({},Z),o):l({},Z),{titleText:lt,content:ct,flavour:Se,open:ie,onChangeOpen:ye,width:re,arrowButtons:Y,startOpen:K,onOpened:dt,onClosed:ut,dataTestId:pt}=r?l(l({},Z),r):l({},Z);g.useEffect(()=>{N!==ce&&(x(N),k(N))},[N]),g.useEffect(()=>{K!==de&&(y(K),F(K))},[K]);const ae=h===void 0?A:h,se=ie===void 0?S:ie,je=M=>{h===void 0&&(x(M),a&&D&&(M?(y(!1),F(S)):y(I))),C&&C(M)},be=M=>{ie===void 0&&(y(M),a&&O&&(M?(x(!1),k(A)):x(B))),ye&&ye(M)};return n.jsxs(i.Box,{children:[O&&n.jsx(Fe,{"data-testid":st,anchor:"left",open:ae,onClose:()=>je(!1),width:v,titleText:j,debugOpacity:c,showCloseArrow:w==="both"||w==="close",onOpened:X,onClosed:oe,navBarOpen:u,navBarWidthOpen:f,navBarWidthClosed:m,children:_}),D&&n.jsx(Fe,{"data-testid":pt,anchor:"right",open:se,onClose:()=>be(!1),width:re,titleText:lt,debugOpacity:c,showCloseArrow:Y==="both"||Y==="close",onOpened:dt,onClosed:ut,navBarOpen:u,navBarWidthOpen:f,navBarWidthClosed:m,children:ct}),n.jsx(zt,l(l({titleText:t,"data-testid":s},O&&L==="push"?{leftPanel:{open:ae,width:v,onOpen:()=>je(!0),showOpenArrow:w==="both"||w==="open"}}:{}),D&&Se==="push"?{rightPanel:{open:se,width:re,onOpen:()=>be(!0),showOpenArrow:Y==="both"||Y==="open"}}:{})),n.jsx(Vt,T(l(l({},L==="push"?{leftPanel:{open:ae,width:v}}:{}),Se==="push"?{rightPanel:{open:se,width:re}}:{}),{children:n.jsx(Qt,T(l({"data-testid":p},d),{children:e}))}))]})}const Je=()=>{const e=i.useTheme();return i.useMediaQuery(e.breakpoints.down("sm"))},Yt=64,Kt=72,Jt=256,U=b.atom(!0),ge=b.atom(Jt),xe=b.atom(Kt),te=b.atom(""),Ze=b.atom(void 0),fe=b.atom(Yt),me=b.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,l({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"}},Oe=(e,t)=>l({width:t,transition:z(e,"width","entering")},et(e)),Pe=(e,t)=>l({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})=>l(l({flexShrink:0,whiteSpace:"nowrap",boxSizing:"border-box",display:"flex",flexDirection:"column"},t&&T(l({},Oe(e,o)),{backgroundColor:"","& .MuiDrawer-paper":Oe(e,o)})),!t&&T(l({},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:c,bottom:d,user:p,domainCode:s,useNewAvatar:u=!1}){const f=Je(),m=b.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:f?"temporary":"permanent",PaperProps:{component:"nav"},onClose:()=>{m(!1)},isSmallScreen:f,children:[!f&&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(c)?n.jsx(Zt,{links:c}):c}),n.jsxs(i.Box,{flexGrow:"0",children:[n.jsx(i.Divider,{variant:"middle",sx:{marginY:"0.5rem"}}),n.jsx(rn,{user:p,domainCode:s,open:e,useNewAvatar:u}),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=b.useSetAtom(U),c=()=>a(s=>!s),d=i.useTheme(),p=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:p?0:d.zIndex.drawer+1},children:[n.jsx(i.IconButton,{size:"medium",color:"inherit",sx:{padding:1.5,marginLeft:"12px"},onClick:c,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:c,navBarDataTestId:d,navBarMiddle:p,navBarBottom:s,user:u,domainCode:f,useNewAvatar:m=!1}){We.useHydrateAtoms([[U,o!=null?o:!0],[te,t!=null?t:""]]);const A=b.useAtomValue(U),[x]=b.useAtom(ge),[S]=b.useAtom(xe),y=b.useAtomValue(te),[B]=b.useAtom(fe),[k]=b.useAtom(Ze),[I]=b.useAtom(me);return n.jsxs(i.Box,{children:[n.jsx(i.CssBaseline,{}),n.jsx(dn,{titleText:y,"data-testid":c,height:B,middle:k}),n.jsxs(i.Box,{sx:{display:"flex"},children:[n.jsx(an,{open:A,top:I,middle:p,bottom:s,user:u,domainCode:f,widthOpen:x,widthClosed:S,offsetTop:B,"data-testid":d,useNewAvatar:m}),n.jsx(sn,T(l({"data-testid":a,topBarHeight:B},r),{children:e}))]})]})}const Ce=({isOpen:e,dialogTitle:t,children:o,maxWidth:r,primaryButton:a,secondaryButton:c,onClose:d,sx:p,"data-testid":s,disableCloseOnBackdropOrEscape:u=!1,isLoading:f=!1})=>{var x,S;const[m,A]=g.useState(!1);return n.jsxs(i.Dialog,{open:e,onClose:(y,B)=>P(exports,null,function*(){u&&(B==="backdropClick"||B==="escapeKeyDown")||m||(c!=null&&c.onClick?yield c.onClick():d())}),fullWidth:!0,maxWidth:r!=null?r:"xs","data-testid":s,sx:p,children:[f&&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:(x=c==null?void 0:c.onClick)!=null?x:d,"data-testid":c==null?void 0:c.testId,disabled:(c==null?void 0:c.disabled)||m,color:c==null?void 0:c.buttonColor,children:(S=c==null?void 0:c.text)!=null?S:"Cancel"}),a&&n.jsx(i.Button,{onClick:()=>P(exports,null,function*(){var y;A(!0),yield(y=a.onClick)==null?void 0:y.call(a),A(!1)}),"data-testid":a.testId,disabled:a.disabled||m,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(c=>c.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:c,"data-testid":d,sx:p,boxSx:s,textFieldColor:u,textFieldVariant:f="filled",loadingText:m="Loading...",noOptionsText:A="No options",popupIcon:x=n.jsx(W.ArrowDropDown,{}),error:S=!1,helperText:y="",preLoadedOptions:B=void 0,disablePortal:k=!1,disableIconFlip:I=!1}){const[F,O]=g.useState(""),D=(h,C)=>{const v=c.filter(w=>w.id!==C);o(v,"delete",h)},{data:j,isLoading:_}=ve({inputValue:F,label:a,lookup:e,minLength:r,preLoadedOptions:B}),L=F.length>=r;return n.jsxs("div",{"data-testid":d,children:[n.jsx(i.Autocomplete,{sx:l(l({},p),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:[...c,...j!=null?j:[]],filterSelectedOptions:!0,includeInputInList:!0,value:c,onChange:(h,C,v)=>{o(C,v,h)},onInputChange:(h,C)=>O(C),noOptionsText:L?A:"Start typing to search",loadingText:m,popupIcon:x,renderInput:h=>n.jsx(i.TextField,T(l({},h),{label:a,fullWidth:!0,variant:f,error:S,helperText:y,InputProps:T(l({},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:C=>{(C.key==="Backspace"||C.key==="Delete")&&C.stopPropagation()},color:u})),renderTags:()=>null,isOptionEqualToValue:(h,C)=>h.id===C.id,renderOption:(h,C,v)=>{if(t){const w=Bt.default(C.label,v.inputValue,{insideWords:!0,findAllOccurrences:!0}),N=Dt.default(C.label,w);return g.createElement("li",T(l({},h),{key:C.id,"data-testid":d?`${d}:Autocomplete:option(${C.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",T(l({},h),{key:C.id,"data-testid":d?`${d}:option(${C.id.toString()})`:void 0}),C.label)}}),c.length>0&&n.jsx(i.Box,{sx:s,children:c.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:C=>D(C,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:c,textFieldVariant:d="filled","data-testid":p,noOptionsText:s="No options",minLength:u=3,disablePortal:f=!1,preLoadedOptions:m,helperText:A="",disabled:x,popupIcon:S,disableIconFlip:y})=>{const[B,k]=g.useState(""),{data:I,isLoading:F}=ve({inputValue:B,label:o,lookup:e,minLength:u!=null?u:0,preLoadedOptions:m}),O=B.length>=u;return n.jsx("div",{"data-testid":p,children:n.jsx(i.Stack,{direction:"row",spacing:1,children:n.jsx(i.Autocomplete,{sx:l(l({},a),y?{".MuiAutocomplete-popupIndicatorOpen":{transform:"rotate(0deg)"}}:{}),"data-testid":p?`${p}:Autocomplete`:void 0,loading:O?F:!1,options:I!=null?I:[],onChange:(D,j)=>{t(D,j)},disablePortal:f,filterOptions:D=>D,value:r,noOptionsText:O?s:"Start typing to search",getOptionLabel:D=>D.label,popupIcon:S,renderInput:D=>n.jsx(i.TextField,T(l({"data-testid":p?`${p}:Autocomplete:TextField`:void 0},D),{variant:d,label:o,color:c,helperText:A})),isOptionEqualToValue:(D,j)=>D.id===j.id,onInputChange:(D,j)=>{k(j)},renderOption:(D,j)=>g.createElement("li",T(l({},D),{key:j.id,"data-testid":p?`${p}:Autocomplete:option(${j.id.toString()})`:void 0}),j.label),disabled:x})})})},tt=e=>{if(!e)return-1;try{const o=e.split(".")[1].replace(/-/g,"+").replace(/_/g,"/"),r=decodeURIComponent(yt.Buffer.from(o,"base64").toString("utf8").split("").map(function(c){return"%"+("00"+c.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(),[c,d]=g.useState(0),p=()=>P(exports,null,function*(){r({logoutParams:{returnTo:`${window.location.origin}`}})}),s=()=>P(exports,null,function*(){d(c+1),t()});g.useEffect(()=>{(()=>P(exports,null,function*(){if(c>0){const A=yield a({cacheMode:"off"}),x=tt(A)*1e3;o(x)}}))()},[c,a,o]);const u={text:"Continue",onClick:s,disabled:!1,testId:"PreferencesDialog",buttonColor:"secondary"},f={text:"Log out",onClick:p,disabled:!1,testId:"PreferencesDialog",buttonColor:"secondary"};return n.jsx(Ce,{isOpen:e,primaryButton:u,secondaryButton:f,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(e){var r;const t=e.error,o=(r=e==null?void 0:e.error_description)!=null?r:"";return t==="access_denied"&&o.match(/Script.*time.*exceeded/)}function vn({children:e,appName:t="the app",throwErrors:o="none",disableConsoleLogging:r=!1,onError:a=()=>{},withPopup:c=!1}){var A,x;const{isAuthenticated:d,isLoading:p,error:s,loginWithRedirect:u,loginWithPopup:f,logout:m}=ze.useAuth0();if(g.useEffect(()=>{s&&a(s)},[s,a]),g.useEffect(()=>{if(p||d||s)return;const S={appState:{returnTo:`${window.location.pathname}${window.location.search}`}};c?f():u(S)},[p,d,s,u,a,c,f]),s){if(r||console.error(`Error detected in AuthGuard [isAuthenticated=${d},isLoading=${p}]`,s),o==="all")throw s;if(xn(s)){let S="Auth error",y="An unknown Auth0 error occurred.";if(fn(s))S="Unauthorised",y=`You are not authorised to access ${t}.`;else if(mn(s))S="App not authorised",y=`You have not authorised ${t} to access your user profile. This is necessary to use ${t}.`;else if(Cn(s))S="Auth0 script execution time exceeded",y="The Auth0 login flow exceeded the time limit (20s). Try again in a minute.";else if(o==="unknown")throw s;return n.jsxs(i.Dialog,{open:!0,children:[n.jsx(i.DialogTitle,{children:S}),n.jsxs(i.DialogContent,{children:[n.jsx(i.Typography,{children:y}),n.jsx("br",{}),n.jsx(i.Typography,{variant:"subtitle2",children:"Details from Auth0"}),n.jsxs(i.Typography,{variant:"body2",children:["error: ",(A=s==null?void 0:s.error)!=null?A:"N/A"]}),n.jsxs(i.Typography,{variant:"body2",children:["description: ",(x=s==null?void 0:s.error_description)!=null?x:"N/A"]})]}),n.jsx(i.DialogActions,{children:n.jsx(i.Button,{onClick:()=>m({logoutParams:{returnTo:window.location.origin}}),children:"Logout"})})]})}else if(o==="unknown")throw s}return d?n.jsx(n.Fragment,{children:e}):n.jsx(Tt.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(c){var d=c,{overrideState:e=bn,overrideActions:t=Bn,shouldClose:o=wn.shouldClose,children:r}=d,a=Te(d,["overrideState","overrideActions","shouldClose","children"]);var C;const[{open:p},s]=g.useState({open:!1}),u=g.useRef([]),f=g.useRef(Date.now()),m=g.useRef(0),A=g.useCallback(v=>{s({open:v})},[]),x=g.useCallback((v={})=>{m.current+=1,u.current.length>=Me&&Date.now()-f.current>=Re&&(f.current=Date.now(),console.error(`SaladBarProvider: MAX_QUEUE_LENGTH (${Me}) hit ${m.current} times in last ${Re}ms)`),m.current=0);const w=l(T(l({},Le),{key:yn()}),v);return u.current.push(w),u.current.length===1&&s({open:!0}),w.key},[]),S=(v="",w={})=>x(l({message:v,severity:"success"},w)),y=(v="",w={})=>x(l({message:v,severity:"info"},w)),B=(v="",w={})=>x(l({message:v,severity:"warning"},w)),k=(v="",w={})=>x(l({message:v,severity:"error"},w)),I=v=>{const w=u.current.findIndex(N=>N.key===v);if(w!==-1)return w===0?(s({open:!1}),u.current[0]):u.current.splice(w,1)},F=(v,w)=>{o(v,w)&&s({open:!1})},O=()=>{},D=()=>{u.current.shift(),u.current.length>0&&s({open:!0})},j=(C=u.current[0])!=null?C:l({},Le),_={};"autoHideDuration"in j&&(_.autoHideDuration=j.autoHideDuration);const L=l(l({},An),a),h=l(l({open:p,setOpen:A,enqueueNotification:x,enqueueSuccessNotification:S,enqueueInfoNotification:y,enqueueWarningNotification:B,enqueueErrorNotification:k,removeNotification:I},e),t);return n.jsxs(Ae.Provider,{value:h,children:[r,n.jsx(i.Snackbar,T(l(l({},L),_),{open:p,onClose:F,TransitionProps:{onExited:D,onExit:O},sx:{zIndex:Sn},children:n.jsxs("div",{children:[n.jsx(i.Alert,{onClose:v=>F(v,"closeAlert"),severity:j.severity,variant:"filled",icon:j.progressIndicator==="circular"?n.jsx(i.CircularProgress,{size:"1em"}):void 0,style:j.progressIndicator==="linear"?jn:void 0,children:j.message}),j.progressIndicator==="linear"&&n.jsx(i.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=G.createHelper((e={autoHideDuration:1},t={},o={})=>({children:r})=>n.jsx(nt,T(l({},e),{overrideState:t,overrideActions:o,children:r}))),it=b.getDefaultStore(),Tn=({children:e,store:t})=>n.jsx(b.Provider,{store:t!=null?t:it,children:e}),rt="domainCode";var qe;const He=b.atom(JSON.parse((qe=localStorage.getItem(rt))!=null?qe:'{"domainCode": ""}').domainCode),we=b.atom(e=>e(He),(e,t,o)=>{t(He,o),localStorage.setItem(rt,JSON.stringify({domainCode:o}))}),kn={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=kn[e])!=null?t:""},$n=({isLoading:e,isOpen:t,onClose:o,domainOptions:r,applicationName:a,handleLogout:c})=>{const[d,p]=b.useAtom(we),[s,u]=g.useState(d),{enqueueSuccessNotification:f}=ot(),m=r.length===0,A=!!d&&!r.includes(d)&&!r.includes(s),x=!d||m||A,S=()=>P(exports,null,function*(){s?(p(s),f(`Set organisation to ${s}`),o()):p("")}),y=()=>P(exports,null,function*(){d&&!m&&!A?(u(d),o()):x&&c()});let B;return m?B="Unable to retrieve your active organisations. Try logging in again.":A&&(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:S,disabled:!s||m||A,buttonColor:"primary"},secondaryButton:{text:x?"Logout":"Cancel",onClick:y},onClose:x?()=>{}: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:s!==""?s:null,onChange:(k,I)=>u(I!=null?I:""),getOptionLabel:In,options:[...r],renderInput:k=>n.jsx(i.TextField,T(l({},k),{variant:"filled",label:"Select organisation",InputProps:T(l({},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})]})},En=$.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=$.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"}}),On={domainCode:we,navBarOpen:U,navBarWidthOpen:ge,navBarWidthClosed:xe,titleText:te,topBarHeight:fe,navBarTop:me},Pn=G.createHelper(()=>({children:e})=>n.jsx(b.Provider,{children:e})),at=({initialValues:e,children:t})=>(We.useHydrateAtoms(e),n.jsx(n.Fragment,{children:t})),Nn=G.createHelper(e=>({children:t})=>n.jsx(at,{initialValues:Object.entries(e).map(([o,r])=>[On[o],r]),children:t})),_n=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=Tn;exports.AuthGuard=vn;exports.Context=Ae;exports.ContextError=ne;exports.DomainCodeDialog=$n;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=En;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,l=(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},T=(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 c=s=>{try{p(o.next(s))}catch(u){a(u)}},d=s=>{try{p(o.throw(s))}catch(u){a(u)}},p=s=>s.done?r(s.value):Promise.resolve(s.value).then(c,d);p((o=o.apply(e,t)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),g=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"),b=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"),V=e=>e&&e.__esModule?e:{default:e},bt=V(ft),Ue=V(vt),Ie=V(At),Bt=V(wt),Dt=V(St),Tt=V(jt);function kt({text:e}){const[t,o]=g.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=()=>l({width:pe},Ge()),Et=()=>l({width:he},Ge()),Ft=$.styled(i.Drawer,{shouldForwardProp:e=>e!=="open"})(({theme:e,open:t})=>l(l({width:t?pe:he,flexShrink:0,whiteSpace:"nowrap",boxSizing:"border-box",zIndex:e.zIndex.drawer+100},t&&{"& .MuiDrawer-paper":$t()}),!t&&{"& .MuiDrawer-paper":Et()}));class ne extends mt.AgError{}ke(ne,"errorName","ContextError");const Ve=g.createContext(null),Ot={},Pt={},Qe=({overrideState:e=Ot,overrideActions:t=Pt,children:o})=>{const[{open:r},a]=g.useState({open:!0}),c=g.useCallback(s=>{a({open:s})},[]),d=g.useCallback(()=>{a(s=>T(l({},s),{open:!s.open}))},[]),p=l(l({open:r,setOpen:c,toggleOpen:d},e),t);return n.jsx(Ve.Provider,{value:p,children:o})},Xe=()=>{const e=g.useContext(Ve);if(e===null)throw new ne("Error: Tried to useNavBar outside of a <NavBarProvider>");return e},Ye=(e={})=>l({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}}})),Ee=7,Mt=$.styled(Ue.default)(({theme:e})=>({backgroundColor:"#e8e8e8",color:"inherit","& .MuiListItem-root":{padding:"unset"},"& .MuiListItemButton-root":{" .MuiListItemIcon-root":{color:"inherit",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}}}));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",E={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%",[`& .${E.topStripe}`]:{width:"100%",height:`${Ht}px`,backgroundColor:e.palette.primary.main},[`& .${E.titleBar}`]:{backgroundColor:e.palette.primary.light,height:`${qt}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:`${(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:E.topStripe}),n.jsx("div",{className:E.titleBar,children:n.jsxs(i.Box,{className:E.titleSlider,children:[t!==void 0&&!t.open&&t.showOpenArrow&&n.jsxs(i.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(i.Typography,{className:E.titleText,variant:"h6",noWrap:!0,children:e}),o!==void 0&&!o.open&&o.showOpenArrow&&n.jsxs(i.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 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:c})=>({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:`${c}px`},r&&{marginLeft:`${a}px`}))})),Gt=i.styled(i.Box,{shouldForwardProp:e=>!["anchor"].includes(e)})(({theme:e,anchor:t})=>T(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 Fe({children:e,anchor:t="left",open:o,onClose:r=()=>{},titleText:a="",width:c=Ke,showCloseArrow:d=!0,debugOpacity:p=!1,headerBoxProps:s={},onOpened:u,onClosed:f,"data-testid":m,navBarOpen:w=!1,navBarWidthOpen:x=0,navBarWidthClosed:y=0}){return n.jsxs(Ut,{SlideProps:{onEntered:()=>u==null?void 0:u(),onExited:()=>f==null?void 0:f()},variant:"persistent",anchor:t,open:o,width:c,debugOpacity:p,"data-testid":m,navBarOpen:w,navBarWidthOpen:x,navBarWidthClosed:y,children:[n.jsx(Gt,T(l({anchor:t},s),{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 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:`${(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:c=!1,pageContainerProps:d,pageContentDataTestId:p,topBarDataTestId:s,navBarOpen:u,navBarWidthOpen:f,navBarWidthClosed:m}){const[w,x]=g.useState(ce),[y,C]=g.useState(de),[B,k]=g.useState(ce),[I,F]=g.useState(de),O=o!==void 0,D=r!==void 0,{titleText:j,content:_,flavour:L,open:h,onChangeOpen:v,width:A,arrowButtons:S,startOpen:N,onOpened:X,onClosed:oe,dataTestId:st}=o?l(l({},Z),o):l({},Z),{titleText:lt,content:ct,flavour:Se,open:ie,onChangeOpen:ye,width:re,arrowButtons:Y,startOpen:K,onOpened:dt,onClosed:ut,dataTestId:pt}=r?l(l({},Z),r):l({},Z);g.useEffect(()=>{N!==ce&&(x(N),k(N))},[N]),g.useEffect(()=>{K!==de&&(C(K),F(K))},[K]);const ae=h===void 0?w:h,se=ie===void 0?y:ie,je=M=>{h===void 0&&(x(M),a&&D&&(M?(C(!1),F(y)):C(I))),v&&v(M)},be=M=>{ie===void 0&&(C(M),a&&O&&(M?(x(!1),k(w)):x(B))),ye&&ye(M)};return n.jsxs(i.Box,{children:[O&&n.jsx(Fe,{"data-testid":st,anchor:"left",open:ae,onClose:()=>je(!1),width:A,titleText:j,debugOpacity:c,showCloseArrow:S==="both"||S==="close",onOpened:X,onClosed:oe,navBarOpen:u,navBarWidthOpen:f,navBarWidthClosed:m,children:_}),D&&n.jsx(Fe,{"data-testid":pt,anchor:"right",open:se,onClose:()=>be(!1),width:re,titleText:lt,debugOpacity:c,showCloseArrow:Y==="both"||Y==="close",onOpened:dt,onClosed:ut,navBarOpen:u,navBarWidthOpen:f,navBarWidthClosed:m,children:ct}),n.jsx(zt,l(l({titleText:t,"data-testid":s},O&&L==="push"?{leftPanel:{open:ae,width:A,onOpen:()=>je(!0),showOpenArrow:S==="both"||S==="open"}}:{}),D&&Se==="push"?{rightPanel:{open:se,width:re,onOpen:()=>be(!0),showOpenArrow:Y==="both"||Y==="open"}}:{})),n.jsx(Vt,T(l(l({},L==="push"?{leftPanel:{open:ae,width:A}}:{}),Se==="push"?{rightPanel:{open:se,width:re}}:{}),{children:n.jsx(Qt,T(l({"data-testid":p},d),{children:e}))}))]})}const Je=()=>{const e=i.useTheme();return i.useMediaQuery(e.breakpoints.down("sm"))},Yt=64,Kt=72,Jt=256,U=b.atom(!0),ge=b.atom(Jt),xe=b.atom(Kt),te=b.atom(""),Ze=b.atom(void 0),fe=b.atom(Yt),me=b.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,l({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"}},Oe=(e,t)=>l({width:t,transition:z(e,"width","entering")},et(e)),Pe=(e,t)=>l({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})=>l(l({flexShrink:0,whiteSpace:"nowrap",boxSizing:"border-box",display:"flex",flexDirection:"column"},t&&T(l({},Oe(e,o)),{backgroundColor:"","& .MuiDrawer-paper":Oe(e,o)})),!t&&T(l({},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:c,bottom:d,user:p,domainCode:s,useNewAvatar:u=!1}){const f=Je(),m=b.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:f?"temporary":"permanent",PaperProps:{component:"nav"},onClose:()=>{m(!1)},isSmallScreen:f,children:[!f&&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(c)?n.jsx(Zt,{links:c}):c}),n.jsxs(i.Box,{flexGrow:"0",children:[n.jsx(i.Divider,{variant:"middle",sx:{marginY:"0.5rem"}}),n.jsx(rn,{user:p,domainCode:s,open:e,useNewAvatar:u}),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=b.useSetAtom(U),c=()=>a(s=>!s),d=i.useTheme(),p=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:p?0:d.zIndex.drawer+1},children:[n.jsx(i.IconButton,{size:"medium",color:"inherit",sx:{padding:1.5,marginLeft:"12px"},onClick:c,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:c,navBarDataTestId:d,navBarMiddle:p,navBarBottom:s,user:u,domainCode:f,useNewAvatar:m=!1}){We.useHydrateAtoms([[U,o!=null?o:!0],[te,t!=null?t:""]]);const w=b.useAtomValue(U),[x]=b.useAtom(ge),[y]=b.useAtom(xe),C=b.useAtomValue(te),[B]=b.useAtom(fe),[k]=b.useAtom(Ze),[I]=b.useAtom(me);return n.jsxs(i.Box,{children:[n.jsx(i.CssBaseline,{}),n.jsx(dn,{titleText:C,"data-testid":c,height:B,middle:k}),n.jsxs(i.Box,{sx:{display:"flex"},children:[n.jsx(an,{open:w,top:I,middle:p,bottom:s,user:u,domainCode:f,widthOpen:x,widthClosed:y,offsetTop:B,"data-testid":d,useNewAvatar:m}),n.jsx(sn,T(l({"data-testid":a,topBarHeight:B},r),{children:e}))]})]})}const Ce=({isOpen:e,dialogTitle:t,children:o,maxWidth:r,primaryButton:a,secondaryButton:c,onClose:d,sx:p,"data-testid":s,disableCloseOnBackdropOrEscape:u=!1,isLoading:f=!1})=>{var x,y;const[m,w]=g.useState(!1);return n.jsxs(i.Dialog,{open:e,onClose:(C,B)=>P(exports,null,function*(){u&&(B==="backdropClick"||B==="escapeKeyDown")||m||(c!=null&&c.onClick?yield c.onClick():d())}),fullWidth:!0,maxWidth:r!=null?r:"xs","data-testid":s,sx:p,children:[f&&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:(x=c==null?void 0:c.onClick)!=null?x:d,"data-testid":c==null?void 0:c.testId,disabled:(c==null?void 0:c.disabled)||m,color:c==null?void 0:c.buttonColor,children:(y=c==null?void 0:c.text)!=null?y:"Cancel"}),a&&n.jsx(i.Button,{onClick:()=>P(exports,null,function*(){var C;w(!0),yield(C=a.onClick)==null?void 0:C.call(a),w(!1)}),"data-testid":a.testId,disabled:a.disabled||m,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(c=>c.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:c,"data-testid":d,sx:p,boxSx:s,textFieldColor:u,textFieldVariant:f="filled",loadingText:m="Loading...",noOptionsText:w="No options",popupIcon:x=n.jsx(W.ArrowDropDown,{}),error:y=!1,helperText:C="",preLoadedOptions:B=void 0,disablePortal:k=!1,disableIconFlip:I=!1}){const[F,O]=g.useState(""),D=(h,v)=>{const A=c.filter(S=>S.id!==v);o(A,"delete",h)},{data:j,isLoading:_}=ve({inputValue:F,label:a,lookup:e,minLength:r,preLoadedOptions:B}),L=F.length>=r;return n.jsxs("div",{"data-testid":d,children:[n.jsx(i.Autocomplete,{sx:l(l({},p),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:[...c,...j!=null?j:[]],filterSelectedOptions:!0,includeInputInList:!0,value:c,onChange:(h,v,A)=>{o(v,A,h)},onInputChange:(h,v)=>O(v),noOptionsText:L?w:"Start typing to search",loadingText:m,popupIcon:x,renderInput:h=>n.jsx(i.TextField,T(l({},h),{label:a,fullWidth:!0,variant:f,error:y,helperText:C,InputProps:T(l({},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:u})),renderTags:()=>null,isOptionEqualToValue:(h,v)=>h.id===v.id,renderOption:(h,v,A)=>{if(t){const S=Bt.default(v.label,A.inputValue,{insideWords:!0,findAllOccurrences:!0}),N=Dt.default(v.label,S);return g.createElement("li",T(l({},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 g.createElement("li",T(l({},h),{key:v.id,"data-testid":d?`${d}:option(${v.id.toString()})`:void 0}),v.label)}}),c.length>0&&n.jsx(i.Box,{sx:s,children:c.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=>D(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:c,textFieldVariant:d="filled","data-testid":p,noOptionsText:s="No options",minLength:u=3,disablePortal:f=!1,preLoadedOptions:m,helperText:w="",disabled:x,popupIcon:y,disableIconFlip:C})=>{const[B,k]=g.useState(""),{data:I,isLoading:F}=ve({inputValue:B,label:o,lookup:e,minLength:u!=null?u:0,preLoadedOptions:m}),O=B.length>=u;return n.jsx("div",{"data-testid":p,children:n.jsx(i.Stack,{direction:"row",spacing:1,children:n.jsx(i.Autocomplete,{sx:l(l({},a),C?{".MuiAutocomplete-popupIndicatorOpen":{transform:"rotate(0deg)"}}:{}),"data-testid":p?`${p}:Autocomplete`:void 0,loading:O?F:!1,options:I!=null?I:[],onChange:(D,j)=>{t(D,j)},disablePortal:f,filterOptions:D=>D,value:r,noOptionsText:O?s:"Start typing to search",getOptionLabel:D=>D.label,popupIcon:y,renderInput:D=>n.jsx(i.TextField,T(l({"data-testid":p?`${p}:Autocomplete:TextField`:void 0},D),{variant:d,label:o,color:c,helperText:w})),isOptionEqualToValue:(D,j)=>D.id===j.id,onInputChange:(D,j)=>{k(j)},renderOption:(D,j)=>g.createElement("li",T(l({},D),{key:j.id,"data-testid":p?`${p}:Autocomplete:option(${j.id.toString()})`:void 0}),j.label),disabled:x})})})},tt=e=>{if(!e)return-1;try{const o=e.split(".")[1].replace(/-/g,"+").replace(/_/g,"/"),r=decodeURIComponent(yt.Buffer.from(o,"base64").toString("utf8").split("").map(function(c){return"%"+("00"+c.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(),[c,d]=g.useState(0),p=()=>P(exports,null,function*(){r({logoutParams:{returnTo:`${window.location.origin}`}})}),s=()=>P(exports,null,function*(){d(c+1),t()});g.useEffect(()=>{(()=>P(exports,null,function*(){if(c>0){const w=yield a({cacheMode:"off"}),x=tt(w)*1e3;o(x)}}))()},[c,a,o]);const u={text:"Continue",onClick:s,disabled:!1,testId:"PreferencesDialog",buttonColor:"secondary"},f={text:"Log out",onClick:p,disabled:!1,testId:"PreferencesDialog",buttonColor:"secondary"};return n.jsx(Ce,{isOpen:e,primaryButton:u,secondaryButton:f,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(e){var r;const t=e.error,o=(r=e==null?void 0:e.error_description)!=null?r:"";return t==="access_denied"&&o.match(/Script.*time.*exceeded/)}function vn({children:e,appName:t="the app",throwErrors:o="none",disableConsoleLogging:r=!1,onError:a=()=>{},withPopup:c=!1}){var w,x;const{isAuthenticated:d,isLoading:p,error:s,loginWithRedirect:u,loginWithPopup:f,logout:m}=ze.useAuth0();if(g.useEffect(()=>{s&&a(s)},[s,a]),g.useEffect(()=>{if(p||d||s)return;const y={appState:{returnTo:`${window.location.pathname}${window.location.search}`}};if(c){const C=document.createElement("button");C.onclick=()=>f(),C.click(),C.remove()}else u(y)},[p,d,s,u,a,c,f]),s){if(r||console.error(`Error detected in AuthGuard [isAuthenticated=${d},isLoading=${p}]`,s),o==="all")throw s;if(xn(s)){let y="Auth error",C="An unknown Auth0 error occurred.";if(fn(s))y="Unauthorised",C=`You are not authorised to access ${t}.`;else if(mn(s))y="App not authorised",C=`You have not authorised ${t} to access your user profile. This is necessary to use ${t}.`;else if(Cn(s))y="Auth0 script execution time exceeded",C="The Auth0 login flow exceeded the time limit (20s). Try again in a minute.";else if(o==="unknown")throw s;return n.jsxs(i.Dialog,{open:!0,children:[n.jsx(i.DialogTitle,{children:y}),n.jsxs(i.DialogContent,{children:[n.jsx(i.Typography,{children:C}),n.jsx("br",{}),n.jsx(i.Typography,{variant:"subtitle2",children:"Details from Auth0"}),n.jsxs(i.Typography,{variant:"body2",children:["error: ",(w=s==null?void 0:s.error)!=null?w:"N/A"]}),n.jsxs(i.Typography,{variant:"body2",children:["description: ",(x=s==null?void 0:s.error_description)!=null?x:"N/A"]})]}),n.jsx(i.DialogActions,{children:n.jsx(i.Button,{onClick:()=>m({logoutParams:{returnTo:window.location.origin}}),children:"Logout"})})]})}else if(o==="unknown")throw s}return d?n.jsx(n.Fragment,{children:e}):n.jsx(Tt.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(c){var d=c,{overrideState:e=bn,overrideActions:t=Bn,shouldClose:o=wn.shouldClose,children:r}=d,a=Te(d,["overrideState","overrideActions","shouldClose","children"]);var v;const[{open:p},s]=g.useState({open:!1}),u=g.useRef([]),f=g.useRef(Date.now()),m=g.useRef(0),w=g.useCallback(A=>{s({open:A})},[]),x=g.useCallback((A={})=>{m.current+=1,u.current.length>=Me&&Date.now()-f.current>=Re&&(f.current=Date.now(),console.error(`SaladBarProvider: MAX_QUEUE_LENGTH (${Me}) hit ${m.current} times in last ${Re}ms)`),m.current=0);const S=l(T(l({},Le),{key:yn()}),A);return u.current.push(S),u.current.length===1&&s({open:!0}),S.key},[]),y=(A="",S={})=>x(l({message:A,severity:"success"},S)),C=(A="",S={})=>x(l({message:A,severity:"info"},S)),B=(A="",S={})=>x(l({message:A,severity:"warning"},S)),k=(A="",S={})=>x(l({message:A,severity:"error"},S)),I=A=>{const S=u.current.findIndex(N=>N.key===A);if(S!==-1)return S===0?(s({open:!1}),u.current[0]):u.current.splice(S,1)},F=(A,S)=>{o(A,S)&&s({open:!1})},O=()=>{},D=()=>{u.current.shift(),u.current.length>0&&s({open:!0})},j=(v=u.current[0])!=null?v:l({},Le),_={};"autoHideDuration"in j&&(_.autoHideDuration=j.autoHideDuration);const L=l(l({},An),a),h=l(l({open:p,setOpen:w,enqueueNotification:x,enqueueSuccessNotification:y,enqueueInfoNotification:C,enqueueWarningNotification:B,enqueueErrorNotification:k,removeNotification:I},e),t);return n.jsxs(Ae.Provider,{value:h,children:[r,n.jsx(i.Snackbar,T(l(l({},L),_),{open:p,onClose:F,TransitionProps:{onExited:D,onExit:O},sx:{zIndex:Sn},children:n.jsxs("div",{children:[n.jsx(i.Alert,{onClose:A=>F(A,"closeAlert"),severity:j.severity,variant:"filled",icon:j.progressIndicator==="circular"?n.jsx(i.CircularProgress,{size:"1em"}):void 0,style:j.progressIndicator==="linear"?jn:void 0,children:j.message}),j.progressIndicator==="linear"&&n.jsx(i.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=G.createHelper((e={autoHideDuration:1},t={},o={})=>({children:r})=>n.jsx(nt,T(l({},e),{overrideState:t,overrideActions:o,children:r}))),it=b.getDefaultStore(),Tn=({children:e,store:t})=>n.jsx(b.Provider,{store:t!=null?t:it,children:e}),rt="domainCode";var qe;const He=b.atom(JSON.parse((qe=localStorage.getItem(rt))!=null?qe:'{"domainCode": ""}').domainCode),we=b.atom(e=>e(He),(e,t,o)=>{t(He,o),localStorage.setItem(rt,JSON.stringify({domainCode:o}))}),kn={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=kn[e])!=null?t:""},$n=({isLoading:e,isOpen:t,onClose:o,domainOptions:r,applicationName:a,handleLogout:c})=>{const[d,p]=b.useAtom(we),[s,u]=g.useState(d),{enqueueSuccessNotification:f}=ot(),m=r.length===0,w=!!d&&!r.includes(d)&&!r.includes(s),x=!d||m||w,y=()=>P(exports,null,function*(){s?(p(s),f(`Set organisation to ${s}`),o()):p("")}),C=()=>P(exports,null,function*(){d&&!m&&!w?(u(d),o()):x&&c()});let B;return m?B="Unable to retrieve your active organisations. Try logging in again.":w&&(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:y,disabled:!s||m||w,buttonColor:"primary"},secondaryButton:{text:x?"Logout":"Cancel",onClick:C},onClose:x?()=>{}: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:s!==""?s:null,onChange:(k,I)=>u(I!=null?I:""),getOptionLabel:In,options:[...r],renderInput:k=>n.jsx(i.TextField,T(l({},k),{variant:"filled",label:"Select organisation",InputProps:T(l({},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})]})},En=$.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=$.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"}}),On={domainCode:we,navBarOpen:U,navBarWidthOpen:ge,navBarWidthClosed:xe,titleText:te,topBarHeight:fe,navBarTop:me},Pn=G.createHelper(()=>({children:e})=>n.jsx(b.Provider,{children:e})),at=({initialValues:e,children:t})=>(We.useHydrateAtoms(e),n.jsx(n.Fragment,{children:t})),Nn=G.createHelper(e=>({children:t})=>n.jsx(at,{initialValues:Object.entries(e).map(([o,r])=>[On[o],r]),children:t})),_n=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=Tn;exports.AuthGuard=vn;exports.Context=Ae;exports.ContextError=ne;exports.DomainCodeDialog=$n;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=En;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;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|