aptechka 0.76.8 → 0.76.9
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/index.cjs +1 -1
- package/lib/morph/index.js +90 -87
- package/package.json +1 -1
package/lib/morph/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var ue=Object.defineProperty,de=Object.defineProperties;var me=Object.getOwnPropertyDescriptors;var Jt=Object.getOwnPropertySymbols;var fe=Object.prototype.hasOwnProperty,pe=Object.prototype.propertyIsEnumerable;var Qt=(h,e)=>(e=Symbol[h])?e:Symbol.for("Symbol."+h),_t=h=>{throw TypeError(h)};var Zt=(h,e,s)=>e in h?ue(h,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):h[e]=s,Rt=(h,e)=>{for(var s in e||(e={}))fe.call(e,s)&&Zt(h,s,e[s]);if(Jt)for(var s of Jt(e))pe.call(e,s)&&Zt(h,s,e[s]);return h},Dt=(h,e)=>de(h,me(e));var qt=(h,e,s)=>e.has(h)||_t("Cannot "+s);var t=(h,e,s)=>(qt(h,e,"read from private field"),s?s.call(h):e.get(h)),l=(h,e,s)=>e.has(h)?_t("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(h):e.set(h,s),o=(h,e,s,i)=>(qt(h,e,"write to private field"),i?i.call(h,s):e.set(h,s),s),E=(h,e,s)=>(qt(h,e,"access private method"),s);var G=(h,e,s)=>new Promise((i,n)=>{var S=c=>{try{g(s.next(c))}catch(v){n(v)}},p=c=>{try{g(s.throw(c))}catch(v){n(v)}},g=c=>c.done?i(c.value):Promise.resolve(c.value).then(S,p);g((s=s.apply(h,e)).next())});var te=(h,e,s)=>(e=h[Qt("asyncIterator")])?e.call(h):(h=h[Qt("iterator")](),e={},s=(i,n)=>(n=h[i])&&(e[i]=S=>new Promise((p,g,c)=>(S=n.call(h,S),c=S.done,Promise.resolve(S.value).then(v=>p({value:v,done:c}),g)))),s("next"),s("return"),e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ie=require("../index-DekP7OZe.cjs"),q=require("../events-KVanG9sR.cjs"),ee=require("../scroll-CIdNtj3G.cjs");require("construct-style-sheets-polyfill");const dt=require("../url-Dns-01WU.cjs"),ge=require("../css-value-parser/index.cjs"),Ee=require("../string-DUXXtU8v.cjs");class ae extends HTMLElement{connectedCallback(){const e={"aria-live":"assertive","aria-atomic":"true",style:"position: absolute; left: 0; top: 0; clip: rect(0 0 0 0); clip-path: inset(50%); overflow: hidden; white-space: nowrap; width: 1px; height: 1px"};for(const[s,i]of Object.entries(e))this.setAttribute(s,i)}}ie.isBrowser&&!customElements.get("morph-announcer")&&customElements.define("morph-announcer",ae);var H,a,U,st,Ht,ft,it;class It{constructor(e,s){l(this,st);l(this,H);l(this,a);l(this,U);l(this,ft,e=>{var i;if(e.preventDefault(),document.documentElement.classList.contains("click-disabled"))return;if(t(this,a).hasAttribute("data-back")&&t(this,H).previousURL)history.back();else{o(this,U,t(this,a).getAttribute("href")||"/");const n=t(this,a).getAttribute("data-history-action")||"push",S=t(this,a).hasAttribute("data-center-scroll"),p=getComputedStyle(t(this,a)).getPropertyValue("--offset-scroll").trim(),g=p?ge.cssValueParser.parse(p):void 0,c=t(this,a).hasAttribute("data-revalidate")||t(this,a).hasAttribute("data-pagination-more-link")||t(this,a).hasAttribute("data-pagination-set-link"),v=t(this,a).hasAttribute("data-keep-search-parameters"),D=t(this,a).hasAttribute("data-keep-scroll-position")||t(this,a).hasAttribute("data-pagination-more-link"),ut=t(this,a).getAttribute("data-scroll-behaviour"),et=E(this,st,Ht).call(this,t(this,a).getAttribute("data-pagination-set-link")||t(this,a).getAttribute("data-pagination-more-link"));et&&(t(this,a).hasAttribute("data-pagination-set-link")?t(this,H).links.forEach(T=>{T.updatePagination(parseInt(t(this,a).getAttribute("data-value")||"1"),et.selector)}):t(this,a).hasAttribute("data-pagination-more-link")&&t(this,H).links.forEach(T=>{T.updatePagination(et.currentPage+1,et.selector)}));const re=((i=t(this,a).getAttribute("data-submorph"))==null?void 0:i.split(",").map(T=>T.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,Pt=t(this,a).hasAttribute("data-clear-state");let u=t(this,U);if(t(this,a).hasAttribute("data-toggle-params")){const[T,wt]=t(this,U).split("?"),j=new URLSearchParams(wt),O=new URLSearchParams(location.search),A=new URLSearchParams;for(const[w]of j)(!O.has(w)||O.has(w)&&O.get(w)!==j.get(w))&&A.append(w,j.get(w));if(t(this,a).hasAttribute("data-merge-params"))for(const[w]of O)j.has(w)||A.append(w,O.get(w));u=`${T}?${A.toString()}`}t(this,H).navigate(u,{historyAction:n,centerScroll:S,offsetScroll:g,revalidate:c,keepSearchParameters:v,submorph:re,clearState:Pt,keepScrollPosition:D,scrollBehaviour:ut,submorphAppend:t(this,a).hasAttribute("data-pagination-more-link"),mergeParams:t(this,a).hasAttribute("data-merge-params")&&!t(this,a).hasAttribute("data-toggle-params")})}});l(this,it,()=>{const e=t(this,a).hasAttribute("data-revalidate");t(this,H).prefetch(t(this,U),e),t(this,a).removeEventListener("pointerenter",t(this,it))});o(this,H,s),o(this,a,e),t(this,a).addEventListener("click",t(this,ft)),o(this,U,t(this,a).getAttribute("href")||"/"),this.checkCurrent(location.href.replace(location.origin,""));const i=E(this,st,Ht).call(this,t(this,a).getAttribute("data-pagination-set-link")||t(this,a).getAttribute("data-pagination-more-link"));i&&this.updatePagination(i.currentPage,i.selector),t(this,a).hasAttribute("data-prefetch")&&t(this,a).addEventListener("pointerenter",t(this,it))}get element(){return t(this,a)}checkCurrent(e){var v;const s=t(this,H).normalizePath(e),i=t(this,H).normalizePath(t(this,U));t(this,a).hasAttribute("data-include")&&s.pathname.includes(i.pathname)?t(this,a).classList.add("current"):i.pathname===s.pathname?t(this,a).classList.add("current"):(v=t(this,a).getAttribute("data-associated-paths"))!=null&&v.split(",").find(D=>s.pathname.includes(D))?t(this,a).classList.add("current"):t(this,a).classList.remove("current"),s.path===i.path?t(this,a).classList.add("exact"):t(this,a).classList.remove("exact");const[n,S]=t(this,U).split("?"),p=new URLSearchParams(S),g=new URLSearchParams(location.search);let c=0;for(const[D]of g)p.has(D)&&g.get(D)===p.get(D)&&c++;c?(t(this,a).classList.toggle("all-params-matched",g.size===c),t(this,a).classList.toggle("some-params-matched",g.size!==c)):!g.size&&t(this,a).hasAttribute("data-match-no-params")?t(this,a).classList.add("all-params-matched"):(t(this,a).classList.remove("all-params-matched"),t(this,a).classList.remove("some-params-matched"))}updatePagination(e,s){const i=E(this,st,Ht).call(this,s);if(i)if(i.element.setAttribute("data-current-page",e.toString()),t(this,a).hasAttribute("data-pagination-more-link"))if(e<i.totalPages){t(this,a).style.display="";const n=t(this,a).querySelector("[data-pagination-more-link-counter]");n&&(n.textContent=(i.totalPages-e).toString());const S=t(this,a).getAttribute("href"),p=new URL(S,window.location.origin);p.searchParams.set("page",(e+1).toString());const g=p.href.replace(p.origin,"").toString();t(this,a).setAttribute("href",g),this.checkCurrent(g)}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,ft)),t(this,a).removeEventListener("pointerenter",t(this,it)),t(this,a).classList.remove("current","exact","pagination-current")}}H=new WeakMap,a=new WeakMap,U=new WeakMap,st=new WeakSet,Ht=function(e){if(!e)return;const s=document.querySelector(e);if(s){const i=parseInt(s.getAttribute("data-current-page")||"1"),n=parseInt(s.getAttribute("data-total-pages")||"1");return{element:s,currentPage:i,totalPages:n,selector:e}}},ft=new WeakMap,it=new WeakMap;const ve=new DOMParser;var I,J,k,z,Q,B,at,Z,X,pt;class se{constructor(e,s){l(this,I);l(this,J);l(this,k,{x:0,y:0});l(this,z,null);l(this,Q,null);l(this,B,null);l(this,at,null);l(this,Z,null);l(this,X,null);l(this,pt);o(this,I,e),o(this,J,s)}get pathname(){return t(this,J)}get scrollState(){return t(this,k)}get document(){return t(this,B)}setHeaders(e){o(this,pt,e)}setInitialDocument(e){o(this,z,e.cloneNode(!0))}abort(){var e;return(e=t(this,Z))==null?void 0:e.abort(`[${t(this,J)}] page loading cancelled`)}fetch(e,s,i){return G(this,null,function*(){var n;if(!i){const g=((n=t(this,z))==null?void 0:n.documentElement.getAttribute("data-cache"))&&s!==e,c=t(this,z)&&t(this,I).isPopstateNavigation;if(t(this,X)||g||c)return t(this,X)}return o(this,X,new Promise(S=>G(this,null,function*(){try{o(this,Z,new AbortController);const g=yield(yield fetch(e,{signal:t(this,Z).signal,headers:Rt({"X-MORPH":"true","X-MORPH-CURRENT-PATH":encodeURIComponent(s),"X-MORPH-NEW-PATH":encodeURIComponent(e)},t(this,pt))})).text(),c=ve.parseFromString(g,"text/html");this.setInitialDocument(c)}catch(p){console.warn(p)}finally{o(this,Z,null),o(this,X,null),S()}}))),t(this,X)})}cloneDocument(){o(this,B,(t(this,Q)||t(this,z)).cloneNode(!0))}get title(){let e="";if(t(this,B).title)e=t(this,B).title;else{const s=t(this,B).querySelector("h1");e=(s==null?void 0:s.innerText)||(s==null?void 0:s.textContent)||t(this,J)}return e}clearScrollState(){t(this,k).x=0,t(this,k).y=0}clearDocumentState(){o(this,Q,null)}saveScrollState(){t(this,z).documentElement.hasAttribute("data-no-scroll-restoration")?(t(this,k).x=0,t(this,k).y=0):(t(this,k).x=t(this,I).scrollValue.left,t(this,k).y=t(this,I).scrollValue.top)}restoreScrollPosition(){t(this,I).scrollElement.scroll({top:t(this,k).y,left:t(this,k).x,behavior:"instant"})}saveDocumentState(){t(this,z).documentElement.hasAttribute("data-no-page-restoration")?o(this,Q,null):o(this,Q,document.cloneNode(!0))}renewScrollPosition(){t(this,I).scrollElement.scroll({top:0,left:0,behavior:"instant"})}saveState(e){o(this,at,e)}clearState(){const e=t(this,at);return o(this,at,null),e}}I=new WeakMap,J=new WeakMap,k=new WeakMap,z=new WeakMap,Q=new WeakMap,B=new WeakMap,at=new WeakMap,Z=new WeakMap,X=new WeakMap,pt=new WeakMap;var C,nt,gt,zt,Et;class Se{constructor(e){l(this,gt);l(this,C);l(this,nt,[]);l(this,Et,()=>{E(this,gt,zt).call(this)});o(this,C,e);for(const s in t(this,C).dataset){const i=Ee.camelToKebab(s);if(i.startsWith("param-")){const n=i.split("param-")[1],S=t(this,C).dataset[s];t(this,nt).push({name:n,value:S})}}document.addEventListener("morphURLParametersChange",t(this,Et)),E(this,gt,zt).call(this)}destroy(){document.removeEventListener("morphURLParametersChange",t(this,Et))}}C=new WeakMap,nt=new WeakMap,gt=new WeakSet,zt=function(){const e=new URLSearchParams(location.search);let s=!!t(this,nt).find(n=>e.has(n.name)&&(e.get(n.name)===n.value||n.value==="*"||n.value==="all"||n.value==="any"||n.value==="vse"||e.get(n.name)==="*"||e.get(n.name)==="all"||e.get(n.name)==="any"||e.get(n.name)==="vse"));!s&&t(this,C).hasAttribute("data-match-no-params")&&(s=!t(this,nt).filter(n=>e.has(n.name)).length);const i=t(this,C).getAttribute("data-hide-class");s?i?t(this,C).classList.remove(i):t(this,C).style.display="":i?t(this,C).classList.add(i):t(this,C).style.display="none"},Et=new WeakMap;var N,rt,y,K,f,_,Y,$,M,vt,V,St,tt,ot,ht,Lt,lt,bt,m,Ot,yt,Mt,Wt,ne,Ft,Bt,Xt,Kt,Tt,ct;const mt=class mt{constructor(e){l(this,m);l(this,N,null);l(this,rt,null);l(this,y,[]);l(this,K);l(this,f,null);l(this,_);l(this,Y,[]);l(this,$,!1);l(this,M,null);l(this,vt,!1);l(this,V,new Map);l(this,St,[]);l(this,tt,null);l(this,ot,0);l(this,ht,0);l(this,Lt);l(this,lt);l(this,bt);l(this,yt,e=>{var s;return((s=e.getAttribute("href"))==null?void 0:s.startsWith("/"))&&!e.hasAttribute("download")&&!e.hasAttribute("data-morph-skip")&&!e.closest("[data-morph-skip]")&&e.getAttribute("target")!=="_blank"});l(this,Tt,e=>G(this,null,function*(){e.preventDefault(),o(this,$,!0),yield this.navigate(location.href.replace(location.origin,""),{historyAction:"none",submorph:t(this,lt)?void 0:t(this,Lt),revalidate:t(this,lt),keepScrollPosition:t(this,bt)}),o(this,$,!1)}));l(this,ct,()=>{const{left:e,top:s}=this.scrollValue,i=s-t(this,ht),n=e-t(this,ot);o(this,ht,s),o(this,ot,e),document.documentElement.classList.toggle("scroll-y",s>0),document.documentElement.classList.toggle("scroll-x",e>0),document.documentElement.classList.toggle("scroll-y-forward",i>0),document.documentElement.classList.toggle("scroll-y-backward",i<0),document.documentElement.classList.toggle("scroll-x-forward",n>0),document.documentElement.classList.toggle("scroll-x-backward",n<0),q.dispatchEvent(document,"morphScroll",{detail:{left:e,top:s}})});if(ie.isBrowser&&!mt.instance){mt.instance=this,o(this,N,{base:dt.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}),o(this,rt,E(this,m,Wt).call(this,document.body));const s=this.normalizePath(location.pathname+location.search+location.hash);o(this,f,s);const i=new se(this,t(this,f).pathname);i.setInitialDocument(document),t(this,V).set(t(this,f).pathname,i),document.documentElement.setAttribute("data-current-pathname",t(this,f).pathname),document.documentElement.setAttribute("data-current-leaf",s.leaf),this.findLinks(),this.findParamsDependent(),history.scrollRestoration="manual",addEventListener("popstate",t(this,Tt)),dt.changeHistory({action:"replace",pathname:s.pathname,searchParameters:s.parameters,hash:s.hash}),o(this,tt,new ae),E(this,m,Xt).call(this,document)}}get currentURL(){return t(this,f)}get previousURL(){return t(this,_)}get links(){return t(this,y)}get scrollElement(){return t(this,M)}get isPopstateNavigation(){return t(this,$)}get scrollValue(){let e=0,s=0;return t(this,vt)?(e=window.scrollY,s=window.scrollX):(e=t(this,M).scrollTop,s=t(this,M).scrollLeft),{top:e,left:s}}saveState(e){const s=t(this,V).get(t(this,f).path);s&&s.saveState(e)}getState(){const e=t(this,V).get(t(this,f).path);return e==null?void 0:e.clearState()}normalizePath(e,s){return dt.splitPath(e,{base:t(this,N).base,trailingSlash:t(this,N).trailingSlash,mergeParams:s!=null&&s.mergeParams?location.search:""})}prefetch(e,s){return G(this,null,function*(){var n;if(t(this,Y).length)return;e=((n=this.pathnameModifier)==null?void 0:n.call(this,e))||e;const i=E(this,m,Mt).call(this,e);i==null||i.fetch(e,t(this,f).path,s)})}excludeHeadChild(e){return!1}setHeaders(e){}navigate(re){return G(this,arguments,function*(e,{historyAction:s="push",centerScroll:i,offsetScroll:n,scrollBehaviour:S,revalidate:p,keepSearchParameters:g,submorph:c,submorphAppend:v,clearState:D,keepScrollPosition:ut,mergeParams:et}={}){var T,wt,j,O;if(t(this,Y).length)return;o(this,Lt,c),o(this,lt,p),o(this,bt,ut);const Pt=((T=this.pathnameModifier)==null?void 0:T.call(this,e))||e,u=this.normalizePath(Pt,{mergeParams:et});if(!p&&(((wt=t(this,K))==null?void 0:wt.pathname)===u.pathname||t(this,f).pathname===u.pathname)){ut||E(this,m,Kt).call(this,u.hash||0,{centerScroll:i,offsetScroll:n,behavior:"smooth"}),q.dispatchEvent(document,"morphSamePath",{custom:!0}),((j=t(this,f))==null?void 0:j.parameters)!==u.parameters&&(o(this,_,t(this,f)),o(this,f,u),dt.changeHistory({action:((O=t(this,f))==null?void 0:O.hash)!==u.hash?"replace":s,pathname:u.pathname,searchParameters:u.parameters,hash:u.hash}),q.dispatchEvent(document,"morphURLParametersChange",{detail:{newURL:t(this,f),previousURL:t(this,_)}})),t(this,y).forEach(A=>{A.checkCurrent(u.path)});return}else t(this,y).forEach(A=>{A.checkCurrent(u.path)});o(this,K,u);try{let A=!0;if(this.preprocessor)try{yield new Promise((r,P)=>{var R;(R=this.preprocessor)==null||R.call(this,{url:u,resolve:r,reject:P,submorph:c})})}catch(r){r?console.error(r):console.log("Route change canceled"),A=!1}if(!A||t(this,K).pathname!==u.pathname){t(this,y).forEach(r=>{r.checkCurrent(t(this,f).path)});return}const w={url:u,submorph:c};c?v||c.forEach(r=>{document.querySelectorAll(r).forEach(P=>{P.classList.add("out"),P.setAttribute("data-morph-out","")})}):t(this,rt).forEach(r=>{var P,R;(P=r.firstElementChild)==null||P.classList.add("out"),(R=r.firstElementChild)==null||R.setAttribute("data-morph-out","")}),q.dispatchEvent(document,"morphNavigation",{detail:w});const xt=E(this,m,Mt).call(this,t(this,f).pathname),L=E(this,m,Mt).call(this,u.pathname);if(t(this,V).forEach(r=>{r.pathname!==u.pathname&&r.abort()}),yield L==null?void 0:L.fetch(Pt,t(this,f).path,p),t(this,K).pathname!==u.pathname){t(this,y).forEach(r=>{r.checkCurrent(t(this,f).path)});return}xt.clearState(),xt.saveScrollState(),xt.saveDocumentState(),(!t(this,$)||p)&&(L.clearScrollState(),L.clearDocumentState()),D&&L.clearState(),L.cloneDocument(),t(this,tt).textContent=L.title,document.body.appendChild(t(this,tt));const At=Dt(Rt({},w),{document:L.document});v||At.document.querySelectorAll("[data-morph-out]").forEach(r=>{r.classList.remove("out")}),q.dispatchEvent(document,"morphStart",{detail:At});const Yt=Array.from(document.head.children),$t=Array.from(L.document.head.children),jt=E(this,m,ne).call(this,Yt,$t),oe=E(this,m,Ft).call(this,Yt,jt),kt=E(this,m,Ft).call(this,$t,jt).filter(r=>!this.excludeHeadChild(r));kt.forEach((r,P)=>{r.tagName==="SCRIPT"&&(kt[P]=E(this,m,Ot).call(this,r))}),kt.forEach(r=>{document.head.appendChild(r)});const Ut=kt.filter(r=>{if(r.hasAttribute("data-no-waiting"))return!1;if(E(this,m,Bt).call(this,r))return!0});t(this,N).waitForHeadToLoad&&Ut.length&&(yield new Promise(r=>G(this,null,function*(){let P=0;try{for(var R=te(Ut),le,W,x;le=!(W=yield R.next()).done;le=!1){const Ct=W.value;Ct.onload=()=>{P++,P===Ut.length&&r()}}}catch(W){x=[W]}finally{try{le&&(W=R.return)&&(yield W.call(R))}finally{if(x)throw x[0]}}}))),yield ee.wait(10);const Gt=[];v||oe.forEach(r=>{r.hasAttribute("data-permanent")||(E(this,m,Bt).call(this,r)?Gt.push(r):r.remove())});const he=E(this,m,Wt).call(this,L.document.body);!t(this,N).morphInsideScrollContainer&&!c&&E(this,m,Xt).call(this,L.document),document.documentElement.setAttribute("data-current-pathname",u.pathname),document.documentElement.setAttribute("data-current-leaf",u.leaf),dt.changeHistory({action:s,pathname:u.pathname,searchParameters:u.parameters||(g?location.search:""),hash:u.hash}),t(this,tt).remove(),o(this,_,t(this,f)),o(this,f,u);const Nt=[];t(this,rt).forEach((r,P)=>{const R=he[P],le=getComputedStyle(r).getPropertyValue("--morph-duration");let W=[],x=[];c?(c.forEach(d=>{const b=r.querySelector(d),F=R.querySelector(d);b&&F&&(x.push(b),W.push(F))}),x.forEach(d=>{d.parentElement&&Nt.push(d.parentElement)})):(W.push(...R.childNodes),x.push(...r.childNodes),Nt.push(r)),v||x.forEach(d=>{d instanceof HTMLElement&&(this.destroyOldLinks(d),d.classList.add("old"))}),W.forEach(d=>{d instanceof HTMLElement&&(this.findNewLinks(d),d.classList.add("new"))}),c?v?W.forEach((d,b)=>{x[b]instanceof HTMLElement&&x[b].append(...d.childNodes)}):W.forEach((d,b)=>{var F;(F=x[b].parentElement)==null||F.insertBefore(d,x[b])}):r.prepend(...W),setTimeout(()=>{v||x.forEach(d=>{d instanceof HTMLElement&&d.classList.add("old-idle")}),W.forEach(d=>{var b;d instanceof HTMLElement&&((b=d.parentElement)==null||b.style.setProperty("--new-content-height",d.offsetHeight+"px"),d.classList.add("new-idle"))})},0);const Ct=Dt(Rt({},At),{morphElement:r});q.dispatchEvent(document,"morphNewChildrenAdded",{detail:Ct});const ce=new Promise(d=>{setTimeout(()=>{v||x.forEach(b=>b.remove()),W.forEach(b=>{var F;b instanceof HTMLElement&&((F=b.parentElement)==null||F.style.removeProperty("--new-content-height"),b.classList.remove("new-idle","new"))}),v||q.dispatchEvent(document,"morphOldChildrenRemoved",{detail:Ct}),d()},(parseFloat(le)||0)*1e3+10)});t(this,Y).push(ce)}),this.isPopstateNavigation?document.documentElement.style.setProperty("--new-document-scroll-position",(this.scrollValue.top-L.scrollState.y)*1+"px"):document.documentElement.style.setProperty("--new-document-scroll-position",this.scrollValue.top+"px"),q.dispatchEvent(document,"morphBeforeNavigationScroll",{detail:L.scrollState}),u.hash?(L.clearScrollState(),E(this,m,Kt).call(this,u.hash,{centerScroll:i,offsetScroll:n,behavior:S})):t(this,$)?L.restoreScrollPosition():ut||L.renewScrollPosition(),yield Promise.all(t(this,Y)),v||Gt.forEach(r=>r.remove()),o(this,Y,[]),Nt.forEach(r=>{r.querySelectorAll("script").forEach(R=>{R.replaceWith(E(this,m,Ot).call(this,R))})}),t(this,y).forEach(r=>{r.checkCurrent(t(this,f).path)}),this.findParamsDependent(),q.dispatchEvent(document,"morphComplete",{detail:At}),document.documentElement.style.removeProperty("--new-document-scroll-position"),window.dispatchEvent(new Event("resize"))}catch(A){console.error(A)}o(this,K,void 0)})}addLink(e){t(this,y).push(new It(e,this))}addLinks(e){e.forEach(s=>{this.addLink(s)})}removeLink(e){o(this,y,t(this,y).filter(s=>s.element===e?(s.destroy(),!1):!0))}destroyOldLinks(e){o(this,y,t(this,y).filter(s=>e.contains(s.element)?(s.destroy(),!1):!0))}findNewLinks(e){const s=[...e.querySelectorAll("a")].filter(t(this,yt));t(this,y).push(...s.map(i=>new It(i,this)))}findLinks(){const e=[...document.documentElement.querySelectorAll("a")].filter(t(this,yt));t(this,y).forEach(s=>s.destroy()),o(this,y,e.map(s=>new It(s,this)))}findParamsDependent(){const e=[...document.documentElement.querySelectorAll("[data-morph-params-dependent]")];t(this,St).forEach(s=>s.destroy()),o(this,St,e.map(s=>new Se(s)))}};N=new WeakMap,rt=new WeakMap,y=new WeakMap,K=new WeakMap,f=new WeakMap,_=new WeakMap,Y=new WeakMap,$=new WeakMap,M=new WeakMap,vt=new WeakMap,V=new WeakMap,St=new WeakMap,tt=new WeakMap,ot=new WeakMap,ht=new WeakMap,Lt=new WeakMap,lt=new WeakMap,bt=new WeakMap,m=new WeakSet,Ot=function(e){const s=document.createElement("script");for(let i=0;i<e.attributes.length;i++){const n=e.attributes[i];s.setAttribute(n.name,n.value)}return e.hasAttribute("src")||(s.innerHTML=e.innerHTML),s},yt=new WeakMap,Mt=function(e){const s=this.normalizePath(e);let i=t(this,V).get(s.pathname);return i||(i=new se(this,s.pathname),t(this,V).set(s.pathname,i)),i},Wt=function(e){const s=[...e.querySelectorAll("[data-morph]")];return s.length?s:[e]},ne=function(e,s){return e.filter(i=>s.find(n=>n.outerHTML===i.outerHTML))},Ft=function(e,s){return e.filter(i=>!s.find(n=>n.outerHTML===i.outerHTML))},Bt=function(e){return e.tagName==="SCRIPT"||e.tagName==="STYLE"||e.tagName==="LINK"&&e.getAttribute("rel")==="stylesheet"},Xt=function(e){var s,i;(s=t(this,M))==null||s.removeEventListener("scroll",t(this,ct)),o(this,ht,0),o(this,ot,0),o(this,M,t(this,N).scrollSelector&&e.querySelector(t(this,N).scrollSelector)||window),o(this,vt,t(this,M)===window),(i=t(this,M))==null||i.addEventListener("scroll",t(this,ct)),t(this,ct).call(this)},Kt=function(e,s){const i=typeof e=="string"?document.getElementById(e):e;(typeof i=="number"||i)&&ee.scrollToElement(i,{scrollElement:t(this,M),behavior:(s==null?void 0:s.behavior)||"instant",center:s==null?void 0:s.centerScroll,offset:s==null?void 0:s.offsetScroll})},Tt=new WeakMap,ct=new WeakMap,mt.instance=null;let Vt=mt;exports.Morph=Vt;
|
|
1
|
+
"use strict";var de=Object.defineProperty,ue=Object.defineProperties;var me=Object.getOwnPropertyDescriptors;var Jt=Object.getOwnPropertySymbols;var fe=Object.prototype.hasOwnProperty,pe=Object.prototype.propertyIsEnumerable;var Qt=(h,e)=>(e=Symbol[h])?e:Symbol.for("Symbol."+h),_t=h=>{throw TypeError(h)};var Zt=(h,e,s)=>e in h?de(h,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):h[e]=s,Rt=(h,e)=>{for(var s in e||(e={}))fe.call(e,s)&&Zt(h,s,e[s]);if(Jt)for(var s of Jt(e))pe.call(e,s)&&Zt(h,s,e[s]);return h},Dt=(h,e)=>ue(h,me(e));var qt=(h,e,s)=>e.has(h)||_t("Cannot "+s);var t=(h,e,s)=>(qt(h,e,"read from private field"),s?s.call(h):e.get(h)),l=(h,e,s)=>e.has(h)?_t("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(h):e.set(h,s),o=(h,e,s,i)=>(qt(h,e,"write to private field"),i?i.call(h,s):e.set(h,s),s),E=(h,e,s)=>(qt(h,e,"access private method"),s);var G=(h,e,s)=>new Promise((i,n)=>{var L=c=>{try{g(s.next(c))}catch(v){n(v)}},p=c=>{try{g(s.throw(c))}catch(v){n(v)}},g=c=>c.done?i(c.value):Promise.resolve(c.value).then(L,p);g((s=s.apply(h,e)).next())});var te=(h,e,s)=>(e=h[Qt("asyncIterator")])?e.call(h):(h=h[Qt("iterator")](),e={},s=(i,n)=>(n=h[i])&&(e[i]=L=>new Promise((p,g,c)=>(L=n.call(h,L),c=L.done,Promise.resolve(L.value).then(v=>p({value:v,done:c}),g)))),s("next"),s("return"),e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ie=require("../index-DekP7OZe.cjs"),q=require("../events-KVanG9sR.cjs"),ee=require("../scroll-CIdNtj3G.cjs");require("construct-style-sheets-polyfill");const ut=require("../url-Dns-01WU.cjs"),ge=require("../css-value-parser/index.cjs"),Ee=require("../string-DUXXtU8v.cjs");class ae extends HTMLElement{connectedCallback(){const e={"aria-live":"assertive","aria-atomic":"true",style:"position: absolute; left: 0; top: 0; clip: rect(0 0 0 0); clip-path: inset(50%); overflow: hidden; white-space: nowrap; width: 1px; height: 1px"};for(const[s,i]of Object.entries(e))this.setAttribute(s,i)}}ie.isBrowser&&!customElements.get("morph-announcer")&&customElements.define("morph-announcer",ae);var k,a,H,st,Ht,ft,it;class zt{constructor(e,s){l(this,H);l(this,k);l(this,a);l(this,ft,e=>{var i;if(e.preventDefault(),document.documentElement.classList.contains("click-disabled"))return;if(t(this,a).hasAttribute("data-back")&&t(this,k).previousURL)history.back();else{const n=t(this,a).getAttribute("data-history-action")||"push",L=t(this,a).hasAttribute("data-center-scroll"),p=getComputedStyle(t(this,a)).getPropertyValue("--offset-scroll").trim(),g=p?ge.cssValueParser.parse(p):void 0,c=t(this,a).hasAttribute("data-revalidate")||t(this,a).hasAttribute("data-pagination-more-link")||t(this,a).hasAttribute("data-pagination-set-link"),v=t(this,a).hasAttribute("data-keep-search-parameters"),D=t(this,a).hasAttribute("data-keep-scroll-position")||t(this,a).hasAttribute("data-pagination-more-link"),dt=t(this,a).getAttribute("data-scroll-behaviour"),et=E(this,H,Ht).call(this,t(this,a).getAttribute("data-pagination-set-link")||t(this,a).getAttribute("data-pagination-more-link"));et&&(t(this,a).hasAttribute("data-pagination-set-link")?t(this,k).links.forEach(U=>{U.updatePagination(parseInt(t(this,a).getAttribute("data-value")||"1"),et.selector)}):t(this,a).hasAttribute("data-pagination-more-link")&&t(this,k).links.forEach(U=>{U.updatePagination(et.currentPage+1,et.selector)}));const re=((i=t(this,a).getAttribute("data-submorph"))==null?void 0:i.split(",").map(U=>U.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,Pt=t(this,a).hasAttribute("data-clear-state");let d=t(this,H,st);if(t(this,a).hasAttribute("data-toggle-params")){const[U,wt]=t(this,H,st).split("?"),j=new URLSearchParams(wt),W=new URLSearchParams(location.search),A=new URLSearchParams;for(const[w]of j)(!W.has(w)||W.has(w)&&W.get(w)!==j.get(w))&&A.append(w,j.get(w));if(t(this,a).hasAttribute("data-merge-params"))for(const[w]of W)j.has(w)||A.append(w,W.get(w));d=`${U}?${A.toString()}`}t(this,k).navigate(d,{historyAction:n,centerScroll:L,offsetScroll:g,revalidate:c,keepSearchParameters:v,submorph:re,clearState:Pt,keepScrollPosition:D,scrollBehaviour:dt,submorphAppend:t(this,a).hasAttribute("data-pagination-more-link"),mergeParams:t(this,a).hasAttribute("data-merge-params")&&!t(this,a).hasAttribute("data-toggle-params")})}});l(this,it,()=>{const e=t(this,a).hasAttribute("data-revalidate");t(this,k).prefetch(t(this,H,st),e),t(this,a).removeEventListener("pointerenter",t(this,it))});o(this,k,s),o(this,a,e),t(this,a).addEventListener("click",t(this,ft)),this.checkCurrent(location.href.replace(location.origin,""));const i=E(this,H,Ht).call(this,t(this,a).getAttribute("data-pagination-set-link")||t(this,a).getAttribute("data-pagination-more-link"));i&&this.updatePagination(i.currentPage,i.selector),t(this,a).hasAttribute("data-prefetch")&&t(this,a).addEventListener("pointerenter",t(this,it))}get element(){return t(this,a)}checkCurrent(e){var v;const s=t(this,k).normalizePath(e),i=t(this,k).normalizePath(t(this,H,st));t(this,a).hasAttribute("data-include")&&s.pathname.includes(i.pathname)?t(this,a).classList.add("current"):i.pathname===s.pathname?t(this,a).classList.add("current"):(v=t(this,a).getAttribute("data-associated-paths"))!=null&&v.split(",").find(D=>s.pathname.includes(D))?t(this,a).classList.add("current"):t(this,a).classList.remove("current"),s.path===i.path?t(this,a).classList.add("exact"):t(this,a).classList.remove("exact");const[n,L]=t(this,H,st).split("?"),p=new URLSearchParams(L),g=new URLSearchParams(location.search);let c=0;for(const[D]of g)p.has(D)&&g.get(D)===p.get(D)&&c++;c?(t(this,a).classList.toggle("all-params-matched",g.size===c),t(this,a).classList.toggle("some-params-matched",g.size!==c)):!g.size&&t(this,a).hasAttribute("data-match-no-params")?t(this,a).classList.add("all-params-matched"):(t(this,a).classList.remove("all-params-matched"),t(this,a).classList.remove("some-params-matched"))}updatePagination(e,s){const i=E(this,H,Ht).call(this,s);if(i)if(i.element.setAttribute("data-current-page",e.toString()),t(this,a).hasAttribute("data-pagination-more-link"))if(e<i.totalPages){t(this,a).style.display="";const n=t(this,a).querySelector("[data-pagination-more-link-counter]");n&&(n.textContent=(i.totalPages-e).toString());const L=t(this,a).getAttribute("href"),p=new URL(L,window.location.origin);p.searchParams.set("page",(e+1).toString());const g=p.href.replace(p.origin,"").toString();t(this,a).setAttribute("href",g),this.checkCurrent(g)}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,ft)),t(this,a).removeEventListener("pointerenter",t(this,it)),t(this,a).classList.remove("current","exact","pagination-current")}}k=new WeakMap,a=new WeakMap,H=new WeakSet,st=function(){const e=new URL(t(this,a).href);return t(this,k).normalizePath(e.pathname+e.search+e.hash).path},Ht=function(e){if(!e)return;const s=document.querySelector(e);if(s){const i=parseInt(s.getAttribute("data-current-page")||"1"),n=parseInt(s.getAttribute("data-total-pages")||"1");return{element:s,currentPage:i,totalPages:n,selector:e}}},ft=new WeakMap,it=new WeakMap;const ve=new DOMParser;var z,J,C,I,Q,B,at,Z,X,pt;class se{constructor(e,s){l(this,z);l(this,J);l(this,C,{x:0,y:0});l(this,I,null);l(this,Q,null);l(this,B,null);l(this,at,null);l(this,Z,null);l(this,X,null);l(this,pt);o(this,z,e),o(this,J,s)}get pathname(){return t(this,J)}get scrollState(){return t(this,C)}get document(){return t(this,B)}setHeaders(e){o(this,pt,e)}setInitialDocument(e){o(this,I,e.cloneNode(!0))}abort(){var e;return(e=t(this,Z))==null?void 0:e.abort(`[${t(this,J)}] page loading cancelled`)}fetch(e,s,i){return G(this,null,function*(){var n;if(!i){const g=((n=t(this,I))==null?void 0:n.documentElement.getAttribute("data-cache"))&&s!==e,c=t(this,I)&&t(this,z).isPopstateNavigation;if(t(this,X)||g||c)return t(this,X)}return o(this,X,new Promise(L=>G(this,null,function*(){try{o(this,Z,new AbortController);const g=yield(yield fetch(e,{signal:t(this,Z).signal,headers:Rt({"X-MORPH":"true","X-MORPH-CURRENT-PATH":encodeURIComponent(s),"X-MORPH-NEW-PATH":encodeURIComponent(e)},t(this,pt))})).text(),c=ve.parseFromString(g,"text/html");this.setInitialDocument(c)}catch(p){console.warn(p)}finally{o(this,Z,null),o(this,X,null),L()}}))),t(this,X)})}cloneDocument(){o(this,B,(t(this,Q)||t(this,I)).cloneNode(!0))}get title(){let e="";if(t(this,B).title)e=t(this,B).title;else{const s=t(this,B).querySelector("h1");e=(s==null?void 0:s.innerText)||(s==null?void 0:s.textContent)||t(this,J)}return e}clearScrollState(){t(this,C).x=0,t(this,C).y=0}clearDocumentState(){o(this,Q,null)}saveScrollState(){t(this,I).documentElement.hasAttribute("data-no-scroll-restoration")?(t(this,C).x=0,t(this,C).y=0):(t(this,C).x=t(this,z).scrollValue.left,t(this,C).y=t(this,z).scrollValue.top)}restoreScrollPosition(){t(this,z).scrollElement.scroll({top:t(this,C).y,left:t(this,C).x,behavior:"instant"})}saveDocumentState(){t(this,I).documentElement.hasAttribute("data-no-page-restoration")?o(this,Q,null):o(this,Q,document.cloneNode(!0))}renewScrollPosition(){t(this,z).scrollElement.scroll({top:0,left:0,behavior:"instant"})}saveState(e){o(this,at,e)}clearState(){const e=t(this,at);return o(this,at,null),e}}z=new WeakMap,J=new WeakMap,C=new WeakMap,I=new WeakMap,Q=new WeakMap,B=new WeakMap,at=new WeakMap,Z=new WeakMap,X=new WeakMap,pt=new WeakMap;var R,nt,gt,It,Et;class Le{constructor(e){l(this,gt);l(this,R);l(this,nt,[]);l(this,Et,()=>{E(this,gt,It).call(this)});o(this,R,e);for(const s in t(this,R).dataset){const i=Ee.camelToKebab(s);if(i.startsWith("param-")){const n=i.split("param-")[1],L=t(this,R).dataset[s];t(this,nt).push({name:n,value:L})}}document.addEventListener("morphURLParametersChange",t(this,Et)),E(this,gt,It).call(this)}destroy(){document.removeEventListener("morphURLParametersChange",t(this,Et))}}R=new WeakMap,nt=new WeakMap,gt=new WeakSet,It=function(){const e=new URLSearchParams(location.search);let s=!!t(this,nt).find(n=>e.has(n.name)&&(e.get(n.name)===n.value||n.value==="*"||n.value==="all"||n.value==="any"||n.value==="vse"||e.get(n.name)==="*"||e.get(n.name)==="all"||e.get(n.name)==="any"||e.get(n.name)==="vse"));!s&&t(this,R).hasAttribute("data-match-no-params")&&(s=!t(this,nt).filter(n=>e.has(n.name)).length);const i=t(this,R).getAttribute("data-hide-class");s?i?t(this,R).classList.remove(i):t(this,R).style.display="":i?t(this,R).classList.add(i):t(this,R).style.display="none"},Et=new WeakMap;var N,rt,y,K,f,_,Y,$,T,vt,V,Lt,tt,ot,ht,St,lt,bt,m,Wt,yt,Mt,Ot,ne,Ft,Bt,Xt,Kt,Tt,ct;const mt=class mt{constructor(e){l(this,m);l(this,N,null);l(this,rt,null);l(this,y,[]);l(this,K);l(this,f,null);l(this,_);l(this,Y,[]);l(this,$,!1);l(this,T,null);l(this,vt,!1);l(this,V,new Map);l(this,Lt,[]);l(this,tt,null);l(this,ot,0);l(this,ht,0);l(this,St);l(this,lt);l(this,bt);l(this,yt,e=>{var s,i;return(((s=e.getAttribute("href"))==null?void 0:s.startsWith("/"))||((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,Tt,e=>G(this,null,function*(){e.preventDefault(),o(this,$,!0),yield this.navigate(location.href.replace(location.origin,""),{historyAction:"none",submorph:t(this,lt)?void 0:t(this,St),revalidate:t(this,lt),keepScrollPosition:t(this,bt)}),o(this,$,!1)}));l(this,ct,()=>{const{left:e,top:s}=this.scrollValue,i=s-t(this,ht),n=e-t(this,ot);o(this,ht,s),o(this,ot,e),document.documentElement.classList.toggle("scroll-y",s>0),document.documentElement.classList.toggle("scroll-x",e>0),document.documentElement.classList.toggle("scroll-y-forward",i>0),document.documentElement.classList.toggle("scroll-y-backward",i<0),document.documentElement.classList.toggle("scroll-x-forward",n>0),document.documentElement.classList.toggle("scroll-x-backward",n<0),q.dispatchEvent(document,"morphScroll",{detail:{left:e,top:s}})});if(ie.isBrowser&&!mt.instance){mt.instance=this,o(this,N,{base:ut.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}),o(this,rt,E(this,m,Ot).call(this,document.body));const s=this.normalizePath(location.pathname+location.search+location.hash);o(this,f,s);const i=new se(this,t(this,f).pathname);i.setInitialDocument(document),t(this,V).set(t(this,f).pathname,i),document.documentElement.setAttribute("data-current-pathname",t(this,f).pathname),document.documentElement.setAttribute("data-current-leaf",s.leaf),this.findLinks(),this.findParamsDependent(),history.scrollRestoration="manual",addEventListener("popstate",t(this,Tt)),ut.changeHistory({action:"replace",pathname:s.pathname,searchParameters:s.parameters,hash:s.hash}),o(this,tt,new ae),E(this,m,Xt).call(this,document)}}get currentURL(){return t(this,f)}get previousURL(){return t(this,_)}get links(){return t(this,y)}get scrollElement(){return t(this,T)}get isPopstateNavigation(){return t(this,$)}get scrollValue(){let e=0,s=0;return t(this,vt)?(e=window.scrollY,s=window.scrollX):(e=t(this,T).scrollTop,s=t(this,T).scrollLeft),{top:e,left:s}}saveState(e){const s=t(this,V).get(t(this,f).path);s&&s.saveState(e)}getState(){const e=t(this,V).get(t(this,f).path);return e==null?void 0:e.clearState()}normalizePath(e,s){return ut.splitPath(e,{base:t(this,N).base,trailingSlash:t(this,N).trailingSlash,mergeParams:s!=null&&s.mergeParams?location.search:""})}prefetch(e,s){return G(this,null,function*(){var n;if(t(this,Y).length)return;e=((n=this.pathnameModifier)==null?void 0:n.call(this,e))||e;const i=E(this,m,Mt).call(this,e);i==null||i.fetch(e,t(this,f).path,s)})}excludeHeadChild(e){return!1}setHeaders(e){}navigate(re){return G(this,arguments,function*(e,{historyAction:s="push",centerScroll:i,offsetScroll:n,scrollBehaviour:L,revalidate:p,keepSearchParameters:g,submorph:c,submorphAppend:v,clearState:D,keepScrollPosition:dt,mergeParams:et}={}){var U,wt,j,W;if(t(this,Y).length)return;o(this,St,c),o(this,lt,p),o(this,bt,dt);const Pt=((U=this.pathnameModifier)==null?void 0:U.call(this,e))||e,d=this.normalizePath(Pt,{mergeParams:et});if(!p&&(((wt=t(this,K))==null?void 0:wt.pathname)===d.pathname||t(this,f).pathname===d.pathname)){dt||E(this,m,Kt).call(this,d.hash||0,{centerScroll:i,offsetScroll:n,behavior:"smooth"}),q.dispatchEvent(document,"morphSamePath",{custom:!0}),((j=t(this,f))==null?void 0:j.parameters)!==d.parameters&&(o(this,_,t(this,f)),o(this,f,d),ut.changeHistory({action:((W=t(this,f))==null?void 0:W.hash)!==d.hash?"replace":s,pathname:d.pathname,searchParameters:d.parameters,hash:d.hash}),q.dispatchEvent(document,"morphURLParametersChange",{detail:{newURL:t(this,f),previousURL:t(this,_)}})),t(this,y).forEach(A=>{A.checkCurrent(d.path)});return}else t(this,y).forEach(A=>{A.checkCurrent(d.path)});o(this,K,d);try{let A=!0;if(this.preprocessor)try{yield new Promise((r,P)=>{var M;(M=this.preprocessor)==null||M.call(this,{url:d,resolve:r,reject:P,submorph:c})})}catch(r){r?console.error(r):console.log("Route change canceled"),A=!1}if(!A||t(this,K).pathname!==d.pathname){t(this,y).forEach(r=>{r.checkCurrent(t(this,f).path)});return}const w={url:d,submorph:c};c?v||c.forEach(r=>{document.querySelectorAll(r).forEach(P=>{P.classList.add("out"),P.setAttribute("data-morph-out","")})}):t(this,rt).forEach(r=>{var P,M;(P=r.firstElementChild)==null||P.classList.add("out"),(M=r.firstElementChild)==null||M.setAttribute("data-morph-out","")}),q.dispatchEvent(document,"morphNavigation",{detail:w});const Ut=E(this,m,Mt).call(this,t(this,f).pathname),S=E(this,m,Mt).call(this,d.pathname);if(t(this,V).forEach(r=>{r.pathname!==d.pathname&&r.abort()}),yield S==null?void 0:S.fetch(Pt,t(this,f).path,p),t(this,K).pathname!==d.pathname){t(this,y).forEach(r=>{r.checkCurrent(t(this,f).path)});return}Ut.clearState(),Ut.saveScrollState(),Ut.saveDocumentState(),(!t(this,$)||p)&&(S.clearScrollState(),S.clearDocumentState()),D&&S.clearState(),S.cloneDocument(),t(this,tt).textContent=S.title,document.body.appendChild(t(this,tt));const At=Dt(Rt({},w),{document:S.document});v||At.document.querySelectorAll("[data-morph-out]").forEach(r=>{r.classList.remove("out")}),q.dispatchEvent(document,"morphStart",{detail:At});const Yt=Array.from(document.head.children),$t=Array.from(S.document.head.children),jt=E(this,m,ne).call(this,Yt,$t),oe=E(this,m,Ft).call(this,Yt,jt),kt=E(this,m,Ft).call(this,$t,jt).filter(r=>!this.excludeHeadChild(r));kt.forEach((r,P)=>{r.tagName==="SCRIPT"&&(kt[P]=E(this,m,Wt).call(this,r))}),kt.forEach(r=>{document.head.appendChild(r)});const xt=kt.filter(r=>{if(r.hasAttribute("data-no-waiting"))return!1;if(E(this,m,Bt).call(this,r))return!0});t(this,N).waitForHeadToLoad&&xt.length&&(yield new Promise(r=>G(this,null,function*(){let P=0;try{for(var M=te(xt),le,O,x;le=!(O=yield M.next()).done;le=!1){const Ct=O.value;Ct.onload=()=>{P++,P===xt.length&&r()}}}catch(O){x=[O]}finally{try{le&&(O=M.return)&&(yield O.call(M))}finally{if(x)throw x[0]}}}))),yield ee.wait(10);const Gt=[];v||oe.forEach(r=>{r.hasAttribute("data-permanent")||(E(this,m,Bt).call(this,r)?Gt.push(r):r.remove())});const he=E(this,m,Ot).call(this,S.document.body);!t(this,N).morphInsideScrollContainer&&!c&&E(this,m,Xt).call(this,S.document),document.documentElement.setAttribute("data-current-pathname",d.pathname),document.documentElement.setAttribute("data-current-leaf",d.leaf),ut.changeHistory({action:s,pathname:d.pathname,searchParameters:d.parameters||(g?location.search:""),hash:d.hash}),t(this,tt).remove(),o(this,_,t(this,f)),o(this,f,d);const Nt=[];t(this,rt).forEach((r,P)=>{const M=he[P],le=getComputedStyle(r).getPropertyValue("--morph-duration");let O=[],x=[];c?(c.forEach(u=>{const b=r.querySelector(u),F=M.querySelector(u);b&&F&&(x.push(b),O.push(F))}),x.forEach(u=>{u.parentElement&&Nt.push(u.parentElement)})):(O.push(...M.childNodes),x.push(...r.childNodes),Nt.push(r)),v||x.forEach(u=>{u instanceof HTMLElement&&(this.destroyOldLinks(u),u.classList.add("old"))}),O.forEach(u=>{u instanceof HTMLElement&&(this.findNewLinks(u),u.classList.add("new"))}),c?v?O.forEach((u,b)=>{x[b]instanceof HTMLElement&&x[b].append(...u.childNodes)}):O.forEach((u,b)=>{var F;(F=x[b].parentElement)==null||F.insertBefore(u,x[b])}):r.prepend(...O),setTimeout(()=>{v||x.forEach(u=>{u instanceof HTMLElement&&u.classList.add("old-idle")}),O.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"))})},0);const Ct=Dt(Rt({},At),{morphElement:r});q.dispatchEvent(document,"morphNewChildrenAdded",{detail:Ct});const ce=new Promise(u=>{setTimeout(()=>{v||x.forEach(b=>b.remove()),O.forEach(b=>{var F;b instanceof HTMLElement&&((F=b.parentElement)==null||F.style.removeProperty("--new-content-height"),b.classList.remove("new-idle","new"))}),v||q.dispatchEvent(document,"morphOldChildrenRemoved",{detail:Ct}),u()},(parseFloat(le)||0)*1e3+10)});t(this,Y).push(ce)}),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"),q.dispatchEvent(document,"morphBeforeNavigationScroll",{detail:S.scrollState}),d.hash?(S.clearScrollState(),E(this,m,Kt).call(this,d.hash,{centerScroll:i,offsetScroll:n,behavior:L})):t(this,$)?S.restoreScrollPosition():dt||S.renewScrollPosition(),yield Promise.all(t(this,Y)),v||Gt.forEach(r=>r.remove()),o(this,Y,[]),Nt.forEach(r=>{r.querySelectorAll("script").forEach(M=>{M.replaceWith(E(this,m,Wt).call(this,M))})}),t(this,y).forEach(r=>{r.checkCurrent(t(this,f).path)}),this.findParamsDependent(),q.dispatchEvent(document,"morphComplete",{detail:At}),document.documentElement.style.removeProperty("--new-document-scroll-position"),window.dispatchEvent(new Event("resize"))}catch(A){console.error(A)}o(this,K,void 0)})}addLink(e){t(this,y).push(new zt(e,this))}addLinks(e){e.forEach(s=>{this.addLink(s)})}removeLink(e){o(this,y,t(this,y).filter(s=>s.element===e?(s.destroy(),!1):!0))}destroyOldLinks(e){o(this,y,t(this,y).filter(s=>e.contains(s.element)?(s.destroy(),!1):!0))}findNewLinks(e){const s=[...e.querySelectorAll("a")].filter(t(this,yt));t(this,y).push(...s.map(i=>new zt(i,this)))}findLinks(){const e=[...document.documentElement.querySelectorAll("a")].filter(t(this,yt));t(this,y).forEach(s=>s.destroy()),o(this,y,e.map(s=>new zt(s,this)))}findParamsDependent(){const e=[...document.documentElement.querySelectorAll("[data-morph-params-dependent]")];t(this,Lt).forEach(s=>s.destroy()),o(this,Lt,e.map(s=>new Le(s)))}};N=new WeakMap,rt=new WeakMap,y=new WeakMap,K=new WeakMap,f=new WeakMap,_=new WeakMap,Y=new WeakMap,$=new WeakMap,T=new WeakMap,vt=new WeakMap,V=new WeakMap,Lt=new WeakMap,tt=new WeakMap,ot=new WeakMap,ht=new WeakMap,St=new WeakMap,lt=new WeakMap,bt=new WeakMap,m=new WeakSet,Wt=function(e){const s=document.createElement("script");for(let i=0;i<e.attributes.length;i++){const n=e.attributes[i];s.setAttribute(n.name,n.value)}return e.hasAttribute("src")||(s.innerHTML=e.innerHTML),s},yt=new WeakMap,Mt=function(e){const s=this.normalizePath(e);let i=t(this,V).get(s.pathname);return i||(i=new se(this,s.pathname),t(this,V).set(s.pathname,i)),i},Ot=function(e){const s=[...e.querySelectorAll("[data-morph]")];return s.length?s:[e]},ne=function(e,s){return e.filter(i=>s.find(n=>n.outerHTML===i.outerHTML))},Ft=function(e,s){return e.filter(i=>!s.find(n=>n.outerHTML===i.outerHTML))},Bt=function(e){return e.tagName==="SCRIPT"||e.tagName==="STYLE"||e.tagName==="LINK"&&e.getAttribute("rel")==="stylesheet"},Xt=function(e){var s,i;(s=t(this,T))==null||s.removeEventListener("scroll",t(this,ct)),o(this,ht,0),o(this,ot,0),o(this,T,t(this,N).scrollSelector&&e.querySelector(t(this,N).scrollSelector)||window),o(this,vt,t(this,T)===window),(i=t(this,T))==null||i.addEventListener("scroll",t(this,ct)),t(this,ct).call(this)},Kt=function(e,s){const i=typeof e=="string"?document.getElementById(e):e;(typeof i=="number"||i)&&ee.scrollToElement(i,{scrollElement:t(this,T),behavior:(s==null?void 0:s.behavior)||"instant",center:s==null?void 0:s.centerScroll,offset:s==null?void 0:s.offsetScroll})},Tt=new WeakMap,ct=new WeakMap,mt.instance=null;let Vt=mt;exports.Morph=Vt;
|
package/lib/morph/index.js
CHANGED
|
@@ -33,10 +33,10 @@ var G = (h, e, s) => new Promise((i, n) => {
|
|
|
33
33
|
});
|
|
34
34
|
var _t = (h, e, s) => (e = h[Jt("asyncIterator")]) ? e.call(h) : (h = h[Jt("iterator")](), e = {}, s = (i, n) => (n = h[i]) && (e[i] = (S) => new Promise((p, g, c) => (S = n.call(h, S), c = S.done, Promise.resolve(S.value).then((L) => p({ value: L, done: c }), g)))), s("next"), s("return"), e);
|
|
35
35
|
import { i as se } from "../index-Bv9zgfdb.js";
|
|
36
|
-
import { d as
|
|
36
|
+
import { d as z } from "../events-CsVF98U6.js";
|
|
37
37
|
import { w as pe, s as ge } from "../scroll-DNGJVxa2.js";
|
|
38
38
|
import "construct-style-sheets-polyfill";
|
|
39
|
-
import { n as Ee, c as
|
|
39
|
+
import { n as Ee, c as zt, s as Le } from "../url-CBKXmNOi.js";
|
|
40
40
|
import { cssValueParser as Se } from "../css-value-parser/index.js";
|
|
41
41
|
import { c as ve } from "../string-BlMQbe8b.js";
|
|
42
42
|
class ie extends HTMLElement {
|
|
@@ -51,34 +51,32 @@ class ie extends HTMLElement {
|
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
se && !customElements.get("morph-announcer") && customElements.define("morph-announcer", ie);
|
|
54
|
-
var
|
|
55
|
-
class
|
|
54
|
+
var k, a, H, st, Rt, mt, it;
|
|
55
|
+
class It {
|
|
56
56
|
constructor(e, s) {
|
|
57
|
-
l(this, st);
|
|
58
57
|
l(this, H);
|
|
58
|
+
l(this, k);
|
|
59
59
|
l(this, a);
|
|
60
|
-
l(this, U);
|
|
61
60
|
l(this, mt, (e) => {
|
|
62
61
|
var i;
|
|
63
62
|
if (e.preventDefault(), document.documentElement.classList.contains("click-disabled"))
|
|
64
63
|
return;
|
|
65
|
-
if (t(this, a).hasAttribute("data-back") && t(this,
|
|
64
|
+
if (t(this, a).hasAttribute("data-back") && t(this, k).previousURL)
|
|
66
65
|
history.back();
|
|
67
66
|
else {
|
|
68
|
-
o(this, U, t(this, a).getAttribute("href") || "/");
|
|
69
67
|
const n = t(this, a).getAttribute(
|
|
70
68
|
"data-history-action"
|
|
71
69
|
) || "push", S = t(this, a).hasAttribute("data-center-scroll"), p = getComputedStyle(t(this, a)).getPropertyValue("--offset-scroll").trim(), g = p ? Se.parse(p) : void 0, c = t(this, a).hasAttribute("data-revalidate") || t(this, a).hasAttribute("data-pagination-more-link") || t(this, a).hasAttribute("data-pagination-set-link"), L = t(this, a).hasAttribute(
|
|
72
70
|
"data-keep-search-parameters"
|
|
73
71
|
), D = t(this, a).hasAttribute("data-keep-scroll-position") || t(this, a).hasAttribute("data-pagination-more-link"), dt = t(this, a).getAttribute(
|
|
74
72
|
"data-scroll-behaviour"
|
|
75
|
-
), et = E(this,
|
|
76
|
-
et && (t(this, a).hasAttribute("data-pagination-set-link") ? t(this,
|
|
73
|
+
), et = E(this, H, Rt).call(this, t(this, a).getAttribute("data-pagination-set-link") || t(this, a).getAttribute("data-pagination-more-link"));
|
|
74
|
+
et && (t(this, a).hasAttribute("data-pagination-set-link") ? t(this, k).links.forEach((M) => {
|
|
77
75
|
M.updatePagination(
|
|
78
76
|
parseInt(t(this, a).getAttribute("data-value") || "1"),
|
|
79
77
|
et.selector
|
|
80
78
|
);
|
|
81
|
-
}) : t(this, a).hasAttribute("data-pagination-more-link") && t(this,
|
|
79
|
+
}) : t(this, a).hasAttribute("data-pagination-more-link") && t(this, k).links.forEach((M) => {
|
|
82
80
|
M.updatePagination(
|
|
83
81
|
et.currentPage + 1,
|
|
84
82
|
et.selector
|
|
@@ -89,9 +87,9 @@ class zt {
|
|
|
89
87
|
] || t(this, a).hasAttribute("data-pagination-set-link") && [
|
|
90
88
|
t(this, a).getAttribute("data-pagination-set-link")
|
|
91
89
|
] || void 0, yt = t(this, a).hasAttribute("data-clear-state");
|
|
92
|
-
let d = t(this,
|
|
90
|
+
let d = t(this, H, st);
|
|
93
91
|
if (t(this, a).hasAttribute("data-toggle-params")) {
|
|
94
|
-
const [M, Pt] = t(this,
|
|
92
|
+
const [M, Pt] = t(this, H, st).split("?"), j = new URLSearchParams(Pt), W = new URLSearchParams(location.search), A = new URLSearchParams();
|
|
95
93
|
for (const [w] of j)
|
|
96
94
|
(!W.has(w) || W.has(w) && W.get(w) !== j.get(w)) && A.append(w, j.get(w));
|
|
97
95
|
if (t(this, a).hasAttribute("data-merge-params"))
|
|
@@ -99,7 +97,7 @@ class zt {
|
|
|
99
97
|
j.has(w) || A.append(w, W.get(w));
|
|
100
98
|
d = `${M}?${A.toString()}`;
|
|
101
99
|
}
|
|
102
|
-
t(this,
|
|
100
|
+
t(this, k).navigate(d, {
|
|
103
101
|
historyAction: n,
|
|
104
102
|
centerScroll: S,
|
|
105
103
|
offsetScroll: g,
|
|
@@ -116,10 +114,10 @@ class zt {
|
|
|
116
114
|
});
|
|
117
115
|
l(this, it, () => {
|
|
118
116
|
const e = t(this, a).hasAttribute("data-revalidate");
|
|
119
|
-
t(this,
|
|
117
|
+
t(this, k).prefetch(t(this, H, st), e), t(this, a).removeEventListener("pointerenter", t(this, it));
|
|
120
118
|
});
|
|
121
|
-
o(this,
|
|
122
|
-
const i = E(this,
|
|
119
|
+
o(this, k, s), o(this, a, e), t(this, a).addEventListener("click", t(this, mt)), this.checkCurrent(location.href.replace(location.origin, ""));
|
|
120
|
+
const i = E(this, H, Rt).call(this, t(this, a).getAttribute("data-pagination-set-link") || t(this, a).getAttribute("data-pagination-more-link"));
|
|
123
121
|
i && this.updatePagination(
|
|
124
122
|
i.currentPage,
|
|
125
123
|
i.selector
|
|
@@ -130,9 +128,9 @@ class zt {
|
|
|
130
128
|
}
|
|
131
129
|
checkCurrent(e) {
|
|
132
130
|
var L;
|
|
133
|
-
const s = t(this,
|
|
131
|
+
const s = t(this, k).normalizePath(e), i = t(this, k).normalizePath(t(this, H, st));
|
|
134
132
|
t(this, a).hasAttribute("data-include") && s.pathname.includes(i.pathname) ? t(this, a).classList.add("current") : i.pathname === s.pathname ? t(this, a).classList.add("current") : (L = t(this, a).getAttribute("data-associated-paths")) != null && L.split(",").find((D) => s.pathname.includes(D)) ? t(this, a).classList.add("current") : t(this, a).classList.remove("current"), s.path === i.path ? t(this, a).classList.add("exact") : t(this, a).classList.remove("exact");
|
|
135
|
-
const [n, S] = t(this,
|
|
133
|
+
const [n, S] = t(this, H, st).split("?"), p = new URLSearchParams(S), g = new URLSearchParams(location.search);
|
|
136
134
|
let c = 0;
|
|
137
135
|
for (const [D] of g)
|
|
138
136
|
p.has(D) && g.get(D) === p.get(D) && c++;
|
|
@@ -145,7 +143,7 @@ class zt {
|
|
|
145
143
|
)) : !g.size && t(this, a).hasAttribute("data-match-no-params") ? t(this, a).classList.add("all-params-matched") : (t(this, a).classList.remove("all-params-matched"), t(this, a).classList.remove("some-params-matched"));
|
|
146
144
|
}
|
|
147
145
|
updatePagination(e, s) {
|
|
148
|
-
const i = E(this,
|
|
146
|
+
const i = E(this, H, Rt).call(this, s);
|
|
149
147
|
if (i)
|
|
150
148
|
if (i.element.setAttribute(
|
|
151
149
|
"data-current-page",
|
|
@@ -169,7 +167,12 @@ class zt {
|
|
|
169
167
|
t(this, a).removeEventListener("click", t(this, mt)), t(this, a).removeEventListener("pointerenter", t(this, it)), t(this, a).classList.remove("current", "exact", "pagination-current");
|
|
170
168
|
}
|
|
171
169
|
}
|
|
172
|
-
|
|
170
|
+
k = new WeakMap(), a = new WeakMap(), H = new WeakSet(), st = function() {
|
|
171
|
+
const e = new URL(t(this, a).href);
|
|
172
|
+
return t(this, k).normalizePath(
|
|
173
|
+
e.pathname + e.search + e.hash
|
|
174
|
+
).path;
|
|
175
|
+
}, Rt = function(e) {
|
|
173
176
|
if (!e)
|
|
174
177
|
return;
|
|
175
178
|
const s = document.querySelector(e);
|
|
@@ -188,12 +191,12 @@ H = new WeakMap(), a = new WeakMap(), U = new WeakMap(), st = new WeakSet(), Rt
|
|
|
188
191
|
}
|
|
189
192
|
}, mt = new WeakMap(), it = new WeakMap();
|
|
190
193
|
const be = new DOMParser();
|
|
191
|
-
var
|
|
194
|
+
var I, J, C, q, Q, B, at, Z, X, ft;
|
|
192
195
|
class te {
|
|
193
196
|
constructor(e, s) {
|
|
194
|
-
l(this,
|
|
197
|
+
l(this, I);
|
|
195
198
|
l(this, J);
|
|
196
|
-
l(this,
|
|
199
|
+
l(this, C, { x: 0, y: 0 });
|
|
197
200
|
l(this, q, null);
|
|
198
201
|
l(this, Q, null);
|
|
199
202
|
l(this, B, null);
|
|
@@ -201,13 +204,13 @@ class te {
|
|
|
201
204
|
l(this, Z, null);
|
|
202
205
|
l(this, X, null);
|
|
203
206
|
l(this, ft);
|
|
204
|
-
o(this,
|
|
207
|
+
o(this, I, e), o(this, J, s);
|
|
205
208
|
}
|
|
206
209
|
get pathname() {
|
|
207
210
|
return t(this, J);
|
|
208
211
|
}
|
|
209
212
|
get scrollState() {
|
|
210
|
-
return t(this,
|
|
213
|
+
return t(this, C);
|
|
211
214
|
}
|
|
212
215
|
get document() {
|
|
213
216
|
return t(this, B);
|
|
@@ -228,7 +231,7 @@ class te {
|
|
|
228
231
|
return G(this, null, function* () {
|
|
229
232
|
var n;
|
|
230
233
|
if (!i) {
|
|
231
|
-
const g = ((n = t(this, q)) == null ? void 0 : n.documentElement.getAttribute("data-cache")) && s !== e, c = t(this, q) && t(this,
|
|
234
|
+
const g = ((n = t(this, q)) == null ? void 0 : n.documentElement.getAttribute("data-cache")) && s !== e, c = t(this, q) && t(this, I).isPopstateNavigation;
|
|
232
235
|
if (t(this, X) || g || c)
|
|
233
236
|
return t(this, X);
|
|
234
237
|
}
|
|
@@ -266,7 +269,7 @@ class te {
|
|
|
266
269
|
return e;
|
|
267
270
|
}
|
|
268
271
|
clearScrollState() {
|
|
269
|
-
t(this,
|
|
272
|
+
t(this, C).x = 0, t(this, C).y = 0;
|
|
270
273
|
}
|
|
271
274
|
clearDocumentState() {
|
|
272
275
|
o(this, Q, null);
|
|
@@ -274,12 +277,12 @@ class te {
|
|
|
274
277
|
saveScrollState() {
|
|
275
278
|
t(this, q).documentElement.hasAttribute(
|
|
276
279
|
"data-no-scroll-restoration"
|
|
277
|
-
) ? (t(this,
|
|
280
|
+
) ? (t(this, C).x = 0, t(this, C).y = 0) : (t(this, C).x = t(this, I).scrollValue.left, t(this, C).y = t(this, I).scrollValue.top);
|
|
278
281
|
}
|
|
279
282
|
restoreScrollPosition() {
|
|
280
|
-
t(this,
|
|
281
|
-
top: t(this,
|
|
282
|
-
left: t(this,
|
|
283
|
+
t(this, I).scrollElement.scroll({
|
|
284
|
+
top: t(this, C).y,
|
|
285
|
+
left: t(this, C).x,
|
|
283
286
|
behavior: "instant"
|
|
284
287
|
});
|
|
285
288
|
}
|
|
@@ -289,7 +292,7 @@ class te {
|
|
|
289
292
|
) ? o(this, Q, null) : o(this, Q, document.cloneNode(!0));
|
|
290
293
|
}
|
|
291
294
|
renewScrollPosition() {
|
|
292
|
-
t(this,
|
|
295
|
+
t(this, I).scrollElement.scroll({
|
|
293
296
|
top: 0,
|
|
294
297
|
left: 0,
|
|
295
298
|
behavior: "instant"
|
|
@@ -303,21 +306,21 @@ class te {
|
|
|
303
306
|
return o(this, at, null), e;
|
|
304
307
|
}
|
|
305
308
|
}
|
|
306
|
-
|
|
307
|
-
var
|
|
309
|
+
I = new WeakMap(), J = new WeakMap(), C = new WeakMap(), q = new WeakMap(), Q = new WeakMap(), B = new WeakMap(), at = new WeakMap(), Z = new WeakMap(), X = new WeakMap(), ft = new WeakMap();
|
|
310
|
+
var R, nt, pt, qt, gt;
|
|
308
311
|
class ye {
|
|
309
312
|
constructor(e) {
|
|
310
313
|
l(this, pt);
|
|
311
|
-
l(this,
|
|
314
|
+
l(this, R);
|
|
312
315
|
l(this, nt, []);
|
|
313
316
|
l(this, gt, () => {
|
|
314
317
|
E(this, pt, qt).call(this);
|
|
315
318
|
});
|
|
316
|
-
o(this,
|
|
317
|
-
for (const s in t(this,
|
|
319
|
+
o(this, R, e);
|
|
320
|
+
for (const s in t(this, R).dataset) {
|
|
318
321
|
const i = ve(s);
|
|
319
322
|
if (i.startsWith("param-")) {
|
|
320
|
-
const n = i.split("param-")[1], S = t(this,
|
|
323
|
+
const n = i.split("param-")[1], S = t(this, R).dataset[s];
|
|
321
324
|
t(this, nt).push({
|
|
322
325
|
name: n,
|
|
323
326
|
value: S
|
|
@@ -336,14 +339,14 @@ class ye {
|
|
|
336
339
|
);
|
|
337
340
|
}
|
|
338
341
|
}
|
|
339
|
-
|
|
342
|
+
R = new WeakMap(), nt = new WeakMap(), pt = new WeakSet(), qt = function() {
|
|
340
343
|
const e = new URLSearchParams(location.search);
|
|
341
344
|
let s = !!t(this, nt).find((n) => e.has(n.name) && (e.get(n.name) === n.value || n.value === "*" || n.value === "all" || n.value === "any" || n.value === "vse" || e.get(n.name) === "*" || e.get(n.name) === "all" || e.get(n.name) === "any" || e.get(n.name) === "vse"));
|
|
342
|
-
!s && t(this,
|
|
343
|
-
const i = t(this,
|
|
344
|
-
s ? i ? t(this,
|
|
345
|
+
!s && t(this, R).hasAttribute("data-match-no-params") && (s = !t(this, nt).filter((n) => e.has(n.name)).length);
|
|
346
|
+
const i = t(this, R).getAttribute("data-hide-class");
|
|
347
|
+
s ? i ? t(this, R).classList.remove(i) : t(this, R).style.display = "" : i ? t(this, R).classList.add(i) : t(this, R).style.display = "none";
|
|
345
348
|
}, gt = new WeakMap();
|
|
346
|
-
var N, rt, y, K, f, _, Y, $,
|
|
349
|
+
var N, rt, y, K, f, _, Y, $, U, Et, V, Lt, tt, ot, ht, St, lt, vt, m, Vt, bt, Ht, Wt, ae, Ft, Ot, Bt, Xt, Tt, ct;
|
|
347
350
|
const ut = class ut {
|
|
348
351
|
constructor(e) {
|
|
349
352
|
l(this, m);
|
|
@@ -355,7 +358,7 @@ const ut = class ut {
|
|
|
355
358
|
l(this, _);
|
|
356
359
|
l(this, Y, []);
|
|
357
360
|
l(this, $, !1);
|
|
358
|
-
l(this,
|
|
361
|
+
l(this, U, null);
|
|
359
362
|
l(this, Et, !1);
|
|
360
363
|
l(this, V, /* @__PURE__ */ new Map());
|
|
361
364
|
l(this, Lt, []);
|
|
@@ -366,8 +369,8 @@ const ut = class ut {
|
|
|
366
369
|
l(this, lt);
|
|
367
370
|
l(this, vt);
|
|
368
371
|
l(this, bt, (e) => {
|
|
369
|
-
var s;
|
|
370
|
-
return ((s = e.getAttribute("href")) == null ? void 0 : s.startsWith("/")) && !e.hasAttribute("download") && !e.hasAttribute("data-morph-skip") && !e.closest("[data-morph-skip]") && e.getAttribute("target") !== "_blank";
|
|
372
|
+
var s, i;
|
|
373
|
+
return (((s = e.getAttribute("href")) == null ? void 0 : s.startsWith("/")) || ((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";
|
|
371
374
|
});
|
|
372
375
|
l(this, Tt, (e) => G(this, null, function* () {
|
|
373
376
|
e.preventDefault(), o(this, $, !0), yield this.navigate(location.href.replace(location.origin, ""), {
|
|
@@ -391,7 +394,7 @@ const ut = class ut {
|
|
|
391
394
|
), document.documentElement.classList.toggle(
|
|
392
395
|
"scroll-x-backward",
|
|
393
396
|
n < 0
|
|
394
|
-
),
|
|
397
|
+
), z(document, "morphScroll", {
|
|
395
398
|
detail: {
|
|
396
399
|
left: e,
|
|
397
400
|
top: s
|
|
@@ -417,7 +420,7 @@ const ut = class ut {
|
|
|
417
420
|
), document.documentElement.setAttribute(
|
|
418
421
|
"data-current-leaf",
|
|
419
422
|
s.leaf
|
|
420
|
-
), this.findLinks(), this.findParamsDependent(), history.scrollRestoration = "manual", addEventListener("popstate", t(this, Tt)),
|
|
423
|
+
), this.findLinks(), this.findParamsDependent(), history.scrollRestoration = "manual", addEventListener("popstate", t(this, Tt)), zt({
|
|
421
424
|
action: "replace",
|
|
422
425
|
pathname: s.pathname,
|
|
423
426
|
searchParameters: s.parameters,
|
|
@@ -435,14 +438,14 @@ const ut = class ut {
|
|
|
435
438
|
return t(this, y);
|
|
436
439
|
}
|
|
437
440
|
get scrollElement() {
|
|
438
|
-
return t(this,
|
|
441
|
+
return t(this, U);
|
|
439
442
|
}
|
|
440
443
|
get isPopstateNavigation() {
|
|
441
444
|
return t(this, $);
|
|
442
445
|
}
|
|
443
446
|
get scrollValue() {
|
|
444
447
|
let e = 0, s = 0;
|
|
445
|
-
return t(this, Et) ? (e = window.scrollY, s = window.scrollX) : (e = t(this,
|
|
448
|
+
return t(this, Et) ? (e = window.scrollY, s = window.scrollX) : (e = t(this, U).scrollTop, s = t(this, U).scrollLeft), { top: e, left: s };
|
|
446
449
|
}
|
|
447
450
|
saveState(e) {
|
|
448
451
|
const s = t(this, V).get(t(this, f).path);
|
|
@@ -500,14 +503,14 @@ const ut = class ut {
|
|
|
500
503
|
centerScroll: i,
|
|
501
504
|
offsetScroll: n,
|
|
502
505
|
behavior: "smooth"
|
|
503
|
-
}),
|
|
506
|
+
}), z(document, "morphSamePath", {
|
|
504
507
|
custom: !0
|
|
505
|
-
}), ((j = t(this, f)) == null ? void 0 : j.parameters) !== d.parameters && (o(this, _, t(this, f)), o(this, f, d),
|
|
508
|
+
}), ((j = t(this, f)) == null ? void 0 : j.parameters) !== d.parameters && (o(this, _, t(this, f)), o(this, f, d), zt({
|
|
506
509
|
action: ((W = t(this, f)) == null ? void 0 : W.hash) !== d.hash ? "replace" : s,
|
|
507
510
|
pathname: d.pathname,
|
|
508
511
|
searchParameters: d.parameters,
|
|
509
512
|
hash: d.hash
|
|
510
|
-
}),
|
|
513
|
+
}), z(document, "morphURLParametersChange", {
|
|
511
514
|
detail: {
|
|
512
515
|
newURL: t(this, f),
|
|
513
516
|
previousURL: t(this, _)
|
|
@@ -526,8 +529,8 @@ const ut = class ut {
|
|
|
526
529
|
if (this.preprocessor)
|
|
527
530
|
try {
|
|
528
531
|
yield new Promise((r, P) => {
|
|
529
|
-
var
|
|
530
|
-
(
|
|
532
|
+
var T;
|
|
533
|
+
(T = this.preprocessor) == null || T.call(this, {
|
|
531
534
|
url: d,
|
|
532
535
|
resolve: r,
|
|
533
536
|
reject: P,
|
|
@@ -552,12 +555,12 @@ const ut = class ut {
|
|
|
552
555
|
P.classList.add("out"), P.setAttribute("data-morph-out", "");
|
|
553
556
|
});
|
|
554
557
|
}) : t(this, rt).forEach((r) => {
|
|
555
|
-
var P,
|
|
556
|
-
(P = r.firstElementChild) == null || P.classList.add("out"), (
|
|
557
|
-
}),
|
|
558
|
+
var P, T;
|
|
559
|
+
(P = r.firstElementChild) == null || P.classList.add("out"), (T = r.firstElementChild) == null || T.setAttribute("data-morph-out", "");
|
|
560
|
+
}), z(document, "morphNavigation", {
|
|
558
561
|
detail: w
|
|
559
562
|
});
|
|
560
|
-
const
|
|
563
|
+
const Ut = E(this, m, Ht).call(this, t(this, f).pathname), v = E(this, m, Ht).call(this, d.pathname);
|
|
561
564
|
if (t(this, V).forEach((r) => {
|
|
562
565
|
r.pathname !== d.pathname && r.abort();
|
|
563
566
|
}), yield v == null ? void 0 : v.fetch(yt, t(this, f).path, p), t(this, K).pathname !== d.pathname) {
|
|
@@ -566,13 +569,13 @@ const ut = class ut {
|
|
|
566
569
|
});
|
|
567
570
|
return;
|
|
568
571
|
}
|
|
569
|
-
|
|
572
|
+
Ut.clearState(), Ut.saveScrollState(), Ut.saveDocumentState(), (!t(this, $) || p) && (v.clearScrollState(), v.clearDocumentState()), D && v.clearState(), v.cloneDocument(), t(this, tt).textContent = v.title, document.body.appendChild(t(this, tt));
|
|
570
573
|
const wt = Nt(Ct({}, w), {
|
|
571
574
|
document: v.document
|
|
572
575
|
});
|
|
573
576
|
L || wt.document.querySelectorAll("[data-morph-out]").forEach((r) => {
|
|
574
577
|
r.classList.remove("out");
|
|
575
|
-
}),
|
|
578
|
+
}), z(document, "morphStart", {
|
|
576
579
|
detail: wt
|
|
577
580
|
});
|
|
578
581
|
const Kt = Array.from(document.head.children), Yt = Array.from(v.document.head.children), $t = E(this, m, ae).call(this, Kt, Yt), re = E(this, m, Ft).call(this, Kt, $t), At = E(this, m, Ft).call(this, Yt, $t).filter((r) => !this.excludeHeadChild(r));
|
|
@@ -581,26 +584,26 @@ const ut = class ut {
|
|
|
581
584
|
}), At.forEach((r) => {
|
|
582
585
|
document.head.appendChild(r);
|
|
583
586
|
});
|
|
584
|
-
const
|
|
587
|
+
const Mt = At.filter((r) => {
|
|
585
588
|
if (r.hasAttribute("data-no-waiting"))
|
|
586
589
|
return !1;
|
|
587
590
|
if (E(this, m, Ot).call(this, r))
|
|
588
591
|
return !0;
|
|
589
592
|
});
|
|
590
|
-
t(this, N).waitForHeadToLoad &&
|
|
593
|
+
t(this, N).waitForHeadToLoad && Mt.length && (yield new Promise((r) => G(this, null, function* () {
|
|
591
594
|
let P = 0;
|
|
592
595
|
try {
|
|
593
|
-
for (var
|
|
596
|
+
for (var T = _t(Mt), he, F, x; he = !(F = yield T.next()).done; he = !1) {
|
|
594
597
|
const kt = F.value;
|
|
595
598
|
kt.onload = () => {
|
|
596
|
-
P++, P ===
|
|
599
|
+
P++, P === Mt.length && r();
|
|
597
600
|
};
|
|
598
601
|
}
|
|
599
602
|
} catch (F) {
|
|
600
603
|
x = [F];
|
|
601
604
|
} finally {
|
|
602
605
|
try {
|
|
603
|
-
he && (F =
|
|
606
|
+
he && (F = T.return) && (yield F.call(T));
|
|
604
607
|
} finally {
|
|
605
608
|
if (x)
|
|
606
609
|
throw x[0];
|
|
@@ -618,22 +621,22 @@ const ut = class ut {
|
|
|
618
621
|
), document.documentElement.setAttribute(
|
|
619
622
|
"data-current-leaf",
|
|
620
623
|
d.leaf
|
|
621
|
-
),
|
|
624
|
+
), zt({
|
|
622
625
|
action: s,
|
|
623
626
|
pathname: d.pathname,
|
|
624
627
|
searchParameters: d.parameters || (g ? location.search : ""),
|
|
625
628
|
hash: d.hash
|
|
626
629
|
}), t(this, tt).remove(), o(this, _, t(this, f)), o(this, f, d);
|
|
627
|
-
const
|
|
630
|
+
const xt = [];
|
|
628
631
|
t(this, rt).forEach((r, P) => {
|
|
629
|
-
const
|
|
632
|
+
const T = oe[P], he = getComputedStyle(r).getPropertyValue("--morph-duration");
|
|
630
633
|
let F = [], x = [];
|
|
631
634
|
c ? (c.forEach((u) => {
|
|
632
|
-
const b = r.querySelector(u), O =
|
|
635
|
+
const b = r.querySelector(u), O = T.querySelector(u);
|
|
633
636
|
b && O && (x.push(b), F.push(O));
|
|
634
637
|
}), x.forEach((u) => {
|
|
635
|
-
u.parentElement &&
|
|
636
|
-
})) : (F.push(...
|
|
638
|
+
u.parentElement && xt.push(u.parentElement);
|
|
639
|
+
})) : (F.push(...T.childNodes), x.push(...r.childNodes), xt.push(r)), L || x.forEach((u) => {
|
|
637
640
|
u instanceof HTMLElement && (this.destroyOldLinks(u), u.classList.add("old"));
|
|
638
641
|
}), F.forEach((u) => {
|
|
639
642
|
u instanceof HTMLElement && (this.findNewLinks(u), u.classList.add("new"));
|
|
@@ -659,7 +662,7 @@ const ut = class ut {
|
|
|
659
662
|
const kt = Nt(Ct({}, wt), {
|
|
660
663
|
morphElement: r
|
|
661
664
|
});
|
|
662
|
-
|
|
665
|
+
z(document, "morphNewChildrenAdded", {
|
|
663
666
|
detail: kt
|
|
664
667
|
});
|
|
665
668
|
const le = new Promise((u) => {
|
|
@@ -669,7 +672,7 @@ const ut = class ut {
|
|
|
669
672
|
b instanceof HTMLElement && ((O = b.parentElement) == null || O.style.removeProperty(
|
|
670
673
|
"--new-content-height"
|
|
671
674
|
), b.classList.remove("new-idle", "new"));
|
|
672
|
-
}), L ||
|
|
675
|
+
}), L || z(document, "morphOldChildrenRemoved", {
|
|
673
676
|
detail: kt
|
|
674
677
|
}), u();
|
|
675
678
|
}, (parseFloat(he) || 0) * 1e3 + 10);
|
|
@@ -681,19 +684,19 @@ const ut = class ut {
|
|
|
681
684
|
) : document.documentElement.style.setProperty(
|
|
682
685
|
"--new-document-scroll-position",
|
|
683
686
|
this.scrollValue.top + "px"
|
|
684
|
-
),
|
|
687
|
+
), z(document, "morphBeforeNavigationScroll", {
|
|
685
688
|
detail: v.scrollState
|
|
686
689
|
}), d.hash ? (v.clearScrollState(), E(this, m, Xt).call(this, d.hash, {
|
|
687
690
|
centerScroll: i,
|
|
688
691
|
offsetScroll: n,
|
|
689
692
|
behavior: S
|
|
690
|
-
})) : t(this, $) ? v.restoreScrollPosition() : dt || v.renewScrollPosition(), yield Promise.all(t(this, Y)), L || jt.forEach((r) => r.remove()), o(this, Y, []),
|
|
691
|
-
r.querySelectorAll("script").forEach((
|
|
692
|
-
|
|
693
|
+
})) : t(this, $) ? v.restoreScrollPosition() : dt || v.renewScrollPosition(), yield Promise.all(t(this, Y)), L || jt.forEach((r) => r.remove()), o(this, Y, []), xt.forEach((r) => {
|
|
694
|
+
r.querySelectorAll("script").forEach((T) => {
|
|
695
|
+
T.replaceWith(E(this, m, Vt).call(this, T));
|
|
693
696
|
});
|
|
694
697
|
}), t(this, y).forEach((r) => {
|
|
695
698
|
r.checkCurrent(t(this, f).path);
|
|
696
|
-
}), this.findParamsDependent(),
|
|
699
|
+
}), this.findParamsDependent(), z(document, "morphComplete", {
|
|
697
700
|
detail: wt
|
|
698
701
|
}), document.documentElement.style.removeProperty(
|
|
699
702
|
"--new-document-scroll-position"
|
|
@@ -705,7 +708,7 @@ const ut = class ut {
|
|
|
705
708
|
});
|
|
706
709
|
}
|
|
707
710
|
addLink(e) {
|
|
708
|
-
t(this, y).push(new
|
|
711
|
+
t(this, y).push(new It(e, this));
|
|
709
712
|
}
|
|
710
713
|
addLinks(e) {
|
|
711
714
|
e.forEach((s) => {
|
|
@@ -723,14 +726,14 @@ const ut = class ut {
|
|
|
723
726
|
t(this, bt)
|
|
724
727
|
);
|
|
725
728
|
t(this, y).push(
|
|
726
|
-
...s.map((i) => new
|
|
729
|
+
...s.map((i) => new It(i, this))
|
|
727
730
|
);
|
|
728
731
|
}
|
|
729
732
|
findLinks() {
|
|
730
733
|
const e = [
|
|
731
734
|
...document.documentElement.querySelectorAll("a")
|
|
732
735
|
].filter(t(this, bt));
|
|
733
|
-
t(this, y).forEach((s) => s.destroy()), o(this, y, e.map((s) => new
|
|
736
|
+
t(this, y).forEach((s) => s.destroy()), o(this, y, e.map((s) => new It(s, this)));
|
|
734
737
|
}
|
|
735
738
|
findParamsDependent() {
|
|
736
739
|
const e = [
|
|
@@ -743,7 +746,7 @@ const ut = class ut {
|
|
|
743
746
|
));
|
|
744
747
|
}
|
|
745
748
|
};
|
|
746
|
-
N = new WeakMap(), rt = new WeakMap(), y = new WeakMap(), K = new WeakMap(), f = new WeakMap(), _ = new WeakMap(), Y = new WeakMap(), $ = new WeakMap(),
|
|
749
|
+
N = new WeakMap(), rt = new WeakMap(), y = new WeakMap(), K = new WeakMap(), f = new WeakMap(), _ = new WeakMap(), Y = new WeakMap(), $ = new WeakMap(), U = new WeakMap(), Et = new WeakMap(), V = new WeakMap(), Lt = new WeakMap(), tt = new WeakMap(), ot = new WeakMap(), ht = new WeakMap(), St = new WeakMap(), lt = new WeakMap(), vt = new WeakMap(), m = new WeakSet(), Vt = function(e) {
|
|
747
750
|
const s = document.createElement("script");
|
|
748
751
|
for (let i = 0; i < e.attributes.length; i++) {
|
|
749
752
|
const n = e.attributes[i];
|
|
@@ -773,14 +776,14 @@ N = new WeakMap(), rt = new WeakMap(), y = new WeakMap(), K = new WeakMap(), f =
|
|
|
773
776
|
return e.tagName === "SCRIPT" || e.tagName === "STYLE" || e.tagName === "LINK" && e.getAttribute("rel") === "stylesheet";
|
|
774
777
|
}, Bt = function(e) {
|
|
775
778
|
var s, i;
|
|
776
|
-
(s = t(this,
|
|
779
|
+
(s = t(this, U)) == null || s.removeEventListener(
|
|
777
780
|
"scroll",
|
|
778
781
|
t(this, ct)
|
|
779
|
-
), o(this, ht, 0), o(this, ot, 0), o(this,
|
|
782
|
+
), o(this, ht, 0), o(this, ot, 0), o(this, U, t(this, N).scrollSelector && e.querySelector(t(this, N).scrollSelector) || window), o(this, Et, t(this, U) === window), (i = t(this, U)) == null || i.addEventListener("scroll", t(this, ct)), t(this, ct).call(this);
|
|
780
783
|
}, Xt = function(e, s) {
|
|
781
784
|
const i = typeof e == "string" ? document.getElementById(e) : e;
|
|
782
785
|
(typeof i == "number" || i) && ge(i, {
|
|
783
|
-
scrollElement: t(this,
|
|
786
|
+
scrollElement: t(this, U),
|
|
784
787
|
behavior: (s == null ? void 0 : s.behavior) || "instant",
|
|
785
788
|
center: s == null ? void 0 : s.centerScroll,
|
|
786
789
|
offset: s == null ? void 0 : s.offsetScroll
|