@epam/statgpt-sdmx-toolkit 0.2.0-rc.1 → 0.2.0-rc.10

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