@epam/statgpt-sdmx-toolkit 0.1.0-rc.0 → 0.1.0-rc.2

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/index.mjs CHANGED
@@ -1,102 +1,99 @@
1
- const $ = (e) => {
1
+ const P = (e) => {
2
2
  if (e != null) {
3
3
  const t = e.split("=");
4
4
  return t.length === 1 ? e : t[1];
5
5
  }
6
- }, p = (e) => {
6
+ }, S = (e) => {
7
7
  var r;
8
8
  if (e == null)
9
9
  return {};
10
- const t = $(e), n = {
10
+ const t = P(e), n = {
11
11
  agency: "",
12
12
  id: "",
13
13
  version: ""
14
14
  };
15
15
  return t && (t.includes(":") && (n.agency = t.split(":")[0], n.id = t.split(":")[1].split("(")[0]), t.includes("(") && t.includes(")") && (n.version = (r = t.split("(")[1]) == null ? void 0 : r.split(")")[0])), n;
16
- }, Re = (e) => {
17
- const [t, n] = e.split(")."), { agency: r, id: s, version: o } = p(t + ")");
16
+ }, Pe = (e) => {
17
+ const [t, n] = e.split(")."), { agency: r, id: s, version: o } = S(t + ")");
18
18
  return { childId: n, agency: r, id: s, version: o };
19
- }, Jt = (e, t, n) => {
19
+ }, tn = (e, t, n) => {
20
20
  const r = t === "" ? "" : `(${t})`;
21
21
  return `${n}:${e}${r}`;
22
22
  };
23
- var I = /* @__PURE__ */ ((e) => (e.DESCENDANTS = "descendants", e.NONE = "none", e.ALL = "all", e))(I || {}), le = /* @__PURE__ */ ((e) => (e.EXACT = "exact", e.AVAILABLE = "available", e))(le || {});
23
+ var O = /* @__PURE__ */ ((e) => (e.DESCENDANTS = "descendants", e.NONE = "none", e.ALL = "all", e))(O || {}), le = /* @__PURE__ */ ((e) => (e.EXACT = "exact", e.AVAILABLE = "available", e))(le || {});
24
24
  const Ne = (e = "", t = "", n = "") => `sdmx/3.0/availability/dataflow/${e}/${t}/${n}`;
25
- class Xt {
25
+ class nn {
26
26
  constructor(t) {
27
27
  this.client = t;
28
28
  }
29
29
  async getConstraints(t, n) {
30
- const { agency: r, id: s, version: o } = p(t), i = {
30
+ const { agency: r, id: s, version: o } = S(t), i = {
31
31
  filters: n || [],
32
32
  mode: le.AVAILABLE,
33
- references: I.NONE
33
+ references: O.NONE
34
34
  }, c = Ne(r, s, o);
35
35
  return await this.client.postRequest(c, { body: i });
36
36
  }
37
37
  }
38
- var S = /* @__PURE__ */ ((e) => (e.CSV = "csv", e.JSON = "json", e.XML = "xml", e))(S || {}), me = /* @__PURE__ */ ((e) => (e.ID = "id", e.NAME = "name", e.ID_NAME = "both", e))(me || {}), Pe = /* @__PURE__ */ ((e) => (e.FULL_DATASET = "full", e.DATA_IN_TABLE = "query", e))(Pe || {});
39
- const Ie = (e, t) => {
38
+ var w = /* @__PURE__ */ ((e) => (e.CSV = "csv", e.JSON = "json", e.XML = "xml", e))(w || {}), Ie = /* @__PURE__ */ ((e) => (e.ID = "id", e.NAME = "name", e.ID_NAME = "both", e))(Ie || {}), _e = /* @__PURE__ */ ((e) => (e.FULL_DATASET = "full", e.DATA_IN_TABLE = "query", e))(_e || {});
39
+ const Oe = (e, t) => {
40
40
  switch (e) {
41
- case S.CSV:
42
- return w(
41
+ case w.CSV:
42
+ return v(
43
43
  "application/vnd.sdmx.data+csv;version=2.0.0",
44
44
  t
45
45
  );
46
- case S.XML:
47
- return w(
46
+ case w.XML:
47
+ return v(
48
48
  "application/vnd.sdmx.data+xml;version=3.0.0",
49
49
  t
50
50
  );
51
- case S.JSON:
52
- return w(`application/${e}`, t);
51
+ case w.JSON:
52
+ return v(`application/${e}`, t);
53
53
  default:
54
- return w(
54
+ return v(
55
55
  "application/vnd.sdmx.data+csv;version=2.0.0",
56
56
  t
57
57
  );
58
58
  }
59
- }, w = (e, t) => `${e}; labels=${t}`;
60
- var O = /* @__PURE__ */ ((e) => (e.REFERENCE_PARTIAL = "referencepartial", e.FULL = "full", e))(O || {});
61
- const Oe = "all", be = "sdmx/3.0/data/dataflow", F = (e, t, n) => {
62
- const { filterKey: r, timeFilter: s } = n, { agency: o, id: i, version: c } = p(e), a = [encodeURIComponent(s || ""), t].filter((g) => !!g).join("&");
63
- return `${`${be}/${o}/${i}/${c}`}/${r || "*"}?${a}`;
64
- }, _e = (e = "", t = "", n = "", r = I.DESCENDANTS) => `sdmx/3.0/structure/dataflow/${e}/${t}/${n}?references=${r}&detail=${O.REFERENCE_PARTIAL}&forceDataflowDynamicAnnotations=true`;
65
- class Zt {
59
+ }, v = (e, t) => `${e}; labels=${t}`;
60
+ var de = /* @__PURE__ */ ((e) => (e.REFERENCE_PARTIAL = "referencepartial", e.FULL = "full", e))(de || {});
61
+ const me = "all", Le = "sdmx/3.0/data/dataflow", fe = "&", F = ":", be = "=", Ue = "+", rn = ",", qe = "*", z = (e, t, n) => {
62
+ const { filterKey: r, timeFilter: s } = n, { agency: o, id: i, version: c } = S(e), a = [s || "", t].filter((l) => !!l).join(fe);
63
+ return `${`${Le}/${o}/${i}/${c}`}/${r || qe}?${a}`;
64
+ }, We = (e = "", t = "", n = "", r = O.DESCENDANTS) => `sdmx/3.0/structure/dataflow/${e}/${t}/${n}?references=${r}&detail=${de.REFERENCE_PARTIAL}`;
65
+ class sn {
66
66
  constructor(t) {
67
67
  this.client = t;
68
68
  }
69
69
  async getDataSet(t, n) {
70
- const { agency: r, id: s, version: o } = p(t);
70
+ const { agency: r, id: s, version: o } = S(t);
71
71
  return await this.client.getRequest(
72
- _e(r, s, o, n)
72
+ We(r, s, o, n)
73
73
  );
74
74
  }
75
75
  async getDatasetData(t, n) {
76
76
  const r = new URLSearchParams({
77
77
  includeHistory: "false",
78
78
  limit: "10000",
79
- attributes: Oe,
80
- dimensionAtObservation: "TIME_PERIOD",
79
+ attributes: me,
80
+ dimensionAtObservation: "TIME_PERIOD"
81
81
  // TODO: use time dimensions
82
- detail: O.FULL
83
- }).toString(), s = F(t, r, n);
84
- return await this.client.request(s, {
85
- method: "GET"
86
- });
82
+ }).toString(), s = z(t, r, n);
83
+ return await this.client.getRequest(s);
87
84
  }
88
85
  async downloadDataSet(t, n, r, s, o, i, c = !1) {
89
86
  const a = new URLSearchParams({
90
87
  format: n,
91
88
  compress: "false",
92
89
  attributes: c ? "all" : "none"
93
- }).toString(), u = F(t, a, o);
90
+ }).toString(), u = z(t, a, o);
94
91
  return this.client.streamRequest(
95
92
  u,
96
93
  {
97
94
  method: "GET",
98
95
  headers: {
99
- Accept: Ie(n, s),
96
+ Accept: Oe(n, s),
100
97
  "Accept-language": r
101
98
  }
102
99
  },
@@ -104,20 +101,20 @@ class Zt {
104
101
  );
105
102
  }
106
103
  }
107
- const z = async (e, t, n) => await fetch(e, {
104
+ const H = async (e, t, n) => await fetch(e, {
108
105
  method: n.method || "GET",
109
106
  headers: t,
110
107
  body: n.body ? JSON.stringify(n.body) : void 0
111
- }), Le = "application/json", Ue = "Content-Type", R = "Api-Key", qe = "X-CONVERSATION-ID", H = (e, t, n) => {
108
+ }), xe = "application/json", Be = "Content-Type", N = "Api-Key", Ve = "X-CONVERSATION-ID", J = (e, t, n) => {
112
109
  const r = {
113
- [Ue]: (t == null ? void 0 : t.contentType) || Le
110
+ [Be]: (t == null ? void 0 : t.contentType) || xe
114
111
  };
115
- return t != null && t.jwt && (r.Authorization = `Bearer ${t.jwt}`), t != null && t.chatReference && (r[qe] = t.chatReference), { ...r, ...n };
116
- }, We = (e) => {
112
+ return t != null && t.jwt && (r.Authorization = `Bearer ${t.jwt}`), t != null && t.chatReference && (r[Ve] = t.chatReference), { ...r, ...n };
113
+ }, Ce = (e) => {
117
114
  const t = { ...e };
118
- return t[R] && (t[R] = t[R].substring(0, 8) + "...[REDACTED]"), t.Authorization && (t.Authorization = "Bearer [REDACTED]"), t;
119
- }, xe = (e, t) => e.error || e.message || `${t.status} ${t.statusText}`;
120
- class en {
115
+ return t[N] && (t[N] = t[N].substring(0, 8) + "...[REDACTED]"), t.Authorization && (t.Authorization = "Bearer [REDACTED]"), t;
116
+ }, Ye = (e, t) => e.error || e.message || `${t.status} ${t.statusText}`;
117
+ class on {
121
118
  constructor(t) {
122
119
  this.config = t, console.info("SdmxApiClient initialized", {
123
120
  apiUrl: t.apiUrl || "NOT SET"
@@ -131,7 +128,7 @@ class en {
131
128
  }
132
129
  async streamRequest(t, n, r) {
133
130
  const s = `${this.config.apiUrl}/${t}`, o = {
134
- ...H(void 0, {
131
+ ...J(void 0, {
135
132
  jwt: this.config.jwt
136
133
  }),
137
134
  ...n.headers
@@ -141,7 +138,7 @@ class en {
141
138
  async start(a) {
142
139
  var u;
143
140
  try {
144
- const l = await z(s, o, n);
141
+ const l = await H(s, o, n);
145
142
  if (!l.ok) {
146
143
  const f = await l.text();
147
144
  throw console.error(
@@ -150,11 +147,11 @@ class en {
150
147
  }
151
148
  const g = (u = l.body) == null ? void 0 : u.getReader();
152
149
  if (!g) throw new Error("Failed to create stream reader");
153
- const h = new Uint8Array([239, 187, 191]);
154
- a.enqueue(h);
150
+ const E = new Uint8Array([239, 187, 191]);
151
+ a.enqueue(E);
155
152
  const d = async () => {
156
- const { done: f, value: E } = await g.read();
157
- f ? a.close() : (a.enqueue(E), await d());
153
+ const { done: f, value: A } = await g.read();
154
+ f ? a.close() : (a.enqueue(A), await d());
158
155
  };
159
156
  d();
160
157
  } catch (l) {
@@ -168,14 +165,14 @@ class en {
168
165
  }
169
166
  async request(t, n) {
170
167
  const r = Date.now(), s = t.includes("availability") && this.config.constrainsApiUrl ? `${this.config.constrainsApiUrl}/${t}` : `${this.config.apiUrl}/${t}`, o = {
171
- ...H(void 0, {
168
+ ...J(void 0, {
172
169
  jwt: this.config.jwt
173
170
  }),
174
171
  ...n.headers
175
172
  };
176
173
  this.config.apiKey != null && (o["Ocp-Apim-Subscription-Key"] = this.config.apiKey), this.addInfoRequestLog("API Request", s, n, o);
177
174
  try {
178
- const i = await z(s, o, n), c = Date.now() - r;
175
+ const i = await H(s, o, n), c = Date.now() - r;
179
176
  let a;
180
177
  const u = await i.text();
181
178
  try {
@@ -195,7 +192,7 @@ class en {
195
192
  }
196
193
  if (!i.ok) {
197
194
  this.addErrorRequestLog(s, n, i, c, a);
198
- const l = xe(a, i);
195
+ const l = Ye(a, i);
199
196
  throw new Error(`API request failed: ${l}`);
200
197
  }
201
198
  return a;
@@ -213,7 +210,7 @@ class en {
213
210
  const o = {
214
211
  method: r.method || "GET",
215
212
  url: n,
216
- headers: We(s)
213
+ headers: Ce(s)
217
214
  };
218
215
  r.body && (o.body = r.body), console.info(t, o);
219
216
  }
@@ -239,126 +236,125 @@ class en {
239
236
  });
240
237
  }
241
238
  }
242
- const de = "+", tn = ",";
243
- var Be = /* @__PURE__ */ ((e) => (e.CONDITIONAL = "Conditional", e.MANDATORY = "Mandatory", e))(Be || {}), b = /* @__PURE__ */ ((e) => (e.DIMENSION = "Dimension", e.MEASURE_DIMENSION = "MeasureDimension", e.TIME_DIMENSION = "TimeDimension", e))(b || {}), Ce = /* @__PURE__ */ ((e) => (e.UNBOUNDED = "unbounded", e))(Ce || {});
244
- const Ve = (e, t) => {
239
+ var ke = /* @__PURE__ */ ((e) => (e.CONDITIONAL = "Conditional", e.MANDATORY = "Mandatory", e))(ke || {}), m = /* @__PURE__ */ ((e) => (e.DIMENSION = "Dimension", e.MEASURE_DIMENSION = "MeasureDimension", e.TIME_DIMENSION = "TimeDimension", e))(m || {}), Me = /* @__PURE__ */ ((e) => (e.UNBOUNDED = "unbounded", e))(Me || {});
240
+ const Qe = (e, t) => {
245
241
  var c, a, u, l, g;
246
242
  const n = (a = (c = e == null ? void 0 : e.data) == null ? void 0 : c.dataSets) == null ? void 0 : a[0], r = (l = (u = e == null ? void 0 : e.data) == null ? void 0 : u.structures) == null ? void 0 : l[0], s = ((g = r == null ? void 0 : r.attributes) == null ? void 0 : g.dimensionGroup) || [], o = n == null ? void 0 : n.dimensionGroupAttributes, i = {};
247
- for (const h of s) {
248
- const d = h.relationship.dimensions, { codedSeriesKey: f, decodedSeriesKey: E } = fe(
243
+ for (const E of s) {
244
+ const d = E.relationship.dimensions, { codedSeriesKey: f, decodedSeriesKey: A } = ge(
249
245
  e,
250
246
  t,
251
247
  d
252
248
  );
253
- i[h.id] = {
249
+ i[E.id] = {
254
250
  values: (o == null ? void 0 : o[f]) || [],
255
- decodedSeriesKey: E,
251
+ decodedSeriesKey: A,
256
252
  codedSeriesKey: f
257
253
  };
258
254
  }
259
255
  return i;
260
- }, fe = (e, t, n) => {
256
+ }, ge = (e, t, n) => {
261
257
  var c, a;
262
258
  const r = (a = (c = e == null ? void 0 : e.data) == null ? void 0 : c.structures) == null ? void 0 : a[0], s = [
263
259
  ...(r == null ? void 0 : r.dimensions.series) || [],
264
260
  ...(r == null ? void 0 : r.dimensions.observation) || []
265
261
  ], o = new Array(s == null ? void 0 : s.length), i = new Array(s == null ? void 0 : s.length);
266
262
  return n == null || n.forEach((u) => {
267
- const l = (s == null ? void 0 : s.findIndex((d) => d.id === u)) || 0, g = t[l], h = s[l].values.findIndex(
263
+ const l = (s == null ? void 0 : s.findIndex((d) => d.id === u)) || 0, g = t[l], E = s[l].values.findIndex(
268
264
  (d) => d.id === g || d.value === g
269
265
  ) || 0;
270
- o[l] = h >= 0 ? h : g, i[l] = g;
266
+ o[l] = E >= 0 ? E : g, i[l] = g;
271
267
  }), {
272
268
  codedSeriesKey: o.join(":"),
273
269
  decodedSeriesKey: i.join(":")
274
270
  };
275
- }, nn = (e, t, n) => {
276
- var g, h, d, f, E;
277
- const r = (h = (g = e == null ? void 0 : e.data) == null ? void 0 : g.dataSets) == null ? void 0 : h[0], s = (f = (d = e == null ? void 0 : e.data) == null ? void 0 : d.structures) == null ? void 0 : f[0], o = (((E = s == null ? void 0 : s.attributes) == null ? void 0 : E.dimensionGroup) || []).filter(
278
- (A) => {
271
+ }, cn = (e, t, n) => {
272
+ var g, E, d, f, A;
273
+ const r = (E = (g = e == null ? void 0 : e.data) == null ? void 0 : g.dataSets) == null ? void 0 : E[0], s = (f = (d = e == null ? void 0 : e.data) == null ? void 0 : d.structures) == null ? void 0 : f[0], o = (((A = s == null ? void 0 : s.attributes) == null ? void 0 : A.dimensionGroup) || []).filter(
274
+ (h) => {
279
275
  var y;
280
- return ((y = A.relationship.dimensions) == null ? void 0 : y.length) === 1 && A.relationship.dimensions.includes(t || "");
276
+ return ((y = h.relationship.dimensions) == null ? void 0 : y.length) === 1 && h.relationship.dimensions.includes(t || "");
281
277
  }
282
278
  ), i = r == null ? void 0 : r.dimensionGroupAttributes, c = [
283
279
  ...(s == null ? void 0 : s.dimensions.series) || [],
284
280
  ...(s == null ? void 0 : s.dimensions.observation) || []
285
- ], a = c == null ? void 0 : c.findIndex((A) => A.id === t), u = new Array(c == null ? void 0 : c.length);
281
+ ], a = c == null ? void 0 : c.findIndex((h) => h.id === t), u = new Array(c == null ? void 0 : c.length);
286
282
  u[a] = n || "";
287
283
  const l = {};
288
- for (const A of o) {
289
- const y = A.relationship.dimensions, { codedSeriesKey: D, decodedSeriesKey: v } = fe(
284
+ for (const h of o) {
285
+ const y = h.relationship.dimensions, { codedSeriesKey: D, decodedSeriesKey: p } = ge(
290
286
  e,
291
287
  u,
292
288
  y
293
289
  );
294
- l[A.id] = {
290
+ l[h.id] = {
295
291
  values: (i == null ? void 0 : i[D]) || [],
296
- decodedSeriesKey: v,
292
+ decodedSeriesKey: p,
297
293
  codedSeriesKey: D
298
294
  };
299
295
  }
300
296
  return l;
301
- }, Ye = (e, t) => {
297
+ }, Ge = (e, t) => {
302
298
  var r;
303
299
  if (t == null)
304
300
  return;
305
301
  const n = (r = e.values) == null ? void 0 : r[t];
306
302
  return n ?? (t instanceof Array ? { values: t } : { value: t.toString() });
307
- }, ke = "Observation", rn = (e) => {
308
- var u, l, g, h, d, f;
303
+ }, Ke = "Observation", an = (e) => {
304
+ var u, l, g, E, d, f;
309
305
  const t = (u = e == null ? void 0 : e.data) == null ? void 0 : u.dataSets, n = (g = (l = e == null ? void 0 : e.data) == null ? void 0 : l.structures) == null ? void 0 : g[0];
310
306
  if (!t || !n)
311
307
  return [];
312
- const r = n.attributes, s = n.dimensions, o = (r == null ? void 0 : r.dimensionGroup) || [], i = t[0].series || t[0].observations, c = (h = s.series) != null && h.length ? s.series : s.observation, a = [];
313
- for (const E in i) {
314
- const A = [], { name: y, parsedTimeSeriesValue: D } = Ke(
315
- E,
308
+ const r = n.attributes, s = n.dimensions, o = (r == null ? void 0 : r.dimensionGroup) || [], i = t[0].series || t[0].observations, c = (E = s.series) != null && E.length ? s.series : s.observation, a = [];
309
+ for (const A in i) {
310
+ const h = [], { name: y, parsedTimeSeriesValue: D } = je(
311
+ A,
316
312
  c
317
- ), v = i[E], De = v.attributes || [];
318
- if (Object.keys(v).length === 0) {
313
+ ), p = i[A], Te = p.attributes || [];
314
+ if (Object.keys(p).length === 0) {
319
315
  a.push({
320
316
  name: y,
321
317
  parsedTimeSeriesValue: D,
322
- values: A,
318
+ values: h,
323
319
  attributes: [],
324
320
  dataSetAttrs: []
325
321
  });
326
322
  continue;
327
323
  }
328
- A.push(
329
- ...je(v, n)
324
+ h.push(
325
+ ...Je(p, n)
330
326
  );
331
- const Te = N(
327
+ const Re = I(
332
328
  (r == null ? void 0 : r.series) || [],
333
- (T) => De[T]
334
- ), ve = Fe(
329
+ (T) => Te[T]
330
+ ), pe = Xe(
335
331
  ((d = n.attributes) == null ? void 0 : d.dataSet) || [],
336
332
  ((f = t[0].attributes) == null ? void 0 : f.filter((T) => T != null)) || []
337
- ), pe = Ve(
333
+ ), Se = Qe(
338
334
  e,
339
335
  D
340
- ), we = o.map((T, Se) => {
341
- const j = pe[T.id], $e = Ye(
336
+ ), ve = o.map((T, $e) => {
337
+ const j = Se[T.id], we = Ge(
342
338
  T,
343
- j.values[Se]
339
+ j.values[$e]
344
340
  );
345
341
  return {
346
342
  attribute: T,
347
- dimensionGroupValue: $e,
343
+ dimensionGroupValue: we,
348
344
  dimensionGroupData: j
349
345
  };
350
346
  });
351
347
  a.push({
352
348
  name: y,
353
349
  parsedTimeSeriesValue: D,
354
- values: A,
355
- attributes: Te,
356
- dataSetAttrs: ve,
357
- dimensionGroupAttributes: we
350
+ values: h,
351
+ attributes: Re,
352
+ dataSetAttrs: pe,
353
+ dimensionGroupAttributes: ve
358
354
  });
359
355
  }
360
356
  return a;
361
- }, Ke = (e, t) => {
357
+ }, je = (e, t) => {
362
358
  const n = e.split(new RegExp("(?<!\\|):(?!\\||$)")), r = [];
363
359
  for (let s = 0; s < n.length; s++) {
364
360
  const o = t == null ? void 0 : t[s], i = Number(n[s]);
@@ -372,69 +368,69 @@ const Ve = (e, t) => {
372
368
  r.push((c == null ? void 0 : c.id) || (c == null ? void 0 : c.value) || "");
373
369
  }
374
370
  return {
375
- name: Ge(r),
371
+ name: ze(r),
376
372
  parsedTimeSeriesValue: r
377
373
  };
378
- }, N = (e, t) => {
374
+ }, I = (e, t) => {
379
375
  const n = [];
380
376
  for (let r = 0; r < e.length; r++) {
381
- const s = e[r], o = t(r), i = o != null && s.values != null ? Me(o, s) : void 0;
377
+ const s = e[r], o = t(r), i = o != null && s.values != null ? Fe(o, s) : void 0;
382
378
  n.push({
383
379
  name: s.id,
384
380
  value: i
385
381
  });
386
382
  }
387
383
  return n;
388
- }, Me = (e, t) => {
384
+ }, Fe = (e, t) => {
389
385
  const n = t.values[e];
390
386
  return n == null ? typeof e == "object" ? e : e.toString() : (n == null ? void 0 : n.id) || (n == null ? void 0 : n.value) || (n == null ? void 0 : n.ids) || (n == null ? void 0 : n.values);
391
- }, Ge = (e) => e.map((t) => t ? Qe(t) : "").join("."), Qe = (e) => e.replace(/\./g, "|.").replace(/:/g, "|:"), je = (e, t) => {
387
+ }, ze = (e) => e.map((t) => t ? He(t) : "").join("."), He = (e) => e.replace(/\./g, "|.").replace(/:/g, "|:"), Je = (e, t) => {
392
388
  var i, c, a, u, l;
393
389
  const n = (c = (i = t.measures) == null ? void 0 : i.observation) == null ? void 0 : c.length;
394
390
  if (e.observations == null)
395
391
  return [
396
392
  {
397
- values: J(e, t.measures),
398
- obsAttributes: N(
393
+ values: X(e, t.measures),
394
+ obsAttributes: I(
399
395
  ((a = t.attributes) == null ? void 0 : a.observation) || [],
400
396
  (g) => e[g + n]
401
397
  ),
402
- dimensionAtObservation: ke
398
+ dimensionAtObservation: Ke
403
399
  }
404
400
  ];
405
401
  const r = e.observations, s = (u = t.dimensions.observation) == null ? void 0 : u[0], o = [];
406
402
  for (const g in r) {
407
- const h = s == null ? void 0 : s.values[g];
403
+ const E = s == null ? void 0 : s.values[g];
408
404
  o.push({
409
- dimensionAtObservation: (h == null ? void 0 : h.value) || (h == null ? void 0 : h.id),
410
- values: J(
405
+ dimensionAtObservation: (E == null ? void 0 : E.value) || (E == null ? void 0 : E.id),
406
+ values: X(
411
407
  r[g],
412
408
  t.measures
413
409
  ),
414
- obsAttributes: N(
410
+ obsAttributes: I(
415
411
  ((l = t.attributes) == null ? void 0 : l.observation) || [],
416
412
  (d) => r[g][d + n]
417
413
  )
418
414
  });
419
415
  }
420
416
  return o;
421
- }, J = (e, t) => {
417
+ }, X = (e, t) => {
422
418
  var n;
423
419
  return ((n = t == null ? void 0 : t.observation) == null ? void 0 : n.map((r, s) => ({ name: r.id, value: e[s] }))) || [];
424
- }, Fe = (e, t) => e.reduce(
420
+ }, Xe = (e, t) => e.reduce(
425
421
  (n, r, s) => {
426
422
  const o = t[s];
427
- return ze(n, r, o, ""), n;
423
+ return Ze(n, r, o, ""), n;
428
424
  },
429
425
  []
430
- ), ze = (e, t, n, r) => {
426
+ ), Ze = (e, t, n, r) => {
431
427
  var o, i, c;
432
428
  const s = n != null ? ((o = t == null ? void 0 : t.values) == null ? void 0 : o.length) > 0 ? ((i = t.values[n]) == null ? void 0 : i.id) || ((c = t.values[n]) == null ? void 0 : c.value) : String(n) : r;
433
429
  e.push({
434
430
  name: t.id,
435
431
  value: s || ""
436
432
  });
437
- }, He = /^[0-9][0-9][0-9][0-9]-Q[1-4]$/, Je = /^[0-9][0-9][0-9][0-9]-W[0-9][0-9]?$/, Xe = /^[0-9][0-9][0-9][0-9]-S[1-2]$/, Ze = /^[0-9][0-9][0-9][0-9]$/, et = /^[0-9][0-9][0-9][0-9]-(0[1-9]|1[0-2])-[0-9][0-9]$/, tt = /^[0-9][0-9][0-9][0-9]-M(0[1-9]|(1[0-2]))$/, _ = (e) => Ze.exec(e), L = (e) => !!_(e), nt = (e) => Xe.exec(e), U = (e) => !!nt(e), q = (e) => tt.exec(e), W = (e) => !!q(e), x = (e) => He.exec(e), B = (e) => !!x(e), rt = (e) => et.exec(e), st = (e) => !!rt(e), ot = (e) => Je.exec(e), C = (e) => !!ot(e), V = 1440 * 60 * 1e3, Y = 7 * V;
433
+ }, et = /^[0-9][0-9][0-9][0-9]-Q[1-4]$/, tt = /^[0-9][0-9][0-9][0-9]-W[0-9][0-9]?$/, nt = /^[0-9][0-9][0-9][0-9]-S[1-2]$/, rt = /^[0-9][0-9][0-9][0-9]$/, st = /^[0-9][0-9][0-9][0-9]-(0[1-9]|1[0-2])-[0-9][0-9]$/, ot = /^[0-9][0-9][0-9][0-9]-M(0[1-9]|(1[0-2]))$/, L = (e) => rt.exec(e), b = (e) => !!L(e), it = (e) => nt.exec(e), U = (e) => !!it(e), q = (e) => ot.exec(e), W = (e) => !!q(e), x = (e) => et.exec(e), B = (e) => !!x(e), ct = (e) => st.exec(e), at = (e) => !!ct(e), ut = (e) => tt.exec(e), V = (e) => !!ut(e), C = 1440 * 60 * 1e3, Y = 7 * C;
438
434
  function k(e) {
439
435
  const t = `${e}-01-01`, n = new Date(t);
440
436
  if (n.getDay() !== 4) {
@@ -443,55 +439,55 @@ function k(e) {
443
439
  }
444
440
  return n;
445
441
  }
446
- function it(e) {
442
+ function lt(e) {
447
443
  const t = new Date(e), r = -((t.getDay() + 6) % 7) + 3;
448
444
  return t.setDate(t.getDate() + r), new Date(t.valueOf());
449
445
  }
450
- function sn(e, t = "W") {
451
- const n = `${e}-12-31`, r = X(new Date(n), t);
446
+ function un(e, t = "W") {
447
+ const n = `${e}-12-31`, r = Z(new Date(n), t);
452
448
  if (r.weekYear === e)
453
449
  return r.weekNumber;
454
450
  const s = `${e}-12-24`;
455
- return X(new Date(s), t).weekNumber;
451
+ return Z(new Date(s), t).weekNumber;
456
452
  }
457
- function ct(e, t, n = "W") {
453
+ function dt(e, t, n = "W") {
458
454
  return `${e}-${n}${t < 10 ? "0" + t : t}`;
459
455
  }
460
- function X(e, t = "W") {
461
- const n = it(e), r = n.getFullYear(), s = k(r), o = 1 + Math.ceil(
456
+ function Z(e, t = "W") {
457
+ const n = lt(e), r = n.getFullYear(), s = k(r), o = 1 + Math.ceil(
462
458
  (n.getTime() - s.getTime()) / Y
463
459
  );
464
460
  return {
465
- code: ct(r, o, t),
461
+ code: dt(r, o, t),
466
462
  weekNumber: o,
467
463
  weekYear: r
468
464
  };
469
465
  }
470
- function at(e) {
471
- const [t, n] = e.split("-W"), s = k(+t).getTime() + (+n - 1) * Y - 3 * V;
466
+ function ft(e) {
467
+ const [t, n] = e.split("-W"), s = k(+t).getTime() + (+n - 1) * Y - 3 * C;
472
468
  return new Date(s);
473
469
  }
474
- function ut(e) {
475
- const [t, n] = e.split("-W"), s = k(+t).getTime() + (+n - 1) * Y + 3 * V;
470
+ function gt(e) {
471
+ const [t, n] = e.split("-W"), s = k(+t).getTime() + (+n - 1) * Y + 3 * C;
476
472
  return new Date(s);
477
473
  }
478
- function ge(e) {
479
- return L(e) ? lt(e) : U(e) ? ft(e) : B(e) ? ht(e) : W(e) ? Et(e) : C(e) ? at(e) : Dt(e);
474
+ function Ee(e) {
475
+ return b(e) ? Et(e) : U(e) ? At(e) : B(e) ? Dt(e) : W(e) ? Rt(e) : V(e) ? ft(e) : St(e);
480
476
  }
481
477
  function he(e) {
482
- return L(e) ? dt(e) : U(e) ? gt(e) : B(e) ? At(e) : W(e) ? yt(e) : C(e) ? ut(e) : Tt(e);
478
+ return b(e) ? ht(e) : U(e) ? yt(e) : B(e) ? Tt(e) : W(e) ? pt(e) : V(e) ? gt(e) : vt(e);
483
479
  }
484
- function lt(e) {
485
- const t = _(e);
480
+ function Et(e) {
481
+ const t = L(e);
486
482
  if (t)
487
483
  return new Date(Number(t[0]), 0, 1);
488
484
  }
489
- function dt(e) {
490
- const t = _(e);
485
+ function ht(e) {
486
+ const t = L(e);
491
487
  if (t)
492
488
  return new Date(Number(t[0]) + 1, 0, 1);
493
489
  }
494
- function ft(e) {
490
+ function At(e) {
495
491
  const [t, n] = e.split("-S");
496
492
  switch (+n) {
497
493
  case 1:
@@ -500,7 +496,7 @@ function ft(e) {
500
496
  return new Date(+t, 6, 1);
501
497
  }
502
498
  }
503
- function gt(e) {
499
+ function yt(e) {
504
500
  const [t, n] = e.split("-S");
505
501
  switch (+n) {
506
502
  case 1:
@@ -509,7 +505,7 @@ function gt(e) {
509
505
  return new Date(+t + 1, 0, 1);
510
506
  }
511
507
  }
512
- function ht(e) {
508
+ function Dt(e) {
513
509
  const t = x(e);
514
510
  if (!t)
515
511
  return;
@@ -525,7 +521,7 @@ function ht(e) {
525
521
  return new Date(+n, 9, 1);
526
522
  }
527
523
  }
528
- function At(e) {
524
+ function Tt(e) {
529
525
  const t = x(e);
530
526
  if (!t)
531
527
  return;
@@ -541,45 +537,45 @@ function At(e) {
541
537
  return new Date(+n + 1, 0, 1);
542
538
  }
543
539
  }
544
- function Et(e) {
540
+ function Rt(e) {
545
541
  const t = q(e);
546
542
  if (!t)
547
543
  return;
548
544
  const [n, r] = t[0].split("-M");
549
545
  return new Date(+n, +r - 1, 1);
550
546
  }
551
- function yt(e) {
547
+ function pt(e) {
552
548
  const t = q(e);
553
549
  if (!t)
554
550
  return;
555
551
  const [n, r] = t[0].split("-M");
556
552
  return new Date(+n, +r, 1);
557
553
  }
558
- const Dt = (e) => /* @__PURE__ */ new Date(`${e}T00:00:00`), Tt = (e) => {
554
+ const St = (e) => /* @__PURE__ */ new Date(`${e}T00:00:00`), vt = (e) => {
559
555
  const t = /* @__PURE__ */ new Date(`${e}T23:59:00`);
560
556
  return t.setMinutes(t.getMinutes() + 1), t;
561
- }, vt = 1, on = (e, t, n, r = !0, s = "Q") => {
562
- const o = [], i = t && t > 3 ? $t(t, r) : 1, c = n ? Math.floor((n - 1) / 3) : 4;
557
+ }, $t = 1, ln = (e, t, n, r = !0, s = "Q") => {
558
+ const o = [], i = t && t > 3 ? It(t, r) : 1, c = n ? Math.floor((n - 1) / 3) : 4;
563
559
  for (let a = i; a <= c; a++)
564
560
  o.push(`${e}-${s}${a}`);
565
561
  return o;
566
- }, cn = (e, t, n, r = "S") => {
562
+ }, dn = (e, t, n, r = "S") => {
567
563
  const s = [];
568
564
  return (t || 1) < 7 && (n || 12) > 6 && s.push(`${e}-${r}1`), n == null && s.push(`${e}-${r}2`), s;
569
- }, an = (e) => Math.ceil(e / 3), Ae = (e, t, n = "M") => `${e}-${n}${t.toString().padStart(2, "0")}`, pt = (e, t, n = "M") => {
565
+ }, fn = (e) => Math.ceil(e / 3), Ae = (e, t, n = "M") => `${e}-${n}${t.toString().padStart(2, "0")}`, wt = (e, t, n = "M") => {
570
566
  const r = [];
571
567
  for (let s = t; s <= 12; s++)
572
568
  r.push(Ae(e, s, n));
573
569
  return r;
574
- }, wt = (e, t, n, r = "M") => {
570
+ }, Pt = (e, t, n, r = "M") => {
575
571
  const s = [];
576
572
  for (let o = t; o < n; o++)
577
573
  s.push(Ae(e, o, r));
578
574
  return s;
579
- }, un = (e, t, n, r = "M") => {
575
+ }, gn = (e, t, n, r = "M") => {
580
576
  const s = t || 1, o = n == null, i = n || 12;
581
- return o ? pt(e, s, r) : wt(e, s, i, r);
582
- }, ln = (e, t, n = "M") => {
577
+ return o ? wt(e, s, r) : Pt(e, s, i, r);
578
+ }, En = (e, t, n = "M") => {
583
579
  switch (t) {
584
580
  case 0:
585
581
  return [
@@ -608,61 +604,61 @@ const Dt = (e) => /* @__PURE__ */ new Date(`${e}T00:00:00`), Tt = (e) => {
608
604
  default:
609
605
  return [];
610
606
  }
611
- }, dn = (e, t) => {
612
- const n = Z(t, !0), r = Z(e), s = n.getFullYear(), o = r.getFullYear(), i = n.getTime() <= r.getTime() ? o + vt - s : 0;
607
+ }, hn = (e, t) => {
608
+ const n = ee(t, !0), r = ee(e), s = n.getFullYear(), o = r.getFullYear(), i = n.getTime() <= r.getTime() ? o + $t - s : 0;
613
609
  return Array.from({ length: i }, (a, u) => s + u);
614
- }, Z = (e, t = !1) => {
615
- const n = St(e, t);
610
+ }, ee = (e, t = !1) => {
611
+ const n = Nt(e, t);
616
612
  return n ? (n.getTimezoneOffset() > 0 && n.setMinutes(n.getMinutes() + n.getTimezoneOffset()), n) : /* @__PURE__ */ new Date();
617
- }, St = (e, t = !1) => {
613
+ }, Nt = (e, t = !1) => {
618
614
  const n = Number(e);
619
- return e.toString().length !== 13 ? t ? ge(e) : he(e) : isNaN(n) ? /* @__PURE__ */ new Date(`${e}T00:00:00.000Z`) : new Date(n);
620
- }, $t = (e, t) => t ? Math.floor((e + 1) / 3) : Math.ceil((e + 1) / 3), fn = (e, t) => {
621
- const n = te(e) - te(t);
615
+ return e.toString().length !== 13 ? t ? Ee(e) : he(e) : isNaN(n) ? /* @__PURE__ */ new Date(`${e}T00:00:00.000Z`) : new Date(n);
616
+ }, It = (e, t) => t ? Math.floor((e + 1) / 3) : Math.ceil((e + 1) / 3), An = (e, t) => {
617
+ const n = ne(e) - ne(t);
622
618
  if (n === 0 && e !== t) {
623
- const r = ee(e), s = ee(t);
619
+ const r = te(e), s = te(t);
624
620
  return r - s;
625
621
  }
626
622
  return n;
627
- }, ee = (e) => L(e) ? 6 : U(e) ? 5 : B(e) ? 4 : W(e) ? 3 : C(e) ? 2 : st(e) ? 1 : 0, te = (e, t = !1) => {
628
- const n = t ? ge(e) : he(e);
623
+ }, te = (e) => b(e) ? 6 : U(e) ? 5 : B(e) ? 4 : W(e) ? 3 : V(e) ? 2 : at(e) ? 1 : 0, ne = (e, t = !1) => {
624
+ const n = t ? Ee(e) : he(e);
629
625
  return (n == null ? void 0 : n.getTime()) || 0;
630
626
  };
631
- var K = /* @__PURE__ */ ((e) => (e.LAST_UPDATE_AT = "lastUpdatedAt", e.SERIES_COUNT = "series_count", e))(K || {}), Rt = /* @__PURE__ */ ((e) => (e.C = "c", e))(Rt || {}), m = /* @__PURE__ */ ((e) => (e.EQUALS = "eq", e.NOT_EQUALS = "ne", e.LESS = "lt", e.LESS_OR_EQUAL = "le", e.GREATER = "gt", e.GREATER_OR_EQUAL = "ge", e.CONTAINS = "co", e.NOT_CONTAINS = "nc", e.STARTS = "sw", e.ENDS = "ew", e))(m || {}), Nt = /* @__PURE__ */ ((e) => (e.BOOLEAN = "Boolean", e.DATE_TIME = "DateTime", e.DECIMAL = "Decimal", e.INTEGER = "Integer", e.OBSERVATION_TIME_PERIOD = "ObservationalTimePeriod", e.STRING = "String", e.TIME = "Time", e.TIME_RANGE = "TimeRange", e.URI = "URI", e))(Nt || {});
632
- function gn(e) {
627
+ var M = /* @__PURE__ */ ((e) => (e.LAST_UPDATE_AT = "lastUpdatedAt", e.SERIES_COUNT = "series_count", e))(M || {}), _t = /* @__PURE__ */ ((e) => (e.C = "c", e))(_t || {}), R = /* @__PURE__ */ ((e) => (e.EQUALS = "eq", e.NOT_EQUALS = "ne", e.LESS = "lt", e.LESS_OR_EQUAL = "le", e.GREATER = "gt", e.GREATER_OR_EQUAL = "ge", e.CONTAINS = "co", e.NOT_CONTAINS = "nc", e.STARTS = "sw", e.ENDS = "ew", e))(R || {}), Ot = /* @__PURE__ */ ((e) => (e.BOOLEAN = "Boolean", e.DATE_TIME = "DateTime", e.DECIMAL = "Decimal", e.INTEGER = "Integer", e.OBSERVATION_TIME_PERIOD = "ObservationalTimePeriod", e.STRING = "String", e.TIME = "Time", e.TIME_RANGE = "TimeRange", e.URI = "URI", e))(Ot || {});
628
+ function yn(e) {
633
629
  var t, n;
634
630
  return (n = (t = e == null ? void 0 : e.annotations) == null ? void 0 : t.find((r) => {
635
- if (r.id === K.LAST_UPDATE_AT)
631
+ if (r.id === M.LAST_UPDATE_AT)
636
632
  return r;
637
633
  })) == null ? void 0 : n.value;
638
634
  }
639
- const M = (e, t) => (e == null ? void 0 : e.names) && (e == null ? void 0 : e.names[t]) || (e == null ? void 0 : e.name), Ee = (e, t, n) => {
635
+ const Q = (e, t) => (e == null ? void 0 : e.names) && (e == null ? void 0 : e.names[t]) || (e == null ? void 0 : e.name), ye = (e, t, n) => {
640
636
  if (!(!e || t != null && t.has(e == null ? void 0 : e.id)) && (t == null || t.set(e == null ? void 0 : e.id, e), e != null && e.parent)) {
641
637
  const r = n == null ? void 0 : n.get(e == null ? void 0 : e.parent);
642
- Ee(r, t, n);
638
+ ye(r, t, n);
643
639
  }
644
640
  }, mt = (e, t) => {
645
641
  const n = /* @__PURE__ */ new Map(), r = new Map(e == null ? void 0 : e.map((s) => [s.id, s]));
646
642
  return t == null || t.forEach((s) => {
647
- Ee(s, n, r);
643
+ ye(s, n, r);
648
644
  }), Array.from(n == null ? void 0 : n.values());
649
- }, Pt = "time_period_end", It = "time_period_start", hn = (e) => {
645
+ }, Lt = "time_period_end", bt = "time_period_start", Dn = "TIME_PERIOD", Tn = (e) => {
650
646
  const t = e == null ? void 0 : e.find(
651
- (o) => o.id === It
647
+ (o) => o.id === bt
652
648
  ), n = e == null ? void 0 : e.find(
653
- (o) => o.id === Pt
649
+ (o) => o.id === Lt
654
650
  ), r = n != null && n.title ? new Date(n == null ? void 0 : n.title) : null;
655
651
  return {
656
652
  startPeriod: t != null && t.title ? new Date(t == null ? void 0 : t.title) : null,
657
653
  endPeriod: r
658
654
  };
659
- }, Ot = (e, t) => e.id.localeCompare(t.id), bt = (e, t) => e.memberValue.localeCompare(t.memberValue), _t = (e, t) => {
655
+ }, Ut = (e, t) => e.id.localeCompare(t.id), qt = (e, t) => e.memberValue.localeCompare(t.memberValue), Wt = (e, t) => {
660
656
  const n = new Array(e.length), r = e.map((i, c) => [i, c]);
661
657
  r.sort(
662
- (i, c) => Ot(i[0], c[0])
658
+ (i, c) => Ut(i[0], c[0])
663
659
  );
664
660
  const s = [...t];
665
- s.sort(bt);
661
+ s.sort(qt);
666
662
  let o = 0;
667
663
  for (const i of r) {
668
664
  const c = i[0];
@@ -671,10 +667,10 @@ const M = (e, t) => (e == null ? void 0 : e.names) && (e == null ? void 0 : e.na
671
667
  o < s.length && s[o].memberValue === c.id && (n[i[1]] = i[0]);
672
668
  }
673
669
  return n.filter((i) => i != null);
674
- }, Lt = (e) => !!(e != null && e.some((t) => t.parent)), An = (e, t, n, r, s = []) => {
670
+ }, xt = (e) => !!(e != null && e.some((t) => t.parent)), Rn = (e, t, n, r, s = []) => {
675
671
  var i, c;
676
672
  let o = e || [];
677
- if (Ut(n || [], t || "")) {
673
+ if (Bt(n || [], t || "")) {
678
674
  const a = (i = (n || [])[0].cubeRegions) == null ? void 0 : i.find(
679
675
  ({ isIncluded: u }) => u
680
676
  );
@@ -685,132 +681,132 @@ const M = (e, t) => (e == null ? void 0 : e.names) && (e == null ? void 0 : e.na
685
681
  u ? o = o.length === 0 ? (u.selectionValues || []).map(({ memberValue: l }) => ({
686
682
  id: l,
687
683
  name: l
688
- })) : _t(o, u.selectionValues) : o = [];
684
+ })) : Wt(o, u.selectionValues) : o = [];
689
685
  }
690
686
  } else s.length !== 0 && (o = o.filter(({ id: a }) => s.includes(a)));
691
- return Lt(e) && (o = mt(e, o)), o == null ? void 0 : o.map((a) => ({
687
+ return xt(e) && (o = mt(e, o)), o == null ? void 0 : o.map((a) => ({
692
688
  ...a,
693
- name: r ? M(a, r) : a == null ? void 0 : a.name
689
+ name: r ? Q(a, r) : a == null ? void 0 : a.name
694
690
  }));
695
- }, Ut = (e, t) => e != null && e.length > 0 && t != null, qt = /^[v^~<>=]*?(\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+))?(?:-([\da-z\-]+(?:\.[\da-z\-]+)*))?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i, ne = (e) => {
691
+ }, Bt = (e, t) => e != null && e.length > 0 && t != null, Vt = /^[v^~<>=]*?(\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+))?(?:-([\da-z\-]+(?:\.[\da-z\-]+)*))?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i, re = (e) => {
696
692
  if (typeof e != "string")
697
693
  throw new TypeError("Invalid argument expected string");
698
- const t = e.match(qt);
694
+ const t = e.match(Vt);
699
695
  if (!t)
700
696
  throw new Error(`Invalid argument not valid semver ('${e}' received)`);
701
697
  return t.shift(), t;
702
- }, re = (e) => e === "*" || e === "x" || e === "X", se = (e) => {
698
+ }, se = (e) => e === "*" || e === "x" || e === "X", oe = (e) => {
703
699
  const t = parseInt(e, 10);
704
700
  return isNaN(t) ? e : t;
705
- }, Wt = (e, t) => typeof e != typeof t ? [String(e), String(t)] : [e, t], xt = (e, t) => {
706
- if (re(e) || re(t))
701
+ }, Ct = (e, t) => typeof e != typeof t ? [String(e), String(t)] : [e, t], Yt = (e, t) => {
702
+ if (se(e) || se(t))
707
703
  return 0;
708
- const [n, r] = Wt(se(e), se(t));
704
+ const [n, r] = Ct(oe(e), oe(t));
709
705
  return n > r ? 1 : n < r ? -1 : 0;
710
- }, oe = (e, t) => {
706
+ }, ie = (e, t) => {
711
707
  for (let n = 0; n < Math.max(e.length, t.length); n++) {
712
- const r = xt(e[n] || "0", t[n] || "0");
708
+ const r = Yt(e[n] || "0", t[n] || "0");
713
709
  if (r !== 0)
714
710
  return r;
715
711
  }
716
712
  return 0;
717
- }, Bt = (e, t) => {
718
- const n = ne(e), r = ne(t), s = n.pop(), o = r.pop(), i = oe(n, r);
719
- return i !== 0 ? i : s && o ? oe(s.split("."), o.split(".")) : s || o ? s ? -1 : 1 : 0;
720
- }, Ct = (e, t, n) => {
721
- Vt(n);
722
- const r = Bt(e, t);
723
- return ye[n].includes(r);
724
- }, ye = {
713
+ }, kt = (e, t) => {
714
+ const n = re(e), r = re(t), s = n.pop(), o = r.pop(), i = ie(n, r);
715
+ return i !== 0 ? i : s && o ? ie(s.split("."), o.split(".")) : s || o ? s ? -1 : 1 : 0;
716
+ }, Mt = (e, t, n) => {
717
+ Qt(n);
718
+ const r = kt(e, t);
719
+ return De[n].includes(r);
720
+ }, De = {
725
721
  ">": [1],
726
722
  ">=": [0, 1],
727
723
  "=": [0],
728
724
  "<=": [-1, 0],
729
725
  "<": [-1],
730
726
  "!=": [-1, 1]
731
- }, ie = Object.keys(ye), Vt = (e) => {
732
- if (ie.indexOf(e) === -1)
733
- throw new Error(`Invalid operator, expected one of ${ie.join("|")}`);
734
- }, P = "+", G = (e, t) => {
735
- const { agency: n, id: r, version: s } = p(e), o = t.filter(
727
+ }, ce = Object.keys(De), Qt = (e) => {
728
+ if (ce.indexOf(e) === -1)
729
+ throw new Error(`Invalid operator, expected one of ${ce.join("|")}`);
730
+ }, _ = "+", G = (e, t) => {
731
+ const { agency: n, id: r, version: s } = S(e), o = t.filter(
736
732
  (a) => {
737
733
  var u;
738
- return a.agencyID === n && a.id === r && !((u = a == null ? void 0 : a.version) != null && u.includes(P));
734
+ return a.agencyID === n && a.id === r && !((u = a == null ? void 0 : a.version) != null && u.includes(_));
739
735
  }
740
736
  );
741
737
  if (o.length === 1)
742
738
  return o[0];
743
- if (!(s != null && s.includes(P)))
739
+ if (!(s != null && s.includes(_)))
744
740
  return o.find((a) => a.version === s);
745
741
  const i = o.map(
746
742
  (a) => a.version
747
- ), c = Yt(s, i);
743
+ ), c = Gt(s, i);
748
744
  return o.find(
749
745
  (a) => a.version === c[0]
750
746
  );
751
- }, Yt = (e, t) => {
752
- const n = kt(e, t);
747
+ }, Gt = (e, t) => {
748
+ const n = Kt(e, t);
753
749
  return n.length > 0 ? [n[0]] : [];
754
- }, kt = (e, t) => {
750
+ }, Kt = (e, t) => {
755
751
  const n = [];
756
752
  return t.forEach((r) => {
757
- Mt(e, r) && n.push(r);
753
+ Ft(e, r) && n.push(r);
758
754
  }), n;
759
- }, Kt = (e) => {
755
+ }, jt = (e) => {
760
756
  const t = e.trim().replace(/\d+\+/, "*"), [n] = t.split("*");
761
757
  return new RegExp(`^${n}`);
762
- }, Mt = (e, t) => {
758
+ }, Ft = (e, t) => {
763
759
  const n = e.trim().replace(/\+/, "");
764
- return Kt(e).test(t) && Ct(t, n, ">=");
765
- }, Q = (e, t) => {
766
- const { concept: n } = Gt(e, t);
760
+ return jt(e).test(t) && Mt(t, n, ">=");
761
+ }, K = (e, t) => {
762
+ const { concept: n } = zt(e, t);
767
763
  return n;
768
- }, Gt = (e, t) => {
764
+ }, zt = (e, t) => {
769
765
  if (e == null)
770
766
  return {
771
767
  concept: void 0,
772
768
  scheme: void 0
773
769
  };
774
- const { childId: n, agency: r, id: s, version: o } = Re(e);
775
- if (o != null && o.includes(P)) {
770
+ const { childId: n, agency: r, id: s, version: o } = Pe(e);
771
+ if (o != null && o.includes(_)) {
776
772
  const i = G(
777
773
  e,
778
774
  t
779
775
  );
780
776
  return {
781
- concept: ce((i == null ? void 0 : i.concepts) || [], n),
777
+ concept: ae((i == null ? void 0 : i.concepts) || [], n),
782
778
  scheme: i
783
779
  };
784
780
  }
785
781
  for (const i of t)
786
- if (Qt(i, s, r, o))
782
+ if (Ht(i, s, r, o))
787
783
  return {
788
- concept: ce((i == null ? void 0 : i.concepts) || [], n),
784
+ concept: ae((i == null ? void 0 : i.concepts) || [], n),
789
785
  scheme: i
790
786
  };
791
787
  return {
792
788
  concept: void 0,
793
789
  scheme: void 0
794
790
  };
795
- }, ce = (e, t) => e == null ? void 0 : e.find((n) => n.id === t), Qt = (e, t, n, r) => e.id === t && e.agencyID === n && e.version === r, En = (e = [], t = [], n) => {
791
+ }, ae = (e, t) => e == null ? void 0 : e.find((n) => n.id === t), Ht = (e, t, n, r) => e.id === t && e.agencyID === n && e.version === r, pn = (e = [], t = [], n) => {
796
792
  var a, u;
797
- const r = (n == null ? void 0 : n.conceptIdentity) || "", s = Q(r, t), o = $(
793
+ const r = (n == null ? void 0 : n.conceptIdentity) || "", s = K(r, t), o = P(
798
794
  (a = n == null ? void 0 : n.localRepresentation) == null ? void 0 : a.enumeration
799
- ), i = $(
795
+ ), i = P(
800
796
  (u = s == null ? void 0 : s.coreRepresentation) == null ? void 0 : u.enumeration
801
797
  ), c = o || i;
802
798
  if (c != null)
803
799
  return G(c, e);
804
- }, yn = (e, t, n, r) => {
800
+ }, Sn = (e, t, n, r) => {
805
801
  var o, i;
806
802
  const s = (o = t == null ? void 0 : t.find(
807
803
  (c) => (c == null ? void 0 : c.id) === (e == null ? void 0 : e.id)
808
804
  )) == null ? void 0 : o.values;
809
805
  return ((i = n == null ? void 0 : n.filter((c) => s == null ? void 0 : s.some((a) => a.id === c.id))) == null ? void 0 : i.map((c) => ({
810
806
  ...c,
811
- name: r ? M(c, r) : c == null ? void 0 : c.name
807
+ name: r ? Q(c, r) : c == null ? void 0 : c.name
812
808
  }))) || [];
813
- }, jt = (e, t) => {
809
+ }, Jt = (e, t) => {
814
810
  var s, o, i;
815
811
  const n = (s = t == null ? void 0 : t.dataStructureComponents) == null ? void 0 : s.attributeList, r = (o = e == null ? void 0 : e.metadataStructureComponents) == null ? void 0 : o.metadataAttributeList;
816
812
  return (i = n == null ? void 0 : n.metadataAttributeUsages) == null ? void 0 : i.map((c) => {
@@ -824,47 +820,47 @@ const M = (e, t) => (e == null ? void 0 : e.names) && (e == null ? void 0 : e.na
824
820
  isMandatory: Number(a == null ? void 0 : a.minOccurs) > 0
825
821
  };
826
822
  });
827
- }, Dn = (e = [], t, n) => {
828
- const r = $(t == null ? void 0 : t.conceptIdentity) || "", s = Q(r, e);
829
- return n ? M(s, n) : (s == null ? void 0 : s.name) ?? (s == null ? void 0 : s.id) ?? (t == null ? void 0 : t.id);
823
+ }, vn = (e = [], t, n) => {
824
+ const r = P(t == null ? void 0 : t.conceptIdentity) || "", s = K(r, e);
825
+ return n ? Q(s, n) : (s == null ? void 0 : s.name) ?? (s == null ? void 0 : s.id) ?? (t == null ? void 0 : t.id);
830
826
  };
831
- function ae(e) {
827
+ function ue(e) {
832
828
  var t, n, r;
833
829
  return (r = (n = (t = e == null ? void 0 : e.dataStructures) == null ? void 0 : t[0]) == null ? void 0 : n.dataStructureComponents) == null ? void 0 : r.dimensionList;
834
830
  }
835
- function Tn(e) {
831
+ function $n(e) {
836
832
  var t, n, r, s;
837
833
  return ((s = (r = (n = (t = e == null ? void 0 : e.data) == null ? void 0 : t.structures) == null ? void 0 : n[0]) == null ? void 0 : r.dimensions) == null ? void 0 : s.series) || [];
838
834
  }
839
- function vn(e) {
835
+ function wn(e) {
840
836
  var t, n, r, s, o;
841
837
  return ((o = (s = (r = (n = (t = e == null ? void 0 : e.data) == null ? void 0 : t.structures) == null ? void 0 : n[0]) == null ? void 0 : r.dimensions) == null ? void 0 : s.observation) == null ? void 0 : o[0].values.map((i) => i.value).filter((i) => i != null)) || [];
842
838
  }
843
- function pn(e) {
839
+ function Pn(e) {
844
840
  return e.find(
845
- (t) => t.type === b.TIME_DIMENSION
841
+ (t) => t.type === m.TIME_DIMENSION
846
842
  );
847
843
  }
848
- const wn = (e) => {
844
+ const Nn = (e) => {
849
845
  var i, c, a, u, l, g;
850
846
  const t = /* @__PURE__ */ new Map(), n = (i = e == null ? void 0 : e.dataStructures) == null ? void 0 : i[0], r = (c = e == null ? void 0 : e.metadataStructures) == null ? void 0 : c[0], s = (e == null ? void 0 : e.conceptSchemes) || [], o = (e == null ? void 0 : e.codelists) || [];
851
847
  return e && [
852
- ...((a = ae(e)) == null ? void 0 : a.dimensions) || [],
853
- ...((u = ae(e)) == null ? void 0 : u.timeDimensions) || [],
854
- ...jt(r, n),
848
+ ...((a = ue(e)) == null ? void 0 : a.dimensions) || [],
849
+ ...((u = ue(e)) == null ? void 0 : u.timeDimensions) || [],
850
+ ...Jt(r, n),
855
851
  ...((g = (l = n == null ? void 0 : n.dataStructureComponents) == null ? void 0 : l.attributeList) == null ? void 0 : g.attributes) || []
856
852
  ].forEach(
857
853
  (d) => {
858
854
  var y, D;
859
- const f = Q(
855
+ const f = K(
860
856
  d == null ? void 0 : d.conceptIdentity,
861
857
  s
862
- ), E = ((y = d == null ? void 0 : d.localRepresentation) == null ? void 0 : y.enumeration) || ((D = f == null ? void 0 : f.coreRepresentation) == null ? void 0 : D.enumeration), A = G(
863
- E,
858
+ ), A = ((y = d == null ? void 0 : d.localRepresentation) == null ? void 0 : y.enumeration) || ((D = f == null ? void 0 : f.coreRepresentation) == null ? void 0 : D.enumeration), h = G(
859
+ A,
864
860
  o
865
861
  );
866
- d != null && d.id && (E ? t.set(d == null ? void 0 : d.id, {
867
- ...A,
862
+ d != null && d.id && (A ? t.set(d == null ? void 0 : d.id, {
863
+ ...h,
868
864
  name: f == null ? void 0 : f.name,
869
865
  names: f == null ? void 0 : f.names
870
866
  }) : t.set(d == null ? void 0 : d.id, {
@@ -874,12 +870,12 @@ const wn = (e) => {
874
870
  }));
875
871
  }
876
872
  ), t;
877
- }, Sn = (e) => {
873
+ }, In = (e) => {
878
874
  var t;
879
875
  return ((t = e == null ? void 0 : e.find(
880
- (n) => n.id === K.SERIES_COUNT
876
+ (n) => n.id === M.SERIES_COUNT
881
877
  )) == null ? void 0 : t.title) || "";
882
- }, Ft = "/api/download", $n = (e, t, n, r, s, o, i) => {
878
+ }, Xt = "/api/download", _n = (e, t, n, r, s, o, i) => {
883
879
  const c = new URLSearchParams({
884
880
  urn: e,
885
881
  format: t,
@@ -889,143 +885,152 @@ const wn = (e) => {
889
885
  attribute: r,
890
886
  language: n,
891
887
  isMetadata: i ? "true" : "none"
892
- }).toString();
893
- window.open(`${Ft}?${c}`, "_blank");
894
- }, ue = (e) => isNaN(Date.parse(e)) ? null : new Date(e), Rn = (e, t) => {
888
+ }).toString(), a = `${Xt}?${c}`;
889
+ window.open(a, "_blank");
890
+ }, $ = (e) => isNaN(Date.parse(e)) ? null : new Date(e), On = (e, t) => {
895
891
  var r, s;
896
892
  const n = [];
897
893
  for (const o of e) {
898
- if (o.type !== b.DIMENSION)
894
+ if (o.type !== m.DIMENSION)
899
895
  continue;
900
896
  const i = t.find((c) => c.componentCode === o.id);
901
- i != null && ((r = i.values) == null ? void 0 : r.length) > 0 ? n.push((s = i.values) == null ? void 0 : s.join(de)) : n.push("*");
897
+ i != null && ((r = i.values) == null ? void 0 : r.length) > 0 ? n.push((s = i.values) == null ? void 0 : s.join(Ue)) : n.push("*");
902
898
  }
903
899
  return n.join(".");
904
- }, zt = (e, t) => {
900
+ }, Zt = (e, t) => {
905
901
  if (!e || !e.startPeriod && !e.endPeriod)
906
902
  return null;
907
903
  const n = [], { startPeriod: r, endPeriod: s } = e;
908
904
  if (r && n.push(
909
- `${m.GREATER_OR_EQUAL}:${r.toISOString().split("T")[0]}`
905
+ `${R.GREATER_OR_EQUAL}${F}${r.toISOString().split("T")[0]}`
910
906
  ), s && n.push(
911
- `${m.LESS_OR_EQUAL}:${s.toISOString().split("T")[0]}`
907
+ `${R.LESS_OR_EQUAL}${F}${s.toISOString().split("T")[0]}`
912
908
  ), n.length === 0)
913
909
  return null;
914
- const o = n.join(de);
915
- return `c${encodeURIComponent(`[${t}]`)}=${o}`;
916
- }, Nn = (e, t) => {
917
- const n = Ht(e, t) || null;
918
- return n ? zt(n, t == null ? void 0 : t.id) : null;
919
- }, Ht = (e, t) => {
920
- var c, a;
921
- const n = t.id, r = (c = e == null ? void 0 : e.filters) == null ? void 0 : c.find(
922
- (u) => u.componentCode === n
910
+ const o = t;
911
+ return n.map(
912
+ (i) => `${encodeURIComponent(`c[${o}]`)}${be}${encodeURIComponent(i)}`
913
+ ).join(fe);
914
+ }, mn = (e, t) => {
915
+ const n = en(e, t) || null;
916
+ return n ? Zt(n, t == null ? void 0 : t.id) : null;
917
+ }, en = (e, t) => {
918
+ var a, u;
919
+ const n = t.id, r = (a = e == null ? void 0 : e.filters) == null ? void 0 : a.find(
920
+ (l) => l.componentCode === n
923
921
  );
924
922
  if (!r || !r.values)
925
923
  return null;
926
- const s = (a = r.values) == null ? void 0 : a.filter((u) => !!u);
924
+ const s = (u = r.values) == null ? void 0 : u.filter((l) => !!l);
927
925
  if (!s.length)
928
926
  return null;
929
- const o = ue(s[0]), i = ue(s[1]);
930
- return { startPeriod: o, endPeriod: i };
927
+ const o = r.operator;
928
+ if (o === R.LESS_OR_EQUAL || o === R.LESS)
929
+ return { startPeriod: null, endPeriod: $(s[0]) };
930
+ if (o === R.GREATER_OR_EQUAL || o === R.GREATER)
931
+ return { startPeriod: $(s[0]), endPeriod: null };
932
+ const i = $(s[0]), c = $(s[1]);
933
+ return { startPeriod: i, endPeriod: c };
931
934
  };
932
935
  export {
933
- K as Annotations,
934
- Be as AssignmentStatus,
935
- Xt as AvailabilityApi,
936
- be as DATASET_DATA_URL,
937
- Zt as DatasetApi,
938
- b as DimensionType,
939
- Pe as DownloadType,
940
- me as FileColumnsAttribute,
941
- tn as GET_v3_FILTER_AND,
942
- de as GET_v3_FILTER_OR,
943
- ke as OBSERVATION_KEY,
944
- Ce as OccurrenceType,
945
- Nt as RepresentationTextType,
946
- Rt as SDMX_DATA_QUERY_PARAMS,
947
- P as SINGLE_WILDCARD_SYMBOL,
948
- en as SdmxApiClient,
936
+ M as Annotations,
937
+ ke as AssignmentStatus,
938
+ nn as AvailabilityApi,
939
+ Le as DATASET_DATA_URL,
940
+ sn as DatasetApi,
941
+ m as DimensionType,
942
+ _e as DownloadType,
943
+ Ie as FileColumnsAttribute,
944
+ qe as GET_v3_FILTER_ALL,
945
+ rn as GET_v3_FILTER_AND,
946
+ Ue as GET_v3_FILTER_OR,
947
+ Ke as OBSERVATION_KEY,
948
+ Me as OccurrenceType,
949
+ Ot as RepresentationTextType,
950
+ _t as SDMX_DATA_QUERY_PARAMS,
951
+ _ as SINGLE_WILDCARD_SYMBOL,
952
+ on as SdmxApiClient,
949
953
  le as SdmxAvailabilityMode,
950
- S as SdmxDataFormat,
951
- O as SdmxDetails,
952
- I as SdmxReferences,
953
- m as SeriesFilterOperator,
954
- Pt as TIME_PERIOD_END,
955
- It as TIME_PERIOD_START,
956
- et as dailyPattern,
957
- Qe as decodeDimensionId,
958
- En as findCodelistByDimension,
959
- F as generateDatasetDataRequest,
960
- Jt as generateShortUrn,
961
- hn as getAnnotationPeriod,
954
+ w as SdmxDataFormat,
955
+ de as SdmxDetails,
956
+ O as SdmxReferences,
957
+ R as SeriesFilterOperator,
958
+ Dn as TIME_PERIOD,
959
+ Lt as TIME_PERIOD_END,
960
+ bt as TIME_PERIOD_START,
961
+ st as dailyPattern,
962
+ He as decodeDimensionId,
963
+ pn as findCodelistByDimension,
964
+ z as generateDatasetDataRequest,
965
+ tn as generateShortUrn,
966
+ Tn as getAnnotationPeriod,
962
967
  G as getArtifactByUrnWithWildCard,
963
- nn as getAttachedDimensionsSeriesByDimension,
964
- Ve as getAttachedDimensionsSeriesByTsId,
965
- fe as getAttachedDimensionsSeriesKey,
966
- Ye as getAttributeValueFromDataQueryResponse,
967
- yn as getAvailableCodes,
968
- An as getAvailableCodesFromConstrains,
969
- Re as getChildParsedUrn,
970
- Q as getConcept,
971
- ce as getConceptByUrn,
972
- Gt as getConceptWithScheme,
973
- jt as getConvertedMetaAttributes,
974
- rt as getDailyRegExp,
975
- Dn as getDimensionTitle,
976
- ae as getDimensions,
968
+ cn as getAttachedDimensionsSeriesByDimension,
969
+ Qe as getAttachedDimensionsSeriesByTsId,
970
+ ge as getAttachedDimensionsSeriesKey,
971
+ Ge as getAttributeValueFromDataQueryResponse,
972
+ Sn as getAvailableCodes,
973
+ Rn as getAvailableCodesFromConstrains,
974
+ Pe as getChildParsedUrn,
975
+ K as getConcept,
976
+ ae as getConceptByUrn,
977
+ zt as getConceptWithScheme,
978
+ Jt as getConvertedMetaAttributes,
979
+ ct as getDailyRegExp,
980
+ vn as getDimensionTitle,
981
+ ue as getDimensions,
977
982
  mt as getFilteredItemsWithParents,
978
- X as getISOWeek,
979
- $ as getKeyFromUrn,
980
- gn as getLastUpdatedTime,
981
- sn as getLastWeekNumberOfYear,
982
- M as getLocalizedName,
983
- un as getMonthlyData,
984
- ln as getMonthlyDataByQuarter,
983
+ Z as getISOWeek,
984
+ P as getKeyFromUrn,
985
+ yn as getLastUpdatedTime,
986
+ un as getLastWeekNumberOfYear,
987
+ Q as getLocalizedName,
988
+ gn as getMonthlyData,
989
+ En as getMonthlyDataByQuarter,
985
990
  q as getMonthlyRegExp,
986
991
  he as getParsedEndPeriodDate,
987
- rn as getParsedResponse,
988
- ge as getParsedStartPeriodDate,
989
- Z as getPeriodDate,
990
- an as getQuarterByMonth,
992
+ an as getParsedResponse,
993
+ Ee as getParsedStartPeriodDate,
994
+ ee as getPeriodDate,
995
+ fn as getQuarterByMonth,
991
996
  x as getQuarterlyRegExp,
992
- on as getQuartersData,
993
- zt as getQueryTimePeriodFilters,
994
- Ie as getRequestAcceptHeader,
995
- Yt as getResolvedVersionBySingleWildcard,
996
- cn as getSemiAnnualData,
997
- nt as getSemiAnnuallyRegExp,
998
- N as getSeriesAttributes,
999
- Ke as getSeriesName,
1000
- wn as getStructureComponentsMap,
1001
- Tn as getStructureDimensions,
1002
- pn as getTimeDimension,
1003
- vn as getTimePeriods,
1004
- Nn as getTimeQueryFilter,
1005
- Ht as getTimeRangeFromAttachment,
1006
- Sn as getTimeSeriesCount,
1007
- Rn as getTimeSeriesFilterKey,
1008
- Ge as getTimeSeriesId,
1009
- ct as getWeekCode,
1010
- ut as getWeeklyPeriodEndDate,
1011
- at as getWeeklyPeriodStartDate,
1012
- ot as getWeeklyRegExp,
1013
- Kt as getWildCardRegexp,
1014
- _ as getYearlyRegExp,
1015
- dn as getYears,
1016
- st as isDaily,
997
+ ln as getQuartersData,
998
+ Zt as getQueryTimePeriodFilters,
999
+ Oe as getRequestAcceptHeader,
1000
+ Gt as getResolvedVersionBySingleWildcard,
1001
+ dn as getSemiAnnualData,
1002
+ it as getSemiAnnuallyRegExp,
1003
+ I as getSeriesAttributes,
1004
+ je as getSeriesName,
1005
+ Nn as getStructureComponentsMap,
1006
+ $n as getStructureDimensions,
1007
+ Pn as getTimeDimension,
1008
+ wn as getTimePeriods,
1009
+ mn as getTimeQueryFilter,
1010
+ en as getTimeRangeFromAttachment,
1011
+ In as getTimeSeriesCount,
1012
+ On as getTimeSeriesFilterKey,
1013
+ ze as getTimeSeriesId,
1014
+ dt as getWeekCode,
1015
+ gt as getWeeklyPeriodEndDate,
1016
+ ft as getWeeklyPeriodStartDate,
1017
+ ut as getWeeklyRegExp,
1018
+ jt as getWildCardRegexp,
1019
+ L as getYearlyRegExp,
1020
+ hn as getYears,
1021
+ at as isDaily,
1017
1022
  W as isMonthly,
1018
1023
  B as isQuarterly,
1019
1024
  U as isSemiAnnually,
1020
- C as isWeekly,
1021
- Mt as isWildCardVersionCorrect,
1022
- L as isYearly,
1023
- tt as monthlyPattern,
1024
- $n as openDownloadWindow,
1025
- He as quarterPattern,
1026
- Xe as semiAnnuallyPattern,
1027
- fn as sortPeriods,
1028
- p as splitUrn,
1029
- Je as weeklyPattern,
1030
- Ze as yearlyPattern
1025
+ V as isWeekly,
1026
+ Ft as isWildCardVersionCorrect,
1027
+ b as isYearly,
1028
+ ot as monthlyPattern,
1029
+ _n as openDownloadWindow,
1030
+ et as quarterPattern,
1031
+ nt as semiAnnuallyPattern,
1032
+ An as sortPeriods,
1033
+ S as splitUrn,
1034
+ tt as weeklyPattern,
1035
+ rt as yearlyPattern
1031
1036
  };