@fxi/zartigl 0.14.0 → 0.14.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/zartigl.js CHANGED
@@ -1,59 +1,68 @@
1
- import { m as ae, p as ft, s as pt, a as qe, b as Gt, r as ze, c as Ot, d as he, e as Bt, f as gt, g as $t } from "./index-Cd7Nk4ve.js";
2
- import { T as qt, g as Wt, r as Xt, d as Ht, c as W, a as Yt, b as ge, e as Zt, f as J, h as Se, i as O, G as jt, j as We, F as Qt, 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 Kt, t as ke, u as Jt, w as _t, x as z, y as He, z as we, A as ei, B as ti, C as ii, D as Ye, E as ai, H as Fe, I as si, J as xt, K as ri, L as ni, M as oi, N as li } from "./engine-CiDquHYk.js";
3
- import { O as Ua, P as Va } from "./engine-CiDquHYk.js";
4
- import { B as ci, a as hi, b as ui, c as di, d as bt, r as St, e as mi, g as fi } from "./backdrop-Dceb4d8E.js";
5
- import { f as za, i as Ga } from "./backdrop-Dceb4d8E.js";
6
- import { inflate as pi } from "pako";
7
- import gi from "numcodecs/blosc";
8
- const Ie = 85, vi = 89.9;
9
- function Ue(s) {
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
10
  return Math.max(-Ie, Math.min(Ie, s));
11
11
  }
12
12
  function Ze(s) {
13
- const e = Ue(s), t = Math.sin(e * Math.PI / 180);
13
+ const e = Ve(s), t = Math.sin(e * Math.PI / 180);
14
14
  return 0.5 - Math.log((1 + t) / (1 - t)) / (4 * Math.PI);
15
15
  }
16
16
  function ve(s) {
17
17
  return (s + 180) / 360;
18
18
  }
19
- function yi(s) {
19
+ function _i(s) {
20
20
  return ((s + 180) % 360 + 360) % 360 - 180;
21
21
  }
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]);
24
+ return {
25
+ west: s[t[0]] - r,
26
+ east: s[t[1]] + r,
27
+ south: Math.min(e[i[0]], e[i[1]]) - n,
28
+ north: Math.max(e[i[0]], e[i[1]]) + n
29
+ };
30
+ }
22
31
  function ye(s, e) {
23
32
  if (s.getProjection?.()?.type !== "globe")
24
33
  return !1;
25
34
  const t = e?.projectionTransition;
26
35
  return typeof t == "number" ? t > 0 : !0;
27
36
  }
28
- function _i(s, e) {
29
- const t = yi(s) * Math.PI / 180, i = e * Math.PI / 180, a = Math.cos(i);
37
+ function xi(s, e) {
38
+ const t = _i(s) * Math.PI / 180, i = e * Math.PI / 180, a = Math.cos(i);
30
39
  return [
31
40
  Math.sin(t) * a,
32
41
  Math.sin(i),
33
42
  Math.cos(t) * a
34
43
  ];
35
44
  }
36
- function xi(s) {
45
+ function bi(s) {
37
46
  return {
38
47
  west: -180,
39
48
  east: 180,
40
- south: Ue(s.getSouth()),
41
- north: Ue(s.getNorth())
49
+ south: Ve(s.getSouth()),
50
+ north: Ve(s.getNorth())
42
51
  };
43
52
  }
44
- function bi(s, e = 1, t = !1) {
45
- const i = t ? vi : Ie, a = (d) => Math.max(-i, Math.min(i, d)), r = a(s.getSouth()), n = a(s.getNorth()), c = Math.max(0, n - r) * Math.max(0, e);
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);
46
55
  return {
47
56
  west: -180,
48
57
  east: 180,
49
- south: a(r - c),
50
- north: a(n + c)
58
+ south: a(r - l),
59
+ north: a(n + l)
51
60
  };
52
61
  }
53
- function Si(s, e, t = 1e-6) {
62
+ function wi(s, e, t = 1e-6) {
54
63
  return s.south <= e.south + t && s.north >= e.north - t;
55
64
  }
56
- function wi(s, e = !1) {
65
+ function Ti(s, e = !1) {
57
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 };
58
67
  return e ? {
59
68
  ...o,
@@ -95,7 +104,7 @@ out vec2 v_tex_coord;
95
104
  void main() {
96
105
  v_tex_coord = a_position * 0.5 + 0.5;
97
106
  gl_Position = vec4(a_position, 0.0, 1.0);
98
- }`, Ti = `#version 300 es
107
+ }`, Mi = `#version 300 es
99
108
  precision highp float;
100
109
 
101
110
  uint pcg(uint v) {
@@ -365,7 +374,7 @@ void main() {
365
374
  fract(newPos.y * 255.0)
366
375
  );
367
376
  #endif
368
- }`, Mi = `precision highp float;
377
+ }`, Ri = `precision highp float;
369
378
 
370
379
  attribute float a_index;
371
380
  attribute float a_is_curr;
@@ -597,7 +606,7 @@ void main() {
597
606
  vec2 worldPos = vec2((pos.x + u_world_offset) * u_world_size, pos.y * u_world_size);
598
607
  gl_Position = u_matrix * vec4(worldPos, 0.0, 1.0);
599
608
  }
600
- }`, Ri = `precision mediump float;
609
+ }`, Pi = `precision mediump float;
601
610
 
602
611
  uniform sampler2D u_color_ramp;
603
612
  uniform float u_particle_contrast;
@@ -636,7 +645,7 @@ void main() {
636
645
  }
637
646
 
638
647
  gl_FragColor = vec4(color.rgb, color.a * u_opacity);
639
- }`, Pi = `#version 300 es
648
+ }`, Ei = `#version 300 es
640
649
  precision mediump float;
641
650
 
642
651
  uniform sampler2D u_screen;
@@ -653,7 +662,7 @@ void main() {
653
662
  float alpha = floor(color.a * 255.0 * u_opacity) / 255.0;
654
663
 
655
664
  o_color = vec4(color.rgb * step(1.0 / 255.0, alpha), alpha);
656
- }`, Ei = `#version 300 es
665
+ }`, Li = `#version 300 es
657
666
  precision mediump float;
658
667
 
659
668
  uniform sampler2D u_screen;
@@ -724,7 +733,7 @@ void main() {
724
733
  }
725
734
  vec3 rgb = u_grade_on > 0.5 ? gradeColor(color.rgb, u_grade) : color.rgb;
726
735
  o_color = vec4(rgb, color.a);
727
- }`, Li = `#version 300 es
736
+ }`, Di = `#version 300 es
728
737
  precision mediump float;
729
738
 
730
739
  uniform sampler2D u_screen;
@@ -761,7 +770,7 @@ vec4 addGlow(vec4 trail, sampler2D glowTex, vec2 uv, float gain) {
761
770
 
762
771
  void main() {
763
772
  o_color = glowGather(u_screen, ivec2(gl_FragCoord.xy));
764
- }`, wt = `precision highp float;
773
+ }`, Tt = `precision highp float;
765
774
 
766
775
  attribute vec2 a_grid_uv;
767
776
 
@@ -785,14 +794,17 @@ float latToMercY(float lat) {
785
794
  }
786
795
 
787
796
  void main() {
788
- float lng = mix(u_geo_bounds.x, u_geo_bounds.z, a_grid_uv.x);
797
+
798
+ float width = u_geo_bounds.z - u_geo_bounds.x;
799
+ float east = width >= 359.0 ? u_geo_bounds.x + 360.0 : u_geo_bounds.z;
800
+ float lng = mix(u_geo_bounds.x, east, a_grid_uv.x);
789
801
  float lat = mix(u_geo_bounds.y, u_geo_bounds.w, a_grid_uv.y);
790
802
  vec2 merc = vec2(lngToMercX(lng) + u_world_offset, latToMercY(lat));
791
803
  vec2 worldPos = merc * u_world_size;
792
804
 
793
- v_geo_uv = a_grid_uv;
805
+ v_geo_uv = vec2((lng - u_geo_bounds.x) / width, a_grid_uv.y);
794
806
  gl_Position = u_matrix * vec4(worldPos, 0.0, 1.0);
795
- }`, Di = `precision mediump float;
807
+ }`, Ai = `precision mediump float;
796
808
 
797
809
  uniform sampler2D u_field;
798
810
  uniform sampler2D u_color_ramp;
@@ -855,7 +867,8 @@ vec3 sampleVelocityPair(sampler2D field, vec2 uv, vec2 minimum, vec2 maximum) {
855
867
  }
856
868
 
