@epam/statgpt-sdmx-toolkit 0.2.0-rc.40 → 0.2.0-rc.42

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.
Files changed (3) hide show
  1. package/index.cjs +2 -2
  2. package/index.mjs +544 -584
  3. package/package.json +3 -3
package/index.mjs CHANGED
@@ -1,85 +1,84 @@
1
- const I = (e) => {
1
+ const v = (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) => {
7
- var s;
6
+ }, D = (e) => {
8
7
  if (e == null)
9
8
  return {};
10
- const t = I(e), n = {
9
+ const t = v(e), n = {
11
10
  agency: "",
12
11
  id: "",
13
12
  version: ""
14
13
  };
15
- return t && (t.includes(":") && (n.agency = t.split(":")[0], n.id = t.split(":")[1].split("(")[0]), t.includes("(") && t.includes(")") && (n.version = (s = t.split("(")[1]) == null ? void 0 : s.split(")")[0])), n;
16
- }, Pe = (e) => {
17
- const [t, n] = e.split(")."), { agency: s, id: r, version: o } = p(t + ")");
14
+ return t && (t.includes(":") && (n.agency = t.split(":")[0], n.id = t.split(":")[1].split("(")[0]), t.includes("(") && t.includes(")") && (n.version = t.split("(")[1]?.split(")")[0])), n;
15
+ }, we = (e) => {
16
+ const [t, n] = e.split(")."), { agency: s, id: r, version: o } = D(t + ")");
18
17
  return { childId: n, agency: s, id: r, version: o };
19
- }, Tn = (e, t, n) => {
18
+ }, gn = (e, t, n) => {
20
19
  const s = t === "" ? "" : `(${t})`;
21
20
  return `${n}:${e}${s}`;
22
21
  };
23
- var k = /* @__PURE__ */ ((e) => (e.DESCENDANTS = "descendants", e.NONE = "none", e.ALL = "all", e))(k || {}), ye = /* @__PURE__ */ ((e) => (e.EXACT = "exact", e.AVAILABLE = "available", e))(ye || {});
24
- const be = (e = "", t = "", n = "") => `sdmx/3.0/availability/dataflow/${e}/${t}/${n}`;
25
- class Rn {
22
+ var L = /* @__PURE__ */ ((e) => (e.DESCENDANTS = "descendants", e.NONE = "none", e.ALL = "all", e))(L || {}), me = /* @__PURE__ */ ((e) => (e.EXACT = "exact", e.AVAILABLE = "available", e))(me || {});
23
+ const Ie = (e = "", t = "", n = "") => `sdmx/3.0/availability/dataflow/${e}/${t}/${n}`;
24
+ class hn {
26
25
  constructor(t) {
27
26
  this.client = t;
28
27
  }
29
28
  async getConstraints(t, n) {
30
- const { agency: s, id: r, version: o } = p(t), i = {
29
+ const { agency: s, id: r, version: o } = D(t), i = {
31
30
  filters: n || [],
32
- mode: ye.AVAILABLE,
33
- references: k.NONE
34
- }, c = be(s, r, o);
31
+ mode: me.AVAILABLE,
32
+ references: L.NONE
33
+ }, c = Ie(s, r, o);
35
34
  return await this.client.postRequest(c, { body: i });
36
35
  }
37
36
  }
38
- var N = /* @__PURE__ */ ((e) => (e.CSV = "csv", e.JSON = "json", e.XML = "xml", e))(N || {}), Le = /* @__PURE__ */ ((e) => (e.ID = "id", e.NAME = "name", e.ID_NAME = "both", e))(Le || {}), Ue = /* @__PURE__ */ ((e) => (e.FULL_DATASET = "full", e.DATA_IN_TABLE = "query", e))(Ue || {});
39
- const xe = (e, t) => {
37
+ var S = /* @__PURE__ */ ((e) => (e.CSV = "csv", e.JSON = "json", e.XML = "xml", e))(S || {}), Ne = /* @__PURE__ */ ((e) => (e.ID = "id", e.NAME = "name", e.ID_NAME = "both", e))(Ne || {}), $e = /* @__PURE__ */ ((e) => (e.FULL_DATASET = "full", e.DATA_IN_TABLE = "query", e))($e || {});
38
+ const Pe = (e, t) => {
40
39
  switch (e) {
41
- case N.CSV:
42
- return m(
40
+ case S.CSV:
41
+ return A(
43
42
  "application/vnd.sdmx.data+csv;version=2.0.0",
44
43
  t
45
44
  );
46
- case N.XML:
47
- return m(
45
+ case S.XML:
46
+ return A(
48
47
  "application/vnd.sdmx.data+xml;version=3.0.0",
49
48
  t
50
49
  );
51
- case N.JSON:
52
- return m(`application/${e}`, t);
50
+ case S.JSON:
51
+ return A(`application/${e}`, t);
53
52
  default:
54
- return m(
53
+ return A(
55
54
  "application/vnd.sdmx.data+csv;version=2.0.0",
56
55
  t
57
56
  );
58
57
  }
59
- }, m = (e, t) => `${e}; labels=${t}`;
60
- var Se = /* @__PURE__ */ ((e) => (e.REFERENCE_PARTIAL = "referencepartial", e.FULL = "full", e))(Se || {});
61
- const Ye = "all", Ce = "sdmx/3.0/data/dataflow", Te = "&", se = ":", We = "=", ke = "+", wn = ",", qe = "*", re = (e, t, n) => {
62
- const { filterKey: s, timeFilter: r } = n, { agency: o, id: i, version: c } = p(e), a = [r || "", t].filter((l) => !!l).join(Te);
63
- return `${`${Ce}/${o}/${i}/${c}`}/${s || qe}?${a}`;
64
- }, Me = (e = "", t = "", n = "", s = k.DESCENDANTS) => `sdmx/3.0/structure/dataflow/${e}/${t}/${n}?references=${s}&detail=${Se.REFERENCE_PARTIAL}`;
58
+ }, A = (e, t) => `${e}; labels=${t}`;
59
+ var fe = /* @__PURE__ */ ((e) => (e.REFERENCE_PARTIAL = "referencepartial", e.FULL = "full", e))(fe || {});
60
+ const be = "all", _e = "sdmx/3.0/data/dataflow", ge = "&", J = ":", Oe = "=", Le = "+", En = ",", Me = "*", X = (e, t, n) => {
61
+ const { filterKey: s, timeFilter: r } = n, { agency: o, id: i, version: c } = D(e), a = [r || "", t].filter((d) => !!d).join(ge);
62
+ return `${`${_e}/${o}/${i}/${c}`}/${s || Me}?${a}`;
63
+ }, Ce = (e = "", t = "", n = "", s = L.DESCENDANTS) => `sdmx/3.0/structure/dataflow/${e}/${t}/${n}?references=${s}&detail=${fe.REFERENCE_PARTIAL}`;
65
64
  class pn {
66
65
  constructor(t) {
67
66
  this.client = t;
68
67
  }
69
68
  async getDataSet(t, n) {
70
- const { agency: s, id: r, version: o } = p(t);
69
+ const { agency: s, id: r, version: o } = D(t);
71
70
  return await this.client.getRequest(
72
- Me(s, r, o, n)
71
+ Ce(s, r, o, n)
73
72
  );
74
73
  }
75
74
  async getDatasetData(t, n) {
76
75
  const s = new URLSearchParams({
77
76
  includeHistory: "false",
78
77
  limit: "1000",
79
- attributes: Ye,
78
+ attributes: be,
80
79
  dimensionAtObservation: "TIME_PERIOD"
81
80
  // TODO: use time dimensions
82
- }).toString(), r = re(t, s, n);
81
+ }).toString(), r = X(t, s, n);
83
82
  return await this.client.getRequest(r);
84
83
  }
85
84
  async downloadDataSet(t, n, s, r, o, i, c = !1) {
@@ -88,13 +87,13 @@ class pn {
88
87
  compress: "false",
89
88
  attributes: c ? "all" : "none",
90
89
  limit: "1000"
91
- }).toString(), u = re(t, a, o);
90
+ }).toString(), u = X(t, a, o);
92
91
  return this.client.streamRequest(
93
92
  u,
94
93
  {
95
94
  method: "GET",
96
95
  headers: {
97
- Accept: xe(n, r),
96
+ Accept: Pe(n, r),
98
97
  "Accept-language": s
99
98
  }
100
99
  },
@@ -102,31 +101,31 @@ class pn {
102
101
  );
103
102
  }
104
103
  }
105
- const Qe = (e, t) => e.error || e.message || `${t.status} ${t.statusText}`, Be = "application/json", Ve = "Content-Type", x = "Api-Key", Fe = "X-CONVERSATION-ID", $ = "Ocp-Apim-Subscription-Key";
106
- class oe extends Error {
104
+ const Ue = (e, t) => e.error || e.message || `${t.status} ${t.statusText}`, xe = "application/json", Ye = "Content-Type", P = "Api-Key", We = "X-CONVERSATION-ID", T = "Ocp-Apim-Subscription-Key";
105
+ class Z extends Error {
107
106
  constructor(t) {
108
107
  super(t.message), this.isHttpError = !0, this.name = "HttpError", this.code = t.code, this.status = t.status, this.details = t.details;
109
108
  }
110
109
  }
111
- const v = (e) => isNaN(Date.parse(e)) ? null : new Date(e), Y = (e, t, n) => {
110
+ const y = (e) => isNaN(Date.parse(e)) ? null : new Date(e), b = (e, t, n) => {
112
111
  const s = {
113
- [Ve]: (t == null ? void 0 : t.contentType) || Be
112
+ [Ye]: t?.contentType || xe
114
113
  };
115
- return t != null && t.jwt && (s.Authorization = `Bearer ${t.jwt}`), t != null && t.chatReference && (s[Fe] = t.chatReference), { ...s, ...n };
116
- }, Ge = (e) => {
114
+ return t?.jwt && (s.Authorization = `Bearer ${t.jwt}`), t?.chatReference && (s[We] = t.chatReference), { ...s, ...n };
115
+ }, ke = (e) => {
117
116
  const t = { ...e };
118
- return t[x] && (t[x] = t[x].substring(0, 8) + "...[REDACTED]"), t.Authorization && (t.Authorization = "Bearer [REDACTED]"), t[$] && (t[$] = t[$].substring(0, 8) + "...[REDACTED]"), t;
119
- }, ie = async (e, t, n) => await fetch(e, {
117
+ return t[P] && (t[P] = t[P].substring(0, 8) + "...[REDACTED]"), t.Authorization && (t.Authorization = "Bearer [REDACTED]"), t[T] && (t[T] = t[T].substring(0, 8) + "...[REDACTED]"), t;
118
+ }, ee = async (e, t, n) => await fetch(e, {
120
119
  method: n.method || "GET",
121
120
  headers: t,
122
121
  body: n.body ? JSON.stringify(n.body) : void 0
123
- }), Ke = async (e, t, n) => await fetch(e, {
122
+ }), qe = async (e, t, n) => await fetch(e, {
124
123
  method: n.method,
125
124
  headers: t,
126
- body: n != null && n.isFormData && typeof (n == null ? void 0 : n.body) == "string" ? n.body : JSON.stringify(n.body),
127
- signal: n == null ? void 0 : n.signal
125
+ body: n?.isFormData && typeof n?.body == "string" ? n.body : JSON.stringify(n.body),
126
+ signal: n?.signal
128
127
  });
129
- class je {
128
+ class Qe {
130
129
  constructor() {
131
130
  this.decoder = new TextDecoder();
132
131
  }
@@ -139,15 +138,15 @@ class je {
139
138
  a,
140
139
  r
141
140
  );
142
- await this.processStreamData(u, o), c == null || c();
141
+ await this.processStreamData(u, o), c?.();
143
142
  } catch (u) {
144
143
  this.handleStreamError(u, i);
145
144
  }
146
145
  }
147
146
  async initializeStreamRequest(t, n, s, r) {
148
- const o = Y(void 0, {
147
+ const o = b(void 0, {
149
148
  jwt: r
150
- }), i = await Ke(
149
+ }), i = await qe(
151
150
  t,
152
151
  {
153
152
  Accept: "text/event-stream",
@@ -167,13 +166,13 @@ class je {
167
166
  } catch {
168
167
  a.error = "Failed to parse error body";
169
168
  }
170
- throw new oe({
169
+ throw new Z({
171
170
  status: i.status,
172
171
  message: a.error ?? "No response body"
173
172
  });
174
173
  }
175
174
  if (!i.body)
176
- throw new oe({
175
+ throw new Z({
177
176
  message: "No response body",
178
177
  status: i.status
179
178
  });
@@ -202,7 +201,7 @@ class je {
202
201
  }
203
202
  handleStreamError(t, n) {
204
203
  const s = t instanceof Error ? t : new Error(String(t));
205
- throw n == null || n(s), s;
204
+ throw n?.(s), s;
206
205
  }
207
206
  parseSSEDataLine(t, n) {
208
207
  const s = t.trim();
@@ -218,12 +217,12 @@ class je {
218
217
  } catch (i) {
219
218
  console.error(`Failed to parse SSE data: ${r} ${i}`);
220
219
  }
221
- n == null || n(o);
220
+ n?.(o);
222
221
  }
223
222
  }
224
223
  }
225
- new je();
226
- class mn {
224
+ new Qe();
225
+ class Dn {
227
226
  constructor(t) {
228
227
  this.config = t, console.info("SdmxApiClient initialized", {
229
228
  apiUrl: t.apiUrl || "NOT SET"
@@ -237,34 +236,33 @@ class mn {
237
236
  }
238
237
  async streamRequest(t, n, s) {
239
238
  const r = `${this.config.apiUrl}/${t}`, o = {
240
- ...Y(void 0, {
239
+ ...b(void 0, {
241
240
  jwt: this.config.jwt
242
241
  }),
243
242
  ...n.headers
244
243
  };
245
- this.config.apiKey != null && (o[$] = this.config.apiKey);
244
+ this.config.apiKey != null && (o[T] = this.config.apiKey);
246
245
  const i = new ReadableStream({
247
246
  async start(a) {
248
- var u;
249
247
  try {
250
- const l = await ie(r, o, n);
251
- if (!l.ok) {
252
- const g = await l.text();
248
+ const u = await ee(r, o, n);
249
+ if (!u.ok) {
250
+ const f = await u.text();
253
251
  throw console.error(
254
- `Fetch failed! Status: ${l.status}, Body: ${g}`
255
- ), new Error(`Fetch failed with status ${l.status}`);
252
+ `Fetch failed! Status: ${u.status}, Body: ${f}`
253
+ ), new Error(`Fetch failed with status ${u.status}`);
256
254
  }
257
- const f = (u = l.body) == null ? void 0 : u.getReader();
258
- if (!f) throw new Error("Failed to create stream reader");
259
- const h = new Uint8Array([239, 187, 191]);
260
- a.enqueue(h);
261
- const d = async () => {
262
- const { done: g, value: E } = await f.read();
263
- g ? a.close() : (a.enqueue(E), await d());
255
+ const d = u.body?.getReader();
256
+ if (!d) throw new Error("Failed to create stream reader");
257
+ const l = new Uint8Array([239, 187, 191]);
258
+ a.enqueue(l);
259
+ const m = async () => {
260
+ const { done: f, value: E } = await d.read();
261
+ f ? a.close() : (a.enqueue(E), await m());
264
262
  };
265
- d();
266
- } catch (l) {
267
- a.error(l);
263
+ m();
264
+ } catch (u) {
265
+ a.error(u);
268
266
  }
269
267
  }
270
268
  }), c = new Headers({
@@ -274,14 +272,14 @@ class mn {
274
272
  }
275
273
  async request(t, n) {
276
274
  const s = Date.now(), r = t.includes("availability") && this.config.constrainsApiUrl ? `${this.config.constrainsApiUrl}/${t}` : `${this.config.apiUrl}/${t}`, o = {
277
- ...Y(void 0, {
275
+ ...b(void 0, {
278
276
  jwt: this.config.jwt
279
277
  }),
280
278
  ...n.headers
281
279
  };
282
280
  this.config.apiKey != null && (o["Ocp-Apim-Subscription-Key"] = this.config.apiKey), this.addInfoRequestLog("API Request", r, n, o);
283
281
  try {
284
- const i = await ie(r, o, n), c = Date.now() - s;
282
+ const i = await ee(r, o, n), c = Date.now() - s;
285
283
  let a;
286
284
  const u = await i.text();
287
285
  try {
@@ -301,8 +299,8 @@ class mn {
301
299
  }
302
300
  if (!i.ok) {
303
301
  this.addErrorRequestLog(r, n, i, c, a);
304
- const l = Qe(a, i);
305
- throw new Error(`API request failed: ${l}`);
302
+ const d = Ue(a, i);
303
+ throw new Error(`API request failed: ${d}`);
306
304
  }
307
305
  return a;
308
306
  } catch (i) {
@@ -319,7 +317,7 @@ class mn {
319
317
  const o = {
320
318
  method: s.method || "GET",
321
319
  url: n,
322
- headers: Ge(r)
320
+ headers: ke(r)
323
321
  };
324
322
  s.body && (o.body = s.body), console.info(t, o);
325
323
  }
@@ -345,129 +343,121 @@ class mn {
345
343
  });
346
344
  }
347
345
  }
348
- const vn = ["FREQ", "FREQUENCY"];
349
- var He = /* @__PURE__ */ ((e) => (e.CONDITIONAL = "Conditional", e.MANDATORY = "Mandatory", e))(He || {}), q = /* @__PURE__ */ ((e) => (e.DIMENSION = "Dimension", e.MEASURE_DIMENSION = "MeasureDimension", e.TIME_DIMENSION = "TimeDimension", e))(q || {}), ze = /* @__PURE__ */ ((e) => (e.UNBOUNDED = "unbounded", e))(ze || {});
350
- const Je = (e, t) => {
351
- var c, a, u, l, f;
352
- const n = (a = (c = e == null ? void 0 : e.data) == null ? void 0 : c.dataSets) == null ? void 0 : a[0], s = (l = (u = e == null ? void 0 : e.data) == null ? void 0 : u.structures) == null ? void 0 : l[0], r = ((f = s == null ? void 0 : s.attributes) == null ? void 0 : f.dimensionGroup) || [], o = n == null ? void 0 : n.dimensionGroupAttributes, i = {};
353
- for (const h of r) {
354
- const d = h.relationship.dimensions, { codedSeriesKey: g, decodedSeriesKey: E } = Re(
346
+ const An = ["FREQ", "FREQUENCY"];
347
+ var Ve = /* @__PURE__ */ ((e) => (e.CONDITIONAL = "Conditional", e.MANDATORY = "Mandatory", e))(Ve || {}), M = /* @__PURE__ */ ((e) => (e.DIMENSION = "Dimension", e.MEASURE_DIMENSION = "MeasureDimension", e.TIME_DIMENSION = "TimeDimension", e))(M || {}), Be = /* @__PURE__ */ ((e) => (e.UNBOUNDED = "unbounded", e))(Be || {});
348
+ const Fe = (e, t) => {
349
+ const n = e?.data?.dataSets?.[0], r = e?.data?.structures?.[0]?.attributes?.dimensionGroup || [], o = n?.dimensionGroupAttributes, i = {};
350
+ for (const c of r) {
351
+ const a = c.relationship.dimensions, { codedSeriesKey: u, decodedSeriesKey: d } = he(
355
352
  e,
356
353
  t,
357
- d
354
+ a
358
355
  );
359
- i[h.id] = {
360
- values: (o == null ? void 0 : o[g]) || [],
361
- decodedSeriesKey: E,
362
- codedSeriesKey: g
356
+ i[c.id] = {
357
+ values: o?.[u] || [],
358
+ decodedSeriesKey: d,
359
+ codedSeriesKey: u
363
360
  };
364
361
  }
365
362
  return i;
366
- }, Re = (e, t, n) => {
367
- var c, a;
368
- const s = (a = (c = e == null ? void 0 : e.data) == null ? void 0 : c.structures) == null ? void 0 : a[0], r = [
369
- ...(s == null ? void 0 : s.dimensions.series) || [],
370
- ...(s == null ? void 0 : s.dimensions.observation) || []
371
- ], o = new Array(r == null ? void 0 : r.length), i = new Array(r == null ? void 0 : r.length);
372
- return n == null || n.forEach((u) => {
373
- const l = (r == null ? void 0 : r.findIndex((d) => d.id === u)) || 0, f = t[l], h = r[l].values.findIndex(
374
- (d) => d.id === f || d.value === f
363
+ }, he = (e, t, n) => {
364
+ const s = e?.data?.structures?.[0], r = [
365
+ ...s?.dimensions.series || [],
366
+ ...s?.dimensions.observation || []
367
+ ], o = new Array(r?.length), i = new Array(r?.length);
368
+ return n?.forEach((c) => {
369
+ const a = r?.findIndex((l) => l.id === c) || 0, u = t[a], d = r[a].values.findIndex(
370
+ (l) => l.id === u || l.value === u
375
371
  ) || 0;
376
- o[l] = h >= 0 ? h : f, i[l] = f;
372
+ o[a] = d >= 0 ? d : u, i[a] = u;
377
373
  }), {
378
374
  codedSeriesKey: o.join(":"),
379
375
  decodedSeriesKey: i.join(":")
380
376
  };
381
- }, Nn = (e, t, n) => {
382
- var f, h, d, g, E;
383
- const s = (h = (f = e == null ? void 0 : e.data) == null ? void 0 : f.dataSets) == null ? void 0 : h[0], r = (g = (d = e == null ? void 0 : e.data) == null ? void 0 : d.structures) == null ? void 0 : g[0], o = (((E = r == null ? void 0 : r.attributes) == null ? void 0 : E.dimensionGroup) || []).filter(
384
- (D) => {
385
- var A;
386
- return ((A = D.relationship.dimensions) == null ? void 0 : A.length) === 1 && D.relationship.dimensions.includes(t || "");
387
- }
388
- ), i = s == null ? void 0 : s.dimensionGroupAttributes, c = [
389
- ...(r == null ? void 0 : r.dimensions.series) || [],
390
- ...(r == null ? void 0 : r.dimensions.observation) || []
391
- ], a = c == null ? void 0 : c.findIndex((D) => D.id === t), u = new Array(c == null ? void 0 : c.length);
377
+ }, yn = (e, t, n) => {
378
+ const s = e?.data?.dataSets?.[0], r = e?.data?.structures?.[0], o = (r?.attributes?.dimensionGroup || []).filter(
379
+ (l) => l.relationship.dimensions?.length === 1 && l.relationship.dimensions.includes(t || "")
380
+ ), i = s?.dimensionGroupAttributes, c = [
381
+ ...r?.dimensions.series || [],
382
+ ...r?.dimensions.observation || []
383
+ ], a = c?.findIndex((l) => l.id === t), u = new Array(c?.length);
392
384
  u[a] = n || "";
393
- const l = {};
394
- for (const D of o) {
395
- const A = D.relationship.dimensions, { codedSeriesKey: y, decodedSeriesKey: S } = Re(
385
+ const d = {};
386
+ for (const l of o) {
387
+ const m = l.relationship.dimensions, { codedSeriesKey: f, decodedSeriesKey: E } = he(
396
388
  e,
397
389
  u,
398
- A
390
+ m
399
391
  );
400
- l[D.id] = {
401
- values: (i == null ? void 0 : i[y]) || [],
402
- decodedSeriesKey: S,
403
- codedSeriesKey: y
392
+ d[l.id] = {
393
+ values: i?.[f] || [],
394
+ decodedSeriesKey: E,
395
+ codedSeriesKey: f
404
396
  };
405
397
  }
406
- return l;
407
- }, Xe = (e, t) => {
408
- var s;
398
+ return d;
399
+ }, Ge = (e, t) => {
409
400
  if (t == null)
410
401
  return;
411
- const n = (s = e.values) == null ? void 0 : s[t];
402
+ const n = e.values?.[t];
412
403
  return n ?? (t instanceof Array ? { values: t } : { value: t.toString() });
413
- }, Ze = "Observation", $n = (e) => {
414
- var u, l, f, h, d, g;
415
- const t = (u = e == null ? void 0 : e.data) == null ? void 0 : u.dataSets, n = (f = (l = e == null ? void 0 : e.data) == null ? void 0 : l.structures) == null ? void 0 : f[0];
404
+ }, Ke = "Observation", Sn = (e) => {
405
+ const t = e?.data?.dataSets, n = e?.data?.structures?.[0];
416
406
  if (!t || !n)
417
407
  return [];
418
- const s = n.attributes, r = n.dimensions, o = (s == null ? void 0 : s.dimensionGroup) || [], i = t[0].series || t[0].observations, c = (h = r.series) != null && h.length ? r.series : r.observation, a = [];
419
- for (const E in i) {
420
- const D = [], { name: A, parsedTimeSeriesValue: y } = et(
421
- E,
408
+ const s = n.attributes, r = n.dimensions, o = s?.dimensionGroup || [], i = t[0].series || t[0].observations, c = r.series?.length ? r.series : r.observation, a = [];
409
+ for (const u in i) {
410
+ const d = [], { name: l, parsedTimeSeriesValue: m } = je(
411
+ u,
422
412
  c
423
- ), S = i[E], O = S.attributes || [];
424
- if (Object.keys(S).length === 0) {
413
+ ), f = i[u], E = f.attributes || [];
414
+ if (Object.keys(f).length === 0) {
425
415
  a.push({
426
- name: A,
427
- parsedTimeSeriesValue: y,
428
- values: D,
416
+ name: l,
417
+ parsedTimeSeriesValue: m,
418
+ values: d,
429
419
  attributes: [],
430
420
  dataSetAttrs: []
431
421
  });
432
422
  continue;
433
423
  }
434
- D.push(
435
- ...rt(S, n)
424
+ d.push(
425
+ ...Xe(f, n)
436
426
  );
437
- const P = C(
438
- (s == null ? void 0 : s.series) || [],
439
- (T) => O[T]
440
- ), b = ot(
441
- ((d = n.attributes) == null ? void 0 : d.dataSet) || [],
442
- ((g = t[0].attributes) == null ? void 0 : g.filter((T) => T != null)) || []
443
- ), L = Je(
427
+ const w = _(
428
+ s?.series || [],
429
+ (p) => E[p]
430
+ ), I = Ze(
431
+ n.attributes?.dataSet || [],
432
+ t[0].attributes?.filter((p) => p != null) || []
433
+ ), N = Fe(
444
434
  e,
445
- y
446
- ), U = o.map((T, _e) => {
447
- const ne = L[T.id], Oe = Xe(
448
- T,
449
- ne.values[_e]
435
+ m
436
+ ), $ = o.map((p, ve) => {
437
+ const z = N[p.id], Re = Ge(
438
+ p,
439
+ z.values[ve]
450
440
  );
451
441
  return {
452
- attribute: T,
453
- dimensionGroupValue: Oe,
454
- dimensionGroupData: ne
442
+ attribute: p,
443
+ dimensionGroupValue: Re,
444
+ dimensionGroupData: z
455
445
  };
456
446
  });
457
447
  a.push({
458
- name: A,
459
- parsedTimeSeriesValue: y,
460
- values: D,
461
- attributes: P,
462
- dataSetAttrs: b,
463
- dimensionGroupAttributes: U
448
+ name: l,
449
+ parsedTimeSeriesValue: m,
450
+ values: d,
451
+ attributes: w,
452
+ dataSetAttrs: I,
453
+ dimensionGroupAttributes: $
464
454
  });
465
455
  }
466
456
  return a;
467
- }, et = (e, t) => {
457
+ }, je = (e, t) => {
468
458
  const n = e.split(new RegExp("(?<!\\|):(?!\\||$)")), s = [];
469
459
  for (let r = 0; r < n.length; r++) {
470
- const o = t == null ? void 0 : t[r], i = Number(n[r]);
460
+ const o = t?.[r], i = Number(n[r]);
471
461
  if (i < 0 || o == null)
472
462
  continue;
473
463
  const c = o.values[i];
@@ -475,73 +465,68 @@ const Je = (e, t) => {
475
465
  s.push(n[r].replace("|:", ":"));
476
466
  continue;
477
467
  }
478
- s.push((c == null ? void 0 : c.id) || (c == null ? void 0 : c.value) || "");
468
+ s.push(c?.id || c?.value || "");
479
469
  }
480
470
  return {
481
- name: nt(s),
471
+ name: ze(s),
482
472
  parsedTimeSeriesValue: s
483
473
  };
484
- }, C = (e, t) => {
474
+ }, _ = (e, t) => {
485
475
  const n = [];
486
476
  for (let s = 0; s < e.length; s++) {
487
- const r = e[s], o = t(s), i = o != null && r.values != null ? tt(o, r) : void 0;
477
+ const r = e[s], o = t(s), i = o != null && r.values != null ? He(o, r) : void 0;
488
478
  n.push({
489
479
  name: r.id,
490
480
  value: i
491
481
  });
492
482
  }
493
483
  return n;
494
- }, tt = (e, t) => {
484
+ }, He = (e, t) => {
495
485
  const n = t.values[e];
496
- 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);
497
- }, nt = (e) => e.map((t) => t ? st(t) : "").join("."), st = (e) => e.replace(/\./g, "|.").replace(/:/g, "|:"), rt = (e, t) => {
498
- var i, c, a, u, l;
499
- const n = (c = (i = t.measures) == null ? void 0 : i.observation) == null ? void 0 : c.length;
486
+ return n == null ? typeof e == "object" ? e : e.toString() : n?.id || n?.value || n?.ids || n?.values;
487
+ }, ze = (e) => e.map((t) => t ? Je(t) : "").join("."), Je = (e) => e.replace(/\./g, "|.").replace(/:/g, "|:"), Xe = (e, t) => {
488
+ const n = t.measures?.observation?.length;
500
489
  if (e.observations == null)
501
490
  return [
502
491
  {
503
- values: ce(e, t.measures),
504
- obsAttributes: C(
505
- ((a = t.attributes) == null ? void 0 : a.observation) || [],
506
- (f) => e[f + n]
492
+ values: te(e, t.measures),
493
+ obsAttributes: _(
494
+ t.attributes?.observation || [],
495
+ (i) => e[i + n]
507
496
  ),
508
- dimensionAtObservation: Ze
497
+ dimensionAtObservation: Ke
509
498
  }
510
499
  ];
511
- const s = e.observations, r = (u = t.dimensions.observation) == null ? void 0 : u[0], o = [];
512
- for (const f in s) {
513
- const h = r == null ? void 0 : r.values[f];
500
+ const s = e.observations, r = t.dimensions.observation?.[0], o = [];
501
+ for (const i in s) {
502
+ const c = r?.values[i];
514
503
  o.push({
515
- dimensionAtObservation: (h == null ? void 0 : h.value) || (h == null ? void 0 : h.id),
516
- values: ce(
517
- s[f],
504
+ dimensionAtObservation: c?.value || c?.id,
505
+ values: te(
506
+ s[i],
518
507
  t.measures
519
508
  ),
520
- obsAttributes: C(
521
- ((l = t.attributes) == null ? void 0 : l.observation) || [],
522
- (d) => s[f][d + n]
509
+ obsAttributes: _(
510
+ t.attributes?.observation || [],
511
+ (a) => s[i][a + n]
523
512
  )
524
513
  });
525
514
  }
526
515
  return o;
527
- }, ce = (e, t) => {
528
- var n;
529
- return ((n = t == null ? void 0 : t.observation) == null ? void 0 : n.map((s, r) => ({ name: s.id, value: e[r] }))) || [];
530
- }, ot = (e, t) => e.reduce(
516
+ }, te = (e, t) => t?.observation?.map((n, s) => ({ name: n.id, value: e[s] })) || [], Ze = (e, t) => e.reduce(
531
517
  (n, s, r) => {
532
518
  const o = t[r];
533
- return it(n, s, o, ""), n;
519
+ return et(n, s, o, ""), n;
534
520
  },
535
521
  []
536
- ), it = (e, t, n, s) => {
537
- var o, i, c;
538
- const r = 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) : s;
522
+ ), et = (e, t, n, s) => {
523
+ const r = n != null ? t?.values?.length > 0 ? t.values[n]?.id || t.values[n]?.value : String(n) : s;
539
524
  e.push({
540
525
  name: t.id,
541
526
  value: r || ""
542
527
  });
543
- }, ct = /^[0-9][0-9][0-9][0-9]-Q[1-4]$/, at = /^[0-9][0-9][0-9][0-9]-W[0-9][0-9]?$/, ut = /^[0-9][0-9][0-9][0-9]-S[1-2]$/, lt = /^[0-9][0-9][0-9][0-9]$/, dt = /^[0-9][0-9][0-9][0-9]-(0[1-9]|1[0-2])-[0-9][0-9]$/, ft = /^[0-9][0-9][0-9][0-9]-M(0[1-9]|(1[0-2]))$/, M = (e) => lt.exec(e), Q = (e) => !!M(e), gt = (e) => ut.exec(e), B = (e) => !!gt(e), V = (e) => ft.exec(e), F = (e) => !!V(e), G = (e) => ct.exec(e), K = (e) => !!G(e), ht = (e) => dt.exec(e), Et = (e) => !!ht(e), At = (e) => at.exec(e), j = (e) => !!At(e), H = 1440 * 60 * 1e3, z = 7 * H;
544
- function J(e) {
528
+ }, tt = /^[0-9][0-9][0-9][0-9]-Q[1-4]$/, nt = /^[0-9][0-9][0-9][0-9]-W[0-9][0-9]?$/, st = /^[0-9][0-9][0-9][0-9]-S[1-2]$/, rt = /^[0-9][0-9][0-9][0-9]$/, ot = /^[0-9][0-9][0-9][0-9]-(0[1-9]|1[0-2])-[0-9][0-9]$/, it = /^[0-9][0-9][0-9][0-9]-M(0[1-9]|(1[0-2]))$/, C = (e) => rt.exec(e), U = (e) => !!C(e), at = (e) => st.exec(e), x = (e) => !!at(e), Y = (e) => it.exec(e), W = (e) => !!Y(e), k = (e) => tt.exec(e), q = (e) => !!k(e), ct = (e) => ot.exec(e), ut = (e) => !!ct(e), dt = (e) => nt.exec(e), Q = (e) => !!dt(e), V = 1440 * 60 * 1e3, B = 7 * V;
529
+ function F(e) {
545
530
  const t = `${e}-01-01`, n = new Date(t);
546
531
  if (n.getDay() !== 4) {
547
532
  const r = 1 + (4 - n.getDay() + 7) % 7;
@@ -549,55 +534,55 @@ function J(e) {
549
534
  }
550
535
  return n;
551
536
  }
552
- function Dt(e) {
537
+ function lt(e) {
553
538
  const t = new Date(e), s = -((t.getDay() + 6) % 7) + 3;
554
539
  return t.setDate(t.getDate() + s), new Date(t.valueOf());
555
540
  }
556
- function ae(e, t = "W") {
557
- const n = `${e}-12-31`, s = _(new Date(n), t);
541
+ function ne(e, t = "W") {
542
+ const n = `${e}-12-31`, s = R(new Date(n), t);
558
543
  if (s.weekYear === e)
559
544
  return s.weekNumber;
560
545
  const r = `${e}-12-24`;
561
- return _(new Date(r), t).weekNumber;
546
+ return R(new Date(r), t).weekNumber;
562
547
  }
563
- function we(e, t, n = "W") {
548
+ function Ee(e, t, n = "W") {
564
549
  return `${e}-${n}${t < 10 ? "0" + t : t}`;
565
550
  }
566
- function _(e, t = "W") {
567
- const n = Dt(e), s = n.getFullYear(), r = J(s), o = 1 + Math.ceil(
568
- (n.getTime() - r.getTime()) / z
551
+ function R(e, t = "W") {
552
+ const n = lt(e), s = n.getFullYear(), r = F(s), o = 1 + Math.ceil(
553
+ (n.getTime() - r.getTime()) / B
569
554
  );
570
555
  return {
571
- code: we(s, o, t),
556
+ code: Ee(s, o, t),
572
557
  weekNumber: o,
573
558
  weekYear: s
574
559
  };
575
560
  }
576
- function yt(e) {
577
- const [t, n] = e.split("-W"), r = J(+t).getTime() + (+n - 1) * z - 3 * H;
561
+ function mt(e) {
562
+ const [t, n] = e.split("-W"), r = F(+t).getTime() + (+n - 1) * B - 3 * V;
578
563
  return new Date(r);
579
564
  }
580
- function St(e) {
581
- const [t, n] = e.split("-W"), r = J(+t).getTime() + (+n - 1) * z + 3 * H;
565
+ function ft(e) {
566
+ const [t, n] = e.split("-W"), r = F(+t).getTime() + (+n - 1) * B + 3 * V;
582
567
  return new Date(r);
583
568
  }
584
569
  function pe(e) {
585
- return Q(e) ? Tt(e) : B(e) ? wt(e) : K(e) ? mt(e) : F(e) ? Nt(e) : j(e) ? yt(e) : It(e);
570
+ return U(e) ? gt(e) : x(e) ? Et(e) : q(e) ? Dt(e) : W(e) ? yt(e) : Q(e) ? mt(e) : Tt(e);
586
571
  }
587
- function me(e) {
588
- return Q(e) ? Rt(e) : B(e) ? pt(e) : K(e) ? vt(e) : F(e) ? $t(e) : j(e) ? St(e) : _t(e);
572
+ function De(e) {
573
+ return U(e) ? ht(e) : x(e) ? pt(e) : q(e) ? At(e) : W(e) ? St(e) : Q(e) ? ft(e) : vt(e);
589
574
  }
590
- function Tt(e) {
591
- const t = M(e);
575
+ function gt(e) {
576
+ const t = C(e);
592
577
  if (t)
593
578
  return new Date(Number(t[0]), 0, 1);
594
579
  }
595
- function Rt(e) {
596
- const t = M(e);
580
+ function ht(e) {
581
+ const t = C(e);
597
582
  if (t)
598
583
  return new Date(Number(t[0]) + 1, 0, 1);
599
584
  }
600
- function wt(e) {
585
+ function Et(e) {
601
586
  const [t, n] = e.split("-S");
602
587
  switch (+n) {
603
588
  case 1:
@@ -615,8 +600,8 @@ function pt(e) {
615
600
  return new Date(+t + 1, 0, 1);
616
601
  }
617
602
  }
618
- function mt(e) {
619
- const t = G(e);
603
+ function Dt(e) {
604
+ const t = k(e);
620
605
  if (!t)
621
606
  return;
622
607
  const [n, s] = t[0].split("-Q");
@@ -631,8 +616,8 @@ function mt(e) {
631
616
  return new Date(+n, 9, 1);
632
617
  }
633
618
  }
634
- function vt(e) {
635
- const t = G(e);
619
+ function At(e) {
620
+ const t = k(e);
636
621
  if (!t)
637
622
  return;
638
623
  const [n, s] = t[0].split("-Q");
@@ -647,45 +632,45 @@ function vt(e) {
647
632
  return new Date(+n + 1, 0, 1);
648
633
  }
649
634
  }
650
- function Nt(e) {
651
- const t = V(e);
635
+ function yt(e) {
636
+ const t = Y(e);
652
637
  if (!t)
653
638
  return;
654
639
  const [n, s] = t[0].split("-M");
655
640
  return new Date(+n, +s - 1, 1);
656
641
  }
657
- function $t(e) {
658
- const t = V(e);
642
+ function St(e) {
643
+ const t = Y(e);
659
644
  if (!t)
660
645
  return;
661
646
  const [n, s] = t[0].split("-M");
662
647
  return new Date(+n, +s, 1);
663
648
  }
664
- const It = (e) => /* @__PURE__ */ new Date(`${e}T00:00:00`), _t = (e) => {
649
+ const Tt = (e) => /* @__PURE__ */ new Date(`${e}T00:00:00`), vt = (e) => {
665
650
  const t = /* @__PURE__ */ new Date(`${e}T23:59:00`);
666
651
  return t.setMinutes(t.getMinutes() + 1), t;
667
- }, Ot = 1, Pt = (e, t, n, s = !0, r = "Q") => {
668
- const o = [], i = t && t > 3 ? Wt(t, s) : 1, c = n ? Math.floor((n - 1) / 3) : 4;
652
+ }, Rt = 1, wt = (e, t, n, s = !0, r = "Q") => {
653
+ const o = [], i = t && t > 3 ? Ot(t, s) : 1, c = n ? Math.floor((n - 1) / 3) : 4;
669
654
  for (let a = i; a <= c; a++)
670
655
  o.push(`${e}-${r}${a}`);
671
656
  return o;
672
- }, bt = (e, t, n, s = "S") => {
657
+ }, It = (e, t, n, s = "S") => {
673
658
  const r = [];
674
659
  return (t || 1) < 7 && (n || 12) > 6 && r.push(`${e}-${s}1`), n == null && r.push(`${e}-${s}2`), r;
675
- }, In = (e) => Math.ceil(e / 3), ve = (e, t, n = "M") => `${e}-${n}${t.toString().padStart(2, "0")}`, Lt = (e, t, n = "M") => {
660
+ }, Tn = (e) => Math.ceil(e / 3), Ae = (e, t, n = "M") => `${e}-${n}${t.toString().padStart(2, "0")}`, Nt = (e, t, n = "M") => {
676
661
  const s = [];
677
662
  for (let r = t; r <= 12; r++)
678
- s.push(ve(e, r, n));
663
+ s.push(Ae(e, r, n));
679
664
  return s;
680
- }, Ut = (e, t, n, s = "M") => {
665
+ }, $t = (e, t, n, s = "M") => {
681
666
  const r = [];
682
667
  for (let o = t; o < n; o++)
683
- r.push(ve(e, o, s));
668
+ r.push(Ae(e, o, s));
684
669
  return r;
685
- }, xt = (e, t, n, s = "M") => {
670
+ }, Pt = (e, t, n, s = "M") => {
686
671
  const r = t || 1, o = n == null, i = n || 12;
687
- return o ? Lt(e, r, s) : Ut(e, r, i, s);
688
- }, _n = (e, t, n = "M") => {
672
+ return o ? Nt(e, r, s) : $t(e, r, i, s);
673
+ }, vn = (e, t, n = "M") => {
689
674
  switch (t) {
690
675
  case 0:
691
676
  return [
@@ -714,61 +699,57 @@ const It = (e) => /* @__PURE__ */ new Date(`${e}T00:00:00`), _t = (e) => {
714
699
  default:
715
700
  return [];
716
701
  }
717
- }, Yt = (e, t) => {
718
- const n = R(t, !0), s = R(e), r = n.getFullYear(), o = s.getFullYear(), i = n.getTime() <= s.getTime() ? o + Ot - r : 0;
702
+ }, bt = (e, t) => {
703
+ const n = g(t, !0), s = g(e), r = n.getFullYear(), o = s.getFullYear(), i = n.getTime() <= s.getTime() ? o + Rt - r : 0;
719
704
  return Array.from({ length: i }, (a, u) => r + u);
720
- }, R = (e, t = !1) => {
721
- const n = Ct(e, t);
705
+ }, g = (e, t = !1) => {
706
+ const n = _t(e, t);
722
707
  return n ? (n.getTimezoneOffset() > 0 && n.setMinutes(n.getMinutes() + n.getTimezoneOffset()), n) : /* @__PURE__ */ new Date();
723
- }, Ct = (e, t = !1) => {
708
+ }, _t = (e, t = !1) => {
724
709
  const n = Number(e);
725
- return e.toString().length !== 13 ? t ? pe(e) : me(e) : isNaN(n) ? /* @__PURE__ */ new Date(`${e}T00:00:00.000Z`) : new Date(n);
726
- }, Wt = (e, t) => t ? Math.floor((e + 1) / 3) : Math.ceil((e + 1) / 3), On = (e, t) => {
727
- const n = le(e) - le(t);
710
+ return e.toString().length !== 13 ? t ? pe(e) : De(e) : isNaN(n) ? /* @__PURE__ */ new Date(`${e}T00:00:00.000Z`) : new Date(n);
711
+ }, Ot = (e, t) => t ? Math.floor((e + 1) / 3) : Math.ceil((e + 1) / 3), Rn = (e, t) => {
712
+ const n = re(e) - re(t);
728
713
  if (n === 0 && e !== t) {
729
- const s = ue(e), r = ue(t);
714
+ const s = se(e), r = se(t);
730
715
  return s - r;
731
716
  }
732
717
  return n;
733
- }, ue = (e) => Q(e) ? 6 : B(e) ? 5 : K(e) ? 4 : F(e) ? 3 : j(e) ? 2 : Et(e) ? 1 : 0, le = (e, t = !1) => {
734
- const n = t ? pe(e) : me(e);
735
- return (n == null ? void 0 : n.getTime()) || 0;
736
- };
737
- var X = /* @__PURE__ */ ((e) => (e.LAST_UPDATE_AT = "lastUpdatedAt", e.SERIES_COUNT = "series_count", e))(X || {}), kt = /* @__PURE__ */ ((e) => (e.C = "c", e))(kt || {}), w = /* @__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))(w || {}), qt = /* @__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))(qt || {}), Mt = /* @__PURE__ */ ((e) => (e.ANNUAL = "A", e.QUARTERLY = "Q", e.MONTHLY = "M", e))(Mt || {});
738
- function Pn(e) {
739
- var t, n;
740
- return (n = (t = e == null ? void 0 : e.annotations) == null ? void 0 : t.find((s) => {
741
- if (s.id === X.LAST_UPDATE_AT)
742
- return s;
743
- })) == null ? void 0 : n.value;
718
+ }, se = (e) => U(e) ? 6 : x(e) ? 5 : q(e) ? 4 : W(e) ? 3 : Q(e) ? 2 : ut(e) ? 1 : 0, re = (e, t = !1) => (t ? pe(e) : De(e))?.getTime() || 0;
719
+ var G = /* @__PURE__ */ ((e) => (e.LAST_UPDATE_AT = "lastUpdatedAt", e.SERIES_COUNT = "series_count", e))(G || {}), Lt = /* @__PURE__ */ ((e) => (e.C = "c", e))(Lt || {}), h = /* @__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))(h || {}), Mt = /* @__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))(Mt || {}), Ct = /* @__PURE__ */ ((e) => (e.ANNUAL = "A", e.QUARTERLY = "Q", e.MONTHLY = "M", e))(Ct || {});
720
+ function wn(e) {
721
+ return e?.annotations?.find((t) => {
722
+ if (t.id === G.LAST_UPDATE_AT)
723
+ return t;
724
+ })?.value;
744
725
  }
745
- const Z = (e, t) => (e == null ? void 0 : e.names) && (e == null ? void 0 : e.names[t]) || (e == null ? void 0 : e.name), Ne = (e, t, n) => {
746
- 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)) {
747
- const s = n == null ? void 0 : n.get(e == null ? void 0 : e.parent);
748
- Ne(s, t, n);
726
+ const K = (e, t) => e?.names && e?.names[t] || e?.name, ye = (e, t, n) => {
727
+ if (!(!e || t?.has(e?.id)) && (t?.set(e?.id, e), e?.parent)) {
728
+ const s = n?.get(e?.parent);
729
+ ye(s, t, n);
749
730
  }
750
- }, Qt = (e, t) => {
751
- const n = /* @__PURE__ */ new Map(), s = new Map(e == null ? void 0 : e.map((r) => [r.id, r]));
752
- return t == null || t.forEach((r) => {
753
- Ne(r, n, s);
754
- }), Array.from(n == null ? void 0 : n.values());
755
- }, Bt = "time_period_end", Vt = "time_period_start", Ft = "TIME_PERIOD", bn = (e) => {
756
- const t = e == null ? void 0 : e.find(
757
- (o) => o.id === Vt
758
- ), n = e == null ? void 0 : e.find(
759
- (o) => o.id === Bt
760
- ), s = n != null && n.title ? new Date(n == null ? void 0 : n.title) : null;
731
+ }, Ut = (e, t) => {
732
+ const n = /* @__PURE__ */ new Map(), s = new Map(e?.map((r) => [r.id, r]));
733
+ return t?.forEach((r) => {
734
+ ye(r, n, s);
735
+ }), Array.from(n?.values());
736
+ }, xt = "time_period_end", Yt = "time_period_start", Wt = "TIME_PERIOD", In = (e) => {
737
+ const t = e?.find(
738
+ (o) => o.id === Yt
739
+ ), n = e?.find(
740
+ (o) => o.id === xt
741
+ ), s = n?.title ? new Date(n?.title) : null;
761
742
  return {
762
- startPeriod: t != null && t.title ? new Date(t == null ? void 0 : t.title) : null,
743
+ startPeriod: t?.title ? new Date(t?.title) : null,
763
744
  endPeriod: s
764
745
  };
765
- }, Gt = (e, t) => e.id.localeCompare(t.id), Kt = (e, t) => e.memberValue.localeCompare(t.memberValue), jt = (e, t) => {
746
+ }, kt = (e, t) => e.id.localeCompare(t.id), qt = (e, t) => e.memberValue.localeCompare(t.memberValue), Qt = (e, t) => {
766
747
  const n = new Array(e.length), s = e.map((i, c) => [i, c]);
767
748
  s.sort(
768
- (i, c) => Gt(i[0], c[0])
749
+ (i, c) => kt(i[0], c[0])
769
750
  );
770
751
  const r = [...t];
771
- r.sort(Kt);
752
+ r.sort(qt);
772
753
  let o = 0;
773
754
  for (const i of s) {
774
755
  const c = i[0];
@@ -777,225 +758,208 @@ const Z = (e, t) => (e == null ? void 0 : e.names) && (e == null ? void 0 : e.na
777
758
  o < r.length && r[o].memberValue === c.id && (n[i[1]] = i[0]);
778
759
  }
779
760
  return n.filter((i) => i != null);
780
- }, Ht = (e) => !!(e != null && e.some((t) => t.parent)), Ln = (e, t, n, s, r = []) => {
781
- var i, c;
761
+ }, Vt = (e) => !!e?.some((t) => t.parent), Nn = (e, t, n, s, r = []) => {
782
762
  let o = e || [];
783
- if (zt(n || [], t || "")) {
784
- const a = (i = (n || [])[0].cubeRegions) == null ? void 0 : i.find(
785
- ({ isIncluded: u }) => u
763
+ if (Bt(n || [], t || "")) {
764
+ const i = (n || [])[0].cubeRegions?.find(
765
+ ({ isIncluded: c }) => c
786
766
  );
787
- if (a) {
788
- const u = (c = a.memberSelection) == null ? void 0 : c.find(
789
- ({ componentId: l }) => l === t
767
+ if (i) {
768
+ const c = i.memberSelection?.find(
769
+ ({ componentId: a }) => a === t
790
770
  );
791
- u ? o = o.length === 0 ? (u.selectionValues || []).map(({ memberValue: l }) => ({
792
- id: l,
793
- name: l
794
- })) : jt(o, u.selectionValues) : o = [];
771
+ c ? o = o.length === 0 ? (c.selectionValues || []).map(({ memberValue: a }) => ({
772
+ id: a,
773
+ name: a
774
+ })) : Qt(o, c.selectionValues) : o = [];
795
775
  }
796
- } else r.length !== 0 && (o = o.filter(({ id: a }) => r.includes(a)));
797
- return Ht(e) && (o = Qt(e, o)), o == null ? void 0 : o.map((a) => ({
798
- ...a,
799
- name: s ? Z(a, s) : a == null ? void 0 : a.name
776
+ } else r.length !== 0 && (o = o.filter(({ id: i }) => r.includes(i)));
777
+ return Vt(e) && (o = Ut(e, o)), o?.map((i) => ({
778
+ ...i,
779
+ name: s ? K(i, s) : i?.name
800
780
  }));
801
- }, zt = (e, t) => e != null && e.length > 0 && t != null, Un = (e) => {
802
- var n;
781
+ }, Bt = (e, t) => e != null && e.length > 0 && t != null, $n = (e) => {
803
782
  const t = [];
804
- return (n = e == null ? void 0 : e.filters) == null || n.forEach((s) => {
805
- s.componentCode !== Ft && t.push({
806
- componentCode: s.componentCode,
807
- operator: w.EQUALS,
808
- value: s.values.join(",")
783
+ return e?.filters?.forEach((n) => {
784
+ n.componentCode !== Wt && t.push({
785
+ componentCode: n.componentCode,
786
+ operator: h.EQUALS,
787
+ value: n.values.join(",")
809
788
  });
810
789
  }), t;
811
- }, Jt = /^[v^~<>=]*?(\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+))?(?:-([\da-z\-]+(?:\.[\da-z\-]+)*))?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i, de = (e) => {
790
+ }, Ft = /^[v^~<>=]*?(\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+))?(?:-([\da-z\-]+(?:\.[\da-z\-]+)*))?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i, oe = (e) => {
812
791
  if (typeof e != "string")
813
792
  throw new TypeError("Invalid argument expected string");
814
- const t = e.match(Jt);
793
+ const t = e.match(Ft);
815
794
  if (!t)
816
795
  throw new Error(`Invalid argument not valid semver ('${e}' received)`);
817
796
  return t.shift(), t;
818
- }, fe = (e) => e === "*" || e === "x" || e === "X", ge = (e) => {
797
+ }, ie = (e) => e === "*" || e === "x" || e === "X", ae = (e) => {
819
798
  const t = parseInt(e, 10);
820
799
  return isNaN(t) ? e : t;
821
- }, Xt = (e, t) => typeof e != typeof t ? [String(e), String(t)] : [e, t], Zt = (e, t) => {
822
- if (fe(e) || fe(t))
800
+ }, Gt = (e, t) => typeof e != typeof t ? [String(e), String(t)] : [e, t], Kt = (e, t) => {
801
+ if (ie(e) || ie(t))
823
802
  return 0;
824
- const [n, s] = Xt(ge(e), ge(t));
803
+ const [n, s] = Gt(ae(e), ae(t));
825
804
  return n > s ? 1 : n < s ? -1 : 0;
826
- }, he = (e, t) => {
805
+ }, ce = (e, t) => {
827
806
  for (let n = 0; n < Math.max(e.length, t.length); n++) {
828
- const s = Zt(e[n] || "0", t[n] || "0");
807
+ const s = Kt(e[n] || "0", t[n] || "0");
829
808
  if (s !== 0)
830
809
  return s;
831
810
  }
832
811
  return 0;
833
- }, en = (e, t) => {
834
- const n = de(e), s = de(t), r = n.pop(), o = s.pop(), i = he(n, s);
835
- return i !== 0 ? i : r && o ? he(r.split("."), o.split(".")) : r || o ? r ? -1 : 1 : 0;
836
- }, tn = (e, t, n) => {
837
- nn(n);
838
- const s = en(e, t);
839
- return $e[n].includes(s);
840
- }, $e = {
812
+ }, jt = (e, t) => {
813
+ const n = oe(e), s = oe(t), r = n.pop(), o = s.pop(), i = ce(n, s);
814
+ return i !== 0 ? i : r && o ? ce(r.split("."), o.split(".")) : r || o ? r ? -1 : 1 : 0;
815
+ }, Ht = (e, t, n) => {
816
+ zt(n);
817
+ const s = jt(e, t);
818
+ return Se[n].includes(s);
819
+ }, Se = {
841
820
  ">": [1],
842
821
  ">=": [0, 1],
843
822
  "=": [0],
844
823
  "<=": [-1, 0],
845
824
  "<": [-1],
846
825
  "!=": [-1, 1]
847
- }, Ee = Object.keys($e), nn = (e) => {
848
- if (Ee.indexOf(e) === -1)
849
- throw new Error(`Invalid operator, expected one of ${Ee.join("|")}`);
850
- }, W = "+", ee = (e, t) => {
851
- const { agency: n, id: s, version: r } = p(e), o = t.filter(
852
- (a) => {
853
- var u;
854
- return a.agencyID === n && a.id === s && !((u = a == null ? void 0 : a.version) != null && u.includes(W));
855
- }
826
+ }, ue = Object.keys(Se), zt = (e) => {
827
+ if (ue.indexOf(e) === -1)
828
+ throw new Error(`Invalid operator, expected one of ${ue.join("|")}`);
829
+ }, O = "+", j = (e, t) => {
830
+ const { agency: n, id: s, version: r } = D(e), o = t.filter(
831
+ (a) => a.agencyID === n && a.id === s && !a?.version?.includes(O)
856
832
  );
857
833
  if (o.length === 1)
858
834
  return o[0];
859
- if (!(r != null && r.includes(W)))
835
+ if (!r?.includes(O))
860
836
  return o.find((a) => a.version === r);
861
837
  const i = o.map(
862
838
  (a) => a.version
863
- ), c = sn(r, i);
839
+ ), c = Jt(r, i);
864
840
  return o.find(
865
841
  (a) => a.version === c[0]
866
842
  );
867
- }, sn = (e, t) => {
868
- const n = rn(e, t);
843
+ }, Jt = (e, t) => {
844
+ const n = Xt(e, t);
869
845
  return n.length > 0 ? [n[0]] : [];
870
- }, rn = (e, t) => {
846
+ }, Xt = (e, t) => {
871
847
  const n = [];
872
848
  return t.forEach((s) => {
873
- cn(e, s) && n.push(s);
849
+ en(e, s) && n.push(s);
874
850
  }), n;
875
- }, on = (e) => {
851
+ }, Zt = (e) => {
876
852
  const t = e.trim().replace(/\d+\+/, "*"), [n] = t.split("*");
877
853
  return new RegExp(`^${n}`);
878
- }, cn = (e, t) => {
854
+ }, en = (e, t) => {
879
855
  const n = e.trim().replace(/\+/, "");
880
- return on(e).test(t) && tn(t, n, ">=");
881
- }, te = (e, t) => {
882
- const { concept: n } = an(e, t);
856
+ return Zt(e).test(t) && Ht(t, n, ">=");
857
+ }, H = (e, t) => {
858
+ const { concept: n } = tn(e, t);
883
859
  return n;
884
- }, an = (e, t) => {
860
+ }, tn = (e, t) => {
885
861
  if (e == null)
886
862
  return {
887
863
  concept: void 0,
888
864
  scheme: void 0
889
865
  };
890
- const { childId: n, agency: s, id: r, version: o } = Pe(e);
891
- if (o != null && o.includes(W)) {
892
- const i = ee(
866
+ const { childId: n, agency: s, id: r, version: o } = we(e);
867
+ if (o?.includes(O)) {
868
+ const i = j(
893
869
  e,
894
870
  t
895
871
  );
896
872
  return {
897
- concept: Ae((i == null ? void 0 : i.concepts) || [], n),
873
+ concept: de(i?.concepts || [], n),
898
874
  scheme: i
899
875
  };
900
876
  }
901
877
  for (const i of t)
902
- if (un(i, r, s, o))
878
+ if (nn(i, r, s, o))
903
879
  return {
904
- concept: Ae((i == null ? void 0 : i.concepts) || [], n),
880
+ concept: de(i?.concepts || [], n),
905
881
  scheme: i
906
882
  };
907
883
  return {
908
884
  concept: void 0,
909
885
  scheme: void 0
910
886
  };
911
- }, Ae = (e, t) => e == null ? void 0 : e.find((n) => n.id === t), un = (e, t, n, s) => e.id === t && e.agencyID === n && e.version === s, xn = (e = [], t = [], n) => {
912
- var a, u;
913
- const s = (n == null ? void 0 : n.conceptIdentity) || "", r = te(s, t), o = I(
914
- (a = n == null ? void 0 : n.localRepresentation) == null ? void 0 : a.enumeration
915
- ), i = I(
916
- (u = r == null ? void 0 : r.coreRepresentation) == null ? void 0 : u.enumeration
887
+ }, de = (e, t) => e?.find((n) => n.id === t), nn = (e, t, n, s) => e.id === t && e.agencyID === n && e.version === s, Pn = (e = [], t = [], n) => {
888
+ const s = n?.conceptIdentity || "", r = H(s, t), o = v(
889
+ n?.localRepresentation?.enumeration
890
+ ), i = v(
891
+ r?.coreRepresentation?.enumeration
917
892
  ), c = o || i;
918
893
  if (c != null)
919
- return ee(c, e);
920
- }, Yn = (e, t, n, s) => {
921
- var o, i;
922
- const r = (o = t == null ? void 0 : t.find(
923
- (c) => (c == null ? void 0 : c.id) === (e == null ? void 0 : e.id)
924
- )) == null ? void 0 : o.values;
925
- return ((i = n == null ? void 0 : n.filter((c) => r == null ? void 0 : r.some((a) => a.id === c.id))) == null ? void 0 : i.map((c) => ({
926
- ...c,
927
- name: s ? Z(c, s) : c == null ? void 0 : c.name
928
- }))) || [];
929
- }, ln = (e, t) => {
930
- var r, o, i;
931
- const n = (r = t == null ? void 0 : t.dataStructureComponents) == null ? void 0 : r.attributeList, s = (o = e == null ? void 0 : e.metadataStructureComponents) == null ? void 0 : o.metadataAttributeList;
932
- return (i = n == null ? void 0 : n.metadataAttributeUsages) == null ? void 0 : i.map((c) => {
933
- var u;
934
- const a = (u = s == null ? void 0 : s.metadataAttributes) == null ? void 0 : u.find(
935
- (l) => (l == null ? void 0 : l.id) === (c == null ? void 0 : c.metadataAttributeReference)
894
+ return j(c, e);
895
+ }, bn = (e, t, n, s) => {
896
+ const r = t?.find(
897
+ (o) => o?.id === e?.id
898
+ )?.values;
899
+ return n?.filter((o) => r?.some((i) => i.id === o.id))?.map((o) => ({
900
+ ...o,
901
+ name: s ? K(o, s) : o?.name
902
+ })) || [];
903
+ }, sn = (e, t) => {
904
+ const n = t?.dataStructureComponents?.attributeList, s = e?.metadataStructureComponents?.metadataAttributeList;
905
+ return n?.metadataAttributeUsages?.map((r) => {
906
+ const o = s?.metadataAttributes?.find(
907
+ (i) => i?.id === r?.metadataAttributeReference
936
908
  );
937
909
  return {
938
- ...a,
939
- attributeRelationship: c.attributeRelationship,
940
- isMandatory: Number(a == null ? void 0 : a.minOccurs) > 0
910
+ ...o,
911
+ attributeRelationship: r.attributeRelationship,
912
+ isMandatory: Number(o?.minOccurs) > 0
941
913
  };
942
914
  });
943
- }, Cn = (e = [], t, n) => {
944
- const s = I(t == null ? void 0 : t.conceptIdentity) || "", r = te(s, e);
945
- return n ? Z(r, n) : (r == null ? void 0 : r.name) ?? (r == null ? void 0 : r.id) ?? (t == null ? void 0 : t.id);
915
+ }, _n = (e = [], t, n) => {
916
+ const s = v(t?.conceptIdentity) || "", r = H(s, e);
917
+ return n ? K(r, n) : r?.name ?? r?.id ?? t?.id;
946
918
  };
947
- function De(e) {
948
- var t, n, s;
949
- return (s = (n = (t = e == null ? void 0 : e.dataStructures) == null ? void 0 : t[0]) == null ? void 0 : n.dataStructureComponents) == null ? void 0 : s.dimensionList;
919
+ function le(e) {
920
+ return e?.dataStructures?.[0]?.dataStructureComponents?.dimensionList;
950
921
  }
951
- function Wn(e) {
952
- var t, n, s, r;
953
- return ((r = (s = (n = (t = e == null ? void 0 : e.data) == null ? void 0 : t.structures) == null ? void 0 : n[0]) == null ? void 0 : s.dimensions) == null ? void 0 : r.series) || [];
922
+ function On(e) {
923
+ return e?.data?.structures?.[0]?.dimensions?.series || [];
954
924
  }
955
- function kn(e) {
956
- var t, n, s, r, o;
957
- return ((o = (r = (s = (n = (t = e == null ? void 0 : e.data) == null ? void 0 : t.structures) == null ? void 0 : n[0]) == null ? void 0 : s.dimensions) == null ? void 0 : r.observation) == null ? void 0 : o[0].values.map((i) => i.value).filter((i) => i != null)) || [];
925
+ function Ln(e) {
926
+ return e?.data?.structures?.[0]?.dimensions?.observation?.[0].values.map((t) => t.value).filter((t) => t != null) || [];
958
927
  }
959
- function qn(e) {
928
+ function Mn(e) {
960
929
  return e.find(
961
- (t) => t.type === q.TIME_DIMENSION
930
+ (t) => t.type === M.TIME_DIMENSION
962
931
  );
963
932
  }
964
- const Mn = (e) => {
965
- var i, c, a, u, l, f;
966
- const t = /* @__PURE__ */ new Map(), n = (i = e == null ? void 0 : e.dataStructures) == null ? void 0 : i[0], s = (c = e == null ? void 0 : e.metadataStructures) == null ? void 0 : c[0], r = (e == null ? void 0 : e.conceptSchemes) || [], o = (e == null ? void 0 : e.codelists) || [];
933
+ const Cn = (e) => {
934
+ const t = /* @__PURE__ */ new Map(), n = e?.dataStructures?.[0], s = e?.metadataStructures?.[0], r = e?.conceptSchemes || [], o = e?.codelists || [];
967
935
  return e && [
968
- ...((a = De(e)) == null ? void 0 : a.dimensions) || [],
969
- ...((u = De(e)) == null ? void 0 : u.timeDimensions) || [],
970
- ...ln(s, n),
971
- ...((f = (l = n == null ? void 0 : n.dataStructureComponents) == null ? void 0 : l.attributeList) == null ? void 0 : f.attributes) || []
936
+ ...le(e)?.dimensions || [],
937
+ ...le(e)?.timeDimensions || [],
938
+ ...sn(s, n),
939
+ ...n?.dataStructureComponents?.attributeList?.attributes || []
972
940
  ].forEach(
973
- (d) => {
974
- var A, y;
975
- const g = te(
976
- d == null ? void 0 : d.conceptIdentity,
941
+ (c) => {
942
+ const a = H(
943
+ c?.conceptIdentity,
977
944
  r
978
- ), E = ((A = d == null ? void 0 : d.localRepresentation) == null ? void 0 : A.enumeration) || ((y = g == null ? void 0 : g.coreRepresentation) == null ? void 0 : y.enumeration), D = ee(
979
- E,
945
+ ), u = c?.localRepresentation?.enumeration || a?.coreRepresentation?.enumeration, d = j(
946
+ u,
980
947
  o
981
948
  );
982
- d != null && d.id && (E ? t.set(d == null ? void 0 : d.id, {
983
- ...D,
984
- name: g == null ? void 0 : g.name,
985
- names: g == null ? void 0 : g.names
986
- }) : t.set(d == null ? void 0 : d.id, {
987
- id: d == null ? void 0 : d.id,
988
- name: g == null ? void 0 : g.name,
989
- names: g == null ? void 0 : g.names
949
+ c?.id && (u ? t.set(c?.id, {
950
+ ...d,
951
+ name: a?.name,
952
+ names: a?.names
953
+ }) : t.set(c?.id, {
954
+ id: c?.id,
955
+ name: a?.name,
956
+ names: a?.names
990
957
  }));
991
958
  }
992
959
  ), t;
993
- }, Qn = (e) => {
994
- var t;
995
- return ((t = e == null ? void 0 : e.find(
996
- (n) => n.id === X.SERIES_COUNT
997
- )) == null ? void 0 : t.title) || "";
998
- }, dn = "/api/download", Bn = (e, t, n, s, r, o, i) => {
960
+ }, Un = (e) => e?.find(
961
+ (t) => t.id === G.SERIES_COUNT
962
+ )?.title || "", rn = "/api/download", xn = (e, t, n, s, r, o, i) => {
999
963
  const c = new URLSearchParams({
1000
964
  urn: e,
1001
965
  format: t,
@@ -1005,72 +969,70 @@ const Mn = (e) => {
1005
969
  attribute: s,
1006
970
  language: n,
1007
971
  isMetadata: i ? "true" : "none"
1008
- }).toString(), a = `${dn}?${c}`;
972
+ }).toString(), a = `${rn}?${c}`;
1009
973
  window.open(a, "_blank");
1010
- }, Vn = (e, t) => {
1011
- var s, r;
974
+ }, Yn = (e, t) => {
1012
975
  const n = [];
1013
- for (const o of e) {
1014
- if (o.type !== q.DIMENSION)
976
+ for (const s of e) {
977
+ if (s.type !== M.DIMENSION)
1015
978
  continue;
1016
- const i = t.find((c) => c.componentCode === o.id);
1017
- i != null && ((s = i.values) == null ? void 0 : s.length) > 0 ? n.push((r = i.values) == null ? void 0 : r.join(ke)) : n.push("*");
979
+ const r = t.find((o) => o.componentCode === s.id);
980
+ r != null && r.values?.length > 0 ? n.push(r.values?.join(Le)) : n.push("*");
1018
981
  }
1019
982
  return n.join(".");
1020
- }, fn = (e, t) => {
983
+ }, on = (e, t) => {
1021
984
  if (!e || !e.startPeriod && !e.endPeriod)
1022
985
  return null;
1023
986
  const n = [], { startPeriod: s, endPeriod: r } = e;
1024
987
  if (s && n.push(
1025
- `${w.GREATER_OR_EQUAL}${se}${s.toISOString().split("T")[0]}`
988
+ `${h.GREATER_OR_EQUAL}${J}${s.toISOString().split("T")[0]}`
1026
989
  ), r && n.push(
1027
- `${w.LESS_OR_EQUAL}${se}${r.toISOString().split("T")[0]}`
990
+ `${h.LESS_OR_EQUAL}${J}${r.toISOString().split("T")[0]}`
1028
991
  ), n.length === 0)
1029
992
  return null;
1030
993
  const o = t;
1031
994
  return n.map(
1032
- (i) => `${encodeURIComponent(`c[${o}]`)}${We}${encodeURIComponent(i)}`
1033
- ).join(Te);
1034
- }, Fn = (e, t) => {
1035
- const n = gn(e, t) || null;
1036
- return n ? fn(n, t == null ? void 0 : t.id) : null;
1037
- }, gn = (e, t) => {
1038
- var a, u;
1039
- const n = t.id, s = (a = e == null ? void 0 : e.filters) == null ? void 0 : a.find(
1040
- (l) => l.componentCode === n
995
+ (i) => `${encodeURIComponent(`c[${o}]`)}${Oe}${encodeURIComponent(i)}`
996
+ ).join(ge);
997
+ }, Wn = (e, t) => {
998
+ const n = an(e, t) || null;
999
+ return n ? on(n, t?.id) : null;
1000
+ }, an = (e, t) => {
1001
+ const n = t.id, s = e?.filters?.find(
1002
+ (a) => a.componentCode === n
1041
1003
  );
1042
1004
  if (!s || !s.values)
1043
1005
  return null;
1044
- const r = (u = s.values) == null ? void 0 : u.filter((l) => !!l);
1006
+ const r = s.values?.filter((a) => !!a);
1045
1007
  if (!r.length)
1046
1008
  return null;
1047
1009
  const o = s.operator;
1048
- if (o === w.LESS_OR_EQUAL || o === w.LESS)
1049
- return { startPeriod: null, endPeriod: v(r[0]) };
1050
- if (o === w.GREATER_OR_EQUAL || o === w.GREATER)
1051
- return { startPeriod: v(r[0]), endPeriod: null };
1052
- const i = v(r[0]), c = v(r[1]);
1010
+ if (o === h.LESS_OR_EQUAL || o === h.LESS)
1011
+ return { startPeriod: null, endPeriod: y(r[0]) };
1012
+ if (o === h.GREATER_OR_EQUAL || o === h.GREATER)
1013
+ return { startPeriod: y(r[0]), endPeriod: null };
1014
+ const i = y(r[0]), c = y(r[1]);
1053
1015
  return { startPeriod: i, endPeriod: c };
1054
- }, Ie = (e, t, n) => {
1055
- const s = R(t, !0), r = R(n), o = R(e, !0), i = R(e), c = s.getTime() > o.getTime() ? s : o, a = r.getTime() < i.getTime() ? r : i;
1016
+ }, Te = (e, t, n) => {
1017
+ const s = g(t, !0), r = g(n), o = g(e, !0), i = g(e), c = s.getTime() > o.getTime() ? s : o, a = r.getTime() < i.getTime() ? r : i;
1056
1018
  return {
1057
1019
  start: c,
1058
1020
  end: a
1059
1021
  };
1060
- }, hn = (e, t, n, s = "W") => {
1061
- const r = +e, { start: o, end: i } = Ie(e, t, n);
1022
+ }, cn = (e, t, n, s = "W") => {
1023
+ const r = +e, { start: o, end: i } = Te(e, t, n);
1062
1024
  if (o.getTime() > i.getTime())
1063
1025
  return [];
1064
- const c = _(o, s), a = c.weekYear === r ? c.weekNumber : c.weekYear < r ? 1 : ae(r, s), u = _(i, s), l = u.weekYear === r ? u.weekNumber : u.weekYear > r ? ae(r, s) : 1, f = [];
1065
- if (a < l)
1066
- for (let h = a; h <= l; h++)
1067
- f.push(we(r, h, s));
1068
- return f;
1069
- }, En = (e) => {
1026
+ const c = R(o, s), a = c.weekYear === r ? c.weekNumber : c.weekYear < r ? 1 : ne(r, s), u = R(i, s), d = u.weekYear === r ? u.weekNumber : u.weekYear > r ? ne(r, s) : 1, l = [];
1027
+ if (a < d)
1028
+ for (let m = a; m <= d; m++)
1029
+ l.push(Ee(r, m, s));
1030
+ return l;
1031
+ }, un = (e) => {
1070
1032
  const t = new Date(e);
1071
1033
  return t.setMinutes(t.getMinutes() - t.getTimezoneOffset()), t.toISOString().slice(0, 10);
1072
- }, An = (e, t, n) => {
1073
- const { start: s, end: r } = Ie(e, t, n);
1034
+ }, dn = (e, t, n) => {
1035
+ const { start: s, end: r } = Te(e, t, n);
1074
1036
  if (s.getTime() > r.getTime())
1075
1037
  return [];
1076
1038
  const o = [], i = new Date(
@@ -1079,159 +1041,157 @@ const Mn = (e) => {
1079
1041
  s.getDate()
1080
1042
  ), c = new Date(r.getFullYear(), r.getMonth(), r.getDate());
1081
1043
  for (; i.getTime() < c.getTime(); ) {
1082
- const a = En(i);
1044
+ const a = un(i);
1083
1045
  o.push(a), i.setDate(i.getDate() + 1);
1084
1046
  }
1085
1047
  return o;
1086
- }, Dn = (e) => ({
1087
- isDailyExist: !!(e != null && e.some(({ memberValue: t }) => t === "D")),
1088
- isWeeklyExist: !!(e != null && e.some(({ memberValue: t }) => t === "W")),
1089
- isMonthlyExist: !!(e != null && e.some(({ memberValue: t }) => t === "M")),
1090
- isQuarterlyExist: !!(e != null && e.some(({ memberValue: t }) => t === "Q")),
1091
- isSemiAnnualExist: !!(e != null && e.some(({ memberValue: t }) => t === "S")),
1092
- isYearlyExist: !!(e != null && e.some(
1048
+ }, ln = (e) => ({
1049
+ isDailyExist: !!e?.some(({ memberValue: t }) => t === "D"),
1050
+ isWeeklyExist: !!e?.some(({ memberValue: t }) => t === "W"),
1051
+ isMonthlyExist: !!e?.some(({ memberValue: t }) => t === "M"),
1052
+ isQuarterlyExist: !!e?.some(({ memberValue: t }) => t === "Q"),
1053
+ isSemiAnnualExist: !!e?.some(({ memberValue: t }) => t === "S"),
1054
+ isYearlyExist: !!e?.some(
1093
1055
  ({ memberValue: t }) => t === "A" || t === "Y"
1094
- ))
1095
- }), yn = (e, t, n, s) => {
1096
- var i, c;
1097
- const r = s === 0 ? ((i = R(t.toString(), !0)) == null ? void 0 : i.getMonth()) + 1 : void 0, o = s === e.length - 1 ? ((c = R(n.toString())) == null ? void 0 : c.getMonth()) + 1 || 1 : void 0;
1056
+ )
1057
+ }), mn = (e, t, n, s) => {
1058
+ const r = s === 0 ? g(t.toString(), !0)?.getMonth() + 1 : void 0, o = s === e.length - 1 ? g(n.toString())?.getMonth() + 1 || 1 : void 0;
1098
1059
  return { startMonth: r, endMonth: o };
1099
- }, Sn = ["FREQUENCY", "FREQ"], Gn = (e, t) => {
1100
- var a, u, l, f, h, d, g;
1101
- const n = (h = (f = (l = (u = (a = e == null ? void 0 : e[0]) == null ? void 0 : a.cubeRegions) == null ? void 0 : u[0]) == null ? void 0 : l.memberSelection) == null ? void 0 : f.find(
1102
- (E) => Sn.includes(E.componentId)
1103
- )) == null ? void 0 : h.selectionValues, s = Dn(n || []), r = ((d = t == null ? void 0 : t.startPeriod) == null ? void 0 : d.getTime()) || 1, o = ((g = t == null ? void 0 : t.endPeriod) == null ? void 0 : g.getTime()) || 1, i = Yt(o, r), c = [];
1104
- return i.forEach((E, D) => {
1105
- const A = [], { startMonth: y, endMonth: S } = yn(
1060
+ }, fn = ["FREQUENCY", "FREQ"], kn = (e, t) => {
1061
+ const n = e?.[0]?.cubeRegions?.[0]?.memberSelection?.find(
1062
+ (a) => fn.includes(a.componentId)
1063
+ )?.selectionValues, s = ln(n || []), r = t?.startPeriod?.getTime() || 1, o = t?.endPeriod?.getTime() || 1, i = bt(o, r), c = [];
1064
+ return i.forEach((a, u) => {
1065
+ const d = [], { startMonth: l, endMonth: m } = mn(
1106
1066
  i,
1107
1067
  new Date(r),
1108
1068
  new Date(o),
1109
- D
1069
+ u
1110
1070
  ), {
1111
- isDailyExist: O,
1112
- isWeeklyExist: P,
1113
- isMonthlyExist: b,
1114
- isQuarterlyExist: L,
1115
- isSemiAnnualExist: U,
1116
- isYearlyExist: T
1071
+ isDailyExist: f,
1072
+ isWeeklyExist: E,
1073
+ isMonthlyExist: w,
1074
+ isQuarterlyExist: I,
1075
+ isSemiAnnualExist: N,
1076
+ isYearlyExist: $
1117
1077
  } = s;
1118
- T && A.push(E.toString()), U && A.push(...bt(E, y, S)), L && A.push(
1119
- ...Pt(E, y, S, !1)
1120
- ), b && A.push(...xt(E, y, S)), P && A.push(
1121
- ...hn(E, r.toString(), o.toString())
1122
- ), O && A.push(
1123
- ...An(E, r.toString(), o.toString())
1124
- ), c.push(...A);
1078
+ $ && d.push(a.toString()), N && d.push(...It(a, l, m)), I && d.push(
1079
+ ...wt(a, l, m, !1)
1080
+ ), w && d.push(...Pt(a, l, m)), E && d.push(
1081
+ ...cn(a, r.toString(), o.toString())
1082
+ ), f && d.push(
1083
+ ...dn(a, r.toString(), o.toString())
1084
+ ), c.push(...d);
1125
1085
  }), c;
1126
1086
  };
1127
1087
  export {
1128
- X as Annotations,
1129
- He as AssignmentStatus,
1130
- Rn as AvailabilityApi,
1131
- Ce as DATASET_DATA_URL,
1088
+ G as Annotations,
1089
+ Ve as AssignmentStatus,
1090
+ hn as AvailabilityApi,
1091
+ _e as DATASET_DATA_URL,
1132
1092
  pn as DatasetApi,
1133
- q as DimensionType,
1134
- Ue as DownloadType,
1135
- vn as FREQUENCY_DIMENSION_ID,
1136
- Sn as FREQUENCY_DIM_ID,
1137
- Le as FileColumnsAttribute,
1138
- qe as GET_v3_FILTER_ALL,
1139
- wn as GET_v3_FILTER_AND,
1140
- ke as GET_v3_FILTER_OR,
1141
- Ze as OBSERVATION_KEY,
1142
- ze as OccurrenceType,
1143
- Mt as Periods,
1144
- qt as RepresentationTextType,
1145
- kt as SDMX_DATA_QUERY_PARAMS,
1146
- W as SINGLE_WILDCARD_SYMBOL,
1147
- mn as SdmxApiClient,
1148
- ye as SdmxAvailabilityMode,
1149
- N as SdmxDataFormat,
1150
- Se as SdmxDetails,
1151
- k as SdmxReferences,
1152
- w as SeriesFilterOperator,
1153
- Ft as TIME_PERIOD,
1154
- Bt as TIME_PERIOD_END,
1155
- Vt as TIME_PERIOD_START,
1156
- dt as dailyPattern,
1157
- st as decodeDimensionId,
1158
- xn as findCodelistByDimension,
1159
- re as generateDatasetDataRequest,
1160
- Tn as generateShortUrn,
1161
- Gn as getAdditionalColumns,
1162
- bn as getAnnotationPeriod,
1163
- ee as getArtifactByUrnWithWildCard,
1164
- Nn as getAttachedDimensionsSeriesByDimension,
1165
- Je as getAttachedDimensionsSeriesByTsId,
1166
- Re as getAttachedDimensionsSeriesKey,
1167
- Xe as getAttributeValueFromDataQueryResponse,
1168
- Yn as getAvailableCodes,
1169
- Ln as getAvailableCodesFromConstrains,
1170
- Pe as getChildParsedUrn,
1171
- te as getConcept,
1172
- Ae as getConceptByUrn,
1173
- an as getConceptWithScheme,
1174
- ln as getConvertedMetaAttributes,
1175
- ht as getDailyRegExp,
1176
- An as getDaysColumns,
1177
- Cn as getDimensionTitle,
1178
- De as getDimensions,
1179
- Qt as getFilteredItemsWithParents,
1180
- Un as getFiltersDtoFromDataQuery,
1181
- _ as getISOWeek,
1182
- I as getKeyFromUrn,
1183
- Pn as getLastUpdatedTime,
1184
- ae as getLastWeekNumberOfYear,
1185
- Z as getLocalizedName,
1186
- xt as getMonthlyData,
1187
- _n as getMonthlyDataByQuarter,
1188
- V as getMonthlyRegExp,
1189
- me as getParsedEndPeriodDate,
1190
- $n as getParsedResponse,
1093
+ M as DimensionType,
1094
+ $e as DownloadType,
1095
+ An as FREQUENCY_DIMENSION_ID,
1096
+ fn as FREQUENCY_DIM_ID,
1097
+ Ne as FileColumnsAttribute,
1098
+ Me as GET_v3_FILTER_ALL,
1099
+ En as GET_v3_FILTER_AND,
1100
+ Le as GET_v3_FILTER_OR,
1101
+ Ke as OBSERVATION_KEY,
1102
+ Be as OccurrenceType,
1103
+ Ct as Periods,
1104
+ Mt as RepresentationTextType,
1105
+ Lt as SDMX_DATA_QUERY_PARAMS,
1106
+ O as SINGLE_WILDCARD_SYMBOL,
1107
+ Dn as SdmxApiClient,
1108
+ me as SdmxAvailabilityMode,
1109
+ S as SdmxDataFormat,
1110
+ fe as SdmxDetails,
1111
+ L as SdmxReferences,
1112
+ h as SeriesFilterOperator,
1113
+ Wt as TIME_PERIOD,
1114
+ xt as TIME_PERIOD_END,
1115
+ Yt as TIME_PERIOD_START,
1116
+ ot as dailyPattern,
1117
+ Je as decodeDimensionId,
1118
+ Pn as findCodelistByDimension,
1119
+ X as generateDatasetDataRequest,
1120
+ gn as generateShortUrn,
1121
+ kn as getAdditionalColumns,
1122
+ In as getAnnotationPeriod,
1123
+ j as getArtifactByUrnWithWildCard,
1124
+ yn as getAttachedDimensionsSeriesByDimension,
1125
+ Fe as getAttachedDimensionsSeriesByTsId,
1126
+ he as getAttachedDimensionsSeriesKey,
1127
+ Ge as getAttributeValueFromDataQueryResponse,
1128
+ bn as getAvailableCodes,
1129
+ Nn as getAvailableCodesFromConstrains,
1130
+ we as getChildParsedUrn,
1131
+ H as getConcept,
1132
+ de as getConceptByUrn,
1133
+ tn as getConceptWithScheme,
1134
+ sn as getConvertedMetaAttributes,
1135
+ ct as getDailyRegExp,
1136
+ dn as getDaysColumns,
1137
+ _n as getDimensionTitle,
1138
+ le as getDimensions,
1139
+ Ut as getFilteredItemsWithParents,
1140
+ $n as getFiltersDtoFromDataQuery,
1141
+ R as getISOWeek,
1142
+ v as getKeyFromUrn,
1143
+ wn as getLastUpdatedTime,
1144
+ ne as getLastWeekNumberOfYear,
1145
+ K as getLocalizedName,
1146
+ Pt as getMonthlyData,
1147
+ vn as getMonthlyDataByQuarter,
1148
+ Y as getMonthlyRegExp,
1149
+ De as getParsedEndPeriodDate,
1150
+ Sn as getParsedResponse,
1191
1151
  pe as getParsedStartPeriodDate,
1192
- R as getPeriodDate,
1193
- Dn as getPeriods,
1194
- In as getQuarterByMonth,
1195
- G as getQuarterlyRegExp,
1196
- Pt as getQuartersData,
1197
- fn as getQueryTimePeriodFilters,
1198
- xe as getRequestAcceptHeader,
1199
- sn as getResolvedVersionBySingleWildcard,
1200
- bt as getSemiAnnualData,
1201
- gt as getSemiAnnuallyRegExp,
1202
- C as getSeriesAttributes,
1203
- et as getSeriesName,
1204
- Mn as getStructureComponentsMap,
1205
- Wn as getStructureDimensions,
1206
- qn as getTimeDimension,
1207
- kn as getTimePeriods,
1208
- Fn as getTimeQueryFilter,
1209
- gn as getTimeRangeFromAttachment,
1210
- Qn as getTimeSeriesCount,
1211
- Vn as getTimeSeriesFilterKey,
1212
- nt as getTimeSeriesId,
1213
- we as getWeekCode,
1214
- St as getWeeklyPeriodEndDate,
1215
- yt as getWeeklyPeriodStartDate,
1216
- At as getWeeklyRegExp,
1217
- hn as getWeeksColumns,
1218
- on as getWildCardRegexp,
1219
- Ie as getYearPeriod,
1220
- M as getYearlyRegExp,
1221
- Yt as getYears,
1222
- Et as isDaily,
1223
- F as isMonthly,
1224
- K as isQuarterly,
1225
- B as isSemiAnnually,
1226
- j as isWeekly,
1227
- cn as isWildCardVersionCorrect,
1228
- Q as isYearly,
1229
- ft as monthlyPattern,
1230
- Bn as openDownloadWindow,
1231
- ct as quarterPattern,
1232
- ut as semiAnnuallyPattern,
1233
- On as sortPeriods,
1234
- p as splitUrn,
1235
- at as weeklyPattern,
1236
- lt as yearlyPattern
1152
+ g as getPeriodDate,
1153
+ ln as getPeriods,
1154
+ Tn as getQuarterByMonth,
1155
+ k as getQuarterlyRegExp,
1156
+ wt as getQuartersData,
1157
+ on as getQueryTimePeriodFilters,
1158
+ Pe as getRequestAcceptHeader,
1159
+ Jt as getResolvedVersionBySingleWildcard,
1160
+ It as getSemiAnnualData,
1161
+ at as getSemiAnnuallyRegExp,
1162
+ _ as getSeriesAttributes,
1163
+ je as getSeriesName,
1164
+ Cn as getStructureComponentsMap,
1165
+ On as getStructureDimensions,
1166
+ Mn as getTimeDimension,
1167
+ Ln as getTimePeriods,
1168
+ Wn as getTimeQueryFilter,
1169
+ an as getTimeRangeFromAttachment,
1170
+ Un as getTimeSeriesCount,
1171
+ Yn as getTimeSeriesFilterKey,
1172
+ ze as getTimeSeriesId,
1173
+ Ee as getWeekCode,
1174
+ ft as getWeeklyPeriodEndDate,
1175
+ mt as getWeeklyPeriodStartDate,
1176
+ dt as getWeeklyRegExp,
1177
+ cn as getWeeksColumns,
1178
+ Zt as getWildCardRegexp,
1179
+ Te as getYearPeriod,
1180
+ C as getYearlyRegExp,
1181
+ bt as getYears,
1182
+ ut as isDaily,
1183
+ W as isMonthly,
1184
+ q as isQuarterly,
1185
+ x as isSemiAnnually,
1186
+ Q as isWeekly,
1187
+ en as isWildCardVersionCorrect,
1188
+ U as isYearly,
1189
+ it as monthlyPattern,
1190
+ xn as openDownloadWindow,
1191
+ tt as quarterPattern,
1192
+ st as semiAnnuallyPattern,
1193
+ Rn as sortPeriods,
1194
+ D as splitUrn,
1195
+ nt as weeklyPattern,
1196
+ rt as yearlyPattern
1237
1197
  };