@fxi/zartigl 0.9.2 → 0.9.3

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,30 +1,30 @@
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,
1
+ const Y = { label: "Thermal", tags: ["sequential", "temperature"], colors: ["#042333", "#2c3395", "#744796", "#b15f82", "#eb7958", "#fbb43d", "#e8fa5b"] }, j = { label: "Haline", tags: ["sequential", "salinity"], colors: ["#2a186c", "#17568b", "#1a7e8f", "#22a785", "#55c666", "#aadc32", "#fde333"] }, z = { label: "Solar", tags: ["sequential", "irradiance"], colors: ["#330f0b", "#6b2313", "#a83c12", "#d6621a", "#f3951e", "#f7c741", "#f9f871"] }, K = { 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"] }, Q = { label: "RdYlBu", tags: ["diverging"], colors: ["#3288bd", "#66c2a5", "#abdda4", "#e6f598", "#fee08b", "#fdae61", "#f46d43", "#d53e4f"] }, Z = { label: "Dense", tags: ["sequential"], colors: ["#e6f1f1", "#92c4ca", "#44929a", "#20627a", "#1a3c6a", "#211a50", "#0d0621"] }, ee = { label: "Algae", tags: ["sequential", "biology", "log"], colors: ["#d7f9d0", "#a2d595", "#64b463", "#129450", "#126e45", "#1a482f", "#122414"] }, te = { label: "Oxygen", tags: ["sequential", "biology", "hypoxia"], colors: ["#09060f", "#5b1028", "#d43d2f", "#f39b3d", "#f3e7b3", "#79cbd1", "#176b9c"] }, re = { label: "Matter", tags: ["sequential", "biology"], colors: ["#fdfecc", "#f2c98a", "#e07c4e", "#bc3754", "#8d1a6d", "#51156b", "#1c0c3f"] }, ne = { label: "Viridis", tags: ["sequential", "perceptual"], colors: ["#440154", "#443983", "#31688e", "#21918c", "#35b779", "#90d743", "#fde725"] }, ae = { label: "Plasma", tags: ["sequential", "perceptual"], colors: ["#0d0887", "#5e01a6", "#9c179e", "#cc4778", "#ed7953", "#fdb42f", "#f0f921"] }, ie = { label: "Cyclic", tags: ["cyclic", "direction"], colors: ["#2e22ea", "#b541fb", "#fc93c0", "#f1ee35", "#77c80d", "#458776", "#2c24e9"] }, oe = { label: "Tempo", tags: ["sequential"], colors: ["#fff6f4", "#c2d1b9", "#7db390", "#2a937f", "#156d73", "#1c455b", "#151d44"] }, se = { label: "Turbid", tags: ["sequential", "biology", "log"], colors: ["#e9f5a0", "#c8c86e", "#a09845", "#786031", "#533324", "#341423", "#150d17"] }, ce = { label: "Speed", tags: ["sequential", "velocity"], colors: ["#fcfea4", "#d5e429", "#94c63e", "#52a657", "#2d8169", "#1d5b6d", "#0d3361"] }, de = { label: "Amp", tags: ["sequential"], colors: ["#f2f2f2", "#c0b8db", "#9180b6", "#6c4e9e", "#4e2e83", "#32185d", "#110a35"] }, ue = { 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"] }, fe = { label: "Curl", tags: ["diverging"], colors: ["#152237", "#2471b3", "#8dbac4", "#f2f2f2", "#c79f84", "#a63827", "#270b17"] }, he = { label: "Gray", tags: ["sequential"], colors: ["#000000", "#252525", "#4d4d4d", "#7a7a7a", "#a8a8a8", "#d4d4d4", "#ffffff"] }, q = {
2
+ thermal: Y,
3
3
  "thermal-alt": { label: "Thermal Alt", tags: ["sequential", "temperature"], colors: ["#176b9c", "#79cbd1", "#f3e7b3", "#f39b3d", "#d43d2f", "#5b1028", "#09060f"] },
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,
4
+ haline: j,
5
+ solar: z,
6
+ ice: K,
7
+ deep: J,
8
+ rdylbu: Q,
9
+ dense: Z,
10
+ algae: ee,
11
+ oxygen: te,
12
+ matter: re,
13
+ viridis: ne,
14
+ plasma: ae,
15
+ cyclic: ie,
16
+ tempo: oe,
17
+ turbid: se,
18
+ speed: ce,
19
+ amp: de,
20
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,
21
+ balance: ue,
22
+ delta: le,
23
+ curl: fe,
24
24
  "mono-black": { label: "Black", tags: ["monochrome", "particles"], colors: ["#000000", "#000000"] },
25
25
  "mono-white": { label: "White", tags: ["monochrome", "particles"], colors: ["#ffffff", "#ffffff"] },
26
26
  "mono-pink": { label: "Pink", tags: ["monochrome", "particles"], colors: ["#ff2aa1", "#ff2aa1"] },
27
- gray: le
27
+ gray: he
28
28
  };
29
29
  function I(e) {
30
30
  const t = {}, r = e.length - 1;
@@ -32,8 +32,8 @@ function I(e) {
32
32
  t[r === 0 ? 0 : a / r] = n;
33
33
  }), t;
34
34
  }
