nodejs-map 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +95 -2
- package/dist/app/assets/app.worker-PoneE3J2.js +8 -0
- package/dist/app/assets/app.worker-PoneE3J2.js.map +1 -0
- package/dist/app/assets/atlas.worker-B0xwOHwo.js +2 -0
- package/dist/app/assets/atlas.worker-B0xwOHwo.js.map +1 -0
- package/dist/app/assets/cm-BiB0hvWw.js +13 -0
- package/dist/app/assets/cm-BiB0hvWw.js.map +1 -0
- package/dist/app/assets/dist-B37Ex44M.js +2 -0
- package/dist/app/assets/dist-B37Ex44M.js.map +1 -0
- package/dist/app/assets/dist-hDhUT_Vg.js +2 -0
- package/dist/app/assets/dist-hDhUT_Vg.js.map +1 -0
- package/dist/app/assets/index-2K-ozYKf.js +16 -0
- package/dist/app/assets/index-2K-ozYKf.js.map +1 -0
- package/dist/app/assets/index-Cw18rDSZ.css +1 -0
- package/dist/app/assets/map-Cnxgv4Ve.js +129 -0
- package/dist/app/assets/map-Cnxgv4Ve.js.map +1 -0
- package/dist/app/assets/map-Cz4s03Wm.css +1 -0
- package/dist/app/assets/sdf-label-font-1nAa0TP8.png +0 -0
- package/dist/app/config.json +5 -0
- package/dist/app/favicon.svg +1 -0
- package/dist/app/index.html +21 -0
- package/dist/atlas/v26.13.1/build-report.json +178 -0
- package/dist/atlas/v26.13.1/chunks/lib.bootstrap.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/lib.core.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/lib.crypto.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/lib.devtools.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/lib.events.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/lib.fs.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/lib.modules.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/lib.net.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/lib.net.1.json +1 -0
- package/dist/atlas/v26.13.1/chunks/lib.platform.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/lib.process.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/lib.rest.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/lib.streams.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/lib.timers.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/lib.workers.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/lib.zlib.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/src.callbacks.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/src.crypto.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/src.diag.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/src.fs.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/src.inspector.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/src.loop.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/src.modules.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/src.napi.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/src.net.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/src.net.1.json +1 -0
- package/dist/atlas/v26.13.1/chunks/src.process.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/src.rest.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/src.support.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/src.zlib.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/uv.api.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/uv.backends.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/uv.fs.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/uv.loop.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/uv.net.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/uv.rest.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/uv.threadpool.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.api.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.asmjs.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.ast.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.base.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.baseline.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.bigint.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.builtins.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.codegen.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.codegen.riscv.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.common.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.compiler-dispatcher.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.compiler.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.compiler.backend.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.compiler.turboshaft.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.d8.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.date.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.debug.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.deoptimizer.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.diagnostics.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.dumpling.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.execution.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.extensions.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.flags.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.fuzzilli.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.handles.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.heap.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.heap.cppgc.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.ic.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.init.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.inspector.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.interpreter.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.json.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.libplatform.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.libsampler.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.logging.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.maglev.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.numbers.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.objects.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.parsing.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.profiler.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.regexp.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.root.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.roots.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.runtime.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.sandbox.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.snapshot.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.strings.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.tasks.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.torque.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.tracing.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.trap-handler.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.utils.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.wasm.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.zone.0.json +1 -0
- package/dist/atlas/v26.13.1/edges.json +1 -0
- package/dist/atlas/v26.13.1/files.json +1 -0
- package/dist/atlas/v26.13.1/index.json +1 -0
- package/dist/atlas/v26.13.1/link-check.json +16 -0
- package/dist/atlas/v26.13.1/search.json +1 -0
- package/dist/cli.js +6002 -0
- package/dist/examples.json +1 -0
- package/dist/lessons/async-await-chain.nmrec.gz +0 -0
- package/dist/lessons/beforeexit-and-exit.nmrec.gz +0 -0
- package/dist/lessons/dns-lookup-thread-pool.nmrec.gz +0 -0
- package/dist/lessons/esm-twist.nmrec.gz +0 -0
- package/dist/lessons/eventemitter-is-synchronous.nmrec.gz +0 -0
- package/dist/lessons/fs-promises-await.nmrec.gz +0 -0
- package/dist/lessons/fs-sync-vs-async.nmrec.gz +0 -0
- package/dist/lessons/index.json +621 -0
- package/dist/lessons/interval-and-clear.nmrec.gz +0 -0
- package/dist/lessons/nested-ticks-and-microtasks.nmrec.gz +0 -0
- package/dist/lessons/pbkdf2-six-jobs-four-threads.nmrec.gz +0 -0
- package/dist/lessons/pool-with-two-threads.nmrec.gz +0 -0
- package/dist/lessons/readfile-thread-pool.nmrec.gz +0 -0
- package/dist/lessons/tcp-round-trip.nmrec.gz +0 -0
- package/dist/lessons/tick-before-promise.nmrec.gz +0 -0
- package/dist/lessons/timeout-vs-immediate-io.nmrec.gz +0 -0
- package/dist/lessons/timeout-vs-immediate-main.nmrec.gz +0 -0
- package/dist/lessons/timer-vs-file-read.nmrec.gz +0 -0
- package/dist/lessons/timers-phase.nmrec.gz +0 -0
- package/dist/preload.cjs +477 -0
- package/package.json +25 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 ProCodrr
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,96 @@
|
|
|
1
|
-
#
|
|
1
|
+
# nodejs-map
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
See what happens inside real Node.js while your program runs.
|
|
4
|
+
|
|
5
|
+
`nodejs-map` runs your code on your own Node.js, on your own machine, and
|
|
6
|
+
shows two things side by side in the browser:
|
|
7
|
+
|
|
8
|
+
- **A map of Node.js** that you can zoom like a street map: your code, Node's
|
|
9
|
+
JavaScript library, the C++ bindings, V8 and libuv, down to single source
|
|
10
|
+
files and functions, each linked to the exact line on GitHub.
|
|
11
|
+
- **A debugger and live view**: set breakpoints, pause and step as in Chrome
|
|
12
|
+
DevTools, and watch the call stack, the `nextTick` queue, the promise queue,
|
|
13
|
+
timers, the event loop phases, the thread pool and pending I/O as they change.
|
|
14
|
+
|
|
15
|
+
Every run can be saved as a recording and replayed later, step by step,
|
|
16
|
+
forwards and backwards. The package also carries 18 short recorded lessons
|
|
17
|
+
(nextTick and promises, timers and immediates, the thread pool, file reads,
|
|
18
|
+
sockets, process exit).
|
|
19
|
+
|
|
20
|
+
## Use
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
npx nodejs-map # start in the current folder and open the browser
|
|
24
|
+
npx nodejs-map file.js # the same, with file.js opened in the editor
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Options: `--port <n>`, `--no-open`, `--node <path>` (run programs with another
|
|
28
|
+
Node binary), `--help`.
|
|
29
|
+
|
|
30
|
+
Without a browser, to save what one run did:
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
npx nodejs-map record file.js --out file.nmrec.gz --include-source
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Safety
|
|
37
|
+
|
|
38
|
+
1. The helper listens on `127.0.0.1` only, on a random port.
|
|
39
|
+
2. Every request must carry a secret that is made anew at each start and is
|
|
40
|
+
part of the address the helper prints; requests from other web sites are
|
|
41
|
+
refused (the helper also checks the `Host` and `Origin` headers).
|
|
42
|
+
3. Code runs only when you press **Run**, and only files inside the folder you
|
|
43
|
+
started `nodejs-map` in (or the text in the editor). Opening a recording or
|
|
44
|
+
a shared link never runs anything.
|
|
45
|
+
4. The debugger port of your program is bound to `127.0.0.1` and is never
|
|
46
|
+
given to the browser; the helper relays a short, fixed list of debugger
|
|
47
|
+
actions.
|
|
48
|
+
|
|
49
|
+
Your code, its output and your recordings stay on your machine. The page
|
|
50
|
+
makes one kind of request to the outside: when you open a code location, it
|
|
51
|
+
fetches that file of Node's own source from `raw.githubusercontent.com`,
|
|
52
|
+
because Node's source is not shipped in this package.
|
|
53
|
+
|
|
54
|
+
## Observed, inferred, model
|
|
55
|
+
|
|
56
|
+
Everything on screen says how it is known:
|
|
57
|
+
|
|
58
|
+
- **observed**: Node itself reported it (an `async_hooks` callback, a trace
|
|
59
|
+
event, the debugger);
|
|
60
|
+
- **inferred**: worked out from other signals by a rule, and the rule names the
|
|
61
|
+
places in Node's source it relies on;
|
|
62
|
+
- **model**: an illustration.
|
|
63
|
+
|
|
64
|
+
An inferred or modelled thing is never shown as observed. On a standard Node
|
|
65
|
+
build, for example, the timers and check phases of the event loop are
|
|
66
|
+
observed, the poll phase is inferred, and which thread-pool thread ran a job
|
|
67
|
+
is observed but arrives with a delay.
|
|
68
|
+
|
|
69
|
+
One more thing to know: at a breakpoint only JavaScript stops. The clock, the
|
|
70
|
+
thread pool and the operating system keep running, which can change what your
|
|
71
|
+
program does next. The paused view says so.
|
|
72
|
+
|
|
73
|
+
## What to expect from this first release
|
|
74
|
+
|
|
75
|
+
- Tested on Windows and Linux with Node.js 26.13.1. macOS has not been tested
|
|
76
|
+
yet.
|
|
77
|
+
- The map is built for Node.js v26.13.1. On another 26.x version the tool
|
|
78
|
+
still runs and says that the map was built for a different version.
|
|
79
|
+
- Watching a program slows it down. A small program takes about 0.2 s longer
|
|
80
|
+
from start to finish. Programs that create very many timers or promises are
|
|
81
|
+
slowed much more, because every one of them is recorded: a stress test with
|
|
82
|
+
100,000 chained promises took 1.6 s instead of 0.08 s.
|
|
83
|
+
- Worker threads run but are not shown.
|
|
84
|
+
- Stopping between event loop phases needs a patched build of Node, which is
|
|
85
|
+
not part of this package yet. On a standard build those controls are
|
|
86
|
+
visible and say why they are off.
|
|
87
|
+
|
|
88
|
+
## Requirements
|
|
89
|
+
|
|
90
|
+
- Node.js 26 or newer.
|
|
91
|
+
- A current desktop browser.
|
|
92
|
+
- No other dependencies; nothing is installed globally.
|
|
93
|
+
|
|
94
|
+
## Licence
|
|
95
|
+
|
|
96
|
+
MIT. Node.js source code is not included in this package: the map links to it.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
const e=[`cb.nextTick`,`cb.microtask`,`cb.timers`,`cb.immediate`,`cb.pool`,`cb.io`,`cb.close`,`cb.other`,`stdout`,`stderr`,`pause`,`pool`,`note`];var t=class{#e=[];#t=0;#n=!1;#r=/* @__PURE__ */ new Set;get events(){return this.#e}get length(){return this.#e.length}get version(){return this.#t}get status(){return this.#n?`ended`:this.#e.length===0?`empty`:`live`}get live(){return!this.#n&&this.#e.length>0}apply(e){let t=this.#e.length,n=typeof e!=`object`||!e?NaN:e.base,r=typeof e==`object`&&e&&Array.isArray(e.events)?e.events:null;if(!Number.isInteger(n)||n<0||r===null)return this.#i(`bad-base`);if(n>t)return this.#i(`gap`);let i=n,a=0;for(;i<t&&a<r.length&&this.#e[i]===r[a];)i++,a++;let o=i<t;if(!o&&a===r.length)return this.#a(t,t,!1,!1,!1);o&&(this.#e.length=i);for(let e=a;e<r.length;e++)this.#e.push(r[e]);return this.#a(i,t,o,!1,!0)}load(e){let t=this.#e.length;return this.#e=Array.isArray(e)?e.slice():[],this.#n=!0,this.#a(0,t,t>0,!0,!0)}end(){let e=this.#e.length;return this.#n?this.#a(e,e,!1,!1,!1):(this.#n=!0,this.#a(e,e,!1,!1,!0))}reset(){let e=this.#e.length;return this.#e=[],this.#n=!1,this.#a(0,e,e>0,!0,!0)}subscribe(e){return this.#r.add(e),()=>{this.#r.delete(e)}}#i(e){let t=this.#e.length;return{from:t,previousLength:t,length:t,truncated:!1,replaced:!1,status:this.status,version:this.#t,rejected:e}}#a(e,t,n,r,i){i&&this.#t++;let a={from:e,previousLength:t,length:this.#e.length,truncated:n,replaced:r,status:this.status,version:this.#t,rejected:null};if(i)for(let e of[...this.#r])e(a);return a}};const n=[`nextTick`,`microtask`,`timers`,`immediate`,`pool`,`io`,`close`],r=e=>Object.assign(Object.create(null),e),i=r({nextTick:0,microtask:1,timers:2,immediate:3,pool:4,io:5,close:6}),a=[null,`timers`,`pending`,`idle`,`prepare`,`poll`,`check`,`closing`],o=r({timers:1,pending:2,idle:3,prepare:4,poll:5,check:6,closing:7});function s(e){let t=typeof e==`string`?i[e]:void 0;return t===void 0?-1:t}function c(e){let t=typeof e==`string`?o[e]:void 0;return t===void 0?0:t}const l=/* @__PURE__ */ new Set([`loop.sample`,`signal`,`scope`,`pool.thread`,`promise.settled`,`item.new`,`item.gone`,`timer.set`,`pool.link`,`clock.frozen`,`clock.unfrozen`]),u=1024,d=e=>typeof e==`number`&&Number.isFinite(e),f=e=>typeof e==`number`&&Number.isInteger(e)&&e>=0,p=e=>typeof e==`string`,m=e=>typeof e==`object`&&!!e;function h(e){if(!m(e))return 2;let t=e;if(!p(t.k)||!d(t.t))return 2;let n=t.c;if(n!==`observed`&&n!==`inferred`&&n!==`model`||t.rule!==void 0&&!p(t.rule)||t.at!==void 0&&!p(t.at)||t.tid!==void 0&&!d(t.tid))return 2;switch(t.k){case`run.start`:return m(t.node)&&m(t.caps)&&p(t.mode)&&p(t.program)&&d(t.poolSize)?0:2;case`run.end`:return(t.code===null||t.code===void 0||d(t.code))&&(t.signal===null||t.signal===void 0||p(t.signal))?0:2;case`output`:return(t.stream===`stdout`||t.stream===`stderr`)&&p(t.text)?0:2;case`item.new`:{let e=t.loc;return f(t.id)&&p(t.type)&&f(t.trigger)&&(t.label===void 0||p(t.label))&&(e===void 0||m(e)&&p(e.url)&&d(e.line))?0:2}case`callback.start`:return f(t.id)&&p(t.type)?0:2;case`callback.end`:case`item.gone`:case`promise.settled`:return f(t.id)?0:2;case`timer.set`:return f(t.id)&&d(t.delayMs)&&typeof t.repeat==`boolean`?0:2;case`loop.sample`:return d(t.loopCount)&&d(t.events)&&d(t.eventsWaiting)?0:2;case`scope`:return p(t.name)&&d(t.durUs)?0:2;case`pool.thread`:return(t.edge===`start`||t.edge===`end`)&&p(t.name)?0:2;case`signal`:return p(t.cat)&&p(t.name)&&p(t.ph)?0:2;case`queue.add`:case`queue.remove`:return s(t.queue)>=0&&f(t.id)?0:2;case`loop.turn`:return d(t.n)?0:2;case`phase.enter`:case`phase.leave`:return c(t.phase)>0&&(t.turn===void 0||d(t.turn))&&(t.afterPoll===void 0||typeof t.afterPoll==`boolean`)&&(t.pollTimeoutMs===void 0||d(t.pollTimeoutMs))?0:2;case`timer.fired`:return t.lateMs===void 0||d(t.lateMs)?0:2;case`pool.queued`:return p(t.job)&&p(t.kind)&&(t.op===void 0||p(t.op))&&(t.id===void 0||f(t.id))?0:2;case`pool.delivered`:case`pool.cancelled`:return p(t.job)?0:2;case`pool.started`:case`pool.finished`:case`pool.posted`:return p(t.job)&&f(t.thread)&&t.thread>=1&&t.thread<=u?0:2;case`pool.link`:return p(t.job)&&f(t.id)?0:2;case`pool.size`:return f(t.size)&&t.size>=1&&t.size<=u?0:2;case`debug.paused`:return p(t.reason)&&Array.isArray(t.frames)&&typeof t.timeKeptRunning==`boolean`?0:2;case`debug.resumed`:return d(t.pausedMs)?0:2;case`gate.stopped`:return p(t.gate)&&(t.job===void 0||p(t.job))&&(t.phase===void 0||c(t.phase)>0)?0:2;case`gate.released`:return d(t.stoppedMs)?0:2;case`clock.frozen`:return t.why===void 0||p(t.why)?0:2;case`clock.unfrozen`:return d(t.hiddenMs)?0:2;case`note`:return(t.level===`info`||t.level===`warn`)&&p(t.text)?0:2;default:return 1}}function g(e,t){let n=e.length;if(n<=16){for(;n>0&&e[n-1]>=t;)n--;return n}let r=0;for(;r<n;){let i=r+n>>>1;e[i]<t?r=i+1:n=i}return r}function _(e,t){let n=g(e,t);return n===0?-1:e[n-1]}function v(e,t){return{c:e.c,rule:e.rule===void 0?null:e.rule,index:t,t:e.t}}const ee={observed:0,inferred:1,model:2};function y(e,t){return ee[e]>=ee[t]?e:t}var b=class{n=0;flags=/* @__PURE__ */ new Uint8Array(1024);blockFlags=/* @__PURE__ */ new Uint8Array(4);tMono=/* @__PURE__ */ new Float64Array(1024);tlState=/* @__PURE__ */ new Uint8Array(1024);tlClass=/* @__PURE__ */ new Uint8Array(1024);items=/* @__PURE__ */ new Map;order=[];output=[];outputChars=[];notes=[];turns=[];turnNumbers=[];pauses=[];#e=null;#t=null;#n=[];#r=[];#i(){let e=this.flags.length*2,t=t=>{let n=new Uint8Array(e);return n.set(t),n};this.flags=t(this.flags);let n=new Uint8Array(e>>8);n.set(this.blockFlags),this.blockFlags=n,this.tlState=t(this.tlState),this.tlClass=t(this.tlClass);let r=new Float64Array(e);r.set(this.tMono),this.tMono=r}#a(e,t){this.#n.push(t),this.#r.push(e.id)}#o(e,t,n){let r=this.items.get(e);return r===void 0?(r={id:e,ref:{id:e,type:n,label:null,trigger:0,loc:null,created:null},early:null,newIndex:-1,firstIndex:t,starts:[],ends:[],goneIndex:-1,settledIndex:-1,children:[],jobNames:[],jobIndexes:[],timer:null},this.items.set(e,r),this.order.push(r),this.#a(r,t)):n!==`?`&&r.newIndex<0&&r.ref.type===`?`&&(r.ref={...r.ref,type:n}),r}add(e,t){t>=this.flags.length&&this.#i();let n=t===0?0:this.tMono[t-1];this.tlState[t]=0,this.tlClass[t]=0;let r=h(e);if(r!==0){let i=r===1?192:64;this.flags[t]=i,t&255?this.blockFlags[t>>8]=this.blockFlags[t>>8]|i:this.blockFlags[t>>8]=i;let a=r===1?e.t:n;return this.tMono[t]=t===0||a>n?a:n,this.n=t+1,i}this.tMono[t]=t===0||e.t>n?e.t:n;let i=+!l.has(e.k);switch(e.k){case`item.new`:{let n={id:e.id,type:e.type,label:e.label===void 0?null:e.label,trigger:e.trigger,loc:e.loc===void 0?null:e.loc,created:v(e,t)},r=this.items.get(e.id);if(r===void 0){let r=this.#o(e.id,t,e.type);r.ref=n,r.newIndex=t;let i=this.items.get(e.trigger);i!==void 0&&i!==r&&(i.children.push(t),this.#a(i,t))}else if(r.newIndex<0){r.early=r.ref,r.ref=n,r.newIndex=t,this.#a(r,t);let i=this.items.get(e.trigger);i!==void 0&&i!==r&&(i.children.push(t),this.#a(i,t))}break}case`callback.start`:{let n=this.#o(e.id,t,e.type);n.starts.push(t),this.#a(n,t),i|=2;break}case`callback.end`:{let n=this.#o(e.id,t,`?`);n.ends.push(t),this.#a(n,t);break}case`item.gone`:{let n=this.#o(e.id,t,`?`);n.goneIndex<0&&(n.goneIndex=t);let r=n.timer;r!==null&&r.clearedIndex<0&&r.arms[r.arms.length-1]>x(n.starts)&&(r.clearedIndex=t),this.#a(n,t);break}case`promise.settled`:{let n=this.#o(e.id,t,`?`);n.settledIndex<0&&(n.settledIndex=t),this.#a(n,t);break}case`timer.set`:{let n=this.#o(e.id,t,`?`);n.timer===null?n.timer={setIndex:t,delayMs:e.delayMs,repeat:e.repeat,arms:[t],clearedIndex:-1}:n.timer.arms.push(t),this.#a(n,t);break}case`queue.add`:{let n=this.#o(e.id,t,`?`),r=n.timer;e.queue===`timers`&&r!==null&&r.clearedIndex<0&&x(n.starts)>r.arms[r.arms.length-1]&&(r.arms.push(t),this.#a(n,t));break}case`queue.remove`:{let n=this.items.get(e.id),r=n===void 0?null:n.timer;n!==void 0&&r!==null&&e.queue===`timers`&&r.clearedIndex<0&&(r.repeat||r.arms[r.arms.length-1]>x(n.starts))&&(r.clearedIndex=t,this.#a(n,t));break}case`pool.queued`:e.id!==void 0&&this.#s(e.id,e.job,t);break;case`pool.link`:this.#s(e.id,e.job,t);break;case`output`:{let n=this.outputChars.length===0?0:this.outputChars[this.outputChars.length-1];this.output.push({seq:this.output.length,index:t,t:e.t,stream:e.stream,text:e.text}),this.outputChars.push(n+e.text.length),i|=16;break}case`note`:this.notes.push(t);break;case`loop.turn`:this.turns.push(t),this.turnNumbers.push(e.n),i|=8;break;case`phase.enter`:i|=4;break;case`debug.paused`:{let n={kind:`debug`,index:t,t:e.t,endIndex:null,ms:null,reason:e.reason,timeKeptRunning:e.timeKeptRunning};this.pauses.push(n),this.#e=n,i|=32;break}case`debug.resumed`:this.#e!==null&&(this.#e.endIndex=t,this.#e.ms=e.pausedMs,this.#e=null);break;case`gate.stopped`:{let n={kind:`gate`,index:t,t:e.t,endIndex:null,ms:null,reason:e.gate,timeKeptRunning:!1};this.pauses.push(n),this.#t=n,i|=32;break}case`gate.released`:this.#t!==null&&(this.#t.endIndex=t,this.#t.ms=e.stoppedMs,this.#t=null)}return this.flags[t]=i,t&255?this.blockFlags[t>>8]=this.blockFlags[t>>8]|i:this.blockFlags[t>>8]=i,this.n=t+1,i}nextWith(e,t){let n=this.flags,r=this.blockFlags,i=this.n,a=Math.max(0,t);for(;a<i;){if((r[a>>8]&e)===0){a=(a>>8)+1<<8;continue}let t=Math.min(i,(a>>8)+1<<8);for(;a<t;a++)if((n[a]&e)!==0)return a}return-1}previousWith(e,t){let n=this.flags,r=this.blockFlags,i=Math.min(this.n-1,t);for(;i>=0;){if((r[i>>8]&e)===0){i=(i>>8<<8)-1;continue}let t=i>>8<<8;for(;i>=t;i--)if((n[i]&e)!==0)return i}return-1}#s(e,t,n){let r=this.#o(e,n,`?`);r.jobNames.push(t),r.jobIndexes.push(n),this.#a(r,n)}truncate(e){if(e>=this.n)return;let t=this.#n,n=this.#r;for(;t.length>0&&t[t.length-1]>=e;){t.pop();let r=this.items.get(n.pop());if(r===void 0)continue;if(r.firstIndex>=e){this.items.delete(r.id);continue}r.newIndex>=e&&(r.ref=r.early,r.early=null,r.newIndex=-1),S(r.starts,e),S(r.ends,e),S(r.children,e);let i=g(r.jobIndexes,e);r.jobIndexes.length=i,r.jobNames.length=i,r.goneIndex>=e&&(r.goneIndex=-1),r.settledIndex>=e&&(r.settledIndex=-1);let a=r.timer;a!==null&&(a.setIndex>=e?r.timer=null:(S(a.arms,e),a.clearedIndex>=e&&(a.clearedIndex=-1)))}let r=this.order;for(;r.length>0&&r[r.length-1].firstIndex>=e;)r.pop();for(;this.output.length>0&&this.output[this.output.length-1].index>=e;)this.output.pop(),this.outputChars.pop();S(this.notes,e);let i=g(this.turns,e);this.turns.length=i,this.turnNumbers.length=i;let a=this.pauses;for(;a.length>0&&a[a.length-1].index>=e;)a.pop();if(this.#e=this.#c(`debug`,e),this.#t=this.#c(`gate`,e),e&255){let t=0;for(let n=e&-256;n<e;n++)t|=this.flags[n];this.blockFlags[e>>8]=t}this.n=e}#c(e,t){for(let n=this.pauses.length-1;n>=0;n--){let r=this.pauses[n];if(r.kind===e)return r.endIndex!==null&&r.endIndex>=t&&(r.endIndex=null,r.ms=null),r.endIndex===null?r:null}return null}itemsBefore(e){let t=this.order,n=0,r=t.length;for(;n<r;){let i=n+r>>>1;t[i].firstIndex<e?n=i+1:r=i}return n}refAt(e,t){return e.newIndex>=0&&e.newIndex>=t&&e.early!==null?e.early:e.ref}timerStateAt(e,t,n){let r=e.timer;return r===null||r.setIndex>=t?0:r.clearedIndex>=0&&r.clearedIndex<t?4:n?2:_(r.arms,t)>_(e.starts,t)?1:3}};function x(e){return e.length===0?-1:e[e.length-1]}function S(e,t){let n=e.length;for(;n>0&&e[n-1]>=t;)n--;e.length=n}var C=class extends Error{line;constructor(e,t){super(t===void 0?e:`line ${t}: ${e}`),this.name=`RecordingError`,this.line=t}};const w={text:1e6,name:512,frames:200,args:32,sources:64};function T(e,t){throw new C(`${e}: ${t}`)}const E=e=>(t,n)=>(typeof t!=`string`&&T(n,`must be a string`),t.length>e&&T(n,`string longer than ${e}`),t),D=E(w.name),te=E(w.text),O=(e,t)=>(typeof e==`number`&&Number.isFinite(e)||T(t,`must be a finite number`),e),k=(e,t)=>(O(e,t),e<0&&T(t,`must not be negative`),e),ne=(e,t)=>(typeof e==`number`&&Number.isSafeInteger(e)||T(t,`must be an integer`),e),re=(e,t)=>((typeof e!=`number`||!Number.isInteger(e)||e<1||e>1024)&&T(t,`must be a whole number from 1 to 1024`),e),A=(e,t)=>(ne(e,t),e<0&&T(t,`must not be negative`),e),j=(e,t)=>(typeof e!=`boolean`&&T(t,`must be true or false`),e),M=(...e)=>(t,n)=>(typeof t==`string`&&e.includes(t)||T(n,`must be one of ${e.join(`, `)}`),t),ie=e=>(t,n)=>t===null?null:e(t,n),N=e=>({check:e}),P=e=>({check:e,optional:!0});function ae(e){if(typeof e!=`object`||!e||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function F(e,t,n,r){ae(t)||T(n,`must be an object`);let i={};for(let i of Object.keys(t))!Object.hasOwn(e,i)&&!(r&&r.has(i))&&T(n,`unknown field "${i}"`);for(let r of Object.keys(e)){let a=e[r],o=Object.hasOwn(t,r)?t[r]:void 0;o===void 0?a.optional||T(n,`missing field "${r}"`):i[r]=a.check(o,n===``?r:`${n}.${r}`)}return i}const I=e=>(t,n)=>F(e,t,n),oe={url:N(D),line:N(A),col:P(A)},se={fn:N(D),loc:N(I(oe)),origin:N(M(`user`,`node`,`other`)),at:P(D)},ce={version:N(D),v8:N(D),uv:N(D),platform:N(D),arch:N(D)},le=M(`observed`,`inferred`,`model`),ue={provider:N(M(`user`,`pinned`,`probe`)),jsDebugger:N(j),asyncItems:N(j),poolThreads:N(M(`delayed`,`live`,`none`)),phasesTimersCheck:N(M(`observed`,`inferred`,`model`,`none`)),phasesOther:N(M(`observed`,`inferred`,`model`,`none`)),gates:N(I({phase:N(j),timer:N(j),poolStart:N(j),poolPost:N(j)})),frozenClock:N(j)},de=M(`timers`,`pending`,`idle`,`prepare`,`poll`,`check`,`closing`),fe=M(`nextTick`,`microtask`,`timers`,`immediate`,`pool`,`io`,`close`),pe=(e,t)=>(Array.isArray(e)||T(t,`must be a list`),e.length>w.frames&&T(t,`more than ${w.frames} frames`),e.map((e,n)=>F(se,e,`${t}[${n}]`))),me=(e,t)=>{ae(e)||T(t,`must be an object`);let n=Object.keys(e);n.length>w.args&&T(t,`more than ${w.args} keys`);let r=Object.create(null);for(let i of n){i.length>w.name&&T(t,`key too long`);let n=e[i];n===null||typeof n==`boolean`||typeof n==`number`&&Number.isFinite(n)||typeof n==`string`&&n.length<=w.text?r[i]=n:T(`${t}.${i}`,`must be a string, a finite number, true, false or null`)}return Object.assign({},r)},he={k:N(D),t:N(O),tq:P(M(`approx`,`tie`)),src:N(M(`hooks`,`trace`,`cdp`,`probe`,`helper`,`rule`)),c:N(le),rule:P(E(32)),at:P(D),tid:P(A)},ge={"run.start":{node:N(I(ce)),caps:N(I(ue)),mode:N(M(`free`,`debug`)),program:N(D),poolSize:N(A)},"run.end":{code:N(ie(ne)),signal:N(ie(D))},output:{stream:N(M(`stdout`,`stderr`)),text:N(te)},"item.new":{id:N(A),type:N(D),trigger:N(A),label:P(D),loc:P(I(oe))},"callback.start":{id:N(A),type:N(D),close:P(j)},"callback.end":{id:N(A)},"item.gone":{id:N(A)},"promise.settled":{id:N(A)},"timer.set":{id:N(A),delayMs:N(k),repeat:N(j)},"loop.sample":{loopCount:N(A),events:N(A),eventsWaiting:N(A)},scope:{name:N(D),durUs:N(k)},"pool.thread":{edge:N(M(`start`,`end`)),name:N(D)},signal:{cat:N(D),name:N(D),ph:N(E(8)),ref:P(D),args:P(me)},"queue.add":{queue:N(fe),id:N(A)},"queue.remove":{queue:N(fe),id:N(A),why:N(M(`cancel`,`gone`))},"loop.turn":{n:N(A)},"phase.enter":{phase:N(de),turn:P(A),afterPoll:P(j),pollTimeoutMs:P(O)},"phase.leave":{phase:N(de),turn:P(A),afterPoll:P(j)},"timer.fired":{lateMs:P(O)},"pool.queued":{job:N(D),kind:N(M(`fs`,`dns`,`crypto`,`zlib`,`user`,`unknown`)),op:P(D),id:P(A)},"pool.started":{job:N(D),thread:N(A)},"pool.finished":{job:N(D),thread:N(A)},"pool.posted":{job:N(D),thread:N(A)},"pool.delivered":{job:N(D)},"pool.cancelled":{job:N(D)},"pool.link":{job:N(D),id:N(A)},"pool.size":{size:N(re)},"debug.paused":{reason:N(M(`breakpoint`,`step`,`pause`,`exception`,`entry`,`other`)),frames:N(pe),timeKeptRunning:N(j)},"debug.resumed":{pausedMs:N(k)},"gate.stopped":{gate:N(M(`phase`,`turn`,`timer`,`poolStart`,`poolPost`,`poolDone`,`manual`)),phase:P(de),job:P(D)},"gate.released":{stoppedMs:N(k)},"clock.frozen":{why:P(M(`gate`,`breakpoint`))},"clock.unfrozen":{hiddenMs:N(k)},note:{level:N(M(`info`,`warn`)),text:N(E(2e3))}},_e=new Set(Object.keys(ge)),ve=/* @__PURE__ */ new Map;for(let e of Object.keys(ge))ve.set(e,{...he,...ge[e]});function ye(e){return typeof e==`string`&&_e.has(e)}function be(e){if(!ae(e))throw new C(`an event must be an object`);let t=e.k;if(!ye(t))throw new C(`unknown event kind ${typeof t==`string`?JSON.stringify(t.slice(0,60)):typeof t}`);let n=F(ve.get(t),e,t);if(n.c!==`observed`&&typeof n.rule!=`string`)throw new C(`${t}: an ${String(n.c)} event must name its rule`);return n}const xe={format:N(M(`nodejs-map-recording`)),version:N(A),created:N(E(64)),tool:N(E(64)),node:N(I(ce)),atlas:N(I({tag:N(E(64)),commit:N(E(64))})),title:P(D),description:P(E(4e3)),sources:P((e,t)=>(Array.isArray(e)||T(t,`must be a list`),e.length>w.sources&&T(t,`more than ${w.sources} sources`),e.map((e,n)=>F({name:N(D),text:N(te)},e,`${t}[${n}]`))))};function Se(e){let t=F(xe,e,`header`);if(t.version>1)throw new C(`this recording is format version ${t.version}; this reader understands up to 1`);if(t.version<1)throw new C(`header.version: must be 1 or more`);if(Number.isNaN(Date.parse(t.created)))throw new C(`header.created: not a date`);return t}const Ce=4e6,we=/^[A-Za-z][A-Za-z0-9]{0,31}:[ifbnsj]$/,Te=/* @__PURE__ */ new Set([`k`,`t`,`src`,`c`,`constructor`,`prototype`]);function Ee(e){switch(typeof e){case`number`:return Number.isSafeInteger(e)?`i`:`f`;case`string`:return`s`;case`boolean`:return`b`;default:return e===null?`n`:`j`}}var De=class{#e=/* @__PURE__ */ new Map;#t=/* @__PURE__ */ new Map;#n=0;header(e){return JSON.stringify(Se(e))+`
|
|
2
|
+
`}events(e){let t=[];for(let n of e)this.#i(n,t);return t.join(``)}#r(e,t){let n=this.#t.get(e);return n===void 0&&(n=this.#t.size,this.#t.set(e,n),t.push(`["s",`+JSON.stringify(e)+`]
|
|
3
|
+
`)),n}#i(e,t){let n=`${String(e.k)}|${String(e.src)}|${String(e.c)}`,r=[],i=[];for(let t of Object.keys(e)){if(t===`k`||t===`t`||t===`src`||t===`c`)continue;let a=e[t];if(a===void 0)continue;let o=Ee(a);r.push(t),i.push(o),n+=`|${t}:${o}`}let a=this.#e.get(n);a===void 0&&(a={index:this.#e.size,names:r,types:i},this.#e.set(n,a),t.push(JSON.stringify([`d`,e.k,e.src,e.c,r.map((e,t)=>`${e}:${i[t]}`)])+`
|
|
4
|
+
`));let o=e.t;if(typeof o!=`number`||!Number.isFinite(o))throw new C(`${String(e.k)}: t must be a finite number`);let s=Math.round(o*1e3),c=`[${a.index},${s-this.#n}`;this.#n=s;for(let n=0;n<r.length;n++){let a=e[r[n]];switch(i[n]){case`i`:case`f`:c+=`,`+String(a);break;case`b`:c+=a?`,1`:`,0`;break;case`n`:c+=`,0`;break;case`s`:c+=`,`+this.#r(a,t);break;default:c+=`,`+this.#r(JSON.stringify(a),t)}}t.push(c+`]
|
|
5
|
+
`)}};function Oe(e){let t=new De;return t.header({...e.header,version:1})+t.events(e.events)}var ke=class{#e=``;#t=0;#n;#r=[];#i=[];#a=0;#o=0;get header(){return this.#n}get count(){return this.#o}push(e){let t=[],n=this.#e+e,r=0;for(;;){let e=n.indexOf(`
|
|
6
|
+
`,r);if(e<0)break;this.#s(n.slice(r,e),t),r=e+1}if(n=n.slice(r),n.length>Ce)throw new C(`line too long`,this.#t+1);return this.#e=n,t}finish(){let e=[],t=this.#e;if(this.#e=``,t.trim()!==``&&this.#s(t,e),this.#n===void 0)throw new C(`empty recording: no header line`);return e}#s(e,t){this.#t++;let n=e.endsWith(`\r`)?e.slice(0,-1):e;if(n.length>Ce)throw new C(`line too long`,this.#t);if(n===``){if(this.#n===void 0)throw new C(`the first line must be the header`,this.#t);return}let r;try{r=JSON.parse(n)}catch{throw new C(`not valid JSON`,this.#t)}try{if(this.#n===void 0){this.#n=Se(r);return}if(!Array.isArray(r)||r.length<2)throw new C(`expected a definition or an event row`);let e=r[0];if(e===`s`)this.#c(r);else if(e===`d`)this.#l(r);else if(typeof e==`number`)t.push(this.#d(r)),this.#o++;else throw new C(`unknown line type`)}catch(e){throw e instanceof C&&e.line===void 0?new C(e.message,this.#t):e}}#c(e){if(e.length!==2||typeof e[1]!=`string`)throw new C(`bad string definition`);if(this.#i.length>=4e6)throw new C(`too many strings`);this.#i.push(e[1])}#l(e){let[,t,n,r,i]=e;if(e.length!==5||typeof t!=`string`||typeof n!=`string`||typeof r!=`string`||!Array.isArray(i))throw new C(`bad shape definition`);if(this.#r.length>=8192)throw new C(`too many shapes`);if(i.length>32)throw new C(`too many fields in a shape`);let a=[],o=[];for(let e of i){if(typeof e!=`string`||!we.test(e))throw new C(`bad field in a shape`);let t=e.lastIndexOf(`:`),n=e.slice(0,t);if(Te.has(n)||a.includes(n))throw new C(`field "${n}" not allowed in a shape`);a.push(n),o.push(e.slice(t+1))}this.#r.push({k:t,src:n,c:r,names:a,types:o})}#u(e){if(typeof e!=`number`||!Number.isInteger(e)||e<0||e>=this.#i.length)throw new C(`string number out of range`);return this.#i[e]}#d(e){let t=e[0],n=Number.isInteger(t)&&t>=0?this.#r[t]:void 0;if(n===void 0)throw new C(`shape number out of range`);let r=e[1];if(typeof r!=`number`||!Number.isSafeInteger(r))throw new C(`bad time delta`);if(e.length!==n.names.length+2)throw new C(`wrong number of values for the shape`);if(this.#a+=r,!Number.isSafeInteger(this.#a))throw new C(`time out of range`);let i={k:n.k,t:this.#a/1e3,src:n.src,c:n.c};for(let t=0;t<n.names.length;t++){let r=e[t+2],a;switch(n.types[t]){case`i`:case`f`:if(typeof r!=`number`)throw new C(`expected a number`);a=r;break;case`b`:if(r!==0&&r!==1)throw new C(`expected 0 or 1`);a=r===1;break;case`n`:a=null;break;case`s`:a=this.#u(r);break;default:try{a=JSON.parse(this.#u(r))}catch(e){throw e instanceof C?e:new C(`bad JSON value`)}}i[n.names[t]]=a}return be(i)}};function Ae(e){let t=new ke,n=t.push(e);for(let e of t.finish())n.push(e);return{header:t.header,events:n}}const L={callbackScopeCtor:`o:cb.InternalMakeCallback`,callbackScopeClose:`s:src/api/callback.cc#node::InternalCallbackScope::Close`,runTimers:`s:src/env.cc#node::Environment::RunTimers`,scheduleTimer:`s:src/env.cc#node::Environment::ScheduleTimer`,checkImmediate:`s:src/env.cc#node::Environment::CheckImmediate`,toggleImmediateRef:`s:src/env.cc#node::Environment::ToggleImmediateRef`,uvRunTimers:`s:deps/uv/src/timer.c#uv__run_timers`,processTimers:`s:lib/internal/timers.js#getTimerCallbacks/processTimers`,listOnTimeout:`o:timers.listOnTimeout`,processImmediate:`s:lib/internal/timers.js#getTimerCallbacks/processImmediate`,timeoutCtor:`s:lib/internal/timers.js#Timeout.prototype.constructor`,immediateCtor:`s:lib/internal/timers.js#Immediate.prototype.constructor`,timerInsert:`s:lib/internal/timers.js#insert`,nextTick:`s:lib/internal/process/task_queues.js#nextTick`,processTicks:`s:lib/internal/process/task_queues.js#processTicksAndRejections`,queueMicrotask:`s:lib/internal/process/task_queues.js#queueMicrotask`,runMicrotask:`s:lib/internal/process/task_queues.js#runMicrotask`,promiseInitHook:`s:lib/internal/async_hooks.js#promiseInitHook`,promiseBeforeHook:`s:lib/internal/async_hooks.js#promiseBeforeHook`,uvRunUnix:`s:deps/uv/src/unix/core.c#uv_run`,uvRunWin:`s:deps/uv/src/win/core.c#uv_run`,uvPollWin:`s:deps/uv/src/win/core.c#uv__poll`,uvProcessReqs:`s:deps/uv/src/win/core.c#uv__process_reqs`,uvIoPollLinux:`s:deps/uv/src/unix/linux.c#uv__io_poll`,uvAsyncIo:`s:deps/uv/src/unix/async.c#uv__async_io`,uvAsyncWakeupWin:`s:deps/uv/src/win/async.c#uv__process_async_wakeup_req`,worker:`s:deps/uv/src/threadpool.c#worker`,post:`s:deps/uv/src/threadpool.c#post`,workSubmit:`s:deps/uv/src/threadpool.c#uv__work_submit`,workDone:`s:deps/uv/src/threadpool.c#uv__work_done`,initThreads:`s:deps/uv/src/threadpool.c#init_threads`,scheduleWork:`s:src/threadpoolwork-inl.h#node::ThreadPoolWork::ScheduleWork`,fsWorkUnix:`s:deps/uv/src/unix/fs.c#uv__fs_work`,fsWorkWin:`s:deps/uv/src/win/fs.c#uv__fs_work`,getaddrinfoUnix:`s:deps/uv/src/unix/getaddrinfo.c#uv_getaddrinfo`,getaddrinfoWin:`s:deps/uv/src/win/getaddrinfo.c#uv_getaddrinfo`,uvMetricsInfo:`s:src/node_perf.cc#node::performance::UvMetricsInfo`,queryResponse:`s:src/cares_wrap.h#node::cares_wrap::QueryWrap::QueueResponseCallback`,handleOnClose:`s:src/handle_wrap.cc#node::HandleWrap::OnClose`,closingUnix:`s:deps/uv/src/unix/core.c#uv__run_closing_handles`,closingWin:`s:deps/uv/src/win/core.c#uv__process_endgames`,ioFeed:`s:deps/uv/src/unix/core.c#uv__io_feed`,runPending:`s:deps/uv/src/unix/core.c#uv__run_pending`,streamIo:`s:deps/uv/src/unix/stream.c#uv__stream_io`,writeReqFinish:`s:deps/uv/src/unix/stream.c#uv__write_req_finish`,shutdownUnix:`s:deps/uv/src/unix/stream.c#uv_shutdown`},R={phaseTimers:`o:phase.timers`,phasePending:`o:phase.pending`,phasePoll:`o:phase.poll`,phaseCheck:`o:phase.check`,tickDrain:`o:tick.drain`,microtaskDrain:`o:microtask.run`,promiseReactionEnqueue:`o:v8.enqueueMicrotask`,promiseReactionRun:`o:v8.promiseReactionJob`,performPromiseThen:`o:v8.performPromiseThen`,triggerReactions:`o:v8.triggerReactions`,poolSubmit:`o:pool.submit`,poolWorker:`o:pool.worker`,poolDone:`o:pool.done`,makeCallback:`o:cb.InternalMakeCallback`,uvRun:`o:loop.run`,dnsQueryResponse:`o:dns.queryResponse`,nativeImmediatesRun:`o:immediate.native`,shutdownQueue:`o:uv.shutdown`,shutdownRun:`o:uv.shutdownDone`,closeCallbacks:`o:loop.finishClose`,handleOnClose:`o:cb.handleOnClose`},je=[{id:`C0`,title:`A callback started or ended`,statement:`Node calls the async_hooks "before" hook just before it runs the JavaScript callback of an async item and "after" when the callback has returned. We report these two moments as they are.`,yields:`observed`,platform:`all`,cites:[L.callbackScopeCtor,L.callbackScopeClose,L.listOnTimeout,L.processImmediate,L.processTicks]},{id:`T0`,title:`The timers phase ran timer callbacks`,statement:`Node reports a timed scope named RunTimers each time libuv's timers step calls Node's one timer. From its start to its end the loop is in the timers phase and is running due setTimeout and setInterval callbacks.`,yields:`observed`,platform:`all`,cites:[L.runTimers,L.uvRunTimers,L.scheduleTimer,R.phaseTimers]},{id:`T1`,title:`A timer callback implies the timers phase`,statement:`A callback of an item of type Timeout started and no RunTimers scope has been reported for that moment (trace events arrive later than hooks). Timeout callbacks are only ever run by processTimers, which libuv calls in its timers step, so the loop is in the timers phase.`,yields:`inferred`,platform:`all`,cites:[L.processTimers,L.listOnTimeout,L.runTimers,R.phaseTimers]},{id:`T2`,title:`A timer callback inside a reported timers scope`,statement:`A Timeout callback started between the start and the end of a RunTimers scope that Node reported. Both facts are observed, so this callback ran in the timers phase.`,yields:`observed`,platform:`all`,cites:[L.runTimers,L.listOnTimeout]},{id:`I0`,title:`The check phase ran`,statement:`Node reports a timed scope named CheckImmediate from the callback of a libuv check handle that is always active. It runs once in every loop turn, in the check phase, whether or not the program used setImmediate.`,yields:`observed`,platform:`all`,cites:[L.checkImmediate,R.phaseCheck]},{id:`I1`,title:`An immediate callback implies the check phase`,statement:`A callback of an item of type Immediate started and no CheckImmediate scope has been reported for that moment. Immediate callbacks are only run by processImmediate, which Node calls from the check phase.`,yields:`inferred`,platform:`all`,cites:[L.processImmediate,L.checkImmediate,R.phaseCheck]},{id:`I2`,title:`An immediate callback inside a reported check scope`,statement:`An Immediate callback started between the start and the end of a CheckImmediate scope that Node reported.`,yields:`observed`,platform:`all`,cites:[L.checkImmediate,L.processImmediate]},{id:`P1u`,title:`A thread pool result is delivered inside the poll step (Linux, macOS)`,statement:`A callback of a thread-pool-backed item (file system, dns.lookup, crypto, zlib) started outside the timers and check phases. On Unix a finished job wakes the loop through an async handle, and libuv runs the callback from uv__io_poll, so the loop is in the poll phase.`,yields:`inferred`,platform:`unix`,cites:[L.uvRunUnix,L.uvIoPollLinux,L.uvAsyncIo,L.workDone,R.phasePoll]},{id:`P1w`,title:`A thread pool result is delivered after the poll step (Windows)`,statement:`A callback of a thread-pool-backed item started outside the timers and check phases. On Windows uv__poll only collects finished requests; their callbacks run in uv__process_reqs, which uv_run calls right after the poll and again at the top of the next turn. We show this as the pending step.`,yields:`inferred`,platform:`win32`,cites:[L.uvRunWin,L.uvPollWin,L.uvProcessReqs,L.uvAsyncWakeupWin,L.workDone,R.phasePending]},{id:`P2`,title:`A handle callback that is not its close callback is delivered by the poll step`,statement:`A callback of a handle (TCP socket or server, pipe, terminal, UDP socket, child process, signal, file watcher) started outside the timers and check phases, and the helper saw that it is not the handle's close callback (rule CL1). Data, connections and other events of a handle are read in the poll step: on Unix libuv calls back from there; on Windows uv__poll only collects them and the callbacks run in uv__process_reqs right after, which we show as the pending step after the poll. On Windows the same holds for write, shutdown, connect and send requests. No phase is inferred, rather than a wrong one, in these cases: write, shutdown, connect and send requests on Unix (libuv finishes them from uv__stream_io in the poll step when data was still waiting to be written, and otherwise queues the stream with uv__io_feed so that the callback runs in a pending pass: a shutdown with no write waiting runs in the pending step, one behind queued writes in the poll step, and the type does not say which); message ports and every other kind of item, whose callbacks can be made from several steps; a handle whose close state the helper could not read.`,yields:`inferred`,platform:`all`,cites:[L.uvRunUnix,L.uvRunWin,L.uvProcessReqs,L.streamIo,L.ioFeed,L.runPending,L.writeReqFinish,L.shutdownUnix,R.shutdownQueue,R.shutdownRun,R.phasePoll,R.phasePending]},{id:`CL1`,title:`A handle's close callback runs in the closing step`,statement:`A callback of a handle started, and the handle object carries the property Node sets when close(callback) is called (handle_onclose). After close() the handle gets no other callback, so this one is the close callback: libuv makes it in the closing step at the end of the turn (uv__run_closing_handles on Unix, uv__process_endgames on Windows), and Node passes it on from HandleWrap::OnClose.`,yields:`inferred`,platform:`all`,cites:[L.handleOnClose,L.closingUnix,L.closingWin,L.uvRunUnix,L.uvRunWin,R.handleOnClose,R.closeCallbacks]},{id:`I3`,title:`A dns.resolve answer is delivered in the check phase`,statement:`A callback of a QUERYWRAP item (dns.resolve and its relatives, answered by c-ares) started outside a reported scope. Node does not call back when the answer arrives on the socket: QueryWrap::QueueResponseCallback defers it with SetImmediate, so it runs with the native immediates in the check phase, on every system.`,yields:`inferred`,platform:`all`,cites:[L.queryResponse,L.checkImmediate,R.dnsQueryResponse,R.nativeImmediatesRun,R.phaseCheck]},{id:`K1`,title:`A nextTick callback ran from the tick queue`,statement:`A callback of an item of type TickObject started. process.nextTick creates exactly one TickObject per call and processTicksAndRejections runs them in order when the current callback scope closes, before the loop continues.`,yields:`inferred`,platform:`all`,cites:[L.nextTick,L.processTicks,L.callbackScopeClose,R.tickDrain]},{id:`M1`,title:`A microtask ran`,statement:`A callback of an item of type PROMISE or Microtask started. Promise reactions and queueMicrotask callbacks are jobs on V8's microtask queue, drained after the nextTick queue and whenever a callback scope closes.`,yields:`inferred`,platform:`all`,cites:[L.promiseBeforeHook,L.runMicrotask,L.processTicks,L.callbackScopeClose,R.microtaskDrain,R.promiseReactionRun]},{id:`L1`,title:`Loop counters`,statement:`performance.nodeTiming.uvMetricsInfo returns libuv's own counters. loopCount is increased once per turn, just before the poll step. We read it when a top-level callback starts, so the value is exact but the moment a turn began is not known from it.`,yields:`observed`,platform:`all`,cites:[L.uvMetricsInfo,L.uvRunUnix,L.uvRunWin]},{id:`L2`,title:`Loop turns from the check phase`,statement:`CheckImmediate is reported once per loop turn (rule I0). The timers step that follows it belongs to the same turn. The first callback or scope after that starts the next turn; we place the turn boundary there.`,yields:`inferred`,platform:`all`,cites:[L.checkImmediate,L.uvRunUnix,L.uvRunWin,R.uvRun]},{id:`L3`,title:`Loop turns from the loop counter`,statement:`The loop counter read when a callback starts (rule L1) is higher than at the previous callback, so at least one new turn began in between. Until trace events arrive we place the turn boundary at this callback. Turns in which no callback of ours ran are skipped.`,yields:`inferred`,platform:`all`,cites:[L.uvMetricsInfo,L.uvRunUnix,L.uvRunWin,R.uvRun]},{id:`W0`,title:`A job was submitted to, or came back from, the thread pool`,statement:`Node's ThreadPoolWork reports a trace event with the job's address when it submits work to libuv and another when the result is delivered on the main thread.`,yields:`observed`,platform:`all`,cites:[L.scheduleWork,L.workSubmit,L.workDone,R.poolSubmit,R.poolDone]},{id:`W1`,title:`Which async item a pool job belongs to`,statement:`The trace event for a submitted job follows the creation of an async item of a thread-pool-backed type on the main thread, in the same synchronous call. We take that item as the owner of the job. The trace event itself carries no async id.`,yields:`inferred`,platform:`all`,cites:[L.scheduleWork,L.workSubmit]},{id:`W2`,title:`A pool thread started a job`,statement:`Node's ThreadPoolWork reports a trace event from the pool thread when the work function begins. The event carries the real thread id and the kind of job, but not which job.`,yields:`observed`,platform:`all`,cites:[L.scheduleWork,L.worker,R.poolWorker]},{id:`W2b`,title:`Which job a pool thread started`,statement:`libuv keeps one first-in first-out work queue for all pool threads. The n-th "started" report for a kind of job is therefore the n-th submitted job of that kind. Two threads that take jobs within the same microsecond can report in swapped order.`,yields:`inferred`,platform:`all`,cites:[L.worker,L.post,L.workSubmit]},{id:`W3`,title:`A pool thread finished a job`,statement:`The pool thread reports a trace event when the work function returns. The thread and the time are observed; the job is the one that thread started (rule W2b).`,yields:`inferred`,platform:`all`,cites:[L.scheduleWork,L.worker]},{id:`W4`,title:`The result of a pool job was delivered`,statement:`The pool thread appends the finished job to the loop's done queue and wakes the loop; uv__work_done runs the after-work callbacks on the main thread in that order. The "result delivered" trace event with the job's address marks this, and the callback of the owning item follows.`,yields:`inferred`,platform:`all`,cites:[L.worker,L.workDone,R.poolDone]},{id:`W5`,title:`A job is waiting for a free pool thread`,statement:`A job was submitted while as many jobs as the pool has threads were running. It waits in the queue. This count is incomplete: file system requests and dns.lookup hold pool threads without reporting from them, and dns.lookup may use at most half of the threads.`,yields:`inferred`,platform:`all`,cites:[L.worker,L.post,L.initThreads]},{id:`W6`,title:`File system requests and dns.lookup use the pool without thread reports`,statement:`Classic file system requests and dns.lookup are handed to the pool by libuv itself, not through ThreadPoolWork. Node reports their start and end on the main thread only. We show them as queued pool work; which thread ran them, and when, is not available on an official build.`,yields:`inferred`,platform:`all`,cites:[L.fsWorkUnix,L.fsWorkWin,L.getaddrinfoUnix,L.getaddrinfoWin,L.workSubmit]},{id:`X1`,title:`The first use of the thread pool blocks the main thread`,statement:`The pool threads are created on the first submission, and the submitting thread waits until all of them have started. A gap on the main thread right after the first submission is this wait.`,yields:`inferred`,platform:`all`,cites:[L.workSubmit,L.initThreads]},{id:`W7`,title:`The pool size is read when the pool is first used`,statement:`libuv creates the pool threads at the first submission and reads UV_THREADPOOL_SIZE only then (no value: 4 threads; 0 or text that is not a number: 1; at most 1024). A program can therefore still set the variable before its first pool request. The helper reads the variable when the first thread-pool-backed async item is created and reports the size when it differs from the one the run started with. A use of the pool that creates no such item (a native add-on, a worker thread) is not seen.`,yields:`inferred`,platform:`all`,cites:[L.initThreads,L.workSubmit]},{id:`G1`,title:`Thread reports are missing for a pool job`,statement:`Every ThreadPoolWork job reports one start and one end from its pool thread. When a job was submitted and delivered but one of the two reports is absent, it was dropped while trace events were being read from the target. The job ran; its thread or times are not known.`,yields:`inferred`,platform:`all`,cites:[L.scheduleWork]},{id:`QT`,title:`A new Timeout waits in the timer lists`,statement:`An async item of type Timeout was created. setTimeout and setInterval construct a Timeout and insert it into the timer lists in the same call, so the item is waiting in the timers queue.`,yields:`inferred`,platform:`all`,cites:[L.timeoutCtor,L.timerInsert]},{id:`QT2`,title:`A repeating timer waits again after it ran`,statement:`The callback of a Timeout created by setInterval returned and the timer was not cleared. listOnTimeout inserts a repeating timer again after each run.`,yields:`inferred`,platform:`all`,cites:[L.listOnTimeout,L.timerInsert]},{id:`QI`,title:`A new Immediate waits in the immediate queue`,statement:`An async item of type Immediate was created. The Immediate constructor appends itself to the immediate queue.`,yields:`inferred`,platform:`all`,cites:[L.immediateCtor,L.processImmediate,L.toggleImmediateRef]},{id:`QK`,title:`A new TickObject waits in the nextTick queue`,statement:`An async item of type TickObject was created. process.nextTick pushes exactly one TickObject onto the tick queue per call.`,yields:`inferred`,platform:`all`,cites:[L.nextTick]},{id:`QM`,title:`A queueMicrotask callback waits in the microtask queue`,statement:`An async item of type Microtask was created. queueMicrotask creates it and enqueues the callback on V8's microtask queue in the same call.`,yields:`inferred`,platform:`all`,cites:[L.queueMicrotask,R.promiseReactionEnqueue]},{id:`QP`,title:`A promise reaction is queued when its promise settles`,statement:`then, catch, finally and await register a reaction on a promise and create a second promise for it (async_hooks reports that one with the first as its trigger). V8 puts the reaction job on the microtask queue when the first promise settles, or at once when it has already settled. The helper sees settling through the promiseResolve hook, which fires on fulfil and reject and not when a promise is merely resolved with another promise. So the reaction is shown in the microtask queue from the later of the two moments, creation and settling, until its callback starts. A promise that is only created while another promise's callback runs is not a reaction (its trigger is the running callback); neither is a promise that settles or runs before its trigger has settled (the wrapper an await makes around a plain value). Reactions of a promise whose settling was not seen are not shown as queued; they simply run.`,yields:`inferred`,platform:`all`,cites:[L.promiseInitHook,R.performPromiseThen,R.triggerReactions,R.promiseReactionEnqueue]},{id:`QP2`,title:`A reaction that was shown as queued did not run in its turn`,statement:`The microtask queue is first-in first-out and is emptied completely before the next timer, immediate or I/O callback. When a reaction that rule QP put in the queue is overtaken by a later microtask, or is still listed when such a callback starts, it was not in the queue: rule QP was wrong for this promise. The entry is removed here rather than left standing.`,yields:`inferred`,platform:`all`,cites:[R.promiseReactionEnqueue,R.triggerReactions]},{id:`QW`,title:`A new thread-pool-backed request waits for the pool`,statement:`An async item of a thread-pool-backed type was created (FSREQCALLBACK, FSREQPROMISE, GETADDRINFOREQWRAP, GETNAMEINFOREQWRAP, a crypto *REQUEST, zlib). Node creates the item and submits the work in the same call, so the request is with the thread pool until its callback starts.`,yields:`inferred`,platform:`all`,cites:[L.workSubmit,L.scheduleWork,R.poolSubmit]},{id:`QR`,title:`A new one-shot I/O request waits on the operating system`,statement:`An async item of a one-shot request type was created (a connect, write or shutdown request). It waits for the operating system until its callback starts.`,yields:`inferred`,platform:`all`,cites:[R.phasePoll,R.makeCallback]},{id:`QX`,title:`A waiting item went away without running`,statement:`An item that was waiting was reported as destroyed before any callback of it started (for example clearTimeout, clearImmediate or clearInterval). It left its queue.`,yields:`inferred`,platform:`all`,cites:[L.timeoutCtor,L.immediateCtor]}],Me=/* @__PURE__ */ new Set([`C0`,`T2`,`I2`,`L1`,`W2`,`W4`,`W5`,`W6`,`X1`]),Ne=je.filter(e=>!Me.has(e.id));je.filter(e=>Me.has(e.id)),new Map(Ne.map(e=>[e.id,e]));function Pe(e){return e===`FSREQCALLBACK`||e===`FSREQPROMISE`||e===`GETADDRINFOREQWRAP`||e===`GETNAMEINFOREQWRAP`||e===`ZLIB`||e===`BROTLI_DECODE`||e===`BROTLI_ENCODE`||e===`ZSTD_COMPRESS`||e===`ZSTD_DECOMPRESS`||e.endsWith(`REQUEST`)}function Fe(e){return e===`TCPCONNECTWRAP`||e===`PIPECONNECTWRAP`||e===`WRITEWRAP`||e===`SHUTDOWNWRAP`||e===`UDPSENDWRAP`}const Ie=/* @__PURE__ */ new Set([`TCPWRAP`,`TCPSERVERWRAP`,`PIPEWRAP`,`PIPESERVERWRAP`,`TTYWRAP`,`UDPWRAP`,`PROCESSWRAP`,`SIGNALWRAP`,`FSEVENTWRAP`,`STATWATCHER`,`MESSAGEPORT`]);function Le(){let e=[];for(let t=0;t<7;t++)e.push({items:[],head:0});return{status:`idle`,startIndex:-1,endIndex:-1,mainScript:!1,idleIndex:-1,stack:[],turn:-1,turnIndex:-1,phase:0,phaseIndex:-1,lastPhase:0,lastPhaseEntered:-1,lastPhaseLeft:-1,pollIndex:-1,scopeIndex:-1,sampleIndex:-1,queues:e,where:/* @__PURE__ */ new Map,timersActive:/* @__PURE__ */ new Set,timersRecent:[],tSet:0,tWaiting:0,tRunning:0,tDone:0,tCleared:0,firedCount:0,firedIndex:-1,poolSizeIndex:-1,threads:[],jobs:/* @__PURE__ */ new Map,poolWaiting:[],poolDone:[],doneUntied:0,tids:/* @__PURE__ */ new Map,pQueued:0,pStarted:0,pFinished:0,pPosted:0,pDelivered:0,pCancelled:0,pDropped:0,poolPosts:!1,outputCount:0,noteCount:0,paused:!1,pausedIndex:-1,lastPausedIndex:-1,lastResumedIndex:-1,pauses:0,gateStopped:!1,gateIndex:-1,gateReleasedIndex:-1,gateStops:0,clockFrozen:!1,clockIndex:-1,clockUnfrozenIndex:-1,hiddenMs:0,focusIndex:-1,unknown:0,malformed:0,inconsistent:0}}function Re(e){let t=[];for(let n of e.queues)t.push({items:n.head===0?n.items.slice():n.items.slice(n.head),head:0});return{...e,stack:e.stack.slice(),queues:t,where:new Map(e.where),timersActive:new Set(e.timersActive),timersRecent:e.timersRecent.slice(),threads:e.threads.slice(),jobs:new Map(e.jobs),poolWaiting:e.poolWaiting.slice(),poolDone:e.poolDone.slice(),tids:new Map(e.tids)}}function ze(e){let t=64+e.stack.length+e.where.size*2+e.timersActive.size+e.timersRecent.length+e.threads.length+e.jobs.size*2+e.poolWaiting.length+e.poolDone.length+e.tids.size*2;for(let n of e.queues)t+=n.items.length-n.head;return t}function Be(e,t,n){e.queues[t].items.push(n),e.where.set(n.id,(e.where.get(n.id)??0)|1<<t)}function Ve(e,t){let n=e.items;for(let r=e.head;r<n.length;r++)if(n[r].id===t)return r;return-1}function He(e,t,n){let r=e.where.get(n);if(r===void 0||!(r&1<<t))return null;let i=e.queues[t],a=Ve(i,n),o=r&~(1<<t);if(o===0?e.where.delete(n):e.where.set(n,o),a<0)return null;let s=i.items[a];return a===i.head?(i.head++,i.head===i.items.length?(i.items=[],i.head=0):i.head>=1024&&i.head*2>=i.items.length&&(i.items=i.items.slice(i.head),i.head=0)):i.items.splice(a,1),s}function z(e,t){let n=e.stack;for(let e=n.length-1;e>=0;e--)if(n[e].id===t)return!0;return!1}function Ue(e,t,n){t===1?e.tWaiting+=n:t===2?e.tRunning+=n:t===3?e.tDone+=n:t===4&&(e.tCleared+=n)}function B(e,t,n,r,i){let a=t.timerStateAt(n,i+1,z(e,n.id));if(a===r)return;r===0&&e.tSet++,Ue(e,r,-1),Ue(e,a,1);let o=a===1||a===2;if(o&&r!==1&&r!==2){e.timersActive.add(n.id);let t=e.timersRecent.indexOf(n.id);t>=0&&e.timersRecent.splice(t,1)}else if(!o){e.timersActive.delete(n.id);let t=e.timersRecent.indexOf(n.id);t>=0&&e.timersRecent.splice(t,1),e.timersRecent.push(n.id),e.timersRecent.length>32&&e.timersRecent.shift()}}function We(e,t,n,r){let i=[];for(let e of n){let n=t.items.get(e.id);if(n===void 0||n.timer===null)continue;let a=!1;for(let e of i)e[0]===n&&(a=!0);a||i.push([n,t.timerStateAt(n,r,!0)])}return i}function Ge(e,t){let n=e.indexOf(t);return n<0?!1:(e.splice(n,1),!0)}function Ke(e,t){for(;e.threads.length<t;)e.threads.push({job:null,tid:-1,jobs:0})}function V(e,t){if(t.state===0){Ge(e.poolWaiting,t.job);return}let n=t.thread>0?e.threads[t.thread-1]:void 0;n!==void 0&&n.job===t.job&&(e.threads[t.thread-1]={job:null,tid:n.tid,jobs:n.jobs}),t.done&&Je(e,t)}function qe(e,t){e.jobs.set(t.job,t.done?t:{...t,done:!0}),e.poolDone.push(t.job),t.id<0&&e.doneUntied++}function Je(e,t){Ge(e.poolDone,t.job)&&t.id<0&&e.doneUntied--}function Ye(e,t,n,r,i){Ke(e,t);let a=e.threads[t-1];a.job!==null&&a.job!==n&&(e.inconsistent++,e.jobs.delete(a.job)),e.threads[t-1]={job:n,tid:r===void 0?a.tid:r,jobs:a.jobs+ +!!i}}function Xe(e,t,n){let r=t.jobNames;for(let i=0;i<r.length&&t.jobIndexes[i]<n;i++){let n=e.jobs.get(r[i]);if(n!==void 0&&n.id===t.id){if(n.state===0)Ge(e.poolWaiting,n.job);else if(n.done)Je(e,n);else continue;e.jobs.delete(n.job),e.pDelivered++}}}function Ze(e,t,n,r){if(n.id>=0){let i=t.items.get(n.id),a=n.queuedIndex>=0?n.queuedIndex:n.startedIndex;if(i!==void 0&&(i.goneIndex>=0&&i.goneIndex<=r||_(i.starts,r+1)>a)){e.jobs.delete(n.job),e.pDelivered++;return}}qe(e,n);for(let t=0;e.doneUntied>32&&t<e.poolDone.length;){let n=e.poolDone[t];e.jobs.get(n).id<0?(e.poolDone.splice(t,1),e.jobs.delete(n),e.pDropped++,e.doneUntied--):t++}}function Qe(e,t){return e===`TickObject`?{via:2,rule:`K1`}:e===`PROMISE`||e===`Microtask`?{via:3,rule:`M1`}:e===`Timeout`?{via:1,rule:`T1`}:e===`Immediate`?{via:1,rule:`I1`}:Pe(e)?{via:1,rule:t===`win32`?`P1w`:`P1u`}:Fe(e)||Ie.has(e)?{via:1,rule:`P2`}:null}function H(e){e.status=e.endIndex>=0?`ended`:e.startIndex<0?`idle`:e.paused?`paused`:e.gateStopped?`gate`:`running`}function U(e,t){e.phase!==0&&(e.lastPhase=e.phase,e.lastPhaseEntered=e.phaseIndex,e.lastPhaseLeft=t,e.phase=0,e.phaseIndex=-1)}function W(e,t){e.mainScript&&(e.mainScript=!1,e.stack.length===0&&(e.idleIndex=t))}function $e(e,t,n,r,i,a){if(r&64)return r&128?e.unknown++:e.malformed++,0;t.at!==void 0&&t.at!==``&&(e.focusIndex=n);let o=0;switch(t.k){case`run.start`:e.startIndex>=0&&e.inconsistent++,e.startIndex=n,e.endIndex=-1,e.mainScript=!0,e.poolPosts=t.caps.poolThreads===`live`,e.poolSizeIndex=-1,Ke(e,Math.max(0,Math.min(1024,Math.floor(t.poolSize)))),H(e);break;case`run.end`:{e.endIndex=n;let t=We(e,i,e.stack,n);e.stack.length>0&&(e.stack=[]);for(let[r,a]of t)B(e,i,r,a,n);e.mainScript=!1,e.idleIndex=n,U(e,n),e.paused&&(e.paused=!1,e.lastPausedIndex=e.pausedIndex,e.lastResumedIndex=-1),e.gateStopped=!1,e.clockFrozen=!1,H(e);break}case`output`:e.outputCount++,o=t.stream===`stdout`?9:10;break;case`item.new`:{let r=i.items.get(t.id);r!==void 0&&r.newIndex!==n&&e.inconsistent++;break}case`callback.start`:{let r=i.items.get(t.id),s=i.timerStateAt(r,n,z(e,t.id));e.mainScript=!1;let c=e.stack.length,l=t.type,u=0,d=-1,f=null,p=-1,m=e.where.get(t.id);if(m!==void 0)for(let n=0;n<7;n++){if(!(m&1<<n))continue;if(n===5&&Ie.has(l)){let r=e.queues[5],i=Ve(r,t.id);if(i>=0){let e=r.items[i];r.items[i]={id:e.id,index:e.index,runs:e.runs+1},p<0&&(p=n,d=e.index)}continue}let r=He(e,n,t.id);r!==null&&p<0&&(p=n,d=r.index)}if(p>=0)u=p===0?2:p===1?3:1;else{let t=e.startIndex>=0?a[e.startIndex]:void 0,n=Qe(l,t!==void 0&&t.k===`run.start`?t.node.platform:``);n!==null&&(u=n.via,f=n.rule)}e.stack.push({id:t.id,index:n,via:u,viaIndex:d,viaRule:f,queue:p,phase:c===0?e.phase:0,phaseIndex:c===0?e.phaseIndex:-1,depth:c}),Xe(e,r,n),s!==0&&B(e,i,r,s,n),o=p>=0?p+1:8;break}case`callback.end`:{let r=e.stack,a=r.length-1;for(;a>=0&&r[a].id!==t.id;)a--;if(a<0){e.inconsistent++;break}a!==r.length-1&&e.inconsistent++;let o=We(e,i,r.slice(a),n);r.length=a,a===0&&(e.idleIndex=n);for(let[t,r]of o)B(e,i,t,r,n);break}case`item.gone`:{let r=i.items.get(t.id),a=i.timerStateAt(r,n,z(e,t.id)),o=e.where.get(t.id);if(o!==void 0)for(let n=0;n<7;n++)o&1<<n&&He(e,n,t.id);Xe(e,r,n),a!==0&&B(e,i,r,a,n);break}case`promise.settled`:break;case`timer.set`:{let r=i.items.get(t.id);r.timer!==null&&r.timer.setIndex!==n&&e.inconsistent++,B(e,i,r,i.timerStateAt(r,n,z(e,t.id)),n);break}case`loop.sample`:e.sampleIndex=n;break;case`scope`:(t.name===`RunTimers`||t.name===`CheckImmediate`)&&W(e,n),e.scopeIndex=n;break;case`pool.thread`:{if(t.tid===void 0)break;let r=e.tids.get(t.tid),i=(r===void 0?0:r.starts)+ +(t.edge===`start`),a=(r===void 0?0:r.ends)+ +(t.edge===`end`);e.tids.set(t.tid,{tid:t.tid,busy:t.edge===`start`,name:t.name,index:n,starts:i,ends:a});break}case`signal`:break;case`queue.add`:{let r=s(t.queue),a=i.items.get(t.id),o=r===2?i.timerStateAt(a,n,z(e,t.id)):0;(e.where.get(t.id)??0)&1<<r||Be(e,r,{id:t.id,index:n,runs:0}),o!==0&&B(e,i,a,o,n);break}case`queue.remove`:{let r=s(t.queue),a=i.items.get(t.id),o=r===2&&a!==void 0?i.timerStateAt(a,n,z(e,t.id)):0;He(e,r,t.id),a!==void 0&&o!==0&&B(e,i,a,o,n);break}case`loop.turn`:W(e,n),U(e,n),e.turn=t.n,e.turnIndex=n;break;case`phase.enter`:W(e,n),U(e,n),e.phase=c(t.phase),e.phaseIndex=n,t.pollTimeoutMs!==void 0&&(e.pollIndex=n),t.turn!==void 0&&t.turn!==e.turn&&(e.turn=t.turn,e.turnIndex=n);break;case`phase.leave`:{let r=c(t.phase);e.phase===r?U(e,n):e.phase===0?(e.lastPhase=r,e.lastPhaseEntered=-1,e.lastPhaseLeft=n):e.inconsistent++;break}case`timer.fired`:W(e,n),e.firedCount++,e.firedIndex=n;break;case`pool.queued`:{let r=e.jobs.get(t.job);r!==void 0&&(e.inconsistent++,V(e,r)),e.jobs.set(t.job,{job:t.job,kind:t.kind,op:t.op===void 0?null:t.op,id:t.id===void 0?-1:t.id,linkIndex:t.id===void 0?-1:n,state:0,thread:0,queuedIndex:n,startedIndex:-1,finishedIndex:-1,postedIndex:-1,done:!1,atIndex:t.at===void 0?-1:n}),e.poolWaiting.push(t.job),e.pQueued++,o=12;break}case`pool.started`:{let r=e.jobs.get(t.job);r===void 0?r={job:t.job,kind:`unknown`,op:null,id:-1,linkIndex:-1,state:0,thread:0,queuedIndex:-1,startedIndex:-1,finishedIndex:-1,postedIndex:-1,done:!1,atIndex:-1}:(r.state!==0&&e.inconsistent++,V(e,r)),Ye(e,t.thread,t.job,t.tid,!0),e.jobs.set(t.job,{...r,state:1,thread:t.thread,startedIndex:n,done:!1,atIndex:t.at===void 0?r.atIndex:n}),e.pStarted++,o=12;break}case`pool.finished`:{let r=e.jobs.get(t.job);r===void 0?r={job:t.job,kind:`unknown`,op:null,id:-1,linkIndex:-1,state:0,thread:0,queuedIndex:-1,startedIndex:-1,finishedIndex:-1,postedIndex:-1,done:!1,atIndex:-1}:((r.state===1&&r.thread!==t.thread||r.state>=2)&&e.inconsistent++,V(e,r)),e.pFinished++;let a={...r,state:2,thread:t.thread,finishedIndex:n,done:!1,atIndex:t.at===void 0?r.atIndex:n};e.poolPosts?(Ye(e,t.thread,t.job,t.tid,!1),e.jobs.set(t.job,a)):Ze(e,i,a,n),o=12;break}case`pool.posted`:{e.poolPosts=!0;let r=e.jobs.get(t.job);r===void 0?r={job:t.job,kind:`unknown`,op:null,id:-1,linkIndex:-1,state:0,thread:0,queuedIndex:-1,startedIndex:-1,finishedIndex:-1,postedIndex:-1,done:!1,atIndex:-1}:(r.state===3&&e.inconsistent++,V(e,r)),e.pPosted++,Ze(e,i,{...r,state:3,thread:t.thread,postedIndex:n,done:!1,atIndex:t.at===void 0?r.atIndex:n},n),o=12;break}case`pool.delivered`:{let n=e.jobs.get(t.job);if(o=12,n===void 0)break;(n.state===0||n.state===1)&&e.inconsistent++,V(e,n),e.jobs.delete(t.job),e.pDelivered++;break}case`pool.cancelled`:{let n=e.jobs.get(t.job);if(o=12,n===void 0)break;if(n.state!==0){e.inconsistent++;break}V(e,n),e.jobs.delete(t.job),e.pCancelled++;break}case`pool.size`:for(e.poolSizeIndex=n,Ke(e,t.size);e.threads.length>t.size;){let t=e.threads[e.threads.length-1];if(t.job!==null||t.jobs>0)break;e.threads.pop()}o=12;break;case`pool.link`:{let r=e.jobs.get(t.job);if(r===void 0)break;r.done?(Je(e,r),e.jobs.delete(t.job),Ze(e,i,{...r,id:t.id,linkIndex:n,done:!1},n)):e.jobs.set(t.job,{...r,id:t.id,linkIndex:n});break}case`debug.paused`:e.paused=!0,e.pausedIndex=n,e.pauses++,H(e),o=11;break;case`debug.resumed`:e.lastPausedIndex=e.paused?e.pausedIndex:-1,e.lastResumedIndex=n,e.paused=!1,e.pausedIndex=-1,H(e);break;case`gate.stopped`:e.gateStopped=!0,e.gateIndex=n,e.gateStops++,H(e),o=11;break;case`gate.released`:e.gateStopped=!1,e.gateReleasedIndex=n,H(e);break;case`clock.frozen`:e.clockFrozen=!0,e.clockIndex=n;break;case`clock.unfrozen`:e.clockFrozen=!1,e.clockUnfrozenIndex=n,e.hiddenMs+=t.hiddenMs;break;case`note`:e.noteCount++,o=13}return o}const et=`replay:main`,tt=`replay:due`;new Map([{id:et,title:`The main script is running`,statement:`The run has started and no callback has started and the event loop has reported nothing yet. Node runs its start-up code and then the main script before it enters the loop, so the main thread is running one of the two. For an ES module the body itself runs inside promise callbacks, which then show as callbacks.`,yields:`inferred`,platform:`all`,cites:[`s:lib/internal/modules/run_main.js#executeUserEntryPoint`,`o:loop.run`]},{id:tt,title:`When a timer is due`,statement:`A timer was armed (set, or put back after a run) with a delay. We show it as due at the time of that event plus the delay, and measure lateness against that. Node starts the delay from the loop's cached clock, which was read at the start of the current loop turn, so the real due time can be earlier than shown by the time the current callback had already been running.`,yields:`inferred`,platform:`all`,cites:[`s:lib/internal/timers.js#Timeout.prototype.constructor`,`s:lib/internal/timers.js#insert`,`o:timers.listOnTimeout`]},{id:`replay:handle`,title:`A handle keeps waiting after its callback`,statement:`An item whose type is a libuv handle (a socket, a server, a pipe, a child process, a watcher) was waiting on the operating system and one of its callbacks ran. A handle stays registered with the loop until it is closed, so it is still shown as waiting. It leaves when it is reported destroyed.`,yields:`inferred`,platform:`all`,cites:[`s:src/handle_wrap.cc#node::HandleWrap::OnClose`,`o:phase.poll`]},{id:`replay:delivered`,title:`The result of a pool job reached the loop`,statement:`The callback of an item started, or the item was destroyed, while a pool job of that item was shown as finished or as still queued. The after-work callback on the main thread is what leads to that callback, so the work is done and its result is no longer waiting to be delivered. (File system requests and dns.lookup report nothing from the pool thread; for them the callback is the only sign that the work ran.)`,yields:`inferred`,platform:`all`,cites:[`s:deps/uv/src/threadpool.c#uv__work_done`,`o:pool.done`]}].map(e=>[e.id,e]));const nt={maxEntries:200,maxOutput:200,maxNotes:50,maxLog:50,items:`none`};function rt(e,t){if(t===void 0)return e;let n=(e,t)=>typeof e==`number`&&e>=0?Math.floor(e):t;return{maxEntries:n(t.maxEntries,e.maxEntries),maxOutput:n(t.maxOutput,e.maxOutput),maxNotes:n(t.maxNotes,e.maxNotes),maxLog:n(t.maxLog,e.maxLog),items:t.items===`all`||t.items===`none`?t.items:e.items}}const it=[`unknown`,`phase`,`nextTick`,`microtask`],at=[null,`waiting`,`running`,`done`,`cleared`];function G(e,t){return v(e.events[t],t)}function K(e,t){return t<0?null:G(e,t)}function ot(e,t){for(let n of e.stack)if(n.id===t)return!0;return!1}function st(e,t,n){let r=e.index.items.get(t);return r===void 0||r.firstIndex>=n?{id:t,type:`?`,label:null,trigger:0,loc:null,created:null}:e.index.refAt(r,n)}function ct(e,t,n,r){let i=n.timer;if(i===null||i.setIndex>=r)return null;let a=e.events,o=_(i.arms,r),s=_(n.starts,r),c=at[e.index.timerStateAt(n,r,ot(t,n.id))],l=G(e,o),u=i.delayMs*1e3,d=null;if(s>=0){let e=_(i.arms,s);e>=0&&(d=(a[s].t-(a[e].t+u))/1e3)}return{item:e.index.refAt(n,r),delayMs:i.delayMs,repeat:i.repeat,set:G(e,i.setIndex),armed:l,dueT:l.t+u,dueFrom:{c:`inferred`,rule:tt,index:o,t:l.t},state:c,runs:g(n.starts,r),lastRun:K(e,s),lateMs:d,cleared:i.clearedIndex>=0&&i.clearedIndex<r?G(e,i.clearedIndex):null}}function lt(e,t,r,i){let a=e.index.refAt(r,i),o=g(r.starts,i),s=g(r.ends,i),c=r.goneIndex>=0&&r.goneIndex<i,l=t.where.get(r.id)??0,u=[];for(let e=0;e<7;e++)l&1<<e&&u.push(n[e]);let d;d=c?`gone`:ot(t,r.id)?`running`:u.length>0?`waiting`:o>0?`ran`:`created`;let f=g(r.jobIndexes,i);return{id:a.id,type:a.type,label:a.label,trigger:a.trigger,loc:a.loc,created:a.created,state:d,queues:u,runs:o,lastStart:o>0?G(e,r.starts[o-1]):null,lastEnd:s>0?G(e,r.ends[s-1]):null,gone:c?G(e,r.goneIndex):null,settled:r.settledIndex>=0&&r.settledIndex<i?G(e,r.settledIndex):null,timer:ct(e,t,r,i),job:f>0?r.jobNames[f-1]:null,children:g(r.children,i)}}function ut(e,t,r){let i=G(e,t.index),o=null;return t.viaIndex>=0?o=G(e,t.viaIndex):t.viaRule!==null&&(o={c:`inferred`,rule:t.viaRule,index:t.index,t:i.t}),{item:st(e,t.id,r),from:i,via:it[t.via],viaFrom:o,queue:t.queue>=0?n[t.queue]:null,phase:a[t.phase],phaseFrom:K(e,t.phaseIndex),phaseAfterPoll:q(e,t.phaseIndex),depth:t.depth}}const dt=[`waiting`,`running`,`finished`,`posted`];function ft(e,t){if(!t.gateStopped||t.gateIndex<0)return null;let n=e.events[t.gateIndex];return n.k===`gate.stopped`&&n.job!==void 0&&(n.gate===`poolStart`||n.gate===`poolPost`||n.gate===`poolDone`)?n:null}function pt(e,t,n,r){let i=t.atIndex>=0?e.events[t.atIndex]:void 0;return{job:t.job,kind:t.kind,op:t.op,state:dt[t.state],item:t.id>=0?st(e,t.id,n):null,itemFrom:K(e,t.linkIndex),thread:t.thread>0?t.thread:null,queued:K(e,t.queuedIndex),started:K(e,t.startedIndex),finished:K(e,t.finishedIndex),posted:K(e,t.postedIndex),at:i!==void 0&&i.at!==void 0?i.at:null,held:r!==null&&r.job===t.job?r.gate:null}}function mt(e,t){let n=t.startIndex>=0?e.events[t.startIndex]:void 0,r=t.endIndex>=0?e.events[t.endIndex]:void 0,i=n!==void 0&&n.k===`run.start`?n:void 0,a=r!==void 0&&r.k===`run.end`?r:void 0;return{status:t.status,node:i===void 0?null:i.node,caps:i===void 0?null:i.caps,program:i===void 0?null:i.program,mode:i===void 0?null:i.mode,poolSize:i===void 0?null:i.poolSize,exitCode:a===void 0||a.code===void 0?null:a.code,signal:a===void 0||a.signal===void 0?null:a.signal,started:K(e,t.startIndex),ended:K(e,t.endIndex)}}function ht(e,t,n){if(t.stack.length>0){let r=t.stack.map(t=>ut(e,t,n));return{doing:`callback`,from:r[r.length-1].from,stack:r}}if(t.mainScript&&t.startIndex>=0){let n=G(e,t.startIndex);return{doing:`main`,from:{c:`inferred`,rule:et,index:n.index,t:n.t},stack:[]}}return{doing:`nothing`,from:K(e,t.idleIndex),stack:[]}}function q(e,t){if(t<0)return!1;let n=e.events[t];return(n.k===`phase.enter`||n.k===`phase.leave`)&&n.afterPoll===!0}function gt(e,t){let n=t.scopeIndex>=0?e.events[t.scopeIndex]:void 0,r=t.sampleIndex>=0?e.events[t.sampleIndex]:void 0,i=t.pollIndex>=0?e.events[t.pollIndex]:void 0;return{turn:t.turnIndex>=0?t.turn:null,turnFrom:K(e,t.turnIndex),phase:a[t.phase],phaseFrom:t.phase===0?null:K(e,t.phaseIndex),afterPoll:t.phase!==0&&q(e,t.phaseIndex),poll:i!==void 0&&i.k===`phase.enter`&&i.pollTimeoutMs!==void 0?{timeoutMs:i.pollTimeoutMs,current:t.phase!==0&&t.phaseIndex===t.pollIndex,from:G(e,t.pollIndex)}:null,lastPhase:t.lastPhase===0?null:{phase:a[t.lastPhase],afterPoll:q(e,t.lastPhaseEntered)||q(e,t.lastPhaseLeft),entered:K(e,t.lastPhaseEntered),left:G(e,t.lastPhaseLeft)},lastScope:n!==void 0&&n.k===`scope`?{name:n.name,durUs:n.durUs,from:G(e,t.scopeIndex)}:null,lastSample:r!==void 0&&r.k===`loop.sample`?{loopCount:r.loopCount,events:r.events,eventsWaiting:r.eventsWaiting,from:G(e,t.sampleIndex)}:null}}function _t(e,t,n,r,i,a){let o=n.items.length-n.head,s=Math.min(o,i),c=[];for(let t=0;t<s;t++){let i=n.items[n.head+t],a=e.events[i.index];c.push({item:st(e,i.id,r),from:v(a,i.index),at:a.at===void 0?null:a.at,runs:i.runs})}return{name:t,total:o,entries:c,truncated:s<o,leftAtEnd:a&&o>0}}function vt(e,t,n,r){let i=[];for(let r of t.timersActive){let t=e.index.items.get(r),a=t===void 0?null:t.timer;t===void 0||a===null||a.setIndex>=n||i.push({rec:t,due:e.events[_(a.arms,n)].t+a.delayMs*1e3,set:a.setIndex})}i.sort((e,t)=>e.due-t.due||e.set-t.set);let a=i.length>r,o=[];for(let a=0;a<i.length&&a<r;a++){let r=ct(e,t,i[a].rec,n);r!==null&&o.push(r)}let s=[];for(let r of t.timersRecent){let i=e.index.items.get(r),a=i===void 0?null:ct(e,t,i,n);a!==null&&s.push(a)}let c=t.firedIndex>=0?e.events[t.firedIndex]:void 0;return{active:o,recent:s,counts:{set:t.tSet,waiting:t.tWaiting,running:t.tRunning,done:t.tDone,cleared:t.tCleared},fired:{count:t.firedCount,last:c!==void 0&&c.k===`timer.fired`?{lateMs:c.lateMs===void 0?null:c.lateMs,from:G(e,t.firedIndex)}:null},truncated:a,leftAtEnd:t.endIndex>=0&&t.tWaiting>0}}function yt(e,t,n,r,i){let a=t.poolSizeIndex>=0?e.events[t.poolSizeIndex]:void 0,o=a!==void 0&&a.k===`pool.size`?a.size:i,s=a!==void 0&&a.k===`pool.size`?G(e,t.poolSizeIndex):K(e,t.startIndex),c=ft(e,t),l=null;if(c!==null){let r=c.job,i=t.jobs.get(r),a=null;if(c.gate!==`poolDone`){if(i!==void 0&&i.state!==0&&i.thread>0)a=i.thread;else if(c.tid!==void 0){let e=t.threads.findIndex(e=>e.tid===c.tid);e>=0&&(a=e+1)}}l={gate:c.gate,job:r,where:c.gate===`poolDone`?`loop`:`thread`,thread:a,view:i===void 0?null:pt(e,i,n,c),from:G(e,t.gateIndex)}}let u=[];for(let r=0;r<t.threads.length;r++){let i=t.threads[r],a=i.job===null?void 0:t.jobs.get(i.job);u.push({thread:r+1,job:a===void 0?null:pt(e,a,n,c),tid:i.tid>=0?i.tid:null,jobs:i.jobs,extra:o!==null&&r+1>o})}let d=i=>{let a=[];for(let o=0;o<i.length&&a.length<r;o++){let r=t.jobs.get(i[o]);r!==void 0&&a.push(pt(e,r,n,c))}return a},f=[];for(let n of t.tids.values())f.push({tid:n.tid,busy:n.busy,name:n.name,from:G(e,n.index),starts:n.starts,ends:n.ends});return f.sort((e,t)=>e.tid-t.tid),{size:o,sizeFrom:s,threads:u,waiting:d(t.poolWaiting),done:d(t.poolDone),held:l,tids:f,counts:{queued:t.pQueued,started:t.pStarted,finished:t.pFinished,posted:t.pPosted,delivered:t.pDelivered,cancelled:t.pCancelled,droppedUnlinked:t.pDropped},truncated:t.poolWaiting.length>r||t.poolDone.length>r,leftAtEnd:t.endIndex>=0&&t.jobs.size>0}}function bt(e,t){let n=t.paused&&t.pausedIndex>=0?e.events[t.pausedIndex]:void 0,r=n!==void 0&&n.k===`debug.paused`?n:void 0,i=null;if(t.lastResumedIndex>=0){let n=e.events[t.lastResumedIndex],r=t.lastPausedIndex>=0?e.events[t.lastPausedIndex]:void 0;n.k===`debug.resumed`&&(i={pausedMs:n.pausedMs,timeKeptRunning:r!==void 0&&r.k===`debug.paused`&&r.timeKeptRunning,paused:K(e,t.lastPausedIndex),resumed:G(e,t.lastResumedIndex)})}let a=t.gateStopped&&t.gateIndex>=0?e.events[t.gateIndex]:void 0,o=a!==void 0&&a.k===`gate.stopped`?a:void 0,s=t.gateReleasedIndex>=0?e.events[t.gateReleasedIndex]:void 0,c=t.clockUnfrozenIndex>=0?e.events[t.clockUnfrozenIndex]:void 0,l=t.clockFrozen&&t.clockIndex>=0?e.events[t.clockIndex]:void 0;return{paused:t.paused,reason:r===void 0?null:r.reason,frames:r===void 0?[]:r.frames,timeKeptRunning:r!==void 0&&r.timeKeptRunning,from:r===void 0?null:G(e,t.pausedIndex),lastPause:i,pauses:t.pauses,gate:{stopped:t.gateStopped,gate:o===void 0?null:o.gate,phase:o===void 0||o.phase===void 0?null:o.phase,job:o===void 0||o.job===void 0?null:o.job,from:o===void 0?null:G(e,t.gateIndex),lastStoppedMs:s!==void 0&&s.k===`gate.released`?s.stoppedMs:null,stops:t.gateStops},clock:{frozen:t.clockFrozen,why:l!==void 0&&l.k===`clock.frozen`&&(l.why===`gate`||l.why===`breakpoint`)?l.why:null,from:t.clockFrozen?K(e,t.clockIndex):null,lastHiddenMs:c!==void 0&&c.k===`clock.unfrozen`?c.hiddenMs:null,hiddenMs:t.hiddenMs}}}function xt(e,t,r){let i=/* @__PURE__ */ new Map,a=(e,t)=>{if(e===void 0||e===``)return null;let n=i.get(e);return n===void 0&&(n={at:e,count:0,c:t,waiting:0,poolWaiting:0,poolRunning:0,poolDone:0,queues:[],pool:!1},i.set(e,n)),n.count++,n.c=y(n.c,t),n};for(let i=0;i<7;i++){let o=t.queues[i],s=n[i];for(let t=o.head;t<o.items.length;t++){let n=o.items[t];if(i===4){let t=e.index.items.get(n.id);if(t!==void 0&&g(t.jobIndexes,r)>0)continue}let c=e.events[n.index],l=a(c.at,c.c);l!==null&&(l.waiting++,l.queues.includes(s)||l.queues.push(s))}}for(let n of t.jobs.values()){if(n.atIndex<0)continue;let t=e.events[n.atIndex],r=a(t.at,t.c);r!==null&&(r.pool=!0,n.state===0?r.poolWaiting++:n.state===1?r.poolRunning++:r.poolDone++)}let o=[...i.values()].sort((e,t)=>e.at<t.at?-1:+(e.at>t.at)),s=t.focusIndex>=0?e.events[t.focusIndex]:void 0;return{at:s===void 0||s.at===void 0?null:s.at,from:s===void 0?null:G(e,t.focusIndex),kind:s===void 0?null:s.k,waiting:o}}function St(e,t,n){let r=Math.max(0,Math.floor(t)),i=Math.min(e.ready,Math.floor(n)),a=[];for(let t=r;t<i;t++)a.push({index:t,event:e.events[t],skipped:!!(e.index.flags[t]&64)});return a}function Ct(e,t,n,r){let i=Math.max(0,Math.floor(n)),a=Math.min(t.outputCount,Math.floor(r));return i<a?e.index.output.slice(i,a):[]}function wt(e,t,n,r,i){let a=e.index.itemsBefore(n),o=Math.max(0,Math.floor(r)),s=Math.min(a,o+Math.max(0,Math.floor(i))),c=[];for(let r=o;r<s;r++)c.push(lt(e,t,e.index.order[r],n));return c}function Tt(e,t,r,i){let a=e.index,o=mt(e,t),s={};for(let a=0;a<7;a++){let o=n[a];s[o]=_t(e,o,t.queues[a],r,i.maxEntries,t.endIndex>=0)}let c=a.itemsBefore(r),l=[];for(let n=Math.max(0,t.noteCount-i.maxNotes);n<t.noteCount;n++){let t=a.notes[n],r=e.events[t];r.k===`note`&&l.push({seq:n,level:r.level,text:r.text,from:v(r,t)})}let u=t.outputCount;return{position:r,length:e.length,ready:e.ready,live:e.live,version:e.version,t:r===0?e.ready>0?a.tMono[0]:0:a.tMono[r-1],endT:e.ready===0?0:a.tMono[e.ready-1],run:o,main:ht(e,t,r),loop:gt(e,t),queues:s,items:{total:c,all:i.items===`all`?wt(e,t,r,0,c):null},timers:vt(e,t,r,i.maxEntries),pool:yt(e,t,r,i.maxEntries,o.poolSize),output:{total:u,chars:u===0?0:a.outputChars[u-1],chunks:a.output.slice(Math.max(0,u-i.maxOutput),u)},debug:bt(e,t),notes:{total:t.noteCount,items:l},focus:xt(e,t,r),log:St(e,r-i.maxLog,r),problems:{unknown:t.unknown,malformed:t.malformed,inconsistent:t.inconsistent}}}const Et=e.length;function Dt(e,t,n,r,i){let a=Math.max(1,Math.min(8192,Math.floor(Number.isFinite(n)?n:1))),o=new Uint32Array(a),s=new Uint32Array(a),c=new Uint8Array(a),l=new Uint8Array(a),u=new Uint8Array(a),d=new Uint8Array(a),f=new Uint32Array(a*Et),p=e.tlState,m=e.tlClass,h=e.tMono,g=t===0?0:h[0],_=t===0?0:h[t-1],v=r===`time`,ee=_-g,y=/* @__PURE__ */ new Uint32Array(8),b=0,x=0;for(let e=0;e<a;e++){o[e]=b;let n;if(e===a-1)n=t;else if(!v)n=Math.min(t,Math.ceil((e+1)*t/a));else if(ee<=0)n=t;else{let r=g+(e+1)*ee/a;for(n=b;n<t&&h[n]<r;)n++}if(n<=b){c[e]=x&7,l[e]=x>>3&3,u[e]=x&32?1:0,d[e]=x&64?1:0;continue}y.fill(0);let r=0,i=0,_=e*Et;for(;b<n;b++){let e=p[b],t=e&7;if(t!==0){y[t]=y[t]+1;let n=e>>3&3;n>r&&(r=n)}i|=e;let n=m[b];n!==0&&(f[_+n-1]=f[_+n-1]+1),x=e}s[e]=n-o[e];let S=0,C=0;for(let e=1;e<8;e++)y[e]>C&&(S=e,C=y[e]);c[e]=S,l[e]=S===0?0:r,u[e]=i&32?1:0,d[e]=i&64?1:0}return{axis:v?`time`:`index`,width:a,version:i,length:t,from:v?g:0,to:v?_:t,start:o,events:s,phase:c,phaseCertainty:l,paused:u,busy:d,counts:f}}function Ot(e,t,n){let r=[];for(let n of e.notes){let e=t[n];e.k===`note`&&r.push({index:n,t:e.t,level:e.level,text:e.text})}let i=new Uint32Array(e.output.length),a=new Uint8Array(e.output.length);for(let t=0;t<e.output.length;t++){let n=e.output[t];i[t]=n.index,a[t]=+(n.stream===`stderr`)}return{version:n,pauses:e.pauses.map(e=>({...e})),notes:r,turnIndex:Uint32Array.from(e.turns),turnNumber:Uint32Array.from(e.turnNumbers),outputIndex:i,outputStream:a}}const kt={observed:1,inferred:2,model:3},At=typeof performance<`u`&&typeof performance.now==`function`?()=>performance.now():()=>Date.now();function jt(e){switch(e){case`step`:return 1;case`callback`:return 2;case`phase`:return 4;case`turn`:return 8;case`output`:return 16;case`pause`:return 32;default:return 255}}var Mt=class{store;#e=new b;#t=0;#n=Le();#r=[];#i=[];#a=0;#o;#s;#c;#l=0;#u=null;#d=0;#f;#p=/* @__PURE__ */ new Set;#m;#h=/* @__PURE__ */ new Map;#g=null;#_=-1;constructor(e,t){this.store=e;let n=t?.keyframeInterval;this.#s=typeof n==`number`&&n>=1?Math.floor(n):512,this.#o=this.#s,this.#c=t?.eager!==!1,this.#f=rt(nt,t?.view),this.#m=e.subscribe(e=>this.#v(e)),this.#c&&this.#S(1/0)}#v(e){e.rejected===null&&(e.replaced&&(this.#l=0),e.from<this.#t&&this.#y(e.from),this.#l>e.length&&(this.#l=e.length),this.#c&&this.#S(1/0));for(let t of[...this.#p])t(e)}#y(e){for(this.#e.truncate(e);this.#i.length>0&&this.#i[this.#i.length-1]>e;)this.#i.pop(),this.#a-=ze(this.#r.pop());let t=this.#i.length-1,n=t>=0?this.#i[t]:0,r=t>=0?Re(this.#r[t]):Le();this.#x(r,n,e),this.#n=r,this.#t=e,this.#o=n+(t>=0?this.#b(this.#r[t]):this.#s),this.#u!==null&&this.#d>e&&(this.#u=null)}#b(e){return Math.max(this.#s,ze(e)>>2)}#x(e,t,n){let r=this.store.events,i=this.#e,a=i.flags;for(let o=t;o<n;o++)$e(e,r[o],o,a[o],i,r)}#S(e){let t=this.store.events,n=t.length,r=this.#t;if(r>=n)return;let i=this.#e,a=this.#n,o=e===1/0?1/0:At()+e;for(;r<n;){let e=t[r],n=i.add(e,r);i.tlClass[r]=$e(a,e,r,n,i,t);let s=a.phase;if(s!==0&&(s|=(kt[t[a.phaseIndex].c]??0)<<3),(a.paused||a.gateStopped)&&(s|=32),a.stack.length>0&&(s|=64),i.tlState[r]=s,r++,r===this.#o){let e=Re(a);this.#r.push(e),this.#i.push(r),this.#a+=ze(e),this.#o=r+this.#b(e)}if(!(r&255)&&o!==1/0&&At()>=o)break}this.#t=r}get ready(){return this.#t}pump(e=4){return this.#S(Math.max(0,e)),this.#t<this.store.length}get position(){return Math.min(this.#l,this.#t)}#C(e){let t=this.#i,n=0,r=t.length;for(;n<r;){let i=n+r>>>1;t[i]<=e?n=i+1:r=i}return n-1}#w(e){let t=this.#C(e),n=t>=0?this.#i[t]:0,r=t>=0?Re(this.#r[t]):Le();return this.#x(r,n,e),r}#T(){let e=this.position;if(e===this.#t)return this.#n;let t=this.#C(e),n=t>=0?this.#i[t]:0;return this.#u!==null&&this.#d<=e&&this.#d>=n?this.#x(this.#u,this.#d,e):this.#u=this.#w(e),this.#d=e,this.#u}seek(e){let t=Number.isFinite(e)?Math.floor(e):e>0?this.store.length:0;return this.#l=Math.max(0,Math.min(this.store.length,t)),this.position}seekTime(e){return this.seek(this.positionAtTime(e))}positionAtTime(e){let t=this.#e.tMono,n=0,r=this.#t;for(;n<r;){let i=n+r>>>1;t[i]<=e?n=i+1:r=i}return n}timeAt(e){if(this.#t===0)return 0;let t=Math.max(1,Math.min(this.#t,Math.floor(e)));return this.#e.tMono[t-1]}find(e,t,n){let r=this.#t,i=n===void 0?this.position:Math.max(0,Math.min(r,Math.floor(n)));if(e===`event`){let e=t>0?i+1:i-1;return e<0||e>r?null:e}let a=jt(e);if(t>0){let e=this.#e.nextWith(a,i);return e<0||e>=r?null:e+1}let o=this.#e.previousWith(a,i-2);return o>=0?o+1:e===`step`&&i>0?0:null}step(e,t){let n=this.find(e,t);return n===null?null:(this.#l=n,n)}#E(){return{index:this.#e,events:this.store.events,length:this.store.length,ready:this.#t,live:this.store.live,version:this.store.version}}view(e){return Tt(this.#E(),this.#T(),this.position,rt(this.#f,e))}viewAt(e,t){let n=Math.max(0,Math.min(this.#t,Math.floor(e))),r=n===this.position?this.#T():this.#w(n);return Tt(this.#E(),r,n,rt(this.#f,t))}doing(){let e=this.#T();return e.stack.length>0?`callback`:e.mainScript&&e.startIndex>=0?`main`:`nothing`}item(e){let t=this.position,n=this.#e.items.get(e);return n===void 0||n.firstIndex>=t?null:lt(this.#E(),this.#T(),n,t)}why(e){let t=this.position,n=this.#E(),r=this.#T(),i=[],a=/* @__PURE__ */ new Set,o=e;for(;i.length<1e3&&!a.has(o);){a.add(o);let e=this.#e.items.get(o);if(e===void 0||e.firstIndex>=t)break;let s=lt(n,r,e,t);if(i.push(s),s.created===null)break;o=s.trigger}return i}items(e=0,t=1/0){let n=this.position,r=this.#e.itemsBefore(n);return wt(this.#E(),this.#T(),n,e,Math.min(t,r))}itemCount(){return this.#e.itemsBefore(this.position)}output(e,t){return Ct(this.#E(),this.#T(),e,t)}events(e,t){return St(this.#E(),e,t)}timeline(e,t=`index`){let n=t+`:`+e,r=this.#h.get(n),i=this.store.version;if(r!==void 0&&r.version===i&&r.length===this.#t)return r;let a=Dt(this.#e,this.#t,e,t,i);return this.#h.size>=4&&this.#h.clear(),this.#h.set(n,a),a}markers(){let e=this.store.version,t=this.#g;return t!==null&&t.version===e&&this.#_===this.#t?t:(this.#g=Ot(this.#e,this.store.events,e),this.#_=this.#t,this.#g)}query(e){switch(e.what){case`item`:return{what:`item`,item:this.item(e.id)};case`why`:return{what:`why`,chain:this.why(e.id)};case`items`:return{what:`items`,items:this.items(e.from,e.limit),total:this.itemCount()};case`output`:return{what:`output`,chunks:this.output(e.from,e.to)};case`events`:{let t=Math.max(0,Math.floor(e.from));return{what:`events`,entries:this.events(t,Math.min(e.to,t+1e3))}}case`viewAt`:return{what:`viewAt`,view:this.viewAt(e.position)};default:throw TypeError(`unknown query`)}}stats(){return{ready:this.#t,keyframes:this.#r.length,keyframeSlots:this.#a,keyframeInterval:this.#s}}subscribe(e){return this.#p.add(e),()=>{this.#p.delete(e)}}dispose(){this.#m(),this.#p.clear()}};const Nt=(e,t,n)=>e<t?t:e>n?n:e;var Pt=class{replay;#e=!1;#t=1;#n=`steps`;#r=5;#i=.01;#a=2e3;#o=600;#s=!0;#c=250;#l=null;#u=0;#d=null;#f=!1;#p=!1;#m=null;#h;constructor(e,t){this.replay=e,t!==void 0&&this.setOptions(t),this.#h=e.subscribe(e=>{e.replaced&&(this.#p=!1),e.status===`live`&&this.#s&&(this.#p=!0)})}dispose(){this.#h()}get state(){let e=this.replay,t=e.position,n=e.ready,r=e.store.live;return{playing:this.#e,speed:this.#t,pace:this.#n,follow:this.#s,following:this.#s&&r&&t===n,position:t,length:n,live:r,atEnd:!r&&n>0&&t===n&&e.store.length===n,waiting:this.#f,deadTime:this.#d,t:e.timeAt(t)}}play(){let e=this.replay;!e.store.live&&e.position>=e.store.length&&e.store.length>0&&e.seek(0),this.#e=!0,this.#g()}pause(){this.#e=!1,this.#s=!1,this.#p=!1,this.#g()}toggle(){this.#e?this.pause():this.play()}setSpeed(e){Number.isFinite(e)&&(this.#t=Nt(e,.05,20))}setPace(e){(e===`steps`||e===`time`||e===`tick`)&&(this.#n=e,this.#g())}setFollow(e){this.#s=e===!0,this.#p=this.#s&&this.replay.store.live}setOptions(e){e.speed!==void 0&&this.setSpeed(e.speed),e.pace!==void 0&&this.setPace(e.pace),typeof e.stepsPerSecond==`number`&&e.stepsPerSecond>0&&(this.#r=e.stepsPerSecond),typeof e.timeScale==`number`&&e.timeScale>0&&(this.#i=e.timeScale),typeof e.deadTimeUs==`number`&&e.deadTimeUs>=0&&(this.#a=e.deadTimeUs),typeof e.deadTimePauseMs==`number`&&e.deadTimePauseMs>=0&&(this.#o=e.deadTimePauseMs),e.follow!==void 0&&this.setFollow(e.follow),typeof e.maxTickMs==`number`&&e.maxTickMs>0&&(this.#c=e.maxTickMs)}seek(e){let t=this.replay,n=t.seek(e);t.store.live&&n>=t.ready||(this.#s=!1,this.#p=!1),this.#g()}seekTime(e){this.seek(this.replay.positionAtTime(e))}step(e,t){return this.#e=!1,this.#s=!1,this.#p=!1,this.#g(),this.replay.step(e,t)!==null}command(e){switch(e.do){case`play`:return this.play();case`pause`:return this.pause();case`toggle`:return this.toggle();case`speed`:return this.setSpeed(e.speed);case`pace`:return this.setPace(e.pace);case`follow`:return this.setFollow(e.on);case`seek`:return this.seek(e.position);case`seekTime`:return this.seekTime(e.t);case`step`:this.step(e.kind,e.direction);return;case`options`:return this.setOptions(e.options);default:return}}#g(){this.#l=null,this.#u=0,this.#d=null,this.#f=!1}tick(e){let t=this.replay,n=t.position,r=t.ready,i=t.store.live;if(this.#s&&(i||this.#p))n!==r&&t.seek(r),this.#p=i||t.store.length>r,this.#l=e,this.#u=0,this.#d=null,this.#f=!1;else if(this.#e){let n=this.#l===null?0:Nt(e-this.#l,0,this.#c);this.#l=e,this.#n===`tick`?this.#_(r):this.#n===`time`?this.#x(n,r):this.#b(n,r),t.position>=r?(this.#d=null,this.#u=0,i||t.store.length>r?this.#f=!0:(this.#f=!1,this.#e=!1,this.#l=null)):this.#f=!1}let a=this.state,o=this.#m,s=o===null||o.position!==a.position||o.playing!==a.playing||o.speed!==a.speed||o.pace!==a.pace||o.follow!==a.follow||o.following!==a.following||o.length!==a.length||o.live!==a.live||o.atEnd!==a.atEnd||o.waiting!==a.waiting||o.deadTime===null!=(a.deadTime===null)||o.deadTime!==null&&a.deadTime!==null&&o.deadTime.progress!==a.deadTime.progress;return this.#m=a,{moved:a.position!==n,changed:s,state:a}}#_(e){let t=this.replay.position;t<e&&this.replay.seek(t+1)}#v(e,t){if(this.#a<=0||e<=0)return 0;let n=this.replay.timeAt(t)-this.replay.timeAt(e);return n>this.#a?n:0}#y(e,t,n,r){let i=Nt(r,0,1),a=this.#d;a!==null&&a.afterIndex===t-1&&a.beforeIndex===n-1?a.progress!==i&&(this.#d={...a,progress:i}):this.#d={ms:e/1e3,afterIndex:t-1,beforeIndex:n-1,during:this.replay.doing(),progress:i}}#b(e,t){let n=this.replay,r=1e3/this.#r;this.#u+=e*this.#t;let i=n.position;for(let e=0;e<2e3&&i<t;e++){let e=n.find(`step`,1,i);if(e===null){if(n.store.live||n.store.length>t)e=t;else{i=t;break}}let a=this.#v(i,e),o=a>0?this.#o:0,s=i===0?0:r,c=s+o;if(this.#u<c){a>0&&this.#u>=s?(i!==n.position&&n.seek(i),this.#y(a,i,e,o===0?1:(this.#u-s)/o)):this.#d=null;break}this.#u-=c,this.#d=null,i=e}i!==n.position&&n.seek(i)}#x(e,t){let n=this.replay;this.#u+=e*this.#t;let r=1/(1e3*this.#i),i=n.position;for(this.#d=null;i<t;){let e=i===0?0:n.timeAt(i+1)-n.timeAt(i),t=this.#a>0&&e>this.#a,a=t?Math.min(this.#o,e*r):e*r;if(this.#u<a){t&&(i!==n.position&&n.seek(i),this.#y(e,i,i+1,a===0?1:this.#u/a));break}this.#u-=a,i++}i!==n.position&&n.seek(i)}};const Ft=33554432;function It(e){return e instanceof Uint8Array?e:new Uint8Array(e)}async function Lt(e,t,n,r){let i=e.writable.getWriter();i.write(t).catch(()=>{}),i.close().catch(()=>{});let a=e.readable.getReader(),o=[],s=0;for(;;){let{done:e,value:t}=await a.read();if(e)break;if(s+=t.byteLength,s>n)throw a.cancel().catch(()=>{}),new C(r);o.push(t)}let c=new Uint8Array(s),l=0;for(let e of o)c.set(e,l),l+=e.byteLength;return c}function Rt(e){return Lt(new CompressionStream(`gzip`),e,1/0,``)}async function zt(e,t){let n=`the recording is larger than ${Math.round(t/1048576)} MB when unpacked`;try{return await Lt(new DecompressionStream(`gzip`),e,t,n)}catch(e){throw e instanceof C?e:new C(`not a valid gzip file`)}}function Bt(e){return e.length>=2&&e[0]===31&&e[1]===139}function Vt(e){try{return new TextDecoder(`utf-8`,{fatal:!0}).decode(e)}catch{throw new C(`not a text file (invalid UTF-8)`)}}function Ht(e){let t;try{t=Ae(e.charCodeAt(0)===65279?e.slice(1):e)}catch(e){throw e instanceof C?e:new C(`not a nodejs-map recording`)}if(typeof t!=`object`||!t||t.header===void 0||t.header===null||!Array.isArray(t.events))throw new C(`not a nodejs-map recording`);return t}const J=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_`,Ut=(/* @__PURE__ */ new Int8Array(128)).fill(-1);for(let e=0;e<64;e++)Ut[J.charCodeAt(e)]=e;function Wt(e){let t=[],n=``,r=e.length;for(let i=0;i<r;i+=3){let a=e[i],o=i+1<r?e[i+1]:0,s=i+2<r?e[i+2]:0;n+=J[a>>2],n+=J[(a&3)<<4|o>>4],i+1<r&&(n+=J[(o&15)<<2|s>>6]),i+2<r&&(n+=J[s&63]),n.length>=8192&&(t.push(n),n=``)}return t.push(n),t.join(``)}function Gt(e){let t=e.length;if(t%4==1)throw new C(`the link is damaged (wrong length)`);let n=new Uint8Array(Math.floor(t*3/4)),r=0;for(let i=0;i<t;i+=4){let a=[0,0,0,0];for(let n=0;n<4&&!(i+n>=t);n++){let t=e.charCodeAt(i+n),r=t<128?Ut[t]:-1;if(r<0)throw new C(`the link is damaged (unexpected character)`);a[n]=r}let[o,s,c,l]=a;n[r++]=o<<2|s>>4,i+2<t&&(n[r++]=(s&15)<<4|c>>2),i+3<t&&(n[r++]=(c&3)<<6|l)}return n}async function Kt(e,t){let n=t?.maxBytes!==void 0&&t.maxBytes>0?t.maxBytes:268435456;if(typeof e==`string`){if(e.length>n)throw new C(`the recording is larger than ${Math.round(n/1048576)} MB`);return Ht(e)}if(!(e instanceof Uint8Array)&&!(e instanceof ArrayBuffer))throw new C(`not a recording: expected text or bytes`);let r=It(e);if(Bt(r))r=await zt(r,n);else if(r.byteLength>n)throw new C(`the recording is larger than ${Math.round(n/1048576)} MB`);return Ht(Vt(r))}async function qt(e,t){let n=new TextEncoder().encode(Oe(e));return t?.gzip===!0?Rt(n):n}async function Jt(e,t){let n=t?.maxChars!==void 0&&t.maxChars>0?Math.floor(t.maxChars):24e3,r=await Rt(new TextEncoder().encode(Oe(e))),i=6+Math.ceil(r.byteLength*4/3);if(i>n)return{ok:!1,reason:`too-big`,length:i,limit:n,message:`This recording is too big to share as a link (${i.toLocaleString(`en-US`)} characters; links work up to ${n.toLocaleString(`en-US`)}). Save it and share the file instead.`};let a=`rec=1.`+Wt(r);return{ok:!0,fragment:a,length:a.length,fitsEverywhere:a.length<=2e3}}async function Yt(e,t){if(typeof e!=`string`)throw new C(`not a recording link`);if(e.length>2097152)throw new C(`the link is too long to be a recording link`);let n=e.startsWith(`#`)?e.slice(1):e,r;for(let e of n.split(`&`))if(e.startsWith(`rec=`)){r=e.slice(4);break}if(r===void 0)throw new C(`this link does not contain a recording`);let i=r.indexOf(`.`);if(i<0||r.slice(0,i)!==`1`)throw new C(`this link was made by a newer version of nodejs-map`);let a=Gt(r.slice(i+1));if(!Bt(a))throw new C(`the link is damaged`);return Ht(Vt(await zt(a,t?.maxBytes!==void 0&&t.maxBytes>0?Math.min(t.maxBytes,Ft):Ft)))}const Xt=[`nextTick`,`microtask`,`timers`,`immediate`,`pool`,`io`,`close`],Zt=[`run`,`main`,`loop`,`items`,`timers`,`pool`,`debug`,`notes`,`focus`,`problems`],Qt=[`position`,`length`,`ready`,`live`,`version`,`t`,`endT`];function Y(e,t){if(e===t)return!0;if(typeof e!=`object`||typeof t!=`object`||e===null||t===null)return!1;if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!Y(e[n],t[n]))return!1;return!0}if(Array.isArray(t))return!1;let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r of n)if(!Y(e[r],t[r]))return!1;return!0}function $t(e,t,n,r){if(!r||e.length===0||t.length===0)return e.length===0&&t.length===0?null:{from:0,to:0,prepend:[],append:t.slice()};let i=n(e[0]),a=n(e[e.length-1]),o=n(t[0]),s=n(t[t.length-1]);if(i===o&&a===s)return null;let c=Math.max(i,o),l=Math.min(a,s)+1;if(c>=l)return{from:0,to:0,prepend:[],append:t.slice()};let u=[],d=[];for(let e of t){let t=n(e);t<c?u.push(e):t>=l&&d.push(e)}return{from:c,to:l,prepend:u,append:d}}const en=e=>e.seq,tn=e=>e.index;function nn(e,t){let n={},r={};if(e===null){for(let e of Qt)n[e]=t[e];for(let e of Zt)n[e]=t[e];for(let e of Xt)r[e]=t.queues[e];return{full:!0,set:n,queues:r,output:{total:t.output.total,chars:t.output.chars,from:0,to:0,prepend:[],append:t.output.chunks.slice()},log:{from:0,to:0,prepend:[],append:t.log.slice()}}}for(let r of Qt)e[r]!==t[r]&&(n[r]=t[r]);for(let r of Zt)Y(e[r],t[r])||(n[r]=t[r]);for(let n of Xt)Y(e.queues[n],t.queues[n])||(r[n]=t.queues[n]);let i=e.version===t.version,a=$t(e.output.chunks,t.output.chunks,en,i);return{full:!1,set:n,queues:r,output:a===null&&e.output.total===t.output.total&&e.output.chars===t.output.chars?null:{total:t.output.total,chars:t.output.chars,...a??{from:0,to:2**53-1,prepend:[],append:[]}},log:$t(e.log,t.log,tn,i)}}const rn={maxEntries:60,maxOutput:50,maxLog:30};var an=class{store;replay;player;#e;#t;#n;#r={...rn};#i=`full`;#a=null;#o=`internal`;#s=null;#c=!1;#l=!0;#u=!0;#d=-1/0;#f=null;#p=null;#m=!1;#h=0;constructor(e,n){this.#e=e,this.#t=n?.now??(typeof performance<`u`?()=>performance.now():()=>Date.now()),this.#n=n?.defer??((e,t)=>{let n=setTimeout(e,t);return()=>clearTimeout(n)}),this.store=new t,this.replay=new Mt(this.store,{eager:!1}),this.player=new Pt(this.replay),this.#g({op:`ready`})}handle(e){if(this.#m)return;let t=typeof e==`object`&&e&&`id`in e&&typeof e.id==`number`?e.id:null;try{this.#_(e)}catch(e){this.#g({op:`error`,re:t,message:X(e)})}this.#x()}dispose(){this.#m=!0,this.#f!==null&&this.#f(),this.#p!==null&&this.#p(),this.#f=null,this.#p=null,this.player.dispose(),this.replay.dispose()}#g(e,t){this.#m||this.#e(e,t)}#_(e){if(typeof e!=`object`||!e)throw TypeError(`not a request`);switch(e.op){case`reset`:this.#h++,this.store.reset(),this.player.pause(),this.player.setFollow(!0),this.#y();break;case`events`:{let t=this.store.apply({base:e.base,events:e.events});if(t.rejected!==null)throw RangeError(t.rejected===`gap`?`events refused: the batch starts at ${e.base} but only ${t.length} events are known`:`events refused: the batch is not of the form { base, events }`);this.#y();break}case`ended`:this.store.end(),this.#y();break;case`open`:this.#v(e.id,Kt(e.data));break;case`openFragment`:this.#v(e.id,Yt(e.fragment));break;case`save`:{let t=e.id;qt({header:e.header,events:this.store.events},{gzip:e.gzip===!0}).then(e=>this.#g({op:`saved`,re:t,bytes:e},e.buffer instanceof ArrayBuffer?[e.buffer]:void 0),e=>this.#g({op:`error`,re:t,message:X(e)}));break}case`share`:{let t=e.id;Jt({header:e.header,events:this.store.events}).then(e=>this.#g({op:`shared`,re:t,result:e}),e=>this.#g({op:`error`,re:t,message:X(e)}));break}case`player`:this.player.command(e.cmd),this.#l=!0;break;case`tick`:this.#o!==`external`&&(this.#o=`external`,this.#f!==null&&this.#f(),this.#f=null),this.#C(typeof e.now==`number`?e.now:this.#t());break;case`configure`:e.view!==void 0&&(this.#r={...this.#r,...e.view},this.#l=!0),(e.views===`full`||e.views===`patch`)&&(this.#i=e.views,this.#a=null,this.#l=!0),(e.clock===`external`||e.clock===`internal`)&&(this.#o=e.clock),e.timeline!==void 0&&(this.#s=e.timeline===null?null:{width:e.timeline.width,axis:e.timeline.axis===`time`?`time`:`index`},this.#u=!0,this.#d=-1/0),e.markers!==void 0&&(this.#c=e.markers===!0,this.#u=!0,this.#d=-1/0);break;case`query`:this.#g({op:`answer`,re:e.id,answer:this.replay.query(e.q)});break;default:throw TypeError(`unknown request`)}}#v(e,t){let n=++this.#h;t.then(t=>{this.#m||n!==this.#h||(this.store.load(t.events),this.player.pause(),this.#y(),this.#g({op:`opened`,re:e,header:t.header,events:t.events.length}),this.#x())},t=>this.#g({op:`error`,re:e,message:X(t)}))}#y(){this.#l=!0,this.#u=!0,this.#b()}#b(){this.#p!==null||this.#m||this.replay.ready>=this.store.length||(this.#p=this.#n(()=>{this.#p=null;let e=this.replay.pump(6);this.#l=!0,this.#u=!0,e&&this.#b(),this.#x()},0))}#x(){this.#m||this.#o!==`internal`||this.#f!==null||this.#S()&&(this.#f=this.#n(()=>{this.#f=null,this.#C(this.#t()),this.#x()},16))}#S(){if(this.#l||this.#u)return!0;let e=this.player.state;return e.playing||e.follow&&e.live&&e.position<e.length}#C(e){let t=this.player.tick(e);if(t.changed&&(this.#l=!0),this.#l){this.#l=!1;let e=this.replay.view(this.#r);this.#i===`patch`?(this.#g({op:`patch`,patch:nn(this.#a,e),player:t.state}),this.#a=e):this.#g({op:`view`,view:e,player:t.state})}this.#u&&(this.#s!==null||this.#c)?(!this.store.live&&this.replay.ready>=this.store.length||e-this.#d>=100)&&(this.#u=!1,this.#d=e,this.#s!==null&&this.#g({op:`timeline`,summary:this.replay.timeline(this.#s.width,this.#s.axis)}),this.#c&&this.#g({op:`markers`,markers:this.replay.markers()})):this.#s===null&&!this.#c&&(this.#u=!1)}};function X(e){return e instanceof Error?e.message:String(e)}const Z={uvRun:{id:`o:loop.run`,meaning:`uv_run: the event loop. Runs due timers once, then turns: pending, idle, prepare, poll, pending again, check, close, timers.`},phaseTimers:{id:`o:phase.timers`,meaning:`Timers phase: uv__run_timers runs every libuv timer whose time has come (Node uses one for all JS timers).`},phasePending:{id:`o:phase.pending`,meaning:`Pending phase: callbacks deferred from the previous turn; on Windows, completed I/O requests run here.`},phaseIdle:{id:`o:phase.idle`,meaning:`Idle phase: idle handles; Node keeps one active while immediates are queued so poll does not block.`},phasePrepare:{id:`o:phase.prepare`,meaning:`Prepare phase: prepare handles, just before the loop waits for I/O.`},phasePoll:{id:`o:phase.poll`,meaning:`Poll phase: waits for I/O (epoll, kqueue or IOCP) up to the next timer and runs what is ready.`},phaseCheck:{id:`o:phase.check`,meaning:`Check phase: check handles; Node runs setImmediate callbacks here.`},phaseClosing:{id:`o:phase.close`,meaning:`Close phase: close callbacks of handles closed during this turn.`},loopTime:{id:`o:loop.updateTime`,meaning:`The loop clock: libuv reads the time once per turn; timers compare against this cached time.`},spinEventLoop:{id:`o:loop.spin`,meaning:`Node's loop driver: calls uv_run until there is no more work, then emits beforeExit.`},tickEnqueue:{id:`o:tick.nextTick`,meaning:`process.nextTick: pushes a callback onto the nextTick queue.`},tickDrain:{id:`o:tick.drain`,meaning:`processTicksAndRejections: runs the nextTick queue, then microtasks, until both are empty.`},runNextTicks:{id:`o:tick.runNextTicks`,meaning:`runNextTicks: drains nextTicks and microtasks between two timer or immediate callbacks.`},microtaskEnqueue:{id:`o:microtask.queueMicrotask`,meaning:`queueMicrotask: puts a callback on V8's microtask queue.`},microtaskCallback:{id:`o:microtask.runCallback`,meaning:`runMicrotask: the wrapper that runs a queueMicrotask callback with async_hooks before/after.`},microtaskCheckpoint:{id:`o:microtask.checkpoint`,meaning:`MicrotaskQueue::PerformCheckpoint: V8 runs all queued microtasks if it is not already doing so.`},microtaskDrain:{id:`o:microtask.run`,meaning:`MicrotaskQueue::RunMicrotasks: V8 runs every queued microtask (promise reactions, queueMicrotask callbacks).`},runMicrotasksBinding:{id:`o:microtask.binding`,meaning:`runMicrotasks(): the C++ binding processTicksAndRejections calls to make V8 drain the microtask queue.`},promiseThen:{id:`o:v8.promiseThen`,meaning:`Promise.prototype.then (V8 Torque builtin).`},performPromiseThen:{id:`o:v8.performPromiseThen`,meaning:`PerformPromiseThen: stores the reaction, or queues a reaction job at once if the promise is already settled.`},triggerPromiseReactions:{id:`o:v8.triggerReactions`,meaning:`TriggerPromiseReactions: when a promise settles, turns each stored reaction into a queued job.`},promiseReactionEnqueue:{id:`o:v8.enqueueMicrotask`,meaning:`EnqueueMicrotask builtin: where a promise reaction job (or any microtask) is appended to the microtask queue.`},runMicrotasksBuiltin:{id:`o:v8.runMicrotasksBuiltin`,meaning:`RunMicrotasks builtin: the loop inside V8 that takes jobs off the microtask queue.`},runSingleMicrotask:{id:`o:v8.runSingleMicrotask`,meaning:`RunSingleMicrotask: runs one job, dispatching on its kind (callable, promise reaction, ...).`},promiseReactionRun:{id:`o:v8.promiseReactionJob`,meaning:`PromiseReactionJob: runs a .then/.catch handler with the settled value and settles the derived promise.`},timerSet:{id:`o:timers.setTimeout`,meaning:`setTimeout: creates a Timeout and inserts it into the timer lists.`},setInterval:{id:`o:timers.setInterval`,meaning:`setInterval: a Timeout that is re-inserted after each run.`},timerInsert:{id:`o:timers.insert`,meaning:`insert: appends the timer to the list for its duration; a new earliest list reschedules the libuv timer.`},scheduleTimer:{id:`o:timers.scheduleTimer`,meaning:`Environment::ScheduleTimer: starts the single libuv timer for the earliest JS timer.`},timersNative:{id:`o:timers.runTimers`,meaning:`Environment::RunTimers: the libuv timer callback; calls processTimers in JS and reschedules.`},timersProcess:{id:`o:timers.processTimers`,meaning:`processTimers: walks the due timer lists in expiry order.`},listOnTimeout:{id:`o:timers.listOnTimeout`,meaning:`listOnTimeout: runs each due timer of one list; nextTicks and microtasks run between timers.`},uvRunTimers:{id:`o:phase.timers`,meaning:`uv__run_timers: libuv runs timers whose timeout is not later than the loop time.`},immediateSet:{id:`o:immediate.setImmediate`,meaning:`setImmediate: creates an Immediate and appends it to the immediate queue.`},immediateNative:{id:`o:immediate.check`,meaning:`Environment::CheckImmediate: the check-phase callback that calls processImmediate.`},immediateProcess:{id:`o:immediate.process`,meaning:`processImmediate: runs the queued immediates; nextTicks and microtasks run between them.`},toggleImmediateRef:{id:`o:immediate.toggleRef`,meaning:`Environment::ToggleImmediateRef: starts/stops an idle handle so poll does not block while immediates wait.`},poolQueueWork:{id:`o:pool.queue_work`,meaning:`uv_queue_work: the public "run this function on the thread pool" call.`},poolSubmit:{id:`o:pool.submit`,meaning:`uv__work_submit: queues work for the pool (starts the threads on first use).`},poolPost:{id:`o:pool.post`,meaning:`post: appends to the shared work queue and wakes an idle pool thread.`},poolWorker:{id:`o:pool.worker`,meaning:`worker: a pool thread; waits, runs one work item, posts the result back.`},poolDone:{id:`o:pool.done`,meaning:`uv__work_done: on the main thread, runs the after-work callbacks of finished items.`},poolWake:{id:`o:pool.asyncSend`,meaning:`uv_async_send: wakes the loop from another thread (eventfd/pipe on Unix, a completion packet on Windows).`},scheduleWork:{id:`o:cb.ScheduleWork`,meaning:`ThreadPoolWork::ScheduleWork: Node's wrapper around uv_queue_work for fs, crypto and zlib jobs.`},asyncWrapMakeCallback:{id:`o:cb.MakeCallback`,meaning:`AsyncWrap::MakeCallback: calls a JS callback for an async resource (async_hooks before/after).`},makeCallback:{id:`o:cb.InternalMakeCallback`,meaning:`InternalMakeCallback: opens a callback scope, calls the function, closes the scope.`},callbackScopeClose:{id:`o:cb.ScopeClose`,meaning:`InternalCallbackScope::Close: after a callback, runs microtasks or the nextTick drain.`},inspectorPause:{id:`o:inspector.pause`,meaning:`runMessageLoopOnPause: the main thread waits here while a breakpoint holds JavaScript.`},fsReadFile:{id:`o:fs.readFile`,meaning:`fs.readFile: small files in one thread-pool job (ReadFileJob), large ones in chunks.`},fsReadFileJobRun:{id:`o:fs.ReadFileJob.Run`,meaning:`ReadFileJob::Run: schedules the whole read on the thread pool.`},fsReadFileJobWork:{id:`o:fs.ReadFileJob.DoThreadPoolWork`,meaning:`ReadFileJob::DoThreadPoolWork: open, fstat, read, close on a pool thread.`},fsReadFileJobAfter:{id:`o:fs.ReadFileJob.AfterThreadPoolWork`,meaning:`ReadFileJob::AfterThreadPoolWork: builds the Buffer and calls back into JS.`},fsReqCallback:{id:`o:fs.reqCallback`,meaning:`FSReqCallback::Resolve: delivers the result of an async fs request to its JS callback.`},fsReqPromise:{id:`o:fs.reqPromise`,meaning:`FSReqPromise::Resolve: settles the promise of an fs/promises request.`},cryptoPbkdf2:{id:`o:crypto.pbkdf2`,meaning:`crypto.pbkdf2: creates a PBKDF2Job and runs it on the thread pool.`},cryptoRandomBytes:{id:`o:crypto.randomBytes`,meaning:`crypto.randomBytes: creates a RandomBytesJob and runs it on the thread pool.`},cryptoJobRun:{id:`o:crypto.jobRun`,meaning:`CryptoJob::Run: runs a crypto job now (sync) or schedules it on the thread pool (async).`},cryptoDeriveBitsWork:{id:`o:crypto.deriveBitsWork`,meaning:`DeriveBitsJob::DoThreadPoolWork: the pool-thread side of pbkdf2, randomBytes, scrypt, hkdf...`},cryptoPbkdf2DeriveBits:{id:`o:crypto.pbkdf2DeriveBits`,meaning:`PBKDF2Traits::DeriveBits: the PBKDF2 computation (OpenSSL) on a pool thread.`},cryptoRandomBytesDeriveBits:{id:`o:crypto.randomBytesDeriveBits`,meaning:`RandomBytesTraits::DeriveBits: fills the buffer with random bytes on a pool thread.`},cryptoJobAfter:{id:`o:crypto.jobAfter`,meaning:`CryptoJob::AfterThreadPoolWork: back on the main thread, calls job.ondone in JS.`},zlibProcessChunk:{id:`o:zlib.processChunk`,meaning:`processChunk: hands one chunk to the native zlib handle (async write).`},zlibWrite:{id:`o:zlib.write`,meaning:`CompressionStream::Write: queues compression work on the thread pool.`},zlibWork:{id:`o:zlib.work`,meaning:`ZlibContext::DoThreadPoolWork: runs deflate/inflate on a pool thread.`},zlibAfter:{id:`o:zlib.after`,meaning:`CompressionStream::AfterThreadPoolWork: back on the main thread, calls the JS write callback.`},dnsLookup:{id:`o:dns.lookup`,meaning:`dns.lookup: asks the OS resolver (getaddrinfo) on the thread pool, not c-ares.`},dnsGetAddrInfo:{id:`o:dns.getAddrInfo`,meaning:`GetAddrInfo (C++): starts uv_getaddrinfo with AfterGetAddrInfo as callback.`},uvGetaddrinfo:{id:`o:dns.uvGetaddrinfo`,meaning:`uv_getaddrinfo: queues the lookup as slow I/O work on the thread pool.`},getaddrinfoWork:{id:`o:dns.getaddrinfoWork`,meaning:`uv__getaddrinfo_work: calls the OS getaddrinfo on a pool thread.`},dnsAfterGetAddrInfo:{id:`o:dns.afterGetAddrInfo`,meaning:`AfterGetAddrInfo: back on the main thread, converts the addresses and calls oncomplete in JS.`},streamRead:{id:`o:net.streamRead`,meaning:`LibuvStreamWrap::OnUvRead: data arrived on a TCP socket, pipe or TTY; calls onread in JS.`},streamAfterWrite:{id:`o:net.afterWrite`,meaning:`LibuvStreamWrap::AfterUvWrite: a write finished; calls the write callback.`},streamAfterShutdown:{id:`o:net.afterShutdown`,meaning:`LibuvStreamWrap::AfterUvShutdown: the write side was shut down.`},onConnection:{id:`o:net.onConnection`,meaning:`ConnectionWrap::OnConnection: a server accepted a connection.`},afterConnect:{id:`o:net.afterConnect`,meaning:`ConnectionWrap::AfterConnect: an outgoing connect finished.`},udpRecv:{id:`o:net.udpRecv`,meaning:`UDPWrap::OnRecv: a datagram arrived.`},processExit:{id:`o:proc.onExit`,meaning:`ProcessWrap::OnExit: a child process exited.`},fsEvent:{id:`o:fs.watchEvent`,meaning:`FSEventWrap::OnEvent: fs.watch saw a change.`},statWatcher:{id:`o:fs.statWatcher`,meaning:`StatWatcher::Callback: fs.watchFile polled a changed stat.`},httpIncoming:{id:`o:http.incoming`,meaning:`IncomingMessage: a received HTTP request (server) or response (client).`},httpClientRequest:{id:`o:http.clientRequest`,meaning:`ClientRequest: an outgoing HTTP request.`},udpSendDone:{id:`o:net.udpSendDone`,meaning:`UDPWrap::OnSendDone: a datagram send finished; calls oncomplete in JS.`},dnsChannel:{id:`o:dns.channel`,meaning:`ChannelWrap::New: creates the c-ares resolver channel used by dns.resolve* and dns.Resolver.`},dnsQueryResponse:{id:`o:dns.queryResponse`,meaning:`QueryWrap::QueueResponseCallback: defers a c-ares answer with SetImmediate, so its callback runs in the check phase.`},nativeImmediatesRun:{id:`o:immediate.native`,meaning:`Environment::RunAndClearNativeImmediates: runs C++ SetImmediate callbacks (such as c-ares answers) from CheckImmediate.`},streamShutdownQueue:{id:`o:uv.shutdown`,meaning:`uv_shutdown: on Unix, with no writes pending, puts the stream on the pending queue (uv__io_feed); on Windows (TCP), queues a pending request.`},streamShutdownRun:{id:`o:uv.shutdownDone`,meaning:`Where the shutdown callback runs: uv__drain on Unix (from the pending phase), uv__process_tcp_shutdown_req on Windows (TCP).`},uvClose:{id:`o:loop.uvClose`,meaning:`uv_close: starts closing a handle; its close callback always runs later, in the close phase.`},closeCallbacks:{id:`o:loop.finishClose`,meaning:`Where a close callback runs: uv__finish_close (called by uv__run_closing_handles) on Unix, uv__process_endgames on Windows.`},handleOnClose:{id:`o:cb.handleOnClose`,meaning:`HandleWrap::OnClose: Node's close callback for every handle; calls the JS handle's onclose.`},streamFinished:{id:`o:streams.eos`,meaning:`eos (stream.finished): calls back once a stream has ended, finished or errored; used by pipeline.`},messagePortOnMessage:{id:`o:worker.onMessage`,meaning:`MessagePort::OnMessage: delivers queued messages from another thread to the JS listener of the port.`},workerExit:{id:`o:worker.onExit`,meaning:`Worker::JoinThread: after the worker thread stopped, calls onexit in the parent thread.`}};Z.phaseTimers.id,Z.phasePending.id,Z.phaseIdle.id,Z.phasePrepare.id,Z.phasePoll.id,Z.phaseCheck.id,Z.phaseClosing.id;const on={Timeout:{id:Z.listOnTimeout.id,title:`setTimeout / setInterval timer`,meaning:`setTimeout / setInterval timer; its callback runs from listOnTimeout.`},Immediate:{id:Z.immediateProcess.id,title:`setImmediate`,meaning:`setImmediate; its callback runs from processImmediate in the check phase.`},TickObject:{id:Z.tickDrain.id,title:`process.nextTick`,meaning:`process.nextTick; its callback runs from processTicksAndRejections.`},PROMISE:{id:Z.promiseReactionRun.id,title:`promise`,meaning:`A promise (reported while an async hook is enabled); its reactions run as microtasks.`},Microtask:{id:Z.microtaskCallback.id,title:`queueMicrotask`,meaning:`queueMicrotask callback; runs from the microtask queue via runMicrotask.`},FSREQCALLBACK:{id:Z.fsReqCallback.id,title:`fs request (callback)`,meaning:`Callback-style fs request. fs.readFile's ReadFileJob reports this type too (its callback comes from ReadFileJob::AfterThreadPoolWork).`},FSREQPROMISE:{id:Z.fsReqPromise.id,title:`fs/promises request`,meaning:`fs/promises request.`},PBKDF2REQUEST:{id:Z.cryptoJobAfter.id,title:`pbkdf2 request`,meaning:`crypto.pbkdf2 job; work in PBKDF2Traits::DeriveBits on the pool.`},RANDOMBYTESREQUEST:{id:Z.cryptoJobAfter.id,title:`randomBytes request`,meaning:`crypto.randomBytes / randomFill job; work in RandomBytesTraits::DeriveBits on the pool.`},SCRYPTREQUEST:{id:Z.cryptoJobAfter.id,title:`scrypt request`,meaning:`crypto.scrypt job on the pool.`},GETADDRINFOREQWRAP:{id:Z.dnsAfterGetAddrInfo.id,title:`dns.lookup request`,meaning:`dns.lookup request; getaddrinfo runs on the pool.`},ZLIB:{id:Z.zlibAfter.id,title:`zlib stream`,meaning:`zlib stream; each chunk is compressed on the pool.`},TCPWRAP:{id:Z.streamRead.id,title:`TCP connection`,meaning:`TCP socket handle; reads arrive in the poll phase.`},TCPSERVERWRAP:{id:Z.onConnection.id,title:`TCP server`,meaning:`TCP server handle; new connections arrive in the poll phase.`},TCPCONNECTWRAP:{id:Z.afterConnect.id,title:`TCP connect request`,meaning:`Outgoing TCP connect request.`},PIPEWRAP:{id:Z.streamRead.id,title:`pipe`,meaning:`Pipe handle (also stdio pipes).`},PIPECONNECTWRAP:{id:Z.afterConnect.id,title:`pipe connect request`,meaning:`Outgoing pipe connect request.`},TTYWRAP:{id:Z.streamRead.id,title:`terminal (TTY)`,meaning:`TTY handle (terminal stdio).`},WRITEWRAP:{id:Z.streamAfterWrite.id,title:`stream write`,meaning:`A stream write request.`},SHUTDOWNWRAP:{id:Z.streamAfterShutdown.id,title:`stream shutdown`,meaning:`A stream shutdown request; on Unix uv__drain runs its callback - in the pending phase when no write was waiting, else in poll after the last write.`},UDPWRAP:{id:Z.udpRecv.id,title:`UDP socket`,meaning:`UDP socket handle.`},PROCESSWRAP:{id:Z.processExit.id,title:`child process`,meaning:`Child process handle.`},FSEVENTWRAP:{id:Z.fsEvent.id,title:`fs.watch watcher`,meaning:`fs.watch handle.`},STATWATCHER:{id:Z.statWatcher.id,title:`fs.watchFile watcher`,meaning:`fs.watchFile handle.`},HTTPINCOMINGMESSAGE:{id:Z.httpIncoming.id,title:`HTTP incoming message`,meaning:`HTTP incoming message (server request or client response).`},QUERYWRAP:{id:Z.dnsQueryResponse.id,title:`DNS query (dns.resolve*)`,meaning:`A c-ares query; the answer is deferred with SetImmediate, so the callback runs in the check phase.`},DNSCHANNEL:{id:Z.dnsChannel.id,title:`DNS resolver (c-ares)`,meaning:`The c-ares channel behind dns.resolve* and dns.Resolver; created when the dns module loads.`},PIPESERVERWRAP:{id:Z.onConnection.id,title:`pipe server`,meaning:`Pipe (named pipe / Unix socket) server handle; new connections arrive in the poll phase.`},UDPSENDWRAP:{id:Z.udpSendDone.id,title:`UDP send`,meaning:`A UDP send request.`},STREAM_END_OF_STREAM:{id:Z.streamFinished.id,title:`stream finished callback`,meaning:`stream.finished / pipeline callback, bound to the context where it was registered.`},MESSAGEPORT:{id:Z.messagePortOnMessage.id,title:`MessagePort (worker messages)`,meaning:`A message channel between threads; messages are delivered by MessagePort::OnMessage.`},WORKER:{id:Z.workerExit.id,title:`worker thread`,meaning:`A worker_threads Worker as seen from the parent thread.`},HTTPCLIENTREQUEST:{id:Z.httpClientRequest.id,title:`HTTP client request`,meaning:`HTTP client request.`}};Object.fromEntries(Object.entries(on).map(([e,t])=>[e,t.id]));const sn={nextTick:`nextTick queue`,microtask:`Microtask queue`,timers:`Timers`,immediate:`Immediates`,pool:`Thread pool requests`,io:`Pending I/O`,close:`Close callbacks`},cn={timers:`timers`,pending:`pending`,idle:`idle`,prepare:`prepare`,poll:`poll`,check:`check`,closing:`close`},ln=new Intl.NumberFormat(`en`,{maximumFractionDigits:1,minimumFractionDigits:1}),un=new Intl.NumberFormat(`en`,{maximumFractionDigits:3,minimumFractionDigits:3}),dn=new Intl.NumberFormat(`en`,{maximumFractionDigits:0});function fn(e){if(!Number.isFinite(e))return`-`;let t=Math.abs(e);return t<1e3?`${dn.format(e)} µs`:t<1e6?`${un.format(e/1e3)} ms`:`${un.format(e/1e6)} s`}function Q(e){return Number.isFinite(e)?Math.abs(e)<1e3?`${ln.format(e)} ms`:`${ln.format(e/1e3)} s`:`-`}function pn(e){let t=e.replace(/[?#].*$/,``).split(/[\\/]/);for(let e=t.length-1;e>=0;e--){let n=t[e];if(n)try{return decodeURIComponent(n)}catch{return n}}return e}function $(e,t=160){let n=``;for(let r of e){if(n.length>=t)return`${n}…`;let e=r.codePointAt(0);n+=r===`
|
|
7
|
+
`?`⏎`:r===` `?` `:e<32||e===127?`�`:r}return n}const mn=[`run`,`output`,`callbacks`,`queues`,`loop`,`timers`,`pool`,`items`,`debug`,`signals`],hn={"run.start":`run`,"run.end":`run`,note:`run`,output:`output`,"item.new":`items`,"item.gone":`items`,"promise.settled":`items`,"callback.start":`callbacks`,"callback.end":`callbacks`,"timer.set":`timers`,"timer.fired":`timers`,"loop.sample":`signals`,scope:`signals`,"pool.thread":`signals`,signal:`signals`,"queue.add":`queues`,"queue.remove":`queues`,"loop.turn":`loop`,"phase.enter":`loop`,"phase.leave":`loop`,"pool.queued":`pool`,"pool.started":`pool`,"pool.finished":`pool`,"pool.posted":`pool`,"pool.delivered":`pool`,"pool.cancelled":`pool`,"pool.size":`pool`,"pool.link":`pool`,"debug.paused":`debug`,"debug.resumed":`debug`,"gate.stopped":`debug`,"gate.released":`debug`,"clock.frozen":`debug`,"clock.unfrozen":`debug`};function gn(e){switch(e.k){case`run.start`:return`Run started: ${$(e.program,60)} on Node ${e.node.version} (${e.mode===`debug`?`debug`:`free run`}, pool size ${e.poolSize})`;case`run.end`:return e.signal?`Run ended by signal ${e.signal}`:`Run ended with exit code ${String(e.code)}`;case`output`:return`${e.stream}: ${$(e.text,120)}`;case`item.new`:return`New ${e.label?`${$(e.label,40)} (${e.type})`:e.type} #${e.id}, created during #${e.trigger}${e.loc?` at ${pn(e.loc.url)}:${e.loc.line}`:``}`;case`callback.start`:return`${e.close===!0?`Close callback`:`Callback`} of ${e.type} #${e.id} started`;case`callback.end`:return`Callback of #${e.id} returned`;case`item.gone`:return`#${e.id} destroyed`;case`promise.settled`:return`Promise #${e.id} settled`;case`timer.set`:return`${e.repeat?`setInterval`:`setTimeout`} #${e.id}: ${Q(e.delayMs)}`;case`loop.sample`:return`Loop counters: turn ${e.loopCount}, ${e.events} events, ${e.eventsWaiting} waiting`;case`scope`:return`Node scope ${$(e.name,40)} lasted ${fn(e.durUs)}`;case`pool.thread`:return`A pool thread ${e.edge===`start`?`started`:`finished`} ${$(e.name,40)}`;case`signal`:return`${$(e.cat,40)} / ${$(e.name,40)} (${$(e.ph,4)})`;case`queue.add`:return`#${e.id} waits in ${sn[e.queue]??e.queue}`;case`queue.remove`:return`#${e.id} left ${sn[e.queue]??e.queue} (${e.why===`cancel`?`cancelled`:`gone`})`;case`loop.turn`:return`Loop turn ${e.n}`;case`phase.enter`:return`Entered the ${cn[e.phase]??e.phase} phase`;case`phase.leave`:return`Left the ${cn[e.phase]??e.phase} phase`;case`timer.fired`:return`Node's timer is due${e.lateMs===void 0?``:`, ${Q(e.lateMs)} late`}`;case`pool.queued`:return`Pool job ${$(e.job,24)} queued (${e.kind}${e.op?` ${$(e.op,30)}`:``})`;case`pool.started`:return`Pool thread ${e.thread} started job ${$(e.job,24)}`;case`pool.finished`:return`Pool thread ${e.thread} finished job ${$(e.job,24)}`;case`pool.posted`:return`Pool thread ${e.thread} posted the result of job ${$(e.job,24)} to the loop`;case`pool.delivered`:return`The loop took the result of pool job ${$(e.job,24)}`;case`pool.cancelled`:return`Pool job ${$(e.job,24)} was cancelled before a thread took it`;case`pool.size`:return`The thread pool has ${e.size} threads (the program changed the size before first use)`;case`pool.link`:return`Pool job ${$(e.job,24)} belongs to #${e.id}`;case`debug.paused`:{let t=e.frames[0];return`Paused (${e.reason})${t?` at ${pn(t.loc.url)}:${t.loc.line}`:``}`}case`debug.resumed`:return`Resumed after ${Q(e.pausedMs)}`;case`gate.stopped`:return`Stopped at the ${e.gate} gate${e.phase?` (${cn[e.phase]??e.phase})`:``}`;case`gate.released`:return`Gate released after ${Q(e.stoppedMs)}`;case`clock.frozen`:return`Loop clock frozen`;case`clock.unfrozen`:return`Loop clock running again; ${Q(e.hiddenMs)} hidden from the program`;case`note`:return`${e.level===`warn`?`Warning from the tool`:`Note from the tool`}: ${$(e.text,220)}`;default:return String(e.k)}}const _n={groups:mn,certainty:[`observed`,`inferred`,`model`]},vn={observed:1,inferred:2,model:4};function yn(e){return`${[...e.groups].sort().join(`,`)}|${[...e.certainty].sort().join(`,`)}`}function bn(e,t){let n;try{n=gn(e)}catch{n=String(e.k)}return{index:t,t:e.t,k:e.k,c:e.c,src:e.src,rule:e.rule??null,at:e.at??null,approx:e.tq!==void 0,text:n}}function xn(e){switch(e.k){case`run.start`:return`running`;case`run.end`:return`ended`;case`debug.paused`:return`paused`;case`gate.stopped`:return`gated`;case`debug.resumed`:case`gate.released`:return`running`;default:return null}}var Sn=class{#e=[];#t=/* @__PURE__ */ new Uint32Array(1024);#n=0;#r=0;#i=yn(_n);#a=new Set(mn);#o=7;#s=!0;#c=[];#l=null;get length(){return this.#e.length}reset(){this.#e=[],this.#n=0,this.#r=0,this.#c=[],this.#l=null}apply(e,t){if(!Number.isInteger(e)||e<0||e>this.#e.length)return!1;if(e<this.#e.length){if(this.#e.length=e,this.#r>e){this.#r=e;let t=this.#n;for(;t>0&&this.#t[t-1]>=e;)t--;this.#n=t}for(;this.#c.length>0&&this.#c[this.#c.length-1][0]>=e;)this.#c.pop()}for(let e=0;e<t.length;e++){let n=t[e],r=this.#e.length;if(this.#e.push(n),typeof n!=`object`||!n)continue;let i=xn(n);i&&this.#c.push([r,i]),n.k===`run.start`&&(this.#l=n.mode===`debug`?`debug`:`free`)}return!0}tail(){let e=this.#c[this.#c.length-1];return{status:e?e[1]:`idle`,mode:this.#l,length:this.#e.length}}#u(e){if(typeof e!=`object`||!e)return this.#s;if(this.#s)return!0;let t=hn[e.k];return t!==void 0&&!this.#a.has(t)?!1:((vn[e.c]??0)&this.#o)!==0}#d(e){let t=yn(e);t!==this.#i&&(this.#i=t,this.#a=new Set(e.groups),this.#o=e.certainty.reduce((e,t)=>e|(vn[t]??0),0),this.#s=this.#a.size===mn.length&&this.#o===7,this.#n=0,this.#r=0)}#f(){if(this.#s)this.#r=this.#e.length;else{for(let e=this.#r;e<this.#e.length;e++)if(this.#u(this.#e[e])){if(this.#n===this.#t.length){let e=new Uint32Array(this.#t.length*2);e.set(this.#t),this.#t=e}this.#t[this.#n++]=e}this.#r=this.#e.length}}#p(e){if(this.#s)return Math.min(e,this.#e.length)-1;let t=0,n=this.#n;for(;t<n;){let r=t+n>>1;this.#t[r]<e?t=r+1:n=r}return t-1}window(e,t,n,r){this.#d(e),this.#f();let i=this.#s?this.#e.length:this.#n,a=Math.max(0,Math.min(Math.trunc(t),i)),o=Math.max(a,Math.min(a+Math.max(0,Math.min(Math.trunc(n),500)),i)),s=[];for(let e=a;e<o;e++){let t=this.#s?e:this.#t[e],n=this.#e[t];if(n===void 0)break;s.push(typeof n==`object`&&n?bn(n,t):{index:t,t:0,k:`?`,c:`model`,src:`helper`,rule:null,at:null,approx:!1,text:`Malformed event`})}return{total:i,offset:a,rows:s,cursorRow:this.#p(r),length:this.#e.length,all:this.#s,position:r}}eventAt(e){return this.#e[e]??null}};function Cn(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.op===`events`&&typeof t.run==`string`&&typeof t.base==`number`&&Array.isArray(t.events)}function wn(e){return e instanceof Error?e.message:String(e)}const Tn=5e3;var En=class{#e;#t;#n=new Sn;#r=null;#i=!1;#a=/* @__PURE__ */ new Set;#o=``;#s=0;constructor(e,t){this.#e=e,this.#t=new an((t,n)=>e(t,n),t)}handle(e){try{e.op.startsWith(`app.`)?this.#u(e):(this.#t.handle(e),e.op===`tick`&&this.#e({op:`app.ticked`}))}catch(t){this.#e({op:`app.error`,re:`id`in e&&typeof e.id==`number`?e.id:null,message:wn(t)})}}dispose(){this.#t.dispose()}#c(){this.#s++,this.#r!==null&&this.#a.add(this.#r),this.#r=null,this.#i=!1,this.#n.reset(),this.#t.handle({op:`reset`})}#l(){let e=this.#n.tail(),t=`${e.status}|${String(e.mode)}|${String(this.#r)}`;t!==this.#o&&(this.#o=t,this.#e({op:`app.tail`,tail:e,run:this.#r}))}#u(e){switch(e.op){case`app.newRun`:this.#c(),this.#i=!0,this.#l();return;case`app.run`:if(this.#a.has(e.run))return;(this.#i||this.#r===null)&&(this.#r=e.run,this.#i=!1,this.#l());return;case`app.eventsText`:{let t;try{t=JSON.parse(e.text)}catch{this.#e({op:`app.error`,re:null,message:`The helper sent an events message that is not valid JSON.`});return}if(!Cn(t)||this.#a.has(t.run))return;if(this.#r===null){if(!this.#i)return;this.#r=t.run,this.#i=!1}else if(t.run!==this.#r)return;if(!this.#n.apply(t.base,t.events)){this.#e({op:`app.error`,re:null,message:`Events from the helper arrived with a gap; the view may be incomplete.`});return}this.#t.handle({op:`events`,base:t.base,events:t.events}),this.#l();return}case`app.runEnded`:if(e.run!==this.#r)return;this.#t.handle({op:`ended`});return;case`app.open`:this.#d(e.id,()=>Kt(e.data));return;case`app.openFragment`:this.#d(e.id,()=>Yt(e.fragment));return;case`app.close`:this.#c(),this.#l();return;case`app.log`:this.#e({op:`app.log`,re:e.id,window:this.#n.window(e.filter,e.offset,e.limit,e.position)});return}}async#d(e,t){this.#c();let n=this.#s,r;try{r=await t()}catch(t){this.#e({op:`app.error`,re:e,message:wn(t)});return}if(n!==this.#s)this.#e({op:`app.error`,re:e,message:`Opening was cancelled: another run or recording was opened meanwhile.`});else try{let t=r.events;this.#t.handle({op:`player`,cmd:{do:`follow`,on:!1}}),this.#t.handle({op:`player`,cmd:{do:`pause`}});for(let e=0;e<t.length||e===0;e+=Tn){let n=t.slice(e,e+Tn);if(this.#n.apply(e,n),this.#t.handle({op:`events`,base:e,events:n}),t.length===0)break}this.#t.handle({op:`ended`}),this.#t.handle({op:`player`,cmd:{do:`seek`,position:0}}),this.#e({op:`app.opened`,re:e,header:r.header,events:t.length}),this.#l()}catch(t){this.#e({op:`app.error`,re:e,message:wn(t)})}}};const Dn=globalThis,On=new En((e,t)=>Dn.postMessage(e,t??[]));Dn.addEventListener(`message`,e=>On.handle(e.data));
|
|
8
|
+
//# sourceMappingURL=app.worker-PoneE3J2.js.map
|