857
869
  void main() {
858
- if (v_geo_uv.x < 0.0 || v_geo_uv.x > 1.0 || v_geo_uv.y < 0.0 || v_geo_uv.y > 1.0) {
870
+
871
+ if (v_geo_uv.y < 0.0 || v_geo_uv.y > 1.0) {
859
872
  discard;
860
873
  }
861
874
 
@@ -891,7 +904,7 @@ void main() {
891
904
  vec4 color = texture2D(u_color_ramp, vec2(t, 0.5));
892
905
  color.rgb = applyVibrance(color.rgb, u_vibrance);
893
906
  gl_FragColor = vec4(color.rgb, color.a * u_opacity);
894
- }`, Tt = `precision highp float;
907
+ }`, Mt = `precision highp float;
895
908
 
896
909
  attribute vec2 a_grid_uv;
897
910
 
@@ -907,8 +920,15 @@ varying vec2 v_geo_uv;
907
920
  const float PI = 3.14159265358979323846;
908
921
 
909
922
  void main() {
910
- float lng = mix(u_geo_bounds.x, u_geo_bounds.z, a_grid_uv.x);
911
- float lat = mix(u_geo_bounds.y, u_geo_bounds.w, a_grid_uv.y);
923
+
924
+
925
+
926
+
927
+ float width = u_geo_bounds.z - u_geo_bounds.x;
928
+ float east = width >= 359.0 ? u_geo_bounds.x + 360.0 : u_geo_bounds.z;
929
+ float lng = mix(u_geo_bounds.x, east, a_grid_uv.x);
930
+
931
+ float lat = clamp(mix(u_geo_bounds.y, u_geo_bounds.w, a_grid_uv.y), -90.0, 90.0);
912
932
  float lngRad = radians(lng);
913
933
  float latRad = radians(lat);
914
934
  float cosLat = cos(latRad);
@@ -918,7 +938,7 @@ void main() {
918
938
  cos(lngRad) * cosLat
919
939
  );
920
940
 
921
- v_geo_uv = a_grid_uv;
941
+ v_geo_uv = vec2((lng - u_geo_bounds.x) / width, a_grid_uv.y);
922
942
  vec4 position = u_matrix * vec4(ecef, 1.0);
923
943
  position.z = (1.0 - (dot(ecef, u_clipping_plane.xyz) + u_clipping_plane.w)) * position.w;
924
944
  if (u_projection_transition < 0.999) {
@@ -934,7 +954,7 @@ void main() {
934
954
  position.xyw = mix(flatPosition.xyw, position.xyw, u_projection_transition);
935
955
  }
936
956
  gl_Position = position;
937
- }`, Ai = `precision mediump float;
957
+ }`, Ci = `precision mediump float;
938
958
 
939
959
  uniform sampler2D u_field;
940
960
  uniform sampler2D u_color_ramp;
@@ -1024,8 +1044,8 @@ void main() {
1024
1044
  color.rgb = applyVibrance(color.rgb, u_vibrance);
1025
1045
  gl_FragColor = vec4(color.rgb, color.a * u_opacity);
1026
1046
  }`;
1027
- const Me = [0, 0, 0, 0], B = 512, H = B * B, Y = 128, ee = 64, Ci = 1, ki = 0.92, Fi = 0.1, je = 0.98;
1028
- function Ii(s) {
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) {
1029
1049
  if (Number.isNaN(s))
1030
1050
  return 32256;
1031
1051
  if (s === 1 / 0)
@@ -1051,26 +1071,26 @@ const Ui = {
1051
1071
  opacity: 1,
1052
1072
  logScale: !1,
1053
1073
  vibrance: 0,
1054
- colorGrade: hi,
1055
- backdrop: ci,
1074
+ colorGrade: ui,
1075
+ backdrop: hi,
1056
1076
  glow: 0,
1057
1077
  scalarMode: !1,
1058
1078
  particleState: "auto",
1059
1079
  rgba8MaxParticleZoom: 4
1060
1080
  };
1061
- class Mt {
1081
+ class Rt {
1062
1082
  constructor(e) {
1063
- 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 qt(this.params.fadeOpacity);
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);
1064
1084
  }
1065
1085
  init(e) {
1066
- this.gl = e, this.webglInfo = Wt(e), this.stateFormat = this.params.particleState === "rgba8" ? Xt(e) : Ht(e);
1086
+ this.gl = e, this.webglInfo = Xt(e), this.stateFormat = this.params.particleState === "rgba8" ? Ht(e) : Yt(e);
1067
1087
  const t = this.stateFormat.kind !== "rgba8-packed" ? `#define USE_FLOAT_STATE 1
1068
1088
  ` : "";
1069
1089
  this.updateProgram = W(
1070
1090
  e,
1071
1091
  de,
1072
- Ti.replace(/^(#version[^\n]*\n)/, `$1${t}`)
1073
- ), this.drawProgram = W(e, t + Mi, Ri), this.fadeProgram = W(e, de, Pi), this.compositeProgram = W(e, de, Ei), this.glowProgram = W(e, de, Li), this.gridProgram = W(e, wt, Di), this.gridGlobeProgram = W(e, Tt, Ai), this.updateLocs = this.getUniforms(this.updateProgram, [
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, [
1074
1094
  "u_particles",
1075
1095
  ...ue,
1076
1096
  "u_velocity",
@@ -1154,7 +1174,7 @@ class Mt {
1154
1174
  "u_vibrance",
1155
1175
  "u_scalar_mode",
1156
1176
  "u_solid"
1157
- ]), this.quadBuffer = Yt(e), this.initRasterGrid(), this.colorRampTexture = ge(e, this.params.colorRamp), this.initParticleState();
1177
+ ]), this.quadBuffer = Zt(e), this.initRasterGrid(), this.colorRampTexture = ge(e, this.params.colorRamp), this.initParticleState();
1158
1178
  }
1159
1179
  getUniforms(e, t) {
1160
1180
  const i = {};
@@ -1174,7 +1194,7 @@ class Mt {
1174
1194
  if (this.stateFormat?.kind === "float16") {
1175
1195
  const a = new Uint16Array(t);
1176
1196
  for (let r = 0; r < t; r++)
1177
- a[r] = Ii(Math.random());
1197
+ a[r] = Vi(Math.random());
1178
1198
  return a;
1179
1199
  }
1180
1200
  const i = new Uint8Array(t);
@@ -1183,7 +1203,7 @@ class Mt {
1183
1203
  return i;
1184
1204
  }
1185
1205
  createStateTexture(e) {
1186
- return Zt(
1206
+ return jt(
1187
1207
  this.gl,
1188
1208
  this.gl.NEAREST,
1189
1209
  e,
@@ -1196,10 +1216,10 @@ class Mt {
1196
1216
  initParticleState() {
1197
1217
  const e = this.gl, t = this.makeStateData(), i = this.createStateTexture(t), a = this.createStateTexture(t), r = J(e, i), n = J(e, a);
1198
1218
  this.particleStateTextures = [i, a], this.particleFramebuffers = [r, n];
1199
- const o = new Float32Array(H * 2), c = new Float32Array(H * 2);
1219
+ const o = new Float32Array(H * 2), l = new Float32Array(H * 2);
1200
1220
  for (let d = 0; d < H; d++)
1201
- o[d * 2] = d, o[d * 2 + 1] = d, c[d * 2] = 0, c[d * 2 + 1] = 1;
1202
- 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);
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);
1203
1223
  }
1204
1224
  initRasterGrid() {
1205
1225
  const e = this.gl, t = new Float32Array(
@@ -1207,17 +1227,17 @@ class Mt {
1207
1227
  );
1208
1228
  let i = 0;
1209
1229
  for (let o = 0; o <= ee; o++)
1210
- for (let c = 0; c <= Y; c++)
1211
- t[i++] = c / Y, t[i++] = o / ee;
1230
+ for (let l = 0; l <= Y; l++)
1231
+ t[i++] = l / Y, t[i++] = o / ee;
1212
1232
  const a = new Uint16Array(
1213
1233
  Y * ee * 6
1214
1234
  );
1215
1235
  let r = 0;
1216
1236
  const n = Y + 1;
1217
1237
  for (let o = 0; o < ee; o++)
1218
- for (let c = 0; c < Y; c++) {
1219
- const d = o * n + c, l = d + 1, u = d + n, f = u + 1;
1220
- a[r++] = d, a[r++] = u, a[r++] = l, a[r++] = l, a[r++] = u, a[r++] = f;
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;
1221
1241
  }
1222
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;
1223
1243
  }
@@ -1236,14 +1256,14 @@ class Mt {
1236
1256
  return;
1237
1257
  const i = this.gl;
1238
1258
  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();
1239
- 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), c = J(i, n);
1240
- this.screenTextures = [r, n], this.screenFramebuffers = [o, c];
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];
1241
1261
  }
1242
1262
  /**
1243
1263
  * Run one simulation step: update positions, fade trails, draw particles.
1244
1264
  * Must be called within the MapLibre render callback.
1245
1265
  */
1246
- render(e, t, i, a, r, n, o, c, d = !1, l = [0, 0, 1], u, f) {
1266
+ render(e, t, i, a, r, n, o, l, d = !1, c = [0, 0, 1], u, f) {
1247
1267
  const m = { unit: e, min: t, max: i }, p = f ?? { a: m, b: m, mix: 0 }, h = this.gl;
1248
1268
  if (this.screenWidth === 0 || this.screenHeight === 0)
1249
1269
  return;
@@ -1255,12 +1275,12 @@ class Mt {
1255
1275
  let y = !1;
1256
1276
  if (T) {
1257
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;
1258
- const E = r.maxX - r.minX;
1278
+ const R = r.maxX - r.minX;
1259
1279
  if (this.prevBounds) {
1260
- const F = this.prevBounds.maxX - this.prevBounds.minX, P = this.prevBounds.maxY - this.prevBounds.minY, L = 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(E - F) / Math.max(F, L), w = Math.abs(b - N) / Math.max(F, L) + Math.abs(A - C) / Math.max(P, L), U = Math.min(1, I + w);
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);
1261
1281
  this.redistributionBoost = Math.max(
1262
- this.redistributionBoost * ki,
1263
- U * Ci
1282
+ this.redistributionBoost * Fi,
1283
+ V * ki
1264
1284
  );
1265
1285
  }
1266
1286
  this.prevBounds = {
@@ -1271,7 +1291,7 @@ class Mt {
1271
1291
  };
1272
1292
  const k = Math.min(
1273
1293
  this.params.dropRate + this.redistributionBoost,
1274
- Fi
1294
+ Ii
1275
1295
  );
1276
1296
  h.uniform1f(this.updateLocs.u_drop_rate, k), h.uniform1f(
1277
1297
  this.updateLocs.u_drop_rate_bump,
@@ -1282,12 +1302,12 @@ class Mt {
1282
1302
  r.minY,
1283
1303
  r.maxX,
1284
1304
  r.maxY
1285
- ), h.uniform1f(this.updateLocs.u_is_globe, d ? 1 : 0), c && h.uniform4f(
1305
+ ), h.uniform1f(this.updateLocs.u_is_globe, d ? 1 : 0), l && h.uniform4f(
1286
1306
  this.updateLocs.u_geo_bounds,
1287
- c.west,
1288
- c.south,
1289
- c.east,
1290
- c.north
1307
+ l.west,
1308
+ l.south,
1309
+ l.east,
1310
+ l.north
1291
1311
  ), h.uniform1f(
1292
1312
  this.updateLocs.u_valid_threshold,
1293
1313
  je
@@ -1297,16 +1317,16 @@ class Mt {
1297
1317
  this.fadeLocs.u_opacity,
1298
1318
  this.updateTrailFadeOpacity(performance.now())
1299
1319
  ), this.drawQuad();
1300
- const v = (E) => {
1301
- c && (d && u ? this.renderGridGlobe(
1320
+ const v = (R) => {
1321
+ l && (d && u ? this.renderGridGlobe(
1302
1322
  e,
1303
1323
  t,
1304
1324
  i,
1305
1325
  a,
1306
- c,
1326
+ l,
1307
1327
  u,
1308
1328
  1,
1309
- E,
1329
+ R,
1310
1330
  p
1311
1331
  ) : d || this.renderGrid(
1312
1332
  e,
@@ -1315,9 +1335,9 @@ class Mt {
1315
1335
  a,
1316
1336
  n,
1317
1337
  o,
1318
- c,
1338
+ l,
1319
1339
  1,
1320
- E,
1340
+ R,
1321
1341
  p
1322
1342
  ));
1323
1343
  };
@@ -1327,12 +1347,12 @@ class Mt {
1327
1347
  h.ONE_MINUS_SRC_ALPHA,
1328
1348
  h.ONE,
1329
1349
  h.ONE_MINUS_SRC_ALPHA
1330
- ), 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), c && h.uniform4f(
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(
1331
1351
  this.drawLocs.u_geo_bounds,
1332
- c.west,
1333
- c.south,
1334
- c.east,
1335
- c.north
1352
+ l.west,
1353
+ l.south,
1354
+ l.east,
1355
+ l.north
1336
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(
1337
1357
  this.drawLocs.u_particle_contrast,
1338
1358
  this.renderMode === "raster+particles" ? 1 : 0
@@ -1344,30 +1364,30 @@ class Mt {
1344
1364
  je
1345
1365
  ), h.uniform1f(this.drawLocs.u_is_globe, d ? 1 : 0), h.uniform3f(
1346
1366
  this.drawLocs.u_globe_center,
1347
- l[0],
1348
- l[1],
1349
- l[2]
1367
+ c[0],
1368
+ c[1],
1369
+ c[2]
1350
1370
  ), h.uniformMatrix4fv(
1351
1371
  this.drawLocs.u_matrix,
1352
1372
  !1,
1353
1373
  a instanceof Float32Array ? a : new Float32Array(Array.from(a))
1354
1374
  );
1355
- const E = h.getAttribLocation(this.drawProgram, "a_index");
1356
- h.bindBuffer(h.ARRAY_BUFFER, this.particleIndexBuffer), h.enableVertexAttribArray(E), h.vertexAttribPointer(E, 1, h.FLOAT, !1, 0, 0);
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);
1357
1377
  const k = h.getAttribLocation(this.drawProgram, "a_is_curr");
1358
1378
  h.bindBuffer(h.ARRAY_BUFFER, this.particleIsCurrBuffer), h.enableVertexAttribArray(k), h.vertexAttribPointer(k, 1, h.FLOAT, !1, 0, 0);
1359
1379
  for (const F of o)
1360
1380
  h.uniform1f(this.drawLocs.u_world_offset, F), h.drawArrays(h.LINES, 0, this.numParticles * 2);
1361
- h.disableVertexAttribArray(E), h.disableVertexAttribArray(k), h.disable(h.BLEND);
1381
+ h.disableVertexAttribArray(R), h.disableVertexAttribArray(k), h.disable(h.BLEND);
1362
1382
  }
1363
1383
  h.bindFramebuffer(h.FRAMEBUFFER, g), h.viewport(0, 0, this.screenWidth, this.screenHeight);
1364
- const _ = ui(this.params.backdrop);
1384
+ const _ = di(this.params.backdrop);
1365
1385
  _[3] > 0 && v(_);
1366
- const S = this.params.glow > 0 ? this.renderGlow(g) : null, R = this.params.colorGrade;
1386
+ const S = this.params.glow > 0 ? this.renderGlow(g) : null, E = this.params.colorGrade;
1367
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(
1368
1388
  this.compositeLocs.u_glow,
1369
- S ? jt * this.params.glow : 0
1370
- ), h.uniform1f(this.compositeLocs.u_grade_on, R.enabled ? 1 : 0), h.uniform4f(this.compositeLocs.u_grade, ...di(R)), 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();
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();
1371
1391
  }
1372
1392
  /**
1373
1393
  * Reduce the latest trails into the glow texture (glow.glsl), then rebind
@@ -1380,16 +1400,16 @@ class Mt {
1380
1400
  deleteGlowTarget() {
1381
1401
  this.glowTexture && (this.gl.deleteTexture(this.glowTexture), this.gl.deleteFramebuffer(this.glowFramebuffer), this.glowTexture = null, this.glowFramebuffer = null);
1382
1402
  }
1383
- renderGrid(e, t, i, a, r, n, o, c = 1, d = Me, l) {
1403
+ renderGrid(e, t, i, a, r, n, o, l = 1, d = Me, c) {
1384
1404
  const u = this.gl;
1385
1405
  u.useProgram(this.gridProgram), u.disable(u.DEPTH_TEST), u.disable(u.STENCIL_TEST), u.disable(u.BLEND), this.setGridFieldUniforms(
1386
1406
  this.gridLocs,
1387
1407
  e,
1388
1408
  t,
1389
1409
  i,
1390
- c,
1410
+ l,
1391
1411
  d,
1392
- l
1412
+ c
1393
1413
  ), u.uniformMatrix4fv(
1394
1414
  this.gridLocs.u_matrix,
1395
1415
  !1,
@@ -1410,15 +1430,15 @@ class Mt {
1410
1430
  );
1411
1431
  this.unbindRasterGrid(this.gridProgram), u.disable(u.BLEND);
1412
1432
  }
1413
- renderGridGlobe(e, t, i, a, r, n, o = 1, c = Me, d, l = Qt) {
1433
+ renderGridGlobe(e, t, i, a, r, n, o = 1, l = Me, d, c = Kt) {
1414
1434
  const u = this.gl;
1415
- u.useProgram(this.gridGlobeProgram), vt(u, this.gridGlobeLocs, l), u.disable(u.DEPTH_TEST), u.disable(u.STENCIL_TEST), u.disable(u.BLEND), this.setGridFieldUniforms(
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(
1416
1436
  this.gridGlobeLocs,
1417
1437
  e,
1418
1438
  t,
1419
1439
  i,
1420
1440
  o,
1421
- c,
1441
+ l,
1422
1442
  d
1423
1443
  ), u.uniformMatrix4fv(
1424
1444
  this.gridGlobeLocs.u_matrix,
@@ -1444,12 +1464,12 @@ class Mt {
1444
1464
  ), this.unbindRasterGrid(this.gridGlobeProgram), u.disable(u.BLEND);
1445
1465
  }
1446
1466
  setGridFieldUniforms(e, t, i, a, r, n, o) {
1447
- const c = this.gl, d = { unit: t, min: i, max: a }, l = o ?? { a: d, b: d, mix: 0 };
1448
- Te(c, e, l), c.uniform1i(e.u_field, l.a.unit), c.uniform4f(e.u_solid, ...n), O(c, this.colorRampTexture, 2), c.uniform1i(e.u_color_ramp, 2);
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);
1449
1469
  const u = Math.sqrt(
1450
1470
  Math.max(Math.abs(i[0]), Math.abs(a[0])) ** 2 + Math.max(Math.abs(i[1]), Math.abs(a[1])) ** 2
1451
1471
  );
1452
- c.uniform1f(e.u_field_min, 0), c.uniform1f(e.u_field_max, u > 0 ? u : 1), c.uniform1f(e.u_u_min, l.a.min[0]), c.uniform1f(e.u_u_max, l.a.max[0]), c.uniform1f(e.u_v_min, l.a.min[1]), c.uniform1f(e.u_v_max, l.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);
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);
1453
1473
  }
1454
1474
  bindRasterGrid(e) {
1455
1475
  const t = this.gl, i = t.getAttribLocation(e, "a_grid_uv");
@@ -1604,7 +1624,7 @@ class Mt {
1604
1624
  e.deleteBuffer(this.quadBuffer), e.deleteBuffer(this.particleIndexBuffer), e.deleteBuffer(this.particleIsCurrBuffer), e.deleteTexture(this.colorRampTexture);
1605
1625
  }
1606
1626
  }
1607
- class Rt {
1627
+ class Pt {
1608
1628
  constructor() {
1609
1629
  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;
1610
1630
  }
@@ -1618,17 +1638,17 @@ class Rt {
1618
1638
  * fields may use a fixed color domain so fragments never decode physical values.
1619
1639
  */
1620
1640
  update(e, t = null) {
1621
- const i = this.gl, { u: a, v: r, width: n, height: o, uMin: c, uMax: d, vMin: l, vMax: u } = e;
1622
- this.scalarMode = e.scalarMode ?? !1, this.width = n, this.height = o, this.uMin = c, this.uMax = d, this.vMin = l, this.vMax = u, this.geoBounds = e.bounds;
1623
- const f = this.scalarMode && t ? t[0] : c, p = (this.scalarMode && t ? t[1] : d) - f || 1, h = u - l || 1, g = new Uint8Array(n * o * 4);
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);
1624
1644
  for (let y = 0; y < n * o; y++) {
1625
1645
  const v = a[y], _ = r[y];
1626
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(
1627
1647
  Math.max(0, Math.min(1, (v - f) / p)) * 255
1628
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(
1629
- Math.max(0, Math.min(1, (v - c) / p)) * 255
1649
+ Math.max(0, Math.min(1, (v - l) / p)) * 255
1630
1650
  ), g[y * 4 + 1] = Math.round(
1631
- Math.max(0, Math.min(1, (_ - l) / h)) * 255
1651
+ Math.max(0, Math.min(1, (_ - c) / h)) * 255
1632
1652
  ), g[y * 4 + 2] = 0, g[y * 4 + 3] = 255);
1633
1653
  }
1634
1654
  if (e.latDescending) {
@@ -1642,7 +1662,7 @@ class Rt {
1642
1662
  console.log(
1643
1663
  `[zartigl] Velocity texture: ${n}x${o}, valid=${x} (${(100 * x / (n * o)).toFixed(
1644
1664
  1
1645
- )}%), nodata=${T}, uRange=[${c.toFixed(4)}, ${d.toFixed(4)}], vRange=[${l.toFixed(4)}, ${u.toFixed(4)}]`
1665
+ )}%), nodata=${T}, uRange=[${l.toFixed(4)}, ${d.toFixed(4)}], vRange=[${c.toFixed(4)}, ${u.toFixed(4)}]`
1646
1666
  ), this.texture || (this.texture = i.createTexture());
1647
1667
  const M = this.linearFilter ? i.LINEAR : i.NEAREST;
1648
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(
@@ -1682,8 +1702,8 @@ class Rt {
1682
1702
  this.gl && this.texture && (this.gl.deleteTexture(this.texture), this.texture = null);
1683
1703
  }
1684
1704
  }
1685
- function Pt(s, e, t, i, a, r, n) {
1686
- const o = new Float32Array(t * i).fill(NaN), c = new Float32Array(t * i).fill(NaN);
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);
1687
1707
  for (const m of s)
1688
1708
  for (let p = 0; p < m.latSize; p++)
