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