const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["strapi-D_Y4QZhh.js","strapi-D6821bIJ.css"])))=>i.map(i=>d[i]);
import{r as f,ao as I,cf as v,U as T,n as w,cg as D,b8 as A,_ as B,a as E,b as C,ap as U,j as e,ch as m,aY as O,ci as G,k as R,cj as H,aj as K,P,aq as F,B as V,ck as $}from"./strapi-D_Y4QZhh.js";import{s as q}from"./sortBy-D8xDiPL0.js";import{s as W}from"./selectors-CVtJ1Wu7.js";import"./_baseMap-CCeMgCnY.js";import"./_baseEach-xZsTMLD4.js";const Y=n=>n.map(a=>{const l=a.links.map(r=>({...r,isDisplayed:!1}));return{...a,links:l}}),z=()=>{const[{isLoading:n,menu:a},l]=f.useState({isLoading:!0,menu:[]}),r=I("useSettingsMenu",s=>s.checkUserHasPermissions),h=v("useSettingsMenu",s=>s.shouldUpdateStrapi),u=T("useSettingsMenu",s=>s.settings),c=w(W),b=f.useMemo(()=>D(),[]),{admin:i,global:t}=A(b,async()=>(await B(async()=>{const{SETTINGS_LINKS_EE:s}=await import("./strapi-D_Y4QZhh.js").then(o=>o.iG);return{SETTINGS_LINKS_EE:s}},__vite__mapDeps([0,1]))).SETTINGS_LINKS_EE(),{combine(s,o){return{admin:[...o.admin,...s.admin],global:[...s.global,...o.global]}},defaultValue:{admin:[],global:[]}}),S=f.useCallback(s=>{if(!s.id)throw new Error("The settings menu item must have an id attribute.");return{...s,permissions:c.settings?.[s.id]?.main??[]}},[c.settings]);return f.useEffect(()=>{const s=async()=>{const _=await(k=>Promise.all(k.reduce((g,x,L)=>{const j=x.links.map(async(y,p)=>({hasPermission:(await r(y.permissions)).length>0,sectionIndex:L,linkIndex:p}));return[...g,...j]},[])))(M);l(k=>({...k,isLoading:!1,menu:M.map((g,x)=>({...g,links:g.links.map((L,j)=>{const y=_.find(p=>p.sectionIndex===x&&p.linkIndex===j);return{...L,isDisplayed:!!y?.hasPermission}})}))}))},{global:o,...N}=u,M=Y([{...o,links:q([...o.links,...t.map(S)],d=>d.id).map(d=>({...d,hasNotification:d.id==="000-application-infos"&&h}))},{id:"permissions",intlLabel:{id:"Settings.permissions",defaultMessage:"Administration Panel"},links:i.map(S)},...Object.values(N)]);s()},[i,t,u,h,S,r]),{isLoading:n,menu:a.map(s=>({...s,links:s.links.filter(o=>o.isDisplayed)}))}},J=R(H)`
  border-radius: 50%;
  padding: ${({theme:n})=>n.spaces[2]};
  height: 2rem;
`,Q=({menu:n})=>{const{formatMessage:a}=E(),{trackUsage:l}=C(),{pathname:r}=U(),u=n.filter(i=>!i.links.every(t=>t.isDisplayed===!1)).map(i=>({...i,title:i.intlLabel,links:i.links.map(t=>({...t,title:t.intlLabel,name:t.id}))})),c=a({id:"global.settings",defaultMessage:"Settings"}),b=i=>()=>{l("willNavigate",{from:r,to:i})};return e.jsxs(m.Main,{"aria-label":c,children:[e.jsx(m.Header,{label:c}),e.jsx(O,{background:"neutral150",marginBottom:5}),e.jsx(m.Sections,{children:u.map(i=>e.jsx(m.Section,{label:a(i.intlLabel),children:i.links.map(t=>e.jsx(m.Link,{to:t.to,onClick:b(t.to),label:a(t.intlLabel),endAction:e.jsxs(e.Fragment,{children:[t?.licenseOnly&&e.jsx(G,{fill:"primary600",width:"1.5rem",height:"1.5rem"}),t?.hasNotification&&e.jsx(J,{"aria-label":"Notification",backgroundColor:"primary600",textColor:"neutral0",children:"1"})]})},t.id))},i.id))})]})},is=()=>{const n=K("/settings/:settingId/*"),{formatMessage:a}=E(),{isLoading:l,menu:r}=z();return l?e.jsx(P.Loading,{}):n?.params.settingId?e.jsxs(V.Root,{sideNav:e.jsx(Q,{menu:r}),children:[e.jsx(P.Title,{children:a({id:"global.settings",defaultMessage:"Settings"})}),e.jsx($,{})]}):e.jsx(F,{to:"application-infos"})};export{is as Layout};
