@overvis/hmi-workspace-ui 0.1.0 → 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 (115) hide show
  1. package/dist/alarm-list-sheAq-pb.js +414 -0
  2. package/dist/alarm-rule-dialog-D_ml7V0v.js +417 -0
  3. package/dist/{alarm-rule-lists-C5v1Kf7A.js → alarm-rule-lists-DaA4soF4.js} +123 -125
  4. package/dist/{alarm-rules-page-CqFzofPd.js → alarm-rules-page-OFjOQ-dm.js} +15 -18
  5. package/dist/alert-dialog-B60PF7S9.js +891 -0
  6. package/dist/{base-revision-YCO27zR4.js → base-revision-DYCOZS0R.js} +26 -29
  7. package/dist/{breadcrumbs-0cjsV2cq.js → breadcrumbs-D2u8KZQo.js} +6 -7
  8. package/dist/{catalog-list-DjZojYLJ.js → catalog-list-LXuRix0-.js} +2 -4
  9. package/dist/{code-editor-BVimvjDV.js → code-editor-BMSyzAxu.js} +5 -6
  10. package/dist/dashboard-bindings.js +1 -2
  11. package/dist/{dashboards-page-BlrJguNz.js → dashboards-page-wnmmLpVC.js} +335 -359
  12. package/dist/{de-14WdmJxZ.js → de-hkEr2usK.js} +1 -2
  13. package/dist/diagnostic-text-CsbENUNI.js +116 -0
  14. package/dist/{dialogs-B6BRnf3Q.js → dialogs-AtIYlNSy.js} +219 -227
  15. package/dist/{dialogs-D_v1LeH4.js → dialogs-DsHbKgZD.js} +2523 -2590
  16. package/dist/{display-DmOo23mi.js → display-DSyEwQt8.js} +4 -6
  17. package/dist/{editor-language-To9MxloY.js → editor-language-CTfJBXMs.js} +3 -5
  18. package/dist/editor-page-BWbVGJvU.js +1337 -0
  19. package/dist/{en-BgercpT0.js → en-UW_k-Bd6.js} +1 -2
  20. package/dist/entity-controls-BCuRx882.js +71 -0
  21. package/dist/errors-Cawve9yD.js +25 -0
  22. package/dist/{footer-DC-Q0052.js → footer-B9XdpVzq.js} +2404 -2515
  23. package/dist/host.js +8143 -675
  24. package/dist/{i18n-BgzakKoC.js → i18n-Dt6xbSK6.js} +77 -90
  25. package/dist/i18n.js +1 -2
  26. package/dist/index.js +5149 -5345
  27. package/dist/{lat-lng-B12P7QyY.js → lat-lng-Bl77AGSO.js} +1 -2
  28. package/dist/{list-page-CvsdZb86.js → list-page-agHupfNb.js} +116 -123
  29. package/dist/{location-map-renderer-DO5yfdSU.js → location-map-renderer-kxU6cgFl.js} +6 -6
  30. package/dist/{location-picker-renderer-CjCxg6ai.js → location-picker-renderer-B1_-n8lf.js} +3 -4
  31. package/dist/{model-B8gGi4OK.js → model-tpg_xpFB.js} +1 -2
  32. package/dist/{notice-card-DyGywFsW.js → notice-card-CH28rYUt.js} +54 -58
  33. package/dist/{page-v6LCwswN.js → page-CZPHJUmz.js} +92 -100
  34. package/dist/page-DpdkOGGb.js +449 -0
  35. package/dist/page-HCGXXGjy.js +507 -0
  36. package/dist/panel-BCwBlB_h.js +949 -0
  37. package/dist/parameter-values.js +3 -16
  38. package/dist/{pl-lQ9HXV9k.js → pl-BokvsP3J.js} +1 -2
  39. package/dist/presence-code-cT6wxlTg.js +73 -0
  40. package/dist/{query-gate-DVhNIkge.js → query-gate-DqmHsZ07.js} +6 -6
  41. package/dist/{provider-DoEpKcQ-.js → quick-report-DEqqwQxR.js} +9423 -5102
  42. package/dist/{retention-BYXNpYmR.js → retention-DZ0reGGe.js} +4 -6
  43. package/dist/retention-note-nequESpo.js +40 -0
  44. package/dist/{rolldown-runtime-Dy4uBu1J.js → rolldown-runtime-CGnMp29N.js} +1 -2
  45. package/dist/{ru-qTKINoUj.js → ru-DZSlsRHq.js} +1 -2
  46. package/dist/run-text-DneX9rWh.js +112 -0
  47. package/dist/{search-D4rDnE9T.js → search-DP9_alSQ.js} +26 -29
  48. package/dist/{sections-kCOyc4NR.js → sections-BU7NKUOQ.js} +2 -3
  49. package/dist/{select-BKiOWdSr.js → select-Te6Qv1Zu.js} +17 -23
  50. package/dist/{spinner-C-HPNxOc.js → spinner-BRcNKwjH.js} +182 -201
  51. package/dist/src/version.d.ts +1 -1
  52. package/dist/src/workspace/local-workspace-app.d.ts +1 -1
  53. package/dist/src/workspace/routes.d.ts +1 -1
  54. package/dist/{starter-fields-BRLX0z-v.js → starter-fields-yM4B49nd.js} +154 -157
  55. package/dist/{starter-handoff-BA3ucMKL.js → starter-handoff-BaK8Ss8I.js} +1 -2
  56. package/dist/styles.css +1 -1
  57. package/dist/ui.js +334 -374
  58. package/dist/{uk-CwpJAxmx.js → uk-CjXPq9Lk.js} +1 -2
  59. package/dist/{wireguard-docs-AfU6NzTL.js → wireguard-docs-CC8XKBR7.js} +14 -17
  60. package/package.json +15 -9
  61. package/dist/alarm-list-BL3xQ5Lf.js +0 -423
  62. package/dist/alarm-rule-dialog-S1ZUg-74.js +0 -423
  63. package/dist/alert-B8MAoIO8.js +0 -45
  64. package/dist/alert-dialog-CYkuMg5D.js +0 -129
  65. package/dist/api-error-9rQmUN5L.js +0 -93
  66. package/dist/breadcrumb-DzVL1yHa.js +0 -74
  67. package/dist/button-6SxPBYMz.js +0 -44
  68. package/dist/context-u9KJQmdB.js +0 -102
  69. package/dist/copyable-id-DYGiAcnq.js +0 -40
  70. package/dist/dashboard-context-CBfG6DoT.js +0 -191
  71. package/dist/date-time-picker-C3FhMXk6.js +0 -266
  72. package/dist/diagnostic-text-BAkzW0SE.js +0 -111
  73. package/dist/diagnostic-text-DiKd2i1w.js +0 -76
  74. package/dist/dialog-BIhQXcZC.js +0 -237
  75. package/dist/dialog-BqyIxMD-.js +0 -54
  76. package/dist/dropdown-menu-DSzbBq3v.js +0 -136
  77. package/dist/editor-page-BiSZJz5b.js +0 -1353
  78. package/dist/empty-B-QJ-06w.js +0 -59
  79. package/dist/entity-controls-D1K4Ot3O.js +0 -76
  80. package/dist/errors-CcsvDHu8.js +0 -26
  81. package/dist/history-page-sAAhG54V.js +0 -1400
  82. package/dist/icon-D-pR9htW.js +0 -57
  83. package/dist/index-page-DMH82fZe.js +0 -214
  84. package/dist/item-B5SaTFQU.js +0 -120
  85. package/dist/mutation-form-validators-BNz5bsv1.js +0 -2408
  86. package/dist/mutations-THtGG6Ai.js +0 -240
  87. package/dist/page-2KPemaAj.js +0 -328
  88. package/dist/page-6rIoTg2L.js +0 -459
  89. package/dist/page-C6giEoEd.js +0 -1935
  90. package/dist/page-DCbTxKsi.js +0 -313
  91. package/dist/page-DWO427hT.js +0 -208
  92. package/dist/page-LXu_2zm3.js +0 -137
  93. package/dist/page-aaUiVOnk.js +0 -513
  94. package/dist/page-header-RB2YFWlE.js +0 -55
  95. package/dist/page-title-CdCbiLt8.js +0 -14
  96. package/dist/panel-DDy8tUNR.js +0 -338
  97. package/dist/presence-code-BfSXr50g.js +0 -83
  98. package/dist/progress-C7cxNJA1.js +0 -83
  99. package/dist/provider-BOeYHi0n.js +0 -134
  100. package/dist/quick-report-CUVJnbKP.js +0 -416
  101. package/dist/radio-group-CZGqVbkJ.js +0 -26
  102. package/dist/retention-note-CHhA6gjY.js +0 -42
  103. package/dist/run-text-DvaO8LDF.js +0 -113
  104. package/dist/select-eNgZdZ30.js +0 -521
  105. package/dist/skeleton-6yk8Tdh5.js +0 -19
  106. package/dist/slider-DorDsoF8.js +0 -37
  107. package/dist/status-page-DAHiKM9P.js +0 -3286
  108. package/dist/switch-BqD0RH_G.js +0 -18
  109. package/dist/table-Q2-voLuw.js +0 -65
  110. package/dist/tabs-CSIucYFP.js +0 -57
  111. package/dist/theme-provider-BkRohQFU.js +0 -61
  112. package/dist/toggle-group-9Bs0Mm3r.js +0 -82
  113. package/dist/trpc-CvJUuUXp.js +0 -153
  114. package/dist/utils-CX-Pz5p6.js +0 -8
  115. package/dist/writability-BuH-spxv.js +0 -57
