@fxi/zartigl 0.13.1 → 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,53 +1,68 @@
1
- import { m as ae, p as mt, s as ft, a as $e, b as Nt, r as Ne, c as zt, d as he, e as Gt, f as pt, g as Ot } from "./index-DsKvU_FK.js";
2
- import { T as Bt, g as $t, r as qt, d as Wt, c as W, a as Xt, b as ge, e as Ht, f as J, h as be, i as O, G as Yt, j as qe, v as Q, k as K, s as ze, l as Ge, m as gt, n as We, o as Ae, p as Zt, q as Ce, t as jt, u as vt, w as z, x as Xe, y as Se, z as Qt, A as Kt, B as Jt, C as He, D as ei, E as ke, F as ti, H as yt, I as ii, J as ai, K as si, L as ri } from "./engine-Bhb-WayM.js";
3
- import { M as ka, N as Fa } from "./engine-Bhb-WayM.js";
4
- import { B as ni, a as oi, b as li, c as ci, d as _t, r as xt, e as hi, g as ui } from "./backdrop-Dceb4d8E.js";
5
- import { f as Ua, i as Va } from "./backdrop-Dceb4d8E.js";
6
- import { inflate as di } from "pako";
7
- import mi from "numcodecs/blosc";
8
- const Fe = 85, fi = 89.9;
9
- function Ie(s) {
10
- return Math.max(-Fe, Math.min(Fe, s));
11
- }
12
- function Ye(s) {
13
- const e = Ie(s), t = Math.sin(e * Math.PI / 180);
1
+ import { m as ae, p as ft, s as pt, a as qe, b as Ot, r as ze, c as Bt, d as he, e as $t, f as gt, g as qt } from "./index-BDIf6Jc0.js";
2
+ import { T as Wt, g as Xt, r as Ht, d as Yt, c as W, a as Zt, b as ge, e as jt, f as J, h as Se, i as O, G as Qt, j as We, F as Kt, s as vt, v as Q, k as K, l as Ge, m as Oe, n as yt, o as Xe, p as Ce, q as Jt, t as ke, u as ei, w as _t, x as z, y as He, z as we, A as ti, B as ii, C as ai, D as Ye, E as si, H as Fe, I as ri, J as xt, K as ni, L as oi, M as li, N as ci } from "./engine-C8ZNzILO.js";
3
+ import { O as Ua, P as Na } from "./engine-C8ZNzILO.js";
4
+ import { B as hi, a as ui, b as di, c as mi, d as bt, r as St, e as fi, g as pi } from "./backdrop-Dceb4d8E.js";
5
+ import { f as Ga, i as Oa } from "./backdrop-Dceb4d8E.js";
6
+ import { inflate as gi } from "pako";
7
+ import vi from "numcodecs/blosc";
8
+ const Ie = 85, yi = 89.9;
9
+ function Ve(s) {
10
+ return Math.max(-Ie, Math.min(Ie, s));
11
+ }
12
+ function Ze(s) {
13
+ const e = Ve(s), t = Math.sin(e * Math.PI / 180);
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 pi(s) {
19
+ function _i(s) {
20
20
  return ((s + 180) % 360 + 360) % 360 - 180;
21
21
  }
22
- function gi(s, e) {
23
- const t = pi(s) * Math.PI / 180, i = e * Math.PI / 180, a = Math.cos(i);
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
+ }
31
+ function ye(s, e) {
32
+ if (s.getProjection?.()?.type !== "globe")
33
+ return !1;
34
+ const t = e?.projectionTransition;
35
+ return typeof t == "number" ? t > 0 : !0;
36
+ }
37
+ function xi(s, e) {
38
+ const t = _i(s) * Math.PI / 180, i = e * Math.PI / 180, a = Math.cos(i);
24
39
  return [
25
40
  Math.sin(t) * a,
26
41
  Math.sin(i),
27
42
  Math.cos(t) * a
28
43
  ];
29
44
  }
30
- function vi(s) {
45
+ function bi(s) {
31
46
  return {
32
47
  west: -180,
33
48
  east: 180,
34
- south: Ie(s.getSouth()),
35
- north: Ie(s.getNorth())
49
+ south: Ve(s.getSouth()),
50
+ north: Ve(s.getNorth())
36
51
  };
37
52
  }
38
- function yi(s, e = 1, t = !1) {
39
- const i = t ? fi : Fe, a = (u) => Math.max(-i, Math.min(i, u)), 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);
40
55
  return {
41
56
  west: -180,
42
57
  east: 180,
43
- south: a(r - c),
44
- north: a(n + c)
58
+ south: a(r - l),
59
+ north: a(n + l)
45
60
  };
46
61
  }
47
- function _i(s, e, t = 1e-6) {
62
+ function wi(s, e, t = 1e-6) {
48
63
  return s.south <= e.south + t && s.north >= e.north - t;
49
64
  }
50
- function xi(s, e = !1) {
65
+ function Ti(s, e = !1) {
51
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 };
52
67
  return e ? {
53
68
  ...o,
@@ -55,11 +70,11 @@ function xi(s, e = !1) {
55
70
  maxY: (Math.min(s.getNorth(), 90) + 90) / 180
56
71
  } : {
57
72
  ...o,
58
- minY: Ye(s.getNorth()),
59
- maxY: Ye(s.getSouth())
73
+ minY: Ze(s.getNorth()),
74
+ maxY: Ze(s.getSouth())
60
75
  };
61
76
  }
62
- function Oe(s, e) {
77
+ function Be(s, e) {
63
78
  if (e)
64
79
  return [0];
65
80
  const t = ve(s.getWest()), i = ve(s.getEast()), a = [];
@@ -77,7 +92,7 @@ const ue = [
77
92
  "u_velocity_flip_y",
78
93
  "u_velocity_next_flip_y"
79
94
  ];
80
- function we(s, e, t) {
95
+ function Te(s, e, t) {
81
96
  s.uniform1i(e.u_velocity_next, t.b.unit), s.uniform2f(e.u_velocity_next_min, ...t.b.min), s.uniform2f(e.u_velocity_next_max, ...t.b.max), s.uniform1f(e.u_velocity_mix, t.mix), s.uniform1f(e.u_velocity_physical, t.a.physical ? 1 : 0), s.uniform1f(e.u_velocity_next_physical, t.b.physical ? 1 : 0), s.uniform1f(e.u_velocity_flip_y, t.a.northToSouth ? 1 : 0), s.uniform1f(e.u_velocity_next_flip_y, t.b.northToSouth ? 1 : 0);
82
97
  }
83
98
  var de = `#version 300 es
@@ -89,7 +104,7 @@ out vec2 v_tex_coord;
89
104
  void main() {
90
105
  v_tex_coord = a_position * 0.5 + 0.5;
91
106
  gl_Position = vec4(a_position, 0.0, 1.0);
92
- }`, bi = `#version 300 es
107
+ }`, Mi = `#version 300 es
93
108
  precision highp float;
94
109
 
95
110
  uint pcg(uint v) {
@@ -359,7 +374,7 @@ void main() {
359
374
  fract(newPos.y * 255.0)
360
375
  );
361
376
  #endif
362
- }`, Si = `precision highp float;
377
+ }`, Ri = `precision highp float;
363
378
 
364
379
  attribute float a_index;
365
380
  attribute float a_is_curr;
@@ -591,7 +606,7 @@ void main() {
591
606
  vec2 worldPos = vec2((pos.x + u_world_offset) * u_world_size, pos.y * u_world_size);
592
607
  gl_Position = u_matrix * vec4(worldPos, 0.0, 1.0);
593
608
  }
594
- }`, wi = `precision mediump float;
609
+ }`, Pi = `precision mediump float;
595
610
 
596
611
  uniform sampler2D u_color_ramp;
597
612
  uniform float u_particle_contrast;
@@ -630,7 +645,7 @@ void main() {
630
645
  }
631
646
 
632
647
  gl_FragColor = vec4(color.rgb, color.a * u_opacity);
633
- }`, Ti = `#version 300 es
648
+ }`, Ei = `#version 300 es
634
649
  precision mediump float;
635
650
 
636
651
  uniform sampler2D u_screen;
@@ -647,7 +662,7 @@ void main() {
647
662
  float alpha = floor(color.a * 255.0 * u_opacity) / 255.0;
648
663
 
649
664
  o_color = vec4(color.rgb * step(1.0 / 255.0, alpha), alpha);
650
- }`, Mi = `#version 300 es
665
+ }`, Li = `#version 300 es
651
666
  precision mediump float;
652
667
 
653
668
  uniform sampler2D u_screen;
@@ -718,7 +733,7 @@ void main() {
718
733
  }
719
734
  vec3 rgb = u_grade_on > 0.5 ? gradeColor(color.rgb, u_grade) : color.rgb;
720
735
  o_color = vec4(rgb, color.a);
721
- }`, Ri = `#version 300 es
736
+ }`, Di = `#version 300 es
722
737
  precision mediump float;
723
738
 
724
739
  uniform sampler2D u_screen;
@@ -755,7 +770,7 @@ vec4 addGlow(vec4 trail, sampler2D glowTex, vec2 uv, float gain) {
755
770
 
756
771
  void main() {
757
772
  o_color = glowGather(u_screen, ivec2(gl_FragCoord.xy));
758
- }`, bt = `precision highp float;
773
+ }`, Tt = `precision highp float;
759
774
 
760
775
  attribute vec2 a_grid_uv;
761
776
 
@@ -779,14 +794,17 @@ float latToMercY(float lat) {
779
794
  }
780
795
 
781
796
  void main() {
782
- 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);
783
801
  float lat = mix(u_geo_bounds.y, u_geo_bounds.w, a_grid_uv.y);
784
802
  vec2 merc = vec2(lngToMercX(lng) + u_world_offset, latToMercY(lat));
785
803
  vec2 worldPos = merc * u_world_size;
786
804
 
787
- v_geo_uv = a_grid_uv;
805
+ v_geo_uv = vec2((lng - u_geo_bounds.x) / width, a_grid_uv.y);
788
806
  gl_Position = u_matrix * vec4(worldPos, 0.0, 1.0);
789
- }`, Pi = `precision mediump float;
807
+ }`, Ai = `precision mediump float;
790
808
 
791
809
  uniform sampler2D u_field;
792
810
  uniform sampler2D u_color_ramp;
@@ -849,7 +867,8 @@ vec3 sampleVelocityPair(sampler2D field, vec2 uv, vec2 minimum, vec2 maximum) {
849
867
  }
850
868
 
851
869
  void main() {
852
- 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) {
853
872
  discard;
854
873
  }
855
874
 
@@ -885,7 +904,7 @@ void main() {
885
904
  vec4 color = texture2D(u_color_ramp, vec2(t, 0.5));
886
905
  color.rgb = applyVibrance(color.rgb, u_vibrance);
887
906
  gl_FragColor = vec4(color.rgb, color.a * u_opacity);
888
- }`, St = `precision highp float;
907
+ }`, Mt = `precision highp float;
889
908
 
890
909
  attribute vec2 a_grid_uv;
891
910
 
@@ -893,11 +912,23 @@ uniform mat4 u_matrix;
893
912
  uniform vec4 u_geo_bounds;
894
913
  uniform vec4 u_clipping_plane;
895
914
 
915
+ uniform float u_projection_transition;
916
+ uniform mat4 u_fallback_matrix;
917
+
896
918
  varying vec2 v_geo_uv;
897
919
 
920
+ const float PI = 3.14159265358979323846;
921
+
898
922
  void main() {
899
- float lng = mix(u_geo_bounds.x, u_geo_bounds.z, a_grid_uv.x);
900
- 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);
901
932
  float lngRad = radians(lng);
902
933
  float latRad = radians(lat);
903
934
  float cosLat = cos(latRad);
@@ -907,11 +938,23 @@ void main() {
907
938
  cos(lngRad) * cosLat
908
939
  );
909
940
 
910
- v_geo_uv = a_grid_uv;
941
+ v_geo_uv = vec2((lng - u_geo_bounds.x) / width, a_grid_uv.y);
911
942
  vec4 position = u_matrix * vec4(ecef, 1.0);
912
943
  position.z = (1.0 - (dot(ecef, u_clipping_plane.xyz) + u_clipping_plane.w)) * position.w;
944
+ if (u_projection_transition < 0.999) {
945
+
946
+ float sinLat = sin(radians(clamp(lat, -85.0, 85.0)));
947
+ vec2 merc = vec2(
948
+ (lng + 180.0) / 360.0,
949
+ 0.5 - log((1.0 + sinLat) / (1.0 - sinLat)) / (4.0 * PI)
950
+ );
951
+ vec4 flatPosition = u_fallback_matrix * vec4(merc, 0.0, 1.0);
952
+ float globeness = clamp((u_projection_transition - 0.2) / 0.8, 0.0, 1.0);
953
+ position.z = mix(0.0, position.z, globeness);
954
+ position.xyw = mix(flatPosition.xyw, position.xyw, u_projection_transition);
955
+ }
913
956
  gl_Position = position;
914
- }`, Ei = `precision mediump float;
957
+ }`, Ci = `precision mediump float;
915
958
 
916
959
  uniform sampler2D u_field;
917
960
  uniform sampler2D u_color_ramp;
@@ -1001,8 +1044,8 @@ void main() {
1001
1044
  color.rgb = applyVibrance(color.rgb, u_vibrance);
1002
1045
  gl_FragColor = vec4(color.rgb, color.a * u_opacity);
1003
1046
  }`;
1004
- const Te = [0, 0, 0, 0], B = 512, H = B * B, Y = 128, ee = 64, Li = 1, Di = 0.92, Ai = 0.1, Ze = 0.98;
1005
- function Ci(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) {
1006
1049
  if (Number.isNaN(s))
1007
1050
  return 32256;
1008
1051
  if (s === 1 / 0)
@@ -1019,7 +1062,7 @@ function Ci(s) {
1019
1062
  const i = Math.floor(Math.log2(t)), a = t / 2 ** i - 1;
1020
1063
  return e | i + 15 << 10 | Math.round(a * 1024);
1021
1064
  }
1022
- const ki = {
1065
+ const Ui = {
1023
1066
  particleDensity: 0.05,
1024
1067
  speed: 1,
1025
1068
  fadeOpacity: 0.996,
@@ -1028,26 +1071,26 @@ const ki = {
1028
1071
  opacity: 1,
1029
1072
  logScale: !1,
1030
1073
  vibrance: 0,
1031
- colorGrade: oi,
1032
- backdrop: ni,
1074
+ colorGrade: ui,
1075
+ backdrop: hi,
1033
1076
  glow: 0,
1034
1077
  scalarMode: !1,
1035
1078
  particleState: "auto",
1036
1079
  rgba8MaxParticleZoom: 4
1037
1080
  };
1038
- class wt {
1081
+ class Rt {
1039
1082
  constructor(e) {
1040
- this.numParticles = 0, this.prevBounds = null, this.redistributionBoost = 0, this.frame = Math.floor(Math.random() * 2 ** 30), this.webglInfo = null, this.lastRgba8ParticlesSuppressed = !1, this.screenWidth = 0, this.screenHeight = 0, this.glowTexture = null, this.glowFramebuffer = null, this.rasterGridIndexCount = 0, this.renderMode = "raster+particles", this.params = { ...ki, ...e }, this.trailFade = new Bt(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);
1041
1084
  }
1042
1085
  init(e) {
1043
- this.gl = e, this.webglInfo = $t(e), this.stateFormat = this.params.particleState === "rgba8" ? qt(e) : Wt(e);
1086
+ this.gl = e, this.webglInfo = Xt(e), this.stateFormat = this.params.particleState === "rgba8" ? Ht(e) : Yt(e);
1044
1087
  const t = this.stateFormat.kind !== "rgba8-packed" ? `#define USE_FLOAT_STATE 1
1045
1088
  ` : "";
1046
1089
  this.updateProgram = W(
1047
1090
  e,
1048
1091
  de,
1049
- bi.replace(/^(#version[^\n]*\n)/, `$1${t}`)
1050
- ), this.drawProgram = W(e, t + Si, wi), this.fadeProgram = W(e, de, Ti), this.compositeProgram = W(e, de, Mi), this.glowProgram = W(e, de, Ri), this.gridProgram = W(e, bt, Pi), this.gridGlobeProgram = W(e, St, Ei), 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, [
1051
1094
  "u_particles",
1052
1095
  ...ue,
1053
1096
  "u_velocity",
@@ -1118,6 +1161,8 @@ class wt {
1118
1161
  "u_matrix",
1119
1162
  "u_geo_bounds",
1120
1163
  "u_clipping_plane",
1164
+ "u_projection_transition",
1165
+ "u_fallback_matrix",
1121
1166
  "u_field_min",
1122
1167
  "u_field_max",
1123
1168
  "u_u_min",
@@ -1129,7 +1174,7 @@ class wt {
1129
1174
  "u_vibrance",
1130
1175
  "u_scalar_mode",
1131
1176
  "u_solid"
1132
- ]), this.quadBuffer = Xt(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();
1133
1178
  }
1134
1179
  getUniforms(e, t) {
1135
1180
  const i = {};
@@ -1149,7 +1194,7 @@ class wt {
1149
1194
  if (this.stateFormat?.kind === "float16") {
1150
1195
  const a = new Uint16Array(t);
1151
1196
  for (let r = 0; r < t; r++)
1152
- a[r] = Ci(Math.random());
1197
+ a[r] = Vi(Math.random());
1153
1198
  return a;
1154
1199
  }
1155
1200
  const i = new Uint8Array(t);
@@ -1158,7 +1203,7 @@ class wt {
1158
1203
  return i;
1159
1204
  }
1160
1205
  createStateTexture(e) {
1161
- return Ht(
1206
+ return jt(
1162
1207
  this.gl,
1163
1208
  this.gl.NEAREST,
1164
1209
  e,
@@ -1171,10 +1216,10 @@ class wt {
1171
1216
  initParticleState() {
1172
1217
  const e = this.gl, t = this.makeStateData(), i = this.createStateTexture(t), a = this.createStateTexture(t), r = J(e, i), n = J(e, a);
1173
1218
  this.particleStateTextures = [i, a], this.particleFramebuffers = [r, n];
1174
- const o = new Float32Array(H * 2), c = new Float32Array(H * 2);
1175
- for (let u = 0; u < H; u++)
1176
- o[u * 2] = u, o[u * 2 + 1] = u, c[u * 2] = 0, c[u * 2 + 1] = 1;
1177
- 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);
1219
+ const o = new Float32Array(H * 2), l = new Float32Array(H * 2);
1220
+ for (let d = 0; d < H; d++)
1221
+ o[d * 2] = d, o[d * 2 + 1] = d, l[d * 2] = 0, l[d * 2 + 1] = 1;
1222
+ this.particleIndexBuffer = e.createBuffer(), e.bindBuffer(e.ARRAY_BUFFER, this.particleIndexBuffer), e.bufferData(e.ARRAY_BUFFER, o, e.STATIC_DRAW), this.particleIsCurrBuffer = e.createBuffer(), e.bindBuffer(e.ARRAY_BUFFER, this.particleIsCurrBuffer), e.bufferData(e.ARRAY_BUFFER, l, e.STATIC_DRAW);
1178
1223
  }
1179
1224
  initRasterGrid() {
1180
1225
  const e = this.gl, t = new Float32Array(
@@ -1182,17 +1227,17 @@ class wt {
1182
1227
  );
1183
1228
  let i = 0;
1184
1229
  for (let o = 0; o <= ee; o++)
1185
- for (let c = 0; c <= Y; c++)
1186
- 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;
1187
1232
  const a = new Uint16Array(
1188
1233
  Y * ee * 6
1189
1234
  );
1190
1235
  let r = 0;
1191
1236
  const n = Y + 1;
1192
1237
  for (let o = 0; o < ee; o++)
1193
- for (let c = 0; c < Y; c++) {
1194
- const u = o * n + c, l = u + 1, d = u + n, f = d + 1;
1195
- a[r++] = u, a[r++] = d, a[r++] = l, a[r++] = l, a[r++] = d, 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;
1196
1241
  }
1197
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;
1198
1243
  }
@@ -1211,14 +1256,14 @@ class wt {
1211
1256
  return;
1212
1257
  const i = this.gl;
1213
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();
1214
- const a = new Uint8Array(e * t * 4), r = be(i, i.NEAREST, a, e, t), n = be(i, i.NEAREST, a, e, t), o = J(i, r), c = J(i, n);
1215
- 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];
1216
1261
  }
1217
1262
  /**
1218
1263
  * Run one simulation step: update positions, fade trails, draw particles.
1219
1264
  * Must be called within the MapLibre render callback.
1220
1265
  */
1221
- render(e, t, i, a, r, n, o, c, u = !1, l = [0, 0, 1], d, f) {
1266
+ render(e, t, i, a, r, n, o, l, d = !1, c = [0, 0, 1], u, f) {
1222
1267
  const m = { unit: e, min: t, max: i }, p = f ?? { a: m, b: m, mix: 0 }, h = this.gl;
1223
1268
  if (this.screenWidth === 0 || this.screenHeight === 0)
1224
1269
  return;
@@ -1229,13 +1274,13 @@ class wt {
1229
1274
  const T = !x && (this.renderMode === "particles" || this.renderMode === "raster+particles"), M = x || this.renderMode === "raster" || this.renderMode === "raster+particles";
1230
1275
  let y = !1;
1231
1276
  if (T) {
1232
- 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), we(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;
1233
- const E = r.maxX - r.minX;
1277
+ h.disable(h.BLEND), h.useProgram(this.updateProgram), h.viewport(0, 0, B, B), O(h, this.particleStateTextures[0], 0), h.uniform1i(this.updateLocs.u_particles, 0), Te(h, this.updateLocs, p), h.uniform1i(this.updateLocs.u_velocity, p.a.unit), h.uniform2f(this.updateLocs.u_velocity_min, ...p.a.min), h.uniform2f(this.updateLocs.u_velocity_max, ...p.a.max), h.uniform1f(this.updateLocs.u_speed, this.params.speed), h.uniform1f(this.updateLocs.u_world_size, n), h.uniform1ui(this.updateLocs.u_frame, this.frame), this.frame = this.frame + 1 >>> 0;
1278
+ const R = r.maxX - r.minX;
1234
1279
  if (this.prevBounds) {
1235
- 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);
1236
1281
  this.redistributionBoost = Math.max(
1237
- this.redistributionBoost * Di,
1238
- U * Li
1282
+ this.redistributionBoost * Fi,
1283
+ V * ki
1239
1284
  );
1240
1285
  }
1241
1286
  this.prevBounds = {
@@ -1246,7 +1291,7 @@ class wt {
1246
1291
  };
1247
1292
  const k = Math.min(
1248
1293
  this.params.dropRate + this.redistributionBoost,
1249
- Ai
1294
+ Ii
1250
1295
  );
1251
1296
  h.uniform1f(this.updateLocs.u_drop_rate, k), h.uniform1f(
1252
1297
  this.updateLocs.u_drop_rate_bump,
@@ -1257,57 +1302,57 @@ class wt {
1257
1302
  r.minY,
1258
1303
  r.maxX,
1259
1304
  r.maxY
1260
- ), h.uniform1f(this.updateLocs.u_is_globe, u ? 1 : 0), c && h.uniform4f(
1305
+ ), h.uniform1f(this.updateLocs.u_is_globe, d ? 1 : 0), l && h.uniform4f(
1261
1306
  this.updateLocs.u_geo_bounds,
1262
- c.west,
1263
- c.south,
1264
- c.east,
1265
- c.north
1307
+ l.west,
1308
+ l.south,
1309
+ l.east,
1310
+ l.north
1266
1311
  ), h.uniform1f(
1267
1312
  this.updateLocs.u_valid_threshold,
1268
- Ze
1313
+ je
1269
1314
  ), h.bindFramebuffer(h.FRAMEBUFFER, this.particleFramebuffers[1]), this.drawQuad(), y = !0;
1270
1315
  }
1271
1316
  h.viewport(0, 0, this.screenWidth, this.screenHeight), h.bindFramebuffer(h.FRAMEBUFFER, this.screenFramebuffers[1]), h.useProgram(this.fadeProgram), h.disable(h.BLEND), O(h, this.screenTextures[0], 0), h.uniform1i(this.fadeLocs.u_screen, 0), h.uniform1f(
1272
1317
  this.fadeLocs.u_opacity,
1273
1318
  this.updateTrailFadeOpacity(performance.now())
1274
1319
  ), this.drawQuad();
1275
- const v = (E) => {
1276
- c && (u && d ? this.renderGridGlobe(
1320
+ const v = (R) => {
1321
+ l && (d && u ? this.renderGridGlobe(
1277
1322
  e,
1278
1323
  t,
1279
1324
  i,
1280
1325
  a,
1281
- c,
1282
- d,
1326
+ l,
1327
+ u,
1283
1328
  1,
1284
- E,
1329
+ R,
1285
1330
  p
1286
- ) : u || this.renderGrid(
1331
+ ) : d || this.renderGrid(
1287
1332
  e,
1288
1333
  t,
1289
1334
  i,
1290
1335
  a,
1291
1336
  n,
1292
1337
  o,
1293
- c,
1338
+ l,
1294
1339
  1,
1295
- E,
1340
+ R,
1296
1341
  p
1297
1342
  ));
1298
1343
  };
1299
- if (M && v(Te), T) {
1344
+ if (M && v(Me), T) {
1300
1345
  h.useProgram(this.drawProgram), h.enable(h.BLEND), h.blendFuncSeparate(
1301
1346
  h.SRC_ALPHA,
1302
1347
  h.ONE_MINUS_SRC_ALPHA,
1303
1348
  h.ONE,
1304
1349
  h.ONE_MINUS_SRC_ALPHA
1305
- ), 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), we(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(
1306
1351
  this.drawLocs.u_geo_bounds,
1307
- c.west,
1308
- c.south,
1309
- c.east,
1310
- c.north
1352
+ l.west,
1353
+ l.south,
1354
+ l.east,
1355
+ l.north
1311
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(
1312
1357
  this.drawLocs.u_particle_contrast,
1313
1358
  this.renderMode === "raster+particles" ? 1 : 0
@@ -1316,115 +1361,115 @@ class wt {
1316
1361
  this.params.logScale ? 1 : 0
1317
1362
  ), h.uniform1f(this.drawLocs.u_vibrance, this.params.vibrance), h.uniform1f(
1318
1363
  this.drawLocs.u_valid_threshold,
1319
- Ze
1320
- ), h.uniform1f(this.drawLocs.u_is_globe, u ? 1 : 0), h.uniform3f(
1364
+ je
1365
+ ), h.uniform1f(this.drawLocs.u_is_globe, d ? 1 : 0), h.uniform3f(
1321
1366
  this.drawLocs.u_globe_center,
1322
- l[0],
1323
- l[1],
1324
- l[2]
1367
+ c[0],
1368
+ c[1],
1369
+ c[2]
1325
1370
  ), h.uniformMatrix4fv(
1326
1371
  this.drawLocs.u_matrix,
1327
1372
  !1,
1328
1373
  a instanceof Float32Array ? a : new Float32Array(Array.from(a))
1329
1374
  );
1330
- const E = h.getAttribLocation(this.drawProgram, "a_index");
1331
- 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);
1332
1377
  const k = h.getAttribLocation(this.drawProgram, "a_is_curr");
1333
1378
  h.bindBuffer(h.ARRAY_BUFFER, this.particleIsCurrBuffer), h.enableVertexAttribArray(k), h.vertexAttribPointer(k, 1, h.FLOAT, !1, 0, 0);
1334
1379
  for (const F of o)
1335
1380
  h.uniform1f(this.drawLocs.u_world_offset, F), h.drawArrays(h.LINES, 0, this.numParticles * 2);
1336
- h.disableVertexAttribArray(E), h.disableVertexAttribArray(k), h.disable(h.BLEND);
1381
+ h.disableVertexAttribArray(R), h.disableVertexAttribArray(k), h.disable(h.BLEND);
1337
1382
  }
1338
1383
  h.bindFramebuffer(h.FRAMEBUFFER, g), h.viewport(0, 0, this.screenWidth, this.screenHeight);
1339
- const _ = li(this.params.backdrop);
1384
+ const _ = di(this.params.backdrop);
1340
1385
  _[3] > 0 && v(_);
1341
- 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;
1342
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(
1343
1388
  this.compositeLocs.u_glow,
1344
- S ? Yt * this.params.glow : 0
1345
- ), h.uniform1f(this.compositeLocs.u_grade_on, R.enabled ? 1 : 0), h.uniform4f(this.compositeLocs.u_grade, ...ci(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();
1346
1391
  }
1347
1392
  /**
1348
1393
  * Reduce the latest trails into the glow texture (glow.glsl), then rebind
1349
1394
  * `framebuffer` with the full viewport.
1350
1395
  */
1351
1396
  renderGlow(e) {
1352
- const t = this.gl, i = Math.ceil(this.screenWidth / qe), a = Math.ceil(this.screenHeight / qe);
1353
- return this.glowTexture || (this.glowTexture = be(t, t.LINEAR, null, i, a), this.glowFramebuffer = J(t, this.glowTexture)), t.bindFramebuffer(t.FRAMEBUFFER, this.glowFramebuffer), t.viewport(0, 0, i, a), t.disable(t.BLEND), t.useProgram(this.glowProgram), O(t, this.screenTextures[1], 0), t.uniform1i(this.glowLocs.u_screen, 0), this.drawQuad(), t.bindFramebuffer(t.FRAMEBUFFER, e), t.viewport(0, 0, this.screenWidth, this.screenHeight), this.glowTexture;
1397
+ const t = this.gl, i = Math.ceil(this.screenWidth / We), a = Math.ceil(this.screenHeight / We);
1398
+ return this.glowTexture || (this.glowTexture = Se(t, t.LINEAR, null, i, a), this.glowFramebuffer = J(t, this.glowTexture)), t.bindFramebuffer(t.FRAMEBUFFER, this.glowFramebuffer), t.viewport(0, 0, i, a), t.disable(t.BLEND), t.useProgram(this.glowProgram), O(t, this.screenTextures[1], 0), t.uniform1i(this.glowLocs.u_screen, 0), this.drawQuad(), t.bindFramebuffer(t.FRAMEBUFFER, e), t.viewport(0, 0, this.screenWidth, this.screenHeight), this.glowTexture;
1354
1399
  }
1355
1400
  deleteGlowTarget() {
1356
1401
  this.glowTexture && (this.gl.deleteTexture(this.glowTexture), this.gl.deleteFramebuffer(this.glowFramebuffer), this.glowTexture = null, this.glowFramebuffer = null);
1357
1402
  }
1358
- renderGrid(e, t, i, a, r, n, o, c = 1, u = Te, l) {
1359
- const d = this.gl;
1360
- d.useProgram(this.gridProgram), d.disable(d.DEPTH_TEST), d.disable(d.STENCIL_TEST), d.disable(d.BLEND), this.setGridFieldUniforms(
1403
+ renderGrid(e, t, i, a, r, n, o, l = 1, d = Me, c) {
1404
+ const u = this.gl;
1405
+ u.useProgram(this.gridProgram), u.disable(u.DEPTH_TEST), u.disable(u.STENCIL_TEST), u.disable(u.BLEND), this.setGridFieldUniforms(
1361
1406
  this.gridLocs,
1362
1407
  e,
1363
1408
  t,
1364
1409
  i,
1365
- c,
1366
- u,
1367
- l
1368
- ), d.uniformMatrix4fv(
1410
+ l,
1411
+ d,
1412
+ c
1413
+ ), u.uniformMatrix4fv(
1369
1414
  this.gridLocs.u_matrix,
1370
1415
  !1,
1371
1416
  a instanceof Float32Array ? a : new Float32Array(Array.from(a))
1372
- ), d.uniform4f(
1417
+ ), u.uniform4f(
1373
1418
  this.gridLocs.u_geo_bounds,
1374
1419
  o.west,
1375
1420
  o.south,
1376
1421
  o.east,
1377
1422
  o.north
1378
- ), d.uniform1f(this.gridLocs.u_world_size, r), d.enable(d.BLEND), d.blendFunc(d.SRC_ALPHA, d.ONE_MINUS_SRC_ALPHA), this.bindRasterGrid(this.gridProgram);
1423
+ ), u.uniform1f(this.gridLocs.u_world_size, r), u.enable(u.BLEND), u.blendFunc(u.SRC_ALPHA, u.ONE_MINUS_SRC_ALPHA), this.bindRasterGrid(this.gridProgram);
1379
1424
  for (const f of n)
1380
- d.uniform1f(this.gridLocs.u_world_offset, f), d.drawElements(
1381
- d.TRIANGLES,
1425
+ u.uniform1f(this.gridLocs.u_world_offset, f), u.drawElements(
1426
+ u.TRIANGLES,
1382
1427
  this.rasterGridIndexCount,
1383
- d.UNSIGNED_SHORT,
1428
+ u.UNSIGNED_SHORT,
1384
1429
  0
1385
1430
  );
1386
- this.unbindRasterGrid(this.gridProgram), d.disable(d.BLEND);
1431
+ this.unbindRasterGrid(this.gridProgram), u.disable(u.BLEND);
1387
1432
  }
1388
- renderGridGlobe(e, t, i, a, r, n, o = 1, c = Te, u) {
1389
- const l = this.gl;
1390
- l.useProgram(this.gridGlobeProgram), l.disable(l.DEPTH_TEST), l.disable(l.STENCIL_TEST), l.disable(l.BLEND), this.setGridFieldUniforms(
1433
+ renderGridGlobe(e, t, i, a, r, n, o = 1, l = Me, d, c = Kt) {
1434
+ const u = this.gl;
1435
+ u.useProgram(this.gridGlobeProgram), vt(u, this.gridGlobeLocs, c), u.disable(u.DEPTH_TEST), u.disable(u.STENCIL_TEST), u.disable(u.BLEND), this.setGridFieldUniforms(
1391
1436
  this.gridGlobeLocs,
1392
1437
  e,
1393
1438
  t,
1394
1439
  i,
1395
1440
  o,
1396
- c,
1397
- u
1398
- ), l.uniformMatrix4fv(
1441
+ l,
1442
+ d
1443
+ ), u.uniformMatrix4fv(
1399
1444
  this.gridGlobeLocs.u_matrix,
1400
1445
  !1,
1401
1446
  a instanceof Float32Array ? a : new Float32Array(Array.from(a))
1402
- ), l.uniform4f(
1447
+ ), u.uniform4f(
1403
1448
  this.gridGlobeLocs.u_geo_bounds,
1404
1449
  r.west,
1405
1450
  r.south,
1406
1451
  r.east,
1407
1452
  r.north
1408
- ), l.uniform4f(
1453
+ ), u.uniform4f(
1409
1454
  this.gridGlobeLocs.u_clipping_plane,
1410
1455
  n[0],
1411
1456
  n[1],
1412
1457
  n[2],
1413
1458
  n[3]
1414
- ), l.enable(l.BLEND), l.blendFunc(l.SRC_ALPHA, l.ONE_MINUS_SRC_ALPHA), this.bindRasterGrid(this.gridGlobeProgram), l.drawElements(
1415
- l.TRIANGLES,
1459
+ ), u.enable(u.BLEND), u.blendFunc(u.SRC_ALPHA, u.ONE_MINUS_SRC_ALPHA), this.bindRasterGrid(this.gridGlobeProgram), u.drawElements(
1460
+ u.TRIANGLES,
1416
1461
  this.rasterGridIndexCount,
1417
- l.UNSIGNED_SHORT,
1462
+ u.UNSIGNED_SHORT,
1418
1463
  0
1419
- ), this.unbindRasterGrid(this.gridGlobeProgram), l.disable(l.BLEND);
1464
+ ), this.unbindRasterGrid(this.gridGlobeProgram), u.disable(u.BLEND);
1420
1465
  }
1421
1466
  setGridFieldUniforms(e, t, i, a, r, n, o) {
1422
- const c = this.gl, u = { unit: t, min: i, max: a }, l = o ?? { a: u, b: u, mix: 0 };
1423
- we(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);
1424
- const d = Math.sqrt(
1467
+ const l = this.gl, d = { unit: t, min: i, max: a }, c = o ?? { a: d, b: d, mix: 0 };
1468
+ Te(l, e, c), l.uniform1i(e.u_field, c.a.unit), l.uniform4f(e.u_solid, ...n), O(l, this.colorRampTexture, 2), l.uniform1i(e.u_color_ramp, 2);
1469
+ const u = Math.sqrt(
1425
1470
  Math.max(Math.abs(i[0]), Math.abs(a[0])) ** 2 + Math.max(Math.abs(i[1]), Math.abs(a[1])) ** 2
1426
1471
  );
1427
- c.uniform1f(e.u_field_min, 0), c.uniform1f(e.u_field_max, d > 0 ? d : 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);
1428
1473
  }
1429
1474
  bindRasterGrid(e) {
1430
1475
  const t = this.gl, i = t.getAttribLocation(e, "a_grid_uv");
@@ -1490,11 +1535,11 @@ class wt {
1490
1535
  }
1491
1536
  /** Partial values take the vibrant preset; see resolveColorGrade. */
1492
1537
  setColorGrade(e) {
1493
- this.params.colorGrade = _t(e);
1538
+ this.params.colorGrade = bt(e);
1494
1539
  }
1495
1540
  /** Missing values take the defaults; see resolveBackdrop. */
1496
1541
  setBackdrop(e) {
1497
- this.params.backdrop = xt(e);
1542
+ this.params.backdrop = St(e);
1498
1543
  }
1499
1544
  /** Halo strength, clamped to [0, 1]; 0 frees the glow texture. */
1500
1545
  setGlow(e) {
@@ -1579,7 +1624,7 @@ class wt {
1579
1624
  e.deleteBuffer(this.quadBuffer), e.deleteBuffer(this.particleIndexBuffer), e.deleteBuffer(this.particleIsCurrBuffer), e.deleteTexture(this.colorRampTexture);
1580
1625
  }
1581
1626
  }
1582
- class Tt {
1627
+ class Pt {
1583
1628
  constructor() {
1584
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;
1585
1630
  }
@@ -1593,17 +1638,17 @@ class Tt {
1593
1638
  * fields may use a fixed color domain so fragments never decode physical values.
1594
1639
  */
1595
1640
  update(e, t = null) {
1596
- const i = this.gl, { u: a, v: r, width: n, height: o, uMin: c, uMax: u, vMin: l, vMax: d } = e;
1597
- this.scalarMode = e.scalarMode ?? !1, this.width = n, this.height = o, this.uMin = c, this.uMax = u, this.vMin = l, this.vMax = d, this.geoBounds = e.bounds;
1598
- const f = this.scalarMode && t ? t[0] : c, p = (this.scalarMode && t ? t[1] : u) - f || 1, h = d - 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);
1599
1644
  for (let y = 0; y < n * o; y++) {
1600
1645
  const v = a[y], _ = r[y];
1601
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(
1602
1647
  Math.max(0, Math.min(1, (v - f) / p)) * 255
1603
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(
1604
- Math.max(0, Math.min(1, (v - c) / p)) * 255
1649
+ Math.max(0, Math.min(1, (v - l) / p)) * 255
1605
1650
  ), g[y * 4 + 1] = Math.round(
1606
- Math.max(0, Math.min(1, (_ - l) / h)) * 255
1651
+ Math.max(0, Math.min(1, (_ - c) / h)) * 255
1607
1652
  ), g[y * 4 + 2] = 0, g[y * 4 + 3] = 255);
1608
1653
  }
1609
1654
  if (e.latDescending) {
@@ -1617,7 +1662,7 @@ class Tt {
1617
1662
  console.log(
1618
1663
  `[zartigl] Velocity texture: ${n}x${o}, valid=${x} (${(100 * x / (n * o)).toFixed(
1619
1664
  1
1620
- )}%), nodata=${T}, uRange=[${c.toFixed(4)}, ${u.toFixed(4)}], vRange=[${l.toFixed(4)}, ${d.toFixed(4)}]`
1665
+ )}%), nodata=${T}, uRange=[${l.toFixed(4)}, ${d.toFixed(4)}], vRange=[${c.toFixed(4)}, ${u.toFixed(4)}]`
1621
1666
  ), this.texture || (this.texture = i.createTexture());
1622
1667
  const M = this.linearFilter ? i.LINEAR : i.NEAREST;
1623
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(
@@ -1657,8 +1702,8 @@ class Tt {
1657
1702
  this.gl && this.texture && (this.gl.deleteTexture(this.texture), this.texture = null);
1658
1703
  }
1659
1704
  }
1660
- function Mt(s, e, t, i, a, r, n) {
1661
- 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);
1662
1707
  for (const m of s)
1663
1708
  for (let p = 0; p < m.latSize; p++)
1664
1709
  for (let h = 0; h < m.lonSize; h++) {
@@ -1669,38 +1714,38 @@ function Mt(s, e, t, i, a, r, n) {
1669
1714
  for (let p = 0; p < m.latSize; p++)
1670
1715
  for (let h = 0; h < m.lonSize; h++) {
1671
1716
  const g = p * m.lonChunkSize + h, x = (m.latStart + p) * i + (m.lonStart + h);
1672
- c[x] = m.data[g];
1717
+ l[x] = m.data[g];
1673
1718
  }
1674
- let u = 1 / 0, l = -1 / 0, d = 1 / 0, f = -1 / 0;
1719
+ let d = 1 / 0, c = -1 / 0, u = 1 / 0, f = -1 / 0;
1675
1720
  for (let m = 0; m < o.length; m++)
1676
- isNaN(o[m]) || (o[m] < u && (u = o[m]), o[m] > l && (l = o[m])), isNaN(c[m]) || (c[m] < d && (d = c[m]), c[m] > f && (f = c[m]));
1677
- return isFinite(u) || (u = -1), isFinite(l) || (l = 1), isFinite(d) || (d = -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), {
1678
1723
  u: o,
1679
- v: c,
1724
+ v: l,
1680
1725
  width: i,
1681
1726
  height: t,
1682
- uMin: u,
1683
- uMax: l,
1684
- vMin: d,
1727
+ uMin: d,
1728
+ uMax: c,
1729
+ vMin: u,
1685
1730
  vMax: f,
1686
1731
  bounds: a ?? { west: -180, south: -90, east: 180, north: 90 },
1687
1732
  latDescending: r,
1688
1733
  scalarMode: n
1689
1734
  };
1690
1735
  }
1691
- const Me = [
1736
+ const Re = [
1692
1737
  "depth",
1693
1738
  "elevation",
1694
1739
  "level",
1695
1740
  "altitude",
1696
1741
  "pressure_level"
1697
1742
  ];
1698
- class je extends Error {
1743
+ class Qe extends Error {
1699
1744
  constructor(e, t) {
1700
1745
  super(`Chunk fetch failed: ${e} ${t}`), this.name = "ZarrChunkFetchError", this.status = e, this.url = t;
1701
1746
  }
1702
1747
  }
1703
- class ye {
1748
+ class _e {
1704
1749
  constructor(e, t = 200) {
1705
1750
  this.meta = null, this.coords = null, this.initPromise = null, this.verticalName = "depth", this.timeUnits = "", this.timeCalendar = "standard", this.cache = /* @__PURE__ */ new Map(), this.abortControllers = /* @__PURE__ */ new Map(), this.bloscCodecCache = /* @__PURE__ */ new Map(), this.root = e.replace(/\/$/, ""), this.maxCacheSize = t;
1706
1751
  }
@@ -1752,7 +1797,7 @@ class ye {
1752
1797
  let a = t ? i[0] : NaN, r = a;
1753
1798
  for (let o = 1; o < i.length; o++)
1754
1799
  a = Math.min(a, i[o]), r = Math.max(r, i[o]);
1755
- const n = Ni(i);
1800
+ const n = Bi(i);
1756
1801
  return {
1757
1802
  min: a,
1758
1803
  max: r,
@@ -1824,7 +1869,7 @@ class ye {
1824
1869
  throw new Error(
1825
1870
  `Unsupported Zarr time units: ${this.timeUnits || "<missing>"}`
1826
1871
  );
1827
- const i = Ui(t[2]);
1872
+ const i = Gi(t[2]);
1828
1873
  if (!Number.isFinite(i))
1829
1874
  throw new Error(`Invalid Zarr time epoch: ${t[2]}`);
1830
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;
@@ -1837,28 +1882,28 @@ class ye {
1837
1882
  }
1838
1883
  async sampleVariableAt(e, t) {
1839
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);
1840
- for (let l = 0; l < i.length; l++) {
1841
- const d = i[l];
1885
+ for (let c = 0; c < i.length; c++) {
1886
+ const u = i[c];
1842
1887
  let f = 0;
1843
- d === "time" ? f = t.timeIdx : d === "latitude" ? f = t.latIdx : d === "longitude" ? f = t.lonIdx : (d === this.verticalName || Me.includes(d)) && (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];
1844
1889
  }
1845
- let c;
1890
+ let l;
1846
1891
  try {
1847
- c = await this.fetchChunk(e, n);
1848
- } catch (l) {
1849
- if (l instanceof je && (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))
1850
1895
  return NaN;
1851
- throw l;
1896
+ throw c;
1852
1897
  }
1853
- const u = this.getFlatOffset(e, o);
1854
- return u < c.length ? c[u] : NaN;
1898
+ const d = this.getFlatOffset(e, o);
1899
+ return d < l.length ? l[d] : NaN;
1855
1900
  }
1856
1901
  getFlatOffset(e, t) {
1857
1902
  const i = this.getArrayMeta(e), a = i.chunks;
1858
1903
  if (i.order === "F") {
1859
1904
  let n = 0, o = 1;
1860
- for (let c = 0; c < t.length; c++)
1861
- n += t[c] * o, o *= a[c];
1905
+ for (let l = 0; l < t.length; l++)
1906
+ n += t[l] * o, o *= a[l];
1862
1907
  return n;
1863
1908
  }
1864
1909
  let r = 0;
@@ -1874,13 +1919,13 @@ class ye {
1874
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(
1875
1920
  t.time.length - 1,
1876
1921
  e.timeEndIndex ?? t.time.length - 1
1877
- ), c = Math.max(1, Math.floor(e.stride ?? 1)), u = Math.max(
1922
+ ), l = Math.max(1, Math.floor(e.stride ?? 1)), d = Math.max(
1878
1923
  0,
1879
1924
  Math.floor(e.stopAfterMissingSamples ?? 0)
1880
1925
  );
1881
- let l = 0;
1882
- const d = [];
1883
- for (let f = n; f <= o; f += c) {
1926
+ let c = 0;
1927
+ const u = [];
1928
+ for (let f = n; f <= o; f += l) {
1884
1929
  const m = {};
1885
1930
  for (const g of e.variables)
1886
1931
  m[g] = await this.sampleVariableAt(g, {
@@ -1890,21 +1935,21 @@ class ye {
1890
1935
  lonIdx: i
1891
1936
  });
1892
1937
  const p = this.zarrTimeToMs(t.time[f]);
1893
- if (d.push({
1938
+ if (u.push({
1894
1939
  axisValue: p,
1895
1940
  time: p,
1896
1941
  depth: t.vertical[r],
1897
1942
  values: m
1898
- }), l = e.variables.every(
1943
+ }), c = e.variables.every(
1899
1944
  (g) => !Number.isFinite(m[g])
1900
- ) ? l + 1 : 0, u > 0 && l >= u)
1945
+ ) ? c + 1 : 0, d > 0 && c >= d)
1901
1946
  break;
1902
1947
  }
1903
1948
  return {
1904
1949
  longitude: t.longitude[i],
1905
1950
  latitude: t.latitude[a],
1906
1951
  depth: t.vertical[r],
1907
- points: d
1952
+ points: u
1908
1953
  };
1909
1954
  }
1910
1955
  async sampleVerticalProfile(e) {
@@ -1914,22 +1959,22 @@ class ye {
1914
1959
  Math.floor(e.stopAfterMissingSamples ?? 0)
1915
1960
  );
1916
1961
  let o = 0;
1917
- const c = [];
1918
- let u = Array.from(
1962
+ const l = [];
1963
+ let d = Array.from(
1919
1964
  { length: t.vertical.length },
1920
1965
  (f, m) => m
1921
1966
  ).sort(
1922
1967
  (f, m) => Math.abs(t.vertical[f]) - Math.abs(t.vertical[m])
1923
1968
  );
1924
- const l = Math.max(
1969
+ const c = Math.max(
1925
1970
  1,
1926
- Math.floor(e.maxDepths ?? u.length)
1927
- ), d = Math.max(
1971
+ Math.floor(e.maxDepths ?? d.length)
1972
+ ), u = Math.max(
1928
1973
  1,
1929
- Math.floor(e.stride ?? Math.ceil(u.length / l))
1974
+ Math.floor(e.stride ?? Math.ceil(d.length / c))
1930
1975
  );
1931
- u = u.filter((f, m) => m % d === 0).slice(0, l);
1932
- for (const f of u) {
1976
+ d = d.filter((f, m) => m % u === 0).slice(0, c);
1977
+ for (const f of d) {
1933
1978
  const m = {};
1934
1979
  for (const g of e.variables)
1935
1980
  m[g] = await this.sampleVariableAt(g, {
@@ -1939,7 +1984,7 @@ class ye {
1939
1984
  lonIdx: i
1940
1985
  });
1941
1986
  const p = t.vertical[f];
1942
- if (c.push({
1987
+ if (l.push({
1943
1988
  axisValue: p,
1944
1989
  time: this.zarrTimeToMs(t.time[r]),
1945
1990
  depth: p,
@@ -1953,7 +1998,7 @@ class ye {
1953
1998
  longitude: t.longitude[i],
1954
1999
  latitude: t.latitude[a],
1955
2000
  time: this.zarrTimeToMs(t.time[r]),
1956
- points: c
2001
+ points: l
1957
2002
  };
1958
2003
  }
1959
2004
  /** Return the actual name of the vertical dimension ("depth" or "elevation"). */
@@ -1964,11 +2009,11 @@ class ye {
1964
2009
  * Get chunk indices that intersect a geographic bounding box.
1965
2010
  */
1966
2011
  getChunksForBounds(e, t, i, a) {
1967
- const r = this.getCoords(), n = this.getChunkShape(e), o = this.getDimensions(e), c = o.indexOf("latitude"), u = o.indexOf("longitude"), l = n[c], d = n[u], 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 / d), E = Math.floor(v / d), k = this.getShape(e), F = k[c], P = k[u], 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 = [];
1968
2013
  for (let b = _; b <= S; b++)
1969
- for (let A = R; A <= E; A++) {
1970
- const N = b * l, C = A * d, I = Math.min(l, F - N), w = Math.min(d, P - C);
1971
- 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({
1972
2017
  timeIdx: t,
1973
2018
  depthIdx: i,
1974
2019
  latIdx: b,
@@ -1979,7 +2024,7 @@ class ye {
1979
2024
  lonSize: w
1980
2025
  });
1981
2026
  }
1982
- return L;
2027
+ return D;
1983
2028
  }
1984
2029
  async fetchChunk(e, t) {
1985
2030
  return (await this.fetchChunkResult(e, t)).data;
@@ -1995,13 +2040,13 @@ class ye {
1995
2040
  throw new Error(
1996
2041
  `Variable ${e} must have latitude and longitude dimensions`
1997
2042
  );
1998
- 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);
1999
2044
  for (let m = 0; m < i.length; m++) {
2000
2045
  const p = i[m];
2001
2046
  let h = 0;
2002
2047
  if (p === "time")
2003
2048
  h = t.timeIndex;
2004
- else if (p === this.verticalName || Me.includes(p))
2049
+ else if (p === this.verticalName || Re.includes(p))
2005
2050
  h = t.verticalIndex;
2006
2051
  else if (p === "latitude") {
2007
2052
  o[m] = t.latitudeChunkIndex;
@@ -2010,19 +2055,19 @@ class ye {
2010
2055
  o[m] = t.longitudeChunkIndex;
2011
2056
  continue;
2012
2057
  }
2013
- 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];
2014
2059
  }
2015
- const u = await this.fetchChunkResult(e, o), l = a[r], d = a[n], f = new Float32Array(l * d);
2060
+ const d = await this.fetchChunkResult(e, o), c = a[r], u = a[n], f = new Float32Array(c * u);
2016
2061
  f.fill(NaN);
2017
- for (let m = 0; m < l; m++) {
2018
- c[r] = m;
2019
- for (let p = 0; p < d; p++) {
2020
- c[n] = p;
2021
- const h = this.getFlatOffset(e, c);
2022
- h < u.data.length && (f[m * d + p] = u.data[h]);
2062
+ for (let m = 0; m < c; m++) {
2063
+ l[r] = m;
2064
+ for (let p = 0; p < u; p++) {
2065
+ l[n] = p;
2066
+ const h = this.getFlatOffset(e, l);
2067
+ h < d.data.length && (f[m * u + p] = d.data[h]);
2023
2068
  }
2024
2069
  }
2025
- return { ...u, data: f };
2070
+ return { ...d, data: f };
2026
2071
  }
2027
2072
  async fetchChunkResult(e, t) {
2028
2073
  const i = this.getDimensionSeparator(e), a = t.join(i), r = `${e}/${a}`, n = `${this.root}/${e}/${a}`;
@@ -2031,23 +2076,23 @@ class ye {
2031
2076
  this.abortControllers.get(r)?.abort();
2032
2077
  const o = new AbortController();
2033
2078
  this.abortControllers.set(r, o);
2034
- const c = this.getArrayMeta(e);
2079
+ const l = this.getArrayMeta(e);
2035
2080
  try {
2036
- const u = await fetch(n, { signal: o.signal });
2037
- if (!u.ok) {
2038
- if (u.status === 403 || u.status === 404)
2081
+ const d = await fetch(n, { signal: o.signal });
2082
+ if (!d.ok) {
2083
+ if (d.status === 403 || d.status === 404)
2039
2084
  return {
2040
- data: Ii(c),
2085
+ data: zi(l),
2041
2086
  missing: !0,
2042
- status: u.status,
2087
+ status: d.status,
2043
2088
  url: n
2044
2089
  };
2045
- throw new je(u.status, n);
2090
+ throw new Qe(d.status, n);
2046
2091
  }
2047
- const l = new Uint8Array(await u.arrayBuffer()), d = Fi(
2048
- await this.decompress(l, c, e)
2092
+ const c = new Uint8Array(await d.arrayBuffer()), u = Ni(
2093
+ await this.decompress(c, l, e)
2049
2094
  );
2050
- return this.cacheChunk(r, d), { data: d, missing: !1, url: n };
2095
+ return this.cacheChunk(r, u), { data: u, missing: !1, url: n };
2051
2096
  } finally {
2052
2097
  this.abortControllers.get(r) === o && this.abortControllers.delete(r);
2053
2098
  }
@@ -2067,7 +2112,7 @@ class ye {
2067
2112
  getBloscCodec(e) {
2068
2113
  const t = e.compressor, i = `${t.cname ?? "lz4"}-${t.clevel ?? 5}-${t.shuffle ?? 1}-${t.blocksize ?? 0}`;
2069
2114
  let a = this.bloscCodecCache.get(i);
2070
- return a || (a = mi.fromConfig({
2115
+ return a || (a = vi.fromConfig({
2071
2116
  id: "blosc",
2072
2117
  cname: t.cname ?? "lz4",
2073
2118
  clevel: t.clevel ?? 5,
@@ -2081,7 +2126,7 @@ class ye {
2081
2126
  switch (t.compressor.id) {
2082
2127
  case "zlib":
2083
2128
  case "gzip":
2084
- a = di(e);
2129
+ a = gi(e);
2085
2130
  break;
2086
2131
  case "blosc": {
2087
2132
  a = await this.getBloscCodec(t).decode(e);
@@ -2107,70 +2152,70 @@ class ye {
2107
2152
  a.byteLength / 8
2108
2153
  );
2109
2154
  else if (n === "<i2" || n === "|i2") {
2110
- const c = new Int16Array(
2155
+ const l = new Int16Array(
2111
2156
  a.buffer,
2112
2157
  a.byteOffset,
2113
2158
  a.byteLength / 2
2114
2159
  );
2115
- r = Float32Array.from(c);
2160
+ r = Float32Array.from(l);
2116
2161
  } else if (n === "<i4" || n === "|i4") {
2117
- const c = new Int32Array(
2162
+ const l = new Int32Array(
2118
2163
  a.buffer,
2119
2164
  a.byteOffset,
2120
2165
  a.byteLength / 4
2121
2166
  );
2122
- r = Float32Array.from(c);
2167
+ r = Float32Array.from(l);
2123
2168
  } else if (n === "<i8" || n === "|i8") {
2124
- const c = new DataView(
2169
+ const l = new DataView(
2125
2170
  a.buffer,
2126
2171
  a.byteOffset,
2127
2172
  a.byteLength
2128
- ), u = a.byteLength / 8;
2129
- r = new Float64Array(u);
2130
- for (let l = 0; l < u; l++)
2131
- r[l] = Number(c.getBigInt64(l * 8, !0));
2173
+ ), d = a.byteLength / 8;
2174
+ r = new Float64Array(d);
2175
+ for (let c = 0; c < d; c++)
2176
+ r[c] = Number(l.getBigInt64(c * 8, !0));
2132
2177
  } else
2133
2178
  throw new Error(`Unsupported dtype: ${n}`);
2134
2179
  const o = t.fill_value;
2135
2180
  if (o != null && typeof o == "number" && !isNaN(o))
2136
- for (let c = 0; c < r.length; c++)
2137
- r[c] === o && (r[c] = NaN);
2181
+ for (let l = 0; l < r.length; l++)
2182
+ r[l] === o && (r[l] = NaN);
2138
2183
  if (i) {
2139
- const c = this.getAttrs(i), u = c.scale_factor, l = c.add_offset;
2140
- if (u != null || l != null) {
2141
- const d = u ?? 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;
2142
2187
  for (let m = 0; m < r.length; m++)
2143
- isNaN(r[m]) || (r[m] = r[m] * d + f);
2188
+ isNaN(r[m]) || (r[m] = r[m] * u + f);
2144
2189
  }
2145
2190
  }
2146
2191
  return r;
2147
2192
  }
2148
2193
  async loadCoordinates() {
2149
- const e = async (c) => {
2150
- const u = this.getArrayMeta(c), l = u.shape[0], d = Math.ceil(l / u.chunks[0]), f = [];
2151
- for (let g = 0; g < d; g++) {
2152
- const x = `${this.root}/${c}/${g}`, T = await fetch(x);
2194
+ const e = async (l) => {
2195
+ const d = this.getArrayMeta(l), c = d.shape[0], u = Math.ceil(c / d.chunks[0]), f = [];
2196
+ for (let g = 0; g < u; g++) {
2197
+ const x = `${this.root}/${l}/${g}`, T = await fetch(x);
2153
2198
  if (!T.ok)
2154
- throw new Error(`Failed to fetch coord ${c}/${g}`);
2199
+ throw new Error(`Failed to fetch coord ${l}/${g}`);
2155
2200
  const M = new Uint8Array(await T.arrayBuffer());
2156
- f.push(await this.decompress(M, u));
2201
+ f.push(await this.decompress(M, d));
2157
2202
  }
2158
2203
  if (f.length === 1)
2159
- return f[0].length > l ? f[0].subarray(0, l) : f[0];
2160
- 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);
2161
2206
  let h = 0;
2162
2207
  for (const g of f) {
2163
- const x = Math.min(g.length, l - h);
2164
- 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)
2165
2210
  break;
2166
2211
  }
2167
2212
  return p;
2168
2213
  };
2169
2214
  let t = null;
2170
- for (const c of Me) {
2171
- const u = `${c}/.zarray`;
2172
- if (this.meta.metadata[u] && "dtype" in this.meta.metadata[u]) {
2173
- t = c;
2215
+ for (const l of Re) {
2216
+ const d = `${l}/.zarray`;
2217
+ if (this.meta.metadata[d] && "dtype" in this.meta.metadata[d]) {
2218
+ t = l;
2174
2219
  break;
2175
2220
  }
2176
2221
  }
@@ -2191,30 +2236,30 @@ class ye {
2191
2236
  };
2192
2237
  }
2193
2238
  }
2194
- function Fi(s) {
2239
+ function Ni(s) {
2195
2240
  return s instanceof Float32Array ? s : Float32Array.from(s);
2196
2241
  }
2197
- function Ii(s) {
2242
+ function zi(s) {
2198
2243
  const e = s.chunks.reduce((i, a) => i * a, 1), t = new Float32Array(e);
2199
2244
  return t.fill(NaN), t;
2200
2245
  }
2201
- function Ui(s) {
2246
+ function Gi(s) {
2202
2247
  const t = s.trim().replace(/\s+\([^)]*\)\s*$/, "").match(
2203
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
2204
2249
  );
2205
2250
  if (!t)
2206
2251
  return NaN;
2207
- 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), u = Number((t[7] ?? "").padEnd(3, "0").slice(0, 3)), l = t[8] ?? "Z";
2208
- 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)
2209
2254
  return NaN;
2210
- const d = /* @__PURE__ */ new Date(0);
2211
- d.setUTCFullYear(i, a - 1, r), d.setUTCHours(n, o, c, u);
2212
- const f = d.getTime();
2213
- if (d.getUTCFullYear() !== i || d.getUTCMonth() !== a - 1 || d.getUTCDate() !== r || d.getUTCHours() !== n || d.getUTCMinutes() !== o || d.getUTCSeconds() !== c || d.getUTCMilliseconds() !== u)
2255
+ const u = /* @__PURE__ */ new Date(0);
2256
+ u.setUTCFullYear(i, a - 1, r), u.setUTCHours(n, o, l, d);
2257
+ const f = u.getTime();
2258
+ if (u.getUTCFullYear() !== i || u.getUTCMonth() !== a - 1 || u.getUTCDate() !== r || u.getUTCHours() !== n || u.getUTCMinutes() !== o || u.getUTCSeconds() !== l || u.getUTCMilliseconds() !== d)
2214
2259
  return NaN;
2215
- if (/^z$/i.test(l))
2260
+ if (/^z$/i.test(c))
2216
2261
  return f;
2217
- const m = l.match(/^([+-])(\d{2}):?(\d{2})$/);
2262
+ const m = c.match(/^([+-])(\d{2}):?(\d{2})$/);
2218
2263
  if (!m)
2219
2264
  return NaN;
2220
2265
  const p = Number(m[2]), h = Number(m[3]);
@@ -2223,7 +2268,7 @@ function Ui(s) {
2223
2268
  const g = (p * 60 + h) * 6e4;
2224
2269
  return f - (m[1] === "+" ? g : -g);
2225
2270
  }
2226
- function Vi(s) {
2271
+ function Oi(s) {
2227
2272
  if (typeof s != "number" || !Number.isFinite(s) || s <= 0)
2228
2273
  return s;
2229
2274
  const e = [
@@ -2245,7 +2290,7 @@ function Vi(s) {
2245
2290
  return t;
2246
2291
  return Math.round(s);
2247
2292
  }
2248
- function Ni(s) {
2293
+ function Bi(s) {
2249
2294
  if (s.length < 2)
2250
2295
  return;
2251
2296
  const e = s[1] - s[0];
@@ -2255,28 +2300,28 @@ function Ni(s) {
2255
2300
  for (let i = 2; i < s.length; i++)
2256
2301
  if (Math.abs(s[i] - s[i - 1] - e) > t)
2257
2302
  return;
2258
- return Vi(e);
2303
+ return Oi(e);
2259
2304
  }
2260
- class _e extends Error {
2305
+ class xe extends Error {
2261
2306
  constructor(e, t, i) {
2262
2307
  super(
2263
2308
  t.length > 0 ? "Remote data is not available yet; the selected frame may still be publishing." : "The selected frame contains no renderable data."
2264
2309
  ), this.name = "ZartiglFrameUnavailableError", this.time = e, this.statuses = [...new Set(t)].sort((a, r) => a - r), this.urls = [...new Set(i)];
2265
2310
  }
2266
2311
  }
2267
- function zi(s) {
2312
+ function $i(s) {
2268
2313
  for (const e of s)
2269
2314
  if (Number.isFinite(e))
2270
2315
  return !0;
2271
2316
  return !1;
2272
2317
  }
2273
- function Gi(s, e) {
2318
+ function qi(s, e) {
2274
2319
  for (let t = 0; t < Math.min(s.length, e.length); t++)
2275
2320
  if (Number.isFinite(s[t]) && Number.isFinite(e[t]))
2276
2321
  return !0;
2277
2322
  return !1;
2278
2323
  }
2279
- function Rt(s) {
2324
+ function Lt(s) {
2280
2325
  return {
2281
2326
  phase: "blocked",
2282
2327
  time: s.time,
@@ -2286,7 +2331,7 @@ function Rt(s) {
2286
2331
  }
2287
2332
  class me {
2288
2333
  constructor(e) {
2289
- 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 ye(e.source), this.activeField = new Tt(), this.simulation = new wt({
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({
2290
2335
  colorRamp: e.colorRamp,
2291
2336
  opacity: e.opacity ?? 1,
2292
2337
  logScale: e.logScale ?? !1,
@@ -2318,31 +2363,34 @@ class me {
2318
2363
  const i = K(e);
2319
2364
  if (this.suspended || !this.map || !this.activeData || !this.activeField.hasData())
2320
2365
  return;
2321
- const a = ze(i);
2366
+ const a = Ge(i);
2322
2367
  try {
2323
2368
  const r = i.canvas;
2324
2369
  this.simulation.resize(r.width, r.height), i.bindFramebuffer(i.FRAMEBUFFER, a.framebuffer), i.viewport(0, 0, r.width, r.height);
2325
- const n = this.map.getBounds(), o = this.map.getProjection?.()?.type === "globe", c = 512 * Math.pow(2, this.map.getZoom());
2326
- this.activeField.bind(this.textureUnit), o ? 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(
2327
2372
  this.textureUnit,
2328
2373
  [this.activeData.uMin, this.activeData.vMin],
2329
2374
  [this.activeData.uMax, this.activeData.vMax],
2330
2375
  t.modelViewProjectionMatrix,
2331
2376
  this.activeField.geoBounds,
2332
- t.defaultProjectionData.clippingPlane,
2333
- 1
2377
+ o.clippingPlane,
2378
+ 1,
2379
+ void 0,
2380
+ void 0,
2381
+ o
2334
2382
  ) : this.simulation.renderGrid(
2335
2383
  this.textureUnit,
2336
2384
  [this.activeData.uMin, this.activeData.vMin],
2337
2385
  [this.activeData.uMax, this.activeData.vMax],
2338
2386
  t.modelViewProjectionMatrix,
2339
- c,
2340
- Oe(n, !1),
2387
+ d,
2388
+ Be(n, !1),
2341
2389
  this.activeField.geoBounds,
2342
2390
  1
2343
2391
  );
2344
2392
  } finally {
2345
- Ge(i, a);
2393
+ Oe(i, a);
2346
2394
  }
2347
2395
  if (this.pendingReadyTime != null) {
2348
2396
  const r = this.pendingReadyTime;
@@ -2475,7 +2523,7 @@ class me {
2475
2523
  const n = r instanceof Error ? r : new Error(String(r));
2476
2524
  e === this.generation && t === this.requestId && (this.emit(
2477
2525
  "status",
2478
- n instanceof _e ? Rt(n) : { phase: "error", time: a, error: n }
2526
+ n instanceof xe ? Lt(n) : { phase: "error", time: a, error: n }
2479
2527
  ), this.emit("error", n));
2480
2528
  }
2481
2529
  } finally {
@@ -2493,7 +2541,7 @@ class me {
2493
2541
  r,
2494
2542
  n,
2495
2543
  a
2496
- ), c = this.zarrSource.getDimensions(this.variable), u = c.indexOf("latitude"), l = c.indexOf("longitude"), d = 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);
2497
2545
  let f = 0;
2498
2546
  const m = o.length, p = [], h = [];
2499
2547
  t?.(f, m);
@@ -2510,46 +2558,46 @@ class me {
2510
2558
  );
2511
2559
  return A.missing && (A.status != null && p.push(A.status), h.push(A.url)), f++, t?.(f, m), {
2512
2560
  data: A.data,
2513
- latStart: b.latIdx * d[u],
2514
- lonStart: b.lonIdx * d[l],
2561
+ latStart: b.latIdx * u[d],
2562
+ lonStart: b.lonIdx * u[c],
2515
2563
  latSize: b.latSize,
2516
2564
  lonSize: b.lonSize,
2517
- lonChunkSize: d[l]
2565
+ lonChunkSize: u[c]
2518
2566
  };
2519
2567
  })
2520
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) => ({
2521
2569
  ...b,
2522
2570
  latStart: b.latStart - x,
2523
2571
  lonStart: b.lonStart - M
2524
- })), R = this.zarrSource.getCoords(), E = Math.min(T - 1, R.latitude.length - 1), k = Math.min(y - 1, R.longitude.length - 1), F = {
2525
- west: R.longitude[M],
2526
- east: R.longitude[k],
2527
- south: Math.min(R.latitude[x], R.latitude[E]),
2528
- north: Math.max(R.latitude[x], R.latitude[E])
2529
- }, P = R.latitude[x] > R.latitude[E], L = Mt(
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(
2530
2578
  S,
2531
2579
  [],
2532
2580
  v,
2533
2581
  _,
2534
2582
  F,
2535
- P,
2583
+ L,
2536
2584
  !0
2537
2585
  );
2538
- if (!zi(L.u))
2539
- throw new _e(
2586
+ if (!$i(D.u))
2587
+ throw new xe(
2540
2588
  this.timeToMs(e),
2541
2589
  p,
2542
2590
  h
2543
2591
  );
2544
- return L;
2592
+ return D;
2545
2593
  }
2546
2594
  setActive(e, t) {
2547
2595
  const i = this.timeToMs(t);
2548
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();
2549
2597
  }
2550
2598
  sampleActiveData(e, t, i) {
2551
- const { west: a, east: r, south: n, north: o } = e.bounds, c = r - a, u = o - n;
2552
- if (e.width <= 0 || e.height <= 0 || c <= 0 || u <= 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)
2553
2601
  return {
2554
2602
  longitude: t,
2555
2603
  latitude: i,
@@ -2558,8 +2606,8 @@ class me {
2558
2606
  time: this.timeToMs(this.time),
2559
2607
  depth: this.depth
2560
2608
  };
2561
- const l = a >= 0 && r > 180 ? (t % 360 + 360) % 360 : ((t + 180) % 360 + 360) % 360 - 180;
2562
- 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)
2563
2611
  return {
2564
2612
  longitude: t,
2565
2613
  latitude: i,
@@ -2568,13 +2616,13 @@ class me {
2568
2616
  time: this.timeToMs(this.time),
2569
2617
  depth: this.depth
2570
2618
  };
2571
- const d = (l - a) / c, f = e.latDescending ? (o - i) / u : (i - n) / u, m = Math.max(
2619
+ const u = (c - a) / l, f = e.latDescending ? (o - i) / d : (i - n) / d, m = Math.max(
2572
2620
  0,
2573
- Math.min(e.width - 1, Math.round(d * (e.width - 1)))
2621
+ Math.min(e.width - 1, Math.floor(u * e.width))
2574
2622
  ), p = Math.max(
2575
2623
  0,
2576
- Math.min(e.height - 1, Math.round(f * (e.height - 1)))
2577
- ), 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) * u : n + p / Math.max(1, e.height - 1) * u;
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;
2578
2626
  return {
2579
2627
  longitude: g,
2580
2628
  latitude: x,
@@ -2604,7 +2652,7 @@ class me {
2604
2652
  a(...t);
2605
2653
  }
2606
2654
  }
2607
- function Oi(s, e, t) {
2655
+ function Wi(s, e, t) {
2608
2656
  if (!Number.isFinite(s) || !Number.isFinite(e))
2609
2657
  return { u: NaN, v: NaN };
2610
2658
  const i = t.direction_convention !== t.output_direction ? 180 : 0, a = (s + i) * Math.PI / 180;
@@ -2613,15 +2661,15 @@ function Oi(s, e, t) {
2613
2661
  v: e * Math.cos(a)
2614
2662
  };
2615
2663
  }
2616
- function Ra(s) {
2664
+ function Da(s) {
2617
2665
  return [s.direction_variable, s.magnitude_variable];
2618
2666
  }
2619
- const Bi = 0.7;
2620
- class D {
2667
+ const Xi = 0.7;
2668
+ class P {
2621
2669
  constructor(e) {
2622
- 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.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")
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")
2623
2671
  throw new Error("Vector GeoVideo requires a vector-luma manifest");
2624
- this.playback = e.geoVideo ? new gt(
2672
+ this.playback = e.geoVideo ? new yt(
2625
2673
  { ...e.geoVideo, time: e.time },
2626
2674
  () => this.map?.triggerRepaint(),
2627
2675
  (t, ...i) => {
@@ -2639,16 +2687,16 @@ class D {
2639
2687
  }
2640
2688
  t === "timeChange" && (this.time = i[0]), this.emit(t, ...i);
2641
2689
  }
2642
- ) : 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 ye(e.source), this.velocityField = new Tt(), this.simulation = new wt({
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({
2643
2691
  particleDensity: e.particleDensity ?? 0.05,
2644
2692
  speed: e.speed ?? 1,
2645
- fadeOpacity: We(e.fade ?? Bi),
2693
+ fadeOpacity: Xe(e.fade ?? Xi),
2646
2694
  colorRamp: e.colorRamp,
2647
2695
  opacity: e.opacity ?? 1,
2648
2696
  logScale: e.logScale ?? !1,
2649
2697
  vibrance: e.vibrance ?? 0,
2650
- colorGrade: _t(e.colorGrade),
2651
- backdrop: xt(e.backdrop),
2698
+ colorGrade: bt(e.colorGrade),
2699
+ backdrop: St(e.backdrop),
2652
2700
  glow: e.glow ?? 0,
2653
2701
  particleState: e.particleState ?? "auto",
2654
2702
  rgba8MaxParticleZoom: e.rgba8MaxParticleZoom ?? 4
@@ -2696,9 +2744,9 @@ class D {
2696
2744
  };
2697
2745
  }
2698
2746
  isViewportCovered() {
2699
- return !this.map || !this.velocityField.hasData() ? !1 : _i(
2747
+ return !this.map || !this.velocityField.hasData() ? !1 : wi(
2700
2748
  this.velocityField.geoBounds,
2701
- vi(this.map.getBounds())
2749
+ bi(this.map.getBounds())
2702
2750
  );
2703
2751
  }
2704
2752
  reloadIfViewportUncovered() {
@@ -2715,37 +2763,37 @@ class D {
2715
2763
  * The map's current viewport is used to determine the lat bounds of the request.
2716
2764
  */
2717
2765
  async fetchVelocityData(e, t) {
2718
- const i = this.map.getBounds(), a = this.map.getProjection?.()?.type === "globe", r = yi(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);
2719
2767
  console.log(
2720
2768
  `[zartigl] Loading velocity: depth=${this.depth} → depthIdx=${o}, actual depth value=${this.zarrSource.getCoords().vertical[o]}, timeIdx=${n}`
2721
2769
  );
2722
- const c = this.vectorDerivation?.direction_variable ?? this.variableU, u = this.zarrSource.getChunksForBounds(
2723
- c,
2770
+ const l = this.vectorDerivation?.direction_variable ?? this.variableU, d = this.zarrSource.getChunksForBounds(
2771
+ l,
2724
2772
  n,
2725
2773
  o,
2726
2774
  r
2727
- ), l = this.zarrSource.getDimensions(c), d = l.indexOf("latitude"), f = l.indexOf("longitude");
2775
+ ), c = this.zarrSource.getDimensions(l), u = c.indexOf("latitude"), f = c.indexOf("longitude");
2728
2776
  let m = 0;
2729
- const p = u.length * 2, h = [], g = [];
2777
+ const p = d.length * 2, h = [], g = [];
2730
2778
  t?.(m, p);
2731
- const x = (w) => u.map(async (U) => {
2779
+ const x = (w) => d.map(async (V) => {
2732
2780
  const X = await this.zarrSource.fetchSpatialChunkResult(w, {
2733
- timeIndex: U.timeIdx,
2734
- verticalIndex: U.depthIdx,
2735
- latitudeChunkIndex: U.latIdx,
2736
- longitudeChunkIndex: U.lonIdx
2781
+ timeIndex: V.timeIdx,
2782
+ verticalIndex: V.depthIdx,
2783
+ latitudeChunkIndex: V.latIdx,
2784
+ longitudeChunkIndex: V.lonIdx
2737
2785
  });
2738
2786
  X.missing && (X.status != null && h.push(X.status), g.push(X.url)), m++, t?.(m, p);
2739
2787
  const oe = this.zarrSource.getChunkShape(w), le = oe[f];
2740
2788
  return {
2741
2789
  data: X.data,
2742
- latStart: U.latIdx * oe[d],
2743
- lonStart: U.lonIdx * le,
2744
- latSize: U.latSize,
2745
- lonSize: U.lonSize,
2790
+ latStart: V.latIdx * oe[u],
2791
+ lonStart: V.lonIdx * le,
2792
+ latSize: V.latSize,
2793
+ lonSize: V.lonSize,
2746
2794
  lonChunkSize: le
2747
2795
  };
2748
- }), [T, M] = this.vectorDerivation ? $i(
2796
+ }), [T, M] = this.vectorDerivation ? Hi(
2749
2797
  await Promise.all(
2750
2798
  x(this.vectorDerivation.direction_variable)
2751
2799
  ),
@@ -2756,7 +2804,7 @@ class D {
2756
2804
  ) : await Promise.all([
2757
2805
  Promise.all(x(this.variableU)),
2758
2806
  Promise.all(x(this.variableV))
2759
- ]), 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) => ({
2760
2808
  ...w,
2761
2809
  latStart: w.latStart - y,
2762
2810
  lonStart: w.lonStart - _
@@ -2764,21 +2812,21 @@ class D {
2764
2812
  ...w,
2765
2813
  latStart: w.latStart - y,
2766
2814
  lonStart: w.lonStart - _
2767
- })), P = this.zarrSource.getCoords(), L = Math.min(v - 1, P.latitude.length - 1), b = Math.min(S - 1, P.longitude.length - 1), A = {
2768
- west: P.longitude[_],
2769
- east: P.longitude[b],
2770
- south: Math.min(P.latitude[y], P.latitude[L]),
2771
- north: Math.max(P.latitude[y], P.latitude[L])
2772
- }, N = P.latitude[y] > P.latitude[L], C = Mt(
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(
2773
2821
  k,
2774
2822
  F,
2775
- R,
2776
2823
  E,
2824
+ R,
2777
2825
  A,
2778
2826
  N
2779
2827
  ), I = this.zarrSource.getValueDomain?.();
2780
- if (I != null && I > 0 && (C.uMin = -I, C.uMax = I, C.vMin = -I, C.vMax = I), !Gi(C.u, C.v))
2781
- throw new _e(
2828
+ if (I != null && I > 0 && (C.uMin = -I, C.uMax = I, C.vMin = -I, C.vMax = I), !qi(C.u, C.v))
2829
+ throw new xe(
2782
2830
  this.timeToMs(e),
2783
2831
  h,
2784
2832
  g
@@ -2804,12 +2852,12 @@ class D {
2804
2852
  else {
2805
2853
  const o = await this.fetchVelocityData(
2806
2854
  a,
2807
- (c, u) => {
2855
+ (l, d) => {
2808
2856
  t === this.generation && i === this.requestId && this.emit("status", {
2809
2857
  phase: "fetching",
2810
2858
  time: r,
2811
- completed: c,
2812
- total: u
2859
+ completed: l,
2860
+ total: d
2813
2861
  });
2814
2862
  }
2815
2863
  );
@@ -2825,7 +2873,7 @@ class D {
2825
2873
  const o = n instanceof Error ? n : new Error(String(n));
2826
2874
  console.error("[zartigl] Failed to load velocity:", o), t === this.generation && i === this.requestId && (this.emit(
2827
2875
  "status",
2828
- o instanceof _e ? Rt(o) : { phase: "error", time: r, error: o }
2876
+ o instanceof xe ? Lt(o) : { phase: "error", time: r, error: o }
2829
2877
  ), this.emit("error", o));
2830
2878
  }
2831
2879
  } finally {
@@ -2843,52 +2891,61 @@ class D {
2843
2891
  if (this.playback ? !r || !n : !this.initialized || !this.velocityField.hasData())
2844
2892
  return;
2845
2893
  n?.setFilter(this.simulation.renderMode !== "raster");
2846
- const o = n?.manifest.encoding.kind === "vector-luma" ? n.manifest.encoding.valueDomain : 0, c = n ? [-o, -o] : [this.velocityField.uMin, this.velocityField.vMin], u = 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 ? {
2847
2895
  west: n.bounds[0],
2848
2896
  south: n.bounds[1],
2849
2897
  east: n.bounds[2],
2850
2898
  north: n.bounds[3]
2851
- } : this.velocityField.geoBounds, d = r ? {
2899
+ } : this.velocityField.geoBounds, u = r ? {
2852
2900
  a: {
2853
2901
  unit: 1,
2854
- min: c,
2855
- max: u,
2902
+ min: l,
2903
+ max: d,
2856
2904
  physical: !0,
2857
2905
  northToSouth: !0
2858
2906
  },
2859
2907
  b: {
2860
2908
  unit: 4,
2861
- min: c,
2862
- max: u,
2909
+ min: l,
2910
+ max: d,
2863
2911
  physical: !0,
2864
2912
  northToSouth: !0
2865
2913
  },
2866
2914
  mix: r[2]
2867
- } : void 0, f = ze(i), m = r ? [1, 4].map((p) => (i.activeTexture(i.TEXTURE0 + p), i.getParameter(i.TEXTURE_BINDING_2D))) : [];
2915
+ } : void 0, f = Ge(i), m = r ? [1, 4].map((p) => (i.activeTexture(i.TEXTURE0 + p), i.getParameter(i.TEXTURE_BINDING_2D))) : [];
2868
2916
  try {
2869
2917
  const p = i.canvas;
2870
2918
  this.simulation.resize(p.width, p.height), i.bindFramebuffer(i.FRAMEBUFFER, f.framebuffer), r ? (i.activeTexture(i.TEXTURE1), i.bindTexture(i.TEXTURE_2D, r[0]), i.activeTexture(i.TEXTURE4), i.bindTexture(i.TEXTURE_2D, r[1])) : this.velocityField.bind(this.velocityTexUnit);
2871
- const h = this.map.getProjection?.()?.type === "globe", g = this.map.getBounds(), x = xi(g, h), T = Oe(g, h);
2919
+ const h = ye(this.map, t.defaultProjectionData);
2920
+ if (this.globeRendering !== null && this.globeRendering !== h) {
2921
+ if (this.globeRendering = h, !this.playback) {
2922
+ this.loadViewportVelocity({ resetParticles: !0 });
2923
+ return;
2924
+ }
2925
+ this.simulation.resetParticles();
2926
+ }
2927
+ this.globeRendering = h;
2928
+ const g = this.map.getBounds(), x = Ti(g, h), T = Be(g, h);
2872
2929
  i.disable(i.DEPTH_TEST), i.disable(i.STENCIL_TEST);
2873
2930
  const M = 512 * Math.pow(2, this.map.getZoom()), y = this.map.getCenter();
2874
2931
  this.simulation.render(
2875
2932
  this.velocityTexUnit,
2876
- c,
2877
- u,
2933
+ l,
2934
+ d,
2878
2935
  a,
2879
2936
  x,
2880
2937
  M,
2881
2938
  T,
2882
- l,
2939
+ c,
2883
2940
  h,
2884
- gi(y.lng, y.lat),
2941
+ xi(y.lng, y.lat),
2885
2942
  t.defaultProjectionData.clippingPlane,
2886
- ...d ? [d] : []
2943
+ ...u ? [u] : []
2887
2944
  );
2888
2945
  } finally {
2889
2946
  m.forEach((p, h) => {
2890
2947
  i.activeTexture(i.TEXTURE0 + (h === 0 ? 1 : 4)), i.bindTexture(i.TEXTURE_2D, p);
2891
- }), Ge(i, f);
2948
+ }), Oe(i, f);
2892
2949
  }
2893
2950
  if (this.pendingReadyTime != null) {
2894
2951
  const p = this.pendingReadyTime;
@@ -3010,7 +3067,7 @@ class D {
3010
3067
  this.simulation.setSpeed(e);
3011
3068
  }
3012
3069
  setFade(e) {
3013
- this.simulation.setFadeOpacity(We(e));
3070
+ this.simulation.setFadeOpacity(Xe(e));
3014
3071
  }
3015
3072
  setParticleDensity(e) {
3016
3073
  this.simulation.setParticleDensity(e);
@@ -3069,23 +3126,23 @@ class D {
3069
3126
  a(...t);
3070
3127
  }
3071
3128
  }
3072
- function $i(s, e, t) {
3129
+ function Hi(s, e, t) {
3073
3130
  const i = [], a = [];
3074
3131
  for (let r = 0; r < s.length; r++) {
3075
- const n = s[r], o = e[r], c = new Float32Array(n.data.length), u = new Float32Array(n.data.length);
3076
- for (let l = 0; l < n.data.length; l++) {
3077
- const d = Oi(
3078
- n.data[l],
3079
- 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],
3080
3137
  t
3081
3138
  );
3082
- c[l] = d.u, u[l] = d.v;
3139
+ l[c] = u.u, d[c] = u.v;
3083
3140
  }
3084
- i.push({ ...n, data: c }), a.push({ ...n, data: u });
3141
+ i.push({ ...n, data: l }), a.push({ ...n, data: d });
3085
3142
  }
3086
3143
  return [i, a];
3087
3144
  }
3088
- var Qe = `precision mediump float;
3145
+ var Ke = `precision mediump float;
3089
3146
 
3090
3147
  uniform sampler2D u_color;
3091
3148
  uniform sampler2D u_color_next;
@@ -3098,7 +3155,6 @@ uniform float u_log_scale;
3098
3155
  uniform float u_vibrance;
3099
3156
  uniform float u_mask_threshold;
3100
3157
  uniform vec2 u_color_domain;
3101
- uniform vec2 u_texel_size;
3102
3158
 
3103
3159
  varying vec2 v_geo_uv;
3104
3160
 
@@ -3124,9 +3180,8 @@ float geoVideoScalarValue(float r) {
3124
3180
  }
3125
3181
 
3126
3182
  void main() {
3127
- vec2 sourceUv = vec2(v_geo_uv.x, 1.0 - v_geo_uv.y);
3128
- vec2 halfTexel = 0.5 * u_texel_size;
3129
- vec2 uv = mix(halfTexel, vec2(1.0) - halfTexel, sourceUv);
3183
+
3184
+ vec2 uv = vec2(v_geo_uv.x, 1.0 - v_geo_uv.y);
3130
3185
  vec3 media = texture2D(u_color, uv).rgb;
3131
3186
  float alpha = texture2D(u_mask, uv).r;
3132
3187
  if (alpha <= u_mask_threshold) discard;
@@ -3147,7 +3202,7 @@ void main() {
3147
3202
  const Z = 128, te = 64;
3148
3203
  class G {
3149
3204
  constructor(e) {
3150
- this.type = "custom", this.renderingMode = "3d", this.map = null, this.gl = null, this.manifest = null, this.colorRampTexture = null, this.mercatorProgram = null, this.globeProgram = null, this.vertexBuffer = null, this.indexBuffer = null, this.indexCount = 0, this.abortController = null, this.listeners = /* @__PURE__ */ new Map(), this.id = e.id, this.source = e.manifest, this.opacity = e.opacity ?? 1, this.playback = new gt(
3205
+ this.type = "custom", this.renderingMode = "3d", this.map = null, this.gl = null, this.manifest = null, this.colorRampTexture = null, this.mercatorProgram = null, this.globeProgram = null, this.vertexBuffer = null, this.indexBuffer = null, this.indexCount = 0, this.abortController = null, this.listeners = /* @__PURE__ */ new Map(), this.id = e.id, this.source = e.manifest, this.opacity = e.opacity ?? 1, this.playback = new yt(
3151
3206
  e,
3152
3207
  () => this.map?.triggerRepaint(),
3153
3208
  (t, ...i) => this.emit(t, ...i)
@@ -3157,7 +3212,7 @@ class G {
3157
3212
  const i = K(t);
3158
3213
  this.map = e, this.gl = i, this.abortController = new AbortController(), this.emit("loading"), this.emit("status", { phase: "metadata" });
3159
3214
  try {
3160
- if (this.manifest = await Ae(
3215
+ if (this.manifest = await Ce(
3161
3216
  this.source,
3162
3217
  this.abortController.signal
3163
3218
  ), this.abortController?.signal.aborted || !this.map)
@@ -3189,75 +3244,84 @@ class G {
3189
3244
  const n = r.manifest;
3190
3245
  if (!a || !r.maskTexture)
3191
3246
  return;
3192
- const o = ze(i), c = [0, 1, 2, 3].map((u) => (i.activeTexture(i.TEXTURE0 + u), 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)));
3193
3248
  try {
3194
- const u = this.map?.getProjection?.()?.type === "globe", l = u ? this.globeProgram : this.mercatorProgram;
3195
- 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)
3196
3251
  return;
3197
- 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(
3198
- 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"),
3199
3254
  this.logScale ? 1 : 0
3200
- ), i.uniform1f(i.getUniformLocation(l, "u_vibrance"), this.vibrance), i.uniform1f(
3201
- 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"),
3202
3257
  n.mask.threshold
3203
3258
  );
3204
- const { codeRange: d, valueRange: f, transfer: m } = Zt(
3259
+ const { codeRange: u, valueRange: f, transfer: m } = Jt(
3205
3260
  n.encoding
3206
3261
  );
3207
3262
  i.uniform1f(
3208
- i.getUniformLocation(l, "u_scalar_transfer"),
3263
+ i.getUniformLocation(c, "u_scalar_transfer"),
3209
3264
  m
3210
3265
  );
3211
3266
  const p = this.colorDomain ?? f;
3212
3267
  i.uniform2f(
3213
- i.getUniformLocation(l, "u_code_range"),
3214
- ...d
3268
+ i.getUniformLocation(c, "u_code_range"),
3269
+ ...u
3215
3270
  ), i.uniform2f(
3216
- i.getUniformLocation(l, "u_value_range"),
3271
+ i.getUniformLocation(c, "u_value_range"),
3217
3272
  ...f
3218
3273
  ), i.uniform2f(
3219
- i.getUniformLocation(l, "u_color_domain"),
3274
+ i.getUniformLocation(c, "u_color_domain"),
3220
3275
  p[0],
3221
3276
  p[1]
3222
- ), i.uniform2f(
3223
- i.getUniformLocation(l, "u_texel_size"),
3224
- 1 / n.media.width,
3225
- 1 / n.media.height
3226
3277
  ), i.uniformMatrix4fv(
3227
- i.getUniformLocation(l, "u_matrix"),
3278
+ i.getUniformLocation(c, "u_matrix"),
3228
3279
  !1,
3229
3280
  t.modelViewProjectionMatrix instanceof Float32Array ? t.modelViewProjectionMatrix : new Float32Array(Array.from(t.modelViewProjectionMatrix))
3230
3281
  );
3231
3282
  const [h, g, x, T] = n.bounds, M = x < h ? x + 360 : x;
3232
3283
  if (i.uniform4f(
3233
- i.getUniformLocation(l, "u_geo_bounds"),
3284
+ i.getUniformLocation(c, "u_geo_bounds"),
3234
3285
  h,
3235
3286
  g,
3236
3287
  M,
3237
3288
  T
3238
- ), this.bindGrid(i, l), u) {
3289
+ ), this.bindGrid(i, c), d) {
3239
3290
  const y = t.defaultProjectionData.clippingPlane;
3240
3291
  i.uniform4f(
3241
- i.getUniformLocation(l, "u_clipping_plane"),
3292
+ i.getUniformLocation(c, "u_clipping_plane"),
3242
3293
  ...y
3294
+ ), vt(
3295
+ i,
3296
+ {
3297
+ u_projection_transition: i.getUniformLocation(
3298
+ c,
3299
+ "u_projection_transition"
3300
+ ),
3301
+ u_fallback_matrix: i.getUniformLocation(
3302
+ c,
3303
+ "u_fallback_matrix"
3304
+ )
3305
+ },
3306
+ t.defaultProjectionData
3243
3307
  ), i.drawElements(i.TRIANGLES, this.indexCount, i.UNSIGNED_SHORT, 0);
3244
3308
  } else {
3245
3309
  const y = 512 * Math.pow(2, this.map.getZoom());
3246
- i.uniform1f(i.getUniformLocation(l, "u_world_size"), y);
3247
- for (const v of Oe(
3310
+ i.uniform1f(i.getUniformLocation(c, "u_world_size"), y);
3311
+ for (const v of Be(
3248
3312
  this.map.getBounds(),
3249
3313
  !1
3250
3314
  ))
3251
3315
  i.uniform1f(
3252
- i.getUniformLocation(l, "u_world_offset"),
3316
+ i.getUniformLocation(c, "u_world_offset"),
3253
3317
  v
3254
3318
  ), i.drawElements(i.TRIANGLES, this.indexCount, i.UNSIGNED_SHORT, 0);
3255
3319
  }
3256
- this.unbindGrid(i, l);
3320
+ this.unbindGrid(i, c);
3257
3321
  } finally {
3258
- c.forEach((u, l) => {
3259
- i.activeTexture(i.TEXTURE0 + l), i.bindTexture(i.TEXTURE_2D, u);
3260
- }), Ge(i, o);
3322
+ l.forEach((d, c) => {
3323
+ i.activeTexture(i.TEXTURE0 + c), i.bindTexture(i.TEXTURE_2D, d);
3324
+ }), Oe(i, o);
3261
3325
  }
3262
3326
  }
3263
3327
  onRemove() {
@@ -3296,7 +3360,7 @@ class G {
3296
3360
  setColorRamp(e) {
3297
3361
  this.colorRamp = e, this.gl && (this.colorRampTexture && this.gl.deleteTexture(this.colorRampTexture), this.colorRampTexture = ge(
3298
3362
  this.gl,
3299
- Ce(e)
3363
+ ke(e)
3300
3364
  )), this.map?.triggerRepaint();
3301
3365
  }
3302
3366
  setLogScale(e) {
@@ -3336,7 +3400,7 @@ class G {
3336
3400
  id: this.id,
3337
3401
  initialized: !!e?.currentPair,
3338
3402
  playing: this.playback.isPlaying(),
3339
- 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,
3340
3404
  manifestId: this.manifest?.id,
3341
3405
  mediaUrl: this.manifest?.media.url,
3342
3406
  preloadedMediaUrl: this.playback.preloadedMediaUrl,
@@ -3360,24 +3424,24 @@ class G {
3360
3424
  return this.listeners.get(e)?.delete(t), this;
3361
3425
  }
3362
3426
  initGl(e) {
3363
- this.mercatorProgram = W(e, bt, Qe), this.globeProgram = W(e, St, Qe), this.colorRampTexture = ge(
3427
+ this.mercatorProgram = W(e, Tt, Ke), this.globeProgram = W(e, Mt, Ke), this.colorRampTexture = ge(
3364
3428
  e,
3365
- Ce(this.colorRamp)
3429
+ ke(this.colorRamp)
3366
3430
  );
3367
3431
  const t = new Float32Array(
3368
3432
  (Z + 1) * (te + 1) * 2
3369
3433
  );
3370
3434
  let i = 0;
3371
3435
  for (let o = 0; o <= te; o++)
3372
- for (let c = 0; c <= Z; c++)
3373
- 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;
3374
3438
  const a = new Uint16Array(Z * te * 6);
3375
3439
  let r = 0;
3376
3440
  const n = Z + 1;
3377
3441
  for (let o = 0; o < te; o++)
3378
- for (let c = 0; c < Z; c++) {
3379
- const u = o * n + c, l = u + 1, d = u + n, f = d + 1;
3380
- a[r++] = u, a[r++] = d, a[r++] = l, a[r++] = l, a[r++] = d, 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;
3381
3445
  }
3382
3446
  if (this.vertexBuffer = e.createBuffer(), this.indexBuffer = e.createBuffer(), !this.vertexBuffer || !this.indexBuffer)
3383
3447
  throw new Error("Failed to create GeoVideo grid");
@@ -3395,28 +3459,28 @@ class G {
3395
3459
  i(...t);
3396
3460
  }
3397
3461
  }
3398
- function Be(s) {
3462
+ function $e(s) {
3399
3463
  return typeof s == "string" ? s : new Date(s).toISOString();
3400
3464
  }
3401
3465
  function j(s) {
3402
3466
  return encodeURIComponent(String(s));
3403
3467
  }
3404
- function Pt(s, e) {
3468
+ function Dt(s, e) {
3405
3469
  return e === "depth" ? -Math.abs(s) : s;
3406
3470
  }
3407
- function qi(s) {
3471
+ function Yi(s) {
3408
3472
  let e = s.template.replace(/\{TileMatrix\}/gi, "{z}").replace(/\{TileRow\}/gi, "{y}").replace(/\{TileCol\}/gi, "{x}");
3409
3473
  return s.tileMatrixSet != null && (e = e.replace(
3410
3474
  /\{TileMatrixSet\}/gi,
3411
3475
  j(s.tileMatrixSet)
3412
- )), s.style != null && (e = e.replace(/\{Style\}/gi, j(s.style))), s.time != null && (e = e.replace(/\{time\}/gi, j(Be(s.time)))), s.depth != null && (e = e.replace(
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(
3413
3477
  /\{elevation\}/gi,
3414
- j(Pt(s.depth, s.verticalLabel))
3478
+ j(Dt(s.depth, s.verticalLabel))
3415
3479
  )), [...e.matchAll(/\{([^{}]+)\}/g)].some(
3416
3480
  (t) => !/^(?:z|y|x)$/i.test(t[1])
3417
3481
  ) ? void 0 : e;
3418
3482
  }
3419
- function Ke(s) {
3483
+ function Je(s) {
3420
3484
  const e = [
3421
3485
  ["SERVICE", "WMTS"],
3422
3486
  ["VERSION", "1.0.0"],
@@ -3428,16 +3492,16 @@ function Ke(s) {
3428
3492
  ["TILEROW", "{y}"],
3429
3493
  ["TILECOL", "{x}"]
3430
3494
  ];
3431
- s.style && e.push(["STYLE", s.style]), s.time != null && e.push(["time", Be(s.time)]), s.depth != null && e.push([
3495
+ s.style && e.push(["STYLE", s.style]), s.time != null && e.push(["time", $e(s.time)]), s.depth != null && e.push([
3432
3496
  "elevation",
3433
- String(Pt(s.depth, s.verticalLabel))
3497
+ String(Dt(s.depth, s.verticalLabel))
3434
3498
  ]);
3435
3499
  const t = e.map(
3436
3500
  ([i, a]) => `${i}=${a.startsWith("{") ? a : j(a)}`
3437
3501
  ).join("&");
3438
3502
  return `${s.baseUrl}?${t}`;
3439
3503
  }
3440
- function Wi(s) {
3504
+ function Zi(s) {
3441
3505
  const e = [
3442
3506
  ["SERVICE", "WMTS"],
3443
3507
  ["REQUEST", "GetLegend"],
@@ -3446,38 +3510,38 @@ function Wi(s) {
3446
3510
  ];
3447
3511
  return s.style && e.push(["STYLE", s.style]), `${s.baseUrl}?${e.map(([t, i]) => `${t}=${j(i)}`).join("&")}`;
3448
3512
  }
3449
- function Xi(s) {
3513
+ function ji(s) {
3450
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";
3451
3515
  }
3452
- function Hi(s) {
3516
+ function Qi(s) {
3453
3517
  return s.variables.kind === "scalar" ? s.variables.value : "scalar";
3454
3518
  }
3455
- function Yi(s) {
3519
+ function Ki(s) {
3456
3520
  return s.variables.kind === "vector" ? s.variables.u ?? "uo" : "uo";
3457
3521
  }
3458
- function Zi(s) {
3522
+ function Ji(s) {
3459
3523
  return s.variables.kind === "vector" ? s.variables.v ?? "vo" : "vo";
3460
3524
  }
3461
- function ji(s) {
3525
+ function ea(s) {
3462
3526
  return s.variables.kind === "vector" ? s.variables.derivation : void 0;
3463
3527
  }
3464
- class Qi {
3528
+ class ta {
3465
3529
  constructor(e) {
3466
- 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 = Xi(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") {
3467
3531
  const t = e.sourceConfig;
3468
- this.delegate = new D({
3532
+ this.delegate = new P({
3469
3533
  ...e,
3470
3534
  source: t.endpoints.field,
3471
3535
  zarrSource: e.zarrSource,
3472
- variableU: Yi(t),
3473
- variableV: Zi(t),
3474
- vectorDerivation: ji(t),
3536
+ variableU: Ki(t),
3537
+ variableV: Ji(t),
3538
+ vectorDerivation: ea(t),
3475
3539
  unit: e.unit ?? ""
3476
3540
  });
3477
3541
  } else if (this.backend === "vector-geovideo") {
3478
3542
  if (!e.geoVideoManifest)
3479
3543
  throw new Error("Vector GeoVideo requires a loaded manifest");
3480
- this.delegate = new D({
3544
+ this.delegate = new P({
3481
3545
  ...e,
3482
3546
  source: e.geoVideoManifest.media.url,
3483
3547
  geoVideo: {
@@ -3498,7 +3562,7 @@ class Qi {
3498
3562
  id: e.id,
3499
3563
  source: t.endpoints.field,
3500
3564
  zarrSource: e.zarrSource,
3501
- variable: Hi(t),
3565
+ variable: Qi(t),
3502
3566
  time: e.time,
3503
3567
  depth: e.depth,
3504
3568
  colorRamp: e.colorRamp,
@@ -3529,7 +3593,7 @@ class Qi {
3529
3593
  vibrance: e.vibrance
3530
3594
  });
3531
3595
  }
3532
- 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) => {
3533
3597
  this.time = t;
3534
3598
  });
3535
3599
  }
@@ -3617,16 +3681,16 @@ class Qi {
3617
3681
  }
3618
3682
  }
3619
3683
  setSpeed(e) {
3620
- this.delegate instanceof D && this.delegate.setSpeed(e);
3684
+ this.delegate instanceof P && this.delegate.setSpeed(e);
3621
3685
  }
3622
3686
  setFade(e) {
3623
- this.delegate instanceof D && this.delegate.setFade(e);
3687
+ this.delegate instanceof P && this.delegate.setFade(e);
3624
3688
  }
3625
3689
  setParticleDensity(e) {
3626
- this.delegate instanceof D && this.delegate.setParticleDensity(e);
3690
+ this.delegate instanceof P && this.delegate.setParticleDensity(e);
3627
3691
  }
3628
3692
  setRenderMode(e) {
3629
- this.delegate instanceof D && this.delegate.setRenderMode(e);
3693
+ this.delegate instanceof P && this.delegate.setRenderMode(e);
3630
3694
  }
3631
3695
  setRgba8MaxParticleZoom(e) {
3632
3696
  this.delegate?.setRgba8MaxParticleZoom(e);
@@ -3642,34 +3706,34 @@ class Qi {
3642
3706
  this.map?.getLayer(this.rasterLayerId) && this.map.setPaintProperty(this.rasterLayerId, "raster-opacity", e);
3643
3707
  }
3644
3708
  setLogScale(e) {
3645
- 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);
3646
3710
  }
3647
3711
  setVibrance(e) {
3648
3712
  this.delegate?.setVibrance(e);
3649
3713
  }
3650
3714
  /** Particle trails only; rasters ignore it. */
3651
3715
  setColorGrade(e) {
3652
- this.delegate instanceof D && this.delegate.setColorGrade(e);
3716
+ this.delegate instanceof P && this.delegate.setColorGrade(e);
3653
3717
  }
3654
3718
  /** Under particle trails only; rasters ignore it. */
3655
3719
  setBackdrop(e) {
3656
- this.delegate instanceof D && this.delegate.setBackdrop(e);
3720
+ this.delegate instanceof P && this.delegate.setBackdrop(e);
3657
3721
  }
3658
3722
  /** Particle trails only; rasters ignore it. */
3659
3723
  setGlow(e) {
3660
- this.delegate instanceof D && this.delegate.setGlow(e);
3724
+ this.delegate instanceof P && this.delegate.setGlow(e);
3661
3725
  }
3662
3726
  setColorDomain(e) {
3663
3727
  this.delegate instanceof me && this.delegate.setColorDomain(e), this.delegate instanceof G && this.delegate.setColorDomain(e);
3664
3728
  }
3665
3729
  async play() {
3666
- (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();
3667
3731
  }
3668
3732
  pause() {
3669
- (this.delegate instanceof G || this.delegate instanceof D) && this.delegate.pause();
3733
+ (this.delegate instanceof G || this.delegate instanceof P) && this.delegate.pause();
3670
3734
  }
3671
3735
  setLoop(e) {
3672
- (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);
3673
3737
  }
3674
3738
  /** Media rate multiplier of a scalar GeoVideo. */
3675
3739
  setPlaybackRate(e) {
@@ -3677,21 +3741,21 @@ class Qi {
3677
3741
  }
3678
3742
  /** Cadence of the continuous vector GeoVideo clock. */
3679
3743
  setStepsPerSecond(e) {
3680
- this.delegate instanceof D && this.delegate.setStepsPerSecond(e);
3744
+ this.delegate instanceof P && this.delegate.setStepsPerSecond(e);
3681
3745
  }
3682
3746
  setTimeRange(e) {
3683
- (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);
3684
3748
  }
3685
3749
  /**
3686
3750
  * Move a GeoVideo to another artifact, such as the next archive
3687
3751
  * chunk, without rebuilding the map layer. False when a new layer is needed.
3688
3752
  */
3689
3753
  replaceGeoVideoManifest(e, t) {
3690
- 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);
3691
3755
  }
3692
3756
  /** Load the GeoVideo artifact expected next, such as the next archive chunk. */
3693
3757
  preloadGeoVideoManifest(e, t) {
3694
- 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);
3695
3759
  }
3696
3760
  async samplePoint(e) {
3697
3761
  if (this.delegate instanceof me)
@@ -3708,14 +3772,14 @@ class Qi {
3708
3772
  return;
3709
3773
  this.removeWmts();
3710
3774
  const e = this.options.sourceConfig, t = e.tileUrlTemplate ? [
3711
- qi({
3775
+ Yi({
3712
3776
  template: e.tileUrlTemplate,
3713
3777
  tileMatrixSet: e.tileMatrixSet,
3714
3778
  style: e.style,
3715
3779
  time: this.time,
3716
3780
  depth: this.depth,
3717
3781
  verticalLabel: this.options.verticalLabel
3718
- }) ?? Ke({
3782
+ }) ?? Je({
3719
3783
  baseUrl: e.baseUrl ?? new URL(e.capabilitiesUrl).origin,
3720
3784
  layer: e.layer,
3721
3785
  tileMatrixSet: e.tileMatrixSet ?? "EPSG:3857",
@@ -3726,7 +3790,7 @@ class Qi {
3726
3790
  verticalLabel: this.options.verticalLabel
3727
3791
  })
3728
3792
  ] : [
3729
- Ke({
3793
+ Je({
3730
3794
  baseUrl: e.baseUrl ?? new URL(e.capabilitiesUrl).origin,
3731
3795
  layer: e.layer,
3732
3796
  tileMatrixSet: e.tileMatrixSet ?? "EPSG:3857",
@@ -3760,7 +3824,7 @@ class Qi {
3760
3824
  min: 0,
3761
3825
  max: 0,
3762
3826
  unit: this.options.unit ?? "",
3763
- time: Be(this.time),
3827
+ time: $e(this.time),
3764
3828
  depth: this.depth
3765
3829
  }), this.emit("status", { phase: "ready", time: e });
3766
3830
  }
@@ -3779,19 +3843,19 @@ class Qi {
3779
3843
  return i && this.map?.getLayer(i) ? i : void 0;
3780
3844
  }
3781
3845
  }
3782
- function Re(s, e) {
3846
+ function Pe(s, e) {
3783
3847
  return s.match(new RegExp(`\\b${e}=["']([^"']+)["']`, "i"))?.[1].replace(/&amp;/g, "&").replace(/&quot;/g, '"').replace(/&apos;/g, "'");
3784
3848
  }
3785
- function Ki(s, e, t) {
3849
+ function ia(s, e, t) {
3786
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);
3787
3851
  return [...a.matchAll(/\{([^{}]+)\}/g)].some(
3788
3852
  (n) => !/^(?:z|y|x|Time|Elevation)$/i.test(n[1])
3789
3853
  ) ? void 0 : a;
3790
3854
  }
3791
- function Et(s) {
3855
+ function At(s) {
3792
3856
  return s.replace(/<[^>]+>/g, "").trim();
3793
3857
  }
3794
- function xe(s, e) {
3858
+ function be(s, e) {
3795
3859
  const t = new RegExp(
3796
3860
  `<(?:(?:\\w+):)?${e}\\b[^>]*>([\\s\\S]*?)<\\/(?:(?:\\w+):)?${e}>`,
3797
3861
  "gi"
@@ -3799,30 +3863,30 @@ function xe(s, e) {
3799
3863
  return [...s.matchAll(t)].map((i) => i[1]);
3800
3864
  }
3801
3865
  function se(s, e) {
3802
- return xe(s, e).map(Et).find(Boolean);
3866
+ return be(s, e).map(At).find(Boolean);
3803
3867
  }
3804
- function Je(s, e) {
3868
+ function et(s, e) {
3805
3869
  const t = e.match(
3806
3870
  /^P(?:(\d+)Y)?(?:(\d+)M)?(?:(\d+)D)?(?:T(?:(\d+)H)?(?:(\d+)M)?(?:(\d+)S)?)?$/
3807
3871
  );
3808
3872
  if (!t || !t.slice(1).some((m) => Number(m) > 0))
3809
3873
  return;
3810
- 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(), u = i.getUTCSeconds(), l = i.getUTCMilliseconds(), d = new Date(
3811
- Date.UTC(a, r, 1, o, c, u, 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)
3812
3876
  ), f = new Date(
3813
- Date.UTC(d.getUTCFullYear(), d.getUTCMonth() + 1, 0)
3877
+ Date.UTC(u.getUTCFullYear(), u.getUTCMonth() + 1, 0)
3814
3878
  ).getUTCDate();
3815
- return d.setUTCDate(Math.min(n, f)), d.setUTCDate(d.getUTCDate() + Number(t[3] ?? 0)), d.setUTCHours(d.getUTCHours() + Number(t[4] ?? 0)), d.setUTCMinutes(d.getUTCMinutes() + Number(t[5] ?? 0)), d.setUTCSeconds(d.getUTCSeconds() + Number(t[6] ?? 0)), d.getTime();
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();
3816
3880
  }
3817
- function Ji(s) {
3881
+ function aa(s) {
3818
3882
  const e = [];
3819
3883
  for (const t of s.flatMap((i) => i.split(","))) {
3820
3884
  const i = t.trim().split("/");
3821
3885
  if (i.length === 3) {
3822
- const r = Date.parse(i[0]), n = Date.parse(i[1]), o = Je(r, i[2]);
3886
+ const r = Date.parse(i[0]), n = Date.parse(i[1]), o = et(r, i[2]);
3823
3887
  if (Number.isFinite(r) && Number.isFinite(n) && o && o > r)
3824
- for (let c = r, u = 0; c <= n && u < 1e5; u += 1)
3825
- e.push(c), c = Je(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]);
3826
3890
  continue;
3827
3891
  }
3828
3892
  const a = Date.parse(t.trim());
@@ -3830,14 +3894,14 @@ function Ji(s) {
3830
3894
  }
3831
3895
  return [...new Set(e)].sort((t, i) => t - i);
3832
3896
  }
3833
- function et(s, e) {
3834
- for (const t of xe(s, "Dimension"))
3897
+ function tt(s, e) {
3898
+ for (const t of be(s, "Dimension"))
3835
3899
  if (se(t, "Identifier")?.toLowerCase() === e.toLowerCase())
3836
- return xe(t, "Value").map(Et);
3900
+ return be(t, "Value").map(At);
3837
3901
  return [];
3838
3902
  }
3839
- function ea(s, e) {
3840
- const t = xe(s, "Layer").find(
3903
+ function sa(s, e) {
3904
+ const t = be(s, "Layer").find(
3841
3905
  (h) => se(h, "Identifier") === e.layer
3842
3906
  );
3843
3907
  if (!t)
@@ -3845,7 +3909,7 @@ function ea(s, e) {
3845
3909
  const i = e.tileMatrixSet ?? se(t, "TileMatrixSet") ?? "";
3846
3910
  if (!/3857|GoogleMapsCompatible/i.test(i))
3847
3911
  throw new Error(`Unsupported WMTS tile matrix set: ${i || "missing"}`);
3848
- const a = Ji(et(t, "time")), r = a.length ? {
3912
+ const a = aa(tt(t, "time")), r = a.length ? {
3849
3913
  min: a[0],
3850
3914
  max: a[a.length - 1],
3851
3915
  size: a.length,
@@ -3854,22 +3918,22 @@ function ea(s, e) {
3854
3918
  step: a.length > 1 && a.every(
3855
3919
  (h, g) => g === 0 || h - a[g - 1] === a[1] - a[0]
3856
3920
  ) ? a[1] - a[0] : void 0
3857
- } : { min: 0, max: 0, size: 1, values: [0], units: "static" }, n = et(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(
3858
3922
  /GetTile[\s\S]*?(?:xlink:href|href)=["']([^"']+)/i
3859
- )?.[1], l = [
3923
+ )?.[1], c = [
3860
3924
  ...t.matchAll(/<(?:(?:\w+):)?ResourceURL\b([^>]*)\/?\s*>/gi)
3861
3925
  ].find(
3862
- (h) => Re(h[1], "resourceType")?.toLowerCase() === "tile"
3863
- ), d = l ? Re(l[1], "template") : void 0, f = [
3926
+ (h) => Pe(h[1], "resourceType")?.toLowerCase() === "tile"
3927
+ ), u = c ? Pe(c[1], "template") : void 0, f = [
3864
3928
  ...t.matchAll(
3865
3929
  /<(?:(?:\w+):)?Style\b([^>]*)>([\s\S]*?)<\/(?:(?:\w+):)?Style>/gi
3866
3930
  )
3867
3931
  ], m = f.find(
3868
- (h) => Re(h[1], "isDefault")?.toLowerCase() === "true"
3932
+ (h) => Pe(h[1], "isDefault")?.toLowerCase() === "true"
3869
3933
  ), p = e.style ?? se(m?.[2] ?? f[0]?.[2] ?? "", "Identifier");
3870
3934
  return {
3871
- baseUrl: e.baseUrl ?? c ?? new URL(e.capabilitiesUrl).origin,
3872
- tileUrlTemplate: e.tileUrlTemplate ?? (d ? Ki(d, 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),
3873
3937
  tileMatrixSet: i,
3874
3938
  format: e.format ?? se(t, "Format") ?? "image/png",
3875
3939
  style: p,
@@ -3877,15 +3941,15 @@ function ea(s, e) {
3877
3941
  vertical: o
3878
3942
  };
3879
3943
  }
3880
- async function ta(s, e) {
3944
+ async function ra(s, e) {
3881
3945
  const t = await fetch(s.capabilitiesUrl, { signal: e });
3882
3946
  if (!t.ok)
3883
3947
  throw new Error(
3884
3948
  `WMTS capabilities request failed (${t.status}): ${s.capabilitiesUrl}`
3885
3949
  );
3886
- return ea(await t.text(), s);
3950
+ return sa(await t.text(), s);
3887
3951
  }
3888
- const ia = [
3952
+ const na = [
3889
3953
  0.25,
3890
3954
  0.5,
3891
3955
  1,
@@ -3894,8 +3958,8 @@ const ia = [
3894
3958
  8,
3895
3959
  16,
3896
3960
  32
3897
- ], tt = [0.25, 0.5, 1, 2];
3898
- function it(s, e) {
3961
+ ], it = [0.25, 0.5, 1, 2];
3962
+ function at(s, e) {
3899
3963
  if (s.length === 0)
3900
3964
  return e;
3901
3965
  let t = s[0], i;
@@ -3903,8 +3967,8 @@ function it(s, e) {
3903
3967
  a < t && (t = a), a <= e && (i === void 0 || a > i) && (i = a);
3904
3968
  return i ?? t;
3905
3969
  }
3906
- function aa(s) {
3907
- 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 = [
3908
3972
  (n) => n.getUTCHours(),
3909
3973
  (n) => n.getUTCMinutes(),
3910
3974
  (n) => n.getUTCSeconds(),
@@ -3915,7 +3979,7 @@ function aa(s) {
3915
3979
  return "year";
3916
3980
  if (t([(o) => o.getUTCDate(), ...i]))
3917
3981
  return "month";
3918
- const n = s.slice(1).map((o, c) => o - s[c]);
3982
+ const n = s.slice(1).map((o, l) => o - s[l]);
3919
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";
3920
3984
  }
3921
3985
  const a = e[0];
@@ -3924,7 +3988,7 @@ function aa(s) {
3924
3988
  const r = a.getUTCHours() === 0 && a.getUTCMinutes() === 0 && a.getUTCSeconds() === 0 && a.getUTCMilliseconds() === 0;
3925
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";
3926
3990
  }
3927
- function Lt(s) {
3991
+ function Ct(s) {
3928
3992
  if (s.length < 2)
3929
3993
  return;
3930
3994
  const e = s[1] - s[0];
@@ -3933,7 +3997,7 @@ function Lt(s) {
3933
3997
  ) ? e : void 0;
3934
3998
  }
3935
3999
  function re(s, e) {
3936
- return e ? yt(e, [
4000
+ return e ? xt(e, [
3937
4001
  s.values[0],
3938
4002
  s.values[s.values.length - 1]
3939
4003
  ]) : null;
@@ -3952,11 +4016,11 @@ function ne(s, e) {
3952
4016
  min: r[0],
3953
4017
  max: r[r.length - 1],
3954
4018
  size: r.length,
3955
- step: Lt(r),
4019
+ step: Ct(r),
3956
4020
  values: r
3957
4021
  };
3958
4022
  }
3959
- function at(s, e) {
4023
+ function st(s, e) {
3960
4024
  const { start: t, end: i } = s.temporal ?? {};
3961
4025
  return t || i ? ne(e, { start: t, end: i }) : e;
3962
4026
  }
@@ -3966,20 +4030,20 @@ function fe(s) {
3966
4030
  s.variables.derivation.magnitude_variable
3967
4031
  ] : [s.variables.u ?? "uo", s.variables.v ?? "vo"];
3968
4032
  }
3969
- function Pe(s, e) {
3970
- const t = s.sources.filter(ke);
4033
+ function Ee(s, e) {
4034
+ const t = s.sources.filter(Fe);
3971
4035
  return t.find((i) => i.id === e) ?? (e === "geovideo" || e === "auto" ? t[0] : void 0);
3972
4036
  }
3973
- function Dt(s) {
4037
+ function kt(s) {
3974
4038
  return [...s].sort((e, t) => {
3975
4039
  const i = Math.abs(e), a = Math.abs(t);
3976
4040
  return i !== a ? i - a : t - e;
3977
4041
  });
3978
4042
  }
3979
- function Ee(s, e) {
3980
- return s?.values.length ? e == null ? Dt(s.values)[0] : V(s.values, e) : e ?? 0;
4043
+ function Le(s, e) {
4044
+ return s?.values.length ? e == null ? kt(s.values)[0] : U(s.values, e) : e ?? 0;
3981
4045
  }
3982
- function V(s, e) {
4046
+ function U(s, e) {
3983
4047
  if (s.length === 0)
3984
4048
  return e;
3985
4049
  let t = s[0], i = Math.abs(t - e);
@@ -3989,7 +4053,7 @@ function V(s, e) {
3989
4053
  }
3990
4054
  return t;
3991
4055
  }
3992
- function st(s) {
4056
+ function rt(s) {
3993
4057
  for (const [e, t] of [
3994
4058
  [s?.playbackRate, "Playback rate"],
3995
4059
  [s?.stepsPerSecond, "Steps per second"]
@@ -3997,14 +4061,14 @@ function st(s) {
3997
4061
  if (e != null && (!Number.isFinite(e) || e <= 0))
3998
4062
  throw new Error(`${t} must be positive`);
3999
4063
  }
4000
- function rt(s, e) {
4001
- const t = s.surface?.value ?? 0, i = V(
4064
+ function nt(s, e) {
4065
+ const t = s.surface?.value ?? 0, i = U(
4002
4066
  [t, ...s.depths.map((a) => a.value)],
4003
4067
  e
4004
4068
  );
4005
4069
  return i === t ? null : i;
4006
4070
  }
4007
- function sa(s) {
4071
+ function la(s) {
4008
4072
  const e = s.surface ?? s.depths[0];
4009
4073
  return {
4010
4074
  name: e.name,
@@ -4016,24 +4080,24 @@ function sa(s) {
4016
4080
  ]
4017
4081
  };
4018
4082
  }
4019
- function nt(s, e) {
4083
+ function ot(s, e) {
4020
4084
  return JSON.stringify([
4021
4085
  s?.values ?? null,
4022
4086
  e ? [e.name, e.units, e.values] : null
4023
4087
  ]);
4024
4088
  }
4025
- function ra(s) {
4089
+ function ca(s) {
4026
4090
  const e = [...new Set(s)].sort((t, i) => t - i);
4027
4091
  return {
4028
4092
  min: e[0],
4029
4093
  max: e[e.length - 1],
4030
- step: Lt(e),
4094
+ step: Ct(e),
4031
4095
  size: e.length,
4032
4096
  units: "milliseconds since 1970-01-01T00:00:00Z",
4033
4097
  values: e
4034
4098
  };
4035
4099
  }
4036
- const na = 5 * 6e4, oa = 6e4, ot = 6;
4100
+ const ha = 5 * 6e4, ua = 6e4, lt = 6;
4037
4101
  function pe(s) {
4038
4102
  const { particles: e = {}, raster: t = {} } = s, i = {
4039
4103
  palette: s.palette,
@@ -4043,7 +4107,7 @@ function pe(s) {
4043
4107
  speed: e.speed,
4044
4108
  fade: e.fade,
4045
4109
  glow: e.glow,
4046
- colorGrade: e.grade === void 0 ? void 0 : ui(e.grade),
4110
+ colorGrade: e.grade === void 0 ? void 0 : pi(e.grade),
4047
4111
  opacity: t.opacity,
4048
4112
  logScale: t.logScale,
4049
4113
  vibrance: t.vibrance,
@@ -4061,25 +4125,25 @@ function Ue(s) {
4061
4125
  const e = s.alphaFadeLow ?? 0, t = s.alphaFadeHigh ?? 0;
4062
4126
  return e > 0 || t > 0 ? { low: e, high: t, curve: s.alphaFadeCurve ?? "linear" } : void 0;
4063
4127
  }
4064
- const lt = "rdylbu", la = new Set(
4065
- vt({ includeDeprecated: !0 }).map((s) => s.id)
4066
- ), ct = /* @__PURE__ */ new Set();
4067
- function Ve(s) {
4068
- return typeof s != "string" || la.has(s) ? s : (ct.has(s) || (ct.add(s), console.warn(
4069
- `[zartigl] palette "${s}" is not in this version: drawn with "${lt}"`
4070
- )), lt);
4128
+ const ct = "rdylbu", da = new Set(
4129
+ _t({ includeDeprecated: !0 }).map((s) => s.id)
4130
+ ), ht = /* @__PURE__ */ new Set();
4131
+ function Ne(s) {
4132
+ return typeof s != "string" || da.has(s) ? s : (ht.has(s) || (ht.add(s), console.warn(
4133
+ `[zartigl] palette "${s}" is not in this version: drawn with "${ct}"`
4134
+ )), ct);
4071
4135
  }
4072
- function Le(s) {
4073
- const { reversePalette: e } = s, t = Ve(s.palette), i = Ue(s);
4074
- return t != null && (e || i) ? Ce(t, { reverse: e, alphaFade: i }) : t;
4136
+ function De(s) {
4137
+ const { reversePalette: e } = s, t = Ne(s.palette), i = Ue(s);
4138
+ return t != null && (e || i) ? ke(t, { reverse: e, alphaFade: i }) : t;
4075
4139
  }
4076
- const ca = [
4140
+ const ma = [
4077
4141
  "palette",
4078
4142
  "reversePalette",
4079
4143
  "alphaFadeLow",
4080
4144
  "alphaFadeHigh",
4081
4145
  "alphaFadeCurve"
4082
- ], At = Object.freeze({
4146
+ ], Ft = Object.freeze({
4083
4147
  palette: "style.palette",
4084
4148
  renderMode: "style.renderMode",
4085
4149
  particleDensity: "style.particles.density",
@@ -4092,7 +4156,7 @@ const ca = [
4092
4156
  colorDomain: "style.raster.colorDomain",
4093
4157
  backdrop: "style.particles.backdrop"
4094
4158
  });
4095
- function De(s) {
4159
+ function Ae(s) {
4096
4160
  const {
4097
4161
  palette: e,
4098
4162
  renderMode: t,
@@ -4101,13 +4165,13 @@ function De(s) {
4101
4165
  fade: r,
4102
4166
  colorGrade: n,
4103
4167
  opacity: o,
4104
- logScale: c,
4105
- vibrance: u,
4106
- colorDomain: l,
4107
- backdrop: d,
4168
+ logScale: l,
4169
+ vibrance: d,
4170
+ colorDomain: c,
4171
+ backdrop: u,
4108
4172
  ...f
4109
4173
  } = s ?? {}, m = Object.keys(s ?? {}).filter(
4110
- (h) => h in At && s[h] !== void 0
4174
+ (h) => h in Ft && s[h] !== void 0
4111
4175
  );
4112
4176
  return {
4113
4177
  style: ae({
@@ -4117,47 +4181,47 @@ function De(s) {
4117
4181
  density: i,
4118
4182
  speed: a,
4119
4183
  fade: r,
4120
- grade: n && hi(n),
4121
- backdrop: d
4184
+ grade: n && fi(n),
4185
+ backdrop: u
4122
4186
  },
4123
- raster: { opacity: o, logScale: c, vibrance: u, colorDomain: l }
4187
+ raster: { opacity: o, logScale: l, vibrance: d, colorDomain: c }
4124
4188
  }),
4125
4189
  settings: e === void 0 || typeof e == "string" ? f : { ...f, palette: e },
4126
4190
  legacyKeys: m
4127
4191
  };
4128
4192
  }
4129
- const ht = /* @__PURE__ */ new Set();
4130
- function ut(s) {
4193
+ const ut = /* @__PURE__ */ new Set();
4194
+ function dt(s) {
4131
4195
  for (const e of s)
4132
- ht.has(e) || (ht.add(e), console.warn(
4133
- `[zartigl] settings.${e} is deprecated: use ${At[e]}`
4196
+ ut.has(e) || (ut.add(e), console.warn(
4197
+ `[zartigl] settings.${e} is deprecated: use ${Ft[e]}`
4134
4198
  ));
4135
4199
  }
4136
- function Ct(s, e) {
4137
- const t = Ne(s, e);
4200
+ function It(s, e) {
4201
+ const t = ze(s, e);
4138
4202
  return {
4139
4203
  ...pe(t),
4140
4204
  palette: t.palette ?? "rdylbu",
4141
4205
  colorDomain: Q(t.raster.colorDomain)
4142
4206
  };
4143
4207
  }
4144
- function ha(s) {
4208
+ function fa(s) {
4145
4209
  return {
4146
- ...Ct(s),
4210
+ ...It(s),
4147
4211
  particleState: "auto",
4148
4212
  rgba8MaxParticleZoom: 4
4149
4213
  };
4150
4214
  }
4151
- function ua(s) {
4215
+ function pa(s) {
4152
4216
  const { palette: e, ...t } = s;
4153
4217
  return t;
4154
4218
  }
4155
- function dt(s, e, t) {
4156
- s !== void 0 && mt(s, "style", {
4219
+ function mt(s, e, t) {
4220
+ s !== void 0 && ft(s, "style", {
4157
4221
  kind: e.layers.find((i) => i.id === t)?.kind
4158
4222
  });
4159
4223
  }
4160
- class Pa {
4224
+ class Aa {
4161
4225
  constructor(e) {
4162
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 = () => {
4163
4227
  this.attachQueued && this.attachWhenReady();
@@ -4165,9 +4229,9 @@ class Pa {
4165
4229
  throw new Error("Zartigl requires a layer UUID");
4166
4230
  if (e.time != null && z(e.time, "time"), e.depth != null && !Number.isFinite(e.depth))
4167
4231
  throw new Error("Depth must be finite");
4168
- st(e.geoVideo), this.id = e.id ?? "zartigl", this.map = e.map, this.catalog = e.catalog, this.initialLayer = e.layer, this.initialTime = e.time, this.initialDepth = e.depth, this.depthRequest = e.depth ?? null, this.sourcePreference = e.source ?? "auto", this.timeRange = e.timeRange ? { ...e.timeRange } : void 0, this.autoplay = e.geoVideo?.autoplay ?? !0, this.loop = e.geoVideo?.loop ?? !0, this.playbackRate = e.geoVideo?.playbackRate ?? 1, this.stepsPerSecond = e.geoVideo?.stepsPerSecond ?? null, this.metadata = e.metadata ? { ...e.metadata } : void 0, this.before = e.before, this.visible = e.visible ?? !0;
4169
- const t = De(e.settings);
4170
- ut(t.legacyKeys), this.style = ae(t.style, e.style), dt(this.style, e.catalog, e.layer), this.settings = { ...t.settings, ...pe(this.style) }, this.settings.colorDomain !== void 0 && (this.settings.colorDomain = Q(
4232
+ rt(e.geoVideo), this.id = e.id ?? "zartigl", this.map = e.map, this.catalog = e.catalog, this.initialLayer = e.layer, this.initialTime = e.time, this.initialDepth = e.depth, this.depthRequest = e.depth ?? null, this.sourcePreference = e.source ?? "auto", this.timeRange = e.timeRange ? { ...e.timeRange } : void 0, this.autoplay = e.geoVideo?.autoplay ?? !0, this.loop = e.geoVideo?.loop ?? !0, this.playbackRate = e.geoVideo?.playbackRate ?? 1, this.stepsPerSecond = e.geoVideo?.stepsPerSecond ?? null, this.metadata = e.metadata ? { ...e.metadata } : void 0, this.before = e.before, this.visible = e.visible ?? !0;
4233
+ const t = Ae(e.settings);
4234
+ dt(t.legacyKeys), this.style = ae(t.style, e.style), mt(this.style, e.catalog, e.layer), this.settings = { ...t.settings, ...pe(this.style) }, this.settings.colorDomain !== void 0 && (this.settings.colorDomain = Q(
4171
4235
  this.settings.colorDomain
4172
4236
  )), this.colorDomainOverridden = this.settings.colorDomain !== void 0, this.paletteOverridden = this.settings.palette !== void 0, this.map.on("load", this.onMapReady), this.map.on("styledata", this.onMapReady), this.map.on("idle", this.onMapReady);
4173
4237
  }
@@ -4184,16 +4248,16 @@ class Pa {
4184
4248
  }
4185
4249
  async update(e) {
4186
4250
  this.assertAlive();
4187
- const t = De(e.settings);
4188
- ut(t.legacyKeys);
4251
+ const t = Ae(e.settings);
4252
+ dt(t.legacyKeys);
4189
4253
  const i = t.legacyKeys.length ? { ...e, settings: t.settings, stylePatch: t.style } : e;
4190
4254
  if (!this.initialized)
4191
4255
  throw new Error("Call init() before update()");
4192
4256
  if (i.depth != null && !Number.isFinite(i.depth))
4193
4257
  throw new Error("Depth must be finite");
4194
- i.time != null && z(i.time, "time"), st(i.geoVideo), i.settings?.colorDomain !== void 0 && Q(i.settings.colorDomain);
4258
+ i.time != null && z(i.time, "time"), rt(i.geoVideo), i.settings?.colorDomain !== void 0 && Q(i.settings.colorDomain);
4195
4259
  for (const a of [i.style, i.stylePatch])
4196
- a !== void 0 && mt(a, "style");
4260
+ a !== void 0 && ft(a, "style");
4197
4261
  return i.time != null && this.pause(), this.enqueue(i, ++this.requestSeq);
4198
4262
  }
4199
4263
  /**
@@ -4215,11 +4279,11 @@ class Pa {
4215
4279
  }
4216
4280
  async applyUpdate(e, t, i) {
4217
4281
  this.assertAlive(), i != null && e.time != null && this.playSeq !== 0 && this.playSeq < i && this.pause();
4218
- 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, u = e.stylePatch === void 0 ? e.style : e.style === void 0 ? ae(this.style, e.stylePatch) : ae(e.stylePatch, e.style), l = e.settings?.palette, d = u !== void 0 && l !== void 0 && typeof l != "string" && e.style?.palette === void 0 ? ua(u) : u;
4219
- dt(d, this.catalog, c);
4220
- const f = d ?? (a ? ft(
4282
+ const a = e.layer != null && e.layer !== this.catalogLayer?.id, r = e.source != null && (a || e.source !== this.sourcePreference), n = !a && e.source === "auto" && this.sourcePreference === "auto", o = { time: e.time, depth: e.depth }, l = a ? e.layer : this.catalogLayer?.id, d = e.stylePatch === void 0 ? e.style : e.style === void 0 ? ae(this.style, e.stylePatch) : ae(e.stylePatch, e.style), c = e.settings?.palette, u = d !== void 0 && c !== void 0 && typeof c != "string" && e.style?.palette === void 0 ? pa(d) : d;
4283
+ mt(u, this.catalog, l);
4284
+ const f = u ?? (a ? pt(
4221
4285
  this.style,
4222
- this.catalog.layers.find((m) => m.id === c)?.kind
4286
+ this.catalog.layers.find((m) => m.id === l)?.kind
4223
4287
  ) : void 0);
4224
4288
  if (a) {
4225
4289
  const m = { ...e.settings, ...pe(f) };
@@ -4266,10 +4330,10 @@ class Pa {
4266
4330
  e.geoVideo && (e.geoVideo.autoplay != null && (this.autoplay = e.geoVideo.autoplay, this.catalogSource?.type === "geovideo" && (this.autoplay ? await this.startPlayback(i ?? ++this.requestSeq) : this.pause())), e.geoVideo.loop != null && this.applyLoop(e.geoVideo.loop), e.geoVideo.stepsPerSecond != null ? (this.stepsPerSecond = e.geoVideo.stepsPerSecond, this.applyPlaybackSpeed()) : e.geoVideo.playbackRate != null && this.applyPlaybackRate(e.geoVideo.playbackRate)), e.time != null && e.depth != null ? this.applyTimeAndDepth(e.time, e.depth) : (e.time != null && this.applyTime(e.time), e.depth != null && this.applyDepth(e.depth)), e.time != null && this.requestedTime === z(e.time, "time") && (this.requestedTime = null), e.visible != null && this.applyVisible(e.visible);
4267
4331
  }
4268
4332
  async loadLayer(e, t = this.sourcePreference, i, a) {
4269
- const r = this.getSource(), n = nt(this.timeMeta, this.verticalMeta);
4333
+ const r = this.getSource(), n = ot(this.timeMeta, this.verticalMeta);
4270
4334
  await this.loadSource(e, t, i, a);
4271
4335
  const o = this.getSource();
4272
- o && (o.id !== r?.id || o.type !== r?.type) ? this.emit("sourceChange", o) : nt(this.timeMeta, this.verticalMeta) !== n && this.emit("axesChange");
4336
+ o && (o.id !== r?.id || o.type !== r?.type) ? this.emit("sourceChange", o) : ot(this.timeMeta, this.verticalMeta) !== n && this.emit("axesChange");
4273
4337
  }
4274
4338
  async loadSource(e, t, i, a) {
4275
4339
  this.assertAlive();
@@ -4278,104 +4342,104 @@ class Pa {
4278
4342
  );
4279
4343
  if (!r)
4280
4344
  throw new Error(`Unknown zartigl catalog entry: ${e}`);
4281
- const n = ha(r), o = i ? i.timeRange : this.timeRange, c = a ?? ++this.switchGeneration, u = {
4345
+ const n = fa(r), o = i ? i.timeRange : this.timeRange, l = a ?? ++this.switchGeneration, d = {
4282
4346
  ...i?.target,
4283
4347
  depth: i?.target?.depth ?? this.depthRequest ?? void 0
4284
- }, l = await this.selectSource(
4348
+ }, c = await this.selectSource(
4285
4349
  r,
4286
4350
  t,
4287
4351
  o,
4288
- u
4289
- ), d = i?.settings ?? this.settings, f = i?.colorDomainOverridden ?? this.colorDomainOverridden, m = i?.paletteOverridden ?? this.paletteOverridden;
4290
- if (l.type === "geovideo") {
4352
+ d
4353
+ ), u = i?.settings ?? this.settings, f = i?.colorDomainOverridden ?? this.colorDomainOverridden, m = i?.paletteOverridden ?? this.paletteOverridden;
4354
+ if (c.type === "geovideo") {
4291
4355
  this.emit("status", { phase: "metadata" });
4292
4356
  try {
4293
- if (!l.manifestUrl)
4357
+ if (!c.manifestUrl)
4294
4358
  throw new Error(
4295
- `GeoVideo archive source was not resolved to a chunk: ${l.id}`
4359
+ `GeoVideo archive source was not resolved to a chunk: ${c.id}`
4296
4360
  );
4297
4361
  const v = await this.loadChunkManifest(
4298
- l.manifestUrl
4362
+ c.manifestUrl
4299
4363
  ), _ = r.sources.find(
4300
4364
  (ce) => ce.id === v.provenance.inputSourceId
4301
4365
  );
4302
- 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")
4303
4367
  throw new Error(
4304
- `GeoVideo manifest identity does not match catalog entry/source: ${l.id}`
4368
+ `GeoVideo manifest identity does not match catalog entry/source: ${c.id}`
4305
4369
  );
4306
- const S = Pe(r, l.id), R = S ? this.chunkLevels.get(l.manifestUrl) ?? null : null, E = v.vertical;
4307
- if (S && (R ? !Xe(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))
4308
4372
  throw new Error(
4309
- `GeoVideo manifest level does not match its index: ${l.manifestUrl}`
4373
+ `GeoVideo manifest level does not match its index: ${c.manifestUrl}`
4310
4374
  );
4311
- 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 ? sa(P) : null;
4312
- 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)
4313
4377
  throw new DOMException(
4314
4378
  "Layer selection was superseded",
4315
4379
  "AbortError"
4316
4380
  );
4317
- const N = Se(v), C = ra(F ?? N), I = re(
4381
+ const N = we(v), C = ca(F ?? N), I = re(
4318
4382
  C,
4319
4383
  o
4320
4384
  ), w = ne(
4321
4385
  C,
4322
4386
  o
4323
- ), U = N.filter(
4387
+ ), V = N.filter(
4324
4388
  (ce) => ce >= w.min && ce <= w.max
4325
- ), X = U.length ? U : N, oe = this.catalogLayer?.id === r.id && this.catalogSource?.type === "geovideo", le = this.settings.palette;
4326
- 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 : Ee(A, u.depth), L && (this.depthRequest = this.depth);
4327
- const Vt = d.colorDomain;
4328
- if (this.settings = { ...n, ...d }, this.colorDomainOverridden = f, this.paletteOverridden = m, this.settings.colorDomain = f ? Vt ?? null : v.style.colorDomain, this.settings.palette = m ? this.settings.palette : $e(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))
4329
4393
  return;
4330
4394
  this.detach(), this.attachWhenReady();
4331
4395
  return;
4332
4396
  } catch (v) {
4333
- const _ = v instanceof Error ? v : new Error(String(v)), S = l.manifestUrl;
4334
- if (_.name !== "AbortError" && !(_ instanceof RangeError) && t === "auto" && S && !this.failedGeoVideo.has(S) && this.catalogSource?.id !== l.id)
4335
- 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);
4336
4400
  throw _.name !== "AbortError" && (this.emit("status", { phase: "error", error: _ }), this.emit("error", _)), _;
4337
4401
  }
4338
4402
  }
4339
- if (l.type === "wmts") {
4403
+ if (c.type === "wmts") {
4340
4404
  this.emit("status", { phase: "metadata" });
4341
4405
  try {
4342
- const v = await ta(l);
4343
- if (c !== this.switchGeneration)
4406
+ const v = await ra(c);
4407
+ if (l !== this.switchGeneration)
4344
4408
  throw new DOMException(
4345
4409
  "Layer selection was superseded",
4346
4410
  "AbortError"
4347
4411
  );
4348
4412
  const _ = v.time, S = ne(_, o);
4349
4413
  this.detach(), this.catalogLayer = r, this.catalogSource = {
4350
- ...l,
4414
+ ...c,
4351
4415
  baseUrl: v.baseUrl,
4352
- tileUrlTemplate: l.tileUrlTemplate ?? v.tileUrlTemplate,
4416
+ tileUrlTemplate: c.tileUrlTemplate ?? v.tileUrlTemplate,
4353
4417
  tileMatrixSet: v.tileMatrixSet,
4354
4418
  format: v.format,
4355
- style: l.style ?? v.style
4419
+ style: c.style ?? v.style
4356
4420
  }, this.sourcePreference = t, this.timeRange = o, this.activeFieldSource = null, this.geoVideoManifest = null, this.wmtsMetadata = v, this.fullTimeMeta = _, this.resolvedTimeRange = re(
4357
4421
  _,
4358
4422
  o
4359
- ), this.timeMeta = S, this.verticalMeta = v.vertical, this.archiveLevel = null, this.depthLocked = !1, this.variableUnit = "", this.variableStandardName = l.layer, this.time = this.pendingTime == null ? it(S.values, Date.now()) : V(S.values, this.pendingTime), this.pendingTime = null, this.depth = Ee(v.vertical, u.depth), this.settings = { ...n, ...d }, 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();
4360
4424
  return;
4361
4425
  } catch (v) {
4362
4426
  const _ = v instanceof Error ? v : new Error(String(v));
4363
4427
  throw _.name !== "AbortError" && (this.emit("status", { phase: "error", error: _ }), this.emit("error", _)), _;
4364
4428
  }
4365
4429
  }
4366
- const p = this.getFieldSource(l.endpoints.field);
4430
+ const p = this.getFieldSource(c.endpoints.field);
4367
4431
  let h, g, x, T, M;
4368
4432
  this.emit("status", { phase: "metadata" });
4369
4433
  try {
4370
4434
  await p.init();
4371
- const v = fe(l);
4435
+ const v = fe(c);
4372
4436
  for (const _ of v)
4373
4437
  if (!p.hasVariable(_))
4374
4438
  throw new Error(
4375
4439
  `Configured variable not found in Zarr store: ${_}`
4376
4440
  );
4377
- if (g = at(
4378
- l,
4441
+ if (g = st(
4442
+ c,
4379
4443
  p.getTimeDimension()
4380
4444
  ), g.values.length === 0)
4381
4445
  throw new Error("Zarr time coordinate is empty");
@@ -4386,11 +4450,11 @@ class Pa {
4386
4450
  const _ = v instanceof Error ? v : new Error(String(v));
4387
4451
  throw this.emit("status", { phase: "error", error: _ }), this.emit("error", _), _;
4388
4452
  }
4389
- if (c !== this.switchGeneration)
4453
+ if (l !== this.switchGeneration)
4390
4454
  throw new DOMException("Layer selection was superseded", "AbortError");
4391
- 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 ? it(this.timeMeta.values, Date.now()) : V(this.timeMeta.values, this.pendingTime), this.pendingTime = null, this.depth = Ee(T, u.depth);
4392
- const y = d.colorDomain;
4393
- this.settings = { ...n, ...d }, this.colorDomainOverridden = f, this.paletteOverridden = m, this.settings.colorDomain = f ? y ?? null : n.colorDomain ?? null, this.lastMeta = null, this.attachWhenReady();
4455
+ this.detach(), this.catalogLayer = r, this.catalogSource = c, this.sourcePreference = t, this.timeRange = o, this.activeFieldSource = p, this.geoVideoManifest = null, this.wmtsMetadata = null, this.fullTimeMeta = g, this.resolvedTimeRange = x, this.timeMeta = h, this.verticalMeta = T, this.archiveLevel = null, this.depthLocked = !1, this.variableUnit = typeof M.units == "string" ? M.units : "", this.variableStandardName = typeof M.standard_name == "string" ? M.standard_name : void 0, this.time = this.pendingTime == null ? at(this.timeMeta.values, Date.now()) : U(this.timeMeta.values, this.pendingTime), this.pendingTime = null, this.depth = Le(T, d.depth);
4456
+ const y = u.colorDomain;
4457
+ this.settings = { ...n, ...u }, this.colorDomainOverridden = f, this.paletteOverridden = m, this.settings.colorDomain = f ? y ?? null : n.colorDomain ?? null, this.lastMeta = null, this.attachWhenReady();
4394
4458
  }
4395
4459
  async changeSource(e, t = this.timeRange, i = {}) {
4396
4460
  if (this.assertAlive(), !this.catalogLayer) {
@@ -4414,16 +4478,16 @@ class Pa {
4414
4478
  const a = this.catalogLayer, r = this.catalogSource;
4415
4479
  if (!a || !r || !this.isArchiveChunk(r))
4416
4480
  return !1;
4417
- const n = Pe(a, this.sourcePreference), o = n ? await this.archiveLevels(a, n) : null, u = !!o?.depths.length && t.depth != null && rt(o, t.depth) !== this.archiveLevel;
4418
- if ((t.time == null && !i || Nt(r, this.sourceTimeRequest(e, t.time))) && !u)
4481
+ const n = Ee(a, this.sourcePreference), o = n ? await this.archiveLevels(a, n) : null, d = !!o?.depths.length && t.depth != null && nt(o, t.depth) !== this.archiveLevel;
4482
+ if ((t.time == null && !i || Ot(r, this.sourceTimeRequest(e, t.time))) && !d)
4419
4483
  return !1;
4420
- const d = await this.selectSource(
4484
+ const u = await this.selectSource(
4421
4485
  a,
4422
4486
  this.sourcePreference,
4423
4487
  e,
4424
4488
  t
4425
4489
  );
4426
- return !Qt(d, r);
4490
+ return !ti(u, r);
4427
4491
  }
4428
4492
  applyVisible(e) {
4429
4493
  this.assertAlive(), this.visible !== e && (this.visible = e, e ? this.attachWhenReady() : this.detach());
@@ -4448,7 +4512,7 @@ class Pa {
4448
4512
  applyTime(e) {
4449
4513
  this.assertAlive();
4450
4514
  const t = z(e, "time");
4451
- 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);
4452
4516
  }
4453
4517
  /** Start GeoVideo playback; does nothing where playback is unavailable. */
4454
4518
  async play() {
@@ -4475,7 +4539,7 @@ class Pa {
4475
4539
  const t = this.timeMeta?.values ?? [];
4476
4540
  if (!t.length)
4477
4541
  return;
4478
- const i = V(t, this.requestedTime ?? this.time);
4542
+ const i = U(t, this.requestedTime ?? this.time);
4479
4543
  return t[t.indexOf(i) + e];
4480
4544
  }
4481
4545
  pause() {
@@ -4496,10 +4560,10 @@ class Pa {
4496
4560
  }
4497
4561
  /** Media rate for the loaded artifact: steps per second when set, else the raw multiplier. */
4498
4562
  effectivePlaybackRate() {
4499
- return this.stepsPerSecond != null && this.geoVideoManifest ? Kt(this.geoVideoManifest, this.stepsPerSecond) : this.playbackRate;
4563
+ return this.stepsPerSecond != null && this.geoVideoManifest ? ii(this.geoVideoManifest, this.stepsPerSecond) : this.playbackRate;
4500
4564
  }
4501
4565
  playbackSpeeds() {
4502
- return this.catalogLayer?.kind === "vector" ? tt : ia;
4566
+ return this.catalogLayer?.kind === "vector" ? it : na;
4503
4567
  }
4504
4568
  /**
4505
4569
  * Steps per second the active source shows. Vector GeoVideo stays inside
@@ -4507,29 +4571,29 @@ class Pa {
4507
4571
  */
4508
4572
  appliedStepsPerSecond() {
4509
4573
  if (this.catalogLayer?.kind === "vector") {
4510
- const e = tt;
4574
+ const e = it;
4511
4575
  return Math.min(
4512
4576
  e[e.length - 1],
4513
4577
  Math.max(e[0], this.stepsPerSecond ?? 1)
4514
4578
  );
4515
4579
  }
4516
- return this.stepsPerSecond != null ? this.stepsPerSecond : this.geoVideoManifest ? this.playbackRate * Jt(this.geoVideoManifest) : this.playbackRate;
4580
+ return this.stepsPerSecond != null ? this.stepsPerSecond : this.geoVideoManifest ? this.playbackRate * ai(this.geoVideoManifest) : this.playbackRate;
4517
4581
  }
4518
4582
  /** Apply or clear a time window without rebuilding source metadata or the map layer. */
4519
4583
  applyTimeRange(e) {
4520
4584
  if (this.assertAlive(), !this.fullTimeMeta)
4521
4585
  throw new Error("Set a layer before changing its time range");
4522
- 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);
4523
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();
4524
4588
  }
4525
4589
  applyDepth(e) {
4526
- 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);
4527
4591
  }
4528
4592
  applyTimeAndDepth(e, t) {
4529
- this.assertAlive(), this.time = V(
4593
+ this.assertAlive(), this.time = U(
4530
4594
  this.timeMeta?.values ?? [],
4531
4595
  z(e, "time")
4532
- ), 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);
4533
4597
  }
4534
4598
  on(e, t) {
4535
4599
  return this.assertAlive(), this.listeners.has(e) || this.listeners.set(e, /* @__PURE__ */ new Set()), this.listeners.get(e).add(t), this;
@@ -4547,7 +4611,7 @@ class Pa {
4547
4611
  values: t.values,
4548
4612
  units: t.units,
4549
4613
  current: this.time,
4550
- granularity: aa(t.values),
4614
+ granularity: oa(t.values),
4551
4615
  timelineKind: this.geoVideoManifest?.timeline.kind
4552
4616
  } : {
4553
4617
  min: NaN,
@@ -4563,7 +4627,7 @@ class Pa {
4563
4627
  return { values: [], label: "depth", current: void 0 };
4564
4628
  const e = this.verticalMeta;
4565
4629
  return {
4566
- values: Dt(e.values),
4630
+ values: kt(e.values),
4567
4631
  name: e.name,
4568
4632
  label: e.label,
4569
4633
  units: e.units,
@@ -4584,7 +4648,7 @@ class Pa {
4584
4648
  const i = this.catalogSource;
4585
4649
  return {
4586
4650
  type: "image",
4587
- url: Wi({
4651
+ url: Zi({
4588
4652
  baseUrl: i.baseUrl ?? this.wmtsMetadata?.baseUrl ?? new URL(i.capabilitiesUrl).origin,
4589
4653
  layer: i.layer,
4590
4654
  style: i.style
@@ -4593,7 +4657,7 @@ class Pa {
4593
4657
  };
4594
4658
  }
4595
4659
  if (this.catalogSource.type === "geovideo" && this.geoVideoManifest) {
4596
- const i = typeof this.settings.palette == "string" ? Ve(this.settings.palette) : "custom", a = this.settings.colorDomain ?? this.geoVideoManifest.style.colorDomain;
4660
+ const i = typeof this.settings.palette == "string" ? Ne(this.settings.palette) : "custom", a = this.settings.colorDomain ?? this.geoVideoManifest.style.colorDomain;
4597
4661
  return {
4598
4662
  type: "gradient",
4599
4663
  palette: i,
@@ -4601,10 +4665,10 @@ class Pa {
4601
4665
  alphaFade: Ue(this.settings),
4602
4666
  min: a[0],
4603
4667
  max: a[1],
4604
- unit: He(this.geoVideoManifest.style.unit)
4668
+ unit: Ye(this.geoVideoManifest.style.unit)
4605
4669
  };
4606
4670
  }
4607
- const e = typeof this.settings.palette == "string" ? Ve(this.settings.palette) : "custom", t = this.catalogLayer.kind === "scalar" ? this.settings.colorDomain : null;
4671
+ const e = typeof this.settings.palette == "string" ? Ne(this.settings.palette) : "custom", t = this.catalogLayer.kind === "scalar" ? this.settings.colorDomain : null;
4608
4672
  return {
4609
4673
  type: "gradient",
4610
4674
  palette: e,
@@ -4612,11 +4676,11 @@ class Pa {
4612
4676
  alphaFade: this.catalogLayer.kind === "scalar" ? Ue(this.settings) : void 0,
4613
4677
  min: t?.[0] ?? this.lastMeta?.min,
4614
4678
  max: t?.[1] ?? this.lastMeta?.max,
4615
- unit: He(this.lastMeta?.unit ?? this.variableUnit)
4679
+ unit: Ye(this.lastMeta?.unit ?? this.variableUnit)
4616
4680
  };
4617
4681
  }
4618
4682
  getPalettes() {
4619
- return vt();
4683
+ return _t();
4620
4684
  }
4621
4685
  getSource() {
4622
4686
  return this.catalogSource ? { id: this.catalogSource.id, type: this.catalogSource.type } : void 0;
@@ -4649,7 +4713,7 @@ class Pa {
4649
4713
  if (e.timeline.kind === "snapshot-loop")
4650
4714
  return this.catalogLayer?.kind !== "vector";
4651
4715
  const t = this.timeMeta;
4652
- return Se(e).filter(
4716
+ return we(e).filter(
4653
4717
  (a) => !t || a >= t.min && a <= t.max
4654
4718
  ).length > 1;
4655
4719
  }
@@ -4662,9 +4726,9 @@ class Pa {
4662
4726
  * source chose, such as a GeoVideo archive's palette.
4663
4727
  */
4664
4728
  getStyle() {
4665
- return Ne(
4729
+ return ze(
4666
4730
  this.catalogLayer ?? void 0,
4667
- De(this.settings).style
4731
+ Ae(this.settings).style
4668
4732
  );
4669
4733
  }
4670
4734
  /** The style override over the layer's own. */
@@ -4688,7 +4752,7 @@ class Pa {
4688
4752
  devicePixelRatio: typeof window < "u" ? window.devicePixelRatio : void 0,
4689
4753
  catalogEntry: this.catalogLayer ? {
4690
4754
  id: this.catalogLayer.id,
4691
- title: zt(
4755
+ title: Bt(
4692
4756
  this.catalogLayer.title,
4693
4757
  this.catalog.defaultLocale,
4694
4758
  this.catalog.defaultLocale
@@ -4713,23 +4777,23 @@ class Pa {
4713
4777
  * color domain of a GeoVideo archive included, as a load sets them.
4714
4778
  */
4715
4779
  styledSettings() {
4716
- const e = Ct(
4780
+ const e = It(
4717
4781
  this.catalogLayer ?? void 0,
4718
4782
  this.style
4719
4783
  ), t = this.catalogSource?.type === "geovideo" ? this.geoVideoManifest : null;
4720
- return t && this.style.raster?.colorDomain === void 0 && (e.colorDomain = t.style.colorDomain), t && this.style.palette === void 0 && (e.palette = $e(this.catalogLayer?.defaults)?.palette ?? t.style.palette), e;
4784
+ return t && this.style.raster?.colorDomain === void 0 && (e.colorDomain = t.style.colorDomain), t && this.style.palette === void 0 && (e.palette = qe(this.catalogLayer?.defaults)?.palette ?? t.style.palette), e;
4721
4785
  }
4722
4786
  applySettings(e) {
4723
4787
  this.assertAlive();
4724
4788
  const t = e.colorDomain === void 0 ? e : {
4725
4789
  ...e,
4726
4790
  colorDomain: Q(e.colorDomain)
4727
- }, i = ca.some(
4791
+ }, i = ma.some(
4728
4792
  (r) => t[r] != null && t[r] !== this.settings[r]
4729
4793
  ), a = t.particleState != null && t.particleState !== this.settings.particleState;
4730
4794
  if (t.colorDomain !== void 0 && (this.colorDomainOverridden = !0), t.palette !== void 0 && (this.paletteOverridden = !0), this.settings = { ...this.settings, ...t }, !!this.layer) {
4731
4795
  if (i && this.catalogSource?.type === "geovideo") {
4732
- this.layer.setColorRamp(Le(this.settings)), this.applyMutableSettings(this.layer, t);
4796
+ this.layer.setColorRamp(De(this.settings)), this.applyMutableSettings(this.layer, t);
4733
4797
  return;
4734
4798
  }
4735
4799
  if (i || a) {
@@ -4748,7 +4812,7 @@ class Pa {
4748
4812
  );
4749
4813
  const a = Math.max(1, Math.floor(e.maxPoints ?? 512)), r = this.getQuerySource(i.endpoints.pointSeries);
4750
4814
  await r.init();
4751
- const n = r.getTimeDimension().values, o = at(
4815
+ const n = r.getTimeDimension().values, o = st(
4752
4816
  i,
4753
4817
  r.getTimeDimension()
4754
4818
  );
@@ -4763,29 +4827,29 @@ class Pa {
4763
4827
  stopAfterMissingSamples: 12
4764
4828
  });
4765
4829
  }
4766
- const c = this.timeRange ? Math.max(
4830
+ const l = this.timeRange ? Math.max(
4767
4831
  o.min,
4768
4832
  this.resolvedTimeRange?.[0] ?? this.timeMeta?.min ?? o.min
4769
- ) : o.min, u = this.timeRange ? Math.min(
4833
+ ) : o.min, d = this.timeRange ? Math.min(
4770
4834
  o.max,
4771
4835
  this.resolvedTimeRange?.[1] ?? this.timeMeta?.max ?? o.max
4772
- ) : o.max, l = n.findIndex((m) => m >= c);
4773
- let d = n.length - 1;
4774
- for (; d >= 0 && n[d] > u; )
4775
- d--;
4776
- if (l < 0 || d < l)
4836
+ ) : o.max, c = n.findIndex((m) => m >= l);
4837
+ let u = n.length - 1;
4838
+ for (; u >= 0 && n[u] > d; )
4839
+ u--;
4840
+ if (c < 0 || u < c)
4777
4841
  throw new Error("Time range does not overlap the point-series store");
4778
4842
  const f = Math.max(
4779
4843
  1,
4780
- Math.ceil((d - l + 1) / a)
4844
+ Math.ceil((u - c + 1) / a)
4781
4845
  );
4782
4846
  return r.sampleTimeSeries({
4783
4847
  variables: fe(i),
4784
4848
  longitude: e.longitude,
4785
4849
  latitude: e.latitude,
4786
4850
  depth: e.depth ?? this.depth,
4787
- timeStartIndex: l,
4788
- timeEndIndex: d,
4851
+ timeStartIndex: c,
4852
+ timeEndIndex: u,
4789
4853
  stride: f,
4790
4854
  stopAfterMissingSamples: 12
4791
4855
  });
@@ -4822,7 +4886,7 @@ class Pa {
4822
4886
  );
4823
4887
  return;
4824
4888
  }
4825
- const e = new Qi({
4889
+ const e = new ta({
4826
4890
  id: this.id,
4827
4891
  entry: this.catalogLayer,
4828
4892
  sourceConfig: this.catalogSource,
@@ -4848,14 +4912,14 @@ class Pa {
4848
4912
  zarrSource: this.activeFieldSource ?? void 0,
4849
4913
  unit: this.variableUnit,
4850
4914
  verticalLabel: this.verticalMeta?.label,
4851
- colorRamp: Le(this.settings),
4915
+ colorRamp: De(this.settings),
4852
4916
  metadata: this.metadata ? { ...this.metadata } : void 0,
4853
4917
  before: this.before
4854
4918
  });
4855
4919
  this.pendingTime = null, this.autoplayPending = !1, e.on("loading", () => this.emit("loading")), e.on("loaded", (t) => {
4856
4920
  this.lastMeta = t, this.emit("loaded", t);
4857
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) => {
4858
- 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));
4859
4923
  }), e.on("playbackChange", (t) => {
4860
4924
  e === this.layer && (t && this.preloadNextArchiveChunk(e), t !== this.playing && (this.playing = t, this.emit("playbackChange", t)));
4861
4925
  }), e.on("playbackEnd", () => {
@@ -4887,7 +4951,7 @@ class Pa {
4887
4951
  loop: i.geoVideoLoop,
4888
4952
  playbackRate: i.geoVideoPlaybackRate,
4889
4953
  stepsPerSecond: this.catalogLayer?.kind === "vector" ? this.appliedStepsPerSecond() : void 0
4890
- }) ? (t.setColorDomain(this.settings.colorDomain ?? null), this.settings.palette && this.settings.palette !== e && t.setColorRamp(Le(this.settings)), !0) : !1;
4954
+ }) ? (t.setColorDomain(this.settings.colorDomain ?? null), this.settings.palette && this.settings.palette !== e && t.setColorRamp(De(this.settings)), !0) : !1;
4891
4955
  }
4892
4956
  detach() {
4893
4957
  const e = this.layer;
@@ -4902,11 +4966,11 @@ class Pa {
4902
4966
  }
4903
4967
  getQuerySource(e) {
4904
4968
  let t = this.querySources.get(e);
4905
- return t || (t = new ye(e, 80), this.querySources.set(e, t)), t;
4969
+ return t || (t = new _e(e, 80), this.querySources.set(e, t)), t;
4906
4970
  }
4907
4971
  getFieldSource(e) {
4908
4972
  let t = this.fieldSources.get(e);
4909
- return t || (t = new ye(e), this.fieldSources.set(e, t)), t;
4973
+ return t || (t = new _e(e), this.fieldSources.set(e, t)), t;
4910
4974
  }
4911
4975
  /**
4912
4976
  * Time the caller asked for, so selection skips fixed-period sources (such
@@ -4924,19 +4988,19 @@ class Pa {
4924
4988
  * "auto", a level deeper than the surface GeoVideo renders shows Zarr.
4925
4989
  */
4926
4990
  async selectSource(e, t, i, a = {}) {
4927
- const r = this.sourceTimeRequest(i, a.time), n = Pe(e, t);
4991
+ const r = this.sourceTimeRequest(i, a.time), n = Ee(e, t);
4928
4992
  if (n) {
4929
- const o = await this.archiveLevels(e, n), u = o.depths.length > 0 && a.depth != null ? rt(o, a.depth) : this.catalogLayer?.id === e.id && this.catalogSource?.id === n.id ? this.archiveLevel : null, l = await this.resolveArchives(e, u), d = 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(
4930
4994
  (m) => m.id === n.id
4931
4995
  );
4932
- if (d.length) {
4996
+ if (u.length) {
4933
4997
  const m = await this.archiveSample(
4934
4998
  e,
4935
4999
  n.id,
4936
5000
  i,
4937
5001
  a.time,
4938
- u
4939
- ), p = ei(d, { time: m });
5002
+ d
5003
+ ), p = si(u, { time: m });
4940
5004
  if (p && !this.isFailedGeoVideo(p))
4941
5005
  return p;
4942
5006
  if (t !== "auto" || this.catalogSource?.id === n.id)
@@ -4944,17 +5008,17 @@ class Pa {
4944
5008
  `GeoVideo chunk unavailable: ${p?.type === "geovideo" ? p.manifestUrl : n.id}`
4945
5009
  );
4946
5010
  } else {
4947
- if (u != null)
4948
- throw new Error(`GeoVideo archive level unavailable: ${u}`);
5011
+ if (d != null)
5012
+ throw new Error(`GeoVideo archive level unavailable: ${d}`);
4949
5013
  if (t !== "auto")
4950
5014
  throw new Error(`GeoVideo archive unavailable: ${n.id}`);
4951
5015
  }
4952
- const f = he(l, ["zarr"], r);
5016
+ const f = he(c, ["zarr"], r);
4953
5017
  if (f)
4954
5018
  return f;
4955
5019
  e = {
4956
- ...l,
4957
- sources: l.sources.filter(
5020
+ ...c,
5021
+ sources: c.sources.filter(
4958
5022
  (m) => m.type !== "geovideo"
4959
5023
  )
4960
5024
  };
@@ -4977,7 +5041,7 @@ class Pa {
4977
5041
  }
4978
5042
  isArchiveChunk(e) {
4979
5043
  return e.type === "geovideo" && !!this.catalogLayer?.sources.some(
4980
- (t) => t.id === e.id && ke(t)
5044
+ (t) => t.id === e.id && Fe(t)
4981
5045
  );
4982
5046
  }
4983
5047
  /**
@@ -4989,7 +5053,7 @@ class Pa {
4989
5053
  if (!e || !t || !this.isArchiveChunk(t))
4990
5054
  return null;
4991
5055
  const i = this.archiveLevel;
4992
- return ti(
5056
+ return ri(
4993
5057
  (await this.resolveArchives(e, i)).sources,
4994
5058
  t,
4995
5059
  {
@@ -5000,7 +5064,7 @@ class Pa {
5000
5064
  }
5001
5065
  /** A chunk manifest, reusing the one requested ahead for the next chunk. */
5002
5066
  loadChunkManifest(e) {
5003
- return this.nextChunkManifest?.url === e ? this.nextChunkManifest.manifest : Ae(e);
5067
+ return this.nextChunkManifest?.url === e ? this.nextChunkManifest.manifest : Ce(e);
5004
5068
  }
5005
5069
  /**
5006
5070
  * While a scalar archive chunk plays, load the next chunk into the layer so
@@ -5013,7 +5077,7 @@ class Pa {
5013
5077
  const i = await this.nextArchiveChunk(), a = i?.source.type === "geovideo" && i.source.manifestUrl;
5014
5078
  if (!i || !a)
5015
5079
  return;
5016
- this.nextChunkManifest?.url !== a && (this.nextChunkManifest = { url: a, manifest: Ae(a) });
5080
+ this.nextChunkManifest?.url !== a && (this.nextChunkManifest = { url: a, manifest: Ce(a) });
5017
5081
  const r = this.nextChunkManifest, n = await r.manifest.catch((o) => {
5018
5082
  throw this.nextChunkManifest === r && (this.nextChunkManifest = null), o;
5019
5083
  });
@@ -5066,14 +5130,14 @@ class Pa {
5066
5130
  const a = (await this.resolveArchives(e, i)).sources.flatMap(
5067
5131
  (n) => n.id === t && n.type === "geovideo" && n.manifestUrl ? [n.manifestUrl] : []
5068
5132
  ), r = a.filter((n) => !this.chunkTimes.has(n));
5069
- for (let n = 0; n < r.length; n += ot) {
5070
- const o = r.slice(n, n + ot);
5133
+ for (let n = 0; n < r.length; n += lt) {
5134
+ const o = r.slice(n, n + lt);
5071
5135
  (await Promise.allSettled(
5072
- o.map((u) => this.loadChunkManifest(u))
5073
- )).forEach((u, l) => {
5074
- u.status === "fulfilled" ? this.chunkTimes.set(o[l], Se(u.value)) : console.warn(
5136
+ o.map((d) => this.loadChunkManifest(d))
5137
+ )).forEach((d, c) => {
5138
+ d.status === "fulfilled" ? this.chunkTimes.set(o[c], we(d.value)) : console.warn(
5075
5139
  "[zartigl] GeoVideo chunk samples unavailable:",
5076
- u.reason
5140
+ d.reason
5077
5141
  );
5078
5142
  });
5079
5143
  }
@@ -5088,13 +5152,13 @@ class Pa {
5088
5152
  * and the time shown in agreement.
5089
5153
  */
5090
5154
  async archiveSample(e, t, i, a, r = null) {
5091
- const n = await this.archiveTimes(e, t, r), [o, c] = i && n.length ? yt(i, [n[0], n[n.length - 1]]) : [-1 / 0, 1 / 0], u = n.filter((d) => d >= o && d <= c);
5092
- if (u.length === 0)
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);
5156
+ if (d.length === 0)
5093
5157
  throw new RangeError(
5094
5158
  "Time range does not contain any available timestamps"
5095
5159
  );
5096
- const l = this.sourceTimeRequest(void 0, a).time;
5097
- return l == null ? u[u.length - 1] : V(u, l);
5160
+ const c = this.sourceTimeRequest(void 0, a).time;
5161
+ return c == null ? d[d.length - 1] : U(d, c);
5098
5162
  }
5099
5163
  /**
5100
5164
  * Entry whose archive sources are replaced by one fixed-period source per
@@ -5105,7 +5169,7 @@ class Pa {
5105
5169
  async resolveArchives(e, t = null) {
5106
5170
  const i = await Promise.all(
5107
5171
  e.sources.map(async (a) => {
5108
- if (!ke(a))
5172
+ if (!Fe(a))
5109
5173
  return [a];
5110
5174
  const r = await this.archiveChunksAt(
5111
5175
  e,
@@ -5119,7 +5183,7 @@ class Pa {
5119
5183
  return n ? this.archiveChunksAt(
5120
5184
  e,
5121
5185
  a,
5122
- ii(n, a.indexUrl),
5186
+ ni(n, a.indexUrl),
5123
5187
  n
5124
5188
  ) : [];
5125
5189
  })
@@ -5140,28 +5204,28 @@ class Pa {
5140
5204
  if (r && r.expires > Date.now())
5141
5205
  return r.chunks;
5142
5206
  const n = {
5143
- expires: Date.now() + na,
5144
- chunks: ai(i).then((o) => {
5145
- if (a ? !Xe(o.vertical, a) : o.vertical !== void 0)
5207
+ expires: Date.now() + ha,
5208
+ chunks: oi(i).then((o) => {
5209
+ if (a ? !He(o.vertical, a) : o.vertical !== void 0)
5146
5210
  throw new Error(`GeoVideo index level does not match: ${i}`);
5147
5211
  !a && !this.archiveRoots.has(t.indexUrl) && this.archiveRoots.set(t.indexUrl, {
5148
5212
  surface: o.surface,
5149
5213
  depths: o.depths ?? []
5150
5214
  });
5151
- const c = si(
5215
+ const l = li(
5152
5216
  { ...t, indexUrl: i },
5153
5217
  o,
5154
5218
  e
5155
5219
  );
5156
- for (const u of ri(o, i))
5157
- this.chunkLevels.set(u.manifestUrl, a), u.times && this.chunkTimes.set(u.manifestUrl, u.times);
5158
- return c;
5159
- }).catch((o) => (console.warn("[zartigl] GeoVideo archive unavailable:", o), n.expires = Date.now() + oa, []))
5220
+ for (const d of ci(o, i))
5221
+ this.chunkLevels.set(d.manifestUrl, a), d.times && this.chunkTimes.set(d.manifestUrl, d.times);
5222
+ return l;
5223
+ }).catch((o) => (console.warn("[zartigl] GeoVideo archive unavailable:", o), n.expires = Date.now() + ua, []))
5160
5224
  };
5161
5225
  return this.archiveChunks.set(i, n), n.chunks;
5162
5226
  }
5163
5227
  resolveSource(e, t, i) {
5164
- const a = t === "auto" ? Gt(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(
5165
5229
  e,
5166
5230
  [t],
5167
5231
  i
@@ -5222,33 +5286,33 @@ class Pa {
5222
5286
  a(...t);
5223
5287
  }
5224
5288
  }
5225
- function da(s, e) {
5289
+ function ga(s, e) {
5226
5290
  const t = new Date(s).toISOString();
5227
5291
  return e === "year" ? t.slice(0, 4) : e === "month" ? t.slice(0, 7) : e === "day" ? t.slice(0, 10) : "";
5228
5292
  }
5229
- function ma(s, e) {
5293
+ function va(s, e) {
5230
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();
5231
5295
  }
5232
- function Ea(s, e, t) {
5296
+ function Ca(s, e, t) {
5233
5297
  if (!e || s.length === 0)
5234
5298
  return;
5235
5299
  if (["year", "month", "day"].includes(t)) {
5236
5300
  const a = s.find(
5237
- (r) => da(r, t) === e
5301
+ (r) => ga(r, t) === e
5238
5302
  );
5239
5303
  if (a !== void 0)
5240
5304
  return a;
5241
5305
  }
5242
- const i = ma(e, t);
5306
+ const i = va(e, t);
5243
5307
  if (Number.isFinite(i))
5244
5308
  return s.reduce(
5245
5309
  (a, r) => Math.abs(r - i) < Math.abs(a - i) ? r : a
5246
5310
  );
5247
5311
  }
5248
- const kt = pt.devDependencies["maplibre-gl"].replace(
5312
+ const Vt = gt.devDependencies["maplibre-gl"].replace(
5249
5313
  /^[^\d]*/,
5250
5314
  ""
5251
- ), fa = `https://cdn.jsdelivr.net/npm/maplibre-gl@${kt}/+esm`, pa = `https://cdn.jsdelivr.net/npm/maplibre-gl@${kt}/dist/maplibre-gl.css`, ga = `{
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 = `{
5252
5316
  version: 8,
5253
5317
  sources: {
5254
5318
  "eox-cloudless": {
@@ -5272,10 +5336,10 @@ const kt = pt.devDependencies["maplibre-gl"].replace(
5272
5336
  function q(s) {
5273
5337
  return JSON.stringify(s);
5274
5338
  }
5275
- function va(s) {
5339
+ function ba(s) {
5276
5340
  return JSON.stringify(s, null, 2);
5277
5341
  }
5278
- function Ft(s) {
5342
+ function Ut(s) {
5279
5343
  return s instanceof Date ? `new Date(${q(s.toISOString())})` : typeof s == "string" ? `new Date(${q(s)})` : String(s);
5280
5344
  }
5281
5345
  function ie(s, e = 6) {
@@ -5283,25 +5347,25 @@ function ie(s, e = 6) {
5283
5347
  }
5284
5348
  function $(s, e) {
5285
5349
  const t = " ".repeat(e);
5286
- return va(s).split(`
5350
+ return ba(s).split(`
5287
5351
  `).map((i) => `${t}${i}`).join(`
5288
5352
  `).trimStart();
5289
5353
  }
5290
- function ya(s, e) {
5354
+ function Sa(s, e) {
5291
5355
  const t = " ".repeat(e);
5292
5356
  return s.split(`
5293
5357
  `).map((i) => i.length > 0 ? `${t}${i}` : i).join(`
5294
5358
  `);
5295
5359
  }
5296
- const _a = (s) => {
5360
+ const wa = (s) => {
5297
5361
  const e = s.source ?? "auto";
5298
5362
  return s.sourceType ?? (e === "wmts" || e === "geovideo" ? e : "zarr");
5299
5363
  };
5300
- function It(s) {
5301
- const { layerKind: e, layerDefaults: t } = s, i = ft(s.style ?? {}, e), a = t === void 0 ? i : Ot(i, Ne({ kind: e, defaults: t })), r = a.raster?.opacity, n = _a(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 } };
5302
5366
  return Object.keys(n).length ? n : void 0;
5303
5367
  }
5304
- function Ut(s) {
5368
+ function zt(s) {
5305
5369
  const { particleState: e, rgba8MaxParticleZoom: t } = s.settings ?? {}, i = Object.fromEntries(
5306
5370
  Object.entries({ particleState: e, rgba8MaxParticleZoom: t }).filter(
5307
5371
  ([, a]) => a !== void 0
@@ -5309,8 +5373,8 @@ function Ut(s) {
5309
5373
  );
5310
5374
  return s.layerKind === "vector" && Object.keys(i).length ? i : void 0;
5311
5375
  }
5312
- function La(s) {
5313
- const e = s.source ?? "auto", t = It(s), i = Ut(s), a = [
5376
+ function ka(s) {
5377
+ const e = s.source ?? "auto", t = Nt(s), i = zt(s), a = [
5314
5378
  " idView: widget.opt.view.id,",
5315
5379
  " map: widget.opt.map,",
5316
5380
  ` layer: ${q(s.layerId)},`,
@@ -5318,7 +5382,7 @@ function La(s) {
5318
5382
  ];
5319
5383
  for (const r of ["title", "subtitle", "description"])
5320
5384
  s[r] != null && a.push(` ${r}: ${$(s[r], 10)},`);
5321
- return s.entry && a.push(` entry: ${$(s.entry, 10)},`), t && a.push(` style: ${$(t, 10)},`), i && a.push(` settings: ${$(i, 10)},`), s.time != null && a.push(` time: ${Ft(s.time)},`), s.timeRange != null && a.push(
5385
+ return s.entry && a.push(` entry: ${$(s.entry, 10)},`), t && a.push(` style: ${$(t, 10)},`), i && a.push(` settings: ${$(i, 10)},`), s.time != null && a.push(` time: ${Ut(s.time)},`), s.timeRange != null && a.push(
5322
5386
  ` timeRange: ${$(s.timeRange, 10)},`
5323
5387
  ), s.geoVideo != null && a.push(
5324
5388
  ` geoVideo: ${$(s.geoVideo, 10)},`
@@ -5357,16 +5421,16 @@ ${a.join(`
5357
5421
  };
5358
5422
  }`;
5359
5423
  }
5360
- function xa(s) {
5361
- const e = s.moduleBaseUrl ?? `https://cdn.jsdelivr.net/npm/@fxi/zartigl@${pt.version}/dist`, t = s.source ?? "auto", i = It(s), a = Ut(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)},
5362
5426
  `, n = s.geoVideo == null ? "" : ` geoVideo: ${$(s.geoVideo, 2)},
5363
5427
  `, o = i == null ? "" : ` style: ${$(i, 2)},
5364
- `, c = a == null ? "" : ` settings: ${$(a, 2)},
5365
- `, u = s.time == null ? "" : ` time: ${Ft(s.time)},
5366
- `, l = s.depth == null ? "" : ` depth: ${s.depth},
5367
- `, d = s.center ?? [0, 20], f = s.projection ?? "mercator", m = s.mapStyle == null ? ga : q(s.mapStyle), p = `map.setProjection({ type: ${q(f)} });
5428
+ `, l = a == null ? "" : ` settings: ${$(a, 2)},
5429
+ `, d = s.time == null ? "" : ` time: ${Ut(s.time)},
5430
+ `, c = s.depth == null ? "" : ` depth: ${s.depth},
5431
+ `, u = s.center ?? [0, 20], f = s.projection ?? "mercator", m = s.mapStyle == null ? xa : q(s.mapStyle), p = `map.setProjection({ type: ${q(f)} });
5368
5432
  map.jumpTo({
5369
- center: [${ie(d[0])}, ${ie(d[1])}],
5433
+ center: [${ie(u[0])}, ${ie(u[1])}],
5370
5434
  zoom: ${ie(s.zoom ?? 2, 3)},
5371
5435
  bearing: ${ie(s.bearing ?? 0, 3)},
5372
5436
  pitch: ${ie(s.pitch ?? 0, 3)},
@@ -5393,10 +5457,10 @@ const z = new Zartigl({
5393
5457
  catalog,
5394
5458
  layer: ${q(s.layerId)},
5395
5459
  source: ${q(t)},
5396
- ${r}${n}${o}${c}${u}${l}});
5460
+ ${r}${n}${o}${l}${d}${c}});
5397
5461
 
5398
5462
  await z.init();`;
5399
- return `import maplibregl from ${q(fa)};
5463
+ return `import maplibregl from ${q(ya)};
5400
5464
  import { Zartigl } from "${e}/zartigl.js";
5401
5465
  import { catalog } from "${e}/catalog.js";
5402
5466
 
@@ -5408,18 +5472,18 @@ const map = new maplibregl.Map({
5408
5472
  });
5409
5473
 
5410
5474
  map.once("style.load", async () => {
5411
- ${ya(p, 2)}
5475
+ ${Sa(p, 2)}
5412
5476
  });`;
5413
5477
  }
5414
- function Da(s) {
5415
- const e = xa(s);
5478
+ function Fa(s) {
5479
+ const e = Ta(s);
5416
5480
  return `<!doctype html>
5417
5481
  <html lang="en">
5418
5482
  <head>
5419
5483
  <meta charset="UTF-8" />
5420
5484
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
5421
5485
  <title>Zartigl demo</title>
5422
- <link rel="stylesheet" href=${q(pa)} />
5486
+ <link rel="stylesheet" href=${q(_a)} />
5423
5487
  <style>
5424
5488
  html, body, #map {
5425
5489
  width: 100%;
@@ -5441,41 +5505,41 @@ ${e}
5441
5505
  </html>`;
5442
5506
  }
5443
5507
  export {
5444
- ni as BACKDROP_OFF,
5445
- oi as COLOR_GRADE_OFF,
5446
- Ua as COLOR_GRADE_VIBRANT,
5447
- ia 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,
5448
5512
  G as GeoVideoLayer,
5449
- At as LEGACY_STYLE_SETTINGS,
5450
- wt as ParticleSimulation,
5513
+ Ft as LEGACY_STYLE_SETTINGS,
5514
+ Rt as ParticleSimulation,
5451
5515
  me as ScalarLayer,
5452
- tt as VECTOR_GEOVIDEO_SPEEDS,
5453
- D as VectorLayer,
5454
- Tt as VelocityField,
5455
- ye as ZarrSource,
5456
- Pa as Zartigl,
5457
- _e as ZartiglFrameUnavailableError,
5458
- La as buildMapxWidgetSnippet,
5459
- Da as buildStandaloneDemoHtml,
5460
- xa as buildStandaloneDemoSnippet,
5461
- Wi as buildWmtsLegendUrl,
5462
- Ke as buildWmtsTileUrl,
5463
- hi as colorGradeToGrade,
5464
- Oi as deriveDirectionMagnitudeComponents,
5465
- He as formatUnit,
5466
- jt as geoVideoSecondsForTime,
5467
- ka as geoVideoTimeForSeconds,
5468
- Se as geoVideoTimelineValues,
5469
- vt as getPalettes,
5470
- Ra as getVectorDerivationVariables,
5471
- ui as gradeToColorGrade,
5472
- Va as isHexColor,
5473
- Ae as loadGeoVideoManifest,
5474
- xt as resolveBackdrop,
5475
- _t as resolveColorGrade,
5476
- Ce as resolveColorRamp,
5477
- Ea as resolveTimeInputSelection,
5478
- De as splitLegacySettings,
5479
- Mt as stitchVelocityChunks,
5480
- Fa as validateGeoVideoManifest
5516
+ it as VECTOR_GEOVIDEO_SPEEDS,
5517
+ P as VectorLayer,
5518
+ Pt as VelocityField,
5519
+ _e as ZarrSource,
5520
+ Aa as Zartigl,
5521
+ xe as ZartiglFrameUnavailableError,
5522
+ ka as buildMapxWidgetSnippet,
5523
+ Fa as buildStandaloneDemoHtml,
5524
+ Ta as buildStandaloneDemoSnippet,
5525
+ Zi as buildWmtsLegendUrl,
5526
+ Je as buildWmtsTileUrl,
5527
+ fi as colorGradeToGrade,
5528
+ Wi as deriveDirectionMagnitudeComponents,
5529
+ Ye as formatUnit,
5530
+ ei as geoVideoSecondsForTime,
5531
+ Ua as geoVideoTimeForSeconds,
5532
+ we as geoVideoTimelineValues,
5533
+ _t as getPalettes,
5534
+ Da as getVectorDerivationVariables,
5535
+ pi as gradeToColorGrade,
5536
+ Oa as isHexColor,
5537
+ Ce as loadGeoVideoManifest,
5538
+ St as resolveBackdrop,
5539
+ bt as resolveColorGrade,
5540
+ ke as resolveColorRamp,
5541
+ Ca as resolveTimeInputSelection,
5542
+ Ae as splitLegacySettings,
5543
+ Et as stitchVelocityChunks,
5544
+ Na as validateGeoVideoManifest
5481
5545
  };