vuepress-theme-hope
Version:
A light vuepress theme with tons of features
3 lines (2 loc) • 29.1 kB
JavaScript
import{isLinkWithProtocol as ve,isLinkExternal as Ge,ensureEndingSlash as Ue,isLinkAbsolute as We,isArray as Ye,isPlainObject as Xe,keys as pe,startsWith as Qe,isString as F,useRoutePaths as Ze,entries as de,fromEntries as Je,hasGlobalComponent as R,isNumber as Ke,useHeaders as ea}from"@vuepress/helper/client";import{useEventListener as V,usePreferredDark as aa,useStorage as ta,watchImmediate as P,useFullscreen as Q,useScrollLock as me,useToggle as Z,useThrottleFn as la,useElementHover as oa}from"@vueuse/core";import{computed as i,provide as na,inject as he,ref as w,onMounted as T,watchEffect as sa,defineComponent as d,h as a,resolveComponent as C,toRef as J,nextTick as ra,shallowRef as j,watch as _,onUnmounted as fe,Transition as H,TransitionGroup as ua}from"vue";import{resolveRoute as q,usePageFrontmatter as G,useRouteLocale as K,useRoutePath as ge,AutoLink as ia,onContentUpdated as $,useRoute as D,useSiteData as ca,useSiteLocaleData as be,ClientOnly as ke,withBase as ye,RouteLink as we,Content as va}from"vuepress/client";import{isActiveLink as Se,IconBase as z,resolveRepoLink as pa,resolveRepoType as da,RepoIcon as ma,RenderDefault as ha}from"vuepress-shared/client";import{u as y,c as I,e as fa,d as U,P as ga,f as ba}from"./PageInfo-Cb8wmvLH.js";import ee from"@vuepress/helper/noopComponent";import ae from"./styles/variables.module.scss";import{sidebarData as te}from"@temp/theme-hope/sidebar.js";const le=(e,t)=>t.activeMatch?new RegExp(t.activeMatch,"u").test(e.path):Se(e,t.link),oe=(e,t)=>"children"in t?!!t.prefix&&Se(e,t.prefix)||t.children.some(l=>oe(e,l)):le(e,t),ne=e=>!ve(e)&&!Ge(e),se=(e,t=!1,l)=>{const{meta:s,path:o,notFound:n}=q(e,l);return n?{text:o,link:o}:{text:!t&&s.shortTitle?s.shortTitle:s.title||o,link:o,icon:s.icon}},B=(e="",t="")=>ve(t)||We(t)?t:`${Ue(e)}${t}`,Le=(e,t)=>{const l=F(e)?se(B(t,e)):e.link?{...e,link:ne(e.link)?q(B(t,e.link)).path:e.link}:e;if("children"in l){const s=B(t,l.prefix),o=l.children==="structure"?te[s]:l.children;return{...l,prefix:s,children:o.map(n=>Le(n,s))}}return{...l}},re=({config:e,prefix:t=""})=>e.map(l=>Le(l,t)),ka=({config:e,routePath:t,headerDepth:l})=>{const s=pe(e).sort((o,n)=>n.length-o.length);for(const o of s)if(Qe(decodeURI(t),o)){const n=e[o];return re({config:n==="structure"?te[o]:n||[],prefix:o})}return console.warn(`${decodeURI(t)} is missing it's sidebar config.`),[]},ya=({config:e,headerDepth:t,routeLocale:l,routePath:s})=>e==="structure"?re({config:te[l],prefix:l}):Ye(e)?re({config:e}):Xe(e)?ka({config:e,routePath:s,headerDepth:t}):[],Ce=Symbol(__VUEPRESS_DEV__?"sidebarItems":""),wa=()=>{const e=G(),t=y(),l=K(),s=ge(),o=i(()=>e.value.home?!1:e.value.sidebar??t.value.sidebar??"structure"),n=i(()=>e.value.headerDepth??t.value.headerDepth??2),r=i(()=>ya({config:o.value,headerDepth:n.value,routeLocale:l.value,routePath:s.value}));na(Ce,r)},ue=()=>{const e=he(Ce);if(!e)throw new Error("useSidebarItems() is called without provider.");return e},{mobileBreakPoint:Sa,pcBreakPoint:La}=ae,xe=e=>e.endsWith("px")?Number(e.slice(0,-2)):null,W=()=>{const e=w(!1),t=w(!1),l=()=>{e.value=window.innerWidth<=(xe(Sa)??719),t.value=window.innerWidth>=(xe(La)??1440)};return V("resize",l,!1),V("orientationchange",l,!1),T(()=>{l()}),{isMobile:e,isPC:t}},Me=Symbol(__VUEPRESS_DEV__?"darkMode":""),N=()=>{const e=he(Me);if(!e)throw new Error("useDarkMode() is called without provider.");return e},Ca=e=>{const t=aa(),l=I(),s=i(()=>l.value.darkmode??"switch"),o=ta("vuepress-theme-hope-scheme","auto"),n=i(()=>{const u=s.value;return u==="disable"?!1:u==="enable"?!0:u==="auto"?t.value:u==="toggle"?o.value==="dark":o.value==="dark"||o.value==="auto"&&t.value}),r=i(()=>{const u=s.value;return u==="switch"||u==="toggle"});e.provide(Me,{canToggle:r,config:s,isDarkMode:n,status:o}),Object.defineProperties(e.config.globalProperties,{$isDarkMode:{get:()=>n.value}})},xa=()=>{const{config:e,isDarkMode:t,status:l}=N();sa(()=>{e.value==="disable"?l.value="light":e.value==="enable"?l.value="dark":e.value==="toggle"&&l.value==="auto"&&(l.value="light")}),V("beforeprint",()=>{t.value&&document.documentElement.setAttribute("data-theme","light")}),V("afterprint",()=>{t.value&&document.documentElement.setAttribute("data-theme","dark")}),T(()=>{P(t,s=>{document.documentElement.setAttribute("data-theme",s?"dark":"light")})})};var Ma=d({name:"PageFooter",setup(){const e=I(),t=y(),l=G(),s=fa(),o=i(()=>{const{copyright:c,footer:v}=l.value;return v!==!1&&!!(c||v||t.value.displayFooter)}),n=i(()=>{const{footer:c}=l.value;return F(c)?c:t.value.footer??""}),r=i(()=>s.value.map(({name:c})=>c).join(", ")),u=c=>`Copyright © ${new Date().getFullYear()} ${r.value} ${c?`${c} Licensed`:""}`,p=i(()=>{const{copyright:c,license:v=""}=l.value,{license:b}=e.value,{copyright:g}=t.value;return c??(v?u(v):g??(r.value||b?u(b):!1))});return()=>o.value?a("footer",{class:"vp-footer-wrapper","vp-footer":""},[n.value?a("div",{class:"vp-footer",innerHTML:n.value}):null,p.value?a("div",{class:"vp-copyright",innerHTML:p.value}):null]):null}}),S=d({name:"AutoLink",props:{config:{type:Object,required:!0},iconSizing:{type:String,default:"both"}},emits:["focusout"],slots:Object,setup(e,{emit:t,slots:l}){return()=>{const{icon:s}=e.config;return a(ia,{...e,onFocusout:()=>{t("focusout")}},{default:l.default,before:l.before??(s?()=>a(C("VPIcon"),{icon:s,sizing:e.iconSizing}):null),after:l.after})}}}),Te=d({name:"NavbarDropdown",props:{config:{type:Object,required:!0}},slots:Object,setup(e,{slots:t}){const l=J(e,"config"),s=i(()=>l.value.ariaLabel??l.value.text),o=w(!1),n=r=>{r.detail===0&&(o.value=!o.value)};return $(()=>{o.value=!1}),()=>a("div",{class:["vp-dropdown-wrapper",{open:o.value}]},[a("button",{type:"button",class:"vp-dropdown-title","aria-label":s.value,onClick:n},[t.title?.()??[a(C("VPIcon"),{icon:l.value.icon}),e.config.text],a("span",{class:"arrow"}),a("ul",{class:"vp-dropdown"},l.value.children.map((r,u)=>{const p=u===l.value.children.length-1;return a("li",{class:"vp-dropdown-item"},"children"in r?[a("h4",{class:"vp-dropdown-subtitle"},r.link?a(S,{config:r,onFocusout:()=>{r.children.length===0&&p&&(o.value=!1)}}):r.text),a("ul",{class:"vp-dropdown-subitems"},r.children.map((c,v)=>a("li",{class:"vp-dropdown-subitem"},a(S,{config:c,onFocusout:()=>{v===r.children.length-1&&p&&(o.value=!1)}}))))]:a(S,{config:r,onFocusout:()=>{p&&(o.value=!1)}}))}))])])}});const Ie=()=>a(z,{name:"i18n"},()=>[a("path",{d:"M379.392 460.8 494.08 575.488l-42.496 102.4L307.2 532.48 138.24 701.44l-71.68-72.704L234.496 460.8l-45.056-45.056c-27.136-27.136-51.2-66.56-66.56-108.544h112.64c7.68 14.336 16.896 27.136 26.112 35.84l45.568 46.08 45.056-45.056C382.976 312.32 409.6 247.808 409.6 204.8H0V102.4h256V0h102.4v102.4h256v102.4H512c0 70.144-37.888 161.28-87.04 210.944L378.88 460.8zM576 870.4 512 1024H409.6l256-614.4H768l256 614.4H921.6l-64-153.6H576zM618.496 768h196.608L716.8 532.48 618.496 768z"})]);Ie.displayName="I18nIcon";const $e=(e,t="")=>F(e)?se(B(t,e)):"children"in e?{...e,...e.link&&ne(e.link)?{link:q(B(t,e.link)).path}:{},children:e.children.map(l=>$e(l,B(t,e.prefix)))}:{...e,link:ne(e.link)?q(B(t,e.link)).path:e.link},ze=()=>{const e=y();return i(()=>(e.value.navbar||[]).map(t=>$e(t)))},Ta=()=>{const e=Ze(),t=D(),l=K(),s=ca(),o=be(),n=I(),r=y();return i(()=>{const u=pe(s.value.locales),p=de(n.value.extraLocales??{});if(u.length<2&&!p.length)return null;const{path:c,fullPath:v}=t,{navbarLocales:b}=r.value;return{text:"",ariaLabel:b.selectLangAriaLabel,children:[...u.map(g=>{const L=s.value.locales[g]??{},m=n.value.locales[g]??{},h=L.lang,f=m.navbarLocales.langName;let M;if(h===o.value.lang)M=v;else{const x=c.replace(l.value,g);M=e.value.some(E=>E===x)?v.replace(c,x):m.home??g}return{text:f,link:M}}),...p.map(([g,L])=>({text:g,link:L.replace(":route",t.fullPath.replace(l.value,""))}))]}})},Ia=()=>{const e=y(),t=i(()=>e.value.repo),l=i(()=>t.value?pa(t.value):null),s=i(()=>t.value?da(t.value):null),o=i(()=>l.value?e.value.repoLabel??s.value??"Source":null);return i(()=>!l.value||!o.value||e.value.repoDisplay===!1?null:{type:s.value??"Source",label:o.value,link:l.value})};var $a=d({name:"LanguageDropdown",setup(){const e=Ta();return()=>e.value?a("div",{class:"vp-nav-item"},a(Te,{config:e.value},{title:()=>a(Ie,{"aria-label":e.value?.ariaLabel,style:{width:"1rem",height:"1rem",verticalAlign:"middle"}})})):null}}),za=d({name:"NavScreenMenu",props:{config:{type:Object,required:!0}},setup(e){const t=J(e,"config"),l=i(()=>t.value.ariaLabel??t.value.text),s=w(!1),o=(n,r)=>r[r.length-1]===n;return $(()=>{s.value=!1}),()=>[a("button",{type:"button",class:["vp-nav-screen-menu-title",{active:s.value}],"aria-label":l.value,onClick:()=>{s.value=!s.value}},[a("span",{class:"text"},[a(C("VPIcon"),{icon:t.value.icon,sizing:"both"}),e.config.text]),a("span",{class:["arrow",s.value?"down":"end"]})]),a("ul",{class:["vp-nav-screen-menu",{hide:!s.value}]},t.value.children.map(n=>a("li",{class:"vp-nav-screen-menu-item"},"children"in n?[a("h4",{class:"vp-nav-screen-menu-subtitle"},n.link?a(S,{config:n,onFocusout:()=>{o(n,t.value.children)&&n.children.length===0&&(s.value=!1)}}):n.text),a("ul",{class:"vp-nav-screen-menu-subitems"},n.children.map(r=>a("li",{class:"vp-nav-screen-menu-subitem"},a(S,{config:r,onFocusout:()=>{o(r,n.children)&&o(n,t.value.children)&&(s.value=!1)}}))))]:a(S,{config:n,onFocusout:()=>{o(n,t.value.children)&&(s.value=!1)}}))))]}}),Ba=d({name:"NavScreenLinks",setup(){const e=ze();return()=>e.value.length?a("nav",{class:"nav-screen-links"},e.value.map(t=>a("div",{class:"navbar-links-item"},"children"in t?a(za,{config:t}):a(S,{config:t})))):null}});const Be=()=>a(z,{name:"dark"},()=>a("path",{d:"M524.8 938.667h-4.267a439.893 439.893 0 0 1-313.173-134.4 446.293 446.293 0 0 1-11.093-597.334A432.213 432.213 0 0 1 366.933 90.027a42.667 42.667 0 0 1 45.227 9.386 42.667 42.667 0 0 1 10.24 42.667 358.4 358.4 0 0 0 82.773 375.893 361.387 361.387 0 0 0 376.747 82.774 42.667 42.667 0 0 1 54.187 55.04 433.493 433.493 0 0 1-99.84 154.88 438.613 438.613 0 0 1-311.467 128z"}));Be.displayName="DarkIcon";const Ee=()=>a(z,{name:"light"},()=>a("path",{d:"M952 552h-80a40 40 0 0 1 0-80h80a40 40 0 0 1 0 80zM801.88 280.08a41 41 0 0 1-57.96-57.96l57.96-58a41.04 41.04 0 0 1 58 58l-58 57.96zM512 752a240 240 0 1 1 0-480 240 240 0 0 1 0 480zm0-560a40 40 0 0 1-40-40V72a40 40 0 0 1 80 0v80a40 40 0 0 1-40 40zm-289.88 88.08-58-57.96a41.04 41.04 0 0 1 58-58l57.96 58a41 41 0 0 1-57.96 57.96zM192 512a40 40 0 0 1-40 40H72a40 40 0 0 1 0-80h80a40 40 0 0 1 40 40zm30.12 231.92a41 41 0 0 1 57.96 57.96l-57.96 58a41.04 41.04 0 0 1-58-58l58-57.96zM512 832a40 40 0 0 1 40 40v80a40 40 0 0 1-80 0v-80a40 40 0 0 1 40-40zm289.88-88.08 58 57.96a41.04 41.04 0 0 1-58 58l-57.96-58a41 41 0 0 1 57.96-57.96z"}));Ee.displayName="LightIcon";const Pe=()=>a(z,{name:"auto"},()=>a("path",{d:"M512 992C246.92 992 32 777.08 32 512S246.92 32 512 32s480 214.92 480 480-214.92 480-480 480zm0-840c-198.78 0-360 161.22-360 360 0 198.84 161.22 360 360 360s360-161.16 360-360c0-198.78-161.22-360-360-360zm0 660V212c165.72 0 300 134.34 300 300 0 165.72-134.28 300-300 300z"}));Pe.displayName="AutoIcon";const De=()=>a(z,{name:"enter-fullscreen"},()=>a("path",{d:"M762.773 90.24h-497.28c-96.106 0-174.4 78.293-174.4 174.4v497.28c0 96.107 78.294 174.4 174.4 174.4h497.28c96.107 0 175.04-78.293 174.4-174.4V264.64c0-96.213-78.186-174.4-174.4-174.4zm-387.2 761.173H215.04c-21.867 0-40.427-17.92-41.067-41.066V649.92c0-22.507 17.92-40.427 40.427-40.427 11.307 0 21.227 4.694 28.48 11.947 7.253 7.253 11.947 17.92 11.947 28.48v62.293l145.28-145.28c15.893-15.893 41.813-15.893 57.706 0 15.894 15.894 15.894 41.814 0 57.707l-145.28 145.28h62.294c22.506 0 40.426 17.92 40.426 40.427s-17.173 41.066-39.68 41.066zM650.24 165.76h160.427c21.866 0 40.426 17.92 41.066 41.067v160.426c0 22.507-17.92 40.427-40.426 40.427-11.307 0-21.227-4.693-28.48-11.947-7.254-7.253-11.947-17.92-11.947-28.48v-62.186L625.6 450.347c-15.893 15.893-41.813 15.893-57.707 0-15.893-15.894-15.893-41.814 0-57.707l145.28-145.28H650.88c-22.507 0-40.427-17.92-40.427-40.427s17.174-41.173 39.787-41.173z"}));De.displayName="EnterFullScreenIcon";const Ne=()=>a(z,{name:"cancel-fullscreen"},()=>a("path",{d:"M778.468 78.62H247.922c-102.514 0-186.027 83.513-186.027 186.027V795.08c0 102.514 83.513 186.027 186.027 186.027h530.432c102.514 0 186.71-83.513 186.026-186.027V264.647C964.494 162.02 880.981 78.62 778.468 78.62zM250.88 574.35h171.122c23.324 0 43.122 19.115 43.804 43.805v171.121c0 24.008-19.114 43.122-43.122 43.122-12.06 0-22.641-5.006-30.378-12.743s-12.743-19.115-12.743-30.379V722.83L224.597 877.91c-16.953 16.952-44.6 16.952-61.553 0-16.953-16.954-16.953-44.602 0-61.554L318.009 661.39h-66.446c-24.007 0-43.122-19.114-43.122-43.122 0-24.12 18.432-43.918 42.439-43.918zm521.899-98.873H601.657c-23.325 0-43.122-19.114-43.805-43.804V260.55c0-24.007 19.115-43.122 43.122-43.122 12.06 0 22.642 5.007 30.379 12.743s12.743 19.115 12.743 30.38v66.445l154.965-154.965c16.953-16.953 44.601-16.953 61.554 0 16.953 16.953 16.953 44.6 0 61.554L705.536 388.55h66.446c24.007 0 43.122 19.115 43.122 43.122.114 24.007-18.318 43.804-42.325 43.804z"}));Ne.displayName="CancelFullScreenIcon";const Oe=()=>a(z,{name:"outlook"},()=>[a("path",{d:"M224 800c0 9.6 3.2 44.8 6.4 54.4 6.4 48-48 76.8-48 76.8s80 41.6 147.2 0 134.4-134.4 38.4-195.2c-22.4-12.8-41.6-19.2-57.6-19.2C259.2 716.8 227.2 761.6 224 800zM560 675.2l-32 51.2c-51.2 51.2-83.2 32-83.2 32 25.6 67.2 0 112-12.8 128 25.6 6.4 51.2 9.6 80 9.6 54.4 0 102.4-9.6 150.4-32l0 0c3.2 0 3.2-3.2 3.2-3.2 22.4-16 12.8-35.2 6.4-44.8-9.6-12.8-12.8-25.6-12.8-41.6 0-54.4 60.8-99.2 137.6-99.2 6.4 0 12.8 0 22.4 0 12.8 0 38.4 9.6 48-25.6 0-3.2 0-3.2 3.2-6.4 0-3.2 3.2-6.4 3.2-6.4 6.4-16 6.4-16 6.4-19.2 9.6-35.2 16-73.6 16-115.2 0-105.6-41.6-198.4-108.8-268.8C704 396.8 560 675.2 560 675.2zM224 419.2c0-28.8 22.4-51.2 51.2-51.2 28.8 0 51.2 22.4 51.2 51.2 0 28.8-22.4 51.2-51.2 51.2C246.4 470.4 224 448 224 419.2zM320 284.8c0-22.4 19.2-41.6 41.6-41.6 22.4 0 41.6 19.2 41.6 41.6 0 22.4-19.2 41.6-41.6 41.6C339.2 326.4 320 307.2 320 284.8zM457.6 208c0-12.8 12.8-25.6 25.6-25.6 12.8 0 25.6 12.8 25.6 25.6 0 12.8-12.8 25.6-25.6 25.6C470.4 233.6 457.6 220.8 457.6 208zM128 505.6C128 592 153.6 672 201.6 736c28.8-60.8 112-60.8 124.8-60.8-16-51.2 16-99.2 16-99.2l316.8-422.4c-48-19.2-99.2-32-150.4-32C297.6 118.4 128 291.2 128 505.6zM764.8 86.4c-22.4 19.2-390.4 518.4-390.4 518.4-22.4 28.8-12.8 76.8 22.4 99.2l9.6 6.4c35.2 22.4 80 12.8 99.2-25.6 0 0 6.4-12.8 9.6-19.2 54.4-105.6 275.2-524.8 288-553.6 6.4-19.2-3.2-32-19.2-32C777.6 76.8 771.2 80 764.8 86.4z"})]);Oe.displayName="OutlookIcon";var Ae=d({name:"ColorModeSwitch",setup(){const{config:e,isDarkMode:t,status:l}=N(),s=U(),o=()=>{e.value==="switch"?l.value={light:"dark",dark:"auto",auto:"light"}[l.value]:l.value=l.value==="light"?"dark":"light"},n=async r=>{if(!(document.startViewTransition&&!window.matchMedia("(prefers-reduced-motion: reduce)").matches&&!s.value)){o();return}const u=r.clientX,p=r.clientY,c=Math.hypot(Math.max(u,innerWidth-u),Math.max(p,innerHeight-p)),v=t.value;await document.startViewTransition(async()=>{o(),await ra()}).ready,t.value!==v&&document.documentElement.animate({clipPath:t.value?[`circle(${c}px at ${u}px ${p}px)`,`circle(0px at ${u}px ${p}px)`]:[`circle(0px at ${u}px ${p}px)`,`circle(${c}px at ${u}px ${p}px)`]},{duration:400,pseudoElement:t.value?"::view-transition-old(root)":"::view-transition-new(root)"})};return()=>a("button",{type:"button",class:"vp-color-mode-switch",id:"color-mode-switch",onClick:n},[a(Pe,{style:{display:l.value==="auto"?"block":"none"}}),a(Be,{style:{display:l.value==="dark"?"block":"none"}}),a(Ee,{style:{display:l.value==="light"?"block":"none"}})])}}),Ea=d({name:"ColorMode",setup(){const e=y(),{canToggle:t}=N(),l=i(()=>e.value.outlookLocales.darkmode);return()=>t.value?a("div",{class:"vp-color-mode"},[a("label",{class:"vp-color-mode-title",for:"color-mode-switch"},l.value),a(Ae)]):null}});const ie="VUEPRESS_THEME_COLOR";var Pa=d({name:"ThemeColorPicker",props:{themeColors:{type:Object,required:!0}},setup(e){const{isDarkMode:t}=N(),l=i(()=>{const o={...e.themeColors};for(const[n,r]of Object.entries(o))n.includes("light")&&(t.value||(o[n.replace("light-","")]=r),delete o[n]),n.includes("dark")&&(t.value&&(o[n.replace("dark-","")]=r),delete o[n]);return Object.entries(o).map(([n,r])=>({name:n,color:r}))}),s=(o="")=>{const n=document.documentElement.classList,r=l.value.map(({name:u})=>u);if(!o){localStorage.removeItem(ie),n.remove(...r);return}n.remove(...r.filter(u=>u!==o)),n.add(o),localStorage.setItem(ie,o)};return T(()=>{const o=localStorage.getItem(ie);o&&s(o)}),()=>a("ul",{class:"vp-theme-color-picker",id:"theme-color-picker"},[a("li",a("span",{class:"theme-color",onClick:()=>{s()}})),l.value.map(({name:o,color:n})=>a("li",a("span",{style:{background:n},onClick:()=>{s(o)}})))])}});const O=ae.hasMultipleThemeColors==="true",Da=O?Je(de(ae).filter(([e])=>e.startsWith("theme-"))):{};var Na=d({name:"ThemeColor",setup(){const e=y(),t=i(()=>e.value.outlookLocales.themeColor);return()=>O?a("div",{class:"vp-theme-color"},[a("label",{class:"vp-theme-color-title",for:"theme-color-picker"},t.value),a(Pa,{themeColors:Da})]):null}}),Oa=d({name:"ToggleFullScreenButton",setup(){const{isSupported:e,isFullscreen:t,toggle:l}=Q();return()=>e.value?a("button",{type:"button",id:"full-screen-switch",class:"full-screen",ariaPressed:t.value,onClick:()=>l()},t.value?a(Ne):a(De)):null}}),Re=d({name:"ToggleFullScreenButton",setup(){const e=y(),{isSupported:t}=Q(),l=i(()=>e.value.outlookLocales.fullscreen);return()=>t.value?a("div",{class:"full-screen-wrapper"},[a("label",{class:"full-screen-title",for:"full-screen-switch"},l.value),a(Oa)]):null}}),Ve=d({name:"OutlookSettings",setup(){const e=I(),t=U(),l=i(()=>!t.value&&e.value.fullscreen);return()=>a(ke,()=>[O?a(Na):null,a(Ea),l.value?a(Re):null])}}),Aa=d({name:"NavScreen",props:{show:Boolean},slots:Object,setup(e,{slots:t}){const{isMobile:l}=W(),s=j(),o=me(s);return $(()=>{o.value=!1}),_(l,n=>{!n&&e.show&&(o.value=!1)}),T(()=>{s.value=document.body}),fe(()=>{o.value=!1}),()=>a(H,{name:"fade-in-down",onEnter:()=>{o.value=!0},onAfterLeave:()=>{o.value=!1}},()=>e.show?a("div",{id:"nav-screen",class:"vp-nav-screen"},a("div",{class:"vp-nav-screen-container"},[t.before?.(),a(Ba),a("div",{class:"vp-outlook-wrapper"},a(Ve)),t.after?.()])):null)}}),Ra=d({name:"NavbarBrand",setup(){const e=K(),t=be(),l=y(),s=i(()=>l.value.home??e.value),o=i(()=>t.value.title),n=i(()=>l.value.navbarTitle??o.value),r=i(()=>l.value.logo?ye(l.value.logo):null),u=i(()=>l.value.logoDark?ye(l.value.logoDark):null);return()=>a(we,{to:s.value,class:"vp-brand","aria-label":l.value.routeLocales.home},()=>[r.value?a("img",{class:["vp-nav-logo",{light:!!u.value}],src:r.value,alt:""}):null,u.value?a("img",{class:["vp-nav-logo dark"],src:u.value,alt:""}):null,n.value?a("span",{class:["vp-site-name",{"hide-in-pad":r.value&&(l.value.hideSiteNameOnMobile??!0)}]},n.value):null])}}),Va=d({name:"NavbarLinks",setup(){const e=ze();return()=>e.value.length?a("nav",{class:"vp-nav-links"},e.value.map(t=>a("div",{class:"vp-nav-item hide-in-mobile"},"children"in t?a(Te,{config:t}):a(S,{config:t,iconSizing:"height"})))):null}}),ja=d({name:"RepoLink",setup(){const e=Ia();return()=>e.value?a("div",{class:"vp-nav-item vp-action"},a("a",{class:"vp-action-link",href:e.value.link,target:"_blank",rel:"noopener noreferrer","aria-label":e.value.label},a(ma,{type:e.value.type,style:{width:"1.25rem",height:"1.25rem",verticalAlign:"middle"}}))):null}});const je=({active:e=!1},{emit:t})=>a("button",{type:"button",class:["vp-toggle-navbar-button",{"is-active":e}],"aria-label":"Toggle Navbar","aria-expanded":e,"aria-controls":"nav-screen",onClick:()=>{t("toggle")}},a("span",[a("span",{class:"vp-top"}),a("span",{class:"vp-middle"}),a("span",{class:"vp-bottom"})]));je.displayName="ToggleNavbarButton";const ce=(e,{emit:t})=>a("button",{type:"button",class:"vp-toggle-sidebar-button",title:"Toggle Sidebar",onClick:()=>{t("toggle")}},a("span",{class:"icon"}));ce.displayName="ToggleSidebarButton",ce.emits=["toggle"];var Fa=d({name:"OutlookButton",setup(){const e=I(),{canToggle:t}=N(),{isSupported:l}=Q(),s=U(),o=w(!1),n=i(()=>!s.value&&e.value.fullscreen&&l),r=i(()=>O||t.value||n.value);return $(()=>{o.value=!1}),()=>r.value?a("div",{class:"vp-nav-item hide-in-mobile"},t.value&&!n.value&&!O?a(Ae):n.value&&!t.value&&!O?a(Re):a("button",{type:"button",class:["vp-outlook-button",{open:o.value}],tabindex:"-1","aria-hidden":!0},[a(Oe),a("div",{class:"vp-outlook-dropdown"},a(Ve))])):null}}),_a=d({name:"NavBar",emits:["toggleSidebar"],slots:Object,setup(e,{emit:t,slots:l}){const s=y(),{isMobile:o}=W(),n=w(!1),r=i(()=>{const{navbarAutoHide:v="mobile"}=s.value;return v!=="none"&&(v==="always"||o.value)}),u=i(()=>s.value.navbarLayout??{start:["Brand"],center:["Links"],end:["Language","Repo","Outlook","Search"]}),p={Brand:Ra,Language:__VP_MULTI_LANGUAGES__?$a:ee,Links:Va,Repo:ja,Outlook:Fa,Search:R("SearchBox")?C("SearchBox"):ee},c=v=>p[v]??(R(v)?C(v):ee);return $(()=>{n.value=!1}),_(o,v=>{v||(n.value=!1)}),()=>[a("header",{key:"navbar",id:"navbar",class:["vp-navbar",{"auto-hide":r.value}],"vp-navbar":""},[a("div",{class:"vp-navbar-start"},[a(ce,{onToggle:()=>{n.value&&(n.value=!1),t("toggleSidebar")}}),u.value.start?.map(v=>a(c(v)))]),a("div",{class:"vp-navbar-center"},[u.value.center?.map(v=>a(c(v)))]),a("div",{class:"vp-navbar-end"},[u.value.end?.map(v=>a(c(v))),a(je,{active:n.value,onToggle:()=>{n.value=!n.value}})])]),a(Aa,{show:n.value},{before:l.screenTop,after:l.screenBottom})]}}),Ha=d({name:"SidebarChild",props:{config:{type:Object,required:!0}},setup(e){const t=D();return()=>F(e.config.link)?a(S,{class:["vp-sidebar-link",{active:le(t,e.config)}],config:{...e.config,exact:!0}}):a("p",e,[a(C("VPIcon"),{icon:e.config.icon,sizing:"both"}),e.config.text])}}),qa=d({name:"SidebarGroup",props:{config:{type:Object,required:!0},open:{type:Boolean,required:!0}},emits:["toggle"],setup(e,{emit:t}){const l=D(),s=w(!1),o=i(()=>oe(l,e.config)),n=i(()=>le(l,e.config)),r=i(()=>e.open||e.config.expanded&&!s.value);return()=>{const{collapsible:u,children:p=[],icon:c,prefix:v,link:b,text:g}=e.config;return a("section",{class:"vp-sidebar-group"},[a(u?"button":"p",{class:["vp-sidebar-header",{clickable:u||b,exact:n.value,active:o.value}],...u?{type:"button",onClick:()=>{s.value=!0,t("toggle")}}:{}},[a(C("VPIcon"),{icon:c,sizing:"both"}),b?a(S,{class:"vp-sidebar-title no-external-link-icon",config:{text:g,link:b}}):a("span",{class:"vp-sidebar-title"},g),u?a("span",{class:["vp-arrow",r.value?"down":"end"]}):null]),r.value||!u?a(Fe,{key:v,config:p}):null])}}}),Fe=d({name:"SidebarLinks",props:{config:{type:Array,required:!0}},setup(e){const t=D(),l=ge(),s=w(-1),o=n=>{s.value=n===s.value?-1:n};return P(l,()=>{const n=e.config.findIndex(r=>oe(t,r));s.value=n},{flush:"post"}),()=>a("ul",{class:"vp-sidebar-links"},e.config.map((n,r)=>a("li","children"in n?a(qa,{config:n,open:r===s.value,onToggle:()=>{o(r)}}):a(Ha,{config:n}))))}}),Ga=d({name:"SideBar",slots:Object,setup(e,{slots:t}){const l=D(),s=ue(),o=j();return T(()=>{P(()=>l.hash,n=>{const r=document.querySelector(`.vp-sidebar a.vp-sidebar-link[href="${l.path}${n}"]`);if(!r)return;const{top:u,height:p}=o.value.getBoundingClientRect(),{top:c,height:v}=r.getBoundingClientRect();c<u?r.scrollIntoView(!0):c+v>u+p&&r.scrollIntoView(!1)})}),()=>a("aside",{ref:o,key:"sidebar",id:"sidebar",class:"vp-sidebar","vp-sidebar":""},[t.top?.(),t.default?.()??a(Fe,{config:s.value}),t.bottom?.()])}}),Ua=d({name:"CommonWrapper",props:{containerClass:String,noNavbar:Boolean,noSidebar:Boolean,noToc:Boolean},slots:Object,setup(e,{slots:t}){const l=G(),s=I(),o=y(),{isMobile:n,isPC:r}=W(),u=U(),[p,c]=Z(!1),[v,b]=Z(!1),g=ue(),L=j(),m=me(L),h=w(!1),f=i(()=>e.noNavbar||l.value.navbar===!1||o.value.navbar===!1?!1:!!(o.value.logo??o.value.repo??o.value.navbar)),M=i(()=>e.noSidebar?!1:(l.value.sidebar??!0)&&g.value.length!==0&&!l.value.home),x=i(()=>l.value.externalLinkIcon??s.value.externalLinkIcon??!0),E=i(()=>!e.noToc&&!l.value.home&&(l.value.toc??o.value.toc??!0)),A={x:0,y:0},_e=k=>{A.x=k.changedTouches[0].clientX,A.y=k.changedTouches[0].clientY},He=k=>{const X=k.changedTouches[0].clientX-A.x,qe=k.changedTouches[0].clientY-A.y;Math.abs(X)>Math.abs(qe)*1.5&&Math.abs(X)>40&&(X>0&&A.x<=80?c(!0):c(!1))};let Y=0;return V("scroll",la(()=>{const k=window.scrollY;k<=58||k<Y?h.value=!1:Y+200<k&&!p.value&&(h.value=!0),Y=k},300,!0)),$(()=>{c(!1)}),_(n,k=>{k||c(!1)}),_(p,k=>{m.value=k}),T(()=>{L.value=document.body}),fe(()=>{m.value=!1}),()=>a(R("GlobalEncrypt")?C("GlobalEncrypt"):ha,()=>a("div",{class:["theme-container",{"hide-navbar":h.value,"no-navbar":!f.value,"sidebar-collapsed":!n.value&&!r.value&&v.value,"sidebar-open":n.value&&p.value,"no-sidebar":!M.value&&!t.sidebar&&!t.sidebarTop&&!t.sidebarBottom,"external-link-icon":x.value,pure:u.value,"has-toc":E.value},e.containerClass??"",l.value.containerClass??""],"vp-container":"",onTouchStart:_e,onTouchEnd:He},[f.value?a(_a,{onToggleSidebar:()=>c()},{screenTop:t.navScreenTop,screenBottom:t.navScreenBottom}):null,a(H,{name:"fade-in"},()=>p.value?a("div",{class:"vp-sidebar-mask",onClick:()=>c(!1)}):null),a(H,{name:"fade-in"},()=>n.value?null:a("div",{class:"toggle-sidebar-wrapper",onClick:()=>b()},a("span",{class:["arrow",v.value?"end":"start"]}))),a(Ga,{},{default:t.sidebar,top:t.sidebarTop,bottom:t.sidebarBottom}),t.default(),a(Ma)]))}});const Wa=d({name:"DropTransition",props:{delay:{type:Number,default:0},duration:{type:Number,default:.25},group:Boolean,appear:Boolean},slots:Object,setup(e,{slots:t}){const l=o=>{o.style.transition=`transform ${e.duration}s ease-in-out ${e.delay}s, opacity ${e.duration}s ease-in-out ${e.delay}s`,o.style.transform="translateY(-20px)",o.style.opacity="0"},s=o=>{o.style.transform="translateY(0)",o.style.opacity="1"};return()=>{const o={name:"drop",appear:e.appear,onAppear:l,onAfterAppear:s,onEnter:l,onAfterEnter:s,onBeforeLeave:l},n=()=>t.default();return e.group?a(ua,o,n):a(H,o,n)}}});var Ya=d({name:"MarkdownContent",props:{custom:Boolean},slots:Object,setup(e,{slots:t}){const l=G(),s=I(),o=y(),n=w(),r=oa(n,{delayEnter:Ke(s.value.focus)?s.value.focus:1500,delayLeave:0}),u=i(()=>!!(s.value.focus??s.value.pure)&&r.value),p=i(()=>l.value.changelog??((o.value.changelog??!1)&&!l.value.home)),c=i(()=>l.value.contributors??((o.value.contributors??!0)&&!l.value.home));return T(()=>{const v=document.documentElement;P(u,b=>{b?v.classList.add("is-focusing"):v.classList.remove("is-focusing")})}),()=>a("div",{class:{custom:e.custom},"vp-content":""},[t.before?.(),a(va,{ref:n,id:"markdown-content"}),t.after?.(),p.value&&R("GitChangelog")?a(C("GitChangelog")):null,c.value&&R("GitContributors")?a(C("GitContributors")):null])}}),Xa=d({name:"PrintButton",setup(){const e=I(),t=y();return()=>e.value.print===!1?null:a("button",{type:"button",class:"print-button",title:t.value.metaLocales.print,onClick:()=>{window.print()}},a(ga))}}),Qa=d({name:"TOC",props:{items:Array,options:Object},slots:Object,setup(e,{slots:t}){const l=J(e,"options"),s=ea(l),o=D(),n=ba(),[r,u]=Z(),p=j(),c=w("-2rem"),v=m=>{p.value?.scrollTo({top:m,behavior:"smooth"})},b=()=>{if(p.value){const m=document.querySelector(".vp-toc-item.active");m?c.value=`${m.getBoundingClientRect().top-p.value.getBoundingClientRect().top+p.value.scrollTop}px`:c.value="-2rem"}else c.value="-2rem"};T(()=>{P(()=>o.hash,m=>{if(p.value){const h=document.querySelector(`#toc a.vp-toc-link[href$="${m}"]`);if(!h)return;const{top:f,height:M}=p.value.getBoundingClientRect(),{top:x,height:E}=h.getBoundingClientRect();x<f?v(p.value.scrollTop+x-f):x+E>f+M&&v(p.value.scrollTop+x+E-f-M)}},{flush:"post"}),P(()=>o.fullPath,b,{flush:"post"})});const g=({title:m,level:h,slug:f})=>a(we,{to:`#${f}`,class:["vp-toc-link",`level${h}`],onClick:()=>{u()}},()=>m),L=m=>m.length?a("ul",{class:"vp-toc-list"},m.map(h=>{const f=L(h.children);return[a("li",{class:["vp-toc-item",{active:o.hash===`#${h.slug}`}]},g(h)),f?a("li",f):null]})):null;return()=>{const m=e.items?.length?L(e.items):L(s.value),h=t.before?.(),f=t.after?.();return a(ke,()=>m||h||f?a("div",{class:"vp-toc-placeholder"},[a("aside",{id:"toc","vp-toc":""},[h,m?[a("div",{class:"vp-toc-header",onClick:()=>{u()}},[n.value.toc,a(Xa),a("div",{class:["arrow",r.value?"down":"end"]})]),a("div",{class:["vp-toc-wrapper",r.value?"open":""],ref:p},[m,a("div",{class:"vp-toc-marker",style:{top:c.value}})])]:null,f])]):null)}}}),Za=d({name:"SkipLink",props:{content:{type:String,default:"main-content"}},setup(e){const t=y(),l=j(),s=({target:o})=>{const n=document.querySelector(o.hash);if(n){const r=()=>{n.removeAttribute("tabindex"),n.removeEventListener("blur",r)};n.setAttribute("tabindex","-1"),n.addEventListener("blur",r),n.focus(),window.scrollTo(0,0)}};return $(()=>{l.value?.focus()}),()=>[a("span",{ref:l,tabindex:"-1"}),a("a",{href:`#${e.content}`,class:"vp-skip-link sr-only",onClick:s},t.value.routeLocales.skipToContent)]}});export{Wa as D,Qa as T,N as a,W as b,Ua as c,wa as d,Ca as i,Ya as l,Za as m,S as p,se as r,xa as s,ue as u};
//# sourceMappingURL=SkipLink-BWaLo8et.js.map