@popcraft/cli 0.48.3 → 0.50.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.
Files changed (2) hide show
  1. package/dist/popcraft.mjs +716 -386
  2. package/package.json +2 -2
package/dist/popcraft.mjs CHANGED
@@ -1196,7 +1196,7 @@ function operations(spec = openapi) {
1196
1196
  }
1197
1197
  async function call(target2, method, path, opts = {}) {
1198
1198
  const qs = new URLSearchParams(opts.query ?? {}).toString();
1199
- const headers = { "user-agent": `popcraft-cli/${"0.48.3"}`, ...opts.headers };
1199
+ const headers = { "user-agent": `popcraft-cli/${"0.50.0"}`, ...opts.headers };
1200
1200
  if (target2.token) headers.authorization = `Bearer ${target2.token}`;
1201
1201
  if (opts.contentType) headers["content-type"] = opts.contentType;
1202
1202
  try {
@@ -3994,14 +3994,14 @@ function describeTextTarget(doc2, n) {
3994
3994
  names.unshift(p2.name);
3995
3995
  p2 = p2.parentId ? doc2.nodes[p2.parentId] : void 0;
3996
3996
  }
3997
- const current4 = str2(n.characters ?? "", 400);
3998
- const charsPerLine = n.textAutoResize === "WIDTH_AND_HEIGHT" ? Math.max(current4.length, 8) : Math.max(4, Math.floor(n.width / Math.max(1, n.fontSize * 0.52)));
3999
- const lines2 = n.textAutoResize === "NONE" ? Math.max(1, Math.floor(n.height / Math.max(1, n.fontSize * 1.2))) : Math.max(1, current4.split("\n").length, Math.round(n.height / Math.max(1, n.fontSize * 1.2)));
3997
+ const current5 = str2(n.characters ?? "", 400);
3998
+ const charsPerLine = n.textAutoResize === "WIDTH_AND_HEIGHT" ? Math.max(current5.length, 8) : Math.max(4, Math.floor(n.width / Math.max(1, n.fontSize * 0.52)));
3999
+ const lines2 = n.textAutoResize === "NONE" ? Math.max(1, Math.floor(n.height / Math.max(1, n.fontSize * 1.2))) : Math.max(1, current5.split("\n").length, Math.round(n.height / Math.max(1, n.fontSize * 1.2)));
4000
4000
  return {
4001
4001
  id: n.id,
4002
4002
  name: str2(n.name, AI_LIMITS.maxNameChars),
4003
4003
  role: inferTextRole(n, names),
4004
- current: current4,
4004
+ current: current5,
4005
4005
  maxChars: Math.max(4, Math.min(AI_LIMITS.maxTextChars, charsPerLine * lines2)),
4006
4006
  path: str2(names.join(" / "), 200)
4007
4007
  };
@@ -5200,8 +5200,8 @@ var init_properties = __esm({
5200
5200
  T = "Transform";
5201
5201
  A = "Appearance";
5202
5202
  inFlow = (n, parent) => {
5203
- const mode = parent ? fieldOf(parent, "layoutMode") : void 0;
5204
- return !!mode && mode !== "NONE" && fieldOf(n, "layoutPositioning") !== "ABSOLUTE";
5203
+ const mode2 = parent ? fieldOf(parent, "layoutMode") : void 0;
5204
+ return !!mode2 && mode2 !== "NONE" && fieldOf(n, "layoutPositioning") !== "ABSOLUTE";
5205
5205
  };
5206
5206
  num5 = (v) => typeof v === "number" && Number.isFinite(v) ? v : void 0;
5207
5207
  effectType = (...types) => {
@@ -5807,8 +5807,8 @@ function packedToHex(v) {
5807
5807
  const [r, g, b, a] = unpackRGBA(v);
5808
5808
  return `#${[r, g, b, a].map((x2) => x2.toString(16).padStart(2, "0")).join("")}`;
5809
5809
  }
5810
- function celsToRGBA(cells, mode, palette2, transparentIndex) {
5811
- if (mode !== "INDEXED") return cells;
5810
+ function celsToRGBA(cells, mode2, palette2, transparentIndex) {
5811
+ if (mode2 !== "INDEXED") return cells;
5812
5812
  const lut = palette2.map(hexToPacked);
5813
5813
  const out = new Uint32Array(cells.length);
5814
5814
  for (let i2 = 0; i2 < cells.length; i2++) {
@@ -6500,21 +6500,21 @@ function glyphInstancesToRings(instances) {
6500
6500
  }
6501
6501
  const commands2 = glyph2?.path?.commands;
6502
6502
  if (!commands2?.length) continue;
6503
- let current4 = [];
6503
+ let current5 = [];
6504
6504
  const push2 = () => {
6505
- if (current4.length >= 3) rings.push(closeRing(current4));
6506
- current4 = [];
6505
+ if (current5.length >= 3) rings.push(closeRing(current5));
6506
+ current5 = [];
6507
6507
  };
6508
6508
  const t3 = glyphTransform(g);
6509
6509
  const turn = glyphTurn(g);
6510
6510
  flattenPath(commands2, t3, (x0, y0, x1, y1) => {
6511
6511
  const [ax, ay] = turn(x0, y0), [bx, by] = turn(x1, y1);
6512
- const last3 = current4[current4.length - 1];
6512
+ const last3 = current5[current5.length - 1];
6513
6513
  if (!last3 || last3[0] !== ax || last3[1] !== ay) {
6514
6514
  push2();
6515
- current4.push([ax, ay]);
6515
+ current5.push([ax, ay]);
6516
6516
  }
6517
- current4.push([bx, by]);
6517
+ current5.push([bx, by]);
6518
6518
  });
6519
6519
  push2();
6520
6520
  }
@@ -6974,8 +6974,8 @@ function addHeaderFooterToMaster(doc2, masterId, kind) {
6974
6974
  return { doc: updated, textId: text.id };
6975
6975
  }
6976
6976
  function reorderPrintPages(doc2, pageId2, orderedIds) {
6977
- const current4 = listPrintPages(doc2, pageId2);
6978
- const rest = current4.map((f2) => f2.id).filter((id3) => !orderedIds.includes(id3));
6977
+ const current5 = listPrintPages(doc2, pageId2);
6978
+ const rest = current5.map((f2) => f2.id).filter((id3) => !orderedIds.includes(id3));
6979
6979
  const patches = {};
6980
6980
  [...orderedIds, ...rest].forEach((id3, index2) => {
6981
6981
  const f2 = doc2.nodes[id3];
@@ -7779,12 +7779,12 @@ function getAncestors(document2, nodeId2) {
7779
7779
  const ancestors = [];
7780
7780
  const node2 = document2.nodes[nodeId2];
7781
7781
  if (!node2) return ancestors;
7782
- let current4 = node2;
7783
- while (current4.parentId) {
7784
- const parent = document2.nodes[current4.parentId];
7782
+ let current5 = node2;
7783
+ while (current5.parentId) {
7784
+ const parent = document2.nodes[current5.parentId];
7785
7785
  if (parent) {
7786
7786
  ancestors.push(parent);
7787
- current4 = parent;
7787
+ current5 = parent;
7788
7788
  } else {
7789
7789
  break;
7790
7790
  }
@@ -8578,15 +8578,15 @@ function resolveStepRefs(params2, results) {
8578
8578
  return fill(params2);
8579
8579
  }
8580
8580
  function documentContext(doc2, opts) {
8581
- let current4 = doc2;
8581
+ let current5 = doc2;
8582
8582
  let pageId2 = opts.pageId && doc2.pages.includes(opts.pageId) ? opts.pageId : doc2.pages[0];
8583
8583
  let selection = (opts.selection ?? []).filter((id3) => id3 in doc2.nodes);
8584
8584
  const notices = [];
8585
8585
  const caps = opts.capabilities ?? [];
8586
8586
  const ctx2 = {
8587
- doc: () => current4,
8587
+ doc: () => current5,
8588
8588
  commit: (next2) => {
8589
- current4 = next2;
8589
+ current5 = next2;
8590
8590
  },
8591
8591
  pageId: () => pageId2,
8592
8592
  selection: () => [...selection],
@@ -8610,18 +8610,18 @@ function documentContext(doc2, opts) {
8610
8610
  },
8611
8611
  create: (name2) => {
8612
8612
  const page = createPage(name2);
8613
- current4 = { ...current4, pages: [...current4.pages, page.id], nodes: { ...current4.nodes, [page.id]: page } };
8613
+ current5 = { ...current5, pages: [...current5.pages, page.id], nodes: { ...current5.nodes, [page.id]: page } };
8614
8614
  pageId2 = page.id;
8615
8615
  selection = [];
8616
8616
  return page.id;
8617
8617
  },
8618
8618
  rename: (id3, name2) => {
8619
- current4 = updateNode(current4, id3, { name: name2 });
8619
+ current5 = updateNode(current5, id3, { name: name2 });
8620
8620
  }
8621
8621
  },
8622
8622
  readOnlyReason: () => null
8623
8623
  };
8624
- return { ctx: ctx2, document: () => current4, pageId: () => pageId2, selection: () => [...selection], notices };
8624
+ return { ctx: ctx2, document: () => current5, pageId: () => pageId2, selection: () => [...selection], notices };
8625
8625
  }
8626
8626
  var BROWSER_NEEDS, SIGNIN_DOMAINS, APP_ONLY, UNAVAILABLE, STORE_BOUND, STEP_REF;
8627
8627
  var init_headless = __esm({
@@ -8645,6 +8645,7 @@ var init_headless = __esm({
8645
8645
  "view.zoom",
8646
8646
  "view.zoomTo",
8647
8647
  "view.stage",
8648
+ "view.screenLayout",
8648
8649
  "view.present",
8649
8650
  "view.copyLink",
8650
8651
  "canvas.toggle",
@@ -32785,6 +32786,8 @@ var init_en2 = __esm({
32785
32786
  "command:page.create": "New page",
32786
32787
  "command:page.setCurrent": "Next page",
32787
32788
  "command:paint.replaceColor": "Replace color",
32789
+ "command:paint.setFills": "Set fills",
32790
+ "command:paint.setStrokes": "Set strokes",
32788
32791
  "command:presentation.configureAudio": "Presentation audio settings",
32789
32792
  "command:presentation.fallbackAudio": "Use offline fallback audio",
32790
32793
  "command:presentation.generateAudio": "Generate presentation audio",
@@ -32827,6 +32830,7 @@ var init_en2 = __esm({
32827
32830
  "command:text.setPath#circle": "Text on a circle",
32828
32831
  "command:text.setPath#path": "Attach text to path",
32829
32832
  "command:text.setPath#wave": "Wave text",
32833
+ "command:text.setTypography": "Set typography",
32830
32834
  "command:vector.boolean": "Boolean",
32831
32835
  "command:vector.boolean#exclude": "Exclude",
32832
32836
  "command:vector.boolean#intersect": "Intersect",
@@ -32849,6 +32853,7 @@ var init_en2 = __esm({
32849
32853
  "command:view.present#fullscreen": "Present (fullscreen)",
32850
32854
  "command:view.present#presenter": "Presenter view",
32851
32855
  "command:view.present#window": "Present in a window for screen share\u2026",
32856
+ "command:view.screenLayout": "Flip canvas and panels",
32852
32857
  "command:view.select": "Deselect all",
32853
32858
  "command:view.stage": "Stage view",
32854
32859
  "command:view.zoom": "Zoom",
@@ -33519,6 +33524,12 @@ var init_en2 = __esm({
33519
33524
  "drawSettingsPanel.wetMix": "Wet mix",
33520
33525
  "drawSettingsPanel.wetPaint": "Wet paint",
33521
33526
  "drawSettingsPanel.whatTheTipRotatesWith": "What the tip rotates with",
33527
+ "duoHarness.closed": "Closed",
33528
+ "duoHarness.frameTitle": "PopCraft on an iPhone Duo",
33529
+ "duoHarness.halfOpen": "Half open",
33530
+ "duoHarness.open": "Open",
33531
+ "duoHarness.posture": "Fold posture",
33532
+ "duoHarness.rotate": "Rotate",
33522
33533
  "editorStore.leftNothingThoseShapesProduce": "{toLowerCase} left nothing \u2014 those shapes produce an empty result.",
33523
33534
  "editorStore.readOnlyPickAMode": "This file is read only. Pick Design, or another mode, to edit it.",
33524
33535
  "editorStore.savingToBrowserStorageFailed": "Saving to browser storage failed \u2014 recent changes may not be saved.",
@@ -34805,6 +34816,10 @@ var init_en2 = __esm({
34805
34816
  "panelRail.dragToTheOtherSide": "{title} \u2014 drag to the other side (or Alt+Shift+Arrow) to move it",
34806
34817
  "panelRail.leftPanel": "Left panel",
34807
34818
  "panelRail.rightPanel": "Right panel",
34819
+ "panelTab.agent": "Agent",
34820
+ "panelTab.comments": "Comments",
34821
+ "panelTab.inspect": "Inspect",
34822
+ "panelTab.layers": "Layers",
34808
34823
  "pdfExportDialog.aTSFriendlyR\xE9sum\xE9sRealText": "ATS-friendly (r\xE9sum\xE9s): real text in reading order",
34809
34824
  "pdfExportDialog.cancel": "Cancel",
34810
34825
  "pdfExportDialog.cMYKUncalibrated": "CMYK (uncalibrated)",
@@ -34836,6 +34851,34 @@ var init_en2 = __esm({
34836
34851
  "pendingInstallNotice.dismiss": "Dismiss",
34837
34852
  "pendingInstallNotice.signIn": "Sign in",
34838
34853
  "pendingInstallNotice.tryItInANew": "Try it in a new file",
34854
+ "phoneShell.allFiles": "All files",
34855
+ "phoneShell.backToMore": "Back to More",
34856
+ "phoneShell.canvas": "Canvas",
34857
+ "phoneShell.commands": "Commands",
34858
+ "phoneShell.design": "Design",
34859
+ "phoneShell.editorMode": "Editor mode",
34860
+ "phoneShell.editSelection": "Edit {name}",
34861
+ "phoneShell.flipCanvas": "Flip canvas and panels",
34862
+ "phoneShell.layers": "Layers",
34863
+ "phoneShell.layout": "Screen layout",
34864
+ "phoneShell.layoutAuto": "Automatic (fits the screen)",
34865
+ "phoneShell.layoutDesktop": "Desktop",
34866
+ "phoneShell.layoutPanes": "Two panes",
34867
+ "phoneShell.layoutPhone": "Phone",
34868
+ "phoneShell.modes": "Modes",
34869
+ "phoneShell.more": "More",
34870
+ "phoneShell.panels": "Panels",
34871
+ "phoneShell.pinToDock": "Pin {name} to the dock",
34872
+ "phoneShell.properties": "Properties",
34873
+ "phoneShell.recent": "Recent",
34874
+ "phoneShell.resizePanels": "Resize the two panels",
34875
+ "phoneShell.resizePanes": "Resize canvas and panels",
34876
+ "phoneShell.searchCommands": "Search commands",
34877
+ "phoneShell.selectedCount": "{count, plural, one {# layer} other {# layers}}",
34878
+ "phoneShell.settings": "Settings",
34879
+ "phoneShell.textSize": "Size",
34880
+ "phoneShell.unpinFromDock": "Unpin {name} from the dock",
34881
+ "phoneShell.untitled": "Untitled",
34839
34882
  "photoBrowser.anyCreativeCommonsLicence": "Any Creative Commons licence",
34840
34883
  "photoBrowser.freeToUseAndEdit": "Free to use and edit commercially",
34841
34884
  "photoBrowser.licences": "Licences",
@@ -35859,6 +35902,7 @@ var init_en2 = __esm({
35859
35902
  "shareImage.upload": "Upload",
35860
35903
  "shareImage.uploadHint": "A PNG or JPEG under 1 MB. 1200\xD7630 fits link previews best.",
35861
35904
  "shareImage.whichFrame": "Frame to share",
35905
+ "sheet.close": "Close",
35862
35906
  "showAdvanceControl.advance": "Advance",
35863
35907
  "showAdvanceControl.afterADelay": "After a delay",
35864
35908
  "showAdvanceControl.loopTheShow": "Loop the show",
@@ -94264,20 +94308,20 @@ function accentText(s) {
94264
94308
  function bidiText(s) {
94265
94309
  return s.trim() ? `${RLO}${s}${PDF}` : s;
94266
94310
  }
94267
- function walk2(els, mode) {
94311
+ function walk2(els, mode2) {
94268
94312
  return els.map((el) => {
94269
- if (el.type === TYPE.literal) return { ...el, value: mode === "accented" ? accentText(el.value) : bidiText(el.value) };
94313
+ if (el.type === TYPE.literal) return { ...el, value: mode2 === "accented" ? accentText(el.value) : bidiText(el.value) };
94270
94314
  if (el.type === TYPE.plural || el.type === TYPE.select) {
94271
- const options = Object.fromEntries(Object.entries(el.options).map(([k2, o]) => [k2, { ...o, value: walk2(o.value, mode) }]));
94315
+ const options = Object.fromEntries(Object.entries(el.options).map(([k2, o]) => [k2, { ...o, value: walk2(o.value, mode2) }]));
94272
94316
  return { ...el, options };
94273
94317
  }
94274
- if (el.type === TYPE.tag) return { ...el, children: walk2(el.children, mode) };
94318
+ if (el.type === TYPE.tag) return { ...el, children: walk2(el.children, mode2) };
94275
94319
  return el;
94276
94320
  });
94277
94321
  }
94278
- function pseudoAst(ast, mode) {
94279
- const body = walk2(ast, mode);
94280
- if (mode !== "accented") return body;
94322
+ function pseudoAst(ast, mode2) {
94323
+ const body = walk2(ast, mode2);
94324
+ if (mode2 !== "accented") return body;
94281
94325
  return [{ type: TYPE.literal, value: PSEUDO_OPEN }, ...body, { type: TYPE.literal, value: PSEUDO_CLOSE }];
94282
94326
  }
94283
94327
  var ACCENTS, VOWELS, PSEUDO_OPEN, PSEUDO_CLOSE, RLO, PDF;
@@ -94920,9 +94964,9 @@ var require_react_production = __commonJS({
94920
94964
  exports.useState = function(initialState) {
94921
94965
  return ReactSharedInternals.H.useState(initialState);
94922
94966
  };
94923
- exports.useSyncExternalStore = function(subscribe, getSnapshot, getServerSnapshot) {
94967
+ exports.useSyncExternalStore = function(subscribe2, getSnapshot, getServerSnapshot) {
94924
94968
  return ReactSharedInternals.H.useSyncExternalStore(
94925
- subscribe,
94969
+ subscribe2,
94926
94970
  getSnapshot,
94927
94971
  getServerSnapshot
94928
94972
  );
@@ -95802,8 +95846,8 @@ var init_shader_graph = __esm({
95802
95846
  inputs: [col2("base", BLACK2), col2("layer", WHITE2), f322("amount", 1, [0, 2])],
95803
95847
  options: [{ name: "mode", values: ["add", "screen", "multiply", "over", "max"], default: "add" }],
95804
95848
  emit: (c2) => {
95805
- const mode = c2.opt("mode");
95806
- const mixed = mode === "screen" ? "vec3<f32>(1.0) - (vec3<f32>(1.0) - a.rgb) * (vec3<f32>(1.0) - b.rgb)" : mode === "multiply" ? "a.rgb * b.rgb" : mode === "over" ? "mix(a.rgb, b.rgb, b.a)" : mode === "max" ? "max(a.rgb, b.rgb)" : "a.rgb + b.rgb";
95849
+ const mode2 = c2.opt("mode");
95850
+ const mixed = mode2 === "screen" ? "vec3<f32>(1.0) - (vec3<f32>(1.0) - a.rgb) * (vec3<f32>(1.0) - b.rgb)" : mode2 === "multiply" ? "a.rgb * b.rgb" : mode2 === "over" ? "mix(a.rgb, b.rgb, b.a)" : mode2 === "max" ? "max(a.rgb, b.rgb)" : "a.rgb + b.rgb";
95807
95851
  return `let a = ${c2.in("base")};
95808
95852
  let b = ${c2.in("layer")};
95809
95853
  let k = ${c2.in("amount")};
@@ -96328,11 +96372,29 @@ function holdsIndexedDB(close) {
96328
96372
  closers.delete(close);
96329
96373
  };
96330
96374
  }
96331
- var closers;
96375
+ function closeAllIndexedDB() {
96376
+ for (const close of [...closers]) {
96377
+ try {
96378
+ close();
96379
+ } catch {
96380
+ }
96381
+ }
96382
+ }
96383
+ var closers, CHANNEL, channel;
96332
96384
  var init_open_connections = __esm({
96333
96385
  "lib/storage/open-connections.ts"() {
96334
96386
  "use strict";
96335
96387
  closers = /* @__PURE__ */ new Set();
96388
+ CHANNEL = "popcraft-close-indexeddb";
96389
+ channel = null;
96390
+ if (typeof BroadcastChannel !== "undefined") {
96391
+ try {
96392
+ channel = new BroadcastChannel(CHANNEL);
96393
+ channel.onmessage = () => closeAllIndexedDB();
96394
+ channel.unref?.();
96395
+ } catch {
96396
+ }
96397
+ }
96336
96398
  }
96337
96399
  });
96338
96400
 
@@ -96837,22 +96899,22 @@ var init_vanilla = __esm({
96837
96899
  "node_modules/.pnpm/zustand@5.0.15_@types+react@19.3.0_immer@11.1.21_react@19.3.0_use-sync-external-store@1.6.0_react@19.3.0_/node_modules/zustand/esm/vanilla.mjs"() {
96838
96900
  createStoreImpl = (createState) => {
96839
96901
  let state;
96840
- const listeners8 = /* @__PURE__ */ new Set();
96902
+ const listeners9 = /* @__PURE__ */ new Set();
96841
96903
  const setState = (partial2, replace) => {
96842
96904
  const nextState = typeof partial2 === "function" ? partial2(state) : partial2;
96843
96905
  if (!Object.is(nextState, state)) {
96844
96906
  const previousState = state;
96845
96907
  state = (replace != null ? replace : typeof nextState !== "object" || nextState === null) ? nextState : Object.assign({}, state, nextState);
96846
- listeners8.forEach((listener) => listener(state, previousState));
96908
+ listeners9.forEach((listener) => listener(state, previousState));
96847
96909
  }
96848
96910
  };
96849
96911
  const getState2 = () => state;
96850
96912
  const getInitialState = () => initialState;
96851
- const subscribe = (listener) => {
96852
- listeners8.add(listener);
96853
- return () => listeners8.delete(listener);
96913
+ const subscribe2 = (listener) => {
96914
+ listeners9.add(listener);
96915
+ return () => listeners9.delete(listener);
96854
96916
  };
96855
- const api3 = { setState, getState: getState2, getInitialState, subscribe };
96917
+ const api3 = { setState, getState: getState2, getInitialState, subscribe: subscribe2 };
96856
96918
  const initialState = state = createState(setState, getState2, api3);
96857
96919
  return api3;
96858
96920
  };
@@ -99888,13 +99950,13 @@ function compositionAt(comp, t3) {
99888
99950
  else return EMPTY_MOMENT;
99889
99951
  }
99890
99952
  const clip = clips2[index2];
99891
- const current4 = { clip, index: index2, local: clipLocalTime(clip, t3) };
99953
+ const current5 = { clip, index: index2, local: clipLocalTime(clip, t3) };
99892
99954
  const tr = clip.transitionIn;
99893
99955
  const prev = index2 > 0 ? clips2[index2 - 1] : void 0;
99894
- if (!tr || !prev || tr.duration <= 0 || t3 >= clip.start + tr.duration || t3 < clip.start) return { current: current4, previous: null, transition: null };
99956
+ if (!tr || !prev || tr.duration <= 0 || t3 >= clip.start + tr.duration || t3 < clip.start) return { current: current5, previous: null, transition: null };
99895
99957
  const progress2 = evalInterp(tr.interp, (t3 - clip.start) / tr.duration, tr.duration);
99896
99958
  return {
99897
- current: current4,
99959
+ current: current5,
99898
99960
  previous: { clip: prev, index: index2 - 1, local: clipLocalTime(prev, t3) },
99899
99961
  transition: { type: tr.type, progress: progress2, params: tr.params }
99900
99962
  };
@@ -101451,7 +101513,7 @@ function repairStateMachine(raw, markerIds, hasNode) {
101451
101513
  else delete t3.guards;
101452
101514
  return t3;
101453
101515
  });
101454
- const listeners8 = entries4(raw.listeners, (e) => {
101516
+ const listeners9 = entries4(raw.listeners, (e) => {
101455
101517
  if (!STATE_MACHINE_LISTENER_TYPES.includes(e.type)) return null;
101456
101518
  let l = e;
101457
101519
  if (e.layer !== void 0 && !(typeof e.layer === "string" && hasNode(e.layer))) {
@@ -101471,7 +101533,7 @@ function repairStateMachine(raw, markerIds, hasNode) {
101471
101533
  const initial = typeof raw.initial === "string" && states[raw.initial] ? raw.initial : sortedValues(states)[0].id;
101472
101534
  if (id3 !== raw.id || name2 !== raw.name || initial !== raw.initial) changed = true;
101473
101535
  if (!changed) return raw;
101474
- return { id: id3, name: name2, initial, states, transitions, inputs, listeners: listeners8 };
101536
+ return { id: id3, name: name2, initial, states, transitions, inputs, listeners: listeners9 };
101475
101537
  }
101476
101538
  var STATE_MACHINE_INPUT_TYPES, STATE_MACHINE_GUARD_OPS, STATE_MACHINE_ACTION_TYPES, STATE_MACHINE_LISTENER_TYPES, isKeyListener, ANY_STATE, MAX_STEPS2, byId2, sortedValues, machineOf, startValue, isObj3, finite4, isValue, goodId;
101477
101539
  var init_state_machine = __esm({
@@ -247966,6 +248028,7 @@ function repairCompositions(comps, nodes) {
247966
248028
  var isObj5, finite6, optFinite, isVec2, TIMELINE_COLOR_IDS, TIMELINE_COLORS, UNITS, ORDERS, PROP_KEYS, ANIMATOR_ID, MOTION_TYPES, TRANSITIONS, isFraction, MEDIA_HASH;
247967
248029
  var init_invariants = __esm({
247968
248030
  "lib/motion/invariants.ts"() {
248031
+ "use strict";
247969
248032
  init_easing();
247970
248033
  init_properties();
247971
248034
  init_markers();
@@ -249088,6 +249151,7 @@ function beforeWrite() {
249088
249151
  var leave;
249089
249152
  var init_read_only = __esm({
249090
249153
  "lib/editor/modes/read-only.ts"() {
249154
+ "use strict";
249091
249155
  leave = null;
249092
249156
  }
249093
249157
  });
@@ -252159,11 +252223,11 @@ function bufferPolylines(lines2, width) {
252159
252223
  return pieces.map((p2) => [p2[0]]);
252160
252224
  }
252161
252225
  }
252162
- function combineRings(rings, mode) {
252226
+ function combineRings(rings, mode2) {
252163
252227
  const polys = rings.filter((r) => r.length >= 3).map((r) => [r]);
252164
252228
  if (polys.length === 0) return [];
252165
252229
  try {
252166
- return polys.length > 1 ? import_polygon_clipping4.default[mode](polys[0], ...polys.slice(1)) : [polys[0]];
252230
+ return polys.length > 1 ? import_polygon_clipping4.default[mode2](polys[0], ...polys.slice(1)) : [polys[0]];
252167
252231
  } catch {
252168
252232
  return polys.map((p2) => [p2[0]]);
252169
252233
  }
@@ -252177,8 +252241,8 @@ function nodeWorldMultiPoly(doc2, id3) {
252177
252241
  return mp.map((poly) => poly.map((ring) => ring.map(([x2, y]) => place4(x2, y))));
252178
252242
  }
252179
252243
  const rings = nodeWorldRings(doc2, id3);
252180
- const mode = node2.type === "VECTOR" && node2.fillRule === "EVENODD" ? "xor" : "union";
252181
- return combineRings(rings, mode);
252244
+ const mode2 = node2.type === "VECTOR" && node2.fillRule === "EVENODD" ? "xor" : "union";
252245
+ return combineRings(rings, mode2);
252182
252246
  }
252183
252247
  function nodeAreaMultiPoly(doc2, id3) {
252184
252248
  if (!doc2.nodes[id3]) return [];
@@ -253359,17 +253423,17 @@ function packDabs(dabs, frame3, paint, prev) {
253359
253423
  const p2 = worldToLayer(frame3, d.cx, d.cy);
253360
253424
  const round5 = Math.max(0.1, d.roundness ?? 1);
253361
253425
  let rx = d.r * k2, ry = d.r * round5 * k2;
253362
- let mode = 0;
253363
- if (paint.stamp) mode = 2;
253426
+ let mode2 = 0;
253427
+ if (paint.stamp) mode2 = 2;
253364
253428
  else if (paint.tip === "SQUARE") {
253365
- mode = 1;
253429
+ mode2 = 1;
253366
253430
  rx *= 0.85;
253367
253431
  ry *= 0.85;
253368
253432
  } else if (paint.tip === "NIB") {
253369
- mode = 1;
253433
+ mode2 = 1;
253370
253434
  ry *= 0.45;
253371
253435
  } else if (paint.tip === "CHISEL") {
253372
- mode = 1;
253436
+ mode2 = 1;
253373
253437
  ry *= 0.5;
253374
253438
  }
253375
253439
  const angle2 = d.angle - frame3.rotationRad;
@@ -253381,8 +253445,8 @@ function packDabs(dabs, frame3, paint, prev) {
253381
253445
  data[o + 12] = d.charge ?? 1;
253382
253446
  data[o + 13] = (d.travel ?? 0) - frame3.rotationRad;
253383
253447
  data[o + 4] = angle2;
253384
- data[o + 5] = (paint.smudgeStrength !== void 0 || paint.liquify) && mode === 0 ? 0.6 : d.hardness ?? paint.hardness;
253385
- data[o + 6] = mode;
253448
+ data[o + 5] = (paint.smudgeStrength !== void 0 || paint.liquify) && mode2 === 0 ? 0.6 : d.hardness ?? paint.hardness;
253449
+ data[o + 6] = mode2;
253386
253450
  if (paint.cloneOffset) {
253387
253451
  data[o + 8] = paint.cloneOffset.x;
253388
253452
  data[o + 9] = paint.cloneOffset.y;
@@ -253663,12 +253727,12 @@ function selectAll(g) {
253663
253727
  s.fill(1);
253664
253728
  return s;
253665
253729
  }
253666
- function combineSelection(base, next2, mode) {
253667
- if (!base || mode === "REPLACE") return next2;
253730
+ function combineSelection(base, next2, mode2) {
253731
+ if (!base || mode2 === "REPLACE") return next2;
253668
253732
  const out = new Uint8Array(next2.length);
253669
253733
  for (let i2 = 0; i2 < next2.length; i2++) {
253670
253734
  const a = base[i2] ? 1 : 0, b = next2[i2] ? 1 : 0;
253671
- out[i2] = mode === "ADD" ? a | b : mode === "SUBTRACT" ? a & ~b : a & b;
253735
+ out[i2] = mode2 === "ADD" ? a | b : mode2 === "SUBTRACT" ? a & ~b : a & b;
253672
253736
  }
253673
253737
  return out;
253674
253738
  }
@@ -253839,10 +253903,10 @@ function createImageEditSlice(set4, get4) {
253839
253903
  if (!edit) return;
253840
253904
  set4({ imageEdit: { ...edit, ...combine ? { combine } : {}, ...tolerance !== void 0 ? { tolerance } : {} } });
253841
253905
  },
253842
- applySelection: (next2, mode) => {
253906
+ applySelection: (next2, mode2) => {
253843
253907
  const edit = get4().imageEdit;
253844
253908
  if (!edit) return;
253845
- set4({ imageEdit: { ...edit, selection: combineSelection(edit.selection, next2, mode ?? edit.combine) } });
253909
+ set4({ imageEdit: { ...edit, selection: combineSelection(edit.selection, next2, mode2 ?? edit.combine) } });
253846
253910
  },
253847
253911
  selectAllImage: () => {
253848
253912
  const edit = get4().imageEdit;
@@ -254369,15 +254433,15 @@ function createModeSlice(set4, get4) {
254369
254433
  tabOrder: loadTabOrder(),
254370
254434
  stageView: {},
254371
254435
  stageFrameId: null,
254372
- setMode: (mode) => {
254436
+ setMode: (mode2) => {
254373
254437
  const state = get4();
254374
- if (state.mode === mode) return;
254438
+ if (state.mode === mode2) return;
254375
254439
  const st = get4();
254376
254440
  if (st.vectorEditMode) st.exitVectorEditMode?.();
254377
254441
  if (st.pixelEdit) st.exitPixelEdit?.();
254378
254442
  const motion = get4();
254379
254443
  motion.setMotionTarget?.(null);
254380
- const profile = MODE_PROFILES[mode];
254444
+ const profile = MODE_PROFILES[mode2];
254381
254445
  const sides = state.tabSides ?? {};
254382
254446
  const tabs = {};
254383
254447
  const keyOf3 = (tab) => sideOf(sides, tab) === "left" ? "leftTab" : "rightTab";
@@ -254390,7 +254454,7 @@ function createModeSlice(set4, get4) {
254390
254454
  tabs[keyOf3(previous)] = side === sideOf(sides, "composition") ? "composition" : tabsOn(sides, side, state.tabOrder)[0] ?? previous;
254391
254455
  }
254392
254456
  set4({
254393
- mode,
254457
+ mode: mode2,
254394
254458
  ...tabs,
254395
254459
  // Tools do not survive a mode switch: PopCorn's washi used to stay armed in Design, where nothing
254396
254460
  // could draw it. The toolset that owns the tool is the only place it is reachable. The mode says
@@ -254434,9 +254498,9 @@ function createModeSlice(set4, get4) {
254434
254498
  }
254435
254499
  set4(patch2);
254436
254500
  },
254437
- setStageView: (on, mode) => {
254501
+ setStageView: (on, mode2) => {
254438
254502
  const state = get4();
254439
- const m = mode ?? state.mode;
254503
+ const m = mode2 ?? state.mode;
254440
254504
  if (!!state.stageView[m] === on) return;
254441
254505
  set4({ stageView: { ...state.stageView, [m]: on } });
254442
254506
  },
@@ -254930,25 +254994,25 @@ function createPixelSlice(set4, get4) {
254930
254994
  commit(id3, { palette: clean3 }, "Edit palette");
254931
254995
  },
254932
254996
  /** Switch color mode, converting every frame (and tile): quantize to palette / luminance. */
254933
- pixelSetColorMode: (id3, mode) => {
254997
+ pixelSetColorMode: (id3, mode2) => {
254934
254998
  const n = node2(id3);
254935
- if (!n || n.colorMode === mode) return;
254999
+ if (!n || n.colorMode === mode2) return;
254936
255000
  const count2 = n.pixelWidth * n.pixelHeight;
254937
255001
  let palette2 = n.palette;
254938
- if (mode === "INDEXED" && palette2.length < 2) {
255002
+ if (mode2 === "INDEXED" && palette2.length < 2) {
254939
255003
  const all4 = new Uint32Array(count2 * n.frames.length);
254940
255004
  n.frames.forEach((_, i2) => all4.set(frameRGBA(n, i2), i2 * count2));
254941
255005
  palette2 = extractPalette(all4, 256).map(packedToHex);
254942
255006
  }
254943
- const conv = (b64, cellCount) => encodeCels(convertCels(decodeCels(b64, cellCount), n.colorMode, mode, n.palette, palette2, n.transparentIndex));
254944
- const patch2 = { colorMode: mode, palette: palette2 };
255007
+ const conv = (b64, cellCount) => encodeCels(convertCels(decodeCels(b64, cellCount), n.colorMode, mode2, n.palette, palette2, n.transparentIndex));
255008
+ const patch2 = { colorMode: mode2, palette: palette2 };
254945
255009
  if (n.tileset) {
254946
255010
  const tc = n.tileset.tileW * n.tileset.tileH;
254947
255011
  patch2.tileset = { ...n.tileset, tiles: n.tileset.tiles.map((t3) => conv(t3, tc)) };
254948
255012
  } else {
254949
255013
  patch2.frames = n.frames.map((f2) => ({ ...f2, cels: conv(f2.cels, count2) }));
254950
255014
  }
254951
- commit(id3, patch2, `Color mode: ${mode.toLowerCase()}`);
255015
+ commit(id3, patch2, `Color mode: ${mode2.toLowerCase()}`);
254952
255016
  },
254953
255017
  /** Dedupe the canvas into a tileset + per-frame tile maps (Aseprite "convert to tilemap"). */
254954
255018
  pixelConvertToTilemap: (id3, tileW, tileH) => {
@@ -256883,9 +256947,9 @@ function presenceChanges(prev, next2) {
256883
256947
  for (const [id3, name2] of before) if (!after.has(id3)) out.push(t2("a11y.personLeft", { name: name2 }));
256884
256948
  return out;
256885
256949
  }
256886
- function announcePresence(subscribe) {
256950
+ function announcePresence(subscribe2) {
256887
256951
  let last3 = null;
256888
- return subscribe((people) => {
256952
+ return subscribe2((people) => {
256889
256953
  if (last3) for (const m of presenceChanges(last3, people)) announce(m);
256890
256954
  last3 = people;
256891
256955
  });
@@ -257026,6 +257090,7 @@ function followPeers(peers) {
257026
257090
  var PALETTE, usePresence, awareness, CURSOR_SEND_MS, VIEWPORT_SEND_MS, cursorTimer, pendingCursor, sentCursor, EMOTE_MS, lastFollowCamera;
257027
257091
  var init_presence = __esm({
257028
257092
  "lib/collab/presence.ts"() {
257093
+ "use strict";
257029
257094
  init_esm();
257030
257095
  init_editor_store();
257031
257096
  init_status_announcements();
@@ -257922,7 +257987,7 @@ function documentPath(opts) {
257922
257987
  }
257923
257988
  function tabChannel() {
257924
257989
  if (!isDesktopTabs() || typeof BroadcastChannel === "undefined") return null;
257925
- return channel ??= new BroadcastChannel(CHANNEL);
257990
+ return channel2 ??= new BroadcastChannel(CHANNEL2);
257926
257991
  }
257927
257992
  function postTabMessage(msg) {
257928
257993
  tabChannel()?.postMessage(msg);
@@ -257935,15 +258000,15 @@ function onTabMessage(fn) {
257935
258000
  ch.addEventListener("message", handler);
257936
258001
  return () => ch.removeEventListener("message", handler);
257937
258002
  }
257938
- var EDITOR_HOME, localDocPath, cloudFilePath, CHANNEL, channel;
258003
+ var EDITOR_HOME, localDocPath, cloudFilePath, CHANNEL2, channel2;
257939
258004
  var init_tab_mode = __esm({
257940
258005
  "lib/desktop/tab-mode.ts"() {
257941
258006
  "use strict";
257942
258007
  EDITOR_HOME = "/home";
257943
258008
  localDocPath = (docId) => `${EDITOR_HOME}?doc=${encodeURIComponent(docId)}`;
257944
258009
  cloudFilePath = (key5) => `/pop/${encodeURIComponent(key5)}`;
257945
- CHANNEL = "popcraft-desktop-tabs";
257946
- channel = null;
258010
+ CHANNEL2 = "popcraft-desktop-tabs";
258011
+ channel2 = null;
257947
258012
  }
257948
258013
  });
257949
258014
 
@@ -258880,17 +258945,17 @@ function setModifierParam(track2, id3, name2, value3) {
258880
258945
  return next2;
258881
258946
  });
258882
258947
  }
258883
- function setLoopMode(track2, id3, mode) {
258884
- return change(track2, id3, (m) => m.kind === "loop" && m.mode !== mode ? { ...m, mode } : m);
258948
+ function setLoopMode(track2, id3, mode2) {
258949
+ return change(track2, id3, (m) => m.kind === "loop" && m.mode !== mode2 ? { ...m, mode: mode2 } : m);
258885
258950
  }
258886
258951
  function setAudioSignal(track2, id3, signal) {
258887
258952
  return change(track2, id3, (m) => m.kind === "audio" && m.signal !== signal ? { ...m, signal, ...signal === "spectrum" && m.bin === void 0 ? { bin: 0.25 } : {} } : m);
258888
258953
  }
258889
- function setAudioMode(track2, id3, mode) {
258954
+ function setAudioMode(track2, id3, mode2) {
258890
258955
  return change(track2, id3, (m) => {
258891
- if (m.kind !== "audio" || (m.mode ?? "add") === mode) return m;
258892
- const next2 = { ...m, mode };
258893
- if (mode === "add") delete next2.mode;
258956
+ if (m.kind !== "audio" || (m.mode ?? "add") === mode2) return m;
258957
+ const next2 = { ...m, mode: mode2 };
258958
+ if (mode2 === "add") delete next2.mode;
258894
258959
  return next2;
258895
258960
  });
258896
258961
  }
@@ -260241,10 +260306,10 @@ var init_autokey = __esm({
260241
260306
  });
260242
260307
 
260243
260308
  // lib/motion/key-selection.ts
260244
- function selectKeys(sel, refs, mode) {
260245
- if (mode === "replace") return dedupe2(refs);
260309
+ function selectKeys(sel, refs, mode2) {
260310
+ if (mode2 === "replace") return dedupe2(refs);
260246
260311
  const have = new Set(sel.map(keyRefId));
260247
- if (mode === "toggle" && refs.length && refs.every((r) => have.has(keyRefId(r)))) {
260312
+ if (mode2 === "toggle" && refs.length && refs.every((r) => have.has(keyRefId(r)))) {
260248
260313
  const drop = new Set(refs.map(keyRefId));
260249
260314
  return sel.filter((r) => !drop.has(keyRefId(r)));
260250
260315
  }
@@ -260863,8 +260928,8 @@ function createMotionSlice(set4, get4) {
260863
260928
  const tr = get4().transport;
260864
260929
  if (tr.playing && !tr.loop && tr.end > 0 && transportTime(tr, now2) >= tr.end) put3({ playing: false, playAnchor: null, time: tr.end });
260865
260930
  },
260866
- selectKeys: (refs, mode = "replace") => {
260867
- const next2 = selectKeys(liveKeys(), refs, mode);
260931
+ selectKeys: (refs, mode2 = "replace") => {
260932
+ const next2 = selectKeys(liveKeys(), refs, mode2);
260868
260933
  const cur = get4().keySelection;
260869
260934
  if (next2.length || cur.length) set4({ keySelection: next2 });
260870
260935
  },
@@ -261711,8 +261776,8 @@ function scopeOf(doc2, key5, record2) {
261711
261776
  const c2 = r && doc2.collections?.[r.collectionId];
261712
261777
  return withKey(r && c2 ? itemScope(c2, r, vars) : vars, key5);
261713
261778
  }
261714
- function setVariableValue(action3, variable, current4, doc2, key5, record2) {
261715
- if (action3.variableToggle) return !current4;
261779
+ function setVariableValue(action3, variable, current5, doc2, key5, record2) {
261780
+ if (action3.variableToggle) return !current5;
261716
261781
  if (action3.variableExpression !== void 0 && action3.variableExpression.trim()) {
261717
261782
  const v = tryEvaluate(action3.variableExpression, scopeOf(doc2, key5, record2));
261718
261783
  return v === void 0 ? void 0 : coerceToVariable(variable.type, v);
@@ -261737,14 +261802,14 @@ function glideValue(g, now2) {
261737
261802
  const k2 = g.duration > 0 ? Math.min(1, Math.max(0, (now2 - g.at) / g.duration)) : 1;
261738
261803
  return g.from + (g.to - g.from) * ease(k2, g.easing, g.duration, g.spring);
261739
261804
  }
261740
- function startGlide(glides, id3, mode, from2, to, transition2, now2) {
261805
+ function startGlide(glides, id3, mode2, from2, to, transition2, now2) {
261741
261806
  const rest = { ...glides ?? {} };
261742
261807
  delete rest[id3];
261743
261808
  const duration3 = transition2?.duration ?? 0;
261744
261809
  const prev = glides?.[id3];
261745
- const start2 = prev && prev.mode === mode ? glideValue(prev, now2) : from2;
261810
+ const start2 = prev && prev.mode === mode2 ? glideValue(prev, now2) : from2;
261746
261811
  if (!(duration3 > 0) || typeof start2 !== "number" || typeof to !== "number" || start2 === to) return Object.keys(rest).length ? rest : null;
261747
- return { ...rest, [id3]: { mode, from: start2, to, at: now2, duration: duration3, easing: transition2.easing, ...transition2.spring ? { spring: transition2.spring } : {} } };
261812
+ return { ...rest, [id3]: { mode: mode2, from: start2, to, at: now2, duration: duration3, easing: transition2.easing, ...transition2.spring ? { spring: transition2.spring } : {} } };
261748
261813
  }
261749
261814
  var init_variable_glides = __esm({
261750
261815
  "lib/motion/variable-glides.ts"() {
@@ -261759,7 +261824,7 @@ function scrollerOf(nodes, id3) {
261759
261824
  for (let cur = nodes[id3]?.parentId; cur; cur = nodes[cur]?.parentId) if (scrolls(nodes[cur])) return cur;
261760
261825
  return null;
261761
261826
  }
261762
- function placed(doc2, frameId, current4, x2, y) {
261827
+ function placed(doc2, frameId, current5, x2, y) {
261763
261828
  const node2 = doc2.nodes[frameId];
261764
261829
  if (!scrolls(node2)) return null;
261765
261830
  const bounds2 = getNodeBounds(doc2, frameId);
@@ -261767,8 +261832,8 @@ function placed(doc2, frameId, current4, x2, y) {
261767
261832
  const maxX = Math.max(0, bounds2.width - node2.width);
261768
261833
  const maxY = Math.max(0, bounds2.height - node2.height);
261769
261834
  return {
261770
- x: node2.overflowScrolling === "HORIZONTAL" || node2.overflowScrolling === "BOTH" ? Math.max(0, Math.min(maxX, x2)) : current4.x,
261771
- y: node2.overflowScrolling === "VERTICAL" || node2.overflowScrolling === "BOTH" ? Math.max(0, Math.min(maxY, y)) : current4.y
261835
+ x: node2.overflowScrolling === "HORIZONTAL" || node2.overflowScrolling === "BOTH" ? Math.max(0, Math.min(maxX, x2)) : current5.x,
261836
+ y: node2.overflowScrolling === "VERTICAL" || node2.overflowScrolling === "BOTH" ? Math.max(0, Math.min(maxY, y)) : current5.y
261772
261837
  };
261773
261838
  }
261774
261839
  function scrollBy(state, frameId, dx, dy) {
@@ -262471,7 +262536,7 @@ var init_plugin_store = __esm({
262471
262536
  toasts: [],
262472
262537
  permissionPrompt: null,
262473
262538
  managerOpen: false,
262474
- setInstalled: (installed3) => set4({ installed: installed3 }),
262539
+ setInstalled: (installed4) => set4({ installed: installed4 }),
262475
262540
  setManagerOpen: (managerOpen) => set4({ managerOpen }),
262476
262541
  upsertSession: (s) => set4((st) => ({ sessions: [...st.sessions.filter((x2) => x2.sessionId !== s.sessionId), s] })),
262477
262542
  patchSession: (sessionId, patch2) => set4((st) => ({ sessions: st.sessions.map((x2) => x2.sessionId === sessionId ? { ...x2, ...patch2 } : x2) })),
@@ -262575,6 +262640,7 @@ function formatDate(date5, opts = { month: "short", day: "numeric", year: "numer
262575
262640
  var cache5, nf;
262576
262641
  var init_format = __esm({
262577
262642
  "lib/i18n/format.ts"() {
262643
+ "use strict";
262578
262644
  init_runtime();
262579
262645
  cache5 = /* @__PURE__ */ new Map();
262580
262646
  nf = (opts) => cached2("n", opts, (l) => new Intl.NumberFormat(l, opts));
@@ -271632,11 +271698,11 @@ function repairTree(nodes, pages2) {
271632
271698
  });
271633
271699
  if (keep.length !== kids.length) put3({ ...node2, childIds: keep });
271634
271700
  }
271635
- const current4 = out ?? nodes;
271636
- for (const id3 in current4) {
271637
- const node2 = current4[id3];
271701
+ const current5 = out ?? nodes;
271702
+ for (const id3 in current5) {
271703
+ const node2 = current5[id3];
271638
271704
  if (pages2.includes(id3)) continue;
271639
- const parents = (listedBy.get(id3) ?? []).filter((p2) => (current4[p2].childIds ?? []).includes(id3));
271705
+ const parents = (listedBy.get(id3) ?? []).filter((p2) => (current5[p2].childIds ?? []).includes(id3));
271640
271706
  const parent = parents[0] ?? null;
271641
271707
  if (parent && node2.parentId !== parent) put3({ ...node2, parentId: parent });
271642
271708
  }
@@ -271682,7 +271748,7 @@ function finishDocument(ydoc, base, nodes) {
271682
271748
  }
271683
271749
  return doc2;
271684
271750
  }
271685
- function applyYEventsToDocument(ydoc, current4, events) {
271751
+ function applyYEventsToDocument(ydoc, current5, events) {
271686
271752
  const ynodes = yNodes(ydoc);
271687
271753
  const touched = /* @__PURE__ */ new Set();
271688
271754
  let structure = false;
@@ -271700,9 +271766,9 @@ function applyYEventsToDocument(ydoc, current4, events) {
271700
271766
  structure = true;
271701
271767
  }
271702
271768
  }
271703
- let nodes = current4.nodes;
271769
+ let nodes = current5.nodes;
271704
271770
  if (touched.size) {
271705
- nodes = { ...current4.nodes };
271771
+ nodes = { ...current5.nodes };
271706
271772
  for (const id3 of touched) {
271707
271773
  if (!isSafeKey(id3)) continue;
271708
271774
  const ynode = ynodes.get(id3);
@@ -271710,9 +271776,9 @@ function applyYEventsToDocument(ydoc, current4, events) {
271710
271776
  else delete nodes[id3];
271711
271777
  }
271712
271778
  }
271713
- if (!touched.size && !structure) return current4;
271714
- if (!structure && !tree) return { ...current4, nodes };
271715
- return finishDocument(ydoc, current4, nodes);
271779
+ if (!touched.size && !structure) return current5;
271780
+ if (!structure && !tree) return { ...current5, nodes };
271781
+ return finishDocument(ydoc, current5, nodes);
271716
271782
  }
271717
271783
  var LOCAL_ORIGIN, RECORD_FIELDS, META_FIELDS, sameSyncedFields, yRecordMaps, TRACK_PREFIX, MACHINE_PARTS, MACHINE_PREFIX, MAX_DOC_NAME, UNSAFE_KEYS, isSafeKey, yNodes, yPages, yMeta;
271718
271784
  var init_ydoc = __esm({
@@ -272895,12 +272961,12 @@ function startCollabSession(docId, opts) {
272895
272961
  if (!bound || tr.origin === LOCAL_ORIGIN || !isActive()) return;
272896
272962
  if (useEditorStore.getState().isVersionHistoryMode) return;
272897
272963
  if (sendTimer) flush();
272898
- const current4 = useEditorStore.getState().document;
272899
- const sharedCurrent = withoutPrivate(current4);
272964
+ const current5 = useEditorStore.getState().document;
272965
+ const sharedCurrent = withoutPrivate(current5);
272900
272966
  const shared = applyYEventsToDocument(ydoc, sharedCurrent, events);
272901
272967
  if (shared === sharedCurrent) return;
272902
- const next2 = repairDocumentPaints(migrateDocumentMotion(restorePrivate(shared, current4)));
272903
- if (!(tr.origin instanceof UndoManager)) noteRemoteChanges(current4, next2, changedIds(current4, next2, events));
272968
+ const next2 = repairDocumentPaints(migrateDocumentMotion(restorePrivate(shared, current5)));
272969
+ if (!(tr.origin instanceof UndoManager)) noteRemoteChanges(current5, next2, changedIds(current5, next2, events));
272904
272970
  if (typeof window !== "undefined") window.dispatchEvent(new CustomEvent("popcraft-media-retry"));
272905
272971
  applyingRemote = true;
272906
272972
  synced = shared;
@@ -273038,9 +273104,9 @@ function withDeadline(p2, ms2) {
273038
273104
  return Promise.race([p2, deadline]).finally(() => clearTimeout(timer));
273039
273105
  }
273040
273106
  async function trackOpen(run4, opts = {}) {
273041
- const current4 = useOpenProgress.getState().open;
273042
- if (current4 && !current4.error) {
273043
- const joined = { stage: (s) => patch(current4.id, { stage: s }) };
273107
+ const current5 = useOpenProgress.getState().open;
273108
+ if (current5 && !current5.error) {
273109
+ const joined = { stage: (s) => patch(current5.id, { stage: s }) };
273044
273110
  return run4(joined);
273045
273111
  }
273046
273112
  const id3 = nextId++;
@@ -274311,9 +274377,9 @@ function changedBox(a, b, width) {
274311
274377
  }
274312
274378
  function createGifEncoder(width, height, opts, shared) {
274313
274379
  const gif = (0, import_gifenc.GIFEncoder)();
274314
- const mode = opts.palette ?? "global";
274380
+ const mode2 = opts.palette ?? "global";
274315
274381
  const dither = opts.dither ?? "none";
274316
- const incremental = mode === "global" && !!shared;
274382
+ const incremental = mode2 === "global" && !!shared;
274317
274383
  let n = 0;
274318
274384
  let pending8 = null;
274319
274385
  let canvas = null;
@@ -274326,7 +274392,7 @@ function createGifEncoder(width, height, opts, shared) {
274326
274392
  const flush = (keep) => {
274327
274393
  const p2 = pending8;
274328
274394
  if (!p2) return new Uint8Array(0);
274329
- const own2 = mode === "per-frame" || n === 0;
274395
+ const own2 = mode2 === "per-frame" || n === 0;
274330
274396
  gif.writeFrame(p2.idx, p2.w, p2.h, {
274331
274397
  palette: own2 ? p2.palette.colors : void 0,
274332
274398
  delay: p2.delay,
@@ -274348,7 +274414,7 @@ function createGifEncoder(width, height, opts, shared) {
274348
274414
  return {
274349
274415
  frame(rgba, delay3) {
274350
274416
  let palette2 = shared;
274351
- if (mode === "per-frame" || !palette2) {
274417
+ if (mode2 === "per-frame" || !palette2) {
274352
274418
  const c2 = new PaletteCounter();
274353
274419
  c2.add(rgba);
274354
274420
  palette2 = c2.palette();
@@ -275380,18 +275446,18 @@ var init_misc = __esm({
275380
275446
  /** @internal */
275381
275447
  _emit(...args2) {
275382
275448
  const [event, data] = args2;
275383
- const listeners8 = this._listeners.get(event);
275384
- if (!listeners8) {
275449
+ const listeners9 = this._listeners.get(event);
275450
+ if (!listeners9) {
275385
275451
  return;
275386
275452
  }
275387
- for (const entry of listeners8) {
275453
+ for (const entry of listeners9) {
275388
275454
  try {
275389
275455
  entry.fn(data);
275390
275456
  } catch (error62) {
275391
275457
  console.error(error62);
275392
275458
  }
275393
275459
  if (entry.once) {
275394
- listeners8.delete(entry);
275460
+ listeners9.delete(entry);
275395
275461
  }
275396
275462
  }
275397
275463
  }
@@ -279554,8 +279620,8 @@ var init_mp3_misc = __esm({
279554
279620
  return 12 * bitrate / sampleRate * 4;
279555
279621
  }
279556
279622
  };
279557
- getXingOffset = (mpegVersionId, channel3) => {
279558
- return mpegVersionId === 3 ? channel3 === 3 ? 21 : 36 : channel3 === 3 ? 13 : 21;
279623
+ getXingOffset = (mpegVersionId, channel4) => {
279624
+ return mpegVersionId === 3 ? channel4 === 3 ? 21 : 36 : channel4 === 3 ? 13 : 21;
279559
279625
  };
279560
279626
  readMp3FrameHeader = (word, remainingBytes) => {
279561
279627
  const firstByte = word >>> 24;
@@ -279587,7 +279653,7 @@ var init_mp3_misc = __esm({
279587
279653
  const bitrateIndex = thirdByte >> 4 & 15;
279588
279654
  const frequencyIndex = (thirdByte >> 2 & 3) % 3;
279589
279655
  const padding3 = thirdByte >> 1 & 1;
279590
- const channel3 = fourthByte >> 6 & 3;
279656
+ const channel4 = fourthByte >> 6 & 3;
279591
279657
  const modeExtension = fourthByte >> 4 & 3;
279592
279658
  const copyright = fourthByte >> 3 & 1;
279593
279659
  const original = fourthByte >> 2 & 1;
@@ -279623,7 +279689,7 @@ var init_mp3_misc = __esm({
279623
279689
  bitrate,
279624
279690
  frequencyIndex,
279625
279691
  sampleRate,
279626
- channel: channel3,
279692
+ channel: channel4,
279627
279693
  modeExtension,
279628
279694
  copyright,
279629
279695
  original,
@@ -279648,8 +279714,8 @@ var init_mp3_misc = __esm({
279648
279714
  XingFlags2[XingFlags2["FileSize"] = 2] = "FileSize";
279649
279715
  XingFlags2[XingFlags2["Toc"] = 4] = "Toc";
279650
279716
  })(XingFlags || (XingFlags = {}));
279651
- getMp3ChannelCount = (channel3) => {
279652
- return channel3 === 3 ? 1 : 2;
279717
+ getMp3ChannelCount = (channel4) => {
279718
+ return channel4 === 3 ? 1 : 2;
279653
279719
  };
279654
279720
  }
279655
279721
  });
@@ -290406,10 +290472,10 @@ var init_mpeg_ts_demuxer = __esm({
290406
290472
  return true;
290407
290473
  }
290408
290474
  async ensureCurrentPacketHasNext() {
290409
- const current4 = this.decodeOrderPackets[0];
290410
- assert2(current4);
290475
+ const current5 = this.decodeOrderPackets[0];
290476
+ assert2(current5);
290411
290477
  while (true) {
290412
- const presentationIndex = this.presentationOrderPackets.indexOf(current4);
290478
+ const presentationIndex = this.presentationOrderPackets.indexOf(current5);
290413
290479
  if (presentationIndex !== -1 && presentationIndex <= this.presentationOrderPackets.length - 2) {
290414
290480
  break;
290415
290481
  }
@@ -295725,8 +295791,8 @@ var init_sample2 = __esm({
295725
295791
  while (remainingFrames > 0) {
295726
295792
  const framesToCopy = Math.min(maxFramesPerChunk, remainingFrames);
295727
295793
  const chunkData = new Float32Array(numberOfChannels * framesToCopy);
295728
- for (let channel3 = 0; channel3 < numberOfChannels; channel3++) {
295729
- audioBuffer.copyFromChannel(chunkData.subarray(channel3 * framesToCopy, (channel3 + 1) * framesToCopy), channel3, currentRelativeFrame);
295794
+ for (let channel4 = 0; channel4 < numberOfChannels; channel4++) {
295795
+ audioBuffer.copyFromChannel(chunkData.subarray(channel4 * framesToCopy, (channel4 + 1) * framesToCopy), channel4, currentRelativeFrame);
295730
295796
  }
295731
295797
  yield new _AudioSample({
295732
295798
  format: "f32-planar",
@@ -295759,8 +295825,8 @@ var init_sample2 = __esm({
295759
295825
  while (remainingFrames > 0) {
295760
295826
  const framesToCopy = Math.min(maxFramesPerChunk, remainingFrames);
295761
295827
  const chunkData = new Float32Array(numberOfChannels * framesToCopy);
295762
- for (let channel3 = 0; channel3 < numberOfChannels; channel3++) {
295763
- audioBuffer.copyFromChannel(chunkData.subarray(channel3 * framesToCopy, (channel3 + 1) * framesToCopy), channel3, currentRelativeFrame);
295828
+ for (let channel4 = 0; channel4 < numberOfChannels; channel4++) {
295829
+ audioBuffer.copyFromChannel(chunkData.subarray(channel4 * framesToCopy, (channel4 + 1) * framesToCopy), channel4, currentRelativeFrame);
295764
295830
  }
295765
295831
  const audioSample = new _AudioSample({
295766
295832
  format: "f32-planar",
@@ -309668,11 +309734,11 @@ function pathBounds(paths) {
309668
309734
  }
309669
309735
  return minX === Infinity ? null : { minX, minY, maxX, maxY };
309670
309736
  }
309671
- function parseColor2(input2, current4) {
309737
+ function parseColor2(input2, current5) {
309672
309738
  if (!input2) return null;
309673
309739
  const s = input2.trim().toLowerCase();
309674
309740
  if (!s || s === "none" || s === "transparent") return null;
309675
- if (s === "currentcolor") return current4 ?? { r: 0, g: 0, b: 0, a: 1 };
309741
+ if (s === "currentcolor") return current5 ?? { r: 0, g: 0, b: 0, a: 1 };
309676
309742
  const hex10 = s.startsWith("#") ? s.slice(1) : NAMED[s];
309677
309743
  if (hex10 && /^[0-9a-f]+$/.test(hex10)) {
309678
309744
  const full = hex10.length <= 4 ? hex10.split("").map((c2) => c2 + c2).join("") : hex10;
@@ -311145,8 +311211,8 @@ function reflectUrl() {
311145
311211
  const base = documentPath({ linkKey: activeLink?.key, localDocId });
311146
311212
  const atSameAddress = window.location.pathname === base.split("?")[0];
311147
311213
  const path = atSameAddress ? withDeepLink(base, parseDeepLink(window.location.search)) : base;
311148
- const current4 = window.location.pathname + (isDesktopTabs() || localDocId || path.includes("?") ? window.location.search : "");
311149
- if (current4 !== path) window.history.replaceState(null, "", path);
311214
+ const current5 = window.location.pathname + (isDesktopTabs() || localDocId || path.includes("?") ? window.location.search : "");
311215
+ if (current5 !== path) window.history.replaceState(null, "", path);
311150
311216
  }
311151
311217
  function onSyncStatus(fn) {
311152
311218
  statusListeners.add(fn);
@@ -311801,7 +311867,6 @@ async function dispatchShaped(key5, options) {
311801
311867
  var onViolation;
311802
311868
  var init_dispatch = __esm({
311803
311869
  "lib/commands/dispatch.ts"() {
311804
- "use strict";
311805
311870
  init_errors();
311806
311871
  init_registry();
311807
311872
  init_confirm();
@@ -312981,6 +313046,7 @@ function areaBounds(rings) {
312981
313046
  }
312982
313047
  var init_text_area = __esm({
312983
313048
  "lib/engine/text/text-area.ts"() {
313049
+ "use strict";
312984
313050
  }
312985
313051
  });
312986
313052
 
@@ -313014,7 +313080,7 @@ function fitsContainer(result, node2) {
313014
313080
  if (node2.textAutoResize === "HEIGHT") return result.lines.length <= (node2.characters ?? "").split("\n").length;
313015
313081
  return result.contentHeight <= node2.height + 0.5;
313016
313082
  }
313017
- function fitLayout(node2, mode, run4) {
313083
+ function fitLayout(node2, mode2, run4) {
313018
313084
  const cache11 = /* @__PURE__ */ new Map();
313019
313085
  const at4 = (s) => {
313020
313086
  let r = cache11.get(s);
@@ -313027,7 +313093,7 @@ function fitLayout(node2, mode, run4) {
313027
313093
  const ok2 = (s) => fitsContainer(at4(s), node2);
313028
313094
  let lo, hi;
313029
313095
  if (ok2(1)) {
313030
- if (mode === "SHRINK") return { ...at4(1), fitScale: 1 };
313096
+ if (mode2 === "SHRINK") return { ...at4(1), fitScale: 1 };
313031
313097
  lo = 1;
313032
313098
  hi = 2;
313033
313099
  while (hi < MAX_SCALE && ok2(hi)) {
@@ -313244,10 +313310,10 @@ function layoutTextUncached(node2, atlas, cameraZoom = 1) {
313244
313310
  return bestResult || layoutTextUncached({ ...node2, __isAutosizing: true, fontSize: 2 }, atlas, cameraZoom);
313245
313311
  }
313246
313312
  if (!isSticky && node2.__fitScale === void 0) {
313247
- const mode = fitModeOf(node2);
313248
- if (mode) {
313313
+ const mode2 = fitModeOf(node2);
313314
+ if (mode2) {
313249
313315
  const area4 = !node2.textPath && node2.textAreaRings?.length;
313250
- const best = fitLayout(node2, mode, (n, s) => layoutTextUncached({ ...n, __fitScale: s, ...area4 ? { __areaShift: 0 } : {} }, atlas, cameraZoom));
313316
+ const best = fitLayout(node2, mode2, (n, s) => layoutTextUncached({ ...n, __fitScale: s, ...area4 ? { __areaShift: 0 } : {} }, atlas, cameraZoom));
313251
313317
  if (!area4 || (node2.textVerticalAlign || node2.verticalAlign || "TOP") === "TOP") return best;
313252
313318
  return { ...layoutAreaAligned({ ...scaleTypography(node2, best.fitScale), __fitScale: best.fitScale }, atlas, cameraZoom), fitScale: best.fitScale };
313253
313319
  }
@@ -315468,25 +315534,25 @@ function effectFilter(node2, ctx2, totalMat) {
315468
315534
  const sigma = (blur) => Math.max(0.5, blur / 3);
315469
315535
  const id3 = uid(ctx2, "fx");
315470
315536
  let parts = "";
315471
- let current4 = "SourceGraphic";
315537
+ let current5 = "SourceGraphic";
315472
315538
  if (drop) {
315473
315539
  const [dx, dy] = localOffset(drop.offset.x, drop.offset.y);
315474
315540
  const spread2 = drop.spread || 0;
315475
315541
  const knock = drop.showBehindTransparent === false;
315476
315542
  if (!spread2 && !knock) {
315477
- parts += `<feDropShadow in="${current4}" dx="${fmt2(dx)}" dy="${fmt2(dy)}" stdDeviation="${fmt2(sigma(drop.blur))}" flood-color="${colorToSVG(drop.color)}" flood-opacity="${fmt2(drop.color.a ?? 1)}" result="withdrop"/>`;
315543
+ parts += `<feDropShadow in="${current5}" dx="${fmt2(dx)}" dy="${fmt2(dy)}" stdDeviation="${fmt2(sigma(drop.blur))}" flood-color="${colorToSVG(drop.color)}" flood-opacity="${fmt2(drop.color.a ?? 1)}" result="withdrop"/>`;
315478
315544
  } else {
315479
- parts += (spread2 ? `<feMorphology in="SourceAlpha" operator="${spread2 > 0 ? "dilate" : "erode"}" radius="${fmt2(Math.abs(spread2))}" result="dropspread"/>` : "") + `<feGaussianBlur in="${spread2 ? "dropspread" : "SourceAlpha"}" stdDeviation="${fmt2(drop.blur > 0 ? sigma(drop.blur) : 0)}" result="dropblur"/><feOffset in="dropblur" dx="${fmt2(dx)}" dy="${fmt2(dy)}" result="dropoff"/><feFlood flood-color="${colorToSVG(drop.color)}" flood-opacity="${fmt2(drop.color.a ?? 1)}" result="dropcol"/><feComposite in="dropcol" in2="dropoff" operator="in" result="dropshadow"/>` + (knock ? `<feComposite in="dropshadow" in2="SourceAlpha" operator="out" result="dropshadow"/>` : "") + `<feMerge result="withdrop"><feMergeNode in="dropshadow"/><feMergeNode in="${current4}"/></feMerge>`;
315545
+ parts += (spread2 ? `<feMorphology in="SourceAlpha" operator="${spread2 > 0 ? "dilate" : "erode"}" radius="${fmt2(Math.abs(spread2))}" result="dropspread"/>` : "") + `<feGaussianBlur in="${spread2 ? "dropspread" : "SourceAlpha"}" stdDeviation="${fmt2(drop.blur > 0 ? sigma(drop.blur) : 0)}" result="dropblur"/><feOffset in="dropblur" dx="${fmt2(dx)}" dy="${fmt2(dy)}" result="dropoff"/><feFlood flood-color="${colorToSVG(drop.color)}" flood-opacity="${fmt2(drop.color.a ?? 1)}" result="dropcol"/><feComposite in="dropcol" in2="dropoff" operator="in" result="dropshadow"/>` + (knock ? `<feComposite in="dropshadow" in2="SourceAlpha" operator="out" result="dropshadow"/>` : "") + `<feMerge result="withdrop"><feMergeNode in="dropshadow"/><feMergeNode in="${current5}"/></feMerge>`;
315480
315546
  }
315481
- current4 = "withdrop";
315547
+ current5 = "withdrop";
315482
315548
  }
315483
315549
  if (inner) {
315484
315550
  const [dx, dy] = localOffset(inner.offset.x, inner.offset.y);
315485
315551
  const spread2 = inner.spread || 0;
315486
- parts += `<feComponentTransfer in="SourceAlpha" result="inv"><feFuncA type="table" tableValues="1 0"/></feComponentTransfer>` + (spread2 > 0 ? `<feMorphology in="inv" operator="dilate" radius="${fmt2(spread2)}" result="inv"/>` : "") + `<feGaussianBlur in="inv" stdDeviation="${fmt2(sigma(inner.blur))}" result="innerblur"/><feOffset in="innerblur" dx="${fmt2(dx)}" dy="${fmt2(dy)}" result="inneroff"/><feComposite in="inneroff" in2="SourceAlpha" operator="in" result="innermask"/><feFlood flood-color="${colorToSVG(inner.color)}" flood-opacity="${fmt2(inner.color.a ?? 1)}" result="innercol"/><feComposite in="innercol" in2="innermask" operator="in" result="inner"/><feMerge result="withinner"><feMergeNode in="${current4}"/><feMergeNode in="inner"/></feMerge>`;
315487
- current4 = "withinner";
315552
+ parts += `<feComponentTransfer in="SourceAlpha" result="inv"><feFuncA type="table" tableValues="1 0"/></feComponentTransfer>` + (spread2 > 0 ? `<feMorphology in="inv" operator="dilate" radius="${fmt2(spread2)}" result="inv"/>` : "") + `<feGaussianBlur in="inv" stdDeviation="${fmt2(sigma(inner.blur))}" result="innerblur"/><feOffset in="innerblur" dx="${fmt2(dx)}" dy="${fmt2(dy)}" result="inneroff"/><feComposite in="inneroff" in2="SourceAlpha" operator="in" result="innermask"/><feFlood flood-color="${colorToSVG(inner.color)}" flood-opacity="${fmt2(inner.color.a ?? 1)}" result="innercol"/><feComposite in="innercol" in2="innermask" operator="in" result="inner"/><feMerge result="withinner"><feMergeNode in="${current5}"/><feMergeNode in="inner"/></feMerge>`;
315553
+ current5 = "withinner";
315488
315554
  }
315489
- if (layerBlur) parts += `<feGaussianBlur in="${current4}" stdDeviation="${fmt2(sigma(layerBlur.radius))}"/>`;
315555
+ if (layerBlur) parts += `<feGaussianBlur in="${current5}" stdDeviation="${fmt2(sigma(layerBlur.radius))}"/>`;
315490
315556
  ctx2.defs.push(`<filter id="${id3}" ${region}>${parts}</filter>`);
315491
315557
  return ` filter="url(#${id3})"`;
315492
315558
  }
@@ -316410,13 +316476,13 @@ ${num7(c2[0])} ${num7(c2[1])} ${num7(c2[2])} ${num7(c2[3])} ${num7(c2[4])} ${num
316410
316476
  for (const run4 of item.runs) {
316411
316477
  this.w(`q /${this.gs(opacity * run4.alpha, 1, blend2)} gs ${this.res.color.fill(run4.color)} BT
316412
316478
  `);
316413
- let current4 = "";
316479
+ let current5 = "";
316414
316480
  for (const g of run4.glyphs) {
316415
316481
  const { resource, gid } = this.res.fonts.use(g.font, g.gid, g.codePoints);
316416
- if (resource !== current4) {
316482
+ if (resource !== current5) {
316417
316483
  this.w(`/${resource} ${num7(run4.size)} Tf
316418
316484
  `);
316419
- current4 = resource;
316485
+ current5 = resource;
316420
316486
  }
316421
316487
  this.w(`1 0 0 -1 ${num7(g.x)} ${num7(g.y)} Tm <${gid.toString(16).padStart(4, "0")}> Tj
316422
316488
  `);
@@ -316896,8 +316962,8 @@ var init_color2 = __esm({
316896
316962
  "use strict";
316897
316963
  init_writer2();
316898
316964
  ColorOut = class {
316899
- constructor(mode) {
316900
- this.mode = mode;
316965
+ constructor(mode2) {
316966
+ this.mode = mode2;
316901
316967
  }
316902
316968
  get colorSpace() {
316903
316969
  return this.mode === "CMYK" ? "/DeviceCMYK" : "/DeviceRGB";
@@ -317206,13 +317272,13 @@ async function encodeImageData(imageData, format, quality = 0.9, dpi) {
317206
317272
  }
317207
317273
  function sliceRegion(node2, doc2) {
317208
317274
  let pageId2 = null;
317209
- let current4 = node2;
317210
- while (current4) {
317211
- if (current4.type === "PAGE") {
317212
- pageId2 = current4.id;
317275
+ let current5 = node2;
317276
+ while (current5) {
317277
+ if (current5.type === "PAGE") {
317278
+ pageId2 = current5.id;
317213
317279
  break;
317214
317280
  }
317215
- current4 = current4.parentId ? doc2.nodes[current4.parentId] : void 0;
317281
+ current5 = current5.parentId ? doc2.nodes[current5.parentId] : void 0;
317216
317282
  }
317217
317283
  if (!pageId2) return null;
317218
317284
  const page = doc2.nodes[pageId2];
@@ -317417,6 +317483,7 @@ async function selectionReferenceImages(doc2, selection, opts = {}) {
317417
317483
  var FIT_QUALITIES, FIT_SCALES, blobToDataUrl;
317418
317484
  var init_reference_images = __esm({
317419
317485
  "lib/ai/reference-images.ts"() {
317486
+ "use strict";
317420
317487
  init_export();
317421
317488
  init_selection_bounds();
317422
317489
  init_renderer_registry();
@@ -318172,8 +318239,8 @@ function provideAgentCapability(name2, impl) {
318172
318239
  else provided.set(name2, impl);
318173
318240
  }
318174
318241
  function agentCapability(name2, ctx2) {
318175
- const installed3 = provided.get(name2);
318176
- if (installed3) return installed3;
318242
+ const installed4 = provided.get(name2);
318243
+ if (installed4) return installed4;
318177
318244
  switch (name2) {
318178
318245
  case "render":
318179
318246
  return renderCapability(ctx2);
@@ -318259,7 +318326,6 @@ function agentToolList() {
318259
318326
  var AGENT_CAPABILITIES, legacyCommandId, legacyTools, blobToDataUrl3, provided, legacyTool, legacyToolList;
318260
318327
  var init_agent = __esm({
318261
318328
  "lib/commands/agent.ts"() {
318262
- "use strict";
318263
318329
  init_types5();
318264
318330
  init_registry();
318265
318331
  init_errors();
@@ -320109,8 +320175,8 @@ var init_node = __esm({
320109
320175
  const patches = /* @__PURE__ */ new Map();
320110
320176
  for (const id3 of ids2) {
320111
320177
  const n = resolvedNodeOrThrow(doc2, id3);
320112
- const current4 = n.rotation ?? 0;
320113
- const next2 = args2.degrees !== void 0 ? args2.degrees : current4 + (args2.by ?? 0);
320178
+ const current5 = n.rotation ?? 0;
320179
+ const next2 = args2.degrees !== void 0 ? args2.degrees : current5 + (args2.by ?? 0);
320114
320180
  patches.set(id3, { rotation: (next2 % 360 + 360) % 360 });
320115
320181
  }
320116
320182
  commitUpdates(ctx2, doc2, patches);
@@ -320123,6 +320189,7 @@ var init_node = __esm({
320123
320189
  // lib/commands/text.ts
320124
320190
  function applyTypeStyle(node2, styles) {
320125
320191
  const patch2 = { ...styles };
320192
+ if (node2.textStyleId && Object.keys(styles).some((k2) => TYPOGRAPHY_OVERRIDE_KEYS.has(k2))) patch2.textStyleId = void 0;
320126
320193
  const segments = node2.styledSegments;
320127
320194
  if (segments?.length) {
320128
320195
  const keys4 = Object.keys(styles);
@@ -320135,7 +320202,7 @@ function applyTypeStyle(node2, styles) {
320135
320202
  }
320136
320203
  return patch2;
320137
320204
  }
320138
- var textSet, TYPE_FIELDS, textSetTypography, textSearchFonts, textSetEffect;
320205
+ var textSet, TYPE_FIELDS, TYPOGRAPHY_OVERRIDE_KEYS, textSetTypography, textSearchFonts, textSetEffect;
320139
320206
  var init_text = __esm({
320140
320207
  "lib/commands/text.ts"() {
320141
320208
  "use strict";
@@ -320222,6 +320289,20 @@ var init_text = __esm({
320222
320289
  "textDecoration",
320223
320290
  "textAutoResize"
320224
320291
  ];
320292
+ TYPOGRAPHY_OVERRIDE_KEYS = /* @__PURE__ */ new Set([
320293
+ "fontFamily",
320294
+ "fontWeight",
320295
+ "fontSize",
320296
+ "fontStyle",
320297
+ "letterSpacing",
320298
+ "lineHeight",
320299
+ "paragraphSpacing",
320300
+ "paragraphIndent",
320301
+ "textDecoration",
320302
+ "textCase",
320303
+ "fontFeatures",
320304
+ "fontVariations"
320305
+ ]);
320225
320306
  textSetTypography = defineCommand({
320226
320307
  id: "text.setTypography",
320227
320308
  title: "Set typography",
@@ -320245,6 +320326,8 @@ var init_text = __esm({
320245
320326
  textAutoResize: external_exports.enum(["NONE", "WIDTH_AND_HEIGHT", "HEIGHT"]).optional()
320246
320327
  }),
320247
320328
  expose: {
320329
+ // Panels dispatch it (the phone's quick sheet setting a size); a palette row could not know the values.
320330
+ ui: { label: "Set typography", palette: false },
320248
320331
  plugin: { method: "setTypography" },
320249
320332
  agent: {
320250
320333
  name: "set_typography",
@@ -320446,18 +320529,18 @@ var init_text_path2 = __esm({
320446
320529
  patches.set(t3.id, { textPath: void 0 });
320447
320530
  continue;
320448
320531
  }
320449
- const mode = args2.mode ?? (args2.pathId ? "PATH" : t3.textPath?.mode ?? (other ? "PATH" : "ARC"));
320450
- const pathId = mode === "PATH" ? args2.pathId ?? (t3.textPath?.mode === "PATH" && !other ? t3.textPath.pathId : other ?? t3.textPath?.pathId) : void 0;
320451
- if (mode === "PATH") {
320532
+ const mode2 = args2.mode ?? (args2.pathId ? "PATH" : t3.textPath?.mode ?? (other ? "PATH" : "ARC"));
320533
+ const pathId = mode2 === "PATH" ? args2.pathId ?? (t3.textPath?.mode === "PATH" && !other ? t3.textPath.pathId : other ?? t3.textPath?.pathId) : void 0;
320534
+ if (mode2 === "PATH") {
320452
320535
  if (!pathId) throw new ToolError("set_text_path with mode PATH needs pathId (or a text and one shape selected).");
320453
320536
  const src = nodeOrThrow(doc2, pathId);
320454
320537
  if (pathId === t3.id || !isPathSource(src)) throw new ToolError(`"${src.name}" (${pathId}) is a ${src.type}; a text can follow a vector, rectangle, ellipse, polygon, star, line, arrow or frame.`);
320455
320538
  }
320456
- const keep = t3.textPath && t3.textPath.mode === mode ? t3.textPath : null;
320457
- const closed = mode === "CIRCLE" || mode === "PATH" && isClosedOutline(doc2.nodes[pathId]);
320458
- const fresh = keep ? {} : closed ? { align: "CENTER", offset: 0.5 } : mode === "ARC" ? { bend: 50 } : {};
320459
- const tp = { ...keep ?? {}, ...fresh, ...given, mode, ...mode === "PATH" ? { pathId } : {} };
320460
- if (mode !== "PATH") delete tp.pathId;
320539
+ const keep = t3.textPath && t3.textPath.mode === mode2 ? t3.textPath : null;
320540
+ const closed = mode2 === "CIRCLE" || mode2 === "PATH" && isClosedOutline(doc2.nodes[pathId]);
320541
+ const fresh = keep ? {} : closed ? { align: "CENTER", offset: 0.5 } : mode2 === "ARC" ? { bend: 50 } : {};
320542
+ const tp = { ...keep ?? {}, ...fresh, ...given, mode: mode2, ...mode2 === "PATH" ? { pathId } : {} };
320543
+ if (mode2 !== "PATH") delete tp.pathId;
320461
320544
  patches.set(t3.id, { textPath: tp, textArea: void 0 });
320462
320545
  }
320463
320546
  commitUpdates(ctx2, doc2, patches);
@@ -320674,6 +320757,8 @@ var init_paint = __esm({
320674
320757
  remove: external_exports.boolean().optional().describe("Clear all fills.")
320675
320758
  }),
320676
320759
  expose: {
320760
+ // Panels dispatch it (the phone's quick sheet adding one); a palette row could not know the paint.
320761
+ ui: { label: "Set fills", palette: false },
320677
320762
  plugin: { method: "setFills" },
320678
320763
  agent: {
320679
320764
  name: "set_fills",
@@ -320686,22 +320771,22 @@ var init_paint = __esm({
320686
320771
  if (given > 1) throw new ToolError('set_fills takes one of "color", "gradient" or "image", not several.');
320687
320772
  if (!given && !args2.remove) throw new ToolError('set_fills needs a "color", a "gradient", an "image" or remove:true.');
320688
320773
  const paint = buildPaint(args2);
320689
- const mode = args2.mode ?? "merge";
320774
+ const mode2 = args2.mode ?? "merge";
320690
320775
  const patches = /* @__PURE__ */ new Map();
320691
320776
  for (const id3 of ids2) {
320692
320777
  const existing = doc2.nodes[id3].fills ?? [];
320693
320778
  let fills;
320694
320779
  if (args2.remove) fills = [];
320695
- else if (mode === "replace" || !existing.length) fills = [paint];
320696
- else if (mode === "add") fills = [...existing, paint];
320780
+ else if (mode2 === "replace" || !existing.length) fills = [paint];
320781
+ else if (mode2 === "add") fills = [...existing, paint];
320697
320782
  else fills = [paint, ...existing.slice(1)];
320698
320783
  patches.set(id3, { fills });
320699
320784
  }
320700
320785
  const what = args2.gradient ? `a ${args2.gradient.type.toLowerCase()} gradient` : args2.image ? "an image" : args2.color;
320701
320786
  commitUpdates(ctx2, doc2, patches);
320702
320787
  return {
320703
- summary: args2.remove ? `Cleared fills on ${plural2(ids2.length, "layer")}` : `Filled ${plural2(ids2.length, "layer")} with ${what} (${mode})`,
320704
- data: { ids: ids2, mode }
320788
+ summary: args2.remove ? `Cleared fills on ${plural2(ids2.length, "layer")}` : `Filled ${plural2(ids2.length, "layer")} with ${what} (${mode2})`,
320789
+ data: { ids: ids2, mode: mode2 }
320705
320790
  };
320706
320791
  }
320707
320792
  });
@@ -320727,6 +320812,8 @@ var init_paint = __esm({
320727
320812
  remove: external_exports.boolean().optional()
320728
320813
  }),
320729
320814
  expose: {
320815
+ // Panels dispatch it (the phone's quick sheet adding one); a palette row could not know the paint.
320816
+ ui: { label: "Set strokes", palette: false },
320730
320817
  plugin: { method: "setStrokes" },
320731
320818
  agent: {
320732
320819
  name: "set_strokes",
@@ -321337,6 +321424,222 @@ var init_resolution = __esm({
321337
321424
  }
321338
321425
  });
321339
321426
 
321427
+ // lib/editor/form-factor.ts
321428
+ var form_factor_exports = {};
321429
+ __export(form_factor_exports, {
321430
+ COMPACT_TABLET_MAX_WIDTH: () => COMPACT_TABLET_MAX_WIDTH,
321431
+ PHONE_MAX_HEIGHT: () => PHONE_MAX_HEIGHT,
321432
+ PHONE_MAX_WIDTH: () => PHONE_MAX_WIDTH,
321433
+ PHONE_MEDIA_QUERY: () => PHONE_MEDIA_QUERY,
321434
+ TABLET_MAX_WIDTH: () => TABLET_MAX_WIDTH,
321435
+ classify: () => classify,
321436
+ currentShell: () => currentShell,
321437
+ getCanvasSide: () => getCanvasSide,
321438
+ layoutMode: () => layoutMode,
321439
+ setCanvasSide: () => setCanvasSide,
321440
+ setLayoutMode: () => setLayoutMode,
321441
+ useCanvasSide: () => useCanvasSide,
321442
+ useLayoutMode: () => useLayoutMode,
321443
+ usePhone: () => usePhone,
321444
+ useShell: () => useShell
321445
+ });
321446
+ function classify(f2) {
321447
+ const narrowPhone = f2.width <= PHONE_MAX_WIDTH || f2.height <= PHONE_MAX_HEIGHT;
321448
+ const touchCompact = f2.coarse && f2.width <= COMPACT_TABLET_MAX_WIDTH;
321449
+ const autoPhone = narrowPhone || touchCompact;
321450
+ const phone = f2.mode === "phone" || f2.mode === "panes" || f2.mode === "auto" && autoPhone;
321451
+ const halfOpen = f2.hinge === "partial" && f2.fold !== "none";
321452
+ let formFactor;
321453
+ if (f2.mode === "desktop") formFactor = f2.coarse && !f2.hover ? "tablet" : "desktop";
321454
+ else if (phone) formFactor = "phone";
321455
+ else if (f2.width <= COMPACT_TABLET_MAX_WIDTH) formFactor = "compact-tablet";
321456
+ else if (f2.coarse && !f2.hover || f2.coarse && f2.width <= TABLET_MAX_WIDTH) formFactor = "tablet";
321457
+ else formFactor = "desktop";
321458
+ const isPhone = formFactor === "phone";
321459
+ const phoneSize = isPhone && f2.width > PHONE_MAX_WIDTH && f2.height > PHONE_MAX_HEIGHT ? "tablet" : "";
321460
+ const orient = !isPhone ? "" : phoneSize === "" && f2.width > f2.height && f2.height <= PHONE_MAX_HEIGHT ? "landscape" : "portrait";
321461
+ const panes = isPhone && (f2.mode === "panes" || halfOpen || f2.mode === "auto" && phoneSize === "tablet");
321462
+ const split2 = !panes ? "" : halfOpen ? f2.fold === "horizontal" ? "stacked" : "side" : f2.width > f2.height ? "side" : "stacked";
321463
+ return { formFactor, orient, phoneSize, panes, split: split2, hinge: f2.hinge, fold: f2.fold };
321464
+ }
321465
+ function readMode() {
321466
+ try {
321467
+ const v = localStorage.getItem(MODE_KEY);
321468
+ return v === "desktop" || v === "phone" || v === "panes" ? v : "auto";
321469
+ } catch {
321470
+ return "auto";
321471
+ }
321472
+ }
321473
+ function hingeAttr() {
321474
+ const v = document.documentElement.getAttribute("data-pc-hinge");
321475
+ return v === "closed" || v === "partial" || v === "open" ? v : "unknown";
321476
+ }
321477
+ function foldAttr() {
321478
+ const v = document.documentElement.getAttribute("data-pc-fold");
321479
+ return v === "vertical" || v === "horizontal" ? v : "none";
321480
+ }
321481
+ function publishWebSegments() {
321482
+ const vs = window.viewport;
321483
+ const segs = vs?.segments;
321484
+ if (!segs || document.documentElement.hasAttribute("data-pc-native-fold")) return;
321485
+ const d = document.documentElement;
321486
+ if (segs.length < 2) {
321487
+ if (d.getAttribute("data-pc-hinge") === "partial") {
321488
+ d.setAttribute("data-pc-hinge", "open");
321489
+ d.setAttribute("data-pc-fold", "none");
321490
+ }
321491
+ return;
321492
+ }
321493
+ const [a, b] = segs;
321494
+ const vertical = Math.abs(a.y - b.y) < 1;
321495
+ const x2 = vertical ? a.x + a.width : 0;
321496
+ const y = vertical ? 0 : a.y + a.height;
321497
+ const w = vertical ? b.x - x2 : window.innerWidth;
321498
+ const h = vertical ? window.innerHeight : b.y - y;
321499
+ d.setAttribute("data-pc-hinge", "partial");
321500
+ d.setAttribute("data-pc-fold", vertical ? "vertical" : "horizontal");
321501
+ d.style.setProperty("--pc-fold-x", `${Math.round(x2)}px`);
321502
+ d.style.setProperty("--pc-fold-y", `${Math.round(y)}px`);
321503
+ d.style.setProperty("--pc-fold-w", `${Math.round(w)}px`);
321504
+ d.style.setProperty("--pc-fold-h", `${Math.round(h)}px`);
321505
+ }
321506
+ function setAttr(el, name2, value3) {
321507
+ if (!value3) {
321508
+ if (el.hasAttribute(name2)) el.removeAttribute(name2);
321509
+ } else if (el.getAttribute(name2) !== value3) el.setAttribute(name2, value3);
321510
+ }
321511
+ function recompute() {
321512
+ publishWebSegments();
321513
+ const mm = (q) => window.matchMedia?.(q).matches ?? false;
321514
+ const touch = document.documentElement.hasAttribute("data-pc-touch");
321515
+ const next2 = classify({
321516
+ width: window.innerWidth,
321517
+ height: window.innerHeight,
321518
+ coarse: touch || mm("(pointer: coarse)"),
321519
+ hover: !touch && mm("(hover: hover)"),
321520
+ hinge: hingeAttr(),
321521
+ fold: foldAttr(),
321522
+ mode
321523
+ });
321524
+ const b = document.body;
321525
+ setAttr(b, "data-form-factor", next2.formFactor === "desktop" ? "" : next2.formFactor);
321526
+ setAttr(b, "data-phone-orient", next2.orient);
321527
+ setAttr(b, "data-phone-size", next2.phoneSize);
321528
+ setAttr(b, "data-panes", next2.panes ? next2.split : "");
321529
+ setAttr(b, "data-canvas-side", next2.panes && canvasSide === "bottom" ? "bottom" : "");
321530
+ if (JSON.stringify(next2) === JSON.stringify(current4)) return;
321531
+ current4 = next2;
321532
+ for (const l of listeners6) l();
321533
+ }
321534
+ function install() {
321535
+ if (installed || typeof window === "undefined") return;
321536
+ installed = true;
321537
+ mode = readMode();
321538
+ let raf = 0;
321539
+ const again = () => {
321540
+ cancelAnimationFrame(raf);
321541
+ raf = requestAnimationFrame(recompute);
321542
+ };
321543
+ window.addEventListener("resize", again);
321544
+ window.addEventListener("orientationchange", () => setTimeout(recompute, 50));
321545
+ window.matchMedia?.("(pointer: coarse)").addEventListener?.("change", again);
321546
+ window.matchMedia?.("(hover: hover)").addEventListener?.("change", again);
321547
+ window.addEventListener("pc-fold", again);
321548
+ new MutationObserver(again).observe(document.documentElement, { attributes: true, attributeFilter: ["data-pc-hinge", "data-pc-fold", "data-pc-touch"] });
321549
+ recompute();
321550
+ }
321551
+ function subscribe(l) {
321552
+ install();
321553
+ listeners6.add(l);
321554
+ return () => {
321555
+ listeners6.delete(l);
321556
+ };
321557
+ }
321558
+ function currentShell() {
321559
+ install();
321560
+ return current4;
321561
+ }
321562
+ function useShell(select) {
321563
+ return (0, import_react6.useSyncExternalStore)(subscribe, () => select(current4), () => select(SERVER));
321564
+ }
321565
+ function layoutMode() {
321566
+ install();
321567
+ return mode;
321568
+ }
321569
+ function useLayoutMode() {
321570
+ return (0, import_react6.useSyncExternalStore)(
321571
+ (l) => {
321572
+ install();
321573
+ modeListeners.add(l);
321574
+ return () => {
321575
+ modeListeners.delete(l);
321576
+ };
321577
+ },
321578
+ () => mode,
321579
+ () => "auto"
321580
+ );
321581
+ }
321582
+ function setLayoutMode(next2) {
321583
+ install();
321584
+ mode = next2;
321585
+ try {
321586
+ localStorage.setItem(MODE_KEY, next2);
321587
+ } catch {
321588
+ }
321589
+ for (const l of modeListeners) l();
321590
+ recompute();
321591
+ }
321592
+ function useCanvasSide() {
321593
+ return (0, import_react6.useSyncExternalStore)((l) => {
321594
+ sideListeners.add(l);
321595
+ return () => {
321596
+ sideListeners.delete(l);
321597
+ };
321598
+ }, () => canvasSide, () => "top");
321599
+ }
321600
+ function getCanvasSide() {
321601
+ return canvasSide;
321602
+ }
321603
+ function setCanvasSide(next2) {
321604
+ canvasSide = next2;
321605
+ try {
321606
+ localStorage.setItem(SIDE_KEY, next2);
321607
+ } catch {
321608
+ }
321609
+ for (const l of sideListeners) l();
321610
+ if (installed) {
321611
+ const b = document.body;
321612
+ setAttr(b, "data-canvas-side", current4.panes && next2 === "bottom" ? "bottom" : "");
321613
+ }
321614
+ }
321615
+ var import_react6, PHONE_MAX_WIDTH, PHONE_MAX_HEIGHT, COMPACT_TABLET_MAX_WIDTH, TABLET_MAX_WIDTH, PHONE_MEDIA_QUERY, MODE_KEY, mode, current4, listeners6, installed, SERVER, usePhone, modeListeners, SIDE_KEY, canvasSide, sideListeners;
321616
+ var init_form_factor = __esm({
321617
+ "lib/editor/form-factor.ts"() {
321618
+ "use client";
321619
+ import_react6 = __toESM(require_react());
321620
+ PHONE_MAX_WIDTH = 599;
321621
+ PHONE_MAX_HEIGHT = 499;
321622
+ COMPACT_TABLET_MAX_WIDTH = 959;
321623
+ TABLET_MAX_WIDTH = 1180;
321624
+ PHONE_MEDIA_QUERY = `(max-width: ${PHONE_MAX_WIDTH}px), (max-height: ${PHONE_MAX_HEIGHT}px), (max-width: ${COMPACT_TABLET_MAX_WIDTH}px) and (pointer: coarse)`;
321625
+ MODE_KEY = "popcraft-layout-mode";
321626
+ mode = "auto";
321627
+ current4 = { formFactor: "desktop", orient: "", phoneSize: "", panes: false, split: "", hinge: "unknown", fold: "none" };
321628
+ listeners6 = /* @__PURE__ */ new Set();
321629
+ installed = false;
321630
+ SERVER = { formFactor: "desktop", orient: "", phoneSize: "", panes: false, split: "", hinge: "unknown", fold: "none" };
321631
+ usePhone = () => useShell((s) => s.formFactor === "phone");
321632
+ modeListeners = /* @__PURE__ */ new Set();
321633
+ SIDE_KEY = "popcraft-canvas-side";
321634
+ canvasSide = "top";
321635
+ try {
321636
+ if (typeof localStorage !== "undefined" && localStorage.getItem(SIDE_KEY) === "bottom") canvasSide = "bottom";
321637
+ } catch {
321638
+ }
321639
+ sideListeners = /* @__PURE__ */ new Set();
321640
+ }
321641
+ });
321642
+
321340
321643
  // lib/commands/view.ts
321341
321644
  async function copyToClipboard(url4) {
321342
321645
  try {
@@ -321345,7 +321648,7 @@ async function copyToClipboard(url4) {
321345
321648
  if (typeof window !== "undefined") window.prompt("Copy this link:", url4);
321346
321649
  }
321347
321650
  }
321348
- var viewGetSelection, viewSelect, viewZoomTo, viewStage, viewPresent, viewZoom, viewCopyLink;
321651
+ var viewGetSelection, viewSelect, viewZoomTo, viewStage, viewScreenLayout, viewPresent, viewZoom, viewCopyLink;
321349
321652
  var init_view2 = __esm({
321350
321653
  "lib/commands/view.ts"() {
321351
321654
  "use strict";
@@ -321501,6 +321804,36 @@ var init_view2 = __esm({
321501
321804
  return { summary: on ? "Stage view on: showing only the active frame" : "Stage view off: showing the whole page", data: { on } };
321502
321805
  }
321503
321806
  });
321807
+ viewScreenLayout = defineCommand({
321808
+ id: "view.screenLayout",
321809
+ title: "Screen layout",
321810
+ domain: "view",
321811
+ effect: "view",
321812
+ permission: "read",
321813
+ params: external_exports.object({
321814
+ layout: external_exports.enum(["auto", "phone", "panes", "desktop"]).optional().describe('"auto" fits the screen; "phone" one page at a time; "panes" the canvas beside the panels; "desktop" the full workbench.'),
321815
+ canvas: external_exports.enum(["top", "bottom", "flip"]).optional().describe('In two panes, which pane holds the canvas; "flip" swaps it.')
321816
+ }),
321817
+ expose: {
321818
+ ui: {
321819
+ label: "Flip canvas and panels",
321820
+ keywords: ["flip", "swap", "canvas bottom", "canvas top", "fold", "foldable", "tabletop", "panes", "layout", "phone", "tablet"],
321821
+ defaults: { canvas: "flip" }
321822
+ },
321823
+ agent: {
321824
+ name: "set_screen_layout",
321825
+ description: 'Change how the editor lays itself out on this device: layout "auto" (fit the screen), "phone" (one page at a time with a dock), "panes" (canvas beside the panels) or "desktop"; and canvas "top", "bottom" or "flip" to choose which of the two panes holds the canvas. Changes nothing in the document.'
321826
+ }
321827
+ },
321828
+ run: async (args2) => {
321829
+ if (typeof window === "undefined") throw new ToolError("The screen layout is only available in the editor.");
321830
+ const ff = await Promise.resolve().then(() => (init_form_factor(), form_factor_exports));
321831
+ if (args2.layout) ff.setLayoutMode(args2.layout);
321832
+ if (args2.canvas) ff.setCanvasSide(args2.canvas === "flip" ? ff.getCanvasSide() === "top" ? "bottom" : "top" : args2.canvas);
321833
+ const side = ff.getCanvasSide();
321834
+ return { summary: `Screen layout ${ff.layoutMode()}, canvas on the ${side}`, data: { layout: ff.layoutMode(), canvas: side } };
321835
+ }
321836
+ });
321504
321837
  viewPresent = defineCommand({
321505
321838
  id: "view.present",
321506
321839
  title: "Present",
@@ -323664,9 +323997,9 @@ function siteTokens(doc2) {
323664
323997
  const vars = [];
323665
323998
  for (const v of Object.values(doc2.variables ?? {}).sort((a, b) => a.name.localeCompare(b.name) || a.id.localeCompare(b.id))) {
323666
323999
  const values3 = {};
323667
- for (const [mode, value3] of Object.entries(v.valuesByMode ?? {})) {
324000
+ for (const [mode2, value3] of Object.entries(v.valuesByMode ?? {})) {
323668
324001
  const css = cssValue(v, value3);
323669
- if (css !== null) values3[mode] = css;
324002
+ if (css !== null) values3[mode2] = css;
323670
324003
  }
323671
324004
  if (!Object.keys(values3).length) continue;
323672
324005
  let name2 = codeSyntaxFor(v, "WEB");
@@ -323735,7 +324068,7 @@ var init_tokens2 = __esm({
323735
324068
  init_dev_mode();
323736
324069
  init_paint2();
323737
324070
  slug = (s) => s.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "") || "x";
323738
- modeClass = (collection, mode) => `pc-${slug(collection.name)}-${slug(mode.name)}`;
324071
+ modeClass = (collection, mode2) => `pc-${slug(collection.name)}-${slug(mode2.name)}`;
323739
324072
  isColor3 = (v) => !!v && typeof v === "object" && "r" in v && "g" in v && "b" in v;
323740
324073
  px3 = (name2) => `calc(var(${name2}) * 1px)`;
323741
324074
  NUMBER_PROPS = {
@@ -325552,7 +325885,7 @@ function stateMachineFromDotLottie(input2, id3 = "sm1", name2 = "State machine")
325552
325885
  transitions[tid] = { id: tid, from: from2, to, ...guards.length ? { guards } : {} };
325553
325886
  }
325554
325887
  }
325555
- const listeners8 = {};
325888
+ const listeners9 = {};
325556
325889
  let completeSeen = false;
325557
325890
  for (const it of list2(raw.interactions)) {
325558
325891
  const type = DOT_INTERACTIONS[String(it.type)];
@@ -325567,12 +325900,12 @@ function stateMachineFromDotLottie(input2, id3 = "sm1", name2 = "State machine")
325567
325900
  }
325568
325901
  const layer2 = typeof it.layerName === "string" ? input2.nodeByName(it.layerName) : void 0;
325569
325902
  if (typeof it.layerName === "string" && !layer2) notes.add(`The layer \u201C${it.layerName}\u201D an interaction listens on was not found: it listens on the whole frame.`);
325570
- const lid = freshId3(listeners8, "l");
325571
- listeners8[lid] = { id: lid, type, ...layer2 ? { layer: layer2 } : {}, actions: actions(it.actions) };
325903
+ const lid = freshId3(listeners9, "l");
325904
+ listeners9[lid] = { id: lid, type, ...layer2 ? { layer: layer2 } : {}, actions: actions(it.actions) };
325572
325905
  }
325573
325906
  const initial = typeof raw.initial === "string" ? stateByName.get(raw.initial) : void 0;
325574
325907
  return {
325575
- machine: { id: id3, name: name2, initial: initial ?? Object.keys(states)[0], states, transitions, inputs, listeners: listeners8 },
325908
+ machine: { id: id3, name: name2, initial: initial ?? Object.keys(states)[0], states, transitions, inputs, listeners: listeners9 },
325576
325909
  notes: [...notes]
325577
325910
  };
325578
325911
  }
@@ -328147,7 +328480,7 @@ var init_package = __esm({
328147
328480
  "packages/runtime/package.json"() {
328148
328481
  package_default = {
328149
328482
  name: "@popcraft/runtime",
328150
- version: "0.48.3",
328483
+ version: "0.50.0",
328151
328484
  description: "What code exported from PopCraft shares: the meaning of expressions (operators and functions) and, as it grows, the parts of a design's behaviour that are common code rather than generated React.",
328152
328485
  license: "MIT",
328153
328486
  homepage: "https://popcraft.app/docs/exporting/nextjs",
@@ -343357,8 +343690,8 @@ var require_gen_mapping_umd = __commonJS({
343357
343690
  function getColumnIndex(line, genColumn) {
343358
343691
  let index2 = line.length;
343359
343692
  for (let i2 = index2 - 1; i2 >= 0; index2 = i2--) {
343360
- const current4 = line[i2];
343361
- if (genColumn >= current4[COLUMN]) break;
343693
+ const current5 = line[i2];
343694
+ if (genColumn >= current5[COLUMN]) break;
343362
343695
  }
343363
343696
  return index2;
343364
343697
  }
@@ -352813,7 +353146,6 @@ function exportsOf(source3) {
352813
353146
  var CODE_LIMITS, packageOf;
352814
353147
  var init_source2 = __esm({
352815
353148
  "lib/code/source.ts"() {
352816
- "use strict";
352817
353149
  CODE_LIMITS = { modules: 100, sourceLength: 2e5, packages: 12 };
352818
353150
  packageOf = (spec) => spec.split("/").slice(0, spec.startsWith("@") ? 2 : 1).join("/");
352819
353151
  }
@@ -352856,7 +353188,6 @@ function compileModule(module2) {
352856
353188
  var import_sucrase, BUILT_IN, memo4;
352857
353189
  var init_compile2 = __esm({
352858
353190
  "lib/code/compile.ts"() {
352859
- "use strict";
352860
353191
  import_sucrase = __toESM(require_dist2());
352861
353192
  init_source2();
352862
353193
  init_source2();
@@ -353589,23 +353920,23 @@ async function previewSite(doc2, pageId2, resolvers, media2 = mediaToDataUrl) {
353589
353920
  return withSiteCode(site, doc2);
353590
353921
  }
353591
353922
  function startPreview(iframe, player, onMessage2, opts = {}) {
353592
- const channel3 = new MessageChannel();
353923
+ const channel4 = new MessageChannel();
353593
353924
  let ready3 = false;
353594
353925
  let queue2 = [];
353595
- channel3.port1.onmessage = (e) => {
353926
+ channel4.port1.onmessage = (e) => {
353596
353927
  const m = parseFromFrame(e.data);
353597
353928
  if (!m) return;
353598
353929
  if (m.type === "ready") {
353599
353930
  ready3 = true;
353600
- for (const q of queue2) channel3.port1.postMessage(q);
353931
+ for (const q of queue2) channel4.port1.postMessage(q);
353601
353932
  queue2 = [];
353602
353933
  }
353603
353934
  if (m.type === "needCode") {
353604
- void codeScript().then((js) => channel3.port1.postMessage({ type: "code", js }));
353935
+ void codeScript().then((js) => channel4.port1.postMessage({ type: "code", js }));
353605
353936
  return;
353606
353937
  }
353607
353938
  if (m.type === "needIsland") {
353608
- void islandScript().then((js) => channel3.port1.postMessage({ type: "island", js }));
353939
+ void islandScript().then((js) => channel4.port1.postMessage({ type: "island", js }));
353609
353940
  return;
353610
353941
  }
353611
353942
  onMessage2(m);
@@ -353613,19 +353944,19 @@ function startPreview(iframe, player, onMessage2, opts = {}) {
353613
353944
  const onHello = (e) => {
353614
353945
  if (e.data !== HELLO_MESSAGE || e.source !== iframe.contentWindow) return;
353615
353946
  window.removeEventListener("message", onHello);
353616
- iframe.contentWindow?.postMessage(PORT_MESSAGE, "*", [channel3.port2]);
353947
+ iframe.contentWindow?.postMessage(PORT_MESSAGE, "*", [channel4.port2]);
353617
353948
  };
353618
353949
  window.addEventListener("message", onHello);
353619
353950
  iframe.setAttribute("sandbox", "allow-scripts");
353620
353951
  iframe.srcdoc = previewDocument(player, opts.cdn);
353621
353952
  return {
353622
353953
  send(message) {
353623
- if (ready3) channel3.port1.postMessage(message);
353954
+ if (ready3) channel4.port1.postMessage(message);
353624
353955
  else queue2.push(message);
353625
353956
  },
353626
353957
  destroy() {
353627
353958
  window.removeEventListener("message", onHello);
353628
- channel3.port1.close();
353959
+ channel4.port1.close();
353629
353960
  iframe.removeAttribute("srcdoc");
353630
353961
  }
353631
353962
  };
@@ -353904,7 +354235,7 @@ function base644(bytes2) {
353904
354235
  for (let i2 = 0; i2 < bytes2.length; i2 += 32768) bin += String.fromCharCode(...bytes2.subarray(i2, i2 + 32768));
353905
354236
  return btoa(bin);
353906
354237
  }
353907
- async function webFontFaces(doc2, trees, mode, dir = "fonts") {
354238
+ async function webFontFaces(doc2, trees, mode2, dir = "fonts") {
353908
354239
  const used = new Set(trees.flatMap((t3) => [...fontFamilies(t3).keys()]));
353909
354240
  const faces2 = [];
353910
354241
  const files = [];
@@ -353919,7 +354250,7 @@ async function webFontFaces(doc2, trees, mode, dir = "fonts") {
353919
354250
  const own2 = fontFormat(bytes2) ?? format;
353920
354251
  const weight = fontWeightOf(f2), style = fontStyleOf(f2);
353921
354252
  let url4;
353922
- if (mode === "files") {
354253
+ if (mode2 === "files") {
353923
354254
  const name2 = `${dir}/${slug3(f2.family)}-${weight}${style === "italic" ? "-italic" : ""}.${EXT2[own2]}`;
353924
354255
  if (!files.some((x2) => x2.name === name2)) files.push({ name: name2, bytes: bytes2 });
353925
354256
  url4 = name2;
@@ -355679,9 +356010,9 @@ var init_meta = __esm({
355679
356010
  throw new ToolError("Only one todo may be in_progress at a time.");
355680
356011
  }
355681
356012
  const done = todos.filter((t3) => t3.status === "done").length;
355682
- const current4 = todos.find((t3) => t3.status === "in_progress");
356013
+ const current5 = todos.find((t3) => t3.status === "in_progress");
355683
356014
  return {
355684
- summary: todos.length ? `${done}/${todos.length} done${current4 ? ` \u2014 ${current4.title}` : ""}` : "Cleared the plan",
356015
+ summary: todos.length ? `${done}/${todos.length} done${current5 ? ` \u2014 ${current5.title}` : ""}` : "Cleared the plan",
355685
356016
  data: { todos }
355686
356017
  };
355687
356018
  }
@@ -355811,14 +356142,14 @@ var init_meta = __esm({
355811
356142
  });
355812
356143
 
355813
356144
  // lib/ai/schemas.ts
355814
- var DESIGN_NODE_TYPES, DESIGN_FONTS, layoutMode, align2, counterAlign, sizing, boxProps, frameLayoutProps, designNodeSchema, designScreenSchema, designSchema, contentSchema, layoutSuggestionSchema, generateRequestSchema, contentRequestSchema, layoutRequestSchema, embedRequestSchema;
356145
+ var DESIGN_NODE_TYPES, DESIGN_FONTS, layoutMode2, align2, counterAlign, sizing, boxProps, frameLayoutProps, designNodeSchema, designScreenSchema, designSchema, contentSchema, layoutSuggestionSchema, generateRequestSchema, contentRequestSchema, layoutRequestSchema, embedRequestSchema;
355815
356146
  var init_schemas3 = __esm({
355816
356147
  "lib/ai/schemas.ts"() {
355817
356148
  "use strict";
355818
356149
  init_zod();
355819
356150
  DESIGN_NODE_TYPES = ["FRAME", "TEXT", "RECTANGLE", "ELLIPSE", "LINE"];
355820
356151
  DESIGN_FONTS = ["Inter", "Source Serif 4", "JetBrains Mono"];
355821
- layoutMode = external_exports.enum(["NONE", "HORIZONTAL", "VERTICAL"]);
356152
+ layoutMode2 = external_exports.enum(["NONE", "HORIZONTAL", "VERTICAL"]);
355822
356153
  align2 = external_exports.enum(["MIN", "CENTER", "MAX", "SPACE_BETWEEN"]);
355823
356154
  counterAlign = external_exports.enum(["MIN", "CENTER", "MAX"]);
355824
356155
  sizing = external_exports.enum(["FIXED", "HUG", "FILL"]);
@@ -355837,7 +356168,7 @@ var init_schemas3 = __esm({
355837
356168
  heightSizing: sizing.nullable()
355838
356169
  };
355839
356170
  frameLayoutProps = {
355840
- layout: layoutMode.nullable().describe("Auto layout direction; prefer VERTICAL/HORIZONTAL for real UI"),
356171
+ layout: layoutMode2.nullable().describe("Auto layout direction; prefer VERTICAL/HORIZONTAL for real UI"),
355841
356172
  gap: external_exports.number().nullable().describe("Spacing between children in px"),
355842
356173
  padding: external_exports.array(external_exports.number()).nullable().describe("[top, right, bottom, left] px"),
355843
356174
  primaryAlign: align2.nullable(),
@@ -356292,14 +356623,14 @@ async function generateDesignIntoPage(opts, signal) {
356292
356623
  st.zoomToSelection();
356293
356624
  return rootIds.length;
356294
356625
  }
356295
- function openSearchItem(item, mode = item.kind === "component" ? "insert" : "select") {
356626
+ function openSearchItem(item, mode2 = item.kind === "component" ? "insert" : "select") {
356296
356627
  const st = editor();
356297
356628
  const node2 = st.document.nodes[item.id];
356298
356629
  if (item.kind === "style" || item.kind === "variable" || !node2) {
356299
356630
  notice2(`${item.detail}: ${item.name}`);
356300
356631
  return;
356301
356632
  }
356302
- if (mode === "insert" && (node2.type === "COMPONENT" || node2.type === "COMPONENT_SET")) {
356633
+ if (mode2 === "insert" && (node2.type === "COMPONENT" || node2.type === "COMPONENT_SET")) {
356303
356634
  guardEditable();
356304
356635
  const main2 = node2.type === "COMPONENT_SET" ? st.document.nodes[node2.childIds.find((c2) => st.document.nodes[c2]?.type === "COMPONENT") ?? ""] : node2;
356305
356636
  if (!main2) return;
@@ -359090,9 +359421,9 @@ function applyOp(frame3, sm, op4) {
359090
359421
  }
359091
359422
  case "removeListener": {
359092
359423
  if (!sm.listeners[op4.listener]) throw new ToolError(`The machine has no listener "${op4.listener}".`);
359093
- const { [op4.listener]: _gone, ...listeners8 } = sm.listeners;
359424
+ const { [op4.listener]: _gone, ...listeners9 } = sm.listeners;
359094
359425
  void _gone;
359095
- return { next: { ...sm, listeners: listeners8 } };
359426
+ return { next: { ...sm, listeners: listeners9 } };
359096
359427
  }
359097
359428
  }
359098
359429
  }
@@ -361899,7 +362230,6 @@ var init_delete_current_file = __esm({
361899
362230
  var storeOpsSeam;
361900
362231
  var init_seams = __esm({
361901
362232
  "lib/commands/seams.ts"() {
361902
- "use strict";
361903
362233
  storeOpsSeam = (st) => ({
361904
362234
  booleanOperation: (op4) => st().booleanOperation(op4),
361905
362235
  flatten: () => st().flattenSelection(),
@@ -362213,7 +362543,7 @@ function closeAudienceWindow() {
362213
362543
  } catch {
362214
362544
  }
362215
362545
  }
362216
- var CLOSED, status2, listeners6, emit3, audienceStatus, AUDIENCE_MESSAGES, audienceAvailable, session, NAME2, CANVAS_USAGE;
362546
+ var CLOSED, status2, listeners7, emit3, audienceStatus, AUDIENCE_MESSAGES, audienceAvailable, session, NAME2, CANVAS_USAGE;
362217
362547
  var init_audience_window = __esm({
362218
362548
  "lib/slides/audience/audience-window.ts"() {
362219
362549
  init_renderer_registry();
@@ -362223,10 +362553,10 @@ var init_audience_window = __esm({
362223
362553
  init_resolution();
362224
362554
  CLOSED = { open: false, resolution: null, surface: { width: 0, height: 0 }, capture: { width: 0, height: 0 }, atResolution: true };
362225
362555
  status2 = CLOSED;
362226
- listeners6 = /* @__PURE__ */ new Set();
362556
+ listeners7 = /* @__PURE__ */ new Set();
362227
362557
  emit3 = (next2) => {
362228
362558
  status2 = next2;
362229
- for (const l of listeners6) l();
362559
+ for (const l of listeners7) l();
362230
362560
  };
362231
362561
  audienceStatus = () => status2;
362232
362562
  AUDIENCE_MESSAGES = {
@@ -362703,7 +363033,7 @@ var init_schema = __esm({
362703
363033
  // lib/theme/sync.ts
362704
363034
  function themeChannel() {
362705
363035
  if (typeof BroadcastChannel === "undefined") return null;
362706
- return channel2 ??= new BroadcastChannel(CHANNEL2);
363036
+ return channel3 ??= new BroadcastChannel(CHANNEL3);
362707
363037
  }
362708
363038
  function announceThemeChange() {
362709
363039
  if (typeof window === "undefined") return;
@@ -362716,13 +363046,13 @@ function announceThemeChange() {
362716
363046
  } catch {
362717
363047
  }
362718
363048
  }
362719
- var CHANNEL2, THEME_REV_KEY, channel2;
363049
+ var CHANNEL3, THEME_REV_KEY, channel3;
362720
363050
  var init_sync3 = __esm({
362721
363051
  "lib/theme/sync.ts"() {
362722
363052
  "use strict";
362723
- CHANNEL2 = "popcraft-theme";
363053
+ CHANNEL3 = "popcraft-theme";
362724
363054
  THEME_REV_KEY = "popcraft-theme-rev";
362725
- channel2 = null;
363055
+ channel3 = null;
362726
363056
  }
362727
363057
  });
362728
363058
 
@@ -362883,15 +363213,15 @@ function usePickableThemes() {
362883
363213
  const userThemes = useThemeStore((s) => s.userThemes);
362884
363214
  const pluginThemes = useThemeStore((s) => s.pluginThemes);
362885
363215
  const localThemes = useThemeStore((s) => s.localThemes);
362886
- return (0, import_react10.useMemo)(() => pickableThemes({ userThemes, pluginThemes, localThemes }), [userThemes, pluginThemes, localThemes]);
363216
+ return (0, import_react11.useMemo)(() => pickableThemes({ userThemes, pluginThemes, localThemes }), [userThemes, pluginThemes, localThemes]);
362887
363217
  }
362888
- var import_react10, IDB_KEY, useThemeStore, cssString2, defaultAccent, effectiveAccent;
363218
+ var import_react11, IDB_KEY, useThemeStore, cssString2, defaultAccent, effectiveAccent;
362889
363219
  var init_theme_store = __esm({
362890
363220
  "lib/theme/theme-store.ts"() {
362891
363221
  init_contrast();
362892
363222
  init_idb();
362893
363223
  init_esm();
362894
- import_react10 = __toESM(require_react());
363224
+ import_react11 = __toESM(require_react());
362895
363225
  init_boot2();
362896
363226
  init_builtin();
362897
363227
  init_resolve();
@@ -365876,7 +366206,7 @@ function createAgentRuntime(host) {
365876
366206
  let loading3 = null;
365877
366207
  let active3 = 0;
365878
366208
  let waiting3 = [];
365879
- let listeners8 = [];
366209
+ let listeners9 = [];
365880
366210
  let pendingSaves = 0;
365881
366211
  let maxConcurrent = ((__v) => __v == null ? "null" : typeof __v)(host.maxConcurrent) === "number" ? host.maxConcurrent : 4;
365882
366212
  let now2 = () => {
@@ -365889,7 +366219,7 @@ function createAgentRuntime(host) {
365889
366219
  if (((__v) => __v == null ? "null" : typeof __v)(host.onChange) === "function") {
365890
366220
  host.onChange() ?? null;
365891
366221
  }
365892
- for (const l of listeners8.slice() ?? null) {
366222
+ for (const l of listeners9.slice() ?? null) {
365893
366223
  l() ?? null;
365894
366224
  }
365895
366225
  }
@@ -366164,12 +366494,12 @@ function createAgentRuntime(host) {
366164
366494
  }
366165
366495
  }, subscribe: (l) => {
366166
366496
  {
366167
- listeners8.push(l) ?? null;
366497
+ listeners9.push(l) ?? null;
366168
366498
  return () => {
366169
366499
  {
366170
- let i2 = listeners8.indexOf(l) ?? null;
366500
+ let i2 = listeners9.indexOf(l) ?? null;
366171
366501
  if (i2 >= 0) {
366172
- listeners8.splice(i2, 1) ?? null;
366502
+ listeners9.splice(i2, 1) ?? null;
366173
366503
  }
366174
366504
  }
366175
366505
  };
@@ -366515,8 +366845,8 @@ function indexedDbStore(name2 = "hypery-agents") {
366515
366845
  req.onsuccess = () => res(req.result);
366516
366846
  req.onerror = () => rej(req.error);
366517
366847
  }));
366518
- const tx2 = async (mode, fn) => {
366519
- const store6 = (await open4()).transaction("kv", mode).objectStore("kv");
366848
+ const tx2 = async (mode2, fn) => {
366849
+ const store6 = (await open4()).transaction("kv", mode2).objectStore("kv");
366520
366850
  return new Promise((res, rej) => {
366521
366851
  const r = fn(store6);
366522
366852
  r.onsuccess = () => res(r.result);
@@ -367717,8 +368047,8 @@ async function reviewUpdate(update3) {
367717
368047
  }
367718
368048
  function acceptUpdate(update3, payload, accept) {
367719
368049
  const lib = useLibraries.getState().available.find((l) => l.id === update3.libraryId);
367720
- const current4 = liveDoc().libraries?.[update3.libraryId];
367721
- const doc2 = applyLibrary(liveDoc(), update3.libraryId, { name: update3.name, version: update3.to, fileKey: lib?.fileKey ?? current4?.fileKey ?? void 0, importedAt: Date.now() }, payload, accept);
368050
+ const current5 = liveDoc().libraries?.[update3.libraryId];
368051
+ const doc2 = applyLibrary(liveDoc(), update3.libraryId, { name: update3.name, version: update3.to, fileKey: lib?.fileKey ?? current5?.fileKey ?? void 0, importedAt: Date.now() }, payload, accept);
367722
368052
  useEditorStore.getState().commitDocument(doc2, `Update library: ${update3.name}`);
367723
368053
  computeUpdates();
367724
368054
  }
@@ -368802,8 +369132,8 @@ var init_registry3 = __esm({
368802
369132
  });
368803
369133
 
368804
369134
  // lib/plugins/panels.ts
368805
- function pluginPanels(installed3) {
368806
- return installed3.filter((p2) => p2.enabled).flatMap((p2) => (p2.manifest.contributes?.panels ?? []).map((panel) => ({
369135
+ function pluginPanels(installed4) {
369136
+ return installed4.filter((p2) => p2.enabled).flatMap((p2) => (p2.manifest.contributes?.panels ?? []).map((panel) => ({
368807
369137
  tab: pluginPanelTab(p2.manifest.id, panel.id),
368808
369138
  pluginId: p2.manifest.id,
368809
369139
  pluginName: p2.manifest.name,
@@ -368811,8 +369141,8 @@ function pluginPanels(installed3) {
368811
369141
  icon: panel.icon ?? (p2.manifest.icon?.startsWith("data:image/") ? p2.manifest.icon : null)
368812
369142
  })));
368813
369143
  }
368814
- function syncPluginTabs(installed3) {
368815
- setPluginTabs(new Map(pluginPanels(installed3).map((p2) => [p2.tab, p2.panel.side ?? "right"])));
369144
+ function syncPluginTabs(installed4) {
369145
+ setPluginTabs(new Map(pluginPanels(installed4).map((p2) => [p2.tab, p2.panel.side ?? "right"])));
368816
369146
  }
368817
369147
  var pluginPanelTab;
368818
369148
  var init_panels = __esm({
@@ -368870,10 +369200,10 @@ function pluginToolCommand(plugin, tool2) {
368870
369200
  }
368871
369201
  });
368872
369202
  }
368873
- function syncPluginAgentTools(installed3) {
369203
+ function syncPluginAgentTools(installed4) {
368874
369204
  const want = /* @__PURE__ */ new Map();
368875
369205
  const nextSources = /* @__PURE__ */ new Map();
368876
- for (const plugin of installed3) {
369206
+ for (const plugin of installed4) {
368877
369207
  if (!pluginToolsActive(plugin)) continue;
368878
369208
  for (const tool2 of plugin.manifest.contributes.agentTools) {
368879
369209
  try {
@@ -373749,7 +374079,7 @@ var init_pdf2 = __esm({
373749
374079
  get signatureManager() {
373750
374080
  return this.#signatureManager;
373751
374081
  }
373752
- switchToMode(mode, callback) {
374082
+ switchToMode(mode2, callback) {
373753
374083
  this._eventBus.on("annotationeditormodechanged", callback, {
373754
374084
  once: true,
373755
374085
  signal: this._signal,
@@ -373757,7 +374087,7 @@ var init_pdf2 = __esm({
373757
374087
  });
373758
374088
  this._eventBus.dispatch("showannotationeditorui", {
373759
374089
  source: this,
373760
- mode
374090
+ mode: mode2
373761
374091
  });
373762
374092
  }
373763
374093
  setPreference(name2, value3) {
@@ -374409,8 +374739,8 @@ var init_pdf2 = __esm({
374409
374739
  removeLayer(layer2) {
374410
374740
  this.#allLayers.delete(layer2.pageIndex);
374411
374741
  }
374412
- async updateMode(mode, editId = null, isFromUser = false, isFromKeyboard = false, mustEnterInEditMode = false, editComment = false) {
374413
- if (this.#mode === mode) {
374742
+ async updateMode(mode2, editId = null, isFromUser = false, isFromKeyboard = false, mustEnterInEditMode = false, editComment = false) {
374743
+ if (this.#mode === mode2) {
374414
374744
  return;
374415
374745
  }
374416
374746
  if (this.#updateModeCapability) {
@@ -374425,8 +374755,8 @@ var init_pdf2 = __esm({
374425
374755
  this.#commentManager?.hideSidebar();
374426
374756
  }
374427
374757
  this.#commentManager?.destroyPopup();
374428
- this.#mode = mode;
374429
- if (mode === AnnotationEditorType.NONE) {
374758
+ this.#mode = mode2;
374759
+ if (mode2 === AnnotationEditorType.NONE) {
374430
374760
  this.setEditingState(false);
374431
374761
  this.#disableAll();
374432
374762
  for (const editor2 of this.#allEditors.values()) {
@@ -374440,7 +374770,7 @@ var init_pdf2 = __esm({
374440
374770
  for (const editor2 of this.#allEditors.values()) {
374441
374771
  editor2.addStandaloneCommentButton();
374442
374772
  }
374443
- if (mode === AnnotationEditorType.SIGNATURE) {
374773
+ if (mode2 === AnnotationEditorType.SIGNATURE) {
374444
374774
  await this.#signatureManager?.loadSignatures();
374445
374775
  }
374446
374776
  if (isFromUser) {
@@ -374450,9 +374780,9 @@ var init_pdf2 = __esm({
374450
374780
  await this.#enableAll();
374451
374781
  this.unselectAll();
374452
374782
  for (const layer2 of this.#allLayers.values()) {
374453
- layer2.updateMode(mode);
374783
+ layer2.updateMode(mode2);
374454
374784
  }
374455
- if (mode === AnnotationEditorType.POPUP) {
374785
+ if (mode2 === AnnotationEditorType.POPUP) {
374456
374786
  this.#allEditableAnnotations ||= await this.#pdfDocument.getAnnotationsByType(new Set(this.#editorTypes.map((editorClass) => editorClass._editorType)));
374457
374787
  const elementIds = /* @__PURE__ */ new Set();
374458
374788
  const allComments = [];
@@ -380946,20 +381276,20 @@ fn fs_main(in : VertexOutput) -> @location(0) vec4<f32> {
380946
381276
  graphics.current.updateClipFromPath();
380947
381277
  }
380948
381278
  setFillAndStrokeStyleToContext(graphics, paintType, color4) {
380949
- const context = graphics.ctx, current4 = graphics.current;
380950
- current4.patternFill = current4.patternStroke = false;
381279
+ const context = graphics.ctx, current5 = graphics.current;
381280
+ current5.patternFill = current5.patternStroke = false;
380951
381281
  switch (paintType) {
380952
381282
  case PaintType.COLORED:
380953
381283
  const {
380954
381284
  fillStyle,
380955
381285
  strokeStyle
380956
381286
  } = this.ctx;
380957
- context.fillStyle = current4.fillColor = fillStyle;
380958
- context.strokeStyle = current4.strokeColor = strokeStyle;
381287
+ context.fillStyle = current5.fillColor = fillStyle;
381288
+ context.strokeStyle = current5.strokeColor = strokeStyle;
380959
381289
  break;
380960
381290
  case PaintType.UNCOLORED:
380961
381291
  context.fillStyle = context.strokeStyle = color4;
380962
- current4.fillColor = current4.strokeColor = color4;
381292
+ current5.fillColor = current5.strokeColor = color4;
380963
381293
  break;
380964
381294
  default:
380965
381295
  throw new FormatError2(`Unsupported paint type: ${paintType}`);
@@ -382196,19 +382526,19 @@ fn fs_main(in : VertexOutput) -> @location(0) vec4<f32> {
382196
382526
  setFont(opIdx, fontRefName, size6) {
382197
382527
  this.dependencyTracker?.recordSimpleData("font", opIdx).recordSimpleDataFromNamed("fontObj", fontRefName, opIdx);
382198
382528
  const fontObj = this.commonObjs.get(fontRefName);
382199
- const current4 = this.current;
382529
+ const current5 = this.current;
382200
382530
  if (!fontObj) {
382201
382531
  throw new Error(`Can't find font for ${fontRefName}`);
382202
382532
  }
382203
- current4.fontMatrix = fontObj.fontMatrix || FONT_IDENTITY_MATRIX;
382204
- if (current4.fontMatrix[0] === 0 || current4.fontMatrix[3] === 0) {
382533
+ current5.fontMatrix = fontObj.fontMatrix || FONT_IDENTITY_MATRIX;
382534
+ if (current5.fontMatrix[0] === 0 || current5.fontMatrix[3] === 0) {
382205
382535
  warn3("Invalid font matrix for font " + fontRefName);
382206
382536
  }
382207
382537
  if (size6 < 0) {
382208
382538
  size6 = -size6;
382209
- current4.fontDirection = -1;
382539
+ current5.fontDirection = -1;
382210
382540
  } else {
382211
- current4.fontDirection = 1;
382541
+ current5.fontDirection = 1;
382212
382542
  }
382213
382543
  this.current.font = fontObj;
382214
382544
  this.current.fontSize = size6;
@@ -382228,9 +382558,9 @@ fn fs_main(in : VertexOutput) -> @location(0) vec4<f32> {
382228
382558
  this.current.fontSizeScale = size6 / browserFontSize;
382229
382559
  this.ctx.font = `${italic} ${bold} ${browserFontSize}px ${typeface}`;
382230
382560
  }
382231
- setTextRenderingMode(opIdx, mode) {
382561
+ setTextRenderingMode(opIdx, mode2) {
382232
382562
  this.dependencyTracker?.recordSimpleData("textRenderingMode", opIdx);
382233
- this.current.textRenderingMode = mode;
382563
+ this.current.textRenderingMode = mode2;
382234
382564
  }
382235
382565
  setTextRise(opIdx, rise) {
382236
382566
  this.dependencyTracker?.recordSimpleData("textRise", opIdx);
@@ -382248,12 +382578,12 @@ fn fs_main(in : VertexOutput) -> @location(0) vec4<f32> {
382248
382578
  setTextMatrix(opIdx, matrix) {
382249
382579
  this.dependencyTracker?.resetIncrementalData("sameLineText").recordSimpleData("textMatrix", opIdx);
382250
382580
  const {
382251
- current: current4
382581
+ current: current5
382252
382582
  } = this;
382253
- current4.textMatrix = matrix;
382254
- current4.textMatrixScale = Math.hypot(matrix[0], matrix[1]);
382255
- current4.x = current4.lineX = 0;
382256
- current4.y = current4.lineY = 0;
382583
+ current5.textMatrix = matrix;
382584
+ current5.textMatrixScale = Math.hypot(matrix[0], matrix[1]);
382585
+ current5.x = current5.lineX = 0;
382586
+ current5.y = current5.lineY = 0;
382257
382587
  }
382258
382588
  nextLine(opIdx) {
382259
382589
  this.moveText(opIdx, 0, this.current.leading);
@@ -382266,14 +382596,14 @@ fn fs_main(in : VertexOutput) -> @location(0) vec4<f32> {
382266
382596
  }
382267
382597
  paintChar(opIdx, character, x2, y, patternFillTransform, patternStrokeTransform) {
382268
382598
  const ctx2 = this.ctx;
382269
- const current4 = this.current;
382270
- const font = current4.font;
382271
- const textRenderingMode = current4.textRenderingMode;
382272
- const fontSize = current4.fontSize / current4.fontSizeScale;
382599
+ const current5 = this.current;
382600
+ const font = current5.font;
382601
+ const textRenderingMode = current5.textRenderingMode;
382602
+ const fontSize = current5.fontSize / current5.fontSizeScale;
382273
382603
  const fillStrokeMode = textRenderingMode & TextRenderingMode.FILL_STROKE_MASK;
382274
382604
  const isAddToPathSet = !!(textRenderingMode & TextRenderingMode.ADD_TO_PATH_FLAG);
382275
- const patternFill = current4.patternFill && !font.missingFile;
382276
- const patternStroke = current4.patternStroke && !font.missingFile;
382605
+ const patternFill = current5.patternFill && !font.missingFile;
382606
+ const patternStroke = current5.patternStroke && !font.missingFile;
382277
382607
  let path;
382278
382608
  if ((font.disableFontFace || isAddToPathSet || patternFill || patternStroke) && !font.missingFile) {
382279
382609
  path = font.getPathGenerator(this.commonObjs, character);
@@ -382362,49 +382692,49 @@ fn fs_main(in : VertexOutput) -> @location(0) vec4<f32> {
382362
382692
  this.dependencyTracker.recordFutureForcedDependency("textClip", opIdx).inheritPendingDependenciesAsFutureForcedDependencies();
382363
382693
  }
382364
382694
  }
382365
- const current4 = this.current;
382366
- const font = current4.font;
382695
+ const current5 = this.current;
382696
+ const font = current5.font;
382367
382697
  if (font.isType3Font) {
382368
- const started9 = this.#beginKnockoutElement(current4.fillAlpha);
382698
+ const started9 = this.#beginKnockoutElement(current5.fillAlpha);
382369
382699
  this.showType3Text(opIdx, glyphs);
382370
382700
  this.dependencyTracker?.recordShowTextOperation(opIdx);
382371
382701
  this.#endKnockoutElement(started9);
382372
382702
  return;
382373
382703
  }
382374
- const fontSize = current4.fontSize;
382704
+ const fontSize = current5.fontSize;
382375
382705
  if (fontSize === 0) {
382376
382706
  this.dependencyTracker?.recordOperation(opIdx);
382377
382707
  return;
382378
382708
  }
382379
- const started8 = this.#beginKnockoutElement(current4.fillAlpha);
382709
+ const started8 = this.#beginKnockoutElement(current5.fillAlpha);
382380
382710
  const ctx2 = this.ctx;
382381
- const fontSizeScale = current4.fontSizeScale;
382382
- const charSpacing = current4.charSpacing;
382383
- const wordSpacing = current4.wordSpacing;
382384
- const fontDirection = current4.fontDirection;
382385
- const textHScale = current4.textHScale * fontDirection;
382711
+ const fontSizeScale = current5.fontSizeScale;
382712
+ const charSpacing = current5.charSpacing;
382713
+ const wordSpacing = current5.wordSpacing;
382714
+ const fontDirection = current5.fontDirection;
382715
+ const textHScale = current5.textHScale * fontDirection;
382386
382716
  const glyphsLength = glyphs.length;
382387
382717
  const vertical = font.vertical;
382388
382718
  const spacingDir = vertical ? 1 : -1;
382389
382719
  const defaultVMetrics = font.defaultVMetrics;
382390
- const widthAdvanceScale = fontSize * current4.fontMatrix[0];
382391
- const simpleFillText = current4.textRenderingMode === TextRenderingMode.FILL && !font.disableFontFace && !current4.patternFill;
382720
+ const widthAdvanceScale = fontSize * current5.fontMatrix[0];
382721
+ const simpleFillText = current5.textRenderingMode === TextRenderingMode.FILL && !font.disableFontFace && !current5.patternFill;
382392
382722
  ctx2.save();
382393
- if (current4.textMatrix) {
382394
- ctx2.transform(...current4.textMatrix);
382723
+ if (current5.textMatrix) {
382724
+ ctx2.transform(...current5.textMatrix);
382395
382725
  }
382396
- ctx2.translate(current4.x, current4.y + current4.textRise);
382726
+ ctx2.translate(current5.x, current5.y + current5.textRise);
382397
382727
  if (fontDirection > 0) {
382398
382728
  ctx2.scale(textHScale, -1);
382399
382729
  } else {
382400
382730
  ctx2.scale(textHScale, 1);
382401
382731
  }
382402
382732
  let patternFillTransform, patternStrokeTransform;
382403
- const fillStrokeMode = current4.textRenderingMode & TextRenderingMode.FILL_STROKE_MASK;
382733
+ const fillStrokeMode = current5.textRenderingMode & TextRenderingMode.FILL_STROKE_MASK;
382404
382734
  const needsFill = fillStrokeMode === TextRenderingMode.FILL || fillStrokeMode === TextRenderingMode.FILL_STROKE;
382405
382735
  const needsStroke = fillStrokeMode === TextRenderingMode.STROKE || fillStrokeMode === TextRenderingMode.FILL_STROKE;
382406
- let lineWidth2 = current4.lineWidth;
382407
- const scale = current4.textMatrixScale;
382736
+ let lineWidth2 = current5.lineWidth;
382737
+ const scale = current5.textMatrixScale;
382408
382738
  if (scale === 0 || lineWidth2 === 0) {
382409
382739
  if (needsStroke) {
382410
382740
  lineWidth2 = this.getSinglePixelWidth();
@@ -382417,16 +382747,16 @@ fn fs_main(in : VertexOutput) -> @location(0) vec4<f32> {
382417
382747
  lineWidth2 /= fontSizeScale;
382418
382748
  }
382419
382749
  ctx2.lineWidth = lineWidth2;
382420
- if (needsFill && current4.patternFill) {
382750
+ if (needsFill && current5.patternFill) {
382421
382751
  ctx2.save();
382422
- const pattern = current4.fillColor.getPattern(ctx2, this, getCurrentTransformInverse(ctx2), PathType.FILL, opIdx);
382752
+ const pattern = current5.fillColor.getPattern(ctx2, this, getCurrentTransformInverse(ctx2), PathType.FILL, opIdx);
382423
382753
  patternFillTransform = getCurrentTransform(ctx2);
382424
382754
  ctx2.restore();
382425
382755
  ctx2.fillStyle = pattern;
382426
382756
  }
382427
- if (needsStroke && current4.patternStroke) {
382757
+ if (needsStroke && current5.patternStroke) {
382428
382758
  ctx2.save();
382429
- const pattern = current4.strokeColor.getPattern(ctx2, this, getCurrentTransformInverse(ctx2), PathType.STROKE, opIdx);
382759
+ const pattern = current5.strokeColor.getPattern(ctx2, this, getCurrentTransformInverse(ctx2), PathType.STROKE, opIdx);
382430
382760
  patternStrokeTransform = getCurrentTransform(ctx2);
382431
382761
  ctx2.restore();
382432
382762
  ctx2.strokeStyle = pattern;
@@ -382444,7 +382774,7 @@ fn fs_main(in : VertexOutput) -> @location(0) vec4<f32> {
382444
382774
  const measure4 = ctx2.measureText(joinedChars);
382445
382775
  this.dependencyTracker.recordBBox(opIdx, this.ctx, -measure4.actualBoundingBoxLeft, measure4.actualBoundingBoxRight, -measure4.actualBoundingBoxAscent, measure4.actualBoundingBoxDescent).recordShowTextOperation(opIdx);
382446
382776
  }
382447
- current4.x += width * widthAdvanceScale * textHScale;
382777
+ current5.x += width * widthAdvanceScale * textHScale;
382448
382778
  ctx2.restore();
382449
382779
  this.compose();
382450
382780
  this.#endKnockoutElement(started8);
@@ -382510,9 +382840,9 @@ fn fs_main(in : VertexOutput) -> @location(0) vec4<f32> {
382510
382840
  }
382511
382841
  }
382512
382842
  if (vertical) {
382513
- current4.y -= x2;
382843
+ current5.y -= x2;
382514
382844
  } else {
382515
- current4.x += x2 * textHScale;
382845
+ current5.x += x2 * textHScale;
382516
382846
  }
382517
382847
  ctx2.restore();
382518
382848
  this.compose();
@@ -382521,17 +382851,17 @@ fn fs_main(in : VertexOutput) -> @location(0) vec4<f32> {
382521
382851
  }
382522
382852
  showType3Text(opIdx, glyphs) {
382523
382853
  const ctx2 = this.ctx;
382524
- const current4 = this.current;
382525
- const font = current4.font;
382526
- const fontSize = current4.fontSize;
382527
- const fontDirection = current4.fontDirection;
382854
+ const current5 = this.current;
382855
+ const font = current5.font;
382856
+ const fontSize = current5.fontSize;
382857
+ const fontDirection = current5.fontDirection;
382528
382858
  const spacingDir = font.vertical ? 1 : -1;
382529
- const charSpacing = current4.charSpacing;
382530
- const wordSpacing = current4.wordSpacing;
382531
- const textHScale = current4.textHScale * fontDirection;
382532
- const fontMatrix = current4.fontMatrix || FONT_IDENTITY_MATRIX;
382859
+ const charSpacing = current5.charSpacing;
382860
+ const wordSpacing = current5.wordSpacing;
382861
+ const textHScale = current5.textHScale * fontDirection;
382862
+ const fontMatrix = current5.fontMatrix || FONT_IDENTITY_MATRIX;
382533
382863
  const glyphsLength = glyphs.length;
382534
- const isTextInvisible = current4.textRenderingMode === TextRenderingMode.INVISIBLE;
382864
+ const isTextInvisible = current5.textRenderingMode === TextRenderingMode.INVISIBLE;
382535
382865
  let i2, glyph2, width, spacingLength;
382536
382866
  if (isTextInvisible || fontSize === 0) {
382537
382867
  return;
@@ -382539,10 +382869,10 @@ fn fs_main(in : VertexOutput) -> @location(0) vec4<f32> {
382539
382869
  this._cachedScaleForStroking[0] = -1;
382540
382870
  this._cachedGetSinglePixelWidth = null;
382541
382871
  ctx2.save();
382542
- if (current4.textMatrix) {
382543
- ctx2.transform(...current4.textMatrix);
382872
+ if (current5.textMatrix) {
382873
+ ctx2.transform(...current5.textMatrix);
382544
382874
  }
382545
- ctx2.translate(current4.x, current4.y + current4.textRise);
382875
+ ctx2.translate(current5.x, current5.y + current5.textRise);
382546
382876
  ctx2.scale(textHScale, fontDirection);
382547
382877
  const dependencyTracker = this.dependencyTracker;
382548
382878
  this.dependencyTracker = dependencyTracker ? new CanvasNestedDependencyTracker(dependencyTracker, opIdx) : null;
@@ -382551,7 +382881,7 @@ fn fs_main(in : VertexOutput) -> @location(0) vec4<f32> {
382551
382881
  if (typeof glyph2 === "number") {
382552
382882
  spacingLength = spacingDir * glyph2 * fontSize / 1e3;
382553
382883
  this.ctx.translate(spacingLength, 0);
382554
- current4.x += spacingLength * textHScale;
382884
+ current5.x += spacingLength * textHScale;
382555
382885
  continue;
382556
382886
  }
382557
382887
  const spacing = (glyph2.isSpace ? wordSpacing : 0) + charSpacing;
@@ -382561,7 +382891,7 @@ fn fs_main(in : VertexOutput) -> @location(0) vec4<f32> {
382561
382891
  } else if (this.contentVisible) {
382562
382892
  this.save();
382563
382893
  if (operatorList.fnArray[0] === OPS2.setCharWidth) {
382564
- current4.fillAlpha = current4.strokeAlpha = 1;
382894
+ current5.fillAlpha = current5.strokeAlpha = 1;
382565
382895
  ctx2.globalAlpha = 1;
382566
382896
  }
382567
382897
  ctx2.scale(fontSize, fontSize);
@@ -382573,7 +382903,7 @@ fn fs_main(in : VertexOutput) -> @location(0) vec4<f32> {
382573
382903
  Util.applyTransform(p2, fontMatrix);
382574
382904
  width = p2[0] * fontSize + spacing;
382575
382905
  ctx2.translate(width, 0);
382576
- current4.x += width * textHScale;
382906
+ current5.x += width * textHScale;
382577
382907
  }
382578
382908
  ctx2.restore();
382579
382909
  if (dependencyTracker) {
@@ -387985,7 +388315,7 @@ fn fs_main(in : VertexOutput) -> @location(0) vec4<f32> {
387985
388315
  return;
387986
388316
  }
387987
388317
  const {
387988
- annotationEditorType: mode,
388318
+ annotationEditorType: mode2,
387989
388319
  data: {
387990
388320
  id: editId
387991
388321
  }
@@ -387993,7 +388323,7 @@ fn fs_main(in : VertexOutput) -> @location(0) vec4<f32> {
387993
388323
  this.container.addEventListener("dblclick", () => {
387994
388324
  this.linkService.eventBus?.dispatch("switchannotationeditormode", {
387995
388325
  source: this,
387996
- mode,
388326
+ mode: mode2,
387997
388327
  editId,
387998
388328
  mustEnterInEditMode: true
387999
388329
  });
@@ -396350,9 +396680,9 @@ fn fs_main(in : VertexOutput) -> @location(0) vec4<f32> {
396350
396680
  updateToolbar(options) {
396351
396681
  this.#uiManager.updateToolbar(options);
396352
396682
  }
396353
- updateMode(mode = this.#uiManager.getMode()) {
396683
+ updateMode(mode2 = this.#uiManager.getMode()) {
396354
396684
  this.#cleanup();
396355
- switch (mode) {
396685
+ switch (mode2) {
396356
396686
  case AnnotationEditorType.NONE:
396357
396687
  this.div.classList.toggle("nonEditing", true);
396358
396688
  this.disableTextSelection();
@@ -396380,12 +396710,12 @@ fn fs_main(in : VertexOutput) -> @location(0) vec4<f32> {
396380
396710
  classList
396381
396711
  } = this.div;
396382
396712
  classList.toggle("nonEditing", false);
396383
- if (mode === AnnotationEditorType.POPUP) {
396713
+ if (mode2 === AnnotationEditorType.POPUP) {
396384
396714
  classList.toggle("commentEditing", true);
396385
396715
  } else {
396386
396716
  classList.toggle("commentEditing", false);
396387
396717
  for (const editorType of _AnnotationEditorLayer.#editorTypes.values()) {
396388
- classList.toggle(`${editorType._type}Editing`, mode === editorType._editorType);
396718
+ classList.toggle(`${editorType._type}Editing`, mode2 === editorType._editorType);
396389
396719
  }
396390
396720
  }
396391
396721
  this.div.hidden = false;
@@ -398444,17 +398774,17 @@ function runningSessionFor(pluginId) {
398444
398774
  return [...running3.values()].find((s) => s.plugin.manifest.id === pluginId);
398445
398775
  }
398446
398776
  async function refreshInstalledPlugins() {
398447
- const installed3 = await listPlugins();
398448
- syncPluginTabs(installed3);
398449
- usePluginStore.getState().setInstalled(installed3);
398450
- syncPluginThemes(installed3);
398451
- syncPluginAgentTools(installed3);
398777
+ const installed4 = await listPlugins();
398778
+ syncPluginTabs(installed4);
398779
+ usePluginStore.getState().setInstalled(installed4);
398780
+ syncPluginThemes(installed4);
398781
+ syncPluginAgentTools(installed4);
398452
398782
  }
398453
- function syncPluginThemes(installed3) {
398783
+ function syncPluginThemes(installed4) {
398454
398784
  const themes = useThemeStore.getState();
398455
- const live = new Set(installed3.map((p2) => p2.manifest.id));
398785
+ const live = new Set(installed4.map((p2) => p2.manifest.id));
398456
398786
  for (const id3 of Object.keys(themes.pluginThemes)) if (!live.has(id3)) themes.setPluginThemes(id3, []);
398457
- for (const p2 of installed3) themes.setPluginThemes(p2.manifest.id, p2.enabled ? p2.themes ?? [] : []);
398787
+ for (const p2 of installed4) themes.setPluginThemes(p2.manifest.id, p2.enabled ? p2.themes ?? [] : []);
398458
398788
  }
398459
398789
  async function installPluginPayload(payload, opts = {}) {
398460
398790
  const rec = await installPlugin(payload);
@@ -398504,13 +398834,13 @@ async function runPlugin(pluginId, commandId, opts = {}) {
398504
398834
  iframe.style.display = "none";
398505
398835
  iframe.dataset.popcraftPlugin = pluginId;
398506
398836
  iframe.srcdoc = withAgentToolsShim(withWasmEvalCsp(buildMainDocument(plugin.mainCode, granted.includes("network"))));
398507
- const channel3 = new MessageChannel();
398837
+ const channel4 = new MessageChannel();
398508
398838
  const session3 = {
398509
398839
  sessionId,
398510
398840
  plugin,
398511
398841
  granted,
398512
398842
  iframe,
398513
- port: channel3.port1,
398843
+ port: channel4.port1,
398514
398844
  uiPort: null,
398515
398845
  pendingToUI: [],
398516
398846
  unsubscribers: [],
@@ -398521,7 +398851,7 @@ async function runPlugin(pluginId, commandId, opts = {}) {
398521
398851
  exportRequest: opts.exportRequest ?? null,
398522
398852
  env: null,
398523
398853
  tools: createToolChannel((event, data) => {
398524
- if (running3.has(sessionId)) channel3.port1.postMessage({ kind: "event", event, data });
398854
+ if (running3.has(sessionId)) channel4.port1.postMessage({ kind: "event", event, data });
398525
398855
  }, plugin.manifest.name)
398526
398856
  };
398527
398857
  running3.set(sessionId, session3);
@@ -398604,15 +398934,15 @@ async function runPlugin(pluginId, commandId, opts = {}) {
398604
398934
  }
398605
398935
  };
398606
398936
  session3.env = env;
398607
- channel3.port1.onmessage = async (ev) => {
398937
+ channel4.port1.onmessage = async (ev) => {
398608
398938
  const m = ev.data;
398609
398939
  if (!running3.has(sessionId)) return;
398610
398940
  if (m.kind === "rpc" && typeof m.id === "number" && typeof m.method === "string") {
398611
398941
  try {
398612
398942
  const result = await handlePluginCall(env, m.method, m.params ?? {});
398613
- if (running3.has(sessionId)) channel3.port1.postMessage({ kind: "result", id: m.id, result });
398943
+ if (running3.has(sessionId)) channel4.port1.postMessage({ kind: "result", id: m.id, result });
398614
398944
  } catch (err2) {
398615
- if (running3.has(sessionId)) channel3.port1.postMessage({ kind: "result", id: m.id, error: err2 instanceof Error ? err2.message : String(err2) });
398945
+ if (running3.has(sessionId)) channel4.port1.postMessage({ kind: "result", id: m.id, error: err2 instanceof Error ? err2.message : String(err2) });
398616
398946
  }
398617
398947
  } else if (m.kind === "toUI") {
398618
398948
  if (session3.uiPort) session3.uiPort.postMessage({ kind: "event", event: "message", data: m.data });
@@ -398624,7 +398954,7 @@ async function runPlugin(pluginId, commandId, opts = {}) {
398624
398954
  }
398625
398955
  };
398626
398956
  iframe.addEventListener("load", () => {
398627
- iframe.contentWindow?.postMessage({ type: "popcraft-plugin-port" }, "*", [channel3.port2]);
398957
+ iframe.contentWindow?.postMessage({ type: "popcraft-plugin-port" }, "*", [channel4.port2]);
398628
398958
  post(session3, "init", {
398629
398959
  command,
398630
398960
  importMode: session3.importMode,
@@ -398659,15 +398989,15 @@ function attachPluginUI(sessionId, iframe) {
398659
398989
  const session3 = running3.get(sessionId);
398660
398990
  if (!session3 || !iframe.contentWindow) return;
398661
398991
  session3.uiPort?.close();
398662
- const channel3 = new MessageChannel();
398663
- session3.uiPort = channel3.port1;
398664
- channel3.port1.onmessage = (ev) => {
398992
+ const channel4 = new MessageChannel();
398993
+ session3.uiPort = channel4.port1;
398994
+ channel4.port1.onmessage = (ev) => {
398665
398995
  const m = ev.data;
398666
398996
  if (m.kind === "fromUI") post(session3, "uimessage", m.data);
398667
398997
  else if (m.kind === "closeUI") usePluginStore.getState().patchSession(sessionId, { ui: null });
398668
398998
  };
398669
- iframe.contentWindow.postMessage({ type: "popcraft-plugin-port" }, "*", [channel3.port2]);
398670
- for (const data of session3.pendingToUI.splice(0)) channel3.port1.postMessage({ kind: "event", event: "message", data });
398999
+ iframe.contentWindow.postMessage({ type: "popcraft-plugin-port" }, "*", [channel4.port2]);
399000
+ for (const data of session3.pendingToUI.splice(0)) channel4.port1.postMessage({ kind: "event", event: "message", data });
398671
399001
  }
398672
399002
  function pluginUIDocument(sessionId) {
398673
399003
  const s = running3.get(sessionId);
@@ -398699,8 +399029,8 @@ async function ensureBackgroundSession(pluginId, command) {
398699
399029
  }
398700
399030
  async function callPluginTool(plugin, tool2, args2, options) {
398701
399031
  const id3 = plugin.manifest.id;
398702
- const current4 = await getPlugin(id3);
398703
- if (!current4?.enabled || current4.granted === null) throw new Error(`${plugin.manifest.name} is disabled or has not been allowed to run`);
399032
+ const current5 = await getPlugin(id3);
399033
+ if (!current5?.enabled || current5.granted === null) throw new Error(`${plugin.manifest.name} is disabled or has not been allowed to run`);
398704
399034
  const session3 = await ensureBackgroundSession(id3, "agent");
398705
399035
  if (!session3?.env) throw new Error(`${plugin.manifest.name} could not start`);
398706
399036
  const env = session3.env;
@@ -398770,13 +399100,13 @@ var init_host3 = __esm({
398770
399100
  const d = e.data;
398771
399101
  if (!d) return;
398772
399102
  if (d.type !== "popcraft-import-as-new" && d.type !== "popcraft-import-into-current") return;
398773
- const mode = d.type === "popcraft-import-as-new" ? "new" : "into-current";
399103
+ const mode2 = d.type === "popcraft-import-as-new" ? "new" : "into-current";
398774
399104
  const name2 = d.name || "Imported";
398775
399105
  void (async () => {
398776
399106
  try {
398777
399107
  const { importViaPlugin: importViaPlugin2, applyPluginLayoutIr: applyPluginLayoutIr2 } = await Promise.resolve().then(() => (init_plugin_import(), plugin_import_exports));
398778
399108
  if (d.ir && typeof d.ir === "object") {
398779
- await applyPluginLayoutIr2(d.ir, { mode, name: name2 });
399109
+ await applyPluginLayoutIr2(d.ir, { mode: mode2, name: name2 });
398780
399110
  return;
398781
399111
  }
398782
399112
  if (typeof d.dataUrl !== "string") return;
@@ -398785,7 +399115,7 @@ var init_host3 = __esm({
398785
399115
  const bytes2 = new Uint8Array(bin.length);
398786
399116
  for (let i2 = 0; i2 < bin.length; i2++) bytes2[i2] = bin.charCodeAt(i2);
398787
399117
  const file2 = new File([bytes2], name2);
398788
- await importViaPlugin2(file2, { mode });
399118
+ await importViaPlugin2(file2, { mode: mode2 });
398789
399119
  } catch (err2) {
398790
399120
  usePluginStore.getState().toast(String(err2 instanceof Error ? err2.message : err2), { error: true });
398791
399121
  }
@@ -401046,17 +401376,17 @@ __export(recorders_exports, {
401046
401376
  setDesignRecorder: () => setDesignRecorder
401047
401377
  });
401048
401378
  function setDesignRecorder(r) {
401049
- installed = r;
401379
+ installed2 = r;
401050
401380
  }
401051
401381
  function designRecorder() {
401052
- if (installed) return installed;
401382
+ if (installed2) return installed2;
401053
401383
  if (typeof window !== "undefined") return async (source3, namespaces2, globals) => (await Promise.resolve().then(() => (init_sandbox(), sandbox_exports))).recordInSandbox(source3, namespaces2, globals);
401054
401384
  throw new Error("Design scripts are built in the editor, the desktop app or the popcraft CLI, not on the server: build the file with the CLI (popcraft run file.popcraft write_design \u2026) and push it, or run it in the app (popcraft run --ui \u2026).");
401055
401385
  }
401056
- var installed;
401386
+ var installed2;
401057
401387
  var init_recorders = __esm({
401058
401388
  "lib/agent/design-script/recorders.ts"() {
401059
- installed = null;
401389
+ installed2 = null;
401060
401390
  }
401061
401391
  });
401062
401392
 
@@ -402420,8 +402750,8 @@ var init_app = __esm({
402420
402750
  permission: null,
402421
402751
  params: external_exports.object({ mode: external_exports.enum([...MODE_IDS, ...Object.keys(MODE_ALIASES)]) }),
402422
402752
  expose: { ui: { label: "Switch mode", keywords: ["mode", "view"], variants: MODE_LIST.map((m) => ({ id: m.id.toLowerCase(), label: `${m.label} mode`, shortcut: m.shortcut, params: { mode: m.id } })) } },
402423
- run: async ({ mode }) => {
402424
- const id3 = MODE_ALIASES[mode] ?? mode;
402753
+ run: async ({ mode: mode2 }) => {
402754
+ const id3 = MODE_ALIASES[mode2] ?? mode2;
402425
402755
  (await store5()).setMode(id3);
402426
402756
  return { summary: `${MODE_LIST.find((m) => m.id === id3)?.label} mode` };
402427
402757
  }
@@ -405328,13 +405658,13 @@ function settleRequest(outcome) {
405328
405658
  emit5();
405329
405659
  p2.resolve(outcome);
405330
405660
  }
405331
- var pending7, listeners7, emit5, opener;
405661
+ var pending7, listeners8, emit5, opener;
405332
405662
  var init_requests = __esm({
405333
405663
  "lib/audio/presentation/requests.ts"() {
405334
405664
  pending7 = null;
405335
- listeners7 = /* @__PURE__ */ new Set();
405665
+ listeners8 = /* @__PURE__ */ new Set();
405336
405666
  emit5 = () => {
405337
- for (const l of listeners7) l();
405667
+ for (const l of listeners8) l();
405338
405668
  };
405339
405669
  opener = null;
405340
405670
  }
@@ -406125,7 +406455,6 @@ function registerBuiltinCommands() {
406125
406455
  var builtinCommands, uiOnlyCommands;
406126
406456
  var init_builtin4 = __esm({
406127
406457
  "lib/commands/builtin.ts"() {
406128
- "use strict";
406129
406458
  init_registry();
406130
406459
  init_node();
406131
406460
  init_node();
@@ -406204,6 +406533,7 @@ var init_builtin4 = __esm({
406204
406533
  viewSelect,
406205
406534
  viewZoomTo,
406206
406535
  viewStage,
406536
+ viewScreenLayout,
406207
406537
  viewPresent,
406208
406538
  showSetAdvance,
406209
406539
  // was document.ts
@@ -408389,11 +408719,11 @@ var init_editor_store = __esm({
408389
408719
  return newNode;
408390
408720
  };
408391
408721
  const traverse = (currentId, sx, sy) => {
408392
- const current4 = sourceNodes[currentId];
408393
- if (!current4) return;
408394
- newNodes[currentId] = scaleProps(current4, sx, sy);
408395
- if ("childIds" in current4 && current4.childIds) {
408396
- for (const childId of current4.childIds) {
408722
+ const current5 = sourceNodes[currentId];
408723
+ if (!current5) return;
408724
+ newNodes[currentId] = scaleProps(current5, sx, sy);
408725
+ if ("childIds" in current5 && current5.childIds) {
408726
+ for (const childId of current5.childIds) {
408397
408727
  traverse(childId, sx, sy);
408398
408728
  }
408399
408729
  }
@@ -408756,10 +409086,10 @@ var init_editor_store = __esm({
408756
409086
  const state = get4();
408757
409087
  const newExpanded = new Set(state.expandedLayerNodes);
408758
409088
  ids2.forEach((id3) => {
408759
- let current4 = resolveVirtualNode2(state.document.nodes, id3);
408760
- for (let guard2 = 0; current4?.parentId && guard2 < 64; guard2++) {
408761
- newExpanded.add(current4.parentId);
408762
- current4 = resolveVirtualNode2(state.document.nodes, current4.parentId);
409089
+ let current5 = resolveVirtualNode2(state.document.nodes, id3);
409090
+ for (let guard2 = 0; current5?.parentId && guard2 < 64; guard2++) {
409091
+ newExpanded.add(current5.parentId);
409092
+ current5 = resolveVirtualNode2(state.document.nodes, current5.parentId);
408763
409093
  }
408764
409094
  });
408765
409095
  const cellSel = state.tableCellSelection;
@@ -408771,10 +409101,10 @@ var init_editor_store = __esm({
408771
409101
  addToSelection: (id3) => {
408772
409102
  const state = get4();
408773
409103
  const newExpanded = new Set(state.expandedLayerNodes);
408774
- let current4 = state.document.nodes[id3];
408775
- while (current4 && current4.parentId) {
408776
- newExpanded.add(current4.parentId);
408777
- current4 = state.document.nodes[current4.parentId];
409104
+ let current5 = state.document.nodes[id3];
409105
+ while (current5 && current5.parentId) {
409106
+ newExpanded.add(current5.parentId);
409107
+ current5 = state.document.nodes[current5.parentId];
408778
409108
  }
408779
409109
  set4({
408780
409110
  selection: [...state.selection, id3],
@@ -409316,11 +409646,11 @@ var init_editor_store = __esm({
409316
409646
  if (!pages2.length) return;
409317
409647
  const cam = state.camera;
409318
409648
  const selected = pages2.findIndex((pg) => state.selection.includes(pg.id));
409319
- const current4 = selected >= 0 ? selected : pages2.reduce((best, pg, i2) => {
409649
+ const current5 = selected >= 0 ? selected : pages2.reduce((best, pg, i2) => {
409320
409650
  const d = Math.hypot(pg.x + pg.width / 2 - cam.x, pg.y + pg.height / 2 - cam.y);
409321
409651
  return d < best.d ? { i: i2, d } : best;
409322
409652
  }, { i: 0, d: Infinity }).i;
409323
- const target2 = typeof to === "number" ? to : to === "first" ? 0 : to === "last" ? pages2.length - 1 : current4 + (to === "next" ? 1 : -1);
409653
+ const target2 = typeof to === "number" ? to : to === "first" ? 0 : to === "last" ? pages2.length - 1 : current5 + (to === "next" ? 1 : -1);
409324
409654
  const page = pages2[Math.max(0, Math.min(pages2.length - 1, target2))];
409325
409655
  set4({ selection: [page.id] });
409326
409656
  get4().zoomToNodes([page.id], 0.1);
@@ -410099,14 +410429,14 @@ var init_editor_store = __esm({
410099
410429
  for (const p2 of points) get4().pickShapeBuilderFace(p2.x, p2.y, "add");
410100
410430
  get4().commitShapeBuilder();
410101
410431
  },
410102
- pickShapeBuilderFace: (worldX, worldY, mode) => {
410432
+ pickShapeBuilderFace: (worldX, worldY, mode2) => {
410103
410433
  const state = get4();
410104
410434
  const sb = state.shapeBuilder;
410105
410435
  if (!sb) return;
410106
410436
  const i2 = faceAt(shapeBuilderFaces(state.document, sb.nodeIds), worldX, worldY);
410107
410437
  if (i2 < 0) return;
410108
410438
  const has = sb.picked.includes(i2);
410109
- const wanted = mode === "toggle" ? !has : mode === "add";
410439
+ const wanted = mode2 === "toggle" ? !has : mode2 === "add";
410110
410440
  if (wanted === has) return;
410111
410441
  set4({ shapeBuilder: { ...sb, picked: wanted ? [...sb.picked, i2] : sb.picked.filter((x2) => x2 !== i2) } });
410112
410442
  },
@@ -410723,7 +411053,7 @@ var init_editor_store = __esm({
410723
411053
  const collection = state.document.variableCollections?.[collectionId];
410724
411054
  if (!collection) return;
410725
411055
  const modeId = v4_default();
410726
- const mode = { id: modeId, name: name2 || `Mode ${collection.modes.length + 1}` };
411056
+ const mode2 = { id: modeId, name: name2 || `Mode ${collection.modes.length + 1}` };
410727
411057
  const newVariables = { ...state.document.variables || {} };
410728
411058
  for (const [vid, v] of Object.entries(newVariables)) {
410729
411059
  if (v.variableCollectionId !== collectionId) continue;
@@ -410736,7 +411066,7 @@ var init_editor_store = __esm({
410736
411066
  variables: newVariables,
410737
411067
  variableCollections: {
410738
411068
  ...state.document.variableCollections,
410739
- [collectionId]: { ...collection, modes: [...collection.modes, mode] }
411069
+ [collectionId]: { ...collection, modes: [...collection.modes, mode2] }
410740
411070
  }
410741
411071
  };
410742
411072
  const command = createCommand("ADD_VARIABLE_MODE", "Add variable mode", documentBefore, documentAfter);
@@ -411485,10 +411815,10 @@ async function installHyperySession(url4) {
411485
411815
  getToken: async () => (session3 = await freshSession(url4, session3)).accessToken
411486
411816
  });
411487
411817
  useAiStore2.setState({ signedIn: true, online: true });
411488
- installed2 = session3;
411818
+ installed3 = session3;
411489
411819
  return session3;
411490
411820
  }
411491
- var account, REFRESH_MARGIN_MS, SIGN_IN_TIMEOUT_MS, b64url, forgetSession, installed2, hyperySignedIn;
411821
+ var account, REFRESH_MARGIN_MS, SIGN_IN_TIMEOUT_MS, b64url, forgetSession, installed3, hyperySignedIn;
411492
411822
  var init_hypery = __esm({
411493
411823
  "packages/cli/src/hypery.ts"() {
411494
411824
  "use strict";
@@ -411499,8 +411829,8 @@ var init_hypery = __esm({
411499
411829
  SIGN_IN_TIMEOUT_MS = 10 * 6e4;
411500
411830
  b64url = (buf) => buf.toString("base64url");
411501
411831
  forgetSession = (url4) => forgetToken(account(url4));
411502
- installed2 = null;
411503
- hyperySignedIn = () => installed2 !== null;
411832
+ installed3 = null;
411833
+ hyperySignedIn = () => installed3 !== null;
411504
411834
  }
411505
411835
  });
411506
411836
 
@@ -413469,9 +413799,9 @@ import { dirname as dirname5, extname as extname3, join as join12, resolve as re
413469
413799
  function loadPlugin(ref3, root2 = desktopDataDir()) {
413470
413800
  let path = ref3;
413471
413801
  if (!existsSync13(path)) {
413472
- const installed3 = listResources2("plugins", root2).find((r) => r.name === ref3);
413473
- if (!installed3) throw usage(`No plugin "${ref3}": give its folder, .zip or .json, or the name of one in \`popcraft plugins list\`.`);
413474
- path = join12(root2, installed3.path);
413802
+ const installed4 = listResources2("plugins", root2).find((r) => r.name === ref3);
413803
+ if (!installed4) throw usage(`No plugin "${ref3}": give its folder, .zip or .json, or the name of one in \`popcraft plugins list\`.`);
413804
+ path = join12(root2, installed4.path);
413475
413805
  }
413476
413806
  if (statSync6(path).isDirectory()) {
413477
413807
  const dir = resolve6(path);
@@ -413729,7 +414059,7 @@ init_resources();
413729
414059
  init_desktop();
413730
414060
  init_hypery();
413731
414061
  import { createInterface } from "node:readline";
413732
- var VERSION2 = "0.48.3";
414062
+ var VERSION2 = "0.50.0";
413733
414063
  var HELP = `popcraft ${VERSION2} \u2014 the PopCraft command line
413734
414064
 
413735
414065
  Files (headless, on .popcraft files):