@fxi/zartigl 0.14.1 → 0.15.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.
package/dist/zartigl.js CHANGED
@@ -1,88 +1,86 @@
1
- import { m as ae, p as ft, s as pt, a as qe, b as Ot, r as ze, c as Bt, d as he, e as $t, f as gt, g as qt } from "./index-BDIf6Jc0.js";
2
- import { T as Wt, g as Xt, r as Ht, d as Yt, c as W, a as Zt, b as ge, e as jt, f as J, h as Se, i as O, G as Qt, j as We, F as Kt, s as vt, v as Q, k as K, l as Ge, m as Oe, n as yt, o as Xe, p as Ce, q as Jt, t as ke, u as ei, w as _t, x as z, y as He, z as we, A as ti, B as ii, C as ai, D as Ye, E as si, H as Fe, I as ri, J as xt, K as ni, L as oi, M as li, N as ci } from "./engine-C8ZNzILO.js";
3
- import { O as Ua, P as Na } from "./engine-C8ZNzILO.js";
4
- import { B as hi, a as ui, b as di, c as mi, d as bt, r as St, e as fi, g as pi } from "./backdrop-Dceb4d8E.js";
5
- import { f as Ga, i as Oa } from "./backdrop-Dceb4d8E.js";
6
- import { inflate as gi } from "pako";
7
- import vi from "numcodecs/blosc";
8
- const Ie = 85, yi = 89.9;
9
- function Ve(s) {
10
- return Math.max(-Ie, Math.min(Ie, s));
11
- }
12
- function Ze(s) {
13
- const e = Ve(s), t = Math.sin(e * Math.PI / 180);
1
+ import { m as ae, p as dt, s as mt, a as $e, b as Gt, r as ze, c as Ot, d as ue, e as Nt, f as ft, g as Bt } from "./index-jwaF2X-1.js";
2
+ import { T as $t, $ as qt, a0 as Wt, a1 as Xt, s as q, a2 as Ht, q as ge, a3 as Yt, a4 as J, a5 as Se, a6 as O, a as Zt, c as qe, a7 as jt, a8 as pt, Y as Q, Z as ve, a9 as K, aa as Ge, ab as Oe, i as gt, v as We, H as Ae, A as Qt, N as Ce, ac as Kt, D as vt, ad as z, ae as Xe, B as we, af as Jt, ag as ei, ah as ti, w as He, ai as ii, E as ke, I as ai, S as yt, aj as si, F as ri, x as ni, z as oi } from "./geovideo-index-D-BHqpO6.js";
3
+ import { ak as Ma, X as Pa } from "./geovideo-index-D-BHqpO6.js";
4
+ import { B as li, C as ci, b as ui, d as hi, e as _t, r as xt, c as di, g as mi } from "./backdrop-BMwRyFI5.js";
5
+ import { a as La, i as Da } from "./backdrop-BMwRyFI5.js";
6
+ const Fe = 85, fi = 89.9;
7
+ function Ve(a) {
8
+ return Math.max(-Fe, Math.min(Fe, a));
9
+ }
10
+ function Ye(a) {
11
+ const e = Ve(a), t = Math.sin(e * Math.PI / 180);
14
12
  return 0.5 - Math.log((1 + t) / (1 - t)) / (4 * Math.PI);
15
13
  }
16
- function ve(s) {
17
- return (s + 180) / 360;
14
+ function ye(a) {
15
+ return (a + 180) / 360;
18
16
  }
19
- function _i(s) {
20
- return ((s + 180) % 360 + 360) % 360 - 180;
17
+ function pi(a) {
18
+ return ((a + 180) % 360 + 360) % 360 - 180;
21
19
  }
22
- function wt(s, e, t, i) {
23
- const a = (o, l, d) => d > l ? Math.abs(o[d] - o[l]) / (d - l) / 2 : o.length > 1 ? Math.abs(o[1] - o[0]) / 2 : 0, r = a(s, t[0], t[1]), n = a(e, i[0], i[1]);
20
+ function bt(a, e, t, i) {
21
+ const s = (o, c, d) => d > c ? Math.abs(o[d] - o[c]) / (d - c) / 2 : o.length > 1 ? Math.abs(o[1] - o[0]) / 2 : 0, r = s(a, t[0], t[1]), n = s(e, i[0], i[1]);
24
22
  return {
25
- west: s[t[0]] - r,
26
- east: s[t[1]] + r,
23
+ west: a[t[0]] - r,
24
+ east: a[t[1]] + r,
27
25
  south: Math.min(e[i[0]], e[i[1]]) - n,
28
26
  north: Math.max(e[i[0]], e[i[1]]) + n
29
27
  };
30
28
  }
31
- function ye(s, e) {
32
- if (s.getProjection?.()?.type !== "globe")
29
+ function _e(a, e) {
30
+ if (a.getProjection?.()?.type !== "globe")
33
31
  return !1;
34
32
  const t = e?.projectionTransition;
35
33
  return typeof t == "number" ? t > 0 : !0;
36
34
  }
37
- function xi(s, e) {
38
- const t = _i(s) * Math.PI / 180, i = e * Math.PI / 180, a = Math.cos(i);
35
+ function gi(a, e) {
36
+ const t = pi(a) * Math.PI / 180, i = e * Math.PI / 180, s = Math.cos(i);
39
37
  return [
40
- Math.sin(t) * a,
38
+ Math.sin(t) * s,
41
39
  Math.sin(i),
42
- Math.cos(t) * a
40
+ Math.cos(t) * s
43
41
  ];
44
42
  }
45
- function bi(s) {
43
+ function vi(a) {
46
44
  return {
47
45
  west: -180,
48
46
  east: 180,
49
- south: Ve(s.getSouth()),
50
- north: Ve(s.getNorth())
47
+ south: Ve(a.getSouth()),
48
+ north: Ve(a.getNorth())
51
49
  };
52
50
  }
53
- function Si(s, e = 1, t = !1) {
54
- const i = t ? yi : Ie, a = (d) => Math.max(-i, Math.min(i, d)), r = a(s.getSouth()), n = a(s.getNorth()), l = Math.max(0, n - r) * Math.max(0, e);
51
+ function yi(a, e = 1, t = !1) {
52
+ const i = t ? fi : Fe, s = (d) => Math.max(-i, Math.min(i, d)), r = s(a.getSouth()), n = s(a.getNorth()), c = Math.max(0, n - r) * Math.max(0, e);
55
53
  return {
56
54
  west: -180,
57
55
  east: 180,
58
- south: a(r - l),
59
- north: a(n + l)
56
+ south: s(r - c),
57
+ north: s(n + c)
60
58
  };
61
59
  }
62
- function wi(s, e, t = 1e-6) {
63
- return s.south <= e.south + t && s.north >= e.north - t;
60
+ function _i(a, e, t = 1e-6) {
61
+ return a.south <= e.south + t && a.north >= e.north - t;
64
62
  }
65
- function Ti(s, e = !1) {
66
- const t = s.getWest(), i = s.getEast(), a = ve(t), r = ve(i), n = a - Math.floor(a), o = r - a >= 1 ? { minX: 0, maxX: 1 } : { minX: n, maxX: n + r - a };
63
+ function xi(a, e = !1) {
64
+ const t = a.getWest(), i = a.getEast(), s = ye(t), r = ye(i), n = s - Math.floor(s), o = r - s >= 1 ? { minX: 0, maxX: 1 } : { minX: n, maxX: n + r - s };
67
65
  return e ? {
68
66
  ...o,
69
- minY: (Math.max(s.getSouth(), -90) + 90) / 180,
70
- maxY: (Math.min(s.getNorth(), 90) + 90) / 180
67
+ minY: (Math.max(a.getSouth(), -90) + 90) / 180,
68
+ maxY: (Math.min(a.getNorth(), 90) + 90) / 180
71
69
  } : {
72
70
  ...o,
73
- minY: Ze(s.getNorth()),
74
- maxY: Ze(s.getSouth())
71
+ minY: Ye(a.getNorth()),
72
+ maxY: Ye(a.getSouth())
75
73
  };
76
74
  }
77
- function Be(s, e) {
75
+ function Ne(a, e) {
78
76
  if (e)
79
77
  return [0];
80
- const t = ve(s.getWest()), i = ve(s.getEast()), a = [];
78
+ const t = ye(a.getWest()), i = ye(a.getEast()), s = [];
81
79
  for (let r = Math.floor(t); r <= Math.floor(i); r++)
82
- a.push(r);
83
- return a;
80
+ s.push(r);
81
+ return s;
84
82
  }
85
- const ue = [
83
+ const he = [
86
84
  "u_velocity_next",
87
85
  "u_velocity_next_min",
88
86
  "u_velocity_next_max",
@@ -92,8 +90,8 @@ const ue = [
92
90
  "u_velocity_flip_y",
93
91
  "u_velocity_next_flip_y"
94
92
  ];
95
- function Te(s, e, t) {
96
- s.uniform1i(e.u_velocity_next, t.b.unit), s.uniform2f(e.u_velocity_next_min, ...t.b.min), s.uniform2f(e.u_velocity_next_max, ...t.b.max), s.uniform1f(e.u_velocity_mix, t.mix), s.uniform1f(e.u_velocity_physical, t.a.physical ? 1 : 0), s.uniform1f(e.u_velocity_next_physical, t.b.physical ? 1 : 0), s.uniform1f(e.u_velocity_flip_y, t.a.northToSouth ? 1 : 0), s.uniform1f(e.u_velocity_next_flip_y, t.b.northToSouth ? 1 : 0);
93
+ function Te(a, e, t) {
94
+ a.uniform1i(e.u_velocity_next, t.b.unit), a.uniform2f(e.u_velocity_next_min, ...t.b.min), a.uniform2f(e.u_velocity_next_max, ...t.b.max), a.uniform1f(e.u_velocity_mix, t.mix), a.uniform1f(e.u_velocity_physical, t.a.physical ? 1 : 0), a.uniform1f(e.u_velocity_next_physical, t.b.physical ? 1 : 0), a.uniform1f(e.u_velocity_flip_y, t.a.northToSouth ? 1 : 0), a.uniform1f(e.u_velocity_next_flip_y, t.b.northToSouth ? 1 : 0);
97
95
  }
98
96
  var de = `#version 300 es
99
97
  precision highp float;
@@ -104,7 +102,7 @@ out vec2 v_tex_coord;
104
102
  void main() {
105
103
  v_tex_coord = a_position * 0.5 + 0.5;
106
104
  gl_Position = vec4(a_position, 0.0, 1.0);
107
- }`, Mi = `#version 300 es
105
+ }`, bi = `#version 300 es
108
106
  precision highp float;
109
107
 
110
108
  uint pcg(uint v) {
@@ -374,7 +372,7 @@ void main() {
374
372
  fract(newPos.y * 255.0)
375
373
  );
376
374
  #endif
377
- }`, Ri = `precision highp float;
375
+ }`, Si = `precision highp float;
378
376
 
379
377
  attribute float a_index;
380
378
  attribute float a_is_curr;
@@ -606,7 +604,7 @@ void main() {
606
604
  vec2 worldPos = vec2((pos.x + u_world_offset) * u_world_size, pos.y * u_world_size);
607
605
  gl_Position = u_matrix * vec4(worldPos, 0.0, 1.0);
608
606
  }
609
- }`, Pi = `precision mediump float;
607
+ }`, wi = `precision mediump float;
610
608
 
611
609
  uniform sampler2D u_color_ramp;
612
610
  uniform float u_particle_contrast;
@@ -645,7 +643,7 @@ void main() {
645
643
  }
646
644
 
647
645
  gl_FragColor = vec4(color.rgb, color.a * u_opacity);
648
- }`, Ei = `#version 300 es
646
+ }`, Ti = `#version 300 es
649
647
  precision mediump float;
650
648
 
651
649
  uniform sampler2D u_screen;
@@ -662,7 +660,7 @@ void main() {
662
660
  float alpha = floor(color.a * 255.0 * u_opacity) / 255.0;
663
661
 
664
662
  o_color = vec4(color.rgb * step(1.0 / 255.0, alpha), alpha);
665
- }`, Li = `#version 300 es
663
+ }`, Ri = `#version 300 es
666
664
  precision mediump float;
667
665
 
668
666
  uniform sampler2D u_screen;
@@ -733,7 +731,7 @@ void main() {
733
731
  }
734
732
  vec3 rgb = u_grade_on > 0.5 ? gradeColor(color.rgb, u_grade) : color.rgb;
735
733
  o_color = vec4(rgb, color.a);
736
- }`, Di = `#version 300 es
734
+ }`, Mi = `#version 300 es
737
735
  precision mediump float;
738
736
 
739
737
  uniform sampler2D u_screen;
@@ -770,7 +768,7 @@ vec4 addGlow(vec4 trail, sampler2D glowTex, vec2 uv, float gain) {
770
768
 
771
769
  void main() {
772
770
  o_color = glowGather(u_screen, ivec2(gl_FragCoord.xy));
773
- }`, Tt = `precision highp float;
771
+ }`, St = `precision highp float;
774
772
 
775
773
  attribute vec2 a_grid_uv;
776
774
 
@@ -804,7 +802,7 @@ void main() {
804
802
 
805
803
  v_geo_uv = vec2((lng - u_geo_bounds.x) / width, a_grid_uv.y);
806
804
  gl_Position = u_matrix * vec4(worldPos, 0.0, 1.0);
807
- }`, Ai = `precision mediump float;
805
+ }`, Pi = `precision mediump float;
808
806
 
809
807
  uniform sampler2D u_field;
810
808
  uniform sampler2D u_color_ramp;
@@ -904,7 +902,7 @@ void main() {
904
902
  vec4 color = texture2D(u_color_ramp, vec2(t, 0.5));
905
903
  color.rgb = applyVibrance(color.rgb, u_vibrance);
906
904
  gl_FragColor = vec4(color.rgb, color.a * u_opacity);
907
- }`, Mt = `precision highp float;
905
+ }`, wt = `precision highp float;
908
906
 
909
907
  attribute vec2 a_grid_uv;
910
908
 
@@ -954,7 +952,7 @@ void main() {
954
952
  position.xyw = mix(flatPosition.xyw, position.xyw, u_projection_transition);
955
953
  }
956
954
  gl_Position = position;
957
- }`, Ci = `precision mediump float;
955
+ }`, Ei = `precision mediump float;
958
956
 
959
957
  uniform sampler2D u_field;
960
958
  uniform sampler2D u_color_ramp;
@@ -1044,25 +1042,25 @@ void main() {
1044
1042
  color.rgb = applyVibrance(color.rgb, u_vibrance);
1045
1043
  gl_FragColor = vec4(color.rgb, color.a * u_opacity);
1046
1044
  }`;
1047
- const Me = [0, 0, 0, 0], B = 512, H = B * B, Y = 128, ee = 64, ki = 1, Fi = 0.92, Ii = 0.1, je = 0.98;
1048
- function Vi(s) {
1049
- if (Number.isNaN(s))
1045
+ const Re = [0, 0, 0, 0], N = 512, H = N * N, Y = 128, ee = 64, Li = 1, Di = 0.92, Ai = 0.1, Ze = 0.98;
1046
+ function Ci(a) {
1047
+ if (Number.isNaN(a))
1050
1048
  return 32256;
1051
- if (s === 1 / 0)
1049
+ if (a === 1 / 0)
1052
1050
  return 31744;
1053
- if (s === -1 / 0)
1051
+ if (a === -1 / 0)
1054
1052
  return 64512;
1055
- const e = s < 0 ? 32768 : 0, t = Math.abs(s);
1053
+ const e = a < 0 ? 32768 : 0, t = Math.abs(a);
1056
1054
  if (t === 0)
1057
1055
  return e;
1058
1056
  if (t >= 65504)
1059
1057
  return e | 31743;
1060
1058
  if (t < 6103515625e-14)
1061
1059
  return e | Math.round(t / 5960464477539063e-23);
1062
- const i = Math.floor(Math.log2(t)), a = t / 2 ** i - 1;
1063
- return e | i + 15 << 10 | Math.round(a * 1024);
1060
+ const i = Math.floor(Math.log2(t)), s = t / 2 ** i - 1;
1061
+ return e | i + 15 << 10 | Math.round(s * 1024);
1064
1062
  }
1065
- const Ui = {
1063
+ const ki = {
1066
1064
  particleDensity: 0.05,
1067
1065
  speed: 1,
1068
1066
  fadeOpacity: 0.996,
@@ -1071,28 +1069,28 @@ const Ui = {
1071
1069
  opacity: 1,
1072
1070
  logScale: !1,
1073
1071
  vibrance: 0,
1074
- colorGrade: ui,
1075
- backdrop: hi,
1072
+ colorGrade: ci,
1073
+ backdrop: li,
1076
1074
  glow: 0,
1077
1075
  scalarMode: !1,
1078
1076
  particleState: "auto",
1079
1077
  rgba8MaxParticleZoom: 4
1080
1078
  };
1081
- class Rt {
1079
+ class Tt {
1082
1080
  constructor(e) {
1083
- this.numParticles = 0, this.prevBounds = null, this.redistributionBoost = 0, this.frame = Math.floor(Math.random() * 2 ** 30), this.webglInfo = null, this.lastRgba8ParticlesSuppressed = !1, this.screenWidth = 0, this.screenHeight = 0, this.glowTexture = null, this.glowFramebuffer = null, this.rasterGridIndexCount = 0, this.renderMode = "raster+particles", this.params = { ...Ui, ...e }, this.trailFade = new Wt(this.params.fadeOpacity);
1081
+ this.numParticles = 0, this.prevBounds = null, this.redistributionBoost = 0, this.frame = Math.floor(Math.random() * 2 ** 30), this.webglInfo = null, this.lastRgba8ParticlesSuppressed = !1, this.screenWidth = 0, this.screenHeight = 0, this.glowTexture = null, this.glowFramebuffer = null, this.rasterGridIndexCount = 0, this.renderMode = "raster+particles", this.params = { ...ki, ...e }, this.trailFade = new $t(this.params.fadeOpacity);
1084
1082
  }
1085
1083
  init(e) {
1086
- this.gl = e, this.webglInfo = Xt(e), this.stateFormat = this.params.particleState === "rgba8" ? Ht(e) : Yt(e);
1084
+ this.gl = e, this.webglInfo = qt(e), this.stateFormat = this.params.particleState === "rgba8" ? Wt(e) : Xt(e);
1087
1085
  const t = this.stateFormat.kind !== "rgba8-packed" ? `#define USE_FLOAT_STATE 1
1088
1086
  ` : "";
1089
- this.updateProgram = W(
1087
+ this.updateProgram = q(
1090
1088
  e,
1091
1089
  de,
1092
- Mi.replace(/^(#version[^\n]*\n)/, `$1${t}`)
1093
- ), this.drawProgram = W(e, t + Ri, Pi), this.fadeProgram = W(e, de, Ei), this.compositeProgram = W(e, de, Li), this.glowProgram = W(e, de, Di), this.gridProgram = W(e, Tt, Ai), this.gridGlobeProgram = W(e, Mt, Ci), this.updateLocs = this.getUniforms(this.updateProgram, [
1090
+ bi.replace(/^(#version[^\n]*\n)/, `$1${t}`)
1091
+ ), this.drawProgram = q(e, t + Si, wi), this.fadeProgram = q(e, de, Ti), this.compositeProgram = q(e, de, Ri), this.glowProgram = q(e, de, Mi), this.gridProgram = q(e, St, Pi), this.gridGlobeProgram = q(e, wt, Ei), this.updateLocs = this.getUniforms(this.updateProgram, [
1094
1092
  "u_particles",
1095
- ...ue,
1093
+ ...he,
1096
1094
  "u_velocity",
1097
1095
  "u_velocity_min",
1098
1096
  "u_velocity_max",
@@ -1108,7 +1106,7 @@ class Rt {
1108
1106
  ]), this.drawLocs = this.getUniforms(this.drawProgram, [
1109
1107
  "u_particles",
1110
1108
  "u_prev_particles",
1111
- ...ue,
1109
+ ...he,
1112
1110
  "u_velocity",
1113
1111
  "u_velocity_min",
1114
1112
  "u_velocity_max",
@@ -1136,7 +1134,7 @@ class Rt {
1136
1134
  "u_grade_on",
1137
1135
  "u_grade"
1138
1136
  ]), this.glowLocs = this.getUniforms(this.glowProgram, ["u_screen"]), this.gridLocs = this.getUniforms(this.gridProgram, [
1139
- ...ue,
1137
+ ...he,
1140
1138
  "u_field",
1141
1139
  "u_color_ramp",
1142
1140
  "u_matrix",
@@ -1155,7 +1153,7 @@ class Rt {
1155
1153
  "u_scalar_mode",
1156
1154
  "u_solid"
1157
1155
  ]), this.gridGlobeLocs = this.getUniforms(this.gridGlobeProgram, [
1158
- ...ue,
1156
+ ...he,
1159
1157
  "u_field",
1160
1158
  "u_color_ramp",
1161
1159
  "u_matrix",
@@ -1174,52 +1172,52 @@ class Rt {
1174
1172
  "u_vibrance",
1175
1173
  "u_scalar_mode",
1176
1174
  "u_solid"
1177
- ]), this.quadBuffer = Zt(e), this.initRasterGrid(), this.colorRampTexture = ge(e, this.params.colorRamp), this.initParticleState();
1175
+ ]), this.quadBuffer = Ht(e), this.initRasterGrid(), this.colorRampTexture = ge(e, this.params.colorRamp), this.initParticleState();
1178
1176
  }
1179
1177
  getUniforms(e, t) {
1180
1178
  const i = {};
1181
- for (const a of t)
1182
- i[a] = this.gl.getUniformLocation(e, a);
1179
+ for (const s of t)
1180
+ i[s] = this.gl.getUniformLocation(e, s);
1183
1181
  return i;
1184
1182
  }
1185
1183
  /** Random initial particle positions, matching the active state format. */
1186
1184
  makeStateData() {
1187
- const e = B, t = e * e * 4;
1185
+ const e = N, t = e * e * 4;
1188
1186
  if (this.stateFormat?.kind === "float32") {
1189
- const a = new Float32Array(t);
1187
+ const s = new Float32Array(t);
1190
1188
  for (let r = 0; r < t; r++)
1191
- a[r] = Math.random();
1192
- return a;
1189
+ s[r] = Math.random();
1190
+ return s;
1193
1191
  }
1194
1192
  if (this.stateFormat?.kind === "float16") {
1195
- const a = new Uint16Array(t);
1193
+ const s = new Uint16Array(t);
1196
1194
  for (let r = 0; r < t; r++)
1197
- a[r] = Vi(Math.random());
1198
- return a;
1195
+ s[r] = Ci(Math.random());
1196
+ return s;
1199
1197
  }
1200
1198
  const i = new Uint8Array(t);
1201
- for (let a = 0; a < t; a++)
1202
- i[a] = Math.floor(Math.random() * 256);
1199
+ for (let s = 0; s < t; s++)
1200
+ i[s] = Math.floor(Math.random() * 256);
1203
1201
  return i;
1204
1202
  }
1205
1203
  createStateTexture(e) {
1206
- return jt(
1204
+ return Yt(
1207
1205
  this.gl,
1208
1206
  this.gl.NEAREST,
1209
1207
  e,
1210
- B,
1211
- B,
1208
+ N,
1209
+ N,
1212
1210
  this.stateFormat.internalFormat,
1213
1211
  this.stateFormat.type
1214
1212
  );
1215
1213
  }
1216
1214
  initParticleState() {
1217
- const e = this.gl, t = this.makeStateData(), i = this.createStateTexture(t), a = this.createStateTexture(t), r = J(e, i), n = J(e, a);
1218
- this.particleStateTextures = [i, a], this.particleFramebuffers = [r, n];
1219
- const o = new Float32Array(H * 2), l = new Float32Array(H * 2);
1215
+ const e = this.gl, t = this.makeStateData(), i = this.createStateTexture(t), s = this.createStateTexture(t), r = J(e, i), n = J(e, s);
1216
+ this.particleStateTextures = [i, s], this.particleFramebuffers = [r, n];
1217
+ const o = new Float32Array(H * 2), c = new Float32Array(H * 2);
1220
1218
  for (let d = 0; d < H; d++)
1221
- o[d * 2] = d, o[d * 2 + 1] = d, l[d * 2] = 0, l[d * 2 + 1] = 1;
1222
- this.particleIndexBuffer = e.createBuffer(), e.bindBuffer(e.ARRAY_BUFFER, this.particleIndexBuffer), e.bufferData(e.ARRAY_BUFFER, o, e.STATIC_DRAW), this.particleIsCurrBuffer = e.createBuffer(), e.bindBuffer(e.ARRAY_BUFFER, this.particleIsCurrBuffer), e.bufferData(e.ARRAY_BUFFER, l, e.STATIC_DRAW);
1219
+ o[d * 2] = d, o[d * 2 + 1] = d, c[d * 2] = 0, c[d * 2 + 1] = 1;
1220
+ this.particleIndexBuffer = e.createBuffer(), e.bindBuffer(e.ARRAY_BUFFER, this.particleIndexBuffer), e.bufferData(e.ARRAY_BUFFER, o, e.STATIC_DRAW), this.particleIsCurrBuffer = e.createBuffer(), e.bindBuffer(e.ARRAY_BUFFER, this.particleIsCurrBuffer), e.bufferData(e.ARRAY_BUFFER, c, e.STATIC_DRAW);
1223
1221
  }
1224
1222
  initRasterGrid() {
1225
1223
  const e = this.gl, t = new Float32Array(
@@ -1227,19 +1225,19 @@ class Rt {
1227
1225
  );
1228
1226
  let i = 0;
1229
1227
  for (let o = 0; o <= ee; o++)
1230
- for (let l = 0; l <= Y; l++)
1231
- t[i++] = l / Y, t[i++] = o / ee;
1232
- const a = new Uint16Array(
1228
+ for (let c = 0; c <= Y; c++)
1229
+ t[i++] = c / Y, t[i++] = o / ee;
1230
+ const s = new Uint16Array(
1233
1231
  Y * ee * 6
1234
1232
  );
1235
1233
  let r = 0;
1236
1234
  const n = Y + 1;
1237
1235
  for (let o = 0; o < ee; o++)
1238
- for (let l = 0; l < Y; l++) {
1239
- const d = o * n + l, c = d + 1, u = d + n, f = u + 1;
1240
- a[r++] = d, a[r++] = u, a[r++] = c, a[r++] = c, a[r++] = u, a[r++] = f;
1236
+ for (let c = 0; c < Y; c++) {
1237
+ const d = o * n + c, u = d + 1, h = d + n, v = h + 1;
1238
+ s[r++] = d, s[r++] = h, s[r++] = u, s[r++] = u, s[r++] = h, s[r++] = v;
1241
1239
  }
1242
- this.rasterGridBuffer = e.createBuffer(), e.bindBuffer(e.ARRAY_BUFFER, this.rasterGridBuffer), e.bufferData(e.ARRAY_BUFFER, t, e.STATIC_DRAW), this.rasterGridIndexBuffer = e.createBuffer(), e.bindBuffer(e.ELEMENT_ARRAY_BUFFER, this.rasterGridIndexBuffer), e.bufferData(e.ELEMENT_ARRAY_BUFFER, a, e.STATIC_DRAW), this.rasterGridIndexCount = a.length;
1240
+ this.rasterGridBuffer = e.createBuffer(), e.bindBuffer(e.ARRAY_BUFFER, this.rasterGridBuffer), e.bufferData(e.ARRAY_BUFFER, t, e.STATIC_DRAW), this.rasterGridIndexBuffer = e.createBuffer(), e.bindBuffer(e.ELEMENT_ARRAY_BUFFER, this.rasterGridIndexBuffer), e.bufferData(e.ELEMENT_ARRAY_BUFFER, s, e.STATIC_DRAW), this.rasterGridIndexCount = s.length;
1243
1241
  }
1244
1242
  /**
1245
1243
  * Ensure screen textures match the current canvas size and recompute
@@ -1256,31 +1254,31 @@ class Rt {
1256
1254
  return;
1257
1255
  const i = this.gl;
1258
1256
  this.screenWidth = e, this.screenHeight = t, this.screenTextures && (i.deleteTexture(this.screenTextures[0]), i.deleteTexture(this.screenTextures[1]), i.deleteFramebuffer(this.screenFramebuffers[0]), i.deleteFramebuffer(this.screenFramebuffers[1])), this.deleteGlowTarget();
1259
- const a = new Uint8Array(e * t * 4), r = Se(i, i.NEAREST, a, e, t), n = Se(i, i.NEAREST, a, e, t), o = J(i, r), l = J(i, n);
1260
- this.screenTextures = [r, n], this.screenFramebuffers = [o, l];
1257
+ const s = new Uint8Array(e * t * 4), r = Se(i, i.NEAREST, s, e, t), n = Se(i, i.NEAREST, s, e, t), o = J(i, r), c = J(i, n);
1258
+ this.screenTextures = [r, n], this.screenFramebuffers = [o, c];
1261
1259
  }
1262
1260
  /**
1263
1261
  * Run one simulation step: update positions, fade trails, draw particles.
1264
1262
  * Must be called within the MapLibre render callback.
1265
1263
  */
1266
- render(e, t, i, a, r, n, o, l, d = !1, c = [0, 0, 1], u, f) {
1267
- const m = { unit: e, min: t, max: i }, p = f ?? { a: m, b: m, mix: 0 }, h = this.gl;
1264
+ render(e, t, i, s, r, n, o, c, d = !1, u = [0, 0, 1], h, v) {
1265
+ const m = { unit: e, min: t, max: i }, f = v ?? { a: m, b: m, mix: 0 }, l = this.gl;
1268
1266
  if (this.screenWidth === 0 || this.screenHeight === 0)
1269
1267
  return;
1270
- const g = h.getParameter(
1271
- h.FRAMEBUFFER_BINDING
1268
+ const p = l.getParameter(
1269
+ l.FRAMEBUFFER_BINDING
1272
1270
  ), x = this.shouldSuppressRgba8Particles(n);
1273
1271
  x && !this.lastRgba8ParticlesSuppressed && this.clearState(), this.lastRgba8ParticlesSuppressed = x;
1274
- const T = !x && (this.renderMode === "particles" || this.renderMode === "raster+particles"), M = x || this.renderMode === "raster" || this.renderMode === "raster+particles";
1272
+ const T = !x && (this.renderMode === "particles" || this.renderMode === "raster+particles"), R = x || this.renderMode === "raster" || this.renderMode === "raster+particles";
1275
1273
  let y = !1;
1276
1274
  if (T) {
1277
- h.disable(h.BLEND), h.useProgram(this.updateProgram), h.viewport(0, 0, B, B), O(h, this.particleStateTextures[0], 0), h.uniform1i(this.updateLocs.u_particles, 0), Te(h, this.updateLocs, p), h.uniform1i(this.updateLocs.u_velocity, p.a.unit), h.uniform2f(this.updateLocs.u_velocity_min, ...p.a.min), h.uniform2f(this.updateLocs.u_velocity_max, ...p.a.max), h.uniform1f(this.updateLocs.u_speed, this.params.speed), h.uniform1f(this.updateLocs.u_world_size, n), h.uniform1ui(this.updateLocs.u_frame, this.frame), this.frame = this.frame + 1 >>> 0;
1278
- const R = r.maxX - r.minX;
1275
+ l.disable(l.BLEND), l.useProgram(this.updateProgram), l.viewport(0, 0, N, N), O(l, this.particleStateTextures[0], 0), l.uniform1i(this.updateLocs.u_particles, 0), Te(l, this.updateLocs, f), l.uniform1i(this.updateLocs.u_velocity, f.a.unit), l.uniform2f(this.updateLocs.u_velocity_min, ...f.a.min), l.uniform2f(this.updateLocs.u_velocity_max, ...f.a.max), l.uniform1f(this.updateLocs.u_speed, this.params.speed), l.uniform1f(this.updateLocs.u_world_size, n), l.uniform1ui(this.updateLocs.u_frame, this.frame), this.frame = this.frame + 1 >>> 0;
1276
+ const P = r.maxX - r.minX;
1279
1277
  if (this.prevBounds) {
1280
- const F = this.prevBounds.maxX - this.prevBounds.minX, L = this.prevBounds.maxY - this.prevBounds.minY, D = 1e-6, b = (r.minX + r.maxX) * 0.5, A = (r.minY + r.maxY) * 0.5, N = (this.prevBounds.minX + this.prevBounds.maxX) * 0.5, C = (this.prevBounds.minY + this.prevBounds.maxY) * 0.5, I = Math.abs(R - F) / Math.max(F, D), w = Math.abs(b - N) / Math.max(F, D) + Math.abs(A - C) / Math.max(L, D), V = Math.min(1, I + w);
1278
+ const U = this.prevBounds.maxX - this.prevBounds.minX, L = this.prevBounds.maxY - this.prevBounds.minY, D = 1e-6, b = (r.minX + r.maxX) * 0.5, V = (r.minY + r.maxY) * 0.5, X = (this.prevBounds.minX + this.prevBounds.maxX) * 0.5, C = (this.prevBounds.minY + this.prevBounds.maxY) * 0.5, I = Math.abs(P - U) / Math.max(U, D), w = Math.abs(b - X) / Math.max(U, D) + Math.abs(V - C) / Math.max(L, D), k = Math.min(1, I + w);
1281
1279
  this.redistributionBoost = Math.max(
1282
- this.redistributionBoost * Fi,
1283
- V * ki
1280
+ this.redistributionBoost * Di,
1281
+ k * Li
1284
1282
  );
1285
1283
  }
1286
1284
  this.prevBounds = {
@@ -1289,187 +1287,187 @@ class Rt {
1289
1287
  maxX: r.maxX,
1290
1288
  maxY: r.maxY
1291
1289
  };
1292
- const k = Math.min(
1290
+ const A = Math.min(
1293
1291
  this.params.dropRate + this.redistributionBoost,
1294
- Ii
1292
+ Ai
1295
1293
  );
1296
- h.uniform1f(this.updateLocs.u_drop_rate, k), h.uniform1f(
1294
+ l.uniform1f(this.updateLocs.u_drop_rate, A), l.uniform1f(
1297
1295
  this.updateLocs.u_drop_rate_bump,
1298
1296
  this.params.dropRateBump
1299
- ), h.uniform4f(
1297
+ ), l.uniform4f(
1300
1298
  this.updateLocs.u_bounds,
1301
1299
  r.minX,
1302
1300
  r.minY,
1303
1301
  r.maxX,
1304
1302
  r.maxY
1305
- ), h.uniform1f(this.updateLocs.u_is_globe, d ? 1 : 0), l && h.uniform4f(
1303
+ ), l.uniform1f(this.updateLocs.u_is_globe, d ? 1 : 0), c && l.uniform4f(
1306
1304
  this.updateLocs.u_geo_bounds,
1307
- l.west,
1308
- l.south,
1309
- l.east,
1310
- l.north
1311
- ), h.uniform1f(
1305
+ c.west,
1306
+ c.south,
1307
+ c.east,
1308
+ c.north
1309
+ ), l.uniform1f(
1312
1310
  this.updateLocs.u_valid_threshold,
1313
- je
1314
- ), h.bindFramebuffer(h.FRAMEBUFFER, this.particleFramebuffers[1]), this.drawQuad(), y = !0;
1311
+ Ze
1312
+ ), l.bindFramebuffer(l.FRAMEBUFFER, this.particleFramebuffers[1]), this.drawQuad(), y = !0;
1315
1313
  }
1316
- h.viewport(0, 0, this.screenWidth, this.screenHeight), h.bindFramebuffer(h.FRAMEBUFFER, this.screenFramebuffers[1]), h.useProgram(this.fadeProgram), h.disable(h.BLEND), O(h, this.screenTextures[0], 0), h.uniform1i(this.fadeLocs.u_screen, 0), h.uniform1f(
1314
+ l.viewport(0, 0, this.screenWidth, this.screenHeight), l.bindFramebuffer(l.FRAMEBUFFER, this.screenFramebuffers[1]), l.useProgram(this.fadeProgram), l.disable(l.BLEND), O(l, this.screenTextures[0], 0), l.uniform1i(this.fadeLocs.u_screen, 0), l.uniform1f(
1317
1315
  this.fadeLocs.u_opacity,
1318
1316
  this.updateTrailFadeOpacity(performance.now())
1319
1317
  ), this.drawQuad();
1320
- const v = (R) => {
1321
- l && (d && u ? this.renderGridGlobe(
1318
+ const g = (P) => {
1319
+ c && (d && h ? this.renderGridGlobe(
1322
1320
  e,
1323
1321
  t,
1324
1322
  i,
1325
- a,
1326
- l,
1327
- u,
1323
+ s,
1324
+ c,
1325
+ h,
1328
1326
  1,
1329
- R,
1330
- p
1327
+ P,
1328
+ f
1331
1329
  ) : d || this.renderGrid(
1332
1330
  e,
1333
1331
  t,
1334
1332
  i,
1335
- a,
1333
+ s,
1336
1334
  n,
1337
1335
  o,
1338
- l,
1336
+ c,
1339
1337
  1,
1340
- R,
1341
- p
1338
+ P,
1339
+ f
1342
1340
  ));
1343
1341
  };
1344
- if (M && v(Me), T) {
1345
- h.useProgram(this.drawProgram), h.enable(h.BLEND), h.blendFuncSeparate(
1346
- h.SRC_ALPHA,
1347
- h.ONE_MINUS_SRC_ALPHA,
1348
- h.ONE,
1349
- h.ONE_MINUS_SRC_ALPHA
1350
- ), O(h, this.particleStateTextures[1], 0), h.uniform1i(this.drawLocs.u_particles, 0), O(h, this.particleStateTextures[0], 3), h.uniform1i(this.drawLocs.u_prev_particles, 3), Te(h, this.drawLocs, p), h.uniform1i(this.drawLocs.u_velocity, p.a.unit), h.uniform2f(this.drawLocs.u_velocity_min, ...p.a.min), h.uniform2f(this.drawLocs.u_velocity_max, ...p.a.max), l && h.uniform4f(
1342
+ if (R && g(Re), T) {
1343
+ l.useProgram(this.drawProgram), l.enable(l.BLEND), l.blendFuncSeparate(
1344
+ l.SRC_ALPHA,
1345
+ l.ONE_MINUS_SRC_ALPHA,
1346
+ l.ONE,
1347
+ l.ONE_MINUS_SRC_ALPHA
1348
+ ), O(l, this.particleStateTextures[1], 0), l.uniform1i(this.drawLocs.u_particles, 0), O(l, this.particleStateTextures[0], 3), l.uniform1i(this.drawLocs.u_prev_particles, 3), Te(l, this.drawLocs, f), l.uniform1i(this.drawLocs.u_velocity, f.a.unit), l.uniform2f(this.drawLocs.u_velocity_min, ...f.a.min), l.uniform2f(this.drawLocs.u_velocity_max, ...f.a.max), c && l.uniform4f(
1351
1349
  this.drawLocs.u_geo_bounds,
1352
- l.west,
1353
- l.south,
1354
- l.east,
1355
- l.north
1356
- ), h.uniform1f(this.drawLocs.u_particles_res, B), h.uniform1f(this.drawLocs.u_world_size, n), h.uniform1f(this.drawLocs.u_speed, this.params.speed), O(h, this.colorRampTexture, 2), h.uniform1i(this.drawLocs.u_color_ramp, 2), h.uniform1f(
1350
+ c.west,
1351
+ c.south,
1352
+ c.east,
1353
+ c.north
1354
+ ), l.uniform1f(this.drawLocs.u_particles_res, N), l.uniform1f(this.drawLocs.u_world_size, n), l.uniform1f(this.drawLocs.u_speed, this.params.speed), O(l, this.colorRampTexture, 2), l.uniform1i(this.drawLocs.u_color_ramp, 2), l.uniform1f(
1357
1355
  this.drawLocs.u_particle_contrast,
1358
1356
  this.renderMode === "raster+particles" ? 1 : 0
1359
- ), h.uniform1f(this.drawLocs.u_opacity, this.params.opacity), h.uniform1f(
1357
+ ), l.uniform1f(this.drawLocs.u_opacity, this.params.opacity), l.uniform1f(
1360
1358
  this.drawLocs.u_log_scale,
1361
1359
  this.params.logScale ? 1 : 0
1362
- ), h.uniform1f(this.drawLocs.u_vibrance, this.params.vibrance), h.uniform1f(
1360
+ ), l.uniform1f(this.drawLocs.u_vibrance, this.params.vibrance), l.uniform1f(
1363
1361
  this.drawLocs.u_valid_threshold,
1364
- je
1365
- ), h.uniform1f(this.drawLocs.u_is_globe, d ? 1 : 0), h.uniform3f(
1362
+ Ze
1363
+ ), l.uniform1f(this.drawLocs.u_is_globe, d ? 1 : 0), l.uniform3f(
1366
1364
  this.drawLocs.u_globe_center,
1367
- c[0],
1368
- c[1],
1369
- c[2]
1370
- ), h.uniformMatrix4fv(
1365
+ u[0],
1366
+ u[1],
1367
+ u[2]
1368
+ ), l.uniformMatrix4fv(
1371
1369
  this.drawLocs.u_matrix,
1372
1370
  !1,
1373
- a instanceof Float32Array ? a : new Float32Array(Array.from(a))
1371
+ s instanceof Float32Array ? s : new Float32Array(Array.from(s))
1374
1372
  );
1375
- const R = h.getAttribLocation(this.drawProgram, "a_index");
1376
- h.bindBuffer(h.ARRAY_BUFFER, this.particleIndexBuffer), h.enableVertexAttribArray(R), h.vertexAttribPointer(R, 1, h.FLOAT, !1, 0, 0);
1377
- const k = h.getAttribLocation(this.drawProgram, "a_is_curr");
1378
- h.bindBuffer(h.ARRAY_BUFFER, this.particleIsCurrBuffer), h.enableVertexAttribArray(k), h.vertexAttribPointer(k, 1, h.FLOAT, !1, 0, 0);
1379
- for (const F of o)
1380
- h.uniform1f(this.drawLocs.u_world_offset, F), h.drawArrays(h.LINES, 0, this.numParticles * 2);
1381
- h.disableVertexAttribArray(R), h.disableVertexAttribArray(k), h.disable(h.BLEND);
1373
+ const P = l.getAttribLocation(this.drawProgram, "a_index");
1374
+ l.bindBuffer(l.ARRAY_BUFFER, this.particleIndexBuffer), l.enableVertexAttribArray(P), l.vertexAttribPointer(P, 1, l.FLOAT, !1, 0, 0);
1375
+ const A = l.getAttribLocation(this.drawProgram, "a_is_curr");
1376
+ l.bindBuffer(l.ARRAY_BUFFER, this.particleIsCurrBuffer), l.enableVertexAttribArray(A), l.vertexAttribPointer(A, 1, l.FLOAT, !1, 0, 0);
1377
+ for (const U of o)
1378
+ l.uniform1f(this.drawLocs.u_world_offset, U), l.drawArrays(l.LINES, 0, this.numParticles * 2);
1379
+ l.disableVertexAttribArray(P), l.disableVertexAttribArray(A), l.disable(l.BLEND);
1382
1380
  }
1383
- h.bindFramebuffer(h.FRAMEBUFFER, g), h.viewport(0, 0, this.screenWidth, this.screenHeight);
1384
- const _ = di(this.params.backdrop);
1385
- _[3] > 0 && v(_);
1386
- const S = this.params.glow > 0 ? this.renderGlow(g) : null, E = this.params.colorGrade;
1387
- h.useProgram(this.compositeProgram), O(h, this.screenTextures[1], 0), h.uniform1i(this.compositeLocs.u_screen, 0), O(h, S ?? this.screenTextures[1], 1), h.uniform1i(this.compositeLocs.u_glow_tex, 1), h.uniform1f(
1381
+ l.bindFramebuffer(l.FRAMEBUFFER, p), l.viewport(0, 0, this.screenWidth, this.screenHeight);
1382
+ const _ = ui(this.params.backdrop);
1383
+ _[3] > 0 && g(_);
1384
+ const S = this.params.glow > 0 ? this.renderGlow(p) : null, E = this.params.colorGrade;
1385
+ l.useProgram(this.compositeProgram), O(l, this.screenTextures[1], 0), l.uniform1i(this.compositeLocs.u_screen, 0), O(l, S ?? this.screenTextures[1], 1), l.uniform1i(this.compositeLocs.u_glow_tex, 1), l.uniform1f(
1388
1386
  this.compositeLocs.u_glow,
1389
- S ? Qt * this.params.glow : 0
1390
- ), h.uniform1f(this.compositeLocs.u_grade_on, E.enabled ? 1 : 0), h.uniform4f(this.compositeLocs.u_grade, ...mi(E)), h.enable(h.BLEND), h.blendFunc(h.SRC_ALPHA, h.ONE_MINUS_SRC_ALPHA), this.drawQuad(), h.disable(h.BLEND), y && (this.particleStateTextures.reverse(), this.particleFramebuffers.reverse()), this.screenTextures.reverse(), this.screenFramebuffers.reverse();
1387
+ S ? Zt * this.params.glow : 0
1388
+ ), l.uniform1f(this.compositeLocs.u_grade_on, E.enabled ? 1 : 0), l.uniform4f(this.compositeLocs.u_grade, ...hi(E)), l.enable(l.BLEND), l.blendFunc(l.SRC_ALPHA, l.ONE_MINUS_SRC_ALPHA), this.drawQuad(), l.disable(l.BLEND), y && (this.particleStateTextures.reverse(), this.particleFramebuffers.reverse()), this.screenTextures.reverse(), this.screenFramebuffers.reverse();
1391
1389
  }
1392
1390
  /**
1393
1391
  * Reduce the latest trails into the glow texture (glow.glsl), then rebind
1394
1392
  * `framebuffer` with the full viewport.
1395
1393
  */
1396
1394
  renderGlow(e) {
1397
- const t = this.gl, i = Math.ceil(this.screenWidth / We), a = Math.ceil(this.screenHeight / We);
1398
- return this.glowTexture || (this.glowTexture = Se(t, t.LINEAR, null, i, a), this.glowFramebuffer = J(t, this.glowTexture)), t.bindFramebuffer(t.FRAMEBUFFER, this.glowFramebuffer), t.viewport(0, 0, i, a), t.disable(t.BLEND), t.useProgram(this.glowProgram), O(t, this.screenTextures[1], 0), t.uniform1i(this.glowLocs.u_screen, 0), this.drawQuad(), t.bindFramebuffer(t.FRAMEBUFFER, e), t.viewport(0, 0, this.screenWidth, this.screenHeight), this.glowTexture;
1395
+ const t = this.gl, i = Math.ceil(this.screenWidth / qe), s = Math.ceil(this.screenHeight / qe);
1396
+ return this.glowTexture || (this.glowTexture = Se(t, t.LINEAR, null, i, s), this.glowFramebuffer = J(t, this.glowTexture)), t.bindFramebuffer(t.FRAMEBUFFER, this.glowFramebuffer), t.viewport(0, 0, i, s), t.disable(t.BLEND), t.useProgram(this.glowProgram), O(t, this.screenTextures[1], 0), t.uniform1i(this.glowLocs.u_screen, 0), this.drawQuad(), t.bindFramebuffer(t.FRAMEBUFFER, e), t.viewport(0, 0, this.screenWidth, this.screenHeight), this.glowTexture;
1399
1397
  }
1400
1398
  deleteGlowTarget() {
1401
1399
  this.glowTexture && (this.gl.deleteTexture(this.glowTexture), this.gl.deleteFramebuffer(this.glowFramebuffer), this.glowTexture = null, this.glowFramebuffer = null);
1402
1400
  }
1403
- renderGrid(e, t, i, a, r, n, o, l = 1, d = Me, c) {
1404
- const u = this.gl;
1405
- u.useProgram(this.gridProgram), u.disable(u.DEPTH_TEST), u.disable(u.STENCIL_TEST), u.disable(u.BLEND), this.setGridFieldUniforms(
1401
+ renderGrid(e, t, i, s, r, n, o, c = 1, d = Re, u) {
1402
+ const h = this.gl;
1403
+ h.useProgram(this.gridProgram), h.disable(h.DEPTH_TEST), h.disable(h.STENCIL_TEST), h.disable(h.BLEND), this.setGridFieldUniforms(
1406
1404
  this.gridLocs,
1407
1405
  e,
1408
1406
  t,
1409
1407
  i,
1410
- l,
1408
+ c,
1411
1409
  d,
1412
- c
1413
- ), u.uniformMatrix4fv(
1410
+ u
1411
+ ), h.uniformMatrix4fv(
1414
1412
  this.gridLocs.u_matrix,
1415
1413
  !1,
1416
- a instanceof Float32Array ? a : new Float32Array(Array.from(a))
1417
- ), u.uniform4f(
1414
+ s instanceof Float32Array ? s : new Float32Array(Array.from(s))
1415
+ ), h.uniform4f(
1418
1416
  this.gridLocs.u_geo_bounds,
1419
1417
  o.west,
1420
1418
  o.south,
1421
1419
  o.east,
1422
1420
  o.north
1423
- ), u.uniform1f(this.gridLocs.u_world_size, r), u.enable(u.BLEND), u.blendFunc(u.SRC_ALPHA, u.ONE_MINUS_SRC_ALPHA), this.bindRasterGrid(this.gridProgram);
1424
- for (const f of n)
1425
- u.uniform1f(this.gridLocs.u_world_offset, f), u.drawElements(
1426
- u.TRIANGLES,
1421
+ ), h.uniform1f(this.gridLocs.u_world_size, r), h.enable(h.BLEND), h.blendFunc(h.SRC_ALPHA, h.ONE_MINUS_SRC_ALPHA), this.bindRasterGrid(this.gridProgram);
1422
+ for (const v of n)
1423
+ h.uniform1f(this.gridLocs.u_world_offset, v), h.drawElements(
1424
+ h.TRIANGLES,
1427
1425
  this.rasterGridIndexCount,
1428
- u.UNSIGNED_SHORT,
1426
+ h.UNSIGNED_SHORT,
1429
1427
  0
1430
1428
  );
1431
- this.unbindRasterGrid(this.gridProgram), u.disable(u.BLEND);
1429
+ this.unbindRasterGrid(this.gridProgram), h.disable(h.BLEND);
1432
1430
  }
1433
- renderGridGlobe(e, t, i, a, r, n, o = 1, l = Me, d, c = Kt) {
1434
- const u = this.gl;
1435
- u.useProgram(this.gridGlobeProgram), vt(u, this.gridGlobeLocs, c), u.disable(u.DEPTH_TEST), u.disable(u.STENCIL_TEST), u.disable(u.BLEND), this.setGridFieldUniforms(
1431
+ renderGridGlobe(e, t, i, s, r, n, o = 1, c = Re, d, u = jt) {
1432
+ const h = this.gl;
1433
+ h.useProgram(this.gridGlobeProgram), pt(h, this.gridGlobeLocs, u), h.disable(h.DEPTH_TEST), h.disable(h.STENCIL_TEST), h.disable(h.BLEND), this.setGridFieldUniforms(
1436
1434
  this.gridGlobeLocs,
1437
1435
  e,
1438
1436
  t,
1439
1437
  i,
1440
1438
  o,
1441
- l,
1439
+ c,
1442
1440
  d
1443
- ), u.uniformMatrix4fv(
1441
+ ), h.uniformMatrix4fv(
1444
1442
  this.gridGlobeLocs.u_matrix,
1445
1443
  !1,
1446
- a instanceof Float32Array ? a : new Float32Array(Array.from(a))
1447
- ), u.uniform4f(
1444
+ s instanceof Float32Array ? s : new Float32Array(Array.from(s))
1445
+ ), h.uniform4f(
1448
1446
  this.gridGlobeLocs.u_geo_bounds,
1449
1447
  r.west,
1450
1448
  r.south,
1451
1449
  r.east,
1452
1450
  r.north
1453
- ), u.uniform4f(
1451
+ ), h.uniform4f(
1454
1452
  this.gridGlobeLocs.u_clipping_plane,
1455
1453
  n[0],
1456
1454
  n[1],
1457
1455
  n[2],
1458
1456
  n[3]
1459
- ), u.enable(u.BLEND), u.blendFunc(u.SRC_ALPHA, u.ONE_MINUS_SRC_ALPHA), this.bindRasterGrid(this.gridGlobeProgram), u.drawElements(
1460
- u.TRIANGLES,
1457
+ ), h.enable(h.BLEND), h.blendFunc(h.SRC_ALPHA, h.ONE_MINUS_SRC_ALPHA), this.bindRasterGrid(this.gridGlobeProgram), h.drawElements(
1458
+ h.TRIANGLES,
1461
1459
  this.rasterGridIndexCount,
1462
- u.UNSIGNED_SHORT,
1460
+ h.UNSIGNED_SHORT,
1463
1461
  0
1464
- ), this.unbindRasterGrid(this.gridGlobeProgram), u.disable(u.BLEND);
1462
+ ), this.unbindRasterGrid(this.gridGlobeProgram), h.disable(h.BLEND);
1465
1463
  }
1466
- setGridFieldUniforms(e, t, i, a, r, n, o) {
1467
- const l = this.gl, d = { unit: t, min: i, max: a }, c = o ?? { a: d, b: d, mix: 0 };
1468
- Te(l, e, c), l.uniform1i(e.u_field, c.a.unit), l.uniform4f(e.u_solid, ...n), O(l, this.colorRampTexture, 2), l.uniform1i(e.u_color_ramp, 2);
1469
- const u = Math.sqrt(
1470
- Math.max(Math.abs(i[0]), Math.abs(a[0])) ** 2 + Math.max(Math.abs(i[1]), Math.abs(a[1])) ** 2
1464
+ setGridFieldUniforms(e, t, i, s, r, n, o) {
1465
+ const c = this.gl, d = { unit: t, min: i, max: s }, u = o ?? { a: d, b: d, mix: 0 };
1466
+ Te(c, e, u), c.uniform1i(e.u_field, u.a.unit), c.uniform4f(e.u_solid, ...n), O(c, this.colorRampTexture, 2), c.uniform1i(e.u_color_ramp, 2);
1467
+ const h = Math.sqrt(
1468
+ Math.max(Math.abs(i[0]), Math.abs(s[0])) ** 2 + Math.max(Math.abs(i[1]), Math.abs(s[1])) ** 2
1471
1469
  );
1472
- l.uniform1f(e.u_field_min, 0), l.uniform1f(e.u_field_max, u > 0 ? u : 1), l.uniform1f(e.u_u_min, c.a.min[0]), l.uniform1f(e.u_u_max, c.a.max[0]), l.uniform1f(e.u_v_min, c.a.min[1]), l.uniform1f(e.u_v_max, c.a.max[1]), l.uniform1f(e.u_opacity, this.params.opacity * r), l.uniform1f(e.u_log_scale, this.params.logScale ? 1 : 0), l.uniform1f(e.u_vibrance, this.params.vibrance), l.uniform1f(e.u_scalar_mode, this.params.scalarMode ? 1 : 0);
1470
+ c.uniform1f(e.u_field_min, 0), c.uniform1f(e.u_field_max, h > 0 ? h : 1), c.uniform1f(e.u_u_min, u.a.min[0]), c.uniform1f(e.u_u_max, u.a.max[0]), c.uniform1f(e.u_v_min, u.a.min[1]), c.uniform1f(e.u_v_max, u.a.max[1]), c.uniform1f(e.u_opacity, this.params.opacity * r), c.uniform1f(e.u_log_scale, this.params.logScale ? 1 : 0), c.uniform1f(e.u_vibrance, this.params.vibrance), c.uniform1f(e.u_scalar_mode, this.params.scalarMode ? 1 : 0);
1473
1471
  }
1474
1472
  bindRasterGrid(e) {
1475
1473
  const t = this.gl, i = t.getAttribLocation(e, "a_grid_uv");
@@ -1535,11 +1533,11 @@ class Rt {
1535
1533
  }
1536
1534
  /** Partial values take the vibrant preset; see resolveColorGrade. */
1537
1535
  setColorGrade(e) {
1538
- this.params.colorGrade = bt(e);
1536
+ this.params.colorGrade = _t(e);
1539
1537
  }
1540
1538
  /** Missing values take the defaults; see resolveBackdrop. */
1541
1539
  setBackdrop(e) {
1542
- this.params.backdrop = St(e);
1540
+ this.params.backdrop = xt(e);
1543
1541
  }
1544
1542
  /** Halo strength, clamped to [0, 1]; 0 frees the glow texture. */
1545
1543
  setGlow(e) {
@@ -1556,9 +1554,9 @@ class Rt {
1556
1554
  * or map move. Randomises the full state texture and clears trail FBOs.
1557
1555
  */
1558
1556
  resetParticles() {
1559
- const e = this.gl, t = B, i = this.makeStateData();
1560
- for (const a of this.particleStateTextures)
1561
- e.bindTexture(e.TEXTURE_2D, a), e.texImage2D(
1557
+ const e = this.gl, t = N, i = this.makeStateData();
1558
+ for (const s of this.particleStateTextures)
1559
+ e.bindTexture(e.TEXTURE_2D, s), e.texImage2D(
1562
1560
  e.TEXTURE_2D,
1563
1561
  0,
1564
1562
  this.stateFormat.internalFormat,
@@ -1587,7 +1585,7 @@ class Rt {
1587
1585
  return {
1588
1586
  particleState: this.stateFormat?.kind ?? "rgba8-packed",
1589
1587
  particleStateMode: this.params.particleState,
1590
- particleStateResolution: B,
1588
+ particleStateResolution: N,
1591
1589
  maxParticles: H,
1592
1590
  activeParticles: this.numParticles,
1593
1591
  rgba8MaxParticleZoom: this.params.rgba8MaxParticleZoom,
@@ -1624,7 +1622,7 @@ class Rt {
1624
1622
  e.deleteBuffer(this.quadBuffer), e.deleteBuffer(this.particleIndexBuffer), e.deleteBuffer(this.particleIsCurrBuffer), e.deleteTexture(this.colorRampTexture);
1625
1623
  }
1626
1624
  }
1627
- class Pt {
1625
+ class Rt {
1628
1626
  constructor() {
1629
1627
  this.gl = null, this.texture = null, this.width = 0, this.height = 0, this.uMin = 0, this.uMax = 0, this.vMin = 0, this.vMax = 0, this.geoBounds = { west: -180, south: -90, east: 180, north: 90 }, this.scalarMode = !1, this.linearFilter = !0;
1630
1628
  }
@@ -1638,34 +1636,34 @@ class Pt {
1638
1636
  * fields may use a fixed color domain so fragments never decode physical values.
1639
1637
  */
1640
1638
  update(e, t = null) {
1641
- const i = this.gl, { u: a, v: r, width: n, height: o, uMin: l, uMax: d, vMin: c, vMax: u } = e;
1642
- this.scalarMode = e.scalarMode ?? !1, this.width = n, this.height = o, this.uMin = l, this.uMax = d, this.vMin = c, this.vMax = u, this.geoBounds = e.bounds;
1643
- const f = this.scalarMode && t ? t[0] : l, p = (this.scalarMode && t ? t[1] : d) - f || 1, h = u - c || 1, g = new Uint8Array(n * o * 4);
1639
+ const i = this.gl, { u: s, v: r, width: n, height: o, uMin: c, uMax: d, vMin: u, vMax: h } = e;
1640
+ this.scalarMode = e.scalarMode ?? !1, this.width = n, this.height = o, this.uMin = c, this.uMax = d, this.vMin = u, this.vMax = h, this.geoBounds = e.bounds;
1641
+ const v = this.scalarMode && t ? t[0] : c, f = (this.scalarMode && t ? t[1] : d) - v || 1, l = h - u || 1, p = new Uint8Array(n * o * 4);
1644
1642
  for (let y = 0; y < n * o; y++) {
1645
- const v = a[y], _ = r[y];
1646
- this.scalarMode ? isNaN(v) ? (g[y * 4] = 0, g[y * 4 + 1] = 0, g[y * 4 + 2] = 0, g[y * 4 + 3] = 0) : (g[y * 4] = Math.round(
1647
- Math.max(0, Math.min(1, (v - f) / p)) * 255
1648
- ), g[y * 4 + 1] = 128, g[y * 4 + 2] = 0, g[y * 4 + 3] = 255) : isNaN(v) || isNaN(_) ? (g[y * 4] = 0, g[y * 4 + 1] = 0, g[y * 4 + 2] = 0, g[y * 4 + 3] = 0) : (g[y * 4] = Math.round(
1649
- Math.max(0, Math.min(1, (v - l) / p)) * 255
1650
- ), g[y * 4 + 1] = Math.round(
1651
- Math.max(0, Math.min(1, (_ - c) / h)) * 255
1652
- ), g[y * 4 + 2] = 0, g[y * 4 + 3] = 255);
1643
+ const g = s[y], _ = r[y];
1644
+ this.scalarMode ? isNaN(g) ? (p[y * 4] = 0, p[y * 4 + 1] = 0, p[y * 4 + 2] = 0, p[y * 4 + 3] = 0) : (p[y * 4] = Math.round(
1645
+ Math.max(0, Math.min(1, (g - v) / f)) * 255
1646
+ ), p[y * 4 + 1] = 128, p[y * 4 + 2] = 0, p[y * 4 + 3] = 255) : isNaN(g) || isNaN(_) ? (p[y * 4] = 0, p[y * 4 + 1] = 0, p[y * 4 + 2] = 0, p[y * 4 + 3] = 0) : (p[y * 4] = Math.round(
1647
+ Math.max(0, Math.min(1, (g - c) / f)) * 255
1648
+ ), p[y * 4 + 1] = Math.round(
1649
+ Math.max(0, Math.min(1, (_ - u) / l)) * 255
1650
+ ), p[y * 4 + 2] = 0, p[y * 4 + 3] = 255);
1653
1651
  }
1654
1652
  if (e.latDescending) {
1655
- const y = n * 4, v = new Uint8Array(y);
1653
+ const y = n * 4, g = new Uint8Array(y);
1656
1654
  for (let _ = 0, S = o - 1; _ < S; _++, S--)
1657
- v.set(g.subarray(_ * y, (_ + 1) * y)), g.copyWithin(_ * y, S * y, (S + 1) * y), g.set(v, S * y);
1655
+ g.set(p.subarray(_ * y, (_ + 1) * y)), p.copyWithin(_ * y, S * y, (S + 1) * y), p.set(g, S * y);
1658
1656
  }
1659
1657
  let x = 0, T = 0;
1660
1658
  for (let y = 0; y < n * o; y++)
1661
- g[y * 4 + 3] === 255 ? x++ : T++;
1659
+ p[y * 4 + 3] === 255 ? x++ : T++;
1662
1660
  console.log(
1663
1661
  `[zartigl] Velocity texture: ${n}x${o}, valid=${x} (${(100 * x / (n * o)).toFixed(
1664
1662
  1
1665
- )}%), nodata=${T}, uRange=[${l.toFixed(4)}, ${d.toFixed(4)}], vRange=[${c.toFixed(4)}, ${u.toFixed(4)}]`
1663
+ )}%), nodata=${T}, uRange=[${c.toFixed(4)}, ${d.toFixed(4)}], vRange=[${u.toFixed(4)}, ${h.toFixed(4)}]`
1666
1664
  ), this.texture || (this.texture = i.createTexture());
1667
- const M = this.linearFilter ? i.LINEAR : i.NEAREST;
1668
- i.bindTexture(i.TEXTURE_2D, this.texture), i.texParameteri(i.TEXTURE_2D, i.TEXTURE_WRAP_S, i.CLAMP_TO_EDGE), i.texParameteri(i.TEXTURE_2D, i.TEXTURE_WRAP_T, i.CLAMP_TO_EDGE), i.texParameteri(i.TEXTURE_2D, i.TEXTURE_MIN_FILTER, M), i.texParameteri(i.TEXTURE_2D, i.TEXTURE_MAG_FILTER, M), i.pixelStorei(i.UNPACK_ALIGNMENT, 1), i.texImage2D(
1665
+ const R = this.linearFilter ? i.LINEAR : i.NEAREST;
1666
+ i.bindTexture(i.TEXTURE_2D, this.texture), i.texParameteri(i.TEXTURE_2D, i.TEXTURE_WRAP_S, i.CLAMP_TO_EDGE), i.texParameteri(i.TEXTURE_2D, i.TEXTURE_WRAP_T, i.CLAMP_TO_EDGE), i.texParameteri(i.TEXTURE_2D, i.TEXTURE_MIN_FILTER, R), i.texParameteri(i.TEXTURE_2D, i.TEXTURE_MAG_FILTER, R), i.pixelStorei(i.UNPACK_ALIGNMENT, 1), i.texImage2D(
1669
1667
  i.TEXTURE_2D,
1670
1668
  0,
1671
1669
  i.RGBA,
@@ -1674,7 +1672,7 @@ class Pt {
1674
1672
  0,
1675
1673
  i.RGBA,
1676
1674
  i.UNSIGNED_BYTE,
1677
- g
1675
+ p
1678
1676
  ), i.bindTexture(i.TEXTURE_2D, null);
1679
1677
  }
1680
1678
  /** Switch between bilinear (particles) and nearest-neighbour (raster) sampling. */
@@ -1702,636 +1700,67 @@ class Pt {
1702
1700
  this.gl && this.texture && (this.gl.deleteTexture(this.texture), this.texture = null);
1703
1701
  }
1704
1702
  }
1705
- function Et(s, e, t, i, a, r, n) {
1706
- const o = new Float32Array(t * i).fill(NaN), l = new Float32Array(t * i).fill(NaN);
1707
- for (const m of s)
1708
- for (let p = 0; p < m.latSize; p++)
1709
- for (let h = 0; h < m.lonSize; h++) {
1710
- const g = p * m.lonChunkSize + h, x = (m.latStart + p) * i + (m.lonStart + h);
1711
- o[x] = m.data[g];
1703
+ function Mt(a, e, t, i, s, r, n) {
1704
+ const o = new Float32Array(t * i).fill(NaN), c = new Float32Array(t * i).fill(NaN);
1705
+ for (const m of a)
1706
+ for (let f = 0; f < m.latSize; f++)
1707
+ for (let l = 0; l < m.lonSize; l++) {
1708
+ const p = f * m.lonChunkSize + l, x = (m.latStart + f) * i + (m.lonStart + l);
1709
+ o[x] = m.data[p];
1712
1710
  }
1713
1711
  for (const m of e)
1714
- for (let p = 0; p < m.latSize; p++)
1715
- for (let h = 0; h < m.lonSize; h++) {
1716
- const g = p * m.lonChunkSize + h, x = (m.latStart + p) * i + (m.lonStart + h);
1717
- l[x] = m.data[g];
1712
+ for (let f = 0; f < m.latSize; f++)
1713
+ for (let l = 0; l < m.lonSize; l++) {
1714
+ const p = f * m.lonChunkSize + l, x = (m.latStart + f) * i + (m.lonStart + l);
1715
+ c[x] = m.data[p];
1718
1716
  }
1719
- let d = 1 / 0, c = -1 / 0, u = 1 / 0, f = -1 / 0;
1717
+ let d = 1 / 0, u = -1 / 0, h = 1 / 0, v = -1 / 0;
1720
1718
  for (let m = 0; m < o.length; m++)
1721
- isNaN(o[m]) || (o[m] < d && (d = o[m]), o[m] > c && (c = o[m])), isNaN(l[m]) || (l[m] < u && (u = l[m]), l[m] > f && (f = l[m]));
1722
- return isFinite(d) || (d = -1), isFinite(c) || (c = 1), isFinite(u) || (u = -1), isFinite(f) || (f = 1), {
1719
+ isNaN(o[m]) || (o[m] < d && (d = o[m]), o[m] > u && (u = o[m])), isNaN(c[m]) || (c[m] < h && (h = c[m]), c[m] > v && (v = c[m]));
1720
+ return isFinite(d) || (d = -1), isFinite(u) || (u = 1), isFinite(h) || (h = -1), isFinite(v) || (v = 1), {
1723
1721
  u: o,
1724
- v: l,
1722
+ v: c,
1725
1723
  width: i,
1726
1724
  height: t,
1727
1725
  uMin: d,
1728
- uMax: c,
1729
- vMin: u,
1730
- vMax: f,
1731
- bounds: a ?? { west: -180, south: -90, east: 180, north: 90 },
1726
+ uMax: u,
1727
+ vMin: h,
1728
+ vMax: v,
1729
+ bounds: s ?? { west: -180, south: -90, east: 180, north: 90 },
1732
1730
  latDescending: r,
1733
1731
  scalarMode: n
1734
1732
  };
1735
1733
  }
1736
- const Re = [
1737
- "depth",
1738
- "elevation",
1739
- "level",
1740
- "altitude",
1741
- "pressure_level"
1742
- ];
1743
- class Qe extends Error {
1744
- constructor(e, t) {
1745
- super(`Chunk fetch failed: ${e} ${t}`), this.name = "ZarrChunkFetchError", this.status = e, this.url = t;
1746
- }
1747
- }
1748
- class _e {
1749
- constructor(e, t = 200) {
1750
- this.meta = null, this.coords = null, this.initPromise = null, this.verticalName = "depth", this.timeUnits = "", this.timeCalendar = "standard", this.cache = /* @__PURE__ */ new Map(), this.abortControllers = /* @__PURE__ */ new Map(), this.bloscCodecCache = /* @__PURE__ */ new Map(), this.root = e.replace(/\/$/, ""), this.maxCacheSize = t;
1751
- }
1752
- async init() {
1753
- if (!this.coords) {
1754
- if (this.initPromise)
1755
- return this.initPromise;
1756
- this.initPromise = (async () => {
1757
- const e = await fetch(`${this.root}/.zmetadata`);
1758
- if (!e.ok)
1759
- throw new Error(`Failed to fetch .zmetadata: ${e.status}`);
1760
- this.meta = await e.json(), await this.loadCoordinates();
1761
- })();
1762
- try {
1763
- await this.initPromise;
1764
- } catch (e) {
1765
- throw this.meta = null, this.coords = null, e;
1766
- } finally {
1767
- this.initPromise = null;
1768
- }
1769
- }
1770
- }
1771
- getArrayMeta(e) {
1772
- const t = `${e}/.zarray`, i = this.meta.metadata[t];
1773
- if (!i || !("dtype" in i))
1774
- throw new Error(`No .zarray for ${e}`);
1775
- return i;
1776
- }
1777
- getAttrs(e) {
1778
- const t = `${e}/.zattrs`;
1779
- return this.meta.metadata[t] ?? {};
1780
- }
1781
- getDimensionSeparator(e) {
1782
- return this.getArrayMeta(e).dimension_separator ?? ".";
1783
- }
1784
- getShape(e) {
1785
- return this.getArrayMeta(e).shape;
1786
- }
1787
- getChunkShape(e) {
1788
- return this.getArrayMeta(e).chunks;
1789
- }
1790
- getCoords() {
1791
- if (!this.coords)
1792
- throw new Error("Call init() first");
1793
- return this.coords;
1794
- }
1795
- getTimeDimension() {
1796
- const e = this.getCoords().time, t = e.length, i = Array.from(e, (o) => this.zarrTimeToMs(o));
1797
- let a = t ? i[0] : NaN, r = a;
1798
- for (let o = 1; o < i.length; o++)
1799
- a = Math.min(a, i[o]), r = Math.max(r, i[o]);
1800
- const n = Bi(i);
1801
- return {
1802
- min: a,
1803
- max: r,
1804
- step: n,
1805
- size: t,
1806
- units: this.timeUnits,
1807
- values: i
1808
- };
1809
- }
1810
- getVerticalDimension(e) {
1811
- if (!this.verticalName || e && !this.getDimensions(e).includes(this.verticalName))
1812
- return;
1813
- const t = this.getAttrs(this.verticalName), i = typeof t.units == "string" ? t.units : void 0, a = typeof t.standard_name == "string" ? t.standard_name : "", r = i?.toLowerCase() ?? "", n = a.includes("pressure") || this.verticalName.includes("pressure") || /(^|\s)(pa|hpa|bar|dbar)($|\s)/i.test(r) ? "pressure" : a.includes("elevation") || this.verticalName === "elevation" || t.positive === "up" ? "elevation" : "depth";
1814
- return {
1815
- name: this.verticalName,
1816
- label: n,
1817
- units: i,
1818
- values: Array.from(this.getCoords().vertical)
1819
- };
1820
- }
1821
- hasVariable(e) {
1822
- const t = this.meta?.metadata[`${e}/.zarray`];
1823
- return !!(t && "dtype" in t);
1824
- }
1825
- getVariableAttrs(e) {
1826
- if (!this.meta)
1827
- throw new Error("Call init() first");
1828
- if (!this.hasVariable(e))
1829
- throw new Error(`No .zarray for ${e}`);
1830
- return { ...this.getAttrs(e) };
1831
- }
1832
- getDimensions(e) {
1833
- return this.getAttrs(e)._ARRAY_DIMENSIONS ?? ["time", "latitude", "longitude"];
1834
- }
1835
- findNearestIndex(e, t) {
1836
- let i = 0, a = Math.abs(e[0] - t);
1837
- for (let r = 1; r < e.length; r++) {
1838
- const n = Math.abs(e[r] - t);
1839
- n < a && (a = n, i = r);
1840
- }
1841
- return i;
1842
- }
1843
- findTimeIndex(e) {
1844
- const t = this.getCoords();
1845
- let i;
1846
- return typeof e == "string" ? i = new Date(e).getTime() : i = e, this.findNearestIndex(t.time, this.msToZarrTime(i));
1847
- }
1848
- /**
1849
- * Convert a Unix-ms timestamp to the native time units used by this zarr
1850
- * (read from the time variable's .zattrs "units" field).
1851
- * Unsupported units are rejected during initialization rather than guessed.
1852
- */
1853
- msToZarrTime(e) {
1854
- const { refMs: t, multiplier: i } = this.parseTimeEncoding();
1855
- return (e - t) / i;
1856
- }
1857
- zarrTimeToMs(e) {
1858
- const { refMs: t, multiplier: i } = this.parseTimeEncoding();
1859
- return t + e * i;
1860
- }
1861
- parseTimeEncoding() {
1862
- const e = this.timeCalendar.toLowerCase();
1863
- if (!["standard", "gregorian", "proleptic_gregorian"].includes(e))
1864
- throw new Error(`Unsupported Zarr time calendar: ${this.timeCalendar}`);
1865
- const t = this.timeUnits.match(
1866
- /^(milliseconds?|seconds?|minutes?|hours?|days?)\s+since\s+(.+)$/i
1867
- );
1868
- if (!t)
1869
- throw new Error(
1870
- `Unsupported Zarr time units: ${this.timeUnits || "<missing>"}`
1871
- );
1872
- const i = Gi(t[2]);
1873
- if (!Number.isFinite(i))
1874
- throw new Error(`Invalid Zarr time epoch: ${t[2]}`);
1875
- const a = t[1].toLowerCase(), r = a.startsWith("ms") || a.startsWith("milli") ? 1 : a.startsWith("s") ? 1e3 : a.startsWith("min") ? 6e4 : a.startsWith("h") ? 36e5 : 864e5;
1876
- return { refMs: i, multiplier: r };
1877
- }
1878
- findNearestLongitudeIndex(e) {
1879
- const t = this.getCoords().longitude, i = t[0], a = t[t.length - 1];
1880
- let r = e;
1881
- return i >= 0 && a > 180 ? r = (e % 360 + 360) % 360 : r = ((e + 180) % 360 + 360) % 360 - 180, this.findNearestIndex(t, r);
1882
- }
1883
- async sampleVariableAt(e, t) {
1884
- const i = this.getDimensions(e), a = this.getChunkShape(e), r = this.getShape(e), n = new Array(i.length).fill(0), o = new Array(i.length).fill(0);
1885
- for (let c = 0; c < i.length; c++) {
1886
- const u = i[c];
1887
- let f = 0;
1888
- u === "time" ? f = t.timeIdx : u === "latitude" ? f = t.latIdx : u === "longitude" ? f = t.lonIdx : (u === this.verticalName || Re.includes(u)) && (f = t.depthIdx), f = Math.max(0, Math.min(r[c] - 1, f)), n[c] = Math.floor(f / a[c]), o[c] = f - n[c] * a[c];
1889
- }
1890
- let l;
1891
- try {
1892
- l = await this.fetchChunk(e, n);
1893
- } catch (c) {
1894
- if (c instanceof Qe && (c.status === 403 || c.status === 404))
1895
- return NaN;
1896
- throw c;
1897
- }
1898
- const d = this.getFlatOffset(e, o);
1899
- return d < l.length ? l[d] : NaN;
1900
- }
1901
- getFlatOffset(e, t) {
1902
- const i = this.getArrayMeta(e), a = i.chunks;
1903
- if (i.order === "F") {
1904
- let n = 0, o = 1;
1905
- for (let l = 0; l < t.length; l++)
1906
- n += t[l] * o, o *= a[l];
1907
- return n;
1908
- }
1909
- let r = 0;
1910
- for (let n = 0; n < t.length; n++)
1911
- r = r * a[n] + t[n];
1912
- return r;
1913
- }
1914
- findDepthIndex(e) {
1915
- return this.findNearestIndex(this.getCoords().vertical, e);
1916
- }
1917
- async sampleTimeSeries(e) {
1918
- await this.init();
1919
- const t = this.getCoords(), i = this.findNearestLongitudeIndex(e.longitude), a = this.findNearestIndex(t.latitude, e.latitude), r = this.findDepthIndex(e.depth ?? 0), n = Math.max(0, e.timeStartIndex ?? 0), o = Math.min(
1920
- t.time.length - 1,
1921
- e.timeEndIndex ?? t.time.length - 1
1922
- ), l = Math.max(1, Math.floor(e.stride ?? 1)), d = Math.max(
1923
- 0,
1924
- Math.floor(e.stopAfterMissingSamples ?? 0)
1925
- );
1926
- let c = 0;
1927
- const u = [];
1928
- for (let f = n; f <= o; f += l) {
1929
- const m = {};
1930
- for (const g of e.variables)
1931
- m[g] = await this.sampleVariableAt(g, {
1932
- timeIdx: f,
1933
- depthIdx: r,
1934
- latIdx: a,
1935
- lonIdx: i
1936
- });
1937
- const p = this.zarrTimeToMs(t.time[f]);
1938
- if (u.push({
1939
- axisValue: p,
1940
- time: p,
1941
- depth: t.vertical[r],
1942
- values: m
1943
- }), c = e.variables.every(
1944
- (g) => !Number.isFinite(m[g])
1945
- ) ? c + 1 : 0, d > 0 && c >= d)
1946
- break;
1947
- }
1948
- return {
1949
- longitude: t.longitude[i],
1950
- latitude: t.latitude[a],
1951
- depth: t.vertical[r],
1952
- points: u
1953
- };
1954
- }
1955
- async sampleVerticalProfile(e) {
1956
- await this.init();
1957
- const t = this.getCoords(), i = this.findNearestLongitudeIndex(e.longitude), a = this.findNearestIndex(t.latitude, e.latitude), r = this.findTimeIndex(e.time), n = Math.max(
1958
- 0,
1959
- Math.floor(e.stopAfterMissingSamples ?? 0)
1960
- );
1961
- let o = 0;
1962
- const l = [];
1963
- let d = Array.from(
1964
- { length: t.vertical.length },
1965
- (f, m) => m
1966
- ).sort(
1967
- (f, m) => Math.abs(t.vertical[f]) - Math.abs(t.vertical[m])
1968
- );
1969
- const c = Math.max(
1970
- 1,
1971
- Math.floor(e.maxDepths ?? d.length)
1972
- ), u = Math.max(
1973
- 1,
1974
- Math.floor(e.stride ?? Math.ceil(d.length / c))
1975
- );
1976
- d = d.filter((f, m) => m % u === 0).slice(0, c);
1977
- for (const f of d) {
1978
- const m = {};
1979
- for (const g of e.variables)
1980
- m[g] = await this.sampleVariableAt(g, {
1981
- timeIdx: r,
1982
- depthIdx: f,
1983
- latIdx: a,
1984
- lonIdx: i
1985
- });
1986
- const p = t.vertical[f];
1987
- if (l.push({
1988
- axisValue: p,
1989
- time: this.zarrTimeToMs(t.time[r]),
1990
- depth: p,
1991
- values: m
1992
- }), o = e.variables.every(
1993
- (g) => !Number.isFinite(m[g])
1994
- ) ? o + 1 : 0, n > 0 && o >= n)
1995
- break;
1996
- }
1997
- return {
1998
- longitude: t.longitude[i],
1999
- latitude: t.latitude[a],
2000
- time: this.zarrTimeToMs(t.time[r]),
2001
- points: l
2002
- };
2003
- }
2004
- /** Return the actual name of the vertical dimension ("depth" or "elevation"). */
2005
- getVerticalDimName() {
2006
- return this.verticalName;
2007
- }
2008
- /**
2009
- * Get chunk indices that intersect a geographic bounding box.
2010
- */
2011
- getChunksForBounds(e, t, i, a) {
2012
- const r = this.getCoords(), n = this.getChunkShape(e), o = this.getDimensions(e), l = o.indexOf("latitude"), d = o.indexOf("longitude"), c = n[l], u = n[d], f = r.latitude, m = r.longitude, p = this.findNearestIndex(f, a.north), h = this.findNearestIndex(f, a.south), g = this.findNearestIndex(m, a.west), x = this.findNearestIndex(m, a.east), T = Math.min(p, h), M = Math.max(p, h), y = Math.min(g, x), v = Math.max(g, x), _ = Math.floor(T / c), S = Math.floor(M / c), E = Math.floor(y / u), R = Math.floor(v / u), k = this.getShape(e), F = k[l], L = k[d], D = [];
2013
- for (let b = _; b <= S; b++)
2014
- for (let A = E; A <= R; A++) {
2015
- const N = b * c, C = A * u, I = Math.min(c, F - N), w = Math.min(u, L - C);
2016
- D.push({
2017
- timeIdx: t,
2018
- depthIdx: i,
2019
- latIdx: b,
2020
- lonIdx: A,
2021
- latRange: [f[N], f[N + I - 1]],
2022
- lonRange: [m[C], m[C + w - 1]],
2023
- latSize: I,
2024
- lonSize: w
2025
- });
2026
- }
2027
- return D;
2028
- }
2029
- async fetchChunk(e, t) {
2030
- return (await this.fetchChunkResult(e, t)).data;
2031
- }
2032
- /**
2033
- * Fetch one latitude/longitude chunk and extract the requested time/vertical
2034
- * plane from it. Logical coordinate indices are converted to physical Zarr
2035
- * chunk indices before fetching.
2036
- */
2037
- async fetchSpatialChunkResult(e, t) {
2038
- const i = this.getDimensions(e), a = this.getChunkShape(e), r = i.indexOf("latitude"), n = i.indexOf("longitude");
2039
- if (r < 0 || n < 0)
2040
- throw new Error(
2041
- `Variable ${e} must have latitude and longitude dimensions`
2042
- );
2043
- const o = new Array(i.length).fill(0), l = new Array(i.length).fill(0);
2044
- for (let m = 0; m < i.length; m++) {
2045
- const p = i[m];
2046
- let h = 0;
2047
- if (p === "time")
2048
- h = t.timeIndex;
2049
- else if (p === this.verticalName || Re.includes(p))
2050
- h = t.verticalIndex;
2051
- else if (p === "latitude") {
2052
- o[m] = t.latitudeChunkIndex;
2053
- continue;
2054
- } else if (p === "longitude") {
2055
- o[m] = t.longitudeChunkIndex;
2056
- continue;
2057
- }
2058
- o[m] = Math.floor(h / a[m]), l[m] = h % a[m];
2059
- }
2060
- const d = await this.fetchChunkResult(e, o), c = a[r], u = a[n], f = new Float32Array(c * u);
2061
- f.fill(NaN);
2062
- for (let m = 0; m < c; m++) {
2063
- l[r] = m;
2064
- for (let p = 0; p < u; p++) {
2065
- l[n] = p;
2066
- const h = this.getFlatOffset(e, l);
2067
- h < d.data.length && (f[m * u + p] = d.data[h]);
2068
- }
2069
- }
2070
- return { ...d, data: f };
2071
- }
2072
- async fetchChunkResult(e, t) {
2073
- const i = this.getDimensionSeparator(e), a = t.join(i), r = `${e}/${a}`, n = `${this.root}/${e}/${a}`;
2074
- if (this.cache.has(r))
2075
- return { data: this.cache.get(r), missing: !1, url: n };
2076
- this.abortControllers.get(r)?.abort();
2077
- const o = new AbortController();
2078
- this.abortControllers.set(r, o);
2079
- const l = this.getArrayMeta(e);
2080
- try {
2081
- const d = await fetch(n, { signal: o.signal });
2082
- if (!d.ok) {
2083
- if (d.status === 403 || d.status === 404)
2084
- return {
2085
- data: zi(l),
2086
- missing: !0,
2087
- status: d.status,
2088
- url: n
2089
- };
2090
- throw new Qe(d.status, n);
2091
- }
2092
- const c = new Uint8Array(await d.arrayBuffer()), u = Ni(
2093
- await this.decompress(c, l, e)
2094
- );
2095
- return this.cacheChunk(r, u), { data: u, missing: !1, url: n };
2096
- } finally {
2097
- this.abortControllers.get(r) === o && this.abortControllers.delete(r);
2098
- }
2099
- }
2100
- cancelAll() {
2101
- for (const e of this.abortControllers.values())
2102
- e.abort();
2103
- this.abortControllers.clear();
2104
- }
2105
- cacheChunk(e, t) {
2106
- if (this.cache.size >= this.maxCacheSize) {
2107
- const i = this.cache.keys().next().value;
2108
- i !== void 0 && this.cache.delete(i);
2109
- }
2110
- this.cache.set(e, t);
2111
- }
2112
- getBloscCodec(e) {
2113
- const t = e.compressor, i = `${t.cname ?? "lz4"}-${t.clevel ?? 5}-${t.shuffle ?? 1}-${t.blocksize ?? 0}`;
2114
- let a = this.bloscCodecCache.get(i);
2115
- return a || (a = vi.fromConfig({
2116
- id: "blosc",
2117
- cname: t.cname ?? "lz4",
2118
- clevel: t.clevel ?? 5,
2119
- shuffle: t.shuffle ?? 1,
2120
- blocksize: t.blocksize ?? 0
2121
- }), this.bloscCodecCache.set(i, a)), a;
2122
- }
2123
- async decompress(e, t, i) {
2124
- let a;
2125
- if (t.compressor)
2126
- switch (t.compressor.id) {
2127
- case "zlib":
2128
- case "gzip":
2129
- a = gi(e);
2130
- break;
2131
- case "blosc": {
2132
- a = await this.getBloscCodec(t).decode(e);
2133
- break;
2134
- }
2135
- default:
2136
- throw new Error(`Unsupported compressor: ${t.compressor.id}`);
2137
- }
2138
- else
2139
- a = e;
2140
- let r;
2141
- const n = t.dtype;
2142
- if (n === "<f4" || n === "|f4")
2143
- r = new Float32Array(
2144
- a.buffer,
2145
- a.byteOffset,
2146
- a.byteLength / 4
2147
- );
2148
- else if (n === "<f8" || n === "|f8")
2149
- r = new Float64Array(
2150
- a.buffer,
2151
- a.byteOffset,
2152
- a.byteLength / 8
2153
- );
2154
- else if (n === "<i2" || n === "|i2") {
2155
- const l = new Int16Array(
2156
- a.buffer,
2157
- a.byteOffset,
2158
- a.byteLength / 2
2159
- );
2160
- r = Float32Array.from(l);
2161
- } else if (n === "<i4" || n === "|i4") {
2162
- const l = new Int32Array(
2163
- a.buffer,
2164
- a.byteOffset,
2165
- a.byteLength / 4
2166
- );
2167
- r = Float32Array.from(l);
2168
- } else if (n === "<i8" || n === "|i8") {
2169
- const l = new DataView(
2170
- a.buffer,
2171
- a.byteOffset,
2172
- a.byteLength
2173
- ), d = a.byteLength / 8;
2174
- r = new Float64Array(d);
2175
- for (let c = 0; c < d; c++)
2176
- r[c] = Number(l.getBigInt64(c * 8, !0));
2177
- } else
2178
- throw new Error(`Unsupported dtype: ${n}`);
2179
- const o = t.fill_value;
2180
- if (o != null && typeof o == "number" && !isNaN(o))
2181
- for (let l = 0; l < r.length; l++)
2182
- r[l] === o && (r[l] = NaN);
2183
- if (i) {
2184
- const l = this.getAttrs(i), d = l.scale_factor, c = l.add_offset;
2185
- if (d != null || c != null) {
2186
- const u = d ?? 1, f = c ?? 0;
2187
- for (let m = 0; m < r.length; m++)
2188
- isNaN(r[m]) || (r[m] = r[m] * u + f);
2189
- }
2190
- }
2191
- return r;
2192
- }
2193
- async loadCoordinates() {
2194
- const e = async (l) => {
2195
- const d = this.getArrayMeta(l), c = d.shape[0], u = Math.ceil(c / d.chunks[0]), f = [];
2196
- for (let g = 0; g < u; g++) {
2197
- const x = `${this.root}/${l}/${g}`, T = await fetch(x);
2198
- if (!T.ok)
2199
- throw new Error(`Failed to fetch coord ${l}/${g}`);
2200
- const M = new Uint8Array(await T.arrayBuffer());
2201
- f.push(await this.decompress(M, d));
2202
- }
2203
- if (f.length === 1)
2204
- return f[0].length > c ? f[0].subarray(0, c) : f[0];
2205
- const m = f.some((g) => g instanceof Float64Array) ? Float64Array : Float32Array, p = new m(c);
2206
- let h = 0;
2207
- for (const g of f) {
2208
- const x = Math.min(g.length, c - h);
2209
- if (p.set(g.subarray(0, x), h), h += x, h >= c)
2210
- break;
2211
- }
2212
- return p;
2213
- };
2214
- let t = null;
2215
- for (const l of Re) {
2216
- const d = `${l}/.zarray`;
2217
- if (this.meta.metadata[d] && "dtype" in this.meta.metadata[d]) {
2218
- t = l;
2219
- break;
2220
- }
2221
- }
2222
- this.verticalName = t ?? "";
2223
- const i = this.getAttrs("time");
2224
- this.timeUnits = i.units ?? "", this.timeCalendar = i.calendar ?? "standard", this.parseTimeEncoding();
2225
- const [a, r, n] = await Promise.all([
2226
- e("time"),
2227
- e("latitude"),
2228
- e("longitude")
2229
- ]);
2230
- let o;
2231
- t ? o = await e(t) : o = new Float32Array([0]), this.coords = {
2232
- time: a,
2233
- vertical: o,
2234
- latitude: r,
2235
- longitude: n
2236
- };
2237
- }
2238
- }
2239
- function Ni(s) {
2240
- return s instanceof Float32Array ? s : Float32Array.from(s);
2241
- }
2242
- function zi(s) {
2243
- const e = s.chunks.reduce((i, a) => i * a, 1), t = new Float32Array(e);
2244
- return t.fill(NaN), t;
2245
- }
2246
- function Gi(s) {
2247
- const t = s.trim().replace(/\s+\([^)]*\)\s*$/, "").match(
2248
- /^(\d{4})-(\d{2})-(\d{2})(?:(?:T|\s+)(\d{2})(?::(\d{2})(?::(\d{2})(?:\.(\d{1,9}))?)?)?)?(?:\s*(Z|[+-]\d{2}:?\d{2}))?$/i
2249
- );
2250
- if (!t)
2251
- return NaN;
2252
- const i = Number(t[1]), a = Number(t[2]), r = Number(t[3]), n = Number(t[4] ?? 0), o = Number(t[5] ?? 0), l = Number(t[6] ?? 0), d = Number((t[7] ?? "").padEnd(3, "0").slice(0, 3)), c = t[8] ?? "Z";
2253
- if (a < 1 || a > 12 || n > 23 || o > 59 || l > 59)
2254
- return NaN;
2255
- const u = /* @__PURE__ */ new Date(0);
2256
- u.setUTCFullYear(i, a - 1, r), u.setUTCHours(n, o, l, d);
2257
- const f = u.getTime();
2258
- if (u.getUTCFullYear() !== i || u.getUTCMonth() !== a - 1 || u.getUTCDate() !== r || u.getUTCHours() !== n || u.getUTCMinutes() !== o || u.getUTCSeconds() !== l || u.getUTCMilliseconds() !== d)
2259
- return NaN;
2260
- if (/^z$/i.test(c))
2261
- return f;
2262
- const m = c.match(/^([+-])(\d{2}):?(\d{2})$/);
2263
- if (!m)
2264
- return NaN;
2265
- const p = Number(m[2]), h = Number(m[3]);
2266
- if (p > 23 || h > 59)
2267
- return NaN;
2268
- const g = (p * 60 + h) * 6e4;
2269
- return f - (m[1] === "+" ? g : -g);
2270
- }
2271
- function Oi(s) {
2272
- if (typeof s != "number" || !Number.isFinite(s) || s <= 0)
2273
- return s;
2274
- const e = [
2275
- 60 * 1e3,
2276
- 180 * 1e3,
2277
- 300 * 1e3,
2278
- 600 * 1e3,
2279
- 900 * 1e3,
2280
- 1800 * 1e3,
2281
- 3600 * 1e3,
2282
- 10800 * 1e3,
2283
- 360 * 60 * 1e3,
2284
- 720 * 60 * 1e3,
2285
- 1440 * 60 * 1e3,
2286
- 10080 * 60 * 1e3
2287
- ];
2288
- for (const t of e)
2289
- if (Math.abs(s - t) <= Math.max(1e3, t * 0.02))
2290
- return t;
2291
- return Math.round(s);
2292
- }
2293
- function Bi(s) {
2294
- if (s.length < 2)
2295
- return;
2296
- const e = s[1] - s[0];
2297
- if (!Number.isFinite(e) || e <= 0)
2298
- return;
2299
- const t = Math.max(1, Math.abs(e) * 1e-9);
2300
- for (let i = 2; i < s.length; i++)
2301
- if (Math.abs(s[i] - s[i - 1] - e) > t)
2302
- return;
2303
- return Oi(e);
2304
- }
2305
1734
  class xe extends Error {
2306
1735
  constructor(e, t, i) {
2307
1736
  super(
2308
1737
  t.length > 0 ? "Remote data is not available yet; the selected frame may still be publishing." : "The selected frame contains no renderable data."
2309
- ), this.name = "ZartiglFrameUnavailableError", this.time = e, this.statuses = [...new Set(t)].sort((a, r) => a - r), this.urls = [...new Set(i)];
1738
+ ), this.name = "ZartiglFrameUnavailableError", this.time = e, this.statuses = [...new Set(t)].sort((s, r) => s - r), this.urls = [...new Set(i)];
2310
1739
  }
2311
1740
  }
2312
- function $i(s) {
2313
- for (const e of s)
1741
+ function Fi(a) {
1742
+ for (const e of a)
2314
1743
  if (Number.isFinite(e))
2315
1744
  return !0;
2316
1745
  return !1;
2317
1746
  }
2318
- function qi(s, e) {
2319
- for (let t = 0; t < Math.min(s.length, e.length); t++)
2320
- if (Number.isFinite(s[t]) && Number.isFinite(e[t]))
1747
+ function Vi(a, e) {
1748
+ for (let t = 0; t < Math.min(a.length, e.length); t++)
1749
+ if (Number.isFinite(a[t]) && Number.isFinite(e[t]))
2321
1750
  return !0;
2322
1751
  return !1;
2323
1752
  }
2324
- function Lt(s) {
1753
+ function Pt(a) {
2325
1754
  return {
2326
1755
  phase: "blocked",
2327
- time: s.time,
2328
- statuses: s.statuses,
2329
- message: s.message
1756
+ time: a.time,
1757
+ statuses: a.statuses,
1758
+ message: a.message
2330
1759
  };
2331
1760
  }
2332
1761
  class me {
2333
1762
  constructor(e) {
2334
- this.type = "custom", this.renderingMode = "3d", this.map = null, this.gl = null, this.activeData = null, this.initialized = !1, this.suspended = !1, this.loading = !1, this.reloadQueued = !1, this.generation = 0, this.requestId = 0, this.pendingReadyTime = null, this.frameCache = /* @__PURE__ */ new Map(), this.inflight = /* @__PURE__ */ new Set(), this.listeners = /* @__PURE__ */ new Map(), this.textureUnit = 1, this.moveEndHandler = null, this.id = e.id, this.variable = e.variable, this.time = e.time ?? 0, this.depth = e.depth ?? 0, this.unit = e.unit ?? "", this.colorDomain = Q(e.colorDomain ?? null), this.zarrSource = e.zarrSource ?? new _e(e.source), this.activeField = new Pt(), this.simulation = new Rt({
1763
+ this.type = "custom", this.renderingMode = "3d", this.map = null, this.gl = null, this.activeData = null, this.initialized = !1, this.suspended = !1, this.loading = !1, this.reloadQueued = !1, this.generation = 0, this.requestId = 0, this.pendingReadyTime = null, this.frameCache = /* @__PURE__ */ new Map(), this.inflight = /* @__PURE__ */ new Set(), this.listeners = /* @__PURE__ */ new Map(), this.textureUnit = 1, this.moveEndHandler = null, this.id = e.id, this.variable = e.variable, this.time = e.time ?? 0, this.depth = e.depth ?? 0, this.unit = e.unit ?? "", this.colorDomain = Q(e.colorDomain ?? null), this.zarrSource = e.zarrSource ?? new ve(e.source), this.activeField = new Rt(), this.simulation = new Tt({
2335
1764
  colorRamp: e.colorRamp,
2336
1765
  opacity: e.opacity ?? 1,
2337
1766
  logScale: e.logScale ?? !1,
@@ -2363,12 +1792,12 @@ class me {
2363
1792
  const i = K(e);
2364
1793
  if (this.suspended || !this.map || !this.activeData || !this.activeField.hasData())
2365
1794
  return;
2366
- const a = Ge(i);
1795
+ const s = Ge(i);
2367
1796
  try {
2368
1797
  const r = i.canvas;
2369
- this.simulation.resize(r.width, r.height), i.bindFramebuffer(i.FRAMEBUFFER, a.framebuffer), i.viewport(0, 0, r.width, r.height);
2370
- const n = this.map.getBounds(), o = t.defaultProjectionData, l = ye(this.map, o), d = 512 * Math.pow(2, this.map.getZoom());
2371
- this.activeField.bind(this.textureUnit), l ? this.simulation.renderGridGlobe(
1798
+ this.simulation.resize(r.width, r.height), i.bindFramebuffer(i.FRAMEBUFFER, s.framebuffer), i.viewport(0, 0, r.width, r.height);
1799
+ const n = this.map.getBounds(), o = t.defaultProjectionData, c = _e(this.map, o), d = 512 * Math.pow(2, this.map.getZoom());
1800
+ this.activeField.bind(this.textureUnit), c ? this.simulation.renderGridGlobe(
2372
1801
  this.textureUnit,
2373
1802
  [this.activeData.uMin, this.activeData.vMin],
2374
1803
  [this.activeData.uMax, this.activeData.vMax],
@@ -2385,12 +1814,12 @@ class me {
2385
1814
  [this.activeData.uMax, this.activeData.vMax],
2386
1815
  t.modelViewProjectionMatrix,
2387
1816
  d,
2388
- Be(n, !1),
1817
+ Ne(n, !1),
2389
1818
  this.activeField.geoBounds,
2390
1819
  1
2391
1820
  );
2392
1821
  } finally {
2393
- Oe(i, a);
1822
+ Oe(i, s);
2394
1823
  }
2395
1824
  if (this.pendingReadyTime != null) {
2396
1825
  const r = this.pendingReadyTime;
@@ -2502,28 +1931,28 @@ class me {
2502
1931
  return;
2503
1932
  }
2504
1933
  this.loading = !0, this.emit("loading");
2505
- const e = this.generation, t = this.requestId, i = this.time, a = this.timeToMs(i);
1934
+ const e = this.generation, t = this.requestId, i = this.time, s = this.timeToMs(i);
2506
1935
  try {
2507
1936
  if (await this.zarrSource.init(), e !== this.generation || t !== this.requestId)
2508
1937
  return;
2509
1938
  this.initialized = !0;
2510
- const r = this.frameCache.get(a) ?? await this.fetchScalarData(i, (n, o) => {
1939
+ const r = this.frameCache.get(s) ?? await this.fetchScalarData(i, (n, o) => {
2511
1940
  e === this.generation && t === this.requestId && this.emit("status", {
2512
1941
  phase: "fetching",
2513
- time: a,
1942
+ time: s,
2514
1943
  completed: n,
2515
1944
  total: o
2516
1945
  });
2517
1946
  });
2518
1947
  if (e !== this.generation || t !== this.requestId)
2519
1948
  return;
2520
- this.frameCache.set(a, r), this.setActive(r, i);
1949
+ this.frameCache.set(s, r), this.setActive(r, i);
2521
1950
  } catch (r) {
2522
1951
  if (r.name !== "AbortError") {
2523
1952
  const n = r instanceof Error ? r : new Error(String(r));
2524
1953
  e === this.generation && t === this.requestId && (this.emit(
2525
1954
  "status",
2526
- n instanceof xe ? Lt(n) : { phase: "error", time: a, error: n }
1955
+ n instanceof xe ? Pt(n) : { phase: "error", time: s, error: n }
2527
1956
  ), this.emit("error", n));
2528
1957
  }
2529
1958
  } finally {
@@ -2531,7 +1960,7 @@ class me {
2531
1960
  }
2532
1961
  }
2533
1962
  async fetchScalarData(e, t) {
2534
- const i = this.map.getBounds(), a = {
1963
+ const i = this.map.getBounds(), s = {
2535
1964
  west: -180,
2536
1965
  east: 180,
2537
1966
  south: Math.max(i.getSouth(), -85),
@@ -2540,14 +1969,14 @@ class me {
2540
1969
  this.variable,
2541
1970
  r,
2542
1971
  n,
2543
- a
2544
- ), l = this.zarrSource.getDimensions(this.variable), d = l.indexOf("latitude"), c = l.indexOf("longitude"), u = this.zarrSource.getChunkShape(this.variable);
2545
- let f = 0;
2546
- const m = o.length, p = [], h = [];
2547
- t?.(f, m);
2548
- const g = await Promise.all(
1972
+ s
1973
+ ), c = this.zarrSource.getDimensions(this.variable), d = c.indexOf("latitude"), u = c.indexOf("longitude"), h = this.zarrSource.getChunkShape(this.variable);
1974
+ let v = 0;
1975
+ const m = o.length, f = [], l = [];
1976
+ t?.(v, m);
1977
+ const p = await Promise.all(
2549
1978
  o.map(async (b) => {
2550
- const A = await this.zarrSource.fetchSpatialChunkResult(
1979
+ const V = await this.zarrSource.fetchSpatialChunkResult(
2551
1980
  this.variable,
2552
1981
  {
2553
1982
  timeIndex: b.timeIdx,
@@ -2556,38 +1985,38 @@ class me {
2556
1985
  longitudeChunkIndex: b.lonIdx
2557
1986
  }
2558
1987
  );
2559
- return A.missing && (A.status != null && p.push(A.status), h.push(A.url)), f++, t?.(f, m), {
2560
- data: A.data,
2561
- latStart: b.latIdx * u[d],
2562
- lonStart: b.lonIdx * u[c],
1988
+ return V.missing && (V.status != null && f.push(V.status), l.push(V.url)), v++, t?.(v, m), {
1989
+ data: V.data,
1990
+ latStart: b.latIdx * h[d],
1991
+ lonStart: b.lonIdx * h[u],
2563
1992
  latSize: b.latSize,
2564
1993
  lonSize: b.lonSize,
2565
- lonChunkSize: u[c]
1994
+ lonChunkSize: h[u]
2566
1995
  };
2567
1996
  })
2568
- ), x = Math.min(...g.map((b) => b.latStart)), T = Math.max(...g.map((b) => b.latStart + b.latSize)), M = Math.min(...g.map((b) => b.lonStart)), y = Math.max(...g.map((b) => b.lonStart + b.lonSize)), v = T - x, _ = y - M, S = g.map((b) => ({
1997
+ ), x = Math.min(...p.map((b) => b.latStart)), T = Math.max(...p.map((b) => b.latStart + b.latSize)), R = Math.min(...p.map((b) => b.lonStart)), y = Math.max(...p.map((b) => b.lonStart + b.lonSize)), g = T - x, _ = y - R, S = p.map((b) => ({
2569
1998
  ...b,
2570
1999
  latStart: b.latStart - x,
2571
- lonStart: b.lonStart - M
2572
- })), E = this.zarrSource.getCoords(), R = Math.min(T - 1, E.latitude.length - 1), k = Math.min(y - 1, E.longitude.length - 1), F = wt(
2000
+ lonStart: b.lonStart - R
2001
+ })), E = this.zarrSource.getCoords(), P = Math.min(T - 1, E.latitude.length - 1), A = Math.min(y - 1, E.longitude.length - 1), U = bt(
2573
2002
  E.longitude,
2574
2003
  E.latitude,
2575
- [M, k],
2576
- [x, R]
2577
- ), L = E.latitude[x] > E.latitude[R], D = Et(
2004
+ [R, A],
2005
+ [x, P]
2006
+ ), L = E.latitude[x] > E.latitude[P], D = Mt(
2578
2007
  S,
2579
2008
  [],
2580
- v,
2009
+ g,
2581
2010
  _,
2582
- F,
2011
+ U,
2583
2012
  L,
2584
2013
  !0
2585
2014
  );
2586
- if (!$i(D.u))
2015
+ if (!Fi(D.u))
2587
2016
  throw new xe(
2588
2017
  this.timeToMs(e),
2589
- p,
2590
- h
2018
+ f,
2019
+ l
2591
2020
  );
2592
2021
  return D;
2593
2022
  }
@@ -2596,8 +2025,8 @@ class me {
2596
2025
  this.emit("status", { phase: "rendering", time: i }), this.activeData = e, this.activeField.update(e, this.colorDomain), this.activeField.setFilter(!1), this.emit("loaded", this.computeFieldMeta(e, t)), this.pendingReadyTime = i, this.map?.triggerRepaint();
2597
2026
  }
2598
2027
  sampleActiveData(e, t, i) {
2599
- const { west: a, east: r, south: n, north: o } = e.bounds, l = r - a, d = o - n;
2600
- if (e.width <= 0 || e.height <= 0 || l <= 0 || d <= 0)
2028
+ const { west: s, east: r, south: n, north: o } = e.bounds, c = r - s, d = o - n;
2029
+ if (e.width <= 0 || e.height <= 0 || c <= 0 || d <= 0)
2601
2030
  return {
2602
2031
  longitude: t,
2603
2032
  latitude: i,
@@ -2606,8 +2035,8 @@ class me {
2606
2035
  time: this.timeToMs(this.time),
2607
2036
  depth: this.depth
2608
2037
  };
2609
- const c = a + ((t - a) % 360 + 360) % 360;
2610
- if (c > r && l < 359 || i < n || i > o)
2038
+ const u = s + ((t - s) % 360 + 360) % 360;
2039
+ if (u > r && c < 359 || i < n || i > o)
2611
2040
  return {
2612
2041
  longitude: t,
2613
2042
  latitude: i,
@@ -2616,17 +2045,17 @@ class me {
2616
2045
  time: this.timeToMs(this.time),
2617
2046
  depth: this.depth
2618
2047
  };
2619
- const u = (c - a) / l, f = e.latDescending ? (o - i) / d : (i - n) / d, m = Math.max(
2048
+ const h = (u - s) / c, v = e.latDescending ? (o - i) / d : (i - n) / d, m = Math.max(
2620
2049
  0,
2621
- Math.min(e.width - 1, Math.floor(u * e.width))
2622
- ), p = Math.max(
2050
+ Math.min(e.width - 1, Math.floor(h * e.width))
2051
+ ), f = Math.max(
2623
2052
  0,
2624
- Math.min(e.height - 1, Math.floor(f * e.height))
2625
- ), h = e.u[p * e.width + m] ?? NaN, g = a + (m + 0.5) / e.width * l, x = e.latDescending ? o - (p + 0.5) / e.height * d : n + (p + 0.5) / e.height * d;
2053
+ Math.min(e.height - 1, Math.floor(v * e.height))
2054
+ ), l = e.u[f * e.width + m] ?? NaN, p = s + (m + 0.5) / e.width * c, x = e.latDescending ? o - (f + 0.5) / e.height * d : n + (f + 0.5) / e.height * d;
2626
2055
  return {
2627
- longitude: g,
2056
+ longitude: p,
2628
2057
  latitude: x,
2629
- value: h,
2058
+ value: l,
2630
2059
  unit: this.unit,
2631
2060
  time: this.timeToMs(this.time),
2632
2061
  depth: this.depth
@@ -2648,38 +2077,38 @@ class me {
2648
2077
  emit(e, ...t) {
2649
2078
  const i = this.listeners.get(e);
2650
2079
  if (i)
2651
- for (const a of i)
2652
- a(...t);
2080
+ for (const s of i)
2081
+ s(...t);
2653
2082
  }
2654
2083
  }
2655
- function Wi(s, e, t) {
2656
- if (!Number.isFinite(s) || !Number.isFinite(e))
2084
+ function Ui(a, e, t) {
2085
+ if (!Number.isFinite(a) || !Number.isFinite(e))
2657
2086
  return { u: NaN, v: NaN };
2658
- const i = t.direction_convention !== t.output_direction ? 180 : 0, a = (s + i) * Math.PI / 180;
2087
+ const i = t.direction_convention !== t.output_direction ? 180 : 0, s = (a + i) * Math.PI / 180;
2659
2088
  return {
2660
- u: e * Math.sin(a),
2661
- v: e * Math.cos(a)
2089
+ u: e * Math.sin(s),
2090
+ v: e * Math.cos(s)
2662
2091
  };
2663
2092
  }
2664
- function Da(s) {
2665
- return [s.direction_variable, s.magnitude_variable];
2093
+ function _a(a) {
2094
+ return [a.direction_variable, a.magnitude_variable];
2666
2095
  }
2667
- const Xi = 0.7;
2668
- class P {
2096
+ const Ii = 0.7;
2097
+ class M {
2669
2098
  constructor(e) {
2670
2099
  if (this.type = "custom", this.renderingMode = "3d", this.map = null, this.gl = null, this.initialized = !1, this.suspended = !1, this.loading = !1, this.reloadQueued = !1, this.reloadQueuedResetParticles = !1, this.globeRendering = null, this.generation = 0, this.requestId = 0, this.pendingReadyTime = null, this.velocityTexUnit = 1, this.moveStartHandler = null, this.moveHandler = null, this.moveEndHandler = null, this.frameCache = /* @__PURE__ */ new Map(), this.inflight = /* @__PURE__ */ new Set(), this.listeners = /* @__PURE__ */ new Map(), this.id = e.id, this.geoVideoManifest = e.geoVideo?.manifest, this.geoVideoManifest && this.geoVideoManifest.encoding.kind !== "vector-luma")
2671
2100
  throw new Error("Vector GeoVideo requires a vector-luma manifest");
2672
- this.playback = e.geoVideo ? new yt(
2101
+ this.playback = e.geoVideo ? new gt(
2673
2102
  { ...e.geoVideo, time: e.time },
2674
2103
  () => this.map?.triggerRepaint(),
2675
2104
  (t, ...i) => {
2676
2105
  if (t === "loaded") {
2677
2106
  this.initialized = !0;
2678
- const a = i[0], r = this.playback?.field?.manifest.encoding;
2107
+ const s = i[0], r = this.playback?.field?.manifest.encoding;
2679
2108
  this.emit("loaded", {
2680
- ...a,
2109
+ ...s,
2681
2110
  min: 0,
2682
- max: r?.kind === "vector-luma" ? Math.SQRT2 * r.valueDomain : a.max,
2111
+ max: r?.kind === "vector-luma" ? Math.SQRT2 * r.valueDomain : s.max,
2683
2112
  unit: this.unit,
2684
2113
  depth: this.depth
2685
2114
  });
@@ -2687,16 +2116,16 @@ class P {
2687
2116
  }
2688
2117
  t === "timeChange" && (this.time = i[0]), this.emit(t, ...i);
2689
2118
  }
2690
- ) : null, this.variableU = e.variableU ?? "uo", this.variableV = e.variableV ?? "vo", this.vectorDerivation = e.vectorDerivation, this.unit = e.unit ?? "m/s", this.time = e.time ?? 0, this.depth = e.depth ?? 0, this.zarrSourceValue = this.playback ? null : e.zarrSource ?? new _e(e.source), this.velocityField = new Pt(), this.simulation = new Rt({
2119
+ ) : null, this.variableU = e.variableU ?? "uo", this.variableV = e.variableV ?? "vo", this.vectorDerivation = e.vectorDerivation, this.unit = e.unit ?? "m/s", this.time = e.time ?? 0, this.depth = e.depth ?? 0, this.zarrSourceValue = this.playback ? null : e.zarrSource ?? new ve(e.source), this.velocityField = new Rt(), this.simulation = new Tt({
2691
2120
  particleDensity: e.particleDensity ?? 0.05,
2692
2121
  speed: e.speed ?? 1,
2693
- fadeOpacity: Xe(e.fade ?? Xi),
2122
+ fadeOpacity: We(e.fade ?? Ii),
2694
2123
  colorRamp: e.colorRamp,
2695
2124
  opacity: e.opacity ?? 1,
2696
2125
  logScale: e.logScale ?? !1,
2697
2126
  vibrance: e.vibrance ?? 0,
2698
- colorGrade: bt(e.colorGrade),
2699
- backdrop: St(e.backdrop),
2127
+ colorGrade: _t(e.colorGrade),
2128
+ backdrop: xt(e.backdrop),
2700
2129
  glow: e.glow ?? 0,
2701
2130
  particleState: e.particleState ?? "auto",
2702
2131
  rgba8MaxParticleZoom: e.rgba8MaxParticleZoom ?? 4
@@ -2709,8 +2138,8 @@ class P {
2709
2138
  }
2710
2139
  async onAdd(e, t) {
2711
2140
  const i = K(t);
2712
- this.map = e, this.gl = i, this.simulation.init(i), this.velocityField.init(i), this.playback && this.geoVideoManifest ? (this.emit("loading"), this.emit("status", { phase: "metadata" }), this.playback.load(i, this.geoVideoManifest).catch((a) => {
2713
- const r = a instanceof Error ? a : new Error(String(a));
2141
+ this.map = e, this.gl = i, this.simulation.init(i), this.velocityField.init(i), this.playback && this.geoVideoManifest ? (this.emit("loading"), this.emit("status", { phase: "metadata" }), this.playback.load(i, this.geoVideoManifest).catch((s) => {
2142
+ const r = s instanceof Error ? s : new Error(String(s));
2714
2143
  r.name !== "AbortError" && this.map && (this.playback?.pause(), this.emit("status", { phase: "error", error: r }), this.emit("error", r));
2715
2144
  })) : this.initAsync(), this.moveStartHandler = () => {
2716
2145
  this.suspended || (this.simulation.setCameraMoving(!0), this.map?.triggerRepaint());
@@ -2744,9 +2173,9 @@ class P {
2744
2173
  };
2745
2174
  }
2746
2175
  isViewportCovered() {
2747
- return !this.map || !this.velocityField.hasData() ? !1 : wi(
2176
+ return !this.map || !this.velocityField.hasData() ? !1 : _i(
2748
2177
  this.velocityField.geoBounds,
2749
- bi(this.map.getBounds())
2178
+ vi(this.map.getBounds())
2750
2179
  );
2751
2180
  }
2752
2181
  reloadIfViewportUncovered() {
@@ -2763,37 +2192,37 @@ class P {
2763
2192
  * The map's current viewport is used to determine the lat bounds of the request.
2764
2193
  */
2765
2194
  async fetchVelocityData(e, t) {
2766
- const i = this.map.getBounds(), a = this.globeRendering ?? ye(this.map), r = Si(i, 1, a), n = this.zarrSource.findTimeIndex(e), o = this.zarrSource.findDepthIndex(this.depth);
2195
+ const i = this.map.getBounds(), s = this.globeRendering ?? _e(this.map), r = yi(i, 1, s), n = this.zarrSource.findTimeIndex(e), o = this.zarrSource.findDepthIndex(this.depth);
2767
2196
  console.log(
2768
2197
  `[zartigl] Loading velocity: depth=${this.depth} → depthIdx=${o}, actual depth value=${this.zarrSource.getCoords().vertical[o]}, timeIdx=${n}`
2769
2198
  );
2770
- const l = this.vectorDerivation?.direction_variable ?? this.variableU, d = this.zarrSource.getChunksForBounds(
2771
- l,
2199
+ const c = this.vectorDerivation?.direction_variable ?? this.variableU, d = this.zarrSource.getChunksForBounds(
2200
+ c,
2772
2201
  n,
2773
2202
  o,
2774
2203
  r
2775
- ), c = this.zarrSource.getDimensions(l), u = c.indexOf("latitude"), f = c.indexOf("longitude");
2204
+ ), u = this.zarrSource.getDimensions(c), h = u.indexOf("latitude"), v = u.indexOf("longitude");
2776
2205
  let m = 0;
2777
- const p = d.length * 2, h = [], g = [];
2778
- t?.(m, p);
2779
- const x = (w) => d.map(async (V) => {
2780
- const X = await this.zarrSource.fetchSpatialChunkResult(w, {
2781
- timeIndex: V.timeIdx,
2782
- verticalIndex: V.depthIdx,
2783
- latitudeChunkIndex: V.latIdx,
2784
- longitudeChunkIndex: V.lonIdx
2206
+ const f = d.length * 2, l = [], p = [];
2207
+ t?.(m, f);
2208
+ const x = (w) => d.map(async (k) => {
2209
+ const W = await this.zarrSource.fetchSpatialChunkResult(w, {
2210
+ timeIndex: k.timeIdx,
2211
+ verticalIndex: k.depthIdx,
2212
+ latitudeChunkIndex: k.latIdx,
2213
+ longitudeChunkIndex: k.lonIdx
2785
2214
  });
2786
- X.missing && (X.status != null && h.push(X.status), g.push(X.url)), m++, t?.(m, p);
2787
- const oe = this.zarrSource.getChunkShape(w), le = oe[f];
2215
+ W.missing && (W.status != null && l.push(W.status), p.push(W.url)), m++, t?.(m, f);
2216
+ const oe = this.zarrSource.getChunkShape(w), le = oe[v];
2788
2217
  return {
2789
- data: X.data,
2790
- latStart: V.latIdx * oe[u],
2791
- lonStart: V.lonIdx * le,
2792
- latSize: V.latSize,
2793
- lonSize: V.lonSize,
2218
+ data: W.data,
2219
+ latStart: k.latIdx * oe[h],
2220
+ lonStart: k.lonIdx * le,
2221
+ latSize: k.latSize,
2222
+ lonSize: k.lonSize,
2794
2223
  lonChunkSize: le
2795
2224
  };
2796
- }), [T, M] = this.vectorDerivation ? Hi(
2225
+ }), [T, R] = this.vectorDerivation ? zi(
2797
2226
  await Promise.all(
2798
2227
  x(this.vectorDerivation.direction_variable)
2799
2228
  ),
@@ -2804,32 +2233,32 @@ class P {
2804
2233
  ) : await Promise.all([
2805
2234
  Promise.all(x(this.variableU)),
2806
2235
  Promise.all(x(this.variableV))
2807
- ]), y = Math.min(...T.map((w) => w.latStart)), v = Math.max(...T.map((w) => w.latStart + w.latSize)), _ = Math.min(...T.map((w) => w.lonStart)), S = Math.max(...T.map((w) => w.lonStart + w.lonSize)), E = v - y, R = S - _, k = T.map((w) => ({
2236
+ ]), y = Math.min(...T.map((w) => w.latStart)), g = Math.max(...T.map((w) => w.latStart + w.latSize)), _ = Math.min(...T.map((w) => w.lonStart)), S = Math.max(...T.map((w) => w.lonStart + w.lonSize)), E = g - y, P = S - _, A = T.map((w) => ({
2808
2237
  ...w,
2809
2238
  latStart: w.latStart - y,
2810
2239
  lonStart: w.lonStart - _
2811
- })), F = M.map((w) => ({
2240
+ })), U = R.map((w) => ({
2812
2241
  ...w,
2813
2242
  latStart: w.latStart - y,
2814
2243
  lonStart: w.lonStart - _
2815
- })), L = this.zarrSource.getCoords(), D = Math.min(v - 1, L.latitude.length - 1), b = Math.min(S - 1, L.longitude.length - 1), A = wt(
2244
+ })), L = this.zarrSource.getCoords(), D = Math.min(g - 1, L.latitude.length - 1), b = Math.min(S - 1, L.longitude.length - 1), V = bt(
2816
2245
  L.longitude,
2817
2246
  L.latitude,
2818
2247
  [_, b],
2819
2248
  [y, D]
2820
- ), N = L.latitude[y] > L.latitude[D], C = Et(
2821
- k,
2822
- F,
2823
- E,
2824
- R,
2249
+ ), X = L.latitude[y] > L.latitude[D], C = Mt(
2825
2250
  A,
2826
- N
2251
+ U,
2252
+ E,
2253
+ P,
2254
+ V,
2255
+ X
2827
2256
  ), I = this.zarrSource.getValueDomain?.();
2828
- if (I != null && I > 0 && (C.uMin = -I, C.uMax = I, C.vMin = -I, C.vMax = I), !qi(C.u, C.v))
2257
+ if (I != null && I > 0 && (C.uMin = -I, C.uMax = I, C.vMin = -I, C.vMax = I), !Vi(C.u, C.v))
2829
2258
  throw new xe(
2830
2259
  this.timeToMs(e),
2831
- h,
2832
- g
2260
+ l,
2261
+ p
2833
2262
  );
2834
2263
  return C;
2835
2264
  }
@@ -2841,7 +2270,7 @@ class P {
2841
2270
  return;
2842
2271
  }
2843
2272
  this.loading = !0, this.emit("loading");
2844
- const t = this.generation, i = this.requestId, a = this.time, r = this.timeToMs(a);
2273
+ const t = this.generation, i = this.requestId, s = this.time, r = this.timeToMs(s);
2845
2274
  try {
2846
2275
  if (await this.zarrSource.init(), t !== this.generation || i !== this.requestId)
2847
2276
  return;
@@ -2851,12 +2280,12 @@ class P {
2851
2280
  n = this.frameCache.get(r);
2852
2281
  else {
2853
2282
  const o = await this.fetchVelocityData(
2854
- a,
2855
- (l, d) => {
2283
+ s,
2284
+ (c, d) => {
2856
2285
  t === this.generation && i === this.requestId && this.emit("status", {
2857
2286
  phase: "fetching",
2858
2287
  time: r,
2859
- completed: l,
2288
+ completed: c,
2860
2289
  total: d
2861
2290
  });
2862
2291
  }
@@ -2867,13 +2296,13 @@ class P {
2867
2296
  }
2868
2297
  if (t !== this.generation || i !== this.requestId)
2869
2298
  return;
2870
- this.emit("status", { phase: "rendering", time: r }), this.velocityField.update(n), e.resetParticles && this.simulation.resetParticles(), this.emit("loaded", this.computeFieldMeta(n, a)), this.pendingReadyTime = r, this.map?.triggerRepaint();
2299
+ this.emit("status", { phase: "rendering", time: r }), this.velocityField.update(n), e.resetParticles && this.simulation.resetParticles(), this.emit("loaded", this.computeFieldMeta(n, s)), this.pendingReadyTime = r, this.map?.triggerRepaint();
2871
2300
  } catch (n) {
2872
2301
  if (n.name !== "AbortError") {
2873
2302
  const o = n instanceof Error ? n : new Error(String(n));
2874
2303
  console.error("[zartigl] Failed to load velocity:", o), t === this.generation && i === this.requestId && (this.emit(
2875
2304
  "status",
2876
- o instanceof xe ? Lt(o) : { phase: "error", time: r, error: o }
2305
+ o instanceof xe ? Pt(o) : { phase: "error", time: r, error: o }
2877
2306
  ), this.emit("error", o));
2878
2307
  }
2879
2308
  } finally {
@@ -2884,72 +2313,72 @@ class P {
2884
2313
  }
2885
2314
  }
2886
2315
  render(e, t) {
2887
- const i = K(e), a = t.modelViewProjectionMatrix;
2316
+ const i = K(e), s = t.modelViewProjectionMatrix;
2888
2317
  if (this.suspended || !this.map)
2889
2318
  return;
2890
2319
  const r = this.playback?.sample(performance.now()), n = this.playback?.field;
2891
2320
  if (this.playback ? !r || !n : !this.initialized || !this.velocityField.hasData())
2892
2321
  return;
2893
2322
  n?.setFilter(this.simulation.renderMode !== "raster");
2894
- const o = n?.manifest.encoding.kind === "vector-luma" ? n.manifest.encoding.valueDomain : 0, l = n ? [-o, -o] : [this.velocityField.uMin, this.velocityField.vMin], d = n ? [o, o] : [this.velocityField.uMax, this.velocityField.vMax], c = n ? {
2323
+ const o = n?.manifest.encoding.kind === "vector-luma" ? n.manifest.encoding.valueDomain : 0, c = n ? [-o, -o] : [this.velocityField.uMin, this.velocityField.vMin], d = n ? [o, o] : [this.velocityField.uMax, this.velocityField.vMax], u = n ? {
2895
2324
  west: n.bounds[0],
2896
2325
  south: n.bounds[1],
2897
2326
  east: n.bounds[2],
2898
2327
  north: n.bounds[3]
2899
- } : this.velocityField.geoBounds, u = r ? {
2328
+ } : this.velocityField.geoBounds, h = r ? {
2900
2329
  a: {
2901
2330
  unit: 1,
2902
- min: l,
2331
+ min: c,
2903
2332
  max: d,
2904
2333
  physical: !0,
2905
2334
  northToSouth: !0
2906
2335
  },
2907
2336
  b: {
2908
2337
  unit: 4,
2909
- min: l,
2338
+ min: c,
2910
2339
  max: d,
2911
2340
  physical: !0,
2912
2341
  northToSouth: !0
2913
2342
  },
2914
2343
  mix: r[2]
2915
- } : void 0, f = Ge(i), m = r ? [1, 4].map((p) => (i.activeTexture(i.TEXTURE0 + p), i.getParameter(i.TEXTURE_BINDING_2D))) : [];
2344
+ } : void 0, v = Ge(i), m = r ? [1, 4].map((f) => (i.activeTexture(i.TEXTURE0 + f), i.getParameter(i.TEXTURE_BINDING_2D))) : [];
2916
2345
  try {
2917
- const p = i.canvas;
2918
- this.simulation.resize(p.width, p.height), i.bindFramebuffer(i.FRAMEBUFFER, f.framebuffer), r ? (i.activeTexture(i.TEXTURE1), i.bindTexture(i.TEXTURE_2D, r[0]), i.activeTexture(i.TEXTURE4), i.bindTexture(i.TEXTURE_2D, r[1])) : this.velocityField.bind(this.velocityTexUnit);
2919
- const h = ye(this.map, t.defaultProjectionData);
2920
- if (this.globeRendering !== null && this.globeRendering !== h) {
2921
- if (this.globeRendering = h, !this.playback) {
2346
+ const f = i.canvas;
2347
+ this.simulation.resize(f.width, f.height), i.bindFramebuffer(i.FRAMEBUFFER, v.framebuffer), r ? (i.activeTexture(i.TEXTURE1), i.bindTexture(i.TEXTURE_2D, r[0]), i.activeTexture(i.TEXTURE4), i.bindTexture(i.TEXTURE_2D, r[1])) : this.velocityField.bind(this.velocityTexUnit);
2348
+ const l = _e(this.map, t.defaultProjectionData);
2349
+ if (this.globeRendering !== null && this.globeRendering !== l) {
2350
+ if (this.globeRendering = l, !this.playback) {
2922
2351
  this.loadViewportVelocity({ resetParticles: !0 });
2923
2352
  return;
2924
2353
  }
2925
2354
  this.simulation.resetParticles();
2926
2355
  }
2927
- this.globeRendering = h;
2928
- const g = this.map.getBounds(), x = Ti(g, h), T = Be(g, h);
2356
+ this.globeRendering = l;
2357
+ const p = this.map.getBounds(), x = xi(p, l), T = Ne(p, l);
2929
2358
  i.disable(i.DEPTH_TEST), i.disable(i.STENCIL_TEST);
2930
- const M = 512 * Math.pow(2, this.map.getZoom()), y = this.map.getCenter();
2359
+ const R = 512 * Math.pow(2, this.map.getZoom()), y = this.map.getCenter();
2931
2360
  this.simulation.render(
2932
2361
  this.velocityTexUnit,
2933
- l,
2362
+ c,
2934
2363
  d,
2935
- a,
2364
+ s,
2936
2365
  x,
2937
- M,
2366
+ R,
2938
2367
  T,
2939
- c,
2940
- h,
2941
- xi(y.lng, y.lat),
2368
+ u,
2369
+ l,
2370
+ gi(y.lng, y.lat),
2942
2371
  t.defaultProjectionData.clippingPlane,
2943
- ...u ? [u] : []
2372
+ ...h ? [h] : []
2944
2373
  );
2945
2374
  } finally {
2946
- m.forEach((p, h) => {
2947
- i.activeTexture(i.TEXTURE0 + (h === 0 ? 1 : 4)), i.bindTexture(i.TEXTURE_2D, p);
2948
- }), Oe(i, f);
2375
+ m.forEach((f, l) => {
2376
+ i.activeTexture(i.TEXTURE0 + (l === 0 ? 1 : 4)), i.bindTexture(i.TEXTURE_2D, f);
2377
+ }), Oe(i, v);
2949
2378
  }
2950
2379
  if (this.pendingReadyTime != null) {
2951
- const p = this.pendingReadyTime;
2952
- this.pendingReadyTime = null, this.emit("status", { phase: "ready", time: p });
2380
+ const f = this.pendingReadyTime;
2381
+ this.pendingReadyTime = null, this.emit("status", { phase: "ready", time: f });
2953
2382
  }
2954
2383
  this.map.triggerRepaint();
2955
2384
  }
@@ -2980,10 +2409,10 @@ class P {
2980
2409
  const i = this.depth !== t;
2981
2410
  if (this.time = e, this.depth = t, i && (this.generation++, this.zarrSource.cancelAll(), this.frameCache.clear(), this.inflight.clear()), this.suspended)
2982
2411
  return;
2983
- const a = this.timeToMs(e);
2984
- if (!i && this.frameCache.has(a)) {
2985
- const r = this.frameCache.get(a);
2986
- this.emit("status", { phase: "rendering", time: a }), this.velocityField.update(r), this.emit("loaded", this.computeFieldMeta(r, e)), this.pendingReadyTime = a, this.map?.triggerRepaint();
2412
+ const s = this.timeToMs(e);
2413
+ if (!i && this.frameCache.has(s)) {
2414
+ const r = this.frameCache.get(s);
2415
+ this.emit("status", { phase: "rendering", time: s }), this.velocityField.update(r), this.emit("loaded", this.computeFieldMeta(r, e)), this.pendingReadyTime = s, this.map?.triggerRepaint();
2987
2416
  return;
2988
2417
  }
2989
2418
  this.loadViewportVelocity();
@@ -3067,7 +2496,7 @@ class P {
3067
2496
  this.simulation.setSpeed(e);
3068
2497
  }
3069
2498
  setFade(e) {
3070
- this.simulation.setFadeOpacity(Xe(e));
2499
+ this.simulation.setFadeOpacity(We(e));
3071
2500
  }
3072
2501
  setParticleDensity(e) {
3073
2502
  this.simulation.setParticleDensity(e);
@@ -3122,27 +2551,27 @@ class P {
3122
2551
  emit(e, ...t) {
3123
2552
  const i = this.listeners.get(e);
3124
2553
  if (i)
3125
- for (const a of i)
3126
- a(...t);
3127
- }
3128
- }
3129
- function Hi(s, e, t) {
3130
- const i = [], a = [];
3131
- for (let r = 0; r < s.length; r++) {
3132
- const n = s[r], o = e[r], l = new Float32Array(n.data.length), d = new Float32Array(n.data.length);
3133
- for (let c = 0; c < n.data.length; c++) {
3134
- const u = Wi(
3135
- n.data[c],
3136
- o.data[c],
2554
+ for (const s of i)
2555
+ s(...t);
2556
+ }
2557
+ }
2558
+ function zi(a, e, t) {
2559
+ const i = [], s = [];
2560
+ for (let r = 0; r < a.length; r++) {
2561
+ const n = a[r], o = e[r], c = new Float32Array(n.data.length), d = new Float32Array(n.data.length);
2562
+ for (let u = 0; u < n.data.length; u++) {
2563
+ const h = Ui(
2564
+ n.data[u],
2565
+ o.data[u],
3137
2566
  t
3138
2567
  );
3139
- l[c] = u.u, d[c] = u.v;
2568
+ c[u] = h.u, d[u] = h.v;
3140
2569
  }
3141
- i.push({ ...n, data: l }), a.push({ ...n, data: d });
2570
+ i.push({ ...n, data: c }), s.push({ ...n, data: d });
3142
2571
  }
3143
- return [i, a];
2572
+ return [i, s];
3144
2573
  }
3145
- var Ke = `precision mediump float;
2574
+ var je = `precision mediump float;
3146
2575
 
3147
2576
  uniform sampler2D u_color;
3148
2577
  uniform sampler2D u_color_next;
@@ -3202,7 +2631,7 @@ void main() {
3202
2631
  const Z = 128, te = 64;
3203
2632
  class G {
3204
2633
  constructor(e) {
3205
- this.type = "custom", this.renderingMode = "3d", this.map = null, this.gl = null, this.manifest = null, this.colorRampTexture = null, this.mercatorProgram = null, this.globeProgram = null, this.vertexBuffer = null, this.indexBuffer = null, this.indexCount = 0, this.abortController = null, this.listeners = /* @__PURE__ */ new Map(), this.id = e.id, this.source = e.manifest, this.opacity = e.opacity ?? 1, this.playback = new yt(
2634
+ this.type = "custom", this.renderingMode = "3d", this.map = null, this.gl = null, this.manifest = null, this.colorRampTexture = null, this.mercatorProgram = null, this.globeProgram = null, this.vertexBuffer = null, this.indexBuffer = null, this.indexCount = 0, this.abortController = null, this.listeners = /* @__PURE__ */ new Map(), this.id = e.id, this.source = e.manifest, this.opacity = e.opacity ?? 1, this.playback = new gt(
3206
2635
  e,
3207
2636
  () => this.map?.triggerRepaint(),
3208
2637
  (t, ...i) => this.emit(t, ...i)
@@ -3212,7 +2641,7 @@ class G {
3212
2641
  const i = K(t);
3213
2642
  this.map = e, this.gl = i, this.abortController = new AbortController(), this.emit("loading"), this.emit("status", { phase: "metadata" });
3214
2643
  try {
3215
- if (this.manifest = await Ce(
2644
+ if (this.manifest = await Ae(
3216
2645
  this.source,
3217
2646
  this.abortController.signal
3218
2647
  ), this.abortController?.signal.aborted || !this.map)
@@ -3222,84 +2651,84 @@ class G {
3222
2651
  `GeoVideoLayer renders scalar-luma manifests, received ${this.manifest.encoding.kind}`
3223
2652
  );
3224
2653
  this.colorDomain == null && (this.colorDomain = this.manifest.style.colorDomain);
3225
- const a = i.getParameter(i.MAX_TEXTURE_SIZE);
3226
- if (this.manifest.media.width > a || this.manifest.media.height > a)
2654
+ const s = i.getParameter(i.MAX_TEXTURE_SIZE);
2655
+ if (this.manifest.media.width > s || this.manifest.media.height > s)
3227
2656
  throw new Error(
3228
- `GeoVideo ${this.manifest.media.width}x${this.manifest.media.height} exceeds GPU texture limit ${a}`
2657
+ `GeoVideo ${this.manifest.media.width}x${this.manifest.media.height} exceeds GPU texture limit ${s}`
3229
2658
  );
3230
2659
  if (this.initGl(i), this.abortController.signal.aborted)
3231
2660
  return;
3232
2661
  await this.playback.load(i, this.manifest);
3233
- } catch (a) {
3234
- const r = a instanceof Error ? a : new Error(String(a));
2662
+ } catch (s) {
2663
+ const r = s instanceof Error ? s : new Error(String(s));
3235
2664
  if (r.name === "AbortError")
3236
2665
  return;
3237
2666
  throw this.emit("status", { phase: "error", error: r }), this.emit("error", r), r;
3238
2667
  }
3239
2668
  }
3240
2669
  render(e, t) {
3241
- const i = K(e), a = this.playback.sample(performance.now()), r = this.playback.field;
2670
+ const i = K(e), s = this.playback.sample(performance.now()), r = this.playback.field;
3242
2671
  if (!r)
3243
2672
  return;
3244
2673
  const n = r.manifest;
3245
- if (!a || !r.maskTexture)
2674
+ if (!s || !r.maskTexture)
3246
2675
  return;
3247
- const o = Ge(i), l = [0, 1, 2, 3].map((d) => (i.activeTexture(i.TEXTURE0 + d), i.getParameter(i.TEXTURE_BINDING_2D)));
2676
+ const o = Ge(i), c = [0, 1, 2, 3].map((d) => (i.activeTexture(i.TEXTURE0 + d), i.getParameter(i.TEXTURE_BINDING_2D)));
3248
2677
  try {
3249
- const d = !!this.map && ye(this.map, t.defaultProjectionData), c = d ? this.globeProgram : this.mercatorProgram;
3250
- if (!c || !this.map)
2678
+ const d = !!this.map && _e(this.map, t.defaultProjectionData), u = d ? this.globeProgram : this.mercatorProgram;
2679
+ if (!u || !this.map)
3251
2680
  return;
3252
- i.useProgram(c), i.disable(i.DEPTH_TEST), i.disable(i.STENCIL_TEST), i.enable(i.BLEND), i.blendFunc(i.SRC_ALPHA, i.ONE_MINUS_SRC_ALPHA), i.activeTexture(i.TEXTURE0), i.bindTexture(i.TEXTURE_2D, a[0]), i.uniform1i(i.getUniformLocation(c, "u_color"), 0), i.activeTexture(i.TEXTURE3), i.bindTexture(i.TEXTURE_2D, a[1]), i.uniform1i(i.getUniformLocation(c, "u_color_next"), 3), i.uniform1f(i.getUniformLocation(c, "u_mix"), a[2]), i.activeTexture(i.TEXTURE1), i.bindTexture(i.TEXTURE_2D, r.maskTexture), i.uniform1i(i.getUniformLocation(c, "u_mask"), 1), i.activeTexture(i.TEXTURE2), i.bindTexture(i.TEXTURE_2D, this.colorRampTexture), i.uniform1i(i.getUniformLocation(c, "u_color_ramp"), 2), i.uniform1f(i.getUniformLocation(c, "u_opacity"), this.opacity), i.uniform1f(i.getUniformLocation(c, "u_scalar_luma"), 1), i.uniform1f(
3253
- i.getUniformLocation(c, "u_log_scale"),
2681
+ i.useProgram(u), i.disable(i.DEPTH_TEST), i.disable(i.STENCIL_TEST), i.enable(i.BLEND), i.blendFunc(i.SRC_ALPHA, i.ONE_MINUS_SRC_ALPHA), i.activeTexture(i.TEXTURE0), i.bindTexture(i.TEXTURE_2D, s[0]), i.uniform1i(i.getUniformLocation(u, "u_color"), 0), i.activeTexture(i.TEXTURE3), i.bindTexture(i.TEXTURE_2D, s[1]), i.uniform1i(i.getUniformLocation(u, "u_color_next"), 3), i.uniform1f(i.getUniformLocation(u, "u_mix"), s[2]), i.activeTexture(i.TEXTURE1), i.bindTexture(i.TEXTURE_2D, r.maskTexture), i.uniform1i(i.getUniformLocation(u, "u_mask"), 1), i.activeTexture(i.TEXTURE2), i.bindTexture(i.TEXTURE_2D, this.colorRampTexture), i.uniform1i(i.getUniformLocation(u, "u_color_ramp"), 2), i.uniform1f(i.getUniformLocation(u, "u_opacity"), this.opacity), i.uniform1f(i.getUniformLocation(u, "u_scalar_luma"), 1), i.uniform1f(
2682
+ i.getUniformLocation(u, "u_log_scale"),
3254
2683
  this.logScale ? 1 : 0
3255
- ), i.uniform1f(i.getUniformLocation(c, "u_vibrance"), this.vibrance), i.uniform1f(
3256
- i.getUniformLocation(c, "u_mask_threshold"),
2684
+ ), i.uniform1f(i.getUniformLocation(u, "u_vibrance"), this.vibrance), i.uniform1f(
2685
+ i.getUniformLocation(u, "u_mask_threshold"),
3257
2686
  n.mask.threshold
3258
2687
  );
3259
- const { codeRange: u, valueRange: f, transfer: m } = Jt(
2688
+ const { codeRange: h, valueRange: v, transfer: m } = Qt(
3260
2689
  n.encoding
3261
2690
  );
3262
2691
  i.uniform1f(
3263
- i.getUniformLocation(c, "u_scalar_transfer"),
2692
+ i.getUniformLocation(u, "u_scalar_transfer"),
3264
2693
  m
3265
2694
  );
3266
- const p = this.colorDomain ?? f;
2695
+ const f = this.colorDomain ?? v;
3267
2696
  i.uniform2f(
3268
- i.getUniformLocation(c, "u_code_range"),
3269
- ...u
2697
+ i.getUniformLocation(u, "u_code_range"),
2698
+ ...h
3270
2699
  ), i.uniform2f(
3271
- i.getUniformLocation(c, "u_value_range"),
3272
- ...f
2700
+ i.getUniformLocation(u, "u_value_range"),
2701
+ ...v
3273
2702
  ), i.uniform2f(
3274
- i.getUniformLocation(c, "u_color_domain"),
3275
- p[0],
3276
- p[1]
2703
+ i.getUniformLocation(u, "u_color_domain"),
2704
+ f[0],
2705
+ f[1]
3277
2706
  ), i.uniformMatrix4fv(
3278
- i.getUniformLocation(c, "u_matrix"),
2707
+ i.getUniformLocation(u, "u_matrix"),
3279
2708
  !1,
3280
2709
  t.modelViewProjectionMatrix instanceof Float32Array ? t.modelViewProjectionMatrix : new Float32Array(Array.from(t.modelViewProjectionMatrix))
3281
2710
  );
3282
- const [h, g, x, T] = n.bounds, M = x < h ? x + 360 : x;
2711
+ const [l, p, x, T] = n.bounds, R = x < l ? x + 360 : x;
3283
2712
  if (i.uniform4f(
3284
- i.getUniformLocation(c, "u_geo_bounds"),
3285
- h,
3286
- g,
3287
- M,
2713
+ i.getUniformLocation(u, "u_geo_bounds"),
2714
+ l,
2715
+ p,
2716
+ R,
3288
2717
  T
3289
- ), this.bindGrid(i, c), d) {
2718
+ ), this.bindGrid(i, u), d) {
3290
2719
  const y = t.defaultProjectionData.clippingPlane;
3291
2720
  i.uniform4f(
3292
- i.getUniformLocation(c, "u_clipping_plane"),
2721
+ i.getUniformLocation(u, "u_clipping_plane"),
3293
2722
  ...y
3294
- ), vt(
2723
+ ), pt(
3295
2724
  i,
3296
2725
  {
3297
2726
  u_projection_transition: i.getUniformLocation(
3298
- c,
2727
+ u,
3299
2728
  "u_projection_transition"
3300
2729
  ),
3301
2730
  u_fallback_matrix: i.getUniformLocation(
3302
- c,
2731
+ u,
3303
2732
  "u_fallback_matrix"
3304
2733
  )
3305
2734
  },
@@ -3307,20 +2736,20 @@ class G {
3307
2736
  ), i.drawElements(i.TRIANGLES, this.indexCount, i.UNSIGNED_SHORT, 0);
3308
2737
  } else {
3309
2738
  const y = 512 * Math.pow(2, this.map.getZoom());
3310
- i.uniform1f(i.getUniformLocation(c, "u_world_size"), y);
3311
- for (const v of Be(
2739
+ i.uniform1f(i.getUniformLocation(u, "u_world_size"), y);
2740
+ for (const g of Ne(
3312
2741
  this.map.getBounds(),
3313
2742
  !1
3314
2743
  ))
3315
2744
  i.uniform1f(
3316
- i.getUniformLocation(c, "u_world_offset"),
3317
- v
2745
+ i.getUniformLocation(u, "u_world_offset"),
2746
+ g
3318
2747
  ), i.drawElements(i.TRIANGLES, this.indexCount, i.UNSIGNED_SHORT, 0);
3319
2748
  }
3320
- this.unbindGrid(i, c);
2749
+ this.unbindGrid(i, u);
3321
2750
  } finally {
3322
- l.forEach((d, c) => {
3323
- i.activeTexture(i.TEXTURE0 + c), i.bindTexture(i.TEXTURE_2D, d);
2751
+ c.forEach((d, u) => {
2752
+ i.activeTexture(i.TEXTURE0 + u), i.bindTexture(i.TEXTURE_2D, d);
3324
2753
  }), Oe(i, o);
3325
2754
  }
3326
2755
  }
@@ -3360,7 +2789,7 @@ class G {
3360
2789
  setColorRamp(e) {
3361
2790
  this.colorRamp = e, this.gl && (this.colorRampTexture && this.gl.deleteTexture(this.colorRampTexture), this.colorRampTexture = ge(
3362
2791
  this.gl,
3363
- ke(e)
2792
+ Ce(e)
3364
2793
  )), this.map?.triggerRepaint();
3365
2794
  }
3366
2795
  setLogScale(e) {
@@ -3400,7 +2829,7 @@ class G {
3400
2829
  id: this.id,
3401
2830
  initialized: !!e?.currentPair,
3402
2831
  playing: this.playback.isPlaying(),
3403
- currentTime: e ? e.manifest.timeline.kind === "snapshot-loop" ? (this.playback.time - e.times[0]) / 1e3 : ei(e.manifest, this.playback.time) : 0,
2832
+ currentTime: e ? e.manifest.timeline.kind === "snapshot-loop" ? (this.playback.time - e.times[0]) / 1e3 : Kt(e.manifest, this.playback.time) : 0,
3404
2833
  manifestId: this.manifest?.id,
3405
2834
  mediaUrl: this.manifest?.media.url,
3406
2835
  preloadedMediaUrl: this.playback.preloadedMediaUrl,
@@ -3424,28 +2853,28 @@ class G {
3424
2853
  return this.listeners.get(e)?.delete(t), this;
3425
2854
  }
3426
2855
  initGl(e) {
3427
- this.mercatorProgram = W(e, Tt, Ke), this.globeProgram = W(e, Mt, Ke), this.colorRampTexture = ge(
2856
+ this.mercatorProgram = q(e, St, je), this.globeProgram = q(e, wt, je), this.colorRampTexture = ge(
3428
2857
  e,
3429
- ke(this.colorRamp)
2858
+ Ce(this.colorRamp)
3430
2859
  );
3431
2860
  const t = new Float32Array(
3432
2861
  (Z + 1) * (te + 1) * 2
3433
2862
  );
3434
2863
  let i = 0;
3435
2864
  for (let o = 0; o <= te; o++)
3436
- for (let l = 0; l <= Z; l++)
3437
- t[i++] = l / Z, t[i++] = o / te;
3438
- const a = new Uint16Array(Z * te * 6);
2865
+ for (let c = 0; c <= Z; c++)
2866
+ t[i++] = c / Z, t[i++] = o / te;
2867
+ const s = new Uint16Array(Z * te * 6);
3439
2868
  let r = 0;
3440
2869
  const n = Z + 1;
3441
2870
  for (let o = 0; o < te; o++)
3442
- for (let l = 0; l < Z; l++) {
3443
- const d = o * n + l, c = d + 1, u = d + n, f = u + 1;
3444
- a[r++] = d, a[r++] = u, a[r++] = c, a[r++] = c, a[r++] = u, a[r++] = f;
2871
+ for (let c = 0; c < Z; c++) {
2872
+ const d = o * n + c, u = d + 1, h = d + n, v = h + 1;
2873
+ s[r++] = d, s[r++] = h, s[r++] = u, s[r++] = u, s[r++] = h, s[r++] = v;
3445
2874
  }
3446
2875
  if (this.vertexBuffer = e.createBuffer(), this.indexBuffer = e.createBuffer(), !this.vertexBuffer || !this.indexBuffer)
3447
2876
  throw new Error("Failed to create GeoVideo grid");
3448
- e.bindBuffer(e.ARRAY_BUFFER, this.vertexBuffer), e.bufferData(e.ARRAY_BUFFER, t, e.STATIC_DRAW), e.bindBuffer(e.ELEMENT_ARRAY_BUFFER, this.indexBuffer), e.bufferData(e.ELEMENT_ARRAY_BUFFER, a, e.STATIC_DRAW), this.indexCount = a.length;
2877
+ e.bindBuffer(e.ARRAY_BUFFER, this.vertexBuffer), e.bufferData(e.ARRAY_BUFFER, t, e.STATIC_DRAW), e.bindBuffer(e.ELEMENT_ARRAY_BUFFER, this.indexBuffer), e.bufferData(e.ELEMENT_ARRAY_BUFFER, s, e.STATIC_DRAW), this.indexCount = s.length;
3449
2878
  }
3450
2879
  bindGrid(e, t) {
3451
2880
  const i = e.getAttribLocation(t, "a_grid_uv");
@@ -3459,89 +2888,89 @@ class G {
3459
2888
  i(...t);
3460
2889
  }
3461
2890
  }
3462
- function $e(s) {
3463
- return typeof s == "string" ? s : new Date(s).toISOString();
2891
+ function Be(a) {
2892
+ return typeof a == "string" ? a : new Date(a).toISOString();
3464
2893
  }
3465
- function j(s) {
3466
- return encodeURIComponent(String(s));
2894
+ function j(a) {
2895
+ return encodeURIComponent(String(a));
3467
2896
  }
3468
- function Dt(s, e) {
3469
- return e === "depth" ? -Math.abs(s) : s;
2897
+ function Et(a, e) {
2898
+ return e === "depth" ? -Math.abs(a) : a;
3470
2899
  }
3471
- function Yi(s) {
3472
- let e = s.template.replace(/\{TileMatrix\}/gi, "{z}").replace(/\{TileRow\}/gi, "{y}").replace(/\{TileCol\}/gi, "{x}");
3473
- return s.tileMatrixSet != null && (e = e.replace(
2900
+ function Gi(a) {
2901
+ let e = a.template.replace(/\{TileMatrix\}/gi, "{z}").replace(/\{TileRow\}/gi, "{y}").replace(/\{TileCol\}/gi, "{x}");
2902
+ return a.tileMatrixSet != null && (e = e.replace(
3474
2903
  /\{TileMatrixSet\}/gi,
3475
- j(s.tileMatrixSet)
3476
- )), s.style != null && (e = e.replace(/\{Style\}/gi, j(s.style))), s.time != null && (e = e.replace(/\{time\}/gi, j($e(s.time)))), s.depth != null && (e = e.replace(
2904
+ j(a.tileMatrixSet)
2905
+ )), a.style != null && (e = e.replace(/\{Style\}/gi, j(a.style))), a.time != null && (e = e.replace(/\{time\}/gi, j(Be(a.time)))), a.depth != null && (e = e.replace(
3477
2906
  /\{elevation\}/gi,
3478
- j(Dt(s.depth, s.verticalLabel))
2907
+ j(Et(a.depth, a.verticalLabel))
3479
2908
  )), [...e.matchAll(/\{([^{}]+)\}/g)].some(
3480
2909
  (t) => !/^(?:z|y|x)$/i.test(t[1])
3481
2910
  ) ? void 0 : e;
3482
2911
  }
3483
- function Je(s) {
2912
+ function Qe(a) {
3484
2913
  const e = [
3485
2914
  ["SERVICE", "WMTS"],
3486
2915
  ["VERSION", "1.0.0"],
3487
2916
  ["REQUEST", "GetTile"],
3488
- ["LAYER", s.layer],
3489
- ["FORMAT", s.format],
3490
- ["TILEMATRIXSET", s.tileMatrixSet],
2917
+ ["LAYER", a.layer],
2918
+ ["FORMAT", a.format],
2919
+ ["TILEMATRIXSET", a.tileMatrixSet],
3491
2920
  ["TILEMATRIX", "{z}"],
3492
2921
  ["TILEROW", "{y}"],
3493
2922
  ["TILECOL", "{x}"]
3494
2923
  ];
3495
- s.style && e.push(["STYLE", s.style]), s.time != null && e.push(["time", $e(s.time)]), s.depth != null && e.push([
2924
+ a.style && e.push(["STYLE", a.style]), a.time != null && e.push(["time", Be(a.time)]), a.depth != null && e.push([
3496
2925
  "elevation",
3497
- String(Dt(s.depth, s.verticalLabel))
2926
+ String(Et(a.depth, a.verticalLabel))
3498
2927
  ]);
3499
2928
  const t = e.map(
3500
- ([i, a]) => `${i}=${a.startsWith("{") ? a : j(a)}`
2929
+ ([i, s]) => `${i}=${s.startsWith("{") ? s : j(s)}`
3501
2930
  ).join("&");
3502
- return `${s.baseUrl}?${t}`;
2931
+ return `${a.baseUrl}?${t}`;
3503
2932
  }
3504
- function Zi(s) {
2933
+ function Oi(a) {
3505
2934
  const e = [
3506
2935
  ["SERVICE", "WMTS"],
3507
2936
  ["REQUEST", "GetLegend"],
3508
- ["LAYER", s.layer],
3509
- ["FORMAT", s.format ?? "image/svg+xml"]
2937
+ ["LAYER", a.layer],
2938
+ ["FORMAT", a.format ?? "image/svg+xml"]
3510
2939
  ];
3511
- return s.style && e.push(["STYLE", s.style]), `${s.baseUrl}?${e.map(([t, i]) => `${t}=${j(i)}`).join("&")}`;
2940
+ return a.style && e.push(["STYLE", a.style]), `${a.baseUrl}?${e.map(([t, i]) => `${t}=${j(i)}`).join("&")}`;
3512
2941
  }
3513
- function ji(s) {
3514
- return s.sourceConfig.type === "wmts" ? "scalar-wmts" : s.sourceConfig.type === "geovideo" ? s.entry.kind === "vector" ? "vector-geovideo" : "scalar-geovideo" : s.entry.kind === "vector" ? "vector-zarr" : "scalar-zarr";
2942
+ function Ni(a) {
2943
+ return a.sourceConfig.type === "wmts" ? "scalar-wmts" : a.sourceConfig.type === "geovideo" ? a.entry.kind === "vector" ? "vector-geovideo" : "scalar-geovideo" : a.entry.kind === "vector" ? "vector-zarr" : "scalar-zarr";
3515
2944
  }
3516
- function Qi(s) {
3517
- return s.variables.kind === "scalar" ? s.variables.value : "scalar";
2945
+ function Bi(a) {
2946
+ return a.variables.kind === "scalar" ? a.variables.value : "scalar";
3518
2947
  }
3519
- function Ki(s) {
3520
- return s.variables.kind === "vector" ? s.variables.u ?? "uo" : "uo";
2948
+ function $i(a) {
2949
+ return a.variables.kind === "vector" ? a.variables.u ?? "uo" : "uo";
3521
2950
  }
3522
- function Ji(s) {
3523
- return s.variables.kind === "vector" ? s.variables.v ?? "vo" : "vo";
2951
+ function qi(a) {
2952
+ return a.variables.kind === "vector" ? a.variables.v ?? "vo" : "vo";
3524
2953
  }
3525
- function ea(s) {
3526
- return s.variables.kind === "vector" ? s.variables.derivation : void 0;
2954
+ function Wi(a) {
2955
+ return a.variables.kind === "vector" ? a.variables.derivation : void 0;
3527
2956
  }
3528
- class ta {
2957
+ class Xi {
3529
2958
  constructor(e) {
3530
- if (this.type = "custom", this.renderingMode = "3d", this.delegate = null, this.map = null, this.suspended = !1, this.listeners = /* @__PURE__ */ new Map(), this.options = e, this.id = e.id, this.metadata = e.metadata ? { ...e.metadata } : void 0, this.backend = ji(e), this.rasterSourceId = `${e.id}-wmts-source`, this.rasterLayerId = `${e.id}-wmts`, this.time = e.time ?? 0, this.depth = e.depth ?? 0, this.opacity = e.opacity ?? 1, this.backend === "vector-zarr") {
2959
+ if (this.type = "custom", this.renderingMode = "3d", this.delegate = null, this.map = null, this.suspended = !1, this.listeners = /* @__PURE__ */ new Map(), this.options = e, this.id = e.id, this.metadata = e.metadata ? { ...e.metadata } : void 0, this.backend = Ni(e), this.rasterSourceId = `${e.id}-wmts-source`, this.rasterLayerId = `${e.id}-wmts`, this.time = e.time ?? 0, this.depth = e.depth ?? 0, this.opacity = e.opacity ?? 1, this.backend === "vector-zarr") {
3531
2960
  const t = e.sourceConfig;
3532
- this.delegate = new P({
2961
+ this.delegate = new M({
3533
2962
  ...e,
3534
2963
  source: t.endpoints.field,
3535
2964
  zarrSource: e.zarrSource,
3536
- variableU: Ki(t),
3537
- variableV: Ji(t),
3538
- vectorDerivation: ea(t),
2965
+ variableU: $i(t),
2966
+ variableV: qi(t),
2967
+ vectorDerivation: Wi(t),
3539
2968
  unit: e.unit ?? ""
3540
2969
  });
3541
2970
  } else if (this.backend === "vector-geovideo") {
3542
2971
  if (!e.geoVideoManifest)
3543
2972
  throw new Error("Vector GeoVideo requires a loaded manifest");
3544
- this.delegate = new P({
2973
+ this.delegate = new M({
3545
2974
  ...e,
3546
2975
  source: e.geoVideoManifest.media.url,
3547
2976
  geoVideo: {
@@ -3562,7 +2991,7 @@ class ta {
3562
2991
  id: e.id,
3563
2992
  source: t.endpoints.field,
3564
2993
  zarrSource: e.zarrSource,
3565
- variable: Qi(t),
2994
+ variable: Bi(t),
3566
2995
  time: e.time,
3567
2996
  depth: e.depth,
3568
2997
  colorRamp: e.colorRamp,
@@ -3593,7 +3022,7 @@ class ta {
3593
3022
  vibrance: e.vibrance
3594
3023
  });
3595
3024
  }
3596
- this.delegate instanceof P && this.backend === "vector-geovideo" && this.delegate.on("timeChange", (t) => {
3025
+ this.delegate instanceof M && this.backend === "vector-geovideo" && this.delegate.on("timeChange", (t) => {
3597
3026
  this.time = t;
3598
3027
  });
3599
3028
  }
@@ -3681,16 +3110,16 @@ class ta {
3681
3110
  }
3682
3111
  }
3683
3112
  setSpeed(e) {
3684
- this.delegate instanceof P && this.delegate.setSpeed(e);
3113
+ this.delegate instanceof M && this.delegate.setSpeed(e);
3685
3114
  }
3686
3115
  setFade(e) {
3687
- this.delegate instanceof P && this.delegate.setFade(e);
3116
+ this.delegate instanceof M && this.delegate.setFade(e);
3688
3117
  }
3689
3118
  setParticleDensity(e) {
3690
- this.delegate instanceof P && this.delegate.setParticleDensity(e);
3119
+ this.delegate instanceof M && this.delegate.setParticleDensity(e);
3691
3120
  }
3692
3121
  setRenderMode(e) {
3693
- this.delegate instanceof P && this.delegate.setRenderMode(e);
3122
+ this.delegate instanceof M && this.delegate.setRenderMode(e);
3694
3123
  }
3695
3124
  setRgba8MaxParticleZoom(e) {
3696
3125
  this.delegate?.setRgba8MaxParticleZoom(e);
@@ -3706,34 +3135,34 @@ class ta {
3706
3135
  this.map?.getLayer(this.rasterLayerId) && this.map.setPaintProperty(this.rasterLayerId, "raster-opacity", e);
3707
3136
  }
3708
3137
  setLogScale(e) {
3709
- this.delegate instanceof me && this.delegate.setLogScale(e), this.delegate instanceof P && this.delegate.setLogScale(e), this.delegate instanceof G && this.delegate.setLogScale(e);
3138
+ this.delegate instanceof me && this.delegate.setLogScale(e), this.delegate instanceof M && this.delegate.setLogScale(e), this.delegate instanceof G && this.delegate.setLogScale(e);
3710
3139
  }
3711
3140
  setVibrance(e) {
3712
3141
  this.delegate?.setVibrance(e);
3713
3142
  }
3714
3143
  /** Particle trails only; rasters ignore it. */
3715
3144
  setColorGrade(e) {
3716
- this.delegate instanceof P && this.delegate.setColorGrade(e);
3145
+ this.delegate instanceof M && this.delegate.setColorGrade(e);
3717
3146
  }
3718
3147
  /** Under particle trails only; rasters ignore it. */
3719
3148
  setBackdrop(e) {
3720
- this.delegate instanceof P && this.delegate.setBackdrop(e);
3149
+ this.delegate instanceof M && this.delegate.setBackdrop(e);
3721
3150
  }
3722
3151
  /** Particle trails only; rasters ignore it. */
3723
3152
  setGlow(e) {
3724
- this.delegate instanceof P && this.delegate.setGlow(e);
3153
+ this.delegate instanceof M && this.delegate.setGlow(e);
3725
3154
  }
3726
3155
  setColorDomain(e) {
3727
3156
  this.delegate instanceof me && this.delegate.setColorDomain(e), this.delegate instanceof G && this.delegate.setColorDomain(e);
3728
3157
  }
3729
3158
  async play() {
3730
- (this.delegate instanceof G || this.delegate instanceof P) && await this.delegate.play();
3159
+ (this.delegate instanceof G || this.delegate instanceof M) && await this.delegate.play();
3731
3160
  }
3732
3161
  pause() {
3733
- (this.delegate instanceof G || this.delegate instanceof P) && this.delegate.pause();
3162
+ (this.delegate instanceof G || this.delegate instanceof M) && this.delegate.pause();
3734
3163
  }
3735
3164
  setLoop(e) {
3736
- (this.delegate instanceof G || this.delegate instanceof P) && this.delegate.setLoop(e);
3165
+ (this.delegate instanceof G || this.delegate instanceof M) && this.delegate.setLoop(e);
3737
3166
  }
3738
3167
  /** Media rate multiplier of a scalar GeoVideo. */
3739
3168
  setPlaybackRate(e) {
@@ -3741,21 +3170,21 @@ class ta {
3741
3170
  }
3742
3171
  /** Cadence of the continuous vector GeoVideo clock. */
3743
3172
  setStepsPerSecond(e) {
3744
- this.delegate instanceof P && this.delegate.setStepsPerSecond(e);
3173
+ this.delegate instanceof M && this.delegate.setStepsPerSecond(e);
3745
3174
  }
3746
3175
  setTimeRange(e) {
3747
- (this.delegate instanceof G || this.delegate instanceof P) && this.delegate.setTimeRange(e);
3176
+ (this.delegate instanceof G || this.delegate instanceof M) && this.delegate.setTimeRange(e);
3748
3177
  }
3749
3178
  /**
3750
3179
  * Move a GeoVideo to another artifact, such as the next archive
3751
3180
  * chunk, without rebuilding the map layer. False when a new layer is needed.
3752
3181
  */
3753
3182
  replaceGeoVideoManifest(e, t) {
3754
- return this.suspended || !(this.delegate instanceof G || this.delegate instanceof P) || !this.delegate.replaceManifest(e, t) ? !1 : (t.time != null && (this.time = t.time), !0);
3183
+ return this.suspended || !(this.delegate instanceof G || this.delegate instanceof M) || !this.delegate.replaceManifest(e, t) ? !1 : (t.time != null && (this.time = t.time), !0);
3755
3184
  }
3756
3185
  /** Load the GeoVideo artifact expected next, such as the next archive chunk. */
3757
3186
  preloadGeoVideoManifest(e, t) {
3758
- return !this.suspended && (this.delegate instanceof G || this.delegate instanceof P) && this.delegate.preloadManifest(e, t);
3187
+ return !this.suspended && (this.delegate instanceof G || this.delegate instanceof M) && this.delegate.preloadManifest(e, t);
3759
3188
  }
3760
3189
  async samplePoint(e) {
3761
3190
  if (this.delegate instanceof me)
@@ -3772,14 +3201,14 @@ class ta {
3772
3201
  return;
3773
3202
  this.removeWmts();
3774
3203
  const e = this.options.sourceConfig, t = e.tileUrlTemplate ? [
3775
- Yi({
3204
+ Gi({
3776
3205
  template: e.tileUrlTemplate,
3777
3206
  tileMatrixSet: e.tileMatrixSet,
3778
3207
  style: e.style,
3779
3208
  time: this.time,
3780
3209
  depth: this.depth,
3781
3210
  verticalLabel: this.options.verticalLabel
3782
- }) ?? Je({
3211
+ }) ?? Qe({
3783
3212
  baseUrl: e.baseUrl ?? new URL(e.capabilitiesUrl).origin,
3784
3213
  layer: e.layer,
3785
3214
  tileMatrixSet: e.tileMatrixSet ?? "EPSG:3857",
@@ -3790,7 +3219,7 @@ class ta {
3790
3219
  verticalLabel: this.options.verticalLabel
3791
3220
  })
3792
3221
  ] : [
3793
- Je({
3222
+ Qe({
3794
3223
  baseUrl: e.baseUrl ?? new URL(e.capabilitiesUrl).origin,
3795
3224
  layer: e.layer,
3796
3225
  tileMatrixSet: e.tileMatrixSet ?? "EPSG:3857",
@@ -3824,15 +3253,15 @@ class ta {
3824
3253
  min: 0,
3825
3254
  max: 0,
3826
3255
  unit: this.options.unit ?? "",
3827
- time: $e(this.time),
3256
+ time: Be(this.time),
3828
3257
  depth: this.depth
3829
3258
  }), this.emit("status", { phase: "ready", time: e });
3830
3259
  }
3831
3260
  emit(e, ...t) {
3832
3261
  const i = this.listeners.get(e);
3833
3262
  if (i)
3834
- for (const a of i)
3835
- a(...t);
3263
+ for (const s of i)
3264
+ s(...t);
3836
3265
  }
3837
3266
  /** The WMTS raster takes the place of this custom layer, right above it. */
3838
3267
  getBeforeLayerId() {
@@ -3843,113 +3272,113 @@ class ta {
3843
3272
  return i && this.map?.getLayer(i) ? i : void 0;
3844
3273
  }
3845
3274
  }
3846
- function Pe(s, e) {
3847
- return s.match(new RegExp(`\\b${e}=["']([^"']+)["']`, "i"))?.[1].replace(/&amp;/g, "&").replace(/&quot;/g, '"').replace(/&apos;/g, "'");
3275
+ function Me(a, e) {
3276
+ return a.match(new RegExp(`\\b${e}=["']([^"']+)["']`, "i"))?.[1].replace(/&amp;/g, "&").replace(/&quot;/g, '"').replace(/&apos;/g, "'");
3848
3277
  }
3849
- function ia(s, e, t) {
3850
- const i = s.replace(/\{TileMatrix\}/gi, "{z}").replace(/\{TileRow\}/gi, "{y}").replace(/\{TileCol\}/gi, "{x}").replace(/\{TileMatrixSet\}/gi, e), a = t == null ? i : i.replace(/\{Style\}/gi, t);
3851
- return [...a.matchAll(/\{([^{}]+)\}/g)].some(
3278
+ function Hi(a, e, t) {
3279
+ const i = a.replace(/\{TileMatrix\}/gi, "{z}").replace(/\{TileRow\}/gi, "{y}").replace(/\{TileCol\}/gi, "{x}").replace(/\{TileMatrixSet\}/gi, e), s = t == null ? i : i.replace(/\{Style\}/gi, t);
3280
+ return [...s.matchAll(/\{([^{}]+)\}/g)].some(
3852
3281
  (n) => !/^(?:z|y|x|Time|Elevation)$/i.test(n[1])
3853
- ) ? void 0 : a;
3282
+ ) ? void 0 : s;
3854
3283
  }
3855
- function At(s) {
3856
- return s.replace(/<[^>]+>/g, "").trim();
3284
+ function Lt(a) {
3285
+ return a.replace(/<[^>]+>/g, "").trim();
3857
3286
  }
3858
- function be(s, e) {
3287
+ function be(a, e) {
3859
3288
  const t = new RegExp(
3860
3289
  `<(?:(?:\\w+):)?${e}\\b[^>]*>([\\s\\S]*?)<\\/(?:(?:\\w+):)?${e}>`,
3861
3290
  "gi"
3862
3291
  );
3863
- return [...s.matchAll(t)].map((i) => i[1]);
3292
+ return [...a.matchAll(t)].map((i) => i[1]);
3864
3293
  }
3865
- function se(s, e) {
3866
- return be(s, e).map(At).find(Boolean);
3294
+ function se(a, e) {
3295
+ return be(a, e).map(Lt).find(Boolean);
3867
3296
  }
3868
- function et(s, e) {
3297
+ function Ke(a, e) {
3869
3298
  const t = e.match(
3870
3299
  /^P(?:(\d+)Y)?(?:(\d+)M)?(?:(\d+)D)?(?:T(?:(\d+)H)?(?:(\d+)M)?(?:(\d+)S)?)?$/
3871
3300
  );
3872
3301
  if (!t || !t.slice(1).some((m) => Number(m) > 0))
3873
3302
  return;
3874
- const i = new Date(s), a = i.getUTCFullYear() + Number(t[1] ?? 0), r = i.getUTCMonth() + Number(t[2] ?? 0), n = i.getUTCDate(), o = i.getUTCHours(), l = i.getUTCMinutes(), d = i.getUTCSeconds(), c = i.getUTCMilliseconds(), u = new Date(
3875
- Date.UTC(a, r, 1, o, l, d, c)
3876
- ), f = new Date(
3877
- Date.UTC(u.getUTCFullYear(), u.getUTCMonth() + 1, 0)
3303
+ const i = new Date(a), s = i.getUTCFullYear() + Number(t[1] ?? 0), r = i.getUTCMonth() + Number(t[2] ?? 0), n = i.getUTCDate(), o = i.getUTCHours(), c = i.getUTCMinutes(), d = i.getUTCSeconds(), u = i.getUTCMilliseconds(), h = new Date(
3304
+ Date.UTC(s, r, 1, o, c, d, u)
3305
+ ), v = new Date(
3306
+ Date.UTC(h.getUTCFullYear(), h.getUTCMonth() + 1, 0)
3878
3307
  ).getUTCDate();
3879
- return u.setUTCDate(Math.min(n, f)), u.setUTCDate(u.getUTCDate() + Number(t[3] ?? 0)), u.setUTCHours(u.getUTCHours() + Number(t[4] ?? 0)), u.setUTCMinutes(u.getUTCMinutes() + Number(t[5] ?? 0)), u.setUTCSeconds(u.getUTCSeconds() + Number(t[6] ?? 0)), u.getTime();
3308
+ return h.setUTCDate(Math.min(n, v)), h.setUTCDate(h.getUTCDate() + Number(t[3] ?? 0)), h.setUTCHours(h.getUTCHours() + Number(t[4] ?? 0)), h.setUTCMinutes(h.getUTCMinutes() + Number(t[5] ?? 0)), h.setUTCSeconds(h.getUTCSeconds() + Number(t[6] ?? 0)), h.getTime();
3880
3309
  }
3881
- function aa(s) {
3310
+ function Yi(a) {
3882
3311
  const e = [];
3883
- for (const t of s.flatMap((i) => i.split(","))) {
3312
+ for (const t of a.flatMap((i) => i.split(","))) {
3884
3313
  const i = t.trim().split("/");
3885
3314
  if (i.length === 3) {
3886
- const r = Date.parse(i[0]), n = Date.parse(i[1]), o = et(r, i[2]);
3315
+ const r = Date.parse(i[0]), n = Date.parse(i[1]), o = Ke(r, i[2]);
3887
3316
  if (Number.isFinite(r) && Number.isFinite(n) && o && o > r)
3888
- for (let l = r, d = 0; l <= n && d < 1e5; d += 1)
3889
- e.push(l), l = et(l, i[2]);
3317
+ for (let c = r, d = 0; c <= n && d < 1e5; d += 1)
3318
+ e.push(c), c = Ke(c, i[2]);
3890
3319
  continue;
3891
3320
  }
3892
- const a = Date.parse(t.trim());
3893
- Number.isFinite(a) && e.push(a);
3321
+ const s = Date.parse(t.trim());
3322
+ Number.isFinite(s) && e.push(s);
3894
3323
  }
3895
3324
  return [...new Set(e)].sort((t, i) => t - i);
3896
3325
  }
3897
- function tt(s, e) {
3898
- for (const t of be(s, "Dimension"))
3326
+ function Je(a, e) {
3327
+ for (const t of be(a, "Dimension"))
3899
3328
  if (se(t, "Identifier")?.toLowerCase() === e.toLowerCase())
3900
- return be(t, "Value").map(At);
3329
+ return be(t, "Value").map(Lt);
3901
3330
  return [];
3902
3331
  }
3903
- function sa(s, e) {
3904
- const t = be(s, "Layer").find(
3905
- (h) => se(h, "Identifier") === e.layer
3332
+ function Zi(a, e) {
3333
+ const t = be(a, "Layer").find(
3334
+ (l) => se(l, "Identifier") === e.layer
3906
3335
  );
3907
3336
  if (!t)
3908
3337
  throw new Error(`WMTS capabilities do not contain layer: ${e.layer}`);
3909
3338
  const i = e.tileMatrixSet ?? se(t, "TileMatrixSet") ?? "";
3910
3339
  if (!/3857|GoogleMapsCompatible/i.test(i))
3911
3340
  throw new Error(`Unsupported WMTS tile matrix set: ${i || "missing"}`);
3912
- const a = aa(tt(t, "time")), r = a.length ? {
3913
- min: a[0],
3914
- max: a[a.length - 1],
3915
- size: a.length,
3916
- values: a,
3341
+ const s = Yi(Je(t, "time")), r = s.length ? {
3342
+ min: s[0],
3343
+ max: s[s.length - 1],
3344
+ size: s.length,
3345
+ values: s,
3917
3346
  units: "milliseconds since 1970-01-01T00:00:00Z",
3918
- step: a.length > 1 && a.every(
3919
- (h, g) => g === 0 || h - a[g - 1] === a[1] - a[0]
3920
- ) ? a[1] - a[0] : void 0
3921
- } : { min: 0, max: 0, size: 1, values: [0], units: "static" }, n = tt(t, "elevation").flatMap((h) => h.split(",")).map(Number).filter(Number.isFinite), o = n.length ? { name: "elevation", label: "elevation", values: n } : null, l = s.match(
3347
+ step: s.length > 1 && s.every(
3348
+ (l, p) => p === 0 || l - s[p - 1] === s[1] - s[0]
3349
+ ) ? s[1] - s[0] : void 0
3350
+ } : { min: 0, max: 0, size: 1, values: [0], units: "static" }, n = Je(t, "elevation").flatMap((l) => l.split(",")).map(Number).filter(Number.isFinite), o = n.length ? { name: "elevation", label: "elevation", values: n } : null, c = a.match(
3922
3351
  /GetTile[\s\S]*?(?:xlink:href|href)=["']([^"']+)/i
3923
- )?.[1], c = [
3352
+ )?.[1], u = [
3924
3353
  ...t.matchAll(/<(?:(?:\w+):)?ResourceURL\b([^>]*)\/?\s*>/gi)
3925
3354
  ].find(
3926
- (h) => Pe(h[1], "resourceType")?.toLowerCase() === "tile"
3927
- ), u = c ? Pe(c[1], "template") : void 0, f = [
3355
+ (l) => Me(l[1], "resourceType")?.toLowerCase() === "tile"
3356
+ ), h = u ? Me(u[1], "template") : void 0, v = [
3928
3357
  ...t.matchAll(
3929
3358
  /<(?:(?:\w+):)?Style\b([^>]*)>([\s\S]*?)<\/(?:(?:\w+):)?Style>/gi
3930
3359
  )
3931
- ], m = f.find(
3932
- (h) => Pe(h[1], "isDefault")?.toLowerCase() === "true"
3933
- ), p = e.style ?? se(m?.[2] ?? f[0]?.[2] ?? "", "Identifier");
3360
+ ], m = v.find(
3361
+ (l) => Me(l[1], "isDefault")?.toLowerCase() === "true"
3362
+ ), f = e.style ?? se(m?.[2] ?? v[0]?.[2] ?? "", "Identifier");
3934
3363
  return {
3935
- baseUrl: e.baseUrl ?? l ?? new URL(e.capabilitiesUrl).origin,
3936
- tileUrlTemplate: e.tileUrlTemplate ?? (u ? ia(u, i, p) : void 0),
3364
+ baseUrl: e.baseUrl ?? c ?? new URL(e.capabilitiesUrl).origin,
3365
+ tileUrlTemplate: e.tileUrlTemplate ?? (h ? Hi(h, i, f) : void 0),
3937
3366
  tileMatrixSet: i,
3938
3367
  format: e.format ?? se(t, "Format") ?? "image/png",
3939
- style: p,
3368
+ style: f,
3940
3369
  time: r,
3941
3370
  vertical: o
3942
3371
  };
3943
3372
  }
3944
- async function ra(s, e) {
3945
- const t = await fetch(s.capabilitiesUrl, { signal: e });
3373
+ async function ji(a, e) {
3374
+ const t = await fetch(a.capabilitiesUrl, { signal: e });
3946
3375
  if (!t.ok)
3947
3376
  throw new Error(
3948
- `WMTS capabilities request failed (${t.status}): ${s.capabilitiesUrl}`
3377
+ `WMTS capabilities request failed (${t.status}): ${a.capabilitiesUrl}`
3949
3378
  );
3950
- return sa(await t.text(), s);
3379
+ return Zi(await t.text(), a);
3951
3380
  }
3952
- const na = [
3381
+ const Qi = [
3953
3382
  0.25,
3954
3383
  0.5,
3955
3384
  1,
@@ -3958,17 +3387,17 @@ const na = [
3958
3387
  8,
3959
3388
  16,
3960
3389
  32
3961
- ], it = [0.25, 0.5, 1, 2];
3962
- function at(s, e) {
3963
- if (s.length === 0)
3390
+ ], et = [0.25, 0.5, 1, 2];
3391
+ function tt(a, e) {
3392
+ if (a.length === 0)
3964
3393
  return e;
3965
- let t = s[0], i;
3966
- for (const a of s)
3967
- a < t && (t = a), a <= e && (i === void 0 || a > i) && (i = a);
3394
+ let t = a[0], i;
3395
+ for (const s of a)
3396
+ s < t && (t = s), s <= e && (i === void 0 || s > i) && (i = s);
3968
3397
  return i ?? t;
3969
3398
  }
3970
- function oa(s) {
3971
- const e = s.map((n) => new Date(n)), t = (n) => n.every((o) => e.every((l) => o(l) === o(e[0]))), i = [
3399
+ function Ki(a) {
3400
+ const e = a.map((n) => new Date(n)), t = (n) => n.every((o) => e.every((c) => o(c) === o(e[0]))), i = [
3972
3401
  (n) => n.getUTCHours(),
3973
3402
  (n) => n.getUTCMinutes(),
3974
3403
  (n) => n.getUTCSeconds(),
@@ -3979,135 +3408,135 @@ function oa(s) {
3979
3408
  return "year";
3980
3409
  if (t([(o) => o.getUTCDate(), ...i]))
3981
3410
  return "month";
3982
- const n = s.slice(1).map((o, l) => o - s[l]);
3411
+ const n = a.slice(1).map((o, c) => o - a[c]);
3983
3412
  return t(i) && n.every((o) => o % 864e5 === 0) ? "day" : t(i.slice(1)) && n.every((o) => o % 36e5 === 0) ? "hour" : t(i.slice(2)) && n.every((o) => o % 6e4 === 0) ? "minute" : "second";
3984
3413
  }
3985
- const a = e[0];
3986
- if (!a)
3414
+ const s = e[0];
3415
+ if (!s)
3987
3416
  return "second";
3988
- const r = a.getUTCHours() === 0 && a.getUTCMinutes() === 0 && a.getUTCSeconds() === 0 && a.getUTCMilliseconds() === 0;
3989
- return r && a.getUTCMonth() === 0 && a.getUTCDate() === 1 ? "year" : r && a.getUTCDate() === 1 ? "month" : r ? "day" : a.getUTCMinutes() === 0 && a.getUTCSeconds() === 0 && a.getUTCMilliseconds() === 0 ? "hour" : a.getUTCSeconds() === 0 && a.getUTCMilliseconds() === 0 ? "minute" : "second";
3417
+ const r = s.getUTCHours() === 0 && s.getUTCMinutes() === 0 && s.getUTCSeconds() === 0 && s.getUTCMilliseconds() === 0;
3418
+ return r && s.getUTCMonth() === 0 && s.getUTCDate() === 1 ? "year" : r && s.getUTCDate() === 1 ? "month" : r ? "day" : s.getUTCMinutes() === 0 && s.getUTCSeconds() === 0 && s.getUTCMilliseconds() === 0 ? "hour" : s.getUTCSeconds() === 0 && s.getUTCMilliseconds() === 0 ? "minute" : "second";
3990
3419
  }
3991
- function Ct(s) {
3992
- if (s.length < 2)
3420
+ function Dt(a) {
3421
+ if (a.length < 2)
3993
3422
  return;
3994
- const e = s[1] - s[0];
3995
- return s.every(
3996
- (t, i) => i === 0 || t - s[i - 1] === e
3423
+ const e = a[1] - a[0];
3424
+ return a.every(
3425
+ (t, i) => i === 0 || t - a[i - 1] === e
3997
3426
  ) ? e : void 0;
3998
3427
  }
3999
- function re(s, e) {
4000
- return e ? xt(e, [
4001
- s.values[0],
4002
- s.values[s.values.length - 1]
3428
+ function re(a, e) {
3429
+ return e ? yt(e, [
3430
+ a.values[0],
3431
+ a.values[a.values.length - 1]
4003
3432
  ]) : null;
4004
3433
  }
4005
- function ne(s, e) {
4006
- const t = re(s, e);
3434
+ function ne(a, e) {
3435
+ const t = re(a, e);
4007
3436
  if (!t)
4008
- return s;
4009
- const [i, a] = t, r = s.values.filter((n) => n >= i && n <= a);
3437
+ return a;
3438
+ const [i, s] = t, r = a.values.filter((n) => n >= i && n <= s);
4010
3439
  if (r.length === 0)
4011
3440
  throw new RangeError(
4012
3441
  "Time range does not contain any available timestamps"
4013
3442
  );
4014
3443
  return {
4015
- ...s,
3444
+ ...a,
4016
3445
  min: r[0],
4017
3446
  max: r[r.length - 1],
4018
3447
  size: r.length,
4019
- step: Ct(r),
3448
+ step: Dt(r),
4020
3449
  values: r
4021
3450
  };
4022
3451
  }
4023
- function st(s, e) {
4024
- const { start: t, end: i } = s.temporal ?? {};
3452
+ function it(a, e) {
3453
+ const { start: t, end: i } = a.temporal ?? {};
4025
3454
  return t || i ? ne(e, { start: t, end: i }) : e;
4026
3455
  }
4027
- function fe(s) {
4028
- return s.variables.kind === "scalar" ? [s.variables.value] : s.variables.derivation ? [
4029
- s.variables.derivation.direction_variable,
4030
- s.variables.derivation.magnitude_variable
4031
- ] : [s.variables.u ?? "uo", s.variables.v ?? "vo"];
3456
+ function fe(a) {
3457
+ return a.variables.kind === "scalar" ? [a.variables.value] : a.variables.derivation ? [
3458
+ a.variables.derivation.direction_variable,
3459
+ a.variables.derivation.magnitude_variable
3460
+ ] : [a.variables.u ?? "uo", a.variables.v ?? "vo"];
4032
3461
  }
4033
- function Ee(s, e) {
4034
- const t = s.sources.filter(Fe);
3462
+ function Pe(a, e) {
3463
+ const t = a.sources.filter(ke);
4035
3464
  return t.find((i) => i.id === e) ?? (e === "geovideo" || e === "auto" ? t[0] : void 0);
4036
3465
  }
4037
- function kt(s) {
4038
- return [...s].sort((e, t) => {
4039
- const i = Math.abs(e), a = Math.abs(t);
4040
- return i !== a ? i - a : t - e;
3466
+ function At(a) {
3467
+ return [...a].sort((e, t) => {
3468
+ const i = Math.abs(e), s = Math.abs(t);
3469
+ return i !== s ? i - s : t - e;
4041
3470
  });
4042
3471
  }
4043
- function Le(s, e) {
4044
- return s?.values.length ? e == null ? kt(s.values)[0] : U(s.values, e) : e ?? 0;
3472
+ function Ee(a, e) {
3473
+ return a?.values.length ? e == null ? At(a.values)[0] : F(a.values, e) : e ?? 0;
4045
3474
  }
4046
- function U(s, e) {
4047
- if (s.length === 0)
3475
+ function F(a, e) {
3476
+ if (a.length === 0)
4048
3477
  return e;
4049
- let t = s[0], i = Math.abs(t - e);
4050
- for (let a = 1; a < s.length; a++) {
4051
- const r = Math.abs(s[a] - e);
4052
- r < i && (t = s[a], i = r);
3478
+ let t = a[0], i = Math.abs(t - e);
3479
+ for (let s = 1; s < a.length; s++) {
3480
+ const r = Math.abs(a[s] - e);
3481
+ r < i && (t = a[s], i = r);
4053
3482
  }
4054
3483
  return t;
4055
3484
  }
4056
- function rt(s) {
3485
+ function at(a) {
4057
3486
  for (const [e, t] of [
4058
- [s?.playbackRate, "Playback rate"],
4059
- [s?.stepsPerSecond, "Steps per second"]
3487
+ [a?.playbackRate, "Playback rate"],
3488
+ [a?.stepsPerSecond, "Steps per second"]
4060
3489
  ])
4061
3490
  if (e != null && (!Number.isFinite(e) || e <= 0))
4062
3491
  throw new Error(`${t} must be positive`);
4063
3492
  }
4064
- function nt(s, e) {
4065
- const t = s.surface?.value ?? 0, i = U(
4066
- [t, ...s.depths.map((a) => a.value)],
3493
+ function st(a, e) {
3494
+ const t = a.surface?.value ?? 0, i = F(
3495
+ [t, ...a.depths.map((s) => s.value)],
4067
3496
  e
4068
3497
  );
4069
3498
  return i === t ? null : i;
4070
3499
  }
4071
- function la(s) {
4072
- const e = s.surface ?? s.depths[0];
3500
+ function Ji(a) {
3501
+ const e = a.surface ?? a.depths[0];
4073
3502
  return {
4074
3503
  name: e.name,
4075
3504
  label: e.positive === "up" || e.name === "elevation" ? "elevation" : "depth",
4076
3505
  units: e.units || void 0,
4077
3506
  values: [
4078
- s.surface?.value ?? 0,
4079
- ...s.depths.map((t) => t.value)
3507
+ a.surface?.value ?? 0,
3508
+ ...a.depths.map((t) => t.value)
4080
3509
  ]
4081
3510
  };
4082
3511
  }
4083
- function ot(s, e) {
3512
+ function rt(a, e) {
4084
3513
  return JSON.stringify([
4085
- s?.values ?? null,
3514
+ a?.values ?? null,
4086
3515
  e ? [e.name, e.units, e.values] : null
4087
3516
  ]);
4088
3517
  }
4089
- function ca(s) {
4090
- const e = [...new Set(s)].sort((t, i) => t - i);
3518
+ function ea(a) {
3519
+ const e = [...new Set(a)].sort((t, i) => t - i);
4091
3520
  return {
4092
3521
  min: e[0],
4093
3522
  max: e[e.length - 1],
4094
- step: Ct(e),
3523
+ step: Dt(e),
4095
3524
  size: e.length,
4096
3525
  units: "milliseconds since 1970-01-01T00:00:00Z",
4097
3526
  values: e
4098
3527
  };
4099
3528
  }
4100
- const ha = 5 * 6e4, ua = 6e4, lt = 6;
4101
- function pe(s) {
4102
- const { particles: e = {}, raster: t = {} } = s, i = {
4103
- palette: s.palette,
4104
- reversePalette: s.reversePalette,
4105
- renderMode: s.renderMode,
3529
+ const ta = 5 * 6e4, ia = 6e4, nt = 6;
3530
+ function pe(a) {
3531
+ const { particles: e = {}, raster: t = {} } = a, i = {
3532
+ palette: a.palette,
3533
+ reversePalette: a.reversePalette,
3534
+ renderMode: a.renderMode,
4106
3535
  particleDensity: e.density,
4107
3536
  speed: e.speed,
4108
3537
  fade: e.fade,
4109
3538
  glow: e.glow,
4110
- colorGrade: e.grade === void 0 ? void 0 : pi(e.grade),
3539
+ colorGrade: e.grade === void 0 ? void 0 : mi(e.grade),
4111
3540
  opacity: t.opacity,
4112
3541
  logScale: t.logScale,
4113
3542
  vibrance: t.vibrance,
@@ -4118,32 +3547,32 @@ function pe(s) {
4118
3547
  backdrop: e.backdrop && { ...e.backdrop }
4119
3548
  };
4120
3549
  return Object.fromEntries(
4121
- Object.entries(i).filter(([, a]) => a !== void 0)
3550
+ Object.entries(i).filter(([, s]) => s !== void 0)
4122
3551
  );
4123
3552
  }
4124
- function Ue(s) {
4125
- const e = s.alphaFadeLow ?? 0, t = s.alphaFadeHigh ?? 0;
4126
- return e > 0 || t > 0 ? { low: e, high: t, curve: s.alphaFadeCurve ?? "linear" } : void 0;
3553
+ function Ue(a) {
3554
+ const e = a.alphaFadeLow ?? 0, t = a.alphaFadeHigh ?? 0;
3555
+ return e > 0 || t > 0 ? { low: e, high: t, curve: a.alphaFadeCurve ?? "linear" } : void 0;
4127
3556
  }
4128
- const ct = "rdylbu", da = new Set(
4129
- _t({ includeDeprecated: !0 }).map((s) => s.id)
4130
- ), ht = /* @__PURE__ */ new Set();
4131
- function Ne(s) {
4132
- return typeof s != "string" || da.has(s) ? s : (ht.has(s) || (ht.add(s), console.warn(
4133
- `[zartigl] palette "${s}" is not in this version: drawn with "${ct}"`
4134
- )), ct);
3557
+ const ot = "rdylbu", aa = new Set(
3558
+ vt({ includeDeprecated: !0 }).map((a) => a.id)
3559
+ ), lt = /* @__PURE__ */ new Set();
3560
+ function Ie(a) {
3561
+ return typeof a != "string" || aa.has(a) ? a : (lt.has(a) || (lt.add(a), console.warn(
3562
+ `[zartigl] palette "${a}" is not in this version: drawn with "${ot}"`
3563
+ )), ot);
4135
3564
  }
4136
- function De(s) {
4137
- const { reversePalette: e } = s, t = Ne(s.palette), i = Ue(s);
4138
- return t != null && (e || i) ? ke(t, { reverse: e, alphaFade: i }) : t;
3565
+ function Le(a) {
3566
+ const { reversePalette: e } = a, t = Ie(a.palette), i = Ue(a);
3567
+ return t != null && (e || i) ? Ce(t, { reverse: e, alphaFade: i }) : t;
4139
3568
  }
4140
- const ma = [
3569
+ const sa = [
4141
3570
  "palette",
4142
3571
  "reversePalette",
4143
3572
  "alphaFadeLow",
4144
3573
  "alphaFadeHigh",
4145
3574
  "alphaFadeCurve"
4146
- ], Ft = Object.freeze({
3575
+ ], Ct = Object.freeze({
4147
3576
  palette: "style.palette",
4148
3577
  renderMode: "style.renderMode",
4149
3578
  particleDensity: "style.particles.density",
@@ -4156,22 +3585,22 @@ const ma = [
4156
3585
  colorDomain: "style.raster.colorDomain",
4157
3586
  backdrop: "style.particles.backdrop"
4158
3587
  });
4159
- function Ae(s) {
3588
+ function De(a) {
4160
3589
  const {
4161
3590
  palette: e,
4162
3591
  renderMode: t,
4163
3592
  particleDensity: i,
4164
- speed: a,
3593
+ speed: s,
4165
3594
  fade: r,
4166
3595
  colorGrade: n,
4167
3596
  opacity: o,
4168
- logScale: l,
3597
+ logScale: c,
4169
3598
  vibrance: d,
4170
- colorDomain: c,
4171
- backdrop: u,
4172
- ...f
4173
- } = s ?? {}, m = Object.keys(s ?? {}).filter(
4174
- (h) => h in Ft && s[h] !== void 0
3599
+ colorDomain: u,
3600
+ backdrop: h,
3601
+ ...v
3602
+ } = a ?? {}, m = Object.keys(a ?? {}).filter(
3603
+ (l) => l in Ct && a[l] !== void 0
4175
3604
  );
4176
3605
  return {
4177
3606
  style: ae({
@@ -4179,49 +3608,49 @@ function Ae(s) {
4179
3608
  renderMode: t,
4180
3609
  particles: {
4181
3610
  density: i,
4182
- speed: a,
3611
+ speed: s,
4183
3612
  fade: r,
4184
- grade: n && fi(n),
4185
- backdrop: u
3613
+ grade: n && di(n),
3614
+ backdrop: h
4186
3615
  },
4187
- raster: { opacity: o, logScale: l, vibrance: d, colorDomain: c }
3616
+ raster: { opacity: o, logScale: c, vibrance: d, colorDomain: u }
4188
3617
  }),
4189
- settings: e === void 0 || typeof e == "string" ? f : { ...f, palette: e },
3618
+ settings: e === void 0 || typeof e == "string" ? v : { ...v, palette: e },
4190
3619
  legacyKeys: m
4191
3620
  };
4192
3621
  }
4193
- const ut = /* @__PURE__ */ new Set();
4194
- function dt(s) {
4195
- for (const e of s)
4196
- ut.has(e) || (ut.add(e), console.warn(
4197
- `[zartigl] settings.${e} is deprecated: use ${Ft[e]}`
3622
+ const ct = /* @__PURE__ */ new Set();
3623
+ function ut(a) {
3624
+ for (const e of a)
3625
+ ct.has(e) || (ct.add(e), console.warn(
3626
+ `[zartigl] settings.${e} is deprecated: use ${Ct[e]}`
4198
3627
  ));
4199
3628
  }
4200
- function It(s, e) {
4201
- const t = ze(s, e);
3629
+ function kt(a, e) {
3630
+ const t = ze(a, e);
4202
3631
  return {
4203
3632
  ...pe(t),
4204
3633
  palette: t.palette ?? "rdylbu",
4205
3634
  colorDomain: Q(t.raster.colorDomain)
4206
3635
  };
4207
3636
  }
4208
- function fa(s) {
3637
+ function ra(a) {
4209
3638
  return {
4210
- ...It(s),
3639
+ ...kt(a),
4211
3640
  particleState: "auto",
4212
3641
  rgba8MaxParticleZoom: 4
4213
3642
  };
4214
3643
  }
4215
- function pa(s) {
4216
- const { palette: e, ...t } = s;
3644
+ function na(a) {
3645
+ const { palette: e, ...t } = a;
4217
3646
  return t;
4218
3647
  }
4219
- function mt(s, e, t) {
4220
- s !== void 0 && ft(s, "style", {
3648
+ function ht(a, e, t) {
3649
+ a !== void 0 && dt(a, "style", {
4221
3650
  kind: e.layers.find((i) => i.id === t)?.kind
4222
3651
  });
4223
3652
  }
4224
- class Aa {
3653
+ class xa {
4225
3654
  constructor(e) {
4226
3655
  if (this.fullTimeMeta = null, this.autoplayPending = !0, this.playing = !1, this.catalogLayer = null, this.catalogSource = null, this.layer = null, this.time = 0, this.pendingTime = null, this.requestedTime = null, this.playbackIntent = 0, this.requestSeq = 0, this.playSeq = 0, this.depth = 0, this.depthRequest = null, this.failedGeoVideo = /* @__PURE__ */ new Set(), this.lastMeta = null, this.timeMeta = null, this.resolvedTimeRange = null, this.verticalMeta = null, this.variableUnit = "", this.geoVideoManifest = null, this.wmtsMetadata = null, this.fieldSources = /* @__PURE__ */ new Map(), this.archiveChunks = /* @__PURE__ */ new Map(), this.chunkTimes = /* @__PURE__ */ new Map(), this.archiveRoots = /* @__PURE__ */ new Map(), this.archiveLevel = null, this.depthLocked = !1, this.chunkLevels = /* @__PURE__ */ new Map(), this.nextChunkManifest = null, this.activeFieldSource = null, this.switchGeneration = 0, this.destroyed = !1, this.initialized = !1, this.initStarted = !1, this.updateQueue = Promise.resolve(), this.suspended = !1, this.attachQueued = !1, this.anchor = null, this.querySources = /* @__PURE__ */ new Map(), this.listeners = /* @__PURE__ */ new Map(), this.onMapReady = () => {
4227
3656
  this.attachQueued && this.attachWhenReady();
@@ -4229,9 +3658,9 @@ class Aa {
4229
3658
  throw new Error("Zartigl requires a layer UUID");
4230
3659
  if (e.time != null && z(e.time, "time"), e.depth != null && !Number.isFinite(e.depth))
4231
3660
  throw new Error("Depth must be finite");
4232
- rt(e.geoVideo), this.id = e.id ?? "zartigl", this.map = e.map, this.catalog = e.catalog, this.initialLayer = e.layer, this.initialTime = e.time, this.initialDepth = e.depth, this.depthRequest = e.depth ?? null, this.sourcePreference = e.source ?? "auto", this.timeRange = e.timeRange ? { ...e.timeRange } : void 0, this.autoplay = e.geoVideo?.autoplay ?? !0, this.loop = e.geoVideo?.loop ?? !0, this.playbackRate = e.geoVideo?.playbackRate ?? 1, this.stepsPerSecond = e.geoVideo?.stepsPerSecond ?? null, this.metadata = e.metadata ? { ...e.metadata } : void 0, this.before = e.before, this.visible = e.visible ?? !0;
4233
- const t = Ae(e.settings);
4234
- dt(t.legacyKeys), this.style = ae(t.style, e.style), mt(this.style, e.catalog, e.layer), this.settings = { ...t.settings, ...pe(this.style) }, this.settings.colorDomain !== void 0 && (this.settings.colorDomain = Q(
3661
+ at(e.geoVideo), this.id = e.id ?? "zartigl", this.map = e.map, this.catalog = e.catalog, this.initialLayer = e.layer, this.initialTime = e.time, this.initialDepth = e.depth, this.depthRequest = e.depth ?? null, this.sourcePreference = e.source ?? "auto", this.timeRange = e.timeRange ? { ...e.timeRange } : void 0, this.autoplay = e.geoVideo?.autoplay ?? !0, this.loop = e.geoVideo?.loop ?? !0, this.playbackRate = e.geoVideo?.playbackRate ?? 1, this.stepsPerSecond = e.geoVideo?.stepsPerSecond ?? null, this.metadata = e.metadata ? { ...e.metadata } : void 0, this.before = e.before, this.visible = e.visible ?? !0;
3662
+ const t = De(e.settings);
3663
+ ut(t.legacyKeys), this.style = ae(t.style, e.style), ht(this.style, e.catalog, e.layer), this.settings = { ...t.settings, ...pe(this.style) }, this.settings.colorDomain !== void 0 && (this.settings.colorDomain = Q(
4235
3664
  this.settings.colorDomain
4236
3665
  )), this.colorDomainOverridden = this.settings.colorDomain !== void 0, this.paletteOverridden = this.settings.palette !== void 0, this.map.on("load", this.onMapReady), this.map.on("styledata", this.onMapReady), this.map.on("idle", this.onMapReady);
4237
3666
  }
@@ -4248,16 +3677,16 @@ class Aa {
4248
3677
  }
4249
3678
  async update(e) {
4250
3679
  this.assertAlive();
4251
- const t = Ae(e.settings);
4252
- dt(t.legacyKeys);
3680
+ const t = De(e.settings);
3681
+ ut(t.legacyKeys);
4253
3682
  const i = t.legacyKeys.length ? { ...e, settings: t.settings, stylePatch: t.style } : e;
4254
3683
  if (!this.initialized)
4255
3684
  throw new Error("Call init() before update()");
4256
3685
  if (i.depth != null && !Number.isFinite(i.depth))
4257
3686
  throw new Error("Depth must be finite");
4258
- i.time != null && z(i.time, "time"), rt(i.geoVideo), i.settings?.colorDomain !== void 0 && Q(i.settings.colorDomain);
4259
- for (const a of [i.style, i.stylePatch])
4260
- a !== void 0 && ft(a, "style");
3687
+ i.time != null && z(i.time, "time"), at(i.geoVideo), i.settings?.colorDomain !== void 0 && Q(i.settings.colorDomain);
3688
+ for (const s of [i.style, i.stylePatch])
3689
+ s !== void 0 && dt(s, "style");
4261
3690
  return i.time != null && this.pause(), this.enqueue(i, ++this.requestSeq);
4262
3691
  }
4263
3692
  /**
@@ -4267,7 +3696,7 @@ class Aa {
4267
3696
  enqueue(e, t) {
4268
3697
  const i = e.layer != null && e.layer !== this.catalogLayer?.id;
4269
3698
  e.time != null ? (this.playbackIntent += 1, this.requestedTime = z(e.time, "time")) : i && (this.requestedTime = null), e.depth != null ? (this.depthRequest = e.depth, this.playbackIntent += 1) : i && (this.depthRequest = null);
4270
- const a = e.layer != null ? ++this.switchGeneration : void 0, r = e.layer != null ? this.applyUpdate(e, a, t) : this.updateQueue.then(() => this.applyUpdate(e, void 0, t));
3699
+ const s = e.layer != null ? ++this.switchGeneration : void 0, r = e.layer != null ? this.applyUpdate(e, s, t) : this.updateQueue.then(() => this.applyUpdate(e, void 0, t));
4271
3700
  if (this.updateQueue = r.catch(() => {
4272
3701
  }), e.depth != null) {
4273
3702
  const n = e.depth;
@@ -4279,14 +3708,14 @@ class Aa {
4279
3708
  }
4280
3709
  async applyUpdate(e, t, i) {
4281
3710
  this.assertAlive(), i != null && e.time != null && this.playSeq !== 0 && this.playSeq < i && this.pause();
4282
- const a = e.layer != null && e.layer !== this.catalogLayer?.id, r = e.source != null && (a || e.source !== this.sourcePreference), n = !a && e.source === "auto" && this.sourcePreference === "auto", o = { time: e.time, depth: e.depth }, l = a ? e.layer : this.catalogLayer?.id, d = e.stylePatch === void 0 ? e.style : e.style === void 0 ? ae(this.style, e.stylePatch) : ae(e.stylePatch, e.style), c = e.settings?.palette, u = d !== void 0 && c !== void 0 && typeof c != "string" && e.style?.palette === void 0 ? pa(d) : d;
4283
- mt(u, this.catalog, l);
4284
- const f = u ?? (a ? pt(
3711
+ const s = e.layer != null && e.layer !== this.catalogLayer?.id, r = e.source != null && (s || e.source !== this.sourcePreference), n = !s && e.source === "auto" && this.sourcePreference === "auto", o = { time: e.time, depth: e.depth }, c = s ? e.layer : this.catalogLayer?.id, d = e.stylePatch === void 0 ? e.style : e.style === void 0 ? ae(this.style, e.stylePatch) : ae(e.stylePatch, e.style), u = e.settings?.palette, h = d !== void 0 && u !== void 0 && typeof u != "string" && e.style?.palette === void 0 ? na(d) : d;
3712
+ ht(h, this.catalog, c);
3713
+ const v = h ?? (s ? mt(
4285
3714
  this.style,
4286
- this.catalog.layers.find((m) => m.id === l)?.kind
3715
+ this.catalog.layers.find((m) => m.id === c)?.kind
4287
3716
  ) : void 0);
4288
- if (a) {
4289
- const m = { ...e.settings, ...pe(f) };
3717
+ if (s) {
3718
+ const m = { ...e.settings, ...pe(v) };
4290
3719
  await this.loadLayer(
4291
3720
  e.layer,
4292
3721
  e.source ?? "auto",
@@ -4298,163 +3727,163 @@ class Aa {
4298
3727
  target: o
4299
3728
  },
4300
3729
  t
4301
- ), this.style = f;
3730
+ ), this.style = v;
4302
3731
  } else {
4303
3732
  const m = Object.prototype.hasOwnProperty.call(
4304
3733
  e,
4305
3734
  "timeRange"
4306
- ), p = m ? e.timeRange ?? void 0 : this.timeRange;
3735
+ ), f = m ? e.timeRange ?? void 0 : this.timeRange;
4307
3736
  if (r || n)
4308
- await this.changeSource(e.source, p, o);
4309
- else if (await this.needsSourceSwitch(p, o, m)) {
4310
- const h = this.playing && e.time == null && e.depth != null, g = this.playbackIntent;
4311
- await this.changeSource(this.sourcePreference, p, o), h && g === this.playbackIntent && !this.destroyed && await this.play();
3737
+ await this.changeSource(e.source, f, o);
3738
+ else if (await this.needsSourceSwitch(f, o, m)) {
3739
+ const l = this.playing && e.time == null && e.depth != null, p = this.playbackIntent;
3740
+ await this.changeSource(this.sourcePreference, f, o), l && p === this.playbackIntent && !this.destroyed && await this.play();
4312
3741
  } else m && this.applyTimeRange(e.timeRange ?? null);
4313
3742
  }
4314
- if (!a && f !== void 0) {
4315
- this.style = f;
4316
- const m = { ...e.settings, ...pe(this.style) }, p = this.settings.palette;
4317
- m.palette === void 0 && p && typeof p != "string" && (m.palette = p);
4318
- const h = {
3743
+ if (!s && v !== void 0) {
3744
+ this.style = v;
3745
+ const m = { ...e.settings, ...pe(this.style) }, f = this.settings.palette;
3746
+ m.palette === void 0 && f && typeof f != "string" && (m.palette = f);
3747
+ const l = {
4319
3748
  ...this.styledSettings(),
4320
3749
  ...m
4321
3750
  };
4322
3751
  this.applySettings(
4323
3752
  Object.fromEntries(
4324
- Object.entries(h).filter(
4325
- ([g, x]) => JSON.stringify(x) !== JSON.stringify(this.settings[g])
3753
+ Object.entries(l).filter(
3754
+ ([p, x]) => JSON.stringify(x) !== JSON.stringify(this.settings[p])
4326
3755
  )
4327
3756
  )
4328
3757
  ), this.colorDomainOverridden = m.colorDomain !== void 0, this.paletteOverridden = m.palette !== void 0;
4329
- } else !a && e.settings && this.applySettings(e.settings);
3758
+ } else !s && e.settings && this.applySettings(e.settings);
4330
3759
  e.geoVideo && (e.geoVideo.autoplay != null && (this.autoplay = e.geoVideo.autoplay, this.catalogSource?.type === "geovideo" && (this.autoplay ? await this.startPlayback(i ?? ++this.requestSeq) : this.pause())), e.geoVideo.loop != null && this.applyLoop(e.geoVideo.loop), e.geoVideo.stepsPerSecond != null ? (this.stepsPerSecond = e.geoVideo.stepsPerSecond, this.applyPlaybackSpeed()) : e.geoVideo.playbackRate != null && this.applyPlaybackRate(e.geoVideo.playbackRate)), e.time != null && e.depth != null ? this.applyTimeAndDepth(e.time, e.depth) : (e.time != null && this.applyTime(e.time), e.depth != null && this.applyDepth(e.depth)), e.time != null && this.requestedTime === z(e.time, "time") && (this.requestedTime = null), e.visible != null && this.applyVisible(e.visible);
4331
3760
  }
4332
- async loadLayer(e, t = this.sourcePreference, i, a) {
4333
- const r = this.getSource(), n = ot(this.timeMeta, this.verticalMeta);
4334
- await this.loadSource(e, t, i, a);
3761
+ async loadLayer(e, t = this.sourcePreference, i, s) {
3762
+ const r = this.getSource(), n = rt(this.timeMeta, this.verticalMeta);
3763
+ await this.loadSource(e, t, i, s);
4335
3764
  const o = this.getSource();
4336
- o && (o.id !== r?.id || o.type !== r?.type) ? this.emit("sourceChange", o) : ot(this.timeMeta, this.verticalMeta) !== n && this.emit("axesChange");
3765
+ o && (o.id !== r?.id || o.type !== r?.type) ? this.emit("sourceChange", o) : rt(this.timeMeta, this.verticalMeta) !== n && this.emit("axesChange");
4337
3766
  }
4338
- async loadSource(e, t, i, a) {
3767
+ async loadSource(e, t, i, s) {
4339
3768
  this.assertAlive();
4340
3769
  const r = this.catalog.layers.find(
4341
- (v) => v.id === e
3770
+ (g) => g.id === e
4342
3771
  );
4343
3772
  if (!r)
4344
3773
  throw new Error(`Unknown zartigl catalog entry: ${e}`);
4345
- const n = fa(r), o = i ? i.timeRange : this.timeRange, l = a ?? ++this.switchGeneration, d = {
3774
+ const n = ra(r), o = i ? i.timeRange : this.timeRange, c = s ?? ++this.switchGeneration, d = {
4346
3775
  ...i?.target,
4347
3776
  depth: i?.target?.depth ?? this.depthRequest ?? void 0
4348
- }, c = await this.selectSource(
3777
+ }, u = await this.selectSource(
4349
3778
  r,
4350
3779
  t,
4351
3780
  o,
4352
3781
  d
4353
- ), u = i?.settings ?? this.settings, f = i?.colorDomainOverridden ?? this.colorDomainOverridden, m = i?.paletteOverridden ?? this.paletteOverridden;
4354
- if (c.type === "geovideo") {
3782
+ ), h = i?.settings ?? this.settings, v = i?.colorDomainOverridden ?? this.colorDomainOverridden, m = i?.paletteOverridden ?? this.paletteOverridden;
3783
+ if (u.type === "geovideo") {
4355
3784
  this.emit("status", { phase: "metadata" });
4356
3785
  try {
4357
- if (!c.manifestUrl)
3786
+ if (!u.manifestUrl)
4358
3787
  throw new Error(
4359
- `GeoVideo archive source was not resolved to a chunk: ${c.id}`
3788
+ `GeoVideo archive source was not resolved to a chunk: ${u.id}`
4360
3789
  );
4361
- const v = await this.loadChunkManifest(
4362
- c.manifestUrl
3790
+ const g = await this.loadChunkManifest(
3791
+ u.manifestUrl
4363
3792
  ), _ = r.sources.find(
4364
- (ce) => ce.id === v.provenance.inputSourceId
3793
+ (ce) => ce.id === g.provenance.inputSourceId
4365
3794
  );
4366
- if (v.id !== c.id || v.provenance.catalogEntryId !== r.id || _?.type !== "zarr")
3795
+ if (g.id !== u.id || g.provenance.catalogEntryId !== r.id || _?.type !== "zarr")
4367
3796
  throw new Error(
4368
- `GeoVideo manifest identity does not match catalog entry/source: ${c.id}`
3797
+ `GeoVideo manifest identity does not match catalog entry/source: ${u.id}`
4369
3798
  );
4370
- const S = Ee(r, c.id), E = S ? this.chunkLevels.get(c.manifestUrl) ?? null : null, R = v.vertical;
4371
- if (S && (E ? !He(R, E) : R !== void 0))
3799
+ const S = Pe(r, u.id), E = S ? this.chunkLevels.get(u.manifestUrl) ?? null : null, P = g.vertical;
3800
+ if (S && (E ? !Xe(P, E) : P !== void 0))
4372
3801
  throw new Error(
4373
- `GeoVideo manifest level does not match its index: ${c.manifestUrl}`
3802
+ `GeoVideo manifest level does not match its index: ${u.manifestUrl}`
4374
3803
  );
4375
- const k = E?.value ?? null, F = S ? await this.archiveTimes(r, c.id, k) : null, L = S ? await this.archiveLevels(r, S) : null, D = !!L?.depths.length, b = !D && !!L?.surface, A = D || b ? la(L) : null;
4376
- if (l !== this.switchGeneration)
3804
+ const A = E?.value ?? null, U = S ? await this.archiveTimes(r, u.id, A) : null, L = S ? await this.archiveLevels(r, S) : null, D = !!L?.depths.length, b = !D && !!L?.surface, V = D || b ? Ji(L) : null;
3805
+ if (c !== this.switchGeneration)
4377
3806
  throw new DOMException(
4378
3807
  "Layer selection was superseded",
4379
3808
  "AbortError"
4380
3809
  );
4381
- const N = we(v), C = ca(F ?? N), I = re(
3810
+ const X = we(g), C = ea(U ?? X), I = re(
4382
3811
  C,
4383
3812
  o
4384
3813
  ), w = ne(
4385
3814
  C,
4386
3815
  o
4387
- ), V = N.filter(
3816
+ ), k = X.filter(
4388
3817
  (ce) => ce >= w.min && ce <= w.max
4389
- ), X = V.length ? V : N, oe = this.catalogLayer?.id === r.id && this.catalogSource?.type === "geovideo", le = this.settings.palette;
4390
- this.catalogLayer = r, this.catalogSource = c, this.sourcePreference = t, this.timeRange = o, this.activeFieldSource = null, this.geoVideoManifest = v, this.wmtsMetadata = null, this.fullTimeMeta = C, this.resolvedTimeRange = I, this.timeMeta = w, this.verticalMeta = A, this.variableUnit = v.style.unit ?? "", this.variableStandardName = v.provenance.variables[0], this.time = this.pendingTime == null ? X[0] : U(X, this.pendingTime), this.pendingTime = null, this.depthLocked = b, this.archiveLevel = k, this.depth = D ? k ?? L.surface?.value ?? 0 : Le(A, d.depth), D && (this.depthRequest = this.depth);
4391
- const Gt = u.colorDomain;
4392
- if (this.settings = { ...n, ...u }, this.colorDomainOverridden = f, this.paletteOverridden = m, this.settings.colorDomain = f ? Gt ?? null : v.style.colorDomain, this.settings.palette = m ? this.settings.palette : qe(r.defaults).palette ?? v.style.palette, this.lastMeta = null, oe && this.replaceGeoVideoInPlace(le))
3818
+ ), W = k.length ? k : X, oe = this.catalogLayer?.id === r.id && this.catalogSource?.type === "geovideo", le = this.settings.palette;
3819
+ this.catalogLayer = r, this.catalogSource = u, this.sourcePreference = t, this.timeRange = o, this.activeFieldSource = null, this.geoVideoManifest = g, this.wmtsMetadata = null, this.fullTimeMeta = C, this.resolvedTimeRange = I, this.timeMeta = w, this.verticalMeta = V, this.variableUnit = g.style.unit ?? "", this.variableStandardName = g.provenance.variables[0], this.time = this.pendingTime == null ? W[0] : F(W, this.pendingTime), this.pendingTime = null, this.depthLocked = b, this.archiveLevel = A, this.depth = D ? A ?? L.surface?.value ?? 0 : Ee(V, d.depth), D && (this.depthRequest = this.depth);
3820
+ const zt = h.colorDomain;
3821
+ if (this.settings = { ...n, ...h }, this.colorDomainOverridden = v, this.paletteOverridden = m, this.settings.colorDomain = v ? zt ?? null : g.style.colorDomain, this.settings.palette = m ? this.settings.palette : $e(r.defaults).palette ?? g.style.palette, this.lastMeta = null, oe && this.replaceGeoVideoInPlace(le))
4393
3822
  return;
4394
3823
  this.detach(), this.attachWhenReady();
4395
3824
  return;
4396
- } catch (v) {
4397
- const _ = v instanceof Error ? v : new Error(String(v)), S = c.manifestUrl;
4398
- if (_.name !== "AbortError" && !(_ instanceof RangeError) && t === "auto" && S && !this.failedGeoVideo.has(S) && this.catalogSource?.id !== c.id)
4399
- return console.warn("[zartigl] GeoVideo unavailable, falling back:", _), this.failedGeoVideo.add(S), this.loadSource(e, t, i, l);
3825
+ } catch (g) {
3826
+ const _ = g instanceof Error ? g : new Error(String(g)), S = u.manifestUrl;
3827
+ if (_.name !== "AbortError" && !(_ instanceof RangeError) && t === "auto" && S && !this.failedGeoVideo.has(S) && this.catalogSource?.id !== u.id)
3828
+ return console.warn("[zartigl] GeoVideo unavailable, falling back:", _), this.failedGeoVideo.add(S), this.loadSource(e, t, i, c);
4400
3829
  throw _.name !== "AbortError" && (this.emit("status", { phase: "error", error: _ }), this.emit("error", _)), _;
4401
3830
  }
4402
3831
  }
4403
- if (c.type === "wmts") {
3832
+ if (u.type === "wmts") {
4404
3833
  this.emit("status", { phase: "metadata" });
4405
3834
  try {
4406
- const v = await ra(c);
4407
- if (l !== this.switchGeneration)
3835
+ const g = await ji(u);
3836
+ if (c !== this.switchGeneration)
4408
3837
  throw new DOMException(
4409
3838
  "Layer selection was superseded",
4410
3839
  "AbortError"
4411
3840
  );
4412
- const _ = v.time, S = ne(_, o);
3841
+ const _ = g.time, S = ne(_, o);
4413
3842
  this.detach(), this.catalogLayer = r, this.catalogSource = {
4414
- ...c,
4415
- baseUrl: v.baseUrl,
4416
- tileUrlTemplate: c.tileUrlTemplate ?? v.tileUrlTemplate,
4417
- tileMatrixSet: v.tileMatrixSet,
4418
- format: v.format,
4419
- style: c.style ?? v.style
4420
- }, this.sourcePreference = t, this.timeRange = o, this.activeFieldSource = null, this.geoVideoManifest = null, this.wmtsMetadata = v, this.fullTimeMeta = _, this.resolvedTimeRange = re(
3843
+ ...u,
3844
+ baseUrl: g.baseUrl,
3845
+ tileUrlTemplate: u.tileUrlTemplate ?? g.tileUrlTemplate,
3846
+ tileMatrixSet: g.tileMatrixSet,
3847
+ format: g.format,
3848
+ style: u.style ?? g.style
3849
+ }, this.sourcePreference = t, this.timeRange = o, this.activeFieldSource = null, this.geoVideoManifest = null, this.wmtsMetadata = g, this.fullTimeMeta = _, this.resolvedTimeRange = re(
4421
3850
  _,
4422
3851
  o
4423
- ), this.timeMeta = S, this.verticalMeta = v.vertical, this.archiveLevel = null, this.depthLocked = !1, this.variableUnit = "", this.variableStandardName = c.layer, this.time = this.pendingTime == null ? at(S.values, Date.now()) : U(S.values, this.pendingTime), this.pendingTime = null, this.depth = Le(v.vertical, d.depth), this.settings = { ...n, ...u }, this.colorDomainOverridden = f, this.paletteOverridden = m, this.lastMeta = null, this.attachWhenReady();
3852
+ ), this.timeMeta = S, this.verticalMeta = g.vertical, this.archiveLevel = null, this.depthLocked = !1, this.variableUnit = "", this.variableStandardName = u.layer, this.time = this.pendingTime == null ? tt(S.values, Date.now()) : F(S.values, this.pendingTime), this.pendingTime = null, this.depth = Ee(g.vertical, d.depth), this.settings = { ...n, ...h }, this.colorDomainOverridden = v, this.paletteOverridden = m, this.lastMeta = null, this.attachWhenReady();
4424
3853
  return;
4425
- } catch (v) {
4426
- const _ = v instanceof Error ? v : new Error(String(v));
3854
+ } catch (g) {
3855
+ const _ = g instanceof Error ? g : new Error(String(g));
4427
3856
  throw _.name !== "AbortError" && (this.emit("status", { phase: "error", error: _ }), this.emit("error", _)), _;
4428
3857
  }
4429
3858
  }
4430
- const p = this.getFieldSource(c.endpoints.field);
4431
- let h, g, x, T, M;
3859
+ const f = this.getFieldSource(u.endpoints.field);
3860
+ let l, p, x, T, R;
4432
3861
  this.emit("status", { phase: "metadata" });
4433
3862
  try {
4434
- await p.init();
4435
- const v = fe(c);
4436
- for (const _ of v)
4437
- if (!p.hasVariable(_))
3863
+ await f.init();
3864
+ const g = fe(u);
3865
+ for (const _ of g)
3866
+ if (!f.hasVariable(_))
4438
3867
  throw new Error(
4439
3868
  `Configured variable not found in Zarr store: ${_}`
4440
3869
  );
4441
- if (g = st(
4442
- c,
4443
- p.getTimeDimension()
4444
- ), g.values.length === 0)
3870
+ if (p = it(
3871
+ u,
3872
+ f.getTimeDimension()
3873
+ ), p.values.length === 0)
4445
3874
  throw new Error("Zarr time coordinate is empty");
4446
- x = re(g, o), h = ne(g, o), T = p.getVerticalDimension(v[0]) ?? null, M = p.getVariableAttrs(
4447
- v[v.length - 1]
3875
+ x = re(p, o), l = ne(p, o), T = f.getVerticalDimension(g[0]) ?? null, R = f.getVariableAttrs(
3876
+ g[g.length - 1]
4448
3877
  );
4449
- } catch (v) {
4450
- const _ = v instanceof Error ? v : new Error(String(v));
3878
+ } catch (g) {
3879
+ const _ = g instanceof Error ? g : new Error(String(g));
4451
3880
  throw this.emit("status", { phase: "error", error: _ }), this.emit("error", _), _;
4452
3881
  }
4453
- if (l !== this.switchGeneration)
3882
+ if (c !== this.switchGeneration)
4454
3883
  throw new DOMException("Layer selection was superseded", "AbortError");
4455
- this.detach(), this.catalogLayer = r, this.catalogSource = c, this.sourcePreference = t, this.timeRange = o, this.activeFieldSource = p, this.geoVideoManifest = null, this.wmtsMetadata = null, this.fullTimeMeta = g, this.resolvedTimeRange = x, this.timeMeta = h, this.verticalMeta = T, this.archiveLevel = null, this.depthLocked = !1, this.variableUnit = typeof M.units == "string" ? M.units : "", this.variableStandardName = typeof M.standard_name == "string" ? M.standard_name : void 0, this.time = this.pendingTime == null ? at(this.timeMeta.values, Date.now()) : U(this.timeMeta.values, this.pendingTime), this.pendingTime = null, this.depth = Le(T, d.depth);
4456
- const y = u.colorDomain;
4457
- this.settings = { ...n, ...u }, this.colorDomainOverridden = f, this.paletteOverridden = m, this.settings.colorDomain = f ? y ?? null : n.colorDomain ?? null, this.lastMeta = null, this.attachWhenReady();
3884
+ this.detach(), this.catalogLayer = r, this.catalogSource = u, this.sourcePreference = t, this.timeRange = o, this.activeFieldSource = f, this.geoVideoManifest = null, this.wmtsMetadata = null, this.fullTimeMeta = p, this.resolvedTimeRange = x, this.timeMeta = l, this.verticalMeta = T, this.archiveLevel = null, this.depthLocked = !1, this.variableUnit = typeof R.units == "string" ? R.units : "", this.variableStandardName = typeof R.standard_name == "string" ? R.standard_name : void 0, this.time = this.pendingTime == null ? tt(this.timeMeta.values, Date.now()) : F(this.timeMeta.values, this.pendingTime), this.pendingTime = null, this.depth = Ee(T, d.depth);
3885
+ const y = h.colorDomain;
3886
+ this.settings = { ...n, ...h }, this.colorDomainOverridden = v, this.paletteOverridden = m, this.settings.colorDomain = v ? y ?? null : n.colorDomain ?? null, this.lastMeta = null, this.attachWhenReady();
4458
3887
  }
4459
3888
  async changeSource(e, t = this.timeRange, i = {}) {
4460
3889
  if (this.assertAlive(), !this.catalogLayer) {
@@ -4475,19 +3904,19 @@ class Aa {
4475
3904
  * depth ever switches to another source.
4476
3905
  */
4477
3906
  async needsSourceSwitch(e, t, i) {
4478
- const a = this.catalogLayer, r = this.catalogSource;
4479
- if (!a || !r || !this.isArchiveChunk(r))
3907
+ const s = this.catalogLayer, r = this.catalogSource;
3908
+ if (!s || !r || !this.isArchiveChunk(r))
4480
3909
  return !1;
4481
- const n = Ee(a, this.sourcePreference), o = n ? await this.archiveLevels(a, n) : null, d = !!o?.depths.length && t.depth != null && nt(o, t.depth) !== this.archiveLevel;
4482
- if ((t.time == null && !i || Ot(r, this.sourceTimeRequest(e, t.time))) && !d)
3910
+ const n = Pe(s, this.sourcePreference), o = n ? await this.archiveLevels(s, n) : null, d = !!o?.depths.length && t.depth != null && st(o, t.depth) !== this.archiveLevel;
3911
+ if ((t.time == null && !i || Gt(r, this.sourceTimeRequest(e, t.time))) && !d)
4483
3912
  return !1;
4484
- const u = await this.selectSource(
4485
- a,
3913
+ const h = await this.selectSource(
3914
+ s,
4486
3915
  this.sourcePreference,
4487
3916
  e,
4488
3917
  t
4489
3918
  );
4490
- return !ti(u, r);
3919
+ return !Jt(h, r);
4491
3920
  }
4492
3921
  applyVisible(e) {
4493
3922
  this.assertAlive(), this.visible !== e && (this.visible = e, e ? this.attachWhenReady() : this.detach());
@@ -4512,7 +3941,7 @@ class Aa {
4512
3941
  applyTime(e) {
4513
3942
  this.assertAlive();
4514
3943
  const t = z(e, "time");
4515
- this.layer || (this.pendingTime = t), this.time = U(this.timeMeta?.values ?? [], t), this.layer?.setTime(this.time);
3944
+ this.layer || (this.pendingTime = t), this.time = F(this.timeMeta?.values ?? [], t), this.layer?.setTime(this.time);
4516
3945
  }
4517
3946
  /** Start GeoVideo playback; does nothing where playback is unavailable. */
4518
3947
  async play() {
@@ -4539,7 +3968,7 @@ class Aa {
4539
3968
  const t = this.timeMeta?.values ?? [];
4540
3969
  if (!t.length)
4541
3970
  return;
4542
- const i = U(t, this.requestedTime ?? this.time);
3971
+ const i = F(t, this.requestedTime ?? this.time);
4543
3972
  return t[t.indexOf(i) + e];
4544
3973
  }
4545
3974
  pause() {
@@ -4560,10 +3989,10 @@ class Aa {
4560
3989
  }
4561
3990
  /** Media rate for the loaded artifact: steps per second when set, else the raw multiplier. */
4562
3991
  effectivePlaybackRate() {
4563
- return this.stepsPerSecond != null && this.geoVideoManifest ? ii(this.geoVideoManifest, this.stepsPerSecond) : this.playbackRate;
3992
+ return this.stepsPerSecond != null && this.geoVideoManifest ? ei(this.geoVideoManifest, this.stepsPerSecond) : this.playbackRate;
4564
3993
  }
4565
3994
  playbackSpeeds() {
4566
- return this.catalogLayer?.kind === "vector" ? it : na;
3995
+ return this.catalogLayer?.kind === "vector" ? et : Qi;
4567
3996
  }
4568
3997
  /**
4569
3998
  * Steps per second the active source shows. Vector GeoVideo stays inside
@@ -4571,29 +4000,29 @@ class Aa {
4571
4000
  */
4572
4001
  appliedStepsPerSecond() {
4573
4002
  if (this.catalogLayer?.kind === "vector") {
4574
- const e = it;
4003
+ const e = et;
4575
4004
  return Math.min(
4576
4005
  e[e.length - 1],
4577
4006
  Math.max(e[0], this.stepsPerSecond ?? 1)
4578
4007
  );
4579
4008
  }
4580
- return this.stepsPerSecond != null ? this.stepsPerSecond : this.geoVideoManifest ? this.playbackRate * ai(this.geoVideoManifest) : this.playbackRate;
4009
+ return this.stepsPerSecond != null ? this.stepsPerSecond : this.geoVideoManifest ? this.playbackRate * ti(this.geoVideoManifest) : this.playbackRate;
4581
4010
  }
4582
4011
  /** Apply or clear a time window without rebuilding source metadata or the map layer. */
4583
4012
  applyTimeRange(e) {
4584
4013
  if (this.assertAlive(), !this.fullTimeMeta)
4585
4014
  throw new Error("Set a layer before changing its time range");
4586
- const t = e == null ? void 0 : { ...e }, i = re(this.fullTimeMeta, t), a = ne(this.fullTimeMeta, t), r = U(a.values, this.time);
4587
- return this.timeRange = t, this.resolvedTimeRange = i, this.timeMeta = a, this.time = r, this.layer?.setTimeRange([a.min, a.max]), this.layer?.setTime(r), this.getTimeMeta();
4015
+ const t = e == null ? void 0 : { ...e }, i = re(this.fullTimeMeta, t), s = ne(this.fullTimeMeta, t), r = F(s.values, this.time);
4016
+ return this.timeRange = t, this.resolvedTimeRange = i, this.timeMeta = s, this.time = r, this.layer?.setTimeRange([s.min, s.max]), this.layer?.setTime(r), this.getTimeMeta();
4588
4017
  }
4589
4018
  applyDepth(e) {
4590
- this.assertAlive(), this.depth = U(this.verticalMeta?.values ?? [], e), this.layer?.setDepth(this.depth);
4019
+ this.assertAlive(), this.depth = F(this.verticalMeta?.values ?? [], e), this.layer?.setDepth(this.depth);
4591
4020
  }
4592
4021
  applyTimeAndDepth(e, t) {
4593
- this.assertAlive(), this.time = U(
4022
+ this.assertAlive(), this.time = F(
4594
4023
  this.timeMeta?.values ?? [],
4595
4024
  z(e, "time")
4596
- ), this.depth = U(this.verticalMeta?.values ?? [], t), this.layer?.setTimeAndDepth(this.time, this.depth);
4025
+ ), this.depth = F(this.verticalMeta?.values ?? [], t), this.layer?.setTimeAndDepth(this.time, this.depth);
4597
4026
  }
4598
4027
  on(e, t) {
4599
4028
  return this.assertAlive(), this.listeners.has(e) || this.listeners.set(e, /* @__PURE__ */ new Set()), this.listeners.get(e).add(t), this;
@@ -4611,7 +4040,7 @@ class Aa {
4611
4040
  values: t.values,
4612
4041
  units: t.units,
4613
4042
  current: this.time,
4614
- granularity: oa(t.values),
4043
+ granularity: Ki(t.values),
4615
4044
  timelineKind: this.geoVideoManifest?.timeline.kind
4616
4045
  } : {
4617
4046
  min: NaN,
@@ -4627,7 +4056,7 @@ class Aa {
4627
4056
  return { values: [], label: "depth", current: void 0 };
4628
4057
  const e = this.verticalMeta;
4629
4058
  return {
4630
- values: kt(e.values),
4059
+ values: At(e.values),
4631
4060
  name: e.name,
4632
4061
  label: e.label,
4633
4062
  units: e.units,
@@ -4648,7 +4077,7 @@ class Aa {
4648
4077
  const i = this.catalogSource;
4649
4078
  return {
4650
4079
  type: "image",
4651
- url: Zi({
4080
+ url: Oi({
4652
4081
  baseUrl: i.baseUrl ?? this.wmtsMetadata?.baseUrl ?? new URL(i.capabilitiesUrl).origin,
4653
4082
  layer: i.layer,
4654
4083
  style: i.style
@@ -4657,18 +4086,18 @@ class Aa {
4657
4086
  };
4658
4087
  }
4659
4088
  if (this.catalogSource.type === "geovideo" && this.geoVideoManifest) {
4660
- const i = typeof this.settings.palette == "string" ? Ne(this.settings.palette) : "custom", a = this.settings.colorDomain ?? this.geoVideoManifest.style.colorDomain;
4089
+ const i = typeof this.settings.palette == "string" ? Ie(this.settings.palette) : "custom", s = this.settings.colorDomain ?? this.geoVideoManifest.style.colorDomain;
4661
4090
  return {
4662
4091
  type: "gradient",
4663
4092
  palette: i,
4664
4093
  reverse: this.settings.reversePalette ?? !1,
4665
4094
  alphaFade: Ue(this.settings),
4666
- min: a[0],
4667
- max: a[1],
4668
- unit: Ye(this.geoVideoManifest.style.unit)
4095
+ min: s[0],
4096
+ max: s[1],
4097
+ unit: He(this.geoVideoManifest.style.unit)
4669
4098
  };
4670
4099
  }
4671
- const e = typeof this.settings.palette == "string" ? Ne(this.settings.palette) : "custom", t = this.catalogLayer.kind === "scalar" ? this.settings.colorDomain : null;
4100
+ const e = typeof this.settings.palette == "string" ? Ie(this.settings.palette) : "custom", t = this.catalogLayer.kind === "scalar" ? this.settings.colorDomain : null;
4672
4101
  return {
4673
4102
  type: "gradient",
4674
4103
  palette: e,
@@ -4676,11 +4105,11 @@ class Aa {
4676
4105
  alphaFade: this.catalogLayer.kind === "scalar" ? Ue(this.settings) : void 0,
4677
4106
  min: t?.[0] ?? this.lastMeta?.min,
4678
4107
  max: t?.[1] ?? this.lastMeta?.max,
4679
- unit: Ye(this.lastMeta?.unit ?? this.variableUnit)
4108
+ unit: He(this.lastMeta?.unit ?? this.variableUnit)
4680
4109
  };
4681
4110
  }
4682
4111
  getPalettes() {
4683
- return _t();
4112
+ return vt();
4684
4113
  }
4685
4114
  getSource() {
4686
4115
  return this.catalogSource ? { id: this.catalogSource.id, type: this.catalogSource.type } : void 0;
@@ -4714,7 +4143,7 @@ class Aa {
4714
4143
  return this.catalogLayer?.kind !== "vector";
4715
4144
  const t = this.timeMeta;
4716
4145
  return we(e).filter(
4717
- (a) => !t || a >= t.min && a <= t.max
4146
+ (s) => !t || s >= t.min && s <= t.max
4718
4147
  ).length > 1;
4719
4148
  }
4720
4149
  /** Whether palette/domain styling is applied to values in the active renderer. */
@@ -4728,7 +4157,7 @@ class Aa {
4728
4157
  getStyle() {
4729
4158
  return ze(
4730
4159
  this.catalogLayer ?? void 0,
4731
- Ae(this.settings).style
4160
+ De(this.settings).style
4732
4161
  );
4733
4162
  }
4734
4163
  /** The style override over the layer's own. */
@@ -4752,7 +4181,7 @@ class Aa {
4752
4181
  devicePixelRatio: typeof window < "u" ? window.devicePixelRatio : void 0,
4753
4182
  catalogEntry: this.catalogLayer ? {
4754
4183
  id: this.catalogLayer.id,
4755
- title: Bt(
4184
+ title: Ot(
4756
4185
  this.catalogLayer.title,
4757
4186
  this.catalog.defaultLocale,
4758
4187
  this.catalog.defaultLocale
@@ -4777,26 +4206,26 @@ class Aa {
4777
4206
  * color domain of a GeoVideo archive included, as a load sets them.
4778
4207
  */
4779
4208
  styledSettings() {
4780
- const e = It(
4209
+ const e = kt(
4781
4210
  this.catalogLayer ?? void 0,
4782
4211
  this.style
4783
4212
  ), t = this.catalogSource?.type === "geovideo" ? this.geoVideoManifest : null;
4784
- return t && this.style.raster?.colorDomain === void 0 && (e.colorDomain = t.style.colorDomain), t && this.style.palette === void 0 && (e.palette = qe(this.catalogLayer?.defaults)?.palette ?? t.style.palette), e;
4213
+ return t && this.style.raster?.colorDomain === void 0 && (e.colorDomain = t.style.colorDomain), t && this.style.palette === void 0 && (e.palette = $e(this.catalogLayer?.defaults)?.palette ?? t.style.palette), e;
4785
4214
  }
4786
4215
  applySettings(e) {
4787
4216
  this.assertAlive();
4788
4217
  const t = e.colorDomain === void 0 ? e : {
4789
4218
  ...e,
4790
4219
  colorDomain: Q(e.colorDomain)
4791
- }, i = ma.some(
4220
+ }, i = sa.some(
4792
4221
  (r) => t[r] != null && t[r] !== this.settings[r]
4793
- ), a = t.particleState != null && t.particleState !== this.settings.particleState;
4222
+ ), s = t.particleState != null && t.particleState !== this.settings.particleState;
4794
4223
  if (t.colorDomain !== void 0 && (this.colorDomainOverridden = !0), t.palette !== void 0 && (this.paletteOverridden = !0), this.settings = { ...this.settings, ...t }, !!this.layer) {
4795
4224
  if (i && this.catalogSource?.type === "geovideo") {
4796
- this.layer.setColorRamp(De(this.settings)), this.applyMutableSettings(this.layer, t);
4225
+ this.layer.setColorRamp(Le(this.settings)), this.applyMutableSettings(this.layer, t);
4797
4226
  return;
4798
4227
  }
4799
- if (i || a) {
4228
+ if (i || s) {
4800
4229
  this.detach(), this.attachWhenReady();
4801
4230
  return;
4802
4231
  }
@@ -4810,14 +4239,14 @@ class Aa {
4810
4239
  throw new Error(
4811
4240
  `Catalog entry does not provide point-query capability: ${t.id}`
4812
4241
  );
4813
- const a = Math.max(1, Math.floor(e.maxPoints ?? 512)), r = this.getQuerySource(i.endpoints.pointSeries);
4242
+ const s = Math.max(1, Math.floor(e.maxPoints ?? 512)), r = this.getQuerySource(i.endpoints.pointSeries);
4814
4243
  await r.init();
4815
- const n = r.getTimeDimension().values, o = st(
4244
+ const n = r.getTimeDimension().values, o = it(
4816
4245
  i,
4817
4246
  r.getTimeDimension()
4818
4247
  );
4819
4248
  if (!this.timeRange && o.size === n.length) {
4820
- const m = Math.max(1, Math.ceil(n.length / a));
4249
+ const m = Math.max(1, Math.ceil(n.length / s));
4821
4250
  return r.sampleTimeSeries({
4822
4251
  variables: fe(i),
4823
4252
  longitude: e.longitude,
@@ -4827,30 +4256,30 @@ class Aa {
4827
4256
  stopAfterMissingSamples: 12
4828
4257
  });
4829
4258
  }
4830
- const l = this.timeRange ? Math.max(
4259
+ const c = this.timeRange ? Math.max(
4831
4260
  o.min,
4832
4261
  this.resolvedTimeRange?.[0] ?? this.timeMeta?.min ?? o.min
4833
4262
  ) : o.min, d = this.timeRange ? Math.min(
4834
4263
  o.max,
4835
4264
  this.resolvedTimeRange?.[1] ?? this.timeMeta?.max ?? o.max
4836
- ) : o.max, c = n.findIndex((m) => m >= l);
4837
- let u = n.length - 1;
4838
- for (; u >= 0 && n[u] > d; )
4839
- u--;
4840
- if (c < 0 || u < c)
4265
+ ) : o.max, u = n.findIndex((m) => m >= c);
4266
+ let h = n.length - 1;
4267
+ for (; h >= 0 && n[h] > d; )
4268
+ h--;
4269
+ if (u < 0 || h < u)
4841
4270
  throw new Error("Time range does not overlap the point-series store");
4842
- const f = Math.max(
4271
+ const v = Math.max(
4843
4272
  1,
4844
- Math.ceil((u - c + 1) / a)
4273
+ Math.ceil((h - u + 1) / s)
4845
4274
  );
4846
4275
  return r.sampleTimeSeries({
4847
4276
  variables: fe(i),
4848
4277
  longitude: e.longitude,
4849
4278
  latitude: e.latitude,
4850
4279
  depth: e.depth ?? this.depth,
4851
- timeStartIndex: c,
4852
- timeEndIndex: u,
4853
- stride: f,
4280
+ timeStartIndex: u,
4281
+ timeEndIndex: h,
4282
+ stride: v,
4854
4283
  stopAfterMissingSamples: 12
4855
4284
  });
4856
4285
  }
@@ -4886,7 +4315,7 @@ class Aa {
4886
4315
  );
4887
4316
  return;
4888
4317
  }
4889
- const e = new ta({
4318
+ const e = new Xi({
4890
4319
  id: this.id,
4891
4320
  entry: this.catalogLayer,
4892
4321
  sourceConfig: this.catalogSource,
@@ -4912,14 +4341,14 @@ class Aa {
4912
4341
  zarrSource: this.activeFieldSource ?? void 0,
4913
4342
  unit: this.variableUnit,
4914
4343
  verticalLabel: this.verticalMeta?.label,
4915
- colorRamp: De(this.settings),
4344
+ colorRamp: Le(this.settings),
4916
4345
  metadata: this.metadata ? { ...this.metadata } : void 0,
4917
4346
  before: this.before
4918
4347
  });
4919
4348
  this.pendingTime = null, this.autoplayPending = !1, e.on("loading", () => this.emit("loading")), e.on("loaded", (t) => {
4920
4349
  this.lastMeta = t, this.emit("loaded", t);
4921
4350
  }), e.on("error", (t) => this.emit("error", t)), e.on("status", (t) => this.emit("status", t)), e.on("frameBuffered", (t) => this.emit("frameBuffered", t)), e.on("cacheInvalidated", () => this.emit("cacheInvalidated")), e.on("timeChange", (t) => {
4922
- e === this.layer && (this.time = U(this.timeMeta?.values ?? [], t), this.playing && (this.requestedTime = null), this.emit("timeChange", this.time));
4351
+ e === this.layer && (this.time = F(this.timeMeta?.values ?? [], t), this.playing && (this.requestedTime = null), this.emit("timeChange", this.time));
4923
4352
  }), e.on("playbackChange", (t) => {
4924
4353
  e === this.layer && (t && this.preloadNextArchiveChunk(e), t !== this.playing && (this.playing = t, this.emit("playbackChange", t)));
4925
4354
  }), e.on("playbackEnd", () => {
@@ -4951,7 +4380,7 @@ class Aa {
4951
4380
  loop: i.geoVideoLoop,
4952
4381
  playbackRate: i.geoVideoPlaybackRate,
4953
4382
  stepsPerSecond: this.catalogLayer?.kind === "vector" ? this.appliedStepsPerSecond() : void 0
4954
- }) ? (t.setColorDomain(this.settings.colorDomain ?? null), this.settings.palette && this.settings.palette !== e && t.setColorRamp(De(this.settings)), !0) : !1;
4383
+ }) ? (t.setColorDomain(this.settings.colorDomain ?? null), this.settings.palette && this.settings.palette !== e && t.setColorRamp(Le(this.settings)), !0) : !1;
4955
4384
  }
4956
4385
  detach() {
4957
4386
  const e = this.layer;
@@ -4966,19 +4395,19 @@ class Aa {
4966
4395
  }
4967
4396
  getQuerySource(e) {
4968
4397
  let t = this.querySources.get(e);
4969
- return t || (t = new _e(e, 80), this.querySources.set(e, t)), t;
4398
+ return t || (t = new ve(e, 80), this.querySources.set(e, t)), t;
4970
4399
  }
4971
4400
  getFieldSource(e) {
4972
4401
  let t = this.fieldSources.get(e);
4973
- return t || (t = new _e(e), this.fieldSources.set(e, t)), t;
4402
+ return t || (t = new ve(e), this.fieldSources.set(e, t)), t;
4974
4403
  }
4975
4404
  /**
4976
4405
  * Time the caller asked for, so selection skips fixed-period sources (such
4977
4406
  * as a GeoVideo artifact) that cannot show it. A trailing window targets now.
4978
4407
  */
4979
4408
  sourceTimeRequest(e, t) {
4980
- const i = t ?? this.pendingTime, a = {};
4981
- return i != null && (a.time = z(i, "time")), e?.trailing ? a.start = a.end = Date.now() : e && (e.start != null && (a.start = z(e.start, "timeRange.start")), e.end != null && (a.end = z(e.end, "timeRange.end"))), a;
4409
+ const i = t ?? this.pendingTime, s = {};
4410
+ return i != null && (s.time = z(i, "time")), e?.trailing ? s.start = s.end = Date.now() : e && (e.start != null && (s.start = z(e.start, "timeRange.start")), e.end != null && (s.end = z(e.end, "timeRange.end"))), s;
4982
4411
  }
4983
4412
  /**
4984
4413
  * Source for a preference and target. An archive (pinned, or the
@@ -4987,25 +4416,25 @@ class Aa {
4987
4416
  * "auto" moves on to Zarr. Regional artifacts show only when pinned. In
4988
4417
  * "auto", a level deeper than the surface GeoVideo renders shows Zarr.
4989
4418
  */
4990
- async selectSource(e, t, i, a = {}) {
4991
- const r = this.sourceTimeRequest(i, a.time), n = Ee(e, t);
4419
+ async selectSource(e, t, i, s = {}) {
4420
+ const r = this.sourceTimeRequest(i, s.time), n = Pe(e, t);
4992
4421
  if (n) {
4993
- const o = await this.archiveLevels(e, n), d = o.depths.length > 0 && a.depth != null ? nt(o, a.depth) : this.catalogLayer?.id === e.id && this.catalogSource?.id === n.id ? this.archiveLevel : null, c = await this.resolveArchives(e, d), u = c.sources.filter(
4422
+ const o = await this.archiveLevels(e, n), d = o.depths.length > 0 && s.depth != null ? st(o, s.depth) : this.catalogLayer?.id === e.id && this.catalogSource?.id === n.id ? this.archiveLevel : null, u = await this.resolveArchives(e, d), h = u.sources.filter(
4994
4423
  (m) => m.id === n.id
4995
4424
  );
4996
- if (u.length) {
4425
+ if (h.length) {
4997
4426
  const m = await this.archiveSample(
4998
4427
  e,
4999
4428
  n.id,
5000
4429
  i,
5001
- a.time,
4430
+ s.time,
5002
4431
  d
5003
- ), p = si(u, { time: m });
5004
- if (p && !this.isFailedGeoVideo(p))
5005
- return p;
4432
+ ), f = ii(h, { time: m });
4433
+ if (f && !this.isFailedGeoVideo(f))
4434
+ return f;
5006
4435
  if (t !== "auto" || this.catalogSource?.id === n.id)
5007
4436
  throw new Error(
5008
- `GeoVideo chunk unavailable: ${p?.type === "geovideo" ? p.manifestUrl : n.id}`
4437
+ `GeoVideo chunk unavailable: ${f?.type === "geovideo" ? f.manifestUrl : n.id}`
5009
4438
  );
5010
4439
  } else {
5011
4440
  if (d != null)
@@ -5013,17 +4442,17 @@ class Aa {
5013
4442
  if (t !== "auto")
5014
4443
  throw new Error(`GeoVideo archive unavailable: ${n.id}`);
5015
4444
  }
5016
- const f = he(c, ["zarr"], r);
5017
- if (f)
5018
- return f;
4445
+ const v = ue(u, ["zarr"], r);
4446
+ if (v)
4447
+ return v;
5019
4448
  e = {
5020
- ...c,
5021
- sources: c.sources.filter(
4449
+ ...u,
4450
+ sources: u.sources.filter(
5022
4451
  (m) => m.type !== "geovideo"
5023
4452
  )
5024
4453
  };
5025
4454
  }
5026
- return t === "auto" && this.isFailedGeoVideo(this.resolveSource(e, t, r)) ? he(e, ["zarr"], r) ?? this.resolveSource(
4455
+ return t === "auto" && this.isFailedGeoVideo(this.resolveSource(e, t, r)) ? ue(e, ["zarr"], r) ?? this.resolveSource(
5027
4456
  this.withoutFailedGeoVideo(e),
5028
4457
  t,
5029
4458
  r
@@ -5041,7 +4470,7 @@ class Aa {
5041
4470
  }
5042
4471
  isArchiveChunk(e) {
5043
4472
  return e.type === "geovideo" && !!this.catalogLayer?.sources.some(
5044
- (t) => t.id === e.id && Fe(t)
4473
+ (t) => t.id === e.id && ke(t)
5045
4474
  );
5046
4475
  }
5047
4476
  /**
@@ -5053,7 +4482,7 @@ class Aa {
5053
4482
  if (!e || !t || !this.isArchiveChunk(t))
5054
4483
  return null;
5055
4484
  const i = this.archiveLevel;
5056
- return ri(
4485
+ return ai(
5057
4486
  (await this.resolveArchives(e, i)).sources,
5058
4487
  t,
5059
4488
  {
@@ -5064,7 +4493,7 @@ class Aa {
5064
4493
  }
5065
4494
  /** A chunk manifest, reusing the one requested ahead for the next chunk. */
5066
4495
  loadChunkManifest(e) {
5067
- return this.nextChunkManifest?.url === e ? this.nextChunkManifest.manifest : Ce(e);
4496
+ return this.nextChunkManifest?.url === e ? this.nextChunkManifest.manifest : Ae(e);
5068
4497
  }
5069
4498
  /**
5070
4499
  * While a scalar archive chunk plays, load the next chunk into the layer so
@@ -5074,10 +4503,10 @@ class Aa {
5074
4503
  const t = this.catalogSource;
5075
4504
  if (t)
5076
4505
  try {
5077
- const i = await this.nextArchiveChunk(), a = i?.source.type === "geovideo" && i.source.manifestUrl;
5078
- if (!i || !a)
4506
+ const i = await this.nextArchiveChunk(), s = i?.source.type === "geovideo" && i.source.manifestUrl;
4507
+ if (!i || !s)
5079
4508
  return;
5080
- this.nextChunkManifest?.url !== a && (this.nextChunkManifest = { url: a, manifest: Ce(a) });
4509
+ this.nextChunkManifest?.url !== s && (this.nextChunkManifest = { url: s, manifest: Ae(s) });
5081
4510
  const r = this.nextChunkManifest, n = await r.manifest.catch((o) => {
5082
4511
  throw this.nextChunkManifest === r && (this.nextChunkManifest = null), o;
5083
4512
  });
@@ -5115,7 +4544,7 @@ class Aa {
5115
4544
  }
5116
4545
  /** The entry's initialised field Zarr, or null when it has none. */
5117
4546
  async entryFieldZarr(e) {
5118
- const t = he(e, ["zarr"]);
4547
+ const t = ue(e, ["zarr"]);
5119
4548
  if (t?.type !== "zarr")
5120
4549
  return null;
5121
4550
  const i = this.getFieldSource(t.endpoints.field);
@@ -5127,22 +4556,22 @@ class Aa {
5127
4556
  * a time; one that cannot be read only leaves its samples out.
5128
4557
  */
5129
4558
  async archiveTimes(e, t, i = null) {
5130
- const a = (await this.resolveArchives(e, i)).sources.flatMap(
4559
+ const s = (await this.resolveArchives(e, i)).sources.flatMap(
5131
4560
  (n) => n.id === t && n.type === "geovideo" && n.manifestUrl ? [n.manifestUrl] : []
5132
- ), r = a.filter((n) => !this.chunkTimes.has(n));
5133
- for (let n = 0; n < r.length; n += lt) {
5134
- const o = r.slice(n, n + lt);
4561
+ ), r = s.filter((n) => !this.chunkTimes.has(n));
4562
+ for (let n = 0; n < r.length; n += nt) {
4563
+ const o = r.slice(n, n + nt);
5135
4564
  (await Promise.allSettled(
5136
4565
  o.map((d) => this.loadChunkManifest(d))
5137
- )).forEach((d, c) => {
5138
- d.status === "fulfilled" ? this.chunkTimes.set(o[c], we(d.value)) : console.warn(
4566
+ )).forEach((d, u) => {
4567
+ d.status === "fulfilled" ? this.chunkTimes.set(o[u], we(d.value)) : console.warn(
5139
4568
  "[zartigl] GeoVideo chunk samples unavailable:",
5140
4569
  d.reason
5141
4570
  );
5142
4571
  });
5143
4572
  }
5144
4573
  return [
5145
- ...new Set(a.flatMap((n) => this.chunkTimes.get(n) ?? []))
4574
+ ...new Set(s.flatMap((n) => this.chunkTimes.get(n) ?? []))
5146
4575
  ].sort((n, o) => n - o);
5147
4576
  }
5148
4577
  /**
@@ -5151,14 +4580,14 @@ class Aa {
5151
4580
  * the latest without a time. Snapping once, here, keeps the chunk loaded
5152
4581
  * and the time shown in agreement.
5153
4582
  */
5154
- async archiveSample(e, t, i, a, r = null) {
5155
- const n = await this.archiveTimes(e, t, r), [o, l] = i && n.length ? xt(i, [n[0], n[n.length - 1]]) : [-1 / 0, 1 / 0], d = n.filter((u) => u >= o && u <= l);
4583
+ async archiveSample(e, t, i, s, r = null) {
4584
+ const n = await this.archiveTimes(e, t, r), [o, c] = i && n.length ? yt(i, [n[0], n[n.length - 1]]) : [-1 / 0, 1 / 0], d = n.filter((h) => h >= o && h <= c);
5156
4585
  if (d.length === 0)
5157
4586
  throw new RangeError(
5158
4587
  "Time range does not contain any available timestamps"
5159
4588
  );
5160
- const c = this.sourceTimeRequest(void 0, a).time;
5161
- return c == null ? d[d.length - 1] : U(d, c);
4589
+ const u = this.sourceTimeRequest(void 0, s).time;
4590
+ return u == null ? d[d.length - 1] : F(d, u);
5162
4591
  }
5163
4592
  /**
5164
4593
  * Entry whose archive sources are replaced by one fixed-period source per
@@ -5168,22 +4597,22 @@ class Aa {
5168
4597
  */
5169
4598
  async resolveArchives(e, t = null) {
5170
4599
  const i = await Promise.all(
5171
- e.sources.map(async (a) => {
5172
- if (!Fe(a))
5173
- return [a];
4600
+ e.sources.map(async (s) => {
4601
+ if (!ke(s))
4602
+ return [s];
5174
4603
  const r = await this.archiveChunksAt(
5175
4604
  e,
5176
- a,
5177
- a.indexUrl,
4605
+ s,
4606
+ s.indexUrl,
5178
4607
  null
5179
4608
  );
5180
4609
  if (t == null)
5181
4610
  return r;
5182
- const n = this.archiveRoots.get(a.indexUrl)?.depths.find((o) => o.value === t);
4611
+ const n = this.archiveRoots.get(s.indexUrl)?.depths.find((o) => o.value === t);
5183
4612
  return n ? this.archiveChunksAt(
5184
4613
  e,
5185
- a,
5186
- ni(n, a.indexUrl),
4614
+ s,
4615
+ si(n, s.indexUrl),
5187
4616
  n
5188
4617
  ) : [];
5189
4618
  })
@@ -5199,46 +4628,46 @@ class Aa {
5199
4628
  * which also lists the levels below, or a depth's, which must record that
5200
4629
  * level. Revalidated like any archive index.
5201
4630
  */
5202
- archiveChunksAt(e, t, i, a) {
4631
+ archiveChunksAt(e, t, i, s) {
5203
4632
  const r = this.archiveChunks.get(i);
5204
4633
  if (r && r.expires > Date.now())
5205
4634
  return r.chunks;
5206
4635
  const n = {
5207
- expires: Date.now() + ha,
5208
- chunks: oi(i).then((o) => {
5209
- if (a ? !He(o.vertical, a) : o.vertical !== void 0)
4636
+ expires: Date.now() + ta,
4637
+ chunks: ri(i).then((o) => {
4638
+ if (s ? !Xe(o.vertical, s) : o.vertical !== void 0)
5210
4639
  throw new Error(`GeoVideo index level does not match: ${i}`);
5211
- !a && !this.archiveRoots.has(t.indexUrl) && this.archiveRoots.set(t.indexUrl, {
4640
+ !s && !this.archiveRoots.has(t.indexUrl) && this.archiveRoots.set(t.indexUrl, {
5212
4641
  surface: o.surface,
5213
4642
  depths: o.depths ?? []
5214
4643
  });
5215
- const l = li(
4644
+ const c = ni(
5216
4645
  { ...t, indexUrl: i },
5217
4646
  o,
5218
4647
  e
5219
4648
  );
5220
- for (const d of ci(o, i))
5221
- this.chunkLevels.set(d.manifestUrl, a), d.times && this.chunkTimes.set(d.manifestUrl, d.times);
5222
- return l;
5223
- }).catch((o) => (console.warn("[zartigl] GeoVideo archive unavailable:", o), n.expires = Date.now() + ua, []))
4649
+ for (const d of oi(o, i))
4650
+ this.chunkLevels.set(d.manifestUrl, s), d.times && this.chunkTimes.set(d.manifestUrl, d.times);
4651
+ return c;
4652
+ }).catch((o) => (console.warn("[zartigl] GeoVideo archive unavailable:", o), n.expires = Date.now() + ia, []))
5224
4653
  };
5225
4654
  return this.archiveChunks.set(i, n), n.chunks;
5226
4655
  }
5227
4656
  resolveSource(e, t, i) {
5228
- const a = t === "auto" ? $t(e, i) : e.sources.find((r) => r.id === t) ?? he(
4657
+ const s = t === "auto" ? Nt(e, i) : e.sources.find((r) => r.id === t) ?? ue(
5229
4658
  e,
5230
4659
  [t],
5231
4660
  i
5232
4661
  );
5233
- if (!a)
4662
+ if (!s)
5234
4663
  throw new Error(
5235
4664
  `Catalog entry ${e.id} does not provide source: ${t}`
5236
4665
  );
5237
- if (e.kind === "vector" && a.type !== "zarr" && a.type !== "geovideo")
4666
+ if (e.kind === "vector" && s.type !== "zarr" && s.type !== "geovideo")
5238
4667
  throw new Error(
5239
4668
  `Vector catalog entry ${e.id} requires a Zarr or GeoVideo source`
5240
4669
  );
5241
- return a;
4670
+ return s;
5242
4671
  }
5243
4672
  querySource(e) {
5244
4673
  const t = e.defaults.querySourceId ? e.sources.find(
@@ -5267,7 +4696,7 @@ class Aa {
5267
4696
  /** First layer above the render layer that is not its own WMTS raster. */
5268
4697
  layerAbove(e) {
5269
4698
  const t = this.map.getLayersOrder?.() ?? [], i = t.indexOf(e);
5270
- return i < 0 ? void 0 : t.slice(i + 1).find((a) => a !== `${e}-wmts`);
4699
+ return i < 0 ? void 0 : t.slice(i + 1).find((s) => s !== `${e}-wmts`);
5271
4700
  }
5272
4701
  requireLayer() {
5273
4702
  if (!this.catalogLayer)
@@ -5282,37 +4711,37 @@ class Aa {
5282
4711
  emit(e, ...t) {
5283
4712
  const i = this.listeners.get(e);
5284
4713
  if (i)
5285
- for (const a of i)
5286
- a(...t);
4714
+ for (const s of i)
4715
+ s(...t);
5287
4716
  }
5288
4717
  }
5289
- function ga(s, e) {
5290
- const t = new Date(s).toISOString();
4718
+ function oa(a, e) {
4719
+ const t = new Date(a).toISOString();
5291
4720
  return e === "year" ? t.slice(0, 4) : e === "month" ? t.slice(0, 7) : e === "day" ? t.slice(0, 10) : "";
5292
4721
  }
5293
- function va(s, e) {
5294
- return e === "year" ? Date.UTC(Number(s), 0, 1) : e === "month" ? (/* @__PURE__ */ new Date(`${s}-01T00:00:00Z`)).getTime() : e === "day" ? (/* @__PURE__ */ new Date(`${s}T00:00:00Z`)).getTime() : (/* @__PURE__ */ new Date(`${s}Z`)).getTime();
4722
+ function la(a, e) {
4723
+ return e === "year" ? Date.UTC(Number(a), 0, 1) : e === "month" ? (/* @__PURE__ */ new Date(`${a}-01T00:00:00Z`)).getTime() : e === "day" ? (/* @__PURE__ */ new Date(`${a}T00:00:00Z`)).getTime() : (/* @__PURE__ */ new Date(`${a}Z`)).getTime();
5295
4724
  }
5296
- function Ca(s, e, t) {
5297
- if (!e || s.length === 0)
4725
+ function ba(a, e, t) {
4726
+ if (!e || a.length === 0)
5298
4727
  return;
5299
4728
  if (["year", "month", "day"].includes(t)) {
5300
- const a = s.find(
5301
- (r) => ga(r, t) === e
4729
+ const s = a.find(
4730
+ (r) => oa(r, t) === e
5302
4731
  );
5303
- if (a !== void 0)
5304
- return a;
4732
+ if (s !== void 0)
4733
+ return s;
5305
4734
  }
5306
- const i = va(e, t);
4735
+ const i = la(e, t);
5307
4736
  if (Number.isFinite(i))
5308
- return s.reduce(
5309
- (a, r) => Math.abs(r - i) < Math.abs(a - i) ? r : a
4737
+ return a.reduce(
4738
+ (s, r) => Math.abs(r - i) < Math.abs(s - i) ? r : s
5310
4739
  );
5311
4740
  }
5312
- const Vt = gt.devDependencies["maplibre-gl"].replace(
4741
+ const Ft = ft.devDependencies["maplibre-gl"].replace(
5313
4742
  /^[^\d]*/,
5314
4743
  ""
5315
- ), ya = `https://cdn.jsdelivr.net/npm/maplibre-gl@${Vt}/+esm`, _a = `https://cdn.jsdelivr.net/npm/maplibre-gl@${Vt}/dist/maplibre-gl.css`, xa = `{
4744
+ ), ca = `https://cdn.jsdelivr.net/npm/maplibre-gl@${Ft}/+esm`, ua = `https://cdn.jsdelivr.net/npm/maplibre-gl@${Ft}/dist/maplibre-gl.css`, ha = `{
5316
4745
  version: 8,
5317
4746
  sources: {
5318
4747
  "eox-cloudless": {
@@ -5333,60 +4762,60 @@ const Vt = gt.devDependencies["maplibre-gl"].replace(
5333
4762
  }
5334
4763
  ]
5335
4764
  }`;
5336
- function q(s) {
5337
- return JSON.stringify(s);
4765
+ function $(a) {
4766
+ return JSON.stringify(a);
5338
4767
  }
5339
- function ba(s) {
5340
- return JSON.stringify(s, null, 2);
4768
+ function da(a) {
4769
+ return JSON.stringify(a, null, 2);
5341
4770
  }
5342
- function Ut(s) {
5343
- return s instanceof Date ? `new Date(${q(s.toISOString())})` : typeof s == "string" ? `new Date(${q(s)})` : String(s);
4771
+ function Vt(a) {
4772
+ return a instanceof Date ? `new Date(${$(a.toISOString())})` : typeof a == "string" ? `new Date(${$(a)})` : String(a);
5344
4773
  }
5345
- function ie(s, e = 6) {
5346
- return String(Number(s.toFixed(e)));
4774
+ function ie(a, e = 6) {
4775
+ return String(Number(a.toFixed(e)));
5347
4776
  }
5348
- function $(s, e) {
4777
+ function B(a, e) {
5349
4778
  const t = " ".repeat(e);
5350
- return ba(s).split(`
4779
+ return da(a).split(`
5351
4780
  `).map((i) => `${t}${i}`).join(`
5352
4781
  `).trimStart();
5353
4782
  }
5354
- function Sa(s, e) {
4783
+ function ma(a, e) {
5355
4784
  const t = " ".repeat(e);
5356
- return s.split(`
4785
+ return a.split(`
5357
4786
  `).map((i) => i.length > 0 ? `${t}${i}` : i).join(`
5358
4787
  `);
5359
4788
  }
5360
- const wa = (s) => {
5361
- const e = s.source ?? "auto";
5362
- return s.sourceType ?? (e === "wmts" || e === "geovideo" ? e : "zarr");
4789
+ const fa = (a) => {
4790
+ const e = a.source ?? "auto";
4791
+ return a.sourceType ?? (e === "wmts" || e === "geovideo" ? e : "zarr");
5363
4792
  };
5364
- function Nt(s) {
5365
- const { layerKind: e, layerDefaults: t } = s, i = pt(s.style ?? {}, e), a = t === void 0 ? i : qt(i, ze({ kind: e, defaults: t })), r = a.raster?.opacity, n = wa(s) !== "wmts" ? a : r === void 0 ? {} : { raster: { opacity: r } };
4793
+ function Ut(a) {
4794
+ const { layerKind: e, layerDefaults: t } = a, i = mt(a.style ?? {}, e), s = t === void 0 ? i : Bt(i, ze({ kind: e, defaults: t })), r = s.raster?.opacity, n = fa(a) !== "wmts" ? s : r === void 0 ? {} : { raster: { opacity: r } };
5366
4795
  return Object.keys(n).length ? n : void 0;
5367
4796
  }
5368
- function zt(s) {
5369
- const { particleState: e, rgba8MaxParticleZoom: t } = s.settings ?? {}, i = Object.fromEntries(
4797
+ function It(a) {
4798
+ const { particleState: e, rgba8MaxParticleZoom: t } = a.settings ?? {}, i = Object.fromEntries(
5370
4799
  Object.entries({ particleState: e, rgba8MaxParticleZoom: t }).filter(
5371
- ([, a]) => a !== void 0
4800
+ ([, s]) => s !== void 0
5372
4801
  )
5373
4802
  );
5374
- return s.layerKind === "vector" && Object.keys(i).length ? i : void 0;
4803
+ return a.layerKind === "vector" && Object.keys(i).length ? i : void 0;
5375
4804
  }
5376
- function ka(s) {
5377
- const e = s.source ?? "auto", t = Nt(s), i = zt(s), a = [
4805
+ function Sa(a) {
4806
+ const e = a.source ?? "auto", t = Ut(a), i = It(a), s = [
5378
4807
  " idView: widget.opt.view.id,",
5379
4808
  " map: widget.opt.map,",
5380
- ` layer: ${q(s.layerId)},`,
5381
- ` source: ${q(e)},`
4809
+ ` layer: ${$(a.layerId)},`,
4810
+ ` source: ${$(e)},`
5382
4811
  ];
5383
4812
  for (const r of ["title", "subtitle", "description"])
5384
- s[r] != null && a.push(` ${r}: ${$(s[r], 10)},`);
5385
- return s.entry && a.push(` entry: ${$(s.entry, 10)},`), t && a.push(` style: ${$(t, 10)},`), i && a.push(` settings: ${$(i, 10)},`), s.time != null && a.push(` time: ${Ut(s.time)},`), s.timeRange != null && a.push(
5386
- ` timeRange: ${$(s.timeRange, 10)},`
5387
- ), s.geoVideo != null && a.push(
5388
- ` geoVideo: ${$(s.geoVideo, 10)},`
5389
- ), s.depth != null && a.push(` depth: ${s.depth},`), a.push(
4813
+ a[r] != null && s.push(` ${r}: ${B(a[r], 10)},`);
4814
+ return a.entry && s.push(` entry: ${B(a.entry, 10)},`), t && s.push(` style: ${B(t, 10)},`), i && s.push(` settings: ${B(i, 10)},`), a.time != null && s.push(` time: ${Vt(a.time)},`), a.timeRange != null && s.push(
4815
+ ` timeRange: ${B(a.timeRange, 10)},`
4816
+ ), a.geoVideo != null && s.push(
4817
+ ` geoVideo: ${B(a.geoVideo, 10)},`
4818
+ ), a.depth != null && s.push(` depth: ${a.depth},`), s.push(
5390
4819
  " elLegend: elLegend,",
5391
4820
  " elInputs: widget.elContent,"
5392
4821
  ), `function handler() {
@@ -5405,7 +4834,7 @@ function ka(s) {
5405
4834
  const elLegend = getViewLegend(widget.opt.view, { clone: false });
5406
4835
 
5407
4836
  local.arco = new ArcoMapLegend({
5408
- ${a.join(`
4837
+ ${s.join(`
5409
4838
  `)}
5410
4839
  });
5411
4840
 
@@ -5421,19 +4850,19 @@ ${a.join(`
5421
4850
  };
5422
4851
  }`;
5423
4852
  }
5424
- function Ta(s) {
5425
- const e = s.moduleBaseUrl ?? `https://cdn.jsdelivr.net/npm/@fxi/zartigl@${gt.version}/dist`, t = s.source ?? "auto", i = Nt(s), a = zt(s), r = s.timeRange == null ? "" : ` timeRange: ${$(s.timeRange, 2)},
5426
- `, n = s.geoVideo == null ? "" : ` geoVideo: ${$(s.geoVideo, 2)},
5427
- `, o = i == null ? "" : ` style: ${$(i, 2)},
5428
- `, l = a == null ? "" : ` settings: ${$(a, 2)},
5429
- `, d = s.time == null ? "" : ` time: ${Ut(s.time)},
5430
- `, c = s.depth == null ? "" : ` depth: ${s.depth},
5431
- `, u = s.center ?? [0, 20], f = s.projection ?? "mercator", m = s.mapStyle == null ? xa : q(s.mapStyle), p = `map.setProjection({ type: ${q(f)} });
4853
+ function pa(a) {
4854
+ const e = a.moduleBaseUrl ?? `https://cdn.jsdelivr.net/npm/@fxi/zartigl@${ft.version}/dist`, t = a.source ?? "auto", i = Ut(a), s = It(a), r = a.timeRange == null ? "" : ` timeRange: ${B(a.timeRange, 2)},
4855
+ `, n = a.geoVideo == null ? "" : ` geoVideo: ${B(a.geoVideo, 2)},
4856
+ `, o = i == null ? "" : ` style: ${B(i, 2)},
4857
+ `, c = s == null ? "" : ` settings: ${B(s, 2)},
4858
+ `, d = a.time == null ? "" : ` time: ${Vt(a.time)},
4859
+ `, u = a.depth == null ? "" : ` depth: ${a.depth},
4860
+ `, h = a.center ?? [0, 20], v = a.projection ?? "mercator", m = a.mapStyle == null ? ha : $(a.mapStyle), f = `map.setProjection({ type: ${$(v)} });
5432
4861
  map.jumpTo({
5433
- center: [${ie(u[0])}, ${ie(u[1])}],
5434
- zoom: ${ie(s.zoom ?? 2, 3)},
5435
- bearing: ${ie(s.bearing ?? 0, 3)},
5436
- pitch: ${ie(s.pitch ?? 0, 3)},
4862
+ center: [${ie(h[0])}, ${ie(h[1])}],
4863
+ zoom: ${ie(a.zoom ?? 2, 3)},
4864
+ bearing: ${ie(a.bearing ?? 0, 3)},
4865
+ pitch: ${ie(a.pitch ?? 0, 3)},
5437
4866
  });
5438
4867
  map.setSky({
5439
4868
  "sky-color": "#05070f",
@@ -5455,12 +4884,12 @@ const z = new Zartigl({
5455
4884
  id: "zartigl-demo",
5456
4885
  map,
5457
4886
  catalog,
5458
- layer: ${q(s.layerId)},
5459
- source: ${q(t)},
5460
- ${r}${n}${o}${l}${d}${c}});
4887
+ layer: ${$(a.layerId)},
4888
+ source: ${$(t)},
4889
+ ${r}${n}${o}${c}${d}${u}});
5461
4890
 
5462
4891
  await z.init();`;
5463
- return `import maplibregl from ${q(ya)};
4892
+ return `import maplibregl from ${$(ca)};
5464
4893
  import { Zartigl } from "${e}/zartigl.js";
5465
4894
  import { catalog } from "${e}/catalog.js";
5466
4895
 
@@ -5472,18 +4901,18 @@ const map = new maplibregl.Map({
5472
4901
  });
5473
4902
 
5474
4903
  map.once("style.load", async () => {
5475
- ${Sa(p, 2)}
4904
+ ${ma(f, 2)}
5476
4905
  });`;
5477
4906
  }
5478
- function Fa(s) {
5479
- const e = Ta(s);
4907
+ function wa(a) {
4908
+ const e = pa(a);
5480
4909
  return `<!doctype html>
5481
4910
  <html lang="en">
5482
4911
  <head>
5483
4912
  <meta charset="UTF-8" />
5484
4913
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
5485
4914
  <title>Zartigl demo</title>
5486
- <link rel="stylesheet" href=${q(_a)} />
4915
+ <link rel="stylesheet" href=${$(ua)} />
5487
4916
  <style>
5488
4917
  html, body, #map {
5489
4918
  width: 100%;
@@ -5505,41 +4934,41 @@ ${e}
5505
4934
  </html>`;
5506
4935
  }
5507
4936
  export {
5508
- hi as BACKDROP_OFF,
5509
- ui as COLOR_GRADE_OFF,
5510
- Ga as COLOR_GRADE_VIBRANT,
5511
- na as GEOVIDEO_SPEEDS,
4937
+ li as BACKDROP_OFF,
4938
+ ci as COLOR_GRADE_OFF,
4939
+ La as COLOR_GRADE_VIBRANT,
4940
+ Qi as GEOVIDEO_SPEEDS,
5512
4941
  G as GeoVideoLayer,
5513
- Ft as LEGACY_STYLE_SETTINGS,
5514
- Rt as ParticleSimulation,
4942
+ Ct as LEGACY_STYLE_SETTINGS,
4943
+ Tt as ParticleSimulation,
5515
4944
  me as ScalarLayer,
5516
- it as VECTOR_GEOVIDEO_SPEEDS,
5517
- P as VectorLayer,
5518
- Pt as VelocityField,
5519
- _e as ZarrSource,
5520
- Aa as Zartigl,
4945
+ et as VECTOR_GEOVIDEO_SPEEDS,
4946
+ M as VectorLayer,
4947
+ Rt as VelocityField,
4948
+ ve as ZarrSource,
4949
+ xa as Zartigl,
5521
4950
  xe as ZartiglFrameUnavailableError,
5522
- ka as buildMapxWidgetSnippet,
5523
- Fa as buildStandaloneDemoHtml,
5524
- Ta as buildStandaloneDemoSnippet,
5525
- Zi as buildWmtsLegendUrl,
5526
- Je as buildWmtsTileUrl,
5527
- fi as colorGradeToGrade,
5528
- Wi as deriveDirectionMagnitudeComponents,
5529
- Ye as formatUnit,
5530
- ei as geoVideoSecondsForTime,
5531
- Ua as geoVideoTimeForSeconds,
4951
+ Sa as buildMapxWidgetSnippet,
4952
+ wa as buildStandaloneDemoHtml,
4953
+ pa as buildStandaloneDemoSnippet,
4954
+ Oi as buildWmtsLegendUrl,
4955
+ Qe as buildWmtsTileUrl,
4956
+ di as colorGradeToGrade,
4957
+ Ui as deriveDirectionMagnitudeComponents,
4958
+ He as formatUnit,
4959
+ Kt as geoVideoSecondsForTime,
4960
+ Ma as geoVideoTimeForSeconds,
5532
4961
  we as geoVideoTimelineValues,
5533
- _t as getPalettes,
5534
- Da as getVectorDerivationVariables,
5535
- pi as gradeToColorGrade,
5536
- Oa as isHexColor,
5537
- Ce as loadGeoVideoManifest,
5538
- St as resolveBackdrop,
5539
- bt as resolveColorGrade,
5540
- ke as resolveColorRamp,
5541
- Ca as resolveTimeInputSelection,
5542
- Ae as splitLegacySettings,
5543
- Et as stitchVelocityChunks,
5544
- Na as validateGeoVideoManifest
4962
+ vt as getPalettes,
4963
+ _a as getVectorDerivationVariables,
4964
+ mi as gradeToColorGrade,
4965
+ Da as isHexColor,
4966
+ Ae as loadGeoVideoManifest,
4967
+ xt as resolveBackdrop,
4968
+ _t as resolveColorGrade,
4969
+ Ce as resolveColorRamp,
4970
+ ba as resolveTimeInputSelection,
4971
+ De as splitLegacySettings,
4972
+ Mt as stitchVelocityChunks,
4973
+ Pa as validateGeoVideoManifest
5545
4974
  };