"use strict";(self.webpackChunk_digicommerce_cms_admin=self.webpackChunk_digicommerce_cms_admin||[]).push([[801],{66244:(et,C,t)=>{t.r(C),t.d(C,{default:()=>ke});var e=t(32735),c=t(88425),b=t(84968),w=t(33795),k=t.n(w);const O={i8:"0.1.2"};var T=t(78227),i=t(5141),q=t(74506),_=t(51968),A=t(19615),ee=t(60216),h=t.n(ee),j=t(5636),te=t(27635),g=t(34499),ne=t(54742),S=t(9808),D=t(95602),ae=t(90662),oe=t(82926),se=t.n(oe),re=t(70258),le=t.n(re),ie=t(19799);const ce=(0,A.default)(S.Box)`
  width: ${150/16}rem;
  position: absolute;
  bottom: ${({theme:n})=>n.spaces[9]};
  left: ${({theme:n})=>n.spaces[5]};
`,z=(0,A.default)(i.NavLink)`
  display: flex;
  justify-content: space-between;
  align-items: center;
  text-decoration: none;
  padding: ${({theme:n})=>`${n.spaces[2]} ${n.spaces[4]}`};
  border-radius: ${({theme:n})=>n.spaces[1]};

  &:hover {
    background: ${({theme:n,logout:a})=>a?n.colors.danger100:n.colors.primary100};
    text-decoration: none;
  }

  svg {
    path {
      fill: ${({theme:n})=>n.colors.danger600};
    }
  }
`,U=({generalSectionLinks:n,pluginsSectionLinks:a})=>{const o=(0,e.useRef)(),[d,p]=(0,e.useState)(!1),{logos:{menu:l}}=(0,ie.Z)(),[f,m]=(0,c.usePersistentState)("navbar-condensed",!1),{userDisplayName:u}=(0,c.useAppInfos)(),{formatMessage:r}=(0,j.useIntl)(),P=u.split(" ").map(s=>s.substring(0,1)).join("").substring(0,2),y=()=>p(s=>!s),I=()=>{c.auth.clearAppStorage(),y()},M=s=>{var v,E;!s.currentTarget.contains(s.relatedTarget)&&((E=(v=s.relatedTarget)==null?void 0:v.parentElement)==null?void 0:E.id)!=="main-nav-user-button"&&p(!1)},x=r({id:"app.components.LeftMenu.navbrand.title",defaultMessage:"Digi Dashboard"});return e.createElement(g.MainNav,{condensed:f},e.createElement(g.NavBrand,{as:i.NavLink,workplace:r({id:"app.components.LeftMenu.navbrand.workplace",defaultMessage:"Workplace"}),title:x,icon:e.createElement("img",{src:l.custom||l.default,alt:r({id:"app.components.LeftMenu.logo.alt",defaultMessage:"Application logo"})})}),e.createElement(te.Divider,null),e.createElement(g.NavSections,null,e.createElement(g.NavLink,{as:i.NavLink,to:"/content-manager",icon:e.createElement(se(),null)},r({id:"global.content-manager",defaultMessage:"Content manager"})),a.length>0?e.createElement(g.NavSection,{label:r({id:"app.components.LeftMenu.plugins",defaultMessage:"Plugins"})},a.map(s=>{const v=s.icon;return e.createElement(g.NavLink,{as:i.NavLink,to:s.to,key:s.to,icon:e.createElement(v,null)},r(s.intlLabel))})):null,n.length>0?e.createElement(g.NavSection,{label:r({id:"app.components.LeftMenu.general",defaultMessage:"General"})},n.map(s=>{const v=s.icon;return e.createElement(g.NavLink,{as:i.NavLink,badgeContent:s.notificationsCount>0&&s.notificationsCount.toString()||void 0,to:s.to,key:s.to,icon:e.createElement(v,null)},r(s.intlLabel))})):null),e.createElement(g.NavUser,{id:"main-nav-user-button",ref:o,onClick:y,initials:P},u),d&&e.createElement(ce,{onBlur:M,padding:1,shadow:"tableShadow",background:"neutral0",hasRadius:!0},e.createElement(ne.FocusTrap,{onEscape:y},e.createElement(ae.Stack,{spacing:0},e.createElement(z,{tabIndex:0,onClick:y,to:"/me"},e.createElement(D.Typography,null,r({id:"global.profile",defaultMessage:"Profile"}))),e.createElement(z,{tabIndex:0,onClick:I,logout:"logout",to:"/auth/login"},e.createElement(D.Typography,{textColor:"danger600"},r({id:"app.components.LeftMenu.logout",defaultMessage:"Logout"})),e.createElement(le(),null))))),e.createElement(g.NavCondense,{onClick:()=>m(s=>!s)},r(f?{id:"app.components.LeftMenu.expand",defaultMessage:"Expand the navbar"}:{id:"app.components.LeftMenu.collapse",defaultMessage:"Collapse the navbar"})))};U.propTypes={generalSectionLinks:h().array.isRequired,pluginsSectionLinks:h().array.isRequired};const de=U;var ue=t(19192),pe=t(16540);const me=(0,A.default)(S.Box)`
  flex: 1;
`,F=({children:n,sideNav:a})=>{const{formatMessage:o}=(0,j.useIntl)();return e.createElement(S.Box,{background:"neutral100"},e.createElement(pe.SkipToContent,null,o({id:"skipToContent",defaultMessage:"Skip to content"})),e.createElement(ue.Flex,{alignItems:"flex-start"},a,e.createElement(me,null,n)))};F.propTypes={children:h().node.isRequired,sideNav:h().node.isRequired};const fe=F;var B=t(7602);const ge=(0,e.lazy)(()=>Promise.all([t.e(8469),t.e(6925),t.e(9420),t.e(20),t.e(1669),t.e(6043),t.e(994)]).then(t.bind(t,92494))),ve=(0,e.lazy)(()=>t.e(3981).then(t.bind(t,38364))),he=(0,e.lazy)(()=>t.e(3677).then(t.bind(t,15415))),ye=(0,e.lazy)(()=>Promise.all([t.e(8469),t.e(5516)]).then(t.bind(t,71561))),V=(0,e.lazy)(()=>Promise.resolve().then(t.bind(t,53951))),Ee=(0,e.lazy)(()=>t.e(9501).then(t.bind(t,92336))),Pe=(0,e.lazy)(()=>t.e(9497).then(t.bind(t,9972))),$=(0,e.lazy)(()=>Promise.all([t.e(8469),t.e(9420),t.e(20),t.e(5895)]).then(t.bind(t,50020))),Le=()=>{const{isLoading:n,generalSectionLinks:a,pluginsSectionLinks:o}=(0,T.H9)(),{menu:d}=(0,c.useStrapiApp)(),p=(0,e.useMemo)(()=>d.filter(l=>l.Component).map(({to:l,Component:f,exact:m})=>(0,B.ot)(f,l,m)),[d]);return n?e.createElement(c.LoadingIndicatorPage,null):e.createElement(q.DndProvider,{backend:_.PD},e.createElement(fe,{sideNav:e.createElement(de,{generalSectionLinks:a,pluginsSectionLinks:o})},e.createElement(e.Suspense,{fallback:e.createElement(c.LoadingIndicatorPage,null)},e.createElement(i.Switch,null,e.createElement(i.Route,{path:"/",component:ve,exact:!0}),e.createElement(i.Route,{path:"/me",component:Pe,exact:!0}),e.createElement(i.Route,{path:"/content-manager",component:ge}),p,e.createElement(i.Route,{path:"/settings/:settingId",component:$}),e.createElement(i.Route,{path:"/settings",component:$,exact:!0}),e.createElement(i.Route,{path:"/marketplace"},e.createElement(ye,null)),e.createElement(i.Route,{path:"/list-plugins",exact:!0},e.createElement(he,null)),e.createElement(i.Route,{path:"/404",component:V}),e.createElement(i.Route,{path:"/500",component:Ee}),e.createElement(i.Route,{path:"",component:V})))))};var Ae=Object.defineProperty,G=Object.getOwnPropertySymbols,Se=Object.prototype.hasOwnProperty,Re=Object.prototype.propertyIsEnumerable,K=(n,a,o)=>a in n?Ae(n,a,{enumerable:!0,configurable:!0,writable:!0,value:o}):n[a]=o,Ne=(n,a)=>{for(var o in a||(a={}))Se.call(a,o)&&K(n,o,a[o]);if(G)for(var o of G(a))Re.call(a,o)&&K(n,o,a[o]);return n};const Ie=n=>({plugins:Object.keys(n).reduce((a,o)=>(a[o]=Ne({},n[o]),a),{})});var Me=t(49415),xe=t(3040),Ce=t.n(xe);const W={plugins:null},Oe=(n=W,a)=>(0,Me.default)(n,o=>{switch(a.type){case"SET_PLUGIN_READY":{Ce()(o,["plugins",a.pluginId,"isReady"],!0);break}default:return o}}),Te=()=>{const{plugins:n}=(0,c.useStrapiApp)(),[{plugins:a},o]=(0,e.useReducer)(Oe,W,()=>Ie(n)),d=(0,e.useRef)(l=>{o({type:"SET_PLUGIN_READY",pluginId:l})});if(Object.keys(a).some(l=>a[l].isReady===!1)){const l=Object.keys(a).reduce((f,m)=>{const u=a[m].initializer;if(u){const r=a[m].pluginId;f.push(e.createElement(u,{key:r,setPlugin:d.current}))}return f},[]);return e.createElement(e.Fragment,null,l,e.createElement(c.LoadingIndicatorPage,null))}return e.createElement(Le,null)};var Q=t(4409),H=t(17367);const je=()=>({type:H.l}),De=n=>({type:H.m,permissions:n}),Y=({children:n,permissions:a,refetchPermissions:o})=>{const{allPermissions:d}=(0,Q.useSelector)(l=>l.rbacProvider),p=(0,Q.useDispatch)();return(0,e.useEffect)(()=>(p(De(a)),()=>{p(je())}),[a,p]),d?e.createElement(c.RBACProviderContext.Provider,{value:{allPermissions:d,refetchPermissions:o}},n):e.createElement(c.LoadingIndicatorPage,null)};Y.propTypes={children:h().element.isRequired,permissions:h().array.isRequired,refetchPermissions:h().func.isRequired};const ze=Y;var Ue=t(43653),Fe=t.n(Ue),R=t(17247),L=(n,a,o)=>new Promise((d,p)=>{var l=u=>{try{m(o.next(u))}catch(r){p(r)}},f=u=>{try{m(o.throw(u))}catch(r){p(r)}},m=u=>u.done?d(u.value):Promise.resolve(u.value).then(l,f);m((o=o.apply(n,a)).next())});const Be=O.i8,Ve=()=>L(void 0,null,function*(){try{const{data:{tag_name:n}}=yield Fe().get("https://api.github.com/repos/strapi/strapi/releases/latest");return n}catch(n){return Be}}),$e=()=>L(void 0,null,function*(){try{const{data:n,headers:a}=yield R.be.get("/admin/information");if(!a["content-type"].includes("application/json"))throw new Error("Not found");return n.data}catch(n){throw new Error(n)}}),Ge=()=>L(void 0,null,function*(){try{const{data:n,headers:a}=yield R.be.get("/admin/users/me/permissions");if(!a["content-type"].includes("application/json"))throw new Error("Not found");return n.data}catch(n){throw new Error(n)}}),Ke=()=>L(void 0,null,function*(){try{const{data:{data:{roles:n}}}=yield R.be.get("/admin/users/me");return n}catch(n){throw new Error(n)}});var We=t(54770),N=t.n(We);const Qe=(n,a)=>!N().valid(n)||!N().valid(a)?!1:N().lt(n,a);var He=Object.defineProperty,Ye=Object.defineProperties,Ze=Object.getOwnPropertyDescriptors,Z=Object.getOwnPropertySymbols,Je=Object.prototype.hasOwnProperty,Xe=Object.prototype.propertyIsEnumerable,J=(n,a,o)=>a in n?He(n,a,{enumerable:!0,configurable:!0,writable:!0,value:o}):n[a]=o,be=(n,a)=>{for(var o in a||(a={}))Je.call(a,o)&&J(n,o,a[o]);if(Z)for(var o of Z(a))Xe.call(a,o)&&J(n,o,a[o]);return n},we=(n,a)=>Ye(n,Ze(a));const X=O.i8,ke=()=>{const{setGuidedTourVisibility:n}=(0,c.useGuidedTour)(),a=(0,c.useNotification)(),o=(0,e.useRef)(n),d=c.auth.getUserInfo(),p=k()(d,"username")||(0,B.Pp)(d.firstname,d.lastname),[l,f]=(0,e.useState)(p),{showReleaseNotification:m}=(0,T.um)(),[{data:u,status:r},{data:P,isLoading:y},{data:I,status:M,refetch:x,isFetched:s,isFetching:v},{data:E}]=(0,b.useQueries)([{queryKey:"app-infos",queryFn:$e},{queryKey:"strapi-release",queryFn:()=>Ve(a),enabled:m,initialData:X},{queryKey:"admin-users-permission",queryFn:Ge,initialData:[]},{queryKey:"user-roles",queryFn:Ke}]),qe=(0,e.useMemo)(()=>Qe(X,P),[P]);return(0,e.useEffect)(()=>{E&&E.find(({code:_e})=>_e==="strapi-super-admin")&&o.current(!0)},[E]),y||(v&&s||r==="loading"||M==="loading")?e.createElement(c.LoadingIndicatorPage,null):r==="error"?e.createElement("div",null,"error..."):e.createElement(c.AppInfosContext.Provider,{value:we(be({},u),{latestStrapiReleaseTag:P,setUserDisplayName:f,shouldUpdateStrapi:qe,userDisplayName:l})},e.createElement(ze,{permissions:I,refetchPermissions:x},e.createElement(Te,null)))}}}]);
