aptechka 0.69.8 → 0.69.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- "use strict";var Ct=(a,e)=>(e=Symbol[a])?e:Symbol.for("Symbol."+a),Tt=a=>{throw TypeError(a)};var pt=(a,e,s)=>e.has(a)||Tt("Cannot "+s);var t=(a,e,s)=>(pt(a,e,"read from private field"),s?s.call(a):e.get(a)),o=(a,e,s)=>e.has(a)?Tt("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(a):e.set(a,s),r=(a,e,s,i)=>(pt(a,e,"write to private field"),i?i.call(a,s):e.set(a,s),s),p=(a,e,s)=>(pt(a,e,"access private method"),s);var W=(a,e,s)=>new Promise((i,u)=>{var w=g=>{try{v(s.next(g))}catch(O){u(O)}},N=g=>{try{v(s.throw(g))}catch(O){u(O)}},v=g=>g.done?i(g.value):Promise.resolve(g.value).then(w,N);v((s=s.apply(a,e)).next())});var xt=(a,e,s)=>(e=a[Ct("asyncIterator")])?e.call(a):(a=a[Ct("iterator")](),e={},s=(i,u)=>(u=a[i])&&(e[i]=w=>new Promise((N,v,g)=>(w=u.call(a,w),g=w.done,Promise.resolve(w.value).then(O=>N({value:O,done:g}),v)))),s("next"),s("return"),e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Ht=require("../index-DekP7OZe.cjs"),Y=require("../events-KVanG9sR.cjs"),zt=require("../polyfills-Df4r-ETT.cjs"),Mt=require("../scroll-CIdNtj3G.cjs");require("construct-style-sheets-polyfill");const ct=require("../url-BT4fssbO.cjs"),Bt=require("../css-value-parser/index.cjs");class qt extends HTMLElement{connectedCallback(){const e={"aria-live":"assertive","aria-atomic":"true",style:"position: absolute; left: 0; top: 0; clip: rect(0 0 0 0); clip-path: inset(50%); overflow: hidden; white-space: nowrap; width: 1px; height: 1px"};for(const[s,i]of Object.entries(e))this.setAttribute(s,i)}}Ht.isBrowser&&!customElements.get("morph-announcer")&&customElements.define("morph-announcer",qt);var C,l,D,st,$;class Et{constructor(e,s){o(this,C);o(this,l);o(this,D);o(this,st,e=>{var i;if(e.preventDefault(),t(this,l).hasAttribute("data-back")&&t(this,C).previousPathname)history.back();else{r(this,D,t(this,l).getAttribute("href")||"/");const u=t(this,l).getAttribute("data-history-action")||"push",w=t(this,l).hasAttribute("data-center-scroll"),N=getComputedStyle(t(this,l)).getPropertyValue("--offset-scroll").trim(),v=N?Bt.cssValueParser.parse(N):void 0,g=t(this,l).hasAttribute("data-revalidate"),O=t(this,l).hasAttribute("data-keep-search-parameters"),h=(i=t(this,l).getAttribute("data-submorph"))==null?void 0:i.split(",").map(H=>H.trim()),ot=t(this,l).hasAttribute("data-clear-state");t(this,C).navigate(t(this,D),{historyAction:u,centerScroll:w,offsetScroll:v,revalidate:g,keepSearchParameters:O,submorph:h,clearState:ot})}});o(this,$,()=>{const e=t(this,l).hasAttribute("data-revalidate");t(this,C).prefetch(t(this,D),e),t(this,l).removeEventListener("pointerenter",t(this,$))});r(this,C,s),r(this,l,e),r(this,D,t(this,l).getAttribute("href")||"/"),t(this,l).addEventListener("click",t(this,st)),this.checkCurrent(location.pathname),t(this,l).hasAttribute("data-prefetch")&&t(this,l).addEventListener("pointerenter",t(this,$))}get element(){return t(this,l)}checkCurrent(e){const s=t(this,C).normalizePath(e),i=t(this,C).normalizePath(t(this,D));t(this,l).hasAttribute("data-include")&&s.pathname.includes(i.pathname)?t(this,l).classList.add("current"):i.pathname===s.pathname?t(this,l).classList.add("current"):t(this,l).classList.remove("current")}destroy(){t(this,l).removeEventListener("click",t(this,st)),t(this,l).removeEventListener("pointerenter",t(this,$)),t(this,l).classList.remove("current")}}C=new WeakMap,l=new WeakMap,D=new WeakMap,st=new WeakMap,$=new WeakMap;const Ot=new DOMParser;var T,I,b,P,X,R,G,j,V;class Nt{constructor(e,s){o(this,T);o(this,I);o(this,b,{x:0,y:0});o(this,P,null);o(this,X,null);o(this,R,null);o(this,G,null);o(this,j,null);o(this,V,null);r(this,T,e),r(this,I,s)}get path(){return t(this,I)}get scrollState(){return t(this,b)}get document(){return t(this,R)}setInitialDocument(e){r(this,P,e.cloneNode(!0))}abort(){var e;return(e=t(this,j))==null?void 0:e.abort(`[${t(this,I)}] page loading cancelled`)}fetch(e){return W(this,null,function*(){return t(this,V)||t(this,P)&&t(this,P).documentElement.hasAttribute("data-cache")&&!e||t(this,P)&&t(this,T).isPopstateNavigation?t(this,V):(r(this,V,new Promise(s=>W(this,null,function*(){try{r(this,j,new AbortController);const u=yield(yield fetch(t(this,I),{signal:t(this,j).signal})).text(),w=Ot.parseFromString(u,"text/html");this.setInitialDocument(w)}catch(i){console.warn(i)}finally{r(this,j,null),r(this,V,null),s()}}))),t(this,V))})}cloneDocument(){r(this,R,(t(this,X)||t(this,P)).cloneNode(!0))}get title(){let e="";if(t(this,R).title)e=t(this,R).title;else{const s=t(this,R).querySelector("h1");e=(s==null?void 0:s.innerText)||(s==null?void 0:s.textContent)||t(this,I)}return e}clearScrollState(){t(this,b).x=0,t(this,b).y=0}clearDocumentState(){r(this,X,null)}saveScrollState(){t(this,P).documentElement.hasAttribute("data-no-scroll-restoration")?(t(this,b).x=0,t(this,b).y=0):(t(this,b).x=t(this,T).scrollValue.left,t(this,b).y=t(this,T).scrollValue.top)}restoreScrollPosition(){t(this,T).scrollElement.scroll({top:t(this,b).y,left:t(this,b).x,behavior:"instant"})}saveDocumentState(){t(this,P).documentElement.hasAttribute("data-no-page-restoration")?r(this,X,null):r(this,X,document.cloneNode(!0))}renewScrollPosition(){t(this,T).scrollElement.scroll({top:0,left:0,behavior:"instant"})}saveState(e){r(this,G,e)}clearState(){const e=t(this,G);return r(this,G,null),e}}T=new WeakMap,I=new WeakMap,b=new WeakMap,P=new WeakMap,X=new WeakMap,R=new WeakMap,G=new WeakMap,j=new WeakMap,V=new WeakMap;var A,J,E,z,f,it,B,x,L,rt,M,U,Q,Z,nt,c,ht,St,Dt,vt,wt,yt,bt,ut,_;const et=class et{constructor(e){o(this,c);o(this,A,null);o(this,J,null);o(this,E,[]);o(this,z);o(this,f,null);o(this,it);o(this,B,[]);o(this,x,!1);o(this,L,null);o(this,rt,!1);o(this,M,new Map);o(this,U,null);o(this,Q,0);o(this,Z,0);o(this,nt,e=>{var s;return((s=e.getAttribute("href"))==null?void 0:s.startsWith("/"))&&!e.hasAttribute("download")&&!e.hasAttribute("data-morph-skip")&&!e.closest("[data-morph-skip]")&&e.getAttribute("target")!=="_blank"});o(this,ut,e=>W(this,null,function*(){var s;(s=e.state)!=null&&s.path&&(e.preventDefault(),r(this,x,!0),yield this.navigate(e.state.path,{historyAction:"none"}),r(this,x,!1))}));o(this,_,()=>{const{left:e,top:s}=this.scrollValue,i=s-t(this,Z),u=e-t(this,Q);r(this,Z,s),r(this,Q,e),document.documentElement.classList.toggle("scroll-y",s>0),document.documentElement.classList.toggle("scroll-x",e>0),document.documentElement.classList.toggle("scroll-y-forward",i>0),document.documentElement.classList.toggle("scroll-y-backward",i<0),document.documentElement.classList.toggle("scroll-x-forward",u>0),document.documentElement.classList.toggle("scroll-x-backward",u<0),Y.dispatchEvent(document,"morphScroll",{detail:{left:e,top:s}})});if(Ht.isBrowser&&!et.instance){et.instance=this,r(this,A,{base:ct.normalizeBase(e==null?void 0:e.base),waitForHeadToLoad:(e==null?void 0:e.waitForHeadToLoad)!==!1,trailingSlash:(e==null?void 0:e.trailingSlash)||!1,scrollSelector:e==null?void 0:e.scrollSelector,morphInsideScrollContainer:(e==null?void 0:e.morphInsideScrollContainer)||!1}),r(this,J,p(this,c,St).call(this,document.body));const s=this.normalizePath(location.pathname+location.hash+location.search);r(this,f,s.path);const i=new Nt(this,t(this,f));i.setInitialDocument(document),t(this,M).set(t(this,f),i),document.documentElement.setAttribute("data-current-pathname",t(this,f)),document.documentElement.setAttribute("data-current-leaf",s.leaf),this.findLinks(),history.scrollRestoration="manual",addEventListener("popstate",t(this,ut)),ct.changeHistory({action:"replace",pathname:s.pathname,searchParameters:s.parameters,hash:s.hash}),r(this,U,new qt),p(this,c,yt).call(this,document)}}get currentPath(){return t(this,f)}get previousPathname(){return t(this,it)}get links(){return t(this,E)}get scrollElement(){return t(this,L)}get isPopstateNavigation(){return t(this,x)}get scrollValue(){let e=0,s=0;return t(this,rt)?(e=window.scrollY,s=window.scrollX):(e=t(this,L).scrollTop,s=t(this,L).scrollLeft),{top:e,left:s}}saveState(e){const s=t(this,M).get(t(this,f));s&&s.saveState(e)}getState(){const e=t(this,M).get(t(this,f));return e==null?void 0:e.clearState()}normalizePath(e){return ct.splitPath(e,{base:t(this,A).base,trailingSlash:t(this,A).trailingSlash})}prefetch(e,s){return W(this,null,function*(){if(t(this,B).length)return;const i=p(this,c,ht).call(this,e);i==null||i.fetch(s)})}navigate(O){return W(this,arguments,function*(e,{historyAction:s="push",centerScroll:i,offsetScroll:u,revalidate:w,keepSearchParameters:N,submorph:v,clearState:g}={}){var ot;if(t(this,B).length)return;const h=this.normalizePath(((ot=this.pathnameModifier)==null?void 0:ot.call(this,e))||e);if(t(this,z)===h.path||t(this,f)===h.path){t(this,x)||p(this,c,bt).call(this,h.hash||0,{centerScroll:i,offsetScroll:u,behavior:"smooth"});return}r(this,z,h.path),t(this,E).forEach(H=>{H.checkCurrent(h.path)});try{let H=!0;if(this.preprocessor)try{yield new Promise((n,k)=>{var y;(y=this.preprocessor)==null||y.call(this,{path:e,resolve:n,reject:k,submorph:v})})}catch(n){n?console.error(n):console.log("Route change canceled"),H=!1}if(!H||t(this,z)!==h.path){t(this,E).forEach(n=>{n.checkCurrent(t(this,f))});return}const dt={path:h.path,submorph:v};Y.dispatchEvent(document,"morphNavigation",{detail:dt});const mt=p(this,c,ht).call(this,t(this,f)),m=p(this,c,ht).call(this,e);if(t(this,M).forEach(n=>{n.path!==h.path&&n.abort()}),yield m==null?void 0:m.fetch(w),t(this,z)!==h.path){t(this,E).forEach(n=>{n.checkCurrent(t(this,f))});return}mt.clearState(),mt.saveScrollState(),mt.saveDocumentState(),t(this,x)||(m.clearScrollState(),m.clearDocumentState()),g&&m.clearState(),m.cloneDocument(),t(this,U).textContent=m.title,document.body.appendChild(t(this,U)),Y.dispatchEvent(document,"morphStart",{detail:dt});const Lt=Array.from(document.head.children),Pt=Array.from(m.document.head.children),At=p(this,c,Dt).call(this,Lt,Pt),It=p(this,c,vt).call(this,Lt,At),at=p(this,c,vt).call(this,Pt,At);at.forEach((n,k)=>{if(n.tagName==="SCRIPT"&&n.getAttribute("src")){const y=document.createElement("script");y.type="module",y.src=n.getAttribute("src"),at[k]=y}}),at.forEach(n=>{document.head.appendChild(n)});const ft=at.filter(n=>{if(n.hasAttribute("data-no-waiting"))return!1;if(p(this,c,wt).call(this,n))return!0});t(this,A).waitForHeadToLoad&&ft.length&&(yield new Promise(n=>W(this,null,function*(){let k=0;try{for(var y=xt(ft),tt,F,K;tt=!(F=yield y.next()).done;tt=!1){const lt=F.value;lt.onload=()=>{k++,k===ft.length&&n()}}}catch(F){K=[F]}finally{try{tt&&(F=y.return)&&(yield F.call(y))}finally{if(K)throw K[0]}}}))),yield Mt.wait(10);const kt=[];It.forEach(n=>{n.hasAttribute("data-permanent")||(p(this,c,wt).call(this,n)?kt.push(n):n.remove())});const Rt=p(this,c,St).call(this,m.document.body);t(this,A).morphInsideScrollContainer||p(this,c,yt).call(this,m.document),document.documentElement.setAttribute("data-current-pathname",h.pathname),document.documentElement.setAttribute("data-current-leaf",h.leaf),ct.changeHistory({action:s,pathname:h.pathname,searchParameters:h.parameters||(N?location.search:""),hash:h.hash}),t(this,U).remove(),r(this,it,t(this,f)),r(this,f,h.path),t(this,J).forEach((n,k)=>{const y=Rt[k],tt=getComputedStyle(n).getPropertyValue("--morph-duration");let F=[],K=[];v?v.forEach(d=>{const S=n.querySelector(d),q=y.querySelector(d);S&&q&&(K.push(S),F.push(q))}):(F.push(...y.childNodes),K.push(...n.childNodes)),K.forEach(d=>{d instanceof HTMLElement&&(this.destroyOldLinks(d),d.classList.add("old"))}),F.forEach(d=>{d instanceof HTMLElement&&(this.findNewLinks(d),d.classList.add("new"))}),v?F.forEach((d,S)=>{var q;(q=K[S].parentElement)==null||q.insertBefore(d,K[S])}):n.prepend(...F),zt.requestIdleCallback(()=>{F.forEach(d=>{var S;d instanceof HTMLElement&&((S=d.parentElement)==null||S.style.setProperty("--new-content-height",d.offsetHeight+"px"),d.classList.add("in"))})});const lt={morphElement:n,path:h.path};Y.dispatchEvent(document,"morphNewChildrenAdded",{detail:lt});const Vt=new Promise(d=>{setTimeout(()=>{K.forEach(S=>S.remove()),F.forEach(S=>{var q;S instanceof HTMLElement&&((q=S.parentElement)==null||q.style.removeProperty("--new-content-height"),S.classList.remove("in","new"))}),Y.dispatchEvent(document,"morphOldChildrenRemoved",{detail:lt}),d()},(parseFloat(tt)||0)*1e3+10)});t(this,B).push(Vt)}),this.isPopstateNavigation?document.documentElement.style.setProperty("--new-document-scroll-position",(this.scrollValue.top-m.scrollState.y)*1+"px"):document.documentElement.style.setProperty("--new-document-scroll-position",this.scrollValue.top+"px"),Y.dispatchEvent(document,"morphBeforeNavigationScroll",{detail:m.scrollState}),h.hash?(m.clearScrollState(),p(this,c,bt).call(this,h.hash,{centerScroll:i,offsetScroll:u})):t(this,x)?m.restoreScrollPosition():m.renewScrollPosition(),yield Promise.all(t(this,B)),kt.forEach(n=>n.remove()),r(this,B,[]),t(this,J).forEach(n=>{n.querySelectorAll("script").forEach(y=>{const tt=document.createElement("script");tt.type="module",tt.src=y.getAttribute("src"),y.replaceWith(tt)})}),Y.dispatchEvent(document,"morphComplete",{detail:dt}),document.documentElement.style.removeProperty("--new-document-scroll-position"),window.dispatchEvent(new Event("resize"))}catch(H){console.error(H)}r(this,z,void 0)})}addLink(e){t(this,E).push(new Et(e,this))}addLinks(e){e.forEach(s=>{this.addLink(s)})}removeLink(e){r(this,E,t(this,E).filter(s=>s.element===e?(s.destroy(),!1):!0))}destroyOldLinks(e){r(this,E,t(this,E).filter(s=>e.contains(s.element)?(s.destroy(),!1):!0))}findNewLinks(e){const s=[...e.querySelectorAll("a")].filter(t(this,nt));t(this,E).push(...s.map(i=>new Et(i,this)))}findLinks(){const e=[...document.documentElement.querySelectorAll("a")].filter(t(this,nt));t(this,E).forEach(s=>s.destroy()),r(this,E,e.map(s=>new Et(s,this)))}};A=new WeakMap,J=new WeakMap,E=new WeakMap,z=new WeakMap,f=new WeakMap,it=new WeakMap,B=new WeakMap,x=new WeakMap,L=new WeakMap,rt=new WeakMap,M=new WeakMap,U=new WeakMap,Q=new WeakMap,Z=new WeakMap,nt=new WeakMap,c=new WeakSet,ht=function(e){let s=t(this,M).get(e);return s||(s=new Nt(this,e),t(this,M).set(e,s)),s},St=function(e){const s=[...e.querySelectorAll("[data-morph]")];return s.length?s:[e]},Dt=function(e,s){return e.filter(i=>s.find(u=>u.outerHTML===i.outerHTML))},vt=function(e,s){return e.filter(i=>!s.find(u=>u.outerHTML===i.outerHTML))},wt=function(e){return e.tagName==="SCRIPT"||e.tagName==="STYLE"||e.tagName==="LINK"&&e.getAttribute("rel")==="stylesheet"},yt=function(e){var s,i;(s=t(this,L))==null||s.removeEventListener("scroll",t(this,_)),r(this,Z,0),r(this,Q,0),r(this,L,t(this,A).scrollSelector&&e.querySelector(t(this,A).scrollSelector)||window),r(this,rt,t(this,L)===window),(i=t(this,L))==null||i.addEventListener("scroll",t(this,_)),t(this,_).call(this)},bt=function(e,s){const i=typeof e=="string"?document.getElementById(e):e;(typeof i=="number"||i)&&Mt.scrollToElement(i,{scrollElement:t(this,L),behavior:(s==null?void 0:s.behavior)||"instant",center:s==null?void 0:s.centerScroll,offset:s==null?void 0:s.offsetScroll})},ut=new WeakMap,_=new WeakMap,et.instance=null;let gt=et;exports.Morph=gt;
1
+ "use strict";var Wt=Object.defineProperty,Yt=Object.defineProperties;var Xt=Object.getOwnPropertyDescriptors;var Ct=Object.getOwnPropertySymbols;var jt=Object.prototype.hasOwnProperty,Ut=Object.prototype.propertyIsEnumerable;var Tt=(r,t)=>(t=Symbol[r])?t:Symbol.for("Symbol."+r),Mt=r=>{throw TypeError(r)};var xt=(r,t,s)=>t in r?Wt(r,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):r[t]=s,Nt=(r,t)=>{for(var s in t||(t={}))jt.call(t,s)&&xt(r,s,t[s]);if(Ct)for(var s of Ct(t))Ut.call(t,s)&&xt(r,s,t[s]);return r},Ht=(r,t)=>Yt(r,Xt(t));var pt=(r,t,s)=>t.has(r)||Mt("Cannot "+s);var e=(r,t,s)=>(pt(r,t,"read from private field"),s?s.call(r):t.get(r)),a=(r,t,s)=>t.has(r)?Mt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(r):t.set(r,s),n=(r,t,s,i)=>(pt(r,t,"write to private field"),i?i.call(r,s):t.set(r,s),s),p=(r,t,s)=>(pt(r,t,"access private method"),s);var W=(r,t,s)=>new Promise((i,u)=>{var w=g=>{try{v(s.next(g))}catch(O){u(O)}},N=g=>{try{v(s.throw(g))}catch(O){u(O)}},v=g=>g.done?i(g.value):Promise.resolve(g.value).then(w,N);v((s=s.apply(r,t)).next())});var qt=(r,t,s)=>(t=r[Tt("asyncIterator")])?t.call(r):(r=r[Tt("iterator")](),t={},s=(i,u)=>(u=r[i])&&(t[i]=w=>new Promise((N,v,g)=>(w=u.call(r,w),g=w.done,Promise.resolve(w.value).then(O=>N({value:O,done:g}),v)))),s("next"),s("return"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Rt=require("../index-DekP7OZe.cjs"),Y=require("../events-KVanG9sR.cjs"),Kt=require("../polyfills-Df4r-ETT.cjs"),Dt=require("../scroll-CIdNtj3G.cjs");require("construct-style-sheets-polyfill");const ct=require("../url-BT4fssbO.cjs"),$t=require("../css-value-parser/index.cjs");class Vt extends HTMLElement{connectedCallback(){const t={"aria-live":"assertive","aria-atomic":"true",style:"position: absolute; left: 0; top: 0; clip: rect(0 0 0 0); clip-path: inset(50%); overflow: hidden; white-space: nowrap; width: 1px; height: 1px"};for(const[s,i]of Object.entries(t))this.setAttribute(s,i)}}Rt.isBrowser&&!customElements.get("morph-announcer")&&customElements.define("morph-announcer",Vt);var C,l,D,st,$;class Et{constructor(t,s){a(this,C);a(this,l);a(this,D);a(this,st,t=>{var i;if(t.preventDefault(),e(this,l).hasAttribute("data-back")&&e(this,C).previousPathname)history.back();else{n(this,D,e(this,l).getAttribute("href")||"/");const u=e(this,l).getAttribute("data-history-action")||"push",w=e(this,l).hasAttribute("data-center-scroll"),N=getComputedStyle(e(this,l)).getPropertyValue("--offset-scroll").trim(),v=N?$t.cssValueParser.parse(N):void 0,g=e(this,l).hasAttribute("data-revalidate"),O=e(this,l).hasAttribute("data-keep-search-parameters"),h=(i=e(this,l).getAttribute("data-submorph"))==null?void 0:i.split(",").map(H=>H.trim()),ot=e(this,l).hasAttribute("data-clear-state");e(this,C).navigate(e(this,D),{historyAction:u,centerScroll:w,offsetScroll:v,revalidate:g,keepSearchParameters:O,submorph:h,clearState:ot})}});a(this,$,()=>{const t=e(this,l).hasAttribute("data-revalidate");e(this,C).prefetch(e(this,D),t),e(this,l).removeEventListener("pointerenter",e(this,$))});n(this,C,s),n(this,l,t),n(this,D,e(this,l).getAttribute("href")||"/"),e(this,l).addEventListener("click",e(this,st)),this.checkCurrent(location.pathname),e(this,l).hasAttribute("data-prefetch")&&e(this,l).addEventListener("pointerenter",e(this,$))}get element(){return e(this,l)}checkCurrent(t){const s=e(this,C).normalizePath(t),i=e(this,C).normalizePath(e(this,D));e(this,l).hasAttribute("data-include")&&s.pathname.includes(i.pathname)?e(this,l).classList.add("current"):i.pathname===s.pathname?e(this,l).classList.add("current"):e(this,l).classList.remove("current")}destroy(){e(this,l).removeEventListener("click",e(this,st)),e(this,l).removeEventListener("pointerenter",e(this,$)),e(this,l).classList.remove("current")}}C=new WeakMap,l=new WeakMap,D=new WeakMap,st=new WeakMap,$=new WeakMap;const Gt=new DOMParser;var T,I,b,P,X,R,G,j,V;class It{constructor(t,s){a(this,T);a(this,I);a(this,b,{x:0,y:0});a(this,P,null);a(this,X,null);a(this,R,null);a(this,G,null);a(this,j,null);a(this,V,null);n(this,T,t),n(this,I,s)}get path(){return e(this,I)}get scrollState(){return e(this,b)}get document(){return e(this,R)}setInitialDocument(t){n(this,P,t.cloneNode(!0))}abort(){var t;return(t=e(this,j))==null?void 0:t.abort(`[${e(this,I)}] page loading cancelled`)}fetch(t){return W(this,null,function*(){return e(this,V)||e(this,P)&&e(this,P).documentElement.hasAttribute("data-cache")&&!t||e(this,P)&&e(this,T).isPopstateNavigation?e(this,V):(n(this,V,new Promise(s=>W(this,null,function*(){try{n(this,j,new AbortController);const u=yield(yield fetch(e(this,I),{signal:e(this,j).signal})).text(),w=Gt.parseFromString(u,"text/html");this.setInitialDocument(w)}catch(i){console.warn(i)}finally{n(this,j,null),n(this,V,null),s()}}))),e(this,V))})}cloneDocument(){n(this,R,(e(this,X)||e(this,P)).cloneNode(!0))}get title(){let t="";if(e(this,R).title)t=e(this,R).title;else{const s=e(this,R).querySelector("h1");t=(s==null?void 0:s.innerText)||(s==null?void 0:s.textContent)||e(this,I)}return t}clearScrollState(){e(this,b).x=0,e(this,b).y=0}clearDocumentState(){n(this,X,null)}saveScrollState(){e(this,P).documentElement.hasAttribute("data-no-scroll-restoration")?(e(this,b).x=0,e(this,b).y=0):(e(this,b).x=e(this,T).scrollValue.left,e(this,b).y=e(this,T).scrollValue.top)}restoreScrollPosition(){e(this,T).scrollElement.scroll({top:e(this,b).y,left:e(this,b).x,behavior:"instant"})}saveDocumentState(){e(this,P).documentElement.hasAttribute("data-no-page-restoration")?n(this,X,null):n(this,X,document.cloneNode(!0))}renewScrollPosition(){e(this,T).scrollElement.scroll({top:0,left:0,behavior:"instant"})}saveState(t){n(this,G,t)}clearState(){const t=e(this,G);return n(this,G,null),t}}T=new WeakMap,I=new WeakMap,b=new WeakMap,P=new WeakMap,X=new WeakMap,R=new WeakMap,G=new WeakMap,j=new WeakMap,V=new WeakMap;var A,J,E,z,f,it,B,x,L,rt,M,U,Q,Z,nt,c,ht,St,zt,vt,wt,yt,bt,ut,_;const et=class et{constructor(t){a(this,c);a(this,A,null);a(this,J,null);a(this,E,[]);a(this,z);a(this,f,null);a(this,it);a(this,B,[]);a(this,x,!1);a(this,L,null);a(this,rt,!1);a(this,M,new Map);a(this,U,null);a(this,Q,0);a(this,Z,0);a(this,nt,t=>{var s;return((s=t.getAttribute("href"))==null?void 0:s.startsWith("/"))&&!t.hasAttribute("download")&&!t.hasAttribute("data-morph-skip")&&!t.closest("[data-morph-skip]")&&t.getAttribute("target")!=="_blank"});a(this,ut,t=>W(this,null,function*(){var s;(s=t.state)!=null&&s.path&&(t.preventDefault(),n(this,x,!0),yield this.navigate(t.state.path,{historyAction:"none"}),n(this,x,!1))}));a(this,_,()=>{const{left:t,top:s}=this.scrollValue,i=s-e(this,Z),u=t-e(this,Q);n(this,Z,s),n(this,Q,t),document.documentElement.classList.toggle("scroll-y",s>0),document.documentElement.classList.toggle("scroll-x",t>0),document.documentElement.classList.toggle("scroll-y-forward",i>0),document.documentElement.classList.toggle("scroll-y-backward",i<0),document.documentElement.classList.toggle("scroll-x-forward",u>0),document.documentElement.classList.toggle("scroll-x-backward",u<0),Y.dispatchEvent(document,"morphScroll",{detail:{left:t,top:s}})});if(Rt.isBrowser&&!et.instance){et.instance=this,n(this,A,{base:ct.normalizeBase(t==null?void 0:t.base),waitForHeadToLoad:(t==null?void 0:t.waitForHeadToLoad)!==!1,trailingSlash:(t==null?void 0:t.trailingSlash)||!1,scrollSelector:t==null?void 0:t.scrollSelector,morphInsideScrollContainer:(t==null?void 0:t.morphInsideScrollContainer)||!1}),n(this,J,p(this,c,St).call(this,document.body));const s=this.normalizePath(location.pathname+location.hash+location.search);n(this,f,s.path);const i=new It(this,e(this,f));i.setInitialDocument(document),e(this,M).set(e(this,f),i),document.documentElement.setAttribute("data-current-pathname",e(this,f)),document.documentElement.setAttribute("data-current-leaf",s.leaf),this.findLinks(),history.scrollRestoration="manual",addEventListener("popstate",e(this,ut)),ct.changeHistory({action:"replace",pathname:s.pathname,searchParameters:s.parameters,hash:s.hash}),n(this,U,new Vt),p(this,c,yt).call(this,document)}}get currentPath(){return e(this,f)}get previousPathname(){return e(this,it)}get links(){return e(this,E)}get scrollElement(){return e(this,L)}get isPopstateNavigation(){return e(this,x)}get scrollValue(){let t=0,s=0;return e(this,rt)?(t=window.scrollY,s=window.scrollX):(t=e(this,L).scrollTop,s=e(this,L).scrollLeft),{top:t,left:s}}saveState(t){const s=e(this,M).get(e(this,f));s&&s.saveState(t)}getState(){const t=e(this,M).get(e(this,f));return t==null?void 0:t.clearState()}normalizePath(t){return ct.splitPath(t,{base:e(this,A).base,trailingSlash:e(this,A).trailingSlash})}prefetch(t,s){return W(this,null,function*(){if(e(this,B).length)return;const i=p(this,c,ht).call(this,t);i==null||i.fetch(s)})}navigate(O){return W(this,arguments,function*(t,{historyAction:s="push",centerScroll:i,offsetScroll:u,revalidate:w,keepSearchParameters:N,submorph:v,clearState:g}={}){var ot;if(e(this,B).length)return;const h=this.normalizePath(((ot=this.pathnameModifier)==null?void 0:ot.call(this,t))||t);if(e(this,z)===h.path||e(this,f)===h.path){e(this,x)||p(this,c,bt).call(this,h.hash||0,{centerScroll:i,offsetScroll:u,behavior:"smooth"});return}n(this,z,h.path),e(this,E).forEach(H=>{H.checkCurrent(h.path)});try{let H=!0;if(this.preprocessor)try{yield new Promise((o,k)=>{var y;(y=this.preprocessor)==null||y.call(this,{path:t,resolve:o,reject:k,submorph:v})})}catch(o){o?console.error(o):console.log("Route change canceled"),H=!1}if(!H||e(this,z)!==h.path){e(this,E).forEach(o=>{o.checkCurrent(e(this,f))});return}const dt={path:h.path,submorph:v};Y.dispatchEvent(document,"morphNavigation",{detail:dt});const mt=p(this,c,ht).call(this,e(this,f)),m=p(this,c,ht).call(this,t);if(e(this,M).forEach(o=>{o.path!==h.path&&o.abort()}),yield m==null?void 0:m.fetch(w),e(this,z)!==h.path){e(this,E).forEach(o=>{o.checkCurrent(e(this,f))});return}mt.clearState(),mt.saveScrollState(),mt.saveDocumentState(),e(this,x)||(m.clearScrollState(),m.clearDocumentState()),g&&m.clearState(),m.cloneDocument(),e(this,U).textContent=m.title,document.body.appendChild(e(this,U)),Y.dispatchEvent(document,"morphStart",{detail:dt});const Lt=Array.from(document.head.children),Pt=Array.from(m.document.head.children),At=p(this,c,zt).call(this,Lt,Pt),Bt=p(this,c,vt).call(this,Lt,At),at=p(this,c,vt).call(this,Pt,At);at.forEach((o,k)=>{if(o.tagName==="SCRIPT"&&o.getAttribute("src")){const y=document.createElement("script");y.type="module",y.src=o.getAttribute("src"),at[k]=y}}),at.forEach(o=>{document.head.appendChild(o)});const ft=at.filter(o=>{if(o.hasAttribute("data-no-waiting"))return!1;if(p(this,c,wt).call(this,o))return!0});e(this,A).waitForHeadToLoad&&ft.length&&(yield new Promise(o=>W(this,null,function*(){let k=0;try{for(var y=qt(ft),tt,F,K;tt=!(F=yield y.next()).done;tt=!1){const lt=F.value;lt.onload=()=>{k++,k===ft.length&&o()}}}catch(F){K=[F]}finally{try{tt&&(F=y.return)&&(yield F.call(y))}finally{if(K)throw K[0]}}}))),yield Dt.wait(10);const kt=[];Bt.forEach(o=>{o.hasAttribute("data-permanent")||(p(this,c,wt).call(this,o)?kt.push(o):o.remove())});const Ot=p(this,c,St).call(this,m.document.body);e(this,A).morphInsideScrollContainer||p(this,c,yt).call(this,m.document),document.documentElement.setAttribute("data-current-pathname",h.pathname),document.documentElement.setAttribute("data-current-leaf",h.leaf),ct.changeHistory({action:s,pathname:h.pathname,searchParameters:h.parameters||(N?location.search:""),hash:h.hash}),e(this,U).remove(),n(this,it,e(this,f)),n(this,f,h.path),e(this,J).forEach((o,k)=>{const y=Ot[k],tt=getComputedStyle(o).getPropertyValue("--morph-duration");let F=[],K=[];v?v.forEach(d=>{const S=o.querySelector(d),q=y.querySelector(d);S&&q&&(K.push(S),F.push(q))}):(F.push(...y.childNodes),K.push(...o.childNodes)),K.forEach(d=>{d instanceof HTMLElement&&(this.destroyOldLinks(d),d.classList.add("old"))}),F.forEach(d=>{d instanceof HTMLElement&&(this.findNewLinks(d),d.classList.add("new"))}),v?F.forEach((d,S)=>{var q;(q=K[S].parentElement)==null||q.insertBefore(d,K[S])}):o.prepend(...F),Kt.requestIdleCallback(()=>{F.forEach(d=>{var S;d instanceof HTMLElement&&((S=d.parentElement)==null||S.style.setProperty("--new-content-height",d.offsetHeight+"px"),d.classList.add("in"))})});const lt={morphElement:o,path:h.path};Y.dispatchEvent(document,"morphNewChildrenAdded",{detail:lt});const Ft=new Promise(d=>{setTimeout(()=>{K.forEach(S=>S.remove()),F.forEach(S=>{var q;S instanceof HTMLElement&&((q=S.parentElement)==null||q.style.removeProperty("--new-content-height"),S.classList.remove("in","new"))}),Y.dispatchEvent(document,"morphOldChildrenRemoved",{detail:lt}),d()},(parseFloat(tt)||0)*1e3+10)});e(this,B).push(Ft)}),this.isPopstateNavigation?document.documentElement.style.setProperty("--new-document-scroll-position",(this.scrollValue.top-m.scrollState.y)*1+"px"):document.documentElement.style.setProperty("--new-document-scroll-position",this.scrollValue.top+"px"),Y.dispatchEvent(document,"morphBeforeNavigationScroll",{detail:m.scrollState}),h.hash?(m.clearScrollState(),p(this,c,bt).call(this,h.hash,{centerScroll:i,offsetScroll:u})):e(this,x)?m.restoreScrollPosition():m.renewScrollPosition(),yield Promise.all(e(this,B)),kt.forEach(o=>o.remove()),n(this,B,[]),e(this,J).forEach(o=>{o.querySelectorAll("script").forEach(y=>{const tt=document.createElement("script");tt.type="module",tt.src=y.getAttribute("src"),y.replaceWith(tt)})}),Y.dispatchEvent(document,"morphComplete",{detail:Ht(Nt({},dt),{document:m.document})}),document.documentElement.style.removeProperty("--new-document-scroll-position"),window.dispatchEvent(new Event("resize"))}catch(H){console.error(H)}n(this,z,void 0)})}addLink(t){e(this,E).push(new Et(t,this))}addLinks(t){t.forEach(s=>{this.addLink(s)})}removeLink(t){n(this,E,e(this,E).filter(s=>s.element===t?(s.destroy(),!1):!0))}destroyOldLinks(t){n(this,E,e(this,E).filter(s=>t.contains(s.element)?(s.destroy(),!1):!0))}findNewLinks(t){const s=[...t.querySelectorAll("a")].filter(e(this,nt));e(this,E).push(...s.map(i=>new Et(i,this)))}findLinks(){const t=[...document.documentElement.querySelectorAll("a")].filter(e(this,nt));e(this,E).forEach(s=>s.destroy()),n(this,E,t.map(s=>new Et(s,this)))}};A=new WeakMap,J=new WeakMap,E=new WeakMap,z=new WeakMap,f=new WeakMap,it=new WeakMap,B=new WeakMap,x=new WeakMap,L=new WeakMap,rt=new WeakMap,M=new WeakMap,U=new WeakMap,Q=new WeakMap,Z=new WeakMap,nt=new WeakMap,c=new WeakSet,ht=function(t){let s=e(this,M).get(t);return s||(s=new It(this,t),e(this,M).set(t,s)),s},St=function(t){const s=[...t.querySelectorAll("[data-morph]")];return s.length?s:[t]},zt=function(t,s){return t.filter(i=>s.find(u=>u.outerHTML===i.outerHTML))},vt=function(t,s){return t.filter(i=>!s.find(u=>u.outerHTML===i.outerHTML))},wt=function(t){return t.tagName==="SCRIPT"||t.tagName==="STYLE"||t.tagName==="LINK"&&t.getAttribute("rel")==="stylesheet"},yt=function(t){var s,i;(s=e(this,L))==null||s.removeEventListener("scroll",e(this,_)),n(this,Z,0),n(this,Q,0),n(this,L,e(this,A).scrollSelector&&t.querySelector(e(this,A).scrollSelector)||window),n(this,rt,e(this,L)===window),(i=e(this,L))==null||i.addEventListener("scroll",e(this,_)),e(this,_).call(this)},bt=function(t,s){const i=typeof t=="string"?document.getElementById(t):t;(typeof i=="number"||i)&&Dt.scrollToElement(i,{scrollElement:e(this,L),behavior:(s==null?void 0:s.behavior)||"instant",center:s==null?void 0:s.centerScroll,offset:s==null?void 0:s.offsetScroll})},ut=new WeakMap,_=new WeakMap,et.instance=null;let gt=et;exports.Morph=gt;