aptechka 0.59.2 → 0.60.1

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.
@@ -36,12 +36,17 @@ export interface MorphScrollDetail {
36
36
  top: number;
37
37
  }
38
38
  export interface MorphEvents {
39
+ morphNavigation: CustomEvent<MorphTransitionEntry>;
39
40
  morphStart: CustomEvent<MorphTransitionEntry>;
40
41
  morphComplete: CustomEvent<MorphTransitionEntry>;
41
42
  morphNewChildrenAdded: CustomEvent<MorphChildrenActionEntry>;
42
43
  morphOldChildrenRemoved: CustomEvent<MorphChildrenActionEntry>;
43
44
  morphScroll: CustomEvent<MorphScrollDetail>;
44
45
  }
46
+ export interface MorphGetRouteOptions {
47
+ searchParameters?: string;
48
+ revalidate?: boolean;
49
+ }
45
50
  export declare class Morph {
46
51
  #private;
47
52
  static instance: Morph;
@@ -1 +1 @@
1
- "use strict";var yt=(n,t)=>(t=Symbol[n])?t:Symbol.for("Symbol."+n),wt=n=>{throw TypeError(n)};var nt=(n,t,s)=>t.has(n)||wt("Cannot "+s);var e=(n,t,s)=>(nt(n,t,"read from private field"),s?s.call(n):t.get(n)),o=(n,t,s)=>t.has(n)?wt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(n):t.set(n,s),a=(n,t,s,i)=>(nt(n,t,"write to private field"),i?i.call(n,s):t.set(n,s),s),d=(n,t,s)=>(nt(n,t,"access private method"),s);var N=(n,t,s)=>new Promise((i,u)=>{var p=E=>{try{H(s.next(E))}catch(h){u(h)}},M=E=>{try{H(s.throw(E))}catch(h){u(h)}},H=E=>E.done?i(E.value):Promise.resolve(E.value).then(p,M);H((s=s.apply(n,t)).next())});var bt=(n,t,s)=>(t=n[yt("asyncIterator")])?t.call(n):(n=n[yt("iterator")](),t={},s=(i,u)=>(u=n[i])&&(t[i]=p=>new Promise((M,H,E)=>(p=u.call(n,p),E=p.done,Promise.resolve(p.value).then(h=>M({value:h,done:E}),H)))),s("next"),s("return"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const At=require("../index-Cqw2NKev.cjs"),K=require("../events-KVanG9sR.cjs"),Rt=require("../polyfills-Df4r-ETT.cjs"),kt=require("../scroll-DAhSpkhR.cjs"),tt=require("../url-D1CgmwZ_.cjs"),zt=require("../css-value-parser/index.cjs");class Ct 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)}}At.isBrowser&&!customElements.get("morph-announcer")&&customElements.define("morph-announcer",Ct);var b,c,x,G,F;class ot{constructor(t,s){o(this,b);o(this,c);o(this,x);o(this,G,t=>{if(t.preventDefault(),e(this,c).hasAttribute("data-back")&&e(this,b).previousPathname)history.back();else{const i=e(this,c).getAttribute("data-history-action")||"push",u=e(this,c).hasAttribute("data-center-scroll"),p=getComputedStyle(e(this,c)).getPropertyValue("--offset-scroll").trim(),M=p?zt.cssValueParser.parse(p):void 0,H=e(this,c).hasAttribute("data-revalidate"),E=e(this,c).hasAttribute("data-keep-search-parameters");e(this,b).navigate(e(this,x),{historyAction:i,centerScroll:u,offsetScroll:M,revalidate:H,keepSearchParameters:E})}});o(this,F,()=>{const t=e(this,c).hasAttribute("data-revalidate");e(this,b).prefetch(e(this,x),t),e(this,c).removeEventListener("pointerenter",e(this,F))});a(this,b,s),a(this,c,t),a(this,x,e(this,c).getAttribute("href")||"/"),e(this,c).addEventListener("click",e(this,G)),this.checkCurrent(location.pathname),e(this,c).hasAttribute("data-prefetch")&&e(this,c).addEventListener("pointerenter",e(this,F))}get element(){return e(this,c)}checkCurrent(t){const s=e(this,b).normalizePath(t),i=e(this,b).normalizePath(e(this,x));e(this,c).hasAttribute("data-include")&&s.pathname.includes(i.pathname)?e(this,c).classList.add("current"):i.pathname===s.pathname?e(this,c).classList.add("current"):e(this,c).classList.remove("current")}destroy(){e(this,c).removeEventListener("click",e(this,G)),e(this,c).removeEventListener("pointerenter",e(this,F)),e(this,c).classList.remove("current")}}b=new WeakMap,c=new WeakMap,x=new WeakMap,G=new WeakMap,F=new WeakMap;var A,V,v,q,D,C;class Pt{constructor(t,s,i){o(this,A);o(this,V);o(this,v,{x:0,y:0});o(this,q);o(this,D,null);o(this,C,null);a(this,A,t),a(this,V,s),a(this,q,i.cloneNode(!0))}get pathname(){return e(this,V)}get scrollState(){return e(this,v)}get document(){return e(this,C)}cloneDocument(){a(this,C,(e(this,D)||e(this,q)).cloneNode(!0))}get title(){let t="";if(e(this,C).title)t=e(this,C).title;else{const s=e(this,C).querySelector("h1");t=(s==null?void 0:s.innerText)||(s==null?void 0:s.textContent)||e(this,V)}return t}clearScrollState(){e(this,v).x=0,e(this,v).y=0}clearDocumentState(){a(this,D,null)}saveScrollState(){e(this,q).documentElement.hasAttribute("data-no-scroll-restoration")?(e(this,v).x=0,e(this,v).y=0):(e(this,v).x=e(this,A).scrollElement.scrollLeft,e(this,v).y=e(this,A).scrollElement.scrollTop)}saveDocumentState(){e(this,q).documentElement.hasAttribute("data-no-page-restoration")?a(this,D,null):a(this,D,document.cloneNode(!0))}restoreScrollPosition(){e(this,A).scrollElement.scroll({top:e(this,v).y,left:e(this,v).x})}renewScrollPosition(){e(this,A).scrollElement.scroll({top:0,left:0,behavior:"instant"})}}A=new WeakMap,V=new WeakMap,v=new WeakMap,q=new WeakMap,D=new WeakMap,C=new WeakMap;var k,B,m,st,T,f,J,R,P,y,W,z,Q,l,et,Tt,lt,Mt,ct,ht,ut,dt,it,j;const Y=class Y{constructor(t){o(this,l);o(this,k,null);o(this,B,null);o(this,m,[]);o(this,st,new DOMParser);o(this,T);o(this,f,null);o(this,J);o(this,R,[]);o(this,P,!1);o(this,y,null);o(this,W,new Map);o(this,z,null);o(this,Q,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"});o(this,it,t=>N(this,null,function*(){var s;(s=t.state)!=null&&s.path&&(t.preventDefault(),a(this,P,!0),yield this.navigate(t.state.path,{historyAction:"none"}),a(this,P,!1))}));o(this,j,()=>{const t=e(this,y).scrollTop,s=e(this,y).scrollLeft;document.documentElement.classList.toggle("top-scrolled",t>0),document.documentElement.classList.toggle("left-scrolled",s>0),K.dispatchEvent(document,"morphScroll",{detail:{left:s,top:t}})});if(At.isBrowser&&!Y.instance){Y.instance=this,a(this,k,{base:tt.normalizeBase(t==null?void 0:t.base),waitForHeadToLoad:(t==null?void 0:t.waitForHeadToLoad)!==!1,cachePages:(t==null?void 0:t.cachePages)!==!1,trailingSlash:(t==null?void 0:t.trailingSlash)||!1,scrollSelector:(t==null?void 0:t.scrollSelector)||"body",morphInsideScrollContainer:(t==null?void 0:t.morphInsideScrollContainer)||!1}),a(this,B,d(this,l,lt).call(this,document.body));const s=this.normalizePath(location.pathname+location.hash);a(this,f,s.pathname),e(this,W).set(e(this,f),new Pt(this,e(this,f),document)),document.documentElement.setAttribute("data-current-pathname",e(this,f)),document.documentElement.setAttribute("data-current-leaf",s.leaf),this.findLinks(),addEventListener("popstate",e(this,it)),tt.changeHistory({action:"replace",pathname:e(this,f),searchParameters:s.parameters||location.search,hash:s.hash}),a(this,z,new Ct),d(this,l,ut).call(this,document)}}get currentPathname(){return e(this,f)}get previousPathname(){return e(this,J)}get links(){return e(this,m)}get scrollElement(){return e(this,y)}get isPopstateNavigation(){return e(this,P)}normalizePath(t){return tt.splitPath(t,{base:e(this,k).base,trailingSlash:e(this,k).trailingSlash})}prefetch(t,s){return N(this,null,function*(){const i=this.normalizePath(t);d(this,l,et).call(this,i.pathname,s)})}navigate(H){return N(this,arguments,function*(t,{historyAction:s="push",centerScroll:i,offsetScroll:u,revalidate:p,keepSearchParameters:M}={}){var mt;if(e(this,R).length)return;const E=this.normalizePath(((mt=this.pathnameModifier)==null?void 0:mt.call(this,t))||t);let{pathname:h,hash:X,parameters:Ht,leaf:Nt}=E;if(e(this,T)===h||e(this,f)===h){e(this,P)||d(this,l,dt).call(this,X||0,{centerScroll:i,offsetScroll:u,behavior:"smooth"});return}a(this,T,h),e(this,m).forEach(I=>{I.checkCurrent(h)});try{let I=!0;if(this.preprocessor)try{yield new Promise((r,w)=>{var S;(S=this.preprocessor)==null||S.call(this,{pathname:h,resolve:r,reject:w})})}catch(r){r?console.error(r):console.log("Route change canceled"),I=!1}if(!I||e(this,T)!==h){e(this,m).forEach(r=>{r.checkCurrent(e(this,f))});return}const ft=yield d(this,l,et).call(this,e(this,f)),L=yield d(this,l,et).call(this,h,p);if(e(this,T)!==h){e(this,m).forEach(r=>{r.checkCurrent(e(this,f))});return}ft.saveScrollState(),ft.saveDocumentState(),e(this,P)||(L.clearScrollState(),L.clearDocumentState()),L.cloneDocument(),e(this,z).textContent=L.title,document.body.appendChild(e(this,z));const pt={pathname:h};K.dispatchEvent(document,"morphStart",{detail:pt});const Et=Array.from(document.head.children),gt=Array.from(L.document.head.children),vt=d(this,l,Mt).call(this,Et,gt),xt=d(this,l,ct).call(this,Et,vt),Z=d(this,l,ct).call(this,gt,vt);Z.forEach((r,w)=>{if(r.tagName==="SCRIPT"&&r.getAttribute("src")){const S=document.createElement("script");S.type="module",S.src=r.getAttribute("src"),Z[w]=S}}),Z.forEach(r=>{document.head.appendChild(r)});const rt=Z.filter(r=>{if(r.hasAttribute("data-no-waiting"))return!1;if(d(this,l,ht).call(this,r))return!0});e(this,k).waitForHeadToLoad&&rt.length&&(yield new Promise(r=>N(this,null,function*(){let w=0;try{for(var S=bt(rt),O,U,Lt;O=!(U=yield S.next()).done;O=!1){const _=U.value;_.onload=()=>{w++,w===rt.length&&r()}}}catch(U){Lt=[U]}finally{try{O&&(U=S.return)&&(yield U.call(S))}finally{if(Lt)throw Lt[0]}}}))),yield kt.wait(10);const St=[];xt.forEach(r=>{r.hasAttribute("data-permanent")||(d(this,l,ht).call(this,r)?St.push(r):r.remove())});const qt=d(this,l,lt).call(this,L.document.body);e(this,k).morphInsideScrollContainer||d(this,l,ut).call(this,L.document),document.documentElement.setAttribute("data-current-pathname",h),document.documentElement.setAttribute("data-current-leaf",Nt),tt.changeHistory({action:s,pathname:h,searchParameters:Ht||(M?location.search:""),hash:X}),e(this,z).remove(),a(this,J,e(this,f)),a(this,f,h),e(this,B).forEach((r,w)=>{const S=qt[w],O=getComputedStyle(r).getPropertyValue("--morph-duration"),U=[...S.childNodes];if(O){const Lt=[...r.childNodes];Lt.forEach(g=>{g instanceof HTMLElement&&(this.destroyOldLinks(g),g.classList.add("old"))}),U.forEach(g=>{g instanceof HTMLElement&&(this.findNewLinks(g),g.classList.add("new"))}),r.prepend(...U),Rt.requestIdleCallback(()=>{U.forEach(g=>{g instanceof HTMLElement&&g.classList.add("in")})});const _={morphElement:r,pathname:h};K.dispatchEvent(document,"morphNewChildrenAdded",{detail:_});const Dt=new Promise(g=>{setTimeout(()=>{Lt.forEach($=>$.remove()),U.forEach($=>{$ instanceof HTMLElement&&$.classList.remove("in","new")}),K.dispatchEvent(document,"morphOldChildrenRemoved",{detail:_}),g()},(parseFloat(O)||0)*1e3+10)});e(this,R).push(Dt)}else this.destroyOldLinks(r),r.innerHTML="",r.append(...U),this.findNewLinks(r)}),X?(L.clearScrollState(),d(this,l,dt).call(this,X,{centerScroll:i,offsetScroll:u})):e(this,P)?L.restoreScrollPosition():L.renewScrollPosition(),yield Promise.all(e(this,R)),St.forEach(r=>r.remove()),a(this,R,[]),e(this,B).forEach(r=>{r.querySelectorAll("script").forEach(S=>{const O=document.createElement("script");O.type="module",O.src=S.getAttribute("src"),S.replaceWith(O)})}),K.dispatchEvent(document,"morphComplete",{detail:pt}),window.dispatchEvent(new Event("resize"))}catch(I){console.error(I)}a(this,T,void 0)})}addLink(t){e(this,m).push(new ot(t,this))}addLinks(t){t.forEach(s=>{this.addLink(s)})}removeLink(t){a(this,m,e(this,m).filter(s=>s.element===t?(s.destroy(),!1):!0))}destroyOldLinks(t){a(this,m,e(this,m).filter(s=>t.contains(s.element)?(s.destroy(),!1):!0))}findNewLinks(t){const s=[...t.querySelectorAll("a")].filter(e(this,Q));e(this,m).push(...s.map(i=>new ot(i,this)))}findLinks(){const t=[...document.documentElement.querySelectorAll("a")].filter(e(this,Q));e(this,m).forEach(s=>s.destroy()),a(this,m,t.map(s=>new ot(s,this)))}};k=new WeakMap,B=new WeakMap,m=new WeakMap,st=new WeakMap,T=new WeakMap,f=new WeakMap,J=new WeakMap,R=new WeakMap,P=new WeakMap,y=new WeakMap,W=new WeakMap,z=new WeakMap,Q=new WeakMap,l=new WeakSet,et=function(t,s=!1){return N(this,null,function*(){let i=e(this,W).get(t);return(!i||s)&&(i=yield d(this,l,Tt).call(this,t)),i})},Tt=function(t){return N(this,null,function*(){const i=yield(yield fetch(t)).text(),u=e(this,st).parseFromString(i,"text/html"),p=new Pt(this,t,u);return e(this,W).set(t,p),p})},lt=function(t){const s=[...t.querySelectorAll("[data-morph]")];return s.length?s:[t]},Mt=function(t,s){return t.filter(i=>s.find(u=>u.outerHTML===i.outerHTML))},ct=function(t,s){return t.filter(i=>!s.find(u=>u.outerHTML===i.outerHTML))},ht=function(t){return t.tagName==="SCRIPT"||t.tagName==="STYLE"||t.tagName==="LINK"&&t.getAttribute("rel")==="stylesheet"},ut=function(t){var s,i;(s=e(this,y))==null||s.removeEventListener("scroll",e(this,j)),a(this,y,t.querySelector(e(this,k).scrollSelector)||t.documentElement),(i=e(this,y))==null||i.addEventListener("scroll",e(this,j)),e(this,j).call(this)},dt=function(t,s){const i=typeof t=="string"?document.getElementById(t):t;(typeof i=="number"||i)&&kt.scrollToElement(i,{scrollElement:e(this,y),behavior:(s==null?void 0:s.behavior)||"instant",center:s==null?void 0:s.centerScroll,offset:s==null?void 0:s.offsetScroll})},it=new WeakMap,j=new WeakMap,Y.instance=null;let at=Y;exports.Morph=at;
1
+ "use strict";var wt=(n,t)=>(t=Symbol[n])?t:Symbol.for("Symbol."+n),bt=n=>{throw TypeError(n)};var at=(n,t,s)=>t.has(n)||bt("Cannot "+s);var e=(n,t,s)=>(at(n,t,"read from private field"),s?s.call(n):t.get(n)),a=(n,t,s)=>t.has(n)?bt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(n):t.set(n,s),o=(n,t,s,i)=>(at(n,t,"write to private field"),i?i.call(n,s):t.set(n,s),s),d=(n,t,s)=>(at(n,t,"access private method"),s);var N=(n,t,s)=>new Promise((i,u)=>{var E=p=>{try{H(s.next(p))}catch(h){u(h)}},L=p=>{try{H(s.throw(p))}catch(h){u(h)}},H=p=>p.done?i(p.value):Promise.resolve(p.value).then(E,L);H((s=s.apply(n,t)).next())});var Pt=(n,t,s)=>(t=n[wt("asyncIterator")])?t.call(n):(n=n[wt("iterator")](),t={},s=(i,u)=>(u=n[i])&&(t[i]=E=>new Promise((L,H,p)=>(E=u.call(n,E),p=E.done,Promise.resolve(E.value).then(h=>L({value:h,done:p}),H)))),s("next"),s("return"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Ct=require("../index-Cqw2NKev.cjs"),F=require("../events-KVanG9sR.cjs"),Rt=require("../polyfills-Df4r-ETT.cjs"),kt=require("../scroll-DAhSpkhR.cjs"),tt=require("../url-D1CgmwZ_.cjs"),zt=require("../css-value-parser/index.cjs");class Tt 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)}}Ct.isBrowser&&!customElements.get("morph-announcer")&&customElements.define("morph-announcer",Tt);var P,l,x,Y,V;class ot{constructor(t,s){a(this,P);a(this,l);a(this,x);a(this,Y,t=>{if(t.preventDefault(),e(this,l).hasAttribute("data-back")&&e(this,P).previousPathname)history.back();else{const i=e(this,l).getAttribute("data-history-action")||"push",u=e(this,l).hasAttribute("data-center-scroll"),E=getComputedStyle(e(this,l)).getPropertyValue("--offset-scroll").trim(),L=E?zt.cssValueParser.parse(E):void 0,H=e(this,l).hasAttribute("data-revalidate"),p=e(this,l).hasAttribute("data-keep-search-parameters");e(this,P).navigate(e(this,x),{historyAction:i,centerScroll:u,offsetScroll:L,revalidate:H,keepSearchParameters:p})}});a(this,V,()=>{const t=e(this,l).hasAttribute("data-revalidate");e(this,P).prefetch(e(this,x),t),e(this,l).removeEventListener("pointerenter",e(this,V))});o(this,P,s),o(this,l,t),o(this,x,e(this,l).getAttribute("href")||"/"),e(this,l).addEventListener("click",e(this,Y)),this.checkCurrent(location.pathname),e(this,l).hasAttribute("data-prefetch")&&e(this,l).addEventListener("pointerenter",e(this,V))}get element(){return e(this,l)}checkCurrent(t){const s=e(this,P).normalizePath(t),i=e(this,P).normalizePath(e(this,x));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,Y)),e(this,l).removeEventListener("pointerenter",e(this,V)),e(this,l).classList.remove("current")}}P=new WeakMap,l=new WeakMap,x=new WeakMap,Y=new WeakMap,V=new WeakMap;var C,B,v,q,D,T;class At{constructor(t,s,i){a(this,C);a(this,B);a(this,v,{x:0,y:0});a(this,q);a(this,D,null);a(this,T,null);o(this,C,t),o(this,B,s),o(this,q,i.cloneNode(!0))}get pathname(){return e(this,B)}get scrollState(){return e(this,v)}get document(){return e(this,T)}cloneDocument(){o(this,T,(e(this,D)||e(this,q)).cloneNode(!0))}get title(){let t="";if(e(this,T).title)t=e(this,T).title;else{const s=e(this,T).querySelector("h1");t=(s==null?void 0:s.innerText)||(s==null?void 0:s.textContent)||e(this,B)}return t}clearScrollState(){e(this,v).x=0,e(this,v).y=0}clearDocumentState(){o(this,D,null)}saveScrollState(){e(this,q).documentElement.hasAttribute("data-no-scroll-restoration")?(e(this,v).x=0,e(this,v).y=0):(e(this,v).x=e(this,C).scrollElement.scrollLeft,e(this,v).y=e(this,C).scrollElement.scrollTop)}saveDocumentState(){e(this,q).documentElement.hasAttribute("data-no-page-restoration")?o(this,D,null):o(this,D,document.cloneNode(!0))}restoreScrollPosition(){e(this,C).scrollElement.scroll({top:e(this,v).y,left:e(this,v).x})}renewScrollPosition(){e(this,C).scrollElement.scroll({top:0,left:0,behavior:"instant"})}}C=new WeakMap,B=new WeakMap,v=new WeakMap,q=new WeakMap,D=new WeakMap,T=new WeakMap;var k,W,m,st,M,f,G,R,A,w,j,z,J,c,et,Mt,lt,Ht,ht,ut,dt,mt,it,U;const K=class K{constructor(t){a(this,c);a(this,k,null);a(this,W,null);a(this,m,[]);a(this,st,new DOMParser);a(this,M);a(this,f,null);a(this,G);a(this,R,[]);a(this,A,!1);a(this,w,null);a(this,j,new Map);a(this,z,null);a(this,J,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,it,t=>N(this,null,function*(){var s;(s=t.state)!=null&&s.path&&(t.preventDefault(),o(this,A,!0),yield this.navigate(t.state.path,{historyAction:"none"}),o(this,A,!1))}));a(this,U,()=>{const t=e(this,w).scrollTop,s=e(this,w).scrollLeft;document.documentElement.classList.toggle("top-scrolled",t>0),document.documentElement.classList.toggle("left-scrolled",s>0),F.dispatchEvent(document,"morphScroll",{detail:{left:s,top:t}})});if(Ct.isBrowser&&!K.instance){K.instance=this,o(this,k,{base:tt.normalizeBase(t==null?void 0:t.base),waitForHeadToLoad:(t==null?void 0:t.waitForHeadToLoad)!==!1,cachePages:(t==null?void 0:t.cachePages)!==!1,trailingSlash:(t==null?void 0:t.trailingSlash)||!1,scrollSelector:(t==null?void 0:t.scrollSelector)||"body",morphInsideScrollContainer:(t==null?void 0:t.morphInsideScrollContainer)||!1}),o(this,W,d(this,c,lt).call(this,document.body));const s=this.normalizePath(location.pathname+location.hash);o(this,f,s.pathname),e(this,j).set(e(this,f),new At(this,e(this,f),document)),document.documentElement.setAttribute("data-current-pathname",e(this,f)),document.documentElement.setAttribute("data-current-leaf",s.leaf),this.findLinks(),addEventListener("popstate",e(this,it)),tt.changeHistory({action:"replace",pathname:e(this,f),searchParameters:s.parameters||location.search,hash:s.hash}),o(this,z,new Tt),d(this,c,dt).call(this,document)}}get currentPathname(){return e(this,f)}get previousPathname(){return e(this,G)}get links(){return e(this,m)}get scrollElement(){return e(this,w)}get isPopstateNavigation(){return e(this,A)}normalizePath(t){return tt.splitPath(t,{base:e(this,k).base,trailingSlash:e(this,k).trailingSlash})}prefetch(t,s){return N(this,null,function*(){const i=this.normalizePath(t);d(this,c,et).call(this,i.pathname,{searchParameters:i.parameters,revalidate:s})})}navigate(H){return N(this,arguments,function*(t,{historyAction:s="push",centerScroll:i,offsetScroll:u,revalidate:E,keepSearchParameters:L}={}){var pt;if(e(this,R).length)return;const p=this.normalizePath(((pt=this.pathnameModifier)==null?void 0:pt.call(this,t))||t);let{pathname:h,hash:Q,parameters:ft,leaf:Nt}=p;if(e(this,M)===h||e(this,f)===h){e(this,A)||d(this,c,mt).call(this,Q||0,{centerScroll:i,offsetScroll:u,behavior:"smooth"});return}o(this,M,h),e(this,m).forEach(I=>{I.checkCurrent(h)});try{let I=!0;if(this.preprocessor)try{yield new Promise((r,b)=>{var S;(S=this.preprocessor)==null||S.call(this,{pathname:h,resolve:r,reject:b})})}catch(r){r?console.error(r):console.log("Route change canceled"),I=!1}if(!I||e(this,M)!==h){e(this,m).forEach(r=>{r.checkCurrent(e(this,f))});return}const rt={pathname:h};F.dispatchEvent(document,"morphNavigation",{detail:rt});const Et=yield d(this,c,et).call(this,e(this,f)),y=yield d(this,c,et).call(this,h,{searchParameters:ft,revalidate:E});if(e(this,M)!==h){e(this,m).forEach(r=>{r.checkCurrent(e(this,f))});return}Et.saveScrollState(),Et.saveDocumentState(),e(this,A)||(y.clearScrollState(),y.clearDocumentState()),y.cloneDocument(),e(this,z).textContent=y.title,document.body.appendChild(e(this,z)),F.dispatchEvent(document,"morphStart",{detail:rt});const gt=Array.from(document.head.children),vt=Array.from(y.document.head.children),St=d(this,c,Ht).call(this,gt,vt),xt=d(this,c,ht).call(this,gt,St),X=d(this,c,ht).call(this,vt,St);X.forEach((r,b)=>{if(r.tagName==="SCRIPT"&&r.getAttribute("src")){const S=document.createElement("script");S.type="module",S.src=r.getAttribute("src"),X[b]=S}}),X.forEach(r=>{document.head.appendChild(r)});const nt=X.filter(r=>{if(r.hasAttribute("data-no-waiting"))return!1;if(d(this,c,ut).call(this,r))return!0});e(this,k).waitForHeadToLoad&&nt.length&&(yield new Promise(r=>N(this,null,function*(){let b=0;try{for(var S=Pt(nt),O,$,yt;O=!($=yield S.next()).done;O=!1){const Z=$.value;Z.onload=()=>{b++,b===nt.length&&r()}}}catch($){yt=[$]}finally{try{O&&($=S.return)&&(yield $.call(S))}finally{if(yt)throw yt[0]}}}))),yield kt.wait(10);const Lt=[];xt.forEach(r=>{r.hasAttribute("data-permanent")||(d(this,c,ut).call(this,r)?Lt.push(r):r.remove())});const qt=d(this,c,lt).call(this,y.document.body);e(this,k).morphInsideScrollContainer||d(this,c,dt).call(this,y.document),document.documentElement.setAttribute("data-current-pathname",h),document.documentElement.setAttribute("data-current-leaf",Nt),tt.changeHistory({action:s,pathname:h,searchParameters:ft||(L?location.search:""),hash:Q}),e(this,z).remove(),o(this,G,e(this,f)),o(this,f,h),e(this,W).forEach((r,b)=>{const S=qt[b],O=getComputedStyle(r).getPropertyValue("--morph-duration"),$=[...S.childNodes];if(O){const yt=[...r.childNodes];yt.forEach(g=>{g instanceof HTMLElement&&(this.destroyOldLinks(g),g.classList.add("old"))}),$.forEach(g=>{g instanceof HTMLElement&&(this.findNewLinks(g),g.classList.add("new"))}),r.prepend(...$),Rt.requestIdleCallback(()=>{$.forEach(g=>{g instanceof HTMLElement&&g.classList.add("in")})});const Z={morphElement:r,pathname:h};F.dispatchEvent(document,"morphNewChildrenAdded",{detail:Z});const Dt=new Promise(g=>{setTimeout(()=>{yt.forEach(_=>_.remove()),$.forEach(_=>{_ instanceof HTMLElement&&_.classList.remove("in","new")}),F.dispatchEvent(document,"morphOldChildrenRemoved",{detail:Z}),g()},(parseFloat(O)||0)*1e3+10)});e(this,R).push(Dt)}else this.destroyOldLinks(r),r.innerHTML="",r.append(...$),this.findNewLinks(r)}),Q?(y.clearScrollState(),d(this,c,mt).call(this,Q,{centerScroll:i,offsetScroll:u})):e(this,A)?y.restoreScrollPosition():y.renewScrollPosition(),yield Promise.all(e(this,R)),Lt.forEach(r=>r.remove()),o(this,R,[]),e(this,W).forEach(r=>{r.querySelectorAll("script").forEach(S=>{const O=document.createElement("script");O.type="module",O.src=S.getAttribute("src"),S.replaceWith(O)})}),F.dispatchEvent(document,"morphComplete",{detail:rt}),window.dispatchEvent(new Event("resize"))}catch(I){console.error(I)}o(this,M,void 0)})}addLink(t){e(this,m).push(new ot(t,this))}addLinks(t){t.forEach(s=>{this.addLink(s)})}removeLink(t){o(this,m,e(this,m).filter(s=>s.element===t?(s.destroy(),!1):!0))}destroyOldLinks(t){o(this,m,e(this,m).filter(s=>t.contains(s.element)?(s.destroy(),!1):!0))}findNewLinks(t){const s=[...t.querySelectorAll("a")].filter(e(this,J));e(this,m).push(...s.map(i=>new ot(i,this)))}findLinks(){const t=[...document.documentElement.querySelectorAll("a")].filter(e(this,J));e(this,m).forEach(s=>s.destroy()),o(this,m,t.map(s=>new ot(s,this)))}};k=new WeakMap,W=new WeakMap,m=new WeakMap,st=new WeakMap,M=new WeakMap,f=new WeakMap,G=new WeakMap,R=new WeakMap,A=new WeakMap,w=new WeakMap,j=new WeakMap,z=new WeakMap,J=new WeakMap,c=new WeakSet,et=function(t,s){return N(this,null,function*(){let i=e(this,j).get(t);return(!i||s!=null&&s.revalidate)&&(i=yield d(this,c,Mt).call(this,t,s==null?void 0:s.searchParameters)),i})},Mt=function(t,s){return N(this,null,function*(){const u=yield(yield fetch(`${t}${s?"?"+s:""}`)).text(),E=e(this,st).parseFromString(u,"text/html"),L=new At(this,t,E);return e(this,j).set(t,L),L})},lt=function(t){const s=[...t.querySelectorAll("[data-morph]")];return s.length?s:[t]},Ht=function(t,s){return t.filter(i=>s.find(u=>u.outerHTML===i.outerHTML))},ht=function(t,s){return t.filter(i=>!s.find(u=>u.outerHTML===i.outerHTML))},ut=function(t){return t.tagName==="SCRIPT"||t.tagName==="STYLE"||t.tagName==="LINK"&&t.getAttribute("rel")==="stylesheet"},dt=function(t){var s,i;(s=e(this,w))==null||s.removeEventListener("scroll",e(this,U)),o(this,w,t.querySelector(e(this,k).scrollSelector)||t.documentElement),(i=e(this,w))==null||i.addEventListener("scroll",e(this,U)),e(this,U).call(this)},mt=function(t,s){const i=typeof t=="string"?document.getElementById(t):t;(typeof i=="number"||i)&&kt.scrollToElement(i,{scrollElement:e(this,w),behavior:(s==null?void 0:s.behavior)||"instant",center:s==null?void 0:s.centerScroll,offset:s==null?void 0:s.offsetScroll})},it=new WeakMap,U=new WeakMap,K.instance=null;let ct=K;exports.Morph=ct;
@@ -1,32 +1,32 @@
1
- var vt = (n, t) => (t = Symbol[n]) ? t : Symbol.for("Symbol." + n), St = (n) => {
1
+ var St = (n, t) => (t = Symbol[n]) ? t : Symbol.for("Symbol." + n), wt = (n) => {
2
2
  throw TypeError(n);
3
3
  };
4
- var rt = (n, t, s) => t.has(n) || St("Cannot " + s);
5
- var e = (n, t, s) => (rt(n, t, "read from private field"), s ? s.call(n) : t.get(n)), o = (n, t, s) => t.has(n) ? St("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(n) : t.set(n, s), a = (n, t, s, i) => (rt(n, t, "write to private field"), i ? i.call(n, s) : t.set(n, s), s), d = (n, t, s) => (rt(n, t, "access private method"), s);
4
+ var nt = (n, t, s) => t.has(n) || wt("Cannot " + s);
5
+ var e = (n, t, s) => (nt(n, t, "read from private field"), s ? s.call(n) : t.get(n)), a = (n, t, s) => t.has(n) ? wt("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(n) : t.set(n, s), o = (n, t, s, i) => (nt(n, t, "write to private field"), i ? i.call(n, s) : t.set(n, s), s), d = (n, t, s) => (nt(n, t, "access private method"), s);
6
6
  var N = (n, t, s) => new Promise((i, u) => {
7
- var p = (E) => {
7
+ var E = (p) => {
8
8
  try {
9
- M(s.next(E));
9
+ M(s.next(p));
10
10
  } catch (h) {
11
11
  u(h);
12
12
  }
13
- }, H = (E) => {
13
+ }, S = (p) => {
14
14
  try {
15
- M(s.throw(E));
15
+ M(s.throw(p));
16
16
  } catch (h) {
17
17
  u(h);
18
18
  }
19
- }, M = (E) => E.done ? i(E.value) : Promise.resolve(E.value).then(p, H);
19
+ }, M = (p) => p.done ? i(p.value) : Promise.resolve(p.value).then(E, S);
20
20
  M((s = s.apply(n, t)).next());
21
21
  });
22
- var wt = (n, t, s) => (t = n[vt("asyncIterator")]) ? t.call(n) : (n = n[vt("iterator")](), t = {}, s = (i, u) => (u = n[i]) && (t[i] = (p) => new Promise((H, M, E) => (p = u.call(n, p), E = p.done, Promise.resolve(p.value).then((h) => H({ value: h, done: E }), M)))), s("next"), s("return"), t);
22
+ var yt = (n, t, s) => (t = n[St("asyncIterator")]) ? t.call(n) : (n = n[St("iterator")](), t = {}, s = (i, u) => (u = n[i]) && (t[i] = (E) => new Promise((S, M, p) => (E = u.call(n, E), p = E.done, Promise.resolve(E.value).then((h) => S({ value: h, done: p }), M)))), s("next"), s("return"), t);
23
23
  import { i as At } from "../index-euf5anj6.js";
24
- import { d as K } from "../events-CsVF98U6.js";
24
+ import { d as F } from "../events-CsVF98U6.js";
25
25
  import { r as Rt } from "../polyfills-DJrTJQky.js";
26
26
  import { w as zt, s as It } from "../scroll-Benkuq-t.js";
27
- import { n as qt, c as yt, s as Ot } from "../url-B6BNcw6_.js";
27
+ import { n as qt, c as bt, s as Ot } from "../url-B6BNcw6_.js";
28
28
  import { cssValueParser as Ft } from "../css-value-parser/index.js";
29
- class Pt extends HTMLElement {
29
+ class Ct extends HTMLElement {
30
30
  connectedCallback() {
31
31
  const t = {
32
32
  "aria-live": "assertive",
@@ -37,200 +37,203 @@ class Pt extends HTMLElement {
37
37
  this.setAttribute(s, i);
38
38
  }
39
39
  }
40
- At && !customElements.get("morph-announcer") && customElements.define("morph-announcer", Pt);
41
- var b, c, x, G, F;
42
- class nt {
40
+ At && !customElements.get("morph-announcer") && customElements.define("morph-announcer", Ct);
41
+ var k, c, x, Y, V;
42
+ class at {
43
43
  constructor(t, s) {
44
- o(this, b);
45
- o(this, c);
46
- o(this, x);
47
- o(this, G, (t) => {
48
- if (t.preventDefault(), e(this, c).hasAttribute("data-back") && e(this, b).previousPathname)
44
+ a(this, k);
45
+ a(this, c);
46
+ a(this, x);
47
+ a(this, Y, (t) => {
48
+ if (t.preventDefault(), e(this, c).hasAttribute("data-back") && e(this, k).previousPathname)
49
49
  history.back();
50
50
  else {
51
51
  const i = e(this, c).getAttribute(
52
52
  "data-history-action"
53
- ) || "push", u = e(this, c).hasAttribute("data-center-scroll"), p = getComputedStyle(e(this, c)).getPropertyValue("--offset-scroll").trim(), H = p ? Ft.parse(p) : void 0, M = e(this, c).hasAttribute("data-revalidate"), E = e(this, c).hasAttribute(
53
+ ) || "push", u = e(this, c).hasAttribute("data-center-scroll"), E = getComputedStyle(e(this, c)).getPropertyValue("--offset-scroll").trim(), S = E ? Ft.parse(E) : void 0, M = e(this, c).hasAttribute("data-revalidate"), p = e(this, c).hasAttribute(
54
54
  "data-keep-search-parameters"
55
55
  );
56
- e(this, b).navigate(e(this, x), {
56
+ e(this, k).navigate(e(this, x), {
57
57
  historyAction: i,
58
58
  centerScroll: u,
59
- offsetScroll: H,
59
+ offsetScroll: S,
60
60
  revalidate: M,
61
- keepSearchParameters: E
61
+ keepSearchParameters: p
62
62
  });
63
63
  }
64
64
  });
65
- o(this, F, () => {
65
+ a(this, V, () => {
66
66
  const t = e(this, c).hasAttribute("data-revalidate");
67
- e(this, b).prefetch(e(this, x), t), e(this, c).removeEventListener("pointerenter", e(this, F));
67
+ e(this, k).prefetch(e(this, x), t), e(this, c).removeEventListener("pointerenter", e(this, V));
68
68
  });
69
- a(this, b, s), a(this, c, t), a(this, x, e(this, c).getAttribute("href") || "/"), e(this, c).addEventListener("click", e(this, G)), this.checkCurrent(location.pathname), e(this, c).hasAttribute("data-prefetch") && e(this, c).addEventListener("pointerenter", e(this, F));
69
+ o(this, k, s), o(this, c, t), o(this, x, e(this, c).getAttribute("href") || "/"), e(this, c).addEventListener("click", e(this, Y)), this.checkCurrent(location.pathname), e(this, c).hasAttribute("data-prefetch") && e(this, c).addEventListener("pointerenter", e(this, V));
70
70
  }
71
71
  get element() {
72
72
  return e(this, c);
73
73
  }
74
74
  checkCurrent(t) {
75
- const s = e(this, b).normalizePath(t), i = e(this, b).normalizePath(e(this, x));
75
+ const s = e(this, k).normalizePath(t), i = e(this, k).normalizePath(e(this, x));
76
76
  e(this, c).hasAttribute("data-include") && s.pathname.includes(i.pathname) ? e(this, c).classList.add("current") : i.pathname === s.pathname ? e(this, c).classList.add("current") : e(this, c).classList.remove("current");
77
77
  }
78
78
  destroy() {
79
- e(this, c).removeEventListener("click", e(this, G)), e(this, c).removeEventListener("pointerenter", e(this, F)), e(this, c).classList.remove("current");
79
+ e(this, c).removeEventListener("click", e(this, Y)), e(this, c).removeEventListener("pointerenter", e(this, V)), e(this, c).classList.remove("current");
80
80
  }
81
81
  }
82
- b = new WeakMap(), c = new WeakMap(), x = new WeakMap(), G = new WeakMap(), F = new WeakMap();
83
- var P, V, L, D, R, C;
84
- class bt {
82
+ k = new WeakMap(), c = new WeakMap(), x = new WeakMap(), Y = new WeakMap(), V = new WeakMap();
83
+ var C, W, v, D, R, T;
84
+ class kt {
85
85
  constructor(t, s, i) {
86
- o(this, P);
87
- o(this, V);
88
- o(this, L, { x: 0, y: 0 });
89
- o(this, D);
90
- o(this, R, null);
91
- o(this, C, null);
92
- a(this, P, t), a(this, V, s), a(this, D, i.cloneNode(!0));
86
+ a(this, C);
87
+ a(this, W);
88
+ a(this, v, { x: 0, y: 0 });
89
+ a(this, D);
90
+ a(this, R, null);
91
+ a(this, T, null);
92
+ o(this, C, t), o(this, W, s), o(this, D, i.cloneNode(!0));
93
93
  }
94
94
  get pathname() {
95
- return e(this, V);
95
+ return e(this, W);
96
96
  }
97
97
  get scrollState() {
98
- return e(this, L);
98
+ return e(this, v);
99
99
  }
100
100
  get document() {
101
- return e(this, C);
101
+ return e(this, T);
102
102
  }
103
103
  cloneDocument() {
104
- a(this, C, (e(this, R) || e(this, D)).cloneNode(!0));
104
+ o(this, T, (e(this, R) || e(this, D)).cloneNode(!0));
105
105
  }
106
106
  get title() {
107
107
  let t = "";
108
- if (e(this, C).title)
109
- t = e(this, C).title;
108
+ if (e(this, T).title)
109
+ t = e(this, T).title;
110
110
  else {
111
- const s = e(this, C).querySelector("h1");
112
- t = (s == null ? void 0 : s.innerText) || (s == null ? void 0 : s.textContent) || e(this, V);
111
+ const s = e(this, T).querySelector("h1");
112
+ t = (s == null ? void 0 : s.innerText) || (s == null ? void 0 : s.textContent) || e(this, W);
113
113
  }
114
114
  return t;
115
115
  }
116
116
  clearScrollState() {
117
- e(this, L).x = 0, e(this, L).y = 0;
117
+ e(this, v).x = 0, e(this, v).y = 0;
118
118
  }
119
119
  clearDocumentState() {
120
- a(this, R, null);
120
+ o(this, R, null);
121
121
  }
122
122
  saveScrollState() {
123
123
  e(this, D).documentElement.hasAttribute(
124
124
  "data-no-scroll-restoration"
125
- ) ? (e(this, L).x = 0, e(this, L).y = 0) : (e(this, L).x = e(this, P).scrollElement.scrollLeft, e(this, L).y = e(this, P).scrollElement.scrollTop);
125
+ ) ? (e(this, v).x = 0, e(this, v).y = 0) : (e(this, v).x = e(this, C).scrollElement.scrollLeft, e(this, v).y = e(this, C).scrollElement.scrollTop);
126
126
  }
127
127
  saveDocumentState() {
128
128
  e(this, D).documentElement.hasAttribute(
129
129
  "data-no-page-restoration"
130
- ) ? a(this, R, null) : a(this, R, document.cloneNode(!0));
130
+ ) ? o(this, R, null) : o(this, R, document.cloneNode(!0));
131
131
  }
132
132
  restoreScrollPosition() {
133
- e(this, P).scrollElement.scroll({
134
- top: e(this, L).y,
135
- left: e(this, L).x
133
+ e(this, C).scrollElement.scroll({
134
+ top: e(this, v).y,
135
+ left: e(this, v).x
136
136
  });
137
137
  }
138
138
  renewScrollPosition() {
139
- e(this, P).scrollElement.scroll({
139
+ e(this, C).scrollElement.scroll({
140
140
  top: 0,
141
141
  left: 0,
142
142
  behavior: "instant"
143
143
  });
144
144
  }
145
145
  }
146
- P = new WeakMap(), V = new WeakMap(), L = new WeakMap(), D = new WeakMap(), R = new WeakMap(), C = new WeakMap();
147
- var k, W, m, et, T, f, J, z, A, w, B, I, Q, l, tt, Ct, ot, Tt, at, lt, ct, ht, st, U;
148
- const Y = class Y {
146
+ C = new WeakMap(), W = new WeakMap(), v = new WeakMap(), D = new WeakMap(), R = new WeakMap(), T = new WeakMap();
147
+ var P, B, m, et, H, f, G, z, A, y, U, I, J, l, tt, Tt, ot, Ht, lt, ct, ht, ut, st, $;
148
+ const K = class K {
149
149
  constructor(t) {
150
- o(this, l);
151
- o(this, k, null);
152
- o(this, W, null);
153
- o(this, m, []);
154
- o(this, et, new DOMParser());
155
- o(this, T);
156
- o(this, f, null);
157
- o(this, J);
158
- o(this, z, []);
159
- o(this, A, !1);
160
- o(this, w, null);
161
- o(this, B, /* @__PURE__ */ new Map());
162
- o(this, I, null);
163
- o(this, Q, (t) => {
150
+ a(this, l);
151
+ a(this, P, null);
152
+ a(this, B, null);
153
+ a(this, m, []);
154
+ a(this, et, new DOMParser());
155
+ a(this, H);
156
+ a(this, f, null);
157
+ a(this, G);
158
+ a(this, z, []);
159
+ a(this, A, !1);
160
+ a(this, y, null);
161
+ a(this, U, /* @__PURE__ */ new Map());
162
+ a(this, I, null);
163
+ a(this, J, (t) => {
164
164
  var s;
165
165
  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";
166
166
  });
167
- o(this, st, (t) => N(this, null, function* () {
167
+ a(this, st, (t) => N(this, null, function* () {
168
168
  var s;
169
- (s = t.state) != null && s.path && (t.preventDefault(), a(this, A, !0), yield this.navigate(t.state.path, { historyAction: "none" }), a(this, A, !1));
169
+ (s = t.state) != null && s.path && (t.preventDefault(), o(this, A, !0), yield this.navigate(t.state.path, { historyAction: "none" }), o(this, A, !1));
170
170
  }));
171
- o(this, U, () => {
172
- const t = e(this, w).scrollTop, s = e(this, w).scrollLeft;
173
- document.documentElement.classList.toggle("top-scrolled", t > 0), document.documentElement.classList.toggle("left-scrolled", s > 0), K(document, "morphScroll", {
171
+ a(this, $, () => {
172
+ const t = e(this, y).scrollTop, s = e(this, y).scrollLeft;
173
+ document.documentElement.classList.toggle("top-scrolled", t > 0), document.documentElement.classList.toggle("left-scrolled", s > 0), F(document, "morphScroll", {
174
174
  detail: {
175
175
  left: s,
176
176
  top: t
177
177
  }
178
178
  });
179
179
  });
180
- if (At && !Y.instance) {
181
- Y.instance = this, a(this, k, {
180
+ if (At && !K.instance) {
181
+ K.instance = this, o(this, P, {
182
182
  base: qt(t == null ? void 0 : t.base),
183
183
  waitForHeadToLoad: (t == null ? void 0 : t.waitForHeadToLoad) !== !1,
184
184
  cachePages: (t == null ? void 0 : t.cachePages) !== !1,
185
185
  trailingSlash: (t == null ? void 0 : t.trailingSlash) || !1,
186
186
  scrollSelector: (t == null ? void 0 : t.scrollSelector) || "body",
187
187
  morphInsideScrollContainer: (t == null ? void 0 : t.morphInsideScrollContainer) || !1
188
- }), a(this, W, d(this, l, ot).call(this, document.body));
188
+ }), o(this, B, d(this, l, ot).call(this, document.body));
189
189
  const s = this.normalizePath(
190
190
  location.pathname + location.hash
191
191
  );
192
- a(this, f, s.pathname), e(this, B).set(
192
+ o(this, f, s.pathname), e(this, U).set(
193
193
  e(this, f),
194
- new bt(this, e(this, f), document)
194
+ new kt(this, e(this, f), document)
195
195
  ), document.documentElement.setAttribute(
196
196
  "data-current-pathname",
197
197
  e(this, f)
198
198
  ), document.documentElement.setAttribute(
199
199
  "data-current-leaf",
200
200
  s.leaf
201
- ), this.findLinks(), addEventListener("popstate", e(this, st)), yt({
201
+ ), this.findLinks(), addEventListener("popstate", e(this, st)), bt({
202
202
  action: "replace",
203
203
  pathname: e(this, f),
204
204
  searchParameters: s.parameters || location.search,
205
205
  hash: s.hash
206
- }), a(this, I, new Pt()), d(this, l, ct).call(this, document);
206
+ }), o(this, I, new Ct()), d(this, l, ht).call(this, document);
207
207
  }
208
208
  }
209
209
  get currentPathname() {
210
210
  return e(this, f);
211
211
  }
212
212
  get previousPathname() {
213
- return e(this, J);
213
+ return e(this, G);
214
214
  }
215
215
  get links() {
216
216
  return e(this, m);
217
217
  }
218
218
  get scrollElement() {
219
- return e(this, w);
219
+ return e(this, y);
220
220
  }
221
221
  get isPopstateNavigation() {
222
222
  return e(this, A);
223
223
  }
224
224
  normalizePath(t) {
225
225
  return Ot(t, {
226
- base: e(this, k).base,
227
- trailingSlash: e(this, k).trailingSlash
226
+ base: e(this, P).base,
227
+ trailingSlash: e(this, P).trailingSlash
228
228
  });
229
229
  }
230
230
  prefetch(t, s) {
231
231
  return N(this, null, function* () {
232
232
  const i = this.normalizePath(t);
233
- d(this, l, tt).call(this, i.pathname, s);
233
+ d(this, l, tt).call(this, i.pathname, {
234
+ searchParameters: i.parameters,
235
+ revalidate: s
236
+ });
234
237
  });
235
238
  }
236
239
  navigate(M) {
@@ -238,107 +241,112 @@ const Y = class Y {
238
241
  historyAction: s = "push",
239
242
  centerScroll: i,
240
243
  offsetScroll: u,
241
- revalidate: p,
242
- keepSearchParameters: H
244
+ revalidate: E,
245
+ keepSearchParameters: S
243
246
  } = {}) {
244
- var ut;
247
+ var mt;
245
248
  if (e(this, z).length)
246
249
  return;
247
- const E = this.normalizePath(((ut = this.pathnameModifier) == null ? void 0 : ut.call(this, t)) || t);
248
- let { pathname: h, hash: X, parameters: Ht, leaf: Mt } = E;
249
- if (e(this, T) === h || e(this, f) === h) {
250
- e(this, A) || d(this, l, ht).call(this, X || 0, {
250
+ const p = this.normalizePath(((mt = this.pathnameModifier) == null ? void 0 : mt.call(this, t)) || t);
251
+ let { pathname: h, hash: Q, parameters: dt, leaf: Mt } = p;
252
+ if (e(this, H) === h || e(this, f) === h) {
253
+ e(this, A) || d(this, l, ut).call(this, Q || 0, {
251
254
  centerScroll: i,
252
255
  offsetScroll: u,
253
256
  behavior: "smooth"
254
257
  });
255
258
  return;
256
259
  }
257
- a(this, T, h), e(this, m).forEach((q) => {
260
+ o(this, H, h), e(this, m).forEach((q) => {
258
261
  q.checkCurrent(h);
259
262
  });
260
263
  try {
261
264
  let q = !0;
262
265
  if (this.preprocessor)
263
266
  try {
264
- yield new Promise((r, y) => {
265
- var v;
266
- (v = this.preprocessor) == null || v.call(this, {
267
+ yield new Promise((r, b) => {
268
+ var L;
269
+ (L = this.preprocessor) == null || L.call(this, {
267
270
  pathname: h,
268
271
  resolve: r,
269
- reject: y
272
+ reject: b
270
273
  });
271
274
  });
272
275
  } catch (r) {
273
276
  r ? console.error(r) : console.log("Route change canceled"), q = !1;
274
277
  }
275
- if (!q || e(this, T) !== h) {
278
+ if (!q || e(this, H) !== h) {
276
279
  e(this, m).forEach((r) => {
277
280
  r.checkCurrent(e(this, f));
278
281
  });
279
282
  return;
280
283
  }
281
- const dt = yield d(this, l, tt).call(this, e(this, f)), S = yield d(this, l, tt).call(this, h, p);
282
- if (e(this, T) !== h) {
284
+ const it = {
285
+ pathname: h
286
+ };
287
+ F(document, "morphNavigation", {
288
+ detail: it
289
+ });
290
+ const ft = yield d(this, l, tt).call(this, e(this, f)), w = yield d(this, l, tt).call(this, h, {
291
+ searchParameters: dt,
292
+ revalidate: E
293
+ });
294
+ if (e(this, H) !== h) {
283
295
  e(this, m).forEach((r) => {
284
296
  r.checkCurrent(e(this, f));
285
297
  });
286
298
  return;
287
299
  }
288
- dt.saveScrollState(), dt.saveDocumentState(), e(this, A) || (S.clearScrollState(), S.clearDocumentState()), S.cloneDocument(), e(this, I).textContent = S.title, document.body.appendChild(e(this, I));
289
- const mt = {
290
- pathname: h
291
- };
292
- K(document, "morphStart", {
293
- detail: mt
300
+ ft.saveScrollState(), ft.saveDocumentState(), e(this, A) || (w.clearScrollState(), w.clearDocumentState()), w.cloneDocument(), e(this, I).textContent = w.title, document.body.appendChild(e(this, I)), F(document, "morphStart", {
301
+ detail: it
294
302
  });
295
- const ft = Array.from(document.head.children), pt = Array.from(S.document.head.children), Et = d(this, l, Tt).call(this, ft, pt), Nt = d(this, l, at).call(this, ft, Et), Z = d(this, l, at).call(this, pt, Et);
296
- Z.forEach((r, y) => {
303
+ const pt = Array.from(document.head.children), Et = Array.from(w.document.head.children), gt = d(this, l, Ht).call(this, pt, Et), Nt = d(this, l, lt).call(this, pt, gt), X = d(this, l, lt).call(this, Et, gt);
304
+ X.forEach((r, b) => {
297
305
  if (r.tagName === "SCRIPT" && r.getAttribute("src")) {
298
- const v = document.createElement("script");
299
- v.type = "module", v.src = r.getAttribute("src"), Z[y] = v;
306
+ const L = document.createElement("script");
307
+ L.type = "module", L.src = r.getAttribute("src"), X[b] = L;
300
308
  }
301
- }), Z.forEach((r) => {
309
+ }), X.forEach((r) => {
302
310
  document.head.appendChild(r);
303
311
  });
304
- const it = Z.filter((r) => {
312
+ const rt = X.filter((r) => {
305
313
  if (r.hasAttribute("data-no-waiting"))
306
314
  return !1;
307
- if (d(this, l, lt).call(this, r))
315
+ if (d(this, l, ct).call(this, r))
308
316
  return !0;
309
317
  });
310
- e(this, k).waitForHeadToLoad && it.length && (yield new Promise((r) => N(this, null, function* () {
311
- let y = 0;
318
+ e(this, P).waitForHeadToLoad && rt.length && (yield new Promise((r) => N(this, null, function* () {
319
+ let b = 0;
312
320
  try {
313
- for (var v = wt(it), O, j, Lt; O = !(j = yield v.next()).done; O = !1) {
314
- const $ = j.value;
315
- $.onload = () => {
316
- y++, y === it.length && r();
321
+ for (var L = yt(rt), O, j, Lt; O = !(j = yield L.next()).done; O = !1) {
322
+ const Z = j.value;
323
+ Z.onload = () => {
324
+ b++, b === rt.length && r();
317
325
  };
318
326
  }
319
327
  } catch (j) {
320
328
  Lt = [j];
321
329
  } finally {
322
330
  try {
323
- O && (j = v.return) && (yield j.call(v));
331
+ O && (j = L.return) && (yield j.call(L));
324
332
  } finally {
325
333
  if (Lt)
326
334
  throw Lt[0];
327
335
  }
328
336
  }
329
337
  }))), yield zt(10);
330
- const gt = [];
338
+ const vt = [];
331
339
  Nt.forEach((r) => {
332
- r.hasAttribute("data-permanent") || (d(this, l, lt).call(this, r) ? gt.push(r) : r.remove());
340
+ r.hasAttribute("data-permanent") || (d(this, l, ct).call(this, r) ? vt.push(r) : r.remove());
333
341
  });
334
- const xt = d(this, l, ot).call(this, S.document.body);
335
- e(this, k).morphInsideScrollContainer || d(this, l, ct).call(this, S.document), document.documentElement.setAttribute("data-current-pathname", h), document.documentElement.setAttribute("data-current-leaf", Mt), yt({
342
+ const xt = d(this, l, ot).call(this, w.document.body);
343
+ e(this, P).morphInsideScrollContainer || d(this, l, ht).call(this, w.document), document.documentElement.setAttribute("data-current-pathname", h), document.documentElement.setAttribute("data-current-leaf", Mt), bt({
336
344
  action: s,
337
345
  pathname: h,
338
- searchParameters: Ht || (H ? location.search : ""),
339
- hash: X
340
- }), e(this, I).remove(), a(this, J, e(this, f)), a(this, f, h), e(this, W).forEach((r, y) => {
341
- const v = xt[y], O = getComputedStyle(r).getPropertyValue("--morph-duration"), j = [...v.childNodes];
346
+ searchParameters: dt || (S ? location.search : ""),
347
+ hash: Q
348
+ }), e(this, I).remove(), o(this, G, e(this, f)), o(this, f, h), e(this, B).forEach((r, b) => {
349
+ const L = xt[b], O = getComputedStyle(r).getPropertyValue("--morph-duration"), j = [...L.childNodes];
342
350
  if (O) {
343
351
  const Lt = [...r.childNodes];
344
352
  Lt.forEach((g) => {
@@ -350,41 +358,41 @@ const Y = class Y {
350
358
  g instanceof HTMLElement && g.classList.add("in");
351
359
  });
352
360
  });
353
- const $ = {
361
+ const Z = {
354
362
  morphElement: r,
355
363
  pathname: h
356
364
  };
357
- K(document, "morphNewChildrenAdded", {
358
- detail: $
365
+ F(document, "morphNewChildrenAdded", {
366
+ detail: Z
359
367
  });
360
368
  const Dt = new Promise((g) => {
361
369
  setTimeout(() => {
362
370
  Lt.forEach((_) => _.remove()), j.forEach((_) => {
363
371
  _ instanceof HTMLElement && _.classList.remove("in", "new");
364
- }), K(document, "morphOldChildrenRemoved", {
365
- detail: $
372
+ }), F(document, "morphOldChildrenRemoved", {
373
+ detail: Z
366
374
  }), g();
367
375
  }, (parseFloat(O) || 0) * 1e3 + 10);
368
376
  });
369
377
  e(this, z).push(Dt);
370
378
  } else
371
379
  this.destroyOldLinks(r), r.innerHTML = "", r.append(...j), this.findNewLinks(r);
372
- }), X ? (S.clearScrollState(), d(this, l, ht).call(this, X, { centerScroll: i, offsetScroll: u })) : e(this, A) ? S.restoreScrollPosition() : S.renewScrollPosition(), yield Promise.all(e(this, z)), gt.forEach((r) => r.remove()), a(this, z, []), e(this, W).forEach((r) => {
373
- r.querySelectorAll("script").forEach((v) => {
380
+ }), Q ? (w.clearScrollState(), d(this, l, ut).call(this, Q, { centerScroll: i, offsetScroll: u })) : e(this, A) ? w.restoreScrollPosition() : w.renewScrollPosition(), yield Promise.all(e(this, z)), vt.forEach((r) => r.remove()), o(this, z, []), e(this, B).forEach((r) => {
381
+ r.querySelectorAll("script").forEach((L) => {
374
382
  const O = document.createElement("script");
375
- O.type = "module", O.src = v.getAttribute("src"), v.replaceWith(O);
383
+ O.type = "module", O.src = L.getAttribute("src"), L.replaceWith(O);
376
384
  });
377
- }), K(document, "morphComplete", {
378
- detail: mt
385
+ }), F(document, "morphComplete", {
386
+ detail: it
379
387
  }), window.dispatchEvent(new Event("resize"));
380
388
  } catch (q) {
381
389
  console.error(q);
382
390
  }
383
- a(this, T, void 0);
391
+ o(this, H, void 0);
384
392
  });
385
393
  }
386
394
  addLink(t) {
387
- e(this, m).push(new nt(t, this));
395
+ e(this, m).push(new at(t, this));
388
396
  }
389
397
  addLinks(t) {
390
398
  t.forEach((s) => {
@@ -392,69 +400,71 @@ const Y = class Y {
392
400
  });
393
401
  }
394
402
  removeLink(t) {
395
- a(this, m, e(this, m).filter((s) => s.element === t ? (s.destroy(), !1) : !0));
403
+ o(this, m, e(this, m).filter((s) => s.element === t ? (s.destroy(), !1) : !0));
396
404
  }
397
405
  destroyOldLinks(t) {
398
- a(this, m, e(this, m).filter((s) => t.contains(s.element) ? (s.destroy(), !1) : !0));
406
+ o(this, m, e(this, m).filter((s) => t.contains(s.element) ? (s.destroy(), !1) : !0));
399
407
  }
400
408
  findNewLinks(t) {
401
409
  const s = [...t.querySelectorAll("a")].filter(
402
- e(this, Q)
410
+ e(this, J)
403
411
  );
404
412
  e(this, m).push(
405
- ...s.map((i) => new nt(i, this))
413
+ ...s.map((i) => new at(i, this))
406
414
  );
407
415
  }
408
416
  findLinks() {
409
417
  const t = [
410
418
  ...document.documentElement.querySelectorAll("a")
411
- ].filter(e(this, Q));
412
- e(this, m).forEach((s) => s.destroy()), a(this, m, t.map((s) => new nt(s, this)));
419
+ ].filter(e(this, J));
420
+ e(this, m).forEach((s) => s.destroy()), o(this, m, t.map((s) => new at(s, this)));
413
421
  }
414
422
  };
415
- k = new WeakMap(), W = new WeakMap(), m = new WeakMap(), et = new WeakMap(), T = new WeakMap(), f = new WeakMap(), J = new WeakMap(), z = new WeakMap(), A = new WeakMap(), w = new WeakMap(), B = new WeakMap(), I = new WeakMap(), Q = new WeakMap(), l = new WeakSet(), tt = function(t, s = !1) {
423
+ P = new WeakMap(), B = new WeakMap(), m = new WeakMap(), et = new WeakMap(), H = new WeakMap(), f = new WeakMap(), G = new WeakMap(), z = new WeakMap(), A = new WeakMap(), y = new WeakMap(), U = new WeakMap(), I = new WeakMap(), J = new WeakMap(), l = new WeakSet(), tt = function(t, s) {
416
424
  return N(this, null, function* () {
417
- let i = e(this, B).get(t);
418
- return (!i || s) && (i = yield d(this, l, Ct).call(this, t)), i;
425
+ let i = e(this, U).get(t);
426
+ return (!i || s != null && s.revalidate) && (i = yield d(this, l, Tt).call(this, t, s == null ? void 0 : s.searchParameters)), i;
419
427
  });
420
- }, Ct = function(t) {
428
+ }, Tt = function(t, s) {
421
429
  return N(this, null, function* () {
422
- const i = yield (yield fetch(t)).text(), u = e(this, et).parseFromString(i, "text/html"), p = new bt(this, t, u);
423
- return e(this, B).set(t, p), p;
430
+ const u = yield (yield fetch(
431
+ `${t}${s ? "?" + s : ""}`
432
+ )).text(), E = e(this, et).parseFromString(u, "text/html"), S = new kt(this, t, E);
433
+ return e(this, U).set(t, S), S;
424
434
  });
425
435
  }, ot = function(t) {
426
436
  const s = [...t.querySelectorAll("[data-morph]")];
427
437
  return s.length ? s : [t];
428
- }, Tt = function(t, s) {
438
+ }, Ht = function(t, s) {
429
439
  return t.filter(
430
440
  (i) => s.find(
431
441
  (u) => u.outerHTML === i.outerHTML
432
442
  )
433
443
  );
434
- }, at = function(t, s) {
444
+ }, lt = function(t, s) {
435
445
  return t.filter(
436
446
  (i) => !s.find(
437
447
  (u) => u.outerHTML === i.outerHTML
438
448
  )
439
449
  );
440
- }, lt = function(t) {
441
- return t.tagName === "SCRIPT" || t.tagName === "STYLE" || t.tagName === "LINK" && t.getAttribute("rel") === "stylesheet";
442
450
  }, ct = function(t) {
451
+ return t.tagName === "SCRIPT" || t.tagName === "STYLE" || t.tagName === "LINK" && t.getAttribute("rel") === "stylesheet";
452
+ }, ht = function(t) {
443
453
  var s, i;
444
- (s = e(this, w)) == null || s.removeEventListener(
454
+ (s = e(this, y)) == null || s.removeEventListener(
445
455
  "scroll",
446
- e(this, U)
447
- ), a(this, w, t.querySelector(e(this, k).scrollSelector) || t.documentElement), (i = e(this, w)) == null || i.addEventListener("scroll", e(this, U)), e(this, U).call(this);
448
- }, ht = function(t, s) {
456
+ e(this, $)
457
+ ), o(this, y, t.querySelector(e(this, P).scrollSelector) || t.documentElement), (i = e(this, y)) == null || i.addEventListener("scroll", e(this, $)), e(this, $).call(this);
458
+ }, ut = function(t, s) {
449
459
  const i = typeof t == "string" ? document.getElementById(t) : t;
450
460
  (typeof i == "number" || i) && It(i, {
451
- scrollElement: e(this, w),
461
+ scrollElement: e(this, y),
452
462
  behavior: (s == null ? void 0 : s.behavior) || "instant",
453
463
  center: s == null ? void 0 : s.centerScroll,
454
464
  offset: s == null ? void 0 : s.offsetScroll
455
465
  });
456
- }, st = new WeakMap(), U = new WeakMap(), Y.instance = null;
457
- let kt = Y;
466
+ }, st = new WeakMap(), $ = new WeakMap(), K.instance = null;
467
+ let Pt = K;
458
468
  export {
459
- kt as Morph
469
+ Pt as Morph
460
470
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aptechka",
3
- "version": "0.59.2",
3
+ "version": "0.60.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/denisavitski/aptechka.git"