aptechka 0.72.1 → 0.72.2
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.
- package/lib/morph/Morph.d.ts +2 -1
- package/lib/morph/index.cjs +1 -1
- package/lib/morph/index.js +117 -113
- package/package.json +1 -1
package/lib/morph/Morph.d.ts
CHANGED
|
@@ -36,6 +36,7 @@ export interface MorphNavigateOptions {
|
|
|
36
36
|
keepSearchParameters?: boolean;
|
|
37
37
|
submorph?: Array<string>;
|
|
38
38
|
clearState?: boolean;
|
|
39
|
+
keepScrollPosition?: boolean;
|
|
39
40
|
}
|
|
40
41
|
export interface MorphScrollDetail {
|
|
41
42
|
left: number;
|
|
@@ -95,7 +96,7 @@ export declare class Morph {
|
|
|
95
96
|
prefetch(path: string, revalidate?: boolean): Promise<void>;
|
|
96
97
|
excludeHeadChild(child: Node): boolean;
|
|
97
98
|
setHeaders(path: string): void;
|
|
98
|
-
navigate(path: string, { historyAction, centerScroll, offsetScroll, revalidate, keepSearchParameters, submorph, clearState, }?: MorphNavigateOptions): Promise<void>;
|
|
99
|
+
navigate(path: string, { historyAction, centerScroll, offsetScroll, revalidate, keepSearchParameters, submorph, clearState, keepScrollPosition, }?: MorphNavigateOptions): Promise<void>;
|
|
99
100
|
addLink(element: HTMLAnchorElement): void;
|
|
100
101
|
addLinks(elements: Array<HTMLAnchorElement>): void;
|
|
101
102
|
removeLink(element: HTMLAnchorElement): void;
|
package/lib/morph/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var Zt=Object.defineProperty,_t=Object.defineProperties;var te=Object.getOwnPropertyDescriptors;var It=Object.getOwnPropertySymbols;var ee=Object.prototype.hasOwnProperty,se=Object.prototype.propertyIsEnumerable;var Vt=(a,t)=>(t=Symbol[a])?t:Symbol.for("Symbol."+a),Ft=a=>{throw TypeError(a)};var Ot=(a,t,s)=>t in a?Zt(a,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):a[t]=s,ft=(a,t)=>{for(var s in t||(t={}))ee.call(t,s)&&Ot(a,s,t[s]);if(It)for(var s of It(t))se.call(t,s)&&Ot(a,s,t[s]);return a},Lt=(a,t)=>_t(a,te(t));var wt=(a,t,s)=>t.has(a)||Ft("Cannot "+s);var e=(a,t,s)=>(wt(a,t,"read from private field"),s?s.call(a):t.get(a)),o=(a,t,s)=>t.has(a)?Ft("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(a):t.set(a,s),n=(a,t,s,i)=>(wt(a,t,"write to private field"),i?i.call(a,s):t.set(a,s),s),E=(a,t,s)=>(wt(a,t,"access private method"),s);var B=(a,t,s)=>new Promise((i,h)=>{var v=L=>{try{f(s.next(L))}catch(O){h(O)}},A=L=>{try{f(s.throw(L))}catch(O){h(O)}},f=L=>L.done?i(L.value):Promise.resolve(L.value).then(v,A);f((s=s.apply(a,t)).next())});var Bt=(a,t,s)=>(t=a[Vt("asyncIterator")])?t.call(a):(a=a[Vt("iterator")](),t={},s=(i,h)=>(h=a[i])&&(t[i]=v=>new Promise((A,f,L)=>(v=h.call(a,v),L=v.done,Promise.resolve(v.value).then(O=>A({value:O,done:L}),f)))),s("next"),s("return"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Yt=require("../index-DekP7OZe.cjs"),H=require("../events-KVanG9sR.cjs"),ie=require("../polyfills-Df4r-ETT.cjs"),Wt=require("../scroll-CIdNtj3G.cjs");require("construct-style-sheets-polyfill");const st=require("../url-YEESIcRn.cjs"),re=require("../css-value-parser/index.cjs");class jt 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)}}Yt.isBrowser&&!customElements.get("morph-announcer")&&customElements.define("morph-announcer",jt);var M,l,q,rt,G;class yt{constructor(t,s){o(this,M);o(this,l);o(this,q);o(this,rt,t=>{var i;if(t.preventDefault(),document.documentElement.classList.contains("click-disabled"))return;if(e(this,l).hasAttribute("data-back")&&e(this,M).previousURL)history.back();else{n(this,q,e(this,l).getAttribute("href")||"/");const h=e(this,l).getAttribute("data-history-action")||"push",v=e(this,l).hasAttribute("data-center-scroll"),A=getComputedStyle(e(this,l)).getPropertyValue("--offset-scroll").trim(),f=A?re.cssValueParser.parse(A):void 0,L=e(this,l).hasAttribute("data-revalidate"),O=e(this,l).hasAttribute("data-keep-search-parameters"),ht=(i=e(this,l).getAttribute("data-submorph"))==null?void 0:i.split(",").map(ct=>ct.trim()),c=e(this,l).hasAttribute("data-clear-state");e(this,M).navigate(e(this,q),{historyAction:h,centerScroll:v,offsetScroll:f,revalidate:L,keepSearchParameters:O,submorph:ht,clearState:c})}});o(this,G,()=>{const t=e(this,l).hasAttribute("data-revalidate");e(this,M).prefetch(e(this,q),t),e(this,l).removeEventListener("pointerenter",e(this,G))});n(this,M,s),n(this,l,t),n(this,q,e(this,l).getAttribute("href")||"/"),e(this,l).addEventListener("click",e(this,rt)),this.checkCurrent(location.pathname),e(this,l).hasAttribute("data-prefetch")&&e(this,l).addEventListener("pointerenter",e(this,G))}get element(){return e(this,l)}checkCurrent(t){var h;const s=e(this,M).normalizePath(t),i=e(this,M).normalizePath(e(this,q));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"):(h=e(this,l).getAttribute("data-associated-paths"))!=null&&h.split(",").find(v=>s.pathname.includes(v))?e(this,l).classList.add("current"):e(this,l).classList.remove("current")}destroy(){e(this,l).removeEventListener("click",e(this,rt)),e(this,l).removeEventListener("pointerenter",e(this,G)),e(this,l).classList.remove("current")}}M=new WeakMap,l=new WeakMap,q=new WeakMap,rt=new WeakMap,G=new WeakMap;const ne=new DOMParser;var R,W,y,k,X,D,J,Y,U,Q,nt;class Xt{constructor(t,s){o(this,R);o(this,W);o(this,y,{x:0,y:0});o(this,k,null);o(this,X,null);o(this,D,null);o(this,J,null);o(this,Y,null);o(this,U,null);o(this,Q);o(this,nt);n(this,R,t),n(this,W,s),n(this,Q,s)}get pathname(){return e(this,W)}get scrollState(){return e(this,y)}get document(){return e(this,D)}setHeaders(t){n(this,nt,t)}setInitialDocument(t){n(this,k,t.cloneNode(!0))}abort(){var t;return(t=e(this,Y))==null?void 0:t.abort(`[${e(this,W)}] page loading cancelled`)}fetch(t,s,i){return B(this,null,function*(){return e(this,U)||e(this,k)&&e(this,k).documentElement.hasAttribute("data-cache")&&(!i||e(this,Q)!==t)||e(this,k)&&e(this,R).isPopstateNavigation?e(this,U):(n(this,Q,t),n(this,U,new Promise(h=>B(this,null,function*(){try{n(this,Y,new AbortController);const A=yield(yield fetch(t,{signal:e(this,Y).signal,headers:ft({"X-MORPH":"true","X-MORPH-CURRENT-PATH":s,"X-MORPH-NEW-PATH":t},e(this,nt))})).text(),f=ne.parseFromString(A,"text/html");this.setInitialDocument(f)}catch(v){console.warn(v)}finally{n(this,Y,null),n(this,U,null),h()}}))),e(this,U))})}cloneDocument(){n(this,D,(e(this,X)||e(this,k)).cloneNode(!0))}get title(){let t="";if(e(this,D).title)t=e(this,D).title;else{const s=e(this,D).querySelector("h1");t=(s==null?void 0:s.innerText)||(s==null?void 0:s.textContent)||e(this,W)}return t}clearScrollState(){e(this,y).x=0,e(this,y).y=0}clearDocumentState(){n(this,X,null)}saveScrollState(){e(this,k).documentElement.hasAttribute("data-no-scroll-restoration")?(e(this,y).x=0,e(this,y).y=0):(e(this,y).x=e(this,R).scrollValue.left,e(this,y).y=e(this,R).scrollValue.top)}restoreScrollPosition(){e(this,R).scrollElement.scroll({top:e(this,y).y,left:e(this,y).x,behavior:"instant"})}saveDocumentState(){e(this,k).documentElement.hasAttribute("data-no-page-restoration")?n(this,X,null):n(this,X,document.cloneNode(!0))}renewScrollPosition(){e(this,R).scrollElement.scroll({top:0,left:0,behavior:"instant"})}saveState(t){n(this,J,t)}clearState(){const t=e(this,J);return n(this,J,null),t}}R=new WeakMap,W=new WeakMap,y=new WeakMap,k=new WeakMap,X=new WeakMap,D=new WeakMap,J=new WeakMap,Y=new WeakMap,U=new WeakMap,Q=new WeakMap,nt=new WeakMap;var C,Z,g,z,m,j,I,V,P,at,T,K,_,tt,ot,u,Pt,lt,pt,At,Kt,kt,Ct,Ht,Mt,Et,et;const it=class it{constructor(t){o(this,u);o(this,C,null);o(this,Z,null);o(this,g,[]);o(this,z);o(this,m,null);o(this,j);o(this,I,[]);o(this,V,!1);o(this,P,null);o(this,at,!1);o(this,T,new Map);o(this,K,null);o(this,_,0);o(this,tt,0);o(this,ot,null);o(this,lt,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,Et,t=>B(this,null,function*(){t.preventDefault(),n(this,V,!0),yield this.navigate(location.href.replace(location.origin,""),{historyAction:"none",submorph:e(this,ot)||void 0}),n(this,V,!1)}));o(this,et,()=>{const{left:t,top:s}=this.scrollValue,i=s-e(this,tt),h=t-e(this,_);n(this,tt,s),n(this,_,t),document.documentElement.classList.toggle("scroll-y",s>0),document.documentElement.classList.toggle("scroll-x",t>0),document.documentElement.classList.toggle("scroll-y-forward",i>0),document.documentElement.classList.toggle("scroll-y-backward",i<0),document.documentElement.classList.toggle("scroll-x-forward",h>0),document.documentElement.classList.toggle("scroll-x-backward",h<0),H.dispatchEvent(document,"morphScroll",{detail:{left:t,top:s}})});if(Yt.isBrowser&&!it.instance){it.instance=this,n(this,C,{base:st.normalizeBase(t==null?void 0:t.base),waitForHeadToLoad:(t==null?void 0:t.waitForHeadToLoad)!==!1,trailingSlash:(t==null?void 0:t.trailingSlash)||!1,scrollSelector:t==null?void 0:t.scrollSelector,morphInsideScrollContainer:(t==null?void 0:t.morphInsideScrollContainer)||!1}),n(this,Z,E(this,u,At).call(this,document.body));const s=this.normalizePath(location.pathname+location.hash+location.search);n(this,m,s);const i=new Xt(this,e(this,m).pathname);i.setInitialDocument(document),e(this,T).set(e(this,m).pathname,i),document.documentElement.setAttribute("data-current-pathname",e(this,m).pathname),document.documentElement.setAttribute("data-current-leaf",s.leaf),this.findLinks(),history.scrollRestoration="manual",addEventListener("popstate",e(this,Et)),st.changeHistory({action:"replace",pathname:s.pathname,searchParameters:s.parameters,hash:s.hash}),n(this,K,new jt),E(this,u,Ht).call(this,document)}}get currentURL(){return e(this,m)}get previousURL(){return e(this,j)}get links(){return e(this,g)}get scrollElement(){return e(this,P)}get isPopstateNavigation(){return e(this,V)}get scrollValue(){let t=0,s=0;return e(this,at)?(t=window.scrollY,s=window.scrollX):(t=e(this,P).scrollTop,s=e(this,P).scrollLeft),{top:t,left:s}}saveState(t){const s=e(this,T).get(e(this,m).path);s&&s.saveState(t)}getState(){const t=e(this,T).get(e(this,m).path);return t==null?void 0:t.clearState()}normalizePath(t){return st.splitPath(t,{base:e(this,C).base,trailingSlash:e(this,C).trailingSlash})}prefetch(t,s){return B(this,null,function*(){var h;if(e(this,I).length)return;t=((h=this.pathnameModifier)==null?void 0:h.call(this,t))||t;const i=E(this,u,pt).call(this,t);i==null||i.fetch(t,e(this,m).path,s)})}excludeHeadChild(t){return!1}setHeaders(t){}navigate(O){return B(this,arguments,function*(t,{historyAction:s="push",centerScroll:i,offsetScroll:h,revalidate:v,keepSearchParameters:A,submorph:f,clearState:L}={}){var ct,Rt,Tt,xt;if(e(this,I).length)return;n(this,ot,f||null);const ht=((ct=this.pathnameModifier)==null?void 0:ct.call(this,t))||t,c=this.normalizePath(ht);if(((Rt=e(this,z))==null?void 0:Rt.pathname)===c.pathname||e(this,m).pathname===c.pathname){E(this,u,Mt).call(this,c.hash||0,{centerScroll:i,offsetScroll:h,behavior:"smooth"}),H.dispatchEvent(document,"morphSamePath",{custom:!0}),((Tt=e(this,m))==null?void 0:Tt.parameters)!==c.parameters&&(n(this,j,e(this,m)),n(this,m,c),st.changeHistory({action:((xt=e(this,m))==null?void 0:xt.hash)!==c.hash?"replace":s,pathname:c.pathname,searchParameters:c.parameters,hash:c.hash}),H.dispatchEvent(document,"morphURLParametersChange",{detail:{newURL:e(this,m),previousURL:e(this,j)}}));return}n(this,z,c),e(this,g).forEach($=>{$.checkCurrent(c.pathname)});try{let $=!0;if(this.preprocessor)try{yield new Promise((r,S)=>{var b;(b=this.preprocessor)==null||b.call(this,{url:c,resolve:r,reject:S,submorph:f})})}catch(r){r?console.error(r):console.log("Route change canceled"),$=!1}if(!$||e(this,z).pathname!==c.pathname){e(this,g).forEach(r=>{r.checkCurrent(e(this,m).pathname)});return}const Nt={url:c,submorph:f};f?f.forEach(r=>{document.querySelectorAll(r).forEach(S=>{S.classList.add("out"),S.setAttribute("data-morph-out","")})}):e(this,Z).forEach(r=>{var S,b;(S=r.firstElementChild)==null||S.classList.add("out"),(b=r.firstElementChild)==null||b.setAttribute("data-morph-out","")}),H.dispatchEvent(document,"morphNavigation",{detail:Nt});const gt=E(this,u,pt).call(this,e(this,m).pathname),p=E(this,u,pt).call(this,c.pathname);if(e(this,T).forEach(r=>{r.pathname!==c.pathname&&r.abort()}),yield p==null?void 0:p.fetch(ht,e(this,m).path,v),e(this,z).pathname!==c.pathname){e(this,g).forEach(r=>{r.checkCurrent(e(this,m).path)});return}gt.clearState(),gt.saveScrollState(),gt.saveDocumentState(),e(this,V)||(p.clearScrollState(),p.clearDocumentState()),L&&p.clearState(),p.cloneDocument(),e(this,K).textContent=p.title,document.body.appendChild(e(this,K));const ut=Lt(ft({},Nt),{document:p.document});ut.document.querySelectorAll("[data-morph-out]").forEach(r=>{r.classList.remove("out")}),H.dispatchEvent(document,"morphStart",{detail:ut});const qt=Array.from(document.head.children),Dt=Array.from(p.document.head.children),Ut=E(this,u,Kt).call(this,qt,Dt),$t=E(this,u,kt).call(this,qt,Ut),dt=E(this,u,kt).call(this,Dt,Ut).filter(r=>!this.excludeHeadChild(r));dt.forEach((r,S)=>{r.tagName==="SCRIPT"&&(dt[S]=E(this,u,Pt).call(this,r))}),dt.forEach(r=>{document.head.appendChild(r)});const vt=dt.filter(r=>{if(r.hasAttribute("data-no-waiting"))return!1;if(E(this,u,Ct).call(this,r))return!0});e(this,C).waitForHeadToLoad&&vt.length&&(yield new Promise(r=>B(this,null,function*(){let S=0;try{for(var b=Bt(vt),Jt,F,x;Jt=!(F=yield b.next()).done;Jt=!1){const mt=F.value;mt.onload=()=>{S++,S===vt.length&&r()}}}catch(F){x=[F]}finally{try{Jt&&(F=b.return)&&(yield F.call(b))}finally{if(x)throw x[0]}}}))),yield Wt.wait(10);const zt=[];$t.forEach(r=>{r.hasAttribute("data-permanent")||(E(this,u,Ct).call(this,r)?zt.push(r):r.remove())});const Gt=E(this,u,At).call(this,p.document.body);!e(this,C).morphInsideScrollContainer&&!f&&E(this,u,Ht).call(this,p.document),document.documentElement.setAttribute("data-current-pathname",c.pathname),document.documentElement.setAttribute("data-current-leaf",c.leaf),st.changeHistory({action:s,pathname:c.pathname,searchParameters:c.parameters||(A?location.search:""),hash:c.hash}),e(this,K).remove(),n(this,j,e(this,m)),n(this,m,c);const St=[];e(this,Z).forEach((r,S)=>{const b=Gt[S],Jt=getComputedStyle(r).getPropertyValue("--morph-duration");let F=[],x=[];f?(f.forEach(d=>{const w=r.querySelector(d),N=b.querySelector(d);w&&N&&(x.push(w),F.push(N))}),x.forEach(d=>{d.parentElement&&St.push(d.parentElement)})):(F.push(...b.childNodes),x.push(...r.childNodes),St.push(r)),x.forEach(d=>{d instanceof HTMLElement&&(this.destroyOldLinks(d),d.classList.add("old"))}),F.forEach(d=>{d instanceof HTMLElement&&(this.findNewLinks(d),d.classList.add("new"))}),f?F.forEach((d,w)=>{var N;(N=x[w].parentElement)==null||N.insertBefore(d,x[w])}):r.prepend(...F),ie.requestIdleCallback(()=>{x.forEach(d=>{d instanceof HTMLElement&&d.classList.add("old-idle")}),F.forEach(d=>{var w;d instanceof HTMLElement&&((w=d.parentElement)==null||w.style.setProperty("--new-content-height",d.offsetHeight+"px"),d.classList.add("new-idle"))})});const mt=Lt(ft({},ut),{morphElement:r});H.dispatchEvent(document,"morphNewChildrenAdded",{detail:mt});const Qt=new Promise(d=>{setTimeout(()=>{x.forEach(w=>w.remove()),F.forEach(w=>{var N;w instanceof HTMLElement&&((N=w.parentElement)==null||N.style.removeProperty("--new-content-height"),w.classList.remove("new-idle","new"))}),H.dispatchEvent(document,"morphOldChildrenRemoved",{detail:mt}),d()},(parseFloat(Jt)||0)*1e3+10)});e(this,I).push(Qt)}),this.isPopstateNavigation?document.documentElement.style.setProperty("--new-document-scroll-position",(this.scrollValue.top-p.scrollState.y)*1+"px"):document.documentElement.style.setProperty("--new-document-scroll-position",this.scrollValue.top+"px"),H.dispatchEvent(document,"morphBeforeNavigationScroll",{detail:p.scrollState}),c.hash?(p.clearScrollState(),E(this,u,Mt).call(this,c.hash,{centerScroll:i,offsetScroll:h})):e(this,V)?p.restoreScrollPosition():p.renewScrollPosition(),yield Promise.all(e(this,I)),zt.forEach(r=>r.remove()),n(this,I,[]),St.forEach(r=>{r.querySelectorAll("script").forEach(b=>{b.replaceWith(E(this,u,Pt).call(this,b))})}),e(this,g).forEach(r=>{r.checkCurrent(e(this,m).path)}),H.dispatchEvent(document,"morphComplete",{detail:ut}),document.documentElement.style.removeProperty("--new-document-scroll-position"),window.dispatchEvent(new Event("resize"))}catch($){console.error($)}n(this,z,void 0)})}addLink(t){e(this,g).push(new yt(t,this))}addLinks(t){t.forEach(s=>{this.addLink(s)})}removeLink(t){n(this,g,e(this,g).filter(s=>s.element===t?(s.destroy(),!1):!0))}destroyOldLinks(t){n(this,g,e(this,g).filter(s=>t.contains(s.element)?(s.destroy(),!1):!0))}findNewLinks(t){const s=[...t.querySelectorAll("a")].filter(e(this,lt));e(this,g).push(...s.map(i=>new yt(i,this)))}findLinks(){const t=[...document.documentElement.querySelectorAll("a")].filter(e(this,lt));e(this,g).forEach(s=>s.destroy()),n(this,g,t.map(s=>new yt(s,this)))}};C=new WeakMap,Z=new WeakMap,g=new WeakMap,z=new WeakMap,m=new WeakMap,j=new WeakMap,I=new WeakMap,V=new WeakMap,P=new WeakMap,at=new WeakMap,T=new WeakMap,K=new WeakMap,_=new WeakMap,tt=new WeakMap,ot=new WeakMap,u=new WeakSet,Pt=function(t){const s=document.createElement("script");for(let i=0;i<t.attributes.length;i++){const h=t.attributes[i];s.setAttribute(h.name,h.value)}return t.hasAttribute("src")||(s.innerHTML=t.innerHTML),s},lt=new WeakMap,pt=function(t){const s=this.normalizePath(t);let i=e(this,T).get(s.pathname);return i||(i=new Xt(this,s.pathname),e(this,T).set(s.pathname,i)),i},At=function(t){const s=[...t.querySelectorAll("[data-morph]")];return s.length?s:[t]},Kt=function(t,s){return t.filter(i=>s.find(h=>h.outerHTML===i.outerHTML))},kt=function(t,s){return t.filter(i=>!s.find(h=>h.outerHTML===i.outerHTML))},Ct=function(t){return t.tagName==="SCRIPT"||t.tagName==="STYLE"||t.tagName==="LINK"&&t.getAttribute("rel")==="stylesheet"},Ht=function(t){var s,i;(s=e(this,P))==null||s.removeEventListener("scroll",e(this,et)),n(this,tt,0),n(this,_,0),n(this,P,e(this,C).scrollSelector&&t.querySelector(e(this,C).scrollSelector)||window),n(this,at,e(this,P)===window),(i=e(this,P))==null||i.addEventListener("scroll",e(this,et)),e(this,et).call(this)},Mt=function(t,s){const i=typeof t=="string"?document.getElementById(t):t;(typeof i=="number"||i)&&Wt.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})},Et=new WeakMap,et=new WeakMap,it.instance=null;let bt=it;exports.Morph=bt;
|
|
1
|
+
"use strict";var _t=Object.defineProperty,te=Object.defineProperties;var ee=Object.getOwnPropertyDescriptors;var It=Object.getOwnPropertySymbols;var se=Object.prototype.hasOwnProperty,ie=Object.prototype.propertyIsEnumerable;var Vt=(a,t)=>(t=Symbol[a])?t:Symbol.for("Symbol."+a),Ft=a=>{throw TypeError(a)};var Ot=(a,t,s)=>t in a?_t(a,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):a[t]=s,ft=(a,t)=>{for(var s in t||(t={}))se.call(t,s)&&Ot(a,s,t[s]);if(It)for(var s of It(t))ie.call(t,s)&&Ot(a,s,t[s]);return a},Lt=(a,t)=>te(a,ee(t));var wt=(a,t,s)=>t.has(a)||Ft("Cannot "+s);var e=(a,t,s)=>(wt(a,t,"read from private field"),s?s.call(a):t.get(a)),o=(a,t,s)=>t.has(a)?Ft("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(a):t.set(a,s),n=(a,t,s,i)=>(wt(a,t,"write to private field"),i?i.call(a,s):t.set(a,s),s),E=(a,t,s)=>(wt(a,t,"access private method"),s);var B=(a,t,s)=>new Promise((i,h)=>{var v=L=>{try{f(s.next(L))}catch(H){h(H)}},A=L=>{try{f(s.throw(L))}catch(H){h(H)}},f=L=>L.done?i(L.value):Promise.resolve(L.value).then(v,A);f((s=s.apply(a,t)).next())});var Bt=(a,t,s)=>(t=a[Vt("asyncIterator")])?t.call(a):(a=a[Vt("iterator")](),t={},s=(i,h)=>(h=a[i])&&(t[i]=v=>new Promise((A,f,L)=>(v=h.call(a,v),L=v.done,Promise.resolve(v.value).then(H=>A({value:H,done:L}),f)))),s("next"),s("return"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Yt=require("../index-DekP7OZe.cjs"),M=require("../events-KVanG9sR.cjs"),re=require("../polyfills-Df4r-ETT.cjs"),Wt=require("../scroll-CIdNtj3G.cjs");require("construct-style-sheets-polyfill");const st=require("../url-YEESIcRn.cjs"),ne=require("../css-value-parser/index.cjs");class jt 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)}}Yt.isBrowser&&!customElements.get("morph-announcer")&&customElements.define("morph-announcer",jt);var R,l,D,rt,G;class yt{constructor(t,s){o(this,R);o(this,l);o(this,D);o(this,rt,t=>{var i;if(t.preventDefault(),document.documentElement.classList.contains("click-disabled"))return;if(e(this,l).hasAttribute("data-back")&&e(this,R).previousURL)history.back();else{n(this,D,e(this,l).getAttribute("href")||"/");const h=e(this,l).getAttribute("data-history-action")||"push",v=e(this,l).hasAttribute("data-center-scroll"),A=getComputedStyle(e(this,l)).getPropertyValue("--offset-scroll").trim(),f=A?ne.cssValueParser.parse(A):void 0,L=e(this,l).hasAttribute("data-revalidate"),H=e(this,l).hasAttribute("data-keep-search-parameters"),$t=e(this,l).hasAttribute("data-keep-scroll-position"),ht=(i=e(this,l).getAttribute("data-submorph"))==null?void 0:i.split(",").map(ct=>ct.trim()),c=e(this,l).hasAttribute("data-clear-state");e(this,R).navigate(e(this,D),{historyAction:h,centerScroll:v,offsetScroll:f,revalidate:L,keepSearchParameters:H,submorph:ht,clearState:c,keepScrollPosition:$t})}});o(this,G,()=>{const t=e(this,l).hasAttribute("data-revalidate");e(this,R).prefetch(e(this,D),t),e(this,l).removeEventListener("pointerenter",e(this,G))});n(this,R,s),n(this,l,t),n(this,D,e(this,l).getAttribute("href")||"/"),e(this,l).addEventListener("click",e(this,rt)),this.checkCurrent(location.pathname),e(this,l).hasAttribute("data-prefetch")&&e(this,l).addEventListener("pointerenter",e(this,G))}get element(){return e(this,l)}checkCurrent(t){var h;const s=e(this,R).normalizePath(t),i=e(this,R).normalizePath(e(this,D));e(this,l).hasAttribute("data-include")&&s.pathname.includes(i.pathname)?e(this,l).classList.add("current"):i.pathname===s.pathname?e(this,l).classList.add("current"):(h=e(this,l).getAttribute("data-associated-paths"))!=null&&h.split(",").find(v=>s.pathname.includes(v))?e(this,l).classList.add("current"):e(this,l).classList.remove("current")}destroy(){e(this,l).removeEventListener("click",e(this,rt)),e(this,l).removeEventListener("pointerenter",e(this,G)),e(this,l).classList.remove("current")}}R=new WeakMap,l=new WeakMap,D=new WeakMap,rt=new WeakMap,G=new WeakMap;const ae=new DOMParser;var T,W,y,k,X,U,J,Y,z,Q,nt;class Xt{constructor(t,s){o(this,T);o(this,W);o(this,y,{x:0,y:0});o(this,k,null);o(this,X,null);o(this,U,null);o(this,J,null);o(this,Y,null);o(this,z,null);o(this,Q);o(this,nt);n(this,T,t),n(this,W,s),n(this,Q,s)}get pathname(){return e(this,W)}get scrollState(){return e(this,y)}get document(){return e(this,U)}setHeaders(t){n(this,nt,t)}setInitialDocument(t){n(this,k,t.cloneNode(!0))}abort(){var t;return(t=e(this,Y))==null?void 0:t.abort(`[${e(this,W)}] page loading cancelled`)}fetch(t,s,i){return B(this,null,function*(){return e(this,z)||e(this,k)&&e(this,k).documentElement.hasAttribute("data-cache")&&(!i||e(this,Q)!==t)||e(this,k)&&e(this,T).isPopstateNavigation?e(this,z):(n(this,Q,t),n(this,z,new Promise(h=>B(this,null,function*(){try{n(this,Y,new AbortController);const A=yield(yield fetch(t,{signal:e(this,Y).signal,headers:ft({"X-MORPH":"true","X-MORPH-CURRENT-PATH":s,"X-MORPH-NEW-PATH":t},e(this,nt))})).text(),f=ae.parseFromString(A,"text/html");this.setInitialDocument(f)}catch(v){console.warn(v)}finally{n(this,Y,null),n(this,z,null),h()}}))),e(this,z))})}cloneDocument(){n(this,U,(e(this,X)||e(this,k)).cloneNode(!0))}get title(){let t="";if(e(this,U).title)t=e(this,U).title;else{const s=e(this,U).querySelector("h1");t=(s==null?void 0:s.innerText)||(s==null?void 0:s.textContent)||e(this,W)}return t}clearScrollState(){e(this,y).x=0,e(this,y).y=0}clearDocumentState(){n(this,X,null)}saveScrollState(){e(this,k).documentElement.hasAttribute("data-no-scroll-restoration")?(e(this,y).x=0,e(this,y).y=0):(e(this,y).x=e(this,T).scrollValue.left,e(this,y).y=e(this,T).scrollValue.top)}restoreScrollPosition(){e(this,T).scrollElement.scroll({top:e(this,y).y,left:e(this,y).x,behavior:"instant"})}saveDocumentState(){e(this,k).documentElement.hasAttribute("data-no-page-restoration")?n(this,X,null):n(this,X,document.cloneNode(!0))}renewScrollPosition(){e(this,T).scrollElement.scroll({top:0,left:0,behavior:"instant"})}saveState(t){n(this,J,t)}clearState(){const t=e(this,J);return n(this,J,null),t}}T=new WeakMap,W=new WeakMap,y=new WeakMap,k=new WeakMap,X=new WeakMap,U=new WeakMap,J=new WeakMap,Y=new WeakMap,z=new WeakMap,Q=new WeakMap,nt=new WeakMap;var C,Z,g,I,m,j,V,O,P,at,x,K,_,tt,ot,u,Pt,lt,pt,At,Kt,kt,Ct,Ht,Mt,Et,et;const it=class it{constructor(t){o(this,u);o(this,C,null);o(this,Z,null);o(this,g,[]);o(this,I);o(this,m,null);o(this,j);o(this,V,[]);o(this,O,!1);o(this,P,null);o(this,at,!1);o(this,x,new Map);o(this,K,null);o(this,_,0);o(this,tt,0);o(this,ot,null);o(this,lt,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,Et,t=>B(this,null,function*(){t.preventDefault(),n(this,O,!0),yield this.navigate(location.href.replace(location.origin,""),{historyAction:"none",submorph:e(this,ot)||void 0}),n(this,O,!1)}));o(this,et,()=>{const{left:t,top:s}=this.scrollValue,i=s-e(this,tt),h=t-e(this,_);n(this,tt,s),n(this,_,t),document.documentElement.classList.toggle("scroll-y",s>0),document.documentElement.classList.toggle("scroll-x",t>0),document.documentElement.classList.toggle("scroll-y-forward",i>0),document.documentElement.classList.toggle("scroll-y-backward",i<0),document.documentElement.classList.toggle("scroll-x-forward",h>0),document.documentElement.classList.toggle("scroll-x-backward",h<0),M.dispatchEvent(document,"morphScroll",{detail:{left:t,top:s}})});if(Yt.isBrowser&&!it.instance){it.instance=this,n(this,C,{base:st.normalizeBase(t==null?void 0:t.base),waitForHeadToLoad:(t==null?void 0:t.waitForHeadToLoad)!==!1,trailingSlash:(t==null?void 0:t.trailingSlash)||!1,scrollSelector:t==null?void 0:t.scrollSelector,morphInsideScrollContainer:(t==null?void 0:t.morphInsideScrollContainer)||!1}),n(this,Z,E(this,u,At).call(this,document.body));const s=this.normalizePath(location.pathname+location.hash+location.search);n(this,m,s);const i=new Xt(this,e(this,m).pathname);i.setInitialDocument(document),e(this,x).set(e(this,m).pathname,i),document.documentElement.setAttribute("data-current-pathname",e(this,m).pathname),document.documentElement.setAttribute("data-current-leaf",s.leaf),this.findLinks(),history.scrollRestoration="manual",addEventListener("popstate",e(this,Et)),st.changeHistory({action:"replace",pathname:s.pathname,searchParameters:s.parameters,hash:s.hash}),n(this,K,new jt),E(this,u,Ht).call(this,document)}}get currentURL(){return e(this,m)}get previousURL(){return e(this,j)}get links(){return e(this,g)}get scrollElement(){return e(this,P)}get isPopstateNavigation(){return e(this,O)}get scrollValue(){let t=0,s=0;return e(this,at)?(t=window.scrollY,s=window.scrollX):(t=e(this,P).scrollTop,s=e(this,P).scrollLeft),{top:t,left:s}}saveState(t){const s=e(this,x).get(e(this,m).path);s&&s.saveState(t)}getState(){const t=e(this,x).get(e(this,m).path);return t==null?void 0:t.clearState()}normalizePath(t){return st.splitPath(t,{base:e(this,C).base,trailingSlash:e(this,C).trailingSlash})}prefetch(t,s){return B(this,null,function*(){var h;if(e(this,V).length)return;t=((h=this.pathnameModifier)==null?void 0:h.call(this,t))||t;const i=E(this,u,pt).call(this,t);i==null||i.fetch(t,e(this,m).path,s)})}excludeHeadChild(t){return!1}setHeaders(t){}navigate($t){return B(this,arguments,function*(t,{historyAction:s="push",centerScroll:i,offsetScroll:h,revalidate:v,keepSearchParameters:A,submorph:f,clearState:L,keepScrollPosition:H}={}){var ct,Rt,Tt,xt;if(e(this,V).length)return;n(this,ot,f||null);const ht=((ct=this.pathnameModifier)==null?void 0:ct.call(this,t))||t,c=this.normalizePath(ht);if(((Rt=e(this,I))==null?void 0:Rt.pathname)===c.pathname||e(this,m).pathname===c.pathname){E(this,u,Mt).call(this,c.hash||0,{centerScroll:i,offsetScroll:h,behavior:"smooth"}),M.dispatchEvent(document,"morphSamePath",{custom:!0}),((Tt=e(this,m))==null?void 0:Tt.parameters)!==c.parameters&&(n(this,j,e(this,m)),n(this,m,c),st.changeHistory({action:((xt=e(this,m))==null?void 0:xt.hash)!==c.hash?"replace":s,pathname:c.pathname,searchParameters:c.parameters,hash:c.hash}),M.dispatchEvent(document,"morphURLParametersChange",{detail:{newURL:e(this,m),previousURL:e(this,j)}}));return}n(this,I,c),e(this,g).forEach($=>{$.checkCurrent(c.pathname)});try{let $=!0;if(this.preprocessor)try{yield new Promise((r,S)=>{var b;(b=this.preprocessor)==null||b.call(this,{url:c,resolve:r,reject:S,submorph:f})})}catch(r){r?console.error(r):console.log("Route change canceled"),$=!1}if(!$||e(this,I).pathname!==c.pathname){e(this,g).forEach(r=>{r.checkCurrent(e(this,m).pathname)});return}const Nt={url:c,submorph:f};f?f.forEach(r=>{document.querySelectorAll(r).forEach(S=>{S.classList.add("out"),S.setAttribute("data-morph-out","")})}):e(this,Z).forEach(r=>{var S,b;(S=r.firstElementChild)==null||S.classList.add("out"),(b=r.firstElementChild)==null||b.setAttribute("data-morph-out","")}),M.dispatchEvent(document,"morphNavigation",{detail:Nt});const gt=E(this,u,pt).call(this,e(this,m).pathname),p=E(this,u,pt).call(this,c.pathname);if(e(this,x).forEach(r=>{r.pathname!==c.pathname&&r.abort()}),yield p==null?void 0:p.fetch(ht,e(this,m).path,v),e(this,I).pathname!==c.pathname){e(this,g).forEach(r=>{r.checkCurrent(e(this,m).path)});return}gt.clearState(),gt.saveScrollState(),gt.saveDocumentState(),e(this,O)||(p.clearScrollState(),p.clearDocumentState()),L&&p.clearState(),p.cloneDocument(),e(this,K).textContent=p.title,document.body.appendChild(e(this,K));const ut=Lt(ft({},Nt),{document:p.document});ut.document.querySelectorAll("[data-morph-out]").forEach(r=>{r.classList.remove("out")}),M.dispatchEvent(document,"morphStart",{detail:ut});const qt=Array.from(document.head.children),Dt=Array.from(p.document.head.children),Ut=E(this,u,Kt).call(this,qt,Dt),Gt=E(this,u,kt).call(this,qt,Ut),dt=E(this,u,kt).call(this,Dt,Ut).filter(r=>!this.excludeHeadChild(r));dt.forEach((r,S)=>{r.tagName==="SCRIPT"&&(dt[S]=E(this,u,Pt).call(this,r))}),dt.forEach(r=>{document.head.appendChild(r)});const vt=dt.filter(r=>{if(r.hasAttribute("data-no-waiting"))return!1;if(E(this,u,Ct).call(this,r))return!0});e(this,C).waitForHeadToLoad&&vt.length&&(yield new Promise(r=>B(this,null,function*(){let S=0;try{for(var b=Bt(vt),Qt,F,N;Qt=!(F=yield b.next()).done;Qt=!1){const mt=F.value;mt.onload=()=>{S++,S===vt.length&&r()}}}catch(F){N=[F]}finally{try{Qt&&(F=b.return)&&(yield F.call(b))}finally{if(N)throw N[0]}}}))),yield Wt.wait(10);const zt=[];Gt.forEach(r=>{r.hasAttribute("data-permanent")||(E(this,u,Ct).call(this,r)?zt.push(r):r.remove())});const Jt=E(this,u,At).call(this,p.document.body);!e(this,C).morphInsideScrollContainer&&!f&&E(this,u,Ht).call(this,p.document),document.documentElement.setAttribute("data-current-pathname",c.pathname),document.documentElement.setAttribute("data-current-leaf",c.leaf),st.changeHistory({action:s,pathname:c.pathname,searchParameters:c.parameters||(A?location.search:""),hash:c.hash}),e(this,K).remove(),n(this,j,e(this,m)),n(this,m,c);const St=[];e(this,Z).forEach((r,S)=>{const b=Jt[S],Qt=getComputedStyle(r).getPropertyValue("--morph-duration");let F=[],N=[];f?(f.forEach(d=>{const w=r.querySelector(d),q=b.querySelector(d);w&&q&&(N.push(w),F.push(q))}),N.forEach(d=>{d.parentElement&&St.push(d.parentElement)})):(F.push(...b.childNodes),N.push(...r.childNodes),St.push(r)),N.forEach(d=>{d instanceof HTMLElement&&(this.destroyOldLinks(d),d.classList.add("old"))}),F.forEach(d=>{d instanceof HTMLElement&&(this.findNewLinks(d),d.classList.add("new"))}),f?F.forEach((d,w)=>{var q;(q=N[w].parentElement)==null||q.insertBefore(d,N[w])}):r.prepend(...F),re.requestIdleCallback(()=>{N.forEach(d=>{d instanceof HTMLElement&&d.classList.add("old-idle")}),F.forEach(d=>{var w;d instanceof HTMLElement&&((w=d.parentElement)==null||w.style.setProperty("--new-content-height",d.offsetHeight+"px"),d.classList.add("new-idle"))})});const mt=Lt(ft({},ut),{morphElement:r});M.dispatchEvent(document,"morphNewChildrenAdded",{detail:mt});const Zt=new Promise(d=>{setTimeout(()=>{N.forEach(w=>w.remove()),F.forEach(w=>{var q;w instanceof HTMLElement&&((q=w.parentElement)==null||q.style.removeProperty("--new-content-height"),w.classList.remove("new-idle","new"))}),M.dispatchEvent(document,"morphOldChildrenRemoved",{detail:mt}),d()},(parseFloat(Qt)||0)*1e3+10)});e(this,V).push(Zt)}),this.isPopstateNavigation?document.documentElement.style.setProperty("--new-document-scroll-position",(this.scrollValue.top-p.scrollState.y)*1+"px"):document.documentElement.style.setProperty("--new-document-scroll-position",this.scrollValue.top+"px"),M.dispatchEvent(document,"morphBeforeNavigationScroll",{detail:p.scrollState}),c.hash?(p.clearScrollState(),E(this,u,Mt).call(this,c.hash,{centerScroll:i,offsetScroll:h})):e(this,O)?p.restoreScrollPosition():H||p.renewScrollPosition(),yield Promise.all(e(this,V)),zt.forEach(r=>r.remove()),n(this,V,[]),St.forEach(r=>{r.querySelectorAll("script").forEach(b=>{b.replaceWith(E(this,u,Pt).call(this,b))})}),e(this,g).forEach(r=>{r.checkCurrent(e(this,m).path)}),M.dispatchEvent(document,"morphComplete",{detail:ut}),document.documentElement.style.removeProperty("--new-document-scroll-position"),window.dispatchEvent(new Event("resize"))}catch($){console.error($)}n(this,I,void 0)})}addLink(t){e(this,g).push(new yt(t,this))}addLinks(t){t.forEach(s=>{this.addLink(s)})}removeLink(t){n(this,g,e(this,g).filter(s=>s.element===t?(s.destroy(),!1):!0))}destroyOldLinks(t){n(this,g,e(this,g).filter(s=>t.contains(s.element)?(s.destroy(),!1):!0))}findNewLinks(t){const s=[...t.querySelectorAll("a")].filter(e(this,lt));e(this,g).push(...s.map(i=>new yt(i,this)))}findLinks(){const t=[...document.documentElement.querySelectorAll("a")].filter(e(this,lt));e(this,g).forEach(s=>s.destroy()),n(this,g,t.map(s=>new yt(s,this)))}};C=new WeakMap,Z=new WeakMap,g=new WeakMap,I=new WeakMap,m=new WeakMap,j=new WeakMap,V=new WeakMap,O=new WeakMap,P=new WeakMap,at=new WeakMap,x=new WeakMap,K=new WeakMap,_=new WeakMap,tt=new WeakMap,ot=new WeakMap,u=new WeakSet,Pt=function(t){const s=document.createElement("script");for(let i=0;i<t.attributes.length;i++){const h=t.attributes[i];s.setAttribute(h.name,h.value)}return t.hasAttribute("src")||(s.innerHTML=t.innerHTML),s},lt=new WeakMap,pt=function(t){const s=this.normalizePath(t);let i=e(this,x).get(s.pathname);return i||(i=new Xt(this,s.pathname),e(this,x).set(s.pathname,i)),i},At=function(t){const s=[...t.querySelectorAll("[data-morph]")];return s.length?s:[t]},Kt=function(t,s){return t.filter(i=>s.find(h=>h.outerHTML===i.outerHTML))},kt=function(t,s){return t.filter(i=>!s.find(h=>h.outerHTML===i.outerHTML))},Ct=function(t){return t.tagName==="SCRIPT"||t.tagName==="STYLE"||t.tagName==="LINK"&&t.getAttribute("rel")==="stylesheet"},Ht=function(t){var s,i;(s=e(this,P))==null||s.removeEventListener("scroll",e(this,et)),n(this,tt,0),n(this,_,0),n(this,P,e(this,C).scrollSelector&&t.querySelector(e(this,C).scrollSelector)||window),n(this,at,e(this,P)===window),(i=e(this,P))==null||i.addEventListener("scroll",e(this,et)),e(this,et).call(this)},Mt=function(t,s){const i=typeof t=="string"?document.getElementById(t):t;(typeof i=="number"||i)&&Wt.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})},Et=new WeakMap,et=new WeakMap,it.instance=null;let bt=it;exports.Morph=bt;
|
package/lib/morph/index.js
CHANGED
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
1
|
+
var Zt = Object.defineProperty, _t = Object.defineProperties;
|
|
2
|
+
var te = Object.getOwnPropertyDescriptors;
|
|
3
3
|
var zt = Object.getOwnPropertySymbols;
|
|
4
|
-
var
|
|
4
|
+
var ee = Object.prototype.hasOwnProperty, se = Object.prototype.propertyIsEnumerable;
|
|
5
5
|
var It = (a, t) => (t = Symbol[a]) ? t : Symbol.for("Symbol." + a), Ot = (a) => {
|
|
6
6
|
throw TypeError(a);
|
|
7
7
|
};
|
|
8
|
-
var Vt = (a, t, s) => t in a ?
|
|
8
|
+
var Vt = (a, t, s) => t in a ? Zt(a, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : a[t] = s, mt = (a, t) => {
|
|
9
9
|
for (var s in t || (t = {}))
|
|
10
|
-
|
|
10
|
+
ee.call(t, s) && Vt(a, s, t[s]);
|
|
11
11
|
if (zt)
|
|
12
12
|
for (var s of zt(t))
|
|
13
|
-
|
|
13
|
+
se.call(t, s) && Vt(a, s, t[s]);
|
|
14
14
|
return a;
|
|
15
|
-
}, Lt = (a, t) =>
|
|
15
|
+
}, Lt = (a, t) => _t(a, te(t));
|
|
16
16
|
var wt = (a, t, s) => t.has(a) || Ot("Cannot " + s);
|
|
17
17
|
var e = (a, t, s) => (wt(a, t, "read from private field"), s ? s.call(a) : t.get(a)), o = (a, t, s) => t.has(a) ? Ot("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(a) : t.set(a, s), n = (a, t, s, i) => (wt(a, t, "write to private field"), i ? i.call(a, s) : t.set(a, s), s), E = (a, t, s) => (wt(a, t, "access private method"), s);
|
|
18
18
|
var W = (a, t, s) => new Promise((i, h) => {
|
|
19
19
|
var S = (w) => {
|
|
20
20
|
try {
|
|
21
21
|
f(s.next(w));
|
|
22
|
-
} catch (
|
|
23
|
-
h(
|
|
22
|
+
} catch (H) {
|
|
23
|
+
h(H);
|
|
24
24
|
}
|
|
25
25
|
}, P = (w) => {
|
|
26
26
|
try {
|
|
27
27
|
f(s.throw(w));
|
|
28
|
-
} catch (
|
|
29
|
-
h(
|
|
28
|
+
} catch (H) {
|
|
29
|
+
h(H);
|
|
30
30
|
}
|
|
31
31
|
}, f = (w) => w.done ? i(w.value) : Promise.resolve(w.value).then(S, P);
|
|
32
32
|
f((s = s.apply(a, t)).next());
|
|
33
33
|
});
|
|
34
|
-
var Ft = (a, t, s) => (t = a[It("asyncIterator")]) ? t.call(a) : (a = a[It("iterator")](), t = {}, s = (i, h) => (h = a[i]) && (t[i] = (S) => new Promise((P, f, w) => (S = h.call(a, S), w = S.done, Promise.resolve(S.value).then((
|
|
34
|
+
var Ft = (a, t, s) => (t = a[It("asyncIterator")]) ? t.call(a) : (a = a[It("iterator")](), t = {}, s = (i, h) => (h = a[i]) && (t[i] = (S) => new Promise((P, f, w) => (S = h.call(a, S), w = S.done, Promise.resolve(S.value).then((H) => P({ value: H, done: w }), f)))), s("next"), s("return"), t);
|
|
35
35
|
import { i as Bt } from "../index-Bv9zgfdb.js";
|
|
36
|
-
import { d as
|
|
37
|
-
import { r as
|
|
38
|
-
import { w as
|
|
36
|
+
import { d as R } from "../events-CsVF98U6.js";
|
|
37
|
+
import { r as ie } from "../polyfills-DJrTJQky.js";
|
|
38
|
+
import { w as re, s as ne } from "../scroll-DPkCFTxg.js";
|
|
39
39
|
import "construct-style-sheets-polyfill";
|
|
40
|
-
import { n as
|
|
41
|
-
import { cssValueParser as
|
|
40
|
+
import { n as ae, c as vt, s as oe } from "../url-UL9zSCHb.js";
|
|
41
|
+
import { cssValueParser as le } from "../css-value-parser/index.js";
|
|
42
42
|
class Yt extends HTMLElement {
|
|
43
43
|
connectedCallback() {
|
|
44
44
|
const t = {
|
|
@@ -51,71 +51,74 @@ class Yt extends HTMLElement {
|
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
Bt && !customElements.get("morph-announcer") && customElements.define("morph-announcer", Yt);
|
|
54
|
-
var
|
|
54
|
+
var M, l, U, it, G;
|
|
55
55
|
class yt {
|
|
56
56
|
constructor(t, s) {
|
|
57
|
-
o(this,
|
|
57
|
+
o(this, M);
|
|
58
58
|
o(this, l);
|
|
59
|
-
o(this,
|
|
59
|
+
o(this, U);
|
|
60
60
|
o(this, it, (t) => {
|
|
61
61
|
var i;
|
|
62
62
|
if (t.preventDefault(), document.documentElement.classList.contains("click-disabled"))
|
|
63
63
|
return;
|
|
64
|
-
if (e(this, l).hasAttribute("data-back") && e(this,
|
|
64
|
+
if (e(this, l).hasAttribute("data-back") && e(this, M).previousURL)
|
|
65
65
|
history.back();
|
|
66
66
|
else {
|
|
67
|
-
n(this,
|
|
67
|
+
n(this, U, e(this, l).getAttribute("href") || "/");
|
|
68
68
|
const h = e(this, l).getAttribute(
|
|
69
69
|
"data-history-action"
|
|
70
|
-
) || "push", S = e(this, l).hasAttribute("data-center-scroll"), P = getComputedStyle(e(this, l)).getPropertyValue("--offset-scroll").trim(), f = P ?
|
|
70
|
+
) || "push", S = e(this, l).hasAttribute("data-center-scroll"), P = getComputedStyle(e(this, l)).getPropertyValue("--offset-scroll").trim(), f = P ? le.parse(P) : void 0, w = e(this, l).hasAttribute("data-revalidate"), H = e(this, l).hasAttribute(
|
|
71
71
|
"data-keep-search-parameters"
|
|
72
|
+
), Kt = e(this, l).hasAttribute(
|
|
73
|
+
"data-keep-scroll-position"
|
|
72
74
|
), lt = (i = e(this, l).getAttribute("data-submorph")) == null ? void 0 : i.split(",").map((ht) => ht.trim()), c = e(this, l).hasAttribute("data-clear-state");
|
|
73
|
-
e(this,
|
|
75
|
+
e(this, M).navigate(e(this, U), {
|
|
74
76
|
historyAction: h,
|
|
75
77
|
centerScroll: S,
|
|
76
78
|
offsetScroll: f,
|
|
77
79
|
revalidate: w,
|
|
78
|
-
keepSearchParameters:
|
|
80
|
+
keepSearchParameters: H,
|
|
79
81
|
submorph: lt,
|
|
80
|
-
clearState: c
|
|
82
|
+
clearState: c,
|
|
83
|
+
keepScrollPosition: Kt
|
|
81
84
|
});
|
|
82
85
|
}
|
|
83
86
|
});
|
|
84
87
|
o(this, G, () => {
|
|
85
88
|
const t = e(this, l).hasAttribute("data-revalidate");
|
|
86
|
-
e(this,
|
|
89
|
+
e(this, M).prefetch(e(this, U), t), e(this, l).removeEventListener("pointerenter", e(this, G));
|
|
87
90
|
});
|
|
88
|
-
n(this,
|
|
91
|
+
n(this, M, s), n(this, l, t), n(this, U, e(this, l).getAttribute("href") || "/"), e(this, l).addEventListener("click", e(this, it)), this.checkCurrent(location.pathname), e(this, l).hasAttribute("data-prefetch") && e(this, l).addEventListener("pointerenter", e(this, G));
|
|
89
92
|
}
|
|
90
93
|
get element() {
|
|
91
94
|
return e(this, l);
|
|
92
95
|
}
|
|
93
96
|
checkCurrent(t) {
|
|
94
97
|
var h;
|
|
95
|
-
const s = e(this,
|
|
98
|
+
const s = e(this, M).normalizePath(t), i = e(this, M).normalizePath(e(this, U));
|
|
96
99
|
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") : (h = e(this, l).getAttribute("data-associated-paths")) != null && h.split(",").find((S) => s.pathname.includes(S)) ? e(this, l).classList.add("current") : e(this, l).classList.remove("current");
|
|
97
100
|
}
|
|
98
101
|
destroy() {
|
|
99
102
|
e(this, l).removeEventListener("click", e(this, it)), e(this, l).removeEventListener("pointerenter", e(this, G)), e(this, l).classList.remove("current");
|
|
100
103
|
}
|
|
101
104
|
}
|
|
102
|
-
|
|
103
|
-
const
|
|
104
|
-
var
|
|
105
|
+
M = new WeakMap(), l = new WeakMap(), U = new WeakMap(), it = new WeakMap(), G = new WeakMap();
|
|
106
|
+
const he = new DOMParser();
|
|
107
|
+
var T, X, y, k, B, q, J, Y, z, Q, rt;
|
|
105
108
|
class Wt {
|
|
106
109
|
constructor(t, s) {
|
|
107
|
-
o(this,
|
|
110
|
+
o(this, T);
|
|
108
111
|
o(this, X);
|
|
109
112
|
o(this, y, { x: 0, y: 0 });
|
|
110
113
|
o(this, k, null);
|
|
111
114
|
o(this, B, null);
|
|
112
|
-
o(this,
|
|
115
|
+
o(this, q, null);
|
|
113
116
|
o(this, J, null);
|
|
114
117
|
o(this, Y, null);
|
|
115
|
-
o(this,
|
|
118
|
+
o(this, z, null);
|
|
116
119
|
o(this, Q);
|
|
117
120
|
o(this, rt);
|
|
118
|
-
n(this,
|
|
121
|
+
n(this, T, t), n(this, X, s), n(this, Q, s);
|
|
119
122
|
}
|
|
120
123
|
get pathname() {
|
|
121
124
|
return e(this, X);
|
|
@@ -124,7 +127,7 @@ class Wt {
|
|
|
124
127
|
return e(this, y);
|
|
125
128
|
}
|
|
126
129
|
get document() {
|
|
127
|
-
return e(this,
|
|
130
|
+
return e(this, q);
|
|
128
131
|
}
|
|
129
132
|
setHeaders(t) {
|
|
130
133
|
n(this, rt, t);
|
|
@@ -140,7 +143,7 @@ class Wt {
|
|
|
140
143
|
}
|
|
141
144
|
fetch(t, s, i) {
|
|
142
145
|
return W(this, null, function* () {
|
|
143
|
-
return e(this,
|
|
146
|
+
return e(this, z) || e(this, k) && e(this, k).documentElement.hasAttribute("data-cache") && (!i || e(this, Q) !== t) || e(this, k) && e(this, T).isPopstateNavigation ? e(this, z) : (n(this, Q, t), n(this, z, new Promise((h) => W(this, null, function* () {
|
|
144
147
|
try {
|
|
145
148
|
n(this, Y, new AbortController());
|
|
146
149
|
const P = yield (yield fetch(t, {
|
|
@@ -150,25 +153,25 @@ class Wt {
|
|
|
150
153
|
"X-MORPH-CURRENT-PATH": s,
|
|
151
154
|
"X-MORPH-NEW-PATH": t
|
|
152
155
|
}, e(this, rt))
|
|
153
|
-
})).text(), f =
|
|
156
|
+
})).text(), f = he.parseFromString(P, "text/html");
|
|
154
157
|
this.setInitialDocument(f);
|
|
155
158
|
} catch (S) {
|
|
156
159
|
console.warn(S);
|
|
157
160
|
} finally {
|
|
158
|
-
n(this, Y, null), n(this,
|
|
161
|
+
n(this, Y, null), n(this, z, null), h();
|
|
159
162
|
}
|
|
160
|
-
}))), e(this,
|
|
163
|
+
}))), e(this, z));
|
|
161
164
|
});
|
|
162
165
|
}
|
|
163
166
|
cloneDocument() {
|
|
164
|
-
n(this,
|
|
167
|
+
n(this, q, (e(this, B) || e(this, k)).cloneNode(!0));
|
|
165
168
|
}
|
|
166
169
|
get title() {
|
|
167
170
|
let t = "";
|
|
168
|
-
if (e(this,
|
|
169
|
-
t = e(this,
|
|
171
|
+
if (e(this, q).title)
|
|
172
|
+
t = e(this, q).title;
|
|
170
173
|
else {
|
|
171
|
-
const s = e(this,
|
|
174
|
+
const s = e(this, q).querySelector("h1");
|
|
172
175
|
t = (s == null ? void 0 : s.innerText) || (s == null ? void 0 : s.textContent) || e(this, X);
|
|
173
176
|
}
|
|
174
177
|
return t;
|
|
@@ -182,10 +185,10 @@ class Wt {
|
|
|
182
185
|
saveScrollState() {
|
|
183
186
|
e(this, k).documentElement.hasAttribute(
|
|
184
187
|
"data-no-scroll-restoration"
|
|
185
|
-
) ? (e(this, y).x = 0, e(this, y).y = 0) : (e(this, y).x = e(this,
|
|
188
|
+
) ? (e(this, y).x = 0, e(this, y).y = 0) : (e(this, y).x = e(this, T).scrollValue.left, e(this, y).y = e(this, T).scrollValue.top);
|
|
186
189
|
}
|
|
187
190
|
restoreScrollPosition() {
|
|
188
|
-
e(this,
|
|
191
|
+
e(this, T).scrollElement.scroll({
|
|
189
192
|
top: e(this, y).y,
|
|
190
193
|
left: e(this, y).x,
|
|
191
194
|
behavior: "instant"
|
|
@@ -197,7 +200,7 @@ class Wt {
|
|
|
197
200
|
) ? n(this, B, null) : n(this, B, document.cloneNode(!0));
|
|
198
201
|
}
|
|
199
202
|
renewScrollPosition() {
|
|
200
|
-
e(this,
|
|
203
|
+
e(this, T).scrollElement.scroll({
|
|
201
204
|
top: 0,
|
|
202
205
|
left: 0,
|
|
203
206
|
behavior: "instant"
|
|
@@ -211,22 +214,22 @@ class Wt {
|
|
|
211
214
|
return n(this, J, null), t;
|
|
212
215
|
}
|
|
213
216
|
}
|
|
214
|
-
|
|
215
|
-
var C, Z, g,
|
|
217
|
+
T = new WeakMap(), X = new WeakMap(), y = new WeakMap(), k = new WeakMap(), B = new WeakMap(), q = new WeakMap(), J = new WeakMap(), Y = new WeakMap(), z = new WeakMap(), Q = new WeakMap(), rt = new WeakMap();
|
|
218
|
+
var C, Z, g, I, m, j, V, O, A, nt, x, K, _, tt, at, u, bt, ot, ft, At, jt, Pt, kt, Ct, Ht, pt, et;
|
|
216
219
|
const st = class st {
|
|
217
220
|
constructor(t) {
|
|
218
221
|
o(this, u);
|
|
219
222
|
o(this, C, null);
|
|
220
223
|
o(this, Z, null);
|
|
221
224
|
o(this, g, []);
|
|
222
|
-
o(this,
|
|
225
|
+
o(this, I);
|
|
223
226
|
o(this, m, null);
|
|
224
227
|
o(this, j);
|
|
225
|
-
o(this,
|
|
226
|
-
o(this,
|
|
228
|
+
o(this, V, []);
|
|
229
|
+
o(this, O, !1);
|
|
227
230
|
o(this, A, null);
|
|
228
231
|
o(this, nt, !1);
|
|
229
|
-
o(this,
|
|
232
|
+
o(this, x, /* @__PURE__ */ new Map());
|
|
230
233
|
o(this, K, null);
|
|
231
234
|
o(this, _, 0);
|
|
232
235
|
o(this, tt, 0);
|
|
@@ -236,10 +239,10 @@ const st = class st {
|
|
|
236
239
|
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";
|
|
237
240
|
});
|
|
238
241
|
o(this, pt, (t) => W(this, null, function* () {
|
|
239
|
-
t.preventDefault(), n(this,
|
|
242
|
+
t.preventDefault(), n(this, O, !0), yield this.navigate(location.href.replace(location.origin, ""), {
|
|
240
243
|
historyAction: "none",
|
|
241
244
|
submorph: e(this, at) || void 0
|
|
242
|
-
}), n(this,
|
|
245
|
+
}), n(this, O, !1);
|
|
243
246
|
}));
|
|
244
247
|
o(this, et, () => {
|
|
245
248
|
const { left: t, top: s } = this.scrollValue, i = s - e(this, tt), h = t - e(this, _);
|
|
@@ -255,7 +258,7 @@ const st = class st {
|
|
|
255
258
|
), document.documentElement.classList.toggle(
|
|
256
259
|
"scroll-x-backward",
|
|
257
260
|
h < 0
|
|
258
|
-
),
|
|
261
|
+
), R(document, "morphScroll", {
|
|
259
262
|
detail: {
|
|
260
263
|
left: t,
|
|
261
264
|
top: s
|
|
@@ -264,7 +267,7 @@ const st = class st {
|
|
|
264
267
|
});
|
|
265
268
|
if (Bt && !st.instance) {
|
|
266
269
|
st.instance = this, n(this, C, {
|
|
267
|
-
base:
|
|
270
|
+
base: ae(t == null ? void 0 : t.base),
|
|
268
271
|
waitForHeadToLoad: (t == null ? void 0 : t.waitForHeadToLoad) !== !1,
|
|
269
272
|
trailingSlash: (t == null ? void 0 : t.trailingSlash) || !1,
|
|
270
273
|
scrollSelector: t == null ? void 0 : t.scrollSelector,
|
|
@@ -275,7 +278,7 @@ const st = class st {
|
|
|
275
278
|
);
|
|
276
279
|
n(this, m, s);
|
|
277
280
|
const i = new Wt(this, e(this, m).pathname);
|
|
278
|
-
i.setInitialDocument(document), e(this,
|
|
281
|
+
i.setInitialDocument(document), e(this, x).set(e(this, m).pathname, i), document.documentElement.setAttribute(
|
|
279
282
|
"data-current-pathname",
|
|
280
283
|
e(this, m).pathname
|
|
281
284
|
), document.documentElement.setAttribute(
|
|
@@ -302,22 +305,22 @@ const st = class st {
|
|
|
302
305
|
return e(this, A);
|
|
303
306
|
}
|
|
304
307
|
get isPopstateNavigation() {
|
|
305
|
-
return e(this,
|
|
308
|
+
return e(this, O);
|
|
306
309
|
}
|
|
307
310
|
get scrollValue() {
|
|
308
311
|
let t = 0, s = 0;
|
|
309
312
|
return e(this, nt) ? (t = window.scrollY, s = window.scrollX) : (t = e(this, A).scrollTop, s = e(this, A).scrollLeft), { top: t, left: s };
|
|
310
313
|
}
|
|
311
314
|
saveState(t) {
|
|
312
|
-
const s = e(this,
|
|
315
|
+
const s = e(this, x).get(e(this, m).path);
|
|
313
316
|
s && s.saveState(t);
|
|
314
317
|
}
|
|
315
318
|
getState() {
|
|
316
|
-
const t = e(this,
|
|
319
|
+
const t = e(this, x).get(e(this, m).path);
|
|
317
320
|
return t == null ? void 0 : t.clearState();
|
|
318
321
|
}
|
|
319
322
|
normalizePath(t) {
|
|
320
|
-
return
|
|
323
|
+
return oe(t, {
|
|
321
324
|
base: e(this, C).base,
|
|
322
325
|
trailingSlash: e(this, C).trailingSlash
|
|
323
326
|
});
|
|
@@ -325,7 +328,7 @@ const st = class st {
|
|
|
325
328
|
prefetch(t, s) {
|
|
326
329
|
return W(this, null, function* () {
|
|
327
330
|
var h;
|
|
328
|
-
if (e(this,
|
|
331
|
+
if (e(this, V).length)
|
|
329
332
|
return;
|
|
330
333
|
t = ((h = this.pathnameModifier) == null ? void 0 : h.call(this, t)) || t;
|
|
331
334
|
const i = E(this, u, ft).call(this, t);
|
|
@@ -337,7 +340,7 @@ const st = class st {
|
|
|
337
340
|
}
|
|
338
341
|
setHeaders(t) {
|
|
339
342
|
}
|
|
340
|
-
navigate(
|
|
343
|
+
navigate(Kt) {
|
|
341
344
|
return W(this, arguments, function* (t, {
|
|
342
345
|
historyAction: s = "push",
|
|
343
346
|
centerScroll: i,
|
|
@@ -345,26 +348,27 @@ const st = class st {
|
|
|
345
348
|
revalidate: S,
|
|
346
349
|
keepSearchParameters: P,
|
|
347
350
|
submorph: f,
|
|
348
|
-
clearState: w
|
|
351
|
+
clearState: w,
|
|
352
|
+
keepScrollPosition: H
|
|
349
353
|
} = {}) {
|
|
350
354
|
var ht, Rt, Mt, Tt;
|
|
351
|
-
if (e(this,
|
|
355
|
+
if (e(this, V).length)
|
|
352
356
|
return;
|
|
353
357
|
n(this, at, f || null);
|
|
354
358
|
const lt = ((ht = this.pathnameModifier) == null ? void 0 : ht.call(this, t)) || t, c = this.normalizePath(lt);
|
|
355
|
-
if (((Rt = e(this,
|
|
359
|
+
if (((Rt = e(this, I)) == null ? void 0 : Rt.pathname) === c.pathname || e(this, m).pathname === c.pathname) {
|
|
356
360
|
E(this, u, Ht).call(this, c.hash || 0, {
|
|
357
361
|
centerScroll: i,
|
|
358
362
|
offsetScroll: h,
|
|
359
363
|
behavior: "smooth"
|
|
360
|
-
}),
|
|
364
|
+
}), R(document, "morphSamePath", {
|
|
361
365
|
custom: !0
|
|
362
366
|
}), ((Mt = e(this, m)) == null ? void 0 : Mt.parameters) !== c.parameters && (n(this, j, e(this, m)), n(this, m, c), vt({
|
|
363
367
|
action: ((Tt = e(this, m)) == null ? void 0 : Tt.hash) !== c.hash ? "replace" : s,
|
|
364
368
|
pathname: c.pathname,
|
|
365
369
|
searchParameters: c.parameters,
|
|
366
370
|
hash: c.hash
|
|
367
|
-
}),
|
|
371
|
+
}), R(document, "morphURLParametersChange", {
|
|
368
372
|
detail: {
|
|
369
373
|
newURL: e(this, m),
|
|
370
374
|
previousURL: e(this, j)
|
|
@@ -372,7 +376,7 @@ const st = class st {
|
|
|
372
376
|
}));
|
|
373
377
|
return;
|
|
374
378
|
}
|
|
375
|
-
n(this,
|
|
379
|
+
n(this, I, c), e(this, g).forEach(($) => {
|
|
376
380
|
$.checkCurrent(c.pathname);
|
|
377
381
|
});
|
|
378
382
|
try {
|
|
@@ -391,7 +395,7 @@ const st = class st {
|
|
|
391
395
|
} catch (r) {
|
|
392
396
|
r ? console.error(r) : console.log("Route change canceled"), $ = !1;
|
|
393
397
|
}
|
|
394
|
-
if (!$ || e(this,
|
|
398
|
+
if (!$ || e(this, I).pathname !== c.pathname) {
|
|
395
399
|
e(this, g).forEach((r) => {
|
|
396
400
|
r.checkCurrent(e(this, m).pathname);
|
|
397
401
|
});
|
|
@@ -408,28 +412,28 @@ const st = class st {
|
|
|
408
412
|
}) : e(this, Z).forEach((r) => {
|
|
409
413
|
var L, b;
|
|
410
414
|
(L = r.firstElementChild) == null || L.classList.add("out"), (b = r.firstElementChild) == null || b.setAttribute("data-morph-out", "");
|
|
411
|
-
}),
|
|
415
|
+
}), R(document, "morphNavigation", {
|
|
412
416
|
detail: xt
|
|
413
417
|
});
|
|
414
418
|
const Et = E(this, u, ft).call(this, e(this, m).pathname), p = E(this, u, ft).call(this, c.pathname);
|
|
415
|
-
if (e(this,
|
|
419
|
+
if (e(this, x).forEach((r) => {
|
|
416
420
|
r.pathname !== c.pathname && r.abort();
|
|
417
|
-
}), yield p == null ? void 0 : p.fetch(lt, e(this, m).path, S), e(this,
|
|
421
|
+
}), yield p == null ? void 0 : p.fetch(lt, e(this, m).path, S), e(this, I).pathname !== c.pathname) {
|
|
418
422
|
e(this, g).forEach((r) => {
|
|
419
423
|
r.checkCurrent(e(this, m).path);
|
|
420
424
|
});
|
|
421
425
|
return;
|
|
422
426
|
}
|
|
423
|
-
Et.clearState(), Et.saveScrollState(), Et.saveDocumentState(), e(this,
|
|
427
|
+
Et.clearState(), Et.saveScrollState(), Et.saveDocumentState(), e(this, O) || (p.clearScrollState(), p.clearDocumentState()), w && p.clearState(), p.cloneDocument(), e(this, K).textContent = p.title, document.body.appendChild(e(this, K));
|
|
424
428
|
const ct = Lt(mt({}, xt), {
|
|
425
429
|
document: p.document
|
|
426
430
|
});
|
|
427
431
|
ct.document.querySelectorAll("[data-morph-out]").forEach((r) => {
|
|
428
432
|
r.classList.remove("out");
|
|
429
|
-
}),
|
|
433
|
+
}), R(document, "morphStart", {
|
|
430
434
|
detail: ct
|
|
431
435
|
});
|
|
432
|
-
const Nt = Array.from(document.head.children), Dt = Array.from(p.document.head.children), Ut = E(this, u, jt).call(this, Nt, Dt),
|
|
436
|
+
const Nt = Array.from(document.head.children), Dt = Array.from(p.document.head.children), Ut = E(this, u, jt).call(this, Nt, Dt), $t = E(this, u, Pt).call(this, Nt, Ut), ut = E(this, u, Pt).call(this, Dt, Ut).filter((r) => !this.excludeHeadChild(r));
|
|
433
437
|
ut.forEach((r, L) => {
|
|
434
438
|
r.tagName === "SCRIPT" && (ut[L] = E(this, u, bt).call(this, r));
|
|
435
439
|
}), ut.forEach((r) => {
|
|
@@ -444,28 +448,28 @@ const st = class st {
|
|
|
444
448
|
e(this, C).waitForHeadToLoad && gt.length && (yield new Promise((r) => W(this, null, function* () {
|
|
445
449
|
let L = 0;
|
|
446
450
|
try {
|
|
447
|
-
for (var b = Ft(gt),
|
|
451
|
+
for (var b = Ft(gt), Jt, F, N; Jt = !(F = yield b.next()).done; Jt = !1) {
|
|
448
452
|
const dt = F.value;
|
|
449
453
|
dt.onload = () => {
|
|
450
454
|
L++, L === gt.length && r();
|
|
451
455
|
};
|
|
452
456
|
}
|
|
453
457
|
} catch (F) {
|
|
454
|
-
|
|
458
|
+
N = [F];
|
|
455
459
|
} finally {
|
|
456
460
|
try {
|
|
457
|
-
|
|
461
|
+
Jt && (F = b.return) && (yield F.call(b));
|
|
458
462
|
} finally {
|
|
459
|
-
if (
|
|
460
|
-
throw
|
|
463
|
+
if (N)
|
|
464
|
+
throw N[0];
|
|
461
465
|
}
|
|
462
466
|
}
|
|
463
|
-
}))), yield
|
|
467
|
+
}))), yield re(10);
|
|
464
468
|
const qt = [];
|
|
465
|
-
|
|
469
|
+
$t.forEach((r) => {
|
|
466
470
|
r.hasAttribute("data-permanent") || (E(this, u, kt).call(this, r) ? qt.push(r) : r.remove());
|
|
467
471
|
});
|
|
468
|
-
const
|
|
472
|
+
const Gt = E(this, u, At).call(this, p.document.body);
|
|
469
473
|
!e(this, C).morphInsideScrollContainer && !f && E(this, u, Ct).call(this, p.document), document.documentElement.setAttribute(
|
|
470
474
|
"data-current-pathname",
|
|
471
475
|
c.pathname
|
|
@@ -480,25 +484,25 @@ const st = class st {
|
|
|
480
484
|
}), e(this, K).remove(), n(this, j, e(this, m)), n(this, m, c);
|
|
481
485
|
const St = [];
|
|
482
486
|
e(this, Z).forEach((r, L) => {
|
|
483
|
-
const b =
|
|
484
|
-
let F = [],
|
|
487
|
+
const b = Gt[L], Jt = getComputedStyle(r).getPropertyValue("--morph-duration");
|
|
488
|
+
let F = [], N = [];
|
|
485
489
|
f ? (f.forEach((d) => {
|
|
486
|
-
const v = r.querySelector(d),
|
|
487
|
-
v &&
|
|
488
|
-
}),
|
|
490
|
+
const v = r.querySelector(d), D = b.querySelector(d);
|
|
491
|
+
v && D && (N.push(v), F.push(D));
|
|
492
|
+
}), N.forEach((d) => {
|
|
489
493
|
d.parentElement && St.push(d.parentElement);
|
|
490
|
-
})) : (F.push(...b.childNodes),
|
|
494
|
+
})) : (F.push(...b.childNodes), N.push(...r.childNodes), St.push(r)), N.forEach((d) => {
|
|
491
495
|
d instanceof HTMLElement && (this.destroyOldLinks(d), d.classList.add("old"));
|
|
492
496
|
}), F.forEach((d) => {
|
|
493
497
|
d instanceof HTMLElement && (this.findNewLinks(d), d.classList.add("new"));
|
|
494
498
|
}), f ? F.forEach((d, v) => {
|
|
495
|
-
var
|
|
496
|
-
(
|
|
499
|
+
var D;
|
|
500
|
+
(D = N[v].parentElement) == null || D.insertBefore(
|
|
497
501
|
d,
|
|
498
|
-
|
|
502
|
+
N[v]
|
|
499
503
|
);
|
|
500
|
-
}) : r.prepend(...F),
|
|
501
|
-
|
|
504
|
+
}) : r.prepend(...F), ie(() => {
|
|
505
|
+
N.forEach((d) => {
|
|
502
506
|
d instanceof HTMLElement && d.classList.add("old-idle");
|
|
503
507
|
}), F.forEach((d) => {
|
|
504
508
|
var v;
|
|
@@ -511,40 +515,40 @@ const st = class st {
|
|
|
511
515
|
const dt = Lt(mt({}, ct), {
|
|
512
516
|
morphElement: r
|
|
513
517
|
});
|
|
514
|
-
|
|
518
|
+
R(document, "morphNewChildrenAdded", {
|
|
515
519
|
detail: dt
|
|
516
520
|
});
|
|
517
|
-
const
|
|
521
|
+
const Qt = new Promise((d) => {
|
|
518
522
|
setTimeout(() => {
|
|
519
|
-
|
|
520
|
-
var
|
|
521
|
-
v instanceof HTMLElement && ((
|
|
523
|
+
N.forEach((v) => v.remove()), F.forEach((v) => {
|
|
524
|
+
var D;
|
|
525
|
+
v instanceof HTMLElement && ((D = v.parentElement) == null || D.style.removeProperty(
|
|
522
526
|
"--new-content-height"
|
|
523
527
|
), v.classList.remove("new-idle", "new"));
|
|
524
|
-
}),
|
|
528
|
+
}), R(document, "morphOldChildrenRemoved", {
|
|
525
529
|
detail: dt
|
|
526
530
|
}), d();
|
|
527
|
-
}, (parseFloat(
|
|
531
|
+
}, (parseFloat(Jt) || 0) * 1e3 + 10);
|
|
528
532
|
});
|
|
529
|
-
e(this,
|
|
533
|
+
e(this, V).push(Qt);
|
|
530
534
|
}), this.isPopstateNavigation ? document.documentElement.style.setProperty(
|
|
531
535
|
"--new-document-scroll-position",
|
|
532
536
|
(this.scrollValue.top - p.scrollState.y) * 1 + "px"
|
|
533
537
|
) : document.documentElement.style.setProperty(
|
|
534
538
|
"--new-document-scroll-position",
|
|
535
539
|
this.scrollValue.top + "px"
|
|
536
|
-
),
|
|
540
|
+
), R(document, "morphBeforeNavigationScroll", {
|
|
537
541
|
detail: p.scrollState
|
|
538
542
|
}), c.hash ? (p.clearScrollState(), E(this, u, Ht).call(this, c.hash, {
|
|
539
543
|
centerScroll: i,
|
|
540
544
|
offsetScroll: h
|
|
541
|
-
})) : e(this,
|
|
545
|
+
})) : e(this, O) ? p.restoreScrollPosition() : H || p.renewScrollPosition(), yield Promise.all(e(this, V)), qt.forEach((r) => r.remove()), n(this, V, []), St.forEach((r) => {
|
|
542
546
|
r.querySelectorAll("script").forEach((b) => {
|
|
543
547
|
b.replaceWith(E(this, u, bt).call(this, b));
|
|
544
548
|
});
|
|
545
549
|
}), e(this, g).forEach((r) => {
|
|
546
550
|
r.checkCurrent(e(this, m).path);
|
|
547
|
-
}),
|
|
551
|
+
}), R(document, "morphComplete", {
|
|
548
552
|
detail: ct
|
|
549
553
|
}), document.documentElement.style.removeProperty(
|
|
550
554
|
"--new-document-scroll-position"
|
|
@@ -552,7 +556,7 @@ const st = class st {
|
|
|
552
556
|
} catch ($) {
|
|
553
557
|
console.error($);
|
|
554
558
|
}
|
|
555
|
-
n(this,
|
|
559
|
+
n(this, I, void 0);
|
|
556
560
|
});
|
|
557
561
|
}
|
|
558
562
|
addLink(t) {
|
|
@@ -584,7 +588,7 @@ const st = class st {
|
|
|
584
588
|
e(this, g).forEach((s) => s.destroy()), n(this, g, t.map((s) => new yt(s, this)));
|
|
585
589
|
}
|
|
586
590
|
};
|
|
587
|
-
C = new WeakMap(), Z = new WeakMap(), g = new WeakMap(),
|
|
591
|
+
C = new WeakMap(), Z = new WeakMap(), g = new WeakMap(), I = new WeakMap(), m = new WeakMap(), j = new WeakMap(), V = new WeakMap(), O = new WeakMap(), A = new WeakMap(), nt = new WeakMap(), x = new WeakMap(), K = new WeakMap(), _ = new WeakMap(), tt = new WeakMap(), at = new WeakMap(), u = new WeakSet(), bt = function(t) {
|
|
588
592
|
const s = document.createElement("script");
|
|
589
593
|
for (let i = 0; i < t.attributes.length; i++) {
|
|
590
594
|
const h = t.attributes[i];
|
|
@@ -593,8 +597,8 @@ C = new WeakMap(), Z = new WeakMap(), g = new WeakMap(), z = new WeakMap(), m =
|
|
|
593
597
|
return t.hasAttribute("src") || (s.innerHTML = t.innerHTML), s;
|
|
594
598
|
}, ot = new WeakMap(), ft = function(t) {
|
|
595
599
|
const s = this.normalizePath(t);
|
|
596
|
-
let i = e(this,
|
|
597
|
-
return i || (i = new Wt(this, s.pathname), e(this,
|
|
600
|
+
let i = e(this, x).get(s.pathname);
|
|
601
|
+
return i || (i = new Wt(this, s.pathname), e(this, x).set(s.pathname, i)), i;
|
|
598
602
|
}, At = function(t) {
|
|
599
603
|
const s = [...t.querySelectorAll("[data-morph]")];
|
|
600
604
|
return s.length ? s : [t];
|
|
@@ -620,7 +624,7 @@ C = new WeakMap(), Z = new WeakMap(), g = new WeakMap(), z = new WeakMap(), m =
|
|
|
620
624
|
), n(this, tt, 0), n(this, _, 0), n(this, A, e(this, C).scrollSelector && t.querySelector(e(this, C).scrollSelector) || window), n(this, nt, e(this, A) === window), (i = e(this, A)) == null || i.addEventListener("scroll", e(this, et)), e(this, et).call(this);
|
|
621
625
|
}, Ht = function(t, s) {
|
|
622
626
|
const i = typeof t == "string" ? document.getElementById(t) : t;
|
|
623
|
-
(typeof i == "number" || i) &&
|
|
627
|
+
(typeof i == "number" || i) && ne(i, {
|
|
624
628
|
scrollElement: e(this, A),
|
|
625
629
|
behavior: (s == null ? void 0 : s.behavior) || "instant",
|
|
626
630
|
center: s == null ? void 0 : s.centerScroll,
|