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

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