@davmash/bygone 0.10.1 → 0.11.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.
- package/CHANGELOG.md +25 -0
- package/README.md +64 -0
- package/bin/bygone.js +18 -1
- package/cli/commandSpec.js +22 -2
- package/cli/completions.js +30 -8
- package/cli/correspondence.js +71 -0
- package/cli/dependencies.js +62 -0
- package/cli/evidence.js +67 -0
- package/cli/present.js +61 -16
- package/cli/tour.js +18 -1
- package/cli/tourExport.js +1 -1
- package/completions/_bygone +15 -3
- package/completions/bygone +13 -5
- package/completions/bygone.fish +9 -0
- package/docs/change-tour-format.md +60 -6
- package/docs/correspondence.md +259 -0
- package/docs/dependencies.md +94 -0
- package/docs/evidence-review.md +163 -0
- package/docs/generating-change-tours.md +3 -0
- package/docs/present.md +3 -0
- package/docs/product-surface.md +2 -1
- package/docs/releasing.md +11 -0
- package/docs/vscode-integration.md +183 -0
- package/media/diff.worker.js +10 -9
- package/media/webview.css +1 -1
- package/media/webview.js +167 -167
- package/out/changeCorrespondence.js +739 -0
- package/out/changeTour.js +1366 -967
- package/out/dependencyGraph.js +213939 -0
- package/out/gitComparison.js +4 -0
- package/out/requirements.js +427 -0
- package/out/reviewDependencies.js +669 -0
- package/out/reviewWorkspace.js +1129 -0
- package/out/standalone-main.js +3382 -1341
- package/out/tourCoverage.js +1852 -1448
- package/package.json +2 -2
- package/schemas/change-tour-source.schema.json +48 -3
- package/web/export-runtime.json +6 -6
- package/web/index.html +13 -0
- package/web/presenter.css +81 -0
- package/web/web-host.js +23 -20
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
# VS Code SCM, symbols and document editing
|
|
2
|
+
|
|
3
|
+
The contextual Bygone panel uses VS Code's built-in Git API for repository
|
|
4
|
+
identity and change notifications. Source Control actions choose HEAD → index
|
|
5
|
+
or index → working document. Ordinary source following chooses HEAD → working
|
|
6
|
+
document. Symbol navigation changes the focus within that comparison, never
|
|
7
|
+
its revisions. Native SCM diff following is opt-in.
|
|
8
|
+
|
|
9
|
+
## Snapshot and edit contract
|
|
10
|
+
|
|
11
|
+
`followController.ts` owns the comparison and captured endpoints. HEAD and index
|
|
12
|
+
reads are checked again before publication; working content comes from the open
|
|
13
|
+
`TextDocument`, including unsaved edits. Each policy reads only its endpoints.
|
|
14
|
+
Staged comparisons therefore remain usable even if unrelated working bytes are
|
|
15
|
+
binary or oversized. Git renames retain separate source and destination paths.
|
|
16
|
+
|
|
17
|
+
The installed document-symbol provider identifies the enclosing declaration.
|
|
18
|
+
`liveSymbols.ts` runs Strand's existing inventory and correspondence matcher in
|
|
19
|
+
a cancelable worker. Whole-snapshot and symbol-substring digests are checked
|
|
20
|
+
before accepting ranges. Dirty-to-staged navigation needs an accepted mapping;
|
|
21
|
+
matching names or offsets are insufficient. Committed correspondence artifacts
|
|
22
|
+
and their validation contract are unchanged.
|
|
23
|
+
|
|
24
|
+
Native insertions exactly at either edge of a focused symbol return to file
|
|
25
|
+
context: the inserted text may belong to that declaration or its neighbor.
|
|
26
|
+
Boundary edits made inside Bygone retain the known slice binding. Edits strictly
|
|
27
|
+
inside a slice and shifts caused by edits before it continue to track normally.
|
|
28
|
+
|
|
29
|
+
Working full-file views and symbol slices are projections of the same document.
|
|
30
|
+
`followSync.js` allows one edit in flight and keeps subsequent typing until an
|
|
31
|
+
acknowledgment. `followEdits.ts` computes a granular replacement, preserving
|
|
32
|
+
unrelated text and UTF-16/CRLF boundaries. Before submission, the controller
|
|
33
|
+
checks the projection identity, document version, range and content. An older
|
|
34
|
+
token from an unchanged refresh is accepted only when all those checks still
|
|
35
|
+
match the current projection; a changed version is always rejected. There is no
|
|
36
|
+
asynchronous gap between that check and `workspace.applyEdit`.
|
|
37
|
+
|
|
38
|
+
VS Code's extension host attaches the open document's version to bulk text edits;
|
|
39
|
+
the main thread rejects a changed version before applying them. See the
|
|
40
|
+
[1.74 extension-host bulk edit implementation](https://github.com/microsoft/vscode/blob/1.74.0/src/vs/workbench/api/common/extHostBulkEdits.ts)
|
|
41
|
+
and [main-thread validation](https://github.com/microsoft/vscode/blob/1.74.0/src/vs/workbench/contrib/bulkEdit/browser/bulkTextEdits.ts).
|
|
42
|
+
The integration suite submits competing native and Bygone edits without waiting
|
|
43
|
+
between them and verifies rejection rather than an overwritten native edit.
|
|
44
|
+
|
|
45
|
+
Rejected drafts open in untitled recovery documents. Pending text is also kept
|
|
46
|
+
in workspace state for restoration. Draft clearing is guarded against newer
|
|
47
|
+
drafts. Save, undo and redo operate on the authoritative VS Code document; typing
|
|
48
|
+
does not save or stage. Other comparison panels observe the document change.
|
|
49
|
+
The existing manual two-way bridge also checks its base text and document version.
|
|
50
|
+
|
|
51
|
+
Save, undo and redo retain the document binding from when they were requested.
|
|
52
|
+
Commands queued behind an edit execute in order, including repeated undo requests.
|
|
53
|
+
If the comparison changes before a document command executes, Bygone rejects it
|
|
54
|
+
with a notice rather than applying it to the new document. Recovery deduplicates
|
|
55
|
+
a draft only against an entire current, version-validated projection; a matching
|
|
56
|
+
prefix or an obsolete snapshot is insufficient.
|
|
57
|
+
|
|
58
|
+
Pin freezes the target, historical snapshots and symbol focus. A pinned working
|
|
59
|
+
projection remains editable. Repository changes produce a notice until Resume;
|
|
60
|
+
unpinned comparisons keep their policy when a file leaves its SCM group.
|
|
61
|
+
Live staged and working comparisons reconcile Git-reported rename paths while
|
|
62
|
+
preserving their comparison policy. A captured staged pin remains
|
|
63
|
+
visible even if the live index enters a conflict; Resume checks the current
|
|
64
|
+
index again. Working-change actions also appear in Git's separate untracked group.
|
|
65
|
+
If the Git API repository disappears, live SCM comparisons become unavailable
|
|
66
|
+
until it returns. Captured staged pins remain read-only and explicitly report
|
|
67
|
+
that Git integration is unavailable; Resume requires the repository again.
|
|
68
|
+
|
|
69
|
+
## Supported scope and budgets
|
|
70
|
+
|
|
71
|
+
- Trusted local text files; maximum 128 KiB and 5,000 lines per endpoint.
|
|
72
|
+
- JavaScript/TypeScript symbol analysis, including JSX/TSX, for the selected file
|
|
73
|
+
pair or Git-reported rename. No repository-wide cross-file symbol matching.
|
|
74
|
+
- HEAD/index/absent endpoints are read-only. Conflicts, binary/invalid text and
|
|
75
|
+
unsupported editor inputs have explicit unavailable states.
|
|
76
|
+
- The matcher allows 300 ms, 20,000 candidate comparisons and 2,000 result records.
|
|
77
|
+
A 2.5-second worker deadline also bounds inventory/parsing and startup. Cancellation
|
|
78
|
+
terminates stale workers. File rendering does not wait for optional analysis.
|
|
79
|
+
- Missing, ambiguous or budget-limited correspondence retains file context or a
|
|
80
|
+
known one-sided slice; it never supplies an inferred counterpart. Invalid syntax
|
|
81
|
+
during typing retains the guarded editable range until it can be analyzed again.
|
|
82
|
+
|
|
83
|
+
## Reproducing verification
|
|
84
|
+
|
|
85
|
+
Run the normal checks from a clean dependency install:
|
|
86
|
+
|
|
87
|
+
```sh
|
|
88
|
+
npm ci
|
|
89
|
+
npm test
|
|
90
|
+
npm run lint
|
|
91
|
+
npm run bundle:check
|
|
92
|
+
npm run package:vsix
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
The Extension Host runner makes disposable synthetic repositories and a disposable
|
|
96
|
+
extension profile. It never stages, commits or checks out the developer's repository.
|
|
97
|
+
On Linux with Xvfb and an installed VS Code binary:
|
|
98
|
+
|
|
99
|
+
```sh
|
|
100
|
+
BYGONE_VSCODE_EXECUTABLE=/path/to/code xvfb-run -a node scripts/test-following.mjs
|
|
101
|
+
BYGONE_SCM_TEST=1 BYGONE_VSCODE_EXECUTABLE=/path/to/code xvfb-run -a node scripts/test-following.mjs
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Set `BYGONE_VSCODE_VERSION` instead to let the runner download a version. Compile
|
|
105
|
+
first (`npm test` includes compilation). The SCM suite injects a renderer driver
|
|
106
|
+
only into the disposable test bundle, so it exercises actual Monaco edits and
|
|
107
|
+
messages without adding production test commands.
|
|
108
|
+
|
|
109
|
+
## Verification record: 2026-10-24
|
|
110
|
+
|
|
111
|
+
Implementation branch: `feat/vscode-scm-symbol-integration`, based on
|
|
112
|
+
`ec318cfbd9d9cddef2fcac150723958c0f7987c2`. These checks ran against the feature
|
|
113
|
+
implementation before its initial commit, not a published release.
|
|
114
|
+
|
|
115
|
+
| Check | Result |
|
|
116
|
+
| --- | --- |
|
|
117
|
+
| Regression suite | 433 Node tests plus the existing diff-engine runner passed |
|
|
118
|
+
| TypeScript, ESLint, renderer size budgets | Passed |
|
|
119
|
+
| VSIX contents and packaging | Passed; 14 archive entries, 2.65 MB compressed, including the 3.39 MiB Strand worker |
|
|
120
|
+
| Original following suite | 16 cases passed on VS Code 1.74.0 and 1.143.1, Linux ARM64 in a fresh Lima guest checkout |
|
|
121
|
+
| SCM/symbol/editing suite | 19 cases passed on both versions; staged/dirty separation, full-file and slice edits, save/shared undo/redo, range shifts, temporary syntax errors, concurrent rejection/recovery, composition across unchanged refreshes, rapid typing, multiple panels, exact snapshot reveal, native Git lifecycle and disabled-Git fallback |
|
|
122
|
+
| Snapshot fixtures | Added/deleted/renamed files, unborn HEAD, linked worktrees, multiple repositories, conflict stages, encoding/binary/size rejection |
|
|
123
|
+
| Symbol adapter | Renames, duplicate method names, unmatched additions, digest/range validation and worker cancellation |
|
|
124
|
+
|
|
125
|
+
Cold worker measurements in the same Linux ARM64 guest (three runs per input,
|
|
126
|
+
adding an unsaved prefix; no warm worker reuse):
|
|
127
|
+
|
|
128
|
+
| Input | Bytes | Symbols / accepted pairs | Elapsed |
|
|
129
|
+
| --- | ---: | ---: | ---: |
|
|
130
|
+
| `followEdits.ts` | 2,272 | 6 / 6 | 109–153 ms |
|
|
131
|
+
| `gitIntegration.ts` | 4,403 | 22 / 22 | 111–171 ms |
|
|
132
|
+
| `followController.ts` | 35,789 | 70 / 70 | 222–238 ms |
|
|
133
|
+
| 50 repetitive generated functions | 3,380 | 50 / 0 (record budget) | 122–130 ms |
|
|
134
|
+
| 500 repetitive generated functions | 34,781 | 500 / 0 (candidate budget) | 186–202 ms |
|
|
135
|
+
|
|
136
|
+
These are bounded fixture observations, not a general latency guarantee.
|
|
137
|
+
The repetitive cases deliberately demonstrate safe budget fallbacks.
|
|
138
|
+
|
|
139
|
+
Verification limits: IME coverage dispatches composition events in real Monaco;
|
|
140
|
+
it does not drive an operating-system input method. Symbol navigation exercises
|
|
141
|
+
the installed TypeScript provider and command-generated cursor selections, not
|
|
142
|
+
physical clicks in Outline/Go to Symbol. Restoration exercises the serializer
|
|
143
|
+
and persisted-draft constructor path, not a whole application restart. Remote and
|
|
144
|
+
untrusted workspace guards were inspected; a remote host and restricted-mode
|
|
145
|
+
window were not launched. macOS/Windows Extension Hosts, marketplace installation,
|
|
146
|
+
release CI and publication were not exercised.
|
|
147
|
+
|
|
148
|
+
## Review-fix verification: 2026-10-26
|
|
149
|
+
|
|
150
|
+
The fixes applied over `cfd5e335d75f2be324c0865abe4c2f5bdece06f5` passed
|
|
151
|
+
435 Node tests plus the existing diff-engine runner, TypeScript compilation,
|
|
152
|
+
ESLint, renderer size budgets and VSIX packaging. In a fresh Linux ARM64 Lima
|
|
153
|
+
checkout, all 25 SCM cases and all 16 original following cases passed on each
|
|
154
|
+
of VS Code 1.74.0 and 1.143.1. Host and guest source/test SHA-256 hashes matched.
|
|
155
|
+
|
|
156
|
+
Six added Extension Host cases cover complete rejected deletion/reversion recovery,
|
|
157
|
+
deferred Save/Undo/Redo across a comparison switch, repeated Undo followed by
|
|
158
|
+
Save and Pin, a live staged rename, conflict-after-staged-pin, and separate
|
|
159
|
+
untracked resources. The untracked case checks the contributed menu conditions
|
|
160
|
+
and executes the command with a resource argument; it does not physically click
|
|
161
|
+
the SCM menu. The earlier platform, IME, restart, remote/restricted-host and
|
|
162
|
+
release-verification limits still apply.
|
|
163
|
+
|
|
164
|
+
## Rebase and follow-up fixes: 2026-10-26
|
|
165
|
+
|
|
166
|
+
Rebased onto main `728f41e6`, preserving both the requirements and VS Code
|
|
167
|
+
build/test entries. The rebased changes passed 464 Node tests plus the existing
|
|
168
|
+
diff-engine runner. Final source passed TypeScript, ESLint, renderer size budgets
|
|
169
|
+
and VSIX packaging. A fresh Linux ARM64 Lima checkout passed all 29 SCM cases
|
|
170
|
+
and all 16 following cases on each of VS Code 1.74.0 and 1.143.1.
|
|
171
|
+
|
|
172
|
+
New regressions cover native insertions at both symbol boundaries, index refresh
|
|
173
|
+
for two-dot filenames, live working comparisons through successive staged
|
|
174
|
+
renames, loss/recovery of the Git API in an already-open comparison, and the
|
|
175
|
+
explicit read-only snapshot behavior of a staged pin while Git is unavailable.
|
|
176
|
+
The platform and interaction limits above still apply; hosted CI was not run.
|
|
177
|
+
|
|
178
|
+
## Pinned evidence handoff
|
|
179
|
+
|
|
180
|
+
[Evidence Review](evidence-review.md) uses this same editing bridge for full-file
|
|
181
|
+
and exact symbol projections. Its left endpoint is an immutable cited snapshot,
|
|
182
|
+
and its Return action restores the originating review. It does not stage files
|
|
183
|
+
or alter saved evidence while editing.
|
package/media/diff.worker.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
"use strict";(()=>{function C(){}C.prototype={diff:function(e,t){var
|
|
2
|
-
`));var e=[],t=n.split(/(\n|\r\n)/);t[t.length-1]||t.pop();for(var
|
|
1
|
+
"use strict";(()=>{function C(){}C.prototype={diff:function(e,t){var i,o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},r=o.callback;typeof o=="function"&&(r=o,o={}),this.options=o;var s=this;function l(x){return r?(setTimeout(function(){r(void 0,x)},0),!0):x}e=this.castInput(e),t=this.castInput(t),e=this.removeEmpty(this.tokenize(e)),t=this.removeEmpty(this.tokenize(t));var d=t.length,u=e.length,f=1,a=d+u;o.maxEditLength&&(a=Math.min(a,o.maxEditLength));var v=(i=o.timeout)!==null&&i!==void 0?i:1/0,m=Date.now()+v,p=[{oldPos:-1,lastComponent:void 0}],c=this.extractCommon(p[0],t,e,0);if(p[0].oldPos+1>=u&&c+1>=d)return l([{value:this.join(t),count:t.length}]);var h=-1/0,g=1/0;function b(){for(var x=Math.max(h,-f);x<=Math.min(g,f);x+=2){var y=void 0,I=p[x-1],w=p[x+1];I&&(p[x-1]=void 0);var N=!1;if(w){var E=w.oldPos-x;N=w&&0<=E&&E<d}var T=I&&I.oldPos+1<u;if(!N&&!T){p[x]=void 0;continue}if(!T||N&&I.oldPos+1<w.oldPos?y=s.addToPath(w,!0,void 0,0):y=s.addToPath(I,void 0,!0,1),c=s.extractCommon(y,t,e,x),y.oldPos+1>=u&&c+1>=d)return l(We(s,y.lastComponent,t,e,s.useLongestToken));p[x]=y,y.oldPos+1>=u&&(g=Math.min(g,x-1)),c+1>=d&&(h=Math.max(h,x+1))}f++}if(r)(function x(){setTimeout(function(){if(f>a||Date.now()>m)return r();b()||x()},0)})();else for(;f<=a&&Date.now()<=m;){var S=b();if(S)return S}},addToPath:function(e,t,i,o){var r=e.lastComponent;return r&&r.added===t&&r.removed===i?{oldPos:e.oldPos+o,lastComponent:{count:r.count+1,added:t,removed:i,previousComponent:r.previousComponent}}:{oldPos:e.oldPos+o,lastComponent:{count:1,added:t,removed:i,previousComponent:r}}},extractCommon:function(e,t,i,o){for(var r=t.length,s=i.length,l=e.oldPos,d=l-o,u=0;d+1<r&&l+1<s&&this.equals(t[d+1],i[l+1]);)d++,l++,u++;return u&&(e.lastComponent={count:u,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=[],i=0;i<e.length;i++)e[i]&&t.push(e[i]);return t},castInput:function(e){return e},tokenize:function(e){return e.split("")},join:function(e){return e.join("")}};function We(n,e,t,i,o){for(var r=[],s;e;)r.push(e),s=e.previousComponent,delete e.previousComponent,e=s;r.reverse();for(var l=0,d=r.length,u=0,f=0;l<d;l++){var a=r[l];if(a.removed){if(a.value=n.join(i.slice(f,f+a.count)),f+=a.count,l&&r[l-1].added){var m=r[l-1];r[l-1]=r[l],r[l]=m}}else{if(!a.added&&o){var v=t.slice(u,u+a.count);v=v.map(function(c,h){var g=i[f+h];return g.length>c.length?g:c}),a.value=n.join(v)}else a.value=n.join(t.slice(u,u+a.count));u+=a.count,a.added||(f+=a.count)}}var p=r[d-1];return d>1&&typeof p.value=="string"&&(p.added||p.removed)&&n.equals("",p.value)&&(r[d-2].value+=p.value,r.pop()),r}var $e=new C;function de(n,e,t){return $e.diff(n,e,t)}var ue=/^[A-Za-z\xC0-\u02C6\u02C8-\u02D7\u02DE-\u02FF\u1E00-\u1EFF]+$/,ce=/\S/,Q=new C;Q.equals=function(n,e){return this.options.ignoreCase&&(n=n.toLowerCase(),e=e.toLowerCase()),n===e||this.options.ignoreWhitespace&&!ce.test(n)&&!ce.test(e)};Q.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]&&ue.test(e[t])&&ue.test(e[t+2])&&(e[t]+=e[t+2],e.splice(t+1,2),t--);return e};function ge(n,e,t){return Q.diff(n,e,t)}var he=new C;he.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 i=0;i<t.length;i++){var o=t[i];i%2&&!this.options.newlineIsToken?e[e.length-1]+=o:(this.options.ignoreWhitespace&&(o=o.trim()),e.push(o))}return e};var Be=new C;Be.tokenize=function(n){return n.split(/(\S.+?[.!?])(?=\s+|$)/)};var Ge=new C;Ge.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 Ue=Object.prototype.toString,W=new C;W.useLongestToken=!0;W.tokenize=he.tokenize;W.castInput=function(n){var e=this.options,t=e.undefinedReplacement,i=e.stringifyReplacer,o=i===void 0?function(r,s){return typeof s>"u"?t:s}:i;return typeof n=="string"?n:JSON.stringify(Z(n,null,null,o),o," ")};W.equals=function(n,e){return C.prototype.equals.call(W,n.replace(/,([\r\n])/g,"$1"),e.replace(/,([\r\n])/g,"$1"))};function Z(n,e,t,i,o){e=e||[],t=t||[],i&&(n=i(o,n));var r;for(r=0;r<e.length;r+=1)if(e[r]===n)return t[r];var s;if(Ue.call(n)==="[object Array]"){for(e.push(n),s=new Array(n.length),t.push(s),r=0;r<n.length;r+=1)s[r]=Z(n[r],e,t,i,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(),r=0;r<l.length;r+=1)d=l[r],s[d]=Z(n[d],e,t,i,d);e.pop(),t.pop()}else s=n;return s}var z=new C;z.tokenize=function(n){return n.slice()};z.join=z.removeEmpty=function(n){return n};function ee(n,e,t){return z.diff(n,e,t)}var Pe=2e4,qe=100,j=Fe("BYGONE_MAX_INLINE_HIGHLIGHT_LINE_LENGTH",Pe),Re=Fe("BYGONE_DIFF_TIMEOUT_MS",qe);function Te(n,e,t={}){let i=ve(n),o=ve(e);if(n===e)return pe(i);if(i.length===o.length&&i.every((m,p)=>m===o[p])){let m=pe(i),p=n.match(/[^\n]*\n|[^\n]+$/g)||[],c=e.match(/[^\n]*\n|[^\n]+$/g)||[];return i.forEach((h,g)=>{p[g]!==c[g]&&(m.leftLines[g].kind=m.rows[g].left.kind="removed",m.rightLines[g].kind=m.rows[g].right.kind="added",m.leftLines[g].inlineDetail=m.rightLines[g].inlineDetail="line-ending",m.blocks.push($("replace",g,g+1,g,g+1)))}),m.blocks=me(m.blocks),m.hasChanges=!0,m.formattingOnly=!0,m}let r=Xe(i,o,t.timeoutMs??Re);if(!r)return Ye(i,o);let s=[],l=[],d=[],u=[],f=1,a=1;for(let m=0;m<r.length;m++){let p=r[m],c=p.removed?p.value:[],h=p.added?p.value:[];if(!p.added&&!p.removed){for(let g of p.value)l.push(R("context",g,f)),d.push(R("context",g,a)),s.push(k(A("context",g,f++),A("context",g,a++)));continue}if(p.removed&&m+1<r.length&&r[m+1].added){let g=r[m+1],b=Ke(c,g.value,f,a,s,l,d,u);f=b.left,a=b.right,m++;continue}if(p.removed){let g=l.length,b=d.length;for(let S of c)l.push(R("removed",S,f)),s.push(k(A("removed",S,f++),H()));u.push($("delete",g,l.length,b,d.length));continue}if(p.added){let g=l.length,b=d.length;for(let S of h)d.push(R("added",S,a)),s.push(k(H(),A("added",S,a++)));u.push($("insert",g,l.length,b,d.length))}}let v=s.some(m=>m.left.kind!=="context"||m.right.kind!=="context");return Ce({rows:s,leftLines:l,rightLines:d,blocks:me(u),reflows:u.filter(m=>m.reflow),hasChanges:v,quality:"exact"})}function Ce(n){for(let e of n.blocks)if(e.kind==="replace")for(let t of["left","right"])for(let i=e[`${t}Start`];i<e[`${t}End`];i++){let o=n[`${t}Lines`][i];o.kind!=="context"&&!o.segments&&(o.inlineDetail="omitted")}return n}function me(n){let e=[],t=!1;for(let o of n){let r=o.kind!=="replace",s=e[e.length-1];r&&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=r}let i=[];for(let o of e){let r={...o};delete r.reflow;let s=i[i.length-1];s?.kind===r.kind&&s.leftEnd===r.leftStart&&s.rightEnd===r.rightStart?(s.leftEnd=r.leftEnd,s.rightEnd=r.rightEnd):i.push(r)}return i}function Xe(n,e,t){let i=Date.now()+t,o=p=>p.flatMap((c,h)=>{let g=M(c);return O(g)?[{key:g,index:h}]:[]}),r=o(n),s=o(e),l=ee(r.map(p=>p.key),s.map(p=>p.key),{timeout:i-Date.now()});if(!l)return;let d=[],u=0,f=0,a=(p,c)=>{if(u===p&&f===c)return!0;let h=je(n.slice(u,p),e.slice(f,c)),g=ee(h.left,h.right,{timeout:i-Date.now()});return g?(d.push(...g.map(b=>({...b,value:b.value.map(S=>h.lines[S])}))),!0):!1},v=0,m=0;for(let p of l){if(p.removed){v+=p.value.length;continue}if(p.added){m+=p.value.length;continue}for(let c=0;c<p.value.length;c++){let h=r[v++].index,g=s[m++].index;if(!a(h,g))return;let b=n[h],S=e[g];b===S?d.push({value:[b]}):d.push({removed:!0,value:[b]},{added:!0,value:[S]}),u=h+1,f=g+1}}return a(n.length,e.length)?d:void 0}function je(n,e){let t=new Map,i=[],o=r=>{let s=t.get(r);if(s!==void 0)return s;let l=i.length;return t.set(r,l),i.push(r),l};return{left:n.map(o),right:e.map(o),lines:i}}function pe(n){return{rows:n.map((e,t)=>k(A("context",e,t+1),A("context",e,t+1))),leftLines:n.map((e,t)=>R("context",e,t+1)),rightLines:n.map((e,t)=>R("context",e,t+1)),blocks:[],hasChanges:!1,quality:"exact"}}function Ye(n,e){let t=n.map((s,l)=>R("removed",s,l+1)),i=e.map((s,l)=>R("added",s,l+1)),o=[...n.map((s,l)=>k(A("removed",s,l+1),H())),...e.map((s,l)=>k(H(),A("added",s,l+1)))],r="replace";return n.length===0?r="insert":e.length===0&&(r="delete"),Ce({rows:o,leftLines:t,rightLines:i,blocks:o.length===0?[]:[$(r,0,n.length,0,e.length)],hasChanges:o.length>0,quality:"fallback"})}function ve(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
|
|
4
|
+
`);return e[e.length-1]===""&&e.pop(),e}function Ke(n,e,t,i,o,r,s,l){let d=K(n,e),u=d.filter(w=>w.left!==void 0&&w.right!==void 0&&re(w.left,w.right)).length,f=!d.some(w=>w.reflow)&&Je(n,e,u),a=d.flatMap(w=>w.reflow||w.left===void 0||w.right===void 0||re(w.left,w.right)?[w]:[{left:w.left},{right:w.right}]),v=[];for(let w=0;w<a.length;){let N=a[w];if(N.reflow||N.left!==void 0&&N.right!==void 0){v.push(N),w++;continue}let E=w;for(;w<a.length&&!a[w].reflow&&(a[w].left===void 0||a[w].right===void 0);)w++;let T=a.slice(E,w),L=T.filter(F=>F.left!==void 0),D=T.filter(F=>F.right!==void 0);if(L.length===1&&D.length===1)v.push({left:L[0].left,right:D[0].right});else for(let F of T)v.push(F)}let m=t,p=i,c=[],h=[],g=()=>{wn(c,h),c=[],h=[]},b,S=!1,x=r.length,y=s.length,I=()=>{if(!b)return;let w=$(b,x,r.length,y,s.length);S&&(w.reflow=!0),l.push(w)};for(let{left:w,right:N,reflow:E}of v){(E||w!==void 0&&N!==void 0)&&g();let T=f||E||w!==void 0&&N!==void 0?"replace":w!==void 0?"delete":"insert";(b!==T||S!==!!E||E?.start)&&(I(),b=T,S=!!E,x=r.length,y=s.length);let L,D;w!==void 0&&(L=R("removed",w,m),r.push(L)),N!==void 0&&(D=R("added",N,p),s.push(D)),E?(L&&(L.segments=E.leftSegments),D&&(D.segments=E.rightSegments)):L&&D?bn(L,D):f&&(L&&Ae(L),D&&Ae(D)),!E&&(w===void 0||N===void 0)&&(L&&c.push(L),D&&h.push(D)),o.push(k(w===void 0?H():A("removed",w,m++),N===void 0?H():A("added",N,p++)))}return I(),g(),{left:m,right:p}}function re(n,e){if(!n.trim()&&!e.trim()||J(n,e).eligible)return!0;let i=B(n);if(i&&i===B(e))return!0;let o=new Set(G(M(n)).filter(be));return G(M(e)).some(r=>o.has(r)&&be(r))}var Ve=new Set(["and","are","for","from","into","that","the","this","to","with"]);function be(n){return n.length>=3&&/^[\p{L}\p{N}_$]+$/u.test(n)&&!Ve.has(n)}function Je(n,e,t){if(t===0)return!1;let i=Math.max(n.length,e.length);if(i<=2||t*2>=i)return!0;let o=[...n,...e].map(Ze);return o[0]!==null&&o.every(r=>r===o[0])}function Ze(n){let e=n.trimStart();return/^[-*+]\s+/.test(e)?"bullet":/^\d+[.)]\s+/.test(e)?"ordered":/^>\s+/.test(e)?"quote":null}var ke=1e4,ie=2e3,Qe=.52,en=.35,_e=.38,nn=.33,Oe=.86,Y=.08,P=.05,q=-.12,we=5e3,tn=2e3,rn=5e7,Se=4,on=8,ne=4;function xe(n){let e=[];for(let t=0;t<n.length;t++){let i=n[t],o=[i],r=i.match(/^(\s*)(?:[\w-]+:\s+|[-*+]\s+)(\S.*)$/);if(r&&!/^[|>\[{]/.test(r[2]))for(;t+1<n.length;){let s=n[t+1];if(!s.trim()||s.length-s.trimStart().length<=r[1].length||/^\s*(?:[\w-]+:|[-*+]\s|\d+[.)]\s|#)/.test(s))break;o.push(s),t++}e.push(o.join(`
|
|
5
5
|
`))}return e}function K(n,e){if([...n,...e].some(o=>o.includes(`
|
|
6
|
-
`)))return
|
|
6
|
+
`)))return te(n,e);let t=xe(n),i=xe(e);return t.length===n.length&&i.length===e.length?te(n,e):te(t,i).flatMap(o=>{let r=o.left?.split(`
|
|
7
7
|
`)||[],s=o.right?.split(`
|
|
8
|
-
`)||[];if(!
|
|
9
|
-
`))){let
|
|
8
|
+
`)||[];if(!r.length||!s.length)return[...r.map(a=>({left:a})),...s.map(a=>({right:a}))];if(r.length===1&&s.length===1)return[o];let d=ae(o.left,o.right)||fe(o.left,o.right),u=d&&_(d.leftSegments),f=d&&_(d.rightSegments);return Array.from({length:Math.max(r.length,s.length)},(a,v)=>({left:r[v],right:s[v],reflow:{start:v===0,leftSegments:u?.[v],rightSegments:f?.[v]}}))})}function te(n,e){if(n.length===0)return e.map(c=>({right:c}));if(e.length===0)return n.map(c=>({left:c}));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((c,h)=>({left:c,right:e[h]})),...K(n.slice(t),e.slice(t))];let i=1,o=1,r=n[0].trim().replace(/\s+/g," "),s=e[0].trim().replace(/\s+/g," ");for(;r&&s&&r!==s;)if(s.startsWith(r+" ")&&i<n.length)r+=" "+n[i++].trim().replace(/\s+/g," ");else if(r.startsWith(s+" ")&&o<e.length)s+=" "+e[o++].trim().replace(/\s+/g," ");else break;if(r===s&&(i>1||o>1)&&![...n,...e].some(c=>c.includes(`
|
|
9
|
+
`))){let c=ae(n.slice(0,i).join(`
|
|
10
10
|
`),e.slice(0,o).join(`
|
|
11
|
-
`));if(
|
|
11
|
+
`));if(c){let h=_(c.leftSegments),g=_(c.rightSegments);return[...Array.from({length:Math.max(i,o)},(b,S)=>({left:S<i?n[S]:void 0,right:S<o?e[S]:void 0,reflow:{start:S===0,leftSegments:h[S],rightSegments:g[S]}})),...K(n.slice(i),e.slice(o))]}}let l=n.reduce((c,h)=>c+Math.min(h.length,ie),0),d=e.reduce((c,h)=>c+Math.min(h.length,ie),0);if(l*d>rn)return ye(n,e,!0);if(n.length===1&&e.length===1){let c=J(n[0],e[0]);return!n[0].trim()&&!e[0].trim()||(c.eligible||c.score>=en)&&re(n[0],e[0])&&se(n[0],e[0])&&O(M(n[0]))&&O(M(e[0]))?[{left:n[0],right:e[0]}]:[{left:n[0]},{right:e[0]}]}if(n.length*e.length>ke)return ye(n,e);let u=sn(n,e),f=Array.from({length:n.length+1},()=>new Array(e.length+1).fill(Number.NEGATIVE_INFINITY)),a=Array.from({length:n.length+1},()=>new Array(e.length+1).fill(null));f[0][0]=0;for(let c=1;c<=n.length;c++)f[c][0]=f[c-1][0]+q,a[c][0]="left";for(let c=1;c<=e.length;c++)f[0][c]=f[0][c-1]+q,a[0][c]="right";for(let c=1;c<=n.length;c++)for(let h=1;h<=e.length;h++){let g=u[c-1][h-1],S=[{move:"left",score:f[c-1][h]+q},{move:"right",score:f[c][h-1]+q},{move:"match",score:g===null?Number.NEGATIVE_INFINITY:f[c-1][h-1]+g}].reduce((x,y)=>y.score>x.score?y:x);f[c][h]=S.score,a[c][h]=S.move}let v=[],m=n.length,p=e.length;for(;m>0||p>0;){let c=a[m][p];c==="match"?v.push({left:n[--m],right:e[--p]}):c==="left"?v.push({left:n[--m]}):v.push({right:e[--p]})}return v.reverse()}function J(n,e){let t=M(n),i=M(e),o=O(t),r=O(i);if(o&&r&&t===i)return{score:1,eligible:!0,characterSimilarity:1,tokenSimilarity:1,lengthSimilarity:1};if(!o||!r)return{score:0,eligible:!1,characterSimilarity:0,tokenSimilarity:0,lengthSimilarity:0};let s=G(t),l=G(i),d=b=>b.length<=ie?b:[0,Math.floor(b.length/2)-300,b.length-600].map(S=>b.slice(S,S+600)).join(" "),u=vn(d(t),d(i)),f=mn(s,l),a=Math.min(t.length,i.length)/Math.max(t.length,i.length),v=pn(s,l),m=b=>b.match(/^(?:(?:const|let|var)\s+)?([\p{L}_$][\p{L}\p{N}_$.-]*\s*(?::|=(?!=)))\s*/u)?.[1].replace(/\s+/g,""),p=m(t),c=p&&p===m(i)?.12:0,h=Math.min(1,u*.52+f*.32+a*.1+v*.06+c),g=c>0||u>=.52||f>=.45||u>=.48&&f>=.28;return{score:h,eligible:g&&h>=Qe,characterSimilarity:u,tokenSimilarity:f,lengthSimilarity:a}}function sn(n,e){let t=n.map(c=>e.map(h=>J(c,h))),i=He(n,e),o=t.map(c=>oe(c)),r=e.map((c,h)=>oe(t.map(g=>g[h]))),s=t.map((c,h)=>c.map((g,b)=>{if(i.has(`${h}:${b}`))return Math.max(g.score,1);if(!g.eligible)return null;let S=o[h],x=r[b],y=g.score===S.best&&g.score===x.best,I=g.score>=Oe?Y/2:Y,w=S.best-S.second>=I,N=x.best-x.second>=I;return y&&w&&N?g.score:null}));if(Math.max(n.length,e.length)>on||Math.abs(n.length-e.length)>ne)return s;let l=(c,h,g)=>c.score>=_e&&se(n[h],e[g])&&Math.abs(h-g)<=ne,d=t.map((c,h)=>X(c,(g,b)=>l(g,h,b))),u=e.map((c,h)=>X(t.map(g=>g[h]),(g,b)=>l(g,b,h))),f=(c,h,g)=>c.score>=nn&&se(n[h],e[g])&&Math.abs(h-g)<=ne,a=t.map((c,h)=>X(c,(g,b)=>f(g,h,b))),v=e.map((c,h)=>X(t.map(g=>g[h]),(g,b)=>f(g,b,h))),m=(c,h)=>{let g=t[c][h];if(!l(g,c,h))return!1;let b=d[c],S=u[h];return g.score===b.best&&g.score===S.best&&b.best-b.second>=P&&S.best-S.second>=P},p=(c,h)=>{let g=t[c][h];if(!f(g,c,h))return!1;let b=a[c],S=v[h];return g.score===b.best&&g.score===S.best&&b.best-b.second>=P&&S.best-S.second>=P};return s.map((c,h)=>c.map((g,b)=>{if(g!==null)return g;let S=m(h,b)&&(ln(s,h,b)||fn(t,h,b,m)),x=an(t,h,b,(y,I)=>f(t[y][I],y,I),p);return!S&&!x?null:t[h][b].score}))}function ln(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 fn(n,e,t,i){return e>0&&t>0&&i(e-1,t-1)||e+1<n.length&&t+1<n[e+1].length&&i(e+1,t+1)}function an(n,e,t,i,o){let r=e,s=t;for(;r>0&&s>0&&i(r-1,s-1);)r--,s--;let l=e,d=t,u=n[e][t].score,f=1;for(;l+1<n.length&&d+1<n[l+1].length&&i(l+1,d+1);)l++,d++,u+=n[l][d].score,f++;for(let a=e-1,v=t-1;a>=r&&v>=s;a--,v--)u+=n[a][v].score,f++;return f>=3&&u/f>=_e&&o(r,s)&&o(l,d)}function X(n,e){let t=Number.NEGATIVE_INFINITY,i=Number.NEGATIVE_INFINITY;return n.forEach((o,r)=>{e(o,r)&&(o.score>t?(i=t,t=o.score):o.score>i&&(i=o.score))}),{best:t,second:i}}function oe(n){let e=Number.NEGATIVE_INFINITY,t=Number.NEGATIVE_INFINITY;for(let i of n)i.eligible&&(i.score>e?(t=e,e=i.score):i.score>t&&(t=i.score));return{best:e,second:t}}function ye(n,e,t=!1){let i=un(n,e,t);if(i.length===0)return[...n.map(l=>({left:l})),...e.map(l=>({right:l}))];let o=[],r=0,s=0;for(let l of i)De(o,n.slice(r,l.leftIndex),e.slice(s,l.rightIndex)),o.push({left:n[l.leftIndex],right:e[l.rightIndex]}),r=l.leftIndex+1,s=l.rightIndex+1;return De(o,n.slice(r),e.slice(s)),o}function un(n,e,t){let i=cn(n,e,t);if(i===null)return[];let o=He(n,e),r=i.map(({leftIndex:f,rightIndex:a,exact:v})=>({leftIndex:f,rightIndex:a,exact:v,structural:o.has(`${f}:${a}`),match:J(n[f],e[a])})).filter(f=>f.exact||f.structural||f.match.eligible),s=Ee(r,"leftIndex"),l=Ee(r,"rightIndex"),d=r.filter(f=>{if(f.exact||f.structural)return!0;let a=s.get(f.leftIndex),v=l.get(f.rightIndex);if(!a||!v||f.match.score!==a.best||f.match.score!==v.best)return!1;let m=f.match.score>=Oe?Y/2:Y;return a.best-a.second>=m&&v.best-v.second>=m}),u=gn(d,e.length);return u.length<=tn?u:[]}function cn(n,e,t){let i=Ne(n,M),o=Ne(e,M),r=new Map;for(let[d,u]of i){let f=o.get(d);if(!O(d)||u.length!==1||f?.length!==1)continue;let a=u[0],v=f[0];if(r.set(`${a}:${v}`,{leftIndex:a,rightIndex:v,exact:!0}),r.size>we)return null}if(t)return[...r.values()];let s=Ie(n),l=Ie(e);for(let[d,u]of s){let f=l.get(d);if(!(!f||u.length>Se||f.length>Se))for(let a of u)for(let v of f){let m=`${a}:${v}`;if(!r.has(m)&&(r.set(m,{leftIndex:a,rightIndex:v,exact:!1}),r.size>we))return null}}return[...r.values()]}function Ne(n,e){let t=new Map;return n.forEach((i,o)=>{let r=e(i),s=t.get(r)??[];s.push(o),t.set(r,s)}),t}function Ie(n){let e=new Map;return n.forEach((t,i)=>{let o=new Set(G(M(t)).filter(dn));for(let r of o){let s=e.get(r)??[];s.push(i),e.set(r,s)}}),e}function dn(n){return n.length>=2&&/[\p{L}\p{N}_$]/u.test(n)}function Ee(n,e){let t=new Map;for(let i of n){let o=t.get(i[e])??[];o.push(i.match),t.set(i[e],o)}return new Map([...t].map(([i,o])=>[i,oe(o)]))}function gn(n,e){let t=[...n].sort((u,f)=>u.leftIndex-f.leftIndex||u.rightIndex-f.rightIndex),i=new Array(e+2).fill(0),o=new Array(e+2).fill(-1),r=new Array(t.length).fill(0),s=new Array(t.length).fill(-1);for(let u=0;u<t.length;){let f=u+1;for(;f<t.length&&t[f].leftIndex===t[u].leftIndex;)f++;for(let a=u;a<f;a++){let v=Le(i,o,t[a].rightIndex),m=t[a].exact||t[a].structural?.5:0;r[a]=v.score+t[a].match.score+m,s[a]=v.candidateIndex}for(let a=u;a<f;a++)hn(i,o,t[a].rightIndex+1,r[a],a);u=f}let l=Le(i,o,e+1),d=[];for(let u=l.candidateIndex;u>=0;u=s[u])d.push({leftIndex:t[u].leftIndex,rightIndex:t[u].rightIndex});return d.reverse()}function Le(n,e,t){let i=0,o=-1;for(let r=t;r>0;r-=r&-r)n[r]>i&&(i=n[r],o=e[r]);return{score:i,candidateIndex:o}}function hn(n,e,t,i,o){for(let r=t;r<n.length;r+=r&-r)i>n[r]&&(n[r]=i,e[r]=o)}function De(n,e,t){if(e.length*t.length<=ke){n.push(...K(e,t));return}n.push(...e.map(i=>({left:i}))),n.push(...t.map(i=>({right:i})))}function M(n){return n.trim().replace(/\s+/g," ")}function He(n,e){let t=Me(n),i=Me(e),o=new Set;for(let[r,s]of t){let l=i.get(r);s.length===1&&l?.length===1&&o.add(`${s[0]}:${l[0]}`)}return o}function Me(n){let e=new Map;return n.forEach((t,i)=>{let o=B(t);if(!o)return;let r=e.get(o)??[];r.push(i),e.set(o,r)}),e}function se(n,e){let t=B(n),i=B(e);return!t||!i?t===i:t.split(":",1)[0]===i.split(":",1)[0]}function B(n){let e=M(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[i,o]of t){let r=e.match(o);if(r)return`${i}:${r[1]}`}return null}function O(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 mn(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 i=0;for(let o of e){let r=t.get(o)??0;r>0&&(i++,t.set(o,r-1))}return 2*i/(n.length+e.length)}function pn(n,e){if(n.length===0||e.length===0)return 0;let t=n[0]===e[0]?.5:0,i=n[n.length-1]===e[e.length-1]?.5:0;return t+i}function vn(n,e){let t=n.length+e.length;return t===0?1:2*de(n,e).filter(o=>!o.added&&!o.removed).reduce((o,r)=>o+r.value.length,0)/t}function bn(n,e){let t=ae(n.content,e.content);if(t){n.segments=t.leftSegments,e.segments=t.rightSegments;return}let i=fe(n.content,e.content);i&&(n.segments=i.leftSegments,e.segments=i.rightSegments)}function wn(n,e){if(!n.length||!e.length||n.length===1&&e.length===1)return;let t=f=>f.reduce((a,v)=>a+v.content.length+1,-1);if(t(n)>j||t(e)>j)return;let i=n.map(f=>f.content).join(`
|
|
12
12
|
`),o=e.map(f=>f.content).join(`
|
|
13
|
-
`),
|
|
14
|
-
|
|
13
|
+
`),r=fe(i,o);if(!r)return;let{leftSegments:s,rightSegments:l}=r,d=_(s),u=_(l);n.forEach((f,a)=>{f.segments=d[a]}),e.forEach((f,a)=>{f.segments=u[a]})}function Ae(n){/[^\s]/.test(n.content)&&(n.segments=[{kind:n.kind,text:n.content,emphasis:!0}])}var le=new Intl.Segmenter(void 0,{granularity:"grapheme"});function Sn(n,e){if(n===e)return n?[{value:n}]:[];let t=Array.from(le.segment(n),l=>l.segment),i=Array.from(le.segment(e),l=>l.segment),o=Math.min(t.length,i.length),r=0,s=0;for(;r<o&&t[r]===i[r];)r++;for(;s<o&&t[t.length-s-1]===i[i.length-s-1];)s++;return s===o&&r<o&&(r=0),s=Math.min(s,o-r),[{value:t.slice(0,r).join("")},{value:t.slice(r,t.length-s).join(""),removed:!0},{value:i.slice(r,i.length-s).join(""),added:!0},{value:s?t.slice(-s).join(""):""}].filter(l=>l.value.length>0)}function xn(n,e){let t=ge(n,e,{timeout:Re,maxEditLength:2e3});if(!t)return;let i=a=>new Set([...Array.from(le.segment(a),v=>v.index),a.length]),o=i(n),r=i(e),s=[],l=0,d=0,u="",f="";for(let a=0;a<t.length;){let v=t[a];if(!v.added&&!v.removed)u+=v.value,f+=v.value,l+=v.value.length,d+=v.value.length,a++;else for(;a<t.length&&(t[a].added||t[a].removed);){let m=t[a++];m.removed?(u+=m.value,l+=m.value.length):(f+=m.value,d+=m.value.length)}if(o.has(l)&&r.has(d)){for(let m of Sn(u,f)){let p=s[s.length-1];p&&p.added===m.added&&p.removed===m.removed?p.value+=m.value:s.push(m)}u="",f=""}}return s}function fe(n,e){if(n.length>j||e.length>j)return;let t=xn(n,e);if(!t)return;let i=[],o=[],r=!1;for(let s of t){let l=s.value;if(!s.added&&!s.removed){let u={kind:"context",text:l,emphasis:!1};i.push(u),o.push(u);continue}let d=l.length>0;r=r||d,s.removed&&i.push({kind:"removed",text:l,emphasis:d}),s.added&&o.push({kind:"added",text:l,emphasis:d})}return{leftSegments:V(i),rightSegments:V(o),hasInlineChanges:r}}function ae(n,e){let t=n.split(/(\S+)/),i=e.split(/(\S+)/);if(t.length!==i.length||t.some((l,d)=>d%2===1&&l!==i[d]))return;let o=[],r=[],s=(l,d,u)=>{if(!u)return;let f=l[l.length-1];f?.kind===d?f.text+=u:l.push({kind:d,text:u,emphasis:d!=="context"})};return t.forEach((l,d)=>{let u=i[d],f=0;if(d>0)for(;f<Math.min(l.length,u.length)&&l[f]===u[f];)f++;let a=0;for(;a<Math.min(l.length,u.length)-f&&l[l.length-a-1]===u[u.length-a-1];)a++;if(d===0)for(;f<Math.min(l.length,u.length)-a&&l[f]===u[f];)f++;s(o,"context",l.slice(0,f)),s(r,"context",u.slice(0,f)),s(o,"removed",l.slice(f,l.length-a)),s(r,"added",u.slice(f,u.length-a)),s(o,"context",l.slice(l.length-a)),s(r,"context",u.slice(u.length-a))}),{leftSegments:V(o),rightSegments:V(r)}}function V(n){let e=[];return _(n).forEach((t,i)=>{i>0&&e.push({kind:"context",text:`
|
|
14
|
+
`,emphasis:!1});let o=t.map(u=>u.text).join(""),r=o.match(/^[\t ]*/u)[0].length,s=0,l=0,d="context";for(let u of t){if(s>=r)break;u.emphasis&&(l+=Math.min(u.text.length,r-s),d=u.kind),s+=u.text.length}l&&e.push({kind:d,text:o.slice(0,l),emphasis:!0}),r>l&&e.push({kind:"context",text:o.slice(l,r),emphasis:!1}),s=0;for(let u of t){let f=Math.max(0,r-s);f<u.text.length&&e.push({...u,text:u.text.slice(f)}),s+=u.text.length}}),e}function _(n){let e=[[]];for(let t of n)t.text.split(`
|
|
15
|
+
`).forEach((i,o)=>{o>0&&e.push([]),i&&e[e.length-1].push({...t,text:i})});return e}function H(){return{kind:"placeholder",content:"",lineNumber:null}}function A(n,e,t){return{kind:n,content:e,lineNumber:t}}function R(n,e,t){return{kind:n,content:e,lineNumber:t}}function k(n,e){return{left:n,right:e}}function $(n,e,t,i,o){return{kind:n,leftStart:e,leftEnd:t,rightStart:i,rightEnd:o}}function Fe(n,e){let t=typeof process<"u"?process.env?.[n]:void 0,i=Number.parseInt(t??"",10);return Number.isFinite(i)&&i>0?i:e}self.addEventListener("message",n=>{let{id:e,leftContent:t,rightContent:i}=n.data||{};if(!(typeof e!="number"||typeof t!="string"||typeof i!="string"))try{let o=Te(t,i);self.postMessage({id:e,model:o})}catch(o){self.postMessage({id:e,error:o&&o.message||String(o)})}});})();
|
|
15
16
|
//# sourceMappingURL=diff.worker.js.map
|