@brett_lamy/ui 5.15.0 → 5.16.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.
Files changed (121) hide show
  1. package/dist/components/call-stack.d.ts +26 -0
  2. package/dist/components/call-stack.d.ts.map +1 -0
  3. package/dist/components/call-stack.js +236 -0
  4. package/dist/components/code-editor-window.d.ts +191 -0
  5. package/dist/components/code-editor-window.d.ts.map +1 -0
  6. package/dist/components/code-editor-window.js +1474 -0
  7. package/dist/components/code-editor.d.ts +213 -0
  8. package/dist/components/code-editor.d.ts.map +1 -0
  9. package/dist/components/code-editor.js +484 -0
  10. package/dist/components/debug-toolbar.d.ts +13 -0
  11. package/dist/components/debug-toolbar.d.ts.map +1 -0
  12. package/dist/components/debug-toolbar.js +85 -0
  13. package/dist/components/file-upload.d.ts +1 -1
  14. package/dist/components/file-upload.d.ts.map +1 -1
  15. package/dist/components/file-upload.js +1 -1
  16. package/dist/components/filter-input.d.ts +1 -1
  17. package/dist/components/filter-input.d.ts.map +1 -1
  18. package/dist/components/filter-input.js +1 -1
  19. package/dist/components/filter.d.ts +1 -1
  20. package/dist/components/filter.d.ts.map +1 -1
  21. package/dist/components/filter.js +1 -1
  22. package/dist/components/log-list.d.ts +95 -0
  23. package/dist/components/log-list.d.ts.map +1 -0
  24. package/dist/components/log-list.js +549 -0
  25. package/dist/components/object-tree.d.ts +30 -0
  26. package/dist/components/object-tree.d.ts.map +1 -0
  27. package/dist/components/object-tree.js +415 -0
  28. package/dist/components/object-value.d.ts +13 -0
  29. package/dist/components/object-value.d.ts.map +1 -0
  30. package/dist/components/object-value.js +69 -0
  31. package/dist/components/request-table.d.ts +78 -0
  32. package/dist/components/request-table.d.ts.map +1 -0
  33. package/dist/components/request-table.js +697 -0
  34. package/dist/components/spreadsheet.d.ts +1 -1
  35. package/dist/components/spreadsheet.d.ts.map +1 -1
  36. package/dist/components/spreadsheet.js +1 -1
  37. package/dist/components/syntax-highlighting.d.ts +45 -77
  38. package/dist/components/syntax-highlighting.d.ts.map +1 -1
  39. package/dist/components/syntax-highlighting.js +36 -275
  40. package/dist/components/terminal.d.ts +62 -0
  41. package/dist/components/terminal.d.ts.map +1 -0
  42. package/dist/components/terminal.js +172 -0
  43. package/dist/components/trace-timeline.d.ts +97 -0
  44. package/dist/components/trace-timeline.d.ts.map +1 -0
  45. package/dist/components/trace-timeline.js +850 -0
  46. package/dist/components/tree.d.ts.map +1 -1
  47. package/dist/components/tree.js +99 -91
  48. package/dist/components/video-preview.d.ts +1 -1
  49. package/dist/components/video-preview.d.ts.map +1 -1
  50. package/dist/components/video-preview.js +1 -1
  51. package/dist/components/video-timeline.d.ts +1 -1
  52. package/dist/components/video-timeline.d.ts.map +1 -1
  53. package/dist/components/video-timeline.js +1 -1
  54. package/dist/components/workspace.d.ts.map +1 -1
  55. package/dist/components/workspace.js +1 -1
  56. package/dist/index.css +1 -1
  57. package/dist/index.d.ts +47 -11
  58. package/dist/index.d.ts.map +1 -1
  59. package/dist/index.js +120 -100
  60. package/dist/lib/call-stack-model.d.ts +75 -0
  61. package/dist/lib/call-stack-model.d.ts.map +1 -0
  62. package/dist/lib/call-stack-model.js +114 -0
  63. package/dist/lib/code-document.d.ts +229 -0
  64. package/dist/lib/code-document.d.ts.map +1 -0
  65. package/dist/lib/code-document.js +727 -0
  66. package/dist/lib/code-editor-gpu.d.ts +9 -0
  67. package/dist/lib/code-editor-gpu.d.ts.map +1 -0
  68. package/dist/lib/code-editor-gpu.js +23 -0
  69. package/dist/lib/code-editor-model.d.ts +371 -0
  70. package/dist/lib/code-editor-model.d.ts.map +1 -0
  71. package/dist/lib/code-editor-model.js +1105 -0
  72. package/dist/lib/{file-upload.d.ts → file-upload-model.d.ts} +1 -1
  73. package/dist/lib/file-upload-model.d.ts.map +1 -0
  74. package/dist/lib/{file-upload.js → file-upload-model.js} +1 -1
  75. package/dist/lib/{filter.d.ts → filter-model.d.ts} +1 -1
  76. package/dist/lib/filter-model.d.ts.map +1 -0
  77. package/dist/lib/{filter.js → filter-model.js} +1 -1
  78. package/dist/lib/filter-query.d.ts +1 -1
  79. package/dist/lib/filter-query.d.ts.map +1 -1
  80. package/dist/lib/filter-query.js +1 -1
  81. package/dist/lib/log-list-model.d.ts +132 -0
  82. package/dist/lib/log-list-model.d.ts.map +1 -0
  83. package/dist/lib/log-list-model.js +214 -0
  84. package/dist/lib/log-list-window.d.ts +121 -0
  85. package/dist/lib/log-list-window.d.ts.map +1 -0
  86. package/dist/lib/log-list-window.js +245 -0
  87. package/dist/lib/object-tree-model.d.ts +162 -0
  88. package/dist/lib/object-tree-model.d.ts.map +1 -0
  89. package/dist/lib/object-tree-model.js +347 -0
  90. package/dist/lib/object-tree-value.d.ts +139 -0
  91. package/dist/lib/object-tree-value.d.ts.map +1 -0
  92. package/dist/lib/object-tree-value.js +410 -0
  93. package/dist/lib/request-table-model.d.ts +85 -0
  94. package/dist/lib/request-table-model.d.ts.map +1 -0
  95. package/dist/lib/request-table-model.js +105 -0
  96. package/dist/lib/{spreadsheet.d.ts → spreadsheet-model.d.ts} +1 -1
  97. package/dist/lib/spreadsheet-model.d.ts.map +1 -0
  98. package/dist/lib/{spreadsheet.js → spreadsheet-model.js} +1 -1
  99. package/dist/lib/syntax.d.ts +19 -7
  100. package/dist/lib/syntax.d.ts.map +1 -1
  101. package/dist/lib/syntax.js +54 -50
  102. package/dist/lib/terminal-line.d.ts +155 -0
  103. package/dist/lib/terminal-line.d.ts.map +1 -0
  104. package/dist/lib/terminal-line.js +463 -0
  105. package/dist/lib/trace-timeline-draw.d.ts +109 -0
  106. package/dist/lib/trace-timeline-draw.d.ts.map +1 -0
  107. package/dist/lib/trace-timeline-draw.js +252 -0
  108. package/dist/lib/trace-timeline-model.d.ts +324 -0
  109. package/dist/lib/trace-timeline-model.d.ts.map +1 -0
  110. package/dist/lib/trace-timeline-model.js +510 -0
  111. package/dist/lib/video-render.d.ts +1 -1
  112. package/dist/lib/video-render.d.ts.map +1 -1
  113. package/dist/lib/video-render.js +1 -1
  114. package/dist/lib/{video-timeline.d.ts → video-timeline-model.d.ts} +1 -1
  115. package/dist/lib/video-timeline-model.d.ts.map +1 -0
  116. package/dist/lib/{video-timeline.js → video-timeline-model.js} +1 -1
  117. package/package.json +5 -1
  118. package/dist/lib/file-upload.d.ts.map +0 -1
  119. package/dist/lib/filter.d.ts.map +0 -1
  120. package/dist/lib/spreadsheet.d.ts.map +0 -1
  121. package/dist/lib/video-timeline.d.ts.map +0 -1
