react-spring-carousel 3.0.0-beta-1.0.422 → 3.0.0-beta-2.0.1

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