@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,2464 @@
1
+ import { S as Q } from "./index-C3iAUQqS.mjs";
2
+ import { _ as ee, a as rt } from "./__mfe_internal__addon_pipeline_analytics_widgets__loadShare___mf_0_camstack_mf_1_types__loadShare__.mjs-OesvKBZV.mjs";
3
+ var nt = Object.defineProperty, o = (e, t) => nt(e, "name", { value: t, configurable: !0 }), it = Object.create, ae = Object.defineProperty, ot = Object.getOwnPropertyDescriptor, ce = Object.getOwnPropertyNames, st = Object.getPrototypeOf, at = Object.prototype.hasOwnProperty, _ = /* @__PURE__ */ o((e, t) => function() {
4
+ return t || (0, e[ce(e)[0]])((t = { exports: {} }).exports, t), t.exports;
5
+ }, "__commonJS"), ct = /* @__PURE__ */ o((e, t, r, n) => {
6
+ if (t && typeof t == "object" || typeof t == "function") for (var i = ce(t), s = 0, c = i.length, a; s < c; s++)
7
+ a = i[s], !at.call(e, a) && a !== r && ae(e, a, {
8
+ get: ((u) => t[u]).bind(null, a),
9
+ enumerable: !(n = ot(t, a)) || n.enumerable
10
+ });
11
+ return e;
12
+ }, "__copyProps"), m = /* @__PURE__ */ o((e, t, r) => (r = e != null ? it(st(e)) : {}, ct(t || !e || !e.__esModule ? ae(r, "default", {
13
+ value: e,
14
+ enumerable: !0
15
+ }) : r, e)), "__toESM"), ue = _({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/typeof.js"(e, t) {
16
+ function r(n) {
17
+ "@babel/helpers - typeof";
18
+ return t.exports = r = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(i) {
19
+ return typeof i;
20
+ } : function(i) {
21
+ return i && typeof Symbol == "function" && i.constructor === Symbol && i !== Symbol.prototype ? "symbol" : typeof i;
22
+ }, t.exports.__esModule = !0, t.exports.default = t.exports, r(n);
23
+ }
24
+ o(r, "_typeof$2"), t.exports = r, t.exports.__esModule = !0, t.exports.default = t.exports;
25
+ } }), ut = _({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPrimitive.js"(e, t) {
26
+ var r = ue().default;
27
+ function n(i, s) {
28
+ if (r(i) != "object" || !i) return i;
29
+ var c = i[Symbol.toPrimitive];
30
+ if (c !== void 0) {
31
+ var a = c.call(i, s || "default");
32
+ if (r(a) != "object") return a;
33
+ throw new TypeError("@@toPrimitive must return a primitive value.");
34
+ }
35
+ return (s === "string" ? String : Number)(i);
36
+ }
37
+ o(n, "toPrimitive$1"), t.exports = n, t.exports.__esModule = !0, t.exports.default = t.exports;
38
+ } }), lt = _({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPropertyKey.js"(e, t) {
39
+ var r = ue().default, n = ut();
40
+ function i(s) {
41
+ var c = n(s, "string");
42
+ return r(c) == "symbol" ? c : c + "";
43
+ }
44
+ o(i, "toPropertyKey$1"), t.exports = i, t.exports.__esModule = !0, t.exports.default = t.exports;
45
+ } }), S = _({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/defineProperty.js"(e, t) {
46
+ var r = lt();
47
+ function n(i, s, c) {
48
+ return (s = r(s)) in i ? Object.defineProperty(i, s, {
49
+ value: c,
50
+ enumerable: !0,
51
+ configurable: !0,
52
+ writable: !0
53
+ }) : i[s] = c, i;
54
+ }
55
+ o(n, "_defineProperty"), t.exports = n, t.exports.__esModule = !0, t.exports.default = t.exports;
56
+ } }), v = _({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/objectSpread2.js"(e, t) {
57
+ var r = S();
58
+ function n(s, c) {
59
+ var a = Object.keys(s);
60
+ if (Object.getOwnPropertySymbols) {
61
+ var u = Object.getOwnPropertySymbols(s);
62
+ c && (u = u.filter(function(l) {
63
+ return Object.getOwnPropertyDescriptor(s, l).enumerable;
64
+ })), a.push.apply(a, u);
65
+ }
66
+ return a;
67
+ }
68
+ o(n, "ownKeys");
69
+ function i(s) {
70
+ for (var c = 1; c < arguments.length; c++) {
71
+ var a = arguments[c] != null ? arguments[c] : {};
72
+ c % 2 ? n(Object(a), !0).forEach(function(u) {
73
+ r(s, u, a[u]);
74
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(s, Object.getOwnPropertyDescriptors(a)) : n(Object(a)).forEach(function(u) {
75
+ Object.defineProperty(s, u, Object.getOwnPropertyDescriptor(a, u));
76
+ });
77
+ }
78
+ return s;
79
+ }
80
+ o(i, "_objectSpread2"), t.exports = i, t.exports.__esModule = !0, t.exports.default = t.exports;
81
+ } });
82
+ function C(e) {
83
+ const t = {
84
+ subscribe(r) {
85
+ let n = null, i = !1, s = !1, c = !1;
86
+ function a() {
87
+ if (n === null) {
88
+ c = !0;
89
+ return;
90
+ }
91
+ s || (s = !0, typeof n == "function" ? n() : n && n.unsubscribe());
92
+ }
93
+ return o(a, "unsubscribe"), n = e({
94
+ next(u) {
95
+ var l;
96
+ i || (l = r.next) === null || l === void 0 || l.call(r, u);
97
+ },
98
+ error(u) {
99
+ var l;
100
+ i || (i = !0, (l = r.error) === null || l === void 0 || l.call(r, u), a());
101
+ },
102
+ complete() {
103
+ var u;
104
+ i || (i = !0, (u = r.complete) === null || u === void 0 || u.call(r), a());
105
+ }
106
+ }), c && a(), { unsubscribe: a };
107
+ },
108
+ pipe(...r) {
109
+ return r.reduce(le, t);
110
+ }
111
+ };
112
+ return t;
113
+ }
114
+ o(C, "observable");
115
+ function le(e, t) {
116
+ return t(e);
117
+ }
118
+ o(le, "pipeReducer");
119
+ function de(e) {
120
+ const t = new AbortController();
121
+ return new Promise((n, i) => {
122
+ let s = !1;
123
+ function c() {
124
+ s || (s = !0, a.unsubscribe());
125
+ }
126
+ o(c, "onDone"), t.signal.addEventListener("abort", () => {
127
+ i(t.signal.reason);
128
+ });
129
+ const a = e.subscribe({
130
+ next(u) {
131
+ s = !0, n(u), c();
132
+ },
133
+ error(u) {
134
+ i(u);
135
+ },
136
+ complete() {
137
+ t.abort(), c();
138
+ }
139
+ });
140
+ });
141
+ }
142
+ o(de, "observableToPromise");
143
+ function pe(e) {
144
+ return (t) => {
145
+ let r = 0, n = null;
146
+ const i = [];
147
+ function s() {
148
+ n || (n = t.subscribe({
149
+ next(a) {
150
+ for (const l of i) {
151
+ var u;
152
+ (u = l.next) === null || u === void 0 || u.call(l, a);
153
+ }
154
+ },
155
+ error(a) {
156
+ for (const l of i) {
157
+ var u;
158
+ (u = l.error) === null || u === void 0 || u.call(l, a);
159
+ }
160
+ },
161
+ complete() {
162
+ for (const u of i) {
163
+ var a;
164
+ (a = u.complete) === null || a === void 0 || a.call(u);
165
+ }
166
+ }
167
+ }));
168
+ }
169
+ o(s, "startIfNeeded");
170
+ function c() {
171
+ if (r === 0 && n) {
172
+ const a = n;
173
+ n = null, a.unsubscribe();
174
+ }
175
+ }
176
+ return o(c, "resetIfNeeded"), C((a) => (r++, i.push(a), s(), { unsubscribe() {
177
+ r--, c();
178
+ const u = i.findIndex((l) => l === a);
179
+ u > -1 && i.splice(u, 1);
180
+ } }));
181
+ };
182
+ }
183
+ o(pe, "share");
184
+ function U(e) {
185
+ let t = e;
186
+ const r = [], n = /* @__PURE__ */ o((c) => {
187
+ t !== void 0 && c.next(t), r.push(c);
188
+ }, "addObserver"), i = /* @__PURE__ */ o((c) => {
189
+ r.splice(r.indexOf(c), 1);
190
+ }, "removeObserver"), s = C((c) => (n(c), () => {
191
+ i(c);
192
+ }));
193
+ return s.next = (c) => {
194
+ if (t !== c) {
195
+ t = c;
196
+ for (const a of r) a.next(c);
197
+ }
198
+ }, s.get = () => t, s;
199
+ }
200
+ o(U, "behaviorSubject");
201
+ function fe(e) {
202
+ return C((t) => {
203
+ function r(i = 0, s = e.op) {
204
+ const c = e.links[i];
205
+ if (!c) throw new Error("No more links to execute - did you forget to add an ending link?");
206
+ return c({
207
+ op: s,
208
+ next(u) {
209
+ return r(i + 1, u);
210
+ }
211
+ });
212
+ }
213
+ return o(r, "execute"), r().subscribe(t);
214
+ });
215
+ }
216
+ o(fe, "createChain");
217
+ function j(e) {
218
+ return !!e && !Array.isArray(e) && typeof e == "object";
219
+ }
220
+ o(j, "isObject");
221
+ function he() {
222
+ return /* @__PURE__ */ Object.create(null);
223
+ }
224
+ o(he, "emptyObject");
225
+ var te = /* @__PURE__ */ o((e) => e(), "run");
226
+ function B(e = 0) {
227
+ return new Promise((t) => setTimeout(t, e));
228
+ }
229
+ o(B, "sleep");
230
+ var dt = Object.create, me = Object.defineProperty, pt = Object.getOwnPropertyDescriptor, ye = Object.getOwnPropertyNames, ft = Object.getPrototypeOf, ht = Object.prototype.hasOwnProperty, M = /* @__PURE__ */ o((e, t) => function() {
231
+ return t || (0, e[ye(e)[0]])((t = { exports: {} }).exports, t), t.exports;
232
+ }, "__commonJS"), mt = /* @__PURE__ */ o((e, t, r, n) => {
233
+ if (t && typeof t == "object" || typeof t == "function") for (var i = ye(t), s = 0, c = i.length, a; s < c; s++)
234
+ a = i[s], !ht.call(e, a) && a !== r && me(e, a, {
235
+ get: ((u) => t[u]).bind(null, a),
236
+ enumerable: !(n = pt(t, a)) || n.enumerable
237
+ });
238
+ return e;
239
+ }, "__copyProps"), L = /* @__PURE__ */ o((e, t, r) => (r = e != null ? dt(ft(e)) : {}, mt(t || !e || !e.__esModule ? me(r, "default", {
240
+ value: e,
241
+ enumerable: !0
242
+ }) : r, e)), "__toESM"), ve = /* @__PURE__ */ o(() => {
243
+ }, "noop"), re = /* @__PURE__ */ o((e) => {
244
+ Object.freeze && Object.freeze(e);
245
+ }, "freezeIfAvailable");
246
+ function H(e, t, r) {
247
+ var n;
248
+ const i = t.join(".");
249
+ return (n = r[i]) !== null && n !== void 0 || (r[i] = new Proxy(ve, {
250
+ get(s, c) {
251
+ if (!(typeof c != "string" || c === "then"))
252
+ return H(e, [...t, c], r);
253
+ },
254
+ apply(s, c, a) {
255
+ const u = t[t.length - 1];
256
+ if (u === "valueOf" || u === "toString" || u === "toJSON")
257
+ return `tRPC.proxy(${t.slice(0, -1).join(".")})`;
258
+ let l = {
259
+ args: a,
260
+ path: t
261
+ };
262
+ return u === "call" ? l = {
263
+ args: a.length >= 2 ? [a[1]] : [],
264
+ path: t.slice(0, -1)
265
+ } : u === "apply" && (l = {
266
+ args: a.length >= 2 ? a[1] : [],
267
+ path: t.slice(0, -1)
268
+ }), re(l.args), re(l.path), e(l);
269
+ }
270
+ })), r[i];
271
+ }
272
+ o(H, "createInnerProxy");
273
+ var yt = /* @__PURE__ */ o((e) => H(e, [], he()), "createRecursiveProxy"), vt = /* @__PURE__ */ o((e) => new Proxy(ve, { get(t, r) {
274
+ if (r !== "then")
275
+ return e(r);
276
+ } }), "createFlatProxy"), be = M({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/typeof.js"(e, t) {
277
+ function r(n) {
278
+ "@babel/helpers - typeof";
279
+ return t.exports = r = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(i) {
280
+ return typeof i;
281
+ } : function(i) {
282
+ return i && typeof Symbol == "function" && i.constructor === Symbol && i !== Symbol.prototype ? "symbol" : typeof i;
283
+ }, t.exports.__esModule = !0, t.exports.default = t.exports, r(n);
284
+ }
285
+ o(r, "_typeof$2"), t.exports = r, t.exports.__esModule = !0, t.exports.default = t.exports;
286
+ } }), bt = M({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPrimitive.js"(e, t) {
287
+ var r = be().default;
288
+ function n(i, s) {
289
+ if (r(i) != "object" || !i) return i;
290
+ var c = i[Symbol.toPrimitive];
291
+ if (c !== void 0) {
292
+ var a = c.call(i, s || "default");
293
+ if (r(a) != "object") return a;
294
+ throw new TypeError("@@toPrimitive must return a primitive value.");
295
+ }
296
+ return (s === "string" ? String : Number)(i);
297
+ }
298
+ o(n, "toPrimitive$1"), t.exports = n, t.exports.__esModule = !0, t.exports.default = t.exports;
299
+ } }), gt = M({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPropertyKey.js"(e, t) {
300
+ var r = be().default, n = bt();
301
+ function i(s) {
302
+ var c = n(s, "string");
303
+ return r(c) == "symbol" ? c : c + "";
304
+ }
305
+ o(i, "toPropertyKey$1"), t.exports = i, t.exports.__esModule = !0, t.exports.default = t.exports;
306
+ } }), ge = M({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/defineProperty.js"(e, t) {
307
+ var r = gt();
308
+ function n(i, s, c) {
309
+ return (s = r(s)) in i ? Object.defineProperty(i, s, {
310
+ value: c,
311
+ enumerable: !0,
312
+ configurable: !0,
313
+ writable: !0
314
+ }) : i[s] = c, i;
315
+ }
316
+ o(n, "_defineProperty"), t.exports = n, t.exports.__esModule = !0, t.exports.default = t.exports;
317
+ } }), V = M({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/objectSpread2.js"(e, t) {
318
+ var r = ge();
319
+ function n(s, c) {
320
+ var a = Object.keys(s);
321
+ if (Object.getOwnPropertySymbols) {
322
+ var u = Object.getOwnPropertySymbols(s);
323
+ c && (u = u.filter(function(l) {
324
+ return Object.getOwnPropertyDescriptor(s, l).enumerable;
325
+ })), a.push.apply(a, u);
326
+ }
327
+ return a;
328
+ }
329
+ o(n, "ownKeys");
330
+ function i(s) {
331
+ for (var c = 1; c < arguments.length; c++) {
332
+ var a = arguments[c] != null ? arguments[c] : {};
333
+ c % 2 ? n(Object(a), !0).forEach(function(u) {
334
+ r(s, u, a[u]);
335
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(s, Object.getOwnPropertyDescriptors(a)) : n(Object(a)).forEach(function(u) {
336
+ Object.defineProperty(s, u, Object.getOwnPropertyDescriptor(a, u));
337
+ });
338
+ }
339
+ return s;
340
+ }
341
+ o(i, "_objectSpread2"), t.exports = i, t.exports.__esModule = !0, t.exports.default = t.exports;
342
+ } });
343
+ L(V(), 1);
344
+ L(ge(), 1);
345
+ var q = L(V(), 1);
346
+ function _e(e, t) {
347
+ if ("error" in e) {
348
+ const n = t.deserialize(e.error);
349
+ return {
350
+ ok: !1,
351
+ error: (0, q.default)((0, q.default)({}, e), {}, { error: n })
352
+ };
353
+ }
354
+ return {
355
+ ok: !0,
356
+ result: (0, q.default)((0, q.default)({}, e.result), (!e.result.type || e.result.type === "data") && {
357
+ type: "data",
358
+ data: t.deserialize(e.result.data)
359
+ })
360
+ };
361
+ }
362
+ o(_e, "transformResultInner");
363
+ var N = class extends Error {
364
+ static {
365
+ o(this, "TransformResultError");
366
+ }
367
+ constructor() {
368
+ super("Unable to transform response from server");
369
+ }
370
+ };
371
+ function K(e, t) {
372
+ let r;
373
+ try {
374
+ r = _e(e, t);
375
+ } catch {
376
+ throw new N();
377
+ }
378
+ if (!r.ok && (!j(r.error.error) || typeof r.error.error.code != "number")) throw new N();
379
+ if (r.ok && !j(r.result)) throw new N();
380
+ return r;
381
+ }
382
+ o(K, "transformResult");
383
+ L(V(), 1);
384
+ var A = m(S(), 1), O = m(v(), 1);
385
+ function Pe(e) {
386
+ return e instanceof P;
387
+ }
388
+ o(Pe, "isTRPCClientError");
389
+ function we(e) {
390
+ return j(e) && j(e.error) && typeof e.error.code == "number" && typeof e.error.message == "string";
391
+ }
392
+ o(we, "isTRPCErrorResponse");
393
+ function xe(e, t) {
394
+ return typeof e == "string" ? e : j(e) && typeof e.message == "string" ? e.message : t;
395
+ }
396
+ o(xe, "getMessageFromUnknownError");
397
+ var P = class I extends Error {
398
+ static {
399
+ o(this, "TRPCClientError");
400
+ }
401
+ constructor(t, r) {
402
+ var n, i;
403
+ const s = r?.cause;
404
+ super(t, { cause: s }), (0, A.default)(this, "cause", void 0), (0, A.default)(this, "shape", void 0), (0, A.default)(this, "data", void 0), (0, A.default)(this, "meta", void 0), this.meta = r?.meta, this.cause = s, this.shape = r == null || (n = r.result) === null || n === void 0 ? void 0 : n.error, this.data = r == null || (i = r.result) === null || i === void 0 ? void 0 : i.error.data, this.name = "TRPCClientError", Object.setPrototypeOf(this, I.prototype);
405
+ }
406
+ static from(t, r = {}) {
407
+ const n = t;
408
+ return Pe(n) ? (r.meta && (n.meta = (0, O.default)((0, O.default)({}, n.meta), r.meta)), n) : we(n) ? new I(n.error.message, (0, O.default)((0, O.default)({}, r), {}, {
409
+ result: n,
410
+ cause: r.cause
411
+ })) : new I(xe(n, "Unknown error"), (0, O.default)((0, O.default)({}, r), {}, { cause: n }));
412
+ }
413
+ };
414
+ function Y(e) {
415
+ const t = e;
416
+ return t ? "input" in t ? t : {
417
+ input: t,
418
+ output: t
419
+ } : {
420
+ input: {
421
+ serialize: /* @__PURE__ */ o((r) => r, "serialize"),
422
+ deserialize: /* @__PURE__ */ o((r) => r, "deserialize")
423
+ },
424
+ output: {
425
+ serialize: /* @__PURE__ */ o((r) => r, "serialize"),
426
+ deserialize: /* @__PURE__ */ o((r) => r, "deserialize")
427
+ }
428
+ };
429
+ }
430
+ o(Y, "getTransformer");
431
+ var ne = /* @__PURE__ */ o((e) => typeof e == "function", "isFunction");
432
+ function Se(e) {
433
+ if (e) return e;
434
+ if (typeof window < "u" && ne(window.fetch)) return window.fetch;
435
+ if (typeof globalThis < "u" && ne(globalThis.fetch)) return globalThis.fetch;
436
+ throw new Error("No fetch implementation found");
437
+ }
438
+ o(Se, "getFetch");
439
+ var R = m(v(), 1);
440
+ function Ce(e) {
441
+ return {
442
+ url: e.url.toString(),
443
+ fetch: e.fetch,
444
+ transformer: Y(e.transformer),
445
+ methodOverride: e.methodOverride
446
+ };
447
+ }
448
+ o(Ce, "resolveHTTPLinkOptions");
449
+ function Oe(e) {
450
+ const t = {};
451
+ for (let r = 0; r < e.length; r++) {
452
+ const n = e[r];
453
+ t[r] = n;
454
+ }
455
+ return t;
456
+ }
457
+ o(Oe, "arrayToDict");
458
+ var _t = {
459
+ query: "GET",
460
+ mutation: "POST",
461
+ subscription: "PATCH"
462
+ };
463
+ function J(e) {
464
+ return "input" in e ? e.transformer.input.serialize(e.input) : Oe(e.inputs.map((t) => e.transformer.input.serialize(t)));
465
+ }
466
+ o(J, "getInput");
467
+ var F = /* @__PURE__ */ o((e) => {
468
+ const t = e.url.split("?");
469
+ let n = t[0].replace(/\/$/, "") + "/" + e.path;
470
+ const i = [];
471
+ if (t[1] && i.push(t[1]), "inputs" in e && i.push("batch=1"), e.type === "query" || e.type === "subscription") {
472
+ const s = J(e);
473
+ s !== void 0 && e.methodOverride !== "POST" && i.push(`input=${encodeURIComponent(JSON.stringify(s))}`);
474
+ }
475
+ return i.length && (n += "?" + i.join("&")), n;
476
+ }, "getUrl"), Pt = /* @__PURE__ */ o((e) => {
477
+ if (e.type === "query" && e.methodOverride !== "POST") return;
478
+ const t = J(e);
479
+ return t !== void 0 ? JSON.stringify(t) : void 0;
480
+ }, "getBody"), wt = /* @__PURE__ */ o((e) => D((0, R.default)((0, R.default)({}, e), {}, {
481
+ contentTypeHeader: "application/json",
482
+ getUrl: F,
483
+ getBody: Pt
484
+ })), "jsonHttpRequester"), xt = class extends Error {
485
+ static {
486
+ o(this, "AbortError");
487
+ }
488
+ constructor() {
489
+ const e = "AbortError";
490
+ super(e), this.name = e, this.message = e;
491
+ }
492
+ }, St = /* @__PURE__ */ o((e) => {
493
+ var t;
494
+ if (e?.aborted)
495
+ throw (t = e.throwIfAborted) === null || t === void 0 || t.call(e), typeof DOMException < "u" ? new DOMException("AbortError", "AbortError") : new xt();
496
+ }, "throwIfAborted");
497
+ async function Ee(e) {
498
+ var t, r;
499
+ St(e.signal);
500
+ const n = e.getUrl(e), i = e.getBody(e), s = (t = e.methodOverride) !== null && t !== void 0 ? t : _t[e.type], c = await (async () => {
501
+ const u = await e.headers();
502
+ return Symbol.iterator in u ? Object.fromEntries(u) : u;
503
+ })(), a = (0, R.default)((0, R.default)((0, R.default)({}, e.contentTypeHeader && s !== "GET" ? { "content-type": e.contentTypeHeader } : {}), e.trpcAcceptHeader ? { [(r = e.trpcAcceptHeaderKey) !== null && r !== void 0 ? r : "trpc-accept"]: e.trpcAcceptHeader } : void 0), c);
504
+ return Se(e.fetch)(n, {
505
+ method: s,
506
+ signal: e.signal,
507
+ body: i,
508
+ headers: a
509
+ });
510
+ }
511
+ o(Ee, "fetchHTTPResponse");
512
+ async function D(e) {
513
+ const t = {}, r = await Ee(e);
514
+ t.response = r;
515
+ const n = await r.json();
516
+ return t.responseJSON = n, {
517
+ json: n,
518
+ meta: t
519
+ };
520
+ }
521
+ o(D, "httpRequest");
522
+ function Te(e) {
523
+ return e instanceof Uint8Array || e instanceof Blob;
524
+ }
525
+ o(Te, "isOctetType");
526
+ function ke(e) {
527
+ return e instanceof FormData;
528
+ }
529
+ o(ke, "isFormData");
530
+ var k = m(v(), 1), Ct = /* @__PURE__ */ o((e) => {
531
+ if ("input" in e) {
532
+ const { input: t } = e;
533
+ if (ke(t)) {
534
+ if (e.type !== "mutation" && e.methodOverride !== "POST") throw new Error("FormData is only supported for mutations");
535
+ return D((0, k.default)((0, k.default)({}, e), {}, {
536
+ contentTypeHeader: void 0,
537
+ getUrl: F,
538
+ getBody: /* @__PURE__ */ o(() => t, "getBody")
539
+ }));
540
+ }
541
+ if (Te(t)) {
542
+ if (e.type !== "mutation" && e.methodOverride !== "POST") throw new Error("Octet type input is only supported for mutations");
543
+ return D((0, k.default)((0, k.default)({}, e), {}, {
544
+ contentTypeHeader: "application/octet-stream",
545
+ getUrl: F,
546
+ getBody: /* @__PURE__ */ o(() => t, "getBody")
547
+ }));
548
+ }
549
+ }
550
+ return wt(e);
551
+ }, "universalRequester");
552
+ function je(e) {
553
+ const t = Ce(e);
554
+ return () => (r) => {
555
+ const { op: n } = r;
556
+ return C((i) => {
557
+ const { path: s, input: c, type: a } = n;
558
+ if (a === "subscription") throw new Error("Subscriptions are unsupported by `httpLink` - use `httpSubscriptionLink` or `wsLink`");
559
+ const u = Ct((0, k.default)((0, k.default)({}, t), {}, {
560
+ type: a,
561
+ path: s,
562
+ input: c,
563
+ signal: n.signal,
564
+ headers() {
565
+ return e.headers ? typeof e.headers == "function" ? e.headers({ op: n }) : e.headers : {};
566
+ }
567
+ }));
568
+ let l;
569
+ return u.then((d) => {
570
+ l = d.meta;
571
+ const p = K(d.json, t.transformer.output);
572
+ if (!p.ok) {
573
+ i.error(P.from(p.error, { meta: l }));
574
+ return;
575
+ }
576
+ i.next({
577
+ context: d.meta,
578
+ result: p.result
579
+ }), i.complete();
580
+ }).catch((d) => {
581
+ i.error(P.from(d, { meta: l }));
582
+ }), () => {
583
+ };
584
+ });
585
+ };
586
+ }
587
+ o(je, "httpLink");
588
+ m(v(), 1);
589
+ m(v(), 1);
590
+ var Ot = {
591
+ encode: /* @__PURE__ */ o((e) => JSON.stringify(e), "encode"),
592
+ decode: /* @__PURE__ */ o((e) => {
593
+ if (typeof e != "string") throw new Error("jsonEncoder received binary data. JSON uses text frames. Use a binary encoder for binary data.");
594
+ return JSON.parse(e);
595
+ }, "decode")
596
+ }, Et = {
597
+ enabled: !1,
598
+ closeMs: 0
599
+ }, Tt = {
600
+ enabled: !1,
601
+ pongTimeoutMs: 1e3,
602
+ intervalMs: 5e3
603
+ }, kt = /* @__PURE__ */ o((e) => e === 0 ? 0 : Math.min(1e3 * 2 ** e, 3e4), "exponentialBackoff"), Re = /* @__PURE__ */ o((e, ...t) => typeof e == "function" ? e(...t) : e, "resultOf"), jt = m(S(), 1), E = class Me extends Error {
604
+ static {
605
+ o(this, "TRPCWebSocketClosedError");
606
+ }
607
+ constructor(t) {
608
+ super(t.message, { cause: t.cause }), this.name = "TRPCWebSocketClosedError", Object.setPrototypeOf(this, Me.prototype);
609
+ }
610
+ }, Rt = class {
611
+ static {
612
+ o(this, "ResettableTimeout");
613
+ }
614
+ constructor(e, t) {
615
+ this.onTimeout = e, this.timeoutMs = t, (0, jt.default)(this, "timeout", void 0);
616
+ }
617
+ /**
618
+ * Resets the current timeout, restarting it with the same duration.
619
+ * Does nothing if no timeout is active.
620
+ */
621
+ reset() {
622
+ this.timeout && (clearTimeout(this.timeout), this.timeout = setTimeout(this.onTimeout, this.timeoutMs));
623
+ }
624
+ start() {
625
+ clearTimeout(this.timeout), this.timeout = setTimeout(this.onTimeout, this.timeoutMs);
626
+ }
627
+ stop() {
628
+ clearTimeout(this.timeout), this.timeout = void 0;
629
+ }
630
+ };
631
+ function X() {
632
+ let e, t;
633
+ return {
634
+ promise: new Promise((n, i) => {
635
+ e = n, t = i;
636
+ }),
637
+ resolve: e,
638
+ reject: t
639
+ };
640
+ }
641
+ o(X, "withResolvers");
642
+ async function qe(e) {
643
+ const t = await Re(e.url);
644
+ if (!e.connectionParams) return t;
645
+ const n = `${t.includes("?") ? "&" : "?"}connectionParams=1`;
646
+ return t + n;
647
+ }
648
+ o(qe, "prepareUrl");
649
+ async function Ae(e, t) {
650
+ const r = {
651
+ method: "connectionParams",
652
+ data: await Re(e)
653
+ };
654
+ return t.encode(r);
655
+ }
656
+ o(Ae, "buildConnectionMessage");
657
+ var ie = m(S(), 1), Mt = class {
658
+ static {
659
+ o(this, "RequestManager");
660
+ }
661
+ constructor() {
662
+ (0, ie.default)(this, "outgoingRequests", new Array()), (0, ie.default)(this, "pendingRequests", {});
663
+ }
664
+ /**
665
+ * Registers a new request by adding it to the outgoing queue and setting up
666
+ * callbacks for lifecycle events such as completion or error.
667
+ *
668
+ * @param message - The outgoing message to be sent.
669
+ * @param callbacks - Callback functions to observe the request's state.
670
+ * @returns A cleanup function to manually remove the request.
671
+ */
672
+ register(e, t) {
673
+ const { promise: r, resolve: n } = X();
674
+ return this.outgoingRequests.push({
675
+ id: String(e.id),
676
+ message: e,
677
+ end: r,
678
+ callbacks: {
679
+ next: t.next,
680
+ complete: /* @__PURE__ */ o(() => {
681
+ t.complete(), n();
682
+ }, "complete"),
683
+ error: /* @__PURE__ */ o((i) => {
684
+ t.error(i), n();
685
+ }, "error")
686
+ }
687
+ }), () => {
688
+ this.delete(e.id), t.complete(), n();
689
+ };
690
+ }
691
+ /**
692
+ * Deletes a request from both the outgoing and pending collections, if it exists.
693
+ */
694
+ delete(e) {
695
+ e !== null && (this.outgoingRequests = this.outgoingRequests.filter(({ id: t }) => t !== String(e)), delete this.pendingRequests[String(e)]);
696
+ }
697
+ /**
698
+ * Moves all outgoing requests to the pending state and clears the outgoing queue.
699
+ *
700
+ * The caller is expected to handle the actual sending of the requests
701
+ * (e.g., sending them over the network) after this method is called.
702
+ *
703
+ * @returns The list of requests that were transitioned to the pending state.
704
+ */
705
+ flush() {
706
+ const e = this.outgoingRequests;
707
+ this.outgoingRequests = [];
708
+ for (const t of e) this.pendingRequests[t.id] = t;
709
+ return e;
710
+ }
711
+ /**
712
+ * Retrieves all currently pending requests, which are in flight awaiting responses
713
+ * or handling ongoing subscriptions.
714
+ */
715
+ getPendingRequests() {
716
+ return Object.values(this.pendingRequests);
717
+ }
718
+ /**
719
+ * Retrieves a specific pending request by its message ID.
720
+ */
721
+ getPendingRequest(e) {
722
+ return e === null ? null : this.pendingRequests[String(e)];
723
+ }
724
+ /**
725
+ * Retrieves all outgoing requests, which are waiting to be sent.
726
+ */
727
+ getOutgoingRequests() {
728
+ return this.outgoingRequests;
729
+ }
730
+ /**
731
+ * Retrieves all requests, both outgoing and pending, with their respective states.
732
+ *
733
+ * @returns An array of all requests with their state ("outgoing" or "pending").
734
+ */
735
+ getRequests() {
736
+ return [...this.getOutgoingRequests().map((e) => ({
737
+ state: "outgoing",
738
+ message: e.message,
739
+ end: e.end,
740
+ callbacks: e.callbacks
741
+ })), ...this.getPendingRequests().map((e) => ({
742
+ state: "pending",
743
+ message: e.message,
744
+ end: e.end,
745
+ callbacks: e.callbacks
746
+ }))];
747
+ }
748
+ /**
749
+ * Checks if there are any pending requests, including ongoing subscriptions.
750
+ */
751
+ hasPendingRequests() {
752
+ return this.getPendingRequests().length > 0;
753
+ }
754
+ /**
755
+ * Checks if there are any pending subscriptions
756
+ */
757
+ hasPendingSubscriptions() {
758
+ return this.getPendingRequests().some((e) => e.message.method === "subscription");
759
+ }
760
+ /**
761
+ * Checks if there are any outgoing requests waiting to be sent.
762
+ */
763
+ hasOutgoingRequests() {
764
+ return this.outgoingRequests.length > 0;
765
+ }
766
+ }, x = m(S(), 1);
767
+ function Ie(e) {
768
+ const { promise: t, resolve: r, reject: n } = X();
769
+ return e.addEventListener("open", () => {
770
+ e.removeEventListener("error", n), r();
771
+ }), e.addEventListener("error", n), t;
772
+ }
773
+ o(Ie, "asyncWsOpen");
774
+ function De(e, { intervalMs: t, pongTimeoutMs: r }) {
775
+ let n, i;
776
+ function s() {
777
+ n = setTimeout(() => {
778
+ e.send("PING"), i = setTimeout(() => {
779
+ e.close();
780
+ }, r);
781
+ }, t);
782
+ }
783
+ o(s, "start");
784
+ function c() {
785
+ clearTimeout(n), s();
786
+ }
787
+ o(c, "reset");
788
+ function a() {
789
+ clearTimeout(i), c();
790
+ }
791
+ o(a, "pong"), e.addEventListener("open", s), e.addEventListener("message", ({ data: u }) => {
792
+ clearTimeout(n), s(), u === "PONG" && a();
793
+ }), e.addEventListener("close", () => {
794
+ clearTimeout(n), clearTimeout(i);
795
+ });
796
+ }
797
+ o(De, "setupPingInterval");
798
+ var Le = class z {
799
+ static {
800
+ o(this, "WsConnection");
801
+ }
802
+ constructor(t) {
803
+ var r;
804
+ if ((0, x.default)(this, "id", ++z.connectCount), (0, x.default)(this, "WebSocketPonyfill", void 0), (0, x.default)(this, "urlOptions", void 0), (0, x.default)(this, "keepAliveOpts", void 0), (0, x.default)(this, "encoder", void 0), (0, x.default)(this, "wsObservable", U(null)), (0, x.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");
805
+ this.urlOptions = t.urlOptions, this.keepAliveOpts = t.keepAlive, this.encoder = t.encoder;
806
+ }
807
+ get ws() {
808
+ return this.wsObservable.get();
809
+ }
810
+ set ws(t) {
811
+ this.wsObservable.next(t);
812
+ }
813
+ /**
814
+ * Checks if the WebSocket connection is open and ready to communicate.
815
+ */
816
+ isOpen() {
817
+ return !!this.ws && this.ws.readyState === this.WebSocketPonyfill.OPEN && !this.openPromise;
818
+ }
819
+ /**
820
+ * Checks if the WebSocket connection is closed or in the process of closing.
821
+ */
822
+ isClosed() {
823
+ return !!this.ws && (this.ws.readyState === this.WebSocketPonyfill.CLOSING || this.ws.readyState === this.WebSocketPonyfill.CLOSED);
824
+ }
825
+ async open() {
826
+ var t = this;
827
+ if (t.openPromise) return t.openPromise;
828
+ t.id = ++z.connectCount;
829
+ const r = qe(t.urlOptions).then((n) => new t.WebSocketPonyfill(n));
830
+ t.openPromise = r.then(async (n) => {
831
+ t.ws = n, n.binaryType = "arraybuffer", n.addEventListener("message", function({ data: i }) {
832
+ i === "PING" && this.send("PONG");
833
+ }), t.keepAliveOpts.enabled && De(n, t.keepAliveOpts), n.addEventListener("close", () => {
834
+ t.ws === n && (t.ws = null);
835
+ }), await Ie(n), t.urlOptions.connectionParams && n.send(await Ae(t.urlOptions.connectionParams, t.encoder));
836
+ });
837
+ try {
838
+ await t.openPromise;
839
+ } finally {
840
+ t.openPromise = null;
841
+ }
842
+ }
843
+ /**
844
+ * Closes the WebSocket connection gracefully.
845
+ * Waits for any ongoing open operation to complete before closing.
846
+ */
847
+ async close() {
848
+ var t = this;
849
+ try {
850
+ await t.openPromise;
851
+ } finally {
852
+ var r;
853
+ (r = t.ws) === null || r === void 0 || r.close();
854
+ }
855
+ }
856
+ };
857
+ (0, x.default)(Le, "connectCount", 0);
858
+ function Ne(e) {
859
+ return e.isOpen() ? {
860
+ id: e.id,
861
+ state: "open",
862
+ ws: e.ws
863
+ } : e.isClosed() ? {
864
+ id: e.id,
865
+ state: "closed",
866
+ ws: e.ws
867
+ } : e.ws ? {
868
+ id: e.id,
869
+ state: "connecting",
870
+ ws: e.ws
871
+ } : null;
872
+ }
873
+ o(Ne, "backwardCompatibility");
874
+ var g = m(S(), 1), T = m(v(), 1), qt = class {
875
+ static {
876
+ o(this, "WsClient");
877
+ }
878
+ constructor(e) {
879
+ var t, r;
880
+ (0, g.default)(this, "connectionState", void 0), (0, g.default)(this, "allowReconnect", !1), (0, g.default)(this, "requestManager", new Mt()), (0, g.default)(this, "activeConnection", void 0), (0, g.default)(this, "reconnectRetryDelay", void 0), (0, g.default)(this, "inactivityTimeout", void 0), (0, g.default)(this, "callbacks", void 0), (0, g.default)(this, "lazyMode", void 0), (0, g.default)(this, "encoder", void 0), (0, g.default)(this, "reconnecting", null), this.encoder = (t = e.experimental_encoder) !== null && t !== void 0 ? t : Ot, this.callbacks = {
881
+ onOpen: e.onOpen,
882
+ onClose: e.onClose,
883
+ onError: e.onError
884
+ };
885
+ const n = (0, T.default)((0, T.default)({}, Et), e.lazy);
886
+ this.inactivityTimeout = new Rt(() => {
887
+ if (this.requestManager.hasOutgoingRequests() || this.requestManager.hasPendingRequests()) {
888
+ this.inactivityTimeout.reset();
889
+ return;
890
+ }
891
+ this.close().catch(() => null);
892
+ }, n.closeMs), this.activeConnection = new Le({
893
+ WebSocketPonyfill: e.WebSocket,
894
+ urlOptions: e,
895
+ keepAlive: (0, T.default)((0, T.default)({}, Tt), e.keepAlive),
896
+ encoder: this.encoder
897
+ }), this.activeConnection.wsObservable.subscribe({ next: /* @__PURE__ */ o((i) => {
898
+ i && this.setupWebSocketListeners(i);
899
+ }, "next") }), this.reconnectRetryDelay = (r = e.retryDelayMs) !== null && r !== void 0 ? r : kt, this.lazyMode = n.enabled, this.connectionState = U({
900
+ type: "state",
901
+ state: n.enabled ? "idle" : "connecting",
902
+ error: null
903
+ }), this.lazyMode || this.open().catch(() => null);
904
+ }
905
+ /**
906
+ * Opens the WebSocket connection. Handles reconnection attempts and updates
907
+ * the connection state accordingly.
908
+ */
909
+ async open() {
910
+ var e = this;
911
+ e.allowReconnect = !0, e.connectionState.get().state === "idle" && e.connectionState.next({
912
+ type: "state",
913
+ state: "connecting",
914
+ error: null
915
+ });
916
+ try {
917
+ await e.activeConnection.open();
918
+ } catch (t) {
919
+ return e.reconnect(new E({
920
+ message: "Initialization error",
921
+ cause: t
922
+ })), e.reconnecting;
923
+ }
924
+ }
925
+ /**
926
+ * Closes the WebSocket connection and stops managing requests.
927
+ * Ensures all outgoing and pending requests are properly finalized.
928
+ */
929
+ async close() {
930
+ var e = this;
931
+ e.allowReconnect = !1, e.inactivityTimeout.stop();
932
+ const t = [];
933
+ for (const r of e.requestManager.getRequests()) r.message.method === "subscription" ? r.callbacks.complete() : r.state === "outgoing" ? r.callbacks.error(P.from(new E({ message: "Closed before connection was established" }))) : t.push(r.end);
934
+ await Promise.all(t).catch(() => null), await e.activeConnection.close().catch(() => null), e.connectionState.next({
935
+ type: "state",
936
+ state: "idle",
937
+ error: null
938
+ });
939
+ }
940
+ /**
941
+ * Method to request the server.
942
+ * Handles data transformation, batching of requests, and subscription lifecycle.
943
+ *
944
+ * @param op - The operation details including id, type, path, input and signal
945
+ * @param transformer - Data transformer for serializing requests and deserializing responses
946
+ * @param lastEventId - Optional ID of the last received event for subscriptions
947
+ *
948
+ * @returns An observable that emits operation results and handles cleanup
949
+ */
950
+ request({ op: { id: e, type: t, path: r, input: n, signal: i }, transformer: s, lastEventId: c }) {
951
+ return C((a) => {
952
+ const u = this.batchSend({
953
+ id: e,
954
+ method: t,
955
+ params: {
956
+ input: s.input.serialize(n),
957
+ path: r,
958
+ lastEventId: c
959
+ }
960
+ }, (0, T.default)((0, T.default)({}, a), {}, { next(l) {
961
+ const d = K(l, s.output);
962
+ if (!d.ok) {
963
+ a.error(P.from(d.error));
964
+ return;
965
+ }
966
+ a.next({ result: d.result });
967
+ } }));
968
+ return () => {
969
+ u(), t === "subscription" && this.activeConnection.isOpen() && this.send({
970
+ id: e,
971
+ method: "subscription.stop"
972
+ }), i?.removeEventListener("abort", u);
973
+ };
974
+ });
975
+ }
976
+ get connection() {
977
+ return Ne(this.activeConnection);
978
+ }
979
+ reconnect(e) {
980
+ var t = this;
981
+ if (this.connectionState.next({
982
+ type: "state",
983
+ state: "connecting",
984
+ error: P.from(e)
985
+ }), this.reconnecting) return;
986
+ const r = /* @__PURE__ */ o(async (n) => {
987
+ try {
988
+ await B(t.reconnectRetryDelay(n)), t.allowReconnect && (await t.activeConnection.close(), await t.activeConnection.open(), t.requestManager.hasPendingRequests() && t.send(t.requestManager.getPendingRequests().map(({ message: i }) => i))), t.reconnecting = null;
989
+ } catch {
990
+ await r(n + 1);
991
+ }
992
+ }, "tryReconnect");
993
+ this.reconnecting = r(0);
994
+ }
995
+ setupWebSocketListeners(e) {
996
+ var t = this;
997
+ const r = /* @__PURE__ */ o((n) => {
998
+ const i = this.requestManager.getPendingRequests();
999
+ for (const { message: s, callbacks: c } of i)
1000
+ s.method !== "subscription" && (c.error(P.from(n ?? new E({
1001
+ message: "WebSocket closed",
1002
+ cause: n
1003
+ }))), this.requestManager.delete(s.id));
1004
+ }, "handleCloseOrError");
1005
+ e.addEventListener("open", () => {
1006
+ te(async () => {
1007
+ var n, i;
1008
+ t.lazyMode && t.inactivityTimeout.start(), (n = (i = t.callbacks).onOpen) === null || n === void 0 || n.call(i), t.connectionState.next({
1009
+ type: "state",
1010
+ state: "pending",
1011
+ error: null
1012
+ });
1013
+ }).catch((n) => {
1014
+ e.close(3e3), r(n);
1015
+ });
1016
+ }), e.addEventListener("message", ({ data: n }) => {
1017
+ if (this.inactivityTimeout.reset(), ["PING", "PONG"].includes(n)) return;
1018
+ const i = this.encoder.decode(n);
1019
+ if ("method" in i) {
1020
+ this.handleIncomingRequest(i);
1021
+ return;
1022
+ }
1023
+ this.handleResponseMessage(i);
1024
+ }), e.addEventListener("close", (n) => {
1025
+ var i, s;
1026
+ r(n), (i = (s = this.callbacks).onClose) === null || i === void 0 || i.call(s, n), (!this.lazyMode || this.requestManager.hasPendingSubscriptions()) && this.reconnect(new E({
1027
+ message: "WebSocket closed",
1028
+ cause: n
1029
+ }));
1030
+ }), e.addEventListener("error", (n) => {
1031
+ var i, s;
1032
+ r(n), (i = (s = this.callbacks).onError) === null || i === void 0 || i.call(s, n), this.reconnect(new E({
1033
+ message: "WebSocket closed",
1034
+ cause: n
1035
+ }));
1036
+ });
1037
+ }
1038
+ handleResponseMessage(e) {
1039
+ const t = this.requestManager.getPendingRequest(e.id);
1040
+ if (!t) return;
1041
+ t.callbacks.next(e);
1042
+ let r = !0;
1043
+ "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));
1044
+ }
1045
+ handleIncomingRequest(e) {
1046
+ e.method === "reconnect" && this.reconnect(new E({ message: "Server requested reconnect" }));
1047
+ }
1048
+ /**
1049
+ * Sends a message or batch of messages directly to the server.
1050
+ */
1051
+ send(e) {
1052
+ if (!this.activeConnection.isOpen()) throw new Error("Active connection is not open");
1053
+ const t = e instanceof Array ? e : [e];
1054
+ this.activeConnection.ws.send(this.encoder.encode(t.length === 1 ? t[0] : t));
1055
+ }
1056
+ /**
1057
+ * Groups requests for batch sending.
1058
+ *
1059
+ * @returns A function to abort the batched request.
1060
+ */
1061
+ batchSend(e, t) {
1062
+ var r = this;
1063
+ return this.inactivityTimeout.reset(), te(async () => {
1064
+ r.activeConnection.isOpen() || await r.open(), await B(0), r.requestManager.hasOutgoingRequests() && r.send(r.requestManager.flush().map(({ message: n }) => n));
1065
+ }).catch((n) => {
1066
+ this.requestManager.delete(e.id), t.error(P.from(n));
1067
+ }), this.requestManager.register(e, t);
1068
+ }
1069
+ };
1070
+ function We(e) {
1071
+ return new qt(e);
1072
+ }
1073
+ o(We, "createWSClient");
1074
+ function Be(e) {
1075
+ const { client: t } = e, r = Y(e.transformer);
1076
+ return () => ({ op: n }) => C((i) => {
1077
+ const s = n.type === "subscription" ? t.connectionState.subscribe({ next(a) {
1078
+ i.next({
1079
+ result: a,
1080
+ context: n.context
1081
+ });
1082
+ } }) : null, c = t.request({
1083
+ op: n,
1084
+ transformer: r
1085
+ }).subscribe(i);
1086
+ return () => {
1087
+ c.unsubscribe(), s?.unsubscribe();
1088
+ };
1089
+ });
1090
+ }
1091
+ o(Be, "wsLink");
1092
+ var W = m(S(), 1), oe = m(v(), 1), At = class {
1093
+ static {
1094
+ o(this, "TRPCUntypedClient");
1095
+ }
1096
+ constructor(e) {
1097
+ (0, W.default)(this, "links", void 0), (0, W.default)(this, "runtime", void 0), (0, W.default)(this, "requestId", void 0), this.requestId = 0, this.runtime = {}, this.links = e.links.map((t) => t(this.runtime));
1098
+ }
1099
+ $request(e) {
1100
+ var t;
1101
+ return fe({
1102
+ links: this.links,
1103
+ op: (0, oe.default)((0, oe.default)({}, e), {}, {
1104
+ context: (t = e.context) !== null && t !== void 0 ? t : {},
1105
+ id: ++this.requestId
1106
+ })
1107
+ }).pipe(pe());
1108
+ }
1109
+ async requestAsPromise(e) {
1110
+ var t = this;
1111
+ try {
1112
+ const r = t.$request(e);
1113
+ return (await de(r)).result.data;
1114
+ } catch (r) {
1115
+ throw P.from(r);
1116
+ }
1117
+ }
1118
+ query(e, t, r) {
1119
+ return this.requestAsPromise({
1120
+ type: "query",
1121
+ path: e,
1122
+ input: t,
1123
+ context: r?.context,
1124
+ signal: r?.signal
1125
+ });
1126
+ }
1127
+ mutation(e, t, r) {
1128
+ return this.requestAsPromise({
1129
+ type: "mutation",
1130
+ path: e,
1131
+ input: t,
1132
+ context: r?.context,
1133
+ signal: r?.signal
1134
+ });
1135
+ }
1136
+ subscription(e, t, r) {
1137
+ return this.$request({
1138
+ type: "subscription",
1139
+ path: e,
1140
+ input: t,
1141
+ context: r.context,
1142
+ signal: r.signal
1143
+ }).subscribe({
1144
+ next(i) {
1145
+ switch (i.result.type) {
1146
+ case "state": {
1147
+ var s;
1148
+ (s = r.onConnectionStateChange) === null || s === void 0 || s.call(r, i.result);
1149
+ break;
1150
+ }
1151
+ case "started": {
1152
+ var c;
1153
+ (c = r.onStarted) === null || c === void 0 || c.call(r, { context: i.context });
1154
+ break;
1155
+ }
1156
+ case "stopped": {
1157
+ var a;
1158
+ (a = r.onStopped) === null || a === void 0 || a.call(r);
1159
+ break;
1160
+ }
1161
+ case "data":
1162
+ case void 0: {
1163
+ var u;
1164
+ (u = r.onData) === null || u === void 0 || u.call(r, i.result.data);
1165
+ break;
1166
+ }
1167
+ }
1168
+ },
1169
+ error(i) {
1170
+ var s;
1171
+ (s = r.onError) === null || s === void 0 || s.call(r, i);
1172
+ },
1173
+ complete() {
1174
+ var i;
1175
+ (i = r.onComplete) === null || i === void 0 || i.call(r);
1176
+ }
1177
+ });
1178
+ }
1179
+ }, It = /* @__PURE__ */ Symbol.for("trpc_untypedClient"), Dt = {
1180
+ query: "query",
1181
+ mutate: "mutation",
1182
+ subscribe: "subscription"
1183
+ }, Lt = /* @__PURE__ */ o((e) => Dt[e], "clientCallTypeToProcedureType");
1184
+ function Fe(e) {
1185
+ const t = yt(({ path: r, args: n }) => {
1186
+ const i = [...r], s = Lt(i.pop()), c = i.join(".");
1187
+ return e[s](c, ...n);
1188
+ });
1189
+ return vt((r) => r === It ? e : t[r]);
1190
+ }
1191
+ o(Fe, "createTRPCClientProxy");
1192
+ function $(e) {
1193
+ const t = new At(e);
1194
+ return Fe(t);
1195
+ }
1196
+ o($, "createTRPCClient");
1197
+ m(v(), 1);
1198
+ m(v(), 1);
1199
+ var Nt = _({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/asyncIterator.js"(e, t) {
1200
+ function r(i) {
1201
+ var s, c, a, u = 2;
1202
+ for (typeof Symbol < "u" && (c = Symbol.asyncIterator, a = Symbol.iterator); u--; ) {
1203
+ if (c && (s = i[c]) != null) return s.call(i);
1204
+ if (a && (s = i[a]) != null) return new n(s.call(i));
1205
+ c = "@@asyncIterator", a = "@@iterator";
1206
+ }
1207
+ throw new TypeError("Object is not async iterable");
1208
+ }
1209
+ o(r, "_asyncIterator$1");
1210
+ function n(i) {
1211
+ function s(c) {
1212
+ if (Object(c) !== c) return Promise.reject(new TypeError(c + " is not an object."));
1213
+ var a = c.done;
1214
+ return Promise.resolve(c.value).then(function(u) {
1215
+ return {
1216
+ value: u,
1217
+ done: a
1218
+ };
1219
+ });
1220
+ }
1221
+ return o(s, "AsyncFromSyncIteratorContinuation"), n = /* @__PURE__ */ o(function(a) {
1222
+ this.s = a, this.n = a.next;
1223
+ }, "AsyncFromSyncIterator$1"), n.prototype = {
1224
+ s: null,
1225
+ n: null,
1226
+ next: /* @__PURE__ */ o(function() {
1227
+ return s(this.n.apply(this.s, arguments));
1228
+ }, "next"),
1229
+ return: /* @__PURE__ */ o(function(a) {
1230
+ var u = this.s.return;
1231
+ return u === void 0 ? Promise.resolve({
1232
+ value: a,
1233
+ done: !0
1234
+ }) : s(u.apply(this.s, arguments));
1235
+ }, "_return"),
1236
+ throw: /* @__PURE__ */ o(function(a) {
1237
+ var u = this.s.return;
1238
+ return u === void 0 ? Promise.reject(a) : s(u.apply(this.s, arguments));
1239
+ }, "_throw")
1240
+ }, new n(i);
1241
+ }
1242
+ o(n, "AsyncFromSyncIterator"), t.exports = r, t.exports.__esModule = !0, t.exports.default = t.exports;
1243
+ } });
1244
+ m(Nt(), 1);
1245
+ m(v(), 1);
1246
+ var Wt = _({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/usingCtx.js"(e, t) {
1247
+ function r() {
1248
+ var n = typeof SuppressedError == "function" ? SuppressedError : function(a, u) {
1249
+ var l = Error();
1250
+ return l.name = "SuppressedError", l.error = a, l.suppressed = u, l;
1251
+ }, i = {}, s = [];
1252
+ function c(a, u) {
1253
+ if (u != null) {
1254
+ if (Object(u) !== u) throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");
1255
+ if (a) var l = u[Symbol.asyncDispose || Symbol.for("Symbol.asyncDispose")];
1256
+ if (l === void 0 && (l = u[Symbol.dispose || Symbol.for("Symbol.dispose")], a)) var d = l;
1257
+ if (typeof l != "function") throw new TypeError("Object is not disposable.");
1258
+ d && (l = /* @__PURE__ */ o(function() {
1259
+ try {
1260
+ d.call(u);
1261
+ } catch (f) {
1262
+ return Promise.reject(f);
1263
+ }
1264
+ }, "o$1")), s.push({
1265
+ v: u,
1266
+ d: l,
1267
+ a
1268
+ });
1269
+ } else a && s.push({
1270
+ d: u,
1271
+ a
1272
+ });
1273
+ return u;
1274
+ }
1275
+ return o(c, "using"), {
1276
+ e: i,
1277
+ u: c.bind(null, !1),
1278
+ a: c.bind(null, !0),
1279
+ d: /* @__PURE__ */ o(function() {
1280
+ var u, l = this.e, d = 0;
1281
+ function p() {
1282
+ for (; u = s.pop(); ) try {
1283
+ if (!u.a && d === 1) return d = 0, s.push(u), Promise.resolve().then(p);
1284
+ if (u.d) {
1285
+ var h = u.d.call(u.v);
1286
+ if (u.a) return d |= 2, Promise.resolve(h).then(p, f);
1287
+ } else d |= 1;
1288
+ } catch (y) {
1289
+ return f(y);
1290
+ }
1291
+ if (d === 1) return l !== i ? Promise.reject(l) : Promise.resolve();
1292
+ if (l !== i) throw l;
1293
+ }
1294
+ o(p, "next");
1295
+ function f(h) {
1296
+ return l = l !== i ? new n(h, l) : h, p();
1297
+ }
1298
+ return o(f, "err"), p();
1299
+ }, "d")
1300
+ };
1301
+ }
1302
+ o(r, "_usingCtx"), t.exports = r, t.exports.__esModule = !0, t.exports.default = t.exports;
1303
+ } }), ze = _({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/OverloadYield.js"(e, t) {
1304
+ function r(n, i) {
1305
+ this.v = n, this.k = i;
1306
+ }
1307
+ o(r, "_OverloadYield"), t.exports = r, t.exports.__esModule = !0, t.exports.default = t.exports;
1308
+ } }), Bt = _({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/awaitAsyncGenerator.js"(e, t) {
1309
+ var r = ze();
1310
+ function n(i) {
1311
+ return new r(i, 0);
1312
+ }
1313
+ o(n, "_awaitAsyncGenerator$1"), t.exports = n, t.exports.__esModule = !0, t.exports.default = t.exports;
1314
+ } }), Ft = _({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/wrapAsyncGenerator.js"(e, t) {
1315
+ var r = ze();
1316
+ function n(s) {
1317
+ return function() {
1318
+ return new i(s.apply(this, arguments));
1319
+ };
1320
+ }
1321
+ o(n, "_wrapAsyncGenerator$1");
1322
+ function i(s) {
1323
+ var c, a;
1324
+ function u(d, p) {
1325
+ try {
1326
+ var f = s[d](p), h = f.value, y = h instanceof r;
1327
+ Promise.resolve(y ? h.v : h).then(function(b) {
1328
+ if (y) {
1329
+ var w = d === "return" ? "return" : "next";
1330
+ if (!h.k || b.done) return u(w, b);
1331
+ b = s[w](b).value;
1332
+ }
1333
+ l(f.done ? "return" : "normal", b);
1334
+ }, function(b) {
1335
+ u("throw", b);
1336
+ });
1337
+ } catch (b) {
1338
+ l("throw", b);
1339
+ }
1340
+ }
1341
+ o(u, "resume");
1342
+ function l(d, p) {
1343
+ switch (d) {
1344
+ case "return":
1345
+ c.resolve({
1346
+ value: p,
1347
+ done: !0
1348
+ });
1349
+ break;
1350
+ case "throw":
1351
+ c.reject(p);
1352
+ break;
1353
+ default:
1354
+ c.resolve({
1355
+ value: p,
1356
+ done: !1
1357
+ });
1358
+ }
1359
+ (c = c.next) ? u(c.key, c.arg) : a = null;
1360
+ }
1361
+ o(l, "settle"), this._invoke = function(d, p) {
1362
+ return new Promise(function(f, h) {
1363
+ var y = {
1364
+ key: d,
1365
+ arg: p,
1366
+ resolve: f,
1367
+ reject: h,
1368
+ next: null
1369
+ };
1370
+ a ? a = a.next = y : (c = a = y, u(d, p));
1371
+ });
1372
+ }, typeof s.return != "function" && (this.return = void 0);
1373
+ }
1374
+ o(i, "AsyncGenerator"), i.prototype[typeof Symbol == "function" && Symbol.asyncIterator || "@@asyncIterator"] = function() {
1375
+ return this;
1376
+ }, i.prototype.next = function(s) {
1377
+ return this._invoke("next", s);
1378
+ }, i.prototype.throw = function(s) {
1379
+ return this._invoke("throw", s);
1380
+ }, i.prototype.return = function(s) {
1381
+ return this._invoke("return", s);
1382
+ }, t.exports = n, t.exports.__esModule = !0, t.exports.default = t.exports;
1383
+ } });
1384
+ m(Wt(), 1);
1385
+ m(Bt(), 1);
1386
+ m(Ft(), 1);
1387
+ m(v(), 1);
1388
+ var zt = 1e4, $t = 3e3, Gt = 2e3, Ut = 3e4, Ht = class {
1389
+ static {
1390
+ o(this, "System");
1391
+ }
1392
+ serverUrl;
1393
+ useWs;
1394
+ baseRetryMs;
1395
+ maxRetryMs;
1396
+ onConnectionChange;
1397
+ token;
1398
+ _trpcClient;
1399
+ _wsClient = null;
1400
+ // Mirror — owns binding cache + state mirror + lifecycle listeners.
1401
+ // Lazily initialised on `init()`. Subsequent `reconnect()` disposes
1402
+ // the old mirror and rebuilds against the new tRPC client.
1403
+ mirror = null;
1404
+ mirrorInit = null;
1405
+ // Transport-readiness probe state. `connected` flips true the first
1406
+ // time `auth.me` succeeds against the current tRPC client; resets
1407
+ // on every `reconnect()` / `close()` so the next consumer waits for
1408
+ // a fresh handshake before issuing queries.
1409
+ connected = !1;
1410
+ connectedPromise = null;
1411
+ // System-cap namespaces — populated in the constructor from
1412
+ // `createSystemProxy(api)`. Each namespace is a `Pick<InferProvider<typeof cap>, …>`
1413
+ // shape generated by `scripts/generate-system-proxy.ts`.
1414
+ _systemProxy;
1415
+ // Connection-version + listener bookkeeping for the admin UI's
1416
+ // reconnect watchdog.
1417
+ _connectionVersion = 0;
1418
+ connectionListeners = /* @__PURE__ */ new Set();
1419
+ constructor(e) {
1420
+ this.serverUrl = e.serverUrl.replace(/\/+$/, ""), this.token = e.token;
1421
+ const t = typeof window < "u";
1422
+ this.useWs = e.useWebSocket ?? t, this.onConnectionChange = e.onConnectionChange, this.baseRetryMs = e.retryDelayMs ?? Gt, this.maxRetryMs = e.maxRetryDelayMs ?? Ut, this._trpcClient = this.buildTrpcClient(), this._systemProxy = ee(this._trpcClient);
1423
+ }
1424
+ // ── Connection state ─────────────────────────────────────────────
1425
+ get connectionVersion() {
1426
+ return this._connectionVersion;
1427
+ }
1428
+ /**
1429
+ * Subscribe to connection-state transitions. Called with `('connected'
1430
+ * | 'disconnected' | 'connecting', version)` whenever the SDK opens,
1431
+ * closes, or starts a manual reconnect. Listener errors are swallowed
1432
+ * so a misbehaving consumer cannot break the SDK's event loop.
1433
+ */
1434
+ subscribeConnectionEvents(e) {
1435
+ return this.connectionListeners.add(e), () => {
1436
+ this.connectionListeners.delete(e);
1437
+ };
1438
+ }
1439
+ emitConnectionEvent(e) {
1440
+ try {
1441
+ this.onConnectionChange?.(e);
1442
+ } catch {
1443
+ }
1444
+ for (const t of this.connectionListeners)
1445
+ try {
1446
+ t(e, this._connectionVersion);
1447
+ } catch {
1448
+ }
1449
+ }
1450
+ // ── Lifecycle ────────────────────────────────────────────────────
1451
+ /**
1452
+ * Wait until the underlying tRPC transport is connected AND the
1453
+ * server has responded to a cheap auth round-trip (`auth.me`). This
1454
+ * is the canonical "ready to issue queries" gate.
1455
+ *
1456
+ * Why a probe, not just `ws.readyState === OPEN`?
1457
+ * The WS handshake completes asynchronously: tRPC's `wsLink`
1458
+ * queues outgoing messages and only flushes them after `open()`
1459
+ * resolves (post `connectionParams` send). On the server, the
1460
+ * tRPC context is created lazily once the connectionParams
1461
+ * message is received. A query fired between WS-open and
1462
+ * connection-params-processed is technically queued by tRPC, but
1463
+ * the auth context for that query is only resolved once the
1464
+ * handshake message is decoded server-side. A probe round-trip is
1465
+ * the safest way to confirm both sides have agreed on the auth
1466
+ * identity before the React tree starts firing parallel queries
1467
+ * (which can otherwise land before any addon-side service
1468
+ * discovery has settled, returning empty results that get cached).
1469
+ *
1470
+ * Idempotent — concurrent callers await the same in-flight Promise.
1471
+ * Bounded by `timeoutMs` (default 15s) — beyond which a
1472
+ * `Error('System.awaitConnected: probe timed out after Xms')` is
1473
+ * thrown so the host can render a clear error state instead of
1474
+ * hanging on a bricked socket.
1475
+ */
1476
+ async awaitConnected(e) {
1477
+ if (this.connected) return;
1478
+ if (this.connectedPromise) return this.connectedPromise;
1479
+ const t = e ?? 15e3;
1480
+ this.connectedPromise = (async () => {
1481
+ const r = this._trpcClient.auth.me.query();
1482
+ Number.isFinite(t) ? await new Promise((n, i) => {
1483
+ const s = setTimeout(() => i(new Error(`System.awaitConnected: probe timed out after ${t}ms`)), t);
1484
+ r.then(() => {
1485
+ clearTimeout(s), n();
1486
+ }, (c) => {
1487
+ clearTimeout(s), i(c instanceof Error ? c : new Error(String(c)));
1488
+ });
1489
+ }) : await r, this.connected = !0;
1490
+ })();
1491
+ try {
1492
+ await this.connectedPromise;
1493
+ } finally {
1494
+ this.connectedPromise = null;
1495
+ }
1496
+ }
1497
+ /**
1498
+ * Warm-boot the device mirror. Awaits the transport probe first
1499
+ * (`awaitConnected`) so the three mirror round-trips
1500
+ * (`getAllBindings` + `getAllSnapshots` + `listAll`) cannot race
1501
+ * against the WS auth handshake. Subsequent `getDevice(id)` calls
1502
+ * are sync; live `device.*` event subscriptions keep the caches
1503
+ * fresh.
1504
+ *
1505
+ * Idempotent — concurrent callers await the same in-flight Promise.
1506
+ */
1507
+ async init(e) {
1508
+ if (this.mirror?.isReady()) return;
1509
+ if (this.mirrorInit) return this.mirrorInit;
1510
+ const t = new rt(this._trpcClient);
1511
+ return this.mirror = t, this.mirrorInit = (async () => {
1512
+ await this.awaitConnected(e), await t.init(e);
1513
+ })().finally(() => {
1514
+ this.mirrorInit = null;
1515
+ }), this.mirrorInit;
1516
+ }
1517
+ /** Promise that resolves once `init()` has completed. */
1518
+ async awaitReady() {
1519
+ if (!this.mirror?.isReady())
1520
+ return this.mirrorInit ? this.mirrorInit : this.init();
1521
+ }
1522
+ /** True after `init()` resolves. */
1523
+ isReady() {
1524
+ return this.mirror?.isReady() ?? !1;
1525
+ }
1526
+ /** True after the transport probe has succeeded at least once. */
1527
+ isConnected() {
1528
+ return this.connected;
1529
+ }
1530
+ /**
1531
+ * Force a fresh WebSocket handshake. Tears down the wsClient + tRPC
1532
+ * client + mirror (the mirror captures the tRPC reference at
1533
+ * construction time and would otherwise dispatch through a closed
1534
+ * client) and rebuilds them. No-op for HTTP transport.
1535
+ */
1536
+ reconnect() {
1537
+ this.useWs && (this.emitConnectionEvent("connecting"), this._wsClient?.close(), this.disposeMirror(), this.connected = !1, this.connectedPromise = null, this._trpcClient = this.buildTrpcClient(), this._systemProxy = ee(this._trpcClient));
1538
+ }
1539
+ /** Tear down WS connection + mirror. The instance is unusable afterwards. */
1540
+ close() {
1541
+ this.disposeMirror(), this.connected = !1, this.connectedPromise = null, this._wsClient?.close();
1542
+ }
1543
+ disposeMirror() {
1544
+ this.mirror?.dispose(), this.mirror = null, this.mirrorInit = null;
1545
+ }
1546
+ // ── Auth ──────────────────────────────────────────────────────────
1547
+ async login(e, t) {
1548
+ const r = await this._trpcClient.auth.login.mutate({
1549
+ username: e,
1550
+ password: t
1551
+ });
1552
+ if (typeof r == "object" && r !== null && "token" in r) {
1553
+ const n = r.token;
1554
+ typeof n == "string" && this.setToken(n);
1555
+ }
1556
+ return r;
1557
+ }
1558
+ async logout() {
1559
+ await this._trpcClient.auth.logout.mutate();
1560
+ }
1561
+ async getMe() {
1562
+ return await this._trpcClient.auth.me.query();
1563
+ }
1564
+ /** Update the auth token (e.g. after login or token refresh). */
1565
+ setToken(e) {
1566
+ this.token = e;
1567
+ }
1568
+ // ── Devices ──────────────────────────────────────────────────────
1569
+ /**
1570
+ * Synchronous snapshot of every device matching the optional filters.
1571
+ * Backed by the `SystemMirror` warm-boot cache — call `init()` first
1572
+ * (or `awaitReady()`) before invoking. Returns an empty array if the
1573
+ * mirror has not yet been booted.
1574
+ *
1575
+ * Each returned proxy has `binding` populated from the mirror's
1576
+ * binding cache (Phase 5 dedup), so consumers no longer need to
1577
+ * make a separate `deviceManager.getBindings` round-trip.
1578
+ */
1579
+ listDevices(e) {
1580
+ return this.mirror ? (e ? this.mirror.query(e) : this.mirror.getAllDevices()).map((r) => this.attachBinding(r)) : [];
1581
+ }
1582
+ /**
1583
+ * Sync lookup by numeric id. `null` if the mirror has not been booted
1584
+ * or the device is unknown.
1585
+ */
1586
+ getDevice(e) {
1587
+ const t = this.mirror?.getDeviceById(e) ?? null;
1588
+ return t ? this.attachBinding(t) : null;
1589
+ }
1590
+ /** Sync lookup by display name (exact match). */
1591
+ getDeviceByName(e) {
1592
+ const t = this.mirror?.getDeviceByName(e) ?? null;
1593
+ return t ? this.attachBinding(t) : null;
1594
+ }
1595
+ /** Sync lookup by stableId. */
1596
+ getDeviceByStableId(e) {
1597
+ const t = this.mirror?.getDeviceByStableId(e) ?? null;
1598
+ return t ? this.attachBinding(t) : null;
1599
+ }
1600
+ /**
1601
+ * Resolve when a device with `deviceId` becomes available. Resolves
1602
+ * immediately if already known; rejects with a timeout error
1603
+ * otherwise (default 30s).
1604
+ */
1605
+ async waitForDevice(e, t) {
1606
+ this.mirror || await this.init();
1607
+ const r = await this.mirror.waitForDevice(e, t ?? 3e4);
1608
+ return this.attachBinding(r);
1609
+ }
1610
+ /** Subscribe to `device.registered` events. */
1611
+ onDeviceAdded(e) {
1612
+ if (!this.mirror)
1613
+ throw new Error("System.onDeviceAdded: call init() before subscribing");
1614
+ return this.mirror.onDeviceAdded(e);
1615
+ }
1616
+ /** Subscribe to `device.unregistered` events. */
1617
+ onDeviceRemoved(e) {
1618
+ if (!this.mirror)
1619
+ throw new Error("System.onDeviceRemoved: call init() before subscribing");
1620
+ return this.mirror.onDeviceRemoved(e);
1621
+ }
1622
+ /**
1623
+ * Patch the proxy's `binding` field from the mirror's cache. The
1624
+ * generated `createDeviceProxy()` already sets `binding` to the
1625
+ * binding it was constructed with — this is a defensive overwrite
1626
+ * that uses the latest cached entry in case a `binding-changed`
1627
+ * event landed between proxy creation and access.
1628
+ */
1629
+ attachBinding(e) {
1630
+ const t = this.lookupBinding(e.deviceId);
1631
+ if (t === e.binding) return e;
1632
+ const r = e;
1633
+ return r.binding = t, e;
1634
+ }
1635
+ /** Fetch the latest cached binding from the mirror, or `null`. */
1636
+ lookupBinding(e) {
1637
+ return this.mirror ? this.mirror.getDeviceById(e)?.binding ?? null : null;
1638
+ }
1639
+ // ── System caps ──────────────────────────────────────────────────
1640
+ //
1641
+ // One getter per `scope: 'system'` capability. The actual surface
1642
+ // comes from `createSystemProxy(api)` (codegen). Adding a new
1643
+ // system cap regenerates the proxy and the new namespace surfaces
1644
+ // automatically via `system.<newCap>.<method>(input)`.
1645
+ get addonPages() {
1646
+ return this._systemProxy.addonPages;
1647
+ }
1648
+ get addonSettings() {
1649
+ return this._systemProxy.addonSettings;
1650
+ }
1651
+ get alerts() {
1652
+ return this._systemProxy.alerts;
1653
+ }
1654
+ get audioAnalyzer() {
1655
+ return this._systemProxy.audioAnalyzer;
1656
+ }
1657
+ get audioCodec() {
1658
+ return this._systemProxy.audioCodec;
1659
+ }
1660
+ get backup() {
1661
+ return this._systemProxy.backup;
1662
+ }
1663
+ get decoder() {
1664
+ return this._systemProxy.decoder;
1665
+ }
1666
+ get deviceManager() {
1667
+ return this._systemProxy.deviceManager;
1668
+ }
1669
+ get deviceProvider() {
1670
+ return this._systemProxy.deviceProvider;
1671
+ }
1672
+ get deviceState() {
1673
+ return this._systemProxy.deviceState;
1674
+ }
1675
+ get metricsProvider() {
1676
+ return this._systemProxy.metricsProvider;
1677
+ }
1678
+ get notificationOutput() {
1679
+ return this._systemProxy.notificationOutput;
1680
+ }
1681
+ get pipelineExecutor() {
1682
+ return this._systemProxy.pipelineExecutor;
1683
+ }
1684
+ get pipelineOrchestrator() {
1685
+ return this._systemProxy.pipelineOrchestrator;
1686
+ }
1687
+ get pipelineRunner() {
1688
+ return this._systemProxy.pipelineRunner;
1689
+ }
1690
+ get platformProbe() {
1691
+ return this._systemProxy.platformProbe;
1692
+ }
1693
+ get recordingEngine() {
1694
+ return this._systemProxy.recordingEngine;
1695
+ }
1696
+ get settingsStore() {
1697
+ return this._systemProxy.settingsStore;
1698
+ }
1699
+ get storage() {
1700
+ return this._systemProxy.storage;
1701
+ }
1702
+ get streamBroker() {
1703
+ return this._systemProxy.streamBroker;
1704
+ }
1705
+ get turnProvider() {
1706
+ return this._systemProxy.turnProvider;
1707
+ }
1708
+ get userManagement() {
1709
+ return this._systemProxy.userManagement;
1710
+ }
1711
+ // ── Live events ──────────────────────────────────────────────────
1712
+ /**
1713
+ * Subscribe to a single event category. Returns an unsubscribe
1714
+ * handle. Errors thrown by the listener are swallowed so a single
1715
+ * misbehaving consumer cannot tear down the WS subscription.
1716
+ *
1717
+ * Categories should be values from the `EventCategory` enum
1718
+ * (`@camstack/types`) — passing a raw string works for forward-compat
1719
+ * but loses type safety. The SDK forwards the value verbatim to the
1720
+ * server's `live.onEvent` subscription.
1721
+ */
1722
+ subscribeEvent(e, t) {
1723
+ const r = this._trpcClient.live.onEvent.subscribe({
1724
+ category: e
1725
+ }, {
1726
+ onData: /* @__PURE__ */ o((n) => {
1727
+ try {
1728
+ t(n);
1729
+ } catch {
1730
+ }
1731
+ }, "onData")
1732
+ });
1733
+ return () => {
1734
+ try {
1735
+ r.unsubscribe();
1736
+ } catch {
1737
+ }
1738
+ };
1739
+ }
1740
+ // ── Escape hatches ───────────────────────────────────────────────
1741
+ //
1742
+ // Kept public so the ui-library `<TrpcProvider>` can seed React
1743
+ // Query with the same WebSocket connection during Phase 2. Phase 4
1744
+ // is expected to revisit whether either field can be hidden.
1745
+ /** Direct tRPC client. Read once per call; rebuilt on `reconnect()`. */
1746
+ get trpcClient() {
1747
+ return this._trpcClient;
1748
+ }
1749
+ /**
1750
+ * Underlying WSClient (or `null` for HTTP transport). Used by
1751
+ * advanced consumers that need direct access to the WebSocket
1752
+ * (e.g. for keep-alive metrics). Rebuilt on `reconnect()`.
1753
+ */
1754
+ get wsClient() {
1755
+ return this._wsClient;
1756
+ }
1757
+ // ── Internals ────────────────────────────────────────────────────
1758
+ buildTrpcClient() {
1759
+ const e = /* @__PURE__ */ o(() => {
1760
+ const t = {};
1761
+ return this.token && (t.Authorization = `Bearer ${this.token}`), t;
1762
+ }, "headers");
1763
+ if (this.useWs) {
1764
+ const t = this.serverUrl.replace(/^http/, "ws") + "/trpc", r = this.baseRetryMs, n = this.maxRetryMs;
1765
+ return this._wsClient = We({
1766
+ url: t,
1767
+ connectionParams: /* @__PURE__ */ o(() => ({
1768
+ token: this.token
1769
+ }), "connectionParams"),
1770
+ retryDelayMs: /* @__PURE__ */ o((i) => Math.min(r * Math.pow(2, i), n), "retryDelayMs"),
1771
+ keepAlive: {
1772
+ enabled: !0,
1773
+ intervalMs: zt,
1774
+ pongTimeoutMs: $t
1775
+ },
1776
+ onOpen: /* @__PURE__ */ o(() => {
1777
+ this._connectionVersion += 1, this.emitConnectionEvent("connected");
1778
+ }, "onOpen"),
1779
+ onClose: /* @__PURE__ */ o(() => {
1780
+ this.emitConnectionEvent("disconnected");
1781
+ }, "onClose")
1782
+ }), $({
1783
+ links: [
1784
+ Be({
1785
+ client: this._wsClient,
1786
+ transformer: Q
1787
+ })
1788
+ ]
1789
+ });
1790
+ }
1791
+ return this._wsClient = null, $({
1792
+ links: [
1793
+ je({
1794
+ url: `${this.serverUrl}/trpc`,
1795
+ headers: e,
1796
+ transformer: Q
1797
+ })
1798
+ ]
1799
+ });
1800
+ }
1801
+ };
1802
+ function Vt(e) {
1803
+ return new Ht(e);
1804
+ }
1805
+ o(Vt, "createSystem");
1806
+ var Kt = /* @__PURE__ */ (function(e) {
1807
+ return e.Motion = "motion", e.Person = "person", e.Vehicle = "vehicle", e.Animal = "animal", e.Audio = "audio", e.Face = "face", e.Plate = "plate", e.Package = "package", e.Doorbell = "doorbell", e.Sensor = "sensor", e;
1808
+ })({}), $e = [
1809
+ "animal",
1810
+ "dog_cat",
1811
+ "dog",
1812
+ "cat",
1813
+ "horse",
1814
+ "sheep",
1815
+ "cow",
1816
+ "elephant",
1817
+ "bear",
1818
+ "zebra",
1819
+ "giraffe",
1820
+ "mouse",
1821
+ "rabbit",
1822
+ "deer",
1823
+ "lion",
1824
+ "tiger",
1825
+ "bird",
1826
+ "eagle",
1827
+ "owl",
1828
+ "pigeon",
1829
+ "fish",
1830
+ "whale",
1831
+ "dolphin",
1832
+ "snake",
1833
+ "turtle",
1834
+ "lizard"
1835
+ ], Ge = [
1836
+ "person",
1837
+ "people",
1838
+ "pedestrian",
1839
+ "rider",
1840
+ "driver",
1841
+ "cyclist",
1842
+ "skier",
1843
+ "skateboarder",
1844
+ "face",
1845
+ "hand",
1846
+ "head",
1847
+ "body"
1848
+ ], Ue = [
1849
+ "vehicle",
1850
+ "car",
1851
+ "truck",
1852
+ "bus",
1853
+ "motorcycle",
1854
+ "bicycle",
1855
+ "van",
1856
+ "ambulance",
1857
+ "police_car",
1858
+ "fire_truck",
1859
+ "train",
1860
+ "subway",
1861
+ "tram",
1862
+ "airplane",
1863
+ "boat",
1864
+ "ship",
1865
+ "helicopter"
1866
+ ], He = [
1867
+ "face",
1868
+ "eyes",
1869
+ "nose",
1870
+ "mouth",
1871
+ "ears",
1872
+ "eyebrows",
1873
+ "left_eye",
1874
+ "right_eye",
1875
+ "pupil",
1876
+ "iris",
1877
+ "eyelid",
1878
+ "eye_corner",
1879
+ "upper_lip",
1880
+ "lower_lip",
1881
+ "teeth",
1882
+ "chin",
1883
+ "cheek",
1884
+ "forehead",
1885
+ "jaw",
1886
+ "glasses",
1887
+ "sunglasses",
1888
+ "facial_hair",
1889
+ "beard",
1890
+ "mustache",
1891
+ "facial_landmark",
1892
+ "facial_keypoint"
1893
+ ], Ve = [
1894
+ "plate",
1895
+ "license_plate",
1896
+ "front_plate",
1897
+ "rear_plate",
1898
+ "motorcycle_plate",
1899
+ "temporary_plate",
1900
+ "dealer_plate",
1901
+ "licensePlate",
1902
+ "plate_number",
1903
+ "plate_character",
1904
+ "plate_digit",
1905
+ "plate_letter",
1906
+ "plate_symbol",
1907
+ "plate_region",
1908
+ "plate_country_identifier",
1909
+ "plate_frame",
1910
+ "plate_bolt",
1911
+ "plate_sticker",
1912
+ "plate_validation_tag",
1913
+ "damaged_plate",
1914
+ "obscured_plate",
1915
+ "dirty_plate"
1916
+ ], Ke = [
1917
+ "motion",
1918
+ "movement",
1919
+ "other"
1920
+ ], Ye = [
1921
+ "package",
1922
+ "packet"
1923
+ ], Je = [
1924
+ "audio"
1925
+ ], Xe = [
1926
+ "speech",
1927
+ "scream",
1928
+ "babbling",
1929
+ "yell",
1930
+ "bellow",
1931
+ "whoop",
1932
+ "whispering",
1933
+ "laughter",
1934
+ "snicker",
1935
+ "crying",
1936
+ "cry",
1937
+ "sigh",
1938
+ "singing",
1939
+ "choir",
1940
+ "chant",
1941
+ "mantra",
1942
+ "child_singing",
1943
+ "rapping",
1944
+ "humming",
1945
+ "groan",
1946
+ "grunt",
1947
+ "whistling",
1948
+ "breathing",
1949
+ "wheeze",
1950
+ "snoring",
1951
+ "gasp",
1952
+ "pant",
1953
+ "snort",
1954
+ "cough",
1955
+ "throat_clearing",
1956
+ "sneeze",
1957
+ "sniff",
1958
+ "cheering",
1959
+ "applause",
1960
+ "chatter",
1961
+ "crowd",
1962
+ "children_playing",
1963
+ "bark",
1964
+ "yip",
1965
+ "howl",
1966
+ "bow-wow",
1967
+ "growling",
1968
+ "whimper_dog",
1969
+ "purr",
1970
+ "meow",
1971
+ "hiss",
1972
+ "caterwaul",
1973
+ "pets",
1974
+ "livestock",
1975
+ "doorbell",
1976
+ "ding-dong",
1977
+ "door",
1978
+ "slam",
1979
+ "knock",
1980
+ "alarm",
1981
+ "telephone",
1982
+ "music",
1983
+ "dog",
1984
+ "dogs"
1985
+ ], Ze = [
1986
+ "doorbell",
1987
+ "ring"
1988
+ ], Qe = [
1989
+ "lock",
1990
+ "binary",
1991
+ "flood",
1992
+ "entry",
1993
+ "door",
1994
+ "leak",
1995
+ "door_open",
1996
+ "flooded",
1997
+ "entry_open"
1998
+ ], et = {
1999
+ ...$e.reduce((e, t) => ({
2000
+ ...e,
2001
+ [t]: "animal"
2002
+ }), {}),
2003
+ ...Ge.reduce((e, t) => ({
2004
+ ...e,
2005
+ [t]: "person"
2006
+ }), {}),
2007
+ ...Ue.reduce((e, t) => ({
2008
+ ...e,
2009
+ [t]: "vehicle"
2010
+ }), {}),
2011
+ ...Ke.reduce((e, t) => ({
2012
+ ...e,
2013
+ [t]: "motion"
2014
+ }), {}),
2015
+ ...Ye.reduce((e, t) => ({
2016
+ ...e,
2017
+ [t]: "package"
2018
+ }), {}),
2019
+ ...He.reduce((e, t) => ({
2020
+ ...e,
2021
+ [t]: "face"
2022
+ }), {}),
2023
+ ...Ve.reduce((e, t) => ({
2024
+ ...e,
2025
+ [t]: "plate"
2026
+ }), {}),
2027
+ ...Je.reduce((e, t) => ({
2028
+ ...e,
2029
+ [t]: "audio"
2030
+ }), {}),
2031
+ ...Xe.reduce((e, t) => ({
2032
+ ...e,
2033
+ [t]: "audio"
2034
+ }), {}),
2035
+ ...Ze.reduce((e, t) => ({
2036
+ ...e,
2037
+ [t]: "doorbell"
2038
+ }), {}),
2039
+ ...Qe.reduce((e, t) => ({
2040
+ ...e,
2041
+ [t]: "sensor"
2042
+ }), {})
2043
+ }, Yt = /* @__PURE__ */ o((e) => He.includes(e), "isFaceClassname"), Jt = /* @__PURE__ */ o((e) => Ve.includes(e), "isPlateClassname"), dr = /* @__PURE__ */ o((e) => $e.includes(e), "isAnimalClassname"), pr = /* @__PURE__ */ o((e) => Ge.includes(e), "isPersonClassname"), fr = /* @__PURE__ */ o((e) => Ue.includes(e), "isVehicleClassname"), hr = /* @__PURE__ */ o((e) => Ke.includes(e), "isMotionClassname"), mr = /* @__PURE__ */ o((e) => Ze.includes(e), "isDoorbellClassname"), yr = /* @__PURE__ */ o((e) => Ye.includes(e), "isPackageClassname"), vr = /* @__PURE__ */ o((e) => Je.includes(e) || Xe.includes(e), "isAudioClassname"), br = /* @__PURE__ */ o((e) => Qe.includes(e), "isSensorLabelClassname"), gr = /* @__PURE__ */ o((e) => Yt(e) || Jt(e), "isLabelDetection"), _r = /* @__PURE__ */ o((e) => et[e], "getParentClass"), Pr = /* @__PURE__ */ o((e) => {
2044
+ const { className: t } = e, r = {
2045
+ face: "person",
2046
+ plate: "vehicle"
2047
+ }, n = et[t];
2048
+ return n && n !== t ? n : r[t];
2049
+ }, "getParentDetectionClass"), Xt = Object.values(Kt), G = Xt.filter((e) => e !== "motion"), tt = [
2050
+ "person",
2051
+ "doorbell",
2052
+ "package"
2053
+ ], Zt = [
2054
+ ...tt,
2055
+ "vehicle",
2056
+ "animal",
2057
+ "audio",
2058
+ "face",
2059
+ "plate"
2060
+ ], Qt = [
2061
+ ...G
2062
+ ];
2063
+ function er(e, t) {
2064
+ switch (e) {
2065
+ case "critical":
2066
+ return tt;
2067
+ case "important":
2068
+ return Zt;
2069
+ case "all":
2070
+ return Qt;
2071
+ case "custom":
2072
+ return t?.length ? t : G;
2073
+ default:
2074
+ return G;
2075
+ }
2076
+ }
2077
+ o(er, "getClassesForTimelinePreset");
2078
+ var se = {
2079
+ // Scrypted PascalCase
2080
+ Light: "light",
2081
+ Switch: "switch",
2082
+ WindowCovering: "cover",
2083
+ Lock: "lock",
2084
+ SecuritySystem: "alarm",
2085
+ Buttons: "button",
2086
+ Select: "select",
2087
+ Siren: "siren",
2088
+ Sensor: "sensor",
2089
+ Entry: "entry",
2090
+ Program: "script",
2091
+ MediaPlayer: "media_player",
2092
+ Outlet: "switch",
2093
+ // Home Assistant lowercase domains
2094
+ light: "light",
2095
+ switch: "switch",
2096
+ input_boolean: "switch",
2097
+ cover: "cover",
2098
+ lock: "lock",
2099
+ alarm_control_panel: "alarm",
2100
+ input_button: "button",
2101
+ button: "button",
2102
+ input_select: "select",
2103
+ select: "select",
2104
+ siren: "siren",
2105
+ sensor: "sensor",
2106
+ media_player: "media_player",
2107
+ script: "script"
2108
+ }, wr = {
2109
+ light: "light",
2110
+ switch: "switch",
2111
+ input_boolean: "switch",
2112
+ cover: "cover",
2113
+ lock: "lock",
2114
+ alarm_control_panel: "alarm",
2115
+ input_button: "button",
2116
+ button: "button",
2117
+ input_select: "select",
2118
+ select: "select",
2119
+ siren: "siren",
2120
+ sensor: "sensor",
2121
+ binary_sensor: "sensor",
2122
+ media_player: "media_player",
2123
+ script: "script",
2124
+ climate: "climate",
2125
+ camera: "camera",
2126
+ fan: "fan",
2127
+ vacuum: "vacuum",
2128
+ automation: "automation",
2129
+ scene: "scene",
2130
+ input_number: "sensor",
2131
+ person: "person",
2132
+ device_tracker: "tracker",
2133
+ weather: "weather",
2134
+ water_heater: "climate"
2135
+ }, xr = {
2136
+ Light: "light",
2137
+ Switch: "switch",
2138
+ WindowCovering: "cover",
2139
+ Lock: "lock",
2140
+ SecuritySystem: "alarm",
2141
+ Buttons: "button",
2142
+ Select: "select",
2143
+ Siren: "siren",
2144
+ Sensor: "sensor",
2145
+ Entry: "entry",
2146
+ Program: "script",
2147
+ MediaPlayer: "media_player",
2148
+ Camera: "camera",
2149
+ Doorbell: "doorbell",
2150
+ Fan: "fan",
2151
+ Outlet: "switch"
2152
+ };
2153
+ function tr(e) {
2154
+ const t = se[e];
2155
+ if (t) return t;
2156
+ const r = e.toLowerCase();
2157
+ return se[r] ?? null;
2158
+ }
2159
+ o(tr, "getCanonicalDeviceType");
2160
+ var rr = [
2161
+ "Entry",
2162
+ "Light",
2163
+ "Switch",
2164
+ "Lock",
2165
+ "SecuritySystem",
2166
+ "Buttons",
2167
+ "WindowCovering",
2168
+ "Siren",
2169
+ "Sensor",
2170
+ "Select",
2171
+ "Program"
2172
+ ], Sr = new Set(rr), nr = [
2173
+ "light",
2174
+ "switch",
2175
+ "input_boolean",
2176
+ "cover",
2177
+ "lock",
2178
+ "alarm_control_panel",
2179
+ "input_button",
2180
+ "button",
2181
+ "input_select",
2182
+ "select",
2183
+ "siren",
2184
+ "media_player",
2185
+ "script"
2186
+ ], Cr = new Set(nr), Z = [
2187
+ {
2188
+ id: "liveStream",
2189
+ label: "Live Stream",
2190
+ sources: {
2191
+ frigate: !0,
2192
+ scrypted: !0,
2193
+ rtsp: !0
2194
+ },
2195
+ adapterMethod: "getLiveStream"
2196
+ },
2197
+ {
2198
+ id: "multiResolution",
2199
+ label: "Multi-Resolution",
2200
+ sources: {
2201
+ frigate: !0,
2202
+ scrypted: !0,
2203
+ rtsp: !1
2204
+ },
2205
+ adapterMethod: "getResolutions"
2206
+ },
2207
+ {
2208
+ id: "motion",
2209
+ label: "Motion Detection",
2210
+ sources: {
2211
+ frigate: !1,
2212
+ scrypted: !0,
2213
+ rtsp: !1
2214
+ },
2215
+ adapterMethod: "getMotion"
2216
+ },
2217
+ {
2218
+ id: "objectDetection",
2219
+ label: "Object Detection",
2220
+ sources: {
2221
+ frigate: !1,
2222
+ scrypted: !0,
2223
+ rtsp: !1
2224
+ },
2225
+ adapterMethod: "getObjectDetections"
2226
+ },
2227
+ {
2228
+ id: "audioVolume",
2229
+ label: "Audio Level",
2230
+ sources: {
2231
+ frigate: !1,
2232
+ scrypted: !0,
2233
+ rtsp: !1
2234
+ },
2235
+ adapterMethod: "getAudioVolume"
2236
+ },
2237
+ {
2238
+ id: "audioVolumes",
2239
+ label: "Audio Volumes (dBFS)",
2240
+ sources: {
2241
+ frigate: !1,
2242
+ scrypted: !0,
2243
+ rtsp: !1
2244
+ },
2245
+ adapterMethod: "getAudioVolumes"
2246
+ },
2247
+ {
2248
+ id: "ptz",
2249
+ label: "PTZ Control",
2250
+ sources: {
2251
+ frigate: !1,
2252
+ scrypted: !0,
2253
+ rtsp: !1
2254
+ },
2255
+ adapterMethod: "getPTZ"
2256
+ },
2257
+ {
2258
+ id: "intercom",
2259
+ label: "Intercom (Mic)",
2260
+ sources: {
2261
+ frigate: !1,
2262
+ scrypted: !0,
2263
+ rtsp: !1
2264
+ },
2265
+ adapterMethod: "getIntercomSupport"
2266
+ },
2267
+ {
2268
+ id: "deviceStatus",
2269
+ label: "Device Status",
2270
+ sources: {
2271
+ frigate: !1,
2272
+ scrypted: !0,
2273
+ rtsp: !1
2274
+ },
2275
+ adapterMethod: "getStatus"
2276
+ },
2277
+ {
2278
+ id: "timeline",
2279
+ label: "Detection Timeline",
2280
+ sources: {
2281
+ frigate: !0,
2282
+ scrypted: !0,
2283
+ rtsp: !1
2284
+ },
2285
+ adapterMethod: "getCameraDayData"
2286
+ },
2287
+ {
2288
+ id: "clusteredTimeline",
2289
+ label: "Clustered Timeline",
2290
+ sources: {
2291
+ frigate: !0,
2292
+ scrypted: !0,
2293
+ rtsp: !1
2294
+ },
2295
+ requiresBackend: !0,
2296
+ adapterMethod: "getClusteredDayData"
2297
+ },
2298
+ {
2299
+ id: "detectionClasses",
2300
+ label: "Detection Classes",
2301
+ sources: {
2302
+ frigate: !0,
2303
+ scrypted: !0,
2304
+ rtsp: !1
2305
+ },
2306
+ adapterMethod: "getDetectionClasses"
2307
+ },
2308
+ {
2309
+ id: "videoClips",
2310
+ label: "Video Clips",
2311
+ sources: {
2312
+ frigate: !0,
2313
+ scrypted: !0,
2314
+ rtsp: !1
2315
+ },
2316
+ adapterMethod: "getVideoClips"
2317
+ },
2318
+ {
2319
+ id: "nvrPlayback",
2320
+ label: "NVR Playback",
2321
+ sources: {
2322
+ frigate: !0,
2323
+ scrypted: !0,
2324
+ rtsp: !1
2325
+ },
2326
+ adapterMethod: "getNvrPlaybackSupported"
2327
+ },
2328
+ {
2329
+ id: "nvrScrub",
2330
+ label: "NVR Scrub/Seek",
2331
+ sources: {
2332
+ frigate: !1,
2333
+ scrypted: !0,
2334
+ rtsp: !1
2335
+ },
2336
+ adapterMethod: "seekRecordingStream"
2337
+ },
2338
+ {
2339
+ id: "recordingThumbnail",
2340
+ label: "Recording Thumbnails",
2341
+ sources: {
2342
+ frigate: !0,
2343
+ scrypted: !0,
2344
+ rtsp: !1
2345
+ },
2346
+ adapterMethod: "getRecordingStreamThumbnail"
2347
+ },
2348
+ {
2349
+ id: "nvrSeekToLive",
2350
+ label: "Seek to Live",
2351
+ sources: {
2352
+ frigate: !1,
2353
+ scrypted: !0,
2354
+ rtsp: !1
2355
+ },
2356
+ adapterMethod: "seekNvrToLive"
2357
+ }
2358
+ ];
2359
+ function ir(e, t, r) {
2360
+ const n = Z.find((i) => i.id === e);
2361
+ return !(!n || !n.sources[t] || n.platforms && n.platforms[r] === !1);
2362
+ }
2363
+ o(ir, "isFeatureAvailable");
2364
+ function or(e) {
2365
+ return Z.filter((t) => t.sources[e]);
2366
+ }
2367
+ o(or, "getSourceFeatures");
2368
+ function sr() {
2369
+ return Z.filter((e) => e.requiresBackend);
2370
+ }
2371
+ o(sr, "getBackendRequiredFeatures");
2372
+ function ar(e, t, r) {
2373
+ if (e.length === 0) return null;
2374
+ const n = t.viewportWidth * t.viewportHeight * (t.pixelRatio ?? 1), i = t.bandwidthMbps ?? 100, s = t.packetLoss ?? 0, c = t.rttMs ?? 50;
2375
+ let a = "high";
2376
+ t.maxResolution === "low" || t.isCellular || i < 1 || s > 0.05 ? a = "low" : t.maxResolution === "medium" || i < 5 || n < 5e5 || c > 200 ? a = "medium" : (t.maxResolution === "high" || n > 2e6) && (a = "high");
2377
+ const u = {
2378
+ main: "high",
2379
+ sub: "medium",
2380
+ ext: "low"
2381
+ }, l = r ?? "native", d = e.map((f) => {
2382
+ let h = 0;
2383
+ const y = u[f.profile] ?? "medium";
2384
+ if (y === a ? h += 100 : (a === "high" && y === "medium" || a === "medium" && y === "high" || a === "medium" && y === "low" || a === "low" && y === "medium") && (h += 50), f.transport === l ? h += 30 : f.transport === "native" ? h += 20 : f.transport === "rtsp" ? h += 15 : f.transport === "rtmp" && (h += 10), f.metadata?.width && f.metadata?.height) {
2385
+ const w = f.metadata.width * f.metadata.height / Math.max(n, 1);
2386
+ w >= 0.8 && w <= 2 ? h += 25 : w >= 0.5 && w <= 3 && (h += 15), w > 4 && i < 10 && (h -= 20);
2387
+ }
2388
+ return f.metadata?.codec && (i < 5 && f.metadata.codec.includes("265") && (h += 10), i >= 10 && f.metadata.codec.includes("264") && (h += 5)), {
2389
+ ...f,
2390
+ score: h,
2391
+ targetTier: a
2392
+ };
2393
+ });
2394
+ d.sort((f, h) => h.score - f.score);
2395
+ const p = d[0];
2396
+ return {
2397
+ streamName: p.streamName,
2398
+ profile: p.profile,
2399
+ transport: p.transport,
2400
+ label: p.label,
2401
+ metadata: p.metadata,
2402
+ reason: `${p.targetTier} quality → ${p.profile}/${p.transport} (score: ${p.score})`
2403
+ };
2404
+ }
2405
+ o(ar, "selectOptimalStream");
2406
+ function cr(e, t) {
2407
+ return t ? 10 : e.isCellular || (e.packetLoss ?? 0) > 0.02 ? 15 : 30;
2408
+ }
2409
+ o(cr, "getNextEvalInterval");
2410
+ /*! Bundled license information:
2411
+
2412
+ @trpc/client/dist/httpLink-lG_6juPY.mjs:
2413
+ (* istanbul ignore if -- @preserve *)
2414
+ */
2415
+ export {
2416
+ G as DEFAULT_ENABLED_CLASSES,
2417
+ Kt as DetectionClass,
2418
+ nr as ELIGIBLE_HA_DOMAINS,
2419
+ Cr as ELIGIBLE_HA_DOMAINS_SET,
2420
+ rr as ELIGIBLE_SCRYPTED_DEVICE_TYPES,
2421
+ Sr as ELIGIBLE_SCRYPTED_DEVICE_TYPES_SET,
2422
+ Z as FEATURE_MATRIX,
2423
+ wr as HA_DOMAIN_TYPE_MAP,
2424
+ se as RAW_TO_CANONICAL,
2425
+ xr as SCRYPTED_TYPE_TO_CANONICAL,
2426
+ Ht as System,
2427
+ Qt as TIMELINE_PRESET_ALL,
2428
+ tt as TIMELINE_PRESET_CRITICAL,
2429
+ Zt as TIMELINE_PRESET_IMPORTANT,
2430
+ $e as animalClasses,
2431
+ Je as audioClasses,
2432
+ Xe as audioLabelClasses,
2433
+ Vt as createSystem,
2434
+ Xt as defaultDetectionClasses,
2435
+ et as detectionClassesDefaultMap,
2436
+ Ze as doorbellClasses,
2437
+ He as faceClasses,
2438
+ sr as getBackendRequiredFeatures,
2439
+ tr as getCanonicalDeviceType,
2440
+ er as getClassesForTimelinePreset,
2441
+ cr as getNextEvalInterval,
2442
+ _r as getParentClass,
2443
+ Pr as getParentDetectionClass,
2444
+ or as getSourceFeatures,
2445
+ dr as isAnimalClassname,
2446
+ vr as isAudioClassname,
2447
+ mr as isDoorbellClassname,
2448
+ Yt as isFaceClassname,
2449
+ ir as isFeatureAvailable,
2450
+ gr as isLabelDetection,
2451
+ hr as isMotionClassname,
2452
+ yr as isPackageClassname,
2453
+ pr as isPersonClassname,
2454
+ Jt as isPlateClassname,
2455
+ br as isSensorLabelClassname,
2456
+ fr as isVehicleClassname,
2457
+ Ve as licensePlateClasses,
2458
+ Ke as motionClasses,
2459
+ Ye as packageClasses,
2460
+ Ge as personClasses,
2461
+ ar as selectOptimalStream,
2462
+ Qe as sensorLabelClasses,
2463
+ Ue as vehicleClasses
2464
+ };