@mcurcio/patchbay 0.7.0 → 0.9.0

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.
@@ -45,40 +45,351 @@ function _({ tone: e, children: r, actions: i, onDismiss: a, labels: o, classNam
45
45
  ]
46
46
  });
47
47
  }
48
+ // src/composites/code-editor/CodeRuns.tsx
49
+ function v({ runs: e }) {
50
+ return e.map((e, n) => e.class === "" && e.mark === void 0 ? e.text : /* @__PURE__ */ t("span", {
51
+ className: "pb-code-run",
52
+ "data-class": e.class || void 0,
53
+ "data-mark": e.mark,
54
+ children: e.text
55
+ }, n));
56
+ }
57
+ // src/composites/code-editor/highlight.ts
58
+ function y(e) {
59
+ return e.replace(/\r\n?/g, "\n");
60
+ }
61
+ function b(e) {
62
+ let t = [0];
63
+ for (let n = e.indexOf("\n"); n !== -1; n = e.indexOf("\n", n + 1)) t.push(n + 1);
64
+ return t;
65
+ }
66
+ function x(e, t) {
67
+ let n = Math.min(e.length, Math.max(0, Math.trunc(t))), r = b(e), i = 0;
68
+ for (; i + 1 < r.length && (r[i + 1] ?? Infinity) <= n;) i += 1;
69
+ return {
70
+ line: i + 1,
71
+ column: n - (r[i] ?? 0) + 1,
72
+ offset: n
73
+ };
74
+ }
75
+ function S(e, t, n = 1) {
76
+ let r = b(e), i = Math.min(r.length, Math.max(1, Math.trunc(t))) - 1, a = r[i] ?? 0, o = i + 1 < r.length ? (r[i + 1] ?? 0) - 1 : e.length;
77
+ return Math.min(o, a + Math.max(1, Math.trunc(n)) - 1);
78
+ }
79
+ function C(e) {
80
+ return e === "error" ? "error" : e === "warning" ? "warning" : "other";
81
+ }
82
+ var w = {
83
+ other: 1,
84
+ warning: 2,
85
+ error: 3
86
+ };
87
+ function T(e, t) {
88
+ return e !== void 0 && w[e] >= w[t] ? e : t;
89
+ }
90
+ function E(e, t) {
91
+ let n = b(e), r = Math.min(n.length, Math.max(1, Math.trunc(t.line))) - 1, i = n[r] ?? 0, a = r + 1 < n.length ? (n[r + 1] ?? 0) - 1 : e.length;
92
+ if (t.column === void 0) {
93
+ let t = i, n = a;
94
+ for (; t < n && /\s/.test(e[t] ?? "");) t += 1;
95
+ for (; n > t && /\s/.test(e[n - 1] ?? "");) --n;
96
+ return {
97
+ start: t,
98
+ end: n
99
+ };
100
+ }
101
+ let o = S(e, r + 1, t.column), s = o;
102
+ for (; s < a && !/\s/.test(e[s] ?? "");) s += 1;
103
+ return s === o && o < a && (s = o + 1), {
104
+ start: o,
105
+ end: s
106
+ };
107
+ }
108
+ function D(e, t = [], n = []) {
109
+ let r = [""], i = new Uint16Array(e.length);
110
+ for (let n of t) {
111
+ let t = Math.max(0, Math.trunc(n.start)), a = Math.min(e.length, Math.trunc(n.end));
112
+ if (!(a > t)) continue;
113
+ let o = n.class === "space" ? "" : n.class, s = r.indexOf(o);
114
+ s === -1 && (s = r.push(o) - 1), i.fill(s, t, a);
115
+ }
116
+ let a = [
117
+ void 0,
118
+ "other",
119
+ "warning",
120
+ "error"
121
+ ], o = new Uint8Array(e.length);
122
+ for (let t of n) {
123
+ let { start: n, end: r } = E(e, t), i = w[C(t.severity)];
124
+ for (let e = n; e < r; e += 1) o[e] = Math.max(o[e] ?? 0, i);
125
+ }
126
+ let s = [], c = 0;
127
+ for (let t = 1; t <= e.length; t += 1) {
128
+ if (t < e.length && i[t] === i[c] && o[t] === o[c]) continue;
129
+ let n = a[o[c] ?? 0], l = {
130
+ text: e.slice(c, t),
131
+ class: r[i[c] ?? 0] ?? ""
132
+ };
133
+ n !== void 0 && (l.mark = n), s.push(l), c = t;
134
+ }
135
+ return s;
136
+ }
137
+ function O(e, t = []) {
138
+ let n = b(e).length, r = Array.from({ length: n }, (e, t) => ({
139
+ line: t + 1,
140
+ column: 1,
141
+ diagnostics: []
142
+ }));
143
+ for (let e of t) {
144
+ let t = r[Math.min(n, Math.max(1, Math.trunc(e.line))) - 1];
145
+ t !== void 0 && (t.diagnostics.length === 0 && (t.column = e.column ?? 1), t.diagnostics.push(e), t.mark = T(t.mark, C(e.severity)));
146
+ }
147
+ return r;
148
+ }
149
+ var k, A;
150
+ function j() {
151
+ return k ??= import("knobly/highlight").then((e) => A = e.highlight, (e) => (console.warn("patchbay: language \"knobly\" needs the knobly package; drawing plain text.", e), A = null, null)), k;
152
+ }
153
+ function M(e, t) {
154
+ let n = t === void 0 && e === "knobly", [r, a] = l(void 0);
155
+ return i(() => {
156
+ if (!n || A !== void 0) return;
157
+ let e = !0;
158
+ return j().then((t) => {
159
+ e && a({ highlight: t });
160
+ }), () => {
161
+ e = !1;
162
+ };
163
+ }, [n]), t === void 0 ? n ? A ?? r?.highlight ?? void 0 : void 0 : t;
164
+ }
165
+ // src/composites/code-editor/CodeEditor.tsx
166
+ var N = {
167
+ diagnostic: ({ line: e, column: t, severity: n, code: r, message: i }) => `Line ${String(e)}${t === void 0 ? "" : `, column ${String(t)}`}: ${n}${r === void 0 || r === "" ? "" : ` ${r}`}: ${i}`,
168
+ tabKey: "Tab indents. Press Escape, then Tab, to move on."
169
+ }, P = [];
170
+ function F(e, t) {
171
+ if (t !== "" && e.startsWith(t)) return t.length;
172
+ if (e.startsWith(" ")) return 1;
173
+ let n = t === " " || t === "" ? 4 : t.length, r = 0;
174
+ for (; r < n && e[r] === " ";) r += 1;
175
+ return r;
176
+ }
177
+ function I(e, t, n, r, i) {
178
+ let a = e.slice(t, n).includes("\n");
179
+ if (!i && !a) {
180
+ if (r === "") return;
181
+ let e = t + r.length;
182
+ return {
183
+ from: t,
184
+ to: n,
185
+ insert: r,
186
+ start: e,
187
+ end: e
188
+ };
189
+ }
190
+ let o = e.lastIndexOf("\n", t - 1) + 1, s = n > t && e[n - 1] === "\n" ? n - 1 : n, c = e.indexOf("\n", s), l = c === -1 ? e.length : c, u = e.slice(o, l).split("\n"), d = u.map((e) => i ? e.slice(F(e, r)) : e === "" ? e : r + e), f = d.join("\n");
191
+ if (f !== e.slice(o, l)) {
192
+ if (t === n) {
193
+ let e = (d[0] ?? "").length - (u[0] ?? "").length, n = Math.max(o, t + e);
194
+ return {
195
+ from: o,
196
+ to: l,
197
+ insert: f,
198
+ start: n,
199
+ end: n
200
+ };
201
+ }
202
+ return {
203
+ from: o,
204
+ to: l,
205
+ insert: f,
206
+ start: o,
207
+ end: o + f.length
208
+ };
209
+ }
210
+ }
211
+ function L(e) {
212
+ let t = document.execCommand;
213
+ return typeof t == "function" ? e === "" ? t.call(document, "delete", !1) : t.call(document, "insertText", !1, e) : !1;
214
+ }
215
+ function R({ value: e, onChange: r, language: i, highlight: l, diagnostics: u = P, onCaret: d, lineNumbers: f = !0, indent: p = " ", labels: m, readOnly: h = !1, className: g, style: _, ref: b, onKeyDown: C, onBlur: w, onScroll: T, onSelect: E, "aria-describedby": k, ...A }) {
216
+ let j = {
217
+ ...N,
218
+ ...m
219
+ }, F = c(null), R = c(null), z = c(null), B = c(!1), V = c(null), H = c(""), U = a(), W = M(i, l), G = y(e), ee = s(() => D(G, W?.(G), u), [
220
+ G,
221
+ W,
222
+ u
223
+ ]), K = s(() => O(G, u), [G, u]), q = () => {
224
+ let e = F.current;
225
+ e !== null && (R.current !== null && (R.current.scrollTop = e.scrollTop, R.current.scrollLeft = e.scrollLeft), z.current !== null && (z.current.scrollTop = e.scrollTop));
226
+ }, J = () => {
227
+ let e = F.current;
228
+ if (e === null || d === void 0) return;
229
+ let t = e.selectionDirection === "backward" ? e.selectionStart : e.selectionEnd, n = x(e.value, t), r = `${String(n.line)}:${String(n.column)}:${String(n.offset)}`;
230
+ r !== H.current && (H.current = r, d(n));
231
+ };
232
+ o(() => {
233
+ let e = F.current, t = V.current;
234
+ V.current = null, e !== null && t !== null && e.value === t.value && (e.setSelectionRange(t.start, t.end), J()), q();
235
+ });
236
+ let Y = (e, t) => {
237
+ if (e.setSelectionRange(t.from, t.to), L(t.insert)) {
238
+ e.setSelectionRange(t.start, t.end), J();
239
+ return;
240
+ }
241
+ let n = e.value.slice(0, t.from) + t.insert + e.value.slice(t.to);
242
+ V.current = {
243
+ value: n,
244
+ start: t.start,
245
+ end: t.end
246
+ }, r?.(n);
247
+ }, X = (e) => {
248
+ if (C?.(e), e.defaultPrevented) return;
249
+ if (e.key === "Escape") {
250
+ B.current = !0;
251
+ return;
252
+ }
253
+ if (e.key !== "Tab") {
254
+ e.key !== "Shift" && (B.current = !1);
255
+ return;
256
+ }
257
+ let t = B.current;
258
+ if (B.current = !1, t || h || e.ctrlKey || e.altKey || e.metaKey || e.nativeEvent.isComposing) return;
259
+ e.preventDefault();
260
+ let n = e.currentTarget, r = I(n.value, n.selectionStart, n.selectionEnd, p, e.shiftKey);
261
+ r !== void 0 && Y(n, r);
262
+ }, Z = (e, t) => {
263
+ let n = F.current;
264
+ if (n === null) return;
265
+ let r = S(n.value, e, t);
266
+ n.focus(), n.setSelectionRange(r, r), J();
267
+ }, Q = [...h ? [] : [j.tabKey], ...u.map((e) => j.diagnostic(e))], te = [k, Q.length > 0 ? U : void 0].filter((e) => e !== void 0 && e !== "").join(" ") || void 0, $ = String(K.length).length;
268
+ return /* @__PURE__ */ n("div", {
269
+ className: g === void 0 ? "pb-code-editor" : `pb-code-editor ${g}`,
270
+ style: _,
271
+ "data-readonly": h || void 0,
272
+ children: [
273
+ f ? /* @__PURE__ */ t("pre", {
274
+ ref: z,
275
+ className: "pb-code-gutter",
276
+ "aria-hidden": "true",
277
+ style: { "--pb-code-gutter-digits": $ },
278
+ children: /* @__PURE__ */ t("code", {
279
+ className: "pb-code-gutter-code",
280
+ children: K.map((e) => /* @__PURE__ */ n("span", {
281
+ className: "pb-code-gutter-row",
282
+ children: [
283
+ e.line,
284
+ /* @__PURE__ */ t("span", {
285
+ className: "pb-code-gutter-mark",
286
+ "data-mark": e.mark,
287
+ title: e.diagnostics.length === 0 ? void 0 : e.diagnostics.map((e) => j.diagnostic(e)).join("\n"),
288
+ onClick: e.mark === void 0 ? void 0 : () => {
289
+ Z(e.line, e.column);
290
+ }
291
+ }),
292
+ "\n"
293
+ ]
294
+ }, e.line))
295
+ })
296
+ }) : null,
297
+ /* @__PURE__ */ n("div", {
298
+ className: "pb-code-box",
299
+ children: [/* @__PURE__ */ t("pre", {
300
+ ref: R,
301
+ className: "pb-code-layer",
302
+ "aria-hidden": "true",
303
+ children: /* @__PURE__ */ n("code", {
304
+ className: "pb-code-layer-code",
305
+ children: [/* @__PURE__ */ t(v, { runs: ee }), "\n"]
306
+ })
307
+ }), /* @__PURE__ */ t("textarea", {
308
+ spellCheck: !1,
309
+ autoCapitalize: "off",
310
+ autoComplete: "off",
311
+ autoCorrect: "off",
312
+ wrap: "off",
313
+ ...A,
314
+ ref: (e) => {
315
+ if (F.current = e, typeof b == "function") return b(e);
316
+ b && (b.current = e);
317
+ },
318
+ className: "pb-code-input",
319
+ value: e,
320
+ readOnly: h,
321
+ "aria-describedby": te,
322
+ onChange: (e) => r?.(e.target.value),
323
+ onKeyDown: X,
324
+ onBlur: (e) => {
325
+ B.current = !1, w?.(e);
326
+ },
327
+ onScroll: (e) => {
328
+ q(), T?.(e);
329
+ },
330
+ onSelect: (e) => {
331
+ J(), E?.(e);
332
+ }
333
+ })]
334
+ }),
335
+ Q.length > 0 ? /* @__PURE__ */ t("div", {
336
+ id: U,
337
+ hidden: !0,
338
+ children: Q.map((e, n) => /* @__PURE__ */ t("p", { children: e }, n))
339
+ }) : null
340
+ ]
341
+ });
342
+ }
343
+ // src/composites/code-editor/CodeText.tsx
344
+ function z({ value: e, language: n, highlight: r, className: i, ...a }) {
345
+ let o = M(n, r), c = s(() => {
346
+ let t = y(e);
347
+ return D(t, o?.(t));
348
+ }, [e, o]);
349
+ return /* @__PURE__ */ t("pre", {
350
+ tabIndex: 0,
351
+ ...a,
352
+ className: i === void 0 ? "pb-code-text" : `pb-code-text ${i}`,
353
+ children: /* @__PURE__ */ t("code", {
354
+ className: "pb-code-text-code",
355
+ children: /* @__PURE__ */ t(v, { runs: c })
356
+ })
357
+ });
358
+ }
48
359
  // src/composites/command-palette/rank.ts
