aptechka 0.72.8 → 0.73.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.
- package/lib/morph/Morph.d.ts +2 -1
- package/lib/morph/MorphLink.d.ts +1 -0
- package/lib/morph/index.cjs +1 -1
- package/lib/morph/index.js +478 -409
- package/package.json +1 -1
package/lib/morph/Morph.d.ts
CHANGED
|
@@ -36,6 +36,7 @@ export interface MorphNavigateOptions {
|
|
|
36
36
|
revalidate?: boolean;
|
|
37
37
|
keepSearchParameters?: boolean;
|
|
38
38
|
submorph?: Array<string>;
|
|
39
|
+
submorphAppend?: boolean;
|
|
39
40
|
clearState?: boolean;
|
|
40
41
|
keepScrollPosition?: boolean;
|
|
41
42
|
}
|
|
@@ -97,7 +98,7 @@ export declare class Morph {
|
|
|
97
98
|
prefetch(path: string, revalidate?: boolean): Promise<void>;
|
|
98
99
|
excludeHeadChild(child: Node): boolean;
|
|
99
100
|
setHeaders(path: string): void;
|
|
100
|
-
navigate(path: string, { historyAction, centerScroll, offsetScroll, scrollBehaviour, revalidate, keepSearchParameters, submorph, clearState, keepScrollPosition, }?: MorphNavigateOptions): Promise<void>;
|
|
101
|
+
navigate(path: string, { historyAction, centerScroll, offsetScroll, scrollBehaviour, revalidate, keepSearchParameters, submorph, submorphAppend, clearState, keepScrollPosition, }?: MorphNavigateOptions): Promise<void>;
|
|
101
102
|
addLink(element: HTMLAnchorElement): void;
|
|
102
103
|
addLinks(elements: Array<HTMLAnchorElement>): void;
|
|
103
104
|
removeLink(element: HTMLAnchorElement): void;
|
package/lib/morph/MorphLink.d.ts
CHANGED
package/lib/morph/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var te=Object.defineProperty,ee=Object.defineProperties;var se=Object.getOwnPropertyDescriptors;var Vt=Object.getOwnPropertySymbols;var ie=Object.prototype.hasOwnProperty,re=Object.prototype.propertyIsEnumerable;var Ot=(a,t)=>(t=Symbol[a])?t:Symbol.for("Symbol."+a),Ft=a=>{throw TypeError(a)};var Bt=(a,t,s)=>t in a?te(a,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):a[t]=s,ft=(a,t)=>{for(var s in t||(t={}))ie.call(t,s)&&Bt(a,s,t[s]);if(Vt)for(var s of Vt(t))re.call(t,s)&&Bt(a,s,t[s]);return a},wt=(a,t)=>ee(a,se(t));var yt=(a,t,s)=>t.has(a)||Ft("Cannot "+s);var e=(a,t,s)=>(yt(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)=>(yt(a,t,"write to private field"),i?i.call(a,s):t.set(a,s),s),E=(a,t,s)=>(yt(a,t,"access private method"),s);var F=(a,t,s)=>new Promise((i,h)=>{var v=f=>{try{b(s.next(f))}catch(H){h(H)}},y=f=>{try{b(s.throw(f))}catch(H){h(H)}},b=f=>f.done?i(f.value):Promise.resolve(f.value).then(v,y);b((s=s.apply(a,t)).next())});var Wt=(a,t,s)=>(t=a[Ot("asyncIterator")])?t.call(a):(a=a[Ot("iterator")](),t={},s=(i,h)=>(h=a[i])&&(t[i]=v=>new Promise((y,b,f)=>(v=h.call(a,v),f=v.done,Promise.resolve(v.value).then(H=>y({value:H,done:f}),b)))),s("next"),s("return"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const jt=require("../index-DekP7OZe.cjs"),R=require("../events-KVanG9sR.cjs"),ne=require("../polyfills-Df4r-ETT.cjs"),Xt=require("../scroll-CIdNtj3G.cjs");require("construct-style-sheets-polyfill");const st=require("../url-DGcX4fGV.cjs"),ae=require("../css-value-parser/index.cjs");class Kt 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)}}jt.isBrowser&&!customElements.get("morph-announcer")&&customElements.define("morph-announcer",Kt);var M,l,U,rt,G;class bt{constructor(t,s){o(this,M);o(this,l);o(this,U);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,U,e(this,l).getAttribute("href")||"/");const h=e(this,l).getAttribute("data-history-action")||"push",v=e(this,l).hasAttribute("data-center-scroll"),y=getComputedStyle(e(this,l)).getPropertyValue("--offset-scroll").trim(),b=y?ae.cssValueParser.parse(y):void 0,f=e(this,l).hasAttribute("data-revalidate"),H=e(this,l).hasAttribute("data-keep-search-parameters"),gt=e(this,l).hasAttribute("data-keep-scroll-position"),Gt=e(this,l).getAttribute("data-scroll-behaviour"),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,U),{historyAction:h,centerScroll:v,offsetScroll:b,revalidate:f,keepSearchParameters:H,submorph:ht,clearState:c,keepScrollPosition:gt,scrollBehaviour:Gt})}});o(this,G,()=>{const t=e(this,l).hasAttribute("data-revalidate");e(this,M).prefetch(e(this,U),t),e(this,l).removeEventListener("pointerenter",e(this,G))});n(this,M,s),n(this,l,t),n(this,U,e(this,l).getAttribute("href")||"/"),e(this,l).addEventListener("click",e(this,rt)),this.checkCurrent(location.href.replace(location.origin,"")),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,U));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"),s.path===i.path?e(this,l).classList.add("exact"):e(this,l).classList.remove("exact")}destroy(){e(this,l).removeEventListener("click",e(this,rt)),e(this,l).removeEventListener("pointerenter",e(this,G)),e(this,l).classList.remove("current","exact")}}M=new WeakMap,l=new WeakMap,U=new WeakMap,rt=new WeakMap,G=new WeakMap;const oe=new DOMParser;var T,W,w,k,X,D,J,Y,I,Q,nt;class Yt{constructor(t,s){o(this,T);o(this,W);o(this,w,{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,I,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,w)}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 F(this,null,function*(){return!i&&(e(this,I)||e(this,k)&&e(this,k).documentElement.hasAttribute("data-cache")&&e(this,Q)!==t||e(this,k)&&e(this,T).isPopstateNavigation)?e(this,I):(n(this,Q,t),n(this,I,new Promise(h=>F(this,null,function*(){try{n(this,Y,new AbortController);const y=yield(yield fetch(t,{signal:e(this,Y).signal,headers:ft({"X-MORPH":"true","X-MORPH-CURRENT-PATH":encodeURIComponent(s),"X-MORPH-NEW-PATH":encodeURIComponent(t)},e(this,nt))})).text(),b=oe.parseFromString(y,"text/html");this.setInitialDocument(b)}catch(v){console.warn(v)}finally{n(this,Y,null),n(this,I,null),h()}}))),e(this,I))})}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,w).x=0,e(this,w).y=0}clearDocumentState(){n(this,X,null)}saveScrollState(){e(this,k).documentElement.hasAttribute("data-no-scroll-restoration")?(e(this,w).x=0,e(this,w).y=0):(e(this,w).x=e(this,T).scrollValue.left,e(this,w).y=e(this,T).scrollValue.top)}restoreScrollPosition(){e(this,T).scrollElement.scroll({top:e(this,w).y,left:e(this,w).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,w=new WeakMap,k=new WeakMap,X=new WeakMap,D=new WeakMap,J=new WeakMap,Y=new WeakMap,I=new WeakMap,Q=new WeakMap,nt=new WeakMap;var C,Z,g,z,m,j,V,O,P,at,x,K,_,tt,ot,u,Pt,lt,pt,kt,$t,Ct,Ht,Rt,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,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=>F(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),R.dispatchEvent(document,"morphScroll",{detail:{left:t,top:s}})});if(jt.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,kt).call(this,document.body));const s=this.normalizePath(location.pathname+location.search+location.hash);n(this,m,s);const i=new Yt(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 Kt),E(this,u,Rt).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 F(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(Gt){return F(this,arguments,function*(t,{historyAction:s="push",centerScroll:i,offsetScroll:h,scrollBehaviour:v,revalidate:y,keepSearchParameters:b,submorph:f,clearState:H,keepScrollPosition:gt}={}){var ct,Tt,xt,Nt;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(e(this,g).forEach($=>{$.checkCurrent(c.path)}),!y&&(((Tt=e(this,z))==null?void 0:Tt.pathname)===c.pathname||e(this,m).pathname===c.pathname)){E(this,u,Mt).call(this,c.hash||0,{centerScroll:i,offsetScroll:h,behavior:"smooth"}),R.dispatchEvent(document,"morphSamePath",{custom:!0}),((xt=e(this,m))==null?void 0:xt.parameters)!==c.parameters&&(n(this,j,e(this,m)),n(this,m,c),st.changeHistory({action:((Nt=e(this,m))==null?void 0:Nt.hash)!==c.hash?"replace":s,pathname:c.pathname,searchParameters:c.parameters,hash:c.hash}),R.dispatchEvent(document,"morphURLParametersChange",{detail:{newURL:e(this,m),previousURL:e(this,j)}}));return}n(this,z,c);try{let $=!0;if(this.preprocessor)try{yield new Promise((r,S)=>{var A;(A=this.preprocessor)==null||A.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).path)});return}const qt={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,A;(S=r.firstElementChild)==null||S.classList.add("out"),(A=r.firstElementChild)==null||A.setAttribute("data-morph-out","")}),R.dispatchEvent(document,"morphNavigation",{detail:qt});const vt=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,y),e(this,z).pathname!==c.pathname){e(this,g).forEach(r=>{r.checkCurrent(e(this,m).path)});return}vt.clearState(),vt.saveScrollState(),vt.saveDocumentState(),e(this,O)||(p.clearScrollState(),p.clearDocumentState()),H&&p.clearState(),p.cloneDocument(),e(this,K).textContent=p.title,document.body.appendChild(e(this,K));const ut=wt(ft({},qt),{document:p.document});ut.document.querySelectorAll("[data-morph-out]").forEach(r=>{r.classList.remove("out")}),R.dispatchEvent(document,"morphStart",{detail:ut});const Ut=Array.from(document.head.children),Dt=Array.from(p.document.head.children),It=E(this,u,$t).call(this,Ut,Dt),Jt=E(this,u,Ct).call(this,Ut,It),dt=E(this,u,Ct).call(this,Dt,It).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 St=dt.filter(r=>{if(r.hasAttribute("data-no-waiting"))return!1;if(E(this,u,Ht).call(this,r))return!0});e(this,C).waitForHeadToLoad&&St.length&&(yield new Promise(r=>F(this,null,function*(){let S=0;try{for(var A=Wt(St),Zt,B,N;Zt=!(B=yield A.next()).done;Zt=!1){const mt=B.value;mt.onload=()=>{S++,S===St.length&&r()}}}catch(B){N=[B]}finally{try{Zt&&(B=A.return)&&(yield B.call(A))}finally{if(N)throw N[0]}}}))),yield Xt.wait(10);const zt=[];Jt.forEach(r=>{r.hasAttribute("data-permanent")||(E(this,u,Ht).call(this,r)?zt.push(r):r.remove())});const Qt=E(this,u,kt).call(this,p.document.body);!e(this,C).morphInsideScrollContainer&&!f&&E(this,u,Rt).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||(b?location.search:""),hash:c.hash}),e(this,K).remove(),n(this,j,e(this,m)),n(this,m,c);const Lt=[];e(this,Z).forEach((r,S)=>{const A=Qt[S],Zt=getComputedStyle(r).getPropertyValue("--morph-duration");let B=[],N=[];f?(f.forEach(d=>{const L=r.querySelector(d),q=A.querySelector(d);L&&q&&(N.push(L),B.push(q))}),N.forEach(d=>{d.parentElement&&Lt.push(d.parentElement)})):(B.push(...A.childNodes),N.push(...r.childNodes),Lt.push(r)),N.forEach(d=>{d instanceof HTMLElement&&(this.destroyOldLinks(d),d.classList.add("old"))}),B.forEach(d=>{d instanceof HTMLElement&&(this.findNewLinks(d),d.classList.add("new"))}),f?B.forEach((d,L)=>{var q;(q=N[L].parentElement)==null||q.insertBefore(d,N[L])}):r.prepend(...B),ne.requestIdleCallback(()=>{N.forEach(d=>{d instanceof HTMLElement&&d.classList.add("old-idle")}),B.forEach(d=>{var L;d instanceof HTMLElement&&((L=d.parentElement)==null||L.style.setProperty("--new-content-height",d.offsetHeight+"px"),d.classList.add("new-idle"))})});const mt=wt(ft({},ut),{morphElement:r});R.dispatchEvent(document,"morphNewChildrenAdded",{detail:mt});const _t=new Promise(d=>{setTimeout(()=>{N.forEach(L=>L.remove()),B.forEach(L=>{var q;L instanceof HTMLElement&&((q=L.parentElement)==null||q.style.removeProperty("--new-content-height"),L.classList.remove("new-idle","new"))}),R.dispatchEvent(document,"morphOldChildrenRemoved",{detail:mt}),d()},(parseFloat(Zt)||0)*1e3+10)});e(this,V).push(_t)}),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"),R.dispatchEvent(document,"morphBeforeNavigationScroll",{detail:p.scrollState}),c.hash?(p.clearScrollState(),E(this,u,Mt).call(this,c.hash,{centerScroll:i,offsetScroll:h,behavior:v})):e(this,O)?p.restoreScrollPosition():gt||p.renewScrollPosition(),yield Promise.all(e(this,V)),zt.forEach(r=>r.remove()),n(this,V,[]),Lt.forEach(r=>{r.querySelectorAll("script").forEach(A=>{A.replaceWith(E(this,u,Pt).call(this,A))})}),e(this,g).forEach(r=>{r.checkCurrent(e(this,m).path)}),R.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 bt(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 bt(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 bt(s,this)))}};C=new WeakMap,Z=new WeakMap,g=new WeakMap,z=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 Yt(this,s.pathname),e(this,x).set(s.pathname,i)),i},kt=function(t){const s=[...t.querySelectorAll("[data-morph]")];return s.length?s:[t]},$t=function(t,s){return t.filter(i=>s.find(h=>h.outerHTML===i.outerHTML))},Ct=function(t,s){return t.filter(i=>!s.find(h=>h.outerHTML===i.outerHTML))},Ht=function(t){return t.tagName==="SCRIPT"||t.tagName==="STYLE"||t.tagName==="LINK"&&t.getAttribute("rel")==="stylesheet"},Rt=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)&&Xt.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 At=it;exports.Morph=At;
|
|
1
|
+
"use strict";var se=Object.defineProperty,ae=Object.defineProperties;var ne=Object.getOwnPropertyDescriptors;var Wt=Object.getOwnPropertySymbols;var re=Object.prototype.hasOwnProperty,oe=Object.prototype.propertyIsEnumerable;var Xt=(o,e)=>(e=Symbol[o])?e:Symbol.for("Symbol."+o),jt=o=>{throw TypeError(o)};var Yt=(o,e,i)=>e in o?se(o,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):o[e]=i,gt=(o,e)=>{for(var i in e||(e={}))re.call(e,i)&&Yt(o,i,e[i]);if(Wt)for(var i of Wt(e))oe.call(e,i)&&Yt(o,i,e[i]);return o},At=(o,e)=>ae(o,ne(e));var Pt=(o,e,i)=>e.has(o)||jt("Cannot "+i);var t=(o,e,i)=>(Pt(o,e,"read from private field"),i?i.call(o):e.get(o)),l=(o,e,i)=>e.has(o)?jt("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(o):e.set(o,i),r=(o,e,i,s)=>(Pt(o,e,"write to private field"),s?s.call(o,i):e.set(o,i),i),p=(o,e,i)=>(Pt(o,e,"access private method"),i);var W=(o,e,i)=>new Promise((s,h)=>{var v=d=>{try{L(i.next(d))}catch(E){h(E)}},g=d=>{try{L(i.throw(d))}catch(E){h(E)}},L=d=>d.done?s(d.value):Promise.resolve(d.value).then(v,g);L((i=i.apply(o,e)).next())});var Kt=(o,e,i)=>(e=o[Xt("asyncIterator")])?e.call(o):(o=o[Xt("iterator")](),e={},i=(s,h)=>(h=o[s])&&(e[s]=v=>new Promise((g,L,d)=>(v=h.call(o,v),d=v.done,Promise.resolve(v.value).then(E=>g({value:E,done:d}),L)))),i("next"),i("return"),e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Jt=require("../index-DekP7OZe.cjs"),M=require("../events-KVanG9sR.cjs"),le=require("../polyfills-Df4r-ETT.cjs"),$t=require("../scroll-CIdNtj3G.cjs");require("construct-style-sheets-polyfill");const at=require("../url-DGcX4fGV.cjs"),he=require("../css-value-parser/index.cjs");class Qt extends HTMLElement{connectedCallback(){const e={"aria-live":"assertive","aria-atomic":"true",style:"position: absolute; left: 0; top: 0; clip: rect(0 0 0 0); clip-path: inset(50%); overflow: hidden; white-space: nowrap; width: 1px; height: 1px"};for(const[i,s]of Object.entries(e))this.setAttribute(i,s)}}Jt.isBrowser&&!customElements.get("morph-announcer")&&customElements.define("morph-announcer",Qt);var P,a,I,J,Et,rt,Q;class Ct{constructor(e,i){l(this,J);l(this,P);l(this,a);l(this,I);l(this,rt,e=>{var s;if(e.preventDefault(),document.documentElement.classList.contains("click-disabled"))return;if(t(this,a).hasAttribute("data-back")&&t(this,P).previousURL)history.back();else{r(this,I,t(this,a).getAttribute("href")||"/");const h=t(this,a).getAttribute("data-history-action")||"push",v=t(this,a).hasAttribute("data-center-scroll"),g=getComputedStyle(t(this,a)).getPropertyValue("--offset-scroll").trim(),L=g?he.cssValueParser.parse(g):void 0,d=t(this,a).hasAttribute("data-revalidate")||t(this,a).hasAttribute("data-pagination-more-link")||t(this,a).hasAttribute("data-pagination-set-link"),E=t(this,a).hasAttribute("data-keep-search-parameters"),bt=t(this,a).hasAttribute("data-keep-scroll-position")||t(this,a).hasAttribute("data-pagination-more-link"),Lt=t(this,a).getAttribute("data-scroll-behaviour"),ut=p(this,J,Et).call(this,t(this,a).getAttribute("data-pagination-set-link")||t(this,a).getAttribute("data-pagination-more-link"));ut&&(t(this,a).hasAttribute("data-pagination-set-link")?t(this,P).links.forEach(q=>{q.updatePagination(parseInt(t(this,a).getAttribute("data-value")||"1"),ut.selector)}):t(this,a).hasAttribute("data-pagination-more-link")&&t(this,P).links.forEach(q=>{q.updatePagination(ut.currentPage+1,ut.selector)}));const dt=((s=t(this,a).getAttribute("data-submorph"))==null?void 0:s.split(",").map(q=>q.trim()))||t(this,a).hasAttribute("data-pagination-more-link")&&[t(this,a).getAttribute("data-pagination-more-link")]||t(this,a).hasAttribute("data-pagination-set-link")&&[t(this,a).getAttribute("data-pagination-set-link")]||void 0,c=t(this,a).hasAttribute("data-clear-state");t(this,P).navigate(t(this,I),{historyAction:h,centerScroll:v,offsetScroll:L,revalidate:d,keepSearchParameters:E,submorph:dt,clearState:c,keepScrollPosition:bt,scrollBehaviour:Lt,submorphAppend:t(this,a).hasAttribute("data-pagination-more-link")})}});l(this,Q,()=>{const e=t(this,a).hasAttribute("data-revalidate");t(this,P).prefetch(t(this,I),e),t(this,a).removeEventListener("pointerenter",t(this,Q))});r(this,P,i),r(this,a,e),t(this,a).addEventListener("click",t(this,rt)),r(this,I,t(this,a).getAttribute("href")||"/"),this.checkCurrent(location.href.replace(location.origin,""));const s=p(this,J,Et).call(this,t(this,a).getAttribute("data-pagination-set-link")||t(this,a).getAttribute("data-pagination-more-link"));s&&this.updatePagination(s.currentPage,s.selector),t(this,a).hasAttribute("data-prefetch")&&t(this,a).addEventListener("pointerenter",t(this,Q))}get element(){return t(this,a)}checkCurrent(e){var h;const i=t(this,P).normalizePath(e),s=t(this,P).normalizePath(t(this,I));t(this,a).hasAttribute("data-include")&&i.pathname.includes(s.pathname)?t(this,a).classList.add("current"):s.pathname===i.pathname?t(this,a).classList.add("current"):(h=t(this,a).getAttribute("data-associated-paths"))!=null&&h.split(",").find(v=>i.pathname.includes(v))?t(this,a).classList.add("current"):t(this,a).classList.remove("current"),i.path===s.path?t(this,a).classList.add("exact"):t(this,a).classList.remove("exact")}updatePagination(e,i){const s=p(this,J,Et).call(this,i);if(s)if(s.element.setAttribute("data-current-page",e.toString()),t(this,a).hasAttribute("data-pagination-more-link"))if(e<s.totalPages){t(this,a).style.display="";const h=t(this,a).querySelector("[data-pagination-more-link-counter]");h&&(h.textContent=(s.totalPages-e).toString());const v=t(this,a).getAttribute("href"),g=new URL(v,window.location.origin);g.searchParams.set("page",(e+1).toString());const L=g.href.replace(g.origin,"").toString();t(this,a).setAttribute("href",L),this.checkCurrent(L)}else t(this,a).style.display="none";else t(this,a).hasAttribute("data-pagination-set-link")&&(t(this,a).getAttribute("data-value")===e.toString()?t(this,a).classList.add("pagination-current"):t(this,a).classList.remove("pagination-current"))}destroy(){t(this,a).removeEventListener("click",t(this,rt)),t(this,a).removeEventListener("pointerenter",t(this,Q)),t(this,a).classList.remove("current","exact","pagination-current")}}P=new WeakMap,a=new WeakMap,I=new WeakMap,J=new WeakSet,Et=function(e){if(!e)return;const i=document.querySelector(e);if(i){const s=parseInt(i.getAttribute("data-current-page")||"1"),h=parseInt(i.getAttribute("data-total-pages")||"1");return{element:i,currentPage:s,totalPages:h,selector:e}}},rt=new WeakMap,Q=new WeakMap;const ce=new DOMParser;var T,X,k,x,Y,z,Z,j,V,ot;class Gt{constructor(e,i){l(this,T);l(this,X);l(this,k,{x:0,y:0});l(this,x,null);l(this,Y,null);l(this,z,null);l(this,Z,null);l(this,j,null);l(this,V,null);l(this,ot);r(this,T,e),r(this,X,i)}get pathname(){return t(this,X)}get scrollState(){return t(this,k)}get document(){return t(this,z)}setHeaders(e){r(this,ot,e)}setInitialDocument(e){r(this,x,e.cloneNode(!0))}abort(){var e;return(e=t(this,j))==null?void 0:e.abort(`[${t(this,X)}] page loading cancelled`)}fetch(e,i,s){return W(this,null,function*(){var h;if(!s){const L=((h=t(this,x))==null?void 0:h.documentElement.getAttribute("data-cache"))&&i!==e,d=t(this,x)&&t(this,T).isPopstateNavigation;if(t(this,V)||L||d)return t(this,V)}return r(this,V,new Promise(v=>W(this,null,function*(){try{r(this,j,new AbortController);const L=yield(yield fetch(e,{signal:t(this,j).signal,headers:gt({"X-MORPH":"true","X-MORPH-CURRENT-PATH":encodeURIComponent(i),"X-MORPH-NEW-PATH":encodeURIComponent(e)},t(this,ot))})).text(),d=ce.parseFromString(L,"text/html");this.setInitialDocument(d)}catch(g){console.warn(g)}finally{r(this,j,null),r(this,V,null),v()}}))),t(this,V)})}cloneDocument(){r(this,z,(t(this,Y)||t(this,x)).cloneNode(!0))}get title(){let e="";if(t(this,z).title)e=t(this,z).title;else{const i=t(this,z).querySelector("h1");e=(i==null?void 0:i.innerText)||(i==null?void 0:i.textContent)||t(this,X)}return e}clearScrollState(){t(this,k).x=0,t(this,k).y=0}clearDocumentState(){r(this,Y,null)}saveScrollState(){t(this,x).documentElement.hasAttribute("data-no-scroll-restoration")?(t(this,k).x=0,t(this,k).y=0):(t(this,k).x=t(this,T).scrollValue.left,t(this,k).y=t(this,T).scrollValue.top)}restoreScrollPosition(){t(this,T).scrollElement.scroll({top:t(this,k).y,left:t(this,k).x,behavior:"instant"})}saveDocumentState(){t(this,x).documentElement.hasAttribute("data-no-page-restoration")?r(this,Y,null):r(this,Y,document.cloneNode(!0))}renewScrollPosition(){t(this,T).scrollElement.scroll({top:0,left:0,behavior:"instant"})}saveState(e){r(this,Z,e)}clearState(){const e=t(this,Z);return r(this,Z,null),e}}T=new WeakMap,X=new WeakMap,k=new WeakMap,x=new WeakMap,Y=new WeakMap,z=new WeakMap,Z=new WeakMap,j=new WeakMap,V=new WeakMap,ot=new WeakMap;var R,_,y,O,f,K,F,B,C,lt,N,$,tt,et,ht,it,m,Rt,ct,vt,Mt,Zt,Tt,xt,Nt,qt,St,st;const nt=class nt{constructor(e){l(this,m);l(this,R,null);l(this,_,null);l(this,y,[]);l(this,O);l(this,f,null);l(this,K);l(this,F,[]);l(this,B,!1);l(this,C,null);l(this,lt,!1);l(this,N,new Map);l(this,$,null);l(this,tt,0);l(this,et,0);l(this,ht);l(this,it);l(this,ct,e=>{var i;return((i=e.getAttribute("href"))==null?void 0:i.startsWith("/"))&&!e.hasAttribute("download")&&!e.hasAttribute("data-morph-skip")&&!e.closest("[data-morph-skip]")&&e.getAttribute("target")!=="_blank"});l(this,St,e=>W(this,null,function*(){e.preventDefault(),r(this,B,!0),yield this.navigate(location.href.replace(location.origin,""),{historyAction:"none",submorph:t(this,it)?void 0:t(this,ht),revalidate:t(this,it)}),r(this,B,!1)}));l(this,st,()=>{const{left:e,top:i}=this.scrollValue,s=i-t(this,et),h=e-t(this,tt);r(this,et,i),r(this,tt,e),document.documentElement.classList.toggle("scroll-y",i>0),document.documentElement.classList.toggle("scroll-x",e>0),document.documentElement.classList.toggle("scroll-y-forward",s>0),document.documentElement.classList.toggle("scroll-y-backward",s<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:e,top:i}})});if(Jt.isBrowser&&!nt.instance){nt.instance=this,r(this,R,{base:at.normalizeBase(e==null?void 0:e.base),waitForHeadToLoad:(e==null?void 0:e.waitForHeadToLoad)!==!1,trailingSlash:(e==null?void 0:e.trailingSlash)||!1,scrollSelector:e==null?void 0:e.scrollSelector,morphInsideScrollContainer:(e==null?void 0:e.morphInsideScrollContainer)||!1}),r(this,_,p(this,m,Mt).call(this,document.body));const i=this.normalizePath(location.pathname+location.search+location.hash);r(this,f,i);const s=new Gt(this,t(this,f).pathname);s.setInitialDocument(document),t(this,N).set(t(this,f).pathname,s),document.documentElement.setAttribute("data-current-pathname",t(this,f).pathname),document.documentElement.setAttribute("data-current-leaf",i.leaf),this.findLinks(),history.scrollRestoration="manual",addEventListener("popstate",t(this,St)),at.changeHistory({action:"replace",pathname:i.pathname,searchParameters:i.parameters,hash:i.hash}),r(this,$,new Qt),p(this,m,Nt).call(this,document)}}get currentURL(){return t(this,f)}get previousURL(){return t(this,K)}get links(){return t(this,y)}get scrollElement(){return t(this,C)}get isPopstateNavigation(){return t(this,B)}get scrollValue(){let e=0,i=0;return t(this,lt)?(e=window.scrollY,i=window.scrollX):(e=t(this,C).scrollTop,i=t(this,C).scrollLeft),{top:e,left:i}}saveState(e){const i=t(this,N).get(t(this,f).path);i&&i.saveState(e)}getState(){const e=t(this,N).get(t(this,f).path);return e==null?void 0:e.clearState()}normalizePath(e){return at.splitPath(e,{base:t(this,R).base,trailingSlash:t(this,R).trailingSlash})}prefetch(e,i){return W(this,null,function*(){var h;if(t(this,F).length)return;e=((h=this.pathnameModifier)==null?void 0:h.call(this,e))||e;const s=p(this,m,vt).call(this,e);s==null||s.fetch(e,t(this,f).path,i)})}excludeHeadChild(e){return!1}setHeaders(e){}navigate(ut){return W(this,arguments,function*(e,{historyAction:i="push",centerScroll:s,offsetScroll:h,scrollBehaviour:v,revalidate:g,keepSearchParameters:L,submorph:d,submorphAppend:E,clearState:bt,keepScrollPosition:Lt}={}){var q,Ut,Dt,It;if(t(this,F).length)return;r(this,ht,d),r(this,it,g);const dt=((q=this.pathnameModifier)==null?void 0:q.call(this,e))||e,c=this.normalizePath(dt);if(t(this,y).forEach(G=>{G.checkCurrent(c.path)}),!g&&(((Ut=t(this,O))==null?void 0:Ut.pathname)===c.pathname||t(this,f).pathname===c.pathname)){p(this,m,qt).call(this,c.hash||0,{centerScroll:s,offsetScroll:h,behavior:"smooth"}),M.dispatchEvent(document,"morphSamePath",{custom:!0}),((Dt=t(this,f))==null?void 0:Dt.parameters)!==c.parameters&&(r(this,K,t(this,f)),r(this,f,c),at.changeHistory({action:((It=t(this,f))==null?void 0:It.hash)!==c.hash?"replace":i,pathname:c.pathname,searchParameters:c.parameters,hash:c.hash}),M.dispatchEvent(document,"morphURLParametersChange",{detail:{newURL:t(this,f),previousURL:t(this,K)}}));return}r(this,O,c);try{let G=!0;if(this.preprocessor)try{yield new Promise((n,w)=>{var A;(A=this.preprocessor)==null||A.call(this,{url:c,resolve:n,reject:w,submorph:d})})}catch(n){n?console.error(n):console.log("Route change canceled"),G=!1}if(!G||t(this,O).pathname!==c.pathname){t(this,y).forEach(n=>{n.checkCurrent(t(this,f).path)});return}const zt={url:c,submorph:d};d?E||d.forEach(n=>{document.querySelectorAll(n).forEach(w=>{w.classList.add("out"),w.setAttribute("data-morph-out","")})}):t(this,_).forEach(n=>{var w,A;(w=n.firstElementChild)==null||w.classList.add("out"),(A=n.firstElementChild)==null||A.setAttribute("data-morph-out","")}),M.dispatchEvent(document,"morphNavigation",{detail:zt});const yt=p(this,m,vt).call(this,t(this,f).pathname),S=p(this,m,vt).call(this,c.pathname);if(t(this,N).forEach(n=>{n.pathname!==c.pathname&&n.abort()}),yield S==null?void 0:S.fetch(dt,t(this,f).path,g),t(this,O).pathname!==c.pathname){t(this,y).forEach(n=>{n.checkCurrent(t(this,f).path)});return}yt.clearState(),yt.saveScrollState(),yt.saveDocumentState(),(!t(this,B)||g)&&(S.clearScrollState(),S.clearDocumentState()),bt&&S.clearState(),S.cloneDocument(),t(this,$).textContent=S.title,document.body.appendChild(t(this,$));const mt=At(gt({},zt),{document:S.document});E||mt.document.querySelectorAll("[data-morph-out]").forEach(n=>{n.classList.remove("out")}),M.dispatchEvent(document,"morphStart",{detail:mt});const Vt=Array.from(document.head.children),Ot=Array.from(S.document.head.children),Ft=p(this,m,Zt).call(this,Vt,Ot),_t=p(this,m,Tt).call(this,Vt,Ft),ft=p(this,m,Tt).call(this,Ot,Ft).filter(n=>!this.excludeHeadChild(n));ft.forEach((n,w)=>{n.tagName==="SCRIPT"&&(ft[w]=p(this,m,Rt).call(this,n))}),ft.forEach(n=>{document.head.appendChild(n)});const wt=ft.filter(n=>{if(n.hasAttribute("data-no-waiting"))return!1;if(p(this,m,xt).call(this,n))return!0});t(this,R).waitForHeadToLoad&&wt.length&&(yield new Promise(n=>W(this,null,function*(){let w=0;try{for(var A=Kt(wt),ee,U,H;ee=!(U=yield A.next()).done;ee=!1){const pt=U.value;pt.onload=()=>{w++,w===wt.length&&n()}}}catch(U){H=[U]}finally{try{ee&&(U=A.return)&&(yield U.call(A))}finally{if(H)throw H[0]}}}))),yield $t.wait(10);const Bt=[];E||_t.forEach(n=>{n.hasAttribute("data-permanent")||(p(this,m,xt).call(this,n)?Bt.push(n):n.remove())});const te=p(this,m,Mt).call(this,S.document.body);!t(this,R).morphInsideScrollContainer&&!d&&p(this,m,Nt).call(this,S.document),document.documentElement.setAttribute("data-current-pathname",c.pathname),document.documentElement.setAttribute("data-current-leaf",c.leaf),at.changeHistory({action:i,pathname:c.pathname,searchParameters:c.parameters||(L?location.search:""),hash:c.hash}),t(this,$).remove(),r(this,K,t(this,f)),r(this,f,c);const kt=[];t(this,_).forEach((n,w)=>{const A=te[w],ee=getComputedStyle(n).getPropertyValue("--morph-duration");let U=[],H=[];d?(d.forEach(u=>{const b=n.querySelector(u),D=A.querySelector(u);b&&D&&(H.push(b),U.push(D))}),H.forEach(u=>{u.parentElement&&kt.push(u.parentElement)})):(U.push(...A.childNodes),H.push(...n.childNodes),kt.push(n)),E||H.forEach(u=>{u instanceof HTMLElement&&(this.destroyOldLinks(u),u.classList.add("old"))}),U.forEach(u=>{u instanceof HTMLElement&&(this.findNewLinks(u),u.classList.add("new"))}),d?E?U.forEach((u,b)=>{H[b]instanceof HTMLElement&&H[b].append(...u.childNodes)}):U.forEach((u,b)=>{var D;(D=H[b].parentElement)==null||D.insertBefore(u,H[b])}):n.prepend(...U),le.requestIdleCallback(()=>{E||H.forEach(u=>{u instanceof HTMLElement&&u.classList.add("old-idle")}),U.forEach(u=>{var b;u instanceof HTMLElement&&((b=u.parentElement)==null||b.style.setProperty("--new-content-height",u.offsetHeight+"px"),u.classList.add("new-idle"))})});const pt=At(gt({},mt),{morphElement:n});M.dispatchEvent(document,"morphNewChildrenAdded",{detail:pt});const ie=new Promise(u=>{setTimeout(()=>{E||H.forEach(b=>b.remove()),U.forEach(b=>{var D;b instanceof HTMLElement&&((D=b.parentElement)==null||D.style.removeProperty("--new-content-height"),b.classList.remove("new-idle","new"))}),E||M.dispatchEvent(document,"morphOldChildrenRemoved",{detail:pt}),u()},(parseFloat(ee)||0)*1e3+10)});t(this,F).push(ie)}),this.isPopstateNavigation?document.documentElement.style.setProperty("--new-document-scroll-position",(this.scrollValue.top-S.scrollState.y)*1+"px"):document.documentElement.style.setProperty("--new-document-scroll-position",this.scrollValue.top+"px"),M.dispatchEvent(document,"morphBeforeNavigationScroll",{detail:S.scrollState}),c.hash?(S.clearScrollState(),p(this,m,qt).call(this,c.hash,{centerScroll:s,offsetScroll:h,behavior:v})):t(this,B)?S.restoreScrollPosition():Lt||S.renewScrollPosition(),yield Promise.all(t(this,F)),E||Bt.forEach(n=>n.remove()),r(this,F,[]),kt.forEach(n=>{n.querySelectorAll("script").forEach(A=>{A.replaceWith(p(this,m,Rt).call(this,A))})}),t(this,y).forEach(n=>{n.checkCurrent(t(this,f).path)}),M.dispatchEvent(document,"morphComplete",{detail:mt}),document.documentElement.style.removeProperty("--new-document-scroll-position"),window.dispatchEvent(new Event("resize"))}catch(G){console.error(G)}r(this,O,void 0)})}addLink(e){t(this,y).push(new Ct(e,this))}addLinks(e){e.forEach(i=>{this.addLink(i)})}removeLink(e){r(this,y,t(this,y).filter(i=>i.element===e?(i.destroy(),!1):!0))}destroyOldLinks(e){r(this,y,t(this,y).filter(i=>e.contains(i.element)?(i.destroy(),!1):!0))}findNewLinks(e){const i=[...e.querySelectorAll("a")].filter(t(this,ct));t(this,y).push(...i.map(s=>new Ct(s,this)))}findLinks(){const e=[...document.documentElement.querySelectorAll("a")].filter(t(this,ct));t(this,y).forEach(i=>i.destroy()),r(this,y,e.map(i=>new Ct(i,this)))}};R=new WeakMap,_=new WeakMap,y=new WeakMap,O=new WeakMap,f=new WeakMap,K=new WeakMap,F=new WeakMap,B=new WeakMap,C=new WeakMap,lt=new WeakMap,N=new WeakMap,$=new WeakMap,tt=new WeakMap,et=new WeakMap,ht=new WeakMap,it=new WeakMap,m=new WeakSet,Rt=function(e){const i=document.createElement("script");for(let s=0;s<e.attributes.length;s++){const h=e.attributes[s];i.setAttribute(h.name,h.value)}return e.hasAttribute("src")||(i.innerHTML=e.innerHTML),i},ct=new WeakMap,vt=function(e){const i=this.normalizePath(e);let s=t(this,N).get(i.pathname);return s||(s=new Gt(this,i.pathname),t(this,N).set(i.pathname,s)),s},Mt=function(e){const i=[...e.querySelectorAll("[data-morph]")];return i.length?i:[e]},Zt=function(e,i){return e.filter(s=>i.find(h=>h.outerHTML===s.outerHTML))},Tt=function(e,i){return e.filter(s=>!i.find(h=>h.outerHTML===s.outerHTML))},xt=function(e){return e.tagName==="SCRIPT"||e.tagName==="STYLE"||e.tagName==="LINK"&&e.getAttribute("rel")==="stylesheet"},Nt=function(e){var i,s;(i=t(this,C))==null||i.removeEventListener("scroll",t(this,st)),r(this,et,0),r(this,tt,0),r(this,C,t(this,R).scrollSelector&&e.querySelector(t(this,R).scrollSelector)||window),r(this,lt,t(this,C)===window),(s=t(this,C))==null||s.addEventListener("scroll",t(this,st)),t(this,st).call(this)},qt=function(e,i){const s=typeof e=="string"?document.getElementById(e):e;(typeof s=="number"||s)&&$t.scrollToElement(s,{scrollElement:t(this,C),behavior:(i==null?void 0:i.behavior)||"instant",center:i==null?void 0:i.centerScroll,offset:i==null?void 0:i.offsetScroll})},St=new WeakMap,st=new WeakMap,nt.instance=null;let Ht=nt;exports.Morph=Ht;
|