import{W as o,j as n,ak as u,f as y,b0 as q,av as w,D as I}from"./vendor-mui-core-DnR6WYuU.js";import{r as $}from"./vendor-react-CTtPmzVP.js";import{l as k,aM as W,V as A,m as B,k as H}from"./vendor-ux-KtPBvlG0.js";import{b0 as V,bm as P,bn as Q,bo as C,k as Y,bp as G,ae as J,a4 as K,aa as U,a5 as N,a7 as X}from"./index-DGg3AL9l.js";import{ae as Z,Q as ee,I as ne}from"./vendor-utils-BqKQizRf.js";import{a as oe}from"./vendor-hooks-DpqqC65c.js";function z({name:e="",logo:t="",description:i="",...c}){if(!e&&!t&&!i)return null;const d=$.isValidElement(t)?t:n.jsx("img",{src:t,alt:e});return n.jsxs(te,{...c,children:[n.jsxs("div",{children:[t&&n.jsx(u,{component:"a",href:"/",className:"footer-brand-logo",children:d}),e&&n.jsx("div",{className:"footer-brand-name",children:e})]}),i&&n.jsx("div",{className:"footer-brand-desc",children:i})]})}z.propTypes={name:o.node,logo:o.node,description:o.string};const te=k("div")`
  display: flex;
  flex-direction: column;
  font-size: 14px;
  a {
    text-decoration: none;
    color: inherit;
  }
  > div:first-of-type {
    display: flex;
    align-items: center;
  }
  .footer-brand-logo {
    display: flex;
    align-items: center;
    margin-right: 12px;
    line-height: 1;
    img,
    svg {
      width: auto;
      height: 40px;
      max-height: 40px;
    }
  }
  .footer-brand-name {
    font-size: 18px;
    color: ${e=>e.theme.palette.grey[900]};
  }
  .footer-brand-desc {
    white-space: pre-line;
    margin-top: 16px;
    color: ${e=>e.theme.palette.text.secondary};
  }

  ${e=>e.theme.breakpoints.down("sm")} {
    width: auto;
  }

  ${e=>e.theme.breakpoints.down("md")} {
    .footer-brand-logo {
      img,
      svg {
        height: 32px;
        max-height: 32px;
      }
    }
  }
`;function M({links:e=[],flowLayout:t=!1,columns:i,...c}){const[d,x]=$.useState(-1),f=V({key:"md"}),g=e.some(l=>l.items?.length),b=!f&&g&&Z(i)&&i>1,h=({label:l,link:r,icon:a,render:p,props:m})=>{let s=l;if(p)s=p({label:l,link:r,props:m});else if(r&&ee(r)){const j=r.startsWith("http")||r.startsWith("//"),_=Q(r)?{}:{target:j?"_blank":"_self",rel:j?"noreferrer noopener":void 0};s=n.jsx("a",{href:r,"aria-label":`Footer link for ${l}`,..._,...m,children:l})}return n.jsxs(n.Fragment,{children:[a&&n.jsx(C,{icon:a,size:20,sx:{mr:.5}}),s]})},v=oe(()=>e?.length?t?e.map((l,r)=>n.jsx("span",{className:"footer-links-item",children:h(l)},r)):b?P(e,{columns:i}).map((l,r)=>n.jsx("div",{className:"footer-links-column",children:l.filter(a=>a.group).map((a,p)=>{const{items:m}=a;return n.jsxs("div",{className:"footer-links-group",children:[n.jsx("span",{className:"footer-links-item",children:h(a)}),!!m?.length&&n.jsx("div",{className:"footer-links-sub",children:m.map((s,j)=>n.jsx("span",{className:y("footer-links-item",{"footer-links-item--new":s.isNew}),children:h(s)},j))})]},p)})},r)):e.map((l,r)=>{const{items:a}=l,p=r===d;return n.jsxs("div",{className:y("footer-links-group",{"footer-links-group--active":p}),onClick:()=>x(d===r?-1:r),children:[n.jsxs("span",{className:"footer-links-item",children:[h(l),!!a?.length&&n.jsx("span",{className:"footer-links-group-expand-icon",children:n.jsx(q,{style:{transform:`rotate(${p?180:0}deg)`}})})]}),!!a?.length&&n.jsx("div",{className:"footer-links-sub",children:a.map((m,s)=>n.jsx("span",{className:y("footer-links-item",{"footer-links-item--new":m.isNew}),children:h(m)},s))})]},r)}):null,[e,t,b,d]);return e?.length?n.jsx(ie,{...c,className:y(c.className,{"footer-links--grouped":g,"footer-links--flow":t,"footer-links--columns":b}),children:n.jsx("div",{className:"footer-links-inner",children:v})}):null}M.propTypes={links:o.arrayOf(o.shape({label:o.string,link:o.string,render:o.func,props:o.object})),flowLayout:o.bool,columns:o.number.isRequired};const ie=k("div")`
  overflow: hidden;
  color: ${({theme:e})=>e.palette.text.secondary};
  .footer-links-inner {
    display: flex;
    justify-content: space-between;
    margin: 0 -8px;
  }
  .footer-links-group,
  .footer-links-sub {
    display: flex;
    flex-direction: column;
  }
  .footer-links-group-expand-icon {
    display: none;
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translate(0, -50%);
    line-height: 1;
    svg {
      width: auto;
      height: 0.75em;
    }
  }
  .footer-links-item {
    display: inline-flex;
    align-items: center;
    position: relative;
    padding: 6px 8px;
    font-size: 14px;
    white-space: nowrap;
    &--new::after {
      content: 'New';
      color: ${({theme:e})=>e.palette.info.main};
      background-color: ${({theme:e})=>e.palette.info.light};
      padding: 1px 8px;
      border-radius: 10px/50%;
      margin-left: 8px;
    }
  }
  &.footer-links--grouped {
    .footer-links-group {
      > .footer-links-item {
        font-weight: 600;
        color: ${({theme:e})=>e.palette.text.primary};
      }
      .footer-links-sub {
        margin-top: 8px;
      }
    }
  }
  a {
    display: inline-block;
    max-width: 150px;
    color: inherit;
    text-decoration: none;
    transition: color 0.2s ease-in-out;
    &:hover {
      color: ${({theme:e})=>e.palette.text.primary};
    }
  }
  /* columns 布局 */
  &.footer-links--columns {
    .footer-links-inner {
      gap: 96px;
    }
    .footer-links-column {
      display: flex;
      flex-direction: column;
    }
    .footer-links-group {
      .footer-links-sub {
        margin-top: 2px;
        margin-bottom: 12px;
      }
    }
  }

  /* flow 布局 */
  &.footer-links--flow {
    display: inline-flex;
    .footer-links-inner {
      justify-content: center;
      flex-wrap: wrap;
      margin: 0 -8px;
      .footer-links-item {
        padding: 0 8px;
      }
      .footer-links-item + .footer-links-item::before {
        content: '';
        position: absolute;
        left: 0;
        top: 50%;
        transform: translate(0, -50%);
        height: 1em;
        border-left: 1px solid ${e=>e.theme.palette.text.secondary};
      }
    }
  }

  /* 移动端样式 */
  ${e=>e.theme.breakpoints.down("md")} {
    .footer-links-inner {
      flex-direction: column;
      margin: 0;
    }
    .footer-links-sub {
      display: none;
    }
    .footer-links-group {
      position: relative;
      padding: 12px 0;
      .footer-links-item .footer-links-group-expand-icon {
        display: inline-block;
      }
    }
    .footer-links-group + .footer-links-group {
      border-top: 1px solid ${e=>e.theme.palette.grey[200]};
    }
    .footer-links-group--active {
      .footer-links-sub {
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        .footer-links-item {
          flex: 0 0 50%;
        }
      }
    }
    .footer-links-item {
      padding-left: 0;
      padding-right: 0;
      font-size: 13px;
    }
    &.footer-links--grouped {
      .footer-links-group {
        > .footer-links-item {
          font-size: 14px;
        }
      }
    }

    &.footer-links--flow {
      .footer-links-inner {
        flex-direction: row;
      }
    }
  }
`;function O({items:e=null,...t}){return e?.length?n.jsx(re,{...t,children:e.map((i,c)=>n.jsx("a",{href:i.link,target:"_blank","aria-label":`Social media icon${i.title?` for ${i.title}`:""}`,rel:"noreferrer",children:n.jsx(C,{icon:i.icon||i.title,size:24,component:"span"})},c))}):null}O.propTypes={items:o.arrayOf(o.shape({icon:o.string,link:o.string}))};const re=k("div")`
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 20px;
  a {
    color: ${e=>e.theme.palette.text.secondary};
    text-decoration: none;
    transition: color 0.2s ease-in-out;
    &:hover {
      color: ${({theme:e})=>e.palette.text.primary};
    }
  }
  ${e=>e.theme.breakpoints.down("md")} {
    gap: 12px;
  }
`;function L({owner:e="ArcBlock",year:t=`${new Date().getFullYear()}`,...i}){return n.jsxs(se,{...i,children:["Copyright © ",t," ",e]})}L.propTypes={owner:o.string,year:o.string};const se=k("p")`
  display: flex;
  align-items: center;
  margin: 0;
  font-size: 13px;
`;function T({children:e=null,autoCenter:t=!1,...i}){return e?n.jsx(le,{...i,className:y(i.className,{"footer-row-auto-center":t}),children:e}):null}T.propTypes={children:o.any,autoCenter:o.bool};const le=k(u)`
  display: flex;
  justify-content: space-between;
  & + & {
    margin-top: 24px;
  }
  &.footer-row-auto-center > *:only-child {
    margin: 0 auto;
  }

  ${({theme:e})=>e.breakpoints.down("md")} {
    align-items: stretch;
    flex-direction: column;
    gap: ${({theme:e})=>e.spacing(1)};
    > * {
      flex: 1 0 100%;
    }
    &.footer-row-auto-center > * {
      margin: 0 auto;
    }
  }
`;function R({elements:e,data:t,className:i="",...c}){const d=!!t.navigation?.length;let x=null;return d?x=n.jsxs(w,{sx:{display:"flex",flexDirection:{xs:"column",md:"row"},justifyContent:"space-between"},children:[n.jsxs(u,{sx:{flex:"1 1 auto",paddingRight:{xs:0,md:3},display:"flex",flexDirection:"column",alignItems:"flex-start",gap:2,pb:3},children:[n.jsx(u,{children:e.brand}),n.jsx(u,{sx:{lineHeight:1},children:e.socialMedia})]}),n.jsx(u,{sx:({palette:f})=>({mb:3,borderTop:{xs:`1px solid ${f.grey[200]}`,md:0}}),children:e.navigation})]}):x=n.jsxs(w,{sx:{display:"flex",flexDirection:{xs:"column",md:"row"},justifyContent:"space-between",alignItems:"space-between",gap:2,pb:3},children:[n.jsx(u,{children:e.brand}),n.jsx(u,{sx:{lineHeight:1},children:e.socialMedia})]}),n.jsx(ae,{...c,className:y({"footer--with-navs":d},i),children:n.jsxs(w,{style:{padding:0},children:[x,n.jsx(u,{sx:{pt:3,borderTop:1,borderColor:"divider"}}),n.jsx(w,{children:n.jsxs(T,{autoCenter:!0,children:[e.copyright,e.links]})})]})})}R.propTypes={elements:o.shape({brand:o.element,navigation:o.element,socialMedia:o.element,copyright:o.element,links:o.element}).isRequired,data:o.object.isRequired,className:o.string};const ae=k("div")`
  padding: 32px 0 24px 0;
  .footer-brand-name,
  .footer-brand-desc {
    display: none;
  }
  &.footer--with-navs {
    ${e=>e.theme.breakpoints.up("md")} {
      .footer-brand-desc {
        max-width: 360px;
        display: block;
      }
    }
  }
  && .footer-brand-logo {
    margin-right: 0;
  }
`;function E({elements:e,data:t,...i}){return n.jsx(pe,{...i,children:n.jsx(w,{style:{padding:0},children:n.jsxs(w,{className:"plain-layout-container",children:[e.links&&n.jsxs(T,{sx:{width:1},autoCenter:!0,children:[e.copyright,e.links]}),!e.links&&n.jsxs(n.Fragment,{children:[$.cloneElement(e.brand,{name:null,description:null}),e.copyright]})]})})})}E.propTypes={elements:o.shape({brand:o.element,navigation:o.element,socialMedia:o.element,copyright:o.element,links:o.element}).isRequired,data:o.object.isRequired};const pe=k("div")`
  padding: 24px 0;
  .plain-layout-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
  }
`,D=[{name:"plain",support:(e,t)=>!t.navigation?.length&&!t.socialMedia?.length,component:E},{name:"standard",support:()=>!0,component:R}],ce=D.reduce((e,t)=>({...e,[t.name]:t}),{});function F({...e}){const{brand:t=null,navigation:i=null,socialMedia:c=null,copyright:d=null,links:x=null,layout:f="auto",...g}=e,b=()=>t?n.jsx(z,{...t}):null,h=()=>i?.length?n.jsx(M,{links:i,columns:3}):null,v=()=>c?.length?n.jsx(O,{items:c}):null,l=()=>{const m=d?.owner||t?.name;return m?n.jsx(L,{owner:m,year:d?.year||void 0}):null},r=()=>x?.length?n.jsx(M,{flowLayout:!0,links:x}):null,a={brand:b(),navigation:h(),socialMedia:v(),copyright:l(),links:r()};let p=null;if(f==="auto"?p=D.find(m=>m.support(a,e)).component:p=ce[f]?.component,!p)throw new Error(`layout ${f} is not supported.`);return n.jsxs(u,{...g,className:y("blocklet__footer",g.className),sx:[{position:"relative"},...Array.isArray(g.sx)?g.sx:[g.sx]],children:[n.jsx(p,{elements:a,data:e}),n.jsx(u,{sx:{position:"absolute",right:16,bottom:0,fontSize:12,color:"transparent","::selection":{background:"#000",color:"#fff"}},children:window?.blocklet?.version})]})}F.propTypes={brand:o.shape({name:o.node,description:o.string,logo:o.node}),navigation:o.arrayOf(o.shape({label:o.node,link:o.string})),socialMedia:o.arrayOf(o.shape({icon:o.node,link:o.string})),copyright:o.shape({owner:o.string,year:o.oneOfType([o.string,o.number])}),links:o.arrayOf(o.shape({label:o.node,link:o.string})),layout:o.oneOf(["auto","standard","plain"])};function S({meta:e={},theme:t={},...i}){const{locale:c,defaultLocale:d}=A()||{},x=I(),f=$.useMemo(()=>{const s=Object.assign({},window.blocklet,e);try{return K(s)}catch(j){return console.error("Failed to format blocklet info",j,s),s}},[e]),g=$.useMemo(()=>B(x,t),[x,t]),b=U({key:"xs",meta:e,theme:t});if(!f.appName)return null;const{appName:h,appDescription:v,description:l,copyright:r}=f,a=g.palette.background.default,p={footerNav:N({navigation:f?.navigation?.footer,locale:c,defaultLocale:d,section:"footer"})||[],socialMedia:N({navigation:f?.navigation?.social,locale:c,defaultLocale:d,section:"footer"})||[],links:N({navigation:f?.navigation?.bottom,locale:c,defaultLocale:d,section:"footer"})||[]},m={brand:{name:h,description:v||l,logo:b},navigation:X(p.footerNav,s=>({...s,label:s.title,link:s.link}),"items"),copyright:r,socialMedia:p.socialMedia,links:p.links.map(s=>({...s,label:s.title}))};return n.jsx(H,{theme:g,children:n.jsx(de,{...m,...ne(i,["bordered"]),$bordered:i?.bordered,$bgcolor:a})})}S.propTypes={meta:J,theme:o.object};const de=k(F)`
  ${({$bordered:e,theme:t})=>`border-top: 1px solid ${e&&t.palette.divider};`}
  color: ${({theme:e})=>e.palette.text.secondary};
  ${({$bgcolor:e})=>e&&`background-color: ${e};`}
`,ke=W(G(S),{FallbackComponent:Y});export{ke as _};
