@camstack/addon-pipeline-analytics 0.1.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.
Files changed (56) hide show
  1. package/dist/@mf-types/compiled-types/widgets/AudioHistoryChart.d.ts +5 -0
  2. package/dist/@mf-types/compiled-types/widgets/AudioHistoryChart.d.ts.map +1 -0
  3. package/dist/@mf-types/compiled-types/widgets/AudioMetricsPanel.d.ts +11 -0
  4. package/dist/@mf-types/compiled-types/widgets/AudioMetricsPanel.d.ts.map +1 -0
  5. package/dist/@mf-types/compiled-types/widgets/DetectionHistoryChart.d.ts +5 -0
  6. package/dist/@mf-types/compiled-types/widgets/DetectionHistoryChart.d.ts.map +1 -0
  7. package/dist/@mf-types/compiled-types/widgets/MotionHistoryChart.d.ts +5 -0
  8. package/dist/@mf-types/compiled-types/widgets/MotionHistoryChart.d.ts.map +1 -0
  9. package/dist/@mf-types/compiled-types/widgets/OccupancyHistoryChart.d.ts +5 -0
  10. package/dist/@mf-types/compiled-types/widgets/OccupancyHistoryChart.d.ts.map +1 -0
  11. package/dist/@mf-types/compiled-types/widgets/OccupancyPanel.d.ts +11 -0
  12. package/dist/@mf-types/compiled-types/widgets/OccupancyPanel.d.ts.map +1 -0
  13. package/dist/@mf-types/compiled-types/widgets/chart-utils.d.ts +98 -0
  14. package/dist/@mf-types/compiled-types/widgets/chart-utils.d.ts.map +1 -0
  15. package/dist/@mf-types/compiled-types/widgets/index.d.ts +28 -0
  16. package/dist/@mf-types/compiled-types/widgets/index.d.ts.map +1 -0
  17. package/dist/@mf-types/widgets.d.ts +2 -0
  18. package/dist/@mf-types.d.ts +3 -0
  19. package/dist/@mf-types.zip +0 -0
  20. package/dist/__mfe_internal__addon_pipeline_analytics_widgets__loadShare___mf_0_camstack_mf_1_sdk__loadShare__.mjs-CCBTZBOa.mjs +12 -0
  21. package/dist/__mfe_internal__addon_pipeline_analytics_widgets__loadShare___mf_0_camstack_mf_1_types__loadShare__.mjs-OesvKBZV.mjs +16 -0
  22. package/dist/__mfe_internal__addon_pipeline_analytics_widgets__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.mjs-D0mniK1l.mjs +15 -0
  23. package/dist/__mfe_internal__addon_pipeline_analytics_widgets__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.mjs-DoWbefqS.mjs +104 -0
  24. package/dist/__mfe_internal__addon_pipeline_analytics_widgets__loadShare___mf_0_trpc_mf_1_client__loadShare__.mjs-52bfkwC8.mjs +85 -0
  25. package/dist/__mfe_internal__addon_pipeline_analytics_widgets__loadShare___mf_0_trpc_mf_1_react_mf_2_query__loadShare__.mjs-CVrnrGED.mjs +62 -0
  26. package/dist/__mfe_internal__addon_pipeline_analytics_widgets__loadShare__react__loadShare__.mjs-DuO9h7li.mjs +85 -0
  27. package/dist/__mfe_internal__addon_pipeline_analytics_widgets__loadShare__react__loadShare__.mjs_commonjs-proxy-CmqNjq44.mjs +29 -0
  28. package/dist/__mfe_internal__addon_pipeline_analytics_widgets__loadShare__react_mf_1_jsx_mf_2_runtime__loadShare__.mjs-BsyrX6NO.mjs +36 -0
  29. package/dist/__mfe_internal__addon_pipeline_analytics_widgets__loadShare__react_mf_2_dom__loadShare__.mjs-Dp8hqYOB.mjs +45 -0
  30. package/dist/__mfe_internal__addon_pipeline_analytics_widgets__loadShare__react_mf_2_dom__loadShare__.mjs_commonjs-proxy-CA8cCIEl.mjs +6 -0
  31. package/dist/__mfe_internal__addon_pipeline_analytics_widgets__loadShare__react_mf_2_dom_mf_1_client__loadShare__.mjs-BZjEt71l.mjs +34 -0
  32. package/dist/_stub.js +1397 -0
  33. package/dist/_virtual_mf-localSharedImportMap___mfe_internal__addon_pipeline_analytics_widgets-Cm7MAUA1.mjs +157 -0
  34. package/dist/client-DdXDZxzK.mjs +10063 -0
  35. package/dist/getErrorShape-BPSzUA7W-TlK8ipWe.mjs +211 -0
  36. package/dist/hostInit-WKMmag4S.mjs +168 -0
  37. package/dist/index-B4OKsa9p.mjs +2603 -0
  38. package/dist/index-C3iAUQqS.mjs +533 -0
  39. package/dist/index-D0dNM7_R.mjs +2892 -0
  40. package/dist/index-DKqbmJDl.mjs +2464 -0
  41. package/dist/index-DnFVXz0U.mjs +14162 -0
  42. package/dist/index-DyYvUfc7.mjs +725 -0
  43. package/dist/index-Oq45bZIA.mjs +17936 -0
  44. package/dist/index-k0CA0h_r.mjs +185 -0
  45. package/dist/index-kIgjN-uq.mjs +435 -0
  46. package/dist/index-xncRG7-x.mjs +2713 -0
  47. package/dist/index.d.mts +190 -0
  48. package/dist/index.d.ts +190 -0
  49. package/dist/index.js +2623 -0
  50. package/dist/index.js.map +1 -0
  51. package/dist/index.mjs +2602 -0
  52. package/dist/index.mjs.map +1 -0
  53. package/dist/jsx-runtime-4ro1c69i.mjs +55 -0
  54. package/dist/remoteEntry.js +85 -0
  55. package/dist/virtualExposes-8FzWTdq3.mjs +42 -0
  56. package/package.json +89 -0
