@davmash/bygone 0.9.8 → 0.10.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 (68) hide show
  1. package/CHANGELOG.md +26 -1
  2. package/README.md +74 -1
  3. package/cli/commandSpec.js +2 -0
  4. package/cli/completions.js +3 -3
  5. package/cli/present.js +41 -14
  6. package/cli/tour.js +22 -1
  7. package/cli/tourExport.js +147 -0
  8. package/cli/tourFile.js +109 -4
  9. package/cli/tourHistory.js +31 -1
  10. package/completions/_bygone +1 -1
  11. package/completions/bygone +1 -1
  12. package/completions/bygone.fish +1 -1
  13. package/docs/change-tour-format.md +85 -68
  14. package/docs/explore.md +14 -3
  15. package/docs/generating-change-tours.md +84 -46
  16. package/docs/present.md +103 -14
  17. package/docs/product-surface.md +19 -8
  18. package/docs/sharing-tours.md +95 -0
  19. package/docs/visual-walkthrough/README.md +89 -0
  20. package/docs/visual-walkthrough/build-tour.mjs +54 -0
  21. package/docs/visual-walkthrough/capture-desktop.cjs +42 -0
  22. package/docs/visual-walkthrough/capture-desktop.mjs +21 -0
  23. package/docs/visual-walkthrough/captures.md +49 -0
  24. package/docs/visual-walkthrough/create-demo.mjs +57 -0
  25. package/docs/visual-walkthrough/deconstructed-demo.bygone +100 -0
  26. package/docs/visual-walkthrough/images/01-two-files.png +0 -0
  27. package/docs/visual-walkthrough/images/02-many-panels.png +0 -0
  28. package/docs/visual-walkthrough/images/03-directories.png +0 -0
  29. package/docs/visual-walkthrough/images/04-search.png +0 -0
  30. package/docs/visual-walkthrough/images/05-repository-history.png +0 -0
  31. package/docs/visual-walkthrough/images/06-file-history.png +0 -0
  32. package/docs/visual-walkthrough/images/07-branch-review.png +0 -0
  33. package/docs/visual-walkthrough/images/08-tour-reader.png +0 -0
  34. package/docs/visual-walkthrough/images/09-focused-step.png +0 -0
  35. package/docs/visual-walkthrough/images/10-deconstructed.png +0 -0
  36. package/docs/visual-walkthrough/images/11-exploration.png +0 -0
  37. package/docs/visual-walkthrough/images/12-authoring.png +0 -0
  38. package/docs/visual-walkthrough/images/13-export.png +0 -0
  39. package/docs/visual-walkthrough/images/14-vscode.png +0 -0
  40. package/docs/visual-walkthrough/images/15-cli.png +0 -0
  41. package/docs/visual-walkthrough/narrative.md +134 -0
  42. package/docs/visual-walkthrough/outline.md +52 -0
  43. package/docs/visual-walkthrough/walkthrough.bygone +340 -0
  44. package/docs/walkthrough.md +6 -101
  45. package/examples/bygone-history.bygone +11 -44
  46. package/examples/marker-focus.bygone +116 -0
  47. package/examples/navigation-lab.bygone.yaml +401 -336
  48. package/examples/tour-orientation.bygone +349 -0
  49. package/media/diff.worker.js +13 -3
  50. package/media/webview.css +1 -1
  51. package/media/webview.js +394 -319
  52. package/out/changeTour.js +865 -397
  53. package/out/deepLink.js +167 -0
  54. package/out/historyDirectory.js +66 -0
  55. package/out/standalone-main.js +20532 -16832
  56. package/out/tourCoverage.js +850 -386
  57. package/out/tourDocument.js +97 -0
  58. package/package.json +1 -1
  59. package/schemas/change-tour-source.schema.json +91 -64
  60. package/skills/pr-tour-guide/SKILL.md +144 -128
  61. package/skills/pr-tour-guide/references/expectations-and-feedback.md +57 -0
  62. package/standalone/index.html +10 -25
  63. package/web/export-bootstrap.js +62 -0
  64. package/web/export-licenses.txt +78 -0
  65. package/web/export-runtime.json +12 -0
  66. package/web/index.html +54 -47
  67. package/web/presenter.css +332 -178
  68. package/web/web-host.js +239 -137
