aegis-desktop 1.0.13 → 1.0.15
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/SOURCE-OFFER.txt +9 -0
- package/bin/aegis.js +1 -32
- package/lib/account-key.js +1 -56
- package/lib/auto.js +1 -430
- package/lib/avatar/companion.js +1 -698
- package/lib/avatar/cosmetics.js +1 -532
- package/lib/avatar/events.js +1 -344
- package/lib/avatar/holder-turn.js +1 -350
- package/lib/avatar/holders.js +1 -612
- package/lib/avatar/identity.js +1 -641
- package/lib/avatar/level.js +1 -368
- package/lib/avatar/mirror.js +1 -524
- package/lib/avatar/persona.js +1 -388
- package/lib/avatar/profile.js +1 -977
- package/lib/avatar/register.js +1 -307
- package/lib/avatar/store.js +1 -472
- package/lib/avatar/tiers.js +1 -38
- package/lib/avatar/transfer.js +1 -415
- package/lib/avatar/turn.js +1 -216
- package/lib/avatar/voice.js +1 -328
- package/lib/avatar/xp.js +1 -404
- package/lib/deep-link.js +1 -120
- package/lib/fingerprint.js +2 -347
- package/lib/google-connect.js +1 -169
- package/lib/local/agents.js +1 -105
- package/lib/local/autonomous.js +1 -1045
- package/lib/local/claude-pro.js +1 -993
- package/lib/local/context.js +1 -95
- package/lib/local/engine.js +1 -3228
- package/lib/local/entitlement.js +1 -654
- package/lib/local/git-scope.js +1 -228
- package/lib/local/local.js +1 -2135
- package/lib/local/prompt.js +1 -275
- package/lib/local/queue.js +1 -560
- package/lib/local/session-rounds.js +1 -208
- package/lib/local/shell.js +1 -680
- package/lib/local/telemetry.js +1 -470
- package/lib/local/tools.js +1 -1238
- package/lib/local/turn-guard.js +1 -300
- package/lib/local/worktree-lock.js +1 -235
- package/lib/provider-key-mirror.js +1 -252
- package/lib/quick-launcher.js +1 -84
- package/lib/settings.js +1 -890
- package/lib/sync/memory-queue.js +1 -60
- package/lib/sync/persist-gate.js +1 -148
- package/lib/sync/sessions.js +1 -106
- package/lib/window-state.js +1 -66
- package/main.js +3 -4390
- package/package.json +3 -5
- package/preload.js +3 -628
- package/renderer/app.js +1 -6560
- package/renderer/avatar/assemble.js +1 -335
- package/renderer/avatar/avatar.js +1 -380
- package/renderer/avatar/cards.js +1 -141
- package/renderer/avatar/hud.js +1 -206
- package/renderer/avatar/machine.js +1 -213
- package/renderer/avatar/pane.js +1 -439
- package/renderer/avatar/parts.js +1 -437
- package/renderer/budget.js +1 -168
- package/renderer/companion.js +1 -223
- package/renderer/diff.js +1 -359
- package/renderer/diffview.js +1 -336
- package/renderer/fingerprint.js +3 -720
- package/renderer/markdown.js +1 -168
- package/renderer/provider-toolbar.js +1 -134
- package/renderer/providers.js +1 -259
- package/renderer/quick.js +1 -191
- package/renderer/stream-policy.js +1 -306
- package/renderer/transcript-view.js +1 -323
- package/renderer/usage.js +1 -1239
- package/vendor/aegis.js +1 -2054
- package/vendor/attest.js +1 -442
- package/vendor/authorship-key.js +1 -410
- package/vendor/auto-provision.js +1 -134
- package/vendor/brain-catalog.js +1 -268
- package/vendor/byok-catalog.js +1 -230
- package/vendor/credentials.js +1 -494
- package/vendor/device-fingerprint.js +1 -141
- package/vendor/drive-connect.js +1 -85
- package/vendor/drive-upload.js +1 -174
- package/vendor/env-file.js +1 -1273
- package/vendor/fingerprint.js +1 -1064
- package/vendor/foreign-memory.js +1 -669
- package/vendor/google-signin.js +1 -125
- package/vendor/hooks.js +1 -430
- package/vendor/model-discovery.js +1 -330
- package/vendor/platform.js +1 -937
- package/vendor/prefs.js +1 -351
- package/vendor/presence-constants.js +1 -107
- package/vendor/presence.js +1 -438
- package/vendor/record-vault.js +3 -1055
- package/vendor/session-store.js +1 -548
- package/vendor/topup.js +1 -297
- package/vendor/touch.js +1 -458
- package/vendor/update.js +1 -704
- package/vendor/user-models.js +1 -381
|
@@ -1,325 +1,3 @@
|
|
|
1
1
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
2
2
|
// Copyright (C) 2026 Niklas Borneklint — AEGIS Code (aegiscode) / Aegiscloud.
|
|
3
|
-
|
|
4
|
-
// Conveying a modified copy, or running one as a network service, owes the
|
|
5
|
-
// corresponding source under this licence (§5/§13) — see LICENSING.md.
|
|
6
|
-
'use strict';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* The DOM-touching half of the transcript policy, extracted
|
|
10
|
-
* from app.js so the two symptoms this work exists to prevent can be asserted
|
|
11
|
-
* *behaviourally* — not just as pure math in stream-policy.js:
|
|
12
|
-
*
|
|
13
|
-
* - the transcript snapping to the bottom while you read → `follow()` asks
|
|
14
|
-
* stream-policy's `shouldFollow()` and the reader's own scroll sets the
|
|
15
|
-
* veto through `attachScrollVeto()`;
|
|
16
|
-
* - Escape failing to interrupt → `bindEscapeInterrupt()` is the one place
|
|
17
|
-
* the keyboard listener is registered.
|
|
18
|
-
*
|
|
19
|
-
* Why extract instead of testing app.js itself: app.js boots only under the
|
|
20
|
-
* Electron host (`window.aegis`/`window.models`) and builds a 2000-line UI, so
|
|
21
|
-
* a test that drives it would assert on a mock of everything. Everything here
|
|
22
|
-
* touches exactly four DOM surfaces — three numbers on the transcript element
|
|
23
|
-
* (scrollHeight/scrollTop/clientHeight), one passive `scroll` listener, one
|
|
24
|
-
* `keydown` listener on the document, and `requestAnimationFrame` — so
|
|
25
|
-
* test/renderer-dom.test.mjs drives the real file with a 60-line fake DOM and
|
|
26
|
-
* no third-party dependency. app.js only calls into this.
|
|
27
|
-
*
|
|
28
|
-
* Loaded as a classic script (index.html) *before* app.js, and requireable
|
|
29
|
-
* from Node like budget.js/stream-policy.js.
|
|
30
|
-
*/
|
|
31
|
-
|
|
32
|
-
// The decisions stay in stream-policy.js — one definition of "at the tail" and
|
|
33
|
-
// of "the reader has the veto". Classic script: resolve the globals declared by
|
|
34
|
-
// the sibling script tag; CommonJS: resolve the module. Eager, so a missing
|
|
35
|
-
// stream-policy.js script tag fails at load instead of on the first paint.
|
|
36
|
-
const policy =
|
|
37
|
-
typeof module !== 'undefined' && module.exports
|
|
38
|
-
? require('./stream-policy.js')
|
|
39
|
-
: { nearBottom: nearBottom, shouldFollow: shouldFollow };
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Coalescing paint + follow-the-tail state for the one transcript element.
|
|
43
|
-
*
|
|
44
|
-
* `messages` is the transcript (`#messages`); `requestFrame` defaults to the
|
|
45
|
-
* window's `requestAnimationFrame` and is injectable so a test can flush
|
|
46
|
-
* frames deterministically.
|
|
47
|
-
*/
|
|
48
|
-
function createTranscriptView(deps) {
|
|
49
|
-
const d = deps || {};
|
|
50
|
-
const messages = d.messages;
|
|
51
|
-
const requestFrame =
|
|
52
|
-
typeof d.requestFrame === 'function'
|
|
53
|
-
? d.requestFrame
|
|
54
|
-
: typeof requestAnimationFrame === 'function'
|
|
55
|
-
? requestAnimationFrame
|
|
56
|
-
: (fn) => fn();
|
|
57
|
-
|
|
58
|
-
/** Set while the reader has deliberately scrolled away from the tail. */
|
|
59
|
-
let scrolledUp = false;
|
|
60
|
-
|
|
61
|
-
/** Current transcript scroll metrics, or null when there is no transcript. */
|
|
62
|
-
function metrics() {
|
|
63
|
-
if (!messages) return null;
|
|
64
|
-
return {
|
|
65
|
-
scrollHeight: messages.scrollHeight,
|
|
66
|
-
scrollTop: messages.scrollTop,
|
|
67
|
-
clientHeight: messages.clientHeight,
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* The reader's veto over the streaming auto-scroll. This is the passive
|
|
73
|
-
* `scroll` listener: without it `scrolledUp` can never become true, leaving
|
|
74
|
-
* the transcript pinned to the tail no matter how far up you read while a
|
|
75
|
-
* model is working. Fires on every scroll frame, so it only records position.
|
|
76
|
-
*/
|
|
77
|
-
function noteScroll() {
|
|
78
|
-
scrolledUp = !policy.nearBottom(metrics());
|
|
79
|
-
return scrolledUp;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
function attachScrollVeto(el) {
|
|
83
|
-
const target = el || messages;
|
|
84
|
-
if (!target || typeof target.addEventListener !== 'function') return false;
|
|
85
|
-
target.addEventListener('scroll', noteScroll, { passive: true });
|
|
86
|
-
return true;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Follow the tail only while the reader is still there (was
|
|
91
|
-
* `stickToBottom`). A streaming turn must never yank the view back down once
|
|
92
|
-
* someone has scrolled up to read — that was why the transcript felt
|
|
93
|
-
* unscrollable while a model was working. `force` is for the cases where the
|
|
94
|
-
* view genuinely must follow: a message the user just sent, or a card they
|
|
95
|
-
* just opened. Returns whether the view moved.
|
|
96
|
-
*/
|
|
97
|
-
function follow(opts) {
|
|
98
|
-
if (!messages) return false;
|
|
99
|
-
if (!policy.shouldFollow(metrics(), { force: opts && opts.force, userScrolledUp: scrolledUp })) {
|
|
100
|
-
return false;
|
|
101
|
-
}
|
|
102
|
-
if (opts && opts.force) scrolledUp = false;
|
|
103
|
-
messages.scrollTop = messages.scrollHeight;
|
|
104
|
-
return true;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* Coalesce high-frequency stream updates to one paint per frame (was
|
|
109
|
-
* `rafPainter`). A cloud brain fan-out emits dozens of chunks a second, and
|
|
110
|
-
* each repaint read scrollHeight (forcing a synchronous layout) — that
|
|
111
|
-
* thrash is what made the window feel frozen mid-turn. Only the latest
|
|
112
|
-
* payload is painted; dropped frames are invisible because the text is
|
|
113
|
-
* cumulative. The returned function is idempotent within a frame.
|
|
114
|
-
*/
|
|
115
|
-
function paint(fn) {
|
|
116
|
-
let queued = false;
|
|
117
|
-
return function schedule() {
|
|
118
|
-
if (queued) return;
|
|
119
|
-
queued = true;
|
|
120
|
-
requestFrame(() => {
|
|
121
|
-
queued = false;
|
|
122
|
-
fn();
|
|
123
|
-
});
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
return {
|
|
128
|
-
metrics: metrics,
|
|
129
|
-
noteScroll: noteScroll,
|
|
130
|
-
attachScrollVeto: attachScrollVeto,
|
|
131
|
-
follow: follow,
|
|
132
|
-
paint: paint,
|
|
133
|
-
isScrolledUp: () => scrolledUp,
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* The pane-scroll signal behind the UI "lift" (see the scroll-lift section in
|
|
139
|
-
* style.css): while any scrolling pane is off its top edge, the chrome around
|
|
140
|
-
* it gains depth instead of reading as a static page.
|
|
141
|
-
*
|
|
142
|
-
* Registered *here*, next to the veto, for the same reason that veto lives
|
|
143
|
-
* here and not inline: this file is the one owner of `scroll` listeners, so
|
|
144
|
-
* "the reader's scroll position" has exactly one definition. A second listener
|
|
145
|
-
* with its own idea of it is how the two drift apart — which is what
|
|
146
|
-
* test/renderer-wiring.test.mjs's 5b guard exists to prevent.
|
|
147
|
-
*
|
|
148
|
-
* The panes arrive from app.js (it knows which elements scroll); this function
|
|
149
|
-
* owns the listener, the frame coalescing and the class toggle. A `window`
|
|
150
|
-
* listener would never fire at all — html/body are `height: 100%`, so the
|
|
151
|
-
* window itself never scrolls — hence the explicit pane list.
|
|
152
|
-
*
|
|
153
|
-
* `threshold` is 4px, not 0: sub-pixel scroll positions read from a pane at
|
|
154
|
-
* rest would otherwise flicker the shadow on and off at the top.
|
|
155
|
-
*/
|
|
156
|
-
function attachScrollLift(deps) {
|
|
157
|
-
const d = deps || {};
|
|
158
|
-
const panes = Array.prototype.slice.call(d.panes || []);
|
|
159
|
-
const target =
|
|
160
|
-
d.target || (typeof document !== 'undefined' && document.body ? document.body : null);
|
|
161
|
-
if (!panes.length || !target || !target.classList) return null;
|
|
162
|
-
|
|
163
|
-
const schedule =
|
|
164
|
-
typeof d.requestFrame === 'function'
|
|
165
|
-
? d.requestFrame
|
|
166
|
-
: typeof requestAnimationFrame === 'function'
|
|
167
|
-
? requestAnimationFrame
|
|
168
|
-
: (fn) => fn();
|
|
169
|
-
const className = d.className || 'is-scrolled';
|
|
170
|
-
const threshold = typeof d.threshold === 'number' ? d.threshold : 4;
|
|
171
|
-
|
|
172
|
-
let queued = false;
|
|
173
|
-
/** Idempotent: one class toggle per frame no matter how many events fired. */
|
|
174
|
-
function sync() {
|
|
175
|
-
queued = false;
|
|
176
|
-
let lifted = false;
|
|
177
|
-
for (const pane of panes) {
|
|
178
|
-
if (pane && pane.scrollTop > threshold) {
|
|
179
|
-
lifted = true;
|
|
180
|
-
break;
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
target.classList.toggle(className, lifted);
|
|
184
|
-
}
|
|
185
|
-
function onScroll() {
|
|
186
|
-
if (queued) return;
|
|
187
|
-
queued = true;
|
|
188
|
-
schedule(sync);
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
for (const pane of panes) {
|
|
192
|
-
if (pane && typeof pane.addEventListener === 'function') {
|
|
193
|
-
pane.addEventListener('scroll', onScroll, { passive: true });
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
sync();
|
|
197
|
-
|
|
198
|
-
return {
|
|
199
|
-
sync: sync,
|
|
200
|
-
panes: panes,
|
|
201
|
-
unbind: () => {
|
|
202
|
-
for (const pane of panes) {
|
|
203
|
-
if (pane && typeof pane.removeEventListener === 'function') {
|
|
204
|
-
pane.removeEventListener('scroll', onScroll);
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
},
|
|
208
|
-
};
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
/**
|
|
212
|
-
* Escape → the running turn's interrupt (the keyboard twin of the cancel
|
|
213
|
-
* button, for the window that is too busy to aim at it).
|
|
214
|
-
*
|
|
215
|
-
* Deliberately the only `keydown` registration: the memory overlay wins while
|
|
216
|
-
* it is open — Escape closes it rather than reaching past it to cancel a turn
|
|
217
|
-
* the user may not be looking at — and Escape does nothing at all when no turn
|
|
218
|
-
* is pending, so the key never becomes a surprise.
|
|
219
|
-
*
|
|
220
|
-
* Returns the handler plus an `unbind()` for symmetry with the listener it
|
|
221
|
-
* owns; the return value is also what lets a test call the decision directly.
|
|
222
|
-
*/
|
|
223
|
-
function bindEscapeInterrupt(deps) {
|
|
224
|
-
const d = deps || {};
|
|
225
|
-
|
|
226
|
-
// Why the last Escape did what it did.
|
|
227
|
-
//
|
|
228
|
-
// This exists because the only externally visible signal an ignored Escape
|
|
229
|
-
// leaves behind is `defaultPrevented === false`, and that single bit cannot
|
|
230
|
-
// tell four legitimate refusals (overlay open, no pending turn, no stopTurn,
|
|
231
|
-
// auto-repeat) apart from the one genuinely broken case: a dependency threw
|
|
232
|
-
// inside the listener, and `dispatchEvent` reported the listener error as
|
|
233
|
-
// uncaught instead of propagating it to the caller. Both look identical from
|
|
234
|
-
// outside — the turn keeps running and `defaultPrevented` is false — so a
|
|
235
|
-
// wiring fault is indistinguishable from a policy decision without this.
|
|
236
|
-
let lastDecision = null;
|
|
237
|
-
|
|
238
|
-
function handle(e) {
|
|
239
|
-
const decision = {
|
|
240
|
-
at: Date.now(),
|
|
241
|
-
key: e && e.key,
|
|
242
|
-
repeat: Boolean(e && e.repeat),
|
|
243
|
-
overlayOpen: null,
|
|
244
|
-
hasPendingTurn: null,
|
|
245
|
-
consumed: false,
|
|
246
|
-
threw: null,
|
|
247
|
-
};
|
|
248
|
-
lastDecision = decision;
|
|
249
|
-
|
|
250
|
-
if (!e || e.key !== 'Escape') return false;
|
|
251
|
-
// A held key is one intent, not one per repeat. Without this the auto-repeat
|
|
252
|
-
// events keep arriving after the interrupted turn has already ended, and
|
|
253
|
-
// the ones that land once the user has sent the next message stop that turn
|
|
254
|
-
// instead — the keyboard twin of a stuck cancel button.
|
|
255
|
-
if (e.repeat) return false;
|
|
256
|
-
if (typeof d.isOverlayOpen === 'function') {
|
|
257
|
-
try {
|
|
258
|
-
decision.overlayOpen = Boolean(d.isOverlayOpen());
|
|
259
|
-
} catch (err) {
|
|
260
|
-
// A probe that breaks must not disarm the interrupt: the user's only
|
|
261
|
-
// keyboard route to stopping a runaway turn is this handler, and
|
|
262
|
-
// "unknown" is not "open". The reason is recorded rather than raised,
|
|
263
|
-
// so the smoke run fails on it while the user still gets their Escape.
|
|
264
|
-
decision.threw = 'isOverlayOpen: ' + ((err && err.message) || err);
|
|
265
|
-
decision.overlayOpen = false;
|
|
266
|
-
}
|
|
267
|
-
if (decision.overlayOpen) {
|
|
268
|
-
if (typeof d.onOverlayEscape === 'function') {
|
|
269
|
-
try {
|
|
270
|
-
d.onOverlayEscape();
|
|
271
|
-
} catch (err) {
|
|
272
|
-
decision.threw = 'onOverlayEscape: ' + ((err && err.message) || err);
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
return false;
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
if (typeof d.hasPendingTurn === 'function') {
|
|
279
|
-
try {
|
|
280
|
-
decision.hasPendingTurn = Boolean(d.hasPendingTurn());
|
|
281
|
-
} catch (err) {
|
|
282
|
-
decision.threw = 'hasPendingTurn: ' + ((err && err.message) || err);
|
|
283
|
-
return false;
|
|
284
|
-
}
|
|
285
|
-
if (!decision.hasPendingTurn) return false;
|
|
286
|
-
}
|
|
287
|
-
if (typeof d.stopTurn !== 'function') return false;
|
|
288
|
-
if (typeof e.preventDefault === 'function') e.preventDefault();
|
|
289
|
-
decision.consumed = true;
|
|
290
|
-
// The key is consumed either way — the interrupt has been asked for and the
|
|
291
|
-
// turn must not survive a throw from the stop itself. What the stop
|
|
292
|
-
// ANSWERED is recorded, because a consumed key with a refused stop is the
|
|
293
|
-
// one combination that looks like success from outside while nothing has
|
|
294
|
-
// happened: `defaultPrevented` is true, the bubble never appears, and the
|
|
295
|
-
// turn runs to completion.
|
|
296
|
-
let stopResult = null;
|
|
297
|
-
try {
|
|
298
|
-
const r = d.stopTurn();
|
|
299
|
-
stopResult = r === undefined ? null : Boolean(r);
|
|
300
|
-
} catch (err) {
|
|
301
|
-
stopResult = false;
|
|
302
|
-
decision.threw = 'stopTurn: ' + ((err && err.message) || err);
|
|
303
|
-
}
|
|
304
|
-
decision.stopAccepted = stopResult;
|
|
305
|
-
return true;
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
if (d.doc && typeof d.doc.addEventListener === 'function') {
|
|
309
|
-
d.doc.addEventListener('keydown', handle);
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
return {
|
|
313
|
-
handle: handle,
|
|
314
|
-
lastDecision: () => lastDecision,
|
|
315
|
-
unbind: () => {
|
|
316
|
-
if (d.doc && typeof d.doc.removeEventListener === 'function') {
|
|
317
|
-
d.doc.removeEventListener('keydown', handle);
|
|
318
|
-
}
|
|
319
|
-
},
|
|
320
|
-
};
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
if (typeof module !== 'undefined' && module.exports) {
|
|
324
|
-
module.exports = { createTranscriptView, bindEscapeInterrupt, attachScrollLift };
|
|
325
|
-
}
|
|
3
|
+
"use strict";const policy="undefined"!=typeof module&&module.exports?require("./stream-policy.js"):{nearBottom:nearBottom,shouldFollow:shouldFollow};function createTranscriptView(e){const t=e||{},n=t.messages,o="function"==typeof t.requestFrame?t.requestFrame:"function"==typeof requestAnimationFrame?requestAnimationFrame:e=>e();let r=!1;function c(){return n?{scrollHeight:n.scrollHeight,scrollTop:n.scrollTop,clientHeight:n.clientHeight}:null}function l(){return r=!policy.nearBottom(c()),r}return{metrics:c,noteScroll:l,attachScrollVeto:function(e){const t=e||n;return!(!t||"function"!=typeof t.addEventListener||(t.addEventListener("scroll",l,{passive:!0}),0))},follow:function(e){return!!n&&!!policy.shouldFollow(c(),{force:e&&e.force,userScrolledUp:r})&&(e&&e.force&&(r=!1),n.scrollTop=n.scrollHeight,!0)},paint:function(e){let t=!1;return function(){t||(t=!0,o((()=>{t=!1,e()})))}},isScrolledUp:()=>r}}function attachScrollLift(e){const t=e||{},n=Array.prototype.slice.call(t.panes||[]),o=t.target||("undefined"!=typeof document&&document.body?document.body:null);if(!n.length||!o||!o.classList)return null;const r="function"==typeof t.requestFrame?t.requestFrame:"function"==typeof requestAnimationFrame?requestAnimationFrame:e=>e(),c=t.className||"is-scrolled",l="number"==typeof t.threshold?t.threshold:4;let s=!1;function i(){s=!1;let e=!1;for(const t of n)if(t&&t.scrollTop>l){e=!0;break}o.classList.toggle(c,e)}function u(){s||(s=!0,r(i))}for(const e of n)e&&"function"==typeof e.addEventListener&&e.addEventListener("scroll",u,{passive:!0});return i(),{sync:i,panes:n,unbind:()=>{for(const e of n)e&&"function"==typeof e.removeEventListener&&e.removeEventListener("scroll",u)}}}function bindEscapeInterrupt(e){const t=e||{};let n=null;function o(e){const o={at:Date.now(),key:e&&e.key,repeat:Boolean(e&&e.repeat),overlayOpen:null,hasPendingTurn:null,consumed:!1,threw:null};if(n=o,!e||"Escape"!==e.key)return!1;if(e.repeat)return!1;if("function"==typeof t.isOverlayOpen){try{o.overlayOpen=Boolean(t.isOverlayOpen())}catch(e){o.threw="isOverlayOpen: "+(e&&e.message||e),o.overlayOpen=!1}if(o.overlayOpen){if("function"==typeof t.onOverlayEscape)try{t.onOverlayEscape()}catch(e){o.threw="onOverlayEscape: "+(e&&e.message||e)}return!1}}if("function"==typeof t.hasPendingTurn){try{o.hasPendingTurn=Boolean(t.hasPendingTurn())}catch(e){return o.threw="hasPendingTurn: "+(e&&e.message||e),!1}if(!o.hasPendingTurn)return!1}if("function"!=typeof t.stopTurn)return!1;"function"==typeof e.preventDefault&&e.preventDefault(),o.consumed=!0;let r=null;try{const e=t.stopTurn();r=void 0===e?null:Boolean(e)}catch(e){r=!1,o.threw="stopTurn: "+(e&&e.message||e)}return o.stopAccepted=r,!0}return t.doc&&"function"==typeof t.doc.addEventListener&&t.doc.addEventListener("keydown",o),{handle:o,lastDecision:()=>n,unbind:()=>{t.doc&&"function"==typeof t.doc.removeEventListener&&t.doc.removeEventListener("keydown",o)}}}"undefined"!=typeof module&&module.exports&&(module.exports={createTranscriptView:createTranscriptView,bindEscapeInterrupt:bindEscapeInterrupt,attachScrollLift:attachScrollLift});
|