aptechka 0.71.30 → 0.72.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-CkhCt-4W.js → DragControls-B7q22wzw.js} +25 -23
- package/lib/{DragControls-CfE2oPAi.cjs → DragControls-tVaq-vIe.cjs} +1 -1
- package/lib/controls/index.cjs +1 -1
- package/lib/controls/index.js +1 -1
- package/lib/morph/index.cjs +1 -1
- package/lib/morph/index.js +228 -215
- package/lib/scroll/index.cjs +1 -1
- package/lib/scroll/index.js +1 -1
- package/package.json +1 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
var _ = (
|
|
2
|
-
throw TypeError(
|
|
1
|
+
var _ = (a) => {
|
|
2
|
+
throw TypeError(a);
|
|
3
3
|
};
|
|
4
|
-
var G = (
|
|
5
|
-
var t = (
|
|
4
|
+
var G = (a, r, e) => r.has(a) || _("Cannot " + e);
|
|
5
|
+
var t = (a, r, e) => (G(a, r, "read from private field"), e ? e.call(a) : r.get(a)), s = (a, r, e) => r.has(a) ? _("Cannot add the same private member more than once") : r instanceof WeakSet ? r.add(a) : r.set(a, e), i = (a, r, e, h) => (G(a, r, "write to private field"), h ? h.call(a, e) : r.set(a, e), e), A = (a, r, e) => (G(a, 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,48 +13,48 @@ 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 ae } 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 ae());
|
|
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 g, c, u, X;
|
|
28
|
+
class ge extends j {
|
|
29
29
|
constructor(e) {
|
|
30
30
|
super();
|
|
31
|
-
s(this,
|
|
31
|
+
s(this, g, 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 n;
|
|
37
|
+
e.code === "Space" ? n = h * t(this, c)[t(this, u)] * 0.4 : e.code === "ArrowLeft" ? n = -1 * t(this, c)[t(this, u)] * 0.2 : e.code === "ArrowRight" ? n = 1 * t(this, c)[t(this, u)] * 0.2 : e.code === "ArrowUp" ? n = -1 * t(this, c)[t(this, u)] * 0.2 : e.code === "ArrowDown" ? n = 1 * t(this, c)[t(this, u)] * 0.2 : e.code === "PageUp" ? n = -1 * t(this, c)[t(this, u)] : e.code === "PageDown" ? n = 1 * t(this, c)[t(this, u)] : e.code === "Home" ? n = 0 : e.code === "End" && (n = t(this, u) === "offsetWidth" ? t(this, c).scrollWidth : t(this, c).scrollHeight), n && (e.stopPropagation(), this.changeEvent.notify("keyboard", n, e));
|
|
38
38
|
});
|
|
39
|
-
b && (i(this,
|
|
39
|
+
b && (i(this, g, e != null && e.element && Z(e.element) || window), i(this, c, t(this, g) instanceof HTMLElement ? t(this, g) : 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, g).addEventListener(
|
|
46
46
|
"keydown",
|
|
47
47
|
t(this, X)
|
|
48
48
|
);
|
|
49
49
|
}
|
|
50
50
|
disconnect() {
|
|
51
|
-
b && t(this,
|
|
51
|
+
b && t(this, g).removeEventListener(
|
|
52
52
|
"keydown",
|
|
53
53
|
t(this, X)
|
|
54
54
|
);
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
|
-
|
|
57
|
+
g = new WeakMap(), c = new WeakMap(), u = new WeakMap(), X = new WeakMap();
|
|
58
58
|
var E, M, Y, O, d, I, m, w, Q, J, H, S, q;
|
|
59
59
|
class Ee extends j {
|
|
60
60
|
constructor(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 n = Math.abs(e.deltaY), y = Math.abs(e.deltaX);
|
|
137
|
+
if (!(this.axis === "x" && n > y || this.axis === "y" && y > n) && (e.preventDefault(), !(this.debounce && this.axis === "x" && y < 5 || this.debounce && this.axis === "y" && n < 5)))
|
|
138
|
+
if (h = (this.axis === "max" ? y > n ? 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;
|
|
@@ -184,17 +184,19 @@ const v = class v extends j {
|
|
|
184
184
|
))
|
|
185
185
|
return;
|
|
186
186
|
this.swipe || D.unsubscribe(t(this, L));
|
|
187
|
-
let
|
|
187
|
+
let n = h, y = !1;
|
|
188
188
|
document.documentElement.classList.add("grabbing");
|
|
189
189
|
let R = 0, $ = 0, F = 0, U = 0;
|
|
190
190
|
ie(
|
|
191
191
|
(f) => {
|
|
192
|
-
t(v, T) && t(v, T) !== t(this, o) || (R =
|
|
192
|
+
t(v, T) && t(v, T) !== t(this, o) || (R = n.x - f.x, $ = n.y - f.y, F = f.x - h.x, U = f.y - h.y, this.axis === "x" ? (i(this, x, F), i(this, l, R)) : (i(this, x, U), i(this, l, $)), n = f, y = this.axis === "x" && Math.abs(F) > Math.abs(U) || this.axis === "y" && Math.abs(U) > Math.abs(F), y && (document.documentElement.classList.add("click-disabled"), i(v, T, t(this, o)), this.changeEvent.notify("drag", t(this, l), f)));
|
|
193
193
|
},
|
|
194
194
|
(f) => {
|
|
195
|
-
i(v, T, null),
|
|
195
|
+
i(v, T, null), y && (!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), f)), document.documentElement.classList.remove("grabbing"),
|
|
197
|
+
})) : this.swipe && this.changeEvent.notify("drag-end", t(this, l), f)), document.documentElement.classList.remove("grabbing"), setTimeout(() => {
|
|
198
|
+
document.documentElement.classList.remove("click-disabled");
|
|
199
|
+
});
|
|
198
200
|
}
|
|
199
201
|
);
|
|
200
202
|
}), i(this, L, () => {
|
|
@@ -221,6 +223,6 @@ export {
|
|
|
221
223
|
Ee as A,
|
|
222
224
|
j as C,
|
|
223
225
|
p as D,
|
|
224
|
-
|
|
226
|
+
ge as K,
|
|
225
227
|
xe as W
|
|
226
228
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var p=r=>{throw TypeError(r)};var G=(r,a,e)=>a.has(r)||p("Cannot "+e);var t=(r,a,e)=>(G(r,a,"read from private field"),e?e.call(r):a.get(r)),s=(r,a,e)=>a.has(r)?p("Cannot add the same private member more than once"):a instanceof WeakSet?a.add(r):a.set(r,e),i=(r,a,e,h)=>(G(r,a,"write to private field"),h?h.call(r,e):a.set(r,e),e),T=(r,a,e)=>(G(r,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"),re=require("./notifier/index.cjs");var j;class F{constructor(){s(this,j,new re.Notifier)}get changeEvent(){return t(this,j)}}j=new WeakMap;var y,c,u,R;class ne 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 n;e.code==="Space"?n=h*t(this,c)[t(this,u)]*.4:e.code==="ArrowLeft"?n=-1*t(this,c)[t(this,u)]*.2:e.code==="ArrowRight"?n=1*t(this,c)[t(this,u)]*.2:e.code==="ArrowUp"?n=-1*t(this,c)[t(this,u)]*.2:e.code==="ArrowDown"?n=1*t(this,c)[t(this,u)]*.2:e.code==="PageUp"?n=-1*t(this,c)[t(this,u)]:e.code==="PageDown"?n=1*t(this,c)[t(this,u)]:e.code==="Home"?n=0:e.code==="End"&&(n=t(this,u)==="offsetWidth"?t(this,c).scrollWidth:t(this,c).scrollHeight),n&&(e.stopPropagation(),this.changeEvent.notify("keyboard",n,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 x,
|
|
1
|
+
"use strict";var p=r=>{throw TypeError(r)};var G=(r,a,e)=>a.has(r)||p("Cannot "+e);var t=(r,a,e)=>(G(r,a,"read from private field"),e?e.call(r):a.get(r)),s=(r,a,e)=>a.has(r)?p("Cannot add the same private member more than once"):a instanceof WeakSet?a.add(r):a.set(r,e),i=(r,a,e,h)=>(G(r,a,"write to private field"),h?h.call(r,e):a.set(r,e),e),T=(r,a,e)=>(G(r,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"),re=require("./notifier/index.cjs");var j;class F{constructor(){s(this,j,new re.Notifier)}get changeEvent(){return t(this,j)}}j=new WeakMap;var y,c,u,R;class ne 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 n;e.code==="Space"?n=h*t(this,c)[t(this,u)]*.4:e.code==="ArrowLeft"?n=-1*t(this,c)[t(this,u)]*.2:e.code==="ArrowRight"?n=1*t(this,c)[t(this,u)]*.2:e.code==="ArrowUp"?n=-1*t(this,c)[t(this,u)]*.2:e.code==="ArrowDown"?n=1*t(this,c)[t(this,u)]*.2:e.code==="PageUp"?n=-1*t(this,c)[t(this,u)]:e.code==="PageDown"?n=1*t(this,c)[t(this,u)]:e.code==="Home"?n=0:e.code==="End"&&(n=t(this,u)==="offsetWidth"?t(this,c).scrollWidth:t(this,c).scrollHeight),n&&(e.stopPropagation(),this.changeEvent.notify("keyboard",n,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 x,v,X,Y,d,A,m,b,V,J,D,O,I;class ae extends F{constructor(e){super();s(this,b);s(this,x);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,x)*this.direction*(1-t(this,d).current),h)}),i(this,O,()=>{t(this,d).current!==1&&this.changeEvent.notify("autoplay",Math.sign(t(this,x))*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,x,(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,x,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)))}}x=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,x)))):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 n=Math.abs(e.deltaY),g=Math.abs(e.deltaX);if(!(this.axis==="x"&&n>g||this.axis==="y"&&g>n)&&(e.preventDefault(),!(this.debounce&&this.axis==="x"&&g<5||this.debounce&&this.axis==="y"&&n<5)))if(h=(this.axis==="max"?g>n?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,E,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,E);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,E,0),i(this,W,h=>{Math.abs(t(this,E))>2&&h.preventDefault()}),i(this,K,h=>{if(i(this,E,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 n=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=n.x-f.x,$=n.y-f.y,U=f.x-h.x,Q=f.y-h.y,this.axis==="x"?(i(this,E,U),i(this,l,N)):(i(this,E,Q),i(this,l,$)),n=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("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)),document.documentElement.classList.remove("grabbing"),setTimeout(()=>{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,E=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=ne;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-tVaq-vIe.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/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var Jt=Object.defineProperty,Qt=Object.defineProperties;var Zt=Object.getOwnPropertyDescriptors;var Ut=Object.getOwnPropertySymbols;var _t=Object.prototype.hasOwnProperty,te=Object.prototype.propertyIsEnumerable;var zt=(r,t)=>(t=Symbol[r])?t:Symbol.for("Symbol."+r),Vt=r=>{throw TypeError(r)};var It=(r,t,s)=>t in r?Jt(r,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):r[t]=s,dt=(r,t)=>{for(var s in t||(t={}))_t.call(t,s)&&It(r,s,t[s]);if(Ut)for(var s of Ut(t))te.call(t,s)&&It(r,s,t[s]);return r},vt=(r,t)=>Qt(r,Zt(t));var St=(r,t,s)=>t.has(r)||Vt("Cannot "+s);var e=(r,t,s)=>(St(r,t,"read from private field"),s?s.call(r):t.get(r)),o=(r,t,s)=>t.has(r)?Vt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(r):t.set(r,s),n=(r,t,s,i)=>(St(r,t,"write to private field"),i?i.call(r,s):t.set(r,s),s),p=(r,t,s)=>(St(r,t,"access private method"),s);var B=(r,t,s)=>new Promise((i,h)=>{var g=S=>{try{v(s.next(S))}catch(V){h(V)}},b=S=>{try{v(s.throw(S))}catch(V){h(V)}},v=S=>S.done?i(S.value):Promise.resolve(S.value).then(g,b);v((s=s.apply(r,t)).next())});var Ot=(r,t,s)=>(t=r[zt("asyncIterator")])?t.call(r):(r=r[zt("iterator")](),t={},s=(i,h)=>(h=r[i])&&(t[i]=g=>new Promise((b,v,S)=>(g=h.call(r,g),S=g.done,Promise.resolve(g.value).then(V=>b({value:V,done:S}),v)))),s("next"),s("return"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Wt=require("../index-DekP7OZe.cjs"),C=require("../events-KVanG9sR.cjs"),ee=require("../polyfills-Df4r-ETT.cjs"),Ft=require("../scroll-CIdNtj3G.cjs");require("construct-style-sheets-polyfill");const st=require("../url-YEESIcRn.cjs"),se=require("../css-value-parser/index.cjs");class Xt extends HTMLElement{connectedCallback(){const t={"aria-live":"assertive","aria-atomic":"true",style:"position: absolute; left: 0; top: 0; clip: rect(0 0 0 0); clip-path: inset(50%); overflow: hidden; white-space: nowrap; width: 1px; height: 1px"};for(const[s,i]of Object.entries(t))this.setAttribute(s,i)}}Wt.isBrowser&&!customElements.get("morph-announcer")&&customElements.define("morph-announcer",Xt);var H,l,N,nt,G;class wt{constructor(t,s){o(this,H);o(this,l);o(this,N);o(this,nt,t=>{var i;if(t.preventDefault(),e(this,l).hasAttribute("data-back")&&e(this,H).previousURL)history.back();else{n(this,N,e(this,l).getAttribute("href")||"/");const h=e(this,l).getAttribute("data-history-action")||"push",g=e(this,l).hasAttribute("data-center-scroll"),b=getComputedStyle(e(this,l)).getPropertyValue("--offset-scroll").trim(),v=b?se.cssValueParser.parse(b):void 0,S=e(this,l).hasAttribute("data-revalidate"),V=e(this,l).hasAttribute("data-keep-search-parameters"),lt=(i=e(this,l).getAttribute("data-submorph"))==null?void 0:i.split(",").map(ht=>ht.trim()),c=e(this,l).hasAttribute("data-clear-state");e(this,H).navigate(e(this,N),{historyAction:h,centerScroll:g,offsetScroll:v,revalidate:S,keepSearchParameters:V,submorph:lt,clearState:c})}});o(this,G,()=>{const t=e(this,l).hasAttribute("data-revalidate");e(this,H).prefetch(e(this,N),t),e(this,l).removeEventListener("pointerenter",e(this,G))});n(this,H,s),n(this,l,t),n(this,N,e(this,l).getAttribute("href")||"/"),e(this,l).addEventListener("click",e(this,nt)),this.checkCurrent(location.pathname),e(this,l).hasAttribute("data-prefetch")&&e(this,l).addEventListener("pointerenter",e(this,G))}get element(){return e(this,l)}checkCurrent(t){var h;const s=e(this,H).normalizePath(t),i=e(this,H).normalizePath(e(this,N));e(this,l).hasAttribute("data-include")&&s.pathname.includes(i.pathname)?e(this,l).classList.add("current"):i.pathname===s.pathname?e(this,l).classList.add("current"):(h=e(this,l).getAttribute("data-associated-paths"))!=null&&h.split(",").find(g=>s.pathname.includes(g))?e(this,l).classList.add("current"):e(this,l).classList.remove("current")}destroy(){e(this,l).removeEventListener("click",e(this,nt)),e(this,l).removeEventListener("pointerenter",e(this,G)),e(this,l).classList.remove("current")}}H=new WeakMap,l=new WeakMap,N=new WeakMap,nt=new WeakMap,G=new WeakMap;const ie=new DOMParser;var M,W,y,P,X,q,J,Y,D,Q,rt;class Bt{constructor(t,s){o(this,M);o(this,W);o(this,y,{x:0,y:0});o(this,P,null);o(this,X,null);o(this,q,null);o(this,J,null);o(this,Y,null);o(this,D,null);o(this,Q);o(this,rt);n(this,M,t),n(this,W,s),n(this,Q,s)}get pathname(){return e(this,W)}get scrollState(){return e(this,y)}get document(){return e(this,q)}setHeaders(t){n(this,rt,t)}setInitialDocument(t){n(this,P,t.cloneNode(!0))}abort(){var t;return(t=e(this,Y))==null?void 0:t.abort(`[${e(this,W)}] page loading cancelled`)}fetch(t,s,i){return B(this,null,function*(){return e(this,D)||e(this,P)&&e(this,P).documentElement.hasAttribute("data-cache")&&(!i||e(this,Q)!==t)||e(this,P)&&e(this,M).isPopstateNavigation?e(this,D):(n(this,Q,t),n(this,D,new Promise(h=>B(this,null,function*(){try{n(this,Y,new AbortController);const b=yield(yield fetch(t,{signal:e(this,Y).signal,headers:dt({"X-MORPH":"true","X-MORPH-CURRENT-PATH":s,"X-MORPH-NEW-PATH":t},e(this,rt))})).text(),v=ie.parseFromString(b,"text/html");this.setInitialDocument(v)}catch(g){console.warn(g)}finally{n(this,Y,null),n(this,D,null),h()}}))),e(this,D))})}cloneDocument(){n(this,q,(e(this,X)||e(this,P)).cloneNode(!0))}get title(){let t="";if(e(this,q).title)t=e(this,q).title;else{const s=e(this,q).querySelector("h1");t=(s==null?void 0:s.innerText)||(s==null?void 0:s.textContent)||e(this,W)}return t}clearScrollState(){e(this,y).x=0,e(this,y).y=0}clearDocumentState(){n(this,X,null)}saveScrollState(){e(this,P).documentElement.hasAttribute("data-no-scroll-restoration")?(e(this,y).x=0,e(this,y).y=0):(e(this,y).x=e(this,M).scrollValue.left,e(this,y).y=e(this,M).scrollValue.top)}restoreScrollPosition(){e(this,M).scrollElement.scroll({top:e(this,y).y,left:e(this,y).x,behavior:"instant"})}saveDocumentState(){e(this,P).documentElement.hasAttribute("data-no-page-restoration")?n(this,X,null):n(this,X,document.cloneNode(!0))}renewScrollPosition(){e(this,M).scrollElement.scroll({top:0,left:0,behavior:"instant"})}saveState(t){n(this,J,t)}clearState(){const t=e(this,J);return n(this,J,null),t}}M=new WeakMap,W=new WeakMap,y=new WeakMap,P=new WeakMap,X=new WeakMap,q=new WeakMap,J=new WeakMap,Y=new WeakMap,D=new WeakMap,Q=new WeakMap,rt=new WeakMap;var A,Z,E,U,d,j,z,I,L,at,R,K,_,tt,u,Lt,ot,mt,bt,Yt,Pt,At,kt,Ct,ft,et;const it=class it{constructor(t){o(this,u);o(this,A,null);o(this,Z,null);o(this,E,[]);o(this,U);o(this,d,null);o(this,j);o(this,z,[]);o(this,I,!1);o(this,L,null);o(this,at,!1);o(this,R,new Map);o(this,K,null);o(this,_,0);o(this,tt,0);o(this,ot,t=>{var s;return((s=t.getAttribute("href"))==null?void 0:s.startsWith("/"))&&!t.hasAttribute("download")&&!t.hasAttribute("data-morph-skip")&&!t.closest("[data-morph-skip]")&&t.getAttribute("target")!=="_blank"});o(this,ft,t=>B(this,null,function*(){t.preventDefault(),n(this,I,!0),yield this.navigate(location.href.replace(location.origin,""),{historyAction:"none"}),n(this,I,!1)}));o(this,et,()=>{const{left:t,top:s}=this.scrollValue,i=s-e(this,tt),h=t-e(this,_);n(this,tt,s),n(this,_,t),document.documentElement.classList.toggle("scroll-y",s>0),document.documentElement.classList.toggle("scroll-x",t>0),document.documentElement.classList.toggle("scroll-y-forward",i>0),document.documentElement.classList.toggle("scroll-y-backward",i<0),document.documentElement.classList.toggle("scroll-x-forward",h>0),document.documentElement.classList.toggle("scroll-x-backward",h<0),C.dispatchEvent(document,"morphScroll",{detail:{left:t,top:s}})});if(Wt.isBrowser&&!it.instance){it.instance=this,n(this,A,{base:st.normalizeBase(t==null?void 0:t.base),waitForHeadToLoad:(t==null?void 0:t.waitForHeadToLoad)!==!1,trailingSlash:(t==null?void 0:t.trailingSlash)||!1,scrollSelector:t==null?void 0:t.scrollSelector,morphInsideScrollContainer:(t==null?void 0:t.morphInsideScrollContainer)||!1}),n(this,Z,p(this,u,bt).call(this,document.body));const s=this.normalizePath(location.pathname+location.hash+location.search);n(this,d,s);const i=new Bt(this,e(this,d).pathname);i.setInitialDocument(document),e(this,R).set(e(this,d).pathname,i),document.documentElement.setAttribute("data-current-pathname",e(this,d).pathname),document.documentElement.setAttribute("data-current-leaf",s.leaf),this.findLinks(),history.scrollRestoration="manual",addEventListener("popstate",e(this,ft)),st.changeHistory({action:"replace",pathname:s.pathname,searchParameters:s.parameters,hash:s.hash}),n(this,K,new Xt),p(this,u,kt).call(this,document)}}get currentURL(){return e(this,d)}get previousURL(){return e(this,j)}get links(){return e(this,E)}get scrollElement(){return e(this,L)}get isPopstateNavigation(){return e(this,I)}get scrollValue(){let t=0,s=0;return e(this,at)?(t=window.scrollY,s=window.scrollX):(t=e(this,L).scrollTop,s=e(this,L).scrollLeft),{top:t,left:s}}saveState(t){const s=e(this,R).get(e(this,d).path);s&&s.saveState(t)}getState(){const t=e(this,R).get(e(this,d).path);return t==null?void 0:t.clearState()}normalizePath(t){return st.splitPath(t,{base:e(this,A).base,trailingSlash:e(this,A).trailingSlash})}prefetch(t,s){return B(this,null,function*(){var h;if(e(this,z).length)return;t=((h=this.pathnameModifier)==null?void 0:h.call(this,t))||t;const i=p(this,u,mt).call(this,t);i==null||i.fetch(t,e(this,d).path,s)})}excludeHeadChild(t){return!1}setHeaders(t){}navigate(V){return B(this,arguments,function*(t,{historyAction:s="push",centerScroll:i,offsetScroll:h,revalidate:g,keepSearchParameters:b,submorph:v,clearState:S}={}){var ht,Ht,Mt,Rt;if(e(this,z).length)return;const lt=((ht=this.pathnameModifier)==null?void 0:ht.call(this,t))||t,c=this.normalizePath(lt);if(((Ht=e(this,U))==null?void 0:Ht.pathname)===c.pathname||e(this,d).pathname===c.pathname){p(this,u,Ct).call(this,c.hash||0,{centerScroll:i,offsetScroll:h,behavior:"smooth"}),C.dispatchEvent(document,"morphSamePath",{custom:!0}),((Mt=e(this,d))==null?void 0:Mt.parameters)!==c.parameters&&(n(this,j,e(this,d)),n(this,d,c),st.changeHistory({action:((Rt=e(this,d))==null?void 0:Rt.hash)!==c.hash?"replace":s,pathname:c.pathname,searchParameters:c.parameters,hash:c.hash}),C.dispatchEvent(document,"morphURLParametersChange",{detail:{newURL:e(this,d),previousURL:e(this,j)}}));return}n(this,U,c),e(this,E).forEach($=>{$.checkCurrent(c.pathname)});try{let $=!0;if(this.preprocessor)try{yield new Promise((a,k)=>{var T;(T=this.preprocessor)==null||T.call(this,{url:c,resolve:a,reject:k,submorph:v})})}catch(a){a?console.error(a):console.log("Route change canceled"),$=!1}if(!$||e(this,U).pathname!==c.pathname){e(this,E).forEach(a=>{a.checkCurrent(e(this,d).pathname)});return}const Tt={url:c,submorph:v};C.dispatchEvent(document,"morphNavigation",{detail:Tt});const pt=p(this,u,mt).call(this,e(this,d).pathname),f=p(this,u,mt).call(this,c.pathname);if(e(this,R).forEach(a=>{a.pathname!==c.pathname&&a.abort()}),yield f==null?void 0:f.fetch(lt,e(this,d).path,g),e(this,U).pathname!==c.pathname){e(this,E).forEach(a=>{a.checkCurrent(e(this,d).path)});return}pt.clearState(),pt.saveScrollState(),pt.saveDocumentState(),e(this,I)||(f.clearScrollState(),f.clearDocumentState()),S&&f.clearState(),f.cloneDocument(),e(this,K).textContent=f.title,document.body.appendChild(e(this,K));const Et=vt(dt({},Tt),{document:f.document});C.dispatchEvent(document,"morphStart",{detail:Et});const xt=Array.from(document.head.children),Nt=Array.from(f.document.head.children),qt=p(this,u,Yt).call(this,xt,Nt),jt=p(this,u,Pt).call(this,xt,qt),ct=p(this,u,Pt).call(this,Nt,qt).filter(a=>!this.excludeHeadChild(a));ct.forEach((a,k)=>{a.tagName==="SCRIPT"&&(ct[k]=p(this,u,Lt).call(this,a))}),ct.forEach(a=>{document.head.appendChild(a)});const gt=ct.filter(a=>{if(a.hasAttribute("data-no-waiting"))return!1;if(p(this,u,At).call(this,a))return!0});e(this,A).waitForHeadToLoad&>.length&&(yield new Promise(a=>B(this,null,function*(){let k=0;try{for(var T=Ot(gt),$t,O,F;$t=!(O=yield T.next()).done;$t=!1){const ut=O.value;ut.onload=()=>{k++,k===gt.length&&a()}}}catch(O){F=[O]}finally{try{$t&&(O=T.return)&&(yield O.call(T))}finally{if(F)throw F[0]}}}))),yield Ft.wait(10);const Dt=[];jt.forEach(a=>{a.hasAttribute("data-permanent")||(p(this,u,At).call(this,a)?Dt.push(a):a.remove())});const Kt=p(this,u,bt).call(this,f.document.body);e(this,A).morphInsideScrollContainer||p(this,u,kt).call(this,f.document),document.documentElement.setAttribute("data-current-pathname",c.pathname),document.documentElement.setAttribute("data-current-leaf",c.leaf),st.changeHistory({action:s,pathname:c.pathname,searchParameters:c.parameters||(b?location.search:""),hash:c.hash}),e(this,K).remove(),n(this,j,e(this,d)),n(this,d,c),e(this,Z).forEach((a,k)=>{const T=Kt[k],$t=getComputedStyle(a).getPropertyValue("--morph-duration");let O=[],F=[];v?v.forEach(m=>{const w=a.querySelector(m),x=T.querySelector(m);w&&x&&(F.push(w),O.push(x))}):(O.push(...T.childNodes),F.push(...a.childNodes)),F.forEach(m=>{m instanceof HTMLElement&&(this.destroyOldLinks(m),m.classList.add("old"))}),O.forEach(m=>{m instanceof HTMLElement&&(this.findNewLinks(m),m.classList.add("new"))}),v?O.forEach((m,w)=>{var x;(x=F[w].parentElement)==null||x.insertBefore(m,F[w])}):a.prepend(...O),ee.requestIdleCallback(()=>{F.forEach(m=>{m instanceof HTMLElement&&m.classList.add("old-idle")}),O.forEach(m=>{var w;m instanceof HTMLElement&&((w=m.parentElement)==null||w.style.setProperty("--new-content-height",m.offsetHeight+"px"),m.classList.add("new-idle"))})});const ut=vt(dt({},Et),{morphElement:a});C.dispatchEvent(document,"morphNewChildrenAdded",{detail:ut});const Gt=new Promise(m=>{setTimeout(()=>{F.forEach(w=>w.remove()),O.forEach(w=>{var x;w instanceof HTMLElement&&((x=w.parentElement)==null||x.style.removeProperty("--new-content-height"),w.classList.remove("new-idle","new"))}),C.dispatchEvent(document,"morphOldChildrenRemoved",{detail:ut}),m()},(parseFloat($t)||0)*1e3+10)});e(this,z).push(Gt)}),this.isPopstateNavigation?document.documentElement.style.setProperty("--new-document-scroll-position",(this.scrollValue.top-f.scrollState.y)*1+"px"):document.documentElement.style.setProperty("--new-document-scroll-position",this.scrollValue.top+"px"),C.dispatchEvent(document,"morphBeforeNavigationScroll",{detail:f.scrollState}),c.hash?(f.clearScrollState(),p(this,u,Ct).call(this,c.hash,{centerScroll:i,offsetScroll:h})):e(this,I)?f.restoreScrollPosition():f.renewScrollPosition(),yield Promise.all(e(this,z)),Dt.forEach(a=>a.remove()),n(this,z,[]),e(this,Z).forEach(a=>{a.querySelectorAll("script").forEach(T=>{T.replaceWith(p(this,u,Lt).call(this,T))})}),e(this,E).forEach(a=>{a.checkCurrent(e(this,d).path)}),C.dispatchEvent(document,"morphComplete",{detail:Et}),document.documentElement.style.removeProperty("--new-document-scroll-position"),window.dispatchEvent(new Event("resize"))}catch($){console.error($)}n(this,U,void 0)})}addLink(t){e(this,E).push(new wt(t,this))}addLinks(t){t.forEach(s=>{this.addLink(s)})}removeLink(t){n(this,E,e(this,E).filter(s=>s.element===t?(s.destroy(),!1):!0))}destroyOldLinks(t){n(this,E,e(this,E).filter(s=>t.contains(s.element)?(s.destroy(),!1):!0))}findNewLinks(t){const s=[...t.querySelectorAll("a")].filter(e(this,ot));e(this,E).push(...s.map(i=>new wt(i,this)))}findLinks(){const t=[...document.documentElement.querySelectorAll("a")].filter(e(this,ot));e(this,E).forEach(s=>s.destroy()),n(this,E,t.map(s=>new wt(s,this)))}};A=new WeakMap,Z=new WeakMap,E=new WeakMap,U=new WeakMap,d=new WeakMap,j=new WeakMap,z=new WeakMap,I=new WeakMap,L=new WeakMap,at=new WeakMap,R=new WeakMap,K=new WeakMap,_=new WeakMap,tt=new WeakMap,u=new WeakSet,Lt=function(t){const s=document.createElement("script");for(let i=0;i<t.attributes.length;i++){const h=t.attributes[i];s.setAttribute(h.name,h.value)}return t.hasAttribute("src")||(s.innerHTML=t.innerHTML),s},ot=new WeakMap,mt=function(t){const s=this.normalizePath(t);let i=e(this,R).get(s.pathname);return i||(i=new Bt(this,s.pathname),e(this,R).set(s.pathname,i)),i},bt=function(t){const s=[...t.querySelectorAll("[data-morph]")];return s.length?s:[t]},Yt=function(t,s){return t.filter(i=>s.find(h=>h.outerHTML===i.outerHTML))},Pt=function(t,s){return t.filter(i=>!s.find(h=>h.outerHTML===i.outerHTML))},At=function(t){return t.tagName==="SCRIPT"||t.tagName==="STYLE"||t.tagName==="LINK"&&t.getAttribute("rel")==="stylesheet"},kt=function(t){var s,i;(s=e(this,L))==null||s.removeEventListener("scroll",e(this,et)),n(this,tt,0),n(this,_,0),n(this,L,e(this,A).scrollSelector&&t.querySelector(e(this,A).scrollSelector)||window),n(this,at,e(this,L)===window),(i=e(this,L))==null||i.addEventListener("scroll",e(this,et)),e(this,et).call(this)},Ct=function(t,s){const i=typeof t=="string"?document.getElementById(t):t;(typeof i=="number"||i)&&Ft.scrollToElement(i,{scrollElement:e(this,L),behavior:(s==null?void 0:s.behavior)||"instant",center:s==null?void 0:s.centerScroll,offset:s==null?void 0:s.offsetScroll})},ft=new WeakMap,et=new WeakMap,it.instance=null;let yt=it;exports.Morph=yt;
|
|
1
|
+
"use strict";var Qt=Object.defineProperty,Zt=Object.defineProperties;var _t=Object.getOwnPropertyDescriptors;var zt=Object.getOwnPropertySymbols;var te=Object.prototype.hasOwnProperty,ee=Object.prototype.propertyIsEnumerable;var It=(r,t)=>(t=Symbol[r])?t:Symbol.for("Symbol."+r),Ot=r=>{throw TypeError(r)};var Vt=(r,t,s)=>t in r?Qt(r,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):r[t]=s,dt=(r,t)=>{for(var s in t||(t={}))te.call(t,s)&&Vt(r,s,t[s]);if(zt)for(var s of zt(t))ee.call(t,s)&&Vt(r,s,t[s]);return r},St=(r,t)=>Zt(r,_t(t));var wt=(r,t,s)=>t.has(r)||Ot("Cannot "+s);var e=(r,t,s)=>(wt(r,t,"read from private field"),s?s.call(r):t.get(r)),o=(r,t,s)=>t.has(r)?Ot("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(r):t.set(r,s),n=(r,t,s,i)=>(wt(r,t,"write to private field"),i?i.call(r,s):t.set(r,s),s),E=(r,t,s)=>(wt(r,t,"access private method"),s);var B=(r,t,s)=>new Promise((i,h)=>{var v=S=>{try{f(s.next(S))}catch(O){h(O)}},b=S=>{try{f(s.throw(S))}catch(O){h(O)}},f=S=>S.done?i(S.value):Promise.resolve(S.value).then(v,b);f((s=s.apply(r,t)).next())});var Ft=(r,t,s)=>(t=r[It("asyncIterator")])?t.call(r):(r=r[It("iterator")](),t={},s=(i,h)=>(h=r[i])&&(t[i]=v=>new Promise((b,f,S)=>(v=h.call(r,v),S=v.done,Promise.resolve(v.value).then(O=>b({value:O,done:S}),f)))),s("next"),s("return"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Xt=require("../index-DekP7OZe.cjs"),C=require("../events-KVanG9sR.cjs"),se=require("../polyfills-Df4r-ETT.cjs"),Bt=require("../scroll-CIdNtj3G.cjs");require("construct-style-sheets-polyfill");const et=require("../url-YEESIcRn.cjs"),ie=require("../css-value-parser/index.cjs");class Yt extends HTMLElement{connectedCallback(){const t={"aria-live":"assertive","aria-atomic":"true",style:"position: absolute; left: 0; top: 0; clip: rect(0 0 0 0); clip-path: inset(50%); overflow: hidden; white-space: nowrap; width: 1px; height: 1px"};for(const[s,i]of Object.entries(t))this.setAttribute(s,i)}}Xt.isBrowser&&!customElements.get("morph-announcer")&&customElements.define("morph-announcer",Yt);var H,l,q,it,G;class Lt{constructor(t,s){o(this,H);o(this,l);o(this,q);o(this,it,t=>{var i;if(t.preventDefault(),document.documentElement.classList.contains("click-disabled"))return;if(e(this,l).hasAttribute("data-back")&&e(this,H).previousURL)history.back();else{n(this,q,e(this,l).getAttribute("href")||"/");const h=e(this,l).getAttribute("data-history-action")||"push",v=e(this,l).hasAttribute("data-center-scroll"),b=getComputedStyle(e(this,l)).getPropertyValue("--offset-scroll").trim(),f=b?ie.cssValueParser.parse(b):void 0,S=e(this,l).hasAttribute("data-revalidate"),O=e(this,l).hasAttribute("data-keep-search-parameters"),lt=(i=e(this,l).getAttribute("data-submorph"))==null?void 0:i.split(",").map(ht=>ht.trim()),c=e(this,l).hasAttribute("data-clear-state");e(this,H).navigate(e(this,q),{historyAction:h,centerScroll:v,offsetScroll:f,revalidate:S,keepSearchParameters:O,submorph:lt,clearState:c})}});o(this,G,()=>{const t=e(this,l).hasAttribute("data-revalidate");e(this,H).prefetch(e(this,q),t),e(this,l).removeEventListener("pointerenter",e(this,G))});n(this,H,s),n(this,l,t),n(this,q,e(this,l).getAttribute("href")||"/"),e(this,l).addEventListener("click",e(this,it)),this.checkCurrent(location.pathname),e(this,l).hasAttribute("data-prefetch")&&e(this,l).addEventListener("pointerenter",e(this,G))}get element(){return e(this,l)}checkCurrent(t){var h;const s=e(this,H).normalizePath(t),i=e(this,H).normalizePath(e(this,q));e(this,l).hasAttribute("data-include")&&s.pathname.includes(i.pathname)?e(this,l).classList.add("current"):i.pathname===s.pathname?e(this,l).classList.add("current"):(h=e(this,l).getAttribute("data-associated-paths"))!=null&&h.split(",").find(v=>s.pathname.includes(v))?e(this,l).classList.add("current"):e(this,l).classList.remove("current")}destroy(){e(this,l).removeEventListener("click",e(this,it)),e(this,l).removeEventListener("pointerenter",e(this,G)),e(this,l).classList.remove("current")}}H=new WeakMap,l=new WeakMap,q=new WeakMap,it=new WeakMap,G=new WeakMap;const ne=new DOMParser;var M,W,L,P,X,D,J,Y,U,Q,nt;class Wt{constructor(t,s){o(this,M);o(this,W);o(this,L,{x:0,y:0});o(this,P,null);o(this,X,null);o(this,D,null);o(this,J,null);o(this,Y,null);o(this,U,null);o(this,Q);o(this,nt);n(this,M,t),n(this,W,s),n(this,Q,s)}get pathname(){return e(this,W)}get scrollState(){return e(this,L)}get document(){return e(this,D)}setHeaders(t){n(this,nt,t)}setInitialDocument(t){n(this,P,t.cloneNode(!0))}abort(){var t;return(t=e(this,Y))==null?void 0:t.abort(`[${e(this,W)}] page loading cancelled`)}fetch(t,s,i){return B(this,null,function*(){return e(this,U)||e(this,P)&&e(this,P).documentElement.hasAttribute("data-cache")&&(!i||e(this,Q)!==t)||e(this,P)&&e(this,M).isPopstateNavigation?e(this,U):(n(this,Q,t),n(this,U,new Promise(h=>B(this,null,function*(){try{n(this,Y,new AbortController);const b=yield(yield fetch(t,{signal:e(this,Y).signal,headers:dt({"X-MORPH":"true","X-MORPH-CURRENT-PATH":s,"X-MORPH-NEW-PATH":t},e(this,nt))})).text(),f=ne.parseFromString(b,"text/html");this.setInitialDocument(f)}catch(v){console.warn(v)}finally{n(this,Y,null),n(this,U,null),h()}}))),e(this,U))})}cloneDocument(){n(this,D,(e(this,X)||e(this,P)).cloneNode(!0))}get title(){let t="";if(e(this,D).title)t=e(this,D).title;else{const s=e(this,D).querySelector("h1");t=(s==null?void 0:s.innerText)||(s==null?void 0:s.textContent)||e(this,W)}return t}clearScrollState(){e(this,L).x=0,e(this,L).y=0}clearDocumentState(){n(this,X,null)}saveScrollState(){e(this,P).documentElement.hasAttribute("data-no-scroll-restoration")?(e(this,L).x=0,e(this,L).y=0):(e(this,L).x=e(this,M).scrollValue.left,e(this,L).y=e(this,M).scrollValue.top)}restoreScrollPosition(){e(this,M).scrollElement.scroll({top:e(this,L).y,left:e(this,L).x,behavior:"instant"})}saveDocumentState(){e(this,P).documentElement.hasAttribute("data-no-page-restoration")?n(this,X,null):n(this,X,document.cloneNode(!0))}renewScrollPosition(){e(this,M).scrollElement.scroll({top:0,left:0,behavior:"instant"})}saveState(t){n(this,J,t)}clearState(){const t=e(this,J);return n(this,J,null),t}}M=new WeakMap,W=new WeakMap,L=new WeakMap,P=new WeakMap,X=new WeakMap,D=new WeakMap,J=new WeakMap,Y=new WeakMap,U=new WeakMap,Q=new WeakMap,nt=new WeakMap;var A,rt,g,z,m,j,I,V,y,at,R,K,Z,_,u,bt,ot,mt,Pt,jt,At,kt,Ct,Ht,ft,tt;const st=class st{constructor(t){o(this,u);o(this,A,null);o(this,rt,null);o(this,g,[]);o(this,z);o(this,m,null);o(this,j);o(this,I,[]);o(this,V,!1);o(this,y,null);o(this,at,!1);o(this,R,new Map);o(this,K,null);o(this,Z,0);o(this,_,0);o(this,ot,t=>{var s;return((s=t.getAttribute("href"))==null?void 0:s.startsWith("/"))&&!t.hasAttribute("download")&&!t.hasAttribute("data-morph-skip")&&!t.closest("[data-morph-skip]")&&t.getAttribute("target")!=="_blank"});o(this,ft,t=>B(this,null,function*(){t.preventDefault(),n(this,V,!0),yield this.navigate(location.href.replace(location.origin,""),{historyAction:"none",submorph:t.state.submorph}),n(this,V,!1)}));o(this,tt,()=>{const{left:t,top:s}=this.scrollValue,i=s-e(this,_),h=t-e(this,Z);n(this,_,s),n(this,Z,t),document.documentElement.classList.toggle("scroll-y",s>0),document.documentElement.classList.toggle("scroll-x",t>0),document.documentElement.classList.toggle("scroll-y-forward",i>0),document.documentElement.classList.toggle("scroll-y-backward",i<0),document.documentElement.classList.toggle("scroll-x-forward",h>0),document.documentElement.classList.toggle("scroll-x-backward",h<0),C.dispatchEvent(document,"morphScroll",{detail:{left:t,top:s}})});if(Xt.isBrowser&&!st.instance){st.instance=this,n(this,A,{base:et.normalizeBase(t==null?void 0:t.base),waitForHeadToLoad:(t==null?void 0:t.waitForHeadToLoad)!==!1,trailingSlash:(t==null?void 0:t.trailingSlash)||!1,scrollSelector:t==null?void 0:t.scrollSelector,morphInsideScrollContainer:(t==null?void 0:t.morphInsideScrollContainer)||!1}),n(this,rt,E(this,u,Pt).call(this,document.body));const s=this.normalizePath(location.pathname+location.hash+location.search);n(this,m,s);const i=new Wt(this,e(this,m).pathname);i.setInitialDocument(document),e(this,R).set(e(this,m).pathname,i),document.documentElement.setAttribute("data-current-pathname",e(this,m).pathname),document.documentElement.setAttribute("data-current-leaf",s.leaf),this.findLinks(),history.scrollRestoration="manual",addEventListener("popstate",e(this,ft)),et.changeHistory({action:"replace",pathname:s.pathname,searchParameters:s.parameters,hash:s.hash}),n(this,K,new Yt),E(this,u,Ct).call(this,document)}}get currentURL(){return e(this,m)}get previousURL(){return e(this,j)}get links(){return e(this,g)}get scrollElement(){return e(this,y)}get isPopstateNavigation(){return e(this,V)}get scrollValue(){let t=0,s=0;return e(this,at)?(t=window.scrollY,s=window.scrollX):(t=e(this,y).scrollTop,s=e(this,y).scrollLeft),{top:t,left:s}}saveState(t){const s=e(this,R).get(e(this,m).path);s&&s.saveState(t)}getState(){const t=e(this,R).get(e(this,m).path);return t==null?void 0:t.clearState()}normalizePath(t){return et.splitPath(t,{base:e(this,A).base,trailingSlash:e(this,A).trailingSlash})}prefetch(t,s){return B(this,null,function*(){var h;if(e(this,I).length)return;t=((h=this.pathnameModifier)==null?void 0:h.call(this,t))||t;const i=E(this,u,mt).call(this,t);i==null||i.fetch(t,e(this,m).path,s)})}excludeHeadChild(t){return!1}setHeaders(t){}navigate(O){return B(this,arguments,function*(t,{historyAction:s="push",centerScroll:i,offsetScroll:h,revalidate:v,keepSearchParameters:b,submorph:f,clearState:S}={}){var ht,Mt,Rt,Tt;if(e(this,I).length)return;const lt=((ht=this.pathnameModifier)==null?void 0:ht.call(this,t))||t,c=this.normalizePath(lt);if(((Mt=e(this,z))==null?void 0:Mt.pathname)===c.pathname||e(this,m).pathname===c.pathname){E(this,u,Ht).call(this,c.hash||0,{centerScroll:i,offsetScroll:h,behavior:"smooth"}),C.dispatchEvent(document,"morphSamePath",{custom:!0}),((Rt=e(this,m))==null?void 0:Rt.parameters)!==c.parameters&&(n(this,j,e(this,m)),n(this,m,c),et.changeHistory({action:((Tt=e(this,m))==null?void 0:Tt.hash)!==c.hash?"replace":s,pathname:c.pathname,searchParameters:c.parameters,hash:c.hash,state:{submorph:f}}),C.dispatchEvent(document,"morphURLParametersChange",{detail:{newURL:e(this,m),previousURL:e(this,j)}}));return}n(this,z,c),e(this,g).forEach($=>{$.checkCurrent(c.pathname)});try{let $=!0;if(this.preprocessor)try{yield new Promise((a,k)=>{var T;(T=this.preprocessor)==null||T.call(this,{url:c,resolve:a,reject:k,submorph:f})})}catch(a){a?console.error(a):console.log("Route change canceled"),$=!1}if(!$||e(this,z).pathname!==c.pathname){e(this,g).forEach(a=>{a.checkCurrent(e(this,m).pathname)});return}const xt={url:c,submorph:f};C.dispatchEvent(document,"morphNavigation",{detail:xt});const pt=E(this,u,mt).call(this,e(this,m).pathname),p=E(this,u,mt).call(this,c.pathname);if(e(this,R).forEach(a=>{a.pathname!==c.pathname&&a.abort()}),yield p==null?void 0:p.fetch(lt,e(this,m).path,v),e(this,z).pathname!==c.pathname){e(this,g).forEach(a=>{a.checkCurrent(e(this,m).path)});return}pt.clearState(),pt.saveScrollState(),pt.saveDocumentState(),e(this,V)||(p.clearScrollState(),p.clearDocumentState()),S&&p.clearState(),p.cloneDocument(),e(this,K).textContent=p.title,document.body.appendChild(e(this,K));const Et=St(dt({},xt),{document:p.document});C.dispatchEvent(document,"morphStart",{detail:Et});const Nt=Array.from(document.head.children),qt=Array.from(p.document.head.children),Dt=E(this,u,jt).call(this,Nt,qt),Kt=E(this,u,At).call(this,Nt,Dt),ct=E(this,u,At).call(this,qt,Dt).filter(a=>!this.excludeHeadChild(a));ct.forEach((a,k)=>{a.tagName==="SCRIPT"&&(ct[k]=E(this,u,bt).call(this,a))}),ct.forEach(a=>{document.head.appendChild(a)});const gt=ct.filter(a=>{if(a.hasAttribute("data-no-waiting"))return!1;if(E(this,u,kt).call(this,a))return!0});e(this,A).waitForHeadToLoad&>.length&&(yield new Promise(a=>B(this,null,function*(){let k=0;try{for(var T=Ft(gt),Gt,F,x;Gt=!(F=yield T.next()).done;Gt=!1){const ut=F.value;ut.onload=()=>{k++,k===gt.length&&a()}}}catch(F){x=[F]}finally{try{Gt&&(F=T.return)&&(yield F.call(T))}finally{if(x)throw x[0]}}}))),yield Bt.wait(10);const Ut=[];Kt.forEach(a=>{a.hasAttribute("data-permanent")||(E(this,u,kt).call(this,a)?Ut.push(a):a.remove())});const $t=E(this,u,Pt).call(this,p.document.body);!e(this,A).morphInsideScrollContainer&&!f&&E(this,u,Ct).call(this,p.document),document.documentElement.setAttribute("data-current-pathname",c.pathname),document.documentElement.setAttribute("data-current-leaf",c.leaf),et.changeHistory({action:s,pathname:c.pathname,searchParameters:c.parameters||(b?location.search:""),hash:c.hash,state:{submorph:f}}),e(this,K).remove(),n(this,j,e(this,m)),n(this,m,c);const vt=[];e(this,rt).forEach((a,k)=>{const T=$t[k],Gt=getComputedStyle(a).getPropertyValue("--morph-duration");let F=[],x=[];f?(f.forEach(d=>{const w=a.querySelector(d),N=T.querySelector(d);w&&N&&(x.push(w),F.push(N))}),x.forEach(d=>{d.parentElement&&vt.push(d.parentElement)})):(F.push(...T.childNodes),x.push(...a.childNodes),vt.push(a)),x.forEach(d=>{d instanceof HTMLElement&&(this.destroyOldLinks(d),d.classList.add("old"))}),F.forEach(d=>{d instanceof HTMLElement&&(this.findNewLinks(d),d.classList.add("new"))}),f?F.forEach((d,w)=>{var N;(N=x[w].parentElement)==null||N.insertBefore(d,x[w])}):a.prepend(...F),se.requestIdleCallback(()=>{x.forEach(d=>{d instanceof HTMLElement&&d.classList.add("old-idle")}),F.forEach(d=>{var w;d instanceof HTMLElement&&((w=d.parentElement)==null||w.style.setProperty("--new-content-height",d.offsetHeight+"px"),d.classList.add("new-idle"))})});const ut=St(dt({},Et),{morphElement:a});C.dispatchEvent(document,"morphNewChildrenAdded",{detail:ut});const Jt=new Promise(d=>{setTimeout(()=>{x.forEach(w=>w.remove()),F.forEach(w=>{var N;w instanceof HTMLElement&&((N=w.parentElement)==null||N.style.removeProperty("--new-content-height"),w.classList.remove("new-idle","new"))}),C.dispatchEvent(document,"morphOldChildrenRemoved",{detail:ut}),d()},(parseFloat(Gt)||0)*1e3+10)});e(this,I).push(Jt)}),this.isPopstateNavigation?document.documentElement.style.setProperty("--new-document-scroll-position",(this.scrollValue.top-p.scrollState.y)*1+"px"):document.documentElement.style.setProperty("--new-document-scroll-position",this.scrollValue.top+"px"),C.dispatchEvent(document,"morphBeforeNavigationScroll",{detail:p.scrollState}),c.hash?(p.clearScrollState(),E(this,u,Ht).call(this,c.hash,{centerScroll:i,offsetScroll:h})):e(this,V)?p.restoreScrollPosition():p.renewScrollPosition(),yield Promise.all(e(this,I)),Ut.forEach(a=>a.remove()),n(this,I,[]),vt.forEach(a=>{a.querySelectorAll("script").forEach(T=>{T.replaceWith(E(this,u,bt).call(this,T))})}),e(this,g).forEach(a=>{a.checkCurrent(e(this,m).path)}),C.dispatchEvent(document,"morphComplete",{detail:Et}),document.documentElement.style.removeProperty("--new-document-scroll-position"),window.dispatchEvent(new Event("resize"))}catch($){console.error($)}n(this,z,void 0)})}addLink(t){e(this,g).push(new Lt(t,this))}addLinks(t){t.forEach(s=>{this.addLink(s)})}removeLink(t){n(this,g,e(this,g).filter(s=>s.element===t?(s.destroy(),!1):!0))}destroyOldLinks(t){n(this,g,e(this,g).filter(s=>t.contains(s.element)?(s.destroy(),!1):!0))}findNewLinks(t){const s=[...t.querySelectorAll("a")].filter(e(this,ot));e(this,g).push(...s.map(i=>new Lt(i,this)))}findLinks(){const t=[...document.documentElement.querySelectorAll("a")].filter(e(this,ot));e(this,g).forEach(s=>s.destroy()),n(this,g,t.map(s=>new Lt(s,this)))}};A=new WeakMap,rt=new WeakMap,g=new WeakMap,z=new WeakMap,m=new WeakMap,j=new WeakMap,I=new WeakMap,V=new WeakMap,y=new WeakMap,at=new WeakMap,R=new WeakMap,K=new WeakMap,Z=new WeakMap,_=new WeakMap,u=new WeakSet,bt=function(t){const s=document.createElement("script");for(let i=0;i<t.attributes.length;i++){const h=t.attributes[i];s.setAttribute(h.name,h.value)}return t.hasAttribute("src")||(s.innerHTML=t.innerHTML),s},ot=new WeakMap,mt=function(t){const s=this.normalizePath(t);let i=e(this,R).get(s.pathname);return i||(i=new Wt(this,s.pathname),e(this,R).set(s.pathname,i)),i},Pt=function(t){const s=[...t.querySelectorAll("[data-morph]")];return s.length?s:[t]},jt=function(t,s){return t.filter(i=>s.find(h=>h.outerHTML===i.outerHTML))},At=function(t,s){return t.filter(i=>!s.find(h=>h.outerHTML===i.outerHTML))},kt=function(t){return t.tagName==="SCRIPT"||t.tagName==="STYLE"||t.tagName==="LINK"&&t.getAttribute("rel")==="stylesheet"},Ct=function(t){var s,i;(s=e(this,y))==null||s.removeEventListener("scroll",e(this,tt)),n(this,_,0),n(this,Z,0),n(this,y,e(this,A).scrollSelector&&t.querySelector(e(this,A).scrollSelector)||window),n(this,at,e(this,y)===window),(i=e(this,y))==null||i.addEventListener("scroll",e(this,tt)),e(this,tt).call(this)},Ht=function(t,s){const i=typeof t=="string"?document.getElementById(t):t;(typeof i=="number"||i)&&Bt.scrollToElement(i,{scrollElement:e(this,y),behavior:(s==null?void 0:s.behavior)||"instant",center:s==null?void 0:s.centerScroll,offset:s==null?void 0:s.offsetScroll})},ft=new WeakMap,tt=new WeakMap,st.instance=null;let yt=st;exports.Morph=yt;
|