@@ -0,0 +1,349 @@
1
+ version: 5
2
+ title: Explain the change without losing the reader
3
+ opening:
4
+ title: Give each stop a reason to exist
5
+ summary: >-
6
+ A Bygone tour should explain what a change does and why its evidence matters. This branch
7
+ addresses two sources of confusion: explanations that oscillate between sparse claims and scope
8
+ dumps, and a viewer that can make a new topic look like a new comparison. First we’ll trace how
9
+ purpose and comparison become explicit; then how navigation preserves the thread of the
10
+ argument. Every scene here uses the same before-and-after revisions.
11
+ conclusion:
12
+ title: Less repetition, more reasoning—and a visible way through
13
+ summary: >-
14
+ The branch gives authors an opening and conclusion, makes scene landings preview relevant
15
+ evidence, and distinguishes a changed file from changed revisions. Back and Next traverse the
16
+ explanation; constructed stages retain every code focus while telling their story once. Tests
17
+ check comparison identity, navigation order, narration, and a cancellation failure exposed by
18
+ switching code. Those checks establish mechanics, not that a reader understands the change. The
19
+ remaining test is whether someone can explain the outcome and its cause after this tour.
20
+ range:
21
+ base: 1e2e7b0392f205294fd98111409d3925d863b44e
22
+ head: 2ddf51c6e968bb1e5bc827213eef00665a213488
23
+ anchors:
24
+ causal-writing:
25
+ file: skills/pr-tour-guide/SKILL.md
26
+ revision: head
27
+ contains: |-
28
+ - Connect the observable outcome to its mechanism and supporting evidence in
29
+ the main reading path. Preserve the causal links when shortening prose;
30
+ “ignores layout events” is less useful than explaining why skipping scroll
31
+ synchronization prevents a layout event from undoing a code reveal.
32
+ bookends:
33
+ file: src/tourFraming.ts
34
+ revision: head
35
+ contains: |-
36
+ /** Authored bookends belong to a narrative, independently of its evidence scenes. */
37
+ export interface TourPassage {
38
+ title: string;
39
+ summary: string;
40
+ bullets?: string[];
41
+ }
42
+
43
+ export interface ChangeTourFraming {
44
+ opening?: TourPassage;
45
+ conclusion?: TourPassage;
46
+ }
47
+ reading-end:
48
+ file: src/tourReading.ts
49
+ revision: head
50
+ contains: |2-
51
+ if (tour.conclusion) items.push({ kind: 'conclusion', key: 'conclusion', sceneIndex: -1, stepIndex: 0 });
52
+ return items;
53
+ scene-preview:
54
+ file: src/tourOrientation.ts
55
+ revision: head
56
+ contains: |-
57
+ export function tourLanding(tour: ChangeTourManifest, item: TourReadingItem): TourLanding {
58
+ if (item.kind === 'title' || item.kind === 'chapter' || item.kind === 'conclusion') return 'narrative';
59
+ const scene = tour.scenes[item.sceneIndex];
60
+ if (!scene || scene.kind === 'discussion') return 'narrative';
61
+ if (item.kind === 'step' || scene.kind === 'text-diff') return 'evidence';
62
+ return scene.overview ? 'overview' : 'preview';
63
+ }
64
+ actual-evidence:
65
+ file: web/host.js
66
+ revision: head
67
+ contains: |2-
68
+ // Panel selection describes rendered evidence even while the reader stays
69
+ // on an intro, chapter, or conclusion with no evidence of its own.
70
+ const evidenceItem = activePairIndex === undefined ? item : {
71
+ kind: 'step', sceneIndex: state.activeSceneIndex, stepIndex: state.activeStepIndex
72
+ };
73
+ const evidenceContext = evidenceItem && resolveTourEvidenceContext(state.tour, evidenceItem, state.zoom?.mode, activePairIndex);
74
+ const context = rangeOnly || !evidenceContext ? resolveTourRangeEvidenceContext(state.tour, filePath) : evidenceContext;
75
+ const displayedContext = { ...context, scope: filePath, scopeKey: JSON.stringify([filePath]), overview: false };
76
+ const previous = lastReadingEvidence?.tour === state.tour ? lastReadingEvidence.context : null;
77
+ const comparison = previous && (previous.comparisonKey !== displayedContext.comparisonKey || previous.scopeKey !== displayedContext.scopeKey)
78
+ ? describeTourTransition(previous, displayedContext) : describeTourComparison(displayedContext);
79
+ // Remember the actual rendered pair, including user-selected panels and file exploration.
80
+ lastReadingEvidence = { tour: state.tour, context: displayedContext };
81
+ comparison-proof:
82
+ file: test/tourFraming.test.js
83
+ revision: head
84
+ contains: |2-
85
+ tour.scenes[0].steps[0].diff.path = 'other.ts';
86
+ const scopeChange = resolveTourEvidenceContext(tour, intro);
87
+ assert.match(describeTourTransition(initial, scopeChange), /Same revision comparison; file changed from app.ts to other.ts/);
88
+ tour.range.baseRef = 'Different name';
89
+ assert.equal(initial.comparisonKey, resolveTourEvidenceContext(tour, intro).comparisonKey);
90
+ const reversed = clone(tour); [reversed.range.mergeBaseOid, reversed.range.headOid] = [tour.range.headOid, tour.range.mergeBaseOid];
91
+ assert.notEqual(initial.comparisonKey, resolveTourEvidenceContext(reversed, intro).comparisonKey);
92
+ tour.range.headOid = 'c'.repeat(40);
93
+ const changed = resolveTourEvidenceContext(tour, intro);
94
+ assert.notEqual(initial.comparisonKey, changed.comparisonKey, 'Same labels do not hide different OIDs');
95
+ assert.match(describeTourTransition(initial, changed), /Revision comparison changed/);
96
+ linear-navigation:
97
+ file: web/host.js
98
+ revision: head
99
+ contains: |2-
100
+ function showTourLinear(direction) {
101
+ if (!isNarrativeMode()) return false;
102
+ const target = getTourReadingTarget(readingItems, state.readingKey, direction, isImageOnlyTour(state.tour));
103
+ if (!target) return false;
104
+ activateReadingItem(target, false, true);
105
+ return true;
106
+ }
107
+ navigation-proof:
108
+ file: standalone/exportSmoke.js
109
+ revision: head
110
+ contains: |2-
111
+ await advance('tour-next', 'chapter:chapter');
112
+ await advance('tour-next', 'scene:scene');
113
+ await advance('tour-next', 'step:scene:step');
114
+ await advance('tour-next', 'conclusion');
115
+ assert.equal(await evaluate("document.querySelector('#tour-next').disabled"), true);
116
+ await advance('tour-back', 'step:scene:step');
117
+ await advance('tour-back', 'scene:scene');
118
+ await advance('tour-back', 'chapter:chapter');
119
+ await advance('tour-back', 'title');
120
+ stage-once:
121
+ file: src/changeTour.ts
122
+ revision: head
123
+ contains: |2-
124
+ title: focusIndex === 0
125
+ ? stage.title
126
+ : `${focus.file} · Evidence ${focusIndex + 1} of ${focuses.length}`,
127
+ // A stage is one argument supported by multiple code focuses.
128
+ // Keep its explanation once in the reading/narration sequence.
129
+ body: focusIndex === 0 ? stage.narration : '',
130
+ file: focus.file,
131
+ pairIndex: stageIndex,
132
+ stage-recovery:
133
+ file: web/host.js
134
+ revision: head
135
+ contains: |2-
136
+ if (scene.kind === 'deconstructed-diff' && !step.body) {
137
+ const firstStepIndex = scene.steps.findIndex(candidate => candidate.pairIndex === step.pairIndex);
138
+ if (firstStepIndex >= 0 && firstStepIndex < item.stepIndex) {
139
+ const explanation = readingItems.find(candidate => candidate.kind === 'step'
140
+ && candidate.sceneIndex === item.sceneIndex && candidate.stepIndex === firstStepIndex);
141
+ const button = readingButton('Read stage explanation', `Read ${scene.steps[firstStepIndex].title}`, () => activateReadingItem(explanation));
142
+ button.className = 'tour-show-in-code tour-stage-explanation';
143
+ element.append(button);
144
+ }
145
+ }
146
+ stage-proof:
147
+ file: test/runTests.js
148
+ revision: head
149
+ contains: |2-
150
+ const spoken = manifestScene.steps.flatMap((_, index) => narrationFor(index, 'continuous'));
151
+ for (const stage of scene.stages) {
152
+ assert.equal(spoken.filter(segment => segment.text === stage.narration).length, 1);
153
+ }
154
+ assert.equal(spoken.some(segment => segment.source.field === 'stage-title'), false);
155
+ assert.equal(narrationFor(3, 'playback-start').find(segment => segment.source.field === 'stage-title').text,
156
+ 'Stage 2: Finish the behavior');
157
+ assert.equal(narrationFor(3, 'playback-start').some(segment => segment.source.field === 'step-body'), false);
158
+ highlight-cancel:
159
+ file: media/script.js
160
+ revision: head
161
+ contains: |-
162
+ function handlePendingWordHighlightCancellation(editor) {
163
+ // Monaco 0.55's word highlighter ignores the promise from its cursor Delayer.
164
+ // Model replacement and editor disposal cancel it. Handle only that pending
165
+ // operation's expected cancellation, without hiding other renderer failures.
166
+ const pending = editor.getContribution('editor.contrib.wordHighlighter')
167
+ ?.wordHighlighter?.runDelayer?.completionPromise;
168
+ void pending?.catch(error => {
169
+ if (!isCancellationError(error)) throw error;
170
+ });
171
+ }
172
+ highlight-proof:
173
+ file: standalone/diffRegressionSmoke.js
174
+ revision: head
175
+ contains: |2-
176
+ assert.deepEqual(await evaluate('window.highlightFailures'), ['Injected highlight failure'], 'Non-cancellation highlight failures remain observable');
177
+ assert.equal(await evaluate(`${editors}.every(e => e.getOption(window.monaco.editor.EditorOption.occurrencesHighlight) !== 'off')`), true, 'Word highlighting stays enabled');
178
+ assert.deepEqual(errors, []);
179
+ connections: []
180
+ chapters:
181
+ - id: purpose-and-context
182
+ title: Make the purpose and comparison clear
183
+ scenes:
184
+ - id: explanation
185
+ title: What makes a tour an explanation?
186
+ summary: >-
187
+ Start with the author’s contract. The writing guidance asks for a causal account; the
188
+ format gives that account a beginning and an ending. Notice which part requires judgment
189
+ and which part the software can represent.
190
+ steps:
191
+ - id: causal-writing
192
+ title: Keep the reason when cutting the words
193
+ body: >-
194
+ A terse label such as “ignores layout events” leaves the reader to infer why it
195
+ matters. The revised skill asks authors to connect the outcome to the mechanism and
196
+ its evidence in the main reading path. This is the strategy change: shorten repetition
197
+ and inventory, while keeping the reasoning that makes a claim understandable.
198
+ focus: causal-writing
199
+ - id: bookends
200
+ title: Separate the opening promise from the evidence
201
+ body: >-
202
+ Version 5 adds authored opening and conclusion passages, each with a title and
203
+ summary. They belong to the narrative rather than a file or code step, so an author
204
+ can establish the problem before presenting implementation details. These fields
205
+ provide room for framing; their existence cannot guarantee useful prose.
206
+ focus: bookends
207
+ - id: reading-end
208
+ title: Make the recap a destination
209
+ body: >-
210
+ The conclusion is appended to the continuous reading order after the scenes and their
211
+ steps. That makes the ending reachable through the same navigation as the evidence,
212
+ rather than burying the summary in the final code annotation. The navigation test
213
+ later in this tour checks that readers can reach it and move back.
214
+ focus: reading-end
215
+ bullets: []
216
+ tags: []
217
+ takeaway: The format can create space for reasoning; the author must supply the causal argument.
218
+ - id: comparison
219
+ title: Does a new scene mean a new comparison?
220
+ summary: >-
221
+ With the purpose established, the next question is what the viewer puts beneath it. Follow
222
+ the landing rule, the caption’s source of truth, and a test that distinguishes moving to
223
+ another file from changing the revisions.
224
+ steps:
225
+ - id: scene-preview
226
+ title: Show the next evidence unless an overview was authored
227
+ body: >-
228
+ The landing rule gives bookends and discussion passages a narrative view. A scene with
229
+ code steps and no explicit overview gets a preview of its evidence; a step gets the
230
+ evidence itself. A directory overview therefore becomes a deliberate authored choice,
231
+ instead of the automatic visual interruption at every scene boundary.
232
+ focus: scene-preview
233
+ - id: actual-evidence
234
+ title: Describe the comparison the reader actually sees
235
+ body: >-
236
+ The caption resolves the displayed panel pair and file, including manual panel
237
+ selection and file exploration from a parent passage. It remembers that displayed
238
+ context for the next transition. Otherwise a caption could describe the authored stop
239
+ while the reader is looking at a different comparison—the precise ambiguity an
240
+ orientation cue is meant to remove.
241
+ focus: actual-evidence
242
+ - id: comparison-proof
243
+ title: A new file is not a new revision pair
244
+ body: >-
245
+ The test moves from app.ts to other.ts and expects “Same revision comparison.”
246
+ Renaming a revision label leaves its identity unchanged; reversing endpoints or
247
+ changing the head OID changes it. This checks that orientation follows the actual
248
+ ordered revisions, rather than drawing conclusions from titles or file names.
249
+ focus: comparison-proof
250
+ bullets: []
251
+ tags: []
252
+ takeaway: >-
253
+ Use a scene boundary to introduce a new question. Use resolved revisions to decide whether
254
+ the comparison changed.
255
+ - id: keep-the-thread
256
+ title: Keep the argument intact as the reader moves
257
+ scenes:
258
+ - id: navigation
259
+ title: Can the reader advance without steering the scroll?
260
+ summary: >-
261
+ Now keep that context while moving through the explanation. The buttons use the document’s
262
+ reading order, and the exported-viewer test exercises both directions through its
263
+ beginning and ending.
264
+ steps:
265
+ - id: linear-navigation
266
+ title: Move to the next passage, not just the next code step
267
+ body: >-
268
+ Back and Next ask for the adjacent item in the reading order and activate it as linear
269
+ navigation. This carries the reader through introductory passages, scene explanations,
270
+ evidence, and the conclusion. Scroll remains available, but no longer has to be the
271
+ main way to choose the next stop.
272
+ focus: linear-navigation
273
+ - id: navigation-proof
274
+ title: The route reaches the conclusion and returns to the intro
275
+ body: >-
276
+ The export smoke clicks Next through chapter, scene, step, and conclusion; it then
277
+ clicks Back through the reverse route to the title. It also checks that Next is
278
+ disabled at the end. This is a browser interaction check for the navigation contract,
279
+ not evidence that the prose is persuasive.
280
+ focus: navigation-proof
281
+ bullets: []
282
+ tags: []
283
+ takeaway: An ending only works as an ending if the reader can reach it through the normal controls.
284
+ - id: multiple-focuses
285
+ title: Why show several code focuses for one explanation?
286
+ summary: >-
287
+ A constructed stage is an authored intermediate version, rather than a Git commit. It can
288
+ change several files or separated regions. Each focus should add evidence without
289
+ restarting the argument. We’ll inspect how the compiler avoids repeated prose, how a
290
+ reader can recover the explanation, and what narration tests establish.
291
+ steps:
292
+ - id: stage-once
293
+ title: Explain the stage once while retaining every focus
294
+ body: >-
295
+ The compiler puts the stage title and narration on its first focus. Later focuses get
296
+ a file-and-evidence title and an empty body, while keeping the stage’s comparison
297
+ pair. The reader can inspect all of the code supporting one idea without encountering
298
+ the same paragraph at every stop. This is behavior for constructed-stage tours; this
299
+ tour itself stays on real revisions.
300
+ focus: stage-once
301
+ - id: stage-recovery
302
+ title: Let a later focus lead back to its explanation
303
+ body: >-
304
+ An empty continuation body does not mean the reader must remember where the argument
305
+ began. The viewer finds the first focus for the same comparison pair and adds “Read
306
+ stage explanation.” This preserves a route back for someone who arrives at a later
307
+ focus directly.
308
+ focus: stage-recovery
309
+ - id: stage-proof
310
+ title: Continuous narration and direct entry need different context
311
+ body: >-
312
+ The test requires each stage’s narration to appear once during continuous playback.
313
+ Starting directly at a later focus supplies “Stage 2: Finish the behavior,” without
314
+ replaying the full body. That checks generated speech text: it does not establish
315
+ actual audio quality or whether listeners follow the explanation.
316
+ focus: stage-proof
317
+ bullets: []
318
+ tags: []
319
+ takeaway: A stage is one argument, even when its evidence needs several stops.
320
+ - id: switching-code
321
+ title: Can switching evidence leave a stray failure behind?
322
+ summary: >-
323
+ Navigation also replaces editor content. The branch fixes one concrete failure found along
324
+ that path: cancelling pending word highlighting could surface an unhandled rejection. The
325
+ guard is narrow, and the regression check makes that boundary explicit.
326
+ steps:
327
+ - id: highlight-cancel
328
+ title: Handle expected cancellation at editor teardown
329
+ body: >-
330
+ Before model replacement or editor disposal, the renderer attaches a handler to
331
+ Monaco’s pending word-highlighting promise. It absorbs cancellation and rethrows other
332
+ failures. This keeps expected teardown from surfacing as an error while preserving
333
+ word highlighting. The access reaches into Monaco’s internal highlighter, so an editor
334
+ upgrade needs to recheck this integration.
335
+ focus: highlight-cancel
336
+ - id: highlight-proof
337
+ title: Keep unrelated failures observable
338
+ body: >-
339
+ The regression smoke replaces models with real highlighting work pending, then injects
340
+ a non-cancellation failure. These assertions require that injected failure to remain
341
+ observable, word highlighting to stay enabled, and the collected renderer errors to
342
+ stay empty. The result is deliberately bounded: this guards one navigation-related
343
+ failure, not every possible editor lifecycle error.
344
+ focus: highlight-proof
345
+ bullets: []
346
+ tags: []
347
+ takeaway: >-
348
+ Stable navigation includes the editor work it interrupts; keep the cancellation boundary
349
+ specific.
@@ -1,5 +1,15 @@
1
- "use strict";(()=>{function E(){}E.prototype={diff:function(e,t){var r,o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},i=o.callback;typeof o=="function"&&(i=o,o={}),this.options=o;var l=this;function a(v){return i?(setTimeout(function(){i(void 0,v)},0),!0):v}e=this.castInput(e),t=this.castInput(t),e=this.removeEmpty(this.tokenize(e)),t=this.removeEmpty(this.tokenize(t));var c=t.length,f=e.length,s=1,u=c+f;o.maxEditLength&&(u=Math.min(u,o.maxEditLength));var m=(r=o.timeout)!==null&&r!==void 0?r:1/0,L=Date.now()+m,w=[{oldPos:-1,lastComponent:void 0}],g=this.extractCommon(w[0],t,e,0);if(w[0].oldPos+1>=f&&g+1>=c)return a([{value:this.join(t),count:t.length}]);var d=-1/0,p=1/0;function h(){for(var v=Math.max(d,-s);v<=Math.min(p,s);v+=2){var x=void 0,y=w[v-1],A=w[v+1];y&&(w[v-1]=void 0);var R=!1;if(A){var V=A.oldPos-v;R=A&&0<=V&&V<c}var J=y&&y.oldPos+1<f;if(!R&&!J){w[v]=void 0;continue}if(!J||R&&y.oldPos+1<A.oldPos?x=l.addToPath(A,!0,void 0,0):x=l.addToPath(y,void 0,!0,1),g=l.extractCommon(x,t,e,v),x.oldPos+1>=f&&g+1>=c)return a(Ne(l,x.lastComponent,t,e,l.useLongestToken));w[v]=x,x.oldPos+1>=f&&(p=Math.min(p,v-1)),g+1>=c&&(d=Math.max(d,v+1))}s++}if(i)(function v(){setTimeout(function(){if(s>u||Date.now()>L)return i();h()||v()},0)})();else for(;s<=u&&Date.now()<=L;){var b=h();if(b)return b}},addToPath:function(e,t,r,o){var i=e.lastComponent;return i&&i.added===t&&i.removed===r?{oldPos:e.oldPos+o,lastComponent:{count:i.count+1,added:t,removed:r,previousComponent:i.previousComponent}}:{oldPos:e.oldPos+o,lastComponent:{count:1,added:t,removed:r,previousComponent:i}}},extractCommon:function(e,t,r,o){for(var i=t.length,l=r.length,a=e.oldPos,c=a-o,f=0;c+1<i&&a+1<l&&this.equals(t[c+1],r[a+1]);)c++,a++,f++;return f&&(e.lastComponent={count:f,previousComponent:e.lastComponent}),e.oldPos=a,c},equals:function(e,t){return this.options.comparator?this.options.comparator(e,t):e===t||this.options.ignoreCase&&e.toLowerCase()===t.toLowerCase()},removeEmpty:function(e){for(var t=[],r=0;r<e.length;r++)e[r]&&t.push(e[r]);return t},castInput:function(e){return e},tokenize:function(e){return e.split("")},join:function(e){return e.join("")}};function Ne(n,e,t,r,o){for(var i=[],l;e;)i.push(e),l=e.previousComponent,delete e.previousComponent,e=l;i.reverse();for(var a=0,c=i.length,f=0,s=0;a<c;a++){var u=i[a];if(u.removed){if(u.value=n.join(r.slice(s,s+u.count)),s+=u.count,a&&i[a-1].added){var L=i[a-1];i[a-1]=i[a],i[a]=L}}else{if(!u.added&&o){var m=t.slice(f,f+u.count);m=m.map(function(g,d){var p=r[s+d];return p.length>g.length?p:g}),u.value=n.join(m)}else u.value=n.join(t.slice(f,f+u.count));f+=u.count,u.added||(s+=u.count)}}var w=i[c-1];return c>1&&typeof w.value=="string"&&(w.added||w.removed)&&n.equals("",w.value)&&(i[c-2].value+=w.value,i.pop()),i}var Ie=new E;function Q(n,e,t){return Ie.diff(n,e,t)}var j=/^[A-Za-z\xC0-\u02C6\u02C8-\u02D7\u02DE-\u02FF\u1E00-\u1EFF]+$/,Z=/\S/,P=new E;P.equals=function(n,e){return this.options.ignoreCase&&(n=n.toLowerCase(),e=e.toLowerCase()),n===e||this.options.ignoreWhitespace&&!Z.test(n)&&!Z.test(e)};P.tokenize=function(n){for(var e=n.split(/([^\S\r\n]+|[()[\]{}'"\r\n]|\b)/),t=0;t<e.length-1;t++)!e[t+1]&&e[t+2]&&j.test(e[t])&&j.test(e[t+2])&&(e[t]+=e[t+2],e.splice(t+1,2),t--);return e};function ee(n,e,t){return P.diff(n,e,t)}var ne=new E;ne.tokenize=function(n){this.options.stripTrailingCr&&(n=n.replace(/\r\n/g,`
2
- `));var e=[],t=n.split(/(\n|\r\n)/);t[t.length-1]||t.pop();for(var r=0;r<t.length;r++){var o=t[r];r%2&&!this.options.newlineIsToken?e[e.length-1]+=o:(this.options.ignoreWhitespace&&(o=o.trim()),e.push(o))}return e};var Se=new E;Se.tokenize=function(n){return n.split(/(\S.+?[.!?])(?=\s+|$)/)};var Ee=new E;Ee.tokenize=function(n){return n.split(/([{}:;,]|\s+)/)};function F(n){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?F=function(e){return typeof e}:F=function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},F(n)}var Ae=Object.prototype.toString,D=new E;D.useLongestToken=!0;D.tokenize=ne.tokenize;D.castInput=function(n){var e=this.options,t=e.undefinedReplacement,r=e.stringifyReplacer,o=r===void 0?function(i,l){return typeof l>"u"?t:l}:r;return typeof n=="string"?n:JSON.stringify(B(n,null,null,o),o," ")};D.equals=function(n,e){return E.prototype.equals.call(D,n.replace(/,([\r\n])/g,"$1"),e.replace(/,([\r\n])/g,"$1"))};function B(n,e,t,r,o){e=e||[],t=t||[],r&&(n=r(o,n));var i;for(i=0;i<e.length;i+=1)if(e[i]===n)return t[i];var l;if(Ae.call(n)==="[object Array]"){for(e.push(n),l=new Array(n.length),t.push(l),i=0;i<n.length;i+=1)l[i]=B(n[i],e,t,r,o);return e.pop(),t.pop(),l}if(n&&n.toJSON&&(n=n.toJSON()),F(n)==="object"&&n!==null){e.push(n),l={},t.push(l);var a=[],c;for(c in n)n.hasOwnProperty(c)&&a.push(c);for(a.sort(),i=0;i<a.length;i+=1)c=a[i],l[c]=B(n[c],e,t,r,c);e.pop(),t.pop()}else l=n;return l}var H=new E;H.tokenize=function(n){return n.slice()};H.join=H.removeEmpty=function(n){return n};function te(n,e,t){return H.diff(n,e,t)}var Te=500,Re=100,re=ye("BYGONE_MAX_INLINE_HIGHLIGHT_LINE_LENGTH",Te),De=ye("BYGONE_DIFF_TIMEOUT_MS",Re);function me(n,e,t={}){let r=ie(n),o=ie(e);if(n===e)return _e(r);let i=Ce(r,o),l=te(i.left,i.right,{timeout:t.timeoutMs??De});if(!l)return Oe(r,o);let a=l.map(g=>({...g,value:g.value.map(d=>i.lines[d])})),c=[],f=[],s=[],u=[],m=1,L=1;for(let g=0;g<a.length;g++){let d=a[g],p=d.removed?d.value:[],h=d.added?d.value:[];if(!d.added&&!d.removed){for(let b of d.value)f.push(I("context",b,m)),s.push(I("context",b,L)),c.push(M(N("context",b,m++),N("context",b,L++)));continue}if(d.removed&&g+1<a.length&&a[g+1].added){let b=a[g+1],v=Fe(p,b.value,m,L,c,f,s,u);m=v.left,L=v.right,g++;continue}if(d.removed){let b=f.length,v=s.length;for(let x of p)f.push(I("removed",x,m)),c.push(M(N("removed",x,m++),T()));u.push(z("delete",b,f.length,v,s.length));continue}if(d.added){let b=f.length,v=s.length;for(let x of h)s.push(I("added",x,L)),c.push(M(T(),N("added",x,L++)));u.push(z("insert",b,f.length,v,s.length))}}let w=c.some(g=>g.left.kind!=="context"||g.right.kind!=="context");return{rows:c,leftLines:f,rightLines:s,blocks:u,hasChanges:w,quality:"exact"}}function Ce(n,e){let t=new Map,r=[],o=i=>{let l=t.get(i);if(l!==void 0)return l;let a=r.length;return t.set(i,a),r.push(i),a};return{left:n.map(o),right:e.map(o),lines:r}}function _e(n){return{rows:n.map((e,t)=>M(N("context",e,t+1),N("context",e,t+1))),leftLines:n.map((e,t)=>I("context",e,t+1)),rightLines:n.map((e,t)=>I("context",e,t+1)),blocks:[],hasChanges:!1,quality:"exact"}}function Oe(n,e){let t=n.map((l,a)=>I("removed",l,a+1)),r=e.map((l,a)=>I("added",l,a+1)),o=[...n.map((l,a)=>M(N("removed",l,a+1),T())),...e.map((l,a)=>M(T(),N("added",l,a+1)))],i="replace";return n.length===0?i="insert":e.length===0&&(i="delete"),{rows:o,leftLines:t,rightLines:r,blocks:o.length===0?[]:[z(i,0,n.length,0,e.length)],hasChanges:o.length>0,quality:"fallback"}}function ie(n){if(n.length===0)return[];let e=n.replace(/\r\n/g,`
1
+ "use strict";(()=>{function C(){}C.prototype={diff:function(e,t){var r,o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},i=o.callback;typeof o=="function"&&(i=o,o={}),this.options=o;var s=this;function l(S){return i?(setTimeout(function(){i(void 0,S)},0),!0):S}e=this.castInput(e),t=this.castInput(t),e=this.removeEmpty(this.tokenize(e)),t=this.removeEmpty(this.tokenize(t));var d=t.length,c=e.length,f=1,u=d+c;o.maxEditLength&&(u=Math.min(u,o.maxEditLength));var h=(r=o.timeout)!==null&&r!==void 0?r:1/0,b=Date.now()+h,y=[{oldPos:-1,lastComponent:void 0}],a=this.extractCommon(y[0],t,e,0);if(y[0].oldPos+1>=c&&a+1>=d)return l([{value:this.join(t),count:t.length}]);var g=-1/0,m=1/0;function w(){for(var S=Math.max(g,-f);S<=Math.min(m,f);S+=2){var x=void 0,E=y[S-1],v=y[S+1];E&&(y[S-1]=void 0);var N=!1;if(v){var I=v.oldPos-S;N=v&&0<=I&&I<d}var T=E&&E.oldPos+1<c;if(!N&&!T){y[S]=void 0;continue}if(!T||N&&E.oldPos+1<v.oldPos?x=s.addToPath(v,!0,void 0,0):x=s.addToPath(E,void 0,!0,1),a=s.extractCommon(x,t,e,S),x.oldPos+1>=c&&a+1>=d)return l(He(s,x.lastComponent,t,e,s.useLongestToken));y[S]=x,x.oldPos+1>=c&&(m=Math.min(m,S-1)),a+1>=d&&(g=Math.max(g,S+1))}f++}if(i)(function S(){setTimeout(function(){if(f>u||Date.now()>b)return i();w()||S()},0)})();else for(;f<=u&&Date.now()<=b;){var p=w();if(p)return p}},addToPath:function(e,t,r,o){var i=e.lastComponent;return i&&i.added===t&&i.removed===r?{oldPos:e.oldPos+o,lastComponent:{count:i.count+1,added:t,removed:r,previousComponent:i.previousComponent}}:{oldPos:e.oldPos+o,lastComponent:{count:1,added:t,removed:r,previousComponent:i}}},extractCommon:function(e,t,r,o){for(var i=t.length,s=r.length,l=e.oldPos,d=l-o,c=0;d+1<i&&l+1<s&&this.equals(t[d+1],r[l+1]);)d++,l++,c++;return c&&(e.lastComponent={count:c,previousComponent:e.lastComponent}),e.oldPos=l,d},equals:function(e,t){return this.options.comparator?this.options.comparator(e,t):e===t||this.options.ignoreCase&&e.toLowerCase()===t.toLowerCase()},removeEmpty:function(e){for(var t=[],r=0;r<e.length;r++)e[r]&&t.push(e[r]);return t},castInput:function(e){return e},tokenize:function(e){return e.split("")},join:function(e){return e.join("")}};function He(n,e,t,r,o){for(var i=[],s;e;)i.push(e),s=e.previousComponent,delete e.previousComponent,e=s;i.reverse();for(var l=0,d=i.length,c=0,f=0;l<d;l++){var u=i[l];if(u.removed){if(u.value=n.join(r.slice(f,f+u.count)),f+=u.count,l&&i[l-1].added){var b=i[l-1];i[l-1]=i[l],i[l]=b}}else{if(!u.added&&o){var h=t.slice(c,c+u.count);h=h.map(function(a,g){var m=r[f+g];return m.length>a.length?m:a}),u.value=n.join(h)}else u.value=n.join(t.slice(c,c+u.count));c+=u.count,u.added||(f+=u.count)}}var y=i[d-1];return d>1&&typeof y.value=="string"&&(y.added||y.removed)&&n.equals("",y.value)&&(i[d-2].value+=y.value,i.pop()),i}var We=new C;function ue(n,e,t){return We.diff(n,e,t)}var fe=/^[A-Za-z\xC0-\u02C6\u02C8-\u02D7\u02DE-\u02FF\u1E00-\u1EFF]+$/,ae=/\S/,Z=new C;Z.equals=function(n,e){return this.options.ignoreCase&&(n=n.toLowerCase(),e=e.toLowerCase()),n===e||this.options.ignoreWhitespace&&!ae.test(n)&&!ae.test(e)};Z.tokenize=function(n){for(var e=n.split(/([^\S\r\n]+|[()[\]{}'"\r\n]|\b)/),t=0;t<e.length-1;t++)!e[t+1]&&e[t+2]&&fe.test(e[t])&&fe.test(e[t+2])&&(e[t]+=e[t+2],e.splice(t+1,2),t--);return e};function ce(n,e,t){return Z.diff(n,e,t)}var de=new C;de.tokenize=function(n){this.options.stripTrailingCr&&(n=n.replace(/\r\n/g,`
2
+ `));var e=[],t=n.split(/(\n|\r\n)/);t[t.length-1]||t.pop();for(var r=0;r<t.length;r++){var o=t[r];r%2&&!this.options.newlineIsToken?e[e.length-1]+=o:(this.options.ignoreWhitespace&&(o=o.trim()),e.push(o))}return e};var $e=new C;$e.tokenize=function(n){return n.split(/(\S.+?[.!?])(?=\s+|$)/)};var Be=new C;Be.tokenize=function(n){return n.split(/([{}:;,]|\s+)/)};function U(n){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?U=function(e){return typeof e}:U=function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},U(n)}var Ge=Object.prototype.toString,H=new C;H.useLongestToken=!0;H.tokenize=de.tokenize;H.castInput=function(n){var e=this.options,t=e.undefinedReplacement,r=e.stringifyReplacer,o=r===void 0?function(i,s){return typeof s>"u"?t:s}:r;return typeof n=="string"?n:JSON.stringify(J(n,null,null,o),o," ")};H.equals=function(n,e){return C.prototype.equals.call(H,n.replace(/,([\r\n])/g,"$1"),e.replace(/,([\r\n])/g,"$1"))};function J(n,e,t,r,o){e=e||[],t=t||[],r&&(n=r(o,n));var i;for(i=0;i<e.length;i+=1)if(e[i]===n)return t[i];var s;if(Ge.call(n)==="[object Array]"){for(e.push(n),s=new Array(n.length),t.push(s),i=0;i<n.length;i+=1)s[i]=J(n[i],e,t,r,o);return e.pop(),t.pop(),s}if(n&&n.toJSON&&(n=n.toJSON()),U(n)==="object"&&n!==null){e.push(n),s={},t.push(s);var l=[],d;for(d in n)n.hasOwnProperty(d)&&l.push(d);for(l.sort(),i=0;i<l.length;i+=1)d=l[i],s[d]=J(n[d],e,t,r,d);e.pop(),t.pop()}else s=n;return s}var P=new C;P.tokenize=function(n){return n.slice()};P.join=P.removeEmpty=function(n){return n};function ge(n,e,t){return P.diff(n,e,t)}var Pe=2e4,ze=100,Y=Fe("BYGONE_MAX_INLINE_HIGHLIGHT_LINE_LENGTH",Pe),Ae=Fe("BYGONE_DIFF_TIMEOUT_MS",ze);function Re(n,e,t={}){let r=pe(n),o=pe(e);if(n===e)return me(r);if(r.length===o.length&&r.every((a,g)=>a===o[g])){let a=me(r),g=n.match(/[^\n]*\n|[^\n]+$/g)||[],m=e.match(/[^\n]*\n|[^\n]+$/g)||[];return r.forEach((w,p)=>{g[p]!==m[p]&&(a.leftLines[p].kind=a.rows[p].left.kind="removed",a.rightLines[p].kind=a.rows[p].right.kind="added",a.leftLines[p].inlineDetail=a.rightLines[p].inlineDetail="line-ending",a.blocks.push(W("replace",p,p+1,p,p+1)))}),a.blocks=he(a.blocks),a.hasChanges=!0,a.formattingOnly=!0,a}let i=qe(r,o),s=ge(i.left,i.right,{timeout:t.timeoutMs??Ae});if(!s)return Xe(r,o);let l=s.map(a=>({...a,value:a.value.map(g=>i.lines[g])})),d=[],c=[],f=[],u=[],h=1,b=1;for(let a=0;a<l.length;a++){let g=l[a],m=g.removed?g.value:[],w=g.added?g.value:[];if(!g.added&&!g.removed){for(let p of g.value)c.push(A("context",p,h)),f.push(A("context",p,b)),d.push(_(M("context",p,h++),M("context",p,b++)));continue}if(g.removed&&a+1<l.length&&l[a+1].added){let p=l[a+1],S=Ye(m,p.value,h,b,d,c,f,u);h=S.left,b=S.right,a++;continue}if(g.removed){let p=c.length,S=f.length;for(let x of m)c.push(A("removed",x,h)),d.push(_(M("removed",x,h++),O()));u.push(W("delete",p,c.length,S,f.length));continue}if(g.added){let p=c.length,S=f.length;for(let x of w)f.push(A("added",x,b)),d.push(_(O(),M("added",x,b++)));u.push(W("insert",p,c.length,S,f.length))}}let y=d.some(a=>a.left.kind!=="context"||a.right.kind!=="context");return Te({rows:d,leftLines:c,rightLines:f,blocks:he(u),reflows:u.filter(a=>a.reflow),hasChanges:y,quality:"exact"})}function Te(n){for(let e of n.blocks)if(e.kind==="replace")for(let t of["left","right"])for(let r=e[`${t}Start`];r<e[`${t}End`];r++){let o=n[`${t}Lines`][r];o.kind!=="context"&&!o.segments&&(o.inlineDetail="omitted")}return n}function he(n){let e=[],t=!1;for(let o of n){let i=o.kind!=="replace",s=e[e.length-1];i&&t&&s.leftEnd===o.leftStart&&s.rightEnd===o.rightStart?(s.leftEnd=o.leftEnd,s.rightEnd=o.rightEnd,s.leftEnd>s.leftStart&&s.rightEnd>s.rightStart&&(s.kind="replace")):e.push({...o}),t=i}let r=[];for(let o of e){let i={...o};delete i.reflow;let s=r[r.length-1];s?.kind===i.kind&&s.leftEnd===i.leftStart&&s.rightEnd===i.rightStart?(s.leftEnd=i.leftEnd,s.rightEnd=i.rightEnd):r.push(i)}return r}function qe(n,e){let t=new Map,r=[],o=i=>{let s=t.get(i);if(s!==void 0)return s;let l=r.length;return t.set(i,l),r.push(i),l};return{left:n.map(o),right:e.map(o),lines:r}}function me(n){return{rows:n.map((e,t)=>_(M("context",e,t+1),M("context",e,t+1))),leftLines:n.map((e,t)=>A("context",e,t+1)),rightLines:n.map((e,t)=>A("context",e,t+1)),blocks:[],hasChanges:!1,quality:"exact"}}function Xe(n,e){let t=n.map((s,l)=>A("removed",s,l+1)),r=e.map((s,l)=>A("added",s,l+1)),o=[...n.map((s,l)=>_(M("removed",s,l+1),O())),...e.map((s,l)=>_(O(),M("added",s,l+1)))],i="replace";return n.length===0?i="insert":e.length===0&&(i="delete"),Te({rows:o,leftLines:t,rightLines:r,blocks:o.length===0?[]:[W(i,0,n.length,0,e.length)],hasChanges:o.length>0,quality:"fallback"})}function pe(n){if(n.length===0)return[];let e=n.replace(/\r\n/g,`
3
3
  `).split(`
4
- `);return e[e.length-1]===""&&e.pop(),e}function Fe(n,e,t,r,o,i,l,a){let c=xe(n,e),f=c.filter(h=>h.left!==void 0&&h.right!==void 0&&X(h.left,h.right)).length,s=ke(n,e,f),u=c.flatMap(h=>h.left===void 0||h.right===void 0||X(h.left,h.right)?[h]:[{left:h.left},{right:h.right}]),m=t,L=r,w,g=i.length,d=l.length,p=()=>{w&&a.push(z(w,g,i.length,d,l.length))};for(let{left:h,right:b}of u){let v=s||h!==void 0&&b!==void 0?"replace":h!==void 0?"delete":"insert";w!==v&&(p(),w=v,g=i.length,d=l.length);let x,y;h!==void 0&&(x=I("removed",h,m),i.push(x)),b!==void 0&&(y=I("added",b,L),l.push(y)),x&&y?on(x,y):s&&(x&&he(x),y&&he(y)),o.push(M(h===void 0?T():N("removed",h,m++),b===void 0?T():N("added",b,L++)))}return p(),{left:m,right:L}}function X(n,e){if(U(n,e).eligible)return!0;let r=C(n);if(r&&r===C(e))return!0;let o=new Set(O(S(n)).filter(oe));return O(S(e)).some(i=>o.has(i)&&oe(i))}var He=new Set(["and","are","for","from","into","that","the","this","to","with"]);function oe(n){return n.length>=3&&/^[\p{L}\p{N}_$]+$/u.test(n)&&!He.has(n)}function ke(n,e,t){if(t===0)return!1;let r=Math.max(n.length,e.length);if(r<=2||t*2>=r)return!0;let o=[...n,...e].map(We);return o[0]!==null&&o.every(i=>i===o[0])}function We(n){let e=n.trimStart();return/^[-*+]\s+/.test(e)?"bullet":/^\d+[.)]\s+/.test(e)?"ordered":/^>\s+/.test(e)?"quote":null}var be=1e4,se=2e3,Ge=.52,$e=.35,ve=.38,ze=.33,we=.86,$=.08,k=.05,W=-.12,le=5e3,Ue=2e3,Be=5e7,fe=4,Pe=8,q=4;function xe(n,e){if(n.length===0)return e.map(s=>({right:s}));if(e.length===0)return n.map(s=>({left:s}));let t=n.reduce((s,u)=>s+u.length,0),r=e.reduce((s,u)=>s+u.length,0);if(t*r>Be)return[...n.map(s=>({left:s})),...e.map(s=>({right:s}))];if(n.length===1&&e.length===1){let s=U(n[0],e[0]);return(s.eligible||s.score>=$e)&&X(n[0],e[0])&&K(n[0],e[0])&&_(S(n[0]))&&_(S(e[0]))?[{left:n[0],right:e[0]}]:[{left:n[0]},{right:e[0]}]}if(n.length*e.length>be)return Ve(n,e);let o=qe(n,e),i=Array.from({length:n.length+1},()=>new Array(e.length+1).fill(Number.NEGATIVE_INFINITY)),l=Array.from({length:n.length+1},()=>new Array(e.length+1).fill(null));i[0][0]=0;for(let s=1;s<=n.length;s++)i[s][0]=i[s-1][0]+W,l[s][0]="left";for(let s=1;s<=e.length;s++)i[0][s]=i[0][s-1]+W,l[0][s]="right";for(let s=1;s<=n.length;s++)for(let u=1;u<=e.length;u++){let m=o[s-1][u-1],w=[{move:"left",score:i[s-1][u]+W},{move:"right",score:i[s][u-1]+W},{move:"match",score:m===null?Number.NEGATIVE_INFINITY:i[s-1][u-1]+m}].reduce((g,d)=>d.score>g.score?d:g);i[s][u]=w.score,l[s][u]=w.move}let a=[],c=n.length,f=e.length;for(;c>0||f>0;){let s=l[c][f];s==="match"?a.push({left:n[--c],right:e[--f]}):s==="left"?a.push({left:n[--c]}):a.push({right:e[--f]})}return a.reverse()}function U(n,e){let t=S(n),r=S(e),o=_(t),i=_(r);if(!o||!i||t.length>se||r.length>se)return{score:0,eligible:!1,characterSimilarity:0,tokenSimilarity:0,lengthSimilarity:0};if(t===r)return{score:1,eligible:!0,characterSimilarity:1,tokenSimilarity:1,lengthSimilarity:1};let l=O(t),a=O(r),c=rn(t,r),f=nn(l,a),s=Math.min(t.length,r.length)/Math.max(t.length,r.length),u=tn(l,a),m=c*.52+f*.32+s*.1+u*.06,L=c>=.52||f>=.45||c>=.48&&f>=.28;return{score:m,eligible:L&&m>=Ge,characterSimilarity:c,tokenSimilarity:f,lengthSimilarity:s}}function qe(n,e){let t=n.map(g=>e.map(d=>U(g,d))),r=Le(n,e),o=t.map(g=>Y(g)),i=e.map((g,d)=>Y(t.map(p=>p[d]))),l=t.map((g,d)=>g.map((p,h)=>{if(r.has(`${d}:${h}`))return Math.max(p.score,1);if(!p.eligible)return null;let b=o[d],v=i[h],x=p.score===b.best&&p.score===v.best,y=p.score>=we?$/2:$,A=b.best-b.second>=y,R=v.best-v.second>=y;return x&&A&&R?p.score:null}));if(Math.max(n.length,e.length)>Pe||Math.abs(n.length-e.length)>q)return l;let a=(g,d,p)=>g.score>=ve&&K(n[d],e[p])&&Math.abs(d-p)<=q,c=t.map((g,d)=>G(g,(p,h)=>a(p,d,h))),f=e.map((g,d)=>G(t.map(p=>p[d]),(p,h)=>a(p,h,d))),s=(g,d,p)=>g.score>=ze&&K(n[d],e[p])&&Math.abs(d-p)<=q,u=t.map((g,d)=>G(g,(p,h)=>s(p,d,h))),m=e.map((g,d)=>G(t.map(p=>p[d]),(p,h)=>s(p,h,d))),L=(g,d)=>{let p=t[g][d];if(!a(p,g,d))return!1;let h=c[g],b=f[d];return p.score===h.best&&p.score===b.best&&h.best-h.second>=k&&b.best-b.second>=k},w=(g,d)=>{let p=t[g][d];if(!s(p,g,d))return!1;let h=u[g],b=m[d];return p.score===h.best&&p.score===b.best&&h.best-h.second>=k&&b.best-b.second>=k};return l.map((g,d)=>g.map((p,h)=>{if(p!==null)return p;let b=L(d,h)&&(Xe(l,d,h)||Ye(t,d,h,L)),v=Ke(t,d,h,(x,y)=>s(t[x][y],x,y),w);return!b&&!v?null:t[d][h].score}))}function Xe(n,e,t){return e>0&&t>0&&n[e-1][t-1]!==null||e+1<n.length&&t+1<n[e+1].length&&n[e+1][t+1]!==null}function Ye(n,e,t,r){return e>0&&t>0&&r(e-1,t-1)||e+1<n.length&&t+1<n[e+1].length&&r(e+1,t+1)}function Ke(n,e,t,r,o){let i=e,l=t;for(;i>0&&l>0&&r(i-1,l-1);)i--,l--;let a=e,c=t,f=n[e][t].score,s=1;for(;a+1<n.length&&c+1<n[a+1].length&&r(a+1,c+1);)a++,c++,f+=n[a][c].score,s++;for(let u=e-1,m=t-1;u>=i&&m>=l;u--,m--)f+=n[u][m].score,s++;return s>=3&&f/s>=ve&&o(i,l)&&o(a,c)}function G(n,e){let t=Number.NEGATIVE_INFINITY,r=Number.NEGATIVE_INFINITY;return n.forEach((o,i)=>{e(o,i)&&(o.score>t?(r=t,t=o.score):o.score>r&&(r=o.score))}),{best:t,second:r}}function Y(n){let e=Number.NEGATIVE_INFINITY,t=Number.NEGATIVE_INFINITY;for(let r of n)r.eligible&&(r.score>e?(t=e,e=r.score):r.score>t&&(t=r.score));return{best:e,second:t}}function Ve(n,e){let t=Je(n,e),r=[],o=0,i=0;for(let l of t)ge(r,n.slice(o,l.leftIndex),e.slice(i,l.rightIndex)),r.push({left:n[l.leftIndex],right:e[l.rightIndex]}),o=l.leftIndex+1,i=l.rightIndex+1;return ge(r,n.slice(o),e.slice(i)),r}function Je(n,e){let t=je(n,e);if(t===null)return[];let r=Le(n,e),o=t.map(({leftIndex:f,rightIndex:s,exact:u})=>({leftIndex:f,rightIndex:s,exact:u,structural:r.has(`${f}:${s}`),match:U(n[f],e[s])})).filter(f=>f.exact||f.structural||f.match.eligible),i=ce(o,"leftIndex"),l=ce(o,"rightIndex"),a=o.filter(f=>{if(f.exact||f.structural)return!0;let s=i.get(f.leftIndex),u=l.get(f.rightIndex);if(!s||!u||f.match.score!==s.best||f.match.score!==u.best)return!1;let m=f.match.score>=we?$/2:$;return s.best-s.second>=m&&u.best-u.second>=m}),c=Qe(a,e.length);return c.length<=Ue?c:[]}function je(n,e){let t=ae(n,S),r=ae(e,S),o=new Map;for(let[a,c]of t){let f=r.get(a);if(!_(a)||c.length!==1||f?.length!==1)continue;let s=c[0],u=f[0];if(o.set(`${s}:${u}`,{leftIndex:s,rightIndex:u,exact:!0}),o.size>le)return null}let i=ue(n),l=ue(e);for(let[a,c]of i){let f=l.get(a);if(!(!f||c.length>fe||f.length>fe))for(let s of c)for(let u of f){let m=`${s}:${u}`;if(!o.has(m)&&(o.set(m,{leftIndex:s,rightIndex:u,exact:!1}),o.size>le))return null}}return[...o.values()]}function ae(n,e){let t=new Map;return n.forEach((r,o)=>{let i=e(r),l=t.get(i)??[];l.push(o),t.set(i,l)}),t}function ue(n){let e=new Map;return n.forEach((t,r)=>{let o=new Set(O(S(t)).filter(Ze));for(let i of o){let l=e.get(i)??[];l.push(r),e.set(i,l)}}),e}function Ze(n){return n.length>=2&&/[\p{L}\p{N}_$]/u.test(n)}function ce(n,e){let t=new Map;for(let r of n){let o=t.get(r[e])??[];o.push(r.match),t.set(r[e],o)}return new Map([...t].map(([r,o])=>[r,Y(o)]))}function Qe(n,e){let t=[...n].sort((f,s)=>f.leftIndex-s.leftIndex||f.rightIndex-s.rightIndex),r=new Array(e+2).fill(0),o=new Array(e+2).fill(-1),i=new Array(t.length).fill(0),l=new Array(t.length).fill(-1);for(let f=0;f<t.length;){let s=f+1;for(;s<t.length&&t[s].leftIndex===t[f].leftIndex;)s++;for(let u=f;u<s;u++){let m=de(r,o,t[u].rightIndex),L=t[u].exact||t[u].structural?.5:0;i[u]=m.score+t[u].match.score+L,l[u]=m.candidateIndex}for(let u=f;u<s;u++)en(r,o,t[u].rightIndex+1,i[u],u);f=s}let a=de(r,o,e+1),c=[];for(let f=a.candidateIndex;f>=0;f=l[f])c.push({leftIndex:t[f].leftIndex,rightIndex:t[f].rightIndex});return c.reverse()}function de(n,e,t){let r=0,o=-1;for(let i=t;i>0;i-=i&-i)n[i]>r&&(r=n[i],o=e[i]);return{score:r,candidateIndex:o}}function en(n,e,t,r,o){for(let i=t;i<n.length;i+=i&-i)r>n[i]&&(n[i]=r,e[i]=o)}function ge(n,e,t){if(e.length*t.length<=be){n.push(...xe(e,t));return}n.push(...e.map(r=>({left:r}))),n.push(...t.map(r=>({right:r})))}function S(n){return n.trim().replace(/\s+/g," ")}function Le(n,e){let t=pe(n),r=pe(e),o=new Set;for(let[i,l]of t){let a=r.get(i);l.length===1&&a?.length===1&&o.add(`${l[0]}:${a[0]}`)}return o}function pe(n){let e=new Map;return n.forEach((t,r)=>{let o=C(t);if(!o)return;let i=e.get(o)??[];i.push(r),e.set(o,i)}),e}function K(n,e){let t=C(n),r=C(e);return!t||!r?t===r:t.split(":",1)[0]===r.split(":",1)[0]}function C(n){let e=S(n),t=[["function",/^(?:(?:export|default)\s+)*(?:async\s+)?function\s*\*?\s*([\p{L}_$][\p{L}\p{N}_$]*)\s*\(/u],["function",/^(?:async\s+)?def\s+([\p{L}_][\p{L}\p{N}_]*)\s*\(/u],["function",/^(?:pub(?:\([^)]*\))?\s+)?(?:async\s+)?fn\s+([\p{L}_][\p{L}\p{N}_]*)\s*(?:<[^>]*>)?\s*\(/u],["function",/^func\s+(?:\([^)]*\)\s*)?([\p{L}_][\p{L}\p{N}_]*)\s*\(/u],["class",/^(?:(?:export|default|abstract|public)\s+)*class\s+([\p{L}_$][\p{L}\p{N}_$]*)\b/u]];for(let[r,o]of t){let i=e.match(o);if(i)return`${r}:${i[1]}`}return null}function _(n){return n.length<3?!1:/[\p{L}\p{N}_$]/u.test(n)&&!/^[\s()[\]{};,.:+\-*/=>|&!?'"`]+$/.test(n)}function O(n){return n.toLowerCase().match(/[\p{L}_$][\p{L}\p{N}_$]*|\p{N}+(?:\.\p{N}+)?|[^\s\p{L}\p{N}_$]/gu)??[]}function nn(n,e){if(n.length+e.length===0)return 1;let t=new Map;n.forEach(o=>t.set(o,(t.get(o)??0)+1));let r=0;for(let o of e){let i=t.get(o)??0;i>0&&(r++,t.set(o,i-1))}return 2*r/(n.length+e.length)}function tn(n,e){if(n.length===0||e.length===0)return 0;let t=n[0]===e[0]?.5:0,r=n[n.length-1]===e[e.length-1]?.5:0;return t+r}function rn(n,e){let t=n.length+e.length;return t===0?1:2*Q(n,e).filter(o=>!o.added&&!o.removed).reduce((o,i)=>o+i.value.length,0)/t}function on(n,e){if(n.content.length>re||e.content.length>re)return;let{leftSegments:t,rightSegments:r,hasInlineChanges:o}=sn(n.content,e.content);o&&(n.segments=t,e.segments=r)}function he(n){/[^\s]/.test(n.content)&&(n.segments=[{kind:n.kind,text:n.content,emphasis:!0}])}function sn(n,e){let t=ee(n,e),r=[],o=[],i=!1;for(let l of t){let a=l.value;if(!l.added&&!l.removed){let f={kind:"context",text:a,emphasis:!1};r.push(f),o.push(f);continue}let c=/[^\s]/.test(a);i=i||c,l.removed&&r.push({kind:"removed",text:a,emphasis:c}),l.added&&o.push({kind:"added",text:a,emphasis:c})}return{leftSegments:r,rightSegments:o,hasInlineChanges:i}}function T(){return{kind:"placeholder",content:"",lineNumber:null}}function N(n,e,t){return{kind:n,content:e,lineNumber:t}}function I(n,e,t){return{kind:n,content:e,lineNumber:t}}function M(n,e){return{left:n,right:e}}function z(n,e,t,r,o){return{kind:n,leftStart:e,leftEnd:t,rightStart:r,rightEnd:o}}function ye(n,e){let t=typeof process<"u"?process.env?.[n]:void 0,r=Number.parseInt(t??"",10);return Number.isFinite(r)&&r>0?r:e}self.addEventListener("message",n=>{let{id:e,leftContent:t,rightContent:r}=n.data||{};if(!(typeof e!="number"||typeof t!="string"||typeof r!="string"))try{let o=me(t,r);self.postMessage({id:e,model:o})}catch(o){self.postMessage({id:e,error:o&&o.message||String(o)})}});})();
4
+ `);return e[e.length-1]===""&&e.pop(),e}function Ye(n,e,t,r,o,i,s,l){let d=K(n,e),c=d.filter(v=>v.left!==void 0&&v.right!==void 0&&ne(v.left,v.right)).length,f=!d.some(v=>v.reflow)&&Ke(n,e,c),u=d.flatMap(v=>v.reflow||v.left===void 0||v.right===void 0||ne(v.left,v.right)?[v]:[{left:v.left},{right:v.right}]),h=[];for(let v=0;v<u.length;){let N=u[v];if(N.reflow||N.left!==void 0&&N.right!==void 0){h.push(N),v++;continue}let I=v;for(;v<u.length&&!u[v].reflow&&(u[v].left===void 0||u[v].right===void 0);)v++;let T=u.slice(I,v),L=T.filter(F=>F.left!==void 0),D=T.filter(F=>F.right!==void 0);if(L.length===1&&D.length===1)h.push({left:L[0].left,right:D[0].right});else for(let F of T)h.push(F)}let b=t,y=r,a=[],g=[],m=()=>{vn(a,g),a=[],g=[]},w,p=!1,S=i.length,x=s.length,E=()=>{if(!w)return;let v=W(w,S,i.length,x,s.length);p&&(v.reflow=!0),l.push(v)};for(let{left:v,right:N,reflow:I}of h){(I||v!==void 0&&N!==void 0)&&m();let T=f||I||v!==void 0&&N!==void 0?"replace":v!==void 0?"delete":"insert";(w!==T||p!==!!I||I?.start)&&(E(),w=T,p=!!I,S=i.length,x=s.length);let L,D;v!==void 0&&(L=A("removed",v,b),i.push(L)),N!==void 0&&(D=A("added",N,y),s.push(D)),I?(L&&(L.segments=I.leftSegments),D&&(D.segments=I.rightSegments)):L&&D?pn(L,D):f&&(L&&Me(L),D&&Me(D)),!I&&(v===void 0||N===void 0)&&(L&&a.push(L),D&&g.push(D)),o.push(_(v===void 0?O():M("removed",v,b++),N===void 0?O():M("added",N,y++)))}return E(),m(),{left:b,right:y}}function ne(n,e){if(!n.trim()&&!e.trim()||V(n,e).eligible)return!0;let r=$(n);if(r&&r===$(e))return!0;let o=new Set(G(R(n)).filter(ve));return G(R(e)).some(i=>o.has(i)&&ve(i))}var je=new Set(["and","are","for","from","into","that","the","this","to","with"]);function ve(n){return n.length>=3&&/^[\p{L}\p{N}_$]+$/u.test(n)&&!je.has(n)}function Ke(n,e,t){if(t===0)return!1;let r=Math.max(n.length,e.length);if(r<=2||t*2>=r)return!0;let o=[...n,...e].map(Ve);return o[0]!==null&&o.every(i=>i===o[0])}function Ve(n){let e=n.trimStart();return/^[-*+]\s+/.test(e)?"bullet":/^\d+[.)]\s+/.test(e)?"ordered":/^>\s+/.test(e)?"quote":null}var Ce=1e4,te=2e3,Je=.52,Ze=.35,_e=.38,Qe=.33,ke=.86,j=.08,z=.05,q=-.12,be=5e3,en=2e3,nn=5e7,we=4,tn=8,Q=4;function Se(n){let e=[];for(let t=0;t<n.length;t++){let r=n[t],o=[r],i=r.match(/^(\s*)(?:[\w-]+:\s+|[-*+]\s+)(\S.*)$/);if(i&&!/^[|>\[{]/.test(i[2]))for(;t+1<n.length;){let s=n[t+1];if(!s.trim()||s.length-s.trimStart().length<=i[1].length||/^\s*(?:[\w-]+:|[-*+]\s|\d+[.)]\s|#)/.test(s))break;o.push(s),t++}e.push(o.join(`
5
+ `))}return e}function K(n,e){if([...n,...e].some(o=>o.includes(`
6
+ `)))return ee(n,e);let t=Se(n),r=Se(e);return t.length===n.length&&r.length===e.length?ee(n,e):ee(t,r).flatMap(o=>{let i=o.left?.split(`
7
+ `)||[],s=o.right?.split(`
8
+ `)||[];if(!i.length||!s.length)return[...i.map(u=>({left:u})),...s.map(u=>({right:u}))];if(i.length===1&&s.length===1)return[o];let d=le(o.left,o.right)||se(o.left,o.right),c=d&&k(d.leftSegments),f=d&&k(d.rightSegments);return Array.from({length:Math.max(i.length,s.length)},(u,h)=>({left:i[h],right:s[h],reflow:{start:h===0,leftSegments:c?.[h],rightSegments:f?.[h]}}))})}function ee(n,e){if(n.length===0)return e.map(a=>({right:a}));if(e.length===0)return n.map(a=>({left:a}));let t=0;for(;t<Math.min(n.length,e.length)&&n[t].trim()===e[t].trim();)t++;if(t)return[...n.slice(0,t).map((a,g)=>({left:a,right:e[g]})),...K(n.slice(t),e.slice(t))];let r=1,o=1,i=n[0].trim().replace(/\s+/g," "),s=e[0].trim().replace(/\s+/g," ");for(;i&&s&&i!==s;)if(s.startsWith(i+" ")&&r<n.length)i+=" "+n[r++].trim().replace(/\s+/g," ");else if(i.startsWith(s+" ")&&o<e.length)s+=" "+e[o++].trim().replace(/\s+/g," ");else break;if(i===s&&(r>1||o>1)&&![...n,...e].some(a=>a.includes(`
9
+ `))){let a=le(n.slice(0,r).join(`
10
+ `),e.slice(0,o).join(`
11
+ `));if(a){let g=k(a.leftSegments),m=k(a.rightSegments);return[...Array.from({length:Math.max(r,o)},(w,p)=>({left:p<r?n[p]:void 0,right:p<o?e[p]:void 0,reflow:{start:p===0,leftSegments:g[p],rightSegments:m[p]}})),...K(n.slice(r),e.slice(o))]}}let l=n.reduce((a,g)=>a+Math.min(g.length,te),0),d=e.reduce((a,g)=>a+Math.min(g.length,te),0);if(l*d>nn)return ye(n,e,!0);if(n.length===1&&e.length===1){let a=V(n[0],e[0]);return!n[0].trim()&&!e[0].trim()||(a.eligible||a.score>=Ze)&&ne(n[0],e[0])&&ie(n[0],e[0])&&B(R(n[0]))&&B(R(e[0]))?[{left:n[0],right:e[0]}]:[{left:n[0]},{right:e[0]}]}if(n.length*e.length>Ce)return ye(n,e);let c=rn(n,e),f=Array.from({length:n.length+1},()=>new Array(e.length+1).fill(Number.NEGATIVE_INFINITY)),u=Array.from({length:n.length+1},()=>new Array(e.length+1).fill(null));f[0][0]=0;for(let a=1;a<=n.length;a++)f[a][0]=f[a-1][0]+q,u[a][0]="left";for(let a=1;a<=e.length;a++)f[0][a]=f[0][a-1]+q,u[0][a]="right";for(let a=1;a<=n.length;a++)for(let g=1;g<=e.length;g++){let m=c[a-1][g-1],p=[{move:"left",score:f[a-1][g]+q},{move:"right",score:f[a][g-1]+q},{move:"match",score:m===null?Number.NEGATIVE_INFINITY:f[a-1][g-1]+m}].reduce((S,x)=>x.score>S.score?x:S);f[a][g]=p.score,u[a][g]=p.move}let h=[],b=n.length,y=e.length;for(;b>0||y>0;){let a=u[b][y];a==="match"?h.push({left:n[--b],right:e[--y]}):a==="left"?h.push({left:n[--b]}):h.push({right:e[--y]})}return h.reverse()}function V(n,e){let t=R(n),r=R(e),o=B(t),i=B(r);if(o&&i&&t===r)return{score:1,eligible:!0,characterSimilarity:1,tokenSimilarity:1,lengthSimilarity:1};if(!o||!i)return{score:0,eligible:!1,characterSimilarity:0,tokenSimilarity:0,lengthSimilarity:0};let s=G(t),l=G(r),d=w=>w.length<=te?w:[0,Math.floor(w.length/2)-300,w.length-600].map(p=>w.slice(p,p+600)).join(" "),c=mn(d(t),d(r)),f=gn(s,l),u=Math.min(t.length,r.length)/Math.max(t.length,r.length),h=hn(s,l),b=w=>w.match(/^(?:(?:const|let|var)\s+)?([\p{L}_$][\p{L}\p{N}_$.-]*\s*(?::|=(?!=)))\s*/u)?.[1].replace(/\s+/g,""),y=b(t),a=y&&y===b(r)?.12:0,g=Math.min(1,c*.52+f*.32+u*.1+h*.06+a),m=a>0||c>=.52||f>=.45||c>=.48&&f>=.28;return{score:g,eligible:m&&g>=Je,characterSimilarity:c,tokenSimilarity:f,lengthSimilarity:u}}function rn(n,e){let t=n.map(a=>e.map(g=>V(a,g))),r=Oe(n,e),o=t.map(a=>re(a)),i=e.map((a,g)=>re(t.map(m=>m[g]))),s=t.map((a,g)=>a.map((m,w)=>{if(r.has(`${g}:${w}`))return Math.max(m.score,1);if(!m.eligible)return null;let p=o[g],S=i[w],x=m.score===p.best&&m.score===S.best,E=m.score>=ke?j/2:j,v=p.best-p.second>=E,N=S.best-S.second>=E;return x&&v&&N?m.score:null}));if(Math.max(n.length,e.length)>tn||Math.abs(n.length-e.length)>Q)return s;let l=(a,g,m)=>a.score>=_e&&ie(n[g],e[m])&&Math.abs(g-m)<=Q,d=t.map((a,g)=>X(a,(m,w)=>l(m,g,w))),c=e.map((a,g)=>X(t.map(m=>m[g]),(m,w)=>l(m,w,g))),f=(a,g,m)=>a.score>=Qe&&ie(n[g],e[m])&&Math.abs(g-m)<=Q,u=t.map((a,g)=>X(a,(m,w)=>f(m,g,w))),h=e.map((a,g)=>X(t.map(m=>m[g]),(m,w)=>f(m,w,g))),b=(a,g)=>{let m=t[a][g];if(!l(m,a,g))return!1;let w=d[a],p=c[g];return m.score===w.best&&m.score===p.best&&w.best-w.second>=z&&p.best-p.second>=z},y=(a,g)=>{let m=t[a][g];if(!f(m,a,g))return!1;let w=u[a],p=h[g];return m.score===w.best&&m.score===p.best&&w.best-w.second>=z&&p.best-p.second>=z};return s.map((a,g)=>a.map((m,w)=>{if(m!==null)return m;let p=b(g,w)&&(on(s,g,w)||sn(t,g,w,b)),S=ln(t,g,w,(x,E)=>f(t[x][E],x,E),y);return!p&&!S?null:t[g][w].score}))}function on(n,e,t){return e>0&&t>0&&n[e-1][t-1]!==null||e+1<n.length&&t+1<n[e+1].length&&n[e+1][t+1]!==null}function sn(n,e,t,r){return e>0&&t>0&&r(e-1,t-1)||e+1<n.length&&t+1<n[e+1].length&&r(e+1,t+1)}function ln(n,e,t,r,o){let i=e,s=t;for(;i>0&&s>0&&r(i-1,s-1);)i--,s--;let l=e,d=t,c=n[e][t].score,f=1;for(;l+1<n.length&&d+1<n[l+1].length&&r(l+1,d+1);)l++,d++,c+=n[l][d].score,f++;for(let u=e-1,h=t-1;u>=i&&h>=s;u--,h--)c+=n[u][h].score,f++;return f>=3&&c/f>=_e&&o(i,s)&&o(l,d)}function X(n,e){let t=Number.NEGATIVE_INFINITY,r=Number.NEGATIVE_INFINITY;return n.forEach((o,i)=>{e(o,i)&&(o.score>t?(r=t,t=o.score):o.score>r&&(r=o.score))}),{best:t,second:r}}function re(n){let e=Number.NEGATIVE_INFINITY,t=Number.NEGATIVE_INFINITY;for(let r of n)r.eligible&&(r.score>e?(t=e,e=r.score):r.score>t&&(t=r.score));return{best:e,second:t}}function ye(n,e,t=!1){let r=fn(n,e,t);if(r.length===0)return[...n.map(l=>({left:l})),...e.map(l=>({right:l}))];let o=[],i=0,s=0;for(let l of r)Le(o,n.slice(i,l.leftIndex),e.slice(s,l.rightIndex)),o.push({left:n[l.leftIndex],right:e[l.rightIndex]}),i=l.leftIndex+1,s=l.rightIndex+1;return Le(o,n.slice(i),e.slice(s)),o}function fn(n,e,t){let r=an(n,e,t);if(r===null)return[];let o=Oe(n,e),i=r.map(({leftIndex:f,rightIndex:u,exact:h})=>({leftIndex:f,rightIndex:u,exact:h,structural:o.has(`${f}:${u}`),match:V(n[f],e[u])})).filter(f=>f.exact||f.structural||f.match.eligible),s=Ee(i,"leftIndex"),l=Ee(i,"rightIndex"),d=i.filter(f=>{if(f.exact||f.structural)return!0;let u=s.get(f.leftIndex),h=l.get(f.rightIndex);if(!u||!h||f.match.score!==u.best||f.match.score!==h.best)return!1;let b=f.match.score>=ke?j/2:j;return u.best-u.second>=b&&h.best-h.second>=b}),c=cn(d,e.length);return c.length<=en?c:[]}function an(n,e,t){let r=xe(n,R),o=xe(e,R),i=new Map;for(let[d,c]of r){let f=o.get(d);if(!B(d)||c.length!==1||f?.length!==1)continue;let u=c[0],h=f[0];if(i.set(`${u}:${h}`,{leftIndex:u,rightIndex:h,exact:!0}),i.size>be)return null}if(t)return[...i.values()];let s=Ne(n),l=Ne(e);for(let[d,c]of s){let f=l.get(d);if(!(!f||c.length>we||f.length>we))for(let u of c)for(let h of f){let b=`${u}:${h}`;if(!i.has(b)&&(i.set(b,{leftIndex:u,rightIndex:h,exact:!1}),i.size>be))return null}}return[...i.values()]}function xe(n,e){let t=new Map;return n.forEach((r,o)=>{let i=e(r),s=t.get(i)??[];s.push(o),t.set(i,s)}),t}function Ne(n){let e=new Map;return n.forEach((t,r)=>{let o=new Set(G(R(t)).filter(un));for(let i of o){let s=e.get(i)??[];s.push(r),e.set(i,s)}}),e}function un(n){return n.length>=2&&/[\p{L}\p{N}_$]/u.test(n)}function Ee(n,e){let t=new Map;for(let r of n){let o=t.get(r[e])??[];o.push(r.match),t.set(r[e],o)}return new Map([...t].map(([r,o])=>[r,re(o)]))}function cn(n,e){let t=[...n].sort((c,f)=>c.leftIndex-f.leftIndex||c.rightIndex-f.rightIndex),r=new Array(e+2).fill(0),o=new Array(e+2).fill(-1),i=new Array(t.length).fill(0),s=new Array(t.length).fill(-1);for(let c=0;c<t.length;){let f=c+1;for(;f<t.length&&t[f].leftIndex===t[c].leftIndex;)f++;for(let u=c;u<f;u++){let h=Ie(r,o,t[u].rightIndex),b=t[u].exact||t[u].structural?.5:0;i[u]=h.score+t[u].match.score+b,s[u]=h.candidateIndex}for(let u=c;u<f;u++)dn(r,o,t[u].rightIndex+1,i[u],u);c=f}let l=Ie(r,o,e+1),d=[];for(let c=l.candidateIndex;c>=0;c=s[c])d.push({leftIndex:t[c].leftIndex,rightIndex:t[c].rightIndex});return d.reverse()}function Ie(n,e,t){let r=0,o=-1;for(let i=t;i>0;i-=i&-i)n[i]>r&&(r=n[i],o=e[i]);return{score:r,candidateIndex:o}}function dn(n,e,t,r,o){for(let i=t;i<n.length;i+=i&-i)r>n[i]&&(n[i]=r,e[i]=o)}function Le(n,e,t){if(e.length*t.length<=Ce){n.push(...K(e,t));return}n.push(...e.map(r=>({left:r}))),n.push(...t.map(r=>({right:r})))}function R(n){return n.trim().replace(/\s+/g," ")}function Oe(n,e){let t=De(n),r=De(e),o=new Set;for(let[i,s]of t){let l=r.get(i);s.length===1&&l?.length===1&&o.add(`${s[0]}:${l[0]}`)}return o}function De(n){let e=new Map;return n.forEach((t,r)=>{let o=$(t);if(!o)return;let i=e.get(o)??[];i.push(r),e.set(o,i)}),e}function ie(n,e){let t=$(n),r=$(e);return!t||!r?t===r:t.split(":",1)[0]===r.split(":",1)[0]}function $(n){let e=R(n),t=[["function",/^(?:(?:export|default)\s+)*(?:async\s+)?function\s*\*?\s*([\p{L}_$][\p{L}\p{N}_$]*)\s*\(/u],["function",/^(?:async\s+)?def\s+([\p{L}_][\p{L}\p{N}_]*)\s*\(/u],["function",/^(?:pub(?:\([^)]*\))?\s+)?(?:async\s+)?fn\s+([\p{L}_][\p{L}\p{N}_]*)\s*(?:<[^>]*>)?\s*\(/u],["function",/^func\s+(?:\([^)]*\)\s*)?([\p{L}_][\p{L}\p{N}_]*)\s*\(/u],["class",/^(?:(?:export|default|abstract|public)\s+)*class\s+([\p{L}_$][\p{L}\p{N}_$]*)\b/u]];for(let[r,o]of t){let i=e.match(o);if(i)return`${r}:${i[1]}`}return null}function B(n){return n.length<3?!1:/[\p{L}\p{N}_$]/u.test(n)&&!/^[\s()[\]{};,.:+\-*/=>|&!?'"`]+$/.test(n)}function G(n){return n.toLowerCase().match(/[\p{L}_$][\p{L}\p{N}_$]*|\p{N}+(?:\.\p{N}+)?|[^\s\p{L}\p{N}_$]/gu)??[]}function gn(n,e){if(n.length+e.length===0)return 1;let t=new Map;n.forEach(o=>t.set(o,(t.get(o)??0)+1));let r=0;for(let o of e){let i=t.get(o)??0;i>0&&(r++,t.set(o,i-1))}return 2*r/(n.length+e.length)}function hn(n,e){if(n.length===0||e.length===0)return 0;let t=n[0]===e[0]?.5:0,r=n[n.length-1]===e[e.length-1]?.5:0;return t+r}function mn(n,e){let t=n.length+e.length;return t===0?1:2*ue(n,e).filter(o=>!o.added&&!o.removed).reduce((o,i)=>o+i.value.length,0)/t}function pn(n,e){let t=le(n.content,e.content);if(t){n.segments=t.leftSegments,e.segments=t.rightSegments;return}let r=se(n.content,e.content);r&&(n.segments=r.leftSegments,e.segments=r.rightSegments)}function vn(n,e){if(!n.length||!e.length||n.length===1&&e.length===1)return;let t=f=>f.reduce((u,h)=>u+h.content.length+1,-1);if(t(n)>Y||t(e)>Y)return;let r=n.map(f=>f.content).join(`
12
+ `),o=e.map(f=>f.content).join(`
13
+ `),i=se(r,o);if(!i)return;let{leftSegments:s,rightSegments:l}=i,d=k(s),c=k(l);n.forEach((f,u)=>{f.segments=d[u]}),e.forEach((f,u)=>{f.segments=c[u]})}function Me(n){/[^\s]/.test(n.content)&&(n.segments=[{kind:n.kind,text:n.content,emphasis:!0}])}var oe=new Intl.Segmenter(void 0,{granularity:"grapheme"});function bn(n,e){if(n===e)return n?[{value:n}]:[];let t=Array.from(oe.segment(n),l=>l.segment),r=Array.from(oe.segment(e),l=>l.segment),o=Math.min(t.length,r.length),i=0,s=0;for(;i<o&&t[i]===r[i];)i++;for(;s<o&&t[t.length-s-1]===r[r.length-s-1];)s++;return s===o&&i<o&&(i=0),s=Math.min(s,o-i),[{value:t.slice(0,i).join("")},{value:t.slice(i,t.length-s).join(""),removed:!0},{value:r.slice(i,r.length-s).join(""),added:!0},{value:s?t.slice(-s).join(""):""}].filter(l=>l.value.length>0)}function wn(n,e){let t=ce(n,e,{timeout:Ae,maxEditLength:2e3});if(!t)return;let r=u=>new Set([...Array.from(oe.segment(u),h=>h.index),u.length]),o=r(n),i=r(e),s=[],l=0,d=0,c="",f="";for(let u=0;u<t.length;){let h=t[u];if(!h.added&&!h.removed)c+=h.value,f+=h.value,l+=h.value.length,d+=h.value.length,u++;else for(;u<t.length&&(t[u].added||t[u].removed);){let b=t[u++];b.removed?(c+=b.value,l+=b.value.length):(f+=b.value,d+=b.value.length)}if(o.has(l)&&i.has(d)){for(let b of bn(c,f)){let y=s[s.length-1];y&&y.added===b.added&&y.removed===b.removed?y.value+=b.value:s.push(b)}c="",f=""}}return s}function se(n,e){if(n.length>Y||e.length>Y)return;let t=wn(n,e);if(!t)return;let r=[],o=[],i=!1;for(let s of t){let l=s.value;if(!s.added&&!s.removed){let c={kind:"context",text:l,emphasis:!1};r.push(c),o.push(c);continue}let d=l.length>0;i=i||d,s.removed&&r.push({kind:"removed",text:l,emphasis:d}),s.added&&o.push({kind:"added",text:l,emphasis:d})}return{leftSegments:r,rightSegments:o,hasInlineChanges:i}}function le(n,e){let t=n.split(/(\S+)/),r=e.split(/(\S+)/);if(t.length!==r.length||t.some((l,d)=>d%2===1&&l!==r[d]))return;let o=[],i=[],s=(l,d,c)=>{if(!c)return;let f=l[l.length-1];f?.kind===d?f.text+=c:l.push({kind:d,text:c,emphasis:d!=="context"})};return t.forEach((l,d)=>{let c=r[d],f=0;if(d>0)for(;f<Math.min(l.length,c.length)&&l[f]===c[f];)f++;let u=0;for(;u<Math.min(l.length,c.length)-f&&l[l.length-u-1]===c[c.length-u-1];)u++;if(d===0)for(;f<Math.min(l.length,c.length)-u&&l[f]===c[f];)f++;s(o,"context",l.slice(0,f)),s(i,"context",c.slice(0,f)),s(o,"removed",l.slice(f,l.length-u)),s(i,"added",c.slice(f,c.length-u)),s(o,"context",l.slice(l.length-u)),s(i,"context",c.slice(c.length-u))}),{leftSegments:o,rightSegments:i}}function k(n){let e=[[]];for(let t of n)t.text.split(`
14
+ `).forEach((r,o)=>{o>0&&e.push([]),r&&e[e.length-1].push({...t,text:r})});return e}function O(){return{kind:"placeholder",content:"",lineNumber:null}}function M(n,e,t){return{kind:n,content:e,lineNumber:t}}function A(n,e,t){return{kind:n,content:e,lineNumber:t}}function _(n,e){return{left:n,right:e}}function W(n,e,t,r,o){return{kind:n,leftStart:e,leftEnd:t,rightStart:r,rightEnd:o}}function Fe(n,e){let t=typeof process<"u"?process.env?.[n]:void 0,r=Number.parseInt(t??"",10);return Number.isFinite(r)&&r>0?r:e}self.addEventListener("message",n=>{let{id:e,leftContent:t,rightContent:r}=n.data||{};if(!(typeof e!="number"||typeof t!="string"||typeof r!="string"))try{let o=Re(t,r);self.postMessage({id:e,model:o})}catch(o){self.postMessage({id:e,error:o&&o.message||String(o)})}});})();
5
15
  //# sourceMappingURL=diff.worker.js.map