react-spring-carousel 3.0.0-beta-2.0.1875 → 3.0.0-beta-2.0.1876
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/dist/index.es.js +176 -176
- package/dist/index.umd.js +3 -3
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useSpring as
|
|
3
|
-
import Z, { useRef as $, useEffect as
|
|
4
|
-
function
|
|
1
|
+
import { jsxs as Ot, jsx as Q } from "react/jsx-runtime";
|
|
2
|
+
import { useSpring as $t } from "@react-spring/web";
|
|
3
|
+
import Z, { useRef as $, useEffect as _t, useState as At } from "react";
|
|
4
|
+
function Pt(r, t, e) {
|
|
5
5
|
return Math.max(t, Math.min(r, e));
|
|
6
6
|
}
|
|
7
7
|
const v = {
|
|
@@ -21,17 +21,17 @@ const v = {
|
|
|
21
21
|
r[0] -= t[0], r[1] -= t[1];
|
|
22
22
|
}
|
|
23
23
|
};
|
|
24
|
-
function
|
|
24
|
+
function ct(r, t, e) {
|
|
25
25
|
return t === 0 || Math.abs(t) === 1 / 0 ? Math.pow(r, e * 5) : r * t * e / (t + e * r);
|
|
26
26
|
}
|
|
27
|
-
function
|
|
28
|
-
return n === 0 ?
|
|
27
|
+
function ut(r, t, e, n = 0.15) {
|
|
28
|
+
return n === 0 ? Pt(r, t, e) : r < t ? -ct(t - r, e - t, n) + t : r > e ? +ct(r - e, e - t, n) + e : r;
|
|
29
29
|
}
|
|
30
|
-
function
|
|
30
|
+
function Nt(r, [t, e], [n, s]) {
|
|
31
31
|
const [[i, u], [a, c]] = r;
|
|
32
|
-
return [
|
|
32
|
+
return [ut(t, i, u, n), ut(e, a, c, s)];
|
|
33
33
|
}
|
|
34
|
-
function
|
|
34
|
+
function Mt(r, t) {
|
|
35
35
|
if (typeof r != "object" || r === null) return r;
|
|
36
36
|
var e = r[Symbol.toPrimitive];
|
|
37
37
|
if (e !== void 0) {
|
|
@@ -41,19 +41,19 @@ function Nt(r, t) {
|
|
|
41
41
|
}
|
|
42
42
|
return (t === "string" ? String : Number)(r);
|
|
43
43
|
}
|
|
44
|
-
function
|
|
45
|
-
var t =
|
|
44
|
+
function Rt(r) {
|
|
45
|
+
var t = Mt(r, "string");
|
|
46
46
|
return typeof t == "symbol" ? t : String(t);
|
|
47
47
|
}
|
|
48
48
|
function b(r, t, e) {
|
|
49
|
-
return t =
|
|
49
|
+
return t = Rt(t), t in r ? Object.defineProperty(r, t, {
|
|
50
50
|
value: e,
|
|
51
51
|
enumerable: !0,
|
|
52
52
|
configurable: !0,
|
|
53
53
|
writable: !0
|
|
54
54
|
}) : r[t] = e, r;
|
|
55
55
|
}
|
|
56
|
-
function
|
|
56
|
+
function lt(r, t) {
|
|
57
57
|
var e = Object.keys(r);
|
|
58
58
|
if (Object.getOwnPropertySymbols) {
|
|
59
59
|
var n = Object.getOwnPropertySymbols(r);
|
|
@@ -66,15 +66,15 @@ function ut(r, t) {
|
|
|
66
66
|
function h(r) {
|
|
67
67
|
for (var t = 1; t < arguments.length; t++) {
|
|
68
68
|
var e = arguments[t] != null ? arguments[t] : {};
|
|
69
|
-
t % 2 ?
|
|
69
|
+
t % 2 ? lt(Object(e), !0).forEach(function(n) {
|
|
70
70
|
b(r, n, e[n]);
|
|
71
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(r, Object.getOwnPropertyDescriptors(e)) :
|
|
71
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(r, Object.getOwnPropertyDescriptors(e)) : lt(Object(e)).forEach(function(n) {
|
|
72
72
|
Object.defineProperty(r, n, Object.getOwnPropertyDescriptor(e, n));
|
|
73
73
|
});
|
|
74
74
|
}
|
|
75
75
|
return r;
|
|
76
76
|
}
|
|
77
|
-
const
|
|
77
|
+
const bt = {
|
|
78
78
|
pointer: {
|
|
79
79
|
start: "down",
|
|
80
80
|
change: "move",
|
|
@@ -99,60 +99,60 @@ const _t = {
|
|
|
99
99
|
function ft(r) {
|
|
100
100
|
return r ? r[0].toUpperCase() + r.slice(1) : "";
|
|
101
101
|
}
|
|
102
|
-
const
|
|
103
|
-
function
|
|
104
|
-
return r && !
|
|
102
|
+
const Lt = ["enter", "leave"];
|
|
103
|
+
function Vt(r = !1, t) {
|
|
104
|
+
return r && !Lt.includes(t);
|
|
105
105
|
}
|
|
106
|
-
function
|
|
107
|
-
const n =
|
|
108
|
-
return "on" + ft(r) + ft(s) + (
|
|
106
|
+
function jt(r, t = "", e = !1) {
|
|
107
|
+
const n = bt[r], s = n && n[t] || t;
|
|
108
|
+
return "on" + ft(r) + ft(s) + (Vt(e, s) ? "Capture" : "");
|
|
109
109
|
}
|
|
110
|
-
const
|
|
111
|
-
function
|
|
110
|
+
const Ut = ["gotpointercapture", "lostpointercapture"];
|
|
111
|
+
function Kt(r) {
|
|
112
112
|
let t = r.substring(2).toLowerCase();
|
|
113
113
|
const e = !!~t.indexOf("passive");
|
|
114
114
|
e && (t = t.replace("passive", ""));
|
|
115
|
-
const n =
|
|
115
|
+
const n = Ut.includes(t) ? "capturecapture" : "capture", s = !!~t.indexOf(n);
|
|
116
116
|
return s && (t = t.replace("capture", "")), {
|
|
117
117
|
device: t,
|
|
118
118
|
capture: s,
|
|
119
119
|
passive: e
|
|
120
120
|
};
|
|
121
121
|
}
|
|
122
|
-
function
|
|
123
|
-
const e =
|
|
122
|
+
function Bt(r, t = "") {
|
|
123
|
+
const e = bt[r], n = e && e[t] || t;
|
|
124
124
|
return r + n;
|
|
125
125
|
}
|
|
126
126
|
function H(r) {
|
|
127
127
|
return "touches" in r;
|
|
128
128
|
}
|
|
129
|
-
function
|
|
129
|
+
function wt(r) {
|
|
130
130
|
return H(r) ? "touch" : "pointerType" in r ? r.pointerType : "mouse";
|
|
131
131
|
}
|
|
132
|
-
function
|
|
132
|
+
function zt(r) {
|
|
133
133
|
return Array.from(r.touches).filter((t) => {
|
|
134
134
|
var e, n;
|
|
135
135
|
return t.target === r.currentTarget || ((e = r.currentTarget) === null || e === void 0 || (n = e.contains) === null || n === void 0 ? void 0 : n.call(e, t.target));
|
|
136
136
|
});
|
|
137
137
|
}
|
|
138
|
-
function
|
|
138
|
+
function Wt(r) {
|
|
139
139
|
return r.type === "touchend" || r.type === "touchcancel" ? r.changedTouches : r.targetTouches;
|
|
140
140
|
}
|
|
141
|
-
function
|
|
142
|
-
return H(r) ?
|
|
141
|
+
function Et(r) {
|
|
142
|
+
return H(r) ? Wt(r)[0] : r;
|
|
143
143
|
}
|
|
144
|
-
function
|
|
145
|
-
return
|
|
144
|
+
function Yt(r) {
|
|
145
|
+
return zt(r).map((t) => t.identifier);
|
|
146
146
|
}
|
|
147
147
|
function tt(r) {
|
|
148
|
-
const t =
|
|
148
|
+
const t = Et(r);
|
|
149
149
|
return H(r) ? t.identifier : t.pointerId;
|
|
150
150
|
}
|
|
151
|
-
function
|
|
152
|
-
const t =
|
|
151
|
+
function dt(r) {
|
|
152
|
+
const t = Et(r);
|
|
153
153
|
return [t.clientX, t.clientY];
|
|
154
154
|
}
|
|
155
|
-
function
|
|
155
|
+
function Ft(r) {
|
|
156
156
|
const t = {};
|
|
157
157
|
if ("buttons" in r && (t.buttons = r.buttons), "shiftKey" in r) {
|
|
158
158
|
const {
|
|
@@ -173,21 +173,21 @@ function Yt(r) {
|
|
|
173
173
|
function F(r, ...t) {
|
|
174
174
|
return typeof r == "function" ? r(...t) : r;
|
|
175
175
|
}
|
|
176
|
-
function
|
|
176
|
+
function Ht() {
|
|
177
177
|
}
|
|
178
|
-
function
|
|
179
|
-
return r.length === 0 ?
|
|
178
|
+
function Gt(...r) {
|
|
179
|
+
return r.length === 0 ? Ht : r.length === 1 ? r[0] : function() {
|
|
180
180
|
let t;
|
|
181
181
|
for (const e of r)
|
|
182
182
|
t = e.apply(this, arguments) || t;
|
|
183
183
|
return t;
|
|
184
184
|
};
|
|
185
185
|
}
|
|
186
|
-
function
|
|
186
|
+
function ht(r, t) {
|
|
187
187
|
return Object.assign({}, t, r || {});
|
|
188
188
|
}
|
|
189
|
-
const
|
|
190
|
-
class
|
|
189
|
+
const Xt = 32;
|
|
190
|
+
class qt {
|
|
191
191
|
constructor(t, e, n) {
|
|
192
192
|
this.ctrl = t, this.args = e, this.key = n, this.state || (this.state = {}, this.computeValues([0, 0]), this.computeInitial(), this.init && this.init(), this.reset());
|
|
193
193
|
}
|
|
@@ -244,32 +244,32 @@ class Xt {
|
|
|
244
244
|
} = this;
|
|
245
245
|
e.args = this.args;
|
|
246
246
|
let i = 0;
|
|
247
|
-
if (t && (e.event = t, n.preventDefault && t.cancelable && e.event.preventDefault(), e.type = t.type, s.touches = this.ctrl.pointerIds.size || this.ctrl.touchIds.size, s.locked = !!document.pointerLockElement, Object.assign(s,
|
|
248
|
-
const
|
|
249
|
-
v.addTo(e._distance,
|
|
247
|
+
if (t && (e.event = t, n.preventDefault && t.cancelable && e.event.preventDefault(), e.type = t.type, s.touches = this.ctrl.pointerIds.size || this.ctrl.touchIds.size, s.locked = !!document.pointerLockElement, Object.assign(s, Ft(t)), s.down = s.pressed = s.buttons % 2 === 1 || s.touches > 0, i = t.timeStamp - e.timeStamp, e.timeStamp = t.timeStamp, e.elapsedTime = e.timeStamp - e.startTime), e._active) {
|
|
248
|
+
const f = e._delta.map(Math.abs);
|
|
249
|
+
v.addTo(e._distance, f);
|
|
250
250
|
}
|
|
251
251
|
this.axisIntent && this.axisIntent(t);
|
|
252
252
|
const [u, a] = e._movement, [c, p] = n.threshold, {
|
|
253
|
-
_step:
|
|
253
|
+
_step: l,
|
|
254
254
|
values: x
|
|
255
255
|
} = e;
|
|
256
|
-
if (n.hasCustomTransform ? (
|
|
256
|
+
if (n.hasCustomTransform ? (l[0] === !1 && (l[0] = Math.abs(u) >= c && x[0]), l[1] === !1 && (l[1] = Math.abs(a) >= p && x[1])) : (l[0] === !1 && (l[0] = Math.abs(u) >= c && Math.sign(u) * c), l[1] === !1 && (l[1] = Math.abs(a) >= p && Math.sign(a) * p)), e.intentional = l[0] !== !1 || l[1] !== !1, !e.intentional) return;
|
|
257
257
|
const y = [0, 0];
|
|
258
258
|
if (n.hasCustomTransform) {
|
|
259
|
-
const [
|
|
260
|
-
y[0] =
|
|
259
|
+
const [f, M] = x;
|
|
260
|
+
y[0] = l[0] !== !1 ? f - l[0] : 0, y[1] = l[1] !== !1 ? M - l[1] : 0;
|
|
261
261
|
} else
|
|
262
|
-
y[0] =
|
|
262
|
+
y[0] = l[0] !== !1 ? u - l[0] : 0, y[1] = l[1] !== !1 ? a - l[1] : 0;
|
|
263
263
|
this.restrictToAxis && !e._blocked && this.restrictToAxis(y);
|
|
264
264
|
const P = e.offset, N = e._active && !e._blocked || e.active;
|
|
265
265
|
N && (e.first = e._active && !e.active, e.last = !e._active && e.active, e.active = s[this.ingKey] = e._active, t && (e.first && ("bounds" in n && (e._bounds = F(n.bounds, e)), this.setup && this.setup()), e.movement = y, this.computeOffset()));
|
|
266
266
|
const [A, C] = e.offset, [[_, z], [I, w]] = e._bounds;
|
|
267
267
|
e.overflow = [A < _ ? -1 : A > z ? 1 : 0, C < I ? -1 : C > w ? 1 : 0], e._movementBound[0] = e.overflow[0] ? e._movementBound[0] === !1 ? e._movement[0] : e._movementBound[0] : !1, e._movementBound[1] = e.overflow[1] ? e._movementBound[1] === !1 ? e._movement[1] : e._movementBound[1] : !1;
|
|
268
268
|
const V = e._active ? n.rubberband || [0, 0] : [0, 0];
|
|
269
|
-
if (e.offset =
|
|
269
|
+
if (e.offset = Nt(e._bounds, e.offset, V), e.delta = v.sub(e.offset, P), this.computeMovement(), N && (!e.last || i > Xt)) {
|
|
270
270
|
e.delta = v.sub(e.offset, P);
|
|
271
|
-
const
|
|
272
|
-
v.addTo(e.distance,
|
|
271
|
+
const f = e.delta.map(Math.abs);
|
|
272
|
+
v.addTo(e.distance, f), e.direction = e.delta.map(Math.sign), e._direction = e._delta.map(Math.sign), !e.first && i > 0 && (e.velocity = [f[0] / i, f[1] / i], e.timeDelta = i);
|
|
273
273
|
}
|
|
274
274
|
}
|
|
275
275
|
emit() {
|
|
@@ -284,14 +284,14 @@ class Xt {
|
|
|
284
284
|
this.eventStore.clean(), this.timeoutStore.clean();
|
|
285
285
|
}
|
|
286
286
|
}
|
|
287
|
-
function
|
|
287
|
+
function Jt([r, t], e) {
|
|
288
288
|
const n = Math.abs(r), s = Math.abs(t);
|
|
289
289
|
if (n > s && n > e)
|
|
290
290
|
return "x";
|
|
291
291
|
if (s > n && s > e)
|
|
292
292
|
return "y";
|
|
293
293
|
}
|
|
294
|
-
class
|
|
294
|
+
class Qt extends qt {
|
|
295
295
|
constructor(...t) {
|
|
296
296
|
super(...t), b(this, "aliasKey", "xy");
|
|
297
297
|
}
|
|
@@ -310,8 +310,8 @@ class Jt extends Xt {
|
|
|
310
310
|
axisIntent(t) {
|
|
311
311
|
const e = this.state, n = this.config;
|
|
312
312
|
if (!e.axis && t) {
|
|
313
|
-
const s = typeof n.axisThreshold == "object" ? n.axisThreshold[
|
|
314
|
-
e.axis =
|
|
313
|
+
const s = typeof n.axisThreshold == "object" ? n.axisThreshold[wt(t)] : n.axisThreshold;
|
|
314
|
+
e.axis = Jt(e._movement, s);
|
|
315
315
|
}
|
|
316
316
|
e._blocked = (n.lockDirection || !!n.axis) && !e.axis || !!n.axis && n.axis !== e.axis;
|
|
317
317
|
}
|
|
@@ -327,7 +327,7 @@ class Jt extends Xt {
|
|
|
327
327
|
}
|
|
328
328
|
}
|
|
329
329
|
}
|
|
330
|
-
const
|
|
330
|
+
const pt = (r) => r, mt = 0.15, nt = {
|
|
331
331
|
enabled(r = !0) {
|
|
332
332
|
return r;
|
|
333
333
|
},
|
|
@@ -343,7 +343,7 @@ const ht = (r) => r, pt = 0.15, nt = {
|
|
|
343
343
|
rubberband(r = 0) {
|
|
344
344
|
switch (r) {
|
|
345
345
|
case !0:
|
|
346
|
-
return [
|
|
346
|
+
return [mt, mt];
|
|
347
347
|
case !1:
|
|
348
348
|
return [0, 0];
|
|
349
349
|
default:
|
|
@@ -357,13 +357,13 @@ const ht = (r) => r, pt = 0.15, nt = {
|
|
|
357
357
|
transform(r, t, e) {
|
|
358
358
|
const n = r || e.shared.transform;
|
|
359
359
|
if (this.hasCustomTransform = !!n, process.env.NODE_ENV === "development") {
|
|
360
|
-
const s = n ||
|
|
360
|
+
const s = n || pt;
|
|
361
361
|
return (i) => {
|
|
362
362
|
const u = s(i);
|
|
363
363
|
return (!isFinite(u[0]) || !isFinite(u[1])) && console.warn(`[@use-gesture]: config.transform() must produce a valid result, but it was: [${u[0]},${[1]}]`), u;
|
|
364
364
|
};
|
|
365
365
|
}
|
|
366
|
-
return n ||
|
|
366
|
+
return n || pt;
|
|
367
367
|
},
|
|
368
368
|
threshold(r) {
|
|
369
369
|
return v.toVector(r, 0);
|
|
@@ -386,13 +386,13 @@ process.env.NODE_ENV === "development" && Object.assign(nt, {
|
|
|
386
386
|
return NaN;
|
|
387
387
|
}
|
|
388
388
|
});
|
|
389
|
-
const
|
|
389
|
+
const Zt = 0, K = h(h({}, nt), {}, {
|
|
390
390
|
axis(r, t, {
|
|
391
391
|
axis: e
|
|
392
392
|
}) {
|
|
393
393
|
if (this.lockDirection = e === "lock", !this.lockDirection) return e;
|
|
394
394
|
},
|
|
395
|
-
axisThreshold(r =
|
|
395
|
+
axisThreshold(r = Zt) {
|
|
396
396
|
return r;
|
|
397
397
|
},
|
|
398
398
|
bounds(r = {}) {
|
|
@@ -410,13 +410,13 @@ const Qt = 0, K = h(h({}, nt), {}, {
|
|
|
410
410
|
} = r;
|
|
411
411
|
return [[t, e], [n, s]];
|
|
412
412
|
}
|
|
413
|
-
}),
|
|
413
|
+
}), gt = {
|
|
414
414
|
ArrowRight: (r, t = 1) => [r * t, 0],
|
|
415
415
|
ArrowLeft: (r, t = 1) => [-1 * r * t, 0],
|
|
416
416
|
ArrowUp: (r, t = 1) => [0, -1 * r * t],
|
|
417
417
|
ArrowDown: (r, t = 1) => [0, r * t]
|
|
418
418
|
};
|
|
419
|
-
class
|
|
419
|
+
class te extends Qt {
|
|
420
420
|
constructor(...t) {
|
|
421
421
|
super(...t), b(this, "ingKey", "dragging");
|
|
422
422
|
}
|
|
@@ -453,7 +453,7 @@ class Zt extends Jt {
|
|
|
453
453
|
const e = this.config, n = this.state;
|
|
454
454
|
if (t.buttons != null && (Array.isArray(e.pointerButtons) ? !e.pointerButtons.includes(t.buttons) : e.pointerButtons !== -1 && e.pointerButtons !== t.buttons)) return;
|
|
455
455
|
const s = this.ctrl.setEventIds(t);
|
|
456
|
-
e.pointerCapture && t.target.setPointerCapture(t.pointerId), !(s && s.size > 1 && n._pointerActive) && (this.start(t), this.setupPointer(t), n._pointerId = tt(t), n._pointerActive = !0, this.computeValues(
|
|
456
|
+
e.pointerCapture && t.target.setPointerCapture(t.pointerId), !(s && s.size > 1 && n._pointerActive) && (this.start(t), this.setupPointer(t), n._pointerId = tt(t), n._pointerActive = !0, this.computeValues(dt(t)), this.computeInitial(), e.preventScrollAxis && wt(t) !== "mouse" ? (n._active = !1, this.setupScrollPrevention(t)) : e.delay > 0 ? (this.setupDelayTrigger(t), e.triggerAllEvents && (this.compute(t), this.emit())) : this.startPointerDrag(t));
|
|
457
457
|
}
|
|
458
458
|
startPointerDrag(t) {
|
|
459
459
|
const e = this.state;
|
|
@@ -464,7 +464,7 @@ class Zt extends Jt {
|
|
|
464
464
|
if (!e._pointerActive) return;
|
|
465
465
|
const s = tt(t);
|
|
466
466
|
if (e._pointerId !== void 0 && s !== e._pointerId) return;
|
|
467
|
-
const i =
|
|
467
|
+
const i = dt(t);
|
|
468
468
|
if (document.pointerLockElement === t.target ? e._delta = [t.movementX, t.movementY] : (e._delta = v.sub(i, e._values), this.computeValues(i)), v.addTo(e._movement, e._delta), this.compute(t), e._delayed && e.intentional) {
|
|
469
469
|
this.timeoutStore.remove("dragDelay"), e.active = !1, this.startPointerDrag(t);
|
|
470
470
|
return;
|
|
@@ -498,10 +498,10 @@ class Zt extends Jt {
|
|
|
498
498
|
if (e.tap = i <= n.tapsThreshold && u <= n.tapsThreshold, e.tap && n.filterTaps)
|
|
499
499
|
e._force = !0;
|
|
500
500
|
else {
|
|
501
|
-
const [a, c] = e._delta, [p,
|
|
501
|
+
const [a, c] = e._delta, [p, l] = e._movement, [x, y] = n.swipe.velocity, [P, N] = n.swipe.distance, A = n.swipe.duration;
|
|
502
502
|
if (e.elapsedTime < A) {
|
|
503
503
|
const C = Math.abs(a / e.timeDelta), _ = Math.abs(c / e.timeDelta);
|
|
504
|
-
C > x && Math.abs(p) > P && (e.swipe[0] = Math.sign(a)), _ > y && Math.abs(
|
|
504
|
+
C > x && Math.abs(p) > P && (e.swipe[0] = Math.sign(a)), _ > y && Math.abs(l) > N && (e.swipe[1] = Math.sign(c));
|
|
505
505
|
}
|
|
506
506
|
}
|
|
507
507
|
this.emit();
|
|
@@ -528,7 +528,7 @@ class Zt extends Jt {
|
|
|
528
528
|
this.state._preventScroll && t.cancelable && t.preventDefault();
|
|
529
529
|
}
|
|
530
530
|
setupScrollPrevention(t) {
|
|
531
|
-
this.state._preventScroll = !1,
|
|
531
|
+
this.state._preventScroll = !1, ee(t);
|
|
532
532
|
const e = this.eventStore.add(this.sharedConfig.window, "touch", "change", this.preventScroll.bind(this), {
|
|
533
533
|
passive: !1
|
|
534
534
|
});
|
|
@@ -540,14 +540,14 @@ class Zt extends Jt {
|
|
|
540
540
|
}, this.config.delay);
|
|
541
541
|
}
|
|
542
542
|
keyDown(t) {
|
|
543
|
-
const e =
|
|
543
|
+
const e = gt[t.key];
|
|
544
544
|
if (e) {
|
|
545
545
|
const n = this.state, s = t.shiftKey ? 10 : t.altKey ? 0.1 : 1;
|
|
546
546
|
this.start(t), n._delta = e(this.config.keyboardDisplacement, s), n._keyboardActive = !0, v.addTo(n._movement, n._delta), this.compute(t), this.emit();
|
|
547
547
|
}
|
|
548
548
|
}
|
|
549
549
|
keyUp(t) {
|
|
550
|
-
t.key in
|
|
550
|
+
t.key in gt && (this.state._keyboardActive = !1, this.setActive(), this.compute(t), this.emit());
|
|
551
551
|
}
|
|
552
552
|
bind(t) {
|
|
553
553
|
const e = this.config.device;
|
|
@@ -557,23 +557,23 @@ class Zt extends Jt {
|
|
|
557
557
|
});
|
|
558
558
|
}
|
|
559
559
|
}
|
|
560
|
-
function
|
|
560
|
+
function ee(r) {
|
|
561
561
|
"persist" in r && typeof r.persist == "function" && r.persist();
|
|
562
562
|
}
|
|
563
563
|
const B = typeof window < "u" && window.document && window.document.createElement;
|
|
564
|
-
function
|
|
564
|
+
function St() {
|
|
565
565
|
return B && "ontouchstart" in window;
|
|
566
566
|
}
|
|
567
|
-
function ee() {
|
|
568
|
-
return Et() || B && window.navigator.maxTouchPoints > 1;
|
|
569
|
-
}
|
|
570
567
|
function re() {
|
|
571
|
-
return B &&
|
|
568
|
+
return St() || B && window.navigator.maxTouchPoints > 1;
|
|
572
569
|
}
|
|
573
570
|
function ne() {
|
|
574
|
-
return B && "
|
|
571
|
+
return B && "onpointerdown" in window;
|
|
575
572
|
}
|
|
576
573
|
function se() {
|
|
574
|
+
return B && "exitPointerLock" in window.document;
|
|
575
|
+
}
|
|
576
|
+
function ie() {
|
|
577
577
|
try {
|
|
578
578
|
return "constructor" in GestureEvent;
|
|
579
579
|
} catch {
|
|
@@ -582,16 +582,16 @@ function se() {
|
|
|
582
582
|
}
|
|
583
583
|
const T = {
|
|
584
584
|
isBrowser: B,
|
|
585
|
-
gesture:
|
|
586
|
-
touch:
|
|
587
|
-
touchscreen:
|
|
588
|
-
pointer:
|
|
589
|
-
pointerLock:
|
|
590
|
-
},
|
|
585
|
+
gesture: ie(),
|
|
586
|
+
touch: St(),
|
|
587
|
+
touchscreen: re(),
|
|
588
|
+
pointer: ne(),
|
|
589
|
+
pointerLock: se()
|
|
590
|
+
}, oe = 250, ae = 180, ce = 0.5, ue = 50, le = 250, fe = 10, vt = {
|
|
591
591
|
mouse: 0,
|
|
592
592
|
touch: 0,
|
|
593
593
|
pen: 8
|
|
594
|
-
},
|
|
594
|
+
}, xt = h(h({}, K), {}, {
|
|
595
595
|
device(r, t, {
|
|
596
596
|
pointer: {
|
|
597
597
|
touch: e = !1,
|
|
@@ -604,7 +604,7 @@ const T = {
|
|
|
604
604
|
preventScrollAxis(r, t, {
|
|
605
605
|
preventScroll: e
|
|
606
606
|
}) {
|
|
607
|
-
if (this.preventScrollDelay = typeof e == "number" ? e : e || e === void 0 && r ?
|
|
607
|
+
if (this.preventScrollDelay = typeof e == "number" ? e : e || e === void 0 && r ? oe : void 0, !(!T.touchscreen || e === !1))
|
|
608
608
|
return r || (e !== void 0 ? "y" : void 0);
|
|
609
609
|
},
|
|
610
610
|
pointerCapture(r, t, {
|
|
@@ -625,9 +625,9 @@ const T = {
|
|
|
625
625
|
return this.filterTaps = e, this.tapsThreshold = n, i;
|
|
626
626
|
},
|
|
627
627
|
swipe({
|
|
628
|
-
velocity: r =
|
|
629
|
-
distance: t =
|
|
630
|
-
duration: e =
|
|
628
|
+
velocity: r = ce,
|
|
629
|
+
distance: t = ue,
|
|
630
|
+
duration: e = le
|
|
631
631
|
} = {}) {
|
|
632
632
|
return {
|
|
633
633
|
velocity: this.transform(v.toVector(r)),
|
|
@@ -638,7 +638,7 @@ const T = {
|
|
|
638
638
|
delay(r = 0) {
|
|
639
639
|
switch (r) {
|
|
640
640
|
case !0:
|
|
641
|
-
return
|
|
641
|
+
return ae;
|
|
642
642
|
case !1:
|
|
643
643
|
return 0;
|
|
644
644
|
default:
|
|
@@ -646,13 +646,13 @@ const T = {
|
|
|
646
646
|
}
|
|
647
647
|
},
|
|
648
648
|
axisThreshold(r) {
|
|
649
|
-
return r ? h(h({},
|
|
649
|
+
return r ? h(h({}, vt), r) : vt;
|
|
650
650
|
},
|
|
651
651
|
keyboardDisplacement(r = fe) {
|
|
652
652
|
return r;
|
|
653
653
|
}
|
|
654
654
|
});
|
|
655
|
-
process.env.NODE_ENV === "development" && Object.assign(
|
|
655
|
+
process.env.NODE_ENV === "development" && Object.assign(xt, {
|
|
656
656
|
useTouch(r) {
|
|
657
657
|
if (r !== void 0)
|
|
658
658
|
throw Error("[@use-gesture]: `useTouch` option has been renamed to `pointer.touch`. Use it as in `{ pointer: { touch: true } }`.");
|
|
@@ -698,13 +698,13 @@ h(h({}, nt), {}, {
|
|
|
698
698
|
angleBounds: n = {}
|
|
699
699
|
}) {
|
|
700
700
|
const s = (u) => {
|
|
701
|
-
const a =
|
|
701
|
+
const a = ht(F(e, u), {
|
|
702
702
|
min: -1 / 0,
|
|
703
703
|
max: 1 / 0
|
|
704
704
|
});
|
|
705
705
|
return [a.min, a.max];
|
|
706
706
|
}, i = (u) => {
|
|
707
|
-
const a =
|
|
707
|
+
const a = ht(F(n, u), {
|
|
708
708
|
min: -1 / 0,
|
|
709
709
|
max: 1 / 0
|
|
710
710
|
});
|
|
@@ -728,25 +728,25 @@ h(h({}, K), {}, {
|
|
|
728
728
|
h(h({}, K), {}, {
|
|
729
729
|
mouseOnly: (r = !0) => r
|
|
730
730
|
});
|
|
731
|
-
const
|
|
732
|
-
function
|
|
733
|
-
|
|
731
|
+
const Tt = /* @__PURE__ */ new Map(), rt = /* @__PURE__ */ new Map();
|
|
732
|
+
function de(r) {
|
|
733
|
+
Tt.set(r.key, r.engine), rt.set(r.key, r.resolver);
|
|
734
734
|
}
|
|
735
|
-
const
|
|
735
|
+
const he = {
|
|
736
736
|
key: "drag",
|
|
737
|
-
engine:
|
|
738
|
-
resolver:
|
|
737
|
+
engine: te,
|
|
738
|
+
resolver: xt
|
|
739
739
|
};
|
|
740
|
-
function
|
|
740
|
+
function pe(r, t) {
|
|
741
741
|
if (r == null) return {};
|
|
742
742
|
var e = {}, n = Object.keys(r), s, i;
|
|
743
743
|
for (i = 0; i < n.length; i++)
|
|
744
744
|
s = n[i], !(t.indexOf(s) >= 0) && (e[s] = r[s]);
|
|
745
745
|
return e;
|
|
746
746
|
}
|
|
747
|
-
function
|
|
747
|
+
function me(r, t) {
|
|
748
748
|
if (r == null) return {};
|
|
749
|
-
var e =
|
|
749
|
+
var e = pe(r, t), n, s;
|
|
750
750
|
if (Object.getOwnPropertySymbols) {
|
|
751
751
|
var i = Object.getOwnPropertySymbols(r);
|
|
752
752
|
for (s = 0; s < i.length; s++)
|
|
@@ -754,7 +754,7 @@ function pe(r, t) {
|
|
|
754
754
|
}
|
|
755
755
|
return e;
|
|
756
756
|
}
|
|
757
|
-
const
|
|
757
|
+
const ge = {
|
|
758
758
|
target(r) {
|
|
759
759
|
if (r)
|
|
760
760
|
return () => "current" in r ? r.current : r;
|
|
@@ -777,7 +777,7 @@ const me = {
|
|
|
777
777
|
transform(r) {
|
|
778
778
|
return r;
|
|
779
779
|
}
|
|
780
|
-
},
|
|
780
|
+
}, ve = ["target", "eventOptions", "window", "enabled", "transform"];
|
|
781
781
|
function Y(r = {}, t) {
|
|
782
782
|
const e = {};
|
|
783
783
|
for (const [n, s] of Object.entries(t))
|
|
@@ -798,57 +798,57 @@ function Y(r = {}, t) {
|
|
|
798
798
|
}
|
|
799
799
|
return e;
|
|
800
800
|
}
|
|
801
|
-
function
|
|
801
|
+
function ye(r, t, e = {}) {
|
|
802
802
|
const n = r, {
|
|
803
803
|
target: s,
|
|
804
804
|
eventOptions: i,
|
|
805
805
|
window: u,
|
|
806
806
|
enabled: a,
|
|
807
807
|
transform: c
|
|
808
|
-
} = n, p =
|
|
808
|
+
} = n, p = me(n, ve);
|
|
809
809
|
if (e.shared = Y({
|
|
810
810
|
target: s,
|
|
811
811
|
eventOptions: i,
|
|
812
812
|
window: u,
|
|
813
813
|
enabled: a,
|
|
814
814
|
transform: c
|
|
815
|
-
},
|
|
816
|
-
const
|
|
815
|
+
}, ge), t) {
|
|
816
|
+
const l = rt.get(t);
|
|
817
817
|
e[t] = Y(h({
|
|
818
818
|
shared: e.shared
|
|
819
|
-
}, p),
|
|
819
|
+
}, p), l);
|
|
820
820
|
} else
|
|
821
|
-
for (const
|
|
822
|
-
const x = rt.get(
|
|
821
|
+
for (const l in p) {
|
|
822
|
+
const x = rt.get(l);
|
|
823
823
|
if (x)
|
|
824
|
-
e[
|
|
824
|
+
e[l] = Y(h({
|
|
825
825
|
shared: e.shared
|
|
826
|
-
}, p[
|
|
827
|
-
else if (process.env.NODE_ENV === "development" && !["drag", "pinch", "scroll", "wheel", "move", "hover"].includes(
|
|
828
|
-
if (
|
|
826
|
+
}, p[l]), x);
|
|
827
|
+
else if (process.env.NODE_ENV === "development" && !["drag", "pinch", "scroll", "wheel", "move", "hover"].includes(l)) {
|
|
828
|
+
if (l === "domTarget")
|
|
829
829
|
throw Error("[@use-gesture]: `domTarget` option has been renamed to `target`.");
|
|
830
|
-
console.warn(`[@use-gesture]: Unknown config key \`${
|
|
830
|
+
console.warn(`[@use-gesture]: Unknown config key \`${l}\` was used. Please read the documentation for further information.`);
|
|
831
831
|
}
|
|
832
832
|
}
|
|
833
833
|
return e;
|
|
834
834
|
}
|
|
835
|
-
class
|
|
835
|
+
class It {
|
|
836
836
|
constructor(t, e) {
|
|
837
837
|
b(this, "_listeners", /* @__PURE__ */ new Set()), this._ctrl = t, this._gestureKey = e;
|
|
838
838
|
}
|
|
839
839
|
add(t, e, n, s, i) {
|
|
840
|
-
const u = this._listeners, a =
|
|
840
|
+
const u = this._listeners, a = Bt(e, n), c = this._gestureKey ? this._ctrl.config[this._gestureKey].eventOptions : {}, p = h(h({}, c), i);
|
|
841
841
|
t.addEventListener(a, s, p);
|
|
842
|
-
const
|
|
843
|
-
t.removeEventListener(a, s, p), u.delete(
|
|
842
|
+
const l = () => {
|
|
843
|
+
t.removeEventListener(a, s, p), u.delete(l);
|
|
844
844
|
};
|
|
845
|
-
return u.add(
|
|
845
|
+
return u.add(l), l;
|
|
846
846
|
}
|
|
847
847
|
clean() {
|
|
848
848
|
this._listeners.forEach((t) => t()), this._listeners.clear();
|
|
849
849
|
}
|
|
850
850
|
}
|
|
851
|
-
class
|
|
851
|
+
class _e {
|
|
852
852
|
constructor() {
|
|
853
853
|
b(this, "_timeouts", /* @__PURE__ */ new Map());
|
|
854
854
|
}
|
|
@@ -863,20 +863,20 @@ class ye {
|
|
|
863
863
|
this._timeouts.forEach((t) => void window.clearTimeout(t)), this._timeouts.clear();
|
|
864
864
|
}
|
|
865
865
|
}
|
|
866
|
-
class
|
|
866
|
+
class be {
|
|
867
867
|
constructor(t) {
|
|
868
|
-
b(this, "gestures", /* @__PURE__ */ new Set()), b(this, "_targetEventStore", new
|
|
868
|
+
b(this, "gestures", /* @__PURE__ */ new Set()), b(this, "_targetEventStore", new It(this)), b(this, "gestureEventStores", {}), b(this, "gestureTimeoutStores", {}), b(this, "handlers", {}), b(this, "config", {}), b(this, "pointerIds", /* @__PURE__ */ new Set()), b(this, "touchIds", /* @__PURE__ */ new Set()), b(this, "state", {
|
|
869
869
|
shared: {
|
|
870
870
|
shiftKey: !1,
|
|
871
871
|
metaKey: !1,
|
|
872
872
|
ctrlKey: !1,
|
|
873
873
|
altKey: !1
|
|
874
874
|
}
|
|
875
|
-
}),
|
|
875
|
+
}), we(this, t);
|
|
876
876
|
}
|
|
877
877
|
setEventIds(t) {
|
|
878
878
|
if (H(t))
|
|
879
|
-
return this.touchIds = new Set(
|
|
879
|
+
return this.touchIds = new Set(Yt(t)), this.touchIds;
|
|
880
880
|
if ("pointerId" in t)
|
|
881
881
|
return t.type === "pointerup" || t.type === "pointercancel" ? this.pointerIds.delete(t.pointerId) : t.type === "pointerdown" && this.pointerIds.add(t.pointerId), this.pointerIds;
|
|
882
882
|
}
|
|
@@ -884,7 +884,7 @@ class _e {
|
|
|
884
884
|
this.handlers = t, this.nativeHandlers = e;
|
|
885
885
|
}
|
|
886
886
|
applyConfig(t, e) {
|
|
887
|
-
this.config =
|
|
887
|
+
this.config = ye(t, e, this.config);
|
|
888
888
|
}
|
|
889
889
|
clean() {
|
|
890
890
|
this._targetEventStore.clean();
|
|
@@ -900,13 +900,13 @@ class _e {
|
|
|
900
900
|
if (!(e.target && (s = e.target(), !s))) {
|
|
901
901
|
if (e.enabled) {
|
|
902
902
|
for (const u of this.gestures) {
|
|
903
|
-
const a = this.config[u], c =
|
|
903
|
+
const a = this.config[u], c = yt(n, a.eventOptions, !!s);
|
|
904
904
|
if (a.enabled) {
|
|
905
|
-
const p =
|
|
905
|
+
const p = Tt.get(u);
|
|
906
906
|
new p(this, t, u).bind(c);
|
|
907
907
|
}
|
|
908
908
|
}
|
|
909
|
-
const i =
|
|
909
|
+
const i = yt(n, e.eventOptions, !!s);
|
|
910
910
|
for (const u in this.nativeHandlers)
|
|
911
911
|
i(u, "", (a) => this.nativeHandlers[u](h(h({}, this.state.shared), {}, {
|
|
912
912
|
event: a,
|
|
@@ -914,14 +914,14 @@ class _e {
|
|
|
914
914
|
})), void 0, !0);
|
|
915
915
|
}
|
|
916
916
|
for (const i in n)
|
|
917
|
-
n[i] =
|
|
917
|
+
n[i] = Gt(...n[i]);
|
|
918
918
|
if (!s) return n;
|
|
919
919
|
for (const i in n) {
|
|
920
920
|
const {
|
|
921
921
|
device: u,
|
|
922
922
|
capture: a,
|
|
923
923
|
passive: c
|
|
924
|
-
} =
|
|
924
|
+
} = Kt(i);
|
|
925
925
|
this._targetEventStore.add(s, u, "", n[i], {
|
|
926
926
|
capture: a,
|
|
927
927
|
passive: c
|
|
@@ -931,32 +931,32 @@ class _e {
|
|
|
931
931
|
}
|
|
932
932
|
}
|
|
933
933
|
function L(r, t) {
|
|
934
|
-
r.gestures.add(t), r.gestureEventStores[t] = new
|
|
934
|
+
r.gestures.add(t), r.gestureEventStores[t] = new It(r, t), r.gestureTimeoutStores[t] = new _e();
|
|
935
935
|
}
|
|
936
|
-
function
|
|
936
|
+
function we(r, t) {
|
|
937
937
|
t.drag && L(r, "drag"), t.wheel && L(r, "wheel"), t.scroll && L(r, "scroll"), t.move && L(r, "move"), t.pinch && L(r, "pinch"), t.hover && L(r, "hover");
|
|
938
938
|
}
|
|
939
|
-
const
|
|
939
|
+
const yt = (r, t, e) => (n, s, i, u = {}, a = !1) => {
|
|
940
940
|
var c, p;
|
|
941
|
-
const
|
|
942
|
-
let y = a ? n :
|
|
941
|
+
const l = (c = u.capture) !== null && c !== void 0 ? c : t.capture, x = (p = u.passive) !== null && p !== void 0 ? p : t.passive;
|
|
942
|
+
let y = a ? n : jt(n, s, l);
|
|
943
943
|
e && x && (y += "Passive"), r[y] = r[y] || [], r[y].push(i);
|
|
944
944
|
};
|
|
945
|
-
function
|
|
946
|
-
const s = Z.useMemo(() => new
|
|
945
|
+
function Ee(r, t = {}, e, n) {
|
|
946
|
+
const s = Z.useMemo(() => new be(r), []);
|
|
947
947
|
if (s.applyHandlers(r, n), s.applyConfig(t, e), Z.useEffect(s.effect.bind(s)), Z.useEffect(() => s.clean.bind(s), []), t.target === void 0)
|
|
948
948
|
return s.bind.bind(s);
|
|
949
949
|
}
|
|
950
|
-
function
|
|
951
|
-
return
|
|
950
|
+
function Se(r, t) {
|
|
951
|
+
return de(he), Ee({
|
|
952
952
|
drag: r
|
|
953
953
|
}, t || {}, "drag");
|
|
954
954
|
}
|
|
955
955
|
const et = "RSC::Event";
|
|
956
|
-
function
|
|
956
|
+
function xe() {
|
|
957
957
|
const r = $(null);
|
|
958
958
|
function t(n) {
|
|
959
|
-
|
|
959
|
+
_t(() => {
|
|
960
960
|
r.current || (r.current = document.createElement("div"));
|
|
961
961
|
function s(i) {
|
|
962
962
|
n(i.detail);
|
|
@@ -985,7 +985,7 @@ function Se() {
|
|
|
985
985
|
emitEvent: e
|
|
986
986
|
};
|
|
987
987
|
}
|
|
988
|
-
function
|
|
988
|
+
function Ce({
|
|
989
989
|
init: r = !0,
|
|
990
990
|
items: t,
|
|
991
991
|
withLoop: e = !1,
|
|
@@ -996,11 +996,11 @@ function ke({
|
|
|
996
996
|
carouselAxis: a = "x",
|
|
997
997
|
slideType: c = "fixed",
|
|
998
998
|
startingPosition: p = "start",
|
|
999
|
-
enableGestures:
|
|
999
|
+
enableGestures: l = !0,
|
|
1000
1000
|
slideWhenDragThresholdIsReached: x = !0,
|
|
1001
1001
|
onInit: y
|
|
1002
1002
|
}) {
|
|
1003
|
-
const [P, N] =
|
|
1003
|
+
const [P, N] = At(!1), A = $(r), C = $(null), _ = $(null), z = $(0), I = $(!e), w = $(!1), V = $(0), f = $(0), [M, G] = $t(
|
|
1004
1004
|
() => ({
|
|
1005
1005
|
value: 0,
|
|
1006
1006
|
onChange({ value: o }) {
|
|
@@ -1011,7 +1011,7 @@ function ke({
|
|
|
1011
1011
|
}
|
|
1012
1012
|
}),
|
|
1013
1013
|
[a]
|
|
1014
|
-
),
|
|
1014
|
+
), Dt = c !== "freeScroll" && e ? [
|
|
1015
1015
|
...t.map((o) => ({
|
|
1016
1016
|
...o,
|
|
1017
1017
|
id: `prev-repeated-item-${o.id}`,
|
|
@@ -1023,7 +1023,7 @@ function ke({
|
|
|
1023
1023
|
id: `next-repeated-item-${o.id}`,
|
|
1024
1024
|
isClonedItem: !0
|
|
1025
1025
|
}))
|
|
1026
|
-
] : t, { useListenToCustomEvent: st, emitEvent: j } =
|
|
1026
|
+
] : t, { useListenToCustomEvent: st, emitEvent: j } = xe();
|
|
1027
1027
|
function X(o) {
|
|
1028
1028
|
A.current && (w.current || U({
|
|
1029
1029
|
type: "next",
|
|
@@ -1044,17 +1044,17 @@ function ke({
|
|
|
1044
1044
|
toIndex: D,
|
|
1045
1045
|
actionType: E
|
|
1046
1046
|
}) {
|
|
1047
|
-
var
|
|
1047
|
+
var ot, at;
|
|
1048
1048
|
const m = W(), O = !d;
|
|
1049
1049
|
I.current = !1, w.current = !1;
|
|
1050
1050
|
let k = M.value.get(), g = 0;
|
|
1051
|
-
if (o === "next" && c !== "freeScroll" && (
|
|
1051
|
+
if (o === "next" && c !== "freeScroll" && (f.current += 1), o === "prev" && c !== "freeScroll" && (f.current === 0 ? f.current = t.length - 1 : f.current -= 1), D !== void 0 && (f.current = D), c !== "freeScroll" && o === "next") {
|
|
1052
1052
|
const S = J(
|
|
1053
1053
|
e ? m * (t.length * 2) : 0
|
|
1054
1054
|
);
|
|
1055
|
-
g = -(
|
|
1055
|
+
g = -(f.current * m), S - Math.abs(g) < m / 1.2 && c === "fluid" && !e && (g = -S), !e && Math.abs(g) >= S && (w.current = !0, g = -S), e && f.current === t.length && (f.current = 0, k = k + m * t.length, g = 0);
|
|
1056
1056
|
}
|
|
1057
|
-
if (c !== "freeScroll" && o === "prev" && (g = -(
|
|
1057
|
+
if (c !== "freeScroll" && o === "prev" && (g = -(f.current * m), f.current === t.length - 1 && (k = k - t.length * m), !e && g >= 0 && (I.current = !0, g = 0)), c === "freeScroll" && o === "next") {
|
|
1058
1058
|
const S = _.current[a === "x" ? "scrollLeft" : "scrollTop"], R = a === "x" ? _.current.scrollWidth - _.current.clientWidth : _.current.scrollHeight - _.current.clientHeight;
|
|
1059
1059
|
k = S, g = S + m, (g > R || R - g < 80) && (g = R, w.current = !0);
|
|
1060
1060
|
}
|
|
@@ -1067,8 +1067,8 @@ function ke({
|
|
|
1067
1067
|
sliceActionType: E,
|
|
1068
1068
|
slideDirection: o,
|
|
1069
1069
|
currentItem: {
|
|
1070
|
-
index:
|
|
1071
|
-
id: ((
|
|
1070
|
+
index: f.current,
|
|
1071
|
+
id: ((ot = t.at(f.current)) == null ? void 0 : ot.id) ?? "",
|
|
1072
1072
|
startReached: I.current,
|
|
1073
1073
|
endReached: w.current
|
|
1074
1074
|
}
|
|
@@ -1077,8 +1077,8 @@ function ke({
|
|
|
1077
1077
|
sliceActionType: E,
|
|
1078
1078
|
slideDirection: o,
|
|
1079
1079
|
nextItem: {
|
|
1080
|
-
index:
|
|
1081
|
-
id: ((
|
|
1080
|
+
index: f.current,
|
|
1081
|
+
id: ((at = t.at(f.current)) == null ? void 0 : at.id) ?? "",
|
|
1082
1082
|
startReached: I.current,
|
|
1083
1083
|
endReached: w.current
|
|
1084
1084
|
}
|
|
@@ -1097,8 +1097,8 @@ function ke({
|
|
|
1097
1097
|
sliceActionType: E,
|
|
1098
1098
|
slideDirection: o,
|
|
1099
1099
|
currentItem: {
|
|
1100
|
-
index:
|
|
1101
|
-
id: ((R = t.at(
|
|
1100
|
+
index: f.current,
|
|
1101
|
+
id: ((R = t.at(f.current)) == null ? void 0 : R.id) ?? "",
|
|
1102
1102
|
startReached: I.current,
|
|
1103
1103
|
endReached: w.current
|
|
1104
1104
|
}
|
|
@@ -1125,7 +1125,7 @@ function ke({
|
|
|
1125
1125
|
const d = _.current;
|
|
1126
1126
|
return d[a === "x" ? "scrollWidth" : "scrollHeight"] - d.getBoundingClientRect()[a === "x" ? "width" : "height"] - o;
|
|
1127
1127
|
}
|
|
1128
|
-
function
|
|
1128
|
+
function kt() {
|
|
1129
1129
|
let o = 0;
|
|
1130
1130
|
const d = getComputedStyle(
|
|
1131
1131
|
document.documentElement
|
|
@@ -1134,7 +1134,7 @@ function ke({
|
|
|
1134
1134
|
d.replace("px", "")
|
|
1135
1135
|
)), { totalStartEndGutterCssVar: o };
|
|
1136
1136
|
}
|
|
1137
|
-
|
|
1137
|
+
_t(() => {
|
|
1138
1138
|
function o(E, m) {
|
|
1139
1139
|
switch (E) {
|
|
1140
1140
|
case "start":
|
|
@@ -1153,7 +1153,7 @@ function ke({
|
|
|
1153
1153
|
}
|
|
1154
1154
|
function d(E) {
|
|
1155
1155
|
if (C.current) {
|
|
1156
|
-
const { totalStartEndGutterCssVar: m } =
|
|
1156
|
+
const { totalStartEndGutterCssVar: m } = kt();
|
|
1157
1157
|
let O = 0;
|
|
1158
1158
|
e && (O = W() * t.length), O -= W() * o(p, s), O -= m / 2, C.current.style.setProperty(
|
|
1159
1159
|
`--${n}-offset-modifier`,
|
|
@@ -1164,7 +1164,7 @@ function ke({
|
|
|
1164
1164
|
function D() {
|
|
1165
1165
|
d(), U({
|
|
1166
1166
|
type: "next",
|
|
1167
|
-
toIndex:
|
|
1167
|
+
toIndex: f.current,
|
|
1168
1168
|
shouldAnimate: !1,
|
|
1169
1169
|
actionType: "resize"
|
|
1170
1170
|
});
|
|
@@ -1174,7 +1174,7 @@ function ke({
|
|
|
1174
1174
|
window.removeEventListener("resize", D);
|
|
1175
1175
|
};
|
|
1176
1176
|
}, [r, e, n, a, i, p, c]);
|
|
1177
|
-
const
|
|
1177
|
+
const it = l && c !== "freeScroll", Ct = Se(
|
|
1178
1178
|
(o) => {
|
|
1179
1179
|
if (!A.current)
|
|
1180
1180
|
return;
|
|
@@ -1203,7 +1203,7 @@ function ke({
|
|
|
1203
1203
|
}));
|
|
1204
1204
|
},
|
|
1205
1205
|
{
|
|
1206
|
-
enabled:
|
|
1206
|
+
enabled: it,
|
|
1207
1207
|
axis: a,
|
|
1208
1208
|
rubberband: !e,
|
|
1209
1209
|
...e ? {} : {
|
|
@@ -1218,7 +1218,7 @@ function ke({
|
|
|
1218
1218
|
}
|
|
1219
1219
|
);
|
|
1220
1220
|
return {
|
|
1221
|
-
carouselFragment: /* @__PURE__ */
|
|
1221
|
+
carouselFragment: /* @__PURE__ */ Ot(
|
|
1222
1222
|
"div",
|
|
1223
1223
|
{
|
|
1224
1224
|
ref: C,
|
|
@@ -1261,7 +1261,7 @@ function ke({
|
|
|
1261
1261
|
gap: var(--${n}-gutter);
|
|
1262
1262
|
transform: translate3d(var(--${n}-scroll-x-value), var(--${n}-scroll-y-value), 0px);
|
|
1263
1263
|
overflow-x: ${c === "freeScroll" ? "auto" : "visible"};
|
|
1264
|
-
touch-action: ${
|
|
1264
|
+
touch-action: ${it ? a === "x" ? "pan-y" : "pan-x" : "auto"};
|
|
1265
1265
|
}
|
|
1266
1266
|
[data-part-internal="${n}-Item"] {
|
|
1267
1267
|
display: flex;
|
|
@@ -1278,7 +1278,7 @@ function ke({
|
|
|
1278
1278
|
className: "ReactSpringCarouselTrack",
|
|
1279
1279
|
"data-part": "Track",
|
|
1280
1280
|
"data-part-internal": `${n}-Track`,
|
|
1281
|
-
...
|
|
1281
|
+
...Ct(),
|
|
1282
1282
|
onScroll: () => {
|
|
1283
1283
|
I.current = !1, w.current = !1;
|
|
1284
1284
|
},
|
|
@@ -1287,7 +1287,7 @@ function ke({
|
|
|
1287
1287
|
I.current = !1, w.current = !1, M.value.stop();
|
|
1288
1288
|
}
|
|
1289
1289
|
} : {},
|
|
1290
|
-
children:
|
|
1290
|
+
children: Dt.map((o, d) => /* @__PURE__ */ Q(
|
|
1291
1291
|
"div",
|
|
1292
1292
|
{
|
|
1293
1293
|
className: "ReactSpringCarouselItem",
|
|
@@ -1318,7 +1318,7 @@ function ke({
|
|
|
1318
1318
|
);
|
|
1319
1319
|
return;
|
|
1320
1320
|
}
|
|
1321
|
-
o >
|
|
1321
|
+
o > f.current ? X(o) : q(o);
|
|
1322
1322
|
}
|
|
1323
1323
|
if (typeof o == "string") {
|
|
1324
1324
|
const d = t.findIndex((D) => D.id === o);
|
|
@@ -1328,11 +1328,11 @@ function ke({
|
|
|
1328
1328
|
);
|
|
1329
1329
|
return;
|
|
1330
1330
|
}
|
|
1331
|
-
d >
|
|
1331
|
+
d > f.current ? X(d) : q(d);
|
|
1332
1332
|
}
|
|
1333
1333
|
}
|
|
1334
1334
|
};
|
|
1335
1335
|
}
|
|
1336
1336
|
export {
|
|
1337
|
-
|
|
1337
|
+
Ce as useSpringCarousel
|
|
1338
1338
|
};
|
package/dist/index.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(O,P){typeof exports=="object"&&typeof module<"u"?P(exports,require("react/jsx-runtime"),require("@react-spring/web"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","@react-spring/web","react"],P):(O=typeof globalThis<"u"?globalThis:O||self,P(O["react-spring-carousel"]={},O["react/jsx-runtime"],O["@react-spring/web"],O.React))})(this,function(O,P,Te,y){"use strict";function Ie(r,e,t){return Math.max(e,Math.min(r,t))}const v={toVector(r,e){return r===void 0&&(r=e),Array.isArray(r)?r:[r,r]},add(r,e){return[r[0]+e[0],r[1]+e[1]]},sub(r,e){return[r[0]-e[0],r[1]-e[1]]},addTo(r,e){r[0]+=e[0],r[1]+=e[1]},subTo(r,e){r[0]-=e[0],r[1]-=e[1]}};function se(r,e,t){return e===0||Math.abs(e)===1/0?Math.pow(r,t*5):r*e*t/(e+t*r)}function ie(r,e,t,n=.15){return n===0?Ie(r,e,t):r<e?-se(e-r,t-e,n)+e:r>t?+se(r-t,t-e,n)+t:r}function De(r,[e,t],[n,s]){const[[i,u],[a,c]]=r;return[ie(e,i,u,n),ie(t,a,c,s)]}function ke(r,e){if(typeof r!="object"||r===null)return r;var t=r[Symbol.toPrimitive];if(t!==void 0){var n=t.call(r,e);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(r)}function Ce(r){var e=ke(r,"string");return typeof e=="symbol"?e:String(e)}function b(r,e,t){return e=Ce(e),e in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function oe(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);e&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(r,s).enumerable})),t.push.apply(t,n)}return t}function h(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?oe(Object(t),!0).forEach(function(n){b(r,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):oe(Object(t)).forEach(function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(t,n))})}return r}const ae={pointer:{start:"down",change:"move",end:"up"},mouse:{start:"down",change:"move",end:"up"},touch:{start:"start",change:"move",end:"end"},gesture:{start:"start",change:"change",end:"end"}};function ce(r){return r?r[0].toUpperCase()+r.slice(1):""}const Oe=["enter","leave"];function $e(r=!1,e){return r&&!Oe.includes(e)}function Ae(r,e="",t=!1){const n=ae[r],s=n&&n[e]||e;return"on"+ce(r)+ce(s)+($e(t,s)?"Capture":"")}const Pe=["gotpointercapture","lostpointercapture"];function Ne(r){let e=r.substring(2).toLowerCase();const t=!!~e.indexOf("passive");t&&(e=e.replace("passive",""));const n=Pe.includes(e)?"capturecapture":"capture",s=!!~e.indexOf(n);return s&&(e=e.replace("capture","")),{device:e,capture:s,passive:t}}function Me(r,e=""){const t=ae[r],n=t&&t[e]||e;return r+n}function Y(r){return"touches"in r}function ue(r){return Y(r)?"touch":"pointerType"in r?r.pointerType:"mouse"}function Le(r){return Array.from(r.touches).filter(e=>{var t,n;return e.target===r.currentTarget||((t=r.currentTarget)===null||t===void 0||(n=t.contains)===null||n===void 0?void 0:n.call(t,e.target))})}function Re(r){return r.type==="touchend"||r.type==="touchcancel"?r.changedTouches:r.targetTouches}function fe(r){return Y(r)?Re(r)[0]:r}function Ve(r){return Le(r).map(e=>e.identifier)}function q(r){const e=fe(r);return Y(r)?e.identifier:e.pointerId}function le(r){const e=fe(r);return[e.clientX,e.clientY]}function je(r){const e={};if("buttons"in r&&(e.buttons=r.buttons),"shiftKey"in r){const{shiftKey:t,altKey:n,metaKey:s,ctrlKey:i}=r;Object.assign(e,{shiftKey:t,altKey:n,metaKey:s,ctrlKey:i})}return e}function F(r,...e){return typeof r=="function"?r(...e):r}function Ue(){}function Ke(...r){return r.length===0?Ue:r.length===1?r[0]:function(){let e;for(const t of r)e=t.apply(this,arguments)||e;return e}}function de(r,e){return Object.assign({},e,r||{})}const Be=32;class ze{constructor(e,t,n){this.ctrl=e,this.args=t,this.key=n,this.state||(this.state={},this.computeValues([0,0]),this.computeInitial(),this.init&&this.init(),this.reset())}get state(){return this.ctrl.state[this.key]}set state(e){this.ctrl.state[this.key]=e}get shared(){return this.ctrl.state.shared}get eventStore(){return this.ctrl.gestureEventStores[this.key]}get timeoutStore(){return this.ctrl.gestureTimeoutStores[this.key]}get config(){return this.ctrl.config[this.key]}get sharedConfig(){return this.ctrl.config.shared}get handler(){return this.ctrl.handlers[this.key]}reset(){const{state:e,shared:t,ingKey:n,args:s}=this;t[n]=e._active=e.active=e._blocked=e._force=!1,e._step=[!1,!1],e.intentional=!1,e._movement=[0,0],e._distance=[0,0],e._direction=[0,0],e._delta=[0,0],e._bounds=[[-1/0,1/0],[-1/0,1/0]],e.args=s,e.axis=void 0,e.memo=void 0,e.elapsedTime=e.timeDelta=0,e.direction=[0,0],e.distance=[0,0],e.overflow=[0,0],e._movementBound=[!1,!1],e.velocity=[0,0],e.movement=[0,0],e.delta=[0,0],e.timeStamp=0}start(e){const t=this.state,n=this.config;t._active||(this.reset(),this.computeInitial(),t._active=!0,t.target=e.target,t.currentTarget=e.currentTarget,t.lastOffset=n.from?F(n.from,t):t.offset,t.offset=t.lastOffset,t.startTime=t.timeStamp=e.timeStamp)}computeValues(e){const t=this.state;t._values=e,t.values=this.config.transform(e)}computeInitial(){const e=this.state;e._initial=e._values,e.initial=e.values}compute(e){const{state:t,config:n,shared:s}=this;t.args=this.args;let i=0;if(e&&(t.event=e,n.preventDefault&&e.cancelable&&t.event.preventDefault(),t.type=e.type,s.touches=this.ctrl.pointerIds.size||this.ctrl.touchIds.size,s.locked=!!document.pointerLockElement,Object.assign(s,je(e)),s.down=s.pressed=s.buttons%2===1||s.touches>0,i=e.timeStamp-t.timeStamp,t.timeStamp=e.timeStamp,t.elapsedTime=t.timeStamp-t.startTime),t._active){const l=t._delta.map(Math.abs);v.addTo(t._distance,l)}this.axisIntent&&this.axisIntent(e);const[u,a]=t._movement,[c,p]=n.threshold,{_step:f,values:I}=t;if(n.hasCustomTransform?(f[0]===!1&&(f[0]=Math.abs(u)>=c&&I[0]),f[1]===!1&&(f[1]=Math.abs(a)>=p&&I[1])):(f[0]===!1&&(f[0]=Math.abs(u)>=c&&Math.sign(u)*c),f[1]===!1&&(f[1]=Math.abs(a)>=p&&Math.sign(a)*p)),t.intentional=f[0]!==!1||f[1]!==!1,!t.intentional)return;const _=[0,0];if(n.hasCustomTransform){const[l,V]=I;_[0]=f[0]!==!1?l-f[0]:0,_[1]=f[1]!==!1?V-f[1]:0}else _[0]=f[0]!==!1?u-f[0]:0,_[1]=f[1]!==!1?a-f[1]:0;this.restrictToAxis&&!t._blocked&&this.restrictToAxis(_);const M=t.offset,R=t._active&&!t._blocked||t.active;R&&(t.first=t._active&&!t.active,t.last=!t._active&&t.active,t.active=s[this.ingKey]=t._active,e&&(t.first&&("bounds"in n&&(t._bounds=F(n.bounds,t)),this.setup&&this.setup()),t.movement=_,this.computeOffset()));const[N,$]=t.offset,[[w,G],[D,E]]=t._bounds;t.overflow=[N<w?-1:N>G?1:0,$<D?-1:$>E?1:0],t._movementBound[0]=t.overflow[0]?t._movementBound[0]===!1?t._movement[0]:t._movementBound[0]:!1,t._movementBound[1]=t.overflow[1]?t._movementBound[1]===!1?t._movement[1]:t._movementBound[1]:!1;const B=t._active?n.rubberband||[0,0]:[0,0];if(t.offset=De(t._bounds,t.offset,B),t.delta=v.sub(t.offset,M),this.computeMovement(),R&&(!t.last||i>Be)){t.delta=v.sub(t.offset,M);const l=t.delta.map(Math.abs);v.addTo(t.distance,l),t.direction=t.delta.map(Math.sign),t._direction=t._delta.map(Math.sign),!t.first&&i>0&&(t.velocity=[l[0]/i,l[1]/i],t.timeDelta=i)}}emit(){const e=this.state,t=this.shared,n=this.config;if(e._active||this.clean(),(e._blocked||!e.intentional)&&!e._force&&!n.triggerAllEvents)return;const s=this.handler(h(h(h({},t),e),{},{[this.aliasKey]:e.values}));s!==void 0&&(e.memo=s)}clean(){this.eventStore.clean(),this.timeoutStore.clean()}}function We([r,e],t){const n=Math.abs(r),s=Math.abs(e);if(n>s&&n>t)return"x";if(s>n&&s>t)return"y"}class Ye extends ze{constructor(...e){super(...e),b(this,"aliasKey","xy")}reset(){super.reset(),this.state.axis=void 0}init(){this.state.offset=[0,0],this.state.lastOffset=[0,0]}computeOffset(){this.state.offset=v.add(this.state.lastOffset,this.state.movement)}computeMovement(){this.state.movement=v.sub(this.state.offset,this.state.lastOffset)}axisIntent(e){const t=this.state,n=this.config;if(!t.axis&&e){const s=typeof n.axisThreshold=="object"?n.axisThreshold[ue(e)]:n.axisThreshold;t.axis=We(t._movement,s)}t._blocked=(n.lockDirection||!!n.axis)&&!t.axis||!!n.axis&&n.axis!==t.axis}restrictToAxis(e){if(this.config.axis||this.config.lockDirection)switch(this.state.axis){case"x":e[1]=0;break;case"y":e[0]=0;break}}}const he=r=>r,pe=.15,J={enabled(r=!0){return r},eventOptions(r,e,t){return h(h({},t.shared.eventOptions),r)},preventDefault(r=!1){return r},triggerAllEvents(r=!1){return r},rubberband(r=0){switch(r){case!0:return[pe,pe];case!1:return[0,0];default:return v.toVector(r)}},from(r){if(typeof r=="function")return r;if(r!=null)return v.toVector(r)},transform(r,e,t){const n=r||t.shared.transform;if(this.hasCustomTransform=!!n,process.env.NODE_ENV==="development"){const s=n||he;return i=>{const u=s(i);return(!isFinite(u[0])||!isFinite(u[1]))&&console.warn(`[@use-gesture]: config.transform() must produce a valid result, but it was: [${u[0]},${[1]}]`),u}}return n||he},threshold(r){return v.toVector(r,0)}};process.env.NODE_ENV==="development"&&Object.assign(J,{domTarget(r){if(r!==void 0)throw Error("[@use-gesture]: `domTarget` option has been renamed to `target`.");return NaN},lockDirection(r){if(r!==void 0)throw Error("[@use-gesture]: `lockDirection` option has been merged with `axis`. Use it as in `{ axis: 'lock' }`");return NaN},initial(r){if(r!==void 0)throw Error("[@use-gesture]: `initial` option has been renamed to `from`.");return NaN}});const Fe=0,U=h(h({},J),{},{axis(r,e,{axis:t}){if(this.lockDirection=t==="lock",!this.lockDirection)return t},axisThreshold(r=Fe){return r},bounds(r={}){if(typeof r=="function")return i=>U.bounds(r(i));if("current"in r)return()=>r.current;if(typeof HTMLElement=="function"&&r instanceof HTMLElement)return r;const{left:e=-1/0,right:t=1/0,top:n=-1/0,bottom:s=1/0}=r;return[[e,t],[n,s]]}}),me={ArrowRight:(r,e=1)=>[r*e,0],ArrowLeft:(r,e=1)=>[-1*r*e,0],ArrowUp:(r,e=1)=>[0,-1*r*e],ArrowDown:(r,e=1)=>[0,r*e]};class He extends Ye{constructor(...e){super(...e),b(this,"ingKey","dragging")}reset(){super.reset();const e=this.state;e._pointerId=void 0,e._pointerActive=!1,e._keyboardActive=!1,e._preventScroll=!1,e._delayed=!1,e.swipe=[0,0],e.tap=!1,e.canceled=!1,e.cancel=this.cancel.bind(this)}setup(){const e=this.state;if(e._bounds instanceof HTMLElement){const t=e._bounds.getBoundingClientRect(),n=e.currentTarget.getBoundingClientRect(),s={left:t.left-n.left+e.offset[0],right:t.right-n.right+e.offset[0],top:t.top-n.top+e.offset[1],bottom:t.bottom-n.bottom+e.offset[1]};e._bounds=U.bounds(s)}}cancel(){const e=this.state;e.canceled||(e.canceled=!0,e._active=!1,setTimeout(()=>{this.compute(),this.emit()},0))}setActive(){this.state._active=this.state._pointerActive||this.state._keyboardActive}clean(){this.pointerClean(),this.state._pointerActive=!1,this.state._keyboardActive=!1,super.clean()}pointerDown(e){const t=this.config,n=this.state;if(e.buttons!=null&&(Array.isArray(t.pointerButtons)?!t.pointerButtons.includes(e.buttons):t.pointerButtons!==-1&&t.pointerButtons!==e.buttons))return;const s=this.ctrl.setEventIds(e);t.pointerCapture&&e.target.setPointerCapture(e.pointerId),!(s&&s.size>1&&n._pointerActive)&&(this.start(e),this.setupPointer(e),n._pointerId=q(e),n._pointerActive=!0,this.computeValues(le(e)),this.computeInitial(),t.preventScrollAxis&&ue(e)!=="mouse"?(n._active=!1,this.setupScrollPrevention(e)):t.delay>0?(this.setupDelayTrigger(e),t.triggerAllEvents&&(this.compute(e),this.emit())):this.startPointerDrag(e))}startPointerDrag(e){const t=this.state;t._active=!0,t._preventScroll=!0,t._delayed=!1,this.compute(e),this.emit()}pointerMove(e){const t=this.state,n=this.config;if(!t._pointerActive)return;const s=q(e);if(t._pointerId!==void 0&&s!==t._pointerId)return;const i=le(e);if(document.pointerLockElement===e.target?t._delta=[e.movementX,e.movementY]:(t._delta=v.sub(i,t._values),this.computeValues(i)),v.addTo(t._movement,t._delta),this.compute(e),t._delayed&&t.intentional){this.timeoutStore.remove("dragDelay"),t.active=!1,this.startPointerDrag(e);return}if(n.preventScrollAxis&&!t._preventScroll)if(t.axis)if(t.axis===n.preventScrollAxis||n.preventScrollAxis==="xy"){t._active=!1,this.clean();return}else{this.timeoutStore.remove("startPointerDrag"),this.startPointerDrag(e);return}else return;this.emit()}pointerUp(e){this.ctrl.setEventIds(e);try{this.config.pointerCapture&&e.target.hasPointerCapture(e.pointerId)&&e.target.releasePointerCapture(e.pointerId)}catch{process.env.NODE_ENV==="development"&&console.warn("[@use-gesture]: If you see this message, it's likely that you're using an outdated version of `@react-three/fiber`. \n\nPlease upgrade to the latest version.")}const t=this.state,n=this.config;if(!t._active||!t._pointerActive)return;const s=q(e);if(t._pointerId!==void 0&&s!==t._pointerId)return;this.state._pointerActive=!1,this.setActive(),this.compute(e);const[i,u]=t._distance;if(t.tap=i<=n.tapsThreshold&&u<=n.tapsThreshold,t.tap&&n.filterTaps)t._force=!0;else{const[a,c]=t._delta,[p,f]=t._movement,[I,_]=n.swipe.velocity,[M,R]=n.swipe.distance,N=n.swipe.duration;if(t.elapsedTime<N){const $=Math.abs(a/t.timeDelta),w=Math.abs(c/t.timeDelta);$>I&&Math.abs(p)>M&&(t.swipe[0]=Math.sign(a)),w>_&&Math.abs(f)>R&&(t.swipe[1]=Math.sign(c))}}this.emit()}pointerClick(e){!this.state.tap&&e.detail>0&&(e.preventDefault(),e.stopPropagation())}setupPointer(e){const t=this.config,n=t.device;if(process.env.NODE_ENV==="development")try{if(n==="pointer"&&t.preventScrollDelay===void 0){const s="uv"in e?e.sourceEvent.currentTarget:e.currentTarget;window.getComputedStyle(s).touchAction==="auto"&&console.warn("[@use-gesture]: The drag target has its `touch-action` style property set to `auto`. It is recommended to add `touch-action: 'none'` so that the drag gesture behaves correctly on touch-enabled devices. For more information read this: https://use-gesture.netlify.app/docs/extras/#touch-action.\n\nThis message will only show in development mode. It won't appear in production. If this is intended, you can ignore it.",s)}}catch{}t.pointerLock&&e.currentTarget.requestPointerLock(),t.pointerCapture||(this.eventStore.add(this.sharedConfig.window,n,"change",this.pointerMove.bind(this)),this.eventStore.add(this.sharedConfig.window,n,"end",this.pointerUp.bind(this)),this.eventStore.add(this.sharedConfig.window,n,"cancel",this.pointerUp.bind(this)))}pointerClean(){this.config.pointerLock&&document.pointerLockElement===this.state.currentTarget&&document.exitPointerLock()}preventScroll(e){this.state._preventScroll&&e.cancelable&&e.preventDefault()}setupScrollPrevention(e){this.state._preventScroll=!1,Ge(e);const t=this.eventStore.add(this.sharedConfig.window,"touch","change",this.preventScroll.bind(this),{passive:!1});this.eventStore.add(this.sharedConfig.window,"touch","end",t),this.eventStore.add(this.sharedConfig.window,"touch","cancel",t),this.timeoutStore.add("startPointerDrag",this.startPointerDrag.bind(this),this.config.preventScrollDelay,e)}setupDelayTrigger(e){this.state._delayed=!0,this.timeoutStore.add("dragDelay",()=>{this.state._step=[0,0],this.startPointerDrag(e)},this.config.delay)}keyDown(e){const t=me[e.key];if(t){const n=this.state,s=e.shiftKey?10:e.altKey?.1:1;this.start(e),n._delta=t(this.config.keyboardDisplacement,s),n._keyboardActive=!0,v.addTo(n._movement,n._delta),this.compute(e),this.emit()}}keyUp(e){e.key in me&&(this.state._keyboardActive=!1,this.setActive(),this.compute(e),this.emit())}bind(e){const t=this.config.device;e(t,"start",this.pointerDown.bind(this)),this.config.pointerCapture&&(e(t,"change",this.pointerMove.bind(this)),e(t,"end",this.pointerUp.bind(this)),e(t,"cancel",this.pointerUp.bind(this)),e("lostPointerCapture","",this.pointerUp.bind(this))),this.config.keys&&(e("key","down",this.keyDown.bind(this)),e("key","up",this.keyUp.bind(this))),this.config.filterTaps&&e("click","",this.pointerClick.bind(this),{capture:!0,passive:!1})}}function Ge(r){"persist"in r&&typeof r.persist=="function"&&r.persist()}const K=typeof window<"u"&&window.document&&window.document.createElement;function ge(){return K&&"ontouchstart"in window}function Xe(){return ge()||K&&window.navigator.maxTouchPoints>1}function qe(){return K&&"onpointerdown"in window}function Je(){return K&&"exitPointerLock"in window.document}function Qe(){try{return"constructor"in GestureEvent}catch{return!1}}const T={isBrowser:K,gesture:Qe(),touch:ge(),touchscreen:Xe(),pointer:qe(),pointerLock:Je()},Ze=250,et=180,tt=.5,rt=50,nt=250,st=10,ve={mouse:0,touch:0,pen:8},ye=h(h({},U),{},{device(r,e,{pointer:{touch:t=!1,lock:n=!1,mouse:s=!1}={}}){return this.pointerLock=n&&T.pointerLock,T.touch&&t?"touch":this.pointerLock?"mouse":T.pointer&&!s?"pointer":T.touch?"touch":"mouse"},preventScrollAxis(r,e,{preventScroll:t}){if(this.preventScrollDelay=typeof t=="number"?t:t||t===void 0&&r?Ze:void 0,!(!T.touchscreen||t===!1))return r||(t!==void 0?"y":void 0)},pointerCapture(r,e,{pointer:{capture:t=!0,buttons:n=1,keys:s=!0}={}}){return this.pointerButtons=n,this.keys=s,!this.pointerLock&&this.device==="pointer"&&t},threshold(r,e,{filterTaps:t=!1,tapsThreshold:n=3,axis:s=void 0}){const i=v.toVector(r,t?n:s?1:0);return this.filterTaps=t,this.tapsThreshold=n,i},swipe({velocity:r=tt,distance:e=rt,duration:t=nt}={}){return{velocity:this.transform(v.toVector(r)),distance:this.transform(v.toVector(e)),duration:t}},delay(r=0){switch(r){case!0:return et;case!1:return 0;default:return r}},axisThreshold(r){return r?h(h({},ve),r):ve},keyboardDisplacement(r=st){return r}});process.env.NODE_ENV==="development"&&Object.assign(ye,{useTouch(r){if(r!==void 0)throw Error("[@use-gesture]: `useTouch` option has been renamed to `pointer.touch`. Use it as in `{ pointer: { touch: true } }`.");return NaN},experimental_preventWindowScrollY(r){if(r!==void 0)throw Error("[@use-gesture]: `experimental_preventWindowScrollY` option has been renamed to `preventScroll`.");return NaN},swipeVelocity(r){if(r!==void 0)throw Error("[@use-gesture]: `swipeVelocity` option has been renamed to `swipe.velocity`. Use it as in `{ swipe: { velocity: 0.5 } }`.");return NaN},swipeDistance(r){if(r!==void 0)throw Error("[@use-gesture]: `swipeDistance` option has been renamed to `swipe.distance`. Use it as in `{ swipe: { distance: 50 } }`.");return NaN},swipeDuration(r){if(r!==void 0)throw Error("[@use-gesture]: `swipeDuration` option has been renamed to `swipe.duration`. Use it as in `{ swipe: { duration: 250 } }`.");return NaN}}),h(h({},J),{},{device(r,e,{shared:t,pointer:{touch:n=!1}={}}){if(t.target&&!T.touch&&T.gesture)return"gesture";if(T.touch&&n)return"touch";if(T.touchscreen){if(T.pointer)return"pointer";if(T.touch)return"touch"}},bounds(r,e,{scaleBounds:t={},angleBounds:n={}}){const s=u=>{const a=de(F(t,u),{min:-1/0,max:1/0});return[a.min,a.max]},i=u=>{const a=de(F(n,u),{min:-1/0,max:1/0});return[a.min,a.max]};return typeof t!="function"&&typeof n!="function"?[s(),i()]:u=>[s(u),i(u)]},threshold(r,e,t){return this.lockDirection=t.axis==="lock",v.toVector(r,this.lockDirection?[.1,3]:0)},modifierKey(r){return r===void 0?"ctrlKey":r},pinchOnWheel(r=!0){return r}}),h(h({},U),{},{mouseOnly:(r=!0)=>r}),h(h({},U),{},{mouseOnly:(r=!0)=>r});const _e=new Map,Q=new Map;function it(r){_e.set(r.key,r.engine),Q.set(r.key,r.resolver)}const ot={key:"drag",engine:He,resolver:ye};function at(r,e){if(r==null)return{};var t={},n=Object.keys(r),s,i;for(i=0;i<n.length;i++)s=n[i],!(e.indexOf(s)>=0)&&(t[s]=r[s]);return t}function ct(r,e){if(r==null)return{};var t=at(r,e),n,s;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(r);for(s=0;s<i.length;s++)n=i[s],!(e.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(r,n)&&(t[n]=r[n])}return t}const ut={target(r){if(r)return()=>"current"in r?r.current:r},enabled(r=!0){return r},window(r=T.isBrowser?window:void 0){return r},eventOptions({passive:r=!0,capture:e=!1}={}){return{passive:r,capture:e}},transform(r){return r}},ft=["target","eventOptions","window","enabled","transform"];function H(r={},e){const t={};for(const[n,s]of Object.entries(e))switch(typeof s){case"function":if(process.env.NODE_ENV==="development"){const i=s.call(t,r[n],n,r);Number.isNaN(i)||(t[n]=i)}else t[n]=s.call(t,r[n],n,r);break;case"object":t[n]=H(r[n],s);break;case"boolean":s&&(t[n]=r[n]);break}return t}function lt(r,e,t={}){const n=r,{target:s,eventOptions:i,window:u,enabled:a,transform:c}=n,p=ct(n,ft);if(t.shared=H({target:s,eventOptions:i,window:u,enabled:a,transform:c},ut),e){const f=Q.get(e);t[e]=H(h({shared:t.shared},p),f)}else for(const f in p){const I=Q.get(f);if(I)t[f]=H(h({shared:t.shared},p[f]),I);else if(process.env.NODE_ENV==="development"&&!["drag","pinch","scroll","wheel","move","hover"].includes(f)){if(f==="domTarget")throw Error("[@use-gesture]: `domTarget` option has been renamed to `target`.");console.warn(`[@use-gesture]: Unknown config key \`${f}\` was used. Please read the documentation for further information.`)}}return t}class be{constructor(e,t){b(this,"_listeners",new Set),this._ctrl=e,this._gestureKey=t}add(e,t,n,s,i){const u=this._listeners,a=Me(t,n),c=this._gestureKey?this._ctrl.config[this._gestureKey].eventOptions:{},p=h(h({},c),i);e.addEventListener(a,s,p);const f=()=>{e.removeEventListener(a,s,p),u.delete(f)};return u.add(f),f}clean(){this._listeners.forEach(e=>e()),this._listeners.clear()}}class dt{constructor(){b(this,"_timeouts",new Map)}add(e,t,n=140,...s){this.remove(e),this._timeouts.set(e,window.setTimeout(t,n,...s))}remove(e){const t=this._timeouts.get(e);t&&window.clearTimeout(t)}clean(){this._timeouts.forEach(e=>void window.clearTimeout(e)),this._timeouts.clear()}}class ht{constructor(e){b(this,"gestures",new Set),b(this,"_targetEventStore",new be(this)),b(this,"gestureEventStores",{}),b(this,"gestureTimeoutStores",{}),b(this,"handlers",{}),b(this,"config",{}),b(this,"pointerIds",new Set),b(this,"touchIds",new Set),b(this,"state",{shared:{shiftKey:!1,metaKey:!1,ctrlKey:!1,altKey:!1}}),pt(this,e)}setEventIds(e){if(Y(e))return this.touchIds=new Set(Ve(e)),this.touchIds;if("pointerId"in e)return e.type==="pointerup"||e.type==="pointercancel"?this.pointerIds.delete(e.pointerId):e.type==="pointerdown"&&this.pointerIds.add(e.pointerId),this.pointerIds}applyHandlers(e,t){this.handlers=e,this.nativeHandlers=t}applyConfig(e,t){this.config=lt(e,t,this.config)}clean(){this._targetEventStore.clean();for(const e of this.gestures)this.gestureEventStores[e].clean(),this.gestureTimeoutStores[e].clean()}effect(){return this.config.shared.target&&this.bind(),()=>this._targetEventStore.clean()}bind(...e){const t=this.config.shared,n={};let s;if(!(t.target&&(s=t.target(),!s))){if(t.enabled){for(const u of this.gestures){const a=this.config[u],c=we(n,a.eventOptions,!!s);if(a.enabled){const p=_e.get(u);new p(this,e,u).bind(c)}}const i=we(n,t.eventOptions,!!s);for(const u in this.nativeHandlers)i(u,"",a=>this.nativeHandlers[u](h(h({},this.state.shared),{},{event:a,args:e})),void 0,!0)}for(const i in n)n[i]=Ke(...n[i]);if(!s)return n;for(const i in n){const{device:u,capture:a,passive:c}=Ne(i);this._targetEventStore.add(s,u,"",n[i],{capture:a,passive:c})}}}}function L(r,e){r.gestures.add(e),r.gestureEventStores[e]=new be(r,e),r.gestureTimeoutStores[e]=new dt}function pt(r,e){e.drag&&L(r,"drag"),e.wheel&&L(r,"wheel"),e.scroll&&L(r,"scroll"),e.move&&L(r,"move"),e.pinch&&L(r,"pinch"),e.hover&&L(r,"hover")}const we=(r,e,t)=>(n,s,i,u={},a=!1)=>{var c,p;const f=(c=u.capture)!==null&&c!==void 0?c:e.capture,I=(p=u.passive)!==null&&p!==void 0?p:e.passive;let _=a?n:Ae(n,s,f);t&&I&&(_+="Passive"),r[_]=r[_]||[],r[_].push(i)};function mt(r,e={},t,n){const s=y.useMemo(()=>new ht(r),[]);if(s.applyHandlers(r,n),s.applyConfig(e,t),y.useEffect(s.effect.bind(s)),y.useEffect(()=>s.clean.bind(s),[]),e.target===void 0)return s.bind.bind(s)}function gt(r,e){return it(ot),mt({drag:r},e||{},"drag")}const Z="RSC::Event";function vt(){const r=y.useRef(null);function e(n){y.useEffect(()=>{r.current||(r.current=document.createElement("div"));function s(i){n(i.detail)}if(r.current)return r.current.addEventListener(Z,s,!1),()=>{var i;(i=r.current)==null||i.removeEventListener(Z,s,!1)}},[n])}function t(n){if(r.current){const s=new CustomEvent(Z,{detail:n});r.current.dispatchEvent(s)}}return{useListenToCustomEvent:e,emitEvent:t}}function yt({init:r=!0,items:e,withLoop:t=!1,id:n,itemsPerSlide:s=1,gutter:i=0,startEndGutter:u=0,carouselAxis:a="x",slideType:c="fixed",startingPosition:p="start",enableGestures:f=!0,slideWhenDragThresholdIsReached:I=!0,onInit:_}){const[M,R]=y.useState(!1),N=y.useRef(r),$=y.useRef(null),w=y.useRef(null),G=y.useRef(0),D=y.useRef(!t),E=y.useRef(!1),B=y.useRef(0),l=y.useRef(0),[V,ee]=Te.useSpring(()=>({value:0,onChange({value:o}){(c==="fixed"||c==="fluid")&&$.current.style.setProperty(`--${n}-offset-position`,`${o.value}px`),c==="freeScroll"&&(w.current[a==="x"?"scrollLeft":"scrollTop"]=Math.abs(o.value))}}),[a]),_t=c!=="freeScroll"&&t?[...e.map(o=>({...o,id:`prev-repeated-item-${o.id}`,isClonedItem:!0})),...e,...e.map(o=>({...o,id:`next-repeated-item-${o.id}`,isClonedItem:!0}))]:e,{useListenToCustomEvent:Ee,emitEvent:z}=vt();function te(o){N.current&&(E.current||W({type:"next",toIndex:o,actionType:"click"}))}function re(o){N.current&&(D.current||W({type:"prev",toIndex:o,actionType:"click"}))}function W({type:o,shouldAnimate:d=!0,toIndex:k,actionType:S}){var Se,xe;const m=X(),A=!d;D.current=!1,E.current=!1;let C=V.value.get(),g=0;if(o==="next"&&c!=="freeScroll"&&(l.current+=1),o==="prev"&&c!=="freeScroll"&&(l.current===0?l.current=e.length-1:l.current-=1),k!==void 0&&(l.current=k),c!=="freeScroll"&&o==="next"){const x=ne(t?m*(e.length*2):0);g=-(l.current*m),x-Math.abs(g)<m/1.2&&c==="fluid"&&!t&&(g=-x),!t&&Math.abs(g)>=x&&(E.current=!0,g=-x),t&&l.current===e.length&&(l.current=0,C=C+m*e.length,g=0)}if(c!=="freeScroll"&&o==="prev"&&(g=-(l.current*m),l.current===e.length-1&&(C=C-e.length*m),!t&&g>=0&&(D.current=!0,g=0)),c==="freeScroll"&&o==="next"){const x=w.current[a==="x"?"scrollLeft":"scrollTop"],j=a==="x"?w.current.scrollWidth-w.current.clientWidth:w.current.scrollHeight-w.current.clientHeight;C=x,g=x+m,(g>j||j-g<80)&&(g=j,E.current=!0)}if(c==="freeScroll"&&o==="prev"){const x=w.current[a==="x"?"scrollLeft":"scrollTop"];C=x,g=x-m,g<=0&&(g=0,E.current=!0)}G.current=g,z(S==="resize"?{eventName:"onResize",sliceActionType:S,slideDirection:o,currentItem:{index:l.current,id:((Se=e.at(l.current))==null?void 0:Se.id)??"",startReached:D.current,endReached:E.current}}:{eventName:"onSlideStartChange",sliceActionType:S,slideDirection:o,nextItem:{index:l.current,id:((xe=e.at(l.current))==null?void 0:xe.id)??"",startReached:D.current,endReached:E.current}}),ee.start({immediate:A,from:{value:C},to:{value:g},onRest({finished:x}){var j;x&&c==="fixed"&&z({eventName:"onSlideChangeComplete",sliceActionType:S,slideDirection:o,currentItem:{index:l.current,id:((j=e.at(l.current))==null?void 0:j.id)??"",startReached:D.current,endReached:E.current}}),x&&c==="fluid"&&z({eventName:"onSlideChangeComplete",sliceActionType:S,slideDirection:o,currentItem:{index:0,id:"",startReached:D.current,endReached:E.current}})}})}function X(){const o=w.current.children[0];let d=0;return d=o.getBoundingClientRect()[a==="x"?"width":"height"]+i,d}function ne(o){const d=w.current;return d[a==="x"?"scrollWidth":"scrollHeight"]-d.getBoundingClientRect()[a==="x"?"width":"height"]-o}function bt(){let o=0;const d=getComputedStyle(document.documentElement).getPropertyValue(`--${n}-start-end-gutter`);return d.includes("px")&&(o=Number(d.replace("px",""))),{totalStartEndGutterCssVar:o}}y.useEffect(()=>{function o(S,m){switch(S){case"start":return 0;case"middle-start":return Math.floor((m-1)*.25);case"center":return Math.floor((m-1)*.5);case"middle-end":return Math.floor((m-1)*.75);case"end":return m-1;default:return 0}}function d(S){if($.current){const{totalStartEndGutterCssVar:m}=bt();let A=0;t&&(A=X()*e.length),A-=X()*o(p,s),A-=m/2,$.current.style.setProperty(`--${n}-offset-modifier`,`${-A}px`),R(!0),S&&S()}}function k(){d(),W({type:"next",toIndex:l.current,shouldAnimate:!1,actionType:"resize"})}if(r&&(B.current=X()/4),r&&c==="fixed")return d(_),window.addEventListener("resize",k),()=>{window.removeEventListener("resize",k)}},[r,t,n,a,i,p,c]);const wt=gt(o=>{if(!N.current)return;const d=o.dragging,k=o.offset[a==="x"?0:1],S=o.movement[a==="x"?0:1],m=S>B.current,A=S<-B.current,C=o.velocity;d&&(z({...o,eventName:"onDrag",slideActionType:"drag"}),ee.start({value:k,immediate:!0,config:{velocity:C}}),I&&(m||A)&&o.cancel()),o.last&&(m?W({actionType:"drag",type:"prev"}):A?W({actionType:"drag",type:"next"}):ee.start({value:G.current,config:{velocity:C}}))},{enabled:f&&c!=="freeScroll",axis:a,rubberband:!t,...t?{}:{bounds:()=>({right:0,left:-ne(0),top:-ne(0),bottom:0})},from:()=>[V.value.get(),V.value.get()]});return{carouselFragment:P.jsxs("div",{ref:$,className:"ReactSpringCarouselContainer","data-part":"Container","data-part-internal":`${n}-Container`,children:[P.jsx("style",{dangerouslySetInnerHTML:{__html:`
|
|
1
|
+
(function(O,P){typeof exports=="object"&&typeof module<"u"?P(exports,require("react/jsx-runtime"),require("@react-spring/web"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","@react-spring/web","react"],P):(O=typeof globalThis<"u"?globalThis:O||self,P(O["react-spring-carousel"]={},O["react/jsx-runtime"],O["@react-spring/web"],O.React))})(this,function(O,P,Ie,y){"use strict";function De(r,e,t){return Math.max(e,Math.min(r,t))}const v={toVector(r,e){return r===void 0&&(r=e),Array.isArray(r)?r:[r,r]},add(r,e){return[r[0]+e[0],r[1]+e[1]]},sub(r,e){return[r[0]-e[0],r[1]-e[1]]},addTo(r,e){r[0]+=e[0],r[1]+=e[1]},subTo(r,e){r[0]-=e[0],r[1]-=e[1]}};function se(r,e,t){return e===0||Math.abs(e)===1/0?Math.pow(r,t*5):r*e*t/(e+t*r)}function ie(r,e,t,n=.15){return n===0?De(r,e,t):r<e?-se(e-r,t-e,n)+e:r>t?+se(r-t,t-e,n)+t:r}function ke(r,[e,t],[n,s]){const[[i,u],[a,c]]=r;return[ie(e,i,u,n),ie(t,a,c,s)]}function Ce(r,e){if(typeof r!="object"||r===null)return r;var t=r[Symbol.toPrimitive];if(t!==void 0){var n=t.call(r,e);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(r)}function Oe(r){var e=Ce(r,"string");return typeof e=="symbol"?e:String(e)}function b(r,e,t){return e=Oe(e),e in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function oe(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);e&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(r,s).enumerable})),t.push.apply(t,n)}return t}function h(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?oe(Object(t),!0).forEach(function(n){b(r,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):oe(Object(t)).forEach(function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(t,n))})}return r}const ae={pointer:{start:"down",change:"move",end:"up"},mouse:{start:"down",change:"move",end:"up"},touch:{start:"start",change:"move",end:"end"},gesture:{start:"start",change:"change",end:"end"}};function ce(r){return r?r[0].toUpperCase()+r.slice(1):""}const $e=["enter","leave"];function Ae(r=!1,e){return r&&!$e.includes(e)}function Pe(r,e="",t=!1){const n=ae[r],s=n&&n[e]||e;return"on"+ce(r)+ce(s)+(Ae(t,s)?"Capture":"")}const Ne=["gotpointercapture","lostpointercapture"];function Me(r){let e=r.substring(2).toLowerCase();const t=!!~e.indexOf("passive");t&&(e=e.replace("passive",""));const n=Ne.includes(e)?"capturecapture":"capture",s=!!~e.indexOf(n);return s&&(e=e.replace("capture","")),{device:e,capture:s,passive:t}}function Le(r,e=""){const t=ae[r],n=t&&t[e]||e;return r+n}function Y(r){return"touches"in r}function ue(r){return Y(r)?"touch":"pointerType"in r?r.pointerType:"mouse"}function Re(r){return Array.from(r.touches).filter(e=>{var t,n;return e.target===r.currentTarget||((t=r.currentTarget)===null||t===void 0||(n=t.contains)===null||n===void 0?void 0:n.call(t,e.target))})}function Ve(r){return r.type==="touchend"||r.type==="touchcancel"?r.changedTouches:r.targetTouches}function fe(r){return Y(r)?Ve(r)[0]:r}function je(r){return Re(r).map(e=>e.identifier)}function q(r){const e=fe(r);return Y(r)?e.identifier:e.pointerId}function le(r){const e=fe(r);return[e.clientX,e.clientY]}function Ue(r){const e={};if("buttons"in r&&(e.buttons=r.buttons),"shiftKey"in r){const{shiftKey:t,altKey:n,metaKey:s,ctrlKey:i}=r;Object.assign(e,{shiftKey:t,altKey:n,metaKey:s,ctrlKey:i})}return e}function F(r,...e){return typeof r=="function"?r(...e):r}function Ke(){}function Be(...r){return r.length===0?Ke:r.length===1?r[0]:function(){let e;for(const t of r)e=t.apply(this,arguments)||e;return e}}function de(r,e){return Object.assign({},e,r||{})}const ze=32;class We{constructor(e,t,n){this.ctrl=e,this.args=t,this.key=n,this.state||(this.state={},this.computeValues([0,0]),this.computeInitial(),this.init&&this.init(),this.reset())}get state(){return this.ctrl.state[this.key]}set state(e){this.ctrl.state[this.key]=e}get shared(){return this.ctrl.state.shared}get eventStore(){return this.ctrl.gestureEventStores[this.key]}get timeoutStore(){return this.ctrl.gestureTimeoutStores[this.key]}get config(){return this.ctrl.config[this.key]}get sharedConfig(){return this.ctrl.config.shared}get handler(){return this.ctrl.handlers[this.key]}reset(){const{state:e,shared:t,ingKey:n,args:s}=this;t[n]=e._active=e.active=e._blocked=e._force=!1,e._step=[!1,!1],e.intentional=!1,e._movement=[0,0],e._distance=[0,0],e._direction=[0,0],e._delta=[0,0],e._bounds=[[-1/0,1/0],[-1/0,1/0]],e.args=s,e.axis=void 0,e.memo=void 0,e.elapsedTime=e.timeDelta=0,e.direction=[0,0],e.distance=[0,0],e.overflow=[0,0],e._movementBound=[!1,!1],e.velocity=[0,0],e.movement=[0,0],e.delta=[0,0],e.timeStamp=0}start(e){const t=this.state,n=this.config;t._active||(this.reset(),this.computeInitial(),t._active=!0,t.target=e.target,t.currentTarget=e.currentTarget,t.lastOffset=n.from?F(n.from,t):t.offset,t.offset=t.lastOffset,t.startTime=t.timeStamp=e.timeStamp)}computeValues(e){const t=this.state;t._values=e,t.values=this.config.transform(e)}computeInitial(){const e=this.state;e._initial=e._values,e.initial=e.values}compute(e){const{state:t,config:n,shared:s}=this;t.args=this.args;let i=0;if(e&&(t.event=e,n.preventDefault&&e.cancelable&&t.event.preventDefault(),t.type=e.type,s.touches=this.ctrl.pointerIds.size||this.ctrl.touchIds.size,s.locked=!!document.pointerLockElement,Object.assign(s,Ue(e)),s.down=s.pressed=s.buttons%2===1||s.touches>0,i=e.timeStamp-t.timeStamp,t.timeStamp=e.timeStamp,t.elapsedTime=t.timeStamp-t.startTime),t._active){const l=t._delta.map(Math.abs);v.addTo(t._distance,l)}this.axisIntent&&this.axisIntent(e);const[u,a]=t._movement,[c,p]=n.threshold,{_step:f,values:I}=t;if(n.hasCustomTransform?(f[0]===!1&&(f[0]=Math.abs(u)>=c&&I[0]),f[1]===!1&&(f[1]=Math.abs(a)>=p&&I[1])):(f[0]===!1&&(f[0]=Math.abs(u)>=c&&Math.sign(u)*c),f[1]===!1&&(f[1]=Math.abs(a)>=p&&Math.sign(a)*p)),t.intentional=f[0]!==!1||f[1]!==!1,!t.intentional)return;const _=[0,0];if(n.hasCustomTransform){const[l,V]=I;_[0]=f[0]!==!1?l-f[0]:0,_[1]=f[1]!==!1?V-f[1]:0}else _[0]=f[0]!==!1?u-f[0]:0,_[1]=f[1]!==!1?a-f[1]:0;this.restrictToAxis&&!t._blocked&&this.restrictToAxis(_);const M=t.offset,R=t._active&&!t._blocked||t.active;R&&(t.first=t._active&&!t.active,t.last=!t._active&&t.active,t.active=s[this.ingKey]=t._active,e&&(t.first&&("bounds"in n&&(t._bounds=F(n.bounds,t)),this.setup&&this.setup()),t.movement=_,this.computeOffset()));const[N,$]=t.offset,[[w,G],[D,E]]=t._bounds;t.overflow=[N<w?-1:N>G?1:0,$<D?-1:$>E?1:0],t._movementBound[0]=t.overflow[0]?t._movementBound[0]===!1?t._movement[0]:t._movementBound[0]:!1,t._movementBound[1]=t.overflow[1]?t._movementBound[1]===!1?t._movement[1]:t._movementBound[1]:!1;const B=t._active?n.rubberband||[0,0]:[0,0];if(t.offset=ke(t._bounds,t.offset,B),t.delta=v.sub(t.offset,M),this.computeMovement(),R&&(!t.last||i>ze)){t.delta=v.sub(t.offset,M);const l=t.delta.map(Math.abs);v.addTo(t.distance,l),t.direction=t.delta.map(Math.sign),t._direction=t._delta.map(Math.sign),!t.first&&i>0&&(t.velocity=[l[0]/i,l[1]/i],t.timeDelta=i)}}emit(){const e=this.state,t=this.shared,n=this.config;if(e._active||this.clean(),(e._blocked||!e.intentional)&&!e._force&&!n.triggerAllEvents)return;const s=this.handler(h(h(h({},t),e),{},{[this.aliasKey]:e.values}));s!==void 0&&(e.memo=s)}clean(){this.eventStore.clean(),this.timeoutStore.clean()}}function Ye([r,e],t){const n=Math.abs(r),s=Math.abs(e);if(n>s&&n>t)return"x";if(s>n&&s>t)return"y"}class Fe extends We{constructor(...e){super(...e),b(this,"aliasKey","xy")}reset(){super.reset(),this.state.axis=void 0}init(){this.state.offset=[0,0],this.state.lastOffset=[0,0]}computeOffset(){this.state.offset=v.add(this.state.lastOffset,this.state.movement)}computeMovement(){this.state.movement=v.sub(this.state.offset,this.state.lastOffset)}axisIntent(e){const t=this.state,n=this.config;if(!t.axis&&e){const s=typeof n.axisThreshold=="object"?n.axisThreshold[ue(e)]:n.axisThreshold;t.axis=Ye(t._movement,s)}t._blocked=(n.lockDirection||!!n.axis)&&!t.axis||!!n.axis&&n.axis!==t.axis}restrictToAxis(e){if(this.config.axis||this.config.lockDirection)switch(this.state.axis){case"x":e[1]=0;break;case"y":e[0]=0;break}}}const he=r=>r,pe=.15,J={enabled(r=!0){return r},eventOptions(r,e,t){return h(h({},t.shared.eventOptions),r)},preventDefault(r=!1){return r},triggerAllEvents(r=!1){return r},rubberband(r=0){switch(r){case!0:return[pe,pe];case!1:return[0,0];default:return v.toVector(r)}},from(r){if(typeof r=="function")return r;if(r!=null)return v.toVector(r)},transform(r,e,t){const n=r||t.shared.transform;if(this.hasCustomTransform=!!n,process.env.NODE_ENV==="development"){const s=n||he;return i=>{const u=s(i);return(!isFinite(u[0])||!isFinite(u[1]))&&console.warn(`[@use-gesture]: config.transform() must produce a valid result, but it was: [${u[0]},${[1]}]`),u}}return n||he},threshold(r){return v.toVector(r,0)}};process.env.NODE_ENV==="development"&&Object.assign(J,{domTarget(r){if(r!==void 0)throw Error("[@use-gesture]: `domTarget` option has been renamed to `target`.");return NaN},lockDirection(r){if(r!==void 0)throw Error("[@use-gesture]: `lockDirection` option has been merged with `axis`. Use it as in `{ axis: 'lock' }`");return NaN},initial(r){if(r!==void 0)throw Error("[@use-gesture]: `initial` option has been renamed to `from`.");return NaN}});const He=0,U=h(h({},J),{},{axis(r,e,{axis:t}){if(this.lockDirection=t==="lock",!this.lockDirection)return t},axisThreshold(r=He){return r},bounds(r={}){if(typeof r=="function")return i=>U.bounds(r(i));if("current"in r)return()=>r.current;if(typeof HTMLElement=="function"&&r instanceof HTMLElement)return r;const{left:e=-1/0,right:t=1/0,top:n=-1/0,bottom:s=1/0}=r;return[[e,t],[n,s]]}}),me={ArrowRight:(r,e=1)=>[r*e,0],ArrowLeft:(r,e=1)=>[-1*r*e,0],ArrowUp:(r,e=1)=>[0,-1*r*e],ArrowDown:(r,e=1)=>[0,r*e]};class Ge extends Fe{constructor(...e){super(...e),b(this,"ingKey","dragging")}reset(){super.reset();const e=this.state;e._pointerId=void 0,e._pointerActive=!1,e._keyboardActive=!1,e._preventScroll=!1,e._delayed=!1,e.swipe=[0,0],e.tap=!1,e.canceled=!1,e.cancel=this.cancel.bind(this)}setup(){const e=this.state;if(e._bounds instanceof HTMLElement){const t=e._bounds.getBoundingClientRect(),n=e.currentTarget.getBoundingClientRect(),s={left:t.left-n.left+e.offset[0],right:t.right-n.right+e.offset[0],top:t.top-n.top+e.offset[1],bottom:t.bottom-n.bottom+e.offset[1]};e._bounds=U.bounds(s)}}cancel(){const e=this.state;e.canceled||(e.canceled=!0,e._active=!1,setTimeout(()=>{this.compute(),this.emit()},0))}setActive(){this.state._active=this.state._pointerActive||this.state._keyboardActive}clean(){this.pointerClean(),this.state._pointerActive=!1,this.state._keyboardActive=!1,super.clean()}pointerDown(e){const t=this.config,n=this.state;if(e.buttons!=null&&(Array.isArray(t.pointerButtons)?!t.pointerButtons.includes(e.buttons):t.pointerButtons!==-1&&t.pointerButtons!==e.buttons))return;const s=this.ctrl.setEventIds(e);t.pointerCapture&&e.target.setPointerCapture(e.pointerId),!(s&&s.size>1&&n._pointerActive)&&(this.start(e),this.setupPointer(e),n._pointerId=q(e),n._pointerActive=!0,this.computeValues(le(e)),this.computeInitial(),t.preventScrollAxis&&ue(e)!=="mouse"?(n._active=!1,this.setupScrollPrevention(e)):t.delay>0?(this.setupDelayTrigger(e),t.triggerAllEvents&&(this.compute(e),this.emit())):this.startPointerDrag(e))}startPointerDrag(e){const t=this.state;t._active=!0,t._preventScroll=!0,t._delayed=!1,this.compute(e),this.emit()}pointerMove(e){const t=this.state,n=this.config;if(!t._pointerActive)return;const s=q(e);if(t._pointerId!==void 0&&s!==t._pointerId)return;const i=le(e);if(document.pointerLockElement===e.target?t._delta=[e.movementX,e.movementY]:(t._delta=v.sub(i,t._values),this.computeValues(i)),v.addTo(t._movement,t._delta),this.compute(e),t._delayed&&t.intentional){this.timeoutStore.remove("dragDelay"),t.active=!1,this.startPointerDrag(e);return}if(n.preventScrollAxis&&!t._preventScroll)if(t.axis)if(t.axis===n.preventScrollAxis||n.preventScrollAxis==="xy"){t._active=!1,this.clean();return}else{this.timeoutStore.remove("startPointerDrag"),this.startPointerDrag(e);return}else return;this.emit()}pointerUp(e){this.ctrl.setEventIds(e);try{this.config.pointerCapture&&e.target.hasPointerCapture(e.pointerId)&&e.target.releasePointerCapture(e.pointerId)}catch{process.env.NODE_ENV==="development"&&console.warn("[@use-gesture]: If you see this message, it's likely that you're using an outdated version of `@react-three/fiber`. \n\nPlease upgrade to the latest version.")}const t=this.state,n=this.config;if(!t._active||!t._pointerActive)return;const s=q(e);if(t._pointerId!==void 0&&s!==t._pointerId)return;this.state._pointerActive=!1,this.setActive(),this.compute(e);const[i,u]=t._distance;if(t.tap=i<=n.tapsThreshold&&u<=n.tapsThreshold,t.tap&&n.filterTaps)t._force=!0;else{const[a,c]=t._delta,[p,f]=t._movement,[I,_]=n.swipe.velocity,[M,R]=n.swipe.distance,N=n.swipe.duration;if(t.elapsedTime<N){const $=Math.abs(a/t.timeDelta),w=Math.abs(c/t.timeDelta);$>I&&Math.abs(p)>M&&(t.swipe[0]=Math.sign(a)),w>_&&Math.abs(f)>R&&(t.swipe[1]=Math.sign(c))}}this.emit()}pointerClick(e){!this.state.tap&&e.detail>0&&(e.preventDefault(),e.stopPropagation())}setupPointer(e){const t=this.config,n=t.device;if(process.env.NODE_ENV==="development")try{if(n==="pointer"&&t.preventScrollDelay===void 0){const s="uv"in e?e.sourceEvent.currentTarget:e.currentTarget;window.getComputedStyle(s).touchAction==="auto"&&console.warn("[@use-gesture]: The drag target has its `touch-action` style property set to `auto`. It is recommended to add `touch-action: 'none'` so that the drag gesture behaves correctly on touch-enabled devices. For more information read this: https://use-gesture.netlify.app/docs/extras/#touch-action.\n\nThis message will only show in development mode. It won't appear in production. If this is intended, you can ignore it.",s)}}catch{}t.pointerLock&&e.currentTarget.requestPointerLock(),t.pointerCapture||(this.eventStore.add(this.sharedConfig.window,n,"change",this.pointerMove.bind(this)),this.eventStore.add(this.sharedConfig.window,n,"end",this.pointerUp.bind(this)),this.eventStore.add(this.sharedConfig.window,n,"cancel",this.pointerUp.bind(this)))}pointerClean(){this.config.pointerLock&&document.pointerLockElement===this.state.currentTarget&&document.exitPointerLock()}preventScroll(e){this.state._preventScroll&&e.cancelable&&e.preventDefault()}setupScrollPrevention(e){this.state._preventScroll=!1,Xe(e);const t=this.eventStore.add(this.sharedConfig.window,"touch","change",this.preventScroll.bind(this),{passive:!1});this.eventStore.add(this.sharedConfig.window,"touch","end",t),this.eventStore.add(this.sharedConfig.window,"touch","cancel",t),this.timeoutStore.add("startPointerDrag",this.startPointerDrag.bind(this),this.config.preventScrollDelay,e)}setupDelayTrigger(e){this.state._delayed=!0,this.timeoutStore.add("dragDelay",()=>{this.state._step=[0,0],this.startPointerDrag(e)},this.config.delay)}keyDown(e){const t=me[e.key];if(t){const n=this.state,s=e.shiftKey?10:e.altKey?.1:1;this.start(e),n._delta=t(this.config.keyboardDisplacement,s),n._keyboardActive=!0,v.addTo(n._movement,n._delta),this.compute(e),this.emit()}}keyUp(e){e.key in me&&(this.state._keyboardActive=!1,this.setActive(),this.compute(e),this.emit())}bind(e){const t=this.config.device;e(t,"start",this.pointerDown.bind(this)),this.config.pointerCapture&&(e(t,"change",this.pointerMove.bind(this)),e(t,"end",this.pointerUp.bind(this)),e(t,"cancel",this.pointerUp.bind(this)),e("lostPointerCapture","",this.pointerUp.bind(this))),this.config.keys&&(e("key","down",this.keyDown.bind(this)),e("key","up",this.keyUp.bind(this))),this.config.filterTaps&&e("click","",this.pointerClick.bind(this),{capture:!0,passive:!1})}}function Xe(r){"persist"in r&&typeof r.persist=="function"&&r.persist()}const K=typeof window<"u"&&window.document&&window.document.createElement;function ge(){return K&&"ontouchstart"in window}function qe(){return ge()||K&&window.navigator.maxTouchPoints>1}function Je(){return K&&"onpointerdown"in window}function Qe(){return K&&"exitPointerLock"in window.document}function Ze(){try{return"constructor"in GestureEvent}catch{return!1}}const T={isBrowser:K,gesture:Ze(),touch:ge(),touchscreen:qe(),pointer:Je(),pointerLock:Qe()},et=250,tt=180,rt=.5,nt=50,st=250,it=10,ve={mouse:0,touch:0,pen:8},ye=h(h({},U),{},{device(r,e,{pointer:{touch:t=!1,lock:n=!1,mouse:s=!1}={}}){return this.pointerLock=n&&T.pointerLock,T.touch&&t?"touch":this.pointerLock?"mouse":T.pointer&&!s?"pointer":T.touch?"touch":"mouse"},preventScrollAxis(r,e,{preventScroll:t}){if(this.preventScrollDelay=typeof t=="number"?t:t||t===void 0&&r?et:void 0,!(!T.touchscreen||t===!1))return r||(t!==void 0?"y":void 0)},pointerCapture(r,e,{pointer:{capture:t=!0,buttons:n=1,keys:s=!0}={}}){return this.pointerButtons=n,this.keys=s,!this.pointerLock&&this.device==="pointer"&&t},threshold(r,e,{filterTaps:t=!1,tapsThreshold:n=3,axis:s=void 0}){const i=v.toVector(r,t?n:s?1:0);return this.filterTaps=t,this.tapsThreshold=n,i},swipe({velocity:r=rt,distance:e=nt,duration:t=st}={}){return{velocity:this.transform(v.toVector(r)),distance:this.transform(v.toVector(e)),duration:t}},delay(r=0){switch(r){case!0:return tt;case!1:return 0;default:return r}},axisThreshold(r){return r?h(h({},ve),r):ve},keyboardDisplacement(r=it){return r}});process.env.NODE_ENV==="development"&&Object.assign(ye,{useTouch(r){if(r!==void 0)throw Error("[@use-gesture]: `useTouch` option has been renamed to `pointer.touch`. Use it as in `{ pointer: { touch: true } }`.");return NaN},experimental_preventWindowScrollY(r){if(r!==void 0)throw Error("[@use-gesture]: `experimental_preventWindowScrollY` option has been renamed to `preventScroll`.");return NaN},swipeVelocity(r){if(r!==void 0)throw Error("[@use-gesture]: `swipeVelocity` option has been renamed to `swipe.velocity`. Use it as in `{ swipe: { velocity: 0.5 } }`.");return NaN},swipeDistance(r){if(r!==void 0)throw Error("[@use-gesture]: `swipeDistance` option has been renamed to `swipe.distance`. Use it as in `{ swipe: { distance: 50 } }`.");return NaN},swipeDuration(r){if(r!==void 0)throw Error("[@use-gesture]: `swipeDuration` option has been renamed to `swipe.duration`. Use it as in `{ swipe: { duration: 250 } }`.");return NaN}}),h(h({},J),{},{device(r,e,{shared:t,pointer:{touch:n=!1}={}}){if(t.target&&!T.touch&&T.gesture)return"gesture";if(T.touch&&n)return"touch";if(T.touchscreen){if(T.pointer)return"pointer";if(T.touch)return"touch"}},bounds(r,e,{scaleBounds:t={},angleBounds:n={}}){const s=u=>{const a=de(F(t,u),{min:-1/0,max:1/0});return[a.min,a.max]},i=u=>{const a=de(F(n,u),{min:-1/0,max:1/0});return[a.min,a.max]};return typeof t!="function"&&typeof n!="function"?[s(),i()]:u=>[s(u),i(u)]},threshold(r,e,t){return this.lockDirection=t.axis==="lock",v.toVector(r,this.lockDirection?[.1,3]:0)},modifierKey(r){return r===void 0?"ctrlKey":r},pinchOnWheel(r=!0){return r}}),h(h({},U),{},{mouseOnly:(r=!0)=>r}),h(h({},U),{},{mouseOnly:(r=!0)=>r});const _e=new Map,Q=new Map;function ot(r){_e.set(r.key,r.engine),Q.set(r.key,r.resolver)}const at={key:"drag",engine:Ge,resolver:ye};function ct(r,e){if(r==null)return{};var t={},n=Object.keys(r),s,i;for(i=0;i<n.length;i++)s=n[i],!(e.indexOf(s)>=0)&&(t[s]=r[s]);return t}function ut(r,e){if(r==null)return{};var t=ct(r,e),n,s;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(r);for(s=0;s<i.length;s++)n=i[s],!(e.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(r,n)&&(t[n]=r[n])}return t}const ft={target(r){if(r)return()=>"current"in r?r.current:r},enabled(r=!0){return r},window(r=T.isBrowser?window:void 0){return r},eventOptions({passive:r=!0,capture:e=!1}={}){return{passive:r,capture:e}},transform(r){return r}},lt=["target","eventOptions","window","enabled","transform"];function H(r={},e){const t={};for(const[n,s]of Object.entries(e))switch(typeof s){case"function":if(process.env.NODE_ENV==="development"){const i=s.call(t,r[n],n,r);Number.isNaN(i)||(t[n]=i)}else t[n]=s.call(t,r[n],n,r);break;case"object":t[n]=H(r[n],s);break;case"boolean":s&&(t[n]=r[n]);break}return t}function dt(r,e,t={}){const n=r,{target:s,eventOptions:i,window:u,enabled:a,transform:c}=n,p=ut(n,lt);if(t.shared=H({target:s,eventOptions:i,window:u,enabled:a,transform:c},ft),e){const f=Q.get(e);t[e]=H(h({shared:t.shared},p),f)}else for(const f in p){const I=Q.get(f);if(I)t[f]=H(h({shared:t.shared},p[f]),I);else if(process.env.NODE_ENV==="development"&&!["drag","pinch","scroll","wheel","move","hover"].includes(f)){if(f==="domTarget")throw Error("[@use-gesture]: `domTarget` option has been renamed to `target`.");console.warn(`[@use-gesture]: Unknown config key \`${f}\` was used. Please read the documentation for further information.`)}}return t}class be{constructor(e,t){b(this,"_listeners",new Set),this._ctrl=e,this._gestureKey=t}add(e,t,n,s,i){const u=this._listeners,a=Le(t,n),c=this._gestureKey?this._ctrl.config[this._gestureKey].eventOptions:{},p=h(h({},c),i);e.addEventListener(a,s,p);const f=()=>{e.removeEventListener(a,s,p),u.delete(f)};return u.add(f),f}clean(){this._listeners.forEach(e=>e()),this._listeners.clear()}}class ht{constructor(){b(this,"_timeouts",new Map)}add(e,t,n=140,...s){this.remove(e),this._timeouts.set(e,window.setTimeout(t,n,...s))}remove(e){const t=this._timeouts.get(e);t&&window.clearTimeout(t)}clean(){this._timeouts.forEach(e=>void window.clearTimeout(e)),this._timeouts.clear()}}class pt{constructor(e){b(this,"gestures",new Set),b(this,"_targetEventStore",new be(this)),b(this,"gestureEventStores",{}),b(this,"gestureTimeoutStores",{}),b(this,"handlers",{}),b(this,"config",{}),b(this,"pointerIds",new Set),b(this,"touchIds",new Set),b(this,"state",{shared:{shiftKey:!1,metaKey:!1,ctrlKey:!1,altKey:!1}}),mt(this,e)}setEventIds(e){if(Y(e))return this.touchIds=new Set(je(e)),this.touchIds;if("pointerId"in e)return e.type==="pointerup"||e.type==="pointercancel"?this.pointerIds.delete(e.pointerId):e.type==="pointerdown"&&this.pointerIds.add(e.pointerId),this.pointerIds}applyHandlers(e,t){this.handlers=e,this.nativeHandlers=t}applyConfig(e,t){this.config=dt(e,t,this.config)}clean(){this._targetEventStore.clean();for(const e of this.gestures)this.gestureEventStores[e].clean(),this.gestureTimeoutStores[e].clean()}effect(){return this.config.shared.target&&this.bind(),()=>this._targetEventStore.clean()}bind(...e){const t=this.config.shared,n={};let s;if(!(t.target&&(s=t.target(),!s))){if(t.enabled){for(const u of this.gestures){const a=this.config[u],c=we(n,a.eventOptions,!!s);if(a.enabled){const p=_e.get(u);new p(this,e,u).bind(c)}}const i=we(n,t.eventOptions,!!s);for(const u in this.nativeHandlers)i(u,"",a=>this.nativeHandlers[u](h(h({},this.state.shared),{},{event:a,args:e})),void 0,!0)}for(const i in n)n[i]=Be(...n[i]);if(!s)return n;for(const i in n){const{device:u,capture:a,passive:c}=Me(i);this._targetEventStore.add(s,u,"",n[i],{capture:a,passive:c})}}}}function L(r,e){r.gestures.add(e),r.gestureEventStores[e]=new be(r,e),r.gestureTimeoutStores[e]=new ht}function mt(r,e){e.drag&&L(r,"drag"),e.wheel&&L(r,"wheel"),e.scroll&&L(r,"scroll"),e.move&&L(r,"move"),e.pinch&&L(r,"pinch"),e.hover&&L(r,"hover")}const we=(r,e,t)=>(n,s,i,u={},a=!1)=>{var c,p;const f=(c=u.capture)!==null&&c!==void 0?c:e.capture,I=(p=u.passive)!==null&&p!==void 0?p:e.passive;let _=a?n:Pe(n,s,f);t&&I&&(_+="Passive"),r[_]=r[_]||[],r[_].push(i)};function gt(r,e={},t,n){const s=y.useMemo(()=>new pt(r),[]);if(s.applyHandlers(r,n),s.applyConfig(e,t),y.useEffect(s.effect.bind(s)),y.useEffect(()=>s.clean.bind(s),[]),e.target===void 0)return s.bind.bind(s)}function vt(r,e){return ot(at),gt({drag:r},e||{},"drag")}const Z="RSC::Event";function yt(){const r=y.useRef(null);function e(n){y.useEffect(()=>{r.current||(r.current=document.createElement("div"));function s(i){n(i.detail)}if(r.current)return r.current.addEventListener(Z,s,!1),()=>{var i;(i=r.current)==null||i.removeEventListener(Z,s,!1)}},[n])}function t(n){if(r.current){const s=new CustomEvent(Z,{detail:n});r.current.dispatchEvent(s)}}return{useListenToCustomEvent:e,emitEvent:t}}function _t({init:r=!0,items:e,withLoop:t=!1,id:n,itemsPerSlide:s=1,gutter:i=0,startEndGutter:u=0,carouselAxis:a="x",slideType:c="fixed",startingPosition:p="start",enableGestures:f=!0,slideWhenDragThresholdIsReached:I=!0,onInit:_}){const[M,R]=y.useState(!1),N=y.useRef(r),$=y.useRef(null),w=y.useRef(null),G=y.useRef(0),D=y.useRef(!t),E=y.useRef(!1),B=y.useRef(0),l=y.useRef(0),[V,ee]=Ie.useSpring(()=>({value:0,onChange({value:o}){(c==="fixed"||c==="fluid")&&$.current.style.setProperty(`--${n}-offset-position`,`${o.value}px`),c==="freeScroll"&&(w.current[a==="x"?"scrollLeft":"scrollTop"]=Math.abs(o.value))}}),[a]),bt=c!=="freeScroll"&&t?[...e.map(o=>({...o,id:`prev-repeated-item-${o.id}`,isClonedItem:!0})),...e,...e.map(o=>({...o,id:`next-repeated-item-${o.id}`,isClonedItem:!0}))]:e,{useListenToCustomEvent:Ee,emitEvent:z}=yt();function te(o){N.current&&(E.current||W({type:"next",toIndex:o,actionType:"click"}))}function re(o){N.current&&(D.current||W({type:"prev",toIndex:o,actionType:"click"}))}function W({type:o,shouldAnimate:d=!0,toIndex:k,actionType:S}){var xe,Te;const m=X(),A=!d;D.current=!1,E.current=!1;let C=V.value.get(),g=0;if(o==="next"&&c!=="freeScroll"&&(l.current+=1),o==="prev"&&c!=="freeScroll"&&(l.current===0?l.current=e.length-1:l.current-=1),k!==void 0&&(l.current=k),c!=="freeScroll"&&o==="next"){const x=ne(t?m*(e.length*2):0);g=-(l.current*m),x-Math.abs(g)<m/1.2&&c==="fluid"&&!t&&(g=-x),!t&&Math.abs(g)>=x&&(E.current=!0,g=-x),t&&l.current===e.length&&(l.current=0,C=C+m*e.length,g=0)}if(c!=="freeScroll"&&o==="prev"&&(g=-(l.current*m),l.current===e.length-1&&(C=C-e.length*m),!t&&g>=0&&(D.current=!0,g=0)),c==="freeScroll"&&o==="next"){const x=w.current[a==="x"?"scrollLeft":"scrollTop"],j=a==="x"?w.current.scrollWidth-w.current.clientWidth:w.current.scrollHeight-w.current.clientHeight;C=x,g=x+m,(g>j||j-g<80)&&(g=j,E.current=!0)}if(c==="freeScroll"&&o==="prev"){const x=w.current[a==="x"?"scrollLeft":"scrollTop"];C=x,g=x-m,g<=0&&(g=0,E.current=!0)}G.current=g,z(S==="resize"?{eventName:"onResize",sliceActionType:S,slideDirection:o,currentItem:{index:l.current,id:((xe=e.at(l.current))==null?void 0:xe.id)??"",startReached:D.current,endReached:E.current}}:{eventName:"onSlideStartChange",sliceActionType:S,slideDirection:o,nextItem:{index:l.current,id:((Te=e.at(l.current))==null?void 0:Te.id)??"",startReached:D.current,endReached:E.current}}),ee.start({immediate:A,from:{value:C},to:{value:g},onRest({finished:x}){var j;x&&c==="fixed"&&z({eventName:"onSlideChangeComplete",sliceActionType:S,slideDirection:o,currentItem:{index:l.current,id:((j=e.at(l.current))==null?void 0:j.id)??"",startReached:D.current,endReached:E.current}}),x&&c==="fluid"&&z({eventName:"onSlideChangeComplete",sliceActionType:S,slideDirection:o,currentItem:{index:0,id:"",startReached:D.current,endReached:E.current}})}})}function X(){const o=w.current.children[0];let d=0;return d=o.getBoundingClientRect()[a==="x"?"width":"height"]+i,d}function ne(o){const d=w.current;return d[a==="x"?"scrollWidth":"scrollHeight"]-d.getBoundingClientRect()[a==="x"?"width":"height"]-o}function wt(){let o=0;const d=getComputedStyle(document.documentElement).getPropertyValue(`--${n}-start-end-gutter`);return d.includes("px")&&(o=Number(d.replace("px",""))),{totalStartEndGutterCssVar:o}}y.useEffect(()=>{function o(S,m){switch(S){case"start":return 0;case"middle-start":return Math.floor((m-1)*.25);case"center":return Math.floor((m-1)*.5);case"middle-end":return Math.floor((m-1)*.75);case"end":return m-1;default:return 0}}function d(S){if($.current){const{totalStartEndGutterCssVar:m}=wt();let A=0;t&&(A=X()*e.length),A-=X()*o(p,s),A-=m/2,$.current.style.setProperty(`--${n}-offset-modifier`,`${-A}px`),R(!0),S&&S()}}function k(){d(),W({type:"next",toIndex:l.current,shouldAnimate:!1,actionType:"resize"})}if(r&&(B.current=X()/4),r&&c==="fixed")return d(_),window.addEventListener("resize",k),()=>{window.removeEventListener("resize",k)}},[r,t,n,a,i,p,c]);const Se=f&&c!=="freeScroll",Et=vt(o=>{if(!N.current)return;const d=o.dragging,k=o.offset[a==="x"?0:1],S=o.movement[a==="x"?0:1],m=S>B.current,A=S<-B.current,C=o.velocity;d&&(z({...o,eventName:"onDrag",slideActionType:"drag"}),ee.start({value:k,immediate:!0,config:{velocity:C}}),I&&(m||A)&&o.cancel()),o.last&&(m?W({actionType:"drag",type:"prev"}):A?W({actionType:"drag",type:"next"}):ee.start({value:G.current,config:{velocity:C}}))},{enabled:Se,axis:a,rubberband:!t,...t?{}:{bounds:()=>({right:0,left:-ne(0),top:-ne(0),bottom:0})},from:()=>[V.value.get(),V.value.get()]});return{carouselFragment:P.jsxs("div",{ref:$,className:"ReactSpringCarouselContainer","data-part":"Container","data-part-internal":`${n}-Container`,children:[P.jsx("style",{dangerouslySetInnerHTML:{__html:`
|
|
2
2
|
:root {
|
|
3
3
|
--${n}-start-end-gutter: ${u*2}px;
|
|
4
4
|
--${n}-gutter: ${i}px;
|
|
@@ -29,10 +29,10 @@
|
|
|
29
29
|
gap: var(--${n}-gutter);
|
|
30
30
|
transform: translate3d(var(--${n}-scroll-x-value), var(--${n}-scroll-y-value), 0px);
|
|
31
31
|
overflow-x: ${c==="freeScroll"?"auto":"visible"};
|
|
32
|
-
touch-action: ${
|
|
32
|
+
touch-action: ${Se?a==="x"?"pan-y":"pan-x":"auto"};
|
|
33
33
|
}
|
|
34
34
|
[data-part-internal="${n}-Item"] {
|
|
35
35
|
display: flex;
|
|
36
36
|
flex: ${c==="fixed"?`1 0 calc(100% / var(--${n}-items-per-slide) - calc(var(--${n}-gutter) * (var(--${n}-items-per-slide) - 1)) / var(--${n}-items-per-slide) - calc(var(--${n}-start-end-gutter) / var(--${n}-items-per-slide)))`:"1"};
|
|
37
37
|
}
|
|
38
|
-
`}}),P.jsx("div",{ref:w,className:"ReactSpringCarouselTrack","data-part":"Track","data-part-internal":`${n}-Track`,...
|
|
38
|
+
`}}),P.jsx("div",{ref:w,className:"ReactSpringCarouselTrack","data-part":"Track","data-part-internal":`${n}-Track`,...Et(),onScroll:()=>{D.current=!1,E.current=!1},...c==="freeScroll"?{onWheel(){D.current=!1,E.current=!1,V.value.stop()}}:{},children:bt.map((o,d)=>P.jsx("div",{className:"ReactSpringCarouselItem","data-part":"Item","data-part-internal":`${n}-Item`,"data-id":o.id,children:typeof o.renderItem=="function"?o.renderItem({useListenToCustomEvent:Ee,index:d,isClonedItem:!!o.isClonedItem}):o.renderItem},`${o.id}-${d}`))})]}),useListenToCustomEvent:Ee,slideToNextItem:()=>te(),slideToPrevItem:()=>re(),slideToItem:o=>{if(typeof o=="number"){if(!e[o]){console.warn(`The item you're trying to slide doesn't exist. index: ${o}`);return}o>l.current?te(o):re(o)}if(typeof o=="string"){const d=e.findIndex(k=>k.id===o);if(d<0){console.warn(`The item you're trying to slide doesn't exist. id: ${o}`);return}d>l.current?te(d):re(d)}}}}O.useSpringCarousel=_t,Object.defineProperty(O,Symbol.toStringTag,{value:"Module"})});
|