@waveform-playlist/browser 5.1.0 → 5.2.0-next.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,8 +1,8 @@
1
1
  import * as _r from "tone";
2
- import { Volume as $n, getDestination as Mn, start as Bn, now as St, getTransport as ct, getContext as ke, Context as Fr, setContext as Zr, Panner as Vr, Gain as sn, Player as ln, Analyser as Dn, Meter as Pr, connect as zr, StereoWidener as Hr, Gate as Xr, Limiter as Gr, Compressor as Nr, Chebyshev as Lr, BitCrusher as Yr, Distortion as Or, EQ3 as Kr, AutoWah as Ur, AutoFilter as jr, AutoPanner as Jr, Vibrato as Qr, Tremolo as qr, Phaser as ea, Chorus as ta, PingPongDelay as na, FeedbackDelay as ra, JCReverb as aa, Freeverb as oa, Reverb as sa } from "tone";
3
- import { jsx as I, jsxs as te, Fragment as rt } from "react/jsx-runtime";
2
+ import { Volume as $n, getDestination as Mn, start as Bn, now as St, getTransport as ct, getContext as Ae, Context as Fr, setContext as Zr, Panner as Vr, Gain as sn, Player as ln, Analyser as Dn, Meter as Pr, connect as zr, StereoWidener as Hr, Gate as Xr, Limiter as Gr, Compressor as Nr, Chebyshev as Lr, BitCrusher as Yr, Distortion as Or, EQ3 as Kr, AutoWah as Ur, AutoFilter as jr, AutoPanner as Jr, Vibrato as Qr, Tremolo as qr, Phaser as ea, Chorus as ta, PingPongDelay as na, FeedbackDelay as ra, JCReverb as aa, Freeverb as oa, Reverb as sa } from "tone";
3
+ import { jsx as I, jsxs as ne, Fragment as rt } from "react/jsx-runtime";
4
4
  import * as Y from "react";
5
- import _e, { createContext as Be, useContext as Te, useState as E, useEffect as j, Fragment as ia, useRef as R, useCallback as D, useLayoutEffect as la, useMemo as nt } from "react";
5
+ import Fe, { createContext as Me, useContext as Te, useState as R, useEffect as U, Fragment as ia, useRef as T, useCallback as D, useLayoutEffect as la, useMemo as nt } from "react";
6
6
  import S, { withTheme as Tn, ThemeContext as ca, useTheme as ua, ThemeProvider as Rn } from "styled-components";
7
7
  import { useDraggable as bt, useSensor as zt, MouseSensor as da, TouchSensor as ma, PointerSensor as fa, useSensors as ha, DndContext as pa } from "@dnd-kit/core";
8
8
  import { restrictToHorizontalAxis as ga } from "@dnd-kit/modifiers";
@@ -364,10 +364,10 @@ var ya = class {
364
364
  }), this.tracks.clear(), this.effectsCleanup && this.effectsCleanup(), this.masterVolume.dispose();
365
365
  }
366
366
  get context() {
367
- return ke();
367
+ return Ae();
368
368
  }
369
369
  get sampleRate() {
370
- return ke().sampleRate;
370
+ return Ae().sampleRate;
371
371
  }
