@lethevimlet/sshift 1.1.8 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -1
- package/src/server/endpoints/rest/utils.js +1 -1
- package/src/server/services/ssh-manager.js +50 -18
- package/src/server/utils/key-converter.js +203 -96
- package/src/webapp/index.html +1 -0
- package/src/webapp/js/app.js +44 -3
- package/src/webapp/libs/xterm/xterm-addon-unicode11.js +2 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lethevimlet/sshift",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Web-based SSH + SFTP terminal client with tabs and bookmarks",
|
|
5
5
|
"main": "src/server/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
"@xterm/addon-image": "0.9.0",
|
|
25
25
|
"@xterm/addon-search": "0.16.0",
|
|
26
26
|
"@xterm/addon-serialize": "0.14.0",
|
|
27
|
+
"@xterm/addon-unicode11": "0.9.0",
|
|
27
28
|
"@xterm/addon-web-links": "0.12.0",
|
|
28
29
|
"@xterm/addon-webgl": "0.19.0",
|
|
29
30
|
"@xterm/headless": "6.0.0",
|
|
@@ -22,7 +22,7 @@ function registerUtilsEndpoints(app, io) {
|
|
|
22
22
|
const info = detectKeyFormat(content);
|
|
23
23
|
if (info.format === 'ppk') {
|
|
24
24
|
try {
|
|
25
|
-
const converted = await convertPPKToOpenSSH(content, passphrase);
|
|
25
|
+
const converted = await convertPPKToOpenSSH(content, passphrase || undefined);
|
|
26
26
|
res.json({ success: true, key: converted, format: 'openssh' });
|
|
27
27
|
} catch (e) {
|
|
28
28
|
res.status(400).json({ error: e.message });
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const { Client } = require('ssh2');
|
|
2
2
|
const { Terminal } = require('@xterm/headless');
|
|
3
3
|
const { SerializeAddon } = require('@xterm/addon-serialize');
|
|
4
|
+
const { Unicode11Addon } = require('@xterm/addon-unicode11');
|
|
4
5
|
const pluginManager = require('../plugins/plugin-manager');
|
|
5
6
|
const { convertKeyIfNeeded } = require('../utils/key-converter');
|
|
6
7
|
|
|
@@ -56,6 +57,15 @@ class SSHManager {
|
|
|
56
57
|
logLevel: 'off'
|
|
57
58
|
});
|
|
58
59
|
|
|
60
|
+
// Use Unicode 11 width rules so the headless terminal's character-width
|
|
61
|
+
// calculations match the remote PTY. Without this, wide/ambiguous-width
|
|
62
|
+
// characters (CJK, emojis, box-drawing) would be sized differently,
|
|
63
|
+
// causing the serialized screen state to be misaligned when sent to
|
|
64
|
+
// clients that also use Unicode 11.
|
|
65
|
+
const unicode11Addon = new Unicode11Addon();
|
|
66
|
+
terminal.loadAddon(unicode11Addon);
|
|
67
|
+
terminal.unicode.activeVersion = '11';
|
|
68
|
+
|
|
59
69
|
// Create serialize addon for terminal state
|
|
60
70
|
const serializeAddon = new SerializeAddon();
|
|
61
71
|
terminal.loadAddon(serializeAddon);
|
|
@@ -77,10 +87,17 @@ class SSHManager {
|
|
|
77
87
|
username: options.username,
|
|
78
88
|
connectedAt: Date.now(),
|
|
79
89
|
// Data batching state
|
|
80
|
-
dataChunks: [], // Array of
|
|
81
|
-
dataBufferSize: 0, // Running total of chunk lengths for
|
|
90
|
+
dataChunks: [], // Array of raw Buffers for outgoing data
|
|
91
|
+
dataBufferSize: 0, // Running total of chunk byte lengths for size checks
|
|
82
92
|
batchTimer: null, // Timer for batched sends
|
|
83
93
|
lastDataTime: 0, // Timestamp of last data received
|
|
94
|
+
// Streaming UTF-8 decoder that carries incomplete bytes across
|
|
95
|
+
// flushes. If a multi-byte character is split between two SSH
|
|
96
|
+
// data events and the first half is flushed before the second
|
|
97
|
+
// arrives, toString('utf8') would replace the partial byte with
|
|
98
|
+
// \uFFFD. The streaming decoder instead carries the partial byte
|
|
99
|
+
// forward until the character is complete.
|
|
100
|
+
decoder: new TextDecoder('utf-8'),
|
|
84
101
|
writeQueue: null, // Queue for writes when stream is congested
|
|
85
102
|
drainListener: false // Whether a drain listener is active
|
|
86
103
|
};
|
|
@@ -156,20 +173,17 @@ class SSHManager {
|
|
|
156
173
|
});
|
|
157
174
|
|
|
158
175
|
// Handle stream data with batching to reduce socket events
|
|
159
|
-
// This prevents performance issues when multiple clients are connected
|
|
176
|
+
// This prevents performance issues when multiple clients are connected.
|
|
177
|
+
// Buffer raw bytes rather than converting to strings immediately —
|
|
178
|
+
// this avoids corrupting multi-byte UTF-8 characters that span
|
|
179
|
+
// chunk boundaries (each .toString('utf8') would replace the
|
|
180
|
+
// incomplete halves with U+FFFD).
|
|
160
181
|
stream.on('data', (data) => {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
// Buffer data for batched broadcast (headless terminal write
|
|
164
|
-
// is also batched inside bufferData to avoid per-chunk writes)
|
|
165
|
-
this.bufferData(sessionId, dataStr);
|
|
182
|
+
this.bufferData(sessionId, data);
|
|
166
183
|
});
|
|
167
184
|
|
|
168
185
|
stream.stderr.on('data', (data) => {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
// Buffer data for batched broadcast
|
|
172
|
-
this.bufferData(sessionId, dataStr);
|
|
186
|
+
this.bufferData(sessionId, data);
|
|
173
187
|
});
|
|
174
188
|
|
|
175
189
|
stream.on('close', () => {
|
|
@@ -232,13 +246,16 @@ class SSHManager {
|
|
|
232
246
|
|
|
233
247
|
// Buffer data for batched broadcast to reduce socket events
|
|
234
248
|
// This improves performance when multiple clients are connected
|
|
235
|
-
bufferData(sessionId,
|
|
249
|
+
bufferData(sessionId, data) {
|
|
236
250
|
const session = this.sessions.get(sessionId);
|
|
237
251
|
if (!session) return;
|
|
238
252
|
|
|
253
|
+
// Track byte length for size-based flush threshold
|
|
254
|
+
const byteLen = Buffer.isBuffer(data) ? data.length : data.length;
|
|
255
|
+
|
|
239
256
|
// Add data to chunk array (avoids O(n^2) string concatenation)
|
|
240
|
-
session.dataChunks.push(
|
|
241
|
-
session.dataBufferSize +=
|
|
257
|
+
session.dataChunks.push(data);
|
|
258
|
+
session.dataBufferSize += byteLen;
|
|
242
259
|
session.lastDataTime = Date.now();
|
|
243
260
|
|
|
244
261
|
// If buffer exceeds max size, flush immediately
|
|
@@ -268,7 +285,18 @@ class SSHManager {
|
|
|
268
285
|
|
|
269
286
|
// If there's data to send, broadcast it
|
|
270
287
|
if (session.dataChunks.length > 0) {
|
|
271
|
-
|
|
288
|
+
// Concatenate raw Buffers first, then decode with the streaming
|
|
289
|
+
// TextDecoder. Using { stream: true } carries any incomplete
|
|
290
|
+
// trailing UTF-8 bytes forward to the next flush instead of
|
|
291
|
+
// replacing them with U+FFFD. This is critical for TUI apps
|
|
292
|
+
// whose escape sequences and wide characters span multiple SSH
|
|
293
|
+
// data events that may be flushed separately.
|
|
294
|
+
const combined = Buffer.concat(
|
|
295
|
+
session.dataChunks.map(c => Buffer.isBuffer(c) ? c : Buffer.from(c, 'utf8'))
|
|
296
|
+
);
|
|
297
|
+
const joinedData = session.decoder.decode(combined, { stream: true });
|
|
298
|
+
session.dataChunks = [];
|
|
299
|
+
session.dataBufferSize = 0;
|
|
272
300
|
|
|
273
301
|
// Write to headless terminal for state sync (batched write)
|
|
274
302
|
if (session.terminal) {
|
|
@@ -282,8 +310,6 @@ class SSHManager {
|
|
|
282
310
|
sessionId,
|
|
283
311
|
data: joinedData
|
|
284
312
|
});
|
|
285
|
-
session.dataChunks = [];
|
|
286
|
-
session.dataBufferSize = 0;
|
|
287
313
|
}
|
|
288
314
|
}
|
|
289
315
|
|
|
@@ -580,6 +606,12 @@ class SSHManager {
|
|
|
580
606
|
clearTimeout(session.batchTimer);
|
|
581
607
|
session.batchTimer = null;
|
|
582
608
|
}
|
|
609
|
+
// Flush any remaining incomplete UTF-8 bytes from the streaming
|
|
610
|
+
// decoder. Passing { stream: false } (or no option) signals the
|
|
611
|
+
// decoder that the stream has ended, emitting any buffered bytes
|
|
612
|
+
// as replacement characters — there should be none in a clean
|
|
613
|
+
// disconnect, but this prevents a memory leak.
|
|
614
|
+
try { session.decoder.decode(new Uint8Array(0)); } catch (_) {}
|
|
583
615
|
if (session.stream) {
|
|
584
616
|
session.stream.end();
|
|
585
617
|
}
|
|
@@ -57,77 +57,70 @@ function convertPPKViaPuttygen(ppkContent, passphrase) {
|
|
|
57
57
|
const inputFile = path.join(tmpDir, `sshift-ppk-${Date.now()}-${Math.random().toString(36).slice(2)}.ppk`);
|
|
58
58
|
const outputFile = inputFile + '.openssh';
|
|
59
59
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
60
|
+
const doConvert = (passphraseFile) => {
|
|
61
|
+
const args = [inputFile, '-O', 'private-openssh-new', '-o', outputFile];
|
|
62
|
+
if (passphraseFile) {
|
|
63
|
+
args.push('--old-passphrase', passphraseFile);
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
const args = passphrase
|
|
67
|
-
? [inputFile, '--old-passphrase=' + passphrase, '-O', 'private-openssh-new', '-o', outputFile]
|
|
68
|
-
: [inputFile, '-O', 'private-openssh-new', '-o', outputFile];
|
|
69
|
-
|
|
70
66
|
execFile('puttygen', args, (err, stdout, stderr) => {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
67
|
+
const filesToClean = passphraseFile
|
|
68
|
+
? [inputFile, outputFile, passphraseFile]
|
|
69
|
+
: [inputFile, outputFile];
|
|
70
|
+
|
|
71
|
+
if (err) {
|
|
72
|
+
for (const f of filesToClean) { try { fs.unlinkSync(f); } catch (e) { /* ignore */ } }
|
|
73
|
+
const stderrStr = (stderr || '').trim();
|
|
74
|
+
const errMsg = stderrStr || err.message;
|
|
75
|
+
|
|
76
|
+
if (stderrStr.toLowerCase().includes('wrong passphrase') || stderrStr.toLowerCase().includes('unable to read')) {
|
|
77
|
+
return reject(new Error(
|
|
78
|
+
'PPK passphrase is incorrect. Please check the passphrase and try again.'
|
|
79
|
+
));
|
|
76
80
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
cleanupAndResolve(err2, stdout2, stderr2, inputFile, outputFile, reject, resolve);
|
|
80
|
-
});
|
|
81
|
-
return;
|
|
81
|
+
|
|
82
|
+
return reject(new Error('puttygen conversion failed: ' + errMsg));
|
|
82
83
|
}
|
|
83
84
|
|
|
84
|
-
|
|
85
|
+
fs.readFile(outputFile, 'utf8', (readErr, data) => {
|
|
86
|
+
if (passphraseFile) {
|
|
87
|
+
try { fs.unlinkSync(passphraseFile); } catch (e) { /* ignore */ }
|
|
88
|
+
}
|
|
89
|
+
try { fs.unlinkSync(inputFile); } catch (e) { /* ignore */ }
|
|
90
|
+
try { fs.unlinkSync(outputFile); } catch (e) { /* ignore */ }
|
|
91
|
+
if (readErr) {
|
|
92
|
+
return reject(new Error('Failed to read converted key: ' + readErr.message));
|
|
93
|
+
}
|
|
94
|
+
resolve(data);
|
|
95
|
+
});
|
|
85
96
|
});
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
function cleanupAndResolve(err, stdout, stderr, inputFile, outputFile, reject, resolve) {
|
|
91
|
-
try { fs.unlinkSync(inputFile); } catch (e) { /* ignore */ }
|
|
97
|
+
};
|
|
92
98
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
if (stderrStr.includes('no such option') && stderrStr.includes('--old-passphrase')) {
|
|
99
|
-
return reject(new Error(
|
|
100
|
-
'puttygen on this system does not support the --old-passphrase option. ' +
|
|
101
|
-
'Please upgrade puttygen (PuTTY 0.71+) or decrypt the PPK key manually: ' +
|
|
102
|
-
'run "puttygen key.ppk -O private-openssh-new -o key.pem" with the passphrase entered interactively.'
|
|
103
|
-
));
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
if (stderrStr.toLowerCase().includes('wrong passphrase') || stderrStr.toLowerCase().includes('unable to read')) {
|
|
107
|
-
return reject(new Error(
|
|
108
|
-
'PPK passphrase is incorrect. Please check the passphrase and try again. ' +
|
|
109
|
-
'(puttygen error: ' + stderrStr + ')'
|
|
110
|
-
));
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
return reject(new Error('puttygen conversion failed: ' + errMsg));
|
|
114
|
-
}
|
|
99
|
+
fs.writeFile(inputFile, ppkContent, (writeErr) => {
|
|
100
|
+
if (writeErr) {
|
|
101
|
+
try { fs.unlinkSync(inputFile); } catch (e) { /* ignore */ }
|
|
102
|
+
return reject(new Error('Failed to write temporary PPK file: ' + writeErr.message));
|
|
103
|
+
}
|
|
115
104
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
105
|
+
const passphraseFile = path.join(tmpDir, `sshift-ppk-pass-${Date.now()}-${Math.random().toString(36).slice(2)}.txt`);
|
|
106
|
+
fs.writeFile(passphraseFile, passphrase || '', { mode: 0o600 }, (passWriteErr) => {
|
|
107
|
+
if (passWriteErr) {
|
|
108
|
+
try { fs.unlinkSync(inputFile); } catch (e) { /* ignore */ }
|
|
109
|
+
return reject(new Error('Failed to write passphrase file: ' + passWriteErr.message));
|
|
110
|
+
}
|
|
111
|
+
doConvert(passphraseFile);
|
|
112
|
+
});
|
|
113
|
+
});
|
|
122
114
|
});
|
|
123
115
|
}
|
|
124
116
|
|
|
125
|
-
function convertPPKV2ToOpenSSH(ppkContent) {
|
|
117
|
+
function convertPPKV2ToOpenSSH(ppkContent, passphrase) {
|
|
126
118
|
const lines = ppkContent.split('\n');
|
|
127
119
|
|
|
128
120
|
const headers = {};
|
|
129
121
|
const publicLines = [];
|
|
130
122
|
const privateLines = [];
|
|
123
|
+
let macLine = null;
|
|
131
124
|
let section = 'header';
|
|
132
125
|
|
|
133
126
|
for (const rawLine of lines) {
|
|
@@ -144,56 +137,94 @@ function convertPPKV2ToOpenSSH(ppkContent) {
|
|
|
144
137
|
continue;
|
|
145
138
|
}
|
|
146
139
|
if (line.startsWith('Private-MAC:')) {
|
|
147
|
-
|
|
140
|
+
macLine = line.substring('Private-MAC:'.length).trim();
|
|
148
141
|
continue;
|
|
149
142
|
}
|
|
150
143
|
|
|
144
|
+
const colonIdx = line.indexOf(':');
|
|
145
|
+
if (colonIdx !== -1) {
|
|
146
|
+
const key = line.substring(0, colonIdx).trim();
|
|
147
|
+
const value = line.substring(colonIdx + 1).trim();
|
|
148
|
+
if (key.match(/^PuTTY-User-Key-File-/i) ||
|
|
149
|
+
key === 'Encryption' || key === 'Comment' || key === 'Key-Derivation' ||
|
|
150
|
+
key === 'Argon2-Memory' || key === 'Argon2-Passes' ||
|
|
151
|
+
key === 'Argon2-Parallelism' || key === 'Argon2-Salt') {
|
|
152
|
+
headers[key] = value;
|
|
153
|
+
continue;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
151
157
|
if (section === 'public') {
|
|
152
158
|
publicLines.push(line);
|
|
153
159
|
} else if (section === 'private') {
|
|
154
160
|
privateLines.push(line);
|
|
155
|
-
} else if (section === 'header') {
|
|
156
|
-
const colonIdx = line.indexOf(':');
|
|
157
|
-
if (colonIdx !== -1) {
|
|
158
|
-
headers[line.substring(0, colonIdx).trim()] = line.substring(colonIdx + 1).trim();
|
|
159
|
-
}
|
|
160
161
|
}
|
|
161
162
|
}
|
|
162
163
|
|
|
163
164
|
const encType = headers['Encryption'] || 'none';
|
|
164
|
-
if (encType !== 'none') {
|
|
165
|
-
throw new Error(
|
|
166
|
-
`PPK key is encrypted with "${encType}". Please decrypt it first using PuTTYgen: ` +
|
|
167
|
-
`load the PPK, enter the passphrase, then export as OpenSSH key.`
|
|
168
|
-
);
|
|
169
|
-
}
|
|
170
|
-
|
|
171
165
|
const ppkVersion = Object.keys(headers).find(k => k.match(/^PuTTY-User-Key-File-/i));
|
|
172
166
|
const keyType = ppkVersion ? headers[ppkVersion] : null;
|
|
173
167
|
if (!keyType) {
|
|
174
168
|
throw new Error('Could not determine PPK key type. Is this a valid PPK file?');
|
|
175
169
|
}
|
|
176
170
|
|
|
177
|
-
if (ppkVersion && ppkVersion.match(/^PuTTY-User-Key-File-
|
|
171
|
+
if (ppkVersion && !ppkVersion.match(/^PuTTY-User-Key-File-2$/i)) {
|
|
172
|
+
throw new Error(
|
|
173
|
+
`PPK ${ppkVersion.replace('PuTTY-User-Key-File-', 'v')} format is not supported by the built-in converter. ` +
|
|
174
|
+
`Only PPK v2 is supported. Install puttygen (PuTTY 0.71+) to convert this key.`
|
|
175
|
+
);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
const keyDerivation = headers['Key-Derivation'] || '';
|
|
179
|
+
if (keyDerivation && keyDerivation.toLowerCase() !== 'sha1') {
|
|
178
180
|
throw new Error(
|
|
179
|
-
|
|
180
|
-
|
|
181
|
+
`PPK v2 key derivation "${keyDerivation}" is not supported by the built-in converter. ` +
|
|
182
|
+
`Only SHA-1 key derivation is supported. Install puttygen to convert this key.`
|
|
181
183
|
);
|
|
182
184
|
}
|
|
183
185
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
+
let privateData = Buffer.from(privateLines.join(''), 'base64');
|
|
187
|
+
|
|
188
|
+
if (encType === 'aes256-cbc') {
|
|
189
|
+
if (!passphrase) {
|
|
190
|
+
throw new Error(
|
|
191
|
+
'This PPK key is encrypted. Please enter the passphrase for this key.'
|
|
192
|
+
);
|
|
193
|
+
}
|
|
194
|
+
try {
|
|
195
|
+
privateData = decryptPPKV2Private(privateData, passphrase, encType);
|
|
196
|
+
} catch (e) {
|
|
197
|
+
throw new Error(
|
|
198
|
+
'Failed to decrypt PPK key. The passphrase may be incorrect. ' +
|
|
199
|
+
'Please verify the passphrase and try again.'
|
|
200
|
+
);
|
|
201
|
+
}
|
|
202
|
+
} else if (encType !== 'none') {
|
|
203
|
+
throw new Error(
|
|
204
|
+
`PPK v2 encryption "${encType}" is not supported by the built-in converter. ` +
|
|
205
|
+
`Supported: none, aes256-cbc. Try installing puttygen for broader format support.`
|
|
206
|
+
);
|
|
207
|
+
}
|
|
186
208
|
|
|
187
209
|
if (privateData.length < 8) {
|
|
188
|
-
throw new Error('PPK private data is too short. The key file may be corrupt.');
|
|
210
|
+
throw new Error('PPK private data is too short. The key file may be corrupt or the passphrase may be wrong.');
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
if (encType !== 'none' && macLine) {
|
|
214
|
+
const publicData = Buffer.from(publicLines.join(''), 'base64');
|
|
215
|
+
if (!verifyPPKV2MAC(headers, publicData, privateData, passphrase, macLine)) {
|
|
216
|
+
throw new Error(
|
|
217
|
+
'The passphrase is incorrect or the key is corrupted. ' +
|
|
218
|
+
'Please verify the passphrase and try again.'
|
|
219
|
+
);
|
|
220
|
+
}
|
|
189
221
|
}
|
|
190
222
|
|
|
191
223
|
const check1 = privateData.readUInt32BE(0);
|
|
192
224
|
const check2 = privateData.readUInt32BE(4);
|
|
193
225
|
if (check1 !== check2) {
|
|
194
226
|
throw new Error(
|
|
195
|
-
'PPK integrity check failed. The key may be
|
|
196
|
-
'If it has a passphrase, convert using PuTTYgen first.'
|
|
227
|
+
'PPK integrity check failed. The key may be corrupted or the passphrase may be wrong.'
|
|
197
228
|
);
|
|
198
229
|
}
|
|
199
230
|
|
|
@@ -250,6 +281,91 @@ function convertPPKV2ToOpenSSH(ppkContent) {
|
|
|
250
281
|
return encodeOpenSSHPrivateKey(keyParts);
|
|
251
282
|
}
|
|
252
283
|
|
|
284
|
+
function decryptPPKV2Private(encData, passphrase, encType) {
|
|
285
|
+
if (encType === 'aes256-cbc') {
|
|
286
|
+
const keyIv = derivePPKV2Key(passphrase, 48);
|
|
287
|
+
const aesKey = keyIv.slice(0, 32);
|
|
288
|
+
const iv = keyIv.slice(32, 48);
|
|
289
|
+
|
|
290
|
+
const decipher = crypto.createDecipheriv('aes-256-cbc', aesKey, iv);
|
|
291
|
+
decipher.setAutoPadding(false);
|
|
292
|
+
let decrypted = decipher.update(encData);
|
|
293
|
+
decrypted = Buffer.concat([decrypted, decipher.final()]);
|
|
294
|
+
|
|
295
|
+
const padLen = decrypted[decrypted.length - 1];
|
|
296
|
+
if (padLen > 0 && padLen <= 16) {
|
|
297
|
+
let valid = true;
|
|
298
|
+
for (let i = 1; i <= padLen; i++) {
|
|
299
|
+
if (decrypted[decrypted.length - i] !== padLen) {
|
|
300
|
+
valid = false;
|
|
301
|
+
break;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
if (valid) {
|
|
305
|
+
decrypted = decrypted.slice(0, decrypted.length - padLen);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
return decrypted;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
throw new Error(`Unsupported PPK v2 encryption type: ${encType}`);
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
function derivePPKV2Key(passphrase, keyLen) {
|
|
316
|
+
const passBuf = Buffer.from(passphrase, 'utf-8');
|
|
317
|
+
const derived = Buffer.alloc(keyLen);
|
|
318
|
+
|
|
319
|
+
for (let i = 0; i < keyLen; i++) {
|
|
320
|
+
const hash = crypto.createHash('sha1');
|
|
321
|
+
hash.update(passBuf);
|
|
322
|
+
if (i > 0) {
|
|
323
|
+
hash.update(derived.slice(0, i));
|
|
324
|
+
}
|
|
325
|
+
derived[i] = hash.digest()[0];
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
return derived;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
function verifyPPKV2MAC(headers, publicData, privateData, passphrase, macLine) {
|
|
332
|
+
const macKeyBase = crypto.createHash('sha1');
|
|
333
|
+
macKeyBase.update(Buffer.from('putty-private-key-file-mac-key', 'ascii'));
|
|
334
|
+
if (passphrase) {
|
|
335
|
+
macKeyBase.update(Buffer.from(passphrase, 'utf-8'));
|
|
336
|
+
}
|
|
337
|
+
const macKey = macKeyBase.digest();
|
|
338
|
+
|
|
339
|
+
const keyType = Object.keys(headers).find(k => k.match(/^PuTTY-User-Key-File-/i));
|
|
340
|
+
const keyTypeValue = keyType ? headers[keyType] : '';
|
|
341
|
+
const encType = headers['Encryption'] || 'none';
|
|
342
|
+
const comment = headers['Comment'] || '';
|
|
343
|
+
|
|
344
|
+
const macData = Buffer.concat([
|
|
345
|
+
sshString(keyTypeValue),
|
|
346
|
+
sshString(encType),
|
|
347
|
+
sshString(comment),
|
|
348
|
+
sshBuffer(publicData),
|
|
349
|
+
sshBuffer(privateData)
|
|
350
|
+
]);
|
|
351
|
+
|
|
352
|
+
const computed = crypto.createHmac('sha1', macKey).update(macData).digest('hex');
|
|
353
|
+
return computed === macLine.toLowerCase();
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
function sshString(str) {
|
|
357
|
+
const buf = Buffer.from(str, 'utf-8');
|
|
358
|
+
const len = Buffer.alloc(4);
|
|
359
|
+
len.writeUInt32BE(buf.length);
|
|
360
|
+
return Buffer.concat([len, buf]);
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
function sshBuffer(data) {
|
|
364
|
+
const len = Buffer.alloc(4);
|
|
365
|
+
len.writeUInt32BE(data.length);
|
|
366
|
+
return Buffer.concat([len, data]);
|
|
367
|
+
}
|
|
368
|
+
|
|
253
369
|
class SSHBufferReader {
|
|
254
370
|
constructor(buffer) {
|
|
255
371
|
this.buffer = buffer;
|
|
@@ -367,39 +483,30 @@ async function convertPPKToOpenSSH(ppkContent, passphrase) {
|
|
|
367
483
|
throw new Error('Not a PPK key');
|
|
368
484
|
}
|
|
369
485
|
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
);
|
|
486
|
+
// Try built-in converter first (works for v2 encrypted/unencrypted, no puttygen dependency)
|
|
487
|
+
try {
|
|
488
|
+
const result = convertPPKV2ToOpenSSH(ppkContent, passphrase);
|
|
489
|
+
if (result) return result;
|
|
490
|
+
} catch (e) {
|
|
491
|
+
if (!e.message.includes('not supported by the built-in converter')) {
|
|
492
|
+
throw e;
|
|
493
|
+
}
|
|
374
494
|
}
|
|
375
495
|
|
|
376
|
-
//
|
|
496
|
+
// Fall back to puttygen (handles v3 and encryption types the built-in converter doesn't support)
|
|
377
497
|
try {
|
|
378
498
|
const result = await convertPPKViaPuttygen(ppkContent, passphrase);
|
|
379
499
|
if (result && result.includes('BEGIN')) {
|
|
380
500
|
return result;
|
|
381
501
|
}
|
|
382
|
-
} catch (e) {
|
|
383
|
-
// If puttygen failed and key is encrypted, don't try built-in (it can't handle encryption)
|
|
384
|
-
if (info.encrypted) {
|
|
385
|
-
throw new Error(
|
|
386
|
-
'Could not convert encrypted PPK key: ' + e.message +
|
|
387
|
-
'. Ensure puttygen is installed and the passphrase is correct.'
|
|
388
|
-
);
|
|
389
|
-
}
|
|
390
|
-
// puttygen not available, try built-in v2 parser for unencrypted keys
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
// Fall back to built-in PPK v2 converter (unencrypted only)
|
|
394
|
-
try {
|
|
395
|
-
return convertPPKV2ToOpenSSH(ppkContent);
|
|
396
502
|
} catch (e) {
|
|
397
503
|
throw new Error(
|
|
398
504
|
'Could not convert PPK key: ' + e.message +
|
|
399
|
-
'.
|
|
400
|
-
'load the PPK file, then export as OpenSSH key (Conversions > Export OpenSSH key).'
|
|
505
|
+
'. If puttygen is not available, ensure the key uses PPK v2 format with AES-256-CBC encryption (or no encryption).'
|
|
401
506
|
);
|
|
402
507
|
}
|
|
508
|
+
|
|
509
|
+
throw new Error('Failed to convert PPK key: no conversion method available.');
|
|
403
510
|
}
|
|
404
511
|
|
|
405
512
|
async function convertKeyIfNeeded(keyContent, passphrase) {
|
package/src/webapp/index.html
CHANGED
|
@@ -1145,6 +1145,7 @@
|
|
|
1145
1145
|
<script src="/libs/xterm/xterm-addon-serialize.js?v=__VERSION__"></script>
|
|
1146
1146
|
<script src="/libs/xterm/xterm-addon-webgl.js?v=__VERSION__"></script>
|
|
1147
1147
|
<script src="/libs/xterm/xterm-addon-image.js?v=__VERSION__"></script>
|
|
1148
|
+
<script src="/libs/xterm/xterm-addon-unicode11.js?v=__VERSION__"></script>
|
|
1148
1149
|
|
|
1149
1150
|
<!-- Mobile terminal support -->
|
|
1150
1151
|
<script src="/js/mobile-terminal.js?v=__VERSION__"></script>
|
package/src/webapp/js/app.js
CHANGED
|
@@ -5858,7 +5858,7 @@ const wheelHandler = (e) => {
|
|
|
5858
5858
|
|
|
5859
5859
|
const detectResult = await this.detectAndConvertKey(content, passphrase);
|
|
5860
5860
|
if (detectResult.error) {
|
|
5861
|
-
if (this._isPassphraseError(detectResult.error)) {
|
|
5861
|
+
if (this._isPassphraseError(detectResult.error) && !passphrase) {
|
|
5862
5862
|
const promptedPassphrase = await this._promptForKeyPassphrase();
|
|
5863
5863
|
if (promptedPassphrase !== null) {
|
|
5864
5864
|
passphrase = promptedPassphrase;
|
|
@@ -6113,6 +6113,9 @@ const wheelHandler = (e) => {
|
|
|
6113
6113
|
}
|
|
6114
6114
|
|
|
6115
6115
|
// Build connection data - only include auth if provided
|
|
6116
|
+
// Use actual terminal dimensions when available (falls back to 80x24
|
|
6117
|
+
// for the initial connection, then immediately resized via ssh-resize
|
|
6118
|
+
// after terminal is fitted)
|
|
6116
6119
|
const connectionData = {
|
|
6117
6120
|
host,
|
|
6118
6121
|
port,
|
|
@@ -6631,6 +6634,25 @@ const wheelHandler = (e) => {
|
|
|
6631
6634
|
console.log('[SSHIFT] Loading FitAddon...');
|
|
6632
6635
|
terminal.loadAddon(fitAddon);
|
|
6633
6636
|
|
|
6637
|
+
// Load Unicode11 addon for correct wide/ambiguous character width handling.
|
|
6638
|
+
// Without this, xterm.js uses its built-in width table (Unicode 6),
|
|
6639
|
+
// which mis-calculates many characters — causing cursor positioning
|
|
6640
|
+
// and erase-line operations to desync from the remote PTY's layout.
|
|
6641
|
+
// This is the primary fix for "dropped characters" in TUI apps
|
|
6642
|
+
// like OpenCode whose input line repaints depend on exact cell widths.
|
|
6643
|
+
if (typeof window.Unicode11Addon === 'function') {
|
|
6644
|
+
try {
|
|
6645
|
+
const unicode11Addon = new window.Unicode11Addon();
|
|
6646
|
+
terminal.loadAddon(unicode11Addon);
|
|
6647
|
+
terminal.unicode.activeVersion = '11';
|
|
6648
|
+
console.log('[SSHIFT] Unicode11 addon loaded, activeVersion set to 11');
|
|
6649
|
+
} catch (e) {
|
|
6650
|
+
console.warn('[SSHIFT] Failed to load Unicode11 addon:', e.message);
|
|
6651
|
+
}
|
|
6652
|
+
} else {
|
|
6653
|
+
console.warn('[SSHIFT] Unicode11 addon not available (window.Unicode11Addon type:', typeof window.Unicode11Addon, ')');
|
|
6654
|
+
}
|
|
6655
|
+
|
|
6634
6656
|
console.log('[SSHIFT] Opening terminal in container...');
|
|
6635
6657
|
|
|
6636
6658
|
// Ensure container has valid dimensions before opening
|
|
@@ -7371,8 +7393,27 @@ const wheelHandler = (e) => {
|
|
|
7371
7393
|
const MAX_WRITE_PER_FRAME = 32768;
|
|
7372
7394
|
|
|
7373
7395
|
if (combined.length > MAX_WRITE_PER_FRAME) {
|
|
7374
|
-
|
|
7375
|
-
|
|
7396
|
+
// Find a safe split point that doesn't break in the middle of an
|
|
7397
|
+
// escape sequence. Scan backwards from the cap limit for a character
|
|
7398
|
+
// that is NOT part of a multi-byte UTF-16 surrogate or an escape
|
|
7399
|
+
// sequence body. A bare ESC (\x1b) or CSI introducer (\x1b[)
|
|
7400
|
+
// always starts a new sequence, so splitting just before ESC is safe.
|
|
7401
|
+
let splitAt = MAX_WRITE_PER_FRAME;
|
|
7402
|
+
for (let i = MAX_WRITE_PER_FRAME - 1; i > MAX_WRITE_PER_FRAME - 4096 && i > 0; i--) {
|
|
7403
|
+
const code = combined.charCodeAt(i);
|
|
7404
|
+
// ESC (\x1b) always begins a new control sequence
|
|
7405
|
+
if (code === 0x1b) {
|
|
7406
|
+
splitAt = i;
|
|
7407
|
+
break;
|
|
7408
|
+
}
|
|
7409
|
+
// Don't split inside a UTF-16 surrogate pair
|
|
7410
|
+
if (code >= 0xDC00 && code <= 0xDFFF) {
|
|
7411
|
+
splitAt = i;
|
|
7412
|
+
break;
|
|
7413
|
+
}
|
|
7414
|
+
}
|
|
7415
|
+
terminal.write(combined.substring(0, splitAt));
|
|
7416
|
+
session.flushRemaining = combined.substring(splitAt);
|
|
7376
7417
|
session.writeRAF = requestAnimationFrame(() => {
|
|
7377
7418
|
this._flushWriteChunks(sessionId);
|
|
7378
7419
|
});
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Unicode11Addon=t():e.Unicode11Addon=t()}(globalThis,(()=>(()=>{"use strict";var e={384:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.UnicodeV11=void 0;const r=s(765),n=[[768,879],[1155,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1541],[1552,1562],[1564,1564],[1611,1631],[1648,1648],[1750,1757],[1759,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2045,2045],[2070,2073],[2075,2083],[2085,2087],[2089,2093],[2137,2139],[2259,2306],[2362,2362],[2364,2364],[2369,2376],[2381,2381],[2385,2391],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2558,2558],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2641,2641],[2672,2673],[2677,2677],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2810,2815],[2817,2817],[2876,2876],[2879,2879],[2881,2884],[2893,2893],[2902,2902],[2914,2915],[2946,2946],[3008,3008],[3021,3021],[3072,3072],[3076,3076],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3170,3171],[3201,3201],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3328,3329],[3387,3388],[3393,3396],[3405,3405],[3426,3427],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3981,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4151],[4153,4154],[4157,4158],[4184,4185],[4190,4192],[4209,4212],[4226,4226],[4229,4230],[4237,4237],[4253,4253],[4448,4607],[4957,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6158],[6277,6278],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6683,6683],[6742,6742],[6744,6750],[6752,6752],[6754,6754],[6757,6764],[6771,6780],[6783,6783],[6832,6846],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7040,7041],[7074,7077],[7080,7081],[7083,7085],[7142,7142],[7144,7145],[7149,7149],[7151,7153],[7212,7219],[7222,7223],[7376,7378],[7380,7392],[7394,7400],[7405,7405],[7412,7412],[7416,7417],[7616,7673],[7675,7679],[8203,8207],[8234,8238],[8288,8292],[8294,8303],[8400,8432],[11503,11505],[11647,11647],[11744,11775],[12330,12333],[12441,12442],[42607,42610],[42612,42621],[42654,42655],[42736,42737],[43010,43010],[43014,43014],[43019,43019],[43045,43046],[43204,43205],[43232,43249],[43263,43263],[43302,43309],[43335,43345],[43392,43394],[43443,43443],[43446,43449],[43452,43453],[43493,43493],[43561,43566],[43569,43570],[43573,43574],[43587,43587],[43596,43596],[43644,43644],[43696,43696],[43698,43700],[43703,43704],[43710,43711],[43713,43713],[43756,43757],[43766,43766],[44005,44005],[44008,44008],[44013,44013],[64286,64286],[65024,65039],[65056,65071],[65279,65279],[65529,65531]],i=[[66045,66045],[66272,66272],[66422,66426],[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[68325,68326],[68900,68903],[69446,69456],[69633,69633],[69688,69702],[69759,69761],[69811,69814],[69817,69818],[69821,69821],[69837,69837],[69888,69890],[69927,69931],[69933,69940],[70003,70003],[70016,70017],[70070,70078],[70089,70092],[70191,70193],[70196,70196],[70198,70199],[70206,70206],[70367,70367],[70371,70378],[70400,70401],[70459,70460],[70464,70464],[70502,70508],[70512,70516],[70712,70719],[70722,70724],[70726,70726],[70750,70750],[70835,70840],[70842,70842],[70847,70848],[70850,70851],[71090,71093],[71100,71101],[71103,71104],[71132,71133],[71219,71226],[71229,71229],[71231,71232],[71339,71339],[71341,71341],[71344,71349],[71351,71351],[71453,71455],[71458,71461],[71463,71467],[71727,71735],[71737,71738],[72148,72151],[72154,72155],[72160,72160],[72193,72202],[72243,72248],[72251,72254],[72263,72263],[72273,72278],[72281,72283],[72330,72342],[72344,72345],[72752,72758],[72760,72765],[72767,72767],[72850,72871],[72874,72880],[72882,72883],[72885,72886],[73009,73014],[73018,73018],[73020,73021],[73023,73029],[73031,73031],[73104,73105],[73109,73109],[73111,73111],[73459,73460],[78896,78904],[92912,92916],[92976,92982],[94031,94031],[94095,94098],[113821,113822],[113824,113827],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[121344,121398],[121403,121452],[121461,121461],[121476,121476],[121499,121503],[121505,121519],[122880,122886],[122888,122904],[122907,122913],[122915,122916],[122918,122922],[123184,123190],[123628,123631],[125136,125142],[125252,125258],[917505,917505],[917536,917631],[917760,917999]],o=[[4352,4447],[8986,8987],[9001,9002],[9193,9196],[9200,9200],[9203,9203],[9725,9726],[9748,9749],[9800,9811],[9855,9855],[9875,9875],[9889,9889],[9898,9899],[9917,9918],[9924,9925],[9934,9934],[9940,9940],[9962,9962],[9970,9971],[9973,9973],[9978,9978],[9981,9981],[9989,9989],[9994,9995],[10024,10024],[10060,10060],[10062,10062],[10067,10069],[10071,10071],[10133,10135],[10160,10160],[10175,10175],[11035,11036],[11088,11088],[11093,11093],[11904,11929],[11931,12019],[12032,12245],[12272,12283],[12288,12329],[12334,12350],[12353,12438],[12443,12543],[12549,12591],[12593,12686],[12688,12730],[12736,12771],[12784,12830],[12832,12871],[12880,19903],[19968,42124],[42128,42182],[43360,43388],[44032,55203],[63744,64255],[65040,65049],[65072,65106],[65108,65126],[65128,65131],[65281,65376],[65504,65510]],a=[[94176,94179],[94208,100343],[100352,101106],[110592,110878],[110928,110930],[110948,110951],[110960,111355],[126980,126980],[127183,127183],[127374,127374],[127377,127386],[127488,127490],[127504,127547],[127552,127560],[127568,127569],[127584,127589],[127744,127776],[127789,127797],[127799,127868],[127870,127891],[127904,127946],[127951,127955],[127968,127984],[127988,127988],[127992,128062],[128064,128064],[128066,128252],[128255,128317],[128331,128334],[128336,128359],[128378,128378],[128405,128406],[128420,128420],[128507,128591],[128640,128709],[128716,128716],[128720,128722],[128725,128725],[128747,128748],[128756,128762],[128992,129003],[129293,129393],[129395,129398],[129402,129442],[129445,129450],[129454,129482],[129485,129535],[129648,129651],[129656,129658],[129664,129666],[129680,129685],[131072,196605],[196608,262141]];let l;function c(e,t){let s,r=0,n=t.length-1;if(e<t[0][0]||e>t[n][1])return!1;for(;n>=r;)if(s=r+n>>1,e>t[s][1])r=s+1;else{if(!(e<t[s][0]))return!0;n=s-1}return!1}t.UnicodeV11=class{constructor(){if(this.version="11",!l){l=new Uint8Array(65536),l.fill(1),l[0]=0,l.fill(0,1,32),l.fill(0,127,160);for(let e=0;e<n.length;++e)l.fill(0,n[e][0],n[e][1]+1);for(let e=0;e<o.length;++e)l.fill(2,o[e][0],o[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?l[e]:c(e,i)?0:c(e,a)?2:1}charProperties(e,t){let s=this.wcwidth(e),n=0===s&&0!==t;if(n){const e=r.UnicodeService.extractWidth(t);0===e?n=!1:e>s&&(s=e)}return r.UnicodeService.createPropertyValue(0,s,n)}}},546:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.UnicodeV6=void 0;const r=s(765),n=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],i=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]];let o;t.UnicodeV6=class{constructor(){if(this.version="6",!o){o=new Uint8Array(65536),o.fill(1),o[0]=0,o.fill(0,1,32),o.fill(0,127,160),o.fill(2,4352,4448),o[9001]=2,o[9002]=2,o.fill(2,11904,42192),o[12351]=1,o.fill(2,44032,55204),o.fill(2,63744,64256),o.fill(2,65040,65050),o.fill(2,65072,65136),o.fill(2,65280,65377),o.fill(2,65504,65511);for(let e=0;e<n.length;++e)o.fill(0,n[e][0],n[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?o[e]:function(e,t){let s,r=0,n=t.length-1;if(e<t[0][0]||e>t[n][1])return!1;for(;n>=r;)if(s=r+n>>1,e>t[s][1])r=s+1;else{if(!(e<t[s][0]))return!0;n=s-1}return!1}(e,i)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let s=this.wcwidth(e),n=0===s&&0!==t;if(n){const e=r.UnicodeService.extractWidth(t);0===e?n=!1:e>s&&(s=e)}return r.UnicodeService.createPropertyValue(0,s,n)}}},765:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.UnicodeService=void 0;const r=s(546),n=s(276);class i{static extractShouldJoin(e){return!!(1&e)}static extractWidth(e){return e>>1&3}static extractCharKind(e){return e>>3}static createPropertyValue(e,t,s=!1){return(16777215&e)<<3|(3&t)<<1|(s?1:0)}constructor(){this._providers=Object.create(null),this._active="",this._onChange=new n.Emitter,this.onChange=this._onChange.event;const e=new r.UnicodeV6;this.register(e),this._active=e.version,this._activeProvider=e}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(e){if(!this._providers[e])throw new Error(`unknown Unicode version "${e}"`);this._active=e,this._activeProvider=this._providers[e],this._onChange.fire(e)}register(e){this._providers[e.version]=e}wcwidth(e){return this._activeProvider.wcwidth(e)}getStringCellWidth(e){let t=0,s=0;const r=e.length;for(let n=0;n<r;++n){let o=e.charCodeAt(n);if(55296<=o&&o<=56319){if(++n>=r)return t+this.wcwidth(o);const s=e.charCodeAt(n);56320<=s&&s<=57343?o=1024*(o-55296)+s-56320+65536:t+=this.wcwidth(s)}const a=this.charProperties(o,s);let l=i.extractWidth(a);i.extractShouldJoin(a)&&(l-=i.extractWidth(s)),t+=l,s=a}return t}charProperties(e,t){return this._activeProvider.charProperties(e,t)}}t.UnicodeService=i},732:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Permutation=t.CallbackIterable=t.ArrayQueue=t.booleanComparator=t.numberComparator=t.CompareResult=void 0,t.tail=function(e,t=0){return e[e.length-(1+t)]},t.tail2=function(e){if(0===e.length)throw new Error("Invalid tail call");return[e.slice(0,e.length-1),e[e.length-1]]},t.equals=function(e,t,s=(e,t)=>e===t){if(e===t)return!0;if(!e||!t)return!1;if(e.length!==t.length)return!1;for(let r=0,n=e.length;r<n;r++)if(!s(e[r],t[r]))return!1;return!0},t.removeFastWithoutKeepingOrder=function(e,t){const s=e.length-1;t<s&&(e[t]=e[s]),e.pop()},t.binarySearch=function(e,t,s){return i(e.length,(r=>s(e[r],t)))},t.binarySearch2=i,t.quickSelect=function e(t,s,r){if((t|=0)>=s.length)throw new TypeError("invalid index");const n=s[Math.floor(s.length*Math.random())],i=[],o=[],a=[];for(const e of s){const t=r(e,n);t<0?i.push(e):t>0?o.push(e):a.push(e)}return t<i.length?e(t,i,r):t<i.length+a.length?a[0]:e(t-(i.length+a.length),o,r)},t.groupBy=function(e,t){const s=[];let r;for(const n of e.slice(0).sort(t))r&&0===t(r[0],n)?r.push(n):(r=[n],s.push(r));return s},t.groupAdjacentBy=function*(e,t){let s,r;for(const n of e)void 0!==r&&t(r,n)?s.push(n):(s&&(yield s),s=[n]),r=n;s&&(yield s)},t.forEachAdjacent=function(e,t){for(let s=0;s<=e.length;s++)t(0===s?void 0:e[s-1],s===e.length?void 0:e[s])},t.forEachWithNeighbors=function(e,t){for(let s=0;s<e.length;s++)t(0===s?void 0:e[s-1],e[s],s+1===e.length?void 0:e[s+1])},t.sortedDiff=o,t.delta=function(e,t,s){const r=o(e,t,s),n=[],i=[];for(const t of r)n.push(...e.slice(t.start,t.start+t.deleteCount)),i.push(...t.toInsert);return{removed:n,added:i}},t.top=function(e,t,s){if(0===s)return[];const r=e.slice(0,s).sort(t);return a(e,t,r,s,e.length),r},t.topAsync=function(e,t,s,n,i){return 0===s?Promise.resolve([]):new Promise(((o,l)=>{(async()=>{const o=e.length,l=e.slice(0,s).sort(t);for(let c=s,h=Math.min(s+n,o);c<o;c=h,h=Math.min(h+n,o)){if(c>s&&await new Promise((e=>setTimeout(e))),i&&i.isCancellationRequested)throw new r.CancellationError;a(e,t,l,c,h)}return l})().then(o,l)}))},t.coalesce=function(e){return e.filter((e=>!!e))},t.coalesceInPlace=function(e){let t=0;for(let s=0;s<e.length;s++)e[s]&&(e[t]=e[s],t+=1);e.length=t},t.move=function(e,t,s){e.splice(s,0,e.splice(t,1)[0])},t.isFalsyOrEmpty=function(e){return!Array.isArray(e)||0===e.length},t.isNonEmptyArray=function(e){return Array.isArray(e)&&e.length>0},t.distinct=function(e,t=e=>e){const s=new Set;return e.filter((e=>{const r=t(e);return!s.has(r)&&(s.add(r),!0)}))},t.uniqueFilter=function(e){const t=new Set;return s=>{const r=e(s);return!t.has(r)&&(t.add(r),!0)}},t.firstOrDefault=function(e,t){return e.length>0?e[0]:t},t.lastOrDefault=function(e,t){return e.length>0?e[e.length-1]:t},t.commonPrefixLength=function(e,t,s=(e,t)=>e===t){let r=0;for(let n=0,i=Math.min(e.length,t.length);n<i&&s(e[n],t[n]);n++)r++;return r},t.range=function(e,t){let s="number"==typeof t?e:0;"number"==typeof t?s=e:(s=0,t=e);const r=[];if(s<=t)for(let e=s;e<t;e++)r.push(e);else for(let e=s;e>t;e--)r.push(e);return r},t.index=function(e,t,s){return e.reduce(((e,r)=>(e[t(r)]=s?s(r):r,e)),Object.create(null))},t.insert=function(e,t){return e.push(t),()=>l(e,t)},t.remove=l,t.arrayInsert=function(e,t,s){const r=e.slice(0,t),n=e.slice(t);return r.concat(s,n)},t.shuffle=function(e,t){let s;if("number"==typeof t){let e=t;s=()=>{const t=179426549*Math.sin(e++);return t-Math.floor(t)}}else s=Math.random;for(let t=e.length-1;t>0;t-=1){const r=Math.floor(s()*(t+1)),n=e[t];e[t]=e[r],e[r]=n}},t.pushToStart=function(e,t){const s=e.indexOf(t);s>-1&&(e.splice(s,1),e.unshift(t))},t.pushToEnd=function(e,t){const s=e.indexOf(t);s>-1&&(e.splice(s,1),e.push(t))},t.pushMany=function(e,t){for(const s of t)e.push(s)},t.mapArrayOrNot=function(e,t){return Array.isArray(e)?e.map(t):t(e)},t.asArray=function(e){return Array.isArray(e)?e:[e]},t.getRandomElement=function(e){return e[Math.floor(Math.random()*e.length)]},t.insertInto=c,t.splice=function(e,t,s,r){const n=h(e,t);let i=e.splice(n,s);return void 0===i&&(i=[]),c(e,n,r),i},t.compareBy=function(e,t){return(s,r)=>t(e(s),e(r))},t.tieBreakComparators=function(...e){return(t,s)=>{for(const r of e){const e=r(t,s);if(!u.isNeitherLessOrGreaterThan(e))return e}return u.neitherLessOrGreaterThan}},t.reverseOrder=function(e){return(t,s)=>-e(t,s)};const r=s(577),n=s(411);function i(e,t){let s=0,r=e-1;for(;s<=r;){const e=(s+r)/2|0,n=t(e);if(n<0)s=e+1;else{if(!(n>0))return e;r=e-1}}return-(s+1)}function o(e,t,s){const r=[];function n(e,t,s){if(0===t&&0===s.length)return;const n=r[r.length-1];n&&n.start+n.deleteCount===e?(n.deleteCount+=t,n.toInsert.push(...s)):r.push({start:e,deleteCount:t,toInsert:s})}let i=0,o=0;for(;;){if(i===e.length){n(i,0,t.slice(o));break}if(o===t.length){n(i,e.length-i,[]);break}const r=e[i],a=t[o],l=s(r,a);0===l?(i+=1,o+=1):l<0?(n(i,1,[]),i+=1):l>0&&(n(i,0,[a]),o+=1)}return r}function a(e,t,s,r,i){for(const o=s.length;r<i;r++){const i=e[r];if(t(i,s[o-1])<0){s.pop();const e=(0,n.findFirstIdxMonotonousOrArrLen)(s,(e=>t(i,e)<0));s.splice(e,0,i)}}}function l(e,t){const s=e.indexOf(t);if(s>-1)return e.splice(s,1),t}function c(e,t,s){const r=h(e,t),n=e.length,i=s.length;e.length=n+i;for(let t=n-1;t>=r;t--)e[t+i]=e[t];for(let t=0;t<i;t++)e[t+r]=s[t]}function h(e,t){return t<0?Math.max(t+e.length,0):Math.min(t,e.length)}var u;!function(e){e.isLessThan=function(e){return e<0},e.isLessThanOrEqual=function(e){return e<=0},e.isGreaterThan=function(e){return e>0},e.isNeitherLessOrGreaterThan=function(e){return 0===e},e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0}(u||(t.CompareResult=u={})),t.numberComparator=(e,t)=>e-t,t.booleanComparator=(e,s)=>(0,t.numberComparator)(e?1:0,s?1:0),t.ArrayQueue=class{constructor(e){this.items=e,this.firstIdx=0,this.lastIdx=this.items.length-1}get length(){return this.lastIdx-this.firstIdx+1}takeWhile(e){let t=this.firstIdx;for(;t<this.items.length&&e(this.items[t]);)t++;const s=t===this.firstIdx?null:this.items.slice(this.firstIdx,t);return this.firstIdx=t,s}takeFromEndWhile(e){let t=this.lastIdx;for(;t>=0&&e(this.items[t]);)t--;const s=t===this.lastIdx?null:this.items.slice(t+1,this.lastIdx+1);return this.lastIdx=t,s}peek(){if(0!==this.length)return this.items[this.firstIdx]}peekLast(){if(0!==this.length)return this.items[this.lastIdx]}dequeue(){const e=this.items[this.firstIdx];return this.firstIdx++,e}removeLast(){const e=this.items[this.lastIdx];return this.lastIdx--,e}takeCount(e){const t=this.items.slice(this.firstIdx,this.firstIdx+e);return this.firstIdx+=e,t}};class d{static{this.empty=new d((e=>{}))}constructor(e){this.iterate=e}forEach(e){this.iterate((t=>(e(t),!0)))}toArray(){const e=[];return this.iterate((t=>(e.push(t),!0))),e}filter(e){return new d((t=>this.iterate((s=>!e(s)||t(s)))))}map(e){return new d((t=>this.iterate((s=>t(e(s))))))}some(e){let t=!1;return this.iterate((s=>(t=e(s),!t))),t}findFirst(e){let t;return this.iterate((s=>!e(s)||(t=s,!1))),t}findLast(e){let t;return this.iterate((s=>(e(s)&&(t=s),!0))),t}findLastMaxBy(e){let t,s=!0;return this.iterate((r=>((s||u.isGreaterThan(e(r,t)))&&(s=!1,t=r),!0))),t}}t.CallbackIterable=d;class f{constructor(e){this._indexMap=e}static createSortPermutation(e,t){const s=Array.from(e.keys()).sort(((s,r)=>t(e[s],e[r])));return new f(s)}apply(e){return e.map(((t,s)=>e[this._indexMap[s]]))}inverse(){const e=this._indexMap.slice();for(let t=0;t<this._indexMap.length;t++)e[this._indexMap[t]]=t;return new f(e)}}t.Permutation=f},411:(e,t)=>{function s(e,t,s=e.length-1){for(let r=s;r>=0;r--)if(t(e[r]))return r;return-1}function r(e,t,s=0,r=e.length){let n=s,i=r;for(;n<i;){const s=Math.floor((n+i)/2);t(e[s])?n=s+1:i=s}return n-1}function n(e,t,s=0,r=e.length){let n=s,i=r;for(;n<i;){const s=Math.floor((n+i)/2);t(e[s])?i=s:n=s+1}return n}Object.defineProperty(t,"__esModule",{value:!0}),t.MonotonousArray=void 0,t.findLast=function(e,t){const r=s(e,t);if(-1!==r)return e[r]},t.findLastIdx=s,t.findLastMonotonous=function(e,t){const s=r(e,t);return-1===s?void 0:e[s]},t.findLastIdxMonotonous=r,t.findFirstMonotonous=function(e,t){const s=n(e,t);return s===e.length?void 0:e[s]},t.findFirstIdxMonotonousOrArrLen=n,t.findFirstIdxMonotonous=function(e,t,s=0,r=e.length){const i=n(e,t,s,r);return i===e.length?-1:i},t.findFirstMax=o,t.findLastMax=function(e,t){if(0===e.length)return;let s=e[0];for(let r=1;r<e.length;r++){const n=e[r];t(n,s)>=0&&(s=n)}return s},t.findFirstMin=function(e,t){return o(e,((e,s)=>-t(e,s)))},t.findMaxIdx=function(e,t){if(0===e.length)return-1;let s=0;for(let r=1;r<e.length;r++)t(e[r],e[s])>0&&(s=r);return s},t.mapFindFirst=function(e,t){for(const s of e){const e=t(s);if(void 0!==e)return e}};class i{static{this.assertInvariants=!1}constructor(e){this._array=e,this._findLastMonotonousLastIdx=0}findLastMonotonous(e){if(i.assertInvariants){if(this._prevFindLastPredicate)for(const t of this._array)if(this._prevFindLastPredicate(t)&&!e(t))throw new Error("MonotonousArray: current predicate must be weaker than (or equal to) the previous predicate.");this._prevFindLastPredicate=e}const t=r(this._array,e,this._findLastMonotonousLastIdx);return this._findLastMonotonousLastIdx=t+1,-1===t?void 0:this._array[t]}}function o(e,t){if(0===e.length)return;let s=e[0];for(let r=1;r<e.length;r++){const n=e[r];t(n,s)>0&&(s=n)}return s}t.MonotonousArray=i},33:(e,t)=>{var s;Object.defineProperty(t,"__esModule",{value:!0}),t.SetWithKey=void 0,t.groupBy=function(e,t){const s=Object.create(null);for(const r of e){const e=t(r);let n=s[e];n||(n=s[e]=[]),n.push(r)}return s},t.diffSets=function(e,t){const s=[],r=[];for(const r of e)t.has(r)||s.push(r);for(const s of t)e.has(s)||r.push(s);return{removed:s,added:r}},t.diffMaps=function(e,t){const s=[],r=[];for(const[r,n]of e)t.has(r)||s.push(n);for(const[s,n]of t)e.has(s)||r.push(n);return{removed:s,added:r}},t.intersection=function(e,t){const s=new Set;for(const r of t)e.has(r)&&s.add(r);return s};class r{static{s=Symbol.toStringTag}constructor(e,t){this.toKey=t,this._map=new Map,this[s]="SetWithKey";for(const t of e)this.add(t)}get size(){return this._map.size}add(e){const t=this.toKey(e);return this._map.set(t,e),this}delete(e){return this._map.delete(this.toKey(e))}has(e){return this._map.has(this.toKey(e))}*entries(){for(const e of this._map.values())yield[e,e]}keys(){return this.values()}*values(){for(const e of this._map.values())yield e}clear(){this._map.clear()}forEach(e,t){this._map.forEach((s=>e.call(t,s,s,this)))}[Symbol.iterator](){return this.values()}}t.SetWithKey=r},577:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BugIndicatingError=t.ErrorNoTelemetry=t.ExpectedError=t.NotSupportedError=t.NotImplementedError=t.ReadonlyError=t.CancellationError=t.errorHandler=t.ErrorHandler=void 0,t.setUnexpectedErrorHandler=function(e){t.errorHandler.setUnexpectedErrorHandler(e)},t.isSigPipeError=function(e){if(!e||"object"!=typeof e)return!1;const t=e;return"EPIPE"===t.code&&"WRITE"===t.syscall?.toUpperCase()},t.onUnexpectedError=function(e){n(e)||t.errorHandler.onUnexpectedError(e)},t.onUnexpectedExternalError=function(e){n(e)||t.errorHandler.onUnexpectedExternalError(e)},t.transformErrorForSerialization=function(e){if(e instanceof Error){const{name:t,message:s}=e;return{$isError:!0,name:t,message:s,stack:e.stacktrace||e.stack,noTelemetry:h.isErrorNoTelemetry(e)}}return e},t.transformErrorFromSerialization=function(e){let t;return e.noTelemetry?t=new h:(t=new Error,t.name=e.name),t.message=e.message,t.stack=e.stack,t},t.isCancellationError=n,t.canceled=function(){const e=new Error(r);return e.name=e.message,e},t.illegalArgument=function(e){return e?new Error(`Illegal argument: ${e}`):new Error("Illegal argument")},t.illegalState=function(e){return e?new Error(`Illegal state: ${e}`):new Error("Illegal state")},t.getErrorMessage=function(e){return e?e.message?e.message:e.stack?e.stack.split("\n")[0]:String(e):"Error"};class s{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout((()=>{if(e.stack){if(h.isErrorNoTelemetry(e))throw new h(e.message+"\n\n"+e.stack);throw new Error(e.message+"\n\n"+e.stack)}throw e}),0)}}addListener(e){return this.listeners.push(e),()=>{this._removeListener(e)}}emit(e){this.listeners.forEach((t=>{t(e)}))}_removeListener(e){this.listeners.splice(this.listeners.indexOf(e),1)}setUnexpectedErrorHandler(e){this.unexpectedErrorHandler=e}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(e){this.unexpectedErrorHandler(e),this.emit(e)}onUnexpectedExternalError(e){this.unexpectedErrorHandler(e)}}t.ErrorHandler=s,t.errorHandler=new s;const r="Canceled";function n(e){return e instanceof i||e instanceof Error&&e.name===r&&e.message===r}class i extends Error{constructor(){super(r),this.name=this.message}}t.CancellationError=i;class o extends TypeError{constructor(e){super(e?`${e} is read-only and cannot be changed`:"Cannot change read-only property")}}t.ReadonlyError=o;class a extends Error{constructor(e){super("NotImplemented"),e&&(this.message=e)}}t.NotImplementedError=a;class l extends Error{constructor(e){super("NotSupported"),e&&(this.message=e)}}t.NotSupportedError=l;class c extends Error{constructor(){super(...arguments),this.isExpected=!0}}t.ExpectedError=c;class h extends Error{constructor(e){super(e),this.name="CodeExpectedError"}static fromError(e){if(e instanceof h)return e;const t=new h;return t.message=e.message,t.stack=e.stack,t}static isErrorNoTelemetry(e){return"CodeExpectedError"===e.name}}t.ErrorNoTelemetry=h;class u extends Error{constructor(e){super(e||"An unexpected bug occurred."),Object.setPrototypeOf(this,u.prototype)}}t.BugIndicatingError=u},276:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ValueWithChangeEvent=t.Relay=t.EventBufferer=t.DynamicListEventMultiplexer=t.EventMultiplexer=t.MicrotaskEmitter=t.DebounceEmitter=t.PauseableEmitter=t.AsyncEmitter=t.createEventDeliveryQueue=t.Emitter=t.ListenerRefusalError=t.ListenerLeakError=t.EventProfiling=t.Event=void 0,t.setGlobalLeakWarningThreshold=function(e){const t=h;return h=e,{dispose(){h=t}}};const r=s(577),n=s(355),i=s(540),o=s(711),a=s(79);var l;!function(e){function t(e){return(t,s=null,r)=>{let n,i=!1;return n=e((e=>{if(!i)return n?n.dispose():i=!0,t.call(s,e)}),null,r),i&&n.dispose(),n}}function s(e,t,s){return n(((s,r=null,n)=>e((e=>s.call(r,t(e))),null,n)),s)}function r(e,t,s){return n(((s,r=null,n)=>e((e=>t(e)&&s.call(r,e)),null,n)),s)}function n(e,t){let s;const r=new m({onWillAddFirstListener(){s=e(r.fire,r)},onDidRemoveLastListener(){s?.dispose()}});return t?.add(r),r.event}function o(e,t,s=100,r=!1,n=!1,i,o){let a,l,c,h,u=0;const d=new m({leakWarningThreshold:i,onWillAddFirstListener(){a=e((e=>{u++,l=t(l,e),r&&!c&&(d.fire(l),l=void 0),h=()=>{const e=l;l=void 0,c=void 0,(!r||u>1)&&d.fire(e),u=0},"number"==typeof s?(clearTimeout(c),c=setTimeout(h,s)):void 0===c&&(c=0,queueMicrotask(h))}))},onWillRemoveListener(){n&&u>0&&h?.()},onDidRemoveLastListener(){h=void 0,a.dispose()}});return o?.add(d),d.event}e.None=()=>i.Disposable.None,e.defer=function(e,t){return o(e,(()=>{}),0,void 0,!0,void 0,t)},e.once=t,e.map=s,e.forEach=function(e,t,s){return n(((s,r=null,n)=>e((e=>{t(e),s.call(r,e)}),null,n)),s)},e.filter=r,e.signal=function(e){return e},e.any=function(...e){return(t,s=null,r)=>{return n=(0,i.combinedDisposable)(...e.map((e=>e((e=>t.call(s,e)))))),(o=r)instanceof Array?o.push(n):o&&o.add(n),n;var n,o}},e.reduce=function(e,t,r,n){let i=r;return s(e,(e=>(i=t(i,e),i)),n)},e.debounce=o,e.accumulate=function(t,s=0,r){return e.debounce(t,((e,t)=>e?(e.push(t),e):[t]),s,void 0,!0,void 0,r)},e.latch=function(e,t=(e,t)=>e===t,s){let n,i=!0;return r(e,(e=>{const s=i||!t(e,n);return i=!1,n=e,s}),s)},e.split=function(t,s,r){return[e.filter(t,s,r),e.filter(t,(e=>!s(e)),r)]},e.buffer=function(e,t=!1,s=[],r){let n=s.slice(),i=e((e=>{n?n.push(e):a.fire(e)}));r&&r.add(i);const o=()=>{n?.forEach((e=>a.fire(e))),n=null},a=new m({onWillAddFirstListener(){i||(i=e((e=>a.fire(e))),r&&r.add(i))},onDidAddFirstListener(){n&&(t?setTimeout(o):o())},onDidRemoveLastListener(){i&&i.dispose(),i=null}});return r&&r.add(a),a.event},e.chain=function(e,t){return(s,r,n)=>{const i=t(new l);return e((function(e){const t=i.evaluate(e);t!==a&&s.call(r,t)}),void 0,n)}};const a=Symbol("HaltChainable");class l{constructor(){this.steps=[]}map(e){return this.steps.push(e),this}forEach(e){return this.steps.push((t=>(e(t),t))),this}filter(e){return this.steps.push((t=>e(t)?t:a)),this}reduce(e,t){let s=t;return this.steps.push((t=>(s=e(s,t),s))),this}latch(e=(e,t)=>e===t){let t,s=!0;return this.steps.push((r=>{const n=s||!e(r,t);return s=!1,t=r,n?r:a})),this}evaluate(e){for(const t of this.steps)if((e=t(e))===a)break;return e}}e.fromNodeEventEmitter=function(e,t,s=e=>e){const r=(...e)=>n.fire(s(...e)),n=new m({onWillAddFirstListener:()=>e.on(t,r),onDidRemoveLastListener:()=>e.removeListener(t,r)});return n.event},e.fromDOMEventEmitter=function(e,t,s=e=>e){const r=(...e)=>n.fire(s(...e)),n=new m({onWillAddFirstListener:()=>e.addEventListener(t,r),onDidRemoveLastListener:()=>e.removeEventListener(t,r)});return n.event},e.toPromise=function(e){return new Promise((s=>t(e)(s)))},e.fromPromise=function(e){const t=new m;return e.then((e=>{t.fire(e)}),(()=>{t.fire(void 0)})).finally((()=>{t.dispose()})),t.event},e.forward=function(e,t){return e((e=>t.fire(e)))},e.runAndSubscribe=function(e,t,s){return t(s),e((e=>t(e)))};class c{constructor(e,t){this._observable=e,this._counter=0,this._hasChanged=!1;const s={onWillAddFirstListener:()=>{e.addObserver(this)},onDidRemoveLastListener:()=>{e.removeObserver(this)}};this.emitter=new m(s),t&&t.add(this.emitter)}beginUpdate(e){this._counter++}handlePossibleChange(e){}handleChange(e,t){this._hasChanged=!0}endUpdate(e){this._counter--,0===this._counter&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}e.fromObservable=function(e,t){return new c(e,t).emitter.event},e.fromObservableLight=function(e){return(t,s,r)=>{let n=0,o=!1;const a={beginUpdate(){n++},endUpdate(){n--,0===n&&(e.reportChanges(),o&&(o=!1,t.call(s)))},handlePossibleChange(){},handleChange(){o=!0}};e.addObserver(a),e.reportChanges();const l={dispose(){e.removeObserver(a)}};return r instanceof i.DisposableStore?r.add(l):Array.isArray(r)&&r.push(l),l}}}(l||(t.Event=l={}));class c{static{this.all=new Set}static{this._idPool=0}constructor(e){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${e}_${c._idPool++}`,c.all.add(this)}start(e){this._stopWatch=new a.StopWatch,this.listenerCount=e}stop(){if(this._stopWatch){const e=this._stopWatch.elapsed();this.durations.push(e),this.elapsedOverall+=e,this.invocationCount+=1,this._stopWatch=void 0}}}t.EventProfiling=c;let h=-1;class u{static{this._idPool=1}constructor(e,t,s=(u._idPool++).toString(16).padStart(3,"0")){this._errorHandler=e,this.threshold=t,this.name=s,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(e,t){const s=this.threshold;if(s<=0||t<s)return;this._stacks||(this._stacks=new Map);const r=this._stacks.get(e.value)||0;if(this._stacks.set(e.value,r+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=.5*s;const[e,r]=this.getMostFrequentStack(),n=`[${this.name}] potential listener LEAK detected, having ${t} listeners already. MOST frequent listener (${r}):`;console.warn(n),console.warn(e);const i=new f(n,e);this._errorHandler(i)}return()=>{const t=this._stacks.get(e.value)||0;this._stacks.set(e.value,t-1)}}getMostFrequentStack(){if(!this._stacks)return;let e,t=0;for(const[s,r]of this._stacks)(!e||t<r)&&(e=[s,r],t=r);return e}}class d{static create(){const e=new Error;return new d(e.stack??"")}constructor(e){this.value=e}print(){console.warn(this.value.split("\n").slice(2).join("\n"))}}class f extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}}t.ListenerLeakError=f;class p extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}}t.ListenerRefusalError=p;let _=0;class v{constructor(e){this.value=e,this.id=_++}}class m{constructor(e){this._size=0,this._options=e,this._leakageMon=h>0||this._options?.leakWarningThreshold?new u(e?.onListenerError??r.onUnexpectedError,this._options?.leakWarningThreshold??h):void 0,this._perfMon=this._options?._profName?new c(this._options._profName):void 0,this._deliveryQueue=this._options?.deliveryQueue}dispose(){this._disposed||(this._disposed=!0,this._deliveryQueue?.current===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),this._options?.onDidRemoveLastListener?.(),this._leakageMon?.dispose())}get event(){return this._event??=(e,t,s)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){const e=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(e);const t=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],s=new p(`${e}. HINT: Stack shows most frequent listener (${t[1]}-times)`,t[0]);return(this._options?.onListenerError||r.onUnexpectedError)(s),i.Disposable.None}if(this._disposed)return i.Disposable.None;t&&(e=e.bind(t));const n=new v(e);let o;this._leakageMon&&this._size>=Math.ceil(.2*this._leakageMon.threshold)&&(n.stack=d.create(),o=this._leakageMon.check(n.stack,this._size+1)),this._listeners?this._listeners instanceof v?(this._deliveryQueue??=new g,this._listeners=[this._listeners,n]):this._listeners.push(n):(this._options?.onWillAddFirstListener?.(this),this._listeners=n,this._options?.onDidAddFirstListener?.(this)),this._size++;const a=(0,i.toDisposable)((()=>{o?.(),this._removeListener(n)}));return s instanceof i.DisposableStore?s.add(a):Array.isArray(s)&&s.push(a),a},this._event}_removeListener(e){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(1===this._size)return this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),void(this._size=0);const t=this._listeners,s=t.indexOf(e);if(-1===s)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),new Error("Attempted to dispose unknown listener");this._size--,t[s]=void 0;const r=this._deliveryQueue.current===this;if(2*this._size<=t.length){let e=0;for(let s=0;s<t.length;s++)t[s]?t[e++]=t[s]:r&&(this._deliveryQueue.end--,e<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=e}}_deliver(e,t){if(!e)return;const s=this._options?.onListenerError||r.onUnexpectedError;if(s)try{e.value(t)}catch(e){s(e)}else e.value(t)}_deliverQueue(e){const t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){if(this._deliveryQueue?.current&&(this._deliverQueue(this._deliveryQueue),this._perfMon?.stop()),this._perfMon?.start(this._size),this._listeners)if(this._listeners instanceof v)this._deliver(this._listeners,e);else{const t=this._deliveryQueue;t.enqueue(this,e,this._listeners.length),this._deliverQueue(t)}this._perfMon?.stop()}hasListeners(){return this._size>0}}t.Emitter=m,t.createEventDeliveryQueue=()=>new g;class g{constructor(){this.i=-1,this.end=0}enqueue(e,t,s){this.i=0,this.end=s,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}}t.AsyncEmitter=class extends m{async fireAsync(e,t,s){if(this._listeners)for(this._asyncDeliveryQueue||(this._asyncDeliveryQueue=new o.LinkedList),((e,t)=>{if(e instanceof v)t(e);else for(let s=0;s<e.length;s++){const r=e[s];r&&t(r)}})(this._listeners,(t=>this._asyncDeliveryQueue.push([t.value,e])));this._asyncDeliveryQueue.size>0&&!t.isCancellationRequested;){const[e,n]=this._asyncDeliveryQueue.shift(),i=[],o={...n,token:t,waitUntil:t=>{if(Object.isFrozen(i))throw new Error("waitUntil can NOT be called asynchronous");s&&(t=s(t,e)),i.push(t)}};try{e(o)}catch(e){(0,r.onUnexpectedError)(e);continue}Object.freeze(i),await Promise.allSettled(i).then((e=>{for(const t of e)"rejected"===t.status&&(0,r.onUnexpectedError)(t.reason)}))}}};class y extends m{get isPaused(){return 0!==this._isPaused}constructor(e){super(e),this._isPaused=0,this._eventQueue=new o.LinkedList,this._mergeFn=e?.merge}pause(){this._isPaused++}resume(){if(0!==this._isPaused&&0==--this._isPaused)if(this._mergeFn){if(this._eventQueue.size>0){const e=Array.from(this._eventQueue);this._eventQueue.clear(),super.fire(this._mergeFn(e))}}else for(;!this._isPaused&&0!==this._eventQueue.size;)super.fire(this._eventQueue.shift())}fire(e){this._size&&(0!==this._isPaused?this._eventQueue.push(e):super.fire(e))}}t.PauseableEmitter=y,t.DebounceEmitter=class extends y{constructor(e){super(e),this._delay=e.delay??100}fire(e){this._handle||(this.pause(),this._handle=setTimeout((()=>{this._handle=void 0,this.resume()}),this._delay)),super.fire(e)}},t.MicrotaskEmitter=class extends m{constructor(e){super(e),this._queuedEvents=[],this._mergeFn=e?.merge}fire(e){this.hasListeners()&&(this._queuedEvents.push(e),1===this._queuedEvents.length&&queueMicrotask((()=>{this._mergeFn?super.fire(this._mergeFn(this._queuedEvents)):this._queuedEvents.forEach((e=>super.fire(e))),this._queuedEvents=[]})))}};class b{constructor(){this.hasListeners=!1,this.events=[],this.emitter=new m({onWillAddFirstListener:()=>this.onFirstListenerAdd(),onDidRemoveLastListener:()=>this.onLastListenerRemove()})}get event(){return this.emitter.event}add(e){const t={event:e,listener:null};return this.events.push(t),this.hasListeners&&this.hook(t),(0,i.toDisposable)((0,n.createSingleCallFunction)((()=>{this.hasListeners&&this.unhook(t);const e=this.events.indexOf(t);this.events.splice(e,1)})))}onFirstListenerAdd(){this.hasListeners=!0,this.events.forEach((e=>this.hook(e)))}onLastListenerRemove(){this.hasListeners=!1,this.events.forEach((e=>this.unhook(e)))}hook(e){e.listener=e.event((e=>this.emitter.fire(e)))}unhook(e){e.listener?.dispose(),e.listener=null}dispose(){this.emitter.dispose();for(const e of this.events)e.listener?.dispose();this.events=[]}}t.EventMultiplexer=b,t.DynamicListEventMultiplexer=class{constructor(e,t,s,r){this._store=new i.DisposableStore;const n=this._store.add(new b),o=this._store.add(new i.DisposableMap);function a(e){o.set(e,n.add(r(e)))}for(const t of e)a(t);this._store.add(t((e=>{a(e)}))),this._store.add(s((e=>{o.deleteAndDispose(e)}))),this.event=n.event}dispose(){this._store.dispose()}},t.EventBufferer=class{constructor(){this.data=[]}wrapEvent(e,t,s){return(r,n,i)=>e((e=>{const i=this.data[this.data.length-1];if(!t)return void(i?i.buffers.push((()=>r.call(n,e))):r.call(n,e));const o=i;o?(o.items??=[],o.items.push(e),0===o.buffers.length&&i.buffers.push((()=>{o.reducedResult??=s?o.items.reduce(t,s):o.items.reduce(t),r.call(n,o.reducedResult)}))):r.call(n,t(s,e))}),void 0,i)}bufferEvents(e){const t={buffers:new Array};this.data.push(t);const s=e();return this.data.pop(),t.buffers.forEach((e=>e())),s}},t.Relay=class{constructor(){this.listening=!1,this.inputEvent=l.None,this.inputEventListener=i.Disposable.None,this.emitter=new m({onDidAddFirstListener:()=>{this.listening=!0,this.inputEventListener=this.inputEvent(this.emitter.fire,this.emitter)},onDidRemoveLastListener:()=>{this.listening=!1,this.inputEventListener.dispose()}}),this.event=this.emitter.event}set input(e){this.inputEvent=e,this.listening&&(this.inputEventListener.dispose(),this.inputEventListener=e(this.emitter.fire,this.emitter))}dispose(){this.inputEventListener.dispose(),this.emitter.dispose()}},t.ValueWithChangeEvent=class{static const(e){return new E(e)}constructor(e){this._value=e,this._onDidChange=new m,this.onDidChange=this._onDidChange.event}get value(){return this._value}set value(e){e!==this._value&&(this._value=e,this._onDidChange.fire(void 0))}};class E{constructor(e){this.value=e,this.onDidChange=l.None}}},355:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.createSingleCallFunction=function(e,t){const s=this;let r,n=!1;return function(){if(n)return r;if(n=!0,t)try{r=e.apply(s,arguments)}finally{t()}else r=e.apply(s,arguments);return r}}},956:(e,t)=>{var s;Object.defineProperty(t,"__esModule",{value:!0}),t.Iterable=void 0,function(e){function t(e){return e&&"object"==typeof e&&"function"==typeof e[Symbol.iterator]}e.is=t;const s=Object.freeze([]);function*r(e){yield e}e.empty=function(){return s},e.single=r,e.wrap=function(e){return t(e)?e:r(e)},e.from=function(e){return e||s},e.reverse=function*(e){for(let t=e.length-1;t>=0;t--)yield e[t]},e.isEmpty=function(e){return!e||!0===e[Symbol.iterator]().next().done},e.first=function(e){return e[Symbol.iterator]().next().value},e.some=function(e,t){let s=0;for(const r of e)if(t(r,s++))return!0;return!1},e.find=function(e,t){for(const s of e)if(t(s))return s},e.filter=function*(e,t){for(const s of e)t(s)&&(yield s)},e.map=function*(e,t){let s=0;for(const r of e)yield t(r,s++)},e.flatMap=function*(e,t){let s=0;for(const r of e)yield*t(r,s++)},e.concat=function*(...e){for(const t of e)yield*t},e.reduce=function(e,t,s){let r=s;for(const s of e)r=t(r,s);return r},e.slice=function*(e,t,s=e.length){for(t<0&&(t+=e.length),s<0?s+=e.length:s>e.length&&(s=e.length);t<s;t++)yield e[t]},e.consume=function(t,s=Number.POSITIVE_INFINITY){const r=[];if(0===s)return[r,t];const n=t[Symbol.iterator]();for(let t=0;t<s;t++){const t=n.next();if(t.done)return[r,e.empty()];r.push(t.value)}return[r,{[Symbol.iterator]:()=>n}]},e.asyncToArray=async function(e){const t=[];for await(const s of e)t.push(s);return Promise.resolve(t)}}(s||(t.Iterable=s={}))},540:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DisposableMap=t.ImmortalReference=t.AsyncReferenceCollection=t.ReferenceCollection=t.SafeDisposable=t.RefCountedDisposable=t.MandatoryMutableDisposable=t.MutableDisposable=t.Disposable=t.DisposableStore=t.DisposableTracker=void 0,t.setDisposableTracker=function(e){l=e},t.trackDisposable=h,t.markAsDisposed=u,t.markAsSingleton=function(e){return l?.markAsSingleton(e),e},t.isDisposable=f,t.dispose=p,t.disposeIfDisposable=function(e){for(const t of e)f(t)&&t.dispose();return[]},t.combinedDisposable=function(...e){const t=_((()=>p(e)));return function(e,t){if(l)for(const s of e)l.setParent(s,t)}(e,t),t},t.toDisposable=_,t.disposeOnReturn=function(e){const t=new v;try{e(t)}finally{t.dispose()}};const r=s(732),n=s(33),i=s(714),o=s(355),a=s(956);let l=null;class c{constructor(){this.livingDisposables=new Map}static{this.idx=0}getDisposableData(e){let t=this.livingDisposables.get(e);return t||(t={parent:null,source:null,isSingleton:!1,value:e,idx:c.idx++},this.livingDisposables.set(e,t)),t}trackDisposable(e){const t=this.getDisposableData(e);t.source||(t.source=(new Error).stack)}setParent(e,t){this.getDisposableData(e).parent=t}markAsDisposed(e){this.livingDisposables.delete(e)}markAsSingleton(e){this.getDisposableData(e).isSingleton=!0}getRootParent(e,t){const s=t.get(e);if(s)return s;const r=e.parent?this.getRootParent(this.getDisposableData(e.parent),t):e;return t.set(e,r),r}getTrackedDisposables(){const e=new Map;return[...this.livingDisposables.entries()].filter((([,t])=>null!==t.source&&!this.getRootParent(t,e).isSingleton)).flatMap((([e])=>e))}computeLeakingDisposables(e=10,t){let s;if(t)s=t;else{const e=new Map,t=[...this.livingDisposables.values()].filter((t=>null!==t.source&&!this.getRootParent(t,e).isSingleton));if(0===t.length)return;const r=new Set(t.map((e=>e.value)));if(s=t.filter((e=>!(e.parent&&r.has(e.parent)))),0===s.length)throw new Error("There are cyclic diposable chains!")}if(!s)return;function o(e){const t=e.source.split("\n").map((e=>e.trim().replace("at ",""))).filter((e=>""!==e));return function(e,t){for(;e.length>0&&t.some((t=>"string"==typeof t?t===e[0]:e[0].match(t)));)e.shift()}(t,["Error",/^trackDisposable \(.*\)$/,/^DisposableTracker.trackDisposable \(.*\)$/]),t.reverse()}const a=new i.SetMap;for(const e of s){const t=o(e);for(let s=0;s<=t.length;s++)a.add(t.slice(0,s).join("\n"),e)}s.sort((0,r.compareBy)((e=>e.idx),r.numberComparator));let l="",c=0;for(const t of s.slice(0,e)){c++;const e=o(t),r=[];for(let t=0;t<e.length;t++){let i=e[t];i=`(shared with ${a.get(e.slice(0,t+1).join("\n")).size}/${s.length} leaks) at ${i}`;const l=a.get(e.slice(0,t).join("\n")),c=(0,n.groupBy)([...l].map((e=>o(e)[t])),(e=>e));delete c[e[t]];for(const[e,t]of Object.entries(c))r.unshift(` - stacktraces of ${t.length} other leaks continue with ${e}`);r.unshift(i)}l+=`\n\n\n==================== Leaking disposable ${c}/${s.length}: ${t.value.constructor.name} ====================\n${r.join("\n")}\n============================================================\n\n`}return s.length>e&&(l+=`\n\n\n... and ${s.length-e} more leaking disposables\n\n`),{leaks:s,details:l}}}function h(e){return l?.trackDisposable(e),e}function u(e){l?.markAsDisposed(e)}function d(e,t){l?.setParent(e,t)}function f(e){return"object"==typeof e&&null!==e&&"function"==typeof e.dispose&&0===e.dispose.length}function p(e){if(a.Iterable.is(e)){const t=[];for(const s of e)if(s)try{s.dispose()}catch(e){t.push(e)}if(1===t.length)throw t[0];if(t.length>1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}if(e)return e.dispose(),e}function _(e){const t=h({dispose:(0,o.createSingleCallFunction)((()=>{u(t),e()}))});return t}t.DisposableTracker=c;class v{static{this.DISABLE_DISPOSED_WARNING=!1}constructor(){this._toDispose=new Set,this._isDisposed=!1,h(this)}dispose(){this._isDisposed||(u(this),this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(0!==this._toDispose.size)try{p(this._toDispose)}finally{this._toDispose.clear()}}add(e){if(!e)return e;if(e===this)throw new Error("Cannot register a disposable on itself!");return d(e,this),this._isDisposed?v.DISABLE_DISPOSED_WARNING||console.warn(new Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(e),e}delete(e){if(e){if(e===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(e),e.dispose()}}deleteAndLeak(e){e&&this._toDispose.has(e)&&(this._toDispose.delete(e),d(e,null))}}t.DisposableStore=v;class m{static{this.None=Object.freeze({dispose(){}})}constructor(){this._store=new v,h(this),d(this._store,this)}dispose(){u(this),this._store.dispose()}_register(e){if(e===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(e)}}t.Disposable=m;class g{constructor(){this._isDisposed=!1,h(this)}get value(){return this._isDisposed?void 0:this._value}set value(e){this._isDisposed||e===this._value||(this._value?.dispose(),e&&d(e,this),this._value=e)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,u(this),this._value?.dispose(),this._value=void 0}clearAndLeak(){const e=this._value;return this._value=void 0,e&&d(e,null),e}}t.MutableDisposable=g,t.MandatoryMutableDisposable=class{constructor(e){this._disposable=new g,this._isDisposed=!1,this._disposable.value=e}get value(){return this._disposable.value}set value(e){this._isDisposed||e===this._disposable.value||(this._disposable.value=e)}dispose(){this._isDisposed=!0,this._disposable.dispose()}},t.RefCountedDisposable=class{constructor(e){this._disposable=e,this._counter=1}acquire(){return this._counter++,this}release(){return 0==--this._counter&&this._disposable.dispose(),this}},t.SafeDisposable=class{constructor(){this.dispose=()=>{},this.unset=()=>{},this.isset=()=>!1,h(this)}set(e){let t=e;return this.unset=()=>t=void 0,this.isset=()=>void 0!==t,this.dispose=()=>{t&&(t(),t=void 0,u(this))},this}},t.ReferenceCollection=class{constructor(){this.references=new Map}acquire(e,...t){let s=this.references.get(e);s||(s={counter:0,object:this.createReferencedObject(e,...t)},this.references.set(e,s));const{object:r}=s,n=(0,o.createSingleCallFunction)((()=>{0==--s.counter&&(this.destroyReferencedObject(e,s.object),this.references.delete(e))}));return s.counter++,{object:r,dispose:n}}},t.AsyncReferenceCollection=class{constructor(e){this.referenceCollection=e}async acquire(e,...t){const s=this.referenceCollection.acquire(e,...t);try{return{object:await s.object,dispose:()=>s.dispose()}}catch(e){throw s.dispose(),e}}},t.ImmortalReference=class{constructor(e){this.object=e}dispose(){}};class y{constructor(){this._store=new Map,this._isDisposed=!1,h(this)}dispose(){u(this),this._isDisposed=!0,this.clearAndDisposeAll()}clearAndDisposeAll(){if(this._store.size)try{p(this._store.values())}finally{this._store.clear()}}has(e){return this._store.has(e)}get size(){return this._store.size}get(e){return this._store.get(e)}set(e,t,s=!1){this._isDisposed&&console.warn(new Error("Trying to add a disposable to a DisposableMap that has already been disposed of. The added object will be leaked!").stack),s||this._store.get(e)?.dispose(),this._store.set(e,t)}deleteAndDispose(e){this._store.get(e)?.dispose(),this._store.delete(e)}deleteAndLeak(e){const t=this._store.get(e);return this._store.delete(e),t}keys(){return this._store.keys()}values(){return this._store.values()}[Symbol.iterator](){return this._store[Symbol.iterator]()}}t.DisposableMap=y},711:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.LinkedList=void 0;class s{static{this.Undefined=new s(void 0)}constructor(e){this.element=e,this.next=s.Undefined,this.prev=s.Undefined}}class r{constructor(){this._first=s.Undefined,this._last=s.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===s.Undefined}clear(){let e=this._first;for(;e!==s.Undefined;){const t=e.next;e.prev=s.Undefined,e.next=s.Undefined,e=t}this._first=s.Undefined,this._last=s.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){const r=new s(e);if(this._first===s.Undefined)this._first=r,this._last=r;else if(t){const e=this._last;this._last=r,r.prev=e,e.next=r}else{const e=this._first;this._first=r,r.next=e,e.prev=r}this._size+=1;let n=!1;return()=>{n||(n=!0,this._remove(r))}}shift(){if(this._first!==s.Undefined){const e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==s.Undefined){const e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==s.Undefined&&e.next!==s.Undefined){const t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===s.Undefined&&e.next===s.Undefined?(this._first=s.Undefined,this._last=s.Undefined):e.next===s.Undefined?(this._last=this._last.prev,this._last.next=s.Undefined):e.prev===s.Undefined&&(this._first=this._first.next,this._first.prev=s.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==s.Undefined;)yield e.element,e=e.next}}t.LinkedList=r},714:(e,t)=>{var s;Object.defineProperty(t,"__esModule",{value:!0}),t.SetMap=t.BidirectionalMap=t.CounterSet=t.Touch=void 0,t.getOrSet=function(e,t,s){let r=e.get(t);return void 0===r&&(r=s,e.set(t,r)),r},t.mapToString=function(e){const t=[];return e.forEach(((e,s)=>{t.push(`${s} => ${e}`)})),`Map(${e.size}) {${t.join(", ")}}`},t.setToString=function(e){const t=[];return e.forEach((e=>{t.push(e)})),`Set(${e.size}) {${t.join(", ")}}`},t.mapsStrictEqualIgnoreOrder=function(e,t){if(e===t)return!0;if(e.size!==t.size)return!1;for(const[s,r]of e)if(!t.has(s)||t.get(s)!==r)return!1;for(const[s]of t)if(!e.has(s))return!1;return!0},function(e){e[e.None=0]="None",e[e.AsOld=1]="AsOld",e[e.AsNew=2]="AsNew"}(s||(t.Touch=s={})),t.CounterSet=class{constructor(){this.map=new Map}add(e){return this.map.set(e,(this.map.get(e)||0)+1),this}delete(e){let t=this.map.get(e)||0;return 0!==t&&(t--,0===t?this.map.delete(e):this.map.set(e,t),!0)}has(e){return this.map.has(e)}},t.BidirectionalMap=class{constructor(e){if(this._m1=new Map,this._m2=new Map,e)for(const[t,s]of e)this.set(t,s)}clear(){this._m1.clear(),this._m2.clear()}set(e,t){this._m1.set(e,t),this._m2.set(t,e)}get(e){return this._m1.get(e)}getKey(e){return this._m2.get(e)}delete(e){const t=this._m1.get(e);return void 0!==t&&(this._m1.delete(e),this._m2.delete(t),!0)}forEach(e,t){this._m1.forEach(((s,r)=>{e.call(t,s,r,this)}))}keys(){return this._m1.keys()}values(){return this._m1.values()}},t.SetMap=class{constructor(){this.map=new Map}add(e,t){let s=this.map.get(e);s||(s=new Set,this.map.set(e,s)),s.add(t)}delete(e,t){const s=this.map.get(e);s&&(s.delete(t),0===s.size&&this.map.delete(e))}forEach(e,t){const s=this.map.get(e);s&&s.forEach(t)}get(e){return this.map.get(e)||new Set}}},79:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.StopWatch=void 0;const s=globalThis.performance&&"function"==typeof globalThis.performance.now;class r{static create(e){return new r(e)}constructor(e){this._now=s&&!1===e?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return-1!==this._stopTime?this._stopTime-this._startTime:this._now()-this._startTime}}t.StopWatch=r}},t={};function s(r){var n=t[r];if(void 0!==n)return n.exports;var i=t[r]={exports:{}};return e[r](i,i.exports,s),i.exports}var r={};return(()=>{var e=r;Object.defineProperty(e,"__esModule",{value:!0}),e.Unicode11Addon=void 0;const t=s(384);e.Unicode11Addon=class{activate(e){e.unicode.register(new t.UnicodeV11)}dispose(){}}})(),r})()));
|
|
2
|
+
//# sourceMappingURL=addon-unicode11.js.map
|