@fxi/zartigl 0.10.5 → 0.11.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.
@@ -1,45 +1,45 @@
1
1
  import "./backdrop-Dceb4d8E.js";
2
- const te = { label: "Thermal", tags: ["sequential", "temperature"], colors: ["#042333", "#2c3395", "#744796", "#b15f82", "#eb7958", "#fbb43d", "#e8fa5b"] }, ie = { label: "Haline", tags: ["sequential", "salinity"], colors: ["#2a186c", "#17568b", "#1a7e8f", "#22a785", "#55c666", "#aadc32", "#fde333"] }, re = { label: "Solar", tags: ["sequential", "irradiance"], colors: ["#330f0b", "#6b2313", "#a83c12", "#d6621a", "#f3951e", "#f7c741", "#f9f871"] }, ne = { label: "Ice", tags: ["sequential"], colors: ["#040d1a", "#123365", "#1c5f9e", "#2b8ece", "#62bde3", "#aaddf2", "#f2faff"] }, ae = { label: "Deep", tags: ["sequential", "depth"], colors: ["#fdfecc", "#c8e59b", "#74c8a3", "#3194b0", "#2a5b8e", "#281a5e", "#0c0820"] }, se = { label: "RdYlBu", tags: ["diverging"], colors: ["#3288bd", "#66c2a5", "#abdda4", "#e6f598", "#fee08b", "#fdae61", "#f46d43", "#d53e4f"] }, oe = { label: "Dense", tags: ["sequential"], colors: ["#e6f1f1", "#92c4ca", "#44929a", "#20627a", "#1a3c6a", "#211a50", "#0d0621"] }, ce = { label: "Algae", tags: ["sequential", "biology", "log"], colors: ["#d7f9d0", "#a2d595", "#64b463", "#129450", "#126e45", "#1a482f", "#122414"] }, le = { label: "Oxygen", tags: ["sequential", "biology", "hypoxia"], colors: ["#09060f", "#5b1028", "#d43d2f", "#f39b3d", "#f3e7b3", "#79cbd1", "#176b9c"] }, de = { label: "Matter", tags: ["sequential", "biology"], colors: ["#fdfecc", "#f2c98a", "#e07c4e", "#bc3754", "#8d1a6d", "#51156b", "#1c0c3f"] }, he = { label: "Viridis", tags: ["sequential", "perceptual"], colors: ["#440154", "#443983", "#31688e", "#21918c", "#35b779", "#90d743", "#fde725"] }, ue = { label: "Plasma", tags: ["sequential", "perceptual"], colors: ["#0d0887", "#5e01a6", "#9c179e", "#cc4778", "#ed7953", "#fdb42f", "#f0f921"] }, fe = { label: "Cyclic", tags: ["cyclic", "direction"], colors: ["#2e22ea", "#b541fb", "#fc93c0", "#f1ee35", "#77c80d", "#458776", "#2c24e9"] }, me = { label: "Tempo", tags: ["sequential"], colors: ["#fff6f4", "#c2d1b9", "#7db390", "#2a937f", "#156d73", "#1c455b", "#151d44"] }, Ee = { label: "Turbid", tags: ["sequential", "biology", "log"], colors: ["#e9f5a0", "#c8c86e", "#a09845", "#786031", "#533324", "#341423", "#150d17"] }, pe = { label: "Speed", tags: ["sequential", "velocity"], colors: ["#fcfea4", "#d5e429", "#94c63e", "#52a657", "#2d8169", "#1d5b6d", "#0d3361"] }, Te = { label: "Amp", tags: ["sequential"], colors: ["#f2f2f2", "#c0b8db", "#9180b6", "#6c4e9e", "#4e2e83", "#32185d", "#110a35"] }, ge = { label: "Heat", tags: ["sequential"], colors: ["#fde725", "#fde725", "#f8961e", "#e63946", "#9d0208", "#3a0007"] }, be = { label: "Balance", tags: ["diverging"], colors: ["#181c43", "#3066af", "#9bbcdd", "#f2f2f2", "#e07d53", "#b13626", "#2c0b0e"] }, Re = { label: "Delta", tags: ["diverging"], colors: ["#0e3f31", "#20877b", "#99d4c1", "#f2f2f2", "#a1b0d4", "#3c5b9e", "#0d1938"] }, _e = { label: "Curl", tags: ["diverging"], colors: ["#152237", "#2471b3", "#8dbac4", "#f2f2f2", "#c79f84", "#a63827", "#270b17"] }, xe = { label: "Gray", tags: ["sequential"], colors: ["#000000", "#252525", "#4d4d4d", "#7a7a7a", "#a8a8a8", "#d4d4d4", "#ffffff"] }, z = {
3
- thermal: te,
2
+ const Te = { label: "Thermal", tags: ["sequential", "temperature"], colors: ["#042333", "#2c3395", "#744796", "#b15f82", "#eb7958", "#fbb43d", "#e8fa5b"] }, be = { label: "Haline", tags: ["sequential", "salinity"], colors: ["#2a186c", "#17568b", "#1a7e8f", "#22a785", "#55c666", "#aadc32", "#fde333"] }, we = { label: "Solar", tags: ["sequential", "irradiance"], colors: ["#330f0b", "#6b2313", "#a83c12", "#d6621a", "#f3951e", "#f7c741", "#f9f871"] }, ye = { label: "Ice", tags: ["sequential"], colors: ["#040d1a", "#123365", "#1c5f9e", "#2b8ece", "#62bde3", "#aaddf2", "#f2faff"] }, _e = { label: "Deep", tags: ["sequential", "depth"], colors: ["#fdfecc", "#c8e59b", "#74c8a3", "#3194b0", "#2a5b8e", "#281a5e", "#0c0820"] }, Re = { label: "RdYlBu", tags: ["diverging"], colors: ["#3288bd", "#66c2a5", "#abdda4", "#e6f598", "#fee08b", "#fdae61", "#f46d43", "#d53e4f"] }, xe = { label: "Dense", tags: ["sequential"], colors: ["#e6f1f1", "#92c4ca", "#44929a", "#20627a", "#1a3c6a", "#211a50", "#0d0621"] }, ve = { label: "Algae", tags: ["sequential", "biology", "log"], colors: ["#d7f9d0", "#a2d595", "#64b463", "#129450", "#126e45", "#1a482f", "#122414"] }, ke = { label: "Oxygen", tags: ["sequential", "biology", "hypoxia"], colors: ["#09060f", "#5b1028", "#d43d2f", "#f39b3d", "#f3e7b3", "#79cbd1", "#176b9c"] }, Ae = { label: "Matter", tags: ["sequential", "biology"], colors: ["#fdfecc", "#f2c98a", "#e07c4e", "#bc3754", "#8d1a6d", "#51156b", "#1c0c3f"] }, Fe = { label: "Viridis", tags: ["sequential", "perceptual"], colors: ["#440154", "#443983", "#31688e", "#21918c", "#35b779", "#90d743", "#fde725"] }, Se = { label: "Plasma", tags: ["sequential", "perceptual"], colors: ["#0d0887", "#5e01a6", "#9c179e", "#cc4778", "#ed7953", "#fdb42f", "#f0f921"] }, Ue = { label: "Cyclic", tags: ["cyclic", "direction"], colors: ["#2e22ea", "#b541fb", "#fc93c0", "#f1ee35", "#77c80d", "#458776", "#2c24e9"] }, Me = { label: "Tempo", tags: ["sequential"], colors: ["#fff6f4", "#c2d1b9", "#7db390", "#2a937f", "#156d73", "#1c455b", "#151d44"] }, Pe = { label: "Turbid", tags: ["sequential", "biology", "log"], colors: ["#e9f5a0", "#c8c86e", "#a09845", "#786031", "#533324", "#341423", "#150d17"] }, De = { label: "Speed", tags: ["sequential", "velocity"], colors: ["#fcfea4", "#d5e429", "#94c63e", "#52a657", "#2d8169", "#1d5b6d", "#0d3361"] }, Ge = { label: "Amp", tags: ["sequential"], colors: ["#f2f2f2", "#c0b8db", "#9180b6", "#6c4e9e", "#4e2e83", "#32185d", "#110a35"] }, Ne = { label: "Heat", tags: ["sequential"], colors: ["#fde725", "#fde725", "#f8961e", "#e63946", "#9d0208", "#3a0007"] }, Ie = { label: "Balance", tags: ["diverging"], colors: ["#181c43", "#3066af", "#9bbcdd", "#f2f2f2", "#e07d53", "#b13626", "#2c0b0e"] }, Le = { label: "Delta", tags: ["diverging"], colors: ["#0e3f31", "#20877b", "#99d4c1", "#f2f2f2", "#a1b0d4", "#3c5b9e", "#0d1938"] }, Ce = { label: "Curl", tags: ["diverging"], colors: ["#152237", "#2471b3", "#8dbac4", "#f2f2f2", "#c79f84", "#a63827", "#270b17"] }, Ve = { label: "Gray", tags: ["sequential"], colors: ["#000000", "#252525", "#4d4d4d", "#7a7a7a", "#a8a8a8", "#d4d4d4", "#ffffff"] }, he = {
3
+ thermal: Te,
4
4
  "thermal-alt": { label: "Thermal Alt", tags: ["sequential", "temperature"], colors: ["#176b9c", "#79cbd1", "#f3e7b3", "#f39b3d", "#d43d2f", "#5b1028", "#09060f"] },
5
- haline: ie,
6
- solar: re,
7
- ice: ne,
8
- deep: ae,
9
- rdylbu: se,
10
- dense: oe,
11
- algae: ce,
12
- oxygen: le,
13
- matter: de,
14
- viridis: he,
15
- plasma: ue,
16
- cyclic: fe,
17
- tempo: me,
18
- turbid: Ee,
19
- speed: pe,
20
- amp: Te,
21
- heat: ge,
5
+ haline: be,
6
+ solar: we,
7
+ ice: ye,
8
+ deep: _e,
9
+ rdylbu: Re,
10
+ dense: xe,
11
+ algae: ve,
12
+ oxygen: ke,
13
+ matter: Ae,
14
+ viridis: Fe,
15
+ plasma: Se,
16
+ cyclic: Ue,
17
+ tempo: Me,
18
+ turbid: Pe,
19
+ speed: De,
20
+ amp: Ge,
21
+ heat: Ne,
22
22
  "heat-alert": { label: "Heat Alert", tags: ["sequential", "alpha", "deprecated"], colors: ["#fde72500", "#fde725cc", "#f8961e", "#e63946", "#9d0208", "#3a0007"] },
23
- balance: be,
24
- delta: Re,
25
- curl: _e,
23
+ balance: Ie,
24
+ delta: Le,
25
+ curl: Ce,
26
26
  "mono-black": { label: "Black", tags: ["monochrome", "particles"], colors: ["#000000", "#000000"] },
27
27
  "mono-white": { label: "White", tags: ["monochrome", "particles"], colors: ["#ffffff", "#ffffff"] },
28
28
  "mono-pink": { label: "Pink", tags: ["monochrome", "particles"], colors: ["#ff2aa1", "#ff2aa1"] },
29
- gray: xe
30
- }, O = 64, we = {
29
+ gray: Ve
30
+ }, ie = 64, Oe = {
31
31
  linear: (t) => t,
32
32
  // Rises fast: values just inside the zone already show.
33
33
  log: (t) => Math.log10(1 + 9 * t),
34
34
  // Stays faint longer: codec noise at the end of the range stays hidden.
35
35
  exp: (t) => (10 ** t - 1) / 9
36
36
  };
37
- function ye(t, e) {
38
- const i = we[e.curve ?? "linear"], r = e.low ?? 0, n = e.high ?? 0;
39
- let a = 1;
40
- return r > 0 && t < r && (a = Math.min(a, i(Math.max(t, 0) / r))), n > 0 && t > 1 - n && (a = Math.min(a, i(Math.max(1 - t, 0) / n))), a;
37
+ function Be(t, e) {
38
+ const i = Oe[e.curve ?? "linear"], r = e.low ?? 0, n = e.high ?? 0;
39
+ let s = 1;
40
+ return r > 0 && t < r && (s = Math.min(s, i(Math.max(t, 0) / r))), n > 0 && t > 1 - n && (s = Math.min(s, i(Math.max(1 - t, 0) / n))), s;
41
41
  }
42
- function ve(t) {
42
+ function Xe(t) {
43
43
  let e = t.replace("#", "");
44
44
  (e.length === 3 || e.length === 4) && (e = [...e].map((r) => r + r).join(""));
45
45
  const i = (r) => parseInt(e.slice(r, r + 2), 16);
@@ -50,46 +50,46 @@ function ve(t) {
50
50
  e.length === 8 ? i(6) : 255
51
51
  ];
52
52
  }
53
- function Ae([t, e, i, r]) {
53
+ function qe([t, e, i, r]) {
54
54
  return `#${[t, e, i, r].map(
55
55
  (n) => Math.round(Math.min(255, Math.max(0, n))).toString(16).padStart(2, "0")
56
56
  ).join("")}`;
57
57
  }
58
- function ke(t, e) {
58
+ function $e(t, e) {
59
59
  if (e <= t[0][0])
60
60
  return t[0][1];
61
61
  for (let i = 1; i < t.length; i++) {
62
62
  const [r, n] = t[i];
63
63
  if (e <= r) {
64
- const [a, o] = t[i - 1], s = r === a ? 1 : (e - a) / (r - a);
65
- return o.map((l, c) => l + (n[c] - l) * s);
64
+ const [s, o] = t[i - 1], a = r === s ? 1 : (e - s) / (r - s);
65
+ return o.map((d, c) => d + (n[c] - d) * a);
66
66
  }
67
67
  }
68
68
  return t[t.length - 1][1];
69
69
  }
70
- function Fe(t, e) {
70
+ function We(t, e) {
71
71
  const i = Object.entries(t).map(
72
- ([n, a]) => [Number(n), ve(a)]
73
- ).sort((n, a) => n[0] - a[0]), r = {};
74
- for (let n = 0; n <= O; n++) {
75
- const a = n / O, [o, s, l, c] = ke(i, a);
76
- r[a] = Ae([o, s, l, c * ye(a, e)]);
72
+ ([n, s]) => [Number(n), Xe(s)]
73
+ ).sort((n, s) => n[0] - s[0]), r = {};
74
+ for (let n = 0; n <= ie; n++) {
75
+ const s = n / ie, [o, a, d, c] = $e(i, s);
76
+ r[s] = qe([o, a, d, c * Be(s, e)]);
77
77
  }
78
78
  return r;
79
79
  }
80
- const Se = (t) => !!t && ((t.low ?? 0) > 0 || (t.high ?? 0) > 0);
81
- function B(t) {
80
+ const He = (t) => !!t && ((t.low ?? 0) > 0 || (t.high ?? 0) > 0);
81
+ function re(t) {
82
82
  const e = {}, i = t.length - 1;
83
83
  return t.forEach((r, n) => {
84
84
  e[i === 0 ? 0 : n / i] = r;
85
85
  }), e;
86
86
  }
87
- function De(t, e) {
88
- const i = Ue(t, e?.reverse ?? !1);
89
- return Se(e?.alphaFade) ? Fe(i, e.alphaFade) : i;
87
+ function ze(t, e) {
88
+ const i = Ye(t, e?.reverse ?? !1);
89
+ return He(e?.alphaFade) ? We(i, e.alphaFade) : i;
90
90
  }
91
- function Ue(t, e) {
92
- const i = z;
91
+ function Ye(t, e) {
92
+ const i = he;
93
93
  if (typeof t == "string") {
94
94
  const r = i[t];
95
95
  if (!r)
@@ -99,22 +99,22 @@ function Ue(t, e) {
99
99
  ).join(", ")}`
100
100
  );
101
101
  const n = e ? [...r.colors].reverse() : r.colors;
102
- return B(n);
102
+ return re(n);
103
103
  }
104
104
  if (Array.isArray(t)) {
105
105
  const r = e ? [...t].reverse() : t;
106
- return B(r);
106
+ return re(r);
107
107
  }
108
108
  return e ? Object.fromEntries(
109
109
  Object.entries(t).map(([r, n]) => [1 - Number(r), n])
110
110
  ) : t;
111
111
  }
112
- function Ft(t = {}) {
113
- return Object.entries(z).map(([i, r]) => ({ id: i, ...r })).filter(
112
+ function jt(t = {}) {
113
+ return Object.entries(he).map(([i, r]) => ({ id: i, ...r })).filter(
114
114
  (i) => t.includeDeprecated || !i.tags.includes("deprecated")
115
115
  );
116
116
  }
117
- function X(t, e, i) {
117
+ function ne(t, e, i) {
118
118
  const r = t.createShader(e);
119
119
  if (!r)
120
120
  throw new Error("Failed to create shader");
@@ -124,22 +124,22 @@ function X(t, e, i) {
124
124
  }
125
125
  return r;
126
126
  }
127
- function St(t, e, i) {
127
+ function Kt(t, e, i) {
128
128
  const r = t.createProgram();
129
129
  if (!r)
130
130
  throw new Error("Failed to create program");
131
- const n = X(t, t.VERTEX_SHADER, e), a = X(t, t.FRAGMENT_SHADER, i);
132
- if (t.attachShader(r, n), t.attachShader(r, a), t.linkProgram(r), !t.getProgramParameter(r, t.LINK_STATUS)) {
131
+ const n = ne(t, t.VERTEX_SHADER, e), s = ne(t, t.FRAGMENT_SHADER, i);
132
+ if (t.attachShader(r, n), t.attachShader(r, s), t.linkProgram(r), !t.getProgramParameter(r, t.LINK_STATUS)) {
133
133
  const o = t.getProgramInfoLog(r);
134
134
  throw t.deleteProgram(r), new Error(`Program link error: ${o}`);
135
135
  }
136
- return t.deleteShader(n), t.deleteShader(a), r;
136
+ return t.deleteShader(n), t.deleteShader(s), r;
137
137
  }
138
- function Dt(t, e, i, r, n) {
139
- const a = t.createTexture();
140
- if (!a)
138
+ function Qt(t, e, i, r, n) {
139
+ const s = t.createTexture();
140
+ if (!s)
141
141
  throw new Error("Failed to create texture");
142
- return t.bindTexture(t.TEXTURE_2D, a), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_S, t.CLAMP_TO_EDGE), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_T, t.CLAMP_TO_EDGE), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MIN_FILTER, e), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MAG_FILTER, e), t.texImage2D(
142
+ return t.bindTexture(t.TEXTURE_2D, s), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_S, t.CLAMP_TO_EDGE), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_T, t.CLAMP_TO_EDGE), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MIN_FILTER, e), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MAG_FILTER, e), t.texImage2D(
143
143
  t.TEXTURE_2D,
144
144
  0,
145
145
  t.RGBA,
@@ -149,19 +149,19 @@ function Dt(t, e, i, r, n) {
149
149
  t.RGBA,
150
150
  t.UNSIGNED_BYTE,
151
151
  i
152
- ), t.bindTexture(t.TEXTURE_2D, null), a;
152
+ ), t.bindTexture(t.TEXTURE_2D, null), s;
153
153
  }
154
- function Pe(t, e, i) {
154
+ function je(t, e, i) {
155
155
  const r = t.getParameter(
156
156
  t.TEXTURE_BINDING_2D
157
157
  ), n = t.getParameter(
158
158
  t.FRAMEBUFFER_BINDING
159
- ), a = t.createTexture(), o = t.createFramebuffer();
160
- if (!a || !o)
161
- return a && t.deleteTexture(a), o && t.deleteFramebuffer(o), t.bindTexture(t.TEXTURE_2D, r), t.bindFramebuffer(t.FRAMEBUFFER, n), !1;
162
- let s = !1;
159
+ ), s = t.createTexture(), o = t.createFramebuffer();
160
+ if (!s || !o)
161
+ return s && t.deleteTexture(s), o && t.deleteFramebuffer(o), t.bindTexture(t.TEXTURE_2D, r), t.bindFramebuffer(t.FRAMEBUFFER, n), !1;
162
+ let a = !1;
163
163
  try {
164
- t.bindTexture(t.TEXTURE_2D, a), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_S, t.CLAMP_TO_EDGE), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_T, t.CLAMP_TO_EDGE), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MIN_FILTER, t.NEAREST), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MAG_FILTER, t.NEAREST), t.texImage2D(
164
+ t.bindTexture(t.TEXTURE_2D, s), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_S, t.CLAMP_TO_EDGE), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_T, t.CLAMP_TO_EDGE), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MIN_FILTER, t.NEAREST), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MAG_FILTER, t.NEAREST), t.texImage2D(
165
165
  t.TEXTURE_2D,
166
166
  0,
167
167
  e,
@@ -175,27 +175,27 @@ function Pe(t, e, i) {
175
175
  t.FRAMEBUFFER,
176
176
  t.COLOR_ATTACHMENT0,
177
177
  t.TEXTURE_2D,
178
- a,
178
+ s,
179
179
  0
180
- ), s = t.checkFramebufferStatus(t.FRAMEBUFFER) === t.FRAMEBUFFER_COMPLETE;
180
+ ), a = t.checkFramebufferStatus(t.FRAMEBUFFER) === t.FRAMEBUFFER_COMPLETE;
181
181
  } finally {
182
- t.bindFramebuffer(t.FRAMEBUFFER, n), t.bindTexture(t.TEXTURE_2D, r), t.deleteFramebuffer(o), t.deleteTexture(a);
182
+ t.bindFramebuffer(t.FRAMEBUFFER, n), t.bindTexture(t.TEXTURE_2D, r), t.deleteFramebuffer(o), t.deleteTexture(s);
183
183
  }
184
- return s;
184
+ return a;
185
185
  }
186
- function Me(t) {
186
+ function Ke(t) {
187
187
  return {
188
188
  kind: "rgba8-packed",
189
189
  internalFormat: t.RGBA,
190
190
  type: t.UNSIGNED_BYTE
191
191
  };
192
192
  }
193
- function Ut(t) {
193
+ function Zt(t) {
194
194
  if (typeof WebGL2RenderingContext > "u" || !(t instanceof WebGL2RenderingContext))
195
195
  throw new Error("zartigl requires WebGL2");
196
196
  return t;
197
197
  }
198
- function Pt(t) {
198
+ function Jt(t) {
199
199
  const e = [];
200
200
  t.getExtension("EXT_color_buffer_float") ? e.push(
201
201
  { kind: "float32", internalFormat: t.RGBA32F, type: t.FLOAT },
@@ -206,34 +206,34 @@ function Pt(t) {
206
206
  type: t.HALF_FLOAT
207
207
  });
208
208
  for (const i of e)
209
- if (Pe(
209
+ if (je(
210
210
  t,
211
211
  i.internalFormat,
212
212
  i.type
213
213
  ))
214
214
  return i;
215
- return Me(t);
215
+ return Ke(t);
216
216
  }
217
- function Mt(t, e, i, r, n, a, o) {
218
- const s = t.createTexture();
219
- if (!s)
217
+ function ei(t, e, i, r, n, s, o) {
218
+ const a = t.createTexture();
219
+ if (!a)
220
220
  throw new Error("Failed to create texture");
221
- return t.bindTexture(t.TEXTURE_2D, s), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_S, t.CLAMP_TO_EDGE), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_T, t.CLAMP_TO_EDGE), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MIN_FILTER, e), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MAG_FILTER, e), t.texImage2D(
221
+ return t.bindTexture(t.TEXTURE_2D, a), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_S, t.CLAMP_TO_EDGE), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_T, t.CLAMP_TO_EDGE), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MIN_FILTER, e), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MAG_FILTER, e), t.texImage2D(
222
222
  t.TEXTURE_2D,
223
223
  0,
224
- a,
224
+ s,
225
225
  r,
226
226
  n,
227
227
  0,
228
228
  t.RGBA,
229
229
  o,
230
230
  i
231
- ), t.bindTexture(t.TEXTURE_2D, null), s;
231
+ ), t.bindTexture(t.TEXTURE_2D, null), a;
232
232
  }
233
- function Gt(t, e, i) {
233
+ function ti(t, e, i) {
234
234
  t.activeTexture(t.TEXTURE0 + i), t.bindTexture(t.TEXTURE_2D, e);
235
235
  }
236
- function Nt(t, e) {
236
+ function ii(t, e) {
237
237
  const i = t.createFramebuffer();
238
238
  if (!i)
239
239
  throw new Error("Failed to create framebuffer");
@@ -245,7 +245,7 @@ function Nt(t, e) {
245
245
  0
246
246
  ), t.bindFramebuffer(t.FRAMEBUFFER, null), i;
247
247
  }
248
- function It(t) {
248
+ function ri(t) {
249
249
  const e = t.createBuffer();
250
250
  if (!e)
251
251
  throw new Error("Failed to create buffer");
@@ -255,7 +255,7 @@ function It(t) {
255
255
  t.STATIC_DRAW
256
256
  ), e;
257
257
  }
258
- const Ge = {
258
+ const Qe = {
259
259
  0: "#3288bd",
260
260
  0.1: "#66c2a5",
261
261
  0.2: "#abdda4",
@@ -265,19 +265,19 @@ const Ge = {
265
265
  0.6: "#f46d43",
266
266
  1: "#d53e4f"
267
267
  };
268
- function Lt(t, e, i) {
269
- const r = De(e ?? Ge, i), n = document.createElement("canvas");
268
+ function ni(t, e, i) {
269
+ const r = ze(e ?? Qe, i), n = document.createElement("canvas");
270
270
  n.width = 256, n.height = 1;
271
- const a = n.getContext("2d"), o = a.createLinearGradient(0, 0, 256, 0);
272
- for (const [l, c] of Object.entries(r))
273
- o.addColorStop(Number(l), c);
274
- a.fillStyle = o, a.fillRect(0, 0, 256, 1);
275
- const s = t.createTexture();
276
- if (!s)
271
+ const s = n.getContext("2d"), o = s.createLinearGradient(0, 0, 256, 0);
272
+ for (const [d, c] of Object.entries(r))
273
+ o.addColorStop(Number(d), c);
274
+ s.fillStyle = o, s.fillRect(0, 0, 256, 1);
275
+ const a = t.createTexture();
276
+ if (!a)
277
277
  throw new Error("Failed to create color ramp texture");
278
- return t.bindTexture(t.TEXTURE_2D, s), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_S, t.CLAMP_TO_EDGE), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_T, t.CLAMP_TO_EDGE), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MIN_FILTER, t.LINEAR), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MAG_FILTER, t.LINEAR), t.texImage2D(t.TEXTURE_2D, 0, t.RGBA, t.RGBA, t.UNSIGNED_BYTE, n), t.bindTexture(t.TEXTURE_2D, null), s;
278
+ return t.bindTexture(t.TEXTURE_2D, a), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_S, t.CLAMP_TO_EDGE), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_T, t.CLAMP_TO_EDGE), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MIN_FILTER, t.LINEAR), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MAG_FILTER, t.LINEAR), t.texImage2D(t.TEXTURE_2D, 0, t.RGBA, t.RGBA, t.UNSIGNED_BYTE, n), t.bindTexture(t.TEXTURE_2D, null), a;
279
279
  }
280
- function Ct(t) {
280
+ function si(t) {
281
281
  const e = t.getExtension("WEBGL_debug_renderer_info");
282
282
  return {
283
283
  vendor: String(t.getParameter(t.VENDOR) ?? ""),
@@ -287,7 +287,7 @@ function Ct(t) {
287
287
  version: String(t.getParameter(t.VERSION) ?? "")
288
288
  };
289
289
  }
290
- function Vt(t) {
290
+ function ai(t) {
291
291
  return {
292
292
  program: t.getParameter(t.CURRENT_PROGRAM),
293
293
  activeTexture: t.getParameter(t.ACTIVE_TEXTURE),
@@ -304,10 +304,10 @@ function Vt(t) {
304
304
  ]
305
305
  };
306
306
  }
307
- function Ot(t, e) {
307
+ function oi(t, e) {
308
308
  t.useProgram(e.program), t.activeTexture(e.activeTexture), t.bindBuffer(t.ARRAY_BUFFER, e.arrayBuffer), t.bindBuffer(t.ELEMENT_ARRAY_BUFFER, e.elementBuffer), t.bindFramebuffer(t.FRAMEBUFFER, e.framebuffer), e.blend ? t.enable(t.BLEND) : t.disable(t.BLEND), e.depthTest ? t.enable(t.DEPTH_TEST) : t.disable(t.DEPTH_TEST), e.stencilTest ? t.enable(t.STENCIL_TEST) : t.disable(t.STENCIL_TEST), t.viewport(e.viewport[0], e.viewport[1], e.viewport[2], e.viewport[3]), t.blendFunc(e.blendFunc[0], e.blendFunc[1]);
309
309
  }
310
- const Ne = {
310
+ const Ze = {
311
311
  degrees_c: "°C",
312
312
  degc: "°C",
313
313
  degrees_celsius: "°C",
@@ -323,7 +323,7 @@ const Ne = {
323
323
  "0.001": "PSU",
324
324
  psu: "PSU",
325
325
  stress_level: ""
326
- }, Ie = {
326
+ }, Je = {
327
327
  meter: "m",
328
328
  meters: "m",
329
329
  metre: "m",
@@ -346,36 +346,36 @@ const Ne = {
346
346
  newton: "N",
347
347
  pascal: "Pa",
348
348
  kelvin: "K"
349
- }, Le = "⁰¹²³⁴⁵⁶⁷⁸⁹";
350
- function q(t) {
351
- return t === 1 ? "" : [...String(t)].map((e) => Le[Number(e)]).join("");
349
+ }, et = "⁰¹²³⁴⁵⁶⁷⁸⁹";
350
+ function se(t) {
351
+ return t === 1 ? "" : [...String(t)].map((e) => et[Number(e)]).join("");
352
352
  }
353
- function Bt(t) {
354
- const e = t?.trim() ?? "", i = Ne[e.toLowerCase()];
353
+ function ci(t) {
354
+ const e = t?.trim() ?? "", i = Ze[e.toLowerCase()];
355
355
  if (i != null)
356
356
  return i;
357
357
  if (e.includes("/"))
358
358
  return e;
359
359
  const r = [], n = [];
360
- for (const a of e.split(/\s+/)) {
361
- const o = /^([A-Za-z]+)\^?(-?\d+)?$/.exec(a);
360
+ for (const s of e.split(/\s+/)) {
361
+ const o = /^([A-Za-z]+)\^?(-?\d+)?$/.exec(s);
362
362
  if (!o)
363
363
  return e.replace(/_/g, " ");
364
- const s = Ie[o[1]] ?? o[1], l = Number(o[2] ?? 1);
365
- l < 0 ? n.push(s + q(-l)) : r.push(s + q(l));
364
+ const a = Je[o[1]] ?? o[1], d = Number(o[2] ?? 1);
365
+ d < 0 ? n.push(a + se(-d)) : r.push(a + se(d));
366
366
  }
367
367
  return [r.join(" ") || "1", ...n].join("/");
368
368
  }
369
- const W = 20, Ce = 600;
370
- function Ve(t) {
369
+ const ae = 20, tt = 600;
370
+ function it(t) {
371
371
  const e = Math.max(0, Math.min(1, t));
372
- return W * Math.pow(Ce / W, e);
372
+ return ae * Math.pow(tt / ae, e);
373
373
  }
374
- function Xt(t) {
375
- return Math.exp(-1 / Ve(t));
374
+ function di(t) {
375
+ return Math.exp(-1 / it(t));
376
376
  }
377
- const Oe = 0.8, Be = 120, Xe = 300;
378
- class qt {
377
+ const rt = 0.8, nt = 120, st = 300;
378
+ class li {
379
379
  constructor(e) {
380
380
  this.base = e, this.moving = !1, this.start = 0, this.duration = 0, this.from = e, this.to = e;
381
381
  }
@@ -384,7 +384,7 @@ class qt {
384
384
  this.base = e, this.moving || (this.from = e, this.to = e, this.duration = 0);
385
385
  }
386
386
  setMoving(e, i) {
387
- e !== this.moving && (this.from = this.value(i), this.moving = e, this.to = e ? Oe : this.base, this.start = i, this.duration = e ? Be : Xe);
387
+ e !== this.moving && (this.from = this.value(i), this.moving = e, this.to = e ? rt : this.base, this.start = i, this.duration = e ? nt : st);
388
388
  }
389
389
  value(e) {
390
390
  if (this.duration === 0)
@@ -393,7 +393,7 @@ class qt {
393
393
  return i === 1 ? (this.duration = 0, this.from = this.to, this.to) : this.from + (this.to - this.from) * i * i * (3 - 2 * i);
394
394
  }
395
395
  }
396
- var qe = `vec3 velocityValue(vec4 texel, vec2 minimum, vec2 maximum, float physical) {
396
+ var at = `vec3 velocityValue(vec4 texel, vec2 minimum, vec2 maximum, float physical) {
397
397
  if (physical > 0.5) return texel.xyz;
398
398
  return vec3(mix(minimum, maximum, texel.rg), texel.a);
399
399
  }
@@ -401,7 +401,7 @@ var qe = `vec3 velocityValue(vec4 texel, vec2 minimum, vec2 maximum, float physi
401
401
  vec3 blendVelocity(vec3 a, vec3 b, float fraction) {
402
402
  if (fraction <= 0.0) return a;
403
403
  return mix(a, b, fraction);
404
- }`, We = `vec3 applyVibrance(vec3 c, float v) {
404
+ }`, ot = `vec3 applyVibrance(vec3 c, float v) {
405
405
  float mx = max(c.r, max(c.g, c.b));
406
406
  float mn = min(c.r, min(c.g, c.b));
407
407
  float boost = v * (1.0 - (mx - mn));
@@ -422,7 +422,7 @@ vec3 gradeColor(vec3 c, vec4 g) {
422
422
 
423
423
  c = mix(c, c * c * (3.0 - 2.0 * c), g.y);
424
424
  return clamp(applyVibrance(c, g.z), 0.0, 1.0);
425
- }`, $e = `uniform vec2 u_code_range;
425
+ }`, ct = `uniform vec2 u_code_range;
426
426
  uniform vec2 u_value_range;
427
427
  uniform float u_scalar_transfer;
428
428
 
@@ -434,7 +434,7 @@ float geoVideoScalarValue(float r) {
434
434
  float code = geoVideoScalarCode(r);
435
435
  float t = mix(code, (pow(10.0, code) - 1.0) / 9.0, u_scalar_transfer);
436
436
  return mix(u_value_range.x, u_value_range.y, t);
437
- }`, He = `uint pcg(uint v) {
437
+ }`, dt = `uint pcg(uint v) {
438
438
  uint state = v * 747796405u + 2891336453u;
439
439
  uint word = ((state >> ((state >> 28u) + 4u)) ^ state) * 277803737u;
440
440
  return (word >> 22u) ^ word;
@@ -442,13 +442,13 @@ float geoVideoScalarValue(float r) {
442
442
 
443
443
  float random(uvec3 v) {
444
444
  return float(pcg(v.x ^ pcg(v.y ^ pcg(v.z))) >> 8u) * (1.0 / 16777216.0);
445
- }`, Ye = `vec3 applyVibrance(vec3 c, float v) {
445
+ }`, lt = `vec3 applyVibrance(vec3 c, float v) {
446
446
  float mx = max(c.r, max(c.g, c.b));
447
447
  float mn = min(c.r, min(c.g, c.b));
448
448
  float boost = v * (1.0 - (mx - mn));
449
449
  float luma = dot(c, vec3(0.299, 0.587, 0.114));
450
450
  return mix(vec3(luma), c, 1.0 + boost);
451
- }`, je = `#define GLOW_SCALE 4
451
+ }`, ht = `#define GLOW_SCALE 4
452
452
 
453
453
  vec4 glowGather(sampler2D trails, ivec2 texel) {
454
454
  ivec2 last = textureSize(trails, 0) - 1;
@@ -476,8 +476,8 @@ vec4 addGlow(vec4 trail, sampler2D glowTex, vec2 uv, float gain) {
476
476
  vec3 rgb = (trail.rgb * trail.a + glow.rgb * under) / max(alpha, 1e-4);
477
477
  return vec4(rgb, alpha);
478
478
  }`;
479
- const Wt = Ye, $t = We, Ht = He, Yt = $e, jt = qe, zt = je, Kt = 4, Zt = 1.2;
480
- function Jt(t) {
479
+ const hi = lt, ui = ot, fi = dt, mi = ct, pi = at, Ei = ht, gi = 4, Ti = 1.2;
480
+ function bi(t) {
481
481
  if (t == null)
482
482
  return null;
483
483
  if (!Number.isFinite(t[0]) || !Number.isFinite(t[1]) || t[0] >= t[1])
@@ -486,12 +486,12 @@ function Jt(t) {
486
486
  );
487
487
  return [t[0], t[1]];
488
488
  }
489
- function p(t, e) {
489
+ function x(t, e) {
490
490
  if (typeof t != "number" || !Number.isFinite(t))
491
491
  throw new Error(`Invalid GeoVideo manifest ${e}`);
492
492
  return t;
493
493
  }
494
- function v(t, e) {
494
+ function B(t, e) {
495
495
  if (typeof t != "string")
496
496
  throw new Error(`Invalid GeoVideo manifest ${e}`);
497
497
  const i = new Date(t).getTime();
@@ -499,12 +499,12 @@ function v(t, e) {
499
499
  throw new Error(`Invalid GeoVideo manifest ${e}`);
500
500
  return i;
501
501
  }
502
- function P(t) {
502
+ function Y(t) {
503
503
  return typeof t == "string" && /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/.test(
504
504
  t
505
505
  );
506
506
  }
507
- function $(t) {
507
+ function oe(t) {
508
508
  if (!t || typeof t != "object")
509
509
  throw new Error("Invalid GeoVideo manifest");
510
510
  const e = t;
@@ -516,79 +516,79 @@ function $(t) {
516
516
  );
517
517
  if (!Array.isArray(e.bounds) || e.bounds.length !== 4)
518
518
  throw new Error("Invalid GeoVideo manifest bounds");
519
- const [i, r, n, a] = e.bounds.map(
520
- (u, m) => p(u, `bounds[${m}]`)
519
+ const [i, r, n, s] = e.bounds.map(
520
+ (m, E) => x(m, `bounds[${E}]`)
521
521
  );
522
- if (r < -90 || a > 90 || r >= a || i === n)
522
+ if (r < -90 || s > 90 || r >= s || i === n)
523
523
  throw new Error("Invalid GeoVideo geographic bounds");
524
524
  const o = e.media;
525
525
  if (!o || typeof o.url != "string" || !o.url)
526
526
  throw new Error("Invalid GeoVideo media");
527
- for (const u of ["width", "height", "fps", "durationSeconds"])
528
- if (p(o[u], `media.${u}`) <= 0)
529
- throw new Error(`Invalid GeoVideo media.${u}`);
530
- const s = e.encoding;
531
- if (!s || s.bits !== 8 || s.colorSpace !== "bt709" || s.colorRange !== "limited" && s.colorRange !== "full")
527
+ for (const m of ["width", "height", "fps", "durationSeconds"])
528
+ if (x(o[m], `media.${m}`) <= 0)
529
+ throw new Error(`Invalid GeoVideo media.${m}`);
530
+ const a = e.encoding;
531
+ if (!a || a.bits !== 8 || a.colorSpace !== "bt709" || a.colorRange !== "limited" && a.colorRange !== "full")
532
532
  throw new Error("Invalid GeoVideo encoding");
533
- const l = p(s.codeMin, "encoding.codeMin"), c = p(s.codeMax, "encoding.codeMax");
534
- if (l < 0 || c > 255 || l >= c)
533
+ const d = x(a.codeMin, "encoding.codeMin"), c = x(a.codeMax, "encoding.codeMax");
534
+ if (d < 0 || c > 255 || d >= c)
535
535
  throw new Error("Invalid GeoVideo code range");
536
- let d = o.height;
537
- if (s.kind === "scalar-luma") {
538
- if (s.transfer !== "linear" && s.transfer !== "log10-1p9" || p(s.valueMin, "encoding.valueMin") >= p(s.valueMax, "encoding.valueMax"))
536
+ let l = o.height;
537
+ if (a.kind === "scalar-luma") {
538
+ if (a.transfer !== "linear" && a.transfer !== "log10-1p9" || x(a.valueMin, "encoding.valueMin") >= x(a.valueMax, "encoding.valueMax"))
539
539
  throw new Error("Invalid GeoVideo scalar-luma encoding");
540
- } else if (s.kind === "vector-luma") {
541
- if (s.transfer !== "linear" && s.transfer !== "sqrt" || s.layout !== "stacked-uv" || p(s.valueDomain, "encoding.valueDomain") <= 0 || o.height % 2 !== 0)
540
+ } else if (a.kind === "vector-luma") {
541
+ if (a.transfer !== "linear" && a.transfer !== "sqrt" || a.layout !== "stacked-uv" || x(a.valueDomain, "encoding.valueDomain") <= 0 || o.height % 2 !== 0)
542
542
  throw new Error("Invalid GeoVideo vector-luma encoding");
543
- d = o.height / 2;
543
+ l = o.height / 2;
544
544
  } else
545
545
  throw new Error("Unsupported GeoVideo encoding");
546
546
  const h = e.mask;
547
- if (!h || h.kind !== "static-validity" || typeof h.url != "string" || !h.url || p(h.width, "mask.width") !== o.width || p(h.height, "mask.height") !== d || p(h.threshold, "mask.threshold") < 0 || h.threshold > 1)
547
+ if (!h || h.kind !== "static-validity" || typeof h.url != "string" || !h.url || x(h.width, "mask.width") !== o.width || x(h.height, "mask.height") !== l || x(h.threshold, "mask.threshold") < 0 || h.threshold > 1)
548
548
  throw new Error("Invalid GeoVideo static mask");
549
549
  if (e.timeline?.kind === "range") {
550
- const u = v(e.timeline.dateStart, "timeline.dateStart");
551
- if (v(e.timeline.dateEnd, "timeline.dateEnd") <= u)
550
+ const m = B(e.timeline.dateStart, "timeline.dateStart");
551
+ if (B(e.timeline.dateEnd, "timeline.dateEnd") <= m)
552
552
  throw new Error("GeoVideo timeline end must follow start");
553
553
  if (e.timeline.interpolation !== "linear" && e.timeline.interpolation !== "nearest")
554
554
  throw new Error("Invalid GeoVideo interpolation");
555
555
  } else if (e.timeline?.kind === "snapshot-loop")
556
- v(e.timeline.date, "timeline.date");
556
+ B(e.timeline.date, "timeline.date");
557
557
  else if (e.timeline?.kind === "sample-sequence") {
558
558
  if (!Array.isArray(e.timeline.values) || e.timeline.values.length === 0)
559
559
  throw new Error("GeoVideo sample sequence must contain values");
560
- const u = e.timeline.values.map(
561
- (m, T) => v(m, `timeline.values[${T}]`)
560
+ const m = e.timeline.values.map(
561
+ (E, w) => B(E, `timeline.values[${w}]`)
562
562
  );
563
- if (u.some((m, T) => T > 0 && m <= u[T - 1]))
563
+ if (m.some((E, w) => w > 0 && E <= m[w - 1]))
564
564
  throw new Error(
565
565
  "GeoVideo sample sequence values must be strictly increasing"
566
566
  );
567
567
  } else
568
568
  throw new Error("Invalid GeoVideo timeline");
569
- const f = e.style?.colorDomain;
570
- if (!Array.isArray(f) || f.length !== 2 || !f.every(Number.isFinite) || f[0] >= f[1])
569
+ const p = e.style?.colorDomain;
570
+ if (!Array.isArray(p) || p.length !== 2 || !p.every(Number.isFinite) || p[0] >= p[1])
571
571
  throw new Error("Invalid GeoVideo color domain");
572
- if (!P(e.id) || !e.provenance || !P(e.provenance.catalogEntryId) || !P(e.provenance.inputSourceId) || !Array.isArray(e.provenance.variables) || e.provenance.variables.length === 0)
572
+ if (!Y(e.id) || !e.provenance || !Y(e.provenance.catalogEntryId) || !Y(e.provenance.inputSourceId) || !Array.isArray(e.provenance.variables) || e.provenance.variables.length === 0)
573
573
  throw new Error("Invalid GeoVideo provenance");
574
- return { ...e, bounds: [i, r, n, a] };
574
+ return { ...e, bounds: [i, r, n, s] };
575
575
  }
576
- async function ze(t, e) {
576
+ async function ut(t, e) {
577
577
  if (typeof t != "string")
578
- return $(t);
578
+ return oe(t);
579
579
  const i = await fetch(t, { signal: e });
580
580
  if (!i.ok)
581
581
  throw new Error(
582
582
  `GeoVideo manifest request failed (${i.status}): ${t}`
583
583
  );
584
- const r = await i.json(), n = $(r), a = typeof document < "u" ? new URL(t, document.baseURI).href : t;
584
+ const r = await i.json(), n = oe(r), s = typeof document < "u" ? new URL(t, document.baseURI).href : t;
585
585
  return {
586
586
  ...n,
587
- media: { ...n.media, url: new URL(n.media.url, a).href },
588
- mask: { ...n.mask, url: new URL(n.mask.url, a).href }
587
+ media: { ...n.media, url: new URL(n.media.url, s).href },
588
+ mask: { ...n.mask, url: new URL(n.mask.url, s).href }
589
589
  };
590
590
  }
591
- function _(t) {
591
+ function M(t) {
592
592
  if (t.timeline.kind === "snapshot-loop")
593
593
  return [new Date(t.timeline.date).getTime()];
594
594
  if (t.timeline.kind === "sample-sequence")
@@ -599,43 +599,43 @@ function _(t) {
599
599
  );
600
600
  return Array.from(
601
601
  { length: r },
602
- (n, a) => e + (i - e) * a / (r - 1)
602
+ (n, s) => e + (i - e) * s / (r - 1)
603
603
  );
604
604
  }
605
- function K(t) {
605
+ function ue(t) {
606
606
  return t.timeline.kind === "sample-sequence" ? t.timeline.values.length / t.media.durationSeconds : t.media.fps;
607
607
  }
608
- function Qt(t, e) {
609
- return e / K(t);
608
+ function wi(t, e) {
609
+ return e / ue(t);
610
610
  }
611
- function Ke(t, e) {
611
+ function ft(t, e) {
612
612
  if (t.timeline.kind === "snapshot-loop")
613
613
  return 0;
614
614
  if (t.timeline.kind === "sample-sequence") {
615
- const a = _(t);
615
+ const s = M(t);
616
616
  let o = 0;
617
- for (let l = 1; l < a.length; l += 1)
618
- Math.abs(a[l] - e) < Math.abs(a[o] - e) && (o = l);
619
- const s = t.media.durationSeconds / a.length;
620
- return o * s + Math.min(s / 2, 0.5 / t.media.fps);
617
+ for (let d = 1; d < s.length; d += 1)
618
+ Math.abs(s[d] - e) < Math.abs(s[o] - e) && (o = d);
619
+ const a = t.media.durationSeconds / s.length;
620
+ return o * a + Math.min(a / 2, 0.5 / t.media.fps);
621
621
  }
622
622
  const i = new Date(t.timeline.dateStart).getTime(), r = new Date(t.timeline.dateEnd).getTime();
623
- return Math.max(0, Math.min(1, (e - i) / (r - i))) * Z(t);
623
+ return Math.max(0, Math.min(1, (e - i) / (r - i))) * fe(t);
624
624
  }
625
- function ei(t, e) {
625
+ function yi(t, e) {
626
626
  if (t.timeline.kind === "snapshot-loop")
627
627
  return new Date(t.timeline.date).getTime();
628
628
  if (t.timeline.kind === "sample-sequence") {
629
- const o = _(t), s = t.media.durationSeconds / o.length, l = Math.floor((e + 0.25 / t.media.fps) / s);
630
- return o[Math.max(0, Math.min(o.length - 1, l))];
629
+ const o = M(t), a = t.media.durationSeconds / o.length, d = Math.floor((e + 0.25 / t.media.fps) / a);
630
+ return o[Math.max(0, Math.min(o.length - 1, d))];
631
631
  }
632
- const i = new Date(t.timeline.dateStart).getTime(), r = new Date(t.timeline.dateEnd).getTime(), n = Z(t), a = n > 0 ? Math.max(0, Math.min(1, e / n)) : 0;
633
- return i + (r - i) * a;
632
+ const i = new Date(t.timeline.dateStart).getTime(), r = new Date(t.timeline.dateEnd).getTime(), n = fe(t), s = n > 0 ? Math.max(0, Math.min(1, e / n)) : 0;
633
+ return i + (r - i) * s;
634
634
  }
635
- function Z(t) {
635
+ function fe(t) {
636
636
  return Math.max(0, t.media.durationSeconds - 1 / t.media.fps);
637
637
  }
638
- function Ze(t, e) {
638
+ function mt(t, e) {
639
639
  const i = new Uint8Array(t.length / 4);
640
640
  for (let r = 0; r < i.length; r++) {
641
641
  const n = t[r * 4];
@@ -643,7 +643,7 @@ function Ze(t, e) {
643
643
  }
644
644
  return i;
645
645
  }
646
- class Je {
646
+ class pt {
647
647
  constructor() {
648
648
  this.gl = null, this.texture = null, this.framebuffer = null;
649
649
  }
@@ -656,8 +656,8 @@ class Je {
656
656
  this.texture,
657
657
  0
658
658
  );
659
- const a = new Uint8Array(i * r * 4);
660
- return n.readPixels(0, 0, i, r, n.RGBA, n.UNSIGNED_BYTE, a), n.bindFramebuffer(n.FRAMEBUFFER, null), a;
659
+ const s = new Uint8Array(i * r * 4);
660
+ return n.readPixels(0, 0, i, r, n.RGBA, n.UNSIGNED_BYTE, s), n.bindFramebuffer(n.FRAMEBUFFER, null), s;
661
661
  }
662
662
  release() {
663
663
  this.gl?.getExtension("WEBGL_lose_context")?.loseContext(), this.gl = null, this.texture = null, this.framebuffer = null;
@@ -674,44 +674,44 @@ class Je {
674
674
  return this.gl = r, this.texture = r.createTexture(), this.framebuffer = r.createFramebuffer(), r;
675
675
  }
676
676
  }
677
- function H(t) {
677
+ function ce(t) {
678
678
  const e = Math.max(4, Math.floor(t.length / 4 / 997) * 4);
679
679
  for (let i = 3; i < t.length; i += e)
680
680
  if (t[i] !== 0)
681
681
  return !1;
682
682
  return !0;
683
683
  }
684
- function E() {
684
+ function g() {
685
685
  return new DOMException("GeoVideo frame request was cancelled", "AbortError");
686
686
  }
687
- function x(t, e, i) {
687
+ function G(t, e, i) {
688
688
  return e ? e.aborted ? (t.catch(() => {
689
- }), i?.(), Promise.reject(E())) : new Promise((r, n) => {
690
- const a = () => {
691
- i?.(), n(E());
689
+ }), i?.(), Promise.reject(g())) : new Promise((r, n) => {
690
+ const s = () => {
691
+ i?.(), n(g());
692
692
  };
693
- e.addEventListener("abort", a, { once: !0 }), t.then(r, n).finally(() => {
694
- e.removeEventListener("abort", a);
693
+ e.addEventListener("abort", s, { once: !0 }), t.then(r, n).finally(() => {
694
+ e.removeEventListener("abort", s);
695
695
  });
696
696
  }) : t;
697
697
  }
698
- function M(t, e) {
698
+ function j(t, e) {
699
699
  return new Promise(
700
700
  (i) => t.addEventListener(e, () => i(), { once: !0 })
701
701
  );
702
702
  }
703
- const Qe = 250;
704
- function et(t) {
703
+ const Et = 250;
704
+ function gt(t) {
705
705
  return "requestVideoFrameCallback" in t ? Promise.race([
706
706
  new Promise(
707
707
  (e) => t.requestVideoFrameCallback(() => e())
708
708
  ),
709
- new Promise((e) => setTimeout(e, Qe))
709
+ new Promise((e) => setTimeout(e, Et))
710
710
  ]) : Promise.resolve();
711
711
  }
712
- class J {
712
+ class me {
713
713
  constructor(e, i, r = {}) {
714
- this.reader = new Je(), this.video = null, this.maskCodes = null, this.initPromise = null, this.presented = !1, this.primed = !1, this.queue = Promise.resolve(), this.frames = /* @__PURE__ */ new Map(), this.pending = /* @__PURE__ */ new Set(), this.manifest = e, this.planes = i, this.cacheSize = Math.max(1, r.cacheSize ?? 3), this.width = e.media.width, this.height = e.media.height / i, this.times = Float64Array.from(_(e));
714
+ this.reader = new pt(), this.video = null, this.maskCodes = null, this.initPromise = null, this.presented = !1, this.primed = !1, this.queue = Promise.resolve(), this.frames = /* @__PURE__ */ new Map(), this.pending = /* @__PURE__ */ new Set(), this.manifest = e, this.planes = i, this.cacheSize = Math.max(1, r.cacheSize ?? 3), this.width = e.media.width, this.height = e.media.height / i, this.times = Float64Array.from(M(e));
715
715
  }
716
716
  /** Static validity, one 8-bit value per grid cell; null before init(). */
717
717
  get mask() {
@@ -720,11 +720,11 @@ class J {
720
720
  /** Luma codes of the presented frame, or null when it is blank. */
721
721
  readCodes(e, i) {
722
722
  const r = this.reader.read(e, this.width, i);
723
- return H(r) ? null : Ze(r, this.manifest.encoding.colorRange);
723
+ return ce(r) ? null : mt(r, this.manifest.encoding.colorRange);
724
724
  }
725
725
  /** True when the decoder exposed no pixels; reads back one row only. */
726
726
  isBlank(e) {
727
- return H(this.reader.read(e, this.width, 1));
727
+ return ce(this.reader.read(e, this.width, 1));
728
728
  }
729
729
  init() {
730
730
  return this.initPromise ??= this.load().catch((e) => {
@@ -748,23 +748,23 @@ class J {
748
748
  frame(e, i = {}) {
749
749
  const { signal: r } = i;
750
750
  if (r?.aborted)
751
- return Promise.reject(E());
751
+ return Promise.reject(g());
752
752
  let n = this.frames.get(e);
753
753
  if (n ? (this.frames.delete(e), this.frames.set(e, n)) : n = this.enqueue(e), n.settled)
754
754
  return n.promise;
755
- const a = n;
756
- return a.waiters++, x(a.promise, r, () => this.leave(a));
755
+ const s = n;
756
+ return s.waiters++, G(s.promise, r, () => this.leave(s));
757
757
  }
758
758
  enqueue(e) {
759
759
  const i = new AbortController(), r = this.queue.then(
760
- () => i.signal.aborted ? Promise.reject(E()) : this.decode(e, i.signal)
760
+ () => i.signal.aborted ? Promise.reject(g()) : this.decode(e, i.signal)
761
761
  );
762
762
  this.queue = r.catch(() => {
763
763
  });
764
764
  const n = {
765
765
  index: e,
766
766
  controller: i,
767
- promise: x(r, i.signal),
767
+ promise: G(r, i.signal),
768
768
  waiters: 0,
769
769
  settled: !1
770
770
  };
@@ -787,7 +787,7 @@ class J {
787
787
  e.controller.abort(), this.pending.delete(e), this.frames.get(e.index) === e && this.frames.delete(e.index);
788
788
  }
789
789
  async load() {
790
- const [e] = await Promise.all([this.loadMask(), this.loadVideo()]);
790
+ const [e] = await Promise.all([this.loadMask(), this.loadMedia()]);
791
791
  this.maskCodes = e;
792
792
  }
793
793
  async loadMask() {
@@ -802,12 +802,13 @@ class J {
802
802
  throw new Error(
803
803
  `GeoVideo mask dimensions ${n.naturalWidth}x${n.naturalHeight} do not match manifest ${i}x${r}`
804
804
  );
805
- const a = this.reader.read(n, i, r), o = new Uint8Array(i * r);
806
- for (let s = 0; s < o.length; s++)
807
- o[s] = a[s * 4];
805
+ const s = this.reader.read(n, i, r), o = new Uint8Array(i * r);
806
+ for (let a = 0; a < o.length; a++)
807
+ o[a] = s[a * 4];
808
808
  return o;
809
809
  }
810
- async loadVideo() {
810
+ /** Open the media; the default reads frames by seeking a video element. */
811
+ async loadMedia() {
811
812
  const e = document.createElement("video");
812
813
  if (e.crossOrigin = "anonymous", e.muted = !0, e.playsInline = !0, e.preload = "metadata", e.src = this.manifest.media.url, this.video = e, await new Promise((i, r) => {
813
814
  e.addEventListener("loadedmetadata", () => i(), {
@@ -830,8 +831,8 @@ class J {
830
831
  async presentFrame(e, i) {
831
832
  if (this.presented && Math.abs(e.currentTime - i) <= 1e-3 && !e.seeking)
832
833
  return;
833
- const r = et(e), n = M(e, "seeked");
834
- e.currentTime = i, await n, e.readyState < HTMLMediaElement.HAVE_CURRENT_DATA && await Promise.race([M(e, "loadeddata"), M(e, "canplay")]), await r, this.presented = !0;
834
+ const r = gt(e), n = j(e, "seeked");
835
+ e.currentTime = i, await n, e.readyState < HTMLMediaElement.HAVE_CURRENT_DATA && await Promise.race([j(e, "loadeddata"), j(e, "canplay")]), await r, this.presented = !0;
835
836
  }
836
837
  /**
837
838
  * Some mobile browsers expose no decoded pixels to WebGL until playback
@@ -846,40 +847,44 @@ class J {
846
847
  }
847
848
  e.pause(), this.presented = !1;
848
849
  }
850
+ /** Media time inside the video frame showing step `index`. */
851
+ stepSeconds(e) {
852
+ return this.manifest.timeline.kind === "snapshot-loop" ? e / this.manifest.media.fps : ft(this.manifest, this.times[e]);
853
+ }
849
854
  /**
850
855
  * Seek and capture one step. `signal` aborts it between steps; a seek
851
856
  * already started completes first, keeping the queue serial.
852
857
  */
853
858
  async decode(e, i) {
854
859
  if (i.aborted)
855
- throw E();
860
+ throw g();
856
861
  await this.init();
857
862
  const r = this.video, n = this.maskCodes;
858
863
  if (i.aborted || !r || !n)
859
- throw E();
860
- const a = this.manifest.timeline.kind === "snapshot-loop" ? e / this.manifest.media.fps : Ke(this.manifest, this.times[e]);
861
- if (await this.presentFrame(r, a), i.aborted || r !== this.video)
862
- throw E();
864
+ throw g();
865
+ const s = this.stepSeconds(e);
866
+ if (await this.presentFrame(r, s), i.aborted || r !== this.video)
867
+ throw g();
863
868
  const o = this.height * this.planes;
864
- let s = await this.capture(r, o, n);
865
- if (s === null && !this.primed) {
866
- if (await this.primeDecoder(r), await this.presentFrame(r, a), i.aborted || r !== this.video)
867
- throw E();
868
- s = await this.capture(r, o, n);
869
+ let a = await this.capture(r, o, n);
870
+ if (a === null && !this.primed) {
871
+ if (await this.primeDecoder(r), await this.presentFrame(r, s), i.aborted || r !== this.video)
872
+ throw g();
873
+ a = await this.capture(r, o, n);
869
874
  }
870
- if (s === null)
875
+ if (a === null)
871
876
  throw new Error("GeoVideo frame could not be read back from the decoder");
872
- return s;
877
+ return a;
873
878
  }
874
879
  }
875
- function tt(t) {
880
+ function Tt(t) {
876
881
  return {
877
882
  codeRange: [t.codeMin / 255, t.codeMax / 255],
878
883
  valueRange: [t.valueMin, t.valueMax],
879
884
  transfer: t.transfer === "log10-1p9" ? 1 : 0
880
885
  };
881
886
  }
882
- class it extends J {
887
+ class bt extends me {
883
888
  constructor(e, i = {}) {
884
889
  if (e.encoding.kind !== "scalar-luma")
885
890
  throw new Error("GeoVideoScalarSource requires a scalar-luma manifest");
@@ -892,7 +897,7 @@ class it extends J {
892
897
  });
893
898
  }
894
899
  }
895
- function b(t, e) {
900
+ function v(t, e) {
896
901
  if (e <= t[0])
897
902
  return { index: 0, fraction: 0 };
898
903
  const i = t.length - 1;
@@ -900,55 +905,310 @@ function b(t, e) {
900
905
  return { index: i, fraction: 0 };
901
906
  let r = 0, n = i;
902
907
  for (; n - r > 1; ) {
903
- const a = r + n >> 1;
904
- t[a] <= e ? r = a : n = a;
908
+ const s = r + n >> 1;
909
+ t[s] <= e ? r = s : n = s;
905
910
  }
906
911
  return { index: r, fraction: (e - t[r]) / (t[n] - t[r]) };
907
912
  }
908
- function G(t, e) {
909
- const { index: i, fraction: r } = b(t, e);
913
+ function K(t, e) {
914
+ const { index: i, fraction: r } = v(t, e);
910
915
  return i + r;
911
916
  }
912
- function rt(t, e) {
917
+ function wt(t, e) {
913
918
  const i = Math.max(0, Math.min(t.length - 1, Math.floor(e))), r = Math.min(i + 1, t.length - 1);
914
919
  return t[i] + (t[r] - t[i]) * Math.max(0, e - i);
915
920
  }
916
- function nt(t, e) {
921
+ function $(t, e, i) {
922
+ const r = [];
923
+ let n = e;
924
+ for (; n + 8 <= i; ) {
925
+ let s = t.getUint32(n);
926
+ const o = String.fromCharCode(
927
+ t.getUint8(n + 4),
928
+ t.getUint8(n + 5),
929
+ t.getUint8(n + 6),
930
+ t.getUint8(n + 7)
931
+ );
932
+ let a = 8;
933
+ if (s === 1 ? (s = Number(t.getBigUint64(n + 8)), a = 16) : s === 0 && (s = i - n), s < a || n + s > i)
934
+ throw new Error(`Malformed MP4 box ${o}`);
935
+ r.push({ type: o, start: n + a, end: n + s }), n += s;
936
+ }
937
+ return r;
938
+ }
939
+ function b(t, e, i) {
940
+ const r = $(t, e.start, e.end).find(
941
+ (n) => n.type === i
942
+ );
943
+ if (!r)
944
+ throw new Error(`MP4 box ${i} not found in ${e.type}`);
945
+ return r;
946
+ }
947
+ function V(t, e, i) {
948
+ return $(t, e.start, e.end).find((r) => r.type === i) ?? null;
949
+ }
950
+ function D(t, e) {
951
+ return { at: e.start + 8, count: t.getUint32(e.start + 4) };
952
+ }
953
+ function yt(t, e, i) {
954
+ const r = V(t, e, "edts"), n = r && V(t, r, "elst");
955
+ if (!n)
956
+ return;
957
+ const { at: s, count: o } = D(t, n), a = t.getUint8(n.start) === 1 ? Number(t.getBigInt64(s + 8)) : t.getInt32(s + 4);
958
+ if (o !== 1 || a !== i)
959
+ throw new Error("Unsupported MP4 edit list");
960
+ }
961
+ function _t(t) {
962
+ const e = new DataView(t), i = { type: "file", start: 0, end: t.byteLength }, r = b(e, i, "moov"), n = $(e, r.start, r.end).find((f) => {
963
+ if (f.type !== "trak")
964
+ return !1;
965
+ const u = b(e, b(e, f, "mdia"), "hdlr");
966
+ return String.fromCharCode(...new Uint8Array(t, u.start + 8, 4)) === "vide";
967
+ });
968
+ if (!n)
969
+ throw new Error("MP4 has no video track");
970
+ const s = b(
971
+ e,
972
+ b(e, b(e, n, "mdia"), "minf"),
973
+ "stbl"
974
+ ), o = b(e, s, "stsd"), [a] = $(e, o.start + 8, o.end);
975
+ if (!a || a.type !== "avc1" && a.type !== "avc3")
976
+ throw new Error(`Unsupported MP4 sample entry ${a?.type}`);
977
+ const d = e.getUint16(a.start + 24), c = e.getUint16(a.start + 26), l = b(e, { ...a, start: a.start + 78 }, "avcC"), h = new Uint8Array(t.slice(l.start, l.end)), p = (f) => h[f].toString(16).padStart(2, "0"), m = `avc1.${p(1)}${p(2)}${p(3)}`, E = b(e, s, "stsz"), w = e.getUint32(E.start + 4), y = e.getUint32(E.start + 8), A = Array.from(
978
+ { length: y },
979
+ (f, u) => w || e.getUint32(E.start + 12 + u * 4)
980
+ ), N = V(e, s, "co64"), O = N ?? b(e, s, "stco"), U = D(e, O), T = Array.from(
981
+ { length: U.count },
982
+ (f, u) => N ? Number(e.getBigUint64(U.at + u * 8)) : e.getUint32(U.at + u * 4)
983
+ ), _ = D(e, b(e, s, "stsc")), F = [];
984
+ for (let f = 0; f < _.count; f++) {
985
+ const u = _.at + f * 12, I = e.getUint32(u) - 1, R = e.getUint32(u + 4), z = f + 1 < _.count ? e.getUint32(u + 12) - 1 : T.length;
986
+ for (let L = I; L < z; L++) {
987
+ let C = T[L];
988
+ for (let te = 0; te < R && F.length < y; te++)
989
+ F.push(C), C += A[F.length - 1];
990
+ }
991
+ }
992
+ const S = D(e, b(e, s, "stts")), k = [];
993
+ let P = 0;
994
+ for (let f = 0; f < S.count; f++) {
995
+ const u = e.getUint32(S.at + f * 8), I = e.getUint32(S.at + f * 8 + 4);
996
+ for (let R = 0; R < u; R++)
997
+ k.push(P), P += I;
998
+ }
999
+ const W = V(e, s, "ctts");
1000
+ if (W) {
1001
+ const f = e.getUint8(W.start) === 1, u = D(e, W);
1002
+ let I = 0;
1003
+ for (let R = 0; R < u.count; R++) {
1004
+ const z = e.getUint32(u.at + R * 8), L = f ? e.getInt32(u.at + R * 8 + 4) : e.getUint32(u.at + R * 8 + 4);
1005
+ for (let C = 0; C < z; C++)
1006
+ k[I++] += L;
1007
+ }
1008
+ }
1009
+ yt(e, n, Math.min(...k.slice(0, y)));
1010
+ const ge = k.slice(0, y).map((f, u) => [f, u]).sort((f, u) => f[0] - u[0]), J = new Array(y);
1011
+ ge.forEach(([, f], u) => J[f] = u);
1012
+ const H = V(e, s, "stss"), ee = /* @__PURE__ */ new Set();
1013
+ if (H) {
1014
+ const f = D(e, H);
1015
+ for (let u = 0; u < f.count; u++)
1016
+ ee.add(e.getUint32(f.at + u * 4) - 1);
1017
+ }
1018
+ if (F.length !== y || k.length < y)
1019
+ throw new Error("Inconsistent MP4 sample tables");
1020
+ return {
1021
+ codec: m,
1022
+ description: h,
1023
+ width: d,
1024
+ height: c,
1025
+ samples: A.map((f, u) => ({
1026
+ offset: F[u],
1027
+ size: f,
1028
+ frame: J[u],
1029
+ key: H ? ee.has(u) : !0
1030
+ }))
1031
+ };
1032
+ }
1033
+ const Rt = 50;
1034
+ class xt extends bt {
1035
+ constructor() {
1036
+ super(...arguments), this.track = null, this.data = null, this.sampleOfFrame = [], this.decoder = null, this.fed = -1, this.taken = -1, this.outputs = /* @__PURE__ */ new Map(), this.progress = null, this.failure = null, this.loading = null;
1037
+ }
1038
+ /** True once the media decodes through WebCodecs. */
1039
+ get usesWebCodecs() {
1040
+ return this.track !== null;
1041
+ }
1042
+ async loadMedia() {
1043
+ if (typeof VideoDecoder > "u" || typeof fetch > "u")
1044
+ return super.loadMedia();
1045
+ const e = new AbortController();
1046
+ this.loading = e;
1047
+ const i = await fetch(this.manifest.media.url, {
1048
+ signal: e.signal
1049
+ });
1050
+ if (!i.ok)
1051
+ throw new Error(
1052
+ `Failed to load GeoVideo media: ${this.manifest.media.url}`
1053
+ );
1054
+ const r = await i.arrayBuffer();
1055
+ let n;
1056
+ try {
1057
+ n = _t(r);
1058
+ } catch {
1059
+ return this.loading === e ? super.loadMedia() : void 0;
1060
+ }
1061
+ if (n.width !== this.manifest.media.width || n.height !== this.manifest.media.height)
1062
+ throw new Error(
1063
+ `GeoVideo media dimensions ${n.width}x${n.height} do not match manifest ${this.manifest.media.width}x${this.manifest.media.height}`
1064
+ );
1065
+ const { supported: s } = await VideoDecoder.isConfigSupported(
1066
+ this.config(n)
1067
+ ).catch(() => ({ supported: !1 }));
1068
+ if (this.loading !== e)
1069
+ throw g();
1070
+ if (this.loading = null, !s)
1071
+ return super.loadMedia();
1072
+ this.sampleOfFrame = [], n.samples.forEach(
1073
+ (o, a) => this.sampleOfFrame[o.frame] = a
1074
+ ), this.data = r, this.track = n;
1075
+ }
1076
+ release() {
1077
+ this.loading?.abort(), this.loading = null, this.closeDecoder(), this.track = null, this.data = null, super.release();
1078
+ }
1079
+ async decode(e, i) {
1080
+ if (await this.init(), !this.track)
1081
+ return super.decode(e, i);
1082
+ if (i.aborted)
1083
+ throw g();
1084
+ const r = Math.min(
1085
+ this.track.samples.length - 1,
1086
+ Math.floor(this.stepSeconds(e) * this.manifest.media.fps + 1e-6)
1087
+ ), n = await this.decodeFrame(r, i);
1088
+ try {
1089
+ return await createImageBitmap(n, {
1090
+ premultiplyAlpha: "none",
1091
+ colorSpaceConversion: "none"
1092
+ });
1093
+ } finally {
1094
+ n.close();
1095
+ }
1096
+ }
1097
+ config(e) {
1098
+ return {
1099
+ codec: e.codec,
1100
+ description: e.description,
1101
+ codedWidth: e.width,
1102
+ codedHeight: e.height,
1103
+ optimizeForLatency: !0
1104
+ };
1105
+ }
1106
+ /** Video frame `frame`, owned by the caller. */
1107
+ async decodeFrame(e, i) {
1108
+ const r = this.track, n = this.sampleOfFrame[e], s = this.keySample(n);
1109
+ for ((this.fed < 0 || e <= this.taken || s > this.fed) && this.restart(s), this.taken = e - 1, this.dropOutputsBefore(e); !this.outputs.has(e); ) {
1110
+ if (this.failure)
1111
+ throw this.failure;
1112
+ if (i.aborted)
1113
+ throw g();
1114
+ const a = this.decoder;
1115
+ this.fed < r.samples.length && a.decodeQueueSize < 2 && (this.feed(this.fed++), this.fed === r.samples.length && a.flush().catch(() => {
1116
+ })), await this.waitProgress();
1117
+ }
1118
+ const o = this.outputs.get(e);
1119
+ return this.outputs.delete(e), this.taken = e, o;
1120
+ }
1121
+ dropOutputsBefore(e) {
1122
+ for (const [i, r] of this.outputs)
1123
+ i < e && (r.close(), this.outputs.delete(i));
1124
+ }
1125
+ keySample(e) {
1126
+ const { samples: i } = this.track;
1127
+ let r = e;
1128
+ for (; r > 0 && !i[r].key; )
1129
+ r--;
1130
+ return r;
1131
+ }
1132
+ restart(e) {
1133
+ this.closeDecoder(), this.failure = null;
1134
+ const i = new VideoDecoder({
1135
+ output: (r) => {
1136
+ this.decoder !== i || r.timestamp <= this.taken ? r.close() : this.outputs.set(r.timestamp, r), this.notify();
1137
+ },
1138
+ error: (r) => {
1139
+ this.decoder === i && (this.failure = r, this.fed = -1), this.notify();
1140
+ }
1141
+ });
1142
+ i.addEventListener("dequeue", () => this.notify()), i.configure(this.config(this.track)), this.decoder = i, this.fed = e, this.taken = this.track.samples[e].frame - 1;
1143
+ }
1144
+ feed(e) {
1145
+ const i = this.track.samples[e];
1146
+ this.decoder.decode(
1147
+ new EncodedVideoChunk({
1148
+ type: i.key ? "key" : "delta",
1149
+ // Video frame numbers: outputs carry them back in display order.
1150
+ timestamp: i.frame,
1151
+ data: new Uint8Array(this.data, i.offset, i.size)
1152
+ })
1153
+ );
1154
+ }
1155
+ /** Next output, dequeue or error; a timer for decoders without events. */
1156
+ waitProgress() {
1157
+ return new Promise((e) => {
1158
+ const i = setTimeout(r, Rt);
1159
+ function r() {
1160
+ clearTimeout(i), e();
1161
+ }
1162
+ this.progress = r;
1163
+ });
1164
+ }
1165
+ notify() {
1166
+ const e = this.progress;
1167
+ this.progress = null, e?.();
1168
+ }
1169
+ closeDecoder() {
1170
+ this.decoder && this.decoder.state !== "closed" && this.decoder.close(), this.decoder = null, this.fed = -1;
1171
+ for (const e of this.outputs.values())
1172
+ e.close();
1173
+ this.outputs.clear();
1174
+ }
1175
+ }
1176
+ function vt(t, e) {
917
1177
  let i = (t - e.codeMin) / (e.codeMax - e.codeMin) * 2 - 1;
918
1178
  return i = Math.max(-1, Math.min(1, i)), e.transfer === "sqrt" && (i = Math.sign(i) * i * i), i * e.valueDomain;
919
1179
  }
920
- function at(t, e, i, r) {
1180
+ function kt(t, e, i, r) {
921
1181
  const n = e.length;
922
1182
  if (t.length !== 2 * n)
923
1183
  throw new Error(
924
1184
  `GeoVideo vector frame has ${t.length} codes, expected ${2 * n}`
925
1185
  );
926
- const a = new Float32Array(256);
1186
+ const s = new Float32Array(256);
927
1187
  for (let c = 0; c < 256; c++)
928
- a[c] = nt(c, r);
929
- const o = i * 255, s = new Float32Array(n), l = new Float32Array(n);
1188
+ s[c] = vt(c, r);
1189
+ const o = i * 255, a = new Float32Array(n), d = new Float32Array(n);
930
1190
  for (let c = 0; c < n; c++) {
931
- const d = e[c] >= o;
932
- s[c] = d ? a[t[c]] : NaN, l[c] = d ? a[t[n + c]] : NaN;
1191
+ const l = e[c] >= o;
1192
+ a[c] = l ? s[t[c]] : NaN, d[c] = l ? s[t[n + c]] : NaN;
933
1193
  }
934
- return { u: s, v: l };
1194
+ return { u: a, v: d };
935
1195
  }
936
- class st extends J {
1196
+ class At extends me {
937
1197
  constructor(e, i = {}) {
938
1198
  if (e.encoding.kind !== "vector-luma")
939
1199
  throw new Error("GeoVideoVectorSource requires a vector-luma manifest");
940
1200
  super(e, 2, i), this.encoding = e.encoding;
941
- const [r, n, a, o] = e.bounds, s = (a - r) / this.width, l = (o - n) / this.height;
1201
+ const [r, n, s, o] = e.bounds, a = (s - r) / this.width, d = (o - n) / this.height;
942
1202
  this.coords = {
943
1203
  time: this.times,
944
1204
  vertical: new Float32Array([0]),
945
1205
  latitude: Float32Array.from(
946
1206
  { length: this.height },
947
- (c, d) => o - (d + 0.5) * l
1207
+ (c, l) => o - (l + 0.5) * d
948
1208
  ),
949
1209
  longitude: Float32Array.from(
950
1210
  { length: this.width },
951
- (c, d) => r + (d + 0.5) * s
1211
+ (c, l) => r + (l + 0.5) * a
952
1212
  )
953
1213
  };
954
1214
  }
@@ -970,12 +1230,12 @@ class st extends J {
970
1230
  findTimeIndex(e) {
971
1231
  const i = typeof e == "number" ? e : new Date(e).getTime(), r = this.coords.time;
972
1232
  let n = 0;
973
- for (let a = 1; a < r.length; a++)
974
- Math.abs(r[a] - i) < Math.abs(r[n] - i) && (n = a);
1233
+ for (let s = 1; s < r.length; s++)
1234
+ Math.abs(r[s] - i) < Math.abs(r[n] - i) && (n = s);
975
1235
  return n;
976
1236
  }
977
1237
  getChunksForBounds(e, i, r) {
978
- const { latitude: n, longitude: a } = this.coords;
1238
+ const { latitude: n, longitude: s } = this.coords;
979
1239
  return [
980
1240
  {
981
1241
  timeIdx: i,
@@ -983,7 +1243,7 @@ class st extends J {
983
1243
  latIdx: 0,
984
1244
  lonIdx: 0,
985
1245
  latRange: [n[0], n[this.height - 1]],
986
- lonRange: [a[0], a[this.width - 1]],
1246
+ lonRange: [s[0], s[this.width - 1]],
987
1247
  latSize: this.height,
988
1248
  lonSize: this.width
989
1249
  }
@@ -1000,7 +1260,7 @@ class st extends J {
1000
1260
  /** u/v codes are written into luma: read back, then decoded on the CPU. */
1001
1261
  async capture(e, i, r) {
1002
1262
  const n = this.readCodes(e, i);
1003
- return n ? at(
1263
+ return n ? kt(
1004
1264
  n,
1005
1265
  r,
1006
1266
  this.manifest.mask.threshold,
@@ -1008,23 +1268,23 @@ class st extends J {
1008
1268
  ) : null;
1009
1269
  }
1010
1270
  }
1011
- function ot(t, e, i = {}) {
1012
- const [r, n] = i.range ?? [-1 / 0, 1 / 0], a = [...t].sort((s, l) => s.start - l.start), o = a.find(
1013
- (s) => s.start > e && s.start <= n
1014
- ) ?? (i.loop ? a.find(
1015
- (s) => s.end >= r && s.start <= n
1271
+ function Ft(t, e, i = {}) {
1272
+ const [r, n] = i.range ?? [-1 / 0, 1 / 0], s = [...t].sort((a, d) => a.start - d.start), o = s.find(
1273
+ (a) => a.start > e && a.start <= n
1274
+ ) ?? (i.loop ? s.find(
1275
+ (a) => a.end >= r && a.start <= n
1016
1276
  ) : void 0);
1017
1277
  return o ? { chunk: o, time: Math.max(o.start, r) } : null;
1018
1278
  }
1019
- function ct(t, e) {
1279
+ function St(t, e) {
1020
1280
  let i = null, r = -1 / 0;
1021
1281
  for (const n of e) {
1022
- const a = Math.min(t.end, n.end) - Math.max(t.start, n.start);
1023
- Number.isFinite(a) && a >= 0 && a > r && (i = n, r = a);
1282
+ const s = Math.min(t.end, n.end) - Math.max(t.start, n.start);
1283
+ Number.isFinite(s) && s >= 0 && s > r && (i = n, r = s);
1024
1284
  }
1025
1285
  return i;
1026
1286
  }
1027
- function lt(t) {
1287
+ function Ut(t) {
1028
1288
  return {
1029
1289
  width: t.mask.width,
1030
1290
  height: t.mask.height,
@@ -1032,11 +1292,11 @@ function lt(t) {
1032
1292
  rowOrder: "north-to-south"
1033
1293
  };
1034
1294
  }
1035
- function Q(t, e = {}) {
1036
- return t.encoding.kind === "vector-luma" ? new st(t, e) : new it(t, e);
1295
+ function pe(t, e = {}) {
1296
+ return t.encoding.kind === "vector-luma" ? new At(t, e) : new xt(t, e);
1037
1297
  }
1038
- const dt = 3, ht = 3, ut = 0.6, ft = 1.5;
1039
- function mt(t) {
1298
+ const Mt = 3, Pt = 3, Dt = 0.6, Gt = 1.5;
1299
+ function Nt(t) {
1040
1300
  const e = new AbortController();
1041
1301
  if (!t)
1042
1302
  return { controller: e, unlink: () => {
@@ -1047,14 +1307,14 @@ function mt(t) {
1047
1307
  unlink: () => t.removeEventListener("abort", i)
1048
1308
  };
1049
1309
  }
1050
- class ti {
1310
+ class _i {
1051
1311
  constructor(e) {
1052
1312
  this.manifests = /* @__PURE__ */ new Map(), this.open = /* @__PURE__ */ new Map(), this.id = e.id, this.chunks = e.chunks.filter(
1053
1313
  (i) => Number.isFinite(i.start) && Number.isFinite(i.end) && i.end >= i.start
1054
- ).sort((i, r) => i.start - r.start), this.maxOpenChunks = Math.max(2, e.maxOpenChunks ?? dt), this.frameCacheSize = Math.max(
1314
+ ).sort((i, r) => i.start - r.start), this.maxOpenChunks = Math.max(2, e.maxOpenChunks ?? Mt), this.frameCacheSize = Math.max(
1055
1315
  1,
1056
- e.frameCacheSize ?? ht
1057
- ), this.prefetchAt = e.prefetchAt ?? ut, this.maxGap = e.maxGap, this.loadManifest = e.loadManifest ?? ze, this.createFrameSource = e.createFrameSource ?? ((i, r) => Q(
1316
+ e.frameCacheSize ?? Pt
1317
+ ), this.prefetchAt = e.prefetchAt ?? Dt, this.maxGap = e.maxGap, this.loadManifest = e.loadManifest ?? ut, this.createFrameSource = e.createFrameSource ?? ((i, r) => pe(
1058
1318
  i,
1059
1319
  r
1060
1320
  ));
@@ -1072,12 +1332,12 @@ class ti {
1072
1332
  /** Every step time of the archive; loads all chunk manifests. */
1073
1333
  async steps(e = {}) {
1074
1334
  if (e.signal?.aborted)
1075
- throw E();
1076
- const i = await x(
1335
+ throw g();
1336
+ const i = await G(
1077
1337
  Promise.all(this.chunks.map((r) => this.manifest(r))),
1078
1338
  e.signal
1079
1339
  );
1080
- return Float64Array.from(i.flatMap(_));
1340
+ return Float64Array.from(i.flatMap(M));
1081
1341
  }
1082
1342
  /**
1083
1343
  * The frames bracketing `time`, decoded; null out of coverage (before the
@@ -1086,42 +1346,42 @@ class ti {
1086
1346
  async sample(e, i = {}) {
1087
1347
  const { signal: r } = i, n = i.mode ?? "interpolate";
1088
1348
  if (r?.aborted)
1089
- throw E();
1090
- const a = this.chunkIndexAt(e);
1091
- if (a < 0)
1349
+ throw g();
1350
+ const s = this.chunkIndexAt(e);
1351
+ if (s < 0)
1092
1352
  return null;
1093
- const o = [], { controller: s, unlink: l } = mt(r);
1353
+ const o = [], { controller: a, unlink: d } = Nt(r);
1094
1354
  try {
1095
- const c = this.acquire(this.chunks[a], o), d = await x(c.ready, s.signal), { times: h } = d;
1096
- let f;
1355
+ const c = this.acquire(this.chunks[s], o), l = await G(c.ready, a.signal), { times: h } = l;
1356
+ let p;
1097
1357
  if (e <= h[h.length - 1]) {
1098
- const { index: g, fraction: R } = b(h, e);
1099
- f = n === "discrete" || R === 0 ? [c, g, c, g, 0] : [c, g, c, g + 1, R];
1358
+ const { index: T, fraction: _ } = v(h, e);
1359
+ p = n === "discrete" || _ === 0 ? [c, T, c, T, 0] : [c, T, c, T + 1, _];
1100
1360
  } else {
1101
- const g = this.chunks[a + 1];
1102
- if (!g)
1361
+ const T = this.chunks[s + 1];
1362
+ if (!T)
1103
1363
  return null;
1104
- const R = this.acquire(g, o), V = await x(R.ready, s.signal), y = h.length - 1, D = h[y], U = V.times[0];
1105
- if (U - D > this.gapLimit(h, V.times))
1364
+ const _ = this.acquire(T, o), F = await G(_.ready, a.signal), S = h.length - 1, k = h[S], P = F.times[0];
1365
+ if (P - k > this.gapLimit(h, F.times))
1106
1366
  return null;
1107
- f = n === "discrete" ? [c, y, c, y, 0] : e >= U ? [R, 0, R, 0, 0] : [c, y, R, 0, (e - D) / (U - D)];
1367
+ p = n === "discrete" ? [c, S, c, S, 0] : e >= P ? [_, 0, _, 0, 0] : [c, S, _, 0, (e - k) / (P - k)];
1108
1368
  }
1109
- const [u, m, T, F, w] = f, L = u === T && m === F, C = [this.frame(u, m, s.signal)];
1110
- L || C.push(this.frame(T, F, s.signal));
1111
- let S;
1369
+ const [m, E, w, y, A] = p, N = m === w && E === y, O = [this.frame(m, E, a.signal)];
1370
+ N || O.push(this.frame(w, y, a.signal));
1371
+ let U;
1112
1372
  try {
1113
- S = await Promise.all(C);
1114
- } catch (g) {
1115
- throw s.abort(), g;
1373
+ U = await Promise.all(O);
1374
+ } catch (T) {
1375
+ throw a.abort(), T;
1116
1376
  }
1117
- return this.prefetchAfter(a, e), {
1377
+ return this.prefetchAfter(s, e), {
1118
1378
  time: e,
1119
- a: S[0],
1120
- b: S[L ? 0 : 1],
1121
- mix: w
1379
+ a: U[0],
1380
+ b: U[N ? 0 : 1],
1381
+ mix: A
1122
1382
  };
1123
1383
  } finally {
1124
- l();
1384
+ d();
1125
1385
  for (const c of o)
1126
1386
  c.users--;
1127
1387
  this.trim();
@@ -1145,8 +1405,8 @@ class ti {
1145
1405
  chunkIndexAt(e) {
1146
1406
  let i = 0, r = this.chunks.length - 1, n = -1;
1147
1407
  for (; i <= r; ) {
1148
- const a = i + r >> 1;
1149
- this.chunks[a].start <= e ? (n = a, i = a + 1) : r = a - 1;
1408
+ const s = i + r >> 1;
1409
+ this.chunks[s].start <= e ? (n = s, i = s + 1) : r = s - 1;
1150
1410
  }
1151
1411
  return n;
1152
1412
  }
@@ -1157,10 +1417,10 @@ class ti {
1157
1417
  e.length > 1 ? e[e.length - 1] - e[e.length - 2] : 0,
1158
1418
  i.length > 1 ? i[1] - i[0] : 0
1159
1419
  ], n = Math.max(...r);
1160
- return n > 0 ? n * ft : -1 / 0;
1420
+ return n > 0 ? n * Gt : -1 / 0;
1161
1421
  }
1162
1422
  prefetchAfter(e, i) {
1163
- const r = this.chunks[e], n = this.chunks[e + 1], a = r.end - r.start, o = a > 0 ? (i - r.start) / a : 1;
1423
+ const r = this.chunks[e], n = this.chunks[e + 1], s = r.end - r.start, o = s > 0 ? (i - r.start) / s : 1;
1164
1424
  n && o > this.prefetchAt && this.prefetch(n);
1165
1425
  }
1166
1426
  manifest(e) {
@@ -1190,11 +1450,11 @@ class ti {
1190
1450
  };
1191
1451
  r.ready = this.manifest(e).then((n) => {
1192
1452
  if (r.released)
1193
- throw E();
1453
+ throw g();
1194
1454
  return r.opened = {
1195
1455
  manifest: n,
1196
- times: Float64Array.from(_(n)),
1197
- grid: lt(n),
1456
+ times: Float64Array.from(M(n)),
1457
+ grid: Ut(n),
1198
1458
  source: this.createFrameSource(n, {
1199
1459
  cacheSize: this.frameCacheSize
1200
1460
  })
@@ -1206,19 +1466,19 @@ class ti {
1206
1466
  return this.open.set(e.key, i), i;
1207
1467
  }
1208
1468
  async frame(e, i, r) {
1209
- const { manifest: n, times: a, grid: o, source: s } = await x(
1469
+ const { manifest: n, times: s, grid: o, source: a } = await G(
1210
1470
  e.ready,
1211
1471
  r
1212
1472
  );
1213
1473
  if (e.released)
1214
- throw E();
1215
- const l = await s.frame(i, { signal: r });
1474
+ throw g();
1475
+ const d = await a.frame(i, { signal: r });
1216
1476
  return {
1217
1477
  key: `${this.id}/${e.chunk.key}/${i}`,
1218
1478
  chunk: e.chunk,
1219
1479
  step: i,
1220
- time: a[i],
1221
- data: l,
1480
+ time: s[i],
1481
+ data: d,
1222
1482
  grid: o,
1223
1483
  manifest: n
1224
1484
  };
@@ -1236,18 +1496,18 @@ class ti {
1236
1496
  e.released = !0, e.prefetch?.abort(), e.prefetch = null, e.opened?.source.release(), e.opened = null, this.open.get(e.chunk.key) === e && this.open.delete(e.chunk.key);
1237
1497
  }
1238
1498
  }
1239
- const Et = {
1499
+ const It = {
1240
1500
  a: "u_vel0",
1241
1501
  b: "u_vel1",
1242
1502
  mix: "u_vel_mix",
1243
1503
  bounds: "u_bounds"
1244
- }, pt = {
1504
+ }, Lt = {
1245
1505
  a: "u_tint0",
1246
1506
  b: "u_tint1",
1247
1507
  mix: "u_tint_mix",
1248
1508
  bounds: "u_tint_bounds"
1249
1509
  };
1250
- function Tt(t) {
1510
+ function Ct(t) {
1251
1511
  const e = new Float32Array(t.u.length * 4);
1252
1512
  for (let i = 0; i < t.u.length; i++) {
1253
1513
  const r = t.u[i], n = t.v[i];
@@ -1255,10 +1515,10 @@ function Tt(t) {
1255
1515
  }
1256
1516
  return e;
1257
1517
  }
1258
- class gt {
1518
+ class Vt {
1259
1519
  constructor(e, i, r = {}) {
1260
- this.gl = e, this.manifest = i, this.options = r, this.textures = /* @__PURE__ */ new Map(), this.pending = /* @__PURE__ */ new Map(), this.mask = null, this.pair = null, this.destroyed = !1, this.linearFilter = !0, this.uploadedFrames = 0, this.lastUploadDurationMs = 0, this.vector = i.encoding.kind === "vector-luma", this.source = Q(i, { cacheSize: 2 }), this.uniforms = this.vector ? Et : pt;
1261
- const n = _(i);
1520
+ this.gl = e, this.manifest = i, this.options = r, this.textures = /* @__PURE__ */ new Map(), this.pending = /* @__PURE__ */ new Map(), this.mask = null, this.pair = null, this.destroyed = !1, this.linearFilter = !0, this.uploadedFrames = 0, this.lastUploadDurationMs = 0, this.vector = i.encoding.kind === "vector-luma", this.source = pe(i, { cacheSize: 2 }), this.uniforms = this.vector ? It : Lt;
1521
+ const n = M(i);
1262
1522
  this.times = r.animateSnapshot && i.timeline.kind === "snapshot-loop" ? Array.from(
1263
1523
  {
1264
1524
  length: Math.max(
@@ -1266,7 +1526,7 @@ class gt {
1266
1526
  Math.round(i.media.durationSeconds * i.media.fps)
1267
1527
  )
1268
1528
  },
1269
- (a, o) => n[0] + o * 1e3 / i.media.fps
1529
+ (s, o) => n[0] + o * 1e3 / i.media.fps
1270
1530
  ) : n, this.bounds = i.bounds;
1271
1531
  }
1272
1532
  get currentPair() {
@@ -1283,12 +1543,16 @@ class gt {
1283
1543
  }
1284
1544
  /** Resolves once the step at `ms` is uploaded. */
1285
1545
  async prime(e) {
1286
- const { index: i } = b(this.times, e);
1546
+ const { index: i } = v(this.times, e);
1287
1547
  await this.request(i);
1288
1548
  }
1549
+ /** The uploaded texture of the step at `ms`, or null. */
1550
+ texture(e) {
1551
+ return this.textures.get(v(this.times, e).index) ?? null;
1552
+ }
1289
1553
  /** True once the frames interpolated at `ms` are uploaded. */
1290
1554
  ready(e) {
1291
- const { index: i, fraction: r } = b(this.times, e);
1555
+ const { index: i, fraction: r } = v(this.times, e);
1292
1556
  return this.textures.has(i) && (r === 0 || this.textures.has(i + 1));
1293
1557
  }
1294
1558
  /**
@@ -1296,12 +1560,12 @@ class gt {
1296
1560
  * `ms`, then request those first.
1297
1561
  */
1298
1562
  focus(e) {
1299
- const { index: i } = b(this.times, e), r = Math.min(i + 1, this.times.length - 1);
1563
+ const { index: i } = v(this.times, e), r = Math.min(i + 1, this.times.length - 1);
1300
1564
  [...this.pending.keys()].some(
1301
- (a) => a !== i && a !== r
1565
+ (s) => s !== i && s !== r
1302
1566
  ) && (this.source.cancelAll(), this.pending.clear());
1303
- for (const a of [i, r])
1304
- this.request(a).catch(() => {
1567
+ for (const s of [i, r])
1568
+ this.request(s).catch(() => {
1305
1569
  });
1306
1570
  }
1307
1571
  /**
@@ -1309,13 +1573,13 @@ class gt {
1309
1573
  * while a requested frame decodes.
1310
1574
  */
1311
1575
  sample(e, i = !0) {
1312
- const { index: r, fraction: n } = b(this.times, e), a = Math.min(r + 1, this.times.length - 1);
1313
- [...this.pending.keys()].some((c) => c < r || c > a + 1) && (this.source.cancelAll(), this.pending.clear());
1314
- for (const c of [r, a, a + 1])
1576
+ const { index: r, fraction: n } = v(this.times, e), s = Math.min(r + 1, this.times.length - 1);
1577
+ [...this.pending.keys()].some((c) => c < r || c > s + 1) && (this.source.cancelAll(), this.pending.clear());
1578
+ for (const c of [r, s, s + 1])
1315
1579
  c < this.times.length && this.request(c).catch(() => {
1316
1580
  });
1317
- const o = this.textures.get(r), s = this.textures.get(a), l = i ? n : 0;
1318
- return o && (l === 0 || s) && (this.pair = [o, l === 0 ? o : s, l]), this.evict(r), this.pair;
1581
+ const o = this.textures.get(r), a = this.textures.get(s), d = i ? n : 0;
1582
+ return o && (d === 0 || a) && (this.pair = [o, d === 0 ? o : a, d]), this.evict(r), this.pair;
1319
1583
  }
1320
1584
  /** Switch spatial filtering without changing the decoded-step cache. */
1321
1585
  setFilter(e) {
@@ -1348,10 +1612,10 @@ class gt {
1348
1612
  return !1;
1349
1613
  const n = this.uniforms;
1350
1614
  if (e.texture(n.a, r, this.pair[0]), e.texture(n.b, r + 1, this.pair[1]), e.float(n.mix, this.pair[2]), e.vec4(n.bounds, this.bounds), this.mask && this.manifest.encoding.kind === "scalar-luma") {
1351
- const { codeRange: a, valueRange: o, transfer: s } = tt(
1615
+ const { codeRange: s, valueRange: o, transfer: a } = Tt(
1352
1616
  this.manifest.encoding
1353
1617
  );
1354
- e.texture("u_tint_mask", r + 2, this.mask), e.vec2("u_code_range", ...a), e.vec2("u_value_range", ...o), e.float("u_scalar_transfer", s);
1618
+ e.texture("u_tint_mask", r + 2, this.mask), e.vec2("u_code_range", ...s), e.vec2("u_value_range", ...o), e.float("u_scalar_transfer", a);
1355
1619
  }
1356
1620
  return !0;
1357
1621
  }
@@ -1369,8 +1633,8 @@ class gt {
1369
1633
  return i;
1370
1634
  const r = this.source.frame(e).then((n) => {
1371
1635
  if (!this.destroyed && this.pending.get(e) === r && !this.textures.has(e)) {
1372
- const a = performance.now();
1373
- this.textures.set(e, this.uploadPreservingState(n)), this.uploadedFrames++, this.lastUploadDurationMs = performance.now() - a, this.options.onReady?.();
1636
+ const s = performance.now();
1637
+ this.textures.set(e, this.uploadPreservingState(n)), this.uploadedFrames++, this.lastUploadDurationMs = performance.now() - s, this.options.onReady?.();
1374
1638
  }
1375
1639
  }).catch((n) => {
1376
1640
  throw !this.destroyed && this.pending.get(e) === r && !(n instanceof Error && n.name === "AbortError") && this.options.onError?.(n), n;
@@ -1387,15 +1651,15 @@ class gt {
1387
1651
  i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,
1388
1652
  i.UNPACK_COLORSPACE_CONVERSION_WEBGL,
1389
1653
  i.UNPACK_ALIGNMENT
1390
- ], a = n.map((o) => i.getParameter(o));
1654
+ ], s = n.map((o) => i.getParameter(o));
1391
1655
  try {
1392
1656
  return this.upload(e);
1393
1657
  } finally {
1394
- i.bindTexture(i.TEXTURE_2D, r), n.forEach((o, s) => i.pixelStorei(o, a[s]));
1658
+ i.bindTexture(i.TEXTURE_2D, r), n.forEach((o, a) => i.pixelStorei(o, s[a]));
1395
1659
  }
1396
1660
  }
1397
1661
  upload(e) {
1398
- const i = this.gl, { width: r, height: n } = this.source, a = this.gridTexture();
1662
+ const i = this.gl, { width: r, height: n } = this.source, s = this.gridTexture();
1399
1663
  return this.vector ? i.texImage2D(
1400
1664
  i.TEXTURE_2D,
1401
1665
  0,
@@ -1405,7 +1669,7 @@ class gt {
1405
1669
  0,
1406
1670
  i.RGBA,
1407
1671
  i.FLOAT,
1408
- Tt(e)
1672
+ Ct(e)
1409
1673
  ) : (i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL, !1), i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL, !1), i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL, i.NONE), i.texImage2D(
1410
1674
  i.TEXTURE_2D,
1411
1675
  0,
@@ -1413,7 +1677,7 @@ class gt {
1413
1677
  i.RGBA,
1414
1678
  i.UNSIGNED_BYTE,
1415
1679
  e
1416
- ), this.mask ??= this.uploadMask()), i.bindTexture(i.TEXTURE_2D, null), a;
1680
+ ), this.mask ??= this.uploadMask()), i.bindTexture(i.TEXTURE_2D, null), s;
1417
1681
  }
1418
1682
  /** The source's mask, loaded with its first frame, as an R8 texture. */
1419
1683
  uploadMask() {
@@ -1458,7 +1722,7 @@ class gt {
1458
1722
  }
1459
1723
  }
1460
1724
  }
1461
- class bt {
1725
+ class Ot {
1462
1726
  constructor(e, i) {
1463
1727
  this.onPlaying = i, this.time = 0, this.endFraction = 0, this.held = !1, this.playingValue = e;
1464
1728
  }
@@ -1469,6 +1733,10 @@ class bt {
1469
1733
  set ms(e) {
1470
1734
  this.time = e, this.endFraction = 0;
1471
1735
  }
1736
+ /** Progress through the final sample's held step, 0 elsewhere. */
1737
+ get holdFraction() {
1738
+ return this.endFraction;
1739
+ }
1472
1740
  get playing() {
1473
1741
  return this.playingValue;
1474
1742
  }
@@ -1483,37 +1751,37 @@ class bt {
1483
1751
  * Advance in step units, including irregular timelines. Returns true at a
1484
1752
  * non-looping end. holdLastStep gives the final sample a full step's duration.
1485
1753
  */
1486
- advance(e, i, r, n = [i[0], i[i.length - 1]], a = !1, o = !1) {
1754
+ advance(e, i, r, n = [i[0], i[i.length - 1]], s = !1, o = !1) {
1487
1755
  if (!this.advancing || !i.length)
1488
1756
  return !1;
1489
- const s = G(i, n[0]), l = G(i, n[1]), c = l + (o ? 1 : 0);
1490
- let d = Math.max(s, G(i, this.ms) + this.endFraction) + Math.max(0, e) * r;
1491
- const h = o ? d >= c : d > c;
1492
- return h && a && c > s ? d = s + (d - s) % (c - s) : d = Math.min(c, d), this.time = rt(i, Math.min(l, d)), this.endFraction = Math.max(0, d - l), h && !a;
1757
+ const a = K(i, n[0]), d = K(i, n[1]), c = d + (o ? 1 : 0);
1758
+ let l = Math.max(a, K(i, this.ms) + this.endFraction) + Math.max(0, e) * r;
1759
+ const h = o ? l >= c : l > c;
1760
+ return h && s && c > a ? l = a + (l - a) % (c - a) : l = Math.min(c, l), this.time = wt(i, Math.min(d, l)), this.endFraction = Math.max(0, l - d), h && !s;
1493
1761
  }
1494
1762
  }
1495
- function A(t) {
1496
- const e = _(t);
1763
+ function X(t) {
1764
+ const e = M(t);
1497
1765
  return [e[0], e[e.length - 1]];
1498
1766
  }
1499
- function N(t, e) {
1767
+ function Q(t, e) {
1500
1768
  return e ? [Math.max(t[0], e[0]), Math.min(t[1], e[1])] : t;
1501
1769
  }
1502
- function k([t, e], i) {
1770
+ function q([t, e], i) {
1503
1771
  return Math.max(t, Math.min(e, i));
1504
1772
  }
1505
- class ii {
1773
+ class Ri {
1506
1774
  constructor(e, i, r) {
1507
1775
  this.repaint = i, this.emit = r, this.field = null, this.manifest = null, this.gl = null, this.pendingField = null, this.standby = null, this.awaitingNext = !1, this.timeRange = null, this.lastTick = null, this.lastStepTime = null, this.seekId = 0, this.seeking = !1, this.failed = !1, this.exactTime = 0, this.endEmitted = !1, this.destroyed = !1, this.resumePlayback = !1, this.playOnReady = e.autoplay ?? !0, this.loop = e.loop ?? !0, this.playbackRate = e.playbackRate ?? 1, this.stepsPerSecond = e.stepsPerSecond;
1508
1776
  const n = typeof e.time == "string" ? Date.parse(e.time) : e.time;
1509
- this.requestedTime = n != null && Number.isFinite(n) ? n : null, this.requestedTimeRange = e.timeRange, this.clock = new bt(
1777
+ this.requestedTime = n != null && Number.isFinite(n) ? n : null, this.requestedTimeRange = e.timeRange, this.clock = new Ot(
1510
1778
  !1,
1511
- (a) => this.emit("playbackChange", a)
1779
+ (s) => this.emit("playbackChange", s)
1512
1780
  );
1513
1781
  }
1514
1782
  async load(e, i) {
1515
- if (this.gl = e, this.manifest = i, this.timeRange = N(
1516
- A(i),
1783
+ if (this.gl = e, this.manifest = i, this.timeRange = Q(
1784
+ X(i),
1517
1785
  this.requestedTimeRange
1518
1786
  ), this.timeRange[0] > this.timeRange[1])
1519
1787
  throw new Error(
@@ -1522,10 +1790,25 @@ class ii {
1522
1790
  this.pendingField = this.createField(i), await this.prepare(this.pendingField);
1523
1791
  }
1524
1792
  sample(e) {
1525
- return this.tick(e), this.field ? this.pendingField || this.seeking ? this.field.currentPair : this.field.sample(
1793
+ if (this.tick(e), !this.field)
1794
+ return null;
1795
+ const i = this.pendingField || this.seeking ? this.field.currentPair : this.field.sample(
1526
1796
  this.clock.advancing ? this.clock.ms : this.exactTime,
1527
1797
  this.clock.advancing && !this.awaitingNext
1528
- ) : null;
1798
+ );
1799
+ return this.handoff(i) ?? i;
1800
+ }
1801
+ /**
1802
+ * Through the final step of a chunk followed by a decoded one, the last
1803
+ * frame blends into the next chunk's first, as steps do within a chunk:
1804
+ * the chunk swap then lands on the frame already shown.
1805
+ */
1806
+ handoff(e) {
1807
+ const i = this.clock.holdFraction, r = this.pendingField ?? this.standby?.field, n = this.pendingField ? this.requestedTime : this.standby?.time;
1808
+ if (!e || i <= 0 || !r || n == null)
1809
+ return null;
1810
+ const s = r.texture(n);
1811
+ return s ? [e[0], s, Math.min(1, i)] : null;
1529
1812
  }
1530
1813
  get time() {
1531
1814
  return this.clock.ms;
@@ -1557,12 +1840,12 @@ class ii {
1557
1840
  const r = this.clock.advance(
1558
1841
  i,
1559
1842
  this.field.times,
1560
- this.stepsPerSecond ?? this.playbackRate * K(this.field.manifest),
1843
+ this.stepsPerSecond ?? this.playbackRate * ue(this.field.manifest),
1561
1844
  this.playbackRange(this.field),
1562
1845
  this.loop,
1563
1846
  !0
1564
- ), { index: n } = b(this.field.times, this.clock.ms), a = this.field.manifest.timeline.kind === "snapshot-loop" ? this.field.times[0] : k(this.timeRange, this.field.times[n]);
1565
- a !== this.lastStepTime && (this.lastStepTime = a, this.emit("timeChange", a)), r ? this.reachEnd() : this.repaint();
1847
+ ), { index: n } = v(this.field.times, this.clock.ms), s = this.field.manifest.timeline.kind === "snapshot-loop" ? this.field.times[0] : q(this.timeRange, this.field.times[n]);
1848
+ s !== this.lastStepTime && (this.lastStepTime = s, this.emit("timeChange", s)), r ? this.reachEnd() : this.repaint();
1566
1849
  }
1567
1850
  setTime(e) {
1568
1851
  const i = typeof e == "number" ? e : Date.parse(e);
@@ -1575,27 +1858,27 @@ class ii {
1575
1858
  /** Load the requested step first; stale seeks and swaps cannot replace it. */
1576
1859
  async prepare(e, i) {
1577
1860
  this.failed = !1;
1578
- const r = ++this.seekId, n = this.timeRange ?? A(e.manifest), a = i ?? k(n, this.requestedTime ?? n[0]), o = b(e.times, a), s = Math.min(
1861
+ const r = ++this.seekId, n = this.timeRange ?? X(e.manifest), s = i ?? q(n, this.requestedTime ?? n[0]), o = v(e.times, s), a = Math.min(
1579
1862
  e.times.length - 1,
1580
1863
  o.index + (o.fraction > 0.5 ? 1 : 0)
1581
- ), l = e.times[s];
1582
- this.seeking = !0, this.lastTick = null, e.focus(l);
1864
+ ), d = e.times[a];
1865
+ this.seeking = !0, this.lastTick = null, e.focus(d);
1583
1866
  try {
1584
- await e.prime(l);
1585
- } catch (d) {
1867
+ await e.prime(d);
1868
+ } catch (l) {
1586
1869
  if (r !== this.seekId)
1587
1870
  return;
1588
- throw d;
1871
+ throw l;
1589
1872
  }
1590
1873
  if (r !== this.seekId || this.destroyed)
1591
1874
  return;
1592
1875
  const c = this.pendingField === e;
1593
- if (c && (this.field?.destroy(), this.field = e, this.pendingField = null, this.lastStepTime = null), this.exactTime = l, this.clock.ms = k(this.playbackRange(e), l), e.sample(l, !1), this.seeking = !1, this.endEmitted = !1, this.repaint(), c) {
1594
- const d = e.manifest;
1876
+ if (c && (this.field?.destroy(), this.field = e, this.pendingField = null, this.lastStepTime = null), this.exactTime = d, this.clock.ms = q(this.playbackRange(e), d), e.sample(d, !1), this.seeking = !1, this.endEmitted = !1, this.repaint(), c) {
1877
+ const l = e.manifest;
1595
1878
  if (this.emit("loaded", {
1596
- min: d.style.colorDomain[0],
1597
- max: d.style.colorDomain[1],
1598
- unit: d.style.unit ?? "",
1879
+ min: l.style.colorDomain[0],
1880
+ max: l.style.colorDomain[1],
1881
+ unit: l.style.unit ?? "",
1599
1882
  time: new Date(this.clock.ms).toISOString()
1600
1883
  }), this.emit("status", { phase: "ready", time: this.clock.ms }), this.playOnReady) {
1601
1884
  this.playOnReady = !1;
@@ -1612,7 +1895,7 @@ class ii {
1612
1895
  this.playOnReady ||= this.isPlaying(), this.pendingField?.destroy();
1613
1896
  const n = this.standby;
1614
1897
  return this.standby = null, n && n.field.manifest.media.url !== e.media.url && n.field.destroy(), this.pendingField = n?.field.manifest.media.url === e.media.url ? n.field : this.createField(e), this.awaitingNext = !1, this.manifest = e, this.requestedTimeRange = i.timeRange, this.timeRange = r, this.requestedTime = i.time ?? r[0], this.loop = i.loop ?? this.loop, this.playbackRate = i.playbackRate ?? this.playbackRate, this.stepsPerSecond = i.stepsPerSecond ?? this.stepsPerSecond, this.lastTick = null, this.prepare(this.pendingField).catch(
1615
- (a) => this.reportError(a)
1898
+ (s) => this.reportError(s)
1616
1899
  ), !0;
1617
1900
  }
1618
1901
  /** Decode the next chunk ahead of its swap, including its static mask. */
@@ -1620,11 +1903,11 @@ class ii {
1620
1903
  const r = this.replacementTimeRange(e, i);
1621
1904
  if (!r || !this.gl || e.media.url === this.manifest?.media.url)
1622
1905
  return !1;
1623
- const n = k(r, i.time ?? r[0]);
1906
+ const n = q(r, i.time ?? r[0]);
1624
1907
  this.standby?.field.manifest.media.url !== e.media.url && (this.discardStandby(), this.standby = { field: this.createField(e), time: n });
1625
- const a = this.standby;
1626
- return a.time = n, a.field.prime(n).catch(() => {
1627
- this.standby === a && this.discardStandby();
1908
+ const s = this.standby;
1909
+ return s.time = n, s.field.focus(n), s.field.prime(n).catch(() => {
1910
+ this.standby === s && this.discardStandby();
1628
1911
  }), !0;
1629
1912
  }
1630
1913
  discardStandby() {
@@ -1635,8 +1918,8 @@ class ii {
1635
1918
  const r = this.manifest;
1636
1919
  if (!r || e.encoding.kind !== r.encoding.kind || e.media.width !== r.media.width || e.media.height !== r.media.height || e.mask.width !== r.mask.width || e.mask.height !== r.mask.height)
1637
1920
  return null;
1638
- const n = N(
1639
- A(e),
1921
+ const n = Q(
1922
+ X(e),
1640
1923
  i.timeRange
1641
1924
  );
1642
1925
  return n[0] <= n[1] ? n : null;
@@ -1657,7 +1940,7 @@ class ii {
1657
1940
  pause() {
1658
1941
  const e = this.playOnReady && !this.clock.playing;
1659
1942
  if (this.playOnReady = !1, this.awaitingNext = !1, this.clock.setPlaying(!1), this.field && !this.pendingField && !this.seeking && !this.endEmitted) {
1660
- const { index: i } = b(this.field.times, this.clock.ms);
1943
+ const { index: i } = v(this.field.times, this.clock.ms);
1661
1944
  this.prepare(this.field, this.field.times[i]).catch(
1662
1945
  (r) => this.reportError(r)
1663
1946
  );
@@ -1681,8 +1964,8 @@ class ii {
1681
1964
  setTimeRange(e) {
1682
1965
  if (!Number.isFinite(e[0]) || !Number.isFinite(e[1]) || e[0] > e[1])
1683
1966
  throw new Error("Invalid GeoVideo time range");
1684
- const i = N(
1685
- this.manifest ? A(this.manifest) : e,
1967
+ const i = Q(
1968
+ this.manifest ? X(this.manifest) : e,
1686
1969
  e
1687
1970
  );
1688
1971
  if (i[0] > i[1])
@@ -1700,7 +1983,7 @@ class ii {
1700
1983
  ];
1701
1984
  }
1702
1985
  createField(e) {
1703
- const i = new gt(this.gl, e, {
1986
+ const i = new Vt(this.gl, e, {
1704
1987
  repeatLongitude: !1,
1705
1988
  animateSnapshot: !0,
1706
1989
  onError: (r) => {
@@ -1715,7 +1998,7 @@ class ii {
1715
1998
  i.name === "AbortError" || this.destroyed || (this.playOnReady = !1, this.awaitingNext = !1, this.failed = !0, this.seeking = !0, this.clock.setPlaying(!1), this.emit("status", { phase: "error", error: i }), this.emit("error", i));
1716
1999
  }
1717
2000
  }
1718
- function I(t) {
2001
+ function Z(t) {
1719
2002
  const { start: e, end: i } = t.temporal ?? {};
1720
2003
  return {
1721
2004
  source: t,
@@ -1723,70 +2006,70 @@ function I(t) {
1723
2006
  end: Date.parse(i ?? e ?? "")
1724
2007
  };
1725
2008
  }
1726
- function ri(t, e, i = {}) {
1727
- const r = t.filter((a) => a.id === e.id && a.temporal?.start != null).map(I), n = ot(
2009
+ function xi(t, e, i = {}) {
2010
+ const r = t.filter((s) => s.id === e.id && s.temporal?.start != null).map(Z), n = Ft(
1728
2011
  r,
1729
2012
  Date.parse(e.temporal?.end ?? ""),
1730
2013
  i
1731
2014
  );
1732
2015
  return n ? { source: n.chunk.source, time: n.time } : null;
1733
2016
  }
1734
- function ni(t, e) {
1735
- return ct(I(t), e.map(I))?.source ?? null;
2017
+ function vi(t, e) {
2018
+ return St(Z(t), e.map(Z))?.source ?? null;
1736
2019
  }
1737
- const Rt = /^P(?:(\d+)Y)?(?:(\d+)M)?(?:(\d+)W)?(?:(\d+)D)?(?:T(?:(\d+)H)?(?:(\d+)M)?(?:(\d+)S)?)?$/;
1738
- function _t(t) {
2020
+ const Bt = /^P(?:(\d+)Y)?(?:(\d+)M)?(?:(\d+)W)?(?:(\d+)D)?(?:T(?:(\d+)H)?(?:(\d+)M)?(?:(\d+)S)?)?$/;
2021
+ function Xt(t) {
1739
2022
  return t instanceof Date ? t.getTime() : typeof t == "number" ? t : new Date(t).getTime();
1740
2023
  }
1741
- function Y(t, e) {
1742
- const i = _t(t);
2024
+ function de(t, e) {
2025
+ const i = Xt(t);
1743
2026
  if (!Number.isFinite(i))
1744
2027
  throw new Error(`Invalid ${e}`);
1745
2028
  return i;
1746
2029
  }
1747
- function ee(t, e) {
1748
- const i = e.match(Rt);
2030
+ function Ee(t, e) {
2031
+ const i = e.match(Bt);
1749
2032
  if (!i)
1750
2033
  throw new Error(`Invalid trailing time duration: ${e}`);
1751
- const r = i.slice(1).map((w) => Number(w ?? 0));
1752
- if (!r.some((w) => w > 0))
2034
+ const r = i.slice(1).map((A) => Number(A ?? 0));
2035
+ if (!r.some((A) => A > 0))
1753
2036
  throw new Error("Trailing time duration must be positive");
1754
- const [n, a, o, s, l, c, d] = r, h = new Date(t), f = h.getUTCFullYear() * 12 + h.getUTCMonth() - n * 12 - a, u = Math.floor(f / 12), m = (f % 12 + 12) % 12, T = new Date(Date.UTC(u, m + 1, 0)).getUTCDate();
2037
+ const [n, s, o, a, d, c, l] = r, h = new Date(t), p = h.getUTCFullYear() * 12 + h.getUTCMonth() - n * 12 - s, m = Math.floor(p / 12), E = (p % 12 + 12) % 12, w = new Date(Date.UTC(m, E + 1, 0)).getUTCDate();
1755
2038
  return Date.UTC(
1756
- u,
1757
2039
  m,
1758
- Math.min(h.getUTCDate(), T),
2040
+ E,
2041
+ Math.min(h.getUTCDate(), w),
1759
2042
  h.getUTCHours(),
1760
2043
  h.getUTCMinutes(),
1761
2044
  h.getUTCSeconds(),
1762
2045
  h.getUTCMilliseconds()
1763
- ) - (((o * 7 + s) * 24 + l) * 60 + c) * 6e4 - d * 1e3;
2046
+ ) - (((o * 7 + a) * 24 + d) * 60 + c) * 6e4 - l * 1e3;
1764
2047
  }
1765
- function ai(t, [e, i]) {
2048
+ function ki(t, [e, i]) {
1766
2049
  let r = e, n = i;
1767
- if (typeof t.trailing == "string" ? r = ee(i, t.trailing) : (t.start != null && (r = Y(t.start, "time range start")), t.end != null && (n = Y(t.end, "time range end"))), r > n)
2050
+ if (typeof t.trailing == "string" ? r = Ee(i, t.trailing) : (t.start != null && (r = de(t.start, "time range start")), t.end != null && (n = de(t.end, "time range end"))), r > n)
1768
2051
  throw new Error("Time range start must not follow its end");
1769
2052
  return [Math.max(e, r), Math.min(i, n)];
1770
2053
  }
1771
- const xt = (t) => typeof t == "object" && t !== null && !Array.isArray(t);
1772
- function si(t, e) {
1773
- if (!xt(t))
2054
+ const qt = (t) => typeof t == "object" && t !== null && !Array.isArray(t);
2055
+ function Ai(t, e) {
2056
+ if (!qt(t))
1774
2057
  throw new Error(`${e} must be an object`);
1775
- for (const a of Object.keys(t))
1776
- if (a !== "start" && a !== "end" && a !== "trailing")
1777
- throw new Error(`${e}.${a} is not a time range key`);
2058
+ for (const s of Object.keys(t))
2059
+ if (s !== "start" && s !== "end" && s !== "trailing")
2060
+ throw new Error(`${e}.${s} is not a time range key`);
1778
2061
  if (t.trailing !== void 0) {
1779
2062
  if (t.start !== void 0 || t.end !== void 0)
1780
2063
  throw new Error(`${e}.trailing excludes start and end`);
1781
2064
  if (typeof t.trailing != "string")
1782
2065
  throw new Error(`${e}.trailing must be an ISO 8601 duration`);
1783
- return ee(0, t.trailing), { trailing: t.trailing };
2066
+ return Ee(0, t.trailing), { trailing: t.trailing };
1784
2067
  }
1785
- const i = (a) => {
1786
- const o = t[a];
2068
+ const i = (s) => {
2069
+ const o = t[s];
1787
2070
  if (o !== void 0) {
1788
2071
  if (typeof o != "string" || !Number.isFinite(Date.parse(o)))
1789
- throw new Error(`${e}.${a} is not a date`);
2072
+ throw new Error(`${e}.${s} is not a date`);
1790
2073
  return o;
1791
2074
  }
1792
2075
  }, r = i("start"), n = i("end");
@@ -1797,37 +2080,37 @@ function si(t, e) {
1797
2080
  ...n !== void 0 && { end: n }
1798
2081
  };
1799
2082
  }
1800
- function oi(t) {
2083
+ function Fi(t) {
1801
2084
  return t.type === "geovideo" && typeof t.indexUrl == "string";
1802
2085
  }
1803
- function ci(t, e) {
2086
+ function Si(t, e) {
1804
2087
  return t.id === e.id && (t.type !== "geovideo" || e.type !== "geovideo" || t.manifestUrl === e.manifestUrl);
1805
2088
  }
1806
- function j(t) {
2089
+ function le(t) {
1807
2090
  return typeof t == "string" && Number.isFinite(Date.parse(t));
1808
2091
  }
1809
- function wt(t) {
2092
+ function $t(t) {
1810
2093
  const e = t;
1811
2094
  if (!e || e.schemaVersion !== 1 || e.type !== "geovideo-index" || !Array.isArray(e.chunks))
1812
2095
  throw new Error("Unsupported GeoVideo index");
1813
2096
  for (const i of e.chunks)
1814
- if (!j(i?.start) || !j(i.end) || Date.parse(i.end) < Date.parse(i.start) || typeof i.manifestUrl != "string")
2097
+ if (!le(i?.start) || !le(i.end) || Date.parse(i.end) < Date.parse(i.start) || typeof i.manifestUrl != "string")
1815
2098
  throw new Error("Invalid GeoVideo index chunk");
1816
2099
  return e;
1817
2100
  }
1818
- async function li(t, e) {
2101
+ async function Ui(t, e) {
1819
2102
  const i = await fetch(t, { signal: e });
1820
2103
  if (!i.ok)
1821
2104
  throw new Error(
1822
2105
  `GeoVideo index request failed (${i.status}): ${t}`
1823
2106
  );
1824
- return wt(await i.json());
2107
+ return $t(await i.json());
1825
2108
  }
1826
- function yt(t) {
2109
+ function Wt(t) {
1827
2110
  return typeof document < "u" ? new URL(t, document.baseURI).href : t;
1828
2111
  }
1829
- function vt(t, e) {
1830
- const i = yt(e);
2112
+ function Ht(t, e) {
2113
+ const i = Wt(e);
1831
2114
  return t.chunks.map((r) => ({
1832
2115
  key: r.key,
1833
2116
  manifestUrl: new URL(r.manifestUrl, i).href,
@@ -1837,17 +2120,17 @@ function vt(t, e) {
1837
2120
  ...r.provisional ? { provisional: !0 } : {}
1838
2121
  }));
1839
2122
  }
1840
- function At(t, e, i) {
2123
+ function zt(t, e, i) {
1841
2124
  if (e.sourceId !== t.id || e.catalogEntryId !== i.id)
1842
2125
  throw new Error(
1843
2126
  `GeoVideo index identity does not match catalog entry/source: ${t.id}`
1844
2127
  );
1845
2128
  }
1846
- function di(t, e, i) {
1847
- At(t, e, i);
1848
- const r = vt(e, t.indexUrl);
2129
+ function Mi(t, e, i) {
2130
+ zt(t, e, i);
2131
+ const r = Ht(e, t.indexUrl);
1849
2132
  return e.chunks.map(
1850
- (n, a) => ({
2133
+ (n, s) => ({
1851
2134
  id: t.id,
1852
2135
  type: "geovideo",
1853
2136
  title: t.title,
@@ -1858,75 +2141,76 @@ function di(t, e, i) {
1858
2141
  start: n.start,
1859
2142
  end: n.end
1860
2143
  },
1861
- manifestUrl: r[a].manifestUrl
2144
+ manifestUrl: r[s].manifestUrl
1862
2145
  })
1863
2146
  );
1864
2147
  }
1865
2148
  export {
1866
- Ve as $,
1867
- K as A,
1868
- Bt as B,
1869
- oi as C,
1870
- ri as D,
1871
- li as E,
1872
- di as F,
1873
- Zt as G,
1874
- ai as H,
1875
- ei as I,
1876
- $ as J,
1877
- $t as K,
1878
- Yt as L,
1879
- zt as M,
1880
- ti as N,
1881
- bt as O,
1882
- gt as P,
1883
- J as Q,
1884
- it as R,
1885
- st as S,
1886
- qt as T,
1887
- Ht as U,
1888
- jt as V,
1889
- Wt as W,
1890
- ye as X,
1891
- At as Y,
1892
- Q as Z,
1893
- X as _,
1894
- It as a,
1895
- lt as a0,
1896
- vt as a1,
1897
- ot as a2,
1898
- ni as a3,
1899
- ct as a4,
1900
- si as a5,
1901
- rt as a6,
1902
- ee as a7,
1903
- b as a8,
1904
- G as a9,
1905
- wt as aa,
1906
- Tt as ab,
1907
- Lt as b,
1908
- St as c,
1909
- Pt as d,
1910
- Mt as e,
1911
- Nt as f,
1912
- Ct as g,
1913
- Dt as h,
1914
- Gt as i,
1915
- Kt as j,
1916
- Ut as k,
1917
- Ot as l,
1918
- ii as m,
1919
- Xt as n,
1920
- ze as o,
1921
- tt as p,
1922
- De as q,
1923
- Me as r,
1924
- Vt as s,
1925
- Ke as t,
1926
- Ft as u,
1927
- Jt as v,
1928
- Y as w,
1929
- _ as x,
1930
- ci as y,
1931
- Qt as z
2149
+ ne as $,
2150
+ ue as A,
2151
+ ci as B,
2152
+ Fi as C,
2153
+ xi as D,
2154
+ Ui as E,
2155
+ Mi as F,
2156
+ Ti as G,
2157
+ ki as H,
2158
+ yi as I,
2159
+ oe as J,
2160
+ ui as K,
2161
+ mi as L,
2162
+ Ei as M,
2163
+ _i as N,
2164
+ Ot as O,
2165
+ xt as P,
2166
+ Vt as Q,
2167
+ me as R,
2168
+ bt as S,
2169
+ li as T,
2170
+ At as U,
2171
+ fi as V,
2172
+ pi as W,
2173
+ hi as X,
2174
+ Be as Y,
2175
+ zt as Z,
2176
+ pe as _,
2177
+ ri as a,
2178
+ it as a0,
2179
+ Ut as a1,
2180
+ Ht as a2,
2181
+ Ft as a3,
2182
+ vi as a4,
2183
+ St as a5,
2184
+ Ai as a6,
2185
+ wt as a7,
2186
+ Ee as a8,
2187
+ v as a9,
2188
+ K as aa,
2189
+ $t as ab,
2190
+ Ct as ac,
2191
+ ni as b,
2192
+ Kt as c,
2193
+ Jt as d,
2194
+ ei as e,
2195
+ ii as f,
2196
+ si as g,
2197
+ Qt as h,
2198
+ ti as i,
2199
+ gi as j,
2200
+ Zt as k,
2201
+ oi as l,
2202
+ Ri as m,
2203
+ di as n,
2204
+ ut as o,
2205
+ Tt as p,
2206
+ ze as q,
2207
+ Ke as r,
2208
+ ai as s,
2209
+ ft as t,
2210
+ jt as u,
2211
+ bi as v,
2212
+ de as w,
2213
+ M as x,
2214
+ Si as y,
2215
+ wi as z
1932
2216
  };