@fxi/zartigl 0.7.1 → 0.9.0

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,29 +1,30 @@
1
- const $ = { label: "Thermal", tags: ["sequential", "temperature"], colors: ["#042333", "#2c3395", "#744796", "#b15f82", "#eb7958", "#fbb43d", "#e8fa5b"] }, W = { label: "Haline", tags: ["sequential", "salinity"], colors: ["#2a186c", "#17568b", "#1a7e8f", "#22a785", "#55c666", "#aadc32", "#fde333"] }, H = { label: "Solar", tags: ["sequential", "irradiance"], colors: ["#330f0b", "#6b2313", "#a83c12", "#d6621a", "#f3951e", "#f7c741", "#f9f871"] }, Y = { label: "Ice", tags: ["sequential"], colors: ["#040d1a", "#123365", "#1c5f9e", "#2b8ece", "#62bde3", "#aaddf2", "#f2faff"] }, z = { label: "Deep", tags: ["sequential", "depth"], colors: ["#fdfecc", "#c8e59b", "#74c8a3", "#3194b0", "#2a5b8e", "#281a5e", "#0c0820"] }, j = { label: "RdYlBu", tags: ["diverging"], colors: ["#3288bd", "#66c2a5", "#abdda4", "#e6f598", "#fee08b", "#fdae61", "#f46d43", "#d53e4f"] }, K = { label: "Dense", tags: ["sequential"], colors: ["#e6f1f1", "#92c4ca", "#44929a", "#20627a", "#1a3c6a", "#211a50", "#0d0621"] }, J = { label: "Algae", tags: ["sequential", "biology", "log"], colors: ["#d7f9d0", "#a2d595", "#64b463", "#129450", "#126e45", "#1a482f", "#122414"] }, Q = { label: "Oxygen", tags: ["sequential", "biology", "hypoxia"], colors: ["#09060f", "#5b1028", "#d43d2f", "#f39b3d", "#f3e7b3", "#79cbd1", "#176b9c"] }, Z = { label: "Matter", tags: ["sequential", "biology"], colors: ["#fdfecc", "#f2c98a", "#e07c4e", "#bc3754", "#8d1a6d", "#51156b", "#1c0c3f"] }, ee = { label: "Viridis", tags: ["sequential", "perceptual"], colors: ["#440154", "#443983", "#31688e", "#21918c", "#35b779", "#90d743", "#fde725"] }, te = { label: "Plasma", tags: ["sequential", "perceptual"], colors: ["#0d0887", "#5e01a6", "#9c179e", "#cc4778", "#ed7953", "#fdb42f", "#f0f921"] }, re = { label: "Cyclic", tags: ["cyclic", "direction"], colors: ["#2e22ea", "#b541fb", "#fc93c0", "#f1ee35", "#77c80d", "#458776", "#2c24e9"] }, ne = { label: "Tempo", tags: ["sequential"], colors: ["#fff6f4", "#c2d1b9", "#7db390", "#2a937f", "#156d73", "#1c455b", "#151d44"] }, ae = { label: "Turbid", tags: ["sequential", "biology", "log"], colors: ["#e9f5a0", "#c8c86e", "#a09845", "#786031", "#533324", "#341423", "#150d17"] }, ie = { label: "Speed", tags: ["sequential", "velocity"], colors: ["#fcfea4", "#d5e429", "#94c63e", "#52a657", "#2d8169", "#1d5b6d", "#0d3361"] }, oe = { label: "Amp", tags: ["sequential"], colors: ["#f2f2f2", "#c0b8db", "#9180b6", "#6c4e9e", "#4e2e83", "#32185d", "#110a35"] }, se = { label: "Balance", tags: ["diverging"], colors: ["#181c43", "#3066af", "#9bbcdd", "#f2f2f2", "#e07d53", "#b13626", "#2c0b0e"] }, ce = { label: "Delta", tags: ["diverging"], colors: ["#0e3f31", "#20877b", "#99d4c1", "#f2f2f2", "#a1b0d4", "#3c5b9e", "#0d1938"] }, de = { label: "Curl", tags: ["diverging"], colors: ["#152237", "#2471b3", "#8dbac4", "#f2f2f2", "#c79f84", "#a63827", "#270b17"] }, ue = { label: "Gray", tags: ["sequential"], colors: ["#000000", "#252525", "#4d4d4d", "#7a7a7a", "#a8a8a8", "#d4d4d4", "#ffffff"] }, g = {
2
- thermal: $,
1
+ const W = { label: "Thermal", tags: ["sequential", "temperature"], colors: ["#042333", "#2c3395", "#744796", "#b15f82", "#eb7958", "#fbb43d", "#e8fa5b"] }, H = { label: "Haline", tags: ["sequential", "salinity"], colors: ["#2a186c", "#17568b", "#1a7e8f", "#22a785", "#55c666", "#aadc32", "#fde333"] }, Y = { label: "Solar", tags: ["sequential", "irradiance"], colors: ["#330f0b", "#6b2313", "#a83c12", "#d6621a", "#f3951e", "#f7c741", "#f9f871"] }, z = { label: "Ice", tags: ["sequential"], colors: ["#040d1a", "#123365", "#1c5f9e", "#2b8ece", "#62bde3", "#aaddf2", "#f2faff"] }, j = { label: "Deep", tags: ["sequential", "depth"], colors: ["#fdfecc", "#c8e59b", "#74c8a3", "#3194b0", "#2a5b8e", "#281a5e", "#0c0820"] }, K = { label: "RdYlBu", tags: ["diverging"], colors: ["#3288bd", "#66c2a5", "#abdda4", "#e6f598", "#fee08b", "#fdae61", "#f46d43", "#d53e4f"] }, J = { label: "Dense", tags: ["sequential"], colors: ["#e6f1f1", "#92c4ca", "#44929a", "#20627a", "#1a3c6a", "#211a50", "#0d0621"] }, Q = { label: "Algae", tags: ["sequential", "biology", "log"], colors: ["#d7f9d0", "#a2d595", "#64b463", "#129450", "#126e45", "#1a482f", "#122414"] }, Z = { label: "Oxygen", tags: ["sequential", "biology", "hypoxia"], colors: ["#09060f", "#5b1028", "#d43d2f", "#f39b3d", "#f3e7b3", "#79cbd1", "#176b9c"] }, ee = { label: "Matter", tags: ["sequential", "biology"], colors: ["#fdfecc", "#f2c98a", "#e07c4e", "#bc3754", "#8d1a6d", "#51156b", "#1c0c3f"] }, te = { label: "Viridis", tags: ["sequential", "perceptual"], colors: ["#440154", "#443983", "#31688e", "#21918c", "#35b779", "#90d743", "#fde725"] }, re = { label: "Plasma", tags: ["sequential", "perceptual"], colors: ["#0d0887", "#5e01a6", "#9c179e", "#cc4778", "#ed7953", "#fdb42f", "#f0f921"] }, ne = { label: "Cyclic", tags: ["cyclic", "direction"], colors: ["#2e22ea", "#b541fb", "#fc93c0", "#f1ee35", "#77c80d", "#458776", "#2c24e9"] }, ae = { label: "Tempo", tags: ["sequential"], colors: ["#fff6f4", "#c2d1b9", "#7db390", "#2a937f", "#156d73", "#1c455b", "#151d44"] }, ie = { label: "Turbid", tags: ["sequential", "biology", "log"], colors: ["#e9f5a0", "#c8c86e", "#a09845", "#786031", "#533324", "#341423", "#150d17"] }, oe = { label: "Speed", tags: ["sequential", "velocity"], colors: ["#fcfea4", "#d5e429", "#94c63e", "#52a657", "#2d8169", "#1d5b6d", "#0d3361"] }, se = { label: "Amp", tags: ["sequential"], colors: ["#f2f2f2", "#c0b8db", "#9180b6", "#6c4e9e", "#4e2e83", "#32185d", "#110a35"] }, ce = { label: "Balance", tags: ["diverging"], colors: ["#181c43", "#3066af", "#9bbcdd", "#f2f2f2", "#e07d53", "#b13626", "#2c0b0e"] }, de = { label: "Delta", tags: ["diverging"], colors: ["#0e3f31", "#20877b", "#99d4c1", "#f2f2f2", "#a1b0d4", "#3c5b9e", "#0d1938"] }, ue = { label: "Curl", tags: ["diverging"], colors: ["#152237", "#2471b3", "#8dbac4", "#f2f2f2", "#c79f84", "#a63827", "#270b17"] }, le = { label: "Gray", tags: ["sequential"], colors: ["#000000", "#252525", "#4d4d4d", "#7a7a7a", "#a8a8a8", "#d4d4d4", "#ffffff"] }, X = {
2
+ thermal: W,
3
3
  "thermal-alt": { label: "Thermal Alt", tags: ["sequential", "temperature"], colors: ["#176b9c", "#79cbd1", "#f3e7b3", "#f39b3d", "#d43d2f", "#5b1028", "#09060f"] },
4
- haline: W,
5
- solar: H,
6
- ice: Y,
7
- deep: z,
8
- rdylbu: j,
9
- dense: K,
10
- algae: J,
11
- oxygen: Q,
12
- matter: Z,
13
- viridis: ee,
14
- plasma: te,
15
- cyclic: re,
16
- tempo: ne,
17
- turbid: ae,
18
- speed: ie,
19
- amp: oe,
20
- balance: se,
21
- delta: ce,
22
- curl: de,
4
+ haline: H,
5
+ solar: Y,
6
+ ice: z,
7
+ deep: j,
8
+ rdylbu: K,
9
+ dense: J,
10
+ algae: Q,
11
+ oxygen: Z,
12
+ matter: ee,
13
+ viridis: te,
14
+ plasma: re,
15
+ cyclic: ne,
16
+ tempo: ae,
17
+ turbid: ie,
18
+ speed: oe,
19
+ amp: se,
20
+ "heat-alert": { label: "Heat Alert", tags: ["sequential", "alpha"], colors: ["#fde72500", "#fde725cc", "#f8961e", "#e63946", "#9d0208", "#3a0007"] },
21
+ balance: ce,
22
+ delta: de,
23
+ curl: ue,
23
24
  "mono-black": { label: "Black", tags: ["monochrome", "particles"], colors: ["#000000", "#000000"] },
24
25
  "mono-white": { label: "White", tags: ["monochrome", "particles"], colors: ["#ffffff", "#ffffff"] },
25
26
  "mono-pink": { label: "Pink", tags: ["monochrome", "particles"], colors: ["#ff2aa1", "#ff2aa1"] },
26
- gray: ue
27
+ gray: le
27
28
  };
28
29
  function I(e) {
29
30
  const t = {}, r = e.length - 1;
@@ -32,7 +33,7 @@ function I(e) {
32
33
  }), t;
33
34
  }