35
- function fe(e, t) {
36
- const r = X;
35
+ function me(e, t) {
36
+ const r = q;
37
37
  if (typeof e == "string") {
38
38
  const n = r[e];
39
39
  if (!n)
@@ -51,10 +51,10 @@ function fe(e, t) {
51
51
  }
52
52
  return e;
53
53
  }
54
- function je() {
55
- return Object.entries(X).map(([t, r]) => ({ id: t, ...r }));
54
+ function et() {
55
+ return Object.entries(q).map(([t, r]) => ({ id: t, ...r }));
56
56
  }
57
- function g(e, t, r) {
57
+ function C(e, t, r) {
58
58
  const n = e.createShader(t);
59
59
  if (!n)
60
60
  throw new Error("Failed to create shader");
@@ -64,18 +64,18 @@ function g(e, t, r) {
64
64
  }
65
65
  return n;
66
66
  }
67
- function Ke(e, t, r) {
67
+ function tt(e, t, r) {
68
68
  const n = e.createProgram();
69
69
  if (!n)
70
70
  throw new Error("Failed to create program");
71
- const a = g(e, e.VERTEX_SHADER, t), i = g(e, e.FRAGMENT_SHADER, r);
71
+ const a = C(e, e.VERTEX_SHADER, t), i = C(e, e.FRAGMENT_SHADER, r);
72
72
  if (e.attachShader(n, a), e.attachShader(n, i), e.linkProgram(n), !e.getProgramParameter(n, e.LINK_STATUS)) {
73
- const s = e.getProgramInfoLog(n);
74
- throw e.deleteProgram(n), new Error(`Program link error: ${s}`);
73
+ const o = e.getProgramInfoLog(n);
74
+ throw e.deleteProgram(n), new Error(`Program link error: ${o}`);
75
75
  }
76
76
  return e.deleteShader(a), e.deleteShader(i), n;
77
77
  }
78
- function Je(e, t, r, n, a) {
78
+ function rt(e, t, r, n, a) {
79
79
  const i = e.createTexture();
80
80
  if (!i)
81
81
  throw new Error("Failed to create texture");
@@ -91,15 +91,15 @@ function Je(e, t, r, n, a) {
91
91
  r
92
92
  ), e.bindTexture(e.TEXTURE_2D, null), i;
93
93
  }
94
- function he(e, t, r) {
94
+ function Ee(e, t, r) {
95
95
  const n = e.getParameter(
96
96
  e.TEXTURE_BINDING_2D
97
97
  ), a = e.getParameter(
98
98
  e.FRAMEBUFFER_BINDING
99
- ), i = e.createTexture(), s = e.createFramebuffer();
100
- if (!i || !s)
101
- return i && e.deleteTexture(i), s && e.deleteFramebuffer(s), e.bindTexture(e.TEXTURE_2D, n), e.bindFramebuffer(e.FRAMEBUFFER, a), !1;
102
- let o = !1;
99
+ ), i = e.createTexture(), o = e.createFramebuffer();
100
+ if (!i || !o)
101
+ return i && e.deleteTexture(i), o && e.deleteFramebuffer(o), e.bindTexture(e.TEXTURE_2D, n), e.bindFramebuffer(e.FRAMEBUFFER, a), !1;
102
+ let s = !1;
103
103
  try {
104
104
  e.bindTexture(e.TEXTURE_2D, i), 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.NEAREST), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_MAG_FILTER, e.NEAREST), e.texImage2D(
105
105
  e.TEXTURE_2D,
@@ -111,31 +111,31 @@ function he(e, t, r) {
111
111
  e.RGBA,
112
112
  r,
113
113
  null
114
- ), e.bindFramebuffer(e.FRAMEBUFFER, s), e.framebufferTexture2D(
114
+ ), e.bindFramebuffer(e.FRAMEBUFFER, o), e.framebufferTexture2D(
115
115
  e.FRAMEBUFFER,
116
116
  e.COLOR_ATTACHMENT0,
117
117
  e.TEXTURE_2D,
118
118
  i,
119
119
  0
120
- ), o = e.checkFramebufferStatus(e.FRAMEBUFFER) === e.FRAMEBUFFER_COMPLETE;
120
+ ), s = e.checkFramebufferStatus(e.FRAMEBUFFER) === e.FRAMEBUFFER_COMPLETE;
121
121
  } finally {
122
- e.bindFramebuffer(e.FRAMEBUFFER, a), e.bindTexture(e.TEXTURE_2D, n), e.deleteFramebuffer(s), e.deleteTexture(i);
122
+ e.bindFramebuffer(e.FRAMEBUFFER, a), e.bindTexture(e.TEXTURE_2D, n), e.deleteFramebuffer(o), e.deleteTexture(i);
123
123
  }
124
- return o;
124
+ return s;
125
125
  }
126
- function me(e) {
126
+ function Te(e) {
127
127
  return {
128
128
  kind: "rgba8-packed",
129
129
  internalFormat: e.RGBA,
130
130
  type: e.UNSIGNED_BYTE
131
131
  };
132
132
  }
133
- function Qe(e) {
133
+ function nt(e) {
134
134
  if (typeof WebGL2RenderingContext > "u" || !(e instanceof WebGL2RenderingContext))
135
135
  throw new Error("zartigl requires WebGL2");
136
136
  return e;
137
137
  }
138
- function Ze(e) {
138
+ function at(e) {
139
139
  const t = [];
140
140
  e.getExtension("EXT_color_buffer_float") ? t.push(
141
141
  { kind: "float32", internalFormat: e.RGBA32F, type: e.FLOAT },
@@ -146,19 +146,19 @@ function Ze(e) {
146
146
  type: e.HALF_FLOAT
147
147
  });
148
148
  for (const r of t)
149
- if (he(
149
+ if (Ee(
150
150
  e,
151
151
  r.internalFormat,
152
152
  r.type
153
153
  ))
154
154
  return r;
155
- return me(e);
155
+ return Te(e);
156
156
  }
157
- function et(e, t, r, n, a, i, s) {
158
- const o = e.createTexture();
159
- if (!o)
157
+ function it(e, t, r, n, a, i, o) {
158
+ const s = e.createTexture();
159
+ if (!s)
160
160
  throw new Error("Failed to create texture");
161
- return e.bindTexture(e.TEXTURE_2D, o), 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, t), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_MAG_FILTER, t), e.texImage2D(
161
+ 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, t), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_MAG_FILTER, t), e.texImage2D(
162
162
  e.TEXTURE_2D,
163
163
  0,
164
164
  i,
@@ -166,14 +166,14 @@ function et(e, t, r, n, a, i, s) {
166
166
  a,
167
167
  0,
168
168
  e.RGBA,
169
- s,
169
+ o,
170
170
  r
171
- ), e.bindTexture(e.TEXTURE_2D, null), o;
171
+ ), e.bindTexture(e.TEXTURE_2D, null), s;
172
172
  }
173
- function tt(e, t, r) {
173
+ function ot(e, t, r) {
174
174
  e.activeTexture(e.TEXTURE0 + r), e.bindTexture(e.TEXTURE_2D, t);
175
175
  }
176
- function rt(e, t) {
176
+ function st(e, t) {
177
177
  const r = e.createFramebuffer();
178
178
  if (!r)
179
179
  throw new Error("Failed to create framebuffer");
@@ -185,7 +185,7 @@ function rt(e, t) {
185
185
  0
186
186
  ), e.bindFramebuffer(e.FRAMEBUFFER, null), r;
187
187
  }
188
- function nt(e) {
188
+ function ct(e) {
189
189
  const t = e.createBuffer();
190
190
  if (!t)
191
191
  throw new Error("Failed to create buffer");
@@ -195,7 +195,7 @@ function nt(e) {
195
195
  e.STATIC_DRAW
196
196
  ), t;
197
197
  }
198
- const Ee = {
198
+ const pe = {
199
199
  0: "#3288bd",
200
200
  0.1: "#66c2a5",
201
201
  0.2: "#abdda4",
@@ -205,19 +205,19 @@ const Ee = {
205
205
  0.6: "#f46d43",
206
206
  1: "#d53e4f"
207
207
  };
208
- function at(e, t) {
209
- const r = t != null ? fe(t) : Ee, n = document.createElement("canvas");
208
+ function dt(e, t) {
209
+ const r = t != null ? me(t) : pe, n = document.createElement("canvas");
210
210
  n.width = 256, n.height = 1;
211
211
  const a = n.getContext("2d"), i = a.createLinearGradient(0, 0, 256, 0);
212
- for (const [o, d] of Object.entries(r))
213
- i.addColorStop(Number(o), d);
212
+ for (const [s, d] of Object.entries(r))
213
+ i.addColorStop(Number(s), d);
214
214
  a.fillStyle = i, a.fillRect(0, 0, 256, 1);
215
- const s = e.createTexture();
216
- if (!s)
215
+ const o = e.createTexture();
216
+ if (!o)
217
217
  throw new Error("Failed to create color ramp texture");
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
+ return e.bindTexture(e.TEXTURE_2D, o), 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), o;
219
219
  }
220
- function it(e) {
220
+ function ut(e) {
221
221
  const t = e.getExtension("WEBGL_debug_renderer_info");
222
222
  return {
223
223
  vendor: String(e.getParameter(e.VENDOR) ?? ""),
@@ -227,7 +227,7 @@ function it(e) {
227
227
  version: String(e.getParameter(e.VERSION) ?? "")
228
228
  };
229
229
  }
230
- function ot(e) {
230
+ function lt(e) {
231
231
  return {
232
232
  program: e.getParameter(e.CURRENT_PROGRAM),
233
233
  activeTexture: e.getParameter(e.ACTIVE_TEXTURE),
@@ -244,10 +244,10 @@ function ot(e) {
244
244
  ]
245
245
  };
246
246
  }
247
- function st(e, t) {
247
+ function ft(e, t) {
248
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]);
249
249
  }
250
- const Te = {
250
+ const be = {
251
251
  degrees_c: "°C",
252
252
  degc: "°C",
253
253
  degrees_celsius: "°C",
@@ -263,7 +263,7 @@ const Te = {
263
263
  "0.001": "PSU",
264
264
  psu: "PSU",
265
265
  stress_level: ""
266
- }, pe = {
266
+ }, we = {
267
267
  meter: "m",
268
268
  meters: "m",
269
269
  metre: "m",
@@ -286,36 +286,36 @@ const Te = {
286
286
  newton: "N",
287
287
  pascal: "Pa",
288
288
  kelvin: "K"
289
- }, be = "⁰¹²³⁴⁵⁶⁷⁸⁹";
290
- function C(e) {
291
- return e === 1 ? "" : [...String(e)].map((t) => be[Number(t)]).join("");
289
+ }, Re = "⁰¹²³⁴⁵⁶⁷⁸⁹";
290
+ function N(e) {
291
+ return e === 1 ? "" : [...String(e)].map((t) => Re[Number(t)]).join("");
292
292
  }
293
- function ct(e) {
294
- const t = e?.trim() ?? "", r = Te[t.toLowerCase()];
293
+ function ht(e) {
294
+ const t = e?.trim() ?? "", r = be[t.toLowerCase()];
295
295
  if (r != null)
296
296
  return r;
297
297
  if (t.includes("/"))
298
298
  return t;
299
299
  const n = [], a = [];
300
300
  for (const i of t.split(/\s+/)) {
301
- const s = /^([A-Za-z]+)\^?(-?\d+)?$/.exec(i);
302
- if (!s)
301
+ const o = /^([A-Za-z]+)\^?(-?\d+)?$/.exec(i);
302
+ if (!o)
303
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));
304
+ const s = we[o[1]] ?? o[1], d = Number(o[2] ?? 1);
305
+ d < 0 ? a.push(s + N(-d)) : n.push(s + N(d));
306
306
  }
307
307
  return [n.join(" ") || "1", ...a].join("/");
308
308
  }
309
- const N = 20, we = 600;
310
- function Re(e) {
309
+ const L = 20, _e = 600;
310
+ function Ae(e) {
311
311
  const t = Math.max(0, Math.min(1, e));
312
- return N * Math.pow(we / N, t);
312
+ return L * Math.pow(_e / L, t);
313
313
  }
314
- function dt(e) {
315
- return Math.exp(-1 / Re(e));
314
+ function mt(e) {
315
+ return Math.exp(-1 / Ae(e));
316
316
  }
317
- const _e = 0.8, Ae = 120, Fe = 300;
318
- class ut {
317
+ const Fe = 0.8, xe = 120, ye = 300;
318
+ class Et {
319
319
  constructor(t) {
320
320
  this.base = t, this.moving = !1, this.start = 0, this.duration = 0, this.from = t, this.to = t;
321
321
  }
@@ -324,7 +324,7 @@ class ut {
324
324
  this.base = t, this.moving || (this.from = t, this.to = t, this.duration = 0);
325
325
  }
326
326
  setMoving(t, r) {
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);
327
+ t !== this.moving && (this.from = this.value(r), this.moving = t, this.to = t ? Fe : this.base, this.start = r, this.duration = t ? xe : ye);
328
328
  }
329
329
  value(t) {
330
330
  if (this.duration === 0)
@@ -333,7 +333,7 @@ class ut {
333
333
  return r === 1 ? (this.duration = 0, this.from = this.to, this.to) : this.from + (this.to - this.from) * r * r * (3 - 2 * r);
334
334
  }
335
335
  }
336
- function lt(e) {
336
+ function Tt(e) {
337
337
  if (e == null)
338
338
  return null;
339
339
  if (!Number.isFinite(e[0]) || !Number.isFinite(e[1]) || e[0] >= e[1])
@@ -342,12 +342,12 @@ function lt(e) {
342
342
  );
343
343
  return [e[0], e[1]];
344
344
  }
345
- function m(e, t) {
345
+ function T(e, t) {
346
346
  if (typeof e != "number" || !Number.isFinite(e))
347
347
  throw new Error(`Invalid GeoVideo manifest ${t}`);
348
348
  return e;
349
349
  }
350
- function F(e, t) {
350
+ function x(e, t) {
351
351
  if (typeof e != "string")
352
352
  throw new Error(`Invalid GeoVideo manifest ${t}`);
353
353
  const r = new Date(e).getTime();
@@ -360,7 +360,7 @@ function S(e) {
360
360
  e
361
361
  );
362
362
  }
363
- function L(e) {
363
+ function V(e) {
364
364
  if (!e || typeof e != "object")
365
365
  throw new Error("Invalid GeoVideo manifest");
366
366
  const t = e;
@@ -373,78 +373,78 @@ function L(e) {
373
373
  if (!Array.isArray(t.bounds) || t.bounds.length !== 4)
374
374
  throw new Error("Invalid GeoVideo manifest bounds");
375
375
  const [r, n, a, i] = t.bounds.map(
376
- (l, T) => m(l, `bounds[${T}]`)
376
+ (l, m) => T(l, `bounds[${m}]`)
377
377
  );
378
378
  if (n < -90 || i > 90 || n >= i || r === a)
379
379
  throw new Error("Invalid GeoVideo geographic bounds");
380
- const s = t.media;
381
- if (!s || typeof s.url != "string" || !s.url)
380
+ const o = t.media;
381
+ if (!o || typeof o.url != "string" || !o.url)
382
382
  throw new Error("Invalid GeoVideo media");
383
383
  for (const l of ["width", "height", "fps", "durationSeconds"])
384
- if (m(s[l], `media.${l}`) <= 0)
384
+ if (T(o[l], `media.${l}`) <= 0)
385
385
  throw new Error(`Invalid GeoVideo media.${l}`);
386
- const o = t.encoding;
387
- if (!o || o.bits !== 8 || o.colorSpace !== "bt709" || o.colorRange !== "limited" && o.colorRange !== "full")
386
+ const s = t.encoding;
387
+ if (!s || s.bits !== 8 || s.colorSpace !== "bt709" || s.colorRange !== "limited" && s.colorRange !== "full")
388
388
  throw new Error("Invalid GeoVideo encoding");
389
- const d = m(o.codeMin, "encoding.codeMin"), c = m(o.codeMax, "encoding.codeMax");
389
+ const d = T(s.codeMin, "encoding.codeMin"), c = T(s.codeMax, "encoding.codeMax");
390
390
  if (d < 0 || c > 255 || d >= c)
391
391
  throw new Error("Invalid GeoVideo code range");
392
- let h = s.height;
393
- if (o.kind === "scalar-luma") {
394
- if (o.transfer !== "linear" || m(o.valueMin, "encoding.valueMin") >= m(o.valueMax, "encoding.valueMax"))
392
+ let f = o.height;
393
+ if (s.kind === "scalar-luma") {
394
+ if (s.transfer !== "linear" || T(s.valueMin, "encoding.valueMin") >= T(s.valueMax, "encoding.valueMax"))
395
395
  throw new Error("Invalid GeoVideo scalar-luma encoding");
396
- } else if (o.kind === "vector-luma") {
397
- if (o.transfer !== "linear" && o.transfer !== "sqrt" || o.layout !== "stacked-uv" || m(o.valueDomain, "encoding.valueDomain") <= 0 || s.height % 2 !== 0)
396
+ } else if (s.kind === "vector-luma") {
397
+ if (s.transfer !== "linear" && s.transfer !== "sqrt" || s.layout !== "stacked-uv" || T(s.valueDomain, "encoding.valueDomain") <= 0 || o.height % 2 !== 0)
398
398
  throw new Error("Invalid GeoVideo vector-luma encoding");
399
- h = s.height / 2;
399
+ f = o.height / 2;
400
400
  } else
401
401
  throw new Error("Unsupported GeoVideo encoding");
402
402
  const u = t.mask;
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)
403
+ if (!u || u.kind !== "static-validity" || typeof u.url != "string" || !u.url || T(u.width, "mask.width") !== o.width || T(u.height, "mask.height") !== f || T(u.threshold, "mask.threshold") < 0 || u.threshold > 1)
404
404
  throw new Error("Invalid GeoVideo static mask");
405
405
  if (t.timeline?.kind === "range") {
406
- const l = F(t.timeline.dateStart, "timeline.dateStart");
407
- if (F(t.timeline.dateEnd, "timeline.dateEnd") <= l)
406
+ const l = x(t.timeline.dateStart, "timeline.dateStart");
407
+ if (x(t.timeline.dateEnd, "timeline.dateEnd") <= l)
408
408
  throw new Error("GeoVideo timeline end must follow start");
409
409
  if (t.timeline.interpolation !== "linear" && t.timeline.interpolation !== "nearest")
410
410
  throw new Error("Invalid GeoVideo interpolation");
411
411
  } else if (t.timeline?.kind === "snapshot-loop")
412
- F(t.timeline.date, "timeline.date");
412
+ x(t.timeline.date, "timeline.date");
413
413
  else if (t.timeline?.kind === "sample-sequence") {
414
414
  if (!Array.isArray(t.timeline.values) || t.timeline.values.length === 0)
415
415
  throw new Error("GeoVideo sample sequence must contain values");
416
416
  const l = t.timeline.values.map(
417
- (T, b) => F(T, `timeline.values[${b}]`)
417
+ (m, p) => x(m, `timeline.values[${p}]`)
418
418
  );
419
- if (l.some((T, b) => b > 0 && T <= l[b - 1]))
419
+ if (l.some((m, p) => p > 0 && m <= l[p - 1]))
420
420
  throw new Error(
421
421
  "GeoVideo sample sequence values must be strictly increasing"
422
422
  );
423
423
  } else
424
424
  throw new Error("Invalid GeoVideo timeline");
425
- const E = t.style?.colorDomain;
426
- if (!Array.isArray(E) || E.length !== 2 || !E.every(Number.isFinite) || E[0] >= E[1])
425
+ const h = t.style?.colorDomain;
426
+ if (!Array.isArray(h) || h.length !== 2 || !h.every(Number.isFinite) || h[0] >= h[1])
427
427
  throw new Error("Invalid GeoVideo color domain");
428
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)
429
429
  throw new Error("Invalid GeoVideo provenance");
430
430
  return { ...t, bounds: [r, n, a, i] };
431
431
  }
432
- async function xe(e, t) {
432
+ async function ve(e, t) {
433
433
  if (typeof e != "string")
434
- return L(e);
434
+ return V(e);
435
435
  const r = await fetch(e, { signal: t });
436
436
  if (!r.ok)
437
437
  throw new Error(
438
438
  `GeoVideo manifest request failed (${r.status}): ${e}`
439
439
  );
440
- const n = await r.json(), a = L(n), i = typeof document < "u" ? new URL(e, document.baseURI).href : e;
440
+ const n = await r.json(), a = V(n), i = typeof document < "u" ? new URL(e, document.baseURI).href : e;
441
441
  return {
442
442
  ...a,
443
443
  media: { ...a.media, url: new URL(a.media.url, i).href },
444
444
  mask: { ...a.mask, url: new URL(a.mask.url, i).href }
445
445
  };
446
446
  }
447
- function _(e) {
447
+ function A(e) {
448
448
  if (e.timeline.kind === "snapshot-loop")
449
449
  return [new Date(e.timeline.date).getTime()];
450
450
  if (e.timeline.kind === "sample-sequence")
@@ -458,37 +458,37 @@ function _(e) {
458
458
  (a, i) => t + (r - t) * i / (n - 1)
459
459
  );
460
460
  }
461
- function ve(e) {
461
+ function Ue(e) {
462
462
  return e.timeline.kind === "sample-sequence" ? e.timeline.values.length / e.media.durationSeconds : e.media.fps;
463
463
  }
464
- function ft(e, t) {
465
- return t / ve(e);
464
+ function pt(e, t) {
465
+ return t / Ue(e);
466
466
  }
467
- function ye(e, t) {
467
+ function De(e, t) {
468
468
  if (e.timeline.kind === "snapshot-loop")
469
469
  return 0;
470
470
  if (e.timeline.kind === "sample-sequence") {
471
- const i = _(e);
472
- let s = 0;
471
+ const i = A(e);
472
+ let o = 0;
473
473
  for (let d = 1; d < i.length; d += 1)
474
- Math.abs(i[d] - t) < Math.abs(i[s] - t) && (s = d);
475
- const o = e.media.durationSeconds / i.length;
476
- return s * o + Math.min(o / 2, 0.5 / e.media.fps);
474
+ Math.abs(i[d] - t) < Math.abs(i[o] - t) && (o = d);
475
+ const s = e.media.durationSeconds / i.length;
476
+ return o * s + Math.min(s / 2, 0.5 / e.media.fps);
477
477
  }
478
478
  const r = new Date(e.timeline.dateStart).getTime(), n = new Date(e.timeline.dateEnd).getTime();
479
- return Math.max(0, Math.min(1, (t - r) / (n - r))) * O(e);
479
+ return Math.max(0, Math.min(1, (t - r) / (n - r))) * $(e);
480
480
  }
481
- function ht(e, t) {
481
+ function bt(e, t) {
482
482
  if (e.timeline.kind === "snapshot-loop")
483
483
  return new Date(e.timeline.date).getTime();
484
484
  if (e.timeline.kind === "sample-sequence") {
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))];
485
+ const o = A(e), s = e.media.durationSeconds / o.length, d = Math.floor((t + 0.25 / e.media.fps) / s);
486
+ return o[Math.max(0, Math.min(o.length - 1, d))];
487
487
  }
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;
488
+ const r = new Date(e.timeline.dateStart).getTime(), n = new Date(e.timeline.dateEnd).getTime(), a = $(e), i = a > 0 ? Math.max(0, Math.min(1, t / a)) : 0;
489
489
  return r + (n - r) * i;
490
490
  }
491
- function O(e) {
491
+ function $(e) {
492
492
  return Math.max(0, e.media.durationSeconds - 1 / e.media.fps);
493
493
  }
494
494
  function Se(e, t) {
@@ -499,7 +499,7 @@ function Se(e, t) {
499
499
  }
500
500
  return r;
501
501
  }
502
- class Ue {
502
+ class Me {
503
503
  constructor() {
504
504
  this.gl = null, this.texture = null, this.framebuffer = null;
505
505
  }
@@ -530,44 +530,44 @@ class Ue {
530
530
  return this.gl = n, this.texture = n.createTexture(), this.framebuffer = n.createFramebuffer(), n;
531
531
  }
532
532
  }
533
- function V(e) {
533
+ function B(e) {
534
534
  const t = Math.max(4, Math.floor(e.length / 4 / 997) * 4);
535
535
  for (let r = 3; r < e.length; r += t)
536
536
  if (e[r] !== 0)
537
537
  return !1;
538
538
  return !0;
539
539
  }
540
- function f() {
540
+ function E() {
541
541
  return new DOMException("GeoVideo frame request was cancelled", "AbortError");
542
542
  }
543
543
  function R(e, t, r) {
544
544
  return t ? t.aborted ? (e.catch(() => {
545
- }), r?.(), Promise.reject(f())) : new Promise((n, a) => {
545
+ }), r?.(), Promise.reject(E())) : new Promise((n, a) => {
546
546
  const i = () => {
547
- r?.(), a(f());
547
+ r?.(), a(E());
548
548
  };
549
549
  t.addEventListener("abort", i, { once: !0 }), e.then(n, a).finally(() => {
550
550
  t.removeEventListener("abort", i);
551
551
  });
552
552
  }) : e;
553
553
  }
554
- function U(e, t) {
554
+ function M(e, t) {
555
555
  return new Promise(
556
556
  (r) => e.addEventListener(t, () => r(), { once: !0 })
557
557
  );
558
558
  }
559
- const De = 250;
560
- function Me(e) {
559
+ const ke = 250;
560
+ function Pe(e) {
561
561
  return "requestVideoFrameCallback" in e ? Promise.race([
562
562
  new Promise(
563
563
  (t) => e.requestVideoFrameCallback(() => t())
564
564
  ),
565
- new Promise((t) => setTimeout(t, De))
565
+ new Promise((t) => setTimeout(t, ke))
566
566
  ]) : Promise.resolve();
567
567
  }
568
- class q {
568
+ class W {
569
569
  constructor(t, r, n = {}) {
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));
570
+ this.reader = new Me(), 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(A(t));
571
571
  }
572
572
  /** Static validity, one 8-bit value per grid cell; null before init(). */
573
573
  get mask() {
@@ -576,11 +576,11 @@ class q {
576
576
  /** Luma codes of the presented frame, or null when it is blank. */
577
577
  readCodes(t, r) {
578
578
  const n = this.reader.read(t, this.width, r);
579
- return V(n) ? null : Se(n, this.manifest.encoding.colorRange);
579
+ return B(n) ? null : Se(n, this.manifest.encoding.colorRange);
580
580
  }
581
581
  /** True when the decoder exposed no pixels; reads back one row only. */
582
582
  isBlank(t) {
583
- return V(this.reader.read(t, this.width, 1));
583
+ return B(this.reader.read(t, this.width, 1));
584
584
  }
585
585
  init() {
586
586
  return this.initPromise ??= this.load().catch((t) => {
@@ -604,7 +604,7 @@ class q {
604
604
  frame(t, r = {}) {
605
605
  const { signal: n } = r;
606
606
  if (n?.aborted)
607
- return Promise.reject(f());
607
+ return Promise.reject(E());
608
608
  let a = this.frames.get(t);
609
609
  if (a ? (this.frames.delete(t), this.frames.set(t, a)) : a = this.enqueue(t), a.settled)
610
610
  return a.promise;
@@ -613,7 +613,7 @@ class q {
613
613
  }
614
614
  enqueue(t) {
615
615
  const r = new AbortController(), n = this.queue.then(
616
- () => r.signal.aborted ? Promise.reject(f()) : this.decode(t, r.signal)
616
+ () => r.signal.aborted ? Promise.reject(E()) : this.decode(t, r.signal)
617
617
  );
618
618
  this.queue = n.catch(() => {
619
619
  });
@@ -658,10 +658,10 @@ class q {
658
658
  throw new Error(
659
659
  `GeoVideo mask dimensions ${a.naturalWidth}x${a.naturalHeight} do not match manifest ${r}x${n}`
660
660
  );
661
- const i = this.reader.read(a, r, n), s = new Uint8Array(r * n);
662
- for (let o = 0; o < s.length; o++)
663
- s[o] = i[o * 4];
664
- return s;
661
+ const i = this.reader.read(a, r, n), o = new Uint8Array(r * n);
662
+ for (let s = 0; s < o.length; s++)
663
+ o[s] = i[s * 4];
664
+ return o;
665
665
  }
666
666
  async loadVideo() {
667
667
  const t = document.createElement("video");
@@ -683,8 +683,8 @@ class q {
683
683
  async presentFrame(t, r) {
684
684
  if (this.presented && Math.abs(t.currentTime - r) <= 1e-3 && !t.seeking)
685
685
  return;
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;
686
+ const n = Pe(t), a = M(t, "seeked");
687
+ 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;
688
688
  }
689
689
  /**
690
690
  * Some mobile browsers expose no decoded pixels to WebGL until playback
@@ -705,33 +705,33 @@ class q {
705
705
  */
706
706
  async decode(t, r) {
707
707
  if (r.aborted)
708
- throw f();
708
+ throw E();
709
709
  await this.init();
710
710
  const n = this.video, a = this.maskCodes;
711
711
  if (r.aborted || !n || !a)
712
- throw f();
713
- const i = ye(this.manifest, this.times[t]);
712
+ throw E();
713
+ const i = De(this.manifest, this.times[t]);
714
714
  if (await this.presentFrame(n, i), r.aborted || n !== this.video)
715
- throw f();
716
- const s = this.height * this.planes;
717
- let o = await this.capture(n, s, a);
718
- if (o === null && !this.primed) {
715
+ throw E();
716
+ const o = this.height * this.planes;
717
+ let s = await this.capture(n, o, a);
718
+ if (s === null && !this.primed) {
719
719
  if (await this.primeDecoder(n), await this.presentFrame(n, i), r.aborted || n !== this.video)
720
- throw f();
721
- o = await this.capture(n, s, a);
720
+ throw E();
721
+ s = await this.capture(n, o, a);
722
722
  }
723
- if (o === null)
723
+ if (s === null)
724
724
  throw new Error("GeoVideo frame could not be read back from the decoder");
725
- return o;
725
+ return s;
726
726
  }
727
727
  }
728
- function mt(e) {
728
+ function wt(e) {
729
729
  return {
730
730
  codeRange: [e.codeMin / 255, e.codeMax / 255],
731
731
  valueRange: [e.valueMin, e.valueMax]
732
732
  };
733
733
  }
734
- class ke extends q {
734
+ class ge extends W {
735
735
  constructor(t, r = {}) {
736
736
  if (t.encoding.kind !== "scalar-luma")
737
737
  throw new Error("GeoVideoScalarSource requires a scalar-luma manifest");
@@ -744,11 +744,11 @@ class ke extends q {
744
744
  });
745
745
  }
746
746
  }
747
- function Pe(e, t) {
747
+ function Ge(e, t) {
748
748
  let r = (e - t.codeMin) / (t.codeMax - t.codeMin) * 2 - 1;
749
749
  return r = Math.max(-1, Math.min(1, r)), t.transfer === "sqrt" && (r = Math.sign(r) * r * r), r * t.valueDomain;
750
750
  }
751
- function Ge(e, t, r, n) {
751
+ function Ie(e, t, r, n) {
752
752
  const a = t.length;
753
753
  if (e.length !== 2 * a)
754
754
  throw new Error(
@@ -756,30 +756,30 @@ function Ge(e, t, r, n) {
756
756
  );
757
757
  const i = new Float32Array(256);
758
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);
759
+ i[c] = Ge(c, n);
760
+ const o = r * 255, s = new Float32Array(a), d = new Float32Array(a);
761
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;
762
+ const f = t[c] >= o;
763
+ s[c] = f ? i[e[c]] : NaN, d[c] = f ? i[e[a + c]] : NaN;
764
764
  }
765
- return { u: o, v: d };
765
+ return { u: s, v: d };
766
766
  }
767
- class Ie extends q {
767
+ class Ce extends W {
768
768
  constructor(t, r = {}) {
769
769
  if (t.encoding.kind !== "vector-luma")
770
770
  throw new Error("GeoVideoVectorSource requires a vector-luma manifest");
771
771
  super(t, 2, r), this.encoding = t.encoding;
772
- const [n, a, i, s] = t.bounds, o = (i - n) / this.width, d = (s - a) / this.height;
772
+ const [n, a, i, o] = t.bounds, s = (i - n) / this.width, d = (o - a) / this.height;
773
773
  this.coords = {
774
774
  time: this.times,
775
775
  vertical: new Float32Array([0]),
776
776
  latitude: Float32Array.from(
777
777
  { length: this.height },
778
- (c, h) => s - (h + 0.5) * d
778
+ (c, f) => o - (f + 0.5) * d
779
779
  ),
780
780
  longitude: Float32Array.from(
781
781
  { length: this.width },
782
- (c, h) => n + (h + 0.5) * o
782
+ (c, f) => n + (f + 0.5) * s
783
783
  )
784
784
  };
785
785
  }
@@ -831,7 +831,7 @@ class Ie extends q {
831
831
  /** u/v codes are written into luma: read back, then decoded on the CPU. */
832
832
  async capture(t, r, n) {
833
833
  const a = this.readCodes(t, r);
834
- return a ? Ge(
834
+ return a ? Ie(
835
835
  a,
836
836
  n,
837
837
  this.manifest.mask.threshold,
@@ -839,15 +839,15 @@ class Ie extends q {
839
839
  ) : null;
840
840
  }
841
841
  }
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(
844
- (o) => o.start > t && o.start <= a
842
+ function Ne(e, t, r = {}) {
843
+ const [n, a] = r.range ?? [-1 / 0, 1 / 0], i = [...e].sort((s, d) => s.start - d.start), o = i.find(
844
+ (s) => s.start > t && s.start <= a
845
845
  ) ?? (r.loop ? i.find(
846
- (o) => o.end >= n && o.start <= a
846
+ (s) => s.end >= n && s.start <= a
847
847
  ) : void 0);
848
- return s ? { chunk: s, time: Math.max(s.start, n) } : null;
848
+ return o ? { chunk: o, time: Math.max(o.start, n) } : null;
849
849
  }
850
- function Ce(e, t) {
850
+ function Le(e, t) {
851
851
  let r = null, n = -1 / 0;
852
852
  for (const a of t) {
853
853
  const i = Math.min(e.end, a.end) - Math.max(e.start, a.start);
@@ -855,7 +855,7 @@ function Ce(e, t) {
855
855
  }
856
856
  return r;
857
857
  }
858
- function Ne(e) {
858
+ function Ve(e) {
859
859
  return {
860
860
  width: e.mask.width,
861
861
  height: e.mask.height,
@@ -863,11 +863,11 @@ function Ne(e) {
863
863
  rowOrder: "north-to-south"
864
864
  };
865
865
  }
866
- function Le(e, t = {}) {
867
- return e.encoding.kind === "vector-luma" ? new Ie(e, t) : new ke(e, t);
866
+ function Be(e, t = {}) {
867
+ return e.encoding.kind === "vector-luma" ? new Ce(e, t) : new ge(e, t);
868
868
  }
869
- const Ve = 3, Be = 3, Xe = 0.6, Oe = 1.5;
870
- function qe(e, t) {
869
+ const Xe = 3, Oe = 3, qe = 0.6, $e = 1.5;
870
+ function We(e, t) {
871
871
  const r = e.length - 1;
872
872
  if (t <= e[0])
873
873
  return { step: 0, fraction: 0 };
@@ -880,7 +880,7 @@ function qe(e, t) {
880
880
  }
881
881
  return { step: n, fraction: (t - e[n]) / (e[a] - e[n]) };
882
882
  }
883
- function $e(e) {
883
+ function He(e) {
884
884
  const t = new AbortController();
885
885
  if (!e)
886
886
  return { controller: t, unlink: () => {
@@ -891,14 +891,14 @@ function $e(e) {
891
891
  unlink: () => e.removeEventListener("abort", r)
892
892
  };
893
893
  }
894
- class Et {
894
+ class Rt {
895
895
  constructor(t) {
896
896
  this.manifests = /* @__PURE__ */ new Map(), this.open = /* @__PURE__ */ new Map(), this.id = t.id, this.chunks = t.chunks.filter(
897
897
  (r) => Number.isFinite(r.start) && Number.isFinite(r.end) && r.end >= r.start
898
- ).sort((r, n) => r.start - n.start), this.maxOpenChunks = Math.max(2, t.maxOpenChunks ?? Ve), this.frameCacheSize = Math.max(
898
+ ).sort((r, n) => r.start - n.start), this.maxOpenChunks = Math.max(2, t.maxOpenChunks ?? Xe), this.frameCacheSize = Math.max(
899
899
  1,
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(
900
+ t.frameCacheSize ?? Oe
901
+ ), this.prefetchAt = t.prefetchAt ?? qe, this.maxGap = t.maxGap, this.loadManifest = t.loadManifest ?? ve, this.createFrameSource = t.createFrameSource ?? ((r, n) => Be(
902
902
  r,
903
903
  n
904
904
  ));
@@ -916,12 +916,12 @@ class Et {
916
916
  /** Every step time of the archive; loads all chunk manifests. */
917
917
  async steps(t = {}) {
918
918
  if (t.signal?.aborted)
919
- throw f();
919
+ throw E();
920
920
  const r = await R(
921
921
  Promise.all(this.chunks.map((n) => this.manifest(n))),
922
922
  t.signal
923
923
  );
924
- return Float64Array.from(r.flatMap(_));
924
+ return Float64Array.from(r.flatMap(A));
925
925
  }
926
926
  /**
927
927
  * The frames bracketing `time`, decoded; null out of coverage (before the
@@ -930,43 +930,43 @@ class Et {
930
930
  async sample(t, r = {}) {
931
931
  const { signal: n } = r, a = r.mode ?? "interpolate";
932
932
  if (n?.aborted)
933
- throw f();
933
+ throw E();
934
934
  const i = this.chunkIndexAt(t);
935
935
  if (i < 0)
936
936
  return null;
937
- const s = [], { controller: o, unlink: d } = $e(n);
937
+ const o = [], { controller: s, unlink: d } = He(n);
938
938
  try {
939
- const c = this.acquire(this.chunks[i], s), h = await R(c.ready, o.signal), { times: u } = h;
940
- let E;
939
+ const c = this.acquire(this.chunks[i], o), f = await R(c.ready, s.signal), { times: u } = f;
940
+ let h;
941
941
  if (t <= u[u.length - 1]) {
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];
942
+ const { step: b, fraction: w } = We(u, t);
943
+ h = a === "discrete" || w === 0 ? [c, b, c, b, 0] : [c, b, c, b + 1, w];
944
944
  } else {
945
- const p = this.chunks[i + 1];
946
- if (!p)
945
+ const b = this.chunks[i + 1];
946
+ if (!b)
947
947
  return null;
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))
948
+ const w = this.acquire(b, o), G = await R(w.ready, s.signal), F = u.length - 1, U = u[F], D = G.times[0];
949
+ if (D - U > this.gapLimit(u, G.times))
950
950
  return null;
951
- E = a === "discrete" ? [c, A, c, A, 0] : t >= y ? [w, 0, w, 0, 0] : [c, A, w, 0, (t - v) / (y - v)];
951
+ h = a === "discrete" ? [c, F, c, F, 0] : t >= D ? [w, 0, w, 0, 0] : [c, F, w, 0, (t - U) / (D - U)];
952
952
  }
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));
955
- let x;
953
+ const [l, m, p, y, _] = h, P = l === p && m === y, g = [this.frame(l, m, s.signal)];
954
+ P || g.push(this.frame(p, y, s.signal));
955
+ let v;
956
956
  try {
957
- x = await Promise.all(P);
958
- } catch (p) {
959
- throw o.abort(), p;
957
+ v = await Promise.all(g);
958
+ } catch (b) {
959
+ throw s.abort(), b;
960
960
  }
961
961
  return this.prefetchAfter(i, t), {
962
962
  time: t,
963
- a: x[0],
964
- b: x[k ? 0 : 1],
965
- mix: $
963
+ a: v[0],
964
+ b: v[P ? 0 : 1],
965
+ mix: _
966
966
  };
967
967
  } finally {
968
968
  d();
969
- for (const c of s)
969
+ for (const c of o)
970
970
  c.users--;
971
971
  this.trim();
972
972
  }
@@ -1001,11 +1001,11 @@ class Et {
1001
1001
  t.length > 1 ? t[t.length - 1] - t[t.length - 2] : 0,
1002
1002
  r.length > 1 ? r[1] - r[0] : 0
1003
1003
  ], a = Math.max(...n);
1004
- return a > 0 ? a * Oe : -1 / 0;
1004
+ return a > 0 ? a * $e : -1 / 0;
1005
1005
  }
1006
1006
  prefetchAfter(t, r) {
1007
- const n = this.chunks[t], a = this.chunks[t + 1], i = n.end - n.start, s = i > 0 ? (r - n.start) / i : 1;
1008
- a && s > this.prefetchAt && this.prefetch(a);
1007
+ const n = this.chunks[t], a = this.chunks[t + 1], i = n.end - n.start, o = i > 0 ? (r - n.start) / i : 1;
1008
+ a && o > this.prefetchAt && this.prefetch(a);
1009
1009
  }
1010
1010
  manifest(t) {
1011
1011
  let r = this.manifests.get(t.manifestUrl);
@@ -1034,11 +1034,11 @@ class Et {
1034
1034
  };
1035
1035
  n.ready = this.manifest(t).then((a) => {
1036
1036
  if (n.released)
1037
- throw f();
1037
+ throw E();
1038
1038
  return n.opened = {
1039
1039
  manifest: a,
1040
- times: Float64Array.from(_(a)),
1041
- grid: Ne(a),
1040
+ times: Float64Array.from(A(a)),
1041
+ grid: Ve(a),
1042
1042
  source: this.createFrameSource(a, {
1043
1043
  cacheSize: this.frameCacheSize
1044
1044
  })
@@ -1050,20 +1050,20 @@ class Et {
1050
1050
  return this.open.set(t.key, r), r;
1051
1051
  }
1052
1052
  async frame(t, r, n) {
1053
- const { manifest: a, times: i, grid: s, source: o } = await R(
1053
+ const { manifest: a, times: i, grid: o, source: s } = await R(
1054
1054
  t.ready,
1055
1055
  n
1056
1056
  );
1057
1057
  if (t.released)
1058
- throw f();
1059
- const d = await o.frame(r, { signal: n });
1058
+ throw E();
1059
+ const d = await s.frame(r, { signal: n });
1060
1060
  return {
1061
1061
  key: `${this.id}/${t.chunk.key}/${r}`,
1062
1062
  chunk: t.chunk,
1063
1063
  step: r,
1064
1064
  time: i[r],
1065
1065
  data: d,
1066
- grid: s,
1066
+ grid: o,
1067
1067
  manifest: a
1068
1068
  };
1069
1069
  }
@@ -1080,7 +1080,7 @@ class Et {
1080
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);
1081
1081
  }
1082
1082
  }
1083
- function D(e) {
1083
+ function k(e) {
1084
1084
  const { start: t, end: r } = e.temporal ?? {};
1085
1085
  return {
1086
1086
  source: e,
@@ -1088,48 +1088,111 @@ function D(e) {
1088
1088
  end: Date.parse(r ?? t ?? "")
1089
1089
  };
1090
1090
  }
1091
- function Tt(e, t, r = {}) {
1092
- const n = e.filter((i) => i.id === t.id && i.temporal?.start != null).map(D), a = ge(
1091
+ function _t(e, t, r = {}) {
1092
+ const n = e.filter((i) => i.id === t.id && i.temporal?.start != null).map(k), a = Ne(
1093
1093
  n,
1094
1094
  Date.parse(t.temporal?.end ?? ""),
1095
1095
  r
1096
1096
  );
1097
1097
  return a ? { source: a.chunk.source, time: a.time } : null;
1098
1098
  }
1099
- function pt(e, t) {
1100
- return Ce(D(e), t.map(D))?.source ?? null;
1099
+ function At(e, t) {
1100
+ return Le(k(e), t.map(k))?.source ?? null;
1101
+ }
1102
+ const Ye = /^P(?:(\d+)Y)?(?:(\d+)M)?(?:(\d+)W)?(?:(\d+)D)?(?:T(?:(\d+)H)?(?:(\d+)M)?(?:(\d+)S)?)?$/;
1103
+ function je(e) {
1104
+ return e instanceof Date ? e.getTime() : typeof e == "number" ? e : new Date(e).getTime();
1101
1105
  }
1102
- function bt(e) {
1106
+ function X(e, t) {
1107
+ const r = je(e);
1108
+ if (!Number.isFinite(r))
1109
+ throw new Error(`Invalid ${t}`);
1110
+ return r;
1111
+ }
1112
+ function H(e, t) {
1113
+ const r = t.match(Ye);
1114
+ if (!r)
1115
+ throw new Error(`Invalid trailing time duration: ${t}`);
1116
+ const n = r.slice(1).map((_) => Number(_ ?? 0));
1117
+ if (!n.some((_) => _ > 0))
1118
+ throw new Error("Trailing time duration must be positive");
1119
+ const [a, i, o, s, d, c, f] = n, u = new Date(e), h = u.getUTCFullYear() * 12 + u.getUTCMonth() - a * 12 - i, l = Math.floor(h / 12), m = (h % 12 + 12) % 12, p = new Date(Date.UTC(l, m + 1, 0)).getUTCDate();
1120
+ return Date.UTC(
1121
+ l,
1122
+ m,
1123
+ Math.min(u.getUTCDate(), p),
1124
+ u.getUTCHours(),
1125
+ u.getUTCMinutes(),
1126
+ u.getUTCSeconds(),
1127
+ u.getUTCMilliseconds()
1128
+ ) - (((o * 7 + s) * 24 + d) * 60 + c) * 6e4 - f * 1e3;
1129
+ }
1130
+ function Ft(e, [t, r]) {
1131
+ let n = t, a = r;
1132
+ if (typeof e.trailing == "string" ? n = H(r, e.trailing) : (e.start != null && (n = X(e.start, "time range start")), e.end != null && (a = X(e.end, "time range end"))), n > a)
1133
+ throw new Error("Time range start must not follow its end");
1134
+ return [Math.max(t, n), Math.min(r, a)];
1135
+ }
1136
+ const ze = (e) => typeof e == "object" && e !== null && !Array.isArray(e);
1137
+ function xt(e, t) {
1138
+ if (!ze(e))
1139
+ throw new Error(`${t} must be an object`);
1140
+ for (const i of Object.keys(e))
1141
+ if (i !== "start" && i !== "end" && i !== "trailing")
1142
+ throw new Error(`${t}.${i} is not a time range key`);
1143
+ if (e.trailing !== void 0) {
1144
+ if (e.start !== void 0 || e.end !== void 0)
1145
+ throw new Error(`${t}.trailing excludes start and end`);
1146
+ if (typeof e.trailing != "string")
1147
+ throw new Error(`${t}.trailing must be an ISO 8601 duration`);
1148
+ return H(0, e.trailing), { trailing: e.trailing };
1149
+ }
1150
+ const r = (i) => {
1151
+ const o = e[i];
1152
+ if (o !== void 0) {
1153
+ if (typeof o != "string" || !Number.isFinite(Date.parse(o)))
1154
+ throw new Error(`${t}.${i} is not a date`);
1155
+ return o;
1156
+ }
1157
+ }, n = r("start"), a = r("end");
1158
+ if (n !== void 0 && a !== void 0 && Date.parse(n) > Date.parse(a))
1159
+ throw new Error(`${t}.start must not follow its end`);
1160
+ return {
1161
+ ...n !== void 0 && { start: n },
1162
+ ...a !== void 0 && { end: a }
1163
+ };
1164
+ }
1165
+ function yt(e) {
1103
1166
  return e.type === "geovideo" && typeof e.indexUrl == "string";
1104
1167
  }
1105
- function wt(e, t) {
1168
+ function vt(e, t) {
1106
1169
  return e.id === t.id && (e.type !== "geovideo" || t.type !== "geovideo" || e.manifestUrl === t.manifestUrl);
1107
1170
  }
1108
- function B(e) {
1171
+ function O(e) {
1109
1172
  return typeof e == "string" && Number.isFinite(Date.parse(e));
1110
1173
  }
1111
- function We(e) {
1174
+ function Ke(e) {
1112
1175
  const t = e;
1113
1176
  if (!t || t.schemaVersion !== 1 || t.type !== "geovideo-index" || !Array.isArray(t.chunks))
1114
1177
  throw new Error("Unsupported GeoVideo index");
1115
1178
  for (const r of t.chunks)
1116
- if (!B(r?.start) || !B(r.end) || Date.parse(r.end) < Date.parse(r.start) || typeof r.manifestUrl != "string")
1179
+ if (!O(r?.start) || !O(r.end) || Date.parse(r.end) < Date.parse(r.start) || typeof r.manifestUrl != "string")
1117
1180
  throw new Error("Invalid GeoVideo index chunk");
1118
1181
  return t;
1119
1182
  }
1120
- async function Rt(e, t) {
1183
+ async function Ut(e, t) {
1121
1184
  const r = await fetch(e, { signal: t });
1122
1185
  if (!r.ok)
1123
1186
  throw new Error(
1124
1187
  `GeoVideo index request failed (${r.status}): ${e}`
1125
1188
  );
1126
- return We(await r.json());
1189
+ return Ke(await r.json());
1127
1190
  }
1128
- function He(e) {
1191
+ function Je(e) {
1129
1192
  return typeof document < "u" ? new URL(e, document.baseURI).href : e;
1130
1193
  }
1131
- function Ye(e, t) {
1132
- const r = He(t);
1194
+ function Qe(e, t) {
1195
+ const r = Je(t);
1133
1196
  return e.chunks.map((n) => ({
1134
1197
  key: n.key,
1135
1198
  manifestUrl: new URL(n.manifestUrl, r).href,
@@ -1139,15 +1202,15 @@ function Ye(e, t) {
1139
1202
  ...n.provisional ? { provisional: !0 } : {}
1140
1203
  }));
1141
1204
  }
1142
- function ze(e, t, r) {
1205
+ function Ze(e, t, r) {
1143
1206
  if (t.sourceId !== e.id || t.catalogEntryId !== r.id)
1144
1207
  throw new Error(
1145
1208
  `GeoVideo index identity does not match catalog entry/source: ${e.id}`
1146
1209
  );
1147
1210
  }
1148
- function _t(e, t, r) {
1149
- ze(e, t, r);
1150
- const n = Ye(t, e.indexUrl);
1211
+ function Dt(e, t, r) {
1212
+ Ze(e, t, r);
1213
+ const n = Qe(t, e.indexUrl);
1151
1214
  return t.chunks.map(
1152
1215
  (a, i) => ({
1153
1216
  id: e.id,
@@ -1165,50 +1228,54 @@ function _t(e, t, r) {
1165
1228
  );
1166
1229
  }
1167
1230
  export {
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
1231
+ et as A,
1232
+ yt as B,
1233
+ _t as C,
1234
+ Ut as D,
1235
+ Dt as E,
1236
+ Ft as F,
1237
+ Ce as G,
1238
+ V as H,
1239
+ Rt as I,
1240
+ W as J,
1241
+ ge as K,
1242
+ Ze as L,
1243
+ Be as M,
1244
+ C as N,
1245
+ Ae as O,
1246
+ Ve as P,
1247
+ Qe as Q,
1248
+ Ne as R,
1249
+ At as S,
1250
+ Et as T,
1251
+ Le as U,
1252
+ xt as V,
1253
+ H as W,
1254
+ Ke as X,
1255
+ ct as a,
1256
+ dt as b,
1257
+ tt as c,
1258
+ at as d,
1259
+ it as e,
1260
+ st as f,
1261
+ ut as g,
1262
+ rt as h,
1263
+ ot as i,
1264
+ nt as j,
1265
+ ft as k,
1266
+ mt as l,
1267
+ ve as m,
1268
+ wt as n,
1269
+ De as o,
1270
+ me as p,
1271
+ bt as q,
1272
+ Te as r,
1273
+ lt as s,
1274
+ A as t,
1275
+ X as u,
1276
+ Tt as v,
1277
+ vt as w,
1278
+ pt as x,
1279
+ Ue as y,
1280
+ ht as z
1214
1281
  };