@ai-ecoverse/slicc-spectrum 1.58.3 → 1.60.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/dist/slicc-ui.js CHANGED
@@ -24,7 +24,7 @@ import {
24
24
  } from "./chunk-EN3XGF2M.js";
25
25
  import {
26
26
  define
27
- } from "./chunk-TK4ZJ7LA.js";
27
+ } from "./chunk-XI74SELH.js";
28
28
  import {
29
29
  Emitter
30
30
  } from "./chunk-T5NHW4KC.js";
@@ -10171,7 +10171,7 @@ function coneLabel(model, agent) {
10171
10171
  }
10172
10172
  function watchTitles(model, update) {
10173
10173
  const seen = /* @__PURE__ */ new Map();
10174
- const check2 = (id) => {
10174
+ const check3 = (id) => {
10175
10175
  const agent = model.agent.list().find((candidate) => candidate.id === id);
10176
10176
  if (agent?.kind !== "cone") return;
10177
10177
  const title = agentTitle(model, agent);
@@ -10180,8 +10180,8 @@ function watchTitles(model, update) {
10180
10180
  update();
10181
10181
  };
10182
10182
  const stops = [
10183
- model.agent.on("messages", check2),
10184
- model.agent.on("message", ({ agentId }) => check2(agentId))
10183
+ model.agent.on("messages", check3),
10184
+ model.agent.on("message", ({ agentId }) => check3(agentId))
10185
10185
  ];
10186
10186
  return () => {
10187
10187
  for (const stop of stops) stop();
@@ -10197,15 +10197,15 @@ function ago(at, now = Date.now()) {
10197
10197
  return `${Math.floor(days / 7)} weeks ago`;
10198
10198
  }
10199
10199
  async function deleteCone(model, agent, trigger2) {
10200
- const ok = await confirm({
10200
+ const ok2 = await confirm({
10201
10201
  title: `Delete cone ${coneLabel(model, agent)}?`,
10202
10202
  body: "It stops, with its scoops. Its conversation stays in the Freezer, where you can thaw it.",
10203
10203
  action: "Delete cone",
10204
10204
  variant: "confirmation",
10205
10205
  trigger: trigger2
10206
10206
  });
10207
- if (ok) model.agent.freeze?.(agent.id);
10208
- return ok;
10207
+ if (ok2) model.agent.freeze?.(agent.id);
10208
+ return ok2;
10209
10209
  }
10210
10210
  var frozenKinds = {
10211
10211
  cone: ["indigo", "Cone"],
@@ -10277,14 +10277,14 @@ var SliccFreezer = class extends ModelElement {
10277
10277
  this.focusOn("swc-action-button");
10278
10278
  }
10279
10279
  async #remove(cone, trigger2) {
10280
- const ok = await confirm({
10280
+ const ok2 = await confirm({
10281
10281
  title: `Remove ${this.#named(cone)} from the Freezer?`,
10282
10282
  body: "Its working folders are deleted. The conversation stays in the session database. You can\u2019t undo this.",
10283
10283
  action: "Remove",
10284
10284
  variant: "destructive",
10285
10285
  trigger: trigger2
10286
10286
  });
10287
- if (ok) this.model?.agent.discard(cone.id);
10287
+ if (ok2) this.model?.agent.discard(cone.id);
10288
10288
  }
10289
10289
  #named(cone) {
10290
10290
  const rows = this.model?.agent.frozen() ?? [];
@@ -10503,14 +10503,14 @@ var SliccAgents = class extends ModelElement {
10503
10503
  async #drop(agent, trigger2) {
10504
10504
  const port = this.model?.agent;
10505
10505
  if (!port?.drop) return;
10506
- const ok = await confirm({
10506
+ const ok2 = await confirm({
10507
10507
  title: `Drop scoop ${agent.name}?`,
10508
10508
  body: "It stops, and its working folder is deleted. Its conversation and reports are kept. You can\u2019t undo this.",
10509
10509
  action: "Drop",
10510
10510
  variant: "destructive",
10511
10511
  trigger: trigger2
10512
10512
  });
10513
- if (!ok) return;
10513
+ if (!ok2) return;
10514
10514
  const { [agent.id]: _9, ...rest } = this.errors;
10515
10515
  this.errors = rest;
10516
10516
  try {
@@ -10858,33 +10858,33 @@ var lights = {
10858
10858
  unlinked: ["negative", (owner) => `Unlinked from ${owner}`],
10859
10859
  failed: ["negative", (owner) => `Can\u2019t reach ${owner}`]
10860
10860
  };
10861
- function followLight(state2) {
10862
- const [variant, text2] = lights[state2.link];
10863
- return { variant, text: text2(state2.owner) };
10861
+ function followLight(state3) {
10862
+ const [variant, text2] = lights[state3.link];
10863
+ return { variant, text: text2(state3.owner) };
10864
10864
  }
10865
- function followPage(state2) {
10866
- if (!state2) return null;
10867
- const { owner } = state2;
10868
- if (state2.link === "connecting")
10865
+ function followPage(state3) {
10866
+ if (!state3) return null;
10867
+ const { owner } = state3;
10868
+ if (state3.link === "connecting")
10869
10869
  return {
10870
10870
  kind: "connecting",
10871
10871
  title: `Connecting to ${owner}\u2026`,
10872
10872
  body: `This device follows ${owner}. Its agent shows here once it\u2019s connected.`
10873
10873
  };
10874
- if (state2.link === "unlinked")
10874
+ if (state3.link === "unlinked")
10875
10875
  return {
10876
10876
  kind: "unlinked",
10877
10877
  title: `${owner} unlinked this device`,
10878
10878
  body: `To follow it again, open a new link from ${owner}.`
10879
10879
  };
10880
- if (state2.link === "failed")
10880
+ if (state3.link === "failed")
10881
10881
  return {
10882
10882
  kind: "failed",
10883
10883
  title: `Can\u2019t follow ${owner}`,
10884
- body: state2.error ?? `The link to ${owner} failed.`
10884
+ body: state3.error ?? `The link to ${owner} failed.`
10885
10885
  };
10886
- if (state2.access.view) return null;
10887
- const where2 = state2.name ? `next to ${state2.name}` : "for this device";
10886
+ if (state3.access.view) return null;
10887
+ const where2 = state3.name ? `next to ${state3.name}` : "for this device";
10888
10888
  return {
10889
10889
  kind: "waiting",
10890
10890
  title: `Waiting for ${owner} to allow this device`,
@@ -10895,26 +10895,26 @@ function list(items, last) {
10895
10895
  if (items.length < 2) return items.join("");
10896
10896
  return `${items.slice(0, -1).join(", ")} ${last} ${items.at(-1)}`;
10897
10897
  }
10898
- function followCan(state2) {
10898
+ function followCan(state3) {
10899
10899
  const allowed = ["watch the agent"];
10900
10900
  const missing = [];
10901
- (state2.access.control ? allowed : missing).push("send prompts");
10902
- (state2.access.terminal ? allowed : missing).push("open terminals");
10901
+ (state3.access.control ? allowed : missing).push("send prompts");
10902
+ (state3.access.terminal ? allowed : missing).push("open terminals");
10903
10903
  const can = `This device can ${list(allowed, "and")}.`;
10904
- return missing.length ? `${can} To ${list(missing, "or")}, allow it on ${state2.owner}.` : can;
10904
+ return missing.length ? `${can} To ${list(missing, "or")}, allow it on ${state3.owner}.` : can;
10905
10905
  }
10906
10906
  function following(model) {
10907
- const state2 = model?.follow?.state();
10908
- return state2 && !followPage(state2) ? state2 : null;
10907
+ const state3 = model?.follow?.state();
10908
+ return state3 && !followPage(state3) ? state3 : null;
10909
10909
  }
10910
10910
  function watchOnly(model) {
10911
- const state2 = following(model);
10912
- if (!state2 || state2.access.control) return "";
10913
- return `${state2.owner} lets this device watch only. To send prompts, allow Control for it on ${state2.owner}.`;
10911
+ const state3 = following(model);
10912
+ if (!state3 || state3.access.control) return "";
10913
+ return `${state3.owner} lets this device watch only. To send prompts, allow Control for it on ${state3.owner}.`;
10914
10914
  }
10915
10915
  function terminalsAllowed(model) {
10916
- const state2 = model?.follow?.state();
10917
- return !state2 || !!state2.access.terminal;
10916
+ const state3 = model?.follow?.state();
10917
+ return !state3 || !!state3.access.terminal;
10918
10918
  }
10919
10919
  var SliccFollow = class extends ModelElement {
10920
10920
  static properties = {
@@ -11010,15 +11010,15 @@ var SliccFollow = class extends ModelElement {
11010
11010
  async leave() {
11011
11011
  const port = this.model?.follow;
11012
11012
  if (!port || this.busy) return;
11013
- const state2 = port.state();
11014
- if (state2.link !== "unlinked") {
11015
- const ok = await confirm({
11016
- title: `Stop following ${state2.owner}?`,
11017
- body: `This device forgets the link. To follow ${state2.owner} again, open a new link from it.`,
11013
+ const state3 = port.state();
11014
+ if (state3.link !== "unlinked") {
11015
+ const ok2 = await confirm({
11016
+ title: `Stop following ${state3.owner}?`,
11017
+ body: `This device forgets the link. To follow ${state3.owner} again, open a new link from it.`,
11018
11018
  action: "Leave",
11019
11019
  variant: "confirmation"
11020
11020
  });
11021
- if (!ok) return;
11021
+ if (!ok2) return;
11022
11022
  }
11023
11023
  await this.#run("leave", () => port.leave());
11024
11024
  }
@@ -11057,12 +11057,12 @@ var SliccFollow = class extends ModelElement {
11057
11057
  </div>`;
11058
11058
  }
11059
11059
  render() {
11060
- const state2 = this.model?.follow?.state();
11061
- if (!state2) return A;
11062
- const page = followPage(state2);
11060
+ const state3 = this.model?.follow?.state();
11061
+ if (!state3) return A;
11062
+ const page = followPage(state3);
11063
11063
  if (this.page) return page ? this.#page(page) : A;
11064
- const light = followLight(state2);
11065
- return b`<swc-action-button id="chip" class="chip" size="s" quiet data-follow=${state2.link} accessible-label=${light.text}>
11064
+ const light = followLight(state3);
11065
+ return b`<swc-action-button id="chip" class="chip" size="s" quiet data-follow=${state3.link} accessible-label=${light.text}>
11066
11066
  ${this.compact ? b`<swc-icon-user-following slot="icon" size="s" aria-hidden="true"></swc-icon-user-following>` : A}
11067
11067
  <swc-status-light size="s" variant=${light.variant}><span class="text">${light.text}</span></swc-status-light>
11068
11068
  </swc-action-button>
@@ -11070,8 +11070,8 @@ var SliccFollow = class extends ModelElement {
11070
11070
  <swc-popover for="chip" placement="bottom-end" accessible-label=${light.text}>
11071
11071
  <div class="panel">
11072
11072
  <h2>${light.text}</h2>
11073
- ${state2.link === "reconnecting" ? b`<p class="muted" data-reconnecting>The link to ${state2.owner} dropped. The conversation may be out of date until it’s back${state2.access.control ? ", and sending waits until then" : ""}.</p>` : A}
11074
- <p data-can>${followCan(state2)}</p>
11073
+ ${state3.link === "reconnecting" ? b`<p class="muted" data-reconnecting>The link to ${state3.owner} dropped. The conversation may be out of date until it’s back${state3.access.control ? ", and sending waits until then" : ""}.</p>` : A}
11074
+ <p data-can>${followCan(state3)}</p>
11075
11075
  ${this.#error()}
11076
11076
  <div class="actions">${this.#leaveButton()}</div>
11077
11077
  </div>
@@ -12786,9 +12786,9 @@ var SliccNetwork = class extends ModelElement {
12786
12786
  }
12787
12787
  }
12788
12788
  async copy() {
12789
- const done = await copyText(command);
12790
- this.copied = done;
12791
- this.uncopied = !done;
12789
+ const done2 = await copyText(command);
12790
+ this.copied = done2;
12791
+ this.uncopied = !done2;
12792
12792
  }
12793
12793
  async #act(action, run2, area) {
12794
12794
  if (this.busy) return;
@@ -12835,13 +12835,13 @@ var SliccNetwork = class extends ModelElement {
12835
12835
  if (event2.key === "Enter") this.#sendKey(event2);
12836
12836
  }
12837
12837
  async #signOut(port) {
12838
- const ok = await confirm({
12838
+ const ok2 = await confirm({
12839
12839
  title: "Sign out of Tailscale?",
12840
12840
  body: "This browser leaves your tailnet until you sign in again.",
12841
12841
  action: "Sign out",
12842
12842
  variant: "confirmation"
12843
12843
  });
12844
- if (ok) await this.#tailnet("sign-out", () => port.logoutTailnet?.());
12844
+ if (ok2) await this.#tailnet("sign-out", () => port.logoutTailnet?.());
12845
12845
  }
12846
12846
  #copyButton(key2, what, label, value, area, hidden = false) {
12847
12847
  const copied = this.tailnetCopied === key2;
@@ -12949,13 +12949,13 @@ var SliccNetwork = class extends ModelElement {
12949
12949
  async #setControl(port, device, toggle) {
12950
12950
  const allowed = toggle.checked;
12951
12951
  if (allowed) {
12952
- const ok = await confirm({
12952
+ const ok2 = await confirm({
12953
12953
  title: `Allow remote control from ${device.name}?`,
12954
12954
  body: "It can send prompts to the agent, watch its replies and stop it. Unlinking it, or a new certificate on it, turns this off again.",
12955
12955
  action: "Allow",
12956
12956
  variant: "confirmation"
12957
12957
  });
12958
- if (!ok) {
12958
+ if (!ok2) {
12959
12959
  toggle.checked = false;
12960
12960
  return;
12961
12961
  }
@@ -12968,22 +12968,22 @@ var SliccNetwork = class extends ModelElement {
12968
12968
  }
12969
12969
  async #unlink(port, status2, device) {
12970
12970
  const isExit = status2.exit?.kind === "link" && status2.exit.id === device.id;
12971
- const ok = await confirm({
12971
+ const ok2 = await confirm({
12972
12972
  title: `Unlink ${device.name}?`,
12973
12973
  body: unlinkBody(device, isExit),
12974
12974
  action: "Unlink",
12975
12975
  variant: "confirmation"
12976
12976
  });
12977
- if (ok) await this.#act(`unlink:${device.id}`, () => port.unlink?.(device.id), "linksError");
12977
+ if (ok2) await this.#act(`unlink:${device.id}`, () => port.unlink?.(device.id), "linksError");
12978
12978
  }
12979
12979
  async #rotate(port, follow) {
12980
- const ok = await confirm({
12980
+ const ok2 = await confirm({
12981
12981
  title: "Make a new join URL?",
12982
12982
  body: `Linked devices stay linked. Anyone with the old ${follow ? "join URL, follow link or QR code" : "URL"} can\u2019t link anymore.`,
12983
12983
  action: "New URL",
12984
12984
  variant: "confirmation"
12985
12985
  });
12986
- if (ok) await this.#act("rotate", () => port.rotateJoinUrl?.(), "linksError");
12986
+ if (ok2) await this.#act("rotate", () => port.rotateJoinUrl?.(), "linksError");
12987
12987
  }
12988
12988
  #access(port, device) {
12989
12989
  const access = device.access;
@@ -13162,14 +13162,14 @@ var SliccNetwork = class extends ModelElement {
13162
13162
  </section>`;
13163
13163
  }
13164
13164
  async #disconnect(tray, name, trigger2) {
13165
- const ok = await confirm({
13165
+ const ok2 = await confirm({
13166
13166
  title: `Disconnect from ${name}?`,
13167
13167
  body: "This SLICC stops syncing with the tray until you reconnect.",
13168
13168
  action: "Disconnect",
13169
13169
  variant: "confirmation",
13170
13170
  trigger: trigger2
13171
13171
  });
13172
- if (ok) tray.disconnect();
13172
+ if (ok2) tray.disconnect();
13173
13173
  }
13174
13174
  #sync(tray) {
13175
13175
  const status2 = tray.status();
@@ -13366,8 +13366,9 @@ function create(tag3, model, params = {}) {
13366
13366
  function sideOf(id) {
13367
13367
  return surface(terminalOf(id) === null ? id : "terminal")?.side ?? "center";
13368
13368
  }
13369
- function first(dock, side) {
13370
- return dock.api.panels.find((panel) => sideOf(panel.id) === side)?.id;
13369
+ var home = (panel) => sideOf(panel.id);
13370
+ function first(dock, side, sider, except) {
13371
+ return dock.api.panels.find((panel) => panel.id !== except && sider(panel) === side)?.id;
13371
13372
  }
13372
13373
  var neighbours = {
13373
13374
  left: [
@@ -13383,26 +13384,47 @@ var neighbours = {
13383
13384
  ["left", "right"]
13384
13385
  ]
13385
13386
  };
13386
- function placement(dock, side, screen) {
13387
+ function place(dock, side, screen, sider, except) {
13387
13388
  const anchor = (id, direction) => id ? { position: { referencePanel: id, direction } } : null;
13388
13389
  if (screen === "phone") return anchor(dock.api.panels[0]?.id, "within") ?? {};
13389
- const same = anchor(first(dock, side), "within");
13390
+ const same = anchor(first(dock, side, sider, except), "within");
13390
13391
  if (same) return same;
13391
13392
  for (const [other, direction] of neighbours[side]) {
13392
- const found = anchor(first(dock, other), direction);
13393
+ const found = anchor(first(dock, other, sider, except), direction);
13393
13394
  if (found) return found;
13394
13395
  }
13395
13396
  return {};
13396
13397
  }
13397
- function openSurface(dock, item2, screen) {
13398
+ function placement(dock, side, screen) {
13399
+ return place(dock, side, screen, home);
13400
+ }
13401
+ function views(node) {
13402
+ return node.type === "leaf" ? node.data.views : node.data.flatMap(views);
13403
+ }
13404
+ function destination(dock, id, side, screen) {
13405
+ const { grid } = dock.api.toJSON();
13406
+ const root2 = grid.root;
13407
+ const columns = String(grid.orientation) === "HORIZONTAL" && root2.type === "branch" ? root2.data.map(views) : [views(root2)];
13408
+ const holds = (test) => columns.findIndex((ids) => ids.some((other) => other !== id && test(other)));
13409
+ const chat = holds((other) => chatAgent(other) !== null);
13410
+ const middle = chat < 0 ? holds((other) => sideOf(other) === "center") : chat;
13411
+ const current = (panel) => {
13412
+ if (middle < 0) return home(panel);
13413
+ const at = columns.findIndex((ids) => ids.includes(panel.id));
13414
+ return at < middle ? "left" : at > middle ? "right" : "center";
13415
+ };
13416
+ return place(dock, side, screen, current, id);
13417
+ }
13418
+ function openSurface(dock, item2, screen, focus = true) {
13398
13419
  if (dock.has(item2.id)) return;
13399
- const place2 = placement(dock, item2.side, screen);
13400
- const fresh2 = place2.position?.direction !== "within";
13420
+ const place3 = placement(dock, item2.side, screen);
13421
+ const fresh2 = place3.position?.direction !== "within";
13401
13422
  dock.open({
13402
13423
  id: item2.id,
13403
13424
  component: item2.id,
13404
13425
  title: item2.title,
13405
- ...place2,
13426
+ inactive: !focus,
13427
+ ...place3,
13406
13428
  ...fresh2 && item2.width && screen !== "phone" ? { initialWidth: item2.width } : {}
13407
13429
  });
13408
13430
  }
@@ -13419,35 +13441,37 @@ function openChat(dock, agent, screen, focus = true, reveal = true) {
13419
13441
  const id = chatId(agent.id);
13420
13442
  if (!dock.has(id)) {
13421
13443
  const sibling = chats(dock)[0];
13422
- const place2 = sibling ? { position: { referencePanel: sibling, direction: "within" } } : placement(dock, "center", screen);
13444
+ const place3 = sibling ? { position: { referencePanel: sibling, direction: "within" } } : placement(dock, "center", screen);
13423
13445
  dock.open({
13424
13446
  id,
13425
13447
  component: "chat",
13426
13448
  title: agent.name,
13427
13449
  params: { agent: agent.id },
13428
13450
  inactive: !focus,
13429
- ...place2
13451
+ ...place3
13430
13452
  });
13431
13453
  }
13432
13454
  if (focus) dock.focusPanel(id);
13433
13455
  else if (reveal) dock.reveal(id);
13434
13456
  return id;
13435
13457
  }
13436
- function openDocument(dock, kind, path, screen) {
13458
+ function openDocument(dock, kind, path, screen, focus = true) {
13437
13459
  const id = `${kind}:${path}`;
13438
13460
  if (!dock.has(id)) {
13439
13461
  const sibling = dock.api.panels.find((panel) => /^(file|diff):/.test(panel.id));
13440
13462
  const chat = chats(dock)[0];
13441
- const place2 = sibling ? { position: { referencePanel: sibling.id, direction: "within" } } : chat && screen !== "phone" ? { position: { referencePanel: chat, direction: "right" } } : placement(dock, "center", screen);
13463
+ const place3 = sibling ? { position: { referencePanel: sibling.id, direction: "within" } } : chat && screen !== "phone" ? { position: { referencePanel: chat, direction: "right" } } : placement(dock, "center", screen);
13442
13464
  dock.open({
13443
13465
  id,
13444
13466
  component: kind,
13445
13467
  title: documents[kind].title(path),
13446
13468
  params: { path },
13447
- ...place2
13469
+ inactive: !focus,
13470
+ ...place3
13448
13471
  });
13449
13472
  }
13450
- dock.focusPanel(id);
13473
+ if (focus) dock.focusPanel(id);
13474
+ else dock.reveal(id);
13451
13475
  return id;
13452
13476
  }
13453
13477
  function terminalPanel(terminal) {
@@ -13516,7 +13540,7 @@ var directions = {
13516
13540
  function dropPlacement(panel, position) {
13517
13541
  return panel ? { position: { referencePanel: panel, direction: directions[position] ?? "within" } } : null;
13518
13542
  }
13519
- function openSprinkle(dock, sprinkle, screen, place2 = null) {
13543
+ function openSprinkle(dock, sprinkle, screen, place3 = null, focus = true) {
13520
13544
  const id = `sprinkle:${sprinkle.id}`;
13521
13545
  if (!dock.has(id)) {
13522
13546
  dock.open({
@@ -13524,13 +13548,364 @@ function openSprinkle(dock, sprinkle, screen, place2 = null) {
13524
13548
  component: "sprinkle",
13525
13549
  title: sprinkle.title,
13526
13550
  params: { sprinkle: sprinkle.id },
13527
- ...place2 ?? placement(dock, "right", screen)
13551
+ inactive: !focus,
13552
+ ...place3 ?? placement(dock, "right", screen)
13528
13553
  });
13529
13554
  }
13530
- dock.focusPanel(id);
13555
+ if (focus) dock.focusPanel(id);
13556
+ else dock.reveal(id);
13531
13557
  return id;
13532
13558
  }
13533
13559
 
13560
+ // src/app/panel-command.ts
13561
+ var userCloseWindow = 6e4;
13562
+ var positions = {
13563
+ left: "left",
13564
+ right: "right",
13565
+ above: "top",
13566
+ below: "bottom",
13567
+ within: "center"
13568
+ };
13569
+ var ok = (message) => ({ code: 0, message });
13570
+ var refused = (message) => ({ code: 5, message });
13571
+ var unknown = (id) => ({
13572
+ code: 1,
13573
+ message: `no panel called ${id}; panel list shows the ids you can use`
13574
+ });
13575
+ var Panels = class {
13576
+ #host;
13577
+ #quiet = 0;
13578
+ #closed = /* @__PURE__ */ new Map();
13579
+ constructor(host4) {
13580
+ this.#host = host4;
13581
+ }
13582
+ quietly(run2) {
13583
+ this.#quiet++;
13584
+ try {
13585
+ return run2();
13586
+ } finally {
13587
+ this.#quiet--;
13588
+ }
13589
+ }
13590
+ closed(id) {
13591
+ if (this.#quiet === 0) this.#closed.set(id, Date.now());
13592
+ }
13593
+ closedAgo(id) {
13594
+ const at = this.#closed.get(id);
13595
+ if (at === void 0) return null;
13596
+ const ago2 = Date.now() - at;
13597
+ return ago2 < userCloseWindow ? ago2 : null;
13598
+ }
13599
+ recentClose() {
13600
+ const dock = this.#host.dock();
13601
+ for (const id of this.#closed.keys()) {
13602
+ const ago2 = this.closedAgo(id);
13603
+ if (ago2 !== null && !dock.has(id)) return { id, ago: ago2 };
13604
+ }
13605
+ return null;
13606
+ }
13607
+ typing() {
13608
+ return this.#host.typing();
13609
+ }
13610
+ agents() {
13611
+ return this.#host.model()?.agent.list() ?? [];
13612
+ }
13613
+ active() {
13614
+ return this.#host.model()?.agent.active() ?? null;
13615
+ }
13616
+ list() {
13617
+ const host4 = this.#host;
13618
+ const surfaces3 = host4.surfaces();
13619
+ const offers = (id) => surfaces3.some((item2) => item2.id === id);
13620
+ const rows = [
13621
+ ...surfaces3.filter((item2) => item2.id !== "chat" && item2.id !== "terminal").map((item2) => ({
13622
+ id: item2.id,
13623
+ title: item2.title,
13624
+ kind: "surface",
13625
+ side: item2.side,
13626
+ agent: null
13627
+ })),
13628
+ ...(offers("chat") ? this.agents() : []).map((agent) => ({
13629
+ id: `chat:${agent.id}`,
13630
+ title: agent.name,
13631
+ kind: "chat",
13632
+ side: "center",
13633
+ agent: agent.id
13634
+ })),
13635
+ ...(offers("terminal") ? host4.model()?.terminals.list() ?? [] : []).map((info) => ({
13636
+ id: terminalPanel(info.id),
13637
+ title: terminalTitle(info),
13638
+ kind: "terminal",
13639
+ side: "right",
13640
+ agent: null
13641
+ })),
13642
+ ...host4.sprinkles().map((sprinkle) => ({
13643
+ id: `sprinkle:${sprinkle.id}`,
13644
+ title: sprinkle.title,
13645
+ kind: "sprinkle",
13646
+ side: "right",
13647
+ agent: sprinkle.id.includes("/") ? sprinkle.agentId : null
13648
+ })),
13649
+ ...host4.dock().api.panels.filter((panel) => /^(file|diff):/.test(panel.id)).map((panel) => ({
13650
+ id: panel.id,
13651
+ title: panel.title ?? panel.id,
13652
+ kind: panel.id.slice(0, panel.id.indexOf(":")),
13653
+ side: "center",
13654
+ agent: null
13655
+ }))
13656
+ ];
13657
+ return rows.map((row) => this.#state(row));
13658
+ }
13659
+ #state(row) {
13660
+ const dock = this.#host.dock();
13661
+ const panel = dock.api.getPanel(row.id);
13662
+ const content = dock.content(row.id);
13663
+ return {
13664
+ ...row,
13665
+ open: panel !== void 0,
13666
+ visible: panel?.api.isVisible === true,
13667
+ active: panel !== void 0 && dock.api.activePanel?.id === row.id,
13668
+ busy: content?.busyReason ?? null
13669
+ };
13670
+ }
13671
+ find(id) {
13672
+ const listed = this.list().find((info) => info.id === id);
13673
+ if (listed) return listed;
13674
+ const document2 = id.match(/^(file|diff):(.+)$/);
13675
+ if (!document2) return void 0;
13676
+ return this.#state({
13677
+ id,
13678
+ title: id,
13679
+ kind: document2[1],
13680
+ side: "center",
13681
+ agent: null
13682
+ });
13683
+ }
13684
+ open(id, options = {}) {
13685
+ return this.#show(id, false, options);
13686
+ }
13687
+ focus(id, options = {}) {
13688
+ return this.#show(id, true, options);
13689
+ }
13690
+ #show(id, focus, { place: place3, section }) {
13691
+ const info = this.find(id);
13692
+ if (!info) return unknown(id);
13693
+ const bad = this.#reference(id, place3);
13694
+ if (bad) return bad;
13695
+ this.quietly(() => this.#host.open(id, focus, section));
13696
+ if (place3) {
13697
+ const moved = this.move(id, place3);
13698
+ if (moved.code !== 0) return moved;
13699
+ }
13700
+ return ok(`${focus ? "focused" : info.open ? "showed" : "opened"} ${id}`);
13701
+ }
13702
+ close(id) {
13703
+ const info = this.find(id);
13704
+ if (!info) return unknown(id);
13705
+ if (!info.open) return ok(`${id} was already closed`);
13706
+ if (info.kind === "terminal")
13707
+ return refused(`closing ${id} stops its shell; ask the user to close it`);
13708
+ if (info.kind === "chat" && chats(this.#host.dock()).length === 1)
13709
+ return refused(`${id} is the last chat, so it stays open`);
13710
+ if (info.busy) return refused(`${id} is busy: ${info.busy}`);
13711
+ this.quietly(() => this.#host.dock().close(id));
13712
+ return ok(`closed ${id}`);
13713
+ }
13714
+ move(id, place3) {
13715
+ const info = this.find(id);
13716
+ if (!info) return unknown(id);
13717
+ const bad = this.#reference(id, place3);
13718
+ if (bad) return bad;
13719
+ const dock = this.#host.dock();
13720
+ if (!info.open) this.quietly(() => this.#host.open(id, false));
13721
+ if (!dock.has(id)) return unknown(id);
13722
+ if (this.#host.screen() === "phone")
13723
+ return ok(`phones show one panel at a time, so ${id} stays where it is`);
13724
+ const busy = info.open ? info.busy : this.find(id)?.busy ?? null;
13725
+ if (busy) return refused(`${id} is busy: ${busy}`);
13726
+ const target = typeof place3 === "string" ? destination(dock, id, place3, this.#host.screen()) : { position: { referencePanel: place3.ref, direction: place3.direction } };
13727
+ const reference2 = target.position && dock.api.getPanel(target.position.referencePanel);
13728
+ if (!reference2 || !target.position) return ok(`${id} is the only panel, so it stays`);
13729
+ const position = positions[target.position.direction];
13730
+ const panel = dock.api.getPanel(id);
13731
+ this.quietly(() => panel?.api.moveTo({ group: reference2.group, position }));
13732
+ return ok(`moved ${id}`);
13733
+ }
13734
+ #reference(id, place3) {
13735
+ if (typeof place3 !== "object") return null;
13736
+ if (place3.ref === id) return { code: 2, message: `can't place ${id} beside itself` };
13737
+ if (!this.#host.dock().has(place3.ref)) return { code: 1, message: `${place3.ref} isn't open` };
13738
+ return null;
13739
+ }
13740
+ reset() {
13741
+ const busy = this.list().find((info) => info.open && info.busy);
13742
+ if (busy) return refused(`${busy.id} is busy: ${busy.busy}`);
13743
+ this.quietly(() => this.#host.reset());
13744
+ return ok("restored the default layout");
13745
+ }
13746
+ };
13747
+ var help = `usage: panel <command>
13748
+
13749
+ list [--json] the panels you can reach, and their state
13750
+ open <id> [place] show a panel; keyboard focus stays where it is
13751
+ focus <id> [place] show a panel and give it keyboard focus
13752
+ close <id> close a panel
13753
+ move <id> <place> move an open panel
13754
+ reset restore the default layout
13755
+
13756
+ place: left | center | right, or --left | --right | --above | --below | --within <id>
13757
+ open and focus also take --section <name>, e.g. panel open settings --section accounts
13758
+
13759
+ ids: the ones panel list shows, e.g. files, changes, terminal, monitor, settings,
13760
+ chat (your cone's chat), chat:<agent>, terminal:<n>, sprinkle:<name>,
13761
+ file:<path>, diff:<path>
13762
+ `;
13763
+ var verbs = /* @__PURE__ */ new Set(["list", "open", "focus", "close", "move", "reset"]);
13764
+ var sides = /* @__PURE__ */ new Set(["left", "center", "right"]);
13765
+ var directions2 = /* @__PURE__ */ new Set(["left", "right", "above", "below", "within"]);
13766
+ function scan(parsed, rest, positional) {
13767
+ for (let index = 0; index < rest.length; index++) {
13768
+ const arg = rest[index];
13769
+ const flag = arg.startsWith("--") ? arg.slice(2) : null;
13770
+ if (flag === "json") parsed.json = true;
13771
+ else if (flag === "section" || flag !== null && directions2.has(flag)) {
13772
+ const value = rest[++index];
13773
+ if (value === void 0) return `--${flag} needs a value`;
13774
+ if (flag === "section") parsed.section = value;
13775
+ else if (parsed.place) return "give one place";
13776
+ else parsed.place = { direction: flag, ref: value };
13777
+ } else if (arg.startsWith("-")) return `unknown option ${arg}`;
13778
+ else positional.push(arg);
13779
+ }
13780
+ const [id, side, ...extra] = positional;
13781
+ if (extra.length > 0) return `unexpected ${extra[0]}`;
13782
+ parsed.id = id;
13783
+ if (side === void 0) return null;
13784
+ if (!sides.has(side)) return `${side} isn't a place; use left, center or right`;
13785
+ if (parsed.place) return "give one place";
13786
+ parsed.place = side;
13787
+ return null;
13788
+ }
13789
+ function check({ verb, id, json, section, place: place3 }) {
13790
+ const ids = verb === "list" || verb === "reset" ? 0 : 1;
13791
+ if ((id === void 0 ? 0 : 1) !== ids)
13792
+ return ids ? `${verb} needs an id` : `${verb} takes no id`;
13793
+ if (json && verb !== "list") return "--json is for list";
13794
+ if (section !== void 0 && verb !== "open" && verb !== "focus")
13795
+ return "--section is for open and focus";
13796
+ if (place3 && verb !== "open" && verb !== "focus" && verb !== "move")
13797
+ return `${verb} takes no place`;
13798
+ if (verb === "move" && !place3) return "move needs a place";
13799
+ return null;
13800
+ }
13801
+ function parse(args2) {
13802
+ const [verb, ...rest] = args2;
13803
+ if (!verbs.has(verb)) return `unknown command ${verb}`;
13804
+ const parsed = { verb, json: false };
13805
+ return scan(parsed, rest, []) ?? check(parsed) ?? parsed;
13806
+ }
13807
+ function coneOf(agents, id) {
13808
+ let agent = agents.find((candidate) => candidate.id === id);
13809
+ const seen = /* @__PURE__ */ new Set();
13810
+ while (agent && agent.kind !== "cone" && !seen.has(agent)) {
13811
+ seen.add(agent);
13812
+ agent = agents.find((candidate) => candidate.id === agent?.parentId);
13813
+ }
13814
+ return agent?.kind === "cone" ? agent.id : null;
13815
+ }
13816
+ function resolve(panels, raw2, reachable, cone) {
13817
+ if (/^(file|diff):./.test(raw2)) return raw2;
13818
+ if (raw2 === "chat") {
13819
+ const agent = cone === void 0 ? panels.active() : cone;
13820
+ return reachable.some((info) => info.id === `chat:${agent}`) ? `chat:${agent}` : null;
13821
+ }
13822
+ if (raw2 === "terminal") {
13823
+ const terminals = reachable.filter((info) => info.kind === "terminal");
13824
+ const picked = terminals.find((info) => info.active) ?? terminals.filter((info) => info.open).at(-1) ?? terminals.at(-1);
13825
+ return picked?.id ?? null;
13826
+ }
13827
+ if (reachable.some((info) => info.id === raw2)) return raw2;
13828
+ const name = raw2.startsWith("sprinkle:") ? raw2.slice(9) : raw2;
13829
+ const sprinkles = reachable.filter((info) => info.kind === "sprinkle");
13830
+ const found = sprinkles.find((info) => info.id === `sprinkle:${name}`) ?? sprinkles.find((info) => cone && info.id === `sprinkle:${cone}/${name}`) ?? sprinkles.find((info) => info.id.split("/").at(-1) === name);
13831
+ return found?.id ?? null;
13832
+ }
13833
+ function state(info) {
13834
+ const shown2 = info.active ? "active" : info.visible ? "shown" : info.open ? "open" : "closed";
13835
+ return info.busy ? `${shown2} \xB7 busy: ${info.busy}` : shown2;
13836
+ }
13837
+ function table(rows) {
13838
+ const lines = [["ID", "TITLE", "STATE"], ...rows.map((row) => [row.id, row.title, state(row)])];
13839
+ const widths = [0, 1].map((column) => Math.max(...lines.map((line) => line[column].length)));
13840
+ return lines.map(([id, title, shown2]) => `${id.padEnd(widths[0])} ${title.padEnd(widths[1])} ${shown2}`).join("\n");
13841
+ }
13842
+ var done = (result, note = "") => result.code === 0 ? { stdout: `${result.message}${note}
13843
+ `, stderr: "", code: 0 } : { stdout: "", stderr: `panel: ${result.message}
13844
+ `, code: result.code };
13845
+ function act(scope, parsed) {
13846
+ const { panels, reachable, cone } = scope;
13847
+ if (parsed.verb === "reset") {
13848
+ const recent = scope.agent ? panels.recentClose() : null;
13849
+ if (recent)
13850
+ return refusedOutput(
13851
+ `the user closed ${recent.id} ${Math.round(recent.ago / 1e3)} s ago; ask before resetting the layout`
13852
+ );
13853
+ return done(panels.reset());
13854
+ }
13855
+ const raw2 = parsed.id;
13856
+ const id = resolve(panels, raw2, reachable, cone);
13857
+ if (!id) return done(unknown(raw2));
13858
+ let place3 = parsed.place;
13859
+ if (typeof place3 === "object") {
13860
+ const ref = resolve(panels, place3.ref, reachable, cone);
13861
+ if (!ref) return done(unknown(place3.ref));
13862
+ place3 = { ...place3, ref };
13863
+ }
13864
+ if (parsed.verb === "close") return done(panels.close(id));
13865
+ const ago2 = scope.agent && !panels.find(id)?.open ? panels.closedAgo(id) : null;
13866
+ if (ago2 !== null)
13867
+ return refusedOutput(
13868
+ `the user closed ${id} ${Math.round(ago2 / 1e3)} s ago; ask before opening it again`
13869
+ );
13870
+ if (parsed.verb === "move") return done(panels.move(id, place3));
13871
+ const options = { place: place3, section: parsed.section };
13872
+ if (parsed.verb === "open") return done(panels.open(id, options));
13873
+ if (scope.agent && panels.typing())
13874
+ return done(
13875
+ panels.open(id, options),
13876
+ "; the user is typing, so it was shown without taking focus"
13877
+ );
13878
+ return done(panels.focus(id, options));
13879
+ }
13880
+ function panelCommand(app, argv, caller) {
13881
+ const panels = app.panels;
13882
+ const args2 = argv[0] === "panel" ? argv.slice(1) : argv;
13883
+ if (args2.length === 0 || args2[0] === "--help" || args2[0] === "-h" || args2[0] === "help")
13884
+ return { stdout: help, stderr: "", code: 0 };
13885
+ if (caller.readOnly && args2[0] !== "list")
13886
+ return refusedOutput("this page only follows SLICC; panel list is all it allows");
13887
+ const parsed = parse(args2);
13888
+ if (typeof parsed === "string")
13889
+ return { stdout: "", stderr: `panel: ${parsed}
13890
+
13891
+ ${help}`, code: 2 };
13892
+ const agents = panels.agents();
13893
+ const scoped2 = caller.agentId !== null || !!caller.cone;
13894
+ const cone = scoped2 ? caller.cone ?? coneOf(agents, caller.agentId) : void 0;
13895
+ const reachable = panels.list().filter(
13896
+ (info) => !scoped2 || info.agent === null || !!cone && coneOf(agents, info.agent) === cone
13897
+ );
13898
+ if (parsed.verb !== "list")
13899
+ return act({ panels, agent: caller.agentId !== null, cone, reachable }, parsed);
13900
+ const body4 = parsed.json ? JSON.stringify(reachable, null, 2) : table(reachable);
13901
+ return { stdout: `${body4}
13902
+ `, stderr: "", code: 0 };
13903
+ }
13904
+ function refusedOutput(message) {
13905
+ return { stdout: "", stderr: `panel: ${message}
13906
+ `, code: 5 };
13907
+ }
13908
+
13534
13909
  // node_modules/@adobe/spectrum-wc/dist/swc.css
13535
13910
  var swc_default = `/**
13536
13911
  * Copyright 2026 Adobe. All rights reserved.
@@ -13662,23 +14037,23 @@ function installProperties(document2, text2 = swc_default) {
13662
14037
  var following2 = "SLICC runs in another tab. This tab shows it and sends your actions there.";
13663
14038
  var connecting = "Connecting to the tab running SLICC\u2026";
13664
14039
  var alone = "SLICC is open in another tab.";
13665
- function tabsBanner(state2) {
13666
- if (!state2 || state2.role === "alone") return null;
13667
- if (state2.skew === "newer")
14040
+ function tabsBanner(state3) {
14041
+ if (!state3 || state3.role === "alone") return null;
14042
+ if (state3.skew === "newer")
13668
14043
  return {
13669
14044
  kind: "skew",
13670
14045
  skew: "newer",
13671
14046
  text: "Another tab runs a newer SLICC. Reload this tab.",
13672
14047
  reload: true
13673
14048
  };
13674
- if (state2.skew === "older")
14049
+ if (state3.skew === "older")
13675
14050
  return {
13676
14051
  kind: "skew",
13677
14052
  skew: "older",
13678
14053
  text: "Another tab runs an older SLICC. Reload the other SLICC tab.",
13679
14054
  reload: false
13680
14055
  };
13681
- if (state2.stalled)
14056
+ if (state3.stalled)
13682
14057
  return {
13683
14058
  kind: "stalled",
13684
14059
  skew: null,
@@ -13687,11 +14062,11 @@ function tabsBanner(state2) {
13687
14062
  };
13688
14063
  return null;
13689
14064
  }
13690
- function tabsLight(state2) {
13691
- if (!state2 || state2.role === "owner" || state2.role === "alone") return null;
13692
- const banner = tabsBanner(state2);
14065
+ function tabsLight(state3) {
14066
+ if (!state3 || state3.role === "owner" || state3.role === "alone") return null;
14067
+ const banner = tabsBanner(state3);
13693
14068
  if (banner) return { variant: "notice", text: "Another tab", tooltip: banner.text };
13694
- if (state2.role === "connecting")
14069
+ if (state3.role === "connecting")
13695
14070
  return { variant: "info", text: "Connecting", tooltip: connecting };
13696
14071
  return { variant: "neutral", text: "Another tab", tooltip: following2 };
13697
14072
  }
@@ -13932,11 +14307,11 @@ var SliccTerminalPanel = class extends ThemedElement {
13932
14307
  const host4 = this.getRootNode().host;
13933
14308
  const panel = host4?.localName === "slicc-dock" ? host4.api.getPanel(terminalPanel(id)) : void 0;
13934
14309
  if (!panel || laid(panel.api)) return Promise.resolve();
13935
- return new Promise((resolve) => {
14310
+ return new Promise((resolve2) => {
13936
14311
  const watch = panel.api.onDidDimensionsChange((size4) => {
13937
14312
  if (!laid(size4)) return;
13938
14313
  watch.dispose();
13939
- resolve();
14314
+ resolve2();
13940
14315
  });
13941
14316
  });
13942
14317
  }
@@ -19890,7 +20265,7 @@ function block(lines, i25) {
19890
20265
  const end = run(lines, i25, (l24) => l24.trim() !== "" && !starts.test(l24) && !itemPattern.test(l24));
19891
20266
  return [{ type: "paragraph", text: lines.slice(i25, end).join(" ") }, end];
19892
20267
  }
19893
- function parse(text2) {
20268
+ function parse2(text2) {
19894
20269
  const lines = text2.split("\n");
19895
20270
  const blocks = [];
19896
20271
  let i25 = 0;
@@ -19931,7 +20306,7 @@ function render(entry) {
19931
20306
  }
19932
20307
  }
19933
20308
  function markdown(text2) {
19934
- return b`${parse(text2).map(render)}`;
20309
+ return b`${parse2(text2).map(render)}`;
19935
20310
  }
19936
20311
 
19937
20312
  // src/app/messages.ts
@@ -20057,7 +20432,7 @@ function toolSummary(calls) {
20057
20432
  }
20058
20433
  return [...counts].sort((a22, b13) => b13[1] - a22[1]).map(([kind, count]) => `${count} ${count === 1 ? kind.one : kind.many}`).join(", ");
20059
20434
  }
20060
- function state(status2, label = toolStates[status2][0]) {
20435
+ function state2(status2, label = toolStates[status2][0]) {
20061
20436
  return b`<span class="state" data-state=${status2}>${toolStates[status2][1]}<span>${label}</span></span>`;
20062
20437
  }
20063
20438
  var actionLabels = {
@@ -20114,7 +20489,7 @@ function tool(call, color = "light") {
20114
20489
  <span class="title">${call.title}</span>
20115
20490
  <span class="name">${call.name}</span>
20116
20491
  ${call.meta ? b`<span class="tool-meta">${call.meta}</span>` : A}
20117
- ${state(call.status)}
20492
+ ${state2(call.status)}
20118
20493
  </span>
20119
20494
  ${call.image ? b`<span class="thumb"><img src=${call.image} alt="" /></span>` : A}
20120
20495
  </summary>
@@ -20139,7 +20514,7 @@ function cluster(calls, open, color) {
20139
20514
  <swc-icon-chevron-right class="chevron" size="s" aria-hidden="true"></swc-icon-chevron-right>
20140
20515
  <span class="title">${calls.length} tools</span>
20141
20516
  <span class="names"><span aria-hidden="true">· </span>${toolSummary(calls)}</span>
20142
- ${state(overall, label || void 0)}
20517
+ ${state2(overall, label || void 0)}
20143
20518
  </summary>
20144
20519
  <div class="calls">${calls.map((call) => tool(call, color))}</div>
20145
20520
  </details>`;
@@ -20174,7 +20549,7 @@ function card(item2) {
20174
20549
  }
20175
20550
  return b`<div class="card light" data-tone=${item2.tone}><strong>${item2.title}</strong><span>${item2.detail}</span></div>`;
20176
20551
  }
20177
- function check(items) {
20552
+ function check2(items) {
20178
20553
  return b`<ul class="check">
20179
20554
  ${items.map((entry) => b`<li data-tone=${entry.tone ?? "positive"}><span class="mark" aria-hidden="true">✓</span>${entry.text}</li>`)}
20180
20555
  </ul>`;
@@ -20244,7 +20619,7 @@ function part(entry, handlers, showThinking) {
20244
20619
  case "plan":
20245
20620
  return b`<div class="plan"><div class="label">Plan</div><ol>${entry.items.map((step) => b`<li>${step}</li>`)}</ol></div>`;
20246
20621
  case "check":
20247
- return check(entry.items);
20622
+ return check2(entry.items);
20248
20623
  case "diff":
20249
20624
  return b`<div class="inline-diff">
20250
20625
  <button class="diff-head" @click=${() => handlers.open(entry.path)}>${entry.path}</button>
@@ -21155,7 +21530,7 @@ function requiresText(item2, all2) {
21155
21530
  ].filter(Boolean);
21156
21531
  return parts2.length ? parts2.join("; ") : null;
21157
21532
  }
21158
- var snapshot = (items) => new Map(items.map(({ id, state: state2, error }) => [id, { state: state2, error }]));
21533
+ var snapshot = (items) => new Map(items.map(({ id, state: state3, error }) => [id, { state: state3, error }]));
21159
21534
  function settled(failures, before, after) {
21160
21535
  return new Map(
21161
21536
  [...failures].filter(([id]) => {
@@ -21218,6 +21593,11 @@ var SliccUpdates = class extends ModelElement {
21218
21593
  this.busy = /* @__PURE__ */ new Map();
21219
21594
  this.problems = /* @__PURE__ */ new Map();
21220
21595
  }
21596
+ get busyReason() {
21597
+ const packages = this.model?.updates?.packages?.() ?? [];
21598
+ const running2 = this.busy.size > 0 || packages.some((item2) => packageRunning.has(item2.state));
21599
+ return running2 ? "a package is installing" : null;
21600
+ }
21221
21601
  static styles = [
21222
21602
  i`
21223
21603
  :host {
@@ -21566,8 +21946,8 @@ var SliccUpdates = class extends ModelElement {
21566
21946
  return b`<span>Checked <time datetime=${date.toISOString()}>${shown2}</time></span>`;
21567
21947
  }
21568
21948
  #item(item2) {
21569
- const [variant, state2] = states[item2.state];
21570
- const label = item2.state === "failed" && item2.from !== null ? "Update failed" : state2;
21949
+ const [variant, state3] = states[item2.state];
21950
+ const label = item2.state === "failed" && item2.from !== null ? "Update failed" : state3;
21571
21951
  const error = this.failures.get(item2.id) ?? item2.error;
21572
21952
  return b`<swc-divider size="s"></swc-divider>
21573
21953
  <article data-id=${item2.id} data-state=${item2.state} aria-label=${item2.label}>
@@ -21625,10 +22005,10 @@ var SliccUpdates = class extends ModelElement {
21625
22005
  accessible-label=${`${item2.label}: ${packageLight(item2)?.[1].toLowerCase()}`}
21626
22006
  ></swc-progress-bar>`;
21627
22007
  }
21628
- #package(item2, all2, act) {
22008
+ #package(item2, all2, act2) {
21629
22009
  const light = packageLight(item2);
21630
22010
  const busy = this.busy.get(item2.id);
21631
- const shown2 = busy ? [busy] : act ? item2.actions : [];
22011
+ const shown2 = busy ? [busy] : act2 ? item2.actions : [];
21632
22012
  const error = this.problems.get(item2.id) ?? item2.error;
21633
22013
  return b`<li data-id=${item2.id} data-state=${item2.state}>
21634
22014
  <div class="name">
@@ -21759,6 +22139,9 @@ function finishTransitions(root2) {
21759
22139
  for (const element2 of root2.querySelectorAll("*"))
21760
22140
  if (element2.shadowRoot) finishTransitions(element2.shadowRoot);
21761
22141
  }
22142
+ function editable(node) {
22143
+ return node instanceof HTMLElement && (node.isContentEditable || node.tagName === "TEXTAREA" || node.tagName === "INPUT");
22144
+ }
21762
22145
  var SliccApp = class extends ThemedElement {
21763
22146
  static properties = {
21764
22147
  ...ThemedElement.properties,
@@ -21769,6 +22152,17 @@ var SliccApp = class extends ThemedElement {
21769
22152
  layoutKey = "slicc-ui.layout.v2";
21770
22153
  dips = new Dips();
21771
22154
  terminalPanels = new TerminalPanels();
22155
+ panels = new Panels({
22156
+ dock: () => this.dock,
22157
+ screen: () => this.screen,
22158
+ model: () => this.model,
22159
+ surfaces: () => this.#available(),
22160
+ sprinkles: () => this.#sprinkles(),
22161
+ open: (id, focus, section) => this.#open(id, focus, section),
22162
+ reset: () => this.resetLayout(),
22163
+ typing: () => this.#typing()
22164
+ });
22165
+ #typedAt = Number.NEGATIVE_INFINITY;
21772
22166
  #fontBase = defaultFontBase;
21773
22167
  #variableFont = defaultVariableFont;
21774
22168
  #resize = null;
@@ -22111,12 +22505,15 @@ var SliccApp = class extends ThemedElement {
22111
22505
  }
22112
22506
  if (this.#painted !== color) this.#hold.paint(color);
22113
22507
  this.#painted = color;
22114
- if (!this.model) return;
22115
- const layout = this.#started !== this.screen;
22116
- if (layout) this.#start(this.model);
22117
- else if (changed.has("model")) this.#rebind(this.model);
22118
- this.#updates(layout);
22119
- this.#retitle();
22508
+ const model = this.model;
22509
+ if (!model) return;
22510
+ this.panels.quietly(() => {
22511
+ const layout = this.#started !== this.screen;
22512
+ if (layout) this.#start(model);
22513
+ else if (changed.has("model")) this.#rebind(model);
22514
+ this.#updates(layout);
22515
+ this.#retitle();
22516
+ });
22120
22517
  }
22121
22518
  #retitle() {
22122
22519
  for (const sprinkle of this.#sprinkles()) {
@@ -22180,7 +22577,10 @@ var SliccApp = class extends ThemedElement {
22180
22577
  if (!this.#started) return;
22181
22578
  const dock = this.dock;
22182
22579
  dock.factories = this.#factories(model);
22183
- if (!terminalsAllowed(model)) for (const id of terminalPanels(dock)) dock.close(id);
22580
+ if (!terminalsAllowed(model))
22581
+ this.panels.quietly(() => {
22582
+ for (const id of terminalPanels(dock)) dock.close(id);
22583
+ });
22184
22584
  }
22185
22585
  #start(model) {
22186
22586
  const dock = this.dock;
@@ -22230,11 +22630,13 @@ var SliccApp = class extends ThemedElement {
22230
22630
  const dock = this.renderRoot.querySelector("slicc-dock");
22231
22631
  if (!dock || !this.#started) return;
22232
22632
  const known = new Set(this.model?.agent.list().map((agent) => agent.id));
22233
- for (const id of chats(dock)) {
22234
- if (!known.has(chatAgent(id))) dock.close(id);
22235
- }
22236
- if (this.model && this.#offers("terminal"))
22237
- this.terminalPanels.sync(dock, this.model.terminals, this.screen);
22633
+ this.panels.quietly(() => {
22634
+ for (const id of chats(dock)) {
22635
+ if (!known.has(chatAgent(id))) dock.close(id);
22636
+ }
22637
+ if (this.model && this.#offers("terminal"))
22638
+ this.terminalPanels.sync(dock, this.model.terminals, this.screen);
22639
+ });
22238
22640
  }
22239
22641
  #activated(event2) {
22240
22642
  const { id } = event2.detail;
@@ -22245,7 +22647,9 @@ var SliccApp = class extends ThemedElement {
22245
22647
  }
22246
22648
  resetLayout() {
22247
22649
  const terminals = this.model?.terminals.list();
22248
- defaultLayout(this.dock, this.screen, this.#active(), this.#available(), terminals);
22650
+ this.panels.quietly(
22651
+ () => defaultLayout(this.dock, this.screen, this.#active(), this.#available(), terminals)
22652
+ );
22249
22653
  this.#save();
22250
22654
  }
22251
22655
  #showSurface(event2) {
@@ -22253,14 +22657,28 @@ var SliccApp = class extends ThemedElement {
22253
22657
  this.show(id, section);
22254
22658
  }
22255
22659
  show(id, section) {
22256
- const agent = this.#active();
22257
- if (id === "chat" && agent && this.#offers("chat")) {
22258
- openChat(this.dock, agent, this.screen);
22660
+ this.#open(id, true, section);
22661
+ }
22662
+ #open(id, focus, section) {
22663
+ const agent = id === "chat" ? this.#active() : this.model?.agent.list().find((candidate) => `chat:${candidate.id}` === id);
22664
+ if (agent && this.#offers("chat")) {
22665
+ openChat(this.dock, agent, this.screen, focus);
22259
22666
  return;
22260
22667
  }
22261
22668
  const sprinkle = this.#sprinkles().find((candidate) => `sprinkle:${candidate.id}` === id);
22262
22669
  if (sprinkle) {
22263
- openSprinkle(this.dock, sprinkle, this.screen);
22670
+ this.dips.detach(sprinkle.id);
22671
+ openSprinkle(this.dock, sprinkle, this.screen, null, focus);
22672
+ return;
22673
+ }
22674
+ const terminal = this.model?.terminals.list().find((info) => info.id === terminalOf(id));
22675
+ if (terminal && this.#offers("terminal")) {
22676
+ this.#reveal(openTerminal(this.dock, terminal, this.screen), focus);
22677
+ return;
22678
+ }
22679
+ const document2 = id.match(/^(file|diff):(.+)$/);
22680
+ if (document2) {
22681
+ openDocument(this.dock, document2[1], document2[2], this.screen, focus);
22264
22682
  return;
22265
22683
  }
22266
22684
  const item2 = surface(id, this.#available());
@@ -22269,12 +22687,24 @@ var SliccApp = class extends ThemedElement {
22269
22687
  if (this.model) this.terminalPanels.show(this.dock, this.model.terminals, this.screen);
22270
22688
  return;
22271
22689
  }
22272
- openSurface(this.dock, item2, this.screen);
22690
+ openSurface(this.dock, item2, this.screen, focus);
22273
22691
  if (id === "updates") this.dock.api.getPanel(id)?.api.updateParameters({ boot: false });
22274
- this.dock.focusPanel(id);
22692
+ this.#reveal(id, focus);
22275
22693
  if (section)
22276
22694
  this.dock.content(id)?.reveal?.(section);
22277
22695
  }
22696
+ #reveal(id, focus) {
22697
+ if (focus) this.dock.focusPanel(id);
22698
+ else this.dock.reveal(id);
22699
+ }
22700
+ #typing() {
22701
+ if (Date.now() - this.#typedAt < 3e3) return true;
22702
+ let active = this.ownerDocument.activeElement;
22703
+ while (active?.shadowRoot?.activeElement) active = active.shadowRoot.activeElement;
22704
+ if (!editable(active)) return false;
22705
+ const value = "value" in active ? String(active.value) : active.textContent;
22706
+ return (value ?? "").trim() !== "";
22707
+ }
22278
22708
  #sprinkle(id) {
22279
22709
  return this.#sprinkles().find((candidate) => candidate.id === id);
22280
22710
  }
@@ -22290,11 +22720,11 @@ var SliccApp = class extends ThemedElement {
22290
22720
  return cone ? { ...sprinkle, title: `${cone.name} / ${sprinkle.title}` } : sprinkle;
22291
22721
  }).sort((a22, b13) => order.indexOf(a22.agentId) - order.indexOf(b13.agentId));
22292
22722
  }
22293
- #detach(id, place2, open) {
22723
+ #detach(id, place3, open) {
22294
22724
  const sprinkle = this.#sprinkle(id);
22295
22725
  if (!sprinkle) return;
22296
22726
  this.dips.detach(id);
22297
- if (open) openSprinkle(this.dock, sprinkle, this.screen, place2);
22727
+ if (open) openSprinkle(this.dock, sprinkle, this.screen, place3);
22298
22728
  }
22299
22729
  #dropped(event2) {
22300
22730
  const { type, data, panel, position } = event2.detail;
@@ -22373,6 +22803,7 @@ var SliccApp = class extends ThemedElement {
22373
22803
  this.model?.settings.update({ color: this.color === "dark" ? "light" : "dark" });
22374
22804
  }
22375
22805
  #keydown = (event2) => {
22806
+ if (editable(event2.composedPath()[0])) this.#typedAt = Date.now();
22376
22807
  if (!event2.altKey || event2.ctrlKey || event2.metaKey) return;
22377
22808
  const digit = event2.code.match(/^Digit([1-9])$/)?.[1] ?? event2.key.match(/^[1-9]$/)?.[0];
22378
22809
  const surface2 = digit ? this.#available()[Number(digit) - 1] : void 0;
@@ -22469,10 +22900,10 @@ var SliccApp = class extends ThemedElement {
22469
22900
  <swc-tooltip for="updates" placement="bottom">${text2}</swc-tooltip>`;
22470
22901
  }
22471
22902
  #tabsIndicator() {
22472
- const state2 = this.model?.tabs?.state();
22473
- const light = tabsLight(state2);
22474
- if (!state2 || !light) return A;
22475
- return b`<span id="tabs" class="tabs" tabindex="0" role="img" data-tabs data-role=${state2.role} ?data-stalled=${state2.stalled} data-skew=${state2.skew ?? A} aria-label=${`${light.text}. ${light.tooltip}`}>
22903
+ const state3 = this.model?.tabs?.state();
22904
+ const light = tabsLight(state3);
22905
+ if (!state3 || !light) return A;
22906
+ return b`<span id="tabs" class="tabs" tabindex="0" role="img" data-tabs data-role=${state3.role} ?data-stalled=${state3.stalled} data-skew=${state3.skew ?? A} aria-label=${`${light.text}. ${light.tooltip}`}>
22476
22907
  <swc-status-light size="s" variant=${light.variant}>${this.screen === "phone" ? A : light.text}</swc-status-light>
22477
22908
  </span>
22478
22909
  <swc-tooltip for="tabs" placement="bottom">${light.tooltip}</swc-tooltip>`;
@@ -22491,9 +22922,9 @@ var SliccApp = class extends ThemedElement {
22491
22922
  const port = this.model?.network;
22492
22923
  if (!port || !this.#offers("network")) return A;
22493
22924
  const status2 = networkStatus(port);
22494
- const [variant, state2] = networkHealth[status2.health];
22925
+ const [variant, state3] = networkHealth[status2.health];
22495
22926
  const label = networkLabel(status2);
22496
- const content = this.screen === "phone" ? networkIcon[status2.health] : b`<swc-status-light size="s" variant=${variant}>Network${status2.health === "ok" ? A : b`<span class="state"> ${state2.toLowerCase()}</span>`}</swc-status-light>`;
22927
+ const content = this.screen === "phone" ? networkIcon[status2.health] : b`<swc-status-light size="s" variant=${variant}>Network${status2.health === "ok" ? A : b`<span class="state"> ${state3.toLowerCase()}</span>`}</swc-status-light>`;
22497
22928
  return b`<swc-action-button id="network" quiet size="s" data-network data-health=${status2.health} accessible-label=${label} @click=${() => this.show("network")}>${content}</swc-action-button>
22498
22929
  <swc-tooltip for="network" placement="bottom">${status2.detail ?? label}${status2.tailnet?.state === "running" ? " Tailscale is connected." : ""}</swc-tooltip>`;
22499
22930
  }
@@ -22555,6 +22986,7 @@ var SliccApp = class extends ThemedElement {
22555
22986
  <main>
22556
22987
  ${rails.left}
22557
22988
  <slicc-dock empty-text="All panels are closed. Open one from a rail or View." @layout-change=${this.#save}
22989
+ @panel-close=${(event2) => this.panels.closed(event2.detail.id)}
22558
22990
  @active-panel-change=${this.#activated}
22559
22991
  @external-drop=${this.#dropped}
22560
22992
  @detach-sprinkle=${(event2) => this.#detach(event2.detail.id, null, true)}
@@ -22579,8 +23011,8 @@ function countdown(ms) {
22579
23011
  }
22580
23012
  function asking(approval) {
22581
23013
  const { kind, name, where: where2 } = approval.requester;
22582
- const place2 = where2 ? ` in ${where2}` : "";
22583
- return kind === "user" ? `You ran this with sudo${place2} (as ${name})` : `${name} wants to run this with sudo${place2}`;
23014
+ const place3 = where2 ? ` in ${where2}` : "";
23015
+ return kind === "user" ? `You ran this with sudo${place3} (as ${name})` : `${name} wants to run this with sudo${place3}`;
22584
23016
  }
22585
23017
  function sudo(approval) {
22586
23018
  const as = approval.target && approval.target !== "root" ? `-u ${approval.target} ` : "";
@@ -23132,7 +23564,7 @@ function host3(url) {
23132
23564
  return url;
23133
23565
  }
23134
23566
  }
23135
- function place(url) {
23567
+ function place2(url) {
23136
23568
  try {
23137
23569
  const { host: host4, pathname } = new URL(url);
23138
23570
  return host4 ? `${host4}${pathname === "/" ? "" : pathname}` : url;
@@ -23159,9 +23591,9 @@ function typed(action) {
23159
23591
  const count = action.length === void 0 ? "" : ` ${action.length} ${action.length === 1 ? "character" : "characters"}`;
23160
23592
  return `Typed${count}${action.target ? ` into ${action.target}` : ""}`;
23161
23593
  }
23162
- var verbs = {
23163
- open: (action) => `Opened ${place(action.value ?? "")}`.trim(),
23164
- goto: (action) => `Went to ${place(action.value ?? "")}`.trim(),
23594
+ var verbs2 = {
23595
+ open: (action) => `Opened ${place2(action.value ?? "")}`.trim(),
23596
+ goto: (action) => `Went to ${place2(action.value ?? "")}`.trim(),
23165
23597
  back: () => "Went back",
23166
23598
  reload: () => "Reloaded",
23167
23599
  close: () => "Closed tab",
@@ -23177,7 +23609,7 @@ var verbs = {
23177
23609
  request: (action) => called(action.value)
23178
23610
  };
23179
23611
  function describe(action) {
23180
- return verbs[action.kind](action);
23612
+ return verbs2[action.kind](action);
23181
23613
  }
23182
23614
  var icons = {
23183
23615
  open: b`<swc-icon-open-in size="s"></swc-icon-open-in>`,
@@ -23908,7 +24340,7 @@ var SliccBrowser = class extends ModelElement {
23908
24340
  ${wide ? A : this.#picker(tabs, tab)}
23909
24341
  </div>
23910
24342
  <div class="address">
23911
- <span class="url" title=${tab.url}>${narrow ? place(tab.url) : tab.url}</span>
24343
+ <span class="url" title=${tab.url}>${narrow ? place2(tab.url) : tab.url}</span>
23912
24344
  <swc-action-button size="s" quiet data-action="copy-url" accessible-label=${copy === "Copy" ? "Copy URL" : copy} @click=${() => this.#copy(tab.url)}><swc-icon-copy slot="icon"></swc-icon-copy>${narrow ? A : copy}</swc-action-button>
23913
24345
  <swc-action-button size="s" quiet data-action="open-tab" accessible-label="Show in the browser" @click=${() => this.model?.browser.activate(tab.id)}><swc-icon-open-in slot="icon"></swc-icon-open-in>${narrow ? A : "Open"}</swc-action-button>
23914
24346
  </div>
@@ -24734,7 +25166,7 @@ var SliccChat = class extends ThemedElement {
24734
25166
  model: null,
24735
25167
  readOnly: false,
24736
25168
  answer: (questionId, answer) => this.model?.agent.answer(this.#id(), questionId, answer),
24737
- resolve: (messageId, state2) => this.model?.agent.resolveLick(this.#id(), messageId, state2),
25169
+ resolve: (messageId, state3) => this.model?.agent.resolveLick(this.#id(), messageId, state3),
24738
25170
  action: (action, messageId) => this.#action(action, messageId),
24739
25171
  dropping: (messageId) => failedTurns(this.model.agent.messages(this.#id()), messageId).length,
24740
25172
  open: (path) => this.dispatchEvent(
@@ -24823,6 +25255,14 @@ var SliccChat = class extends ThemedElement {
24823
25255
  #id() {
24824
25256
  return this.agent || (this.model?.agent.active() ?? "");
24825
25257
  }
25258
+ get busyReason() {
25259
+ const open = (this.model?.agent.messages(this.#id()) ?? []).some(
25260
+ (message) => ("parts" in message ? message.parts : []).some(
25261
+ (part2) => part2.type === "question" && part2.question.state === "open"
25262
+ )
25263
+ );
25264
+ return open ? "a question waits for an answer" : null;
25265
+ }
24826
25266
  #agent() {
24827
25267
  const id = this.#id();
24828
25268
  return this.model?.agent.list().find((agent) => agent.id === id);
@@ -25874,9 +26314,9 @@ var commands2 = [
25874
26314
  }
25875
26315
  ];
25876
26316
  function readFile(file) {
25877
- return new Promise((resolve, reject) => {
26317
+ return new Promise((resolve2, reject) => {
25878
26318
  const reader = new FileReader();
25879
- reader.onload = () => resolve(String(reader.result));
26319
+ reader.onload = () => resolve2(String(reader.result));
25880
26320
  reader.onerror = () => reject(reader.error);
25881
26321
  if (file.type.startsWith("image/")) reader.readAsDataURL(file);
25882
26322
  else reader.readAsText(file);
@@ -26165,8 +26605,8 @@ var SliccComposer = class extends ModelElement {
26165
26605
  ];
26166
26606
  }
26167
26607
  #held() {
26168
- const state2 = this.model?.follow?.state();
26169
- return state2?.link === "reconnecting" ? state2.owner : null;
26608
+ const state3 = this.model?.follow?.state();
26609
+ return state3?.link === "reconnecting" ? state3.owner : null;
26170
26610
  }
26171
26611
  #switch(id) {
26172
26612
  if (this.#agent)
@@ -27699,6 +28139,11 @@ var SliccSettings = class extends ModelElement {
27699
28139
  this.#cancelled.add(account.id);
27700
28140
  this.model?.settings.cancel?.(account.id);
27701
28141
  }
28142
+ get busyReason() {
28143
+ const accounts = this.model?.settings.accounts() ?? [];
28144
+ if (accounts.some((account) => this.#signingIn(account))) return "signing in";
28145
+ return this.entering === null ? null : "a key is being entered";
28146
+ }
27702
28147
  #signingIn(account) {
27703
28148
  return account.status === "signing-in" || account.auth !== "api-key" && account.status !== "connected" && this.pending.has(account.id);
27704
28149
  }
@@ -27942,9 +28387,9 @@ function literal(value) {
27942
28387
  return "null";
27943
28388
  }
27944
28389
  }
27945
- function store(state2) {
28390
+ function store(state3) {
27946
28391
  return `(() => {
27947
- let state = ${literal(state2)};
28392
+ let state = ${literal(state3)};
27948
28393
  const tag = Math.random().toString(36).slice(2);
27949
28394
  const pending = new Map();
27950
28395
  let next = 0;
@@ -27982,11 +28427,11 @@ function store(state2) {
27982
28427
  });
27983
28428
  })();`;
27984
28429
  }
27985
- function frameDocument(source, color, name, state2) {
28430
+ function frameDocument(source, color, name, state3) {
27986
28431
  const scheme = `<style>${sprinkleTokens}${sprinkle_theme_default}</style>`;
27987
28432
  const light = `<script>document.documentElement.classList.toggle('theme-light', ${color === "light"});<\/script>`;
27988
28433
  const script = `<script data-name="${name.replace(/"/g, "&quot;")}">${bridge}<\/script>`;
27989
- const injection = light + scheme + script + (state2 ? `<script>${store(state2.value)}<\/script>` : "");
28434
+ const injection = light + scheme + script + (state3 ? `<script>${store(state3.value)}<\/script>` : "");
27990
28435
  const head2 = source.match(/<head\b[^>]*>/i);
27991
28436
  if (!head2 || head2.index === void 0) return injection + source;
27992
28437
  const at = head2.index + head2[0].length;
@@ -28197,12 +28642,12 @@ var SliccSprinkle = class extends ThemedElement {
28197
28642
  return this.model?.sprinkles.list().find((candidate) => candidate.id === this.sprinkle);
28198
28643
  }
28199
28644
  #frame = { key: "", doc: "" };
28200
- #document(data, state2) {
28201
- const key2 = `${!!state2}
28645
+ #document(data, state3) {
28646
+ const key2 = `${!!state3}
28202
28647
  ${data.name}
28203
28648
  ${data.html}`;
28204
28649
  if (this.#frame.key !== key2)
28205
- this.#frame = { key: key2, doc: frameDocument(data.html, this.color, data.name, state2) };
28650
+ this.#frame = { key: key2, doc: frameDocument(data.html, this.color, data.name, state3) };
28206
28651
  return this.#frame.doc;
28207
28652
  }
28208
28653
  updated(changed) {
@@ -28226,11 +28671,11 @@ ${data.html}`;
28226
28671
  }
28227
28672
  const bridged = !!this.model?.sprinkles.call;
28228
28673
  if (bridged && !this.#held.ready) return b``;
28229
- const state2 = bridged ? this.#held : void 0;
28674
+ const state3 = bridged ? this.#held : void 0;
28230
28675
  const style = `color-scheme:${this.color};${this.inline ? `height:${this.height}px;` : ""}`;
28231
28676
  const frame = b`${i17(
28232
28677
  this.#mounts,
28233
- b`<iframe title=${data.title} sandbox="allow-scripts" style=${style} .srcdoc=${this.#document(data, state2)}></iframe>`
28678
+ b`<iframe title=${data.title} sandbox="allow-scripts" style=${style} .srcdoc=${this.#document(data, state3)}></iframe>`
28234
28679
  )}`;
28235
28680
  if (!this.inline) return frame;
28236
28681
  return b`<div class="handle" draggable="true" title="Drag into the dock or a rail to open as a panel" @dragstart=${this.#drag}>
@@ -34138,8 +34583,8 @@ async function createShikiPrimitiveAsync(options) {
34138
34583
  });
34139
34584
  }
34140
34585
  var _grammarStateMap = /* @__PURE__ */ new WeakMap();
34141
- function setLastGrammarStateToMap(keys, state2) {
34142
- _grammarStateMap.set(keys, state2);
34586
+ function setLastGrammarStateToMap(keys, state3) {
34587
+ _grammarStateMap.set(keys, state3);
34143
34588
  }
34144
34589
  function getLastGrammarStateFromMap(keys) {
34145
34590
  return _grammarStateMap.get(keys);
@@ -34208,9 +34653,9 @@ function getScopes(stack) {
34208
34653
  pushScope(stack);
34209
34654
  return scopes;
34210
34655
  }
34211
- function getGrammarStack(state2, theme3) {
34212
- if (!(state2 instanceof GrammarState)) throw new ShikiError2("Invalid grammar state");
34213
- return state2.getInternalStack(theme3);
34656
+ function getGrammarStack(state3, theme3) {
34657
+ if (!(state3 instanceof GrammarState)) throw new ShikiError2("Invalid grammar state");
34658
+ return state3.getInternalStack(theme3);
34214
34659
  }
34215
34660
  var RE_COMMA = /,/;
34216
34661
  var RE_SPACE = / /;
@@ -34583,8 +35028,8 @@ var DefinedInfo = class extends Info {
34583
35028
  mark(this, "space", space);
34584
35029
  if (typeof mask === "number") {
34585
35030
  while (++index < checks.length) {
34586
- const check2 = checks[index];
34587
- mark(this, checks[index], (mask & types_exports[check2]) === types_exports[check2]);
35031
+ const check3 = checks[index];
35032
+ mark(this, checks[index], (mask & types_exports[check3]) === types_exports[check3]);
34588
35033
  }
34589
35034
  }
34590
35035
  }
@@ -36213,17 +36658,17 @@ function stringifyEntities(value, options) {
36213
36658
  var htmlCommentRegex = /^>|^->|<!--|-->|--!>|<!-$/g;
36214
36659
  var bogusCommentEntitySubset = [">"];
36215
36660
  var commentEntitySubset = ["<", ">"];
36216
- function comment(node, _1, _22, state2) {
36217
- return state2.settings.bogusComments ? "<?" + stringifyEntities(
36661
+ function comment(node, _1, _22, state3) {
36662
+ return state3.settings.bogusComments ? "<?" + stringifyEntities(
36218
36663
  node.value,
36219
- Object.assign({}, state2.settings.characterReferences, {
36664
+ Object.assign({}, state3.settings.characterReferences, {
36220
36665
  subset: bogusCommentEntitySubset
36221
36666
  })
36222
36667
  ) + ">" : "<!--" + node.value.replace(htmlCommentRegex, encode2) + "-->";
36223
36668
  function encode2($0) {
36224
36669
  return stringifyEntities(
36225
36670
  $0,
36226
- Object.assign({}, state2.settings.characterReferences, {
36671
+ Object.assign({}, state3.settings.characterReferences, {
36227
36672
  subset: commentEntitySubset
36228
36673
  })
36229
36674
  );
@@ -36231,8 +36676,8 @@ function comment(node, _1, _22, state2) {
36231
36676
  }
36232
36677
 
36233
36678
  // node_modules/hast-util-to-html/lib/handle/doctype.js
36234
- function doctype(_1, _22, _32, state2) {
36235
- return "<!" + (state2.settings.upperDoctype ? "DOCTYPE" : "doctype") + (state2.settings.tightDoctype ? "" : " ") + "html>";
36679
+ function doctype(_1, _22, _32, state3) {
36680
+ return "<!" + (state3.settings.upperDoctype ? "DOCTYPE" : "doctype") + (state3.settings.tightDoctype ? "" : " ") + "html>";
36236
36681
  }
36237
36682
 
36238
36683
  // node_modules/ccount/index.js
@@ -36457,26 +36902,26 @@ var constants = {
36457
36902
  ['\0"&'.split(""), "\0\"&'`".split("")]
36458
36903
  ]
36459
36904
  };
36460
- function element(node, index, parent, state2) {
36461
- const schema = state2.schema;
36462
- const omit = schema.space === "svg" ? false : state2.settings.omitOptionalTags;
36463
- let selfClosing = schema.space === "svg" ? state2.settings.closeEmptyElements : state2.settings.voids.includes(node.tagName.toLowerCase());
36905
+ function element(node, index, parent, state3) {
36906
+ const schema = state3.schema;
36907
+ const omit = schema.space === "svg" ? false : state3.settings.omitOptionalTags;
36908
+ let selfClosing = schema.space === "svg" ? state3.settings.closeEmptyElements : state3.settings.voids.includes(node.tagName.toLowerCase());
36464
36909
  const parts2 = [];
36465
36910
  let last;
36466
36911
  if (schema.space === "html" && node.tagName === "svg") {
36467
- state2.schema = svg3;
36912
+ state3.schema = svg3;
36468
36913
  }
36469
- const attributes = serializeAttributes(state2, node.properties);
36470
- const content = state2.all(
36914
+ const attributes = serializeAttributes(state3, node.properties);
36915
+ const content = state3.all(
36471
36916
  schema.space === "html" && node.tagName === "template" ? node.content : node
36472
36917
  );
36473
- state2.schema = schema;
36918
+ state3.schema = schema;
36474
36919
  if (content) selfClosing = false;
36475
36920
  if (attributes || !omit || !opening(node, index, parent)) {
36476
36921
  parts2.push("<", node.tagName, attributes ? " " + attributes : "");
36477
- if (selfClosing && (schema.space === "svg" || state2.settings.closeSelfClosing)) {
36922
+ if (selfClosing && (schema.space === "svg" || state3.settings.closeSelfClosing)) {
36478
36923
  last = attributes.charAt(attributes.length - 1);
36479
- if (!state2.settings.tightSelfClosing || last === "/" || last && last !== '"' && last !== "'") {
36924
+ if (!state3.settings.tightSelfClosing || last === "/" || last && last !== '"' && last !== "'") {
36480
36925
  parts2.push(" ");
36481
36926
  }
36482
36927
  parts2.push("/");
@@ -36489,31 +36934,31 @@ function element(node, index, parent, state2) {
36489
36934
  }
36490
36935
  return parts2.join("");
36491
36936
  }
36492
- function serializeAttributes(state2, properties) {
36937
+ function serializeAttributes(state3, properties) {
36493
36938
  const values = [];
36494
36939
  let index = -1;
36495
36940
  let key2;
36496
36941
  if (properties) {
36497
36942
  for (key2 in properties) {
36498
36943
  if (properties[key2] !== null && properties[key2] !== void 0) {
36499
- const value = serializeAttribute(state2, key2, properties[key2]);
36944
+ const value = serializeAttribute(state3, key2, properties[key2]);
36500
36945
  if (value) values.push(value);
36501
36946
  }
36502
36947
  }
36503
36948
  }
36504
36949
  while (++index < values.length) {
36505
- const last = state2.settings.tightAttributes ? values[index].charAt(values[index].length - 1) : void 0;
36950
+ const last = state3.settings.tightAttributes ? values[index].charAt(values[index].length - 1) : void 0;
36506
36951
  if (index !== values.length - 1 && last !== '"' && last !== "'") {
36507
36952
  values[index] += " ";
36508
36953
  }
36509
36954
  }
36510
36955
  return values.join("");
36511
36956
  }
36512
- function serializeAttribute(state2, key2, value) {
36513
- const info = find(state2.schema, key2);
36514
- const x7 = state2.settings.allowParseErrors && state2.schema.space === "html" ? 0 : 1;
36515
- const y10 = state2.settings.allowDangerousCharacters ? 0 : 1;
36516
- let quote = state2.quote;
36957
+ function serializeAttribute(state3, key2, value) {
36958
+ const info = find(state3.schema, key2);
36959
+ const x7 = state3.settings.allowParseErrors && state3.schema.space === "html" ? 0 : 1;
36960
+ const y10 = state3.settings.allowDangerousCharacters ? 0 : 1;
36961
+ let quote = state3.quote;
36517
36962
  let result;
36518
36963
  if (info.overloadedBoolean && (value === info.attribute || value === "")) {
36519
36964
  value = true;
@@ -36525,32 +36970,32 @@ function serializeAttribute(state2, key2, value) {
36525
36970
  }
36526
36971
  const name = stringifyEntities(
36527
36972
  info.attribute,
36528
- Object.assign({}, state2.settings.characterReferences, {
36973
+ Object.assign({}, state3.settings.characterReferences, {
36529
36974
  // Always encode without parse errors in non-HTML.
36530
36975
  subset: constants.name[x7][y10]
36531
36976
  })
36532
36977
  );
36533
36978
  if (value === true) return name;
36534
36979
  value = Array.isArray(value) ? (info.commaSeparated ? stringify : stringify2)(value, {
36535
- padLeft: !state2.settings.tightCommaSeparatedLists
36980
+ padLeft: !state3.settings.tightCommaSeparatedLists
36536
36981
  }) : String(value);
36537
- if (state2.settings.collapseEmptyAttributes && !value) return name;
36538
- if (state2.settings.preferUnquoted) {
36982
+ if (state3.settings.collapseEmptyAttributes && !value) return name;
36983
+ if (state3.settings.preferUnquoted) {
36539
36984
  result = stringifyEntities(
36540
36985
  value,
36541
- Object.assign({}, state2.settings.characterReferences, {
36986
+ Object.assign({}, state3.settings.characterReferences, {
36542
36987
  attribute: true,
36543
36988
  subset: constants.unquoted[x7][y10]
36544
36989
  })
36545
36990
  );
36546
36991
  }
36547
36992
  if (result !== value) {
36548
- if (state2.settings.quoteSmart && ccount(value, quote) > ccount(value, state2.alternative)) {
36549
- quote = state2.alternative;
36993
+ if (state3.settings.quoteSmart && ccount(value, quote) > ccount(value, state3.alternative)) {
36994
+ quote = state3.alternative;
36550
36995
  }
36551
36996
  result = quote + stringifyEntities(
36552
36997
  value,
36553
- Object.assign({}, state2.settings.characterReferences, {
36998
+ Object.assign({}, state3.settings.characterReferences, {
36554
36999
  // Always encode without parse errors in non-HTML.
36555
37000
  subset: (quote === "'" ? constants.single : constants.double)[x7][y10],
36556
37001
  attribute: true
@@ -36562,35 +37007,35 @@ function serializeAttribute(state2, key2, value) {
36562
37007
 
36563
37008
  // node_modules/hast-util-to-html/lib/handle/text.js
36564
37009
  var textEntitySubset = ["<", "&"];
36565
- function text(node, _9, parent, state2) {
37010
+ function text(node, _9, parent, state3) {
36566
37011
  return parent && parent.type === "element" && (parent.tagName === "script" || parent.tagName === "style") ? node.value : stringifyEntities(
36567
37012
  node.value,
36568
- Object.assign({}, state2.settings.characterReferences, {
37013
+ Object.assign({}, state3.settings.characterReferences, {
36569
37014
  subset: textEntitySubset
36570
37015
  })
36571
37016
  );
36572
37017
  }
36573
37018
 
36574
37019
  // node_modules/hast-util-to-html/lib/handle/raw.js
36575
- function raw(node, index, parent, state2) {
36576
- return state2.settings.allowDangerousHtml ? node.value : text(node, index, parent, state2);
37020
+ function raw(node, index, parent, state3) {
37021
+ return state3.settings.allowDangerousHtml ? node.value : text(node, index, parent, state3);
36577
37022
  }
36578
37023
 
36579
37024
  // node_modules/hast-util-to-html/lib/handle/root.js
36580
- function root(node, _1, _22, state2) {
36581
- return state2.all(node);
37025
+ function root(node, _1, _22, state3) {
37026
+ return state3.all(node);
36582
37027
  }
36583
37028
 
36584
37029
  // node_modules/hast-util-to-html/lib/handle/index.js
36585
37030
  var handle = zwitch("type", {
36586
37031
  invalid,
36587
- unknown,
37032
+ unknown: unknown2,
36588
37033
  handlers: { comment, doctype, element, raw, root, text }
36589
37034
  });
36590
37035
  function invalid(node) {
36591
37036
  throw new Error("Expected node, not `" + node + "`");
36592
37037
  }
36593
- function unknown(node_) {
37038
+ function unknown2(node_) {
36594
37039
  const node = (
36595
37040
  /** @type {Nodes} */
36596
37041
  node_
@@ -36609,7 +37054,7 @@ function toHtml(tree, options) {
36609
37054
  if (quote !== '"' && quote !== "'") {
36610
37055
  throw new Error("Invalid quote `" + quote + "`, expected `'` or `\"`");
36611
37056
  }
36612
- const state2 = {
37057
+ const state3 = {
36613
37058
  one,
36614
37059
  all,
36615
37060
  settings: {
@@ -36635,7 +37080,7 @@ function toHtml(tree, options) {
36635
37080
  quote,
36636
37081
  alternative
36637
37082
  };
36638
- return state2.one(
37083
+ return state3.one(
36639
37084
  Array.isArray(tree) ? { type: "root", children: tree } : tree,
36640
37085
  void 0,
36641
37086
  void 0
@@ -39536,9 +39981,9 @@ var FirstPassVisitor = {
39536
39981
  }
39537
39982
  }
39538
39983
  },
39539
- Assertion({ node, parent, key: key2, container, root: root2, remove: remove2, replaceWith }, state2) {
39984
+ Assertion({ node, parent, key: key2, container, root: root2, remove: remove2, replaceWith }, state3) {
39540
39985
  const { kind, negate } = node;
39541
- const { asciiWordBoundaries, avoidSubclass, supportedGNodes, wordIsAscii } = state2;
39986
+ const { asciiWordBoundaries, avoidSubclass, supportedGNodes, wordIsAscii } = state3;
39542
39987
  if (kind === "text_segment_boundary") {
39543
39988
  throw new Error(`Unsupported text segment boundary "\\${negate ? "Y" : "y"}"`);
39544
39989
  } else if (kind === "line_end") {
@@ -39561,7 +40006,7 @@ var FirstPassVisitor = {
39561
40006
  throw new Error(r36`Uses "\G" in a way that requires a subclass`);
39562
40007
  } else {
39563
40008
  replaceWith(setParent(F3("string_start"), parent));
39564
- state2.strategy = "clip_search";
40009
+ state3.strategy = "clip_search";
39565
40010
  }
39566
40011
  }
39567
40012
  } else if (kind === "string_end" || kind === "string_start") {
@@ -39754,10 +40199,10 @@ var FirstPassVisitor = {
39754
40199
  disable && !Object.keys(disable).length && delete node.flags.disable;
39755
40200
  !node.flags.enable && !node.flags.disable && delete node.flags;
39756
40201
  },
39757
- LookaroundAssertion({ node }, state2) {
40202
+ LookaroundAssertion({ node }, state3) {
39758
40203
  const { kind } = node;
39759
40204
  if (kind === "lookbehind") {
39760
- state2.passedLookbehind = true;
40205
+ state3.passedLookbehind = true;
39761
40206
  }
39762
40207
  },
39763
40208
  NamedCallout({ node, parent, replaceWith }) {
@@ -39884,17 +40329,17 @@ var SecondPassVisitor = {
39884
40329
  }
39885
40330
  },
39886
40331
  Group: {
39887
- enter({ node }, state2) {
39888
- state2.prevFlags = state2.currentFlags;
40332
+ enter({ node }, state3) {
40333
+ state3.prevFlags = state3.currentFlags;
39889
40334
  if (node.flags) {
39890
- state2.currentFlags = getNewCurrentFlags(state2.currentFlags, node.flags);
40335
+ state3.currentFlags = getNewCurrentFlags(state3.currentFlags, node.flags);
39891
40336
  }
39892
40337
  },
39893
- exit(_9, state2) {
39894
- state2.currentFlags = state2.prevFlags;
40338
+ exit(_9, state3) {
40339
+ state3.currentFlags = state3.prevFlags;
39895
40340
  }
39896
40341
  },
39897
- Subroutine({ node, parent, replaceWith }, state2) {
40342
+ Subroutine({ node, parent, replaceWith }, state3) {
39898
40343
  const { isRecursive, ref } = node;
39899
40344
  if (isRecursive) {
39900
40345
  let reffed = parent;
@@ -39903,14 +40348,14 @@ var SecondPassVisitor = {
39903
40348
  break;
39904
40349
  }
39905
40350
  }
39906
- state2.reffedNodesByReferencer.set(node, reffed);
40351
+ state3.reffedNodesByReferencer.set(node, reffed);
39907
40352
  return;
39908
40353
  }
39909
- const reffedGroupNode = state2.subroutineRefMap.get(ref);
40354
+ const reffedGroupNode = state3.subroutineRefMap.get(ref);
39910
40355
  const isGlobalRecursion = ref === 0;
39911
40356
  const expandedSubroutine = isGlobalRecursion ? createRecursion(0) : (
39912
40357
  // The reffed group might itself contain subroutines, which are expanded during sub-traversal
39913
- cloneCapturingGroup(reffedGroupNode, state2.groupOriginByCopy, null)
40358
+ cloneCapturingGroup(reffedGroupNode, state3.groupOriginByCopy, null)
39914
40359
  );
39915
40360
  let replacement = expandedSubroutine;
39916
40361
  if (!isGlobalRecursion) {
@@ -39918,8 +40363,8 @@ var SecondPassVisitor = {
39918
40363
  reffedGroupNode,
39919
40364
  (p17) => p17.type === "Group" && !!p17.flags
39920
40365
  ));
39921
- const reffedGroupFlags = reffedGroupFlagMods ? getNewCurrentFlags(state2.globalFlags, reffedGroupFlagMods) : state2.globalFlags;
39922
- if (!areFlagsEqual(reffedGroupFlags, state2.currentFlags)) {
40366
+ const reffedGroupFlags = reffedGroupFlagMods ? getNewCurrentFlags(state3.globalFlags, reffedGroupFlagMods) : state3.globalFlags;
40367
+ if (!areFlagsEqual(reffedGroupFlags, state3.currentFlags)) {
39923
40368
  replacement = A6({
39924
40369
  flags: getFlagModsFromFlags(reffedGroupFlags)
39925
40370
  });
@@ -39930,12 +40375,12 @@ var SecondPassVisitor = {
39930
40375
  }
39931
40376
  };
39932
40377
  var ThirdPassVisitor = {
39933
- Backreference({ node, parent, replaceWith }, state2) {
40378
+ Backreference({ node, parent, replaceWith }, state3) {
39934
40379
  if (node.orphan) {
39935
- state2.highestOrphanBackref = Math.max(state2.highestOrphanBackref, node.ref);
40380
+ state3.highestOrphanBackref = Math.max(state3.highestOrphanBackref, node.ref);
39936
40381
  return;
39937
40382
  }
39938
- const reffedNodes = state2.reffedNodesByReferencer.get(node);
40383
+ const reffedNodes = state3.reffedNodesByReferencer.get(node);
39939
40384
  const participants = reffedNodes.filter((reffed) => canParticipateWithNode(reffed, node));
39940
40385
  if (!participants.length) {
39941
40386
  replaceWith(setParentDeep(K2({ negate: true }), parent));
@@ -39951,28 +40396,28 @@ var ThirdPassVisitor = {
39951
40396
  node.ref = participants[0].number;
39952
40397
  }
39953
40398
  },
39954
- CapturingGroup({ node }, state2) {
39955
- node.number = ++state2.numCapturesToLeft;
40399
+ CapturingGroup({ node }, state3) {
40400
+ node.number = ++state3.numCapturesToLeft;
39956
40401
  if (node.name) {
39957
- if (state2.groupsByName.get(node.name).get(node).hasDuplicateNameToRemove) {
40402
+ if (state3.groupsByName.get(node.name).get(node).hasDuplicateNameToRemove) {
39958
40403
  delete node.name;
39959
40404
  }
39960
40405
  }
39961
40406
  },
39962
40407
  Regex: {
39963
- exit({ node }, state2) {
39964
- const numCapsNeeded = Math.max(state2.highestOrphanBackref - state2.numCapturesToLeft, 0);
40408
+ exit({ node }, state3) {
40409
+ const numCapsNeeded = Math.max(state3.highestOrphanBackref - state3.numCapturesToLeft, 0);
39965
40410
  for (let i25 = 0; i25 < numCapsNeeded; i25++) {
39966
40411
  const emptyCapture = P3();
39967
40412
  node.body.at(-1).body.push(emptyCapture);
39968
40413
  }
39969
40414
  }
39970
40415
  },
39971
- Subroutine({ node }, state2) {
40416
+ Subroutine({ node }, state3) {
39972
40417
  if (!node.isRecursive || node.ref === 0) {
39973
40418
  return;
39974
40419
  }
39975
- node.ref = state2.reffedNodesByReferencer.get(node).number;
40420
+ node.ref = state3.reffedNodesByReferencer.get(node).number;
39976
40421
  }
39977
40422
  };
39978
40423
  function addParentProperties(root2) {
@@ -40214,7 +40659,7 @@ function generate(ast, options) {
40214
40659
  ignoreCase: !!((ast.flags.ignoreCase || hasCaseInsensitiveNode) && !hasCaseSensitiveNode)
40215
40660
  };
40216
40661
  let lastNode = ast;
40217
- const state2 = {
40662
+ const state3 = {
40218
40663
  accuracy: opts.accuracy,
40219
40664
  appliedGlobalFlags,
40220
40665
  captureMap: /* @__PURE__ */ new Map(),
@@ -40232,10 +40677,10 @@ function generate(ast, options) {
40232
40677
  verbose: opts.verbose
40233
40678
  };
40234
40679
  function gen(node) {
40235
- state2.lastNode = lastNode;
40680
+ state3.lastNode = lastNode;
40236
40681
  lastNode = node;
40237
40682
  const fn = throwIfNullish(generator[node.type], `Unexpected node type "${node.type}"`);
40238
- return fn(node, state2, gen);
40683
+ return fn(node, state3, gen);
40239
40684
  }
40240
40685
  const result = {
40241
40686
  pattern: ast.body.map(gen).join("|"),
@@ -40250,7 +40695,7 @@ function generate(ast, options) {
40250
40695
  }
40251
40696
  result._captureTransfers = /* @__PURE__ */ new Map();
40252
40697
  result._hiddenCaptures = [];
40253
- state2.captureMap.forEach((value, key2) => {
40698
+ state3.captureMap.forEach((value, key2) => {
40254
40699
  if (value.hidden) {
40255
40700
  result._hiddenCaptures.push(key2);
40256
40701
  }
@@ -40262,37 +40707,37 @@ function generate(ast, options) {
40262
40707
  }
40263
40708
  var FlagModifierVisitor = {
40264
40709
  "*": {
40265
- enter({ node }, state2) {
40710
+ enter({ node }, state3) {
40266
40711
  if (isAnyGroup(node)) {
40267
- const currentModI = state2.getCurrentModI();
40268
- state2.pushModI(
40712
+ const currentModI = state3.getCurrentModI();
40713
+ state3.pushModI(
40269
40714
  node.flags ? getNewCurrentFlags({ ignoreCase: currentModI }, node.flags).ignoreCase : currentModI
40270
40715
  );
40271
40716
  }
40272
40717
  },
40273
- exit({ node }, state2) {
40718
+ exit({ node }, state3) {
40274
40719
  if (isAnyGroup(node)) {
40275
- state2.popModI();
40720
+ state3.popModI();
40276
40721
  }
40277
40722
  }
40278
40723
  },
40279
- Backreference(_9, state2) {
40280
- state2.setHasCasedChar();
40724
+ Backreference(_9, state3) {
40725
+ state3.setHasCasedChar();
40281
40726
  },
40282
- Character({ node }, state2) {
40727
+ Character({ node }, state3) {
40283
40728
  if (charHasCase(cp(node.value))) {
40284
- state2.setHasCasedChar();
40729
+ state3.setHasCasedChar();
40285
40730
  }
40286
40731
  },
40287
- CharacterClassRange({ node, skip }, state2) {
40732
+ CharacterClassRange({ node, skip }, state3) {
40288
40733
  skip();
40289
40734
  if (getCasesOutsideCharClassRange(node, { firstOnly: true }).length) {
40290
- state2.setHasCasedChar();
40735
+ state3.setHasCasedChar();
40291
40736
  }
40292
40737
  },
40293
- CharacterSet({ node }, state2) {
40738
+ CharacterSet({ node }, state3) {
40294
40739
  if (node.kind === "property" && UnicodePropertiesWithSpecificCase.has(node.value)) {
40295
- state2.setHasCasedChar();
40740
+ state3.setHasCasedChar();
40296
40741
  }
40297
40742
  }
40298
40743
  };
@@ -40321,11 +40766,11 @@ var generator = {
40321
40766
  /**
40322
40767
  @param {BackreferenceNode} node
40323
40768
  */
40324
- Backreference({ ref }, state2) {
40769
+ Backreference({ ref }, state3) {
40325
40770
  if (typeof ref !== "number") {
40326
40771
  throw new Error("Unexpected named backref in transformed AST");
40327
40772
  }
40328
- if (!state2.useFlagMods && state2.accuracy === "strict" && state2.currentFlags.ignoreCase && !state2.captureMap.get(ref).ignoreCase) {
40773
+ if (!state3.useFlagMods && state3.accuracy === "strict" && state3.currentFlags.ignoreCase && !state3.captureMap.get(ref).ignoreCase) {
40329
40774
  throw new Error("Use of case-insensitive backref to case-sensitive group requires target ES2025 or non-strict accuracy");
40330
40775
  }
40331
40776
  return "\\" + ref;
@@ -40333,55 +40778,55 @@ var generator = {
40333
40778
  /**
40334
40779
  @param {CapturingGroupNode} node
40335
40780
  */
40336
- CapturingGroup(node, state2, gen) {
40781
+ CapturingGroup(node, state3, gen) {
40337
40782
  const { body: body4, name, number: number2 } = node;
40338
- const data = { ignoreCase: state2.currentFlags.ignoreCase };
40339
- const origin = state2.originMap.get(node);
40783
+ const data = { ignoreCase: state3.currentFlags.ignoreCase };
40784
+ const origin = state3.originMap.get(node);
40340
40785
  if (origin) {
40341
40786
  data.hidden = true;
40342
40787
  if (number2 > origin.number) {
40343
40788
  data.transferTo = origin.number;
40344
40789
  }
40345
40790
  }
40346
- state2.captureMap.set(number2, data);
40791
+ state3.captureMap.set(number2, data);
40347
40792
  return `(${name ? `?<${name}>` : ""}${body4.map(gen).join("|")})`;
40348
40793
  },
40349
40794
  /**
40350
40795
  @param {CharacterNode} node
40351
40796
  */
40352
- Character({ value }, state2) {
40797
+ Character({ value }, state3) {
40353
40798
  const char = cp(value);
40354
40799
  const escaped = getCharEscape(value, {
40355
- escDigit: state2.lastNode.type === "Backreference",
40356
- inCharClass: state2.inCharClass,
40357
- useFlagV: state2.useFlagV
40800
+ escDigit: state3.lastNode.type === "Backreference",
40801
+ inCharClass: state3.inCharClass,
40802
+ useFlagV: state3.useFlagV
40358
40803
  });
40359
40804
  if (escaped !== char) {
40360
40805
  return escaped;
40361
40806
  }
40362
- if (state2.useAppliedIgnoreCase && state2.currentFlags.ignoreCase && charHasCase(char)) {
40807
+ if (state3.useAppliedIgnoreCase && state3.currentFlags.ignoreCase && charHasCase(char)) {
40363
40808
  const cases = getIgnoreCaseMatchChars(char);
40364
- return state2.inCharClass ? cases.join("") : cases.length > 1 ? `[${cases.join("")}]` : cases[0];
40809
+ return state3.inCharClass ? cases.join("") : cases.length > 1 ? `[${cases.join("")}]` : cases[0];
40365
40810
  }
40366
40811
  return char;
40367
40812
  },
40368
40813
  /**
40369
40814
  @param {CharacterClassNode} node
40370
40815
  */
40371
- CharacterClass(node, state2, gen) {
40816
+ CharacterClass(node, state3, gen) {
40372
40817
  const { kind, negate, parent } = node;
40373
40818
  let { body: body4 } = node;
40374
- if (kind === "intersection" && !state2.useFlagV) {
40819
+ if (kind === "intersection" && !state3.useFlagV) {
40375
40820
  throw new Error("Use of character class intersection requires min target ES2024");
40376
40821
  }
40377
- if (envFlags.bugFlagVLiteralHyphenIsRange && state2.useFlagV && body4.some(isLiteralHyphen)) {
40822
+ if (envFlags.bugFlagVLiteralHyphenIsRange && state3.useFlagV && body4.some(isLiteralHyphen)) {
40378
40823
  body4 = [m12(45), ...body4.filter((kid) => !isLiteralHyphen(kid))];
40379
40824
  }
40380
40825
  const genClass = () => `[${negate ? "^" : ""}${body4.map(gen).join(kind === "intersection" ? "&&" : "")}]`;
40381
- if (!state2.inCharClass) {
40826
+ if (!state3.inCharClass) {
40382
40827
  if (
40383
40828
  // Already established `kind !== 'intersection'` if `!state.useFlagV`; don't check again
40384
- (!state2.useFlagV || envFlags.bugNestedClassIgnoresNegation) && !negate
40829
+ (!state3.useFlagV || envFlags.bugNestedClassIgnoresNegation) && !negate
40385
40830
  ) {
40386
40831
  const negatedChildClasses = body4.filter(
40387
40832
  (kid) => kid.type === "CharacterClass" && kid.kind === "union" && kid.negate
@@ -40408,21 +40853,21 @@ var generator = {
40408
40853
  return gen(group);
40409
40854
  }
40410
40855
  }
40411
- state2.inCharClass = true;
40856
+ state3.inCharClass = true;
40412
40857
  const result = genClass();
40413
- state2.inCharClass = false;
40858
+ state3.inCharClass = false;
40414
40859
  return result;
40415
40860
  }
40416
40861
  const firstEl = body4[0];
40417
40862
  if (
40418
40863
  // Already established that the parent is a char class via `inCharClass`; don't check again
40419
40864
  kind === "union" && !negate && firstEl && // Allows many nested classes to work with `target` ES2018 which doesn't support nesting
40420
- ((!state2.useFlagV || !state2.verbose) && parent.kind === "union" && !(envFlags.bugFlagVLiteralHyphenIsRange && state2.useFlagV) || !state2.verbose && parent.kind === "intersection" && // JS doesn't allow intersection with union or ranges
40865
+ ((!state3.useFlagV || !state3.verbose) && parent.kind === "union" && !(envFlags.bugFlagVLiteralHyphenIsRange && state3.useFlagV) || !state3.verbose && parent.kind === "intersection" && // JS doesn't allow intersection with union or ranges
40421
40866
  body4.length === 1 && firstEl.type !== "CharacterClassRange")
40422
40867
  ) {
40423
40868
  return body4.map(gen).join("");
40424
40869
  }
40425
- if (!state2.useFlagV && parent.type === "CharacterClass") {
40870
+ if (!state3.useFlagV && parent.type === "CharacterClass") {
40426
40871
  throw new Error("Uses nested character class in a way that requires min target ES2024");
40427
40872
  }
40428
40873
  return genClass();
@@ -40430,18 +40875,18 @@ var generator = {
40430
40875
  /**
40431
40876
  @param {CharacterClassRangeNode} node
40432
40877
  */
40433
- CharacterClassRange(node, state2) {
40878
+ CharacterClassRange(node, state3) {
40434
40879
  const min2 = node.min.value;
40435
40880
  const max2 = node.max.value;
40436
40881
  const escOpts = {
40437
40882
  escDigit: false,
40438
40883
  inCharClass: true,
40439
- useFlagV: state2.useFlagV
40884
+ useFlagV: state3.useFlagV
40440
40885
  };
40441
40886
  const minStr = getCharEscape(min2, escOpts);
40442
40887
  const maxStr = getCharEscape(max2, escOpts);
40443
40888
  const extraChars = /* @__PURE__ */ new Set();
40444
- if (state2.useAppliedIgnoreCase && state2.currentFlags.ignoreCase) {
40889
+ if (state3.useAppliedIgnoreCase && state3.currentFlags.ignoreCase) {
40445
40890
  const charsOutsideRange = getCasesOutsideCharClassRange(node);
40446
40891
  const ranges = getCodePointRangesFromChars(charsOutsideRange);
40447
40892
  ranges.forEach((value) => {
@@ -40455,9 +40900,9 @@ var generator = {
40455
40900
  /**
40456
40901
  @param {CharacterSetNode} node
40457
40902
  */
40458
- CharacterSet({ kind, negate, value, key: key2 }, state2) {
40903
+ CharacterSet({ kind, negate, value, key: key2 }, state3) {
40459
40904
  if (kind === "dot") {
40460
- return state2.currentFlags.dotAll ? state2.appliedGlobalFlags.dotAll || state2.useFlagMods ? "." : "[^]" : (
40905
+ return state3.currentFlags.dotAll ? state3.appliedGlobalFlags.dotAll || state3.useFlagMods ? "." : "[^]" : (
40461
40906
  // Onig's only line break char is line feed, unlike JS
40462
40907
  r36`[^\n]`
40463
40908
  );
@@ -40466,7 +40911,7 @@ var generator = {
40466
40911
  return negate ? r36`\D` : r36`\d`;
40467
40912
  }
40468
40913
  if (kind === "property") {
40469
- if (state2.useAppliedIgnoreCase && state2.currentFlags.ignoreCase && UnicodePropertiesWithSpecificCase.has(value)) {
40914
+ if (state3.useAppliedIgnoreCase && state3.currentFlags.ignoreCase && UnicodePropertiesWithSpecificCase.has(value)) {
40470
40915
  throw new Error(`Unicode property "${value}" can't be case-insensitive when other chars have specific case`);
40471
40916
  }
40472
40917
  return `${negate ? r36`\P` : r36`\p`}{${key2 ? `${key2}=` : ""}${value}}`;
@@ -40479,28 +40924,28 @@ var generator = {
40479
40924
  /**
40480
40925
  @param {FlagsNode} node
40481
40926
  */
40482
- Flags(node, state2) {
40927
+ Flags(node, state3) {
40483
40928
  return (
40484
40929
  // The transformer should never turn on the properties for flags d, g, m since Onig doesn't
40485
40930
  // have equivs. Flag m is never used since Onig uses different line break chars than JS
40486
40931
  // (node.hasIndices ? 'd' : '') +
40487
40932
  // (node.global ? 'g' : '') +
40488
40933
  // (node.multiline ? 'm' : '') +
40489
- (state2.appliedGlobalFlags.ignoreCase ? "i" : "") + (node.dotAll ? "s" : "") + (node.sticky ? "y" : "")
40934
+ (state3.appliedGlobalFlags.ignoreCase ? "i" : "") + (node.dotAll ? "s" : "") + (node.sticky ? "y" : "")
40490
40935
  );
40491
40936
  },
40492
40937
  /**
40493
40938
  @param {GroupNode} node
40494
40939
  */
40495
- Group({ atomic: atomic2, body: body4, flags, parent }, state2, gen) {
40496
- const currentFlags = state2.currentFlags;
40940
+ Group({ atomic: atomic2, body: body4, flags, parent }, state3, gen) {
40941
+ const currentFlags = state3.currentFlags;
40497
40942
  if (flags) {
40498
- state2.currentFlags = getNewCurrentFlags(currentFlags, flags);
40943
+ state3.currentFlags = getNewCurrentFlags(currentFlags, flags);
40499
40944
  }
40500
40945
  const contents = body4.map(gen).join("|");
40501
- const result = !state2.verbose && body4.length === 1 && // Single alt
40502
- parent.type !== "Quantifier" && !atomic2 && (!state2.useFlagMods || !flags) ? contents : `(?${getGroupPrefix(atomic2, flags, state2.useFlagMods)}${contents})`;
40503
- state2.currentFlags = currentFlags;
40946
+ const result = !state3.verbose && body4.length === 1 && // Single alt
40947
+ parent.type !== "Quantifier" && !atomic2 && (!state3.useFlagMods || !flags) ? contents : `(?${getGroupPrefix(atomic2, flags, state3.useFlagMods)}${contents})`;
40948
+ state3.currentFlags = currentFlags;
40504
40949
  return result;
40505
40950
  },
40506
40951
  /**
@@ -40519,11 +40964,11 @@ var generator = {
40519
40964
  /**
40520
40965
  @param {SubroutineNode & {isRecursive: true}} node
40521
40966
  */
40522
- Subroutine({ isRecursive, ref }, state2) {
40967
+ Subroutine({ isRecursive, ref }, state3) {
40523
40968
  if (!isRecursive) {
40524
40969
  throw new Error("Unexpected non-recursive subroutine in transformed AST");
40525
40970
  }
40526
- const limit2 = state2.recursionLimit;
40971
+ const limit2 = state3.recursionLimit;
40527
40972
  return ref === 0 ? `(?R=${limit2})` : r36`\g<${ref}&R=${limit2}>`;
40528
40973
  }
40529
40974
  };
@@ -42489,13 +42934,13 @@ var InteractionManager = class {
42489
42934
  }
42490
42935
  };
42491
42936
  }
42492
- resolveLineRenderRange(state2, split, source) {
42493
- if (state2.range == null) return;
42494
- const rowRange = this.getIndexesFromSelection(state2.range, split);
42937
+ resolveLineRenderRange(state3, split, source) {
42938
+ if (state3.range == null) return;
42939
+ const rowRange = this.getIndexesFromSelection(state3.range, split);
42495
42940
  if (rowRange == null) {
42496
42941
  console.error({
42497
42942
  rowRange,
42498
- range: state2.range
42943
+ range: state3.range
42499
42944
  });
42500
42945
  throw new Error(`InteractionManager.renderSelection: No valid ${source} rowRange`);
42501
42946
  }
@@ -43759,14 +44204,14 @@ function isDefaultRenderRange(renderRange) {
43759
44204
  }
43760
44205
 
43761
44206
  // node_modules/@pierre/diffs/dist/utils/processLine.js
43762
- function processLine(node, line, state2) {
43763
- const lineInfo = typeof state2.lineInfo === "function" ? state2.lineInfo(line) : state2.lineInfo[line - 1];
44207
+ function processLine(node, line, state3) {
44208
+ const lineInfo = typeof state3.lineInfo === "function" ? state3.lineInfo(line) : state3.lineInfo[line - 1];
43764
44209
  if (lineInfo == null) {
43765
44210
  const errorMessage = `processLine: line ${line}, contains no state.lineInfo`;
43766
44211
  console.error(errorMessage, {
43767
44212
  node,
43768
44213
  line,
43769
- state: state2
44214
+ state: state3
43770
44215
  });
43771
44216
  throw new Error(errorMessage);
43772
44217
  }
@@ -43918,7 +44363,7 @@ function cyrb53(str, seed = 0) {
43918
44363
 
43919
44364
  // node_modules/@pierre/diffs/dist/utils/createTransformerWithState.js
43920
44365
  function createTransformerWithState(useTokenTransformer = false, useCSSClasses = false) {
43921
- const state2 = { lineInfo: [] };
44366
+ const state3 = { lineInfo: [] };
43922
44367
  const transformers = [{
43923
44368
  line(node) {
43924
44369
  delete node.properties.class;
@@ -43932,7 +44377,7 @@ function createTransformerWithState(useTokenTransformer = false, useCSSClasses =
43932
44377
  for (const node of code2.children) {
43933
44378
  if (node.type !== "element") continue;
43934
44379
  if (useTokenTransformer) wrapTokenFragments(node);
43935
- children.push(processLine(node, index, state2));
44380
+ children.push(processLine(node, index, state3));
43936
44381
  index++;
43937
44382
  }
43938
44383
  code2.children = children;
@@ -43974,7 +44419,7 @@ function createTransformerWithState(useTokenTransformer = false, useCSSClasses =
43974
44419
  return node;
43975
44420
  } });
43976
44421
  return {
43977
- state: state2,
44422
+ state: state3,
43978
44423
  transformers,
43979
44424
  toClass
43980
44425
  };
@@ -44227,14 +44672,14 @@ function renderFileWithHighlighter(file, highlighter2, { theme: theme3, tokenize
44227
44672
  totalLines = Infinity;
44228
44673
  }
44229
44674
  const isWindowedHighlight = startingLine > 0 || totalLines < Infinity;
44230
- const { state: state2, transformers } = createTransformerWithState(useTokenTransformer);
44675
+ const { state: state3, transformers } = createTransformerWithState(useTokenTransformer);
44231
44676
  const lang = forcePlainText ? "text" : file.lang ?? getFiletypeFromFileName(file.name);
44232
44677
  const baseThemeType = typeof theme3 === "string" ? highlighter2.getTheme(theme3).type : void 0;
44233
44678
  const themeStyles = getHighlighterThemeStyles({
44234
44679
  theme: theme3,
44235
44680
  highlighter: highlighter2
44236
44681
  });
44237
- state2.lineInfo = (shikiLineNumber) => ({
44682
+ state3.lineInfo = (shikiLineNumber) => ({
44238
44683
  type: "context",
44239
44684
  lineIndex: shikiLineNumber - 1 + startingLine,
44240
44685
  lineNumber: shikiLineNumber + startingLine
@@ -47233,7 +47678,7 @@ var Diff = class {
47233
47678
  }
47234
47679
  diffWithOptionsObj(oldTokens, newTokens, options, callback) {
47235
47680
  var _a;
47236
- const done = (value) => {
47681
+ const done2 = (value) => {
47237
47682
  value = this.postProcess(value, options);
47238
47683
  if (callback) {
47239
47684
  setTimeout(function() {
@@ -47255,7 +47700,7 @@ var Diff = class {
47255
47700
  const bestPath = [{ oldPos: -1, lastComponent: void 0 }];
47256
47701
  let newPos = this.extractCommon(bestPath[0], newTokens, oldTokens, 0, options);
47257
47702
  if (bestPath[0].oldPos + 1 >= oldLen && newPos + 1 >= newLen) {
47258
- return done(this.buildValues(bestPath[0].lastComponent, newTokens, oldTokens));
47703
+ return done2(this.buildValues(bestPath[0].lastComponent, newTokens, oldTokens));
47259
47704
  }
47260
47705
  let minDiagonalToConsider = -Infinity, maxDiagonalToConsider = Infinity;
47261
47706
  const execEditLength = () => {
@@ -47282,7 +47727,7 @@ var Diff = class {
47282
47727
  }
47283
47728
  newPos = this.extractCommon(basePath, newTokens, oldTokens, diagonalPath, options);
47284
47729
  if (basePath.oldPos + 1 >= oldLen && newPos + 1 >= newLen) {
47285
- return done(this.buildValues(basePath.lastComponent, newTokens, oldTokens)) || true;
47730
+ return done2(this.buildValues(basePath.lastComponent, newTokens, oldTokens)) || true;
47286
47731
  } else {
47287
47732
  bestPath[diagonalPath] = basePath;
47288
47733
  if (basePath.oldPos + 1 >= oldLen) {
@@ -48409,7 +48854,7 @@ function iterateOverDiff({ diff, diffStyle, startingLine = 0, totalLines = Infin
48409
48854
  expandedHunks,
48410
48855
  collapsedContextThreshold
48411
48856
  });
48412
- const state2 = {
48857
+ const state3 = {
48413
48858
  viewportStart: startingLine,
48414
48859
  viewportEnd: startingLine + totalLines,
48415
48860
  isWindowedHighlight: startingLine > 0 || totalLines < Infinity,
@@ -48417,44 +48862,44 @@ function iterateOverDiff({ diff, diffStyle, startingLine = 0, totalLines = Infin
48417
48862
  unifiedCount: iterationStart.unifiedCount,
48418
48863
  finalHunkIndex: diff.hunks.length - 1,
48419
48864
  shouldBreak() {
48420
- if (!state2.isWindowedHighlight) return false;
48421
- const breakUnified = state2.unifiedCount >= startingLine + totalLines;
48422
- const breakSplit = state2.splitCount >= startingLine + totalLines;
48865
+ if (!state3.isWindowedHighlight) return false;
48866
+ const breakUnified = state3.unifiedCount >= startingLine + totalLines;
48867
+ const breakSplit = state3.splitCount >= startingLine + totalLines;
48423
48868
  if (diffStyle === "unified") return breakUnified;
48424
48869
  else if (diffStyle === "split") return breakSplit;
48425
48870
  else return breakUnified && breakSplit;
48426
48871
  },
48427
48872
  shouldSkip(unifiedCount, splitCount) {
48428
- if (!state2.isWindowedHighlight) return false;
48429
- const skipUnified = unifiedCount > 0 && state2.unifiedCount + unifiedCount <= startingLine;
48430
- const skipSplit = splitCount > 0 && state2.splitCount + splitCount <= startingLine;
48873
+ if (!state3.isWindowedHighlight) return false;
48874
+ const skipUnified = unifiedCount > 0 && state3.unifiedCount + unifiedCount <= startingLine;
48875
+ const skipSplit = splitCount > 0 && state3.splitCount + splitCount <= startingLine;
48431
48876
  if (diffStyle === "unified") return skipUnified;
48432
48877
  else if (diffStyle === "split") return skipSplit;
48433
48878
  else return skipUnified && skipSplit;
48434
48879
  },
48435
48880
  incrementCounts(unifiedValue, splitValue) {
48436
- if (diffStyle === "unified" || diffStyle === "both") state2.unifiedCount += unifiedValue;
48437
- if (diffStyle === "split" || diffStyle === "both") state2.splitCount += splitValue;
48881
+ if (diffStyle === "unified" || diffStyle === "both") state3.unifiedCount += unifiedValue;
48882
+ if (diffStyle === "split" || diffStyle === "both") state3.splitCount += splitValue;
48438
48883
  },
48439
48884
  isInWindow(unifiedHeight, splitHeight) {
48440
- if (!state2.isWindowedHighlight) return true;
48441
- const unifiedInWindow = state2.isInUnifiedWindow(unifiedHeight);
48442
- const splitInWindow = state2.isInSplitWindow(splitHeight);
48885
+ if (!state3.isWindowedHighlight) return true;
48886
+ const unifiedInWindow = state3.isInUnifiedWindow(unifiedHeight);
48887
+ const splitInWindow = state3.isInSplitWindow(splitHeight);
48443
48888
  if (diffStyle === "unified") return unifiedInWindow;
48444
48889
  else if (diffStyle === "split") return splitInWindow;
48445
48890
  else return unifiedInWindow || splitInWindow;
48446
48891
  },
48447
48892
  isInUnifiedWindow(unifiedHeight) {
48448
- return !state2.isWindowedHighlight || state2.unifiedCount >= startingLine - unifiedHeight && state2.unifiedCount < startingLine + totalLines;
48893
+ return !state3.isWindowedHighlight || state3.unifiedCount >= startingLine - unifiedHeight && state3.unifiedCount < startingLine + totalLines;
48449
48894
  },
48450
48895
  isInSplitWindow(splitHeight) {
48451
- return !state2.isWindowedHighlight || state2.splitCount >= startingLine - splitHeight && state2.splitCount < startingLine + totalLines;
48896
+ return !state3.isWindowedHighlight || state3.splitCount >= startingLine - splitHeight && state3.splitCount < startingLine + totalLines;
48452
48897
  },
48453
48898
  emit(props, silent = false) {
48454
48899
  if (!silent) {
48455
- if (diffStyle === "unified") state2.incrementCounts(1, 0);
48456
- else if (diffStyle === "split") state2.incrementCounts(0, 1);
48457
- else state2.incrementCounts(1, 1);
48900
+ if (diffStyle === "unified") state3.incrementCounts(1, 0);
48901
+ else if (diffStyle === "split") state3.incrementCounts(0, 1);
48902
+ else state3.incrementCounts(1, 1);
48458
48903
  }
48459
48904
  return callback(props) ?? false;
48460
48905
  }
@@ -48471,7 +48916,7 @@ function iterateOverDiff({ diff, diffStyle, startingLine = 0, totalLines = Infin
48471
48916
  };
48472
48917
  const hunk = diff.hunks[hunkIndex];
48473
48918
  if (hunk == null) throw new Error("iterateOverDiff: invalid hunk index");
48474
- if (state2.shouldBreak()) break;
48919
+ if (state3.shouldBreak()) break;
48475
48920
  const deletionBoundary = getHunkSideStartBoundary(hunk.deletionStart, hunk.deletionCount);
48476
48921
  const additionBoundary = getHunkSideStartBoundary(hunk.additionStart, hunk.additionCount);
48477
48922
  const deletionStartIndex = !diff.isPartial && hunk.deletionCount === 0 ? deletionBoundary : hunk.deletionLineIndex;
@@ -48483,7 +48928,7 @@ function iterateOverDiff({ diff, diffStyle, startingLine = 0, totalLines = Infin
48483
48928
  hunkIndex,
48484
48929
  collapsedContextThreshold
48485
48930
  });
48486
- const trailingRegion = hunkIndex === state2.finalHunkIndex ? getTrailingExpandedRegion({
48931
+ const trailingRegion = hunkIndex === state3.finalHunkIndex ? getTrailingExpandedRegion({
48487
48932
  fileDiff: diff,
48488
48933
  hunkIndex,
48489
48934
  expandedHunks,
@@ -48492,15 +48937,15 @@ function iterateOverDiff({ diff, diffStyle, startingLine = 0, totalLines = Infin
48492
48937
  }) : void 0;
48493
48938
  const expandedLineCount = leadingRegion.fromStart + leadingRegion.fromEnd;
48494
48939
  let consumedCollapsed = leadingRegion.collapsedLines === 0;
48495
- if (!state2.shouldSkip(expandedLineCount, expandedLineCount)) {
48940
+ if (!state3.shouldSkip(expandedLineCount, expandedLineCount)) {
48496
48941
  let unifiedLineIndex2 = hunk.unifiedLineStart - leadingRegion.rangeSize;
48497
48942
  let splitLineIndex2 = hunk.splitLineStart - leadingRegion.rangeSize;
48498
48943
  let deletionLineIndex2 = deletionStartIndex - leadingRegion.rangeSize;
48499
48944
  let additionLineIndex2 = additionStartIndex - leadingRegion.rangeSize;
48500
48945
  let deletionLineNumber2 = deletionBoundary + 1 - leadingRegion.rangeSize;
48501
48946
  let additionLineNumber2 = additionBoundary + 1 - leadingRegion.rangeSize;
48502
- if (walkContextLines(state2, leadingRegion.fromStart, diffStyle, (index) => {
48503
- return state2.emit({
48947
+ if (walkContextLines(state3, leadingRegion.fromStart, diffStyle, (index) => {
48948
+ return state3.emit({
48504
48949
  hunkIndex,
48505
48950
  hunk,
48506
48951
  collapsedBefore: 0,
@@ -48528,8 +48973,8 @@ function iterateOverDiff({ diff, diffStyle, startingLine = 0, totalLines = Infin
48528
48973
  additionLineIndex2 = additionStartIndex - leadingRegion.fromEnd;
48529
48974
  deletionLineNumber2 = deletionBoundary + 1 - leadingRegion.fromEnd;
48530
48975
  additionLineNumber2 = additionBoundary + 1 - leadingRegion.fromEnd;
48531
- if (walkContextLines(state2, leadingRegion.fromEnd, diffStyle, (index) => {
48532
- return state2.emit({
48976
+ if (walkContextLines(state3, leadingRegion.fromEnd, diffStyle, (index) => {
48977
+ return state3.emit({
48533
48978
  hunkIndex,
48534
48979
  hunk,
48535
48980
  collapsedBefore: consumePendingCollapsed(),
@@ -48554,7 +48999,7 @@ function iterateOverDiff({ diff, diffStyle, startingLine = 0, totalLines = Infin
48554
48999
  consumePendingCollapsed();
48555
49000
  })) break hunkIterator;
48556
49001
  } else {
48557
- state2.incrementCounts(expandedLineCount, expandedLineCount);
49002
+ state3.incrementCounts(expandedLineCount, expandedLineCount);
48558
49003
  consumePendingCollapsed();
48559
49004
  }
48560
49005
  let unifiedLineIndex = hunk.unifiedLineStart;
@@ -48565,15 +49010,15 @@ function iterateOverDiff({ diff, diffStyle, startingLine = 0, totalLines = Infin
48565
49010
  let additionLineNumber = additionBoundary + 1;
48566
49011
  const lastContent = hunk.hunkContent.at(-1);
48567
49012
  for (const content of hunk.hunkContent) {
48568
- if (state2.shouldBreak()) break hunkIterator;
49013
+ if (state3.shouldBreak()) break hunkIterator;
48569
49014
  const isLastContent = content === lastContent;
48570
49015
  if (content.type === "context") {
48571
- if (!state2.shouldSkip(content.lines, content.lines)) {
48572
- if (walkContextLines(state2, content.lines, diffStyle, (index) => {
49016
+ if (!state3.shouldSkip(content.lines, content.lines)) {
49017
+ if (walkContextLines(state3, content.lines, diffStyle, (index) => {
48573
49018
  const isLastLine = isLastContent && index === content.lines - 1;
48574
49019
  const unifiedRowIndex = unifiedLineIndex + index;
48575
49020
  const splitRowIndex = splitLineIndex + index;
48576
- return state2.emit({
49021
+ return state3.emit({
48577
49022
  hunkIndex,
48578
49023
  hunk,
48579
49024
  collapsedBefore: consumePendingCollapsed(),
@@ -48598,7 +49043,7 @@ function iterateOverDiff({ diff, diffStyle, startingLine = 0, totalLines = Infin
48598
49043
  consumePendingCollapsed();
48599
49044
  })) break hunkIterator;
48600
49045
  } else {
48601
- state2.incrementCounts(content.lines, content.lines);
49046
+ state3.incrementCounts(content.lines, content.lines);
48602
49047
  consumePendingCollapsed();
48603
49048
  }
48604
49049
  unifiedLineIndex += content.lines;
@@ -48610,12 +49055,12 @@ function iterateOverDiff({ diff, diffStyle, startingLine = 0, totalLines = Infin
48610
49055
  } else {
48611
49056
  const splitCount = Math.max(content.deletions, content.additions);
48612
49057
  const unifiedCount = content.deletions + content.additions;
48613
- if (!state2.shouldSkip(unifiedCount, splitCount)) {
48614
- const iterationRanges = getChangeIterationRanges(state2, content, diffStyle);
49058
+ if (!state3.shouldSkip(unifiedCount, splitCount)) {
49059
+ const iterationRanges = getChangeIterationRanges(state3, content, diffStyle);
48615
49060
  if ((iterationRanges[0]?.[0] ?? 0) > 0) consumePendingCollapsed();
48616
49061
  for (const [rangeStart, rangeEnd] of iterationRanges) for (let index = rangeStart; index < rangeEnd; index++) {
48617
49062
  const collapsedAfter = getTrailingCollapsedAfter(unifiedLineIndex + index, diffStyle === "unified" ? splitLineIndex + (index < content.deletions ? index : index - content.deletions) : splitLineIndex + index);
48618
- if (state2.emit(getChangeLineData({
49063
+ if (state3.emit(getChangeLineData({
48619
49064
  hunkIndex,
48620
49065
  hunk,
48621
49066
  collapsedBefore: consumePendingCollapsed(),
@@ -48636,7 +49081,7 @@ function iterateOverDiff({ diff, diffStyle, startingLine = 0, totalLines = Infin
48636
49081
  }
48637
49082
  }
48638
49083
  consumePendingCollapsed();
48639
- state2.incrementCounts(unifiedCount, splitCount);
49084
+ state3.incrementCounts(unifiedCount, splitCount);
48640
49085
  unifiedLineIndex += unifiedCount;
48641
49086
  splitLineIndex += splitCount;
48642
49087
  deletionLineIndex += content.deletions;
@@ -48648,9 +49093,9 @@ function iterateOverDiff({ diff, diffStyle, startingLine = 0, totalLines = Infin
48648
49093
  if (trailingRegion != null) {
48649
49094
  const { collapsedLines, fromStart, fromEnd } = trailingRegion;
48650
49095
  const len = fromStart + fromEnd;
48651
- if (walkContextLines(state2, len, diffStyle, (index) => {
49096
+ if (walkContextLines(state3, len, diffStyle, (index) => {
48652
49097
  const isLastLine = index === len - 1;
48653
- return state2.emit({
49098
+ return state3.emit({
48654
49099
  hunkIndex: diff.hunks.length,
48655
49100
  hunk: void 0,
48656
49101
  collapsedBefore: 0,
@@ -48671,7 +49116,7 @@ function iterateOverDiff({ diff, diffStyle, startingLine = 0, totalLines = Infin
48671
49116
  noEOFCR: false
48672
49117
  }
48673
49118
  });
48674
- }, void 0, () => state2.shouldBreak())) break hunkIterator;
49119
+ }, void 0, () => state3.shouldBreak())) break hunkIterator;
48675
49120
  }
48676
49121
  }
48677
49122
  }
@@ -48755,16 +49200,16 @@ function getHunkPrefixCounts({ diff, expandedHunks, collapsedContextThreshold })
48755
49200
  }
48756
49201
  return prefixCounts;
48757
49202
  }
48758
- function getContextLineIterationBounds(state2, count, diffStyle) {
48759
- if (!state2.isWindowedHighlight || count <= 0) return [0, count];
49203
+ function getContextLineIterationBounds(state3, count, diffStyle) {
49204
+ if (!state3.isWindowedHighlight || count <= 0) return [0, count];
48760
49205
  const ranges = [];
48761
49206
  function pushRange(currentCount) {
48762
- const start2 = Math.max(0, state2.viewportStart - currentCount);
48763
- const end2 = Math.min(count, state2.viewportEnd - currentCount);
49207
+ const start2 = Math.max(0, state3.viewportStart - currentCount);
49208
+ const end2 = Math.min(count, state3.viewportEnd - currentCount);
48764
49209
  if (end2 > start2) ranges.push([start2, end2]);
48765
49210
  }
48766
- if (diffStyle !== "split") pushRange(state2.unifiedCount);
48767
- if (diffStyle !== "unified") pushRange(state2.splitCount);
49211
+ if (diffStyle !== "split") pushRange(state3.unifiedCount);
49212
+ if (diffStyle !== "unified") pushRange(state3.splitCount);
48768
49213
  if (ranges.length === 0) return [0, 0];
48769
49214
  let start = ranges[0][0];
48770
49215
  let end = ranges[0][1];
@@ -48775,36 +49220,36 @@ function getContextLineIterationBounds(state2, count, diffStyle) {
48775
49220
  }
48776
49221
  return [start, end];
48777
49222
  }
48778
- function walkContextLines(state2, count, diffStyle, callback, onSkippedStart, shouldBreak) {
48779
- const [startIndex, endIndex] = getContextLineIterationBounds(state2, count, diffStyle);
49223
+ function walkContextLines(state3, count, diffStyle, callback, onSkippedStart, shouldBreak) {
49224
+ const [startIndex, endIndex] = getContextLineIterationBounds(state3, count, diffStyle);
48780
49225
  if (startIndex > 0) {
48781
- state2.incrementCounts(startIndex, startIndex);
49226
+ state3.incrementCounts(startIndex, startIndex);
48782
49227
  onSkippedStart?.();
48783
49228
  }
48784
49229
  let index = startIndex;
48785
49230
  while (index < count) {
48786
49231
  if (shouldBreak?.() === true) return true;
48787
49232
  if (index >= endIndex) {
48788
- state2.incrementCounts(count - index, count - index);
49233
+ state3.incrementCounts(count - index, count - index);
48789
49234
  break;
48790
49235
  }
48791
- if (state2.isInWindow(0, 0)) {
49236
+ if (state3.isInWindow(0, 0)) {
48792
49237
  if (callback(index) === true) return true;
48793
- } else state2.incrementCounts(1, 1);
49238
+ } else state3.incrementCounts(1, 1);
48794
49239
  index++;
48795
49240
  }
48796
49241
  return false;
48797
49242
  }
48798
- function getChangeIterationRanges(state2, content, diffStyle) {
48799
- if (!state2.isWindowedHighlight) return [[0, diffStyle === "unified" ? content.deletions + content.additions : Math.max(content.deletions, content.additions)]];
49243
+ function getChangeIterationRanges(state3, content, diffStyle) {
49244
+ if (!state3.isWindowedHighlight) return [[0, diffStyle === "unified" ? content.deletions + content.additions : Math.max(content.deletions, content.additions)]];
48800
49245
  const useUnified = diffStyle !== "split";
48801
49246
  const useSplit = diffStyle !== "unified";
48802
49247
  const iterationSpace = diffStyle === "unified" ? "unified" : "split";
48803
49248
  const iterationRanges = [];
48804
49249
  function getVisibleRange(start, count) {
48805
- if (start + count <= state2.viewportStart || start >= state2.viewportEnd) return;
48806
- const visibleStart = Math.max(0, state2.viewportStart - start);
48807
- const visibleEnd = Math.min(count, state2.viewportEnd - start);
49250
+ if (start + count <= state3.viewportStart || start >= state3.viewportEnd) return;
49251
+ const visibleStart = Math.max(0, state3.viewportStart - start);
49252
+ const visibleEnd = Math.min(count, state3.viewportEnd - start);
48808
49253
  return visibleEnd > visibleStart ? [visibleStart, visibleEnd] : void 0;
48809
49254
  }
48810
49255
  function mapRangeToIteration(range3, kind) {
@@ -48817,12 +49262,12 @@ function getChangeIterationRanges(state2, content, diffStyle) {
48817
49262
  if (end > start) iterationRanges.push([start, end]);
48818
49263
  }
48819
49264
  if (useUnified) {
48820
- pushRange(getVisibleRange(state2.unifiedCount, content.deletions), "deletions");
48821
- pushRange(getVisibleRange(state2.unifiedCount + content.deletions, content.additions), "additions");
49265
+ pushRange(getVisibleRange(state3.unifiedCount, content.deletions), "deletions");
49266
+ pushRange(getVisibleRange(state3.unifiedCount + content.deletions, content.additions), "additions");
48822
49267
  }
48823
49268
  if (useSplit) {
48824
- pushRange(getVisibleRange(state2.splitCount, content.deletions), "deletions");
48825
- pushRange(getVisibleRange(state2.splitCount, content.additions), "additions");
49269
+ pushRange(getVisibleRange(state3.splitCount, content.deletions), "deletions");
49270
+ pushRange(getVisibleRange(state3.splitCount, content.additions), "additions");
48826
49271
  }
48827
49272
  if (iterationRanges.length === 0) return iterationRanges;
48828
49273
  iterationRanges.sort((a22, b13) => a22[0] - b13[0]);
@@ -49138,7 +49583,7 @@ function createBucket() {
49138
49583
  function renderTwoFiles({ deletionFile, additionFile, deletionInfo, additionInfo, highlighter: highlighter2, deletionDecorations, additionDecorations, languageOverride, options: { theme: themeOrThemes, ...options } }) {
49139
49584
  const deletionLang = languageOverride ?? getFiletypeFromFileName(deletionFile.name);
49140
49585
  const additionLang = languageOverride ?? getFiletypeFromFileName(additionFile.name);
49141
- const { state: state2, transformers } = createTransformerWithState(options.useTokenTransformer);
49586
+ const { state: state3, transformers } = createTransformerWithState(options.useTokenTransformer);
49142
49587
  const hastConfig = (() => {
49143
49588
  return typeof themeOrThemes === "string" ? {
49144
49589
  ...options,
@@ -49164,7 +49609,7 @@ function renderTwoFiles({ deletionFile, additionFile, deletionInfo, additionInfo
49164
49609
  deletionLines: (() => {
49165
49610
  if (deletionFile.contents === "") return [];
49166
49611
  hastConfig.lang = deletionLang;
49167
- state2.lineInfo = deletionInfo;
49612
+ state3.lineInfo = deletionInfo;
49168
49613
  hastConfig.decorations = deletionDecorations;
49169
49614
  return getLineNodes(highlighter2.codeToHast(cleanLastNewline(deletionFile.contents), hastConfig));
49170
49615
  })(),
@@ -49172,7 +49617,7 @@ function renderTwoFiles({ deletionFile, additionFile, deletionInfo, additionInfo
49172
49617
  if (additionFile.contents === "") return [];
49173
49618
  hastConfig.lang = additionLang;
49174
49619
  hastConfig.decorations = additionDecorations;
49175
- state2.lineInfo = additionInfo;
49620
+ state3.lineInfo = additionInfo;
49176
49621
  return getLineNodes(highlighter2.codeToHast(cleanLastNewline(additionFile.contents), hastConfig));
49177
49622
  })()
49178
49623
  };
@@ -51092,8 +51537,8 @@ function areHunkDataEqual(hunkA, hunkB) {
51092
51537
  async function awaitWithTimeout(callback, timeout = 300) {
51093
51538
  let timeoutId;
51094
51539
  try {
51095
- await Promise.race([callback(), new Promise((resolve) => {
51096
- timeoutId = setTimeout(resolve, timeout);
51540
+ await Promise.race([callback(), new Promise((resolve2) => {
51541
+ timeoutId = setTimeout(resolve2, timeout);
51097
51542
  })]);
51098
51543
  } finally {
51099
51544
  if (timeoutId != null) clearTimeout(timeoutId);
@@ -54020,14 +54465,14 @@ var PopoutWindow = class extends CompositeDisposable {
54020
54465
  id: _this.target,
54021
54466
  window: externalWindow
54022
54467
  });
54023
- return new Promise((resolve) => {
54468
+ return new Promise((resolve2) => {
54024
54469
  const abandon = (err) => {
54025
54470
  _this._failure = {
54026
54471
  reason: "unscriptable",
54027
54472
  error: err instanceof Error ? err : new Error(String(err))
54028
54473
  };
54029
54474
  _this.close();
54030
- resolve(null);
54475
+ resolve2(null);
54031
54476
  };
54032
54477
  try {
54033
54478
  externalWindow.addEventListener("unload", () => {
@@ -54039,7 +54484,7 @@ var PopoutWindow = class extends CompositeDisposable {
54039
54484
  disposable.addDisposables(_this.onWillClose(() => {
54040
54485
  var _this$_failure;
54041
54486
  (_this$_failure = _this._failure) !== null && _this$_failure !== void 0 || (_this._failure = { reason: "closed" });
54042
- resolve(null);
54487
+ resolve2(null);
54043
54488
  }));
54044
54489
  externalWindow.addEventListener("load", () => {
54045
54490
  try {
@@ -54057,7 +54502,7 @@ var PopoutWindow = class extends CompositeDisposable {
54057
54502
  addDisposableListener(externalWindow, "beforeunload", () => {
54058
54503
  _this.close();
54059
54504
  });
54060
- resolve(container);
54505
+ resolve2(container);
54061
54506
  } catch (err) {
54062
54507
  abandon(err);
54063
54508
  }
@@ -54771,11 +55216,11 @@ var Splitview = class {
54771
55216
  else this.updateSash(sash, 3);
54772
55217
  }
54773
55218
  }
54774
- updateSash(sash, state2) {
54775
- toggleClass(sash.container, "dv-disabled", state2 === 2);
54776
- toggleClass(sash.container, "dv-enabled", state2 === 3);
54777
- toggleClass(sash.container, "dv-maximum", state2 === 0);
54778
- toggleClass(sash.container, "dv-minimum", state2 === 1);
55219
+ updateSash(sash, state3) {
55220
+ toggleClass(sash.container, "dv-disabled", state3 === 2);
55221
+ toggleClass(sash.container, "dv-enabled", state3 === 3);
55222
+ toggleClass(sash.container, "dv-maximum", state3 === 0);
55223
+ toggleClass(sash.container, "dv-minimum", state3 === 1);
54779
55224
  }
54780
55225
  createViewContainer() {
54781
55226
  const element2 = document.createElement("div");
@@ -56974,14 +57419,14 @@ var Droptarget = class Droptarget2 extends CompositeDisposable {
56974
57419
  onDrop: (e119) => {
56975
57420
  var _this$options$getOver7, _this$options6;
56976
57421
  e119.preventDefault();
56977
- const state2 = this._state;
57422
+ const state3 = this._state;
56978
57423
  const edge = this._edge;
56979
57424
  this.removeDropTarget();
56980
57425
  (_this$options$getOver7 = (_this$options6 = this.options).getOverrideTarget) === null || _this$options$getOver7 === void 0 || (_this$options$getOver7 = _this$options$getOver7.call(_this$options6)) === null || _this$options$getOver7 === void 0 || _this$options$getOver7.clear();
56981
- if (state2) {
57426
+ if (state3) {
56982
57427
  e119.stopPropagation();
56983
57428
  this._onDrop.fire({
56984
- position: state2,
57429
+ position: state3,
56985
57430
  nativeEvent: e119,
56986
57431
  edge
56987
57432
  });
@@ -57455,13 +57900,13 @@ var PointerDropTarget = class extends CompositeDisposable {
57455
57900
  }
57456
57901
  _onDropEvent(event2) {
57457
57902
  var _this$options$getOver5, _this$options4;
57458
- const state2 = this._state;
57903
+ const state3 = this._state;
57459
57904
  const edge = this._edge;
57460
57905
  const overrideTarget = (_this$options$getOver5 = (_this$options4 = this.options).getOverrideTarget) === null || _this$options$getOver5 === void 0 ? void 0 : _this$options$getOver5.call(_this$options4);
57461
57906
  this._removeOverlay();
57462
57907
  overrideTarget === null || overrideTarget === void 0 || overrideTarget.clear();
57463
- if (state2) this._onDrop.fire({
57464
- position: state2,
57908
+ if (state3) this._onDrop.fire({
57909
+ position: state3,
57465
57910
  nativeEvent: event2.pointerEvent,
57466
57911
  edge
57467
57912
  });
@@ -60168,9 +60613,9 @@ var TabReorderController = class extends CompositeDisposable {
60168
60613
  else this._animState.currentInsertionIndex = null;
60169
60614
  }
60170
60615
  snapshotTabPositions() {
60171
- const positions = /* @__PURE__ */ new Map();
60172
- for (const tab of this._tabs) positions.set(tab.value.panel.id, tab.value.element.getBoundingClientRect());
60173
- return positions;
60616
+ const positions2 = /* @__PURE__ */ new Map();
60617
+ for (const tab of this._tabs) positions2.set(tab.value.panel.id, tab.value.element.getBoundingClientRect());
60618
+ return positions2;
60174
60619
  }
60175
60620
  /** Main-axis extent of a rect for this header's orientation. */
60176
60621
  _mainAxisSize(rect) {
@@ -63489,10 +63934,10 @@ var GridviewPanel = class extends BasePanelView {
63489
63934
  });
63490
63935
  }
63491
63936
  toJSON() {
63492
- const state2 = super.toJSON();
63937
+ const state3 = super.toJSON();
63493
63938
  const maximum = (value) => value === Number.MAX_SAFE_INTEGER ? void 0 : value;
63494
63939
  const minimum = (value) => value <= 0 ? void 0 : value;
63495
- return _objectSpread2(_objectSpread2({}, state2), {}, {
63940
+ return _objectSpread2(_objectSpread2({}, state3), {}, {
63496
63941
  minimumHeight: minimum(this.minimumHeight),
63497
63942
  maximumHeight: maximum(this.maximumHeight),
63498
63943
  minimumWidth: minimum(this.minimumWidth),
@@ -63984,17 +64429,17 @@ var DockviewPanel = class extends CompositeDisposable {
63984
64429
  for (const key2 of Object.keys(event2.params)) if (event2.params[key2] === void 0) delete this._params[key2];
63985
64430
  this.view.update({ params: this._params });
63986
64431
  }
63987
- updateFromStateModel(state2) {
64432
+ updateFromStateModel(state3) {
63988
64433
  var _state$params, _state$title, _state$renderer, _state$pinned, _this$accessor$option;
63989
- this._maximumHeight = state2.maximumHeight;
63990
- this._minimumHeight = state2.minimumHeight;
63991
- this._maximumWidth = state2.maximumWidth;
63992
- this._minimumWidth = state2.minimumWidth;
63993
- this._params = (_state$params = state2.params) !== null && _state$params !== void 0 ? _state$params : {};
64434
+ this._maximumHeight = state3.maximumHeight;
64435
+ this._minimumHeight = state3.minimumHeight;
64436
+ this._maximumWidth = state3.maximumWidth;
64437
+ this._minimumWidth = state3.minimumWidth;
64438
+ this._params = (_state$params = state3.params) !== null && _state$params !== void 0 ? _state$params : {};
63994
64439
  this.view.update({ params: this._params });
63995
- this.setTitle((_state$title = state2.title) !== null && _state$title !== void 0 ? _state$title : this.id);
63996
- this.setRenderer((_state$renderer = state2.renderer) !== null && _state$renderer !== void 0 ? _state$renderer : this.accessor.renderer);
63997
- this.setPinned(((_state$pinned = state2.pinned) !== null && _state$pinned !== void 0 ? _state$pinned : false) && !!((_this$accessor$option = this.accessor.options.pinnedTabs) === null || _this$accessor$option === void 0 ? void 0 : _this$accessor$option.enabled));
64440
+ this.setTitle((_state$title = state3.title) !== null && _state$title !== void 0 ? _state$title : this.id);
64441
+ this.setRenderer((_state$renderer = state3.renderer) !== null && _state$renderer !== void 0 ? _state$renderer : this.accessor.renderer);
64442
+ this.setPinned(((_state$pinned = state3.pinned) !== null && _state$pinned !== void 0 ? _state$pinned : false) && !!((_this$accessor$option = this.accessor.options.pinnedTabs) === null || _this$accessor$option === void 0 ? void 0 : _this$accessor$option.enabled));
63998
64443
  }
63999
64444
  updateParentGroup(group, options) {
64000
64445
  this._group = group;
@@ -64997,20 +65442,20 @@ var PopoutWindowService = class {
64997
65442
  * only for the timer that starts it.
64998
65443
  */
64999
65444
  scheduleRestoration(delayMs, work, onCancel) {
65000
- return new Promise((resolve) => {
65445
+ return new Promise((resolve2) => {
65001
65446
  const cleanup = () => {
65002
65447
  this._restorationCleanups.delete(cleanup);
65003
65448
  clearTimeout(handle2);
65004
65449
  onCancel === null || onCancel === void 0 || onCancel();
65005
- resolve();
65450
+ resolve2();
65006
65451
  };
65007
65452
  const handle2 = setTimeout(() => {
65008
65453
  this._restorationCleanups.delete(cleanup);
65009
65454
  if (this._host.isDisposed) {
65010
- resolve();
65455
+ resolve2();
65011
65456
  return;
65012
65457
  }
65013
- Promise.resolve(work()).then(() => resolve(), () => resolve());
65458
+ Promise.resolve(work()).then(() => resolve2(), () => resolve2());
65014
65459
  }, delayMs);
65015
65460
  this._restorationCleanups.add(cleanup);
65016
65461
  });
@@ -65272,36 +65717,36 @@ var HeaderActionsService = class {
65272
65717
  }
65273
65718
  refresh(group) {
65274
65719
  if (!(group === null || group === void 0 ? void 0 : group.model)) return;
65275
- const state2 = this._ensureState(group);
65276
- this._refreshSlot("left", group, state2.left);
65277
- this._refreshSlot("right", group, state2.right);
65278
- this._refreshSlot("prefix", group, state2.prefix);
65720
+ const state3 = this._ensureState(group);
65721
+ this._refreshSlot("left", group, state3.left);
65722
+ this._refreshSlot("right", group, state3.right);
65723
+ this._refreshSlot("prefix", group, state3.prefix);
65279
65724
  }
65280
65725
  refreshAll() {
65281
65726
  for (const group of this._host.groups) this.refresh(group);
65282
65727
  }
65283
65728
  disposeGroup(group) {
65284
- const state2 = this._perGroup.get(group);
65285
- if (!state2) return;
65286
- state2.left.dispose();
65287
- state2.right.dispose();
65288
- state2.prefix.dispose();
65729
+ const state3 = this._perGroup.get(group);
65730
+ if (!state3) return;
65731
+ state3.left.dispose();
65732
+ state3.right.dispose();
65733
+ state3.prefix.dispose();
65289
65734
  this._perGroup.delete(group);
65290
65735
  }
65291
65736
  dispose() {
65292
65737
  for (const group of [...this._perGroup.keys()]) this.disposeGroup(group);
65293
65738
  }
65294
65739
  _ensureState(group) {
65295
- let state2 = this._perGroup.get(group);
65296
- if (!state2) {
65297
- state2 = {
65740
+ let state3 = this._perGroup.get(group);
65741
+ if (!state3) {
65742
+ state3 = {
65298
65743
  left: new MutableDisposable(),
65299
65744
  right: new MutableDisposable(),
65300
65745
  prefix: new MutableDisposable()
65301
65746
  };
65302
- this._perGroup.set(group, state2);
65747
+ this._perGroup.set(group, state3);
65303
65748
  }
65304
- return state2;
65749
+ return state3;
65305
65750
  }
65306
65751
  _refreshSlot(slot, group, disposable) {
65307
65752
  const factory = this._host.options[SLOT_OPTION_KEY[slot]];
@@ -66986,16 +67431,16 @@ var ShellManager = class {
66986
67431
  "bottom"
66987
67432
  ]) {
66988
67433
  var _state$collapsed;
66989
- const state2 = data[position];
67434
+ const state3 = data[position];
66990
67435
  const view = this._getView(position);
66991
- if (!state2 || !view) continue;
66992
- view.restoreExpandedSize(state2.size);
66993
- view.setCollapsed((_state$collapsed = state2.collapsed) !== null && _state$collapsed !== void 0 ? _state$collapsed : false);
66994
- if (state2.collapsed) {
67436
+ if (!state3 || !view) continue;
67437
+ view.restoreExpandedSize(state3.size);
67438
+ view.setCollapsed((_state$collapsed = state3.collapsed) !== null && _state$collapsed !== void 0 ? _state$collapsed : false);
67439
+ if (state3.collapsed) {
66995
67440
  this._pendingSizes.delete(position);
66996
67441
  this._resizeView(position, view.collapsedSize);
66997
- } else this.resizeEdgeGroup(position, state2.size);
66998
- this.setEdgeGroupVisible(position, !!state2.visible);
67442
+ } else this.resizeEdgeGroup(position, state3.size);
67443
+ this.setEdgeGroupVisible(position, !!state3.visible);
66999
67444
  }
67000
67445
  }
67001
67446
  dispose() {
@@ -68751,7 +69196,7 @@ var DockviewComponent = class extends BaseGrid {
68751
69196
  const width = this.width;
68752
69197
  const height = this.height;
68753
69198
  const createGroupFromSerializedState = (data2) => {
68754
- const { id, locked, hideHeader, headerPosition, views, activeView } = data2;
69199
+ const { id, locked, hideHeader, headerPosition, views: views2, activeView } = data2;
68755
69200
  if (typeof id !== "string") throw new TypeError("dockview: group id must be of type string");
68756
69201
  const group = this.createGroup({
68757
69202
  id,
@@ -68761,7 +69206,7 @@ var DockviewComponent = class extends BaseGrid {
68761
69206
  });
68762
69207
  this._onDidAddGroup.fire(group);
68763
69208
  const createdPanels = [];
68764
- const presentViews = views.filter((child) => panels[child]);
69209
+ const presentViews = views2.filter((child) => panels[child]);
68765
69210
  for (const child of presentViews) {
68766
69211
  const existingPanel = existingPanels.get(child);
68767
69212
  const temporaryGroup = temporaryGroups.get(child);
@@ -68874,9 +69319,9 @@ var DockviewComponent = class extends BaseGrid {
68874
69319
  const edgeData = edgeGroups[position];
68875
69320
  const groupState = edgeData === null || edgeData === void 0 ? void 0 : edgeData.group;
68876
69321
  if (groupState) {
68877
- const { views, activeView } = groupState;
69322
+ const { views: views2, activeView } = groupState;
68878
69323
  const createdPanels = [];
68879
- for (const panelId of views) {
69324
+ for (const panelId of views2) {
68880
69325
  if (!panels[panelId]) continue;
68881
69326
  const existingPanel = existingPanels.get(panelId);
68882
69327
  const temporaryGroup = temporaryGroups.get(panelId);
@@ -70915,13 +71360,13 @@ function ensureChildIdByNameId(nodes, index) {
70915
71360
  }
70916
71361
  function ensureChildPositions(index) {
70917
71362
  if (index.childPositionById != null) return index.childPositionById;
70918
- const positions = /* @__PURE__ */ new Map();
71363
+ const positions2 = /* @__PURE__ */ new Map();
70919
71364
  for (let i25 = 0; i25 < index.childIds.length; i25++) {
70920
71365
  const childId = index.childIds[i25];
70921
- if (childId != null) positions.set(childId, i25);
71366
+ if (childId != null) positions2.set(childId, i25);
70922
71367
  }
70923
- index.childPositionById = positions;
70924
- return positions;
71368
+ index.childPositionById = positions2;
71369
+ return positions2;
70925
71370
  }
70926
71371
  function appendChildReference(index, childId) {
70927
71372
  if (index.childPositionById != null) index.childPositionById.set(childId, index.childIds.length);
@@ -71884,40 +72329,40 @@ function resolveInitialExpansion(initialExpansion) {
71884
72329
  if (!Number.isInteger(initialExpansion) || initialExpansion < 0) throw new Error(`initialExpansion must be "open", "closed", or a non-negative integer depth. Received: ${String(initialExpansion)}`);
71885
72330
  return initialExpansion;
71886
72331
  }
71887
- function isDirectoryExpandedByDefault(state2, node) {
72332
+ function isDirectoryExpandedByDefault(state3, node) {
71888
72333
  if (hasNodeFlag(node, 2)) return true;
71889
- if (state2.defaultExpansion === "open") return true;
71890
- if (state2.defaultExpansion === "closed") return false;
71891
- return getNodeDepth(node) <= state2.defaultExpansion;
72334
+ if (state3.defaultExpansion === "open") return true;
72335
+ if (state3.defaultExpansion === "closed") return false;
72336
+ return getNodeDepth(node) <= state3.defaultExpansion;
71892
72337
  }
71893
- function isDirectoryExpanded(state2, nodeId, node = state2.snapshot.nodes[nodeId]) {
72338
+ function isDirectoryExpanded(state3, nodeId, node = state3.snapshot.nodes[nodeId]) {
71894
72339
  if (node == null || !isDirectoryNode(node)) return false;
71895
- if (state2.directoriesOpenByDefault && !state2.hasCollapsedDirectoryOverrides) return true;
71896
- if (state2.collapsedDirectoryIds.has(nodeId)) return false;
71897
- if (state2.expandedDirectoryIds.has(nodeId)) return true;
71898
- return isDirectoryExpandedByDefault(state2, node);
72340
+ if (state3.directoriesOpenByDefault && !state3.hasCollapsedDirectoryOverrides) return true;
72341
+ if (state3.collapsedDirectoryIds.has(nodeId)) return false;
72342
+ if (state3.expandedDirectoryIds.has(nodeId)) return true;
72343
+ return isDirectoryExpandedByDefault(state3, node);
71899
72344
  }
71900
- function setDirectoryExpanded(state2, nodeId, expanded, node = state2.snapshot.nodes[nodeId]) {
72345
+ function setDirectoryExpanded(state3, nodeId, expanded, node = state3.snapshot.nodes[nodeId]) {
71901
72346
  if (node == null || !isDirectoryNode(node)) return;
71902
- const expandedByDefault = isDirectoryExpandedByDefault(state2, node);
72347
+ const expandedByDefault = isDirectoryExpandedByDefault(state3, node);
71903
72348
  if (expanded) {
71904
72349
  if (expandedByDefault) {
71905
- state2.collapsedDirectoryIds.delete(nodeId);
71906
- state2.hasCollapsedDirectoryOverrides = state2.collapsedDirectoryIds.size > 0;
72350
+ state3.collapsedDirectoryIds.delete(nodeId);
72351
+ state3.hasCollapsedDirectoryOverrides = state3.collapsedDirectoryIds.size > 0;
71907
72352
  return;
71908
72353
  }
71909
- state2.expandedDirectoryIds.add(nodeId);
72354
+ state3.expandedDirectoryIds.add(nodeId);
71910
72355
  return;
71911
72356
  }
71912
72357
  if (expandedByDefault) {
71913
- state2.collapsedDirectoryIds.add(nodeId);
71914
- state2.hasCollapsedDirectoryOverrides = true;
72358
+ state3.collapsedDirectoryIds.add(nodeId);
72359
+ state3.hasCollapsedDirectoryOverrides = true;
71915
72360
  return;
71916
72361
  }
71917
- state2.expandedDirectoryIds.delete(nodeId);
72362
+ state3.expandedDirectoryIds.delete(nodeId);
71918
72363
  }
71919
- function getOrCreateDirectoryLoadInfo(state2, nodeId) {
71920
- const existingInfo = state2.directoryLoadInfoById.get(nodeId);
72364
+ function getOrCreateDirectoryLoadInfo(state3, nodeId) {
72365
+ const existingInfo = state3.directoryLoadInfoById.get(nodeId);
71921
72366
  if (existingInfo != null) return existingInfo;
71922
72367
  const nextInfo = {
71923
72368
  activeAttemptId: null,
@@ -71925,14 +72370,14 @@ function getOrCreateDirectoryLoadInfo(state2, nodeId) {
71925
72370
  nextAttemptId: 1,
71926
72371
  state: "loaded"
71927
72372
  };
71928
- state2.directoryLoadInfoById.set(nodeId, nextInfo);
72373
+ state3.directoryLoadInfoById.set(nodeId, nextInfo);
71929
72374
  return nextInfo;
71930
72375
  }
71931
- function getDirectoryLoadState(state2, nodeId) {
71932
- return state2.directoryLoadInfoById.get(nodeId)?.state ?? "loaded";
72376
+ function getDirectoryLoadState(state3, nodeId) {
72377
+ return state3.directoryLoadInfoById.get(nodeId)?.state ?? "loaded";
71933
72378
  }
71934
- function beginDirectoryLoad(state2, nodeId) {
71935
- const loadInfo = getOrCreateDirectoryLoadInfo(state2, nodeId);
72379
+ function beginDirectoryLoad(state3, nodeId) {
72380
+ const loadInfo = getOrCreateDirectoryLoadInfo(state3, nodeId);
71936
72381
  if (loadInfo.state === "loading" && loadInfo.activeAttemptId != null) return {
71937
72382
  attemptId: loadInfo.activeAttemptId,
71938
72383
  nodeId,
@@ -71949,46 +72394,46 @@ function beginDirectoryLoad(state2, nodeId) {
71949
72394
  reused: false
71950
72395
  };
71951
72396
  }
71952
- function markDirectoryUnloadedState(state2, nodeId) {
71953
- const loadInfo = getOrCreateDirectoryLoadInfo(state2, nodeId);
72397
+ function markDirectoryUnloadedState(state3, nodeId) {
72398
+ const loadInfo = getOrCreateDirectoryLoadInfo(state3, nodeId);
71954
72399
  loadInfo.activeAttemptId = null;
71955
72400
  loadInfo.errorMessage = null;
71956
72401
  loadInfo.state = "unloaded";
71957
72402
  }
71958
- function completeDirectoryLoad(state2, nodeId, attemptId) {
71959
- const loadInfo = state2.directoryLoadInfoById.get(nodeId);
72403
+ function completeDirectoryLoad(state3, nodeId, attemptId) {
72404
+ const loadInfo = state3.directoryLoadInfoById.get(nodeId);
71960
72405
  if (loadInfo == null || loadInfo.activeAttemptId !== attemptId) return false;
71961
72406
  loadInfo.activeAttemptId = null;
71962
72407
  loadInfo.errorMessage = null;
71963
72408
  loadInfo.state = "loaded";
71964
72409
  return true;
71965
72410
  }
71966
- function isDirectoryLoadAttemptCurrent(state2, nodeId, attemptId) {
71967
- return state2.directoryLoadInfoById.get(nodeId)?.activeAttemptId === attemptId;
72411
+ function isDirectoryLoadAttemptCurrent(state3, nodeId, attemptId) {
72412
+ return state3.directoryLoadInfoById.get(nodeId)?.activeAttemptId === attemptId;
71968
72413
  }
71969
- function failDirectoryLoad(state2, nodeId, attemptId, errorMessage) {
71970
- const loadInfo = state2.directoryLoadInfoById.get(nodeId);
72414
+ function failDirectoryLoad(state3, nodeId, attemptId, errorMessage) {
72415
+ const loadInfo = state3.directoryLoadInfoById.get(nodeId);
71971
72416
  if (loadInfo == null || loadInfo.activeAttemptId !== attemptId) return false;
71972
72417
  loadInfo.activeAttemptId = null;
71973
72418
  loadInfo.errorMessage = errorMessage ?? null;
71974
72419
  loadInfo.state = "error";
71975
72420
  return true;
71976
72421
  }
71977
- function clearDirectoryLoadInfo(state2, nodeId) {
71978
- state2.directoryLoadInfoById.delete(nodeId);
72422
+ function clearDirectoryLoadInfo(state3, nodeId) {
72423
+ state3.directoryLoadInfoById.delete(nodeId);
71979
72424
  }
71980
72425
 
71981
72426
  // node_modules/@pierre/trees/dist/path-store/src/events.js
71982
- function subscribe(state2, type, handler) {
72427
+ function subscribe(state3, type, handler) {
71983
72428
  const rawHandler = handler;
71984
- const existingListeners = state2.listeners.get(type);
72429
+ const existingListeners = state3.listeners.get(type);
71985
72430
  if (existingListeners != null) existingListeners.add(rawHandler);
71986
- else state2.listeners.set(type, /* @__PURE__ */ new Set([rawHandler]));
72431
+ else state3.listeners.set(type, /* @__PURE__ */ new Set([rawHandler]));
71987
72432
  return () => {
71988
- const listeners = state2.listeners.get(type);
72433
+ const listeners = state3.listeners.get(type);
71989
72434
  if (listeners == null) return;
71990
72435
  listeners.delete(rawHandler);
71991
- if (listeners.size === 0) state2.listeners.delete(type);
72436
+ if (listeners.size === 0) state3.listeners.delete(type);
71992
72437
  };
71993
72438
  }
71994
72439
  function createAddEvent(args2) {
@@ -72138,58 +72583,58 @@ function createCleanupEvent(args2) {
72138
72583
  visibleCountDelta: null
72139
72584
  };
72140
72585
  }
72141
- function finalizeEvent(state2, previousVisibleCount, event2) {
72586
+ function finalizeEvent(state3, previousVisibleCount, event2) {
72142
72587
  return {
72143
72588
  ...event2,
72144
- visibleCountDelta: getCurrentVisibleCount(state2) - previousVisibleCount
72589
+ visibleCountDelta: getCurrentVisibleCount(state3) - previousVisibleCount
72145
72590
  };
72146
72591
  }
72147
- function batchEvents(state2, run2) {
72148
- const previousVisibleCount = getCurrentVisibleCount(state2);
72592
+ function batchEvents(state3, run2) {
72593
+ const previousVisibleCount = getCurrentVisibleCount(state3);
72149
72594
  const frame = createTransactionFrame();
72150
- state2.transactionStack.push(frame);
72595
+ state3.transactionStack.push(frame);
72151
72596
  try {
72152
72597
  run2();
72153
72598
  } catch (error) {
72154
- finishTransaction(state2, frame, false);
72599
+ finishTransaction(state3, frame, false);
72155
72600
  throw error;
72156
72601
  }
72157
- finishTransaction(state2, frame, true, getCurrentVisibleCount(state2) - previousVisibleCount);
72602
+ finishTransaction(state3, frame, true, getCurrentVisibleCount(state3) - previousVisibleCount);
72158
72603
  }
72159
- function recordEvent(state2, event2) {
72160
- const instrumentation = state2.instrumentation;
72604
+ function recordEvent(state3, event2) {
72605
+ const instrumentation = state3.instrumentation;
72161
72606
  if (instrumentation == null) {
72162
- recordEventNow(state2, event2);
72607
+ recordEventNow(state3, event2);
72163
72608
  return;
72164
72609
  }
72165
- withBenchmarkPhase(instrumentation, "store.events.record", () => recordEventNow(state2, event2));
72610
+ withBenchmarkPhase(instrumentation, "store.events.record", () => recordEventNow(state3, event2));
72166
72611
  }
72167
- function recordEventNow(state2, event2) {
72168
- const currentFrame = state2.transactionStack[state2.transactionStack.length - 1] ?? null;
72612
+ function recordEventNow(state3, event2) {
72613
+ const currentFrame = state3.transactionStack[state3.transactionStack.length - 1] ?? null;
72169
72614
  if (currentFrame == null) {
72170
- emitEvent(state2, event2);
72615
+ emitEvent(state3, event2);
72171
72616
  return;
72172
72617
  }
72173
72618
  currentFrame.events.push(event2);
72174
72619
  mergeEventMetadataIntoFrame(currentFrame, event2);
72175
72620
  }
72176
- function finishTransaction(state2, frame, emit, visibleCountDelta = null) {
72177
- if (state2.transactionStack.pop() !== frame) throw new Error("Transaction stack underflow");
72621
+ function finishTransaction(state3, frame, emit, visibleCountDelta = null) {
72622
+ if (state3.transactionStack.pop() !== frame) throw new Error("Transaction stack underflow");
72178
72623
  if (!emit) return;
72179
- const parentFrame = state2.transactionStack[state2.transactionStack.length - 1] ?? null;
72624
+ const parentFrame = state3.transactionStack[state3.transactionStack.length - 1] ?? null;
72180
72625
  if (parentFrame != null) {
72181
- const instrumentation2 = state2.instrumentation;
72626
+ const instrumentation2 = state3.instrumentation;
72182
72627
  if (instrumentation2 == null) mergeBatchFrameIntoParent(parentFrame, frame);
72183
72628
  else withBenchmarkPhase(instrumentation2, "store.events.batch.merge", () => mergeBatchFrameIntoParent(parentFrame, frame));
72184
72629
  return;
72185
72630
  }
72186
72631
  const batchEvent = createBatchEvent(frame, visibleCountDelta);
72187
- const instrumentation = state2.instrumentation;
72632
+ const instrumentation = state3.instrumentation;
72188
72633
  if (instrumentation == null) {
72189
- emitEvent(state2, batchEvent);
72634
+ emitEvent(state3, batchEvent);
72190
72635
  return;
72191
72636
  }
72192
- withBenchmarkPhase(instrumentation, "store.events.batch.commit", () => emitEvent(state2, batchEvent));
72637
+ withBenchmarkPhase(instrumentation, "store.events.batch.commit", () => emitEvent(state3, batchEvent));
72193
72638
  }
72194
72639
  function createBatchEvent(frame, visibleCountDelta) {
72195
72640
  return {
@@ -72214,48 +72659,48 @@ function mergeEventMetadataIntoFrame(frame, event2) {
72214
72659
  for (const nodeId of event2.affectedNodeIds) frame.affectedNodeIds.add(nodeId);
72215
72660
  for (const nodeId of event2.affectedAncestorIds) frame.affectedAncestorIds.add(nodeId);
72216
72661
  }
72217
- function emitEvent(state2, event2) {
72218
- const instrumentation = state2.instrumentation;
72662
+ function emitEvent(state3, event2) {
72663
+ const instrumentation = state3.instrumentation;
72219
72664
  if (instrumentation == null) {
72220
- emitEventNow(state2, event2);
72665
+ emitEventNow(state3, event2);
72221
72666
  return;
72222
72667
  }
72223
- withBenchmarkPhase(instrumentation, "store.events.emit", () => emitEventNow(state2, event2));
72668
+ withBenchmarkPhase(instrumentation, "store.events.emit", () => emitEventNow(state3, event2));
72224
72669
  }
72225
- function emitEventNow(state2, event2) {
72226
- state2.listeners.get(event2.operation)?.forEach((handler) => handler(event2));
72227
- state2.listeners.get("*")?.forEach((handler) => handler(event2));
72670
+ function emitEventNow(state3, event2) {
72671
+ state3.listeners.get(event2.operation)?.forEach((handler) => handler(event2));
72672
+ state3.listeners.get("*")?.forEach((handler) => handler(event2));
72228
72673
  }
72229
- function getCurrentVisibleCount(state2) {
72230
- return state2.snapshot.nodes[state2.snapshot.rootId]?.visibleSubtreeCount ?? 0;
72674
+ function getCurrentVisibleCount(state3) {
72675
+ return state3.snapshot.nodes[state3.snapshot.rootId]?.visibleSubtreeCount ?? 0;
72231
72676
  }
72232
72677
 
72233
72678
  // node_modules/@pierre/trees/dist/path-store/src/flatten.js
72234
- function getFlattenedChildDirectoryId(state2, directoryNodeId) {
72235
- if (state2.snapshot.options.flattenEmptyDirectories !== true) return null;
72236
- const directoryNode = state2.snapshot.nodes[directoryNodeId];
72679
+ function getFlattenedChildDirectoryId(state3, directoryNodeId) {
72680
+ if (state3.snapshot.options.flattenEmptyDirectories !== true) return null;
72681
+ const directoryNode = state3.snapshot.nodes[directoryNodeId];
72237
72682
  if (directoryNode == null || !isDirectoryNode(directoryNode) || hasNodeFlag(directoryNode, 2)) return null;
72238
- const directoryIndex = state2.snapshot.directories.get(directoryNodeId);
72683
+ const directoryIndex = state3.snapshot.directories.get(directoryNodeId);
72239
72684
  if (directoryIndex == null || directoryIndex.childIds.length !== 1) return null;
72240
72685
  const childId = directoryIndex.childIds[0];
72241
72686
  if (childId == null) return null;
72242
- const childNode = state2.snapshot.nodes[childId];
72687
+ const childNode = state3.snapshot.nodes[childId];
72243
72688
  if (childNode == null || !isDirectoryNode(childNode)) return null;
72244
72689
  return childId;
72245
72690
  }
72246
- function getFlattenedTerminalDirectoryId(state2, directoryNodeId) {
72691
+ function getFlattenedTerminalDirectoryId(state3, directoryNodeId) {
72247
72692
  let currentDirectoryId = directoryNodeId;
72248
72693
  while (true) {
72249
- const nextDirectoryId = getFlattenedChildDirectoryId(state2, currentDirectoryId);
72694
+ const nextDirectoryId = getFlattenedChildDirectoryId(state3, currentDirectoryId);
72250
72695
  if (nextDirectoryId == null) return currentDirectoryId;
72251
72696
  currentDirectoryId = nextDirectoryId;
72252
72697
  }
72253
72698
  }
72254
- function collectFlattenedDirectoryChainIds(state2, directoryNodeId) {
72699
+ function collectFlattenedDirectoryChainIds(state3, directoryNodeId) {
72255
72700
  const chainIds = [directoryNodeId];
72256
72701
  let currentDirectoryId = directoryNodeId;
72257
72702
  while (true) {
72258
- const nextDirectoryId = getFlattenedChildDirectoryId(state2, currentDirectoryId);
72703
+ const nextDirectoryId = getFlattenedChildDirectoryId(state3, currentDirectoryId);
72259
72704
  if (nextDirectoryId == null) return chainIds;
72260
72705
  chainIds.push(nextDirectoryId);
72261
72706
  currentDirectoryId = nextDirectoryId;
@@ -72263,144 +72708,144 @@ function collectFlattenedDirectoryChainIds(state2, directoryNodeId) {
72263
72708
  }
72264
72709
 
72265
72710
  // node_modules/@pierre/trees/dist/path-store/src/canonical.js
72266
- function listPaths(state2, path) {
72267
- const nodeId = path == null ? state2.snapshot.rootId : findNodeId(state2, path);
72711
+ function listPaths(state3, path) {
72712
+ const nodeId = path == null ? state3.snapshot.rootId : findNodeId(state3, path);
72268
72713
  if (nodeId == null) return [];
72269
- return collectCanonicalEntries(state2, nodeId);
72714
+ return collectCanonicalEntries(state3, nodeId);
72270
72715
  }
72271
- function addPath(state2, path) {
72716
+ function addPath(state3, path) {
72272
72717
  const preparedPath = parseInputPath(path);
72273
72718
  const parentSegments = preparedPath.isDirectory ? preparedPath.segments : preparedPath.segments.slice(0, -1);
72274
- const previousProjectionSignature = getCollapsedProjectionSignature(state2, findDeepestExistingDirectoryId(state2, parentSegments));
72275
- const { createdNodeIds, directoryId } = ensureDirectoryChain(state2, parentSegments);
72719
+ const previousProjectionSignature = getCollapsedProjectionSignature(state3, findDeepestExistingDirectoryId(state3, parentSegments));
72720
+ const { createdNodeIds, directoryId } = ensureDirectoryChain(state3, parentSegments);
72276
72721
  const affectedNodeIds = new Set(createdNodeIds);
72277
72722
  let addedNodeId = directoryId;
72278
72723
  if (preparedPath.isDirectory) {
72279
- const directoryNode = requireNode(state2, directoryId);
72724
+ const directoryNode = requireNode(state3, directoryId);
72280
72725
  if (hasNodeFlag(directoryNode, 1)) throw new Error(`Path already exists: "${path}"`);
72281
72726
  addNodeFlag(directoryNode, 1);
72282
- state2.pathCacheByNodeId.set(directoryId, {
72727
+ state3.pathCacheByNodeId.set(directoryId, {
72283
72728
  path,
72284
- version: state2.pathCacheVersion
72729
+ version: state3.pathCacheVersion
72285
72730
  });
72286
72731
  affectedNodeIds.add(directoryId);
72287
72732
  } else {
72288
- addedNodeId = createFileNode(state2, directoryId, preparedPath.basename);
72733
+ addedNodeId = createFileNode(state3, directoryId, preparedPath.basename);
72289
72734
  affectedNodeIds.add(addedNodeId);
72290
72735
  }
72291
- recomputeCountsUpwardFrom(state2, directoryId);
72292
- const nextProjectionSignature = getCollapsedProjectionSignature(state2, directoryId);
72736
+ recomputeCountsUpwardFrom(state3, directoryId);
72737
+ const nextProjectionSignature = getCollapsedProjectionSignature(state3, directoryId);
72293
72738
  return createAddEvent({
72294
- affectedAncestorIds: collectAncestorIds(state2, addedNodeId),
72739
+ affectedAncestorIds: collectAncestorIds(state3, addedNodeId),
72295
72740
  affectedNodeIds: [...affectedNodeIds],
72296
72741
  path,
72297
72742
  projectionChanged: didProjectionChange(previousProjectionSignature, nextProjectionSignature)
72298
72743
  });
72299
72744
  }
72300
- function removePath(state2, path, options) {
72301
- const nodeId = findNodeId(state2, path);
72745
+ function removePath(state3, path, options) {
72746
+ const nodeId = findNodeId(state3, path);
72302
72747
  if (nodeId == null) throw new Error(`Path does not exist: "${path}"`);
72303
- const node = requireNode(state2, nodeId);
72748
+ const node = requireNode(state3, nodeId);
72304
72749
  if (hasNodeFlag(node, 2)) throw new Error("The root node cannot be removed");
72305
- if (isDirectoryNode(node) && getDirectoryIndex(state2, nodeId).childIds.length > 0 && options.recursive !== true) throw new Error(`Cannot remove a non-empty directory without recursive: "${path}"`);
72750
+ if (isDirectoryNode(node) && getDirectoryIndex(state3, nodeId).childIds.length > 0 && options.recursive !== true) throw new Error(`Cannot remove a non-empty directory without recursive: "${path}"`);
72306
72751
  const parentId = node.parentId;
72307
- const previousProjectionSignature = getCollapsedProjectionSignature(state2, parentId);
72308
- const removedNodeIds = removeSubtree(state2, nodeId);
72309
- removeChildReference(state2, parentId, nodeId, node.nameId);
72310
- promoteEmptyAncestorsToExplicit(state2, parentId);
72311
- recomputeCountsUpwardFrom(state2, parentId);
72312
- const nextProjectionSignature = getCollapsedProjectionSignature(state2, parentId);
72752
+ const previousProjectionSignature = getCollapsedProjectionSignature(state3, parentId);
72753
+ const removedNodeIds = removeSubtree(state3, nodeId);
72754
+ removeChildReference(state3, parentId, nodeId, node.nameId);
72755
+ promoteEmptyAncestorsToExplicit(state3, parentId);
72756
+ recomputeCountsUpwardFrom(state3, parentId);
72757
+ const nextProjectionSignature = getCollapsedProjectionSignature(state3, parentId);
72313
72758
  return createRemoveEvent({
72314
- affectedAncestorIds: collectAncestorIds(state2, parentId),
72759
+ affectedAncestorIds: collectAncestorIds(state3, parentId),
72315
72760
  affectedNodeIds: removedNodeIds,
72316
72761
  path,
72317
72762
  projectionChanged: didProjectionChange(previousProjectionSignature, nextProjectionSignature),
72318
72763
  recursive: options.recursive === true
72319
72764
  });
72320
72765
  }
72321
- function movePath(state2, fromPath, toPath, options) {
72322
- const sourceNodeId = findNodeId(state2, fromPath);
72766
+ function movePath(state3, fromPath, toPath, options) {
72767
+ const sourceNodeId = findNodeId(state3, fromPath);
72323
72768
  if (sourceNodeId == null) throw new Error(`Source path does not exist: "${fromPath}"`);
72324
- const sourceNode = requireNode(state2, sourceNodeId);
72769
+ const sourceNode = requireNode(state3, sourceNodeId);
72325
72770
  if (hasNodeFlag(sourceNode, 2)) throw new Error("The root node cannot be moved");
72326
72771
  const collision = options.collision ?? "error";
72327
- const moveTarget = resolveMoveTarget(state2, sourceNodeId, toPath);
72328
- const previousSourceProjectionSignature = getCollapsedProjectionSignature(state2, sourceNode.parentId);
72329
- const previousTargetProjectionSignature = getCollapsedProjectionSignature(state2, moveTarget.parentId);
72330
- const sourceName = getSegmentValue(state2.snapshot.segmentTable, sourceNode.nameId);
72331
- const targetNameId = internSegment(state2.snapshot.segmentTable, moveTarget.basename);
72772
+ const moveTarget = resolveMoveTarget(state3, sourceNodeId, toPath);
72773
+ const previousSourceProjectionSignature = getCollapsedProjectionSignature(state3, sourceNode.parentId);
72774
+ const previousTargetProjectionSignature = getCollapsedProjectionSignature(state3, moveTarget.parentId);
72775
+ const sourceName = getSegmentValue(state3.snapshot.segmentTable, sourceNode.nameId);
72776
+ const targetNameId = internSegment(state3.snapshot.segmentTable, moveTarget.basename);
72332
72777
  if (moveTarget.parentId === sourceNode.parentId && sourceName === moveTarget.basename) return null;
72333
- if (isDirectoryNode(sourceNode) && isAncestor2(state2, sourceNodeId, moveTarget.parentId)) throw new Error("Cannot move a directory into one of its descendants");
72334
- const siblingCollisionId = ensureChildIdByNameId(state2.snapshot.nodes, getDirectoryIndex(state2, moveTarget.parentId)).get(targetNameId);
72778
+ if (isDirectoryNode(sourceNode) && isAncestor2(state3, sourceNodeId, moveTarget.parentId)) throw new Error("Cannot move a directory into one of its descendants");
72779
+ const siblingCollisionId = ensureChildIdByNameId(state3.snapshot.nodes, getDirectoryIndex(state3, moveTarget.parentId)).get(targetNameId);
72335
72780
  const collisionNodeId = moveTarget.existingNodeId ?? siblingCollisionId ?? null;
72336
72781
  if (collisionNodeId != null && collisionNodeId !== sourceNodeId) {
72337
- if (handleMoveCollision(state2, collisionNodeId, collision, getNodeKind(sourceNode)) === "skip") return null;
72782
+ if (handleMoveCollision(state3, collisionNodeId, collision, getNodeKind(sourceNode)) === "skip") return null;
72338
72783
  }
72339
72784
  const previousParentId = sourceNode.parentId;
72340
- removeChildReference(state2, previousParentId, sourceNodeId, sourceNode.nameId);
72785
+ removeChildReference(state3, previousParentId, sourceNodeId, sourceNode.nameId);
72341
72786
  sourceNode.parentId = moveTarget.parentId;
72342
72787
  sourceNode.nameId = targetNameId;
72343
- state2.pathCacheByNodeId.delete(sourceNodeId);
72344
- recomputeDepths(state2, sourceNodeId);
72345
- insertChildReference(state2, moveTarget.parentId, sourceNodeId);
72346
- promoteEmptyAncestorsToExplicit(state2, previousParentId);
72347
- state2.pathCacheVersion++;
72348
- recomputeCountsUpwardFrom(state2, previousParentId);
72349
- if (moveTarget.parentId !== previousParentId) recomputeCountsUpwardFrom(state2, moveTarget.parentId);
72350
- const nextSourceProjectionSignature = getCollapsedProjectionSignature(state2, previousParentId);
72351
- const nextTargetProjectionSignature = getCollapsedProjectionSignature(state2, moveTarget.parentId);
72788
+ state3.pathCacheByNodeId.delete(sourceNodeId);
72789
+ recomputeDepths(state3, sourceNodeId);
72790
+ insertChildReference(state3, moveTarget.parentId, sourceNodeId);
72791
+ promoteEmptyAncestorsToExplicit(state3, previousParentId);
72792
+ state3.pathCacheVersion++;
72793
+ recomputeCountsUpwardFrom(state3, previousParentId);
72794
+ if (moveTarget.parentId !== previousParentId) recomputeCountsUpwardFrom(state3, moveTarget.parentId);
72795
+ const nextSourceProjectionSignature = getCollapsedProjectionSignature(state3, previousParentId);
72796
+ const nextTargetProjectionSignature = getCollapsedProjectionSignature(state3, moveTarget.parentId);
72352
72797
  return createMoveEvent({
72353
- affectedAncestorIds: [.../* @__PURE__ */ new Set([...collectAncestorIds(state2, previousParentId), ...collectAncestorIds(state2, moveTarget.parentId)])],
72798
+ affectedAncestorIds: [.../* @__PURE__ */ new Set([...collectAncestorIds(state3, previousParentId), ...collectAncestorIds(state3, moveTarget.parentId)])],
72354
72799
  affectedNodeIds: [sourceNodeId],
72355
72800
  from: fromPath,
72356
72801
  projectionChanged: didAnyProjectionChange([previousSourceProjectionSignature, previousTargetProjectionSignature], [nextSourceProjectionSignature, nextTargetProjectionSignature]),
72357
- to: materializeNodePath(state2, sourceNodeId)
72802
+ to: materializeNodePath(state3, sourceNodeId)
72358
72803
  });
72359
72804
  }
72360
- function getCachedNodePath(state2, nodeId) {
72361
- const cachedEntry = state2.pathCacheByNodeId.get(nodeId);
72362
- return cachedEntry != null && cachedEntry.version === state2.pathCacheVersion ? cachedEntry.path : null;
72805
+ function getCachedNodePath(state3, nodeId) {
72806
+ const cachedEntry = state3.pathCacheByNodeId.get(nodeId);
72807
+ return cachedEntry != null && cachedEntry.version === state3.pathCacheVersion ? cachedEntry.path : null;
72363
72808
  }
72364
- function setCachedNodePath(state2, nodeId, path) {
72365
- state2.pathCacheByNodeId.set(nodeId, {
72809
+ function setCachedNodePath(state3, nodeId, path) {
72810
+ state3.pathCacheByNodeId.set(nodeId, {
72366
72811
  path,
72367
- version: state2.pathCacheVersion
72812
+ version: state3.pathCacheVersion
72368
72813
  });
72369
72814
  return path;
72370
72815
  }
72371
- function materializeNodePath(state2, nodeId) {
72372
- const node = requireNode(state2, nodeId);
72373
- const cachedPath = getCachedNodePath(state2, nodeId);
72816
+ function materializeNodePath(state3, nodeId) {
72817
+ const node = requireNode(state3, nodeId);
72818
+ const cachedPath = getCachedNodePath(state3, nodeId);
72374
72819
  if (cachedPath != null) return cachedPath;
72375
- if (hasNodeFlag(node, 2)) return setCachedNodePath(state2, nodeId, "");
72376
- const parentPath = materializeNodePath(state2, node.parentId);
72377
- const nodeName = getSegmentValue(state2.snapshot.segmentTable, node.nameId);
72820
+ if (hasNodeFlag(node, 2)) return setCachedNodePath(state3, nodeId, "");
72821
+ const parentPath = materializeNodePath(state3, node.parentId);
72822
+ const nodeName = getSegmentValue(state3.snapshot.segmentTable, node.nameId);
72378
72823
  const path = parentPath.length === 0 ? nodeName : `${parentPath}${nodeName}`;
72379
- return setCachedNodePath(state2, nodeId, isDirectoryNode(node) ? `${path}/` : path);
72824
+ return setCachedNodePath(state3, nodeId, isDirectoryNode(node) ? `${path}/` : path);
72380
72825
  }
72381
- function recomputeCountsUpwardFrom(state2, startNodeId) {
72382
- const instrumentation = state2.instrumentation;
72826
+ function recomputeCountsUpwardFrom(state3, startNodeId) {
72827
+ const instrumentation = state3.instrumentation;
72383
72828
  if (instrumentation == null) {
72384
- recomputeCountsUpwardFromNow(state2, startNodeId);
72829
+ recomputeCountsUpwardFromNow(state3, startNodeId);
72385
72830
  return;
72386
72831
  }
72387
- withBenchmarkPhase(instrumentation, "store.recomputeCountsUpwardFrom", () => recomputeCountsUpwardFromNow(state2, startNodeId));
72832
+ withBenchmarkPhase(instrumentation, "store.recomputeCountsUpwardFrom", () => recomputeCountsUpwardFromNow(state3, startNodeId));
72388
72833
  }
72389
- function recomputeCountsRecursive(state2, nodeId) {
72834
+ function recomputeCountsRecursive(state3, nodeId) {
72390
72835
  const stack = [[nodeId, 0]];
72391
- const { nodes, directories } = state2.snapshot;
72836
+ const { nodes, directories } = state3.snapshot;
72392
72837
  while (stack.length > 0) {
72393
72838
  const frame = stack[stack.length - 1];
72394
72839
  const nid = frame[0];
72395
72840
  const node = nodes[nid];
72396
72841
  if (node == null || !isDirectoryNode(node)) {
72397
- recomputeNodeCounts(state2, nid, node, true);
72842
+ recomputeNodeCounts(state3, nid, node, true);
72398
72843
  stack.pop();
72399
72844
  continue;
72400
72845
  }
72401
72846
  const dirIndex = directories.get(nid);
72402
72847
  if (dirIndex == null || frame[1] >= dirIndex.childIds.length) {
72403
- recomputeNodeCounts(state2, nid, node, true);
72848
+ recomputeNodeCounts(state3, nid, node, true);
72404
72849
  stack.pop();
72405
72850
  continue;
72406
72851
  }
@@ -72408,51 +72853,51 @@ function recomputeCountsRecursive(state2, nodeId) {
72408
72853
  stack.push([childId, 0]);
72409
72854
  }
72410
72855
  }
72411
- function collectAncestorIds(state2, nodeId) {
72856
+ function collectAncestorIds(state3, nodeId) {
72412
72857
  const ancestorIds = [];
72413
72858
  let currentNodeId = nodeId;
72414
72859
  while (currentNodeId != null) {
72415
- const currentNode = requireNode(state2, currentNodeId);
72860
+ const currentNode = requireNode(state3, currentNodeId);
72416
72861
  ancestorIds.push(currentNodeId);
72417
- if (currentNodeId === state2.snapshot.rootId) break;
72862
+ if (currentNodeId === state3.snapshot.rootId) break;
72418
72863
  currentNodeId = currentNode.parentId;
72419
72864
  }
72420
72865
  return ancestorIds;
72421
72866
  }
72422
- function findNodeId(state2, path) {
72423
- if (path.length === 0) return state2.snapshot.rootId;
72867
+ function findNodeId(state3, path) {
72868
+ if (path.length === 0) return state3.snapshot.rootId;
72424
72869
  const lookupPath = parseLookupPath(path);
72425
- return findNodeIdBySegments(state2, lookupPath.segments, lookupPath.requiresDirectory);
72870
+ return findNodeIdBySegments(state3, lookupPath.segments, lookupPath.requiresDirectory);
72426
72871
  }
72427
- function findNodeIdBySegments(state2, segments, requireDirectory) {
72428
- let currentNodeId = state2.snapshot.rootId;
72872
+ function findNodeIdBySegments(state3, segments, requireDirectory) {
72873
+ let currentNodeId = state3.snapshot.rootId;
72429
72874
  for (const segment2 of segments) {
72430
- const segmentId = state2.snapshot.segmentTable.idByValue.get(segment2);
72875
+ const segmentId = state3.snapshot.segmentTable.idByValue.get(segment2);
72431
72876
  if (segmentId === void 0) return null;
72432
- const currentIndex = getDirectoryIndex(state2, currentNodeId);
72433
- const nextNodeId = ensureChildIdByNameId(state2.snapshot.nodes, currentIndex).get(segmentId);
72877
+ const currentIndex = getDirectoryIndex(state3, currentNodeId);
72878
+ const nextNodeId = ensureChildIdByNameId(state3.snapshot.nodes, currentIndex).get(segmentId);
72434
72879
  if (nextNodeId === void 0) return null;
72435
72880
  currentNodeId = nextNodeId;
72436
72881
  }
72437
- const currentNode = requireNode(state2, currentNodeId);
72882
+ const currentNode = requireNode(state3, currentNodeId);
72438
72883
  if (requireDirectory && !isDirectoryNode(currentNode)) return null;
72439
72884
  return currentNodeId;
72440
72885
  }
72441
- function getDirectoryIndex(state2, directoryId) {
72442
- const directoryIndex = state2.snapshot.directories.get(directoryId);
72886
+ function getDirectoryIndex(state3, directoryId) {
72887
+ const directoryIndex = state3.snapshot.directories.get(directoryId);
72443
72888
  if (directoryIndex === void 0) throw new Error(`Unknown directory child index for node ${String(directoryId)}`);
72444
72889
  return directoryIndex;
72445
72890
  }
72446
- function requireNode(state2, nodeId) {
72447
- const node = state2.snapshot.nodes[nodeId];
72891
+ function requireNode(state3, nodeId) {
72892
+ const node = state3.snapshot.nodes[nodeId];
72448
72893
  if (node === void 0 || hasNodeFlag(node, 4)) throw new Error(`Unknown node ID: ${String(nodeId)}`);
72449
72894
  return node;
72450
72895
  }
72451
- function collectCanonicalEntries(state2, nodeId) {
72452
- const rootNode = state2.snapshot.nodes[nodeId];
72896
+ function collectCanonicalEntries(state3, nodeId) {
72897
+ const rootNode = state3.snapshot.nodes[nodeId];
72453
72898
  if (rootNode === void 0 || hasNodeFlag(rootNode, 4)) return [];
72454
- if (!isDirectoryNode(rootNode)) return [materializeNodePath(state2, nodeId)];
72455
- if (getDirectoryIndex(state2, nodeId).childIds.length === 0) return hasNodeFlag(rootNode, 1) && !hasNodeFlag(rootNode, 2) ? [materializeNodePath(state2, nodeId)] : [];
72899
+ if (!isDirectoryNode(rootNode)) return [materializeNodePath(state3, nodeId)];
72900
+ if (getDirectoryIndex(state3, nodeId).childIds.length === 0) return hasNodeFlag(rootNode, 1) && !hasNodeFlag(rootNode, 2) ? [materializeNodePath(state3, nodeId)] : [];
72456
72901
  const entries = [];
72457
72902
  const stack = [{
72458
72903
  childIndex: 0,
@@ -72461,19 +72906,19 @@ function collectCanonicalEntries(state2, nodeId) {
72461
72906
  while (stack.length > 0) {
72462
72907
  const frame = stack[stack.length - 1];
72463
72908
  if (frame == null) break;
72464
- const currentNode = state2.snapshot.nodes[frame.nodeId];
72909
+ const currentNode = state3.snapshot.nodes[frame.nodeId];
72465
72910
  if (currentNode === void 0 || hasNodeFlag(currentNode, 4)) {
72466
72911
  stack.pop();
72467
72912
  continue;
72468
72913
  }
72469
72914
  if (!isDirectoryNode(currentNode)) {
72470
- entries.push(materializeNodePath(state2, frame.nodeId));
72915
+ entries.push(materializeNodePath(state3, frame.nodeId));
72471
72916
  stack.pop();
72472
72917
  continue;
72473
72918
  }
72474
- const currentIndex = getDirectoryIndex(state2, frame.nodeId);
72919
+ const currentIndex = getDirectoryIndex(state3, frame.nodeId);
72475
72920
  if (currentIndex.childIds.length === 0) {
72476
- if (hasNodeFlag(currentNode, 1) && !hasNodeFlag(currentNode, 2)) entries.push(materializeNodePath(state2, frame.nodeId));
72921
+ if (hasNodeFlag(currentNode, 1) && !hasNodeFlag(currentNode, 2)) entries.push(materializeNodePath(state3, frame.nodeId));
72477
72922
  stack.pop();
72478
72923
  continue;
72479
72924
  }
@@ -72490,19 +72935,19 @@ function collectCanonicalEntries(state2, nodeId) {
72490
72935
  }
72491
72936
  return entries;
72492
72937
  }
72493
- function ensureDirectoryChain(state2, directorySegments) {
72938
+ function ensureDirectoryChain(state3, directorySegments) {
72494
72939
  const createdNodeIds = [];
72495
- let currentDirectoryId = state2.snapshot.rootId;
72940
+ let currentDirectoryId = state3.snapshot.rootId;
72496
72941
  for (const segment2 of directorySegments) {
72497
- const segmentId = internSegment(state2.snapshot.segmentTable, segment2);
72498
- const currentIndex = getDirectoryIndex(state2, currentDirectoryId);
72499
- const existingChildId = ensureChildIdByNameId(state2.snapshot.nodes, currentIndex).get(segmentId);
72942
+ const segmentId = internSegment(state3.snapshot.segmentTable, segment2);
72943
+ const currentIndex = getDirectoryIndex(state3, currentDirectoryId);
72944
+ const existingChildId = ensureChildIdByNameId(state3.snapshot.nodes, currentIndex).get(segmentId);
72500
72945
  if (existingChildId !== void 0) {
72501
- if (!isDirectoryNode(requireNode(state2, existingChildId))) throw new Error(`Cannot create a directory that collides with an existing file: "${segment2}"`);
72946
+ if (!isDirectoryNode(requireNode(state3, existingChildId))) throw new Error(`Cannot create a directory that collides with an existing file: "${segment2}"`);
72502
72947
  currentDirectoryId = existingChildId;
72503
72948
  continue;
72504
72949
  }
72505
- currentDirectoryId = createDirectoryNode(state2, currentDirectoryId, segmentId);
72950
+ currentDirectoryId = createDirectoryNode(state3, currentDirectoryId, segmentId);
72506
72951
  createdNodeIds.push(currentDirectoryId);
72507
72952
  }
72508
72953
  return {
@@ -72510,43 +72955,43 @@ function ensureDirectoryChain(state2, directorySegments) {
72510
72955
  directoryId: currentDirectoryId
72511
72956
  };
72512
72957
  }
72513
- function createDirectoryNode(state2, parentId, nameId) {
72514
- const parentNode = requireNode(state2, parentId);
72515
- const nodeId = state2.snapshot.nodes.length;
72516
- state2.snapshot.nodes.push({
72958
+ function createDirectoryNode(state3, parentId, nameId) {
72959
+ const parentNode = requireNode(state3, parentId);
72960
+ const nodeId = state3.snapshot.nodes.length;
72961
+ state3.snapshot.nodes.push({
72517
72962
  depthAndFlags: createNodeDepthAndFlags(getNodeDepth(parentNode) + 1, 0, 1),
72518
72963
  nameId,
72519
72964
  parentId,
72520
72965
  subtreeNodeCount: 1,
72521
72966
  visibleSubtreeCount: 1
72522
72967
  });
72523
- state2.snapshot.directories.set(nodeId, createDirectoryChildIndex());
72524
- insertChildReference(state2, parentId, nodeId);
72525
- if (state2.collapseNewDirectoriesByDefault) {
72526
- state2.collapsedDirectoryIds.add(nodeId);
72527
- state2.hasCollapsedDirectoryOverrides = true;
72968
+ state3.snapshot.directories.set(nodeId, createDirectoryChildIndex());
72969
+ insertChildReference(state3, parentId, nodeId);
72970
+ if (state3.collapseNewDirectoriesByDefault) {
72971
+ state3.collapsedDirectoryIds.add(nodeId);
72972
+ state3.hasCollapsedDirectoryOverrides = true;
72528
72973
  }
72529
- state2.activeNodeCount++;
72974
+ state3.activeNodeCount++;
72530
72975
  return nodeId;
72531
72976
  }
72532
- function createFileNode(state2, parentId, basename3) {
72533
- const nameId = internSegment(state2.snapshot.segmentTable, basename3);
72534
- const parentIndex = getDirectoryIndex(state2, parentId);
72535
- if (ensureChildIdByNameId(state2.snapshot.nodes, parentIndex).has(nameId)) throw new Error(`Path already exists: "${buildPathPreview(state2, parentId, basename3)}"`);
72536
- const parentNode = requireNode(state2, parentId);
72537
- const nodeId = state2.snapshot.nodes.length;
72538
- state2.snapshot.nodes.push({
72977
+ function createFileNode(state3, parentId, basename3) {
72978
+ const nameId = internSegment(state3.snapshot.segmentTable, basename3);
72979
+ const parentIndex = getDirectoryIndex(state3, parentId);
72980
+ if (ensureChildIdByNameId(state3.snapshot.nodes, parentIndex).has(nameId)) throw new Error(`Path already exists: "${buildPathPreview(state3, parentId, basename3)}"`);
72981
+ const parentNode = requireNode(state3, parentId);
72982
+ const nodeId = state3.snapshot.nodes.length;
72983
+ state3.snapshot.nodes.push({
72539
72984
  depthAndFlags: createNodeDepthAndFlags(getNodeDepth(parentNode) + 1, 0),
72540
72985
  nameId,
72541
72986
  parentId,
72542
72987
  subtreeNodeCount: 1,
72543
72988
  visibleSubtreeCount: 1
72544
72989
  });
72545
- insertChildReference(state2, parentId, nodeId);
72546
- state2.activeNodeCount++;
72990
+ insertChildReference(state3, parentId, nodeId);
72991
+ state3.activeNodeCount++;
72547
72992
  return nodeId;
72548
72993
  }
72549
- function findChildInsertIndex(state2, parentIndex, childId) {
72994
+ function findChildInsertIndex(state3, parentIndex, childId) {
72550
72995
  let low = 0;
72551
72996
  let high = parentIndex.childIds.length;
72552
72997
  while (low < high) {
@@ -72556,72 +73001,72 @@ function findChildInsertIndex(state2, parentIndex, childId) {
72556
73001
  high = middle;
72557
73002
  continue;
72558
73003
  }
72559
- if (compareSiblingNodes(state2, childId, existingChildId) < 0) high = middle;
73004
+ if (compareSiblingNodes(state3, childId, existingChildId) < 0) high = middle;
72560
73005
  else low = middle + 1;
72561
73006
  }
72562
73007
  return low;
72563
73008
  }
72564
- function insertChildReference(state2, parentId, childId) {
72565
- const parentIndex = getDirectoryIndex(state2, parentId);
72566
- const childNode = requireNode(state2, childId);
72567
- ensureChildIdByNameId(state2.snapshot.nodes, parentIndex).set(childNode.nameId, childId);
73009
+ function insertChildReference(state3, parentId, childId) {
73010
+ const parentIndex = getDirectoryIndex(state3, parentId);
73011
+ const childNode = requireNode(state3, childId);
73012
+ ensureChildIdByNameId(state3.snapshot.nodes, parentIndex).set(childNode.nameId, childId);
72568
73013
  applyChildAggregateDelta(parentIndex, childId, childNode.subtreeNodeCount, childNode.visibleSubtreeCount);
72569
- const insertIndex = findChildInsertIndex(state2, parentIndex, childId);
73014
+ const insertIndex = findChildInsertIndex(state3, parentIndex, childId);
72570
73015
  parentIndex.childIds.splice(insertIndex, 0, childId);
72571
73016
  updateChildPositionsFrom(parentIndex, insertIndex);
72572
- rebuildVisibleChildChunks(state2.snapshot.nodes, parentIndex);
72573
- }
72574
- function removeChildReference(state2, parentId, childId, childNameId) {
72575
- const parentIndex = getDirectoryIndex(state2, parentId);
72576
- const positions = ensureChildPositions(parentIndex);
72577
- const childIndex = positions.get(childId) ?? -1;
72578
- ensureChildIdByNameId(state2.snapshot.nodes, parentIndex).delete(childNameId);
72579
- positions.delete(childId);
72580
- const childNode = state2.snapshot.nodes[childId];
73017
+ rebuildVisibleChildChunks(state3.snapshot.nodes, parentIndex);
73018
+ }
73019
+ function removeChildReference(state3, parentId, childId, childNameId) {
73020
+ const parentIndex = getDirectoryIndex(state3, parentId);
73021
+ const positions2 = ensureChildPositions(parentIndex);
73022
+ const childIndex = positions2.get(childId) ?? -1;
73023
+ ensureChildIdByNameId(state3.snapshot.nodes, parentIndex).delete(childNameId);
73024
+ positions2.delete(childId);
73025
+ const childNode = state3.snapshot.nodes[childId];
72581
73026
  if (childNode != null) applyChildAggregateDelta(parentIndex, childId, -childNode.subtreeNodeCount, -childNode.visibleSubtreeCount);
72582
73027
  if (childIndex >= 0) {
72583
73028
  parentIndex.childIds.splice(childIndex, 1);
72584
73029
  updateChildPositionsFrom(parentIndex, childIndex);
72585
- rebuildVisibleChildChunks(state2.snapshot.nodes, parentIndex);
73030
+ rebuildVisibleChildChunks(state3.snapshot.nodes, parentIndex);
72586
73031
  }
72587
73032
  }
72588
- function compareSiblingNodes(state2, leftId, rightId) {
72589
- const sortOption = state2.snapshot.options.sort;
72590
- if (sortOption === "default") return compareSiblingNodesDefault(state2, leftId, rightId);
72591
- return sortOption(createCompareEntry2(state2, leftId), createCompareEntry2(state2, rightId));
73033
+ function compareSiblingNodes(state3, leftId, rightId) {
73034
+ const sortOption = state3.snapshot.options.sort;
73035
+ if (sortOption === "default") return compareSiblingNodesDefault(state3, leftId, rightId);
73036
+ return sortOption(createCompareEntry2(state3, leftId), createCompareEntry2(state3, rightId));
72592
73037
  }
72593
- function compareSiblingNodesDefault(state2, leftId, rightId) {
72594
- const leftNode = requireNode(state2, leftId);
72595
- const rightNode = requireNode(state2, rightId);
73038
+ function compareSiblingNodesDefault(state3, leftId, rightId) {
73039
+ const leftNode = requireNode(state3, leftId);
73040
+ const rightNode = requireNode(state3, rightId);
72596
73041
  const leftIsDirectory = isDirectoryNode(leftNode);
72597
73042
  if (leftIsDirectory !== isDirectoryNode(rightNode)) return leftIsDirectory ? -1 : 1;
72598
- const comparison = compareSegmentSortKeys(getSegmentSortKey(state2.snapshot.segmentTable, leftNode.nameId), getSegmentSortKey(state2.snapshot.segmentTable, rightNode.nameId));
73043
+ const comparison = compareSegmentSortKeys(getSegmentSortKey(state3.snapshot.segmentTable, leftNode.nameId), getSegmentSortKey(state3.snapshot.segmentTable, rightNode.nameId));
72599
73044
  if (comparison !== 0) return comparison;
72600
- const leftName = getSegmentValue(state2.snapshot.segmentTable, leftNode.nameId);
72601
- const rightName = getSegmentValue(state2.snapshot.segmentTable, rightNode.nameId);
73045
+ const leftName = getSegmentValue(state3.snapshot.segmentTable, leftNode.nameId);
73046
+ const rightName = getSegmentValue(state3.snapshot.segmentTable, rightNode.nameId);
72602
73047
  if (leftName !== rightName) return leftName < rightName ? -1 : 1;
72603
73048
  return leftId < rightId ? -1 : 1;
72604
73049
  }
72605
- function createCompareEntry2(state2, nodeId) {
72606
- const node = requireNode(state2, nodeId);
72607
- const path = materializeNodePath(state2, nodeId);
73050
+ function createCompareEntry2(state3, nodeId) {
73051
+ const node = requireNode(state3, nodeId);
73052
+ const path = materializeNodePath(state3, nodeId);
72608
73053
  const isDirectory = isDirectoryNode(node);
72609
73054
  const normalizedPath = isDirectory ? path.slice(0, -1) : path;
72610
73055
  return {
72611
- basename: getSegmentValue(state2.snapshot.segmentTable, node.nameId),
73056
+ basename: getSegmentValue(state3.snapshot.segmentTable, node.nameId),
72612
73057
  depth: getNodeDepth(node),
72613
73058
  isDirectory,
72614
73059
  path,
72615
73060
  segments: normalizedPath.length === 0 ? [] : normalizedPath.split("/")
72616
73061
  };
72617
73062
  }
72618
- function resolveMoveTarget(state2, sourceNodeId, toPath) {
72619
- const sourceNode = requireNode(state2, sourceNodeId);
72620
- const existingDestinationId = findNodeId(state2, toPath);
73063
+ function resolveMoveTarget(state3, sourceNodeId, toPath) {
73064
+ const sourceNode = requireNode(state3, sourceNodeId);
73065
+ const existingDestinationId = findNodeId(state3, toPath);
72621
73066
  if (existingDestinationId != null) {
72622
- const existingDestination = requireNode(state2, existingDestinationId);
73067
+ const existingDestination = requireNode(state3, existingDestinationId);
72623
73068
  if (isDirectoryNode(existingDestination)) return {
72624
- basename: getSegmentValue(state2.snapshot.segmentTable, sourceNode.nameId),
73069
+ basename: getSegmentValue(state3.snapshot.segmentTable, sourceNode.nameId),
72625
73070
  existingNodeId: null,
72626
73071
  parentId: existingDestinationId
72627
73072
  };
@@ -72635,7 +73080,7 @@ function resolveMoveTarget(state2, sourceNodeId, toPath) {
72635
73080
  const destinationLookup = parseLookupPath(toPath);
72636
73081
  const basename3 = destinationLookup.segments[destinationLookup.segments.length - 1] ?? "";
72637
73082
  const parentSegments = destinationLookup.segments.slice(0, -1);
72638
- const parentId = parentSegments.length === 0 ? state2.snapshot.rootId : findNodeIdBySegments(state2, parentSegments, true);
73083
+ const parentId = parentSegments.length === 0 ? state3.snapshot.rootId : findNodeIdBySegments(state3, parentSegments, true);
72639
73084
  if (parentId == null) throw new Error(`Destination parent does not exist: "${toPath}"`);
72640
73085
  return {
72641
73086
  basename: basename3,
@@ -72643,21 +73088,21 @@ function resolveMoveTarget(state2, sourceNodeId, toPath) {
72643
73088
  parentId
72644
73089
  };
72645
73090
  }
72646
- function handleMoveCollision(state2, collisionNodeId, strategy, sourceKind) {
73091
+ function handleMoveCollision(state3, collisionNodeId, strategy, sourceKind) {
72647
73092
  if (strategy === "skip") return "skip";
72648
- if (strategy === "error") throw new Error(`Destination already exists: "${materializeNodePath(state2, collisionNodeId)}"`);
72649
- const collisionNode = requireNode(state2, collisionNodeId);
73093
+ if (strategy === "error") throw new Error(`Destination already exists: "${materializeNodePath(state3, collisionNodeId)}"`);
73094
+ const collisionNode = requireNode(state3, collisionNodeId);
72650
73095
  if (getNodeKind(collisionNode) !== sourceKind) throw new Error("replace collision requires the same source and destination kinds");
72651
- if (isDirectoryNode(collisionNode) && getDirectoryIndex(state2, collisionNodeId).childIds.length > 0) throw new Error("replace collision does not support non-empty directories");
73096
+ if (isDirectoryNode(collisionNode) && getDirectoryIndex(state3, collisionNodeId).childIds.length > 0) throw new Error("replace collision does not support non-empty directories");
72652
73097
  const collisionParentId = collisionNode.parentId;
72653
73098
  const collisionNameId = collisionNode.nameId;
72654
- removeSubtree(state2, collisionNodeId);
72655
- removeChildReference(state2, collisionParentId, collisionNodeId, collisionNameId);
72656
- promoteEmptyAncestorsToExplicit(state2, collisionParentId);
72657
- recomputeCountsUpwardFrom(state2, collisionParentId);
73099
+ removeSubtree(state3, collisionNodeId);
73100
+ removeChildReference(state3, collisionParentId, collisionNodeId, collisionNameId);
73101
+ promoteEmptyAncestorsToExplicit(state3, collisionParentId);
73102
+ recomputeCountsUpwardFrom(state3, collisionParentId);
72658
73103
  return "handled";
72659
73104
  }
72660
- function removeSubtree(state2, nodeId) {
73105
+ function removeSubtree(state3, nodeId) {
72661
73106
  const removedNodeIds = [];
72662
73107
  const stack = [{
72663
73108
  nodeId,
@@ -72666,15 +73111,15 @@ function removeSubtree(state2, nodeId) {
72666
73111
  while (stack.length > 0) {
72667
73112
  const frame = stack.pop();
72668
73113
  if (frame == null) break;
72669
- const node = requireNode(state2, frame.nodeId);
73114
+ const node = requireNode(state3, frame.nodeId);
72670
73115
  if (frame.visitedChildren || !isDirectoryNode(node)) {
72671
- if (isDirectoryNode(node)) state2.snapshot.directories.delete(frame.nodeId);
73116
+ if (isDirectoryNode(node)) state3.snapshot.directories.delete(frame.nodeId);
72672
73117
  addNodeFlag(node, 4);
72673
- state2.pathCacheByNodeId.delete(frame.nodeId);
72674
- if (state2.collapsedDirectoryIds.delete(frame.nodeId)) state2.hasCollapsedDirectoryOverrides = state2.collapsedDirectoryIds.size > 0;
72675
- state2.expandedDirectoryIds.delete(frame.nodeId);
72676
- clearDirectoryLoadInfo(state2, frame.nodeId);
72677
- state2.activeNodeCount--;
73118
+ state3.pathCacheByNodeId.delete(frame.nodeId);
73119
+ if (state3.collapsedDirectoryIds.delete(frame.nodeId)) state3.hasCollapsedDirectoryOverrides = state3.collapsedDirectoryIds.size > 0;
73120
+ state3.expandedDirectoryIds.delete(frame.nodeId);
73121
+ clearDirectoryLoadInfo(state3, frame.nodeId);
73122
+ state3.activeNodeCount--;
72678
73123
  removedNodeIds.push(frame.nodeId);
72679
73124
  continue;
72680
73125
  }
@@ -72682,7 +73127,7 @@ function removeSubtree(state2, nodeId) {
72682
73127
  nodeId: frame.nodeId,
72683
73128
  visitedChildren: true
72684
73129
  });
72685
- const directoryIndex = getDirectoryIndex(state2, frame.nodeId);
73130
+ const directoryIndex = getDirectoryIndex(state3, frame.nodeId);
72686
73131
  for (let childIndex = directoryIndex.childIds.length - 1; childIndex >= 0; childIndex--) {
72687
73132
  const childId = directoryIndex.childIds[childIndex];
72688
73133
  if (childId != null) stack.push({
@@ -72693,38 +73138,38 @@ function removeSubtree(state2, nodeId) {
72693
73138
  }
72694
73139
  return removedNodeIds;
72695
73140
  }
72696
- function promoteEmptyAncestorsToExplicit(state2, startDirectoryId) {
73141
+ function promoteEmptyAncestorsToExplicit(state3, startDirectoryId) {
72697
73142
  let currentDirectoryId = startDirectoryId;
72698
73143
  while (currentDirectoryId != null) {
72699
- const currentNode = requireNode(state2, currentDirectoryId);
73144
+ const currentNode = requireNode(state3, currentDirectoryId);
72700
73145
  if (!isDirectoryNode(currentNode) || hasNodeFlag(currentNode, 2)) return;
72701
- if (getDirectoryIndex(state2, currentDirectoryId).childIds.length > 0) return;
73146
+ if (getDirectoryIndex(state3, currentDirectoryId).childIds.length > 0) return;
72702
73147
  addNodeFlag(currentNode, 1);
72703
73148
  currentDirectoryId = currentNode.parentId === currentDirectoryId ? null : currentNode.parentId;
72704
73149
  }
72705
73150
  }
72706
- function findDeepestExistingDirectoryId(state2, segments) {
72707
- let currentDirectoryId = state2.snapshot.rootId;
73151
+ function findDeepestExistingDirectoryId(state3, segments) {
73152
+ let currentDirectoryId = state3.snapshot.rootId;
72708
73153
  for (const segment2 of segments) {
72709
- const segmentId = state2.snapshot.segmentTable.idByValue.get(segment2);
73154
+ const segmentId = state3.snapshot.segmentTable.idByValue.get(segment2);
72710
73155
  if (segmentId == null) break;
72711
- const nextNodeId = ensureChildIdByNameId(state2.snapshot.nodes, getDirectoryIndex(state2, currentDirectoryId)).get(segmentId);
73156
+ const nextNodeId = ensureChildIdByNameId(state3.snapshot.nodes, getDirectoryIndex(state3, currentDirectoryId)).get(segmentId);
72712
73157
  if (nextNodeId == null) break;
72713
- if (!isDirectoryNode(requireNode(state2, nextNodeId))) break;
73158
+ if (!isDirectoryNode(requireNode(state3, nextNodeId))) break;
72714
73159
  currentDirectoryId = nextNodeId;
72715
73160
  }
72716
73161
  return currentDirectoryId;
72717
73162
  }
72718
- function getCollapsedProjectionSignature(state2, startDirectoryId) {
72719
- const collapsedAncestorId = findNearestCollapsedAncestor(state2, startDirectoryId);
73163
+ function getCollapsedProjectionSignature(state3, startDirectoryId) {
73164
+ const collapsedAncestorId = findNearestCollapsedAncestor(state3, startDirectoryId);
72720
73165
  if (collapsedAncestorId == null) return null;
72721
- const terminalDirectoryId = getFlattenedTerminalDirectoryId(state2, collapsedAncestorId);
72722
- const terminalNode = requireNode(state2, terminalDirectoryId);
72723
- const flattenedSegmentPaths = collapsedAncestorId === terminalDirectoryId ? null : collectFlattenedDirectoryChainIds(state2, collapsedAncestorId).map((nodeId) => materializeNodePath(state2, nodeId));
73166
+ const terminalDirectoryId = getFlattenedTerminalDirectoryId(state3, collapsedAncestorId);
73167
+ const terminalNode = requireNode(state3, terminalDirectoryId);
73168
+ const flattenedSegmentPaths = collapsedAncestorId === terminalDirectoryId ? null : collectFlattenedDirectoryChainIds(state3, collapsedAncestorId).map((nodeId) => materializeNodePath(state3, nodeId));
72724
73169
  return JSON.stringify({
72725
73170
  flattenedSegmentPaths,
72726
- hasChildren: getDirectoryIndex(state2, terminalDirectoryId).childIds.length > 0,
72727
- path: materializeNodePath(state2, terminalDirectoryId),
73171
+ hasChildren: getDirectoryIndex(state3, terminalDirectoryId).childIds.length > 0,
73172
+ path: materializeNodePath(state3, terminalDirectoryId),
72728
73173
  terminalKind: getNodeKind(terminalNode)
72729
73174
  });
72730
73175
  }
@@ -72739,67 +73184,67 @@ function didAnyProjectionChange(previousProjectionSignatures, nextProjectionSign
72739
73184
  }
72740
73185
  return false;
72741
73186
  }
72742
- function findNearestCollapsedAncestor(state2, startDirectoryId) {
73187
+ function findNearestCollapsedAncestor(state3, startDirectoryId) {
72743
73188
  let currentDirectoryId = startDirectoryId;
72744
73189
  while (currentDirectoryId != null) {
72745
- const currentNode = requireNode(state2, currentDirectoryId);
73190
+ const currentNode = requireNode(state3, currentDirectoryId);
72746
73191
  if (!isDirectoryNode(currentNode) || hasNodeFlag(currentNode, 2)) return null;
72747
- if (!isDirectoryExpanded(state2, currentDirectoryId, currentNode)) return currentDirectoryId;
73192
+ if (!isDirectoryExpanded(state3, currentDirectoryId, currentNode)) return currentDirectoryId;
72748
73193
  currentDirectoryId = currentNode.parentId;
72749
73194
  }
72750
73195
  return null;
72751
73196
  }
72752
- function recomputeDepths(state2, nodeId) {
72753
- const node = requireNode(state2, nodeId);
72754
- setNodeDepth(node, (nodeId === state2.snapshot.rootId ? -1 : getNodeDepth(requireNode(state2, node.parentId))) + 1);
73197
+ function recomputeDepths(state3, nodeId) {
73198
+ const node = requireNode(state3, nodeId);
73199
+ setNodeDepth(node, (nodeId === state3.snapshot.rootId ? -1 : getNodeDepth(requireNode(state3, node.parentId))) + 1);
72755
73200
  if (!isDirectoryNode(node)) return;
72756
- const directoryIndex = getDirectoryIndex(state2, nodeId);
72757
- for (const childId of directoryIndex.childIds) recomputeDepths(state2, childId);
73201
+ const directoryIndex = getDirectoryIndex(state3, nodeId);
73202
+ for (const childId of directoryIndex.childIds) recomputeDepths(state3, childId);
72758
73203
  }
72759
- function isAncestor2(state2, ancestorNodeId, nodeId) {
73204
+ function isAncestor2(state3, ancestorNodeId, nodeId) {
72760
73205
  let currentNodeId = nodeId;
72761
73206
  while (currentNodeId != null) {
72762
73207
  if (currentNodeId === ancestorNodeId) return true;
72763
- const currentNode = requireNode(state2, currentNodeId);
72764
- if (currentNodeId === state2.snapshot.rootId) return false;
73208
+ const currentNode = requireNode(state3, currentNodeId);
73209
+ if (currentNodeId === state3.snapshot.rootId) return false;
72765
73210
  currentNodeId = currentNode.parentId;
72766
73211
  }
72767
73212
  return false;
72768
73213
  }
72769
- function recomputeNodeCounts(state2, nodeId, currentNode = requireNode(state2, nodeId), rebuildChildAggregates = false) {
72770
- const instrumentation = state2.instrumentation;
73214
+ function recomputeNodeCounts(state3, nodeId, currentNode = requireNode(state3, nodeId), rebuildChildAggregates = false) {
73215
+ const instrumentation = state3.instrumentation;
72771
73216
  if (instrumentation == null) {
72772
- recomputeNodeCountsNow(state2, nodeId, currentNode, rebuildChildAggregates);
73217
+ recomputeNodeCountsNow(state3, nodeId, currentNode, rebuildChildAggregates);
72773
73218
  return;
72774
73219
  }
72775
- withBenchmarkPhase(instrumentation, "store.recomputeNodeCounts", () => recomputeNodeCountsNow(state2, nodeId, currentNode, rebuildChildAggregates));
73220
+ withBenchmarkPhase(instrumentation, "store.recomputeNodeCounts", () => recomputeNodeCountsNow(state3, nodeId, currentNode, rebuildChildAggregates));
72776
73221
  }
72777
- function recomputeCountsUpwardFromNow(state2, startNodeId) {
73222
+ function recomputeCountsUpwardFromNow(state3, startNodeId) {
72778
73223
  let currentNodeId = startNodeId;
72779
73224
  while (currentNodeId != null) {
72780
- const currentNode = requireNode(state2, currentNodeId);
73225
+ const currentNode = requireNode(state3, currentNodeId);
72781
73226
  const previousSubtreeNodeCount = currentNode.subtreeNodeCount;
72782
73227
  const previousVisibleSubtreeCount = currentNode.visibleSubtreeCount;
72783
- recomputeNodeCounts(state2, currentNodeId, currentNode);
72784
- if (currentNodeId === state2.snapshot.rootId) return;
73228
+ recomputeNodeCounts(state3, currentNodeId, currentNode);
73229
+ if (currentNodeId === state3.snapshot.rootId) return;
72785
73230
  const subtreeNodeDelta = currentNode.subtreeNodeCount - previousSubtreeNodeCount;
72786
73231
  const visibleSubtreeDelta = currentNode.visibleSubtreeCount - previousVisibleSubtreeCount;
72787
73232
  const parentId = currentNode.parentId;
72788
- if (subtreeNodeDelta !== 0 || visibleSubtreeDelta !== 0) applyChildAggregateDelta(getDirectoryIndex(state2, parentId), currentNodeId, subtreeNodeDelta, visibleSubtreeDelta);
73233
+ if (subtreeNodeDelta !== 0 || visibleSubtreeDelta !== 0) applyChildAggregateDelta(getDirectoryIndex(state3, parentId), currentNodeId, subtreeNodeDelta, visibleSubtreeDelta);
72789
73234
  currentNodeId = parentId;
72790
73235
  }
72791
73236
  }
72792
- function recomputeNodeCountsNow(state2, nodeId, currentNode, rebuildChildAggregates) {
73237
+ function recomputeNodeCountsNow(state3, nodeId, currentNode, rebuildChildAggregates) {
72793
73238
  if (!isDirectoryNode(currentNode)) {
72794
73239
  currentNode.subtreeNodeCount = 1;
72795
73240
  currentNode.visibleSubtreeCount = 1;
72796
73241
  return;
72797
73242
  }
72798
- const currentIndex = getDirectoryIndex(state2, nodeId);
73243
+ const currentIndex = getDirectoryIndex(state3, nodeId);
72799
73244
  if (rebuildChildAggregates) {
72800
- const instrumentation = state2.instrumentation;
72801
- if (instrumentation == null) rebuildDirectoryChildAggregates(state2.snapshot.nodes, currentIndex);
72802
- else withBenchmarkPhase(instrumentation, "store.recomputeNodeCounts.rebuildChildAggregates", () => rebuildDirectoryChildAggregates(state2.snapshot.nodes, currentIndex));
73245
+ const instrumentation = state3.instrumentation;
73246
+ if (instrumentation == null) rebuildDirectoryChildAggregates(state3.snapshot.nodes, currentIndex);
73247
+ else withBenchmarkPhase(instrumentation, "store.recomputeNodeCounts.rebuildChildAggregates", () => rebuildDirectoryChildAggregates(state3.snapshot.nodes, currentIndex));
72803
73248
  }
72804
73249
  const subtreeNodeCount = 1 + currentIndex.totalChildSubtreeNodeCount;
72805
73250
  const visibleChildCount = currentIndex.totalChildVisibleSubtreeCount;
@@ -72808,10 +73253,10 @@ function recomputeNodeCountsNow(state2, nodeId, currentNode, rebuildChildAggrega
72808
73253
  currentNode.visibleSubtreeCount = visibleChildCount;
72809
73254
  return;
72810
73255
  }
72811
- currentNode.visibleSubtreeCount = getFlattenedChildDirectoryId(state2, nodeId) != null ? visibleChildCount : isDirectoryExpanded(state2, nodeId, currentNode) ? 1 + visibleChildCount : 1;
73256
+ currentNode.visibleSubtreeCount = getFlattenedChildDirectoryId(state3, nodeId) != null ? visibleChildCount : isDirectoryExpanded(state3, nodeId, currentNode) ? 1 + visibleChildCount : 1;
72812
73257
  }
72813
- function buildPathPreview(state2, parentId, basename3) {
72814
- const parentPath = materializeNodePath(state2, parentId);
73258
+ function buildPathPreview(state3, parentId, basename3) {
73259
+ const parentPath = materializeNodePath(state3, parentId);
72815
73260
  return parentPath.length === 0 ? basename3 : `${parentPath}${basename3}`;
72816
73261
  }
72817
73262
 
@@ -72819,16 +73264,16 @@ function buildPathPreview(state2, parentId, basename3) {
72819
73264
  function isLiveNode(node) {
72820
73265
  return node != null && !hasNodeFlag(node, 4);
72821
73266
  }
72822
- function isLiveDirectoryNode(state2, nodeId) {
72823
- const node = state2.snapshot.nodes[nodeId];
73267
+ function isLiveDirectoryNode(state3, nodeId) {
73268
+ const node = state3.snapshot.nodes[nodeId];
72824
73269
  if (!isLiveNode(node) || !isDirectoryNode(node) || hasNodeFlag(node, 2)) return null;
72825
73270
  return node;
72826
73271
  }
72827
- function countCachedPathEntries(state2) {
73272
+ function countCachedPathEntries(state3) {
72828
73273
  let cachedPathEntryCount = 0;
72829
- for (const [nodeId, cachedEntry] of state2.pathCacheByNodeId) {
72830
- if (cachedEntry.version !== state2.pathCacheVersion) continue;
72831
- if (!isLiveNode(state2.snapshot.nodes[nodeId])) continue;
73274
+ for (const [nodeId, cachedEntry] of state3.pathCacheByNodeId) {
73275
+ if (cachedEntry.version !== state3.pathCacheVersion) continue;
73276
+ if (!isLiveNode(state3.snapshot.nodes[nodeId])) continue;
72832
73277
  cachedPathEntryCount += 1;
72833
73278
  }
72834
73279
  return cachedPathEntryCount;
@@ -72836,13 +73281,13 @@ function countCachedPathEntries(state2) {
72836
73281
  function countSegmentEntries(segmentTable) {
72837
73282
  return Math.max(0, segmentTable.valueById.length - 1);
72838
73283
  }
72839
- function createCleanupMetricSnapshot(state2) {
73284
+ function createCleanupMetricSnapshot(state3) {
72840
73285
  return {
72841
- activeNodeCount: state2.activeNodeCount,
72842
- cachedPathEntryCount: countCachedPathEntries(state2),
72843
- loadInfoEntryCount: state2.directoryLoadInfoById.size,
72844
- segmentCount: countSegmentEntries(state2.snapshot.segmentTable),
72845
- totalNodeSlotCount: Math.max(0, state2.snapshot.nodes.length - 1)
73286
+ activeNodeCount: state3.activeNodeCount,
73287
+ cachedPathEntryCount: countCachedPathEntries(state3),
73288
+ loadInfoEntryCount: state3.directoryLoadInfoById.size,
73289
+ segmentCount: countSegmentEntries(state3.snapshot.segmentTable),
73290
+ totalNodeSlotCount: Math.max(0, state3.snapshot.nodes.length - 1)
72846
73291
  };
72847
73292
  }
72848
73293
  function createCleanupResult(mode, idsPreserved, before, after) {
@@ -72865,20 +73310,20 @@ function createCleanupResult(mode, idsPreserved, before, after) {
72865
73310
  totalNodeSlotCountBefore: before.totalNodeSlotCount
72866
73311
  };
72867
73312
  }
72868
- function collectExpansionOverridePaths(state2) {
73313
+ function collectExpansionOverridePaths(state3) {
72869
73314
  const collapsedPaths = [];
72870
73315
  const expandedPaths = [];
72871
- for (const nodeId of state2.collapsedDirectoryIds) if (isLiveDirectoryNode(state2, nodeId) != null) collapsedPaths.push(materializeNodePath(state2, nodeId));
72872
- for (const nodeId of state2.expandedDirectoryIds) if (isLiveDirectoryNode(state2, nodeId) != null) expandedPaths.push(materializeNodePath(state2, nodeId));
73316
+ for (const nodeId of state3.collapsedDirectoryIds) if (isLiveDirectoryNode(state3, nodeId) != null) collapsedPaths.push(materializeNodePath(state3, nodeId));
73317
+ for (const nodeId of state3.expandedDirectoryIds) if (isLiveDirectoryNode(state3, nodeId) != null) expandedPaths.push(materializeNodePath(state3, nodeId));
72873
73318
  return {
72874
73319
  collapsedPaths,
72875
73320
  expandedPaths
72876
73321
  };
72877
73322
  }
72878
- function collectDirectoryLoadInfos(state2) {
73323
+ function collectDirectoryLoadInfos(state3) {
72879
73324
  const retainedInfos = [];
72880
- for (const [nodeId, info] of state2.directoryLoadInfoById) {
72881
- if (isLiveDirectoryNode(state2, nodeId) == null || getDirectoryLoadState(state2, nodeId) === "loaded") continue;
73325
+ for (const [nodeId, info] of state3.directoryLoadInfoById) {
73326
+ if (isLiveDirectoryNode(state3, nodeId) == null || getDirectoryLoadState(state3, nodeId) === "loaded") continue;
72882
73327
  retainedInfos.push({
72883
73328
  info: {
72884
73329
  activeAttemptId: null,
@@ -72886,33 +73331,33 @@ function collectDirectoryLoadInfos(state2) {
72886
73331
  nextAttemptId: info.nextAttemptId,
72887
73332
  state: info.state
72888
73333
  },
72889
- path: materializeNodePath(state2, nodeId)
73334
+ path: materializeNodePath(state3, nodeId)
72890
73335
  });
72891
73336
  }
72892
73337
  return retainedInfos;
72893
73338
  }
72894
- function restoreExpansionOverridePaths(state2, persistedExpansionState) {
72895
- state2.collapsedDirectoryIds.clear();
72896
- state2.hasCollapsedDirectoryOverrides = false;
72897
- state2.expandedDirectoryIds.clear();
73339
+ function restoreExpansionOverridePaths(state3, persistedExpansionState) {
73340
+ state3.collapsedDirectoryIds.clear();
73341
+ state3.hasCollapsedDirectoryOverrides = false;
73342
+ state3.expandedDirectoryIds.clear();
72898
73343
  for (const path of persistedExpansionState.expandedPaths) {
72899
- const nodeId = findNodeId(state2, path);
73344
+ const nodeId = findNodeId(state3, path);
72900
73345
  if (nodeId == null) continue;
72901
- setDirectoryExpanded(state2, nodeId, true, requireNode(state2, nodeId));
73346
+ setDirectoryExpanded(state3, nodeId, true, requireNode(state3, nodeId));
72902
73347
  }
72903
73348
  for (const path of persistedExpansionState.collapsedPaths) {
72904
- const nodeId = findNodeId(state2, path);
73349
+ const nodeId = findNodeId(state3, path);
72905
73350
  if (nodeId == null) continue;
72906
- setDirectoryExpanded(state2, nodeId, false, requireNode(state2, nodeId));
73351
+ setDirectoryExpanded(state3, nodeId, false, requireNode(state3, nodeId));
72907
73352
  }
72908
73353
  }
72909
- function restoreDirectoryLoadInfos(state2, persistedLoadInfos) {
72910
- state2.directoryLoadInfoById.clear();
73354
+ function restoreDirectoryLoadInfos(state3, persistedLoadInfos) {
73355
+ state3.directoryLoadInfoById.clear();
72911
73356
  for (const retainedInfo of persistedLoadInfos) {
72912
- const nodeId = findNodeId(state2, retainedInfo.path);
73357
+ const nodeId = findNodeId(state3, retainedInfo.path);
72913
73358
  if (nodeId == null) continue;
72914
- if (isLiveDirectoryNode(state2, nodeId) == null) continue;
72915
- state2.directoryLoadInfoById.set(nodeId, {
73359
+ if (isLiveDirectoryNode(state3, nodeId) == null) continue;
73360
+ state3.directoryLoadInfoById.set(nodeId, {
72916
73361
  activeAttemptId: null,
72917
73362
  errorMessage: retainedInfo.info.errorMessage,
72918
73363
  nextAttemptId: retainedInfo.info.nextAttemptId,
@@ -72920,18 +73365,18 @@ function restoreDirectoryLoadInfos(state2, persistedLoadInfos) {
72920
73365
  });
72921
73366
  }
72922
73367
  }
72923
- function clearPathCaches(state2) {
72924
- state2.pathCacheVersion += 1;
72925
- state2.pathCacheByNodeId.clear();
72926
- state2.pathCacheByNodeId.set(state2.snapshot.rootId, {
73368
+ function clearPathCaches(state3) {
73369
+ state3.pathCacheVersion += 1;
73370
+ state3.pathCacheByNodeId.clear();
73371
+ state3.pathCacheByNodeId.set(state3.snapshot.rootId, {
72927
73372
  path: "",
72928
- version: state2.pathCacheVersion
73373
+ version: state3.pathCacheVersion
72929
73374
  });
72930
73375
  }
72931
- function rebuildSegmentTablePreservingNodeIds(state2) {
72932
- const previousSegmentTable = state2.snapshot.segmentTable;
73376
+ function rebuildSegmentTablePreservingNodeIds(state3) {
73377
+ const previousSegmentTable = state3.snapshot.segmentTable;
72933
73378
  const nextSegmentTable = createSegmentTable();
72934
- for (const node of state2.snapshot.nodes) {
73379
+ for (const node of state3.snapshot.nodes) {
72935
73380
  if (!isLiveNode(node)) continue;
72936
73381
  if (hasNodeFlag(node, 2)) {
72937
73382
  node.nameId = 0;
@@ -72939,75 +73384,75 @@ function rebuildSegmentTablePreservingNodeIds(state2) {
72939
73384
  }
72940
73385
  node.nameId = internSegment(nextSegmentTable, getSegmentValue(previousSegmentTable, node.nameId));
72941
73386
  }
72942
- state2.snapshot.segmentTable = nextSegmentTable;
73387
+ state3.snapshot.segmentTable = nextSegmentTable;
72943
73388
  }
72944
- function rebuildDirectoryIndexes(state2) {
72945
- for (const [directoryId, directoryIndex] of state2.snapshot.directories) {
72946
- const directoryNode = state2.snapshot.nodes[directoryId];
73389
+ function rebuildDirectoryIndexes(state3) {
73390
+ for (const [directoryId, directoryIndex] of state3.snapshot.directories) {
73391
+ const directoryNode = state3.snapshot.nodes[directoryId];
72947
73392
  if (!isLiveNode(directoryNode) || !isDirectoryNode(directoryNode)) {
72948
- state2.snapshot.directories.delete(directoryId);
73393
+ state3.snapshot.directories.delete(directoryId);
72949
73394
  continue;
72950
73395
  }
72951
73396
  const liveChildIds = directoryIndex.childIds.filter((childId) => {
72952
- const childNode = state2.snapshot.nodes[childId];
73397
+ const childNode = state3.snapshot.nodes[childId];
72953
73398
  return isLiveNode(childNode) && childNode.parentId === directoryId;
72954
73399
  });
72955
73400
  directoryIndex.childIds = liveChildIds;
72956
- directoryIndex.childIdByNameId = new Map(liveChildIds.map((childId) => [requireNode(state2, childId).nameId, childId]));
73401
+ directoryIndex.childIdByNameId = new Map(liveChildIds.map((childId) => [requireNode(state3, childId).nameId, childId]));
72957
73402
  directoryIndex.childPositionById = new Map(liveChildIds.map((childId, childIndex) => [childId, childIndex]));
72958
- rebuildDirectoryChildAggregates(state2.snapshot.nodes, directoryIndex);
73403
+ rebuildDirectoryChildAggregates(state3.snapshot.nodes, directoryIndex);
72959
73404
  }
72960
73405
  }
72961
- function trimTrailingRemovedNodeSlots(state2) {
72962
- let lastNodeIndex = state2.snapshot.nodes.length - 1;
72963
- while (lastNodeIndex > state2.snapshot.rootId) {
72964
- const node = state2.snapshot.nodes[lastNodeIndex];
73406
+ function trimTrailingRemovedNodeSlots(state3) {
73407
+ let lastNodeIndex = state3.snapshot.nodes.length - 1;
73408
+ while (lastNodeIndex > state3.snapshot.rootId) {
73409
+ const node = state3.snapshot.nodes[lastNodeIndex];
72965
73410
  if (isLiveNode(node)) break;
72966
73411
  lastNodeIndex -= 1;
72967
73412
  }
72968
- state2.snapshot.nodes.length = lastNodeIndex + 1;
72969
- }
72970
- function runStableCleanup(state2) {
72971
- const persistedExpansionState = collectExpansionOverridePaths(state2);
72972
- const persistedLoadInfos = collectDirectoryLoadInfos(state2);
72973
- withBenchmarkPhase(state2.instrumentation, "store.cleanup.stable.clearPathCaches", () => clearPathCaches(state2));
72974
- withBenchmarkPhase(state2.instrumentation, "store.cleanup.stable.rebuildSegmentTable", () => rebuildSegmentTablePreservingNodeIds(state2));
72975
- withBenchmarkPhase(state2.instrumentation, "store.cleanup.stable.rebuildDirectoryIndexes", () => rebuildDirectoryIndexes(state2));
72976
- withBenchmarkPhase(state2.instrumentation, "store.cleanup.stable.trimTrailingRemovedNodeSlots", () => trimTrailingRemovedNodeSlots(state2));
72977
- withBenchmarkPhase(state2.instrumentation, "store.cleanup.stable.restoreExpansionOverrides", () => restoreExpansionOverridePaths(state2, persistedExpansionState));
72978
- withBenchmarkPhase(state2.instrumentation, "store.cleanup.stable.restoreDirectoryLoadInfos", () => restoreDirectoryLoadInfos(state2, persistedLoadInfos));
72979
- withBenchmarkPhase(state2.instrumentation, "store.cleanup.stable.recomputeCounts", () => recomputeCountsRecursive(state2, state2.snapshot.rootId));
72980
- }
72981
- function runAggressiveCleanup(state2) {
72982
- const persistedExpansionState = collectExpansionOverridePaths(state2);
72983
- const persistedLoadInfos = collectDirectoryLoadInfos(state2);
72984
- const canonicalPaths = withBenchmarkPhase(state2.instrumentation, "store.cleanup.aggressive.listPaths", () => listPaths(state2));
72985
- const builderOptions = attachBenchmarkInstrumentation({ ...state2.snapshot.options }, state2.instrumentation);
72986
- const rebuiltSnapshot = withBenchmarkPhase(state2.instrumentation, "store.cleanup.aggressive.rebuildSnapshot", () => {
73413
+ state3.snapshot.nodes.length = lastNodeIndex + 1;
73414
+ }
73415
+ function runStableCleanup(state3) {
73416
+ const persistedExpansionState = collectExpansionOverridePaths(state3);
73417
+ const persistedLoadInfos = collectDirectoryLoadInfos(state3);
73418
+ withBenchmarkPhase(state3.instrumentation, "store.cleanup.stable.clearPathCaches", () => clearPathCaches(state3));
73419
+ withBenchmarkPhase(state3.instrumentation, "store.cleanup.stable.rebuildSegmentTable", () => rebuildSegmentTablePreservingNodeIds(state3));
73420
+ withBenchmarkPhase(state3.instrumentation, "store.cleanup.stable.rebuildDirectoryIndexes", () => rebuildDirectoryIndexes(state3));
73421
+ withBenchmarkPhase(state3.instrumentation, "store.cleanup.stable.trimTrailingRemovedNodeSlots", () => trimTrailingRemovedNodeSlots(state3));
73422
+ withBenchmarkPhase(state3.instrumentation, "store.cleanup.stable.restoreExpansionOverrides", () => restoreExpansionOverridePaths(state3, persistedExpansionState));
73423
+ withBenchmarkPhase(state3.instrumentation, "store.cleanup.stable.restoreDirectoryLoadInfos", () => restoreDirectoryLoadInfos(state3, persistedLoadInfos));
73424
+ withBenchmarkPhase(state3.instrumentation, "store.cleanup.stable.recomputeCounts", () => recomputeCountsRecursive(state3, state3.snapshot.rootId));
73425
+ }
73426
+ function runAggressiveCleanup(state3) {
73427
+ const persistedExpansionState = collectExpansionOverridePaths(state3);
73428
+ const persistedLoadInfos = collectDirectoryLoadInfos(state3);
73429
+ const canonicalPaths = withBenchmarkPhase(state3.instrumentation, "store.cleanup.aggressive.listPaths", () => listPaths(state3));
73430
+ const builderOptions = attachBenchmarkInstrumentation({ ...state3.snapshot.options }, state3.instrumentation);
73431
+ const rebuiltSnapshot = withBenchmarkPhase(state3.instrumentation, "store.cleanup.aggressive.rebuildSnapshot", () => {
72987
73432
  const builder = new PathStoreBuilder(builderOptions);
72988
73433
  builder.appendPaths(canonicalPaths);
72989
73434
  return builder.finish();
72990
73435
  });
72991
- state2.snapshot = rebuiltSnapshot;
72992
- state2.activeNodeCount = rebuiltSnapshot.nodes.length - 1;
72993
- state2.pathCacheByNodeId = /* @__PURE__ */ new Map([[rebuiltSnapshot.rootId, {
73436
+ state3.snapshot = rebuiltSnapshot;
73437
+ state3.activeNodeCount = rebuiltSnapshot.nodes.length - 1;
73438
+ state3.pathCacheByNodeId = /* @__PURE__ */ new Map([[rebuiltSnapshot.rootId, {
72994
73439
  path: "",
72995
73440
  version: 0
72996
73441
  }]]);
72997
- state2.pathCacheVersion = 0;
72998
- withBenchmarkPhase(state2.instrumentation, "store.cleanup.aggressive.restoreExpansionOverrides", () => restoreExpansionOverridePaths(state2, persistedExpansionState));
72999
- withBenchmarkPhase(state2.instrumentation, "store.cleanup.aggressive.restoreDirectoryLoadInfos", () => restoreDirectoryLoadInfos(state2, persistedLoadInfos));
73000
- withBenchmarkPhase(state2.instrumentation, "store.cleanup.aggressive.recomputeCounts", () => recomputeCountsRecursive(state2, state2.snapshot.rootId));
73442
+ state3.pathCacheVersion = 0;
73443
+ withBenchmarkPhase(state3.instrumentation, "store.cleanup.aggressive.restoreExpansionOverrides", () => restoreExpansionOverridePaths(state3, persistedExpansionState));
73444
+ withBenchmarkPhase(state3.instrumentation, "store.cleanup.aggressive.restoreDirectoryLoadInfos", () => restoreDirectoryLoadInfos(state3, persistedLoadInfos));
73445
+ withBenchmarkPhase(state3.instrumentation, "store.cleanup.aggressive.recomputeCounts", () => recomputeCountsRecursive(state3, state3.snapshot.rootId));
73001
73446
  }
73002
- function hasActiveCleanupBlockingLoads(state2) {
73003
- for (const loadInfo of state2.directoryLoadInfoById.values()) if (loadInfo.state === "loading" && loadInfo.activeAttemptId != null) return true;
73447
+ function hasActiveCleanupBlockingLoads(state3) {
73448
+ for (const loadInfo of state3.directoryLoadInfoById.values()) if (loadInfo.state === "loading" && loadInfo.activeAttemptId != null) return true;
73004
73449
  return false;
73005
73450
  }
73006
- function cleanupPathStoreState(state2, mode) {
73007
- const before = createCleanupMetricSnapshot(state2);
73008
- if (mode === "stable") withBenchmarkPhase(state2.instrumentation, "store.cleanup.stable", () => runStableCleanup(state2));
73009
- else withBenchmarkPhase(state2.instrumentation, "store.cleanup.aggressive", () => runAggressiveCleanup(state2));
73010
- const after = createCleanupMetricSnapshot(state2);
73451
+ function cleanupPathStoreState(state3, mode) {
73452
+ const before = createCleanupMetricSnapshot(state3);
73453
+ if (mode === "stable") withBenchmarkPhase(state3.instrumentation, "store.cleanup.stable", () => runStableCleanup(state3));
73454
+ else withBenchmarkPhase(state3.instrumentation, "store.cleanup.aggressive", () => runAggressiveCleanup(state3));
73455
+ const after = createCleanupMetricSnapshot(state3);
73011
73456
  return createCleanupResult(mode, mode === "stable", before, after);
73012
73457
  }
73013
73458
 
@@ -73023,33 +73468,33 @@ function ensureProjectionDepthCapacity(depthTable, depth) {
73023
73468
  nextDepthTable.set(depthTable);
73024
73469
  return nextDepthTable;
73025
73470
  }
73026
- function getVisibleCount(state2) {
73027
- return requireNode(state2, state2.snapshot.rootId).visibleSubtreeCount;
73471
+ function getVisibleCount(state3) {
73472
+ return requireNode(state3, state3.snapshot.rootId).visibleSubtreeCount;
73028
73473
  }
73029
- function getVisibleRowSubtreeEndIndex(state2, cursor, index, totalVisibleCount) {
73030
- const terminalNode = requireNode(state2, cursor.terminalNodeId);
73474
+ function getVisibleRowSubtreeEndIndex(state3, cursor, index, totalVisibleCount) {
73475
+ const terminalNode = requireNode(state3, cursor.terminalNodeId);
73031
73476
  const subtreeSize = Math.max(1, terminalNode.visibleSubtreeCount);
73032
73477
  return Math.min(totalVisibleCount - 1, index + subtreeSize - 1);
73033
73478
  }
73034
- function materializeVisibleAncestorRow(state2, entry, totalVisibleCount, ancestorPaths) {
73479
+ function materializeVisibleAncestorRow(state3, entry, totalVisibleCount, ancestorPaths) {
73035
73480
  return {
73036
73481
  ancestorPaths,
73037
73482
  index: entry.index,
73038
73483
  posInSet: entry.posInSet,
73039
- row: materializeVisibleRow(state2, entry.cursor),
73484
+ row: materializeVisibleRow(state3, entry.cursor),
73040
73485
  setSize: entry.setSize,
73041
- subtreeEndIndex: getVisibleRowSubtreeEndIndex(state2, entry.cursor, entry.index, totalVisibleCount)
73486
+ subtreeEndIndex: getVisibleRowSubtreeEndIndex(state3, entry.cursor, entry.index, totalVisibleCount)
73042
73487
  };
73043
73488
  }
73044
- function selectVisibleRowContextWithinDirectory(state2, directoryNodeId, index, directoryStartIndex, parentVisibleDepth, ancestors2) {
73045
- const directoryIndex = getDirectoryIndex(state2, directoryNodeId);
73046
- const { childIndex, childVisibleIndex, localVisibleIndex } = selectChildIndexByVisibleIndex(state2.snapshot.nodes, directoryIndex, index);
73489
+ function selectVisibleRowContextWithinDirectory(state3, directoryNodeId, index, directoryStartIndex, parentVisibleDepth, ancestors2) {
73490
+ const directoryIndex = getDirectoryIndex(state3, directoryNodeId);
73491
+ const { childIndex, childVisibleIndex, localVisibleIndex } = selectChildIndexByVisibleIndex(state3.snapshot.nodes, directoryIndex, index);
73047
73492
  const childId = directoryIndex.childIds[childIndex];
73048
73493
  if (childId == null) throw new Error(`Visible index ${String(index)} is out of range`);
73049
- return selectVisibleRowContextWithinSubtree(state2, childId, localVisibleIndex, directoryStartIndex + childVisibleIndex, parentVisibleDepth + 1, childIndex, directoryIndex.childIds.length, ancestors2);
73494
+ return selectVisibleRowContextWithinSubtree(state3, childId, localVisibleIndex, directoryStartIndex + childVisibleIndex, parentVisibleDepth + 1, childIndex, directoryIndex.childIds.length, ancestors2);
73050
73495
  }
73051
- function selectVisibleRowContextWithinSubtree(state2, nodeId, index, rowIndex, visibleDepth, posInSet, setSize, ancestors2) {
73052
- if (!isDirectoryNode(requireNode(state2, nodeId))) {
73496
+ function selectVisibleRowContextWithinSubtree(state3, nodeId, index, rowIndex, visibleDepth, posInSet, setSize, ancestors2) {
73497
+ if (!isDirectoryNode(requireNode(state3, nodeId))) {
73053
73498
  if (index === 0) return {
73054
73499
  ancestors: ancestors2,
73055
73500
  cursor: {
@@ -73063,7 +73508,7 @@ function selectVisibleRowContextWithinSubtree(state2, nodeId, index, rowIndex, v
73063
73508
  };
73064
73509
  throw new Error(`Visible index ${String(index)} is out of range for file`);
73065
73510
  }
73066
- const currentCursor = createVisibleRowCursor(state2, nodeId, visibleDepth);
73511
+ const currentCursor = createVisibleRowCursor(state3, nodeId, visibleDepth);
73067
73512
  if (index === 0) return {
73068
73513
  ancestors: ancestors2,
73069
73514
  cursor: currentCursor,
@@ -73071,20 +73516,20 @@ function selectVisibleRowContextWithinSubtree(state2, nodeId, index, rowIndex, v
73071
73516
  posInSet,
73072
73517
  setSize
73073
73518
  };
73074
- const terminalNode = requireNode(state2, currentCursor.terminalNodeId);
73075
- if (!isDirectoryNode(terminalNode) || !isDirectoryExpanded(state2, currentCursor.terminalNodeId, terminalNode)) throw new Error(`Visible index ${String(index)} is out of range for collapsed directory`);
73076
- return selectVisibleRowContextWithinDirectory(state2, currentCursor.terminalNodeId, index - 1, rowIndex + 1, currentCursor.visibleDepth, [...ancestors2, {
73519
+ const terminalNode = requireNode(state3, currentCursor.terminalNodeId);
73520
+ if (!isDirectoryNode(terminalNode) || !isDirectoryExpanded(state3, currentCursor.terminalNodeId, terminalNode)) throw new Error(`Visible index ${String(index)} is out of range for collapsed directory`);
73521
+ return selectVisibleRowContextWithinDirectory(state3, currentCursor.terminalNodeId, index - 1, rowIndex + 1, currentCursor.visibleDepth, [...ancestors2, {
73077
73522
  cursor: currentCursor,
73078
73523
  index: rowIndex,
73079
73524
  posInSet,
73080
73525
  setSize
73081
73526
  }]);
73082
73527
  }
73083
- function getVisibleRowContext(state2, index) {
73084
- const totalVisibleCount = getVisibleCount(state2);
73528
+ function getVisibleRowContext(state3, index) {
73529
+ const totalVisibleCount = getVisibleCount(state3);
73085
73530
  if (index < 0 || index >= totalVisibleCount) return null;
73086
- const selected = selectVisibleRowContextWithinDirectory(state2, state2.snapshot.rootId, index, 0, -1, []);
73087
- const ancestorPaths = selected.ancestors.map((ancestor) => materializeNodePath(state2, ancestor.cursor.terminalNodeId));
73531
+ const selected = selectVisibleRowContextWithinDirectory(state3, state3.snapshot.rootId, index, 0, -1, []);
73532
+ const ancestorPaths = selected.ancestors.map((ancestor) => materializeNodePath(state3, ancestor.cursor.terminalNodeId));
73088
73533
  let cachedAncestorRows = null;
73089
73534
  return {
73090
73535
  ancestorPaths,
@@ -73093,7 +73538,7 @@ function getVisibleRowContext(state2, index) {
73093
73538
  const ancestorRows = [];
73094
73539
  const rowAncestorPaths = [];
73095
73540
  for (const ancestor of selected.ancestors) {
73096
- const ancestorRow = materializeVisibleAncestorRow(state2, ancestor, totalVisibleCount, [...rowAncestorPaths]);
73541
+ const ancestorRow = materializeVisibleAncestorRow(state3, ancestor, totalVisibleCount, [...rowAncestorPaths]);
73097
73542
  ancestorRows.push(ancestorRow);
73098
73543
  rowAncestorPaths.push(ancestorRow.row.path);
73099
73544
  }
@@ -73102,121 +73547,121 @@ function getVisibleRowContext(state2, index) {
73102
73547
  },
73103
73548
  index: selected.index,
73104
73549
  posInSet: selected.posInSet,
73105
- row: materializeVisibleRow(state2, selected.cursor),
73550
+ row: materializeVisibleRow(state3, selected.cursor),
73106
73551
  setSize: selected.setSize,
73107
- subtreeEndIndex: getVisibleRowSubtreeEndIndex(state2, selected.cursor, selected.index, totalVisibleCount)
73552
+ subtreeEndIndex: getVisibleRowSubtreeEndIndex(state3, selected.cursor, selected.index, totalVisibleCount)
73108
73553
  };
73109
73554
  }
73110
- function getVisibleSlice(state2, start, end) {
73111
- const instrumentation = state2.instrumentation;
73112
- const totalVisibleCount = getVisibleCount(state2);
73555
+ function getVisibleSlice(state3, start, end) {
73556
+ const instrumentation = state3.instrumentation;
73557
+ const totalVisibleCount = getVisibleCount(state3);
73113
73558
  if (totalVisibleCount <= 0 || end < start) return [];
73114
73559
  const normalizedStart = Math.max(0, Math.min(start, totalVisibleCount - 1));
73115
73560
  const normalizedEnd = Math.max(normalizedStart, Math.min(end, totalVisibleCount - 1));
73116
73561
  if (instrumentation == null) {
73117
- if (normalizedStart === 0) return collectVisibleRowsDFS(state2, normalizedEnd + 1);
73562
+ if (normalizedStart === 0) return collectVisibleRowsDFS(state3, normalizedEnd + 1);
73118
73563
  const rows2 = [];
73119
- let currentCursor2 = selectVisibleRow(state2, normalizedStart);
73564
+ let currentCursor2 = selectVisibleRow(state3, normalizedStart);
73120
73565
  for (let visibleIndex = normalizedStart; visibleIndex <= normalizedEnd && currentCursor2 != null; visibleIndex++) {
73121
- const row = materializeVisibleRow(state2, currentCursor2);
73566
+ const row = materializeVisibleRow(state3, currentCursor2);
73122
73567
  rows2.push(row);
73123
- currentCursor2 = getNextVisibleRowCursor(state2, currentCursor2);
73568
+ currentCursor2 = getNextVisibleRowCursor(state3, currentCursor2);
73124
73569
  }
73125
73570
  return rows2;
73126
73571
  }
73127
73572
  const rows = [];
73128
73573
  let flattenedRowCount = 0;
73129
73574
  let flattenedSegmentCount = 0;
73130
- let currentCursor = withBenchmarkPhase(instrumentation, "store.getVisibleSlice.selectFirstRow", () => selectVisibleRow(state2, normalizedStart));
73575
+ let currentCursor = withBenchmarkPhase(instrumentation, "store.getVisibleSlice.selectFirstRow", () => selectVisibleRow(state3, normalizedStart));
73131
73576
  for (let visibleIndex = normalizedStart; visibleIndex <= normalizedEnd && currentCursor != null; visibleIndex++) {
73132
- const row = withBenchmarkPhase(instrumentation, "store.getVisibleSlice.materializeRow", () => materializeVisibleRow(state2, currentCursor));
73577
+ const row = withBenchmarkPhase(instrumentation, "store.getVisibleSlice.materializeRow", () => materializeVisibleRow(state3, currentCursor));
73133
73578
  rows.push(row);
73134
73579
  if (row.isFlattened) {
73135
73580
  flattenedRowCount++;
73136
73581
  flattenedSegmentCount += row.flattenedSegments?.length ?? 0;
73137
73582
  }
73138
- currentCursor = withBenchmarkPhase(instrumentation, "store.getVisibleSlice.advanceCursor", () => getNextVisibleRowCursor(state2, currentCursor));
73583
+ currentCursor = withBenchmarkPhase(instrumentation, "store.getVisibleSlice.advanceCursor", () => getNextVisibleRowCursor(state3, currentCursor));
73139
73584
  }
73140
73585
  setBenchmarkCounter(instrumentation, "workload.visibleRowsRead", rows.length);
73141
73586
  setBenchmarkCounter(instrumentation, "workload.flattenedRowsRead", flattenedRowCount);
73142
73587
  setBenchmarkCounter(instrumentation, "workload.flattenedSegmentsRead", flattenedSegmentCount);
73143
73588
  return rows;
73144
73589
  }
73145
- function getVisibleTreeProjectionData(state2, maxRows = getVisibleCount(state2)) {
73146
- const instrumentation = state2.instrumentation;
73147
- if (instrumentation == null) return buildVisibleTreeProjectionDataDFS(state2, maxRows);
73148
- return withBenchmarkPhase(instrumentation, "store.getVisibleTreeProjection", () => buildVisibleTreeProjectionDataDFS(state2, maxRows));
73590
+ function getVisibleTreeProjectionData(state3, maxRows = getVisibleCount(state3)) {
73591
+ const instrumentation = state3.instrumentation;
73592
+ if (instrumentation == null) return buildVisibleTreeProjectionDataDFS(state3, maxRows);
73593
+ return withBenchmarkPhase(instrumentation, "store.getVisibleTreeProjection", () => buildVisibleTreeProjectionDataDFS(state3, maxRows));
73149
73594
  }
73150
- function getVisibleTreeProjection(state2) {
73151
- return createVisibleTreeProjectionFromData(getVisibleTreeProjectionData(state2));
73595
+ function getVisibleTreeProjection(state3) {
73596
+ return createVisibleTreeProjectionFromData(getVisibleTreeProjectionData(state3));
73152
73597
  }
73153
- function getVisibleIndexByPath(state2, path) {
73154
- const nodeId = findNodeId(state2, path);
73155
- if (nodeId == null || nodeId === state2.snapshot.rootId) return null;
73156
- if (isDirectoryNode(requireNode(state2, nodeId)) && getFlattenedTerminalDirectoryId(state2, nodeId) !== nodeId) return null;
73598
+ function getVisibleIndexByPath(state3, path) {
73599
+ const nodeId = findNodeId(state3, path);
73600
+ if (nodeId == null || nodeId === state3.snapshot.rootId) return null;
73601
+ if (isDirectoryNode(requireNode(state3, nodeId)) && getFlattenedTerminalDirectoryId(state3, nodeId) !== nodeId) return null;
73157
73602
  let visibleIndex = 0;
73158
73603
  let currentNodeId = nodeId;
73159
- const { nodes, rootId } = state2.snapshot;
73604
+ const { nodes, rootId } = state3.snapshot;
73160
73605
  while (currentNodeId !== rootId) {
73161
- const parentId = requireNode(state2, currentNodeId).parentId;
73162
- const parentIndex = getDirectoryIndex(state2, parentId);
73606
+ const parentId = requireNode(state3, currentNodeId).parentId;
73607
+ const parentIndex = getDirectoryIndex(state3, parentId);
73163
73608
  const childPosition = ensureChildPositions(parentIndex).get(currentNodeId);
73164
73609
  if (childPosition == null) throw new Error(`Child ${String(currentNodeId)} was not found in its parent index`);
73165
73610
  visibleIndex += getVisibleChildPrefixCount(nodes, parentIndex, childPosition);
73166
73611
  if (parentId !== rootId) {
73167
- const parentNode = requireNode(state2, parentId);
73168
- const flattenedChildDirectoryId = getFlattenedChildDirectoryId(state2, parentId);
73169
- if (!isDirectoryExpanded(state2, parentId, parentNode) && flattenedChildDirectoryId !== currentNodeId) return null;
73170
- if (getFlattenedTerminalDirectoryId(state2, parentId) === parentId) visibleIndex += 1;
73612
+ const parentNode = requireNode(state3, parentId);
73613
+ const flattenedChildDirectoryId = getFlattenedChildDirectoryId(state3, parentId);
73614
+ if (!isDirectoryExpanded(state3, parentId, parentNode) && flattenedChildDirectoryId !== currentNodeId) return null;
73615
+ if (getFlattenedTerminalDirectoryId(state3, parentId) === parentId) visibleIndex += 1;
73171
73616
  }
73172
73617
  currentNodeId = parentId;
73173
73618
  }
73174
73619
  return visibleIndex;
73175
73620
  }
73176
- function expandPath(state2, path) {
73177
- const directoryNodeId = findNodeId(state2, path);
73621
+ function expandPath(state3, path) {
73622
+ const directoryNodeId = findNodeId(state3, path);
73178
73623
  if (directoryNodeId == null) throw new Error(`Path does not exist: "${path}"`);
73179
- const directoryNode = requireNode(state2, directoryNodeId);
73624
+ const directoryNode = requireNode(state3, directoryNodeId);
73180
73625
  if (!isDirectoryNode(directoryNode)) throw new Error(`Path is not a directory: "${path}"`);
73181
- if (isDirectoryExpanded(state2, directoryNodeId, directoryNode)) return null;
73182
- setDirectoryExpanded(state2, directoryNodeId, true, directoryNode);
73183
- recomputeCountsUpwardFrom(state2, directoryNodeId);
73626
+ if (isDirectoryExpanded(state3, directoryNodeId, directoryNode)) return null;
73627
+ setDirectoryExpanded(state3, directoryNodeId, true, directoryNode);
73628
+ recomputeCountsUpwardFrom(state3, directoryNodeId);
73184
73629
  return createExpandEvent({
73185
- affectedAncestorIds: collectAncestorIds(state2, directoryNodeId),
73630
+ affectedAncestorIds: collectAncestorIds(state3, directoryNodeId),
73186
73631
  affectedNodeIds: [directoryNodeId],
73187
73632
  path,
73188
73633
  projectionChanged: true
73189
73634
  });
73190
73635
  }
73191
- function collapsePath(state2, path) {
73192
- const directoryNodeId = findNodeId(state2, path);
73636
+ function collapsePath(state3, path) {
73637
+ const directoryNodeId = findNodeId(state3, path);
73193
73638
  if (directoryNodeId == null) throw new Error(`Path does not exist: "${path}"`);
73194
- const directoryNode = requireNode(state2, directoryNodeId);
73639
+ const directoryNode = requireNode(state3, directoryNodeId);
73195
73640
  if (!isDirectoryNode(directoryNode)) throw new Error(`Path is not a directory: "${path}"`);
73196
- if (!isDirectoryExpanded(state2, directoryNodeId, directoryNode)) return null;
73197
- setDirectoryExpanded(state2, directoryNodeId, false, directoryNode);
73198
- recomputeCountsUpwardFrom(state2, directoryNodeId);
73641
+ if (!isDirectoryExpanded(state3, directoryNodeId, directoryNode)) return null;
73642
+ setDirectoryExpanded(state3, directoryNodeId, false, directoryNode);
73643
+ recomputeCountsUpwardFrom(state3, directoryNodeId);
73199
73644
  return createCollapseEvent({
73200
- affectedAncestorIds: collectAncestorIds(state2, directoryNodeId),
73645
+ affectedAncestorIds: collectAncestorIds(state3, directoryNodeId),
73201
73646
  affectedNodeIds: [directoryNodeId],
73202
73647
  path,
73203
73648
  projectionChanged: true
73204
73649
  });
73205
73650
  }
73206
- function selectVisibleRow(state2, index) {
73207
- if (index < 0 || index >= getVisibleCount(state2)) return null;
73208
- return selectVisibleRowWithinDirectory(state2, state2.snapshot.rootId, index, -1);
73651
+ function selectVisibleRow(state3, index) {
73652
+ if (index < 0 || index >= getVisibleCount(state3)) return null;
73653
+ return selectVisibleRowWithinDirectory(state3, state3.snapshot.rootId, index, -1);
73209
73654
  }
73210
- function selectVisibleRowWithinDirectory(state2, directoryNodeId, index, parentVisibleDepth) {
73211
- const directoryIndex = getDirectoryIndex(state2, directoryNodeId);
73212
- const instrumentation = state2.instrumentation;
73213
- const { childIndex, localVisibleIndex } = instrumentation == null ? selectChildIndexByVisibleIndex(state2.snapshot.nodes, directoryIndex, index) : withBenchmarkPhase(instrumentation, "store.getVisibleSlice.selectChildIndex", () => selectChildIndexByVisibleIndex(state2.snapshot.nodes, directoryIndex, index));
73655
+ function selectVisibleRowWithinDirectory(state3, directoryNodeId, index, parentVisibleDepth) {
73656
+ const directoryIndex = getDirectoryIndex(state3, directoryNodeId);
73657
+ const instrumentation = state3.instrumentation;
73658
+ const { childIndex, localVisibleIndex } = instrumentation == null ? selectChildIndexByVisibleIndex(state3.snapshot.nodes, directoryIndex, index) : withBenchmarkPhase(instrumentation, "store.getVisibleSlice.selectChildIndex", () => selectChildIndexByVisibleIndex(state3.snapshot.nodes, directoryIndex, index));
73214
73659
  const childId = directoryIndex.childIds[childIndex];
73215
- if (childId != null) return selectVisibleRowWithinSubtree(state2, childId, localVisibleIndex, parentVisibleDepth + 1);
73660
+ if (childId != null) return selectVisibleRowWithinSubtree(state3, childId, localVisibleIndex, parentVisibleDepth + 1);
73216
73661
  throw new Error(`Visible index ${String(index)} is out of range`);
73217
73662
  }
73218
- function selectVisibleRowWithinSubtree(state2, nodeId, index, visibleDepth) {
73219
- if (!isDirectoryNode(requireNode(state2, nodeId))) {
73663
+ function selectVisibleRowWithinSubtree(state3, nodeId, index, visibleDepth) {
73664
+ if (!isDirectoryNode(requireNode(state3, nodeId))) {
73220
73665
  if (index === 0) return {
73221
73666
  headNodeId: nodeId,
73222
73667
  terminalNodeId: nodeId,
@@ -73224,57 +73669,57 @@ function selectVisibleRowWithinSubtree(state2, nodeId, index, visibleDepth) {
73224
73669
  };
73225
73670
  throw new Error(`Visible index ${String(index)} is out of range for file`);
73226
73671
  }
73227
- const currentCursor = createVisibleRowCursor(state2, nodeId, visibleDepth);
73672
+ const currentCursor = createVisibleRowCursor(state3, nodeId, visibleDepth);
73228
73673
  if (index === 0) return currentCursor;
73229
- const terminalNode = requireNode(state2, currentCursor.terminalNodeId);
73230
- if (!isDirectoryNode(terminalNode) || !isDirectoryExpanded(state2, currentCursor.terminalNodeId, terminalNode)) throw new Error(`Visible index ${String(index)} is out of range for collapsed directory`);
73231
- return selectVisibleRowWithinDirectory(state2, currentCursor.terminalNodeId, index - 1, currentCursor.visibleDepth);
73674
+ const terminalNode = requireNode(state3, currentCursor.terminalNodeId);
73675
+ if (!isDirectoryNode(terminalNode) || !isDirectoryExpanded(state3, currentCursor.terminalNodeId, terminalNode)) throw new Error(`Visible index ${String(index)} is out of range for collapsed directory`);
73676
+ return selectVisibleRowWithinDirectory(state3, currentCursor.terminalNodeId, index - 1, currentCursor.visibleDepth);
73232
73677
  }
73233
- function createVisibleRowCursor(state2, nodeId, visibleDepth) {
73234
- if (!isDirectoryNode(requireNode(state2, nodeId))) return {
73678
+ function createVisibleRowCursor(state3, nodeId, visibleDepth) {
73679
+ if (!isDirectoryNode(requireNode(state3, nodeId))) return {
73235
73680
  headNodeId: nodeId,
73236
73681
  terminalNodeId: nodeId,
73237
73682
  visibleDepth
73238
73683
  };
73239
- if (state2.instrumentation == null) return {
73684
+ if (state3.instrumentation == null) return {
73240
73685
  headNodeId: nodeId,
73241
- terminalNodeId: getFlattenedTerminalDirectoryId(state2, nodeId),
73686
+ terminalNodeId: getFlattenedTerminalDirectoryId(state3, nodeId),
73242
73687
  visibleDepth
73243
73688
  };
73244
73689
  return {
73245
73690
  headNodeId: nodeId,
73246
- terminalNodeId: withBenchmarkPhase(state2.instrumentation, "store.getVisibleSlice.flatten.resolveTerminalDirectory", () => getFlattenedTerminalDirectoryId(state2, nodeId)),
73691
+ terminalNodeId: withBenchmarkPhase(state3.instrumentation, "store.getVisibleSlice.flatten.resolveTerminalDirectory", () => getFlattenedTerminalDirectoryId(state3, nodeId)),
73247
73692
  visibleDepth
73248
73693
  };
73249
73694
  }
73250
- function isVisibleRowHeadNode(state2, nodeId) {
73251
- const node = requireNode(state2, nodeId);
73695
+ function isVisibleRowHeadNode(state3, nodeId) {
73696
+ const node = requireNode(state3, nodeId);
73252
73697
  if (!isDirectoryNode(node)) return true;
73253
73698
  const parentId = node.parentId;
73254
- if (parentId === state2.snapshot.rootId) return true;
73255
- return getFlattenedChildDirectoryId(state2, parentId) !== nodeId;
73699
+ if (parentId === state3.snapshot.rootId) return true;
73700
+ return getFlattenedChildDirectoryId(state3, parentId) !== nodeId;
73256
73701
  }
73257
- function getNextVisibleRowCursor(state2, currentCursor) {
73258
- const terminalNode = requireNode(state2, currentCursor.terminalNodeId);
73702
+ function getNextVisibleRowCursor(state3, currentCursor) {
73703
+ const terminalNode = requireNode(state3, currentCursor.terminalNodeId);
73259
73704
  if (isDirectoryNode(terminalNode)) {
73260
- const currentIndex = getDirectoryIndex(state2, currentCursor.terminalNodeId);
73261
- if (isDirectoryExpanded(state2, currentCursor.terminalNodeId, terminalNode) && currentIndex.childIds.length > 0) {
73705
+ const currentIndex = getDirectoryIndex(state3, currentCursor.terminalNodeId);
73706
+ if (isDirectoryExpanded(state3, currentCursor.terminalNodeId, terminalNode) && currentIndex.childIds.length > 0) {
73262
73707
  const firstChildId = currentIndex.childIds[0];
73263
- return firstChildId == null ? null : selectVisibleRowWithinSubtree(state2, firstChildId, 0, currentCursor.visibleDepth + 1);
73708
+ return firstChildId == null ? null : selectVisibleRowWithinSubtree(state3, firstChildId, 0, currentCursor.visibleDepth + 1);
73264
73709
  }
73265
73710
  }
73266
73711
  let currentNodeId = currentCursor.terminalNodeId;
73267
73712
  let currentVisibleDepth = currentCursor.visibleDepth;
73268
73713
  while (true) {
73269
- const currentNode = requireNode(state2, currentNodeId);
73270
- if (currentNodeId === state2.snapshot.rootId) return null;
73714
+ const currentNode = requireNode(state3, currentNodeId);
73715
+ if (currentNodeId === state3.snapshot.rootId) return null;
73271
73716
  const parentId = currentNode.parentId;
73272
- const parentIndex = getDirectoryIndex(state2, parentId);
73717
+ const parentIndex = getDirectoryIndex(state3, parentId);
73273
73718
  const siblingIndex = ensureChildPositions(parentIndex).get(currentNodeId) ?? -1;
73274
73719
  if (siblingIndex < 0) throw new Error(`Child ${String(currentNodeId)} was not found in its parent index`);
73275
73720
  const nextSiblingId = parentIndex.childIds[siblingIndex + 1] ?? null;
73276
- if (nextSiblingId != null) return selectVisibleRowWithinSubtree(state2, nextSiblingId, 0, currentVisibleDepth);
73277
- if (isVisibleRowHeadNode(state2, currentNodeId)) currentVisibleDepth--;
73721
+ if (nextSiblingId != null) return selectVisibleRowWithinSubtree(state3, nextSiblingId, 0, currentVisibleDepth);
73722
+ if (isVisibleRowHeadNode(state3, currentNodeId)) currentVisibleDepth--;
73278
73723
  currentNodeId = parentId;
73279
73724
  }
73280
73725
  }
@@ -73299,7 +73744,7 @@ function createVisibleTreeProjectionFromData(projection) {
73299
73744
  }
73300
73745
  };
73301
73746
  }
73302
- function buildVisibleTreeProjectionDataDFS(state2, maxRows) {
73747
+ function buildVisibleTreeProjectionDataDFS(state3, maxRows) {
73303
73748
  const paths = new Array(maxRows);
73304
73749
  const parentRowIndex = new Int32Array(maxRows);
73305
73750
  const posInSetByIndex = new Int32Array(maxRows);
@@ -73307,16 +73752,16 @@ function buildVisibleTreeProjectionDataDFS(state2, maxRows) {
73307
73752
  let lastRowAtDepth = new Int32Array(INITIAL_PROJECTION_DEPTH_CAPACITY);
73308
73753
  lastRowAtDepth.fill(-1);
73309
73754
  let rowCount = 0;
73310
- const { nodes, directories, segmentTable } = state2.snapshot;
73755
+ const { nodes, directories, segmentTable } = state3.snapshot;
73311
73756
  const stack = [[
73312
- directories.get(state2.snapshot.rootId),
73757
+ directories.get(state3.snapshot.rootId),
73313
73758
  0,
73314
73759
  -1,
73315
73760
  ""
73316
73761
  ]];
73317
- const flattenEnabled = state2.snapshot.options.flattenEmptyDirectories;
73318
- const pathCacheByNodeId = state2.pathCacheByNodeId;
73319
- const pathCacheVersion = state2.pathCacheVersion;
73762
+ const flattenEnabled = state3.snapshot.options.flattenEmptyDirectories;
73763
+ const pathCacheByNodeId = state3.pathCacheByNodeId;
73764
+ const pathCacheVersion = state3.pathCacheVersion;
73320
73765
  const segmentValues = segmentTable.valueById;
73321
73766
  while (stack.length > 0 && rowCount < maxRows) {
73322
73767
  const frame = stack[stack.length - 1];
@@ -73337,8 +73782,8 @@ function buildVisibleTreeProjectionDataDFS(state2, maxRows) {
73337
73782
  const cachedPathEntry = pathCacheByNodeId.get(childId);
73338
73783
  path = cachedPathEntry != null && cachedPathEntry.version === pathCacheVersion ? cachedPathEntry.path : `${parentPath}${segmentValues[childNode.nameId]}`;
73339
73784
  } else {
73340
- terminalNodeId = flattenEnabled ? getFlattenedTerminalDirectoryId(state2, childId) : childId;
73341
- path = terminalNodeId === childId ? `${parentPath}${segmentValues[childNode.nameId]}/` : materializeNodePath(state2, terminalNodeId);
73785
+ terminalNodeId = flattenEnabled ? getFlattenedTerminalDirectoryId(state3, childId) : childId;
73786
+ path = terminalNodeId === childId ? `${parentPath}${segmentValues[childNode.nameId]}/` : materializeNodePath(state3, terminalNodeId);
73342
73787
  }
73343
73788
  parentRowIndex[rowCount] = lastRowAtDepth[visibleDepth];
73344
73789
  paths[rowCount] = path;
@@ -73347,7 +73792,7 @@ function buildVisibleTreeProjectionDataDFS(state2, maxRows) {
73347
73792
  lastRowAtDepth[visibleDepth + 1] = rowCount;
73348
73793
  rowCount += 1;
73349
73794
  const terminalNode = nodes[terminalNodeId];
73350
- if (terminalNode != null && isDirectoryNode(terminalNode) && isDirectoryExpanded(state2, terminalNodeId, terminalNode)) stack.push([
73795
+ if (terminalNode != null && isDirectoryNode(terminalNode) && isDirectoryExpanded(state3, terminalNodeId, terminalNode)) stack.push([
73351
73796
  directories.get(terminalNodeId),
73352
73797
  0,
73353
73798
  visibleDepth,
@@ -73375,19 +73820,19 @@ function buildVisibleTreeProjectionDataDFS(state2, maxRows) {
73375
73820
  }
73376
73821
  };
73377
73822
  }
73378
- function collectVisibleRowsDFS(state2, maxRows) {
73823
+ function collectVisibleRowsDFS(state3, maxRows) {
73379
73824
  const rows = new Array(maxRows);
73380
73825
  let rowCount = 0;
73381
- const { nodes, directories, segmentTable } = state2.snapshot;
73826
+ const { nodes, directories, segmentTable } = state3.snapshot;
73382
73827
  const stack = [[
73383
- directories.get(state2.snapshot.rootId),
73828
+ directories.get(state3.snapshot.rootId),
73384
73829
  0,
73385
73830
  -1
73386
73831
  ]];
73387
73832
  const segmentValues = segmentTable.valueById;
73388
- const flattenEnabled = state2.snapshot.options.flattenEmptyDirectories;
73389
- const pathCacheByNodeId = state2.pathCacheByNodeId;
73390
- const pathCacheVersion = state2.pathCacheVersion;
73833
+ const flattenEnabled = state3.snapshot.options.flattenEmptyDirectories;
73834
+ const pathCacheByNodeId = state3.pathCacheByNodeId;
73835
+ const pathCacheVersion = state3.pathCacheVersion;
73391
73836
  while (stack.length > 0 && rowCount < maxRows) {
73392
73837
  const frame = stack[stack.length - 1];
73393
73838
  const dirIndex = frame[0];
@@ -73411,19 +73856,19 @@ function collectVisibleRowsDFS(state2, maxRows) {
73411
73856
  kind: "file",
73412
73857
  loadState: void 0,
73413
73858
  name: segmentValues[childNode.nameId],
73414
- path: cachedPathEntry != null && cachedPathEntry.version === pathCacheVersion ? cachedPathEntry.path : materializeNodePath(state2, childId)
73859
+ path: cachedPathEntry != null && cachedPathEntry.version === pathCacheVersion ? cachedPathEntry.path : materializeNodePath(state3, childId)
73415
73860
  };
73416
73861
  continue;
73417
73862
  }
73418
- const terminalNodeId = flattenEnabled ? getFlattenedTerminalDirectoryId(state2, childId) : childId;
73863
+ const terminalNodeId = flattenEnabled ? getFlattenedTerminalDirectoryId(state3, childId) : childId;
73419
73864
  const cursor = {
73420
73865
  headNodeId: childId,
73421
73866
  terminalNodeId,
73422
73867
  visibleDepth
73423
73868
  };
73424
- rows[rowCount++] = materializeVisibleRow(state2, cursor);
73869
+ rows[rowCount++] = materializeVisibleRow(state3, cursor);
73425
73870
  const terminalNode = nodes[terminalNodeId];
73426
- if (terminalNode != null && isDirectoryNode(terminalNode) && isDirectoryExpanded(state2, terminalNodeId, terminalNode)) stack.push([
73871
+ if (terminalNode != null && isDirectoryNode(terminalNode) && isDirectoryExpanded(state3, terminalNodeId, terminalNode)) stack.push([
73427
73872
  directories.get(terminalNodeId),
73428
73873
  0,
73429
73874
  visibleDepth
@@ -73432,29 +73877,29 @@ function collectVisibleRowsDFS(state2, maxRows) {
73432
73877
  if (rowCount < maxRows) rows.length = rowCount;
73433
73878
  return rows;
73434
73879
  }
73435
- function materializeVisibleRow(state2, cursor) {
73436
- const terminalNode = requireNode(state2, cursor.terminalNodeId);
73437
- const loadState = isDirectoryNode(terminalNode) ? getVisibleRowLoadState(state2, cursor) : null;
73438
- const path = materializeNodePath(state2, cursor.terminalNodeId);
73439
- const name = getSegmentValue(state2.snapshot.segmentTable, terminalNode.nameId);
73440
- const hasChildren = isDirectoryNode(terminalNode) && getDirectoryIndex(state2, cursor.terminalNodeId).childIds.length > 0;
73880
+ function materializeVisibleRow(state3, cursor) {
73881
+ const terminalNode = requireNode(state3, cursor.terminalNodeId);
73882
+ const loadState = isDirectoryNode(terminalNode) ? getVisibleRowLoadState(state3, cursor) : null;
73883
+ const path = materializeNodePath(state3, cursor.terminalNodeId);
73884
+ const name = getSegmentValue(state3.snapshot.segmentTable, terminalNode.nameId);
73885
+ const hasChildren = isDirectoryNode(terminalNode) && getDirectoryIndex(state3, cursor.terminalNodeId).childIds.length > 0;
73441
73886
  const isFlattened = cursor.headNodeId !== cursor.terminalNodeId;
73442
- const instrumentation = state2.instrumentation;
73443
- const flattenedSegments = isFlattened ? instrumentation == null ? collectFlattenedDirectoryChainIds(state2, cursor.headNodeId).map((nodeId) => {
73444
- const node = requireNode(state2, nodeId);
73887
+ const instrumentation = state3.instrumentation;
73888
+ const flattenedSegments = isFlattened ? instrumentation == null ? collectFlattenedDirectoryChainIds(state3, cursor.headNodeId).map((nodeId) => {
73889
+ const node = requireNode(state3, nodeId);
73445
73890
  return {
73446
73891
  isTerminal: nodeId === cursor.terminalNodeId,
73447
- name: getSegmentValue(state2.snapshot.segmentTable, node.nameId),
73892
+ name: getSegmentValue(state3.snapshot.segmentTable, node.nameId),
73448
73893
  nodeId,
73449
- path: materializeNodePath(state2, nodeId)
73894
+ path: materializeNodePath(state3, nodeId)
73450
73895
  };
73451
- }) : withBenchmarkPhase(instrumentation, "store.getVisibleSlice.flatten.collectSegments", () => collectFlattenedDirectoryChainIds(state2, cursor.headNodeId).map((nodeId) => {
73452
- const node = requireNode(state2, nodeId);
73896
+ }) : withBenchmarkPhase(instrumentation, "store.getVisibleSlice.flatten.collectSegments", () => collectFlattenedDirectoryChainIds(state3, cursor.headNodeId).map((nodeId) => {
73897
+ const node = requireNode(state3, nodeId);
73453
73898
  return {
73454
73899
  isTerminal: nodeId === cursor.terminalNodeId,
73455
- name: getSegmentValue(state2.snapshot.segmentTable, node.nameId),
73900
+ name: getSegmentValue(state3.snapshot.segmentTable, node.nameId),
73456
73901
  nodeId,
73457
- path: materializeNodePath(state2, nodeId)
73902
+ path: materializeNodePath(state3, nodeId)
73458
73903
  };
73459
73904
  })) : void 0;
73460
73905
  return {
@@ -73462,7 +73907,7 @@ function materializeVisibleRow(state2, cursor) {
73462
73907
  flattenedSegments,
73463
73908
  hasChildren,
73464
73909
  id: cursor.terminalNodeId,
73465
- isExpanded: isDirectoryNode(terminalNode) && isDirectoryExpanded(state2, cursor.terminalNodeId, terminalNode),
73910
+ isExpanded: isDirectoryNode(terminalNode) && isDirectoryExpanded(state3, cursor.terminalNodeId, terminalNode),
73466
73911
  isFlattened,
73467
73912
  isLoading: loadState === "loading",
73468
73913
  kind: isDirectoryNode(terminalNode) ? "directory" : "file",
@@ -73471,13 +73916,13 @@ function materializeVisibleRow(state2, cursor) {
73471
73916
  path
73472
73917
  };
73473
73918
  }
73474
- function getVisibleRowLoadState(state2, cursor) {
73475
- if (cursor.headNodeId === cursor.terminalNodeId) return getDirectoryLoadState(state2, cursor.terminalNodeId);
73476
- const chainNodeIds = collectFlattenedDirectoryChainIds(state2, cursor.headNodeId);
73919
+ function getVisibleRowLoadState(state3, cursor) {
73920
+ if (cursor.headNodeId === cursor.terminalNodeId) return getDirectoryLoadState(state3, cursor.terminalNodeId);
73921
+ const chainNodeIds = collectFlattenedDirectoryChainIds(state3, cursor.headNodeId);
73477
73922
  let hasUnloaded = false;
73478
73923
  let hasError = false;
73479
73924
  for (const nodeId of chainNodeIds) {
73480
- const loadState = getDirectoryLoadState(state2, nodeId);
73925
+ const loadState = getDirectoryLoadState(state3, nodeId);
73481
73926
  if (loadState === "loading") return "loading";
73482
73927
  if (loadState === "error") {
73483
73928
  hasError = true;
@@ -73571,8 +74016,8 @@ function sweepOpenVisibleCountsSoa(store2) {
73571
74016
  }
73572
74017
 
73573
74018
  // node_modules/@pierre/trees/dist/path-store/src/store.js
73574
- function initializeOpenVisibleCounts(state2) {
73575
- const { directories, nodes, options, rootId, presortedDirectoryNodeIds } = state2.snapshot;
74019
+ function initializeOpenVisibleCounts(state3) {
74020
+ const { directories, nodes, options, rootId, presortedDirectoryNodeIds } = state3.snapshot;
73576
74021
  const flattenEmptyDirectories = options.flattenEmptyDirectories === true;
73577
74022
  const walkDirectory = (nodeId) => {
73578
74023
  const currentNode = nodes[nodeId];
@@ -73622,9 +74067,9 @@ function initializeOpenVisibleCounts(state2) {
73622
74067
  rootNode.subtreeNodeCount = 1 + rootTotalChildSubtreeNodeCount;
73623
74068
  rootNode.visibleSubtreeCount = rootTotalChildVisibleSubtreeCount;
73624
74069
  }
73625
- function initializeOpenVisibleCountsViaSoa(state2) {
73626
- const { directories, nodes, rootId } = state2.snapshot;
73627
- const soa = buildSoaNodeStore(state2.snapshot);
74070
+ function initializeOpenVisibleCountsViaSoa(state3) {
74071
+ const { directories, nodes, rootId } = state3.snapshot;
74072
+ const soa = buildSoaNodeStore(state3.snapshot);
73628
74073
  sweepOpenVisibleCountsSoa(soa);
73629
74074
  const subtreeNodeCount = soa.subtreeNodeCount;
73630
74075
  const visibleSubtreeCount = soa.visibleSubtreeCount;
@@ -76748,17 +77193,17 @@ function RenameInput({ ariaLabel, isFlattened = false, ref, value, onBlur, onInp
76748
77193
 
76749
77194
  // node_modules/@pierre/trees/dist/render/rowAttributes.js
76750
77195
  function computeFileTreeRowElementAttributes(input) {
76751
- const { row, mode, targetPath, ariaLabel, domId, isParked, itemHeight, features, state: state2, extraStyle } = input;
77196
+ const { row, mode, targetPath, ariaLabel, domId, isParked, itemHeight, features, state: state3, extraStyle } = input;
76752
77197
  const isSticky = mode === "sticky";
76753
77198
  const parentPath = row.ancestorPaths.at(-1) ?? "";
76754
77199
  const stateAttributes = {};
76755
- if (state2.isFocusRinged) stateAttributes["data-item-focused"] = true;
77200
+ if (state3.isFocusRinged) stateAttributes["data-item-focused"] = true;
76756
77201
  if (row.isSelected) stateAttributes["data-item-selected"] = true;
76757
- if (state2.isContextHovered) stateAttributes["data-item-context-hover"] = "true";
76758
- if (state2.isDragTarget) stateAttributes["data-item-drag-target"] = true;
76759
- if (state2.isDragging) stateAttributes["data-item-dragging"] = true;
76760
- if (state2.effectiveGitStatus != null) stateAttributes["data-item-git-status"] = state2.effectiveGitStatus;
76761
- if (state2.containsGitChange) stateAttributes["data-item-contains-git-change"] = "true";
77202
+ if (state3.isContextHovered) stateAttributes["data-item-context-hover"] = "true";
77203
+ if (state3.isDragTarget) stateAttributes["data-item-drag-target"] = true;
77204
+ if (state3.isDragging) stateAttributes["data-item-dragging"] = true;
77205
+ if (state3.effectiveGitStatus != null) stateAttributes["data-item-git-status"] = state3.effectiveGitStatus;
77206
+ if (state3.containsGitChange) stateAttributes["data-item-contains-git-change"] = "true";
76762
77207
  return {
76763
77208
  "aria-expanded": !isSticky && row.kind === "directory" ? row.isExpanded : void 0,
76764
77209
  "aria-haspopup": features.contextMenuEnabled ? "menu" : void 0,
@@ -79564,6 +80009,7 @@ function define2() {
79564
80009
  define2();
79565
80010
  export {
79566
80011
  Emitter,
80012
+ Panels,
79567
80013
  SliccAgents,
79568
80014
  SliccApp,
79569
80015
  SliccApprovals,
@@ -79587,6 +80033,7 @@ export {
79587
80033
  confirm,
79588
80034
  define2 as define,
79589
80035
  grammarBase,
80036
+ panelCommand,
79590
80037
  prompt,
79591
80038
  resolveColor,
79592
80039
  setGrammarBase,