import{j as a,D as M,T as _,ce as L,Q as W,cf as q,aV as X,ak as h,cg as Y,aU as Z,av as B,f as V,b$ as J,ch as K}from"./vendor-mui-core-CnXrAOs3.js";import{r as d,k as C,L as z,n as ee,o as ae}from"./vendor-react-Dvs43sk9.js";import{H as E,aV as te}from"./index-sNHCLgAE.js";import{e as ie}from"./vendor-hooks-CjESGRlR.js";import{M as re,l as m,a0 as A,a1 as S}from"./vendor-ux-IiQnod3w.js";import{z as oe}from"./vendor-arcblock-CuFtPveO.js";const H=d.createContext(null),se=e=>{const i=d.use(H);return d.useLayoutEffect(()=>{},[]),i};function le({children:e=void 0,...i}){const[t,r]=d.useState({inFullPage:!1,showToggleButton:!1,headerVisibleInFullPage:!0,footerVisibleInFullPage:!1,sidebarVisibleInFullPage:!1}),s=()=>{r(o=>({...o,inFullPage:!o.inFullPage}))},l=d.useMemo(()=>({...t,headerVisible:!t.inFullPage||t.headerVisibleInFullPage,footerVisible:!t.inFullPage||t.footerVisibleInFullPage,sidebarVisible:!t.inFullPage||t.sidebarVisibleInFullPage,toggleFullPage:s,configure:o=>r(n=>({...n,...o}))}),[t]);return a.jsx(H,{value:l,...i,children:e})}function ne({name:e,size:i=36,alt:t="",color:r="#000000",prefix:s="/images",showBadge:l=!1,style:o={},...n}){const c=`${s}/${e}-${r.replace(/^#/,"")}.png`;return a.jsxs(de,{style:{width:i,height:i},children:[a.jsx(re,{width:i,height:i,alt:t||e,src:c,style:Object.assign({width:i},o),...n}),l&&a.jsx("i",{className:"badge-point"})]})}const de=m("div")`
  position: relative;
  .badge-point {
    position: absolute;
    width: 10px;
    height: 10px;
    border-radius: 10px;
    background-color: #fe4e44;
    right: -2px;
    top: 0;
    box-shadow:
      0px 1px 4px rgba(0, 0, 0, 0.3),
      0px 0px 20px rgba(0, 0, 0, 0.1);
  }
`;function ce({images:e,links:i,prefix:t="/images",addons:r=void 0,logo:s=void 0,...l}){const o=M(),n=C(),c=(x,p)=>new RegExp(`/${p}`).test(n.pathname);return a.jsxs(he,{...l,children:[a.jsx(z,{to:"/",className:"sidebar-logo",children:s||a.jsx(A,{showText:!1,size:20})}),i.map(({url:x,name:p,title:b,showBadge:g})=>{const f=c(x,p);return a.jsxs(pe,{component:z,selected:f,to:x,children:[a.jsx(ne,{name:e[p],size:36,color:f?"#00c2c4":o.typography.color.main,prefix:t,showBadge:g}),a.jsx(_,{component:"span",className:"menu-title",children:b})]},x)}),a.jsx("div",{style:{flex:1}}),r]})}const he=d.memo(m("div")`
  flex: 1;
  display: flex;
  flex-direction: column;

  && .sidebar-logo {
    display: none;
    border-bottom: 1px solid #eee;
    background: ${e=>e.theme.palette.background.default};
    position: sticky;
    top: 0;
    z-index: 1;
    padding: 10px 0;
    text-align: center;
    font-size: 0;
  }
  ${e=>e.theme.breakpoints.down("md")} {
    && .sidebar-logo {
      display: block;
    }
  }
`),T="linear-gradient(32deg, rgba(144, 255, 230, 0.1), rgba(144, 255, 230, 0))",pe=m(W)`
  && {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 100%;
    transition: all 200ms ease-in-out;
    background: ${e=>e.selected?T:""};
    padding: 24px 0;
    border-left: 2px solid ${e=>e.selected?L.A700:"transparent"};
    border-radius: 0;

    &:hover {
      background: ${T};
      border-left-color: ${L.A700};
    }

    .menu-title {
      margin-top: 8px;
      font-size: 12px;
      font-weight: 500;
      text-align: center;
      text-transform: capitalize;
      letter-spacing: normal;
      width: 80%;
      color: ${e=>e.theme.palette.text.primary};
    }
  }
`,xe=m(Y)`
  && {
    z-index: ${e=>e.theme.zIndex.drawer};
    background: ${e=>e.theme.palette.background.default};
    box-shadow: none;
    top: 0;
    height: auto;
  }
  .header-toolbar {
    background: ${e=>e.theme.palette.background.default};
    color: ${e=>e.theme.palette.text.primary};
    margin: ${e=>e.theme.spacing(1)}px 0;
  }
  .header-link {
    display: flex;
    text-decoration: none;
    flex-shrink: 1;
    overflow: hidden;
  }
  .header-logo {
    margin-right: 20px;
  }
  .header-title {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
  }
  .header-title__primary {
    font-size: 24px;
    font-weight: 800;
    color: ${e=>e.theme.typography.color.main};
    text-transform: uppercase;
    display: flex;
    align-items: center;
  }
  .header-title__secondary {
    font-size: 14px;
    line-height: 1.71;
    color: ${e=>e.theme.typography.color.gray};
  }

  .header-addons {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 9999999;

    .user-addon {
      .header-avatar {
        width: 32px;
        border-radius: 16px;
        height: auto;
      }
    }
  }
  .header-menu {
    display: none;
  }
  ${e=>e.theme.breakpoints.down("md")} {
    .header-title {
      display: none;
    }
    .header-title__primary {
      font-size: 20px;
    }
    .header-menu {
      display: block;
    }
  }
`;function ue({onToggleMenu:e,brand:i=void 0,description:t=void 0,addons:r=void 0,brandAddon:s=void 0,homeUrl:l="/",logo:o=void 0,children:n,...c}){return a.jsx(xe,{position:"sticky",className:"header",...c,children:a.jsxs(q,{disableGutters:!1,className:"header-toolbar",children:[a.jsx(W,{color:"inherit","aria-label":"open drawer",className:"header-menu","aira-label":"header menu button",onClick:e,children:a.jsx(X,{})}),a.jsxs(z,{to:l,className:"header-link",children:[a.jsx(h,{sx:{display:{xs:"none",md:"block"}},className:"header-logo",children:o||a.jsx(A,{showText:!1})}),a.jsxs("div",{className:"header-title",children:[a.jsxs(_,{component:"h2",noWrap:!0,className:"header-title__primary",children:[i,s]}),a.jsx(_,{component:"p",noWrap:!0,className:"header-title__secondary",children:t})]})]}),a.jsx(h,{sx:{flexGrow:1}}),!!n&&a.jsx("div",{className:"header-children",children:n}),a.jsx("div",{className:"header-addons",children:r})]})})}const me=m("div")`
  &.dashboard {
    display: flex;
    flex-direction: column;
    height: 100vh;
  }
  .dashboard__body {
    overflow: hidden;
    flex: 1;
  }
  .dashboard__main {
    display: flex;
    flex-direction: column;
    overflow: auto;
    flex: 1;
  }
  .dashboard__content {
    flex: 1;
  }

  .drawerPaper {
    position: relative;
    white-space: nowrap;
    width: 120px;
    background: ${e=>e.theme.palette.background.default};
    box-shadow: 2px 16px 10px 0 rgba(0, 0, 0, ${e=>e.theme.palette.mode==="light"?.05:.5});
    border: 0;
  }
`;function be({links:e=[],brand:i="",description:t="",images:r,title:s="Home",brandAddon:l=void 0,headerAddon:o=void 0,prefix:n="/images",fullWidth:c=!1,contentLayout:x="column",className:p="",homeUrl:b="/",logo:g=void 0,children:f,...P}){const w=ie(document.body)?.width||0,[v,F]=d.useState(w>=960?"permanent":"temporary"),[k,y]=d.useState(v==="permanent");d.useEffect(()=>{const N=w>=960?"permanent":"temporary";F(N),y(N!=="temporary")},[w]);const $=()=>{y(!k)},j=c||x==="row";return a.jsxs(me,{className:`dashboard ${p}`,...P,children:[a.jsx(E,{title:`${s}-${i}`}),a.jsx(ue,{className:"dashboard__header",onToggleMenu:$,brand:i,brandAddon:l,description:t,addons:o,homeUrl:b,logo:g}),a.jsxs(h,{className:"dashboard__body",sx:{display:"flex"},children:[a.jsx(Z,{variant:v,className:"drawer",classes:{paper:"drawerPaper"},open:k,onClose:$,ModalProps:{disablePortal:!0,keepMounted:!0},children:a.jsx(ce,{className:"dashboard__sidebar",images:r,links:e,prefix:n,logo:g})}),a.jsxs(h,{className:"dashboard__main",children:[a.jsx(B,{maxWidth:j?!1:"lg",className:"dashboard__content",children:f}),a.jsx(S,{})]})]})]})}function R({routerLinkComponent:e,to:i,external:t=!1,children:r,...s}){return t?a.jsx("a",{href:i,...s,children:r}):a.jsx(e,{to:i,...s,children:r})}function U({...e}){return a.jsx(R,{routerLinkComponent:z,...e})}function ge({className:e="",...i}){const t=i.external&&typeof e=="function"?e({}):e;return a.jsx(R,{routerLinkComponent:ee,className:t,...i})}function D(e,i){if(e.children?.length)return fe(e,i);const{url:t,icon:r,title:s,showBadge:l,external:o,active:n}=e;return a.jsx("li",{className:"layout-sidebar-item",children:a.jsxs(ge,{external:o,to:t,className:({isActive:c})=>V("layout-sidebar-link",{"layout-sidebar-link--active":o?n:c}),children:[r&&a.jsx("span",{className:`layout-sidebar-icon ${l?"layout-sidebar-badge":""}`,children:r}),a.jsx(_,{component:"span",className:"layout-sidebar-link-text",children:s})]})},`${t}-${i}`)}function fe(e,i){return a.jsxs("li",{className:"layout-sidebar-group",children:[a.jsx("span",{className:"layout-sidebar-group-title",children:e.title}),a.jsx("ul",{children:e.children.map(D)})]},`group-${e.title}-${i}`)}function I({links:e,addons:i=void 0,dense:t=!1,...r}){return a.jsxs(je,{...r,className:V({"layout-sidebar-dense":t}),children:[a.jsx("ul",{children:e.map(D)}),a.jsx("div",{style:{flex:1}}),i]})}const ye="linear-gradient(32deg, rgba(144, 255, 230, 0.1), rgba(144, 255, 230, 0))",je=m("div")`
  display: flex;
  flex-direction: column;
  ul {
    list-style: none;
    margin: 0;
    padding: 0;
  }
  .layout-sidebar-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 22px 24px;
    color: ${e=>e.theme.palette.text.secondary};
    text-decoration: none;

    &:hover,
    &.layout-sidebar-link--active {
      color: ${e=>e.theme.palette.primary.main};
      background: ${ye};
      border-left-color: ${e=>e.theme.palette.primary.main};
    }
  }
  .layout-sidebar-icon {
    display: inline-block;
    width: 32px;
    height: 32px;
    > img,
    > svg {
      width: 32px;
      height: 32px;
    }
  }
  .layout-sidebar-badge {
    position: relative;
    &:after {
      content: '';
      position: absolute;
      width: 10px;
      height: 10px;
      border-radius: 10px;
      background-color: #fe4e44;
      right: -2px;
      top: 0;
      box-shadow:
        0px 1px 4px rgba(0, 0, 0, 0.3),
        0px 0px 20px rgba(0, 0, 0, 0.1);
    }
  }
  .layout-sidebar-link-text {
    margin-top: 8px;
    font-size: 12px;
    font-weight: 500;
    text-align: center;
    text-transform: capitalize;
    letter-spacing: normal;
  }
  /* dense=false 时隐藏 group title */
  .layout-sidebar-group-title {
    display: none;
  }
  &.layout-sidebar-dense {
    box-sizing: border-box;
    padding: 20px 0;
    font-weight: bold;
    .layout-sidebar-item {
      padding: 0 16px;
    }
    .layout-sidebar-item + .layout-sidebar-item {
      margin-top: 1px;
    }
    .layout-sidebar-link {
      box-sizing: border-box;
      flex-direction: row;
      align-items: center;
      width: 100%;
      padding: 8px;
      &:hover,
      &.layout-sidebar-link--active {
        color: ${e=>e.theme.palette.grey[900]};
        background: ${e=>e.theme.palette.grey[100]};
        border: 0;
        border-radius: 4px;
      }
    }
    .layout-sidebar-icon {
      display: inline-block;
      width: 20px;
      height: 20px;
      margin-right: 8px;
      > img,
      > svg {
        width: 20px;
        height: 20px;
      }
    }
    .layout-sidebar-badge {
      &:after {
        width: 6px;
        height: 6px;
        border-radius: 6px;
        right: -2px;
        top: 0;
      }
    }
    .layout-sidebar-link-text {
      margin-top: 0;
      font-size: 14px;
      line-height: 1;
    }
    .layout-sidebar-group {
      color: ${e=>e.theme.palette.text.hint};
      .layout-sidebar-group-title {
        display: inline-block;
        padding: 8px 0 8px 24px;
        font-size: 13px;
        text-transform: uppercase;
      }
    }
    .layout-sidebar-group + .layout-sidebar-group,
    .layout-sidebar-group + .layout-sidebar-item,
    .layout-sidebar-item + .layout-sidebar-group {
      margin-top: 16px;
    }
  }
`;function we({closeMenu:e,...i}){const t=C();return d.useEffect(()=>{e()},[t]),a.jsx(te,{...i})}function G(e,i){return e.map(t=>t.children?.length?{...t,label:t.title,children:G(t.children,i)}:{...t,label:a.jsx(U,{to:t.url,external:t.external,children:t.title}),active:t.external?t.active:!!ae({path:t.url,end:!1},i.pathname)})}function ke({title:e="Home",headerProps:i={},links:t=[],sidebarWidth:r=120,fullWidth:s=!1,dense:l="auto",footerProps:o={},sx:n={},children:c,hideHtmlTitle:x=!1,...p}){const b=M(),{inFullPage:g,showToggleButton:f,headerVisible:P,footerVisible:w,sidebarVisible:v,toggleFullPage:F}=se(),k=C(),y=d.useMemo(()=>G(t,k),[k,t]),$=y.some(u=>!!u.children?.length),j=l==="auto"?y.length>=8||$:l,N=V("dashboard",{"dashboard-dense":j},p.className),O={homeLink:u=>a.jsx(U,{to:window.blocklet?.prefix||"/",children:u}),...i};return d.useEffect(()=>{const{searchParams:u}=new URL(window.location.href);u.get("inviter")&&window.localStorage.setItem("inviter",u.get("inviter"))},[]),a.jsxs(ve,{sx:n,...p,className:N,sidebarWidth:r,children:[!x&&a.jsx(E,{title:e},e),P&&a.jsx($e,{...O,className:"dashboard-header",children:t?.length?({isMobile:u,closeMenu:Q})=>u?a.jsx(we,{mode:"inline",items:y,closeMenu:Q,bgColor:"transparent",activeTextColor:b.palette.primary.main}):null:null}),a.jsxs(h,{className:"dashboard-body",sx:{display:"flex"},children:[!!t?.length&&v&&a.jsx(h,{className:"dashboard-sidebar",sx:{display:{xs:"none",md:"block"}},children:j?a.jsx(I,{links:t,dense:j}):a.jsx(h,{className:"dashboard-sidebar-container",children:a.jsx(I,{links:t,dense:j})})}),a.jsxs(h,{className:"dashboard-main",id:"arc__dashboard-main",children:[f&&a.jsx(h,{sx:{position:"absolute",top:4,right:4,display:"flex",justifyContent:"center",alignItems:"center",width:24,height:24,color:"#fff",bgcolor:"rgba(158,158,158, 0.6);",borderRadius:1,cursor:"pointer"},onClick:F,children:g?a.jsx(J,{style:{fontSize:18}}):a.jsx(K,{style:{fontSize:18}})}),a.jsx(B,{className:"dashboard-content",id:"arc__dashboard-content",...s&&{maxWidth:!1},children:c}),w&&a.jsx(S,{dark:b.palette.mode==="dark",...o})]})]})]})}const ve=m(h)`
  &.dashboard {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background-color: ${({theme:e})=>e.palette.background.default};
  }
  .dashboard-body {
    overflow: hidden;
    flex: 1;
  }
  .dashboard-sidebar {
    box-sizing: border-box;
    flex: 0 0 auto;
    width: ${e=>e.sidebarWidth}px;
    overflow: hidden;
    &:hover {
      overflow-y: auto;
    }
  }
  .dashboard-sidebar-container {
    width: ${e=>e.sidebarWidth}px;
  }
  .dashboard-main {
    display: flex;
    flex-direction: column;
    overflow: auto;
    flex: 1;
    position: relative;
  }
  .dashboard-content {
    flex: 1;
  }
  &.dashboard-dense {
    .dashboard-header {
      border-bottom: 1px solid;
      border-color: ${({theme:e})=>e.palette.divider};
    }
    .dashboard-sidebar {
      width: 256px;
      border-right: 1px solid;
      border-color: ${({theme:e})=>e.palette.divider};
    }
  }
  ${e=>e.theme.breakpoints.up("md")} {
    .header-logo {
      display: flex;
      justify-content: center;
    }
    &.dashboard-dense {
      .header-logo {
        /* dense = true 时 logo 与 sidenav icons 不需要对齐 */
        width: auto;
      }
    }
  }
`,$e=m(oe)`
  .header-container {
    max-width: 100%;
  }
`;function Ce({legacy:e=!0,...i}){return e?a.jsx(be,{...i}):a.jsx(le,{children:a.jsx(ke,{...i})})}export{se as d,Ce as x};
