zidane-gui 8.2.4 → 9.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/README.md +3 -2
  2. package/out/main/chunks/{history-pager-Bd5PUapJ.js → history-pager-DUFgTrih.js} +5 -56
  3. package/out/main/chunks/session-search-sql-BrNTuwjH.js +196 -0
  4. package/out/main/chunks/tool-results-sql-C0MqWcQc.js +41 -0
  5. package/out/main/chunks/transcript-sql-DbZ-a5wb.js +43 -0
  6. package/out/main/chunks/usage-sql-DiITGx8Q.js +67 -0
  7. package/out/main/history-worker.js +2 -4
  8. package/out/main/index.js +2275 -3375
  9. package/out/main/lsp-host.js +17 -4
  10. package/out/main/session-search-worker.js +20 -0
  11. package/out/main/tool-results-worker.js +17 -0
  12. package/out/main/usage-worker.js +5 -19
  13. package/out/preload/index.mjs +69 -5
  14. package/out/renderer/assets/CodeEditor-in2F3Rz-.js +12771 -0
  15. package/out/renderer/assets/ComposerEditor-DzKoxH6Z.js +68 -0
  16. package/out/renderer/assets/DiffsTab-Ceh4E5wW.js +540 -0
  17. package/out/renderer/assets/EditorWorkers-Bhv2OJRb.js +67 -0
  18. package/out/renderer/assets/FileIcon-CYgGSQ59.js +781 -0
  19. package/out/renderer/assets/FilesTab-DESQMqGK.js +11763 -0
  20. package/out/renderer/assets/core-xOIU6ifr.js +9977 -0
  21. package/out/renderer/assets/file-tabs-Cozt9Sho.js +105 -0
  22. package/out/renderer/assets/{ghostty-web-BTRdAlae.js → ghostty-web-BTHoKwMc.js} +1 -1
  23. package/out/renderer/assets/index-DkE-xvCG.js +9525 -0
  24. package/out/renderer/assets/index-DogoEzwx.js +10868 -0
  25. package/out/renderer/assets/{index-BI29HKE2.css → index-DrLLItLS.css} +2481 -2639
  26. package/out/renderer/assets/kit-BUt8oFlT.js +64699 -0
  27. package/out/renderer/assets/pierre-theme-Bj5EAt1L.js +4312 -0
  28. package/out/renderer/assets/useDetachCleanup-Bb7k1ePf.js +3138 -0
  29. package/out/renderer/assets/useFolderChanges-B4X4n6NV.js +7896 -0
  30. package/out/renderer/assets/vendor-BvslLX9q.js +20410 -0
  31. package/out/renderer/assets/vendor-D_E2rLzO.css +388 -0
  32. package/out/renderer/assets/vendor-editor-Bx3dRdBD.js +26391 -0
  33. package/out/renderer/assets/vendor-motion-BLeNAEjH.js +9376 -0
  34. package/out/renderer/assets/vendor-react-DltKc0Ts.js +14275 -0
  35. package/out/renderer/assets/vendor-shiki-ba8IDo5s.js +459 -0
  36. package/out/renderer/index.html +11 -3
  37. package/package.json +10 -4
  38. package/scripts/postinstall.mjs +2 -1
  39. package/out/main/chunks/context-77_UZfgL.js +0 -61
  40. package/out/main/chunks/usage-sql-C2Tg1u44.js +0 -81
  41. package/out/renderer/assets/index-D0Yl489p.js +0 -191283
  42. /package/out/renderer/assets/{working-tree-parse.worker-BAW1QWyk.js → patch-parse.worker-BAW1QWyk.js} +0 -0
