UNPKG

dgz-ui

Version:

Custom ui library using React.js, Shadcn/ui, TailwindCSS, Typescript

1,442 lines (1,441 loc) 33.7 kB
import { jsx as X, jsxs as Jt } from "react/jsx-runtime"; import * as F from "react"; import { useRef as qt, useState as $t, useCallback as mn, useEffect as It } from "react"; import { useTranslation as Xt } from "react-i18next"; import { c as gt } from "../chunks/utils-CnvKSirc.es.js"; import { B as Yt } from "../chunks/button-DTRIYqDb.es.js"; import { c as Zt } from "../chunks/createLucideIcon-CyFYF6Ug.es.js"; /** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */ const gn = [ ["path", { d: "m12 19-7-7 7-7", key: "1l729n" }], ["path", { d: "M19 12H5", key: "x3x0zl" }] ], hn = Zt("arrow-left", gn); /** * @license lucide-react v0.563.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */ const yn = [ ["path", { d: "M5 12h14", key: "1ays0h" }], ["path", { d: "m12 5 7 7-7 7", key: "xquz4c" }] ], Sn = Zt("arrow-right", yn); function bn(t) { return Object.prototype.toString.call(t) === "[object Object]"; } function Kt(t) { return bn(t) || Array.isArray(t); } function xn() { return !!(typeof window < "u" && window.document && window.document.createElement); } function At(t, n) { const o = Object.keys(t), r = Object.keys(n); if (o.length !== r.length) return !1; const u = JSON.stringify(Object.keys(t.breakpoints || {})), s = JSON.stringify(Object.keys(n.breakpoints || {})); return u !== s ? !1 : o.every((e) => { const a = t[e], i = n[e]; return typeof a == "function" ? `${a}` == `${i}` : !Kt(a) || !Kt(i) ? a === i : At(a, i); }); } function Ut(t) { return t.concat().sort((n, o) => n.name > o.name ? 1 : -1).map((n) => n.options); } function En(t, n) { if (t.length !== n.length) return !1; const o = Ut(t), r = Ut(n); return o.every((u, s) => { const e = r[s]; return At(u, e); }); } function Dt(t) { return typeof t == "number"; } function Tt(t) { return typeof t == "string"; } function bt(t) { return typeof t == "boolean"; } function _t(t) { return Object.prototype.toString.call(t) === "[object Object]"; } function D(t) { return Math.abs(t); } function Pt(t) { return Math.sign(t); } function ft(t, n) { return D(t - n); } function vn(t, n) { if (t === 0 || n === 0 || D(t) <= D(n)) return 0; const o = ft(D(t), D(n)); return D(o / t); } function Ln(t) { return Math.round(t * 100) / 100; } function dt(t) { return pt(t).map(Number); } function j(t) { return t[ht(t)]; } function ht(t) { return Math.max(0, t.length - 1); } function Ot(t, n) { return n === ht(t); } function Qt(t, n = 0) { return Array.from(Array(t), (o, r) => n + r); } function pt(t) { return Object.keys(t); } function Wt(t, n) { return [t, n].reduce((o, r) => (pt(r).forEach((u) => { const s = o[u], e = r[u], a = _t(s) && _t(e); o[u] = a ? Wt(s, e) : e; }), o), {}); } function Nt(t, n) { return typeof n.MouseEvent < "u" && t instanceof n.MouseEvent; } function wn(t, n) { const o = { start: r, center: u, end: s }; function r() { return 0; } function u(i) { return s(i) / 2; } function s(i) { return n - i; } function e(i, c) { return Tt(t) ? o[t](i) : t(n, i, c); } return { measure: e }; } function mt() { let t = []; function n(u, s, e, a = { passive: !0 }) { let i; if ("addEventListener" in u) u.addEventListener(s, e, a), i = () => u.removeEventListener(s, e, a); else { const c = u; c.addListener(e), i = () => c.removeListener(e); } return t.push(i), r; } function o() { t = t.filter((u) => u()); } const r = { add: n, clear: o }; return r; } function Cn(t, n, o, r) { const u = mt(), s = 1e3 / 60; let e = null, a = 0, i = 0; function c() { u.add(t, "visibilitychange", () => { t.hidden && l(); }); } function y() { b(), u.clear(); } function d(h) { if (!i) return; e || (e = h, o(), o()); const f = h - e; for (e = h, a += f; a >= s; ) o(), a -= s; const g = a / s; r(g), i && (i = n.requestAnimationFrame(d)); } function p() { i || (i = n.requestAnimationFrame(d)); } function b() { n.cancelAnimationFrame(i), e = null, a = 0, i = 0; } function l() { e = null, a = 0; } return { init: c, destroy: y, start: p, stop: b, update: o, render: r }; } function In(t, n) { const o = n === "rtl", r = t === "y", u = r ? "y" : "x", s = r ? "x" : "y", e = !r && o ? -1 : 1, a = y(), i = d(); function c(l) { const { height: m, width: h } = l; return r ? m : h; } function y() { return r ? "top" : o ? "right" : "left"; } function d() { return r ? "bottom" : o ? "left" : "right"; } function p(l) { return l * e; } return { scroll: u, cross: s, startEdge: a, endEdge: i, measureSize: c, direction: p }; } function et(t = 0, n = 0) { const o = D(t - n); function r(c) { return c < t; } function u(c) { return c > n; } function s(c) { return r(c) || u(c); } function e(c) { return s(c) ? r(c) ? t : n : c; } function a(c) { return o ? c - o * Math.ceil((c - n) / o) : c; } return { length: o, max: n, min: t, constrain: e, reachedAny: s, reachedMax: u, reachedMin: r, removeOffset: a }; } function tn(t, n, o) { const { constrain: r } = et(0, t), u = t + 1; let s = e(n); function e(p) { return o ? D((u + p) % u) : r(p); } function a() { return s; } function i(p) { return s = e(p), d; } function c(p) { return y().set(a() + p); } function y() { return tn(t, a(), o); } const d = { get: a, set: i, add: c, clone: y }; return d; } function Tn(t, n, o, r, u, s, e, a, i, c, y, d, p, b, l, m, h, f, g) { const { cross: x, direction: L } = t, N = ["INPUT", "SELECT", "TEXTAREA"], w = { passive: !1 }, E = mt(), v = mt(), C = et(50, 225).constrain(b.measure(20)), P = { mouse: 300, touch: 400 }, I = { mouse: 500, touch: 600 }, z = l ? 43 : 25; let R = !1, H = 0, G = 0, W = !1, Y = !1, K = !1, U = !1; function it(S) { if (!g) return; function T(k) { (bt(g) || g(S, k)) && ut(k); } const O = n; E.add(O, "dragstart", (k) => k.preventDefault(), w).add(O, "touchmove", () => { }, w).add(O, "touchend", () => { }).add(O, "touchstart", T).add(O, "mousedown", T).add(O, "touchcancel", M).add(O, "contextmenu", M).add(O, "click", Q, !0); } function q() { E.clear(), v.clear(); } function ot() { const S = U ? o : n; v.add(S, "touchmove", B, w).add(S, "touchend", M).add(S, "mousemove", B, w).add(S, "mouseup", M); } function rt(S) { const T = S.nodeName || ""; return N.includes(T); } function _() { return (l ? I : P)[U ? "mouse" : "touch"]; } function ct(S, T) { const O = d.add(Pt(S) * -1), k = y.byDistance(S, !l).distance; return l || D(S) < C ? k : h && T ? k * 0.5 : y.byIndex(O.get(), 0).distance; } function ut(S) { const T = Nt(S, r); U = T, K = l && T && !S.buttons && R, R = ft(u.get(), e.get()) >= 2, !(T && S.button !== 0) && (rt(S.target) || (W = !0, s.pointerDown(S), c.useFriction(0).useDuration(0), u.set(e), ot(), H = s.readPoint(S), G = s.readPoint(S, x), p.emit("pointerDown"))); } function B(S) { if (!Nt(S, r) && S.touches.length >= 2) return M(S); const O = s.readPoint(S), k = s.readPoint(S, x), $ = ft(O, H), J = ft(k, G); if (!Y && !U && (!S.cancelable || (Y = $ > J, !Y))) return M(S); const tt = s.pointerMove(S); $ > m && (K = !0), c.useFriction(0.3).useDuration(0.75), a.start(), u.add(L(tt)), S.preventDefault(); } function M(S) { const O = y.byDistance(0, !1).index !== d.get(), k = s.pointerUp(S) * _(), $ = ct(L(k), O), J = vn(k, $), tt = z - 10 * J, Z = f + J / 50; Y = !1, W = !1, v.clear(), c.useDuration(tt).useFriction(Z), i.distance($, !l), U = !1, p.emit("pointerUp"); } function Q(S) { K && (S.stopPropagation(), S.preventDefault(), K = !1); } function V() { return W; } return { init: it, destroy: q, pointerDown: V }; } function Nn(t, n) { let r, u; function s(d) { return d.timeStamp; } function e(d, p) { const l = `client${(p || t.scroll) === "x" ? "X" : "Y"}`; return (Nt(d, n) ? d : d.touches[0])[l]; } function a(d) { return r = d, u = d, e(d); } function i(d) { const p = e(d) - e(u), b = s(d) - s(r) > 170; return u = d, b && (r = d), p; } function c(d) { if (!r || !u) return 0; const p = e(u) - e(r), b = s(d) - s(r), l = s(d) - s(u) > 170, m = p / b; return b && !l && D(m) > 0.1 ? m : 0; } return { pointerDown: a, pointerMove: i, pointerUp: c, readPoint: e }; } function An() { function t(o) { const { offsetTop: r, offsetLeft: u, offsetWidth: s, offsetHeight: e } = o; return { top: r, right: u + s, bottom: r + e, left: u, width: s, height: e }; } return { measure: t }; } function Dn(t) { function n(r) { return t * (r / 100); } return { measure: n }; } function Pn(t, n, o, r, u, s, e) { const a = [t].concat(r); let i, c, y = [], d = !1; function p(h) { return u.measureSize(e.measure(h)); } function b(h) { if (!s) return; c = p(t), y = r.map(p); function f(g) { for (const x of g) { if (d) return; const L = x.target === t, N = r.indexOf(x.target), w = L ? c : y[N], E = p(L ? t : r[N]); if (D(E - w) >= 0.5) { h.reInit(), n.emit("resize"); break; } } } i = new ResizeObserver((g) => { (bt(s) || s(h, g)) && f(g); }), o.requestAnimationFrame(() => { a.forEach((g) => i.observe(g)); }); } function l() { d = !0, i && i.disconnect(); } return { init: b, destroy: l }; } function On(t, n, o, r, u, s) { let e = 0, a = 0, i = u, c = s, y = t.get(), d = 0; function p() { const w = r.get() - t.get(), E = !i; let v = 0; return E ? (e = 0, o.set(r), t.set(r), v = w) : (o.set(t), e += w / i, e *= c, y += e, t.add(e), v = y - d), a = Pt(v), d = y, N; } function b() { const w = r.get() - n.get(); return D(w) < 1e-3; } function l() { return i; } function m() { return a; } function h() { return e; } function f() { return x(u); } function g() { return L(s); } function x(w) { return i = w, N; } function L(w) { return c = w, N; } const N = { direction: m, duration: l, velocity: h, seek: p, settled: b, useBaseFriction: g, useBaseDuration: f, useFriction: L, useDuration: x }; return N; } function Mn(t, n, o, r, u) { const s = u.measure(10), e = u.measure(50), a = et(0.1, 0.99); let i = !1; function c() { return !(i || !t.reachedAny(o.get()) || !t.reachedAny(n.get())); } function y(b) { if (!c()) return; const l = t.reachedMin(n.get()) ? "min" : "max", m = D(t[l] - n.get()), h = o.get() - n.get(), f = a.constrain(m / e); o.subtract(h * f), !b && D(h) < s && (o.set(t.constrain(o.get())), r.useDuration(25).useBaseFriction()); } function d(b) { i = !b; } return { shouldConstrain: c, constrain: y, toggleActive: d }; } function kn(t, n, o, r, u) { const s = et(-n + t, 0), e = d(), a = y(), i = p(); function c(l, m) { return ft(l, m) <= 1; } function y() { const l = e[0], m = j(e), h = e.lastIndexOf(l), f = e.indexOf(m) + 1; return et(h, f); } function d() { return o.map((l, m) => { const { min: h, max: f } = s, g = s.constrain(l), x = !m, L = Ot(o, m); return x ? f : L || c(h, g) ? h : c(f, g) ? f : g; }).map((l) => parseFloat(l.toFixed(3))); } function p() { if (n <= t + u) return [s.max]; if (r === "keepSnaps") return e; const { min: l, max: m } = a; return e.slice(l, m); } return { snapsContained: i, scrollContainLimit: a }; } function Fn(t, n, o) { const r = n[0], u = o ? r - t : j(n); return { limit: et(u, r) }; } function zn(t, n, o, r) { const s = n.min + 0.1, e = n.max + 0.1, { reachedMin: a, reachedMax: i } = et(s, e); function c(p) { return p === 1 ? i(o.get()) : p === -1 ? a(o.get()) : !1; } function y(p) { if (!c(p)) return; const b = t * (p * -1); r.forEach((l) => l.add(b)); } return { loop: y }; } function Bn(t) { const { max: n, length: o } = t; function r(s) { const e = s - n; return o ? e / -o : 0; } return { get: r }; } function Vn(t, n, o, r, u) { const { startEdge: s, endEdge: e } = t, { groupSlides: a } = u, i = d().map(n.measure), c = p(), y = b(); function d() { return a(r).map((m) => j(m)[e] - m[0][s]).map(D); } function p() { return r.map((m) => o[s] - m[s]).map((m) => -D(m)); } function b() { return a(c).map((m) => m[0]).map((m, h) => m + i[h]); } return { snaps: c, snapsAligned: y }; } function jn(t, n, o, r, u, s) { const { groupSlides: e } = u, { min: a, max: i } = r, c = y(); function y() { const p = e(s), b = !t || n === "keepSnaps"; return o.length === 1 ? [s] : b ? p : p.slice(a, i).map((l, m, h) => { const f = !m, g = Ot(h, m); if (f) { const x = j(h[0]) + 1; return Qt(x); } if (g) { const x = ht(s) - j(h)[0] + 1; return Qt(x, j(h)[0]); } return l; }); } return { slideRegistry: c }; } function Rn(t, n, o, r, u) { const { reachedAny: s, removeOffset: e, constrain: a } = r; function i(l) { return l.concat().sort((m, h) => D(m) - D(h))[0]; } function c(l) { const m = t ? e(l) : a(l), h = n.map((g, x) => ({ diff: y(g - m, 0), index: x })).sort((g, x) => D(g.diff) - D(x.diff)), { index: f } = h[0]; return { index: f, distance: m }; } function y(l, m) { const h = [l, l + o, l - o]; if (!t) return l; if (!m) return i(h); const f = h.filter((g) => Pt(g) === m); return f.length ? i(f) : j(h) - o; } function d(l, m) { const h = n[l] - u.get(), f = y(h, m); return { index: l, distance: f }; } function p(l, m) { const h = u.get() + l, { index: f, distance: g } = c(h), x = !t && s(h); if (!m || x) return { index: f, distance: l }; const L = n[f] - g, N = l + y(L, 0); return { index: f, distance: N }; } return { byDistance: p, byIndex: d, shortcut: y }; } function Hn(t, n, o, r, u, s, e) { function a(d) { const p = d.distance, b = d.index !== n.get(); s.add(p), p && (r.duration() ? t.start() : (t.update(), t.render(1), t.update())), b && (o.set(n.get()), n.set(d.index), e.emit("select")); } function i(d, p) { const b = u.byDistance(d, p); a(b); } function c(d, p) { const b = n.clone().set(d), l = u.byIndex(b.get(), p); a(l); } return { distance: i, index: c }; } function Gn(t, n, o, r, u, s, e, a) { const i = { passive: !0, capture: !0 }; let c = 0; function y(b) { if (!a) return; function l(m) { if ((/* @__PURE__ */ new Date()).getTime() - c > 10) return; e.emit("slideFocusStart"), t.scrollLeft = 0; const g = o.findIndex((x) => x.includes(m)); Dt(g) && (u.useDuration(0), r.index(g, 0), e.emit("slideFocus")); } s.add(document, "keydown", d, !1), n.forEach((m, h) => { s.add(m, "focus", (f) => { (bt(a) || a(b, f)) && l(h); }, i); }); } function d(b) { b.code === "Tab" && (c = (/* @__PURE__ */ new Date()).getTime()); } return { init: y }; } function lt(t) { let n = t; function o() { return n; } function r(i) { n = e(i); } function u(i) { n += e(i); } function s(i) { n -= e(i); } function e(i) { return Dt(i) ? i : i.get(); } return { get: o, set: r, add: u, subtract: s }; } function nn(t, n) { const o = t.scroll === "x" ? e : a, r = n.style; let u = null, s = !1; function e(p) { return `translate3d(${p}px,0px,0px)`; } function a(p) { return `translate3d(0px,${p}px,0px)`; } function i(p) { if (s) return; const b = Ln(t.direction(p)); b !== u && (r.transform = o(b), u = b); } function c(p) { s = !p; } function y() { s || (r.transform = "", n.getAttribute("style") || n.removeAttribute("style")); } return { clear: y, to: i, toggleActive: c }; } function qn(t, n, o, r, u, s, e, a, i) { const y = dt(u), d = dt(u).reverse(), p = f().concat(g()); function b(E, v) { return E.reduce((C, P) => C - u[P], v); } function l(E, v) { return E.reduce((C, P) => b(C, v) > 0 ? C.concat([P]) : C, []); } function m(E) { return s.map((v, C) => ({ start: v - r[C] + 0.5 + E, end: v + n - 0.5 + E })); } function h(E, v, C) { const P = m(v); return E.map((I) => { const z = C ? 0 : -o, R = C ? o : 0, H = C ? "end" : "start", G = P[I][H]; return { index: I, loopPoint: G, slideLocation: lt(-1), translate: nn(t, i[I]), target: () => a.get() > G ? z : R }; }); } function f() { const E = e[0], v = l(d, E); return h(v, o, !1); } function g() { const E = n - e[0] - 1, v = l(y, E); return h(v, -o, !0); } function x() { return p.every(({ index: E }) => { const v = y.filter((C) => C !== E); return b(v, n) <= 0.1; }); } function L() { p.forEach((E) => { const { target: v, translate: C, slideLocation: P } = E, I = v(); I !== P.get() && (C.to(I), P.set(I)); }); } function N() { p.forEach((E) => E.translate.clear()); } return { canLoop: x, clear: N, loop: L, loopPoints: p }; } function $n(t, n, o) { let r, u = !1; function s(i) { if (!o) return; function c(y) { for (const d of y) if (d.type === "childList") { i.reInit(), n.emit("slidesChanged"); break; } } r = new MutationObserver((y) => { u || (bt(o) || o(i, y)) && c(y); }), r.observe(t, { childList: !0 }); } function e() { r && r.disconnect(), u = !0; } return { init: s, destroy: e }; } function Kn(t, n, o, r) { const u = {}; let s = null, e = null, a, i = !1; function c() { a = new IntersectionObserver((l) => { i || (l.forEach((m) => { const h = n.indexOf(m.target); u[h] = m; }), s = null, e = null, o.emit("slidesInView")); }, { root: t.parentElement, threshold: r }), n.forEach((l) => a.observe(l)); } function y() { a && a.disconnect(), i = !0; } function d(l) { return pt(u).reduce((m, h) => { const f = parseInt(h), { isIntersecting: g } = u[f]; return (l && g || !l && !g) && m.push(f), m; }, []); } function p(l = !0) { if (l && s) return s; if (!l && e) return e; const m = d(l); return l && (s = m), l || (e = m), m; } return { init: c, destroy: y, get: p }; } function Un(t, n, o, r, u, s) { const { measureSize: e, startEdge: a, endEdge: i } = t, c = o[0] && u, y = l(), d = m(), p = o.map(e), b = h(); function l() { if (!c) return 0; const g = o[0]; return D(n[a] - g[a]); } function m() { if (!c) return 0; const g = s.getComputedStyle(j(r)); return parseFloat(g.getPropertyValue(`margin-${i}`)); } function h() { return o.map((g, x, L) => { const N = !x, w = Ot(L, x); return N ? p[x] + y : w ? p[x] + d : L[x + 1][a] - g[a]; }).map(D); } return { slideSizes: p, slideSizesWithGaps: b, startGap: y, endGap: d }; } function _n(t, n, o, r, u, s, e, a, i) { const { startEdge: c, endEdge: y, direction: d } = t, p = Dt(o); function b(f, g) { return dt(f).filter((x) => x % g === 0).map((x) => f.slice(x, x + g)); } function l(f) { return f.length ? dt(f).reduce((g, x, L) => { const N = j(g) || 0, w = N === 0, E = x === ht(f), v = u[c] - s[N][c], C = u[c] - s[x][y], P = !r && w ? d(e) : 0, I = !r && E ? d(a) : 0, z = D(C - I - (v + P)); return L && z > n + i && g.push(x), E && g.push(f.length), g; }, []).map((g, x, L) => { const N = Math.max(L[x - 1] || 0); return f.slice(N, g); }) : []; } function m(f) { return p ? b(f, o) : l(f); } return { groupSlides: m }; } function Qn(t, n, o, r, u, s, e) { const { align: a, axis: i, direction: c, startIndex: y, loop: d, duration: p, dragFree: b, dragThreshold: l, inViewThreshold: m, slidesToScroll: h, skipSnaps: f, containScroll: g, watchResize: x, watchSlides: L, watchDrag: N, watchFocus: w } = s, E = 2, v = An(), C = v.measure(n), P = o.map(v.measure), I = In(i, c), z = I.measureSize(C), R = Dn(z), H = wn(a, z), G = !d && !!g, W = d || !!g, { slideSizes: Y, slideSizesWithGaps: K, startGap: U, endGap: it } = Un(I, C, P, o, W, u), q = _n(I, z, h, d, C, P, U, it, E), { snaps: ot, snapsAligned: rt } = Vn(I, H, C, P, q), _ = -j(ot) + j(K), { snapsContained: ct, scrollContainLimit: ut } = kn(z, _, rt, g, E), B = G ? ct : rt, { limit: M } = Fn(_, B, d), Q = tn(ht(B), y, d), V = Q.clone(), A = dt(o), S = ({ dragHandler: st, scrollBody: wt, scrollBounds: Ct, options: { loop: yt } }) => { yt || Ct.constrain(st.pointerDown()), wt.seek(); }, T = ({ scrollBody: st, translate: wt, location: Ct, offsetLocation: yt, previousLocation: sn, scrollLooper: cn, slideLooper: un, dragHandler: an, animation: ln, eventHandler: Bt, scrollBounds: fn, options: { loop: Vt } }, jt) => { const Rt = st.settled(), dn = !fn.shouldConstrain(), Ht = Vt ? Rt : Rt && dn, Gt = Ht && !an.pointerDown(); Gt && ln.stop(); const pn = Ct.get() * jt + sn.get() * (1 - jt); yt.set(pn), Vt && (cn.loop(st.direction()), un.loop()), wt.to(yt.get()), Gt && Bt.emit("settle"), Ht || Bt.emit("scroll"); }, O = Cn(r, u, () => S(Lt), (st) => T(Lt, st)), k = 0.68, $ = B[Q.get()], J = lt($), tt = lt($), Z = lt($), nt = lt($), at = On(J, Z, tt, nt, p, k), Et = Rn(d, B, _, M, nt), vt = Hn(O, Q, V, at, Et, nt, e), kt = Bn(M), Ft = mt(), on = Kn(n, o, e, m), { slideRegistry: zt } = jn(G, g, B, ut, q, A), rn = Gn(t, o, zt, vt, at, Ft, e, w), Lt = { ownerDocument: r, ownerWindow: u, eventHandler: e, containerRect: C, slideRects: P, animation: O, axis: I, dragHandler: Tn(I, t, r, u, nt, Nn(I, u), J, O, vt, at, Et, Q, e, R, b, l, f, k, N), eventStore: Ft, percentOfView: R, index: Q, indexPrevious: V, limit: M, location: J, offsetLocation: Z, previousLocation: tt, options: s, resizeHandler: Pn(n, e, u, o, I, x, v), scrollBody: at, scrollBounds: Mn(M, Z, nt, at, R), scrollLooper: zn(_, M, Z, [J, Z, tt, nt]), scrollProgress: kt, scrollSnapList: B.map(kt.get), scrollSnaps: B, scrollTarget: Et, scrollTo: vt, slideLooper: qn(I, z, _, Y, K, ot, B, Z, o), slideFocus: rn, slidesHandler: $n(n, e, L), slidesInView: on, slideIndexes: A, slideRegistry: zt, slidesToScroll: q, target: nt, translate: nn(I, n) }; return Lt; } function Jn() { let t = {}, n; function o(c) { n = c; } function r(c) { return t[c] || []; } function u(c) { return r(c).forEach((y) => y(n, c)), i; } function s(c, y) { return t[c] = r(c).concat([y]), i; } function e(c, y) { return t[c] = r(c).filter((d) => d !== y), i; } function a() { t = {}; } const i = { init: o, emit: u, off: e, on: s, clear: a }; return i; } const Xn = { align: "center", axis: "x", container: null, slides: null, containScroll: "trimSnaps", direction: "ltr", slidesToScroll: 1, inViewThreshold: 0, breakpoints: {}, dragFree: !1, dragThreshold: 10, loop: !1, skipSnaps: !1, duration: 25, startIndex: 0, active: !0, watchDrag: !0, watchResize: !0, watchSlides: !0, watchFocus: !0 }; function Yn(t) { function n(s, e) { return Wt(s, e || {}); } function o(s) { const e = s.breakpoints || {}, a = pt(e).filter((i) => t.matchMedia(i).matches).map((i) => e[i]).reduce((i, c) => n(i, c), {}); return n(s, a); } function r(s) { return s.map((e) => pt(e.breakpoints || {})).reduce((e, a) => e.concat(a), []).map(t.matchMedia); } return { mergeOptions: n, optionsAtMedia: o, optionsMediaQueries: r }; } function Zn(t) { let n = []; function o(s, e) { return n = e.filter(({ options: a }) => t.optionsAtMedia(a).active !== !1), n.forEach((a) => a.init(s, t)), e.reduce((a, i) => Object.assign(a, { [i.name]: i }), {}); } function r() { n = n.filter((s) => s.destroy()); } return { init: o, destroy: r }; } function St(t, n, o) { const r = t.ownerDocument, u = r.defaultView, s = Yn(u), e = Zn(s), a = mt(), i = Jn(), { mergeOptions: c, optionsAtMedia: y, optionsMediaQueries: d } = s, { on: p, off: b, emit: l } = i, m = I; let h = !1, f, g = c(Xn, St.globalOptions), x = c(g), L = [], N, w, E; function v() { const { container: A, slides: S } = x; w = (Tt(A) ? t.querySelector(A) : A) || t.children[0]; const O = Tt(S) ? w.querySelectorAll(S) : S; E = [].slice.call(O || w.children); } function C(A) { const S = Qn(t, w, E, r, u, A, i); if (A.loop && !S.slideLooper.canLoop()) { const T = Object.assign({}, A, { loop: !1 }); return C(T); } return S; } function P(A, S) { h || (g = c(g, A), x = y(g), L = S || L, v(), f = C(x), d([g, ...L.map(({ options: T }) => T)]).forEach((T) => a.add(T, "change", I)), x.active && (f.translate.to(f.location.get()), f.animation.init(), f.slidesInView.init(), f.slideFocus.init(V), f.eventHandler.init(V), f.resizeHandler.init(V), f.slidesHandler.init(V), f.options.loop && f.slideLooper.loop(), w.offsetParent && E.length && f.dragHandler.init(V), N = e.init(V, L))); } function I(A, S) { const T = q(); z(), P(c({ startIndex: T }, A), S), i.emit("reInit"); } function z() { f.dragHandler.destroy(), f.eventStore.clear(), f.translate.clear(), f.slideLooper.clear(), f.resizeHandler.destroy(), f.slidesHandler.destroy(), f.slidesInView.destroy(), f.animation.destroy(), e.destroy(), a.clear(); } function R() { h || (h = !0, a.clear(), z(), i.emit("destroy"), i.clear()); } function H(A, S, T) { !x.active || h || (f.scrollBody.useBaseFriction().useDuration(S === !0 ? 0 : x.duration), f.scrollTo.index(A, T || 0)); } function G(A) { const S = f.index.add(1).get(); H(S, A, -1); } function W(A) { const S = f.index.add(-1).get(); H(S, A, 1); } function Y() { return f.index.add(1).get() !== q(); } function K() { return f.index.add(-1).get() !== q(); } function U() { return f.scrollSnapList; } function it() { return f.scrollProgress.get(f.offsetLocation.get()); } function q() { return f.index.get(); } function ot() { return f.indexPrevious.get(); } function rt() { return f.slidesInView.get(); } function _() { return f.slidesInView.get(!1); } function ct() { return N; } function ut() { return f; } function B() { return t; } function M() { return w; } function Q() { return E; } const V = { canScrollNext: Y, canScrollPrev: K, containerNode: M, internalEngine: ut, destroy: R, off: b, on: p, emit: l, plugins: ct, previousScrollSnap: ot, reInit: m, rootNode: B, scrollNext: G, scrollPrev: W, scrollProgress: it, scrollSnapList: U, scrollTo: H, selectedScrollSnap: q, slideNodes: Q, slidesInView: rt, slidesNotInView: _ }; return P(n, o), setTimeout(() => i.emit("init"), 0), V; } St.globalOptions = void 0; function Mt(t = {}, n = []) { const o = qt(t), r = qt(n), [u, s] = $t(), [e, a] = $t(), i = mn(() => { u && u.reInit(o.current, r.current); }, [u]); return It(() => { At(o.current, t) || (o.current = t, i()); }, [t, i]), It(() => { En(r.current, n) || (r.current = n, i()); }, [n, i]), It(() => { if (xn() && e) { St.globalOptions = Mt.globalOptions; const c = St(e, o.current, r.current); return s(c), () => c.destroy(); } else s(void 0); }, [e, s]), [a, u]; } Mt.globalOptions = void 0; const en = F.createContext(null); function xt() { const t = F.useContext(en); if (!t) throw new Error("useCarousel must be used within a <Carousel />"); return t; } const Wn = F.forwardRef( ({ orientation: t = "horizontal", opts: n, setApi: o, plugins: r, className: u, children: s, ...e }, a) => { const [i, c] = Mt( { ...n, axis: t === "horizontal" ? "x" : "y" }, r ), [y, d] = F.useState(!1), [p, b] = F.useState(!1), l = F.useCallback((g) => { g && (d(g.canScrollPrev()), b(g.canScrollNext())); }, []), m = F.useCallback(() => { c == null || c.scrollPrev(); }, [c]), h = F.useCallback(() => { c == null || c.scrollNext(); }, [c]), f = F.useCallback( (g) => { g.key === "ArrowLeft" ? (g.preventDefault(), m()) : g.key === "ArrowRight" && (g.preventDefault(), h()); }, [m, h] ); return F.useEffect(() => { !c || !o || o(c); }, [c, o]), F.useEffect(() => { if (c) return l(c), c.on("reInit", l), c.on("select", l), () => { c == null || c.off("select", l); }; }, [c, l]), /* @__PURE__ */ X( en.Provider, { value: { carouselRef: i, api: c, opts: n, orientation: t || ((n == null ? void 0 : n.axis) === "y" ? "vertical" : "horizontal"), scrollPrev: m, scrollNext: h, canScrollPrev: y, canScrollNext: p }, children: /* @__PURE__ */ X( "div", { ref: a, onKeyDownCapture: f, className: gt("relative", u), role: "region", "aria-roledescription": "carousel", ...e, children: s } ) } ); } ); Wn.displayName = "Carousel"; const te = F.forwardRef(({ className: t, ...n }, o) => { const { carouselRef: r, orientation: u } = xt(); return /* @__PURE__ */ X("div", { ref: r, className: "overflow-hidden", children: /* @__PURE__ */ X( "div", { ref: o, className: gt( "flex", u === "horizontal" ? "-ml-4" : "-mt-4 flex-col", t ), ...n } ) }); }); te.displayName = "CarouselContent"; const ne = F.forwardRef(({ className: t, ...n }, o) => { const { orientation: r } = xt(); return /* @__PURE__ */ X( "div", { ref: o, role: "group", "aria-roledescription": "slide", className: gt( "min-w-0 shrink-0 grow-0 basis-full", r === "horizontal" ? "pl-4" : "pt-4", t ), ...n } ); }); ne.displayName = "CarouselItem"; const ee = F.forwardRef( ({ className: t, variant: n, size: o = "icon", ...r }, u) => { const { t: s } = Xt(), { orientation: e, scrollPrev: a, canScrollPrev: i } = xt(); return /* @__PURE__ */ Jt( Yt, { ref: u, variant: n, size: o, className: gt( "absolute h-8 w-8 rounded-full", e === "horizontal" ? "top-1/2 -left-12 -translate-y-1/2" : "-top-12 left-1/2 -translate-x-1/2 rotate-90", t ), disabled: !i, onClick: a, ...r, children: [ /* @__PURE__ */ X(hn, { className: "h-4 w-4" }), /* @__PURE__ */ X("span", { className: "sr-only", children: s("Previous slide") }) ] } ); } ); ee.displayName = "CarouselPrevious"; const oe = F.forwardRef( ({ className: t, variant: n, size: o = "icon", ...r }, u) => { const { t: s } = Xt(), { orientation: e, scrollNext: a, canScrollNext: i } = xt(); return /* @__PURE__ */ Jt( Yt, { ref: u, variant: n, size: o, className: gt( "absolute h-8 w-8 rounded-full", e === "horizontal" ? "top-1/2 -right-12 -translate-y-1/2" : "-bottom-12 left-1/2 -translate-x-1/2 rotate-90", t ), disabled: !i, onClick: a, ...r, children: [ /* @__PURE__ */ X(Sn, { className: "h-4 w-4" }), /* @__PURE__ */ X("span", { className: "sr-only", children: s("Next slide") }) ] } ); } ); oe.displayName = "CarouselNext"; export { Wn as Carousel, te as CarouselContent, ne as CarouselItem, oe as CarouselNext, ee as CarouselPrevious }; //# sourceMappingURL=index.es.js.map