1689
1709
  for (let h = 0; h < m.lonSize; h++) {
@@ -1694,18 +1714,18 @@ function Pt(s, e, t, i, a, r, n) {
1694
1714
  for (let p = 0; p < m.latSize; p++)
1695
1715
  for (let h = 0; h < m.lonSize; h++) {
1696
1716
  const g = p * m.lonChunkSize + h, x = (m.latStart + p) * i + (m.lonStart + h);
1697
- c[x] = m.data[g];
1717
+ l[x] = m.data[g];
1698
1718
  }
1699
- let d = 1 / 0, l = -1 / 0, u = 1 / 0, f = -1 / 0;
1719
+ let d = 1 / 0, c = -1 / 0, u = 1 / 0, f = -1 / 0;
1700
1720
  for (let m = 0; m < o.length; m++)
1701
- isNaN(o[m]) || (o[m] < d && (d = o[m]), o[m] > l && (l = o[m])), isNaN(c[m]) || (c[m] < u && (u = c[m]), c[m] > f && (f = c[m]));
1702
- return isFinite(d) || (d = -1), isFinite(l) || (l = 1), isFinite(u) || (u = -1), isFinite(f) || (f = 1), {
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), {
1703
1723
  u: o,
1704
- v: c,
1724
+ v: l,
1705
1725
  width: i,
1706
1726
  height: t,
1707
1727
  uMin: d,
1708
- uMax: l,
1728
+ uMax: c,
1709
1729
  vMin: u,
1710
1730
  vMax: f,
1711
1731
  bounds: a ?? { west: -180, south: -90, east: 180, north: 90 },
@@ -1777,7 +1797,7 @@ class _e {
1777
1797
  let a = t ? i[0] : NaN, r = a;
1778
1798
  for (let o = 1; o < i.length; o++)
1779
1799
  a = Math.min(a, i[o]), r = Math.max(r, i[o]);
1780
- const n = Oi(i);
1800
+ const n = Bi(i);
1781
1801
  return {
1782
1802
  min: a,
1783
1803
  max: r,
@@ -1849,7 +1869,7 @@ class _e {
1849
1869
  throw new Error(
1850
1870
  `Unsupported Zarr time units: ${this.timeUnits || "<missing>"}`
1851
1871
  );
1852
- const i = zi(t[2]);
1872
+ const i = Gi(t[2]);
1853
1873
  if (!Number.isFinite(i))
1854
1874
  throw new Error(`Invalid Zarr time epoch: ${t[2]}`);
1855
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;
@@ -1862,28 +1882,28 @@ class _e {
1862
1882
  }
1863
1883
  async sampleVariableAt(e, t) {
1864
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);
1865
- for (let l = 0; l < i.length; l++) {
1866
- const u = i[l];
1885
+ for (let c = 0; c < i.length; c++) {
1886
+ const u = i[c];
1867
1887
  let f = 0;
1868
- 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[l] - 1, f)), n[l] = Math.floor(f / a[l]), o[l] = f - n[l] * a[l];
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];
1869
1889
  }
1870
- let c;
1890
+ let l;
1871
1891
  try {
1872
- c = await this.fetchChunk(e, n);
1873
- } catch (l) {
1874
- if (l instanceof Qe && (l.status === 403 || l.status === 404))
1892
+ l = await this.fetchChunk(e, n);
1893
+ } catch (c) {
1894
+ if (c instanceof Qe && (c.status === 403 || c.status === 404))
1875
1895
  return NaN;
1876
- throw l;
1896
+ throw c;
1877
1897
  }
1878
1898
  const d = this.getFlatOffset(e, o);
1879
- return d < c.length ? c[d] : NaN;
1899
+ return d < l.length ? l[d] : NaN;
1880
1900
  }
1881
1901
  getFlatOffset(e, t) {
1882
1902
  const i = this.getArrayMeta(e), a = i.chunks;
1883
1903
  if (i.order === "F") {
1884
1904
  let n = 0, o = 1;
1885
- for (let c = 0; c < t.length; c++)
1886
- n += t[c] * o, o *= a[c];
1905
+ for (let l = 0; l < t.length; l++)
1906
+ n += t[l] * o, o *= a[l];
1887
1907
  return n;
1888
1908
  }
1889
1909
  let r = 0;
@@ -1899,13 +1919,13 @@ class _e {
1899
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(
1900
1920
  t.time.length - 1,
1901
1921
  e.timeEndIndex ?? t.time.length - 1
1902
- ), c = Math.max(1, Math.floor(e.stride ?? 1)), d = Math.max(
1922
+ ), l = Math.max(1, Math.floor(e.stride ?? 1)), d = Math.max(
1903
1923
  0,
1904
1924
  Math.floor(e.stopAfterMissingSamples ?? 0)
1905
1925
  );
1906
- let l = 0;
1926
+ let c = 0;
1907
1927
  const u = [];
1908
- for (let f = n; f <= o; f += c) {
1928
+ for (let f = n; f <= o; f += l) {
1909
1929
  const m = {};
1910
1930
  for (const g of e.variables)
1911
1931
  m[g] = await this.sampleVariableAt(g, {
@@ -1920,9 +1940,9 @@ class _e {
1920
1940
  time: p,
1921
1941
  depth: t.vertical[r],
1922
1942
  values: m
1923
- }), l = e.variables.every(
1943
+ }), c = e.variables.every(
1924
1944
  (g) => !Number.isFinite(m[g])
1925
- ) ? l + 1 : 0, d > 0 && l >= d)
1945
+ ) ? c + 1 : 0, d > 0 && c >= d)
1926
1946
  break;
1927
1947
  }
1928
1948
  return {
@@ -1939,21 +1959,21 @@ class _e {
1939
1959
  Math.floor(e.stopAfterMissingSamples ?? 0)
1940
1960
  );
1941
1961
  let o = 0;
1942
- const c = [];
1962
+ const l = [];
1943
1963
  let d = Array.from(
1944
1964
  { length: t.vertical.length },
1945
1965
  (f, m) => m
1946
1966
  ).sort(
1947
1967
  (f, m) => Math.abs(t.vertical[f]) - Math.abs(t.vertical[m])
1948
1968
  );
1949
- const l = Math.max(
1969
+ const c = Math.max(
1950
1970
  1,
1951
1971
  Math.floor(e.maxDepths ?? d.length)
1952
1972
  ), u = Math.max(
1953
1973
  1,
1954
- Math.floor(e.stride ?? Math.ceil(d.length / l))
1974
+ Math.floor(e.stride ?? Math.ceil(d.length / c))
1955
1975
  );
1956
- d = d.filter((f, m) => m % u === 0).slice(0, l);
1976
+ d = d.filter((f, m) => m % u === 0).slice(0, c);
1957
1977
  for (const f of d) {
1958
1978
  const m = {};
1959
1979
  for (const g of e.variables)
@@ -1964,7 +1984,7 @@ class _e {
1964
1984
  lonIdx: i
1965
1985
  });
1966
1986
  const p = t.vertical[f];
1967
- if (c.push({
1987
+ if (l.push({
1968
1988
  axisValue: p,
1969
1989
  time: this.zarrTimeToMs(t.time[r]),
1970
1990
  depth: p,
@@ -1978,7 +1998,7 @@ class _e {
1978
1998
  longitude: t.longitude[i],
1979
1999
  latitude: t.latitude[a],
1980
2000
  time: this.zarrTimeToMs(t.time[r]),
1981
- points: c
2001
+ points: l
1982
2002
  };
1983
2003
  }
1984
2004
  /** Return the actual name of the vertical dimension ("depth" or "elevation"). */
@@ -1989,11 +2009,11 @@ class _e {
1989
2009
  * Get chunk indices that intersect a geographic bounding box.
1990
2010
  */
1991
2011
  getChunksForBounds(e, t, i, a) {
1992
- const r = this.getCoords(), n = this.getChunkShape(e), o = this.getDimensions(e), c = o.indexOf("latitude"), d = o.indexOf("longitude"), l = n[c], 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 / l), S = Math.floor(M / l), R = Math.floor(y / u), E = Math.floor(v / u), k = this.getShape(e), F = k[c], P = k[d], L = [];
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 = [];
1993
2013
  for (let b = _; b <= S; b++)
1994
- for (let A = R; A <= E; A++) {
1995
- const N = b * l, C = A * u, I = Math.min(l, F - N), w = Math.min(u, P - C);
1996
- L.push({
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({
1997
2017
  timeIdx: t,
1998
2018
  depthIdx: i,
1999
2019
  latIdx: b,
@@ -2004,7 +2024,7 @@ class _e {
2004
2024
  lonSize: w
2005
2025
  });
2006
2026
  }
2007
- return L;
2027
+ return D;
2008
2028
  }
2009
2029
  async fetchChunk(e, t) {
2010
2030
  return (await this.fetchChunkResult(e, t)).data;
@@ -2020,7 +2040,7 @@ class _e {
2020
2040
  throw new Error(
2021
2041
  `Variable ${e} must have latitude and longitude dimensions`
2022
2042
  );
2023
- const o = new Array(i.length).fill(0), c = new Array(i.length).fill(0);
2043
+ const o = new Array(i.length).fill(0), l = new Array(i.length).fill(0);
2024
2044
  for (let m = 0; m < i.length; m++) {
2025
2045
  const p = i[m];
2026
2046
  let h = 0;
@@ -2035,15 +2055,15 @@ class _e {
2035
2055
  o[m] = t.longitudeChunkIndex;
2036
2056
  continue;
2037
2057
  }
2038
- o[m] = Math.floor(h / a[m]), c[m] = h % a[m];
2058
+ o[m] = Math.floor(h / a[m]), l[m] = h % a[m];
2039
2059
  }
2040
- const d = await this.fetchChunkResult(e, o), l = a[r], u = a[n], f = new Float32Array(l * u);
2060
+ const d = await this.fetchChunkResult(e, o), c = a[r], u = a[n], f = new Float32Array(c * u);
2041
2061
  f.fill(NaN);
2042
- for (let m = 0; m < l; m++) {
2043
- c[r] = m;
2062
+ for (let m = 0; m < c; m++) {
2063
+ l[r] = m;
2044
2064
  for (let p = 0; p < u; p++) {
2045
- c[n] = p;
2046
- const h = this.getFlatOffset(e, c);
2065
+ l[n] = p;
2066
+ const h = this.getFlatOffset(e, l);
2047
2067
  h < d.data.length && (f[m * u + p] = d.data[h]);
2048
2068
  }
2049
2069
  }
@@ -2056,21 +2076,21 @@ class _e {
2056
2076
  this.abortControllers.get(r)?.abort();
2057
2077
  const o = new AbortController();
2058
2078
  this.abortControllers.set(r, o);
2059
- const c = this.getArrayMeta(e);
2079
+ const l = this.getArrayMeta(e);
2060
2080
  try {
2061
2081
  const d = await fetch(n, { signal: o.signal });
2062
2082
  if (!d.ok) {
2063
2083
  if (d.status === 403 || d.status === 404)
2064
2084
  return {
2065
- data: Ni(c),
2085
+ data: zi(l),
2066
2086
  missing: !0,
2067
2087
  status: d.status,
2068
2088
  url: n
2069
2089
  };
2070
2090
  throw new Qe(d.status, n);
2071
2091
  }
2072
- const l = new Uint8Array(await d.arrayBuffer()), u = Vi(
2073
- await this.decompress(l, c, e)
2092
+ const c = new Uint8Array(await d.arrayBuffer()), u = Ni(
2093
+ await this.decompress(c, l, e)
2074
2094
  );
2075
2095
  return this.cacheChunk(r, u), { data: u, missing: !1, url: n };
2076
2096
  } finally {
@@ -2092,7 +2112,7 @@ class _e {
2092
2112
  getBloscCodec(e) {
2093
2113
  const t = e.compressor, i = `${t.cname ?? "lz4"}-${t.clevel ?? 5}-${t.shuffle ?? 1}-${t.blocksize ?? 0}`;
2094
2114
  let a = this.bloscCodecCache.get(i);
2095
- return a || (a = gi.fromConfig({
2115
+ return a || (a = vi.fromConfig({
2096
2116
  id: "blosc",
2097
2117
  cname: t.cname ?? "lz4",
2098
2118
  clevel: t.clevel ?? 5,
@@ -2106,7 +2126,7 @@ class _e {
2106
2126
  switch (t.compressor.id) {
2107
2127
  case "zlib":
2108
2128
  case "gzip":
2109
- a = pi(e);
2129
+ a = gi(e);
2110
2130
  break;
2111
2131
  case "blosc": {
2112
2132
  a = await this.getBloscCodec(t).decode(e);
@@ -2132,38 +2152,38 @@ class _e {
2132
2152
  a.byteLength / 8
2133
2153
  );
2134
2154
  else if (n === "<i2" || n === "|i2") {
2135
- const c = new Int16Array(
2155
+ const l = new Int16Array(
2136
2156
  a.buffer,
2137
2157
  a.byteOffset,
2138
2158
  a.byteLength / 2
2139
2159
  );
2140
- r = Float32Array.from(c);
2160
+ r = Float32Array.from(l);
2141
2161
  } else if (n === "<i4" || n === "|i4") {
2142
- const c = new Int32Array(
2162
+ const l = new Int32Array(
2143
2163
  a.buffer,
2144
2164
  a.byteOffset,
2145
2165
  a.byteLength / 4
2146
2166
  );
2147
- r = Float32Array.from(c);
2167
+ r = Float32Array.from(l);
2148
2168
  } else if (n === "<i8" || n === "|i8") {
2149
- const c = new DataView(
2169
+ const l = new DataView(
2150
2170
  a.buffer,
2151
2171
  a.byteOffset,
2152
2172
  a.byteLength
2153
2173
  ), d = a.byteLength / 8;
2154
2174
  r = new Float64Array(d);
2155
- for (let l = 0; l < d; l++)
2156
- r[l] = Number(c.getBigInt64(l * 8, !0));
2175
+ for (let c = 0; c < d; c++)
2176
+ r[c] = Number(l.getBigInt64(c * 8, !0));
2157
2177
  } else
2158
2178
  throw new Error(`Unsupported dtype: ${n}`);
2159
2179
  const o = t.fill_value;
2160
2180
  if (o != null && typeof o == "number" && !isNaN(o))
2161
- for (let c = 0; c < r.length; c++)
2162
- r[c] === o && (r[c] = NaN);
2181
+ for (let l = 0; l < r.length; l++)
2182
+ r[l] === o && (r[l] = NaN);
2163
2183
  if (i) {
2164
- const c = this.getAttrs(i), d = c.scale_factor, l = c.add_offset;
2165
- if (d != null || l != null) {
2166
- const u = d ?? 1, f = l ?? 0;
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;
2167
2187
  for (let m = 0; m < r.length; m++)
2168
2188
  isNaN(r[m]) || (r[m] = r[m] * u + f);
2169
2189
  }
@@ -2171,31 +2191,31 @@ class _e {
2171
2191
  return r;
2172
2192
  }
2173
2193
  async loadCoordinates() {
2174
- const e = async (c) => {
2175
- const d = this.getArrayMeta(c), l = d.shape[0], u = Math.ceil(l / d.chunks[0]), f = [];
2194
+ const e = async (l) => {
2195
+ const d = this.getArrayMeta(l), c = d.shape[0], u = Math.ceil(c / d.chunks[0]), f = [];
2176
2196
  for (let g = 0; g < u; g++) {
2177
- const x = `${this.root}/${c}/${g}`, T = await fetch(x);
2197
+ const x = `${this.root}/${l}/${g}`, T = await fetch(x);
2178
2198
  if (!T.ok)
2179
- throw new Error(`Failed to fetch coord ${c}/${g}`);
2199
+ throw new Error(`Failed to fetch coord ${l}/${g}`);
2180
2200
  const M = new Uint8Array(await T.arrayBuffer());
2181
2201
  f.push(await this.decompress(M, d));
2182
2202
  }
2183
2203
  if (f.length === 1)
2184
- return f[0].length > l ? f[0].subarray(0, l) : f[0];
2185
- const m = f.some((g) => g instanceof Float64Array) ? Float64Array : Float32Array, p = new m(l);
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);
2186
2206
  let h = 0;
2187
2207
  for (const g of f) {
2188
- const x = Math.min(g.length, l - h);
2189
- if (p.set(g.subarray(0, x), h), h += x, h >= l)
2208
+ const x = Math.min(g.length, c - h);
2209
+ if (p.set(g.subarray(0, x), h), h += x, h >= c)
2190
2210
  break;
2191
2211
  }
2192
2212
  return p;
2193
2213
  };
2194
2214
  let t = null;
2195
- for (const c of Re) {
2196
- const d = `${c}/.zarray`;
2215
+ for (const l of Re) {
2216
+ const d = `${l}/.zarray`;
2197
2217
  if (this.meta.metadata[d] && "dtype" in this.meta.metadata[d]) {
2198
- t = c;
2218
+ t = l;
2199
2219
  break;
2200
2220
  }
2201
2221
  }
@@ -2216,30 +2236,30 @@ class _e {
2216
2236
  };
2217
2237
  }
2218
2238
  }
2219
- function Vi(s) {
2239
+ function Ni(s) {
2220
2240
  return s instanceof Float32Array ? s : Float32Array.from(s);
2221
2241
  }
2222
- function Ni(s) {
2242
+ function zi(s) {
2223
2243
  const e = s.chunks.reduce((i, a) => i * a, 1), t = new Float32Array(e);
2224
2244
  return t.fill(NaN), t;
2225
2245
  }
2226
- function zi(s) {
2246
+ function Gi(s) {
2227
2247
  const t = s.trim().replace(/\s+\([^)]*\)\s*$/, "").match(
2228
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
2229
2249
  );
2230
2250
  if (!t)
2231
2251
  return NaN;
2232
- const i = Number(t[1]), a = Number(t[2]), r = Number(t[3]), n = Number(t[4] ?? 0), o = Number(t[5] ?? 0), c = Number(t[6] ?? 0), d = Number((t[7] ?? "").padEnd(3, "0").slice(0, 3)), l = t[8] ?? "Z";
2233
- if (a < 1 || a > 12 || n > 23 || o > 59 || c > 59)
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)
2234
2254
  return NaN;
2235
2255
  const u = /* @__PURE__ */ new Date(0);
2236
- u.setUTCFullYear(i, a - 1, r), u.setUTCHours(n, o, c, d);
2256
+ u.setUTCFullYear(i, a - 1, r), u.setUTCHours(n, o, l, d);
2237
2257
  const f = u.getTime();
2238
- if (u.getUTCFullYear() !== i || u.getUTCMonth() !== a - 1 || u.getUTCDate() !== r || u.getUTCHours() !== n || u.getUTCMinutes() !== o || u.getUTCSeconds() !== c || u.getUTCMilliseconds() !== d)
2258
+ if (u.getUTCFullYear() !== i || u.getUTCMonth() !== a - 1 || u.getUTCDate() !== r || u.getUTCHours() !== n || u.getUTCMinutes() !== o || u.getUTCSeconds() !== l || u.getUTCMilliseconds() !== d)
2239
2259
  return NaN;
2240
- if (/^z$/i.test(l))
2260
+ if (/^z$/i.test(c))
2241
2261
  return f;
2242
- const m = l.match(/^([+-])(\d{2}):?(\d{2})$/);
2262
+ const m = c.match(/^([+-])(\d{2}):?(\d{2})$/);
2243
2263
  if (!m)
2244
2264
  return NaN;
2245
2265
  const p = Number(m[2]), h = Number(m[3]);
@@ -2248,7 +2268,7 @@ function zi(s) {
2248
2268
  const g = (p * 60 + h) * 6e4;
2249
2269
  return f - (m[1] === "+" ? g : -g);
2250
2270
  }
2251
- function Gi(s) {
2271
+ function Oi(s) {
2252
2272
  if (typeof s != "number" || !Number.isFinite(s) || s <= 0)
2253
2273
  return s;
2254
2274
  const e = [
@@ -2270,7 +2290,7 @@ function Gi(s) {
2270
2290
  return t;
2271
2291
  return Math.round(s);
2272
2292
  }
2273
- function Oi(s) {
2293
+ function Bi(s) {
2274
2294
  if (s.length < 2)
2275
2295
  return;
2276
2296
  const e = s[1] - s[0];
@@ -2280,7 +2300,7 @@ function Oi(s) {
2280
2300
  for (let i = 2; i < s.length; i++)
2281
2301
  if (Math.abs(s[i] - s[i - 1] - e) > t)
2282
2302
  return;
2283
- return Gi(e);
2303
+ return Oi(e);
2284
2304
  }
2285
2305
  class xe extends Error {
2286
2306
  constructor(e, t, i) {
@@ -2289,19 +2309,19 @@ class xe extends Error {
2289
2309
  ), this.name = "ZartiglFrameUnavailableError", this.time = e, this.statuses = [...new Set(t)].sort((a, r) => a - r), this.urls = [...new Set(i)];
2290
2310
  }
2291
2311
  }
2292
- function Bi(s) {
2312
+ function $i(s) {
2293
2313
  for (const e of s)
2294
2314
  if (Number.isFinite(e))
2295
2315
  return !0;
2296
2316
  return !1;
2297
2317
  }
2298
- function $i(s, e) {
2318
+ function qi(s, e) {
2299
2319
  for (let t = 0; t < Math.min(s.length, e.length); t++)
2300
2320
  if (Number.isFinite(s[t]) && Number.isFinite(e[t]))
2301
2321
  return !0;
2302
2322
  return !1;
2303
2323
  }
2304
- function Et(s) {
2324
+ function Lt(s) {
2305
2325
  return {
2306
2326
  phase: "blocked",
2307
2327
  time: s.time,
@@ -2311,7 +2331,7 @@ function Et(s) {
2311
2331
  }
2312
2332
  class me {
2313
2333
  constructor(e) {
2314
- 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 Rt(), this.simulation = new Mt({
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({
2315
2335
  colorRamp: e.colorRamp,
2316
2336
  opacity: e.opacity ?? 1,
2317
2337
  logScale: e.logScale ?? !1,
@@ -2347,8 +2367,8 @@ class me {
2347
2367
  try {
2348
2368
  const r = i.canvas;
2349
2369
  this.simulation.resize(r.width, r.height), i.bindFramebuffer(i.FRAMEBUFFER, a.framebuffer), i.viewport(0, 0, r.width, r.height);
2350
- const n = this.map.getBounds(), o = t.defaultProjectionData, c = ye(this.map, o), d = 512 * Math.pow(2, this.map.getZoom());
2351
- this.activeField.bind(this.textureUnit), c ? this.simulation.renderGridGlobe(
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(
2352
2372
  this.textureUnit,
2353
2373
  [this.activeData.uMin, this.activeData.vMin],
2354
2374
  [this.activeData.uMax, this.activeData.vMax],
@@ -2503,7 +2523,7 @@ class me {
2503
2523
  const n = r instanceof Error ? r : new Error(String(r));
2504
2524
  e === this.generation && t === this.requestId && (this.emit(
2505
2525
  "status",
2506
- n instanceof xe ? Et(n) : { phase: "error", time: a, error: n }
2526
+ n instanceof xe ? Lt(n) : { phase: "error", time: a, error: n }
2507
2527
  ), this.emit("error", n));
2508
2528
  }
2509
2529
  } finally {
@@ -2521,7 +2541,7 @@ class me {
2521
2541
  r,
2522
2542
  n,
2523
2543
  a
2524
- ), c = this.zarrSource.getDimensions(this.variable), d = c.indexOf("latitude"), l = c.indexOf("longitude"), u = this.zarrSource.getChunkShape(this.variable);
2544
+ ), l = this.zarrSource.getDimensions(this.variable), d = l.indexOf("latitude"), c = l.indexOf("longitude"), u = this.zarrSource.getChunkShape(this.variable);
2525
2545
  let f = 0;
2526
2546
  const m = o.length, p = [], h = [];
2527
2547
  t?.(f, m);
@@ -2539,45 +2559,45 @@ class me {
2539
2559
  return A.missing && (A.status != null && p.push(A.status), h.push(A.url)), f++, t?.(f, m), {
2540
2560
  data: A.data,
2541
2561
  latStart: b.latIdx * u[d],
2542
- lonStart: b.lonIdx * u[l],
2562
+ lonStart: b.lonIdx * u[c],
2543
2563
  latSize: b.latSize,
2544
2564
  lonSize: b.lonSize,
2545
- lonChunkSize: u[l]
2565
+ lonChunkSize: u[c]
2546
2566
  };
2547
2567
  })
2548
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) => ({
2549
2569
  ...b,
2550
2570
  latStart: b.latStart - x,
2551
2571
  lonStart: b.lonStart - M
2552
- })), R = this.zarrSource.getCoords(), E = Math.min(T - 1, R.latitude.length - 1), k = Math.min(y - 1, R.longitude.length - 1), F = {
2553
- west: R.longitude[M],
2554
- east: R.longitude[k],
2555
- south: Math.min(R.latitude[x], R.latitude[E]),
2556
- north: Math.max(R.latitude[x], R.latitude[E])
2557
- }, P = R.latitude[x] > R.latitude[E], L = Pt(
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(
2573
+ E.longitude,
2574
+ E.latitude,
2575
+ [M, k],
2576
+ [x, R]
2577
+ ), L = E.latitude[x] > E.latitude[R], D = Et(
2558
2578
  S,
2559
2579
  [],
2560
2580
  v,
2561
2581
  _,
2562
2582
  F,
2563
- P,
2583
+ L,
2564
2584
  !0
2565
2585
  );
2566
- if (!Bi(L.u))
2586
+ if (!$i(D.u))
2567
2587
  throw new xe(
2568
2588
  this.timeToMs(e),
2569
2589
  p,
2570
2590
  h
2571
2591
  );
2572
- return L;
2592
+ return D;
2573
2593
  }
2574
2594
  setActive(e, t) {
2575
2595
  const i = this.timeToMs(t);
2576
2596
  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();
2577
2597
  }
2578
2598
  sampleActiveData(e, t, i) {
2579
- const { west: a, east: r, south: n, north: o } = e.bounds, c = r - a, d = o - n;
2580
- if (e.width <= 0 || e.height <= 0 || c <= 0 || d <= 0)
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)
2581
2601
  return {
2582
2602
  longitude: t,
2583
2603
  latitude: i,
@@ -2586,8 +2606,8 @@ class me {
2586
2606
  time: this.timeToMs(this.time),
2587
2607
  depth: this.depth
2588
2608
  };
2589
- const l = a >= 0 && r > 180 ? (t % 360 + 360) % 360 : ((t + 180) % 360 + 360) % 360 - 180;
2590
- if (l < a || l > r || i < n || i > o)
2609
+ const c = a + ((t - a) % 360 + 360) % 360;
2610
+ if (c > r && l < 359 || i < n || i > o)
2591
2611
  return {
2592
2612
  longitude: t,
2593
2613
  latitude: i,
@@ -2596,13 +2616,13 @@ class me {
2596
2616
  time: this.timeToMs(this.time),
2597
2617
  depth: this.depth
2598
2618
  };
2599
- const u = (l - a) / c, f = e.latDescending ? (o - i) / d : (i - n) / d, m = Math.max(
2619
+ const u = (c - a) / l, f = e.latDescending ? (o - i) / d : (i - n) / d, m = Math.max(
2600
2620
  0,
2601
- Math.min(e.width - 1, Math.round(u * (e.width - 1)))
2621
+ Math.min(e.width - 1, Math.floor(u * e.width))
2602
2622
  ), p = Math.max(
2603
2623
  0,
2604
- Math.min(e.height - 1, Math.round(f * (e.height - 1)))
2605
- ), h = e.u[p * e.width + m] ?? NaN, g = a + m / Math.max(1, e.width - 1) * c, x = e.latDescending ? o - p / Math.max(1, e.height - 1) * d : n + p / Math.max(1, e.height - 1) * d;
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;
2606
2626
  return {
2607
2627
  longitude: g,
2608
2628
  latitude: x,
@@ -2632,7 +2652,7 @@ class me {
2632
2652
  a(...t);
2633
2653
  }
2634
2654
  }
2635
- function qi(s, e, t) {
2655
+ function Wi(s, e, t) {
2636
2656
  if (!Number.isFinite(s) || !Number.isFinite(e))
2637
2657
  return { u: NaN, v: NaN };
2638
2658
  const i = t.direction_convention !== t.output_direction ? 180 : 0, a = (s + i) * Math.PI / 180;
@@ -2641,11 +2661,11 @@ function qi(s, e, t) {
2641
2661
  v: e * Math.cos(a)
2642
2662
  };
2643
2663
  }
2644
- function La(s) {
2664
+ function Da(s) {
2645
2665
  return [s.direction_variable, s.magnitude_variable];
2646
2666
  }
2647
- const Wi = 0.7;
2648
- class D {
2667
+ const Xi = 0.7;
2668
+ class P {
2649
2669
  constructor(e) {
2650
2670
  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")
2651
2671
  throw new Error("Vector GeoVideo requires a vector-luma manifest");
@@ -2667,10 +2687,10 @@ class D {
2667
2687
  }
2668
2688
  t === "timeChange" && (this.time = i[0]), this.emit(t, ...i);
2669
2689
  }
2670
- ) : 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 Rt(), this.simulation = new Mt({
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({
2671
2691
  particleDensity: e.particleDensity ?? 0.05,
2672
2692
  speed: e.speed ?? 1,
2673
- fadeOpacity: Xe(e.fade ?? Wi),
2693
+ fadeOpacity: Xe(e.fade ?? Xi),
2674
2694
  colorRamp: e.colorRamp,
2675
2695
  opacity: e.opacity ?? 1,
2676
2696
  logScale: e.logScale ?? !1,
@@ -2724,9 +2744,9 @@ class D {
2724
2744
  };
2725
2745
  }
2726
2746
  isViewportCovered() {
2727
- return !this.map || !this.velocityField.hasData() ? !1 : Si(
2747
+ return !this.map || !this.velocityField.hasData() ? !1 : wi(
2728
2748
  this.velocityField.geoBounds,
2729
- xi(this.map.getBounds())
2749
+ bi(this.map.getBounds())
2730
2750
  );
2731
2751
  }
2732
2752
  reloadIfViewportUncovered() {
@@ -2743,37 +2763,37 @@ class D {
2743
2763
  * The map's current viewport is used to determine the lat bounds of the request.
2744
2764
  */
2745
2765
  async fetchVelocityData(e, t) {
2746
- const i = this.map.getBounds(), a = this.globeRendering ?? ye(this.map), r = bi(i, 1, a), n = this.zarrSource.findTimeIndex(e), o = this.zarrSource.findDepthIndex(this.depth);
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);
2747
2767
  console.log(
2748
2768
  `[zartigl] Loading velocity: depth=${this.depth} → depthIdx=${o}, actual depth value=${this.zarrSource.getCoords().vertical[o]}, timeIdx=${n}`
2749
2769
  );
2750
- const c = this.vectorDerivation?.direction_variable ?? this.variableU, d = this.zarrSource.getChunksForBounds(
2751
- c,
2770
+ const l = this.vectorDerivation?.direction_variable ?? this.variableU, d = this.zarrSource.getChunksForBounds(
2771
+ l,
2752
2772
  n,
2753
2773
  o,
2754
2774
  r
2755
- ), l = this.zarrSource.getDimensions(c), u = l.indexOf("latitude"), f = l.indexOf("longitude");
2775
+ ), c = this.zarrSource.getDimensions(l), u = c.indexOf("latitude"), f = c.indexOf("longitude");
2756
2776
  let m = 0;
2757
2777
  const p = d.length * 2, h = [], g = [];
2758
2778
  t?.(m, p);
2759
- const x = (w) => d.map(async (U) => {
2779
+ const x = (w) => d.map(async (V) => {
2760
2780
  const X = await this.zarrSource.fetchSpatialChunkResult(w, {
2761
- timeIndex: U.timeIdx,
2762
- verticalIndex: U.depthIdx,
2763
- latitudeChunkIndex: U.latIdx,
2764
- longitudeChunkIndex: U.lonIdx
2781
+ timeIndex: V.timeIdx,
2782
+ verticalIndex: V.depthIdx,
2783
+ latitudeChunkIndex: V.latIdx,
2784
+ longitudeChunkIndex: V.lonIdx
2765
2785
  });
2766
2786
  X.missing && (X.status != null && h.push(X.status), g.push(X.url)), m++, t?.(m, p);
2767
2787
  const oe = this.zarrSource.getChunkShape(w), le = oe[f];
2768
2788
  return {
2769
2789
  data: X.data,
2770
- latStart: U.latIdx * oe[u],
2771
- lonStart: U.lonIdx * le,
2772
- latSize: U.latSize,
2773
- lonSize: U.lonSize,
2790
+ latStart: V.latIdx * oe[u],
2791
+ lonStart: V.lonIdx * le,
2792
+ latSize: V.latSize,
2793
+ lonSize: V.lonSize,
2774
2794
  lonChunkSize: le
2775
2795
  };
2776
- }), [T, M] = this.vectorDerivation ? Xi(
2796
+ }), [T, M] = this.vectorDerivation ? Hi(
2777
2797
  await Promise.all(
2778
2798
  x(this.vectorDerivation.direction_variable)
2779
2799
  ),
@@ -2784,7 +2804,7 @@ class D {
2784
2804
  ) : await Promise.all([
2785
2805
  Promise.all(x(this.variableU)),
2786
2806
  Promise.all(x(this.variableV))
2787
- ]), 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)), R = v - y, E = S - _, k = T.map((w) => ({
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) => ({
2788
2808
  ...w,
2789
2809
  latStart: w.latStart - y,
2790
2810
  lonStart: w.lonStart - _
@@ -2792,20 +2812,20 @@ class D {
2792
2812
  ...w,
2793
2813
  latStart: w.latStart - y,
2794
2814
  lonStart: w.lonStart - _
2795
- })), P = this.zarrSource.getCoords(), L = Math.min(v - 1, P.latitude.length - 1), b = Math.min(S - 1, P.longitude.length - 1), A = {
2796
- west: P.longitude[_],
2797
- east: P.longitude[b],
2798
- south: Math.min(P.latitude[y], P.latitude[L]),
2799
- north: Math.max(P.latitude[y], P.latitude[L])
2800
- }, N = P.latitude[y] > P.latitude[L], C = Pt(
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(
2816
+ L.longitude,
2817
+ L.latitude,
2818
+ [_, b],
2819
+ [y, D]
2820
+ ), N = L.latitude[y] > L.latitude[D], C = Et(
2801
2821
  k,
2802
2822
  F,
2803
- R,
2804
2823
  E,
2824
+ R,
2805
2825
  A,
2806
2826
  N
2807
2827
  ), I = this.zarrSource.getValueDomain?.();
2808
- if (I != null && I > 0 && (C.uMin = -I, C.uMax = I, C.vMin = -I, C.vMax = I), !$i(C.u, C.v))
2828
+ if (I != null && I > 0 && (C.uMin = -I, C.uMax = I, C.vMin = -I, C.vMax = I), !qi(C.u, C.v))
2809
2829
  throw new xe(
2810
2830
  this.timeToMs(e),
2811
2831
  h,
@@ -2832,11 +2852,11 @@ class D {
2832
2852
  else {
2833
2853
  const o = await this.fetchVelocityData(
2834
2854
  a,
2835
- (c, d) => {
2855
+ (l, d) => {
2836
2856
  t === this.generation && i === this.requestId && this.emit("status", {
2837
2857
  phase: "fetching",
2838
2858
  time: r,
2839
- completed: c,
2859
+ completed: l,
2840
2860
  total: d
2841
2861
  });
2842
2862
  }
@@ -2853,7 +2873,7 @@ class D {
2853
2873
  const o = n instanceof Error ? n : new Error(String(n));
2854
2874
  console.error("[zartigl] Failed to load velocity:", o), t === this.generation && i === this.requestId && (this.emit(
2855
2875
  "status",
2856
- o instanceof xe ? Et(o) : { phase: "error", time: r, error: o }
2876
+ o instanceof xe ? Lt(o) : { phase: "error", time: r, error: o }
2857
2877
  ), this.emit("error", o));
2858
2878
  }
2859
2879
  } finally {
@@ -2871,7 +2891,7 @@ class D {
2871
2891
  if (this.playback ? !r || !n : !this.initialized || !this.velocityField.hasData())
2872
2892
  return;
2873
2893
  n?.setFilter(this.simulation.renderMode !== "raster");
2874
- 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], l = n ? {
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 ? {
2875
2895
  west: n.bounds[0],
2876
2896
  south: n.bounds[1],
2877
2897
  east: n.bounds[2],
@@ -2879,14 +2899,14 @@ class D {
2879
2899
  } : this.velocityField.geoBounds, u = r ? {
2880
2900
  a: {
2881
2901
  unit: 1,
2882
- min: c,
2902
+ min: l,
2883
2903
  max: d,
2884
2904
  physical: !0,
2885
2905
  northToSouth: !0
2886
2906
  },
2887
2907
  b: {
2888
2908
  unit: 4,
2889
- min: c,
2909
+ min: l,
2890
2910
  max: d,
2891
2911
  physical: !0,
2892
2912
  northToSouth: !0
@@ -2905,20 +2925,20 @@ class D {
2905
2925
  this.simulation.resetParticles();
2906
2926
  }
2907
2927
  this.globeRendering = h;
2908
- const g = this.map.getBounds(), x = wi(g, h), T = Be(g, h);
2928
+ const g = this.map.getBounds(), x = Ti(g, h), T = Be(g, h);
2909
2929
  i.disable(i.DEPTH_TEST), i.disable(i.STENCIL_TEST);
2910
2930
  const M = 512 * Math.pow(2, this.map.getZoom()), y = this.map.getCenter();
2911
2931
  this.simulation.render(
2912
2932
  this.velocityTexUnit,
2913
- c,
2933
+ l,
2914
2934
  d,
2915
2935
  a,
2916
2936
  x,
2917
2937
  M,
2918
2938
  T,
2919
- l,
2939
+ c,
2920
2940
  h,
2921
- _i(y.lng, y.lat),
2941
+ xi(y.lng, y.lat),
2922
2942
  t.defaultProjectionData.clippingPlane,
2923
2943
  ...u ? [u] : []
2924
2944
  );
@@ -3106,19 +3126,19 @@ class D {
3106
3126
  a(...t);
3107
3127
  }
3108
3128
  }
3109
- function Xi(s, e, t) {
3129
+ function Hi(s, e, t) {
3110
3130
  const i = [], a = [];
3111
3131
  for (let r = 0; r < s.length; r++) {
3112
- const n = s[r], o = e[r], c = new Float32Array(n.data.length), d = new Float32Array(n.data.length);
3113
- for (let l = 0; l < n.data.length; l++) {
3114
- const u = qi(
3115
- n.data[l],
3116
- o.data[l],
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],
3117
3137
  t
3118
3138
  );
3119
- c[l] = u.u, d[l] = u.v;
3139
+ l[c] = u.u, d[c] = u.v;
3120
3140
  }
3121
- i.push({ ...n, data: c }), a.push({ ...n, data: d });
3141
+ i.push({ ...n, data: l }), a.push({ ...n, data: d });
3122
3142
  }
3123
3143
  return [i, a];
3124
3144
  }
@@ -3135,7 +3155,6 @@ uniform float u_log_scale;
3135
3155
  uniform float u_vibrance;
3136
3156
  uniform float u_mask_threshold;
3137
3157
  uniform vec2 u_color_domain;
3138
- uniform vec2 u_texel_size;
3139
3158
 
3140
3159
  varying vec2 v_geo_uv;
3141
3160
 
@@ -3161,9 +3180,8 @@ float geoVideoScalarValue(float r) {
3161
3180
  }
3162
3181
 
3163
3182
  void main() {
3164
- vec2 sourceUv = vec2(v_geo_uv.x, 1.0 - v_geo_uv.y);
3165
- vec2 halfTexel = 0.5 * u_texel_size;
3166
- vec2 uv = mix(halfTexel, vec2(1.0) - halfTexel, sourceUv);
3183
+
3184
+ vec2 uv = vec2(v_geo_uv.x, 1.0 - v_geo_uv.y);
3167
3185
  vec3 media = texture2D(u_color, uv).rgb;
3168
3186
  float alpha = texture2D(u_mask, uv).r;
3169
3187
  if (alpha <= u_mask_threshold) discard;
@@ -3226,66 +3244,62 @@ class G {
3226
3244
  const n = r.manifest;
3227
3245
  if (!a || !r.maskTexture)
3228
3246
  return;
3229
- const o = Ge(i), c = [0, 1, 2, 3].map((d) => (i.activeTexture(i.TEXTURE0 + d), i.getParameter(i.TEXTURE_BINDING_2D)));
3247
+ const o = Ge(i), l = [0, 1, 2, 3].map((d) => (i.activeTexture(i.TEXTURE0 + d), i.getParameter(i.TEXTURE_BINDING_2D)));
3230
3248
  try {
3231
- const d = !!this.map && ye(this.map, t.defaultProjectionData), l = d ? this.globeProgram : this.mercatorProgram;
3232
- if (!l || !this.map)
3249
+ const d = !!this.map && ye(this.map, t.defaultProjectionData), c = d ? this.globeProgram : this.mercatorProgram;
3250
+ if (!c || !this.map)
3233
3251
  return;
3234
- i.useProgram(l), 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(l, "u_color"), 0), i.activeTexture(i.TEXTURE3), i.bindTexture(i.TEXTURE_2D, a[1]), i.uniform1i(i.getUniformLocation(l, "u_color_next"), 3), i.uniform1f(i.getUniformLocation(l, "u_mix"), a[2]), i.activeTexture(i.TEXTURE1), i.bindTexture(i.TEXTURE_2D, r.maskTexture), i.uniform1i(i.getUniformLocation(l, "u_mask"), 1), i.activeTexture(i.TEXTURE2), i.bindTexture(i.TEXTURE_2D, this.colorRampTexture), i.uniform1i(i.getUniformLocation(l, "u_color_ramp"), 2), i.uniform1f(i.getUniformLocation(l, "u_opacity"), this.opacity), i.uniform1f(i.getUniformLocation(l, "u_scalar_luma"), 1), i.uniform1f(
3235
- i.getUniformLocation(l, "u_log_scale"),
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"),
3236
3254
  this.logScale ? 1 : 0
3237
- ), i.uniform1f(i.getUniformLocation(l, "u_vibrance"), this.vibrance), i.uniform1f(
3238
- i.getUniformLocation(l, "u_mask_threshold"),
3255
+ ), i.uniform1f(i.getUniformLocation(c, "u_vibrance"), this.vibrance), i.uniform1f(
3256
+ i.getUniformLocation(c, "u_mask_threshold"),
3239
3257
  n.mask.threshold
3240
3258
  );
3241
- const { codeRange: u, valueRange: f, transfer: m } = Kt(
3259
+ const { codeRange: u, valueRange: f, transfer: m } = Jt(
3242
3260
  n.encoding
3243
3261
  );
3244
3262
  i.uniform1f(
3245
- i.getUniformLocation(l, "u_scalar_transfer"),
3263
+ i.getUniformLocation(c, "u_scalar_transfer"),
3246
3264
  m
3247
3265
  );
3248
3266
  const p = this.colorDomain ?? f;
3249
3267
  i.uniform2f(
3250
- i.getUniformLocation(l, "u_code_range"),
3268
+ i.getUniformLocation(c, "u_code_range"),
3251
3269
  ...u
3252
3270
  ), i.uniform2f(
3253
- i.getUniformLocation(l, "u_value_range"),
3271
+ i.getUniformLocation(c, "u_value_range"),
3254
3272
  ...f
3255
3273
  ), i.uniform2f(
3256
- i.getUniformLocation(l, "u_color_domain"),
3274
+ i.getUniformLocation(c, "u_color_domain"),
3257
3275
  p[0],
3258
3276
  p[1]
3259
- ), i.uniform2f(
3260
- i.getUniformLocation(l, "u_texel_size"),
3261
- 1 / n.media.width,
3262
- 1 / n.media.height
3263
3277
  ), i.uniformMatrix4fv(
3264
- i.getUniformLocation(l, "u_matrix"),
3278
+ i.getUniformLocation(c, "u_matrix"),
3265
3279
  !1,
3266
3280
  t.modelViewProjectionMatrix instanceof Float32Array ? t.modelViewProjectionMatrix : new Float32Array(Array.from(t.modelViewProjectionMatrix))
3267
3281
  );
3268
3282
  const [h, g, x, T] = n.bounds, M = x < h ? x + 360 : x;
3269
3283
  if (i.uniform4f(
3270
- i.getUniformLocation(l, "u_geo_bounds"),
3284
+ i.getUniformLocation(c, "u_geo_bounds"),
3271
3285
  h,
3272
3286
  g,
3273
3287
  M,
3274
3288
  T
3275
- ), this.bindGrid(i, l), d) {
3289
+ ), this.bindGrid(i, c), d) {
3276
3290
  const y = t.defaultProjectionData.clippingPlane;
3277
3291
  i.uniform4f(
3278
- i.getUniformLocation(l, "u_clipping_plane"),
3292
+ i.getUniformLocation(c, "u_clipping_plane"),
3279
3293
  ...y
3280
3294
  ), vt(
3281
3295
  i,
3282
3296
  {
3283
3297
  u_projection_transition: i.getUniformLocation(
3284
- l,
3298
+ c,
3285
3299
  "u_projection_transition"
3286
3300
  ),
3287
3301
  u_fallback_matrix: i.getUniformLocation(
3288
- l,
3302
+ c,
3289
3303
  "u_fallback_matrix"
3290
3304
  )
3291
3305
  },
@@ -3293,20 +3307,20 @@ class G {
3293
3307
  ), i.drawElements(i.TRIANGLES, this.indexCount, i.UNSIGNED_SHORT, 0);
3294
3308
  } else {
3295
3309
  const y = 512 * Math.pow(2, this.map.getZoom());
3296
- i.uniform1f(i.getUniformLocation(l, "u_world_size"), y);
3310
+ i.uniform1f(i.getUniformLocation(c, "u_world_size"), y);
3297
3311
  for (const v of Be(
3298
3312
  this.map.getBounds(),
3299
3313
  !1
3300
3314
  ))
3301
3315
  i.uniform1f(
3302
- i.getUniformLocation(l, "u_world_offset"),
3316
+ i.getUniformLocation(c, "u_world_offset"),
3303
3317
  v
3304
3318
  ), i.drawElements(i.TRIANGLES, this.indexCount, i.UNSIGNED_SHORT, 0);
3305
3319
  }
3306
- this.unbindGrid(i, l);
3320
+ this.unbindGrid(i, c);
3307
3321
  } finally {
3308
- c.forEach((d, l) => {
3309
- i.activeTexture(i.TEXTURE0 + l), i.bindTexture(i.TEXTURE_2D, d);
3322
+ l.forEach((d, c) => {
3323
+ i.activeTexture(i.TEXTURE0 + c), i.bindTexture(i.TEXTURE_2D, d);
3310
3324
  }), Oe(i, o);
3311
3325
  }
3312
3326
  }
@@ -3386,7 +3400,7 @@ class G {
3386
3400
  id: this.id,
3387
3401
  initialized: !!e?.currentPair,
3388
3402
  playing: this.playback.isPlaying(),
3389
- currentTime: e ? e.manifest.timeline.kind === "snapshot-loop" ? (this.playback.time - e.times[0]) / 1e3 : Jt(e.manifest, this.playback.time) : 0,
3403
+ currentTime: e ? e.manifest.timeline.kind === "snapshot-loop" ? (this.playback.time - e.times[0]) / 1e3 : ei(e.manifest, this.playback.time) : 0,
3390
3404
  manifestId: this.manifest?.id,
3391
3405
  mediaUrl: this.manifest?.media.url,
3392
3406
  preloadedMediaUrl: this.playback.preloadedMediaUrl,
@@ -3410,7 +3424,7 @@ class G {
3410
3424
  return this.listeners.get(e)?.delete(t), this;
3411
3425
  }
3412
3426
  initGl(e) {
3413
- this.mercatorProgram = W(e, wt, Ke), this.globeProgram = W(e, Tt, Ke), this.colorRampTexture = ge(
3427
+ this.mercatorProgram = W(e, Tt, Ke), this.globeProgram = W(e, Mt, Ke), this.colorRampTexture = ge(
3414
3428
  e,
3415
3429
  ke(this.colorRamp)
3416
3430
  );
@@ -3419,15 +3433,15 @@ class G {
3419
3433
  );
3420
3434
  let i = 0;
3421
3435
  for (let o = 0; o <= te; o++)
3422
- for (let c = 0; c <= Z; c++)
3423
- t[i++] = c / Z, t[i++] = o / te;
3436
+ for (let l = 0; l <= Z; l++)
3437
+ t[i++] = l / Z, t[i++] = o / te;
3424
3438
  const a = new Uint16Array(Z * te * 6);
3425
3439
  let r = 0;
3426
3440
  const n = Z + 1;
3427
3441
  for (let o = 0; o < te; o++)
3428
- for (let c = 0; c < Z; c++) {
3429
- const d = o * n + c, l = d + 1, u = d + n, f = u + 1;
3430
- a[r++] = d, a[r++] = u, a[r++] = l, a[r++] = l, a[r++] = u, a[r++] = f;
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;
3431
3445
  }
3432
3446
  if (this.vertexBuffer = e.createBuffer(), this.indexBuffer = e.createBuffer(), !this.vertexBuffer || !this.indexBuffer)
3433
3447
  throw new Error("Failed to create GeoVideo grid");
@@ -3451,17 +3465,17 @@ function $e(s) {
3451
3465
  function j(s) {
3452
3466
  return encodeURIComponent(String(s));
3453
3467
  }
3454
- function Lt(s, e) {
3468
+ function Dt(s, e) {
3455
3469
  return e === "depth" ? -Math.abs(s) : s;
3456
3470
  }
3457
- function Hi(s) {
3471
+ function Yi(s) {
3458
3472
  let e = s.template.replace(/\{TileMatrix\}/gi, "{z}").replace(/\{TileRow\}/gi, "{y}").replace(/\{TileCol\}/gi, "{x}");
3459
3473
  return s.tileMatrixSet != null && (e = e.replace(
3460
3474
  /\{TileMatrixSet\}/gi,
3461
3475
  j(s.tileMatrixSet)
3462
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(
3463
3477
  /\{elevation\}/gi,
3464
- j(Lt(s.depth, s.verticalLabel))
3478
+ j(Dt(s.depth, s.verticalLabel))
3465
3479
  )), [...e.matchAll(/\{([^{}]+)\}/g)].some(
3466
3480
  (t) => !/^(?:z|y|x)$/i.test(t[1])
3467
3481
  ) ? void 0 : e;
@@ -3480,14 +3494,14 @@ function Je(s) {
3480
3494
  ];
3481
3495
  s.style && e.push(["STYLE", s.style]), s.time != null && e.push(["time", $e(s.time)]), s.depth != null && e.push([
3482
3496
  "elevation",
3483
- String(Lt(s.depth, s.verticalLabel))
3497
+ String(Dt(s.depth, s.verticalLabel))
3484
3498
  ]);
3485
3499
  const t = e.map(
3486
3500
  ([i, a]) => `${i}=${a.startsWith("{") ? a : j(a)}`
3487
3501
  ).join("&");
3488
3502
  return `${s.baseUrl}?${t}`;
3489
3503
  }
3490
- function Yi(s) {
3504
+ function Zi(s) {
3491
3505
  const e = [
3492
3506
  ["SERVICE", "WMTS"],
3493
3507
  ["REQUEST", "GetLegend"],
@@ -3496,38 +3510,38 @@ function Yi(s) {
3496
3510
  ];
3497
3511
  return s.style && e.push(["STYLE", s.style]), `${s.baseUrl}?${e.map(([t, i]) => `${t}=${j(i)}`).join("&")}`;
3498
3512
  }
3499
- function Zi(s) {
3513
+ function ji(s) {
3500
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";
3501
3515
  }
3502
- function ji(s) {
3516
+ function Qi(s) {
3503
3517
  return s.variables.kind === "scalar" ? s.variables.value : "scalar";
3504
3518
  }
3505
- function Qi(s) {
3519
+ function Ki(s) {
3506
3520
  return s.variables.kind === "vector" ? s.variables.u ?? "uo" : "uo";
3507
3521
  }
3508
- function Ki(s) {
3522
+ function Ji(s) {
3509
3523
  return s.variables.kind === "vector" ? s.variables.v ?? "vo" : "vo";
3510
3524
  }
3511
- function Ji(s) {
3525
+ function ea(s) {
3512
3526
  return s.variables.kind === "vector" ? s.variables.derivation : void 0;
3513
3527
  }
3514
- class ea {
3528
+ class ta {
3515
3529
  constructor(e) {
3516
- 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 = Zi(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") {
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") {
3517
3531
  const t = e.sourceConfig;
3518
- this.delegate = new D({
3532
+ this.delegate = new P({
3519
3533
  ...e,
3520
3534
  source: t.endpoints.field,
3521
3535
  zarrSource: e.zarrSource,
3522
- variableU: Qi(t),
3523
- variableV: Ki(t),
3524
- vectorDerivation: Ji(t),
3536
+ variableU: Ki(t),
3537
+ variableV: Ji(t),
3538
+ vectorDerivation: ea(t),
3525
3539
  unit: e.unit ?? ""
3526
3540
  });
3527
3541
  } else if (this.backend === "vector-geovideo") {
3528
3542
  if (!e.geoVideoManifest)
3529
3543
  throw new Error("Vector GeoVideo requires a loaded manifest");
3530
- this.delegate = new D({
3544
+ this.delegate = new P({
3531
3545
  ...e,
3532
3546
  source: e.geoVideoManifest.media.url,
3533
3547
  geoVideo: {
@@ -3548,7 +3562,7 @@ class ea {
3548
3562
  id: e.id,
3549
3563
  source: t.endpoints.field,
3550
3564
  zarrSource: e.zarrSource,
3551
- variable: ji(t),
3565
+ variable: Qi(t),
3552
3566
  time: e.time,
3553
3567
  depth: e.depth,
3554
3568
  colorRamp: e.colorRamp,
@@ -3579,7 +3593,7 @@ class ea {
3579
3593
  vibrance: e.vibrance
3580
3594
  });
3581
3595
  }
3582
- this.delegate instanceof D && this.backend === "vector-geovideo" && this.delegate.on("timeChange", (t) => {
3596
+ this.delegate instanceof P && this.backend === "vector-geovideo" && this.delegate.on("timeChange", (t) => {
3583
3597
  this.time = t;
3584
3598
  });
3585
3599
  }
@@ -3667,16 +3681,16 @@ class ea {
3667
3681
  }
3668
3682
  }
3669
3683
  setSpeed(e) {
3670
- this.delegate instanceof D && this.delegate.setSpeed(e);
3684
+ this.delegate instanceof P && this.delegate.setSpeed(e);
3671
3685
  }
3672
3686
  setFade(e) {
3673
- this.delegate instanceof D && this.delegate.setFade(e);
3687
+ this.delegate instanceof P && this.delegate.setFade(e);
3674
3688
  }
3675
3689
  setParticleDensity(e) {
3676
- this.delegate instanceof D && this.delegate.setParticleDensity(e);
3690
+ this.delegate instanceof P && this.delegate.setParticleDensity(e);
3677
3691
  }
3678
3692
  setRenderMode(e) {
3679
- this.delegate instanceof D && this.delegate.setRenderMode(e);
3693
+ this.delegate instanceof P && this.delegate.setRenderMode(e);
3680
3694
  }
3681
3695
  setRgba8MaxParticleZoom(e) {
3682
3696
  this.delegate?.setRgba8MaxParticleZoom(e);
@@ -3692,34 +3706,34 @@ class ea {
3692
3706
  this.map?.getLayer(this.rasterLayerId) && this.map.setPaintProperty(this.rasterLayerId, "raster-opacity", e);
3693
3707
  }
3694
3708
  setLogScale(e) {
3695
- this.delegate instanceof me && this.delegate.setLogScale(e), this.delegate instanceof D && this.delegate.setLogScale(e), this.delegate instanceof G && this.delegate.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);
3696
3710
  }
3697
3711
  setVibrance(e) {
3698
3712
  this.delegate?.setVibrance(e);
3699
3713
  }
3700
3714
  /** Particle trails only; rasters ignore it. */
3701
3715
  setColorGrade(e) {
3702
- this.delegate instanceof D && this.delegate.setColorGrade(e);
3716
+ this.delegate instanceof P && this.delegate.setColorGrade(e);
3703
3717
  }
3704
3718
  /** Under particle trails only; rasters ignore it. */
3705
3719
  setBackdrop(e) {
3706
- this.delegate instanceof D && this.delegate.setBackdrop(e);
3720
+ this.delegate instanceof P && this.delegate.setBackdrop(e);
3707
3721
  }
3708
3722
  /** Particle trails only; rasters ignore it. */
3709
3723
  setGlow(e) {
3710
- this.delegate instanceof D && this.delegate.setGlow(e);
3724
+ this.delegate instanceof P && this.delegate.setGlow(e);
3711
3725
  }
3712
3726
  setColorDomain(e) {
3713
3727
  this.delegate instanceof me && this.delegate.setColorDomain(e), this.delegate instanceof G && this.delegate.setColorDomain(e);
3714
3728
  }
3715
3729
  async play() {
3716
- (this.delegate instanceof G || this.delegate instanceof D) && await this.delegate.play();
3730
+ (this.delegate instanceof G || this.delegate instanceof P) && await this.delegate.play();
3717
3731
  }
3718
3732
  pause() {
3719
- (this.delegate instanceof G || this.delegate instanceof D) && this.delegate.pause();
3733
+ (this.delegate instanceof G || this.delegate instanceof P) && this.delegate.pause();
3720
3734
  }
3721
3735
  setLoop(e) {
3722
- (this.delegate instanceof G || this.delegate instanceof D) && this.delegate.setLoop(e);
3736
+ (this.delegate instanceof G || this.delegate instanceof P) && this.delegate.setLoop(e);
3723
3737
  }
3724
3738
  /** Media rate multiplier of a scalar GeoVideo. */
3725
3739
  setPlaybackRate(e) {
@@ -3727,21 +3741,21 @@ class ea {
3727
3741
  }
3728
3742
  /** Cadence of the continuous vector GeoVideo clock. */
3729
3743
  setStepsPerSecond(e) {
3730
- this.delegate instanceof D && this.delegate.setStepsPerSecond(e);
3744
+ this.delegate instanceof P && this.delegate.setStepsPerSecond(e);
3731
3745
  }
3732
3746
  setTimeRange(e) {
3733
- (this.delegate instanceof G || this.delegate instanceof D) && this.delegate.setTimeRange(e);
3747
+ (this.delegate instanceof G || this.delegate instanceof P) && this.delegate.setTimeRange(e);
3734
3748
  }
3735
3749
  /**
3736
3750
  * Move a GeoVideo to another artifact, such as the next archive
3737
3751
  * chunk, without rebuilding the map layer. False when a new layer is needed.
3738
3752
  */
3739
3753
  replaceGeoVideoManifest(e, t) {
3740
- return this.suspended || !(this.delegate instanceof G || this.delegate instanceof D) || !this.delegate.replaceManifest(e, t) ? !1 : (t.time != null && (this.time = t.time), !0);
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);
3741
3755
  }
3742
3756
  /** Load the GeoVideo artifact expected next, such as the next archive chunk. */
3743
3757
  preloadGeoVideoManifest(e, t) {
3744
- return !this.suspended && (this.delegate instanceof G || this.delegate instanceof D) && this.delegate.preloadManifest(e, t);
3758
+ return !this.suspended && (this.delegate instanceof G || this.delegate instanceof P) && this.delegate.preloadManifest(e, t);
3745
3759
  }
3746
3760
  async samplePoint(e) {
3747
3761
  if (this.delegate instanceof me)
@@ -3758,7 +3772,7 @@ class ea {
3758
3772
  return;
3759
3773
  this.removeWmts();
3760
3774
  const e = this.options.sourceConfig, t = e.tileUrlTemplate ? [
3761
- Hi({
3775
+ Yi({
3762
3776
  template: e.tileUrlTemplate,
3763
3777
  tileMatrixSet: e.tileMatrixSet,
3764
3778
  style: e.style,
@@ -3832,13 +3846,13 @@ class ea {
3832
3846
  function Pe(s, e) {
3833
3847
  return s.match(new RegExp(`\\b${e}=["']([^"']+)["']`, "i"))?.[1].replace(/&amp;/g, "&").replace(/&quot;/g, '"').replace(/&apos;/g, "'");
3834
3848
  }
3835
- function ta(s, e, t) {
3849
+ function ia(s, e, t) {
3836
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);
3837
3851
  return [...a.matchAll(/\{([^{}]+)\}/g)].some(
3838
3852
  (n) => !/^(?:z|y|x|Time|Elevation)$/i.test(n[1])
3839
3853
  ) ? void 0 : a;
3840
3854
  }
3841
- function Dt(s) {
3855
+ function At(s) {
3842
3856
  return s.replace(/<[^>]+>/g, "").trim();
3843
3857
  }
3844
3858
  function be(s, e) {
@@ -3849,7 +3863,7 @@ function be(s, e) {
3849
3863
  return [...s.matchAll(t)].map((i) => i[1]);
3850
3864
  }
3851
3865
  function se(s, e) {
3852
- return be(s, e).map(Dt).find(Boolean);
3866
+ return be(s, e).map(At).find(Boolean);
3853
3867
  }
3854
3868
  function et(s, e) {
3855
3869
  const t = e.match(
@@ -3857,22 +3871,22 @@ function et(s, e) {
3857
3871
  );
3858
3872
  if (!t || !t.slice(1).some((m) => Number(m) > 0))
3859
3873
  return;
3860
- 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(), c = i.getUTCMinutes(), d = i.getUTCSeconds(), l = i.getUTCMilliseconds(), u = new Date(
3861
- Date.UTC(a, r, 1, o, c, d, l)
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)
3862
3876
  ), f = new Date(
3863
3877
  Date.UTC(u.getUTCFullYear(), u.getUTCMonth() + 1, 0)
3864
3878
  ).getUTCDate();
3865
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();
3866
3880
  }
3867
- function ia(s) {
3881
+ function aa(s) {
3868
3882
  const e = [];
3869
3883
  for (const t of s.flatMap((i) => i.split(","))) {
3870
3884
  const i = t.trim().split("/");
3871
3885
  if (i.length === 3) {
3872
3886
  const r = Date.parse(i[0]), n = Date.parse(i[1]), o = et(r, i[2]);
3873
3887
  if (Number.isFinite(r) && Number.isFinite(n) && o && o > r)
3874
- for (let c = r, d = 0; c <= n && d < 1e5; d += 1)
3875
- e.push(c), c = et(c, i[2]);
3888
+ for (let l = r, d = 0; l <= n && d < 1e5; d += 1)
3889
+ e.push(l), l = et(l, i[2]);
3876
3890
  continue;
3877
3891
  }
3878
3892
  const a = Date.parse(t.trim());
@@ -3883,10 +3897,10 @@ function ia(s) {
3883
3897
  function tt(s, e) {
3884
3898
  for (const t of be(s, "Dimension"))
3885
3899
  if (se(t, "Identifier")?.toLowerCase() === e.toLowerCase())
3886
- return be(t, "Value").map(Dt);
3900
+ return be(t, "Value").map(At);
3887
3901
  return [];
3888
3902
  }
3889
- function aa(s, e) {
3903
+ function sa(s, e) {
3890
3904
  const t = be(s, "Layer").find(
3891
3905
  (h) => se(h, "Identifier") === e.layer
3892
3906
  );
@@ -3895,7 +3909,7 @@ function aa(s, e) {
3895
3909
  const i = e.tileMatrixSet ?? se(t, "TileMatrixSet") ?? "";
3896
3910
  if (!/3857|GoogleMapsCompatible/i.test(i))
3897
3911
  throw new Error(`Unsupported WMTS tile matrix set: ${i || "missing"}`);
3898
- const a = ia(tt(t, "time")), r = a.length ? {
3912
+ const a = aa(tt(t, "time")), r = a.length ? {
3899
3913
  min: a[0],
3900
3914
  max: a[a.length - 1],
3901
3915
  size: a.length,
@@ -3904,13 +3918,13 @@ function aa(s, e) {
3904
3918
  step: a.length > 1 && a.every(
3905
3919
  (h, g) => g === 0 || h - a[g - 1] === a[1] - a[0]
3906
3920
  ) ? a[1] - a[0] : void 0
3907
- } : { 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, c = s.match(
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(
3908
3922
  /GetTile[\s\S]*?(?:xlink:href|href)=["']([^"']+)/i
3909
- )?.[1], l = [
3923
+ )?.[1], c = [
3910
3924
  ...t.matchAll(/<(?:(?:\w+):)?ResourceURL\b([^>]*)\/?\s*>/gi)
3911
3925
  ].find(
3912
3926
  (h) => Pe(h[1], "resourceType")?.toLowerCase() === "tile"
3913
- ), u = l ? Pe(l[1], "template") : void 0, f = [
3927
+ ), u = c ? Pe(c[1], "template") : void 0, f = [
3914
3928
  ...t.matchAll(
3915
3929
  /<(?:(?:\w+):)?Style\b([^>]*)>([\s\S]*?)<\/(?:(?:\w+):)?Style>/gi
3916
3930
  )
@@ -3918,8 +3932,8 @@ function aa(s, e) {
3918
3932
  (h) => Pe(h[1], "isDefault")?.toLowerCase() === "true"
3919
3933
  ), p = e.style ?? se(m?.[2] ?? f[0]?.[2] ?? "", "Identifier");
3920
3934
  return {
3921
- baseUrl: e.baseUrl ?? c ?? new URL(e.capabilitiesUrl).origin,
3922
- tileUrlTemplate: e.tileUrlTemplate ?? (u ? ta(u, i, p) : void 0),
3935
+ baseUrl: e.baseUrl ?? l ?? new URL(e.capabilitiesUrl).origin,
3936
+ tileUrlTemplate: e.tileUrlTemplate ?? (u ? ia(u, i, p) : void 0),
3923
3937
  tileMatrixSet: i,
3924
3938
  format: e.format ?? se(t, "Format") ?? "image/png",
3925
3939
  style: p,
@@ -3927,15 +3941,15 @@ function aa(s, e) {
3927
3941
  vertical: o
3928
3942
  };
3929
3943
  }
3930
- async function sa(s, e) {
3944
+ async function ra(s, e) {
3931
3945
  const t = await fetch(s.capabilitiesUrl, { signal: e });
3932
3946
  if (!t.ok)
3933
3947
  throw new Error(
3934
3948
  `WMTS capabilities request failed (${t.status}): ${s.capabilitiesUrl}`
3935
3949
  );
3936
- return aa(await t.text(), s);
3950
+ return sa(await t.text(), s);
3937
3951
  }
3938
- const ra = [
3952
+ const na = [
3939
3953
  0.25,
3940
3954
  0.5,
3941
3955
  1,
@@ -3953,8 +3967,8 @@ function at(s, e) {
3953
3967
  a < t && (t = a), a <= e && (i === void 0 || a > i) && (i = a);
3954
3968
  return i ?? t;
3955
3969
  }
3956
- function na(s) {
3957
- const e = s.map((n) => new Date(n)), t = (n) => n.every((o) => e.every((c) => o(c) === o(e[0]))), i = [
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 = [
3958
3972
  (n) => n.getUTCHours(),
3959
3973
  (n) => n.getUTCMinutes(),
3960
3974
  (n) => n.getUTCSeconds(),
@@ -3965,7 +3979,7 @@ function na(s) {
3965
3979
  return "year";
3966
3980
  if (t([(o) => o.getUTCDate(), ...i]))
3967
3981
  return "month";
3968
- const n = s.slice(1).map((o, c) => o - s[c]);
3982
+ const n = s.slice(1).map((o, l) => o - s[l]);
3969
3983
  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";
3970
3984
  }
3971
3985
  const a = e[0];
@@ -3974,7 +3988,7 @@ function na(s) {
3974
3988
  const r = a.getUTCHours() === 0 && a.getUTCMinutes() === 0 && a.getUTCSeconds() === 0 && a.getUTCMilliseconds() === 0;
3975
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";
3976
3990
  }
3977
- function At(s) {
3991
+ function Ct(s) {
3978
3992
  if (s.length < 2)
3979
3993
  return;
3980
3994
  const e = s[1] - s[0];
@@ -4002,7 +4016,7 @@ function ne(s, e) {
4002
4016
  min: r[0],
4003
4017
  max: r[r.length - 1],
4004
4018
  size: r.length,
4005
- step: At(r),
4019
+ step: Ct(r),
4006
4020
  values: r
4007
4021
  };
4008
4022
  }
@@ -4020,16 +4034,16 @@ function Ee(s, e) {
4020
4034
  const t = s.sources.filter(Fe);
4021
4035
  return t.find((i) => i.id === e) ?? (e === "geovideo" || e === "auto" ? t[0] : void 0);
4022
4036
  }
4023
- function Ct(s) {
4037
+ function kt(s) {
4024
4038
  return [...s].sort((e, t) => {
4025
4039
  const i = Math.abs(e), a = Math.abs(t);
4026
4040
  return i !== a ? i - a : t - e;
4027
4041
  });
4028
4042
  }
4029
4043
  function Le(s, e) {
4030
- return s?.values.length ? e == null ? Ct(s.values)[0] : V(s.values, e) : e ?? 0;
4044
+ return s?.values.length ? e == null ? kt(s.values)[0] : U(s.values, e) : e ?? 0;
4031
4045
  }
4032
- function V(s, e) {
4046
+ function U(s, e) {
4033
4047
  if (s.length === 0)
4034
4048
  return e;
4035
4049
  let t = s[0], i = Math.abs(t - e);
@@ -4048,13 +4062,13 @@ function rt(s) {
4048
4062
  throw new Error(`${t} must be positive`);
4049
4063
  }
4050
4064
  function nt(s, e) {
4051
- const t = s.surface?.value ?? 0, i = V(
4065
+ const t = s.surface?.value ?? 0, i = U(
4052
4066
  [t, ...s.depths.map((a) => a.value)],
4053
4067
  e
4054
4068
  );
4055
4069
  return i === t ? null : i;
4056
4070
  }
4057
- function oa(s) {
4071
+ function la(s) {
4058
4072
  const e = s.surface ?? s.depths[0];
4059
4073
  return {
4060
4074
  name: e.name,
@@ -4072,18 +4086,18 @@ function ot(s, e) {
4072
4086
  e ? [e.name, e.units, e.values] : null
4073
4087
  ]);
4074
4088
  }
4075
- function la(s) {
4089
+ function ca(s) {
4076
4090
  const e = [...new Set(s)].sort((t, i) => t - i);
4077
4091
  return {
4078
4092
  min: e[0],
4079
4093
  max: e[e.length - 1],
4080
- step: At(e),
4094
+ step: Ct(e),
4081
4095
  size: e.length,
4082
4096
  units: "milliseconds since 1970-01-01T00:00:00Z",
4083
4097
  values: e
4084
4098
  };
4085
4099
  }
4086
- const ca = 5 * 6e4, ha = 6e4, lt = 6;
4100
+ const ha = 5 * 6e4, ua = 6e4, lt = 6;
4087
4101
  function pe(s) {
4088
4102
  const { particles: e = {}, raster: t = {} } = s, i = {
4089
4103
  palette: s.palette,
@@ -4093,7 +4107,7 @@ function pe(s) {
4093
4107
  speed: e.speed,
4094
4108
  fade: e.fade,
4095
4109
  glow: e.glow,
4096
- colorGrade: e.grade === void 0 ? void 0 : fi(e.grade),
4110
+ colorGrade: e.grade === void 0 ? void 0 : pi(e.grade),
4097
4111
  opacity: t.opacity,
4098
4112
  logScale: t.logScale,
4099
4113
  vibrance: t.vibrance,
@@ -4107,29 +4121,29 @@ function pe(s) {
4107
4121
  Object.entries(i).filter(([, a]) => a !== void 0)
4108
4122
  );
4109
4123
  }
4110
- function Ve(s) {
4124
+ function Ue(s) {
4111
4125
  const e = s.alphaFadeLow ?? 0, t = s.alphaFadeHigh ?? 0;
4112
4126
  return e > 0 || t > 0 ? { low: e, high: t, curve: s.alphaFadeCurve ?? "linear" } : void 0;
4113
4127
  }
4114
- const ct = "rdylbu", ua = new Set(
4128
+ const ct = "rdylbu", da = new Set(
4115
4129
  _t({ includeDeprecated: !0 }).map((s) => s.id)
4116
4130
  ), ht = /* @__PURE__ */ new Set();
4117
4131
  function Ne(s) {
4118
- return typeof s != "string" || ua.has(s) ? s : (ht.has(s) || (ht.add(s), console.warn(
4132
+ return typeof s != "string" || da.has(s) ? s : (ht.has(s) || (ht.add(s), console.warn(
4119
4133
  `[zartigl] palette "${s}" is not in this version: drawn with "${ct}"`
4120
4134
  )), ct);
4121
4135
  }
4122
4136
  function De(s) {
4123
- const { reversePalette: e } = s, t = Ne(s.palette), i = Ve(s);
4137
+ const { reversePalette: e } = s, t = Ne(s.palette), i = Ue(s);
4124
4138
  return t != null && (e || i) ? ke(t, { reverse: e, alphaFade: i }) : t;
4125
4139
  }
4126
- const da = [
4140
+ const ma = [
4127
4141
  "palette",
4128
4142
  "reversePalette",
4129
4143
  "alphaFadeLow",
4130
4144
  "alphaFadeHigh",
4131
4145
  "alphaFadeCurve"
4132
- ], kt = Object.freeze({
4146
+ ], Ft = Object.freeze({
4133
4147
  palette: "style.palette",
4134
4148
  renderMode: "style.renderMode",
4135
4149
  particleDensity: "style.particles.density",
@@ -4151,13 +4165,13 @@ function Ae(s) {
4151
4165
  fade: r,
4152
4166
  colorGrade: n,
4153
4167
  opacity: o,
4154
- logScale: c,
4168
+ logScale: l,
4155
4169
  vibrance: d,
4156
- colorDomain: l,
4170
+ colorDomain: c,
4157
4171
  backdrop: u,
4158
4172
  ...f
4159
4173
  } = s ?? {}, m = Object.keys(s ?? {}).filter(
4160
- (h) => h in kt && s[h] !== void 0
4174
+ (h) => h in Ft && s[h] !== void 0
4161
4175
  );
4162
4176
  return {
4163
4177
  style: ae({
@@ -4167,10 +4181,10 @@ function Ae(s) {
4167
4181
  density: i,
4168
4182
  speed: a,
4169
4183
  fade: r,
4170
- grade: n && mi(n),
4184
+ grade: n && fi(n),
4171
4185
  backdrop: u
4172
4186
  },
4173
- raster: { opacity: o, logScale: c, vibrance: d, colorDomain: l }
4187
+ raster: { opacity: o, logScale: l, vibrance: d, colorDomain: c }
4174
4188
  }),
4175
4189
  settings: e === void 0 || typeof e == "string" ? f : { ...f, palette: e },
4176
4190
  legacyKeys: m
@@ -4180,10 +4194,10 @@ const ut = /* @__PURE__ */ new Set();
4180
4194
  function dt(s) {
4181
4195
  for (const e of s)
4182
4196
  ut.has(e) || (ut.add(e), console.warn(
4183
- `[zartigl] settings.${e} is deprecated: use ${kt[e]}`
4197
+ `[zartigl] settings.${e} is deprecated: use ${Ft[e]}`
4184
4198
  ));
4185
4199
  }
4186
- function Ft(s, e) {
4200
+ function It(s, e) {
4187
4201
  const t = ze(s, e);
4188
4202
  return {
4189
4203
  ...pe(t),
@@ -4191,14 +4205,14 @@ function Ft(s, e) {
4191
4205
  colorDomain: Q(t.raster.colorDomain)
4192
4206
  };
4193
4207
  }
4194
- function ma(s) {
4208
+ function fa(s) {
4195
4209
  return {
4196
- ...Ft(s),
4210
+ ...It(s),
4197
4211
  particleState: "auto",
4198
4212
  rgba8MaxParticleZoom: 4
4199
4213
  };
4200
4214
  }
4201
- function fa(s) {
4215
+ function pa(s) {
4202
4216
  const { palette: e, ...t } = s;
4203
4217
  return t;
4204
4218
  }
@@ -4207,7 +4221,7 @@ function mt(s, e, t) {
4207
4221
  kind: e.layers.find((i) => i.id === t)?.kind
4208
4222
  });
4209
4223
  }
4210
- class Da {
4224
+ class Aa {
4211
4225
  constructor(e) {
4212
4226
  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 = () => {
4213
4227
  this.attachQueued && this.attachWhenReady();
@@ -4265,11 +4279,11 @@ class Da {
4265
4279
  }
4266
4280
  async applyUpdate(e, t, i) {
4267
4281
  this.assertAlive(), i != null && e.time != null && this.playSeq !== 0 && this.playSeq < i && this.pause();
4268
- 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 }, c = 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), l = e.settings?.palette, u = d !== void 0 && l !== void 0 && typeof l != "string" && e.style?.palette === void 0 ? fa(d) : d;
4269
- mt(u, this.catalog, c);
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);
4270
4284
  const f = u ?? (a ? pt(
4271
4285
  this.style,
4272
- this.catalog.layers.find((m) => m.id === c)?.kind
4286
+ this.catalog.layers.find((m) => m.id === l)?.kind
4273
4287
  ) : void 0);
4274
4288
  if (a) {
4275
4289
  const m = { ...e.settings, ...pe(f) };
@@ -4328,104 +4342,104 @@ class Da {
4328
4342
  );
4329
4343
  if (!r)
4330
4344
  throw new Error(`Unknown zartigl catalog entry: ${e}`);
4331
- const n = ma(r), o = i ? i.timeRange : this.timeRange, c = a ?? ++this.switchGeneration, d = {
4345
+ const n = fa(r), o = i ? i.timeRange : this.timeRange, l = a ?? ++this.switchGeneration, d = {
4332
4346
  ...i?.target,
4333
4347
  depth: i?.target?.depth ?? this.depthRequest ?? void 0
4334
- }, l = await this.selectSource(
4348
+ }, c = await this.selectSource(
4335
4349
  r,
4336
4350
  t,
4337
4351
  o,
4338
4352
  d
4339
4353
  ), u = i?.settings ?? this.settings, f = i?.colorDomainOverridden ?? this.colorDomainOverridden, m = i?.paletteOverridden ?? this.paletteOverridden;
4340
- if (l.type === "geovideo") {
4354
+ if (c.type === "geovideo") {
4341
4355
  this.emit("status", { phase: "metadata" });
4342
4356
  try {
4343
- if (!l.manifestUrl)
4357
+ if (!c.manifestUrl)
4344
4358
  throw new Error(
4345
- `GeoVideo archive source was not resolved to a chunk: ${l.id}`
4359
+ `GeoVideo archive source was not resolved to a chunk: ${c.id}`
4346
4360
  );
4347
4361
  const v = await this.loadChunkManifest(
4348
- l.manifestUrl
4362
+ c.manifestUrl
4349
4363
  ), _ = r.sources.find(
4350
4364
  (ce) => ce.id === v.provenance.inputSourceId
4351
4365
  );
4352
- if (v.id !== l.id || v.provenance.catalogEntryId !== r.id || _?.type !== "zarr")
4366
+ if (v.id !== c.id || v.provenance.catalogEntryId !== r.id || _?.type !== "zarr")
4353
4367
  throw new Error(
4354
- `GeoVideo manifest identity does not match catalog entry/source: ${l.id}`
4368
+ `GeoVideo manifest identity does not match catalog entry/source: ${c.id}`
4355
4369
  );
4356
- const S = Ee(r, l.id), R = S ? this.chunkLevels.get(l.manifestUrl) ?? null : null, E = v.vertical;
4357
- if (S && (R ? !He(E, R) : E !== void 0))
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))
4358
4372
  throw new Error(
4359
- `GeoVideo manifest level does not match its index: ${l.manifestUrl}`
4373
+ `GeoVideo manifest level does not match its index: ${c.manifestUrl}`
4360
4374
  );
4361
- const k = R?.value ?? null, F = S ? await this.archiveTimes(r, l.id, k) : null, P = S ? await this.archiveLevels(r, S) : null, L = !!P?.depths.length, b = !L && !!P?.surface, A = L || b ? oa(P) : null;
4362
- if (c !== this.switchGeneration)
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)
4363
4377
  throw new DOMException(
4364
4378
  "Layer selection was superseded",
4365
4379
  "AbortError"
4366
4380
  );
4367
- const N = we(v), C = la(F ?? N), I = re(
4381
+ const N = we(v), C = ca(F ?? N), I = re(
4368
4382
  C,
4369
4383
  o
4370
4384
  ), w = ne(
4371
4385
  C,
4372
4386
  o
4373
- ), U = N.filter(
4387
+ ), V = N.filter(
4374
4388
  (ce) => ce >= w.min && ce <= w.max
4375
- ), X = U.length ? U : N, oe = this.catalogLayer?.id === r.id && this.catalogSource?.type === "geovideo", le = this.settings.palette;
4376
- this.catalogLayer = r, this.catalogSource = l, 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] : V(X, this.pendingTime), this.pendingTime = null, this.depthLocked = b, this.archiveLevel = k, this.depth = L ? k ?? P.surface?.value ?? 0 : Le(A, d.depth), L && (this.depthRequest = this.depth);
4377
- const zt = u.colorDomain;
4378
- if (this.settings = { ...n, ...u }, this.colorDomainOverridden = f, this.paletteOverridden = m, this.settings.colorDomain = f ? zt ?? 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))
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))
4379
4393
  return;
4380
4394
  this.detach(), this.attachWhenReady();
4381
4395
  return;
4382
4396
  } catch (v) {
4383
- const _ = v instanceof Error ? v : new Error(String(v)), S = l.manifestUrl;
4384
- if (_.name !== "AbortError" && !(_ instanceof RangeError) && t === "auto" && S && !this.failedGeoVideo.has(S) && this.catalogSource?.id !== l.id)
4385
- return console.warn("[zartigl] GeoVideo unavailable, falling back:", _), this.failedGeoVideo.add(S), this.loadSource(e, t, i, c);
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);
4386
4400
  throw _.name !== "AbortError" && (this.emit("status", { phase: "error", error: _ }), this.emit("error", _)), _;
4387
4401
  }
4388
4402
  }
4389
- if (l.type === "wmts") {
4403
+ if (c.type === "wmts") {
4390
4404
  this.emit("status", { phase: "metadata" });
4391
4405
  try {
4392
- const v = await sa(l);
4393
- if (c !== this.switchGeneration)
4406
+ const v = await ra(c);
4407
+ if (l !== this.switchGeneration)
4394
4408
  throw new DOMException(
4395
4409
  "Layer selection was superseded",
4396
4410
  "AbortError"
4397
4411
  );
4398
4412
  const _ = v.time, S = ne(_, o);
4399
4413
  this.detach(), this.catalogLayer = r, this.catalogSource = {
4400
- ...l,
4414
+ ...c,
4401
4415
  baseUrl: v.baseUrl,
4402
- tileUrlTemplate: l.tileUrlTemplate ?? v.tileUrlTemplate,
4416
+ tileUrlTemplate: c.tileUrlTemplate ?? v.tileUrlTemplate,
4403
4417
  tileMatrixSet: v.tileMatrixSet,
4404
4418
  format: v.format,
4405
- style: l.style ?? v.style
4419
+ style: c.style ?? v.style
4406
4420
  }, this.sourcePreference = t, this.timeRange = o, this.activeFieldSource = null, this.geoVideoManifest = null, this.wmtsMetadata = v, this.fullTimeMeta = _, this.resolvedTimeRange = re(
4407
4421
  _,
4408
4422
  o
4409
- ), this.timeMeta = S, this.verticalMeta = v.vertical, this.archiveLevel = null, this.depthLocked = !1, this.variableUnit = "", this.variableStandardName = l.layer, this.time = this.pendingTime == null ? at(S.values, Date.now()) : V(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();
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();
4410
4424
  return;
4411
4425
  } catch (v) {
4412
4426
  const _ = v instanceof Error ? v : new Error(String(v));
4413
4427
  throw _.name !== "AbortError" && (this.emit("status", { phase: "error", error: _ }), this.emit("error", _)), _;
4414
4428
  }
4415
4429
  }
4416
- const p = this.getFieldSource(l.endpoints.field);
4430
+ const p = this.getFieldSource(c.endpoints.field);
4417
4431
  let h, g, x, T, M;
4418
4432
  this.emit("status", { phase: "metadata" });
4419
4433
  try {
4420
4434
  await p.init();
4421
- const v = fe(l);
4435
+ const v = fe(c);
4422
4436
  for (const _ of v)
4423
4437
  if (!p.hasVariable(_))
4424
4438
  throw new Error(
4425
4439
  `Configured variable not found in Zarr store: ${_}`
4426
4440
  );
4427
4441
  if (g = st(
4428
- l,
4442
+ c,
4429
4443
  p.getTimeDimension()
4430
4444
  ), g.values.length === 0)
4431
4445
  throw new Error("Zarr time coordinate is empty");
@@ -4436,9 +4450,9 @@ class Da {
4436
4450
  const _ = v instanceof Error ? v : new Error(String(v));
4437
4451
  throw this.emit("status", { phase: "error", error: _ }), this.emit("error", _), _;
4438
4452
  }
4439
- if (c !== this.switchGeneration)
4453
+ if (l !== this.switchGeneration)
4440
4454
  throw new DOMException("Layer selection was superseded", "AbortError");
4441
- this.detach(), this.catalogLayer = r, this.catalogSource = l, 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()) : V(this.timeMeta.values, this.pendingTime), this.pendingTime = null, this.depth = Le(T, d.depth);
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);
4442
4456
  const y = u.colorDomain;
4443
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();
4444
4458
  }
@@ -4465,7 +4479,7 @@ class Da {
4465
4479
  if (!a || !r || !this.isArchiveChunk(r))
4466
4480
  return !1;
4467
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;
4468
- if ((t.time == null && !i || Gt(r, this.sourceTimeRequest(e, t.time))) && !d)
4482
+ if ((t.time == null && !i || Ot(r, this.sourceTimeRequest(e, t.time))) && !d)
4469
4483
  return !1;
4470
4484
  const u = await this.selectSource(
4471
4485
  a,
@@ -4473,7 +4487,7 @@ class Da {
4473
4487
  e,
4474
4488
  t
4475
4489
  );
4476
- return !ei(u, r);
4490
+ return !ti(u, r);
4477
4491
  }
4478
4492
  applyVisible(e) {
4479
4493
  this.assertAlive(), this.visible !== e && (this.visible = e, e ? this.attachWhenReady() : this.detach());
@@ -4498,7 +4512,7 @@ class Da {
4498
4512
  applyTime(e) {
4499
4513
  this.assertAlive();
4500
4514
  const t = z(e, "time");
4501
- this.layer || (this.pendingTime = t), this.time = V(this.timeMeta?.values ?? [], t), this.layer?.setTime(this.time);
4515
+ this.layer || (this.pendingTime = t), this.time = U(this.timeMeta?.values ?? [], t), this.layer?.setTime(this.time);
4502
4516
  }
4503
4517
  /** Start GeoVideo playback; does nothing where playback is unavailable. */
4504
4518
  async play() {
@@ -4525,7 +4539,7 @@ class Da {
4525
4539
  const t = this.timeMeta?.values ?? [];
4526
4540
  if (!t.length)
4527
4541
  return;
4528
- const i = V(t, this.requestedTime ?? this.time);
4542
+ const i = U(t, this.requestedTime ?? this.time);
4529
4543
  return t[t.indexOf(i) + e];
4530
4544
  }
4531
4545
  pause() {
@@ -4546,10 +4560,10 @@ class Da {
4546
4560
  }
4547
4561
  /** Media rate for the loaded artifact: steps per second when set, else the raw multiplier. */
4548
4562
  effectivePlaybackRate() {
4549
- return this.stepsPerSecond != null && this.geoVideoManifest ? ti(this.geoVideoManifest, this.stepsPerSecond) : this.playbackRate;
4563
+ return this.stepsPerSecond != null && this.geoVideoManifest ? ii(this.geoVideoManifest, this.stepsPerSecond) : this.playbackRate;
4550
4564
  }
4551
4565
  playbackSpeeds() {
4552
- return this.catalogLayer?.kind === "vector" ? it : ra;
4566
+ return this.catalogLayer?.kind === "vector" ? it : na;
4553
4567
  }
4554
4568
  /**
4555
4569
  * Steps per second the active source shows. Vector GeoVideo stays inside
@@ -4563,23 +4577,23 @@ class Da {
4563
4577
  Math.max(e[0], this.stepsPerSecond ?? 1)
4564
4578
  );
4565
4579
  }
4566
- return this.stepsPerSecond != null ? this.stepsPerSecond : this.geoVideoManifest ? this.playbackRate * ii(this.geoVideoManifest) : this.playbackRate;
4580
+ return this.stepsPerSecond != null ? this.stepsPerSecond : this.geoVideoManifest ? this.playbackRate * ai(this.geoVideoManifest) : this.playbackRate;
4567
4581
  }
4568
4582
  /** Apply or clear a time window without rebuilding source metadata or the map layer. */
4569
4583
  applyTimeRange(e) {
4570
4584
  if (this.assertAlive(), !this.fullTimeMeta)
4571
4585
  throw new Error("Set a layer before changing its time range");
4572
- const t = e == null ? void 0 : { ...e }, i = re(this.fullTimeMeta, t), a = ne(this.fullTimeMeta, t), r = V(a.values, this.time);
4586
+ const t = e == null ? void 0 : { ...e }, i = re(this.fullTimeMeta, t), a = ne(this.fullTimeMeta, t), r = U(a.values, this.time);
4573
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();
4574
4588
  }
4575
4589
  applyDepth(e) {
4576
- this.assertAlive(), this.depth = V(this.verticalMeta?.values ?? [], e), this.layer?.setDepth(this.depth);
4590
+ this.assertAlive(), this.depth = U(this.verticalMeta?.values ?? [], e), this.layer?.setDepth(this.depth);
4577
4591
  }
4578
4592
  applyTimeAndDepth(e, t) {
4579
- this.assertAlive(), this.time = V(
4593
+ this.assertAlive(), this.time = U(
4580
4594
  this.timeMeta?.values ?? [],
4581
4595
  z(e, "time")
4582
- ), this.depth = V(this.verticalMeta?.values ?? [], t), this.layer?.setTimeAndDepth(this.time, this.depth);
4596
+ ), this.depth = U(this.verticalMeta?.values ?? [], t), this.layer?.setTimeAndDepth(this.time, this.depth);
4583
4597
  }
4584
4598
  on(e, t) {
4585
4599
  return this.assertAlive(), this.listeners.has(e) || this.listeners.set(e, /* @__PURE__ */ new Set()), this.listeners.get(e).add(t), this;
@@ -4597,7 +4611,7 @@ class Da {
4597
4611
  values: t.values,
4598
4612
  units: t.units,
4599
4613
  current: this.time,
4600
- granularity: na(t.values),
4614
+ granularity: oa(t.values),
4601
4615
  timelineKind: this.geoVideoManifest?.timeline.kind
4602
4616
  } : {
4603
4617
  min: NaN,
@@ -4613,7 +4627,7 @@ class Da {
4613
4627
  return { values: [], label: "depth", current: void 0 };
4614
4628
  const e = this.verticalMeta;
4615
4629
  return {
4616
- values: Ct(e.values),
4630
+ values: kt(e.values),
4617
4631
  name: e.name,
4618
4632
  label: e.label,
4619
4633
  units: e.units,
@@ -4634,7 +4648,7 @@ class Da {
4634
4648
  const i = this.catalogSource;
4635
4649
  return {
4636
4650
  type: "image",
4637
- url: Yi({
4651
+ url: Zi({
4638
4652
  baseUrl: i.baseUrl ?? this.wmtsMetadata?.baseUrl ?? new URL(i.capabilitiesUrl).origin,
4639
4653
  layer: i.layer,
4640
4654
  style: i.style
@@ -4648,7 +4662,7 @@ class Da {
4648
4662
  type: "gradient",
4649
4663
  palette: i,
4650
4664
  reverse: this.settings.reversePalette ?? !1,
4651
- alphaFade: Ve(this.settings),
4665
+ alphaFade: Ue(this.settings),
4652
4666
  min: a[0],
4653
4667
  max: a[1],
4654
4668
  unit: Ye(this.geoVideoManifest.style.unit)
@@ -4659,7 +4673,7 @@ class Da {
4659
4673
  type: "gradient",
4660
4674
  palette: e,
4661
4675
  reverse: this.settings.reversePalette ?? !1,
4662
- alphaFade: this.catalogLayer.kind === "scalar" ? Ve(this.settings) : void 0,
4676
+ alphaFade: this.catalogLayer.kind === "scalar" ? Ue(this.settings) : void 0,
4663
4677
  min: t?.[0] ?? this.lastMeta?.min,
4664
4678
  max: t?.[1] ?? this.lastMeta?.max,
4665
4679
  unit: Ye(this.lastMeta?.unit ?? this.variableUnit)
@@ -4738,7 +4752,7 @@ class Da {
4738
4752
  devicePixelRatio: typeof window < "u" ? window.devicePixelRatio : void 0,
4739
4753
  catalogEntry: this.catalogLayer ? {
4740
4754
  id: this.catalogLayer.id,
4741
- title: Ot(
4755
+ title: Bt(
4742
4756
  this.catalogLayer.title,
4743
4757
  this.catalog.defaultLocale,
4744
4758
  this.catalog.defaultLocale
@@ -4763,7 +4777,7 @@ class Da {
4763
4777
  * color domain of a GeoVideo archive included, as a load sets them.
4764
4778
  */
4765
4779
  styledSettings() {
4766
- const e = Ft(
4780
+ const e = It(
4767
4781
  this.catalogLayer ?? void 0,
4768
4782
  this.style
4769
4783
  ), t = this.catalogSource?.type === "geovideo" ? this.geoVideoManifest : null;
@@ -4774,7 +4788,7 @@ class Da {
4774
4788
  const t = e.colorDomain === void 0 ? e : {
4775
4789
  ...e,
4776
4790
  colorDomain: Q(e.colorDomain)
4777
- }, i = da.some(
4791
+ }, i = ma.some(
4778
4792
  (r) => t[r] != null && t[r] !== this.settings[r]
4779
4793
  ), a = t.particleState != null && t.particleState !== this.settings.particleState;
4780
4794
  if (t.colorDomain !== void 0 && (this.colorDomainOverridden = !0), t.palette !== void 0 && (this.paletteOverridden = !0), this.settings = { ...this.settings, ...t }, !!this.layer) {
@@ -4813,28 +4827,28 @@ class Da {
4813
4827
  stopAfterMissingSamples: 12
4814
4828
  });
4815
4829
  }
4816
- const c = this.timeRange ? Math.max(
4830
+ const l = this.timeRange ? Math.max(
4817
4831
  o.min,
4818
4832
  this.resolvedTimeRange?.[0] ?? this.timeMeta?.min ?? o.min
4819
4833
  ) : o.min, d = this.timeRange ? Math.min(
4820
4834
  o.max,
4821
4835
  this.resolvedTimeRange?.[1] ?? this.timeMeta?.max ?? o.max
4822
- ) : o.max, l = n.findIndex((m) => m >= c);
4836
+ ) : o.max, c = n.findIndex((m) => m >= l);
4823
4837
  let u = n.length - 1;
4824
4838
  for (; u >= 0 && n[u] > d; )
4825
4839
  u--;
4826
- if (l < 0 || u < l)
4840
+ if (c < 0 || u < c)
4827
4841
  throw new Error("Time range does not overlap the point-series store");
4828
4842
  const f = Math.max(
4829
4843
  1,
4830
- Math.ceil((u - l + 1) / a)
4844
+ Math.ceil((u - c + 1) / a)
4831
4845
  );
4832
4846
  return r.sampleTimeSeries({
4833
4847
  variables: fe(i),
4834
4848
  longitude: e.longitude,
4835
4849
  latitude: e.latitude,
4836
4850
  depth: e.depth ?? this.depth,
4837
- timeStartIndex: l,
4851
+ timeStartIndex: c,
4838
4852
  timeEndIndex: u,
4839
4853
  stride: f,
4840
4854
  stopAfterMissingSamples: 12
@@ -4872,7 +4886,7 @@ class Da {
4872
4886
  );
4873
4887
  return;
4874
4888
  }
4875
- const e = new ea({
4889
+ const e = new ta({
4876
4890
  id: this.id,
4877
4891
  entry: this.catalogLayer,
4878
4892
  sourceConfig: this.catalogSource,
@@ -4905,7 +4919,7 @@ class Da {
4905
4919
  this.pendingTime = null, this.autoplayPending = !1, e.on("loading", () => this.emit("loading")), e.on("loaded", (t) => {
4906
4920
  this.lastMeta = t, this.emit("loaded", t);
4907
4921
  }), 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) => {
4908
- e === this.layer && (this.time = V(this.timeMeta?.values ?? [], t), this.playing && (this.requestedTime = null), this.emit("timeChange", this.time));
4922
+ e === this.layer && (this.time = U(this.timeMeta?.values ?? [], t), this.playing && (this.requestedTime = null), this.emit("timeChange", this.time));
4909
4923
  }), e.on("playbackChange", (t) => {
4910
4924
  e === this.layer && (t && this.preloadNextArchiveChunk(e), t !== this.playing && (this.playing = t, this.emit("playbackChange", t)));
4911
4925
  }), e.on("playbackEnd", () => {
@@ -4976,7 +4990,7 @@ class Da {
4976
4990
  async selectSource(e, t, i, a = {}) {
4977
4991
  const r = this.sourceTimeRequest(i, a.time), n = Ee(e, t);
4978
4992
  if (n) {
4979
- 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, l = await this.resolveArchives(e, d), u = l.sources.filter(
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(
4980
4994
  (m) => m.id === n.id
4981
4995
  );
4982
4996
  if (u.length) {
@@ -4986,7 +5000,7 @@ class Da {
4986
5000
  i,
4987
5001
  a.time,
4988
5002
  d
4989
- ), p = ai(u, { time: m });
5003
+ ), p = si(u, { time: m });
4990
5004
  if (p && !this.isFailedGeoVideo(p))
4991
5005
  return p;
4992
5006
  if (t !== "auto" || this.catalogSource?.id === n.id)
@@ -4999,12 +5013,12 @@ class Da {
4999
5013
  if (t !== "auto")
5000
5014
  throw new Error(`GeoVideo archive unavailable: ${n.id}`);
5001
5015
  }
5002
- const f = he(l, ["zarr"], r);
5016
+ const f = he(c, ["zarr"], r);
5003
5017
  if (f)
5004
5018
  return f;
5005
5019
  e = {
5006
- ...l,
5007
- sources: l.sources.filter(
5020
+ ...c,
5021
+ sources: c.sources.filter(
5008
5022
  (m) => m.type !== "geovideo"
5009
5023
  )
5010
5024
  };
@@ -5039,7 +5053,7 @@ class Da {
5039
5053
  if (!e || !t || !this.isArchiveChunk(t))
5040
5054
  return null;
5041
5055
  const i = this.archiveLevel;
5042
- return si(
5056
+ return ri(
5043
5057
  (await this.resolveArchives(e, i)).sources,
5044
5058
  t,
5045
5059
  {
@@ -5120,8 +5134,8 @@ class Da {
5120
5134
  const o = r.slice(n, n + lt);
5121
5135
  (await Promise.allSettled(
5122
5136
  o.map((d) => this.loadChunkManifest(d))
5123
- )).forEach((d, l) => {
5124
- d.status === "fulfilled" ? this.chunkTimes.set(o[l], we(d.value)) : console.warn(
5137
+ )).forEach((d, c) => {
5138
+ d.status === "fulfilled" ? this.chunkTimes.set(o[c], we(d.value)) : console.warn(
5125
5139
  "[zartigl] GeoVideo chunk samples unavailable:",
5126
5140
  d.reason
5127
5141
  );
@@ -5138,13 +5152,13 @@ class Da {
5138
5152
  * and the time shown in agreement.
5139
5153
  */
5140
5154
  async archiveSample(e, t, i, a, r = null) {
5141
- const n = await this.archiveTimes(e, t, r), [o, c] = i && n.length ? xt(i, [n[0], n[n.length - 1]]) : [-1 / 0, 1 / 0], d = n.filter((u) => u >= o && u <= c);
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);
5142
5156
  if (d.length === 0)
5143
5157
  throw new RangeError(
5144
5158
  "Time range does not contain any available timestamps"
5145
5159
  );
5146
- const l = this.sourceTimeRequest(void 0, a).time;
5147
- return l == null ? d[d.length - 1] : V(d, l);
5160
+ const c = this.sourceTimeRequest(void 0, a).time;
5161
+ return c == null ? d[d.length - 1] : U(d, c);
5148
5162
  }
5149
5163
  /**
5150
5164
  * Entry whose archive sources are replaced by one fixed-period source per
@@ -5169,7 +5183,7 @@ class Da {
5169
5183
  return n ? this.archiveChunksAt(
5170
5184
  e,
5171
5185
  a,
5172
- ri(n, a.indexUrl),
5186
+ ni(n, a.indexUrl),
5173
5187
  n
5174
5188
  ) : [];
5175
5189
  })
@@ -5190,28 +5204,28 @@ class Da {
5190
5204
  if (r && r.expires > Date.now())
5191
5205
  return r.chunks;
5192
5206
  const n = {
5193
- expires: Date.now() + ca,
5194
- chunks: ni(i).then((o) => {
5207
+ expires: Date.now() + ha,
5208
+ chunks: oi(i).then((o) => {
5195
5209
  if (a ? !He(o.vertical, a) : o.vertical !== void 0)
5196
5210
  throw new Error(`GeoVideo index level does not match: ${i}`);
5197
5211
  !a && !this.archiveRoots.has(t.indexUrl) && this.archiveRoots.set(t.indexUrl, {
5198
5212
  surface: o.surface,
5199
5213
  depths: o.depths ?? []
5200
5214
  });
5201
- const c = oi(
5215
+ const l = li(
5202
5216
  { ...t, indexUrl: i },
5203
5217
  o,
5204
5218
  e
5205
5219
  );
5206
- for (const d of li(o, i))
5220
+ for (const d of ci(o, i))
5207
5221
  this.chunkLevels.set(d.manifestUrl, a), d.times && this.chunkTimes.set(d.manifestUrl, d.times);
5208
- return c;
5209
- }).catch((o) => (console.warn("[zartigl] GeoVideo archive unavailable:", o), n.expires = Date.now() + ha, []))
5222
+ return l;
5223
+ }).catch((o) => (console.warn("[zartigl] GeoVideo archive unavailable:", o), n.expires = Date.now() + ua, []))
5210
5224
  };
5211
5225
  return this.archiveChunks.set(i, n), n.chunks;
5212
5226
  }
5213
5227
  resolveSource(e, t, i) {
5214
- const a = t === "auto" ? Bt(e, i) : e.sources.find((r) => r.id === t) ?? he(
5228
+ const a = t === "auto" ? $t(e, i) : e.sources.find((r) => r.id === t) ?? he(
5215
5229
  e,
5216
5230
  [t],
5217
5231
  i
@@ -5272,33 +5286,33 @@ class Da {
5272
5286
  a(...t);
5273
5287
  }
5274
5288
  }
5275
- function pa(s, e) {
5289
+ function ga(s, e) {
5276
5290
  const t = new Date(s).toISOString();
5277
5291
  return e === "year" ? t.slice(0, 4) : e === "month" ? t.slice(0, 7) : e === "day" ? t.slice(0, 10) : "";
5278
5292
  }
5279
- function ga(s, e) {
5293
+ function va(s, e) {
5280
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();
5281
5295
  }
5282
- function Aa(s, e, t) {
5296
+ function Ca(s, e, t) {
5283
5297
  if (!e || s.length === 0)
5284
5298
  return;
5285
5299
  if (["year", "month", "day"].includes(t)) {
5286
5300
  const a = s.find(
5287
- (r) => pa(r, t) === e
5301
+ (r) => ga(r, t) === e
5288
5302
  );
5289
5303
  if (a !== void 0)
5290
5304
  return a;
5291
5305
  }
5292
- const i = ga(e, t);
5306
+ const i = va(e, t);
5293
5307
  if (Number.isFinite(i))
5294
5308
  return s.reduce(
5295
5309
  (a, r) => Math.abs(r - i) < Math.abs(a - i) ? r : a
5296
5310
  );
5297
5311
  }
5298
- const It = gt.devDependencies["maplibre-gl"].replace(
5312
+ const Vt = gt.devDependencies["maplibre-gl"].replace(
5299
5313
  /^[^\d]*/,
5300
5314
  ""
5301
- ), va = `https://cdn.jsdelivr.net/npm/maplibre-gl@${It}/+esm`, ya = `https://cdn.jsdelivr.net/npm/maplibre-gl@${It}/dist/maplibre-gl.css`, _a = `{
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 = `{
5302
5316
  version: 8,
5303
5317
  sources: {
5304
5318
  "eox-cloudless": {
@@ -5322,7 +5336,7 @@ const It = gt.devDependencies["maplibre-gl"].replace(
5322
5336
  function q(s) {
5323
5337
  return JSON.stringify(s);
5324
5338
  }
5325
- function xa(s) {
5339
+ function ba(s) {
5326
5340
  return JSON.stringify(s, null, 2);
5327
5341
  }
5328
5342
  function Ut(s) {
@@ -5333,25 +5347,25 @@ function ie(s, e = 6) {
5333
5347
  }
5334
5348
  function $(s, e) {
5335
5349
  const t = " ".repeat(e);
5336
- return xa(s).split(`
5350
+ return ba(s).split(`
5337
5351
  `).map((i) => `${t}${i}`).join(`
5338
5352
  `).trimStart();
5339
5353
  }
5340
- function ba(s, e) {
5354
+ function Sa(s, e) {
5341
5355
  const t = " ".repeat(e);
5342
5356
  return s.split(`
5343
5357
  `).map((i) => i.length > 0 ? `${t}${i}` : i).join(`
5344
5358
  `);
5345
5359
  }
5346
- const Sa = (s) => {
5360
+ const wa = (s) => {
5347
5361
  const e = s.source ?? "auto";
5348
5362
  return s.sourceType ?? (e === "wmts" || e === "geovideo" ? e : "zarr");
5349
5363
  };
5350
- function Vt(s) {
5351
- const { layerKind: e, layerDefaults: t } = s, i = pt(s.style ?? {}, e), a = t === void 0 ? i : $t(i, ze({ kind: e, defaults: t })), r = a.raster?.opacity, n = Sa(s) !== "wmts" ? a : r === void 0 ? {} : { raster: { opacity: r } };
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 } };
5352
5366
  return Object.keys(n).length ? n : void 0;
5353
5367
  }
5354
- function Nt(s) {
5368
+ function zt(s) {
5355
5369
  const { particleState: e, rgba8MaxParticleZoom: t } = s.settings ?? {}, i = Object.fromEntries(
5356
5370
  Object.entries({ particleState: e, rgba8MaxParticleZoom: t }).filter(
5357
5371
  ([, a]) => a !== void 0
@@ -5359,8 +5373,8 @@ function Nt(s) {
5359
5373
  );
5360
5374
  return s.layerKind === "vector" && Object.keys(i).length ? i : void 0;
5361
5375
  }
5362
- function Ca(s) {
5363
- const e = s.source ?? "auto", t = Vt(s), i = Nt(s), a = [
5376
+ function ka(s) {
5377
+ const e = s.source ?? "auto", t = Nt(s), i = zt(s), a = [
5364
5378
  " idView: widget.opt.view.id,",
5365
5379
  " map: widget.opt.map,",
5366
5380
  ` layer: ${q(s.layerId)},`,
@@ -5407,14 +5421,14 @@ ${a.join(`
5407
5421
  };
5408
5422
  }`;
5409
5423
  }
5410
- function wa(s) {
5411
- const e = s.moduleBaseUrl ?? `https://cdn.jsdelivr.net/npm/@fxi/zartigl@${gt.version}/dist`, t = s.source ?? "auto", i = Vt(s), a = Nt(s), r = s.timeRange == null ? "" : ` timeRange: ${$(s.timeRange, 2)},
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)},
5412
5426
  `, n = s.geoVideo == null ? "" : ` geoVideo: ${$(s.geoVideo, 2)},
5413
5427
  `, o = i == null ? "" : ` style: ${$(i, 2)},
5414
- `, c = a == null ? "" : ` settings: ${$(a, 2)},
5428
+ `, l = a == null ? "" : ` settings: ${$(a, 2)},
5415
5429
  `, d = s.time == null ? "" : ` time: ${Ut(s.time)},
5416
- `, l = s.depth == null ? "" : ` depth: ${s.depth},
5417
- `, u = s.center ?? [0, 20], f = s.projection ?? "mercator", m = s.mapStyle == null ? _a : q(s.mapStyle), p = `map.setProjection({ type: ${q(f)} });
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)} });
5418
5432
  map.jumpTo({
5419
5433
  center: [${ie(u[0])}, ${ie(u[1])}],
5420
5434
  zoom: ${ie(s.zoom ?? 2, 3)},
@@ -5443,10 +5457,10 @@ const z = new Zartigl({
5443
5457
  catalog,
5444
5458
  layer: ${q(s.layerId)},
5445
5459
  source: ${q(t)},
5446
- ${r}${n}${o}${c}${d}${l}});
5460
+ ${r}${n}${o}${l}${d}${c}});
5447
5461
 
5448
5462
  await z.init();`;
5449
- return `import maplibregl from ${q(va)};
5463
+ return `import maplibregl from ${q(ya)};
5450
5464
  import { Zartigl } from "${e}/zartigl.js";
5451
5465
  import { catalog } from "${e}/catalog.js";
5452
5466
 
@@ -5458,18 +5472,18 @@ const map = new maplibregl.Map({
5458
5472
  });
5459
5473
 
5460
5474
  map.once("style.load", async () => {
5461
- ${ba(p, 2)}
5475
+ ${Sa(p, 2)}
5462
5476
  });`;
5463
5477
  }
5464
- function ka(s) {
5465
- const e = wa(s);
5478
+ function Fa(s) {
5479
+ const e = Ta(s);
5466
5480
  return `<!doctype html>
5467
5481
  <html lang="en">
5468
5482
  <head>
5469
5483
  <meta charset="UTF-8" />
5470
5484
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
5471
5485
  <title>Zartigl demo</title>
5472
- <link rel="stylesheet" href=${q(ya)} />
5486
+ <link rel="stylesheet" href=${q(_a)} />
5473
5487
  <style>
5474
5488
  html, body, #map {
5475
5489
  width: 100%;
@@ -5491,41 +5505,41 @@ ${e}
5491
5505
  </html>`;
5492
5506
  }
5493
5507
  export {
5494
- ci as BACKDROP_OFF,
5495
- hi as COLOR_GRADE_OFF,
5496
- za as COLOR_GRADE_VIBRANT,
5497
- ra as GEOVIDEO_SPEEDS,
5508
+ hi as BACKDROP_OFF,
5509
+ ui as COLOR_GRADE_OFF,
5510
+ Ga as COLOR_GRADE_VIBRANT,
5511
+ na as GEOVIDEO_SPEEDS,
5498
5512
  G as GeoVideoLayer,
5499
- kt as LEGACY_STYLE_SETTINGS,
5500
- Mt as ParticleSimulation,
5513
+ Ft as LEGACY_STYLE_SETTINGS,
5514
+ Rt as ParticleSimulation,
5501
5515
  me as ScalarLayer,
5502
5516
  it as VECTOR_GEOVIDEO_SPEEDS,
5503
- D as VectorLayer,
5504
- Rt as VelocityField,
5517
+ P as VectorLayer,
5518
+ Pt as VelocityField,
5505
5519
  _e as ZarrSource,
5506
- Da as Zartigl,
5520
+ Aa as Zartigl,
5507
5521
  xe as ZartiglFrameUnavailableError,
5508
- Ca as buildMapxWidgetSnippet,
5509
- ka as buildStandaloneDemoHtml,
5510
- wa as buildStandaloneDemoSnippet,
5511
- Yi as buildWmtsLegendUrl,
5522
+ ka as buildMapxWidgetSnippet,
5523
+ Fa as buildStandaloneDemoHtml,
5524
+ Ta as buildStandaloneDemoSnippet,
5525
+ Zi as buildWmtsLegendUrl,
5512
5526
  Je as buildWmtsTileUrl,
5513
- mi as colorGradeToGrade,
5514
- qi as deriveDirectionMagnitudeComponents,
5527
+ fi as colorGradeToGrade,
5528
+ Wi as deriveDirectionMagnitudeComponents,
5515
5529
  Ye as formatUnit,
5516
- Jt as geoVideoSecondsForTime,
5530
+ ei as geoVideoSecondsForTime,
5517
5531
  Ua as geoVideoTimeForSeconds,
5518
5532
  we as geoVideoTimelineValues,
5519
5533
  _t as getPalettes,
5520
- La as getVectorDerivationVariables,
5521
- fi as gradeToColorGrade,
5522
- Ga as isHexColor,
5534
+ Da as getVectorDerivationVariables,
5535
+ pi as gradeToColorGrade,
5536
+ Oa as isHexColor,
5523
5537
  Ce as loadGeoVideoManifest,
5524
5538
  St as resolveBackdrop,
5525
5539
  bt as resolveColorGrade,
5526
5540
  ke as resolveColorRamp,
5527
- Aa as resolveTimeInputSelection,
5541
+ Ca as resolveTimeInputSelection,
5528
5542
  Ae as splitLegacySettings,
5529
- Pt as stitchVelocityChunks,
5530
- Va as validateGeoVideoManifest
5543
+ Et as stitchVelocityChunks,
5544
+ Na as validateGeoVideoManifest
5531
5545
  };