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