react-spring-carousel 3.0.0-beta-2.0.24 → 3.0.0-beta-2.0.251
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 +18 -18
- package/dist/index.umd.js +2 -2
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -256,8 +256,8 @@ class Jt {
|
|
|
256
256
|
if (n.hasCustomTransform ? (f[0] === !1 && (f[0] = Math.abs(u) >= c && x[0]), f[1] === !1 && (f[1] = Math.abs(a) >= p && x[1])) : (f[0] === !1 && (f[0] = Math.abs(u) >= c && Math.sign(u) * c), f[1] === !1 && (f[1] = Math.abs(a) >= p && Math.sign(a) * p)), e.intentional = f[0] !== !1 || f[1] !== !1, !e.intentional) return;
|
|
257
257
|
const y = [0, 0];
|
|
258
258
|
if (n.hasCustomTransform) {
|
|
259
|
-
const [l,
|
|
260
|
-
y[0] = f[0] !== !1 ? l - f[0] : 0, y[1] = f[1] !== !1 ?
|
|
259
|
+
const [l, R] = x;
|
|
260
|
+
y[0] = f[0] !== !1 ? l - f[0] : 0, y[1] = f[1] !== !1 ? R - f[1] : 0;
|
|
261
261
|
} else
|
|
262
262
|
y[0] = f[0] !== !1 ? u - f[0] : 0, y[1] = f[1] !== !1 ? a - f[1] : 0;
|
|
263
263
|
this.restrictToAxis && !e._blocked && this.restrictToAxis(y);
|
|
@@ -265,8 +265,8 @@ class Jt {
|
|
|
265
265
|
N && (e.first = e._active && !e.active, e.last = !e._active && e.active, e.active = s[this.ingKey] = e._active, t && (e.first && ("bounds" in n && (e._bounds = F(n.bounds, e)), this.setup && this.setup()), e.movement = y, this.computeOffset()));
|
|
266
266
|
const [C, O] = e.offset, [[_, B], [T, I]] = e._bounds;
|
|
267
267
|
e.overflow = [C < _ ? -1 : C > B ? 1 : 0, O < T ? -1 : O > I ? 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
|
|
269
|
-
if (e.offset = Mt(e._bounds, e.offset,
|
|
268
|
+
const M = e._active ? n.rubberband || [0, 0] : [0, 0];
|
|
269
|
+
if (e.offset = Mt(e._bounds, e.offset, M), e.delta = v.sub(e.offset, P), this.computeMovement(), N && (!e.last || o > qt)) {
|
|
270
270
|
e.delta = v.sub(e.offset, P);
|
|
271
271
|
const l = e.delta.map(Math.abs);
|
|
272
272
|
v.addTo(e.distance, l), e.direction = e.delta.map(Math.sign), e._direction = e._delta.map(Math.sign), !e.first && o > 0 && (e.velocity = [l[0] / o, l[1] / o], e.timeDelta = o);
|
|
@@ -930,11 +930,11 @@ class we {
|
|
|
930
930
|
}
|
|
931
931
|
}
|
|
932
932
|
}
|
|
933
|
-
function
|
|
933
|
+
function V(r, t) {
|
|
934
934
|
r.gestures.add(t), r.gestureEventStores[t] = new It(r, t), r.gestureTimeoutStores[t] = new be();
|
|
935
935
|
}
|
|
936
936
|
function Ee(r, t) {
|
|
937
|
-
t.drag &&
|
|
937
|
+
t.drag && V(r, "drag"), t.wheel && V(r, "wheel"), t.scroll && V(r, "scroll"), t.move && V(r, "move"), t.pinch && V(r, "pinch"), t.hover && V(r, "hover");
|
|
938
938
|
}
|
|
939
939
|
const yt = (r, t, e) => (n, s, o, u = {}, a = !1) => {
|
|
940
940
|
var c, p;
|
|
@@ -1000,7 +1000,7 @@ function Oe({
|
|
|
1000
1000
|
slideWhenDragThresholdIsReached: x = !0,
|
|
1001
1001
|
onInit: y
|
|
1002
1002
|
}) {
|
|
1003
|
-
const [P, N] = Pt(!1), C = $(r), O = $(null), _ = $(null), B = $(0), T = $(!e), I = $(!1),
|
|
1003
|
+
const [P, N] = Pt(!1), C = $(r), O = $(null), _ = $(null), B = $(0), T = $(!e), I = $(!1), M = $(0), l = $(0), [R, G] = $t(
|
|
1004
1004
|
() => ({
|
|
1005
1005
|
value: 0,
|
|
1006
1006
|
onChange({ value: i }) {
|
|
@@ -1047,7 +1047,7 @@ function Oe({
|
|
|
1047
1047
|
var ot, at;
|
|
1048
1048
|
const m = W(), A = !d;
|
|
1049
1049
|
T.current = !1, I.current = !1;
|
|
1050
|
-
let D =
|
|
1050
|
+
let D = R.value.get(), g = 0;
|
|
1051
1051
|
if (i === "next" && c === "fixed" && (l.current += 1), i === "prev" && c === "fixed" && (l.current === 0 ? l.current = t.length - 1 : l.current -= 1), i === "next" && c === "fixed") {
|
|
1052
1052
|
const k = J(
|
|
1053
1053
|
e ? m * (t.length * 2) : 0
|
|
@@ -1055,8 +1055,8 @@ function Oe({
|
|
|
1055
1055
|
g = -(l.current * m), e && l.current === t.length && (l.current = 0, D = D + m * t.length, g = 0), !e && Math.abs(g) >= k && (I.current = !0, g = -k);
|
|
1056
1056
|
}
|
|
1057
1057
|
if (i === "prev" && c === "fixed" && (g = -(l.current * m), l.current === t.length - 1 && (D = D - t.length * m), !e && g >= 0 && (T.current = !0, g = 0)), i === "next" && c === "freeScroll") {
|
|
1058
|
-
const k = _.current[a === "x" ? "scrollLeft" : "scrollTop"],
|
|
1059
|
-
D = k, g = k + m, (g >
|
|
1058
|
+
const k = _.current[a === "x" ? "scrollLeft" : "scrollTop"], L = a === "x" ? _.current.scrollWidth - _.current.clientWidth : _.current.scrollHeight - _.current.clientHeight;
|
|
1059
|
+
D = k, g = k + m, (g > L || L - g < 80) && (g = L, I.current = !0);
|
|
1060
1060
|
}
|
|
1061
1061
|
if (i === "prev" && c === "freeScroll") {
|
|
1062
1062
|
const k = _.current[a === "x" ? "scrollLeft" : "scrollTop"];
|
|
@@ -1091,14 +1091,14 @@ function Oe({
|
|
|
1091
1091
|
value: g
|
|
1092
1092
|
},
|
|
1093
1093
|
onRest({ finished: k }) {
|
|
1094
|
-
var
|
|
1094
|
+
var L;
|
|
1095
1095
|
k && c === "fixed" && z({
|
|
1096
1096
|
eventName: "onSlideChangeComplete",
|
|
1097
1097
|
sliceActionType: b,
|
|
1098
1098
|
slideDirection: i,
|
|
1099
1099
|
currentItem: {
|
|
1100
1100
|
index: l.current,
|
|
1101
|
-
id: ((
|
|
1101
|
+
id: ((L = t.at(l.current)) == null ? void 0 : L.id) ?? "",
|
|
1102
1102
|
startReached: T.current,
|
|
1103
1103
|
endReached: I.current
|
|
1104
1104
|
}
|
|
@@ -1159,7 +1159,7 @@ function Oe({
|
|
|
1159
1159
|
actionType: "resize"
|
|
1160
1160
|
});
|
|
1161
1161
|
}
|
|
1162
|
-
if (r && (C.current = !0,
|
|
1162
|
+
if (r && (C.current = !0, M.current = W() / 4, console.log(M.current)), r && c === "fixed")
|
|
1163
1163
|
return d(y), window.addEventListener("resize", E), () => {
|
|
1164
1164
|
window.removeEventListener("resize", E);
|
|
1165
1165
|
};
|
|
@@ -1168,7 +1168,7 @@ function Oe({
|
|
|
1168
1168
|
(i) => {
|
|
1169
1169
|
if (!C.current)
|
|
1170
1170
|
return;
|
|
1171
|
-
const d = i.dragging, E = i.offset[a === "x" ? 0 : 1], b = i.movement[a === "x" ? 0 : 1], m = b >
|
|
1171
|
+
const d = i.dragging, E = i.offset[a === "x" ? 0 : 1], b = i.movement[a === "x" ? 0 : 1], m = b > M.current, A = b < -M.current, D = i.velocity;
|
|
1172
1172
|
d && (z({
|
|
1173
1173
|
...i,
|
|
1174
1174
|
eventName: "onDrag",
|
|
@@ -1185,7 +1185,7 @@ function Oe({
|
|
|
1185
1185
|
}), i.cancel()) : A ? (j({
|
|
1186
1186
|
actionType: "drag",
|
|
1187
1187
|
type: "next"
|
|
1188
|
-
}), i.cancel()) : (G.start({
|
|
1188
|
+
}), console.log("here2222"), i.cancel()) : (G.start({
|
|
1189
1189
|
value: B.current,
|
|
1190
1190
|
config: {
|
|
1191
1191
|
velocity: D
|
|
@@ -1204,7 +1204,7 @@ function Oe({
|
|
|
1204
1204
|
bottom: 0
|
|
1205
1205
|
})
|
|
1206
1206
|
},
|
|
1207
|
-
from: () => [
|
|
1207
|
+
from: () => [R.value.get(), R.value.get()]
|
|
1208
1208
|
}
|
|
1209
1209
|
);
|
|
1210
1210
|
function Ot(i) {
|
|
@@ -1219,6 +1219,7 @@ function Oe({
|
|
|
1219
1219
|
className: "ReactSpringCarouselContainer",
|
|
1220
1220
|
"data-part": "Container",
|
|
1221
1221
|
"data-part-internal": `${n}-Container`,
|
|
1222
|
+
...Ct(),
|
|
1222
1223
|
children: [
|
|
1223
1224
|
/* @__PURE__ */ Q(
|
|
1224
1225
|
"style",
|
|
@@ -1272,13 +1273,12 @@ function Oe({
|
|
|
1272
1273
|
className: "ReactSpringCarouselTrack",
|
|
1273
1274
|
"data-part": "Track",
|
|
1274
1275
|
"data-part-internal": `${n}-Track`,
|
|
1275
|
-
...Ct(),
|
|
1276
1276
|
onScroll: () => {
|
|
1277
1277
|
T.current = !1, I.current = !1;
|
|
1278
1278
|
},
|
|
1279
1279
|
...c === "freeScroll" ? {
|
|
1280
1280
|
onWheel() {
|
|
1281
|
-
T.current = !1, I.current = !1,
|
|
1281
|
+
T.current = !1, I.current = !1, R.value.stop();
|
|
1282
1282
|
}
|
|
1283
1283
|
} : {},
|
|
1284
1284
|
children: Dt.map((i, d) => /* @__PURE__ */ Q(
|
package/dist/index.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(O,N){typeof exports=="object"&&typeof module<"u"?N(exports,require("react/jsx-runtime"),require("@react-spring/web"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","@react-spring/web","react"],N):(O=typeof globalThis<"u"?globalThis:O||self,N(O["react-spring-carousel"]={},O["react/jsx-runtime"],O["@react-spring/web"],O.React))})(this,function(O,N,Ie,y){"use strict";function De(r,e,t){return Math.max(e,Math.min(r,t))}const v={toVector(r,e){return r===void 0&&(r=e),Array.isArray(r)?r:[r,r]},add(r,e){return[r[0]+e[0],r[1]+e[1]]},sub(r,e){return[r[0]-e[0],r[1]-e[1]]},addTo(r,e){r[0]+=e[0],r[1]+=e[1]},subTo(r,e){r[0]-=e[0],r[1]-=e[1]}};function se(r,e,t){return e===0||Math.abs(e)===1/0?Math.pow(r,t*5):r*e*t/(e+t*r)}function ie(r,e,t,n=.15){return n===0?De(r,e,t):r<e?-se(e-r,t-e,n)+e:r>t?+se(r-t,t-e,n)+t:r}function ke(r,[e,t],[n,s]){const[[o,u],[a,c]]=r;return[ie(e,o,u,n),ie(t,a,c,s)]}function Ce(r,e){if(typeof r!="object"||r===null)return r;var t=r[Symbol.toPrimitive];if(t!==void 0){var n=t.call(r,e);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(r)}function Oe(r){var e=Ce(r,"string");return typeof e=="symbol"?e:String(e)}function b(r,e,t){return e=Oe(e),e in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function oe(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);e&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(r,s).enumerable})),t.push.apply(t,n)}return t}function h(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?oe(Object(t),!0).forEach(function(n){b(r,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):oe(Object(t)).forEach(function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(t,n))})}return r}const ae={pointer:{start:"down",change:"move",end:"up"},mouse:{start:"down",change:"move",end:"up"},touch:{start:"start",change:"move",end:"end"},gesture:{start:"start",change:"change",end:"end"}};function ce(r){return r?r[0].toUpperCase()+r.slice(1):""}const Ae=["enter","leave"];function $e(r=!1,e){return r&&!Ae.includes(e)}function Pe(r,e="",t=!1){const n=ae[r],s=n&&n[e]||e;return"on"+ce(r)+ce(s)+($e(t,s)?"Capture":"")}const Ne=["gotpointercapture","lostpointercapture"];function Me(r){let e=r.substring(2).toLowerCase();const t=!!~e.indexOf("passive");t&&(e=e.replace("passive",""));const n=Ne.includes(e)?"capturecapture":"capture",s=!!~e.indexOf(n);return s&&(e=e.replace("capture","")),{device:e,capture:s,passive:t}}function Le(r,e=""){const t=ae[r],n=t&&t[e]||e;return r+n}function W(r){return"touches"in r}function ue(r){return W(r)?"touch":"pointerType"in r?r.pointerType:"mouse"}function Re(r){return Array.from(r.touches).filter(e=>{var t,n;return e.target===r.currentTarget||((t=r.currentTarget)===null||t===void 0||(n=t.contains)===null||n===void 0?void 0:n.call(t,e.target))})}function Ve(r){return r.type==="touchend"||r.type==="touchcancel"?r.changedTouches:r.targetTouches}function fe(r){return W(r)?Ve(r)[0]:r}function je(r){return Re(r).map(e=>e.identifier)}function q(r){const e=fe(r);return W(r)?e.identifier:e.pointerId}function le(r){const e=fe(r);return[e.clientX,e.clientY]}function Ue(r){const e={};if("buttons"in r&&(e.buttons=r.buttons),"shiftKey"in r){const{shiftKey:t,altKey:n,metaKey:s,ctrlKey:o}=r;Object.assign(e,{shiftKey:t,altKey:n,metaKey:s,ctrlKey:o})}return e}function Y(r,...e){return typeof r=="function"?r(...e):r}function Ke(){}function Be(...r){return r.length===0?Ke:r.length===1?r[0]:function(){let e;for(const t of r)e=t.apply(this,arguments)||e;return e}}function de(r,e){return Object.assign({},e,r||{})}const ze=32;class We{constructor(e,t,n){this.ctrl=e,this.args=t,this.key=n,this.state||(this.state={},this.computeValues([0,0]),this.computeInitial(),this.init&&this.init(),this.reset())}get state(){return this.ctrl.state[this.key]}set state(e){this.ctrl.state[this.key]=e}get shared(){return this.ctrl.state.shared}get eventStore(){return this.ctrl.gestureEventStores[this.key]}get timeoutStore(){return this.ctrl.gestureTimeoutStores[this.key]}get config(){return this.ctrl.config[this.key]}get sharedConfig(){return this.ctrl.config.shared}get handler(){return this.ctrl.handlers[this.key]}reset(){const{state:e,shared:t,ingKey:n,args:s}=this;t[n]=e._active=e.active=e._blocked=e._force=!1,e._step=[!1,!1],e.intentional=!1,e._movement=[0,0],e._distance=[0,0],e._direction=[0,0],e._delta=[0,0],e._bounds=[[-1/0,1/0],[-1/0,1/0]],e.args=s,e.axis=void 0,e.memo=void 0,e.elapsedTime=e.timeDelta=0,e.direction=[0,0],e.distance=[0,0],e.overflow=[0,0],e._movementBound=[!1,!1],e.velocity=[0,0],e.movement=[0,0],e.delta=[0,0],e.timeStamp=0}start(e){const t=this.state,n=this.config;t._active||(this.reset(),this.computeInitial(),t._active=!0,t.target=e.target,t.currentTarget=e.currentTarget,t.lastOffset=n.from?Y(n.from,t):t.offset,t.offset=t.lastOffset,t.startTime=t.timeStamp=e.timeStamp)}computeValues(e){const t=this.state;t._values=e,t.values=this.config.transform(e)}computeInitial(){const e=this.state;e._initial=e._values,e.initial=e.values}compute(e){const{state:t,config:n,shared:s}=this;t.args=this.args;let o=0;if(e&&(t.event=e,n.preventDefault&&e.cancelable&&t.event.preventDefault(),t.type=e.type,s.touches=this.ctrl.pointerIds.size||this.ctrl.touchIds.size,s.locked=!!document.pointerLockElement,Object.assign(s,Ue(e)),s.down=s.pressed=s.buttons%2===1||s.touches>0,o=e.timeStamp-t.timeStamp,t.timeStamp=e.timeStamp,t.elapsedTime=t.timeStamp-t.startTime),t._active){const l=t._delta.map(Math.abs);v.addTo(t._distance,l)}this.axisIntent&&this.axisIntent(e);const[u,a]=t._movement,[c,p]=n.threshold,{_step:f,values:T}=t;if(n.hasCustomTransform?(f[0]===!1&&(f[0]=Math.abs(u)>=c&&T[0]),f[1]===!1&&(f[1]=Math.abs(a)>=p&&T[1])):(f[0]===!1&&(f[0]=Math.abs(u)>=c&&Math.sign(u)*c),f[1]===!1&&(f[1]=Math.abs(a)>=p&&Math.sign(a)*p)),t.intentional=f[0]!==!1||f[1]!==!1,!t.intentional)return;const _=[0,0];if(n.hasCustomTransform){const[l,V]=T;_[0]=f[0]!==!1?l-f[0]:0,_[1]=f[1]!==!1?V-f[1]:0}else _[0]=f[0]!==!1?u-f[0]:0,_[1]=f[1]!==!1?a-f[1]:0;this.restrictToAxis&&!t._blocked&&this.restrictToAxis(_);const M=t.offset,R=t._active&&!t._blocked||t.active;R&&(t.first=t._active&&!t.active,t.last=!t._active&&t.active,t.active=s[this.ingKey]=t._active,e&&(t.first&&("bounds"in n&&(t._bounds=Y(n.bounds,t)),this.setup&&this.setup()),t.movement=_,this.computeOffset()));const[A,$]=t.offset,[[w,H],[I,D]]=t._bounds;t.overflow=[A<w?-1:A>H?1:0,$<I?-1:$>D?1:0],t._movementBound[0]=t.overflow[0]?t._movementBound[0]===!1?t._movement[0]:t._movementBound[0]:!1,t._movementBound[1]=t.overflow[1]?t._movementBound[1]===!1?t._movement[1]:t._movementBound[1]:!1;const B=t._active?n.rubberband||[0,0]:[0,0];if(t.offset=ke(t._bounds,t.offset,B),t.delta=v.sub(t.offset,M),this.computeMovement(),R&&(!t.last||o>ze)){t.delta=v.sub(t.offset,M);const l=t.delta.map(Math.abs);v.addTo(t.distance,l),t.direction=t.delta.map(Math.sign),t._direction=t._delta.map(Math.sign),!t.first&&o>0&&(t.velocity=[l[0]/o,l[1]/o],t.timeDelta=o)}}emit(){const e=this.state,t=this.shared,n=this.config;if(e._active||this.clean(),(e._blocked||!e.intentional)&&!e._force&&!n.triggerAllEvents)return;const s=this.handler(h(h(h({},t),e),{},{[this.aliasKey]:e.values}));s!==void 0&&(e.memo=s)}clean(){this.eventStore.clean(),this.timeoutStore.clean()}}function Ye([r,e],t){const n=Math.abs(r),s=Math.abs(e);if(n>s&&n>t)return"x";if(s>n&&s>t)return"y"}class Fe extends We{constructor(...e){super(...e),b(this,"aliasKey","xy")}reset(){super.reset(),this.state.axis=void 0}init(){this.state.offset=[0,0],this.state.lastOffset=[0,0]}computeOffset(){this.state.offset=v.add(this.state.lastOffset,this.state.movement)}computeMovement(){this.state.movement=v.sub(this.state.offset,this.state.lastOffset)}axisIntent(e){const t=this.state,n=this.config;if(!t.axis&&e){const s=typeof n.axisThreshold=="object"?n.axisThreshold[ue(e)]:n.axisThreshold;t.axis=Ye(t._movement,s)}t._blocked=(n.lockDirection||!!n.axis)&&!t.axis||!!n.axis&&n.axis!==t.axis}restrictToAxis(e){if(this.config.axis||this.config.lockDirection)switch(this.state.axis){case"x":e[1]=0;break;case"y":e[0]=0;break}}}const he=r=>r,pe=.15,J={enabled(r=!0){return r},eventOptions(r,e,t){return h(h({},t.shared.eventOptions),r)},preventDefault(r=!1){return r},triggerAllEvents(r=!1){return r},rubberband(r=0){switch(r){case!0:return[pe,pe];case!1:return[0,0];default:return v.toVector(r)}},from(r){if(typeof r=="function")return r;if(r!=null)return v.toVector(r)},transform(r,e,t){const n=r||t.shared.transform;if(this.hasCustomTransform=!!n,process.env.NODE_ENV==="development"){const s=n||he;return o=>{const u=s(o);return(!isFinite(u[0])||!isFinite(u[1]))&&console.warn(`[@use-gesture]: config.transform() must produce a valid result, but it was: [${u[0]},${[1]}]`),u}}return n||he},threshold(r){return v.toVector(r,0)}};process.env.NODE_ENV==="development"&&Object.assign(J,{domTarget(r){if(r!==void 0)throw Error("[@use-gesture]: `domTarget` option has been renamed to `target`.");return NaN},lockDirection(r){if(r!==void 0)throw Error("[@use-gesture]: `lockDirection` option has been merged with `axis`. Use it as in `{ axis: 'lock' }`");return NaN},initial(r){if(r!==void 0)throw Error("[@use-gesture]: `initial` option has been renamed to `from`.");return NaN}});const He=0,U=h(h({},J),{},{axis(r,e,{axis:t}){if(this.lockDirection=t==="lock",!this.lockDirection)return t},axisThreshold(r=He){return r},bounds(r={}){if(typeof r=="function")return o=>U.bounds(r(o));if("current"in r)return()=>r.current;if(typeof HTMLElement=="function"&&r instanceof HTMLElement)return r;const{left:e=-1/0,right:t=1/0,top:n=-1/0,bottom:s=1/0}=r;return[[e,t],[n,s]]}}),ge={ArrowRight:(r,e=1)=>[r*e,0],ArrowLeft:(r,e=1)=>[-1*r*e,0],ArrowUp:(r,e=1)=>[0,-1*r*e],ArrowDown:(r,e=1)=>[0,r*e]};class Ge extends Fe{constructor(...e){super(...e),b(this,"ingKey","dragging")}reset(){super.reset();const e=this.state;e._pointerId=void 0,e._pointerActive=!1,e._keyboardActive=!1,e._preventScroll=!1,e._delayed=!1,e.swipe=[0,0],e.tap=!1,e.canceled=!1,e.cancel=this.cancel.bind(this)}setup(){const e=this.state;if(e._bounds instanceof HTMLElement){const t=e._bounds.getBoundingClientRect(),n=e.currentTarget.getBoundingClientRect(),s={left:t.left-n.left+e.offset[0],right:t.right-n.right+e.offset[0],top:t.top-n.top+e.offset[1],bottom:t.bottom-n.bottom+e.offset[1]};e._bounds=U.bounds(s)}}cancel(){const e=this.state;e.canceled||(e.canceled=!0,e._active=!1,setTimeout(()=>{this.compute(),this.emit()},0))}setActive(){this.state._active=this.state._pointerActive||this.state._keyboardActive}clean(){this.pointerClean(),this.state._pointerActive=!1,this.state._keyboardActive=!1,super.clean()}pointerDown(e){const t=this.config,n=this.state;if(e.buttons!=null&&(Array.isArray(t.pointerButtons)?!t.pointerButtons.includes(e.buttons):t.pointerButtons!==-1&&t.pointerButtons!==e.buttons))return;const s=this.ctrl.setEventIds(e);t.pointerCapture&&e.target.setPointerCapture(e.pointerId),!(s&&s.size>1&&n._pointerActive)&&(this.start(e),this.setupPointer(e),n._pointerId=q(e),n._pointerActive=!0,this.computeValues(le(e)),this.computeInitial(),t.preventScrollAxis&&ue(e)!=="mouse"?(n._active=!1,this.setupScrollPrevention(e)):t.delay>0?(this.setupDelayTrigger(e),t.triggerAllEvents&&(this.compute(e),this.emit())):this.startPointerDrag(e))}startPointerDrag(e){const t=this.state;t._active=!0,t._preventScroll=!0,t._delayed=!1,this.compute(e),this.emit()}pointerMove(e){const t=this.state,n=this.config;if(!t._pointerActive)return;const s=q(e);if(t._pointerId!==void 0&&s!==t._pointerId)return;const o=le(e);if(document.pointerLockElement===e.target?t._delta=[e.movementX,e.movementY]:(t._delta=v.sub(o,t._values),this.computeValues(o)),v.addTo(t._movement,t._delta),this.compute(e),t._delayed&&t.intentional){this.timeoutStore.remove("dragDelay"),t.active=!1,this.startPointerDrag(e);return}if(n.preventScrollAxis&&!t._preventScroll)if(t.axis)if(t.axis===n.preventScrollAxis||n.preventScrollAxis==="xy"){t._active=!1,this.clean();return}else{this.timeoutStore.remove("startPointerDrag"),this.startPointerDrag(e);return}else return;this.emit()}pointerUp(e){this.ctrl.setEventIds(e);try{this.config.pointerCapture&&e.target.hasPointerCapture(e.pointerId)&&e.target.releasePointerCapture(e.pointerId)}catch{process.env.NODE_ENV==="development"&&console.warn("[@use-gesture]: If you see this message, it's likely that you're using an outdated version of `@react-three/fiber`. \n\nPlease upgrade to the latest version.")}const t=this.state,n=this.config;if(!t._active||!t._pointerActive)return;const s=q(e);if(t._pointerId!==void 0&&s!==t._pointerId)return;this.state._pointerActive=!1,this.setActive(),this.compute(e);const[o,u]=t._distance;if(t.tap=o<=n.tapsThreshold&&u<=n.tapsThreshold,t.tap&&n.filterTaps)t._force=!0;else{const[a,c]=t._delta,[p,f]=t._movement,[T,_]=n.swipe.velocity,[M,R]=n.swipe.distance,A=n.swipe.duration;if(t.elapsedTime<A){const $=Math.abs(a/t.timeDelta),w=Math.abs(c/t.timeDelta);$>T&&Math.abs(p)>M&&(t.swipe[0]=Math.sign(a)),w>_&&Math.abs(f)>R&&(t.swipe[1]=Math.sign(c))}}this.emit()}pointerClick(e){!this.state.tap&&e.detail>0&&(e.preventDefault(),e.stopPropagation())}setupPointer(e){const t=this.config,n=t.device;if(process.env.NODE_ENV==="development")try{if(n==="pointer"&&t.preventScrollDelay===void 0){const s="uv"in e?e.sourceEvent.currentTarget:e.currentTarget;window.getComputedStyle(s).touchAction==="auto"&&console.warn("[@use-gesture]: The drag target has its `touch-action` style property set to `auto`. It is recommended to add `touch-action: 'none'` so that the drag gesture behaves correctly on touch-enabled devices. For more information read this: https://use-gesture.netlify.app/docs/extras/#touch-action.\n\nThis message will only show in development mode. It won't appear in production. If this is intended, you can ignore it.",s)}}catch{}t.pointerLock&&e.currentTarget.requestPointerLock(),t.pointerCapture||(this.eventStore.add(this.sharedConfig.window,n,"change",this.pointerMove.bind(this)),this.eventStore.add(this.sharedConfig.window,n,"end",this.pointerUp.bind(this)),this.eventStore.add(this.sharedConfig.window,n,"cancel",this.pointerUp.bind(this)))}pointerClean(){this.config.pointerLock&&document.pointerLockElement===this.state.currentTarget&&document.exitPointerLock()}preventScroll(e){this.state._preventScroll&&e.cancelable&&e.preventDefault()}setupScrollPrevention(e){this.state._preventScroll=!1,Xe(e);const t=this.eventStore.add(this.sharedConfig.window,"touch","change",this.preventScroll.bind(this),{passive:!1});this.eventStore.add(this.sharedConfig.window,"touch","end",t),this.eventStore.add(this.sharedConfig.window,"touch","cancel",t),this.timeoutStore.add("startPointerDrag",this.startPointerDrag.bind(this),this.config.preventScrollDelay,e)}setupDelayTrigger(e){this.state._delayed=!0,this.timeoutStore.add("dragDelay",()=>{this.state._step=[0,0],this.startPointerDrag(e)},this.config.delay)}keyDown(e){const t=ge[e.key];if(t){const n=this.state,s=e.shiftKey?10:e.altKey?.1:1;this.start(e),n._delta=t(this.config.keyboardDisplacement,s),n._keyboardActive=!0,v.addTo(n._movement,n._delta),this.compute(e),this.emit()}}keyUp(e){e.key in ge&&(this.state._keyboardActive=!1,this.setActive(),this.compute(e),this.emit())}bind(e){const t=this.config.device;e(t,"start",this.pointerDown.bind(this)),this.config.pointerCapture&&(e(t,"change",this.pointerMove.bind(this)),e(t,"end",this.pointerUp.bind(this)),e(t,"cancel",this.pointerUp.bind(this)),e("lostPointerCapture","",this.pointerUp.bind(this))),this.config.keys&&(e("key","down",this.keyDown.bind(this)),e("key","up",this.keyUp.bind(this))),this.config.filterTaps&&e("click","",this.pointerClick.bind(this),{capture:!0,passive:!1})}}function Xe(r){"persist"in r&&typeof r.persist=="function"&&r.persist()}const K=typeof window<"u"&&window.document&&window.document.createElement;function me(){return K&&"ontouchstart"in window}function qe(){return me()||K&&window.navigator.maxTouchPoints>1}function Je(){return K&&"onpointerdown"in window}function Qe(){return K&&"exitPointerLock"in window.document}function Ze(){try{return"constructor"in GestureEvent}catch{return!1}}const S={isBrowser:K,gesture:Ze(),touch:me(),touchscreen:qe(),pointer:Je(),pointerLock:Qe()},et=250,tt=180,rt=.5,nt=50,st=250,it=10,ve={mouse:0,touch:0,pen:8},ye=h(h({},U),{},{device(r,e,{pointer:{touch:t=!1,lock:n=!1,mouse:s=!1}={}}){return this.pointerLock=n&&S.pointerLock,S.touch&&t?"touch":this.pointerLock?"mouse":S.pointer&&!s?"pointer":S.touch?"touch":"mouse"},preventScrollAxis(r,e,{preventScroll:t}){if(this.preventScrollDelay=typeof t=="number"?t:t||t===void 0&&r?et:void 0,!(!S.touchscreen||t===!1))return r||(t!==void 0?"y":void 0)},pointerCapture(r,e,{pointer:{capture:t=!0,buttons:n=1,keys:s=!0}={}}){return this.pointerButtons=n,this.keys=s,!this.pointerLock&&this.device==="pointer"&&t},threshold(r,e,{filterTaps:t=!1,tapsThreshold:n=3,axis:s=void 0}){const o=v.toVector(r,t?n:s?1:0);return this.filterTaps=t,this.tapsThreshold=n,o},swipe({velocity:r=rt,distance:e=nt,duration:t=st}={}){return{velocity:this.transform(v.toVector(r)),distance:this.transform(v.toVector(e)),duration:t}},delay(r=0){switch(r){case!0:return tt;case!1:return 0;default:return r}},axisThreshold(r){return r?h(h({},ve),r):ve},keyboardDisplacement(r=it){return r}});process.env.NODE_ENV==="development"&&Object.assign(ye,{useTouch(r){if(r!==void 0)throw Error("[@use-gesture]: `useTouch` option has been renamed to `pointer.touch`. Use it as in `{ pointer: { touch: true } }`.");return NaN},experimental_preventWindowScrollY(r){if(r!==void 0)throw Error("[@use-gesture]: `experimental_preventWindowScrollY` option has been renamed to `preventScroll`.");return NaN},swipeVelocity(r){if(r!==void 0)throw Error("[@use-gesture]: `swipeVelocity` option has been renamed to `swipe.velocity`. Use it as in `{ swipe: { velocity: 0.5 } }`.");return NaN},swipeDistance(r){if(r!==void 0)throw Error("[@use-gesture]: `swipeDistance` option has been renamed to `swipe.distance`. Use it as in `{ swipe: { distance: 50 } }`.");return NaN},swipeDuration(r){if(r!==void 0)throw Error("[@use-gesture]: `swipeDuration` option has been renamed to `swipe.duration`. Use it as in `{ swipe: { duration: 250 } }`.");return NaN}}),h(h({},J),{},{device(r,e,{shared:t,pointer:{touch:n=!1}={}}){if(t.target&&!S.touch&&S.gesture)return"gesture";if(S.touch&&n)return"touch";if(S.touchscreen){if(S.pointer)return"pointer";if(S.touch)return"touch"}},bounds(r,e,{scaleBounds:t={},angleBounds:n={}}){const s=u=>{const a=de(Y(t,u),{min:-1/0,max:1/0});return[a.min,a.max]},o=u=>{const a=de(Y(n,u),{min:-1/0,max:1/0});return[a.min,a.max]};return typeof t!="function"&&typeof n!="function"?[s(),o()]:u=>[s(u),o(u)]},threshold(r,e,t){return this.lockDirection=t.axis==="lock",v.toVector(r,this.lockDirection?[.1,3]:0)},modifierKey(r){return r===void 0?"ctrlKey":r},pinchOnWheel(r=!0){return r}}),h(h({},U),{},{mouseOnly:(r=!0)=>r}),h(h({},U),{},{mouseOnly:(r=!0)=>r});const _e=new Map,Q=new Map;function ot(r){_e.set(r.key,r.engine),Q.set(r.key,r.resolver)}const at={key:"drag",engine:Ge,resolver:ye};function ct(r,e){if(r==null)return{};var t={},n=Object.keys(r),s,o;for(o=0;o<n.length;o++)s=n[o],!(e.indexOf(s)>=0)&&(t[s]=r[s]);return t}function ut(r,e){if(r==null)return{};var t=ct(r,e),n,s;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(r);for(s=0;s<o.length;s++)n=o[s],!(e.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(r,n)&&(t[n]=r[n])}return t}const ft={target(r){if(r)return()=>"current"in r?r.current:r},enabled(r=!0){return r},window(r=S.isBrowser?window:void 0){return r},eventOptions({passive:r=!0,capture:e=!1}={}){return{passive:r,capture:e}},transform(r){return r}},lt=["target","eventOptions","window","enabled","transform"];function F(r={},e){const t={};for(const[n,s]of Object.entries(e))switch(typeof s){case"function":if(process.env.NODE_ENV==="development"){const o=s.call(t,r[n],n,r);Number.isNaN(o)||(t[n]=o)}else t[n]=s.call(t,r[n],n,r);break;case"object":t[n]=F(r[n],s);break;case"boolean":s&&(t[n]=r[n]);break}return t}function dt(r,e,t={}){const n=r,{target:s,eventOptions:o,window:u,enabled:a,transform:c}=n,p=ut(n,lt);if(t.shared=F({target:s,eventOptions:o,window:u,enabled:a,transform:c},ft),e){const f=Q.get(e);t[e]=F(h({shared:t.shared},p),f)}else for(const f in p){const T=Q.get(f);if(T)t[f]=F(h({shared:t.shared},p[f]),T);else if(process.env.NODE_ENV==="development"&&!["drag","pinch","scroll","wheel","move","hover"].includes(f)){if(f==="domTarget")throw Error("[@use-gesture]: `domTarget` option has been renamed to `target`.");console.warn(`[@use-gesture]: Unknown config key \`${f}\` was used. Please read the documentation for further information.`)}}return t}class be{constructor(e,t){b(this,"_listeners",new Set),this._ctrl=e,this._gestureKey=t}add(e,t,n,s,o){const u=this._listeners,a=Le(t,n),c=this._gestureKey?this._ctrl.config[this._gestureKey].eventOptions:{},p=h(h({},c),o);e.addEventListener(a,s,p);const f=()=>{e.removeEventListener(a,s,p),u.delete(f)};return u.add(f),f}clean(){this._listeners.forEach(e=>e()),this._listeners.clear()}}class ht{constructor(){b(this,"_timeouts",new Map)}add(e,t,n=140,...s){this.remove(e),this._timeouts.set(e,window.setTimeout(t,n,...s))}remove(e){const t=this._timeouts.get(e);t&&window.clearTimeout(t)}clean(){this._timeouts.forEach(e=>void window.clearTimeout(e)),this._timeouts.clear()}}class pt{constructor(e){b(this,"gestures",new Set),b(this,"_targetEventStore",new be(this)),b(this,"gestureEventStores",{}),b(this,"gestureTimeoutStores",{}),b(this,"handlers",{}),b(this,"config",{}),b(this,"pointerIds",new Set),b(this,"touchIds",new Set),b(this,"state",{shared:{shiftKey:!1,metaKey:!1,ctrlKey:!1,altKey:!1}}),gt(this,e)}setEventIds(e){if(W(e))return this.touchIds=new Set(je(e)),this.touchIds;if("pointerId"in e)return e.type==="pointerup"||e.type==="pointercancel"?this.pointerIds.delete(e.pointerId):e.type==="pointerdown"&&this.pointerIds.add(e.pointerId),this.pointerIds}applyHandlers(e,t){this.handlers=e,this.nativeHandlers=t}applyConfig(e,t){this.config=dt(e,t,this.config)}clean(){this._targetEventStore.clean();for(const e of this.gestures)this.gestureEventStores[e].clean(),this.gestureTimeoutStores[e].clean()}effect(){return this.config.shared.target&&this.bind(),()=>this._targetEventStore.clean()}bind(...e){const t=this.config.shared,n={};let s;if(!(t.target&&(s=t.target(),!s))){if(t.enabled){for(const u of this.gestures){const a=this.config[u],c=we(n,a.eventOptions,!!s);if(a.enabled){const p=_e.get(u);new p(this,e,u).bind(c)}}const o=we(n,t.eventOptions,!!s);for(const u in this.nativeHandlers)o(u,"",a=>this.nativeHandlers[u](h(h({},this.state.shared),{},{event:a,args:e})),void 0,!0)}for(const o in n)n[o]=Be(...n[o]);if(!s)return n;for(const o in n){const{device:u,capture:a,passive:c}=Me(o);this._targetEventStore.add(s,u,"",n[o],{capture:a,passive:c})}}}}function L(r,e){r.gestures.add(e),r.gestureEventStores[e]=new be(r,e),r.gestureTimeoutStores[e]=new ht}function gt(r,e){e.drag&&L(r,"drag"),e.wheel&&L(r,"wheel"),e.scroll&&L(r,"scroll"),e.move&&L(r,"move"),e.pinch&&L(r,"pinch"),e.hover&&L(r,"hover")}const we=(r,e,t)=>(n,s,o,u={},a=!1)=>{var c,p;const f=(c=u.capture)!==null&&c!==void 0?c:e.capture,T=(p=u.passive)!==null&&p!==void 0?p:e.passive;let _=a?n:Pe(n,s,f);t&&T&&(_+="Passive"),r[_]=r[_]||[],r[_].push(o)};function mt(r,e={},t,n){const s=y.useMemo(()=>new pt(r),[]);if(s.applyHandlers(r,n),s.applyConfig(e,t),y.useEffect(s.effect.bind(s)),y.useEffect(()=>s.clean.bind(s),[]),e.target===void 0)return s.bind.bind(s)}function vt(r,e){return ot(at),mt({drag:r},e||{},"drag")}const Z="RSC::Event";function yt(){const r=y.useRef(null);function e(n){y.useEffect(()=>{r.current||(r.current=document.createElement("div"));function s(o){n(o.detail)}if(r.current)return r.current.addEventListener(Z,s,!1),()=>{var o;(o=r.current)==null||o.removeEventListener(Z,s,!1)}},[n])}function t(n){if(r.current){const s=new CustomEvent(Z,{detail:n});r.current.dispatchEvent(s)}}return{useListenToCustomEvent:e,emitEvent:t}}function _t({init:r=!0,items:e,withLoop:t=!1,id:n,itemsPerSlide:s=1,gutter:o=0,startEndGutter:u=0,carouselAxis:a="x",slideType:c="fixed",startingPosition:p="start",enableGestures:f=!0,slideWhenDragThresholdIsReached:T=!0,onInit:_}){const[M,R]=y.useState(!1),A=y.useRef(r),$=y.useRef(null),w=y.useRef(null),H=y.useRef(0),I=y.useRef(!t),D=y.useRef(!1),B=y.useRef(0),l=y.useRef(0),[V,ee]=Ie.useSpring(()=>({value:0,onChange({value:i}){c==="fixed"&&$.current.style.setProperty(`--${n}-offset-position`,`${i.value}px`),c==="freeScroll"&&(w.current[a==="x"?"scrollLeft":"scrollTop"]=Math.abs(i.value))}}),[a]),bt=c!=="freeScroll"&&t?[...e.map(i=>({...i,id:`prev-repeated-item-${i.id}`,isClonedItem:!0})),...e,...e.map(i=>({...i,id:`next-repeated-item-${i.id}`,isClonedItem:!0}))]:e,{useListenToCustomEvent:Ee,emitEvent:G}=yt();function te(i){A.current&&(D.current||z({type:"next",toIndex:i,actionType:"click"}))}function re(i){A.current&&(I.current||z({type:"prev",toIndex:i,actionType:"click"}))}function z({type:i,shouldAnimate:d=!0,toIndex:x,actionType:E}){var Se,Te;const g=X(),P=!d;I.current=!1,D.current=!1;let k=V.value.get(),m=0;if(i==="next"&&c==="fixed"&&(l.current+=1),i==="prev"&&c==="fixed"&&(l.current===0?l.current=e.length-1:l.current-=1),i==="next"&&c==="fixed"){const C=ne(t?g*(e.length*2):0);m=-(l.current*g),t&&l.current===e.length&&(l.current=0,k=k+g*e.length,m=0),!t&&Math.abs(m)>=C&&(D.current=!0,m=-C)}if(i==="prev"&&c==="fixed"&&(m=-(l.current*g),l.current===e.length-1&&(k=k-e.length*g),!t&&m>=0&&(I.current=!0,m=0)),i==="next"&&c==="freeScroll"){const C=w.current[a==="x"?"scrollLeft":"scrollTop"],j=a==="x"?w.current.scrollWidth-w.current.clientWidth:w.current.scrollHeight-w.current.clientHeight;k=C,m=C+g,(m>j||j-m<80)&&(m=j,D.current=!0)}if(i==="prev"&&c==="freeScroll"){const C=w.current[a==="x"?"scrollLeft":"scrollTop"];k=C,m=C-g,m<=0&&(m=0,I.current=!0)}H.current=m,E==="resize"?(m=-(l.current*g),G({eventName:"onResize",sliceActionType:E,slideDirection:i,currentItem:{index:l.current,id:((Se=e.at(l.current))==null?void 0:Se.id)??"",startReached:I.current,endReached:D.current}})):G({eventName:"onSlideStartChange",sliceActionType:E,slideDirection:i,nextItem:{index:l.current,id:((Te=e.at(l.current))==null?void 0:Te.id)??"",startReached:I.current,endReached:D.current}}),x!==void 0&&(l.current=x),ee.start({immediate:P,from:{value:k},to:{value:m},onRest({finished:C}){var j;C&&c==="fixed"&&G({eventName:"onSlideChangeComplete",sliceActionType:E,slideDirection:i,currentItem:{index:l.current,id:((j=e.at(l.current))==null?void 0:j.id)??"",startReached:I.current,endReached:D.current}})}})}function X(){const i=w.current.children[0];let d=0;return d=i.getBoundingClientRect()[a==="x"?"width":"height"]+o,d}function ne(i){const d=w.current;return d[a==="x"?"scrollWidth":"scrollHeight"]-d.getBoundingClientRect()[a==="x"?"width":"height"]-i}function wt(){let i=0;const d=getComputedStyle(document.documentElement).getPropertyValue(`--${n}-start-end-gutter`);return d.includes("px")&&(i=Number(d.replace("px",""))),{totalStartEndGutterCssVar:i}}y.useEffect(()=>{function i(E,g){switch(E){case"start":return 0;case"middle-start":return Math.floor((g-1)*.25);case"center":return Math.floor((g-1)*.5);case"middle-end":return Math.floor((g-1)*.75);case"end":return g-1;default:return 0}}function d(E){if($.current){const{totalStartEndGutterCssVar:g}=wt();let P=0;t&&(P=X()*e.length),P-=X()*i(p,s),P-=g/2,$.current.style.setProperty(`--${n}-offset-modifier`,`${-P}px`),R(!0),E&&E()}}function x(){d(),z({type:"resize",toIndex:l.current,shouldAnimate:!1,actionType:"resize"})}if(r&&(A.current=!0,B.current=X()/4),r&&c==="fixed")return d(_),window.addEventListener("resize",x),()=>{window.removeEventListener("resize",x)}},[r,t,n,a,o,p,c]);const xe=f&&c!=="freeScroll",Et=vt(i=>{if(!A.current)return;const d=i.dragging,x=i.offset[a==="x"?0:1],E=i.movement[a==="x"?0:1],g=E>B.current,P=E<-B.current,k=i.velocity;d&&(G({...i,eventName:"onDrag",slideActionType:"drag"}),ee.start({value:x,immediate:!0,config:{velocity:k}}),T&&(g||P)&&i.cancel()),i.last&&(g?(z({actionType:"drag",type:"prev"}),i.cancel()):P?(z({actionType:"drag",type:"next"}),i.cancel()):(ee.start({value:H.current,config:{velocity:k}}),i.cancel()))},{enabled:xe,axis:a,rubberband:!t,...t?{}:{bounds:()=>({right:0,left:-ne(0),top:-ne(0),bottom:0})},from:()=>[V.value.get(),V.value.get()]});function xt(i){var d,x;return typeof i=="number"?l.current===i:((d=e.find(E=>E.id===i))==null?void 0:d.id)===((x=e[l.current])==null?void 0:x.id)}return{carouselFragment:N.jsxs("div",{ref:$,className:"ReactSpringCarouselContainer","data-part":"Container","data-part-internal":`${n}-Container`,children:[N.jsx("style",{dangerouslySetInnerHTML:{__html:`
|
|
1
|
+
(function(O,N){typeof exports=="object"&&typeof module<"u"?N(exports,require("react/jsx-runtime"),require("@react-spring/web"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","@react-spring/web","react"],N):(O=typeof globalThis<"u"?globalThis:O||self,N(O["react-spring-carousel"]={},O["react/jsx-runtime"],O["@react-spring/web"],O.React))})(this,function(O,N,Ie,y){"use strict";function De(r,e,t){return Math.max(e,Math.min(r,t))}const v={toVector(r,e){return r===void 0&&(r=e),Array.isArray(r)?r:[r,r]},add(r,e){return[r[0]+e[0],r[1]+e[1]]},sub(r,e){return[r[0]-e[0],r[1]-e[1]]},addTo(r,e){r[0]+=e[0],r[1]+=e[1]},subTo(r,e){r[0]-=e[0],r[1]-=e[1]}};function se(r,e,t){return e===0||Math.abs(e)===1/0?Math.pow(r,t*5):r*e*t/(e+t*r)}function ie(r,e,t,n=.15){return n===0?De(r,e,t):r<e?-se(e-r,t-e,n)+e:r>t?+se(r-t,t-e,n)+t:r}function ke(r,[e,t],[n,s]){const[[o,u],[a,c]]=r;return[ie(e,o,u,n),ie(t,a,c,s)]}function Ce(r,e){if(typeof r!="object"||r===null)return r;var t=r[Symbol.toPrimitive];if(t!==void 0){var n=t.call(r,e);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(r)}function Oe(r){var e=Ce(r,"string");return typeof e=="symbol"?e:String(e)}function b(r,e,t){return e=Oe(e),e in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function oe(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);e&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(r,s).enumerable})),t.push.apply(t,n)}return t}function h(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?oe(Object(t),!0).forEach(function(n){b(r,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):oe(Object(t)).forEach(function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(t,n))})}return r}const ae={pointer:{start:"down",change:"move",end:"up"},mouse:{start:"down",change:"move",end:"up"},touch:{start:"start",change:"move",end:"end"},gesture:{start:"start",change:"change",end:"end"}};function ce(r){return r?r[0].toUpperCase()+r.slice(1):""}const Ae=["enter","leave"];function $e(r=!1,e){return r&&!Ae.includes(e)}function Pe(r,e="",t=!1){const n=ae[r],s=n&&n[e]||e;return"on"+ce(r)+ce(s)+($e(t,s)?"Capture":"")}const Ne=["gotpointercapture","lostpointercapture"];function Me(r){let e=r.substring(2).toLowerCase();const t=!!~e.indexOf("passive");t&&(e=e.replace("passive",""));const n=Ne.includes(e)?"capturecapture":"capture",s=!!~e.indexOf(n);return s&&(e=e.replace("capture","")),{device:e,capture:s,passive:t}}function Le(r,e=""){const t=ae[r],n=t&&t[e]||e;return r+n}function W(r){return"touches"in r}function ue(r){return W(r)?"touch":"pointerType"in r?r.pointerType:"mouse"}function Re(r){return Array.from(r.touches).filter(e=>{var t,n;return e.target===r.currentTarget||((t=r.currentTarget)===null||t===void 0||(n=t.contains)===null||n===void 0?void 0:n.call(t,e.target))})}function Ve(r){return r.type==="touchend"||r.type==="touchcancel"?r.changedTouches:r.targetTouches}function fe(r){return W(r)?Ve(r)[0]:r}function je(r){return Re(r).map(e=>e.identifier)}function q(r){const e=fe(r);return W(r)?e.identifier:e.pointerId}function le(r){const e=fe(r);return[e.clientX,e.clientY]}function Ue(r){const e={};if("buttons"in r&&(e.buttons=r.buttons),"shiftKey"in r){const{shiftKey:t,altKey:n,metaKey:s,ctrlKey:o}=r;Object.assign(e,{shiftKey:t,altKey:n,metaKey:s,ctrlKey:o})}return e}function Y(r,...e){return typeof r=="function"?r(...e):r}function Ke(){}function Be(...r){return r.length===0?Ke:r.length===1?r[0]:function(){let e;for(const t of r)e=t.apply(this,arguments)||e;return e}}function de(r,e){return Object.assign({},e,r||{})}const ze=32;class We{constructor(e,t,n){this.ctrl=e,this.args=t,this.key=n,this.state||(this.state={},this.computeValues([0,0]),this.computeInitial(),this.init&&this.init(),this.reset())}get state(){return this.ctrl.state[this.key]}set state(e){this.ctrl.state[this.key]=e}get shared(){return this.ctrl.state.shared}get eventStore(){return this.ctrl.gestureEventStores[this.key]}get timeoutStore(){return this.ctrl.gestureTimeoutStores[this.key]}get config(){return this.ctrl.config[this.key]}get sharedConfig(){return this.ctrl.config.shared}get handler(){return this.ctrl.handlers[this.key]}reset(){const{state:e,shared:t,ingKey:n,args:s}=this;t[n]=e._active=e.active=e._blocked=e._force=!1,e._step=[!1,!1],e.intentional=!1,e._movement=[0,0],e._distance=[0,0],e._direction=[0,0],e._delta=[0,0],e._bounds=[[-1/0,1/0],[-1/0,1/0]],e.args=s,e.axis=void 0,e.memo=void 0,e.elapsedTime=e.timeDelta=0,e.direction=[0,0],e.distance=[0,0],e.overflow=[0,0],e._movementBound=[!1,!1],e.velocity=[0,0],e.movement=[0,0],e.delta=[0,0],e.timeStamp=0}start(e){const t=this.state,n=this.config;t._active||(this.reset(),this.computeInitial(),t._active=!0,t.target=e.target,t.currentTarget=e.currentTarget,t.lastOffset=n.from?Y(n.from,t):t.offset,t.offset=t.lastOffset,t.startTime=t.timeStamp=e.timeStamp)}computeValues(e){const t=this.state;t._values=e,t.values=this.config.transform(e)}computeInitial(){const e=this.state;e._initial=e._values,e.initial=e.values}compute(e){const{state:t,config:n,shared:s}=this;t.args=this.args;let o=0;if(e&&(t.event=e,n.preventDefault&&e.cancelable&&t.event.preventDefault(),t.type=e.type,s.touches=this.ctrl.pointerIds.size||this.ctrl.touchIds.size,s.locked=!!document.pointerLockElement,Object.assign(s,Ue(e)),s.down=s.pressed=s.buttons%2===1||s.touches>0,o=e.timeStamp-t.timeStamp,t.timeStamp=e.timeStamp,t.elapsedTime=t.timeStamp-t.startTime),t._active){const l=t._delta.map(Math.abs);v.addTo(t._distance,l)}this.axisIntent&&this.axisIntent(e);const[u,a]=t._movement,[c,p]=n.threshold,{_step:f,values:T}=t;if(n.hasCustomTransform?(f[0]===!1&&(f[0]=Math.abs(u)>=c&&T[0]),f[1]===!1&&(f[1]=Math.abs(a)>=p&&T[1])):(f[0]===!1&&(f[0]=Math.abs(u)>=c&&Math.sign(u)*c),f[1]===!1&&(f[1]=Math.abs(a)>=p&&Math.sign(a)*p)),t.intentional=f[0]!==!1||f[1]!==!1,!t.intentional)return;const _=[0,0];if(n.hasCustomTransform){const[l,j]=T;_[0]=f[0]!==!1?l-f[0]:0,_[1]=f[1]!==!1?j-f[1]:0}else _[0]=f[0]!==!1?u-f[0]:0,_[1]=f[1]!==!1?a-f[1]:0;this.restrictToAxis&&!t._blocked&&this.restrictToAxis(_);const M=t.offset,R=t._active&&!t._blocked||t.active;R&&(t.first=t._active&&!t.active,t.last=!t._active&&t.active,t.active=s[this.ingKey]=t._active,e&&(t.first&&("bounds"in n&&(t._bounds=Y(n.bounds,t)),this.setup&&this.setup()),t.movement=_,this.computeOffset()));const[A,$]=t.offset,[[w,H],[I,D]]=t._bounds;t.overflow=[A<w?-1:A>H?1:0,$<I?-1:$>D?1:0],t._movementBound[0]=t.overflow[0]?t._movementBound[0]===!1?t._movement[0]:t._movementBound[0]:!1,t._movementBound[1]=t.overflow[1]?t._movementBound[1]===!1?t._movement[1]:t._movementBound[1]:!1;const V=t._active?n.rubberband||[0,0]:[0,0];if(t.offset=ke(t._bounds,t.offset,V),t.delta=v.sub(t.offset,M),this.computeMovement(),R&&(!t.last||o>ze)){t.delta=v.sub(t.offset,M);const l=t.delta.map(Math.abs);v.addTo(t.distance,l),t.direction=t.delta.map(Math.sign),t._direction=t._delta.map(Math.sign),!t.first&&o>0&&(t.velocity=[l[0]/o,l[1]/o],t.timeDelta=o)}}emit(){const e=this.state,t=this.shared,n=this.config;if(e._active||this.clean(),(e._blocked||!e.intentional)&&!e._force&&!n.triggerAllEvents)return;const s=this.handler(h(h(h({},t),e),{},{[this.aliasKey]:e.values}));s!==void 0&&(e.memo=s)}clean(){this.eventStore.clean(),this.timeoutStore.clean()}}function Ye([r,e],t){const n=Math.abs(r),s=Math.abs(e);if(n>s&&n>t)return"x";if(s>n&&s>t)return"y"}class Fe extends We{constructor(...e){super(...e),b(this,"aliasKey","xy")}reset(){super.reset(),this.state.axis=void 0}init(){this.state.offset=[0,0],this.state.lastOffset=[0,0]}computeOffset(){this.state.offset=v.add(this.state.lastOffset,this.state.movement)}computeMovement(){this.state.movement=v.sub(this.state.offset,this.state.lastOffset)}axisIntent(e){const t=this.state,n=this.config;if(!t.axis&&e){const s=typeof n.axisThreshold=="object"?n.axisThreshold[ue(e)]:n.axisThreshold;t.axis=Ye(t._movement,s)}t._blocked=(n.lockDirection||!!n.axis)&&!t.axis||!!n.axis&&n.axis!==t.axis}restrictToAxis(e){if(this.config.axis||this.config.lockDirection)switch(this.state.axis){case"x":e[1]=0;break;case"y":e[0]=0;break}}}const he=r=>r,pe=.15,J={enabled(r=!0){return r},eventOptions(r,e,t){return h(h({},t.shared.eventOptions),r)},preventDefault(r=!1){return r},triggerAllEvents(r=!1){return r},rubberband(r=0){switch(r){case!0:return[pe,pe];case!1:return[0,0];default:return v.toVector(r)}},from(r){if(typeof r=="function")return r;if(r!=null)return v.toVector(r)},transform(r,e,t){const n=r||t.shared.transform;if(this.hasCustomTransform=!!n,process.env.NODE_ENV==="development"){const s=n||he;return o=>{const u=s(o);return(!isFinite(u[0])||!isFinite(u[1]))&&console.warn(`[@use-gesture]: config.transform() must produce a valid result, but it was: [${u[0]},${[1]}]`),u}}return n||he},threshold(r){return v.toVector(r,0)}};process.env.NODE_ENV==="development"&&Object.assign(J,{domTarget(r){if(r!==void 0)throw Error("[@use-gesture]: `domTarget` option has been renamed to `target`.");return NaN},lockDirection(r){if(r!==void 0)throw Error("[@use-gesture]: `lockDirection` option has been merged with `axis`. Use it as in `{ axis: 'lock' }`");return NaN},initial(r){if(r!==void 0)throw Error("[@use-gesture]: `initial` option has been renamed to `from`.");return NaN}});const He=0,K=h(h({},J),{},{axis(r,e,{axis:t}){if(this.lockDirection=t==="lock",!this.lockDirection)return t},axisThreshold(r=He){return r},bounds(r={}){if(typeof r=="function")return o=>K.bounds(r(o));if("current"in r)return()=>r.current;if(typeof HTMLElement=="function"&&r instanceof HTMLElement)return r;const{left:e=-1/0,right:t=1/0,top:n=-1/0,bottom:s=1/0}=r;return[[e,t],[n,s]]}}),ge={ArrowRight:(r,e=1)=>[r*e,0],ArrowLeft:(r,e=1)=>[-1*r*e,0],ArrowUp:(r,e=1)=>[0,-1*r*e],ArrowDown:(r,e=1)=>[0,r*e]};class Ge extends Fe{constructor(...e){super(...e),b(this,"ingKey","dragging")}reset(){super.reset();const e=this.state;e._pointerId=void 0,e._pointerActive=!1,e._keyboardActive=!1,e._preventScroll=!1,e._delayed=!1,e.swipe=[0,0],e.tap=!1,e.canceled=!1,e.cancel=this.cancel.bind(this)}setup(){const e=this.state;if(e._bounds instanceof HTMLElement){const t=e._bounds.getBoundingClientRect(),n=e.currentTarget.getBoundingClientRect(),s={left:t.left-n.left+e.offset[0],right:t.right-n.right+e.offset[0],top:t.top-n.top+e.offset[1],bottom:t.bottom-n.bottom+e.offset[1]};e._bounds=K.bounds(s)}}cancel(){const e=this.state;e.canceled||(e.canceled=!0,e._active=!1,setTimeout(()=>{this.compute(),this.emit()},0))}setActive(){this.state._active=this.state._pointerActive||this.state._keyboardActive}clean(){this.pointerClean(),this.state._pointerActive=!1,this.state._keyboardActive=!1,super.clean()}pointerDown(e){const t=this.config,n=this.state;if(e.buttons!=null&&(Array.isArray(t.pointerButtons)?!t.pointerButtons.includes(e.buttons):t.pointerButtons!==-1&&t.pointerButtons!==e.buttons))return;const s=this.ctrl.setEventIds(e);t.pointerCapture&&e.target.setPointerCapture(e.pointerId),!(s&&s.size>1&&n._pointerActive)&&(this.start(e),this.setupPointer(e),n._pointerId=q(e),n._pointerActive=!0,this.computeValues(le(e)),this.computeInitial(),t.preventScrollAxis&&ue(e)!=="mouse"?(n._active=!1,this.setupScrollPrevention(e)):t.delay>0?(this.setupDelayTrigger(e),t.triggerAllEvents&&(this.compute(e),this.emit())):this.startPointerDrag(e))}startPointerDrag(e){const t=this.state;t._active=!0,t._preventScroll=!0,t._delayed=!1,this.compute(e),this.emit()}pointerMove(e){const t=this.state,n=this.config;if(!t._pointerActive)return;const s=q(e);if(t._pointerId!==void 0&&s!==t._pointerId)return;const o=le(e);if(document.pointerLockElement===e.target?t._delta=[e.movementX,e.movementY]:(t._delta=v.sub(o,t._values),this.computeValues(o)),v.addTo(t._movement,t._delta),this.compute(e),t._delayed&&t.intentional){this.timeoutStore.remove("dragDelay"),t.active=!1,this.startPointerDrag(e);return}if(n.preventScrollAxis&&!t._preventScroll)if(t.axis)if(t.axis===n.preventScrollAxis||n.preventScrollAxis==="xy"){t._active=!1,this.clean();return}else{this.timeoutStore.remove("startPointerDrag"),this.startPointerDrag(e);return}else return;this.emit()}pointerUp(e){this.ctrl.setEventIds(e);try{this.config.pointerCapture&&e.target.hasPointerCapture(e.pointerId)&&e.target.releasePointerCapture(e.pointerId)}catch{process.env.NODE_ENV==="development"&&console.warn("[@use-gesture]: If you see this message, it's likely that you're using an outdated version of `@react-three/fiber`. \n\nPlease upgrade to the latest version.")}const t=this.state,n=this.config;if(!t._active||!t._pointerActive)return;const s=q(e);if(t._pointerId!==void 0&&s!==t._pointerId)return;this.state._pointerActive=!1,this.setActive(),this.compute(e);const[o,u]=t._distance;if(t.tap=o<=n.tapsThreshold&&u<=n.tapsThreshold,t.tap&&n.filterTaps)t._force=!0;else{const[a,c]=t._delta,[p,f]=t._movement,[T,_]=n.swipe.velocity,[M,R]=n.swipe.distance,A=n.swipe.duration;if(t.elapsedTime<A){const $=Math.abs(a/t.timeDelta),w=Math.abs(c/t.timeDelta);$>T&&Math.abs(p)>M&&(t.swipe[0]=Math.sign(a)),w>_&&Math.abs(f)>R&&(t.swipe[1]=Math.sign(c))}}this.emit()}pointerClick(e){!this.state.tap&&e.detail>0&&(e.preventDefault(),e.stopPropagation())}setupPointer(e){const t=this.config,n=t.device;if(process.env.NODE_ENV==="development")try{if(n==="pointer"&&t.preventScrollDelay===void 0){const s="uv"in e?e.sourceEvent.currentTarget:e.currentTarget;window.getComputedStyle(s).touchAction==="auto"&&console.warn("[@use-gesture]: The drag target has its `touch-action` style property set to `auto`. It is recommended to add `touch-action: 'none'` so that the drag gesture behaves correctly on touch-enabled devices. For more information read this: https://use-gesture.netlify.app/docs/extras/#touch-action.\n\nThis message will only show in development mode. It won't appear in production. If this is intended, you can ignore it.",s)}}catch{}t.pointerLock&&e.currentTarget.requestPointerLock(),t.pointerCapture||(this.eventStore.add(this.sharedConfig.window,n,"change",this.pointerMove.bind(this)),this.eventStore.add(this.sharedConfig.window,n,"end",this.pointerUp.bind(this)),this.eventStore.add(this.sharedConfig.window,n,"cancel",this.pointerUp.bind(this)))}pointerClean(){this.config.pointerLock&&document.pointerLockElement===this.state.currentTarget&&document.exitPointerLock()}preventScroll(e){this.state._preventScroll&&e.cancelable&&e.preventDefault()}setupScrollPrevention(e){this.state._preventScroll=!1,Xe(e);const t=this.eventStore.add(this.sharedConfig.window,"touch","change",this.preventScroll.bind(this),{passive:!1});this.eventStore.add(this.sharedConfig.window,"touch","end",t),this.eventStore.add(this.sharedConfig.window,"touch","cancel",t),this.timeoutStore.add("startPointerDrag",this.startPointerDrag.bind(this),this.config.preventScrollDelay,e)}setupDelayTrigger(e){this.state._delayed=!0,this.timeoutStore.add("dragDelay",()=>{this.state._step=[0,0],this.startPointerDrag(e)},this.config.delay)}keyDown(e){const t=ge[e.key];if(t){const n=this.state,s=e.shiftKey?10:e.altKey?.1:1;this.start(e),n._delta=t(this.config.keyboardDisplacement,s),n._keyboardActive=!0,v.addTo(n._movement,n._delta),this.compute(e),this.emit()}}keyUp(e){e.key in ge&&(this.state._keyboardActive=!1,this.setActive(),this.compute(e),this.emit())}bind(e){const t=this.config.device;e(t,"start",this.pointerDown.bind(this)),this.config.pointerCapture&&(e(t,"change",this.pointerMove.bind(this)),e(t,"end",this.pointerUp.bind(this)),e(t,"cancel",this.pointerUp.bind(this)),e("lostPointerCapture","",this.pointerUp.bind(this))),this.config.keys&&(e("key","down",this.keyDown.bind(this)),e("key","up",this.keyUp.bind(this))),this.config.filterTaps&&e("click","",this.pointerClick.bind(this),{capture:!0,passive:!1})}}function Xe(r){"persist"in r&&typeof r.persist=="function"&&r.persist()}const B=typeof window<"u"&&window.document&&window.document.createElement;function me(){return B&&"ontouchstart"in window}function qe(){return me()||B&&window.navigator.maxTouchPoints>1}function Je(){return B&&"onpointerdown"in window}function Qe(){return B&&"exitPointerLock"in window.document}function Ze(){try{return"constructor"in GestureEvent}catch{return!1}}const S={isBrowser:B,gesture:Ze(),touch:me(),touchscreen:qe(),pointer:Je(),pointerLock:Qe()},et=250,tt=180,rt=.5,nt=50,st=250,it=10,ve={mouse:0,touch:0,pen:8},ye=h(h({},K),{},{device(r,e,{pointer:{touch:t=!1,lock:n=!1,mouse:s=!1}={}}){return this.pointerLock=n&&S.pointerLock,S.touch&&t?"touch":this.pointerLock?"mouse":S.pointer&&!s?"pointer":S.touch?"touch":"mouse"},preventScrollAxis(r,e,{preventScroll:t}){if(this.preventScrollDelay=typeof t=="number"?t:t||t===void 0&&r?et:void 0,!(!S.touchscreen||t===!1))return r||(t!==void 0?"y":void 0)},pointerCapture(r,e,{pointer:{capture:t=!0,buttons:n=1,keys:s=!0}={}}){return this.pointerButtons=n,this.keys=s,!this.pointerLock&&this.device==="pointer"&&t},threshold(r,e,{filterTaps:t=!1,tapsThreshold:n=3,axis:s=void 0}){const o=v.toVector(r,t?n:s?1:0);return this.filterTaps=t,this.tapsThreshold=n,o},swipe({velocity:r=rt,distance:e=nt,duration:t=st}={}){return{velocity:this.transform(v.toVector(r)),distance:this.transform(v.toVector(e)),duration:t}},delay(r=0){switch(r){case!0:return tt;case!1:return 0;default:return r}},axisThreshold(r){return r?h(h({},ve),r):ve},keyboardDisplacement(r=it){return r}});process.env.NODE_ENV==="development"&&Object.assign(ye,{useTouch(r){if(r!==void 0)throw Error("[@use-gesture]: `useTouch` option has been renamed to `pointer.touch`. Use it as in `{ pointer: { touch: true } }`.");return NaN},experimental_preventWindowScrollY(r){if(r!==void 0)throw Error("[@use-gesture]: `experimental_preventWindowScrollY` option has been renamed to `preventScroll`.");return NaN},swipeVelocity(r){if(r!==void 0)throw Error("[@use-gesture]: `swipeVelocity` option has been renamed to `swipe.velocity`. Use it as in `{ swipe: { velocity: 0.5 } }`.");return NaN},swipeDistance(r){if(r!==void 0)throw Error("[@use-gesture]: `swipeDistance` option has been renamed to `swipe.distance`. Use it as in `{ swipe: { distance: 50 } }`.");return NaN},swipeDuration(r){if(r!==void 0)throw Error("[@use-gesture]: `swipeDuration` option has been renamed to `swipe.duration`. Use it as in `{ swipe: { duration: 250 } }`.");return NaN}}),h(h({},J),{},{device(r,e,{shared:t,pointer:{touch:n=!1}={}}){if(t.target&&!S.touch&&S.gesture)return"gesture";if(S.touch&&n)return"touch";if(S.touchscreen){if(S.pointer)return"pointer";if(S.touch)return"touch"}},bounds(r,e,{scaleBounds:t={},angleBounds:n={}}){const s=u=>{const a=de(Y(t,u),{min:-1/0,max:1/0});return[a.min,a.max]},o=u=>{const a=de(Y(n,u),{min:-1/0,max:1/0});return[a.min,a.max]};return typeof t!="function"&&typeof n!="function"?[s(),o()]:u=>[s(u),o(u)]},threshold(r,e,t){return this.lockDirection=t.axis==="lock",v.toVector(r,this.lockDirection?[.1,3]:0)},modifierKey(r){return r===void 0?"ctrlKey":r},pinchOnWheel(r=!0){return r}}),h(h({},K),{},{mouseOnly:(r=!0)=>r}),h(h({},K),{},{mouseOnly:(r=!0)=>r});const _e=new Map,Q=new Map;function ot(r){_e.set(r.key,r.engine),Q.set(r.key,r.resolver)}const at={key:"drag",engine:Ge,resolver:ye};function ct(r,e){if(r==null)return{};var t={},n=Object.keys(r),s,o;for(o=0;o<n.length;o++)s=n[o],!(e.indexOf(s)>=0)&&(t[s]=r[s]);return t}function ut(r,e){if(r==null)return{};var t=ct(r,e),n,s;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(r);for(s=0;s<o.length;s++)n=o[s],!(e.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(r,n)&&(t[n]=r[n])}return t}const ft={target(r){if(r)return()=>"current"in r?r.current:r},enabled(r=!0){return r},window(r=S.isBrowser?window:void 0){return r},eventOptions({passive:r=!0,capture:e=!1}={}){return{passive:r,capture:e}},transform(r){return r}},lt=["target","eventOptions","window","enabled","transform"];function F(r={},e){const t={};for(const[n,s]of Object.entries(e))switch(typeof s){case"function":if(process.env.NODE_ENV==="development"){const o=s.call(t,r[n],n,r);Number.isNaN(o)||(t[n]=o)}else t[n]=s.call(t,r[n],n,r);break;case"object":t[n]=F(r[n],s);break;case"boolean":s&&(t[n]=r[n]);break}return t}function dt(r,e,t={}){const n=r,{target:s,eventOptions:o,window:u,enabled:a,transform:c}=n,p=ut(n,lt);if(t.shared=F({target:s,eventOptions:o,window:u,enabled:a,transform:c},ft),e){const f=Q.get(e);t[e]=F(h({shared:t.shared},p),f)}else for(const f in p){const T=Q.get(f);if(T)t[f]=F(h({shared:t.shared},p[f]),T);else if(process.env.NODE_ENV==="development"&&!["drag","pinch","scroll","wheel","move","hover"].includes(f)){if(f==="domTarget")throw Error("[@use-gesture]: `domTarget` option has been renamed to `target`.");console.warn(`[@use-gesture]: Unknown config key \`${f}\` was used. Please read the documentation for further information.`)}}return t}class be{constructor(e,t){b(this,"_listeners",new Set),this._ctrl=e,this._gestureKey=t}add(e,t,n,s,o){const u=this._listeners,a=Le(t,n),c=this._gestureKey?this._ctrl.config[this._gestureKey].eventOptions:{},p=h(h({},c),o);e.addEventListener(a,s,p);const f=()=>{e.removeEventListener(a,s,p),u.delete(f)};return u.add(f),f}clean(){this._listeners.forEach(e=>e()),this._listeners.clear()}}class ht{constructor(){b(this,"_timeouts",new Map)}add(e,t,n=140,...s){this.remove(e),this._timeouts.set(e,window.setTimeout(t,n,...s))}remove(e){const t=this._timeouts.get(e);t&&window.clearTimeout(t)}clean(){this._timeouts.forEach(e=>void window.clearTimeout(e)),this._timeouts.clear()}}class pt{constructor(e){b(this,"gestures",new Set),b(this,"_targetEventStore",new be(this)),b(this,"gestureEventStores",{}),b(this,"gestureTimeoutStores",{}),b(this,"handlers",{}),b(this,"config",{}),b(this,"pointerIds",new Set),b(this,"touchIds",new Set),b(this,"state",{shared:{shiftKey:!1,metaKey:!1,ctrlKey:!1,altKey:!1}}),gt(this,e)}setEventIds(e){if(W(e))return this.touchIds=new Set(je(e)),this.touchIds;if("pointerId"in e)return e.type==="pointerup"||e.type==="pointercancel"?this.pointerIds.delete(e.pointerId):e.type==="pointerdown"&&this.pointerIds.add(e.pointerId),this.pointerIds}applyHandlers(e,t){this.handlers=e,this.nativeHandlers=t}applyConfig(e,t){this.config=dt(e,t,this.config)}clean(){this._targetEventStore.clean();for(const e of this.gestures)this.gestureEventStores[e].clean(),this.gestureTimeoutStores[e].clean()}effect(){return this.config.shared.target&&this.bind(),()=>this._targetEventStore.clean()}bind(...e){const t=this.config.shared,n={};let s;if(!(t.target&&(s=t.target(),!s))){if(t.enabled){for(const u of this.gestures){const a=this.config[u],c=we(n,a.eventOptions,!!s);if(a.enabled){const p=_e.get(u);new p(this,e,u).bind(c)}}const o=we(n,t.eventOptions,!!s);for(const u in this.nativeHandlers)o(u,"",a=>this.nativeHandlers[u](h(h({},this.state.shared),{},{event:a,args:e})),void 0,!0)}for(const o in n)n[o]=Be(...n[o]);if(!s)return n;for(const o in n){const{device:u,capture:a,passive:c}=Me(o);this._targetEventStore.add(s,u,"",n[o],{capture:a,passive:c})}}}}function L(r,e){r.gestures.add(e),r.gestureEventStores[e]=new be(r,e),r.gestureTimeoutStores[e]=new ht}function gt(r,e){e.drag&&L(r,"drag"),e.wheel&&L(r,"wheel"),e.scroll&&L(r,"scroll"),e.move&&L(r,"move"),e.pinch&&L(r,"pinch"),e.hover&&L(r,"hover")}const we=(r,e,t)=>(n,s,o,u={},a=!1)=>{var c,p;const f=(c=u.capture)!==null&&c!==void 0?c:e.capture,T=(p=u.passive)!==null&&p!==void 0?p:e.passive;let _=a?n:Pe(n,s,f);t&&T&&(_+="Passive"),r[_]=r[_]||[],r[_].push(o)};function mt(r,e={},t,n){const s=y.useMemo(()=>new pt(r),[]);if(s.applyHandlers(r,n),s.applyConfig(e,t),y.useEffect(s.effect.bind(s)),y.useEffect(()=>s.clean.bind(s),[]),e.target===void 0)return s.bind.bind(s)}function vt(r,e){return ot(at),mt({drag:r},e||{},"drag")}const Z="RSC::Event";function yt(){const r=y.useRef(null);function e(n){y.useEffect(()=>{r.current||(r.current=document.createElement("div"));function s(o){n(o.detail)}if(r.current)return r.current.addEventListener(Z,s,!1),()=>{var o;(o=r.current)==null||o.removeEventListener(Z,s,!1)}},[n])}function t(n){if(r.current){const s=new CustomEvent(Z,{detail:n});r.current.dispatchEvent(s)}}return{useListenToCustomEvent:e,emitEvent:t}}function _t({init:r=!0,items:e,withLoop:t=!1,id:n,itemsPerSlide:s=1,gutter:o=0,startEndGutter:u=0,carouselAxis:a="x",slideType:c="fixed",startingPosition:p="start",enableGestures:f=!0,slideWhenDragThresholdIsReached:T=!0,onInit:_}){const[M,R]=y.useState(!1),A=y.useRef(r),$=y.useRef(null),w=y.useRef(null),H=y.useRef(0),I=y.useRef(!t),D=y.useRef(!1),V=y.useRef(0),l=y.useRef(0),[j,ee]=Ie.useSpring(()=>({value:0,onChange({value:i}){c==="fixed"&&$.current.style.setProperty(`--${n}-offset-position`,`${i.value}px`),c==="freeScroll"&&(w.current[a==="x"?"scrollLeft":"scrollTop"]=Math.abs(i.value))}}),[a]),bt=c!=="freeScroll"&&t?[...e.map(i=>({...i,id:`prev-repeated-item-${i.id}`,isClonedItem:!0})),...e,...e.map(i=>({...i,id:`next-repeated-item-${i.id}`,isClonedItem:!0}))]:e,{useListenToCustomEvent:Ee,emitEvent:G}=yt();function te(i){A.current&&(D.current||z({type:"next",toIndex:i,actionType:"click"}))}function re(i){A.current&&(I.current||z({type:"prev",toIndex:i,actionType:"click"}))}function z({type:i,shouldAnimate:d=!0,toIndex:x,actionType:E}){var Se,Te;const g=X(),P=!d;I.current=!1,D.current=!1;let k=j.value.get(),m=0;if(i==="next"&&c==="fixed"&&(l.current+=1),i==="prev"&&c==="fixed"&&(l.current===0?l.current=e.length-1:l.current-=1),i==="next"&&c==="fixed"){const C=ne(t?g*(e.length*2):0);m=-(l.current*g),t&&l.current===e.length&&(l.current=0,k=k+g*e.length,m=0),!t&&Math.abs(m)>=C&&(D.current=!0,m=-C)}if(i==="prev"&&c==="fixed"&&(m=-(l.current*g),l.current===e.length-1&&(k=k-e.length*g),!t&&m>=0&&(I.current=!0,m=0)),i==="next"&&c==="freeScroll"){const C=w.current[a==="x"?"scrollLeft":"scrollTop"],U=a==="x"?w.current.scrollWidth-w.current.clientWidth:w.current.scrollHeight-w.current.clientHeight;k=C,m=C+g,(m>U||U-m<80)&&(m=U,D.current=!0)}if(i==="prev"&&c==="freeScroll"){const C=w.current[a==="x"?"scrollLeft":"scrollTop"];k=C,m=C-g,m<=0&&(m=0,I.current=!0)}H.current=m,E==="resize"?(m=-(l.current*g),G({eventName:"onResize",sliceActionType:E,slideDirection:i,currentItem:{index:l.current,id:((Se=e.at(l.current))==null?void 0:Se.id)??"",startReached:I.current,endReached:D.current}})):G({eventName:"onSlideStartChange",sliceActionType:E,slideDirection:i,nextItem:{index:l.current,id:((Te=e.at(l.current))==null?void 0:Te.id)??"",startReached:I.current,endReached:D.current}}),x!==void 0&&(l.current=x),ee.start({immediate:P,from:{value:k},to:{value:m},onRest({finished:C}){var U;C&&c==="fixed"&&G({eventName:"onSlideChangeComplete",sliceActionType:E,slideDirection:i,currentItem:{index:l.current,id:((U=e.at(l.current))==null?void 0:U.id)??"",startReached:I.current,endReached:D.current}})}})}function X(){const i=w.current.children[0];let d=0;return d=i.getBoundingClientRect()[a==="x"?"width":"height"]+o,d}function ne(i){const d=w.current;return d[a==="x"?"scrollWidth":"scrollHeight"]-d.getBoundingClientRect()[a==="x"?"width":"height"]-i}function wt(){let i=0;const d=getComputedStyle(document.documentElement).getPropertyValue(`--${n}-start-end-gutter`);return d.includes("px")&&(i=Number(d.replace("px",""))),{totalStartEndGutterCssVar:i}}y.useEffect(()=>{function i(E,g){switch(E){case"start":return 0;case"middle-start":return Math.floor((g-1)*.25);case"center":return Math.floor((g-1)*.5);case"middle-end":return Math.floor((g-1)*.75);case"end":return g-1;default:return 0}}function d(E){if($.current){const{totalStartEndGutterCssVar:g}=wt();let P=0;t&&(P=X()*e.length),P-=X()*i(p,s),P-=g/2,$.current.style.setProperty(`--${n}-offset-modifier`,`${-P}px`),R(!0),E&&E()}}function x(){d(),z({type:"resize",toIndex:l.current,shouldAnimate:!1,actionType:"resize"})}if(r&&(A.current=!0,V.current=X()/4,console.log(V.current)),r&&c==="fixed")return d(_),window.addEventListener("resize",x),()=>{window.removeEventListener("resize",x)}},[r,t,n,a,o,p,c]);const xe=f&&c!=="freeScroll",Et=vt(i=>{if(!A.current)return;const d=i.dragging,x=i.offset[a==="x"?0:1],E=i.movement[a==="x"?0:1],g=E>V.current,P=E<-V.current,k=i.velocity;d&&(G({...i,eventName:"onDrag",slideActionType:"drag"}),ee.start({value:x,immediate:!0,config:{velocity:k}}),T&&(g||P)&&i.cancel()),i.last&&(g?(z({actionType:"drag",type:"prev"}),i.cancel()):P?(z({actionType:"drag",type:"next"}),console.log("here2222"),i.cancel()):(ee.start({value:H.current,config:{velocity:k}}),i.cancel()))},{enabled:xe,axis:a,rubberband:!t,...t?{}:{bounds:()=>({right:0,left:-ne(0),top:-ne(0),bottom:0})},from:()=>[j.value.get(),j.value.get()]});function xt(i){var d,x;return typeof i=="number"?l.current===i:((d=e.find(E=>E.id===i))==null?void 0:d.id)===((x=e[l.current])==null?void 0:x.id)}return{carouselFragment:N.jsxs("div",{ref:$,className:"ReactSpringCarouselContainer","data-part":"Container","data-part-internal":`${n}-Container`,...Et(),children:[N.jsx("style",{dangerouslySetInnerHTML:{__html:`
|
|
2
2
|
:root {
|
|
3
3
|
--${n}-start-end-gutter: ${u*2}px;
|
|
4
4
|
--${n}-gutter: ${o}px;
|
|
@@ -35,4 +35,4 @@
|
|
|
35
35
|
display: flex;
|
|
36
36
|
flex: ${c==="fixed"?`1 0 calc(100% / var(--${n}-items-per-slide) - calc(var(--${n}-gutter) * (var(--${n}-items-per-slide) - 1)) / var(--${n}-items-per-slide) - calc(var(--${n}-start-end-gutter) / var(--${n}-items-per-slide)))`:"1"};
|
|
37
37
|
}
|
|
38
|
-
`}}),N.jsx("div",{ref:w,className:"ReactSpringCarouselTrack","data-part":"Track","data-part-internal":`${n}-Track
|
|
38
|
+
`}}),N.jsx("div",{ref:w,className:"ReactSpringCarouselTrack","data-part":"Track","data-part-internal":`${n}-Track`,onScroll:()=>{I.current=!1,D.current=!1},...c==="freeScroll"?{onWheel(){I.current=!1,D.current=!1,j.value.stop()}}:{},children:bt.map((i,d)=>N.jsx("div",{className:"ReactSpringCarouselItem","data-part":"Item","data-part-internal":`${n}-Item`,"data-id":i.id,children:typeof i.renderItem=="function"?i.renderItem({useListenToCustomEvent:Ee,index:d,isClonedItem:!!i.isClonedItem,isActiveItem:xt}):i.renderItem},`${i.id}-${d}`))})]}),useListenToCustomEvent:Ee,slideToNextItem:()=>te(),slideToPrevItem:()=>re(),slideToItem:i=>{if(typeof i=="number"){if(!e[i]){console.warn(`The item you're trying to slide doesn't exist. index: ${i}`);return}i>l.current?te(i):re(i)}if(typeof i=="string"){const d=e.findIndex(x=>x.id===i);if(d<0){console.warn(`The item you're trying to slide doesn't exist. id: ${i}`);return}d>l.current?te(d):re(d)}}}}O.useSpringCarousel=_t,Object.defineProperty(O,Symbol.toStringTag,{value:"Module"})});
|