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