bmlt-query-client 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/app.js ADDED
@@ -0,0 +1,1738 @@
1
+ var Ie = Object.defineProperty;
2
+ var ue = (r) => {
3
+ throw TypeError(r);
4
+ };
5
+ var Ce = (r, e, t) => e in r ? Ie(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
6
+ var ce = (r, e, t) => Ce(r, typeof e != "symbol" ? e + "" : e, t), te = (r, e, t) => e.has(r) || ue("Cannot " + t);
7
+ var l = (r, e, t) => (te(r, e, "read from private field"), t ? t.call(r) : e.get(r)), T = (r, e, t) => e.has(r) ? ue("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(r) : e.set(r, t), v = (r, e, t, i) => (te(r, e, "write to private field"), i ? i.call(r, t) : e.set(r, t), t), S = (r, e, t) => (te(r, e, "access private method"), t);
8
+ var H = (r, e, t, i) => ({
9
+ set _(n) {
10
+ v(r, e, n, t);
11
+ },
12
+ get _() {
13
+ return l(r, e, i);
14
+ }
15
+ });
16
+ function ve(r) {
17
+ return r && r.__esModule && Object.prototype.hasOwnProperty.call(r, "default") ? r.default : r;
18
+ }
19
+ var re = {}, ie, he;
20
+ function Pe() {
21
+ if (he) return ie;
22
+ he = 1;
23
+ function r(e, t) {
24
+ typeof t == "boolean" && (t = { forever: t }), this._originalTimeouts = JSON.parse(JSON.stringify(e)), this._timeouts = e, this._options = t || {}, this._maxRetryTime = t && t.maxRetryTime || 1 / 0, this._fn = null, this._errors = [], this._attempts = 1, this._operationTimeout = null, this._operationTimeoutCb = null, this._timeout = null, this._operationStart = null, this._timer = null, this._options.forever && (this._cachedTimeouts = this._timeouts.slice(0));
25
+ }
26
+ return ie = r, r.prototype.reset = function() {
27
+ this._attempts = 1, this._timeouts = this._originalTimeouts.slice(0);
28
+ }, r.prototype.stop = function() {
29
+ this._timeout && clearTimeout(this._timeout), this._timer && clearTimeout(this._timer), this._timeouts = [], this._cachedTimeouts = null;
30
+ }, r.prototype.retry = function(e) {
31
+ if (this._timeout && clearTimeout(this._timeout), !e)
32
+ return !1;
33
+ var t = (/* @__PURE__ */ new Date()).getTime();
34
+ if (e && t - this._operationStart >= this._maxRetryTime)
35
+ return this._errors.push(e), this._errors.unshift(new Error("RetryOperation timeout occurred")), !1;
36
+ this._errors.push(e);
37
+ var i = this._timeouts.shift();
38
+ if (i === void 0)
39
+ if (this._cachedTimeouts)
40
+ this._errors.splice(0, this._errors.length - 1), i = this._cachedTimeouts.slice(-1);
41
+ else
42
+ return !1;
43
+ var n = this;
44
+ return this._timer = setTimeout(function() {
45
+ n._attempts++, n._operationTimeoutCb && (n._timeout = setTimeout(function() {
46
+ n._operationTimeoutCb(n._attempts);
47
+ }, n._operationTimeout), n._options.unref && n._timeout.unref()), n._fn(n._attempts);
48
+ }, i), this._options.unref && this._timer.unref(), !0;
49
+ }, r.prototype.attempt = function(e, t) {
50
+ this._fn = e, t && (t.timeout && (this._operationTimeout = t.timeout), t.cb && (this._operationTimeoutCb = t.cb));
51
+ var i = this;
52
+ this._operationTimeoutCb && (this._timeout = setTimeout(function() {
53
+ i._operationTimeoutCb();
54
+ }, i._operationTimeout)), this._operationStart = (/* @__PURE__ */ new Date()).getTime(), this._fn(this._attempts);
55
+ }, r.prototype.try = function(e) {
56
+ console.log("Using RetryOperation.try() is deprecated"), this.attempt(e);
57
+ }, r.prototype.start = function(e) {
58
+ console.log("Using RetryOperation.start() is deprecated"), this.attempt(e);
59
+ }, r.prototype.start = r.prototype.try, r.prototype.errors = function() {
60
+ return this._errors;
61
+ }, r.prototype.attempts = function() {
62
+ return this._attempts;
63
+ }, r.prototype.mainError = function() {
64
+ if (this._errors.length === 0)
65
+ return null;
66
+ for (var e = {}, t = null, i = 0, n = 0; n < this._errors.length; n++) {
67
+ var a = this._errors[n], s = a.message, o = (e[s] || 0) + 1;
68
+ e[s] = o, o >= i && (t = a, i = o);
69
+ }
70
+ return t;
71
+ }, ie;
72
+ }
73
+ var le;
74
+ function Ge() {
75
+ return le || (le = 1, (function(r) {
76
+ var e = Pe();
77
+ r.operation = function(t) {
78
+ var i = r.timeouts(t);
79
+ return new e(i, {
80
+ forever: t && (t.forever || t.retries === 1 / 0),
81
+ unref: t && t.unref,
82
+ maxRetryTime: t && t.maxRetryTime
83
+ });
84
+ }, r.timeouts = function(t) {
85
+ if (t instanceof Array)
86
+ return [].concat(t);
87
+ var i = {
88
+ retries: 10,
89
+ factor: 2,
90
+ minTimeout: 1 * 1e3,
91
+ maxTimeout: 1 / 0,
92
+ randomize: !1
93
+ };
94
+ for (var n in t)
95
+ i[n] = t[n];
96
+ if (i.minTimeout > i.maxTimeout)
97
+ throw new Error("minTimeout is greater than maxTimeout");
98
+ for (var a = [], s = 0; s < i.retries; s++)
99
+ a.push(this.createTimeout(s, i));
100
+ return t && t.forever && !a.length && a.push(this.createTimeout(s, i)), a.sort(function(o, u) {
101
+ return o - u;
102
+ }), a;
103
+ }, r.createTimeout = function(t, i) {
104
+ var n = i.randomize ? Math.random() + 1 : 1, a = Math.round(n * Math.max(i.minTimeout, 1) * Math.pow(i.factor, t));
105
+ return a = Math.min(a, i.maxTimeout), a;
106
+ }, r.wrap = function(t, i, n) {
107
+ if (i instanceof Array && (n = i, i = null), !n) {
108
+ n = [];
109
+ for (var a in t)
110
+ typeof t[a] == "function" && n.push(a);
111
+ }
112
+ for (var s = 0; s < n.length; s++) {
113
+ var o = n[s], u = t[o];
114
+ t[o] = function(h) {
115
+ var f = r.operation(i), p = Array.prototype.slice.call(arguments, 1), E = p.pop();
116
+ p.push(function(g) {
117
+ f.retry(g) || (g && (arguments[0] = f.mainError()), E.apply(this, arguments));
118
+ }), f.attempt(function() {
119
+ h.apply(t, p);
120
+ });
121
+ }.bind(t, u), t[o].options = i;
122
+ }
123
+ };
124
+ })(re)), re;
125
+ }
126
+ var ne, fe;
127
+ function Le() {
128
+ return fe || (fe = 1, ne = Ge()), ne;
129
+ }
130
+ var xe = Le();
131
+ const De = /* @__PURE__ */ ve(xe), Ue = Object.prototype.toString, Fe = (r) => Ue.call(r) === "[object Error]", ke = /* @__PURE__ */ new Set([
132
+ "network error",
133
+ // Chrome
134
+ "Failed to fetch",
135
+ // Chrome
136
+ "NetworkError when attempting to fetch resource.",
137
+ // Firefox
138
+ "The Internet connection appears to be offline.",
139
+ // Safari 16
140
+ "Load failed",
141
+ // Safari 17+
142
+ "Network request failed",
143
+ // `cross-fetch`
144
+ "fetch failed",
145
+ // Undici (Node.js)
146
+ "terminated"
147
+ // Undici (Node.js)
148
+ ]);
149
+ function $e(r) {
150
+ return r && Fe(r) && r.name === "TypeError" && typeof r.message == "string" ? r.message === "Load failed" ? r.stack === void 0 : ke.has(r.message) : !1;
151
+ }
152
+ let Me = class extends Error {
153
+ constructor(e) {
154
+ super(), e instanceof Error ? (this.originalError = e, { message: e } = e) : (this.originalError = new Error(e), this.originalError.stack = this.stack), this.name = "AbortError", this.message = e;
155
+ }
156
+ };
157
+ const de = (r, e, t) => {
158
+ const i = t.retries - (e - 1);
159
+ return r.attemptNumber = e, r.retriesLeft = i, r;
160
+ };
161
+ async function me(r, e) {
162
+ return new Promise((t, i) => {
163
+ e = { ...e }, e.onFailedAttempt ?? (e.onFailedAttempt = () => {
164
+ }), e.shouldRetry ?? (e.shouldRetry = () => !0), e.retries ?? (e.retries = 10);
165
+ const n = De.operation(e), a = () => {
166
+ n.stop(), i(e.signal?.reason);
167
+ };
168
+ e.signal && !e.signal.aborted && e.signal.addEventListener("abort", a, { once: !0 });
169
+ const s = () => {
170
+ e.signal?.removeEventListener("abort", a), n.stop();
171
+ };
172
+ n.attempt(async (o) => {
173
+ try {
174
+ const u = await r(o);
175
+ s(), t(u);
176
+ } catch (u) {
177
+ try {
178
+ if (!(u instanceof Error))
179
+ throw new TypeError(`Non-error was thrown: "${u}". You should only throw errors.`);
180
+ if (u instanceof Me)
181
+ throw u.originalError;
182
+ if (u instanceof TypeError && !$e(u))
183
+ throw u;
184
+ if (de(u, o, e), await e.shouldRetry(u) || (n.stop(), i(u)), await e.onFailedAttempt(u), !n.retry(u))
185
+ throw n.mainError();
186
+ } catch (c) {
187
+ de(c, o, e), s(), i(c);
188
+ }
189
+ }
190
+ });
191
+ });
192
+ }
193
+ var se = { exports: {} }, Ee;
194
+ function qe() {
195
+ return Ee || (Ee = 1, (function(r) {
196
+ var e = Object.prototype.hasOwnProperty, t = "~";
197
+ function i() {
198
+ }
199
+ Object.create && (i.prototype = /* @__PURE__ */ Object.create(null), new i().__proto__ || (t = !1));
200
+ function n(u, c, h) {
201
+ this.fn = u, this.context = c, this.once = h || !1;
202
+ }
203
+ function a(u, c, h, f, p) {
204
+ if (typeof h != "function")
205
+ throw new TypeError("The listener must be a function");
206
+ var E = new n(h, f || u, p), g = t ? t + c : c;
207
+ return u._events[g] ? u._events[g].fn ? u._events[g] = [u._events[g], E] : u._events[g].push(E) : (u._events[g] = E, u._eventsCount++), u;
208
+ }
209
+ function s(u, c) {
210
+ --u._eventsCount === 0 ? u._events = new i() : delete u._events[c];
211
+ }
212
+ function o() {
213
+ this._events = new i(), this._eventsCount = 0;
214
+ }
215
+ o.prototype.eventNames = function() {
216
+ var c = [], h, f;
217
+ if (this._eventsCount === 0) return c;
218
+ for (f in h = this._events)
219
+ e.call(h, f) && c.push(t ? f.slice(1) : f);
220
+ return Object.getOwnPropertySymbols ? c.concat(Object.getOwnPropertySymbols(h)) : c;
221
+ }, o.prototype.listeners = function(c) {
222
+ var h = t ? t + c : c, f = this._events[h];
223
+ if (!f) return [];
224
+ if (f.fn) return [f.fn];
225
+ for (var p = 0, E = f.length, g = new Array(E); p < E; p++)
226
+ g[p] = f[p].fn;
227
+ return g;
228
+ }, o.prototype.listenerCount = function(c) {
229
+ var h = t ? t + c : c, f = this._events[h];
230
+ return f ? f.fn ? 1 : f.length : 0;
231
+ }, o.prototype.emit = function(c, h, f, p, E, g) {
232
+ var P = t ? t + c : c;
233
+ if (!this._events[P]) return !1;
234
+ var d = this._events[P], x = arguments.length, U, w;
235
+ if (d.fn) {
236
+ switch (d.once && this.removeListener(c, d.fn, void 0, !0), x) {
237
+ case 1:
238
+ return d.fn.call(d.context), !0;
239
+ case 2:
240
+ return d.fn.call(d.context, h), !0;
241
+ case 3:
242
+ return d.fn.call(d.context, h, f), !0;
243
+ case 4:
244
+ return d.fn.call(d.context, h, f, p), !0;
245
+ case 5:
246
+ return d.fn.call(d.context, h, f, p, E), !0;
247
+ case 6:
248
+ return d.fn.call(d.context, h, f, p, E, g), !0;
249
+ }
250
+ for (w = 1, U = new Array(x - 1); w < x; w++)
251
+ U[w - 1] = arguments[w];
252
+ d.fn.apply(d.context, U);
253
+ } else {
254
+ var Oe = d.length, Y;
255
+ for (w = 0; w < Oe; w++)
256
+ switch (d[w].once && this.removeListener(c, d[w].fn, void 0, !0), x) {
257
+ case 1:
258
+ d[w].fn.call(d[w].context);
259
+ break;
260
+ case 2:
261
+ d[w].fn.call(d[w].context, h);
262
+ break;
263
+ case 3:
264
+ d[w].fn.call(d[w].context, h, f);
265
+ break;
266
+ case 4:
267
+ d[w].fn.call(d[w].context, h, f, p);
268
+ break;
269
+ default:
270
+ if (!U) for (Y = 1, U = new Array(x - 1); Y < x; Y++)
271
+ U[Y - 1] = arguments[Y];
272
+ d[w].fn.apply(d[w].context, U);
273
+ }
274
+ }
275
+ return !0;
276
+ }, o.prototype.on = function(c, h, f) {
277
+ return a(this, c, h, f, !1);
278
+ }, o.prototype.once = function(c, h, f) {
279
+ return a(this, c, h, f, !0);
280
+ }, o.prototype.removeListener = function(c, h, f, p) {
281
+ var E = t ? t + c : c;
282
+ if (!this._events[E]) return this;
283
+ if (!h)
284
+ return s(this, E), this;
285
+ var g = this._events[E];
286
+ if (g.fn)
287
+ g.fn === h && (!p || g.once) && (!f || g.context === f) && s(this, E);
288
+ else {
289
+ for (var P = 0, d = [], x = g.length; P < x; P++)
290
+ (g[P].fn !== h || p && !g[P].once || f && g[P].context !== f) && d.push(g[P]);
291
+ d.length ? this._events[E] = d.length === 1 ? d[0] : d : s(this, E);
292
+ }
293
+ return this;
294
+ }, o.prototype.removeAllListeners = function(c) {
295
+ var h;
296
+ return c ? (h = t ? t + c : c, this._events[h] && s(this, h)) : (this._events = new i(), this._eventsCount = 0), this;
297
+ }, o.prototype.off = o.prototype.removeListener, o.prototype.addListener = o.prototype.on, o.prefixed = t, o.EventEmitter = o, r.exports = o;
298
+ })(se)), se.exports;
299
+ }
300
+ var Ve = qe();
301
+ const Ye = /* @__PURE__ */ ve(Ve);
302
+ class we extends Error {
303
+ constructor(e) {
304
+ super(e), this.name = "TimeoutError";
305
+ }
306
+ }
307
+ class He extends Error {
308
+ constructor(e) {
309
+ super(), this.name = "AbortError", this.message = e;
310
+ }
311
+ }
312
+ const pe = (r) => globalThis.DOMException === void 0 ? new He(r) : new DOMException(r), ye = (r) => {
313
+ const e = r.reason === void 0 ? pe("This operation was aborted.") : r.reason;
314
+ return e instanceof Error ? e : pe(e);
315
+ };
316
+ function Je(r, e) {
317
+ const {
318
+ milliseconds: t,
319
+ fallback: i,
320
+ message: n,
321
+ customTimers: a = { setTimeout, clearTimeout }
322
+ } = e;
323
+ let s, o;
324
+ const c = new Promise((h, f) => {
325
+ if (typeof t != "number" || Math.sign(t) !== 1)
326
+ throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${t}\``);
327
+ if (e.signal) {
328
+ const { signal: E } = e;
329
+ E.aborted && f(ye(E)), o = () => {
330
+ f(ye(E));
331
+ }, E.addEventListener("abort", o, { once: !0 });
332
+ }
333
+ if (t === Number.POSITIVE_INFINITY) {
334
+ r.then(h, f);
335
+ return;
336
+ }
337
+ const p = new we();
338
+ s = a.setTimeout.call(void 0, () => {
339
+ if (i) {
340
+ try {
341
+ h(i());
342
+ } catch (E) {
343
+ f(E);
344
+ }
345
+ return;
346
+ }
347
+ typeof r.cancel == "function" && r.cancel(), n === !1 ? h() : n instanceof Error ? f(n) : (p.message = n ?? `Promise timed out after ${t} milliseconds`, f(p));
348
+ }, t), (async () => {
349
+ try {
350
+ h(await r);
351
+ } catch (E) {
352
+ f(E);
353
+ }
354
+ })();
355
+ }).finally(() => {
356
+ c.clear(), o && e.signal && e.signal.removeEventListener("abort", o);
357
+ });
358
+ return c.clear = () => {
359
+ a.clearTimeout.call(void 0, s), s = void 0;
360
+ }, c;
361
+ }
362
+ function ze(r, e, t) {
363
+ let i = 0, n = r.length;
364
+ for (; n > 0; ) {
365
+ const a = Math.trunc(n / 2);
366
+ let s = i + a;
367
+ t(r[s], e) <= 0 ? (i = ++s, n -= a + 1) : n = a;
368
+ }
369
+ return i;
370
+ }
371
+ var A;
372
+ class We {
373
+ constructor() {
374
+ T(this, A, []);
375
+ }
376
+ enqueue(e, t) {
377
+ t = {
378
+ priority: 0,
379
+ ...t
380
+ };
381
+ const i = {
382
+ priority: t.priority,
383
+ id: t.id,
384
+ run: e
385
+ };
386
+ if (this.size === 0 || l(this, A)[this.size - 1].priority >= t.priority) {
387
+ l(this, A).push(i);
388
+ return;
389
+ }
390
+ const n = ze(l(this, A), i, (a, s) => s.priority - a.priority);
391
+ l(this, A).splice(n, 0, i);
392
+ }
393
+ setPriority(e, t) {
394
+ const i = l(this, A).findIndex((a) => a.id === e);
395
+ if (i === -1)
396
+ throw new ReferenceError(`No promise function with the id "${e}" exists in the queue.`);
397
+ const [n] = l(this, A).splice(i, 1);
398
+ this.enqueue(n.run, { priority: t, id: e });
399
+ }
400
+ dequeue() {
401
+ return l(this, A).shift()?.run;
402
+ }
403
+ filter(e) {
404
+ return l(this, A).filter((t) => t.priority === e.priority).map((t) => t.run);
405
+ }
406
+ get size() {
407
+ return l(this, A).length;
408
+ }
409
+ }
410
+ A = new WeakMap();
411
+ var k, $, D, z, M, W, N, q, R, Q, O, V, L, j, ee, m, _e, Te, Se, Re, be, K, oe, ae, X, Ae, Z;
412
+ class Qe extends Ye {
413
+ // TODO: The `throwOnTimeout` option should affect the return types of `add()` and `addAll()`
414
+ constructor(t) {
415
+ super();
416
+ T(this, m);
417
+ T(this, k);
418
+ T(this, $);
419
+ T(this, D, 0);
420
+ T(this, z);
421
+ T(this, M);
422
+ T(this, W, 0);
423
+ T(this, N);
424
+ T(this, q);
425
+ T(this, R);
426
+ T(this, Q);
427
+ T(this, O, 0);
428
+ // The `!` is needed because of https://github.com/microsoft/TypeScript/issues/32194
429
+ T(this, V);
430
+ T(this, L);
431
+ T(this, j);
432
+ // Use to assign a unique identifier to a promise function, if not explicitly specified
433
+ T(this, ee, 1n);
434
+ /**
435
+ Per-operation timeout in milliseconds. Operations fulfill once `timeout` elapses if they haven't already.
436
+
437
+ Applies to each future operation.
438
+ */
439
+ ce(this, "timeout");
440
+ if (t = {
441
+ carryoverConcurrencyCount: !1,
442
+ intervalCap: Number.POSITIVE_INFINITY,
443
+ interval: 0,
444
+ concurrency: Number.POSITIVE_INFINITY,
445
+ autoStart: !0,
446
+ queueClass: We,
447
+ ...t
448
+ }, !(typeof t.intervalCap == "number" && t.intervalCap >= 1))
449
+ throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${t.intervalCap?.toString() ?? ""}\` (${typeof t.intervalCap})`);
450
+ if (t.interval === void 0 || !(Number.isFinite(t.interval) && t.interval >= 0))
451
+ throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${t.interval?.toString() ?? ""}\` (${typeof t.interval})`);
452
+ v(this, k, t.carryoverConcurrencyCount), v(this, $, t.intervalCap === Number.POSITIVE_INFINITY || t.interval === 0), v(this, z, t.intervalCap), v(this, M, t.interval), v(this, R, new t.queueClass()), v(this, Q, t.queueClass), this.concurrency = t.concurrency, this.timeout = t.timeout, v(this, j, t.throwOnTimeout === !0), v(this, L, t.autoStart === !1);
453
+ }
454
+ get concurrency() {
455
+ return l(this, V);
456
+ }
457
+ set concurrency(t) {
458
+ if (!(typeof t == "number" && t >= 1))
459
+ throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${t}\` (${typeof t})`);
460
+ v(this, V, t), S(this, m, X).call(this);
461
+ }
462
+ /**
463
+ Updates the priority of a promise function by its id, affecting its execution order. Requires a defined concurrency limit to take effect.
464
+
465
+ For example, this can be used to prioritize a promise function to run earlier.
466
+
467
+ ```js
468
+ import PQueue from 'p-queue';
469
+
470
+ const queue = new PQueue({concurrency: 1});
471
+
472
+ queue.add(async () => '🦄', {priority: 1});
473
+ queue.add(async () => '🦀', {priority: 0, id: '🦀'});
474
+ queue.add(async () => '🦄', {priority: 1});
475
+ queue.add(async () => '🦄', {priority: 1});
476
+
477
+ queue.setPriority('🦀', 2);
478
+ ```
479
+
480
+ In this case, the promise function with `id: '🦀'` runs second.
481
+
482
+ You can also deprioritize a promise function to delay its execution:
483
+
484
+ ```js
485
+ import PQueue from 'p-queue';
486
+
487
+ const queue = new PQueue({concurrency: 1});
488
+
489
+ queue.add(async () => '🦄', {priority: 1});
490
+ queue.add(async () => '🦀', {priority: 1, id: '🦀'});
491
+ queue.add(async () => '🦄');
492
+ queue.add(async () => '🦄', {priority: 0});
493
+
494
+ queue.setPriority('🦀', -1);
495
+ ```
496
+ Here, the promise function with `id: '🦀'` executes last.
497
+ */
498
+ setPriority(t, i) {
499
+ l(this, R).setPriority(t, i);
500
+ }
501
+ async add(t, i = {}) {
502
+ return i.id ?? (i.id = (H(this, ee)._++).toString()), i = {
503
+ timeout: this.timeout,
504
+ throwOnTimeout: l(this, j),
505
+ ...i
506
+ }, new Promise((n, a) => {
507
+ l(this, R).enqueue(async () => {
508
+ H(this, O)._++, H(this, D)._++;
509
+ try {
510
+ i.signal?.throwIfAborted();
511
+ let s = t({ signal: i.signal });
512
+ i.timeout && (s = Je(Promise.resolve(s), { milliseconds: i.timeout })), i.signal && (s = Promise.race([s, S(this, m, Ae).call(this, i.signal)]));
513
+ const o = await s;
514
+ n(o), this.emit("completed", o);
515
+ } catch (s) {
516
+ if (s instanceof we && !i.throwOnTimeout) {
517
+ n();
518
+ return;
519
+ }
520
+ a(s), this.emit("error", s);
521
+ } finally {
522
+ S(this, m, Se).call(this);
523
+ }
524
+ }, i), this.emit("add"), S(this, m, K).call(this);
525
+ });
526
+ }
527
+ async addAll(t, i) {
528
+ return Promise.all(t.map(async (n) => this.add(n, i)));
529
+ }
530
+ /**
531
+ Start (or resume) executing enqueued tasks within concurrency limit. No need to call this if queue is not paused (via `options.autoStart = false` or by `.pause()` method.)
532
+ */
533
+ start() {
534
+ return l(this, L) ? (v(this, L, !1), S(this, m, X).call(this), this) : this;
535
+ }
536
+ /**
537
+ Put queue execution on hold.
538
+ */
539
+ pause() {
540
+ v(this, L, !0);
541
+ }
542
+ /**
543
+ Clear the queue.
544
+ */
545
+ clear() {
546
+ v(this, R, new (l(this, Q))());
547
+ }
548
+ /**
549
+ Can be called multiple times. Useful if you for example add additional items at a later time.
550
+
551
+ @returns A promise that settles when the queue becomes empty.
552
+ */
553
+ async onEmpty() {
554
+ l(this, R).size !== 0 && await S(this, m, Z).call(this, "empty");
555
+ }
556
+ /**
557
+ @returns A promise that settles when the queue size is less than the given limit: `queue.size < limit`.
558
+
559
+ If you want to avoid having the queue grow beyond a certain size you can `await queue.onSizeLessThan()` before adding a new item.
560
+
561
+ Note that this only limits the number of items waiting to start. There could still be up to `concurrency` jobs already running that this call does not include in its calculation.
562
+ */
563
+ async onSizeLessThan(t) {
564
+ l(this, R).size < t || await S(this, m, Z).call(this, "next", () => l(this, R).size < t);
565
+ }
566
+ /**
567
+ The difference with `.onEmpty` is that `.onIdle` guarantees that all work from the queue has finished. `.onEmpty` merely signals that the queue is empty, but it could mean that some promises haven't completed yet.
568
+
569
+ @returns A promise that settles when the queue becomes empty, and all promises have completed; `queue.size === 0 && queue.pending === 0`.
570
+ */
571
+ async onIdle() {
572
+ l(this, O) === 0 && l(this, R).size === 0 || await S(this, m, Z).call(this, "idle");
573
+ }
574
+ /**
575
+ Size of the queue, the number of queued items waiting to run.
576
+ */
577
+ get size() {
578
+ return l(this, R).size;
579
+ }
580
+ /**
581
+ Size of the queue, filtered by the given options.
582
+
583
+ For example, this can be used to find the number of items remaining in the queue with a specific priority level.
584
+ */
585
+ sizeBy(t) {
586
+ return l(this, R).filter(t).length;
587
+ }
588
+ /**
589
+ Number of running items (no longer in the queue).
590
+ */
591
+ get pending() {
592
+ return l(this, O);
593
+ }
594
+ /**
595
+ Whether the queue is currently paused.
596
+ */
597
+ get isPaused() {
598
+ return l(this, L);
599
+ }
600
+ }
601
+ k = new WeakMap(), $ = new WeakMap(), D = new WeakMap(), z = new WeakMap(), M = new WeakMap(), W = new WeakMap(), N = new WeakMap(), q = new WeakMap(), R = new WeakMap(), Q = new WeakMap(), O = new WeakMap(), V = new WeakMap(), L = new WeakMap(), j = new WeakMap(), ee = new WeakMap(), m = new WeakSet(), _e = function() {
602
+ return l(this, $) || l(this, D) < l(this, z);
603
+ }, Te = function() {
604
+ return l(this, O) < l(this, V);
605
+ }, Se = function() {
606
+ H(this, O)._--, S(this, m, K).call(this), this.emit("next");
607
+ }, Re = function() {
608
+ S(this, m, ae).call(this), S(this, m, oe).call(this), v(this, q, void 0);
609
+ }, be = function() {
610
+ const t = Date.now();
611
+ if (l(this, N) === void 0) {
612
+ const i = l(this, W) - t;
613
+ if (i < 0)
614
+ v(this, D, l(this, k) ? l(this, O) : 0);
615
+ else
616
+ return l(this, q) === void 0 && v(this, q, setTimeout(() => {
617
+ S(this, m, Re).call(this);
618
+ }, i)), !0;
619
+ }
620
+ return !1;
621
+ }, K = function() {
622
+ if (l(this, R).size === 0)
623
+ return l(this, N) && clearInterval(l(this, N)), v(this, N, void 0), this.emit("empty"), l(this, O) === 0 && this.emit("idle"), !1;
624
+ if (!l(this, L)) {
625
+ const t = !l(this, m, be);
626
+ if (l(this, m, _e) && l(this, m, Te)) {
627
+ const i = l(this, R).dequeue();
628
+ return i ? (this.emit("active"), i(), t && S(this, m, oe).call(this), !0) : !1;
629
+ }
630
+ }
631
+ return !1;
632
+ }, oe = function() {
633
+ l(this, $) || l(this, N) !== void 0 || (v(this, N, setInterval(() => {
634
+ S(this, m, ae).call(this);
635
+ }, l(this, M))), v(this, W, Date.now() + l(this, M)));
636
+ }, ae = function() {
637
+ l(this, D) === 0 && l(this, O) === 0 && l(this, N) && (clearInterval(l(this, N)), v(this, N, void 0)), v(this, D, l(this, k) ? l(this, O) : 0), S(this, m, X).call(this);
638
+ }, /**
639
+ Executes all queued functions until it reaches the limit.
640
+ */
641
+ X = function() {
642
+ for (; S(this, m, K).call(this); )
643
+ ;
644
+ }, Ae = async function(t) {
645
+ return new Promise((i, n) => {
646
+ t.addEventListener("abort", () => {
647
+ n(t.reason);
648
+ }, { once: !0 });
649
+ });
650
+ }, Z = async function(t, i) {
651
+ return new Promise((n) => {
652
+ const a = () => {
653
+ i && !i() || (this.off(t, a), n());
654
+ };
655
+ this.on(t, a);
656
+ });
657
+ };
658
+ var Ne = /* @__PURE__ */ ((r) => (r.API_ERROR = "ApiError", r.NETWORK_ERROR = "NetworkError", r.VALIDATION_ERROR = "ValidationError", r.GEOCODING_ERROR = "GeocodingError", r.RATE_LIMIT_ERROR = "RateLimitError", r.TIMEOUT_ERROR = "TimeoutError", r.AUTHENTICATION_ERROR = "AuthenticationError", r.SERVER_ERROR = "ServerError", r.CLIENT_ERROR = "ClientError", r.CONFIGURATION_ERROR = "ConfigurationError", r))(Ne || {});
659
+ class b extends Error {
660
+ constructor(e, t, i = {}) {
661
+ super(t), this.name = "BmltQueryError", this.type = e, this.statusCode = i.statusCode, this.response = i.response, this.originalError = i.originalError, this.context = i.context, Object.setPrototypeOf(this, b.prototype);
662
+ }
663
+ /**
664
+ * Check if error is of a specific type
665
+ */
666
+ isType(e) {
667
+ return this.type === e;
668
+ }
669
+ /**
670
+ * Check if error is retryable
671
+ */
672
+ isRetryable() {
673
+ return [
674
+ "NetworkError",
675
+ "TimeoutError",
676
+ "RateLimitError",
677
+ "ServerError"
678
+ /* SERVER_ERROR */
679
+ ].includes(this.type);
680
+ }
681
+ /**
682
+ * Check if error is a client-side error (4xx)
683
+ */
684
+ isClientError() {
685
+ return this.statusCode !== void 0 && this.statusCode >= 400 && this.statusCode < 500;
686
+ }
687
+ /**
688
+ * Check if error is a server-side error (5xx)
689
+ */
690
+ isServerError() {
691
+ return this.statusCode !== void 0 && this.statusCode >= 500;
692
+ }
693
+ /**
694
+ * Get a user-friendly error message
695
+ */
696
+ getUserMessage() {
697
+ switch (this.type) {
698
+ case "NetworkError":
699
+ return "Unable to connect to the BMLT server. Please check your internet connection and try again.";
700
+ case "TimeoutError":
701
+ return "The request timed out. Please try again later.";
702
+ case "RateLimitError":
703
+ return "Too many requests. Please wait a moment and try again.";
704
+ case "GeocodingError":
705
+ return "Unable to find the specified address. Please check the address and try again.";
706
+ case "ValidationError":
707
+ return "Invalid input provided. Please check your parameters and try again.";
708
+ case "AuthenticationError":
709
+ return "Authentication failed. Please check your credentials.";
710
+ case "ServerError":
711
+ return "The BMLT server encountered an error. Please try again later.";
712
+ case "ApiError":
713
+ return this.statusCode === 404 ? "The requested resource was not found." : "An error occurred while communicating with the BMLT server.";
714
+ case "ConfigurationError":
715
+ return "Invalid configuration. Please check your settings.";
716
+ default:
717
+ return this.message || "An unexpected error occurred.";
718
+ }
719
+ }
720
+ /**
721
+ * Convert error to JSON for logging
722
+ */
723
+ toJSON() {
724
+ return {
725
+ name: this.name,
726
+ type: this.type,
727
+ message: this.message,
728
+ statusCode: this.statusCode,
729
+ response: this.response,
730
+ context: this.context,
731
+ stack: this.stack,
732
+ originalError: this.originalError ? {
733
+ name: this.originalError.name,
734
+ message: this.originalError.message,
735
+ stack: this.originalError.stack
736
+ } : void 0
737
+ };
738
+ }
739
+ }
740
+ class I {
741
+ static createApiError(e, t, i, n) {
742
+ let a;
743
+ return t ? t >= 500 ? a = "ServerError" : t === 401 || t === 403 ? a = "AuthenticationError" : t === 429 ? a = "RateLimitError" : t >= 400 ? a = "ClientError" : a = "ApiError" : a = "ApiError", new b(a, e, {
744
+ statusCode: t,
745
+ response: i,
746
+ originalError: n
747
+ });
748
+ }
749
+ static createNetworkError(e, t) {
750
+ return new b("NetworkError", e, {
751
+ originalError: t
752
+ });
753
+ }
754
+ static createTimeoutError(e, t) {
755
+ return new b("TimeoutError", e, {
756
+ originalError: t
757
+ });
758
+ }
759
+ static createValidationError(e, t) {
760
+ return new b("ValidationError", e, {
761
+ context: t
762
+ });
763
+ }
764
+ static createGeocodingError(e, t, i) {
765
+ return new b("GeocodingError", e, {
766
+ originalError: t,
767
+ context: i
768
+ });
769
+ }
770
+ static createRateLimitError(e, t, i) {
771
+ return new b("RateLimitError", e, {
772
+ statusCode: t,
773
+ response: i
774
+ });
775
+ }
776
+ static createConfigurationError(e, t) {
777
+ return new b("ConfigurationError", e, {
778
+ context: t
779
+ });
780
+ }
781
+ }
782
+ class J {
783
+ /**
784
+ * Handle and transform fetch errors
785
+ */
786
+ static handleFetchError(e, t) {
787
+ if (e instanceof Error && e.name === "AbortError")
788
+ return I.createTimeoutError("Request timeout", e);
789
+ if (e instanceof TypeError)
790
+ return I.createNetworkError("Network connection failed", e);
791
+ if (t && !t.ok) {
792
+ const i = `HTTP ${t.status}: ${t.statusText}`;
793
+ return I.createApiError(i, t.status, void 0, e);
794
+ }
795
+ return e instanceof Error ? I.createApiError(e.message, void 0, void 0, e) : I.createApiError("Unknown error occurred", void 0, void 0, new Error(String(e)));
796
+ }
797
+ /**
798
+ * @deprecated Use handleFetchError instead
799
+ */
800
+ static handleAxiosError(e) {
801
+ return J.handleFetchError(e);
802
+ }
803
+ /**
804
+ * Handle validation errors with detailed context
805
+ */
806
+ static handleValidationError(e, t, i, n) {
807
+ let a = `Invalid ${e}: expected ${i}`;
808
+ return n && n.length > 0 && (a += ` (${n.join(", ")})`), I.createValidationError(a, {
809
+ field: e,
810
+ value: t,
811
+ expectedType: i,
812
+ constraints: n
813
+ });
814
+ }
815
+ /**
816
+ * Handle endpoint validation errors
817
+ */
818
+ static handleEndpointError(e, t) {
819
+ const i = `Invalid endpoint/format combination: ${e} with ${t}`;
820
+ return I.createValidationError(i, {
821
+ endpoint: e,
822
+ format: t
823
+ });
824
+ }
825
+ /**
826
+ * Handle URL validation errors
827
+ */
828
+ static handleUrlError(e, t) {
829
+ const i = `Invalid URL: ${t}`;
830
+ return I.createValidationError(i, {
831
+ url: e,
832
+ reason: t
833
+ });
834
+ }
835
+ /**
836
+ * Handle coordinate validation errors
837
+ */
838
+ static handleCoordinateError(e, t, i) {
839
+ const n = i || "Invalid coordinates provided";
840
+ return I.createValidationError(n, {
841
+ latitude: e,
842
+ longitude: t,
843
+ reason: i
844
+ });
845
+ }
846
+ /**
847
+ * Wrap and enhance existing errors
848
+ */
849
+ static wrapError(e, t, i) {
850
+ const n = `${t}: ${e.message}`;
851
+ return e instanceof b ? new b(e.type, n, {
852
+ statusCode: e.statusCode,
853
+ response: e.response,
854
+ originalError: e.originalError || e,
855
+ context: {
856
+ ...e.context,
857
+ ...i
858
+ }
859
+ }) : I.createApiError(n, void 0, void 0, e);
860
+ }
861
+ }
862
+ class it {
863
+ static async withRetry(e, t) {
864
+ const {
865
+ maxRetries: i,
866
+ baseDelay: n,
867
+ maxDelay: a,
868
+ factor: s,
869
+ onRetry: o
870
+ } = t;
871
+ let u;
872
+ for (let c = 0; c <= i; c++)
873
+ try {
874
+ return await e();
875
+ } catch (h) {
876
+ const f = h instanceof b ? h : J.wrapError(h, "Operation failed");
877
+ if (u = f, c === i || !f.isRetryable())
878
+ throw f;
879
+ const p = Math.min(
880
+ n * Math.pow(s, c),
881
+ a
882
+ );
883
+ o && o(f, c + 1), await new Promise((E) => setTimeout(E, p));
884
+ }
885
+ throw u;
886
+ }
887
+ }
888
+ class je {
889
+ constructor(e = {}) {
890
+ const {
891
+ retryCount: t = 3,
892
+ timeout: i = 1e4,
893
+ userAgent: n = "bmlt-query-client/1.0.0",
894
+ countryCode: a = "us",
895
+ viewbox: s,
896
+ bounded: o = !1,
897
+ intervalCap: u = 1,
898
+ interval: c = 1e3,
899
+ // 1 second between requests
900
+ concurrency: h = 1,
901
+ carryoverConcurrencyCount: f = !1,
902
+ ...p
903
+ } = e;
904
+ this.defaultOptions = {
905
+ retryCount: t,
906
+ timeout: i,
907
+ userAgent: n,
908
+ countryCode: a,
909
+ viewbox: s,
910
+ bounded: o
911
+ }, this.baseURL = "https://nominatim.openstreetmap.org", this.queue = new Qe({
912
+ intervalCap: u,
913
+ interval: c,
914
+ concurrency: h,
915
+ carryoverConcurrencyCount: f,
916
+ ...p
917
+ });
918
+ }
919
+ /**
920
+ * Make a fetch request with timeout and error handling
921
+ */
922
+ async fetchWithTimeout(e, t, i) {
923
+ const n = new AbortController(), a = setTimeout(() => n.abort(), t);
924
+ try {
925
+ const s = await fetch(e, {
926
+ method: "GET",
927
+ headers: {
928
+ "User-Agent": i
929
+ },
930
+ signal: n.signal
931
+ });
932
+ if (!s.ok) {
933
+ if (s.status === 429) {
934
+ const u = new Error("Rate limit exceeded for geocoding service");
935
+ throw u.name = "RateLimitError", u.statusCode = 429, u;
936
+ }
937
+ if (s.status >= 400) {
938
+ const u = new Error(
939
+ `Geocoding service error: ${s.status} ${s.statusText}`
940
+ );
941
+ throw u.name = "GeocodingError", u.statusCode = s.status, u;
942
+ }
943
+ }
944
+ return await s.json();
945
+ } catch (s) {
946
+ if (s instanceof Error && s.name === "AbortError") {
947
+ const o = new Error("Request timeout during geocoding");
948
+ throw o.name = "TimeoutError", o;
949
+ }
950
+ if (s instanceof TypeError) {
951
+ const o = new Error("Network error occurred during geocoding");
952
+ throw o.name = "NetworkError", o;
953
+ }
954
+ throw s;
955
+ } finally {
956
+ clearTimeout(a);
957
+ }
958
+ }
959
+ /**
960
+ * Geocode an address using Nominatim
961
+ */
962
+ async geocode(e, t = {}) {
963
+ const i = { ...this.defaultOptions, ...t };
964
+ return this.queue.add(async () => me(
965
+ async () => {
966
+ try {
967
+ const n = {
968
+ q: e,
969
+ format: "json",
970
+ addressdetails: 1,
971
+ limit: 1,
972
+ dedupe: 1
973
+ };
974
+ i.countryCode && (n.countrycodes = i.countryCode), i.viewbox && (n.viewbox = i.viewbox.join(","), i.bounded && (n.bounded = 1));
975
+ const a = new URL(`${this.baseURL}/search`);
976
+ Object.entries(n).forEach(([c, h]) => {
977
+ a.searchParams.append(c, String(h));
978
+ });
979
+ const s = await this.fetchWithTimeout(
980
+ a.toString(),
981
+ i.timeout,
982
+ i.userAgent
983
+ );
984
+ if (!s || s.length === 0)
985
+ throw new b(
986
+ Ne.GEOCODING_ERROR,
987
+ `No results found for address: ${e}`
988
+ );
989
+ const o = s[0], u = {
990
+ latitude: parseFloat(o.lat),
991
+ longitude: parseFloat(o.lon)
992
+ };
993
+ if (isNaN(u.latitude) || isNaN(u.longitude)) {
994
+ const c = new Error("Invalid coordinates received from geocoding service");
995
+ throw c.name = "GeocodingError", c;
996
+ }
997
+ if (u.latitude < -90 || u.latitude > 90 || u.longitude < -180 || u.longitude > 180) {
998
+ const c = new Error("Coordinates out of valid range");
999
+ throw c.name = "GeocodingError", c;
1000
+ }
1001
+ return {
1002
+ coordinates: u,
1003
+ display_name: o.display_name,
1004
+ confidence: o.importance,
1005
+ address: o.address ? {
1006
+ house_number: o.address.house_number,
1007
+ road: o.address.road,
1008
+ neighbourhood: o.address.neighbourhood,
1009
+ suburb: o.address.suburb,
1010
+ city: o.address.city || o.address.town || o.address.village,
1011
+ county: o.address.county,
1012
+ state: o.address.state,
1013
+ postcode: o.address.postcode,
1014
+ country: o.address.country
1015
+ } : void 0
1016
+ };
1017
+ } catch (n) {
1018
+ throw n;
1019
+ }
1020
+ },
1021
+ {
1022
+ retries: i.retryCount,
1023
+ factor: 2,
1024
+ minTimeout: 1e3,
1025
+ maxTimeout: 1e4,
1026
+ onFailedAttempt: (n) => {
1027
+ console.warn(
1028
+ `Geocoding attempt ${n.attemptNumber} failed. ${n.retriesLeft} retries left. Error: ${n.message}`
1029
+ );
1030
+ }
1031
+ }
1032
+ ));
1033
+ }
1034
+ /**
1035
+ * Batch geocode multiple addresses
1036
+ */
1037
+ async batchGeocode(e, t = {}) {
1038
+ const i = e.map(
1039
+ (a) => this.geocode(a, t).catch((s) => (console.warn(`Failed to geocode address "${a}":`, s.message), null))
1040
+ );
1041
+ return (await Promise.all(i)).filter((a) => a !== null);
1042
+ }
1043
+ /**
1044
+ * Reverse geocode coordinates to an address
1045
+ */
1046
+ async reverseGeocode(e, t = {}) {
1047
+ const i = { ...this.defaultOptions, ...t };
1048
+ return this.queue.add(async () => me(
1049
+ async () => {
1050
+ try {
1051
+ const n = new URL(`${this.baseURL}/reverse`);
1052
+ n.searchParams.append("lat", String(e.latitude)), n.searchParams.append("lon", String(e.longitude)), n.searchParams.append("format", "json"), n.searchParams.append("addressdetails", "1");
1053
+ const a = await this.fetchWithTimeout(
1054
+ n.toString(),
1055
+ i.timeout,
1056
+ i.userAgent
1057
+ );
1058
+ if (!a) {
1059
+ const o = new Error(
1060
+ `No results found for coordinates: ${e.latitude}, ${e.longitude}`
1061
+ );
1062
+ throw o.name = "GeocodingError", o;
1063
+ }
1064
+ const s = a;
1065
+ return {
1066
+ coordinates: {
1067
+ latitude: parseFloat(s.lat),
1068
+ longitude: parseFloat(s.lon)
1069
+ },
1070
+ display_name: s.display_name,
1071
+ confidence: s.importance,
1072
+ address: s.address ? {
1073
+ house_number: s.address.house_number,
1074
+ road: s.address.road,
1075
+ neighbourhood: s.address.neighbourhood,
1076
+ suburb: s.address.suburb,
1077
+ city: s.address.city || s.address.town || s.address.village,
1078
+ county: s.address.county,
1079
+ state: s.address.state,
1080
+ postcode: s.address.postcode,
1081
+ country: s.address.country
1082
+ } : void 0
1083
+ };
1084
+ } catch (n) {
1085
+ throw n;
1086
+ }
1087
+ },
1088
+ {
1089
+ retries: i.retryCount,
1090
+ factor: 2,
1091
+ minTimeout: 1e3,
1092
+ maxTimeout: 1e4
1093
+ }
1094
+ ));
1095
+ }
1096
+ /**
1097
+ * Get the current queue size
1098
+ */
1099
+ getQueueSize() {
1100
+ return this.queue.size;
1101
+ }
1102
+ /**
1103
+ * Get the number of pending operations
1104
+ */
1105
+ getPendingCount() {
1106
+ return this.queue.pending;
1107
+ }
1108
+ /**
1109
+ * Clear the queue
1110
+ */
1111
+ clearQueue() {
1112
+ this.queue.clear();
1113
+ }
1114
+ /**
1115
+ * Set concurrency limit
1116
+ */
1117
+ setConcurrency(e) {
1118
+ this.queue.concurrency = e;
1119
+ }
1120
+ }
1121
+ var y = /* @__PURE__ */ ((r) => (r.JSON = "json", r.JSONP = "jsonp", r.TSML = "tsml", r.CSV = "csv", r))(y || {}), _ = /* @__PURE__ */ ((r) => (r.GET_SEARCH_RESULTS = "GetSearchResults", r.GET_FORMATS = "GetFormats", r.GET_SERVICE_BODIES = "GetServiceBodies", r.GET_CHANGES = "GetChanges", r.GET_FIELD_KEYS = "GetFieldKeys", r.GET_FIELD_VALUES = "GetFieldValues", r.GET_NAWS_DUMP = "GetNAWSDump", r.GET_SERVER_INFO = "GetServerInfo", r.GET_COVERAGE_AREA = "GetCoverageArea", r))(_ || {}), G = /* @__PURE__ */ ((r) => (r[r.SUNDAY = 1] = "SUNDAY", r[r.MONDAY = 2] = "MONDAY", r[r.TUESDAY = 3] = "TUESDAY", r[r.WEDNESDAY = 4] = "WEDNESDAY", r[r.THURSDAY = 5] = "THURSDAY", r[r.FRIDAY = 6] = "FRIDAY", r[r.SATURDAY = 7] = "SATURDAY", r))(G || {}), F = /* @__PURE__ */ ((r) => (r[r.IN_PERSON = 1] = "IN_PERSON", r[r.VIRTUAL = 2] = "VIRTUAL", r[r.HYBRID = 3] = "HYBRID", r))(F || {}), Be = /* @__PURE__ */ ((r) => (r.WEEKDAY = "weekday", r.TIME = "time", r.TOWN = "town", r.STATE = "state", r.WEEKDAY_STATE = "weekday_state", r))(Be || {}), Ke = /* @__PURE__ */ ((r) => (r.ENGLISH = "en", r.GERMAN = "de", r.DANISH = "dk", r.SPANISH = "es", r.PERSIAN = "fa", r.FRENCH = "fr", r.ITALIAN = "it", r.POLISH = "pl", r.PORTUGUESE = "pt", r.SWEDISH = "sv", r))(Ke || {});
1122
+ function Xe(r) {
1123
+ const { rootServerURL: e, format: t, endpoint: i, parameters: n = {} } = r, s = `${e.endsWith("/") ? e : `${e}/`}client_interface/${t}/`, o = new URLSearchParams();
1124
+ return o.set("switcher", i), Object.entries(n).forEach(([u, c]) => {
1125
+ c != null && (Array.isArray(c) ? c.forEach((h, f) => {
1126
+ (typeof h == "number" || typeof h == "string") && o.append(`${u}[]`, h.toString());
1127
+ }) : typeof c == "boolean" ? o.set(u, c ? "1" : "0") : o.set(u, c.toString()));
1128
+ }), `${s}?${o.toString()}`;
1129
+ }
1130
+ function nt(r) {
1131
+ const e = {};
1132
+ return Object.entries(r).forEach(([t, i]) => {
1133
+ if (i != null)
1134
+ if (Array.isArray(i))
1135
+ e[t] = i.map((n) => {
1136
+ if (typeof n == "number")
1137
+ return n;
1138
+ if (typeof n == "string") {
1139
+ const a = parseFloat(n);
1140
+ return isNaN(a) ? n : a;
1141
+ }
1142
+ return n;
1143
+ });
1144
+ else if (typeof i == "boolean")
1145
+ e[t] = i;
1146
+ else if (typeof i == "string") {
1147
+ const n = parseFloat(i);
1148
+ !isNaN(n) && isFinite(n) ? e[t] = n : e[t] = i;
1149
+ } else
1150
+ e[t] = i;
1151
+ }), e;
1152
+ }
1153
+ function Ze(r, e) {
1154
+ const i = {
1155
+ [_.GET_SEARCH_RESULTS]: [y.JSON, y.JSONP, y.TSML],
1156
+ [_.GET_FORMATS]: [y.JSON, y.JSONP],
1157
+ [_.GET_SERVICE_BODIES]: [y.JSON, y.JSONP],
1158
+ [_.GET_CHANGES]: [y.JSON, y.JSONP],
1159
+ [_.GET_FIELD_KEYS]: [y.JSON, y.JSONP],
1160
+ [_.GET_FIELD_VALUES]: [y.JSON, y.JSONP],
1161
+ [_.GET_NAWS_DUMP]: [y.CSV],
1162
+ [_.GET_SERVER_INFO]: [y.JSON, y.JSONP],
1163
+ [_.GET_COVERAGE_AREA]: [y.JSON, y.JSONP]
1164
+ }[r];
1165
+ if (!i.includes(e))
1166
+ throw new Error(
1167
+ `Invalid format '${e}' for endpoint '${r}'. Valid formats: ${i.join(", ")}`
1168
+ );
1169
+ }
1170
+ function ge(r) {
1171
+ try {
1172
+ const e = new URL(r);
1173
+ if (!["http:", "https:"].includes(e.protocol))
1174
+ throw new Error("Root server URL must use http or https protocol");
1175
+ return e.href.replace(/\/$/, "");
1176
+ } catch {
1177
+ throw new Error(`Invalid root server URL: ${r}`);
1178
+ }
1179
+ }
1180
+ function st(r) {
1181
+ return typeof r == "number" ? [r] : typeof r == "string" ? r.split(",").map((e) => parseInt(e.trim(), 10)).filter((e) => !isNaN(e)) : Array.isArray(r) ? r.map((e) => typeof e == "number" ? e : parseInt(String(e), 10)).filter((e) => !isNaN(e)) : [];
1182
+ }
1183
+ function ot(r, e) {
1184
+ const t = {};
1185
+ if (typeof r == "number") {
1186
+ if (r < 0 || r > 23)
1187
+ throw new Error("Hours must be between 0 and 23");
1188
+ t.hours = r;
1189
+ }
1190
+ if (typeof e == "number") {
1191
+ if (e < 0 || e > 59)
1192
+ throw new Error("Minutes must be between 0 and 59");
1193
+ t.minutes = e;
1194
+ }
1195
+ return t;
1196
+ }
1197
+ function et(r, e) {
1198
+ if (typeof r != "number" || isNaN(r))
1199
+ throw new Error("Latitude must be a valid number");
1200
+ if (typeof e != "number" || isNaN(e))
1201
+ throw new Error("Longitude must be a valid number");
1202
+ if (r < -90 || r > 90)
1203
+ throw new Error("Latitude must be between -90 and 90 degrees");
1204
+ if (e < -180 || e > 180)
1205
+ throw new Error("Longitude must be between -180 and 180 degrees");
1206
+ }
1207
+ function B(r) {
1208
+ if (typeof r != "number" || isNaN(r))
1209
+ throw new Error("Radius must be a valid number");
1210
+ if (r <= 0)
1211
+ throw new Error("Radius must be greater than 0");
1212
+ }
1213
+ function at(r) {
1214
+ return r * 1.60934;
1215
+ }
1216
+ function ut(r) {
1217
+ return r / 1.60934;
1218
+ }
1219
+ class ct {
1220
+ constructor(e) {
1221
+ const {
1222
+ rootServerURL: t,
1223
+ defaultFormat: i = y.JSON,
1224
+ timeout: n = 3e4,
1225
+ userAgent: a = "bmlt-query-client/1.0.0",
1226
+ geocodingOptions: s = {},
1227
+ enableGeocoding: o = !0
1228
+ } = e;
1229
+ this.rootServerURL = ge(t), this.defaultFormat = i, this.timeout = n, this.userAgent = a, o && (this.geocodingService = new je(s));
1230
+ }
1231
+ /**
1232
+ * Make a request to the BMLT API
1233
+ */
1234
+ async makeRequest(e, t = {}, i = this.defaultFormat) {
1235
+ let n;
1236
+ try {
1237
+ Ze(e, i);
1238
+ const a = Xe({
1239
+ rootServerURL: this.rootServerURL,
1240
+ format: i,
1241
+ endpoint: e,
1242
+ parameters: t
1243
+ }), s = new AbortController(), o = setTimeout(() => s.abort(), this.timeout);
1244
+ try {
1245
+ n = await fetch(a, {
1246
+ method: "GET",
1247
+ headers: {
1248
+ "User-Agent": this.userAgent
1249
+ },
1250
+ signal: s.signal
1251
+ });
1252
+ } finally {
1253
+ clearTimeout(o);
1254
+ }
1255
+ if (!n.ok)
1256
+ throw J.handleFetchError(
1257
+ new Error(`HTTP ${n.status}: ${n.statusText}`),
1258
+ n
1259
+ );
1260
+ const u = await n.text();
1261
+ if (i === y.CSV)
1262
+ return u;
1263
+ if (i === y.JSONP) {
1264
+ const c = t.callback || "callback", h = u.match(new RegExp(`${c}\\((.+)\\);?$`));
1265
+ if (!h)
1266
+ throw new Error("Invalid JSONP response format");
1267
+ return JSON.parse(h[1]);
1268
+ }
1269
+ return i === y.JSON || i === y.TSML ? JSON.parse(u) : u;
1270
+ } catch (a) {
1271
+ throw J.handleFetchError(a, n);
1272
+ }
1273
+ }
1274
+ /**
1275
+ * Search for meetings
1276
+ */
1277
+ async searchMeetings(e = {}) {
1278
+ const { format: t = this.defaultFormat, ...i } = e;
1279
+ return this.makeRequest(_.GET_SEARCH_RESULTS, i, t);
1280
+ }
1281
+ /**
1282
+ * Search for meetings by geographic location using geocoding
1283
+ */
1284
+ async searchMeetingsByAddress(e) {
1285
+ if (!this.geocodingService)
1286
+ throw new Error("Geocoding is not enabled. Initialize client with enableGeocoding: true");
1287
+ const { address: t, radiusMiles: i, radiusKm: n, sortByDistance: a = !0, searchParams: s = {} } = e, o = await this.geocodingService.geocode(t), u = {
1288
+ ...s,
1289
+ lat_val: o.coordinates.latitude,
1290
+ long_val: o.coordinates.longitude,
1291
+ sort_results_by_distance: a
1292
+ };
1293
+ return i !== void 0 ? (B(i), u.geo_width = i) : n !== void 0 && (B(n), u.geo_width_km = n), this.searchMeetings(u);
1294
+ }
1295
+ /**
1296
+ * Search for meetings by coordinates
1297
+ */
1298
+ async searchMeetingsByCoordinates(e, t, i, n = {}) {
1299
+ et(e.latitude, e.longitude);
1300
+ const a = {
1301
+ ...n,
1302
+ lat_val: e.latitude,
1303
+ long_val: e.longitude,
1304
+ sort_results_by_distance: !0
1305
+ };
1306
+ return t !== void 0 ? (B(t), a.geo_width = t) : i !== void 0 && (B(i), a.geo_width_km = i), this.searchMeetings(a);
1307
+ }
1308
+ /**
1309
+ * Get available meeting formats
1310
+ */
1311
+ async getFormats(e = {}) {
1312
+ const { format: t = this.defaultFormat, ...i } = e;
1313
+ return this.makeRequest(_.GET_FORMATS, i, t);
1314
+ }
1315
+ /**
1316
+ * Get service bodies
1317
+ */
1318
+ async getServiceBodies(e = {}) {
1319
+ const { format: t = this.defaultFormat, ...i } = e;
1320
+ return this.makeRequest(_.GET_SERVICE_BODIES, i, t);
1321
+ }
1322
+ /**
1323
+ * Get meeting changes within a date range
1324
+ */
1325
+ async getChanges(e = {}) {
1326
+ const { format: t = this.defaultFormat, ...i } = e;
1327
+ return this.makeRequest(_.GET_CHANGES, i, t);
1328
+ }
1329
+ /**
1330
+ * Get available field keys
1331
+ */
1332
+ async getFieldKeys() {
1333
+ return this.makeRequest(_.GET_FIELD_KEYS);
1334
+ }
1335
+ /**
1336
+ * Get field values for a specific field key
1337
+ */
1338
+ async getFieldValues(e) {
1339
+ const { format: t = this.defaultFormat, ...i } = e;
1340
+ return this.makeRequest(_.GET_FIELD_VALUES, i, t);
1341
+ }
1342
+ /**
1343
+ * Get NAWS dump for a service body (CSV format only)
1344
+ */
1345
+ async getNAWSDump(e) {
1346
+ return this.makeRequest(_.GET_NAWS_DUMP, e, y.CSV);
1347
+ }
1348
+ /**
1349
+ * Get server information
1350
+ */
1351
+ async getServerInfo() {
1352
+ return this.makeRequest(_.GET_SERVER_INFO);
1353
+ }
1354
+ /**
1355
+ * Get server coverage area
1356
+ */
1357
+ async getCoverageArea() {
1358
+ return this.makeRequest(_.GET_COVERAGE_AREA);
1359
+ }
1360
+ /**
1361
+ * Geocode an address using the built-in geocoding service
1362
+ */
1363
+ async geocodeAddress(e, t) {
1364
+ if (!this.geocodingService)
1365
+ throw new Error("Geocoding is not enabled. Initialize client with enableGeocoding: true");
1366
+ return this.geocodingService.geocode(e, t);
1367
+ }
1368
+ /**
1369
+ * Reverse geocode coordinates to an address
1370
+ */
1371
+ async reverseGeocode(e, t) {
1372
+ if (!this.geocodingService)
1373
+ throw new Error("Geocoding is not enabled. Initialize client with enableGeocoding: true");
1374
+ return this.geocodingService.reverseGeocode(e, t);
1375
+ }
1376
+ /**
1377
+ * Get the root server URL
1378
+ */
1379
+ getRootServerURL() {
1380
+ return this.rootServerURL;
1381
+ }
1382
+ /**
1383
+ * Update the root server URL
1384
+ */
1385
+ setRootServerURL(e) {
1386
+ this.rootServerURL = ge(e);
1387
+ }
1388
+ /**
1389
+ * Get the default data format
1390
+ */
1391
+ getDefaultFormat() {
1392
+ return this.defaultFormat;
1393
+ }
1394
+ /**
1395
+ * Set the default data format
1396
+ */
1397
+ setDefaultFormat(e) {
1398
+ this.defaultFormat = e;
1399
+ }
1400
+ /**
1401
+ * Get geocoding service statistics
1402
+ */
1403
+ getGeocodingStats() {
1404
+ return this.geocodingService ? {
1405
+ queueSize: this.geocodingService.getQueueSize(),
1406
+ pendingCount: this.geocodingService.getPendingCount()
1407
+ } : null;
1408
+ }
1409
+ /**
1410
+ * Clear the geocoding queue
1411
+ */
1412
+ clearGeocodingQueue() {
1413
+ this.geocodingService && this.geocodingService.clearQueue();
1414
+ }
1415
+ }
1416
+ class C {
1417
+ constructor(e) {
1418
+ this.params = {}, this.client = e;
1419
+ }
1420
+ /**
1421
+ * Include or exclude specific meeting IDs
1422
+ */
1423
+ meetingIds(e, t = !1) {
1424
+ return Array.isArray(e) ? this.params.meeting_ids = t ? e.map((i) => -i) : e : this.params.meeting_ids = t ? -e : e, this;
1425
+ }
1426
+ /**
1427
+ * Include meetings on specific weekdays
1428
+ */
1429
+ onWeekdays(...e) {
1430
+ return this.params.weekdays = e.length === 1 ? e[0] : e, this;
1431
+ }
1432
+ /**
1433
+ * Exclude meetings on specific weekdays
1434
+ */
1435
+ notOnWeekdays(...e) {
1436
+ const t = e.map((i) => -i);
1437
+ return this.params.weekdays = t.length === 1 ? t[0] : t, this;
1438
+ }
1439
+ /**
1440
+ * Filter by venue types
1441
+ */
1442
+ venueTypes(...e) {
1443
+ return this.params.venue_types = e.length === 1 ? e[0] : e, this;
1444
+ }
1445
+ /**
1446
+ * Include only in-person meetings
1447
+ */
1448
+ inPersonOnly() {
1449
+ return this.venueTypes(F.IN_PERSON);
1450
+ }
1451
+ /**
1452
+ * Include only virtual meetings
1453
+ */
1454
+ virtualOnly() {
1455
+ return this.venueTypes(F.VIRTUAL);
1456
+ }
1457
+ /**
1458
+ * Include only hybrid meetings
1459
+ */
1460
+ hybridOnly() {
1461
+ return this.venueTypes(F.HYBRID);
1462
+ }
1463
+ /**
1464
+ * Include virtual and hybrid meetings
1465
+ */
1466
+ virtualOrHybrid() {
1467
+ return this.venueTypes(F.VIRTUAL, F.HYBRID);
1468
+ }
1469
+ /**
1470
+ * Filter by meeting formats
1471
+ */
1472
+ formats(e, t = !1) {
1473
+ return Array.isArray(e) ? this.params.formats = t ? e.map((i) => -i) : e : this.params.formats = t ? -e : e, this;
1474
+ }
1475
+ /**
1476
+ * Use OR logic for format matching instead of AND
1477
+ */
1478
+ anyFormat() {
1479
+ return this.params.formats_comparison_operator = "OR", this;
1480
+ }
1481
+ /**
1482
+ * Filter by service bodies
1483
+ */
1484
+ serviceBodies(e, t = !1) {
1485
+ return Array.isArray(e) ? this.params.services = t ? e.map((i) => -i) : e : this.params.services = t ? -e : e, this;
1486
+ }
1487
+ /**
1488
+ * Include child service bodies
1489
+ */
1490
+ includeChildServiceBodies() {
1491
+ return this.params.recursive = !0, this;
1492
+ }
1493
+ /**
1494
+ * Search for specific text
1495
+ */
1496
+ searchText(e) {
1497
+ return this.params.SearchString = e, this;
1498
+ }
1499
+ /**
1500
+ * Meetings starting after specific time
1501
+ */
1502
+ startingAfter(e, t = 0) {
1503
+ return this.params.StartsAfterH = e, this.params.StartsAfterM = t, this;
1504
+ }
1505
+ /**
1506
+ * Meetings starting before specific time
1507
+ */
1508
+ startingBefore(e, t = 0) {
1509
+ return this.params.StartsBeforeH = e, this.params.StartsBeforeM = t, this;
1510
+ }
1511
+ /**
1512
+ * Meetings ending before specific time
1513
+ */
1514
+ endingBefore(e, t = 0) {
1515
+ return this.params.EndsBeforeH = e, this.params.EndsBeforeM = t, this;
1516
+ }
1517
+ /**
1518
+ * Minimum meeting duration
1519
+ */
1520
+ minimumDuration(e = 0, t = 0) {
1521
+ return e > 0 && (this.params.MinDurationH = e), t > 0 && (this.params.MinDurationM = t), this;
1522
+ }
1523
+ /**
1524
+ * Maximum meeting duration
1525
+ */
1526
+ maximumDuration(e = 0, t = 0) {
1527
+ return e > 0 && (this.params.MaxDurationH = e), t > 0 && (this.params.MaxDurationM = t), this;
1528
+ }
1529
+ /**
1530
+ * Search within geographic area by coordinates
1531
+ */
1532
+ nearCoordinates(e, t, i) {
1533
+ return this.params.lat_val = e.latitude, this.params.long_val = e.longitude, t !== void 0 ? this.params.geo_width = t : i !== void 0 && (this.params.geo_width_km = i), this;
1534
+ }
1535
+ /**
1536
+ * Search for specific field value
1537
+ */
1538
+ fieldValue(e, t) {
1539
+ return this.params.meeting_key = e, this.params.meeting_key_value = t, this;
1540
+ }
1541
+ /**
1542
+ * Return only specific fields
1543
+ */
1544
+ selectFields(...e) {
1545
+ return this.params.data_field_key = e.join(","), this;
1546
+ }
1547
+ /**
1548
+ * Sort results by specific fields
1549
+ */
1550
+ sortBy(...e) {
1551
+ return this.params.sort_keys = e.join(","), this;
1552
+ }
1553
+ /**
1554
+ * Sort by predefined aliases
1555
+ */
1556
+ sortByAlias(e) {
1557
+ return this.params.sort_key = e, this;
1558
+ }
1559
+ /**
1560
+ * Sort by distance (requires geographic search)
1561
+ */
1562
+ sortByDistance() {
1563
+ return this.params.sort_results_by_distance = !0, this;
1564
+ }
1565
+ /**
1566
+ * Set pagination
1567
+ */
1568
+ paginate(e, t = 1) {
1569
+ return this.params.page_size = e, this.params.page_num = t, this;
1570
+ }
1571
+ /**
1572
+ * Include unpublished meetings
1573
+ */
1574
+ includeUnpublished() {
1575
+ return this.params.advanced_published = 0, this;
1576
+ }
1577
+ /**
1578
+ * Include only unpublished meetings
1579
+ */
1580
+ unpublishedOnly() {
1581
+ return this.params.advanced_published = -1, this;
1582
+ }
1583
+ /**
1584
+ * Set language for format names
1585
+ */
1586
+ language(e) {
1587
+ return this.params.lang_enum = e, this;
1588
+ }
1589
+ /**
1590
+ * Set response format
1591
+ */
1592
+ format(e) {
1593
+ return this.params.format = e, this;
1594
+ }
1595
+ /**
1596
+ * Include formats used in search results
1597
+ */
1598
+ includeFormats() {
1599
+ return this.params.get_used_formats = !0, this;
1600
+ }
1601
+ /**
1602
+ * Return only formats (requires includeFormats)
1603
+ */
1604
+ formatsOnly() {
1605
+ return this.params.get_used_formats = !0, this.params.get_formats_only = !0, this;
1606
+ }
1607
+ /**
1608
+ * Filter by root server IDs (aggregator mode)
1609
+ */
1610
+ rootServerIds(e, t = !1) {
1611
+ return Array.isArray(e) ? this.params.root_server_ids = t ? e.map((i) => -i) : e : this.params.root_server_ids = t ? -e : e, this;
1612
+ }
1613
+ /**
1614
+ * Get the current query parameters
1615
+ */
1616
+ getParams() {
1617
+ return { ...this.params };
1618
+ }
1619
+ /**
1620
+ * Reset the query builder
1621
+ */
1622
+ reset() {
1623
+ return this.params = {}, this;
1624
+ }
1625
+ /**
1626
+ * Clone the current query builder
1627
+ */
1628
+ clone() {
1629
+ const e = new C(this.client);
1630
+ return e.params = { ...this.params }, e;
1631
+ }
1632
+ /**
1633
+ * Execute the search and return results
1634
+ */
1635
+ async execute() {
1636
+ return this.client.searchMeetings(this.params);
1637
+ }
1638
+ /**
1639
+ * Execute the search by geocoding an address first
1640
+ */
1641
+ async executeNearAddress(e, t, i, n = !0) {
1642
+ return this.client.searchMeetingsByAddress({
1643
+ address: e,
1644
+ radiusMiles: t,
1645
+ radiusKm: i,
1646
+ sortByDistance: n,
1647
+ searchParams: this.params
1648
+ });
1649
+ }
1650
+ }
1651
+ class ht {
1652
+ constructor(e) {
1653
+ this.client = e;
1654
+ }
1655
+ /**
1656
+ * Search for today's meetings
1657
+ */
1658
+ today() {
1659
+ const e = (/* @__PURE__ */ new Date()).getDay(), t = e === 0 ? G.SUNDAY : e;
1660
+ return new C(this.client).onWeekdays(t);
1661
+ }
1662
+ /**
1663
+ * Search for weekend meetings
1664
+ */
1665
+ weekend() {
1666
+ return new C(this.client).onWeekdays(G.SATURDAY, G.SUNDAY);
1667
+ }
1668
+ /**
1669
+ * Search for weekday meetings
1670
+ */
1671
+ weekdays() {
1672
+ return new C(this.client).onWeekdays(
1673
+ G.MONDAY,
1674
+ G.TUESDAY,
1675
+ G.WEDNESDAY,
1676
+ G.THURSDAY,
1677
+ G.FRIDAY
1678
+ );
1679
+ }
1680
+ /**
1681
+ * Search for evening meetings (after 5 PM)
1682
+ */
1683
+ evening() {
1684
+ return new C(this.client).startingAfter(17);
1685
+ }
1686
+ /**
1687
+ * Search for morning meetings (before 12 PM)
1688
+ */
1689
+ morning() {
1690
+ return new C(this.client).startingBefore(12);
1691
+ }
1692
+ /**
1693
+ * Search for virtual meetings only
1694
+ */
1695
+ virtual() {
1696
+ return new C(this.client).virtualOnly();
1697
+ }
1698
+ /**
1699
+ * Search for in-person meetings only
1700
+ */
1701
+ inPerson() {
1702
+ return new C(this.client).inPersonOnly();
1703
+ }
1704
+ /**
1705
+ * Search by meeting name or location
1706
+ */
1707
+ byText(e) {
1708
+ return new C(this.client).searchText(e);
1709
+ }
1710
+ }
1711
+ export {
1712
+ ct as BmltClient,
1713
+ y as BmltDataFormat,
1714
+ _ as BmltEndpoint,
1715
+ Ne as BmltErrorType,
1716
+ b as BmltQueryError,
1717
+ I as ErrorFactory,
1718
+ J as ErrorHandler,
1719
+ je as GeocodingService,
1720
+ Ke as Language,
1721
+ C as MeetingQueryBuilder,
1722
+ ht as QuickSearch,
1723
+ it as RetryHandler,
1724
+ Be as SortKey,
1725
+ F as VenueType,
1726
+ G as Weekday,
1727
+ Xe as buildBmltURL,
1728
+ st as extractIds,
1729
+ ot as formatTimeValue,
1730
+ ut as kilometersToMiles,
1731
+ at as milesToKilometers,
1732
+ nt as normalizeParameters,
1733
+ et as validateCoordinates,
1734
+ Ze as validateEndpointFormat,
1735
+ B as validateRadius,
1736
+ ge as validateRootServerURL
1737
+ };
1738
+ //# sourceMappingURL=app.js.map