react-spring-carousel 3.0.0-beta-2.0.82 → 3.0.0-beta-2.0.84
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 +113 -113
- package/dist/index.umd.js +2 -2
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -4,7 +4,7 @@ import Q, { useRef as P, useEffect as B, useState as Vt } from "react";
|
|
|
4
4
|
function Rt(e, t, r) {
|
|
5
5
|
return Math.max(t, Math.min(e, r));
|
|
6
6
|
}
|
|
7
|
-
const
|
|
7
|
+
const _ = {
|
|
8
8
|
toVector(e, t) {
|
|
9
9
|
return e === void 0 && (e = t), Array.isArray(e) ? e : [e, e];
|
|
10
10
|
},
|
|
@@ -45,7 +45,7 @@ function Ut(e) {
|
|
|
45
45
|
var t = Bt(e, "string");
|
|
46
46
|
return typeof t == "symbol" ? t : String(t);
|
|
47
47
|
}
|
|
48
|
-
function
|
|
48
|
+
function k(e, t, r) {
|
|
49
49
|
return t = Ut(t), t in e ? Object.defineProperty(e, t, {
|
|
50
50
|
value: r,
|
|
51
51
|
enumerable: !0,
|
|
@@ -67,14 +67,14 @@ function p(e) {
|
|
|
67
67
|
for (var t = 1; t < arguments.length; t++) {
|
|
68
68
|
var r = arguments[t] != null ? arguments[t] : {};
|
|
69
69
|
t % 2 ? ft(Object(r), !0).forEach(function(n) {
|
|
70
|
-
|
|
70
|
+
k(e, n, r[n]);
|
|
71
71
|
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(r)) : ft(Object(r)).forEach(function(n) {
|
|
72
72
|
Object.defineProperty(e, n, Object.getOwnPropertyDescriptor(r, n));
|
|
73
73
|
});
|
|
74
74
|
}
|
|
75
75
|
return e;
|
|
76
76
|
}
|
|
77
|
-
const
|
|
77
|
+
const xt = {
|
|
78
78
|
pointer: {
|
|
79
79
|
start: "down",
|
|
80
80
|
change: "move",
|
|
@@ -104,7 +104,7 @@ function Gt(e = !1, t) {
|
|
|
104
104
|
return e && !Kt.includes(t);
|
|
105
105
|
}
|
|
106
106
|
function zt(e, t = "", r = !1) {
|
|
107
|
-
const n =
|
|
107
|
+
const n = xt[e], s = n && n[t] || t;
|
|
108
108
|
return "on" + dt(e) + dt(s) + (Gt(r, s) ? "Capture" : "");
|
|
109
109
|
}
|
|
110
110
|
const Wt = ["gotpointercapture", "lostpointercapture"];
|
|
@@ -120,13 +120,13 @@ function Yt(e) {
|
|
|
120
120
|
};
|
|
121
121
|
}
|
|
122
122
|
function Ft(e, t = "") {
|
|
123
|
-
const r =
|
|
123
|
+
const r = xt[e], n = r && r[t] || t;
|
|
124
124
|
return e + n;
|
|
125
125
|
}
|
|
126
126
|
function Y(e) {
|
|
127
127
|
return "touches" in e;
|
|
128
128
|
}
|
|
129
|
-
function
|
|
129
|
+
function Et(e) {
|
|
130
130
|
return Y(e) ? "touch" : "pointerType" in e ? e.pointerType : "mouse";
|
|
131
131
|
}
|
|
132
132
|
function Ht(e) {
|
|
@@ -246,7 +246,7 @@ class ee {
|
|
|
246
246
|
let o = 0;
|
|
247
247
|
if (t && (r.event = t, n.preventDefault && t.cancelable && r.event.preventDefault(), r.type = t.type, s.touches = this.ctrl.pointerIds.size || this.ctrl.touchIds.size, s.locked = !!document.pointerLockElement, Object.assign(s, Jt(t)), s.down = s.pressed = s.buttons % 2 === 1 || s.touches > 0, o = t.timeStamp - r.timeStamp, r.timeStamp = t.timeStamp, r.elapsedTime = r.timeStamp - r.startTime), r._active) {
|
|
248
248
|
const f = r._delta.map(Math.abs);
|
|
249
|
-
|
|
249
|
+
_.addTo(r._distance, f);
|
|
250
250
|
}
|
|
251
251
|
this.axisIntent && this.axisIntent(t);
|
|
252
252
|
const [a, c] = r._movement, [l, h] = n.threshold, {
|
|
@@ -261,15 +261,15 @@ class ee {
|
|
|
261
261
|
} else
|
|
262
262
|
m[0] = u[0] !== !1 ? a - u[0] : 0, m[1] = u[1] !== !1 ? c - u[1] : 0;
|
|
263
263
|
this.restrictToAxis && !r._blocked && this.restrictToAxis(m);
|
|
264
|
-
const $ = r.offset,
|
|
265
|
-
|
|
266
|
-
const [
|
|
267
|
-
r.overflow = [
|
|
264
|
+
const $ = r.offset, w = r._active && !r._blocked || r.active;
|
|
265
|
+
w && (r.first = r._active && !r.active, r.last = !r._active && r.active, r.active = s[this.ingKey] = r._active, t && (r.first && ("bounds" in n && (r._bounds = W(n.bounds, r)), this.setup && this.setup()), r.movement = m, this.computeOffset()));
|
|
266
|
+
const [S, y] = r.offset, [[A, x], [C, D]] = r._bounds;
|
|
267
|
+
r.overflow = [S < A ? -1 : S > x ? 1 : 0, y < C ? -1 : y > D ? 1 : 0], r._movementBound[0] = r.overflow[0] ? r._movementBound[0] === !1 ? r._movement[0] : r._movementBound[0] : !1, r._movementBound[1] = r.overflow[1] ? r._movementBound[1] === !1 ? r._movement[1] : r._movementBound[1] : !1;
|
|
268
268
|
const j = r._active ? n.rubberband || [0, 0] : [0, 0];
|
|
269
|
-
if (r.offset = jt(r._bounds, r.offset, j), r.delta =
|
|
270
|
-
r.delta =
|
|
269
|
+
if (r.offset = jt(r._bounds, r.offset, j), r.delta = _.sub(r.offset, $), this.computeMovement(), w && (!r.last || o > te)) {
|
|
270
|
+
r.delta = _.sub(r.offset, $);
|
|
271
271
|
const f = r.delta.map(Math.abs);
|
|
272
|
-
|
|
272
|
+
_.addTo(r.distance, f), r.direction = r.delta.map(Math.sign), r._direction = r._delta.map(Math.sign), !r.first && o > 0 && (r.velocity = [f[0] / o, f[1] / o], r.timeDelta = o);
|
|
273
273
|
}
|
|
274
274
|
}
|
|
275
275
|
emit() {
|
|
@@ -293,7 +293,7 @@ function re([e, t], r) {
|
|
|
293
293
|
}
|
|
294
294
|
class ne extends ee {
|
|
295
295
|
constructor(...t) {
|
|
296
|
-
super(...t),
|
|
296
|
+
super(...t), k(this, "aliasKey", "xy");
|
|
297
297
|
}
|
|
298
298
|
reset() {
|
|
299
299
|
super.reset(), this.state.axis = void 0;
|
|
@@ -302,15 +302,15 @@ class ne extends ee {
|
|
|
302
302
|
this.state.offset = [0, 0], this.state.lastOffset = [0, 0];
|
|
303
303
|
}
|
|
304
304
|
computeOffset() {
|
|
305
|
-
this.state.offset =
|
|
305
|
+
this.state.offset = _.add(this.state.lastOffset, this.state.movement);
|
|
306
306
|
}
|
|
307
307
|
computeMovement() {
|
|
308
|
-
this.state.movement =
|
|
308
|
+
this.state.movement = _.sub(this.state.offset, this.state.lastOffset);
|
|
309
309
|
}
|
|
310
310
|
axisIntent(t) {
|
|
311
311
|
const r = this.state, n = this.config;
|
|
312
312
|
if (!r.axis && t) {
|
|
313
|
-
const s = typeof n.axisThreshold == "object" ? n.axisThreshold[
|
|
313
|
+
const s = typeof n.axisThreshold == "object" ? n.axisThreshold[Et(t)] : n.axisThreshold;
|
|
314
314
|
r.axis = re(r._movement, s);
|
|
315
315
|
}
|
|
316
316
|
r._blocked = (n.lockDirection || !!n.axis) && !r.axis || !!n.axis && n.axis !== r.axis;
|
|
@@ -347,12 +347,12 @@ const mt = (e) => e, gt = 0.15, nt = {
|
|
|
347
347
|
case !1:
|
|
348
348
|
return [0, 0];
|
|
349
349
|
default:
|
|
350
|
-
return
|
|
350
|
+
return _.toVector(e);
|
|
351
351
|
}
|
|
352
352
|
},
|
|
353
353
|
from(e) {
|
|
354
354
|
if (typeof e == "function") return e;
|
|
355
|
-
if (e != null) return
|
|
355
|
+
if (e != null) return _.toVector(e);
|
|
356
356
|
},
|
|
357
357
|
transform(e, t, r) {
|
|
358
358
|
const n = e || r.shared.transform;
|
|
@@ -366,7 +366,7 @@ const mt = (e) => e, gt = 0.15, nt = {
|
|
|
366
366
|
return n || mt;
|
|
367
367
|
},
|
|
368
368
|
threshold(e) {
|
|
369
|
-
return
|
|
369
|
+
return _.toVector(e, 0);
|
|
370
370
|
}
|
|
371
371
|
};
|
|
372
372
|
process.env.NODE_ENV === "development" && Object.assign(nt, {
|
|
@@ -418,7 +418,7 @@ const se = 0, U = p(p({}, nt), {}, {
|
|
|
418
418
|
};
|
|
419
419
|
class ie extends ne {
|
|
420
420
|
constructor(...t) {
|
|
421
|
-
super(...t),
|
|
421
|
+
super(...t), k(this, "ingKey", "dragging");
|
|
422
422
|
}
|
|
423
423
|
reset() {
|
|
424
424
|
super.reset();
|
|
@@ -453,7 +453,7 @@ class ie extends ne {
|
|
|
453
453
|
const r = this.config, n = this.state;
|
|
454
454
|
if (t.buttons != null && (Array.isArray(r.pointerButtons) ? !r.pointerButtons.includes(t.buttons) : r.pointerButtons !== -1 && r.pointerButtons !== t.buttons)) return;
|
|
455
455
|
const s = this.ctrl.setEventIds(t);
|
|
456
|
-
r.pointerCapture && t.target.setPointerCapture(t.pointerId), !(s && s.size > 1 && n._pointerActive) && (this.start(t), this.setupPointer(t), n._pointerId = Z(t), n._pointerActive = !0, this.computeValues(ht(t)), this.computeInitial(), r.preventScrollAxis &&
|
|
456
|
+
r.pointerCapture && t.target.setPointerCapture(t.pointerId), !(s && s.size > 1 && n._pointerActive) && (this.start(t), this.setupPointer(t), n._pointerId = Z(t), n._pointerActive = !0, this.computeValues(ht(t)), this.computeInitial(), r.preventScrollAxis && Et(t) !== "mouse" ? (n._active = !1, this.setupScrollPrevention(t)) : r.delay > 0 ? (this.setupDelayTrigger(t), r.triggerAllEvents && (this.compute(t), this.emit())) : this.startPointerDrag(t));
|
|
457
457
|
}
|
|
458
458
|
startPointerDrag(t) {
|
|
459
459
|
const r = this.state;
|
|
@@ -465,7 +465,7 @@ class ie extends ne {
|
|
|
465
465
|
const s = Z(t);
|
|
466
466
|
if (r._pointerId !== void 0 && s !== r._pointerId) return;
|
|
467
467
|
const o = ht(t);
|
|
468
|
-
if (document.pointerLockElement === t.target ? r._delta = [t.movementX, t.movementY] : (r._delta =
|
|
468
|
+
if (document.pointerLockElement === t.target ? r._delta = [t.movementX, t.movementY] : (r._delta = _.sub(o, r._values), this.computeValues(o)), _.addTo(r._movement, r._delta), this.compute(t), r._delayed && r.intentional) {
|
|
469
469
|
this.timeoutStore.remove("dragDelay"), r.active = !1, this.startPointerDrag(t);
|
|
470
470
|
return;
|
|
471
471
|
}
|
|
@@ -498,10 +498,10 @@ class ie extends ne {
|
|
|
498
498
|
if (r.tap = o <= n.tapsThreshold && a <= n.tapsThreshold, r.tap && n.filterTaps)
|
|
499
499
|
r._force = !0;
|
|
500
500
|
else {
|
|
501
|
-
const [c, l] = r._delta, [h, u] = r._movement, [v, m] = n.swipe.velocity, [$,
|
|
502
|
-
if (r.elapsedTime <
|
|
503
|
-
const
|
|
504
|
-
|
|
501
|
+
const [c, l] = r._delta, [h, u] = r._movement, [v, m] = n.swipe.velocity, [$, w] = n.swipe.distance, S = n.swipe.duration;
|
|
502
|
+
if (r.elapsedTime < S) {
|
|
503
|
+
const y = Math.abs(c / r.timeDelta), A = Math.abs(l / r.timeDelta);
|
|
504
|
+
y > v && Math.abs(h) > $ && (r.swipe[0] = Math.sign(c)), A > m && Math.abs(u) > w && (r.swipe[1] = Math.sign(l));
|
|
505
505
|
}
|
|
506
506
|
}
|
|
507
507
|
this.emit();
|
|
@@ -543,7 +543,7 @@ class ie extends ne {
|
|
|
543
543
|
const r = vt[t.key];
|
|
544
544
|
if (r) {
|
|
545
545
|
const n = this.state, s = t.shiftKey ? 10 : t.altKey ? 0.1 : 1;
|
|
546
|
-
this.start(t), n._delta = r(this.config.keyboardDisplacement, s), n._keyboardActive = !0,
|
|
546
|
+
this.start(t), n._delta = r(this.config.keyboardDisplacement, s), n._keyboardActive = !0, _.addTo(n._movement, n._delta), this.compute(t), this.emit();
|
|
547
547
|
}
|
|
548
548
|
}
|
|
549
549
|
keyUp(t) {
|
|
@@ -621,7 +621,7 @@ const O = {
|
|
|
621
621
|
tapsThreshold: n = 3,
|
|
622
622
|
axis: s = void 0
|
|
623
623
|
}) {
|
|
624
|
-
const o =
|
|
624
|
+
const o = _.toVector(e, r ? n : s ? 1 : 0);
|
|
625
625
|
return this.filterTaps = r, this.tapsThreshold = n, o;
|
|
626
626
|
},
|
|
627
627
|
swipe({
|
|
@@ -630,8 +630,8 @@ const O = {
|
|
|
630
630
|
duration: r = me
|
|
631
631
|
} = {}) {
|
|
632
632
|
return {
|
|
633
|
-
velocity: this.transform(
|
|
634
|
-
distance: this.transform(
|
|
633
|
+
velocity: this.transform(_.toVector(e)),
|
|
634
|
+
distance: this.transform(_.toVector(t)),
|
|
635
635
|
duration: r
|
|
636
636
|
};
|
|
637
637
|
},
|
|
@@ -713,7 +713,7 @@ p(p({}, nt), {}, {
|
|
|
713
713
|
return typeof r != "function" && typeof n != "function" ? [s(), o()] : (a) => [s(a), o(a)];
|
|
714
714
|
},
|
|
715
715
|
threshold(e, t, r) {
|
|
716
|
-
return this.lockDirection = r.axis === "lock",
|
|
716
|
+
return this.lockDirection = r.axis === "lock", _.toVector(e, this.lockDirection ? [0.1, 3] : 0);
|
|
717
717
|
},
|
|
718
718
|
modifierKey(e) {
|
|
719
719
|
return e === void 0 ? "ctrlKey" : e;
|
|
@@ -777,7 +777,7 @@ const we = {
|
|
|
777
777
|
transform(e) {
|
|
778
778
|
return e;
|
|
779
779
|
}
|
|
780
|
-
},
|
|
780
|
+
}, xe = ["target", "eventOptions", "window", "enabled", "transform"];
|
|
781
781
|
function z(e = {}, t) {
|
|
782
782
|
const r = {};
|
|
783
783
|
for (const [n, s] of Object.entries(t))
|
|
@@ -798,14 +798,14 @@ function z(e = {}, t) {
|
|
|
798
798
|
}
|
|
799
799
|
return r;
|
|
800
800
|
}
|
|
801
|
-
function
|
|
801
|
+
function Ee(e, t, r = {}) {
|
|
802
802
|
const n = e, {
|
|
803
803
|
target: s,
|
|
804
804
|
eventOptions: o,
|
|
805
805
|
window: a,
|
|
806
806
|
enabled: c,
|
|
807
807
|
transform: l
|
|
808
|
-
} = n, h = _e(n,
|
|
808
|
+
} = n, h = _e(n, xe);
|
|
809
809
|
if (r.shared = z({
|
|
810
810
|
target: s,
|
|
811
811
|
eventOptions: o,
|
|
@@ -834,7 +834,7 @@ function xe(e, t, r = {}) {
|
|
|
834
834
|
}
|
|
835
835
|
class Ct {
|
|
836
836
|
constructor(t, r) {
|
|
837
|
-
|
|
837
|
+
k(this, "_listeners", /* @__PURE__ */ new Set()), this._ctrl = t, this._gestureKey = r;
|
|
838
838
|
}
|
|
839
839
|
add(t, r, n, s, o) {
|
|
840
840
|
const a = this._listeners, c = Ft(r, n), l = this._gestureKey ? this._ctrl.config[this._gestureKey].eventOptions : {}, h = p(p({}, l), o);
|
|
@@ -850,7 +850,7 @@ class Ct {
|
|
|
850
850
|
}
|
|
851
851
|
class Te {
|
|
852
852
|
constructor() {
|
|
853
|
-
|
|
853
|
+
k(this, "_timeouts", /* @__PURE__ */ new Map());
|
|
854
854
|
}
|
|
855
855
|
add(t, r, n = 140, ...s) {
|
|
856
856
|
this.remove(t), this._timeouts.set(t, window.setTimeout(r, n, ...s));
|
|
@@ -865,7 +865,7 @@ class Te {
|
|
|
865
865
|
}
|
|
866
866
|
class Se {
|
|
867
867
|
constructor(t) {
|
|
868
|
-
|
|
868
|
+
k(this, "gestures", /* @__PURE__ */ new Set()), k(this, "_targetEventStore", new Ct(this)), k(this, "gestureEventStores", {}), k(this, "gestureTimeoutStores", {}), k(this, "handlers", {}), k(this, "config", {}), k(this, "pointerIds", /* @__PURE__ */ new Set()), k(this, "touchIds", /* @__PURE__ */ new Set()), k(this, "state", {
|
|
869
869
|
shared: {
|
|
870
870
|
shiftKey: !1,
|
|
871
871
|
metaKey: !1,
|
|
@@ -884,7 +884,7 @@ class Se {
|
|
|
884
884
|
this.handlers = t, this.nativeHandlers = r;
|
|
885
885
|
}
|
|
886
886
|
applyConfig(t, r) {
|
|
887
|
-
this.config =
|
|
887
|
+
this.config = Ee(t, r, this.config);
|
|
888
888
|
}
|
|
889
889
|
clean() {
|
|
890
890
|
this._targetEventStore.clean();
|
|
@@ -1003,11 +1003,11 @@ function Me({
|
|
|
1003
1003
|
onInit: u,
|
|
1004
1004
|
initialActiveItem: v = 0
|
|
1005
1005
|
}) {
|
|
1006
|
-
const [m, $] = Vt(!1),
|
|
1006
|
+
const [m, $] = Vt(!1), w = P(e), S = P(null), y = P(null), A = P(0), x = P(0), C = P(!r), D = P(!1), j = P(0), f = P(0), L = Mt(), F = wt({
|
|
1007
1007
|
value: 0,
|
|
1008
1008
|
ref: L,
|
|
1009
1009
|
onChange({ value: i }) {
|
|
1010
|
-
|
|
1010
|
+
y.current.style.transform = `translate3d(calc(${i.value}px + var(--${n}-offset-modifier)), 0px, 0px)`;
|
|
1011
1011
|
}
|
|
1012
1012
|
}), Dt = r ? [
|
|
1013
1013
|
...t.map((i) => ({
|
|
@@ -1027,23 +1027,23 @@ function Me({
|
|
|
1027
1027
|
return i;
|
|
1028
1028
|
}
|
|
1029
1029
|
function Pt() {
|
|
1030
|
-
if (
|
|
1030
|
+
if (S.current) {
|
|
1031
1031
|
const d = window.getComputedStyle(
|
|
1032
|
-
|
|
1032
|
+
S.current
|
|
1033
1033
|
).getPropertyValue(`--${n}-items-per-slide`).trim();
|
|
1034
1034
|
return Number(d) || 1;
|
|
1035
1035
|
}
|
|
1036
1036
|
return 1;
|
|
1037
1037
|
}
|
|
1038
1038
|
function H(i) {
|
|
1039
|
-
|
|
1039
|
+
w.current && (D.current || N({
|
|
1040
1040
|
type: "next",
|
|
1041
1041
|
toIndex: i,
|
|
1042
1042
|
actionType: "click"
|
|
1043
1043
|
}));
|
|
1044
1044
|
}
|
|
1045
1045
|
function X(i) {
|
|
1046
|
-
|
|
1046
|
+
w.current && (C.current || N({
|
|
1047
1047
|
type: "prev",
|
|
1048
1048
|
toIndex: i,
|
|
1049
1049
|
actionType: "click"
|
|
@@ -1052,93 +1052,93 @@ function Me({
|
|
|
1052
1052
|
function N({
|
|
1053
1053
|
type: i,
|
|
1054
1054
|
shouldAnimate: d = !0,
|
|
1055
|
-
toIndex:
|
|
1056
|
-
actionType:
|
|
1055
|
+
toIndex: b,
|
|
1056
|
+
actionType: E
|
|
1057
1057
|
}) {
|
|
1058
1058
|
var M, at;
|
|
1059
|
-
const
|
|
1060
|
-
|
|
1061
|
-
let g = F.value.get(),
|
|
1062
|
-
if (i === "next" && (f.current += 1), i === "prev" && (f.current === 0 ? f.current = t.length - 1 : f.current -= 1),
|
|
1059
|
+
const T = !d;
|
|
1060
|
+
C.current = !1, D.current = !1;
|
|
1061
|
+
let g = F.value.get(), I = 0;
|
|
1062
|
+
if (i === "next" && (f.current += 1), i === "prev" && (f.current === 0 ? f.current = t.length - 1 : f.current -= 1), b !== void 0 && (f.current = b), i === "next") {
|
|
1063
1063
|
const V = q(
|
|
1064
|
-
r ?
|
|
1064
|
+
r ? x.current * (t.length * 2) : 0
|
|
1065
1065
|
);
|
|
1066
|
-
|
|
1066
|
+
I = -(f.current * x.current), r && f.current === t.length && (f.current = 0, g = g + x.current * t.length, I = 0), !r && (Math.abs(I) >= V || f.current === t.length - 1) && (D.current = !0, I = -V);
|
|
1067
1067
|
}
|
|
1068
|
-
i === "prev" && (
|
|
1068
|
+
i === "prev" && (I = -(f.current * x.current), f.current === t.length - 1 && (g = g - t.length * x.current), !r && I >= 0 && (C.current = !0, I = 0)), A.current = I, E === "resize" ? (I = -(f.current * x.current), G({
|
|
1069
1069
|
eventName: "onResize",
|
|
1070
|
-
sliceActionType:
|
|
1070
|
+
sliceActionType: E,
|
|
1071
1071
|
slideDirection: i,
|
|
1072
1072
|
currentItem: {
|
|
1073
1073
|
index: f.current,
|
|
1074
1074
|
id: ((M = t.at(f.current)) == null ? void 0 : M.id) ?? "",
|
|
1075
|
-
startReached:
|
|
1076
|
-
endReached:
|
|
1075
|
+
startReached: C.current,
|
|
1076
|
+
endReached: D.current
|
|
1077
1077
|
}
|
|
1078
1078
|
})) : G({
|
|
1079
1079
|
eventName: "onSlideStartChange",
|
|
1080
|
-
sliceActionType:
|
|
1080
|
+
sliceActionType: E,
|
|
1081
1081
|
slideDirection: i,
|
|
1082
1082
|
nextItem: {
|
|
1083
1083
|
index: f.current,
|
|
1084
1084
|
id: ((at = t.at(f.current)) == null ? void 0 : at.id) ?? "",
|
|
1085
|
-
startReached:
|
|
1086
|
-
endReached:
|
|
1085
|
+
startReached: C.current,
|
|
1086
|
+
endReached: D.current
|
|
1087
1087
|
}
|
|
1088
|
-
}), L.start({
|
|
1089
|
-
immediate:
|
|
1088
|
+
}), T && (y.current.style.transform = `translate3d(calc(${I}px + var(--${n}-offset-modifier)), 0px, 0px)`), L.start({
|
|
1089
|
+
immediate: T,
|
|
1090
1090
|
from: {
|
|
1091
1091
|
value: g
|
|
1092
1092
|
},
|
|
1093
1093
|
to: {
|
|
1094
|
-
value:
|
|
1094
|
+
value: I
|
|
1095
1095
|
},
|
|
1096
1096
|
onChange({ value: V }) {
|
|
1097
|
-
|
|
1097
|
+
y.current.style.transform = `translate3d(calc(${V.value}px + var(--${n}-offset-modifier)), 0px, 0px)`;
|
|
1098
1098
|
},
|
|
1099
1099
|
onRest({ finished: V }) {
|
|
1100
1100
|
var ct;
|
|
1101
1101
|
V && G({
|
|
1102
1102
|
eventName: "onSlideChangeComplete",
|
|
1103
|
-
sliceActionType:
|
|
1103
|
+
sliceActionType: E,
|
|
1104
1104
|
slideDirection: i,
|
|
1105
1105
|
currentItem: {
|
|
1106
1106
|
index: f.current,
|
|
1107
1107
|
id: ((ct = t.at(f.current)) == null ? void 0 : ct.id) ?? "",
|
|
1108
|
-
startReached:
|
|
1109
|
-
endReached:
|
|
1108
|
+
startReached: C.current,
|
|
1109
|
+
endReached: D.current
|
|
1110
1110
|
}
|
|
1111
1111
|
});
|
|
1112
1112
|
}
|
|
1113
1113
|
});
|
|
1114
1114
|
}
|
|
1115
1115
|
function Ot() {
|
|
1116
|
-
const i =
|
|
1116
|
+
const i = y.current;
|
|
1117
1117
|
let d = 0;
|
|
1118
1118
|
return d = i.getBoundingClientRect()[a === "x" ? "width" : "height"] + $t(), d;
|
|
1119
1119
|
}
|
|
1120
1120
|
function q(i) {
|
|
1121
|
-
const d =
|
|
1121
|
+
const d = y.current;
|
|
1122
1122
|
return d[a === "x" ? "scrollWidth" : "scrollHeight"] - d.getBoundingClientRect()[a === "x" ? "width" : "height"] - i;
|
|
1123
1123
|
}
|
|
1124
1124
|
function it() {
|
|
1125
1125
|
let i = 0, d = 0;
|
|
1126
|
-
if (
|
|
1127
|
-
const
|
|
1128
|
-
|
|
1129
|
-
),
|
|
1130
|
-
|
|
1131
|
-
|
|
1126
|
+
if (S.current) {
|
|
1127
|
+
const b = window.getComputedStyle(
|
|
1128
|
+
S.current
|
|
1129
|
+
), E = b.getPropertyValue(`--${n}-start-end-gutter`).trim();
|
|
1130
|
+
E.includes("px") && (i = Number(
|
|
1131
|
+
E.replace("px", "")
|
|
1132
1132
|
));
|
|
1133
|
-
const
|
|
1134
|
-
|
|
1133
|
+
const T = b.getPropertyValue(`--${n}-gutter`).trim();
|
|
1134
|
+
T.includes("px") && (d = Number(T.replace("px", "")));
|
|
1135
1135
|
}
|
|
1136
1136
|
return { totalStartEndGutterCssVar: i, totalGutterCssVar: d };
|
|
1137
1137
|
}
|
|
1138
1138
|
B(() => {
|
|
1139
|
-
function i(
|
|
1139
|
+
function i(T) {
|
|
1140
1140
|
const g = Pt();
|
|
1141
|
-
switch (
|
|
1141
|
+
switch (T) {
|
|
1142
1142
|
case "start":
|
|
1143
1143
|
return 0;
|
|
1144
1144
|
case "middle-start":
|
|
@@ -1154,19 +1154,19 @@ function Me({
|
|
|
1154
1154
|
}
|
|
1155
1155
|
}
|
|
1156
1156
|
function d() {
|
|
1157
|
-
|
|
1158
|
-
const { totalStartEndGutterCssVar:
|
|
1157
|
+
x.current = Ot(), j.current = x.current / 4;
|
|
1158
|
+
const { totalStartEndGutterCssVar: T } = it();
|
|
1159
1159
|
let g = 0;
|
|
1160
|
-
r && (g =
|
|
1160
|
+
r && (g = x.current * t.length), g -= x.current * i(c), g -= T / 2, S.current.style.setProperty(
|
|
1161
1161
|
`--${n}-offset-modifier`,
|
|
1162
1162
|
`${-g}px`
|
|
1163
1163
|
);
|
|
1164
1164
|
}
|
|
1165
|
-
function
|
|
1166
|
-
|
|
1165
|
+
function b(T) {
|
|
1166
|
+
S.current && (d(), $(!0), T && T());
|
|
1167
1167
|
}
|
|
1168
|
-
function
|
|
1169
|
-
|
|
1168
|
+
function E() {
|
|
1169
|
+
b(), N({
|
|
1170
1170
|
type: "resize",
|
|
1171
1171
|
toIndex: f.current,
|
|
1172
1172
|
shouldAnimate: !1,
|
|
@@ -1174,8 +1174,8 @@ function Me({
|
|
|
1174
1174
|
});
|
|
1175
1175
|
}
|
|
1176
1176
|
if (e)
|
|
1177
|
-
return
|
|
1178
|
-
window.removeEventListener("resize",
|
|
1177
|
+
return w.current = !0, b(u), window.addEventListener("resize", E), () => {
|
|
1178
|
+
window.removeEventListener("resize", E);
|
|
1179
1179
|
};
|
|
1180
1180
|
}, [e]), B(() => {
|
|
1181
1181
|
e && v !== f.current && N({
|
|
@@ -1187,23 +1187,23 @@ function Me({
|
|
|
1187
1187
|
}, [e, v]);
|
|
1188
1188
|
const ot = l, At = Ce(
|
|
1189
1189
|
(i) => {
|
|
1190
|
-
if (!
|
|
1190
|
+
if (!w.current)
|
|
1191
1191
|
return;
|
|
1192
|
-
const d = i.dragging,
|
|
1192
|
+
const d = i.dragging, b = i.offset[a === "x" ? 0 : 1], E = i.movement[a === "x" ? 0 : 1], T = E > j.current, g = E < -j.current, I = i.velocity;
|
|
1193
1193
|
d && (G({
|
|
1194
1194
|
...i,
|
|
1195
1195
|
eventName: "onDrag",
|
|
1196
1196
|
slideActionType: "drag"
|
|
1197
1197
|
}), L.start({
|
|
1198
|
-
value:
|
|
1198
|
+
value: b,
|
|
1199
1199
|
immediate: !0,
|
|
1200
1200
|
onChange({ value: M }) {
|
|
1201
|
-
|
|
1201
|
+
y.current.style.transform = `translate3d(calc(${M.value}px + var(--${n}-offset-modifier)), 0px, 0px)`;
|
|
1202
1202
|
},
|
|
1203
1203
|
config: {
|
|
1204
|
-
velocity:
|
|
1204
|
+
velocity: I
|
|
1205
1205
|
}
|
|
1206
|
-
}), h && (
|
|
1206
|
+
}), y.current.style.transform = `translate3d(calc(${b}px + var(--${n}-offset-modifier)), 0px, 0px)`, h && (T || g) && i.cancel()), i.last && (T ? (N({
|
|
1207
1207
|
actionType: "drag",
|
|
1208
1208
|
type: "prev"
|
|
1209
1209
|
}), i.cancel()) : g ? (N({
|
|
@@ -1212,10 +1212,10 @@ function Me({
|
|
|
1212
1212
|
}), i.cancel()) : (L.start({
|
|
1213
1213
|
value: A.current,
|
|
1214
1214
|
onChange({ value: M }) {
|
|
1215
|
-
|
|
1215
|
+
y.current.style.transform = `translate3d(calc(${M.value}px + var(--${n}-offset-modifier)), 0px, 0px)`;
|
|
1216
1216
|
},
|
|
1217
1217
|
config: {
|
|
1218
|
-
velocity:
|
|
1218
|
+
velocity: I
|
|
1219
1219
|
}
|
|
1220
1220
|
}), i.cancel()));
|
|
1221
1221
|
},
|
|
@@ -1235,14 +1235,14 @@ function Me({
|
|
|
1235
1235
|
}
|
|
1236
1236
|
);
|
|
1237
1237
|
function Lt(i) {
|
|
1238
|
-
var d,
|
|
1239
|
-
return typeof i == "number" ? f.current === i : ((d = t.find((
|
|
1238
|
+
var d, b;
|
|
1239
|
+
return typeof i == "number" ? f.current === i : ((d = t.find((E) => E.id === i)) == null ? void 0 : d.id) === ((b = t[f.current]) == null ? void 0 : b.id);
|
|
1240
1240
|
}
|
|
1241
1241
|
return {
|
|
1242
1242
|
carouselFragment: /* @__PURE__ */ Nt(
|
|
1243
1243
|
"div",
|
|
1244
1244
|
{
|
|
1245
|
-
ref:
|
|
1245
|
+
ref: S,
|
|
1246
1246
|
className: "ReactSpringCarouselContainer",
|
|
1247
1247
|
"data-part": "Container",
|
|
1248
1248
|
"data-part-internal": `${n}-Container`,
|
|
@@ -1309,12 +1309,12 @@ function Me({
|
|
|
1309
1309
|
/* @__PURE__ */ J(
|
|
1310
1310
|
"div",
|
|
1311
1311
|
{
|
|
1312
|
-
ref:
|
|
1312
|
+
ref: y,
|
|
1313
1313
|
className: "ReactSpringCarouselTrack",
|
|
1314
1314
|
"data-part": "Track",
|
|
1315
1315
|
"data-part-internal": `${n}-Track`,
|
|
1316
1316
|
onScroll: () => {
|
|
1317
|
-
|
|
1317
|
+
C.current = !1, D.current = !1;
|
|
1318
1318
|
},
|
|
1319
1319
|
children: Dt.map((i, d) => /* @__PURE__ */ J(
|
|
1320
1320
|
"div",
|
|
@@ -1351,7 +1351,7 @@ function Me({
|
|
|
1351
1351
|
i > f.current ? H(i) : X(i);
|
|
1352
1352
|
}
|
|
1353
1353
|
if (typeof i == "string") {
|
|
1354
|
-
const d = t.findIndex((
|
|
1354
|
+
const d = t.findIndex((b) => b.id === i);
|
|
1355
1355
|
if (d < 0) {
|
|
1356
1356
|
console.warn(
|
|
1357
1357
|
`The item you're trying to slide doesn't exist. id: ${i}`
|
|
@@ -1404,13 +1404,13 @@ function Ve({ container: e, onReach: t }) {
|
|
|
1404
1404
|
}
|
|
1405
1405
|
return B(() => {
|
|
1406
1406
|
function c() {
|
|
1407
|
-
var
|
|
1408
|
-
const $ = et(e.current),
|
|
1409
|
-
index:
|
|
1410
|
-
start: $ *
|
|
1411
|
-
end: $ * (
|
|
1412
|
-
})),
|
|
1413
|
-
(
|
|
1407
|
+
var x;
|
|
1408
|
+
const $ = et(e.current), w = ((x = [...e.current.children].at(0)) == null ? void 0 : x.getBoundingClientRect().width) || 0, S = Array(e.current.childElementCount).fill(0).map((C, D) => ({
|
|
1409
|
+
index: D,
|
|
1410
|
+
start: $ * D,
|
|
1411
|
+
end: $ * (D + 1)
|
|
1412
|
+
})), y = e.current.scrollLeft + w, A = S.find(
|
|
1413
|
+
(C) => y >= C.start && y < C.end
|
|
1414
1414
|
);
|
|
1415
1415
|
n.current = (A == null ? void 0 : A.index) || 0;
|
|
1416
1416
|
}
|
|
@@ -1418,8 +1418,8 @@ function Ve({ container: e, onReach: t }) {
|
|
|
1418
1418
|
s.stop();
|
|
1419
1419
|
}
|
|
1420
1420
|
function h($) {
|
|
1421
|
-
const
|
|
1422
|
-
|
|
1421
|
+
const w = $.target;
|
|
1422
|
+
w.scrollLeft === 0 ? (n.current = 0, r.current = "start", t && t("start")) : w.scrollLeft >= _t(w) ? (r.current = "end", t && t("end")) : r.current !== "idle" && (r.current = "idle", t && t("idle"));
|
|
1423
1423
|
}
|
|
1424
1424
|
let u, v = 0;
|
|
1425
1425
|
function m() {
|
package/dist/index.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(A,N){typeof exports=="object"&&typeof module<"u"?N(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"],N):(A=typeof globalThis<"u"?globalThis:A||self,N(A["react-spring-carousel"]={},A["react/jsx-runtime"],A["@react-spring/web"],A.React))})(this,function(A,N,H,m){"use strict";function Ce(t,e,r){return Math.max(e,Math.min(t,r))}const b={toVector(t,e){return t===void 0&&(t=e),Array.isArray(t)?t:[t,t]},add(t,e){return[t[0]+e[0],t[1]+e[1]]},sub(t,e){return[t[0]-e[0],t[1]-e[1]]},addTo(t,e){t[0]+=e[0],t[1]+=e[1]},subTo(t,e){t[0]-=e[0],t[1]-=e[1]}};function se(t,e,r){return e===0||Math.abs(e)===1/0?Math.pow(t,r*5):t*e*r/(e+r*t)}function ie(t,e,r,n=.15){return n===0?Ce(t,e,r):t<e?-se(e-t,r-e,n)+e:t>r?+se(t-r,r-e,n)+r:t}function De(t,[e,r],[n,s]){const[[o,a],[c,l]]=t;return[ie(e,o,a,n),ie(r,c,l,s)]}function $e(t,e){if(typeof t!="object"||t===null)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Pe(t){var e=$e(t,"string");return typeof e=="symbol"?e:String(e)}function S(t,e,r){return e=Pe(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function oe(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),r.push.apply(r,n)}return r}function p(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?oe(Object(r),!0).forEach(function(n){S(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):oe(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}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(t){return t?t[0].toUpperCase()+t.slice(1):""}const Oe=["enter","leave"];function Ae(t=!1,e){return t&&!Oe.includes(e)}function Le(t,e="",r=!1){const n=ae[t],s=n&&n[e]||e;return"on"+ce(t)+ce(s)+(Ae(r,s)?"Capture":"")}const Ne=["gotpointercapture","lostpointercapture"];function Me(t){let e=t.substring(2).toLowerCase();const r=!!~e.indexOf("passive");r&&(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:r}}function Ve(t,e=""){const r=ae[t],n=r&&r[e]||e;return t+n}function z(t){return"touches"in t}function ue(t){return z(t)?"touch":"pointerType"in t?t.pointerType:"mouse"}function je(t){return Array.from(t.touches).filter(e=>{var r,n;return e.target===t.currentTarget||((r=t.currentTarget)===null||r===void 0||(n=r.contains)===null||n===void 0?void 0:n.call(r,e.target))})}function Re(t){return t.type==="touchend"||t.type==="touchcancel"?t.changedTouches:t.targetTouches}function le(t){return z(t)?Re(t)[0]:t}function Be(t){return je(t).map(e=>e.identifier)}function X(t){const e=le(t);return z(t)?e.identifier:e.pointerId}function fe(t){const e=le(t);return[e.clientX,e.clientY]}function Ue(t){const e={};if("buttons"in t&&(e.buttons=t.buttons),"shiftKey"in t){const{shiftKey:r,altKey:n,metaKey:s,ctrlKey:o}=t;Object.assign(e,{shiftKey:r,altKey:n,metaKey:s,ctrlKey:o})}return e}function W(t,...e){return typeof t=="function"?t(...e):t}function Ke(){}function Ge(...t){return t.length===0?Ke:t.length===1?t[0]:function(){let e;for(const r of t)e=r.apply(this,arguments)||e;return e}}function de(t,e){return Object.assign({},e,t||{})}const ze=32;class We{constructor(e,r,n){this.ctrl=e,this.args=r,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:r,ingKey:n,args:s}=this;r[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 r=this.state,n=this.config;r._active||(this.reset(),this.computeInitial(),r._active=!0,r.target=e.target,r.currentTarget=e.currentTarget,r.lastOffset=n.from?W(n.from,r):r.offset,r.offset=r.lastOffset,r.startTime=r.timeStamp=e.timeStamp)}computeValues(e){const r=this.state;r._values=e,r.values=this.config.transform(e)}computeInitial(){const e=this.state;e._initial=e._values,e.initial=e.values}compute(e){const{state:r,config:n,shared:s}=this;r.args=this.args;let o=0;if(e&&(r.event=e,n.preventDefault&&e.cancelable&&r.event.preventDefault(),r.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,o=e.timeStamp-r.timeStamp,r.timeStamp=e.timeStamp,r.elapsedTime=r.timeStamp-r.startTime),r._active){const f=r._delta.map(Math.abs);b.addTo(r._distance,f)}this.axisIntent&&this.axisIntent(e);const[a,c]=r._movement,[l,h]=n.threshold,{_step:u,values:y}=r;if(n.hasCustomTransform?(u[0]===!1&&(u[0]=Math.abs(a)>=l&&y[0]),u[1]===!1&&(u[1]=Math.abs(c)>=h&&y[1])):(u[0]===!1&&(u[0]=Math.abs(a)>=l&&Math.sign(a)*l),u[1]===!1&&(u[1]=Math.abs(c)>=h&&Math.sign(c)*h)),r.intentional=u[0]!==!1||u[1]!==!1,!r.intentional)return;const g=[0,0];if(n.hasCustomTransform){const[f,V]=y;g[0]=u[0]!==!1?f-u[0]:0,g[1]=u[1]!==!1?V-u[1]:0}else g[0]=u[0]!==!1?a-u[0]:0,g[1]=u[1]!==!1?c-u[1]:0;this.restrictToAxis&&!r._blocked&&this.restrictToAxis(g);const O=r.offset,w=r._active&&!r._blocked||r.active;w&&(r.first=r._active&&!r.active,r.last=!r._active&&r.active,r.active=s[this.ingKey]=r._active,e&&(r.first&&("bounds"in n&&(r._bounds=W(n.bounds,r)),this.setup&&this.setup()),r.movement=g,this.computeOffset()));const[I,E]=r.offset,[[L,x],[C,D]]=r._bounds;r.overflow=[I<L?-1:I>x?1:0,E<C?-1:E>D?1:0],r._movementBound[0]=r.overflow[0]?r._movementBound[0]===!1?r._movement[0]:r._movementBound[0]:!1,r._movementBound[1]=r.overflow[1]?r._movementBound[1]===!1?r._movement[1]:r._movementBound[1]:!1;const G=r._active?n.rubberband||[0,0]:[0,0];if(r.offset=De(r._bounds,r.offset,G),r.delta=b.sub(r.offset,O),this.computeMovement(),w&&(!r.last||o>ze)){r.delta=b.sub(r.offset,O);const f=r.delta.map(Math.abs);b.addTo(r.distance,f),r.direction=r.delta.map(Math.sign),r._direction=r._delta.map(Math.sign),!r.first&&o>0&&(r.velocity=[f[0]/o,f[1]/o],r.timeDelta=o)}}emit(){const e=this.state,r=this.shared,n=this.config;if(e._active||this.clean(),(e._blocked||!e.intentional)&&!e._force&&!n.triggerAllEvents)return;const s=this.handler(p(p(p({},r),e),{},{[this.aliasKey]:e.values}));s!==void 0&&(e.memo=s)}clean(){this.eventStore.clean(),this.timeoutStore.clean()}}function Ye([t,e],r){const n=Math.abs(t),s=Math.abs(e);if(n>s&&n>r)return"x";if(s>n&&s>r)return"y"}class Fe extends We{constructor(...e){super(...e),S(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=b.add(this.state.lastOffset,this.state.movement)}computeMovement(){this.state.movement=b.sub(this.state.offset,this.state.lastOffset)}axisIntent(e){const r=this.state,n=this.config;if(!r.axis&&e){const s=typeof n.axisThreshold=="object"?n.axisThreshold[ue(e)]:n.axisThreshold;r.axis=Ye(r._movement,s)}r._blocked=(n.lockDirection||!!n.axis)&&!r.axis||!!n.axis&&n.axis!==r.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=t=>t,pe=.15,q={enabled(t=!0){return t},eventOptions(t,e,r){return p(p({},r.shared.eventOptions),t)},preventDefault(t=!1){return t},triggerAllEvents(t=!1){return t},rubberband(t=0){switch(t){case!0:return[pe,pe];case!1:return[0,0];default:return b.toVector(t)}},from(t){if(typeof t=="function")return t;if(t!=null)return b.toVector(t)},transform(t,e,r){const n=t||r.shared.transform;if(this.hasCustomTransform=!!n,process.env.NODE_ENV==="development"){const s=n||he;return o=>{const a=s(o);return(!isFinite(a[0])||!isFinite(a[1]))&&console.warn(`[@use-gesture]: config.transform() must produce a valid result, but it was: [${a[0]},${[1]}]`),a}}return n||he},threshold(t){return b.toVector(t,0)}};process.env.NODE_ENV==="development"&&Object.assign(q,{domTarget(t){if(t!==void 0)throw Error("[@use-gesture]: `domTarget` option has been renamed to `target`.");return NaN},lockDirection(t){if(t!==void 0)throw Error("[@use-gesture]: `lockDirection` option has been merged with `axis`. Use it as in `{ axis: 'lock' }`");return NaN},initial(t){if(t!==void 0)throw Error("[@use-gesture]: `initial` option has been renamed to `from`.");return NaN}});const He=0,U=p(p({},q),{},{axis(t,e,{axis:r}){if(this.lockDirection=r==="lock",!this.lockDirection)return r},axisThreshold(t=He){return t},bounds(t={}){if(typeof t=="function")return o=>U.bounds(t(o));if("current"in t)return()=>t.current;if(typeof HTMLElement=="function"&&t instanceof HTMLElement)return t;const{left:e=-1/0,right:r=1/0,top:n=-1/0,bottom:s=1/0}=t;return[[e,r],[n,s]]}}),me={ArrowRight:(t,e=1)=>[t*e,0],ArrowLeft:(t,e=1)=>[-1*t*e,0],ArrowUp:(t,e=1)=>[0,-1*t*e],ArrowDown:(t,e=1)=>[0,t*e]};class Xe extends Fe{constructor(...e){super(...e),S(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 r=e._bounds.getBoundingClientRect(),n=e.currentTarget.getBoundingClientRect(),s={left:r.left-n.left+e.offset[0],right:r.right-n.right+e.offset[0],top:r.top-n.top+e.offset[1],bottom:r.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 r=this.config,n=this.state;if(e.buttons!=null&&(Array.isArray(r.pointerButtons)?!r.pointerButtons.includes(e.buttons):r.pointerButtons!==-1&&r.pointerButtons!==e.buttons))return;const s=this.ctrl.setEventIds(e);r.pointerCapture&&e.target.setPointerCapture(e.pointerId),!(s&&s.size>1&&n._pointerActive)&&(this.start(e),this.setupPointer(e),n._pointerId=X(e),n._pointerActive=!0,this.computeValues(fe(e)),this.computeInitial(),r.preventScrollAxis&&ue(e)!=="mouse"?(n._active=!1,this.setupScrollPrevention(e)):r.delay>0?(this.setupDelayTrigger(e),r.triggerAllEvents&&(this.compute(e),this.emit())):this.startPointerDrag(e))}startPointerDrag(e){const r=this.state;r._active=!0,r._preventScroll=!0,r._delayed=!1,this.compute(e),this.emit()}pointerMove(e){const r=this.state,n=this.config;if(!r._pointerActive)return;const s=X(e);if(r._pointerId!==void 0&&s!==r._pointerId)return;const o=fe(e);if(document.pointerLockElement===e.target?r._delta=[e.movementX,e.movementY]:(r._delta=b.sub(o,r._values),this.computeValues(o)),b.addTo(r._movement,r._delta),this.compute(e),r._delayed&&r.intentional){this.timeoutStore.remove("dragDelay"),r.active=!1,this.startPointerDrag(e);return}if(n.preventScrollAxis&&!r._preventScroll)if(r.axis)if(r.axis===n.preventScrollAxis||n.preventScrollAxis==="xy"){r._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 r=this.state,n=this.config;if(!r._active||!r._pointerActive)return;const s=X(e);if(r._pointerId!==void 0&&s!==r._pointerId)return;this.state._pointerActive=!1,this.setActive(),this.compute(e);const[o,a]=r._distance;if(r.tap=o<=n.tapsThreshold&&a<=n.tapsThreshold,r.tap&&n.filterTaps)r._force=!0;else{const[c,l]=r._delta,[h,u]=r._movement,[y,g]=n.swipe.velocity,[O,w]=n.swipe.distance,I=n.swipe.duration;if(r.elapsedTime<I){const E=Math.abs(c/r.timeDelta),L=Math.abs(l/r.timeDelta);E>y&&Math.abs(h)>O&&(r.swipe[0]=Math.sign(c)),L>g&&Math.abs(u)>w&&(r.swipe[1]=Math.sign(l))}}this.emit()}pointerClick(e){!this.state.tap&&e.detail>0&&(e.preventDefault(),e.stopPropagation())}setupPointer(e){const r=this.config,n=r.device;if(process.env.NODE_ENV==="development")try{if(n==="pointer"&&r.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{}r.pointerLock&&e.currentTarget.requestPointerLock(),r.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,qe(e);const r=this.eventStore.add(this.sharedConfig.window,"touch","change",this.preventScroll.bind(this),{passive:!1});this.eventStore.add(this.sharedConfig.window,"touch","end",r),this.eventStore.add(this.sharedConfig.window,"touch","cancel",r),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 r=me[e.key];if(r){const n=this.state,s=e.shiftKey?10:e.altKey?.1:1;this.start(e),n._delta=r(this.config.keyboardDisplacement,s),n._keyboardActive=!0,b.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 r=this.config.device;e(r,"start",this.pointerDown.bind(this)),this.config.pointerCapture&&(e(r,"change",this.pointerMove.bind(this)),e(r,"end",this.pointerUp.bind(this)),e(r,"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 qe(t){"persist"in t&&typeof t.persist=="function"&&t.persist()}const K=typeof window<"u"&&window.document&&window.document.createElement;function ge(){return K&&"ontouchstart"in window}function Je(){return ge()||K&&window.navigator.maxTouchPoints>1}function Qe(){return K&&"onpointerdown"in window}function Ze(){return K&&"exitPointerLock"in window.document}function et(){try{return"constructor"in GestureEvent}catch{return!1}}const P={isBrowser:K,gesture:et(),touch:ge(),touchscreen:Je(),pointer:Qe(),pointerLock:Ze()},tt=250,rt=180,nt=.5,st=50,it=250,ot=10,ve={mouse:0,touch:0,pen:8},ye=p(p({},U),{},{device(t,e,{pointer:{touch:r=!1,lock:n=!1,mouse:s=!1}={}}){return this.pointerLock=n&&P.pointerLock,P.touch&&r?"touch":this.pointerLock?"mouse":P.pointer&&!s?"pointer":P.touch?"touch":"mouse"},preventScrollAxis(t,e,{preventScroll:r}){if(this.preventScrollDelay=typeof r=="number"?r:r||r===void 0&&t?tt:void 0,!(!P.touchscreen||r===!1))return t||(r!==void 0?"y":void 0)},pointerCapture(t,e,{pointer:{capture:r=!0,buttons:n=1,keys:s=!0}={}}){return this.pointerButtons=n,this.keys=s,!this.pointerLock&&this.device==="pointer"&&r},threshold(t,e,{filterTaps:r=!1,tapsThreshold:n=3,axis:s=void 0}){const o=b.toVector(t,r?n:s?1:0);return this.filterTaps=r,this.tapsThreshold=n,o},swipe({velocity:t=nt,distance:e=st,duration:r=it}={}){return{velocity:this.transform(b.toVector(t)),distance:this.transform(b.toVector(e)),duration:r}},delay(t=0){switch(t){case!0:return rt;case!1:return 0;default:return t}},axisThreshold(t){return t?p(p({},ve),t):ve},keyboardDisplacement(t=ot){return t}});process.env.NODE_ENV==="development"&&Object.assign(ye,{useTouch(t){if(t!==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(t){if(t!==void 0)throw Error("[@use-gesture]: `experimental_preventWindowScrollY` option has been renamed to `preventScroll`.");return NaN},swipeVelocity(t){if(t!==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(t){if(t!==void 0)throw Error("[@use-gesture]: `swipeDistance` option has been renamed to `swipe.distance`. Use it as in `{ swipe: { distance: 50 } }`.");return NaN},swipeDuration(t){if(t!==void 0)throw Error("[@use-gesture]: `swipeDuration` option has been renamed to `swipe.duration`. Use it as in `{ swipe: { duration: 250 } }`.");return NaN}}),p(p({},q),{},{device(t,e,{shared:r,pointer:{touch:n=!1}={}}){if(r.target&&!P.touch&&P.gesture)return"gesture";if(P.touch&&n)return"touch";if(P.touchscreen){if(P.pointer)return"pointer";if(P.touch)return"touch"}},bounds(t,e,{scaleBounds:r={},angleBounds:n={}}){const s=a=>{const c=de(W(r,a),{min:-1/0,max:1/0});return[c.min,c.max]},o=a=>{const c=de(W(n,a),{min:-1/0,max:1/0});return[c.min,c.max]};return typeof r!="function"&&typeof n!="function"?[s(),o()]:a=>[s(a),o(a)]},threshold(t,e,r){return this.lockDirection=r.axis==="lock",b.toVector(t,this.lockDirection?[.1,3]:0)},modifierKey(t){return t===void 0?"ctrlKey":t},pinchOnWheel(t=!0){return t}}),p(p({},U),{},{mouseOnly:(t=!0)=>t}),p(p({},U),{},{mouseOnly:(t=!0)=>t});const be=new Map,J=new Map;function at(t){be.set(t.key,t.engine),J.set(t.key,t.resolver)}const ct={key:"drag",engine:Xe,resolver:ye};function ut(t,e){if(t==null)return{};var r={},n=Object.keys(t),s,o;for(o=0;o<n.length;o++)s=n[o],!(e.indexOf(s)>=0)&&(r[s]=t[s]);return r}function lt(t,e){if(t==null)return{};var r=ut(t,e),n,s;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);for(s=0;s<o.length;s++)n=o[s],!(e.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}const ft={target(t){if(t)return()=>"current"in t?t.current:t},enabled(t=!0){return t},window(t=P.isBrowser?window:void 0){return t},eventOptions({passive:t=!0,capture:e=!1}={}){return{passive:t,capture:e}},transform(t){return t}},dt=["target","eventOptions","window","enabled","transform"];function Y(t={},e){const r={};for(const[n,s]of Object.entries(e))switch(typeof s){case"function":if(process.env.NODE_ENV==="development"){const o=s.call(r,t[n],n,t);Number.isNaN(o)||(r[n]=o)}else r[n]=s.call(r,t[n],n,t);break;case"object":r[n]=Y(t[n],s);break;case"boolean":s&&(r[n]=t[n]);break}return r}function ht(t,e,r={}){const n=t,{target:s,eventOptions:o,window:a,enabled:c,transform:l}=n,h=lt(n,dt);if(r.shared=Y({target:s,eventOptions:o,window:a,enabled:c,transform:l},ft),e){const u=J.get(e);r[e]=Y(p({shared:r.shared},h),u)}else for(const u in h){const y=J.get(u);if(y)r[u]=Y(p({shared:r.shared},h[u]),y);else if(process.env.NODE_ENV==="development"&&!["drag","pinch","scroll","wheel","move","hover"].includes(u)){if(u==="domTarget")throw Error("[@use-gesture]: `domTarget` option has been renamed to `target`.");console.warn(`[@use-gesture]: Unknown config key \`${u}\` was used. Please read the documentation for further information.`)}}return r}class _e{constructor(e,r){S(this,"_listeners",new Set),this._ctrl=e,this._gestureKey=r}add(e,r,n,s,o){const a=this._listeners,c=Ve(r,n),l=this._gestureKey?this._ctrl.config[this._gestureKey].eventOptions:{},h=p(p({},l),o);e.addEventListener(c,s,h);const u=()=>{e.removeEventListener(c,s,h),a.delete(u)};return a.add(u),u}clean(){this._listeners.forEach(e=>e()),this._listeners.clear()}}class pt{constructor(){S(this,"_timeouts",new Map)}add(e,r,n=140,...s){this.remove(e),this._timeouts.set(e,window.setTimeout(r,n,...s))}remove(e){const r=this._timeouts.get(e);r&&window.clearTimeout(r)}clean(){this._timeouts.forEach(e=>void window.clearTimeout(e)),this._timeouts.clear()}}class mt{constructor(e){S(this,"gestures",new Set),S(this,"_targetEventStore",new _e(this)),S(this,"gestureEventStores",{}),S(this,"gestureTimeoutStores",{}),S(this,"handlers",{}),S(this,"config",{}),S(this,"pointerIds",new Set),S(this,"touchIds",new Set),S(this,"state",{shared:{shiftKey:!1,metaKey:!1,ctrlKey:!1,altKey:!1}}),gt(this,e)}setEventIds(e){if(z(e))return this.touchIds=new Set(Be(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,r){this.handlers=e,this.nativeHandlers=r}applyConfig(e,r){this.config=ht(e,r,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 r=this.config.shared,n={};let s;if(!(r.target&&(s=r.target(),!s))){if(r.enabled){for(const a of this.gestures){const c=this.config[a],l=we(n,c.eventOptions,!!s);if(c.enabled){const h=be.get(a);new h(this,e,a).bind(l)}}const o=we(n,r.eventOptions,!!s);for(const a in this.nativeHandlers)o(a,"",c=>this.nativeHandlers[a](p(p({},this.state.shared),{},{event:c,args:e})),void 0,!0)}for(const o in n)n[o]=Ge(...n[o]);if(!s)return n;for(const o in n){const{device:a,capture:c,passive:l}=Me(o);this._targetEventStore.add(s,a,"",n[o],{capture:c,passive:l})}}}}function M(t,e){t.gestures.add(e),t.gestureEventStores[e]=new _e(t,e),t.gestureTimeoutStores[e]=new pt}function gt(t,e){e.drag&&M(t,"drag"),e.wheel&&M(t,"wheel"),e.scroll&&M(t,"scroll"),e.move&&M(t,"move"),e.pinch&&M(t,"pinch"),e.hover&&M(t,"hover")}const we=(t,e,r)=>(n,s,o,a={},c=!1)=>{var l,h;const u=(l=a.capture)!==null&&l!==void 0?l:e.capture,y=(h=a.passive)!==null&&h!==void 0?h:e.passive;let g=c?n:Le(n,s,u);r&&y&&(g+="Passive"),t[g]=t[g]||[],t[g].push(o)};function vt(t,e={},r,n){const s=m.useMemo(()=>new mt(t),[]);if(s.applyHandlers(t,n),s.applyConfig(e,r),m.useEffect(s.effect.bind(s)),m.useEffect(()=>s.clean.bind(s),[]),e.target===void 0)return s.bind.bind(s)}function yt(t,e){return at(ct),vt({drag:t},e||{},"drag")}const Q="RSC::Event";function bt(){const t=m.useRef(null);function e(n){m.useEffect(()=>{t.current||(t.current=document.createElement("div"));function s(o){n(o.detail)}if(t.current)return t.current.addEventListener(Q,s,!1),()=>{var o;(o=t.current)==null||o.removeEventListener(Q,s,!1)}},[n])}function r(n){if(t.current){const s=new CustomEvent(Q,{detail:n});t.current.dispatchEvent(s)}}return{useListenToCustomEvent:e,emitEvent:r}}function _t(t){let e=t.replace(/\/\*[\s\S]*?\*\/|([^:]|^)\/\/.*$/gm,"");return e=e.replace(/[\n\t]+/g," "),e=e.replace(/\s*([{}:;,])\s*/g,"$1"),e=e.replace(/\s+}/g,"}"),e=e.replace(/{\s+/g,"{"),e=e.replace(/\s+/g," "),e.trim()}function wt({init:t=!0,items:e,withLoop:r=!1,id:n,gutter:s=[{breakpoint:0,gutter:0,startEndGutter:0}],itemsPerSlide:o=[{breakpoint:0,itemsPerSlide:1}],carouselAxis:a="x",startingPosition:c="start",enableGestures:l=!0,slideWhenDragThresholdIsReached:h=!0,onInit:u,initialActiveItem:y=0}){const[g,O]=m.useState(!1),w=m.useRef(t),I=m.useRef(null),E=m.useRef(null),L=m.useRef(0),x=m.useRef(0),C=m.useRef(!r),D=m.useRef(!1),G=m.useRef(0),f=m.useRef(0),V=H.useSpringRef(),ee=H.useSpring({value:0,ref:V,onChange({value:i}){E.current.style.transform=`translate3d(calc(${i.value}px + var(--${n}-offset-modifier)), 0px, 0px)`}}),Tt=r?[...e.map(i=>({...i,id:`prev-repeated-item-${i.id}`,isClonedItem:!0})),...e,...e.map(i=>({...i,id:`next-repeated-item-${i.id}`,isClonedItem:!0}))]:e,{useListenToCustomEvent:xe,emitEvent:F}=bt();function St(){const{totalGutterCssVar:i}=Te();return i}function It(){if(I.current){const d=window.getComputedStyle(I.current).getPropertyValue(`--${n}-items-per-slide`).trim();return Number(d)||1}return 1}function te(i){w.current&&(D.current||j({type:"next",toIndex:i,actionType:"click"}))}function re(i){w.current&&(C.current||j({type:"prev",toIndex:i,actionType:"click"}))}function j({type:i,shouldAnimate:d=!0,toIndex:_,actionType:T}){var R,Ie;const k=!d;C.current=!1,D.current=!1;let v=ee.value.get(),$=0;if(i==="next"&&(f.current+=1),i==="prev"&&(f.current===0?f.current=e.length-1:f.current-=1),_!==void 0&&(f.current=_),i==="next"){const B=ne(r?x.current*(e.length*2):0);$=-(f.current*x.current),r&&f.current===e.length&&(f.current=0,v=v+x.current*e.length,$=0),!r&&(Math.abs($)>=B||f.current===e.length-1)&&(D.current=!0,$=-B)}i==="prev"&&($=-(f.current*x.current),f.current===e.length-1&&(v=v-e.length*x.current),!r&&$>=0&&(C.current=!0,$=0)),L.current=$,T==="resize"?($=-(f.current*x.current),F({eventName:"onResize",sliceActionType:T,slideDirection:i,currentItem:{index:f.current,id:((R=e.at(f.current))==null?void 0:R.id)??"",startReached:C.current,endReached:D.current}})):F({eventName:"onSlideStartChange",sliceActionType:T,slideDirection:i,nextItem:{index:f.current,id:((Ie=e.at(f.current))==null?void 0:Ie.id)??"",startReached:C.current,endReached:D.current}}),V.start({immediate:k,from:{value:v},to:{value:$},onChange({value:B}){E.current.style.transform=`translate3d(calc(${B.value}px + var(--${n}-offset-modifier)), 0px, 0px)`},onRest({finished:B}){var ke;B&&F({eventName:"onSlideChangeComplete",sliceActionType:T,slideDirection:i,currentItem:{index:f.current,id:((ke=e.at(f.current))==null?void 0:ke.id)??"",startReached:C.current,endReached:D.current}})}})}function kt(){const i=E.current;let d=0;return d=i.getBoundingClientRect()[a==="x"?"width":"height"]+St(),d}function ne(i){const d=E.current;return d[a==="x"?"scrollWidth":"scrollHeight"]-d.getBoundingClientRect()[a==="x"?"width":"height"]-i}function Te(){let i=0,d=0;if(I.current){const _=window.getComputedStyle(I.current),T=_.getPropertyValue(`--${n}-start-end-gutter`).trim();T.includes("px")&&(i=Number(T.replace("px","")));const k=_.getPropertyValue(`--${n}-gutter`).trim();k.includes("px")&&(d=Number(k.replace("px","")))}return{totalStartEndGutterCssVar:i,totalGutterCssVar:d}}m.useEffect(()=>{function i(k){const v=It();switch(k){case"start":return 0;case"middle-start":return Math.floor((v-1)*.25);case"center":return Math.floor((v-1)*.5);case"middle-end":return Math.floor((v-1)*.75);case"end":return v-1;default:return 0}}function d(){x.current=kt(),G.current=x.current/4;const{totalStartEndGutterCssVar:k}=Te();let v=0;r&&(v=x.current*e.length),v-=x.current*i(c),v-=k/2,I.current.style.setProperty(`--${n}-offset-modifier`,`${-v}px`)}function _(k){I.current&&(d(),O(!0),k&&k())}function T(){_(),j({type:"resize",toIndex:f.current,shouldAnimate:!1,actionType:"resize"})}if(t)return w.current=!0,_(u),window.addEventListener("resize",T),()=>{window.removeEventListener("resize",T)}},[t]),m.useEffect(()=>{t&&y!==f.current&&j({type:"next",toIndex:y,actionType:"resize",shouldAnimate:!1})},[t,y]);const Se=l,Ct=yt(i=>{if(!w.current)return;const d=i.dragging,_=i.offset[a==="x"?0:1],T=i.movement[a==="x"?0:1],k=T>G.current,v=T<-G.current,$=i.velocity;d&&(F({...i,eventName:"onDrag",slideActionType:"drag"}),V.start({value:_,immediate:!0,onChange({value:R}){E.current.style.transform=`translate3d(calc(${R.value}px + var(--${n}-offset-modifier)), 0px, 0px)`},config:{velocity:$}}),h&&(k||v)&&i.cancel()),i.last&&(k?(j({actionType:"drag",type:"prev"}),i.cancel()):v?(j({actionType:"drag",type:"next"}),i.cancel()):(V.start({value:L.current,onChange({value:R}){E.current.style.transform=`translate3d(calc(${R.value}px + var(--${n}-offset-modifier)), 0px, 0px)`},config:{velocity:$}}),i.cancel()))},{enabled:Se,axis:a,rubberband:!r,...r?{}:{bounds:()=>({right:0,left:-ne(0),top:-ne(0),bottom:0})},from:()=>[ee.value.get(),ee.value.get()]});function Dt(i){var d,_;return typeof i=="number"?f.current===i:((d=e.find(T=>T.id===i))==null?void 0:d.id)===((_=e[f.current])==null?void 0:_.id)}return{carouselFragment:N.jsxs("div",{ref:I,className:"ReactSpringCarouselContainer","data-part":"Container","data-part-internal":`${n}-Container`,...Ct(),children:[N.jsx("style",{dangerouslySetInnerHTML:{__html:_t(`
|
|
1
|
+
(function(A,N){typeof exports=="object"&&typeof module<"u"?N(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"],N):(A=typeof globalThis<"u"?globalThis:A||self,N(A["react-spring-carousel"]={},A["react/jsx-runtime"],A["@react-spring/web"],A.React))})(this,function(A,N,H,m){"use strict";function Ce(t,e,r){return Math.max(e,Math.min(t,r))}const w={toVector(t,e){return t===void 0&&(t=e),Array.isArray(t)?t:[t,t]},add(t,e){return[t[0]+e[0],t[1]+e[1]]},sub(t,e){return[t[0]-e[0],t[1]-e[1]]},addTo(t,e){t[0]+=e[0],t[1]+=e[1]},subTo(t,e){t[0]-=e[0],t[1]-=e[1]}};function se(t,e,r){return e===0||Math.abs(e)===1/0?Math.pow(t,r*5):t*e*r/(e+r*t)}function ie(t,e,r,n=.15){return n===0?Ce(t,e,r):t<e?-se(e-t,r-e,n)+e:t>r?+se(t-r,r-e,n)+r:t}function De(t,[e,r],[n,s]){const[[o,a],[c,l]]=t;return[ie(e,o,a,n),ie(r,c,l,s)]}function $e(t,e){if(typeof t!="object"||t===null)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Pe(t){var e=$e(t,"string");return typeof e=="symbol"?e:String(e)}function I(t,e,r){return e=Pe(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function oe(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),r.push.apply(r,n)}return r}function p(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?oe(Object(r),!0).forEach(function(n){I(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):oe(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}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(t){return t?t[0].toUpperCase()+t.slice(1):""}const Oe=["enter","leave"];function Ae(t=!1,e){return t&&!Oe.includes(e)}function Le(t,e="",r=!1){const n=ae[t],s=n&&n[e]||e;return"on"+ce(t)+ce(s)+(Ae(r,s)?"Capture":"")}const Ne=["gotpointercapture","lostpointercapture"];function Me(t){let e=t.substring(2).toLowerCase();const r=!!~e.indexOf("passive");r&&(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:r}}function Ve(t,e=""){const r=ae[t],n=r&&r[e]||e;return t+n}function z(t){return"touches"in t}function ue(t){return z(t)?"touch":"pointerType"in t?t.pointerType:"mouse"}function je(t){return Array.from(t.touches).filter(e=>{var r,n;return e.target===t.currentTarget||((r=t.currentTarget)===null||r===void 0||(n=r.contains)===null||n===void 0?void 0:n.call(r,e.target))})}function Re(t){return t.type==="touchend"||t.type==="touchcancel"?t.changedTouches:t.targetTouches}function le(t){return z(t)?Re(t)[0]:t}function Be(t){return je(t).map(e=>e.identifier)}function X(t){const e=le(t);return z(t)?e.identifier:e.pointerId}function fe(t){const e=le(t);return[e.clientX,e.clientY]}function Ue(t){const e={};if("buttons"in t&&(e.buttons=t.buttons),"shiftKey"in t){const{shiftKey:r,altKey:n,metaKey:s,ctrlKey:o}=t;Object.assign(e,{shiftKey:r,altKey:n,metaKey:s,ctrlKey:o})}return e}function W(t,...e){return typeof t=="function"?t(...e):t}function Ke(){}function Ge(...t){return t.length===0?Ke:t.length===1?t[0]:function(){let e;for(const r of t)e=r.apply(this,arguments)||e;return e}}function de(t,e){return Object.assign({},e,t||{})}const ze=32;class We{constructor(e,r,n){this.ctrl=e,this.args=r,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:r,ingKey:n,args:s}=this;r[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 r=this.state,n=this.config;r._active||(this.reset(),this.computeInitial(),r._active=!0,r.target=e.target,r.currentTarget=e.currentTarget,r.lastOffset=n.from?W(n.from,r):r.offset,r.offset=r.lastOffset,r.startTime=r.timeStamp=e.timeStamp)}computeValues(e){const r=this.state;r._values=e,r.values=this.config.transform(e)}computeInitial(){const e=this.state;e._initial=e._values,e.initial=e.values}compute(e){const{state:r,config:n,shared:s}=this;r.args=this.args;let o=0;if(e&&(r.event=e,n.preventDefault&&e.cancelable&&r.event.preventDefault(),r.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,o=e.timeStamp-r.timeStamp,r.timeStamp=e.timeStamp,r.elapsedTime=r.timeStamp-r.startTime),r._active){const f=r._delta.map(Math.abs);w.addTo(r._distance,f)}this.axisIntent&&this.axisIntent(e);const[a,c]=r._movement,[l,h]=n.threshold,{_step:u,values:y}=r;if(n.hasCustomTransform?(u[0]===!1&&(u[0]=Math.abs(a)>=l&&y[0]),u[1]===!1&&(u[1]=Math.abs(c)>=h&&y[1])):(u[0]===!1&&(u[0]=Math.abs(a)>=l&&Math.sign(a)*l),u[1]===!1&&(u[1]=Math.abs(c)>=h&&Math.sign(c)*h)),r.intentional=u[0]!==!1||u[1]!==!1,!r.intentional)return;const g=[0,0];if(n.hasCustomTransform){const[f,V]=y;g[0]=u[0]!==!1?f-u[0]:0,g[1]=u[1]!==!1?V-u[1]:0}else g[0]=u[0]!==!1?a-u[0]:0,g[1]=u[1]!==!1?c-u[1]:0;this.restrictToAxis&&!r._blocked&&this.restrictToAxis(g);const O=r.offset,x=r._active&&!r._blocked||r.active;x&&(r.first=r._active&&!r.active,r.last=!r._active&&r.active,r.active=s[this.ingKey]=r._active,e&&(r.first&&("bounds"in n&&(r._bounds=W(n.bounds,r)),this.setup&&this.setup()),r.movement=g,this.computeOffset()));const[k,b]=r.offset,[[L,E],[D,$]]=r._bounds;r.overflow=[k<L?-1:k>E?1:0,b<D?-1:b>$?1:0],r._movementBound[0]=r.overflow[0]?r._movementBound[0]===!1?r._movement[0]:r._movementBound[0]:!1,r._movementBound[1]=r.overflow[1]?r._movementBound[1]===!1?r._movement[1]:r._movementBound[1]:!1;const G=r._active?n.rubberband||[0,0]:[0,0];if(r.offset=De(r._bounds,r.offset,G),r.delta=w.sub(r.offset,O),this.computeMovement(),x&&(!r.last||o>ze)){r.delta=w.sub(r.offset,O);const f=r.delta.map(Math.abs);w.addTo(r.distance,f),r.direction=r.delta.map(Math.sign),r._direction=r._delta.map(Math.sign),!r.first&&o>0&&(r.velocity=[f[0]/o,f[1]/o],r.timeDelta=o)}}emit(){const e=this.state,r=this.shared,n=this.config;if(e._active||this.clean(),(e._blocked||!e.intentional)&&!e._force&&!n.triggerAllEvents)return;const s=this.handler(p(p(p({},r),e),{},{[this.aliasKey]:e.values}));s!==void 0&&(e.memo=s)}clean(){this.eventStore.clean(),this.timeoutStore.clean()}}function Ye([t,e],r){const n=Math.abs(t),s=Math.abs(e);if(n>s&&n>r)return"x";if(s>n&&s>r)return"y"}class Fe extends We{constructor(...e){super(...e),I(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=w.add(this.state.lastOffset,this.state.movement)}computeMovement(){this.state.movement=w.sub(this.state.offset,this.state.lastOffset)}axisIntent(e){const r=this.state,n=this.config;if(!r.axis&&e){const s=typeof n.axisThreshold=="object"?n.axisThreshold[ue(e)]:n.axisThreshold;r.axis=Ye(r._movement,s)}r._blocked=(n.lockDirection||!!n.axis)&&!r.axis||!!n.axis&&n.axis!==r.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=t=>t,pe=.15,q={enabled(t=!0){return t},eventOptions(t,e,r){return p(p({},r.shared.eventOptions),t)},preventDefault(t=!1){return t},triggerAllEvents(t=!1){return t},rubberband(t=0){switch(t){case!0:return[pe,pe];case!1:return[0,0];default:return w.toVector(t)}},from(t){if(typeof t=="function")return t;if(t!=null)return w.toVector(t)},transform(t,e,r){const n=t||r.shared.transform;if(this.hasCustomTransform=!!n,process.env.NODE_ENV==="development"){const s=n||he;return o=>{const a=s(o);return(!isFinite(a[0])||!isFinite(a[1]))&&console.warn(`[@use-gesture]: config.transform() must produce a valid result, but it was: [${a[0]},${[1]}]`),a}}return n||he},threshold(t){return w.toVector(t,0)}};process.env.NODE_ENV==="development"&&Object.assign(q,{domTarget(t){if(t!==void 0)throw Error("[@use-gesture]: `domTarget` option has been renamed to `target`.");return NaN},lockDirection(t){if(t!==void 0)throw Error("[@use-gesture]: `lockDirection` option has been merged with `axis`. Use it as in `{ axis: 'lock' }`");return NaN},initial(t){if(t!==void 0)throw Error("[@use-gesture]: `initial` option has been renamed to `from`.");return NaN}});const He=0,U=p(p({},q),{},{axis(t,e,{axis:r}){if(this.lockDirection=r==="lock",!this.lockDirection)return r},axisThreshold(t=He){return t},bounds(t={}){if(typeof t=="function")return o=>U.bounds(t(o));if("current"in t)return()=>t.current;if(typeof HTMLElement=="function"&&t instanceof HTMLElement)return t;const{left:e=-1/0,right:r=1/0,top:n=-1/0,bottom:s=1/0}=t;return[[e,r],[n,s]]}}),me={ArrowRight:(t,e=1)=>[t*e,0],ArrowLeft:(t,e=1)=>[-1*t*e,0],ArrowUp:(t,e=1)=>[0,-1*t*e],ArrowDown:(t,e=1)=>[0,t*e]};class Xe extends Fe{constructor(...e){super(...e),I(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 r=e._bounds.getBoundingClientRect(),n=e.currentTarget.getBoundingClientRect(),s={left:r.left-n.left+e.offset[0],right:r.right-n.right+e.offset[0],top:r.top-n.top+e.offset[1],bottom:r.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 r=this.config,n=this.state;if(e.buttons!=null&&(Array.isArray(r.pointerButtons)?!r.pointerButtons.includes(e.buttons):r.pointerButtons!==-1&&r.pointerButtons!==e.buttons))return;const s=this.ctrl.setEventIds(e);r.pointerCapture&&e.target.setPointerCapture(e.pointerId),!(s&&s.size>1&&n._pointerActive)&&(this.start(e),this.setupPointer(e),n._pointerId=X(e),n._pointerActive=!0,this.computeValues(fe(e)),this.computeInitial(),r.preventScrollAxis&&ue(e)!=="mouse"?(n._active=!1,this.setupScrollPrevention(e)):r.delay>0?(this.setupDelayTrigger(e),r.triggerAllEvents&&(this.compute(e),this.emit())):this.startPointerDrag(e))}startPointerDrag(e){const r=this.state;r._active=!0,r._preventScroll=!0,r._delayed=!1,this.compute(e),this.emit()}pointerMove(e){const r=this.state,n=this.config;if(!r._pointerActive)return;const s=X(e);if(r._pointerId!==void 0&&s!==r._pointerId)return;const o=fe(e);if(document.pointerLockElement===e.target?r._delta=[e.movementX,e.movementY]:(r._delta=w.sub(o,r._values),this.computeValues(o)),w.addTo(r._movement,r._delta),this.compute(e),r._delayed&&r.intentional){this.timeoutStore.remove("dragDelay"),r.active=!1,this.startPointerDrag(e);return}if(n.preventScrollAxis&&!r._preventScroll)if(r.axis)if(r.axis===n.preventScrollAxis||n.preventScrollAxis==="xy"){r._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 r=this.state,n=this.config;if(!r._active||!r._pointerActive)return;const s=X(e);if(r._pointerId!==void 0&&s!==r._pointerId)return;this.state._pointerActive=!1,this.setActive(),this.compute(e);const[o,a]=r._distance;if(r.tap=o<=n.tapsThreshold&&a<=n.tapsThreshold,r.tap&&n.filterTaps)r._force=!0;else{const[c,l]=r._delta,[h,u]=r._movement,[y,g]=n.swipe.velocity,[O,x]=n.swipe.distance,k=n.swipe.duration;if(r.elapsedTime<k){const b=Math.abs(c/r.timeDelta),L=Math.abs(l/r.timeDelta);b>y&&Math.abs(h)>O&&(r.swipe[0]=Math.sign(c)),L>g&&Math.abs(u)>x&&(r.swipe[1]=Math.sign(l))}}this.emit()}pointerClick(e){!this.state.tap&&e.detail>0&&(e.preventDefault(),e.stopPropagation())}setupPointer(e){const r=this.config,n=r.device;if(process.env.NODE_ENV==="development")try{if(n==="pointer"&&r.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{}r.pointerLock&&e.currentTarget.requestPointerLock(),r.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,qe(e);const r=this.eventStore.add(this.sharedConfig.window,"touch","change",this.preventScroll.bind(this),{passive:!1});this.eventStore.add(this.sharedConfig.window,"touch","end",r),this.eventStore.add(this.sharedConfig.window,"touch","cancel",r),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 r=me[e.key];if(r){const n=this.state,s=e.shiftKey?10:e.altKey?.1:1;this.start(e),n._delta=r(this.config.keyboardDisplacement,s),n._keyboardActive=!0,w.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 r=this.config.device;e(r,"start",this.pointerDown.bind(this)),this.config.pointerCapture&&(e(r,"change",this.pointerMove.bind(this)),e(r,"end",this.pointerUp.bind(this)),e(r,"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 qe(t){"persist"in t&&typeof t.persist=="function"&&t.persist()}const K=typeof window<"u"&&window.document&&window.document.createElement;function ge(){return K&&"ontouchstart"in window}function Je(){return ge()||K&&window.navigator.maxTouchPoints>1}function Qe(){return K&&"onpointerdown"in window}function Ze(){return K&&"exitPointerLock"in window.document}function et(){try{return"constructor"in GestureEvent}catch{return!1}}const P={isBrowser:K,gesture:et(),touch:ge(),touchscreen:Je(),pointer:Qe(),pointerLock:Ze()},tt=250,rt=180,nt=.5,st=50,it=250,ot=10,ve={mouse:0,touch:0,pen:8},ye=p(p({},U),{},{device(t,e,{pointer:{touch:r=!1,lock:n=!1,mouse:s=!1}={}}){return this.pointerLock=n&&P.pointerLock,P.touch&&r?"touch":this.pointerLock?"mouse":P.pointer&&!s?"pointer":P.touch?"touch":"mouse"},preventScrollAxis(t,e,{preventScroll:r}){if(this.preventScrollDelay=typeof r=="number"?r:r||r===void 0&&t?tt:void 0,!(!P.touchscreen||r===!1))return t||(r!==void 0?"y":void 0)},pointerCapture(t,e,{pointer:{capture:r=!0,buttons:n=1,keys:s=!0}={}}){return this.pointerButtons=n,this.keys=s,!this.pointerLock&&this.device==="pointer"&&r},threshold(t,e,{filterTaps:r=!1,tapsThreshold:n=3,axis:s=void 0}){const o=w.toVector(t,r?n:s?1:0);return this.filterTaps=r,this.tapsThreshold=n,o},swipe({velocity:t=nt,distance:e=st,duration:r=it}={}){return{velocity:this.transform(w.toVector(t)),distance:this.transform(w.toVector(e)),duration:r}},delay(t=0){switch(t){case!0:return rt;case!1:return 0;default:return t}},axisThreshold(t){return t?p(p({},ve),t):ve},keyboardDisplacement(t=ot){return t}});process.env.NODE_ENV==="development"&&Object.assign(ye,{useTouch(t){if(t!==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(t){if(t!==void 0)throw Error("[@use-gesture]: `experimental_preventWindowScrollY` option has been renamed to `preventScroll`.");return NaN},swipeVelocity(t){if(t!==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(t){if(t!==void 0)throw Error("[@use-gesture]: `swipeDistance` option has been renamed to `swipe.distance`. Use it as in `{ swipe: { distance: 50 } }`.");return NaN},swipeDuration(t){if(t!==void 0)throw Error("[@use-gesture]: `swipeDuration` option has been renamed to `swipe.duration`. Use it as in `{ swipe: { duration: 250 } }`.");return NaN}}),p(p({},q),{},{device(t,e,{shared:r,pointer:{touch:n=!1}={}}){if(r.target&&!P.touch&&P.gesture)return"gesture";if(P.touch&&n)return"touch";if(P.touchscreen){if(P.pointer)return"pointer";if(P.touch)return"touch"}},bounds(t,e,{scaleBounds:r={},angleBounds:n={}}){const s=a=>{const c=de(W(r,a),{min:-1/0,max:1/0});return[c.min,c.max]},o=a=>{const c=de(W(n,a),{min:-1/0,max:1/0});return[c.min,c.max]};return typeof r!="function"&&typeof n!="function"?[s(),o()]:a=>[s(a),o(a)]},threshold(t,e,r){return this.lockDirection=r.axis==="lock",w.toVector(t,this.lockDirection?[.1,3]:0)},modifierKey(t){return t===void 0?"ctrlKey":t},pinchOnWheel(t=!0){return t}}),p(p({},U),{},{mouseOnly:(t=!0)=>t}),p(p({},U),{},{mouseOnly:(t=!0)=>t});const be=new Map,J=new Map;function at(t){be.set(t.key,t.engine),J.set(t.key,t.resolver)}const ct={key:"drag",engine:Xe,resolver:ye};function ut(t,e){if(t==null)return{};var r={},n=Object.keys(t),s,o;for(o=0;o<n.length;o++)s=n[o],!(e.indexOf(s)>=0)&&(r[s]=t[s]);return r}function lt(t,e){if(t==null)return{};var r=ut(t,e),n,s;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);for(s=0;s<o.length;s++)n=o[s],!(e.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}const ft={target(t){if(t)return()=>"current"in t?t.current:t},enabled(t=!0){return t},window(t=P.isBrowser?window:void 0){return t},eventOptions({passive:t=!0,capture:e=!1}={}){return{passive:t,capture:e}},transform(t){return t}},dt=["target","eventOptions","window","enabled","transform"];function Y(t={},e){const r={};for(const[n,s]of Object.entries(e))switch(typeof s){case"function":if(process.env.NODE_ENV==="development"){const o=s.call(r,t[n],n,t);Number.isNaN(o)||(r[n]=o)}else r[n]=s.call(r,t[n],n,t);break;case"object":r[n]=Y(t[n],s);break;case"boolean":s&&(r[n]=t[n]);break}return r}function ht(t,e,r={}){const n=t,{target:s,eventOptions:o,window:a,enabled:c,transform:l}=n,h=lt(n,dt);if(r.shared=Y({target:s,eventOptions:o,window:a,enabled:c,transform:l},ft),e){const u=J.get(e);r[e]=Y(p({shared:r.shared},h),u)}else for(const u in h){const y=J.get(u);if(y)r[u]=Y(p({shared:r.shared},h[u]),y);else if(process.env.NODE_ENV==="development"&&!["drag","pinch","scroll","wheel","move","hover"].includes(u)){if(u==="domTarget")throw Error("[@use-gesture]: `domTarget` option has been renamed to `target`.");console.warn(`[@use-gesture]: Unknown config key \`${u}\` was used. Please read the documentation for further information.`)}}return r}class _e{constructor(e,r){I(this,"_listeners",new Set),this._ctrl=e,this._gestureKey=r}add(e,r,n,s,o){const a=this._listeners,c=Ve(r,n),l=this._gestureKey?this._ctrl.config[this._gestureKey].eventOptions:{},h=p(p({},l),o);e.addEventListener(c,s,h);const u=()=>{e.removeEventListener(c,s,h),a.delete(u)};return a.add(u),u}clean(){this._listeners.forEach(e=>e()),this._listeners.clear()}}class pt{constructor(){I(this,"_timeouts",new Map)}add(e,r,n=140,...s){this.remove(e),this._timeouts.set(e,window.setTimeout(r,n,...s))}remove(e){const r=this._timeouts.get(e);r&&window.clearTimeout(r)}clean(){this._timeouts.forEach(e=>void window.clearTimeout(e)),this._timeouts.clear()}}class mt{constructor(e){I(this,"gestures",new Set),I(this,"_targetEventStore",new _e(this)),I(this,"gestureEventStores",{}),I(this,"gestureTimeoutStores",{}),I(this,"handlers",{}),I(this,"config",{}),I(this,"pointerIds",new Set),I(this,"touchIds",new Set),I(this,"state",{shared:{shiftKey:!1,metaKey:!1,ctrlKey:!1,altKey:!1}}),gt(this,e)}setEventIds(e){if(z(e))return this.touchIds=new Set(Be(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,r){this.handlers=e,this.nativeHandlers=r}applyConfig(e,r){this.config=ht(e,r,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 r=this.config.shared,n={};let s;if(!(r.target&&(s=r.target(),!s))){if(r.enabled){for(const a of this.gestures){const c=this.config[a],l=we(n,c.eventOptions,!!s);if(c.enabled){const h=be.get(a);new h(this,e,a).bind(l)}}const o=we(n,r.eventOptions,!!s);for(const a in this.nativeHandlers)o(a,"",c=>this.nativeHandlers[a](p(p({},this.state.shared),{},{event:c,args:e})),void 0,!0)}for(const o in n)n[o]=Ge(...n[o]);if(!s)return n;for(const o in n){const{device:a,capture:c,passive:l}=Me(o);this._targetEventStore.add(s,a,"",n[o],{capture:c,passive:l})}}}}function M(t,e){t.gestures.add(e),t.gestureEventStores[e]=new _e(t,e),t.gestureTimeoutStores[e]=new pt}function gt(t,e){e.drag&&M(t,"drag"),e.wheel&&M(t,"wheel"),e.scroll&&M(t,"scroll"),e.move&&M(t,"move"),e.pinch&&M(t,"pinch"),e.hover&&M(t,"hover")}const we=(t,e,r)=>(n,s,o,a={},c=!1)=>{var l,h;const u=(l=a.capture)!==null&&l!==void 0?l:e.capture,y=(h=a.passive)!==null&&h!==void 0?h:e.passive;let g=c?n:Le(n,s,u);r&&y&&(g+="Passive"),t[g]=t[g]||[],t[g].push(o)};function vt(t,e={},r,n){const s=m.useMemo(()=>new mt(t),[]);if(s.applyHandlers(t,n),s.applyConfig(e,r),m.useEffect(s.effect.bind(s)),m.useEffect(()=>s.clean.bind(s),[]),e.target===void 0)return s.bind.bind(s)}function yt(t,e){return at(ct),vt({drag:t},e||{},"drag")}const Q="RSC::Event";function bt(){const t=m.useRef(null);function e(n){m.useEffect(()=>{t.current||(t.current=document.createElement("div"));function s(o){n(o.detail)}if(t.current)return t.current.addEventListener(Q,s,!1),()=>{var o;(o=t.current)==null||o.removeEventListener(Q,s,!1)}},[n])}function r(n){if(t.current){const s=new CustomEvent(Q,{detail:n});t.current.dispatchEvent(s)}}return{useListenToCustomEvent:e,emitEvent:r}}function _t(t){let e=t.replace(/\/\*[\s\S]*?\*\/|([^:]|^)\/\/.*$/gm,"");return e=e.replace(/[\n\t]+/g," "),e=e.replace(/\s*([{}:;,])\s*/g,"$1"),e=e.replace(/\s+}/g,"}"),e=e.replace(/{\s+/g,"{"),e=e.replace(/\s+/g," "),e.trim()}function wt({init:t=!0,items:e,withLoop:r=!1,id:n,gutter:s=[{breakpoint:0,gutter:0,startEndGutter:0}],itemsPerSlide:o=[{breakpoint:0,itemsPerSlide:1}],carouselAxis:a="x",startingPosition:c="start",enableGestures:l=!0,slideWhenDragThresholdIsReached:h=!0,onInit:u,initialActiveItem:y=0}){const[g,O]=m.useState(!1),x=m.useRef(t),k=m.useRef(null),b=m.useRef(null),L=m.useRef(0),E=m.useRef(0),D=m.useRef(!r),$=m.useRef(!1),G=m.useRef(0),f=m.useRef(0),V=H.useSpringRef(),ee=H.useSpring({value:0,ref:V,onChange({value:i}){b.current.style.transform=`translate3d(calc(${i.value}px + var(--${n}-offset-modifier)), 0px, 0px)`}}),Tt=r?[...e.map(i=>({...i,id:`prev-repeated-item-${i.id}`,isClonedItem:!0})),...e,...e.map(i=>({...i,id:`next-repeated-item-${i.id}`,isClonedItem:!0}))]:e,{useListenToCustomEvent:Ee,emitEvent:F}=bt();function St(){const{totalGutterCssVar:i}=Te();return i}function It(){if(k.current){const d=window.getComputedStyle(k.current).getPropertyValue(`--${n}-items-per-slide`).trim();return Number(d)||1}return 1}function te(i){x.current&&($.current||j({type:"next",toIndex:i,actionType:"click"}))}function re(i){x.current&&(D.current||j({type:"prev",toIndex:i,actionType:"click"}))}function j({type:i,shouldAnimate:d=!0,toIndex:_,actionType:T}){var R,Ie;const S=!d;D.current=!1,$.current=!1;let v=ee.value.get(),C=0;if(i==="next"&&(f.current+=1),i==="prev"&&(f.current===0?f.current=e.length-1:f.current-=1),_!==void 0&&(f.current=_),i==="next"){const B=ne(r?E.current*(e.length*2):0);C=-(f.current*E.current),r&&f.current===e.length&&(f.current=0,v=v+E.current*e.length,C=0),!r&&(Math.abs(C)>=B||f.current===e.length-1)&&($.current=!0,C=-B)}i==="prev"&&(C=-(f.current*E.current),f.current===e.length-1&&(v=v-e.length*E.current),!r&&C>=0&&(D.current=!0,C=0)),L.current=C,T==="resize"?(C=-(f.current*E.current),F({eventName:"onResize",sliceActionType:T,slideDirection:i,currentItem:{index:f.current,id:((R=e.at(f.current))==null?void 0:R.id)??"",startReached:D.current,endReached:$.current}})):F({eventName:"onSlideStartChange",sliceActionType:T,slideDirection:i,nextItem:{index:f.current,id:((Ie=e.at(f.current))==null?void 0:Ie.id)??"",startReached:D.current,endReached:$.current}}),S&&(b.current.style.transform=`translate3d(calc(${C}px + var(--${n}-offset-modifier)), 0px, 0px)`),V.start({immediate:S,from:{value:v},to:{value:C},onChange({value:B}){b.current.style.transform=`translate3d(calc(${B.value}px + var(--${n}-offset-modifier)), 0px, 0px)`},onRest({finished:B}){var ke;B&&F({eventName:"onSlideChangeComplete",sliceActionType:T,slideDirection:i,currentItem:{index:f.current,id:((ke=e.at(f.current))==null?void 0:ke.id)??"",startReached:D.current,endReached:$.current}})}})}function kt(){const i=b.current;let d=0;return d=i.getBoundingClientRect()[a==="x"?"width":"height"]+St(),d}function ne(i){const d=b.current;return d[a==="x"?"scrollWidth":"scrollHeight"]-d.getBoundingClientRect()[a==="x"?"width":"height"]-i}function Te(){let i=0,d=0;if(k.current){const _=window.getComputedStyle(k.current),T=_.getPropertyValue(`--${n}-start-end-gutter`).trim();T.includes("px")&&(i=Number(T.replace("px","")));const S=_.getPropertyValue(`--${n}-gutter`).trim();S.includes("px")&&(d=Number(S.replace("px","")))}return{totalStartEndGutterCssVar:i,totalGutterCssVar:d}}m.useEffect(()=>{function i(S){const v=It();switch(S){case"start":return 0;case"middle-start":return Math.floor((v-1)*.25);case"center":return Math.floor((v-1)*.5);case"middle-end":return Math.floor((v-1)*.75);case"end":return v-1;default:return 0}}function d(){E.current=kt(),G.current=E.current/4;const{totalStartEndGutterCssVar:S}=Te();let v=0;r&&(v=E.current*e.length),v-=E.current*i(c),v-=S/2,k.current.style.setProperty(`--${n}-offset-modifier`,`${-v}px`)}function _(S){k.current&&(d(),O(!0),S&&S())}function T(){_(),j({type:"resize",toIndex:f.current,shouldAnimate:!1,actionType:"resize"})}if(t)return x.current=!0,_(u),window.addEventListener("resize",T),()=>{window.removeEventListener("resize",T)}},[t]),m.useEffect(()=>{t&&y!==f.current&&j({type:"next",toIndex:y,actionType:"resize",shouldAnimate:!1})},[t,y]);const Se=l,Ct=yt(i=>{if(!x.current)return;const d=i.dragging,_=i.offset[a==="x"?0:1],T=i.movement[a==="x"?0:1],S=T>G.current,v=T<-G.current,C=i.velocity;d&&(F({...i,eventName:"onDrag",slideActionType:"drag"}),V.start({value:_,immediate:!0,onChange({value:R}){b.current.style.transform=`translate3d(calc(${R.value}px + var(--${n}-offset-modifier)), 0px, 0px)`},config:{velocity:C}}),b.current.style.transform=`translate3d(calc(${_}px + var(--${n}-offset-modifier)), 0px, 0px)`,h&&(S||v)&&i.cancel()),i.last&&(S?(j({actionType:"drag",type:"prev"}),i.cancel()):v?(j({actionType:"drag",type:"next"}),i.cancel()):(V.start({value:L.current,onChange({value:R}){b.current.style.transform=`translate3d(calc(${R.value}px + var(--${n}-offset-modifier)), 0px, 0px)`},config:{velocity:C}}),i.cancel()))},{enabled:Se,axis:a,rubberband:!r,...r?{}:{bounds:()=>({right:0,left:-ne(0),top:-ne(0),bottom:0})},from:()=>[ee.value.get(),ee.value.get()]});function Dt(i){var d,_;return typeof i=="number"?f.current===i:((d=e.find(T=>T.id===i))==null?void 0:d.id)===((_=e[f.current])==null?void 0:_.id)}return{carouselFragment:N.jsxs("div",{ref:k,className:"ReactSpringCarouselContainer","data-part":"Container","data-part-internal":`${n}-Container`,...Ct(),children:[N.jsx("style",{dangerouslySetInnerHTML:{__html:_t(`
|
|
2
2
|
[data-part-internal="${n}-Container"] {
|
|
3
3
|
display: flex;
|
|
4
4
|
width: 100%;
|
|
@@ -44,4 +44,4 @@
|
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
`).join(""):""}
|
|
47
|
-
`)}}),N.jsx("div",{ref:
|
|
47
|
+
`)}}),N.jsx("div",{ref:b,className:"ReactSpringCarouselTrack","data-part":"Track","data-part-internal":`${n}-Track`,onScroll:()=>{D.current=!1,$.current=!1},children:Tt.map((i,d)=>N.jsx("div",{className:"ReactSpringCarouselItem","data-part":"Item","data-part-internal":`${n}-Item`,"data-id":i.id,children:typeof i.renderItem=="function"?i.renderItem({useListenToCustomEvent:Ee,index:d,isClonedItem:!!i.isClonedItem,isActiveItem:Dt}):i.renderItem},`${i.id}-${d}`))})]}),useListenToCustomEvent:Ee,slideToNextItem:()=>te(),slideToPrevItem:()=>re(),slideToItem:i=>{if(typeof i=="number"){if(!e[i]){console.warn(`The item you're trying to slide doesn't exist. index: ${i}`);return}i>f.current?te(i):re(i)}if(typeof i=="string"){const d=e.findIndex(_=>_.id===i);if(d<0){console.warn(`The item you're trying to slide doesn't exist. id: ${i}`);return}d>f.current?te(d):re(d)}}}}function xt(t){let e=0;const r=getComputedStyle(t).getPropertyValue("gap");return r.includes("px")&&(e=Number(r.replace("px",""))),e}function xe(t){return t.scrollWidth-t.clientWidth}function Z(t){const e=t.children[0],r=xt(t);return e.getBoundingClientRect().width+r}function Et({container:t,onReach:e}){const r=m.useRef("start"),n=m.useRef(0),[,s]=H.useSpring(()=>({x:0}));function o(c){s.start({from:{x:t.current.scrollLeft},to:{x:c},onChange({value:l}){t.current&&(t.current.scrollLeft=l.x)}})}function a(c){if(!t.current||c==="next"&&r.current==="end"||c==="prev"&&r.current==="start")return;let l=0;if(c==="next"&&(n.current+=1),c==="prev"&&(n.current-=1),l=n.current*Z(t.current),c==="next"){const h=xe(t.current);l>h&&(r.current="end",l=h,e&&e("end"))}c==="prev"&&l<=0&&(r.current="start",n.current=0,l=0,e&&e("start")),o(l)}return m.useEffect(()=>{function c(){var E;const O=Z(t.current),x=((E=[...t.current.children].at(0))==null?void 0:E.getBoundingClientRect().width)||0,k=Array(t.current.childElementCount).fill(0).map((D,$)=>({index:$,start:O*$,end:O*($+1)})),b=t.current.scrollLeft+x,L=k.find(D=>b>=D.start&&b<D.end);n.current=(L==null?void 0:L.index)||0}function l(){s.stop()}function h(O){const x=O.target;x.scrollLeft===0?(n.current=0,r.current="start",e&&e("start")):x.scrollLeft>=xe(x)?(r.current="end",e&&e("end")):r.current!=="idle"&&(r.current="idle",e&&e("idle"))}let u,y=0;function g(){y=t.current.scrollLeft,clearTimeout(u),u=setTimeout(function(){t.current.scrollLeft===y&&c()},200)}if(t.current)return t.current.addEventListener("wheel",l,{passive:!0}),t.current.addEventListener("scroll",h),t.current.addEventListener("scroll",g),()=>{t.current&&(t.current.removeEventListener("scroll",g),t.current.removeEventListener("scroll",h),t.current.removeEventListener("wheel",l))}},[t,e]),m.useEffect(()=>{if(t.current){const c=new ResizeObserver(()=>{o(n.current*Z(t.current))});return c.observe(t.current),()=>{c.disconnect()}}},[]),{scrollToNext(){a("next")},scrollToPrev(){a("prev")}}}A.useSpringCarousel=wt,A.useSpringScroll=Et,Object.defineProperty(A,Symbol.toStringTag,{value:"Module"})});
|