34
35
  function fe(e, t) {
35
- const r = g;
36
+ const r = X;
36
37
  if (typeof e == "string") {
37
38
  const n = r[e];
38
39
  if (!n)
@@ -50,10 +51,10 @@ function fe(e, t) {
50
51
  }
51
52
  return e;
52
53
  }
53
- function Ye() {
54
- return Object.entries(g).map(([t, r]) => ({ id: t, ...r }));
54
+ function je() {
55
+ return Object.entries(X).map(([t, r]) => ({ id: t, ...r }));
55
56
  }
56
- function N(e, t, r) {
57
+ function g(e, t, r) {
57
58
  const n = e.createShader(t);
58
59
  if (!n)
59
60
  throw new Error("Failed to create shader");
@@ -63,18 +64,18 @@ function N(e, t, r) {
63
64
  }
64
65
  return n;
65
66
  }
66
- function ze(e, t, r) {
67
+ function Ke(e, t, r) {
67
68
  const n = e.createProgram();
68
69
  if (!n)
69
70
  throw new Error("Failed to create program");
70
- const a = N(e, e.VERTEX_SHADER, t), i = N(e, e.FRAGMENT_SHADER, r);
71
+ const a = g(e, e.VERTEX_SHADER, t), i = g(e, e.FRAGMENT_SHADER, r);
71
72
  if (e.attachShader(n, a), e.attachShader(n, i), e.linkProgram(n), !e.getProgramParameter(n, e.LINK_STATUS)) {
72
73
  const s = e.getProgramInfoLog(n);
73
74
  throw e.deleteProgram(n), new Error(`Program link error: ${s}`);
74
75
  }
75
76
  return e.deleteShader(a), e.deleteShader(i), n;
76
77
  }
77
- function je(e, t, r, n, a) {
78
+ function Je(e, t, r, n, a) {
78
79
  const i = e.createTexture();
79
80
  if (!i)
80
81
  throw new Error("Failed to create texture");
@@ -90,7 +91,7 @@ function je(e, t, r, n, a) {
90
91
  r
91
92
  ), e.bindTexture(e.TEXTURE_2D, null), i;
92
93
  }
93
- function le(e, t, r) {
94
+ function he(e, t, r) {
94
95
  const n = e.getParameter(
95
96
  e.TEXTURE_BINDING_2D
96
97
  ), a = e.getParameter(
@@ -122,19 +123,19 @@ function le(e, t, r) {
122
123
  }
123
124
  return o;
124
125
  }
125
- function he(e) {
126
+ function me(e) {
126
127
  return {
127
128
  kind: "rgba8-packed",
128
129
  internalFormat: e.RGBA,
129
130
  type: e.UNSIGNED_BYTE
130
131
  };
131
132
  }
132
- function Ke(e) {
133
+ function Qe(e) {
133
134
  if (typeof WebGL2RenderingContext > "u" || !(e instanceof WebGL2RenderingContext))
134
135
  throw new Error("zartigl requires WebGL2");
135
136
  return e;
136
137
  }
137
- function Je(e) {
138
+ function Ze(e) {
138
139
  const t = [];
139
140
  e.getExtension("EXT_color_buffer_float") ? t.push(
140
141
  { kind: "float32", internalFormat: e.RGBA32F, type: e.FLOAT },
@@ -145,15 +146,15 @@ function Je(e) {
145
146
  type: e.HALF_FLOAT
146
147
  });
147
148
  for (const r of t)
148
- if (le(
149
+ if (he(
149
150
  e,
150
151
  r.internalFormat,
151
152
  r.type
152
153
  ))
153
154
  return r;
154
- return he(e);
155
+ return me(e);
155
156
  }
156
- function Qe(e, t, r, n, a, i, s) {
157
+ function et(e, t, r, n, a, i, s) {
157
158
  const o = e.createTexture();
158
159
  if (!o)
159
160
  throw new Error("Failed to create texture");
@@ -169,10 +170,10 @@ function Qe(e, t, r, n, a, i, s) {
169
170
  r
170
171
  ), e.bindTexture(e.TEXTURE_2D, null), o;
171
172
  }
172
- function Ze(e, t, r) {
173
+ function tt(e, t, r) {
173
174
  e.activeTexture(e.TEXTURE0 + r), e.bindTexture(e.TEXTURE_2D, t);
174
175
  }
175
- function et(e, t) {
176
+ function rt(e, t) {
176
177
  const r = e.createFramebuffer();
177
178
  if (!r)
178
179
  throw new Error("Failed to create framebuffer");
@@ -184,7 +185,7 @@ function et(e, t) {
184
185
  0
185
186
  ), e.bindFramebuffer(e.FRAMEBUFFER, null), r;
186
187
  }
187
- function tt(e) {
188
+ function nt(e) {
188
189
  const t = e.createBuffer();
189
190
  if (!t)
190
191
  throw new Error("Failed to create buffer");
@@ -194,7 +195,7 @@ function tt(e) {
194
195
  e.STATIC_DRAW
195
196
  ), t;
196
197
  }
197
- const me = {
198
+ const Ee = {
198
199
  0: "#3288bd",
199
200
  0.1: "#66c2a5",
200
201
  0.2: "#abdda4",
@@ -204,19 +205,19 @@ const me = {
204
205
  0.6: "#f46d43",
205
206
  1: "#d53e4f"
206
207
  };
207
- function rt(e, t) {
208
- const r = t != null ? fe(t) : me, n = document.createElement("canvas");
208
+ function at(e, t) {
209
+ const r = t != null ? fe(t) : Ee, n = document.createElement("canvas");
209
210
  n.width = 256, n.height = 1;
210
211
  const a = n.getContext("2d"), i = a.createLinearGradient(0, 0, 256, 0);
211
- for (const [o, c] of Object.entries(r))
212
- i.addColorStop(Number(o), c);
212
+ for (const [o, d] of Object.entries(r))
213
+ i.addColorStop(Number(o), d);
213
214
  a.fillStyle = i, a.fillRect(0, 0, 256, 1);
214
215
  const s = e.createTexture();
215
216
  if (!s)
216
217
  throw new Error("Failed to create color ramp texture");
217
218
  return e.bindTexture(e.TEXTURE_2D, s), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_WRAP_S, e.CLAMP_TO_EDGE), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_WRAP_T, e.CLAMP_TO_EDGE), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_MIN_FILTER, e.LINEAR), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_MAG_FILTER, e.LINEAR), e.texImage2D(e.TEXTURE_2D, 0, e.RGBA, e.RGBA, e.UNSIGNED_BYTE, n), e.bindTexture(e.TEXTURE_2D, null), s;
218
219
  }
219
- function nt(e) {
220
+ function it(e) {
220
221
  const t = e.getExtension("WEBGL_debug_renderer_info");
221
222
  return {
222
223
  vendor: String(e.getParameter(e.VENDOR) ?? ""),
@@ -226,7 +227,7 @@ function nt(e) {
226
227
  version: String(e.getParameter(e.VERSION) ?? "")
227
228
  };
228
229
  }
229
- function at(e) {
230
+ function ot(e) {
230
231
  return {
231
232
  program: e.getParameter(e.CURRENT_PROGRAM),
232
233
  activeTexture: e.getParameter(e.ACTIVE_TEXTURE),
@@ -243,19 +244,78 @@ function at(e) {
243
244
  ]
244
245
  };
245
246
  }
246
- function it(e, t) {
247
+ function st(e, t) {
247
248
  e.useProgram(t.program), e.activeTexture(t.activeTexture), e.bindBuffer(e.ARRAY_BUFFER, t.arrayBuffer), e.bindBuffer(e.ELEMENT_ARRAY_BUFFER, t.elementBuffer), e.bindFramebuffer(e.FRAMEBUFFER, t.framebuffer), t.blend ? e.enable(e.BLEND) : e.disable(e.BLEND), t.depthTest ? e.enable(e.DEPTH_TEST) : e.disable(e.DEPTH_TEST), t.stencilTest ? e.enable(e.STENCIL_TEST) : e.disable(e.STENCIL_TEST), e.viewport(t.viewport[0], t.viewport[1], t.viewport[2], t.viewport[3]), e.blendFunc(t.blendFunc[0], t.blendFunc[1]);
248
249
  }
249
- const L = 20, Ee = 600;
250
- function Te(e) {
250
+ const Te = {
251
+ degrees_c: "°C",
252
+ degc: "°C",
253
+ degrees_celsius: "°C",
254
+ degree_celsius: "°C",
255
+ celsius: "°C",
256
+ // Degree heating weeks accumulate °C over weeks: a product, not a rate.
257
+ degree_celsius_weeks: "°C-weeks",
258
+ degree: "°",
259
+ degrees: "°",
260
+ kelvin: "K",
261
+ 1: "",
262
+ "1e-3": "PSU",
263
+ "0.001": "PSU",
264
+ psu: "PSU",
265
+ stress_level: ""
266
+ }, pe = {
267
+ meter: "m",
268
+ meters: "m",
269
+ metre: "m",
270
+ metres: "m",
271
+ second: "s",
272
+ seconds: "s",
273
+ day: "d",
274
+ days: "d",
275
+ hour: "h",
276
+ hours: "h",
277
+ gram: "g",
278
+ grams: "g",
279
+ milligram: "mg",
280
+ milligrams: "mg",
281
+ kilogram: "kg",
282
+ kilograms: "kg",
283
+ mole: "mol",
284
+ millimole: "mmol",
285
+ watt: "W",
286
+ newton: "N",
287
+ pascal: "Pa",
288
+ kelvin: "K"
289
+ }, be = "⁰¹²³⁴⁵⁶⁷⁸⁹";
290
+ function C(e) {
291
+ return e === 1 ? "" : [...String(e)].map((t) => be[Number(t)]).join("");
292
+ }
293
+ function ct(e) {
294
+ const t = e?.trim() ?? "", r = Te[t.toLowerCase()];
295
+ if (r != null)
296
+ return r;
297
+ if (t.includes("/"))
298
+ return t;
299
+ const n = [], a = [];
300
+ for (const i of t.split(/\s+/)) {
301
+ const s = /^([A-Za-z]+)\^?(-?\d+)?$/.exec(i);
302
+ if (!s)
303
+ return t.replace(/_/g, " ");
304
+ const o = pe[s[1]] ?? s[1], d = Number(s[2] ?? 1);
305
+ d < 0 ? a.push(o + C(-d)) : n.push(o + C(d));
306
+ }
307
+ return [n.join(" ") || "1", ...a].join("/");
308
+ }
309
+ const N = 20, we = 600;
310
+ function Re(e) {
251
311
  const t = Math.max(0, Math.min(1, e));
252
- return L * Math.pow(Ee / L, t);
312
+ return N * Math.pow(we / N, t);
253
313
  }
254
- function ot(e) {
255
- return Math.exp(-1 / Te(e));
314
+ function dt(e) {
315
+ return Math.exp(-1 / Re(e));
256
316
  }
257
- const pe = 0.8, be = 120, we = 300;
258
- class st {
317
+ const _e = 0.8, Ae = 120, Fe = 300;
318
+ class ut {
259
319
  constructor(t) {
260
320
  this.base = t, this.moving = !1, this.start = 0, this.duration = 0, this.from = t, this.to = t;
261
321
  }
@@ -264,7 +324,7 @@ class st {
264
324
  this.base = t, this.moving || (this.from = t, this.to = t, this.duration = 0);
265
325
  }
266
326
  setMoving(t, r) {
267
- t !== this.moving && (this.from = this.value(r), this.moving = t, this.to = t ? pe : this.base, this.start = r, this.duration = t ? be : we);
327
+ t !== this.moving && (this.from = this.value(r), this.moving = t, this.to = t ? _e : this.base, this.start = r, this.duration = t ? Ae : Fe);
268
328
  }
269
329
  value(t) {
270
330
  if (this.duration === 0)
@@ -273,7 +333,7 @@ class st {
273
333
  return r === 1 ? (this.duration = 0, this.from = this.to, this.to) : this.from + (this.to - this.from) * r * r * (3 - 2 * r);
274
334
  }
275
335
  }
276
- function ct(e) {
336
+ function lt(e) {
277
337
  if (e == null)
278
338
  return null;
279
339
  if (!Number.isFinite(e[0]) || !Number.isFinite(e[1]) || e[0] >= e[1])
@@ -295,12 +355,12 @@ function F(e, t) {
295
355
  throw new Error(`Invalid GeoVideo manifest ${t}`);
296
356
  return r;
297
357
  }
298
- function D(e) {
358
+ function S(e) {
299
359
  return typeof e == "string" && /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/.test(
300
360
  e
301
361
  );
302
362
  }
303
- function V(e) {
363
+ function L(e) {
304
364
  if (!e || typeof e != "object")
305
365
  throw new Error("Invalid GeoVideo manifest");
306
366
  const t = e;
@@ -313,21 +373,21 @@ function V(e) {
313
373
  if (!Array.isArray(t.bounds) || t.bounds.length !== 4)
314
374
  throw new Error("Invalid GeoVideo manifest bounds");
315
375
  const [r, n, a, i] = t.bounds.map(
316
- (f, T) => m(f, `bounds[${T}]`)
376
+ (l, T) => m(l, `bounds[${T}]`)
317
377
  );
318
378
  if (n < -90 || i > 90 || n >= i || r === a)
319
379
  throw new Error("Invalid GeoVideo geographic bounds");
320
380
  const s = t.media;
321
381
  if (!s || typeof s.url != "string" || !s.url)
322
382
  throw new Error("Invalid GeoVideo media");
323
- for (const f of ["width", "height", "fps", "durationSeconds"])
324
- if (m(s[f], `media.${f}`) <= 0)
325
- throw new Error(`Invalid GeoVideo media.${f}`);
383
+ for (const l of ["width", "height", "fps", "durationSeconds"])
384
+ if (m(s[l], `media.${l}`) <= 0)
385
+ throw new Error(`Invalid GeoVideo media.${l}`);
326
386
  const o = t.encoding;
327
387
  if (!o || o.bits !== 8 || o.colorSpace !== "bt709" || o.colorRange !== "limited" && o.colorRange !== "full")
328
388
  throw new Error("Invalid GeoVideo encoding");
329
- const c = m(o.codeMin, "encoding.codeMin"), d = m(o.codeMax, "encoding.codeMax");
330
- if (c < 0 || d > 255 || c >= d)
389
+ const d = m(o.codeMin, "encoding.codeMin"), c = m(o.codeMax, "encoding.codeMax");
390
+ if (d < 0 || c > 255 || d >= c)
331
391
  throw new Error("Invalid GeoVideo code range");
332
392
  let h = s.height;
333
393
  if (o.kind === "scalar-luma") {
@@ -343,8 +403,8 @@ function V(e) {
343
403
  if (!u || u.kind !== "static-validity" || typeof u.url != "string" || !u.url || m(u.width, "mask.width") !== s.width || m(u.height, "mask.height") !== h || m(u.threshold, "mask.threshold") < 0 || u.threshold > 1)
344
404
  throw new Error("Invalid GeoVideo static mask");
345
405
  if (t.timeline?.kind === "range") {
346
- const f = F(t.timeline.dateStart, "timeline.dateStart");
347
- if (F(t.timeline.dateEnd, "timeline.dateEnd") <= f)
406
+ const l = F(t.timeline.dateStart, "timeline.dateStart");
407
+ if (F(t.timeline.dateEnd, "timeline.dateEnd") <= l)
348
408
  throw new Error("GeoVideo timeline end must follow start");
349
409
  if (t.timeline.interpolation !== "linear" && t.timeline.interpolation !== "nearest")
350
410
  throw new Error("Invalid GeoVideo interpolation");
@@ -353,10 +413,10 @@ function V(e) {
353
413
  else if (t.timeline?.kind === "sample-sequence") {
354
414
  if (!Array.isArray(t.timeline.values) || t.timeline.values.length === 0)
355
415
  throw new Error("GeoVideo sample sequence must contain values");
356
- const f = t.timeline.values.map(
416
+ const l = t.timeline.values.map(
357
417
  (T, b) => F(T, `timeline.values[${b}]`)
358
418
  );
359
- if (f.some((T, b) => b > 0 && T <= f[b - 1]))
419
+ if (l.some((T, b) => b > 0 && T <= l[b - 1]))
360
420
  throw new Error(
361
421
  "GeoVideo sample sequence values must be strictly increasing"
362
422
  );
@@ -365,19 +425,19 @@ function V(e) {
365
425
  const E = t.style?.colorDomain;
366
426
  if (!Array.isArray(E) || E.length !== 2 || !E.every(Number.isFinite) || E[0] >= E[1])
367
427
  throw new Error("Invalid GeoVideo color domain");
368
- if (!D(t.id) || !t.provenance || !D(t.provenance.catalogEntryId) || !D(t.provenance.inputSourceId) || !Array.isArray(t.provenance.variables) || t.provenance.variables.length === 0)
428
+ if (!S(t.id) || !t.provenance || !S(t.provenance.catalogEntryId) || !S(t.provenance.inputSourceId) || !Array.isArray(t.provenance.variables) || t.provenance.variables.length === 0)
369
429
  throw new Error("Invalid GeoVideo provenance");
370
430
  return { ...t, bounds: [r, n, a, i] };
371
431
  }
372
- async function Re(e, t) {
432
+ async function xe(e, t) {
373
433
  if (typeof e != "string")
374
- return V(e);
434
+ return L(e);
375
435
  const r = await fetch(e, { signal: t });
376
436
  if (!r.ok)
377
437
  throw new Error(
378
438
  `GeoVideo manifest request failed (${r.status}): ${e}`
379
439
  );
380
- const n = await r.json(), a = V(n), i = typeof document < "u" ? new URL(e, document.baseURI).href : e;
440
+ const n = await r.json(), a = L(n), i = typeof document < "u" ? new URL(e, document.baseURI).href : e;
381
441
  return {
382
442
  ...a,
383
443
  media: { ...a.media, url: new URL(a.media.url, i).href },
@@ -398,40 +458,40 @@ function _(e) {
398
458
  (a, i) => t + (r - t) * i / (n - 1)
399
459
  );
400
460
  }
401
- function _e(e) {
461
+ function ve(e) {
402
462
  return e.timeline.kind === "sample-sequence" ? e.timeline.values.length / e.media.durationSeconds : e.media.fps;
403
463
  }
404
- function dt(e, t) {
405
- return t / _e(e);
464
+ function ft(e, t) {
465
+ return t / ve(e);
406
466
  }
407
- function Ae(e, t) {
467
+ function ye(e, t) {
408
468
  if (e.timeline.kind === "snapshot-loop")
409
469
  return 0;
410
470
  if (e.timeline.kind === "sample-sequence") {
411
471
  const i = _(e);
412
472
  let s = 0;
413
- for (let c = 1; c < i.length; c += 1)
414
- Math.abs(i[c] - t) < Math.abs(i[s] - t) && (s = c);
473
+ for (let d = 1; d < i.length; d += 1)
474
+ Math.abs(i[d] - t) < Math.abs(i[s] - t) && (s = d);
415
475
  const o = e.media.durationSeconds / i.length;
416
476
  return s * o + Math.min(o / 2, 0.5 / e.media.fps);
417
477
  }
418
478
  const r = new Date(e.timeline.dateStart).getTime(), n = new Date(e.timeline.dateEnd).getTime();
419
- return Math.max(0, Math.min(1, (t - r) / (n - r))) * X(e);
479
+ return Math.max(0, Math.min(1, (t - r) / (n - r))) * O(e);
420
480
  }
421
- function ut(e, t) {
481
+ function ht(e, t) {
422
482
  if (e.timeline.kind === "snapshot-loop")
423
483
  return new Date(e.timeline.date).getTime();
424
484
  if (e.timeline.kind === "sample-sequence") {
425
- const s = _(e), o = e.media.durationSeconds / s.length, c = Math.floor((t + 0.25 / e.media.fps) / o);
426
- return s[Math.max(0, Math.min(s.length - 1, c))];
485
+ const s = _(e), o = e.media.durationSeconds / s.length, d = Math.floor((t + 0.25 / e.media.fps) / o);
486
+ return s[Math.max(0, Math.min(s.length - 1, d))];
427
487
  }
428
- const r = new Date(e.timeline.dateStart).getTime(), n = new Date(e.timeline.dateEnd).getTime(), a = X(e), i = a > 0 ? Math.max(0, Math.min(1, t / a)) : 0;
488
+ const r = new Date(e.timeline.dateStart).getTime(), n = new Date(e.timeline.dateEnd).getTime(), a = O(e), i = a > 0 ? Math.max(0, Math.min(1, t / a)) : 0;
429
489
  return r + (n - r) * i;
430
490
  }
431
- function X(e) {
491
+ function O(e) {
432
492
  return Math.max(0, e.media.durationSeconds - 1 / e.media.fps);
433
493
  }
434
- function Fe(e, t) {
494
+ function Se(e, t) {
435
495
  const r = new Uint8Array(e.length / 4);
436
496
  for (let n = 0; n < r.length; n++) {
437
497
  const a = e[n * 4];
@@ -439,7 +499,7 @@ function Fe(e, t) {
439
499
  }
440
500
  return r;
441
501
  }
442
- class xe {
502
+ class Ue {
443
503
  constructor() {
444
504
  this.gl = null, this.texture = null, this.framebuffer = null;
445
505
  }
@@ -470,44 +530,57 @@ class xe {
470
530
  return this.gl = n, this.texture = n.createTexture(), this.framebuffer = n.createFramebuffer(), n;
471
531
  }
472
532
  }
473
- function C(e) {
533
+ function V(e) {
474
534
  const t = Math.max(4, Math.floor(e.length / 4 / 997) * 4);
475
535
  for (let r = 3; r < e.length; r += t)
476
536
  if (e[r] !== 0)
477
537
  return !1;
478
538
  return !0;
479
539
  }
480
- function l() {
540
+ function f() {
481
541
  return new DOMException("GeoVideo frame request was cancelled", "AbortError");
482
542
  }
483
543
  function R(e, t, r) {
484
544
  return t ? t.aborted ? (e.catch(() => {
485
- }), r?.(), Promise.reject(l())) : new Promise((n, a) => {
545
+ }), r?.(), Promise.reject(f())) : new Promise((n, a) => {
486
546
  const i = () => {
487
- r?.(), a(l());
547
+ r?.(), a(f());
488
548
  };
489
549
  t.addEventListener("abort", i, { once: !0 }), e.then(n, a).finally(() => {
490
550
  t.removeEventListener("abort", i);
491
551
  });
492
552
  }) : e;
493
553
  }
494
- function M(e, t) {
554
+ function U(e, t) {
495
555
  return new Promise(
496
556
  (r) => e.addEventListener(t, () => r(), { once: !0 })
497
557
  );
498
558
  }
499
- const ve = 250;
500
- function ye(e) {
559
+ const De = 250;
560
+ function Me(e) {
501
561
  return "requestVideoFrameCallback" in e ? Promise.race([
502
562
  new Promise(
503
563
  (t) => e.requestVideoFrameCallback(() => t())
504
564
  ),
505
- new Promise((t) => setTimeout(t, ve))
565
+ new Promise((t) => setTimeout(t, De))
506
566
  ]) : Promise.resolve();
507
567
  }
508
- class O {
568
+ class q {
509
569
  constructor(t, r, n = {}) {
510
- this.reader = new xe(), this.video = null, this.mask = 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 = t, this.planes = r, this.cacheSize = Math.max(1, n.cacheSize ?? 3), this.width = t.media.width, this.height = t.media.height / r, this.times = Float64Array.from(_(t));
570
+ this.reader = new Ue(), 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 = t, this.planes = r, this.cacheSize = Math.max(1, n.cacheSize ?? 3), this.width = t.media.width, this.height = t.media.height / r, this.times = Float64Array.from(_(t));
571
+ }
572
+ /** Static validity, one 8-bit value per grid cell; null before init(). */
573
+ get mask() {
574
+ return this.maskCodes;
575
+ }
576
+ /** Luma codes of the presented frame, or null when it is blank. */
577
+ readCodes(t, r) {
578
+ const n = this.reader.read(t, this.width, r);
579
+ return V(n) ? null : Se(n, this.manifest.encoding.colorRange);
580
+ }
581
+ /** True when the decoder exposed no pixels; reads back one row only. */
582
+ isBlank(t) {
583
+ return V(this.reader.read(t, this.width, 1));
511
584
  }
512
585
  init() {
513
586
  return this.initPromise ??= this.load().catch((t) => {
@@ -521,7 +594,7 @@ class O {
521
594
  }
522
595
  /** Release the video element and GL context; a later init() reloads them. */
523
596
  release() {
524
- this.cancelAll(), this.frames.clear(), this.video && (this.video.removeAttribute("src"), this.video.load()), this.video = null, this.mask = null, this.presented = !1, this.primed = !1, this.initPromise = null, this.reader.release();
597
+ this.cancelAll(), this.frames.clear(), this.video && (this.video.removeAttribute("src"), this.video.load()), this.video = null, this.maskCodes = null, this.presented = !1, this.primed = !1, this.initPromise = null, this.reader.release();
525
598
  }
526
599
  /**
527
600
  * One decode per time step, cached and shared by concurrent requests.
@@ -531,7 +604,7 @@ class O {
531
604
  frame(t, r = {}) {
532
605
  const { signal: n } = r;
533
606
  if (n?.aborted)
534
- return Promise.reject(l());
607
+ return Promise.reject(f());
535
608
  let a = this.frames.get(t);
536
609
  if (a ? (this.frames.delete(t), this.frames.set(t, a)) : a = this.enqueue(t), a.settled)
537
610
  return a.promise;
@@ -540,7 +613,7 @@ class O {
540
613
  }
541
614
  enqueue(t) {
542
615
  const r = new AbortController(), n = this.queue.then(
543
- () => r.signal.aborted ? Promise.reject(l()) : this.decode(t, r.signal)
616
+ () => r.signal.aborted ? Promise.reject(f()) : this.decode(t, r.signal)
544
617
  );
545
618
  this.queue = n.catch(() => {
546
619
  });
@@ -571,7 +644,7 @@ class O {
571
644
  }
572
645
  async load() {
573
646
  const [t] = await Promise.all([this.loadMask(), this.loadVideo()]);
574
- this.mask = t;
647
+ this.maskCodes = t;
575
648
  }
576
649
  async loadMask() {
577
650
  const { url: t, width: r, height: n } = this.manifest.mask, a = new Image();
@@ -610,8 +683,8 @@ class O {
610
683
  async presentFrame(t, r) {
611
684
  if (this.presented && Math.abs(t.currentTime - r) <= 1e-3 && !t.seeking)
612
685
  return;
613
- const n = ye(t), a = M(t, "seeked");
614
- t.currentTime = r, await a, t.readyState < HTMLMediaElement.HAVE_CURRENT_DATA && await Promise.race([M(t, "loadeddata"), M(t, "canplay")]), await n, this.presented = !0;
686
+ const n = Me(t), a = U(t, "seeked");
687
+ t.currentTime = r, await a, t.readyState < HTMLMediaElement.HAVE_CURRENT_DATA && await Promise.race([U(t, "loadeddata"), U(t, "canplay")]), await n, this.presented = !0;
615
688
  }
616
689
  /**
617
690
  * Some mobile browsers expose no decoded pixels to WebGL until playback
@@ -627,68 +700,86 @@ class O {
627
700
  t.pause(), this.presented = !1;
628
701
  }
629
702
  /**
630
- * Seek, read back and decode one step. `signal` aborts it between steps;
631
- * a seek already started completes first, keeping the queue serial.
703
+ * Seek and capture one step. `signal` aborts it between steps; a seek
704
+ * already started completes first, keeping the queue serial.
632
705
  */
633
706
  async decode(t, r) {
634
707
  if (r.aborted)
635
- throw l();
708
+ throw f();
636
709
  await this.init();
637
- const n = this.video, a = this.mask;
710
+ const n = this.video, a = this.maskCodes;
638
711
  if (r.aborted || !n || !a)
639
- throw l();
640
- const i = Ae(this.manifest, this.times[t]);
712
+ throw f();
713
+ const i = ye(this.manifest, this.times[t]);
641
714
  if (await this.presentFrame(n, i), r.aborted || n !== this.video)
642
- throw l();
715
+ throw f();
643
716
  const s = this.height * this.planes;
644
- let o = this.reader.read(n, this.width, s);
645
- if (C(o) && !this.primed) {
717
+ let o = await this.capture(n, s, a);
718
+ if (o === null && !this.primed) {
646
719
  if (await this.primeDecoder(n), await this.presentFrame(n, i), r.aborted || n !== this.video)
647
- throw l();
648
- o = this.reader.read(n, this.width, s);
720
+ throw f();
721
+ o = await this.capture(n, s, a);
649
722
  }
650
- if (C(o))
723
+ if (o === null)
651
724
  throw new Error("GeoVideo frame could not be read back from the decoder");
652
- const c = Fe(o, this.manifest.encoding.colorRange);
653
- return this.decodeCodes(c, a, this.manifest.mask.threshold);
725
+ return o;
726
+ }
727
+ }
728
+ function mt(e) {
729
+ return {
730
+ codeRange: [e.codeMin / 255, e.codeMax / 255],
731
+ valueRange: [e.valueMin, e.valueMax]
732
+ };
733
+ }
734
+ class ke extends q {
735
+ constructor(t, r = {}) {
736
+ if (t.encoding.kind !== "scalar-luma")
737
+ throw new Error("GeoVideoScalarSource requires a scalar-luma manifest");
738
+ super(t, 1, r);
739
+ }
740
+ async capture(t) {
741
+ return this.isBlank(t) ? null : createImageBitmap(t, {
742
+ premultiplyAlpha: "none",
743
+ colorSpaceConversion: "none"
744
+ });
654
745
  }
655
746
  }
656
- function De(e, t) {
747
+ function Pe(e, t) {
657
748
  let r = (e - t.codeMin) / (t.codeMax - t.codeMin) * 2 - 1;
658
749
  return r = Math.max(-1, Math.min(1, r)), t.transfer === "sqrt" && (r = Math.sign(r) * r * r), r * t.valueDomain;
659
750
  }
660
- function Me(e, t, r, n) {
751
+ function Ge(e, t, r, n) {
661
752
  const a = t.length;
662
753
  if (e.length !== 2 * a)
663
754
  throw new Error(
664
755
  `GeoVideo vector frame has ${e.length} codes, expected ${2 * a}`
665
756
  );
666
757
  const i = new Float32Array(256);
667
- for (let d = 0; d < 256; d++)
668
- i[d] = De(d, n);
669
- const s = r * 255, o = new Float32Array(a), c = new Float32Array(a);
670
- for (let d = 0; d < a; d++) {
671
- const h = t[d] >= s;
672
- o[d] = h ? i[e[d]] : NaN, c[d] = h ? i[e[a + d]] : NaN;
758
+ for (let c = 0; c < 256; c++)
759
+ i[c] = Pe(c, n);
760
+ const s = r * 255, o = new Float32Array(a), d = new Float32Array(a);
761
+ for (let c = 0; c < a; c++) {
762
+ const h = t[c] >= s;
763
+ o[c] = h ? i[e[c]] : NaN, d[c] = h ? i[e[a + c]] : NaN;
673
764
  }
674
- return { u: o, v: c };
765
+ return { u: o, v: d };
675
766
  }
676
- class Ue extends O {
767
+ class Ie extends q {
677
768
  constructor(t, r = {}) {
678
769
  if (t.encoding.kind !== "vector-luma")
679
770
  throw new Error("GeoVideoVectorSource requires a vector-luma manifest");
680
771
  super(t, 2, r), this.encoding = t.encoding;
681
- const [n, a, i, s] = t.bounds, o = (i - n) / this.width, c = (s - a) / this.height;
772
+ const [n, a, i, s] = t.bounds, o = (i - n) / this.width, d = (s - a) / this.height;
682
773
  this.coords = {
683
774
  time: this.times,
684
775
  vertical: new Float32Array([0]),
685
776
  latitude: Float32Array.from(
686
777
  { length: this.height },
687
- (d, h) => s - (h + 0.5) * c
778
+ (c, h) => s - (h + 0.5) * d
688
779
  ),
689
780
  longitude: Float32Array.from(
690
781
  { length: this.width },
691
- (d, h) => n + (h + 0.5) * o
782
+ (c, h) => n + (h + 0.5) * o
692
783
  )
693
784
  };
694
785
  }
@@ -737,53 +828,26 @@ class Ue extends O {
737
828
  url: this.manifest.media.url
738
829
  };
739
830
  }
740
- decodeCodes(t, r, n) {
741
- return Me(t, r, n, this.encoding);
742
- }
743
- }
744
- function Se(e, t) {
745
- const r = Math.max(
746
- 0,
747
- Math.min(
748
- 1,
749
- (e - t.codeMin) / (t.codeMax - t.codeMin)
750
- )
751
- );
752
- return t.valueMin + r * (t.valueMax - t.valueMin);
753
- }
754
- function Ge(e, t, r, n) {
755
- const a = t.length;
756
- if (e.length !== a)
757
- throw new Error(
758
- `GeoVideo scalar frame has ${e.length} codes, expected ${a}`
759
- );
760
- const i = new Float32Array(256);
761
- for (let c = 0; c < 256; c++)
762
- i[c] = Se(c, n);
763
- const s = r * 255, o = new Float32Array(a);
764
- for (let c = 0; c < a; c++)
765
- o[c] = t[c] >= s ? i[e[c]] : NaN;
766
- return o;
767
- }
768
- class Pe extends O {
769
- constructor(t, r = {}) {
770
- if (t.encoding.kind !== "scalar-luma")
771
- throw new Error("GeoVideoScalarSource requires a scalar-luma manifest");
772
- super(t, 1, r), this.encoding = t.encoding;
773
- }
774
- decodeCodes(t, r, n) {
775
- return Ge(t, r, n, this.encoding);
831
+ /** u/v codes are written into luma: read back, then decoded on the CPU. */
832
+ async capture(t, r, n) {
833
+ const a = this.readCodes(t, r);
834
+ return a ? Ge(
835
+ a,
836
+ n,
837
+ this.manifest.mask.threshold,
838
+ this.encoding
839
+ ) : null;
776
840
  }
777
841
  }
778
- function ke(e, t, r = {}) {
779
- const [n, a] = r.range ?? [-1 / 0, 1 / 0], i = [...e].sort((o, c) => o.start - c.start), s = i.find(
842
+ function ge(e, t, r = {}) {
843
+ const [n, a] = r.range ?? [-1 / 0, 1 / 0], i = [...e].sort((o, d) => o.start - d.start), s = i.find(
780
844
  (o) => o.start > t && o.start <= a
781
845
  ) ?? (r.loop ? i.find(
782
846
  (o) => o.end >= n && o.start <= a
783
847
  ) : void 0);
784
848
  return s ? { chunk: s, time: Math.max(s.start, n) } : null;
785
849
  }
786
- function Ie(e, t) {
850
+ function Ce(e, t) {
787
851
  let r = null, n = -1 / 0;
788
852
  for (const a of t) {
789
853
  const i = Math.min(e.end, a.end) - Math.max(e.start, a.start);
@@ -800,10 +864,10 @@ function Ne(e) {
800
864
  };
801
865
  }
802
866
  function Le(e, t = {}) {
803
- return e.encoding.kind === "vector-luma" ? new Ue(e, t) : new Pe(e, t);
867
+ return e.encoding.kind === "vector-luma" ? new Ie(e, t) : new ke(e, t);
804
868
  }
805
- const Ve = 3, Ce = 3, Be = 0.6, ge = 1.5;
806
- function Xe(e, t) {
869
+ const Ve = 3, Be = 3, Xe = 0.6, Oe = 1.5;
870
+ function qe(e, t) {
807
871
  const r = e.length - 1;
808
872
  if (t <= e[0])
809
873
  return { step: 0, fraction: 0 };
@@ -816,7 +880,7 @@ function Xe(e, t) {
816
880
  }
817
881
  return { step: n, fraction: (t - e[n]) / (e[a] - e[n]) };
818
882
  }
819
- function Oe(e) {
883
+ function $e(e) {
820
884
  const t = new AbortController();
821
885
  if (!e)
822
886
  return { controller: t, unlink: () => {
@@ -827,14 +891,14 @@ function Oe(e) {
827
891
  unlink: () => e.removeEventListener("abort", r)
828
892
  };
829
893
  }
830
- class ft {
894
+ class Et {
831
895
  constructor(t) {
832
896
  this.manifests = /* @__PURE__ */ new Map(), this.open = /* @__PURE__ */ new Map(), this.id = t.id, this.chunks = t.chunks.filter(
833
897
  (r) => Number.isFinite(r.start) && Number.isFinite(r.end) && r.end >= r.start
834
898
  ).sort((r, n) => r.start - n.start), this.maxOpenChunks = Math.max(2, t.maxOpenChunks ?? Ve), this.frameCacheSize = Math.max(
835
899
  1,
836
- t.frameCacheSize ?? Ce
837
- ), this.prefetchAt = t.prefetchAt ?? Be, this.maxGap = t.maxGap, this.loadManifest = t.loadManifest ?? Re, this.createFrameSource = t.createFrameSource ?? ((r, n) => Le(
900
+ t.frameCacheSize ?? Be
901
+ ), this.prefetchAt = t.prefetchAt ?? Xe, this.maxGap = t.maxGap, this.loadManifest = t.loadManifest ?? xe, this.createFrameSource = t.createFrameSource ?? ((r, n) => Le(
838
902
  r,
839
903
  n
840
904
  ));
@@ -852,7 +916,7 @@ class ft {
852
916
  /** Every step time of the archive; loads all chunk manifests. */
853
917
  async steps(t = {}) {
854
918
  if (t.signal?.aborted)
855
- throw l();
919
+ throw f();
856
920
  const r = await R(
857
921
  Promise.all(this.chunks.map((n) => this.manifest(n))),
858
922
  t.signal
@@ -866,28 +930,28 @@ class ft {
866
930
  async sample(t, r = {}) {
867
931
  const { signal: n } = r, a = r.mode ?? "interpolate";
868
932
  if (n?.aborted)
869
- throw l();
933
+ throw f();
870
934
  const i = this.chunkIndexAt(t);
871
935
  if (i < 0)
872
936
  return null;
873
- const s = [], { controller: o, unlink: c } = Oe(n);
937
+ const s = [], { controller: o, unlink: d } = $e(n);
874
938
  try {
875
- const d = this.acquire(this.chunks[i], s), h = await R(d.ready, o.signal), { times: u } = h;
939
+ const c = this.acquire(this.chunks[i], s), h = await R(c.ready, o.signal), { times: u } = h;
876
940
  let E;
877
941
  if (t <= u[u.length - 1]) {
878
- const { step: p, fraction: w } = Xe(u, t);
879
- E = a === "discrete" || w === 0 ? [d, p, d, p, 0] : [d, p, d, p + 1, w];
942
+ const { step: p, fraction: w } = qe(u, t);
943
+ E = a === "discrete" || w === 0 ? [c, p, c, p, 0] : [c, p, c, p + 1, w];
880
944
  } else {
881
945
  const p = this.chunks[i + 1];
882
946
  if (!p)
883
947
  return null;
884
- const w = this.acquire(p, s), k = await R(w.ready, o.signal), A = u.length - 1, v = u[A], y = k.times[0];
885
- if (y - v > this.gapLimit(u, k.times))
948
+ const w = this.acquire(p, s), G = await R(w.ready, o.signal), A = u.length - 1, v = u[A], y = G.times[0];
949
+ if (y - v > this.gapLimit(u, G.times))
886
950
  return null;
887
- E = a === "discrete" ? [d, A, d, A, 0] : t >= y ? [w, 0, w, 0, 0] : [d, A, w, 0, (t - v) / (y - v)];
951
+ E = a === "discrete" ? [c, A, c, A, 0] : t >= y ? [w, 0, w, 0, 0] : [c, A, w, 0, (t - v) / (y - v)];
888
952
  }
889
- const [f, T, b, S, q] = E, G = f === b && T === S, P = [this.frame(f, T, o.signal)];
890
- G || P.push(this.frame(b, S, o.signal));
953
+ const [l, T, b, M, $] = E, k = l === b && T === M, P = [this.frame(l, T, o.signal)];
954
+ k || P.push(this.frame(b, M, o.signal));
891
955
  let x;
892
956
  try {
893
957
  x = await Promise.all(P);
@@ -897,13 +961,13 @@ class ft {
897
961
  return this.prefetchAfter(i, t), {
898
962
  time: t,
899
963
  a: x[0],
900
- b: x[G ? 0 : 1],
901
- mix: q
964
+ b: x[k ? 0 : 1],
965
+ mix: $
902
966
  };
903
967
  } finally {
904
- c();
905
- for (const d of s)
906
- d.users--;
968
+ d();
969
+ for (const c of s)
970
+ c.users--;
907
971
  this.trim();
908
972
  }
909
973
  }
@@ -937,7 +1001,7 @@ class ft {
937
1001
  t.length > 1 ? t[t.length - 1] - t[t.length - 2] : 0,
938
1002
  r.length > 1 ? r[1] - r[0] : 0
939
1003
  ], a = Math.max(...n);
940
- return a > 0 ? a * ge : -1 / 0;
1004
+ return a > 0 ? a * Oe : -1 / 0;
941
1005
  }
942
1006
  prefetchAfter(t, r) {
943
1007
  const n = this.chunks[t], a = this.chunks[t + 1], i = n.end - n.start, s = i > 0 ? (r - n.start) / i : 1;
@@ -970,7 +1034,7 @@ class ft {
970
1034
  };
971
1035
  n.ready = this.manifest(t).then((a) => {
972
1036
  if (n.released)
973
- throw l();
1037
+ throw f();
974
1038
  return n.opened = {
975
1039
  manifest: a,
976
1040
  times: Float64Array.from(_(a)),
@@ -991,14 +1055,14 @@ class ft {
991
1055
  n
992
1056
  );
993
1057
  if (t.released)
994
- throw l();
995
- const c = await o.frame(r, { signal: n });
1058
+ throw f();
1059
+ const d = await o.frame(r, { signal: n });
996
1060
  return {
997
1061
  key: `${this.id}/${t.chunk.key}/${r}`,
998
1062
  chunk: t.chunk,
999
1063
  step: r,
1000
1064
  time: i[r],
1001
- data: c,
1065
+ data: d,
1002
1066
  grid: s,
1003
1067
  manifest: a
1004
1068
  };
@@ -1016,7 +1080,7 @@ class ft {
1016
1080
  t.released = !0, t.prefetch?.abort(), t.prefetch = null, t.opened?.source.release(), t.opened = null, this.open.get(t.chunk.key) === t && this.open.delete(t.chunk.key);
1017
1081
  }
1018
1082
  }
1019
- function U(e) {
1083
+ function D(e) {
1020
1084
  const { start: t, end: r } = e.temporal ?? {};
1021
1085
  return {
1022
1086
  source: e,
@@ -1024,27 +1088,27 @@ function U(e) {
1024
1088
  end: Date.parse(r ?? t ?? "")
1025
1089
  };
1026
1090
  }
1027
- function lt(e, t, r = {}) {
1028
- const n = e.filter((i) => i.id === t.id && i.temporal?.start != null).map(U), a = ke(
1091
+ function Tt(e, t, r = {}) {
1092
+ const n = e.filter((i) => i.id === t.id && i.temporal?.start != null).map(D), a = ge(
1029
1093
  n,
1030
1094
  Date.parse(t.temporal?.end ?? ""),
1031
1095
  r
1032
1096
  );
1033
1097
  return a ? { source: a.chunk.source, time: a.time } : null;
1034
1098
  }
1035
- function ht(e, t) {
1036
- return Ie(U(e), t.map(U))?.source ?? null;
1099
+ function pt(e, t) {
1100
+ return Ce(D(e), t.map(D))?.source ?? null;
1037
1101
  }
1038
- function mt(e) {
1102
+ function bt(e) {
1039
1103
  return e.type === "geovideo" && typeof e.indexUrl == "string";
1040
1104
  }
1041
- function Et(e, t) {
1105
+ function wt(e, t) {
1042
1106
  return e.id === t.id && (e.type !== "geovideo" || t.type !== "geovideo" || e.manifestUrl === t.manifestUrl);
1043
1107
  }
1044
1108
  function B(e) {
1045
1109
  return typeof e == "string" && Number.isFinite(Date.parse(e));
1046
1110
  }
1047
- function qe(e) {
1111
+ function We(e) {
1048
1112
  const t = e;
1049
1113
  if (!t || t.schemaVersion !== 1 || t.type !== "geovideo-index" || !Array.isArray(t.chunks))
1050
1114
  throw new Error("Unsupported GeoVideo index");
@@ -1053,19 +1117,19 @@ function qe(e) {
1053
1117
  throw new Error("Invalid GeoVideo index chunk");
1054
1118
  return t;
1055
1119
  }
1056
- async function Tt(e, t) {
1120
+ async function Rt(e, t) {
1057
1121
  const r = await fetch(e, { signal: t });
1058
1122
  if (!r.ok)
1059
1123
  throw new Error(
1060
1124
  `GeoVideo index request failed (${r.status}): ${e}`
1061
1125
  );
1062
- return qe(await r.json());
1126
+ return We(await r.json());
1063
1127
  }
1064
- function $e(e) {
1128
+ function He(e) {
1065
1129
  return typeof document < "u" ? new URL(e, document.baseURI).href : e;
1066
1130
  }
1067
- function We(e, t) {
1068
- const r = $e(t);
1131
+ function Ye(e, t) {
1132
+ const r = He(t);
1069
1133
  return e.chunks.map((n) => ({
1070
1134
  key: n.key,
1071
1135
  manifestUrl: new URL(n.manifestUrl, r).href,
@@ -1075,15 +1139,15 @@ function We(e, t) {
1075
1139
  ...n.provisional ? { provisional: !0 } : {}
1076
1140
  }));
1077
1141
  }
1078
- function He(e, t, r) {
1142
+ function ze(e, t, r) {
1079
1143
  if (t.sourceId !== e.id || t.catalogEntryId !== r.id)
1080
1144
  throw new Error(
1081
1145
  `GeoVideo index identity does not match catalog entry/source: ${e.id}`
1082
1146
  );
1083
1147
  }
1084
- function pt(e, t, r) {
1085
- He(e, t, r);
1086
- const n = We(t, e.indexUrl);
1148
+ function _t(e, t, r) {
1149
+ ze(e, t, r);
1150
+ const n = Ye(t, e.indexUrl);
1087
1151
  return t.chunks.map(
1088
1152
  (a, i) => ({
1089
1153
  id: e.id,
@@ -1101,48 +1165,50 @@ function pt(e, t, r) {
1101
1165
  );
1102
1166
  }
1103
1167
  export {
1104
- Tt as A,
1105
- pt as B,
1106
- V as C,
1107
- ft as D,
1108
- O as E,
1109
- Pe as F,
1110
- Ue as G,
1111
- He as H,
1112
- Le as I,
1113
- N as J,
1114
- Te as K,
1115
- Ne as L,
1116
- We as M,
1117
- ke as N,
1118
- ht as O,
1119
- Ie as P,
1120
- qe as Q,
1121
- st as T,
1122
- tt as a,
1123
- rt as b,
1124
- ze as c,
1125
- Je as d,
1126
- Qe as e,
1127
- et as f,
1128
- nt as g,
1129
- je as h,
1130
- Ze as i,
1131
- Ke as j,
1132
- it as k,
1133
- ot as l,
1134
- Re as m,
1135
- Ae as n,
1136
- fe as o,
1137
- ut as p,
1138
- _ as q,
1139
- he as r,
1140
- at as s,
1141
- Et as t,
1142
- dt as u,
1143
- ct as v,
1144
- _e as w,
1145
- Ye as x,
1146
- mt as y,
1147
- lt as z
1168
+ bt as A,
1169
+ Tt as B,
1170
+ Rt as C,
1171
+ _t as D,
1172
+ L as E,
1173
+ Et as F,
1174
+ Ie as G,
1175
+ q as H,
1176
+ ke as I,
1177
+ ze as J,
1178
+ Le as K,
1179
+ g as L,
1180
+ Re as M,
1181
+ Ne as N,
1182
+ Ye as O,
1183
+ ge as P,
1184
+ pt as Q,
1185
+ Ce as R,
1186
+ We as S,
1187
+ ut as T,
1188
+ nt as a,
1189
+ at as b,
1190
+ Ke as c,
1191
+ Ze as d,
1192
+ et as e,
1193
+ rt as f,
1194
+ it as g,
1195
+ Je as h,
1196
+ tt as i,
1197
+ Qe as j,
1198
+ st as k,
1199
+ dt as l,
1200
+ xe as m,
1201
+ mt as n,
1202
+ ye as o,
1203
+ fe as p,
1204
+ ht as q,
1205
+ me as r,
1206
+ ot as s,
1207
+ _ as t,
1208
+ wt as u,
1209
+ lt as v,
1210
+ ft as w,
1211
+ ve as x,
1212
+ ct as y,
1213
+ je as z
1148
1214
  };