372
372
  setOnPlaybackComplete(e) {
373
373
  this.onPlaybackCompleteCallback = e;
@@ -469,7 +469,7 @@ const Nt = /* @__PURE__ */ Object.freeze({
469
469
  "thin",
470
470
  /* @__PURE__ */ Y.createElement(Y.Fragment, null, /* @__PURE__ */ Y.createElement("path", { d: "M153.76,28.41a4,4,0,0,0-4.22.43L78.63,84H32A12,12,0,0,0,20,96v64a12,12,0,0,0,12,12H78.63l70.91,55.16A4.07,4.07,0,0,0,152,228a3.92,3.92,0,0,0,1.76-.41A4,4,0,0,0,156,224V32A4,4,0,0,0,153.76,28.41ZM28,160V96a4,4,0,0,1,4-4H76v72H32A4,4,0,0,1,28,160Zm120,55.82L84,166V90l64-49.78ZM204,128a36,36,0,0,1-9,23.82,4,4,0,1,1-6-5.3,28,28,0,0,0,0-37,4,4,0,0,1,6-5.28A36,36,0,0,1,204,128Z" }))
471
471
  ]
472
- ]), ka = Be({
472
+ ]), ka = Me({
473
473
  color: "currentColor",
474
474
  size: "1em",
475
475
  weight: "regular",
@@ -586,7 +586,7 @@ var Dt = S.div`
586
586
  font-family: ${(e) => e.theme.fontFamily};
587
587
  font-size: ${(e) => e.theme.fontSize};
588
588
  color: ${(e) => e.theme.textColor};
589
- `, Ve = S.button`
589
+ `, Pe = S.button`
590
590
  padding: 0.5rem 1rem;
591
591
  background: ${(e) => e.theme.buttonBackground || "#007bff"};
592
592
  color: ${(e) => e.theme.buttonText || "white"};
@@ -785,7 +785,7 @@ var Vn = S.input.attrs({ type: "range" })`
785
785
  onChange: t,
786
786
  disabled: n = !1,
787
787
  className: r
788
- }) => /* @__PURE__ */ te(Dt, { className: r, children: [
788
+ }) => /* @__PURE__ */ ne(Dt, { className: r, children: [
789
789
  /* @__PURE__ */ I(
790
790
  Tt,
791
791
  {
@@ -926,42 +926,42 @@ var Da = S.canvas.attrs((e) => ({
926
926
  barGap: g = 0,
927
927
  transparentBackground: h = !1,
928
928
  drawMode: d = "inverted"
929
- } = e, b = R([]), y = D(
930
- (w) => {
931
- if (w !== null) {
932
- const C = parseInt(w.dataset.index, 10);
933
- b.current[C] = w;
929
+ } = e, b = T([]), y = D(
930
+ (C) => {
931
+ if (C !== null) {
932
+ const v = parseInt(C.dataset.index, 10);
933
+ b.current[v] = C;
934
934
  }
935
935
  },
936
936
  []
937
937
  );
938
938
  la(() => {
939
- const w = b.current, C = u + g;
940
- let A = 0;
941
- for (let $ = 0; $ < w.length; $++) {
942
- const k = w[$], B = k.getContext("2d"), M = Math.floor(i / 2), _ = 2 ** (n - 1);
943
- if (B) {
944
- B.resetTransform(), B.clearRect(0, 0, k.width, k.height), B.imageSmoothingEnabled = !1, B.scale(o, o);
945
- const T = k.width / o;
946
- let H;
947
- d === "normal" ? H = c : H = l, B.fillStyle = Ba(
948
- B,
949
- H,
950
- T,
939
+ const C = b.current, v = u + g;
940
+ let k = 0;
941
+ for (let B = 0; B < C.length; B++) {
942
+ const $ = C[B], A = $.getContext("2d"), M = Math.floor(i / 2), _ = 2 ** (n - 1);
943
+ if (A) {
944
+ A.resetTransform(), A.clearRect(0, 0, $.width, $.height), A.imageSmoothingEnabled = !1, A.scale(o, o);
945
+ const E = $.width / o;
946
+ let V;
947
+ d === "normal" ? V = c : V = l, A.fillStyle = Ba(
948
+ A,
949
+ V,
950
+ E,
951
951
  i
952
952
  );
953
- const P = A, F = A + T, O = Math.floor((P - u + C) / C) * C;
954
- for (let N = Math.max(0, O); N < F; N += C) {
955
- const Z = N - P;
953
+ const z = k, P = k + E, K = Math.floor((z - u + v) / v) * v;
954
+ for (let X = Math.max(0, K); X < P; X += v) {
955
+ const Z = X - z;
956
956
  if (Z + u <= 0) continue;
957
- const J = N;
958
- if (J * 2 + 1 < t.length) {
959
- const se = t[J * 2] / _, ae = t[J * 2 + 1] / _, ee = Math.abs(se * M), oe = Math.abs(ae * M);
960
- d === "normal" ? B.fillRect(Z, M - oe, u, oe + ee) : (B.fillRect(Z, 0, u, M - oe), B.fillRect(Z, M + ee, u, M - ee));
957
+ const Q = X;
958
+ if (Q * 2 + 1 < t.length) {
959
+ const le = t[Q * 2] / _, te = t[Q * 2 + 1] / _, re = Math.abs(le * M), ae = Math.abs(te * M);
960
+ d === "normal" ? A.fillRect(Z, M - ae, u, ae + re) : (A.fillRect(Z, 0, u, M - ae), A.fillRect(Z, M + re, u, M - re));
961
961
  }
962
962
  }
963
963
  }
964
- A += k.width / o;
964
+ k += $.width / o;
965
965
  }
966
966
  }, [
967
967
  t,
@@ -978,11 +978,11 @@ var Da = S.canvas.attrs((e) => ({
978
978
  let m = r, p = 0;
979
979
  const x = [];
980
980
  for (; m > 0; ) {
981
- const w = Math.min(m, Ma), C = /* @__PURE__ */ I(
981
+ const C = Math.min(m, Ma), v = /* @__PURE__ */ I(
982
982
  Da,
983
983
  {
984
- $cssWidth: w,
985
- width: w * o,
984
+ $cssWidth: C,
985
+ width: C * o,
986
986
  height: i * o,
987
987
  $waveHeight: i,
988
988
  "data-index": p,
@@ -990,7 +990,7 @@ var Da = S.canvas.attrs((e) => ({
990
990
  },
991
991
  `${r}-${p}`
992
992
  );
993
- x.push(C), m -= w, p += 1;
993
+ x.push(v), m -= C, p += 1;
994
994
  }
995
995
  const f = h ? "transparent" : at(c);
996
996
  return /* @__PURE__ */ I(
@@ -1113,7 +1113,7 @@ var Da = S.canvas.attrs((e) => ({
1113
1113
  dragHandleProps: a,
1114
1114
  touchOptimized: s = !1
1115
1115
  }) => {
1116
- const [o, i] = _e.useState(!1);
1116
+ const [o, i] = Fe.useState(!1);
1117
1117
  if (!a)
1118
1118
  return null;
1119
1119
  const { attributes: l, listeners: c, setActivatorNodeRef: u, isDragging: g } = a;
@@ -1236,43 +1236,43 @@ var fn = ({
1236
1236
  fadeOut: m,
1237
1237
  sampleRate: p = 44100,
1238
1238
  showFades: x = !1,
1239
- touchOptimized: v = !1
1239
+ touchOptimized: w = !1
1240
1240
  }) => {
1241
- const f = Math.floor(o / l), C = Math.floor((o + i) / l) - f, A = c && !u && !g, $ = `clip-${r}-${a}`, { attributes: k, listeners: B, setNodeRef: M, setActivatorNodeRef: _, transform: T, isDragging: H } = bt({
1242
- id: $,
1241
+ const f = Math.floor(o / l), v = Math.floor((o + i) / l) - f, k = c && !u && !g, B = `clip-${r}-${a}`, { attributes: $, listeners: A, setNodeRef: M, setActivatorNodeRef: _, transform: E, isDragging: V } = bt({
1242
+ id: B,
1243
1243
  data: { clipId: n, trackIndex: r, clipIndex: a },
1244
- disabled: !A
1245
- }), P = `clip-boundary-left-${r}-${a}`, {
1246
- attributes: F,
1247
- listeners: O,
1248
- setActivatorNodeRef: N,
1244
+ disabled: !k
1245
+ }), z = `clip-boundary-left-${r}-${a}`, {
1246
+ attributes: P,
1247
+ listeners: K,
1248
+ setActivatorNodeRef: X,
1249
1249
  isDragging: Z
1250
1250
  } = bt({
1251
- id: P,
1251
+ id: z,
1252
1252
  data: { clipId: n, trackIndex: r, clipIndex: a, boundary: "left" },
1253
- disabled: !A
1254
- }), J = `clip-boundary-right-${r}-${a}`, {
1255
- attributes: se,
1256
- listeners: ae,
1257
- setActivatorNodeRef: ee,
1258
- isDragging: oe
1253
+ disabled: !k
1254
+ }), Q = `clip-boundary-right-${r}-${a}`, {
1255
+ attributes: le,
1256
+ listeners: te,
1257
+ setActivatorNodeRef: re,
1258
+ isDragging: ae
1259
1259
  } = bt({
1260
- id: J,
1260
+ id: Q,
1261
1261
  data: { clipId: n, trackIndex: r, clipIndex: a, boundary: "right" },
1262
- disabled: !A
1263
- }), ye = T ? {
1264
- transform: Nt.Translate.toString(T),
1265
- zIndex: H ? 100 : void 0
1262
+ disabled: !k
1263
+ }), ye = E ? {
1264
+ transform: Nt.Translate.toString(E),
1265
+ zIndex: V ? 100 : void 0
1266
1266
  // Below controls (z-index: 999) but above other clips
1267
1267
  } : void 0;
1268
- return /* @__PURE__ */ te(
1268
+ return /* @__PURE__ */ ne(
1269
1269
  Ha,
1270
1270
  {
1271
1271
  ref: M,
1272
1272
  style: ye,
1273
1273
  className: t,
1274
1274
  $left: f,
1275
- $width: C,
1275
+ $width: v,
1276
1276
  $isOverlay: g,
1277
1277
  "data-clip-container": "true",
1278
1278
  "data-track-id": b,
@@ -1287,10 +1287,10 @@ var fn = ({
1287
1287
  trackName: s,
1288
1288
  isSelected: h,
1289
1289
  disableDrag: u,
1290
- dragHandleProps: A ? { attributes: k, listeners: B, setActivatorNodeRef: _ } : void 0
1290
+ dragHandleProps: k ? { attributes: $, listeners: A, setActivatorNodeRef: _ } : void 0
1291
1291
  }
1292
1292
  ),
1293
- /* @__PURE__ */ te(Xa, { $isOverlay: g, children: [
1293
+ /* @__PURE__ */ ne(Xa, { $isOverlay: g, children: [
1294
1294
  e,
1295
1295
  x && y && y.duration > 0 && /* @__PURE__ */ I(
1296
1296
  fn,
@@ -1304,14 +1304,14 @@ var fn = ({
1304
1304
  x && m && m.duration > 0 && /* @__PURE__ */ I(
1305
1305
  fn,
1306
1306
  {
1307
- left: C - Math.floor(m.duration * p / l),
1307
+ left: v - Math.floor(m.duration * p / l),
1308
1308
  width: Math.floor(m.duration * p / l),
1309
1309
  type: "fadeOut",
1310
1310
  curveType: m.type
1311
1311
  }
1312
1312
  )
1313
1313
  ] }),
1314
- c && !u && !g && /* @__PURE__ */ te(rt, { children: [
1314
+ c && !u && !g && /* @__PURE__ */ ne(rt, { children: [
1315
1315
  /* @__PURE__ */ I(
1316
1316
  mn,
1317
1317
  {
@@ -1319,11 +1319,11 @@ var fn = ({
1319
1319
  trackIndex: r,
1320
1320
  clipIndex: a,
1321
1321
  edge: "left",
1322
- touchOptimized: v,
1322
+ touchOptimized: w,
1323
1323
  dragHandleProps: {
1324
- attributes: F,
1325
- listeners: O,
1326
- setActivatorNodeRef: N,
1324
+ attributes: P,
1325
+ listeners: K,
1326
+ setActivatorNodeRef: X,
1327
1327
  isDragging: Z
1328
1328
  }
1329
1329
  }
@@ -1335,12 +1335,12 @@ var fn = ({
1335
1335
  trackIndex: r,
1336
1336
  clipIndex: a,
1337
1337
  edge: "right",
1338
- touchOptimized: v,
1338
+ touchOptimized: w,
1339
1339
  dragHandleProps: {
1340
- attributes: se,
1341
- listeners: ae,
1342
- setActivatorNodeRef: ee,
1343
- isDragging: oe
1340
+ attributes: le,
1341
+ listeners: te,
1342
+ setActivatorNodeRef: re,
1343
+ isDragging: ae
1344
1344
  }
1345
1345
  }
1346
1346
  )
@@ -1366,7 +1366,7 @@ var fn = ({
1366
1366
  const a = (s) => {
1367
1367
  t(parseFloat(s.target.value) / 100);
1368
1368
  };
1369
- return /* @__PURE__ */ te(Ga, { className: r, children: [
1369
+ return /* @__PURE__ */ ne(Ga, { className: r, children: [
1370
1370
  /* @__PURE__ */ I(Na, { htmlFor: "master-gain", children: "Master Volume" }),
1371
1371
  /* @__PURE__ */ I(
1372
1372
  La,
@@ -1470,14 +1470,14 @@ var Oa = S.div`
1470
1470
  scrollContainerRef: h,
1471
1471
  isSelecting: d,
1472
1472
  "data-playlist-state": b
1473
- }) => /* @__PURE__ */ I(Oa, { "data-scroll-container": "true", "data-playlist-state": b, ref: h, children: /* @__PURE__ */ te(
1473
+ }) => /* @__PURE__ */ I(Oa, { "data-scroll-container": "true", "data-playlist-state": b, ref: h, children: /* @__PURE__ */ ne(
1474
1474
  Ka,
1475
1475
  {
1476
1476
  $backgroundColor: t,
1477
1477
  $width: o,
1478
1478
  children: [
1479
1479
  r && /* @__PURE__ */ I(Ua, { $width: a, $backgroundColor: n, children: r }),
1480
- /* @__PURE__ */ te(ja, { $width: s, $backgroundColor: t, children: [
1480
+ /* @__PURE__ */ ne(ja, { $width: s, $backgroundColor: t, children: [
1481
1481
  e,
1482
1482
  (l || c) && /* @__PURE__ */ I(
1483
1483
  Ja,
@@ -1622,33 +1622,33 @@ var hn = S.div.attrs((e) => ({
1622
1622
  minPosition: i = 0,
1623
1623
  maxPosition: l = 1 / 0
1624
1624
  }) => {
1625
- const [c, u] = E(null), g = R(0), h = R(0), d = R(0), b = Math.max(0, t - e), y = D((p, x) => {
1625
+ const [c, u] = R(null), g = T(0), h = T(0), d = T(0), b = Math.max(0, t - e), y = D((p, x) => {
1626
1626
  p.preventDefault(), p.stopPropagation(), u(x), g.current = p.clientX, h.current = x === "start" ? e : t;
1627
- const v = (w) => {
1628
- const C = w.clientX - g.current, A = h.current + C;
1627
+ const w = (C) => {
1628
+ const v = C.clientX - g.current, k = h.current + v;
1629
1629
  if (x === "start") {
1630
- const $ = Math.max(i, Math.min(t - 10, A));
1631
- a?.($);
1630
+ const B = Math.max(i, Math.min(t - 10, k));
1631
+ a?.(B);
1632
1632
  } else {
1633
- const $ = Math.max(e + 10, Math.min(l, A));
1634
- s?.($);
1633
+ const B = Math.max(e + 10, Math.min(l, k));
1634
+ s?.(B);
1635
1635
  }
1636
1636
  }, f = () => {
1637
- u(null), document.removeEventListener("mousemove", v), document.removeEventListener("mouseup", f);
1637
+ u(null), document.removeEventListener("mousemove", w), document.removeEventListener("mouseup", f);
1638
1638
  };
1639
- document.addEventListener("mousemove", v), document.addEventListener("mouseup", f);
1639
+ document.addEventListener("mousemove", w), document.addEventListener("mouseup", f);
1640
1640
  }, [e, t, i, l, a, s]), m = D((p) => {
1641
1641
  p.preventDefault(), p.stopPropagation(), u("region"), g.current = p.clientX, h.current = e, d.current = t;
1642
- const x = t - e, v = (w) => {
1643
- const C = w.clientX - g.current;
1644
- let A = h.current + C, $ = d.current + C;
1645
- A < i && (A = i, $ = i + x), $ > l && ($ = l, A = l - x), o?.(A, $);
1642
+ const x = t - e, w = (C) => {
1643
+ const v = C.clientX - g.current;
1644
+ let k = h.current + v, B = d.current + v;
1645
+ k < i && (k = i, B = i + x), B > l && (B = l, k = l - x), o?.(k, B);
1646
1646
  }, f = () => {
1647
- u(null), document.removeEventListener("mousemove", v), document.removeEventListener("mouseup", f);
1647
+ u(null), document.removeEventListener("mousemove", w), document.removeEventListener("mouseup", f);
1648
1648
  };
1649
- document.addEventListener("mousemove", v), document.addEventListener("mouseup", f);
1649
+ document.addEventListener("mousemove", w), document.addEventListener("mouseup", f);
1650
1650
  }, [e, t, i, l, o]);
1651
- return b <= 0 ? null : /* @__PURE__ */ te(rt, { children: [
1651
+ return b <= 0 ? null : /* @__PURE__ */ ne(rt, { children: [
1652
1652
  /* @__PURE__ */ I(
1653
1653
  qa,
1654
1654
  {
@@ -1704,7 +1704,7 @@ var hn = S.div.attrs((e) => ({
1704
1704
  maxPosition: o = 1 / 0,
1705
1705
  controlsOffset: i = 0
1706
1706
  }) => {
1707
- const [l, c] = E(!1), u = R(0), g = R(null), h = t > e, d = D((b) => {
1707
+ const [l, c] = R(!1), u = T(0), g = T(null), h = t > e, d = D((b) => {
1708
1708
  const y = b.target;
1709
1709
  if (y.closest("[data-loop-marker-handle]") || y.closest("[data-loop-region-timescale]"))
1710
1710
  return;
@@ -1713,13 +1713,13 @@ var hn = S.div.attrs((e) => ({
1713
1713
  if (!m) return;
1714
1714
  const p = b.clientX - m.left, x = Math.max(s, Math.min(o, p));
1715
1715
  u.current = x, a?.(x, x);
1716
- const v = (w) => {
1717
- const C = w.clientX - m.left, A = Math.max(s, Math.min(o, C)), $ = Math.min(u.current, A), k = Math.max(u.current, A);
1718
- a?.($, k);
1716
+ const w = (C) => {
1717
+ const v = C.clientX - m.left, k = Math.max(s, Math.min(o, v)), B = Math.min(u.current, k), $ = Math.max(u.current, k);
1718
+ a?.(B, $);
1719
1719
  }, f = () => {
1720
- c(!1), document.removeEventListener("mousemove", v), document.removeEventListener("mouseup", f);
1720
+ c(!1), document.removeEventListener("mousemove", w), document.removeEventListener("mouseup", f);
1721
1721
  };
1722
- document.addEventListener("mousemove", v), document.addEventListener("mouseup", f);
1722
+ document.addEventListener("mousemove", w), document.addEventListener("mouseup", f);
1723
1723
  }, [s, o, a]);
1724
1724
  return /* @__PURE__ */ I(
1725
1725
  to,
@@ -1795,11 +1795,11 @@ var pn = ({
1795
1795
  onChange: s,
1796
1796
  readOnly: o = !1
1797
1797
  }) => {
1798
- const [i, l] = E("");
1799
- return j(() => {
1798
+ const [i, l] = R("");
1799
+ return U(() => {
1800
1800
  const h = dt(n, r);
1801
1801
  l(h);
1802
- }, [n, r, e]), /* @__PURE__ */ te(rt, { children: [
1802
+ }, [n, r, e]), /* @__PURE__ */ ne(rt, { children: [
1803
1803
  /* @__PURE__ */ I(Sa, { as: "label", htmlFor: e, children: t }),
1804
1804
  /* @__PURE__ */ I(
1805
1805
  Fn,
@@ -1832,15 +1832,15 @@ var pn = ({
1832
1832
  onSelectionChange: n,
1833
1833
  className: r
1834
1834
  }) => {
1835
- const [a, s] = E("hh:mm:ss.uuu");
1836
- return j(() => {
1835
+ const [a, s] = R("hh:mm:ss.uuu");
1836
+ return U(() => {
1837
1837
  const l = document.querySelector(".time-format"), c = () => {
1838
1838
  l && s(l.value);
1839
1839
  };
1840
1840
  return l && (s(l.value), l.addEventListener("change", c)), () => {
1841
1841
  l?.removeEventListener("change", c);
1842
1842
  };
1843
- }, []), /* @__PURE__ */ te(rt, { children: [
1843
+ }, []), /* @__PURE__ */ ne(rt, { children: [
1844
1844
  /* @__PURE__ */ I(
1845
1845
  pn,
1846
1846
  {
@@ -1872,8 +1872,8 @@ var pn = ({
1872
1872
  function $t() {
1873
1873
  return window.devicePixelRatio;
1874
1874
  }
1875
- var Yn = Be($t()), On = ({ children: e }) => {
1876
- const [t, n] = E($t());
1875
+ var Yn = Me($t()), On = ({ children: e }) => {
1876
+ const [t, n] = R($t());
1877
1877
  return matchMedia(`(resolution: ${$t()}dppx)`).addEventListener(
1878
1878
  "change",
1879
1879
  () => {
@@ -1881,7 +1881,7 @@ var Yn = Be($t()), On = ({ children: e }) => {
1881
1881
  },
1882
1882
  { once: !0 }
1883
1883
  ), /* @__PURE__ */ I(Yn.Provider, { value: Math.ceil(t), children: e });
1884
- }, Kn = () => Te(Yn), Et = Be({
1884
+ }, Kn = () => Te(Yn), Et = Me({
1885
1885
  sampleRate: 48e3,
1886
1886
  samplesPerPixel: 1e3,
1887
1887
  zoomLevels: [1e3, 1500, 2e3, 2500],
@@ -1894,14 +1894,14 @@ var Yn = Be($t()), On = ({ children: e }) => {
1894
1894
  duration: 3e4,
1895
1895
  barWidth: 1,
1896
1896
  barGap: 0
1897
- }), vt = () => Te(Et), wt = () => Te(ca), Qt = Be(/* @__PURE__ */ I(ia, {})), ao = () => Te(Qt), oo = 0, so = !1, io = 0, lo = 0, co = {
1897
+ }), vt = () => Te(Et), wt = () => Te(ca), Qt = Me(/* @__PURE__ */ I(ia, {})), ao = () => Te(Qt), oo = 0, so = !1, io = 0, lo = 0, co = {
1898
1898
  progress: oo,
1899
1899
  isPlaying: so,
1900
1900
  selectionStart: io,
1901
1901
  selectionEnd: lo
1902
1902
  };
1903
- Be(co);
1904
- Be({
1903
+ Me(co);
1904
+ Me({
1905
1905
  setIsPlaying: () => {
1906
1906
  },
1907
1907
  setProgress: () => {
@@ -1973,20 +1973,20 @@ var fo = S.div.attrs((e) => ({
1973
1973
  bigStep: a,
1974
1974
  secondStep: s,
1975
1975
  renderTimestamp: o
1976
- } = e, i = /* @__PURE__ */ new Map(), l = [], c = R(null), {
1976
+ } = e, i = /* @__PURE__ */ new Map(), l = [], c = T(null), {
1977
1977
  sampleRate: u,
1978
1978
  samplesPerPixel: g,
1979
1979
  timeScaleHeight: h,
1980
1980
  controls: { show: d, width: b }
1981
1981
  } = Te(Et), y = Kn();
1982
- j(() => {
1982
+ U(() => {
1983
1983
  if (c.current !== null) {
1984
- const v = c.current, f = v.getContext("2d");
1984
+ const w = c.current, f = w.getContext("2d");
1985
1985
  if (f) {
1986
- f.resetTransform(), f.clearRect(0, 0, v.width, v.height), f.imageSmoothingEnabled = !1, f.fillStyle = t, f.scale(y, y);
1987
- for (const [w, C] of i.entries()) {
1988
- const A = h - C;
1989
- f.fillRect(w, A, 1, C);
1986
+ f.resetTransform(), f.clearRect(0, 0, w.width, w.height), f.imageSmoothingEnabled = !1, f.fillStyle = t, f.scale(y, y);
1987
+ for (const [C, v] of i.entries()) {
1988
+ const k = h - v;
1989
+ f.fillRect(C, k, 1, v);
1990
1990
  }
1991
1991
  }
1992
1992
  }
@@ -2002,15 +2002,15 @@ var fo = S.div.attrs((e) => ({
2002
2002
  ]);
2003
2003
  const m = uo(n / 1e3, g, u), p = u / g;
2004
2004
  let x = 0;
2005
- for (let v = 0; v < m; v += p * s / 1e3) {
2006
- const f = Math.floor(v);
2005
+ for (let w = 0; w < m; w += p * s / 1e3) {
2006
+ const f = Math.floor(w);
2007
2007
  if (x % r === 0) {
2008
- const w = x, C = mo(w), A = o ? /* @__PURE__ */ I(_e.Fragment, { children: o(w, f) }, `timestamp-${x}`) : /* @__PURE__ */ I(po, { $left: f, children: C }, C);
2009
- l.push(A), i.set(f, h);
2008
+ const C = x, v = mo(C), k = o ? /* @__PURE__ */ I(Fe.Fragment, { children: o(C, f) }, `timestamp-${x}`) : /* @__PURE__ */ I(po, { $left: f, children: v }, v);
2009
+ l.push(k), i.set(f, h);
2010
2010
  } else x % a === 0 ? i.set(f, Math.floor(h / 2)) : x % s === 0 && i.set(f, Math.floor(h / 5));
2011
2011
  x += s;
2012
2012
  }
2013
- return /* @__PURE__ */ te(
2013
+ return /* @__PURE__ */ ne(
2014
2014
  fo,
2015
2015
  {
2016
2016
  $cssWidth: m,
@@ -2109,7 +2109,7 @@ var fo = S.div.attrs((e) => ({
2109
2109
  waveHeight: u,
2110
2110
  controls: { show: g, width: h }
2111
2111
  } = vt(), d = ao();
2112
- return /* @__PURE__ */ te(
2112
+ return /* @__PURE__ */ ne(
2113
2113
  yo,
2114
2114
  {
2115
2115
  $numChannels: e,
@@ -2439,26 +2439,26 @@ function Zo(e) {
2439
2439
  return new Float32Array(M);
2440
2440
  }), i = r ? o.length : 1, l = 24, c = Fo(a, t), u = e.bits === 8 ? 1 : 2, g = l + c * 2 * u * i, h = new ArrayBuffer(g), d = new DataView(h), b = 0, y = l, m = new Array(i), p = new Array(i), x = 0; x < i; x++)
2441
2441
  m[x] = 1 / 0, p[x] = -1 / 0;
2442
- var v = e.bits === 8 ? Eo : _o, f = e.bits === 8 ? Ro : Wo;
2442
+ var w = e.bits === 8 ? Eo : _o, f = e.bits === 8 ? Ro : Wo;
2443
2443
  d.setInt32(0, 2, !0), d.setUint32(4, e.bits === 8, !0), d.setInt32(8, s, !0), d.setInt32(12, t, !0), d.setInt32(16, c, !0), d.setInt32(20, i, !0);
2444
- for (var w = 0; w < a; w++) {
2445
- var C = 0;
2444
+ for (var C = 0; C < a; C++) {
2445
+ var v = 0;
2446
2446
  if (i === 1) {
2447
- for (var A = 0; A < o.length; ++A)
2448
- C += o[A][w];
2449
- C = Math.floor(f * C * n / o.length), C < m[0] && (m[0] = C, m[0] < v && (m[0] = v)), C > p[0] && (p[0] = C, p[0] > f && (p[0] = f));
2447
+ for (var k = 0; k < o.length; ++k)
2448
+ v += o[k][C];
2449
+ v = Math.floor(f * v * n / o.length), v < m[0] && (m[0] = v, m[0] < w && (m[0] = w)), v > p[0] && (p[0] = v, p[0] > f && (p[0] = f));
2450
2450
  } else
2451
- for (var $ = 0; $ < i; ++$)
2452
- C = Math.floor(f * o[$][w] * n), C < m[$] && (m[$] = C, m[$] < v && (m[$] = v)), C > p[$] && (p[$] = C, p[$] > f && (p[$] = f));
2451
+ for (var B = 0; B < i; ++B)
2452
+ v = Math.floor(f * o[B][C] * n), v < m[B] && (m[B] = v, m[B] < w && (m[B] = w)), v > p[B] && (p[B] = v, p[B] > f && (p[B] = f));
2453
2453
  if (++b === t) {
2454
- for (var k = 0; k < i; k++)
2455
- e.bits === 8 ? (d.setInt8(y++, m[k]), d.setInt8(y++, p[k])) : (d.setInt16(y, m[k], !0), d.setInt16(y + 2, p[k], !0), y += 4), m[k] = 1 / 0, p[k] = -1 / 0;
2454
+ for (var $ = 0; $ < i; $++)
2455
+ e.bits === 8 ? (d.setInt8(y++, m[$]), d.setInt8(y++, p[$])) : (d.setInt16(y, m[$], !0), d.setInt16(y + 2, p[$], !0), y += 4), m[$] = 1 / 0, p[$] = -1 / 0;
2456
2456
  b = 0;
2457
2457
  }
2458
2458
  }
2459
2459
  if (b > 0)
2460
- for (var B = 0; B < i; B++)
2461
- e.bits === 8 ? (d.setInt8(y++, m[B]), d.setInt8(y++, p[B])) : (d.setInt16(y, m[B], !0), d.setInt16(y + 2, p[B], !0));
2460
+ for (var A = 0; A < i; A++)
2461
+ e.bits === 8 ? (d.setInt8(y++, m[A]), d.setInt8(y++, p[A])) : (d.setInt16(y, m[A], !0), d.setInt16(y + 2, p[A], !0));
2462
2462
  return h;
2463
2463
  }
2464
2464
  function Mt(e) {
@@ -2515,7 +2515,7 @@ function Go(e, t, n) {
2515
2515
  };
2516
2516
  }
2517
2517
  var No = /* @__PURE__ */ Go("Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwooZnVuY3Rpb24gKCkgewogICd1c2Ugc3RyaWN0JzsKCiAgLyoqCiAgICogQXVkaW9CdWZmZXItYmFzZWQgV2F2ZWZvcm1EYXRhIGdlbmVyYXRvcgogICAqCiAgICogQWRhcHRlZCBmcm9tIEJsb2NrRmlsZTo6Q2FsY1N1bW1hcnkgaW4gQXVkYWNpdHksIHdpdGggcGVybWlzc2lvbi4KICAgKiBTZWUgaHR0cHM6Ly9naXRodWIuY29tL2F1ZGFjaXR5L2F1ZGFjaXR5L2Jsb2IvCiAgICogICAxMTA4YzEzNzZjMDkxNjYxNjIzMzVmYWI0NzQzMDA4Y2JhNTdjNGVlL3NyYy9CbG9ja0ZpbGUuY3BwI0wxOTgKICAgKi8KCiAgdmFyIElOVDhfTUFYID0gMTI3OwogIHZhciBJTlQ4X01JTiA9IC0xMjg7CiAgdmFyIElOVDE2X01BWCA9IDMyNzY3OwogIHZhciBJTlQxNl9NSU4gPSAtMzI3Njg7CiAgZnVuY3Rpb24gY2FsY3VsYXRlV2F2ZWZvcm1EYXRhTGVuZ3RoKGF1ZGlvX3NhbXBsZV9jb3VudCwgc2NhbGUpIHsKICAgIHZhciBkYXRhX2xlbmd0aCA9IE1hdGguZmxvb3IoYXVkaW9fc2FtcGxlX2NvdW50IC8gc2NhbGUpOwogICAgdmFyIHNhbXBsZXNfcmVtYWluaW5nID0gYXVkaW9fc2FtcGxlX2NvdW50IC0gZGF0YV9sZW5ndGggKiBzY2FsZTsKICAgIGlmIChzYW1wbGVzX3JlbWFpbmluZyA+IDApIHsKICAgICAgZGF0YV9sZW5ndGgrKzsKICAgIH0KICAgIHJldHVybiBkYXRhX2xlbmd0aDsKICB9CiAgZnVuY3Rpb24gZ2VuZXJhdGVXYXZlZm9ybURhdGEob3B0aW9ucykgewogICAgdmFyIHNjYWxlID0gb3B0aW9ucy5zY2FsZTsKICAgIHZhciBhbXBsaXR1ZGVfc2NhbGUgPSBvcHRpb25zLmFtcGxpdHVkZV9zY2FsZTsKICAgIHZhciBzcGxpdF9jaGFubmVscyA9IG9wdGlvbnMuc3BsaXRfY2hhbm5lbHM7CiAgICB2YXIgbGVuZ3RoID0gb3B0aW9ucy5sZW5ndGg7CiAgICB2YXIgc2FtcGxlX3JhdGUgPSBvcHRpb25zLnNhbXBsZV9yYXRlOwogICAgdmFyIGNoYW5uZWxzID0gb3B0aW9ucy5jaGFubmVscy5tYXAoZnVuY3Rpb24gKGNoYW5uZWwpIHsKICAgICAgcmV0dXJuIG5ldyBGbG9hdDMyQXJyYXkoY2hhbm5lbCk7CiAgICB9KTsKICAgIHZhciBvdXRwdXRfY2hhbm5lbHMgPSBzcGxpdF9jaGFubmVscyA/IGNoYW5uZWxzLmxlbmd0aCA6IDE7CiAgICB2YXIgaGVhZGVyX3NpemUgPSAyNDsKICAgIHZhciBkYXRhX2xlbmd0aCA9IGNhbGN1bGF0ZVdhdmVmb3JtRGF0YUxlbmd0aChsZW5ndGgsIHNjYWxlKTsKICAgIHZhciBieXRlc19wZXJfc2FtcGxlID0gb3B0aW9ucy5iaXRzID09PSA4ID8gMSA6IDI7CiAgICB2YXIgdG90YWxfc2l6ZSA9IGhlYWRlcl9zaXplICsgZGF0YV9sZW5ndGggKiAyICogYnl0ZXNfcGVyX3NhbXBsZSAqIG91dHB1dF9jaGFubmVsczsKICAgIHZhciBidWZmZXIgPSBuZXcgQXJyYXlCdWZmZXIodG90YWxfc2l6ZSk7CiAgICB2YXIgZGF0YV92aWV3ID0gbmV3IERhdGFWaWV3KGJ1ZmZlcik7CiAgICB2YXIgc2NhbGVfY291bnRlciA9IDA7CiAgICB2YXIgb2Zmc2V0ID0gaGVhZGVyX3NpemU7CiAgICB2YXIgbWluX3ZhbHVlID0gbmV3IEFycmF5KG91dHB1dF9jaGFubmVscyk7CiAgICB2YXIgbWF4X3ZhbHVlID0gbmV3IEFycmF5KG91dHB1dF9jaGFubmVscyk7CiAgICBmb3IgKHZhciBjaGFubmVsID0gMDsgY2hhbm5lbCA8IG91dHB1dF9jaGFubmVsczsgY2hhbm5lbCsrKSB7CiAgICAgIG1pbl92YWx1ZVtjaGFubmVsXSA9IEluZmluaXR5OwogICAgICBtYXhfdmFsdWVbY2hhbm5lbF0gPSAtSW5maW5pdHk7CiAgICB9CiAgICB2YXIgcmFuZ2VfbWluID0gb3B0aW9ucy5iaXRzID09PSA4ID8gSU5UOF9NSU4gOiBJTlQxNl9NSU47CiAgICB2YXIgcmFuZ2VfbWF4ID0gb3B0aW9ucy5iaXRzID09PSA4ID8gSU5UOF9NQVggOiBJTlQxNl9NQVg7CiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoMCwgMiwgdHJ1ZSk7IC8vIFZlcnNpb24KICAgIGRhdGFfdmlldy5zZXRVaW50MzIoNCwgb3B0aW9ucy5iaXRzID09PSA4LCB0cnVlKTsgLy8gSXMgOCBiaXQ/CiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoOCwgc2FtcGxlX3JhdGUsIHRydWUpOyAvLyBTYW1wbGUgcmF0ZQogICAgZGF0YV92aWV3LnNldEludDMyKDEyLCBzY2FsZSwgdHJ1ZSk7IC8vIFNjYWxlCiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoMTYsIGRhdGFfbGVuZ3RoLCB0cnVlKTsgLy8gTGVuZ3RoCiAgICBkYXRhX3ZpZXcuc2V0SW50MzIoMjAsIG91dHB1dF9jaGFubmVscywgdHJ1ZSk7CiAgICBmb3IgKHZhciBpID0gMDsgaSA8IGxlbmd0aDsgaSsrKSB7CiAgICAgIHZhciBzYW1wbGUgPSAwOwogICAgICBpZiAob3V0cHV0X2NoYW5uZWxzID09PSAxKSB7CiAgICAgICAgZm9yICh2YXIgX2NoYW5uZWwgPSAwOyBfY2hhbm5lbCA8IGNoYW5uZWxzLmxlbmd0aDsgKytfY2hhbm5lbCkgewogICAgICAgICAgc2FtcGxlICs9IGNoYW5uZWxzW19jaGFubmVsXVtpXTsKICAgICAgICB9CiAgICAgICAgc2FtcGxlID0gTWF0aC5mbG9vcihyYW5nZV9tYXggKiBzYW1wbGUgKiBhbXBsaXR1ZGVfc2NhbGUgLyBjaGFubmVscy5sZW5ndGgpOwogICAgICAgIGlmIChzYW1wbGUgPCBtaW5fdmFsdWVbMF0pIHsKICAgICAgICAgIG1pbl92YWx1ZVswXSA9IHNhbXBsZTsKICAgICAgICAgIGlmIChtaW5fdmFsdWVbMF0gPCByYW5nZV9taW4pIHsKICAgICAgICAgICAgbWluX3ZhbHVlWzBdID0gcmFuZ2VfbWluOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAoc2FtcGxlID4gbWF4X3ZhbHVlWzBdKSB7CiAgICAgICAgICBtYXhfdmFsdWVbMF0gPSBzYW1wbGU7CiAgICAgICAgICBpZiAobWF4X3ZhbHVlWzBdID4gcmFuZ2VfbWF4KSB7CiAgICAgICAgICAgIG1heF92YWx1ZVswXSA9IHJhbmdlX21heDsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0gZWxzZSB7CiAgICAgICAgZm9yICh2YXIgX2NoYW5uZWwyID0gMDsgX2NoYW5uZWwyIDwgb3V0cHV0X2NoYW5uZWxzOyArK19jaGFubmVsMikgewogICAgICAgICAgc2FtcGxlID0gTWF0aC5mbG9vcihyYW5nZV9tYXggKiBjaGFubmVsc1tfY2hhbm5lbDJdW2ldICogYW1wbGl0dWRlX3NjYWxlKTsKICAgICAgICAgIGlmIChzYW1wbGUgPCBtaW5fdmFsdWVbX2NoYW5uZWwyXSkgewogICAgICAgICAgICBtaW5fdmFsdWVbX2NoYW5uZWwyXSA9IHNhbXBsZTsKICAgICAgICAgICAgaWYgKG1pbl92YWx1ZVtfY2hhbm5lbDJdIDwgcmFuZ2VfbWluKSB7CiAgICAgICAgICAgICAgbWluX3ZhbHVlW19jaGFubmVsMl0gPSByYW5nZV9taW47CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIGlmIChzYW1wbGUgPiBtYXhfdmFsdWVbX2NoYW5uZWwyXSkgewogICAgICAgICAgICBtYXhfdmFsdWVbX2NoYW5uZWwyXSA9IHNhbXBsZTsKICAgICAgICAgICAgaWYgKG1heF92YWx1ZVtfY2hhbm5lbDJdID4gcmFuZ2VfbWF4KSB7CiAgICAgICAgICAgICAgbWF4X3ZhbHVlW19jaGFubmVsMl0gPSByYW5nZV9tYXg7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0KICAgICAgaWYgKCsrc2NhbGVfY291bnRlciA9PT0gc2NhbGUpIHsKICAgICAgICBmb3IgKHZhciBfY2hhbm5lbDMgPSAwOyBfY2hhbm5lbDMgPCBvdXRwdXRfY2hhbm5lbHM7IF9jaGFubmVsMysrKSB7CiAgICAgICAgICBpZiAob3B0aW9ucy5iaXRzID09PSA4KSB7CiAgICAgICAgICAgIGRhdGFfdmlldy5zZXRJbnQ4KG9mZnNldCsrLCBtaW5fdmFsdWVbX2NoYW5uZWwzXSk7CiAgICAgICAgICAgIGRhdGFfdmlldy5zZXRJbnQ4KG9mZnNldCsrLCBtYXhfdmFsdWVbX2NoYW5uZWwzXSk7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBkYXRhX3ZpZXcuc2V0SW50MTYob2Zmc2V0LCBtaW5fdmFsdWVbX2NoYW5uZWwzXSwgdHJ1ZSk7CiAgICAgICAgICAgIGRhdGFfdmlldy5zZXRJbnQxNihvZmZzZXQgKyAyLCBtYXhfdmFsdWVbX2NoYW5uZWwzXSwgdHJ1ZSk7CiAgICAgICAgICAgIG9mZnNldCArPSA0OwogICAgICAgICAgfQogICAgICAgICAgbWluX3ZhbHVlW19jaGFubmVsM10gPSBJbmZpbml0eTsKICAgICAgICAgIG1heF92YWx1ZVtfY2hhbm5lbDNdID0gLUluZmluaXR5OwogICAgICAgIH0KICAgICAgICBzY2FsZV9jb3VudGVyID0gMDsKICAgICAgfQogICAgfQogICAgaWYgKHNjYWxlX2NvdW50ZXIgPiAwKSB7CiAgICAgIGZvciAodmFyIF9jaGFubmVsNCA9IDA7IF9jaGFubmVsNCA8IG91dHB1dF9jaGFubmVsczsgX2NoYW5uZWw0KyspIHsKICAgICAgICBpZiAob3B0aW9ucy5iaXRzID09PSA4KSB7CiAgICAgICAgICBkYXRhX3ZpZXcuc2V0SW50OChvZmZzZXQrKywgbWluX3ZhbHVlW19jaGFubmVsNF0pOwogICAgICAgICAgZGF0YV92aWV3LnNldEludDgob2Zmc2V0KyssIG1heF92YWx1ZVtfY2hhbm5lbDRdKTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgZGF0YV92aWV3LnNldEludDE2KG9mZnNldCwgbWluX3ZhbHVlW19jaGFubmVsNF0sIHRydWUpOwogICAgICAgICAgZGF0YV92aWV3LnNldEludDE2KG9mZnNldCArIDIsIG1heF92YWx1ZVtfY2hhbm5lbDRdLCB0cnVlKTsKICAgICAgICB9CiAgICAgIH0KICAgIH0KICAgIHJldHVybiBidWZmZXI7CiAgfQoKICBvbm1lc3NhZ2UgPSBmdW5jdGlvbiBvbm1lc3NhZ2UoZXZ0KSB7CiAgICB2YXIgYnVmZmVyID0gZ2VuZXJhdGVXYXZlZm9ybURhdGEoZXZ0LmRhdGEpOwoKICAgIC8vIFRyYW5zZmVyIGJ1ZmZlciB0byB0aGUgY2FsbGluZyB0aHJlYWQKICAgIHRoaXMucG9zdE1lc3NhZ2UoYnVmZmVyLCBbYnVmZmVyXSk7CiAgICB0aGlzLmNsb3NlKCk7CiAgfTsKCn0pKCk7Ci8vIyBzb3VyY2VNYXBwaW5nVVJMPXdhdmVmb3JtLWRhdGEtd29ya2VyLmpzLm1hcAoK");
2518
- function Ze(e) {
2518
+ function Ve(e) {
2519
2519
  if (Vo(e) && (e = zo(e)), Po(e)) {
2520
2520
  this._data = new DataView(e), this._offset = this._version() === 2 ? 24 : 20, this._channels = [];
2521
2521
  for (var t = 0; t < this.channels; t++)
@@ -2557,11 +2557,11 @@ function qn(e, t, n) {
2557
2557
  sample_rate: e.sampleRate,
2558
2558
  channels: r
2559
2559
  });
2560
- n(void 0, new Ze(a), e);
2560
+ n(void 0, new Ve(a), e);
2561
2561
  } else {
2562
2562
  var s = new No();
2563
2563
  s.onmessage = function(o) {
2564
- n(void 0, new Ze(o.data), e);
2564
+ n(void 0, new Ve(o.data), e);
2565
2565
  }, s.postMessage({
2566
2566
  scale: t.scale,
2567
2567
  bits: t.bits,
@@ -2583,10 +2583,10 @@ function Oo(e, t, n, r) {
2583
2583
  }, a);
2584
2584
  s && s.catch(a);
2585
2585
  }
2586
- Ze.create = function(t) {
2587
- return new Ze(t);
2586
+ Ve.create = function(t) {
2587
+ return new Ve(t);
2588
2588
  };
2589
- Ze.createFromAudio = function(e, t) {
2589
+ Ve.createFromAudio = function(e, t) {
2590
2590
  var n = Lo(e);
2591
2591
  if (e.audio_context && e.array_buffer)
2592
2592
  return Oo(e.audio_context, e.array_buffer, n, t);
@@ -2600,7 +2600,7 @@ Ze.createFromAudio = function(e, t) {
2600
2600
  function Wt(e) {
2601
2601
  this._inputData = e.waveformData, this._output_samples_per_pixel = e.scale, this._scale = this._inputData.scale, this._input_buffer_size = this._inputData.length;
2602
2602
  var t = this._input_buffer_size * this._inputData.scale, n = Math.ceil(t / this._output_samples_per_pixel), r = 24, a = this._inputData.bits === 8 ? 1 : 2, s = r + n * 2 * this._inputData.channels * a;
2603
- this._output_data = new ArrayBuffer(s), this.output_dataview = new DataView(this._output_data), this.output_dataview.setInt32(0, 2, !0), this.output_dataview.setUint32(4, this._inputData.bits === 8, !0), this.output_dataview.setInt32(8, this._inputData.sample_rate, !0), this.output_dataview.setInt32(12, this._output_samples_per_pixel, !0), this.output_dataview.setInt32(16, n, !0), this.output_dataview.setInt32(20, this._inputData.channels, !0), this._outputWaveformData = new Ze(this._output_data), this._input_index = 0, this._output_index = 0;
2603
+ this._output_data = new ArrayBuffer(s), this.output_dataview = new DataView(this._output_data), this.output_dataview.setInt32(0, 2, !0), this.output_dataview.setUint32(4, this._inputData.bits === 8, !0), this.output_dataview.setInt32(8, this._inputData.sample_rate, !0), this.output_dataview.setInt32(12, this._output_samples_per_pixel, !0), this.output_dataview.setInt32(16, n, !0), this.output_dataview.setInt32(20, this._inputData.channels, !0), this._outputWaveformData = new Ve(this._output_data), this._input_index = 0, this._output_index = 0;
2604
2604
  var o = this._inputData.channels;
2605
2605
  this._min = new Array(o), this._max = new Array(o);
2606
2606
  for (var i = 0; i < o; ++i)
@@ -2640,7 +2640,7 @@ Wt.prototype.next = function() {
2640
2640
  Wt.prototype.getOutputData = function() {
2641
2641
  return this._output_data;
2642
2642
  };
2643
- Ze.prototype = {
2643
+ Ve.prototype = {
2644
2644
  _getResampleOptions: function(t) {
2645
2645
  var n = {};
2646
2646
  if (n.scale = t.scale, n.width = t.width, !ut(n.width) && (typeof n.width != "number" || n.width <= 0))
@@ -2657,7 +2657,7 @@ Ze.prototype = {
2657
2657
  t = this._getResampleOptions(t), t.waveformData = this;
2658
2658
  for (var n = new Wt(t); !n.next(); )
2659
2659
  ;
2660
- return new Ze(n.getOutputData());
2660
+ return new Ve(n.getOutputData());
2661
2661
  },
2662
2662
  /**
2663
2663
  * Concatenates with one or more other waveforms, returning a new WaveformData object.
@@ -2669,7 +2669,7 @@ Ze.prototype = {
2669
2669
  throw new Error("WaveformData.concat(): Waveforms are incompatible");
2670
2670
  });
2671
2671
  var r = this._concatBuffers.apply(this, n);
2672
- return Ze.create(r);
2672
+ return Ve.create(r);
2673
2673
  },
2674
2674
  /**
2675
2675
  * Returns a new ArrayBuffer with the concatenated waveform.
@@ -2704,7 +2704,7 @@ Ze.prototype = {
2704
2704
  var g = this._at(n * this.channels * 2 + u);
2705
2705
  this.bits === 8 ? c.setInt8(s + u, g) : c.setInt16(s + u * 2, g, !0);
2706
2706
  }
2707
- return new Ze(l);
2707
+ return new Ve(l);
2708
2708
  },
2709
2709
  /**
2710
2710
  * Returns the data format version number.
@@ -2823,10 +2823,10 @@ async function er(e) {
2823
2823
  throw new Error(`Failed to fetch waveform data: ${t.statusText}`);
2824
2824
  if (e.endsWith(".dat")) {
2825
2825
  const r = await t.arrayBuffer();
2826
- return Ze.create(r);
2826
+ return Ve.create(r);
2827
2827
  } else {
2828
2828
  const r = await t.json();
2829
- return Ze.create(r);
2829
+ return Ve.create(r);
2830
2830
  }
2831
2831
  }
2832
2832
  function Ko(e, t = 0) {
@@ -3027,11 +3027,11 @@ var jo = S.div.attrs((e) => ({
3027
3027
  `, Cn = S.div`
3028
3028
  position: absolute;
3029
3029
  top: 0;
3030
- ${(e) => e.$position === "left" ? "left: -8px" : "right: -8px"};
3031
- width: 16px;
3030
+ ${(e) => e.$position === "left" ? "left: 0" : "right: 0"};
3031
+ width: 8px;
3032
3032
  height: 100%;
3033
3033
  cursor: ew-resize;
3034
- z-index: 120; /* Above ClickOverlay (z-index: 100) and AnnotationBoxesWrapper (z-index: 110) */
3034
+ z-index: 120;
3035
3035
  background: ${(e) => e.$isDragging ? e.theme?.annotationResizeHandleColor || "rgba(0, 0, 0, 0.2)" : "transparent"};
3036
3036
  border-radius: 4px;
3037
3037
  touch-action: none; /* Important for @dnd-kit on touch devices */
@@ -3083,7 +3083,7 @@ var jo = S.div.attrs((e) => ({
3083
3083
  attributes: m,
3084
3084
  listeners: p,
3085
3085
  setActivatorNodeRef: x,
3086
- isDragging: v
3086
+ isDragging: w
3087
3087
  } = bt({
3088
3088
  id: y,
3089
3089
  data: { annotationId: e, annotationIndex: t, edge: "end" },
@@ -3091,12 +3091,12 @@ var jo = S.div.attrs((e) => ({
3091
3091
  });
3092
3092
  if (c <= 0)
3093
3093
  return null;
3094
- const f = (C) => (A) => {
3095
- A.stopPropagation(), C?.(A);
3096
- }, w = (C) => {
3097
- C.stopPropagation();
3094
+ const f = (v) => (k) => {
3095
+ k.stopPropagation(), v?.(k);
3096
+ }, C = (v) => {
3097
+ v.stopPropagation();
3098
3098
  };
3099
- return /* @__PURE__ */ te(jo, { $left: n, $width: c, children: [
3099
+ return /* @__PURE__ */ ne(jo, { $left: n, $width: c, children: [
3100
3100
  /* @__PURE__ */ I(
3101
3101
  Jo,
3102
3102
  {
@@ -3112,7 +3112,7 @@ var jo = S.div.attrs((e) => ({
3112
3112
  ref: d,
3113
3113
  $position: "left",
3114
3114
  $isDragging: b,
3115
- onClick: w,
3115
+ onClick: C,
3116
3116
  ...h,
3117
3117
  onPointerDown: f(h?.onPointerDown),
3118
3118
  ...g
@@ -3123,8 +3123,8 @@ var jo = S.div.attrs((e) => ({
3123
3123
  {
3124
3124
  ref: x,
3125
3125
  $position: "right",
3126
- $isDragging: v,
3127
- onClick: w,
3126
+ $isDragging: w,
3127
+ onClick: C,
3128
3128
  ...p,
3129
3129
  onPointerDown: f(p?.onPointerDown),
3130
3130
  ...m
@@ -3163,7 +3163,7 @@ var jo = S.div.attrs((e) => ({
3163
3163
  const {
3164
3164
  controls: { show: s, width: o }
3165
3165
  } = vt();
3166
- return /* @__PURE__ */ te(
3166
+ return /* @__PURE__ */ ne(
3167
3167
  qo,
3168
3168
  {
3169
3169
  className: t,
@@ -3311,15 +3311,15 @@ var ns = S.div`
3311
3311
  onAnnotationUpdate: u,
3312
3312
  renderAnnotationItem: g
3313
3313
  }) => {
3314
- const h = R(null), d = R(null), b = R(void 0);
3315
- j(() => {
3316
- }), j(() => {
3314
+ const h = T(null), d = T(null), b = T(void 0);
3315
+ U(() => {
3316
+ }), U(() => {
3317
3317
  const f = d.current;
3318
3318
  if (!f) return;
3319
- const w = () => {
3319
+ const C = () => {
3320
3320
  };
3321
- return f.addEventListener("scroll", w), () => f.removeEventListener("scroll", w);
3322
- }, []), j(() => {
3321
+ return f.addEventListener("scroll", C), () => f.removeEventListener("scroll", C);
3322
+ }, []), U(() => {
3323
3323
  t && h.current && n && h.current.scrollIntoView({
3324
3324
  behavior: "smooth",
3325
3325
  block: r,
@@ -3329,78 +3329,78 @@ var ns = S.div`
3329
3329
  const y = (f) => {
3330
3330
  if (isNaN(f) || !isFinite(f))
3331
3331
  return "0:00.000";
3332
- const w = Math.floor(f / 60), C = (f % 60).toFixed(3);
3333
- return `${w}:${C.padStart(6, "0")}`;
3334
- }, m = (f, w) => {
3332
+ const C = Math.floor(f / 60), v = (f % 60).toFixed(3);
3333
+ return `${C}:${v.padStart(6, "0")}`;
3334
+ }, m = (f, C) => {
3335
3335
  if (!s || !u) return;
3336
- const C = [...e];
3337
- C[f] = {
3338
- ...C[f],
3339
- lines: w.split(`
3336
+ const v = [...e];
3337
+ v[f] = {
3338
+ ...v[f],
3339
+ lines: C.split(`
3340
3340
  `)
3341
- }, u(C);
3342
- }, p = (f, w) => {
3341
+ }, u(v);
3342
+ }, p = (f, C) => {
3343
3343
  if (!s || !u) return;
3344
- const C = w.trim();
3345
- if (!C) return;
3346
- const A = [...e];
3347
- A[f] = {
3348
- ...A[f],
3349
- id: C
3350
- }, u(A);
3351
- }, x = (f, w, C) => {
3344
+ const v = C.trim();
3345
+ if (!v) return;
3346
+ const k = [...e];
3347
+ k[f] = {
3348
+ ...k[f],
3349
+ id: v
3350
+ }, u(k);
3351
+ }, x = (f, C, v) => {
3352
3352
  if (!u) return;
3353
- const A = [...e];
3354
- f.action(A[C], C, A, i || {}), u(A);
3355
- }, v = (f) => f.replace(/\./g, " ");
3356
- return /* @__PURE__ */ I(ns, { ref: d, $height: l, children: e.map((f, w) => {
3357
- const C = f.id === t, A = () => c?.(f);
3353
+ const k = [...e];
3354
+ f.action(k[v], v, k, i || {}), u(k);
3355
+ }, w = (f) => f.replace(/\./g, " ");
3356
+ return /* @__PURE__ */ I(ns, { ref: d, $height: l, children: e.map((f, C) => {
3357
+ const v = f.id === t, k = () => c?.(f);
3358
3358
  return g ? /* @__PURE__ */ I(
3359
3359
  "div",
3360
3360
  {
3361
- ref: C ? h : null,
3361
+ ref: v ? h : null,
3362
3362
  children: g({
3363
3363
  annotation: f,
3364
- index: w,
3365
- isActive: C,
3366
- onClick: A,
3364
+ index: C,
3365
+ isActive: v,
3366
+ onClick: k,
3367
3367
  formatTime: y
3368
3368
  })
3369
3369
  },
3370
3370
  f.id
3371
- ) : /* @__PURE__ */ te(
3371
+ ) : /* @__PURE__ */ ne(
3372
3372
  rs,
3373
3373
  {
3374
- ref: C ? h : null,
3375
- $isActive: C,
3376
- onClick: A,
3374
+ ref: v ? h : null,
3375
+ $isActive: v,
3376
+ onClick: k,
3377
3377
  children: [
3378
- /* @__PURE__ */ te(as, { children: [
3379
- /* @__PURE__ */ te(os, { children: [
3378
+ /* @__PURE__ */ ne(as, { children: [
3379
+ /* @__PURE__ */ ne(os, { children: [
3380
3380
  /* @__PURE__ */ I(
3381
3381
  ss,
3382
3382
  {
3383
3383
  $isEditable: s,
3384
3384
  contentEditable: s,
3385
3385
  suppressContentEditableWarning: !0,
3386
- onBlur: ($) => p(w, $.currentTarget.textContent || ""),
3386
+ onBlur: (B) => p(C, B.currentTarget.textContent || ""),
3387
3387
  children: f.id
3388
3388
  }
3389
3389
  ),
3390
- /* @__PURE__ */ te(is, { children: [
3390
+ /* @__PURE__ */ ne(is, { children: [
3391
3391
  y(f.start),
3392
3392
  " - ",
3393
3393
  y(f.end)
3394
3394
  ] })
3395
3395
  ] }),
3396
- o.length > 0 && /* @__PURE__ */ I(ls, { onClick: ($) => $.stopPropagation(), children: o.map(($, k) => /* @__PURE__ */ I(
3396
+ o.length > 0 && /* @__PURE__ */ I(ls, { onClick: (B) => B.stopPropagation(), children: o.map((B, $) => /* @__PURE__ */ I(
3397
3397
  cs,
3398
3398
  {
3399
- title: $.title,
3400
- onClick: () => x($, f, w),
3401
- children: $.text ? $.text : /* @__PURE__ */ I("i", { className: v($.class || "") })
3399
+ title: B.title,
3400
+ onClick: () => x(B, f, C),
3401
+ children: B.text ? B.text : /* @__PURE__ */ I("i", { className: w(B.class || "") })
3402
3402
  },
3403
- k
3403
+ $
3404
3404
  )) })
3405
3405
  ] }),
3406
3406
  /* @__PURE__ */ I(
@@ -3409,7 +3409,7 @@ var ns = S.div`
3409
3409
  $isEditable: s,
3410
3410
  contentEditable: s,
3411
3411
  suppressContentEditableWarning: !0,
3412
- onBlur: ($) => m(w, $.currentTarget.textContent || ""),
3412
+ onBlur: (B) => m(C, B.currentTarget.textContent || ""),
3413
3413
  children: f.lines.join(`
3414
3414
  `)
3415
3415
  }
@@ -3419,12 +3419,12 @@ var ns = S.div`
3419
3419
  f.id
3420
3420
  );
3421
3421
  }) });
3422
- }, or = _e.memo(ds), ms = ({
3422
+ }, or = Fe.memo(ds), ms = ({
3423
3423
  checked: e,
3424
3424
  onChange: t,
3425
3425
  disabled: n = !1,
3426
3426
  className: r
3427
- }) => /* @__PURE__ */ te(Dt, { className: r, children: [
3427
+ }) => /* @__PURE__ */ ne(Dt, { className: r, children: [
3428
3428
  /* @__PURE__ */ I(
3429
3429
  Tt,
3430
3430
  {
@@ -3444,7 +3444,7 @@ var ns = S.div`
3444
3444
  onChange: t,
3445
3445
  disabled: n = !1,
3446
3446
  className: r
3447
- }) => /* @__PURE__ */ te(Dt, { className: r, children: [
3447
+ }) => /* @__PURE__ */ ne(Dt, { className: r, children: [
3448
3448
  /* @__PURE__ */ I(
3449
3449
  Tt,
3450
3450
  {
@@ -3463,7 +3463,7 @@ var ns = S.div`
3463
3463
  checked: e,
3464
3464
  onChange: t,
3465
3465
  className: n
3466
- }) => /* @__PURE__ */ te(Dt, { className: n, children: [
3466
+ }) => /* @__PURE__ */ ne(Dt, { className: n, children: [
3467
3467
  /* @__PURE__ */ I(
3468
3468
  Tt,
3469
3469
  {
@@ -3522,7 +3522,7 @@ var ns = S.div`
3522
3522
  }
3523
3523
  );
3524
3524
  function bs() {
3525
- const [e, t] = E("hh:mm:ss.uuu");
3525
+ const [e, t] = R("hh:mm:ss.uuu");
3526
3526
  return {
3527
3527
  timeFormat: e,
3528
3528
  setTimeFormat: t,
@@ -3535,7 +3535,7 @@ function ws({
3535
3535
  initialSamplesPerPixel: e,
3536
3536
  zoomLevels: t = vs
3537
3537
  }) {
3538
- const [n, r] = E(() => {
3538
+ const [n, r] = R(() => {
3539
3539
  const c = t.indexOf(e);
3540
3540
  return c !== -1 ? c : Math.floor(t.length / 2);
3541
3541
  }), a = t[n], s = n > 0, o = n < t.length - 1, i = D(() => {
@@ -3556,7 +3556,7 @@ function ys({
3556
3556
  initialVolume: t = 1,
3557
3557
  onVolumeChange: n
3558
3558
  }) {
3559
- const [r, a] = E(t), s = D((o) => {
3559
+ const [r, a] = R(t), s = D((o) => {
3560
3560
  a(o), e.current && e.current.setMasterGain(o), n?.(o);
3561
3561
  }, [e, n]);
3562
3562
  return {
@@ -3565,7 +3565,7 @@ function ys({
3565
3565
  };
3566
3566
  }
3567
3567
  const wi = (e = 256) => {
3568
- const t = R(null), n = D((r, a, s) => {
3568
+ const t = T(null), n = D((r, a, s) => {
3569
3569
  const o = new Dn("fft", e);
3570
3570
  return r.connect(o), r.connect(a), t.current = o, function() {
3571
3571
  o.dispose(), t.current = null;
@@ -3672,21 +3672,21 @@ function sr() {
3672
3672
  return `${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
3673
3673
  }
3674
3674
  function yi(e, t = {}) {
3675
- const { progressive: n = !1 } = t, [r, a] = E([]), [s, o] = E(!0), [i, l] = E(null), [c, u] = E(0), g = e.length;
3676
- return j(() => {
3675
+ const { progressive: n = !1 } = t, [r, a] = R([]), [s, o] = R(!0), [i, l] = R(null), [c, u] = R(0), g = e.length;
3676
+ return U(() => {
3677
3677
  if (e.length === 0) {
3678
3678
  a([]), o(!1), u(0);
3679
3679
  return;
3680
3680
  }
3681
3681
  let h = !1;
3682
3682
  const d = /* @__PURE__ */ new Map(), b = (m, p, x) => {
3683
- const v = x ?? m.audioBuffer;
3684
- if (!v && !m.waveformData)
3683
+ const w = x ?? m.audioBuffer;
3684
+ if (!w && !m.waveformData)
3685
3685
  throw new Error(
3686
3686
  `Track ${p + 1}: Must provide src, audioBuffer, or waveformData`
3687
3687
  );
3688
- const f = v?.duration ?? m.waveformData?.duration, w = Cs({
3689
- audioBuffer: v,
3688
+ const f = w?.duration ?? m.waveformData?.duration, C = Cs({
3689
+ audioBuffer: w,
3690
3690
  startTime: m.startTime ?? 0,
3691
3691
  duration: m.duration ?? f,
3692
3692
  offset: m.offset ?? 0,
@@ -3695,12 +3695,12 @@ function yi(e, t = {}) {
3695
3695
  fadeOut: m.fadeOut,
3696
3696
  waveformData: m.waveformData
3697
3697
  });
3698
- if (isNaN(w.startSample) || isNaN(w.durationSamples) || isNaN(w.offsetSamples))
3699
- throw console.error("Invalid clip values:", w), new Error(`Invalid clip values for track ${p + 1}`);
3698
+ if (isNaN(C.startSample) || isNaN(C.durationSamples) || isNaN(C.offsetSamples))
3699
+ throw console.error("Invalid clip values:", C), new Error(`Invalid clip values for track ${p + 1}`);
3700
3700
  return {
3701
3701
  ...xs({
3702
3702
  name: m.name || `Track ${p + 1}`,
3703
- clips: [w],
3703
+ clips: [C],
3704
3704
  muted: m.muted ?? !1,
3705
3705
  soloed: m.soloed ?? !1,
3706
3706
  volume: m.volume ?? 1,
@@ -3713,31 +3713,31 @@ function yi(e, t = {}) {
3713
3713
  return (async () => {
3714
3714
  try {
3715
3715
  o(!0), l(null), u(0);
3716
- const m = _r.getContext().rawContext, p = e.map(async (v, f) => {
3717
- if (v.audioBuffer) {
3718
- const k = b(v, f, v.audioBuffer);
3719
- return n && !h && (d.set(f, k), u((B) => B + 1), a(
3720
- Array.from({ length: e.length }, (B, M) => d.get(M)).filter((B) => B !== void 0)
3721
- )), k;
3716
+ const m = _r.getContext().rawContext, p = e.map(async (w, f) => {
3717
+ if (w.audioBuffer) {
3718
+ const $ = b(w, f, w.audioBuffer);
3719
+ return n && !h && (d.set(f, $), u((A) => A + 1), a(
3720
+ Array.from({ length: e.length }, (A, M) => d.get(M)).filter((A) => A !== void 0)
3721
+ )), $;
3722
3722
  }
3723
- if (!v.src && v.waveformData) {
3724
- const k = b(v, f);
3725
- return n && !h && (d.set(f, k), u((B) => B + 1), a(
3726
- Array.from({ length: e.length }, (B, M) => d.get(M)).filter((B) => B !== void 0)
3727
- )), k;
3723
+ if (!w.src && w.waveformData) {
3724
+ const $ = b(w, f);
3725
+ return n && !h && (d.set(f, $), u((A) => A + 1), a(
3726
+ Array.from({ length: e.length }, (A, M) => d.get(M)).filter((A) => A !== void 0)
3727
+ )), $;
3728
3728
  }
3729
- if (!v.src)
3729
+ if (!w.src)
3730
3730
  throw new Error(`Track ${f + 1}: Must provide src, audioBuffer, or waveformData`);
3731
- const w = await fetch(v.src);
3732
- if (!w.ok)
3733
- throw new Error(`Failed to fetch ${v.src}: ${w.statusText}`);
3734
- const C = await w.arrayBuffer(), A = await m.decodeAudioData(C);
3735
- if (!A || !A.sampleRate || !A.duration)
3736
- throw new Error(`Invalid audio buffer for ${v.src}`);
3737
- const $ = b(v, f, A);
3738
- return n && !h && (d.set(f, $), u((k) => k + 1), a(
3739
- Array.from({ length: e.length }, (k, B) => d.get(B)).filter((k) => k !== void 0)
3740
- )), $;
3731
+ const C = await fetch(w.src);
3732
+ if (!C.ok)
3733
+ throw new Error(`Failed to fetch ${w.src}: ${C.statusText}`);
3734
+ const v = await C.arrayBuffer(), k = await m.decodeAudioData(v);
3735
+ if (!k || !k.sampleRate || !k.duration)
3736
+ throw new Error(`Invalid audio buffer for ${w.src}`);
3737
+ const B = b(w, f, k);
3738
+ return n && !h && (d.set(f, B), u(($) => $ + 1), a(
3739
+ Array.from({ length: e.length }, ($, A) => d.get(A)).filter(($) => $ !== void 0)
3740
+ )), B;
3741
3741
  }), x = await Promise.all(p);
3742
3742
  h || (n || (a(x), u(x.length)), o(!1));
3743
3743
  } catch (m) {
@@ -3757,7 +3757,7 @@ function Ci({
3757
3757
  samplesPerPixel: n,
3758
3758
  sampleRate: r
3759
3759
  }) {
3760
- const a = _e.useRef(null), s = _e.useCallback(
3760
+ const a = Fe.useRef(null), s = Fe.useCallback(
3761
3761
  (c) => {
3762
3762
  const { transform: u, active: g } = c;
3763
3763
  if (!g?.data?.current) return { ...u, scaleX: 1, scaleY: 1 };
@@ -3768,30 +3768,30 @@ function Ci({
3768
3768
  if (!y) return { ...u, scaleX: 1, scaleY: 1 };
3769
3769
  const m = y.clips[d];
3770
3770
  if (!m) return { ...u, scaleX: 1, scaleY: 1 };
3771
- const p = m.startSample / r, x = m.durationSamples / r, v = u.x * n / r;
3772
- let f = p + v;
3773
- const w = [...y.clips].sort((M, _) => M.startSample - _.startSample), C = w.findIndex((M) => M === m);
3771
+ const p = m.startSample / r, x = m.durationSamples / r, w = u.x * n / r;
3772
+ let f = p + w;
3773
+ const C = [...y.clips].sort((M, _) => M.startSample - _.startSample), v = C.findIndex((M) => M === m);
3774
3774
  f = Math.max(0, f);
3775
- const A = C > 0 ? w[C - 1] : null;
3776
- if (A) {
3777
- const M = (A.startSample + A.durationSamples) / r;
3775
+ const k = v > 0 ? C[v - 1] : null;
3776
+ if (k) {
3777
+ const M = (k.startSample + k.durationSamples) / r;
3778
3778
  f = Math.max(f, M);
3779
3779
  }
3780
- const $ = C < w.length - 1 ? w[C + 1] : null;
3781
- if ($) {
3782
- const M = f + x, _ = $.startSample / r;
3780
+ const B = v < C.length - 1 ? C[v + 1] : null;
3781
+ if (B) {
3782
+ const M = f + x, _ = B.startSample / r;
3783
3783
  M > _ && (f = _ - x);
3784
3784
  }
3785
- const B = (f - p) * r / n;
3785
+ const A = (f - p) * r / n;
3786
3786
  return {
3787
3787
  ...u,
3788
- x: B,
3788
+ x: A,
3789
3789
  scaleX: 1,
3790
3790
  scaleY: 1
3791
3791
  };
3792
3792
  },
3793
3793
  [e, n, r]
3794
- ), o = _e.useCallback(
3794
+ ), o = Fe.useCallback(
3795
3795
  (c) => {
3796
3796
  const { active: u } = c, { boundary: g } = u.data.current;
3797
3797
  if (!g) {
@@ -3806,48 +3806,48 @@ function Ci({
3806
3806
  });
3807
3807
  },
3808
3808
  [e]
3809
- ), i = _e.useCallback(
3809
+ ), i = Fe.useCallback(
3810
3810
  (c) => {
3811
3811
  const { active: u, delta: g } = c, { boundary: h } = u.data.current;
3812
3812
  if (!h || !a.current) return;
3813
- const { trackIndex: d, clipIndex: b } = u.data.current, y = g.x * n, m = Math.floor(0.1 * r), p = a.current, x = e.map((v, f) => {
3814
- if (f !== d) return v;
3815
- const w = [...v.clips].sort(($, k) => $.startSample - k.startSample), C = w.findIndex(($) => $ === v.clips[b]), A = v.clips.map(($, k) => {
3816
- if (k !== b) return $;
3817
- const B = $.sourceDurationSamples;
3813
+ const { trackIndex: d, clipIndex: b } = u.data.current, y = g.x * n, m = Math.floor(0.1 * r), p = a.current, x = e.map((w, f) => {
3814
+ if (f !== d) return w;
3815
+ const C = [...w.clips].sort((B, $) => B.startSample - $.startSample), v = C.findIndex((B) => B === w.clips[b]), k = w.clips.map((B, $) => {
3816
+ if ($ !== b) return B;
3817
+ const A = B.sourceDurationSamples;
3818
3818
  if (h === "left") {
3819
3819
  let M = Math.floor(y);
3820
3820
  const _ = -p.startSample;
3821
3821
  M < _ && (M = _);
3822
- const T = -p.offsetSamples;
3823
- M < T && (M = T);
3824
- const H = C > 0 ? w[C - 1] : null;
3825
- if (H) {
3826
- const J = H.startSample + H.durationSamples - p.startSample;
3827
- M < J && (M = J);
3822
+ const E = -p.offsetSamples;
3823
+ M < E && (M = E);
3824
+ const V = v > 0 ? C[v - 1] : null;
3825
+ if (V) {
3826
+ const Q = V.startSample + V.durationSamples - p.startSample;
3827
+ M < Q && (M = Q);
3828
3828
  }
3829
- const P = p.durationSamples - m;
3830
- M > P && (M = P);
3831
- const F = p.offsetSamples + M, O = p.durationSamples - M, N = p.startSample + M;
3829
+ const z = p.durationSamples - m;
3830
+ M > z && (M = z);
3831
+ const P = p.offsetSamples + M, K = p.durationSamples - M, X = p.startSample + M;
3832
3832
  return {
3833
- ...$,
3834
- offsetSamples: F,
3835
- durationSamples: O,
3836
- startSample: N
3833
+ ...B,
3834
+ offsetSamples: P,
3835
+ durationSamples: K,
3836
+ startSample: X
3837
3837
  };
3838
3838
  } else {
3839
3839
  let M = Math.floor(p.durationSamples + y);
3840
- M = Math.max(m, M), p.offsetSamples + M > B && (M = B - p.offsetSamples);
3841
- const _ = C < w.length - 1 ? w[C + 1] : null;
3842
- return _ && p.startSample + M > _.startSample && (M = _.startSample - p.startSample, M = Math.max(m, M)), { ...$, durationSamples: M };
3840
+ M = Math.max(m, M), p.offsetSamples + M > A && (M = A - p.offsetSamples);
3841
+ const _ = v < C.length - 1 ? C[v + 1] : null;
3842
+ return _ && p.startSample + M > _.startSample && (M = _.startSample - p.startSample, M = Math.max(m, M)), { ...B, durationSamples: M };
3843
3843
  }
3844
3844
  });
3845
- return { ...v, clips: A };
3845
+ return { ...w, clips: k };
3846
3846
  });
3847
3847
  t(x);
3848
3848
  },
3849
3849
  [e, t, n, r]
3850
- ), l = _e.useCallback(
3850
+ ), l = Fe.useCallback(
3851
3851
  (c) => {
3852
3852
  const { active: u, delta: g } = c, { trackIndex: h, clipIndex: d, boundary: b } = u.data.current, y = g.x * n;
3853
3853
  if (b) {
@@ -3856,24 +3856,24 @@ function Ci({
3856
3856
  }
3857
3857
  const m = e.map((p, x) => {
3858
3858
  if (x !== h) return p;
3859
- const v = [...p.clips].sort((C, A) => C.startSample - A.startSample), f = v.findIndex((C) => C === p.clips[d]), w = p.clips.map((C, A) => {
3860
- if (A !== d) return C;
3861
- let $ = Math.floor(C.startSample + y);
3862
- $ = Math.max(0, $);
3863
- const k = f > 0 ? v[f - 1] : null;
3864
- if (k) {
3865
- const M = k.startSample + k.durationSamples;
3866
- $ = Math.max($, M);
3859
+ const w = [...p.clips].sort((v, k) => v.startSample - k.startSample), f = w.findIndex((v) => v === p.clips[d]), C = p.clips.map((v, k) => {
3860
+ if (k !== d) return v;
3861
+ let B = Math.floor(v.startSample + y);
3862
+ B = Math.max(0, B);
3863
+ const $ = f > 0 ? w[f - 1] : null;
3864
+ if ($) {
3865
+ const M = $.startSample + $.durationSamples;
3866
+ B = Math.max(B, M);
3867
3867
  }
3868
- const B = f < v.length - 1 ? v[f + 1] : null;
3869
- return B && $ + C.durationSamples > B.startSample && ($ = B.startSample - C.durationSamples), {
3870
- ...C,
3871
- startSample: $
3868
+ const A = f < w.length - 1 ? w[f + 1] : null;
3869
+ return A && B + v.durationSamples > A.startSample && (B = A.startSample - v.durationSamples), {
3870
+ ...v,
3871
+ startSample: B
3872
3872
  };
3873
3873
  });
3874
3874
  return {
3875
3875
  ...p,
3876
- clips: w
3876
+ clips: C
3877
3877
  };
3878
3878
  });
3879
3879
  t(m);
@@ -3896,7 +3896,7 @@ function Is({
3896
3896
  duration: a,
3897
3897
  linkEndpoints: s
3898
3898
  }) {
3899
- const o = _e.useRef(null), i = _e.useCallback(
3899
+ const o = Fe.useRef(null), i = Fe.useCallback(
3900
3900
  (u) => {
3901
3901
  const { active: g } = u, h = g.data.current;
3902
3902
  if (!h || h.annotationIndex === void 0) {
@@ -3911,14 +3911,14 @@ function Is({
3911
3911
  });
3912
3912
  },
3913
3913
  [e]
3914
- ), l = _e.useCallback(
3914
+ ), l = Fe.useCallback(
3915
3915
  (u) => {
3916
3916
  const { active: g, delta: h } = u;
3917
3917
  if (!o.current)
3918
3918
  return;
3919
3919
  const d = g.data.current;
3920
3920
  if (!d) return;
3921
- const { edge: b, annotationIndex: y } = d, m = o.current, p = h.x * n / r, x = b === "start" ? m.start + p : m.end + p, v = As({
3921
+ const { edge: b, annotationIndex: y } = d, m = o.current, p = h.x * n / r, x = b === "start" ? m.start + p : m.end + p, w = As({
3922
3922
  annotationIndex: y,
3923
3923
  newTime: x,
3924
3924
  isDraggingStart: b === "start",
@@ -3926,10 +3926,10 @@ function Is({
3926
3926
  duration: a,
3927
3927
  linkEndpoints: s
3928
3928
  });
3929
- t(v);
3929
+ t(w);
3930
3930
  },
3931
3931
  [e, t, n, r, a, s]
3932
- ), c = _e.useCallback(() => {
3932
+ ), c = Fe.useCallback(() => {
3933
3933
  o.current = null;
3934
3934
  }, []);
3935
3935
  return {
@@ -4045,7 +4045,7 @@ function xi(e = {}) {
4045
4045
  );
4046
4046
  }
4047
4047
  const Ii = (e) => {
4048
- const { tracks: t, onTracksChange: n, sampleRate: r } = e, { currentTimeRef: a } = Fe(), { selectedTrackId: s } = Ge(), o = D(
4048
+ const { tracks: t, onTracksChange: n, sampleRate: r } = e, { currentTimeRef: a } = Ze(), { selectedTrackId: s } = Ne(), o = D(
4049
4049
  (l, c, u) => {
4050
4050
  const { sampleRate: g, samplesPerPixel: h } = e, d = t[l];
4051
4051
  if (!d) return !1;
@@ -4054,10 +4054,10 @@ const Ii = (e) => {
4054
4054
  const y = b.startSample / g, m = (b.startSample + b.durationSamples) / g;
4055
4055
  if (u <= y || u >= m)
4056
4056
  return console.warn("Split time is outside clip bounds"), !1;
4057
- const p = Math.round(u * g), x = Math.floor(p / h), v = b.startSample + b.durationSamples, f = x * h, w = b.startSample, C = f - w, A = f, $ = v - A, k = f - b.startSample, B = Yt({
4057
+ const p = Math.round(u * g), x = Math.floor(p / h), w = b.startSample + b.durationSamples, f = x * h, C = b.startSample, v = f - C, k = f, B = w - k, $ = f - b.startSample, A = Yt({
4058
4058
  audioBuffer: b.audioBuffer,
4059
- startSample: w,
4060
- durationSamples: C,
4059
+ startSample: C,
4060
+ durationSamples: v,
4061
4061
  offsetSamples: b.offsetSamples,
4062
4062
  sampleRate: b.sampleRate,
4063
4063
  sourceDurationSamples: b.sourceDurationSamples,
@@ -4070,9 +4070,9 @@ const Ii = (e) => {
4070
4070
  // Note: fadeOut removed for first clip since it's cut
4071
4071
  }), M = Yt({
4072
4072
  audioBuffer: b.audioBuffer,
4073
- startSample: A,
4074
- durationSamples: $,
4075
- offsetSamples: b.offsetSamples + k,
4073
+ startSample: k,
4074
+ durationSamples: B,
4075
+ offsetSamples: b.offsetSamples + $,
4076
4076
  sampleRate: b.sampleRate,
4077
4077
  sourceDurationSamples: b.sourceDurationSamples,
4078
4078
  gain: b.gain,
@@ -4083,12 +4083,12 @@ const Ii = (e) => {
4083
4083
  // Note: fadeIn removed for second clip since it's cut
4084
4084
  fadeOut: b.fadeOut
4085
4085
  }), _ = [...d.clips];
4086
- _.splice(c, 1, B, M);
4087
- const T = [...t];
4088
- return T[l] = {
4086
+ _.splice(c, 1, A, M);
4087
+ const E = [...t];
4088
+ return E[l] = {
4089
4089
  ...d,
4090
4090
  clips: _
4091
- }, n(T), !0;
4091
+ }, n(E), !0;
4092
4092
  },
4093
4093
  [t, n, e]
4094
4094
  );
@@ -4124,7 +4124,7 @@ const Ii = (e) => {
4124
4124
  },
4125
4125
  [t, n]
4126
4126
  );
4127
- j(() => {
4127
+ U(() => {
4128
4128
  if (n)
4129
4129
  return window.addEventListener("keydown", r), () => {
4130
4130
  window.removeEventListener("keydown", r);
@@ -4134,7 +4134,7 @@ const Ii = (e) => {
4134
4134
  const t = [], n = typeof navigator < "u" && navigator.platform.includes("Mac");
4135
4135
  return e.metaKey && t.push(n ? "Cmd" : "Ctrl"), e.ctrlKey && !e.metaKey && t.push("Ctrl"), e.altKey && t.push(n ? "Option" : "Alt"), e.shiftKey && t.push("Shift"), t.push(e.key.toUpperCase()), t.join("+");
4136
4136
  }, ki = (e = {}) => {
4137
- const { enabled: t = !0, additionalShortcuts: n = [], shortcuts: r } = e, { isPlaying: a } = Fe(), { setCurrentTime: s, play: o, pause: i, stop: l } = ge(), { playoutRef: c } = De(), u = D(() => {
4137
+ const { enabled: t = !0, additionalShortcuts: n = [], shortcuts: r } = e, { isPlaying: a } = Ze(), { setCurrentTime: s, play: o, pause: i, stop: l } = ge(), { playoutRef: c } = Be(), u = D(() => {
4138
4138
  a ? i() : o();
4139
4139
  }, [a, o, i]), g = D(() => {
4140
4140
  l();
@@ -4185,14 +4185,14 @@ function Si({
4185
4185
  controlsWidth: g = 0,
4186
4186
  onPlay: h
4187
4187
  }) {
4188
- const d = nt(() => t ? e.findIndex((k) => k.id === t) : -1, [e, t]), b = D(
4189
- (k) => {
4188
+ const d = nt(() => t ? e.findIndex(($) => $.id === t) : -1, [e, t]), b = D(
4189
+ ($) => {
4190
4190
  if (!l?.current || !c || !u) return;
4191
- const B = e.find((Z) => Z.id === k);
4192
- if (!B) return;
4193
- const M = l.current, _ = M.clientWidth, T = B.start * u / c + g, H = B.end * u / c + g, P = (T + H) / 2, F = M.scrollLeft, O = F, N = F + _;
4194
- if (T < O || H > N) {
4195
- const Z = Math.max(0, P - _ / 2);
4191
+ const A = e.find((Z) => Z.id === $);
4192
+ if (!A) return;
4193
+ const M = l.current, _ = M.clientWidth, E = A.start * u / c + g, V = A.end * u / c + g, z = (E + V) / 2, P = M.scrollLeft, K = P, X = P + _;
4194
+ if (E < K || V > X) {
4195
+ const Z = Math.max(0, z - _ / 2);
4196
4196
  M.scrollTo({
4197
4197
  left: Z,
4198
4198
  behavior: "smooth"
@@ -4201,98 +4201,98 @@ function Si({
4201
4201
  },
4202
4202
  [e, l, c, u, g]
4203
4203
  );
4204
- j(() => {
4204
+ U(() => {
4205
4205
  t && l?.current && c && u && b(t);
4206
4206
  }, [t, b, l, c, u]);
4207
4207
  const y = D(
4208
- (k) => {
4208
+ ($) => {
4209
4209
  if (d < 0) return;
4210
- const B = e[d], M = Math.max(0, Math.min(B.end - 0.1, B.start + k)), _ = M - B.start, T = [...e];
4211
- if (T[d] = {
4212
- ...B,
4210
+ const A = e[d], M = Math.max(0, Math.min(A.end - 0.1, A.start + $)), _ = M - A.start, E = [...e];
4211
+ if (E[d] = {
4212
+ ...A,
4213
4213
  start: M
4214
4214
  }, s && d > 0) {
4215
- const H = T[d - 1];
4216
- Math.abs(H.end - B.start) < Gt && (T[d - 1] = {
4217
- ...H,
4218
- end: Math.max(H.start + 0.1, H.end + _)
4215
+ const V = E[d - 1];
4216
+ Math.abs(V.end - A.start) < Gt && (E[d - 1] = {
4217
+ ...V,
4218
+ end: Math.max(V.start + 0.1, V.end + _)
4219
4219
  });
4220
4220
  } else if (!s && d > 0) {
4221
- const H = T[d - 1];
4222
- M < H.end && (T[d - 1] = {
4223
- ...H,
4221
+ const V = E[d - 1];
4222
+ M < V.end && (E[d - 1] = {
4223
+ ...V,
4224
4224
  end: M
4225
4225
  });
4226
4226
  }
4227
- n(T);
4227
+ n(E);
4228
4228
  },
4229
4229
  [e, d, s, n]
4230
4230
  ), m = D(
4231
- (k) => {
4231
+ ($) => {
4232
4232
  if (d < 0) return;
4233
- const B = e[d], M = Math.max(B.start + 0.1, Math.min(a, B.end + k)), _ = M - B.end, T = [...e];
4234
- if (T[d] = {
4235
- ...B,
4233
+ const A = e[d], M = Math.max(A.start + 0.1, Math.min(a, A.end + $)), _ = M - A.end, E = [...e];
4234
+ if (E[d] = {
4235
+ ...A,
4236
4236
  end: M
4237
4237
  }, s && d < e.length - 1) {
4238
- const H = T[d + 1];
4239
- if (Math.abs(H.start - B.end) < Gt) {
4240
- const P = Math.min(H.end - 0.1, H.start + _);
4241
- T[d + 1] = {
4242
- ...H,
4243
- start: P
4238
+ const V = E[d + 1];
4239
+ if (Math.abs(V.start - A.end) < Gt) {
4240
+ const z = Math.min(V.end - 0.1, V.start + _);
4241
+ E[d + 1] = {
4242
+ ...V,
4243
+ start: z
4244
4244
  };
4245
- let F = d + 1;
4246
- for (; F < T.length - 1; ) {
4247
- const O = T[F], N = T[F + 1];
4248
- if (Math.abs(N.start - e[F].end) < Gt) {
4249
- const Z = O.end - e[F].end;
4250
- T[F + 1] = {
4251
- ...N,
4252
- start: Math.min(N.end - 0.1, N.start + Z)
4253
- }, F++;
4245
+ let P = d + 1;
4246
+ for (; P < E.length - 1; ) {
4247
+ const K = E[P], X = E[P + 1];
4248
+ if (Math.abs(X.start - e[P].end) < Gt) {
4249
+ const Z = K.end - e[P].end;
4250
+ E[P + 1] = {
4251
+ ...X,
4252
+ start: Math.min(X.end - 0.1, X.start + Z)
4253
+ }, P++;
4254
4254
  } else
4255
4255
  break;
4256
4256
  }
4257
4257
  }
4258
4258
  } else if (!s && d < e.length - 1) {
4259
- const H = T[d + 1];
4260
- if (M > H.start) {
4261
- T[d + 1] = {
4262
- ...H,
4259
+ const V = E[d + 1];
4260
+ if (M > V.start) {
4261
+ E[d + 1] = {
4262
+ ...V,
4263
4263
  start: M
4264
4264
  };
4265
- let P = d + 1;
4266
- for (; P < T.length - 1; ) {
4267
- const F = T[P], O = T[P + 1];
4268
- if (F.end > O.start)
4269
- T[P + 1] = {
4270
- ...O,
4271
- start: F.end
4272
- }, P++;
4265
+ let z = d + 1;
4266
+ for (; z < E.length - 1; ) {
4267
+ const P = E[z], K = E[z + 1];
4268
+ if (P.end > K.start)
4269
+ E[z + 1] = {
4270
+ ...K,
4271
+ start: P.end
4272
+ }, z++;
4273
4273
  else
4274
4274
  break;
4275
4275
  }
4276
4276
  }
4277
4277
  }
4278
- n(T);
4278
+ n(E);
4279
4279
  },
4280
4280
  [e, d, a, s, n]
4281
4281
  ), p = D(() => {
4282
4282
  !r || e.length === 0 || (d <= 0 ? r(e[e.length - 1].id) : r(e[d - 1].id));
4283
4283
  }, [e, d, r]), x = D(() => {
4284
4284
  !r || e.length === 0 || (d < 0 || d >= e.length - 1 ? r(e[0].id) : r(e[d + 1].id));
4285
- }, [e, d, r]), v = D(() => {
4285
+ }, [e, d, r]), w = D(() => {
4286
4286
  !r || e.length === 0 || r(e[0].id);
4287
4287
  }, [e, r]), f = D(() => {
4288
4288
  !r || e.length === 0 || r(e[e.length - 1].id);
4289
- }, [e, r]), w = D(() => {
4289
+ }, [e, r]), C = D(() => {
4290
4290
  r && r(null);
4291
- }, [r]), C = D(() => {
4291
+ }, [r]), v = D(() => {
4292
4292
  if (d < 0 || !h) return;
4293
- const k = e[d], B = o ? void 0 : k.end - k.start;
4294
- h(k.start, B);
4295
- }, [e, d, o, h]), A = nt(
4293
+ const $ = e[d], A = o ? void 0 : $.end - $.start;
4294
+ h($.start, A);
4295
+ }, [e, d, o, h]), k = nt(
4296
4296
  () => [
4297
4297
  {
4298
4298
  key: "[",
@@ -4322,13 +4322,13 @@ function Si({
4322
4322
  },
4323
4323
  {
4324
4324
  key: "Enter",
4325
- action: C,
4325
+ action: v,
4326
4326
  description: "Play selected annotation",
4327
4327
  preventDefault: !0
4328
4328
  }
4329
4329
  ],
4330
- [y, m, C]
4331
- ), $ = nt(
4330
+ [y, m, v]
4331
+ ), B = nt(
4332
4332
  () => [
4333
4333
  {
4334
4334
  key: "ArrowUp",
@@ -4356,7 +4356,7 @@ function Si({
4356
4356
  },
4357
4357
  {
4358
4358
  key: "Home",
4359
- action: v,
4359
+ action: w,
4360
4360
  description: "Select first annotation",
4361
4361
  preventDefault: !0
4362
4362
  },
@@ -4368,29 +4368,29 @@ function Si({
4368
4368
  },
4369
4369
  {
4370
4370
  key: "Escape",
4371
- action: w,
4371
+ action: C,
4372
4372
  description: "Deselect annotation",
4373
4373
  preventDefault: !0
4374
4374
  }
4375
4375
  ],
4376
- [p, x, v, f, w]
4376
+ [p, x, w, f, C]
4377
4377
  );
4378
4378
  return Ot({
4379
- shortcuts: A,
4379
+ shortcuts: k,
4380
4380
  enabled: i && d >= 0
4381
4381
  }), Ot({
4382
- shortcuts: $,
4382
+ shortcuts: B,
4383
4383
  enabled: i && e.length > 0 && !!r
4384
4384
  }), {
4385
4385
  moveStartBoundary: y,
4386
4386
  moveEndBoundary: m,
4387
4387
  selectPrevious: p,
4388
4388
  selectNext: x,
4389
- selectFirst: v,
4389
+ selectFirst: w,
4390
4390
  selectLast: f,
4391
- clearSelection: w,
4391
+ clearSelection: C,
4392
4392
  scrollToAnnotation: b,
4393
- playActiveAnnotation: C
4393
+ playActiveAnnotation: v
4394
4394
  };
4395
4395
  }
4396
4396
  function ks(e) {
@@ -4443,99 +4443,99 @@ function Ms(e, t = {}) {
4443
4443
  const {
4444
4444
  channelCount: n = 1,
4445
4445
  samplesPerPixel: r = 1024
4446
- } = t, [a, s] = E(!1), [o, i] = E(!1), [l, c] = E(0), [u, g] = E(new Int16Array(0)), [h, d] = E(null), [b, y] = E(null), [m, p] = E(0), [x, v] = E(0), f = 16, w = R(!1), C = R(null), A = R(null), $ = R([]), k = R(0), B = R(null), M = R(0), _ = R(!1), T = R(!1), H = D(async () => {
4447
- if (!w.current)
4446
+ } = t, [a, s] = R(!1), [o, i] = R(!1), [l, c] = R(0), [u, g] = R(new Int16Array(0)), [h, d] = R(null), [b, y] = R(null), [m, p] = R(0), [x, w] = R(0), f = 16, C = T(!1), v = T(null), k = T(null), B = T([]), $ = T(0), A = T(null), M = T(0), _ = T(!1), E = T(!1), V = D(async () => {
4447
+ if (!C.current)
4448
4448
  try {
4449
- const Z = ke(), J = new URL("data:text/javascript;base64,InVzZSBzdHJpY3QiOwoKLy8gc3JjL3dvcmtsZXQvcmVjb3JkaW5nLXByb2Nlc3Nvci53b3JrbGV0LnRzCnZhciBSZWNvcmRpbmdQcm9jZXNzb3IgPSBjbGFzcyBleHRlbmRzIEF1ZGlvV29ya2xldFByb2Nlc3NvciB7CiAgY29uc3RydWN0b3IoKSB7CiAgICBzdXBlcigpOwogICAgdGhpcy5idWZmZXJTaXplID0gMDsKICAgIHRoaXMuYnVmZmVycyA9IFtdOwogICAgdGhpcy5zYW1wbGVzQ29sbGVjdGVkID0gMDsKICAgIHRoaXMuaXNSZWNvcmRpbmcgPSBmYWxzZTsKICAgIHRoaXMuY2hhbm5lbENvdW50ID0gMTsKICAgIHRoaXMucG9ydC5vbm1lc3NhZ2UgPSAoZXZlbnQpID0+IHsKICAgICAgY29uc3QgeyBjb21tYW5kLCBzYW1wbGVSYXRlOiBzYW1wbGVSYXRlMiwgY2hhbm5lbENvdW50IH0gPSBldmVudC5kYXRhOwogICAgICBpZiAoY29tbWFuZCA9PT0gInN0YXJ0IikgewogICAgICAgIHRoaXMuaXNSZWNvcmRpbmcgPSB0cnVlOwogICAgICAgIHRoaXMuY2hhbm5lbENvdW50ID0gY2hhbm5lbENvdW50IHx8IDE7CiAgICAgICAgdGhpcy5idWZmZXJTaXplID0gTWF0aC5mbG9vcigoc2FtcGxlUmF0ZTIgfHwgNDhlMykgKiAwLjAxNik7CiAgICAgICAgdGhpcy5idWZmZXJzID0gW107CiAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCB0aGlzLmNoYW5uZWxDb3VudDsgaSsrKSB7CiAgICAgICAgICB0aGlzLmJ1ZmZlcnNbaV0gPSBuZXcgRmxvYXQzMkFycmF5KHRoaXMuYnVmZmVyU2l6ZSk7CiAgICAgICAgfQogICAgICAgIHRoaXMuc2FtcGxlc0NvbGxlY3RlZCA9IDA7CiAgICAgIH0gZWxzZSBpZiAoY29tbWFuZCA9PT0gInN0b3AiKSB7CiAgICAgICAgdGhpcy5pc1JlY29yZGluZyA9IGZhbHNlOwogICAgICAgIGlmICh0aGlzLnNhbXBsZXNDb2xsZWN0ZWQgPiAwKSB7CiAgICAgICAgICB0aGlzLmZsdXNoQnVmZmVycygpOwogICAgICAgIH0KICAgICAgfQogICAgfTsKICB9CiAgcHJvY2VzcyhpbnB1dHMsIG91dHB1dHMsIHBhcmFtZXRlcnMpIHsKICAgIGlmICghdGhpcy5pc1JlY29yZGluZykgewogICAgICByZXR1cm4gdHJ1ZTsKICAgIH0KICAgIGNvbnN0IGlucHV0ID0gaW5wdXRzWzBdOwogICAgaWYgKCFpbnB1dCB8fCBpbnB1dC5sZW5ndGggPT09IDApIHsKICAgICAgcmV0dXJuIHRydWU7CiAgICB9CiAgICBjb25zdCBmcmFtZUNvdW50ID0gaW5wdXRbMF0ubGVuZ3RoOwogICAgZm9yIChsZXQgY2hhbm5lbCA9IDA7IGNoYW5uZWwgPCBNYXRoLm1pbihpbnB1dC5sZW5ndGgsIHRoaXMuY2hhbm5lbENvdW50KTsgY2hhbm5lbCsrKSB7CiAgICAgIGNvbnN0IGlucHV0Q2hhbm5lbCA9IGlucHV0W2NoYW5uZWxdOwogICAgICBjb25zdCBidWZmZXIgPSB0aGlzLmJ1ZmZlcnNbY2hhbm5lbF07CiAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgZnJhbWVDb3VudDsgaSsrKSB7CiAgICAgICAgYnVmZmVyW3RoaXMuc2FtcGxlc0NvbGxlY3RlZCArIGldID0gaW5wdXRDaGFubmVsW2ldOwogICAgICB9CiAgICB9CiAgICB0aGlzLnNhbXBsZXNDb2xsZWN0ZWQgKz0gZnJhbWVDb3VudDsKICAgIGlmICh0aGlzLnNhbXBsZXNDb2xsZWN0ZWQgPj0gdGhpcy5idWZmZXJTaXplKSB7CiAgICAgIHRoaXMuZmx1c2hCdWZmZXJzKCk7CiAgICB9CiAgICByZXR1cm4gdHJ1ZTsKICB9CiAgZmx1c2hCdWZmZXJzKCkgewogICAgY29uc3Qgc2FtcGxlcyA9IHRoaXMuYnVmZmVyc1swXS5zbGljZSgwLCB0aGlzLnNhbXBsZXNDb2xsZWN0ZWQpOwogICAgdGhpcy5wb3J0LnBvc3RNZXNzYWdlKHsKICAgICAgc2FtcGxlcywKICAgICAgc2FtcGxlUmF0ZSwKICAgICAgY2hhbm5lbENvdW50OiB0aGlzLmNoYW5uZWxDb3VudAogICAgfSk7CiAgICB0aGlzLnNhbXBsZXNDb2xsZWN0ZWQgPSAwOwogIH0KfTsKcmVnaXN0ZXJQcm9jZXNzb3IoInJlY29yZGluZy1wcm9jZXNzb3IiLCBSZWNvcmRpbmdQcm9jZXNzb3IpOwovLyMgc291cmNlTWFwcGluZ1VSTD1yZWNvcmRpbmctcHJvY2Vzc29yLndvcmtsZXQuanMubWFw", import.meta.url).href;
4450
- await Z.addAudioWorkletModule(J), w.current = !0;
4449
+ const Z = Ae(), Q = new URL("data:text/javascript;base64,InVzZSBzdHJpY3QiOwoKLy8gc3JjL3dvcmtsZXQvcmVjb3JkaW5nLXByb2Nlc3Nvci53b3JrbGV0LnRzCnZhciBSZWNvcmRpbmdQcm9jZXNzb3IgPSBjbGFzcyBleHRlbmRzIEF1ZGlvV29ya2xldFByb2Nlc3NvciB7CiAgY29uc3RydWN0b3IoKSB7CiAgICBzdXBlcigpOwogICAgdGhpcy5idWZmZXJTaXplID0gMDsKICAgIHRoaXMuYnVmZmVycyA9IFtdOwogICAgdGhpcy5zYW1wbGVzQ29sbGVjdGVkID0gMDsKICAgIHRoaXMuaXNSZWNvcmRpbmcgPSBmYWxzZTsKICAgIHRoaXMuY2hhbm5lbENvdW50ID0gMTsKICAgIHRoaXMucG9ydC5vbm1lc3NhZ2UgPSAoZXZlbnQpID0+IHsKICAgICAgY29uc3QgeyBjb21tYW5kLCBzYW1wbGVSYXRlOiBzYW1wbGVSYXRlMiwgY2hhbm5lbENvdW50IH0gPSBldmVudC5kYXRhOwogICAgICBpZiAoY29tbWFuZCA9PT0gInN0YXJ0IikgewogICAgICAgIHRoaXMuaXNSZWNvcmRpbmcgPSB0cnVlOwogICAgICAgIHRoaXMuY2hhbm5lbENvdW50ID0gY2hhbm5lbENvdW50IHx8IDE7CiAgICAgICAgdGhpcy5idWZmZXJTaXplID0gTWF0aC5mbG9vcigoc2FtcGxlUmF0ZTIgfHwgNDhlMykgKiAwLjAxNik7CiAgICAgICAgdGhpcy5idWZmZXJzID0gW107CiAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCB0aGlzLmNoYW5uZWxDb3VudDsgaSsrKSB7CiAgICAgICAgICB0aGlzLmJ1ZmZlcnNbaV0gPSBuZXcgRmxvYXQzMkFycmF5KHRoaXMuYnVmZmVyU2l6ZSk7CiAgICAgICAgfQogICAgICAgIHRoaXMuc2FtcGxlc0NvbGxlY3RlZCA9IDA7CiAgICAgIH0gZWxzZSBpZiAoY29tbWFuZCA9PT0gInN0b3AiKSB7CiAgICAgICAgdGhpcy5pc1JlY29yZGluZyA9IGZhbHNlOwogICAgICAgIGlmICh0aGlzLnNhbXBsZXNDb2xsZWN0ZWQgPiAwKSB7CiAgICAgICAgICB0aGlzLmZsdXNoQnVmZmVycygpOwogICAgICAgIH0KICAgICAgfQogICAgfTsKICB9CiAgcHJvY2VzcyhpbnB1dHMsIG91dHB1dHMsIHBhcmFtZXRlcnMpIHsKICAgIGlmICghdGhpcy5pc1JlY29yZGluZykgewogICAgICByZXR1cm4gdHJ1ZTsKICAgIH0KICAgIGNvbnN0IGlucHV0ID0gaW5wdXRzWzBdOwogICAgaWYgKCFpbnB1dCB8fCBpbnB1dC5sZW5ndGggPT09IDApIHsKICAgICAgcmV0dXJuIHRydWU7CiAgICB9CiAgICBjb25zdCBmcmFtZUNvdW50ID0gaW5wdXRbMF0ubGVuZ3RoOwogICAgZm9yIChsZXQgY2hhbm5lbCA9IDA7IGNoYW5uZWwgPCBNYXRoLm1pbihpbnB1dC5sZW5ndGgsIHRoaXMuY2hhbm5lbENvdW50KTsgY2hhbm5lbCsrKSB7CiAgICAgIGNvbnN0IGlucHV0Q2hhbm5lbCA9IGlucHV0W2NoYW5uZWxdOwogICAgICBjb25zdCBidWZmZXIgPSB0aGlzLmJ1ZmZlcnNbY2hhbm5lbF07CiAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgZnJhbWVDb3VudDsgaSsrKSB7CiAgICAgICAgYnVmZmVyW3RoaXMuc2FtcGxlc0NvbGxlY3RlZCArIGldID0gaW5wdXRDaGFubmVsW2ldOwogICAgICB9CiAgICB9CiAgICB0aGlzLnNhbXBsZXNDb2xsZWN0ZWQgKz0gZnJhbWVDb3VudDsKICAgIGlmICh0aGlzLnNhbXBsZXNDb2xsZWN0ZWQgPj0gdGhpcy5idWZmZXJTaXplKSB7CiAgICAgIHRoaXMuZmx1c2hCdWZmZXJzKCk7CiAgICB9CiAgICByZXR1cm4gdHJ1ZTsKICB9CiAgZmx1c2hCdWZmZXJzKCkgewogICAgY29uc3Qgc2FtcGxlcyA9IHRoaXMuYnVmZmVyc1swXS5zbGljZSgwLCB0aGlzLnNhbXBsZXNDb2xsZWN0ZWQpOwogICAgdGhpcy5wb3J0LnBvc3RNZXNzYWdlKHsKICAgICAgc2FtcGxlcywKICAgICAgc2FtcGxlUmF0ZSwKICAgICAgY2hhbm5lbENvdW50OiB0aGlzLmNoYW5uZWxDb3VudAogICAgfSk7CiAgICB0aGlzLnNhbXBsZXNDb2xsZWN0ZWQgPSAwOwogIH0KfTsKcmVnaXN0ZXJQcm9jZXNzb3IoInJlY29yZGluZy1wcm9jZXNzb3IiLCBSZWNvcmRpbmdQcm9jZXNzb3IpOwovLyMgc291cmNlTWFwcGluZ1VSTD1yZWNvcmRpbmctcHJvY2Vzc29yLndvcmtsZXQuanMubWFw", import.meta.url).href;
4450
+ await Z.addAudioWorkletModule(Q), C.current = !0;
4451
4451
  } catch (Z) {
4452
4452
  throw console.error("Failed to load AudioWorklet module:", Z), new Error("Failed to load recording processor");
4453
4453
  }
4454
- }, []), P = D(async () => {
4454
+ }, []), z = D(async () => {
4455
4455
  if (!e) {
4456
4456
  y(new Error("No microphone stream available"));
4457
4457
  return;
4458
4458
  }
4459
4459
  try {
4460
4460
  y(null);
4461
- const Z = ke();
4462
- Z.state === "suspended" && await Z.resume(), await H();
4463
- const J = Z.createMediaStreamSource(e);
4464
- A.current = J;
4465
- const se = Z.createAudioWorkletNode("recording-processor");
4466
- C.current = se, J.connect(se), se.port.onmessage = (ee) => {
4467
- const { samples: oe } = ee.data;
4468
- $.current.push(oe), k.current += oe.length, g(
4461
+ const Z = Ae();
4462
+ Z.state === "suspended" && await Z.resume(), await V();
4463
+ const Q = Z.createMediaStreamSource(e);
4464
+ k.current = Q;
4465
+ const le = Z.createAudioWorkletNode("recording-processor");
4466
+ v.current = le, Q.connect(le), le.port.onmessage = (re) => {
4467
+ const { samples: ae } = re.data;
4468
+ B.current.push(ae), $.current += ae.length, g(
4469
4469
  (ye) => $s(
4470
4470
  ye,
4471
- oe,
4471
+ ae,
4472
4472
  r,
4473
- k.current - oe.length,
4473
+ $.current - ae.length,
4474
4474
  f
4475
4475
  )
4476
4476
  );
4477
- }, se.port.postMessage({
4477
+ }, le.port.postMessage({
4478
4478
  command: "start",
4479
4479
  sampleRate: Z.sampleRate,
4480
4480
  channelCount: n
4481
- }), $.current = [], k.current = 0, g(new Int16Array(0)), d(null), p(0), v(0), _.current = !0, T.current = !1, s(!0), i(!1), M.current = performance.now();
4482
- const ae = () => {
4483
- if (_.current && !T.current) {
4484
- const ee = (performance.now() - M.current) / 1e3;
4485
- c(ee), B.current = requestAnimationFrame(ae);
4481
+ }), B.current = [], $.current = 0, g(new Int16Array(0)), d(null), p(0), w(0), _.current = !0, E.current = !1, s(!0), i(!1), M.current = performance.now();
4482
+ const te = () => {
4483
+ if (_.current && !E.current) {
4484
+ const re = (performance.now() - M.current) / 1e3;
4485
+ c(re), A.current = requestAnimationFrame(te);
4486
4486
  }
4487
4487
  };
4488
- ae();
4488
+ te();
4489
4489
  } catch (Z) {
4490
4490
  console.error("Failed to start recording:", Z), y(Z instanceof Error ? Z : new Error("Failed to start recording"));
4491
4491
  }
4492
- }, [e, n, r, H, a, o]), F = D(async () => {
4492
+ }, [e, n, r, V, a, o]), P = D(async () => {
4493
4493
  if (!a)
4494
4494
  return null;
4495
4495
  try {
4496
- if (C.current) {
4497
- if (C.current.port.postMessage({ command: "stop" }), A.current)
4496
+ if (v.current) {
4497
+ if (v.current.port.postMessage({ command: "stop" }), k.current)
4498
4498
  try {
4499
- A.current.disconnect(C.current);
4499
+ k.current.disconnect(v.current);
4500
4500
  } catch {
4501
4501
  }
4502
- C.current.disconnect();
4502
+ v.current.disconnect();
4503
4503
  }
4504
- B.current !== null && (cancelAnimationFrame(B.current), B.current = null);
4505
- const Z = ks($.current), se = ke().rawContext, ae = Ss(
4506
- se,
4504
+ A.current !== null && (cancelAnimationFrame(A.current), A.current = null);
4505
+ const Z = ks(B.current), le = Ae().rawContext, te = Ss(
4506
+ le,
4507
4507
  Z,
4508
- se.sampleRate,
4508
+ le.sampleRate,
4509
4509
  n
4510
4510
  );
4511
- return d(ae), c(ae.duration), _.current = !1, T.current = !1, s(!1), i(!1), p(0), ae;
4511
+ return d(te), c(te.duration), _.current = !1, E.current = !1, s(!1), i(!1), p(0), te;
4512
4512
  } catch (Z) {
4513
4513
  return console.error("Failed to stop recording:", Z), y(Z instanceof Error ? Z : new Error("Failed to stop recording")), null;
4514
4514
  }
4515
- }, [a, n]), O = D(() => {
4516
- a && !o && (B.current !== null && (cancelAnimationFrame(B.current), B.current = null), T.current = !0, i(!0));
4517
- }, [a, o]), N = D(() => {
4515
+ }, [a, n]), K = D(() => {
4516
+ a && !o && (A.current !== null && (cancelAnimationFrame(A.current), A.current = null), E.current = !0, i(!0));
4517
+ }, [a, o]), X = D(() => {
4518
4518
  if (a && o) {
4519
- T.current = !1, i(!1), M.current = performance.now() - l * 1e3;
4519
+ E.current = !1, i(!1), M.current = performance.now() - l * 1e3;
4520
4520
  const Z = () => {
4521
- if (_.current && !T.current) {
4522
- const J = (performance.now() - M.current) / 1e3;
4523
- c(J), B.current = requestAnimationFrame(Z);
4521
+ if (_.current && !E.current) {
4522
+ const Q = (performance.now() - M.current) / 1e3;
4523
+ c(Q), A.current = requestAnimationFrame(Z);
4524
4524
  }
4525
4525
  };
4526
4526
  Z();
4527
4527
  }
4528
4528
  }, [a, o, l]);
4529
- return j(() => () => {
4530
- if (C.current) {
4531
- if (C.current.port.postMessage({ command: "stop" }), A.current)
4529
+ return U(() => () => {
4530
+ if (v.current) {
4531
+ if (v.current.port.postMessage({ command: "stop" }), k.current)
4532
4532
  try {
4533
- A.current.disconnect(C.current);
4533
+ k.current.disconnect(v.current);
4534
4534
  } catch {
4535
4535
  }
4536
- C.current.disconnect();
4536
+ v.current.disconnect();
4537
4537
  }
4538
- B.current !== null && cancelAnimationFrame(B.current);
4538
+ A.current !== null && cancelAnimationFrame(A.current);
4539
4539
  }, []), {
4540
4540
  isRecording: a,
4541
4541
  isPaused: o,
@@ -4544,15 +4544,15 @@ function Ms(e, t = {}) {
4544
4544
  audioBuffer: h,
4545
4545
  level: m,
4546
4546
  peakLevel: x,
4547
- startRecording: P,
4548
- stopRecording: F,
4549
- pauseRecording: O,
4550
- resumeRecording: N,
4547
+ startRecording: z,
4548
+ stopRecording: P,
4549
+ pauseRecording: K,
4550
+ resumeRecording: X,
4551
4551
  error: b
4552
4552
  };
4553
4553
  }
4554
4554
  function Bs() {
4555
- const [e, t] = E(null), [n, r] = E([]), [a, s] = E(!1), [o, i] = E(!1), [l, c] = E(null), u = D(async () => {
4555
+ const [e, t] = R(null), [n, r] = R([]), [a, s] = R(!1), [o, i] = R(!1), [l, c] = R(null), u = D(async () => {
4556
4556
  try {
4557
4557
  const b = (await navigator.mediaDevices.enumerateDevices()).filter((y) => y.kind === "audioinput").map((y) => ({
4558
4558
  deviceId: y.deviceId,
@@ -4593,7 +4593,7 @@ function Bs() {
4593
4593
  }, [e, u]), h = D(() => {
4594
4594
  e && (e.getTracks().forEach((d) => d.stop()), t(null), s(!1));
4595
4595
  }, [e]);
4596
- return j(() => (u(), () => {
4596
+ return U(() => (u(), () => {
4597
4597
  e && e.getTracks().forEach((d) => d.stop());
4598
4598
  }), []), {
4599
4599
  stream: e,
@@ -4609,8 +4609,8 @@ function Ds(e, t = {}) {
4609
4609
  const {
4610
4610
  updateRate: n = 60,
4611
4611
  smoothingTimeConstant: r = 0.8
4612
- } = t, [a, s] = E(0), [o, i] = E(0), l = R(null), c = R(null), u = R(null), g = () => i(0);
4613
- return j(() => {
4612
+ } = t, [a, s] = R(0), [o, i] = R(0), l = T(null), c = T(null), u = T(null), g = () => i(0);
4613
+ return U(() => {
4614
4614
  if (!e) {
4615
4615
  s(0), i(0);
4616
4616
  return;
@@ -4618,7 +4618,7 @@ function Ds(e, t = {}) {
4618
4618
  let h = !0;
4619
4619
  return (async () => {
4620
4620
  if (!h) return;
4621
- const b = ke();
4621
+ const b = Ae();
4622
4622
  if (b.state === "suspended" && await b.resume(), !h) return;
4623
4623
  const y = new Pr({ smoothing: r, context: b });
4624
4624
  l.current = y;
@@ -4626,17 +4626,17 @@ function Ds(e, t = {}) {
4626
4626
  c.current = m, zr(m, y);
4627
4627
  const p = 1e3 / n;
4628
4628
  let x = 0;
4629
- const v = (f) => {
4629
+ const w = (f) => {
4630
4630
  if (!(!h || !l.current)) {
4631
4631
  if (f - x >= p) {
4632
4632
  x = f;
4633
- const w = l.current.getValue(), C = typeof w == "number" ? w : w[0], A = Math.max(0, Math.min(1, (C + 100) / 100));
4634
- s(A), i(($) => Math.max($, A));
4633
+ const C = l.current.getValue(), v = typeof C == "number" ? C : C[0], k = Math.max(0, Math.min(1, (v + 100) / 100));
4634
+ s(k), i((B) => Math.max(B, k));
4635
4635
  }
4636
- u.current = requestAnimationFrame(v);
4636
+ u.current = requestAnimationFrame(w);
4637
4637
  }
4638
4638
  };
4639
- u.current = requestAnimationFrame(v);
4639
+ u.current = requestAnimationFrame(w);
4640
4640
  })(), () => {
4641
4641
  if (h = !1, u.current && (cancelAnimationFrame(u.current), u.current = null), c.current) {
4642
4642
  try {
@@ -4808,18 +4808,18 @@ var Ts = S.div`
4808
4808
  className: a
4809
4809
  }) => {
4810
4810
  const s = Math.max(0, Math.min(1, e)), o = t !== void 0 ? Math.max(0, Math.min(1, t)) : 0;
4811
- return /* @__PURE__ */ te(Ts, { $width: n, $height: r, className: a, children: [
4811
+ return /* @__PURE__ */ ne(Ts, { $width: n, $height: r, className: a, children: [
4812
4812
  /* @__PURE__ */ I(Es, { $level: s, $height: r }),
4813
4813
  t !== void 0 && o > 0 && /* @__PURE__ */ I(Ws, { $peakLevel: o, $height: r }),
4814
- /* @__PURE__ */ te(_s, { $height: r, children: [
4814
+ /* @__PURE__ */ ne(_s, { $height: r, children: [
4815
4815
  /* @__PURE__ */ I(In, { $position: 60, $height: r }),
4816
4816
  /* @__PURE__ */ I(In, { $position: 85, $height: r })
4817
4817
  ] })
4818
4818
  ] });
4819
4819
  };
4820
- _e.memo(Fs);
4820
+ Fe.memo(Fs);
4821
4821
  function $i(e, t, n, r = {}) {
4822
- const { currentTime: a = 0, audioConstraints: s, ...o } = r, [i, l] = E(!1), [c, u] = E(null), {
4822
+ const { currentTime: a = 0, audioConstraints: s, ...o } = r, [i, l] = R(!1), [c, u] = R(null), {
4823
4823
  stream: g,
4824
4824
  devices: h,
4825
4825
  hasPermission: d,
@@ -4827,62 +4827,62 @@ function $i(e, t, n, r = {}) {
4827
4827
  error: y
4828
4828
  } = Bs(), { level: m, peakLevel: p } = Ds(g), {
4829
4829
  isRecording: x,
4830
- isPaused: v,
4830
+ isPaused: w,
4831
4831
  duration: f,
4832
- peaks: w,
4833
- startRecording: C,
4834
- stopRecording: A,
4835
- pauseRecording: $,
4836
- resumeRecording: k,
4837
- error: B
4832
+ peaks: C,
4833
+ startRecording: v,
4834
+ stopRecording: k,
4835
+ pauseRecording: B,
4836
+ resumeRecording: $,
4837
+ error: A
4838
4838
  } = Ms(g, o), M = D(async () => {
4839
- n && (i || (await Ht(), l(!0)), await C());
4840
- }, [n, i, C]), _ = D(async () => {
4841
- const P = await A();
4842
- if (P && n) {
4843
- const F = e.findIndex((ee) => ee.id === n);
4844
- if (F === -1) return;
4845
- const O = e[F], N = Math.floor(a * P.sampleRate);
4839
+ n && (i || (await Ht(), l(!0)), await v());
4840
+ }, [n, i, v]), _ = D(async () => {
4841
+ const z = await k();
4842
+ if (z && n) {
4843
+ const P = e.findIndex((re) => re.id === n);
4844
+ if (P === -1) return;
4845
+ const K = e[P], X = Math.floor(a * z.sampleRate);
4846
4846
  let Z = 0;
4847
- if (O.clips.length > 0) {
4848
- const ee = O.clips.map(
4849
- (oe) => oe.startSample + oe.durationSamples
4847
+ if (K.clips.length > 0) {
4848
+ const re = K.clips.map(
4849
+ (ae) => ae.startSample + ae.durationSamples
4850
4850
  );
4851
- Z = Math.max(...ee);
4851
+ Z = Math.max(...re);
4852
4852
  }
4853
- const J = Math.max(N, Z), se = {
4853
+ const Q = Math.max(X, Z), le = {
4854
4854
  id: `clip-${Date.now()}`,
4855
- audioBuffer: P,
4856
- startSample: J,
4857
- durationSamples: P.length,
4855
+ audioBuffer: z,
4856
+ startSample: Q,
4857
+ durationSamples: z.length,
4858
4858
  offsetSamples: 0,
4859
- sampleRate: P.sampleRate,
4860
- sourceDurationSamples: P.length,
4859
+ sampleRate: z.sampleRate,
4860
+ sourceDurationSamples: z.length,
4861
4861
  gain: 1,
4862
4862
  name: `Recording ${(/* @__PURE__ */ new Date()).toLocaleTimeString()}`
4863
- }, ae = e.map((ee, oe) => oe === F ? {
4864
- ...ee,
4865
- clips: [...ee.clips, se]
4866
- } : ee);
4867
- t(ae);
4863
+ }, te = e.map((re, ae) => ae === P ? {
4864
+ ...re,
4865
+ clips: [...re.clips, le]
4866
+ } : re);
4867
+ t(te);
4868
4868
  }
4869
- }, [n, e, t, a, A]);
4870
- j(() => {
4869
+ }, [n, e, t, a, k]);
4870
+ U(() => {
4871
4871
  d && h.length > 0 && c === null && u(h[0].deviceId);
4872
4872
  }, [d, h.length]);
4873
- const T = D(async () => {
4873
+ const E = D(async () => {
4874
4874
  await b(void 0, s), await Ht(), l(!0);
4875
- }, [b, s]), H = D(async (P) => {
4876
- u(P), await b(P, s), await Ht(), l(!0);
4875
+ }, [b, s]), V = D(async (z) => {
4876
+ u(z), await b(z, s), await Ht(), l(!0);
4877
4877
  }, [b, s]);
4878
4878
  return {
4879
4879
  // Recording state
4880
4880
  isRecording: x,
4881
- isPaused: v,
4881
+ isPaused: w,
4882
4882
  duration: f,
4883
4883
  level: m,
4884
4884
  peakLevel: p,
4885
- error: y || B,
4885
+ error: y || A,
4886
4886
  // Microphone state
4887
4887
  stream: g,
4888
4888
  devices: h,
@@ -4891,12 +4891,12 @@ function $i(e, t, n, r = {}) {
4891
4891
  // Recording controls
4892
4892
  startRecording: M,
4893
4893
  stopRecording: _,
4894
- pauseRecording: $,
4895
- resumeRecording: k,
4896
- requestMicAccess: T,
4897
- changeDevice: H,
4894
+ pauseRecording: B,
4895
+ resumeRecording: $,
4896
+ requestMicAccess: E,
4897
+ changeDevice: V,
4898
4898
  // Track state
4899
- recordingPeaks: w
4899
+ recordingPeaks: C
4900
4900
  };
4901
4901
  }
4902
4902
  const _t = [
@@ -5213,28 +5213,28 @@ function Di(e) {
5213
5213
  };
5214
5214
  }
5215
5215
  function Ti(e = 256) {
5216
- const [t, n] = E([]), r = R(t);
5216
+ const [t, n] = R([]), r = T(t);
5217
5217
  r.current = t;
5218
- const a = R(/* @__PURE__ */ new Map()), s = R(null), o = R(null), i = D((m) => {
5218
+ const a = T(/* @__PURE__ */ new Map()), s = T(null), o = T(null), i = D((m) => {
5219
5219
  const p = o.current;
5220
5220
  if (!p) return;
5221
- const { masterGainNode: x, destination: v, analyserNode: f } = p;
5221
+ const { masterGainNode: x, destination: w, analyserNode: f } = p;
5222
5222
  try {
5223
5223
  x.disconnect();
5224
5224
  } catch {
5225
5225
  }
5226
- const w = m.map((C) => a.current.get(C.instanceId)).filter((C) => C !== void 0);
5227
- if (w.length === 0)
5228
- x.connect(f), f.connect(v);
5226
+ const C = m.map((v) => a.current.get(v.instanceId)).filter((v) => v !== void 0);
5227
+ if (C.length === 0)
5228
+ x.connect(f), f.connect(w);
5229
5229
  else {
5230
- let C = x;
5231
- w.forEach((A) => {
5230
+ let v = x;
5231
+ C.forEach((k) => {
5232
5232
  try {
5233
- A.disconnect();
5233
+ k.disconnect();
5234
5234
  } catch {
5235
5235
  }
5236
- C.connect(A.effect), C = A.effect;
5237
- }), C.connect(f), f.connect(v);
5236
+ v.connect(k.effect), v = k.effect;
5237
+ }), v.connect(f), f.connect(w);
5238
5238
  }
5239
5239
  }, []), l = D((m) => {
5240
5240
  const p = ir(m);
@@ -5243,28 +5243,28 @@ function Ti(e = 256) {
5243
5243
  return;
5244
5244
  }
5245
5245
  const x = {};
5246
- p.parameters.forEach((w) => {
5247
- x[w.name] = w.default;
5246
+ p.parameters.forEach((C) => {
5247
+ x[C.name] = C.default;
5248
5248
  });
5249
- const v = Bt(p, x);
5250
- a.current.set(v.instanceId, v);
5249
+ const w = Bt(p, x);
5250
+ a.current.set(w.instanceId, w);
5251
5251
  const f = {
5252
- instanceId: v.instanceId,
5252
+ instanceId: w.instanceId,
5253
5253
  effectId: p.id,
5254
5254
  definition: p,
5255
5255
  params: x,
5256
5256
  bypassed: !1
5257
5257
  };
5258
- n((w) => [...w, f]);
5258
+ n((C) => [...C, f]);
5259
5259
  }, []), c = D((m) => {
5260
5260
  const p = a.current.get(m);
5261
- p && (p.dispose(), a.current.delete(m)), n((x) => x.filter((v) => v.instanceId !== m));
5261
+ p && (p.dispose(), a.current.delete(m)), n((x) => x.filter((w) => w.instanceId !== m));
5262
5262
  }, []), u = D(
5263
5263
  (m, p, x) => {
5264
- const v = a.current.get(m);
5265
- v && v.setParameter(p, x), n(
5264
+ const w = a.current.get(m);
5265
+ w && w.setParameter(p, x), n(
5266
5266
  (f) => f.map(
5267
- (w) => w.instanceId === m ? { ...w, params: { ...w.params, [p]: x } } : w
5267
+ (C) => C.instanceId === m ? { ...C, params: { ...C.params, [p]: x } } : C
5268
5268
  )
5269
5269
  );
5270
5270
  },
@@ -5273,75 +5273,75 @@ function Ti(e = 256) {
5273
5273
  (m) => {
5274
5274
  const p = r.current.find((f) => f.instanceId === m);
5275
5275
  if (!p) return;
5276
- const x = !p.bypassed, v = a.current.get(m);
5277
- if (v) {
5276
+ const x = !p.bypassed, w = a.current.get(m);
5277
+ if (w) {
5278
5278
  const f = p.params.wet ?? 1;
5279
- v.setParameter("wet", x ? 0 : f);
5279
+ w.setParameter("wet", x ? 0 : f);
5280
5280
  }
5281
5281
  n(
5282
5282
  (f) => f.map(
5283
- (w) => w.instanceId === m ? { ...w, bypassed: x } : w
5283
+ (C) => C.instanceId === m ? { ...C, bypassed: x } : C
5284
5284
  )
5285
5285
  );
5286
5286
  },
5287
5287
  []
5288
5288
  ), h = D((m, p) => {
5289
5289
  n((x) => {
5290
- const v = [...x], [f] = v.splice(m, 1);
5291
- return v.splice(p, 0, f), v;
5290
+ const w = [...x], [f] = w.splice(m, 1);
5291
+ return w.splice(p, 0, f), w;
5292
5292
  });
5293
5293
  }, []), d = D(() => {
5294
5294
  a.current.forEach((m) => m.dispose()), a.current.clear(), n([]);
5295
5295
  }, []);
5296
- j(() => {
5296
+ U(() => {
5297
5297
  i(t);
5298
5298
  }, [t, i]);
5299
5299
  const b = D(
5300
5300
  (m, p, x) => {
5301
- const v = new Dn("fft", e);
5302
- s.current = v, o.current = {
5301
+ const w = new Dn("fft", e);
5302
+ s.current = w, o.current = {
5303
5303
  masterGainNode: m,
5304
5304
  destination: p,
5305
- analyserNode: v
5305
+ analyserNode: w
5306
5306
  };
5307
- const w = r.current.map((C) => a.current.get(C.instanceId)).filter((C) => C !== void 0);
5308
- if (w.length === 0)
5309
- m.connect(v), v.connect(p);
5307
+ const C = r.current.map((v) => a.current.get(v.instanceId)).filter((v) => v !== void 0);
5308
+ if (C.length === 0)
5309
+ m.connect(w), w.connect(p);
5310
5310
  else {
5311
- let C = m;
5312
- w.forEach((A) => {
5313
- C.connect(A.effect), C = A.effect;
5314
- }), C.connect(v), v.connect(p);
5311
+ let v = m;
5312
+ C.forEach((k) => {
5313
+ v.connect(k.effect), v = k.effect;
5314
+ }), v.connect(w), w.connect(p);
5315
5315
  }
5316
5316
  return function() {
5317
- v.dispose(), s.current = null, o.current = null;
5317
+ w.dispose(), s.current = null, o.current = null;
5318
5318
  };
5319
5319
  },
5320
5320
  [e]
5321
5321
  // Only fftSize - reads effects from ref
5322
5322
  );
5323
- j(() => () => {
5323
+ U(() => () => {
5324
5324
  a.current.forEach((m) => m.dispose()), a.current.clear();
5325
5325
  }, []);
5326
5326
  const y = D(() => {
5327
5327
  const m = t.filter((p) => !p.bypassed);
5328
5328
  if (m.length !== 0)
5329
- return (p, x, v) => {
5329
+ return (p, x, w) => {
5330
5330
  const f = [];
5331
- for (const w of m) {
5332
- const C = Bt(w.definition, w.params);
5333
- f.push(C);
5331
+ for (const C of m) {
5332
+ const v = Bt(C.definition, C.params);
5333
+ f.push(v);
5334
5334
  }
5335
5335
  if (f.length === 0)
5336
5336
  p.connect(x);
5337
5337
  else {
5338
- let w = p;
5339
- f.forEach((C) => {
5340
- w.connect(C.effect), w = C.effect;
5341
- }), w.connect(x);
5338
+ let C = p;
5339
+ f.forEach((v) => {
5340
+ C.connect(v.effect), C = v.effect;
5341
+ }), C.connect(x);
5342
5342
  }
5343
5343
  return function() {
5344
- f.forEach((C) => C.dispose());
5344
+ f.forEach((v) => v.dispose());
5345
5345
  };
5346
5346
  };
5347
5347
  }, [t]);
@@ -5360,9 +5360,9 @@ function Ti(e = 256) {
5360
5360
  };
5361
5361
  }
5362
5362
  function Ri() {
5363
- const [e, t] = E(
5363
+ const [e, t] = R(
5364
5364
  /* @__PURE__ */ new Map()
5365
- ), n = R(/* @__PURE__ */ new Map()), r = R(/* @__PURE__ */ new Map()), a = D((d, b) => {
5365
+ ), n = T(/* @__PURE__ */ new Map()), r = T(/* @__PURE__ */ new Map()), a = D((d, b) => {
5366
5366
  const y = r.current.get(d);
5367
5367
  if (!y) return;
5368
5368
  const { graphEnd: m, masterGainNode: p } = y, x = n.current.get(d);
@@ -5370,17 +5370,17 @@ function Ri() {
5370
5370
  m.disconnect();
5371
5371
  } catch {
5372
5372
  }
5373
- const v = b.map((f) => x?.get(f.instanceId)).filter((f) => f !== void 0);
5374
- if (v.length === 0)
5373
+ const w = b.map((f) => x?.get(f.instanceId)).filter((f) => f !== void 0);
5374
+ if (w.length === 0)
5375
5375
  m.connect(p);
5376
5376
  else {
5377
5377
  let f = m;
5378
- v.forEach((w) => {
5378
+ w.forEach((C) => {
5379
5379
  try {
5380
- w.disconnect();
5380
+ C.disconnect();
5381
5381
  } catch {
5382
5382
  }
5383
- f.connect(w.effect), f = w.effect;
5383
+ f.connect(C.effect), f = C.effect;
5384
5384
  }), f.connect(p);
5385
5385
  }
5386
5386
  }, []), s = D((d, b) => {
@@ -5390,8 +5390,8 @@ function Ri() {
5390
5390
  return;
5391
5391
  }
5392
5392
  const m = {};
5393
- y.parameters.forEach((v) => {
5394
- m[v.name] = v.default;
5393
+ y.parameters.forEach((w) => {
5394
+ m[w.name] = w.default;
5395
5395
  });
5396
5396
  const p = Bt(y, m);
5397
5397
  n.current.has(d) || n.current.set(d, /* @__PURE__ */ new Map()), n.current.get(d).set(p.instanceId, p);
@@ -5402,25 +5402,25 @@ function Ri() {
5402
5402
  params: m,
5403
5403
  bypassed: !1
5404
5404
  };
5405
- t((v) => {
5406
- const f = new Map(v), w = f.get(d) || [];
5407
- return f.set(d, [...w, x]), f;
5405
+ t((w) => {
5406
+ const f = new Map(w), C = f.get(d) || [];
5407
+ return f.set(d, [...C, x]), f;
5408
5408
  });
5409
5409
  }, []), o = D((d, b) => {
5410
5410
  const y = n.current.get(d), m = y?.get(b);
5411
5411
  m && (m.dispose(), y?.delete(b)), t((p) => {
5412
- const x = new Map(p), v = x.get(d) || [];
5413
- return x.set(d, v.filter((f) => f.instanceId !== b)), x;
5412
+ const x = new Map(p), w = x.get(d) || [];
5413
+ return x.set(d, w.filter((f) => f.instanceId !== b)), x;
5414
5414
  });
5415
5415
  }, []), i = D(
5416
5416
  (d, b, y, m) => {
5417
5417
  const x = n.current.get(d)?.get(b);
5418
- x && x.setParameter(y, m), t((v) => {
5419
- const f = new Map(v), w = f.get(d) || [];
5418
+ x && x.setParameter(y, m), t((w) => {
5419
+ const f = new Map(w), C = f.get(d) || [];
5420
5420
  return f.set(
5421
5421
  d,
5422
- w.map(
5423
- (C) => C.instanceId === b ? { ...C, params: { ...C.params, [y]: m } } : C
5422
+ C.map(
5423
+ (v) => v.instanceId === b ? { ...v, params: { ...v.params, [y]: m } } : v
5424
5424
  )
5425
5425
  ), f;
5426
5426
  });
@@ -5430,19 +5430,19 @@ function Ri() {
5430
5430
  (d, b) => {
5431
5431
  const m = (u.current.get(d) || []).find((f) => f.instanceId === b);
5432
5432
  if (!m) return;
5433
- const p = !m.bypassed, v = n.current.get(d)?.get(b);
5434
- if (v) {
5433
+ const p = !m.bypassed, w = n.current.get(d)?.get(b);
5434
+ if (w) {
5435
5435
  const f = m.params.wet ?? 1;
5436
- v.setParameter("wet", p ? 0 : f);
5436
+ w.setParameter("wet", p ? 0 : f);
5437
5437
  }
5438
5438
  t((f) => {
5439
- const w = new Map(f), C = w.get(d) || [];
5440
- return w.set(
5439
+ const C = new Map(f), v = C.get(d) || [];
5440
+ return C.set(
5441
5441
  d,
5442
- C.map(
5443
- (A) => A.instanceId === b ? { ...A, bypassed: p } : A
5442
+ v.map(
5443
+ (k) => k.instanceId === b ? { ...k, bypassed: p } : k
5444
5444
  )
5445
- ), w;
5445
+ ), C;
5446
5446
  });
5447
5447
  },
5448
5448
  []
@@ -5452,7 +5452,7 @@ function Ri() {
5452
5452
  const m = new Map(y);
5453
5453
  return m.set(d, []), m;
5454
5454
  });
5455
- }, []), u = R(e);
5455
+ }, []), u = T(e);
5456
5456
  u.current = e;
5457
5457
  const g = D(
5458
5458
  (d) => (b, y, m) => {
@@ -5460,13 +5460,13 @@ function Ri() {
5460
5460
  graphEnd: b,
5461
5461
  masterGainNode: y
5462
5462
  });
5463
- const p = u.current.get(d) || [], x = n.current.get(d), v = p.map((f) => x?.get(f.instanceId)).filter((f) => f !== void 0);
5464
- if (v.length === 0)
5463
+ const p = u.current.get(d) || [], x = n.current.get(d), w = p.map((f) => x?.get(f.instanceId)).filter((f) => f !== void 0);
5464
+ if (w.length === 0)
5465
5465
  b.connect(y);
5466
5466
  else {
5467
5467
  let f = b;
5468
- v.forEach((w) => {
5469
- f.connect(w.effect), f = w.effect;
5468
+ w.forEach((C) => {
5469
+ f.connect(C.effect), f = C.effect;
5470
5470
  }), f.connect(y);
5471
5471
  }
5472
5472
  return function() {
@@ -5476,11 +5476,11 @@ function Ri() {
5476
5476
  []
5477
5477
  // No dependencies - stable function that reads from refs
5478
5478
  );
5479
- j(() => {
5479
+ U(() => {
5480
5480
  e.forEach((d, b) => {
5481
5481
  a(b, d);
5482
5482
  });
5483
- }, [e, a]), j(() => () => {
5483
+ }, [e, a]), U(() => () => {
5484
5484
  n.current.forEach((d) => {
5485
5485
  d.forEach((b) => b.dispose()), d.clear();
5486
5486
  }), n.current.clear();
@@ -5490,21 +5490,21 @@ function Ri() {
5490
5490
  const y = (e.get(d) || []).filter((m) => !m.bypassed);
5491
5491
  if (y.length !== 0)
5492
5492
  return (m, p, x) => {
5493
- const v = [];
5493
+ const w = [];
5494
5494
  for (const f of y) {
5495
- const w = Bt(f.definition, f.params);
5496
- v.push(w);
5495
+ const C = Bt(f.definition, f.params);
5496
+ w.push(C);
5497
5497
  }
5498
- if (v.length === 0)
5498
+ if (w.length === 0)
5499
5499
  m.connect(p);
5500
5500
  else {
5501
5501
  let f = m;
5502
- v.forEach((w) => {
5503
- f.connect(w.effect), f = w.effect;
5502
+ w.forEach((C) => {
5503
+ f.connect(C.effect), f = C.effect;
5504
5504
  }), f.connect(p);
5505
5505
  }
5506
5506
  return function() {
5507
- v.forEach((w) => w.dispose());
5507
+ w.forEach((C) => C.dispose());
5508
5508
  };
5509
5509
  };
5510
5510
  },
@@ -5532,7 +5532,7 @@ function zs(e, t = {}) {
5532
5532
  if (n === 16)
5533
5533
  for (let m = 0; m < s; m++)
5534
5534
  for (let p = 0; p < r; p++) {
5535
- const x = b[p][m], v = Math.max(-1, Math.min(1, x)), f = v < 0 ? v * 32768 : v * 32767;
5535
+ const x = b[p][m], w = Math.max(-1, Math.min(1, x)), f = w < 0 ? w * 32768 : w * 32767;
5536
5536
  d.setInt16(y, f, !0), y += 2;
5537
5537
  }
5538
5538
  else
@@ -5550,7 +5550,7 @@ function Hs(e, t) {
5550
5550
  r.href = n, r.download = t, r.style.display = "none", document.body.appendChild(r), r.click(), document.body.removeChild(r), URL.revokeObjectURL(n);
5551
5551
  }
5552
5552
  function Xs() {
5553
- const [e, t] = E(!1), [n, r] = E(0), [a, s] = E(null);
5553
+ const [e, t] = R(!1), [n, r] = R(0), [a, s] = R(null);
5554
5554
  return {
5555
5555
  exportWav: D(async (i, l, c = {}) => {
5556
5556
  const {
@@ -5570,23 +5570,23 @@ function Xs() {
5570
5570
  throw new Error("No tracks to export");
5571
5571
  if (g === "individual" && (h === void 0 || h < 0 || h >= i.length))
5572
5572
  throw new Error("Invalid track index for individual export");
5573
- const v = i[0].clips[0]?.sampleRate || 44100;
5573
+ const w = i[0].clips[0]?.sampleRate || 44100;
5574
5574
  let f = 0;
5575
5575
  for (const M of i)
5576
5576
  for (const _ of M.clips) {
5577
- const T = _.startSample + _.durationSamples;
5578
- f = Math.max(f, T);
5577
+ const E = _.startSample + _.durationSamples;
5578
+ f = Math.max(f, E);
5579
5579
  }
5580
- f += Math.round(v * 0.1);
5581
- const w = f / v, C = g === "individual" ? [{ track: i[h], state: l[h], index: h }] : i.map((M, _) => ({ track: M, state: l[_], index: _ })), A = l.some((M) => M.soloed), $ = !!m;
5582
- let k;
5583
- if ((y || $) && b)
5584
- k = await Gs(
5585
- C,
5580
+ f += Math.round(w * 0.1);
5581
+ const C = f / w, v = g === "individual" ? [{ track: i[h], state: l[h], index: h }] : i.map((M, _) => ({ track: M, state: l[_], index: _ })), k = l.some((M) => M.soloed), B = !!m;
5582
+ let $;
5583
+ if ((y || B) && b)
5584
+ $ = await Gs(
5585
+ v,
5586
5586
  l,
5587
- A,
5587
+ k,
5588
+ C,
5588
5589
  w,
5589
- v,
5590
5590
  y,
5591
5591
  m,
5592
5592
  (M) => {
@@ -5594,32 +5594,32 @@ function Xs() {
5594
5594
  }
5595
5595
  );
5596
5596
  else {
5597
- const M = new OfflineAudioContext(2, f, v);
5597
+ const M = new OfflineAudioContext(2, f, w);
5598
5598
  let _ = 0;
5599
- const T = C.reduce((H, { track: P }) => H + P.clips.length, 0);
5600
- for (const { track: H, state: P } of C)
5601
- if (!(P.muted && !P.soloed) && !(A && !P.soloed))
5602
- for (const F of H.clips) {
5603
- await Ls(M, F, P, v, b), _++;
5604
- const O = _ / T * 0.5;
5605
- r(O), x?.(O);
5599
+ const E = v.reduce((V, { track: z }) => V + z.clips.length, 0);
5600
+ for (const { track: V, state: z } of v)
5601
+ if (!(z.muted && !z.soloed) && !(k && !z.soloed))
5602
+ for (const P of V.clips) {
5603
+ await Ls(M, P, z, w, b), _++;
5604
+ const K = _ / E * 0.5;
5605
+ r(K), x?.(K);
5606
5606
  }
5607
- r(0.5), x?.(0.5), k = await M.startRendering();
5607
+ r(0.5), x?.(0.5), $ = await M.startRendering();
5608
5608
  }
5609
5609
  r(0.9), x?.(0.9);
5610
- const B = zs(k, { bitDepth: p });
5610
+ const A = zs($, { bitDepth: p });
5611
5611
  if (r(1), x?.(1), d) {
5612
5612
  const M = g === "individual" ? `${u}_${i[h].name}` : u;
5613
- Hs(B, `${M}.wav`);
5613
+ Hs(A, `${M}.wav`);
5614
5614
  }
5615
5615
  return {
5616
- audioBuffer: k,
5617
- blob: B,
5618
- duration: w
5616
+ audioBuffer: $,
5617
+ blob: A,
5618
+ duration: C
5619
5619
  };
5620
- } catch (v) {
5621
- const f = v instanceof Error ? v.message : "Export failed";
5622
- throw s(f), v;
5620
+ } catch (w) {
5621
+ const f = w instanceof Error ? w.message : "Export failed";
5622
+ throw s(f), w;
5623
5623
  } finally {
5624
5624
  t(!1);
5625
5625
  }
@@ -5639,21 +5639,21 @@ async function Gs(e, t, n, r, a, s, o, i) {
5639
5639
  const p = new c(0);
5640
5640
  let x;
5641
5641
  s ? x = s(p, m, !0) : p.connect(m);
5642
- for (const { track: v, state: f } of e) {
5642
+ for (const { track: w, state: f } of e) {
5643
5643
  if (f.muted && !f.soloed || n && !f.soloed) continue;
5644
- const w = new c(Ns(f.volume)), C = new g(f.pan), A = new u(f.muted ? 0 : 1), $ = o?.(v.id);
5645
- $ ? $(A, p, !0) : A.connect(p), C.connect(A), w.connect(C);
5646
- for (const k of v.clips) {
5647
- const { audioBuffer: B, startSample: M, durationSamples: _, offsetSamples: T, gain: H, fadeIn: P, fadeOut: F } = k, O = M / a, N = _ / a, Z = T / a, J = new d(B), se = new h(J), ae = new u(H);
5648
- if (se.connect(ae), ae.connect(w), P) {
5649
- const ee = O, oe = O + P.duration, ye = ae.gain._param;
5650
- ye.setValueAtTime(0, ee), ye.linearRampToValueAtTime(H, oe);
5644
+ const C = new c(Ns(f.volume)), v = new g(f.pan), k = new u(f.muted ? 0 : 1), B = o?.(w.id);
5645
+ B ? B(k, p, !0) : k.connect(p), v.connect(k), C.connect(v);
5646
+ for (const $ of w.clips) {
5647
+ const { audioBuffer: A, startSample: M, durationSamples: _, offsetSamples: E, gain: V, fadeIn: z, fadeOut: P } = $, K = M / a, X = _ / a, Z = E / a, Q = new d(A), le = new h(Q), te = new u(V);
5648
+ if (le.connect(te), te.connect(C), z) {
5649
+ const re = K, ae = K + z.duration, ye = te.gain._param;
5650
+ ye.setValueAtTime(0, re), ye.linearRampToValueAtTime(V, ae);
5651
5651
  }
5652
- if (F) {
5653
- const ee = O + N - F.duration, oe = O + N, ye = ae.gain._param;
5654
- ye.setValueAtTime(H, ee), ye.linearRampToValueAtTime(0, oe);
5652
+ if (P) {
5653
+ const re = K + X - P.duration, ae = K + X, ye = te.gain._param;
5654
+ ye.setValueAtTime(V, re), ye.linearRampToValueAtTime(0, ae);
5655
5655
  }
5656
- se.start(O, Z, N);
5656
+ le.start(K, Z, X);
5657
5657
  }
5658
5658
  }
5659
5659
  y.start(0);
@@ -5682,12 +5682,12 @@ async function Ls(e, t, n, r, a) {
5682
5682
  const m = e.createGain(), p = c * n.volume, x = e.createStereoPanner();
5683
5683
  if (x.pan.value = n.pan, y.connect(m), m.connect(x), x.connect(e.destination), a) {
5684
5684
  if (u ? m.gain.setValueAtTime(0, h) : m.gain.setValueAtTime(p, h), u) {
5685
- const v = h, f = h + u.duration;
5686
- An(m.gain, v, f, 0, p, u.type || "linear");
5685
+ const w = h, f = h + u.duration;
5686
+ An(m.gain, w, f, 0, p, u.type || "linear");
5687
5687
  }
5688
5688
  if (g) {
5689
- const v = h + d - g.duration, f = h + d;
5690
- (!u || u.duration < d - g.duration) && m.gain.setValueAtTime(p, v), An(m.gain, v, f, p, 0, g.type || "linear");
5689
+ const w = h + d - g.duration, f = h + d;
5690
+ (!u || u.duration < d - g.duration) && m.gain.setValueAtTime(p, w), An(m.gain, w, f, p, 0, g.type || "linear");
5691
5691
  }
5692
5692
  } else
5693
5693
  m.gain.setValueAtTime(p, h);
@@ -5725,7 +5725,7 @@ function kn(e, t, n, r) {
5725
5725
  }
5726
5726
  return a;
5727
5727
  }
5728
- const lr = Be(null), cr = Be(null), ur = Be(null), dr = Be(null), mr = Be(null), Ei = ({
5728
+ const lr = Me(null), cr = Me(null), ur = Me(null), dr = Me(null), mr = Me(null), Ei = ({
5729
5729
  tracks: e,
5730
5730
  timescale: t = !1,
5731
5731
  mono: n = !1,
@@ -5744,70 +5744,70 @@ const lr = Be(null), cr = Be(null), ur = Be(null), dr = Be(null), mr = Be(null),
5744
5744
  progressBarWidth: y,
5745
5745
  children: m
5746
5746
  }) => {
5747
- const p = y ?? d + b, [x, v] = E([]), [f, w] = E(null), [C, A] = E(!1), [$, k] = E(0), [B, M] = E(0), [_, T] = E([]), [H, P] = E([]), [F, O] = E([]), [N, Z] = E(0), [J, se] = E(0), [ae, ee] = E(null), [oe, ye] = E(o), [be, Ue] = E(c?.isContinuousPlay ?? !1), [Oe, Se] = E(c?.linkEndpoints ?? !0), [je, K] = E(c?.editable ?? !1), [de, ne] = E(!1), [q, me] = E(0), [Ce, re] = E(0), [Ne, Ke] = E(!1), V = R(null), Pe = R(0), fe = R(0), X = R(null), ie = R(F), he = R(0), pe = R(0), Ie = R(null), Le = R(null), Je = R(!1), st = R(c?.isContinuousPlay ?? !1), et = R(null), mt = R(a), Ft = R(!1), L = R(0), Q = R(0), le = R(0), ve = R(0), { timeFormat: $e, setTimeFormat: ze, formatTime: ce } = bs(), Re = ws({ initialSamplesPerPixel: a, zoomLevels: s }), Me = Re.samplesPerPixel, { masterVolume: Qe, setMasterVolume: qe } = ys({ playoutRef: V, initialVolume: 1 }), it = D((W) => {
5748
- st.current = W, Ue(W);
5747
+ const p = y ?? d + b, [x, w] = R([]), [f, C] = R(null), [v, k] = R(!1), [B, $] = R(0), [A, M] = R(0), [_, E] = R([]), [V, z] = R([]), [P, K] = R([]), [X, Z] = R(0), [Q, le] = R(0), [te, re] = R(null), [ae, ye] = R(o), [be, Ke] = R(c?.isContinuousPlay ?? !1), [Oe, ke] = R(c?.linkEndpoints ?? !1), [Ue, De] = R(c?.editable ?? !1), [ee, j] = R(!1), [oe, de] = R(0), [me, J] = R(0), [Re, je] = R(!1), F = T(null), ze = T(0), fe = T(0), G = T(null), se = T(P), he = T(0), pe = T(0), xe = T(null), Le = T(null), Je = T(!1), st = T(c?.isContinuousPlay ?? !1), et = T(null), mt = T(a), Ft = T(!1), L = T(0), q = T(0), ie = T(0), ve = T(0), { timeFormat: Se, setTimeFormat: He, formatTime: ce } = bs(), Ee = ws({ initialSamplesPerPixel: a, zoomLevels: s }), $e = Ee.samplesPerPixel, { masterVolume: Qe, setMasterVolume: qe } = ys({ playoutRef: F, initialVolume: 1 }), it = D((W) => {
5748
+ st.current = W, Ke(W);
5749
5749
  }, []), Ye = D((W) => {
5750
- et.current = W, w(W);
5750
+ et.current = W, C(W);
5751
5751
  }, []), Zt = D((W) => {
5752
- Ft.current = W, ne(W);
5753
- }, []), ft = D((W, G) => {
5754
- le.current = W, ve.current = G, me(W), re(G);
5752
+ Ft.current = W, j(W);
5753
+ }, []), ft = D((W, N) => {
5754
+ ie.current = W, ve.current = N, de(W), J(N);
5755
5755
  }, []), br = D(() => {
5756
- const W = L.current, G = Q.current;
5757
- W !== G && G > W && ft(W, G);
5756
+ const W = L.current, N = q.current;
5757
+ W !== N && N > W && ft(W, N);
5758
5758
  }, [ft]), vr = D(() => {
5759
5759
  ft(0, 0);
5760
5760
  }, [ft]);
5761
- j(() => {
5762
- Je.current = oe;
5763
- }, [oe]), j(() => {
5764
- ie.current = F;
5765
- }, [F]), j(() => {
5766
- L.current = N, Q.current = J;
5767
- }, [N, J]), j(() => {
5761
+ U(() => {
5762
+ Je.current = ae;
5763
+ }, [ae]), U(() => {
5764
+ se.current = P;
5765
+ }, [P]), U(() => {
5766
+ L.current = X, q.current = Q;
5767
+ }, [X, Q]), U(() => {
5768
5768
  if (!Le.current || !_.length) return;
5769
- const W = Le.current, G = mt.current, U = Me;
5770
- if (G === U) return;
5771
- const ue = l.show ? l.width : 0, z = W.clientWidth, Xe = W.scrollLeft + z / 2 - ue, lt = _[0].sampleRate, xe = Xe * G / lt * lt / U, Ee = Math.max(0, xe + ue - z / 2);
5772
- W.scrollLeft = Ee, mt.current = U;
5773
- }, [Me, _, l]);
5774
- const yt = R(null);
5775
- j(() => {
5776
- if (Ke(!1), e.length === 0) {
5777
- T([]), M(0), O([]), P([]), V.current && (V.current.dispose(), V.current = null);
5769
+ const W = Le.current, N = mt.current, O = $e;
5770
+ if (N === O) return;
5771
+ const ue = l.show ? l.width : 0, H = W.clientWidth, Ge = W.scrollLeft + H / 2 - ue, lt = _[0].sampleRate, Ce = Ge * N / lt * lt / O, We = Math.max(0, Ce + ue - H / 2);
5772
+ W.scrollLeft = We, mt.current = O;
5773
+ }, [$e, _, l]);
5774
+ const yt = T(null);
5775
+ U(() => {
5776
+ if (je(!1), e.length === 0) {
5777
+ E([]), M(0), K([]), z([]), F.current && (F.current.dispose(), F.current = null);
5778
5778
  return;
5779
5779
  }
5780
- const W = C, G = fe.current;
5781
- return V.current && W && (V.current.stop(), X.current && (cancelAnimationFrame(X.current), X.current = null), yt.current = { position: G }), (async () => {
5780
+ const W = v, N = fe.current;
5781
+ return F.current && W && (F.current.stop(), G.current && (cancelAnimationFrame(G.current), G.current = null), yt.current = { position: N }), (async () => {
5782
5782
  try {
5783
5783
  const ue = [];
5784
5784
  e.forEach((we) => {
5785
5785
  we.clips.length > 0 && we.clips[0].audioBuffer && ue.push(we.clips[0].audioBuffer);
5786
5786
  });
5787
- let z = 0;
5787
+ let H = 0;
5788
5788
  e.forEach((we) => {
5789
- we.clips.forEach((xe) => {
5790
- const Ee = xe.sampleRate, Ct = (xe.startSample + xe.durationSamples) / Ee;
5791
- z = Math.max(z, Ct);
5789
+ we.clips.forEach((Ce) => {
5790
+ const We = Ce.sampleRate, Ct = (Ce.startSample + Ce.durationSamples) / We;
5791
+ H = Math.max(H, Ct);
5792
5792
  });
5793
- }), T(ue), M(z), O((we) => we.length === e.length ? we.map((xe, Ee) => ({
5794
- ...xe,
5795
- name: e[Ee].name
5796
- })) : e.map((xe) => ({
5797
- name: xe.name,
5798
- muted: xe.muted,
5799
- soloed: xe.soloed,
5800
- volume: xe.volume,
5801
- pan: xe.pan
5802
- }))), V.current && V.current.dispose();
5803
- const Ae = new Ca({
5793
+ }), E(ue), M(H), K((we) => we.length === e.length ? we.map((Ce, We) => ({
5794
+ ...Ce,
5795
+ name: e[We].name
5796
+ })) : e.map((Ce) => ({
5797
+ name: Ce.name,
5798
+ muted: Ce.muted,
5799
+ soloed: Ce.soloed,
5800
+ volume: Ce.volume,
5801
+ pan: Ce.pan
5802
+ }))), F.current && F.current.dispose();
5803
+ const Ie = new Ca({
5804
5804
  effects: u
5805
- }), Xe = ie.current;
5806
- e.forEach((we, xe) => {
5807
- const Ee = we.clips.filter((ht) => ht.audioBuffer);
5808
- if (Ee.length > 0) {
5809
- const ht = Ee[0].sampleRate, Ct = Math.min(...Ee.map((We) => We.startSample / ht)), Rr = Math.max(...Ee.map((We) => (We.startSample + We.durationSamples) / ht)), xt = Xe[xe], Er = {
5810
- id: `track-${xe}`,
5805
+ }), Ge = se.current;
5806
+ e.forEach((we, Ce) => {
5807
+ const We = we.clips.filter((ht) => ht.audioBuffer);
5808
+ if (We.length > 0) {
5809
+ const ht = We[0].sampleRate, Ct = Math.min(...We.map((_e) => _e.startSample / ht)), Rr = Math.max(...We.map((_e) => (_e.startSample + _e.durationSamples) / ht)), xt = Ge[Ce], Er = {
5810
+ id: `track-${Ce}`,
5811
5811
  // Use consistent index-based ID for track controls
5812
5812
  name: we.name,
5813
5813
  gain: xt?.volume ?? we.volume,
@@ -5816,32 +5816,32 @@ const lr = Be(null), cr = Be(null), ur = Be(null), dr = Be(null), mr = Be(null),
5816
5816
  stereoPan: xt?.pan ?? we.pan,
5817
5817
  startTime: Ct,
5818
5818
  endTime: Rr
5819
- }, Wr = Ee.map((We) => {
5820
- const Pt = We.sampleRate;
5819
+ }, Wr = We.map((_e) => {
5820
+ const Pt = _e.sampleRate;
5821
5821
  return {
5822
- buffer: We.audioBuffer,
5822
+ buffer: _e.audioBuffer,
5823
5823
  // We filtered for audioBuffer above
5824
- startTime: We.startSample / Pt - Ct,
5824
+ startTime: _e.startSample / Pt - Ct,
5825
5825
  // Make relative to track start
5826
- duration: We.durationSamples / Pt,
5827
- offset: We.offsetSamples / Pt,
5828
- fadeIn: We.fadeIn,
5829
- fadeOut: We.fadeOut,
5830
- gain: We.gain
5826
+ duration: _e.durationSamples / Pt,
5827
+ offset: _e.offsetSamples / Pt,
5828
+ fadeIn: _e.fadeIn,
5829
+ fadeOut: _e.fadeOut,
5830
+ gain: _e.gain
5831
5831
  };
5832
5832
  });
5833
- Ae.addTrack({
5833
+ Ie.addTrack({
5834
5834
  clips: Wr,
5835
5835
  track: Er,
5836
5836
  effects: we.effects
5837
5837
  // Pass track effects
5838
5838
  });
5839
5839
  }
5840
- }), Ae.applyInitialSoloState(), V.current = Ae, Ke(!0);
5840
+ }), Ie.applyInitialSoloState(), F.current = Ie, je(!0);
5841
5841
  const lt = new CustomEvent("waveform-playlist:ready", {
5842
5842
  detail: {
5843
5843
  trackCount: e.length,
5844
- duration: z
5844
+ duration: H
5845
5845
  }
5846
5846
  });
5847
5847
  window.dispatchEvent(lt), g?.();
@@ -5849,206 +5849,206 @@ const lr = Be(null), cr = Be(null), ur = Be(null), dr = Be(null), mr = Be(null),
5849
5849
  console.error("Error loading audio:", ue);
5850
5850
  }
5851
5851
  })(), () => {
5852
- X.current && cancelAnimationFrame(X.current), V.current && V.current.dispose();
5852
+ G.current && cancelAnimationFrame(G.current), F.current && F.current.dispose();
5853
5853
  };
5854
- }, [e, g, C]), j(() => {
5854
+ }, [e, g, v]), U(() => {
5855
5855
  if (e.length === 0) return;
5856
- const W = 16, G = e.map((U) => U.clips.map((z) => {
5857
- if (z.waveformData) {
5858
- const Xe = tr(
5859
- z.waveformData,
5856
+ const W = 16, N = e.map((O) => O.clips.map((H) => {
5857
+ if (H.waveformData) {
5858
+ const Ge = tr(
5859
+ H.waveformData,
5860
5860
  // Cast to WaveformData type
5861
- Me,
5861
+ $e,
5862
5862
  0,
5863
5863
  // channel index
5864
- z.offsetSamples,
5865
- z.durationSamples
5864
+ H.offsetSamples,
5865
+ H.durationSamples
5866
5866
  );
5867
5867
  return {
5868
- clipId: z.id,
5869
- trackName: U.name,
5868
+ clipId: H.id,
5869
+ trackName: O.name,
5870
5870
  peaks: {
5871
- length: Xe.length,
5872
- data: [Xe.data],
5871
+ length: Ge.length,
5872
+ data: [Ge.data],
5873
5873
  // Wrap in array for channel compatibility
5874
- bits: Xe.bits
5874
+ bits: Ge.bits
5875
5875
  },
5876
- startSample: z.startSample,
5877
- durationSamples: z.durationSamples,
5878
- fadeIn: z.fadeIn,
5879
- fadeOut: z.fadeOut
5876
+ startSample: H.startSample,
5877
+ durationSamples: H.durationSamples,
5878
+ fadeIn: H.fadeIn,
5879
+ fadeOut: H.fadeOut
5880
5880
  };
5881
5881
  }
5882
- if (!z.audioBuffer)
5883
- return console.warn(`Clip "${z.name || z.id}" has neither waveformData nor audioBuffer - rendering empty`), {
5884
- clipId: z.id,
5885
- trackName: U.name,
5882
+ if (!H.audioBuffer)
5883
+ return console.warn(`Clip "${H.name || H.id}" has neither waveformData nor audioBuffer - rendering empty`), {
5884
+ clipId: H.id,
5885
+ trackName: O.name,
5886
5886
  peaks: {
5887
5887
  length: 0,
5888
5888
  data: [],
5889
5889
  bits: W
5890
5890
  },
5891
- startSample: z.startSample,
5892
- durationSamples: z.durationSamples,
5893
- fadeIn: z.fadeIn,
5894
- fadeOut: z.fadeOut
5891
+ startSample: H.startSample,
5892
+ durationSamples: H.durationSamples,
5893
+ fadeIn: H.fadeIn,
5894
+ fadeOut: H.fadeOut
5895
5895
  };
5896
- const Ae = To(
5897
- z.audioBuffer,
5898
- Me,
5896
+ const Ie = To(
5897
+ H.audioBuffer,
5898
+ $e,
5899
5899
  n,
5900
5900
  W,
5901
- z.offsetSamples,
5902
- z.durationSamples
5901
+ H.offsetSamples,
5902
+ H.durationSamples
5903
5903
  );
5904
5904
  return {
5905
- clipId: z.id,
5906
- trackName: U.name,
5907
- peaks: Ae,
5908
- startSample: z.startSample,
5909
- durationSamples: z.durationSamples,
5910
- fadeIn: z.fadeIn,
5911
- fadeOut: z.fadeOut
5905
+ clipId: H.id,
5906
+ trackName: O.name,
5907
+ peaks: Ie,
5908
+ startSample: H.startSample,
5909
+ durationSamples: H.durationSamples,
5910
+ fadeIn: H.fadeIn,
5911
+ fadeOut: H.fadeOut
5912
5912
  };
5913
5913
  }));
5914
- P(G);
5915
- }, [e, Me, n]), j(() => {
5914
+ z(N);
5915
+ }, [e, $e, n]), U(() => {
5916
5916
  if (c?.annotations) {
5917
- const W = c.annotations.map((G) => typeof G.start == "number" ? G : nr(G));
5918
- v(W);
5917
+ const W = c.annotations.map((N) => typeof N.start == "number" ? N : nr(N));
5918
+ w(W);
5919
5919
  }
5920
5920
  }, [c]);
5921
5921
  const tt = D(() => {
5922
- X.current && (cancelAnimationFrame(X.current), X.current = null);
5922
+ G.current && (cancelAnimationFrame(G.current), G.current = null);
5923
5923
  const W = () => {
5924
- const G = ke().currentTime - he.current, U = pe.current + G;
5925
- if (fe.current = U, k(U), x.length > 0) {
5926
- const z = x.find(
5927
- (Ae) => U >= Ae.start && U < Ae.end
5924
+ const N = Ae().currentTime - he.current, O = pe.current + N;
5925
+ if (fe.current = O, $(O), x.length > 0) {
5926
+ const H = x.find(
5927
+ (Ie) => O >= Ie.start && O < Ie.end
5928
5928
  );
5929
5929
  if (st.current)
5930
- z && z.id !== et.current ? Ye(z.id) : !z && et.current !== null && Ye(null);
5930
+ H && H.id !== et.current ? Ye(H.id) : !H && et.current !== null && Ye(null);
5931
5931
  else if (et.current) {
5932
- const Ae = x.find((Xe) => Xe.id === et.current);
5933
- if (Ae && U >= Ae.end) {
5934
- V.current && V.current.stop(), A(!1), fe.current = Pe.current, k(Pe.current);
5932
+ const Ie = x.find((Ge) => Ge.id === et.current);
5933
+ if (Ie && O >= Ie.end) {
5934
+ F.current && F.current.stop(), k(!1), fe.current = ze.current, $(ze.current);
5935
5935
  return;
5936
5936
  }
5937
5937
  } else
5938
- z && Ye(z.id);
5938
+ H && Ye(H.id);
5939
5939
  }
5940
5940
  if (Je.current && Le.current && _.length > 0) {
5941
- const z = Le.current, Ae = _[0].sampleRate, Xe = U * Ae / mt.current, lt = z.clientWidth, we = l.show ? l.width : 0, xe = Xe + we, Ee = Math.max(0, xe - lt / 2);
5942
- z.scrollLeft = Ee;
5941
+ const H = Le.current, Ie = _[0].sampleRate, Ge = O * Ie / mt.current, lt = H.clientWidth, we = l.show ? l.width : 0, Ce = Ge + we, We = Math.max(0, Ce - lt / 2);
5942
+ H.scrollLeft = We;
5943
5943
  }
5944
- if (Ie.current !== null && U >= Ie.current) {
5945
- V.current && V.current.stop(), A(!1), fe.current = Ie.current, k(Ie.current), Ie.current = null;
5944
+ if (xe.current !== null && O >= xe.current) {
5945
+ F.current && F.current.stop(), k(!1), fe.current = xe.current, $(xe.current), xe.current = null;
5946
5946
  return;
5947
5947
  }
5948
- const ue = le.current !== ve.current && ve.current > le.current;
5949
- if (Ft.current && ue && U >= ve.current) {
5950
- V.current?.stop();
5951
- const Ae = ke().currentTime;
5952
- he.current = Ae, pe.current = le.current, fe.current = le.current, V.current?.play(Ae, le.current), X.current = requestAnimationFrame(W);
5948
+ const ue = ie.current !== ve.current && ve.current > ie.current;
5949
+ if (Ft.current && ue && O >= ve.current) {
5950
+ F.current?.stop();
5951
+ const Ie = Ae().currentTime;
5952
+ he.current = Ie, pe.current = ie.current, fe.current = ie.current, F.current?.play(Ie, ie.current), G.current = requestAnimationFrame(W);
5953
5953
  return;
5954
5954
  }
5955
- if (U >= B) {
5956
- V.current && V.current.stop(), A(!1), fe.current = Pe.current, k(Pe.current), Ye(null);
5955
+ if (O >= A) {
5956
+ F.current && F.current.stop(), k(!1), fe.current = ze.current, $(ze.current), Ye(null);
5957
5957
  return;
5958
5958
  }
5959
- X.current = requestAnimationFrame(W);
5959
+ G.current = requestAnimationFrame(W);
5960
5960
  };
5961
- X.current = requestAnimationFrame(W);
5962
- }, [B, _, Me, x, be]), He = D(() => {
5963
- X.current && (cancelAnimationFrame(X.current), X.current = null);
5961
+ G.current = requestAnimationFrame(W);
5962
+ }, [A, _, $e, x, be]), Xe = D(() => {
5963
+ G.current && (cancelAnimationFrame(G.current), G.current = null);
5964
5964
  }, []);
5965
- j(() => {
5965
+ U(() => {
5966
5966
  (async () => {
5967
- if (C && X.current && V.current)
5967
+ if (v && G.current && F.current)
5968
5968
  if (be) {
5969
- const G = fe.current;
5970
- V.current.stop(), He(), await V.current.init(), V.current.setOnPlaybackComplete(() => {
5969
+ const N = fe.current;
5970
+ F.current.stop(), Xe(), await F.current.init(), F.current.setOnPlaybackComplete(() => {
5971
5971
  });
5972
- const ue = ke().currentTime;
5973
- he.current = ue, pe.current = G, V.current.play(ue, G), tt();
5972
+ const ue = Ae().currentTime;
5973
+ he.current = ue, pe.current = N, F.current.play(ue, N), tt();
5974
5974
  } else
5975
- He(), tt();
5975
+ Xe(), tt();
5976
5976
  })();
5977
- }, [be, C, tt, He]), j(() => {
5977
+ }, [be, v, tt, Xe]), U(() => {
5978
5978
  (async () => {
5979
- if (yt.current && V.current) {
5980
- const { position: G } = yt.current;
5981
- yt.current = null, await V.current.init(), V.current.setOnPlaybackComplete(() => {
5979
+ if (yt.current && F.current) {
5980
+ const { position: N } = yt.current;
5981
+ yt.current = null, await F.current.init(), F.current.setOnPlaybackComplete(() => {
5982
5982
  });
5983
- const ue = ke().currentTime;
5984
- he.current = ue, pe.current = G, V.current.play(ue, G), A(!0), tt();
5983
+ const ue = Ae().currentTime;
5984
+ he.current = ue, pe.current = N, F.current.play(ue, N), k(!0), tt();
5985
5985
  }
5986
5986
  })();
5987
5987
  }, [e, tt]);
5988
- const Vt = D(async (W, G) => {
5989
- if (!V.current || _.length === 0) return;
5990
- await V.current.init(), await Bn();
5991
- const U = W ?? fe.current;
5992
- Pe.current = U, fe.current = U, V.current.setOnPlaybackComplete(() => {
5993
- }), V.current.stop(), He();
5994
- const z = ke().currentTime;
5995
- he.current = z, pe.current = U, Ie.current = G !== void 0 ? U + G : null, V.current.play(z, U, G), A(!0), tt();
5996
- }, [_.length, tt, He]), wr = D(() => {
5997
- if (!V.current) return;
5998
- const W = ke().currentTime - he.current, G = pe.current + W;
5999
- V.current.pause(), A(!1), He(), fe.current = G, k(G);
6000
- }, [He]), yr = D(() => {
6001
- V.current && (V.current.stop(), A(!1), He(), fe.current = Pe.current, k(Pe.current), Ye(null));
6002
- }, [He]), Cr = D((W) => {
6003
- const G = Math.max(0, Math.min(W, B));
6004
- fe.current = G, k(G), C && V.current && (V.current.stop(), He(), Vt(G));
6005
- }, [B, C, Vt, He]), xr = D((W, G) => {
6006
- const U = [...F];
6007
- if (U[W] = { ...U[W], muted: G }, O(U), V.current) {
5988
+ const Vt = D(async (W, N) => {
5989
+ if (!F.current || _.length === 0) return;
5990
+ await F.current.init(), await Bn();
5991
+ const O = W ?? fe.current;
5992
+ ze.current = O, fe.current = O, F.current.setOnPlaybackComplete(() => {
5993
+ }), F.current.stop(), Xe();
5994
+ const H = Ae().currentTime;
5995
+ he.current = H, pe.current = O, xe.current = N !== void 0 ? O + N : null, F.current.play(H, O, N), k(!0), tt();
5996
+ }, [_.length, tt, Xe]), wr = D(() => {
5997
+ if (!F.current) return;
5998
+ const W = Ae().currentTime - he.current, N = pe.current + W;
5999
+ F.current.pause(), k(!1), Xe(), fe.current = N, $(N);
6000
+ }, [Xe]), yr = D(() => {
6001
+ F.current && (F.current.stop(), k(!1), Xe(), fe.current = ze.current, $(ze.current), Ye(null));
6002
+ }, [Xe]), Cr = D((W) => {
6003
+ const N = Math.max(0, Math.min(W, A));
6004
+ fe.current = N, $(N), v && F.current && (F.current.stop(), Xe(), Vt(N));
6005
+ }, [A, v, Vt, Xe]), xr = D((W, N) => {
6006
+ const O = [...P];
6007
+ if (O[W] = { ...O[W], muted: N }, K(O), F.current) {
6008
6008
  const ue = `track-${W}`;
6009
- V.current.setMute(ue, G);
6009
+ F.current.setMute(ue, N);
6010
6010
  }
6011
- }, [F]), Ir = D((W, G) => {
6012
- const U = [...F];
6013
- if (U[W] = { ...U[W], soloed: G }, O(U), V.current) {
6011
+ }, [P]), Ir = D((W, N) => {
6012
+ const O = [...P];
6013
+ if (O[W] = { ...O[W], soloed: N }, K(O), F.current) {
6014
6014
  const ue = `track-${W}`;
6015
- V.current.setSolo(ue, G);
6015
+ F.current.setSolo(ue, N);
6016
6016
  }
6017
- }, [F]), Ar = D((W, G) => {
6018
- const U = [...F];
6019
- if (U[W] = { ...U[W], volume: G }, O(U), V.current) {
6020
- const ue = `track-${W}`, z = V.current.getTrack(ue);
6021
- z && z.setVolume(G);
6017
+ }, [P]), Ar = D((W, N) => {
6018
+ const O = [...P];
6019
+ if (O[W] = { ...O[W], volume: N }, K(O), F.current) {
6020
+ const ue = `track-${W}`, H = F.current.getTrack(ue);
6021
+ H && H.setVolume(N);
6022
6022
  }
6023
- }, [F]), kr = D((W, G) => {
6024
- const U = [...F];
6025
- if (U[W] = { ...U[W], pan: G }, O(U), V.current) {
6026
- const ue = `track-${W}`, z = V.current.getTrack(ue);
6027
- z && z.setPan(G);
6023
+ }, [P]), kr = D((W, N) => {
6024
+ const O = [...P];
6025
+ if (O[W] = { ...O[W], pan: N }, K(O), F.current) {
6026
+ const ue = `track-${W}`, H = F.current.getTrack(ue);
6027
+ H && H.setPan(N);
6028
6028
  }
6029
- }, [F]), Sr = D((W, G) => {
6030
- Z(W), se(G), fe.current = W, k(W), C && V.current && (V.current.stop(), V.current.play(ke().currentTime, W));
6031
- }, [C]), $r = D((W) => {
6029
+ }, [P]), Sr = D((W, N) => {
6030
+ Z(W), le(N), fe.current = W, $(W), v && F.current && (F.current.stop(), F.current.play(Ae().currentTime, W));
6031
+ }, [v]), $r = D((W) => {
6032
6032
  Le.current = W;
6033
6033
  }, []), Mr = _[0]?.sampleRate || 44100, tn = t ? 30 : 0, Br = e.length * r + tn, nn = {
6034
- isPlaying: C,
6035
- currentTime: $,
6034
+ isPlaying: v,
6035
+ currentTime: B,
6036
6036
  currentTimeRef: fe,
6037
6037
  playbackStartTimeRef: he,
6038
6038
  audioStartPositionRef: pe
6039
6039
  }, rn = {
6040
6040
  continuousPlay: be,
6041
6041
  linkEndpoints: Oe,
6042
- annotationsEditable: je,
6043
- isAutomaticScroll: oe,
6044
- isLoopEnabled: de,
6042
+ annotationsEditable: Ue,
6043
+ isAutomaticScroll: ae,
6044
+ isLoopEnabled: ee,
6045
6045
  annotations: x,
6046
6046
  activeAnnotationId: f,
6047
- selectionStart: N,
6048
- selectionEnd: J,
6049
- selectedTrackId: ae,
6050
- loopStart: q,
6051
- loopEnd: Ce
6047
+ selectionStart: X,
6048
+ selectionEnd: Q,
6049
+ selectedTrackId: te,
6050
+ loopStart: oe,
6051
+ loopEnd: me
6052
6052
  }, an = {
6053
6053
  // Playback controls
6054
6054
  play: Vt,
@@ -6056,7 +6056,7 @@ const lr = Be(null), cr = Be(null), ur = Be(null), dr = Be(null), mr = Be(null),
6056
6056
  stop: yr,
6057
6057
  seekTo: Cr,
6058
6058
  setCurrentTime: (W) => {
6059
- fe.current = W, k(W);
6059
+ fe.current = W, $(W);
6060
6060
  },
6061
6061
  // Track controls
6062
6062
  setTrackMute: xr,
@@ -6065,13 +6065,13 @@ const lr = Be(null), cr = Be(null), ur = Be(null), dr = Be(null), mr = Be(null),
6065
6065
  setTrackPan: kr,
6066
6066
  // Selection
6067
6067
  setSelection: Sr,
6068
- setSelectedTrackId: ee,
6068
+ setSelectedTrackId: re,
6069
6069
  // Time format
6070
- setTimeFormat: ze,
6070
+ setTimeFormat: He,
6071
6071
  formatTime: ce,
6072
6072
  // Zoom
6073
- zoomIn: Re.zoomIn,
6074
- zoomOut: Re.zoomOut,
6073
+ zoomIn: Ee.zoomIn,
6074
+ zoomOut: Ee.zoomOut,
6075
6075
  // Master volume
6076
6076
  setMasterVolume: qe,
6077
6077
  // Automatic scroll
@@ -6082,9 +6082,9 @@ const lr = Be(null), cr = Be(null), ur = Be(null), dr = Be(null), mr = Be(null),
6082
6082
  scrollContainerRef: Le,
6083
6083
  // Annotation controls
6084
6084
  setContinuousPlay: it,
6085
- setLinkEndpoints: Se,
6086
- setAnnotationsEditable: K,
6087
- setAnnotations: v,
6085
+ setLinkEndpoints: ke,
6086
+ setAnnotationsEditable: De,
6087
+ setAnnotations: w,
6088
6088
  setActiveAnnotationId: Ye,
6089
6089
  // Loop controls
6090
6090
  setLoopEnabled: Zt,
@@ -6092,26 +6092,26 @@ const lr = Be(null), cr = Be(null), ur = Be(null), dr = Be(null), mr = Be(null),
6092
6092
  setLoopRegionFromSelection: br,
6093
6093
  clearLoopRegion: vr
6094
6094
  }, on = {
6095
- duration: B,
6095
+ duration: A,
6096
6096
  audioBuffers: _,
6097
- peaksDataArray: H,
6098
- trackStates: F,
6097
+ peaksDataArray: V,
6098
+ trackStates: P,
6099
6099
  tracks: e,
6100
6100
  sampleRate: Mr,
6101
6101
  waveHeight: r,
6102
6102
  timeScaleHeight: tn,
6103
6103
  minimumPlaylistHeight: Br,
6104
6104
  controls: l,
6105
- playoutRef: V,
6106
- samplesPerPixel: Me,
6107
- timeFormat: $e,
6105
+ playoutRef: F,
6106
+ samplesPerPixel: $e,
6107
+ timeFormat: Se,
6108
6108
  masterVolume: Qe,
6109
- canZoomIn: Re.canZoomIn,
6110
- canZoomOut: Re.canZoomOut,
6109
+ canZoomIn: Ee.canZoomIn,
6110
+ canZoomOut: Ee.canZoomOut,
6111
6111
  barWidth: d,
6112
6112
  barGap: b,
6113
6113
  progressBarWidth: p,
6114
- isReady: Ne
6114
+ isReady: Re
6115
6115
  }, Dr = {
6116
6116
  ...nn,
6117
6117
  ...rn,
@@ -6119,12 +6119,12 @@ const lr = Be(null), cr = Be(null), ur = Be(null), dr = Be(null), mr = Be(null),
6119
6119
  ...on
6120
6120
  }, Tr = { ...zn, ...i };
6121
6121
  return /* @__PURE__ */ I(Rn, { theme: Tr, children: /* @__PURE__ */ I(lr.Provider, { value: nn, children: /* @__PURE__ */ I(cr.Provider, { value: rn, children: /* @__PURE__ */ I(ur.Provider, { value: an, children: /* @__PURE__ */ I(dr.Provider, { value: on, children: /* @__PURE__ */ I(mr.Provider, { value: Dr, children: m }) }) }) }) }) });
6122
- }, Fe = () => {
6122
+ }, Ze = () => {
6123
6123
  const e = Te(lr);
6124
6124
  if (!e)
6125
6125
  throw new Error("usePlaybackAnimation must be used within WaveformPlaylistProvider");
6126
6126
  return e;
6127
- }, Ge = () => {
6127
+ }, Ne = () => {
6128
6128
  const e = Te(cr);
6129
6129
  if (!e)
6130
6130
  throw new Error("usePlaylistState must be used within WaveformPlaylistProvider");
@@ -6134,7 +6134,7 @@ const lr = Be(null), cr = Be(null), ur = Be(null), dr = Be(null), mr = Be(null),
6134
6134
  if (!e)
6135
6135
  throw new Error("usePlaylistControls must be used within WaveformPlaylistProvider");
6136
6136
  return e;
6137
- }, De = () => {
6137
+ }, Be = () => {
6138
6138
  const e = Te(dr);
6139
6139
  if (!e)
6140
6140
  throw new Error("usePlaylistData must be used within WaveformPlaylistProvider");
@@ -6386,7 +6386,7 @@ var Ys = class {
6386
6386
  return this.track?.peaks.sample_rate ?? 44100;
6387
6387
  }
6388
6388
  };
6389
- const fr = Be(null), hr = Be(null), pr = Be(null), gr = Be(null), _i = ({
6389
+ const fr = Me(null), hr = Me(null), pr = Me(null), gr = Me(null), _i = ({
6390
6390
  track: e,
6391
6391
  samplesPerPixel: t = 1024,
6392
6392
  waveHeight: n = 100,
@@ -6402,180 +6402,180 @@ const fr = Be(null), hr = Be(null), pr = Be(null), gr = Be(null), _i = ({
6402
6402
  onReady: h,
6403
6403
  children: d
6404
6404
  }) => {
6405
- const b = g ?? c + u, [y, m] = E(!1), [p, x] = E(0), [v, f] = E(0), [w, C] = E([]), [A, $] = E(a), [k, B] = E([]), [M, _] = E(null), [T, H] = E(
6405
+ const b = g ?? c + u, [y, m] = R(!1), [p, x] = R(0), [w, f] = R(0), [C, v] = R([]), [k, B] = R(a), [$, A] = R([]), [M, _] = R(null), [E, V] = R(
6406
6406
  l?.isContinuousPlay ?? !1
6407
- ), [P] = E(t), [F, O] = E(s), N = R(null), Z = R(0), J = R(null), se = R(T), ae = R(null), ee = R(null), oe = R(s), ye = R(t);
6408
- j(() => {
6409
- se.current = T;
6410
- }, [T]), j(() => {
6411
- oe.current = F;
6412
- }, [F]);
6413
- const be = D((X) => {
6414
- ae.current = X, _(X);
6415
- }, []), Ue = D((X) => {
6416
- se.current = X, H(X);
6417
- }, []), Oe = D((X) => {
6418
- ee.current = X;
6419
- }, []), Se = e.waveformData.sample_rate;
6420
- j(() => {
6421
- const X = new Os({
6407
+ ), [z] = R(t), [P, K] = R(s), X = T(null), Z = T(0), Q = T(null), le = T(E), te = T(null), re = T(null), ae = T(s), ye = T(t);
6408
+ U(() => {
6409
+ le.current = E;
6410
+ }, [E]), U(() => {
6411
+ ae.current = P;
6412
+ }, [P]);
6413
+ const be = D((G) => {
6414
+ te.current = G, _(G);
6415
+ }, []), Ke = D((G) => {
6416
+ le.current = G, V(G);
6417
+ }, []), Oe = D((G) => {
6418
+ re.current = G;
6419
+ }, []), ke = e.waveformData.sample_rate;
6420
+ U(() => {
6421
+ const G = new Os({
6422
6422
  playbackRate: a
6423
6423
  });
6424
- X.addTrack({
6424
+ G.addTrack({
6425
6425
  source: e.source,
6426
6426
  peaks: e.waveformData,
6427
6427
  name: e.name
6428
6428
  });
6429
- const ie = X.getTrack(X.track?.id ?? "");
6430
- return ie && ie.setOnTimeUpdateCallback((he) => {
6429
+ const se = G.getTrack(G.track?.id ?? "");
6430
+ return se && se.setOnTimeUpdateCallback((he) => {
6431
6431
  Z.current = he;
6432
- }), X.setOnPlaybackComplete(() => {
6432
+ }), G.setOnPlaybackComplete(() => {
6433
6433
  m(!1);
6434
- }), N.current = X, f(e.waveformData.duration), h?.(), () => {
6435
- J.current && cancelAnimationFrame(J.current), X.dispose();
6434
+ }), X.current = G, f(e.waveformData.duration), h?.(), () => {
6435
+ Q.current && cancelAnimationFrame(Q.current), G.dispose();
6436
6436
  };
6437
- }, [e.source, e.waveformData, e.name, a, h]), j(() => {
6438
- const X = tr(
6437
+ }, [e.source, e.waveformData, e.name, a, h]), U(() => {
6438
+ const G = tr(
6439
6439
  e.waveformData,
6440
- P,
6440
+ z,
6441
6441
  0,
6442
6442
  // channel index
6443
6443
  0,
6444
6444
  // offset
6445
- Math.ceil(e.waveformData.duration * Se)
6445
+ Math.ceil(e.waveformData.duration * ke)
6446
6446
  // duration in samples
6447
- ), ie = {
6447
+ ), se = {
6448
6448
  clipId: "media-element-clip",
6449
6449
  trackName: e.name ?? "Track",
6450
6450
  peaks: {
6451
- length: X.length,
6452
- data: [X.data],
6453
- bits: X.bits
6451
+ length: G.length,
6452
+ data: [G.data],
6453
+ bits: G.bits
6454
6454
  },
6455
6455
  startSample: 0,
6456
- durationSamples: Math.ceil(e.waveformData.duration * Se)
6456
+ durationSamples: Math.ceil(e.waveformData.duration * ke)
6457
6457
  };
6458
- C([[ie]]);
6459
- }, [e.waveformData, e.name, P, Se]), j(() => {
6458
+ v([[se]]);
6459
+ }, [e.waveformData, e.name, z, ke]), U(() => {
6460
6460
  if (l?.annotations) {
6461
- const X = l.annotations.map((ie) => typeof ie.start == "number" ? ie : nr(ie));
6462
- B(X);
6461
+ const G = l.annotations.map((se) => typeof se.start == "number" ? se : nr(se));
6462
+ A(G);
6463
6463
  }
6464
6464
  }, [l]);
6465
- const je = D(() => {
6466
- J.current && cancelAnimationFrame(J.current);
6467
- const X = () => {
6468
- const ie = N.current?.getCurrentTime() ?? 0;
6469
- if (Z.current = ie, x(ie), k.length > 0) {
6470
- const he = k.find(
6471
- (pe) => ie >= pe.start && ie < pe.end
6465
+ const Ue = D(() => {
6466
+ Q.current && cancelAnimationFrame(Q.current);
6467
+ const G = () => {
6468
+ const se = X.current?.getCurrentTime() ?? 0;
6469
+ if (Z.current = se, x(se), $.length > 0) {
6470
+ const he = $.find(
6471
+ (pe) => se >= pe.start && se < pe.end
6472
6472
  );
6473
- if (se.current)
6474
- he && he.id !== ae.current ? be(he.id) : !he && ae.current !== null && be(null);
6475
- else if (ae.current) {
6476
- const pe = k.find(
6477
- (Ie) => Ie.id === ae.current
6473
+ if (le.current)
6474
+ he && he.id !== te.current ? be(he.id) : !he && te.current !== null && be(null);
6475
+ else if (te.current) {
6476
+ const pe = $.find(
6477
+ (xe) => xe.id === te.current
6478
6478
  );
6479
- if (pe && ie >= pe.end) {
6480
- N.current?.stop(), m(!1);
6479
+ if (pe && se >= pe.end) {
6480
+ X.current?.stop(), m(!1);
6481
6481
  return;
6482
6482
  }
6483
6483
  } else he && be(he.id);
6484
6484
  }
6485
- if (oe.current && ee.current) {
6486
- const he = ee.current, pe = ie * Se / ye.current, Ie = he.clientWidth, Le = i.show ? i.width : 0, Je = pe + Le, st = Math.max(0, Je - Ie / 2);
6485
+ if (ae.current && re.current) {
6486
+ const he = re.current, pe = se * ke / ye.current, xe = he.clientWidth, Le = i.show ? i.width : 0, Je = pe + Le, st = Math.max(0, Je - xe / 2);
6487
6487
  he.scrollLeft = st;
6488
6488
  }
6489
- if (ie >= v) {
6490
- N.current?.stop(), m(!1), be(null);
6489
+ if (se >= w) {
6490
+ X.current?.stop(), m(!1), be(null);
6491
6491
  return;
6492
6492
  }
6493
- J.current = requestAnimationFrame(X);
6493
+ Q.current = requestAnimationFrame(G);
6494
6494
  };
6495
- J.current = requestAnimationFrame(X);
6496
- }, [v, k, be, Se, i]), K = D(() => {
6497
- J.current && (cancelAnimationFrame(J.current), J.current = null);
6498
- }, []), de = D(
6499
- (X) => {
6500
- if (!N.current) return;
6501
- const ie = X ?? Z.current;
6502
- N.current.play(void 0, ie), m(!0), je();
6495
+ Q.current = requestAnimationFrame(G);
6496
+ }, [w, $, be, ke, i]), De = D(() => {
6497
+ Q.current && (cancelAnimationFrame(Q.current), Q.current = null);
6498
+ }, []), ee = D(
6499
+ (G) => {
6500
+ if (!X.current) return;
6501
+ const se = G ?? Z.current;
6502
+ X.current.play(void 0, se), m(!0), Ue();
6503
6503
  },
6504
- [je]
6505
- ), ne = D(() => {
6506
- N.current && (N.current.pause(), m(!1), K(), x(N.current.getCurrentTime()));
6507
- }, [K]), q = D(() => {
6508
- N.current && (N.current.stop(), m(!1), K(), Z.current = 0, x(0), be(null));
6509
- }, [K, be]), me = D(
6510
- (X) => {
6511
- const ie = Math.max(0, Math.min(X, v));
6512
- Z.current = ie, x(ie), N.current && N.current.seekTo(ie);
6504
+ [Ue]
6505
+ ), j = D(() => {
6506
+ X.current && (X.current.pause(), m(!1), De(), x(X.current.getCurrentTime()));
6507
+ }, [De]), oe = D(() => {
6508
+ X.current && (X.current.stop(), m(!1), De(), Z.current = 0, x(0), be(null));
6509
+ }, [De, be]), de = D(
6510
+ (G) => {
6511
+ const se = Math.max(0, Math.min(G, w));
6512
+ Z.current = se, x(se), X.current && X.current.seekTo(se);
6513
6513
  },
6514
- [v]
6515
- ), Ce = D((X) => {
6516
- const ie = Math.max(0.5, Math.min(2, X));
6517
- $(ie), N.current && N.current.setPlaybackRate(ie);
6518
- }, []), re = r ? 30 : 0, Ne = nt(
6514
+ [w]
6515
+ ), me = D((G) => {
6516
+ const se = Math.max(0.5, Math.min(2, G));
6517
+ B(se), X.current && X.current.setPlaybackRate(se);
6518
+ }, []), J = r ? 30 : 0, Re = nt(
6519
6519
  () => ({
6520
6520
  isPlaying: y,
6521
6521
  currentTime: p,
6522
6522
  currentTimeRef: Z
6523
6523
  }),
6524
6524
  [y, p]
6525
- ), Ke = nt(
6525
+ ), je = nt(
6526
6526
  () => ({
6527
- continuousPlay: T,
6528
- annotations: k,
6527
+ continuousPlay: E,
6528
+ annotations: $,
6529
6529
  activeAnnotationId: M,
6530
- playbackRate: A,
6531
- isAutomaticScroll: F
6530
+ playbackRate: k,
6531
+ isAutomaticScroll: P
6532
6532
  }),
6533
- [T, k, M, A, F]
6534
- ), V = nt(
6533
+ [E, $, M, k, P]
6534
+ ), F = nt(
6535
6535
  () => ({
6536
- play: de,
6537
- pause: ne,
6538
- stop: q,
6539
- seekTo: me,
6540
- setPlaybackRate: Ce,
6541
- setContinuousPlay: Ue,
6542
- setAnnotations: B,
6536
+ play: ee,
6537
+ pause: j,
6538
+ stop: oe,
6539
+ seekTo: de,
6540
+ setPlaybackRate: me,
6541
+ setContinuousPlay: Ke,
6542
+ setAnnotations: A,
6543
6543
  setActiveAnnotationId: be,
6544
- setAutomaticScroll: (X) => {
6545
- O(X);
6544
+ setAutomaticScroll: (G) => {
6545
+ K(G);
6546
6546
  },
6547
6547
  setScrollContainer: Oe,
6548
- scrollContainerRef: ee
6548
+ scrollContainerRef: re
6549
6549
  }),
6550
- [de, ne, q, me, Ce, Ue, be, Oe]
6551
- ), Pe = nt(
6550
+ [ee, j, oe, de, me, Ke, be, Oe]
6551
+ ), ze = nt(
6552
6552
  () => ({
6553
- duration: v,
6554
- peaksDataArray: w,
6555
- sampleRate: Se,
6553
+ duration: w,
6554
+ peaksDataArray: C,
6555
+ sampleRate: ke,
6556
6556
  waveHeight: n,
6557
- timeScaleHeight: re,
6558
- samplesPerPixel: P,
6559
- playoutRef: N,
6557
+ timeScaleHeight: J,
6558
+ samplesPerPixel: z,
6559
+ playoutRef: X,
6560
6560
  controls: i,
6561
6561
  barWidth: c,
6562
6562
  barGap: u,
6563
6563
  progressBarWidth: b
6564
6564
  }),
6565
6565
  [
6566
- v,
6567
6566
  w,
6568
- Se,
6567
+ C,
6568
+ ke,
6569
6569
  n,
6570
- re,
6571
- P,
6570
+ J,
6571
+ z,
6572
6572
  i,
6573
6573
  c,
6574
6574
  u,
6575
6575
  b
6576
6576
  ]
6577
6577
  ), fe = { ...zn, ...o };
6578
- return /* @__PURE__ */ I(Rn, { theme: fe, children: /* @__PURE__ */ I(fr.Provider, { value: Ne, children: /* @__PURE__ */ I(hr.Provider, { value: Ke, children: /* @__PURE__ */ I(pr.Provider, { value: V, children: /* @__PURE__ */ I(gr.Provider, { value: Pe, children: d }) }) }) }) });
6578
+ return /* @__PURE__ */ I(Rn, { theme: fe, children: /* @__PURE__ */ I(fr.Provider, { value: Re, children: /* @__PURE__ */ I(hr.Provider, { value: je, children: /* @__PURE__ */ I(pr.Provider, { value: F, children: /* @__PURE__ */ I(gr.Provider, { value: ze, children: d }) }) }) }) });
6579
6579
  }, qt = () => {
6580
6580
  const e = Te(fr);
6581
6581
  if (!e)
@@ -6605,8 +6605,8 @@ const fr = Be(null), hr = Be(null), pr = Be(null), gr = Be(null), _i = ({
6605
6605
  );
6606
6606
  return e;
6607
6607
  }, Fi = ({ className: e }) => {
6608
- const { isPlaying: t, currentTimeRef: n } = Fe(), { selectionStart: r, selectionEnd: a, isLoopEnabled: s } = Ge(), { play: o } = ge();
6609
- return /* @__PURE__ */ I(Ve, { onClick: async () => {
6608
+ const { isPlaying: t, currentTimeRef: n } = Ze(), { selectionStart: r, selectionEnd: a, isLoopEnabled: s } = Ne(), { play: o } = ge();
6609
+ return /* @__PURE__ */ I(Pe, { onClick: async () => {
6610
6610
  if (r !== a && a > r)
6611
6611
  if (s)
6612
6612
  await o(r);
@@ -6618,27 +6618,27 @@ const fr = Be(null), hr = Be(null), pr = Be(null), gr = Be(null), _i = ({
6618
6618
  await o(n.current ?? 0);
6619
6619
  }, disabled: t, className: e, children: "Play" });
6620
6620
  }, Zi = ({ className: e }) => {
6621
- const { isPlaying: t } = Fe(), { pause: n } = ge();
6622
- return /* @__PURE__ */ I(Ve, { onClick: n, disabled: !t, className: e, children: "Pause" });
6621
+ const { isPlaying: t } = Ze(), { pause: n } = ge();
6622
+ return /* @__PURE__ */ I(Pe, { onClick: n, disabled: !t, className: e, children: "Pause" });
6623
6623
  }, Vi = ({ className: e }) => {
6624
- const { isPlaying: t } = Fe(), { stop: n } = ge();
6625
- return /* @__PURE__ */ I(Ve, { onClick: n, disabled: !t, className: e, children: "Stop" });
6624
+ const { isPlaying: t } = Ze(), { stop: n } = ge();
6625
+ return /* @__PURE__ */ I(Pe, { onClick: n, disabled: !t, className: e, children: "Stop" });
6626
6626
  }, Pi = ({ className: e }) => {
6627
- const { isPlaying: t } = Fe(), { play: n, setCurrentTime: r } = ge(), { playoutRef: a } = De();
6628
- return /* @__PURE__ */ I(Ve, { onClick: () => {
6627
+ const { isPlaying: t } = Ze(), { play: n, setCurrentTime: r } = ge(), { playoutRef: a } = Be();
6628
+ return /* @__PURE__ */ I(Pe, { onClick: () => {
6629
6629
  r(0), t && a.current && (a.current.stop(), n(0));
6630
6630
  }, className: e, children: "Rewind" });
6631
6631
  }, zi = ({ className: e }) => {
6632
- const { isPlaying: t } = Fe(), { play: n, setCurrentTime: r } = ge(), { duration: a, playoutRef: s } = De();
6633
- return /* @__PURE__ */ I(Ve, { onClick: () => {
6632
+ const { isPlaying: t } = Ze(), { play: n, setCurrentTime: r } = ge(), { duration: a, playoutRef: s } = Be();
6633
+ return /* @__PURE__ */ I(Pe, { onClick: () => {
6634
6634
  r(a), t && s.current && (s.current.stop(), n(a));
6635
6635
  }, className: e, children: "Fast Forward" });
6636
6636
  }, Hi = ({
6637
6637
  skipAmount: e = 5,
6638
6638
  className: t
6639
6639
  }) => {
6640
- const { currentTimeRef: n, isPlaying: r } = Fe(), { play: a, setCurrentTime: s } = ge(), { playoutRef: o } = De();
6641
- return /* @__PURE__ */ I(Ve, { onClick: () => {
6640
+ const { currentTimeRef: n, isPlaying: r } = Ze(), { play: a, setCurrentTime: s } = ge(), { playoutRef: o } = Be();
6641
+ return /* @__PURE__ */ I(Pe, { onClick: () => {
6642
6642
  const l = Math.max(0, (n.current ?? 0) - e);
6643
6643
  s(l), r && o.current && (o.current.stop(), a(l));
6644
6644
  }, className: t, children: "Skip Backward" });
@@ -6646,15 +6646,15 @@ const fr = Be(null), hr = Be(null), pr = Be(null), gr = Be(null), _i = ({
6646
6646
  skipAmount: e = 5,
6647
6647
  className: t
6648
6648
  }) => {
6649
- const { currentTimeRef: n, isPlaying: r } = Fe(), { play: a, setCurrentTime: s } = ge(), { duration: o, playoutRef: i } = De();
6650
- return /* @__PURE__ */ I(Ve, { onClick: () => {
6649
+ const { currentTimeRef: n, isPlaying: r } = Ze(), { play: a, setCurrentTime: s } = ge(), { duration: o, playoutRef: i } = Be();
6650
+ return /* @__PURE__ */ I(Pe, { onClick: () => {
6651
6651
  const c = Math.min(o, (n.current ?? 0) + e);
6652
6652
  s(c), r && i.current && (i.current.stop(), a(c));
6653
6653
  }, className: t, children: "Skip Forward" });
6654
6654
  }, Gi = ({ className: e }) => {
6655
- const { isLoopEnabled: t, loopStart: n, loopEnd: r } = Ge(), { setLoopEnabled: a, setLoopRegion: s } = ge(), { duration: o } = De(), i = n !== r && r > n;
6655
+ const { isLoopEnabled: t, loopStart: n, loopEnd: r } = Ne(), { setLoopEnabled: a, setLoopRegion: s } = ge(), { duration: o } = Be(), i = n !== r && r > n;
6656
6656
  return /* @__PURE__ */ I(
6657
- Ve,
6657
+ Pe,
6658
6658
  {
6659
6659
  onClick: () => {
6660
6660
  if (!t && !i) {
@@ -6669,9 +6669,9 @@ const fr = Be(null), hr = Be(null), pr = Be(null), gr = Be(null), _i = ({
6669
6669
  }
6670
6670
  );
6671
6671
  }, Ni = ({ className: e }) => {
6672
- const { selectionStart: t, selectionEnd: n, loopStart: r, loopEnd: a } = Ge(), { setLoopRegionFromSelection: s, clearLoopRegion: o } = ge(), i = t !== n && n > t, l = r !== a && a > r;
6672
+ const { selectionStart: t, selectionEnd: n, loopStart: r, loopEnd: a } = Ne(), { setLoopRegionFromSelection: s, clearLoopRegion: o } = ge(), i = t !== n && n > t, l = r !== a && a > r;
6673
6673
  return /* @__PURE__ */ I(
6674
- Ve,
6674
+ Pe,
6675
6675
  {
6676
6676
  onClick: () => {
6677
6677
  l ? o() : s();
@@ -6683,13 +6683,13 @@ const fr = Be(null), hr = Be(null), pr = Be(null), gr = Be(null), _i = ({
6683
6683
  }
6684
6684
  );
6685
6685
  }, Li = ({ className: e, disabled: t }) => {
6686
- const { zoomIn: n } = ge(), { canZoomIn: r } = De();
6687
- return /* @__PURE__ */ I(Ve, { variant: "success", onClick: n, disabled: t || !r, className: e, children: "Zoom In" });
6686
+ const { zoomIn: n } = ge(), { canZoomIn: r } = Be();
6687
+ return /* @__PURE__ */ I(Pe, { variant: "success", onClick: n, disabled: t || !r, className: e, children: "Zoom In" });
6688
6688
  }, Yi = ({ className: e, disabled: t }) => {
6689
- const { zoomOut: n } = ge(), { canZoomOut: r } = De();
6690
- return /* @__PURE__ */ I(Ve, { variant: "success", onClick: n, disabled: t || !r, className: e, children: "Zoom Out" });
6689
+ const { zoomOut: n } = ge(), { canZoomOut: r } = Be();
6690
+ return /* @__PURE__ */ I(Pe, { variant: "success", onClick: n, disabled: t || !r, className: e, children: "Zoom Out" });
6691
6691
  }, Oi = ({ className: e }) => {
6692
- const { masterVolume: t } = De(), { setMasterVolume: n } = ge();
6692
+ const { masterVolume: t } = Be(), { setMasterVolume: n } = ge();
6693
6693
  return /* @__PURE__ */ I(
6694
6694
  Ya,
6695
6695
  {
@@ -6699,7 +6699,7 @@ const fr = Be(null), hr = Be(null), pr = Be(null), gr = Be(null), _i = ({
6699
6699
  }
6700
6700
  );
6701
6701
  }, Ki = ({ className: e }) => {
6702
- const { timeFormat: t } = De(), { setTimeFormat: n } = ge();
6702
+ const { timeFormat: t } = Be(), { setTimeFormat: n } = ge();
6703
6703
  return /* @__PURE__ */ I(
6704
6704
  wo,
6705
6705
  {
@@ -6715,13 +6715,13 @@ const fr = Be(null), hr = Be(null), pr = Be(null), gr = Be(null), _i = ({
6715
6715
  color: ${(e) => e.theme?.textColor || "#333"};
6716
6716
  user-select: none;
6717
6717
  `, Ui = ({ className: e }) => {
6718
- const t = R(null), n = R(null), { isPlaying: r, currentTimeRef: a, playbackStartTimeRef: s, audioStartPositionRef: o } = Fe(), { timeFormat: i } = De(), l = i;
6719
- return j(() => {
6718
+ const t = T(null), n = T(null), { isPlaying: r, currentTimeRef: a, playbackStartTimeRef: s, audioStartPositionRef: o } = Ze(), { timeFormat: i } = Be(), l = i;
6719
+ return U(() => {
6720
6720
  const c = () => {
6721
6721
  if (t.current) {
6722
6722
  let u;
6723
6723
  if (r) {
6724
- const g = ke().currentTime - (s.current ?? 0);
6724
+ const g = Ae().currentTime - (s.current ?? 0);
6725
6725
  u = (o.current ?? 0) + g;
6726
6726
  } else
6727
6727
  u = a.current ?? 0;
@@ -6732,11 +6732,11 @@ const fr = Be(null), hr = Be(null), pr = Be(null), gr = Be(null), _i = ({
6732
6732
  return r ? n.current = requestAnimationFrame(c) : c(), () => {
6733
6733
  n.current && (cancelAnimationFrame(n.current), n.current = null);
6734
6734
  };
6735
- }, [r, l, a, s, o]), j(() => {
6735
+ }, [r, l, a, s, o]), U(() => {
6736
6736
  !r && t.current && (t.current.textContent = dt(a.current ?? 0, l));
6737
6737
  }), /* @__PURE__ */ I(js, { ref: t, className: e, "aria-label": "Audio position", children: dt(a.current ?? 0, l) });
6738
6738
  }, ji = ({ className: e }) => {
6739
- const { selectionStart: t, selectionEnd: n } = Ge(), { setSelection: r } = ge();
6739
+ const { selectionStart: t, selectionEnd: n } = Ne(), { setSelection: r } = ge();
6740
6740
  return /* @__PURE__ */ I(
6741
6741
  ro,
6742
6742
  {
@@ -6747,7 +6747,7 @@ const fr = Be(null), hr = Be(null), pr = Be(null), gr = Be(null), _i = ({
6747
6747
  }
6748
6748
  );
6749
6749
  }, Ji = ({ className: e }) => {
6750
- const { isAutomaticScroll: t } = Ge(), { setAutomaticScroll: n } = ge();
6750
+ const { isAutomaticScroll: t } = Ne(), { setAutomaticScroll: n } = ge();
6751
6751
  return /* @__PURE__ */ I(
6752
6752
  $a,
6753
6753
  {
@@ -6757,7 +6757,7 @@ const fr = Be(null), hr = Be(null), pr = Be(null), gr = Be(null), _i = ({
6757
6757
  }
6758
6758
  );
6759
6759
  }, Qi = ({ className: e }) => {
6760
- const { continuousPlay: t } = Ge(), { setContinuousPlay: n } = ge();
6760
+ const { continuousPlay: t } = Ne(), { setContinuousPlay: n } = ge();
6761
6761
  return /* @__PURE__ */ I(
6762
6762
  ms,
6763
6763
  {
@@ -6767,7 +6767,7 @@ const fr = Be(null), hr = Be(null), pr = Be(null), gr = Be(null), _i = ({
6767
6767
  }
6768
6768
  );
6769
6769
  }, qi = ({ className: e }) => {
6770
- const { linkEndpoints: t } = Ge(), { setLinkEndpoints: n } = ge();
6770
+ const { linkEndpoints: t } = Ne(), { setLinkEndpoints: n } = ge();
6771
6771
  return /* @__PURE__ */ I(
6772
6772
  fs,
6773
6773
  {
@@ -6777,7 +6777,7 @@ const fr = Be(null), hr = Be(null), pr = Be(null), gr = Be(null), _i = ({
6777
6777
  }
6778
6778
  );
6779
6779
  }, el = ({ className: e }) => {
6780
- const { annotationsEditable: t } = Ge(), { setAnnotationsEditable: n } = ge();
6780
+ const { annotationsEditable: t } = Ne(), { setAnnotationsEditable: n } = ge();
6781
6781
  return /* @__PURE__ */ I(
6782
6782
  hs,
6783
6783
  {
@@ -6790,7 +6790,7 @@ const fr = Be(null), hr = Be(null), pr = Be(null), gr = Be(null), _i = ({
6790
6790
  filename: e,
6791
6791
  className: t
6792
6792
  }) => {
6793
- const { annotations: n } = Ge();
6793
+ const { annotations: n } = Ne();
6794
6794
  return /* @__PURE__ */ I(
6795
6795
  gs,
6796
6796
  {
@@ -6812,7 +6812,7 @@ const fr = Be(null), hr = Be(null), pr = Be(null), gr = Be(null), _i = ({
6812
6812
  onExportComplete: c,
6813
6813
  onExportError: u
6814
6814
  }) => {
6815
- const { tracks: g, trackStates: h } = De(), { exportWav: d, isExporting: b, progress: y } = Xs(), m = async () => {
6815
+ const { tracks: g, trackStates: h } = Be(), { exportWav: d, isExporting: b, progress: y } = Xs(), m = async () => {
6816
6816
  try {
6817
6817
  const x = await d(g, h, {
6818
6818
  filename: t,
@@ -6830,7 +6830,7 @@ const fr = Be(null), hr = Be(null), pr = Be(null), gr = Be(null), _i = ({
6830
6830
  }
6831
6831
  }, p = b ? `Exporting ${Math.round(y * 100)}%` : e;
6832
6832
  return /* @__PURE__ */ I(
6833
- Ve,
6833
+ Pe,
6834
6834
  {
6835
6835
  onClick: m,
6836
6836
  disabled: b || g.length === 0,
@@ -6852,13 +6852,13 @@ const fr = Be(null), hr = Be(null), pr = Be(null), gr = Be(null), _i = ({
6852
6852
  color: e = "#ff0000",
6853
6853
  controlsOffset: t = 0
6854
6854
  }) => {
6855
- const n = R(null), r = R(null), { isPlaying: a, currentTimeRef: s, playbackStartTimeRef: o, audioStartPositionRef: i } = Fe(), { samplesPerPixel: l, sampleRate: c, progressBarWidth: u } = De();
6856
- return j(() => {
6855
+ const n = T(null), r = T(null), { isPlaying: a, currentTimeRef: s, playbackStartTimeRef: o, audioStartPositionRef: i } = Ze(), { samplesPerPixel: l, sampleRate: c, progressBarWidth: u } = Be();
6856
+ return U(() => {
6857
6857
  const g = () => {
6858
6858
  if (n.current) {
6859
6859
  let h;
6860
6860
  if (a) {
6861
- const b = ke().currentTime - (o.current ?? 0);
6861
+ const b = Ae().currentTime - (o.current ?? 0);
6862
6862
  h = (i.current ?? 0) + b;
6863
6863
  } else
6864
6864
  h = s.current ?? 0;
@@ -6870,7 +6870,7 @@ const fr = Be(null), hr = Be(null), pr = Be(null), gr = Be(null), _i = ({
6870
6870
  return a ? r.current = requestAnimationFrame(g) : g(), () => {
6871
6871
  r.current && (cancelAnimationFrame(r.current), r.current = null);
6872
6872
  };
6873
- }, [a, c, l, t, s, o, i]), j(() => {
6873
+ }, [a, c, l, t, s, o, i]), U(() => {
6874
6874
  if (!a && n.current) {
6875
6875
  const h = (s.current ?? 0) * c / l + t;
6876
6876
  n.current.style.transform = `translate3d(${h}px, 0, 0)`;
@@ -6907,44 +6907,44 @@ const fr = Be(null), hr = Be(null), pr = Be(null), gr = Be(null), _i = ({
6907
6907
  clipDurationSamples: t,
6908
6908
  ...n
6909
6909
  }) => {
6910
- const r = R(null), a = R(null), s = wt(), { waveHeight: o } = vt(), { isPlaying: i, currentTimeRef: l, playbackStartTimeRef: c, audioStartPositionRef: u } = Fe(), { samplesPerPixel: g, sampleRate: h } = De(), d = s?.waveProgressColor || "rgba(0, 0, 0, 0.1)";
6911
- j(() => {
6910
+ const r = T(null), a = T(null), s = wt(), { waveHeight: o } = vt(), { isPlaying: i, currentTimeRef: l, playbackStartTimeRef: c, audioStartPositionRef: u } = Ze(), { samplesPerPixel: g, sampleRate: h } = Be(), d = s?.waveProgressColor || "rgba(0, 0, 0, 0.1)";
6911
+ U(() => {
6912
6912
  const p = () => {
6913
6913
  if (r.current) {
6914
6914
  let x;
6915
6915
  if (i) {
6916
- const C = ke().currentTime - (c.current ?? 0);
6917
- x = (u.current ?? 0) + C;
6916
+ const v = Ae().currentTime - (c.current ?? 0);
6917
+ x = (u.current ?? 0) + v;
6918
6918
  } else
6919
6919
  x = l.current ?? 0;
6920
- const v = x * h, f = e + t;
6921
- let w = 0;
6922
- if (v <= e)
6923
- w = 0;
6924
- else if (v >= f)
6925
- w = n.length;
6920
+ const w = x * h, f = e + t;
6921
+ let C = 0;
6922
+ if (w <= e)
6923
+ C = 0;
6924
+ else if (w >= f)
6925
+ C = n.length;
6926
6926
  else {
6927
- const C = v - e;
6928
- w = Math.floor(C / g);
6927
+ const v = w - e;
6928
+ C = Math.floor(v / g);
6929
6929
  }
6930
- r.current.style.width = `${w}px`;
6930
+ r.current.style.width = `${C}px`;
6931
6931
  }
6932
6932
  i && (a.current = requestAnimationFrame(p));
6933
6933
  };
6934
6934
  return i ? a.current = requestAnimationFrame(p) : p(), () => {
6935
6935
  a.current && (cancelAnimationFrame(a.current), a.current = null);
6936
6936
  };
6937
- }, [i, h, g, e, t, n.length, l, c, u]), j(() => {
6937
+ }, [i, h, g, e, t, n.length, l, c, u]), U(() => {
6938
6938
  if (!i && r.current) {
6939
- const x = (l.current ?? 0) * h, v = e + t;
6939
+ const x = (l.current ?? 0) * h, w = e + t;
6940
6940
  let f = 0;
6941
6941
  if (x <= e)
6942
6942
  f = 0;
6943
- else if (x >= v)
6943
+ else if (x >= w)
6944
6944
  f = n.length;
6945
6945
  else {
6946
- const w = x - e;
6947
- f = Math.floor(w / g);
6946
+ const C = x - e;
6947
+ f = Math.floor(C / g);
6948
6948
  }
6949
6949
  r.current.style.width = `${f}px`;
6950
6950
  }
@@ -6953,7 +6953,7 @@ const fr = Be(null), hr = Be(null), pr = Be(null), gr = Be(null), _i = ({
6953
6953
  let y;
6954
6954
  b === "inverted" ? y = n.isSelected && s ? s.selectedWaveFillColor : s?.waveFillColor || "white" : y = n.isSelected && s ? s.selectedWaveOutlineColor : s?.waveOutlineColor || "grey";
6955
6955
  const m = at(y);
6956
- return /* @__PURE__ */ te(qs, { children: [
6956
+ return /* @__PURE__ */ ne(qs, { children: [
6957
6957
  /* @__PURE__ */ I(
6958
6958
  ei,
6959
6959
  {
@@ -6992,98 +6992,98 @@ const fr = Be(null), hr = Be(null), pr = Be(null), gr = Be(null), _i = ({
6992
6992
  touchOptimized: b = !1,
6993
6993
  recordingState: y
6994
6994
  }) => {
6995
- const m = wt(), { isPlaying: p, currentTimeRef: x, playbackStartTimeRef: v, audioStartPositionRef: f } = Fe(), {
6996
- selectionStart: w,
6997
- selectionEnd: C,
6998
- annotations: A,
6999
- activeAnnotationId: $,
7000
- annotationsEditable: k,
7001
- linkEndpoints: B,
6995
+ const m = wt(), { isPlaying: p, currentTimeRef: x, playbackStartTimeRef: w, audioStartPositionRef: f } = Ze(), {
6996
+ selectionStart: C,
6997
+ selectionEnd: v,
6998
+ annotations: k,
6999
+ activeAnnotationId: B,
7000
+ annotationsEditable: $,
7001
+ linkEndpoints: A,
7002
7002
  continuousPlay: M,
7003
7003
  selectedTrackId: _,
7004
- loopStart: T,
7005
- loopEnd: H,
7006
- isLoopEnabled: P
7007
- } = Ge(), {
7008
- setAnnotations: F,
7009
- setActiveAnnotationId: O,
7010
- setTrackMute: N,
7004
+ loopStart: E,
7005
+ loopEnd: V,
7006
+ isLoopEnabled: z
7007
+ } = Ne(), {
7008
+ setAnnotations: P,
7009
+ setActiveAnnotationId: K,
7010
+ setTrackMute: X,
7011
7011
  setTrackSolo: Z,
7012
- setTrackVolume: J,
7013
- setTrackPan: se,
7014
- setSelection: ae,
7015
- play: ee,
7016
- setScrollContainer: oe,
7012
+ setTrackVolume: Q,
7013
+ setTrackPan: le,
7014
+ setSelection: te,
7015
+ play: re,
7016
+ setScrollContainer: ae,
7017
7017
  setSelectedTrackId: ye,
7018
7018
  setCurrentTime: be,
7019
- setLoopRegion: Ue
7019
+ setLoopRegion: Ke
7020
7020
  } = ge(), {
7021
7021
  audioBuffers: Oe,
7022
- peaksDataArray: Se,
7023
- trackStates: je,
7024
- tracks: K,
7025
- duration: de,
7026
- samplesPerPixel: ne,
7027
- sampleRate: q,
7028
- waveHeight: me,
7029
- timeScaleHeight: Ce,
7030
- controls: re,
7031
- playoutRef: Ne,
7032
- barWidth: Ke,
7033
- barGap: V,
7034
- isReady: Pe
7035
- } = De(), [fe, X] = E(!1), ie = R(null), he = D((L) => {
7036
- ie.current = L, oe(L);
7037
- }, [oe]);
7038
- let pe = Oe.length > 0 ? de : ri;
7022
+ peaksDataArray: ke,
7023
+ trackStates: Ue,
7024
+ tracks: De,
7025
+ duration: ee,
7026
+ samplesPerPixel: j,
7027
+ sampleRate: oe,
7028
+ waveHeight: de,
7029
+ timeScaleHeight: me,
7030
+ controls: J,
7031
+ playoutRef: Re,
7032
+ barWidth: je,
7033
+ barGap: F,
7034
+ isReady: ze
7035
+ } = Be(), [fe, G] = R(!1), se = T(null), he = D((L) => {
7036
+ se.current = L, ae(L);
7037
+ }, [ae]);
7038
+ let pe = Oe.length > 0 ? ee : ri;
7039
7039
  if (y?.isRecording) {
7040
- const Q = (y.startSample + y.durationSamples) / q;
7041
- pe = Math.max(pe, Q + 10);
7040
+ const q = (y.startSample + y.durationSamples) / oe;
7041
+ pe = Math.max(pe, q + 10);
7042
7042
  }
7043
- const Ie = Math.floor(pe * q / ne), Le = async (L) => {
7044
- console.log("Annotation clicked:", L.id), O(L.id);
7045
- const Q = M ? void 0 : L.end - L.start;
7046
- await ee(L.start, Q);
7043
+ const xe = Math.floor(pe * oe / j), Le = async (L) => {
7044
+ console.log("Annotation clicked:", L.id), K(L.id);
7045
+ const q = M ? void 0 : L.end - L.start;
7046
+ await re(L.start, q);
7047
7047
  }, Je = D((L) => {
7048
- if (L >= 0 && L < K.length) {
7049
- const Q = K[L];
7050
- ye(Q.id);
7048
+ if (L >= 0 && L < De.length) {
7049
+ const q = De[L];
7050
+ ye(q.id);
7051
7051
  }
7052
- }, [K, ye]), st = (L) => {
7053
- const Q = L.currentTarget.getBoundingClientRect(), le = re.show ? re.width : 0, $e = (L.clientX - Q.left - le) * ne / q, ce = L.clientY - Q.top;
7054
- let Re = 0, Me = -1;
7055
- for (let Qe = 0; Qe < Se.length; Qe++) {
7056
- const qe = Se[Qe], Ye = (qe.length > 0 ? Math.max(...qe.map((Zt) => Zt.peaks.data.length)) : 1) * me + (g ? 22 : 0);
7057
- if (ce >= Re && ce < Re + Ye) {
7058
- Me = Qe;
7052
+ }, [De, ye]), st = (L) => {
7053
+ const q = L.currentTarget.getBoundingClientRect(), ie = J.show ? J.width : 0, Se = (L.clientX - q.left - ie) * j / oe, ce = L.clientY - q.top;
7054
+ let Ee = 0, $e = -1;
7055
+ for (let Qe = 0; Qe < ke.length; Qe++) {
7056
+ const qe = ke[Qe], Ye = (qe.length > 0 ? Math.max(...qe.map((Zt) => Zt.peaks.data.length)) : 1) * de + (g ? 22 : 0);
7057
+ if (ce >= Ee && ce < Ee + Ye) {
7058
+ $e = Qe;
7059
7059
  break;
7060
7060
  }
7061
- Re += Ye;
7061
+ Ee += Ye;
7062
7062
  }
7063
- Me !== -1 && Je(Me), X(!0), be($e), ae($e, $e);
7063
+ $e !== -1 && Je($e), G(!0), be(Se), te(Se, Se);
7064
7064
  }, et = (L) => {
7065
7065
  if (!fe) return;
7066
- const Q = L.currentTarget.getBoundingClientRect(), le = re.show ? re.width : 0, $e = (L.clientX - Q.left - le) * ne / q, ze = Math.min(w, $e), ce = Math.max(w, $e);
7067
- ae(ze, ce);
7066
+ const q = L.currentTarget.getBoundingClientRect(), ie = J.show ? J.width : 0, Se = (L.clientX - q.left - ie) * j / oe, He = Math.min(C, Se), ce = Math.max(C, Se);
7067
+ te(He, ce);
7068
7068
  }, mt = (L) => {
7069
7069
  if (!fe) return;
7070
- X(!1);
7071
- const Q = L.currentTarget.getBoundingClientRect(), le = re.show ? re.width : 0, $e = (L.clientX - Q.left - le) * ne / q, ze = Math.min(w, $e), ce = Math.max(w, $e);
7072
- Math.abs(ce - ze) < 0.1 ? (be(ze), p && Ne.current ? (Ne.current.stop(), ee(ze)) : Ne.current && Ne.current.stop()) : ae(ze, ce);
7070
+ G(!1);
7071
+ const q = L.currentTarget.getBoundingClientRect(), ie = J.show ? J.width : 0, Se = (L.clientX - q.left - ie) * j / oe, He = Math.min(C, Se), ce = Math.max(C, Se);
7072
+ Math.abs(ce - He) < 0.1 ? (be(He), p && Re.current ? (Re.current.stop(), re(He)) : Re.current && Re.current.stop()) : te(He, ce);
7073
7073
  };
7074
- return K.some((L) => L.clips.length > 0) && (Oe.length === 0 || Se.length === 0) ? /* @__PURE__ */ I("div", { className: u, children: "Loading waveform..." }) : /* @__PURE__ */ I(On, { children: /* @__PURE__ */ te(
7074
+ return De.some((L) => L.clips.length > 0) && (Oe.length === 0 || ke.length === 0) ? /* @__PURE__ */ I("div", { className: u, children: "Loading waveform..." }) : /* @__PURE__ */ I(On, { children: /* @__PURE__ */ ne(
7075
7075
  Et.Provider,
7076
7076
  {
7077
7077
  value: {
7078
- samplesPerPixel: ne,
7079
- sampleRate: q,
7080
- zoomLevels: [ne],
7081
- waveHeight: me,
7082
- timeScaleHeight: Ce,
7078
+ samplesPerPixel: j,
7079
+ sampleRate: oe,
7080
+ zoomLevels: [j],
7081
+ waveHeight: de,
7082
+ timeScaleHeight: me,
7083
7083
  duration: pe,
7084
- controls: re,
7085
- barWidth: Ke,
7086
- barGap: V
7084
+ controls: J,
7085
+ barWidth: je,
7086
+ barGap: F
7087
7087
  },
7088
7088
  children: [
7089
7089
  /* @__PURE__ */ I(
@@ -7092,17 +7092,17 @@ const fr = Be(null), hr = Be(null), pr = Be(null), gr = Be(null), _i = ({
7092
7092
  theme: m,
7093
7093
  backgroundColor: at(m.waveOutlineColor),
7094
7094
  timescaleBackgroundColor: m.timescaleBackgroundColor,
7095
- scrollContainerWidth: Ie + (re.show ? re.width : 0),
7096
- timescaleWidth: Ie,
7097
- tracksWidth: Ie,
7098
- controlsWidth: re.show ? re.width : 0,
7095
+ scrollContainerWidth: xe + (J.show ? J.width : 0),
7096
+ timescaleWidth: xe,
7097
+ tracksWidth: xe,
7098
+ controlsWidth: J.show ? J.width : 0,
7099
7099
  onTracksMouseDown: st,
7100
7100
  onTracksMouseMove: et,
7101
7101
  onTracksMouseUp: mt,
7102
7102
  scrollContainerRef: he,
7103
7103
  isSelecting: fe,
7104
- "data-playlist-state": Pe ? "ready" : "loading",
7105
- timescale: Ce > 0 ? /* @__PURE__ */ te(rt, { children: [
7104
+ "data-playlist-state": ze ? "ready" : "loading",
7105
+ timescale: me > 0 ? /* @__PURE__ */ ne(rt, { children: [
7106
7106
  /* @__PURE__ */ I(
7107
7107
  jn,
7108
7108
  {
@@ -7113,41 +7113,41 @@ const fr = Be(null), hr = Be(null), pr = Be(null), gr = Be(null), _i = ({
7113
7113
  renderTimestamp: t
7114
7114
  }
7115
7115
  ),
7116
- P && /* @__PURE__ */ I(
7116
+ z && /* @__PURE__ */ I(
7117
7117
  no,
7118
7118
  {
7119
- startPosition: Math.min(T, H) * q / ne,
7120
- endPosition: Math.max(T, H) * q / ne,
7119
+ startPosition: Math.min(E, V) * oe / j,
7120
+ endPosition: Math.max(E, V) * oe / j,
7121
7121
  markerColor: m.loopMarkerColor,
7122
7122
  regionColor: m.loopRegionColor,
7123
7123
  minPosition: 0,
7124
- maxPosition: Ie,
7125
- controlsOffset: re.show ? re.width : 0,
7126
- onLoopRegionChange: (L, Q) => {
7127
- const le = L * ne / q, ve = Q * ne / q;
7128
- Ue(le, ve);
7124
+ maxPosition: xe,
7125
+ controlsOffset: J.show ? J.width : 0,
7126
+ onLoopRegionChange: (L, q) => {
7127
+ const ie = L * j / oe, ve = q * j / oe;
7128
+ Ke(ie, ve);
7129
7129
  }
7130
7130
  }
7131
7131
  )
7132
7132
  ] }) : void 0,
7133
- children: /* @__PURE__ */ te(rt, { children: [
7134
- Se.map((L, Q) => {
7135
- const le = K[Q];
7136
- if (!le) return null;
7137
- const ve = je[Q] || {
7138
- name: `Track ${Q + 1}`,
7133
+ children: /* @__PURE__ */ ne(rt, { children: [
7134
+ ke.map((L, q) => {
7135
+ const ie = De[q];
7136
+ if (!ie) return null;
7137
+ const ve = Ue[q] || {
7138
+ name: `Track ${q + 1}`,
7139
7139
  muted: !1,
7140
7140
  soloed: !1,
7141
7141
  volume: 1,
7142
7142
  pan: 0
7143
- }, $e = e ? e(Q) : /* @__PURE__ */ te(Ao, { onClick: () => Je(Q), children: [
7144
- /* @__PURE__ */ I(ko, { style: { justifyContent: "center" }, children: ve.name || `Track ${Q + 1}` }),
7145
- /* @__PURE__ */ te(Io, { children: [
7143
+ }, Se = e ? e(q) : /* @__PURE__ */ ne(Ao, { onClick: () => Je(q), children: [
7144
+ /* @__PURE__ */ I(ko, { style: { justifyContent: "center" }, children: ve.name || `Track ${q + 1}` }),
7145
+ /* @__PURE__ */ ne(Io, { children: [
7146
7146
  /* @__PURE__ */ I(
7147
7147
  gn,
7148
7148
  {
7149
7149
  $variant: ve.muted ? "danger" : "outline",
7150
- onClick: () => N(Q, !ve.muted),
7150
+ onClick: () => X(q, !ve.muted),
7151
7151
  children: "Mute"
7152
7152
  }
7153
7153
  ),
@@ -7155,12 +7155,12 @@ const fr = Be(null), hr = Be(null), pr = Be(null), gr = Be(null), _i = ({
7155
7155
  gn,
7156
7156
  {
7157
7157
  $variant: ve.soloed ? "info" : "outline",
7158
- onClick: () => Z(Q, !ve.soloed),
7158
+ onClick: () => Z(q, !ve.soloed),
7159
7159
  children: "Solo"
7160
7160
  }
7161
7161
  )
7162
7162
  ] }),
7163
- /* @__PURE__ */ te(vn, { children: [
7163
+ /* @__PURE__ */ ne(vn, { children: [
7164
7164
  /* @__PURE__ */ I(So, {}),
7165
7165
  /* @__PURE__ */ I(
7166
7166
  bn,
@@ -7169,12 +7169,12 @@ const fr = Be(null), hr = Be(null), pr = Be(null), gr = Be(null), _i = ({
7169
7169
  max: "1",
7170
7170
  step: "0.01",
7171
7171
  value: ve.volume,
7172
- onChange: (ce) => J(Q, parseFloat(ce.target.value))
7172
+ onChange: (ce) => Q(q, parseFloat(ce.target.value))
7173
7173
  }
7174
7174
  ),
7175
7175
  /* @__PURE__ */ I($o, {})
7176
7176
  ] }),
7177
- /* @__PURE__ */ te(vn, { children: [
7177
+ /* @__PURE__ */ ne(vn, { children: [
7178
7178
  /* @__PURE__ */ I("span", { children: "L" }),
7179
7179
  /* @__PURE__ */ I(
7180
7180
  bn,
@@ -7183,78 +7183,78 @@ const fr = Be(null), hr = Be(null), pr = Be(null), gr = Be(null), _i = ({
7183
7183
  max: "1",
7184
7184
  step: "0.01",
7185
7185
  value: ve.pan,
7186
- onChange: (ce) => se(Q, parseFloat(ce.target.value))
7186
+ onChange: (ce) => le(q, parseFloat(ce.target.value))
7187
7187
  }
7188
7188
  ),
7189
7189
  /* @__PURE__ */ I("span", { children: "R" })
7190
7190
  ] })
7191
- ] }), ze = L.length > 0 ? Math.max(...L.map((ce) => ce.peaks.data.length)) : 1;
7192
- return /* @__PURE__ */ I(Qt.Provider, { value: $e, children: /* @__PURE__ */ te(
7191
+ ] }), He = L.length > 0 ? Math.max(...L.map((ce) => ce.peaks.data.length)) : 1;
7192
+ return /* @__PURE__ */ I(Qt.Provider, { value: Se, children: /* @__PURE__ */ ne(
7193
7193
  Jn,
7194
7194
  {
7195
- numChannels: ze,
7195
+ numChannels: He,
7196
7196
  backgroundColor: at(m.waveOutlineColor),
7197
7197
  offset: 0,
7198
- width: Ie,
7198
+ width: xe,
7199
7199
  hasClipHeaders: g,
7200
- trackId: le.id,
7201
- isSelected: le.id === _,
7200
+ trackId: ie.id,
7201
+ isSelected: ie.id === _,
7202
7202
  children: [
7203
- L.map((ce, Re) => {
7204
- const Me = ce.peaks, Qe = Me.length;
7203
+ L.map((ce, Ee) => {
7204
+ const $e = ce.peaks, Qe = $e.length;
7205
7205
  return /* @__PURE__ */ I(
7206
7206
  Lt,
7207
7207
  {
7208
7208
  clipId: ce.clipId,
7209
- trackIndex: Q,
7210
- clipIndex: Re,
7209
+ trackIndex: q,
7210
+ clipIndex: Ee,
7211
7211
  trackName: ce.trackName,
7212
7212
  startSample: ce.startSample,
7213
7213
  durationSamples: ce.durationSamples,
7214
- samplesPerPixel: ne,
7214
+ samplesPerPixel: j,
7215
7215
  showHeader: g,
7216
7216
  disableHeaderDrag: !h,
7217
- isSelected: le.id === _,
7218
- trackId: le.id,
7217
+ isSelected: ie.id === _,
7218
+ trackId: ie.id,
7219
7219
  fadeIn: ce.fadeIn,
7220
7220
  fadeOut: ce.fadeOut,
7221
- sampleRate: q,
7221
+ sampleRate: oe,
7222
7222
  showFades: d,
7223
7223
  touchOptimized: b,
7224
7224
  onMouseDown: (qe) => {
7225
- qe.target.closest('[role="button"][aria-roledescription="draggable"]') || Je(Q);
7225
+ qe.target.closest('[role="button"][aria-roledescription="draggable"]') || Je(q);
7226
7226
  },
7227
- children: Me.data.map((qe, it) => /* @__PURE__ */ I(
7227
+ children: $e.data.map((qe, it) => /* @__PURE__ */ I(
7228
7228
  Sn,
7229
7229
  {
7230
7230
  index: it,
7231
7231
  data: qe,
7232
- bits: Me.bits,
7232
+ bits: $e.bits,
7233
7233
  length: Qe,
7234
- isSelected: le.id === _,
7234
+ isSelected: ie.id === _,
7235
7235
  clipStartSample: ce.startSample,
7236
7236
  clipDurationSamples: ce.durationSamples
7237
7237
  },
7238
- `${Q}-${Re}-${it}`
7238
+ `${q}-${Ee}-${it}`
7239
7239
  ))
7240
7240
  },
7241
- `${Q}-${Re}`
7241
+ `${q}-${Ee}`
7242
7242
  );
7243
7243
  }),
7244
- y?.isRecording && y.trackId === le.id && y.peaks.length > 0 && /* @__PURE__ */ I(
7244
+ y?.isRecording && y.trackId === ie.id && y.peaks.length > 0 && /* @__PURE__ */ I(
7245
7245
  Lt,
7246
7246
  {
7247
7247
  clipId: "recording-preview",
7248
- trackIndex: Q,
7248
+ trackIndex: q,
7249
7249
  clipIndex: L.length,
7250
7250
  trackName: "Recording...",
7251
7251
  startSample: y.startSample,
7252
7252
  durationSamples: y.durationSamples,
7253
- samplesPerPixel: ne,
7253
+ samplesPerPixel: j,
7254
7254
  showHeader: g,
7255
7255
  disableHeaderDrag: !0,
7256
- isSelected: le.id === _,
7257
- trackId: le.id,
7256
+ isSelected: ie.id === _,
7257
+ trackId: ie.id,
7258
7258
  children: /* @__PURE__ */ I(
7259
7259
  Sn,
7260
7260
  {
@@ -7262,84 +7262,84 @@ const fr = Be(null), hr = Be(null), pr = Be(null), gr = Be(null), _i = ({
7262
7262
  data: y.peaks,
7263
7263
  bits: 16,
7264
7264
  length: Math.floor(y.peaks.length / 2),
7265
- isSelected: le.id === _,
7265
+ isSelected: ie.id === _,
7266
7266
  clipStartSample: y.startSample,
7267
7267
  clipDurationSamples: y.durationSamples
7268
7268
  },
7269
- `${Q}-recording-0`
7269
+ `${q}-recording-0`
7270
7270
  )
7271
7271
  },
7272
- `${Q}-recording`
7272
+ `${q}-recording`
7273
7273
  )
7274
7274
  ]
7275
7275
  }
7276
- ) }, le.id);
7276
+ ) }, ie.id);
7277
7277
  }),
7278
- A.length > 0 && /* @__PURE__ */ I(ar, { height: 30, width: Ie, children: A.map((L, Q) => {
7279
- const le = L.start * q / ne, ve = L.end * q / ne, $e = i ? i(L, Q) : L.id;
7278
+ k.length > 0 && /* @__PURE__ */ I(ar, { height: 30, width: xe, children: k.map((L, q) => {
7279
+ const ie = L.start * oe / j, ve = L.end * oe / j, Se = i ? i(L, q) : L.id;
7280
7280
  return /* @__PURE__ */ I(
7281
7281
  rr,
7282
7282
  {
7283
7283
  annotationId: L.id,
7284
- annotationIndex: Q,
7285
- startPosition: le,
7284
+ annotationIndex: q,
7285
+ startPosition: ie,
7286
7286
  endPosition: ve,
7287
- label: $e,
7287
+ label: Se,
7288
7288
  color: "#ff9800",
7289
- isActive: L.id === $,
7289
+ isActive: L.id === B,
7290
7290
  onClick: () => Le(L),
7291
- editable: k
7291
+ editable: $
7292
7292
  },
7293
7293
  L.id
7294
7294
  );
7295
7295
  }) }),
7296
- w !== C && /* @__PURE__ */ I(
7296
+ C !== v && /* @__PURE__ */ I(
7297
7297
  Nn,
7298
7298
  {
7299
- startPosition: Math.min(w, C) * q / ne + (re.show ? re.width : 0),
7300
- endPosition: Math.max(w, C) * q / ne + (re.show ? re.width : 0),
7299
+ startPosition: Math.min(C, v) * oe / j + (J.show ? J.width : 0),
7300
+ endPosition: Math.max(C, v) * oe / j + (J.show ? J.width : 0),
7301
7301
  color: m.selectionColor
7302
7302
  }
7303
7303
  ),
7304
- (p || w === C) && (n ? (
7304
+ (p || C === v) && (n ? (
7305
7305
  // Custom playhead - pass all animation refs for smooth 60fps animation
7306
7306
  n({
7307
- position: (x.current ?? 0) * q / ne + (re.show ? re.width : 0),
7307
+ position: (x.current ?? 0) * oe / j + (J.show ? J.width : 0),
7308
7308
  color: m.playheadColor,
7309
7309
  isPlaying: p,
7310
7310
  currentTimeRef: x,
7311
- playbackStartTimeRef: v,
7311
+ playbackStartTimeRef: w,
7312
7312
  audioStartPositionRef: f,
7313
- samplesPerPixel: ne,
7314
- sampleRate: q,
7315
- controlsOffset: re.show ? re.width : 0,
7316
- getAudioContextTime: () => ke().currentTime
7313
+ samplesPerPixel: j,
7314
+ sampleRate: oe,
7315
+ controlsOffset: J.show ? J.width : 0,
7316
+ getAudioContextTime: () => Ae().currentTime
7317
7317
  })
7318
7318
  ) : /* @__PURE__ */ I(
7319
7319
  Qs,
7320
7320
  {
7321
7321
  color: m.playheadColor,
7322
- controlsOffset: re.show ? re.width : 0
7322
+ controlsOffset: J.show ? J.width : 0
7323
7323
  }
7324
7324
  ))
7325
7325
  ] })
7326
7326
  }
7327
7327
  ),
7328
- A.length > 0 && /* @__PURE__ */ I(
7328
+ k.length > 0 && /* @__PURE__ */ I(
7329
7329
  or,
7330
7330
  {
7331
- annotations: A,
7332
- activeAnnotationId: $ ?? void 0,
7331
+ annotations: k,
7332
+ activeAnnotationId: B ?? void 0,
7333
7333
  shouldScrollToActive: !0,
7334
7334
  scrollActivePosition: l,
7335
7335
  scrollActiveContainer: c,
7336
- editable: k,
7337
- controls: k ? r : void 0,
7338
- annotationListConfig: { linkEndpoints: B, continuousPlay: M },
7336
+ editable: $,
7337
+ controls: $ ? r : void 0,
7338
+ annotationListConfig: { linkEndpoints: A, continuousPlay: M },
7339
7339
  height: s,
7340
7340
  renderAnnotationItem: o,
7341
7341
  onAnnotationUpdate: (L) => {
7342
- F(L);
7342
+ P(L);
7343
7343
  }
7344
7344
  }
7345
7345
  )
@@ -7360,8 +7360,8 @@ const fr = Be(null), hr = Be(null), pr = Be(null), gr = Be(null), _i = ({
7360
7360
  color: e = "#ff0000",
7361
7361
  controlsOffset: t = 0
7362
7362
  }) => {
7363
- const n = R(null), r = R(null), { isPlaying: a, currentTimeRef: s } = qt(), { samplesPerPixel: o, sampleRate: i, progressBarWidth: l } = en();
7364
- return j(() => {
7363
+ const n = T(null), r = T(null), { isPlaying: a, currentTimeRef: s } = qt(), { samplesPerPixel: o, sampleRate: i, progressBarWidth: l } = en();
7364
+ return U(() => {
7365
7365
  const c = () => {
7366
7366
  if (n.current) {
7367
7367
  const g = (s.current ?? 0) * i / o + t;
@@ -7372,7 +7372,7 @@ const fr = Be(null), hr = Be(null), pr = Be(null), gr = Be(null), _i = ({
7372
7372
  return a ? r.current = requestAnimationFrame(c) : c(), () => {
7373
7373
  r.current && (cancelAnimationFrame(r.current), r.current = null);
7374
7374
  };
7375
- }, [a, i, o, t, s]), j(() => {
7375
+ }, [a, i, o, t, s]), U(() => {
7376
7376
  if (!a && n.current) {
7377
7377
  const u = (s.current ?? 0) * i / o + t;
7378
7378
  n.current.style.transform = `translate3d(${u}px, 0, 0)`;
@@ -7408,28 +7408,28 @@ const fr = Be(null), hr = Be(null), pr = Be(null), gr = Be(null), _i = ({
7408
7408
  clipDurationSamples: t,
7409
7409
  ...n
7410
7410
  }) => {
7411
- const r = R(null), a = R(null), s = wt(), { waveHeight: o } = vt(), { isPlaying: i, currentTimeRef: l } = qt(), { samplesPerPixel: c, sampleRate: u } = en(), g = s?.waveProgressColor || "rgba(0, 0, 0, 0.1)";
7412
- j(() => {
7411
+ const r = T(null), a = T(null), s = wt(), { waveHeight: o } = vt(), { isPlaying: i, currentTimeRef: l } = qt(), { samplesPerPixel: c, sampleRate: u } = en(), g = s?.waveProgressColor || "rgba(0, 0, 0, 0.1)";
7412
+ U(() => {
7413
7413
  const y = () => {
7414
7414
  if (r.current) {
7415
7415
  const p = (l.current ?? 0) * u, x = e + t;
7416
- let v = 0;
7416
+ let w = 0;
7417
7417
  if (p <= e)
7418
- v = 0;
7418
+ w = 0;
7419
7419
  else if (p >= x)
7420
- v = n.length;
7420
+ w = n.length;
7421
7421
  else {
7422
7422
  const f = p - e;
7423
- v = Math.floor(f / c);
7423
+ w = Math.floor(f / c);
7424
7424
  }
7425
- r.current.style.width = `${v}px`;
7425
+ r.current.style.width = `${w}px`;
7426
7426
  }
7427
7427
  i && (a.current = requestAnimationFrame(y));
7428
7428
  };
7429
7429
  return i ? a.current = requestAnimationFrame(y) : y(), () => {
7430
7430
  a.current && (cancelAnimationFrame(a.current), a.current = null);
7431
7431
  };
7432
- }, [i, u, c, e, t, n.length, l]), j(() => {
7432
+ }, [i, u, c, e, t, n.length, l]), U(() => {
7433
7433
  if (!i && r.current) {
7434
7434
  const m = (l.current ?? 0) * u, p = e + t;
7435
7435
  let x = 0;
@@ -7438,8 +7438,8 @@ const fr = Be(null), hr = Be(null), pr = Be(null), gr = Be(null), _i = ({
7438
7438
  else if (m >= p)
7439
7439
  x = n.length;
7440
7440
  else {
7441
- const v = m - e;
7442
- x = Math.floor(v / c);
7441
+ const w = m - e;
7442
+ x = Math.floor(w / c);
7443
7443
  }
7444
7444
  r.current.style.width = `${x}px`;
7445
7445
  }
@@ -7448,7 +7448,7 @@ const fr = Be(null), hr = Be(null), pr = Be(null), gr = Be(null), _i = ({
7448
7448
  let d;
7449
7449
  h === "inverted" ? d = s?.selectedWaveFillColor || s?.waveFillColor || "white" : d = s?.selectedWaveOutlineColor || s?.waveOutlineColor || "grey";
7450
7450
  const b = at(d);
7451
- return /* @__PURE__ */ te(si, { children: [
7451
+ return /* @__PURE__ */ ne(si, { children: [
7452
7452
  /* @__PURE__ */ I(
7453
7453
  ii,
7454
7454
  {
@@ -7474,195 +7474,196 @@ const fr = Be(null), hr = Be(null), pr = Be(null), gr = Be(null), _i = ({
7474
7474
  getAnnotationBoxLabel: t,
7475
7475
  renderAnnotationItem: n,
7476
7476
  editable: r = !1,
7477
- onAnnotationUpdate: a,
7478
- scrollActivePosition: s = "center",
7479
- scrollActiveContainer: o = "nearest",
7480
- className: i
7477
+ linkEndpoints: a = !1,
7478
+ onAnnotationUpdate: s,
7479
+ scrollActivePosition: o = "center",
7480
+ scrollActiveContainer: i = "nearest",
7481
+ className: l
7481
7482
  }) => {
7482
- const l = wt(), { isPlaying: c, currentTimeRef: u } = qt(), { annotations: g, activeAnnotationId: h, continuousPlay: d } = Ks(), { play: b, seekTo: y, setActiveAnnotationId: m, setAnnotations: p, setScrollContainer: x } = Us(), {
7483
- duration: v,
7484
- peaksDataArray: f,
7485
- sampleRate: w,
7486
- waveHeight: C,
7487
- timeScaleHeight: A,
7483
+ const c = wt(), { isPlaying: u, currentTimeRef: g } = qt(), { annotations: h, activeAnnotationId: d, continuousPlay: b } = Ks(), { play: y, seekTo: m, setActiveAnnotationId: p, setAnnotations: x, setScrollContainer: w } = Us(), {
7484
+ duration: f,
7485
+ peaksDataArray: C,
7486
+ sampleRate: v,
7487
+ waveHeight: k,
7488
+ timeScaleHeight: B,
7488
7489
  samplesPerPixel: $,
7489
- controls: k,
7490
- playoutRef: B,
7491
- barWidth: M,
7492
- barGap: _
7493
- } = en(), [T, H] = E(0), [P, F] = E(0), [O, N] = E(!1), Z = R(null), J = D((K) => {
7494
- Z.current = K, x(K);
7495
- }, [x]), se = Math.floor(v * w / $), ae = D(async (K) => {
7496
- m(K.id), b(K.start);
7497
- }, [m, b]), ee = D((K) => {
7498
- p(K), a?.(K);
7499
- }, [p, a]), { onDragStart: oe, onDragMove: ye, onDragEnd: be } = Is({
7500
- annotations: g,
7501
- onAnnotationsChange: ee,
7490
+ controls: A,
7491
+ playoutRef: M,
7492
+ barWidth: _,
7493
+ barGap: E
7494
+ } = en(), [V, z] = R(0), [P, K] = R(0), [X, Z] = R(!1), Q = T(null), le = D((ee) => {
7495
+ Q.current = ee, w(ee);
7496
+ }, [w]), te = Math.floor(f * v / $), re = D(async (ee) => {
7497
+ p(ee.id), y(ee.start);
7498
+ }, [p, y]), ae = D((ee) => {
7499
+ x(ee), s?.(ee);
7500
+ }, [x, s]), { onDragStart: ye, onDragMove: be, onDragEnd: Ke } = Is({
7501
+ annotations: h,
7502
+ onAnnotationsChange: ae,
7502
7503
  samplesPerPixel: $,
7503
- sampleRate: w,
7504
- duration: v,
7505
- linkEndpoints: !0
7506
- }), Ue = D((K) => {
7507
- const de = K.currentTarget.getBoundingClientRect(), ne = k.show ? k.width : 0, me = (K.clientX - de.left - ne) * $ / w;
7508
- N(!0), H(me), F(me);
7509
- }, [k, $, w]), Oe = D((K) => {
7510
- if (!O) return;
7511
- const de = K.currentTarget.getBoundingClientRect(), ne = k.show ? k.width : 0, me = (K.clientX - de.left - ne) * $ / w;
7512
- F(me);
7513
- }, [O, k, $, w]), Se = D((K) => {
7514
- if (!O) return;
7515
- N(!1);
7516
- const de = K.currentTarget.getBoundingClientRect(), ne = k.show ? k.width : 0, me = (K.clientX - de.left - ne) * $ / w, Ce = Math.min(T, me), re = Math.max(T, me);
7517
- Math.abs(re - Ce) < 0.1 ? (y(Ce), H(Ce), F(Ce), c && B.current && (B.current.stop(), b(Ce))) : (H(Ce), F(re));
7518
- }, [O, T, $, w, k, y, c, B, b]);
7519
- if (f.length === 0)
7520
- return /* @__PURE__ */ I("div", { className: i, children: "Loading waveform..." });
7521
- const je = null;
7522
- return /* @__PURE__ */ I(On, { children: /* @__PURE__ */ te(
7504
+ sampleRate: v,
7505
+ duration: f,
7506
+ linkEndpoints: a
7507
+ }), Oe = D((ee) => {
7508
+ const j = ee.currentTarget.getBoundingClientRect(), oe = A.show ? A.width : 0, me = (ee.clientX - j.left - oe) * $ / v;
7509
+ Z(!0), z(me), K(me);
7510
+ }, [A, $, v]), ke = D((ee) => {
7511
+ if (!X) return;
7512
+ const j = ee.currentTarget.getBoundingClientRect(), oe = A.show ? A.width : 0, me = (ee.clientX - j.left - oe) * $ / v;
7513
+ K(me);
7514
+ }, [X, A, $, v]), Ue = D((ee) => {
7515
+ if (!X) return;
7516
+ Z(!1);
7517
+ const j = ee.currentTarget.getBoundingClientRect(), oe = A.show ? A.width : 0, me = (ee.clientX - j.left - oe) * $ / v, J = Math.min(V, me), Re = Math.max(V, me);
7518
+ Math.abs(Re - J) < 0.1 ? (m(J), z(J), K(J), u && M.current && (M.current.stop(), y(J))) : (z(J), K(Re));
7519
+ }, [X, V, $, v, A, m, u, M, y]);
7520
+ if (C.length === 0)
7521
+ return /* @__PURE__ */ I("div", { className: l, children: "Loading waveform..." });
7522
+ const De = null;
7523
+ return /* @__PURE__ */ I(On, { children: /* @__PURE__ */ ne(
7523
7524
  Et.Provider,
7524
7525
  {
7525
7526
  value: {
7526
7527
  samplesPerPixel: $,
7527
- sampleRate: w,
7528
+ sampleRate: v,
7528
7529
  zoomLevels: [$],
7529
- waveHeight: C,
7530
- timeScaleHeight: A,
7531
- duration: v,
7532
- controls: k,
7533
- barWidth: M,
7534
- barGap: _
7530
+ waveHeight: k,
7531
+ timeScaleHeight: B,
7532
+ duration: f,
7533
+ controls: A,
7534
+ barWidth: _,
7535
+ barGap: E
7535
7536
  },
7536
7537
  children: [
7537
7538
  /* @__PURE__ */ I(
7538
7539
  Jt,
7539
7540
  {
7540
- theme: l,
7541
- backgroundColor: at(l.waveOutlineColor),
7542
- timescaleBackgroundColor: l.timescaleBackgroundColor,
7543
- scrollContainerWidth: se + (k.show ? k.width : 0),
7544
- timescaleWidth: se,
7545
- tracksWidth: se,
7546
- controlsWidth: k.show ? k.width : 0,
7547
- onTracksMouseDown: Ue,
7548
- onTracksMouseMove: Oe,
7549
- onTracksMouseUp: Se,
7550
- scrollContainerRef: J,
7551
- isSelecting: O,
7552
- timescale: A > 0 ? /* @__PURE__ */ I(
7541
+ theme: c,
7542
+ backgroundColor: at(c.waveOutlineColor),
7543
+ timescaleBackgroundColor: c.timescaleBackgroundColor,
7544
+ scrollContainerWidth: te + (A.show ? A.width : 0),
7545
+ timescaleWidth: te,
7546
+ tracksWidth: te,
7547
+ controlsWidth: A.show ? A.width : 0,
7548
+ onTracksMouseDown: Oe,
7549
+ onTracksMouseMove: ke,
7550
+ onTracksMouseUp: Ue,
7551
+ scrollContainerRef: le,
7552
+ isSelecting: X,
7553
+ timescale: B > 0 ? /* @__PURE__ */ I(
7553
7554
  jn,
7554
7555
  {
7555
- duration: v * 1e3,
7556
+ duration: f * 1e3,
7556
7557
  marker: 1e4,
7557
7558
  bigStep: 5e3,
7558
7559
  secondStep: 1e3
7559
7560
  }
7560
7561
  ) : void 0,
7561
- children: /* @__PURE__ */ te(rt, { children: [
7562
- f.map((K, de) => {
7563
- const ne = K.length > 0 ? Math.max(...K.map((q) => q.peaks.data.length)) : 1;
7564
- return /* @__PURE__ */ I(Qt.Provider, { value: je, children: /* @__PURE__ */ I(
7562
+ children: /* @__PURE__ */ ne(rt, { children: [
7563
+ C.map((ee, j) => {
7564
+ const oe = ee.length > 0 ? Math.max(...ee.map((de) => de.peaks.data.length)) : 1;
7565
+ return /* @__PURE__ */ I(Qt.Provider, { value: De, children: /* @__PURE__ */ I(
7565
7566
  Jn,
7566
7567
  {
7567
- numChannels: ne,
7568
- backgroundColor: at(l.waveOutlineColor),
7568
+ numChannels: oe,
7569
+ backgroundColor: at(c.waveOutlineColor),
7569
7570
  offset: 0,
7570
- width: se,
7571
+ width: te,
7571
7572
  hasClipHeaders: !1,
7572
- trackId: `media-element-track-${de}`,
7573
+ trackId: `media-element-track-${j}`,
7573
7574
  isSelected: !0,
7574
- children: K.map((q, me) => {
7575
- const Ce = q.peaks, re = Ce.length;
7575
+ children: ee.map((de, me) => {
7576
+ const J = de.peaks, Re = J.length;
7576
7577
  return /* @__PURE__ */ I(
7577
7578
  Lt,
7578
7579
  {
7579
- clipId: q.clipId,
7580
- trackIndex: de,
7580
+ clipId: de.clipId,
7581
+ trackIndex: j,
7581
7582
  clipIndex: me,
7582
- trackName: q.trackName,
7583
- startSample: q.startSample,
7584
- durationSamples: q.durationSamples,
7583
+ trackName: de.trackName,
7584
+ startSample: de.startSample,
7585
+ durationSamples: de.durationSamples,
7585
7586
  samplesPerPixel: $,
7586
7587
  showHeader: !1,
7587
7588
  disableHeaderDrag: !0,
7588
7589
  isSelected: !0,
7589
- trackId: `media-element-track-${de}`,
7590
- children: Ce.data.map((Ne, Ke) => /* @__PURE__ */ I(
7590
+ trackId: `media-element-track-${j}`,
7591
+ children: J.data.map((je, F) => /* @__PURE__ */ I(
7591
7592
  ui,
7592
7593
  {
7593
- index: Ke,
7594
- data: Ne,
7595
- bits: Ce.bits,
7596
- length: re,
7597
- clipStartSample: q.startSample,
7598
- clipDurationSamples: q.durationSamples
7594
+ index: F,
7595
+ data: je,
7596
+ bits: J.bits,
7597
+ length: Re,
7598
+ clipStartSample: de.startSample,
7599
+ clipDurationSamples: de.durationSamples
7599
7600
  },
7600
- `${de}-${me}-${Ke}`
7601
+ `${j}-${me}-${F}`
7601
7602
  ))
7602
7603
  },
7603
- `${de}-${me}`
7604
+ `${j}-${me}`
7604
7605
  );
7605
7606
  })
7606
7607
  }
7607
- ) }, de);
7608
+ ) }, j);
7608
7609
  }),
7609
- g.length > 0 && /* @__PURE__ */ I(
7610
+ h.length > 0 && /* @__PURE__ */ I(
7610
7611
  pa,
7611
7612
  {
7612
- onDragStart: oe,
7613
- onDragMove: ye,
7614
- onDragEnd: be,
7613
+ onDragStart: ye,
7614
+ onDragMove: be,
7615
+ onDragEnd: Ke,
7615
7616
  modifiers: r ? [ga] : [],
7616
- children: /* @__PURE__ */ I(ar, { height: 30, width: se, children: g.map((K, de) => {
7617
- const ne = K.start * w / $, q = K.end * w / $, me = t ? t(K, de) : K.id;
7617
+ children: /* @__PURE__ */ I(ar, { height: 30, width: te, children: h.map((ee, j) => {
7618
+ const oe = ee.start * v / $, de = ee.end * v / $, me = t ? t(ee, j) : ee.id;
7618
7619
  return /* @__PURE__ */ I(
7619
7620
  rr,
7620
7621
  {
7621
- annotationId: K.id,
7622
- annotationIndex: de,
7623
- startPosition: ne,
7624
- endPosition: q,
7622
+ annotationId: ee.id,
7623
+ annotationIndex: j,
7624
+ startPosition: oe,
7625
+ endPosition: de,
7625
7626
  label: me,
7626
7627
  color: "#ff9800",
7627
- isActive: K.id === h,
7628
- onClick: () => ae(K),
7628
+ isActive: ee.id === d,
7629
+ onClick: () => re(ee),
7629
7630
  editable: r
7630
7631
  },
7631
- K.id
7632
+ ee.id
7632
7633
  );
7633
7634
  }) })
7634
7635
  }
7635
7636
  ),
7636
- T !== P && /* @__PURE__ */ I(
7637
+ V !== P && /* @__PURE__ */ I(
7637
7638
  Nn,
7638
7639
  {
7639
- startPosition: Math.min(T, P) * w / $ + (k.show ? k.width : 0),
7640
- endPosition: Math.max(T, P) * w / $ + (k.show ? k.width : 0),
7641
- color: l.selectionColor
7640
+ startPosition: Math.min(V, P) * v / $ + (A.show ? A.width : 0),
7641
+ endPosition: Math.max(V, P) * v / $ + (A.show ? A.width : 0),
7642
+ color: c.selectionColor
7642
7643
  }
7643
7644
  ),
7644
7645
  /* @__PURE__ */ I(
7645
7646
  oi,
7646
7647
  {
7647
- color: l.playheadColor,
7648
- controlsOffset: k.show ? k.width : 0
7648
+ color: c.playheadColor,
7649
+ controlsOffset: A.show ? A.width : 0
7649
7650
  }
7650
7651
  )
7651
7652
  ] })
7652
7653
  }
7653
7654
  ),
7654
- g.length > 0 && /* @__PURE__ */ I(
7655
+ h.length > 0 && /* @__PURE__ */ I(
7655
7656
  or,
7656
7657
  {
7657
- annotations: g,
7658
- activeAnnotationId: h ?? void 0,
7658
+ annotations: h,
7659
+ activeAnnotationId: d ?? void 0,
7659
7660
  shouldScrollToActive: !0,
7660
- scrollActivePosition: s,
7661
- scrollActiveContainer: o,
7661
+ scrollActivePosition: o,
7662
+ scrollActiveContainer: i,
7662
7663
  editable: r,
7663
- annotationListConfig: { linkEndpoints: !0, continuousPlay: d },
7664
+ annotationListConfig: { linkEndpoints: a, continuousPlay: b },
7664
7665
  height: e,
7665
- onAnnotationUpdate: ee,
7666
+ onAnnotationUpdate: ae,
7666
7667
  renderAnnotationItem: n
7667
7668
  }
7668
7669
  )
@@ -7723,11 +7724,11 @@ export {
7723
7724
  Us as useMediaElementControls,
7724
7725
  en as useMediaElementData,
7725
7726
  Ks as useMediaElementState,
7726
- Fe as usePlaybackAnimation,
7727
+ Ze as usePlaybackAnimation,
7727
7728
  ki as usePlaybackShortcuts,
7728
7729
  ge as usePlaylistControls,
7729
- De as usePlaylistData,
7730
- Ge as usePlaylistState,
7730
+ Be as usePlaylistData,
7731
+ Ne as usePlaylistState,
7731
7732
  bs as useTimeFormat,
7732
7733
  Ri as useTrackDynamicEffects,
7733
7734
  Wi as useWaveformPlaylist,