@@ -0,0 +1,1474 @@
1
+ "use client";
2
+ import { cn as e } from "../lib/utils.js";
3
+ import { CodeLexer as t, CodeTokenStore as n, LineCache as r, LineScanner as i, alignedScroll as a, comparePositions as o, displayPieces as s, extendSelection as c, hostProducer as l, identityRowMap as u, isCollapsed as d, lexerProducer as f, lineSet as p, markersInRange as ee, movePosition as m, nextCellWindow as h, nextRowWindow as g, orderedSelection as _, originOf as te, physicalSize as ne, revealScroll as re, selectionCells as ie, selectionText as ae, toPhysicalScroll as oe, toVirtualScroll as se, visibleCells as ce, visibleRows as le, wordAt as ue, wrapRowMap as de, wrappedSpan as fe } from "../lib/code-editor-model.js";
4
+ import { caretAt as v, deleteBackwardCommand as pe, deleteForwardCommand as me, detectIndent as he, editBetween as ge, editorKeyAction as _e, indentCommand as ve, insertCommand as ye, lineEditOf as be, mapSelection as xe, moveCaret as Se, newlineCommand as Ce, redoEdit as we, rowOfPosition as Te, rowsOfCells as Ee, tabCommand as De, undoEdit as Oe } from "../lib/code-document.js";
5
+ import { PLAIN_LANGUAGES as ke, codeTokenClass as Ae } from "../lib/syntax.js";
6
+ import { createGpuCodeHighlight as je } from "../lib/code-editor-gpu.js";
7
+ import { Fragment as Me, memo as Ne, useCallback as y, useImperativeHandle as Pe, useLayoutEffect as b, useMemo as x, useReducer as Fe, useRef as S, useState as Ie, useSyncExternalStore as Le } from "react";
8
+ import { jsx as C, jsxs as Re } from "react/jsx-runtime";
9
+ import { Button as w } from "react-aria-components";
10
+ import { cva as T } from "class-variance-authority";
11
+ import { flushSync as ze } from "react-dom";
12
+ //#region src/components/code-editor-window.tsx
13
+ var Be = "0".repeat(128), E = 10, Ve = 24, He = 4096, Ue = 8192, We = 8192, Ge = 16384, Ke = 4096, qe = 256, Je = 4096, Ye = "​", Xe = 2, Ze = 300, Qe = 24, $e = 450, et = 8, tt = 450, nt = 30, rt = /* @__PURE__ */ new Set([
14
+ "ArrowLeft",
15
+ "ArrowRight",
16
+ "ArrowUp",
17
+ "ArrowDown",
18
+ "Home",
19
+ "End"
20
+ ]), D = ":is(button:not([disabled]),a[href],input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex])", it = `[data-code-editor-cell]${D},[data-code-editor-cell] ${D}`, at = T("pointer-events-none absolute inset-x-0 h-(--code-editor-line)", {
21
+ variants: { tint: {
22
+ none: "",
23
+ current: "bg-primary/15 shadow-[inset_3px_0_var(--primary)]",
24
+ info: "bg-primary/10 shadow-[inset_3px_0_color-mix(in_srgb,var(--primary)_45%,transparent)]",
25
+ success: "bg-success/15",
26
+ warning: "bg-warning/15",
27
+ danger: "bg-destructive/15",
28
+ muted: "bg-secondary"
29
+ } },
30
+ defaultVariants: { tint: "none" }
31
+ }), ot = T("box-border flex h-full shrink-0 items-center overflow-hidden", {
32
+ variants: { align: {
33
+ start: "justify-start",
34
+ center: "justify-center",
35
+ end: "justify-end"
36
+ } },
37
+ defaultVariants: { align: "center" }
38
+ }), st = "absolute top-0 z-10 flex h-full w-3.5 -translate-x-1/2 cursor-pointer items-start justify-center border-0 bg-transparent p-0 outline-none data-focus-visible:rounded-sm data-focus-visible:ring-2 data-focus-visible:ring-ring", ct = () => typeof matchMedia < "u" && matchMedia("(prefers-reduced-motion: reduce)").matches, O = (e, t, n) => Math.max(t, Math.min(n, e)), lt = {
39
+ subscribe: () => () => {},
40
+ version: () => 0
41
+ };
42
+ function ut(t) {
43
+ return t.map((t, n) => {
44
+ if (typeof t == "string") return t;
45
+ let r = { width: `calc(var(--code-editor-cell) * ${t.cells})` };
46
+ return t.rtl ? /* @__PURE__ */ C("span", {
47
+ dir: "rtl",
48
+ className: "inline-block text-center [unicode-bidi:isolate]",
49
+ style: r,
50
+ children: t.text
51
+ }, n) : /* @__PURE__ */ C("span", {
52
+ className: e("inline-block text-center", t.control && "text-tertiary-foreground"),
53
+ style: r,
54
+ children: t.text
55
+ }, n);
56
+ });
57
+ }
58
+ function dt(e, t, n, r) {
59
+ let { text: i, plain: a } = e, o = [], c = n, l = (t) => {
60
+ if (a || t >= r) return Math.min(t, r);
61
+ let n = e.offsetAt(e.cellAt(t));
62
+ return n === t ? t : e.after(n);
63
+ };
64
+ for (let n = 0; n < t.length && c < r; n++) {
65
+ let r = l(c + t[n].text.length);
66
+ if (r <= c) continue;
67
+ let u = a ? i.slice(c, r) : ut(s(e, c, r)), d = Ae(t[n]);
68
+ o.push(d ? /* @__PURE__ */ C("span", {
69
+ className: d,
70
+ children: u
71
+ }, n) : a ? u : /* @__PURE__ */ C(Me, { children: u }, n)), c = r;
72
+ }
73
+ return c < r && o.push(a ? i.slice(c, r) : ut(s(e, c, r))), o;
74
+ }
75
+ var ft = Ne(function({ metrics: e, store: t, line: n, start: r, end: i, left: a }) {
76
+ let o = t ?? lt;
77
+ if (Le(o.subscribe, () => o.version(n), () => 0), r >= i) return null;
78
+ let c = t ? t.read(n, e.text, r, i) : null;
79
+ return /* @__PURE__ */ C("span", {
80
+ "data-slot": "code-editor-text",
81
+ className: "absolute top-0 whitespace-pre",
82
+ style: { left: a },
83
+ children: c ? dt(e, c, r, i) : e.plain ? e.text.slice(r, i) : ut(s(e, r, i))
84
+ });
85
+ }), pt = Ne(function({ metrics: t, store: n, row: r, rowCount: i, line: a, lineNumber: o, top: s, start: c, end: l, left: u, selectionLeft: d, selectionWidth: f, composingLeft: p, composingWidth: ee, columnLeft: m, textClassName: h, extra: g, markers: _, onFocusLine: te, onBlurLine: ne }) {
86
+ return /* @__PURE__ */ Re("div", {
87
+ role: "listitem",
88
+ "aria-posinset": r + 1,
89
+ "aria-setsize": i,
90
+ ...g,
91
+ "data-slot": "code-editor-line",
92
+ "data-row": r,
93
+ "data-line": o,
94
+ className: e("absolute left-0 h-(--code-editor-line) w-full [contain:layout_style]", h, g?.className),
95
+ style: g?.style ? {
96
+ ...g.style,
97
+ top: s
98
+ } : { top: s },
99
+ onFocus: _ ? () => te(a) : g?.onFocus,
100
+ onBlur: _ ? () => ne(a) : g?.onBlur,
101
+ children: [
102
+ f > 0 ? /* @__PURE__ */ C("div", {
103
+ "data-slot": "code-editor-selection",
104
+ className: "absolute top-0 h-full bg-muted-foreground/25 group-focus-within/code-editor:bg-primary/25",
105
+ style: {
106
+ left: d,
107
+ width: f
108
+ }
109
+ }) : null,
110
+ /* @__PURE__ */ C(ft, {
111
+ metrics: t,
112
+ store: n,
113
+ line: a,
114
+ start: c,
115
+ end: l,
116
+ left: u
117
+ }),
118
+ ee > 0 ? /* @__PURE__ */ C("div", {
119
+ "data-slot": "code-editor-composing",
120
+ className: "absolute bottom-0.5 h-px bg-foreground",
121
+ style: {
122
+ left: p,
123
+ width: ee
124
+ }
125
+ }) : null,
126
+ m >= 0 ? /* @__PURE__ */ C("div", {
127
+ "data-slot": "code-editor-column",
128
+ className: "absolute top-0.5 bottom-0.5 w-0.5 -translate-x-1/2 rounded-full bg-primary",
129
+ style: { left: m }
130
+ }) : null,
131
+ _?.map((e, t) => /* @__PURE__ */ C(ht, { marker: e }, `${e.column}:${t}`))
132
+ ]
133
+ });
134
+ }, (e, t) => {
135
+ for (let n of Object.keys(e)) if (n !== "markers" && n !== "extra" && !Object.is(e[n], t[n])) return !1;
136
+ if (e.extra !== t.extra) {
137
+ let n = e.extra ?? {}, r = t.extra ?? {}, i = Object.keys(n);
138
+ if (i.length !== Object.keys(r).length || i.some((e) => !Object.is(n[e], r[e]))) return !1;
139
+ }
140
+ let n = e.markers, r = t.markers;
141
+ return n === r ? !0 : !n || !r || n.length !== r.length ? !1 : n.every((e, t) => e === r[t] || e.column === r[t].column && e.left === r[t].left && e.label === r[t].label && e.isActive === r[t].isActive && e.onPress === r[t].onPress && e.className === r[t].className && e.children === r[t].children && e.title === r[t].title);
142
+ }), mt = (e) => e ? { render: (t) => /* @__PURE__ */ C("button", {
143
+ ...t,
144
+ title: e
145
+ }) } : null;
146
+ function ht({ marker: t }) {
147
+ let n = t.children ?? /* @__PURE__ */ C("svg", {
148
+ "aria-hidden": "true",
149
+ viewBox: "0 0 8 5",
150
+ className: e("mt-0.5 block h-[5px] w-2 fill-current", t.isActive ? "text-primary" : "text-muted-foreground/50 group-data-hovered/marker:text-primary/70"),
151
+ children: /* @__PURE__ */ C("path", { d: "M0 0h8L4 5z" })
152
+ });
153
+ return t.onPress ? /* @__PURE__ */ C(w, {
154
+ "data-code-editor-cell": "marker",
155
+ "data-slot": "code-editor-marker",
156
+ "data-active": t.isActive || void 0,
157
+ "aria-label": t.label,
158
+ "aria-pressed": t.isActive === void 0 ? void 0 : t.isActive,
159
+ onPress: () => t.onPress?.(t),
160
+ className: e("group/marker", st, t.className),
161
+ style: { left: t.left },
162
+ ...mt(t.title),
163
+ children: n
164
+ }) : /* @__PURE__ */ C("span", {
165
+ "data-code-editor-cell": "marker",
166
+ "data-slot": "code-editor-marker",
167
+ "data-active": t.isActive || void 0,
168
+ role: "img",
169
+ "aria-label": t.label,
170
+ title: t.title,
171
+ className: e(st, "pointer-events-none", t.className),
172
+ style: { left: t.left },
173
+ children: n
174
+ });
175
+ }
176
+ function gt({ gutter: t, lineNumber: n, gutterClassName: r }) {
177
+ let i = !!t.onPress && (t.isPressable?.(n) ?? !0), a = t.render(n), o = e(ot({ align: t.align }), t.className, r), s = { width: t.width }, c = t.title?.(n);
178
+ return i ? /* @__PURE__ */ C(w, {
179
+ "data-code-editor-cell": t.id,
180
+ "data-slot": "code-editor-gutter-cell",
181
+ "data-gutter": t.id,
182
+ "aria-label": t.label?.(n) ?? `${t.id}, line ${n}`,
183
+ onPress: () => t.onPress?.(n),
184
+ className: e("cursor-pointer border-0 bg-transparent p-0 [font-family:inherit] outline-none data-focus-visible:ring-2 data-focus-visible:ring-ring data-focus-visible:ring-inset data-hovered:bg-secondary data-pressed:bg-secondary-strong", o),
185
+ style: s,
186
+ ...mt(c),
187
+ children: a
188
+ }) : /* @__PURE__ */ C("div", {
189
+ "data-code-editor-cell": t.id,
190
+ "data-slot": "code-editor-gutter-cell",
191
+ "data-gutter": t.id,
192
+ title: c,
193
+ className: o,
194
+ style: s,
195
+ children: a
196
+ });
197
+ }
198
+ var _t = Ne(function({ row: e, line: t, lineNumber: n, top: r, gutters: i, current: a, gutterClassName: o, onFocusLine: s, onBlurLine: c }) {
199
+ return /* @__PURE__ */ C("div", {
200
+ "data-slot": "code-editor-gutter-row",
201
+ "data-row": e,
202
+ "data-line": n,
203
+ "data-current": a || void 0,
204
+ className: "group/gutter absolute left-0 flex h-(--code-editor-line)",
205
+ style: { top: r },
206
+ onFocus: () => s(t),
207
+ onBlur: () => c(t),
208
+ children: i.map((e) => /* @__PURE__ */ C(gt, {
209
+ gutter: e,
210
+ lineNumber: n,
211
+ gutterClassName: o
212
+ }, e.id))
213
+ });
214
+ }), vt = () => typeof navigator < "u" && /Mac/.test(navigator.platform);
215
+ function yt(e) {
216
+ let t = e.tagName;
217
+ return t === "INPUT" || t === "TEXTAREA" || t === "SELECT" || e.isContentEditable;
218
+ }
219
+ function bt({ handleRef: s, lines: Ae, lineCount: Me, getLine: Ne, contentKey: Le, document: w, editable: T = !1, history: D, selectionStore: ot, value: st, onChange: lt, onEdit: ut, language: dt, gutters: ft, lineNumbers: mt = !0, onLineNumberPress: ht, isLineNumberPressable: gt, lineNumberLabel: bt, lineNumberTitle: xt, startLine: St = 1, highlightLines: Ct, addedLines: wt, removedLines: Tt, lineProps: Et, currentLine: Dt, currentColumn: Ot, revealCurrentLine: kt = !0, lineDecoration: At, markers: jt, scrollToLine: Mt, highlight: Nt, engine: Pt, wrap: k = !1, maxHeight: Ft, tabSize: It = 2, lineHeight: Lt = 20, maxLineLength: Rt, paddingY: zt = 0, onCopyText: Bt, onSelectionChange: Vt, onFocusChange: Ht, className: Ut, style: Wt, onKeyDown: Gt, onContextMenu: Kt, "aria-label": qt }) {
220
+ let A = S(null), Jt = S(null), Yt = S(null), Xt = S(null), Zt = S(null), Qt = S(null), j = S(null), $t = S(Ne);
221
+ $t.current = Ne;
222
+ let M = x(() => w || (Ae ? {
223
+ count: Ae.length,
224
+ get: (e) => Ae[e] ?? ""
225
+ } : {
226
+ count: Me ?? 0,
227
+ get: (e) => $t.current?.(e) ?? ""
228
+ }), [
229
+ w ?? Ae ?? (Le === void 0 ? Ne : Le),
230
+ w,
231
+ Ae,
232
+ Me
233
+ ]), N = x(() => new r(M, It), [M, It]), en = S(St);
234
+ en.current = St;
235
+ let P = y((e) => ({
236
+ line: e.line + en.current,
237
+ column: e.offset
238
+ }), []), tn = !!dt && ke.has(dt.toLowerCase()), nn = x(() => typeof Nt == "function" ? Nt : Nt === !1 || Nt === null || tn ? null : Pt === "gpu" ? je({ engine: "gpu" }) : void 0, [
239
+ Nt,
240
+ tn,
241
+ Pt
242
+ ]), rn = S(null), an = S(!1), on = nn === void 0, sn = x(() => on ? new t({
243
+ lineCount: M.count,
244
+ getLine: M.get,
245
+ onInvalidate: (e, t) => rn.current?.invalidate(e, t)
246
+ }) : null, [M, on]), cn = x(() => {
247
+ let e = sn ? f(sn) : nn ? l(nn) : null;
248
+ return e ? new n({
249
+ produce: e,
250
+ getText: (e) => N.text(e),
251
+ schedule: (e) => {
252
+ requestAnimationFrame(e);
253
+ }
254
+ }) : null;
255
+ }, [
256
+ sn,
257
+ nn,
258
+ N
259
+ ]);
260
+ rn.current = cn;
261
+ let ln = S(sn);
262
+ ln.current = sn;
263
+ let un = y(() => {
264
+ let e = A.current, t = rn.current;
265
+ e && (e.dataset.highlighter = t ? t.pending || an.current ? "pending" : on ? "lexer" : "custom" : "none");
266
+ }, [on]);
267
+ b(() => cn?.subscribe(un), [cn, un]);
268
+ let [dn, fn] = Ie({
269
+ width: 0,
270
+ height: 0
271
+ }), [F, pn] = Ie(7.8);
272
+ b(() => {
273
+ let e = A.current, t = Zt.current, n = () => {
274
+ let n = e.clientWidth, r = e.clientHeight;
275
+ fn((e) => e.width === n && e.height === r ? e : {
276
+ width: n,
277
+ height: r
278
+ });
279
+ let i = t.getBoundingClientRect().width / Be.length;
280
+ i > 0 && pn(i);
281
+ };
282
+ if (n(), typeof ResizeObserver > "u") return;
283
+ let r = new ResizeObserver(n);
284
+ return r.observe(e), r.observe(t), () => r.disconnect();
285
+ }, []);
286
+ let [, mn] = Fe((e) => e + 1, 0), I = S(0), hn = S(null), [gn, _n] = Ie(0), vn = S(void 0), yn = y((e) => {
287
+ clearTimeout(vn.current);
288
+ let t = performance.now() + e, n = () => performance.now() > t, r = ln.current, i = hn.current;
289
+ an.current = r ? r.scan(n) : !1;
290
+ let a = i ? i.reached : 0, o = i ? i.run(n) : !1;
291
+ if (i) {
292
+ let e = i.maxCells > I.current;
293
+ e && (I.current = i.maxCells), (i.cellCounts && i.reached !== a || e) && _n((e) => e + 1);
294
+ }
295
+ (an.current || o) && (vn.current = setTimeout(() => yn(4), 16)), un();
296
+ }, [un]);
297
+ b(() => (I.current = Rt ?? 0, mn(), hn.current = k || Rt === void 0 ? new i(M, It, k) : null, an.current = !!sn, yn(8), () => clearTimeout(vn.current)), [
298
+ M,
299
+ It,
300
+ k,
301
+ Rt,
302
+ sn,
303
+ yn
304
+ ]);
305
+ let bn = JSON.stringify([
306
+ Ct ?? null,
307
+ wt ?? null,
308
+ Tt ?? null
309
+ ]), xn = x(() => {
310
+ let [e, t, n] = JSON.parse(bn);
311
+ return {
312
+ marked: p(e),
313
+ added: p(t),
314
+ removed: p(n)
315
+ };
316
+ }, [bn]), Sn = xn.added.size > 0 || xn.removed.size > 0, Cn = String(Math.max(1, St + Math.max(1, M.count) - 1)).length, wn = Math.ceil(Cn * F) + 16, Tn = x(() => mt === !1 ? null : {
317
+ id: "line-number",
318
+ width: wn,
319
+ align: "end",
320
+ className: "pr-2 pl-1 text-caption text-tertiary-foreground group-data-current/gutter:text-foreground data-rac:text-muted-foreground data-hovered:text-foreground",
321
+ render: (e) => /* @__PURE__ */ C("span", {
322
+ "aria-hidden": "true",
323
+ children: e
324
+ }),
325
+ onPress: ht,
326
+ isPressable: gt,
327
+ label: bt ?? ((e) => `Line ${e}`),
328
+ title: xt
329
+ }, [
330
+ mt,
331
+ wn,
332
+ ht,
333
+ gt,
334
+ bt,
335
+ xt
336
+ ]), En = x(() => Sn ? {
337
+ id: "diff-sign",
338
+ width: Math.ceil(F * 2),
339
+ className: "text-muted-foreground",
340
+ render: (e) => /* @__PURE__ */ C("span", {
341
+ "aria-hidden": "true",
342
+ children: xn.added.has(e) ? "+" : xn.removed.has(e) ? "−" : null
343
+ })
344
+ } : null, [
345
+ Sn,
346
+ F,
347
+ xn
348
+ ]), Dn = x(() => {
349
+ let e = En ? [...ft ?? [], En] : ft ?? [];
350
+ return Tn ? mt === "start" ? [Tn, ...e] : En ? [
351
+ ...ft ?? [],
352
+ Tn,
353
+ En
354
+ ] : [...e, Tn] : e;
355
+ }, [
356
+ ft,
357
+ Tn,
358
+ mt,
359
+ En
360
+ ]), On = x(() => Dn.reduce((e, t) => e + t.width, 0), [Dn]), kn = Math.max(0, dn.width - On), An = k ? Math.max(8, Math.floor((kn - E - Ve) / F)) : 0, jn = k ? 0 : M.count, L = x(() => k && hn.current?.cellCounts ? de(hn.current.cellCounts, An) : u(M.count), [
361
+ k,
362
+ An,
363
+ M,
364
+ gn,
365
+ jn
366
+ ]), Mn = Math.min(dn.height, We), R = S({
367
+ x: 0,
368
+ y: 0
369
+ }), Nn = S(null), [z, Pn] = Ie(() => ({
370
+ rows: {
371
+ start: 0,
372
+ end: 0
373
+ },
374
+ cells: {
375
+ start: 0,
376
+ end: 0
377
+ },
378
+ originRow: 0,
379
+ originCell: 0
380
+ })), Fn = S(z);
381
+ Fn.current = z;
382
+ let In = L.rowCount, Ln = S(null), [Rn, zn] = Ie(null), Bn = [], Vn = (e) => {
383
+ let { line: t, part: n } = L.locate(e), r = N.get(t);
384
+ r.cells > I.current && (I.current = r.cells), Bn.push({
385
+ row: e,
386
+ line: t,
387
+ part: n,
388
+ metrics: r
389
+ });
390
+ }, Hn = z.rows, Un = Rn !== null && Rn < M.count ? L.rowOfLine(Rn) : null;
391
+ Un !== null && Un < Hn.start && Vn(Un);
392
+ for (let e = Hn.start; e < Math.min(Hn.end, In); e++) Vn(e);
393
+ Un !== null && Un >= Hn.end && Un < In && Vn(Un);
394
+ let Wn = k ? kn : Math.ceil(I.current * F) + E + Ve, Gn = zt, Kn = In * Lt + Gn * 2, B = {
395
+ width: dn.width,
396
+ height: Mn,
397
+ codeWidth: kn,
398
+ gutterWidth: On,
399
+ cellWidth: F,
400
+ lineHeight: Lt,
401
+ map: L,
402
+ wrap: k,
403
+ cols: An,
404
+ virtualWidth: Wn,
405
+ virtualHeight: Kn,
406
+ padY: Gn
407
+ }, V = S(B), qn = S({
408
+ x: NaN,
409
+ y: NaN
410
+ }), Jn = S(() => {}), Yn = y(() => {
411
+ let e = V.current, { x: t, y: n } = R.current, r = Fn.current, i = typeof devicePixelRatio == "number" && devicePixelRatio > 0 ? devicePixelRatio : 1, a = (e) => Math.round(e * i) / i, o = a(r.originRow * e.lineHeight + e.padY - n), s = a(r.originCell * e.cellWidth - t), c = qn.current;
412
+ (o !== c.y || s !== c.x) && (o !== c.y && Yt.current && (Yt.current.style.transform = `translate3d(0,${o}px,0)`), Xt.current && (Xt.current.style.transform = `translate3d(${s}px,${o}px,0)`), c.x = s, c.y = o, Jn.current());
413
+ }, []), Xn = y((e) => {
414
+ let t = A.current;
415
+ if (!t) return;
416
+ let n = V.current, r = se(t.scrollTop, n.virtualHeight, n.height), i = n.wrap ? 0 : se(t.scrollLeft, n.virtualWidth + n.gutterWidth, n.width);
417
+ R.current = {
418
+ x: i,
419
+ y: r
420
+ };
421
+ let a = Fn.current, o = g(a.rows, le(r - n.padY, n.height, n.lineHeight, n.map.rowCount), n.map.rowCount), s = n.wrap ? {
422
+ start: 0,
423
+ end: 0
424
+ } : h(a.cells, ce(Math.max(0, i - E), Math.min(n.codeWidth, Ge), n.cellWidth)), c = s === a.cells || s.start === a.cells.start && s.end === a.cells.end;
425
+ if (o !== a.rows || !c) {
426
+ let t = {
427
+ rows: o,
428
+ cells: c ? a.cells : s,
429
+ originRow: te(o.start, He),
430
+ originCell: c ? a.originCell : te(s.start, Ue)
431
+ };
432
+ Fn.current = t, e ? ze(() => Pn(t)) : Pn(t);
433
+ }
434
+ Yn();
435
+ }, [Yn]);
436
+ b(() => {
437
+ let e = A.current, t = () => {
438
+ Xn(!0), Nn.current?.();
439
+ };
440
+ return e.addEventListener("scroll", t, { passive: !0 }), () => e.removeEventListener("scroll", t);
441
+ }, [Xn]);
442
+ let H = S(null), U = y(() => {
443
+ let e = H.current, t = A.current;
444
+ if (!e || !t) return;
445
+ H.current = null;
446
+ let n = V.current, r = n.virtualWidth + n.gutterWidth, i = e.y === void 0 ? void 0 : oe(O(e.y, 0, Math.max(0, n.virtualHeight - n.height)), n.virtualHeight, n.height), a = e.x === void 0 ? void 0 : oe(O(e.x, 0, Math.max(0, r - n.width)), r, n.width);
447
+ e.smooth && !ct() ? t.scrollTo({
448
+ ...i === void 0 ? null : { top: i },
449
+ ...a === void 0 ? null : { left: a },
450
+ behavior: "smooth"
451
+ }) : (i !== void 0 && (t.scrollTop = i), a !== void 0 && (t.scrollLeft = a), Xn(!1));
452
+ }, [Xn]), Zn = y((e, t = {}) => {
453
+ let n = V.current;
454
+ if (!n.height || !M.count) return;
455
+ let r = O(e - en.current, 0, M.count - 1), i = N.get(r), { column: o, align: s = "center", smooth: c, reveal: l } = t, u = o == null ? null : i.cellAt(o), d = n.wrap && u !== null ? Math.floor(u / n.cols) : 0, f = n.map.rowOfLine(r) + d, p = R.current, ee = f * n.lineHeight + n.padY, m = l ? re(ee, n.lineHeight, n.height, p.y, nt) : a(ee, n.lineHeight, n.height, p.y, s), h;
456
+ if (!n.wrap && (u === null ? p.x > i.cells * n.cellWidth && (h = 0) : h = re(u * n.cellWidth + E, n.cellWidth, n.codeWidth, p.x, 24), i.cells > I.current)) {
457
+ I.current = i.cells, H.current = {
458
+ x: h,
459
+ y: m,
460
+ smooth: c
461
+ }, mn();
462
+ return;
463
+ }
464
+ h === p.x && (h = void 0), H.current = {
465
+ x: h,
466
+ y: m === p.y ? void 0 : m,
467
+ smooth: c
468
+ }, U();
469
+ }, [
470
+ M,
471
+ N,
472
+ U
473
+ ]), [W, Qn] = Ie(() => T && ot ? ot.current : null), G = S(W);
474
+ G.current = W;
475
+ let $n = S(T);
476
+ $n.current = T;
477
+ let er = S(Vt);
478
+ er.current = Vt;
479
+ let tr = S(null), nr = S(!0), K = y((e) => {
480
+ let t = e && d(e) && !$n.current ? null : e, n = G.current;
481
+ n !== t && (n && t && o(n.anchor, t.anchor) === 0 && o(n.focus, t.focus) === 0 || (G.current = t, t && ot && (ot.current = t), nr.current = !0, Qn(t), er.current?.(t ? {
482
+ anchor: P(t.anchor),
483
+ focus: P(t.focus)
484
+ } : null)));
485
+ }, [ot, P]), q = y((e) => M.get(e) ?? "", [M]), rr = S(M);
486
+ b(() => {
487
+ rr.current !== M && (rr.current = M, tr.current = null, K($n.current ? v({
488
+ line: 0,
489
+ offset: 0
490
+ }) : null));
491
+ }, [M, K]);
492
+ let J = y(() => {
493
+ if ($n.current) return;
494
+ let e = Qt.current, t = G.current;
495
+ if (!e || typeof getSelection > "u") return;
496
+ let n = getSelection();
497
+ if (!n) return;
498
+ if (!t) {
499
+ e.firstChild && n.anchorNode && e.contains(n.anchorNode) && n.removeAllRanges(), e.textContent = "";
500
+ return;
501
+ }
502
+ e.textContent = ae(t, q, Ke).text || " ";
503
+ let r = document.createRange();
504
+ r.selectNodeContents(e), n.removeAllRanges(), n.addRange(r);
505
+ }, [q]), ir = y((e, t) => {
506
+ let n = Jt.current.getBoundingClientRect(), r = V.current, { x: i, y: a } = R.current, o = O(Math.floor((t - n.top + a - r.padY) / r.lineHeight), 0, Math.max(0, r.map.rowCount - 1)), { line: s, part: c } = r.map.locate(o), l = N.get(s), u = (e - n.left + i - E) / r.cellWidth;
507
+ return {
508
+ line: s,
509
+ offset: r.wrap ? l.nearest(c * r.cols + O(u, 0, r.cols)) : l.nearest(u)
510
+ };
511
+ }, [N]), Y = S(null), ar = S(() => {}), or = S({
512
+ count: 0,
513
+ time: 0,
514
+ x: 0,
515
+ y: 0
516
+ }), X = S(null), sr = y(() => {
517
+ let e = Y.current;
518
+ e && K(c(e.base, ir(e.x, e.y), e.granularity, q, M.count));
519
+ }, [
520
+ ir,
521
+ q,
522
+ K,
523
+ M
524
+ ]);
525
+ Nn.current = sr;
526
+ let cr = y(() => {
527
+ let e = Y.current, t = Jt.current, n = A.current;
528
+ if (!e || !t || !n) return;
529
+ let r = t.getBoundingClientRect(), i = (e) => Math.min(4e3, e * e / 8 + e / 2 + 1), a = 0, o = 0;
530
+ e.y < r.top ? a = -i(r.top - e.y) : e.y > r.bottom && (a = i(e.y - r.bottom)), e.x < r.left ? o = -i(r.left - e.x) : e.x > r.right && (o = i(e.x - r.right)), (a || o) && (a && (n.scrollTop += a), o && (n.scrollLeft += o), Xn(!0), sr()), e.frame = requestAnimationFrame(cr);
531
+ }, [Xn, sr]), lr = y((e, t, n, r, i, a) => {
532
+ Y.current = {
533
+ pointerId: e,
534
+ base: r,
535
+ granularity: i,
536
+ x: t,
537
+ y: n,
538
+ frame: requestAnimationFrame(cr),
539
+ touch: a
540
+ }, Jt.current?.setPointerCapture?.(e);
541
+ }, [cr]), ur = y(() => {
542
+ let e = Y.current;
543
+ e && (cancelAnimationFrame(e.frame), Y.current = null, J(), ar.current());
544
+ }, [J]), dr = (e, t) => {
545
+ if (t === "word") {
546
+ let t = ue(q(e.line), e.offset);
547
+ return {
548
+ anchor: {
549
+ line: e.line,
550
+ offset: t.start
551
+ },
552
+ focus: {
553
+ line: e.line,
554
+ offset: t.end
555
+ }
556
+ };
557
+ }
558
+ if (t === "line") {
559
+ let t = e.line >= M.count - 1;
560
+ return {
561
+ anchor: {
562
+ line: e.line,
563
+ offset: 0
564
+ },
565
+ focus: t ? {
566
+ line: e.line,
567
+ offset: q(e.line).length
568
+ } : {
569
+ line: e.line + 1,
570
+ offset: 0
571
+ }
572
+ };
573
+ }
574
+ return {
575
+ anchor: e,
576
+ focus: e
577
+ };
578
+ }, fr = (e) => {
579
+ if (e.target.closest("[data-code-editor-cell]")) return;
580
+ if (e.pointerType === "touch") {
581
+ let { pointerId: t, clientX: n, clientY: r } = e;
582
+ X.current && clearTimeout(X.current.timer), X.current = {
583
+ pointerId: t,
584
+ x: n,
585
+ y: r,
586
+ timer: setTimeout(() => {
587
+ X.current = null, Nr();
588
+ let e = dr(ir(n, r), "word");
589
+ K(e), lr(t, n, r, e, "word", !0);
590
+ }, $e)
591
+ };
592
+ return;
593
+ }
594
+ if (e.button !== 0 || e.ctrlKey && vt()) {
595
+ let t = ir(e.clientX, e.clientY), n = G.current;
596
+ if (n) {
597
+ let { from: e, to: r } = _(n);
598
+ (o(t, e) < 0 || o(t, r) > 0) && K(T ? v(t) : null);
599
+ }
600
+ T && (Nr(), ar.current(), si(e.clientX, e.clientY));
601
+ return;
602
+ }
603
+ Nr(), T && (D?.seal(), yr.current = null, br.current = !1, Cr.current = !1, Or());
604
+ let t = performance.now(), n = or.current;
605
+ n.count = Math.abs(e.clientX - n.x) < 4 && Math.abs(e.clientY - n.y) < 4 && t - n.time < tt ? n.count % 3 + 1 : 1, n.time = t, n.x = e.clientX, n.y = e.clientY;
606
+ let r = ir(e.clientX, e.clientY), i = G.current, a = n.count === 2 ? "word" : n.count === 3 ? "line" : "char", s = e.shiftKey ? i?.anchor ?? tr.current : null;
607
+ if (s) {
608
+ let t = {
609
+ anchor: s,
610
+ focus: s
611
+ };
612
+ K(c(t, r, "char", q, M.count)), lr(e.pointerId, e.clientX, e.clientY, t, "char", !1);
613
+ return;
614
+ }
615
+ tr.current = r;
616
+ let l = dr(r, a);
617
+ K(l), lr(e.pointerId, e.clientX, e.clientY, l, a, !1);
618
+ }, pr = (e) => {
619
+ let t = X.current;
620
+ t && (Math.abs(e.clientX - t.x) > et || Math.abs(e.clientY - t.y) > et) && (clearTimeout(t.timer), X.current = null);
621
+ let n = Y.current;
622
+ !n || n.pointerId !== e.pointerId || (n.x = e.clientX, n.y = e.clientY, sr());
623
+ }, mr = (e) => {
624
+ let t = X.current;
625
+ t && (clearTimeout(t.timer), X.current = null, T ? (Nr(), D?.seal(), yr.current = null, K(v(ir(t.x, t.y)))) : K(null), J()), Y.current?.pointerId === e.pointerId && ur();
626
+ }, hr = () => {
627
+ X.current && clearTimeout(X.current.timer), X.current = null, ur();
628
+ };
629
+ b(() => {
630
+ let e = A.current, t = (e) => {
631
+ Y.current?.touch && e.cancelable && e.preventDefault();
632
+ };
633
+ return e.addEventListener("touchmove", t, { passive: !1 }), () => e.removeEventListener("touchmove", t);
634
+ }, []);
635
+ let gr = (e) => {
636
+ let t = G.current;
637
+ if (!t || d(t) || !A.current.contains(e.target) || e.target !== j.current && yt(e.target)) return;
638
+ let n = ae(t, q);
639
+ e.clipboardData.setData("text/plain", n.text), e.preventDefault(), Bt?.(n);
640
+ }, _r = y(() => {
641
+ if (!M.count) return;
642
+ let e = M.count - 1;
643
+ K({
644
+ anchor: {
645
+ line: 0,
646
+ offset: 0
647
+ },
648
+ focus: {
649
+ line: e,
650
+ offset: q(e).length
651
+ }
652
+ }), J(), ar.current();
653
+ }, [
654
+ q,
655
+ K,
656
+ M,
657
+ J
658
+ ]), vr = S(!1), yr = S(null), br = S(!1), Z = S(null), xr = S({
659
+ text: "",
660
+ selection: !1,
661
+ line: 0,
662
+ start: 0
663
+ }), Sr = S(!1), Cr = S(!1), wr = S(void 0), [Tr, Er] = Ie(!1), [Dr, Or] = Fe((e) => e + 1, 0), [, kr] = Fe((e) => e + 1, 0), Ar = S(lt);
664
+ Ar.current = lt;
665
+ let jr = S(ut);
666
+ jr.current = ut;
667
+ let Mr = S(st);
668
+ Mr.current = st;
669
+ let Nr = y(() => {
670
+ $n.current ? j.current?.focus({ preventScroll: !0 }) : A.current?.focus({ preventScroll: !0 });
671
+ }, []), Pr = y(() => {
672
+ let e = j.current, t = G.current;
673
+ if (!e || !t || Sr.current) return;
674
+ let n = V.current, { x: r, y: i } = R.current, a = Te(t.focus, N.get(t.focus.line), n.map, n.wrap ? n.cols : 0), o = O(n.gutterWidth + E + a.cell * n.cellWidth - r, 0, Math.max(0, n.width - 1)), s = O(a.row * n.lineHeight + n.padY - i, 0, Math.max(0, n.height - n.lineHeight));
675
+ e.style.transform = `translate(${o}px,${s}px)`;
676
+ }, [N]);
677
+ Jn.current = Pr;
678
+ let Fr = y(() => {
679
+ let e = j.current, t = G.current;
680
+ if (!e || !t || Z.current) return;
681
+ nr.current = !1;
682
+ let n, r, i;
683
+ if (!d(t)) n = ae(t, q, Je).text, xr.current = {
684
+ text: n,
685
+ selection: !0,
686
+ line: 0,
687
+ start: 0
688
+ }, r = 0, i = n.length;
689
+ else {
690
+ let { line: e, offset: a } = t.focus, o = q(e), s = Math.max(0, a - qe), c = Math.min(o.length, a + qe), l = (e) => e >= 56320 && e <= 57343;
691
+ s > 0 && l(o.charCodeAt(s)) && s--, c < o.length && l(o.charCodeAt(c)) && c++, n = Ye + o.slice(s, c), xr.current = {
692
+ text: n,
693
+ selection: !1,
694
+ line: e,
695
+ start: s
696
+ }, r = i = a - s + 1;
697
+ }
698
+ e.value !== n && (e.value = n), (e.selectionStart !== r || e.selectionEnd !== i) && e.setSelectionRange(r, i);
699
+ }, [q]);
700
+ ar.current = Fr;
701
+ let Ir = y(() => {
702
+ let e = G.current, t = V.current;
703
+ if (!e || !t.height) return;
704
+ let n = Te(e.focus, N.get(e.focus.line), t.map, t.wrap ? t.cols : 0), r = R.current, i = a(n.row * t.lineHeight + t.padY, t.lineHeight, t.height, r.y, "nearest", Math.min(t.lineHeight, t.height / 3)), o = t.wrap ? r.x : a(n.cell * t.cellWidth + E, t.cellWidth, t.codeWidth, r.x, "nearest", Math.min(Qe, t.codeWidth / 3));
705
+ (i !== r.y || o !== r.x) && (H.current = {
706
+ x: o === r.x ? void 0 : o,
707
+ y: i === r.y ? void 0 : i
708
+ }, U());
709
+ }, [U, N]), Q = y((e) => {
710
+ let t = be(e), n = t.fromLine === t.oldEndLine && t.fromLine === t.newEndLine, r = hn.current, a = r?.cellCounts ?? null, o = a ? a[t.fromLine] : 0, s = n ? N.peek(t.fromLine) : void 0;
711
+ if (N.edit(t), r?.edit(t), ln.current?.edit(t), rn.current?.edit(t), r?.cellCounts) {
712
+ let e = V.current, i = r.cellCounts[t.fromLine];
713
+ (!n || Ee(o, e.cols) !== Ee(i, e.cols)) && _n((e) => e + 1);
714
+ }
715
+ let c = I.current;
716
+ (s ? s.cells >= c && N.get(t.fromLine).cells < c : e.removed.length >= c / 2) && c > 0 && (clearTimeout(wr.current), wr.current = setTimeout(() => {
717
+ let e = new i(M, It, !1), t = () => {
718
+ let n = performance.now() + 4;
719
+ e.run(() => performance.now() > n) ? wr.current = setTimeout(t, 16) : e.maxCells < I.current && (I.current = e.maxCells, mn());
720
+ };
721
+ t();
722
+ }, Ze)), an.current = !!ln.current, yn(Xe), rn.current?.flushNow(), nr.current = !0, kr();
723
+ }, [
724
+ N,
725
+ yn,
726
+ M,
727
+ It
728
+ ]), Lr = y((e, t) => ({
729
+ from: P(e.from),
730
+ to: P(e.to),
731
+ newTo: P(e.newTo),
732
+ text: e.text,
733
+ removed: e.removed,
734
+ origin: t
735
+ }), [P]), Rr = y((e, t) => {
736
+ let n = Lr(e, t);
737
+ jr.current?.(n), Ar.current?.(w.getText(), n);
738
+ }, [Lr, w]), zr = y((e) => {
739
+ let t = w;
740
+ if (Z.current || e === t.getText()) return;
741
+ let n = ge(t, e);
742
+ if (!n) return;
743
+ let r = G.current ?? v({
744
+ line: 0,
745
+ offset: 0
746
+ }), i = t.replace(n);
747
+ Q(i);
748
+ let a = xe(r, i);
749
+ K(a), D?.record(i, "value", r, a), D?.seal();
750
+ }, [
751
+ Q,
752
+ D,
753
+ K,
754
+ w
755
+ ]), Br = y(({ applied: e, origin: t, before: n, after: r, parentLength: i, valueBefore: a, isUndo: o }) => {
756
+ let s = w, c = Mr.current;
757
+ if (!o && c === a && c !== s.getText()) {
758
+ let t = s.replace({
759
+ from: e.from,
760
+ to: e.newTo,
761
+ text: e.removed
762
+ });
763
+ Q(t), K(n);
764
+ return;
765
+ }
766
+ o || D?.record(e, t, n, r, i), c !== void 0 && zr(c);
767
+ }, [
768
+ zr,
769
+ Q,
770
+ D,
771
+ K,
772
+ w
773
+ ]), Vr = S(null), Hr = S(void 0), Ur = y(() => {
774
+ clearTimeout(Hr.current);
775
+ let e = Vr.current;
776
+ e && (Vr.current = null, Br(e));
777
+ }, [Br]), Wr = y((e) => {
778
+ Ur(), Vr.current = e, queueMicrotask(() => {
779
+ Vr.current === e && (Mr.current === e.valueBefore ? Hr.current = setTimeout(Ur, 0) : Ur());
780
+ });
781
+ }, [Ur]);
782
+ b(() => () => {
783
+ clearTimeout(Hr.current), Vr.current = null;
784
+ }, []);
785
+ let $ = y((e) => {
786
+ if (!e || !w) return !1;
787
+ Ur();
788
+ let t = G.current ?? v({
789
+ line: 0,
790
+ offset: 0
791
+ }), n = e.edit.from.line === e.edit.to.line ? w.get(e.edit.from.line).length : 0, r = w.replace(e.edit), i = e.after ?? v(r.newTo);
792
+ Q(r), yr.current = null, K(i), vr.current = !0, Or();
793
+ let { origin: a } = e;
794
+ return Mr.current !== void 0 && Ar.current ? (Wr({
795
+ applied: r,
796
+ origin: a,
797
+ before: t,
798
+ after: i,
799
+ parentLength: n,
800
+ valueBefore: Mr.current,
801
+ isUndo: !1
802
+ }), Rr(r, a)) : (D?.record(r, a, t, i, n), Rr(r, a)), !0;
803
+ }, [
804
+ Wr,
805
+ Q,
806
+ D,
807
+ Rr,
808
+ K,
809
+ Ur,
810
+ w
811
+ ]), Gr = y((e) => {
812
+ if (!D || !w || Z.current) return;
813
+ Ur();
814
+ let t = e ? D.redo() : D.undo();
815
+ if (!t) return;
816
+ let n = G.current ?? v({
817
+ line: 0,
818
+ offset: 0
819
+ }), r = w.replace(e ? we(t) : Oe(t));
820
+ Q(r), yr.current = null;
821
+ let i = e ? t.after : t.before;
822
+ K(i), vr.current = !0, Or();
823
+ let a = e ? "redo" : "undo";
824
+ Mr.current !== void 0 && Wr({
825
+ applied: r,
826
+ origin: a,
827
+ before: n,
828
+ after: i,
829
+ parentLength: 0,
830
+ valueBefore: Mr.current,
831
+ isUndo: !0
832
+ }), Rr(r, a);
833
+ }, [
834
+ Wr,
835
+ Q,
836
+ D,
837
+ Rr,
838
+ K,
839
+ Ur,
840
+ w
841
+ ]), Kr = y(() => ({
842
+ document: M,
843
+ metricsOf: (e) => N.get(e),
844
+ indent: he(M)
845
+ }), [N, M]), qr = () => G.current ?? v({
846
+ line: 0,
847
+ offset: 0
848
+ }), Jr = y((e, t) => {
849
+ let n = G.current ?? v({
850
+ line: 0,
851
+ offset: 0
852
+ });
853
+ return $(e ? pe(Kr(), n, t) : me(Kr(), n, t));
854
+ }, [Kr, $]), Yr = (e, t) => {
855
+ let n = qr(), r = V.current, i = {
856
+ document: M,
857
+ metricsOf: (e) => N.get(e),
858
+ map: r.map,
859
+ cols: r.wrap ? r.cols : 0,
860
+ pageRows: Math.max(1, Math.floor(r.height / r.lineHeight) - 1)
861
+ }, a;
862
+ if (!t && !d(n) && (e === "left" || e === "right")) {
863
+ let { from: t, to: r } = _(n);
864
+ a = e === "left" ? t : r, yr.current = null;
865
+ } else {
866
+ let t = e === "up" || e === "down" || e === "pageUp" || e === "pageDown", r = Se(n.focus, e, i, t ? yr.current : null);
867
+ a = r.position, yr.current = r.goal;
868
+ }
869
+ D?.seal(), K(t ? {
870
+ anchor: n.anchor,
871
+ focus: a
872
+ } : v(a)), vr.current = !0, Or();
873
+ }, Xr = (e) => {
874
+ if (Z.current || e.nativeEvent.isComposing || e.keyCode === 229) return;
875
+ Cr.current = !1;
876
+ let t = _e(e, vt()), n = br.current;
877
+ if (e.key !== "Shift" && e.key !== "Control" && e.key !== "Alt" && e.key !== "Meta" && e.key !== "Tab" && (br.current = !1), t) switch (t.type) {
878
+ case "move":
879
+ e.preventDefault(), Yr(t.move, t.extend);
880
+ break;
881
+ case "deleteBackward":
882
+ case "deleteForward":
883
+ e.preventDefault(), Jr(t.type === "deleteBackward", t.unit);
884
+ break;
885
+ case "newline":
886
+ e.preventDefault(), $(Ce(M, qr()));
887
+ break;
888
+ case "tab": {
889
+ if (n) break;
890
+ e.preventDefault();
891
+ let r = qr(), i = he(M);
892
+ d(r) && !t.outdent ? $(De(r, i, (e) => N.get(e))) : $(ve(M, r, i, t.outdent));
893
+ break;
894
+ }
895
+ case "undo":
896
+ e.preventDefault(), Gr(!1);
897
+ break;
898
+ case "redo":
899
+ e.preventDefault(), Gr(!0);
900
+ break;
901
+ case "selectAll":
902
+ e.preventDefault(), D?.seal(), _r();
903
+ break;
904
+ case "escape": {
905
+ br.current = !0;
906
+ let e = qr();
907
+ d(e) || K(v(e.focus));
908
+ break;
909
+ }
910
+ }
911
+ }, Zr = (e) => {
912
+ let t = G.current;
913
+ if (!T || e.target !== j.current || !t || d(t)) return;
914
+ let n = ae(t, q);
915
+ e.clipboardData.setData("text/plain", n.text), e.preventDefault(), Bt?.(n);
916
+ let { from: r, to: i } = _(t);
917
+ $({
918
+ edit: {
919
+ from: r,
920
+ to: i,
921
+ text: ""
922
+ },
923
+ origin: "cut"
924
+ });
925
+ }, Qr = (e) => {
926
+ if (!T || e.target !== j.current) return;
927
+ e.preventDefault();
928
+ let t = e.clipboardData.getData("text/plain");
929
+ t && $(ye(qr(), t, "paste"));
930
+ }, $r = () => {
931
+ Er(!0), Ht?.(!0), Or(), nr.current = !0, Fr();
932
+ }, ei = () => {
933
+ Er(!1), Ht?.(!1), br.current = !1, D?.seal(), ci();
934
+ }, ti = () => {
935
+ let e = qr(), { from: t, to: n } = _(e);
936
+ Z.current = {
937
+ from: t,
938
+ end: n,
939
+ original: w.slice(t, n),
940
+ before: e
941
+ }, D?.seal(), vr.current = !0, kr();
942
+ }, ni = (e) => {
943
+ let t = Z.current;
944
+ if (!t || !w) return;
945
+ let n = w.replace({
946
+ from: t.from,
947
+ to: t.end,
948
+ text: e.data
949
+ });
950
+ t.end = n.newTo, Q(n), K(v(n.newTo)), vr.current = !0, Or();
951
+ }, ri = (e) => {
952
+ let t = Z.current;
953
+ if (!t || !w) return;
954
+ Z.current = null;
955
+ let n = w.replace({
956
+ from: t.from,
957
+ to: t.end,
958
+ text: t.original
959
+ });
960
+ Q(n), K(t.before), e.data && $(ye(t.before, e.data, "composition")), nr.current = !0, Fr();
961
+ }, ii = y((e) => {
962
+ if (Z.current || e.isComposing) return;
963
+ let t = G.current ?? v({
964
+ line: 0,
965
+ offset: 0
966
+ }), n = (t, n) => {
967
+ e.preventDefault(), Jr(t, n);
968
+ };
969
+ switch (e.inputType) {
970
+ case "insertText":
971
+ e.preventDefault(), e.data && $(ye(t, e.data));
972
+ break;
973
+ case "insertLineBreak":
974
+ case "insertParagraph":
975
+ e.preventDefault(), $(Ce(M, t));
976
+ break;
977
+ case "deleteContentBackward":
978
+ n(!0, "char");
979
+ break;
980
+ case "deleteContentForward":
981
+ n(!1, "char");
982
+ break;
983
+ case "deleteWordBackward":
984
+ n(!0, "word");
985
+ break;
986
+ case "deleteWordForward":
987
+ n(!1, "word");
988
+ break;
989
+ case "deleteSoftLineBackward":
990
+ case "deleteHardLineBackward":
991
+ n(!0, "line");
992
+ break;
993
+ case "deleteSoftLineForward":
994
+ case "deleteHardLineForward":
995
+ n(!1, "line");
996
+ break;
997
+ case "historyUndo":
998
+ e.preventDefault(), Gr(!1);
999
+ break;
1000
+ case "historyRedo": e.preventDefault(), Gr(!0);
1001
+ }
1002
+ }, [
1003
+ $,
1004
+ Jr,
1005
+ M,
1006
+ Gr
1007
+ ]), ai = y(() => {
1008
+ let e = j.current;
1009
+ if (!e || Z.current) return;
1010
+ let t = xr.current, n = e.value;
1011
+ if (n === t.text) return;
1012
+ let r = G.current ?? v({
1013
+ line: 0,
1014
+ offset: 0
1015
+ });
1016
+ if (t.selection) $(ye(r, n));
1017
+ else {
1018
+ let e = t.text.slice(1), r = n.startsWith(Ye) ? n.slice(1) : n;
1019
+ if (e === r) {
1020
+ Jr(!0, "char"), nr.current = !0, Fr();
1021
+ return;
1022
+ }
1023
+ let i = 0;
1024
+ for (; i < e.length && i < r.length && e.charCodeAt(i) === r.charCodeAt(i);) i++;
1025
+ let a = 0;
1026
+ for (; a < e.length - i && a < r.length - i && e.charCodeAt(e.length - 1 - a) === r.charCodeAt(r.length - 1 - a);) a++;
1027
+ $({
1028
+ edit: {
1029
+ from: {
1030
+ line: t.line,
1031
+ offset: t.start + i
1032
+ },
1033
+ to: {
1034
+ line: t.line,
1035
+ offset: t.start + e.length - a
1036
+ },
1037
+ text: r.slice(i, r.length - a)
1038
+ },
1039
+ origin: "input"
1040
+ });
1041
+ }
1042
+ nr.current = !0, Fr();
1043
+ }, [
1044
+ $,
1045
+ Jr,
1046
+ Fr
1047
+ ]), oi = y(() => {
1048
+ let e = j.current, t = G.current;
1049
+ !e || !Cr.current || !t || !d(t) || Z.current || e.value.length > 0 && e.selectionStart === 0 && e.selectionEnd === e.value.length && _r();
1050
+ }, [_r]);
1051
+ b(() => {
1052
+ let e = j.current;
1053
+ if (e) return e.addEventListener("beforeinput", ii), e.addEventListener("input", ai), e.addEventListener("select", oi), () => {
1054
+ e.removeEventListener("beforeinput", ii), e.removeEventListener("input", ai), e.removeEventListener("select", oi);
1055
+ };
1056
+ }, [
1057
+ ii,
1058
+ ai,
1059
+ oi,
1060
+ T
1061
+ ]);
1062
+ let si = (e, t) => {
1063
+ let n = j.current, r = A.current;
1064
+ if (!n || !r) return;
1065
+ let i = r.getBoundingClientRect();
1066
+ Sr.current = !0, Cr.current = !0, n.style.pointerEvents = "auto", n.style.width = "8px", n.style.transform = `translate(${e - i.left - 4}px,${t - i.top - 4}px)`;
1067
+ }, ci = y(() => {
1068
+ let e = j.current;
1069
+ !e || !Sr.current || (Sr.current = !1, e.style.pointerEvents = "", e.style.width = "", Pr());
1070
+ }, [Pr]);
1071
+ b(() => {
1072
+ T && st !== void 0 && zr(st);
1073
+ }, [
1074
+ T,
1075
+ st,
1076
+ zr
1077
+ ]);
1078
+ let li = S(null), ui = S(null), di = y((e) => A.current.querySelectorAll(`[data-slot="code-editor-gutter-row"][data-row="${e}"],[data-slot="code-editor-line"][data-row="${e}"]`), []), fi = y((e, t, n, r) => {
1079
+ let i = V.current, o = Fn.current, s = `[data-code-editor-cell="${CSS.escape(e)}"]`, c = (e) => {
1080
+ for (let t of di(e)) {
1081
+ let e = t.querySelector(s), n = e && (e.matches(it) ? e : e.querySelector(it));
1082
+ if (n) return n;
1083
+ }
1084
+ return null;
1085
+ };
1086
+ for (let e = t + n; e >= o.rows.start && e < o.rows.end; e += n) {
1087
+ let t = c(e);
1088
+ if (t) {
1089
+ ui.current = null, t.focus({ preventScroll: !0 });
1090
+ return;
1091
+ }
1092
+ }
1093
+ let l = n > 0 ? o.rows.end : o.rows.start - 1, u = t >= o.rows.start && t < o.rows.end;
1094
+ if (r > 64 || u && (l < 0 || l >= i.map.rowCount)) {
1095
+ ui.current = null;
1096
+ return;
1097
+ }
1098
+ ui.current = {
1099
+ key: e,
1100
+ from: u ? n > 0 ? o.rows.end - 1 : o.rows.start : t,
1101
+ direction: n,
1102
+ tries: r + 1
1103
+ };
1104
+ let d = Math.max(1, o.rows.end - o.rows.start) * i.lineHeight;
1105
+ H.current = { y: u ? R.current.y + n * d : a(t * i.lineHeight + i.padY, i.lineHeight, i.height, 0, "center") }, U();
1106
+ }, [U, di]), pi = (e, t) => {
1107
+ let n = e.closest("[data-row]");
1108
+ if (!n) return !1;
1109
+ let r = Number(n.dataset.row), i = e.closest("[data-code-editor-cell]")?.dataset.codeEditorCell;
1110
+ if (!i) return !1;
1111
+ if (t === "ArrowUp" || t === "ArrowDown") return fi(i, r, t === "ArrowDown" ? 1 : -1, 0), !0;
1112
+ if (t === "ArrowLeft" || t === "ArrowRight") {
1113
+ let n = [];
1114
+ for (let e of di(r)) n.push(...e.querySelectorAll(it));
1115
+ return n[n.indexOf(e) + (t === "ArrowRight" ? 1 : -1)]?.focus({ preventScroll: !0 }), !0;
1116
+ }
1117
+ return !1;
1118
+ }, mi = (e) => {
1119
+ if (Gt?.(e), e.defaultPrevented) return;
1120
+ let t = A.current, n = e.target;
1121
+ if (n === j.current) {
1122
+ Xr(e);
1123
+ return;
1124
+ }
1125
+ if (!t.contains(n) || yt(n)) return;
1126
+ let r = e.metaKey || e.ctrlKey;
1127
+ if (r && !e.altKey && e.key.toLowerCase() === "a") e.preventDefault(), _r();
1128
+ else if (r && !e.altKey && e.key.toLowerCase() === "c") J();
1129
+ else if (e.key === "Escape" && G.current) K(null), J();
1130
+ else if (n !== t && !r && !e.altKey && n.matches(it) && pi(n, e.key)) e.preventDefault();
1131
+ else if (n === t && e.shiftKey && !r && !e.altKey && rt.has(e.key) && M.count) {
1132
+ e.preventDefault();
1133
+ let t = V.current, n = G.current, r = n?.focus ?? tr.current ?? {
1134
+ line: t.map.locate(Math.floor(R.current.y / t.lineHeight)).line,
1135
+ offset: 0
1136
+ }, i = n?.anchor ?? r, a = m(r, e.key, (e) => N.get(e), M.count);
1137
+ tr.current = i, K({
1138
+ anchor: i,
1139
+ focus: a
1140
+ }), J(), Zn(a.line + 1, {
1141
+ column: a.offset,
1142
+ reveal: !0
1143
+ });
1144
+ }
1145
+ }, hi = (e) => {
1146
+ Kt?.(e), Sr.current && setTimeout(ci, 0), G.current && A.current.contains(e.target) && J(), Y.current?.touch ? e.preventDefault() : Y.current && ur();
1147
+ }, gi = S(void 0), _i = y((e) => {
1148
+ clearTimeout(gi.current), Ln.current = e, zn(e);
1149
+ let t = V.current, n = t.map.rowOfLine(e) * t.lineHeight + t.padY, { y: r } = R.current, i = document.activeElement;
1150
+ (n < r || n + t.lineHeight > r + t.height) && i?.matches(":focus-visible") && A.current.contains(i) && i !== j.current && (H.current = { y: a(n, t.lineHeight, t.height, r, "nearest", t.lineHeight) }, U());
1151
+ let o = i;
1152
+ o && o !== li.current && A.current.contains(o) && o.matches(it) && (li.current?.setAttribute("tabindex", "-1"), o.setAttribute("tabindex", "0"), li.current = o);
1153
+ }, [U]), vi = y((e) => {
1154
+ clearTimeout(gi.current), gi.current = setTimeout(() => {
1155
+ Ln.current === e && (Ln.current = null, zn(null));
1156
+ }, 0);
1157
+ }, []), yi = S(L);
1158
+ b(() => {
1159
+ if (yi.current !== L) {
1160
+ let e = V.current, t = Math.max(0, Math.floor((R.current.y - e.padY) / e.lineHeight)), n = R.current.y - t * e.lineHeight, { line: r, part: i } = yi.current.locate(t);
1161
+ yi.current = L;
1162
+ let a = B.wrap && e.wrap && B.cols ? Math.floor(i * e.cols / B.cols) : 0, o = (L.rowOfLine(r) + a) * B.lineHeight + n;
1163
+ o !== R.current.y && (H.current = {
1164
+ y: o,
1165
+ ...H.current
1166
+ });
1167
+ }
1168
+ V.current = B, Xn(!1), H.current && U();
1169
+ let e = A.current, t = e.querySelectorAll(it), n = le(R.current.y - B.padY, B.height, B.lineHeight, B.map.rowCount), r = (e) => {
1170
+ let t = Number(e.closest("[data-row]")?.dataset.row);
1171
+ return t >= n.start && t < n.end;
1172
+ }, i = li.current;
1173
+ if (!i || !i.isConnected || document.activeElement !== i && !r(i)) {
1174
+ i = null;
1175
+ for (let e of t) if (r(e)) {
1176
+ i = e;
1177
+ break;
1178
+ }
1179
+ li.current = i;
1180
+ }
1181
+ for (let e of t) {
1182
+ let t = e === i ? "0" : "-1";
1183
+ e.getAttribute("tabindex") !== t && e.setAttribute("tabindex", t);
1184
+ }
1185
+ let a = ui.current;
1186
+ a && fi(a.key, a.from, a.direction, a.tries);
1187
+ let o = e.clientHeight;
1188
+ (o !== dn.height || e.clientWidth !== dn.width) && fn({
1189
+ width: e.clientWidth,
1190
+ height: o
1191
+ }), vr.current && (vr.current = !1, Ir()), nr.current && Fr(), Pr(), un();
1192
+ });
1193
+ let bi = S(null), xi = typeof kt == "object" ? kt : null;
1194
+ b(() => {
1195
+ if (!Mn) return;
1196
+ let e = Dt == null ? null : `${Dt}:${Ot ?? ""}`;
1197
+ e !== bi.current && (bi.current = e, Dt != null && kt !== !1 && Zn(Dt, {
1198
+ column: Ot ?? void 0,
1199
+ reveal: !0,
1200
+ smooth: xi?.smooth
1201
+ }));
1202
+ }, [
1203
+ Dt,
1204
+ Ot,
1205
+ kt,
1206
+ xi?.smooth,
1207
+ Mn,
1208
+ Zn
1209
+ ]);
1210
+ let Si = Mt == null ? null : typeof Mt == "number" ? { line: Mt } : Mt, Ci = S(null), wi = Si && `${Si.line}:${Si.column ?? ""}:${Si.align ?? ""}:${Si.smooth ?? ""}`;
1211
+ b(() => {
1212
+ Mn && wi !== Ci.current && (Ci.current = wi, Si && Zn(Si.line, Si));
1213
+ }, [
1214
+ wi,
1215
+ Mn,
1216
+ Zn
1217
+ ]), Pe(s, () => ({
1218
+ scrollToLine: (e, t) => Zn(e, t),
1219
+ getSelection: () => {
1220
+ let e = G.current;
1221
+ return e ? {
1222
+ anchor: P(e.anchor),
1223
+ focus: P(e.focus)
1224
+ } : null;
1225
+ },
1226
+ getSelectionText: () => {
1227
+ let e = G.current;
1228
+ return e ? ae(e, q).text : "";
1229
+ },
1230
+ setSelection: (e) => {
1231
+ let t = (e) => {
1232
+ let t = O(e.line - en.current, 0, Math.max(0, M.count - 1));
1233
+ return {
1234
+ line: t,
1235
+ offset: O(e.column, 0, q(t).length)
1236
+ };
1237
+ };
1238
+ D?.seal(), yr.current = null, K(e ? {
1239
+ anchor: t(e.anchor),
1240
+ focus: t(e.focus)
1241
+ } : T ? G.current && v(G.current.focus) : null), J();
1242
+ },
1243
+ selectAll: _r,
1244
+ focus: Nr,
1245
+ getValue: () => w ? w.getText() : Array.from({ length: M.count }, (e, t) => q(t)).join("\n")
1246
+ }), [
1247
+ q,
1248
+ Zn,
1249
+ K,
1250
+ _r,
1251
+ M,
1252
+ J,
1253
+ P,
1254
+ w,
1255
+ T,
1256
+ D,
1257
+ Nr
1258
+ ]), cn?.beginFrame(Bn.length ? Bn[0].line : 0, Bn.length ? Bn[Bn.length - 1].line + 1 : 0);
1259
+ let Ti = x(() => {
1260
+ if (!jt) return null;
1261
+ if (typeof jt == "function") return jt;
1262
+ let e = /* @__PURE__ */ new Map();
1263
+ for (let t of jt) {
1264
+ if (t.line === void 0) continue;
1265
+ let n = e.get(t.line);
1266
+ n ? n.push(t) : e.set(t.line, [t]);
1267
+ }
1268
+ return (t) => e.get(t);
1269
+ }, [jt]), Ei = W ? _(W) : null, Di = Z.current, Oi = Di ? {
1270
+ from: Di.from,
1271
+ to: Di.end
1272
+ } : null, ki = T && W ? W.focus.line : -1, Ai = T && Tr && W ? Te(W.focus, N.get(W.focus.line), L, k ? An : 0) : null, ji = [], Mi = [], Ni = [];
1273
+ for (let { row: t, line: n, part: r, metrics: i } of Bn) {
1274
+ let a = n + St, o = (O(t, Hn.start - 1, Hn.end) - z.originRow) * Lt, s = At?.(a) ?? null, c = Dt === a, l = s?.tint ?? (c ? "current" : null);
1275
+ (l || s?.className) && ji.push(/* @__PURE__ */ C("div", {
1276
+ "data-slot": "code-editor-band",
1277
+ "data-tint": l ?? void 0,
1278
+ className: e(at({ tint: l ?? "none" }), s?.className),
1279
+ style: { top: o }
1280
+ }, t));
1281
+ let u = xn.added.has(a) ? "add" : xn.removed.has(a) ? "del" : xn.marked.has(a) ? "highlight" : null;
1282
+ u && ji.push(/* @__PURE__ */ C("div", {
1283
+ "data-slot": "code-editor-band",
1284
+ "data-mark": u,
1285
+ className: e(at(), "bl-code-band"),
1286
+ style: { top: o }
1287
+ }, `${t}:mark`)), r === 0 && Dn.length && Mi.push(/* @__PURE__ */ C(_t, {
1288
+ row: t,
1289
+ line: n,
1290
+ lineNumber: a,
1291
+ top: o,
1292
+ gutters: Dn,
1293
+ current: c || Tr && n === ki,
1294
+ gutterClassName: s?.gutterClassName,
1295
+ onFocusLine: _i,
1296
+ onBlurLine: vi
1297
+ }, t));
1298
+ let d, f;
1299
+ k ? (d = fe(i, r, An), f = r * An) : (d = {
1300
+ start: i.offsetAt(z.cells.start),
1301
+ end: i.offsetAt(z.cells.end)
1302
+ }, f = z.originCell);
1303
+ let p = d.end >= i.text.length, m = k ? (r + 1) * An + +!!p : z.cells.end, h = E + (i.cellAt(d.start) - f) * F, g = 0, _ = 0;
1304
+ if (Ei) {
1305
+ let e = ie(Ei, n, i);
1306
+ if (e) {
1307
+ let t = Math.max(e.start, k ? f : z.cells.start), n = Math.min(e.end, m);
1308
+ n > t && (g = E + (t - f) * F, _ = (n - t) * F);
1309
+ }
1310
+ }
1311
+ let te = 0, ne = 0;
1312
+ if (Oi) {
1313
+ let e = ie(Oi, n, i);
1314
+ if (e) {
1315
+ let t = Math.max(e.start, k ? f : z.cells.start), n = Math.min(e.end, m);
1316
+ n > t && (te = E + (t - f) * F, ne = (n - t) * F);
1317
+ }
1318
+ }
1319
+ let re = -1;
1320
+ if (c && Ot != null) {
1321
+ let e = i.cellAt(Ot);
1322
+ e >= (k ? f : z.cells.start) && e < m && (re = E + (e - f) * F);
1323
+ }
1324
+ let ae = null, oe = Ti?.(a);
1325
+ if (oe?.length) {
1326
+ let e = ee(oe, d.start, p ? Infinity : d.end);
1327
+ e.length && (ae = e.map((e) => ({
1328
+ ...e,
1329
+ left: E + (i.cellAt(e.column) - f) * F
1330
+ })));
1331
+ }
1332
+ Ni.push(/* @__PURE__ */ C(pt, {
1333
+ metrics: i,
1334
+ store: cn,
1335
+ row: t,
1336
+ rowCount: In,
1337
+ line: n,
1338
+ lineNumber: a,
1339
+ top: o,
1340
+ start: d.start,
1341
+ end: d.end,
1342
+ left: h,
1343
+ selectionLeft: g,
1344
+ selectionWidth: _,
1345
+ composingLeft: te,
1346
+ composingWidth: ne,
1347
+ columnLeft: re,
1348
+ textClassName: s?.textClassName,
1349
+ extra: r === 0 ? Et?.(a) : void 0,
1350
+ markers: ae,
1351
+ onFocusLine: _i,
1352
+ onBlurLine: vi
1353
+ }, t));
1354
+ }
1355
+ let Pi = qt ?? "Source code", Fi = null;
1356
+ if (Ai && Ai.row >= Hn.start && Ai.row < Math.min(Hn.end, In)) {
1357
+ let e = k ? Ai.cell : Ai.cell - z.originCell;
1358
+ Fi = /* @__PURE__ */ C("div", {
1359
+ "data-slot": "code-editor-caret",
1360
+ "aria-hidden": "true",
1361
+ className: "bl-code-caret pointer-events-none absolute w-0.5 bg-(--bl-syntax-caret,var(--foreground))",
1362
+ style: {
1363
+ top: (Ai.row - z.originRow) * Lt,
1364
+ height: Lt,
1365
+ left: E + e * F - 1
1366
+ }
1367
+ }, Dr);
1368
+ }
1369
+ let Ii = ne(Wn + On), Li = ne(Kn);
1370
+ return /* @__PURE__ */ C("div", {
1371
+ ref: A,
1372
+ "data-slot": "code-editor-content",
1373
+ "data-wrap": k || void 0,
1374
+ "data-editable": T || void 0,
1375
+ dir: "ltr",
1376
+ role: T ? void 0 : "region",
1377
+ "aria-label": T ? void 0 : Pi,
1378
+ tabIndex: T ? void 0 : 0,
1379
+ onKeyDown: mi,
1380
+ onCopy: gr,
1381
+ onCut: Zr,
1382
+ onPaste: Qr,
1383
+ onContextMenu: hi,
1384
+ className: e("group/code-editor bl-scroll relative min-h-0 w-full min-w-0 flex-1 overflow-auto overscroll-x-contain leading-(--code-editor-line) outline-none [contain:inline-size] [font-kerning:none] [font-variant-ligatures:none] [overflow-anchor:none] focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring", k && "overflow-x-hidden", Ut),
1385
+ style: {
1386
+ "--code-editor-line": `${Lt}px`,
1387
+ "--code-editor-cell": `${F}px`,
1388
+ maxHeight: Ft ?? We,
1389
+ ...Wt
1390
+ },
1391
+ children: /* @__PURE__ */ C("div", {
1392
+ "data-slot": "code-editor-extent",
1393
+ className: "relative",
1394
+ style: {
1395
+ width: Math.max(dn.width, Ii),
1396
+ height: Li
1397
+ },
1398
+ children: /* @__PURE__ */ Re("div", {
1399
+ "data-slot": "code-editor-viewport",
1400
+ className: "sticky top-0 left-0 overflow-clip select-none [contain:strict]",
1401
+ style: {
1402
+ width: dn.width,
1403
+ height: Mn
1404
+ },
1405
+ onMouseDown: T ? (e) => {
1406
+ let t = e.target;
1407
+ !e.currentTarget.contains(t) || t === j.current || t.closest(it) || (e.preventDefault(), Nr());
1408
+ } : void 0,
1409
+ children: [
1410
+ T ? /* @__PURE__ */ C("textarea", {
1411
+ ref: j,
1412
+ "data-slot": "code-editor-input",
1413
+ role: "textbox",
1414
+ "aria-multiline": "true",
1415
+ "aria-readonly": "false",
1416
+ "aria-label": Pi,
1417
+ autoCapitalize: "off",
1418
+ autoComplete: "off",
1419
+ autoCorrect: "off",
1420
+ spellCheck: !1,
1421
+ wrap: "off",
1422
+ rows: 1,
1423
+ onFocus: $r,
1424
+ onBlur: ei,
1425
+ onCompositionStart: ti,
1426
+ onCompositionUpdate: ni,
1427
+ onCompositionEnd: ri,
1428
+ className: "pointer-events-none absolute top-0 left-0 z-20 m-0 h-(--code-editor-line) w-px resize-none overflow-hidden border-0 bg-transparent p-0 text-body whitespace-pre text-transparent caret-transparent opacity-0 outline-none select-text"
1429
+ }) : null,
1430
+ /* @__PURE__ */ C("span", {
1431
+ ref: Zt,
1432
+ "aria-hidden": "true",
1433
+ className: "invisible absolute top-0 left-0 whitespace-pre",
1434
+ children: Be
1435
+ }),
1436
+ /* @__PURE__ */ C("span", {
1437
+ ref: Qt,
1438
+ "aria-hidden": "true",
1439
+ "data-slot": "code-editor-copy-proxy",
1440
+ className: "sr-only whitespace-pre select-text"
1441
+ }),
1442
+ On > 0 ? /* @__PURE__ */ C("div", {
1443
+ className: "absolute inset-y-0 left-0 border-r border-border",
1444
+ style: { width: On }
1445
+ }) : null,
1446
+ /* @__PURE__ */ Re("div", {
1447
+ ref: Yt,
1448
+ "data-slot": "code-editor-gutter",
1449
+ className: "absolute top-0 left-0 w-full will-change-transform",
1450
+ children: [ji, Mi]
1451
+ }),
1452
+ /* @__PURE__ */ C("div", {
1453
+ ref: Jt,
1454
+ "data-slot": "code-editor-code",
1455
+ className: "absolute inset-y-0 right-0 cursor-text overflow-clip [-webkit-touch-callout:none]",
1456
+ style: { left: On },
1457
+ onPointerDown: fr,
1458
+ onPointerMove: pr,
1459
+ onPointerUp: mr,
1460
+ onPointerCancel: hr,
1461
+ children: /* @__PURE__ */ Re("div", {
1462
+ ref: Xt,
1463
+ role: "list",
1464
+ className: "absolute top-0 left-0 w-full will-change-transform [unicode-bidi:bidi-override]",
1465
+ children: [Ni, Fi]
1466
+ })
1467
+ })
1468
+ ]
1469
+ })
1470
+ })
1471
+ });
1472
+ }
1473
+ //#endregion
1474
+ export { bt as CodeEditorWindow, ot as codeEditorGutterCellVariants, at as codeEditorLineVariants };