@@ -1,1935 +0,0 @@
1
- import { t as e } from "./rolldown-runtime-Dy4uBu1J.js";
2
- import { r as t } from "./trpc-CvJUuUXp.js";
3
- import { f as n, h as r, m as i, n as a } from "./i18n-BgzakKoC.js";
4
- import { B as o, L as s, S as c, Y as l, a as u, at as d, b as f, d as p, i as m, n as h, t as g, x as _, y as v, z as y } from "./mutation-form-validators-BNz5bsv1.js";
5
- import { A as b, B as x, H as S, L as C, M as w, V as T, Y as E, c as D, d as O, f as k, g as A, j, t as M } from "./spinner-C-HPNxOc.js";
6
- import { t as N } from "./button-6SxPBYMz.js";
7
- import { a as P, i as F, l as I, o as L, r as R, t as z } from "./dialog-BIhQXcZC.js";
8
- import { n as ee } from "./skeleton-6yk8Tdh5.js";
9
- import { a as te, s as ne } from "./context-u9KJQmdB.js";
10
- import { n as re } from "./api-error-9rQmUN5L.js";
11
- import { _ as ie, a as B, c as ae, d as V, f as oe, h as se, i as H, l as U, m as ce, n as le, o as ue, p as de, r as fe, s as pe, t as me, u as W, x as he } from "./quick-report-CUVJnbKP.js";
12
- import { r as ge } from "./writability-BuH-spxv.js";
13
- import { t as _e } from "./switch-BqD0RH_G.js";
14
- import { c as ve } from "./mutations-THtGG6Ai.js";
15
- import { t as ye } from "./copyable-id-DYGiAcnq.js";
16
- import { n as be } from "./icon-D-pR9htW.js";
17
- import { a as G, h as xe, r as Se, t as Ce } from "./dropdown-menu-DSzbBq3v.js";
18
- import { t as we } from "./page-header-RB2YFWlE.js";
19
- import { i as Te, r as Ee, t as De } from "./tabs-CSIucYFP.js";
20
- import { t as Oe } from "./breadcrumbs-0cjsV2cq.js";
21
- import { r as ke, t as Ae } from "./retention-note-CHhA6gjY.js";
22
- import { t as je } from "./model-B8gGi4OK.js";
23
- import { c as Me, d as Ne, f as Pe, h as Fe, l as Ie, m as Le, n as Re, o as ze, p as Be, s as Ve, u as He } from "./dialogs-B6BRnf3Q.js";
24
- import { createContext as Ue, createElement as We, memo as Ge, useCallback as K, useContext as Ke, useEffect as q, useMemo as J, useRef as qe, useState as Y, useSyncExternalStore as Je } from "react";
25
- import { Fragment as X, jsx as Z, jsxs as Q } from "react/jsx-runtime";
26
- import { ChartLineIcon as Ye, ChevronDownIcon as Xe, ChevronRightIcon as Ze, ChevronsDownUpIcon as Qe, ChevronsUpDownIcon as $e, ClockIcon as et, EraserIcon as tt, HistoryIcon as nt, ListTreeIcon as rt, MoreHorizontalIcon as it, PlusIcon as at, Trash2Icon as ot } from "lucide-react";
27
- import { formatAppDateTime as st, resolveLocalized as $ } from "@overvis/hmi-shared";
28
- import { STORAGE_MAX_TARGETS as ct, canManageWorkspace as lt } from "@overvis/hmi-shared/workspace";
29
- import { parameterBranchNameFormSchema as ut, parameterTemplateStampFormSchema as dt, parameterTemplateStampFormToInput as ft, parseParameterUnitIdString as pt } from "@overvis/hmi-shared/parameter";
30
- import { REPORT_PRESET_LIST_BY_PARAMETER_IDS_MAX as mt } from "@overvis/hmi-shared/report";
31
- import { Link as ht, useNavigate as gt } from "@tanstack/react-router";
32
- //#region src/workspace/page-state/branch-path.ts
33
- function _t(e) {
34
- let t = [], n = /* @__PURE__ */ new Set(), r = e.branchId;
35
- for (; r != null && !n.has(r);) {
36
- n.add(r);
37
- let i = e.branchesById.get(r);
38
- if (i == null) break;
39
- t.push($(i.name, e.locale)), r = i.parentId;
40
- }
41
- return t.reverse();
42
- }
43
- //#endregion
44
- //#region src/workspace/page-state/parameters.ts
45
- function vt(e) {
46
- let t = new Map(e.parameters.map((e) => [e.id, e])), n = new Map(e.branches.map((e) => [e.id, e])), r = [];
47
- for (let i of e.selection.selectedParamIds) {
48
- let a = t.get(i);
49
- a != null && r.push({
50
- id: a.id,
51
- name: $(a.name, e.locale),
52
- units: je(a.units, e.locale),
53
- valueType: a.valueType.name,
54
- branchPath: _t({
55
- branchId: a.branchId,
56
- branchesById: n,
57
- locale: e.locale
58
- })
59
- });
60
- }
61
- let i = [];
62
- for (let t of e.selection.selectedBranchIds) {
63
- let r = n.get(t);
64
- r != null && i.push({
65
- id: r.id,
66
- name: $(r.name, e.locale)
67
- });
68
- }
69
- return {
70
- kind: "parameters",
71
- selectedParameters: r,
72
- selectedBranches: i
73
- };
74
- }
75
- //#endregion
76
- //#region src/workspace/parameters/value/reads.tsx
77
- var yt = 1e3;
78
- function bt() {
79
- let e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Map();
80
- function n(n) {
81
- if (n === e) return;
82
- let r = e;
83
- e = n;
84
- let i = /* @__PURE__ */ new Set();
85
- for (let [e, t] of n) r.get(e) !== t && i.add(e);
86
- for (let e of r.keys()) n.has(e) || i.add(e);
87
- for (let e of i) {
88
- let n = t.get(e);
89
- if (n != null) for (let e of n) e();
90
- }
91
- }
92
- return {
93
- get: (t) => e.get(t),
94
- subscribe(e, n) {
95
- let r = t.get(e);
96
- return r ?? (r = /* @__PURE__ */ new Set(), t.set(e, r)), r.add(n), () => {
97
- r.delete(n), r.size === 0 && t.delete(e);
98
- };
99
- },
100
- update: (t) => {
101
- n(t(e));
102
- }
103
- };
104
- }
105
- var xt = Ue(null);
106
- function St({ store: e, children: t }) {
107
- return We(xt.Provider, { value: e }, t);
108
- }
109
- var Ct = Ue(null);
110
- function wt({ value: e, children: t }) {
111
- return We(Ct.Provider, { value: e }, t);
112
- }
113
- var Tt = Ue("repr");
114
- function Et({ mode: e, children: t }) {
115
- return We(Tt.Provider, { value: e }, t);
116
- }
117
- function Dt() {
118
- return Ke(Tt);
119
- }
120
- function Ot(e, t) {
121
- let [n, r] = Y(!1), [i, s] = Y(null), [c, l] = Y(() => e.getSnapshot().selectedParamIds), [u] = Y(bt), d = o({
122
- parameterIds: J(() => Be(c, t), [t, c]),
123
- intervalMs: yt,
124
- enabled: n
125
- }), f = y();
126
- q(() => e.subscribe(() => {
127
- let t = e.getSnapshot().selectedParamIds;
128
- l(t), t.size === 0 && r(!1);
129
- }), [e]), q(() => {
130
- u.update((e) => {
131
- let t = !1, n = new Map(e);
132
- for (let [r, i] of d.states) {
133
- let a = de(e.get(r), i);
134
- a != null && a !== e.get(r) && (n.set(r, a), t = !0);
135
- }
136
- return t ? n : e;
137
- });
138
- }, [d.states, u]);
139
- let p = K(() => {
140
- s(null);
141
- }, []), m = K((e) => {
142
- s(e);
143
- }, []), h = a(), g = K((e, t) => {
144
- s(null), f.writeValues({ items: [{
145
- paramId: e,
146
- ...t
147
- }] }).then((t) => {
148
- let n = t.results[e];
149
- if (n?.status !== "error") return;
150
- let r = "reason" in n.error ? n.error.reason : void 0, i = "params" in n.error ? n.error.params : void 0;
151
- h.error(he({
152
- code: n.error.code,
153
- ...r == null ? {} : { reason: r },
154
- ...i == null ? {} : { params: i }
155
- }));
156
- }).catch((e) => {
157
- h.error(re(e));
158
- });
159
- }, [f, h]), _ = K((e) => {
160
- e && c.size === 0 || (e && s(null), r(e));
161
- }, [c.size]), v = K((e) => {
162
- e === 0 && r(!1);
163
- }, []), b = K((e) => {
164
- s(null);
165
- let n = Be(new Set(e), t);
166
- f.refreshValues(n.length > 0 ? n : e);
167
- }, [f, t]);
168
- return {
169
- live: n,
170
- setLiveEnabled: _,
171
- clearParamSelectionSideEffects: v,
172
- paramValueStore: u,
173
- readPending: d.reading,
174
- anySaving: d.saving,
175
- runRead: b,
176
- editingParamId: i,
177
- startEdit: m,
178
- cancelEdit: p,
179
- commitWrite: g
180
- };
181
- }
182
- //#endregion
183
- //#region src/workspace/setup/parameters/dialogs.tsx
184
- function kt({ workspaceId: e, dialog: t, onCancel: n, onDone: r }) {
185
- let a = i(), { createBranch: o, updateBranch: s } = ve(e), c = u({
186
- defaultValues: { name: t.mode === "rename" ? t.name : "" },
187
- validators: g({
188
- schema: ut,
189
- submit: async (n) => {
190
- let r = n.name.trim();
191
- return t.mode === "rename" ? await s.mutateAsync({
192
- id: t.branchId,
193
- name: r,
194
- ...t.revision === void 0 ? {} : { baseRevision: t.revision }
195
- }) : t.mode === "create-child" ? await o.mutateAsync({
196
- parentId: t.parentId,
197
- name: r
198
- }) : await o.mutateAsync({
199
- workspaceId: e,
200
- parentId: null,
201
- name: r
202
- }), null;
203
- },
204
- mapError: (e, t) => m(e, t, { codeFields: ke })
205
- }),
206
- onSubmitInvalid: p,
207
- onSubmit: () => {
208
- r(t.mode);
209
- }
210
- });
211
- return /* @__PURE__ */ Z(c.AppForm, { children: /* @__PURE__ */ Q(c.FormRoot, {
212
- layout: "dialog",
213
- children: [
214
- /* @__PURE__ */ Q(L, { children: [/* @__PURE__ */ Z(I, { children: t.mode === "rename" ? a("parameter_rename_branch") : t.mode === "create-child" ? a("parameter_create_child_branch_title") : a("parameter_create_root_branch_title") }), t.mode === "rename" ? /* @__PURE__ */ Z(ye, { id: t.branchId }) : null] }),
215
- /* @__PURE__ */ Q(T, { children: [/* @__PURE__ */ Z(c.AppField, {
216
- name: "name",
217
- children: (e) => /* @__PURE__ */ Z(e.TextField, {
218
- label: a("parameter_branch_field_name"),
219
- id: "parameter-branch-name",
220
- autoFocus: !0
221
- })
222
- }), t.mode === "rename" ? /* @__PURE__ */ Z(Ae, {
223
- workspaceId: e,
224
- target: {
225
- kind: "branch",
226
- id: t.branchId
227
- }
228
- }) : null] }),
229
- /* @__PURE__ */ Q(P, { children: [/* @__PURE__ */ Z(N, {
230
- type: "button",
231
- variant: "outline",
232
- onClick: () => {
233
- n();
234
- },
235
- children: a("action_cancel")
236
- }), /* @__PURE__ */ Z(c.SubmitButton, {
237
- label: t.mode === "rename" ? a("parameter_rename_branch_submit") : a("parameter_create_branch_submit"),
238
- pendingLabel: t.mode === "rename" ? a("action_saving") : a("action_creating")
239
- })] })
240
- ]
241
- }) });
242
- }
243
- function At(e, t) {
244
- return Object.fromEntries(e.flatMap((e) => {
245
- let n = t.get(e);
246
- return n === void 0 ? [] : [[e, n]];
247
- }));
248
- }
249
- function jt({ workspaceId: e, paramIds: n, branchIds: a, subtreeByBranchId: o, revisions: s, onCancel: c, onDeleted: l }) {
250
- let d = i(), f = r(), [h, _] = Y(!1), v = ve(e).removeSelection, [y] = Y(() => ({
251
- paramBases: At(n, s.params),
252
- branchBases: At(a, s.branches)
253
- })), { paramCount: b, branchCount: x } = J(() => Ne(n, a, o), [
254
- n,
255
- a,
256
- o
257
- ]), S = J(() => Pe(n, a, o), [
258
- n,
259
- a,
260
- o
261
- ]), C = S.length > mt, w = S.length > 0 && !C, T = t.report.preset.listByParameterIds.useQuery({
262
- workspaceId: e,
263
- parameterIds: w ? S : []
264
- }, {
265
- enabled: w,
266
- staleTime: 0,
267
- refetchOnMount: "always"
268
- }), E = w && T.fetchStatus === "paused", D = T.data == null, O = w && (T.isPending || E && D || T.isFetching && D), k = w && T.isError && !T.isFetching && !E, A = k || E && D, j = C ? [] : T.data?.reportPresets ?? [], M = S.length === 0 || w && !O && !k && !h, R = u({
269
- defaultValues: {},
270
- validators: g({
271
- submit: async () => (await v.mutateAsync({
272
- paramIds: n,
273
- branchIds: a,
274
- ...y
275
- }), null),
276
- mapError: (e, t) => m(e, t, { codeFields: ke })
277
- }),
278
- onSubmitInvalid: p,
279
- onSubmit: () => {
280
- l();
281
- }
282
- });
283
- return /* @__PURE__ */ Z(R.AppForm, { children: /* @__PURE__ */ Q(R.FormRoot, {
284
- layout: "dialog",
285
- children: [
286
- /* @__PURE__ */ Q(L, { children: [/* @__PURE__ */ Z(I, { children: d("parameter_delete_title") }), /* @__PURE__ */ Z(F, { children: d("parameter_delete_description", {
287
- params: String(b),
288
- branches: String(x)
289
- }) })] }),
290
- O ? /* @__PURE__ */ Z("p", {
291
- className: "text-sm text-muted-foreground",
292
- children: d("parameter_delete_reports_checking")
293
- }) : null,
294
- C ? /* @__PURE__ */ Z("p", {
295
- className: "text-sm",
296
- children: d("parameter_delete_reports_over_cap")
297
- }) : null,
298
- A ? /* @__PURE__ */ Q("div", {
299
- className: "flex flex-col items-start gap-2",
300
- children: [k ? /* @__PURE__ */ Z("p", {
301
- className: "text-sm text-destructive",
302
- role: "alert",
303
- children: d("parameter_delete_reports_error")
304
- }) : null, /* @__PURE__ */ Z(N, {
305
- type: "button",
306
- variant: "outline",
307
- size: "sm",
308
- disabled: h,
309
- onClick: () => {
310
- _(!0), T.refetch().finally(() => {
311
- _(!1);
312
- });
313
- },
314
- children: d("parameter_delete_reports_retry")
315
- })]
316
- }) : null,
317
- j.length > 0 ? /* @__PURE__ */ Q("div", {
318
- className: "flex flex-col gap-2",
319
- children: [/* @__PURE__ */ Z("p", {
320
- className: "text-sm",
321
- children: d("parameter_delete_reports_will_lose")
322
- }), /* @__PURE__ */ Z("ul", {
323
- className: "max-h-40 overflow-y-auto text-sm",
324
- children: j.map((e) => /* @__PURE__ */ Z("li", { children: $(e.title, f) }, e.id))
325
- })]
326
- }) : null,
327
- /* @__PURE__ */ Q(P, { children: [/* @__PURE__ */ Z(N, {
328
- type: "button",
329
- variant: "outline",
330
- onClick: () => {
331
- c();
332
- },
333
- children: d("action_cancel")
334
- }), /* @__PURE__ */ Z(R.SubmitButton, {
335
- label: d("parameter_delete_action"),
336
- pendingLabel: d("action_deleting"),
337
- variant: "destructive",
338
- disabled: !M
339
- })] })
340
- ]
341
- }) });
342
- }
343
- //#endregion
344
- //#region src/workspace/setup/parameters/tree/expand.ts
345
- function Mt(e) {
346
- let t = new Set(e.expanded);
347
- if (e.shiftKey) {
348
- let n = e.subtreeBranchIds ?? [e.branchId];
349
- for (let r of n) e.visuallyOpen ? t.delete(r) : t.add(r);
350
- } else e.visuallyOpen ? t.delete(e.branchId) : t.add(e.branchId);
351
- return t;
352
- }
353
- function Nt(e, t) {
354
- if (e.size !== t.size) return !1;
355
- for (let n of e) if (!t.has(n)) return !1;
356
- return !0;
357
- }
358
- //#endregion
359
- //#region src/workspace/setup/parameters/selection.tsx
360
- function Pt(e) {
361
- if (e != null) for (let t of e) t();
362
- }
363
- function Ft(e, t, n) {
364
- let r = e.get(t) ?? /* @__PURE__ */ new Set();
365
- return e.set(t, r), r.add(n), () => {
366
- r.delete(n), r.size === 0 && e.delete(t);
367
- };
368
- }
369
- function It(e) {
370
- let t = {
371
- selectedParamIds: new Set(e?.selectedParamIds ?? []),
372
- selectedBranchIds: new Set(e?.selectedBranchIds ?? []),
373
- checkStateByBranchId: /* @__PURE__ */ new Map()
374
- }, n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map();
375
- return {
376
- getSnapshot() {
377
- return t;
378
- },
379
- getParamSelected(e) {
380
- return t.selectedParamIds.has(e);
381
- },
382
- getBranchCheck(e) {
383
- return t.checkStateByBranchId.get(e) ?? !1;
384
- },
385
- subscribe(e) {
386
- return n.add(e), () => {
387
- n.delete(e);
388
- };
389
- },
390
- subscribeParam: (e, t) => Ft(r, e, t),
391
- subscribeBranch: (e, t) => Ft(i, e, t),
392
- commit(e) {
393
- let a = t, o = [];
394
- for (let t of e.selectedParamIds) a.selectedParamIds.has(t) || o.push(t);
395
- for (let t of a.selectedParamIds) e.selectedParamIds.has(t) || o.push(t);
396
- let s = !Nt(e.selectedBranchIds, a.selectedBranchIds), c = [], l = /* @__PURE__ */ new Set([...a.checkStateByBranchId.keys(), ...e.checkStateByBranchId.keys()]);
397
- for (let t of l) (a.checkStateByBranchId.get(t) ?? !1) !== (e.checkStateByBranchId.get(t) ?? !1) && c.push(t);
398
- if (o.length === 0 && c.length === 0 && !s) return !1;
399
- t = e;
400
- for (let e of o) Pt(r.get(e));
401
- for (let e of c) Pt(i.get(e));
402
- return Pt(n), !0;
403
- }
404
- };
405
- }
406
- var Lt = Ue(null);
407
- function Rt({ store: e, children: t }) {
408
- return We(Lt.Provider, { value: e }, t);
409
- }
410
- function zt() {
411
- let e = Ke(Lt);
412
- if (e == null) throw Error("ParamTreeSelectionProvider is required");
413
- return e;
414
- }
415
- function Bt({ paramId: e, branchId: t, label: n, onParamCheck: r }) {
416
- let i = zt();
417
- return /* @__PURE__ */ Z(E, {
418
- "aria-label": n,
419
- checked: Je((t) => i.subscribeParam(e, t), () => i.getParamSelected(e), () => i.getParamSelected(e)),
420
- onCheckedChange: (n) => {
421
- r(e, t, n);
422
- }
423
- });
424
- }
425
- function Vt({ branchId: e, label: t, onBranchCheck: n }) {
426
- let r = zt(), i = Je((t) => r.subscribeBranch(e, t), () => r.getBranchCheck(e), () => r.getBranchCheck(e));
427
- return /* @__PURE__ */ Z(E, {
428
- "aria-label": t,
429
- checked: i === !0,
430
- indeterminate: i === "indeterminate",
431
- onCheckedChange: (t) => {
432
- n(e, t);
433
- }
434
- });
435
- }
436
- function Ht(e) {
437
- return Je(e.subscribe, e.getSnapshot, e.getSnapshot);
438
- }
439
- //#endregion
440
- //#region src/workspace/setup/parameters/stamp-from-template-form.tsx
441
- function Ut(e) {
442
- return {
443
- workspace: e.filter((e) => e.origin === "workspace"),
444
- overvis: e.filter((e) => e.origin === "overvis")
445
- };
446
- }
447
- function Wt(e) {
448
- let t = e.rootBranchName.trim();
449
- return e.templateId.length === 0 || e.endpointId.length === 0 || t.length === 0 || pt(e.unitId) == null ? !1 : dt["~standard"].validate({
450
- ...e,
451
- rootBranchName: t
452
- }).issues === void 0;
453
- }
454
- function Gt({ workspaceId: e, onCancel: a, onDone: o }) {
455
- let s = i(), c = r(), l = t.templates.parameter.list.useQuery({ workspaceId: e }), f = t.endpoint.list.useQuery({ workspaceId: e }), m = ve(e).stampTemplate, _ = l.data?.templates ?? [], v = Ut(_), y = f.data?.endpoints ?? [], E = l.isLoading, D = f.isLoading, O = l.isError, k = f.isError, A = !E && !O && _.length === 0, M = !D && !k && y.length === 0, R = u({
456
- defaultValues: {
457
- templateId: "",
458
- endpointId: "",
459
- rootBranchName: "",
460
- unitId: ""
461
- },
462
- validators: g({
463
- schema: dt,
464
- submit: async (t) => {
465
- let r = ft(t, { workspaceId: e });
466
- return r.ok ? (await m.mutateAsync(r.input), null) : h(r, ({ problem: e }) => n(e === "unit_id_invalid" ? "error_template_unit_id_required" : "error_parameter_name_invalid"));
467
- }
468
- }),
469
- onSubmitInvalid: p,
470
- onSubmit: () => {
471
- o();
472
- }
473
- });
474
- return /* @__PURE__ */ Z(R.AppForm, { children: /* @__PURE__ */ Q(R.FormRoot, {
475
- layout: "dialog",
476
- children: [
477
- /* @__PURE__ */ Q(L, { children: [/* @__PURE__ */ Z(I, { children: s("parameter_from_template_title") }), /* @__PURE__ */ Z(F, { children: s("parameter_from_template_description") })] }),
478
- /* @__PURE__ */ Q(T, { children: [
479
- /* @__PURE__ */ Z(R.AppField, {
480
- name: "templateId",
481
- children: (e) => {
482
- let t = !e.state.meta.isValid, n = d(e.state.meta.errors, e.name), r = E || O || A;
483
- return /* @__PURE__ */ Q(C, {
484
- "data-invalid": t ? !0 : void 0,
485
- children: [
486
- /* @__PURE__ */ Z(S, {
487
- htmlFor: "parameter-from-template-template",
488
- children: s("parameter_from_template_field_template")
489
- }),
490
- /* @__PURE__ */ Z(b, {
491
- id: "parameter-from-template-template",
492
- className: "w-full",
493
- value: e.state.value,
494
- disabled: r,
495
- "aria-invalid": t || void 0,
496
- onBlur: e.handleBlur,
497
- onChange: (t) => {
498
- let n = t.target.value;
499
- e.handleChange(n);
500
- let r = _.find((e) => e.id === n);
501
- r != null && (R.setFieldValue("rootBranchName", $(r.title, c)), R.setFieldValue("unitId", String(r.defaultUnitId ?? 1)));
502
- },
503
- children: E ? /* @__PURE__ */ Z(w, {
504
- value: "",
505
- children: s("parameter_from_template_template_loading")
506
- }) : O ? /* @__PURE__ */ Z(w, {
507
- value: "",
508
- children: s("parameter_from_template_template_error")
509
- }) : A ? /* @__PURE__ */ Z(w, {
510
- value: "",
511
- children: s("parameter_from_template_template_empty")
512
- }) : /* @__PURE__ */ Q(X, { children: [
513
- /* @__PURE__ */ Z(w, { value: "" }),
514
- v.workspace.length > 0 ? /* @__PURE__ */ Z(j, {
515
- label: s("parameter_from_template_group_workspace"),
516
- children: v.workspace.map((e) => /* @__PURE__ */ Z(w, {
517
- value: e.id,
518
- children: $(e.title, c)
519
- }, e.id))
520
- }) : null,
521
- v.overvis.length > 0 ? /* @__PURE__ */ Z(j, {
522
- label: s("parameter_from_template_group_overvis"),
523
- children: v.overvis.map((e) => /* @__PURE__ */ Z(w, {
524
- value: e.id,
525
- children: $(e.title, c)
526
- }, e.id))
527
- }) : null
528
- ] })
529
- }),
530
- /* @__PURE__ */ Z(x, { errors: n })
531
- ]
532
- });
533
- }
534
- }),
535
- /* @__PURE__ */ Z(R.AppField, {
536
- name: "endpointId",
537
- children: (e) => {
538
- let t = !e.state.meta.isValid, n = d(e.state.meta.errors, e.name), r = D || k || M;
539
- return /* @__PURE__ */ Q(C, {
540
- "data-invalid": t ? !0 : void 0,
541
- children: [
542
- /* @__PURE__ */ Z(S, {
543
- htmlFor: "parameter-from-template-endpoint",
544
- children: s("parameter_from_template_field_endpoint")
545
- }),
546
- /* @__PURE__ */ Z(b, {
547
- id: "parameter-from-template-endpoint",
548
- className: "w-full",
549
- value: e.state.value,
550
- disabled: r,
551
- "aria-invalid": t || void 0,
552
- onBlur: e.handleBlur,
553
- onChange: (t) => {
554
- e.handleChange(t.target.value);
555
- },
556
- children: D ? /* @__PURE__ */ Z(w, {
557
- value: "",
558
- children: s("parameter_from_template_endpoint_loading")
559
- }) : k ? /* @__PURE__ */ Z(w, {
560
- value: "",
561
- children: s("parameter_from_template_endpoint_error")
562
- }) : M ? /* @__PURE__ */ Z(w, {
563
- value: "",
564
- children: s("parameter_from_template_endpoint_empty")
565
- }) : /* @__PURE__ */ Q(X, { children: [/* @__PURE__ */ Z(w, { value: "" }), y.map((e) => /* @__PURE__ */ Z(w, {
566
- value: e.id,
567
- children: $(e.name, c)
568
- }, e.id))] })
569
- }),
570
- /* @__PURE__ */ Z(x, { errors: n })
571
- ]
572
- });
573
- }
574
- }),
575
- /* @__PURE__ */ Z(R.AppField, {
576
- name: "rootBranchName",
577
- children: (e) => /* @__PURE__ */ Z(e.TextField, {
578
- label: s("parameter_from_template_field_root_name"),
579
- id: "parameter-from-template-root-name"
580
- })
581
- }),
582
- /* @__PURE__ */ Z(R.AppField, {
583
- name: "unitId",
584
- children: (e) => /* @__PURE__ */ Z(e.TextField, {
585
- label: s("parameter_from_template_field_unit_id"),
586
- id: "parameter-from-template-unit-id",
587
- type: "number",
588
- inputMode: "numeric",
589
- min: 0,
590
- max: 255
591
- })
592
- })
593
- ] }),
594
- /* @__PURE__ */ Q(P, { children: [/* @__PURE__ */ Z(N, {
595
- type: "button",
596
- variant: "outline",
597
- onClick: () => {
598
- a();
599
- },
600
- children: s("action_cancel")
601
- }), /* @__PURE__ */ Z(R.Subscribe, {
602
- selector: (e) => Wt(e.values) && !E && !D && !O && !k && !A && !M,
603
- children: (e) => /* @__PURE__ */ Z(R.SubmitButton, {
604
- label: s("parameter_from_template_submit"),
605
- pendingLabel: s("action_saving"),
606
- disabled: !e
607
- })
608
- })] })
609
- ]
610
- }) });
611
- }
612
- //#endregion
613
- //#region src/workspace/parameters/value/cells.tsx
614
- function Kt({ selectedCount: e, live: t, readPending: n, writePending: r, displayMode: a, onRead: o, onLiveChange: s, onDisplayModeChange: c }) {
615
- let l = i();
616
- return /* @__PURE__ */ Q(X, { children: [
617
- /* @__PURE__ */ Z(N, {
618
- type: "button",
619
- size: "xs",
620
- variant: "outline",
621
- disabled: e === 0 || n || r,
622
- onClick: o,
623
- children: l("parameter_read_action")
624
- }),
625
- /* @__PURE__ */ Q("label", {
626
- className: "flex items-center gap-1.5 text-xs text-muted-foreground",
627
- children: [/* @__PURE__ */ Z(_e, {
628
- size: "sm",
629
- checked: t,
630
- disabled: r || e === 0 && !t,
631
- "aria-label": l("parameter_live_label"),
632
- onCheckedChange: s
633
- }), l("parameter_live_label")]
634
- }),
635
- /* @__PURE__ */ Z(De, {
636
- value: a,
637
- className: "ml-2",
638
- onValueChange: (e) => {
639
- typeof e == "string" && (e === "repr" || e === "number" || e === "hex") && c(e);
640
- },
641
- children: /* @__PURE__ */ Q(Ee, {
642
- size: "sm",
643
- children: [
644
- /* @__PURE__ */ Z(Te, {
645
- value: "repr",
646
- children: l("parameter_value_mode_repr")
647
- }),
648
- /* @__PURE__ */ Z(Te, {
649
- value: "number",
650
- children: l("parameter_value_mode_number")
651
- }),
652
- /* @__PURE__ */ Z(Te, {
653
- value: "hex",
654
- children: l("parameter_value_mode_hex")
655
- })
656
- ]
657
- })
658
- })
659
- ] });
660
- }
661
- function qt(e) {
662
- return W(st(e));
663
- }
664
- function Jt(e, t, n) {
665
- if (e === "hex") return pe(t.rawHex);
666
- if (e === "number") {
667
- let e = U(t);
668
- return n.name === "datetime" ? qt(e) : W(e);
669
- }
670
- let r = ae(t.value);
671
- return n.name === "datetime" ? qt(r) : W(r);
672
- }
673
- function Yt(e) {
674
- return he({
675
- code: e.code,
676
- ...e.reason == null ? {} : { reason: e.reason },
677
- ...e.params == null ? {} : { params: e.params }
678
- });
679
- }
680
- function Xt({ paramId: e, currentValue: t, rawHex: n, numberValue: r, boolValue: a, valueType: o, units: s, displayMode: c, onCancel: l, onCommit: u }) {
681
- let d = i(), f = o.name === "datetime", p = o.name === "geo" && c !== "hex", { displayValue: m, choices: h, matchedChoice: g, initialDraft: _ } = B({
682
- valueType: o,
683
- currentValue: t,
684
- rawHex: n,
685
- numberValue: r,
686
- boolValue: a,
687
- displayMode: c
688
- }), v = p ? H(m) : null, [y, x] = Y(_), [S, C] = Y(v == null ? "" : String(v.lat)), [T, E] = Y(v == null ? "" : String(v.lon)), [D, O] = Y(!1), [k, A] = Y(!1), [j, M] = Y(!1), N = qe(!1), P = qe(null), F = qe(null);
689
- q(() => () => {
690
- P.current != null && window.clearTimeout(P.current);
691
- }, []);
692
- function I() {
693
- N.current || (N.current = !0, l());
694
- }
695
- function L(e) {
696
- P.current != null && window.clearTimeout(P.current), P.current = window.setTimeout(() => {
697
- P.current = null, !(p && e instanceof Node && F.current?.contains(e)) && I();
698
- }, 0);
699
- }
700
- function R(e) {
701
- if (N.current) return;
702
- let n = e.trim();
703
- if (t !== void 0 && n === _) {
704
- I();
705
- return;
706
- }
707
- let r = ue({
708
- text: n,
709
- valueType: o
710
- });
711
- if (r === null) {
712
- A(!0);
713
- return;
714
- }
715
- N.current = !0, P.current != null && (window.clearTimeout(P.current), P.current = null), u({ value: r });
716
- }
717
- function z() {
718
- if (N.current) return;
719
- let e = H(`${S.trim()},${T.trim()}`);
720
- if (e == null) {
721
- M(!0);
722
- return;
723
- }
724
- if (fe(e.lat, e.lon, m)) {
725
- I();
726
- return;
727
- }
728
- let t = le(e.lat, e.lon);
729
- N.current = !0, P.current != null && (window.clearTimeout(P.current), P.current = null), u({ value: t });
730
- }
731
- function ee(e) {
732
- if (N.current) return;
733
- let t = ce(e);
734
- if (t === n) {
735
- O(!1), I();
736
- return;
737
- }
738
- if (t.length === 0 || !oe(t)) {
739
- O(!0);
740
- return;
741
- }
742
- O(!1), N.current = !0, P.current != null && (window.clearTimeout(P.current), P.current = null), u({ rawHex: t });
743
- }
744
- let te = c !== "hex" && s != null && s.length > 0 && !(c === "repr" && ge(o) != null);
745
- return /* @__PURE__ */ Q(X, { children: [/* @__PURE__ */ Z("div", {
746
- className: "\n mx-1.5 min-w-4 flex-1 self-end border-b border-dotted border-muted-foreground/20\n ",
747
- "aria-hidden": !0
748
- }), /* @__PURE__ */ Q("div", {
749
- className: "\n flex max-w-[40%] shrink-0 items-baseline justify-end gap-1 font-mono text-xs leading-none\n ",
750
- children: [c === "hex" ? /* @__PURE__ */ Q("div", {
751
- className: "flex min-w-0 flex-col items-end gap-0.5",
752
- children: [/* @__PURE__ */ Q("div", {
753
- className: "flex max-w-full items-baseline gap-1",
754
- children: [/* @__PURE__ */ Z("span", {
755
- className: "shrink-0 text-muted-foreground",
756
- children: "0x"
757
- }), /* @__PURE__ */ Z("input", {
758
- autoFocus: !0,
759
- value: y,
760
- size: Math.max(y.length, 1),
761
- "aria-invalid": D,
762
- onChange: (e) => {
763
- O(!1), x(e.target.value);
764
- },
765
- onBlur: (e) => {
766
- L(e.relatedTarget);
767
- },
768
- onKeyDown: (e) => {
769
- if (e.key === "Escape") {
770
- e.preventDefault(), I();
771
- return;
772
- }
773
- e.key === "Enter" && (e.preventDefault(), ee(y));
774
- },
775
- className: "\n max-w-full min-w-[1ch] border-0 border-b border-solid border-foreground\n bg-transparent p-0 font-mono text-xs leading-none text-foreground outline-none\n ",
776
- "aria-label": e,
777
- title: d("parameter_value_hex_input_hint")
778
- })]
779
- }), D ? /* @__PURE__ */ Z("span", {
780
- className: "max-w-full text-[0.65rem] leading-tight text-destructive",
781
- children: d("parameter_value_hex_input_hint")
782
- }) : null]
783
- }) : h == null ? p ? /* @__PURE__ */ Q("div", {
784
- ref: F,
785
- className: "flex min-w-0 flex-col items-end gap-0.5",
786
- children: [/* @__PURE__ */ Q("div", {
787
- className: "flex max-w-full items-baseline gap-1",
788
- children: [
789
- /* @__PURE__ */ Z("input", {
790
- autoFocus: !0,
791
- value: S,
792
- size: Math.max(S.length, 4),
793
- "aria-invalid": j,
794
- "aria-label": d("parameter_field_geo_latitude"),
795
- onChange: (e) => {
796
- M(!1), C(e.target.value);
797
- },
798
- onBlur: (e) => {
799
- L(e.relatedTarget);
800
- },
801
- onKeyDown: (e) => {
802
- if (e.key === "Escape") {
803
- e.preventDefault(), I();
804
- return;
805
- }
806
- e.key === "Enter" && (e.preventDefault(), z());
807
- },
808
- className: "\n max-w-[12ch] min-w-[4ch] border-0 border-b border-solid border-foreground\n bg-transparent p-0 font-mono text-xs leading-none text-foreground outline-none\n ",
809
- title: d("parameter_value_geo_input_hint")
810
- }),
811
- /* @__PURE__ */ Z("span", {
812
- className: "shrink-0 text-muted-foreground",
813
- children: ","
814
- }),
815
- /* @__PURE__ */ Z("input", {
816
- value: T,
817
- size: Math.max(T.length, 4),
818
- "aria-invalid": j,
819
- "aria-label": d("parameter_field_geo_longitude"),
820
- onChange: (e) => {
821
- M(!1), E(e.target.value);
822
- },
823
- onBlur: (e) => {
824
- L(e.relatedTarget);
825
- },
826
- onKeyDown: (e) => {
827
- if (e.key === "Escape") {
828
- e.preventDefault(), I();
829
- return;
830
- }
831
- e.key === "Enter" && (e.preventDefault(), z());
832
- },
833
- className: "\n max-w-[12ch] min-w-[4ch] border-0 border-b border-solid border-foreground\n bg-transparent p-0 font-mono text-xs leading-none text-foreground outline-none\n ",
834
- title: d("parameter_value_geo_input_hint")
835
- })
836
- ]
837
- }), j ? /* @__PURE__ */ Z("span", {
838
- className: "max-w-full text-[0.65rem] leading-tight text-destructive",
839
- children: d("parameter_value_geo_input_hint")
840
- }) : null]
841
- }) : /* @__PURE__ */ Q("div", {
842
- className: "flex min-w-0 flex-col items-end gap-0.5",
843
- children: [/* @__PURE__ */ Z("input", {
844
- autoFocus: !0,
845
- value: y,
846
- size: Math.max(y.length, 1),
847
- "aria-invalid": k,
848
- onChange: (e) => {
849
- A(!1), x(e.target.value);
850
- },
851
- onBlur: (e) => {
852
- L(e.relatedTarget);
853
- },
854
- onKeyDown: (e) => {
855
- if (e.key === "Escape") {
856
- e.preventDefault(), I();
857
- return;
858
- }
859
- e.key === "Enter" && (e.preventDefault(), R(y));
860
- },
861
- className: "\n max-w-full min-w-[1ch] border-0 border-b border-solid border-foreground\n bg-transparent p-0 font-mono text-xs leading-none text-foreground outline-none\n ",
862
- "aria-label": e,
863
- title: f ? d("parameter_value_datetime_input_hint") : void 0
864
- }), k ? /* @__PURE__ */ Z("span", {
865
- className: "max-w-full text-[0.65rem] leading-tight text-destructive",
866
- children: d("parameter_value_datetime_input_hint")
867
- }) : null]
868
- }) : /* @__PURE__ */ Q(b, {
869
- size: "inline",
870
- className: "max-w-full border-b border-solid border-foreground",
871
- autoFocus: !0,
872
- value: g?.writeValue ?? "",
873
- onChange: (e) => {
874
- let t = e.target.value;
875
- if (t.length === 0) {
876
- I();
877
- return;
878
- }
879
- R(t);
880
- },
881
- onBlur: (e) => {
882
- L(e.relatedTarget);
883
- },
884
- onKeyDown: (e) => {
885
- e.key === "Escape" && (e.preventDefault(), I());
886
- },
887
- "aria-label": e,
888
- children: [g == null ? /* @__PURE__ */ Z(w, { value: "" }) : null, h.map((e) => /* @__PURE__ */ Z(w, {
889
- value: e.writeValue,
890
- children: e.label
891
- }, e.writeValue))]
892
- }), te ? /* @__PURE__ */ Z("span", {
893
- className: "shrink-0 leading-none text-muted-foreground",
894
- children: s
895
- }) : null]
896
- })] });
897
- }
898
- function Zt({ paramId: e, state: t, units: n, writable: r, valueType: a }) {
899
- let o = i(), s = Ke(Ct), c = Dt();
900
- if (t == null) return null;
901
- let u = t.status === "ok" || t.status === "failedReading" && t.reading.status === "ok" || t.status === "error" && t.code === "decode_error", d = V(t), f = s != null && !s.live && r && u && !d ? s : null;
902
- if (f?.editingParamId === e) {
903
- let r = f, i = t.status === "failedReading" ? t.reading : t;
904
- return /* @__PURE__ */ Z(Xt, {
905
- paramId: e,
906
- ...i.status === "ok" ? {
907
- currentValue: i.value,
908
- rawHex: i.rawHex,
909
- ...i.numberValue === void 0 ? {} : { numberValue: i.numberValue },
910
- ...i.boolValue === void 0 ? {} : { boolValue: i.boolValue }
911
- } : {},
912
- valueType: a,
913
- units: n,
914
- displayMode: c,
915
- onCancel: r.cancelEdit,
916
- onCommit: (t) => {
917
- r.commitWrite(e, t);
918
- }
919
- });
920
- }
921
- let p = t.status === "ok" || t.status === "error" || t.status === "lastKnown" || t.status === "failedReading", m = t.status !== "loading" && t.refreshing, h = t.status === "loading" || m || d, g = (t.status === "ok" || t.status === "lastKnown" || t.status === "failedReading") && c !== "hex" && n != null && n.length > 0 && !(c === "repr" && ge(a) != null);
922
- return /* @__PURE__ */ Q(X, { children: [p ? /* @__PURE__ */ Z("div", {
923
- className: "\n mx-1.5 mb-0.5 min-w-4 flex-1 self-end border-b border-dotted border-muted-foreground/20\n ",
924
- "aria-hidden": !0
925
- }) : /* @__PURE__ */ Z("div", {
926
- className: "min-w-0 flex-1",
927
- "aria-hidden": !0
928
- }), /* @__PURE__ */ Q("div", {
929
- className: t.status === "failedReading" ? "\n flex max-w-[70%] shrink-0 items-baseline justify-end gap-1 font-mono text-xs\n leading-none\n " : "\n flex max-w-[40%] shrink-0 items-baseline justify-end gap-1 font-mono text-xs\n leading-none\n ",
930
- children: [h ? /* @__PURE__ */ Z(M, { className: "size-3.5 shrink-0 self-center text-muted-foreground" }) : null, t.status === "loading" ? null : V(t) ? /* @__PURE__ */ Z("span", {
931
- className: "min-w-0 truncate text-muted-foreground",
932
- children: o("action_saving")
933
- }) : t.status === "ok" ? /* @__PURE__ */ Q("span", {
934
- className: "inline-flex min-w-0 flex-wrap items-center justify-end gap-1",
935
- title: t.freshness === "stale" ? l(t.receivedAt) : void 0,
936
- children: [/* @__PURE__ */ Q("span", {
937
- className: "inline-flex min-w-0 items-baseline gap-1",
938
- children: [f == null ? /* @__PURE__ */ Z("span", {
939
- className: t.freshness === "stale" ? "min-w-0 truncate leading-none text-muted-foreground" : "min-w-0 truncate leading-none text-foreground",
940
- children: Jt(c, t, a)
941
- }) : /* @__PURE__ */ Z(N, {
942
- type: "button",
943
- variant: "link",
944
- className: "\n h-auto max-w-full min-w-0 p-0 font-mono text-xs leading-none text-blue-600\n hover:no-underline\n data-[stale=true]:text-muted-foreground\n ",
945
- "data-stale": t.freshness === "stale",
946
- onClick: () => {
947
- f.startEdit(e);
948
- },
949
- children: /* @__PURE__ */ Z("span", {
950
- className: "\n inline-flex max-w-full border-b border-dotted border-blue-600/80 pb-px\n ",
951
- children: /* @__PURE__ */ Z("span", {
952
- className: "truncate leading-none",
953
- children: Jt(c, t, a)
954
- })
955
- })
956
- }), g ? /* @__PURE__ */ Z("span", {
957
- className: "shrink-0 leading-none text-muted-foreground",
958
- children: n
959
- }) : null]
960
- }), t.freshness === "stale" ? /* @__PURE__ */ Z("span", {
961
- className: "sr-only",
962
- children: l(t.receivedAt)
963
- }) : null]
964
- }) : t.status === "lastKnown" ? /* @__PURE__ */ Q(X, { children: [/* @__PURE__ */ Z("span", {
965
- className: "min-w-0 truncate leading-none text-muted-foreground",
966
- children: Jt(c, t, a)
967
- }), g ? /* @__PURE__ */ Z("span", {
968
- className: "shrink-0 leading-none text-muted-foreground",
969
- children: n
970
- }) : null] }) : t.status === "failedReading" ? /* @__PURE__ */ Q(X, { children: [
971
- t.reading.status === "ok" && f != null ? /* @__PURE__ */ Z(N, {
972
- type: "button",
973
- variant: "link",
974
- className: "\n h-auto max-w-full min-w-0 p-0 font-mono text-xs leading-none text-blue-600\n hover:no-underline\n data-[stale=true]:text-muted-foreground\n ",
975
- "data-stale": "true",
976
- onClick: () => {
977
- f.startEdit(e);
978
- },
979
- children: /* @__PURE__ */ Z("span", {
980
- className: "truncate leading-none",
981
- children: Jt(c, t.reading, a)
982
- })
983
- }) : /* @__PURE__ */ Z("span", {
984
- className: "min-w-0 truncate leading-none text-muted-foreground",
985
- children: Jt(c, t.reading, a)
986
- }),
987
- g ? /* @__PURE__ */ Z("span", {
988
- className: "shrink-0 leading-none text-muted-foreground",
989
- children: n
990
- }) : null,
991
- /* @__PURE__ */ Z("span", {
992
- className: "shrink-0 text-destructive",
993
- children: Yt(t.failure)
994
- })
995
- ] }) : /* @__PURE__ */ Q(X, { children: [/* @__PURE__ */ Z("span", {
996
- className: "min-w-0 truncate text-destructive",
997
- title: Yt(t),
998
- children: Yt(t)
999
- }), f == null ? null : /* @__PURE__ */ Z(N, {
1000
- type: "button",
1001
- variant: "link",
1002
- size: "xs",
1003
- onClick: () => {
1004
- f.startEdit(e);
1005
- },
1006
- children: o("parameter_value_write_action")
1007
- })] })]
1008
- })] });
1009
- }
1010
- function Qt(e) {
1011
- let t = Ke(xt);
1012
- return Je((n) => t == null ? () => void 0 : t.subscribe(e, n), () => t?.get(e), () => t?.get(e));
1013
- }
1014
- function $t({ paramId: e, units: t, writable: n, valueType: r }) {
1015
- return /* @__PURE__ */ Z(Zt, {
1016
- paramId: e,
1017
- state: Qt(e),
1018
- units: t,
1019
- writable: n,
1020
- valueType: r
1021
- });
1022
- }
1023
- //#endregion
1024
- //#region src/workspace/setup/parameters/toolbar.tsx
1025
- function en({ workspaceId: e, filter: t, onFilterChange: n, filterActive: r, hasBranches: o, treeReady: s, selectionStore: c, knownParamIds: l, paramIdsInTreeOrder: u, onAddRootBranch: d, onAddFromTemplate: f, onDeleteSelection: p, onDeleteReadings: m, onExpandAll: h, onCollapseAll: g, showDetails: _, onShowDetailsChange: v, live: y, readPending: b, writePending: x, displayMode: S, runRead: C, onLiveChange: w, onDisplayModeChange: T }) {
1026
- let E = i(), O = a(), k = gt(), A = lt(te().access), j = ie({
1027
- workspaceId: e,
1028
- navigateToReport: (t) => {
1029
- k({
1030
- to: "/workspace/$workspaceId/reports/$presetId",
1031
- params: {
1032
- workspaceId: e,
1033
- presetId: t
1034
- }
1035
- });
1036
- },
1037
- onSkipped: () => {
1038
- O.warning(E("report_quick_skipped"));
1039
- },
1040
- onError: (e) => {
1041
- let t = re(e);
1042
- O.error(t);
1043
- }
1044
- }), M = Ht(c), P = M.selectedParamIds.size + M.selectedBranchIds.size, F = s ? Be(new Set([...M.selectedParamIds].filter((e) => l.has(e))), u) : [], I = me({
1045
- parameterIds: F,
1046
- pending: j.isPending
1047
- });
1048
- return /* @__PURE__ */ Q("div", {
1049
- className: "\n sticky top-0 z-10 flex flex-col gap-1.5 border-b bg-background/95 px-4 py-2\n backdrop-blur-sm\n supports-backdrop-filter:bg-background/80\n ",
1050
- children: [/* @__PURE__ */ Q("div", {
1051
- className: "flex flex-wrap items-center gap-2",
1052
- children: [
1053
- /* @__PURE__ */ Z(D, {
1054
- value: t,
1055
- onChange: (e) => {
1056
- n(e.target.value);
1057
- },
1058
- placeholder: E("parameter_filter_placeholder"),
1059
- className: "\n h-8 min-w-0 flex-1 basis-40\n sm:max-w-xs sm:flex-none\n "
1060
- }),
1061
- /* @__PURE__ */ Q(Ce, { children: [/* @__PURE__ */ Q(xe, {
1062
- render: /* @__PURE__ */ Z(N, {
1063
- type: "button",
1064
- size: "sm",
1065
- variant: "outline"
1066
- }),
1067
- children: [
1068
- /* @__PURE__ */ Z(at, { "data-icon": "inline-start" }),
1069
- E("parameter_add_menu"),
1070
- /* @__PURE__ */ Z(Xe, {
1071
- "data-icon": "inline-end",
1072
- className: "opacity-70"
1073
- })
1074
- ]
1075
- }), /* @__PURE__ */ Q(Se, {
1076
- align: "start",
1077
- className: "w-auto min-w-40",
1078
- children: [
1079
- /* @__PURE__ */ Z(G, {
1080
- onClick: d,
1081
- children: E("parameter_add_root_branch")
1082
- }),
1083
- /* @__PURE__ */ Z(G, {
1084
- disabled: !o,
1085
- onClick: () => {
1086
- k({
1087
- to: "/workspace/$workspaceId/setup/parameters/new",
1088
- params: { workspaceId: e }
1089
- });
1090
- },
1091
- children: E("parameter_add_action")
1092
- }),
1093
- /* @__PURE__ */ Z(G, {
1094
- onClick: f,
1095
- children: E("parameter_add_from_template")
1096
- })
1097
- ]
1098
- })] }),
1099
- /* @__PURE__ */ Q(N, {
1100
- type: "button",
1101
- size: "sm",
1102
- variant: "destructive",
1103
- disabled: !s || P === 0,
1104
- onClick: p,
1105
- children: [/* @__PURE__ */ Z(ot, { "data-icon": "inline-start" }), E("parameter_delete_action")]
1106
- }),
1107
- A ? /* @__PURE__ */ Q(N, {
1108
- type: "button",
1109
- size: "sm",
1110
- variant: "outline",
1111
- disabled: !s || P === 0,
1112
- onClick: m,
1113
- children: [/* @__PURE__ */ Z(tt, { "data-icon": "inline-start" }), E("storage_delete_readings_selection")]
1114
- }) : null,
1115
- /* @__PURE__ */ Q(N, {
1116
- type: "button",
1117
- size: "sm",
1118
- variant: "outline",
1119
- disabled: !s || I.kind !== "ready",
1120
- onClick: () => {
1121
- I.kind === "ready" && j.create({
1122
- parameterIds: I.parameterIds,
1123
- title: E("parameter_quick_report")
1124
- });
1125
- },
1126
- children: [/* @__PURE__ */ Z(Ye, { "data-icon": "inline-start" }), E("parameter_quick_report")]
1127
- }),
1128
- I.kind === "over_limit" ? /* @__PURE__ */ Z("p", {
1129
- className: "text-xs text-muted-foreground",
1130
- children: E("parameter_quick_report_limit", { limit: String(I.limit) })
1131
- }) : null
1132
- ]
1133
- }), /* @__PURE__ */ Q("div", {
1134
- className: "flex flex-wrap items-center gap-1.5",
1135
- children: [
1136
- /* @__PURE__ */ Q(N, {
1137
- type: "button",
1138
- size: "xs",
1139
- variant: "ghost",
1140
- disabled: !o || r,
1141
- onClick: h,
1142
- children: [/* @__PURE__ */ Z($e, { "data-icon": "inline-start" }), E("parameter_expand_all")]
1143
- }),
1144
- /* @__PURE__ */ Q(N, {
1145
- type: "button",
1146
- size: "xs",
1147
- variant: "ghost",
1148
- disabled: !o || r,
1149
- onClick: g,
1150
- children: [/* @__PURE__ */ Z(Qe, { "data-icon": "inline-start" }), E("parameter_collapse_all")]
1151
- }),
1152
- /* @__PURE__ */ Q("label", {
1153
- className: "ml-3 flex items-center gap-1.5 text-xs text-muted-foreground",
1154
- children: [/* @__PURE__ */ Z(_e, {
1155
- size: "sm",
1156
- checked: _,
1157
- disabled: !o,
1158
- "aria-label": E("parameter_details_label"),
1159
- onCheckedChange: v
1160
- }), E("parameter_details_label")]
1161
- }),
1162
- /* @__PURE__ */ Z("div", {
1163
- className: "ml-auto flex flex-wrap items-center gap-1.5",
1164
- children: /* @__PURE__ */ Z(Kt, {
1165
- selectedCount: F.length,
1166
- live: y,
1167
- readPending: b,
1168
- writePending: x,
1169
- displayMode: S,
1170
- onRead: () => {
1171
- C(F);
1172
- },
1173
- onLiveChange: (e) => {
1174
- s && w(e);
1175
- },
1176
- onDisplayModeChange: T
1177
- })
1178
- })
1179
- ]
1180
- })]
1181
- });
1182
- }
1183
- //#endregion
1184
- //#region src/workspace/setup/parameters/tree/rows.tsx
1185
- var tn = Ge(function({ id: e, name: t, depth: n, paramCount: r, hasChildren: a, open: o, menuOpen: s, onToggleExpand: c, onBranchCheck: l, onMenuOpenChange: u, onAddChildBranch: d, onAddParam: f, onRename: p }) {
1186
- let m = i(), h = m(o ? "parameter_collapse" : "parameter_expand"), g = (t) => {
1187
- c(e, { shiftKey: t });
1188
- };
1189
- return /* @__PURE__ */ Q("div", {
1190
- "data-context-branch-id": e,
1191
- className: `
1192
- group/branch-row flex min-h-7 w-full items-center gap-1 pr-2
1193
- ${Fe(n)}
1194
- `,
1195
- children: [
1196
- /* @__PURE__ */ Z("button", {
1197
- type: "button",
1198
- className: "-ml-1.5 flex size-7 shrink-0 items-center justify-center text-muted-foreground",
1199
- "aria-label": h,
1200
- disabled: !a,
1201
- onClick: (e) => {
1202
- g(e.shiftKey);
1203
- },
1204
- children: Z(a ? o ? Xe : Ze : "span", { className: "size-3.5" })
1205
- }),
1206
- /* @__PURE__ */ Z(Vt, {
1207
- branchId: e,
1208
- label: m("parameter_select_named", { name: t }),
1209
- onBranchCheck: l
1210
- }),
1211
- /* @__PURE__ */ Q("span", {
1212
- className: "flex min-w-0 items-baseline gap-1",
1213
- children: [a ? /* @__PURE__ */ Z("button", {
1214
- type: "button",
1215
- className: "min-w-0 cursor-pointer truncate text-left font-medium",
1216
- "aria-label": h,
1217
- onClick: (e) => {
1218
- g(e.shiftKey);
1219
- },
1220
- children: t
1221
- }) : /* @__PURE__ */ Z("span", {
1222
- className: "min-w-0 truncate font-medium",
1223
- children: t
1224
- }), /* @__PURE__ */ Z("span", {
1225
- className: "shrink-0 text-xs text-muted-foreground/50",
1226
- children: r
1227
- })]
1228
- }),
1229
- /* @__PURE__ */ Q(Ce, {
1230
- open: s,
1231
- onOpenChange: (t) => {
1232
- u(e, t);
1233
- },
1234
- children: [/* @__PURE__ */ Z(xe, {
1235
- render: /* @__PURE__ */ Z(N, {
1236
- type: "button",
1237
- variant: "ghost",
1238
- size: "icon-xs",
1239
- "aria-label": m("parameter_actions_named", { name: t }),
1240
- className: "\n ml-auto size-5 opacity-0\n group-focus-within/branch-row:opacity-100\n group-hover/branch-row:opacity-100\n data-popup-open:opacity-100\n "
1241
- }),
1242
- children: /* @__PURE__ */ Z(it, { className: "size-3.5" })
1243
- }), s ? /* @__PURE__ */ Q(Se, {
1244
- align: "end",
1245
- children: [
1246
- /* @__PURE__ */ Z(G, {
1247
- onClick: () => {
1248
- d(e);
1249
- },
1250
- children: m("parameter_add_child_branch")
1251
- }),
1252
- /* @__PURE__ */ Z(G, {
1253
- onClick: () => {
1254
- f(e);
1255
- },
1256
- children: m("parameter_add_action")
1257
- }),
1258
- /* @__PURE__ */ Z(G, {
1259
- onClick: () => {
1260
- p(e, t);
1261
- },
1262
- children: m("parameter_rename_branch")
1263
- })
1264
- ]
1265
- }) : null]
1266
- })
1267
- ]
1268
- });
1269
- });
1270
- function nn({ deviceLog: e }) {
1271
- let t = i();
1272
- return /* @__PURE__ */ Q(O, { children: [/* @__PURE__ */ Z(A, {
1273
- openOnHover: !0,
1274
- delay: 150,
1275
- className: "\n inline-flex shrink-0 items-center self-center rounded-sm text-muted-foreground\n focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none\n ",
1276
- "aria-label": t("parameter_device_log_chip_aria"),
1277
- children: /* @__PURE__ */ Z(nt, {
1278
- className: "size-3",
1279
- "aria-hidden": !0,
1280
- strokeWidth: 2.25
1281
- })
1282
- }), /* @__PURE__ */ Q(k, {
1283
- side: "top",
1284
- className: "w-auto max-w-xs gap-1 p-2.5 text-xs",
1285
- children: [
1286
- /* @__PURE__ */ Z("p", {
1287
- className: "font-medium text-foreground",
1288
- children: t("parameter_device_log_title")
1289
- }),
1290
- /* @__PURE__ */ Q("p", {
1291
- className: "text-muted-foreground",
1292
- children: [
1293
- t("parameter_device_log_pull", { minutes: e.pullMinutes }),
1294
- " · ",
1295
- e.lastImportAt == null ? t("parameter_device_log_no_import") : t("parameter_device_log_last_import", { when: st(e.lastImportAt) })
1296
- ]
1297
- }),
1298
- e.completeThrough == null ? null : /* @__PURE__ */ Z("p", {
1299
- className: "text-muted-foreground",
1300
- children: t("parameter_device_log_complete_through", { when: st(e.completeThrough) })
1301
- })
1302
- ]
1303
- })] });
1304
- }
1305
- var rn = Ge(function({ id: e, branchId: t, depth: n, icon: r, units: a, disabled: o, backgroundReadingPeriodMs: s, deviceLog: c, lastReadingReceivedAt: l, nextReadingDueAt: u, parts: d, details: p, showDetails: m, workspaceId: h, writable: g, valueType: y, onParamCheck: b }) {
1306
- let x = i(), S = Qt(e), C = S?.status === "ok" || S?.status === "lastKnown" || S?.status === "failedReading", w = d.units != null && !C ? d.units : null, T = f(o, s), E = /* @__PURE__ */ Q(X, { children: [
1307
- /* @__PURE__ */ Z("span", {
1308
- className: "-ml-1.5 size-7 shrink-0",
1309
- "aria-hidden": !0
1310
- }),
1311
- /* @__PURE__ */ Z("span", {
1312
- className: "size-4 shrink-0",
1313
- "aria-hidden": !0
1314
- }),
1315
- /* @__PURE__ */ Z("span", {
1316
- className: "size-3.5 shrink-0",
1317
- "aria-hidden": !0
1318
- })
1319
- ] });
1320
- return /* @__PURE__ */ Q("div", {
1321
- "data-context-parameter-id": e,
1322
- "data-context-branch-id": t,
1323
- className: `
1324
- flex w-full flex-col
1325
- ${Fe(n)}
1326
- ${o ? "opacity-70" : ""}
1327
- `,
1328
- children: [/* @__PURE__ */ Q("div", {
1329
- className: "flex min-h-7 w-full items-center gap-1 pr-2",
1330
- children: [
1331
- /* @__PURE__ */ Z("span", {
1332
- className: "-ml-1.5 size-7 shrink-0",
1333
- "aria-hidden": !0
1334
- }),
1335
- /* @__PURE__ */ Z(Bt, {
1336
- paramId: e,
1337
- branchId: t,
1338
- label: x("parameter_select_named", { name: d.name }),
1339
- onParamCheck: b
1340
- }),
1341
- /* @__PURE__ */ Z(be, {
1342
- icon: r,
1343
- className: "size-3.5 shrink-0 text-muted-foreground",
1344
- strokeWidth: 1.75
1345
- }),
1346
- /* @__PURE__ */ Q("div", {
1347
- className: "flex min-w-0 flex-1 items-center",
1348
- children: [/* @__PURE__ */ Q("div", {
1349
- className: "flex items-baseline gap-1",
1350
- children: [
1351
- /* @__PURE__ */ Z("div", {
1352
- className: "min-w-0 truncate",
1353
- children: /* @__PURE__ */ Q(ht, {
1354
- to: "/workspace/$workspaceId/setup/parameters/$parameterId",
1355
- params: {
1356
- workspaceId: h,
1357
- parameterId: e
1358
- },
1359
- className: "\n font-medium text-primary\n hover:underline\n ",
1360
- children: [
1361
- d.mnemonic == null ? null : /* @__PURE__ */ Q(X, { children: [/* @__PURE__ */ Z("span", {
1362
- className: "font-mono",
1363
- children: d.mnemonic
1364
- }), " · "] }),
1365
- d.name,
1366
- w == null ? null : `, ${w}`
1367
- ]
1368
- })
1369
- }),
1370
- T == null ? null : /* @__PURE__ */ Q("span", {
1371
- className: "shrink-0 text-xs text-muted-foreground",
1372
- role: "img",
1373
- "aria-label": v(T),
1374
- children: [/* @__PURE__ */ Z(et, {
1375
- className: "mr-0.5 inline-block size-3 align-[-0.125em]",
1376
- "aria-hidden": !0,
1377
- strokeWidth: 2.25
1378
- }), _(T)]
1379
- }),
1380
- c == null ? null : /* @__PURE__ */ Z(nn, { deviceLog: c }),
1381
- o ? /* @__PURE__ */ Z("span", {
1382
- className: "\n inline-block shrink-0 rounded-sm border border-border px-1 py-px align-middle\n text-[10px] leading-none font-medium tracking-wide text-muted-foreground\n uppercase\n ",
1383
- children: x("parameter_off_marker")
1384
- }) : null
1385
- ]
1386
- }), /* @__PURE__ */ Z($t, {
1387
- paramId: e,
1388
- units: a,
1389
- writable: g,
1390
- valueType: y
1391
- })]
1392
- })
1393
- ]
1394
- }), m && p != null ? /* @__PURE__ */ Q("div", {
1395
- className: "flex gap-1 pr-2 pb-1",
1396
- children: [E, /* @__PURE__ */ Q("div", {
1397
- className: "mt-0.5 flex min-w-0 flex-1 flex-col gap-1.5",
1398
- children: [p.description == null ? null : /* @__PURE__ */ Z("p", {
1399
- className: "text-xs/snug wrap-break-word whitespace-pre-wrap text-foreground/75",
1400
- children: p.description
1401
- }), /* @__PURE__ */ Q("p", {
1402
- className: "font-mono text-[11px] leading-snug wrap-break-word text-muted-foreground",
1403
- children: [
1404
- p.metaLine,
1405
- l == null ? null : /* @__PURE__ */ Q(X, { children: [" · ", x("parameter_details_last_reading", { when: st(l) })] }),
1406
- u == null ? null : /* @__PURE__ */ Q(X, { children: [" · ", x("parameter_details_next_reading", { when: st(u) })] }),
1407
- p.tags.map((e) => /* @__PURE__ */ Q("span", { children: [" · ", /* @__PURE__ */ Z("span", {
1408
- className: "\n inline-flex max-w-full items-center rounded-sm bg-amber-500/10 px-1.5 py-px\n font-sans text-amber-950/80\n dark:bg-amber-400/10 dark:text-amber-100/80\n ",
1409
- children: /* @__PURE__ */ Z("span", {
1410
- className: "truncate",
1411
- children: e
1412
- })
1413
- })] }, e))
1414
- ]
1415
- })]
1416
- })]
1417
- }) : null]
1418
- });
1419
- }), an = "overvis.setup.parameterTreeExpanded.", on = "overvis.setup.parameterTreeSelection.", sn = "overvis.setup.parameterValueDisplayMode", cn = "overvis.setup.parameterTreeDetails.";
1420
- function ln(e) {
1421
- return Array.isArray(e) && e.every((e) => typeof e == "string");
1422
- }
1423
- function un(e, t, n) {
1424
- try {
1425
- let r = e().getItem(t);
1426
- return r == null ? null : n(r);
1427
- } catch {
1428
- return null;
1429
- }
1430
- }
1431
- function dn(e, t, n) {
1432
- try {
1433
- e().setItem(t, n);
1434
- } catch {}
1435
- }
1436
- var fn = () => localStorage, pn = () => sessionStorage;
1437
- function mn(e) {
1438
- return un(fn, `${an}${e}`, (e) => {
1439
- let t = JSON.parse(e);
1440
- return ln(t) ? new Set(t) : null;
1441
- });
1442
- }
1443
- function hn(e, t) {
1444
- dn(fn, `${an}${e}`, JSON.stringify([...t]));
1445
- }
1446
- function gn(e) {
1447
- return un(fn, `${on}${e}`, (e) => {
1448
- let t = JSON.parse(e);
1449
- return typeof t != "object" || !t || !("paramIds" in t) || !("branchIds" in t) || !ln(t.paramIds) || !ln(t.branchIds) ? null : {
1450
- paramIds: t.paramIds,
1451
- branchIds: t.branchIds
1452
- };
1453
- });
1454
- }
1455
- function _n(e, t, n) {
1456
- dn(fn, `${on}${e}`, JSON.stringify({
1457
- paramIds: [...t],
1458
- branchIds: [...n]
1459
- }));
1460
- }
1461
- function vn(e, t) {
1462
- return new Set([...e].filter((e) => t.has(e)));
1463
- }
1464
- function yn() {
1465
- return un(pn, sn, (e) => e === "repr" || e === "number" || e === "hex" ? e : null) ?? "repr";
1466
- }
1467
- function bn(e) {
1468
- dn(pn, sn, e);
1469
- }
1470
- function xn(e) {
1471
- return un(pn, `${cn}${e}`, (e) => e === "1") ?? !1;
1472
- }
1473
- function Sn(e, t) {
1474
- dn(pn, `${cn}${e}`, t ? "1" : "0");
1475
- }
1476
- //#endregion
1477
- //#region src/workspace/setup/parameters/use-tree-selection.ts
1478
- function Cn(e) {
1479
- let t = gn(e);
1480
- return It(t == null ? void 0 : {
1481
- selectedParamIds: new Set(t.paramIds),
1482
- selectedBranchIds: new Set(t.branchIds)
1483
- });
1484
- }
1485
- function wn(e, t, n) {
1486
- let r = t;
1487
- for (; r != null;) e.delete(r), r = n.get(r) ?? null;
1488
- }
1489
- function Tn({ workspaceId: e, selectionStore: t, indexes: n, treeReady: r, knownParamIds: i, knownBranchIds: a, clearParamSelectionSideEffects: o }) {
1490
- let { branchesByParent: s, paramsByBranch: c, parentById: l, subtreeByBranchId: u } = n, d = K((n, r) => {
1491
- t.commit({
1492
- selectedParamIds: n,
1493
- selectedBranchIds: r,
1494
- checkStateByBranchId: ze(s, c, r, n)
1495
- }) && _n(e, n, r);
1496
- }, [
1497
- t,
1498
- e,
1499
- s,
1500
- c
1501
- ]);
1502
- return q(() => {
1503
- if (!r) return;
1504
- let e = t.getSnapshot();
1505
- d(vn(e.selectedParamIds, i), vn(e.selectedBranchIds, a));
1506
- }, [
1507
- r,
1508
- i,
1509
- a,
1510
- t,
1511
- d
1512
- ]), {
1513
- onBranchCheck: K((e, n) => {
1514
- let r = u.get(e);
1515
- if (r == null) return;
1516
- let i = t.getSnapshot(), a = new Set(i.selectedBranchIds), s = new Set(i.selectedParamIds);
1517
- if (n) {
1518
- for (let e of r.branchIds) a.add(e);
1519
- for (let e of r.paramIds) s.add(e);
1520
- } else {
1521
- for (let e of r.branchIds) a.delete(e);
1522
- for (let e of r.paramIds) s.delete(e);
1523
- wn(a, e, l);
1524
- }
1525
- d(s, a), o(s.size);
1526
- }, [
1527
- u,
1528
- l,
1529
- t,
1530
- d,
1531
- o
1532
- ]),
1533
- onParamCheck: K((e, n, r) => {
1534
- let i = t.getSnapshot(), a = new Set(i.selectedParamIds), s = new Set(i.selectedBranchIds);
1535
- r ? a.add(e) : (a.delete(e), wn(s, n, l)), d(a, s), o(a.size);
1536
- }, [
1537
- l,
1538
- t,
1539
- d,
1540
- o
1541
- ]),
1542
- clearSelection: () => {
1543
- d(/* @__PURE__ */ new Set(), /* @__PURE__ */ new Set()), o(0);
1544
- }
1545
- };
1546
- }
1547
- //#endregion
1548
- //#region src/workspace/setup/parameters/use-tree-view.ts
1549
- var En = 200;
1550
- function Dn({ workspaceId: e, branches: t, parameters: n, indexes: i, treeReady: a, knownBranchIds: o }) {
1551
- let s = r(), { branchesByParent: c, paramsByBranch: l, parentById: u, subtreeByBranchId: d, paramCountByBranchId: f } = i, [p, m] = Y(""), [h, g] = Y("");
1552
- q(() => {
1553
- let e = window.setTimeout(() => {
1554
- g(p);
1555
- }, En);
1556
- return () => {
1557
- window.clearTimeout(e);
1558
- };
1559
- }, [p]);
1560
- let [_, v] = Y(() => mn(e)), y = J(() => (c.get(null) ?? []).map((e) => e.id), [c]);
1561
- if (a && _ != null) {
1562
- let t = vn(_, o);
1563
- Nt(t, _) || (v(t), hn(e, t));
1564
- }
1565
- let b = J(() => {
1566
- let e = _ ?? new Set(y);
1567
- return a ? vn(e, o) : e;
1568
- }, [
1569
- _,
1570
- y,
1571
- a,
1572
- o
1573
- ]), x = h.trim(), S = x.length > 0, C = J(() => S ? new Set(n.filter((e) => Le(e, x)).map((e) => e.id)) : null, [
1574
- S,
1575
- x,
1576
- n
1577
- ]), w = J(() => {
1578
- if (C == null) return null;
1579
- let e = /* @__PURE__ */ new Set();
1580
- for (let t of n) {
1581
- if (!C.has(t.id)) continue;
1582
- let n = t.branchId;
1583
- for (; n != null;) e.add(n), n = u.get(n) ?? null;
1584
- }
1585
- return e;
1586
- }, [
1587
- C,
1588
- n,
1589
- u
1590
- ]), T = J(() => Ve(n, s), [n, s]);
1591
- return {
1592
- filter: p,
1593
- setFilter: m,
1594
- filterActive: S,
1595
- rows: J(() => Ie({
1596
- locale: s,
1597
- branchesByParent: c,
1598
- paramsByBranch: l,
1599
- paramCountByBranchId: f,
1600
- partsByParamId: T,
1601
- effectiveExpanded: b,
1602
- filterActive: S,
1603
- matchingParamIds: C,
1604
- ancestorsOfMatches: w
1605
- }), [
1606
- s,
1607
- c,
1608
- l,
1609
- f,
1610
- T,
1611
- b,
1612
- S,
1613
- C,
1614
- w
1615
- ]),
1616
- effectiveExpanded: b,
1617
- onToggleExpand: K((t, { shiftKey: n }) => {
1618
- v((r) => {
1619
- let i = r ?? new Set(y), a = Mt({
1620
- expanded: i,
1621
- branchId: t,
1622
- shiftKey: n,
1623
- visuallyOpen: S || i.has(t),
1624
- subtreeBranchIds: d.get(t)?.branchIds
1625
- }), s = o.size > 0 ? vn(a, o) : a;
1626
- return hn(e, s), s;
1627
- });
1628
- }, [
1629
- y,
1630
- d,
1631
- o,
1632
- e,
1633
- S
1634
- ]),
1635
- expandAll: () => {
1636
- let n = new Set(t.map((e) => e.id));
1637
- hn(e, n), v(n);
1638
- },
1639
- collapseAll: () => {
1640
- let t = /* @__PURE__ */ new Set();
1641
- hn(e, t), v(t);
1642
- }
1643
- };
1644
- }
1645
- //#endregion
1646
- //#region src/workspace/setup/parameters/page.tsx
1647
- var On = /* @__PURE__ */ e({ SetupParametersPage: () => kn });
1648
- function kn({ workspaceId: e }) {
1649
- return /* @__PURE__ */ Z(s, {
1650
- access: te().access,
1651
- children: /* @__PURE__ */ Z(An, { workspaceId: e })
1652
- });
1653
- }
1654
- function An({ workspaceId: e }) {
1655
- let n = i(), o = a(), s = r(), l = gt(), u = t.parameter.listTree.useQuery({ workspaceId: e }), d = J(() => u.data?.branches ?? [], [u.data?.branches]), f = J(() => u.data?.parameters ?? [], [u.data?.parameters]), [p] = Y(() => Cn(e)), [m, h] = Y(null), [g, _] = Y(() => yn()), [v, y] = Y(() => xn(e)), [b, x] = Y(!1), S = t.endpoint.list.useQuery({ workspaceId: e }, { enabled: v || b }), C = K((t) => {
1656
- y(t), Sn(e, t);
1657
- }, [e]), w = J(() => Me(d, f), [d, f]), T = J(() => He(w), [w]), { live: E, setLiveEnabled: D, clearParamSelectionSideEffects: O, paramValueStore: k, readPending: A, anySaving: j, runRead: M, editingParamId: P, startEdit: F, cancelEdit: I, commitWrite: L } = Ot(p, T);
1658
- q(() => {
1659
- u.data != null && k.update((e) => se(e, u.data.parameters));
1660
- }, [k, u.data]);
1661
- let te = K((e) => {
1662
- e !== g && (I(), _(e), bn(e));
1663
- }, [I, g]), re = J(() => ({
1664
- editingParamId: P,
1665
- startEdit: F,
1666
- cancelEdit: I,
1667
- commitWrite: L,
1668
- live: E,
1669
- displayMode: g
1670
- }), [
1671
- P,
1672
- F,
1673
- I,
1674
- L,
1675
- E,
1676
- g
1677
- ]), [ie, B] = Y(null), [ae, V] = Y(!1), [oe, H] = Y(null), U = J(() => new Set(f.map((e) => e.id)), [f]), ce = J(() => new Set(d.map((e) => e.id)), [d]), le = u.isSuccess, { onBranchCheck: ue, onParamCheck: de, clearSelection: fe } = Tn({
1678
- workspaceId: e,
1679
- selectionStore: p,
1680
- indexes: w,
1681
- treeReady: le,
1682
- knownParamIds: U,
1683
- knownBranchIds: ce,
1684
- clearParamSelectionSideEffects: O
1685
- }), { filter: pe, setFilter: me, filterActive: W, rows: he, effectiveExpanded: ge, onToggleExpand: _e, expandAll: ve, collapseAll: ye } = Dn({
1686
- workspaceId: e,
1687
- branches: d,
1688
- parameters: f,
1689
- indexes: w,
1690
- treeReady: le,
1691
- knownBranchIds: ce
1692
- }), be = J(() => {
1693
- let e = /* @__PURE__ */ new Map(), t = s;
1694
- for (let n of S.data?.endpoints ?? []) e.set(n.id, $(n.name, t));
1695
- return e;
1696
- }, [s, S.data?.endpoints]), G = J(() => {
1697
- if (!v) return null;
1698
- let e = /* @__PURE__ */ new Map();
1699
- for (let t of f) e.set(t.id, c(t, be));
1700
- return e;
1701
- }, [
1702
- v,
1703
- f,
1704
- be
1705
- ]);
1706
- m != null && !he.some((e) => e.kind === "branch" && e.id === m) && h(null);
1707
- let xe = K((e, t) => {
1708
- h(t ? e : null);
1709
- }, []), Se = K((e) => {
1710
- h(null), B({
1711
- mode: "create-child",
1712
- parentId: e
1713
- });
1714
- }, []), Ce = K((t) => {
1715
- h(null), l({
1716
- to: "/workspace/$workspaceId/setup/parameters/new",
1717
- params: { workspaceId: e },
1718
- search: { branchId: t }
1719
- });
1720
- }, [l, e]), Te = K((e, t) => {
1721
- h(null), B({
1722
- mode: "rename",
1723
- branchId: e,
1724
- name: t,
1725
- revision: d.find((t) => t.id === e)?.revision
1726
- });
1727
- }, [d]), Ee = J(() => ({
1728
- params: new Map(f.map((e) => [e.id, e.revision])),
1729
- branches: new Map(d.map((e) => [e.id, e.revision]))
1730
- }), [d, f]);
1731
- return ne("parameters", K(() => vt({
1732
- selection: p.getSnapshot(),
1733
- parameters: f,
1734
- branches: d,
1735
- locale: s
1736
- }), [
1737
- s,
1738
- d,
1739
- f,
1740
- p
1741
- ])), /* @__PURE__ */ Q("div", {
1742
- className: "flex w-full flex-col",
1743
- children: [
1744
- /* @__PURE__ */ Z(we, {
1745
- icon: /* @__PURE__ */ Z(rt, {}),
1746
- breadcrumbs: /* @__PURE__ */ Z(Oe, { workspaceId: e }),
1747
- title: n("setup_parameters_title"),
1748
- description: n("setup_parameters_description")
1749
- }),
1750
- /* @__PURE__ */ Z(en, {
1751
- workspaceId: e,
1752
- filter: pe,
1753
- onFilterChange: me,
1754
- filterActive: W,
1755
- hasBranches: d.length > 0,
1756
- treeReady: le,
1757
- selectionStore: p,
1758
- knownParamIds: U,
1759
- paramIdsInTreeOrder: T,
1760
- onAddRootBranch: () => {
1761
- B({ mode: "create-root" });
1762
- },
1763
- onAddFromTemplate: () => {
1764
- x(!0);
1765
- },
1766
- onDeleteSelection: () => {
1767
- V(!0);
1768
- },
1769
- onDeleteReadings: () => {
1770
- let e = p.getSnapshot(), t = new Set([...e.selectedParamIds].filter((e) => U.has(e)));
1771
- for (let n of e.selectedBranchIds) for (let e of w.subtreeByBranchId.get(n)?.paramIds ?? []) t.add(e);
1772
- if (t.size === 0) {
1773
- o.info(n("storage_delete_preview_nothing"));
1774
- return;
1775
- }
1776
- if (t.size > ct) {
1777
- o.info(n("storage_delete_selection_too_large", { max: String(ct) }));
1778
- return;
1779
- }
1780
- H([...t]);
1781
- },
1782
- onExpandAll: ve,
1783
- onCollapseAll: ye,
1784
- showDetails: v,
1785
- onShowDetailsChange: C,
1786
- live: E,
1787
- readPending: A,
1788
- writePending: j,
1789
- displayMode: g,
1790
- runRead: M,
1791
- onLiveChange: D,
1792
- onDisplayModeChange: te
1793
- }),
1794
- u.isLoading ? /* @__PURE__ */ Q("div", {
1795
- className: "space-y-1 p-4",
1796
- children: [
1797
- /* @__PURE__ */ Z(ee, { className: "h-5 w-2/3" }),
1798
- /* @__PURE__ */ Z(ee, { className: "h-5 w-1/2" }),
1799
- /* @__PURE__ */ Z(ee, { className: "h-5 w-3/5" })
1800
- ]
1801
- }) : d.length === 0 ? /* @__PURE__ */ Q("div", {
1802
- className: "space-y-2 p-4",
1803
- children: [/* @__PURE__ */ Z("p", {
1804
- className: "text-sm text-muted-foreground",
1805
- children: n("setup_parameters_empty")
1806
- }), /* @__PURE__ */ Q(N, {
1807
- type: "button",
1808
- size: "sm",
1809
- onClick: () => {
1810
- B({ mode: "create-root" });
1811
- },
1812
- children: [/* @__PURE__ */ Z(at, { "data-icon": "inline-start" }), n("parameter_add_root_branch")]
1813
- })]
1814
- }) : he.length === 0 && W ? /* @__PURE__ */ Z("p", {
1815
- className: "p-4 text-sm text-muted-foreground",
1816
- children: n("parameter_filter_empty")
1817
- }) : /* @__PURE__ */ Z(Rt, {
1818
- store: p,
1819
- children: /* @__PURE__ */ Z(St, {
1820
- store: k,
1821
- children: /* @__PURE__ */ Z(Et, {
1822
- mode: g,
1823
- children: /* @__PURE__ */ Z(wt, {
1824
- value: re,
1825
- children: /* @__PURE__ */ Z("div", {
1826
- className: "flex flex-col px-4 py-2 text-sm",
1827
- children: he.map((t) => t.kind === "branch" ? /* @__PURE__ */ Z(tn, {
1828
- id: t.id,
1829
- name: t.name,
1830
- depth: t.depth,
1831
- paramCount: t.paramCount,
1832
- hasChildren: t.hasChildren,
1833
- open: W || ge.has(t.id),
1834
- menuOpen: m === t.id,
1835
- onToggleExpand: _e,
1836
- onBranchCheck: ue,
1837
- onMenuOpenChange: xe,
1838
- onAddChildBranch: Se,
1839
- onAddParam: Ce,
1840
- onRename: Te
1841
- }, t.id) : /* @__PURE__ */ Z(rn, {
1842
- id: t.id,
1843
- branchId: t.branchId,
1844
- depth: t.depth,
1845
- icon: t.icon,
1846
- units: t.units,
1847
- disabled: t.disabled,
1848
- backgroundReadingPeriodMs: t.backgroundReadingPeriodMs,
1849
- deviceLog: t.deviceLog,
1850
- lastReadingReceivedAt: t.lastReadingReceivedAt,
1851
- nextReadingDueAt: t.nextReadingDueAt,
1852
- parts: t.parts,
1853
- details: G?.get(t.id) ?? null,
1854
- showDetails: v,
1855
- workspaceId: e,
1856
- writable: t.writable,
1857
- valueType: t.valueType,
1858
- onParamCheck: de
1859
- }, t.id))
1860
- })
1861
- })
1862
- })
1863
- })
1864
- }),
1865
- /* @__PURE__ */ Z(z, {
1866
- open: ie != null,
1867
- onOpenChange: (e) => {
1868
- e || B(null);
1869
- },
1870
- children: /* @__PURE__ */ Z(R, { children: ie == null ? null : /* @__PURE__ */ Z(kt, {
1871
- workspaceId: e,
1872
- dialog: ie,
1873
- onCancel: () => {
1874
- B(null);
1875
- },
1876
- onDone: (e) => {
1877
- B(null), o.success(n(e === "rename" ? "parameter_branch_rename_toast" : "parameter_branch_create_toast"));
1878
- }
1879
- }) })
1880
- }),
1881
- /* @__PURE__ */ Z(z, {
1882
- open: b,
1883
- onOpenChange: x,
1884
- children: /* @__PURE__ */ Z(R, { children: b ? /* @__PURE__ */ Z(Gt, {
1885
- workspaceId: e,
1886
- onCancel: () => {
1887
- x(!1);
1888
- },
1889
- onDone: () => {
1890
- x(!1), o.success(n("parameter_from_template_toast"));
1891
- }
1892
- }) : null })
1893
- }),
1894
- /* @__PURE__ */ Z(z, {
1895
- open: oe != null,
1896
- onOpenChange: (e) => {
1897
- e || H(null);
1898
- },
1899
- children: /* @__PURE__ */ Z(R, { children: oe == null ? null : /* @__PURE__ */ Z(Re, {
1900
- workspaceId: e,
1901
- scope: {
1902
- kind: "parameters",
1903
- parameterIds: oe,
1904
- label: n("storage_selected_parameters", { count: String(oe.length) })
1905
- },
1906
- onCancel: () => {
1907
- H(null);
1908
- },
1909
- onStarted: () => {
1910
- H(null), o.success(n("storage_deletion_started"));
1911
- }
1912
- }) })
1913
- }),
1914
- /* @__PURE__ */ Z(z, {
1915
- open: ae,
1916
- onOpenChange: V,
1917
- children: /* @__PURE__ */ Z(R, { children: ae ? /* @__PURE__ */ Z(jt, {
1918
- workspaceId: e,
1919
- paramIds: [...p.getSnapshot().selectedParamIds].filter((e) => U.has(e)),
1920
- branchIds: [...p.getSnapshot().selectedBranchIds].filter((e) => ce.has(e)),
1921
- subtreeByBranchId: w.subtreeByBranchId,
1922
- revisions: Ee,
1923
- onCancel: () => {
1924
- V(!1);
1925
- },
1926
- onDeleted: () => {
1927
- fe(), V(!1), o.success(n("parameter_delete_toast"));
1928
- }
1929
- }) : null })
1930
- })
1931
- ]
1932
- });
1933
- }
1934
- //#endregion
1935
- export { On as n, kn as t };