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