1 line
10 KiB
JavaScript
1 line
10 KiB
JavaScript
import{i as W}from"./index.hcp1Nv56.js";const O=()=>{document.querySelectorAll("#main-navbar a").forEach(e=>{if(e.pathname==="/"&&location.pathname==="/"){e.classList.add("active");return}if(e.pathname==="/"&&location.pathname!=="/"){e.classList.remove("active");return}location.pathname.startsWith(e.pathname)?e.classList.add("active"):e.classList.remove("active")})};document.addEventListener("astro:page-load",O,{once:!0});document.addEventListener("astro:after-swap",O);const U="astro:before-preparation",B="astro:after-preparation",V="astro:before-swap",K="astro:after-swap",j=t=>document.dispatchEvent(new Event(t));class M extends Event{from;to;direction;navigationType;sourceElement;info;newDocument;constructor(e,r,n,a,c,l,h,s,f){super(e,r),this.from=n,this.to=a,this.direction=c,this.navigationType=l,this.sourceElement=h,this.info=s,this.newDocument=f,Object.defineProperties(this,{from:{enumerable:!0},to:{enumerable:!0,writable:!0},direction:{enumerable:!0,writable:!0},navigationType:{enumerable:!0},sourceElement:{enumerable:!0},info:{enumerable:!0},newDocument:{enumerable:!0,writable:!0}})}}class G extends M{formData;loader;constructor(e,r,n,a,c,l,h,s,f){super(U,{cancelable:!0},e,r,n,a,c,l,h),this.formData=s,this.loader=f.bind(this,this),Object.defineProperties(this,{formData:{enumerable:!0},loader:{enumerable:!0,writable:!0}})}}class z extends M{direction;viewTransition;swap;constructor(e,r,n){super(V,void 0,e.from,e.to,e.direction,e.navigationType,e.sourceElement,e.info,e.newDocument),this.direction=e.direction,this.viewTransition=r,this.swap=n.bind(this,this),Object.defineProperties(this,{direction:{enumerable:!0},viewTransition:{enumerable:!0},swap:{enumerable:!0,writable:!0}})}}async function J(t,e,r,n,a,c,l,h){const s=new G(t,e,r,n,a,c,window.document,l,h);return document.dispatchEvent(s)&&(await s.loader(),s.defaultPrevented||(j(B),s.navigationType!=="traverse"&&L({scrollX,scrollY}))),s}async function Q(t,e,r){const n=new z(t,e,r);return document.dispatchEvent(n),n.swap(),n}const Z=history.pushState.bind(history),v=history.replaceState.bind(history),L=t=>{history.state&&(history.scrollRestoration="manual",v({...history.state,...t},""))},S=!!document.startViewTransition,D=()=>!!document.querySelector('[name="astro-view-transitions-enabled"]'),q=(t,e)=>t.pathname===e.pathname&&t.search===e.search;let A,y,E=!1,H;const N=t=>document.dispatchEvent(new Event(t)),F=()=>N("astro:page-load"),ee=()=>{let t=document.createElement("div");t.setAttribute("aria-live","assertive"),t.setAttribute("aria-atomic","true"),t.className="astro-route-announcer",document.body.append(t),setTimeout(()=>{let e=document.title||document.querySelector("h1")?.textContent||location.pathname;t.textContent=e},60)},w="data-astro-transition-persist",_="data-astro-transition",$="data-astro-transition-fallback";let R,T=0;history.state?(T=history.state.index,scrollTo({left:history.state.scrollX,top:history.state.scrollY})):D()&&(v({index:T,scrollX,scrollY},""),history.scrollRestoration="manual");const te=(t,e)=>{let r=!1,n=!1;return(...a)=>{if(r){n=!0;return}t(...a),r=!0,setTimeout(()=>{n&&(n=!1,t(...a)),r=!1},e)}};async function ne(t,e){try{const r=await fetch(t,e),n=r.headers.get("content-type")?.replace(/;.*$/,"");return n!=="text/html"&&n!=="application/xhtml+xml"?null:{html:await r.text(),redirected:r.redirected?r.url:void 0,mediaType:n}}catch{return null}}function X(){const t=document.querySelector('[name="astro-view-transitions-fallback"]');return t?t.getAttribute("content"):"animate"}function re(){let t=Promise.resolve();for(const e of Array.from(document.scripts)){if(e.dataset.astroExec==="")continue;const r=document.createElement("script");r.innerHTML=e.innerHTML;for(const n of e.attributes){if(n.name==="src"){const a=new Promise(c=>{r.onload=c});t=t.then(()=>a)}r.setAttribute(n.name,n.value)}r.dataset.astroExec="",e.replaceWith(r)}return t}const Y=(t,e,r,n)=>{const a=q(e,t);let c=!1;if(t.href!==location.href&&!n)if(r.history==="replace"){const l=history.state;v({...r.state,index:l.index,scrollX:l.scrollX,scrollY:l.scrollY},"",t.href)}else Z({...r.state,index:++T,scrollX:0,scrollY:0},"",t.href);A=t,a||(scrollTo({left:0,top:0,behavior:"instant"}),c=!0),n?scrollTo(n.scrollX,n.scrollY):(t.hash?(history.scrollRestoration="auto",location.href=t.href):c||scrollTo({left:0,top:0,behavior:"instant"}),history.scrollRestoration="manual")};function oe(t){const e=[];for(const r of t.querySelectorAll("head link[rel=stylesheet]"))if(!document.querySelector(`[${w}="${r.getAttribute(w)}"], link[rel=stylesheet][href="${r.getAttribute("href")}"]`)){const n=document.createElement("link");n.setAttribute("rel","preload"),n.setAttribute("as","style"),n.setAttribute("href",r.getAttribute("href")),e.push(new Promise(a=>{["load","error"].forEach(c=>n.addEventListener(c,a)),document.head.append(n)}))}return e}async function x(t,e,r,n){const a=(o,u)=>{const m=o.getAttribute(w),p=m&&u.head.querySelector(`[${w}="${m}"]`);if(p)return p;if(o.matches("link[rel=stylesheet]")){const b=o.getAttribute("href");return u.head.querySelector(`link[rel=stylesheet][href="${b}"]`)}return null},c=()=>{const o=document.activeElement;if(o?.closest(`[${w}]`)){if(o instanceof HTMLInputElement||o instanceof HTMLTextAreaElement){const u=o.selectionStart,m=o.selectionEnd;return{activeElement:o,start:u,end:m}}return{activeElement:o}}else return{activeElement:null}},l=({activeElement:o,start:u,end:m})=>{o&&(o.focus(),(o instanceof HTMLInputElement||o instanceof HTMLTextAreaElement)&&(o.selectionStart=u,o.selectionEnd=m))},h=o=>{const u=document.documentElement,m=[...u.attributes].filter(({name:i})=>(u.removeAttribute(i),i.startsWith("data-astro-")));[...o.newDocument.documentElement.attributes,...m].forEach(({name:i,value:d})=>u.setAttribute(i,d));for(const i of document.scripts)for(const d of o.newDocument.scripts)if(!i.src&&i.textContent===d.textContent||i.src&&i.type===d.type&&i.src===d.src){d.dataset.astroExec="";break}for(const i of Array.from(document.head.children)){const d=a(i,o.newDocument);d?d.remove():i.remove()}document.head.append(...o.newDocument.head.children);const p=document.body,b=c();document.body.replaceWith(o.newDocument.body);for(const i of p.querySelectorAll(`[${w}]`)){const d=i.getAttribute(w),g=document.querySelector(`[${w}="${d}"]`);g&&g.replaceWith(i)}l(b)};async function s(o){function u(i){const d=i.effect;return!d||!(d instanceof KeyframeEffect)||!d.target?!1:window.getComputedStyle(d.target,d.pseudoElement).animationIterationCount==="infinite"}const m=document.getAnimations();document.documentElement.setAttribute($,o);const b=document.getAnimations().filter(i=>!m.includes(i)&&!u(i));return Promise.all(b.map(i=>i.finished))}if(!E)document.documentElement.setAttribute(_,t.direction),n==="animate"&&await s("old");else throw new DOMException("Transition was skipped");const f=await Q(t,y,h);Y(f.to,f.from,e,r),N(K),n==="animate"&&!E&&s("new").then(()=>H())}async function C(t,e,r,n,a){if(!D()||location.origin!==r.origin){location.href=r.href;return}const c=a?"traverse":n.history==="replace"?"replace":"push";if(c!=="traverse"&&L({scrollX,scrollY}),q(e,r)&&r.hash){Y(r,e,n,a);return}const l=await J(e,r,t,c,n.sourceElement,n.info,n.formData,h);if(l.defaultPrevented){location.href=r.href;return}async function h(s){const f=s.to.href,o={};s.formData&&(o.method="POST",o.body=s.formData);const u=await ne(f,o);if(u===null){s.preventDefault();return}if(u.redirected&&(s.to=new URL(u.redirected)),R??=new DOMParser,s.newDocument=R.parseFromString(u.html,u.mediaType),s.newDocument.querySelectorAll("noscript").forEach(p=>p.remove()),!s.newDocument.querySelector('[name="astro-view-transitions-enabled"]')&&!s.formData){s.preventDefault();return}const m=oe(s.newDocument);m.length&&await Promise.all(m)}if(E=!1,S)y=document.startViewTransition(async()=>await x(l,n,a));else{const s=(async()=>{await new Promise(f=>setTimeout(f)),await x(l,n,a,X())})();y={updateCallbackDone:s,ready:s,finished:new Promise(f=>H=f),skipTransition:()=>{E=!0}}}y.ready.then(async()=>{await re(),F(),ee()}),y.finished.then(()=>{document.documentElement.removeAttribute(_),document.documentElement.removeAttribute($)}),await y.ready}async function P(t,e){await C("forward",A,new URL(t,location.href),e??{})}function se(t){if(!D()&&t.state){location.reload();return}if(t.state===null)return;const e=history.state,r=e.index,n=r>T?"forward":"back";T=r,C(n,A,new URL(location.href),{},e)}const k=()=>{L({scrollX,scrollY})};{(S||X()!=="none")&&(A=new URL(location.href),addEventListener("popstate",se),addEventListener("load",F),"onscrollend"in window?addEventListener("scrollend",k):addEventListener("scroll",te(k,350),{passive:!0}));for(const t of document.scripts)t.dataset.astroExec=""}function ae(){const t=document.querySelector('[name="astro-view-transitions-fallback"]');return t?t.getAttribute("content"):"animate"}function I(t){return t.dataset.astroReload!==void 0}(S||ae()!=="none")&&(document.addEventListener("click",t=>{let e=t.target;if(e instanceof Element&&(e=e.closest("a, area")),!(e instanceof HTMLAnchorElement)&&!(e instanceof SVGAElement)&&!(e instanceof HTMLAreaElement))return;const r=e instanceof HTMLElement?e.target:e.target.baseVal,n=e instanceof HTMLElement?e.href:e.href.baseVal,a=new URL(n,location.href).origin;I(e)||e.hasAttribute("download")||!e.href||r&&r!=="_self"||a!==location.origin||t.button!==0||t.metaKey||t.ctrlKey||t.altKey||t.shiftKey||t.defaultPrevented||(t.preventDefault(),P(n,{history:e.dataset.astroHistory==="replace"?"replace":"auto",sourceElement:e}))}),document.addEventListener("submit",t=>{let e=t.target;if(e.tagName!=="FORM"||I(e))return;const r=e,n=t.submitter,a=new FormData(r,n);let c=n?.getAttribute("formaction")??r.action??location.pathname;const l=n?.getAttribute("formmethod")??r.method;if(l==="dialog")return;const h={sourceElement:n??r};if(l==="get"){const s=new URLSearchParams(a),f=new URL(c);f.search=s.toString(),c=f.toString()}else h.formData=a;t.preventDefault(),P(c,h)}),W({prefetchAll:!0}));document.addEventListener("astro:page-load",()=>{document.querySelectorAll(".off-canvas-toggle").forEach(t=>t.addEventListener("click",()=>{const{target:e}=t.dataset;e&&document.querySelector(e)?.classList.toggle("active")}))});
|