49
- function v(e, t) {
360
+ function B(e, t) {
50
361
  if (t === 0) return !0;
51
362
  let n = e.charAt(t - 1), r = e.charAt(t);
52
363
  return !/[\p{L}\p{N}]/u.test(n) || n !== n.toUpperCase() && r !== r.toLowerCase() && r === r.toUpperCase();
53
364
  }
54
- function y(e) {
365
+ function V(e) {
55
366
  let t = e.toLowerCase();
56
367
  return t.length === 1 ? t : e;
57
368
  }
58
- var b = 3, x = 2, S = 2, C = .1, w = 1, T = .02;
59
- function E(e, t) {
369
+ var H = 3, U = 2, W = 2, G = .1, ee = 1, K = .02;
370
+ function q(e, t) {
60
371
  let n = t.replace(/\s+/g, "");
61
372
  if (n === "") return {
62
373
  indices: [],
63
374
  score: 0
64
375
  };
65
- let r = Array.from({ length: n.length }, (e, t) => y(n.charAt(t))), i = Array.from({ length: e.length }, (t, n) => y(e.charAt(n))), a = e.length, o = r.length;
376
+ let r = Array.from({ length: n.length }, (e, t) => V(n.charAt(t))), i = Array.from({ length: e.length }, (t, n) => V(e.charAt(n))), a = e.length, o = r.length;
66
377
  if (o > a) return;
67
- let s = i.map((t, n) => n === 0 ? b : v(e, n) ? x : 0), c = [], l = [];
378
+ let s = i.map((t, n) => n === 0 ? H : B(e, n) ? U : 0), c = [], l = [];
68
379
  for (let e = 0; e < o; e += 1) {
69
380
  let t = Array(a).fill(-Infinity), n = Array(a).fill(-1), o = r[e];
70
381
  for (let r = e; r < a; r += 1) {
71
382
  if (i[r] !== o) continue;
72
383
  let a = 1 + (s[r] ?? 0);
73
384
  if (e === 0) {
74
- t[r] = a - r * T;
385
+ t[r] = a - r * K;
75
386
  continue;
76
387
  }
77
388
  let l = c[e - 1] ?? [];
78
389
  for (let i = e - 1; i < r; i += 1) {
79
390
  let e = l[i] ?? -Infinity;
80
391
  if (e === -Infinity) continue;
81
- let o = i === r - 1 ? S : -Math.min((r - i - 1) * C, w), s = e + a + o;
392
+ let o = i === r - 1 ? W : -Math.min((r - i - 1) * G, ee), s = e + a + o;
82
393
  s > (t[r] ?? -Infinity) && (t[r] = s, n[r] = i);
83
394
  }
84
395
  }
@@ -94,10 +405,10 @@ function E(e, t) {
94
405
  score: u[d] ?? 0
95
406
  };
96
407
  }
97
- function D(e, t) {
408
+ function J(e, t) {
98
409
  let n = /* @__PURE__ */ new Map();
99
410
  e.forEach((e, r) => {
100
- let i = E(e.label, t);
411
+ let i = q(e.label, t);
101
412
  if (i === void 0) return;
102
413
  let a = n.get(e.group);
103
414
  a === void 0 && (a = {
@@ -128,7 +439,7 @@ function D(e, t) {
128
439
  }))
129
440
  }));
130
441
  }
131
- function O(e, t) {
442
+ function Y(e, t) {
132
443
  let n = new Set(t), r = [];
133
444
  for (let t = 0; t < e.length; t += 1) {
134
445
  let i = n.has(t), a = r[r.length - 1];
@@ -140,14 +451,14 @@ function O(e, t) {
140
451
  return r;
141
452
  }
142
453
  // src/composites/command-palette/CommandPalette.tsx
143
- var k = {
454
+ var X = {
144
455
  palette: "Commands",
145
456
  placeholder: "Type a command",
146
457
  empty: "No commands",
147
458
  noMatch: (e) => `No command matches “${e}”`,
148
459
  keyNames: {}
149
- }, A = 320, j = 360, M = 8;
150
- function N(e, t) {
460
+ }, Z = 320, Q = 360, te = 8;
461
+ function $(e, t) {
151
462
  let n = Math.max(0, Math.min(320, t.width - 16)), r = Math.max(0, Math.min(360, t.height - 16)), i = (e, t, n) => Math.min(Math.max(e, 8), Math.max(8, n - t - 8));
152
463
  return {
153
464
  left: i(e.x, n, t.width),
@@ -156,8 +467,8 @@ function N(e, t) {
156
467
  height: r
157
468
  };
158
469
  }
159
- var P = 8;
160
- function F(e) {
470
+ var ne = 8;
471
+ function re(e) {
161
472
  let t = () => ({
162
473
  width: window.innerWidth,
163
474
  height: window.innerHeight
@@ -172,50 +483,50 @@ function F(e) {
172
483
  };
173
484
  }, [e]), n;
174
485
  }
175
- function I({ onClose: e, commands: r, at: u, platform: d, labels: f, className: p }) {
486
+ function ie({ onClose: e, commands: r, at: u, platform: d, labels: f, className: p }) {
176
487
  let g = {
177
- ...k,
488
+ ...X,
178
489
  ...f
179
- }, _ = a(), v = `${_}-list`, [y, b] = l(""), x = s(() => D(r, y), [r, y]), S = s(() => x.flatMap((e) => e.items.map((e) => e.command)), [x]), C = s(() => S.filter((e) => e.disabled !== !0), [S]), [w, T] = l(void 0), [E, A] = l(y);
180
- E !== y && (A(y), T(void 0));
181
- let j = C.find((e) => e.id === w) ?? C[0], M = (e) => `${_}-option-${S.indexOf(e)}`, I = c(null), L = c(null), R = c(null), z = c(e);
490
+ }, _ = a(), v = `${_}-list`, [y, b] = l(""), x = s(() => J(r, y), [r, y]), S = s(() => x.flatMap((e) => e.items.map((e) => e.command)), [x]), C = s(() => S.filter((e) => e.disabled !== !0), [S]), [w, T] = l(void 0), [E, D] = l(y);
491
+ E !== y && (D(y), T(void 0));
492
+ let O = C.find((e) => e.id === w) ?? C[0], k = (e) => `${_}-option-${S.indexOf(e)}`, A = c(null), j = c(null), M = c(null), N = c(e);
182
493
  o(() => {
183
- z.current = e;
494
+ N.current = e;
184
495
  }), o(() => {
185
496
  let e = document.activeElement instanceof HTMLElement ? document.activeElement : null;
186
- L.current?.focus();
187
- let t = I.current;
497
+ j.current?.focus();
498
+ let t = A.current;
188
499
  return () => {
189
500
  let n = document.activeElement;
190
501
  (n === null || n === document.body || (t?.contains(n) ?? !1) || !n.isConnected) && e?.isConnected === !0 && e.focus();
191
502
  };
192
503
  }, []), i(() => {
193
- if (j === void 0) return;
194
- let e = document.getElementById(M(j));
504
+ if (O === void 0) return;
505
+ let e = document.getElementById(k(O));
195
506
  typeof e?.scrollIntoView == "function" && e.scrollIntoView({ block: "nearest" });
196
- }, [j]);
197
- let B = (e) => {
198
- e.disabled !== !0 && (z.current(), e.run());
199
- }, V = () => {
200
- let e = R.current?.querySelector("[role=\"option\"]"), t = e && e.offsetHeight > 0 ? Math.floor((R.current?.clientHeight ?? 0) / e.offsetHeight) : 0;
201
- return Math.max(1, t || P);
202
- }, H = (e) => {
507
+ }, [O]);
508
+ let P = (e) => {
509
+ e.disabled !== !0 && (N.current(), e.run());
510
+ }, F = () => {
511
+ let e = M.current?.querySelector("[role=\"option\"]"), t = e && e.offsetHeight > 0 ? Math.floor((M.current?.clientHeight ?? 0) / e.offsetHeight) : 0;
512
+ return Math.max(1, t || ne);
513
+ }, I = (e) => {
203
514
  if (e.defaultPrevented || e.nativeEvent.isComposing) return;
204
- let t = e.altKey || e.ctrlKey || e.metaKey, n = j === void 0 ? -1 : C.indexOf(j), r = C.length - 1, i = (t) => {
515
+ let t = e.altKey || e.ctrlKey || e.metaKey, n = O === void 0 ? -1 : C.indexOf(O), r = C.length - 1, i = (t) => {
205
516
  e.preventDefault();
206
517
  let n = C[Math.min(Math.max(t, 0), r)];
207
518
  n !== void 0 && T(n.id);
208
519
  };
209
520
  switch (e.key) {
210
521
  case "Escape":
211
- e.preventDefault(), e.stopPropagation(), z.current();
522
+ e.preventDefault(), e.stopPropagation(), N.current();
212
523
  return;
213
524
  case "Tab":
214
- e.preventDefault(), z.current();
525
+ e.preventDefault(), N.current();
215
526
  return;
216
527
  case "Enter":
217
528
  if (t) return;
218
- e.preventDefault(), j !== void 0 && B(j);
529
+ e.preventDefault(), O !== void 0 && P(O);
219
530
  return;
220
531
  case "ArrowDown":
221
532
  if (t) return;
@@ -227,11 +538,11 @@ function I({ onClose: e, commands: r, at: u, platform: d, labels: f, className:
227
538
  return;
228
539
  case "PageDown":
229
540
  if (t) return;
230
- i(n + V());
541
+ i(n + F());
231
542
  return;
232
543
  case "PageUp":
233
544
  if (t) return;
234
- i(n - V());
545
+ i(n - F());
235
546
  return;
236
547
  case "Home":
237
548
  if (t || e.shiftKey) return;
@@ -243,33 +554,33 @@ function I({ onClose: e, commands: r, at: u, platform: d, labels: f, className:
243
554
  return;
244
555
  default: return;
245
556
  }
246
- }, U = F(u !== void 0), W = u === void 0 ? void 0 : N(u, U), G = W !== void 0, K;
247
- return r.length === 0 ? K = g.empty : S.length === 0 && (K = g.noMatch(y.trim())), /* @__PURE__ */ t("div", {
557
+ }, L = re(u !== void 0), R = u === void 0 ? void 0 : $(u, L), z = R !== void 0, B;
558
+ return r.length === 0 ? B = g.empty : S.length === 0 && (B = g.noMatch(y.trim())), /* @__PURE__ */ t("div", {
248
559
  className: "pb-palette-layer",
249
- "data-anchored": G ? "" : void 0,
560
+ "data-anchored": z ? "" : void 0,
250
561
  onMouseDown: (e) => {
251
- e.target === e.currentTarget && z.current();
562
+ e.target === e.currentTarget && N.current();
252
563
  },
253
564
  children: /* @__PURE__ */ n("div", {
254
- ref: I,
565
+ ref: A,
255
566
  className: p === void 0 ? "pb-palette" : `pb-palette ${p}`,
256
567
  role: "dialog",
257
568
  "aria-modal": "true",
258
569
  "aria-label": g.palette,
259
- style: W === void 0 ? void 0 : {
570
+ style: R === void 0 ? void 0 : {
260
571
  position: "fixed",
261
- left: W.left,
262
- top: W.top,
263
- width: W.width,
264
- maxHeight: W.height
572
+ left: R.left,
573
+ top: R.top,
574
+ width: R.width,
575
+ maxHeight: R.height
265
576
  },
266
577
  onBlur: (e) => {
267
578
  let t = e.relatedTarget;
268
- t instanceof Node && !e.currentTarget.contains(t) && z.current();
579
+ t instanceof Node && !e.currentTarget.contains(t) && N.current();
269
580
  },
270
581
  children: [
271
582
  /* @__PURE__ */ t("input", {
272
- ref: L,
583
+ ref: j,
273
584
  className: "pb-palette-field",
274
585
  type: "text",
275
586
  role: "combobox",
@@ -277,7 +588,7 @@ function I({ onClose: e, commands: r, at: u, platform: d, labels: f, className:
277
588
  "aria-expanded": "true",
278
589
  "aria-controls": v,
279
590
  "aria-autocomplete": "list",
280
- "aria-activedescendant": j === void 0 ? void 0 : M(j),
591
+ "aria-activedescendant": O === void 0 ? void 0 : k(O),
281
592
  autoComplete: "off",
282
593
  autoCapitalize: "off",
283
594
  autoCorrect: "off",
@@ -287,10 +598,10 @@ function I({ onClose: e, commands: r, at: u, platform: d, labels: f, className:
287
598
  onChange: (e) => {
288
599
  b(e.target.value);
289
600
  },
290
- onKeyDown: H
601
+ onKeyDown: I
291
602
  }),
292
603
  /* @__PURE__ */ t("div", {
293
- ref: R,
604
+ ref: M,
294
605
  className: "pb-palette-list",
295
606
  id: v,
296
607
  role: "listbox",
@@ -308,7 +619,7 @@ function I({ onClose: e, commands: r, at: u, platform: d, labels: f, className:
308
619
  role: "presentation",
309
620
  children: e.group
310
621
  }), e.items.map(({ command: e, indices: r }) => {
311
- let i = M(e), a = e.keys === void 0 ? [] : typeof e.keys == "string" ? [e.keys] : e.keys, o = e === j;
622
+ let i = k(e), a = e.keys === void 0 ? [] : typeof e.keys == "string" ? [e.keys] : e.keys, o = e === O;
312
623
  return /* @__PURE__ */ n("div", {
313
624
  id: i,
314
625
  role: "option",
@@ -324,13 +635,13 @@ function I({ onClose: e, commands: r, at: u, platform: d, labels: f, className:
324
635
  e.disabled !== !0 && !o && T(e.id);
325
636
  },
326
637
  onClick: () => {
327
- B(e);
638
+ P(e);
328
639
  },
329
640
  children: [/* @__PURE__ */ n("span", {
330
641
  className: "pb-palette-text",
331
642
  children: [/* @__PURE__ */ t("span", {
332
643
  className: "pb-palette-label",
333
- children: O(e.label, r).map((e, n) => e.marked ? /* @__PURE__ */ t("mark", { children: e.text }, n) : e.text)
644
+ children: Y(e.label, r).map((e, n) => e.marked ? /* @__PURE__ */ t("mark", { children: e.text }, n) : e.text)
334
645
  }), e.hint !== void 0 && /* @__PURE__ */ t("span", {
335
646
  className: "pb-palette-hint",
336
647
  children: e.hint
@@ -350,27 +661,27 @@ function I({ onClose: e, commands: r, at: u, platform: d, labels: f, className:
350
661
  /* @__PURE__ */ t("p", {
351
662
  className: "pb-palette-empty",
352
663
  role: "status",
353
- children: K
664
+ children: B
354
665
  })
355
666
  ]
356
667
  })
357
668
  });
358
669
  }
359
- function L({ open: e, ...n }) {
360
- return e ? u(/* @__PURE__ */ t(I, { ...n }), document.body) : null;
670
+ function ae({ open: e, ...n }) {
671
+ return e ? u(/* @__PURE__ */ t(ie, { ...n }), document.body) : null;
361
672
  }
362
673
  // src/composites/diff-view/DiffView.tsx
363
- function R(e) {
674
+ function oe(e) {
364
675
  return e.startsWith("+++ ") || e.startsWith("--- ") ? "meta" : e.startsWith("@@") ? "hunk" : e.startsWith("+") ? "add" : e.startsWith("-") ? "del" : e.startsWith("\\") ? "note" : e === "" || e.startsWith(" ") ? "context" : "meta";
365
676
  }
366
- function z(e) {
677
+ function se(e) {
367
678
  return e.split("/").filter((e) => e !== "").at(-1) ?? e;
368
679
  }
369
- function B(e) {
680
+ function ce(e) {
370
681
  let t = e.split(/\r?\n/);
371
682
  return t.length > 0 && t.at(-1) === "" && t.pop(), t;
372
683
  }
373
- function V({ text: e, id: n, hidden: r }) {
684
+ function le({ text: e, id: n, hidden: r }) {
374
685
  return /* @__PURE__ */ t("pre", {
375
686
  className: "pb-diff-body",
376
687
  id: n,
@@ -378,22 +689,22 @@ function V({ text: e, id: n, hidden: r }) {
378
689
  tabIndex: 0,
379
690
  children: /* @__PURE__ */ t("code", {
380
691
  className: "pb-diff-code",
381
- children: B(e).map((e, n) => /* @__PURE__ */ t("span", {
692
+ children: ce(e).map((e, n) => /* @__PURE__ */ t("span", {
382
693
  className: "pb-diff-line",
383
- "data-kind": R(e),
694
+ "data-kind": oe(e),
384
695
  children: e === "" ? " " : e
385
696
  }, n))
386
697
  })
387
698
  });
388
699
  }
389
- function H({ diff: e, files: r, level: i = 3, collapsed: o, onToggle: s, className: c, ...u }) {
700
+ function ue({ diff: e, files: r, level: i = 3, collapsed: o, onToggle: s, className: c, ...u }) {
390
701
  let d = a(), [f, p] = l([]), m = o ?? f, h = `h${String(i)}`, g = (e, t) => {
391
702
  o === void 0 && p((n) => t ? n.filter((t) => t !== e) : [...n, e]), s?.(e, t);
392
703
  };
393
704
  return /* @__PURE__ */ t("div", {
394
705
  ...u,
395
706
  className: c === void 0 ? "pb-diff" : `pb-diff ${c}`,
396
- children: r === void 0 ? /* @__PURE__ */ t(V, { text: e }) : r.map((e, r) => {
707
+ children: r === void 0 ? /* @__PURE__ */ t(le, { text: e }) : r.map((e, r) => {
397
708
  let i = !m.includes(e.path), a = `${d}-${String(r)}`;
398
709
  return /* @__PURE__ */ n("div", {
399
710
  className: "pb-diff-file",
@@ -421,9 +732,9 @@ function H({ diff: e, files: r, level: i = 3, collapsed: o, onToggle: s, classNa
421
732
  stroke: "currentColor",
422
733
  strokeWidth: "2"
423
734
  })
424
- }), z(e.path)]
735
+ }), se(e.path)]
425
736
  })
426
- }), /* @__PURE__ */ t(V, {
737
+ }), /* @__PURE__ */ t(le, {
427
738
  text: e.diff,
428
739
  id: a,
429
740
  hidden: !i
@@ -433,14 +744,14 @@ function H({ diff: e, files: r, level: i = 3, collapsed: o, onToggle: s, classNa
433
744
  });
434
745
  }
435
746
  // src/composites/shortcut-sheet/ShortcutSheet.tsx
436
- var U = {
747
+ var de = {
437
748
  title: "Keyboard shortcuts",
438
749
  or: "or",
439
750
  empty: "No shortcuts",
440
751
  close: "Close",
441
752
  keyNames: {}
442
753
  };
443
- function W(e) {
754
+ function fe(e) {
444
755
  let t = /* @__PURE__ */ new Map();
445
756
  for (let n of e) {
446
757
  let e = t.get(n.group);
@@ -451,11 +762,11 @@ function W(e) {
451
762
  lines: t
452
763
  }));
453
764
  }
454
- function G({ open: e, onClose: i, shortcuts: o, children: s, platform: c, labels: l, className: u }) {
765
+ function pe({ open: e, onClose: i, shortcuts: o, children: s, platform: c, labels: l, className: u }) {
455
766
  let d = {
456
- ...U,
767
+ ...de,
457
768
  ...l
458
- }, p = a(), g = W(o);
769
+ }, p = a(), g = fe(o);
459
770
  return /* @__PURE__ */ n(f, {
460
771
  open: e,
461
772
  onClose: i,
@@ -509,7 +820,7 @@ function G({ open: e, onClose: i, shortcuts: o, children: s, platform: c, labels
509
820
  });
510
821
  }
511
822
  // src/composites/status-words/StatusWords.tsx
512
- function K({ items: e, className: n, ...r }) {
823
+ function me({ items: e, className: n, ...r }) {
513
824
  return /* @__PURE__ */ t("ul", {
514
825
  "aria-live": "polite",
515
826
  ...r,
@@ -523,12 +834,12 @@ function K({ items: e, className: n, ...r }) {
523
834
  });
524
835
  }
525
836
  // src/composites/toaster/Toaster.tsx
526
- var q = {
837
+ var he = {
527
838
  region: "Notifications",
528
839
  dismiss: "Dismiss",
529
840
  more: (e) => `and ${e} more`,
530
841
  count: (e) => `${e} times`
531
- }, J = /* @__PURE__ */ new Set([
842
+ }, ge = /* @__PURE__ */ new Set([
532
843
  "top-start",
533
844
  "top",
534
845
  "top-end",
@@ -536,12 +847,12 @@ var q = {
536
847
  "bottom",
537
848
  "bottom-end",
538
849
  "inline"
539
- ]), Y = 256;
540
- function X({ toasts: r, more: s = 0, onDismiss: u, onHold: f, placement: p = "bottom-end", labels: m, className: h, onPointerEnter: g, onPointerLeave: _, onFocus: v, onBlur: y, ...b }) {
850
+ ]), _e = 256;
851
+ function ve({ toasts: r, more: s = 0, onDismiss: u, onHold: f, placement: p = "bottom-end", labels: m, className: h, onPointerEnter: g, onPointerLeave: _, onFocus: v, onBlur: y, ...b }) {
541
852
  let x = {
542
- ...q,
853
+ ...he,
543
854
  ...m
544
- }, S = a(), C = J.has(p) ? p : "inline", w = C.startsWith("top"), T = w ? [...r].reverse() : r, E = r.length === 0 && s <= 0, D = c(/* @__PURE__ */ new Map()), O = c(0), [k, A] = l([]);
855
+ }, S = a(), C = ge.has(p) ? p : "inline", w = C.startsWith("top"), T = w ? [...r].reverse() : r, E = r.length === 0 && s <= 0, D = c(/* @__PURE__ */ new Map()), O = c(0), [k, A] = l([]);
545
856
  i(() => {
546
857
  let e = [];
547
858
  for (let t of r) {
@@ -555,7 +866,7 @@ function X({ toasts: r, more: s = 0, onDismiss: u, onHold: f, placement: p = "bo
555
866
  }));
556
867
  }
557
868
  let t = new Set(r.map((e) => e.id));
558
- if (D.current.size > Y) for (let e of D.current.keys()) t.has(e) || D.current.delete(e);
869
+ if (D.current.size > _e) for (let e of D.current.keys()) t.has(e) || D.current.delete(e);
559
870
  let n = new Set(e.map((e) => e.id));
560
871
  A((r) => {
561
872
  let i = r.filter((e) => t.has(e.id) && !n.has(e.id));
@@ -677,6 +988,6 @@ function X({ toasts: r, more: s = 0, onDismiss: u, onHold: f, placement: p = "bo
677
988
  ]
678
989
  })] });
679
990
  }
680
- export { _ as Banner, L as CommandPalette, H as DiffView, M as PALETTE_GUTTER, j as PALETTE_HEIGHT, A as PALETTE_WIDTH, G as ShortcutSheet, K as StatusWords, X as Toaster, g as defaultBannerLabels, k as defaultCommandPaletteLabels, U as defaultShortcutSheetLabels, q as defaultToasterLabels, W as groupShortcuts, O as markRuns, E as matchSubsequence, N as placePalette, D as rankCommands };
991
+ export { _ as Banner, R as CodeEditor, z as CodeText, ae as CommandPalette, ue as DiffView, te as PALETTE_GUTTER, Q as PALETTE_HEIGHT, Z as PALETTE_WIDTH, pe as ShortcutSheet, me as StatusWords, ve as Toaster, x as caretAt, D as codeRuns, g as defaultBannerLabels, N as defaultCodeEditorLabels, X as defaultCommandPaletteLabels, de as defaultShortcutSheetLabels, he as defaultToasterLabels, fe as groupShortcuts, O as gutterRows, j as loadKnobly, C as markLevel, Y as markRuns, q as matchSubsequence, S as offsetAt, $ as placePalette, J as rankCommands, y as shownText, I as tabEdit };
681
992
 
682
993
  //# sourceMappingURL=composites.js.map