aptechka 0.78.7 → 0.79.0
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/{DragControls-B7q22wzw.js → DragControls-DyIrD3GV.js} +36 -36
- package/lib/DragControls-K67-diF5.cjs +1 -0
- package/lib/controls/index.cjs +1 -1
- package/lib/controls/index.js +1 -1
- package/lib/morph/Morph.d.ts +1 -0
- package/lib/morph/MorphRoute.d.ts +1 -0
- package/lib/morph/index.cjs +1 -1
- package/lib/morph/index.js +274 -266
- package/lib/scroll/index.cjs +1 -1
- package/lib/scroll/index.js +5 -10
- package/lib/scroll-kit/index.cjs +1 -1
- package/lib/scroll-kit/index.js +32 -38
- package/package.json +1 -1
- package/lib/DragControls-tVaq-vIe.cjs +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
var _ = (
|
|
2
|
-
throw TypeError(
|
|
1
|
+
var _ = (n) => {
|
|
2
|
+
throw TypeError(n);
|
|
3
3
|
};
|
|
4
|
-
var G = (
|
|
5
|
-
var t = (
|
|
4
|
+
var G = (n, r, e) => r.has(n) || _("Cannot " + e);
|
|
5
|
+
var t = (n, r, e) => (G(n, r, "read from private field"), e ? e.call(n) : r.get(n)), s = (n, r, e) => r.has(n) ? _("Cannot add the same private member more than once") : r instanceof WeakSet ? r.add(n) : r.set(n, e), i = (n, r, e, h) => (G(n, r, "write to private field"), h ? h.call(n, e) : r.set(n, e), e), A = (n, r, e) => (G(n, r, "access private method"), e);
|
|
6
6
|
import { i as b } from "./index-Bv9zgfdb.js";
|
|
7
7
|
import { g as Z } from "./dom-CVWzyXPH.js";
|
|
8
8
|
import "construct-style-sheets-polyfill";
|
|
@@ -13,49 +13,49 @@ import { T as te } from "./Tweened-BlZB0vl4.js";
|
|
|
13
13
|
import { s as ie } from "./gestures-CcXV6fCp.js";
|
|
14
14
|
import { p as se } from "./number-CumqY64S.js";
|
|
15
15
|
import { TICK_ORDER as he } from "./order/index.js";
|
|
16
|
-
import { Notifier as
|
|
16
|
+
import { Notifier as ne } from "./notifier/index.js";
|
|
17
17
|
var V;
|
|
18
18
|
class j {
|
|
19
19
|
constructor() {
|
|
20
|
-
s(this, V, new
|
|
20
|
+
s(this, V, new ne());
|
|
21
21
|
}
|
|
22
22
|
get changeEvent() {
|
|
23
23
|
return t(this, V);
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
V = new WeakMap();
|
|
27
|
-
var
|
|
28
|
-
class
|
|
27
|
+
var y, c, u, X;
|
|
28
|
+
class ye extends j {
|
|
29
29
|
constructor(e) {
|
|
30
30
|
super();
|
|
31
|
-
s(this,
|
|
31
|
+
s(this, y, null);
|
|
32
32
|
s(this, c, null);
|
|
33
33
|
s(this, u, "offsetHeight");
|
|
34
34
|
s(this, X, (e) => {
|
|
35
35
|
const h = e.shiftKey ? -1 : 1;
|
|
36
|
-
let
|
|
37
|
-
e.code === "Space" ?
|
|
36
|
+
let a;
|
|
37
|
+
e.code === "Space" ? a = h * t(this, c)[t(this, u)] * 0.4 : e.code === "ArrowLeft" ? a = -1 * t(this, c)[t(this, u)] * 0.2 : e.code === "ArrowRight" ? a = 1 * t(this, c)[t(this, u)] * 0.2 : e.code === "ArrowUp" ? a = -1 * t(this, c)[t(this, u)] * 0.2 : e.code === "ArrowDown" ? a = 1 * t(this, c)[t(this, u)] * 0.2 : e.code === "PageUp" ? a = -1 * t(this, c)[t(this, u)] : e.code === "PageDown" ? a = 1 * t(this, c)[t(this, u)] : e.code === "Home" ? a = 0 : e.code === "End" && (a = t(this, u) === "offsetWidth" ? t(this, c).scrollWidth : t(this, c).scrollHeight), a && (e.stopPropagation(), this.changeEvent.notify("keyboard", a, e));
|
|
38
38
|
});
|
|
39
|
-
b && (i(this,
|
|
39
|
+
b && (i(this, y, e != null && e.element && Z(e.element) || window), i(this, c, t(this, y) instanceof HTMLElement ? t(this, y) : document.documentElement), this.dimension = e == null ? void 0 : e.dimension);
|
|
40
40
|
}
|
|
41
41
|
set dimension(e) {
|
|
42
42
|
i(this, u, e === "width" ? "offsetWidth" : "offsetHeight");
|
|
43
43
|
}
|
|
44
44
|
connect() {
|
|
45
|
-
b && t(this,
|
|
45
|
+
b && t(this, y).addEventListener(
|
|
46
46
|
"keydown",
|
|
47
47
|
t(this, X)
|
|
48
48
|
);
|
|
49
49
|
}
|
|
50
50
|
disconnect() {
|
|
51
|
-
b && t(this,
|
|
51
|
+
b && t(this, y).removeEventListener(
|
|
52
52
|
"keydown",
|
|
53
53
|
t(this, X)
|
|
54
54
|
);
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
|
-
|
|
58
|
-
var E, M, Y, O, d, I,
|
|
57
|
+
y = new WeakMap(), c = new WeakMap(), u = new WeakMap(), X = new WeakMap();
|
|
58
|
+
var E, M, Y, O, d, I, f, w, Q, J, H, S, q;
|
|
59
59
|
class Ee extends j {
|
|
60
60
|
constructor(e) {
|
|
61
61
|
super();
|
|
@@ -66,11 +66,11 @@ class Ee extends j {
|
|
|
66
66
|
s(this, O);
|
|
67
67
|
s(this, d);
|
|
68
68
|
s(this, I);
|
|
69
|
-
s(this,
|
|
69
|
+
s(this, f);
|
|
70
70
|
s(this, H);
|
|
71
71
|
s(this, S);
|
|
72
72
|
s(this, q);
|
|
73
|
-
this.direction = 1, i(this, d, new te(0, { easing: ee })), i(this,
|
|
73
|
+
this.direction = 1, i(this, d, new te(0, { easing: ee })), i(this, f, !1), i(this, H, (h) => {
|
|
74
74
|
t(this, d).current !== 1 && this.changeEvent.notify(
|
|
75
75
|
"autoplay",
|
|
76
76
|
h.timeBetweenFrames * t(this, E) * this.direction * (1 - t(this, d).current),
|
|
@@ -87,19 +87,19 @@ class Ee extends j {
|
|
|
87
87
|
}), i(this, E, (e == null ? void 0 : e.speed) || 1), i(this, M, (e == null ? void 0 : e.interval) || !1), i(this, Y, e);
|
|
88
88
|
}
|
|
89
89
|
set interval(e) {
|
|
90
|
-
i(this, M, e), t(this,
|
|
90
|
+
i(this, M, e), t(this, f) && A(this, w, Q).call(this);
|
|
91
91
|
}
|
|
92
92
|
set speed(e) {
|
|
93
|
-
i(this, E, e), t(this,
|
|
93
|
+
i(this, E, e), t(this, f) && A(this, w, Q).call(this);
|
|
94
94
|
}
|
|
95
95
|
connect() {
|
|
96
|
-
t(this,
|
|
96
|
+
t(this, f) || (i(this, f, !0), A(this, w, Q).call(this));
|
|
97
97
|
}
|
|
98
98
|
disconnect() {
|
|
99
|
-
t(this,
|
|
99
|
+
t(this, f) && (i(this, f, !1), A(this, w, J).call(this));
|
|
100
100
|
}
|
|
101
101
|
pauseAndContinue(e, h) {
|
|
102
|
-
t(this,
|
|
102
|
+
t(this, f) && e && (clearTimeout(t(this, I)), t(this, d).set(1, {
|
|
103
103
|
duration: Math.min(e, 1e3),
|
|
104
104
|
equalize: h
|
|
105
105
|
}), i(this, I, setTimeout(() => {
|
|
@@ -110,7 +110,7 @@ class Ee extends j {
|
|
|
110
110
|
}, e)));
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
|
-
E = new WeakMap(), M = new WeakMap(), Y = new WeakMap(), O = new WeakMap(), d = new WeakMap(), I = new WeakMap(),
|
|
113
|
+
E = new WeakMap(), M = new WeakMap(), Y = new WeakMap(), O = new WeakMap(), d = new WeakMap(), I = new WeakMap(), f = new WeakMap(), w = new WeakSet(), Q = function() {
|
|
114
114
|
A(this, w, J).call(this), t(this, M) ? i(this, O, setInterval(
|
|
115
115
|
t(this, S),
|
|
116
116
|
Math.abs(t(this, E))
|
|
@@ -133,9 +133,9 @@ class xe extends j {
|
|
|
133
133
|
s(this, P);
|
|
134
134
|
s(this, B, (e) => {
|
|
135
135
|
let h = 0;
|
|
136
|
-
const
|
|
137
|
-
if (!(this.axis === "x" &&
|
|
138
|
-
if (h = (this.axis === "max" ?
|
|
136
|
+
const a = Math.abs(e.deltaY), g = Math.abs(e.deltaX);
|
|
137
|
+
if (!(this.axis === "x" && a > g || this.axis === "y" && g > a) && (e.preventDefault(), !(this.debounce && this.axis === "x" && g < 5 || this.debounce && this.axis === "y" && a < 5)))
|
|
138
|
+
if (h = (this.axis === "max" ? g > a ? e.deltaX : e.deltaY : this.axis === "x" ? e.deltaX : e.deltaY) * this.speed, e.stopPropagation(), this.debounce) {
|
|
139
139
|
const R = Date.now();
|
|
140
140
|
if (R - t(this, P) > 40 && (h = 100 * Math.sign(h)), i(this, P, R), Math.abs(h) < 100 || t(this, k))
|
|
141
141
|
return;
|
|
@@ -180,22 +180,22 @@ const v = class v extends j {
|
|
|
180
180
|
Math.abs(t(this, x)) > 2 && h.preventDefault();
|
|
181
181
|
}), i(this, N, (h) => {
|
|
182
182
|
if (i(this, x, 0), i(this, l, 0), h.button !== 0 || h.composedPath().find(
|
|
183
|
-
(
|
|
183
|
+
(m) => m instanceof HTMLElement && m.hasAttribute("drag-dead-zone")
|
|
184
184
|
))
|
|
185
185
|
return;
|
|
186
186
|
this.swipe || D.unsubscribe(t(this, L));
|
|
187
|
-
let
|
|
187
|
+
let a = h, g = !1;
|
|
188
188
|
document.documentElement.classList.add("grabbing");
|
|
189
189
|
let R = 0, $ = 0, F = 0, U = 0;
|
|
190
190
|
ie(
|
|
191
|
-
(
|
|
192
|
-
t(v, T) && t(v, T) !== t(this, o) || (R =
|
|
191
|
+
(m) => {
|
|
192
|
+
t(v, T) && t(v, T) !== t(this, o) || (R = a.x - m.x, $ = a.y - m.y, F = m.x - h.x, U = m.y - h.y, this.axis === "x" ? (i(this, x, F), i(this, l, R)) : (i(this, x, U), i(this, l, $)), a = m, g = this.axis === "x" && Math.abs(F) > Math.abs(U) || this.axis === "y" && Math.abs(U) > Math.abs(F), g && (document.documentElement.classList.add("dragging"), document.documentElement.classList.add("click-disabled"), i(v, T, t(this, o)), this.changeEvent.notify("drag", t(this, l), m)));
|
|
193
193
|
},
|
|
194
|
-
(
|
|
195
|
-
i(v, T, null),
|
|
194
|
+
(m) => {
|
|
195
|
+
i(v, T, null), g && (!this.swipe && this.inertion ? (i(this, l, t(this, l) * this.inertion), D.subscribe(t(this, L), {
|
|
196
196
|
order: he.CONTROLS - 1
|
|
197
|
-
})) : this.swipe && this.changeEvent.notify("drag-end", t(this, l),
|
|
198
|
-
document.documentElement.classList.remove("click-disabled");
|
|
197
|
+
})) : this.swipe && this.changeEvent.notify("drag-end", t(this, l), m)), setTimeout(() => {
|
|
198
|
+
document.documentElement.classList.remove("grabbing"), document.documentElement.classList.remove("dragging"), document.documentElement.classList.remove("click-disabled");
|
|
199
199
|
});
|
|
200
200
|
}
|
|
201
201
|
);
|
|
@@ -223,6 +223,6 @@ export {
|
|
|
223
223
|
Ee as A,
|
|
224
224
|
j as C,
|
|
225
225
|
p as D,
|
|
226
|
-
|
|
226
|
+
ye as K,
|
|
227
227
|
xe as W
|
|
228
228
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var p=n=>{throw TypeError(n)};var G=(n,a,e)=>a.has(n)||p("Cannot "+e);var t=(n,a,e)=>(G(n,a,"read from private field"),e?e.call(n):a.get(n)),s=(n,a,e)=>a.has(n)?p("Cannot add the same private member more than once"):a instanceof WeakSet?a.add(n):a.set(n,e),i=(n,a,e,h)=>(G(n,a,"write to private field"),h?h.call(n,e):a.set(n,e),e),T=(n,a,e)=>(G(n,a,"access private method"),e);const w=require("./index-DekP7OZe.cjs"),_=require("./dom-JBOkFLTh.cjs");require("construct-style-sheets-polyfill");const B=require("./ticker/index.cjs");require("./Store-Cd1GlEmZ.cjs");const ee=require("./easings-GegIwET5.cjs"),te=require("./Tweened-mvHucL4Y.cjs"),ie=require("./gestures-C7gbKx11.cjs"),se=require("./number-ChAm68cm.cjs"),he=require("./order/index.cjs"),ne=require("./notifier/index.cjs");var j;class F{constructor(){s(this,j,new ne.Notifier)}get changeEvent(){return t(this,j)}}j=new WeakMap;var y,c,u,R;class re extends F{constructor(e){super();s(this,y,null);s(this,c,null);s(this,u,"offsetHeight");s(this,R,e=>{const h=e.shiftKey?-1:1;let r;e.code==="Space"?r=h*t(this,c)[t(this,u)]*.4:e.code==="ArrowLeft"?r=-1*t(this,c)[t(this,u)]*.2:e.code==="ArrowRight"?r=1*t(this,c)[t(this,u)]*.2:e.code==="ArrowUp"?r=-1*t(this,c)[t(this,u)]*.2:e.code==="ArrowDown"?r=1*t(this,c)[t(this,u)]*.2:e.code==="PageUp"?r=-1*t(this,c)[t(this,u)]:e.code==="PageDown"?r=1*t(this,c)[t(this,u)]:e.code==="Home"?r=0:e.code==="End"&&(r=t(this,u)==="offsetWidth"?t(this,c).scrollWidth:t(this,c).scrollHeight),r&&(e.stopPropagation(),this.changeEvent.notify("keyboard",r,e))});w.isBrowser&&(i(this,y,e!=null&&e.element&&_.getElement(e.element)||window),i(this,c,t(this,y)instanceof HTMLElement?t(this,y):document.documentElement),this.dimension=e==null?void 0:e.dimension)}set dimension(e){i(this,u,e==="width"?"offsetWidth":"offsetHeight")}connect(){w.isBrowser&&t(this,y).addEventListener("keydown",t(this,R))}disconnect(){w.isBrowser&&t(this,y).removeEventListener("keydown",t(this,R))}}y=new WeakMap,c=new WeakMap,u=new WeakMap,R=new WeakMap;var E,v,X,Y,d,A,m,b,V,J,D,O,I;class ae extends F{constructor(e){super();s(this,b);s(this,E);s(this,v);s(this,X);s(this,Y);s(this,d);s(this,A);s(this,m);s(this,D);s(this,O);s(this,I);this.direction=1,i(this,d,new te.Tweened(0,{easing:ee.easeInQuad})),i(this,m,!1),i(this,D,h=>{t(this,d).current!==1&&this.changeEvent.notify("autoplay",h.timeBetweenFrames*t(this,E)*this.direction*(1-t(this,d).current),h)}),i(this,O,()=>{t(this,d).current!==1&&this.changeEvent.notify("autoplay",Math.sign(t(this,E))*this.direction*(1-t(this,d).current),null)}),i(this,I,()=>{t(this,v)&&(document.hidden?t(this,d).set(1,{equalize:!0}):t(this,d).set(0,{equalize:!0}))}),i(this,E,(e==null?void 0:e.speed)||1),i(this,v,(e==null?void 0:e.interval)||!1),i(this,X,e)}set interval(e){i(this,v,e),t(this,m)&&T(this,b,V).call(this)}set speed(e){i(this,E,e),t(this,m)&&T(this,b,V).call(this)}connect(){t(this,m)||(i(this,m,!0),T(this,b,V).call(this))}disconnect(){t(this,m)&&(i(this,m,!1),T(this,b,J).call(this))}pauseAndContinue(e,h){t(this,m)&&e&&(clearTimeout(t(this,A)),t(this,d).set(1,{duration:Math.min(e,1e3),equalize:h}),i(this,A,setTimeout(()=>{t(this,d).set(0,{duration:Math.min(e,5e3),equalize:h})},e)))}}E=new WeakMap,v=new WeakMap,X=new WeakMap,Y=new WeakMap,d=new WeakMap,A=new WeakMap,m=new WeakMap,b=new WeakSet,V=function(){T(this,b,J).call(this),t(this,v)?i(this,Y,setInterval(t(this,O),Math.abs(t(this,E)))):B.ticker.subscribe(t(this,D),t(this,X)),document.addEventListener("visibilitychange",t(this,I))},J=function(){clearInterval(t(this,Y)),B.ticker.unsubscribe(t(this,D)),clearTimeout(t(this,A)),t(this,d).close(),document.removeEventListener("visibilitychange",t(this,I))},D=new WeakMap,O=new WeakMap,I=new WeakMap;var H,M,z,S;class le extends F{constructor(e){super();s(this,H,null);s(this,M);s(this,z);s(this,S,e=>{let h=0;const r=Math.abs(e.deltaY),g=Math.abs(e.deltaX);if(!(this.axis==="x"&&r>g||this.axis==="y"&&g>r)&&(e.preventDefault(),!(this.debounce&&this.axis==="x"&&g<5||this.debounce&&this.axis==="y"&&r<5)))if(h=(this.axis==="max"?g>r?e.deltaX:e.deltaY:this.axis==="x"?e.deltaX:e.deltaY)*this.speed,e.stopPropagation(),this.debounce){const N=Date.now();if(N-t(this,z)>40&&(h=100*Math.sign(h)),i(this,z,N),Math.abs(h)<100||t(this,M))return;this.changeEvent.notify("wheel",h,e),i(this,M,setTimeout(()=>{i(this,M,void 0)},80))}else this.changeEvent.notify("wheel",h,e)});this.axis=(e==null?void 0:e.axis)||"y",this.speed=(e==null?void 0:e.speed)||1,this.debounce=(e==null?void 0:e.debounce)||!1,i(this,z,Date.now()),w.isBrowser&&i(this,H,e!=null&&e.element&&_.getElement(e.element)||window)}connect(){w.isBrowser&&t(this,H).addEventListener("wheel",t(this,S),{passive:!1})}disconnect(){w.isBrowser&&(t(this,H).removeEventListener("wheel",t(this,S)),clearTimeout(t(this,M)))}}H=new WeakMap,M=new WeakMap,z=new WeakMap,S=new WeakMap;var q,P,o,l,C,x,W,K,L;const k=class k extends F{constructor(e){super();s(this,P);s(this,o);s(this,l);s(this,C);s(this,x);s(this,W);s(this,K);s(this,L);this.inertion=1,i(this,P,null),i(this,o,null),i(this,l,0),i(this,C,[]),i(this,x,0),i(this,W,h=>{Math.abs(t(this,x))>2&&h.preventDefault()}),i(this,K,h=>{if(i(this,x,0),i(this,l,0),h.button!==0||h.composedPath().find(f=>f instanceof HTMLElement&&f.hasAttribute("drag-dead-zone")))return;this.swipe||B.ticker.unsubscribe(t(this,L));let r=h,g=!1;document.documentElement.classList.add("grabbing");let N=0,$=0,U=0,Q=0;ie.setupDrag(f=>{t(k,q)&&t(k,q)!==t(this,o)||(N=r.x-f.x,$=r.y-f.y,U=f.x-h.x,Q=f.y-h.y,this.axis==="x"?(i(this,x,U),i(this,l,N)):(i(this,x,Q),i(this,l,$)),r=f,g=this.axis==="x"&&Math.abs(U)>Math.abs(Q)||this.axis==="y"&&Math.abs(Q)>Math.abs(U),g&&(document.documentElement.classList.add("dragging"),document.documentElement.classList.add("click-disabled"),i(k,q,t(this,o)),this.changeEvent.notify("drag",t(this,l),f)))},f=>{i(k,q,null),g&&(!this.swipe&&this.inertion?(i(this,l,t(this,l)*this.inertion),B.ticker.subscribe(t(this,L),{order:he.TICK_ORDER.CONTROLS-1})):this.swipe&&this.changeEvent.notify("drag-end",t(this,l),f)),setTimeout(()=>{document.documentElement.classList.remove("grabbing"),document.documentElement.classList.remove("dragging"),document.documentElement.classList.remove("click-disabled")})})}),i(this,L,()=>{Math.floor(Math.abs(t(this,l)))||B.ticker.unsubscribe(t(this,L)),i(this,l,t(this,l)*.95),i(this,l,se.preciseNumber(t(this,l),3)),this.changeEvent.notify("drag",t(this,l),null)}),this.axis=(e==null?void 0:e.axis)||"y",this.swipe=(e==null?void 0:e.swipe)||!1,w.isBrowser&&(i(this,o,e!=null&&e.element&&_.getElement(e.element)||document.documentElement),i(this,P,(e==null?void 0:e.rootElement)||t(this,o)))}connect(){w.isBrowser&&(i(this,C,[...t(this,P).querySelectorAll("a")]),t(this,C).forEach(e=>{e.addEventListener("click",t(this,W))}),t(this,o).addEventListener("pointerdown",t(this,K)))}disconnect(){w.isBrowser&&(t(this,C).forEach(e=>{e.removeEventListener("click",t(this,W))}),t(this,o).removeEventListener("pointerdown",t(this,K)),B.ticker.unsubscribe(t(this,L)))}};q=new WeakMap,P=new WeakMap,o=new WeakMap,l=new WeakMap,C=new WeakMap,x=new WeakMap,W=new WeakMap,K=new WeakMap,L=new WeakMap,s(k,q,null);let Z=k;exports.AutoplayControls=ae;exports.Controls=F;exports.DragControls=Z;exports.KeyboardControls=re;exports.WheelControls=le;
|
package/lib/controls/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../DragControls-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../DragControls-K67-diF5.cjs");exports.AutoplayControls=o.AutoplayControls;exports.Controls=o.Controls;exports.DragControls=o.DragControls;exports.KeyboardControls=o.KeyboardControls;exports.WheelControls=o.WheelControls;
|
package/lib/controls/index.js
CHANGED
package/lib/morph/Morph.d.ts
CHANGED
|
@@ -99,6 +99,7 @@ export declare class Morph {
|
|
|
99
99
|
prefetch(path: string, revalidate?: boolean): Promise<void>;
|
|
100
100
|
excludeHeadChild(child: Node): boolean;
|
|
101
101
|
setHeaders(path: string): void;
|
|
102
|
+
needRavalidation(path: string): void;
|
|
102
103
|
navigate(path: string, { historyAction, centerScroll, offsetScroll, scrollBehaviour, revalidate, keepSearchParameters, submorph, submorphAppend, clearState, keepScrollPosition, mergeParams, }?: MorphNavigateOptions): Promise<void>;
|
|
103
104
|
addLink(element: HTMLAnchorElement): void;
|
|
104
105
|
addLinks(elements: Array<HTMLAnchorElement>): void;
|
|
@@ -14,6 +14,7 @@ export declare class MorphRoute {
|
|
|
14
14
|
get pathname(): string;
|
|
15
15
|
get scrollState(): MorphRouteScrollState;
|
|
16
16
|
get document(): Document;
|
|
17
|
+
needRavalidation(): void;
|
|
17
18
|
setHeaders(headers: HeadersInit): void;
|
|
18
19
|
setInitialDocument(document: Document): void;
|
|
19
20
|
abort(): void | undefined;
|
package/lib/morph/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var fe=Object.defineProperty,ge=Object.defineProperties;var Ee=Object.getOwnPropertyDescriptors;var Zt=Object.getOwnPropertySymbols;var be=Object.prototype.hasOwnProperty,ve=Object.prototype.propertyIsEnumerable;var _t=(h,e)=>(e=Symbol[h])?e:Symbol.for("Symbol."+h),ee=h=>{throw TypeError(h)};var te=(h,e,s)=>e in h?fe(h,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):h[e]=s,Rt=(h,e)=>{for(var s in e||(e={}))be.call(e,s)&&te(h,s,e[s]);if(Zt)for(var s of Zt(e))ve.call(e,s)&&te(h,s,e[s]);return h},qt=(h,e)=>ge(h,Ee(e));var Dt=(h,e,s)=>e.has(h)||ee("Cannot "+s);var t=(h,e,s)=>(Dt(h,e,"read from private field"),s?s.call(h):e.get(h)),l=(h,e,s)=>e.has(h)?ee("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(h):e.set(h,s),o=(h,e,s,a)=>(Dt(h,e,"write to private field"),a?a.call(h,s):e.set(h,s),s),E=(h,e,s)=>(Dt(h,e,"access private method"),s);var G=(h,e,s)=>new Promise((a,n)=>{var b=d=>{try{u(s.next(d))}catch(v){n(v)}},f=d=>{try{u(s.throw(d))}catch(v){n(v)}},u=d=>d.done?a(d.value):Promise.resolve(d.value).then(b,f);u((s=s.apply(h,e)).next())});var se=(h,e,s)=>(e=h[_t("asyncIterator")])?e.call(h):(h=h[_t("iterator")](),e={},s=(a,n)=>(n=h[a])&&(e[a]=b=>new Promise((f,u,d)=>(b=n.call(h,b),d=b.done,Promise.resolve(b.value).then(v=>f({value:v,done:d}),u)))),s("next"),s("return"),e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ne=require("../index-DekP7OZe.cjs"),D=require("../events-KVanG9sR.cjs"),ie=require("../scroll-CIdNtj3G.cjs");require("construct-style-sheets-polyfill");const mt=require("../url-VIZgwj_h.cjs"),re=require("../string-DUXXtU8v.cjs"),Le=require("../math-GDWEqu7y.cjs"),Se=require("../css-value-parser/index.cjs");class oe 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,a]of Object.entries(e))this.setAttribute(s,a)}}ne.isBrowser&&!customElements.get("morph-announcer")&&customElements.define("morph-announcer",oe);var R,i,x,at,xt,he,ft,nt;class zt{constructor(e,s){l(this,x);l(this,R);l(this,i);l(this,ft,e=>{e.preventDefault(),E(this,x,he).call(this)});l(this,nt,()=>{const e=t(this,i).hasAttribute("data-revalidate");t(this,R).prefetch(t(this,x,at),e),t(this,i).removeEventListener("pointerenter",t(this,nt))});o(this,R,s),o(this,i,e),t(this,i).addEventListener("click",t(this,ft)),this.checkCurrent(location.href.replace(location.origin,""));const a=E(this,x,xt).call(this,t(this,i).getAttribute("data-pagination-set-link")||t(this,i).getAttribute("data-pagination-more-link")||t(this,i).getAttribute("data-pagination-next-link")||t(this,i).getAttribute("data-pagination-prev-link"));a&&this.updatePagination(a.currentPage,a.selector),t(this,i).hasAttribute("data-prefetch")&&t(this,i).addEventListener("pointerenter",t(this,nt))}get element(){return t(this,i)}checkCurrent(e){var v,et;const s=t(this,R).normalizePath(e),a=t(this,R).normalizePath(t(this,x,at));t(this,i).hasAttribute("data-include")&&s.pathname.includes(a.pathname)?t(this,i).classList.add("current"):a.pathname===s.pathname?t(this,i).classList.add("current"):(v=t(this,i).getAttribute("data-associated-paths"))!=null&&v.split(",").find(w=>s.pathname.includes(w))?t(this,i).classList.add("current"):t(this,i).classList.remove("current"),s.path===a.path?t(this,i).classList.add("exact"):t(this,i).classList.remove("exact");const[n,b]=(et=t(this,x,at).split("#")[0])==null?void 0:et.split("?"),f=new URLSearchParams(b),u=new URLSearchParams(location.search);let d=0;for(const[w]of u)f.has(w)&&u.get(w)===f.get(w)&&d++;d?(t(this,i).classList.toggle("all-params-matched",u.size===d),t(this,i).classList.toggle("some-params-matched",u.size!==d)):!u.size&&t(this,i).hasAttribute("data-match-no-params")?t(this,i).classList.add("all-params-matched"):(t(this,i).classList.remove("all-params-matched"),t(this,i).classList.remove("some-params-matched"));for(const w in t(this,i).dataset){const st=re.camelToKebab(w);if(st.startsWith("match-param-")){const $=st.split("match-param-")[1],S=t(this,i).dataset[w],c=`param-${$}-matched`;u.has($)&&u.get($)===S||!u.has($)&&(S===""||S==="*"||S==="all"||S==="any"||S==="vse")?t(this,i).classList.add(c):t(this,i).classList.remove(c)}}}updatePagination(e,s){const a=E(this,x,xt).call(this,s);if(a)if(a.element.setAttribute("data-current-page",e.toString()),t(this,i).hasAttribute("data-pagination-more-link"))if(e<a.totalPages){t(this,i).style.display="";const n=t(this,i).querySelector("[data-pagination-more-link-counter]");n&&(n.textContent=(a.totalPages-e).toString());const b=t(this,i).getAttribute("href"),f=new URL(b,window.location.origin);f.searchParams.set("page",(e+1).toString());const u=f.href.replace(f.origin,"").toString();t(this,i).setAttribute("href",u),this.checkCurrent(u)}else t(this,i).style.display="none";else if(t(this,i).hasAttribute("data-pagination-prev-link")||t(this,i).hasAttribute("data-pagination-next-link")){const n=t(this,i).hasAttribute("data-pagination-prev-link"),b=t(this,i).getAttribute("href"),f=new URL(b,window.location.origin),u=e+(n?-1:1);f.searchParams.set("page",Le.clamp(u,1,a.totalPages).toString());const d=f.href.replace(f.origin,"").toString();t(this,i).setAttribute("href",d),n?u<1?(t(this,i).classList.add("pagination-disabled"),t(this,i).setAttribute("tabindex","-1")):(t(this,i).classList.remove("pagination-disabled"),t(this,i).removeAttribute("tabindex")):u>a.totalPages?(t(this,i).classList.add("pagination-disabled"),t(this,i).setAttribute("tabindex","-1")):(t(this,i).classList.remove("pagination-disabled"),t(this,i).removeAttribute("tabindex"))}else t(this,i).hasAttribute("data-pagination-set-link")&&(t(this,i).getAttribute("data-value")===e.toString()?t(this,i).classList.add("pagination-current"):t(this,i).classList.remove("pagination-current"))}destroy(){t(this,i).removeEventListener("click",t(this,ft)),t(this,i).removeEventListener("pointerenter",t(this,nt)),t(this,i).classList.remove("current","exact","pagination-current")}}R=new WeakMap,i=new WeakMap,x=new WeakSet,at=function(){const e=new URL(t(this,i).href);return t(this,R).normalizePath(e.pathname+e.search+e.hash).path},xt=function(e){if(!e)return;const s=document.querySelector(e);if(s){const a=parseInt(s.getAttribute("data-current-page")||"1"),n=parseInt(s.getAttribute("data-total-pages")||"1");return{element:s,currentPage:a,totalPages:n,selector:e}}},he=function(){var s;if(document.documentElement.classList.contains("click-disabled"))return;if(t(this,i).hasAttribute("data-back")&&t(this,R).previousURL)history.back();else{const a=t(this,i).getAttribute("data-history-action")||"push",n=t(this,i).hasAttribute("data-center-scroll"),b=getComputedStyle(t(this,i)).getPropertyValue("--offset-scroll").trim(),f=b?Se.cssValueParser.parse(b):void 0,u=t(this,i).hasAttribute("data-revalidate")||t(this,i).hasAttribute("data-pagination-more-link")||t(this,i).hasAttribute("data-pagination-set-link")||t(this,i).hasAttribute("data-pagination-next-link")||t(this,i).hasAttribute("data-pagination-prev-link"),d=t(this,i).hasAttribute("data-keep-search-parameters"),v=t(this,i).hasAttribute("data-keep-scroll-position")||t(this,i).hasAttribute("data-pagination-more-link"),et=t(this,i).getAttribute("data-scroll-behaviour"),w=((s=t(this,i).getAttribute("data-submorph"))==null?void 0:s.split(",").map(c=>c.trim()))||t(this,i).hasAttribute("data-pagination-more-link")&&[t(this,i).getAttribute("data-pagination-more-link")]||t(this,i).hasAttribute("data-pagination-set-link")&&[t(this,i).getAttribute("data-pagination-set-link")]||t(this,i).hasAttribute("data-pagination-next-link")&&[t(this,i).getAttribute("data-pagination-next-link")]||t(this,i).hasAttribute("data-pagination-prev-link")&&[t(this,i).getAttribute("data-pagination-prev-link")]||void 0,st=t(this,i).hasAttribute("data-clear-state");let $=t(this,x,at);if(t(this,i).hasAttribute("data-toggle-params")){const[c,Pt]=t(this,x,at).split("?"),j=new URLSearchParams(Pt),V=new URLSearchParams(location.search),it=new URLSearchParams;for(const[y]of j)(!V.has(y)||V.has(y)&&V.get(y)!==j.get(y))&&it.append(y,j.get(y));if(t(this,i).hasAttribute("data-merge-params"))for(const[y]of V)j.has(y)||it.append(y,V.get(y));$=`${c}?${it.toString()}`}const S=E(this,x,xt).call(this,t(this,i).getAttribute("data-pagination-set-link")||t(this,i).getAttribute("data-pagination-more-link")||t(this,i).getAttribute("data-pagination-next-link")||t(this,i).getAttribute("data-pagination-prev-link"));S&&(t(this,i).hasAttribute("data-pagination-set-link")?t(this,R).links.forEach(c=>{c.updatePagination(parseInt(t(this,i).getAttribute("data-value")||"1"),S.selector)}):t(this,i).hasAttribute("data-pagination-prev-link")?t(this,R).links.forEach(c=>{c.updatePagination(S.currentPage-1,S.selector)}):t(this,i).hasAttribute("data-pagination-next-link")?t(this,R).links.forEach(c=>{c.updatePagination(S.currentPage+1,S.selector)}):t(this,i).hasAttribute("data-pagination-more-link")&&t(this,R).links.forEach(c=>{c.updatePagination(S.currentPage+1,S.selector)})),t(this,R).navigate($,{historyAction:a,centerScroll:n,offsetScroll:f,revalidate:u,keepSearchParameters:d,submorph:w,clearState:st,keepScrollPosition:v,scrollBehaviour:et,submorphAppend:t(this,i).hasAttribute("data-pagination-more-link"),mergeParams:!!S||t(this,i).hasAttribute("data-merge-params")&&!t(this,i).hasAttribute("data-toggle-params")})}},ft=new WeakMap,nt=new WeakMap;const ye=new DOMParser;var z,J,H,I,Q,F,rt,Z,B,gt;class ae{constructor(e,s){l(this,z);l(this,J);l(this,H,{x:0,y:0});l(this,I,null);l(this,Q,null);l(this,F,null);l(this,rt,null);l(this,Z,null);l(this,B,null);l(this,gt);o(this,z,e),o(this,J,s)}get pathname(){return t(this,J)}get scrollState(){return t(this,H)}get document(){return t(this,F)}setHeaders(e){o(this,gt,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,a){return G(this,null,function*(){var n;if(!a){const u=((n=t(this,I))==null?void 0:n.documentElement.getAttribute("data-cache"))&&s!==e,d=t(this,I)&&t(this,z).isPopstateNavigation;if(t(this,B)||u||d)return t(this,B)}return o(this,B,new Promise(b=>G(this,null,function*(){try{o(this,Z,new AbortController);const u=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,gt))})).text(),d=ye.parseFromString(u,"text/html");this.setInitialDocument(d)}catch(f){console.warn(f)}finally{o(this,Z,null),o(this,B,null),b()}}))),t(this,B)})}cloneDocument(){o(this,F,(t(this,Q)||t(this,I)).cloneNode(!0))}get title(){let e="";if(t(this,F).title)e=t(this,F).title;else{const s=t(this,F).querySelector("h1");e=(s==null?void 0:s.innerText)||(s==null?void 0:s.textContent)||t(this,J)}return e}clearScrollState(){t(this,H).x=0,t(this,H).y=0}clearDocumentState(){o(this,Q,null)}saveScrollState(){t(this,I).documentElement.hasAttribute("data-no-scroll-restoration")?(t(this,H).x=0,t(this,H).y=0):(t(this,H).x=t(this,z).scrollValue.left,t(this,H).y=t(this,z).scrollValue.top)}restoreScrollPosition(){t(this,z).scrollElement.scroll({top:t(this,H).y,left:t(this,H).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,rt,e)}clearState(){const e=t(this,rt);return o(this,rt,null),e}}z=new WeakMap,J=new WeakMap,H=new WeakMap,I=new WeakMap,Q=new WeakMap,F=new WeakMap,rt=new WeakMap,Z=new WeakMap,B=new WeakMap,gt=new WeakMap;var T,ot,Et,It,bt;class Ae{constructor(e){l(this,Et);l(this,T);l(this,ot,[]);l(this,bt,()=>{E(this,Et,It).call(this)});o(this,T,e);for(const s in t(this,T).dataset){const a=re.camelToKebab(s);if(a.startsWith("param-")){const n=a.split("param-")[1],b=t(this,T).dataset[s];t(this,ot).push({name:n,value:b})}}document.addEventListener("morphURLParametersChange",t(this,bt)),E(this,Et,It).call(this)}destroy(){document.removeEventListener("morphURLParametersChange",t(this,bt))}}T=new WeakMap,ot=new WeakMap,Et=new WeakSet,It=function(){const e=new URLSearchParams(location.search);let s=!!t(this,ot).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,T).hasAttribute("data-match-no-params")&&(s=!t(this,ot).filter(n=>e.has(n.name)).length);const a=t(this,T).getAttribute("data-hide-class");s?a?t(this,T).classList.remove(a):t(this,T).style.display="":a?t(this,T).classList.add(a):t(this,T).style.display="none"},bt=new WeakMap;var q,ht,P,K,g,_,X,Y,U,vt,W,Lt,tt,lt,ct,St,dt,yt,p,Vt,At,Ht,Ot,le,Ft,Bt,Kt,Xt,Tt,ut;const pt=class pt{constructor(e){l(this,p);l(this,q,null);l(this,ht,null);l(this,P,[]);l(this,K);l(this,g,null);l(this,_);l(this,X,[]);l(this,Y,!1);l(this,U,null);l(this,vt,!1);l(this,W,new Map);l(this,Lt,[]);l(this,tt,null);l(this,lt,0);l(this,ct,0);l(this,St);l(this,dt);l(this,yt);l(this,At,e=>{var s,a;return(((s=e.getAttribute("href"))==null?void 0:s.startsWith("/"))||((a=e.getAttribute("href"))==null?void 0:a.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,Y,!0),yield this.navigate(location.href.replace(location.origin,""),{historyAction:"none",submorph:t(this,dt)?void 0:t(this,St),revalidate:t(this,dt),keepScrollPosition:t(this,yt)}),o(this,Y,!1)}));l(this,ut,()=>{const{left:e,top:s}=this.scrollValue,a=s-t(this,ct),n=e-t(this,lt);o(this,ct,s),o(this,lt,e),document.documentElement.classList.toggle("scroll-y",s>0),document.documentElement.classList.toggle("scroll-x",e>0),document.documentElement.classList.toggle("scroll-y-forward",a>0),document.documentElement.classList.toggle("scroll-y-backward",a<0),document.documentElement.classList.toggle("scroll-x-forward",n>0),document.documentElement.classList.toggle("scroll-x-backward",n<0),D.dispatchEvent(document,"morphScroll",{detail:{left:e,top:s}})});if(ne.isBrowser&&!pt.instance){pt.instance=this,o(this,q,{base:mt.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,ht,E(this,p,Ot).call(this,document.body));const s=this.normalizePath(location.pathname+location.search+location.hash);o(this,g,s);const a=new ae(this,t(this,g).pathname);a.setInitialDocument(document),t(this,W).set(t(this,g).pathname,a),document.documentElement.setAttribute("data-current-pathname",t(this,g).pathname),document.documentElement.setAttribute("data-current-leaf",s.leaf),this.findLinks(),this.findParamsDependent(),history.scrollRestoration="manual",addEventListener("popstate",t(this,Tt)),mt.changeHistory({action:"replace",pathname:s.pathname,searchParameters:s.parameters,hash:s.hash}),o(this,tt,new oe),E(this,p,Kt).call(this,document)}}get currentURL(){return t(this,g)}get previousURL(){return t(this,_)}get links(){return t(this,P)}get scrollElement(){return t(this,U)}get isPopstateNavigation(){return t(this,Y)}get scrollValue(){let e=0,s=0;return t(this,vt)?(e=window.scrollY,s=window.scrollX):(e=t(this,U).scrollTop,s=t(this,U).scrollLeft),{top:e,left:s}}saveState(e){const s=t(this,W).get(t(this,g).path);s&&s.saveState(e)}getState(){const e=t(this,W).get(t(this,g).path);return e==null?void 0:e.clearState()}normalizePath(e,s){return mt.splitPath(e,{base:t(this,q).base,trailingSlash:t(this,q).trailingSlash,mergeParams:s!=null&&s.mergeParams?location.search:""})}prefetch(e,s){return G(this,null,function*(){var n;if(t(this,X).length)return;e=((n=this.pathnameModifier)==null?void 0:n.call(this,e))||e;const a=E(this,p,Ht).call(this,e);a==null||a.fetch(e,t(this,g).path,s)})}excludeHeadChild(e){return!1}setHeaders(e){}navigate($){return G(this,arguments,function*(e,{historyAction:s="push",centerScroll:a,offsetScroll:n,scrollBehaviour:b,revalidate:f,keepSearchParameters:u,submorph:d,submorphAppend:v,clearState:et,keepScrollPosition:w,mergeParams:st}={}){var Pt,j,V,it;if(t(this,X).length)return;o(this,St,d),o(this,dt,f),o(this,yt,w);const S=((Pt=this.pathnameModifier)==null?void 0:Pt.call(this,e))||e,c=this.normalizePath(S,{mergeParams:st});if(!f&&(((j=t(this,K))==null?void 0:j.pathname)===c.pathname||t(this,g).pathname===c.pathname)){w||E(this,p,Xt).call(this,c.hash||0,{centerScroll:a,offsetScroll:n,behavior:"smooth"}),D.dispatchEvent(document,"morphSamePath",{custom:!0}),((V=t(this,g))==null?void 0:V.parameters)!==c.parameters&&(o(this,_,t(this,g)),o(this,g,c),mt.changeHistory({action:((it=t(this,g))==null?void 0:it.hash)!==c.hash?"replace":s,pathname:c.pathname,searchParameters:c.parameters,hash:c.hash}),D.dispatchEvent(document,"morphURLParametersChange",{detail:{newURL:t(this,g),previousURL:t(this,_)}})),t(this,P).forEach(y=>{y.checkCurrent(c.path)});return}else t(this,P).forEach(y=>{y.checkCurrent(c.path)});o(this,K,c);try{let y=!0;if(this.preprocessor)try{yield new Promise((r,k)=>{var M;(M=this.preprocessor)==null||M.call(this,{url:c,resolve:r,reject:k,submorph:d})})}catch(r){r?console.error(r):console.log("Route change canceled"),y=!1}if(!y||t(this,K).pathname!==c.pathname){t(this,P).forEach(r=>{r.checkCurrent(t(this,g).path)});return}const Yt={url:c,submorph:d};d?v||d.forEach(r=>{document.querySelectorAll(r).forEach(k=>{k.classList.add("out"),k.setAttribute("data-morph-out","")})}):t(this,ht).forEach(r=>{var k,M;(k=r.firstElementChild)==null||k.classList.add("out"),(M=r.firstElementChild)==null||M.setAttribute("data-morph-out","")}),D.dispatchEvent(document,"morphNavigation",{detail:Yt});const Mt=E(this,p,Ht).call(this,t(this,g).pathname),A=E(this,p,Ht).call(this,c.pathname);if(t(this,W).forEach(r=>{r.pathname!==c.pathname&&r.abort()}),yield A==null?void 0:A.fetch(S,t(this,g).path,f),t(this,K).pathname!==c.pathname){t(this,P).forEach(r=>{r.checkCurrent(t(this,g).path)});return}Mt.clearState(),Mt.saveScrollState(),Mt.saveDocumentState(),(!t(this,Y)||f)&&(A.clearScrollState(),A.clearDocumentState()),et&&A.clearState(),A.cloneDocument(),t(this,tt).textContent=A.title,document.body.appendChild(t(this,tt));const kt=qt(Rt({},Yt),{document:A.document});v||kt.document.querySelectorAll("[data-morph-out]").forEach(r=>{r.classList.remove("out")}),D.dispatchEvent(document,"morphStart",{detail:kt});const $t=Array.from(document.head.children),jt=Array.from(A.document.head.children),Gt=E(this,p,le).call(this,$t,jt),ce=E(this,p,Ft).call(this,$t,Gt),wt=E(this,p,Ft).call(this,jt,Gt).filter(r=>!this.excludeHeadChild(r));wt.forEach((r,k)=>{r.tagName==="SCRIPT"&&(wt[k]=E(this,p,Vt).call(this,r))}),wt.forEach(r=>{document.head.appendChild(r)});const Ut=wt.filter(r=>{if(r.hasAttribute("data-no-waiting"))return!1;if(E(this,p,Bt).call(this,r))return!0});t(this,q).waitForHeadToLoad&&Ut.length&&(yield new Promise(r=>G(this,null,function*(){let k=0;try{for(var M=se(Ut),ue,O,N;ue=!(O=yield M.next()).done;ue=!1){const Ct=O.value;Ct.onload=()=>{k++,k===Ut.length&&r()}}}catch(O){N=[O]}finally{try{ue&&(O=M.return)&&(yield O.call(M))}finally{if(N)throw N[0]}}}))),yield ie.wait(10);const Jt=[];v||ce.forEach(r=>{r.hasAttribute("data-permanent")||(E(this,p,Bt).call(this,r)?Jt.push(r):r.remove())});const de=E(this,p,Ot).call(this,A.document.body);!t(this,q).morphInsideScrollContainer&&!d&&E(this,p,Kt).call(this,A.document),document.documentElement.setAttribute("data-current-pathname",c.pathname),document.documentElement.setAttribute("data-current-leaf",c.leaf),mt.changeHistory({action:s,pathname:c.pathname,searchParameters:c.parameters||(u?location.search:""),hash:c.hash}),t(this,tt).remove(),o(this,_,t(this,g)),o(this,g,c);const Nt=[];t(this,ht).forEach((r,k)=>{const M=de[k],ue=getComputedStyle(r).getPropertyValue("--morph-duration");let O=[],N=[];d?(d.forEach(m=>{const L=r.querySelector(m),C=M.querySelector(m);L&&C&&(N.push(L),O.push(C))}),N.forEach(m=>{m.parentElement&&Nt.push(m.parentElement)})):(O.push(...M.childNodes),N.push(...r.childNodes),Nt.push(r));const Ct=[];v||N.forEach(m=>{m instanceof HTMLElement&&(this.destroyOldLinks(m),m.classList.add("old"),m.querySelectorAll("[data-morph-transfer]").forEach(C=>{const pe=C.getAttribute("data-morph-transfer");Ct.push({element:C,selector:pe})}))}),O.forEach(m=>{m instanceof HTMLElement&&(Ct.forEach(L=>{const C=m.querySelector(L.selector);C&&C.replaceWith(A.document.importNode(L.element,!0))}),this.findNewLinks(m),m.classList.add("new"))}),d?v?O.forEach((m,L)=>{N[L]instanceof HTMLElement&&N[L].append(...m.childNodes)}):O.forEach((m,L)=>{var C;(C=N[L].parentElement)==null||C.insertBefore(m,N[L])}):r.prepend(...O),setTimeout(()=>{v||N.forEach(m=>{m instanceof HTMLElement&&m.classList.add("old-idle")}),O.forEach(m=>{var L;m instanceof HTMLElement&&((L=m.parentElement)==null||L.style.setProperty("--new-content-height",m.offsetHeight+"px"),m.classList.add("new-idle"))})},0);const Qt=qt(Rt({},kt),{morphElement:r});D.dispatchEvent(document,"morphNewChildrenAdded",{detail:Qt});const me=new Promise(m=>{setTimeout(()=>{v||N.forEach(L=>{L.remove()}),O.forEach(L=>{var C;L instanceof HTMLElement&&((C=L.parentElement)==null||C.style.removeProperty("--new-content-height"),L.classList.remove("new-idle","new"))}),v||D.dispatchEvent(document,"morphOldChildrenRemoved",{detail:Qt}),m()},(parseFloat(ue)||0)*1e3+10)});t(this,X).push(me)}),this.isPopstateNavigation?document.documentElement.style.setProperty("--new-document-scroll-position",(this.scrollValue.top-A.scrollState.y)*1+"px"):document.documentElement.style.setProperty("--new-document-scroll-position",this.scrollValue.top+"px"),D.dispatchEvent(document,"morphBeforeNavigationScroll",{detail:A.scrollState}),c.hash?(A.clearScrollState(),E(this,p,Xt).call(this,c.hash,{centerScroll:a,offsetScroll:n,behavior:b})):t(this,Y)?A.restoreScrollPosition():w||A.renewScrollPosition(),yield Promise.all(t(this,X)),v||Jt.forEach(r=>r.remove()),o(this,X,[]),Nt.forEach(r=>{r.querySelectorAll("script").forEach(M=>{M.replaceWith(E(this,p,Vt).call(this,M))})}),t(this,P).forEach(r=>{r.checkCurrent(t(this,g).path)}),this.findParamsDependent(),D.dispatchEvent(document,"morphComplete",{detail:kt}),document.documentElement.style.removeProperty("--new-document-scroll-position"),window.dispatchEvent(new Event("resize"))}catch(y){console.error(y)}o(this,K,void 0)})}addLink(e){t(this,P).push(new zt(e,this))}addLinks(e){e.forEach(s=>{this.addLink(s)})}removeLink(e){o(this,P,t(this,P).filter(s=>s.element===e?(s.destroy(),!1):!0))}destroyOldLinks(e){o(this,P,t(this,P).filter(s=>e.contains(s.element)?(s.destroy(),!1):!0))}findNewLinks(e){const s=[...e.querySelectorAll("a")].filter(t(this,At));t(this,P).push(...s.map(a=>new zt(a,this)))}findLinks(){const e=[...document.documentElement.querySelectorAll("a")].filter(t(this,At));t(this,P).forEach(s=>s.destroy()),o(this,P,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 Ae(s)))}};q=new WeakMap,ht=new WeakMap,P=new WeakMap,K=new WeakMap,g=new WeakMap,_=new WeakMap,X=new WeakMap,Y=new WeakMap,U=new WeakMap,vt=new WeakMap,W=new WeakMap,Lt=new WeakMap,tt=new WeakMap,lt=new WeakMap,ct=new WeakMap,St=new WeakMap,dt=new WeakMap,yt=new WeakMap,p=new WeakSet,Vt=function(e){const s=document.createElement("script");for(let a=0;a<e.attributes.length;a++){const n=e.attributes[a];s.setAttribute(n.name,n.value)}return e.hasAttribute("src")||(s.innerHTML=e.innerHTML),s},At=new WeakMap,Ht=function(e){const s=this.normalizePath(e);let a=t(this,W).get(s.pathname);return a||(a=new ae(this,s.pathname),t(this,W).set(s.pathname,a)),a},Ot=function(e){const s=[...e.querySelectorAll("[data-morph]")];return s.length?s:[e]},le=function(e,s){return e.filter(a=>s.find(n=>n.outerHTML===a.outerHTML))},Ft=function(e,s){return e.filter(a=>!s.find(n=>n.outerHTML===a.outerHTML))},Bt=function(e){return e.tagName==="SCRIPT"||e.tagName==="STYLE"||e.tagName==="LINK"&&e.getAttribute("rel")==="stylesheet"},Kt=function(e){var s,a;(s=t(this,U))==null||s.removeEventListener("scroll",t(this,ut)),o(this,ct,0),o(this,lt,0),o(this,U,t(this,q).scrollSelector&&e.querySelector(t(this,q).scrollSelector)||window),o(this,vt,t(this,U)===window),(a=t(this,U))==null||a.addEventListener("scroll",t(this,ut)),t(this,ut).call(this)},Xt=function(e,s){const a=typeof e=="string"?document.getElementById(e):e;(typeof a=="number"||a)&&ie.scrollToElement(a,{scrollElement:t(this,U),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,ut=new WeakMap,pt.instance=null;let Wt=pt;exports.Morph=Wt;
|
|
1
|
+
"use strict";var ge=Object.defineProperty,Ee=Object.defineProperties;var be=Object.getOwnPropertyDescriptors;var _t=Object.getOwnPropertySymbols;var ve=Object.prototype.hasOwnProperty,Le=Object.prototype.propertyIsEnumerable;var te=(h,e)=>(e=Symbol[h])?e:Symbol.for("Symbol."+h),se=h=>{throw TypeError(h)};var ee=(h,e,s)=>e in h?ge(h,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):h[e]=s,Ht=(h,e)=>{for(var s in e||(e={}))ve.call(e,s)&&ee(h,s,e[s]);if(_t)for(var s of _t(e))Le.call(e,s)&&ee(h,s,e[s]);return h},Dt=(h,e)=>Ee(h,be(e));var zt=(h,e,s)=>e.has(h)||se("Cannot "+s);var t=(h,e,s)=>(zt(h,e,"read from private field"),s?s.call(h):e.get(h)),l=(h,e,s)=>e.has(h)?se("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(h):e.set(h,s),o=(h,e,s,a)=>(zt(h,e,"write to private field"),a?a.call(h,s):e.set(h,s),s),g=(h,e,s)=>(zt(h,e,"access private method"),s);var G=(h,e,s)=>new Promise((a,n)=>{var b=d=>{try{u(s.next(d))}catch(v){n(v)}},f=d=>{try{u(s.throw(d))}catch(v){n(v)}},u=d=>d.done?a(d.value):Promise.resolve(d.value).then(b,f);u((s=s.apply(h,e)).next())});var ie=(h,e,s)=>(e=h[te("asyncIterator")])?e.call(h):(h=h[te("iterator")](),e={},s=(a,n)=>(n=h[a])&&(e[a]=b=>new Promise((f,u,d)=>(b=n.call(h,b),d=b.done,Promise.resolve(b.value).then(v=>f({value:v,done:d}),u)))),s("next"),s("return"),e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const re=require("../index-DekP7OZe.cjs"),D=require("../events-KVanG9sR.cjs"),ae=require("../scroll-CIdNtj3G.cjs");require("construct-style-sheets-polyfill");const pt=require("../url-VIZgwj_h.cjs"),oe=require("../string-DUXXtU8v.cjs"),Se=require("../math-GDWEqu7y.cjs"),ye=require("../css-value-parser/index.cjs");class he 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,a]of Object.entries(e))this.setAttribute(s,a)}}re.isBrowser&&!customElements.get("morph-announcer")&&customElements.define("morph-announcer",he);var R,i,x,at,Tt,le,Et,nt;class It{constructor(e,s){l(this,x);l(this,R);l(this,i);l(this,Et,e=>{e.preventDefault(),g(this,x,le).call(this)});l(this,nt,()=>{const e=t(this,i).hasAttribute("data-revalidate");t(this,R).prefetch(t(this,x,at),e),t(this,i).removeEventListener("pointerenter",t(this,nt))});o(this,R,s),o(this,i,e),t(this,i).addEventListener("click",t(this,Et)),this.checkCurrent(location.href.replace(location.origin,""));const a=g(this,x,Tt).call(this,t(this,i).getAttribute("data-pagination-set-link")||t(this,i).getAttribute("data-pagination-more-link")||t(this,i).getAttribute("data-pagination-next-link")||t(this,i).getAttribute("data-pagination-prev-link"));a&&this.updatePagination(a.currentPage,a.selector),t(this,i).hasAttribute("data-prefetch")&&t(this,i).addEventListener("pointerenter",t(this,nt))}get element(){return t(this,i)}checkCurrent(e){var v,et;const s=t(this,R).normalizePath(e),a=t(this,R).normalizePath(t(this,x,at));t(this,i).hasAttribute("data-include")&&s.pathname.includes(a.pathname)?t(this,i).classList.add("current"):a.pathname===s.pathname?t(this,i).classList.add("current"):(v=t(this,i).getAttribute("data-associated-paths"))!=null&&v.split(",").find(w=>s.pathname.includes(w))?t(this,i).classList.add("current"):t(this,i).classList.remove("current"),s.path===a.path?t(this,i).classList.add("exact"):t(this,i).classList.remove("exact");const[n,b]=(et=t(this,x,at).split("#")[0])==null?void 0:et.split("?"),f=new URLSearchParams(b),u=new URLSearchParams(location.search);let d=0;for(const[w]of u)f.has(w)&&u.get(w)===f.get(w)&&d++;d?(t(this,i).classList.toggle("all-params-matched",u.size===d),t(this,i).classList.toggle("some-params-matched",u.size!==d)):!u.size&&t(this,i).hasAttribute("data-match-no-params")?t(this,i).classList.add("all-params-matched"):(t(this,i).classList.remove("all-params-matched"),t(this,i).classList.remove("some-params-matched"));for(const w in t(this,i).dataset){const st=oe.camelToKebab(w);if(st.startsWith("match-param-")){const $=st.split("match-param-")[1],S=t(this,i).dataset[w],c=`param-${$}-matched`;u.has($)&&u.get($)===S||!u.has($)&&(S===""||S==="*"||S==="all"||S==="any"||S==="vse")?t(this,i).classList.add(c):t(this,i).classList.remove(c)}}}updatePagination(e,s){const a=g(this,x,Tt).call(this,s);if(a)if(a.element.setAttribute("data-current-page",e.toString()),t(this,i).hasAttribute("data-pagination-more-link"))if(e<a.totalPages){t(this,i).style.display="";const n=t(this,i).querySelector("[data-pagination-more-link-counter]");n&&(n.textContent=(a.totalPages-e).toString());const b=t(this,i).getAttribute("href"),f=new URL(b,window.location.origin);f.searchParams.set("page",(e+1).toString());const u=f.href.replace(f.origin,"").toString();t(this,i).setAttribute("href",u),this.checkCurrent(u)}else t(this,i).style.display="none";else if(t(this,i).hasAttribute("data-pagination-prev-link")||t(this,i).hasAttribute("data-pagination-next-link")){const n=t(this,i).hasAttribute("data-pagination-prev-link"),b=t(this,i).getAttribute("href"),f=new URL(b,window.location.origin),u=e+(n?-1:1);f.searchParams.set("page",Se.clamp(u,1,a.totalPages).toString());const d=f.href.replace(f.origin,"").toString();t(this,i).setAttribute("href",d),n?u<1?(t(this,i).classList.add("pagination-disabled"),t(this,i).setAttribute("tabindex","-1")):(t(this,i).classList.remove("pagination-disabled"),t(this,i).removeAttribute("tabindex")):u>a.totalPages?(t(this,i).classList.add("pagination-disabled"),t(this,i).setAttribute("tabindex","-1")):(t(this,i).classList.remove("pagination-disabled"),t(this,i).removeAttribute("tabindex"))}else t(this,i).hasAttribute("data-pagination-set-link")&&(t(this,i).getAttribute("data-value")===e.toString()?t(this,i).classList.add("pagination-current"):t(this,i).classList.remove("pagination-current"))}destroy(){t(this,i).removeEventListener("click",t(this,Et)),t(this,i).removeEventListener("pointerenter",t(this,nt)),t(this,i).classList.remove("current","exact","pagination-current")}}R=new WeakMap,i=new WeakMap,x=new WeakSet,at=function(){const e=new URL(t(this,i).href);return t(this,R).normalizePath(e.pathname+e.search+e.hash).path},Tt=function(e){if(!e)return;const s=document.querySelector(e);if(s){const a=parseInt(s.getAttribute("data-current-page")||"1"),n=parseInt(s.getAttribute("data-total-pages")||"1");return{element:s,currentPage:a,totalPages:n,selector:e}}},le=function(){var s;if(document.documentElement.classList.contains("click-disabled"))return;if(t(this,i).hasAttribute("data-back")&&t(this,R).previousURL)history.back();else{const a=t(this,i).getAttribute("data-history-action")||"push",n=t(this,i).hasAttribute("data-center-scroll"),b=getComputedStyle(t(this,i)).getPropertyValue("--offset-scroll").trim(),f=b?ye.cssValueParser.parse(b):void 0,u=t(this,i).hasAttribute("data-revalidate")||t(this,i).hasAttribute("data-pagination-more-link")||t(this,i).hasAttribute("data-pagination-set-link")||t(this,i).hasAttribute("data-pagination-next-link")||t(this,i).hasAttribute("data-pagination-prev-link"),d=t(this,i).hasAttribute("data-keep-search-parameters"),v=t(this,i).hasAttribute("data-keep-scroll-position")||t(this,i).hasAttribute("data-pagination-more-link"),et=t(this,i).getAttribute("data-scroll-behaviour"),w=((s=t(this,i).getAttribute("data-submorph"))==null?void 0:s.split(",").map(c=>c.trim()))||t(this,i).hasAttribute("data-pagination-more-link")&&[t(this,i).getAttribute("data-pagination-more-link")]||t(this,i).hasAttribute("data-pagination-set-link")&&[t(this,i).getAttribute("data-pagination-set-link")]||t(this,i).hasAttribute("data-pagination-next-link")&&[t(this,i).getAttribute("data-pagination-next-link")]||t(this,i).hasAttribute("data-pagination-prev-link")&&[t(this,i).getAttribute("data-pagination-prev-link")]||void 0,st=t(this,i).hasAttribute("data-clear-state");let $=t(this,x,at);if(t(this,i).hasAttribute("data-toggle-params")){const[c,wt]=t(this,x,at).split("?"),j=new URLSearchParams(wt),V=new URLSearchParams(location.search),it=new URLSearchParams;for(const[y]of j)(!V.has(y)||V.has(y)&&V.get(y)!==j.get(y))&&it.append(y,j.get(y));if(t(this,i).hasAttribute("data-merge-params"))for(const[y]of V)j.has(y)||it.append(y,V.get(y));$=`${c}?${it.toString()}`}const S=g(this,x,Tt).call(this,t(this,i).getAttribute("data-pagination-set-link")||t(this,i).getAttribute("data-pagination-more-link")||t(this,i).getAttribute("data-pagination-next-link")||t(this,i).getAttribute("data-pagination-prev-link"));S&&(t(this,i).hasAttribute("data-pagination-set-link")?t(this,R).links.forEach(c=>{c.updatePagination(parseInt(t(this,i).getAttribute("data-value")||"1"),S.selector)}):t(this,i).hasAttribute("data-pagination-prev-link")?t(this,R).links.forEach(c=>{c.updatePagination(S.currentPage-1,S.selector)}):t(this,i).hasAttribute("data-pagination-next-link")?t(this,R).links.forEach(c=>{c.updatePagination(S.currentPage+1,S.selector)}):t(this,i).hasAttribute("data-pagination-more-link")&&t(this,R).links.forEach(c=>{c.updatePagination(S.currentPage+1,S.selector)})),t(this,R).navigate($,{historyAction:a,centerScroll:n,offsetScroll:f,revalidate:u,keepSearchParameters:d,submorph:w,clearState:st,keepScrollPosition:v,scrollBehaviour:et,submorphAppend:t(this,i).hasAttribute("data-pagination-more-link"),mergeParams:!!S||t(this,i).hasAttribute("data-merge-params")&&!t(this,i).hasAttribute("data-toggle-params")})}},Et=new WeakMap,nt=new WeakMap;const Ae=new DOMParser;var z,J,H,I,Q,F,rt,Z,B,bt,ot;class ne{constructor(e,s){l(this,z);l(this,J);l(this,H,{x:0,y:0});l(this,I,null);l(this,Q,null);l(this,F,null);l(this,rt,null);l(this,Z,null);l(this,B,null);l(this,bt);l(this,ot,!1);o(this,z,e),o(this,J,s)}get pathname(){return t(this,J)}get scrollState(){return t(this,H)}get document(){return t(this,F)}needRavalidation(){o(this,ot,!0)}setHeaders(e){o(this,bt,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,a){return G(this,null,function*(){var n;if(!a&&!t(this,ot)){const u=((n=t(this,I))==null?void 0:n.documentElement.getAttribute("data-cache"))&&s!==e,d=t(this,I)&&t(this,z).isPopstateNavigation;if(t(this,B)||u||d)return t(this,B)}return o(this,B,new Promise(b=>G(this,null,function*(){try{o(this,Z,new AbortController);const u=yield(yield fetch(e,{signal:t(this,Z).signal,headers:Ht({"X-MORPH":"true","X-MORPH-CURRENT-PATH":encodeURIComponent(s),"X-MORPH-NEW-PATH":encodeURIComponent(e)},t(this,bt))})).text(),d=Ae.parseFromString(u,"text/html");this.setInitialDocument(d),o(this,ot,!1)}catch(f){console.warn(f)}finally{o(this,Z,null),o(this,B,null),b()}}))),t(this,B)})}cloneDocument(){o(this,F,(t(this,Q)||t(this,I)).cloneNode(!0))}get title(){let e="";if(t(this,F).title)e=t(this,F).title;else{const s=t(this,F).querySelector("h1");e=(s==null?void 0:s.innerText)||(s==null?void 0:s.textContent)||t(this,J)}return e}clearScrollState(){t(this,H).x=0,t(this,H).y=0}clearDocumentState(){o(this,Q,null)}saveScrollState(){t(this,I).documentElement.hasAttribute("data-no-scroll-restoration")?(t(this,H).x=0,t(this,H).y=0):(t(this,H).x=t(this,z).scrollValue.left,t(this,H).y=t(this,z).scrollValue.top)}restoreScrollPosition(){t(this,z).scrollElement.scroll({top:t(this,H).y,left:t(this,H).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,rt,e)}clearState(){const e=t(this,rt);return o(this,rt,null),e}}z=new WeakMap,J=new WeakMap,H=new WeakMap,I=new WeakMap,Q=new WeakMap,F=new WeakMap,rt=new WeakMap,Z=new WeakMap,B=new WeakMap,bt=new WeakMap,ot=new WeakMap;var T,ht,vt,Wt,Lt;class Pe{constructor(e){l(this,vt);l(this,T);l(this,ht,[]);l(this,Lt,()=>{g(this,vt,Wt).call(this)});o(this,T,e);for(const s in t(this,T).dataset){const a=oe.camelToKebab(s);if(a.startsWith("param-")){const n=a.split("param-")[1],b=t(this,T).dataset[s];t(this,ht).push({name:n,value:b})}}document.addEventListener("morphURLParametersChange",t(this,Lt)),g(this,vt,Wt).call(this)}destroy(){document.removeEventListener("morphURLParametersChange",t(this,Lt))}}T=new WeakMap,ht=new WeakMap,vt=new WeakSet,Wt=function(){const e=new URLSearchParams(location.search);let s=!!t(this,ht).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,T).hasAttribute("data-match-no-params")&&(s=!t(this,ht).filter(n=>e.has(n.name)).length);const a=t(this,T).getAttribute("data-hide-class");s?a?t(this,T).classList.remove(a):t(this,T).style.display="":a?t(this,T).classList.add(a):t(this,T).style.display="none"},Lt=new WeakMap;var q,lt,P,K,E,_,X,Y,M,St,W,yt,tt,ct,dt,At,ut,Pt,p,Ot,kt,ft,Ft,ce,Bt,Kt,Xt,Yt,Ut,mt;const gt=class gt{constructor(e){l(this,p);l(this,q,null);l(this,lt,null);l(this,P,[]);l(this,K);l(this,E,null);l(this,_);l(this,X,[]);l(this,Y,!1);l(this,M,null);l(this,St,!1);l(this,W,new Map);l(this,yt,[]);l(this,tt,null);l(this,ct,0);l(this,dt,0);l(this,At);l(this,ut);l(this,Pt);l(this,kt,e=>{var s,a;return(((s=e.getAttribute("href"))==null?void 0:s.startsWith("/"))||((a=e.getAttribute("href"))==null?void 0:a.startsWith("?")))&&!e.hasAttribute("download")&&!e.hasAttribute("data-morph-skip")&&!e.closest("[data-morph-skip]")&&e.getAttribute("target")!=="_blank"});l(this,Ut,e=>G(this,null,function*(){e.preventDefault(),o(this,Y,!0),yield this.navigate(location.href.replace(location.origin,""),{historyAction:"none",submorph:t(this,ut)?void 0:t(this,At),revalidate:t(this,ut),keepScrollPosition:t(this,Pt)}),o(this,Y,!1)}));l(this,mt,()=>{const{left:e,top:s}=this.scrollValue,a=s-t(this,dt),n=e-t(this,ct);o(this,dt,s),o(this,ct,e),document.documentElement.classList.toggle("scroll-y",s>0),document.documentElement.classList.toggle("scroll-x",e>0),document.documentElement.classList.toggle("scroll-y-forward",a>0),document.documentElement.classList.toggle("scroll-y-backward",a<0),document.documentElement.classList.toggle("scroll-x-forward",n>0),document.documentElement.classList.toggle("scroll-x-backward",n<0),D.dispatchEvent(document,"morphScroll",{detail:{left:e,top:s}})});if(re.isBrowser&&!gt.instance){gt.instance=this,o(this,q,{base:pt.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,lt,g(this,p,Ft).call(this,document.body));const s=this.normalizePath(location.pathname+location.search+location.hash);o(this,E,s);const a=new ne(this,t(this,E).pathname);a.setInitialDocument(document),t(this,W).set(t(this,E).pathname,a),document.documentElement.setAttribute("data-current-pathname",t(this,E).pathname),document.documentElement.setAttribute("data-current-leaf",s.leaf),this.findLinks(),this.findParamsDependent(),history.scrollRestoration="manual",addEventListener("popstate",t(this,Ut)),pt.changeHistory({action:"replace",pathname:s.pathname,searchParameters:s.parameters,hash:s.hash}),o(this,tt,new he),g(this,p,Xt).call(this,document)}}get currentURL(){return t(this,E)}get previousURL(){return t(this,_)}get links(){return t(this,P)}get scrollElement(){return t(this,M)}get isPopstateNavigation(){return t(this,Y)}get scrollValue(){let e=0,s=0;return t(this,St)?(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,W).get(t(this,E).path);s&&s.saveState(e)}getState(){const e=t(this,W).get(t(this,E).path);return e==null?void 0:e.clearState()}normalizePath(e,s){return pt.splitPath(e,{base:t(this,q).base,trailingSlash:t(this,q).trailingSlash,mergeParams:s!=null&&s.mergeParams?location.search:""})}prefetch(e,s){return G(this,null,function*(){var n;if(t(this,X).length)return;e=((n=this.pathnameModifier)==null?void 0:n.call(this,e))||e;const a=g(this,p,ft).call(this,e);a==null||a.fetch(e,t(this,E).path,s)})}excludeHeadChild(e){return!1}setHeaders(e){}needRavalidation(e){const s=this.normalizePath(e),a=g(this,p,ft).call(this,s.path);a==null||a.needRavalidation()}navigate($){return G(this,arguments,function*(e,{historyAction:s="push",centerScroll:a,offsetScroll:n,scrollBehaviour:b,revalidate:f,keepSearchParameters:u,submorph:d,submorphAppend:v,clearState:et,keepScrollPosition:w,mergeParams:st}={}){var wt,j,V,it;if(t(this,X).length)return;o(this,At,d),o(this,ut,f),o(this,Pt,w);const S=((wt=this.pathnameModifier)==null?void 0:wt.call(this,e))||e,c=this.normalizePath(S,{mergeParams:st});if(!f&&(((j=t(this,K))==null?void 0:j.pathname)===c.pathname||t(this,E).pathname===c.pathname)){w||g(this,p,Yt).call(this,c.hash||0,{centerScroll:a,offsetScroll:n,behavior:"smooth"}),D.dispatchEvent(document,"morphSamePath",{custom:!0}),((V=t(this,E))==null?void 0:V.parameters)!==c.parameters&&(o(this,_,t(this,E)),o(this,E,c),pt.changeHistory({action:((it=t(this,E))==null?void 0:it.hash)!==c.hash?"replace":s,pathname:c.pathname,searchParameters:c.parameters,hash:c.hash}),D.dispatchEvent(document,"morphURLParametersChange",{detail:{newURL:t(this,E),previousURL:t(this,_)}})),t(this,P).forEach(y=>{y.checkCurrent(c.path)});return}else t(this,P).forEach(y=>{y.checkCurrent(c.path)});o(this,K,c);try{let y=!0;if(this.preprocessor)try{yield new Promise((r,k)=>{var U;(U=this.preprocessor)==null||U.call(this,{url:c,resolve:r,reject:k,submorph:d})})}catch(r){r?console.error(r):console.log("Route change canceled"),y=!1}if(!y||t(this,K).pathname!==c.pathname){t(this,P).forEach(r=>{r.checkCurrent(t(this,E).path)});return}const $t={url:c,submorph:d};d?v||d.forEach(r=>{document.querySelectorAll(r).forEach(k=>{k.classList.add("out"),k.setAttribute("data-morph-out","")})}):t(this,lt).forEach(r=>{var k,U;(k=r.firstElementChild)==null||k.classList.add("out"),(U=r.firstElementChild)==null||U.setAttribute("data-morph-out","")}),D.dispatchEvent(document,"morphNavigation",{detail:$t});const Mt=g(this,p,ft).call(this,t(this,E).pathname),A=g(this,p,ft).call(this,c.pathname);if(t(this,W).forEach(r=>{r.pathname!==c.pathname&&r.abort()}),yield A==null?void 0:A.fetch(S,t(this,E).path,f),t(this,K).pathname!==c.pathname){t(this,P).forEach(r=>{r.checkCurrent(t(this,E).path)});return}Mt.clearState(),Mt.saveScrollState(),Mt.saveDocumentState(),(!t(this,Y)||f)&&(A.clearScrollState(),A.clearDocumentState()),et&&A.clearState(),A.cloneDocument(),t(this,tt).textContent=A.title,document.body.appendChild(t(this,tt));const Ct=Dt(Ht({},$t),{document:A.document});v||Ct.document.querySelectorAll("[data-morph-out]").forEach(r=>{r.classList.remove("out")}),D.dispatchEvent(document,"morphStart",{detail:Ct});const jt=Array.from(document.head.children),Gt=Array.from(A.document.head.children),Jt=g(this,p,ce).call(this,jt,Gt),de=g(this,p,Bt).call(this,jt,Jt),Rt=g(this,p,Bt).call(this,Gt,Jt).filter(r=>!this.excludeHeadChild(r));Rt.forEach((r,k)=>{r.tagName==="SCRIPT"&&(Rt[k]=g(this,p,Ot).call(this,r))}),Rt.forEach(r=>{document.head.appendChild(r)});const Nt=Rt.filter(r=>{if(r.hasAttribute("data-no-waiting"))return!1;if(g(this,p,Kt).call(this,r))return!0});t(this,q).waitForHeadToLoad&&Nt.length&&(yield new Promise(r=>G(this,null,function*(){let k=0;try{for(var U=ie(Nt),me,O,N;me=!(O=yield U.next()).done;me=!1){const xt=O.value;xt.onload=()=>{k++,k===Nt.length&&r()}}}catch(O){N=[O]}finally{try{me&&(O=U.return)&&(yield O.call(U))}finally{if(N)throw N[0]}}}))),yield ae.wait(10);const Qt=[];v||de.forEach(r=>{r.hasAttribute("data-permanent")||(g(this,p,Kt).call(this,r)?Qt.push(r):r.remove())});const ue=g(this,p,Ft).call(this,A.document.body);!t(this,q).morphInsideScrollContainer&&!d&&g(this,p,Xt).call(this,A.document),document.documentElement.setAttribute("data-current-pathname",c.pathname),document.documentElement.setAttribute("data-current-leaf",c.leaf),pt.changeHistory({action:s,pathname:c.pathname,searchParameters:c.parameters||(u?location.search:""),hash:c.hash}),t(this,tt).remove(),o(this,_,t(this,E)),o(this,E,c);const qt=[];t(this,lt).forEach((r,k)=>{const U=ue[k],me=getComputedStyle(r).getPropertyValue("--morph-duration");let O=[],N=[];d?(d.forEach(m=>{const L=r.querySelector(m),C=U.querySelector(m);L&&C&&(N.push(L),O.push(C))}),N.forEach(m=>{m.parentElement&&qt.push(m.parentElement)})):(O.push(...U.childNodes),N.push(...r.childNodes),qt.push(r));const xt=[];v||N.forEach(m=>{m instanceof HTMLElement&&(this.destroyOldLinks(m),m.classList.add("old"),m.querySelectorAll("[data-morph-transfer]").forEach(C=>{const fe=C.getAttribute("data-morph-transfer");xt.push({element:C,selector:fe})}))}),O.forEach(m=>{m instanceof HTMLElement&&(xt.forEach(L=>{const C=m.querySelector(L.selector);C&&C.replaceWith(A.document.importNode(L.element,!0))}),this.findNewLinks(m),m.classList.add("new"))}),d?v?O.forEach((m,L)=>{N[L]instanceof HTMLElement&&N[L].append(...m.childNodes)}):O.forEach((m,L)=>{var C;(C=N[L].parentElement)==null||C.insertBefore(m,N[L])}):r.prepend(...O),setTimeout(()=>{v||N.forEach(m=>{m instanceof HTMLElement&&m.classList.add("old-idle")}),O.forEach(m=>{var L;m instanceof HTMLElement&&((L=m.parentElement)==null||L.style.setProperty("--new-content-height",m.offsetHeight+"px"),m.classList.add("new-idle"))})},0);const Zt=Dt(Ht({},Ct),{morphElement:r});D.dispatchEvent(document,"morphNewChildrenAdded",{detail:Zt});const pe=new Promise(m=>{setTimeout(()=>{v||N.forEach(L=>{L.remove()}),O.forEach(L=>{var C;L instanceof HTMLElement&&((C=L.parentElement)==null||C.style.removeProperty("--new-content-height"),L.classList.remove("new-idle","new"))}),v||D.dispatchEvent(document,"morphOldChildrenRemoved",{detail:Zt}),m()},(parseFloat(me)||0)*1e3+10)});t(this,X).push(pe)}),this.isPopstateNavigation?document.documentElement.style.setProperty("--new-document-scroll-position",(this.scrollValue.top-A.scrollState.y)*1+"px"):document.documentElement.style.setProperty("--new-document-scroll-position",this.scrollValue.top+"px"),D.dispatchEvent(document,"morphBeforeNavigationScroll",{detail:A.scrollState}),c.hash?(A.clearScrollState(),g(this,p,Yt).call(this,c.hash,{centerScroll:a,offsetScroll:n,behavior:b})):t(this,Y)?A.restoreScrollPosition():w||A.renewScrollPosition(),yield Promise.all(t(this,X)),v||Qt.forEach(r=>r.remove()),o(this,X,[]),qt.forEach(r=>{r.querySelectorAll("script").forEach(U=>{U.replaceWith(g(this,p,Ot).call(this,U))})}),t(this,P).forEach(r=>{r.checkCurrent(t(this,E).path)}),this.findParamsDependent(),D.dispatchEvent(document,"morphComplete",{detail:Ct}),document.documentElement.style.removeProperty("--new-document-scroll-position"),window.dispatchEvent(new Event("resize"))}catch(y){console.error(y)}o(this,K,void 0)})}addLink(e){t(this,P).push(new It(e,this))}addLinks(e){e.forEach(s=>{this.addLink(s)})}removeLink(e){o(this,P,t(this,P).filter(s=>s.element===e?(s.destroy(),!1):!0))}destroyOldLinks(e){o(this,P,t(this,P).filter(s=>e.contains(s.element)?(s.destroy(),!1):!0))}findNewLinks(e){const s=[...e.querySelectorAll("a")].filter(t(this,kt));t(this,P).push(...s.map(a=>new It(a,this)))}findLinks(){const e=[...document.documentElement.querySelectorAll("a")].filter(t(this,kt));t(this,P).forEach(s=>s.destroy()),o(this,P,e.map(s=>new It(s,this)))}findParamsDependent(){const e=[...document.documentElement.querySelectorAll("[data-morph-params-dependent]")];t(this,yt).forEach(s=>s.destroy()),o(this,yt,e.map(s=>new Pe(s)))}};q=new WeakMap,lt=new WeakMap,P=new WeakMap,K=new WeakMap,E=new WeakMap,_=new WeakMap,X=new WeakMap,Y=new WeakMap,M=new WeakMap,St=new WeakMap,W=new WeakMap,yt=new WeakMap,tt=new WeakMap,ct=new WeakMap,dt=new WeakMap,At=new WeakMap,ut=new WeakMap,Pt=new WeakMap,p=new WeakSet,Ot=function(e){const s=document.createElement("script");for(let a=0;a<e.attributes.length;a++){const n=e.attributes[a];s.setAttribute(n.name,n.value)}return e.hasAttribute("src")||(s.innerHTML=e.innerHTML),s},kt=new WeakMap,ft=function(e){const s=this.normalizePath(e);let a=t(this,W).get(s.pathname);return a||(a=new ne(this,s.pathname),t(this,W).set(s.pathname,a)),a},Ft=function(e){const s=[...e.querySelectorAll("[data-morph]")];return s.length?s:[e]},ce=function(e,s){return e.filter(a=>s.find(n=>n.outerHTML===a.outerHTML))},Bt=function(e,s){return e.filter(a=>!s.find(n=>n.outerHTML===a.outerHTML))},Kt=function(e){return e.tagName==="SCRIPT"||e.tagName==="STYLE"||e.tagName==="LINK"&&e.getAttribute("rel")==="stylesheet"},Xt=function(e){var s,a;(s=t(this,M))==null||s.removeEventListener("scroll",t(this,mt)),o(this,dt,0),o(this,ct,0),o(this,M,t(this,q).scrollSelector&&e.querySelector(t(this,q).scrollSelector)||window),o(this,St,t(this,M)===window),(a=t(this,M))==null||a.addEventListener("scroll",t(this,mt)),t(this,mt).call(this)},Yt=function(e,s){const a=typeof e=="string"?document.getElementById(e):e;(typeof a=="number"||a)&&ae.scrollToElement(a,{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})},Ut=new WeakMap,mt=new WeakMap,gt.instance=null;let Vt=gt;exports.Morph=Vt;
|