@@ -0,0 +1,3138 @@
1
+ import { r as reactExports, j as jsxRuntimeExports } from "./vendor-react-DltKc0Ts.js";
2
+ import { E as useLabels, U as Tooltip, V as IconButton } from "./kit-BUt8oFlT.js";
3
+ import { D as DEFAULT_THEMES, A as areThemesEqual, x as createHastElement, a6 as createIconElement, C as CUSTOM_HEADER_SLOT_ID, H as HEADER_PREFIX_SLOT_ID, a5 as createTextNodeElement, F as HEADER_FILENAME_SUFFIX_SLOT_ID, G as HEADER_METADATA_SLOT_ID, q as getThemes, an as UNSAFE_CSS_ATTRIBUTE, ao as DIFFS_SCROLLBAR_MEASURE_ATTRIBUTE, ap as DIFFS_SCROLLBAR_GUTTER_MEASURED_PROPERTY, aq as THEME_CSS_ATTRIBUTE, O as DIFFS_TAG_NAME } from "./pierre-theme-Bj5EAt1L.js";
4
+ import { t as toHtml } from "./index-DogoEzwx.js";
5
+ function FindBar({ find, label, className, style }) {
6
+ const labels = useLabels();
7
+ const input = reactExports.useRef(null);
8
+ reactExports.useEffect(() => {
9
+ if (find.open) input.current?.select();
10
+ }, [find.open, find.asked]);
11
+ if (!find.open) return null;
12
+ const onKeyDown = (e) => {
13
+ if (e.key === "Enter") {
14
+ e.preventDefault();
15
+ find.step(e.shiftKey ? -1 : 1);
16
+ } else if (e.key === "Escape") {
17
+ e.preventDefault();
18
+ e.stopPropagation();
19
+ find.close();
20
+ } else if (e.key.toLowerCase() === "f" && (e.metaKey || e.ctrlKey) && !e.shiftKey && !e.altKey) {
21
+ e.preventDefault();
22
+ input.current?.select();
23
+ }
24
+ };
25
+ const count = find.query === "" ? null : find.total === 0 ? find.searching ? "" : labels.findNoResults : `${find.index + 1}/${find.total}${find.capped ? "+" : ""}`;
26
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs(
27
+ "div",
28
+ {
29
+ role: "search",
30
+ "aria-label": label,
31
+ className: ["zg-float absolute top-2 right-3 z-30 flex items-center gap-1 p-1 max-w-[calc(100%-24px)]", className].filter(Boolean).join(" "),
32
+ style,
33
+ children: [
34
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("label", { className: "zg-well min-w-0 flex-1 flex items-center gap-1.5 h-7 pl-2 pr-1 cursor-text", children: [
35
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "i-ph-magnifying-glass text-sm text-[var(--zg-text-muted)] shrink-0", "aria-hidden": true }),
36
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
37
+ "input",
38
+ {
39
+ ref: input,
40
+ type: "text",
41
+ value: find.query,
42
+ onChange: (e) => find.setQuery(e.target.value),
43
+ onKeyDown,
44
+ placeholder: label,
45
+ "aria-label": label,
46
+ spellCheck: false,
47
+ className: "w-40 min-w-0 flex-1 bg-transparent border-0 outline-none p-0 text-zg-ui text-[var(--zg-text)] placeholder:text-[var(--zg-text-muted)]"
48
+ }
49
+ ),
50
+ count !== null && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "zg-meta shrink-0 select-none tabular-nums", "aria-live": "polite", children: count }),
51
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Tooltip, { label: labels.findMatchCase, portal: true, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
52
+ "button",
53
+ {
54
+ type: "button",
55
+ "aria-pressed": find.caseSensitive,
56
+ "aria-label": labels.findMatchCase,
57
+ onClick: () => {
58
+ find.toggleCase();
59
+ input.current?.focus();
60
+ },
61
+ className: `zg-press-subtle shrink-0 h-5 px-1 rounded-zg-sm border-0 cursor-pointer text-zg-meta font-medium ${find.caseSensitive ? "before:bg-[var(--zg-row-active)] text-[var(--zg-text)]" : "bg-transparent text-[var(--zg-text-muted)] hover:before:bg-[var(--zg-row-hover)]"}`,
62
+ children: "Aa"
63
+ }
64
+ ) })
65
+ ] }),
66
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
67
+ IconButton,
68
+ {
69
+ icon: "i-ph-caret-up",
70
+ label: labels.findPrevious,
71
+ title: labels.findPreviousHint,
72
+ size: "sm",
73
+ disabled: find.total === 0,
74
+ onClick: () => find.step(-1)
75
+ }
76
+ ),
77
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
78
+ IconButton,
79
+ {
80
+ icon: "i-ph-caret-down",
81
+ label: labels.findNext,
82
+ title: labels.findNextHint,
83
+ size: "sm",
84
+ disabled: find.total === 0,
85
+ onClick: () => find.step(1)
86
+ }
87
+ ),
88
+ /* @__PURE__ */ jsxRuntimeExports.jsx(IconButton, { icon: "i-ph-x", label: labels.findClose, title: labels.findCloseHint, size: "sm", onClick: find.close })
89
+ ]
90
+ }
91
+ );
92
+ }
93
+ const MAX_FIND_MATCHES = 5e3;
94
+ function matchesIn(text, query, opts) {
95
+ if (!query) return [];
96
+ const hay = opts.caseSensitive ? text : text.toLowerCase();
97
+ const needle = opts.caseSensitive ? query : query.toLowerCase();
98
+ const out = [];
99
+ for (let at = hay.indexOf(needle); at !== -1; at = hay.indexOf(needle, at + needle.length)) {
100
+ out.push({ start: at, end: at + needle.length });
101
+ }
102
+ return out;
103
+ }
104
+ function fileLines(contents) {
105
+ return contents.split("\n").map((text, i) => ({ side: "new", line: i + 1, text: text.replace(/\r$/, "") }));
106
+ }
107
+ function diffLines(diff) {
108
+ const out = [];
109
+ const strip = (s) => (s ?? "").replace(/\r?\n$/, "");
110
+ for (const hunk of diff.hunks) {
111
+ let oldLine = hunk.deletionStart;
112
+ let newLine = hunk.additionStart;
113
+ for (const block of hunk.hunkContent) {
114
+ if (block.type === "context") {
115
+ for (let i = 0; i < block.lines; i++) {
116
+ out.push({ side: "new", line: newLine++, text: strip(diff.additionLines[block.additionLineIndex + i]) });
117
+ oldLine++;
118
+ }
119
+ } else {
120
+ for (let i = 0; i < block.deletions; i++) {
121
+ out.push({ side: "old", line: oldLine++, text: strip(diff.deletionLines[block.deletionLineIndex + i]) });
122
+ }
123
+ for (let i = 0; i < block.additions; i++) {
124
+ out.push({ side: "new", line: newLine++, text: strip(diff.additionLines[block.additionLineIndex + i]) });
125
+ }
126
+ }
127
+ }
128
+ }
129
+ return out;
130
+ }
131
+ function findAll(parts, query, opts) {
132
+ const matches = [];
133
+ if (!query) return { matches, capped: false };
134
+ for (const { part, lines } of parts) {
135
+ for (const l of lines) {
136
+ for (const m of matchesIn(l.text, query, opts)) {
137
+ if (matches.length >= MAX_FIND_MATCHES) return { matches, capped: true };
138
+ matches.push({ part, side: l.side, line: l.line, start: m.start, end: m.end });
139
+ }
140
+ }
141
+ }
142
+ return { matches, capped: false };
143
+ }
144
+ const STILL_FRAMES = 6;
145
+ const MAX_MS = 2e3;
146
+ const EASE = 0.3;
147
+ function settleScroll(root, target, { offset = 0, smooth = true } = {}) {
148
+ let raf = 0;
149
+ let still = 0;
150
+ const started = performance.now();
151
+ const stop = () => {
152
+ cancelAnimationFrame(raf);
153
+ root.removeEventListener("wheel", stop);
154
+ root.removeEventListener("pointerdown", stop);
155
+ root.removeEventListener("keydown", stop);
156
+ };
157
+ root.addEventListener("wheel", stop, { passive: true });
158
+ root.addEventListener("pointerdown", stop);
159
+ root.addEventListener("keydown", stop);
160
+ const tick = () => {
161
+ const at = target();
162
+ if (!at || performance.now() - started > MAX_MS) return stop();
163
+ if (at instanceof HTMLElement && !at.isConnected) return stop();
164
+ const top = at instanceof HTMLElement ? root.scrollTop + at.getBoundingClientRect().top - root.getBoundingClientRect().top : at.top;
165
+ const max = root.scrollHeight - root.clientHeight;
166
+ const wanted = Math.max(0, Math.min(max, top - (typeof offset === "function" ? offset(root) : offset)));
167
+ const left = wanted - root.scrollTop;
168
+ if (Math.abs(left) < 1) {
169
+ if (++still >= STILL_FRAMES) return stop();
170
+ } else {
171
+ still = 0;
172
+ const step = smooth && Math.abs(left) > 2 ? left * EASE : left;
173
+ root.scrollTop += Math.abs(step) < 1 ? Math.sign(step) : step;
174
+ }
175
+ raf = requestAnimationFrame(tick);
176
+ };
177
+ raf = requestAnimationFrame(tick);
178
+ return stop;
179
+ }
180
+ const FIND_HIGHLIGHT = "zg-find";
181
+ const FIND_CURRENT = "zg-find-current";
182
+ const registry = () => (typeof CSS !== "undefined" ? CSS.highlights : void 0) ?? null;
183
+ const HighlightClass = () => globalThis.Highlight ?? null;
184
+ let owner = null;
185
+ const ROWS = "[data-line]:not([data-column-number])";
186
+ function sideOf(row) {
187
+ return row.getAttribute("data-line-type") === "change-deletion" ? "old" : "new";
188
+ }
189
+ function rangeIn(row, start, end) {
190
+ const walker = document.createTreeWalker(row, NodeFilter.SHOW_TEXT);
191
+ const range = document.createRange();
192
+ let offset = 0;
193
+ let started = false;
194
+ for (let node = walker.nextNode(); node; node = walker.nextNode()) {
195
+ const len = node.textContent?.length ?? 0;
196
+ if (!started && start < offset + len) {
197
+ range.setStart(node, start - offset);
198
+ started = true;
199
+ }
200
+ if (started && end <= offset + len) {
201
+ range.setEnd(node, end - offset);
202
+ return range;
203
+ }
204
+ offset += len;
205
+ }
206
+ return null;
207
+ }
208
+ function paintFind(who, surfaces, query, opts, current) {
209
+ const reg = registry();
210
+ const Highlight = HighlightClass();
211
+ if (!reg || !Highlight) return null;
212
+ owner = who;
213
+ const all = [];
214
+ let currentRange = null;
215
+ let currentRow = null;
216
+ for (const { part, root } of surfaces) {
217
+ for (const row of root.querySelectorAll(ROWS)) {
218
+ const text = row.textContent ?? "";
219
+ const found = matchesIn(text, query, opts);
220
+ if (found.length === 0) continue;
221
+ const line = Number(row.getAttribute("data-line"));
222
+ const side = sideOf(row);
223
+ const isCurrentRow = current !== null && current.part === part && current.side === side && current.line === line;
224
+ if (isCurrentRow) currentRow = row;
225
+ for (const m of found) {
226
+ const range = rangeIn(row, m.start, m.end);
227
+ if (!range) continue;
228
+ if (isCurrentRow && m.start === current.start) currentRange = range;
229
+ else all.push(range);
230
+ }
231
+ }
232
+ }
233
+ reg.set(FIND_HIGHLIGHT, new Highlight(...all));
234
+ if (currentRange) reg.set(FIND_CURRENT, new Highlight(currentRange));
235
+ else reg.delete(FIND_CURRENT);
236
+ return currentRow;
237
+ }
238
+ function clearFind(who) {
239
+ if (owner !== who) return;
240
+ owner = null;
241
+ const reg = registry();
242
+ reg?.delete(FIND_HIGHLIGHT);
243
+ reg?.delete(FIND_CURRENT);
244
+ }
245
+ function rowOf(surfaces, match) {
246
+ const surface = surfaces.find((s) => s.part === match.part);
247
+ if (!surface) return null;
248
+ for (const row of surface.root.querySelectorAll(
249
+ `[data-line="${match.line}"]:not([data-column-number])`
250
+ )) {
251
+ if (sideOf(row) === match.side) return row;
252
+ }
253
+ return null;
254
+ }
255
+ const QUERY_DEBOUNCE_MS = 80;
256
+ const LAND_AT = 0.35;
257
+ function useFind({ parts, version, surfaces, scroller, fallback, smooth }) {
258
+ const [open, setOpen] = reactExports.useState(false);
259
+ const [asked, setAsked] = reactExports.useState(0);
260
+ const show = reactExports.useCallback(() => {
261
+ setOpen(true);
262
+ setAsked((n) => n + 1);
263
+ }, []);
264
+ const [query, setQuery] = reactExports.useState("");
265
+ const [needle, setNeedle] = reactExports.useState("");
266
+ const [opts, setOpts] = reactExports.useState({ caseSensitive: false });
267
+ const [index, setIndex] = reactExports.useState(0);
268
+ const latest = reactExports.useRef({ parts, surfaces, scroller, fallback });
269
+ latest.current = { parts, surfaces, scroller, fallback };
270
+ reactExports.useEffect(() => {
271
+ const t = window.setTimeout(() => setNeedle(query), QUERY_DEBOUNCE_MS);
272
+ return () => window.clearTimeout(t);
273
+ }, [query]);
274
+ const { matches, capped } = reactExports.useMemo(
275
+ () => open && needle ? findAll(latest.current.parts(), needle, opts) : { matches: [], capped: false },
276
+ // eslint-disable-next-line react-hooks/exhaustive-deps -- `version` stands for `parts`
277
+ [open, needle, opts, version]
278
+ );
279
+ const jump = reactExports.useRef(null);
280
+ const [jumps, setJumps] = reactExports.useState(0);
281
+ const searched = reactExports.useRef("");
282
+ reactExports.useEffect(() => {
283
+ const want = jump.current;
284
+ jump.current = null;
285
+ const key = `${needle}\0${opts.caseSensitive}`;
286
+ const fresh = key !== searched.current;
287
+ searched.current = key;
288
+ if (want) {
289
+ const at = matches.findIndex(
290
+ (m) => m.part === want.part && m.side === want.side && m.line === want.line && m.start === want.start
291
+ );
292
+ setIndex(Math.max(0, at));
293
+ } else if (fresh) {
294
+ setIndex(0);
295
+ }
296
+ }, [matches, jumps]);
297
+ const current = matches[Math.min(index, matches.length - 1)] ?? null;
298
+ const me = reactExports.useRef({});
299
+ const frame = reactExports.useRef(0);
300
+ const paint = reactExports.useCallback(() => {
301
+ cancelAnimationFrame(frame.current);
302
+ frame.current = requestAnimationFrame(() => {
303
+ if (!open || !needle) return clearFind(me.current);
304
+ paintFind(me.current, latest.current.surfaces(), needle, opts, current);
305
+ });
306
+ }, [open, needle, opts, current]);
307
+ reactExports.useEffect(() => {
308
+ paint();
309
+ }, [paint]);
310
+ reactExports.useEffect(() => () => clearFind(me.current), []);
311
+ reactExports.useEffect(() => {
312
+ if (!open) return;
313
+ const root = latest.current.scroller();
314
+ const watched = /* @__PURE__ */ new WeakSet();
315
+ const observer = new MutationObserver(() => {
316
+ watch();
317
+ paint();
318
+ });
319
+ const watch = () => {
320
+ for (const s of latest.current.surfaces()) {
321
+ if (watched.has(s.root)) continue;
322
+ watched.add(s.root);
323
+ observer.observe(s.root, { childList: true, subtree: true, characterData: true });
324
+ }
325
+ };
326
+ watch();
327
+ const onScroll = () => {
328
+ watch();
329
+ paint();
330
+ };
331
+ root?.addEventListener("scroll", onScroll, { passive: true });
332
+ return () => {
333
+ observer.disconnect();
334
+ root?.removeEventListener("scroll", onScroll);
335
+ };
336
+ }, [open, paint]);
337
+ const stop = reactExports.useRef(null);
338
+ const currentRef = reactExports.useRef(current);
339
+ reactExports.useLayoutEffect(() => {
340
+ currentRef.current = current;
341
+ });
342
+ const currentKey = current ? `${current.part}\0${current.side}\0${current.line}\0${current.start}` : "";
343
+ reactExports.useEffect(() => {
344
+ stop.current?.();
345
+ const root = latest.current.scroller();
346
+ const target = currentRef.current;
347
+ if (!open || !target || !root) return;
348
+ stop.current = settleScroll(
349
+ root,
350
+ () => rowOf(latest.current.surfaces(), target) ?? latest.current.fallback(target, root),
351
+ { offset: (r) => r.clientHeight * LAND_AT, smooth }
352
+ );
353
+ return () => stop.current?.();
354
+ }, [open, currentKey, jumps, smooth]);
355
+ const step = reactExports.useCallback(
356
+ (direction) => {
357
+ if (matches.length === 0) return;
358
+ setIndex((i) => (i + direction + matches.length) % matches.length);
359
+ },
360
+ [matches.length]
361
+ );
362
+ const jumpTo = reactExports.useCallback((q, o, at) => {
363
+ jump.current = at;
364
+ setJumps((n) => n + 1);
365
+ setQuery(q);
366
+ setNeedle(q);
367
+ setOpts(o);
368
+ setOpen(true);
369
+ }, []);
370
+ const close = reactExports.useCallback(() => {
371
+ setOpen(false);
372
+ clearFind(me.current);
373
+ }, []);
374
+ return {
375
+ open,
376
+ asked,
377
+ show,
378
+ query,
379
+ setQuery,
380
+ caseSensitive: opts.caseSensitive,
381
+ toggleCase: () => setOpts((o) => ({ ...o, caseSensitive: !o.caseSensitive })),
382
+ index: current ? Math.min(index, matches.length - 1) : -1,
383
+ total: matches.length,
384
+ capped,
385
+ searching: query !== needle,
386
+ step,
387
+ jumpTo,
388
+ close
389
+ };
390
+ }
391
+ const callbacks = /* @__PURE__ */ new Set();
392
+ let frameId = null;
393
+ function queueRender(callback) {
394
+ callbacks.add(callback);
395
+ frameId ??= requestAnimationFrame(render);
396
+ }
397
+ function dequeueRender(callback) {
398
+ if (callbacks.delete(callback) && callbacks.size === 0 && frameId != null) {
399
+ cancelAnimationFrame(frameId);
400
+ frameId = null;
401
+ }
402
+ }
403
+ function render(time) {
404
+ const toIterate = new Set(callbacks);
405
+ callbacks.clear();
406
+ for (const callback of toIterate) try {
407
+ callback(time);
408
+ } catch (error) {
409
+ console.error(error);
410
+ }
411
+ if (callbacks.size > 0) frameId = requestAnimationFrame(render);
412
+ else frameId = null;
413
+ }
414
+ function areObjectsEqual(objA, objB, omitKeys) {
415
+ if (objA === objB || objA == null || objB == null) return objA === objB;
416
+ const omitSet = new Set(omitKeys);
417
+ const keysA = Object.keys(objA);
418
+ const keysBSet = new Set(Object.keys(objB));
419
+ for (const key of keysA) {
420
+ keysBSet.delete(key);
421
+ if (omitSet.has(key)) continue;
422
+ if (!(key in objB) || objA[key] !== objB[key]) return false;
423
+ }
424
+ for (const key of Array.from(keysBSet)) if (!omitSet.has(key)) return false;
425
+ return true;
426
+ }
427
+ function areOptionsEqual(optionsA, optionsB) {
428
+ const themeA = optionsA?.theme ?? DEFAULT_THEMES;
429
+ const themeB = optionsB?.theme ?? DEFAULT_THEMES;
430
+ const diffOptsA = getParseDiffOptions(optionsA);
431
+ const diffOptsB = getParseDiffOptions(optionsB);
432
+ return areThemesEqual(themeA, themeB) && areObjectsEqual(optionsA, optionsB, ["theme", "parseDiffOptions"]) && areObjectsEqual(diffOptsA, diffOptsB);
433
+ }
434
+ function getParseDiffOptions(options) {
435
+ if (options != null && "parseDiffOptions" in options) return options.parseDiffOptions;
436
+ }
437
+ function areSelectionsEqual(selectionA, selectionB) {
438
+ return selectionA?.start === selectionB?.start && selectionA?.end === selectionB?.end && selectionA?.side === selectionB?.side && selectionA?.endSide === selectionB?.endSide;
439
+ }
440
+ function createWindowFromScrollPosition({ scrollTop, scrollHeight, height, fitPerfectly = false, fitPerfectlyOverscroll = 0, overscrollSize }) {
441
+ const windowHeight = height + overscrollSize * 2;
442
+ const effectiveHeight = fitPerfectly ? height + fitPerfectlyOverscroll * 2 : windowHeight;
443
+ scrollHeight = Math.max(scrollHeight, effectiveHeight);
444
+ if (windowHeight >= scrollHeight || fitPerfectly) {
445
+ const top2 = Math.max(scrollTop - fitPerfectlyOverscroll, 0);
446
+ const bottom2 = Math.min(scrollTop + effectiveHeight, scrollHeight);
447
+ return {
448
+ top: top2,
449
+ bottom: Math.max(bottom2, top2)
450
+ };
451
+ }
452
+ let top = scrollTop + height / 2 - windowHeight / 2;
453
+ let bottom = top + windowHeight;
454
+ if (top < 0) top = 0;
455
+ if (bottom > scrollHeight) bottom = scrollHeight;
456
+ top = Math.floor(Math.max(top, 0));
457
+ return {
458
+ top,
459
+ bottom: Math.ceil(Math.max(Math.min(bottom, scrollHeight), top))
460
+ };
461
+ }
462
+ function createGutterUtilityElement() {
463
+ return createHastElement({
464
+ tagName: "button",
465
+ properties: {
466
+ "data-utility-button": "",
467
+ type: "button"
468
+ },
469
+ children: [createIconElement({
470
+ name: "diffs-icon-plus",
471
+ properties: { "data-icon": "" }
472
+ })]
473
+ });
474
+ }
475
+ function areSelectionPointsEqual(a, b) {
476
+ return a.lineNumber === b.lineNumber && a.side === b.side;
477
+ }
478
+ function isGutterUtilityPath(path) {
479
+ for (const element of path) {
480
+ if (!(element instanceof HTMLElement)) continue;
481
+ if (element.hasAttribute("data-utility-button") || element.hasAttribute("data-gutter-utility-slot") || element.getAttribute("slot") === "gutter-utility-slot" || element.getAttribute("name") === "gutter-utility-slot") return true;
482
+ }
483
+ return false;
484
+ }
485
+ var InteractionManager = class {
486
+ mode;
487
+ options;
488
+ hoveredLine;
489
+ hoveredToken;
490
+ pre;
491
+ gutterUtilityLine;
492
+ gutterUtilityContainer;
493
+ gutterUtilityButton;
494
+ gutterUtilitySlot;
495
+ interactiveLinesAttr = false;
496
+ interactiveLineNumbersAttr = false;
497
+ hasPointerListeners = false;
498
+ hasDocumentPointerListeners = false;
499
+ selectedRange = null;
500
+ selectedRangeHighlightSide;
501
+ selectedRangeLineNumberOnly = false;
502
+ editorActiveLine = null;
503
+ editorActiveLineSide;
504
+ editorLineNumberOnly = false;
505
+ proposedSelectedRange;
506
+ renderedSelectedLinesState;
507
+ renderedEditorActiveLineState;
508
+ selectionAnchor;
509
+ pointerSession = { mode: "idle" };
510
+ constructor(mode, options) {
511
+ this.mode = mode;
512
+ this.options = options;
513
+ }
514
+ setOptions(options) {
515
+ this.options = options;
516
+ }
517
+ cleanUp() {
518
+ this.pre?.removeEventListener("click", this.handlePointerClick);
519
+ this.pre?.removeEventListener("pointerdown", this.handlePointerDown);
520
+ this.pre?.removeEventListener("pointermove", this.handlePointerMove);
521
+ this.pre?.removeEventListener("pointerleave", this.handlePointerLeave);
522
+ this.pre?.removeAttribute("data-interactive-lines");
523
+ this.pre?.removeAttribute("data-interactive-line-numbers");
524
+ this.pre = void 0;
525
+ this.gutterUtilityContainer?.remove();
526
+ this.gutterUtilityLine = void 0;
527
+ this.gutterUtilityContainer = void 0;
528
+ this.gutterUtilityButton = void 0;
529
+ this.gutterUtilitySlot = void 0;
530
+ this.clearHoveredLine();
531
+ this.clearHoveredToken();
532
+ this.detachDocumentPointerListeners();
533
+ this.clearPointerSession();
534
+ dequeueRender(this.renderSelection);
535
+ this.interactiveLinesAttr = false;
536
+ this.interactiveLineNumbersAttr = false;
537
+ this.hasPointerListeners = false;
538
+ this.setSelectionDirty();
539
+ }
540
+ setup(pre) {
541
+ this.setSelectionDirty();
542
+ const { usesCustomGutterUtility = false, enableGutterUtility = false } = this.options;
543
+ if (this.pre !== pre) {
544
+ this.cleanUp();
545
+ this.pre = pre;
546
+ }
547
+ if (enableGutterUtility) this.ensureGutterUtilityNode(usesCustomGutterUtility);
548
+ else if (this.gutterUtilityContainer != null) {
549
+ this.gutterUtilityContainer.remove();
550
+ this.gutterUtilityLine = void 0;
551
+ this.gutterUtilityContainer = void 0;
552
+ this.gutterUtilityButton = void 0;
553
+ this.gutterUtilitySlot = void 0;
554
+ if (this.pointerSession.mode === "gutterSelecting") {
555
+ this.clearPointerSession();
556
+ this.detachDocumentPointerListeners();
557
+ }
558
+ }
559
+ this.syncPointerListeners(pre);
560
+ this.updateInteractiveLineAttributes();
561
+ this.renderSelection();
562
+ this.placeUtility();
563
+ }
564
+ setSelectionDirty() {
565
+ this.renderedSelectedLinesState = void 0;
566
+ this.renderedEditorActiveLineState = void 0;
567
+ }
568
+ isSelectionDirty() {
569
+ return this.renderedSelectedLinesState === void 0 || this.renderedEditorActiveLineState === void 0;
570
+ }
571
+ setSelection(range, options) {
572
+ const isRangeChange = !(range === this.selectedRange || areSelectionsEqual(range ?? void 0, this.selectedRange ?? void 0));
573
+ const lineNumberOnly = options?.lineNumberOnly ?? false;
574
+ const isStyleChange = options?.activeLineSide !== this.selectedRangeHighlightSide || lineNumberOnly !== this.selectedRangeLineNumberOnly;
575
+ if (!this.isSelectionDirty() && !isRangeChange && !isStyleChange) return;
576
+ this.proposedSelectedRange = void 0;
577
+ this.selectedRange = range;
578
+ this.selectedRangeHighlightSide = options?.activeLineSide;
579
+ this.selectedRangeLineNumberOnly = lineNumberOnly;
580
+ this.renderSelection();
581
+ this.placeUtility();
582
+ if (isRangeChange && options?.notify !== false) this.notifySelectionCommitted(range);
583
+ }
584
+ setEditorActiveLine(lineNumber, { lineNumberOnly = false, side } = {}) {
585
+ const isLineChange = lineNumber !== this.editorActiveLine;
586
+ const isStyleChange = side !== this.editorActiveLineSide || lineNumberOnly !== this.editorLineNumberOnly;
587
+ if (!this.isSelectionDirty() && !isLineChange && !isStyleChange) return;
588
+ this.editorActiveLine = lineNumber;
589
+ this.editorActiveLineSide = side;
590
+ this.editorLineNumberOnly = lineNumberOnly;
591
+ this.renderSelection();
592
+ }
593
+ getSelection() {
594
+ return this.selectedRange;
595
+ }
596
+ getHoveredLine = () => {
597
+ const gutterUtilityLine = this.gutterUtilityLine ?? this.hoveredLine;
598
+ if (gutterUtilityLine != null) {
599
+ if (this.mode === "diff" && gutterUtilityLine.type === "diff-line") return {
600
+ lineNumber: gutterUtilityLine.lineNumber,
601
+ side: gutterUtilityLine.annotationSide
602
+ };
603
+ if (this.mode === "file" && gutterUtilityLine.type === "line") return { lineNumber: gutterUtilityLine.lineNumber };
604
+ }
605
+ };
606
+ handlePointerClick = (event) => {
607
+ const { onHunkExpand, onLineClick, onLineNumberClick, onTokenClick, onMergeConflictActionClick } = this.options;
608
+ if (onHunkExpand == null && onLineClick == null && onLineNumberClick == null && onMergeConflictActionClick == null && onTokenClick == null) return;
609
+ if (this.options.onGutterUtilityClick != null && isGutterUtilityPath(event.composedPath())) return;
610
+ debugLogIfEnabled(this.options.__debugPointerEvents, "click", "FileDiff.DEBUG.handlePointerClick:", event);
611
+ this.handlePointerEvent({
612
+ eventType: "click",
613
+ event
614
+ });
615
+ };
616
+ handlePointerMove = (event) => {
617
+ if (event.pointerType !== "mouse") return;
618
+ const { lineHoverHighlight = "disabled", onLineEnter, onLineLeave, onTokenEnter, onTokenLeave, enableGutterUtility = false } = this.options;
619
+ if (lineHoverHighlight === "disabled" && !enableGutterUtility && onLineEnter == null && onLineLeave == null && onTokenEnter == null && onTokenLeave == null) return;
620
+ debugLogIfEnabled(this.options.__debugPointerEvents, "move", "FileDiff.DEBUG.handlePointerMove:", event);
621
+ this.handlePointerEvent({
622
+ eventType: "move",
623
+ event
624
+ });
625
+ };
626
+ handlePointerLeave = (event) => {
627
+ const { __debugPointerEvents } = this.options;
628
+ debugLogIfEnabled(__debugPointerEvents, "move", "FileDiff.DEBUG.handlePointerLeave: no event");
629
+ if (this.hoveredLine == null && this.hoveredToken == null) {
630
+ debugLogIfEnabled(__debugPointerEvents, "move", "FileDiff.DEBUG.handlePointerLeave: returned early, no hovered line or token");
631
+ return;
632
+ }
633
+ if (this.hoveredToken != null) {
634
+ this.options.onTokenLeave?.(this.hoveredToken, event);
635
+ this.clearHoveredToken();
636
+ }
637
+ if (this.hoveredLine != null) {
638
+ this.options.onLineLeave?.({
639
+ ...this.hoveredLine,
640
+ event
641
+ });
642
+ this.clearHoveredLine();
643
+ }
644
+ this.placeUtility();
645
+ };
646
+ handlePointerEvent({ eventType, event }) {
647
+ const { __debugPointerEvents } = this.options;
648
+ const composedPath = event.composedPath();
649
+ debugLogIfEnabled(__debugPointerEvents, eventType, "FileDiff.DEBUG.handlePointerEvent:", {
650
+ eventType,
651
+ composedPath
652
+ });
653
+ const target = this.resolvePointerTarget(composedPath);
654
+ debugLogIfEnabled(__debugPointerEvents, eventType, "FileDiff.DEBUG.handlePointerEvent: resolvePointerTarget result:", target);
655
+ const { onLineClick, onLineNumberClick, onLineEnter, onLineLeave, onTokenClick, onTokenEnter, onTokenLeave, onHunkExpand, onMergeConflictActionClick } = this.options;
656
+ switch (eventType) {
657
+ case "move": {
658
+ const sameLine = isHoverableLinePointerTarget(target) && this.hoveredLine?.lineElement === target.lineElement;
659
+ if (!(isTokenPointerTarget(target) && this.hoveredToken?.tokenElement === target.tokenElement)) {
660
+ if (this.hoveredToken != null) {
661
+ onTokenLeave?.(this.hoveredToken, event);
662
+ this.clearHoveredToken();
663
+ }
664
+ if (isTokenPointerTarget(target)) {
665
+ this.setHoveredToken(this.toTokenEventBaseProps(target));
666
+ onTokenEnter?.(this.hoveredToken, event);
667
+ }
668
+ }
669
+ if (!sameLine) {
670
+ if (this.hoveredLine != null) {
671
+ onLineLeave?.({
672
+ ...this.hoveredLine,
673
+ event
674
+ });
675
+ this.clearHoveredLine();
676
+ }
677
+ if (isHoverableLinePointerTarget(target)) {
678
+ this.setHoveredLine(this.toEventBaseProps(target));
679
+ this.placeUtility();
680
+ onLineEnter?.({
681
+ ...this.hoveredLine,
682
+ event
683
+ });
684
+ } else this.placeUtility();
685
+ }
686
+ break;
687
+ }
688
+ case "click": {
689
+ if (target == null) break;
690
+ if (isMergeConflictActionPointerTarget(target) && onMergeConflictActionClick != null) {
691
+ onMergeConflictActionClick(target);
692
+ break;
693
+ }
694
+ if (isExpandoPointerTarget(target) && onHunkExpand != null) {
695
+ onHunkExpand(target.hunkIndex, target.all || event.shiftKey ? "both" : target.direction, target.all || event.shiftKey ? Number.POSITIVE_INFINITY : void 0);
696
+ break;
697
+ }
698
+ if (!isHoverableLinePointerTarget(target)) break;
699
+ if (isTokenPointerTarget(target) && onTokenClick != null) onTokenClick(this.toTokenEventBaseProps(target), event);
700
+ const eventBase = this.toEventBaseProps(target);
701
+ if (onLineNumberClick != null && target.numberColumn) onLineNumberClick({
702
+ ...eventBase,
703
+ event
704
+ });
705
+ else if (onLineClick != null) onLineClick({
706
+ ...eventBase,
707
+ event
708
+ });
709
+ break;
710
+ }
711
+ }
712
+ }
713
+ syncPointerListeners(pre) {
714
+ const { __debugPointerEvents, lineHoverHighlight = "disabled", onLineClick, onLineNumberClick, onLineEnter, onLineLeave, onTokenClick, onTokenEnter, onTokenLeave, onHunkExpand, onMergeConflictActionClick, enableGutterUtility = false, enableLineSelection = false, onGutterUtilityClick } = this.options;
715
+ const enableGutterSelection = onGutterUtilityClick != null;
716
+ const shouldAttachPointerListeners = lineHoverHighlight !== "disabled" || onLineClick != null || onLineNumberClick != null || onLineEnter != null || onLineLeave != null || onTokenClick != null || onTokenEnter != null || onTokenLeave != null || onHunkExpand != null || onMergeConflictActionClick != null || enableGutterUtility || enableLineSelection || enableGutterSelection;
717
+ if (shouldAttachPointerListeners && !this.hasPointerListeners) {
718
+ pre.addEventListener("click", this.handlePointerClick);
719
+ pre.addEventListener("pointerdown", this.handlePointerDown);
720
+ pre.addEventListener("pointermove", this.handlePointerMove);
721
+ pre.addEventListener("pointerleave", this.handlePointerLeave);
722
+ this.hasPointerListeners = true;
723
+ debugLogIfEnabled(__debugPointerEvents, "click", "FileDiff.DEBUG.attachEventListeners: Attaching click events for:", (() => {
724
+ const reasons = [];
725
+ if (__debugPointerEvents === "both" || __debugPointerEvents === "click") {
726
+ if (onLineClick != null) reasons.push("onLineClick");
727
+ if (onLineNumberClick != null) reasons.push("onLineNumberClick");
728
+ if (onHunkExpand != null) reasons.push("expandable hunk separators");
729
+ if (onMergeConflictActionClick != null) reasons.push("merge conflict actions");
730
+ }
731
+ return reasons;
732
+ })());
733
+ debugLogIfEnabled(__debugPointerEvents, "move", "FileDiff.DEBUG.attachEventListeners: Attaching pointer move event");
734
+ debugLogIfEnabled(__debugPointerEvents, "move", "FileDiff.DEBUG.attachEventListeners: Attaching pointer leave event");
735
+ } else if (!shouldAttachPointerListeners && this.hasPointerListeners) {
736
+ pre.removeEventListener("click", this.handlePointerClick);
737
+ pre.removeEventListener("pointerdown", this.handlePointerDown);
738
+ pre.removeEventListener("pointermove", this.handlePointerMove);
739
+ pre.removeEventListener("pointerleave", this.handlePointerLeave);
740
+ this.hasPointerListeners = false;
741
+ }
742
+ const hasActiveLineSelectionSession = this.pointerSession.mode === "selecting" || this.pointerSession.mode === "pendingSingleLineUnselect";
743
+ const hasActiveGutterSelectionSession = this.pointerSession.mode === "gutterSelecting";
744
+ if (!enableLineSelection && hasActiveLineSelectionSession || !enableGutterSelection && hasActiveGutterSelectionSession) {
745
+ this.clearPointerSession();
746
+ this.detachDocumentPointerListeners();
747
+ this.selectionAnchor = void 0;
748
+ this.clearPendingSingleLineState();
749
+ }
750
+ }
751
+ updateInteractiveLineAttributes() {
752
+ if (this.pre == null) return;
753
+ const { onLineClick, onLineNumberClick, enableLineSelection = false } = this.options;
754
+ const shouldHaveInteractiveLines = onLineClick != null;
755
+ const shouldHaveInteractiveLineNumbers = onLineNumberClick != null || enableLineSelection;
756
+ if (shouldHaveInteractiveLines && !this.interactiveLinesAttr) {
757
+ this.pre.setAttribute("data-interactive-lines", "");
758
+ this.interactiveLinesAttr = true;
759
+ } else if (!shouldHaveInteractiveLines && this.interactiveLinesAttr) {
760
+ this.pre.removeAttribute("data-interactive-lines");
761
+ this.interactiveLinesAttr = false;
762
+ }
763
+ if (shouldHaveInteractiveLineNumbers && !this.interactiveLineNumbersAttr) {
764
+ this.pre.setAttribute("data-interactive-line-numbers", "");
765
+ this.interactiveLineNumbersAttr = true;
766
+ } else if (!shouldHaveInteractiveLineNumbers && this.interactiveLineNumbersAttr) {
767
+ this.pre.removeAttribute("data-interactive-line-numbers");
768
+ this.interactiveLineNumbersAttr = false;
769
+ }
770
+ }
771
+ handlePointerDown = (event) => {
772
+ if (event.pointerType === "mouse" && event.button !== 0 || this.pre == null || this.pointerSession.mode !== "idle") return;
773
+ const path = event.composedPath();
774
+ if (isGutterUtilityPath(path) && this.options.onGutterUtilityClick != null) this.startGutterSelectionFromPointerDown(event);
775
+ else {
776
+ if (event.pointerType !== "mouse") this.revealUtilityFromGutterPath(path);
777
+ this.startLineSelectionFromPointerDown(event);
778
+ }
779
+ };
780
+ startLineSelectionFromPointerDown(event) {
781
+ const { enableLineSelection = false } = this.options;
782
+ if (!enableLineSelection) return;
783
+ const pointerInfo = this.resolveSelectionInfo(event, {
784
+ source: "event-path",
785
+ requireNumberColumn: true
786
+ });
787
+ if (pointerInfo == null) return;
788
+ const { pre } = this;
789
+ if (pre == null) return;
790
+ const { lineNumber, eventSide, lineIndex } = pointerInfo;
791
+ if (event.shiftKey && this.selectedRange != null) {
792
+ const rowRange = this.getIndexesFromSelection(this.selectedRange, pre.getAttribute("data-diff-type") === "split");
793
+ if (rowRange == null) return;
794
+ const useStart = rowRange.start <= rowRange.end ? lineIndex >= rowRange.start : lineIndex <= rowRange.end;
795
+ this.selectionAnchor = {
796
+ lineNumber: useStart ? this.selectedRange.start : this.selectedRange.end,
797
+ side: useStart ? this.selectedRange.side : this.selectedRange.endSide ?? this.selectedRange.side
798
+ };
799
+ this.updateSelection(lineNumber, eventSide, false);
800
+ this.notifySelectionStart(this.getCurrentSelectionRange());
801
+ this.pointerSession = {
802
+ mode: "selecting",
803
+ pointerId: event.pointerId
804
+ };
805
+ this.attachDocumentPointerListeners();
806
+ return;
807
+ }
808
+ if (this.selectedRange?.start === lineNumber && this.selectedRange?.end === lineNumber) {
809
+ const point = {
810
+ lineNumber,
811
+ side: eventSide
812
+ };
813
+ this.selectionAnchor = point;
814
+ this.pointerSession = {
815
+ mode: "pendingSingleLineUnselect",
816
+ pointerId: event.pointerId,
817
+ anchor: point,
818
+ pending: point
819
+ };
820
+ this.attachDocumentPointerListeners();
821
+ return;
822
+ }
823
+ if (this.options.controlledSelection === true) this.proposedSelectedRange = null;
824
+ else this.selectedRange = null;
825
+ this.placeUtility();
826
+ this.selectionAnchor = {
827
+ lineNumber,
828
+ side: eventSide
829
+ };
830
+ this.updateSelection(lineNumber, eventSide, false);
831
+ this.notifySelectionStart(this.getCurrentSelectionRange());
832
+ this.pointerSession = {
833
+ mode: "selecting",
834
+ pointerId: event.pointerId
835
+ };
836
+ this.attachDocumentPointerListeners();
837
+ }
838
+ startGutterSelectionFromPointerDown(event) {
839
+ const { onGutterUtilityClick } = this.options;
840
+ if (onGutterUtilityClick == null) return;
841
+ const selectedEndpoints = this.currentSelectionEnds();
842
+ const point = selectedEndpoints?.bottom ?? this.resolveSelectionPoint(event, {
843
+ source: "event-path",
844
+ excludeUtility: false
845
+ });
846
+ const anchor = selectedEndpoints?.top ?? point;
847
+ if (point == null || anchor == null) return;
848
+ event.preventDefault();
849
+ event.stopPropagation();
850
+ this.pointerSession = {
851
+ mode: "gutterSelecting",
852
+ pointerId: event.pointerId,
853
+ anchor,
854
+ current: point
855
+ };
856
+ this.selectionAnchor = {
857
+ lineNumber: anchor.lineNumber,
858
+ side: anchor.side
859
+ };
860
+ this.updateSelection(point.lineNumber, point.side, false);
861
+ this.notifySelectionStart(this.getCurrentSelectionRange());
862
+ this.attachDocumentPointerListeners();
863
+ }
864
+ handleDocumentPointerMove = (event) => {
865
+ switch (this.pointerSession.mode) {
866
+ case "idle":
867
+ return;
868
+ case "gutterSelecting": {
869
+ if (event.pointerId !== this.pointerSession.pointerId) return;
870
+ event.preventDefault();
871
+ const point = this.resolveSelectionPoint(event, { source: "coordinates-first" });
872
+ if (point == null) return;
873
+ this.pointerSession.current = point;
874
+ this.updateSelection(point.lineNumber, point.side);
875
+ return;
876
+ }
877
+ case "selecting": {
878
+ if (event.pointerId !== this.pointerSession.pointerId) return;
879
+ event.preventDefault();
880
+ const pointerInfo = this.resolveSelectionInfo(event, {
881
+ source: "coordinates-first",
882
+ requireNumberColumn: false
883
+ });
884
+ if (pointerInfo == null || this.selectionAnchor == null) return;
885
+ this.updateSelection(pointerInfo.lineNumber, pointerInfo.eventSide);
886
+ return;
887
+ }
888
+ case "pendingSingleLineUnselect": {
889
+ if (event.pointerId !== this.pointerSession.pointerId) return;
890
+ event.preventDefault();
891
+ const pointerInfo = this.resolveSelectionInfo(event, {
892
+ source: "coordinates-first",
893
+ requireNumberColumn: false
894
+ });
895
+ if (pointerInfo == null || this.selectionAnchor == null) return;
896
+ const point = {
897
+ lineNumber: pointerInfo.lineNumber,
898
+ side: pointerInfo.eventSide
899
+ };
900
+ if (areSelectionPointsEqual(this.pointerSession.pending, point)) return;
901
+ this.updateSelection(pointerInfo.lineNumber, pointerInfo.eventSide, false);
902
+ this.notifySelectionStart(this.getCurrentSelectionRange());
903
+ this.notifySelectionChangeDelta();
904
+ this.pointerSession = {
905
+ mode: "selecting",
906
+ pointerId: event.pointerId
907
+ };
908
+ return;
909
+ }
910
+ }
911
+ };
912
+ handleDocumentPointerUp = (event) => {
913
+ const { onGutterUtilityClick } = this.options;
914
+ switch (this.pointerSession.mode) {
915
+ case "idle":
916
+ return;
917
+ case "gutterSelecting": {
918
+ const { pointerSession: session } = this;
919
+ if (event.pointerId !== session.pointerId) return;
920
+ event.preventDefault();
921
+ const point = this.resolveSelectionPoint(event, { source: "coordinates-first" });
922
+ if (point != null) {
923
+ session.current = point;
924
+ this.updateSelection(point.lineNumber, point.side);
925
+ }
926
+ const completedRange = this.buildSelectedLineRange(session.anchor, session.current);
927
+ onGutterUtilityClick?.({ ...completedRange });
928
+ this.selectionAnchor = void 0;
929
+ this.notifySelectionEnd(completedRange);
930
+ this.notifySelectionCommitted(completedRange);
931
+ this.clearProposedSelection();
932
+ this.clearPointerSession();
933
+ this.detachDocumentPointerListeners();
934
+ return;
935
+ }
936
+ case "pendingSingleLineUnselect":
937
+ if (event.pointerId !== this.pointerSession.pointerId) return;
938
+ event.preventDefault();
939
+ this.updateSelection(null, void 0, false);
940
+ this.selectionAnchor = void 0;
941
+ this.clearPendingSingleLineState();
942
+ this.detachDocumentPointerListeners();
943
+ this.notifySelectionEnd(this.getCurrentSelectionRange());
944
+ this.notifySelectionCommitted(this.getCurrentSelectionRange());
945
+ this.clearProposedSelection();
946
+ return;
947
+ case "selecting":
948
+ if (event.pointerId !== this.pointerSession.pointerId) return;
949
+ event.preventDefault();
950
+ this.selectionAnchor = void 0;
951
+ this.detachDocumentPointerListeners();
952
+ this.clearPointerSession();
953
+ this.notifySelectionEnd(this.getCurrentSelectionRange());
954
+ this.notifySelectionCommitted(this.getCurrentSelectionRange());
955
+ this.clearProposedSelection();
956
+ }
957
+ };
958
+ handleDocumentPointerCancel = (event) => {
959
+ switch (this.pointerSession.mode) {
960
+ case "idle":
961
+ return;
962
+ case "gutterSelecting":
963
+ case "selecting":
964
+ case "pendingSingleLineUnselect":
965
+ if ("pointerId" in this.pointerSession) {
966
+ if (event.pointerId !== this.pointerSession.pointerId) return;
967
+ }
968
+ this.selectionAnchor = void 0;
969
+ this.clearProposedSelection();
970
+ this.clearPendingSingleLineState();
971
+ this.clearPointerSession();
972
+ this.detachDocumentPointerListeners();
973
+ }
974
+ };
975
+ clearHoveredLine() {
976
+ if (this.hoveredLine == null) return;
977
+ this.hoveredLine.lineElement.removeAttribute("data-hovered");
978
+ this.hoveredLine.numberElement.removeAttribute("data-hovered");
979
+ this.hoveredLine = void 0;
980
+ }
981
+ setHoveredLine(hoveredLine) {
982
+ const { lineHoverHighlight = "disabled" } = this.options;
983
+ if (this.hoveredLine != null) this.clearHoveredLine();
984
+ this.hoveredLine = hoveredLine;
985
+ if (lineHoverHighlight !== "disabled") {
986
+ if (lineHoverHighlight === "both" || lineHoverHighlight === "line") this.hoveredLine.lineElement.setAttribute("data-hovered", "");
987
+ if (lineHoverHighlight === "both" || lineHoverHighlight === "number") this.hoveredLine.numberElement.setAttribute("data-hovered", "");
988
+ }
989
+ }
990
+ clearHoveredToken() {
991
+ if (this.hoveredToken == null) return;
992
+ this.hoveredToken = void 0;
993
+ }
994
+ setHoveredToken(hoveredToken) {
995
+ if (this.hoveredToken != null) this.clearHoveredToken();
996
+ this.hoveredToken = hoveredToken;
997
+ }
998
+ ensureGutterUtilityNode(useCustomGutterUtility) {
999
+ if (this.gutterUtilityContainer == null) {
1000
+ this.gutterUtilityContainer = document.createElement("div");
1001
+ this.gutterUtilityContainer.setAttribute("data-gutter-utility-slot", "");
1002
+ }
1003
+ if (useCustomGutterUtility) {
1004
+ if (this.gutterUtilityButton != null) {
1005
+ this.gutterUtilityButton.remove();
1006
+ this.gutterUtilityButton = void 0;
1007
+ }
1008
+ if (this.gutterUtilitySlot == null) {
1009
+ this.gutterUtilitySlot = document.createElement("slot");
1010
+ this.gutterUtilitySlot.name = "gutter-utility-slot";
1011
+ }
1012
+ if (this.gutterUtilitySlot.parentNode !== this.gutterUtilityContainer) this.gutterUtilityContainer.replaceChildren(this.gutterUtilitySlot);
1013
+ } else {
1014
+ this.gutterUtilitySlot?.remove();
1015
+ this.gutterUtilitySlot = void 0;
1016
+ if (this.gutterUtilityButton == null) {
1017
+ const tempDiv = document.createElement("div");
1018
+ tempDiv.innerHTML = toHtml(createGutterUtilityElement());
1019
+ const utilityButton = tempDiv.firstElementChild;
1020
+ if (!(utilityButton instanceof HTMLButtonElement)) throw new Error("InteractionManager.ensureGutterUtilityNode: Node element should be a button");
1021
+ utilityButton.remove();
1022
+ this.gutterUtilityButton = utilityButton;
1023
+ }
1024
+ if (this.gutterUtilityButton.parentNode !== this.gutterUtilityContainer) this.gutterUtilityContainer.replaceChildren(this.gutterUtilityButton);
1025
+ }
1026
+ }
1027
+ revealUtilityFromGutterPath(path) {
1028
+ if (this.placeUtilityFromSelection()) return;
1029
+ const target = this.resolvePointerTarget(path);
1030
+ if (isLinePointerTarget(target) && target.numberColumn) this.showUtilityOnLine(this.toEventBaseProps(target));
1031
+ }
1032
+ placeUtility() {
1033
+ if (this.placeUtilityFromSelection()) return;
1034
+ if (this.hoveredLine != null) {
1035
+ this.showUtilityOnLine(this.hoveredLine);
1036
+ return;
1037
+ }
1038
+ this.hideUtility();
1039
+ }
1040
+ placeUtilityFromSelection() {
1041
+ const endpoints = this.currentSelectionEnds();
1042
+ if (endpoints == null) return false;
1043
+ const target = this.targetForSelectionPoint(endpoints.bottom);
1044
+ if (target == null) this.hideUtility();
1045
+ else this.showUtilityOnLine(this.toEventBaseProps(target));
1046
+ return true;
1047
+ }
1048
+ showUtilityOnLine(line) {
1049
+ if (this.gutterUtilityContainer == null) return;
1050
+ this.gutterUtilityLine = line;
1051
+ line.numberElement.appendChild(this.gutterUtilityContainer);
1052
+ }
1053
+ hideUtility() {
1054
+ this.gutterUtilityContainer?.remove();
1055
+ this.gutterUtilityLine = void 0;
1056
+ }
1057
+ currentSelectionEnds() {
1058
+ const range = this.getCurrentSelectionRange();
1059
+ return range == null ? void 0 : this.selectionEnds(range);
1060
+ }
1061
+ selectionEnds(range) {
1062
+ const start = {
1063
+ lineNumber: range.start,
1064
+ side: range.side
1065
+ };
1066
+ const end = {
1067
+ lineNumber: range.end,
1068
+ side: range.endSide ?? range.side
1069
+ };
1070
+ const startIndex = this.selectionPointRowIndex(start);
1071
+ const endIndex = this.selectionPointRowIndex(end);
1072
+ if (startIndex == null || endIndex == null) return;
1073
+ return startIndex > endIndex ? {
1074
+ top: end,
1075
+ bottom: start
1076
+ } : {
1077
+ top: start,
1078
+ bottom: end
1079
+ };
1080
+ }
1081
+ selectionPointRowIndex(point) {
1082
+ const indexes = this.getLineIndex(point.lineNumber, point.side);
1083
+ if (indexes == null) return;
1084
+ return this.isSplitDiff() ? indexes[1] : indexes[0];
1085
+ }
1086
+ targetForSelectionPoint(point) {
1087
+ if (this.pre == null) return;
1088
+ const indexes = this.getLineIndex(point.lineNumber, point.side);
1089
+ if (indexes == null) return;
1090
+ const lineIndex = this.mode === "diff" ? `${indexes[0]},${indexes[1]}` : `${indexes[0]}`;
1091
+ const candidates = this.pre.querySelectorAll(`[data-column-number="${point.lineNumber}"][data-line-index="${lineIndex}"]`);
1092
+ for (const element of candidates) {
1093
+ if (!(element instanceof HTMLElement)) continue;
1094
+ const target = this.resolvePointerTarget(getElementPath(element));
1095
+ if (!isLinePointerTarget(target)) continue;
1096
+ if (this.mode === "diff" && point.side != null && target.side !== point.side) continue;
1097
+ return target;
1098
+ }
1099
+ }
1100
+ attachDocumentPointerListeners() {
1101
+ if (this.hasDocumentPointerListeners) return;
1102
+ document.addEventListener("pointermove", this.handleDocumentPointerMove);
1103
+ document.addEventListener("pointerup", this.handleDocumentPointerUp);
1104
+ document.addEventListener("pointercancel", this.handleDocumentPointerCancel);
1105
+ this.hasDocumentPointerListeners = true;
1106
+ }
1107
+ detachDocumentPointerListeners() {
1108
+ if (!this.hasDocumentPointerListeners) return;
1109
+ document.removeEventListener("pointermove", this.handleDocumentPointerMove);
1110
+ document.removeEventListener("pointerup", this.handleDocumentPointerUp);
1111
+ document.removeEventListener("pointercancel", this.handleDocumentPointerCancel);
1112
+ this.hasDocumentPointerListeners = false;
1113
+ }
1114
+ clearPointerSession() {
1115
+ this.pointerSession = { mode: "idle" };
1116
+ }
1117
+ clearPendingSingleLineState() {
1118
+ if (this.pointerSession.mode === "pendingSingleLineUnselect") this.pointerSession = { mode: "idle" };
1119
+ }
1120
+ selectionInfoFromPath(path, requireNumberColumn) {
1121
+ const target = this.resolvePointerTarget(path);
1122
+ if (!isLinePointerTarget(target)) return;
1123
+ if (requireNumberColumn && !target.numberColumn) return;
1124
+ if (target.splitLineIndex == null) return;
1125
+ return {
1126
+ lineIndex: target.splitLineIndex,
1127
+ lineNumber: target.lineNumber,
1128
+ eventSide: this.mode === "diff" ? target.side : void 0
1129
+ };
1130
+ }
1131
+ resolveSelectionInfo(event, options) {
1132
+ const path = this.resolveSelectionPath(event, options);
1133
+ return path != null ? this.selectionInfoFromPath(path, options.requireNumberColumn) : void 0;
1134
+ }
1135
+ selectionPointFromPath(path) {
1136
+ const target = this.resolvePointerTarget(path);
1137
+ if (!isLinePointerTarget(target)) return;
1138
+ return {
1139
+ lineNumber: target.lineNumber,
1140
+ side: this.mode === "diff" ? target.side : void 0
1141
+ };
1142
+ }
1143
+ resolveSelectionPoint(event, options) {
1144
+ const path = this.resolveSelectionPath(event, options);
1145
+ return path != null ? this.selectionPointFromPath(path) : void 0;
1146
+ }
1147
+ resolveSelectionPath(event, options) {
1148
+ const excludeUtility = options.excludeUtility !== false;
1149
+ switch (options.source) {
1150
+ case "event-path":
1151
+ return this.pathFromEventPath(event.composedPath(), excludeUtility);
1152
+ case "coordinates-first": {
1153
+ const coordinatePath = this.pathFromCoordinates(event, excludeUtility);
1154
+ if (coordinatePath !== void 0) return coordinatePath ?? void 0;
1155
+ return this.pathFromEventPath(event.composedPath(), excludeUtility);
1156
+ }
1157
+ }
1158
+ }
1159
+ pathFromCoordinates(event, excludeUtility) {
1160
+ const coordinateTarget = this.hitTest(event);
1161
+ if (coordinateTarget === void 0) return;
1162
+ if (coordinateTarget === null) return null;
1163
+ return this.pathFromElement(coordinateTarget, excludeUtility) ?? null;
1164
+ }
1165
+ pathFromEventPath(path, excludeUtility) {
1166
+ if (excludeUtility && isGutterUtilityPath(path)) return;
1167
+ for (const element of path) if (element instanceof Element) return this.pathFromElement(element, excludeUtility);
1168
+ }
1169
+ pathFromElement(element, excludeUtility) {
1170
+ const path = getElementPath(element);
1171
+ if (excludeUtility && isGutterUtilityPath(path)) return;
1172
+ const row = closestSelectableRow(element);
1173
+ if (row != null) return getElementPath(row);
1174
+ return this.pathFromAnnotationSlot(element);
1175
+ }
1176
+ pathFromAnnotationSlot(element) {
1177
+ const annotatedLine = annotationRowFromSlot(element)?.previousElementSibling;
1178
+ if (annotatedLine instanceof HTMLElement && (annotatedLine.hasAttribute("data-line") || annotatedLine.hasAttribute("data-column-number"))) return getElementPath(annotatedLine);
1179
+ const point = selectionPointFromAnnotationSlotName(getAnnotationSlotName(element));
1180
+ if (point == null) return;
1181
+ const target = this.targetForSelectionPoint(point);
1182
+ return target != null ? getElementPath(target.lineElement) : void 0;
1183
+ }
1184
+ hitTest(event) {
1185
+ if (!Number.isFinite(event.clientX) || !Number.isFinite(event.clientY)) return;
1186
+ const root = this.pre?.getRootNode();
1187
+ const elementFromPointRoot = hasElementFromPoint(root) ? root : hasElementFromPoint(document) ? document : void 0;
1188
+ if (elementFromPointRoot == null) return;
1189
+ return elementFromPointRoot.elementFromPoint(event.clientX, event.clientY);
1190
+ }
1191
+ getLineIndex(lineNumber, side) {
1192
+ const { getLineIndex } = this.options;
1193
+ return getLineIndex != null ? getLineIndex(lineNumber, side) : [lineNumber - 1, lineNumber - 1];
1194
+ }
1195
+ getCurrentSelectionRange() {
1196
+ return this.proposedSelectedRange !== void 0 ? this.proposedSelectedRange : this.selectedRange;
1197
+ }
1198
+ clearProposedSelection() {
1199
+ this.proposedSelectedRange = void 0;
1200
+ }
1201
+ updateSelection(currentLine, side, emitChange = true) {
1202
+ const previousRange = this.getCurrentSelectionRange();
1203
+ let nextRange;
1204
+ if (currentLine == null) nextRange = null;
1205
+ else {
1206
+ const anchorSide = this.selectionAnchor?.side ?? side;
1207
+ const anchorLine = this.selectionAnchor?.lineNumber ?? currentLine;
1208
+ nextRange = this.buildSelectionRange(anchorLine, currentLine, anchorSide, side);
1209
+ }
1210
+ if (areSelectionsEqual(previousRange ?? void 0, nextRange ?? void 0)) return;
1211
+ this.selectedRangeHighlightSide = void 0;
1212
+ this.selectedRangeLineNumberOnly = false;
1213
+ if (this.options.controlledSelection === true) this.proposedSelectedRange = nextRange;
1214
+ else {
1215
+ this.selectedRange = nextRange;
1216
+ queueRender(this.renderSelection);
1217
+ }
1218
+ this.placeUtility();
1219
+ if (emitChange) this.notifySelectionChangeDelta();
1220
+ }
1221
+ getIndexesFromSelection(selectedRange, split) {
1222
+ if (this.pre == null) return;
1223
+ const startIndexes = this.getLineIndex(selectedRange.start, selectedRange.side);
1224
+ const finalIndexes = this.getLineIndex(selectedRange.end, selectedRange.endSide ?? selectedRange.side);
1225
+ return startIndexes != null && finalIndexes != null ? {
1226
+ start: split ? startIndexes[1] : startIndexes[0],
1227
+ end: split ? finalIndexes[1] : finalIndexes[0]
1228
+ } : void 0;
1229
+ }
1230
+ getSelectionRenderState() {
1231
+ return {
1232
+ selectedLines: {
1233
+ range: this.selectedRange,
1234
+ highlightSide: this.selectedRangeHighlightSide,
1235
+ lineNumberOnly: this.selectedRangeLineNumberOnly
1236
+ },
1237
+ editorActiveLine: {
1238
+ range: this.editorActiveLine == null ? null : {
1239
+ start: this.editorActiveLine,
1240
+ end: this.editorActiveLine,
1241
+ side: this.editorActiveLineSide
1242
+ },
1243
+ highlightSide: this.editorActiveLineSide,
1244
+ lineNumberOnly: this.editorLineNumberOnly
1245
+ }
1246
+ };
1247
+ }
1248
+ resolveLineRenderRange(state, split, source) {
1249
+ if (state.range == null) return;
1250
+ const rowRange = this.getIndexesFromSelection(state.range, split);
1251
+ if (rowRange == null) {
1252
+ console.error({
1253
+ rowRange,
1254
+ range: state.range
1255
+ });
1256
+ throw new Error(`InteractionManager.renderSelection: No valid ${source} rowRange`);
1257
+ }
1258
+ return rowRange;
1259
+ }
1260
+ getLineRenderColumns(selectedLines, selectedRowRange, editorActiveLine, editorRowRange) {
1261
+ if (this.pre == null || selectedRowRange == null && editorRowRange == null) return [];
1262
+ const { children: codeElements } = this.pre;
1263
+ if (codeElements.length > 2) {
1264
+ console.error(codeElements);
1265
+ throw new Error("InteractionManager.renderSelection: Somehow there are more than 2 code elements...");
1266
+ }
1267
+ const columns = [];
1268
+ for (const code of codeElements) {
1269
+ const side = code.hasAttribute("data-deletions") ? "deletions" : code.hasAttribute("data-additions") ? "additions" : void 0;
1270
+ const renderSelectedLines = selectedLines != null && selectedRowRange != null && (selectedLines.highlightSide == null || side == null || selectedLines.highlightSide === side);
1271
+ const renderEditorActiveLine = editorActiveLine != null && editorRowRange != null && (editorActiveLine.highlightSide == null || side == null || editorActiveLine.highlightSide === side);
1272
+ if (!renderSelectedLines && !renderEditorActiveLine) continue;
1273
+ const [gutter, content] = code.children;
1274
+ if (!(gutter instanceof HTMLElement) || !(content instanceof HTMLElement)) throw new Error("InteractionManager.renderSelection: missing gutter or content element");
1275
+ if (content.children.length !== gutter.children.length) throw new Error("InteractionManager.renderSelection: gutter and content children dont match, something is wrong");
1276
+ columns.push({
1277
+ content,
1278
+ gutter,
1279
+ renderEditorActiveLine,
1280
+ renderSelectedLines
1281
+ });
1282
+ }
1283
+ return columns;
1284
+ }
1285
+ renderSelection = () => {
1286
+ dequeueRender(this.renderSelection);
1287
+ const renderState = this.getSelectionRenderState();
1288
+ if (this.pre == null) return;
1289
+ const { editorActiveLine, selectedLines } = renderState;
1290
+ const selectedLinesChanged = !areLineRenderStatesEqual(this.renderedSelectedLinesState, selectedLines);
1291
+ const editorActiveLineChanged = !areLineRenderStatesEqual(this.renderedEditorActiveLineState, editorActiveLine);
1292
+ if (!selectedLinesChanged && !editorActiveLineChanged) return;
1293
+ if (selectedLinesChanged) this.renderedSelectedLinesState = void 0;
1294
+ if (editorActiveLineChanged) this.renderedEditorActiveLineState = void 0;
1295
+ const split = this.pre.getAttribute("data-diff-type") === "split";
1296
+ const selectedRowRange = !selectedLinesChanged ? void 0 : this.resolveLineRenderRange(selectedLines, split, "selected-lines");
1297
+ const editorRowRange = !editorActiveLineChanged ? void 0 : this.resolveLineRenderRange(editorActiveLine, split, "editor-active-line");
1298
+ const columns = this.getLineRenderColumns(selectedLinesChanged ? selectedLines : void 0, selectedRowRange, editorActiveLineChanged ? editorActiveLine : void 0, editorRowRange);
1299
+ const selectedLinesComplete = selectedLines.range == null || columns.some((column) => column.renderSelectedLines);
1300
+ const editorActiveLineComplete = editorActiveLine.range == null || columns.some((column) => column.renderEditorActiveLine);
1301
+ if (selectedLinesChanged) for (const element of this.pre.querySelectorAll("[data-selected-line]")) element.removeAttribute("data-selected-line");
1302
+ if (editorActiveLineChanged) for (const element of this.pre.querySelectorAll("[data-editor-active-line]")) element.removeAttribute("data-editor-active-line");
1303
+ const selectedFirst = selectedRowRange == null ? void 0 : Math.min(selectedRowRange.start, selectedRowRange.end);
1304
+ const selectedLast = selectedRowRange == null ? void 0 : Math.max(selectedRowRange.start, selectedRowRange.end);
1305
+ const selectedIsSingle = selectedFirst === selectedLast;
1306
+ const editorLineIndex = editorRowRange?.start;
1307
+ for (const column of columns) {
1308
+ const { content, gutter, renderEditorActiveLine, renderSelectedLines } = column;
1309
+ const finalLineIndex = Math.max(renderSelectedLines ? selectedLast ?? -Infinity : -Infinity, renderEditorActiveLine ? editorLineIndex ?? -Infinity : -Infinity);
1310
+ const len = content.children.length;
1311
+ for (let i = 0; i < len; i++) {
1312
+ const contentElement = content.children[i];
1313
+ const gutterElement = gutter.children[i];
1314
+ if (!(contentElement instanceof HTMLElement) || !(gutterElement instanceof HTMLElement)) continue;
1315
+ const lineIndex = this.parseLineIndex(contentElement, split);
1316
+ if ((lineIndex ?? 0) > finalLineIndex) break;
1317
+ if (lineIndex == null) continue;
1318
+ if (renderSelectedLines && selectedFirst != null && selectedLast != null && lineIndex >= selectedFirst && lineIndex <= selectedLast) {
1319
+ let attributeValue = selectedIsSingle ? "single" : lineIndex === selectedFirst ? "first" : lineIndex === selectedLast ? "last" : "";
1320
+ gutterElement.setAttribute("data-selected-line", attributeValue);
1321
+ if (!selectedLines.lineNumberOnly) {
1322
+ contentElement.setAttribute("data-selected-line", attributeValue);
1323
+ if (gutterElement.nextSibling instanceof HTMLElement && contentElement.nextSibling instanceof HTMLElement && (contentElement.nextSibling.hasAttribute("data-line-annotation") || contentElement.nextSibling.hasAttribute("data-merge-conflict-actions"))) {
1324
+ if (selectedIsSingle) {
1325
+ attributeValue = "last";
1326
+ contentElement.setAttribute("data-selected-line", "first");
1327
+ } else if (lineIndex === selectedFirst) attributeValue = "";
1328
+ else if (lineIndex === selectedLast) contentElement.setAttribute("data-selected-line", "");
1329
+ contentElement.nextSibling.setAttribute("data-selected-line", attributeValue);
1330
+ gutterElement.nextSibling.setAttribute("data-selected-line", attributeValue);
1331
+ }
1332
+ }
1333
+ }
1334
+ if (renderEditorActiveLine && lineIndex === editorLineIndex) {
1335
+ gutterElement.setAttribute("data-editor-active-line", "");
1336
+ if (!editorActiveLine.lineNumberOnly) contentElement.setAttribute("data-editor-active-line", "");
1337
+ }
1338
+ }
1339
+ }
1340
+ if (selectedLinesChanged && selectedLinesComplete) this.renderedSelectedLinesState = selectedLines;
1341
+ if (editorActiveLineChanged && editorActiveLineComplete) this.renderedEditorActiveLineState = editorActiveLine;
1342
+ };
1343
+ notifySelectionCommitted(range) {
1344
+ this.options.onLineSelected?.(range);
1345
+ }
1346
+ notifySelectionChangeDelta() {
1347
+ this.options.onLineSelectionChange?.(this.getCurrentSelectionRange() ?? null);
1348
+ }
1349
+ notifySelectionStart(range) {
1350
+ this.options.onLineSelectionStart?.(range);
1351
+ }
1352
+ notifySelectionEnd(range) {
1353
+ this.options.onLineSelectionEnd?.(range);
1354
+ }
1355
+ toEventBaseProps(target) {
1356
+ if (this.mode === "file") return {
1357
+ type: "line",
1358
+ lineElement: target.lineElement,
1359
+ lineNumber: target.lineNumber,
1360
+ numberColumn: target.numberColumn,
1361
+ numberElement: target.numberElement
1362
+ };
1363
+ return {
1364
+ type: "diff-line",
1365
+ annotationSide: target.side,
1366
+ lineType: target.lineType,
1367
+ lineElement: target.lineElement,
1368
+ numberElement: target.numberElement,
1369
+ lineNumber: target.lineNumber,
1370
+ numberColumn: target.numberColumn
1371
+ };
1372
+ }
1373
+ toTokenEventBaseProps({ lineCharEnd, lineCharStart, lineNumber, side, tokenElement, tokenText }) {
1374
+ if (this.mode === "file") return {
1375
+ type: "token",
1376
+ lineCharEnd,
1377
+ lineCharStart,
1378
+ lineNumber,
1379
+ tokenElement,
1380
+ tokenText
1381
+ };
1382
+ return {
1383
+ type: "token",
1384
+ lineCharEnd,
1385
+ lineCharStart,
1386
+ lineNumber,
1387
+ side,
1388
+ tokenElement,
1389
+ tokenText
1390
+ };
1391
+ }
1392
+ buildSelectedLineRange(anchor, current) {
1393
+ return this.buildSelectionRange(anchor.lineNumber, current.lineNumber, anchor.side, current.side);
1394
+ }
1395
+ buildSelectionRange(start, end, side, endSide) {
1396
+ return {
1397
+ start,
1398
+ end,
1399
+ ...side != null ? { side } : {},
1400
+ ...side !== endSide && endSide != null ? { endSide } : {}
1401
+ };
1402
+ }
1403
+ resolvePointerTarget(path) {
1404
+ let numberColumn = false;
1405
+ let lineType;
1406
+ let codeElement;
1407
+ let lineElement;
1408
+ let lineIndexValue;
1409
+ let numberElement;
1410
+ let tokenElement;
1411
+ let tokenInfo;
1412
+ let expandInfo;
1413
+ let lineNumber;
1414
+ let mergeConflictActionTarget;
1415
+ for (const element of path) {
1416
+ if (!(element instanceof HTMLElement)) continue;
1417
+ if (mergeConflictActionTarget == null && element.hasAttribute("data-merge-conflict-action")) {
1418
+ const resolutionValue = element.getAttribute("data-merge-conflict-action") ?? void 0;
1419
+ const conflictIndexValue = element.getAttribute("data-merge-conflict-conflict-index") ?? void 0;
1420
+ const conflictIndex = conflictIndexValue != null ? Number.parseInt(conflictIndexValue, 10) : NaN;
1421
+ if (isMergeConflictResolution(resolutionValue) && Number.isFinite(conflictIndex)) mergeConflictActionTarget = {
1422
+ kind: "merge-conflict-action",
1423
+ resolution: resolutionValue,
1424
+ conflictIndex
1425
+ };
1426
+ }
1427
+ if (tokenElement == null && element.hasAttribute("data-char")) {
1428
+ tokenElement = element;
1429
+ const startAttr = element.getAttribute("data-char");
1430
+ if (startAttr != null) {
1431
+ const lineCharStart = Number.parseInt(startAttr, 10);
1432
+ if (!Number.isNaN(lineCharStart)) {
1433
+ const tokenText = element.textContent ?? "";
1434
+ const lineCharEnd = lineCharStart + tokenText.length;
1435
+ if (tokenText.trim() !== "" || this.options.enableTokenInteractionsOnWhitespace === true) tokenInfo = {
1436
+ tokenElement,
1437
+ lineCharStart,
1438
+ lineCharEnd,
1439
+ tokenText
1440
+ };
1441
+ continue;
1442
+ }
1443
+ }
1444
+ }
1445
+ const columnNumber = numberElement == null ? element.getAttribute("data-column-number") ?? void 0 : void 0;
1446
+ if (columnNumber != null) {
1447
+ numberElement = element;
1448
+ lineNumber = Number.parseInt(columnNumber, 10);
1449
+ numberColumn = true;
1450
+ lineType = getLineTypeFromElement(element);
1451
+ lineIndexValue = element.getAttribute("data-line-index") ?? void 0;
1452
+ continue;
1453
+ }
1454
+ const lineAttr = lineElement == null ? element.getAttribute("data-line") ?? void 0 : void 0;
1455
+ if (lineAttr != null) {
1456
+ lineElement = element;
1457
+ lineNumber = Number.parseInt(lineAttr, 10);
1458
+ lineType = getLineTypeFromElement(element);
1459
+ lineIndexValue = element.getAttribute("data-line-index") ?? void 0;
1460
+ continue;
1461
+ }
1462
+ if (expandInfo == null && (element.hasAttribute("data-expand-button") || element.hasAttribute("data-unmodified-lines"))) {
1463
+ expandInfo = {
1464
+ hunkIndex: void 0,
1465
+ direction: (() => {
1466
+ if (element.hasAttribute("data-expand-up")) return "up";
1467
+ if (element.hasAttribute("data-expand-down")) return "down";
1468
+ return "both";
1469
+ })(),
1470
+ all: element.hasAttribute("data-expand-all-button")
1471
+ };
1472
+ continue;
1473
+ }
1474
+ const expandIndexValue = expandInfo != null ? element.getAttribute("data-expand-index") ?? void 0 : void 0;
1475
+ if (expandInfo != null && expandIndexValue != null) {
1476
+ const expandIndex = Number.parseInt(expandIndexValue, 10);
1477
+ if (!Number.isNaN(expandIndex)) expandInfo.hunkIndex = expandIndex;
1478
+ continue;
1479
+ }
1480
+ if (codeElement == null && element.hasAttribute("data-code")) {
1481
+ codeElement = element;
1482
+ break;
1483
+ }
1484
+ }
1485
+ if (mergeConflictActionTarget != null) return mergeConflictActionTarget;
1486
+ if (expandInfo?.hunkIndex != null) return {
1487
+ type: "line-info",
1488
+ hunkIndex: expandInfo.hunkIndex,
1489
+ direction: expandInfo.direction,
1490
+ all: expandInfo.all
1491
+ };
1492
+ lineElement ??= lineIndexValue != null ? queryHTMLElement(codeElement, `[data-line][data-line-index="${lineIndexValue}"]`) : void 0;
1493
+ numberElement ??= lineIndexValue != null ? queryHTMLElement(codeElement, `[data-column-number][data-line-index="${lineIndexValue}"]`) : void 0;
1494
+ if (codeElement == null || lineElement == null || numberElement == null || lineType == null || lineNumber == null || Number.isNaN(lineNumber)) return;
1495
+ const splitLineIndex = this.parseLineIndex(lineElement, this.isSplitDiff());
1496
+ if (tokenInfo != null) {
1497
+ if (this.mode === "file") return {
1498
+ kind: "token",
1499
+ lineType,
1500
+ lineElement,
1501
+ lineNumber,
1502
+ numberColumn,
1503
+ numberElement,
1504
+ side: void 0,
1505
+ splitLineIndex,
1506
+ ...tokenInfo
1507
+ };
1508
+ return {
1509
+ kind: "token",
1510
+ lineType,
1511
+ lineElement,
1512
+ lineNumber,
1513
+ numberColumn,
1514
+ numberElement,
1515
+ side: getAnnotationSide(lineType, codeElement),
1516
+ splitLineIndex,
1517
+ ...tokenInfo
1518
+ };
1519
+ }
1520
+ if (this.mode === "file") return {
1521
+ kind: "line",
1522
+ lineType,
1523
+ lineElement,
1524
+ lineNumber,
1525
+ numberColumn,
1526
+ numberElement,
1527
+ side: void 0,
1528
+ splitLineIndex
1529
+ };
1530
+ return {
1531
+ kind: "line",
1532
+ lineType,
1533
+ lineElement,
1534
+ lineNumber,
1535
+ numberColumn,
1536
+ numberElement,
1537
+ side: getAnnotationSide(lineType, codeElement),
1538
+ splitLineIndex
1539
+ };
1540
+ }
1541
+ isSplitDiff() {
1542
+ return this.pre?.getAttribute("data-diff-type") === "split";
1543
+ }
1544
+ parseLineIndex(element, split) {
1545
+ const lineIndexes = (element.getAttribute("data-line-index") ?? "").split(",").map((value) => Number.parseInt(value, 10)).filter((value) => !Number.isNaN(value));
1546
+ if (split && lineIndexes.length === 2) return lineIndexes[1];
1547
+ if (!split) return lineIndexes[0];
1548
+ }
1549
+ };
1550
+ function pluckInteractionOptions({ enableTokenInteractionsOnWhitespace, enableGutterUtility, lineHoverHighlight, onGutterUtilityClick, onLineClick, onLineEnter, onLineLeave, onLineNumberClick, onTokenClick, onTokenEnter, onTokenLeave, renderGutterUtility, __debugPointerEvents, enableLineSelection, controlledSelection, onLineSelected, onLineSelectionStart, onLineSelectionChange, onLineSelectionEnd }, onHunkExpand, getLineIndex, onMergeConflictActionClick) {
1551
+ return {
1552
+ enableTokenInteractionsOnWhitespace,
1553
+ enableGutterUtility: resolveEnableGutterUtilityOption({
1554
+ enableGutterUtility,
1555
+ renderGutterUtility,
1556
+ onGutterUtilityClick
1557
+ }),
1558
+ usesCustomGutterUtility: renderGutterUtility != null,
1559
+ lineHoverHighlight,
1560
+ onGutterUtilityClick,
1561
+ onHunkExpand,
1562
+ onMergeConflictActionClick,
1563
+ onLineClick,
1564
+ onLineEnter,
1565
+ onLineLeave,
1566
+ onLineNumberClick,
1567
+ onTokenClick,
1568
+ onTokenEnter,
1569
+ onTokenLeave,
1570
+ __debugPointerEvents,
1571
+ enableLineSelection,
1572
+ controlledSelection,
1573
+ onLineSelected,
1574
+ onLineSelectionStart,
1575
+ onLineSelectionChange,
1576
+ onLineSelectionEnd,
1577
+ getLineIndex
1578
+ };
1579
+ }
1580
+ function resolveEnableGutterUtilityOption({ enableGutterUtility, renderGutterUtility, onGutterUtilityClick }) {
1581
+ if (onGutterUtilityClick != null && renderGutterUtility != null) throw new Error("Cannot use both 'onGutterUtilityClick' and 'renderGutterUtility'. Use only one gutter utility API.");
1582
+ return enableGutterUtility ?? false;
1583
+ }
1584
+ function isLinePointerTarget(target) {
1585
+ return target != null && "kind" in target && target.kind === "line";
1586
+ }
1587
+ function isTokenPointerTarget(target) {
1588
+ return target != null && "kind" in target && target.kind === "token";
1589
+ }
1590
+ function isHoverableLinePointerTarget(target) {
1591
+ return isLinePointerTarget(target) || isTokenPointerTarget(target);
1592
+ }
1593
+ function isExpandoPointerTarget(target) {
1594
+ return "type" in target && target.type === "line-info";
1595
+ }
1596
+ function isMergeConflictActionPointerTarget(target) {
1597
+ return "kind" in target && target.kind === "merge-conflict-action";
1598
+ }
1599
+ function isMergeConflictResolution(value) {
1600
+ return value === "current" || value === "incoming" || value === "both";
1601
+ }
1602
+ function queryHTMLElement(parent, query) {
1603
+ const element = parent?.querySelector(query);
1604
+ return element instanceof HTMLElement ? element : void 0;
1605
+ }
1606
+ function getElementPath(element) {
1607
+ const path = [];
1608
+ let current = element;
1609
+ while (current != null) {
1610
+ path.push(current);
1611
+ current = current.parentNode;
1612
+ }
1613
+ return path;
1614
+ }
1615
+ function closestSelectableRow(element) {
1616
+ const row = element.closest("[data-line], [data-column-number]");
1617
+ if (row instanceof HTMLElement) return row;
1618
+ const annotationRow = element.closest('[data-line-annotation], [data-gutter-buffer="annotation"]');
1619
+ if (!(annotationRow instanceof HTMLElement)) return;
1620
+ const previousRow = annotationRow.previousElementSibling;
1621
+ return previousRow instanceof HTMLElement && (previousRow.hasAttribute("data-line") || previousRow.hasAttribute("data-column-number")) ? previousRow : void 0;
1622
+ }
1623
+ function annotationRowFromSlot(element) {
1624
+ const slotted = element.closest('[slot^="annotation-"]');
1625
+ const row = (slotted instanceof HTMLElement && slotted.assignedSlot != null ? slotted.assignedSlot : element.tagName === "SLOT" ? element : void 0)?.closest("[data-line-annotation]");
1626
+ return row instanceof HTMLElement ? row : void 0;
1627
+ }
1628
+ function getAnnotationSlotName(element) {
1629
+ const slottedElement = element.closest('[slot^="annotation-"]');
1630
+ if (slottedElement instanceof HTMLElement) return slottedElement.getAttribute("slot") ?? void 0;
1631
+ if (element instanceof HTMLElement) {
1632
+ const slotName = element.getAttribute("name") ?? void 0;
1633
+ return slotName != null && slotName.startsWith("annotation-") ? slotName : void 0;
1634
+ }
1635
+ }
1636
+ function selectionPointFromAnnotationSlotName(slotName) {
1637
+ if (slotName == null) return;
1638
+ const match = /^annotation-(?:(additions|deletions)-)?(\d+)$/.exec(slotName);
1639
+ if (match == null) return;
1640
+ const lineNumber = Number.parseInt(match[2], 10);
1641
+ if (!Number.isFinite(lineNumber) || lineNumber <= 0) return;
1642
+ return {
1643
+ lineNumber,
1644
+ side: match[1]
1645
+ };
1646
+ }
1647
+ function hasElementFromPoint(value) {
1648
+ return value != null && typeof value.elementFromPoint === "function";
1649
+ }
1650
+ function areSelectionRangesEqual(first, second) {
1651
+ return first === second || areSelectionsEqual(first ?? void 0, second ?? void 0);
1652
+ }
1653
+ function areLineRenderStatesEqual(first, second) {
1654
+ return first?.highlightSide === second.highlightSide && first?.lineNumberOnly === second.lineNumberOnly && areSelectionRangesEqual(first?.range ?? null, second.range);
1655
+ }
1656
+ function getAnnotationSide(lineType, codeElement) {
1657
+ switch (lineType) {
1658
+ case "change-deletion":
1659
+ return "deletions";
1660
+ case "change-addition":
1661
+ return "additions";
1662
+ default:
1663
+ return codeElement.hasAttribute("data-deletions") ? "deletions" : "additions";
1664
+ }
1665
+ }
1666
+ function getLineTypeFromElement(element) {
1667
+ const lineType = element.getAttribute("data-line-type");
1668
+ if (lineType == null) return;
1669
+ switch (lineType) {
1670
+ case "change-deletion":
1671
+ case "change-addition":
1672
+ case "context":
1673
+ case "context-expanded":
1674
+ return lineType;
1675
+ default:
1676
+ return;
1677
+ }
1678
+ }
1679
+ function debugLogIfEnabled(debugLogType = "none", logIfType, ...args) {
1680
+ switch (debugLogType) {
1681
+ case "none":
1682
+ return;
1683
+ case "both":
1684
+ break;
1685
+ case "click":
1686
+ if (logIfType !== "click") return;
1687
+ break;
1688
+ case "move":
1689
+ if (logIfType !== "move") return;
1690
+ }
1691
+ console.log(...args);
1692
+ }
1693
+ var ResizeManager = class ResizeManager2 {
1694
+ static resizeObserver;
1695
+ static managersByElement = /* @__PURE__ */ new Map();
1696
+ static getResizeObserver() {
1697
+ const resizeObserver = ResizeManager2.resizeObserver ?? new ResizeObserver(ResizeManager2.handleSharedResizeEntries);
1698
+ ResizeManager2.resizeObserver = resizeObserver;
1699
+ return resizeObserver;
1700
+ }
1701
+ static handleSharedResizeEntries(entries) {
1702
+ const entriesByManager = /* @__PURE__ */ new Map();
1703
+ for (const entry of entries) {
1704
+ const manager = ResizeManager2.managersByElement.get(entry.target);
1705
+ if (manager == null) continue;
1706
+ const managerEntries = entriesByManager.get(manager);
1707
+ if (managerEntries == null) entriesByManager.set(manager, [entry]);
1708
+ else managerEntries.push(entry);
1709
+ }
1710
+ for (const [manager, managerEntries] of entriesByManager) manager.handleResizeEntries(managerEntries);
1711
+ }
1712
+ observedNodes = /* @__PURE__ */ new Map();
1713
+ setup(pre, { disableAnnotations, columnVariables = "apply" }) {
1714
+ const annotationUpdates = /* @__PURE__ */ new Set();
1715
+ const applyColumnVariables = columnVariables === "apply";
1716
+ let columnCount = 0;
1717
+ const observedNodes = new Map(this.observedNodes);
1718
+ this.observedNodes.clear();
1719
+ for (const element of pre.children) {
1720
+ if (columnCount === 2) break;
1721
+ const codeElement = (() => {
1722
+ if (element instanceof HTMLElement && element.tagName === "CODE") return element;
1723
+ })();
1724
+ if (codeElement == null) continue;
1725
+ columnCount++;
1726
+ let item = observedNodes.get(codeElement);
1727
+ if (item != null && item.type !== "code") throw new Error("ResizeManager.setup: somehow a code node is being used for an annotation, should be impossible");
1728
+ let numberElement = codeElement.firstElementChild;
1729
+ if (!(numberElement instanceof HTMLElement)) numberElement = null;
1730
+ if (item != null) {
1731
+ this.observedNodes.set(codeElement, item);
1732
+ observedNodes.delete(codeElement);
1733
+ if (item.numberElement !== numberElement) {
1734
+ if (item.numberElement != null) {
1735
+ this.unobserve(item.numberElement);
1736
+ observedNodes.delete(item.numberElement);
1737
+ }
1738
+ if (numberElement != null) {
1739
+ this.observe(numberElement);
1740
+ observedNodes.delete(numberElement);
1741
+ this.observedNodes.set(numberElement, item);
1742
+ }
1743
+ item.numberElement = numberElement;
1744
+ item.numberWidth = 0;
1745
+ } else if (item.numberElement != null) {
1746
+ observedNodes.delete(item.numberElement);
1747
+ this.observedNodes.set(item.numberElement, item);
1748
+ } else item.numberWidth = 0;
1749
+ syncColumnVariableMode(item, applyColumnVariables);
1750
+ } else {
1751
+ item = {
1752
+ type: "code",
1753
+ codeElement,
1754
+ numberElement,
1755
+ codeWidth: "auto",
1756
+ numberWidth: 0,
1757
+ applyColumnVariables
1758
+ };
1759
+ this.observedNodes.set(codeElement, item);
1760
+ this.observe(codeElement);
1761
+ if (numberElement != null) {
1762
+ this.observedNodes.set(numberElement, item);
1763
+ this.observe(numberElement);
1764
+ }
1765
+ }
1766
+ }
1767
+ if (columnCount > 1 && !disableAnnotations) {
1768
+ const annotationElements = pre.querySelectorAll('[data-line-annotation*=","]');
1769
+ const elementMap = /* @__PURE__ */ new Map();
1770
+ for (const element of annotationElements) {
1771
+ if (!(element instanceof HTMLElement)) continue;
1772
+ const lineAnnotation = element.getAttribute("data-line-annotation") ?? "";
1773
+ if (!/^-?\d+,-?\d+$/.test(lineAnnotation)) {
1774
+ console.error("DiffFileRenderer.setupResizeObserver: Invalid element or annotation", {
1775
+ lineAnnotation,
1776
+ element
1777
+ });
1778
+ continue;
1779
+ }
1780
+ let pairs = elementMap.get(lineAnnotation);
1781
+ if (pairs == null) {
1782
+ pairs = [];
1783
+ elementMap.set(lineAnnotation, pairs);
1784
+ }
1785
+ pairs.push(element);
1786
+ }
1787
+ for (const [key, pair] of elementMap) {
1788
+ if (pair.length !== 2) {
1789
+ console.error("DiffFileRenderer.setupResizeObserver: Bad Pair", key, pair);
1790
+ continue;
1791
+ }
1792
+ const [container1, container2] = pair;
1793
+ const child1 = container1.firstElementChild;
1794
+ const child2 = container2.firstElementChild;
1795
+ if (!(container1 instanceof HTMLElement) || !(container2 instanceof HTMLElement) || !(child1 instanceof HTMLElement) || !(child2 instanceof HTMLElement)) continue;
1796
+ let item = observedNodes.get(child1);
1797
+ if (item != null) {
1798
+ this.observedNodes.set(child1, item);
1799
+ this.observedNodes.set(child2, item);
1800
+ observedNodes.delete(child1);
1801
+ observedNodes.delete(child2);
1802
+ continue;
1803
+ }
1804
+ const child1Height = child1.getBoundingClientRect().height;
1805
+ const child2Height = child2.getBoundingClientRect().height;
1806
+ item = {
1807
+ type: "annotations",
1808
+ column1: {
1809
+ container: container1,
1810
+ child: child1,
1811
+ childHeight: child1Height
1812
+ },
1813
+ column2: {
1814
+ container: container2,
1815
+ child: child2,
1816
+ childHeight: child2Height
1817
+ },
1818
+ currentHeight: "auto"
1819
+ };
1820
+ annotationUpdates.add({
1821
+ child1,
1822
+ child2,
1823
+ item,
1824
+ newHeight: Math.max(child1Height, child2Height)
1825
+ });
1826
+ }
1827
+ for (const pendingUpdate of annotationUpdates) {
1828
+ this.applyNewHeight(pendingUpdate.item, pendingUpdate.newHeight);
1829
+ this.observedNodes.set(pendingUpdate.child1, pendingUpdate.item);
1830
+ this.observedNodes.set(pendingUpdate.child2, pendingUpdate.item);
1831
+ this.observe(pendingUpdate.child1);
1832
+ this.observe(pendingUpdate.child2);
1833
+ }
1834
+ annotationUpdates.clear();
1835
+ }
1836
+ for (const [element, item] of observedNodes) {
1837
+ this.unobserve(element);
1838
+ if (item.type === "code") cleanupStaleCodeItem(item);
1839
+ else cleanupStaleAnnotationItem(item);
1840
+ }
1841
+ observedNodes.clear();
1842
+ }
1843
+ cleanUp() {
1844
+ for (const element of this.observedNodes.keys()) this.unobserve(element);
1845
+ this.observedNodes.clear();
1846
+ }
1847
+ observe(element) {
1848
+ const { managersByElement } = ResizeManager2;
1849
+ const owner2 = managersByElement.get(element);
1850
+ if (owner2 === this) return;
1851
+ else if (owner2 != null && owner2 !== this) throw new Error("ResizeManager.observe: element is already owned by another ResizeManager");
1852
+ managersByElement.set(element, this);
1853
+ ResizeManager2.getResizeObserver().observe(element);
1854
+ }
1855
+ unobserve(element) {
1856
+ const { managersByElement, resizeObserver } = ResizeManager2;
1857
+ const owner2 = managersByElement.get(element);
1858
+ if (owner2 == null) return;
1859
+ else if (owner2 !== this) throw new Error("ResizeManager.unobserve: element is owned by another ResizeManager");
1860
+ managersByElement.delete(element);
1861
+ resizeObserver?.unobserve(element);
1862
+ if (resizeObserver != null && managersByElement.size === 0) {
1863
+ resizeObserver.disconnect();
1864
+ ResizeManager2.resizeObserver = void 0;
1865
+ }
1866
+ }
1867
+ handleResizeEntries(entries) {
1868
+ const codeUpdates = /* @__PURE__ */ new Map();
1869
+ const annotationUpdates = /* @__PURE__ */ new Set();
1870
+ for (const entry of entries) {
1871
+ const { target, borderBoxSize, contentBoxSize } = entry;
1872
+ if (!(target instanceof HTMLElement)) {
1873
+ console.error("ResizeManager.handleResizeEntries: Invalid element for ResizeObserver", entry);
1874
+ continue;
1875
+ }
1876
+ const item = this.observedNodes.get(target);
1877
+ if (item == null) {
1878
+ console.error("ResizeManager.handleResizeEntries: Not a valid observed node", entry);
1879
+ continue;
1880
+ }
1881
+ if (item.type === "annotations") {
1882
+ const column = (() => {
1883
+ if (target === item.column1.child) return item.column1;
1884
+ if (target === item.column2.child) return item.column2;
1885
+ })();
1886
+ if (column == null) {
1887
+ console.error(`ResizeManager.handleResizeEntries: Couldn't find a column for`, {
1888
+ item,
1889
+ target
1890
+ });
1891
+ continue;
1892
+ }
1893
+ column.childHeight = borderBoxSize[0].blockSize;
1894
+ annotationUpdates.add(item);
1895
+ } else if (item.type === "code") {
1896
+ const update = codeUpdates.get(item) ?? {};
1897
+ const inlineSize = contentBoxSize[0].inlineSize;
1898
+ if (target === item.codeElement) update.codeInlineSize = inlineSize;
1899
+ else if (target === item.numberElement) update.numberInlineSize = inlineSize;
1900
+ codeUpdates.set(item, update);
1901
+ }
1902
+ }
1903
+ this.applyAnnotationUpdates(annotationUpdates);
1904
+ annotationUpdates.clear();
1905
+ this.applyColumnUpdates(codeUpdates);
1906
+ codeUpdates.clear();
1907
+ }
1908
+ applyAnnotationUpdates(annotationUpdates) {
1909
+ for (const item of annotationUpdates) this.applyNewHeight(item, Math.max(item.column1.childHeight, item.column2.childHeight));
1910
+ }
1911
+ applyColumnUpdates = (queuedUpdates) => {
1912
+ for (const [item, update] of queuedUpdates) {
1913
+ const nextCodeWidth = update.codeInlineSize != null ? resolveCodeWidth(update.codeInlineSize) : item.codeWidth;
1914
+ const nextNumberWidth = update.numberInlineSize != null ? resolveNumberWidth(update.numberInlineSize) : item.numberWidth;
1915
+ const codeWidthChanged = nextCodeWidth !== item.codeWidth;
1916
+ const numberWidthChanged = nextNumberWidth !== item.numberWidth;
1917
+ if (!codeWidthChanged && !numberWidthChanged) continue;
1918
+ item.codeWidth = nextCodeWidth;
1919
+ item.numberWidth = nextNumberWidth;
1920
+ if (item.applyColumnVariables) applyCodeColumnVariables(item, {
1921
+ codeWidthChanged,
1922
+ numberWidthChanged
1923
+ });
1924
+ }
1925
+ };
1926
+ applyNewHeight(item, newHeight) {
1927
+ if (newHeight !== item.currentHeight) {
1928
+ item.currentHeight = Math.max(newHeight, 0);
1929
+ item.column1.container.style.setProperty("--diffs-annotation-min-height", `${item.currentHeight}px`);
1930
+ item.column2.container.style.setProperty("--diffs-annotation-min-height", `${item.currentHeight}px`);
1931
+ }
1932
+ }
1933
+ };
1934
+ function resolveCodeWidth(inlineSize) {
1935
+ const width = Math.max(Math.floor(inlineSize), 0);
1936
+ return width === 0 ? "auto" : width;
1937
+ }
1938
+ function resolveNumberWidth(inlineSize) {
1939
+ return Math.max(Math.ceil(inlineSize), 0);
1940
+ }
1941
+ function syncColumnVariableMode(item, applyColumnVariables) {
1942
+ if (item.applyColumnVariables === applyColumnVariables) return;
1943
+ item.applyColumnVariables = applyColumnVariables;
1944
+ if (applyColumnVariables) applyCodeColumnVariables(item, {
1945
+ codeWidthChanged: true,
1946
+ numberWidthChanged: true
1947
+ });
1948
+ else removeCodeColumnVariables(item);
1949
+ }
1950
+ function applyCodeColumnVariables(item, { codeWidthChanged, numberWidthChanged }) {
1951
+ const { codeElement, codeWidth, numberWidth } = item;
1952
+ if (codeWidthChanged) codeElement.style.setProperty("--diffs-column-width", `${typeof codeWidth === "number" ? `${codeWidth}px` : "auto"}`);
1953
+ if (numberWidthChanged) codeElement.style.setProperty("--diffs-column-number-width", `${numberWidth === 0 ? "auto" : `${numberWidth}px`}`);
1954
+ if (codeWidthChanged || numberWidthChanged && codeWidth !== "auto") {
1955
+ const targetWidth = typeof codeWidth === "number" ? Math.max(codeWidth - numberWidth, 0) : 0;
1956
+ codeElement.style.setProperty("--diffs-column-content-width", `${targetWidth > 0 ? `${targetWidth}px` : "auto"}`);
1957
+ }
1958
+ }
1959
+ function removeCodeColumnVariables(item) {
1960
+ item.codeElement.style.removeProperty("--diffs-column-content-width");
1961
+ item.codeElement.style.removeProperty("--diffs-column-number-width");
1962
+ item.codeElement.style.removeProperty("--diffs-column-width");
1963
+ }
1964
+ function cleanupStaleCodeItem(item) {
1965
+ if (item.codeElement.isConnected) removeCodeColumnVariables(item);
1966
+ }
1967
+ function cleanupStaleAnnotationItem(item) {
1968
+ if (item.column1.container.isConnected) item.column1.container.style.removeProperty("--diffs-annotation-min-height");
1969
+ if (item.column2.container.isConnected) item.column2.container.style.removeProperty("--diffs-annotation-min-height");
1970
+ }
1971
+ function areRenderRangesEqual(renderRangeA, renderRangeB) {
1972
+ if (renderRangeA == null || renderRangeB == null) return renderRangeA === renderRangeB;
1973
+ return renderRangeA.startingLine === renderRangeB.startingLine && renderRangeA.totalLines === renderRangeB.totalLines && renderRangeA.bufferBefore === renderRangeB.bufferBefore && renderRangeA.bufferAfter === renderRangeB.bufferAfter;
1974
+ }
1975
+ function createAnnotationElement(span) {
1976
+ return createHastElement({
1977
+ tagName: "div",
1978
+ children: [createHastElement({
1979
+ tagName: "div",
1980
+ children: span.annotations?.map((slotId) => createHastElement({
1981
+ tagName: "slot",
1982
+ properties: { name: slotId }
1983
+ })),
1984
+ properties: { "data-annotation-content": "" }
1985
+ })],
1986
+ properties: { "data-line-annotation": `${span.hunkIndex},${span.lineIndex}` }
1987
+ });
1988
+ }
1989
+ function getIconForType(type) {
1990
+ switch (type) {
1991
+ case "file":
1992
+ return "diffs-icon-file-code";
1993
+ case "change":
1994
+ return "diffs-icon-symbol-modified";
1995
+ case "new":
1996
+ return "diffs-icon-symbol-added";
1997
+ case "deleted":
1998
+ return "diffs-icon-symbol-deleted";
1999
+ case "rename-pure":
2000
+ case "rename-changed":
2001
+ return "diffs-icon-symbol-moved";
2002
+ }
2003
+ }
2004
+ function createFileHeaderElement({ fileOrDiff, mode, stickyHeader }) {
2005
+ const fileDiff = "type" in fileOrDiff ? fileOrDiff : void 0;
2006
+ const properties = {
2007
+ "data-diffs-header": mode,
2008
+ "data-change-type": fileDiff?.type,
2009
+ "data-sticky": stickyHeader ? "" : void 0
2010
+ };
2011
+ return createHastElement({
2012
+ tagName: "div",
2013
+ children: [mode === "custom" ? createHastElement({
2014
+ tagName: "slot",
2015
+ properties: { name: CUSTOM_HEADER_SLOT_ID }
2016
+ }) : createHeaderElement({
2017
+ name: fileOrDiff.name,
2018
+ prevName: "prevName" in fileOrDiff ? fileOrDiff.prevName : void 0,
2019
+ iconType: fileDiff?.type ?? "file"
2020
+ }), ...mode === "custom" ? [] : [createMetadataElement(fileDiff)]],
2021
+ properties
2022
+ });
2023
+ }
2024
+ function createHeaderElement({ name, prevName, iconType }) {
2025
+ const children = [createHastElement({
2026
+ tagName: "slot",
2027
+ properties: { name: HEADER_PREFIX_SLOT_ID }
2028
+ }), createIconElement({
2029
+ name: getIconForType(iconType),
2030
+ properties: { "data-change-icon": iconType }
2031
+ })];
2032
+ if (prevName != null) {
2033
+ children.push(createHastElement({
2034
+ tagName: "div",
2035
+ children: [createHastElement({
2036
+ tagName: "bdi",
2037
+ children: [createTextNodeElement(prevName)]
2038
+ })],
2039
+ properties: { "data-prev-name": "" }
2040
+ }));
2041
+ children.push(createIconElement({
2042
+ name: "diffs-icon-arrow-right-short",
2043
+ properties: { "data-rename-icon": "" }
2044
+ }));
2045
+ }
2046
+ children.push(createHastElement({
2047
+ tagName: "div",
2048
+ children: [createHastElement({
2049
+ tagName: "bdi",
2050
+ children: [createTextNodeElement(name)]
2051
+ })],
2052
+ properties: { "data-title": "" }
2053
+ }));
2054
+ children.push(createHastElement({
2055
+ tagName: "slot",
2056
+ properties: { name: HEADER_FILENAME_SUFFIX_SLOT_ID }
2057
+ }));
2058
+ return createHastElement({
2059
+ tagName: "div",
2060
+ children,
2061
+ properties: { "data-header-content": "" }
2062
+ });
2063
+ }
2064
+ function createMetadataElement(fileDiff) {
2065
+ const children = [];
2066
+ if (fileDiff != null) {
2067
+ let additions = 0;
2068
+ let deletions = 0;
2069
+ for (const hunk of fileDiff.hunks) {
2070
+ additions += hunk.additionLines;
2071
+ deletions += hunk.deletionLines;
2072
+ }
2073
+ if (deletions > 0 || additions === 0) children.push(createHastElement({
2074
+ tagName: "span",
2075
+ children: [createTextNodeElement(`-${deletions}`)],
2076
+ properties: { "data-deletions-count": "" }
2077
+ }));
2078
+ if (additions > 0 || deletions === 0) children.push(createHastElement({
2079
+ tagName: "span",
2080
+ children: [createTextNodeElement(`+${additions}`)],
2081
+ properties: { "data-additions-count": "" }
2082
+ }));
2083
+ }
2084
+ children.push(createHastElement({
2085
+ tagName: "slot",
2086
+ properties: { name: HEADER_METADATA_SLOT_ID }
2087
+ }));
2088
+ return createHastElement({
2089
+ tagName: "div",
2090
+ children,
2091
+ properties: { "data-metadata": "" }
2092
+ });
2093
+ }
2094
+ function createPreElement(options) {
2095
+ return createHastElement({
2096
+ tagName: "pre",
2097
+ properties: createPreWrapperProperties(options)
2098
+ });
2099
+ }
2100
+ function createPreWrapperProperties({ diffIndicators, disableBackground, disableLineNumbers, overflow, split, totalLines, type, customProperties }) {
2101
+ return {
2102
+ ...customProperties,
2103
+ "data-diff": type === "diff" ? "" : void 0,
2104
+ "data-file": type === "file" ? "" : void 0,
2105
+ "data-diff-type": type === "diff" ? split ? "split" : "single" : void 0,
2106
+ "data-overflow": overflow,
2107
+ "data-disable-line-numbers": disableLineNumbers ? "" : void 0,
2108
+ "data-background": !disableBackground ? "" : void 0,
2109
+ "data-indicators": diffIndicators === "bars" || diffIndicators === "classic" ? diffIndicators : void 0,
2110
+ style: `--diffs-min-number-column-width-default:${`${totalLines}`.length}ch;`
2111
+ };
2112
+ }
2113
+ function getHighlighterOptions(lang, { theme, preferredHighlighter = "shiki-js" }) {
2114
+ return {
2115
+ langs: Array.isArray(lang) ? lang : [lang ?? "text"],
2116
+ themes: getThemes(theme),
2117
+ preferredHighlighter
2118
+ };
2119
+ }
2120
+ function getLineAnnotationName(annotation) {
2121
+ return `annotation-${"side" in annotation ? `${annotation.side}-` : ""}${annotation.lineNumber}`;
2122
+ }
2123
+ function isDefaultRenderRange(renderRange) {
2124
+ return renderRange.startingLine === 0 && renderRange.totalLines === Infinity && renderRange.bufferBefore === 0 && renderRange.bufferAfter === 0;
2125
+ }
2126
+ function areFileTargetsEqual(fileA, fileB) {
2127
+ return fileA?.cacheKey != null || fileB?.cacheKey != null ? fileA?.cacheKey === fileB?.cacheKey : fileA?.contents === fileB?.contents && fileA?.name === fileB?.name && fileA?.lang === fileB?.lang;
2128
+ }
2129
+ const FILE_ANNOTATION_DOM_KEY = `-1,-1`;
2130
+ function includesFileAnnotations(annotations) {
2131
+ return annotations?.some((annotation) => annotation.lineNumber === 0) ?? false;
2132
+ }
2133
+ function getFileAnnotations(annotations) {
2134
+ const fileAnnotations = annotations[0];
2135
+ return fileAnnotations != null && fileAnnotations.length > 0 ? fileAnnotations : void 0;
2136
+ }
2137
+ function shouldRenderFileAnnotations(renderRange) {
2138
+ return renderRange.startingLine === 0 && renderRange.totalLines > 0;
2139
+ }
2140
+ function applyLineTextWithNewline(line, lineText) {
2141
+ if (line.endsWith("\r\n")) return lineText + "\r\n";
2142
+ if (line.endsWith("\r")) return lineText + "\r";
2143
+ if (line.endsWith("\n")) return lineText + "\n";
2144
+ return lineText;
2145
+ }
2146
+ function createContentColumn(children, rowCount) {
2147
+ return createHastElement({
2148
+ tagName: "div",
2149
+ children,
2150
+ properties: {
2151
+ "data-content": "",
2152
+ style: `grid-row: span ${rowCount}`
2153
+ }
2154
+ });
2155
+ }
2156
+ const SVGSpriteSheet = `<svg data-icon-sprite aria-hidden="true" width="0" height="0">
2157
+ <symbol id="diffs-icon-arrow-right-short" viewBox="0 0 16 16">
2158
+ <path d="M8.47 4.22a.75.75 0 0 0 0 1.06l1.97 1.97H3.75a.75.75 0 0 0 0 1.5h6.69l-1.97 1.97a.75.75 0 1 0 1.06 1.06l3.25-3.25a.75.75 0 0 0 0-1.06L9.53 4.22a.75.75 0 0 0-1.06 0"/>
2159
+ </symbol>
2160
+ <symbol id="diffs-icon-brand-github" viewBox="0 0 16 16">
2161
+ <path d="M8 0c4.42 0 8 3.58 8 8a8.01 8.01 0 0 1-5.45 7.59c-.4.08-.55-.17-.55-.38 0-.27.01-1.13.01-2.2 0-.75-.25-1.23-.54-1.48 1.78-.2 3.65-.88 3.65-3.95 0-.88-.31-1.59-.82-2.15.08-.2.36-1.02-.08-2.12 0 0-.67-.22-2.2.82-.64-.18-1.32-.27-2-.27s-1.36.09-2 .27c-1.53-1.03-2.2-.82-2.2-.82-.44 1.1-.16 1.92-.08 2.12-.51.56-.82 1.28-.82 2.15 0 3.06 1.86 3.75 3.64 3.95-.23.2-.44.55-.51 1.07-.46.21-1.61.55-2.33-.66-.15-.24-.6-.83-1.23-.82-.67.01-.27.38.01.53.34.19.73.9.82 1.13.16.45.68 1.31 2.69.94 0 .67.01 1.3.01 1.49 0 .21-.15.45-.55.38A7.995 7.995 0 0 1 0 8c0-4.42 3.58-8 8-8"/>
2162
+ </symbol>
2163
+ <symbol id="diffs-icon-chevron" viewBox="0 0 16 16">
2164
+ <path d="M1.47 4.47a.75.75 0 0 1 1.06 0L8 9.94l5.47-5.47a.75.75 0 1 1 1.06 1.06l-6 6a.75.75 0 0 1-1.06 0l-6-6a.75.75 0 0 1 0-1.06"/>
2165
+ </symbol>
2166
+ <symbol id="diffs-icon-chevrons-narrow" viewBox="0 0 10 16">
2167
+ <path d="M4.47 2.22a.75.75 0 0 1 1.06 0l3.25 3.25a.75.75 0 0 1-1.06 1.06L5 3.81 2.28 6.53a.75.75 0 0 1-1.06-1.06zM1.22 9.47a.75.75 0 0 1 1.06 0L5 12.19l2.72-2.72a.75.75 0 0 1 1.06 1.06l-3.25 3.25a.75.75 0 0 1-1.06 0l-3.25-3.25a.75.75 0 0 1 0-1.06"/>
2168
+ </symbol>
2169
+ <symbol id="diffs-icon-diff-split" viewBox="0 0 16 16">
2170
+ <path d="M14 0H8.5v16H14a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2m-1.5 6.5v1h1a.5.5 0 0 1 0 1h-1v1a.5.5 0 0 1-1 0v-1h-1a.5.5 0 0 1 0-1h1v-1a.5.5 0 0 1 1 0"/><path d="M2 0a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h5.5V0zm.5 7.5h3a.5.5 0 0 1 0 1h-3a.5.5 0 0 1 0-1" opacity=".3"/>
2171
+ </symbol>
2172
+ <symbol id="diffs-icon-diff-unified" viewBox="0 0 16 16">
2173
+ <path fill-rule="evenodd" d="M16 14a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V8.5h16zm-8-4a.5.5 0 0 0-.5.5v1h-1a.5.5 0 0 0 0 1h1v1a.5.5 0 0 0 1 0v-1h1a.5.5 0 0 0 0-1h-1v-1A.5.5 0 0 0 8 10" clip-rule="evenodd"/><path fill-rule="evenodd" d="M14 0a2 2 0 0 1 2 2v5.5H0V2a2 2 0 0 1 2-2zM6.5 3.5a.5.5 0 0 0 0 1h3a.5.5 0 0 0 0-1z" clip-rule="evenodd" opacity=".4"/>
2174
+ </symbol>
2175
+ <symbol id="diffs-icon-expand" viewBox="0 0 16 16">
2176
+ <path d="M3.47 5.47a.75.75 0 0 1 1.06 0L8 8.94l3.47-3.47a.75.75 0 1 1 1.06 1.06l-4 4a.75.75 0 0 1-1.06 0l-4-4a.75.75 0 0 1 0-1.06"/>
2177
+ </symbol>
2178
+ <symbol id="diffs-icon-expand-all" viewBox="0 0 16 16">
2179
+ <path d="M11.47 9.47a.75.75 0 1 1 1.06 1.06l-4 4a.75.75 0 0 1-1.06 0l-4-4a.75.75 0 1 1 1.06-1.06L8 12.94zM7.526 1.418a.75.75 0 0 1 1.004.052l4 4a.75.75 0 1 1-1.06 1.06L8 3.06 4.53 6.53a.75.75 0 1 1-1.06-1.06l4-4z"/>
2180
+ </symbol>
2181
+ <symbol id="diffs-icon-eye-slash" viewBox="0 0 16 16">
2182
+ <path d="m13.47 1.47-12 12 1.06 1.06 12-12zM8 14c-.92 0-1.802-.208-2.624-.547l1.173-1.174c.476.142.963.221 1.451.221 1.66 0 3.307-.949 4.626-2.196a10.4 10.4 0 0 0 1.494-1.751A5 5 0 0 0 14.443 8a5 5 0 0 0-.323-.553 10 10 0 0 0-1.238-1.5l1.061-1.062C15.222 6.173 16 7.511 16 8c0 1.05-3.582 6-8 6"/><path d="M8 11q-.084 0-.167-.005l3.162-3.162q.006.083.005.167a3 3 0 0 1-3 3M5.005 8.167l3.162-3.162a3 3 0 0 0-3.162 3.162"/><path d="M8 3.5c.485 0 .97.081 1.445.227l1.168-1.169C9.794 2.212 8.915 2 8 2 3.582 2 0 6.8 0 8c0 .555.766 1.88 2.027 3.144l1.06-1.06a9.5 9.5 0 0 1-1.203-1.461 4.3 4.3 0 0 1-.345-.617L1.536 8l.003-.006c.064-.149.176-.359.345-.617a9.8 9.8 0 0 1 1.482-1.73C4.675 4.427 6.326 3.5 8 3.5"/>
2183
+ </symbol>
2184
+ <symbol id="diffs-icon-file-code" viewBox="0 0 16 16">
2185
+ <path d="M10.75 0c.199 0 .39.08.53.22l3.5 3.5c.14.14.22.331.22.53v9A2.75 2.75 0 0 1 12.25 16h-8.5A2.75 2.75 0 0 1 1 13.25V2.75A2.75 2.75 0 0 1 3.75 0zm-7 1.5c-.69 0-1.25.56-1.25 1.25v10.5c0 .69.56 1.25 1.25 1.25h8.5c.69 0 1.25-.56 1.25-1.25V5h-1.25A2.25 2.25 0 0 1 10 2.75V1.5z"/><path d="M7.248 6.19a.75.75 0 0 1 .063 1.058L5.753 9l1.558 1.752a.75.75 0 0 1-1.122.996l-2-2.25a.75.75 0 0 1 0-.996l2-2.25a.75.75 0 0 1 1.06-.063M8.69 7.248a.75.75 0 1 1 1.12-.996l2 2.25a.75.75 0 0 1 0 .996l-2 2.25a.75.75 0 1 1-1.12-.996L10.245 9z"/>
2186
+ </symbol>
2187
+ <symbol id="diffs-icon-plus" viewBox="0 0 16 16">
2188
+ <path d="M8 3a.75.75 0 0 1 .75.75v3.5h3.5a.75.75 0 0 1 0 1.5h-3.5v3.5a.75.75 0 0 1-1.5 0v-3.5h-3.5a.75.75 0 0 1 0-1.5h3.5v-3.5A.75.75 0 0 1 8 3"/>
2189
+ </symbol>
2190
+ <symbol id="diffs-icon-symbol-added" viewBox="0 0 16 16">
2191
+ <path d="M8 4a.75.75 0 0 1 .75.75v2.5h2.5a.75.75 0 0 1 0 1.5h-2.5v2.5a.75.75 0 0 1-1.5 0v-2.5h-2.5a.75.75 0 0 1 0-1.5h2.5v-2.5A.75.75 0 0 1 8 4"/><path d="M1.788 4.296c.196-.88.478-1.381.802-1.706s.826-.606 1.706-.802C5.194 1.588 6.387 1.5 8 1.5s2.806.088 3.704.288c.88.196 1.381.478 1.706.802s.607.826.802 1.706c.2.898.288 2.091.288 3.704s-.088 2.806-.288 3.704c-.195.88-.478 1.381-.802 1.706s-.826.607-1.706.802c-.898.2-2.091.288-3.704.288s-2.806-.088-3.704-.288c-.88-.195-1.381-.478-1.706-.802s-.606-.826-.802-1.706C1.588 10.806 1.5 9.613 1.5 8s.088-2.806.288-3.704M8 0C1.412 0 0 1.412 0 8s1.412 8 8 8 8-1.412 8-8-1.412-8-8-8"/>
2192
+ </symbol>
2193
+ <symbol id="diffs-icon-symbol-added-duo" viewBox="0 0 16 16">
2194
+ <path d="M8 0C1.412 0 0 1.412 0 8s1.412 8 8 8 8-1.412 8-8-1.412-8-8-8" opacity=".2"/><path d="M8 4a.75.75 0 0 1 .75.75v2.5h2.5a.75.75 0 0 1 0 1.5h-2.5v2.5a.75.75 0 0 1-1.5 0v-2.5h-2.5a.75.75 0 0 1 0-1.5h2.5v-2.5A.75.75 0 0 1 8 4"/>
2195
+ </symbol>
2196
+ <symbol id="diffs-icon-symbol-added-fill" viewBox="0 0 16 16">
2197
+ <path fill-rule="evenodd" d="M8 0c6.588 0 8 1.412 8 8s-1.412 8-8 8-8-1.412-8-8 1.412-8 8-8m0 4a.75.75 0 0 0-.75.75v2.5h-2.5a.75.75 0 0 0 0 1.5h2.5v2.5a.75.75 0 0 0 1.5 0v-2.5h2.5a.75.75 0 0 0 0-1.5h-2.5v-2.5A.75.75 0 0 0 8 4" clip-rule="evenodd"/>
2198
+ </symbol>
2199
+ <symbol id="diffs-icon-symbol-deleted" viewBox="0 0 16 16">
2200
+ <path d="M4 8a.75.75 0 0 1 .75-.75h6.5a.75.75 0 0 1 0 1.5h-6.5A.75.75 0 0 1 4 8"/><path d="M1.788 4.296c.196-.88.478-1.381.802-1.706s.826-.606 1.706-.802C5.194 1.588 6.387 1.5 8 1.5s2.806.088 3.704.288c.88.196 1.381.478 1.706.802s.607.826.802 1.706c.2.898.288 2.091.288 3.704s-.088 2.806-.288 3.704c-.195.88-.478 1.381-.802 1.706s-.826.607-1.706.802c-.898.2-2.091.288-3.704.288s-2.806-.088-3.704-.288c-.88-.195-1.381-.478-1.706-.802s-.606-.826-.802-1.706C1.588 10.806 1.5 9.613 1.5 8s.088-2.806.288-3.704M8 0C1.412 0 0 1.412 0 8s1.412 8 8 8 8-1.412 8-8-1.412-8-8-8"/>
2201
+ </symbol>
2202
+ <symbol id="diffs-icon-symbol-deleted-duo" viewBox="0 0 16 16">
2203
+ <path d="M8 0C1.412 0 0 1.412 0 8s1.412 8 8 8 8-1.412 8-8-1.412-8-8-8" opacity=".2"/><path d="M4 8a.75.75 0 0 1 .75-.75h6.5a.75.75 0 0 1 0 1.5h-6.5A.75.75 0 0 1 4 8"/>
2204
+ </symbol>
2205
+ <symbol id="diffs-icon-symbol-deleted-fill" viewBox="0 0 16 16">
2206
+ <path fill-rule="evenodd" d="M8 0c6.588 0 8 1.412 8 8s-1.412 8-8 8-8-1.412-8-8 1.412-8 8-8M4.75 7.25a.75.75 0 0 0 0 1.5h6.5a.75.75 0 0 0 0-1.5z" clip-rule="evenodd"/>
2207
+ </symbol>
2208
+ <symbol id="diffs-icon-symbol-diffstat" viewBox="0 0 16 16">
2209
+ <path d="M1.788 4.296c.196-.88.478-1.381.802-1.706s.826-.606 1.706-.802C5.194 1.588 6.387 1.5 8 1.5s2.806.088 3.704.288c.88.196 1.381.478 1.706.802s.607.826.802 1.706c.2.898.288 2.091.288 3.704s-.088 2.806-.288 3.704c-.195.88-.478 1.381-.802 1.706s-.826.607-1.706.802c-.898.2-2.091.288-3.704.288s-2.806-.088-3.704-.288c-.88-.195-1.381-.478-1.706-.802s-.606-.826-.802-1.706C1.588 10.806 1.5 9.613 1.5 8s.088-2.806.288-3.704M8 0C1.412 0 0 1.412 0 8s1.412 8 8 8 8-1.412 8-8-1.412-8-8-8"/><path d="M8.75 4.296a.75.75 0 0 0-1.5 0V6.25h-2a.75.75 0 0 0 0 1.5h2v1.5h1.5v-1.5h2a.75.75 0 0 0 0-1.5h-2zM5.25 10a.75.75 0 0 0 0 1.5h5.5a.75.75 0 0 0 0-1.5z"/>
2210
+ </symbol>
2211
+ <symbol id="diffs-icon-symbol-diffstat-duo" viewBox="0 0 16 16">
2212
+ <path d="M8 0C1.412 0 0 1.412 0 8s1.412 8 8 8 8-1.412 8-8-1.412-8-8-8" opacity=".2"/><path d="M8.75 4.296a.75.75 0 0 0-1.5 0V6.25h-2a.75.75 0 0 0 0 1.5h2v1.5h1.5v-1.5h2a.75.75 0 0 0 0-1.5h-2zM5.25 10a.75.75 0 0 0 0 1.5h5.5a.75.75 0 0 0 0-1.5z"/>
2213
+ </symbol>
2214
+ <symbol id="diffs-icon-symbol-diffstat-fill" viewBox="0 0 16 16">
2215
+ <path fill-rule="evenodd" d="M8 0c6.588 0 8 1.412 8 8s-1.412 8-8 8-8-1.412-8-8 1.412-8 8-8M5.25 10a.75.75 0 0 0 0 1.5h5.5a.75.75 0 0 0 0-1.5zM8 3.546a.75.75 0 0 0-.75.75V6.25h-2a.75.75 0 0 0 0 1.5h2v1.5h1.5v-1.5h2a.75.75 0 0 0 0-1.5h-2V4.296a.75.75 0 0 0-.75-.75" clip-rule="evenodd"/>
2216
+ </symbol>
2217
+ <symbol id="diffs-icon-symbol-extracted" viewBox="0 0 16 16">
2218
+ <path d="M8.25 4.25a.75.75 0 0 1 0 1.5H6.81l3.302 3.302a1.5 1.5 0 1 1-1.06 1.06L5.75 6.811V8.25a.75.75 0 0 1-1.5 0V5A.75.75 0 0 1 5 4.25z"/><path fill-rule="evenodd" d="M8 0c6.588 0 8 1.412 8 8s-1.412 8-8 8-8-1.412-8-8 1.412-8 8-8m0 1.5c-1.613 0-2.807.089-3.704.288-.88.196-1.382.477-1.706.802-.325.324-.606.826-.802 1.706C1.588 5.193 1.5 6.387 1.5 8s.089 2.807.288 3.704c.196.88.477 1.382.802 1.706.324.325.826.606 1.706.802.897.2 2.091.288 3.704.288s2.807-.089 3.704-.288c.88-.196 1.382-.477 1.706-.802.325-.324.606-.826.802-1.706.2-.897.288-2.091.288-3.704s-.089-2.807-.288-3.704c-.196-.88-.477-1.382-.802-1.706-.324-.325-.826-.606-1.706-.802C10.807 1.588 9.613 1.5 8 1.5" clip-rule="evenodd"/>
2219
+ </symbol>
2220
+ <symbol id="diffs-icon-symbol-extracted-duo" viewBox="0 0 16 16">
2221
+ <path fill-rule="evenodd" d="M8 0c6.588 0 8 1.412 8 8s-1.412 8-8 8-8-1.412-8-8 1.412-8 8-8" clip-rule="evenodd" opacity=".2"/><path d="M8.25 4.25a.75.75 0 0 1 0 1.5H6.81l3.302 3.302a1.5 1.5 0 1 1-1.06 1.06L5.75 6.811V8.25a.75.75 0 0 1-1.5 0V5A.75.75 0 0 1 5 4.25z"/>
2222
+ </symbol>
2223
+ <symbol id="diffs-icon-symbol-extracted-fill" viewBox="0 0 16 16">
2224
+ <path fill-rule="evenodd" d="M8 0c6.588 0 8 1.412 8 8s-1.412 8-8 8-8-1.412-8-8 1.412-8 8-8M5 4.25a.75.75 0 0 0-.75.75v3.25a.75.75 0 0 0 1.5 0V6.81l3.302 3.302a1.5 1.5 0 1 0 1.06-1.06L6.811 5.75H8.25a.75.75 0 0 0 0-1.5z" clip-rule="evenodd"/>
2225
+ </symbol>
2226
+ <symbol id="diffs-icon-symbol-ignored" viewBox="0 0 16 16">
2227
+ <path d="M1.5 8c0 1.613.088 2.806.288 3.704.196.88.478 1.381.802 1.706s.826.607 1.706.802c.898.2 2.091.288 3.704.288s2.806-.088 3.704-.288c.88-.195 1.381-.478 1.706-.802s.607-.826.802-1.706c.2-.898.288-2.091.288-3.704s-.088-2.806-.288-3.704c-.195-.88-.478-1.381-.802-1.706s-.826-.606-1.706-.802C10.806 1.588 9.613 1.5 8 1.5s-2.806.088-3.704.288c-.88.196-1.381.478-1.706.802s-.606.826-.802 1.706C1.588 5.194 1.5 6.387 1.5 8M0 8c0-6.588 1.412-8 8-8s8 1.412 8 8-1.412 8-8 8-8-1.412-8-8m11.53-2.47a.75.75 0 0 0-1.06-1.06l-6 6a.75.75 0 1 0 1.06 1.06z"/>
2228
+ </symbol>
2229
+ <symbol id="diffs-icon-symbol-ignored-duo" viewBox="0 0 16 16">
2230
+ <path d="M8 0C1.412 0 0 1.412 0 8s1.412 8 8 8 8-1.412 8-8-1.412-8-8-8" opacity=".2"/><path d="M11.53 4.47a.75.75 0 0 1 0 1.06l-6 6a.75.75 0 0 1-1.06-1.06l6-6a.75.75 0 0 1 1.06 0"/>
2231
+ </symbol>
2232
+ <symbol id="diffs-icon-symbol-ignored-fill" viewBox="0 0 16 16">
2233
+ <path fill-rule="evenodd" d="M8 0c6.588 0 8 1.412 8 8s-1.412 8-8 8-8-1.412-8-8 1.412-8 8-8m3.53 4.47a.75.75 0 0 0-1.06 0l-6 6a.75.75 0 1 0 1.06 1.06l6-6a.75.75 0 0 0 0-1.06" clip-rule="evenodd"/>
2234
+ </symbol>
2235
+ <symbol id="diffs-icon-symbol-inlined" viewBox="0 0 16 16">
2236
+ <path d="M7.75 11.75a.75.75 0 0 1 0-1.5h1.44L5.887 6.948a1.5 1.5 0 1 1 1.06-1.06l3.302 3.301V7.75a.75.75 0 0 1 1.5 0V11a.75.75 0 0 1-.75.75z"/><path fill-rule="evenodd" d="M8 16c-6.588 0-8-1.412-8-8s1.412-8 8-8 8 1.412 8 8-1.412 8-8 8m0-1.5c1.613 0 2.807-.089 3.704-.288.88-.196 1.382-.477 1.706-.802.325-.324.606-.826.802-1.706.2-.897.288-2.091.288-3.704s-.089-2.807-.288-3.704c-.196-.88-.477-1.382-.802-1.706-.324-.325-.826-.606-1.706-.802C10.807 1.588 9.613 1.5 8 1.5s-2.807.089-3.704.288c-.88.196-1.382.477-1.706.802-.325.324-.606.826-.802 1.706C1.588 5.193 1.5 6.387 1.5 8s.089 2.807.288 3.704c.196.88.477 1.382.802 1.706.324.325.826.606 1.706.802.897.2 2.091.288 3.704.288" clip-rule="evenodd"/>
2237
+ </symbol>
2238
+ <symbol id="diffs-icon-symbol-inlined-duo" viewBox="0 0 16 16">
2239
+ <path fill-rule="evenodd" d="M8 16c-6.588 0-8-1.412-8-8s1.412-8 8-8 8 1.412 8 8-1.412 8-8 8" clip-rule="evenodd" opacity=".2"/><path d="M7.75 11.75a.75.75 0 0 1 0-1.5h1.44L5.887 6.948a1.5 1.5 0 1 1 1.06-1.06l3.302 3.301V7.75a.75.75 0 0 1 1.5 0V11a.75.75 0 0 1-.75.75z"/>
2240
+ </symbol>
2241
+ <symbol id="diffs-icon-symbol-inlined-fill" viewBox="0 0 16 16">
2242
+ <path fill-rule="evenodd" d="M8 0c6.588 0 8 1.412 8 8s-1.412 8-8 8-8-1.412-8-8 1.412-8 8-8M5.5 4a1.5 1.5 0 1 0 .388 2.948l3.301 3.302H7.75a.75.75 0 0 0 0 1.5H11a.75.75 0 0 0 .75-.75V7.75a.75.75 0 0 0-1.5 0v1.44L6.948 5.887A1.5 1.5 0 0 0 5.5 4" clip-rule="evenodd"/>
2243
+ </symbol>
2244
+ <symbol id="diffs-icon-symbol-modified" viewBox="0 0 16 16">
2245
+ <path d="M1.5 8c0 1.613.088 2.806.288 3.704.196.88.478 1.381.802 1.706s.826.607 1.706.802c.898.2 2.091.288 3.704.288s2.806-.088 3.704-.288c.88-.195 1.381-.478 1.706-.802s.607-.826.802-1.706c.2-.898.288-2.091.288-3.704s-.088-2.806-.288-3.704c-.195-.88-.478-1.381-.802-1.706s-.826-.606-1.706-.802C10.806 1.588 9.613 1.5 8 1.5s-2.806.088-3.704.288c-.88.196-1.381.478-1.706.802s-.606.826-.802 1.706C1.588 5.194 1.5 6.387 1.5 8M0 8c0-6.588 1.412-8 8-8s8 1.412 8 8-1.412 8-8 8-8-1.412-8-8m8 3a3 3 0 1 0 0-6 3 3 0 0 0 0 6"/>
2246
+ </symbol>
2247
+ <symbol id="diffs-icon-symbol-modified-duo" viewBox="0 0 16 16">
2248
+ <path d="M8 0C1.412 0 0 1.412 0 8s1.412 8 8 8 8-1.412 8-8-1.412-8-8-8" opacity=".2"/><path d="M11 8a3 3 0 1 1-6 0 3 3 0 0 1 6 0"/>
2249
+ </symbol>
2250
+ <symbol id="diffs-icon-symbol-modified-fill" viewBox="0 0 16 16">
2251
+ <path fill-rule="evenodd" d="M8 0c6.588 0 8 1.412 8 8s-1.412 8-8 8-8-1.412-8-8 1.412-8 8-8m0 5a3 3 0 1 0 0 6 3 3 0 0 0 0-6" clip-rule="evenodd"/>
2252
+ </symbol>
2253
+ <symbol id="diffs-icon-symbol-moved" viewBox="0 0 16 16">
2254
+ <path d="M1.788 4.296c.196-.88.478-1.381.802-1.706s.826-.606 1.706-.802C5.194 1.588 6.387 1.5 8 1.5s2.806.088 3.704.288c.88.196 1.381.478 1.706.802s.607.826.802 1.706c.2.898.288 2.091.288 3.704s-.088 2.806-.288 3.704c-.195.88-.478 1.381-.802 1.706s-.826.607-1.706.802c-.898.2-2.091.288-3.704.288s-2.806-.088-3.704-.288c-.88-.195-1.381-.478-1.706-.802s-.606-.826-.802-1.706C1.588 10.806 1.5 9.613 1.5 8s.088-2.806.288-3.704M8 0C1.412 0 0 1.412 0 8s1.412 8 8 8 8-1.412 8-8-1.412-8-8-8"/><path d="M8.495 4.695a.75.75 0 0 0-.05 1.06L10.486 8l-2.041 2.246a.75.75 0 0 0 1.11 1.008l2.5-2.75a.75.75 0 0 0 0-1.008l-2.5-2.75a.75.75 0 0 0-1.06-.051m-4 0a.75.75 0 0 0-.05 1.06l2.044 2.248-1.796 1.995a.75.75 0 0 0 1.114 1.004l2.25-2.5a.75.75 0 0 0-.002-1.007l-2.5-2.75a.75.75 0 0 0-1.06-.05"/>
2255
+ </symbol>
2256
+ <symbol id="diffs-icon-symbol-moved-duo" viewBox="0 0 16 16">
2257
+ <path d="M8 0C1.412 0 0 1.412 0 8s1.412 8 8 8 8-1.412 8-8-1.412-8-8-8" opacity=".2"/><path d="M8.496 4.695a.75.75 0 0 0-.051 1.06L10.486 8l-2.041 2.246a.75.75 0 0 0 1.11 1.008l2.5-2.75a.75.75 0 0 0 0-1.008l-2.5-2.75a.75.75 0 0 0-1.06-.051m-4 0a.75.75 0 0 0-.051 1.06L6.49 8.003 4.693 9.998a.75.75 0 0 0 1.114 1.004l2.25-2.5a.75.75 0 0 0-.002-1.007l-2.5-2.75a.75.75 0 0 0-1.06-.05"/>
2258
+ </symbol>
2259
+ <symbol id="diffs-icon-symbol-moved-fill" viewBox="0 0 16 16">
2260
+ <path fill-rule="evenodd" d="M8 0c6.588 0 8 1.412 8 8s-1.412 8-8 8-8-1.412-8-8 1.412-8 8-8m1.555 4.745a.75.75 0 0 0-1.11 1.01L10.486 8l-2.04 2.245a.75.75 0 0 0 1.109 1.01l2.5-2.75a.75.75 0 0 0 0-1.01zm-4 0a.75.75 0 0 0-1.11 1.01l2.043 2.248-1.796 1.995a.75.75 0 0 0 1.116 1.004l2.25-2.5a.75.75 0 0 0-.003-1.007z" clip-rule="evenodd"/>
2261
+ </symbol>
2262
+ <symbol id="diffs-icon-symbol-ref" viewBox="0 0 16 16">
2263
+ <path d="M1.5 8c0 1.613.088 2.806.288 3.704.196.88.478 1.381.802 1.706.286.286.71.54 1.41.73V1.86c-.7.19-1.124.444-1.41.73-.324.325-.606.826-.802 1.706C1.588 5.194 1.5 6.387 1.5 8m4 6.397c.697.07 1.522.103 2.5.103 1.613 0 2.806-.088 3.704-.288.88-.195 1.381-.478 1.706-.802s.607-.826.802-1.706c.2-.898.288-2.091.288-3.704s-.088-2.806-.288-3.704c-.195-.88-.478-1.381-.802-1.706s-.826-.606-1.706-.802C10.806 1.588 9.613 1.5 8 1.5c-.978 0-1.803.033-2.5.103zM0 8c0-6.588 1.412-8 8-8s8 1.412 8 8-1.412 8-8 8-8-1.412-8-8m7-2a1 1 0 0 1 1-1h3a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1H8a1 1 0 0 1-1-1z"/>
2264
+ </symbol>
2265
+ </svg>`;
2266
+ function arePrePropertiesEqual(propsA, propsB) {
2267
+ if (propsA == null || propsB == null) return propsA === propsB;
2268
+ return areCustomPropertiesEqual(propsA.customProperties, propsB.customProperties) && propsA.type === propsB.type && propsA.diffIndicators === propsB.diffIndicators && propsA.disableBackground === propsB.disableBackground && propsA.disableLineNumbers === propsB.disableLineNumbers && propsA.overflow === propsB.overflow && propsA.split === propsB.split && propsA.totalLines === propsB.totalLines;
2269
+ }
2270
+ const EMPTY_CUSTOM_PROPERTIES = {};
2271
+ function areCustomPropertiesEqual(customPropertiesA = EMPTY_CUSTOM_PROPERTIES, customPropertiesB = EMPTY_CUSTOM_PROPERTIES) {
2272
+ if (customPropertiesA === customPropertiesB) return true;
2273
+ const keysA = Object.keys(customPropertiesA);
2274
+ const keysB = Object.keys(customPropertiesB);
2275
+ if (keysA.length !== keysB.length) return false;
2276
+ for (const key of keysA) if (customPropertiesA[key] !== customPropertiesB[key]) return false;
2277
+ return true;
2278
+ }
2279
+ function createAnnotationWrapperNode(slot) {
2280
+ const wrapper = document.createElement("div");
2281
+ wrapper.dataset.annotationSlot = "";
2282
+ wrapper.slot = slot;
2283
+ wrapper.style.whiteSpace = "normal";
2284
+ return wrapper;
2285
+ }
2286
+ function createGutterUtilityContentNode() {
2287
+ const gutterUtilityContent = document.createElement("div");
2288
+ gutterUtilityContent.slot = "gutter-utility-slot";
2289
+ gutterUtilityContent.style.position = "absolute";
2290
+ gutterUtilityContent.style.top = "0";
2291
+ gutterUtilityContent.style.bottom = "0";
2292
+ gutterUtilityContent.style.textAlign = "center";
2293
+ gutterUtilityContent.style.whiteSpace = "normal";
2294
+ gutterUtilityContent.style.touchAction = "none";
2295
+ return gutterUtilityContent;
2296
+ }
2297
+ function createUnsafeCSSStyleNode() {
2298
+ const node = document.createElement("style");
2299
+ node.setAttribute(UNSAFE_CSS_ATTRIBUTE, "");
2300
+ return node;
2301
+ }
2302
+ var style_default = '@layer base,theme,rendered,unsafe;@layer base{:host{--diffs-font-fallback:"SF Mono", Monaco, Consolas, "Ubuntu Mono", "Liberation Mono", "Courier New", monospace;--diffs-header-font-fallback:system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", "Liberation Sans", Arial, sans-serif;--diffs-mixer:light-dark(#000,#fff);--diffs-gap-fallback:8px;--diffs-scrollbar-gutter-fallback:6px;--diffs-scrollbar-gutter:var(--diffs-scrollbar-gutter-override,var(--diffs-scrollbar-gutter-measured,var(--diffs-scrollbar-gutter-fallback)));--diffs-added-light:#0dbe4e;--diffs-added-dark:#5ecc71;--diffs-modified-light:#009fff;--diffs-modified-dark:#69b1ff;--diffs-deleted-light:#ff2e3f;--diffs-deleted-dark:#ff6762;--diffs-warning-light:#d5a910;--diffs-warning-dark:#ffd452;color-scheme:light dark;font-family:var(--diffs-header-font-family,var(--diffs-header-font-fallback));font-size:var(--diffs-font-size,13px);line-height:var(--diffs-line-height,20px);font-feature-settings:var(--diffs-font-features);--diffs-bg:light-dark(var(--diffs-light-bg,#fff),var(--diffs-dark-bg,#000));--diffs-bg-buffer:var(--diffs-bg-buffer-override,light-dark(color-mix(in lab, var(--diffs-bg) 92%, var(--diffs-mixer)),color-mix(in lab, var(--diffs-bg) 92%, var(--diffs-mixer))));--diffs-bg-context:var(--diffs-bg-context-override,light-dark(color-mix(in lab, var(--diffs-bg) 98.5%, var(--diffs-mixer)),color-mix(in lab, var(--diffs-bg) 92.5%, var(--diffs-mixer))));--diffs-bg-context-gutter:var(--diffs-bg-context-gutter-override,light-dark(color-mix(in lab, var(--diffs-bg-context) 90%, var(--diffs-bg)),color-mix(in lab, var(--diffs-bg-context) 45%, var(--diffs-bg))));--diffs-bg-separator:var(--diffs-bg-separator-override,light-dark(color-mix(in lab, var(--diffs-bg) 96%, var(--diffs-mixer)),color-mix(in lab, var(--diffs-bg) 85%, var(--diffs-mixer))));--diffs-fg:light-dark(var(--diffs-light,#000),var(--diffs-dark,#fff));--diffs-fg-number:var(--diffs-fg-number-override,light-dark(color-mix(in lab, var(--diffs-fg) 65%, var(--diffs-bg)),color-mix(in lab, var(--diffs-fg) 65%, var(--diffs-bg))));--diffs-fg-conflict-marker:var(--diffs-fg-conflict-marker-override,var(--diffs-fg-number));--diffs-deletion-base:var(--diffs-deletion-color-override,light-dark(var(--diffs-light-deletion-color,var(--diffs-deletion-color,var(--diffs-deleted-light))),var(--diffs-dark-deletion-color,var(--diffs-deletion-color,var(--diffs-deleted-dark)))));--diffs-addition-base:var(--diffs-addition-color-override,light-dark(var(--diffs-light-addition-color,var(--diffs-addition-color,var(--diffs-added-light))),var(--diffs-dark-addition-color,var(--diffs-addition-color,var(--diffs-added-dark)))));--diffs-modified-base:var(--diffs-modified-color-override,light-dark(var(--diffs-light-modified-color,var(--diffs-modified-color,var(--diffs-modified-light))),var(--diffs-dark-modified-color,var(--diffs-modified-color,var(--diffs-modified-dark)))));--diffs-bg-deletion:var(--diffs-bg-deletion-override,light-dark(color-mix(in lab, var(--diffs-bg) 88%, var(--diffs-deletion-base)),color-mix(in lab, var(--diffs-bg) 80%, var(--diffs-deletion-base))));--diffs-bg-deletion-emphasis:var(--diffs-bg-deletion-emphasis-override,light-dark(rgb(from var(--diffs-deletion-base) r g b / .15),rgb(from var(--diffs-deletion-base) r g b / .2)));--diffs-bg-addition:var(--diffs-bg-addition-override,light-dark(color-mix(in lab, var(--diffs-bg) 88%, var(--diffs-addition-base)),color-mix(in lab, var(--diffs-bg) 80%, var(--diffs-addition-base))));--diffs-bg-addition-emphasis:var(--diffs-bg-addition-emphasis-override,light-dark(rgb(from var(--diffs-addition-base) r g b / .15),rgb(from var(--diffs-addition-base) r g b / .2)));--diffs-selection-base:var(--diffs-modified-base);--diffs-selection-number-fg:light-dark(color-mix(in lab, var(--diffs-selection-base) 65%, var(--diffs-mixer)),color-mix(in lab, var(--diffs-selection-base) 75%, var(--diffs-mixer)));background-color:var(--diffs-bg);color:var(--diffs-fg);display:block}pre,code,[data-error-wrapper]{isolation:isolate;font-family:var(--diffs-font-family,var(--diffs-font-fallback));outline:none;margin:0;padding:0;display:block}pre,code{background-color:var(--diffs-bg)}code{contain:content}input,button{font-family:inherit;font-size:inherit;line-height:inherit}*,:before,:after{box-sizing:border-box}[data-icon-sprite]{display:none}[data-diffs-header],[data-separator]{font-family:var(--diffs-header-font-family,var(--diffs-header-font-fallback))}[data-diffs-header][data-sticky]{z-index:1;background-color:var(--diffs-bg);position:sticky;top:0}[data-file-info]{color:var(--fg);background-color:color-mix(in lab, var(--bg) 98%, var(--fg));border-block:1px solid color-mix(in lab, var(--bg) 95%, var(--fg));padding:10px;font-weight:700}[data-diff],[data-file]{--diffs-grid-number-column-width:minmax(min-content, max-content);--diffs-code-grid:var(--diffs-grid-number-column-width) 1fr;&[data-dehydrated]{--diffs-code-grid:var(--diffs-grid-number-column-width) minmax(0, 1fr)}&:hover [data-code]::-webkit-scrollbar-thumb{background-color:var(--diffs-bg-context)}}@supports (-webkit-touch-callout:none){:host{--diffs-scrollbar-gutter-fallback:0px}}[data-line] span,[data-edit-prediction-suffix] span{color:light-dark(var(--diffs-token-light,var(--diffs-light)),var(--diffs-token-dark,var(--diffs-dark)));background-color:light-dark(var(--diffs-token-light-bg,inherit),var(--diffs-token-dark-bg,inherit));font-weight:light-dark(var(--diffs-token-light-font-weight,inherit),var(--diffs-token-dark-font-weight,inherit));font-style:light-dark(var(--diffs-token-light-font-style,inherit),var(--diffs-token-dark-font-style,inherit));text-decoration:light-dark(var(--diffs-token-light-text-decoration,inherit),var(--diffs-token-dark-text-decoration,inherit))}[data-line],[data-gutter-buffer],[data-column-number],[data-line-annotation],[data-no-newline],[data-merge-conflict],[data-merge-conflict-actions],[data-editor-overlay]{--diffs-computed-decoration-bg:var(--diffs-bg);--diffs-computed-diff-line-bg:var(--diffs-computed-decoration-bg);--diffs-computed-selected-line-bg:var(--diffs-computed-diff-line-bg);--diffs-computed-editor-active-line-bg:var(--diffs-computed-selected-line-bg);--diffs-computed-hovered-line-bg:var(--diffs-computed-editor-active-line-bg);--diffs-hover-mix-target:var(--diffs-bg-hover-override,var(--diffs-mixer));--diffs-line-bg:var(--diffs-computed-hovered-line-bg);color:var(--diffs-fg);background-color:var(--diffs-line-bg,var(--diffs-bg))}[data-line],[data-no-newline]{&[data-decoration-bg]{--mix-deco-light:92%;--mix-deco-dark:85%;&[data-decoration-bg-depth="2"]{--mix-deco-light:88%;--mix-deco-dark:80%}&[data-decoration-bg-depth="3"]{--mix-deco-light:85%;--mix-deco-dark:78%}--diffs-hover-mix-target:var(--diffs-decoration-bg);--diffs-computed-decoration-bg:light-dark(color-mix(in lab, var(--diffs-bg) var(--mix-deco-light), var(--diffs-decoration-bg)),color-mix(in lab, var(--diffs-bg) var(--mix-deco-dark), var(--diffs-decoration-bg)))}}[data-line-annotation],[data-gutter-buffer=annotation]{--diffs-annotation-bg:var(--diffs-bg-context);--diffs-computed-decoration-bg:var(--diffs-annotation-bg);--diffs-hover-mix-target:var(--diffs-computed-editor-active-line-bg)}[data-merge-conflict-actions],[data-gutter-buffer=merge-conflict-action],[data-gutter-buffer=merge-conflict-marker-base],[data-gutter-buffer=merge-conflict-marker-separator],[data-merge-conflict=marker-base],[data-merge-conflict=marker-separator]{--diffs-computed-decoration-bg:var(--diffs-bg-context);--diffs-hover-mix-target:var(--diffs-computed-editor-active-line-bg)}[data-gutter-buffer=merge-conflict-marker-start],[data-merge-conflict=marker-start]{--diffs-computed-decoration-bg:light-dark(color-mix(in lab, var(--diffs-bg) 78%, var(--conflict-bg-current-header-override,var(--diffs-addition-base))),color-mix(in lab, var(--diffs-bg) 68%, var(--conflict-bg-current-header-override,var(--diffs-addition-base))));--diffs-hover-mix-target:var(--diffs-computed-editor-active-line-bg)}[data-gutter-buffer=merge-conflict-marker-end],[data-merge-conflict=marker-end]{--diffs-computed-decoration-bg:light-dark(color-mix(in lab, var(--diffs-bg) 78%, var(--conflict-bg-incoming-header-override,var(--diffs-modified-base))),color-mix(in lab, var(--diffs-bg) 68%, var(--conflict-bg-incoming-header-override,var(--diffs-modified-base))));--diffs-hover-mix-target:var(--diffs-computed-editor-active-line-bg)}[data-has-merge-conflict] [data-line-annotation],[data-has-merge-conflict] [data-gutter-buffer=annotation]{--diffs-computed-decoration-bg:var(--diffs-bg);--diffs-hover-mix-target:var(--diffs-computed-editor-active-line-bg)}:where([data-background]){& [data-gutter-buffer],& [data-column-number]{--mix-light:91%;--mix-dark:85%}& [data-line],& [data-no-newline]{--mix-light:88%;--mix-dark:80%}& [data-gutter-buffer],& [data-column-number],& [data-line],& [data-no-newline]{--diffs-diff-line-mix-target:var(--diffs-bg);&[data-line-type=change-deletion]{--diffs-diff-line-mix-target:var(--diffs-bg-deletion-override,var(--diffs-deletion-base));--diffs-hover-mix-target:var(--diffs-diff-line-mix-target);&:where([data-gutter-buffer],[data-column-number]){color:var(--diffs-fg-number-deletion-override,var(--diffs-deletion-base));--diffs-diff-line-mix-target:var(--diffs-bg-deletion-number-override,var(--diffs-deletion-base))}--diffs-computed-diff-line-bg:light-dark(color-mix(in lab, var(--diffs-computed-decoration-bg) var(--mix-light), var(--diffs-diff-line-mix-target)),color-mix(in lab, var(--diffs-computed-decoration-bg) var(--mix-dark), var(--diffs-diff-line-mix-target)))}&[data-line-type=change-addition]{--diffs-diff-line-mix-target:var(--diffs-bg-addition-override,var(--diffs-addition-base));--diffs-hover-mix-target:var(--diffs-diff-line-mix-target);&:where([data-gutter-buffer],[data-column-number]){color:var(--diffs-fg-number-addition-override,var(--diffs-addition-base));--diffs-diff-line-mix-target:var(--diffs-bg-addition-number-override,var(--diffs-addition-base))}--diffs-computed-diff-line-bg:light-dark(color-mix(in lab, var(--diffs-computed-decoration-bg) var(--mix-light), var(--diffs-diff-line-mix-target)),color-mix(in lab, var(--diffs-computed-decoration-bg) var(--mix-dark), var(--diffs-diff-line-mix-target)))}&[data-merge-conflict=current]{--diffs-diff-line-mix-target:var(--conflict-bg-current-override,var(--diffs-addition-base));--diffs-hover-mix-target:var(--diffs-diff-line-mix-target);&:where([data-gutter-buffer],[data-column-number]){color:var(--diffs-fg-number-addition-override,var(--diffs-addition-base));--diffs-diff-line-mix-target:var(--conflict-bg-current-number-override,var(--diffs-addition-base))}--diffs-computed-diff-line-bg:light-dark(color-mix(in lab, var(--diffs-computed-decoration-bg) var(--mix-light), var(--diffs-diff-line-mix-target)),color-mix(in lab, var(--diffs-computed-decoration-bg) var(--mix-dark), var(--diffs-diff-line-mix-target)))}&[data-merge-conflict=incoming]{--diffs-diff-line-mix-target:var(--conflict-bg-incoming-override,var(--diffs-modified-base));--diffs-hover-mix-target:var(--diffs-diff-line-mix-target);&:where([data-gutter-buffer],[data-column-number]){color:var(--diffs-modified-base);--diffs-diff-line-mix-target:var(--conflict-bg-incoming-number-override,var(--diffs-modified-base))}--diffs-computed-diff-line-bg:light-dark(color-mix(in lab, var(--diffs-computed-decoration-bg) var(--mix-light), var(--diffs-diff-line-mix-target)),color-mix(in lab, var(--diffs-computed-decoration-bg) var(--mix-dark), var(--diffs-diff-line-mix-target)))}}}[data-gutter-buffer],[data-column-number],[data-line],[data-line-annotation],[data-merge-conflict],[data-merge-conflict-actions],[data-no-newline],[data-editor-overlay]{--diffs-selection-mix-target:var(--diffs-bg-selection-override,var(--diffs-selection-base));--diffs-selection-emphasis-mix-target:var(--diffs-selection-mix-target);&:where([data-editor-overlay]),&:where([data-line],[data-line-annotation],[data-merge-conflict],[data-merge-conflict-actions],[data-no-newline])[data-selected-line]{--mix-selection-light:82%;--mix-selection-dark:75%;--diffs-hover-mix-target:var(--diffs-selection-mix-target)}&:where([data-gutter-buffer][data-selected-line],[data-column-number]:is([data-selected-line],[data-editor-active-line])){--mix-selection-light:75%;--mix-selection-dark:60%;--diffs-selection-mix-target:var(--diffs-bg-selection-number-override,var(--diffs-selection-base));--diffs-hover-mix-target:var(--diffs-selection-mix-target)}&:where([data-line][data-selected-line]):is([data-line-type=change-addition],[data-line-type=change-deletion]){--diffs-selection-emphasis-mix-target:light-dark(color-mix(in lab, var(--diffs-diff-line-mix-target,var(--diffs-selection-mix-target)) var(--mix-selection-light), var(--diffs-selection-mix-target)),var(--diffs-selection-mix-target))}&:where([data-editor-overlay]),&[data-selected-line]{--diffs-computed-selected-line-bg:light-dark(color-mix(in lab, var(--diffs-computed-diff-line-bg) var(--mix-selection-light), var(--diffs-selection-mix-target)),color-mix(in lab, var(--diffs-computed-diff-line-bg) var(--mix-selection-dark), var(--diffs-selection-mix-target)))}}[data-line][data-editor-active-line],[data-column-number][data-editor-active-line]{--diffs-computed-editor-active-line-bg:color-mix(in lab, var(--diffs-computed-selected-line-bg) var(--diffs-editor-active-line-source-mix,100%), var(--diffs-selection-emphasis-mix-target))}@media (pointer:fine){[data-line][data-hovered],[data-gutter-buffer][data-hovered],[data-column-number][data-hovered],[data-line-annotation][data-hovered],[data-no-newline][data-hovered],[data-merge-conflict][data-hovered],[data-merge-conflict-actions][data-hovered],[data-editor-overlay][data-hovered]{--diffs-computed-hovered-line-bg:light-dark(color-mix(in lab, var(--diffs-computed-editor-active-line-bg) 97%, var(--diffs-hover-mix-target)),color-mix(in lab, var(--diffs-computed-editor-active-line-bg) 91%, var(--diffs-hover-mix-target)))}}[data-gutter-buffer][data-selected-line],[data-column-number]:is([data-selected-line],[data-editor-active-line]){color:var(--diffs-selection-number-fg)}[data-no-newline]{user-select:none;& span{opacity:.6}}[data-diff-type=split][data-overflow=scroll]{grid-template-columns:1fr 1fr;display:grid;& [data-additions]{border-left:1px solid var(--diffs-bg)}& [data-deletions]{border-right:1px solid var(--diffs-bg)}}[data-code]{grid-auto-flow:dense;grid-template-columns:var(--diffs-code-grid);overflow:var(--diffs-overflow-override,scroll) clip;overscroll-behavior-x:none;tab-size:var(--diffs-tab-size,2);padding-top:var(--diffs-gap-block,var(--diffs-gap-fallback));padding-bottom:max(0px, calc(var(--diffs-gap-block,var(--diffs-gap-fallback)) - var(--diffs-scrollbar-gutter)));scrollbar-gutter:stable;align-self:flex-start;display:grid}[data-diffs-scrollbar-measure]{opacity:0;pointer-events:none;scrollbar-gutter:auto;grid-template-columns:none;width:100px;height:100px;padding:0;position:absolute;top:-200px;left:-200px}[data-container-size]{container-type:inline-size}[data-code]::-webkit-scrollbar{width:0;height:var(--diffs-scrollbar-gutter)}[data-code]::-webkit-scrollbar-track{background:0 0}[data-code]::-webkit-scrollbar-thumb{background-color:#0000;background-clip:content-box;border:1px solid #0000;border-radius:3px}[data-code]::-webkit-scrollbar-corner{background-color:#0000}@supports ((-moz-appearance:none)){[data-code]{scrollbar-width:thin;scrollbar-color:var(--diffs-bg-context) transparent;padding-bottom:var(--diffs-gap-block,var(--diffs-gap-fallback))}}[data-diffs-header]~[data-diff],[data-diffs-header]~[data-file]{& [data-code],&[data-overflow=wrap],&[data-dehydrated][data-diff-type=split][data-overflow=scroll]{padding-top:0}}[data-gutter]{grid-template-rows:subgrid;grid-template-columns:subgrid;z-index:3;background-color:var(--diffs-bg);grid-column:1;display:grid;position:relative;& [data-gutter-buffer],& [data-column-number]{border-right:var(--diffs-gap-style,2px solid var(--diffs-bg))}}[data-content]{grid-template-rows:subgrid;grid-template-columns:subgrid;background-color:var(--diffs-bg);grid-column:2;min-width:0;display:grid}[data-diff-type=split][data-overflow=wrap],[data-dehydrated][data-diff-type=split][data-overflow=scroll]{grid-auto-flow:dense;grid-template-columns:repeat(2, var(--diffs-code-grid));padding-block:var(--diffs-gap-block,var(--diffs-gap-fallback));display:grid;& [data-code]{display:contents}& [data-deletions]{& [data-gutter]{grid-column:1}& [data-content]{border-right:1px solid var(--diffs-bg);grid-column:2}}& [data-additions]{& [data-gutter]{border-left:1px solid var(--diffs-bg);grid-column:3}& [data-content]{grid-column:4}}}[data-dehydrated][data-diff-type=split][data-overflow=scroll] [data-content]{overflow:clip}[data-overflow=scroll] [data-gutter]{position:sticky;left:0}[data-interactive-lines] [data-line]{cursor:pointer}[data-interactive-line-numbers] [data-column-number]{cursor:pointer;touch-action:none}[data-content-buffer],[data-gutter-buffer]{user-select:none;min-height:1lh;position:relative}[data-gutter-buffer]{padding-left:2ch;padding-right:1ch;&:before{content:"";min-width:var(--diffs-min-number-column-width,var(--diffs-min-number-column-width-default,3ch));display:block}}[data-gutter-buffer=annotation]{--diffs-annotation-bg:var(--diffs-bg-context-gutter);min-height:0}[data-gutter-buffer=buffer]{--diffs-line-bg:var(--diffs-bg-context-gutter)}[data-content-buffer]{background-position:5px 0;background-size:8px 8px;background-origin:border-box;background-image:repeating-linear-gradient(-45deg, transparent, transparent calc(3px * 1.414), var(--diffs-bg-buffer) calc(3px * 1.414), var(--diffs-bg-buffer) calc(4px * 1.414));grid-column:1}[data-separator]{box-sizing:content-box;background-color:var(--diffs-bg)}[data-separator=simple]{min-height:4px}[data-separator=line-info],[data-separator=line-info-basic],[data-separator=metadata],[data-separator=simple]{background-color:var(--diffs-bg-separator)}[data-separator=line-info],[data-separator=line-info-basic],[data-separator=metadata]{height:32px;position:relative}[data-separator-wrapper]{user-select:none;fill:currentColor;background-color:var(--diffs-bg);align-items:center;height:100%;display:flex;position:absolute;inset-inline:0}[data-content] [data-separator-wrapper]{display:none}[data-separator=metadata] [data-separator-wrapper]{background-color:var(--diffs-bg-separator);height:100%;color:var(--diffs-fg-number);white-space:nowrap;text-overflow:ellipsis;min-width:min-content;padding-inline:1ch;inset-inline:100% auto;overflow:hidden}[data-separator=line-info]{margin-block:var(--diffs-gap-block,var(--diffs-gap-fallback));& [data-separator-wrapper]{min-width:16px}}[data-separator=line-info-basic],[data-separator=metadata]{margin-block:0}[data-separator=line-info][data-separator-first]{margin-top:0}[data-separator=line-info][data-separator-last]{margin-bottom:0}[data-expand-index] [data-separator-wrapper]{grid-template-columns:32px auto;display:grid}[data-expand-index] [data-separator-wrapper][data-separator-multi-button]{grid-template-columns:32px 32px auto}[data-expand-button],[data-separator-content]{background-color:var(--diffs-bg-separator);flex:none;align-items:center;display:flex}[data-expand-index] [data-separator-content]:hover{cursor:pointer;text-decoration:underline}[data-expand-button]{cursor:pointer;min-width:32px;color:var(--diffs-fg-number);border-right:2px solid var(--diffs-bg);flex-shrink:0;justify-content:center;align-self:stretch;&:hover{color:var(--diffs-fg)}&[data-expand-all-button]{display:none}}[data-expand-down] [data-icon]{transform:scaleY(-1)}[data-separator-content]{height:100%;color:var(--diffs-fg-number);flex:auto;justify-content:flex-start;padding:0 1ch;overflow:hidden}[data-separator=line-info],[data-separator=line-info-basic]{& [data-separator-content]{user-select:none;height:100%;overflow:clip}}[data-unmodified-lines]{text-overflow:ellipsis;white-space:nowrap;flex:0 auto;min-width:0;display:block;overflow:hidden}@supports (width:1cqi){[data-unified]{& [data-separator=line-info] [data-separator-wrapper]{padding-inline:var(--diffs-gap-inline,var(--diffs-gap-fallback));width:100cqi;& [data-separator-content]{border-radius:6px}}& [data-separator=line-info][data-expand-index] [data-separator-wrapper] [data-separator-content]{border-top-left-radius:unset;border-bottom-left-radius:unset}}[data-gutter]{& [data-separator=line-info] [data-separator-wrapper]{padding-left:var(--diffs-gap-inline,var(--diffs-gap-fallback))}& [data-separator=line-info] [data-separator-content]{border-top-left-radius:6px;border-bottom-left-radius:6px}& [data-separator=line-info][data-expand-index] [data-separator-content]{border-top-left-radius:unset;border-bottom-left-radius:unset}}[data-additions]{& [data-content] [data-separator=line-info]{background-color:var(--diffs-bg);& [data-separator-wrapper]{display:none}}& [data-gutter] [data-separator=line-info] [data-separator-wrapper]{background-color:var(--diffs-bg-separator);border-top-right-radius:6px;border-bottom-right-radius:6px;height:100%;display:block;& [data-separator-content],& [data-expand-button]{display:none}}}[data-overflow=scroll] [data-additions] [data-gutter] [data-separator=line-info] [data-separator-wrapper]{width:calc(100cqi - var(--diffs-gap-inline,var(--diffs-gap-fallback)))}[data-overflow=wrap] [data-additions] [data-content] [data-separator=line-info] [data-separator-wrapper]{background-color:var(--diffs-bg-separator);height:100%;margin-right:var(--diffs-gap-inline,var(--diffs-gap-fallback));border-top-right-radius:6px;border-bottom-right-radius:6px;display:block;& [data-separator-content],& [data-expand-button]{display:none}}[data-separator=line-info] [data-separator-wrapper]{& [data-expand-both],& [data-expand-down],& [data-expand-up]{border-top-left-radius:6px;border-bottom-left-radius:6px}}@media (pointer:fine){[data-separator=line-info] [data-separator-wrapper]{&[data-separator-multi-button]{& [data-expand-up]{border-top-left-radius:6px;border-bottom-left-radius:unset}& [data-expand-down]{border-bottom-left-radius:6px;border-top-left-radius:unset}}}}}@media (pointer:coarse){[data-separator=line-info-basic] [data-separator-wrapper][data-separator-multi-button]{grid-template-columns:34px 34px auto;& [data-separator-content]{grid-column:unset;grid-row:unset}}@supports (width:1cqi){[data-separator=line-info] [data-separator-wrapper]{& [data-expand-both],& [data-expand-down],& [data-expand-up]{border-top-left-radius:6px;border-bottom-left-radius:6px}&[data-separator-multi-button]{& [data-expand-up]{border-top-left-radius:6px;border-bottom-left-radius:6px}& [data-expand-down]{border-bottom-left-radius:unset;border-top-left-radius:unset}}}}}@media (pointer:fine){[data-separator-wrapper][data-separator-multi-button]{grid-template-rows:50% 50%;display:grid;& [data-separator-content]{grid-area:1/2/-1;min-width:min-content}& [data-expand-button]{grid-column:1}}[data-separator=line-info] [data-separator-wrapper],[data-separator=line-info] [data-separator-wrapper][data-separator-multi-button]{grid-template-columns:34px auto}[data-separator=line-info-basic][data-expand-index] [data-separator-wrapper]{grid-template-columns:100% auto}[data-separator=line-info],[data-separator=line-info-basic]{& [data-separator-multi-button]{& [data-expand-up]{border-bottom:1px solid var(--diffs-bg);border-right:2px solid var(--diffs-bg)}& [data-expand-down]{border-top:1px solid var(--diffs-bg);border-right:2px solid var(--diffs-bg)}}}}[data-additions] [data-gutter] [data-separator-wrapper],[data-additions] [data-separator=line-info-basic] [data-separator-wrapper],[data-content] [data-separator-wrapper]{display:none}[data-line-annotation]{min-height:var(--diffs-annotation-min-height,0);z-index:2}[data-merge-conflict-actions]{z-index:2}[data-separator=custom]{grid-template-columns:subgrid;display:grid}[data-line],[data-column-number],[data-no-newline]{padding-inline:1ch;position:relative}[data-indicators=classic] [data-line]{padding-inline-start:2ch}[data-indicators=classic]{& [data-line-type=change-addition],& [data-line-type=change-deletion]{&[data-no-newline],&[data-line]{&:before{user-select:none;width:1ch;height:1lh;display:inline-block;position:absolute;top:0;left:0}}}& [data-line-type=change-addition]{&[data-line],&[data-no-newline]{&:before{content:"+";color:var(--diffs-addition-base)}}}& [data-line-type=change-deletion]{&[data-line],&[data-no-newline]{&:before{content:"-";color:var(--diffs-deletion-base)}}}}[data-indicators=bars]{& [data-line-type=change-deletion],& [data-line-type=change-addition]{&[data-column-number]{&:before{content:"";user-select:none;contain:strict;width:4px;height:100%;display:block;position:absolute;top:0;left:0}}}& [data-line-type=change-deletion]{&[data-column-number]{&:before{background-image:linear-gradient(0deg, var(--diffs-bg-deletion) 50%, var(--diffs-deletion-base) 50%);background-repeat:repeat;background-size:2px 2px;background-size:calc(1lh / round(1lh / 2px)) calc(1lh / round(1lh / 2px))}}}& [data-line-type=change-addition]{&[data-column-number]{&:before{background-color:var(--diffs-addition-base)}}}}[data-overflow=wrap]{& [data-line]{white-space:pre-wrap;word-break:break-word}& [data-annotation-content]{word-break:break-word}}[data-overflow=scroll] [data-line]{white-space:pre;min-height:1lh}[data-column-number]{box-sizing:content-box;text-align:right;user-select:none;color:var(--diffs-fg-number);padding-left:2ch}[data-line-number-content]{min-width:var(--diffs-min-number-column-width,var(--diffs-min-number-column-width-default,3ch));z-index:1;display:inline-block;position:relative}[data-disable-line-numbers]{& [data-gutter-buffer],& [data-column-number]{min-width:4px;padding:0;&:before{min-width:0}}& [data-line-number-content]{display:none}& [data-gutter-utility-slot]{right:unset;justify-content:flex-start;left:0}&[data-indicators=bars] [data-gutter-utility-slot]{left:6px}}[data-file][data-disable-line-numbers]{& [data-gutter-buffer],& [data-column-number]{border-right:0;min-width:0}}[data-diff-span]{box-decoration-break:clone;border-radius:3px}[data-line-type=change-addition] [data-diff-span]{background-color:var(--diffs-bg-addition-emphasis)}[data-line-type=change-deletion] [data-diff-span]{background-color:var(--diffs-bg-deletion-emphasis)}[data-merge-conflict=marker-start],[data-merge-conflict=marker-base],[data-merge-conflict=marker-separator],[data-merge-conflict=marker-end]{color:var(--diffs-fg);padding-left:1ch}[data-merge-conflict=marker-start],[data-merge-conflict=marker-end]{align-items:center;display:flex;&:after{color:var(--diffs-fg-conflict-marker);font-size:.75rem;font-style:normal;line-height:1.25rem;font-family:var(--diffs-header-font-family,var(--diffs-header-font-fallback));padding-left:1ch}}[data-merge-conflict=marker-start]:after{content:"(Current Change)"}[data-merge-conflict=marker-end]:after{content:"(Incoming Change)"}[data-merge-conflict-actions-content]{min-height:1.75rem;font-family:var(--diffs-header-font-family,var(--diffs-header-font-fallback));color:var(--diffs-fg);align-items:center;gap:.25rem;padding-inline:.5rem;font-size:.75rem;line-height:1.2;display:flex}[data-merge-conflict-action]{appearance:none;color:var(--diffs-fg-number);font:inherit;cursor:pointer;background:0 0;border:0;padding:0;font-style:normal}[data-merge-conflict-action]:hover{color:var(--diffs-fg)}[data-merge-conflict-action=current]:hover{color:var(--diffs-addition-base)}[data-merge-conflict-action=incoming]:hover{color:var(--diffs-modified-base)}[data-merge-conflict-action-separator]{color:var(--diffs-fg-number);opacity:.6;user-select:none}[data-diffs-header=default]{background-color:var(--diffs-bg);justify-content:space-between;align-items:center;gap:var(--diffs-gap-inline,var(--diffs-gap-fallback));min-height:calc(1lh + (var(--diffs-gap-block,var(--diffs-gap-fallback)) * 3));z-index:2;flex-direction:row;padding-inline:16px;display:flex;position:relative;top:0}[data-header-content]{align-items:center;gap:var(--diffs-gap-inline,var(--diffs-gap-fallback));white-space:nowrap;flex-direction:row;min-width:0;display:flex}[data-header-content] [data-prev-name],[data-header-content] [data-title]{text-overflow:ellipsis;white-space:nowrap;direction:rtl;min-width:0;overflow:hidden}[data-prev-name]{opacity:.7}[data-rename-icon]{fill:currentColor;flex-grow:0;flex-shrink:0}[data-diffs-header=default] [data-metadata]{white-space:nowrap;align-items:center;gap:1ch;display:flex}[data-diffs-header=default] [data-additions-count]{font-family:var(--diffs-font-family,var(--diffs-font-fallback));color:var(--diffs-addition-base)}[data-diffs-header=default] [data-deletions-count]{font-family:var(--diffs-font-family,var(--diffs-font-fallback));color:var(--diffs-deletion-base)}[data-change-icon]{fill:currentColor;flex-shrink:0}[data-change-icon=change],[data-change-icon=rename-pure],[data-change-icon=rename-changed]{color:var(--diffs-modified-base)}[data-change-icon=new]{color:var(--diffs-addition-base)}[data-change-icon=deleted]{color:var(--diffs-deletion-base)}[data-change-icon=file]{opacity:.6}[data-annotation-content]{z-index:2;isolation:isolate;white-space:normal;align-self:flex-start;min-width:0;display:flow-root;position:relative}[data-overflow=scroll] [data-annotation-content],[data-overflow=scroll] [data-merge-conflict-actions-content]{width:var(--diffs-column-content-width,auto);left:var(--diffs-column-number-width,0);position:sticky}[data-annotation-slot]{text-wrap-mode:wrap;word-break:normal;white-space-collapse:collapse}[data-gutter-utility-slot]{touch-action:none;justify-content:flex-end;display:flex;position:absolute;top:0;bottom:0;right:0}[data-utility-button]{appearance:none;cursor:pointer;width:1lh;height:1lh;font-size:var(--diffs-font-size,13px);line-height:var(--diffs-line-height,20px);background-color:var(--diffs-modified-base);color:var(--diffs-bg);fill:currentColor;z-index:4;touch-action:none;border:none;border-radius:4px;justify-content:center;align-items:center;margin-right:calc(-1lh + 1ch);padding:0;display:flex;position:relative;&:before{content:"";display:block;position:absolute;inset:0 0 0 -4px}}[data-decoration-bar-stack]{pointer-events:none;isolation:isolate;z-index:1;background-color:var(--diffs-decoration-bar-color,transparent);box-sizing:content-box;border-left:2px solid var(--diffs-bg);border-right:2px solid var(--diffs-bg);width:6px;position:absolute;top:0;bottom:0;right:-2px;[data-decoration-bar-depth="1"] &{background-color:color-mix(in lab, var(--diffs-bg) 20%, var(--diffs-decoration-bar-color,transparent))}[data-decoration-bar-depth="2"] &{background-color:color-mix(in lab, var(--diffs-bg) 45%, var(--diffs-decoration-bar-color,transparent))}[data-decoration-bar-depth="3"] &{background-color:color-mix(in lab, var(--diffs-bg) 65%, var(--diffs-decoration-bar-color,transparent))}[data-decoration-bar-start] &{border-top-left-radius:5px;border-top-right-radius:5px}[data-decoration-bar-end] &{z-index:3;border-bottom-right-radius:5px;border-bottom-left-radius:5px}}[data-placeholder]{contain:strict}[data-error-wrapper]{padding:var(--diffs-gap-block,var(--diffs-gap-fallback)) var(--diffs-gap-inline,var(--diffs-gap-fallback));scrollbar-width:none;max-height:400px;overflow:auto;& [data-error-message]{color:var(--diffs-deletion-base);font-size:18px;font-weight:700}& [data-error-stack]{color:var(--diffs-fg-number)}}}@layer theme,rendered,unsafe;\n';
2303
+ let measuredScrollbarGutter;
2304
+ function getMeasuredScrollbarGutter(shadowRoot) {
2305
+ if (measuredScrollbarGutter != null) return measuredScrollbarGutter;
2306
+ const host = shadowRoot.host;
2307
+ if (typeof HTMLElement !== "undefined" && host instanceof HTMLElement && !host.isConnected) return;
2308
+ const wrapper = document.createElement("div");
2309
+ wrapper.setAttribute("data-code", "");
2310
+ wrapper.setAttribute(DIFFS_SCROLLBAR_MEASURE_ATTRIBUTE, "true");
2311
+ const child = document.createElement("div");
2312
+ child.style.position = "relative";
2313
+ child.style.width = "200%";
2314
+ child.style.height = "200%";
2315
+ wrapper.appendChild(child);
2316
+ shadowRoot.appendChild(wrapper);
2317
+ measuredScrollbarGutter = Math.max(wrapper.offsetHeight - wrapper.clientHeight, 0);
2318
+ wrapper.remove();
2319
+ return measuredScrollbarGutter;
2320
+ }
2321
+ function createMeasuredScrollbarGutterDeclaration(scrollbarGutter) {
2322
+ const value = scrollbarGutter == null ? "var(--diffs-scrollbar-gutter-fallback)" : `${scrollbarGutter}px`;
2323
+ return `${DIFFS_SCROLLBAR_GUTTER_MEASURED_PROPERTY}: ${value};`;
2324
+ }
2325
+ const LAYER_ORDER = `@layer base, theme, rendered, unsafe;`;
2326
+ const SCROLLBAR_GUTTER_DECLARATION_PATTERN = new RegExp(`${escapeRegExp(DIFFS_SCROLLBAR_GUTTER_MEASURED_PROPERTY)}\\s*:\\s*[^;]+;`);
2327
+ function wrapUnsafeCSS(unsafeCSS) {
2328
+ return `${LAYER_ORDER}
2329
+ @layer unsafe {
2330
+ ${unsafeCSS}
2331
+ }`;
2332
+ }
2333
+ function wrapThemeCSS(themeCSS, themeType = "system", scrollbarGutter) {
2334
+ const colorSchemeRule = themeType === "system" ? "" : `
2335
+ color-scheme: ${themeType};`;
2336
+ const scrollbarGutterVar = createMeasuredScrollbarGutterDeclaration(scrollbarGutter);
2337
+ return `${LAYER_ORDER}
2338
+ @layer rendered {
2339
+ :host {${colorSchemeRule}
2340
+ ${scrollbarGutterVar}
2341
+ ${themeCSS}
2342
+ }
2343
+ }`;
2344
+ }
2345
+ function patchScrollbarGutterSize(themeCSS, scrollbarGutter) {
2346
+ const scrollbarGutterRule = createMeasuredScrollbarGutterDeclaration(scrollbarGutter);
2347
+ return themeCSS.replace(SCROLLBAR_GUTTER_DECLARATION_PATTERN, scrollbarGutterRule);
2348
+ }
2349
+ function escapeRegExp(value) {
2350
+ return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
2351
+ }
2352
+ const lineAnnotationSources = /* @__PURE__ */ new WeakMap();
2353
+ function getLineAnnotationSource(annotation) {
2354
+ const source = lineAnnotationSources.get(annotation);
2355
+ return source == null ? annotation : source;
2356
+ }
2357
+ function recordLineAnnotationSource(moved, annotation) {
2358
+ lineAnnotationSources.set(moved, annotation);
2359
+ }
2360
+ function getOrCreateCodeNode({ code, pre, columnType, rowSpan, containerSize = false } = {}) {
2361
+ if (code == null) {
2362
+ code = document.createElement("code");
2363
+ code.setAttribute("data-code", "");
2364
+ if (columnType != null) code.setAttribute(`data-${columnType}`, "");
2365
+ pre?.appendChild(code);
2366
+ }
2367
+ if (rowSpan != null) code.style.setProperty("grid-row", `span ${rowSpan}`);
2368
+ else code.style.removeProperty("grid-row");
2369
+ if (containerSize) code.setAttribute("data-container-size", "");
2370
+ else code.removeAttribute("data-container-size");
2371
+ return code;
2372
+ }
2373
+ function prerenderHTMLIfNecessary(element, html) {
2374
+ if (html == null) return;
2375
+ const shadowRoot = element.shadowRoot ?? element.attachShadow({ mode: "open" });
2376
+ if (shadowRoot.innerHTML === "") shadowRoot.innerHTML = html;
2377
+ }
2378
+ function setPreNodeProperties(pre, { type, diffIndicators, disableBackground, disableLineNumbers, overflow, split, totalLines, customProperties }) {
2379
+ if (customProperties != null) for (const key in customProperties) {
2380
+ const value = customProperties[key];
2381
+ if (value != null) pre.setAttribute(key, `${value}`);
2382
+ }
2383
+ if (type === "diff") {
2384
+ pre.setAttribute("data-diff", "");
2385
+ pre.removeAttribute("data-file");
2386
+ } else {
2387
+ pre.setAttribute("data-file", "");
2388
+ pre.removeAttribute("data-diff");
2389
+ }
2390
+ switch (diffIndicators) {
2391
+ case "bars":
2392
+ case "classic":
2393
+ pre.setAttribute("data-indicators", diffIndicators);
2394
+ break;
2395
+ case "none":
2396
+ pre.removeAttribute("data-indicators");
2397
+ }
2398
+ if (disableLineNumbers) pre.setAttribute("data-disable-line-numbers", "");
2399
+ else pre.removeAttribute("data-disable-line-numbers");
2400
+ if (disableBackground) pre.removeAttribute("data-background");
2401
+ else pre.setAttribute("data-background", "");
2402
+ if (type === "diff") pre.setAttribute("data-diff-type", split ? "split" : "single");
2403
+ else pre.removeAttribute("data-diff-type");
2404
+ pre.setAttribute("data-overflow", overflow);
2405
+ pre.style.setProperty("--diffs-min-number-column-width-default", `${`${totalLines}`.length}ch`);
2406
+ return pre;
2407
+ }
2408
+ function isStyleNode(element) {
2409
+ if (typeof HTMLStyleElement !== "undefined" && element instanceof HTMLStyleElement) return true;
2410
+ const tagName = element.tagName ?? element.nodeName;
2411
+ return typeof tagName === "string" && tagName.toLowerCase() === "style";
2412
+ }
2413
+ let _isMacLike = void 0;
2414
+ let _isSafari = void 0;
2415
+ function isMacLike() {
2416
+ return _isMacLike ??= /macOS|MacIntel|iPhone|iPad|iPod/i.test(getPlatform());
2417
+ }
2418
+ function isSafari() {
2419
+ return _isSafari ??= "safari" in window && "pushNotification" in window.safari || /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
2420
+ }
2421
+ function getPlatform() {
2422
+ const navigator2 = globalThis.navigator;
2423
+ return navigator2?.platform ?? navigator2?.userAgentData?.platform ?? "unknown";
2424
+ }
2425
+ function adoptEditSessionAnnotations(annotations, getName, previousSession) {
2426
+ const slotNames = /* @__PURE__ */ new Map();
2427
+ for (const annotation of annotations) {
2428
+ const source = getLineAnnotationSource(annotation);
2429
+ slotNames.set(source, previousSession?.slotNames.get(source) ?? getName(annotation));
2430
+ }
2431
+ return {
2432
+ provided: annotations,
2433
+ current: annotations,
2434
+ slotNames
2435
+ };
2436
+ }
2437
+ function writeEditSessionAnnotations(session, annotations, getName) {
2438
+ for (const annotation of annotations) {
2439
+ const source = getLineAnnotationSource(annotation);
2440
+ if (!session.slotNames.has(source)) session.slotNames.set(source, getName(annotation));
2441
+ }
2442
+ session.provided = annotations;
2443
+ session.current = annotations;
2444
+ }
2445
+ function resolveEditSessionSlotName(session, annotation, getName) {
2446
+ if (session == null) return getName(annotation);
2447
+ const source = getLineAnnotationSource(annotation);
2448
+ let name = session.slotNames.get(source);
2449
+ if (name == null) {
2450
+ name = getName(annotation);
2451
+ session.slotNames.set(source, name);
2452
+ }
2453
+ return name;
2454
+ }
2455
+ function shouldUseTokenTransformer(options) {
2456
+ return options?.useTokenTransformer === true || options?.onTokenClick != null || options?.onTokenEnter != null || options?.onTokenLeave != null;
2457
+ }
2458
+ function guardWebKitScrollDuringRebuild(pre, rebuild) {
2459
+ const height = pre?.offsetHeight ?? 0;
2460
+ if (pre == null || height === 0) {
2461
+ rebuild();
2462
+ return;
2463
+ }
2464
+ pre.style.minHeight = `${height}px`;
2465
+ try {
2466
+ rebuild();
2467
+ pre.offsetHeight;
2468
+ } finally {
2469
+ pre.style.minHeight = "";
2470
+ }
2471
+ }
2472
+ function upsertHostThemeStyle({ shadowRoot, currentNode, themeCSS }) {
2473
+ if (themeCSS.trim() === "") {
2474
+ currentNode?.remove();
2475
+ return;
2476
+ }
2477
+ currentNode ??= createHostThemeStyleNode();
2478
+ currentNode.textContent = themeCSS;
2479
+ if (currentNode.parentNode !== shadowRoot) shadowRoot.appendChild(currentNode);
2480
+ return currentNode;
2481
+ }
2482
+ function createHostThemeStyleNode() {
2483
+ const node = document.createElement("style");
2484
+ node.setAttribute(THEME_CSS_ATTRIBUTE, "");
2485
+ return node;
2486
+ }
2487
+ if (typeof HTMLElement !== "undefined" && customElements.get("diffs-container") == null) {
2488
+ let sheet;
2489
+ class FileDiffContainer extends HTMLElement {
2490
+ constructor() {
2491
+ super();
2492
+ if (this.shadowRoot != null) return;
2493
+ const shadowRoot = this.attachShadow({ mode: "open" });
2494
+ if (sheet == null) {
2495
+ sheet = new CSSStyleSheet();
2496
+ sheet.replaceSync(style_default);
2497
+ }
2498
+ shadowRoot.adoptedStyleSheets = [sheet];
2499
+ }
2500
+ connectedCallback() {
2501
+ const shadowRoot = this.shadowRoot ?? this.attachShadow({ mode: "open" });
2502
+ getMeasuredScrollbarGutter(shadowRoot);
2503
+ }
2504
+ }
2505
+ customElements.define(DIFFS_TAG_NAME, FileDiffContainer);
2506
+ }
2507
+ function cloneHunks(hunks) {
2508
+ return hunks.map((hunk) => ({
2509
+ ...hunk,
2510
+ hunkContent: hunk.hunkContent.map((content) => ({ ...content }))
2511
+ }));
2512
+ }
2513
+ function cloneFileDiffMetadata(fileDiff) {
2514
+ return {
2515
+ ...fileDiff,
2516
+ hunks: cloneHunks(fileDiff.hunks),
2517
+ deletionLines: [...fileDiff.deletionLines],
2518
+ additionLines: [...fileDiff.additionLines]
2519
+ };
2520
+ }
2521
+ function areVirtualWindowSpecsEqual(windowSpecsA, windowSpecsB) {
2522
+ if (windowSpecsA == null || windowSpecsB == null) return windowSpecsA === windowSpecsB;
2523
+ return windowSpecsA.top === windowSpecsB.top && windowSpecsA.bottom === windowSpecsB.bottom;
2524
+ }
2525
+ const DEFAULT_OVERSCROLL_SIZE = 1e3;
2526
+ const INTERSECTION_OBSERVER_MARGIN = DEFAULT_OVERSCROLL_SIZE * 4;
2527
+ const INTERSECTION_OBSERVER_THRESHOLD = [
2528
+ 0,
2529
+ 1e-6,
2530
+ 0.99999,
2531
+ 1
2532
+ ];
2533
+ const DEFAULT_VIRTUALIZER_CONFIG = {
2534
+ overscrollSize: DEFAULT_OVERSCROLL_SIZE,
2535
+ intersectionObserverMargin: INTERSECTION_OBSERVER_MARGIN,
2536
+ resizeDebugging: false
2537
+ };
2538
+ let lastSize = 0;
2539
+ let instance = -1;
2540
+ var Virtualizer$1 = class Virtualizer {
2541
+ static __STOP = false;
2542
+ static __lastScrollPosition = 0;
2543
+ __id = `virtualizer-${++instance}`;
2544
+ config;
2545
+ type = "simple";
2546
+ intersectionObserver;
2547
+ scrollTop = 0;
2548
+ height = 0;
2549
+ scrollHeight = 0;
2550
+ windowSpecs = {
2551
+ top: 0,
2552
+ bottom: 0
2553
+ };
2554
+ root;
2555
+ contentContainer;
2556
+ resizeObserver;
2557
+ observers = /* @__PURE__ */ new Map();
2558
+ visibleInstances = /* @__PURE__ */ new Map();
2559
+ visibleInstancesDirty = false;
2560
+ instancesChanged = /* @__PURE__ */ new Set();
2561
+ reconcileQueue = /* @__PURE__ */ new Set();
2562
+ scrollDirty = true;
2563
+ heightDirty = true;
2564
+ scrollHeightDirty = true;
2565
+ renderedObservers = 0;
2566
+ connectQueue = /* @__PURE__ */ new Map();
2567
+ constructor(config) {
2568
+ this.config = {
2569
+ ...DEFAULT_VIRTUALIZER_CONFIG,
2570
+ ...config
2571
+ };
2572
+ }
2573
+ setup(root, contentContainer) {
2574
+ if (this.root != null) return;
2575
+ this.root = root;
2576
+ this.resizeObserver = new ResizeObserver(this.handleContainerResize);
2577
+ this.intersectionObserver = new IntersectionObserver(this.handleIntersectionChange, {
2578
+ root: this.root,
2579
+ threshold: INTERSECTION_OBSERVER_THRESHOLD,
2580
+ rootMargin: `${this.config.intersectionObserverMargin}px 0px ${this.config.intersectionObserverMargin}px 0px`
2581
+ });
2582
+ if (root instanceof Document) this.setupWindow();
2583
+ else this.setupElement(contentContainer);
2584
+ window.__INSTANCE = this;
2585
+ window.__TOGGLE = () => {
2586
+ if (Virtualizer.__STOP) {
2587
+ Virtualizer.__STOP = false;
2588
+ (this.getScrollContainerElement() ?? window).scrollTo({ top: Virtualizer.__lastScrollPosition });
2589
+ queueRender(this.computeRenderRangeAndEmit);
2590
+ } else {
2591
+ Virtualizer.__lastScrollPosition = this.getScrollTop();
2592
+ Virtualizer.__STOP = true;
2593
+ }
2594
+ };
2595
+ for (const [container, instance2] of this.connectQueue.entries()) this.connect(container, instance2);
2596
+ this.connectQueue.clear();
2597
+ this.markDOMDirty();
2598
+ queueRender(this.computeRenderRangeAndEmit);
2599
+ }
2600
+ instanceChanged(instance2, domDirty) {
2601
+ this.instancesChanged.add(instance2);
2602
+ if (domDirty) this.markDOMDirty();
2603
+ queueRender(this.computeRenderRangeAndEmit);
2604
+ }
2605
+ requestHeightReconcile(instance2) {
2606
+ this.reconcileQueue.add(instance2);
2607
+ queueRender(this.computeRenderRangeAndEmit);
2608
+ }
2609
+ getWindowSpecs() {
2610
+ if (this.windowSpecs.top === 0 && this.windowSpecs.bottom === 0) this.windowSpecs = createWindowFromScrollPosition({
2611
+ scrollTop: this.getScrollTop(),
2612
+ height: this.getHeight(),
2613
+ scrollHeight: this.getScrollHeight(),
2614
+ overscrollSize: this.config.overscrollSize
2615
+ });
2616
+ return this.windowSpecs;
2617
+ }
2618
+ getRoot() {
2619
+ return this.root;
2620
+ }
2621
+ isInstanceVisible(elementTop, elementHeight) {
2622
+ const scrollTop = this.getScrollTop();
2623
+ const height = this.getHeight();
2624
+ const margin = this.config.intersectionObserverMargin;
2625
+ const top = scrollTop - margin;
2626
+ const bottom = scrollTop + height + margin;
2627
+ return !(elementTop < top - elementHeight || elementTop > bottom);
2628
+ }
2629
+ handleContainerResize = (entries) => {
2630
+ if (this.root == null) return;
2631
+ let shouldQueueUpdate = false;
2632
+ for (const entry of entries) {
2633
+ const blockSize = entry.borderBoxSize[0].blockSize;
2634
+ if (this.root instanceof Document) {
2635
+ if (blockSize !== this.scrollHeight) {
2636
+ this.scrollHeightDirty = true;
2637
+ shouldQueueUpdate = true;
2638
+ if (this.config.resizeDebugging) {
2639
+ console.log("Virtualizer: content size change", this.__id, {
2640
+ sizeChange: blockSize - lastSize,
2641
+ newSize: blockSize
2642
+ });
2643
+ lastSize = blockSize;
2644
+ }
2645
+ }
2646
+ } else if (entry.target === this.root) {
2647
+ if (blockSize !== this.height) {
2648
+ this.heightDirty = true;
2649
+ shouldQueueUpdate = true;
2650
+ }
2651
+ } else if (entry.target === this.contentContainer) {
2652
+ this.scrollHeightDirty = true;
2653
+ shouldQueueUpdate = true;
2654
+ if (this.config.resizeDebugging) {
2655
+ console.log("Virtualizer: scroller size change", this.__id, {
2656
+ sizeChange: blockSize - lastSize,
2657
+ newSize: blockSize
2658
+ });
2659
+ lastSize = blockSize;
2660
+ }
2661
+ }
2662
+ }
2663
+ if (shouldQueueUpdate) queueRender(this.computeRenderRangeAndEmit);
2664
+ };
2665
+ setupWindow() {
2666
+ if (this.root == null || !(this.root instanceof Document)) throw new Error("Virtualizer.setupWindow: Invalid setup method");
2667
+ window.addEventListener("scroll", this.handleWindowScroll, { passive: true });
2668
+ window.addEventListener("resize", this.handleWindowResize, { passive: true });
2669
+ this.resizeObserver?.observe(this.root.documentElement);
2670
+ }
2671
+ setupElement(contentContainer) {
2672
+ if (this.root == null || this.root instanceof Document) throw new Error("Virtualizer.setupElement: Invalid setup method");
2673
+ this.root.addEventListener("scroll", this.handleElementScroll, { passive: true });
2674
+ this.resizeObserver?.observe(this.root);
2675
+ contentContainer ??= this.root.firstElementChild ?? void 0;
2676
+ if (contentContainer instanceof HTMLElement) {
2677
+ this.contentContainer = contentContainer;
2678
+ this.resizeObserver?.observe(contentContainer);
2679
+ }
2680
+ }
2681
+ cleanUp() {
2682
+ dequeueRender(this.computeRenderRangeAndEmit);
2683
+ this.resizeObserver?.disconnect();
2684
+ this.resizeObserver = void 0;
2685
+ this.intersectionObserver?.disconnect();
2686
+ this.intersectionObserver = void 0;
2687
+ this.root?.removeEventListener("scroll", this.handleElementScroll);
2688
+ window.removeEventListener("scroll", this.handleWindowScroll);
2689
+ window.removeEventListener("resize", this.handleWindowResize);
2690
+ this.root = void 0;
2691
+ this.contentContainer = void 0;
2692
+ this.observers.clear();
2693
+ this.visibleInstances.clear();
2694
+ this.instancesChanged.clear();
2695
+ this.reconcileQueue.clear();
2696
+ this.connectQueue.clear();
2697
+ this.visibleInstancesDirty = false;
2698
+ this.windowSpecs = {
2699
+ top: 0,
2700
+ bottom: 0
2701
+ };
2702
+ this.scrollTop = 0;
2703
+ this.height = 0;
2704
+ this.scrollHeight = 0;
2705
+ this.scrollDirty = true;
2706
+ this.heightDirty = true;
2707
+ this.scrollHeightDirty = true;
2708
+ }
2709
+ getOffsetInScrollContainer(element) {
2710
+ return this.getScrollTop() + getRelativeBoundingTop(element, this.getScrollContainerElement());
2711
+ }
2712
+ connect(container, instance2) {
2713
+ if (this.observers.has(container)) throw new Error("Virtualizer.connect: instance is already connected...");
2714
+ if (this.intersectionObserver == null) this.connectQueue.set(container, instance2);
2715
+ else {
2716
+ this.intersectionObserver.observe(container);
2717
+ this.observers.set(container, instance2);
2718
+ this.instancesChanged.add(instance2);
2719
+ this.markDOMDirty();
2720
+ queueRender(this.computeRenderRangeAndEmit);
2721
+ }
2722
+ return () => this.disconnect(container);
2723
+ }
2724
+ disconnect(container) {
2725
+ const instance2 = this.observers.get(container);
2726
+ this.connectQueue.delete(container);
2727
+ if (instance2 == null) return;
2728
+ this.intersectionObserver?.unobserve(container);
2729
+ this.observers.delete(container);
2730
+ this.instancesChanged.delete(instance2);
2731
+ this.reconcileQueue.delete(instance2);
2732
+ if (this.visibleInstances.delete(container)) this.visibleInstancesDirty = true;
2733
+ this.markDOMDirty();
2734
+ queueRender(this.computeRenderRangeAndEmit);
2735
+ }
2736
+ handleWindowResize = () => {
2737
+ if (Virtualizer.__STOP || window.innerHeight === this.height) return;
2738
+ this.heightDirty = true;
2739
+ queueRender(this.computeRenderRangeAndEmit);
2740
+ };
2741
+ handleWindowScroll = () => {
2742
+ if (Virtualizer.__STOP || this.root == null || !(this.root instanceof Document)) return;
2743
+ this.scrollDirty = true;
2744
+ queueRender(this.computeRenderRangeAndEmit);
2745
+ };
2746
+ handleElementScroll = () => {
2747
+ if (Virtualizer.__STOP || this.root == null || this.root instanceof Document) return;
2748
+ this.scrollDirty = true;
2749
+ queueRender(this.computeRenderRangeAndEmit);
2750
+ };
2751
+ computeRenderRangeAndEmit = () => {
2752
+ if (Virtualizer.__STOP) return;
2753
+ const wrapperDirty = this.heightDirty || this.scrollHeightDirty;
2754
+ let instancesHaveChanged = this.instancesChanged.size > 0;
2755
+ if (this.instancesChanged.size === 0) {
2756
+ const windowSpecs = createWindowFromScrollPosition({
2757
+ scrollTop: this.getScrollTop(),
2758
+ height: this.getHeight(),
2759
+ scrollHeight: this.getScrollHeight(),
2760
+ overscrollSize: this.config.overscrollSize
2761
+ });
2762
+ if (!wrapperDirty && areVirtualWindowSpecsEqual(this.windowSpecs, windowSpecs) && this.renderedObservers === this.observers.size && !this.visibleInstancesDirty && this.reconcileQueue.size === 0) return;
2763
+ this.windowSpecs = windowSpecs;
2764
+ }
2765
+ this.visibleInstancesDirty = false;
2766
+ this.renderedObservers = this.observers.size;
2767
+ const anchor = this.getScrollAnchor(this.height);
2768
+ const updatedInstances = /* @__PURE__ */ new Set();
2769
+ for (const instance2 of wrapperDirty ? this.observers.values() : this.visibleInstances.values()) if (instance2.onRender(wrapperDirty)) updatedInstances.add(instance2);
2770
+ for (const instance2 of this.instancesChanged) {
2771
+ if (updatedInstances.has(instance2)) continue;
2772
+ if (instance2.onRender(wrapperDirty)) updatedInstances.add(instance2);
2773
+ }
2774
+ this.scrollFix(anchor);
2775
+ for (const instance2 of updatedInstances) {
2776
+ this.reconcileQueue.delete(instance2);
2777
+ instance2.reconcileHeights();
2778
+ }
2779
+ for (const instance2 of this.reconcileQueue) if (instance2.reconcileHeights()) instancesHaveChanged = true;
2780
+ this.reconcileQueue.clear();
2781
+ instancesHaveChanged ||= this.instancesChanged.size > 0;
2782
+ if (instancesHaveChanged) this.markDOMDirty();
2783
+ if (instancesHaveChanged || wrapperDirty) queueRender(this.computeRenderRangeAndEmit);
2784
+ updatedInstances.clear();
2785
+ this.instancesChanged.clear();
2786
+ };
2787
+ scrollFix(anchor) {
2788
+ if (anchor == null) return;
2789
+ const scrollContainer = this.getScrollContainerElement();
2790
+ const { lineIndex, lineOffset, fileElement, fileOffset, fileTypeOffset } = anchor;
2791
+ if (lineIndex != null && lineOffset != null) {
2792
+ const element = fileElement.shadowRoot?.querySelector(`[data-line][data-line-index="${lineIndex}"]`);
2793
+ if (element instanceof HTMLElement) {
2794
+ const top2 = getRelativeBoundingTop(element, scrollContainer);
2795
+ if (top2 !== lineOffset) {
2796
+ const scrollOffset = top2 - lineOffset;
2797
+ this.applyScrollFix(scrollOffset);
2798
+ }
2799
+ return;
2800
+ }
2801
+ }
2802
+ const top = getRelativeBoundingTop(fileElement, scrollContainer);
2803
+ if (fileTypeOffset === "top") {
2804
+ if (top !== fileOffset) this.applyScrollFix(top - fileOffset);
2805
+ } else {
2806
+ const bottom = top + fileElement.getBoundingClientRect().height;
2807
+ if (bottom !== fileOffset) this.applyScrollFix(bottom - fileOffset);
2808
+ }
2809
+ }
2810
+ applyScrollFix(scrollOffset) {
2811
+ if (this.root == null || this.root instanceof Document) window.scrollTo({
2812
+ top: window.scrollY + scrollOffset,
2813
+ behavior: "instant"
2814
+ });
2815
+ else this.root.scrollTo({
2816
+ top: this.root.scrollTop + scrollOffset,
2817
+ behavior: "instant"
2818
+ });
2819
+ this.markDOMDirty();
2820
+ }
2821
+ getScrollAnchor(viewportHeight) {
2822
+ const scrollContainer = this.getScrollContainerElement();
2823
+ let bestAnchor;
2824
+ for (const [fileElement] of this.visibleInstances.entries()) {
2825
+ const fileTop = getRelativeBoundingTop(fileElement, scrollContainer);
2826
+ const fileBottom = fileTop + fileElement.offsetHeight;
2827
+ let fileOffset;
2828
+ let fileTypeOffset;
2829
+ if (fileBottom <= 0) {
2830
+ fileOffset = fileBottom;
2831
+ fileTypeOffset = "bottom";
2832
+ } else {
2833
+ fileOffset = fileTop;
2834
+ fileTypeOffset = "top";
2835
+ }
2836
+ let bestLineIndex;
2837
+ let bestLineOffset;
2838
+ if (fileBottom > 0 && fileTop < viewportHeight) for (const line of fileElement.shadowRoot?.querySelectorAll("[data-line][data-line-index]") ?? []) {
2839
+ if (!(line instanceof HTMLElement)) continue;
2840
+ const lineIndex = line.dataset.lineIndex;
2841
+ if (lineIndex == null) continue;
2842
+ const lineOffset = getRelativeBoundingTop(line, scrollContainer);
2843
+ if (lineOffset < 0) continue;
2844
+ bestLineIndex = lineIndex;
2845
+ bestLineOffset = lineOffset;
2846
+ break;
2847
+ }
2848
+ if (bestAnchor?.lineOffset != null && bestLineOffset == null) continue;
2849
+ let shouldReplace = false;
2850
+ if (bestAnchor == null) shouldReplace = true;
2851
+ else if (bestLineOffset != null && (bestAnchor.lineOffset == null || bestLineOffset < bestAnchor.lineOffset)) shouldReplace = true;
2852
+ else if (bestLineOffset == null && bestAnchor.lineOffset == null) {
2853
+ if (fileOffset >= 0 && (bestAnchor.fileOffset < 0 || fileOffset < bestAnchor.fileOffset)) shouldReplace = true;
2854
+ else if (fileOffset < 0 && bestAnchor.fileOffset < 0 && fileOffset > bestAnchor.fileOffset) shouldReplace = true;
2855
+ }
2856
+ if (shouldReplace) bestAnchor = {
2857
+ fileElement,
2858
+ fileTypeOffset,
2859
+ fileOffset,
2860
+ lineIndex: bestLineIndex,
2861
+ lineOffset: bestLineOffset
2862
+ };
2863
+ }
2864
+ return bestAnchor;
2865
+ }
2866
+ handleIntersectionChange = (entries) => {
2867
+ this.scrollDirty = true;
2868
+ for (const { target, isIntersecting } of entries) {
2869
+ if (!(target instanceof HTMLElement)) throw new Error("Virtualizer.handleIntersectionChange: target not an HTMLElement");
2870
+ const instance2 = this.observers.get(target);
2871
+ if (instance2 == null) continue;
2872
+ if (isIntersecting && !this.visibleInstances.has(target)) {
2873
+ instance2.setVisibility(true);
2874
+ this.visibleInstances.set(target, instance2);
2875
+ this.visibleInstancesDirty = true;
2876
+ } else if (!isIntersecting && this.visibleInstances.has(target)) {
2877
+ instance2.setVisibility(false);
2878
+ this.visibleInstances.delete(target);
2879
+ this.visibleInstancesDirty = true;
2880
+ }
2881
+ }
2882
+ if (this.visibleInstancesDirty) queueRender(this.computeRenderRangeAndEmit);
2883
+ };
2884
+ /** Return the logical vertical position for the scroll container */
2885
+ getScrollTop() {
2886
+ if (!this.scrollDirty) return this.scrollTop;
2887
+ this.scrollDirty = false;
2888
+ let scrollTop = (() => {
2889
+ if (this.root == null) return 0;
2890
+ if (this.root instanceof Document) return window.scrollY;
2891
+ return this.root.scrollTop;
2892
+ })();
2893
+ scrollTop = this.clampScrollTop(scrollTop);
2894
+ this.scrollTop = scrollTop;
2895
+ return scrollTop;
2896
+ }
2897
+ /** Scroll to a logical vertical position and queue the normal render pass. */
2898
+ scrollTo({ top, behavior = "auto" }) {
2899
+ const { root } = this;
2900
+ if (root == null) return;
2901
+ const scrollTop = this.clampScrollTop(top);
2902
+ if (root instanceof Document) window.scrollTo({
2903
+ top: scrollTop,
2904
+ behavior
2905
+ });
2906
+ else root.scrollTo({
2907
+ top: scrollTop,
2908
+ behavior
2909
+ });
2910
+ this.scrollDirty = true;
2911
+ queueRender(this.computeRenderRangeAndEmit);
2912
+ }
2913
+ clampScrollTop(scrollTop) {
2914
+ return Math.max(0, Math.min(scrollTop, this.getScrollHeight() - this.getHeight()));
2915
+ }
2916
+ getScrollHeight() {
2917
+ if (!this.scrollHeightDirty) return this.scrollHeight;
2918
+ this.scrollHeightDirty = false;
2919
+ this.scrollHeight = (() => {
2920
+ if (this.root == null) return 0;
2921
+ if (this.root instanceof Document) return this.root.documentElement.scrollHeight;
2922
+ return this.root.scrollHeight;
2923
+ })();
2924
+ return this.scrollHeight;
2925
+ }
2926
+ getHeight() {
2927
+ if (!this.heightDirty) return this.height;
2928
+ this.heightDirty = false;
2929
+ this.height = (() => {
2930
+ if (this.root == null) return 0;
2931
+ if (this.root instanceof Document) return globalThis.innerHeight;
2932
+ return this.root.getBoundingClientRect().height;
2933
+ })();
2934
+ return this.height;
2935
+ }
2936
+ markDOMDirty() {
2937
+ this.scrollDirty = true;
2938
+ this.scrollHeightDirty = true;
2939
+ this.heightDirty = true;
2940
+ }
2941
+ getScrollContainerElement() {
2942
+ return this.root == null || this.root instanceof Document ? void 0 : this.root;
2943
+ }
2944
+ };
2945
+ function getRelativeBoundingTop(element, scrollContainer) {
2946
+ const rect = element.getBoundingClientRect();
2947
+ const scrollContainerTop = scrollContainer?.getBoundingClientRect().top ?? 0;
2948
+ return rect.top - scrollContainerTop;
2949
+ }
2950
+ function useStableCallback(callback) {
2951
+ const callbackRef = reactExports.useRef(callback);
2952
+ reactExports.useInsertionEffect(() => void (callbackRef.current = callback));
2953
+ return reactExports.useCallback((...args) => {
2954
+ return callbackRef.current(...args);
2955
+ }, []);
2956
+ }
2957
+ const EditContext = reactExports.createContext(void 0);
2958
+ function EditProvider({ children, createEditor }) {
2959
+ const stableCreateEditor = useStableCallback((editorType, options, editStateKey) => createEditor(editorType, options, editStateKey));
2960
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(EditContext.Provider, {
2961
+ value: stableCreateEditor,
2962
+ children
2963
+ });
2964
+ }
2965
+ function useCreateEditor() {
2966
+ return reactExports.useContext(EditContext);
2967
+ }
2968
+ const GutterUtilitySlotStyles = {
2969
+ position: "absolute",
2970
+ top: 0,
2971
+ bottom: 0,
2972
+ textAlign: "center",
2973
+ whiteSpace: "normal",
2974
+ touchAction: "none"
2975
+ };
2976
+ const MergeConflictSlotStyles = { display: "contents" };
2977
+ function noopRender() {
2978
+ return null;
2979
+ }
2980
+ function templateRender(children, __html) {
2981
+ if (typeof window === "undefined" && __html != null) return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [/* @__PURE__ */ jsxRuntimeExports.jsx("template", {
2982
+ shadowrootmode: "open",
2983
+ dangerouslySetInnerHTML: { __html }
2984
+ }), children] });
2985
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children });
2986
+ }
2987
+ const VirtualizerContext = reactExports.createContext(void 0);
2988
+ function Virtualizer2({ children, config, className, style, contentClassName, contentStyle }) {
2989
+ const [instance2] = reactExports.useState(() => {
2990
+ return typeof window !== "undefined" ? new Virtualizer$1(config) : void 0;
2991
+ });
2992
+ const ref = reactExports.useCallback((node) => {
2993
+ if (node != null) instance2?.setup(node);
2994
+ else instance2?.cleanUp();
2995
+ }, [instance2]);
2996
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(VirtualizerContext.Provider, {
2997
+ value: instance2,
2998
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", {
2999
+ className,
3000
+ style,
3001
+ ref,
3002
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", {
3003
+ className: contentClassName,
3004
+ style: contentStyle,
3005
+ children
3006
+ })
3007
+ })
3008
+ });
3009
+ }
3010
+ function useVirtualizer() {
3011
+ return reactExports.useContext(VirtualizerContext);
3012
+ }
3013
+ const REVEAL_FALLBACK_MS = 250;
3014
+ const timers = /* @__PURE__ */ new WeakMap();
3015
+ function reveal(host) {
3016
+ clearTimeout(timers.get(host));
3017
+ timers.delete(host);
3018
+ host.removeAttribute("data-zg-pending");
3019
+ }
3020
+ function revealOnHighlight(host, highlighted, phase, colors = true) {
3021
+ if (phase === "unmount") {
3022
+ reveal(host);
3023
+ host.removeAttribute("data-zg-held");
3024
+ host.removeAttribute("data-zg-highlight");
3025
+ return;
3026
+ }
3027
+ if (!highlighted && colors) host.setAttribute("data-zg-highlight", "pending");
3028
+ else host.removeAttribute("data-zg-highlight");
3029
+ if (phase === "mount") {
3030
+ if (highlighted) return;
3031
+ host.setAttribute("data-zg-held", "");
3032
+ host.setAttribute("data-zg-pending", "");
3033
+ timers.set(
3034
+ host,
3035
+ setTimeout(() => reveal(host), REVEAL_FALLBACK_MS)
3036
+ );
3037
+ return;
3038
+ }
3039
+ if (highlighted && host.hasAttribute("data-zg-pending")) reveal(host);
3040
+ }
3041
+ function scrollReachOnRender(host, scrolls, phase) {
3042
+ if (phase === "unmount") return;
3043
+ for (const code of host.shadowRoot?.querySelectorAll("code[data-code]") ?? []) {
3044
+ if (scrolls && !code.querySelector('[contenteditable="true"]')) {
3045
+ if (code.tabIndex !== 0) code.tabIndex = 0;
3046
+ } else if (code.hasAttribute("tabindex")) {
3047
+ code.removeAttribute("tabindex");
3048
+ }
3049
+ }
3050
+ }
3051
+ function useDetachCleanup() {
3052
+ const host = reactExports.useRef(null);
3053
+ const stash = reactExports.useRef(/* @__PURE__ */ new Map());
3054
+ reactExports.useLayoutEffect(() => {
3055
+ for (const [root, children] of stash.current) {
3056
+ if (root.childElementCount === 0) root.append(...children);
3057
+ }
3058
+ stash.current.clear();
3059
+ const el = host.current;
3060
+ return () => {
3061
+ if (!el) return;
3062
+ for (const c of el.querySelectorAll("diffs-container")) {
3063
+ const root = c.shadowRoot;
3064
+ if (!root) continue;
3065
+ stash.current.set(root, Array.from(root.childNodes));
3066
+ root.replaceChildren();
3067
+ }
3068
+ };
3069
+ }, []);
3070
+ return host;
3071
+ }
3072
+ export {
3073
+ dequeueRender as $,
3074
+ upsertHostThemeStyle as A,
3075
+ wrapThemeCSS as B,
3076
+ patchScrollbarGutterSize as C,
3077
+ isSafari as D,
3078
+ getOrCreateCodeNode as E,
3079
+ FindBar as F,
3080
+ guardWebKitScrollDuringRebuild as G,
3081
+ isStyleNode as H,
3082
+ InteractionManager as I,
3083
+ arePrePropertiesEqual as J,
3084
+ setPreNodeProperties as K,
3085
+ areObjectsEqual as L,
3086
+ areOptionsEqual as M,
3087
+ includesFileAnnotations as N,
3088
+ FILE_ANNOTATION_DOM_KEY as O,
3089
+ GutterUtilitySlotStyles as P,
3090
+ useVirtualizer as Q,
3091
+ ResizeManager as R,
3092
+ SVGSpriteSheet as S,
3093
+ useCreateEditor as T,
3094
+ useStableCallback as U,
3095
+ noopRender as V,
3096
+ templateRender as W,
3097
+ isMacLike as X,
3098
+ recordLineAnnotationSource as Y,
3099
+ getLineAnnotationSource as Z,
3100
+ cloneHunks as _,
3101
+ areFileTargetsEqual as a,
3102
+ queueRender as a0,
3103
+ isGutterUtilityPath as a1,
3104
+ useDetachCleanup as a2,
3105
+ revealOnHighlight as a3,
3106
+ scrollReachOnRender as a4,
3107
+ EditProvider as a5,
3108
+ Virtualizer2 as a6,
3109
+ fileLines as a7,
3110
+ cloneFileDiffMetadata as a8,
3111
+ MergeConflictSlotStyles as a9,
3112
+ REVEAL_FALLBACK_MS as aa,
3113
+ applyLineTextWithNewline as b,
3114
+ areRenderRangesEqual as c,
3115
+ diffLines as d,
3116
+ shouldRenderFileAnnotations as e,
3117
+ getFileAnnotations as f,
3118
+ getLineAnnotationName as g,
3119
+ createAnnotationElement as h,
3120
+ isDefaultRenderRange as i,
3121
+ createFileHeaderElement as j,
3122
+ createContentColumn as k,
3123
+ getHighlighterOptions as l,
3124
+ createPreElement as m,
3125
+ shouldUseTokenTransformer as n,
3126
+ adoptEditSessionAnnotations as o,
3127
+ pluckInteractionOptions as p,
3128
+ prerenderHTMLIfNecessary as q,
3129
+ resolveEditSessionSlotName as r,
3130
+ settleScroll as s,
3131
+ createAnnotationWrapperNode as t,
3132
+ useFind as u,
3133
+ createGutterUtilityContentNode as v,
3134
+ writeEditSessionAnnotations as w,
3135
+ createUnsafeCSSStyleNode as x,
3136
+ wrapUnsafeCSS as y,
3137
+ getMeasuredScrollbarGutter as z
3138
+ };