react-spring-carousel 3.0.0-beta-2.0.4 → 3.0.0-beta-2.0.42

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 CHANGED
@@ -1,80 +1,80 @@
1
- import { jsxs as Ot, jsx as X } from "react/jsx-runtime";
2
- import { useSpring as At } from "@react-spring/web";
3
- import q, { useRef as k, useEffect as Z, useState as Nt } from "react";
4
- function Mt(r, t, e) {
5
- return Math.max(t, Math.min(r, e));
1
+ import { jsxs as Lt, jsx as q } from "react/jsx-runtime";
2
+ import { useSpring as wt } from "@react-spring/web";
3
+ import J, { useRef as P, useEffect as R, useState as Mt } from "react";
4
+ function Vt(e, t, r) {
5
+ return Math.max(t, Math.min(e, r));
6
6
  }
7
- const y = {
8
- toVector(r, t) {
9
- return r === void 0 && (r = t), Array.isArray(r) ? r : [r, r];
7
+ const b = {
8
+ toVector(e, t) {
9
+ return e === void 0 && (e = t), Array.isArray(e) ? e : [e, e];
10
10
  },
11
- add(r, t) {
12
- return [r[0] + t[0], r[1] + t[1]];
11
+ add(e, t) {
12
+ return [e[0] + t[0], e[1] + t[1]];
13
13
  },
14
- sub(r, t) {
15
- return [r[0] - t[0], r[1] - t[1]];
14
+ sub(e, t) {
15
+ return [e[0] - t[0], e[1] - t[1]];
16
16
  },
17
- addTo(r, t) {
18
- r[0] += t[0], r[1] += t[1];
17
+ addTo(e, t) {
18
+ e[0] += t[0], e[1] += t[1];
19
19
  },
20
- subTo(r, t) {
21
- r[0] -= t[0], r[1] -= t[1];
20
+ subTo(e, t) {
21
+ e[0] -= t[0], e[1] -= t[1];
22
22
  }
23
23
  };
24
- function lt(r, t, e) {
25
- return t === 0 || Math.abs(t) === 1 / 0 ? Math.pow(r, e * 5) : r * t * e / (t + e * r);
24
+ function ut(e, t, r) {
25
+ return t === 0 || Math.abs(t) === 1 / 0 ? Math.pow(e, r * 5) : e * t * r / (t + r * e);
26
26
  }
27
- function ft(r, t, e, n = 0.15) {
28
- return n === 0 ? Mt(r, t, e) : r < t ? -lt(t - r, e - t, n) + t : r > e ? +lt(r - e, e - t, n) + e : r;
27
+ function lt(e, t, r, n = 0.15) {
28
+ return n === 0 ? Vt(e, t, r) : e < t ? -ut(t - e, r - t, n) + t : e > r ? +ut(e - r, r - t, n) + r : e;
29
29
  }
30
- function Rt(r, [t, e], [n, s]) {
31
- const [[o, a], [u, h]] = r;
32
- return [ft(t, o, a, n), ft(e, u, h, s)];
30
+ function Rt(e, [t, r], [n, s]) {
31
+ const [[o, a], [c, l]] = e;
32
+ return [lt(t, o, a, n), lt(r, c, l, s)];
33
33
  }
34
- function Vt(r, t) {
35
- if (typeof r != "object" || r === null) return r;
36
- var e = r[Symbol.toPrimitive];
37
- if (e !== void 0) {
38
- var n = e.call(r, t);
34
+ function jt(e, t) {
35
+ if (typeof e != "object" || e === null) return e;
36
+ var r = e[Symbol.toPrimitive];
37
+ if (r !== void 0) {
38
+ var n = r.call(e, t);
39
39
  if (typeof n != "object") return n;
40
40
  throw new TypeError("@@toPrimitive must return a primitive value.");
41
41
  }
42
- return (t === "string" ? String : Number)(r);
42
+ return (t === "string" ? String : Number)(e);
43
43
  }
44
- function Lt(r) {
45
- var t = Vt(r, "string");
44
+ function Bt(e) {
45
+ var t = jt(e, "string");
46
46
  return typeof t == "symbol" ? t : String(t);
47
47
  }
48
- function w(r, t, e) {
49
- return t = Lt(t), t in r ? Object.defineProperty(r, t, {
50
- value: e,
48
+ function S(e, t, r) {
49
+ return t = Bt(t), t in e ? Object.defineProperty(e, t, {
50
+ value: r,
51
51
  enumerable: !0,
52
52
  configurable: !0,
53
53
  writable: !0
54
- }) : r[t] = e, r;
54
+ }) : e[t] = r, e;
55
55
  }
56
- function dt(r, t) {
57
- var e = Object.keys(r);
56
+ function ft(e, t) {
57
+ var r = Object.keys(e);
58
58
  if (Object.getOwnPropertySymbols) {
59
- var n = Object.getOwnPropertySymbols(r);
59
+ var n = Object.getOwnPropertySymbols(e);
60
60
  t && (n = n.filter(function(s) {
61
- return Object.getOwnPropertyDescriptor(r, s).enumerable;
62
- })), e.push.apply(e, n);
61
+ return Object.getOwnPropertyDescriptor(e, s).enumerable;
62
+ })), r.push.apply(r, n);
63
63
  }
64
- return e;
64
+ return r;
65
65
  }
66
- function d(r) {
66
+ function p(e) {
67
67
  for (var t = 1; t < arguments.length; t++) {
68
- var e = arguments[t] != null ? arguments[t] : {};
69
- t % 2 ? dt(Object(e), !0).forEach(function(n) {
70
- w(r, n, e[n]);
71
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(r, Object.getOwnPropertyDescriptors(e)) : dt(Object(e)).forEach(function(n) {
72
- Object.defineProperty(r, n, Object.getOwnPropertyDescriptor(e, n));
68
+ var r = arguments[t] != null ? arguments[t] : {};
69
+ t % 2 ? ft(Object(r), !0).forEach(function(n) {
70
+ S(e, n, r[n]);
71
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(r)) : ft(Object(r)).forEach(function(n) {
72
+ Object.defineProperty(e, n, Object.getOwnPropertyDescriptor(r, n));
73
73
  });
74
74
  }
75
- return r;
75
+ return e;
76
76
  }
77
- const wt = {
77
+ const Et = {
78
78
  pointer: {
79
79
  start: "down",
80
80
  change: "move",
@@ -96,73 +96,73 @@ const wt = {
96
96
  end: "end"
97
97
  }
98
98
  };
99
- function ht(r) {
100
- return r ? r[0].toUpperCase() + r.slice(1) : "";
99
+ function dt(e) {
100
+ return e ? e[0].toUpperCase() + e.slice(1) : "";
101
101
  }
102
- const jt = ["enter", "leave"];
103
- function Ut(r = !1, t) {
104
- return r && !jt.includes(t);
102
+ const Ut = ["enter", "leave"];
103
+ function Kt(e = !1, t) {
104
+ return e && !Ut.includes(t);
105
105
  }
106
- function Kt(r, t = "", e = !1) {
107
- const n = wt[r], s = n && n[t] || t;
108
- return "on" + ht(r) + ht(s) + (Ut(e, s) ? "Capture" : "");
106
+ function Gt(e, t = "", r = !1) {
107
+ const n = Et[e], s = n && n[t] || t;
108
+ return "on" + dt(e) + dt(s) + (Kt(r, s) ? "Capture" : "");
109
109
  }
110
- const Bt = ["gotpointercapture", "lostpointercapture"];
111
- function zt(r) {
112
- let t = r.substring(2).toLowerCase();
113
- const e = !!~t.indexOf("passive");
114
- e && (t = t.replace("passive", ""));
115
- const n = Bt.includes(t) ? "capturecapture" : "capture", s = !!~t.indexOf(n);
110
+ const zt = ["gotpointercapture", "lostpointercapture"];
111
+ function Wt(e) {
112
+ let t = e.substring(2).toLowerCase();
113
+ const r = !!~t.indexOf("passive");
114
+ r && (t = t.replace("passive", ""));
115
+ const n = zt.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
- passive: e
119
+ passive: r
120
120
  };
121
121
  }
122
- function Gt(r, t = "") {
123
- const e = wt[r], n = e && e[t] || t;
124
- return r + n;
122
+ function Yt(e, t = "") {
123
+ const r = Et[e], n = r && r[t] || t;
124
+ return e + n;
125
125
  }
126
- function G(r) {
127
- return "touches" in r;
126
+ function W(e) {
127
+ return "touches" in e;
128
128
  }
129
- function Et(r) {
130
- return G(r) ? "touch" : "pointerType" in r ? r.pointerType : "mouse";
129
+ function Tt(e) {
130
+ return W(e) ? "touch" : "pointerType" in e ? e.pointerType : "mouse";
131
131
  }
132
- function Yt(r) {
133
- return Array.from(r.touches).filter((t) => {
134
- var e, n;
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));
132
+ function Ft(e) {
133
+ return Array.from(e.touches).filter((t) => {
134
+ var r, n;
135
+ return t.target === e.currentTarget || ((r = e.currentTarget) === null || r === void 0 || (n = r.contains) === null || n === void 0 ? void 0 : n.call(r, t.target));
136
136
  });
137
137
  }
138
- function Ft(r) {
139
- return r.type === "touchend" || r.type === "touchcancel" ? r.changedTouches : r.targetTouches;
138
+ function Ht(e) {
139
+ return e.type === "touchend" || e.type === "touchcancel" ? e.changedTouches : e.targetTouches;
140
140
  }
141
- function Tt(r) {
142
- return G(r) ? Ft(r)[0] : r;
141
+ function St(e) {
142
+ return W(e) ? Ht(e)[0] : e;
143
143
  }
144
- function Wt(r) {
145
- return Yt(r).map((t) => t.identifier);
144
+ function Xt(e) {
145
+ return Ft(e).map((t) => t.identifier);
146
146
  }
147
- function J(r) {
148
- const t = Tt(r);
149
- return G(r) ? t.identifier : t.pointerId;
147
+ function Q(e) {
148
+ const t = St(e);
149
+ return W(e) ? t.identifier : t.pointerId;
150
150
  }
151
- function pt(r) {
152
- const t = Tt(r);
151
+ function ht(e) {
152
+ const t = St(e);
153
153
  return [t.clientX, t.clientY];
154
154
  }
155
- function Ht(r) {
155
+ function qt(e) {
156
156
  const t = {};
157
- if ("buttons" in r && (t.buttons = r.buttons), "shiftKey" in r) {
157
+ if ("buttons" in e && (t.buttons = e.buttons), "shiftKey" in e) {
158
158
  const {
159
- shiftKey: e,
159
+ shiftKey: r,
160
160
  altKey: n,
161
161
  metaKey: s,
162
162
  ctrlKey: o
163
- } = r;
163
+ } = e;
164
164
  Object.assign(t, {
165
- shiftKey: e,
165
+ shiftKey: r,
166
166
  altKey: n,
167
167
  metaKey: s,
168
168
  ctrlKey: o
@@ -170,26 +170,26 @@ function Ht(r) {
170
170
  }
171
171
  return t;
172
172
  }
173
- function z(r, ...t) {
174
- return typeof r == "function" ? r(...t) : r;
173
+ function z(e, ...t) {
174
+ return typeof e == "function" ? e(...t) : e;
175
175
  }
176
- function Xt() {
176
+ function Jt() {
177
177
  }
178
- function qt(...r) {
179
- return r.length === 0 ? Xt : r.length === 1 ? r[0] : function() {
178
+ function Qt(...e) {
179
+ return e.length === 0 ? Jt : e.length === 1 ? e[0] : function() {
180
180
  let t;
181
- for (const e of r)
182
- t = e.apply(this, arguments) || t;
181
+ for (const r of e)
182
+ t = r.apply(this, arguments) || t;
183
183
  return t;
184
184
  };
185
185
  }
186
- function mt(r, t) {
187
- return Object.assign({}, t, r || {});
186
+ function pt(e, t) {
187
+ return Object.assign({}, t, e || {});
188
188
  }
189
- const Jt = 32;
190
- class Qt {
191
- constructor(t, e, n) {
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());
189
+ const Zt = 32;
190
+ class te {
191
+ constructor(t, r, n) {
192
+ this.ctrl = t, this.args = r, this.key = n, this.state || (this.state = {}, this.computeValues([0, 0]), this.computeInitial(), this.init && this.init(), this.reset());
193
193
  }
194
194
  get state() {
195
195
  return this.ctrl.state[this.key];
@@ -218,19 +218,19 @@ class Qt {
218
218
  reset() {
219
219
  const {
220
220
  state: t,
221
- shared: e,
221
+ shared: r,
222
222
  ingKey: n,
223
223
  args: s
224
224
  } = this;
225
- e[n] = t._active = t.active = t._blocked = t._force = !1, t._step = [!1, !1], t.intentional = !1, t._movement = [0, 0], t._distance = [0, 0], t._direction = [0, 0], t._delta = [0, 0], t._bounds = [[-1 / 0, 1 / 0], [-1 / 0, 1 / 0]], t.args = s, t.axis = void 0, t.memo = void 0, t.elapsedTime = t.timeDelta = 0, t.direction = [0, 0], t.distance = [0, 0], t.overflow = [0, 0], t._movementBound = [!1, !1], t.velocity = [0, 0], t.movement = [0, 0], t.delta = [0, 0], t.timeStamp = 0;
225
+ r[n] = t._active = t.active = t._blocked = t._force = !1, t._step = [!1, !1], t.intentional = !1, t._movement = [0, 0], t._distance = [0, 0], t._direction = [0, 0], t._delta = [0, 0], t._bounds = [[-1 / 0, 1 / 0], [-1 / 0, 1 / 0]], t.args = s, t.axis = void 0, t.memo = void 0, t.elapsedTime = t.timeDelta = 0, t.direction = [0, 0], t.distance = [0, 0], t.overflow = [0, 0], t._movementBound = [!1, !1], t.velocity = [0, 0], t.movement = [0, 0], t.delta = [0, 0], t.timeStamp = 0;
226
226
  }
227
227
  start(t) {
228
- const e = this.state, n = this.config;
229
- e._active || (this.reset(), this.computeInitial(), e._active = !0, e.target = t.target, e.currentTarget = t.currentTarget, e.lastOffset = n.from ? z(n.from, e) : e.offset, e.offset = e.lastOffset, e.startTime = e.timeStamp = t.timeStamp);
228
+ const r = this.state, n = this.config;
229
+ r._active || (this.reset(), this.computeInitial(), r._active = !0, r.target = t.target, r.currentTarget = t.currentTarget, r.lastOffset = n.from ? z(n.from, r) : r.offset, r.offset = r.lastOffset, r.startTime = r.timeStamp = t.timeStamp);
230
230
  }
231
231
  computeValues(t) {
232
- const e = this.state;
233
- e._values = t, e.values = this.config.transform(t);
232
+ const r = this.state;
233
+ r._values = t, r.values = this.config.transform(t);
234
234
  }
235
235
  computeInitial() {
236
236
  const t = this.state;
@@ -238,44 +238,44 @@ class Qt {
238
238
  }
239
239
  compute(t) {
240
240
  const {
241
- state: e,
241
+ state: r,
242
242
  config: n,
243
243
  shared: s
244
244
  } = this;
245
- e.args = this.args;
245
+ r.args = this.args;
246
246
  let o = 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, Ht(t)), s.down = s.pressed = s.buttons % 2 === 1 || s.touches > 0, o = 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
- y.addTo(e._distance, f);
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, qt(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
+ const d = r._delta.map(Math.abs);
249
+ b.addTo(r._distance, d);
250
250
  }
251
251
  this.axisIntent && this.axisIntent(t);
252
- const [a, u] = e._movement, [h, p] = n.threshold, {
253
- _step: c,
254
- values: b
255
- } = e;
256
- if (n.hasCustomTransform ? (c[0] === !1 && (c[0] = Math.abs(a) >= h && b[0]), c[1] === !1 && (c[1] = Math.abs(u) >= p && b[1])) : (c[0] === !1 && (c[0] = Math.abs(a) >= h && Math.sign(a) * h), c[1] === !1 && (c[1] = Math.abs(u) >= p && Math.sign(u) * p)), e.intentional = c[0] !== !1 || c[1] !== !1, !e.intentional) return;
257
- const g = [0, 0];
252
+ const [a, c] = r._movement, [l, h] = n.threshold, {
253
+ _step: u,
254
+ values: g
255
+ } = r;
256
+ if (n.hasCustomTransform ? (u[0] === !1 && (u[0] = Math.abs(a) >= l && g[0]), u[1] === !1 && (u[1] = Math.abs(c) >= h && g[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;
257
+ const m = [0, 0];
258
258
  if (n.hasCustomTransform) {
259
- const [f, V] = b;
260
- g[0] = c[0] !== !1 ? f - c[0] : 0, g[1] = c[1] !== !1 ? V - c[1] : 0;
259
+ const [d, V] = g;
260
+ m[0] = u[0] !== !1 ? d - u[0] : 0, m[1] = u[1] !== !1 ? V - u[1] : 0;
261
261
  } else
262
- g[0] = c[0] !== !1 ? a - c[0] : 0, g[1] = c[1] !== !1 ? u - c[1] : 0;
263
- this.restrictToAxis && !e._blocked && this.restrictToAxis(g);
264
- const O = e.offset, D = e._active && !e._blocked || e.active;
265
- D && (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 = z(n.bounds, e)), this.setup && this.setup()), e.movement = g, this.computeOffset()));
266
- const [E, $] = e.offset, [[A, x], [C, P]] = e._bounds;
267
- e.overflow = [E < A ? -1 : E > x ? 1 : 0, $ < C ? -1 : $ > P ? 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
- const R = e._active ? n.rubberband || [0, 0] : [0, 0];
269
- if (e.offset = Rt(e._bounds, e.offset, R), e.delta = y.sub(e.offset, O), this.computeMovement(), D && (!e.last || o > Jt)) {
270
- e.delta = y.sub(e.offset, O);
271
- const f = e.delta.map(Math.abs);
272
- y.addTo(e.distance, f), e.direction = e.delta.map(Math.sign), e._direction = e._delta.map(Math.sign), !e.first && o > 0 && (e.velocity = [f[0] / o, f[1] / o], e.timeDelta = o);
262
+ m[0] = u[0] !== !1 ? a - u[0] : 0, m[1] = u[1] !== !1 ? c - u[1] : 0;
263
+ this.restrictToAxis && !r._blocked && this.restrictToAxis(m);
264
+ const D = r.offset, _ = r._active && !r._blocked || r.active;
265
+ _ && (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 = z(n.bounds, r)), this.setup && this.setup()), r.movement = m, this.computeOffset()));
266
+ const [w, O] = r.offset, [[A, E], [x, I]] = r._bounds;
267
+ r.overflow = [w < A ? -1 : w > E ? 1 : 0, O < x ? -1 : O > I ? 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
+ const M = r._active ? n.rubberband || [0, 0] : [0, 0];
269
+ if (r.offset = Rt(r._bounds, r.offset, M), r.delta = b.sub(r.offset, D), this.computeMovement(), _ && (!r.last || o > Zt)) {
270
+ r.delta = b.sub(r.offset, D);
271
+ const d = r.delta.map(Math.abs);
272
+ b.addTo(r.distance, d), r.direction = r.delta.map(Math.sign), r._direction = r._delta.map(Math.sign), !r.first && o > 0 && (r.velocity = [d[0] / o, d[1] / o], r.timeDelta = o);
273
273
  }
274
274
  }
275
275
  emit() {
276
- const t = this.state, e = this.shared, n = this.config;
276
+ const t = this.state, r = this.shared, n = this.config;
277
277
  if (t._active || this.clean(), (t._blocked || !t.intentional) && !t._force && !n.triggerAllEvents) return;
278
- const s = this.handler(d(d(d({}, e), t), {}, {
278
+ const s = this.handler(p(p(p({}, r), t), {}, {
279
279
  [this.aliasKey]: t.values
280
280
  }));
281
281
  s !== void 0 && (t.memo = s);
@@ -284,16 +284,16 @@ class Qt {
284
284
  this.eventStore.clean(), this.timeoutStore.clean();
285
285
  }
286
286
  }
287
- function Zt([r, t], e) {
288
- const n = Math.abs(r), s = Math.abs(t);
289
- if (n > s && n > e)
287
+ function ee([e, t], r) {
288
+ const n = Math.abs(e), s = Math.abs(t);
289
+ if (n > s && n > r)
290
290
  return "x";
291
- if (s > n && s > e)
291
+ if (s > n && s > r)
292
292
  return "y";
293
293
  }
294
- class te extends Qt {
294
+ class re extends te {
295
295
  constructor(...t) {
296
- super(...t), w(this, "aliasKey", "xy");
296
+ super(...t), S(this, "aliasKey", "xy");
297
297
  }
298
298
  reset() {
299
299
  super.reset(), this.state.axis = void 0;
@@ -302,18 +302,18 @@ class te extends Qt {
302
302
  this.state.offset = [0, 0], this.state.lastOffset = [0, 0];
303
303
  }
304
304
  computeOffset() {
305
- this.state.offset = y.add(this.state.lastOffset, this.state.movement);
305
+ this.state.offset = b.add(this.state.lastOffset, this.state.movement);
306
306
  }
307
307
  computeMovement() {
308
- this.state.movement = y.sub(this.state.offset, this.state.lastOffset);
308
+ this.state.movement = b.sub(this.state.offset, this.state.lastOffset);
309
309
  }
310
310
  axisIntent(t) {
311
- const e = this.state, n = this.config;
312
- if (!e.axis && t) {
313
- const s = typeof n.axisThreshold == "object" ? n.axisThreshold[Et(t)] : n.axisThreshold;
314
- e.axis = Zt(e._movement, s);
311
+ const r = this.state, n = this.config;
312
+ if (!r.axis && t) {
313
+ const s = typeof n.axisThreshold == "object" ? n.axisThreshold[Tt(t)] : n.axisThreshold;
314
+ r.axis = ee(r._movement, s);
315
315
  }
316
- e._blocked = (n.lockDirection || !!n.axis) && !e.axis || !!n.axis && n.axis !== e.axis;
316
+ r._blocked = (n.lockDirection || !!n.axis) && !r.axis || !!n.axis && n.axis !== r.axis;
317
317
  }
318
318
  restrictToAxis(t) {
319
319
  if (this.config.axis || this.config.lockDirection)
@@ -327,98 +327,98 @@ class te extends Qt {
327
327
  }
328
328
  }
329
329
  }
330
- const gt = (r) => r, vt = 0.15, et = {
331
- enabled(r = !0) {
332
- return r;
330
+ const mt = (e) => e, gt = 0.15, rt = {
331
+ enabled(e = !0) {
332
+ return e;
333
333
  },
334
- eventOptions(r, t, e) {
335
- return d(d({}, e.shared.eventOptions), r);
334
+ eventOptions(e, t, r) {
335
+ return p(p({}, r.shared.eventOptions), e);
336
336
  },
337
- preventDefault(r = !1) {
338
- return r;
337
+ preventDefault(e = !1) {
338
+ return e;
339
339
  },
340
- triggerAllEvents(r = !1) {
341
- return r;
340
+ triggerAllEvents(e = !1) {
341
+ return e;
342
342
  },
343
- rubberband(r = 0) {
344
- switch (r) {
343
+ rubberband(e = 0) {
344
+ switch (e) {
345
345
  case !0:
346
- return [vt, vt];
346
+ return [gt, gt];
347
347
  case !1:
348
348
  return [0, 0];
349
349
  default:
350
- return y.toVector(r);
350
+ return b.toVector(e);
351
351
  }
352
352
  },
353
- from(r) {
354
- if (typeof r == "function") return r;
355
- if (r != null) return y.toVector(r);
353
+ from(e) {
354
+ if (typeof e == "function") return e;
355
+ if (e != null) return b.toVector(e);
356
356
  },
357
- transform(r, t, e) {
358
- const n = r || e.shared.transform;
357
+ transform(e, t, r) {
358
+ const n = e || r.shared.transform;
359
359
  if (this.hasCustomTransform = !!n, process.env.NODE_ENV === "development") {
360
- const s = n || gt;
360
+ const s = n || mt;
361
361
  return (o) => {
362
362
  const a = s(o);
363
363
  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;
364
364
  };
365
365
  }
366
- return n || gt;
366
+ return n || mt;
367
367
  },
368
- threshold(r) {
369
- return y.toVector(r, 0);
368
+ threshold(e) {
369
+ return b.toVector(e, 0);
370
370
  }
371
371
  };
372
- process.env.NODE_ENV === "development" && Object.assign(et, {
373
- domTarget(r) {
374
- if (r !== void 0)
372
+ process.env.NODE_ENV === "development" && Object.assign(rt, {
373
+ domTarget(e) {
374
+ if (e !== void 0)
375
375
  throw Error("[@use-gesture]: `domTarget` option has been renamed to `target`.");
376
376
  return NaN;
377
377
  },
378
- lockDirection(r) {
379
- if (r !== void 0)
378
+ lockDirection(e) {
379
+ if (e !== void 0)
380
380
  throw Error("[@use-gesture]: `lockDirection` option has been merged with `axis`. Use it as in `{ axis: 'lock' }`");
381
381
  return NaN;
382
382
  },
383
- initial(r) {
384
- if (r !== void 0)
383
+ initial(e) {
384
+ if (e !== void 0)
385
385
  throw Error("[@use-gesture]: `initial` option has been renamed to `from`.");
386
386
  return NaN;
387
387
  }
388
388
  });
389
- const ee = 0, L = d(d({}, et), {}, {
390
- axis(r, t, {
391
- axis: e
389
+ const ne = 0, j = p(p({}, rt), {}, {
390
+ axis(e, t, {
391
+ axis: r
392
392
  }) {
393
- if (this.lockDirection = e === "lock", !this.lockDirection) return e;
393
+ if (this.lockDirection = r === "lock", !this.lockDirection) return r;
394
394
  },
395
- axisThreshold(r = ee) {
396
- return r;
395
+ axisThreshold(e = ne) {
396
+ return e;
397
397
  },
398
- bounds(r = {}) {
399
- if (typeof r == "function")
400
- return (o) => L.bounds(r(o));
401
- if ("current" in r)
402
- return () => r.current;
403
- if (typeof HTMLElement == "function" && r instanceof HTMLElement)
404
- return r;
398
+ bounds(e = {}) {
399
+ if (typeof e == "function")
400
+ return (o) => j.bounds(e(o));
401
+ if ("current" in e)
402
+ return () => e.current;
403
+ if (typeof HTMLElement == "function" && e instanceof HTMLElement)
404
+ return e;
405
405
  const {
406
406
  left: t = -1 / 0,
407
- right: e = 1 / 0,
407
+ right: r = 1 / 0,
408
408
  top: n = -1 / 0,
409
409
  bottom: s = 1 / 0
410
- } = r;
411
- return [[t, e], [n, s]];
410
+ } = e;
411
+ return [[t, r], [n, s]];
412
412
  }
413
- }), yt = {
414
- ArrowRight: (r, t = 1) => [r * t, 0],
415
- ArrowLeft: (r, t = 1) => [-1 * r * t, 0],
416
- ArrowUp: (r, t = 1) => [0, -1 * r * t],
417
- ArrowDown: (r, t = 1) => [0, r * t]
413
+ }), vt = {
414
+ ArrowRight: (e, t = 1) => [e * t, 0],
415
+ ArrowLeft: (e, t = 1) => [-1 * e * t, 0],
416
+ ArrowUp: (e, t = 1) => [0, -1 * e * t],
417
+ ArrowDown: (e, t = 1) => [0, e * t]
418
418
  };
419
- class re extends te {
419
+ class se extends re {
420
420
  constructor(...t) {
421
- super(...t), w(this, "ingKey", "dragging");
421
+ super(...t), S(this, "ingKey", "dragging");
422
422
  }
423
423
  reset() {
424
424
  super.reset();
@@ -428,13 +428,13 @@ class re extends te {
428
428
  setup() {
429
429
  const t = this.state;
430
430
  if (t._bounds instanceof HTMLElement) {
431
- const e = t._bounds.getBoundingClientRect(), n = t.currentTarget.getBoundingClientRect(), s = {
432
- left: e.left - n.left + t.offset[0],
433
- right: e.right - n.right + t.offset[0],
434
- top: e.top - n.top + t.offset[1],
435
- bottom: e.bottom - n.bottom + t.offset[1]
431
+ const r = t._bounds.getBoundingClientRect(), n = t.currentTarget.getBoundingClientRect(), s = {
432
+ left: r.left - n.left + t.offset[0],
433
+ right: r.right - n.right + t.offset[0],
434
+ top: r.top - n.top + t.offset[1],
435
+ bottom: r.bottom - n.bottom + t.offset[1]
436
436
  };
437
- t._bounds = L.bounds(s);
437
+ t._bounds = j.bounds(s);
438
438
  }
439
439
  }
440
440
  cancel() {
@@ -450,29 +450,29 @@ class re extends te {
450
450
  this.pointerClean(), this.state._pointerActive = !1, this.state._keyboardActive = !1, super.clean();
451
451
  }
452
452
  pointerDown(t) {
453
- const e = this.config, n = this.state;
454
- if (t.buttons != null && (Array.isArray(e.pointerButtons) ? !e.pointerButtons.includes(t.buttons) : e.pointerButtons !== -1 && e.pointerButtons !== t.buttons)) return;
453
+ const r = this.config, n = this.state;
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
- e.pointerCapture && t.target.setPointerCapture(t.pointerId), !(s && s.size > 1 && n._pointerActive) && (this.start(t), this.setupPointer(t), n._pointerId = J(t), n._pointerActive = !0, this.computeValues(pt(t)), this.computeInitial(), e.preventScrollAxis && Et(t) !== "mouse" ? (n._active = !1, this.setupScrollPrevention(t)) : e.delay > 0 ? (this.setupDelayTrigger(t), e.triggerAllEvents && (this.compute(t), this.emit())) : this.startPointerDrag(t));
456
+ r.pointerCapture && t.target.setPointerCapture(t.pointerId), !(s && s.size > 1 && n._pointerActive) && (this.start(t), this.setupPointer(t), n._pointerId = Q(t), n._pointerActive = !0, this.computeValues(ht(t)), this.computeInitial(), r.preventScrollAxis && Tt(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
- const e = this.state;
460
- e._active = !0, e._preventScroll = !0, e._delayed = !1, this.compute(t), this.emit();
459
+ const r = this.state;
460
+ r._active = !0, r._preventScroll = !0, r._delayed = !1, this.compute(t), this.emit();
461
461
  }
462
462
  pointerMove(t) {
463
- const e = this.state, n = this.config;
464
- if (!e._pointerActive) return;
465
- const s = J(t);
466
- if (e._pointerId !== void 0 && s !== e._pointerId) return;
467
- const o = pt(t);
468
- if (document.pointerLockElement === t.target ? e._delta = [t.movementX, t.movementY] : (e._delta = y.sub(o, e._values), this.computeValues(o)), y.addTo(e._movement, e._delta), this.compute(t), e._delayed && e.intentional) {
469
- this.timeoutStore.remove("dragDelay"), e.active = !1, this.startPointerDrag(t);
463
+ const r = this.state, n = this.config;
464
+ if (!r._pointerActive) return;
465
+ const s = Q(t);
466
+ if (r._pointerId !== void 0 && s !== r._pointerId) return;
467
+ const o = ht(t);
468
+ if (document.pointerLockElement === t.target ? r._delta = [t.movementX, t.movementY] : (r._delta = b.sub(o, r._values), this.computeValues(o)), b.addTo(r._movement, r._delta), this.compute(t), r._delayed && r.intentional) {
469
+ this.timeoutStore.remove("dragDelay"), r.active = !1, this.startPointerDrag(t);
470
470
  return;
471
471
  }
472
- if (n.preventScrollAxis && !e._preventScroll)
473
- if (e.axis)
474
- if (e.axis === n.preventScrollAxis || n.preventScrollAxis === "xy") {
475
- e._active = !1, this.clean();
472
+ if (n.preventScrollAxis && !r._preventScroll)
473
+ if (r.axis)
474
+ if (r.axis === n.preventScrollAxis || n.preventScrollAxis === "xy") {
475
+ r._active = !1, this.clean();
476
476
  return;
477
477
  } else {
478
478
  this.timeoutStore.remove("startPointerDrag"), this.startPointerDrag(t);
@@ -489,19 +489,19 @@ class re extends te {
489
489
  } catch {
490
490
  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.");
491
491
  }
492
- const e = this.state, n = this.config;
493
- if (!e._active || !e._pointerActive) return;
494
- const s = J(t);
495
- if (e._pointerId !== void 0 && s !== e._pointerId) return;
492
+ const r = this.state, n = this.config;
493
+ if (!r._active || !r._pointerActive) return;
494
+ const s = Q(t);
495
+ if (r._pointerId !== void 0 && s !== r._pointerId) return;
496
496
  this.state._pointerActive = !1, this.setActive(), this.compute(t);
497
- const [o, a] = e._distance;
498
- if (e.tap = o <= n.tapsThreshold && a <= n.tapsThreshold, e.tap && n.filterTaps)
499
- e._force = !0;
497
+ const [o, a] = r._distance;
498
+ if (r.tap = o <= n.tapsThreshold && a <= n.tapsThreshold, r.tap && n.filterTaps)
499
+ r._force = !0;
500
500
  else {
501
- const [u, h] = e._delta, [p, c] = e._movement, [b, g] = n.swipe.velocity, [O, D] = n.swipe.distance, E = n.swipe.duration;
502
- if (e.elapsedTime < E) {
503
- const $ = Math.abs(u / e.timeDelta), A = Math.abs(h / e.timeDelta);
504
- $ > b && Math.abs(p) > O && (e.swipe[0] = Math.sign(u)), A > g && Math.abs(c) > D && (e.swipe[1] = Math.sign(h));
501
+ const [c, l] = r._delta, [h, u] = r._movement, [g, m] = n.swipe.velocity, [D, _] = n.swipe.distance, w = n.swipe.duration;
502
+ if (r.elapsedTime < w) {
503
+ const O = Math.abs(c / r.timeDelta), A = Math.abs(l / r.timeDelta);
504
+ O > g && Math.abs(h) > D && (r.swipe[0] = Math.sign(c)), A > m && Math.abs(u) > _ && (r.swipe[1] = Math.sign(l));
505
505
  }
506
506
  }
507
507
  this.emit();
@@ -510,16 +510,16 @@ class re extends te {
510
510
  !this.state.tap && t.detail > 0 && (t.preventDefault(), t.stopPropagation());
511
511
  }
512
512
  setupPointer(t) {
513
- const e = this.config, n = e.device;
513
+ const r = this.config, n = r.device;
514
514
  if (process.env.NODE_ENV === "development")
515
515
  try {
516
- if (n === "pointer" && e.preventScrollDelay === void 0) {
516
+ if (n === "pointer" && r.preventScrollDelay === void 0) {
517
517
  const s = "uv" in t ? t.sourceEvent.currentTarget : t.currentTarget;
518
518
  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);
519
519
  }
520
520
  } catch {
521
521
  }
522
- e.pointerLock && t.currentTarget.requestPointerLock(), e.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)));
522
+ r.pointerLock && t.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)));
523
523
  }
524
524
  pointerClean() {
525
525
  this.config.pointerLock && document.pointerLockElement === this.state.currentTarget && document.exitPointerLock();
@@ -528,11 +528,11 @@ class re extends te {
528
528
  this.state._preventScroll && t.cancelable && t.preventDefault();
529
529
  }
530
530
  setupScrollPrevention(t) {
531
- this.state._preventScroll = !1, ne(t);
532
- const e = this.eventStore.add(this.sharedConfig.window, "touch", "change", this.preventScroll.bind(this), {
531
+ this.state._preventScroll = !1, ie(t);
532
+ const r = this.eventStore.add(this.sharedConfig.window, "touch", "change", this.preventScroll.bind(this), {
533
533
  passive: !1
534
534
  });
535
- this.eventStore.add(this.sharedConfig.window, "touch", "end", e), this.eventStore.add(this.sharedConfig.window, "touch", "cancel", e), this.timeoutStore.add("startPointerDrag", this.startPointerDrag.bind(this), this.config.preventScrollDelay, t);
535
+ 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, t);
536
536
  }
537
537
  setupDelayTrigger(t) {
538
538
  this.state._delayed = !0, this.timeoutStore.add("dragDelay", () => {
@@ -540,351 +540,351 @@ class re extends te {
540
540
  }, this.config.delay);
541
541
  }
542
542
  keyDown(t) {
543
- const e = yt[t.key];
544
- if (e) {
543
+ const r = vt[t.key];
544
+ if (r) {
545
545
  const n = this.state, s = t.shiftKey ? 10 : t.altKey ? 0.1 : 1;
546
- this.start(t), n._delta = e(this.config.keyboardDisplacement, s), n._keyboardActive = !0, y.addTo(n._movement, n._delta), this.compute(t), this.emit();
546
+ this.start(t), n._delta = r(this.config.keyboardDisplacement, s), n._keyboardActive = !0, b.addTo(n._movement, n._delta), this.compute(t), this.emit();
547
547
  }
548
548
  }
549
549
  keyUp(t) {
550
- t.key in yt && (this.state._keyboardActive = !1, this.setActive(), this.compute(t), this.emit());
550
+ t.key in vt && (this.state._keyboardActive = !1, this.setActive(), this.compute(t), this.emit());
551
551
  }
552
552
  bind(t) {
553
- const e = this.config.device;
554
- t(e, "start", this.pointerDown.bind(this)), this.config.pointerCapture && (t(e, "change", this.pointerMove.bind(this)), t(e, "end", this.pointerUp.bind(this)), t(e, "cancel", this.pointerUp.bind(this)), t("lostPointerCapture", "", this.pointerUp.bind(this))), this.config.keys && (t("key", "down", this.keyDown.bind(this)), t("key", "up", this.keyUp.bind(this))), this.config.filterTaps && t("click", "", this.pointerClick.bind(this), {
553
+ const r = this.config.device;
554
+ t(r, "start", this.pointerDown.bind(this)), this.config.pointerCapture && (t(r, "change", this.pointerMove.bind(this)), t(r, "end", this.pointerUp.bind(this)), t(r, "cancel", this.pointerUp.bind(this)), t("lostPointerCapture", "", this.pointerUp.bind(this))), this.config.keys && (t("key", "down", this.keyDown.bind(this)), t("key", "up", this.keyUp.bind(this))), this.config.filterTaps && t("click", "", this.pointerClick.bind(this), {
555
555
  capture: !0,
556
556
  passive: !1
557
557
  });
558
558
  }
559
559
  }
560
- function ne(r) {
561
- "persist" in r && typeof r.persist == "function" && r.persist();
560
+ function ie(e) {
561
+ "persist" in e && typeof e.persist == "function" && e.persist();
562
562
  }
563
- const j = typeof window < "u" && window.document && window.document.createElement;
564
- function St() {
565
- return j && "ontouchstart" in window;
566
- }
567
- function se() {
568
- return St() || j && window.navigator.maxTouchPoints > 1;
569
- }
570
- function ie() {
571
- return j && "onpointerdown" in window;
563
+ const B = typeof window < "u" && window.document && window.document.createElement;
564
+ function xt() {
565
+ return B && "ontouchstart" in window;
572
566
  }
573
567
  function oe() {
574
- return j && "exitPointerLock" in window.document;
568
+ return xt() || B && window.navigator.maxTouchPoints > 1;
575
569
  }
576
570
  function ae() {
571
+ return B && "onpointerdown" in window;
572
+ }
573
+ function ce() {
574
+ return B && "exitPointerLock" in window.document;
575
+ }
576
+ function ue() {
577
577
  try {
578
578
  return "constructor" in GestureEvent;
579
579
  } catch {
580
580
  return !1;
581
581
  }
582
582
  }
583
- const I = {
584
- isBrowser: j,
585
- gesture: ae(),
586
- touch: St(),
587
- touchscreen: se(),
588
- pointer: ie(),
589
- pointerLock: oe()
590
- }, ce = 250, ue = 180, le = 0.5, fe = 50, de = 250, he = 10, bt = {
583
+ const $ = {
584
+ isBrowser: B,
585
+ gesture: ue(),
586
+ touch: xt(),
587
+ touchscreen: oe(),
588
+ pointer: ae(),
589
+ pointerLock: ce()
590
+ }, le = 250, fe = 180, de = 0.5, he = 50, pe = 250, me = 10, yt = {
591
591
  mouse: 0,
592
592
  touch: 0,
593
593
  pen: 8
594
- }, xt = d(d({}, L), {}, {
595
- device(r, t, {
594
+ }, It = p(p({}, j), {}, {
595
+ device(e, t, {
596
596
  pointer: {
597
- touch: e = !1,
597
+ touch: r = !1,
598
598
  lock: n = !1,
599
599
  mouse: s = !1
600
600
  } = {}
601
601
  }) {
602
- return this.pointerLock = n && I.pointerLock, I.touch && e ? "touch" : this.pointerLock ? "mouse" : I.pointer && !s ? "pointer" : I.touch ? "touch" : "mouse";
602
+ return this.pointerLock = n && $.pointerLock, $.touch && r ? "touch" : this.pointerLock ? "mouse" : $.pointer && !s ? "pointer" : $.touch ? "touch" : "mouse";
603
603
  },
604
- preventScrollAxis(r, t, {
605
- preventScroll: e
604
+ preventScrollAxis(e, t, {
605
+ preventScroll: r
606
606
  }) {
607
- if (this.preventScrollDelay = typeof e == "number" ? e : e || e === void 0 && r ? ce : void 0, !(!I.touchscreen || e === !1))
608
- return r || (e !== void 0 ? "y" : void 0);
607
+ if (this.preventScrollDelay = typeof r == "number" ? r : r || r === void 0 && e ? le : void 0, !(!$.touchscreen || r === !1))
608
+ return e || (r !== void 0 ? "y" : void 0);
609
609
  },
610
- pointerCapture(r, t, {
610
+ pointerCapture(e, t, {
611
611
  pointer: {
612
- capture: e = !0,
612
+ capture: r = !0,
613
613
  buttons: n = 1,
614
614
  keys: s = !0
615
615
  } = {}
616
616
  }) {
617
- return this.pointerButtons = n, this.keys = s, !this.pointerLock && this.device === "pointer" && e;
617
+ return this.pointerButtons = n, this.keys = s, !this.pointerLock && this.device === "pointer" && r;
618
618
  },
619
- threshold(r, t, {
620
- filterTaps: e = !1,
619
+ threshold(e, t, {
620
+ filterTaps: r = !1,
621
621
  tapsThreshold: n = 3,
622
622
  axis: s = void 0
623
623
  }) {
624
- const o = y.toVector(r, e ? n : s ? 1 : 0);
625
- return this.filterTaps = e, this.tapsThreshold = n, o;
624
+ const o = b.toVector(e, r ? n : s ? 1 : 0);
625
+ return this.filterTaps = r, this.tapsThreshold = n, o;
626
626
  },
627
627
  swipe({
628
- velocity: r = le,
629
- distance: t = fe,
630
- duration: e = de
628
+ velocity: e = de,
629
+ distance: t = he,
630
+ duration: r = pe
631
631
  } = {}) {
632
632
  return {
633
- velocity: this.transform(y.toVector(r)),
634
- distance: this.transform(y.toVector(t)),
635
- duration: e
633
+ velocity: this.transform(b.toVector(e)),
634
+ distance: this.transform(b.toVector(t)),
635
+ duration: r
636
636
  };
637
637
  },
638
- delay(r = 0) {
639
- switch (r) {
638
+ delay(e = 0) {
639
+ switch (e) {
640
640
  case !0:
641
- return ue;
641
+ return fe;
642
642
  case !1:
643
643
  return 0;
644
644
  default:
645
- return r;
645
+ return e;
646
646
  }
647
647
  },
648
- axisThreshold(r) {
649
- return r ? d(d({}, bt), r) : bt;
648
+ axisThreshold(e) {
649
+ return e ? p(p({}, yt), e) : yt;
650
650
  },
651
- keyboardDisplacement(r = he) {
652
- return r;
651
+ keyboardDisplacement(e = me) {
652
+ return e;
653
653
  }
654
654
  });
655
- process.env.NODE_ENV === "development" && Object.assign(xt, {
656
- useTouch(r) {
657
- if (r !== void 0)
655
+ process.env.NODE_ENV === "development" && Object.assign(It, {
656
+ useTouch(e) {
657
+ if (e !== void 0)
658
658
  throw Error("[@use-gesture]: `useTouch` option has been renamed to `pointer.touch`. Use it as in `{ pointer: { touch: true } }`.");
659
659
  return NaN;
660
660
  },
661
- experimental_preventWindowScrollY(r) {
662
- if (r !== void 0)
661
+ experimental_preventWindowScrollY(e) {
662
+ if (e !== void 0)
663
663
  throw Error("[@use-gesture]: `experimental_preventWindowScrollY` option has been renamed to `preventScroll`.");
664
664
  return NaN;
665
665
  },
666
- swipeVelocity(r) {
667
- if (r !== void 0)
666
+ swipeVelocity(e) {
667
+ if (e !== void 0)
668
668
  throw Error("[@use-gesture]: `swipeVelocity` option has been renamed to `swipe.velocity`. Use it as in `{ swipe: { velocity: 0.5 } }`.");
669
669
  return NaN;
670
670
  },
671
- swipeDistance(r) {
672
- if (r !== void 0)
671
+ swipeDistance(e) {
672
+ if (e !== void 0)
673
673
  throw Error("[@use-gesture]: `swipeDistance` option has been renamed to `swipe.distance`. Use it as in `{ swipe: { distance: 50 } }`.");
674
674
  return NaN;
675
675
  },
676
- swipeDuration(r) {
677
- if (r !== void 0)
676
+ swipeDuration(e) {
677
+ if (e !== void 0)
678
678
  throw Error("[@use-gesture]: `swipeDuration` option has been renamed to `swipe.duration`. Use it as in `{ swipe: { duration: 250 } }`.");
679
679
  return NaN;
680
680
  }
681
681
  });
682
- d(d({}, et), {}, {
683
- device(r, t, {
684
- shared: e,
682
+ p(p({}, rt), {}, {
683
+ device(e, t, {
684
+ shared: r,
685
685
  pointer: {
686
686
  touch: n = !1
687
687
  } = {}
688
688
  }) {
689
- if (e.target && !I.touch && I.gesture) return "gesture";
690
- if (I.touch && n) return "touch";
691
- if (I.touchscreen) {
692
- if (I.pointer) return "pointer";
693
- if (I.touch) return "touch";
689
+ if (r.target && !$.touch && $.gesture) return "gesture";
690
+ if ($.touch && n) return "touch";
691
+ if ($.touchscreen) {
692
+ if ($.pointer) return "pointer";
693
+ if ($.touch) return "touch";
694
694
  }
695
695
  },
696
- bounds(r, t, {
697
- scaleBounds: e = {},
696
+ bounds(e, t, {
697
+ scaleBounds: r = {},
698
698
  angleBounds: n = {}
699
699
  }) {
700
700
  const s = (a) => {
701
- const u = mt(z(e, a), {
701
+ const c = pt(z(r, a), {
702
702
  min: -1 / 0,
703
703
  max: 1 / 0
704
704
  });
705
- return [u.min, u.max];
705
+ return [c.min, c.max];
706
706
  }, o = (a) => {
707
- const u = mt(z(n, a), {
707
+ const c = pt(z(n, a), {
708
708
  min: -1 / 0,
709
709
  max: 1 / 0
710
710
  });
711
- return [u.min, u.max];
711
+ return [c.min, c.max];
712
712
  };
713
- return typeof e != "function" && typeof n != "function" ? [s(), o()] : (a) => [s(a), o(a)];
713
+ return typeof r != "function" && typeof n != "function" ? [s(), o()] : (a) => [s(a), o(a)];
714
714
  },
715
- threshold(r, t, e) {
716
- return this.lockDirection = e.axis === "lock", y.toVector(r, this.lockDirection ? [0.1, 3] : 0);
715
+ threshold(e, t, r) {
716
+ return this.lockDirection = r.axis === "lock", b.toVector(e, this.lockDirection ? [0.1, 3] : 0);
717
717
  },
718
- modifierKey(r) {
719
- return r === void 0 ? "ctrlKey" : r;
718
+ modifierKey(e) {
719
+ return e === void 0 ? "ctrlKey" : e;
720
720
  },
721
- pinchOnWheel(r = !0) {
722
- return r;
721
+ pinchOnWheel(e = !0) {
722
+ return e;
723
723
  }
724
724
  });
725
- d(d({}, L), {}, {
726
- mouseOnly: (r = !0) => r
725
+ p(p({}, j), {}, {
726
+ mouseOnly: (e = !0) => e
727
727
  });
728
- d(d({}, L), {}, {
729
- mouseOnly: (r = !0) => r
728
+ p(p({}, j), {}, {
729
+ mouseOnly: (e = !0) => e
730
730
  });
731
- const It = /* @__PURE__ */ new Map(), tt = /* @__PURE__ */ new Map();
732
- function pe(r) {
733
- It.set(r.key, r.engine), tt.set(r.key, r.resolver);
731
+ const kt = /* @__PURE__ */ new Map(), et = /* @__PURE__ */ new Map();
732
+ function ge(e) {
733
+ kt.set(e.key, e.engine), et.set(e.key, e.resolver);
734
734
  }
735
- const me = {
735
+ const ve = {
736
736
  key: "drag",
737
- engine: re,
738
- resolver: xt
737
+ engine: se,
738
+ resolver: It
739
739
  };
740
- function ge(r, t) {
741
- if (r == null) return {};
742
- var e = {}, n = Object.keys(r), s, o;
740
+ function ye(e, t) {
741
+ if (e == null) return {};
742
+ var r = {}, n = Object.keys(e), s, o;
743
743
  for (o = 0; o < n.length; o++)
744
- s = n[o], !(t.indexOf(s) >= 0) && (e[s] = r[s]);
745
- return e;
744
+ s = n[o], !(t.indexOf(s) >= 0) && (r[s] = e[s]);
745
+ return r;
746
746
  }
747
- function ve(r, t) {
748
- if (r == null) return {};
749
- var e = ge(r, t), n, s;
747
+ function be(e, t) {
748
+ if (e == null) return {};
749
+ var r = ye(e, t), n, s;
750
750
  if (Object.getOwnPropertySymbols) {
751
- var o = Object.getOwnPropertySymbols(r);
751
+ var o = Object.getOwnPropertySymbols(e);
752
752
  for (s = 0; s < o.length; s++)
753
- n = o[s], !(t.indexOf(n) >= 0) && Object.prototype.propertyIsEnumerable.call(r, n) && (e[n] = r[n]);
753
+ n = o[s], !(t.indexOf(n) >= 0) && Object.prototype.propertyIsEnumerable.call(e, n) && (r[n] = e[n]);
754
754
  }
755
- return e;
755
+ return r;
756
756
  }
757
- const ye = {
758
- target(r) {
759
- if (r)
760
- return () => "current" in r ? r.current : r;
757
+ const _e = {
758
+ target(e) {
759
+ if (e)
760
+ return () => "current" in e ? e.current : e;
761
761
  },
762
- enabled(r = !0) {
763
- return r;
762
+ enabled(e = !0) {
763
+ return e;
764
764
  },
765
- window(r = I.isBrowser ? window : void 0) {
766
- return r;
765
+ window(e = $.isBrowser ? window : void 0) {
766
+ return e;
767
767
  },
768
768
  eventOptions({
769
- passive: r = !0,
769
+ passive: e = !0,
770
770
  capture: t = !1
771
771
  } = {}) {
772
772
  return {
773
- passive: r,
773
+ passive: e,
774
774
  capture: t
775
775
  };
776
776
  },
777
- transform(r) {
778
- return r;
777
+ transform(e) {
778
+ return e;
779
779
  }
780
- }, be = ["target", "eventOptions", "window", "enabled", "transform"];
781
- function B(r = {}, t) {
782
- const e = {};
780
+ }, we = ["target", "eventOptions", "window", "enabled", "transform"];
781
+ function G(e = {}, t) {
782
+ const r = {};
783
783
  for (const [n, s] of Object.entries(t))
784
784
  switch (typeof s) {
785
785
  case "function":
786
786
  if (process.env.NODE_ENV === "development") {
787
- const o = s.call(e, r[n], n, r);
788
- Number.isNaN(o) || (e[n] = o);
787
+ const o = s.call(r, e[n], n, e);
788
+ Number.isNaN(o) || (r[n] = o);
789
789
  } else
790
- e[n] = s.call(e, r[n], n, r);
790
+ r[n] = s.call(r, e[n], n, e);
791
791
  break;
792
792
  case "object":
793
- e[n] = B(r[n], s);
793
+ r[n] = G(e[n], s);
794
794
  break;
795
795
  case "boolean":
796
- s && (e[n] = r[n]);
796
+ s && (r[n] = e[n]);
797
797
  break;
798
798
  }
799
- return e;
799
+ return r;
800
800
  }
801
- function _e(r, t, e = {}) {
802
- const n = r, {
801
+ function Ee(e, t, r = {}) {
802
+ const n = e, {
803
803
  target: s,
804
804
  eventOptions: o,
805
805
  window: a,
806
- enabled: u,
807
- transform: h
808
- } = n, p = ve(n, be);
809
- if (e.shared = B({
806
+ enabled: c,
807
+ transform: l
808
+ } = n, h = be(n, we);
809
+ if (r.shared = G({
810
810
  target: s,
811
811
  eventOptions: o,
812
812
  window: a,
813
- enabled: u,
814
- transform: h
815
- }, ye), t) {
816
- const c = tt.get(t);
817
- e[t] = B(d({
818
- shared: e.shared
819
- }, p), c);
813
+ enabled: c,
814
+ transform: l
815
+ }, _e), t) {
816
+ const u = et.get(t);
817
+ r[t] = G(p({
818
+ shared: r.shared
819
+ }, h), u);
820
820
  } else
821
- for (const c in p) {
822
- const b = tt.get(c);
823
- if (b)
824
- e[c] = B(d({
825
- shared: e.shared
826
- }, p[c]), b);
827
- else if (process.env.NODE_ENV === "development" && !["drag", "pinch", "scroll", "wheel", "move", "hover"].includes(c)) {
828
- if (c === "domTarget")
821
+ for (const u in h) {
822
+ const g = et.get(u);
823
+ if (g)
824
+ r[u] = G(p({
825
+ shared: r.shared
826
+ }, h[u]), g);
827
+ else if (process.env.NODE_ENV === "development" && !["drag", "pinch", "scroll", "wheel", "move", "hover"].includes(u)) {
828
+ if (u === "domTarget")
829
829
  throw Error("[@use-gesture]: `domTarget` option has been renamed to `target`.");
830
- console.warn(`[@use-gesture]: Unknown config key \`${c}\` was used. Please read the documentation for further information.`);
830
+ console.warn(`[@use-gesture]: Unknown config key \`${u}\` was used. Please read the documentation for further information.`);
831
831
  }
832
832
  }
833
- return e;
833
+ return r;
834
834
  }
835
- class kt {
836
- constructor(t, e) {
837
- w(this, "_listeners", /* @__PURE__ */ new Set()), this._ctrl = t, this._gestureKey = e;
838
- }
839
- add(t, e, n, s, o) {
840
- const a = this._listeners, u = Gt(e, n), h = this._gestureKey ? this._ctrl.config[this._gestureKey].eventOptions : {}, p = d(d({}, h), o);
841
- t.addEventListener(u, s, p);
842
- const c = () => {
843
- t.removeEventListener(u, s, p), a.delete(c);
835
+ class Ct {
836
+ constructor(t, r) {
837
+ S(this, "_listeners", /* @__PURE__ */ new Set()), this._ctrl = t, this._gestureKey = r;
838
+ }
839
+ add(t, r, n, s, o) {
840
+ const a = this._listeners, c = Yt(r, n), l = this._gestureKey ? this._ctrl.config[this._gestureKey].eventOptions : {}, h = p(p({}, l), o);
841
+ t.addEventListener(c, s, h);
842
+ const u = () => {
843
+ t.removeEventListener(c, s, h), a.delete(u);
844
844
  };
845
- return a.add(c), c;
845
+ return a.add(u), u;
846
846
  }
847
847
  clean() {
848
848
  this._listeners.forEach((t) => t()), this._listeners.clear();
849
849
  }
850
850
  }
851
- class we {
851
+ class Te {
852
852
  constructor() {
853
- w(this, "_timeouts", /* @__PURE__ */ new Map());
853
+ S(this, "_timeouts", /* @__PURE__ */ new Map());
854
854
  }
855
- add(t, e, n = 140, ...s) {
856
- this.remove(t), this._timeouts.set(t, window.setTimeout(e, n, ...s));
855
+ add(t, r, n = 140, ...s) {
856
+ this.remove(t), this._timeouts.set(t, window.setTimeout(r, n, ...s));
857
857
  }
858
858
  remove(t) {
859
- const e = this._timeouts.get(t);
860
- e && window.clearTimeout(e);
859
+ const r = this._timeouts.get(t);
860
+ r && window.clearTimeout(r);
861
861
  }
862
862
  clean() {
863
863
  this._timeouts.forEach((t) => void window.clearTimeout(t)), this._timeouts.clear();
864
864
  }
865
865
  }
866
- class Ee {
866
+ class Se {
867
867
  constructor(t) {
868
- w(this, "gestures", /* @__PURE__ */ new Set()), w(this, "_targetEventStore", new kt(this)), w(this, "gestureEventStores", {}), w(this, "gestureTimeoutStores", {}), w(this, "handlers", {}), w(this, "config", {}), w(this, "pointerIds", /* @__PURE__ */ new Set()), w(this, "touchIds", /* @__PURE__ */ new Set()), w(this, "state", {
868
+ S(this, "gestures", /* @__PURE__ */ new Set()), S(this, "_targetEventStore", new Ct(this)), S(this, "gestureEventStores", {}), S(this, "gestureTimeoutStores", {}), S(this, "handlers", {}), S(this, "config", {}), S(this, "pointerIds", /* @__PURE__ */ new Set()), S(this, "touchIds", /* @__PURE__ */ new Set()), S(this, "state", {
869
869
  shared: {
870
870
  shiftKey: !1,
871
871
  metaKey: !1,
872
872
  ctrlKey: !1,
873
873
  altKey: !1
874
874
  }
875
- }), Te(this, t);
875
+ }), xe(this, t);
876
876
  }
877
877
  setEventIds(t) {
878
- if (G(t))
879
- return this.touchIds = new Set(Wt(t)), this.touchIds;
878
+ if (W(t))
879
+ return this.touchIds = new Set(Xt(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
  }
883
- applyHandlers(t, e) {
884
- this.handlers = t, this.nativeHandlers = e;
883
+ applyHandlers(t, r) {
884
+ this.handlers = t, this.nativeHandlers = r;
885
885
  }
886
- applyConfig(t, e) {
887
- this.config = _e(t, e, this.config);
886
+ applyConfig(t, r) {
887
+ this.config = Ee(t, r, this.config);
888
888
  }
889
889
  clean() {
890
890
  this._targetEventStore.clean();
@@ -895,122 +895,126 @@ class Ee {
895
895
  return this.config.shared.target && this.bind(), () => this._targetEventStore.clean();
896
896
  }
897
897
  bind(...t) {
898
- const e = this.config.shared, n = {};
898
+ const r = this.config.shared, n = {};
899
899
  let s;
900
- if (!(e.target && (s = e.target(), !s))) {
901
- if (e.enabled) {
900
+ if (!(r.target && (s = r.target(), !s))) {
901
+ if (r.enabled) {
902
902
  for (const a of this.gestures) {
903
- const u = this.config[a], h = _t(n, u.eventOptions, !!s);
904
- if (u.enabled) {
905
- const p = It.get(a);
906
- new p(this, t, a).bind(h);
903
+ const c = this.config[a], l = bt(n, c.eventOptions, !!s);
904
+ if (c.enabled) {
905
+ const h = kt.get(a);
906
+ new h(this, t, a).bind(l);
907
907
  }
908
908
  }
909
- const o = _t(n, e.eventOptions, !!s);
909
+ const o = bt(n, r.eventOptions, !!s);
910
910
  for (const a in this.nativeHandlers)
911
- o(a, "", (u) => this.nativeHandlers[a](d(d({}, this.state.shared), {}, {
912
- event: u,
911
+ o(a, "", (c) => this.nativeHandlers[a](p(p({}, this.state.shared), {}, {
912
+ event: c,
913
913
  args: t
914
914
  })), void 0, !0);
915
915
  }
916
916
  for (const o in n)
917
- n[o] = qt(...n[o]);
917
+ n[o] = Qt(...n[o]);
918
918
  if (!s) return n;
919
919
  for (const o in n) {
920
920
  const {
921
921
  device: a,
922
- capture: u,
923
- passive: h
924
- } = zt(o);
922
+ capture: c,
923
+ passive: l
924
+ } = Wt(o);
925
925
  this._targetEventStore.add(s, a, "", n[o], {
926
- capture: u,
927
- passive: h
926
+ capture: c,
927
+ passive: l
928
928
  });
929
929
  }
930
930
  }
931
931
  }
932
932
  }
933
- function M(r, t) {
934
- r.gestures.add(t), r.gestureEventStores[t] = new kt(r, t), r.gestureTimeoutStores[t] = new we();
933
+ function L(e, t) {
934
+ e.gestures.add(t), e.gestureEventStores[t] = new Ct(e, t), e.gestureTimeoutStores[t] = new Te();
935
935
  }
936
- function Te(r, t) {
937
- t.drag && M(r, "drag"), t.wheel && M(r, "wheel"), t.scroll && M(r, "scroll"), t.move && M(r, "move"), t.pinch && M(r, "pinch"), t.hover && M(r, "hover");
936
+ function xe(e, t) {
937
+ t.drag && L(e, "drag"), t.wheel && L(e, "wheel"), t.scroll && L(e, "scroll"), t.move && L(e, "move"), t.pinch && L(e, "pinch"), t.hover && L(e, "hover");
938
938
  }
939
- const _t = (r, t, e) => (n, s, o, a = {}, u = !1) => {
940
- var h, p;
941
- const c = (h = a.capture) !== null && h !== void 0 ? h : t.capture, b = (p = a.passive) !== null && p !== void 0 ? p : t.passive;
942
- let g = u ? n : Kt(n, s, c);
943
- e && b && (g += "Passive"), r[g] = r[g] || [], r[g].push(o);
939
+ const bt = (e, t, r) => (n, s, o, a = {}, c = !1) => {
940
+ var l, h;
941
+ const u = (l = a.capture) !== null && l !== void 0 ? l : t.capture, g = (h = a.passive) !== null && h !== void 0 ? h : t.passive;
942
+ let m = c ? n : Gt(n, s, u);
943
+ r && g && (m += "Passive"), e[m] = e[m] || [], e[m].push(o);
944
944
  };
945
- function Se(r, t = {}, e, n) {
946
- const s = q.useMemo(() => new Ee(r), []);
947
- if (s.applyHandlers(r, n), s.applyConfig(t, e), q.useEffect(s.effect.bind(s)), q.useEffect(() => s.clean.bind(s), []), t.target === void 0)
945
+ function Ie(e, t = {}, r, n) {
946
+ const s = J.useMemo(() => new Se(e), []);
947
+ if (s.applyHandlers(e, n), s.applyConfig(t, r), J.useEffect(s.effect.bind(s)), J.useEffect(() => s.clean.bind(s), []), t.target === void 0)
948
948
  return s.bind.bind(s);
949
949
  }
950
- function xe(r, t) {
951
- return pe(me), Se({
952
- drag: r
950
+ function ke(e, t) {
951
+ return ge(ve), Ie({
952
+ drag: e
953
953
  }, t || {}, "drag");
954
954
  }
955
- const Q = "RSC::Event";
956
- function Ie() {
957
- const r = k(null);
955
+ const Z = "RSC::Event";
956
+ function Ce() {
957
+ const e = P(null);
958
958
  function t(n) {
959
- Z(() => {
960
- r.current || (r.current = document.createElement("div"));
959
+ R(() => {
960
+ e.current || (e.current = document.createElement("div"));
961
961
  function s(o) {
962
962
  n(o.detail);
963
963
  }
964
- if (r.current)
965
- return r.current.addEventListener(Q, s, !1), () => {
964
+ if (e.current)
965
+ return e.current.addEventListener(Z, s, !1), () => {
966
966
  var o;
967
- (o = r.current) == null || o.removeEventListener(
968
- Q,
967
+ (o = e.current) == null || o.removeEventListener(
968
+ Z,
969
969
  s,
970
970
  !1
971
971
  );
972
972
  };
973
973
  }, [n]);
974
974
  }
975
- function e(n) {
976
- if (r.current) {
977
- const s = new CustomEvent(Q, {
975
+ function r(n) {
976
+ if (e.current) {
977
+ const s = new CustomEvent(Z, {
978
978
  detail: n
979
979
  });
980
- r.current.dispatchEvent(s);
980
+ e.current.dispatchEvent(s);
981
981
  }
982
982
  }
983
983
  return {
984
984
  useListenToCustomEvent: t,
985
- emitEvent: e
985
+ emitEvent: r
986
986
  };
987
987
  }
988
- function $e({
989
- init: r = !0,
988
+ function De(e) {
989
+ let t = e.replace(/\/\*[\s\S]*?\*\/|([^:]|^)\/\/.*$/gm, "");
990
+ return t = t.replace(/[\n\t]+/g, " "), t = t.replace(/\s*([{}:;,])\s*/g, "$1"), t = t.replace(/\s+}/g, "}"), t = t.replace(/{\s+/g, "{"), t = t.replace(/\s+/g, " "), t.trim();
991
+ }
992
+ function Le({
993
+ init: e = !0,
990
994
  items: t,
991
- withLoop: e = !1,
995
+ withLoop: r = !1,
992
996
  id: n,
993
997
  gutter: s = [{ breakpoint: 0, gutter: 0, startEndGutter: 0 }],
994
998
  itemsPerSlide: o = [{ breakpoint: 0, itemsPerSlide: 1 }],
995
999
  carouselAxis: a = "x",
996
- startingPosition: u = "start",
997
- enableGestures: h = !0,
998
- slideWhenDragThresholdIsReached: p = !0,
999
- onInit: c,
1000
- initialActiveItem: b = 0
1000
+ startingPosition: c = "start",
1001
+ enableGestures: l = !0,
1002
+ slideWhenDragThresholdIsReached: h = !0,
1003
+ onInit: u,
1004
+ initialActiveItem: g = 0
1001
1005
  }) {
1002
- const [g, O] = Nt(!1), D = k(r), E = k(null), $ = k(null), A = k(0), x = k(0), C = k(!e), P = k(!1), R = k(0), f = k(0), [V, Y] = At(
1006
+ const [m, D] = Mt(!1), _ = P(e), w = P(null), O = P(null), A = P(0), E = P(0), x = P(!r), I = P(!1), M = P(0), d = P(0), [V, Y] = wt(
1003
1007
  () => ({
1004
1008
  value: 0,
1005
1009
  onChange({ value: i }) {
1006
- E.current.style.setProperty(
1010
+ w.current.style.setProperty(
1007
1011
  `--${n}-offset-position`,
1008
1012
  `${i.value}px`
1009
1013
  );
1010
1014
  }
1011
1015
  }),
1012
1016
  [a]
1013
- ), Dt = e ? [
1017
+ ), Dt = r ? [
1014
1018
  ...t.map((i) => ({
1015
1019
  ...i,
1016
1020
  id: `prev-repeated-item-${i.id}`,
@@ -1022,29 +1026,29 @@ function $e({
1022
1026
  id: `next-repeated-item-${i.id}`,
1023
1027
  isClonedItem: !0
1024
1028
  }))
1025
- ] : t, { useListenToCustomEvent: rt, emitEvent: U } = Ie();
1026
- function nt() {
1027
- const { totalGutterCssVar: i } = it();
1029
+ ] : t, { useListenToCustomEvent: nt, emitEvent: U } = Ce();
1030
+ function Pt() {
1031
+ const { totalGutterCssVar: i } = st();
1028
1032
  return i;
1029
1033
  }
1030
- function st() {
1031
- if (E.current) {
1032
- const l = window.getComputedStyle(
1033
- E.current
1034
+ function $t() {
1035
+ if (w.current) {
1036
+ const f = window.getComputedStyle(
1037
+ w.current
1034
1038
  ).getPropertyValue(`--${n}-items-per-slide`).trim();
1035
- return Number(l) || 1;
1039
+ return Number(f) || 1;
1036
1040
  }
1037
1041
  return 1;
1038
1042
  }
1039
1043
  function F(i) {
1040
- D.current && (P.current || N({
1044
+ _.current && (I.current || N({
1041
1045
  type: "next",
1042
1046
  toIndex: i,
1043
1047
  actionType: "click"
1044
1048
  }));
1045
1049
  }
1046
- function W(i) {
1047
- D.current && (C.current || N({
1050
+ function H(i) {
1051
+ _.current && (x.current || N({
1048
1052
  type: "prev",
1049
1053
  toIndex: i,
1050
1054
  actionType: "click"
@@ -1052,197 +1056,197 @@ function $e({
1052
1056
  }
1053
1057
  function N({
1054
1058
  type: i,
1055
- shouldAnimate: l = !0,
1056
- toIndex: v,
1057
- actionType: m
1059
+ shouldAnimate: f = !0,
1060
+ toIndex: y,
1061
+ actionType: v
1058
1062
  }) {
1059
- var at, ct;
1060
- const _ = !l;
1061
- C.current = !1, P.current = !1;
1062
- let T = V.value.get(), S = 0;
1063
- if (i === "next" && (f.current += 1), i === "prev" && (f.current === 0 ? f.current = t.length - 1 : f.current -= 1), v !== void 0 && (f.current = v), i === "next") {
1064
- const K = H(
1065
- e ? x.current * (t.length * 2) : 0
1063
+ var ot, at;
1064
+ const T = !f;
1065
+ x.current = !1, I.current = !1;
1066
+ let k = V.value.get(), C = 0;
1067
+ if (i === "next" && (d.current += 1), i === "prev" && (d.current === 0 ? d.current = t.length - 1 : d.current -= 1), y !== void 0 && (d.current = y), i === "next") {
1068
+ const K = X(
1069
+ r ? E.current * (t.length * 2) : 0
1066
1070
  );
1067
- S = -(f.current * x.current), e && f.current === t.length && (f.current = 0, T = T + x.current * t.length, S = 0), !e && Math.abs(S) >= K && (P.current = !0, S = -K);
1071
+ C = -(d.current * E.current), r && d.current === t.length && (d.current = 0, k = k + E.current * t.length, C = 0), !r && Math.abs(C) >= K && (I.current = !0, C = -K);
1068
1072
  }
1069
- i === "prev" && (S = -(f.current * x.current), f.current === t.length - 1 && (T = T - t.length * x.current), !e && S >= 0 && (C.current = !0, S = 0)), A.current = S, m === "resize" ? (S = -(f.current * x.current), U({
1073
+ i === "prev" && (C = -(d.current * E.current), d.current === t.length - 1 && (k = k - t.length * E.current), !r && C >= 0 && (x.current = !0, C = 0)), A.current = C, v === "resize" ? (C = -(d.current * E.current), U({
1070
1074
  eventName: "onResize",
1071
- sliceActionType: m,
1075
+ sliceActionType: v,
1072
1076
  slideDirection: i,
1073
1077
  currentItem: {
1074
- index: f.current,
1075
- id: ((at = t.at(f.current)) == null ? void 0 : at.id) ?? "",
1076
- startReached: C.current,
1077
- endReached: P.current
1078
+ index: d.current,
1079
+ id: ((ot = t.at(d.current)) == null ? void 0 : ot.id) ?? "",
1080
+ startReached: x.current,
1081
+ endReached: I.current
1078
1082
  }
1079
1083
  })) : U({
1080
1084
  eventName: "onSlideStartChange",
1081
- sliceActionType: m,
1085
+ sliceActionType: v,
1082
1086
  slideDirection: i,
1083
1087
  nextItem: {
1084
- index: f.current,
1085
- id: ((ct = t.at(f.current)) == null ? void 0 : ct.id) ?? "",
1086
- startReached: C.current,
1087
- endReached: P.current
1088
+ index: d.current,
1089
+ id: ((at = t.at(d.current)) == null ? void 0 : at.id) ?? "",
1090
+ startReached: x.current,
1091
+ endReached: I.current
1088
1092
  }
1089
1093
  }), Y.start({
1090
- immediate: _,
1094
+ immediate: T,
1091
1095
  from: {
1092
- value: T
1096
+ value: k
1093
1097
  },
1094
1098
  to: {
1095
- value: S
1099
+ value: C
1096
1100
  },
1097
1101
  onRest({ finished: K }) {
1098
- var ut;
1102
+ var ct;
1099
1103
  K && U({
1100
1104
  eventName: "onSlideChangeComplete",
1101
- sliceActionType: m,
1105
+ sliceActionType: v,
1102
1106
  slideDirection: i,
1103
1107
  currentItem: {
1104
- index: f.current,
1105
- id: ((ut = t.at(f.current)) == null ? void 0 : ut.id) ?? "",
1106
- startReached: C.current,
1107
- endReached: P.current
1108
+ index: d.current,
1109
+ id: ((ct = t.at(d.current)) == null ? void 0 : ct.id) ?? "",
1110
+ startReached: x.current,
1111
+ endReached: I.current
1108
1112
  }
1109
1113
  });
1110
1114
  }
1111
1115
  });
1112
1116
  }
1113
- function Ct() {
1114
- const i = $.current.children[0];
1115
- let l = 0;
1116
- return l = i.getBoundingClientRect()[a === "x" ? "width" : "height"] + nt(), l;
1117
+ function Ot() {
1118
+ const i = O.current.children[0];
1119
+ let f = 0;
1120
+ return f = i.getBoundingClientRect()[a === "x" ? "width" : "height"] + Pt(), f;
1117
1121
  }
1118
- function H(i) {
1119
- const l = $.current;
1120
- return l[a === "x" ? "scrollWidth" : "scrollHeight"] - l.getBoundingClientRect()[a === "x" ? "width" : "height"] - i;
1121
- }
1122
- function it() {
1123
- let i = 0, l = 0;
1124
- if (E.current) {
1125
- const v = window.getComputedStyle(
1126
- E.current
1127
- ), m = v.getPropertyValue(`--${n}-start-end-gutter`).trim();
1128
- m.includes("px") && (i = Number(
1129
- m.replace("px", "")
1122
+ function X(i) {
1123
+ const f = O.current;
1124
+ return f[a === "x" ? "scrollWidth" : "scrollHeight"] - f.getBoundingClientRect()[a === "x" ? "width" : "height"] - i;
1125
+ }
1126
+ function st() {
1127
+ let i = 0, f = 0;
1128
+ if (w.current) {
1129
+ const y = window.getComputedStyle(
1130
+ w.current
1131
+ ), v = y.getPropertyValue(`--${n}-start-end-gutter`).trim();
1132
+ v.includes("px") && (i = Number(
1133
+ v.replace("px", "")
1130
1134
  ));
1131
- const _ = v.getPropertyValue(`--${n}-gutter`).trim();
1132
- _.includes("px") && (l = Number(_.replace("px", "")));
1135
+ const T = y.getPropertyValue(`--${n}-gutter`).trim();
1136
+ T.includes("px") && (f = Number(T.replace("px", "")));
1133
1137
  }
1134
- return { totalStartEndGutterCssVar: i, totalGutterCssVar: l };
1138
+ return { totalStartEndGutterCssVar: i, totalGutterCssVar: f };
1135
1139
  }
1136
- Z(() => {
1137
- function i(m) {
1138
- const _ = st();
1139
- switch (m) {
1140
+ R(() => {
1141
+ function i(v) {
1142
+ const T = $t();
1143
+ switch (v) {
1140
1144
  case "start":
1141
1145
  return 0;
1142
1146
  case "middle-start":
1143
- return Math.floor((_ - 1) * 0.25);
1147
+ return Math.floor((T - 1) * 0.25);
1144
1148
  case "center":
1145
- return Math.floor((_ - 1) * 0.5);
1149
+ return Math.floor((T - 1) * 0.5);
1146
1150
  case "middle-end":
1147
- return Math.floor((_ - 1) * 0.75);
1151
+ return Math.floor((T - 1) * 0.75);
1148
1152
  case "end":
1149
- return _ - 1;
1153
+ return T - 1;
1150
1154
  default:
1151
1155
  return 0;
1152
1156
  }
1153
1157
  }
1154
- function l(m) {
1155
- if (x.current = Ct(), R.current = x.current / 4, E.current) {
1156
- const { totalStartEndGutterCssVar: _ } = it();
1157
- let T = 0;
1158
- e && (T = x.current * t.length), T -= x.current * i(u), T -= _ / 2, E.current.style.setProperty(
1158
+ function f(v) {
1159
+ if (E.current = Ot(), M.current = E.current / 4, w.current) {
1160
+ const { totalStartEndGutterCssVar: T } = st();
1161
+ let k = 0;
1162
+ r && (k = E.current * t.length), k -= E.current * i(c), k -= T / 2, w.current.style.setProperty(
1159
1163
  `--${n}-offset-modifier`,
1160
- `${-T}px`
1161
- ), O(!0), m && m();
1164
+ `${-k}px`
1165
+ ), D(!0), v && v();
1162
1166
  }
1163
1167
  }
1164
- function v() {
1165
- l(), N({
1168
+ function y() {
1169
+ f(), N({
1166
1170
  type: "resize",
1167
- toIndex: f.current,
1171
+ toIndex: d.current,
1168
1172
  shouldAnimate: !1,
1169
1173
  actionType: "resize"
1170
1174
  });
1171
1175
  }
1172
- if (r)
1173
- return D.current = !0, l(c), window.addEventListener("resize", v), () => {
1174
- window.removeEventListener("resize", v);
1176
+ if (e)
1177
+ return _.current = !0, f(u), window.addEventListener("resize", y), () => {
1178
+ window.removeEventListener("resize", y);
1175
1179
  };
1176
- }, [r, e, n, a, s, u]), Z(() => {
1177
- r && b !== f.current && N({
1180
+ }, [e, r, n, a, s, c]), R(() => {
1181
+ e && g !== d.current && N({
1178
1182
  type: "next",
1179
- toIndex: b,
1183
+ toIndex: g,
1180
1184
  actionType: "resize",
1181
1185
  shouldAnimate: !1
1182
1186
  });
1183
- }, [r, b]);
1184
- const ot = h, Pt = xe(
1187
+ }, [e, g]);
1188
+ const it = l, At = ke(
1185
1189
  (i) => {
1186
- if (!D.current)
1190
+ if (!_.current)
1187
1191
  return;
1188
- const l = i.dragging, v = i.offset[a === "x" ? 0 : 1], m = i.movement[a === "x" ? 0 : 1], _ = m > R.current, T = m < -R.current, S = i.velocity;
1189
- l && (U({
1192
+ const f = i.dragging, y = i.offset[a === "x" ? 0 : 1], v = i.movement[a === "x" ? 0 : 1], T = v > M.current, k = v < -M.current, C = i.velocity;
1193
+ f && (U({
1190
1194
  ...i,
1191
1195
  eventName: "onDrag",
1192
1196
  slideActionType: "drag"
1193
1197
  }), Y.start({
1194
- value: v,
1198
+ value: y,
1195
1199
  immediate: !0,
1196
1200
  config: {
1197
- velocity: S
1201
+ velocity: C
1198
1202
  }
1199
- }), p && (_ || T) && i.cancel()), i.last && (_ ? (N({
1203
+ }), h && (T || k) && i.cancel()), i.last && (T ? (N({
1200
1204
  actionType: "drag",
1201
1205
  type: "prev"
1202
- }), i.cancel()) : T ? (N({
1206
+ }), i.cancel()) : k ? (N({
1203
1207
  actionType: "drag",
1204
1208
  type: "next"
1205
1209
  }), i.cancel()) : (Y.start({
1206
1210
  value: A.current,
1207
1211
  config: {
1208
- velocity: S
1212
+ velocity: C
1209
1213
  }
1210
1214
  }), i.cancel()));
1211
1215
  },
1212
1216
  {
1213
- enabled: ot,
1217
+ enabled: it,
1214
1218
  axis: a,
1215
- rubberband: !e,
1216
- ...e ? {} : {
1219
+ rubberband: !r,
1220
+ ...r ? {} : {
1217
1221
  bounds: () => ({
1218
1222
  right: 0,
1219
- left: -H(0),
1220
- top: -H(0),
1223
+ left: -X(0),
1224
+ top: -X(0),
1221
1225
  bottom: 0
1222
1226
  })
1223
1227
  },
1224
1228
  from: () => [V.value.get(), V.value.get()]
1225
1229
  }
1226
1230
  );
1227
- function $t(i) {
1228
- var l, v;
1229
- return typeof i == "number" ? f.current === i : ((l = t.find((m) => m.id === i)) == null ? void 0 : l.id) === ((v = t[f.current]) == null ? void 0 : v.id);
1231
+ function Nt(i) {
1232
+ var f, y;
1233
+ return typeof i == "number" ? d.current === i : ((f = t.find((v) => v.id === i)) == null ? void 0 : f.id) === ((y = t[d.current]) == null ? void 0 : y.id);
1230
1234
  }
1231
1235
  return {
1232
- carouselFragment: /* @__PURE__ */ Ot(
1236
+ carouselFragment: /* @__PURE__ */ Lt(
1233
1237
  "div",
1234
1238
  {
1235
- ref: E,
1239
+ ref: w,
1236
1240
  className: "ReactSpringCarouselContainer",
1237
1241
  "data-part": "Container",
1238
1242
  "data-part-internal": `${n}-Container`,
1239
- ...Pt(),
1243
+ ...At(),
1240
1244
  children: [
1241
- /* @__PURE__ */ X(
1245
+ /* @__PURE__ */ q(
1242
1246
  "style",
1243
1247
  {
1244
1248
  dangerouslySetInnerHTML: {
1245
- __html: `
1249
+ __html: De(`
1246
1250
  [data-part-internal="${n}-Container"] {
1247
1251
  display: flex;
1248
1252
  width: 100%;
@@ -1255,14 +1259,14 @@ function $e({
1255
1259
  --${n}-scroll-y-value: ${a === "y" ? `calc(var(--${n}-offset-position) + var(--${n}-offset-modifier))` : "0px"};
1256
1260
  --${n}-gutter: 0px;
1257
1261
  --${n}-start-end-gutter: 0px;
1258
- touch-action: ${ot ? a === "x" ? "pan-y" : "pan-x" : "auto"};
1262
+ touch-action: ${it ? a === "x" ? "pan-y" : "pan-x" : "auto"};
1259
1263
  }
1260
1264
  [data-part-internal="${n}-Track"] {
1261
1265
  display: flex;
1262
1266
  position: relative;
1263
1267
  --initial-offset-modifier: calc(calc(-100% - var(--${n}-gutter) + calc(var(--${n}-start-end-gutter) / 2 / ${t.length} * var(--${n}-items-per-slide)) + var(--${n}-start-end-gutter)) * ${t.length} / var(--${n}-items-per-slide));
1264
- left: ${e && a === "x" && !g ? "var(--initial-offset-modifier)" : "0px"};
1265
- top: ${e && a === "y" && !g ? "var(--initial-offset-modifier)" : "0px"};
1268
+ left: ${r && a === "x" && !m ? "var(--initial-offset-modifier)" : "0px"};
1269
+ top: ${r && a === "y" && !m ? "var(--initial-offset-modifier)" : "0px"};
1266
1270
  flex-direction: ${a === "x" ? "row" : "column"};
1267
1271
  width: 100%;
1268
1272
  height: 100%;
@@ -1271,44 +1275,42 @@ function $e({
1271
1275
  }
1272
1276
  [data-part-internal="${n}-Item"] {
1273
1277
  display: flex;
1274
- flex: 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)))
1278
+ flex: 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)));
1275
1279
  }
1276
- ${s && s.length > 0 ? s.sort((i, l) => i.breakpoint - l.breakpoint).map(
1280
+ ${s && s.length > 0 ? s.sort((i, f) => i.breakpoint - f.breakpoint).map(
1277
1281
  (i) => `
1278
- @media (min-width: ${i.breakpoint}px) {
1279
- [data-part-internal="${n}-Container"] {
1280
- --${n}-gutter: ${i.gutter || 0}px;
1281
- --${n}-start-end-gutter: ${(i.startEndGutter || 0) * 2}px;
1282
- }
1282
+ @media ${i.media || `(min-width: ${i.breakpoint}px)`} {
1283
+ [data-part-internal="${n}-Container"] {
1284
+ --${n}-gutter: ${i.gutter || 0}px;
1285
+ --${n}-start-end-gutter: ${(i.startEndGutter || 0) * 2}px;
1283
1286
  }
1284
- `
1287
+ }
1288
+ `
1285
1289
  ).join("") : ""}
1286
- ${o && o.length > 0 ? o.sort(
1287
- (i, l) => i.breakpoint - l.breakpoint
1288
- ).map(
1290
+ ${o && o.length > 0 ? o.sort((i, f) => i.breakpoint - f.breakpoint).map(
1289
1291
  (i) => `
1290
- @media (min-width: ${i.breakpoint}px) {
1291
- [data-part-internal="${n}-Container"] {
1292
- --${n}-items-per-slide: ${i.itemsPerSlide || 1};
1293
- }
1292
+ @media ${i.media || `(min-width: ${i.breakpoint}px)`} {
1293
+ [data-part-internal="${n}-Container"] {
1294
+ --${n}-items-per-slide: ${i.itemsPerSlide || 1};
1294
1295
  }
1295
- `
1296
+ }
1297
+ `
1296
1298
  ).join("") : ""}
1297
- `
1299
+ `)
1298
1300
  }
1299
1301
  }
1300
1302
  ),
1301
- /* @__PURE__ */ X(
1303
+ /* @__PURE__ */ q(
1302
1304
  "div",
1303
1305
  {
1304
- ref: $,
1306
+ ref: O,
1305
1307
  className: "ReactSpringCarouselTrack",
1306
1308
  "data-part": "Track",
1307
1309
  "data-part-internal": `${n}-Track`,
1308
1310
  onScroll: () => {
1309
- C.current = !1, P.current = !1;
1311
+ x.current = !1, I.current = !1;
1310
1312
  },
1311
- children: Dt.map((i, l) => /* @__PURE__ */ X(
1313
+ children: Dt.map((i, f) => /* @__PURE__ */ q(
1312
1314
  "div",
1313
1315
  {
1314
1316
  className: "ReactSpringCarouselItem",
@@ -1316,24 +1318,22 @@ function $e({
1316
1318
  "data-part-internal": `${n}-Item`,
1317
1319
  "data-id": i.id,
1318
1320
  children: typeof i.renderItem == "function" ? i.renderItem({
1319
- useListenToCustomEvent: rt,
1320
- index: l,
1321
+ useListenToCustomEvent: nt,
1322
+ index: f,
1321
1323
  isClonedItem: !!i.isClonedItem,
1322
- isActiveItem: $t
1324
+ isActiveItem: Nt
1323
1325
  }) : i.renderItem
1324
1326
  },
1325
- `${i.id}-${l}`
1327
+ `${i.id}-${f}`
1326
1328
  ))
1327
1329
  }
1328
1330
  )
1329
1331
  ]
1330
1332
  }
1331
1333
  ),
1332
- useListenToCustomEvent: rt,
1334
+ useListenToCustomEvent: nt,
1333
1335
  slideToNextItem: () => F(),
1334
- slideToPrevItem: () => W(),
1335
- getGutter: nt,
1336
- getItemsPerSlide: st,
1336
+ slideToPrevItem: () => H(),
1337
1337
  slideToItem: (i) => {
1338
1338
  if (typeof i == "number") {
1339
1339
  if (!t[i]) {
@@ -1342,21 +1342,110 @@ function $e({
1342
1342
  );
1343
1343
  return;
1344
1344
  }
1345
- i > f.current ? F(i) : W(i);
1345
+ i > d.current ? F(i) : H(i);
1346
1346
  }
1347
1347
  if (typeof i == "string") {
1348
- const l = t.findIndex((v) => v.id === i);
1349
- if (l < 0) {
1348
+ const f = t.findIndex((y) => y.id === i);
1349
+ if (f < 0) {
1350
1350
  console.warn(
1351
1351
  `The item you're trying to slide doesn't exist. id: ${i}`
1352
1352
  );
1353
1353
  return;
1354
1354
  }
1355
- l > f.current ? F(l) : W(l);
1355
+ f > d.current ? F(f) : H(f);
1356
+ }
1357
+ }
1358
+ };
1359
+ }
1360
+ function Pe(e) {
1361
+ let t = 0;
1362
+ const r = getComputedStyle(e).getPropertyValue("gap");
1363
+ return r.includes("px") && (t = Number(r.replace("px", ""))), t;
1364
+ }
1365
+ function _t(e) {
1366
+ return e.scrollWidth - e.clientWidth;
1367
+ }
1368
+ function tt(e) {
1369
+ const t = e.children[0], r = Pe(e);
1370
+ return t.getBoundingClientRect().width + r;
1371
+ }
1372
+ function Me({ container: e, onReach: t }) {
1373
+ const r = P("start"), n = P(0), [, s] = wt(() => ({
1374
+ x: 0
1375
+ }));
1376
+ function o(c) {
1377
+ s.start({
1378
+ from: {
1379
+ x: e.current.scrollLeft
1380
+ },
1381
+ to: {
1382
+ x: c
1383
+ },
1384
+ onChange({ value: l }) {
1385
+ e.current && (e.current.scrollLeft = l.x);
1356
1386
  }
1387
+ });
1388
+ }
1389
+ function a(c) {
1390
+ if (!e.current || c === "next" && r.current === "end" || c === "prev" && r.current === "start")
1391
+ return;
1392
+ let l = 0;
1393
+ if (c === "next" && (n.current += 1), c === "prev" && (n.current -= 1), l = n.current * tt(e.current), c === "next") {
1394
+ const h = _t(e.current);
1395
+ l > h && (r.current = "end", l = h, t && t("end"));
1396
+ }
1397
+ c === "prev" && l <= 0 && (r.current = "start", n.current = 0, l = 0, t && t("start")), o(l);
1398
+ }
1399
+ return R(() => {
1400
+ function c() {
1401
+ var E;
1402
+ const D = tt(e.current), _ = ((E = [...e.current.children].at(0)) == null ? void 0 : E.getBoundingClientRect().width) || 0, w = Array(e.current.childElementCount).fill(0).map((x, I) => ({
1403
+ index: I,
1404
+ start: D * I,
1405
+ end: D * (I + 1)
1406
+ })), O = e.current.scrollLeft + _, A = w.find(
1407
+ (x) => O >= x.start && O < x.end
1408
+ );
1409
+ n.current = (A == null ? void 0 : A.index) || 0;
1410
+ }
1411
+ function l() {
1412
+ s.stop();
1413
+ }
1414
+ function h(D) {
1415
+ const _ = D.target;
1416
+ _.scrollLeft === 0 ? (n.current = 0, r.current = "start", t && t("start")) : _.scrollLeft >= _t(_) ? (r.current = "end", t && t("end")) : r.current !== "idle" && (r.current = "idle", t && t("idle"));
1417
+ }
1418
+ let u, g = 0;
1419
+ function m() {
1420
+ g = e.current.scrollLeft, clearTimeout(u), u = setTimeout(function() {
1421
+ e.current.scrollLeft === g && c();
1422
+ }, 200);
1423
+ }
1424
+ if (e.current)
1425
+ return e.current.addEventListener("wheel", l, {
1426
+ passive: !0
1427
+ }), e.current.addEventListener("scroll", h), e.current.addEventListener("scroll", m), () => {
1428
+ e.current && (e.current.removeEventListener("scroll", m), e.current.removeEventListener("scroll", h), e.current.removeEventListener("wheel", l));
1429
+ };
1430
+ }, [e, t]), R(() => {
1431
+ if (e.current) {
1432
+ const c = new ResizeObserver(() => {
1433
+ o(n.current * tt(e.current));
1434
+ });
1435
+ return c.observe(e.current), () => {
1436
+ c.disconnect();
1437
+ };
1438
+ }
1439
+ }, []), {
1440
+ scrollToNext() {
1441
+ a("next");
1442
+ },
1443
+ scrollToPrev() {
1444
+ a("prev");
1357
1445
  }
1358
1446
  };
1359
1447
  }
1360
1448
  export {
1361
- $e as useSpringCarousel
1449
+ Le as useSpringCarousel,
1450
+ Me as useSpringScroll
1362
1451
  };