@@ -0,0 +1,2713 @@
1
+ import { i as M, _ as w, r as oe, a as ze, b as I, e as pt, c as W, s as we, d as mt, f as ht, g as We, h as xe, T as yt, j as vt } from "./getErrorShape-BPSzUA7W-TlK8ipWe.mjs";
2
+ var bt = Object.create, Ge = Object.defineProperty, gt = Object.getOwnPropertyDescriptor, Be = Object.getOwnPropertyNames, wt = Object.getPrototypeOf, xt = Object.prototype.hasOwnProperty, T = (e, t) => function() {
3
+ return t || (0, e[Be(e)[0]])((t = { exports: {} }).exports, t), t.exports;
4
+ }, St = (e, t, r, n) => {
5
+ if (t && typeof t == "object" || typeof t == "function") for (var o = Be(t), i = 0, c = o.length, a; i < c; i++)
6
+ a = o[i], !xt.call(e, a) && a !== r && Ge(e, a, {
7
+ get: ((s) => t[s]).bind(null, a),
8
+ enumerable: !(n = gt(t, a)) || n.enumerable
9
+ });
10
+ return e;
11
+ }, S = (e, t, r) => (r = e != null ? bt(wt(e)) : {}, St(Ge(r, "default", {
12
+ value: e,
13
+ enumerable: !0
14
+ }), e)), Fe = T({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/typeof.js"(e, t) {
15
+ function r(n) {
16
+ "@babel/helpers - typeof";
17
+ return t.exports = r = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(o) {
18
+ return typeof o;
19
+ } : function(o) {
20
+ return o && typeof Symbol == "function" && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
21
+ }, t.exports.__esModule = !0, t.exports.default = t.exports, r(n);
22
+ }
23
+ t.exports = r, t.exports.__esModule = !0, t.exports.default = t.exports;
24
+ } }), _t = T({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPrimitive.js"(e, t) {
25
+ var r = Fe().default;
26
+ function n(o, i) {
27
+ if (r(o) != "object" || !o) return o;
28
+ var c = o[Symbol.toPrimitive];
29
+ if (c !== void 0) {
30
+ var a = c.call(o, i || "default");
31
+ if (r(a) != "object") return a;
32
+ throw new TypeError("@@toPrimitive must return a primitive value.");
33
+ }
34
+ return (i === "string" ? String : Number)(o);
35
+ }
36
+ t.exports = n, t.exports.__esModule = !0, t.exports.default = t.exports;
37
+ } }), Pt = T({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPropertyKey.js"(e, t) {
38
+ var r = Fe().default, n = _t();
39
+ function o(i) {
40
+ var c = n(i, "string");
41
+ return r(c) == "symbol" ? c : c + "";
42
+ }
43
+ t.exports = o, t.exports.__esModule = !0, t.exports.default = t.exports;
44
+ } }), D = T({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/defineProperty.js"(e, t) {
45
+ var r = Pt();
46
+ function n(o, i, c) {
47
+ return (i = r(i)) in o ? Object.defineProperty(o, i, {
48
+ value: c,
49
+ enumerable: !0,
50
+ configurable: !0,
51
+ writable: !0
52
+ }) : o[i] = c, o;
53
+ }
54
+ t.exports = n, t.exports.__esModule = !0, t.exports.default = t.exports;
55
+ } }), k = T({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/objectSpread2.js"(e, t) {
56
+ var r = D();
57
+ function n(i, c) {
58
+ var a = Object.keys(i);
59
+ if (Object.getOwnPropertySymbols) {
60
+ var s = Object.getOwnPropertySymbols(i);
61
+ c && (s = s.filter(function(u) {
62
+ return Object.getOwnPropertyDescriptor(i, u).enumerable;
63
+ })), a.push.apply(a, s);
64
+ }
65
+ return a;
66
+ }
67
+ function o(i) {
68
+ for (var c = 1; c < arguments.length; c++) {
69
+ var a = arguments[c] != null ? arguments[c] : {};
70
+ c % 2 ? n(Object(a), !0).forEach(function(s) {
71
+ r(i, s, a[s]);
72
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(i, Object.getOwnPropertyDescriptors(a)) : n(Object(a)).forEach(function(s) {
73
+ Object.defineProperty(i, s, Object.getOwnPropertyDescriptor(a, s));
74
+ });
75
+ }
76
+ return i;
77
+ }
78
+ t.exports = o, t.exports.__esModule = !0, t.exports.default = t.exports;
79
+ } });
80
+ function E(e) {
81
+ const t = {
82
+ subscribe(r) {
83
+ let n = null, o = !1, i = !1, c = !1;
84
+ function a() {
85
+ if (n === null) {
86
+ c = !0;
87
+ return;
88
+ }
89
+ i || (i = !0, typeof n == "function" ? n() : n && n.unsubscribe());
90
+ }
91
+ return n = e({
92
+ next(s) {
93
+ var u;
94
+ o || (u = r.next) === null || u === void 0 || u.call(r, s);
95
+ },
96
+ error(s) {
97
+ var u;
98
+ o || (o = !0, (u = r.error) === null || u === void 0 || u.call(r, s), a());
99
+ },
100
+ complete() {
101
+ var s;
102
+ o || (o = !0, (s = r.complete) === null || s === void 0 || s.call(r), a());
103
+ }
104
+ }), c && a(), { unsubscribe: a };
105
+ },
106
+ pipe(...r) {
107
+ return r.reduce(Et, t);
108
+ }
109
+ };
110
+ return t;
111
+ }
112
+ function Et(e, t) {
113
+ return t(e);
114
+ }
115
+ function jt(e) {
116
+ const t = new AbortController();
117
+ return new Promise((n, o) => {
118
+ let i = !1;
119
+ function c() {
120
+ i || (i = !0, a.unsubscribe());
121
+ }
122
+ t.signal.addEventListener("abort", () => {
123
+ o(t.signal.reason);
124
+ });
125
+ const a = e.subscribe({
126
+ next(s) {
127
+ i = !0, n(s), c();
128
+ },
129
+ error(s) {
130
+ o(s);
131
+ },
132
+ complete() {
133
+ t.abort(), c();
134
+ }
135
+ });
136
+ });
137
+ }
138
+ function Ot(e) {
139
+ return (t) => {
140
+ let r = 0, n = null;
141
+ const o = [];
142
+ function i() {
143
+ n || (n = t.subscribe({
144
+ next(a) {
145
+ for (const u of o) {
146
+ var s;
147
+ (s = u.next) === null || s === void 0 || s.call(u, a);
148
+ }
149
+ },
150
+ error(a) {
151
+ for (const u of o) {
152
+ var s;
153
+ (s = u.error) === null || s === void 0 || s.call(u, a);
154
+ }
155
+ },
156
+ complete() {
157
+ for (const s of o) {
158
+ var a;
159
+ (a = s.complete) === null || a === void 0 || a.call(s);
160
+ }
161
+ }
162
+ }));
163
+ }
164
+ function c() {
165
+ if (r === 0 && n) {
166
+ const a = n;
167
+ n = null, a.unsubscribe();
168
+ }
169
+ }
170
+ return E((a) => (r++, o.push(a), i(), { unsubscribe() {
171
+ r--, c();
172
+ const s = o.findIndex((u) => u === a);
173
+ s > -1 && o.splice(s, 1);
174
+ } }));
175
+ };
176
+ }
177
+ function kt(e) {
178
+ return (t) => E((r) => t.subscribe({
179
+ next(n) {
180
+ var o;
181
+ (o = e.next) === null || o === void 0 || o.call(e, n), r.next(n);
182
+ },
183
+ error(n) {
184
+ var o;
185
+ (o = e.error) === null || o === void 0 || o.call(e, n), r.error(n);
186
+ },
187
+ complete() {
188
+ var n;
189
+ (n = e.complete) === null || n === void 0 || n.call(e), r.complete();
190
+ }
191
+ }));
192
+ }
193
+ function se(e) {
194
+ let t = e;
195
+ const r = [], n = (c) => {
196
+ t !== void 0 && c.next(t), r.push(c);
197
+ }, o = (c) => {
198
+ r.splice(r.indexOf(c), 1);
199
+ }, i = E((c) => (n(c), () => {
200
+ o(c);
201
+ }));
202
+ return i.next = (c) => {
203
+ if (t !== c) {
204
+ t = c;
205
+ for (const a of r) a.next(c);
206
+ }
207
+ }, i.get = () => t, i;
208
+ }
209
+ function He(e) {
210
+ return E((t) => {
211
+ function r(o = 0, i = e.op) {
212
+ const c = e.links[o];
213
+ if (!c) throw new Error("No more links to execute - did you forget to add an ending link?");
214
+ return c({
215
+ op: i,
216
+ next(s) {
217
+ return r(o + 1, s);
218
+ }
219
+ });
220
+ }
221
+ return r().subscribe(t);
222
+ });
223
+ }
224
+ function Se(e) {
225
+ return Array.isArray(e) ? e : [e];
226
+ }
227
+ function Xr(e) {
228
+ return (t) => {
229
+ const r = Se(e.true).map((o) => o(t)), n = Se(e.false).map((o) => o(t));
230
+ return (o) => E((i) => {
231
+ const c = e.condition(o.op) ? r : n;
232
+ return He({
233
+ op: o.op,
234
+ links: c
235
+ }).subscribe(i);
236
+ });
237
+ };
238
+ }
239
+ var _e = w(ze()), Rt = class extends Error {
240
+ constructor(e) {
241
+ super(Tt(e)), Object.assign(this, e);
242
+ }
243
+ };
244
+ function Tt(e) {
245
+ if ("message" in e) return String(e.message);
246
+ }
247
+ function qt(e) {
248
+ if (e instanceof Error) return e;
249
+ const t = typeof e;
250
+ if (!(t === "undefined" || t === "function" || e === null)) {
251
+ if (t !== "object") return new Error(String(e));
252
+ if (M(e)) return new Rt(e);
253
+ }
254
+ }
255
+ function ae(e) {
256
+ if (e instanceof te || e instanceof Error && e.name === "TRPCError") return e;
257
+ const t = new te({
258
+ code: "INTERNAL_SERVER_ERROR",
259
+ cause: e
260
+ });
261
+ return e instanceof Error && e.stack && (t.stack = e.stack), t;
262
+ }
263
+ var te = class extends Error {
264
+ constructor(e) {
265
+ var t, r, n;
266
+ const o = qt(e.cause), i = (t = (r = e.message) !== null && r !== void 0 ? r : o?.message) !== null && t !== void 0 ? t : e.code;
267
+ super(i, { cause: o }), (0, _e.default)(this, "cause", void 0), (0, _e.default)(this, "code", void 0), this.code = e.code, this.name = "TRPCError", (n = this.cause) !== null && n !== void 0 || (this.cause = o);
268
+ }
269
+ }, K = w(oe());
270
+ function At(e, t) {
271
+ if ("error" in e) {
272
+ const n = t.deserialize(e.error);
273
+ return {
274
+ ok: !1,
275
+ error: (0, K.default)((0, K.default)({}, e), {}, { error: n })
276
+ };
277
+ }
278
+ return {
279
+ ok: !0,
280
+ result: (0, K.default)((0, K.default)({}, e.result), (!e.result.type || e.result.type === "data") && {
281
+ type: "data",
282
+ data: t.deserialize(e.result.data)
283
+ })
284
+ };
285
+ }
286
+ var ce = class extends Error {
287
+ constructor() {
288
+ super("Unable to transform response from server");
289
+ }
290
+ };
291
+ function he(e, t) {
292
+ let r;
293
+ try {
294
+ r = At(e, t);
295
+ } catch {
296
+ throw new ce();
297
+ }
298
+ if (!r.ok && (!M(r.error.error) || typeof r.error.error.code != "number")) throw new ce();
299
+ if (r.ok && !M(r.result)) throw new ce();
300
+ return r;
301
+ }
302
+ w(oe());
303
+ function Ct(e) {
304
+ return typeof e == "function";
305
+ }
306
+ async function Mt(e, t) {
307
+ const { _def: r } = e;
308
+ let n = r.procedures[t];
309
+ for (; !n; ) {
310
+ const o = Object.keys(r.lazy).find((c) => t.startsWith(c));
311
+ if (!o) return null;
312
+ await r.lazy[o].load(), n = r.procedures[t];
313
+ }
314
+ return n;
315
+ }
316
+ async function It(e) {
317
+ const { type: t, path: r } = e, n = await Mt(e.router, r);
318
+ if (!n || !Ct(n) || n._def.type !== t && !e.allowMethodOverride) throw new te({
319
+ code: "NOT_FOUND",
320
+ message: `No "${t}"-procedure on path "${r}"`
321
+ });
322
+ /* istanbul ignore if -- @preserve */
323
+ if (n._def.type !== t && e.allowMethodOverride && n._def.type === "subscription") throw new te({
324
+ code: "METHOD_NOT_SUPPORTED",
325
+ message: "Method override is not supported for subscriptions"
326
+ });
327
+ return n(e);
328
+ }
329
+ const Lt = Symbol();
330
+ function Dt(e) {
331
+ return Array.isArray(e) && e[2] === Lt;
332
+ }
333
+ w(oe());
334
+ function Pe(e) {
335
+ return M(e) && e.name === "AbortError";
336
+ }
337
+ var V = w(ze());
338
+ let Je;
339
+ const ue = /* @__PURE__ */ new WeakMap(), Nt = () => {
340
+ };
341
+ Je = Symbol.toStringTag;
342
+ var Ye = class C {
343
+ constructor(t) {
344
+ (0, V.default)(this, "promise", void 0), (0, V.default)(this, "subscribers", []), (0, V.default)(this, "settlement", null), (0, V.default)(this, Je, "Unpromise"), typeof t == "function" ? this.promise = new Promise(t) : this.promise = t;
345
+ const r = this.promise.then((n) => {
346
+ const { subscribers: o } = this;
347
+ this.subscribers = null, this.settlement = {
348
+ status: "fulfilled",
349
+ value: n
350
+ }, o?.forEach(({ resolve: i }) => {
351
+ i(n);
352
+ });
353
+ });
354
+ "catch" in r && r.catch((n) => {
355
+ const { subscribers: o } = this;
356
+ this.subscribers = null, this.settlement = {
357
+ status: "rejected",
358
+ reason: n
359
+ }, o?.forEach(({ reject: i }) => {
360
+ i(n);
361
+ });
362
+ });
363
+ }
364
+ /** Create a promise that mitigates uncontrolled subscription to a long-lived
365
+ * Promise via .then() and .catch() - otherwise a source of memory leaks.
366
+ *
367
+ * The returned promise has an `unsubscribe()` method which can be called when
368
+ * the Promise is no longer being tracked by application logic, and which
369
+ * ensures that there is no reference chain from the original promise to the
370
+ * new one, and therefore no memory leak.
371
+ *
372
+ * If original promise has not yet settled, this adds a new unique promise
373
+ * that listens to then/catch events, along with an `unsubscribe()` method to
374
+ * detach it.
375
+ *
376
+ * If original promise has settled, then creates a new Promise.resolve() or
377
+ * Promise.reject() and provided unsubscribe is a noop.
378
+ *
379
+ * If you call `unsubscribe()` before the returned Promise has settled, it
380
+ * will never settle.
381
+ */
382
+ subscribe() {
383
+ let t, r;
384
+ const { settlement: n } = this;
385
+ if (n === null) {
386
+ if (this.subscribers === null) throw new Error("Unpromise settled but still has subscribers");
387
+ const o = $t();
388
+ this.subscribers = zt(this.subscribers, o), t = o.promise, r = () => {
389
+ this.subscribers !== null && (this.subscribers = Gt(this.subscribers, o));
390
+ };
391
+ } else {
392
+ const { status: o } = n;
393
+ o === "fulfilled" ? t = Promise.resolve(n.value) : t = Promise.reject(n.reason), r = Nt;
394
+ }
395
+ return Object.assign(t, { unsubscribe: r });
396
+ }
397
+ /** STANDARD PROMISE METHODS (but returning a SubscribedPromise) */
398
+ then(t, r) {
399
+ const n = this.subscribe(), { unsubscribe: o } = n;
400
+ return Object.assign(n.then(t, r), { unsubscribe: o });
401
+ }
402
+ catch(t) {
403
+ const r = this.subscribe(), { unsubscribe: n } = r;
404
+ return Object.assign(r.catch(t), { unsubscribe: n });
405
+ }
406
+ finally(t) {
407
+ const r = this.subscribe(), { unsubscribe: n } = r;
408
+ return Object.assign(r.finally(t), { unsubscribe: n });
409
+ }
410
+ /** Unpromise STATIC METHODS */
411
+ /** Create or Retrieve the proxy Unpromise (a re-used Unpromise for the VM lifetime
412
+ * of the provided Promise reference) */
413
+ static proxy(t) {
414
+ const r = C.getSubscribablePromise(t);
415
+ return typeof r < "u" ? r : C.createSubscribablePromise(t);
416
+ }
417
+ /** Create and store an Unpromise keyed by an original Promise. */
418
+ static createSubscribablePromise(t) {
419
+ const r = new C(t);
420
+ return ue.set(t, r), ue.set(r, r), r;
421
+ }
422
+ /** Retrieve a previously-created Unpromise keyed by an original Promise. */
423
+ static getSubscribablePromise(t) {
424
+ return ue.get(t);
425
+ }
426
+ /** Promise STATIC METHODS */
427
+ /** Lookup the Unpromise for this promise, and derive a SubscribedPromise from
428
+ * it (that can be later unsubscribed to eliminate Memory leaks) */
429
+ static resolve(t) {
430
+ const r = typeof t == "object" && t !== null && "then" in t && typeof t.then == "function" ? t : Promise.resolve(t);
431
+ return C.proxy(r).subscribe();
432
+ }
433
+ static async any(t) {
434
+ const n = (Array.isArray(t) ? t : [...t]).map(C.resolve);
435
+ try {
436
+ return await Promise.any(n);
437
+ } finally {
438
+ n.forEach(({ unsubscribe: o }) => {
439
+ o();
440
+ });
441
+ }
442
+ }
443
+ static async race(t) {
444
+ const n = (Array.isArray(t) ? t : [...t]).map(C.resolve);
445
+ try {
446
+ return await Promise.race(n);
447
+ } finally {
448
+ n.forEach(({ unsubscribe: o }) => {
449
+ o();
450
+ });
451
+ }
452
+ }
453
+ /** Create a race of SubscribedPromises that will fulfil to a single winning
454
+ * Promise (in a 1-Tuple). Eliminates memory leaks from long-lived promises
455
+ * accumulating .then() and .catch() subscribers. Allows simple logic to
456
+ * consume the result, like...
457
+ * ```ts
458
+ * const [ winner ] = await Unpromise.race([ promiseA, promiseB ]);
459
+ * if(winner === promiseB){
460
+ * const result = await promiseB;
461
+ * // do the thing
462
+ * }
463
+ * ```
464
+ * */
465
+ static async raceReferences(t) {
466
+ const r = t.map(Ut);
467
+ try {
468
+ return await Promise.race(r);
469
+ } finally {
470
+ for (const n of r) n.unsubscribe();
471
+ }
472
+ }
473
+ };
474
+ function Ut(e) {
475
+ return Ye.proxy(e).then(() => [e]);
476
+ }
477
+ function $t() {
478
+ let e, t;
479
+ return {
480
+ promise: new Promise((n, o) => {
481
+ e = n, t = o;
482
+ }),
483
+ resolve: e,
484
+ reject: t
485
+ };
486
+ }
487
+ function zt(e, t) {
488
+ return [...e, t];
489
+ }
490
+ function Wt(e, t) {
491
+ return [...e.slice(0, t), ...e.slice(t + 1)];
492
+ }
493
+ function Gt(e, t) {
494
+ const r = e.indexOf(t);
495
+ return r !== -1 ? Wt(e, r) : e;
496
+ }
497
+ var Ee, je, Oe, ke;
498
+ (je = (Ee = Symbol).dispose) !== null && je !== void 0 || (Ee.dispose = Symbol());
499
+ (ke = (Oe = Symbol).asyncDispose) !== null && ke !== void 0 || (Oe.asyncDispose = Symbol());
500
+ function re(e, t) {
501
+ const r = e, n = r[Symbol.dispose];
502
+ return r[Symbol.dispose] = () => {
503
+ t(), n?.();
504
+ }, r;
505
+ }
506
+ function Ke(e, t) {
507
+ const r = e, n = r[Symbol.asyncDispose];
508
+ return r[Symbol.asyncDispose] = async () => {
509
+ await t(), await n?.();
510
+ }, r;
511
+ }
512
+ const Ve = Symbol();
513
+ function Bt(e) {
514
+ let t = null;
515
+ return re({ start() {
516
+ if (t) throw new Error("Timer already started");
517
+ return new Promise((n) => {
518
+ t = setTimeout(() => n(Ve), e);
519
+ });
520
+ } }, () => {
521
+ t && clearTimeout(t);
522
+ });
523
+ }
524
+ var H = W({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/usingCtx.js"(e, t) {
525
+ function r() {
526
+ var n = typeof SuppressedError == "function" ? SuppressedError : function(a, s) {
527
+ var u = Error();
528
+ return u.name = "SuppressedError", u.error = a, u.suppressed = s, u;
529
+ }, o = {}, i = [];
530
+ function c(a, s) {
531
+ if (s != null) {
532
+ if (Object(s) !== s) throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");
533
+ if (a) var u = s[Symbol.asyncDispose || Symbol.for("Symbol.asyncDispose")];
534
+ if (u === void 0 && (u = s[Symbol.dispose || Symbol.for("Symbol.dispose")], a)) var l = u;
535
+ if (typeof u != "function") throw new TypeError("Object is not disposable.");
536
+ l && (u = function() {
537
+ try {
538
+ l.call(s);
539
+ } catch (f) {
540
+ return Promise.reject(f);
541
+ }
542
+ }), i.push({
543
+ v: s,
544
+ d: u,
545
+ a
546
+ });
547
+ } else a && i.push({
548
+ d: s,
549
+ a
550
+ });
551
+ return s;
552
+ }
553
+ return {
554
+ e: o,
555
+ u: c.bind(null, !1),
556
+ a: c.bind(null, !0),
557
+ d: function() {
558
+ var s, u = this.e, l = 0;
559
+ function d() {
560
+ for (; s = i.pop(); ) try {
561
+ if (!s.a && l === 1) return l = 0, i.push(s), Promise.resolve().then(d);
562
+ if (s.d) {
563
+ var p = s.d.call(s.v);
564
+ if (s.a) return l |= 2, Promise.resolve(p).then(d, f);
565
+ } else l |= 1;
566
+ } catch (h) {
567
+ return f(h);
568
+ }
569
+ if (l === 1) return u !== o ? Promise.reject(u) : Promise.resolve();
570
+ if (u !== o) throw u;
571
+ }
572
+ function f(p) {
573
+ return u = u !== o ? new n(p, u) : p, d();
574
+ }
575
+ return d();
576
+ }
577
+ };
578
+ }
579
+ t.exports = r, t.exports.__esModule = !0, t.exports.default = t.exports;
580
+ } }), ye = W({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/OverloadYield.js"(e, t) {
581
+ function r(n, o) {
582
+ this.v = n, this.k = o;
583
+ }
584
+ t.exports = r, t.exports.__esModule = !0, t.exports.default = t.exports;
585
+ } }), J = W({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/awaitAsyncGenerator.js"(e, t) {
586
+ var r = ye();
587
+ function n(o) {
588
+ return new r(o, 0);
589
+ }
590
+ t.exports = n, t.exports.__esModule = !0, t.exports.default = t.exports;
591
+ } }), G = W({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/wrapAsyncGenerator.js"(e, t) {
592
+ var r = ye();
593
+ function n(i) {
594
+ return function() {
595
+ return new o(i.apply(this, arguments));
596
+ };
597
+ }
598
+ function o(i) {
599
+ var c, a;
600
+ function s(l, d) {
601
+ try {
602
+ var f = i[l](d), p = f.value, h = p instanceof r;
603
+ Promise.resolve(h ? p.v : p).then(function(m) {
604
+ if (h) {
605
+ var v = l === "return" ? "return" : "next";
606
+ if (!p.k || m.done) return s(v, m);
607
+ m = i[v](m).value;
608
+ }
609
+ u(f.done ? "return" : "normal", m);
610
+ }, function(m) {
611
+ s("throw", m);
612
+ });
613
+ } catch (m) {
614
+ u("throw", m);
615
+ }
616
+ }
617
+ function u(l, d) {
618
+ switch (l) {
619
+ case "return":
620
+ c.resolve({
621
+ value: d,
622
+ done: !0
623
+ });
624
+ break;
625
+ case "throw":
626
+ c.reject(d);
627
+ break;
628
+ default:
629
+ c.resolve({
630
+ value: d,
631
+ done: !1
632
+ });
633
+ }
634
+ (c = c.next) ? s(c.key, c.arg) : a = null;
635
+ }
636
+ this._invoke = function(l, d) {
637
+ return new Promise(function(f, p) {
638
+ var h = {
639
+ key: l,
640
+ arg: d,
641
+ resolve: f,
642
+ reject: p,
643
+ next: null
644
+ };
645
+ a ? a = a.next = h : (c = a = h, s(l, d));
646
+ });
647
+ }, typeof i.return != "function" && (this.return = void 0);
648
+ }
649
+ o.prototype[typeof Symbol == "function" && Symbol.asyncIterator || "@@asyncIterator"] = function() {
650
+ return this;
651
+ }, o.prototype.next = function(i) {
652
+ return this._invoke("next", i);
653
+ }, o.prototype.throw = function(i) {
654
+ return this._invoke("throw", i);
655
+ }, o.prototype.return = function(i) {
656
+ return this._invoke("return", i);
657
+ }, t.exports = n, t.exports.__esModule = !0, t.exports.default = t.exports;
658
+ } });
659
+ w(H());
660
+ w(J());
661
+ w(G());
662
+ function Re(e) {
663
+ const t = e[Symbol.asyncIterator]();
664
+ return t[Symbol.asyncDispose] ? t : Ke(t, async () => {
665
+ var r;
666
+ await ((r = t.return) === null || r === void 0 ? void 0 : r.call(t));
667
+ });
668
+ }
669
+ function Ft() {
670
+ let e, t;
671
+ return {
672
+ promise: new Promise((n, o) => {
673
+ e = n, t = o;
674
+ }),
675
+ resolve: e,
676
+ reject: t
677
+ };
678
+ }
679
+ w(H());
680
+ w(J());
681
+ w(G());
682
+ w(H());
683
+ w(J());
684
+ w(G());
685
+ var Ze = W({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/asyncIterator.js"(e, t) {
686
+ function r(o) {
687
+ var i, c, a, s = 2;
688
+ for (typeof Symbol < "u" && (c = Symbol.asyncIterator, a = Symbol.iterator); s--; ) {
689
+ if (c && (i = o[c]) != null) return i.call(o);
690
+ if (a && (i = o[a]) != null) return new n(i.call(o));
691
+ c = "@@asyncIterator", a = "@@iterator";
692
+ }
693
+ throw new TypeError("Object is not async iterable");
694
+ }
695
+ function n(o) {
696
+ function i(c) {
697
+ if (Object(c) !== c) return Promise.reject(new TypeError(c + " is not an object."));
698
+ var a = c.done;
699
+ return Promise.resolve(c.value).then(function(s) {
700
+ return {
701
+ value: s,
702
+ done: a
703
+ };
704
+ });
705
+ }
706
+ return n = function(a) {
707
+ this.s = a, this.n = a.next;
708
+ }, n.prototype = {
709
+ s: null,
710
+ n: null,
711
+ next: function() {
712
+ return i(this.n.apply(this.s, arguments));
713
+ },
714
+ return: function(a) {
715
+ var s = this.s.return;
716
+ return s === void 0 ? Promise.resolve({
717
+ value: a,
718
+ done: !0
719
+ }) : i(s.apply(this.s, arguments));
720
+ },
721
+ throw: function(a) {
722
+ var s = this.s.return;
723
+ return s === void 0 ? Promise.reject(a) : i(s.apply(this.s, arguments));
724
+ }
725
+ }, new n(o);
726
+ }
727
+ t.exports = r, t.exports.__esModule = !0, t.exports.default = t.exports;
728
+ } }), Ht = w(J()), Jt = w(G()), Te = w(H());
729
+ w(Ze());
730
+ const Yt = 0, Kt = 1, Vt = 0, Zt = 1, Qt = 0, Xt = 1, er = 2;
731
+ var qe = class extends Error {
732
+ constructor(e) {
733
+ super("Received error from server"), this.data = e;
734
+ }
735
+ };
736
+ const tr = (e) => ({ getReader() {
737
+ return new ReadableStream({ start(r) {
738
+ e.on("data", (n) => {
739
+ r.enqueue(n);
740
+ }), e.on("end", () => {
741
+ r.close();
742
+ }), e.on("error", (n) => {
743
+ r.error(n);
744
+ });
745
+ } }).getReader();
746
+ } });
747
+ function rr(e) {
748
+ const t = "getReader" in e ? e.getReader() : tr(e).getReader();
749
+ let r = "";
750
+ return new ReadableStream({
751
+ async pull(n) {
752
+ const { done: o, value: i } = await t.read();
753
+ o ? n.close() : n.enqueue(i);
754
+ },
755
+ cancel() {
756
+ return t.cancel();
757
+ }
758
+ }).pipeThrough(new TextDecoderStream()).pipeThrough(new TransformStream({ transform(n, o) {
759
+ var i;
760
+ r += n;
761
+ const c = r.split(`
762
+ `);
763
+ r = (i = c.pop()) !== null && i !== void 0 ? i : "";
764
+ for (const a of c) o.enqueue(a);
765
+ } }));
766
+ }
767
+ function nr(e) {
768
+ const t = rr(e);
769
+ let r = !1;
770
+ return t.pipeThrough(new TransformStream({ transform(n, o) {
771
+ if (r) {
772
+ const i = JSON.parse(n);
773
+ o.enqueue(i);
774
+ } else {
775
+ const i = JSON.parse(n);
776
+ o.enqueue(i), r = !0;
777
+ }
778
+ } }));
779
+ }
780
+ function or(e) {
781
+ const t = /* @__PURE__ */ new Map();
782
+ function r() {
783
+ return Array.from(t.values()).every((a) => a.closed);
784
+ }
785
+ function n() {
786
+ let a;
787
+ const s = new ReadableStream({ start(d) {
788
+ a = d;
789
+ } }), u = {
790
+ enqueue: (d) => a.enqueue(d),
791
+ close: () => {
792
+ a.close(), l(), r() && e.abort();
793
+ },
794
+ closed: !1,
795
+ getReaderResource: () => {
796
+ const d = s.getReader();
797
+ return re(d, () => {
798
+ u.close(), d.releaseLock();
799
+ });
800
+ },
801
+ error: (d) => {
802
+ a.error(d), l();
803
+ }
804
+ };
805
+ function l() {
806
+ Object.assign(u, {
807
+ closed: !0,
808
+ close: () => {
809
+ },
810
+ enqueue: () => {
811
+ },
812
+ getReaderResource: null,
813
+ error: () => {
814
+ }
815
+ });
816
+ }
817
+ return u;
818
+ }
819
+ function o(a) {
820
+ let s = t.get(a);
821
+ return s || (s = n(), t.set(a, s)), s;
822
+ }
823
+ function i(a) {
824
+ for (const s of t.values()) s.error(a);
825
+ }
826
+ function c() {
827
+ for (const a of t.values()) a.close();
828
+ }
829
+ return {
830
+ getOrCreate: o,
831
+ cancelAll: i,
832
+ closeAll: c
833
+ };
834
+ }
835
+ async function sr(e) {
836
+ const { deserialize: t = (u) => u } = e;
837
+ let r = nr(e.from);
838
+ t && (r = r.pipeThrough(new TransformStream({ transform(u, l) {
839
+ l.enqueue(t(u));
840
+ } })));
841
+ let n = Ft();
842
+ const o = or(e.abortController);
843
+ function i(u) {
844
+ const [l, d, f] = u, p = o.getOrCreate(f);
845
+ switch (d) {
846
+ case Yt:
847
+ return I(async () => {
848
+ try {
849
+ var h = (0, Te.default)();
850
+ const x = h.u(p.getReaderResource()), { value: g } = await x.read(), [b, j, y] = g;
851
+ switch (j) {
852
+ case Vt:
853
+ return c(y);
854
+ case Zt:
855
+ var m, v;
856
+ throw (m = (v = e.formatError) === null || v === void 0 ? void 0 : v.call(e, { error: y })) !== null && m !== void 0 ? m : new qe(y);
857
+ }
858
+ } catch (x) {
859
+ h.e = x;
860
+ } finally {
861
+ h.d();
862
+ }
863
+ });
864
+ case Kt:
865
+ return I((0, Jt.default)(function* () {
866
+ try {
867
+ var h = (0, Te.default)();
868
+ const x = h.u(p.getReaderResource());
869
+ for (; ; ) {
870
+ const { value: g } = yield (0, Ht.default)(x.read()), [b, j, y] = g;
871
+ switch (j) {
872
+ case Xt:
873
+ yield c(y);
874
+ break;
875
+ case Qt:
876
+ return c(y);
877
+ case er:
878
+ var m, v;
879
+ throw (m = (v = e.formatError) === null || v === void 0 ? void 0 : v.call(e, { error: y })) !== null && m !== void 0 ? m : new qe(y);
880
+ }
881
+ }
882
+ } catch (x) {
883
+ h.e = x;
884
+ } finally {
885
+ h.d();
886
+ }
887
+ }));
888
+ }
889
+ }
890
+ function c(u) {
891
+ const [[l], ...d] = u;
892
+ for (const f of d) {
893
+ const [p] = f, h = i(f);
894
+ if (p === null) return h;
895
+ l[p] = h;
896
+ }
897
+ return l;
898
+ }
899
+ const a = () => {
900
+ n && (n.reject(new Error("Stream closed before head was received")), n = null), o.closeAll();
901
+ }, s = (u) => {
902
+ n?.reject(u), n = null, o.cancelAll(u);
903
+ };
904
+ return r.pipeTo(new WritableStream({
905
+ write(u) {
906
+ if (n) {
907
+ const p = u;
908
+ for (const [h, m] of Object.entries(u)) {
909
+ const v = c(m);
910
+ p[h] = v;
911
+ }
912
+ n.resolve(p), n = null;
913
+ return;
914
+ }
915
+ const l = u, [d] = l;
916
+ o.getOrCreate(d).enqueue(l);
917
+ },
918
+ close: a,
919
+ abort: s
920
+ })).catch((u) => {
921
+ var l;
922
+ (l = e.onError) === null || l === void 0 || l.call(e, { error: u }), s(u);
923
+ }), [await n.promise];
924
+ }
925
+ var ir = W({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/asyncGeneratorDelegate.js"(e, t) {
926
+ var r = ye();
927
+ function n(o) {
928
+ var i = {}, c = !1;
929
+ function a(s, u) {
930
+ return c = !0, u = new Promise(function(l) {
931
+ l(o[s](u));
932
+ }), {
933
+ done: !1,
934
+ value: new r(u, 1)
935
+ };
936
+ }
937
+ return i[typeof Symbol < "u" && Symbol.iterator || "@@iterator"] = function() {
938
+ return this;
939
+ }, i.next = function(s) {
940
+ return c ? (c = !1, s) : a("next", s);
941
+ }, typeof o.throw == "function" && (i.throw = function(s) {
942
+ if (c) throw c = !1, s;
943
+ return a("throw", s);
944
+ }), typeof o.return == "function" && (i.return = function(s) {
945
+ return c ? (c = !1, s) : a("return", s);
946
+ }), i;
947
+ }
948
+ t.exports = n, t.exports.__esModule = !0, t.exports.default = t.exports;
949
+ } });
950
+ w(Ze());
951
+ var Ae = w(J()), ar = w(G());
952
+ w(ir());
953
+ var Qe = w(H());
954
+ const cr = "ping", ur = "serialized-error", lr = "connected", dr = "return";
955
+ async function fr(e) {
956
+ try {
957
+ var t = (0, Qe.default)();
958
+ const r = t.u(Bt(e.timeoutMs)), n = await Ye.race([e.promise, r.start()]);
959
+ return n === Ve ? await e.onTimeout() : n;
960
+ } catch (r) {
961
+ t.e = r;
962
+ } finally {
963
+ t.d();
964
+ }
965
+ }
966
+ function pr(e) {
967
+ const { deserialize: t = (a) => a } = e;
968
+ let r = pt();
969
+ const n = e.signal;
970
+ let o = null;
971
+ const i = () => new ReadableStream({
972
+ async start(a) {
973
+ const [s, u] = await Promise.all([e.url(), e.init()]), l = o = new e.EventSource(s, u);
974
+ a.enqueue({
975
+ type: "connecting",
976
+ eventSource: o,
977
+ event: null
978
+ }), l.addEventListener(lr, (f) => {
979
+ const h = JSON.parse(f.data);
980
+ r = h, a.enqueue({
981
+ type: "connected",
982
+ options: h,
983
+ eventSource: l
984
+ });
985
+ }), l.addEventListener(ur, (f) => {
986
+ const p = f;
987
+ a.enqueue({
988
+ type: "serialized-error",
989
+ error: t(JSON.parse(p.data)),
990
+ eventSource: l
991
+ });
992
+ }), l.addEventListener(cr, () => {
993
+ a.enqueue({
994
+ type: "ping",
995
+ eventSource: l
996
+ });
997
+ }), l.addEventListener(dr, () => {
998
+ l.close(), a.close(), o = null;
999
+ }), l.addEventListener("error", (f) => {
1000
+ l.readyState === l.CLOSED ? a.error(f) : a.enqueue({
1001
+ type: "connecting",
1002
+ eventSource: l,
1003
+ event: f
1004
+ });
1005
+ }), l.addEventListener("message", (f) => {
1006
+ const p = f, m = { data: t(JSON.parse(p.data)) };
1007
+ p.lastEventId && (m.id = p.lastEventId), a.enqueue({
1008
+ type: "data",
1009
+ data: m,
1010
+ eventSource: l
1011
+ });
1012
+ });
1013
+ const d = () => {
1014
+ try {
1015
+ l.close(), a.close();
1016
+ } catch {
1017
+ }
1018
+ };
1019
+ n.aborted ? d() : n.addEventListener("abort", d);
1020
+ },
1021
+ cancel() {
1022
+ o?.close();
1023
+ }
1024
+ }), c = () => {
1025
+ let a = i(), s = a.getReader();
1026
+ async function u() {
1027
+ await s.cancel(), o = null;
1028
+ }
1029
+ return Ke({
1030
+ read() {
1031
+ return s.read();
1032
+ },
1033
+ async recreate() {
1034
+ await u(), a = i(), s = a.getReader();
1035
+ }
1036
+ }, u);
1037
+ };
1038
+ return I((0, ar.default)(function* () {
1039
+ try {
1040
+ var a = (0, Qe.default)();
1041
+ const s = a.a(c());
1042
+ for (; ; ) {
1043
+ let u = s.read();
1044
+ const l = r.reconnectAfterInactivityMs;
1045
+ l && (u = fr({
1046
+ promise: u,
1047
+ timeoutMs: l,
1048
+ onTimeout: async () => {
1049
+ const f = {
1050
+ value: {
1051
+ type: "timeout",
1052
+ ms: l,
1053
+ eventSource: o
1054
+ },
1055
+ done: !1
1056
+ };
1057
+ return await s.recreate(), f;
1058
+ }
1059
+ }));
1060
+ const d = yield (0, Ae.default)(u);
1061
+ if (d.done) return d.value;
1062
+ yield d.value;
1063
+ }
1064
+ } catch (s) {
1065
+ a.e = s;
1066
+ } finally {
1067
+ yield (0, Ae.default)(a.d());
1068
+ }
1069
+ }));
1070
+ }
1071
+ w(G());
1072
+ w(oe());
1073
+ var Z = S(D()), N = S(k());
1074
+ function Xe(e) {
1075
+ return e instanceof _;
1076
+ }
1077
+ function mr(e) {
1078
+ return M(e) && M(e.error) && typeof e.error.code == "number" && typeof e.error.message == "string";
1079
+ }
1080
+ function hr(e, t) {
1081
+ return typeof e == "string" ? e : M(e) && typeof e.message == "string" ? e.message : t;
1082
+ }
1083
+ var _ = class ee extends Error {
1084
+ constructor(t, r) {
1085
+ var n, o;
1086
+ const i = r?.cause;
1087
+ super(t, { cause: i }), (0, Z.default)(this, "cause", void 0), (0, Z.default)(this, "shape", void 0), (0, Z.default)(this, "data", void 0), (0, Z.default)(this, "meta", void 0), this.meta = r?.meta, this.cause = i, this.shape = r == null || (n = r.result) === null || n === void 0 ? void 0 : n.error, this.data = r == null || (o = r.result) === null || o === void 0 ? void 0 : o.error.data, this.name = "TRPCClientError", Object.setPrototypeOf(this, ee.prototype);
1088
+ }
1089
+ static from(t, r = {}) {
1090
+ const n = t;
1091
+ return Xe(n) ? (r.meta && (n.meta = (0, N.default)((0, N.default)({}, n.meta), r.meta)), n) : mr(n) ? new ee(n.error.message, (0, N.default)((0, N.default)({}, r), {}, {
1092
+ result: n,
1093
+ cause: r.cause
1094
+ })) : new ee(hr(n, "Unknown error"), (0, N.default)((0, N.default)({}, r), {}, { cause: n }));
1095
+ }
1096
+ };
1097
+ function ie(e) {
1098
+ const t = e;
1099
+ return t ? "input" in t ? t : {
1100
+ input: t,
1101
+ output: t
1102
+ } : {
1103
+ input: {
1104
+ serialize: (r) => r,
1105
+ deserialize: (r) => r
1106
+ },
1107
+ output: {
1108
+ serialize: (r) => r,
1109
+ deserialize: (r) => r
1110
+ }
1111
+ };
1112
+ }
1113
+ const Ce = (e) => typeof e == "function";
1114
+ function yr(e) {
1115
+ if (e) return e;
1116
+ if (typeof window < "u" && Ce(window.fetch)) return window.fetch;
1117
+ if (typeof globalThis < "u" && Ce(globalThis.fetch)) return globalThis.fetch;
1118
+ throw new Error("No fetch implementation found");
1119
+ }
1120
+ var B = S(k());
1121
+ function ve(e) {
1122
+ return {
1123
+ url: e.url.toString(),
1124
+ fetch: e.fetch,
1125
+ transformer: ie(e.transformer),
1126
+ methodOverride: e.methodOverride
1127
+ };
1128
+ }
1129
+ function vr(e) {
1130
+ const t = {};
1131
+ for (let r = 0; r < e.length; r++) {
1132
+ const n = e[r];
1133
+ t[r] = n;
1134
+ }
1135
+ return t;
1136
+ }
1137
+ const br = {
1138
+ query: "GET",
1139
+ mutation: "POST",
1140
+ subscription: "PATCH"
1141
+ };
1142
+ function et(e) {
1143
+ return "input" in e ? e.transformer.input.serialize(e.input) : vr(e.inputs.map((t) => e.transformer.input.serialize(t)));
1144
+ }
1145
+ const L = (e) => {
1146
+ const t = e.url.split("?");
1147
+ let n = t[0].replace(/\/$/, "") + "/" + e.path;
1148
+ const o = [];
1149
+ if (t[1] && o.push(t[1]), "inputs" in e && o.push("batch=1"), e.type === "query" || e.type === "subscription") {
1150
+ const i = et(e);
1151
+ i !== void 0 && e.methodOverride !== "POST" && o.push(`input=${encodeURIComponent(JSON.stringify(i))}`);
1152
+ }
1153
+ return o.length && (n += "?" + o.join("&")), n;
1154
+ }, tt = (e) => {
1155
+ if (e.type === "query" && e.methodOverride !== "POST") return;
1156
+ const t = et(e);
1157
+ return t !== void 0 ? JSON.stringify(t) : void 0;
1158
+ }, rt = (e) => pe((0, B.default)((0, B.default)({}, e), {}, {
1159
+ contentTypeHeader: "application/json",
1160
+ getUrl: L,
1161
+ getBody: tt
1162
+ }));
1163
+ var gr = class extends Error {
1164
+ constructor() {
1165
+ const e = "AbortError";
1166
+ super(e), this.name = e, this.message = e;
1167
+ }
1168
+ };
1169
+ const wr = (e) => {
1170
+ var t;
1171
+ if (e?.aborted)
1172
+ throw (t = e.throwIfAborted) === null || t === void 0 || t.call(e), typeof DOMException < "u" ? new DOMException("AbortError", "AbortError") : new gr();
1173
+ };
1174
+ async function nt(e) {
1175
+ var t, r;
1176
+ wr(e.signal);
1177
+ const n = e.getUrl(e), o = e.getBody(e), i = (t = e.methodOverride) !== null && t !== void 0 ? t : br[e.type], c = await (async () => {
1178
+ const s = await e.headers();
1179
+ return Symbol.iterator in s ? Object.fromEntries(s) : s;
1180
+ })(), a = (0, B.default)((0, B.default)((0, B.default)({}, e.contentTypeHeader && i !== "GET" ? { "content-type": e.contentTypeHeader } : {}), e.trpcAcceptHeader ? { [(r = e.trpcAcceptHeaderKey) !== null && r !== void 0 ? r : "trpc-accept"]: e.trpcAcceptHeader } : void 0), c);
1181
+ return yr(e.fetch)(n, {
1182
+ method: i,
1183
+ signal: e.signal,
1184
+ body: o,
1185
+ headers: a
1186
+ });
1187
+ }
1188
+ async function pe(e) {
1189
+ const t = {}, r = await nt(e);
1190
+ t.response = r;
1191
+ const n = await r.json();
1192
+ return t.responseJSON = n, {
1193
+ json: n,
1194
+ meta: t
1195
+ };
1196
+ }
1197
+ function ot(e) {
1198
+ return e instanceof Uint8Array || e instanceof Blob;
1199
+ }
1200
+ function st(e) {
1201
+ return e instanceof FormData;
1202
+ }
1203
+ function en(e) {
1204
+ return ot(e) || st(e);
1205
+ }
1206
+ var z = S(k());
1207
+ const xr = (e) => {
1208
+ if ("input" in e) {
1209
+ const { input: t } = e;
1210
+ if (st(t)) {
1211
+ if (e.type !== "mutation" && e.methodOverride !== "POST") throw new Error("FormData is only supported for mutations");
1212
+ return pe((0, z.default)((0, z.default)({}, e), {}, {
1213
+ contentTypeHeader: void 0,
1214
+ getUrl: L,
1215
+ getBody: () => t
1216
+ }));
1217
+ }
1218
+ if (ot(t)) {
1219
+ if (e.type !== "mutation" && e.methodOverride !== "POST") throw new Error("Octet type input is only supported for mutations");
1220
+ return pe((0, z.default)((0, z.default)({}, e), {}, {
1221
+ contentTypeHeader: "application/octet-stream",
1222
+ getUrl: L,
1223
+ getBody: () => t
1224
+ }));
1225
+ }
1226
+ }
1227
+ return rt(e);
1228
+ };
1229
+ function tn(e) {
1230
+ const t = ve(e);
1231
+ return () => (r) => {
1232
+ const { op: n } = r;
1233
+ return E((o) => {
1234
+ const { path: i, input: c, type: a } = n;
1235
+ /* istanbul ignore if -- @preserve */
1236
+ if (a === "subscription") throw new Error("Subscriptions are unsupported by `httpLink` - use `httpSubscriptionLink` or `wsLink`");
1237
+ const s = xr((0, z.default)((0, z.default)({}, t), {}, {
1238
+ type: a,
1239
+ path: i,
1240
+ input: c,
1241
+ signal: n.signal,
1242
+ headers() {
1243
+ return e.headers ? typeof e.headers == "function" ? e.headers({ op: n }) : e.headers : {};
1244
+ }
1245
+ }));
1246
+ let u;
1247
+ return s.then((l) => {
1248
+ u = l.meta;
1249
+ const d = he(l.json, t.transformer.output);
1250
+ if (!d.ok) {
1251
+ o.error(_.from(d.error, { meta: u }));
1252
+ return;
1253
+ }
1254
+ o.next({
1255
+ context: l.meta,
1256
+ result: d.result
1257
+ }), o.complete();
1258
+ }).catch((l) => {
1259
+ o.error(_.from(l, { meta: u }));
1260
+ }), () => {
1261
+ };
1262
+ });
1263
+ };
1264
+ }
1265
+ const Me = () => {
1266
+ throw new Error("Something went wrong. Please submit an issue at https://github.com/trpc/trpc/issues/new");
1267
+ };
1268
+ function ne(e) {
1269
+ let t = null, r = null;
1270
+ const n = () => {
1271
+ clearTimeout(r), r = null, t = null;
1272
+ };
1273
+ function o(a) {
1274
+ const s = [[]];
1275
+ let u = 0;
1276
+ for (; ; ) {
1277
+ const f = a[u];
1278
+ if (!f) break;
1279
+ const p = s[s.length - 1];
1280
+ if (f.aborted) {
1281
+ var l;
1282
+ (l = f.reject) === null || l === void 0 || l.call(f, new Error("Aborted")), u++;
1283
+ continue;
1284
+ }
1285
+ if (e.validate(p.concat(f).map((m) => m.key))) {
1286
+ p.push(f), u++;
1287
+ continue;
1288
+ }
1289
+ if (p.length === 0) {
1290
+ var d;
1291
+ (d = f.reject) === null || d === void 0 || d.call(f, new Error("Input is too big for a single dispatch")), u++;
1292
+ continue;
1293
+ }
1294
+ s.push([]);
1295
+ }
1296
+ return s;
1297
+ }
1298
+ function i() {
1299
+ const a = o(t);
1300
+ n();
1301
+ for (const s of a) {
1302
+ if (!s.length) continue;
1303
+ const u = { items: s };
1304
+ for (const d of s) d.batch = u;
1305
+ e.fetch(u.items.map((d) => d.key)).then(async (d) => {
1306
+ await Promise.all(d.map(async (p, h) => {
1307
+ const m = u.items[h];
1308
+ try {
1309
+ var v;
1310
+ const g = await Promise.resolve(p);
1311
+ (v = m.resolve) === null || v === void 0 || v.call(m, g);
1312
+ } catch (g) {
1313
+ var x;
1314
+ (x = m.reject) === null || x === void 0 || x.call(m, g);
1315
+ }
1316
+ m.batch = null, m.reject = null, m.resolve = null;
1317
+ }));
1318
+ for (const p of u.items) {
1319
+ var f;
1320
+ (f = p.reject) === null || f === void 0 || f.call(p, new Error("Missing result")), p.batch = null;
1321
+ }
1322
+ }).catch((d) => {
1323
+ for (const p of u.items) {
1324
+ var f;
1325
+ (f = p.reject) === null || f === void 0 || f.call(p, d), p.batch = null;
1326
+ }
1327
+ });
1328
+ }
1329
+ }
1330
+ function c(a) {
1331
+ var s;
1332
+ const u = {
1333
+ aborted: !1,
1334
+ key: a,
1335
+ batch: null,
1336
+ resolve: Me,
1337
+ reject: Me
1338
+ }, l = new Promise((d, f) => {
1339
+ var p;
1340
+ u.reject = f, u.resolve = d, (p = t) !== null && p !== void 0 || (t = []), t.push(u);
1341
+ });
1342
+ return (s = r) !== null && s !== void 0 || (r = setTimeout(i)), l;
1343
+ }
1344
+ return { load: c };
1345
+ }
1346
+ function it(...e) {
1347
+ const t = new AbortController(), r = e.length;
1348
+ let n = 0;
1349
+ const o = () => {
1350
+ ++n === r && t.abort();
1351
+ };
1352
+ for (const i of e) i?.aborted ? o() : i?.addEventListener("abort", o, { once: !0 });
1353
+ return t.signal;
1354
+ }
1355
+ function be(...e) {
1356
+ const t = new AbortController();
1357
+ for (const r of e) r?.aborted ? t.abort() : r?.addEventListener("abort", () => t.abort(), { once: !0 });
1358
+ return t.signal;
1359
+ }
1360
+ function Sr(e) {
1361
+ return new Promise((t, r) => {
1362
+ if (e.aborted) {
1363
+ r(e.reason);
1364
+ return;
1365
+ }
1366
+ e.addEventListener("abort", () => {
1367
+ r(e.reason);
1368
+ }, { once: !0 });
1369
+ });
1370
+ }
1371
+ var Q = S(k());
1372
+ function rn(e) {
1373
+ var t, r;
1374
+ const n = ve(e), o = (t = e.maxURLLength) !== null && t !== void 0 ? t : 1 / 0, i = (r = e.maxItems) !== null && r !== void 0 ? r : 1 / 0;
1375
+ return () => {
1376
+ const c = (l) => ({
1377
+ validate(d) {
1378
+ if (o === 1 / 0 && i === 1 / 0) return !0;
1379
+ if (d.length > i) return !1;
1380
+ const f = d.map((m) => m.path).join(","), p = d.map((m) => m.input);
1381
+ return L((0, Q.default)((0, Q.default)({}, n), {}, {
1382
+ type: l,
1383
+ path: f,
1384
+ inputs: p,
1385
+ signal: null
1386
+ })).length <= o;
1387
+ },
1388
+ async fetch(d) {
1389
+ const f = d.map((g) => g.path).join(","), p = d.map((g) => g.input), h = it(...d.map((g) => g.signal)), m = await rt((0, Q.default)((0, Q.default)({}, n), {}, {
1390
+ path: f,
1391
+ inputs: p,
1392
+ type: l,
1393
+ headers() {
1394
+ return e.headers ? typeof e.headers == "function" ? e.headers({ opList: d }) : e.headers : {};
1395
+ },
1396
+ signal: h
1397
+ }));
1398
+ return (Array.isArray(m.json) ? m.json : d.map(() => m.json)).map((g) => ({
1399
+ meta: m.meta,
1400
+ json: g
1401
+ }));
1402
+ }
1403
+ }), a = ne(c("query")), s = ne(c("mutation")), u = {
1404
+ query: a,
1405
+ mutation: s
1406
+ };
1407
+ return ({ op: l }) => E((d) => {
1408
+ /* istanbul ignore if -- @preserve */
1409
+ if (l.type === "subscription") throw new Error("Subscriptions are unsupported by `httpLink` - use `httpSubscriptionLink` or `wsLink`");
1410
+ const p = u[l.type].load(l);
1411
+ let h;
1412
+ return p.then((m) => {
1413
+ h = m;
1414
+ const v = he(m.json, n.transformer.output);
1415
+ if (!v.ok) {
1416
+ d.error(_.from(v.error, { meta: m.meta }));
1417
+ return;
1418
+ }
1419
+ d.next({
1420
+ context: m.meta,
1421
+ result: v.result
1422
+ }), d.complete();
1423
+ }).catch((m) => {
1424
+ d.error(_.from(m, { meta: h?.meta }));
1425
+ }), () => {
1426
+ };
1427
+ });
1428
+ };
1429
+ }
1430
+ var O = S(k());
1431
+ function _r(e) {
1432
+ return typeof FormData > "u" ? !1 : e instanceof FormData;
1433
+ }
1434
+ const le = {
1435
+ css: {
1436
+ query: ["72e3ff", "3fb0d8"],
1437
+ mutation: ["c5a3fc", "904dfc"],
1438
+ subscription: ["ff49e1", "d83fbe"]
1439
+ },
1440
+ ansi: {
1441
+ regular: {
1442
+ query: ["\x1B[30;46m", "\x1B[97;46m"],
1443
+ mutation: ["\x1B[30;45m", "\x1B[97;45m"],
1444
+ subscription: ["\x1B[30;42m", "\x1B[97;42m"]
1445
+ },
1446
+ bold: {
1447
+ query: ["\x1B[1;30;46m", "\x1B[1;97;46m"],
1448
+ mutation: ["\x1B[1;30;45m", "\x1B[1;97;45m"],
1449
+ subscription: ["\x1B[1;30;42m", "\x1B[1;97;42m"]
1450
+ }
1451
+ }
1452
+ };
1453
+ function Pr(e) {
1454
+ const { direction: t, type: r, withContext: n, path: o, id: i, input: c } = e, a = [], s = [];
1455
+ if (e.colorMode === "none") a.push(t === "up" ? ">>" : "<<", r, `#${i}`, o);
1456
+ else if (e.colorMode === "ansi") {
1457
+ const [u, l] = le.ansi.regular[r], [d, f] = le.ansi.bold[r];
1458
+ a.push(t === "up" ? u : l, t === "up" ? ">>" : "<<", r, t === "up" ? d : f, `#${i}`, o, "\x1B[0m");
1459
+ } else {
1460
+ const [u, l] = le.css[r], d = `
1461
+ background-color: #${t === "up" ? u : l};
1462
+ color: ${t === "up" ? "black" : "white"};
1463
+ padding: 2px;
1464
+ `;
1465
+ a.push("%c", t === "up" ? ">>" : "<<", r, `#${i}`, `%c${o}%c`, "%O"), s.push(d, `${d}; font-weight: bold;`, `${d}; font-weight: normal;`);
1466
+ }
1467
+ return t === "up" ? s.push(n ? {
1468
+ input: c,
1469
+ context: e.context
1470
+ } : { input: c }) : s.push((0, O.default)({
1471
+ input: c,
1472
+ result: e.result,
1473
+ elapsedMs: e.elapsedMs
1474
+ }, n && { context: e.context })), {
1475
+ parts: a,
1476
+ args: s
1477
+ };
1478
+ }
1479
+ const Er = ({ c: e = console, colorMode: t = "css", withContext: r }) => (n) => {
1480
+ const o = n.input, i = _r(o) ? Object.fromEntries(o) : o, { parts: c, args: a } = Pr((0, O.default)((0, O.default)({}, n), {}, {
1481
+ colorMode: t,
1482
+ input: i,
1483
+ withContext: r
1484
+ })), s = n.direction === "down" && n.result && (n.result instanceof Error || "error" in n.result.result && n.result.result.error) ? "error" : "log";
1485
+ e[s].apply(null, [c.join(" ")].concat(a));
1486
+ };
1487
+ function nn(e = {}) {
1488
+ var t, r;
1489
+ const { enabled: n = () => !0 } = e, o = (t = e.colorMode) !== null && t !== void 0 ? t : typeof window > "u" ? "ansi" : "css", i = (r = e.withContext) !== null && r !== void 0 ? r : o === "css", { logger: c = Er({
1490
+ c: e.console,
1491
+ colorMode: o,
1492
+ withContext: i
1493
+ }) } = e;
1494
+ return () => ({ op: a, next: s }) => E((u) => {
1495
+ n((0, O.default)((0, O.default)({}, a), {}, { direction: "up" })) && c((0, O.default)((0, O.default)({}, a), {}, { direction: "up" }));
1496
+ const l = Date.now();
1497
+ function d(f) {
1498
+ const p = Date.now() - l;
1499
+ n((0, O.default)((0, O.default)({}, a), {}, {
1500
+ direction: "down",
1501
+ result: f
1502
+ })) && c((0, O.default)((0, O.default)({}, a), {}, {
1503
+ direction: "down",
1504
+ elapsedMs: p,
1505
+ result: f
1506
+ }));
1507
+ }
1508
+ return s(a).pipe(kt({
1509
+ next(f) {
1510
+ d(f);
1511
+ },
1512
+ error(f) {
1513
+ d(f);
1514
+ }
1515
+ })).subscribe(u);
1516
+ });
1517
+ }
1518
+ const jr = {
1519
+ encode: (e) => JSON.stringify(e),
1520
+ decode: (e) => {
1521
+ if (typeof e != "string") throw new Error("jsonEncoder received binary data. JSON uses text frames. Use a binary encoder for binary data.");
1522
+ return JSON.parse(e);
1523
+ }
1524
+ }, Or = {
1525
+ enabled: !1,
1526
+ closeMs: 0
1527
+ }, kr = {
1528
+ enabled: !1,
1529
+ pongTimeoutMs: 1e3,
1530
+ intervalMs: 5e3
1531
+ }, Rr = (e) => e === 0 ? 0 : Math.min(1e3 * 2 ** e, 3e4), F = (e, ...t) => typeof e == "function" ? e(...t) : e;
1532
+ var Tr = S(D()), U = class at extends Error {
1533
+ constructor(t) {
1534
+ super(t.message, { cause: t.cause }), this.name = "TRPCWebSocketClosedError", Object.setPrototypeOf(this, at.prototype);
1535
+ }
1536
+ }, qr = class {
1537
+ constructor(e, t) {
1538
+ this.onTimeout = e, this.timeoutMs = t, (0, Tr.default)(this, "timeout", void 0);
1539
+ }
1540
+ /**
1541
+ * Resets the current timeout, restarting it with the same duration.
1542
+ * Does nothing if no timeout is active.
1543
+ */
1544
+ reset() {
1545
+ this.timeout && (clearTimeout(this.timeout), this.timeout = setTimeout(this.onTimeout, this.timeoutMs));
1546
+ }
1547
+ start() {
1548
+ clearTimeout(this.timeout), this.timeout = setTimeout(this.onTimeout, this.timeoutMs);
1549
+ }
1550
+ stop() {
1551
+ clearTimeout(this.timeout), this.timeout = void 0;
1552
+ }
1553
+ };
1554
+ function ct() {
1555
+ let e, t;
1556
+ return {
1557
+ promise: new Promise((n, o) => {
1558
+ e = n, t = o;
1559
+ }),
1560
+ resolve: e,
1561
+ reject: t
1562
+ };
1563
+ }
1564
+ async function Ar(e) {
1565
+ const t = await F(e.url);
1566
+ if (!e.connectionParams) return t;
1567
+ const n = `${t.includes("?") ? "&" : "?"}connectionParams=1`;
1568
+ return t + n;
1569
+ }
1570
+ async function Cr(e, t) {
1571
+ const r = {
1572
+ method: "connectionParams",
1573
+ data: await F(e)
1574
+ };
1575
+ return t.encode(r);
1576
+ }
1577
+ var Ie = S(D()), Mr = class {
1578
+ constructor() {
1579
+ (0, Ie.default)(this, "outgoingRequests", new Array()), (0, Ie.default)(this, "pendingRequests", {});
1580
+ }
1581
+ /**
1582
+ * Registers a new request by adding it to the outgoing queue and setting up
1583
+ * callbacks for lifecycle events such as completion or error.
1584
+ *
1585
+ * @param message - The outgoing message to be sent.
1586
+ * @param callbacks - Callback functions to observe the request's state.
1587
+ * @returns A cleanup function to manually remove the request.
1588
+ */
1589
+ register(e, t) {
1590
+ const { promise: r, resolve: n } = ct();
1591
+ return this.outgoingRequests.push({
1592
+ id: String(e.id),
1593
+ message: e,
1594
+ end: r,
1595
+ callbacks: {
1596
+ next: t.next,
1597
+ complete: () => {
1598
+ t.complete(), n();
1599
+ },
1600
+ error: (o) => {
1601
+ t.error(o), n();
1602
+ }
1603
+ }
1604
+ }), () => {
1605
+ this.delete(e.id), t.complete(), n();
1606
+ };
1607
+ }
1608
+ /**
1609
+ * Deletes a request from both the outgoing and pending collections, if it exists.
1610
+ */
1611
+ delete(e) {
1612
+ e !== null && (this.outgoingRequests = this.outgoingRequests.filter(({ id: t }) => t !== String(e)), delete this.pendingRequests[String(e)]);
1613
+ }
1614
+ /**
1615
+ * Moves all outgoing requests to the pending state and clears the outgoing queue.
1616
+ *
1617
+ * The caller is expected to handle the actual sending of the requests
1618
+ * (e.g., sending them over the network) after this method is called.
1619
+ *
1620
+ * @returns The list of requests that were transitioned to the pending state.
1621
+ */
1622
+ flush() {
1623
+ const e = this.outgoingRequests;
1624
+ this.outgoingRequests = [];
1625
+ for (const t of e) this.pendingRequests[t.id] = t;
1626
+ return e;
1627
+ }
1628
+ /**
1629
+ * Retrieves all currently pending requests, which are in flight awaiting responses
1630
+ * or handling ongoing subscriptions.
1631
+ */
1632
+ getPendingRequests() {
1633
+ return Object.values(this.pendingRequests);
1634
+ }
1635
+ /**
1636
+ * Retrieves a specific pending request by its message ID.
1637
+ */
1638
+ getPendingRequest(e) {
1639
+ return e === null ? null : this.pendingRequests[String(e)];
1640
+ }
1641
+ /**
1642
+ * Retrieves all outgoing requests, which are waiting to be sent.
1643
+ */
1644
+ getOutgoingRequests() {
1645
+ return this.outgoingRequests;
1646
+ }
1647
+ /**
1648
+ * Retrieves all requests, both outgoing and pending, with their respective states.
1649
+ *
1650
+ * @returns An array of all requests with their state ("outgoing" or "pending").
1651
+ */
1652
+ getRequests() {
1653
+ return [...this.getOutgoingRequests().map((e) => ({
1654
+ state: "outgoing",
1655
+ message: e.message,
1656
+ end: e.end,
1657
+ callbacks: e.callbacks
1658
+ })), ...this.getPendingRequests().map((e) => ({
1659
+ state: "pending",
1660
+ message: e.message,
1661
+ end: e.end,
1662
+ callbacks: e.callbacks
1663
+ }))];
1664
+ }
1665
+ /**
1666
+ * Checks if there are any pending requests, including ongoing subscriptions.
1667
+ */
1668
+ hasPendingRequests() {
1669
+ return this.getPendingRequests().length > 0;
1670
+ }
1671
+ /**
1672
+ * Checks if there are any pending subscriptions
1673
+ */
1674
+ hasPendingSubscriptions() {
1675
+ return this.getPendingRequests().some((e) => e.message.method === "subscription");
1676
+ }
1677
+ /**
1678
+ * Checks if there are any outgoing requests waiting to be sent.
1679
+ */
1680
+ hasOutgoingRequests() {
1681
+ return this.outgoingRequests.length > 0;
1682
+ }
1683
+ }, q = S(D());
1684
+ function Ir(e) {
1685
+ const { promise: t, resolve: r, reject: n } = ct();
1686
+ return e.addEventListener("open", () => {
1687
+ e.removeEventListener("error", n), r();
1688
+ }), e.addEventListener("error", n), t;
1689
+ }
1690
+ function Lr(e, { intervalMs: t, pongTimeoutMs: r }) {
1691
+ let n, o;
1692
+ function i() {
1693
+ n = setTimeout(() => {
1694
+ e.send("PING"), o = setTimeout(() => {
1695
+ e.close();
1696
+ }, r);
1697
+ }, t);
1698
+ }
1699
+ function c() {
1700
+ clearTimeout(n), i();
1701
+ }
1702
+ function a() {
1703
+ clearTimeout(o), c();
1704
+ }
1705
+ e.addEventListener("open", i), e.addEventListener("message", ({ data: s }) => {
1706
+ clearTimeout(n), i(), s === "PONG" && a();
1707
+ }), e.addEventListener("close", () => {
1708
+ clearTimeout(n), clearTimeout(o);
1709
+ });
1710
+ }
1711
+ var ut = class me {
1712
+ constructor(t) {
1713
+ var r;
1714
+ if ((0, q.default)(this, "id", ++me.connectCount), (0, q.default)(this, "WebSocketPonyfill", void 0), (0, q.default)(this, "urlOptions", void 0), (0, q.default)(this, "keepAliveOpts", void 0), (0, q.default)(this, "encoder", void 0), (0, q.default)(this, "wsObservable", se(null)), (0, q.default)(this, "openPromise", null), this.WebSocketPonyfill = (r = t.WebSocketPonyfill) !== null && r !== void 0 ? r : WebSocket, !this.WebSocketPonyfill) throw new Error("No WebSocket implementation found - you probably don't want to use this on the server, but if you do you need to pass a `WebSocket`-ponyfill");
1715
+ this.urlOptions = t.urlOptions, this.keepAliveOpts = t.keepAlive, this.encoder = t.encoder;
1716
+ }
1717
+ get ws() {
1718
+ return this.wsObservable.get();
1719
+ }
1720
+ set ws(t) {
1721
+ this.wsObservable.next(t);
1722
+ }
1723
+ /**
1724
+ * Checks if the WebSocket connection is open and ready to communicate.
1725
+ */
1726
+ isOpen() {
1727
+ return !!this.ws && this.ws.readyState === this.WebSocketPonyfill.OPEN && !this.openPromise;
1728
+ }
1729
+ /**
1730
+ * Checks if the WebSocket connection is closed or in the process of closing.
1731
+ */
1732
+ isClosed() {
1733
+ return !!this.ws && (this.ws.readyState === this.WebSocketPonyfill.CLOSING || this.ws.readyState === this.WebSocketPonyfill.CLOSED);
1734
+ }
1735
+ async open() {
1736
+ var t = this;
1737
+ if (t.openPromise) return t.openPromise;
1738
+ t.id = ++me.connectCount;
1739
+ const r = Ar(t.urlOptions).then((n) => new t.WebSocketPonyfill(n));
1740
+ t.openPromise = r.then(async (n) => {
1741
+ t.ws = n, n.binaryType = "arraybuffer", n.addEventListener("message", function({ data: o }) {
1742
+ o === "PING" && this.send("PONG");
1743
+ }), t.keepAliveOpts.enabled && Lr(n, t.keepAliveOpts), n.addEventListener("close", () => {
1744
+ t.ws === n && (t.ws = null);
1745
+ }), await Ir(n), t.urlOptions.connectionParams && n.send(await Cr(t.urlOptions.connectionParams, t.encoder));
1746
+ });
1747
+ try {
1748
+ await t.openPromise;
1749
+ } finally {
1750
+ t.openPromise = null;
1751
+ }
1752
+ }
1753
+ /**
1754
+ * Closes the WebSocket connection gracefully.
1755
+ * Waits for any ongoing open operation to complete before closing.
1756
+ */
1757
+ async close() {
1758
+ var t = this;
1759
+ try {
1760
+ await t.openPromise;
1761
+ } finally {
1762
+ var r;
1763
+ (r = t.ws) === null || r === void 0 || r.close();
1764
+ }
1765
+ }
1766
+ };
1767
+ (0, q.default)(ut, "connectCount", 0);
1768
+ function Dr(e) {
1769
+ return e.isOpen() ? {
1770
+ id: e.id,
1771
+ state: "open",
1772
+ ws: e.ws
1773
+ } : e.isClosed() ? {
1774
+ id: e.id,
1775
+ state: "closed",
1776
+ ws: e.ws
1777
+ } : e.ws ? {
1778
+ id: e.id,
1779
+ state: "connecting",
1780
+ ws: e.ws
1781
+ } : null;
1782
+ }
1783
+ var R = S(D()), $ = S(k()), Nr = class {
1784
+ constructor(e) {
1785
+ var t, r;
1786
+ (0, R.default)(this, "connectionState", void 0), (0, R.default)(this, "allowReconnect", !1), (0, R.default)(this, "requestManager", new Mr()), (0, R.default)(this, "activeConnection", void 0), (0, R.default)(this, "reconnectRetryDelay", void 0), (0, R.default)(this, "inactivityTimeout", void 0), (0, R.default)(this, "callbacks", void 0), (0, R.default)(this, "lazyMode", void 0), (0, R.default)(this, "encoder", void 0), (0, R.default)(this, "reconnecting", null), this.encoder = (t = e.experimental_encoder) !== null && t !== void 0 ? t : jr, this.callbacks = {
1787
+ onOpen: e.onOpen,
1788
+ onClose: e.onClose,
1789
+ onError: e.onError
1790
+ };
1791
+ const n = (0, $.default)((0, $.default)({}, Or), e.lazy);
1792
+ this.inactivityTimeout = new qr(() => {
1793
+ if (this.requestManager.hasOutgoingRequests() || this.requestManager.hasPendingRequests()) {
1794
+ this.inactivityTimeout.reset();
1795
+ return;
1796
+ }
1797
+ this.close().catch(() => null);
1798
+ }, n.closeMs), this.activeConnection = new ut({
1799
+ WebSocketPonyfill: e.WebSocket,
1800
+ urlOptions: e,
1801
+ keepAlive: (0, $.default)((0, $.default)({}, kr), e.keepAlive),
1802
+ encoder: this.encoder
1803
+ }), this.activeConnection.wsObservable.subscribe({ next: (o) => {
1804
+ o && this.setupWebSocketListeners(o);
1805
+ } }), this.reconnectRetryDelay = (r = e.retryDelayMs) !== null && r !== void 0 ? r : Rr, this.lazyMode = n.enabled, this.connectionState = se({
1806
+ type: "state",
1807
+ state: n.enabled ? "idle" : "connecting",
1808
+ error: null
1809
+ }), this.lazyMode || this.open().catch(() => null);
1810
+ }
1811
+ /**
1812
+ * Opens the WebSocket connection. Handles reconnection attempts and updates
1813
+ * the connection state accordingly.
1814
+ */
1815
+ async open() {
1816
+ var e = this;
1817
+ e.allowReconnect = !0, e.connectionState.get().state === "idle" && e.connectionState.next({
1818
+ type: "state",
1819
+ state: "connecting",
1820
+ error: null
1821
+ });
1822
+ try {
1823
+ await e.activeConnection.open();
1824
+ } catch (t) {
1825
+ return e.reconnect(new U({
1826
+ message: "Initialization error",
1827
+ cause: t
1828
+ })), e.reconnecting;
1829
+ }
1830
+ }
1831
+ /**
1832
+ * Closes the WebSocket connection and stops managing requests.
1833
+ * Ensures all outgoing and pending requests are properly finalized.
1834
+ */
1835
+ async close() {
1836
+ var e = this;
1837
+ e.allowReconnect = !1, e.inactivityTimeout.stop();
1838
+ const t = [];
1839
+ for (const r of e.requestManager.getRequests()) r.message.method === "subscription" ? r.callbacks.complete() : r.state === "outgoing" ? r.callbacks.error(_.from(new U({ message: "Closed before connection was established" }))) : t.push(r.end);
1840
+ await Promise.all(t).catch(() => null), await e.activeConnection.close().catch(() => null), e.connectionState.next({
1841
+ type: "state",
1842
+ state: "idle",
1843
+ error: null
1844
+ });
1845
+ }
1846
+ /**
1847
+ * Method to request the server.
1848
+ * Handles data transformation, batching of requests, and subscription lifecycle.
1849
+ *
1850
+ * @param op - The operation details including id, type, path, input and signal
1851
+ * @param transformer - Data transformer for serializing requests and deserializing responses
1852
+ * @param lastEventId - Optional ID of the last received event for subscriptions
1853
+ *
1854
+ * @returns An observable that emits operation results and handles cleanup
1855
+ */
1856
+ request({ op: { id: e, type: t, path: r, input: n, signal: o }, transformer: i, lastEventId: c }) {
1857
+ return E((a) => {
1858
+ const s = this.batchSend({
1859
+ id: e,
1860
+ method: t,
1861
+ params: {
1862
+ input: i.input.serialize(n),
1863
+ path: r,
1864
+ lastEventId: c
1865
+ }
1866
+ }, (0, $.default)((0, $.default)({}, a), {}, { next(u) {
1867
+ const l = he(u, i.output);
1868
+ if (!l.ok) {
1869
+ a.error(_.from(l.error));
1870
+ return;
1871
+ }
1872
+ a.next({ result: l.result });
1873
+ } }));
1874
+ return () => {
1875
+ s(), t === "subscription" && this.activeConnection.isOpen() && this.send({
1876
+ id: e,
1877
+ method: "subscription.stop"
1878
+ }), o?.removeEventListener("abort", s);
1879
+ };
1880
+ });
1881
+ }
1882
+ get connection() {
1883
+ return Dr(this.activeConnection);
1884
+ }
1885
+ reconnect(e) {
1886
+ var t = this;
1887
+ if (this.connectionState.next({
1888
+ type: "state",
1889
+ state: "connecting",
1890
+ error: _.from(e)
1891
+ }), this.reconnecting) return;
1892
+ const r = async (n) => {
1893
+ try {
1894
+ await we(t.reconnectRetryDelay(n)), t.allowReconnect && (await t.activeConnection.close(), await t.activeConnection.open(), t.requestManager.hasPendingRequests() && t.send(t.requestManager.getPendingRequests().map(({ message: o }) => o))), t.reconnecting = null;
1895
+ } catch {
1896
+ await r(n + 1);
1897
+ }
1898
+ };
1899
+ this.reconnecting = r(0);
1900
+ }
1901
+ setupWebSocketListeners(e) {
1902
+ var t = this;
1903
+ const r = (n) => {
1904
+ const o = this.requestManager.getPendingRequests();
1905
+ for (const { message: i, callbacks: c } of o)
1906
+ i.method !== "subscription" && (c.error(_.from(n ?? new U({
1907
+ message: "WebSocket closed",
1908
+ cause: n
1909
+ }))), this.requestManager.delete(i.id));
1910
+ };
1911
+ e.addEventListener("open", () => {
1912
+ I(async () => {
1913
+ var n, o;
1914
+ t.lazyMode && t.inactivityTimeout.start(), (n = (o = t.callbacks).onOpen) === null || n === void 0 || n.call(o), t.connectionState.next({
1915
+ type: "state",
1916
+ state: "pending",
1917
+ error: null
1918
+ });
1919
+ }).catch((n) => {
1920
+ e.close(3e3), r(n);
1921
+ });
1922
+ }), e.addEventListener("message", ({ data: n }) => {
1923
+ if (this.inactivityTimeout.reset(), ["PING", "PONG"].includes(n)) return;
1924
+ const o = this.encoder.decode(n);
1925
+ if ("method" in o) {
1926
+ this.handleIncomingRequest(o);
1927
+ return;
1928
+ }
1929
+ this.handleResponseMessage(o);
1930
+ }), e.addEventListener("close", (n) => {
1931
+ var o, i;
1932
+ r(n), (o = (i = this.callbacks).onClose) === null || o === void 0 || o.call(i, n), (!this.lazyMode || this.requestManager.hasPendingSubscriptions()) && this.reconnect(new U({
1933
+ message: "WebSocket closed",
1934
+ cause: n
1935
+ }));
1936
+ }), e.addEventListener("error", (n) => {
1937
+ var o, i;
1938
+ r(n), (o = (i = this.callbacks).onError) === null || o === void 0 || o.call(i, n), this.reconnect(new U({
1939
+ message: "WebSocket closed",
1940
+ cause: n
1941
+ }));
1942
+ });
1943
+ }
1944
+ handleResponseMessage(e) {
1945
+ const t = this.requestManager.getPendingRequest(e.id);
1946
+ if (!t) return;
1947
+ t.callbacks.next(e);
1948
+ let r = !0;
1949
+ "result" in e && t.message.method === "subscription" && (e.result.type === "data" && (t.message.params.lastEventId = e.result.id), e.result.type !== "stopped" && (r = !1)), r && (t.callbacks.complete(), this.requestManager.delete(e.id));
1950
+ }
1951
+ handleIncomingRequest(e) {
1952
+ e.method === "reconnect" && this.reconnect(new U({ message: "Server requested reconnect" }));
1953
+ }
1954
+ /**
1955
+ * Sends a message or batch of messages directly to the server.
1956
+ */
1957
+ send(e) {
1958
+ if (!this.activeConnection.isOpen()) throw new Error("Active connection is not open");
1959
+ const t = e instanceof Array ? e : [e];
1960
+ this.activeConnection.ws.send(this.encoder.encode(t.length === 1 ? t[0] : t));
1961
+ }
1962
+ /**
1963
+ * Groups requests for batch sending.
1964
+ *
1965
+ * @returns A function to abort the batched request.
1966
+ */
1967
+ batchSend(e, t) {
1968
+ var r = this;
1969
+ return this.inactivityTimeout.reset(), I(async () => {
1970
+ r.activeConnection.isOpen() || await r.open(), await we(0), r.requestManager.hasOutgoingRequests() && r.send(r.requestManager.flush().map(({ message: n }) => n));
1971
+ }).catch((n) => {
1972
+ this.requestManager.delete(e.id), t.error(_.from(n));
1973
+ }), this.requestManager.register(e, t);
1974
+ }
1975
+ };
1976
+ function on(e) {
1977
+ return new Nr(e);
1978
+ }
1979
+ function sn(e) {
1980
+ const { client: t } = e, r = ie(e.transformer);
1981
+ return () => ({ op: n }) => E((o) => {
1982
+ const i = n.type === "subscription" ? t.connectionState.subscribe({ next(a) {
1983
+ o.next({
1984
+ result: a,
1985
+ context: n.context
1986
+ });
1987
+ } }) : null, c = t.request({
1988
+ op: n,
1989
+ transformer: r
1990
+ }).subscribe(o);
1991
+ return () => {
1992
+ c.unsubscribe(), i?.unsubscribe();
1993
+ };
1994
+ });
1995
+ }
1996
+ var de = S(D()), Le = S(k()), lt = class {
1997
+ constructor(e) {
1998
+ (0, de.default)(this, "links", void 0), (0, de.default)(this, "runtime", void 0), (0, de.default)(this, "requestId", void 0), this.requestId = 0, this.runtime = {}, this.links = e.links.map((t) => t(this.runtime));
1999
+ }
2000
+ $request(e) {
2001
+ var t;
2002
+ return He({
2003
+ links: this.links,
2004
+ op: (0, Le.default)((0, Le.default)({}, e), {}, {
2005
+ context: (t = e.context) !== null && t !== void 0 ? t : {},
2006
+ id: ++this.requestId
2007
+ })
2008
+ }).pipe(Ot());
2009
+ }
2010
+ async requestAsPromise(e) {
2011
+ var t = this;
2012
+ try {
2013
+ const r = t.$request(e);
2014
+ return (await jt(r)).result.data;
2015
+ } catch (r) {
2016
+ throw _.from(r);
2017
+ }
2018
+ }
2019
+ query(e, t, r) {
2020
+ return this.requestAsPromise({
2021
+ type: "query",
2022
+ path: e,
2023
+ input: t,
2024
+ context: r?.context,
2025
+ signal: r?.signal
2026
+ });
2027
+ }
2028
+ mutation(e, t, r) {
2029
+ return this.requestAsPromise({
2030
+ type: "mutation",
2031
+ path: e,
2032
+ input: t,
2033
+ context: r?.context,
2034
+ signal: r?.signal
2035
+ });
2036
+ }
2037
+ subscription(e, t, r) {
2038
+ return this.$request({
2039
+ type: "subscription",
2040
+ path: e,
2041
+ input: t,
2042
+ context: r.context,
2043
+ signal: r.signal
2044
+ }).subscribe({
2045
+ next(o) {
2046
+ switch (o.result.type) {
2047
+ case "state": {
2048
+ var i;
2049
+ (i = r.onConnectionStateChange) === null || i === void 0 || i.call(r, o.result);
2050
+ break;
2051
+ }
2052
+ case "started": {
2053
+ var c;
2054
+ (c = r.onStarted) === null || c === void 0 || c.call(r, { context: o.context });
2055
+ break;
2056
+ }
2057
+ case "stopped": {
2058
+ var a;
2059
+ (a = r.onStopped) === null || a === void 0 || a.call(r);
2060
+ break;
2061
+ }
2062
+ case "data":
2063
+ case void 0: {
2064
+ var s;
2065
+ (s = r.onData) === null || s === void 0 || s.call(r, o.result.data);
2066
+ break;
2067
+ }
2068
+ }
2069
+ },
2070
+ error(o) {
2071
+ var i;
2072
+ (i = r.onError) === null || i === void 0 || i.call(r, o);
2073
+ },
2074
+ complete() {
2075
+ var o;
2076
+ (o = r.onComplete) === null || o === void 0 || o.call(r);
2077
+ }
2078
+ });
2079
+ }
2080
+ };
2081
+ function an(e) {
2082
+ return new lt(e);
2083
+ }
2084
+ const dt = Symbol.for("trpc_untypedClient"), Ur = {
2085
+ query: "query",
2086
+ mutate: "mutation",
2087
+ subscribe: "subscription"
2088
+ }, $r = (e) => Ur[e];
2089
+ function zr(e) {
2090
+ const t = mt(({ path: r, args: n }) => {
2091
+ const o = [...r], i = $r(o.pop()), c = o.join(".");
2092
+ return e[i](c, ...n);
2093
+ });
2094
+ return ht((r) => r === dt ? e : t[r]);
2095
+ }
2096
+ function cn(e) {
2097
+ const t = new lt(e);
2098
+ return zr(t);
2099
+ }
2100
+ function un(e) {
2101
+ return e[dt];
2102
+ }
2103
+ var X = S(k());
2104
+ function Wr(e) {
2105
+ var t, r;
2106
+ const n = ve(e), o = (t = e.maxURLLength) !== null && t !== void 0 ? t : 1 / 0, i = (r = e.maxItems) !== null && r !== void 0 ? r : 1 / 0;
2107
+ return () => {
2108
+ const c = (l) => ({
2109
+ validate(d) {
2110
+ if (o === 1 / 0 && i === 1 / 0) return !0;
2111
+ if (d.length > i) return !1;
2112
+ const f = d.map((m) => m.path).join(","), p = d.map((m) => m.input);
2113
+ return L((0, X.default)((0, X.default)({}, n), {}, {
2114
+ type: l,
2115
+ path: f,
2116
+ inputs: p,
2117
+ signal: null
2118
+ })).length <= o;
2119
+ },
2120
+ async fetch(d) {
2121
+ var f;
2122
+ const p = d.map((y) => y.path).join(","), h = d.map((y) => y.input), m = it(...d.map((y) => y.signal)), v = new AbortController(), g = await nt((0, X.default)((0, X.default)({}, n), {}, {
2123
+ signal: be(m, v.signal),
2124
+ type: l,
2125
+ contentTypeHeader: "application/json",
2126
+ trpcAcceptHeader: "application/jsonl",
2127
+ trpcAcceptHeaderKey: (f = e.streamHeader) !== null && f !== void 0 ? f : "trpc-accept",
2128
+ getUrl: L,
2129
+ getBody: tt,
2130
+ inputs: h,
2131
+ path: p,
2132
+ headers() {
2133
+ return e.headers ? typeof e.headers == "function" ? e.headers({ opList: d }) : e.headers : {};
2134
+ }
2135
+ }));
2136
+ if (!g.ok) {
2137
+ const y = await g.json();
2138
+ return "error" in y && (y.error = n.transformer.output.deserialize(y.error)), d.map(() => Promise.resolve({
2139
+ json: y,
2140
+ meta: { response: g }
2141
+ }));
2142
+ }
2143
+ const [b] = await sr({
2144
+ from: g.body,
2145
+ deserialize: (y) => n.transformer.output.deserialize(y),
2146
+ formatError(y) {
2147
+ const P = y.error;
2148
+ return _.from({ error: P });
2149
+ },
2150
+ abortController: v
2151
+ });
2152
+ return Object.keys(d).map(async (y) => {
2153
+ let P = await Promise.resolve(b[y]);
2154
+ if ("result" in P) {
2155
+ const A = await Promise.resolve(P.result);
2156
+ P = { result: { data: await Promise.resolve(A.data) } };
2157
+ }
2158
+ return {
2159
+ json: P,
2160
+ meta: { response: g }
2161
+ };
2162
+ });
2163
+ }
2164
+ }), a = ne(c("query")), s = ne(c("mutation")), u = {
2165
+ query: a,
2166
+ mutation: s
2167
+ };
2168
+ return ({ op: l }) => E((d) => {
2169
+ /* istanbul ignore if -- @preserve */
2170
+ if (l.type === "subscription") throw new Error("Subscriptions are unsupported by `httpBatchStreamLink` - use `httpSubscriptionLink` or `wsLink`");
2171
+ const p = u[l.type].load(l);
2172
+ let h;
2173
+ return p.then((m) => {
2174
+ if (h = m, "error" in m.json) {
2175
+ d.error(_.from(m.json, { meta: m.meta }));
2176
+ return;
2177
+ } else if ("result" in m.json) {
2178
+ d.next({
2179
+ context: m.meta,
2180
+ result: m.json.result
2181
+ }), d.complete();
2182
+ return;
2183
+ }
2184
+ d.complete();
2185
+ }).catch((m) => {
2186
+ d.error(_.from(m, { meta: h?.meta }));
2187
+ }), () => {
2188
+ };
2189
+ });
2190
+ };
2191
+ }
2192
+ const ln = Wr;
2193
+ var De = S(k());
2194
+ function ge(e, t) {
2195
+ return !t || e != null && typeof e != "object" ? e : (0, De.default)((0, De.default)({}, e ?? {}), {}, { lastEventId: t });
2196
+ }
2197
+ var Gr = T({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/asyncIterator.js"(e, t) {
2198
+ function r(o) {
2199
+ var i, c, a, s = 2;
2200
+ for (typeof Symbol < "u" && (c = Symbol.asyncIterator, a = Symbol.iterator); s--; ) {
2201
+ if (c && (i = o[c]) != null) return i.call(o);
2202
+ if (a && (i = o[a]) != null) return new n(i.call(o));
2203
+ c = "@@asyncIterator", a = "@@iterator";
2204
+ }
2205
+ throw new TypeError("Object is not async iterable");
2206
+ }
2207
+ function n(o) {
2208
+ function i(c) {
2209
+ if (Object(c) !== c) return Promise.reject(new TypeError(c + " is not an object."));
2210
+ var a = c.done;
2211
+ return Promise.resolve(c.value).then(function(s) {
2212
+ return {
2213
+ value: s,
2214
+ done: a
2215
+ };
2216
+ });
2217
+ }
2218
+ return n = function(a) {
2219
+ this.s = a, this.n = a.next;
2220
+ }, n.prototype = {
2221
+ s: null,
2222
+ n: null,
2223
+ next: function() {
2224
+ return i(this.n.apply(this.s, arguments));
2225
+ },
2226
+ return: function(a) {
2227
+ var s = this.s.return;
2228
+ return s === void 0 ? Promise.resolve({
2229
+ value: a,
2230
+ done: !0
2231
+ }) : i(s.apply(this.s, arguments));
2232
+ },
2233
+ throw: function(a) {
2234
+ var s = this.s.return;
2235
+ return s === void 0 ? Promise.reject(a) : i(s.apply(this.s, arguments));
2236
+ }
2237
+ }, new n(o);
2238
+ }
2239
+ t.exports = r, t.exports.__esModule = !0, t.exports.default = t.exports;
2240
+ } }), Br = S(Gr());
2241
+ async function Fr(e) {
2242
+ let t = await F(e.url);
2243
+ if (e.connectionParams) {
2244
+ const r = await F(e.connectionParams), n = t.includes("?") ? "&" : "?";
2245
+ t += n + "connectionParams=" + encodeURIComponent(JSON.stringify(r));
2246
+ }
2247
+ return t;
2248
+ }
2249
+ function Hr(e) {
2250
+ const t = ie(e.transformer);
2251
+ return () => ({ op: r }) => E((n) => {
2252
+ var o;
2253
+ const { type: i, path: c, input: a } = r;
2254
+ /* istanbul ignore if -- @preserve */
2255
+ if (i !== "subscription") throw new Error("httpSubscriptionLink only supports subscriptions");
2256
+ let s;
2257
+ const u = new AbortController(), l = be(r.signal, u.signal), d = pr({
2258
+ url: async () => L({
2259
+ transformer: t,
2260
+ url: await Fr(e),
2261
+ input: ge(a, s),
2262
+ path: c,
2263
+ type: i,
2264
+ signal: null
2265
+ }),
2266
+ init: () => F(e.eventSourceOptions, { op: r }),
2267
+ signal: l,
2268
+ deserialize: (h) => t.output.deserialize(h),
2269
+ EventSource: (o = e.EventSource) !== null && o !== void 0 ? o : globalThis.EventSource
2270
+ }), f = se({
2271
+ type: "state",
2272
+ state: "connecting",
2273
+ error: null
2274
+ }), p = f.subscribe({ next(h) {
2275
+ n.next({ result: h });
2276
+ } });
2277
+ return I(async () => {
2278
+ var h = !1, m = !1, v;
2279
+ try {
2280
+ for (var x = (0, Br.default)(d), g; h = !(g = await x.next()).done; h = !1) {
2281
+ const b = g.value;
2282
+ switch (b.type) {
2283
+ case "ping":
2284
+ break;
2285
+ case "data":
2286
+ const j = b.data;
2287
+ let y;
2288
+ j.id ? (s = j.id, y = {
2289
+ id: j.id,
2290
+ data: j
2291
+ }) : y = { data: j.data }, n.next({
2292
+ result: y,
2293
+ context: { eventSource: b.eventSource }
2294
+ });
2295
+ break;
2296
+ case "connected": {
2297
+ n.next({
2298
+ result: { type: "started" },
2299
+ context: { eventSource: b.eventSource }
2300
+ }), f.next({
2301
+ type: "state",
2302
+ state: "pending",
2303
+ error: null
2304
+ });
2305
+ break;
2306
+ }
2307
+ case "serialized-error": {
2308
+ const P = _.from({ error: b.error });
2309
+ if (We.includes(b.error.code)) {
2310
+ f.next({
2311
+ type: "state",
2312
+ state: "connecting",
2313
+ error: P
2314
+ });
2315
+ break;
2316
+ }
2317
+ throw P;
2318
+ }
2319
+ case "connecting": {
2320
+ const P = f.get(), A = b.event && _.from(b.event);
2321
+ if (!A && P.state === "connecting") break;
2322
+ f.next({
2323
+ type: "state",
2324
+ state: "connecting",
2325
+ error: A
2326
+ });
2327
+ break;
2328
+ }
2329
+ case "timeout":
2330
+ f.next({
2331
+ type: "state",
2332
+ state: "connecting",
2333
+ error: new _(`Timeout of ${b.ms}ms reached while waiting for a response`)
2334
+ });
2335
+ }
2336
+ }
2337
+ } catch (b) {
2338
+ m = !0, v = b;
2339
+ } finally {
2340
+ try {
2341
+ h && x.return != null && await x.return();
2342
+ } finally {
2343
+ if (m) throw v;
2344
+ }
2345
+ }
2346
+ n.next({ result: { type: "stopped" } }), f.next({
2347
+ type: "state",
2348
+ state: "idle",
2349
+ error: null
2350
+ }), n.complete();
2351
+ }).catch((h) => {
2352
+ n.error(_.from(h));
2353
+ }), () => {
2354
+ n.complete(), u.abort(), p.unsubscribe();
2355
+ };
2356
+ });
2357
+ }
2358
+ const dn = Hr;
2359
+ var Ne = S(k());
2360
+ function fn(e) {
2361
+ return () => (t) => E((r) => {
2362
+ let n, o, i;
2363
+ a(1);
2364
+ function c() {
2365
+ const s = t.op;
2366
+ return i ? (0, Ne.default)((0, Ne.default)({}, s), {}, { input: ge(s.input, i) }) : s;
2367
+ }
2368
+ function a(s) {
2369
+ const u = c();
2370
+ n = t.next(u).subscribe({
2371
+ error(l) {
2372
+ var d, f;
2373
+ if (!e.retry({
2374
+ op: u,
2375
+ attempts: s,
2376
+ error: l
2377
+ })) {
2378
+ r.error(l);
2379
+ return;
2380
+ }
2381
+ const h = (d = (f = e.retryDelayMs) === null || f === void 0 ? void 0 : f.call(e, s)) !== null && d !== void 0 ? d : 0;
2382
+ if (h <= 0) {
2383
+ a(s + 1);
2384
+ return;
2385
+ }
2386
+ o = setTimeout(() => a(s + 1), h);
2387
+ },
2388
+ next(l) {
2389
+ (!l.result.type || l.result.type === "data") && l.result.id && (i = l.result.id), r.next(l);
2390
+ },
2391
+ complete() {
2392
+ r.complete();
2393
+ }
2394
+ });
2395
+ }
2396
+ return () => {
2397
+ n.unsubscribe(), clearTimeout(o);
2398
+ };
2399
+ });
2400
+ }
2401
+ var Jr = T({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/usingCtx.js"(e, t) {
2402
+ function r() {
2403
+ var n = typeof SuppressedError == "function" ? SuppressedError : function(a, s) {
2404
+ var u = Error();
2405
+ return u.name = "SuppressedError", u.error = a, u.suppressed = s, u;
2406
+ }, o = {}, i = [];
2407
+ function c(a, s) {
2408
+ if (s != null) {
2409
+ if (Object(s) !== s) throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");
2410
+ if (a) var u = s[Symbol.asyncDispose || Symbol.for("Symbol.asyncDispose")];
2411
+ if (u === void 0 && (u = s[Symbol.dispose || Symbol.for("Symbol.dispose")], a)) var l = u;
2412
+ if (typeof u != "function") throw new TypeError("Object is not disposable.");
2413
+ l && (u = function() {
2414
+ try {
2415
+ l.call(s);
2416
+ } catch (f) {
2417
+ return Promise.reject(f);
2418
+ }
2419
+ }), i.push({
2420
+ v: s,
2421
+ d: u,
2422
+ a
2423
+ });
2424
+ } else a && i.push({
2425
+ d: s,
2426
+ a
2427
+ });
2428
+ return s;
2429
+ }
2430
+ return {
2431
+ e: o,
2432
+ u: c.bind(null, !1),
2433
+ a: c.bind(null, !0),
2434
+ d: function() {
2435
+ var s, u = this.e, l = 0;
2436
+ function d() {
2437
+ for (; s = i.pop(); ) try {
2438
+ if (!s.a && l === 1) return l = 0, i.push(s), Promise.resolve().then(d);
2439
+ if (s.d) {
2440
+ var p = s.d.call(s.v);
2441
+ if (s.a) return l |= 2, Promise.resolve(p).then(d, f);
2442
+ } else l |= 1;
2443
+ } catch (h) {
2444
+ return f(h);
2445
+ }
2446
+ if (l === 1) return u !== o ? Promise.reject(u) : Promise.resolve();
2447
+ if (u !== o) throw u;
2448
+ }
2449
+ function f(p) {
2450
+ return u = u !== o ? new n(p, u) : p, d();
2451
+ }
2452
+ return d();
2453
+ }
2454
+ };
2455
+ }
2456
+ t.exports = r, t.exports.__esModule = !0, t.exports.default = t.exports;
2457
+ } }), ft = T({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/OverloadYield.js"(e, t) {
2458
+ function r(n, o) {
2459
+ this.v = n, this.k = o;
2460
+ }
2461
+ t.exports = r, t.exports.__esModule = !0, t.exports.default = t.exports;
2462
+ } }), Yr = T({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/awaitAsyncGenerator.js"(e, t) {
2463
+ var r = ft();
2464
+ function n(o) {
2465
+ return new r(o, 0);
2466
+ }
2467
+ t.exports = n, t.exports.__esModule = !0, t.exports.default = t.exports;
2468
+ } }), Kr = T({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/wrapAsyncGenerator.js"(e, t) {
2469
+ var r = ft();
2470
+ function n(i) {
2471
+ return function() {
2472
+ return new o(i.apply(this, arguments));
2473
+ };
2474
+ }
2475
+ function o(i) {
2476
+ var c, a;
2477
+ function s(l, d) {
2478
+ try {
2479
+ var f = i[l](d), p = f.value, h = p instanceof r;
2480
+ Promise.resolve(h ? p.v : p).then(function(m) {
2481
+ if (h) {
2482
+ var v = l === "return" ? "return" : "next";
2483
+ if (!p.k || m.done) return s(v, m);
2484
+ m = i[v](m).value;
2485
+ }
2486
+ u(f.done ? "return" : "normal", m);
2487
+ }, function(m) {
2488
+ s("throw", m);
2489
+ });
2490
+ } catch (m) {
2491
+ u("throw", m);
2492
+ }
2493
+ }
2494
+ function u(l, d) {
2495
+ switch (l) {
2496
+ case "return":
2497
+ c.resolve({
2498
+ value: d,
2499
+ done: !0
2500
+ });
2501
+ break;
2502
+ case "throw":
2503
+ c.reject(d);
2504
+ break;
2505
+ default:
2506
+ c.resolve({
2507
+ value: d,
2508
+ done: !1
2509
+ });
2510
+ }
2511
+ (c = c.next) ? s(c.key, c.arg) : a = null;
2512
+ }
2513
+ this._invoke = function(l, d) {
2514
+ return new Promise(function(f, p) {
2515
+ var h = {
2516
+ key: l,
2517
+ arg: d,
2518
+ resolve: f,
2519
+ reject: p,
2520
+ next: null
2521
+ };
2522
+ a ? a = a.next = h : (c = a = h, s(l, d));
2523
+ });
2524
+ }, typeof i.return != "function" && (this.return = void 0);
2525
+ }
2526
+ o.prototype[typeof Symbol == "function" && Symbol.asyncIterator || "@@asyncIterator"] = function() {
2527
+ return this;
2528
+ }, o.prototype.next = function(i) {
2529
+ return this._invoke("next", i);
2530
+ }, o.prototype.throw = function(i) {
2531
+ return this._invoke("throw", i);
2532
+ }, o.prototype.return = function(i) {
2533
+ return this._invoke("return", i);
2534
+ }, t.exports = n, t.exports.__esModule = !0, t.exports.default = t.exports;
2535
+ } }), fe = S(Jr()), Ue = S(Yr()), Vr = S(Kr()), $e = S(k());
2536
+ function Zr(e) {
2537
+ const t = ie(e.transformer), r = (n) => {
2538
+ if (e.transformer || n === void 0) return n;
2539
+ const o = JSON.stringify(t.input.serialize(n));
2540
+ return JSON.parse(t.output.deserialize(o));
2541
+ };
2542
+ return () => ({ op: n }) => E((o) => {
2543
+ let i;
2544
+ const c = new AbortController(), a = be(n.signal, c.signal), s = Sr(a);
2545
+ s.catch(() => {
2546
+ });
2547
+ let u = n.input;
2548
+ async function l(p) {
2549
+ return u = p, i = await e.createContext(), It({
2550
+ router: e.router,
2551
+ path: n.path,
2552
+ getRawInput: async () => p,
2553
+ ctx: i,
2554
+ type: n.type,
2555
+ signal: a,
2556
+ batchIndex: 0
2557
+ });
2558
+ }
2559
+ function d(p) {
2560
+ var h;
2561
+ Pe(p) || (h = e.onError) === null || h === void 0 || h.call(e, {
2562
+ error: ae(p),
2563
+ type: n.type,
2564
+ path: n.path,
2565
+ input: u,
2566
+ ctx: i
2567
+ });
2568
+ }
2569
+ function f(p) {
2570
+ if (Xe(p)) return p;
2571
+ const h = ae(p), m = vt({
2572
+ config: e.router._def._config,
2573
+ ctx: i,
2574
+ error: h,
2575
+ input: u,
2576
+ path: n.path,
2577
+ type: n.type
2578
+ });
2579
+ return _.from({ error: r(m) }, { cause: p instanceof Error ? p : void 0 });
2580
+ }
2581
+ return I(async () => {
2582
+ switch (n.type) {
2583
+ case "query":
2584
+ case "mutation": {
2585
+ const m = await l(n.input);
2586
+ if (!xe(m)) {
2587
+ o.next({ result: { data: r(m) } }), o.complete();
2588
+ break;
2589
+ }
2590
+ o.next({ result: { data: (0, Vr.default)(function* () {
2591
+ try {
2592
+ var v = (0, fe.default)();
2593
+ const x = v.a(Re(m)), g = v.u(re({}, () => {
2594
+ o.complete();
2595
+ }));
2596
+ try {
2597
+ for (; ; ) {
2598
+ const b = yield (0, Ue.default)(Promise.race([x.next(), s]));
2599
+ if (b.done) return r(b.value);
2600
+ yield r(b.value);
2601
+ }
2602
+ } catch (b) {
2603
+ throw d(b), f(b);
2604
+ }
2605
+ } catch (x) {
2606
+ v.e = x;
2607
+ } finally {
2608
+ yield (0, Ue.default)(v.d());
2609
+ }
2610
+ })() } });
2611
+ break;
2612
+ }
2613
+ case "subscription":
2614
+ try {
2615
+ var p = (0, fe.default)();
2616
+ const m = se({
2617
+ type: "state",
2618
+ state: "connecting",
2619
+ error: null
2620
+ }), v = m.subscribe({ next(b) {
2621
+ o.next({ result: b });
2622
+ } });
2623
+ let x;
2624
+ const g = p.u(re({}, async () => {
2625
+ o.complete(), m.next({
2626
+ type: "state",
2627
+ state: "idle",
2628
+ error: null
2629
+ }), v.unsubscribe();
2630
+ }));
2631
+ for (; ; ) try {
2632
+ var h = (0, fe.default)();
2633
+ const b = await l(ge(n.input, x));
2634
+ if (!xe(b)) throw new Error("Expected an async iterable");
2635
+ const j = h.a(Re(b));
2636
+ for (o.next({ result: { type: "started" } }), m.next({
2637
+ type: "state",
2638
+ state: "pending",
2639
+ error: null
2640
+ }); ; ) {
2641
+ let y;
2642
+ try {
2643
+ y = await Promise.race([j.next(), s]);
2644
+ } catch (A) {
2645
+ if (Pe(A)) return;
2646
+ const Y = ae(A);
2647
+ if (!We.includes(yt[Y.code])) throw f(Y);
2648
+ d(Y), m.next({
2649
+ type: "state",
2650
+ state: "connecting",
2651
+ error: f(Y)
2652
+ });
2653
+ break;
2654
+ }
2655
+ if (y.done) return;
2656
+ let P;
2657
+ Dt(y.value) ? (x = y.value[0], P = {
2658
+ id: y.value[0],
2659
+ data: {
2660
+ id: y.value[0],
2661
+ data: y.value[1]
2662
+ }
2663
+ }) : P = { data: y.value }, o.next({ result: (0, $e.default)((0, $e.default)({}, P), {}, { data: r(P.data) }) });
2664
+ }
2665
+ } catch (b) {
2666
+ h.e = b;
2667
+ } finally {
2668
+ await h.d();
2669
+ }
2670
+ break;
2671
+ } catch (m) {
2672
+ p.e = m;
2673
+ } finally {
2674
+ p.d();
2675
+ }
2676
+ }
2677
+ }).catch((p) => {
2678
+ d(p), o.error(f(p));
2679
+ }), () => {
2680
+ c.abort();
2681
+ };
2682
+ });
2683
+ }
2684
+ const pn = Zr;
2685
+ export {
2686
+ _ as TRPCClientError,
2687
+ lt as TRPCUntypedClient,
2688
+ $r as clientCallTypeToProcedureType,
2689
+ cn as createTRPCClient,
2690
+ zr as createTRPCClientProxy,
2691
+ cn as createTRPCProxyClient,
2692
+ an as createTRPCUntypedClient,
2693
+ on as createWSClient,
2694
+ pn as experimental_localLink,
2695
+ yr as getFetch,
2696
+ un as getUntypedClient,
2697
+ rn as httpBatchLink,
2698
+ Wr as httpBatchStreamLink,
2699
+ tn as httpLink,
2700
+ Hr as httpSubscriptionLink,
2701
+ st as isFormData,
2702
+ en as isNonJsonSerializable,
2703
+ ot as isOctetType,
2704
+ Xe as isTRPCClientError,
2705
+ jr as jsonEncoder,
2706
+ nn as loggerLink,
2707
+ fn as retryLink,
2708
+ Xr as splitLink,
2709
+ ln as unstable_httpBatchStreamLink,
2710
+ dn as unstable_httpSubscriptionLink,
2711
+ Zr as unstable_localLink,
2712
+ sn as wsLink
2713
+ };