vuesp-components 5.3.1 → 5.3.3

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.
@@ -1,349 +1,432 @@
1
- import { ref as f, reactive as _, watch as z, computed as D, onMounted as Oe, onBeforeUnmount as De } from "vue";
2
- import { u as He, b as Pe, a as Xe } from "../useDialog-Buvn63AR.js";
3
- function Ke(c) {
4
- const { validationSchema: i, initialValues: v = {} } = c, w = typeof i == "function", b = f(
5
- w ? i(v) : i
6
- ), F = f(!0), I = (n) => {
7
- b.value = n;
8
- const r = Object.keys(n), o = Object.keys(l);
9
- r.forEach((s) => {
10
- s in l || (l[s] = v[s] ?? "", p[s] = [], x[s] = !1, g[s] = !1);
11
- }), o.forEach((s) => {
12
- r.includes(s) || (delete l[s], delete p[s], delete x[s], delete g[s]);
13
- }), Q(), L();
14
- }, l = _({}), p = _({}), x = _({}), g = _({}), d = /* @__PURE__ */ new Map(), U = () => {
15
- Object.keys(b.value).forEach((n) => {
16
- l[n] = v[n] ?? "", p[n] = [], x[n] = !1, g[n] = !1;
17
- }), F.value = !0;
18
- }, E = () => w ? i(l) : b.value, C = (n, r) => {
19
- const s = E()[n] || [], h = [];
20
- for (const y of s) {
21
- const T = y(r, l);
22
- T !== !0 && h.push(T);
1
+ import { ref as d, reactive as K, watch as ee, computed as j, onMounted as ze, onBeforeUnmount as We } from "vue";
2
+ import { u as ut, b as it, a as ft } from "../useDialog-Buvn63AR.js";
3
+ function at(a) {
4
+ const { validationSchema: l, initialValues: y = {} } = a, x = typeof l == "function", b = d(
5
+ x ? l(y) : l
6
+ ), T = d(!0), B = (r) => {
7
+ b.value = r;
8
+ const o = Object.keys(r), v = Object.keys(i);
9
+ o.forEach((s) => {
10
+ s in i || (i[s] = y[s] ?? "", w[s] = [], S[s] = !1, g[s] = !1);
11
+ }), v.forEach((s) => {
12
+ o.includes(s) || (delete i[s], delete w[s], delete S[s], delete g[s]);
13
+ }), Q(), F();
14
+ }, i = K({}), w = K({}), S = K({}), g = K({}), h = /* @__PURE__ */ new Map(), U = () => {
15
+ Object.keys(b.value).forEach((r) => {
16
+ i[r] = y[r] ?? "", w[r] = [], S[r] = !1, g[r] = !1;
17
+ }), T.value = !0;
18
+ }, k = () => x ? l(i) : b.value, E = (r, o) => {
19
+ const s = k()[r] || [], f = [];
20
+ for (const m of s) {
21
+ const L = m(o, i);
22
+ L !== !0 && f.push(L);
23
23
  }
24
- return p[n] = h, h.length === 0;
25
- }, K = (n, r) => {
26
- const o = E();
27
- if (!o[n]) return;
28
- C(n, r);
29
- const s = d.get(n);
30
- s && s.forEach((h) => {
31
- o[h] && C(h, l[h]);
32
- }), L();
24
+ return w[r] = f, f.length === 0;
25
+ }, P = (r, o) => {
26
+ const v = k();
27
+ if (!v[r]) return;
28
+ E(r, o);
29
+ const s = h.get(r);
30
+ s && s.forEach((f) => {
31
+ v[f] && E(f, i[f]);
32
+ }), F();
33
33
  }, Q = () => {
34
- d.clear();
35
- const n = E();
36
- Object.keys(n).forEach((r) => {
37
- (n[r] || []).forEach((s) => {
34
+ h.clear();
35
+ const r = k();
36
+ Object.keys(r).forEach((o) => {
37
+ (r[o] || []).forEach((s) => {
38
38
  if (typeof s == "function" && s.name === "sameAs") {
39
- const h = s.toString().match(/['"](.*?)['"]/);
40
- if (h) {
41
- const y = h[1];
42
- d.has(y) || d.set(y, /* @__PURE__ */ new Set()), d.get(y).add(r);
39
+ const f = s.toString().match(/['"](.*?)['"]/);
40
+ if (f) {
41
+ const m = f[1];
42
+ h.has(m) || h.set(m, /* @__PURE__ */ new Set()), h.get(m).add(o);
43
43
  }
44
44
  }
45
45
  });
46
46
  });
47
- }, L = () => {
48
- const n = E();
49
- let r = !0;
50
- return Object.keys(n).forEach((o) => {
51
- C(o, l[o]) || (r = !1);
52
- }), F.value = r, r;
53
- }, M = (n, r = {}) => {
54
- E()[n] || console.warn(`Field "${n}" not found in current validationSchema`);
55
- const s = D({
56
- get: () => l[n],
57
- set: (y) => {
58
- l[n] = y, g[n] = !0, K(n, y);
47
+ }, F = () => {
48
+ const r = k();
49
+ let o = !0;
50
+ return Object.keys(r).forEach((v) => {
51
+ E(v, i[v]) || (o = !1);
52
+ }), T.value = o, o;
53
+ }, M = (r, o = {}) => {
54
+ k()[r] || console.warn(`Field "${r}" not found in current validationSchema`);
55
+ const s = j({
56
+ get: () => i[r],
57
+ set: (m) => {
58
+ i[r] = m, g[r] = !0, P(r, m);
59
59
  }
60
- }), h = D(() => {
60
+ }), f = j(() => {
61
61
  var A;
62
- const y = {
63
- errors: p[n] || [],
64
- touched: x[n] || !1,
65
- dirty: g[n] || !1
66
- }, T = {
67
- message: (A = p[n]) == null ? void 0 : A[0],
68
- onInput: (O) => {
69
- const $ = O.target;
62
+ const m = {
63
+ errors: w[r] || [],
64
+ touched: S[r] || !1,
65
+ dirty: g[r] || !1
66
+ }, L = {
67
+ message: (A = w[r]) == null ? void 0 : A[0],
68
+ onInput: (R) => {
69
+ const $ = R.target;
70
70
  s.value = $.value;
71
71
  },
72
72
  onBlur: () => {
73
- x[n] = !0, K(n, l[n]);
73
+ S[r] = !0, P(r, i[r]);
74
74
  }
75
75
  };
76
- if (r.props) {
77
- const O = r.props(y);
78
- return { ...T, ...O };
76
+ if (o.props) {
77
+ const R = o.props(m);
78
+ return { ...L, ...R };
79
79
  }
80
- return T;
80
+ return L;
81
81
  });
82
- return [s, h];
83
- }, k = (n) => async (r) => {
84
- r && r.preventDefault();
85
- const o = E();
86
- Object.keys(o).forEach((h) => {
87
- x[h] = !0;
88
- }), L() && await n(l);
89
- }, j = () => {
90
- const n = E();
91
- Object.keys(n).forEach((r) => {
92
- l[r] = v[r] || "", p[r] = [], x[r] = !1, g[r] = !1;
93
- }), F.value = !0;
82
+ return [s, f];
83
+ }, I = (r) => async (o) => {
84
+ o && o.preventDefault();
85
+ const v = k();
86
+ Object.keys(v).forEach((f) => {
87
+ S[f] = !0;
88
+ }), F() && await r(i);
89
+ }, C = () => {
90
+ const r = k();
91
+ Object.keys(r).forEach((o) => {
92
+ i[o] = y[o] || "", w[o] = [], S[o] = !1, g[o] = !1;
93
+ }), T.value = !0;
94
94
  };
95
- return U(), Q(), w && z(
96
- () => l,
95
+ return U(), Q(), x && ee(
96
+ () => i,
97
97
  () => {
98
- const n = i(l), r = b.value, o = Object.keys(n), s = Object.keys(r);
99
- (o.length !== s.length || o.some((h) => !s.includes(h))) && I(n);
98
+ const r = l(i), o = b.value, v = Object.keys(r), s = Object.keys(o);
99
+ (v.length !== s.length || v.some((f) => !s.includes(f))) && B(r);
100
100
  },
101
101
  { deep: !0 }
102
102
  ), {
103
- values: l,
104
- errors: p,
103
+ values: i,
104
+ errors: w,
105
105
  defineField: M,
106
- handleSubmit: k,
107
- resetForm: j,
108
- validate: L,
109
- updateSchema: I,
110
- isValid: F
106
+ handleSubmit: I,
107
+ resetForm: C,
108
+ validate: F,
109
+ updateSchema: B,
110
+ isValid: T
111
111
  };
112
112
  }
113
- const Ie = 150, Me = 4096, ie = 256 * 1024, fe = 12, Ue = 1200, Ce = { utf8: "utf-8", cp1251: "windows-1251" }, je = {
113
+ const Ye = 150, Ze = 4096, me = 256 * 1024, pe = 12, Ne = 1200, et = { utf8: "utf-8", cp1251: "windows-1251" }, tt = {
114
114
  encoding: "utf8",
115
115
  framing: "line",
116
116
  gapMs: 25,
117
117
  paused: !1
118
- }, $e = (c, i) => (
118
+ }, nt = (a, l) => (
119
119
  // eslint-disable-next-line no-control-regex
120
- new TextDecoder(Ce[i]).decode(c).replace(/[\u0000-\u0008\u000b\u000c\u000e-\u001f]/g, ".")
121
- ), Be = (c) => Array.from(c, (i) => i.toString(16).padStart(2, "0")).join(" ");
122
- function Qe(c) {
123
- var oe, ue;
124
- const i = f([]), v = _({ ...je }), w = f(0), b = f(0), F = f(0), I = f(0), l = f(""), p = f(!1), x = f(((oe = c.initialLineEnding) == null ? void 0 : oe.call(c)) ?? "crlf"), g = f([]), d = f(-1), U = f(""), E = f(!1), C = f(!0), K = f(!0), Q = f(!0), L = f(!1), M = f(!1), k = f([]), j = f("");
125
- let n = 0, r = [], o = [], s = null, h = null, y = null, T = "", A = null, O = 0, $ = 0, V = 0, R = null;
126
- const G = (e) => {
127
- var a;
128
- const t = (a = c.storageKey) == null ? void 0 : a.call(c);
120
+ new TextDecoder(et[l]).decode(a).replace(/[\u0000-\u0008\u000b\u000c\u000e-\u001f]/g, ".")
121
+ ), rt = (a) => Array.from(a, (l) => l.toString(16).padStart(2, "0")).join(" ");
122
+ function ct(a) {
123
+ var ye, ge;
124
+ const l = d([]), y = K({ ...tt }), x = d(0), b = d(0), T = d(0), B = d(0), i = d(""), w = d(!1), S = d(((ye = a.initialLineEnding) == null ? void 0 : ye.call(a)) ?? "crlf"), g = d([]), h = d(-1), U = d(""), k = d("text"), E = d(null), P = d(!0), Q = d(!0), F = d(!0), M = d(!1), I = d(!1), C = d(!1), r = d([]), o = d("");
125
+ let v = 0, s = [], f = [], m = null, L = null, A = null, R = null, $ = "", _ = null, X = 0, G = 0, V = 0, O = null;
126
+ const te = (e) => {
127
+ var n;
128
+ const t = (n = a.storageKey) == null ? void 0 : n.call(a);
129
129
  return t ? `${t}:${e}` : null;
130
- }, J = (e) => {
131
- const t = G(e);
130
+ }, ne = (e) => {
131
+ const t = te(e);
132
132
  if (!t || typeof localStorage > "u") return null;
133
133
  try {
134
- const a = localStorage.getItem(t);
135
- return a ? JSON.parse(a) : null;
134
+ const n = localStorage.getItem(t);
135
+ return n ? JSON.parse(n) : null;
136
136
  } catch {
137
137
  return null;
138
138
  }
139
- }, H = (e, t) => {
140
- const a = G(e);
141
- if (!(!a || typeof localStorage > "u"))
139
+ }, z = (e, t) => {
140
+ const n = te(e);
141
+ if (!(!n || typeof localStorage > "u"))
142
142
  try {
143
- localStorage.setItem(a, JSON.stringify(t));
143
+ localStorage.setItem(n, JSON.stringify(t));
144
144
  } catch {
145
145
  }
146
- }, W = J("view");
147
- W && Object.assign(v, W, { paused: !1 }), v.paused = !1;
148
- const he = J("quick"), de = ((ue = c.initialQuickCommands) == null ? void 0 : ue.call(c)) ?? [];
149
- k.value = (he ?? de).filter((e) => typeof e == "string").slice(0, fe), z(v, () => H("view", { ...v, paused: !1 }), { deep: !0 });
150
- const P = (e, t) => {
151
- const a = $e(t, v.encoding);
152
- i.value.push({
153
- id: ++n,
146
+ }, re = ne("view");
147
+ re && Object.assign(y, re, { paused: !1 }), y.paused = !1;
148
+ const xe = ne("quick"), we = ((ge = a.initialQuickCommands) == null ? void 0 : ge.call(a)) ?? [];
149
+ r.value = (xe ?? we).filter((e) => typeof e == "string").slice(0, pe), ee(y, () => z("view", { ...y, paused: !1 }), { deep: !0 });
150
+ const Se = "vuesp-serial", D = "sessions", H = () => {
151
+ var t, n;
152
+ const e = (t = a.storageKey) == null ? void 0 : t.call(a);
153
+ return (n = a.session) != null && n.call(a) && e ? `${e}:session` : null;
154
+ }, W = () => new Promise((e, t) => {
155
+ const n = indexedDB.open(Se, 1);
156
+ n.onupgradeneeded = () => {
157
+ n.result.objectStoreNames.contains(D) || n.result.createObjectStore(D);
158
+ }, n.onsuccess = () => e(n.result), n.onerror = () => t(n.error);
159
+ }), be = async (e) => {
160
+ if (typeof indexedDB > "u") return null;
161
+ const t = await W();
162
+ return new Promise((n, c) => {
163
+ const u = t.transaction(D, "readonly").objectStore(D).get(e);
164
+ u.onsuccess = () => n(u.result ?? null), u.onerror = () => c(u.error);
165
+ });
166
+ }, ke = async (e, t) => {
167
+ if (typeof indexedDB > "u") return;
168
+ const n = await W();
169
+ await new Promise((c, u) => {
170
+ const p = n.transaction(D, "readwrite").objectStore(D).put(t, e);
171
+ p.onsuccess = () => c(), p.onerror = () => u(p.error);
172
+ });
173
+ }, Ee = async (e) => {
174
+ if (typeof indexedDB > "u") return;
175
+ const t = await W();
176
+ await new Promise((n, c) => {
177
+ const u = t.transaction(D, "readwrite").objectStore(D).delete(e);
178
+ u.onsuccess = () => n(), u.onerror = () => c(u.error);
179
+ });
180
+ }, Le = () => {
181
+ const e = H();
182
+ e && (R && clearTimeout(R), R = setTimeout(() => {
183
+ const t = {
184
+ lines: l.value.map((n) => ({ ...n, data: n.data ? [...n.data] : void 0 })),
185
+ rxBytes: x.value,
186
+ txBytes: b.value
187
+ };
188
+ ke(e, t).catch(() => {
189
+ });
190
+ }, 800));
191
+ }, Re = async () => {
192
+ var t;
193
+ const e = H();
194
+ if (!(!e || l.value.length))
195
+ try {
196
+ const n = await be(e);
197
+ if (!((t = n == null ? void 0 : n.lines) != null && t.length)) return;
198
+ l.value = n.lines, v = n.lines.reduce((c, u) => Math.max(c, u.id), 0), x.value = n.rxBytes ?? 0, b.value = n.txBytes ?? 0, C.value = !0;
199
+ } catch {
200
+ }
201
+ }, Y = (e, t) => {
202
+ const n = nt(t, y.encoding);
203
+ l.value.push({
204
+ id: ++v,
154
205
  dir: e,
155
- at: (/* @__PURE__ */ new Date()).toLocaleTimeString(c.locale() === "ru" ? "ru-RU" : "en-GB", { hour12: !1 }),
156
- text: v.framing === "gap" ? a.replace(/[\r\n]+/g, " ") : a,
157
- hex: Be(t),
158
- bytes: t.length
206
+ at: (/* @__PURE__ */ new Date()).toLocaleTimeString(a.locale() === "ru" ? "ru-RU" : "en-GB", { hour12: !1 }),
207
+ text: y.framing === "gap" ? n.replace(/[\r\n]+/g, " ") : n,
208
+ hex: rt(t),
209
+ bytes: t.length,
210
+ // Keep a bounded copy for the binary view and byte inspector.
211
+ data: Array.from(t.slice(0, 1024))
159
212
  });
160
- const u = c.maxLines();
161
- i.value.length > u && i.value.splice(0, i.value.length - u);
162
- }, q = () => {
163
- s && (clearTimeout(s), s = null);
164
- }, Y = () => {
165
- if (q(), !r.length) return;
166
- const e = new Uint8Array(r);
167
- r = [], P("rx", e);
168
- }, ve = () => {
169
- q();
170
- const e = v.framing === "gap" ? Math.max(5, v.gapMs) : Ie;
171
- s = setTimeout(Y, e);
172
- }, Z = (e) => {
173
- for (const t of e) r.push(t);
174
- if (v.framing === "line") {
213
+ const c = a.maxLines();
214
+ l.value.length > c && l.value.splice(0, l.value.length - c), Le();
215
+ }, J = () => {
216
+ m && (clearTimeout(m), m = null);
217
+ }, se = () => {
218
+ if (J(), !s.length) return;
219
+ const e = new Uint8Array(s);
220
+ s = [], Y("rx", e);
221
+ }, Te = () => {
222
+ J();
223
+ const e = y.framing === "gap" ? Math.max(5, y.gapMs) : Ye;
224
+ m = setTimeout(se, e);
225
+ }, ae = (e) => {
226
+ for (const t of e) s.push(t);
227
+ if (y.framing === "line") {
175
228
  let t = 0;
176
- for (let a = 0; a < r.length; a++) {
177
- const u = r[a];
178
- if (u !== 10 && u !== 13) continue;
179
- const m = r.slice(t, a);
180
- m.length && P("rx", new Uint8Array(m)), u === 13 && r[a + 1] === 10 && a++, t = a + 1;
229
+ for (let n = 0; n < s.length; n++) {
230
+ const c = s[n];
231
+ if (c !== 10 && c !== 13) continue;
232
+ const u = s.slice(t, n);
233
+ u.length && Y("rx", new Uint8Array(u)), c === 13 && s[n + 1] === 10 && n++, t = n + 1;
181
234
  }
182
- t && (r = r.slice(t));
235
+ t && (s = s.slice(t));
183
236
  }
184
- r.length >= Me ? Y() : ve();
185
- }, B = () => {
186
- y && clearTimeout(y), y = null, M.value = !1;
187
- }, ge = (e) => {
188
- var a;
189
- const t = (a = c.noReplyHint) == null ? void 0 : a.call(c);
190
- t && (B(), y = setTimeout(() => {
191
- w.value === e && (M.value = !0);
237
+ s.length >= Ze ? se() : Te();
238
+ }, q = () => {
239
+ A && clearTimeout(A), A = null, I.value = !1;
240
+ }, Oe = (e) => {
241
+ var n;
242
+ const t = (n = a.noReplyHint) == null ? void 0 : n.call(a);
243
+ t && (q(), A = setTimeout(() => {
244
+ x.value === e && (I.value = !0);
192
245
  }, t.delay ?? 1500));
193
- }, ye = (e) => {
246
+ }, De = (e) => {
194
247
  if (e != null && e.length) {
195
- if (M.value && B(), w.value += e.length, v.paused) {
196
- for (const t of e) o.push(t);
197
- o.length > ie && o.splice(0, o.length - ie);
248
+ if (I.value && q(), x.value += e.length, y.paused) {
249
+ for (const t of e) f.push(t);
250
+ f.length > me && f.splice(0, f.length - me);
198
251
  return;
199
252
  }
200
- Z(e);
253
+ ae(e);
201
254
  }
202
- }, me = () => {
203
- R == null || R(), R = c.transport().subscribe(ye);
255
+ }, je = () => {
256
+ O == null || O(), O = a.transport().subscribe(De);
204
257
  };
205
- z(
206
- () => v.paused,
258
+ ee(
259
+ () => y.paused,
207
260
  (e) => {
208
- if (e || !o.length) return;
209
- const t = new Uint8Array(o);
210
- o = [], Z(t);
261
+ if (e || !f.length) return;
262
+ const t = new Uint8Array(f);
263
+ f = [], ae(t);
211
264
  }
212
265
  );
213
- const N = async (e) => {
214
- const t = await c.transport().send(e);
215
- return t && (b.value += e.length, P("tx", e)), t;
216
- }, X = D(() => l.value.replace(/^0x/i, "").replace(/0x/gi, "").replace(/[^0-9a-fA-F]/g, "")), pe = D(() => {
217
- const e = l.value.replace(/0x/gi, "").replace(/[\s,;:]/g, "");
266
+ const ce = async (e) => {
267
+ const t = await a.transport().send(e);
268
+ return t && (b.value += e.length, Y("tx", e)), t;
269
+ }, Z = j(() => i.value.replace(/^0x/i, "").replace(/0x/gi, "").replace(/[^0-9a-fA-F]/g, "")), Ae = j(() => {
270
+ const e = i.value.replace(/0x/gi, "").replace(/[\s,;:]/g, "");
218
271
  return e.length > 0 && /[^0-9a-fA-F]/.test(e);
219
- }), ee = D(() => {
220
- const e = X.value, t = [];
221
- for (let a = 0; a + 1 < e.length; a += 2) t.push(parseInt(e.slice(a, a + 2), 16));
272
+ }), oe = j(() => {
273
+ const e = Z.value, t = [];
274
+ for (let n = 0; n + 1 < e.length; n += 2) t.push(parseInt(e.slice(n, n + 2), 16));
222
275
  return t;
223
- }), te = D(() => p.value ? pe.value ? c.labels().hexInvalid : X.value && X.value.length % 2 ? c.labels().hexOdd : "" : ""), ne = (e, t) => {
276
+ }), le = j(() => w.value ? Ae.value ? a.labels().hexInvalid : Z.value && Z.value.length % 2 ? a.labels().hexOdd : "" : ""), ue = (e, t) => {
224
277
  if (t) {
225
- const u = e.replace(/0x/gi, "").replace(/[^0-9a-fA-F]/g, "");
226
- if (!u.length || u.length % 2) return [];
227
- const m = [];
228
- for (let S = 0; S + 1 < u.length; S += 2) m.push(parseInt(u.slice(S, S + 2), 16));
229
- return m;
278
+ const c = e.replace(/0x/gi, "").replace(/[^0-9a-fA-F]/g, "");
279
+ if (!c.length || c.length % 2) return [];
280
+ const u = [];
281
+ for (let p = 0; p + 1 < c.length; p += 2) u.push(parseInt(c.slice(p, p + 2), 16));
282
+ return u;
230
283
  }
231
- const a = Array.from(new TextEncoder().encode(e));
232
- return (x.value === "cr" || x.value === "crlf") && a.push(13), (x.value === "lf" || x.value === "crlf") && a.push(10), a;
233
- }, xe = async () => {
234
- if (p.value && (te.value || !ee.value.length)) return;
235
- const e = l.value, t = ne(e, p.value);
236
- !t.length || !await N(new Uint8Array(t.slice(0, 4096))) || (e.trim() && (g.value = [e, ...g.value.filter((u) => u !== e)].slice(0, 50), d.value = -1), l.value = "");
237
- }, re = async (e) => {
238
- const t = ne(e, !1);
284
+ const n = Array.from(new TextEncoder().encode(e));
285
+ return (S.value === "cr" || S.value === "crlf") && n.push(13), (S.value === "lf" || S.value === "crlf") && n.push(10), n;
286
+ }, Be = async () => {
287
+ if (w.value && (le.value || !oe.value.length)) return;
288
+ const e = i.value, t = ue(e, w.value);
289
+ !t.length || !await ce(new Uint8Array(t.slice(0, 4096))) || (e.trim() && (g.value = [e, ...g.value.filter((c) => c !== e)].slice(0, 50), h.value = -1), i.value = "");
290
+ }, ie = async (e) => {
291
+ const t = ue(e, !1);
239
292
  if (!t.length) return;
240
- const a = w.value;
241
- await N(new Uint8Array(t.slice(0, 4096))) && (g.value = [e, ...g.value.filter((m) => m !== e)].slice(0, 50), d.value = -1, T = e, ge(a));
242
- }, we = async () => {
293
+ const n = x.value;
294
+ await ce(new Uint8Array(t.slice(0, 4096))) && (g.value = [e, ...g.value.filter((u) => u !== e)].slice(0, 50), h.value = -1, $ = e, Oe(n));
295
+ }, Fe = async () => {
243
296
  var t;
244
- const e = (t = c.noReplyHint) == null ? void 0 : t.call(c);
245
- e != null && e.onAction && (B(), await e.onAction(), (e.resend ?? !0) && T && await re(T));
246
- }, ke = (e) => {
297
+ const e = (t = a.noReplyHint) == null ? void 0 : t.call(a);
298
+ e != null && e.onAction && (q(), await e.onAction(), (e.resend ?? !0) && $ && await ie($));
299
+ }, Ie = (e) => {
247
300
  if (e.key === "ArrowUp") {
248
301
  if (!g.value.length) return;
249
- e.preventDefault(), d.value = d.value === -1 ? g.value.length - 1 : Math.max(0, d.value - 1), l.value = g.value[d.value] ?? "";
302
+ e.preventDefault(), h.value = h.value === -1 ? g.value.length - 1 : Math.max(0, h.value - 1), i.value = g.value[h.value] ?? "";
250
303
  return;
251
304
  }
252
305
  if (e.key === "ArrowDown") {
253
- if (d.value === -1) return;
254
- e.preventDefault(), d.value++, d.value >= g.value.length ? (d.value = -1, l.value = "") : l.value = g.value[d.value] ?? "";
306
+ if (h.value === -1) return;
307
+ e.preventDefault(), h.value++, h.value >= g.value.length ? (h.value = -1, i.value = "") : i.value = g.value[h.value] ?? "";
255
308
  return;
256
309
  }
257
- e.key === "Escape" && (l.value = "", d.value = -1);
258
- }, Se = D(() => {
310
+ e.key === "Escape" && (i.value = "", h.value = -1);
311
+ }, Ue = j(() => {
259
312
  const e = U.value.trim().toLowerCase();
260
- return e ? i.value.filter((t) => t.text.toLowerCase().includes(e) || t.hex.toLowerCase().includes(e)) : i.value;
261
- }), be = (e) => E.value ? e.hex : e.text || e.hex, Ee = (e) => {
313
+ return e ? l.value.filter((t) => t.text.toLowerCase().includes(e) || t.hex.toLowerCase().includes(e)) : l.value;
314
+ }), Me = (e) => (e.data ?? []).map((t) => t.toString(2).padStart(8, "0")).join(" "), Ce = (e) => k.value === "hex" ? e.hex : k.value === "bin" ? Me(e) : e.text || e.hex, $e = j(() => l.value.find((e) => e.id === E.value) ?? null), _e = (e) => {
315
+ E.value = E.value === e.id ? null : e.id;
316
+ }, qe = (e) => {
262
317
  const t = U.value.trim().toLowerCase();
263
318
  if (!t) return [{ text: e, match: !1 }];
264
- const a = e.toLowerCase(), u = [];
265
- let m = 0;
266
- for (; m < e.length; ) {
267
- const S = a.indexOf(t, m);
268
- if (S === -1) break;
269
- S > m && u.push({ text: e.slice(m, S), match: !1 }), u.push({ text: e.slice(S, S + t.length), match: !0 }), m = S + t.length;
319
+ const n = e.toLowerCase(), c = [];
320
+ let u = 0;
321
+ for (; u < e.length; ) {
322
+ const p = n.indexOf(t, u);
323
+ if (p === -1) break;
324
+ p > u && c.push({ text: e.slice(u, p), match: !1 }), c.push({ text: e.slice(p, p + t.length), match: !0 }), u = p + t.length;
270
325
  }
271
- return m < e.length && u.push({ text: e.slice(m), match: !1 }), u.length ? u : [{ text: e, match: !1 }];
272
- }, ae = () => i.value.map((e) => `${e.at} ${e.dir.toUpperCase()} ${e.text || e.hex}`).join(`
273
- `), se = async () => {
274
- if (!i.value.length) return !1;
326
+ return u < e.length && c.push({ text: e.slice(u), match: !1 }), c.length ? c : [{ text: e, match: !1 }];
327
+ }, N = (e, t) => {
328
+ const n = URL.createObjectURL(t), c = document.createElement("a"), u = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
329
+ return c.href = n, c.download = `serial-${u}.${e}`, c.click(), URL.revokeObjectURL(n), !0;
330
+ }, fe = () => l.value.map((e) => `${e.at} ${e.dir.toUpperCase()} ${e.text || e.hex}`).join(`
331
+ `), Ke = () => {
332
+ if (!l.value.length) return !1;
333
+ const e = (n) => `"${String(n).replace(/"/g, '""')}"`, t = l.value.map((n) => [n.at, n.dir, n.bytes, e(n.text), e(n.hex)].join(","));
334
+ return N("csv", new Blob([["time,direction,bytes,text,hex", ...t].join(`
335
+ `)], { type: "text/csv;charset=utf-8" }));
336
+ }, Pe = () => {
337
+ if (!l.value.length) return !1;
338
+ const e = l.value.map((t) => ({ at: t.at, dir: t.dir, bytes: t.bytes, text: t.text, hex: t.hex }));
339
+ return N("json", new Blob([JSON.stringify(e, null, 2)], { type: "application/json;charset=utf-8" }));
340
+ }, Qe = () => {
341
+ var t;
342
+ const e = [];
343
+ for (const n of l.value)
344
+ n.dir === "rx" && ((t = n.data) != null && t.length) && e.push(...n.data);
345
+ return e.length ? N("bin", new Blob([new Uint8Array(e)], { type: "application/octet-stream" })) : !1;
346
+ }, de = async () => {
347
+ if (!l.value.length) return !1;
275
348
  try {
276
- return await navigator.clipboard.writeText(ae()), L.value = !0, A && clearTimeout(A), A = setTimeout(() => {
277
- L.value = !1;
278
- }, Ue), !0;
349
+ return await navigator.clipboard.writeText(fe()), M.value = !0, _ && clearTimeout(_), _ = setTimeout(() => {
350
+ M.value = !1;
351
+ }, Ne), !0;
279
352
  } catch {
280
353
  return !1;
281
354
  }
282
- }, Te = () => {
283
- if (!i.value.length) return !1;
284
- const e = new Blob([ae()], { type: "text/plain;charset=utf-8" }), t = URL.createObjectURL(e), a = document.createElement("a"), u = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
285
- return a.href = t, a.download = `serial-${u}.log`, a.click(), URL.revokeObjectURL(t), !0;
286
- }, ce = () => {
287
- B(), q(), r = [], o = [], i.value = [], w.value = 0, b.value = 0, F.value = 0, I.value = 0, O = 0, $ = 0, V = performance.now();
288
- }, Fe = (e) => {
289
- const t = c.labels();
355
+ }, Ve = () => {
356
+ if (!l.value.length) return !1;
357
+ const e = new Blob([fe()], { type: "text/plain;charset=utf-8" }), t = URL.createObjectURL(e), n = document.createElement("a"), c = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
358
+ return n.href = t, n.download = `serial-${c}.log`, n.click(), URL.revokeObjectURL(t), !0;
359
+ }, he = () => {
360
+ q(), J();
361
+ const e = H();
362
+ e && Ee(e).catch(() => {
363
+ }), C.value = !1, s = [], f = [], l.value = [], E.value = null, x.value = 0, b.value = 0, T.value = 0, B.value = 0, X = 0, G = 0, V = performance.now();
364
+ }, He = (e) => {
365
+ const t = a.labels();
290
366
  return e < 1024 ? `${e} ${t.byteShort}` : e < 1024 * 1024 ? `${(e / 1024).toFixed(1)} ${t.kiloShort}` : `${(e / (1024 * 1024)).toFixed(2)} ${t.megaShort}`;
291
- }, Le = () => {
367
+ }, Je = () => {
292
368
  const e = performance.now(), t = (e - V) / 1e3;
293
- t <= 0 || (F.value = Math.max(0, Math.round((w.value - O) / t)), I.value = Math.max(0, Math.round((b.value - $) / t)), O = w.value, $ = b.value, V = e);
294
- }, Ae = () => {
295
- const e = j.value.trim();
296
- e && (k.value.includes(e) || (k.value = [...k.value, e].slice(0, fe)), j.value = "", H("quick", k.value));
297
- }, Re = (e) => {
298
- k.value = k.value.filter((t) => t !== e), H("quick", k.value);
299
- }, le = (e) => {
300
- e.ctrlKey && (e.key.toLowerCase() === "l" && (e.preventDefault(), ce()), e.shiftKey && e.key.toLowerCase() === "c" && (e.preventDefault(), se()));
369
+ t <= 0 || (T.value = Math.max(0, Math.round((x.value - X) / t)), B.value = Math.max(0, Math.round((b.value - G) / t)), X = x.value, G = b.value, V = e);
370
+ }, Xe = () => {
371
+ const e = o.value.trim();
372
+ e && (r.value.includes(e) || (r.value = [...r.value, e].slice(0, pe)), o.value = "", z("quick", r.value));
373
+ }, Ge = (e) => {
374
+ r.value = r.value.filter((t) => t !== e), z("quick", r.value);
375
+ }, ve = (e) => {
376
+ e.ctrlKey && (e.key.toLowerCase() === "l" && (e.preventDefault(), he()), e.shiftKey && e.key.toLowerCase() === "c" && (e.preventDefault(), de()));
301
377
  };
302
- return Oe(() => {
303
- me(), V = performance.now(), h = setInterval(Le, 1e3), window.addEventListener("keydown", le);
304
- }), De(() => {
305
- R == null || R(), R = null, B(), q(), h && clearInterval(h), A && clearTimeout(A), window.removeEventListener("keydown", le);
378
+ return ze(() => {
379
+ je(), H() && Re(), V = performance.now(), L = setInterval(Je, 1e3), window.addEventListener("keydown", ve);
380
+ }), We(() => {
381
+ O == null || O(), O = null, q(), J(), L && clearInterval(L), _ && clearTimeout(_), R && clearTimeout(R), window.removeEventListener("keydown", ve);
306
382
  }), {
307
- lines: i,
308
- visibleLines: Se,
309
- view: v,
310
- rxBytes: w,
383
+ lines: l,
384
+ visibleLines: Ue,
385
+ view: y,
386
+ rxBytes: x,
311
387
  txBytes: b,
312
- rxRate: F,
313
- txRate: I,
314
- input: l,
315
- hexSend: p,
316
- lineEnding: x,
388
+ rxRate: T,
389
+ txRate: B,
390
+ input: i,
391
+ hexSend: w,
392
+ lineEnding: S,
317
393
  history: g,
318
394
  filter: U,
319
- hexMode: E,
320
- showTime: C,
321
- wrapLines: K,
322
- autoScroll: Q,
323
- copied: L,
324
- showNoReply: M,
325
- quickCommands: k,
326
- quickInput: j,
327
- hexBytes: ee,
328
- hexError: te,
329
- sendText: xe,
330
- sendQuick: re,
331
- onInputKeydown: ke,
332
- lineContent: be,
333
- lineSegments: Ee,
334
- copyLog: se,
335
- downloadLog: Te,
336
- clearLog: ce,
337
- formatBytes: Fe,
338
- addQuick: Ae,
339
- removeQuick: Re,
340
- applyHintAction: we
395
+ mode: k,
396
+ selectedId: E,
397
+ selectedLine: $e,
398
+ selectLine: _e,
399
+ showTime: P,
400
+ wrapLines: Q,
401
+ autoScroll: F,
402
+ copied: M,
403
+ showNoReply: I,
404
+ quickCommands: r,
405
+ quickInput: o,
406
+ hexBytes: oe,
407
+ hexError: le,
408
+ sendText: Be,
409
+ sendQuick: ie,
410
+ onInputKeydown: Ie,
411
+ lineContent: Ce,
412
+ lineSegments: qe,
413
+ copyLog: de,
414
+ downloadLog: Ve,
415
+ exportCsv: Ke,
416
+ exportJson: Pe,
417
+ exportRxBin: Qe,
418
+ sessionRestored: C,
419
+ clearLog: he,
420
+ formatBytes: He,
421
+ addQuick: Xe,
422
+ removeQuick: Ge,
423
+ applyHintAction: Fe
341
424
  };
342
425
  }
343
426
  export {
344
- He as useDialog,
345
- Pe as useFocusTrap,
346
- Ke as useForm,
347
- Qe as useSerialConsole,
348
- Xe as useSwipeDown
427
+ ut as useDialog,
428
+ it as useFocusTrap,
429
+ at as useForm,
430
+ ct as useSerialConsole,
431
+ ft as useSwipeDown
349
432
  };