@popcraft/cli 0.43.1 → 0.44.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 +769 -622
  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.43.1"}`, ...opts.headers };
1199
+ const headers = { "user-agent": `popcraft-cli/${"0.44.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 {
@@ -2258,10 +2258,10 @@ function substituteTokens(node2, pattern, resolve7) {
2258
2258
  return out;
2259
2259
  });
2260
2260
  if (!edits.length) return node2;
2261
- const patch = { characters };
2262
- if (n.styledSegments) patch.styledSegments = shiftRanges(n.styledSegments, edits);
2263
- if (n.paragraphs) patch.paragraphs = shiftRanges(n.paragraphs, edits);
2264
- return { ...node2, ...patch };
2261
+ const patch2 = { characters };
2262
+ if (n.styledSegments) patch2.styledSegments = shiftRanges(n.styledSegments, edits);
2263
+ if (n.paragraphs) patch2.paragraphs = shiftRanges(n.paragraphs, edits);
2264
+ return { ...node2, ...patch2 };
2265
2265
  }
2266
2266
  var init_text_tokens = __esm({
2267
2267
  "lib/document/text-tokens.ts"() {
@@ -5577,9 +5577,9 @@ function instanceChildPatch(nodes, virtualId, props) {
5577
5577
  if (norm3(rest[k2]) === norm3(child[k2])) delete rest[k2];
5578
5578
  }
5579
5579
  if (Object.keys(rest).length) overrides2[v.childId] = { ...overrides2[v.childId] || {}, ...rest };
5580
- const patch = { overrides: overrides2 };
5581
- if (componentProperties !== host.componentProperties) patch.componentProperties = componentProperties;
5582
- return { hostId: v.hostId, patch };
5580
+ const patch2 = { overrides: overrides2 };
5581
+ if (componentProperties !== host.componentProperties) patch2.componentProperties = componentProperties;
5582
+ return { hostId: v.hostId, patch: patch2 };
5583
5583
  }
5584
5584
  var NO_DEFS, defaultsMemo, boundTracks, BOUND;
5585
5585
  var init_instances = __esm({
@@ -5652,7 +5652,7 @@ function materialise(nodes, hostId, root2) {
5652
5652
  }
5653
5653
  return ids2;
5654
5654
  };
5655
- const frame2 = {
5655
+ const frame3 = {
5656
5656
  ...root2,
5657
5657
  id: hostId,
5658
5658
  parentId: null,
@@ -5663,8 +5663,8 @@ function materialise(nodes, hostId, root2) {
5663
5663
  layoutSizingHorizontal: host.layoutSizingHorizontal ?? root2.layoutSizingHorizontal,
5664
5664
  layoutSizingVertical: root2.layoutSizingVertical
5665
5665
  };
5666
- out[hostId] = frame2;
5667
- frame2.childIds = walk4(hostId, host, root2.childIds ?? []);
5666
+ out[hostId] = frame3;
5667
+ frame3.childIds = walk4(hostId, host, root2.childIds ?? []);
5668
5668
  return out;
5669
5669
  }
5670
5670
  function layoutOf(nodes, hostId) {
@@ -6879,9 +6879,9 @@ function foldGuides(preset, width, height) {
6879
6879
  const span3 = preset.folds.axis === "X" ? width : height;
6880
6880
  return preset.folds.at.map((t3) => ({ id: v4_default(), axis: preset.folds.axis, pos: Math.round(t3 * span3), kind: "FOLD" }));
6881
6881
  }
6882
- function foldGuidesAt(preset, frame2) {
6882
+ function foldGuidesAt(preset, frame3) {
6883
6883
  if (!preset?.folds) return [];
6884
- return foldGuides(preset, frame2.width, frame2.height).map((g) => ({ ...g, pos: g.pos + (g.axis === "X" ? frame2.x : frame2.y) }));
6884
+ return foldGuides(preset, frame3.width, frame3.height).map((g) => ({ ...g, pos: g.pos + (g.axis === "X" ? frame3.x : frame3.y) }));
6885
6885
  }
6886
6886
  function createPrintPage(doc2, pageId2, opts = {}) {
6887
6887
  const existing = listPrintPages(doc2, pageId2);
@@ -6889,7 +6889,7 @@ function createPrintPage(doc2, pageId2, opts = {}) {
6889
6889
  const size6 = preset ? presetPx(preset) : { width: doc2.settings?.pageSize?.width ?? 816, height: doc2.settings?.pageSize?.height ?? 1056 };
6890
6890
  const index2 = existing.length;
6891
6891
  const last3 = existing[existing.length - 1];
6892
- const frame2 = createFrame({
6892
+ const frame3 = createFrame({
6893
6893
  name: opts.name ?? `Page ${index2 + 1}`,
6894
6894
  ...pagePositions([...existing, size6], basePageSize(doc2, existing.length ? existing : [size6]), doc2.settings?.facingPages)[index2],
6895
6895
  width: size6.width,
@@ -6898,15 +6898,15 @@ function createPrintPage(doc2, pageId2, opts = {}) {
6898
6898
  clipsContent: true,
6899
6899
  print: { isPrintPage: true, index: index2, ...last3?.print?.masterId ? { masterId: last3.print.masterId } : {} }
6900
6900
  });
6901
- frame2.parentId = pageId2;
6902
- return frame2;
6901
+ frame3.parentId = pageId2;
6902
+ return frame3;
6903
6903
  }
6904
6904
  function createMasterPage(doc2, pageId2, opts = {}) {
6905
6905
  const masters = listMasterPages(doc2, pageId2);
6906
6906
  const preset = presetById(doc2.settings?.pageSize?.presetId);
6907
6907
  const size6 = preset ? presetPx(preset) : { width: doc2.settings?.pageSize?.width ?? 816, height: doc2.settings?.pageSize?.height ?? 1056 };
6908
6908
  const index2 = masters.length;
6909
- const frame2 = createFrame({
6909
+ const frame3 = createFrame({
6910
6910
  name: opts.name ?? `${MASTER_NAMES[index2 % MASTER_NAMES.length]}-Master`,
6911
6911
  ...masterPosition(index2, size6),
6912
6912
  width: size6.width,
@@ -6915,8 +6915,8 @@ function createMasterPage(doc2, pageId2, opts = {}) {
6915
6915
  clipsContent: true,
6916
6916
  print: { isPrintPage: true, isMaster: true, index: index2 }
6917
6917
  });
6918
- frame2.parentId = pageId2;
6919
- return frame2;
6918
+ frame3.parentId = pageId2;
6919
+ return frame3;
6920
6920
  }
6921
6921
  function assignMaster(doc2, pageIds, masterId) {
6922
6922
  const patches = {};
@@ -6929,11 +6929,11 @@ function assignMaster(doc2, pageIds, masterId) {
6929
6929
  }
6930
6930
  return patches;
6931
6931
  }
6932
- function effectiveMasterId(doc2, frame2) {
6933
- const print2 = frame2.print;
6934
- if (!print2 || print2.isMaster || !frame2.parentId) return void 0;
6935
- const pages2 = listPrintPages(doc2, frame2.parentId);
6936
- const index2 = pages2.findIndex((p2) => p2.id === frame2.id);
6932
+ function effectiveMasterId(doc2, frame3) {
6933
+ const print2 = frame3.print;
6934
+ if (!print2 || print2.isMaster || !frame3.parentId) return void 0;
6935
+ const pages2 = listPrintPages(doc2, frame3.parentId);
6936
+ const index2 = pages2.findIndex((p2) => p2.id === frame3.id);
6937
6937
  if (index2 < 0) return print2.masterId;
6938
6938
  if (index2 === 0 && print2.masterIdFirst && isMasterPage(doc2.nodes[print2.masterIdFirst])) return print2.masterIdFirst;
6939
6939
  if (doc2.settings?.facingPages && index2 >= 0) {
@@ -7018,7 +7018,7 @@ var init_print_pages = __esm({
7018
7018
  x: index2 * (size6.width + gutter(size6.width)),
7019
7019
  y: -(size6.height + 2 * gutter(size6.width))
7020
7020
  });
7021
- foldsOn = (guides, frame2) => (guides ?? []).filter((g) => g.kind === "FOLD" && (g.axis === "X" ? g.pos >= frame2.x && g.pos <= frame2.x + frame2.width : g.pos >= frame2.y && g.pos <= frame2.y + frame2.height));
7021
+ foldsOn = (guides, frame3) => (guides ?? []).filter((g) => g.kind === "FOLD" && (g.axis === "X" ? g.pos >= frame3.x && g.pos <= frame3.x + frame3.width : g.pos >= frame3.y && g.pos <= frame3.y + frame3.height));
7022
7022
  MASTER_NAMES = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
7023
7023
  }
7024
7024
  });
@@ -7086,12 +7086,12 @@ function virtualRootOf(host, doc2) {
7086
7086
  if (!host) return void 0;
7087
7087
  if (host.type === "INSTANCE") return host.mainComponentId || void 0;
7088
7088
  if (host.type === "FRAME") {
7089
- const frame2 = host;
7089
+ const frame3 = host;
7090
7090
  if (doc2) {
7091
7091
  const { effectiveMasterId: effectiveMasterId2 } = (init_print_pages(), __toCommonJS(print_pages_exports));
7092
- return effectiveMasterId2(doc2, frame2);
7092
+ return effectiveMasterId2(doc2, frame3);
7093
7093
  }
7094
- return frame2.print?.masterId;
7094
+ return frame3.print?.masterId;
7095
7095
  }
7096
7096
  return void 0;
7097
7097
  }
@@ -7986,13 +7986,13 @@ function createResolver(nodes, scrollState, roots) {
7986
7986
  const cached3 = frames.get(containerId);
7987
7987
  if (cached3) return cached3;
7988
7988
  const c2 = placementOf(containerId);
7989
- let frame2 = ROOT;
7989
+ let frame3 = ROOT;
7990
7990
  if (c2 && c2.node.type !== "PAGE") {
7991
7991
  const scroll = scrollState?.[c2.node.id];
7992
- frame2 = scroll ? place(outerOf(c2.node), c2.node, scroll) : c2.p;
7992
+ frame3 = scroll ? place(outerOf(c2.node), c2.node, scroll) : c2.p;
7993
7993
  }
7994
- frames.set(containerId, frame2);
7995
- return frame2;
7994
+ frames.set(containerId, frame3);
7995
+ return frame3;
7996
7996
  }
7997
7997
  return {
7998
7998
  matrixOf: (id3) => placementOf(id3)?.p.m ?? IDENTITY,
@@ -8275,8 +8275,8 @@ function getWorldRenderBounds(document2, nodeId2) {
8275
8275
  if (clips2 || node2.type === "BOOLEAN") return;
8276
8276
  const scene2 = scene3dOf(node2);
8277
8277
  if (scene2) {
8278
- const frame2 = sceneFrame(scene2, node2.width, node2.height);
8279
- const toWorld = mul4(mul4(fromAffine(m), frame2.projection), frame2.view);
8278
+ const frame3 = sceneFrame(scene2, node2.width, node2.height);
8279
+ const toWorld = mul4(mul4(fromAffine(m), frame3.projection), frame3.view);
8280
8280
  for (const card of sceneLayers(document2.nodes, id3)) {
8281
8281
  const pad = bleedFor(card.node);
8282
8282
  for (const [x2, y] of projectRect(mul4(toWorld, card.model), -pad, -pad, card.node.width + pad, card.node.height + pad)) {
@@ -33419,6 +33419,19 @@ var init_en2 = __esm({
33419
33419
  "docsSearch.placeholder": "Search guides, reference and file formats\u2026",
33420
33420
  "docsSearch.title": "Search the docs",
33421
33421
  "docsSearch.unavailable": "Search isn\u2019t available right now. Reload the page to try again.",
33422
+ "documentLoader.close": "Close",
33423
+ "documentLoader.errorFailed": "Something went wrong while opening this file. Nothing was lost \u2014 try again.",
33424
+ "documentLoader.errorTimeout": "This is taking much longer than it should. Check your connection and try again.",
33425
+ "documentLoader.errorTitle": "Couldn\u2019t open",
33426
+ "documentLoader.opening": "Opening {name}",
33427
+ "documentLoader.openingLabel": "Opening",
33428
+ "documentLoader.progress": "Progress",
33429
+ "documentLoader.retry": "Retry",
33430
+ "documentLoader.stageDownload": "Downloading",
33431
+ "documentLoader.stageFirstFrame": "First frame",
33432
+ "documentLoader.stageMedia": "Fonts and media",
33433
+ "documentLoader.stagePrepare": "Preparing",
33434
+ "documentLoader.untitled": "Your file",
33422
33435
  "dopesheet.keyframe": "{n} keyframe{value} \xB7 {formatTime}",
33423
33436
  "dopesheet.keyInspector": "Key inspector",
33424
33437
  "dopesheet.keyMenu": "Key menu",
@@ -34547,7 +34560,6 @@ var init_en2 = __esm({
34547
34560
  "newFileDialog.manageTemplate": "Manage template",
34548
34561
  "newFileDialog.newFile": "New file",
34549
34562
  "newFileDialog.noTemplatesMatch": "No templates match.",
34550
- "newFileDialog.openingName": "Opening {name}\u2026",
34551
34563
  "newFileDialog.pageSizes": "Page sizes",
34552
34564
  "newFileDialog.public": "Public",
34553
34565
  "newFileDialog.publishToMarketplace": "Publish to marketplace",
@@ -39325,7 +39337,6 @@ var require_es = __commonJS({
39325
39337
  "newFileDialog.manageTemplate": "Administrar plantilla",
39326
39338
  "newFileDialog.newFile": "Nuevo archivo",
39327
39339
  "newFileDialog.noTemplatesMatch": "Ninguna plantilla coincide.",
39328
- "newFileDialog.openingName": "Abriendo {name}\u2026",
39329
39340
  "newFileDialog.pageSizes": "Tama\xF1os de p\xE1gina",
39330
39341
  "newFileDialog.public": "P\xFAblico",
39331
39342
  "newFileDialog.publishToMarketplace": "Publicar en el marketplace",
@@ -44103,7 +44114,6 @@ var require_fr = __commonJS({
44103
44114
  "newFileDialog.manageTemplate": "G\xE9rer le mod\xE8le",
44104
44115
  "newFileDialog.newFile": "Nouveau fichier",
44105
44116
  "newFileDialog.noTemplatesMatch": "Aucun mod\xE8le ne correspond.",
44106
- "newFileDialog.openingName": "Ouverture de {name}\u2026",
44107
44117
  "newFileDialog.pageSizes": "Tailles de page",
44108
44118
  "newFileDialog.public": "Public",
44109
44119
  "newFileDialog.publishToMarketplace": "Publier sur la place de march\xE9",
@@ -48881,7 +48891,6 @@ var require_de = __commonJS({
48881
48891
  "newFileDialog.manageTemplate": "Vorlage verwalten",
48882
48892
  "newFileDialog.newFile": "Neue Datei",
48883
48893
  "newFileDialog.noTemplatesMatch": "Keine Vorlagen gefunden.",
48884
- "newFileDialog.openingName": "{name} wird ge\xF6ffnet\u2026",
48885
48894
  "newFileDialog.pageSizes": "Seitengr\xF6\xDFen",
48886
48895
  "newFileDialog.public": "\xD6ffentlich",
48887
48896
  "newFileDialog.publishToMarketplace": "Auf dem Marktplatz ver\xF6ffentlichen",
@@ -53659,7 +53668,6 @@ var require_it = __commonJS({
53659
53668
  "newFileDialog.manageTemplate": "Gestisci modello",
53660
53669
  "newFileDialog.newFile": "Nuovo file",
53661
53670
  "newFileDialog.noTemplatesMatch": "Nessun modello corrispondente.",
53662
- "newFileDialog.openingName": "Apertura di {name}\u2026",
53663
53671
  "newFileDialog.pageSizes": "Dimensioni pagina",
53664
53672
  "newFileDialog.public": "Pubblico",
53665
53673
  "newFileDialog.publishToMarketplace": "Pubblica sul marketplace",
@@ -58437,7 +58445,6 @@ var require_pt_BR = __commonJS({
58437
58445
  "newFileDialog.manageTemplate": "Gerenciar modelo",
58438
58446
  "newFileDialog.newFile": "Novo arquivo",
58439
58447
  "newFileDialog.noTemplatesMatch": "Nenhum modelo corresponde.",
58440
- "newFileDialog.openingName": "Abrindo {name}\u2026",
58441
58448
  "newFileDialog.pageSizes": "Tamanhos de p\xE1gina",
58442
58449
  "newFileDialog.public": "P\xFAblico",
58443
58450
  "newFileDialog.publishToMarketplace": "Publicar no marketplace",
@@ -63215,7 +63222,6 @@ var require_ja = __commonJS({
63215
63222
  "newFileDialog.manageTemplate": "\u30C6\u30F3\u30D7\u30EC\u30FC\u30C8\u3092\u7BA1\u7406",
63216
63223
  "newFileDialog.newFile": "\u65B0\u898F\u30D5\u30A1\u30A4\u30EB",
63217
63224
  "newFileDialog.noTemplatesMatch": "\u4E00\u81F4\u3059\u308B\u30C6\u30F3\u30D7\u30EC\u30FC\u30C8\u306F\u3042\u308A\u307E\u305B\u3093\u3002",
63218
- "newFileDialog.openingName": "{name}\u3092\u958B\u3044\u3066\u3044\u307E\u3059\u2026",
63219
63225
  "newFileDialog.pageSizes": "\u30DA\u30FC\u30B8\u30B5\u30A4\u30BA",
63220
63226
  "newFileDialog.public": "\u516C\u958B",
63221
63227
  "newFileDialog.publishToMarketplace": "\u30DE\u30FC\u30B1\u30C3\u30C8\u30D7\u30EC\u30A4\u30B9\u306B\u516C\u958B",
@@ -67993,7 +67999,6 @@ var require_ko = __commonJS({
67993
67999
  "newFileDialog.manageTemplate": "\uD15C\uD50C\uB9BF \uAD00\uB9AC",
67994
68000
  "newFileDialog.newFile": "\uC0C8 \uD30C\uC77C",
67995
68001
  "newFileDialog.noTemplatesMatch": "\uC77C\uCE58\uD558\uB294 \uD15C\uD50C\uB9BF\uC774 \uC5C6\uC2B5\uB2C8\uB2E4.",
67996
- "newFileDialog.openingName": "{name} \uC5EC\uB294 \uC911\u2026",
67997
68002
  "newFileDialog.pageSizes": "\uD398\uC774\uC9C0 \uD06C\uAE30",
67998
68003
  "newFileDialog.public": "\uACF5\uAC1C",
67999
68004
  "newFileDialog.publishToMarketplace": "\uB9C8\uCF13\uD50C\uB808\uC774\uC2A4\uC5D0 \uAC8C\uC2DC",
@@ -72771,7 +72776,6 @@ var require_zh_CN = __commonJS({
72771
72776
  "newFileDialog.manageTemplate": "\u7BA1\u7406\u6A21\u677F",
72772
72777
  "newFileDialog.newFile": "\u65B0\u5EFA\u6587\u4EF6",
72773
72778
  "newFileDialog.noTemplatesMatch": "\u6CA1\u6709\u5339\u914D\u7684\u6A21\u677F\u3002",
72774
- "newFileDialog.openingName": "\u6B63\u5728\u6253\u5F00 {name}\u2026",
72775
72779
  "newFileDialog.pageSizes": "\u9875\u9762\u5C3A\u5BF8",
72776
72780
  "newFileDialog.public": "\u516C\u5F00",
72777
72781
  "newFileDialog.publishToMarketplace": "\u53D1\u5E03\u5230\u5E02\u573A",
@@ -77549,7 +77553,6 @@ var require_zh_TW = __commonJS({
77549
77553
  "newFileDialog.manageTemplate": "\u7BA1\u7406\u7BC4\u672C",
77550
77554
  "newFileDialog.newFile": "\u65B0\u589E\u6A94\u6848",
77551
77555
  "newFileDialog.noTemplatesMatch": "\u7121\u7B26\u5408\u7684\u7BC4\u672C\u3002",
77552
- "newFileDialog.openingName": "\u6B63\u5728\u958B\u555F{name}\u2026",
77553
77556
  "newFileDialog.pageSizes": "\u9801\u9762\u5C3A\u5BF8",
77554
77557
  "newFileDialog.public": "\u516C\u958B",
77555
77558
  "newFileDialog.publishToMarketplace": "\u767C\u4F48\u81F3\u5E02\u96C6",
@@ -82327,7 +82330,6 @@ var require_ru = __commonJS({
82327
82330
  "newFileDialog.manageTemplate": "\u0423\u043F\u0440\u0430\u0432\u043B\u0435\u043D\u0438\u0435 \u0448\u0430\u0431\u043B\u043E\u043D\u043E\u043C",
82328
82331
  "newFileDialog.newFile": "\u041D\u043E\u0432\u044B\u0439 \u0444\u0430\u0439\u043B",
82329
82332
  "newFileDialog.noTemplatesMatch": "\u0428\u0430\u0431\u043B\u043E\u043D\u044B \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D\u044B.",
82330
- "newFileDialog.openingName": "\u041E\u0442\u043A\u0440\u044B\u0442\u0438\u0435 {name}\u2026",
82331
82333
  "newFileDialog.pageSizes": "\u0420\u0430\u0437\u043C\u0435\u0440\u044B \u0441\u0442\u0440\u0430\u043D\u0438\u0446",
82332
82334
  "newFileDialog.public": "\u041F\u0443\u0431\u043B\u0438\u0447\u043D\u044B\u0439",
82333
82335
  "newFileDialog.publishToMarketplace": "\u041E\u043F\u0443\u0431\u043B\u0438\u043A\u043E\u0432\u0430\u0442\u044C \u043D\u0430 \u0442\u043E\u0440\u0433\u043E\u0432\u043E\u0439 \u043F\u043B\u043E\u0449\u0430\u0434\u043A\u0435",
@@ -87105,7 +87107,6 @@ var require_ar = __commonJS({
87105
87107
  "newFileDialog.manageTemplate": "\u0625\u062F\u0627\u0631\u0629 \u0627\u0644\u0642\u0627\u0644\u0628",
87106
87108
  "newFileDialog.newFile": "\u0645\u0644\u0641 \u062C\u062F\u064A\u062F",
87107
87109
  "newFileDialog.noTemplatesMatch": "\u0644\u0627 \u062A\u0648\u062C\u062F \u0642\u0648\u0627\u0644\u0628 \u0645\u0637\u0627\u0628\u0642\u0629.",
87108
- "newFileDialog.openingName": "\u062C\u0627\u0631\u064D \u0641\u062A\u062D {name}\u2026",
87109
87110
  "newFileDialog.pageSizes": "\u0623\u062D\u062C\u0627\u0645 \u0627\u0644\u0635\u0641\u062D\u0627\u062A",
87110
87111
  "newFileDialog.public": "\u0639\u0627\u0645",
87111
87112
  "newFileDialog.publishToMarketplace": "\u0627\u0644\u0646\u0634\u0631 \u0625\u0644\u0649 \u0627\u0644\u0645\u062A\u062C\u0631",
@@ -91883,7 +91884,6 @@ var require_hi = __commonJS({
91883
91884
  "newFileDialog.manageTemplate": "\u091F\u0947\u092E\u094D\u092A\u0932\u0947\u091F \u092A\u094D\u0930\u092C\u0902\u0927\u093F\u0924 \u0915\u0930\u0947\u0902",
91884
91885
  "newFileDialog.newFile": "\u0928\u0908 \u092B\u093C\u093E\u0907\u0932",
91885
91886
  "newFileDialog.noTemplatesMatch": "\u0915\u094B\u0908 \u091F\u0947\u092E\u094D\u092A\u0932\u0947\u091F \u092E\u0947\u0932 \u0928\u0939\u0940\u0902 \u0916\u093E\u0924\u093E\u0964",
91886
- "newFileDialog.openingName": "{name} \u0916\u094B\u0932\u093E \u091C\u093E \u0930\u0939\u093E \u0939\u0948\u2026",
91887
91887
  "newFileDialog.pageSizes": "\u092A\u0943\u0937\u094D\u0920 \u0906\u0915\u093E\u0930",
91888
91888
  "newFileDialog.public": "\u0938\u093E\u0930\u094D\u0935\u091C\u0928\u093F\u0915",
91889
91889
  "newFileDialog.publishToMarketplace": "\u092E\u093E\u0930\u094D\u0915\u0947\u091F\u092A\u094D\u0932\u0947\u0938 \u092A\u0930 \u092A\u094D\u0930\u0915\u093E\u0936\u093F\u0924 \u0915\u0930\u0947\u0902",
@@ -94485,6 +94485,7 @@ function hasMessage(key5) {
94485
94485
  var current2, loading, listeners, formats, asts;
94486
94486
  var init_runtime = __esm({
94487
94487
  "lib/i18n/runtime.ts"() {
94488
+ "use strict";
94488
94489
  init_intl_messageformat();
94489
94490
  init_icu_messageformat_parser();
94490
94491
  init_catalogs();
@@ -97294,10 +97295,10 @@ function detachInstances(nodes, ids2) {
97294
97295
  into[newId3] = node2;
97295
97296
  return newId3;
97296
97297
  };
97297
- const frame2 = { ...inst, type: "FRAME" };
97298
- for (const k2 of INSTANCE_ONLY) delete frame2[k2];
97299
- frame2.childIds = (nodes[inst.mainComponentId].childIds ?? []).map((c2) => copy2(`${id3}::${c2}`, id3)).filter((c2) => !!c2);
97300
- into[id3] = frame2;
97298
+ const frame3 = { ...inst, type: "FRAME" };
97299
+ for (const k2 of INSTANCE_ONLY) delete frame3[k2];
97300
+ frame3.childIds = (nodes[inst.mainComponentId].childIds ?? []).map((c2) => copy2(`${id3}::${c2}`, id3)).filter((c2) => !!c2);
97301
+ into[id3] = frame3;
97301
97302
  }
97302
97303
  return out ?? nodes;
97303
97304
  }
@@ -97397,22 +97398,22 @@ function diffDocuments(before, after) {
97397
97398
  }
97398
97399
  return { nodes, fields };
97399
97400
  }
97400
- function isEmptyPatch(patch) {
97401
- return patch.nodes.size === 0 && patch.fields.size === 0;
97401
+ function isEmptyPatch(patch2) {
97402
+ return patch2.nodes.size === 0 && patch2.fields.size === 0;
97402
97403
  }
97403
- function applyPatch(doc2, patch, side) {
97404
- if (isEmptyPatch(patch)) return doc2;
97404
+ function applyPatch(doc2, patch2, side) {
97405
+ if (isEmptyPatch(patch2)) return doc2;
97405
97406
  let nodes = doc2.nodes;
97406
- if (patch.nodes.size > 0) {
97407
+ if (patch2.nodes.size > 0) {
97407
97408
  nodes = { ...doc2.nodes };
97408
- for (const [id3, change2] of patch.nodes) {
97409
+ for (const [id3, change2] of patch2.nodes) {
97409
97410
  const value3 = change2[side];
97410
97411
  if (value3 === void 0) delete nodes[id3];
97411
97412
  else nodes[id3] = value3;
97412
97413
  }
97413
97414
  }
97414
97415
  const out = { ...doc2, nodes };
97415
- for (const [k2, change2] of patch.fields) {
97416
+ for (const [k2, change2] of patch2.fields) {
97416
97417
  const value3 = change2[side];
97417
97418
  if (value3 === void 0) delete out[k2];
97418
97419
  else out[k2] = value3;
@@ -97850,36 +97851,36 @@ function applyAutoLayout(doc2) {
97850
97851
  const clampedWidth = (w, c2) => Math.max(c2.minWidth ?? 1, Math.min(c2.maxWidth ?? Infinity, w));
97851
97852
  const clampedHeight = (h, c2) => Math.max(c2.minHeight ?? 1, Math.min(c2.maxHeight ?? Infinity, h));
97852
97853
  if (isAutoLayout(node2)) {
97853
- const frame2 = cloneNode(nodeId2);
97854
+ const frame3 = cloneNode(nodeId2);
97854
97855
  let totalChildrenPrimary = 0;
97855
97856
  let maxChildrenCounter = 0;
97856
- const isHorizontal = frame2.layoutMode === "HORIZONTAL";
97857
- const isGrid2 = frame2.layoutMode === "GRID";
97858
- const paddingX = frame2.padding.left + frame2.padding.right;
97859
- const paddingY = frame2.padding.top + frame2.padding.bottom;
97860
- const itemSpacing = frame2.itemSpacing;
97861
- const counterSpacing = frame2.counterAxisSpacing ?? itemSpacing;
97857
+ const isHorizontal = frame3.layoutMode === "HORIZONTAL";
97858
+ const isGrid2 = frame3.layoutMode === "GRID";
97859
+ const paddingX = frame3.padding.left + frame3.padding.right;
97860
+ const paddingY = frame3.padding.top + frame3.padding.bottom;
97861
+ const itemSpacing = frame3.itemSpacing;
97862
+ const counterSpacing = frame3.counterAxisSpacing ?? itemSpacing;
97862
97863
  let fillChildrenCount = 0;
97863
- const childIds = frame2.childIds.filter((id3) => {
97864
+ const childIds = frame3.childIds.filter((id3) => {
97864
97865
  const child = newNodes[id3];
97865
97866
  return child && child.visible && child.layoutPositioning !== "ABSOLUTE";
97866
97867
  });
97867
- for (const id3 of frame2.childIds) {
97868
+ for (const id3 of frame3.childIds) {
97868
97869
  const child = newNodes[id3];
97869
97870
  if (child && child.visible && child.layoutPositioning === "ABSOLUTE") measureNode(id3);
97870
97871
  }
97871
97872
  let intrinsicW = 0;
97872
97873
  let intrinsicH = 0;
97873
97874
  if (isGrid2) {
97874
- const cols = frame2.layoutGridColumns ?? "AUTO";
97875
- const rows = frame2.layoutGridRows ?? "AUTO";
97876
- const minColW = frame2.layoutGridMinColumnWidth ?? 100;
97877
- const minRowH = frame2.layoutGridMinRowHeight ?? 100;
97875
+ const cols = frame3.layoutGridColumns ?? "AUTO";
97876
+ const rows = frame3.layoutGridRows ?? "AUTO";
97877
+ const minColW = frame3.layoutGridMinColumnWidth ?? 100;
97878
+ const minRowH = frame3.layoutGridMinRowHeight ?? 100;
97878
97879
  let actualCols = 1;
97879
- let colSizes = frame2.layoutGridColumnSizes || [];
97880
+ let colSizes = frame3.layoutGridColumnSizes || [];
97880
97881
  if (cols === "AUTO") {
97881
- if (frame2.layoutSizingHorizontal === "FIXED" || frame2.layoutSizingHorizontal === "FILL") {
97882
- const availW = frame2.width - paddingX;
97882
+ if (frame3.layoutSizingHorizontal === "FIXED" || frame3.layoutSizingHorizontal === "FILL") {
97883
+ const availW = frame3.width - paddingX;
97883
97884
  actualCols = Math.max(1, Math.floor((availW + itemSpacing) / (minColW + itemSpacing)));
97884
97885
  } else {
97885
97886
  actualCols = Math.max(1, childIds.length);
@@ -97892,7 +97893,7 @@ function applyAutoLayout(doc2) {
97892
97893
  }
97893
97894
  }
97894
97895
  let actualRows = 1;
97895
- let rowSizes = frame2.layoutGridRowSizes || [];
97896
+ let rowSizes = frame3.layoutGridRowSizes || [];
97896
97897
  if (rows === "AUTO") {
97897
97898
  actualRows = Math.max(1, Math.ceil(childIds.length / actualCols));
97898
97899
  rowSizes = Array.from({ length: actualRows }).map(() => ({ sizing: "HUG", value: "113", min: minRowH }));
@@ -97952,18 +97953,18 @@ function applyAutoLayout(doc2) {
97952
97953
  const totalSpacing = Math.max(0, childIds.length - 1) * itemSpacing;
97953
97954
  intrinsicW = isHorizontal ? totalChildrenPrimary + totalSpacing + paddingX : maxChildrenCounter + paddingX;
97954
97955
  intrinsicH = isHorizontal ? maxChildrenCounter + paddingY : totalChildrenPrimary + totalSpacing + paddingY;
97955
- if (wraps(frame2)) {
97956
- const lines2 = wrapLines(frame2, childIds, (id3) => measureNode(id3));
97956
+ if (wraps(frame3)) {
97957
+ const lines2 = wrapLines(frame3, childIds, (id3) => measureNode(id3));
97957
97958
  const counter = lines2.reduce((a, l) => a + l.counter, 0) + Math.max(0, lines2.length - 1) * counterSpacing;
97958
97959
  if (isHorizontal) intrinsicH = counter + paddingY;
97959
97960
  else intrinsicW = counter + paddingX;
97960
97961
  }
97961
97962
  }
97962
- if (frame2.layoutSizingHorizontal === "HUG") frame2.width = clampedWidth(intrinsicW, frame2);
97963
- if (frame2.layoutSizingVertical === "HUG") frame2.height = clampedHeight(intrinsicH, frame2);
97963
+ if (frame3.layoutSizingHorizontal === "HUG") frame3.width = clampedWidth(intrinsicW, frame3);
97964
+ if (frame3.layoutSizingVertical === "HUG") frame3.height = clampedHeight(intrinsicH, frame3);
97964
97965
  return {
97965
- intrinsicWidth: clampedWidth(frame2.layoutSizingHorizontal === "HUG" ? intrinsicW : frame2.width, frame2),
97966
- intrinsicHeight: clampedHeight(frame2.layoutSizingVertical === "HUG" ? intrinsicH : frame2.height, frame2)
97966
+ intrinsicWidth: clampedWidth(frame3.layoutSizingHorizontal === "HUG" ? intrinsicW : frame3.width, frame3),
97967
+ intrinsicHeight: clampedHeight(frame3.layoutSizingVertical === "HUG" ? intrinsicH : frame3.height, frame3)
97967
97968
  };
97968
97969
  } else {
97969
97970
  let height = node2.height;
@@ -97989,18 +97990,18 @@ function applyAutoLayout(doc2) {
97989
97990
  function layoutNode(nodeId2) {
97990
97991
  const node2 = newNodes[nodeId2];
97991
97992
  if (!isAutoLayout(node2)) return;
97992
- const frame2 = node2;
97993
- const isHorizontal = frame2.layoutMode === "HORIZONTAL";
97994
- const isGrid2 = frame2.layoutMode === "GRID";
97995
- const paddingX = frame2.padding.left + frame2.padding.right;
97996
- const paddingY = frame2.padding.top + frame2.padding.bottom;
97997
- const itemSpacing = frame2.itemSpacing;
97998
- const counterSpacing = frame2.counterAxisSpacing ?? itemSpacing;
97999
- const childIds = frame2.childIds.filter((id3) => {
97993
+ const frame3 = node2;
97994
+ const isHorizontal = frame3.layoutMode === "HORIZONTAL";
97995
+ const isGrid2 = frame3.layoutMode === "GRID";
97996
+ const paddingX = frame3.padding.left + frame3.padding.right;
97997
+ const paddingY = frame3.padding.top + frame3.padding.bottom;
97998
+ const itemSpacing = frame3.itemSpacing;
97999
+ const counterSpacing = frame3.counterAxisSpacing ?? itemSpacing;
98000
+ const childIds = frame3.childIds.filter((id3) => {
98000
98001
  const child = newNodes[id3];
98001
98002
  return child && child.visible && child.layoutPositioning !== "ABSOLUTE";
98002
98003
  });
98003
- const absoluteChildIds = frame2.childIds.filter((id3) => {
98004
+ const absoluteChildIds = frame3.childIds.filter((id3) => {
98004
98005
  const child = newNodes[id3];
98005
98006
  return child && child.visible && child.layoutPositioning === "ABSOLUTE";
98006
98007
  });
@@ -98012,14 +98013,14 @@ function applyAutoLayout(doc2) {
98012
98013
  const clampedWidth = (w, c2) => Math.max(c2.minWidth ?? 1, Math.min(c2.maxWidth ?? Infinity, w));
98013
98014
  const clampedHeight = (h, c2) => Math.max(c2.minHeight ?? 1, Math.min(c2.maxHeight ?? Infinity, h));
98014
98015
  if (isGrid2) {
98015
- const cols = frame2.layoutGridColumns ?? "AUTO";
98016
- const rows = frame2.layoutGridRows ?? "AUTO";
98017
- const minColW = frame2.layoutGridMinColumnWidth ?? 100;
98018
- const minRowH = frame2.layoutGridMinRowHeight ?? 100;
98016
+ const cols = frame3.layoutGridColumns ?? "AUTO";
98017
+ const rows = frame3.layoutGridRows ?? "AUTO";
98018
+ const minColW = frame3.layoutGridMinColumnWidth ?? 100;
98019
+ const minRowH = frame3.layoutGridMinRowHeight ?? 100;
98019
98020
  let actualCols = 1;
98020
- let colSizes = frame2.layoutGridColumnSizes || [];
98021
+ let colSizes = frame3.layoutGridColumnSizes || [];
98021
98022
  if (cols === "AUTO") {
98022
- const availW = frame2.width - paddingX;
98023
+ const availW = frame3.width - paddingX;
98023
98024
  actualCols = Math.max(1, Math.floor((availW + itemSpacing) / (minColW + itemSpacing)));
98024
98025
  colSizes = Array.from({ length: actualCols }).map(() => ({ sizing: "FILL", value: "1fr" }));
98025
98026
  } else {
@@ -98029,7 +98030,7 @@ function applyAutoLayout(doc2) {
98029
98030
  }
98030
98031
  }
98031
98032
  let actualRows = 1;
98032
- let rowSizes = frame2.layoutGridRowSizes || [];
98033
+ let rowSizes = frame3.layoutGridRowSizes || [];
98033
98034
  if (rows === "AUTO") {
98034
98035
  actualRows = Math.max(1, Math.ceil(childIds.length / actualCols));
98035
98036
  rowSizes = Array.from({ length: actualRows }).map(() => ({ sizing: "HUG", value: "113", min: minRowH }));
@@ -98057,7 +98058,7 @@ function applyAutoLayout(doc2) {
98057
98058
  else if (s.sizing === "HUG") fixedColW += colMaxHugs[c2];
98058
98059
  else if (s.sizing === "FILL") totalColFr += parseFloat(s.value) || 1;
98059
98060
  });
98060
- const availColW = Math.max(0, frame2.width - paddingX - Math.max(0, actualCols - 1) * itemSpacing - fixedColW);
98061
+ const availColW = Math.max(0, frame3.width - paddingX - Math.max(0, actualCols - 1) * itemSpacing - fixedColW);
98061
98062
  const colW = new Array(actualCols).fill(0);
98062
98063
  colSizes.forEach((s, c2) => {
98063
98064
  if (s.sizing === "FIXED") colW[c2] = parseFloat(s.value) || 0;
@@ -98071,7 +98072,7 @@ function applyAutoLayout(doc2) {
98071
98072
  else if (s.sizing === "HUG") fixedRowH += Math.max(s.min ?? 0, rowMaxHugs[r]);
98072
98073
  else if (s.sizing === "FILL") totalRowFr += parseFloat(s.value) || 1;
98073
98074
  });
98074
- const availRowH = Math.max(0, frame2.height - paddingY - Math.max(0, actualRows - 1) * counterSpacing - fixedRowH);
98075
+ const availRowH = Math.max(0, frame3.height - paddingY - Math.max(0, actualRows - 1) * counterSpacing - fixedRowH);
98075
98076
  const rowH = new Array(actualRows).fill(0);
98076
98077
  rowSizes.forEach((s, r) => {
98077
98078
  if (s.sizing === "FIXED") rowH[r] = parseFloat(s.value) || 0;
@@ -98079,13 +98080,13 @@ function applyAutoLayout(doc2) {
98079
98080
  else if (s.sizing === "FILL") rowH[r] = totalRowFr > 0 ? availRowH * ((parseFloat(s.value) || 1) / totalRowFr) : 0;
98080
98081
  });
98081
98082
  const colX = new Array(actualCols).fill(0);
98082
- let currX = frame2.padding.left;
98083
+ let currX = frame3.padding.left;
98083
98084
  for (let c2 = 0; c2 < actualCols; c2++) {
98084
98085
  colX[c2] = currX;
98085
98086
  currX += colW[c2] + itemSpacing;
98086
98087
  }
98087
98088
  const rowY = new Array(actualRows).fill(0);
98088
- let currY = frame2.padding.top;
98089
+ let currY = frame3.padding.top;
98089
98090
  for (let r = 0; r < actualRows; r++) {
98090
98091
  rowY[r] = currY;
98091
98092
  currY += rowH[r] + counterSpacing;
@@ -98100,10 +98101,10 @@ function applyAutoLayout(doc2) {
98100
98101
  const cellY = rowY[r];
98101
98102
  child.x = cellX;
98102
98103
  child.y = cellY;
98103
- if (frame2.counterAxisAlignItems === "CENTER") {
98104
+ if (frame3.counterAxisAlignItems === "CENTER") {
98104
98105
  child.x = cellX + (colW[c2] - child.width) / 2;
98105
98106
  child.y = cellY + (rowH[r] - child.height) / 2;
98106
- } else if (frame2.counterAxisAlignItems === "MAX") {
98107
+ } else if (frame3.counterAxisAlignItems === "MAX") {
98107
98108
  child.x = cellX + (colW[c2] - child.width);
98108
98109
  child.y = cellY + (rowH[r] - child.height);
98109
98110
  }
@@ -98123,34 +98124,34 @@ function applyAutoLayout(doc2) {
98123
98124
  }
98124
98125
  });
98125
98126
  const totalSpacing = Math.max(0, childIds.length - 1) * itemSpacing;
98126
- const availablePrimary = (isHorizontal ? frame2.width - paddingX : frame2.height - paddingY) - totalSpacing - usedPrimarySpace;
98127
+ const availablePrimary = (isHorizontal ? frame3.width - paddingX : frame3.height - paddingY) - totalSpacing - usedPrimarySpace;
98127
98128
  const fillPrimarySize = fillPrimaryCount > 0 ? Math.max(0, availablePrimary / fillPrimaryCount) : 0;
98128
98129
  childIds.forEach((childId) => {
98129
98130
  const child = cloneNode(childId);
98130
98131
  if (isHorizontal) {
98131
98132
  if (child.layoutSizingHorizontal === "FILL") child.width = clampedWidth(fillPrimarySize, child);
98132
- if (child.layoutSizingVertical === "FILL") child.height = clampedHeight(Math.max(0, frame2.height - paddingY), child);
98133
+ if (child.layoutSizingVertical === "FILL") child.height = clampedHeight(Math.max(0, frame3.height - paddingY), child);
98133
98134
  } else {
98134
98135
  if (child.layoutSizingVertical === "FILL") child.height = clampedHeight(fillPrimarySize, child);
98135
- if (child.layoutSizingHorizontal === "FILL") child.width = clampedWidth(Math.max(0, frame2.width - paddingX), child);
98136
+ if (child.layoutSizingHorizontal === "FILL") child.width = clampedWidth(Math.max(0, frame3.width - paddingX), child);
98136
98137
  }
98137
98138
  });
98138
- if (wraps(frame2)) {
98139
- const lines2 = wrapLines(frame2, childIds, (id3) => ({ intrinsicWidth: newNodes[id3].width, intrinsicHeight: newNodes[id3].height }));
98140
- let counterPos = isHorizontal ? frame2.padding.top : frame2.padding.left;
98141
- const availPrimaryTotal = isHorizontal ? frame2.width - paddingX : frame2.height - paddingY;
98139
+ if (wraps(frame3)) {
98140
+ const lines2 = wrapLines(frame3, childIds, (id3) => ({ intrinsicWidth: newNodes[id3].width, intrinsicHeight: newNodes[id3].height }));
98141
+ let counterPos = isHorizontal ? frame3.padding.top : frame3.padding.left;
98142
+ const availPrimaryTotal = isHorizontal ? frame3.width - paddingX : frame3.height - paddingY;
98142
98143
  for (const line of lines2) {
98143
98144
  const used = line.ids.reduce((a, id3) => a + (isHorizontal ? newNodes[id3].width : newNodes[id3].height), 0) + Math.max(0, line.ids.length - 1) * itemSpacing;
98144
- let primary = isHorizontal ? frame2.padding.left : frame2.padding.top;
98145
+ let primary = isHorizontal ? frame3.padding.left : frame3.padding.top;
98145
98146
  let extra = 0;
98146
98147
  const free2 = Math.max(0, availPrimaryTotal - used);
98147
- if (frame2.primaryAxisAlignItems === "SPACE_BETWEEN" && line.ids.length > 1) extra = free2 / (line.ids.length - 1);
98148
- else if (frame2.primaryAxisAlignItems === "CENTER") primary += free2 / 2;
98149
- else if (frame2.primaryAxisAlignItems === "MAX") primary += free2;
98148
+ if (frame3.primaryAxisAlignItems === "SPACE_BETWEEN" && line.ids.length > 1) extra = free2 / (line.ids.length - 1);
98149
+ else if (frame3.primaryAxisAlignItems === "CENTER") primary += free2 / 2;
98150
+ else if (frame3.primaryAxisAlignItems === "MAX") primary += free2;
98150
98151
  for (const id3 of line.ids) {
98151
98152
  const child = newNodes[id3];
98152
98153
  const size6 = isHorizontal ? child.height : child.width;
98153
- const off = frame2.counterAxisAlignItems === "CENTER" ? (line.counter - size6) / 2 : frame2.counterAxisAlignItems === "MAX" ? line.counter - size6 : 0;
98154
+ const off = frame3.counterAxisAlignItems === "CENTER" ? (line.counter - size6) / 2 : frame3.counterAxisAlignItems === "MAX" ? line.counter - size6 : 0;
98154
98155
  if (isHorizontal) {
98155
98156
  child.x = primary;
98156
98157
  child.y = counterPos + off;
@@ -98166,13 +98167,13 @@ function applyAutoLayout(doc2) {
98166
98167
  }
98167
98168
  return;
98168
98169
  }
98169
- let currentPrimary = isHorizontal ? frame2.padding.left : frame2.padding.top;
98170
+ let currentPrimary = isHorizontal ? frame3.padding.left : frame3.padding.top;
98170
98171
  let extraSpacing = 0;
98171
- if (frame2.primaryAxisAlignItems === "SPACE_BETWEEN" && fillPrimaryCount === 0 && childIds.length > 1) {
98172
+ if (frame3.primaryAxisAlignItems === "SPACE_BETWEEN" && fillPrimaryCount === 0 && childIds.length > 1) {
98172
98173
  extraSpacing = availablePrimary / (childIds.length - 1);
98173
- } else if (frame2.primaryAxisAlignItems === "CENTER" && fillPrimaryCount === 0) {
98174
+ } else if (frame3.primaryAxisAlignItems === "CENTER" && fillPrimaryCount === 0) {
98174
98175
  currentPrimary += availablePrimary / 2;
98175
- } else if (frame2.primaryAxisAlignItems === "MAX" && fillPrimaryCount === 0) {
98176
+ } else if (frame3.primaryAxisAlignItems === "MAX" && fillPrimaryCount === 0) {
98176
98177
  currentPrimary += availablePrimary;
98177
98178
  }
98178
98179
  childIds.forEach((childId) => {
@@ -98180,22 +98181,22 @@ function applyAutoLayout(doc2) {
98180
98181
  if (isHorizontal) {
98181
98182
  child.x = currentPrimary;
98182
98183
  currentPrimary += child.width + itemSpacing + extraSpacing;
98183
- if (frame2.counterAxisAlignItems === "CENTER") {
98184
- child.y = frame2.padding.top + (frame2.height - paddingY - child.height) / 2;
98185
- } else if (frame2.counterAxisAlignItems === "MAX") {
98186
- child.y = frame2.height - frame2.padding.bottom - child.height;
98184
+ if (frame3.counterAxisAlignItems === "CENTER") {
98185
+ child.y = frame3.padding.top + (frame3.height - paddingY - child.height) / 2;
98186
+ } else if (frame3.counterAxisAlignItems === "MAX") {
98187
+ child.y = frame3.height - frame3.padding.bottom - child.height;
98187
98188
  } else {
98188
- child.y = frame2.padding.top;
98189
+ child.y = frame3.padding.top;
98189
98190
  }
98190
98191
  } else {
98191
98192
  child.y = currentPrimary;
98192
98193
  currentPrimary += child.height + itemSpacing + extraSpacing;
98193
- if (frame2.counterAxisAlignItems === "CENTER") {
98194
- child.x = frame2.padding.left + (frame2.width - paddingX - child.width) / 2;
98195
- } else if (frame2.counterAxisAlignItems === "MAX") {
98196
- child.x = frame2.width - frame2.padding.right - child.width;
98194
+ if (frame3.counterAxisAlignItems === "CENTER") {
98195
+ child.x = frame3.padding.left + (frame3.width - paddingX - child.width) / 2;
98196
+ } else if (frame3.counterAxisAlignItems === "MAX") {
98197
+ child.x = frame3.width - frame3.padding.right - child.width;
98197
98198
  } else {
98198
- child.x = frame2.padding.left;
98199
+ child.x = frame3.padding.left;
98199
98200
  }
98200
98201
  }
98201
98202
  layoutNode(childId);
@@ -98215,27 +98216,27 @@ function applyAutoLayout(doc2) {
98215
98216
  }
98216
98217
  return { ...doc2, nodes: newNodes };
98217
98218
  }
98218
- function wraps(frame2) {
98219
- if (frame2.layoutWrap !== "WRAP" || frame2.layoutMode === "GRID") return false;
98220
- return frame2.layoutMode === "HORIZONTAL" ? frame2.layoutSizingHorizontal !== "HUG" : frame2.layoutSizingVertical !== "HUG";
98219
+ function wraps(frame3) {
98220
+ if (frame3.layoutWrap !== "WRAP" || frame3.layoutMode === "GRID") return false;
98221
+ return frame3.layoutMode === "HORIZONTAL" ? frame3.layoutSizingHorizontal !== "HUG" : frame3.layoutSizingVertical !== "HUG";
98221
98222
  }
98222
- function wrapLines(frame2, childIds, size6) {
98223
- const isHorizontal = frame2.layoutMode === "HORIZONTAL";
98224
- const avail = isHorizontal ? frame2.width - frame2.padding.left - frame2.padding.right : frame2.height - frame2.padding.top - frame2.padding.bottom;
98223
+ function wrapLines(frame3, childIds, size6) {
98224
+ const isHorizontal = frame3.layoutMode === "HORIZONTAL";
98225
+ const avail = isHorizontal ? frame3.width - frame3.padding.left - frame3.padding.right : frame3.height - frame3.padding.top - frame3.padding.bottom;
98225
98226
  const lines2 = [];
98226
98227
  let cur = { ids: [], counter: 0 }, used = 0;
98227
98228
  for (const id3 of childIds) {
98228
98229
  const sz = size6(id3);
98229
98230
  const primary = isHorizontal ? sz.intrinsicWidth : sz.intrinsicHeight;
98230
98231
  const counter = isHorizontal ? sz.intrinsicHeight : sz.intrinsicWidth;
98231
- const needed = cur.ids.length ? used + frame2.itemSpacing + primary : primary;
98232
+ const needed = cur.ids.length ? used + frame3.itemSpacing + primary : primary;
98232
98233
  if (cur.ids.length && needed > avail + 1e-3) {
98233
98234
  lines2.push(cur);
98234
98235
  cur = { ids: [], counter: 0 };
98235
98236
  used = 0;
98236
98237
  }
98237
98238
  cur.ids.push(id3);
98238
- used = cur.ids.length === 1 ? primary : used + frame2.itemSpacing + primary;
98239
+ used = cur.ids.length === 1 ? primary : used + frame3.itemSpacing + primary;
98239
98240
  cur.counter = Math.max(cur.counter, counter);
98240
98241
  }
98241
98242
  if (cur.ids.length) lines2.push(cur);
@@ -98777,10 +98778,10 @@ function scaleTree(nodes, id3, s, isRoot) {
98777
98778
  if (!n) return;
98778
98779
  if (!isRoot) {
98779
98780
  const t3 = n;
98780
- const patch = { x: n.x * s, y: n.y * s, width: n.width * s, height: n.height * s };
98781
- if (typeof t3.fontSize === "number") patch.fontSize = Math.max(12, t3.fontSize * s);
98782
- if (typeof t3.cornerRadius === "number") patch.cornerRadius = t3.cornerRadius * s;
98783
- nodes[id3] = { ...n, ...patch };
98781
+ const patch2 = { x: n.x * s, y: n.y * s, width: n.width * s, height: n.height * s };
98782
+ if (typeof t3.fontSize === "number") patch2.fontSize = Math.max(12, t3.fontSize * s);
98783
+ if (typeof t3.cornerRadius === "number") patch2.cornerRadius = t3.cornerRadius * s;
98784
+ nodes[id3] = { ...n, ...patch2 };
98784
98785
  }
98785
98786
  for (const c2 of n.childIds) scaleTree(nodes, c2, s, false);
98786
98787
  }
@@ -100039,11 +100040,11 @@ function addAudioClip(comp, o) {
100039
100040
  const clip = { id: id3, mediaHash: o.mediaHash, name: o.name, start: Math.max(0, Math.round(o.start ?? 0)), in: 0, out: Math.max(1, Math.round(o.duration)), lane: o.lane ?? 0 };
100040
100041
  return { composition: withAudio(comp, placeAudio(audio, clip)), id: id3 };
100041
100042
  }
100042
- function editAudioClip(comp, id3, patch) {
100043
+ function editAudioClip(comp, id3, patch2) {
100043
100044
  const audio = comp.audio ?? [];
100044
100045
  const cur = audio.find((c2) => c2.id === id3);
100045
100046
  if (!cur) return comp;
100046
- const next2 = { ...cur, ...patch };
100047
+ const next2 = { ...cur, ...patch2 };
100047
100048
  next2.start = Math.max(0, Math.round(next2.start));
100048
100049
  next2.in = Math.max(0, Math.round(next2.in));
100049
100050
  next2.out = Math.max(next2.in + 1, Math.round(next2.out));
@@ -100486,7 +100487,7 @@ function sampleNode(node2, t3, nodes, inputs) {
100486
100487
  const outer = linkNodes;
100487
100488
  if (nodes) linkNodes = nodes;
100488
100489
  let posed2 = node2;
100489
- let patch = null;
100490
+ let patch2 = null;
100490
100491
  let values3 = inputs ? inputs.values : null;
100491
100492
  try {
100492
100493
  for (const key5 in tracks) {
@@ -100517,7 +100518,7 @@ function sampleNode(node2, t3, nodes, inputs) {
100517
100518
  if (prop.valueType === "color") posed2 = unbindItemColor(posed2, path);
100518
100519
  continue;
100519
100520
  }
100520
- if (prop.field) (patch ??= {})[prop.field] = v;
100521
+ if (prop.field) (patch2 ??= {})[prop.field] = v;
100521
100522
  else posed2 = prop.valueType === "color" ? unbindItemColor(prop.write(posed2, path, v), path) : prop.write(posed2, path, v);
100522
100523
  }
100523
100524
  for (const pair of PAIRS) {
@@ -100525,7 +100526,7 @@ function sampleNode(node2, t3, nodes, inputs) {
100525
100526
  if (!tx2 || inputs && (isInputPath(node2, pair[0], inputs.set) || isInputPath(node2, pair[1], inputs.set)) || hasBinding2(tx2) || ty && hasBinding2(ty)) continue;
100526
100527
  const d = spatialDelta(tx2, ty, t3);
100527
100528
  if (!d) continue;
100528
- const p2 = patch ??= {};
100529
+ const p2 = patch2 ??= {};
100529
100530
  for (let axis = 0; axis < 2; axis++) {
100530
100531
  const f2 = pair[axis];
100531
100532
  const cur = f2 in p2 ? p2[f2] : propertyFor(f2)?.read(node2, f2);
@@ -100535,7 +100536,7 @@ function sampleNode(node2, t3, nodes, inputs) {
100535
100536
  } finally {
100536
100537
  linkNodes = outer;
100537
100538
  }
100538
- return patch ? { ...posed2, ...patch } : posed2;
100539
+ return patch2 ? { ...posed2, ...patch2 } : posed2;
100539
100540
  }
100540
100541
  function motionNodes(nodes, rootId) {
100541
100542
  let memo5 = motionMemo.get(nodes);
@@ -100661,7 +100662,7 @@ var init_layer_time_edit = __esm({
100661
100662
  "lib/motion/layer-time-edit.ts"() {
100662
100663
  "use strict";
100663
100664
  init_time();
100664
- withMotion = (motion, patch) => ({ tracks: {}, ...motion, ...patch });
100665
+ withMotion = (motion, patch2) => ({ tracks: {}, ...motion, ...patch2 });
100665
100666
  }
100666
100667
  });
100667
100668
 
@@ -100676,12 +100677,12 @@ function videoClipOf(nodes, id3, frameId, duration3) {
100676
100677
  const speed = clampSpeed(paint.videoSpeed);
100677
100678
  return { nodeId: id3, fill, paint, start: bar.start, end: bar.end, zero, speed, in: sourceMsAt(paint, bar.start - zero), out: sourceMsAt(paint, bar.end - zero) };
100678
100679
  }
100679
- function withVideoPaint(node2, index2, patch) {
100680
+ function withVideoPaint(node2, index2, patch2) {
100680
100681
  const fills = fillsOf(node2);
100681
100682
  const cur = fills[index2];
100682
100683
  if (!cur) return node2;
100683
- const next2 = { ...cur, ...patch };
100684
- for (const k2 of Object.keys(patch)) if (next2[k2] === void 0) delete next2[k2];
100684
+ const next2 = { ...cur, ...patch2 };
100685
+ for (const k2 of Object.keys(patch2)) if (next2[k2] === void 0) delete next2[k2];
100685
100686
  if (Object.keys(next2).every((k2) => next2[k2] === cur[k2]) && Object.keys(next2).length === Object.keys(cur).length) return node2;
100686
100687
  return { ...node2, fills: fills.map((f2, i2) => i2 === index2 ? next2 : f2) };
100687
100688
  }
@@ -101605,16 +101606,16 @@ function resolveTextNodeStyles(node2, styles) {
101605
101606
  if (paragraphs) out.paragraphs = paragraphs;
101606
101607
  return out;
101607
101608
  }
101608
- function withParagraphFormat(node2, range3, patch) {
101609
+ function withParagraphFormat(node2, range3, patch2) {
101609
101610
  const ranges = paragraphRanges(node2.characters || "");
101610
101611
  const targets = range3 && range3.end > range3.start ? ranges.filter((r) => r.start <= range3.end && r.end >= range3.start) : ranges;
101611
101612
  const existing = new Map((node2.paragraphs ?? []).map((p2) => [p2.start, p2]));
101612
101613
  for (const r of targets) {
101613
101614
  const cur = existing.get(r.start) ?? { start: r.start };
101614
101615
  const next2 = { ...cur };
101615
- for (const k2 of Object.keys(patch)) {
101616
- if (patch[k2] === void 0) delete next2[k2];
101617
- else next2[k2] = patch[k2];
101616
+ for (const k2 of Object.keys(patch2)) {
101617
+ if (patch2[k2] === void 0) delete next2[k2];
101618
+ else next2[k2] = patch2[k2];
101618
101619
  }
101619
101620
  existing.set(r.start, next2);
101620
101621
  }
@@ -244638,6 +244639,23 @@ function trackLoad(p2) {
244638
244639
  p2.then(done, done);
244639
244640
  return p2;
244640
244641
  }
244642
+ function loadsSettled(timeoutMs = 1e4) {
244643
+ return new Promise((resolve7) => {
244644
+ let timer = null;
244645
+ const finish3 = (ok2) => {
244646
+ waiters.delete(onIdle);
244647
+ if (timer) clearTimeout(timer);
244648
+ setTimeout(() => resolve7(ok2), 0);
244649
+ };
244650
+ const onIdle = () => finish3(true);
244651
+ if (inflight === 0) {
244652
+ finish3(true);
244653
+ return;
244654
+ }
244655
+ waiters.add(onIdle);
244656
+ timer = setTimeout(() => finish3(false), timeoutMs);
244657
+ });
244658
+ }
244641
244659
  var inflight, waiters;
244642
244660
  var init_readiness = __esm({
244643
244661
  "lib/engine/readiness.ts"() {
@@ -246899,9 +246917,9 @@ function rescaleTextEffect(node2) {
246899
246917
  const preset = node2.textEffectPreset;
246900
246918
  const at4 = node2.textEffectSize;
246901
246919
  if (!preset || !DEFAULTS[preset] || !at4 || at4 === node2.fontSize) return null;
246902
- const patch = textEffectPatch(node2, preset);
246903
- if (preset !== "HOLLOW") delete patch.fills;
246904
- return patch;
246920
+ const patch2 = textEffectPatch(node2, preset);
246921
+ if (preset !== "HOLLOW") delete patch2.fills;
246922
+ return patch2;
246905
246923
  }
246906
246924
  var DEFAULTS, BLACK5, WHITE5, fillPaint, fillColor, shadow, round, OUTLINED;
246907
246925
  var init_effect_presets = __esm({
@@ -246942,12 +246960,12 @@ function addMarker(tl, t3, label3) {
246942
246960
  const marker = { id: id3, t: at4, ...label3 ? { label: label3 } : {} };
246943
246961
  return { timeline: withMarkers(tl, sortMarkers([...markers, marker])), id: id3 };
246944
246962
  }
246945
- function updateMarker(tl, id3, patch) {
246963
+ function updateMarker(tl, id3, patch2) {
246946
246964
  const markers = tl.markers ?? [];
246947
246965
  const i2 = markers.findIndex((m2) => m2.id === id3);
246948
246966
  if (i2 < 0) return tl;
246949
- const m = { ...markers[i2], ...patch };
246950
- if (patch.t !== void 0) m.t = Math.max(0, Math.round(patch.t));
246967
+ const m = { ...markers[i2], ...patch2 };
246968
+ if (patch2.t !== void 0) m.t = Math.max(0, Math.round(patch2.t));
246951
246969
  if (!m.label) delete m.label;
246952
246970
  if (m.kind === "marker" || m.kind === void 0) delete m.kind;
246953
246971
  const was = markers[i2];
@@ -247936,8 +247954,8 @@ function applyInvariants(doc2, touched) {
247936
247954
  function rescaleTextEffects(doc2, id3) {
247937
247955
  const n = doc2.nodes[id3];
247938
247956
  if (!n || n.type !== "TEXT") return doc2;
247939
- const patch = rescaleTextEffect(n);
247940
- return patch ? updateNode(doc2, id3, patch) : doc2;
247957
+ const patch2 = rescaleTextEffect(n);
247958
+ return patch2 ? updateNode(doc2, id3, patch2) : doc2;
247941
247959
  }
247942
247960
  function repairDocumentCompositions(doc2) {
247943
247961
  const comps = repairCompositions(doc2.compositions, doc2.nodes);
@@ -248592,9 +248610,9 @@ function writeSoundtrack(doc2, sound) {
248592
248610
  const compositions = { ...doc2.compositions, [built.composition.id]: built.composition };
248593
248611
  return repairDocumentCompositions({ ...doc2, compositions });
248594
248612
  }
248595
- function configure(doc2, pageId2, patch) {
248613
+ function configure(doc2, pageId2, patch2) {
248596
248614
  const sound = soundOf(doc2, pageId2);
248597
- return writeSoundtrack(doc2, { ...sound, settings: repairSettings({ ...sound.settings, ...patch }) });
248615
+ return writeSoundtrack(doc2, { ...sound, settings: repairSettings({ ...sound.settings, ...patch2 }) });
248598
248616
  }
248599
248617
  function retime(doc2, pageId2, o = {}) {
248600
248618
  const sound = soundOf(doc2, pageId2);
@@ -252419,7 +252437,6 @@ function resizeWindow(doc2, target2, rect) {
252419
252437
  }
252420
252438
  var init_crop = __esm({
252421
252439
  "lib/editor/crop.ts"() {
252422
- "use strict";
252423
252440
  init_dist_node();
252424
252441
  init_scene_graph();
252425
252442
  init_photo_frames();
@@ -253178,8 +253195,8 @@ async function bakeStroke(dabs, color4, opacity, hardness, wetMix = 0, backdrop,
253178
253195
  scale = Math.min(scale, Math.sqrt(MAX_STROKE_PIXELS / (worldW * worldH)));
253179
253196
  const pxW = Math.max(1, Math.round(worldW * scale));
253180
253197
  const pxH = Math.max(1, Math.round(worldH * scale));
253181
- const frame2 = { cx: minX + worldW / 2, cy: minY + worldH / 2, rotationRad: 0, flipX: false, flipY: false, width: worldW, height: worldH, pixelWidth: pxW, pixelHeight: pxH };
253182
- const batch = packDabs(dabs, frame2, { color: color4, alpha: Math.max(0, Math.min(1, opacity)), hardness, tip, stamp: !!stamp, secondaryColor });
253198
+ const frame3 = { cx: minX + worldW / 2, cy: minY + worldH / 2, rotationRad: 0, flipX: false, flipY: false, width: worldW, height: worldH, pixelWidth: pxW, pixelHeight: pxH };
253199
+ const batch = packDabs(dabs, frame3, { color: color4, alpha: Math.max(0, Math.min(1, opacity)), hardness, tip, stamp: !!stamp, secondaryColor });
253183
253200
  const grainTile = grain && grain.depth > 0 ? grain.image ?? getGrainTile(grain.type) : null;
253184
253201
  const wet = backdrop && !stamp ? Math.max(0, Math.min(1, wetMix)) : 0;
253185
253202
  const pixels = await layers2.bake(pxW, pxH, batch, {
@@ -253236,9 +253253,9 @@ function worldToLayer(f2, wx, wy) {
253236
253253
  function layerDensity(f2) {
253237
253254
  return f2.pixelWidth / Math.max(1e-6, f2.width);
253238
253255
  }
253239
- function packDabs(dabs, frame2, paint, prev) {
253256
+ function packDabs(dabs, frame3, paint, prev) {
253240
253257
  const data = new Float32Array(dabs.length * DAB_STRIDE);
253241
- const k2 = layerDensity(frame2);
253258
+ const k2 = layerDensity(frame3);
253242
253259
  const base = paint.color;
253243
253260
  const baseHsl = rgbToHsl(base.r ?? 0, base.g ?? 0, base.b ?? 0);
253244
253261
  const sec = paint.secondaryColor;
@@ -253246,7 +253263,7 @@ function packDabs(dabs, frame2, paint, prev) {
253246
253263
  let n = 0;
253247
253264
  let last3 = prev ?? null;
253248
253265
  for (const d of dabs) {
253249
- const p2 = worldToLayer(frame2, d.cx, d.cy);
253266
+ const p2 = worldToLayer(frame3, d.cx, d.cy);
253250
253267
  const round5 = Math.max(0.1, d.roundness ?? 1);
253251
253268
  let rx = d.r * k2, ry = d.r * round5 * k2;
253252
253269
  let mode = 0;
@@ -253262,14 +253279,14 @@ function packDabs(dabs, frame2, paint, prev) {
253262
253279
  mode = 1;
253263
253280
  ry *= 0.5;
253264
253281
  }
253265
- const angle2 = d.angle - frame2.rotationRad;
253282
+ const angle2 = d.angle - frame3.rotationRad;
253266
253283
  const o = n * DAB_STRIDE;
253267
253284
  data[o] = p2.x;
253268
253285
  data[o + 1] = p2.y;
253269
253286
  data[o + 2] = rx;
253270
253287
  data[o + 3] = ry;
253271
253288
  data[o + 12] = d.charge ?? 1;
253272
- data[o + 13] = (d.travel ?? 0) - frame2.rotationRad;
253289
+ data[o + 13] = (d.travel ?? 0) - frame3.rotationRad;
253273
253290
  data[o + 4] = angle2;
253274
253291
  data[o + 5] = (paint.smudgeStrength !== void 0 || paint.liquify) && mode === 0 ? 0.6 : d.hardness ?? paint.hardness;
253275
253292
  data[o + 6] = mode;
@@ -253282,7 +253299,7 @@ function packDabs(dabs, frame2, paint, prev) {
253282
253299
  last3 = d;
253283
253300
  continue;
253284
253301
  }
253285
- const q = worldToLayer(frame2, last3.cx, last3.cy);
253302
+ const q = worldToLayer(frame3, last3.cx, last3.cy);
253286
253303
  last3 = d;
253287
253304
  data[o + 8] = p2.x - q.x;
253288
253305
  data[o + 9] = p2.y - q.y;
@@ -253293,7 +253310,7 @@ function packDabs(dabs, frame2, paint, prev) {
253293
253310
  last3 = d;
253294
253311
  continue;
253295
253312
  }
253296
- const q = worldToLayer(frame2, last3.cx, last3.cy);
253313
+ const q = worldToLayer(frame3, last3.cx, last3.cy);
253297
253314
  last3 = d;
253298
253315
  data[o + 8] = p2.x - q.x;
253299
253316
  data[o + 9] = p2.y - q.y;
@@ -253378,8 +253395,8 @@ function imageEditGroupOf(nodes, nodeId2) {
253378
253395
  function wrapTargetFor(doc2, nodeId2) {
253379
253396
  const node2 = doc2.nodes[nodeId2];
253380
253397
  if (!node2) return null;
253381
- const frame2 = photoFrameOf(doc2.nodes, nodeId2);
253382
- return frame2 ? frame2.id : nodeId2;
253398
+ const frame3 = photoFrameOf(doc2.nodes, nodeId2);
253399
+ return frame3 ? frame3.id : nodeId2;
253383
253400
  }
253384
253401
  function prepareImageEdit(doc2, nodeId2) {
253385
253402
  const existing = imageEditGroupOf(doc2.nodes, nodeId2);
@@ -253939,8 +253956,8 @@ function createDrawPaletteSlice(set4, get4) {
253939
253956
  commit([...palette2(), tool2], "Add to palette", { activeDrawToolId: tool2.id, editingDrawToolId: tool2.id });
253940
253957
  return tool2.id;
253941
253958
  },
253942
- updateDrawTool: (id3, patch) => {
253943
- const next2 = palette2().map((t3) => t3.id === id3 ? { ...t3, ...patch } : t3);
253959
+ updateDrawTool: (id3, patch2) => {
253960
+ const next2 = palette2().map((t3) => t3.id === id3 ? { ...t3, ...patch2 } : t3);
253944
253961
  commit(next2, "Edit palette");
253945
253962
  },
253946
253963
  removeDrawTool: (id3) => {
@@ -254307,17 +254324,17 @@ function createModeSlice(set4, get4) {
254307
254324
  saveTabSides(tabSides);
254308
254325
  const from2 = side === "left" ? "right" : "left";
254309
254326
  const fromKey = from2 === "left" ? "leftTab" : "rightTab";
254310
- const patch = { tabSides, tabOrder };
254327
+ const patch2 = { tabSides, tabOrder };
254311
254328
  if (state[fromKey] === tab) {
254312
254329
  const next2 = tabsOn(tabSides, from2, tabOrder).find((t3) => !ACTION_TABS.has(t3));
254313
- if (next2) patch[fromKey] = next2;
254314
- else patch[from2 === "left" ? "leftPanelOpen" : "rightPanelOpen"] = false;
254330
+ if (next2) patch2[fromKey] = next2;
254331
+ else patch2[from2 === "left" ? "leftPanelOpen" : "rightPanelOpen"] = false;
254315
254332
  }
254316
254333
  if (!action3) {
254317
- patch[side === "left" ? "leftTab" : "rightTab"] = tab;
254318
- patch[side === "left" ? "leftPanelOpen" : "rightPanelOpen"] = true;
254334
+ patch2[side === "left" ? "leftTab" : "rightTab"] = tab;
254335
+ patch2[side === "left" ? "leftPanelOpen" : "rightPanelOpen"] = true;
254319
254336
  }
254320
- set4(patch);
254337
+ set4(patch2);
254321
254338
  },
254322
254339
  setStageView: (on, mode) => {
254323
254340
  const state = get4();
@@ -254471,24 +254488,24 @@ var init_pixel_layers = __esm({
254471
254488
  });
254472
254489
 
254473
254490
  // lib/engine/pixel/pixel-texture.ts
254474
- function setWorkingPixels(nodeId2, frame2, rgba, version7 = 0) {
254491
+ function setWorkingPixels(nodeId2, frame3, rgba, version7 = 0) {
254475
254492
  if (!rgba) working.delete(nodeId2);
254476
- else working.set(nodeId2, { frame: frame2, rgba, version: version7 });
254493
+ else working.set(nodeId2, { frame: frame3, rgba, version: version7 });
254477
254494
  if (typeof window !== "undefined") window.dispatchEvent(new CustomEvent("popcraft-render"));
254478
254495
  }
254479
254496
  function frameRGBA(node2, frameIndex) {
254480
- const frame2 = node2.frames[Math.max(0, Math.min(node2.frames.length - 1, frameIndex))];
254497
+ const frame3 = node2.frames[Math.max(0, Math.min(node2.frames.length - 1, frameIndex))];
254481
254498
  const w = node2.pixelWidth, h = node2.pixelHeight;
254482
- if (!frame2) return new Uint32Array(w * h);
254483
- const key5 = [frame2.cels, node2.palette, node2.colorMode, node2.transparentIndex, node2.tileset, w, h];
254484
- const holder = frame2;
254499
+ if (!frame3) return new Uint32Array(w * h);
254500
+ const key5 = [frame3.cels, node2.palette, node2.colorMode, node2.transparentIndex, node2.tileset, w, h];
254501
+ const holder = frame3;
254485
254502
  const hit = rgbaCache.get(holder);
254486
254503
  if (hit && hit.key.length === key5.length && hit.key.every((k2, i2) => k2 === key5[i2])) return hit.rgba;
254487
254504
  let rgba;
254488
254505
  if (node2.tileset) {
254489
254506
  const { tileW, tileH, tiles } = node2.tileset;
254490
254507
  const cols = Math.max(1, Math.floor(w / tileW)), rows = Math.max(1, Math.floor(h / tileH));
254491
- const map2 = decodeCels(frame2.cels, cols * rows);
254508
+ const map2 = decodeCels(frame3.cels, cols * rows);
254492
254509
  rgba = new Uint32Array(w * h);
254493
254510
  const tileRGBA = tiles.map((t3) => celsToRGBA(decodeCels(t3, tileW * tileH), node2.colorMode, node2.palette, node2.transparentIndex));
254494
254511
  for (let ty = 0; ty < rows; ty++) for (let tx2 = 0; tx2 < cols; tx2++) {
@@ -254501,7 +254518,7 @@ function frameRGBA(node2, frameIndex) {
254501
254518
  }
254502
254519
  }
254503
254520
  } else {
254504
- rgba = celsToRGBA(decodeCels(frame2.cels, w * h), node2.colorMode, node2.palette, node2.transparentIndex);
254521
+ rgba = celsToRGBA(decodeCels(frame3.cels, w * h), node2.colorMode, node2.palette, node2.transparentIndex);
254505
254522
  }
254506
254523
  rgbaCache.set(holder, { key: key5, rgba });
254507
254524
  return rgba;
@@ -254509,8 +254526,8 @@ function frameRGBA(node2, frameIndex) {
254509
254526
  function setPixelEditingNode(id3) {
254510
254527
  editingNodeId = id3;
254511
254528
  }
254512
- function setPixelPreviewFrame(nodeId2, frame2 = 0) {
254513
- previewFrame = nodeId2 ? { nodeId: nodeId2, frame: frame2 } : null;
254529
+ function setPixelPreviewFrame(nodeId2, frame3 = 0) {
254530
+ previewFrame = nodeId2 ? { nodeId: nodeId2, frame: frame3 } : null;
254514
254531
  if (typeof window !== "undefined") window.dispatchEvent(new CustomEvent("popcraft-render"));
254515
254532
  }
254516
254533
  var working, rgbaCache, editingNodeId, previewFrame;
@@ -254635,14 +254652,14 @@ function createPixelSlice(set4, get4) {
254635
254652
  const empty2 = new Uint32Array(count2);
254636
254653
  if (n.tileset) empty2.fill(EMPTY_INDEX);
254637
254654
  else if (n.colorMode === "INDEXED") empty2.fill(n.transparentIndex);
254638
- const frame2 = { id: v4_default(), cels: opts.duplicate && src ? src.cels : encodeCels(empty2), duration: src?.duration ?? 100 };
254639
- const frames = [...n.frames.slice(0, at4), frame2, ...n.frames.slice(at4)];
254655
+ const frame3 = { id: v4_default(), cels: opts.duplicate && src ? src.cels : encodeCels(empty2), duration: src?.duration ?? 100 };
254656
+ const frames = [...n.frames.slice(0, at4), frame3, ...n.frames.slice(at4)];
254640
254657
  const tags = n.tags.map((t3) => ({ ...t3, from: t3.from >= at4 ? t3.from + 1 : t3.from, to: t3.to >= at4 ? t3.to + 1 : t3.to }));
254641
254658
  let doc2 = updateNode(get4().document, id3, { frames, tags, activeFrame: at4 });
254642
254659
  if (opts.duplicate && src) {
254643
254660
  for (const l of layersOf(doc2, n)) {
254644
254661
  const ids2 = frameIdsOf(l);
254645
- if (ids2 && ids2.includes(src.id)) doc2 = updateNode(doc2, l.id, { pixelFrameIds: [...ids2, frame2.id] });
254662
+ if (ids2 && ids2.includes(src.id)) doc2 = updateNode(doc2, l.id, { pixelFrameIds: [...ids2, frame3.id] });
254646
254663
  }
254647
254664
  }
254648
254665
  commitDoc(doc2, opts.duplicate ? "Duplicate frame" : "New frame");
@@ -254686,10 +254703,10 @@ function createPixelSlice(set4, get4) {
254686
254703
  const tag2 = { id: v4_default(), name: `Tag ${n.tags.length + 1}`, from: clampFrame(n, Math.min(from2, to)), to: clampFrame(n, Math.max(from2, to)), direction: "FORWARD", color: colors2[n.tags.length % colors2.length] };
254687
254704
  commit(id3, { tags: [...n.tags, tag2] }, "Add tag");
254688
254705
  },
254689
- pixelUpdateTag: (id3, tagId, patch) => {
254706
+ pixelUpdateTag: (id3, tagId, patch2) => {
254690
254707
  const n = node2(id3);
254691
254708
  if (!n) return;
254692
- commit(id3, { tags: n.tags.map((t3) => t3.id === tagId ? { ...t3, ...patch } : t3) }, "Edit tag");
254709
+ commit(id3, { tags: n.tags.map((t3) => t3.id === tagId ? { ...t3, ...patch2 } : t3) }, "Edit tag");
254693
254710
  },
254694
254711
  pixelDeleteTag: (id3, tagId) => {
254695
254712
  const n = node2(id3);
@@ -254697,9 +254714,9 @@ function createPixelSlice(set4, get4) {
254697
254714
  commit(id3, { tags: n.tags.filter((t3) => t3.id !== tagId) }, "Delete tag");
254698
254715
  },
254699
254716
  /** Generic pixel-node property change (onion skin, tiled mode, reference…) as one undo step. */
254700
- pixelUpdate: (id3, patch, description = "Pixel canvas settings") => {
254717
+ pixelUpdate: (id3, patch2, description = "Pixel canvas settings") => {
254701
254718
  if (!node2(id3)) return;
254702
- commit(id3, patch, description);
254719
+ commit(id3, patch2, description);
254703
254720
  },
254704
254721
  /**
254705
254722
  * Bake layers into pixels as one undo step. Default: the active frame — its layers are merged into its
@@ -254826,14 +254843,14 @@ function createPixelSlice(set4, get4) {
254826
254843
  palette2 = extractPalette(all4, 256).map(packedToHex);
254827
254844
  }
254828
254845
  const conv = (b64, cellCount) => encodeCels(convertCels(decodeCels(b64, cellCount), n.colorMode, mode, n.palette, palette2, n.transparentIndex));
254829
- const patch = { colorMode: mode, palette: palette2 };
254846
+ const patch2 = { colorMode: mode, palette: palette2 };
254830
254847
  if (n.tileset) {
254831
254848
  const tc = n.tileset.tileW * n.tileset.tileH;
254832
- patch.tileset = { ...n.tileset, tiles: n.tileset.tiles.map((t3) => conv(t3, tc)) };
254849
+ patch2.tileset = { ...n.tileset, tiles: n.tileset.tiles.map((t3) => conv(t3, tc)) };
254833
254850
  } else {
254834
- patch.frames = n.frames.map((f2) => ({ ...f2, cels: conv(f2.cels, count2) }));
254851
+ patch2.frames = n.frames.map((f2) => ({ ...f2, cels: conv(f2.cels, count2) }));
254835
254852
  }
254836
- commit(id3, patch, `Color mode: ${mode.toLowerCase()}`);
254853
+ commit(id3, patch2, `Color mode: ${mode.toLowerCase()}`);
254837
254854
  },
254838
254855
  /** Dedupe the canvas into a tileset + per-frame tile maps (Aseprite "convert to tilemap"). */
254839
254856
  pixelConvertToTilemap: (id3, tileW, tileH) => {
@@ -255947,7 +255964,6 @@ fn shade(uv: vec2<f32>, res: vec2<f32>, tm: f32) -> vec4<f32> {
255947
255964
  var SHADER_PRESETS, shaderPreset, legacyPresetOf, DEFAULT_SHADER_PRESET, DEFAULT_TEXTURE_PARAMS, f, vec4, NOISE_LIB;
255948
255965
  var init_shader_presets = __esm({
255949
255966
  "lib/engine/shader-presets.ts"() {
255950
- "use strict";
255951
255967
  init_shader_graph();
255952
255968
  init_shader_graph_presets();
255953
255969
  init_shader_presets_legacy();
@@ -256300,20 +256316,20 @@ function createWashiTape(a, b, styleId, edge = "SPIKY", width = 32, seed2 = Date
256300
256316
  ...{ washiStyle: style.id, washiEdge: edge, washiSeed: shortSeed }
256301
256317
  });
256302
256318
  }
256303
- function restyleWashiTape(node2, patch) {
256319
+ function restyleWashiTape(node2, patch2) {
256304
256320
  const n = node2;
256305
256321
  if (!n.washiStyle) return node2;
256306
- const style = washiStyle(patch.styleId ?? n.washiStyle);
256307
- const edge = patch.edge ?? n.washiEdge ?? "SPIKY";
256322
+ const style = washiStyle(patch2.styleId ?? n.washiStyle);
256323
+ const edge = patch2.edge ?? n.washiEdge ?? "SPIKY";
256308
256324
  const seed2 = n.washiSeed ?? 1;
256309
256325
  return {
256310
256326
  ...n,
256311
- name: patch.styleId ? `Washi tape \xB7 ${style.label}` : n.name,
256327
+ name: patch2.styleId ? `Washi tape \xB7 ${style.label}` : n.name,
256312
256328
  washiStyle: style.id,
256313
256329
  washiEdge: edge,
256314
256330
  washiSeed: seed2,
256315
256331
  paths: [{ closed: true, points: washiOutline(n.width, n.height, seed2, edge) }],
256316
- fills: patch.styleId ? [washiFill(style, n.height, seed2)] : n.fills
256332
+ fills: patch2.styleId ? [washiFill(style, n.height, seed2)] : n.fills
256317
256333
  };
256318
256334
  }
256319
256335
  var PLAIN, PATTERNED, WASHI_TAPES, washiStyle;
@@ -256534,21 +256550,24 @@ function freshIdMap(t3) {
256534
256550
  return map2;
256535
256551
  }
256536
256552
  function addTree(document2, t3, map2, rootId, parentId, ox, oy) {
256537
- const walk4 = (id3, parent, isRoot) => {
256553
+ const parent = document2.nodes[parentId];
256554
+ if (!parent || !t3.payload.nodes[rootId]) return document2;
256555
+ const nodes = { ...document2.nodes };
256556
+ const walk4 = (id3, parent2, isRoot) => {
256538
256557
  const src = t3.payload.nodes[id3];
256539
256558
  if (!src) return;
256540
- const n = rewriteIds(JSON.parse(JSON.stringify(src)), map2);
256541
- const kids = src.childIds ?? [];
256542
- n.childIds = [];
256559
+ const n = rewriteIds(src, map2);
256543
256560
  if (isRoot) {
256544
256561
  n.x += ox;
256545
256562
  n.y += oy;
256546
256563
  }
256547
- document2 = addNode(document2, { ...n, parentId: parent }, parent);
256548
- for (const k2 of kids) walk4(k2, n.id, false);
256564
+ nodes[n.id] = { ...n, childIds: [], parentId: parent2 };
256565
+ const p2 = nodes[parent2];
256566
+ nodes[parent2] = { ...p2, childIds: [...p2.childIds, n.id] };
256567
+ for (const k2 of src.childIds ?? []) walk4(k2, n.id, false);
256549
256568
  };
256550
256569
  walk4(rootId, parentId, true);
256551
- return document2;
256570
+ return { ...document2, nodes };
256552
256571
  }
256553
256572
  function mergeRecords(doc2, t3, map2, roots) {
256554
256573
  const p2 = t3.payload;
@@ -256797,11 +256816,11 @@ function colorFor(id3) {
256797
256816
  for (let i2 = 0; i2 < id3.length; i2++) h = h * 31 + id3.charCodeAt(i2) >>> 0;
256798
256817
  return PALETTE[h % PALETTE.length];
256799
256818
  }
256800
- function updateLocal(patch) {
256819
+ function updateLocal(patch2) {
256801
256820
  if (!awareness) return;
256802
256821
  const cur = awareness.getLocalState();
256803
256822
  if (!cur) return;
256804
- awareness.setLocalState({ ...cur, ...patch });
256823
+ awareness.setLocalState({ ...cur, ...patch2 });
256805
256824
  }
256806
256825
  function sendCursor() {
256807
256826
  cursorTimer = null;
@@ -256954,12 +256973,12 @@ function createPopcornSlice(set4, get4) {
256954
256973
  const state = get4();
256955
256974
  set4({ document: after, ...extra, history: pushCommand(state.history, createCommand("POPCORN", description, state.document, after)) });
256956
256975
  };
256957
- const restyleSelectedTapes = (patch, description) => {
256976
+ const restyleSelectedTapes = (patch2, description) => {
256958
256977
  const state = get4();
256959
256978
  let doc2 = state.document;
256960
256979
  for (const id3 of state.selection) {
256961
256980
  const n = doc2.nodes[id3];
256962
- if (n?.washiStyle) doc2 = { ...doc2, nodes: { ...doc2.nodes, [id3]: restyleWashiTape(n, patch) } };
256981
+ if (n?.washiStyle) doc2 = { ...doc2, nodes: { ...doc2.nodes, [id3]: restyleWashiTape(n, patch2) } };
256963
256982
  }
256964
256983
  if (doc2 !== state.document) commit(doc2, description);
256965
256984
  };
@@ -257605,16 +257624,16 @@ async function listDocMetas() {
257605
257624
  async function getDocMeta(id3) {
257606
257625
  return (await readIndex()).find((m) => m.id === id3) ?? null;
257607
257626
  }
257608
- async function upsertDocMeta(patch, { create: create8 = false } = {}) {
257609
- if (deletedHere.has(patch.id)) return;
257627
+ async function upsertDocMeta(patch2, { create: create8 = false } = {}) {
257628
+ if (deletedHere.has(patch2.id)) return;
257610
257629
  await update2(INDEX_KEY, (idx) => {
257611
257630
  const list2 = Array.isArray(idx) ? [...idx] : [];
257612
- const i2 = list2.findIndex((m) => m.id === patch.id);
257631
+ const i2 = list2.findIndex((m) => m.id === patch2.id);
257613
257632
  if (i2 < 0 && !create8) return list2;
257614
257633
  if (i2 >= 0) {
257615
257634
  const { thumbnail: inline, ...rest } = list2[i2];
257616
- list2[i2] = { ...rest, ...typeof inline === "string" ? { thumbnail: inline } : {}, ...patch };
257617
- } else list2.push({ id: patch.id, name: patch.name || "Untitled", updatedAt: patch.updatedAt || Date.now(), thumbAt: patch.thumbAt });
257635
+ list2[i2] = { ...rest, ...typeof inline === "string" ? { thumbnail: inline } : {}, ...patch2 };
257636
+ } else list2.push({ id: patch2.id, name: patch2.name || "Untitled", updatedAt: patch2.updatedAt || Date.now(), thumbAt: patch2.thumbAt });
257618
257637
  return list2;
257619
257638
  });
257620
257639
  }
@@ -258007,8 +258026,8 @@ function openFramingIds(nodes, pageId2) {
258007
258026
  const page = nodes[pageId2];
258008
258027
  if (!page) return [];
258009
258028
  const children = (page.childIds ?? []).filter((id3) => nodes[id3] && nodes[id3].visible !== false);
258010
- const frame2 = children.find((id3) => nodes[id3].type === "FRAME");
258011
- return frame2 ? [frame2] : children;
258029
+ const frame3 = children.find((id3) => nodes[id3].type === "FRAME");
258030
+ return frame3 ? [frame3] : children;
258012
258031
  }
258013
258032
  function isSavedCamera(camera2) {
258014
258033
  if (!camera2 || !Number.isFinite(camera2.x) || !Number.isFinite(camera2.y) || !(camera2.zoom > 0)) return false;
@@ -258074,14 +258093,14 @@ function withCounter(node2, counter) {
258074
258093
  }
258075
258094
  return { ...node2, textCounter: counter, characters: formatCounter(counter, counterRest(counter)) };
258076
258095
  }
258077
- function editCounter(node2, patch) {
258096
+ function editCounter(node2, patch2) {
258078
258097
  const c2 = node2.textCounter;
258079
258098
  if (!c2) return node2;
258080
- const next2 = { ...c2, ...patch };
258099
+ const next2 = { ...c2, ...patch2 };
258081
258100
  let motion = node2.motion;
258082
258101
  const track2 = motion?.tracks[COUNTER_PATH];
258083
- if (track2?.keys.length && (patch.from !== void 0 || patch.to !== void 0)) {
258084
- const keys4 = track2.keys.map((k2, i2, all4) => i2 === 0 && patch.from !== void 0 ? { ...k2, v: next2.from } : i2 === all4.length - 1 && patch.to !== void 0 ? { ...k2, v: next2.to } : k2);
258102
+ if (track2?.keys.length && (patch2.from !== void 0 || patch2.to !== void 0)) {
258103
+ const keys4 = track2.keys.map((k2, i2, all4) => i2 === 0 && patch2.from !== void 0 ? { ...k2, v: next2.from } : i2 === all4.length - 1 && patch2.to !== void 0 ? { ...k2, v: next2.to } : k2);
258085
258104
  motion = withTrack(motion, COUNTER_PATH, { ...track2, keys: keys4 });
258086
258105
  }
258087
258106
  return { ...withCounter(node2, next2), motion };
@@ -258348,9 +258367,9 @@ function frameSound(nodes, frameId, lengths2 = NO_LENGTHS) {
258348
258367
  let list2 = frameMemo.get(nodes);
258349
258368
  const hit = list2?.find((m) => m.frameId === frameId && m.lengths === lengths2);
258350
258369
  if (hit) return hit.sound;
258351
- const frame2 = nodes[frameId];
258352
- const sound = frame2 ? [...frame2.timeline?.audio ?? []] : [];
258353
- if (frame2) {
258370
+ const frame3 = nodes[frameId];
258371
+ const sound = frame3 ? [...frame3.timeline?.audio ?? []] : [];
258372
+ if (frame3) {
258354
258373
  const duration3 = timelineDuration(nodes, frameId);
258355
258374
  for (const id3 of videoNodeIds(nodes)) {
258356
258375
  if (id3 === frameId || localTime(nodes, id3, frameId, 0) === void 0) continue;
@@ -258538,7 +258557,7 @@ function compositionPose(base, target2, time4, clock2, runtime, compositions, au
258538
258557
  });
258539
258558
  if (!stage) return pose;
258540
258559
  const moment = compositionAt(comp, time4);
258541
- let patch = null;
258560
+ let patch2 = null;
258542
258561
  const ids2 = /* @__PURE__ */ new Set();
258543
258562
  let live = time4 < compositionDuration(comp);
258544
258563
  for (const a of [moment.previous, moment.current]) {
@@ -258546,7 +258565,7 @@ function compositionPose(base, target2, time4, clock2, runtime, compositions, au
258546
258565
  const fp = evaluatePose(base, { kind: "frame", frameId: a.clip.frameId }, a.local, { clock: clock2, runtime, driveVideo: true, ...audio ? { audio } : {} });
258547
258566
  if (fp.live) live = true;
258548
258567
  for (const id3 of fp.animatedIds) {
258549
- (patch ??= {})[id3] = fp.nodes[id3];
258568
+ (patch2 ??= {})[id3] = fp.nodes[id3];
258550
258569
  ids2.add(id3);
258551
258570
  }
258552
258571
  }
@@ -258554,8 +258573,8 @@ function compositionPose(base, target2, time4, clock2, runtime, compositions, au
258554
258573
  const t3 = placed2(id3), n = base[id3];
258555
258574
  return t3 && n ? { width: n.width, height: n.height, cx: t3.cx, cy: t3.cy } : null;
258556
258575
  });
258557
- const posed2 = patch ? { ...base, ...patch } : base;
258558
- if (patch) noteChanged(base, posed2, Object.keys(patch));
258576
+ const posed2 = patch2 ? { ...base, ...patch2 } : base;
258577
+ if (patch2) noteChanged(base, posed2, Object.keys(patch2));
258559
258578
  return {
258560
258579
  ...pose,
258561
258580
  nodes: posed2,
@@ -258597,17 +258616,17 @@ function withOrbits(pose, orbits) {
258597
258616
  const hit = orbitMemo.get(pose);
258598
258617
  if (hit && hit.orbits === orbits) return hit.pose;
258599
258618
  const nodes = pose.nodes;
258600
- const patch = {};
258619
+ const patch2 = {};
258601
258620
  const visit2 = (id3) => {
258602
258621
  const n = nodes[id3];
258603
258622
  if (!n) return;
258604
258623
  const o = orbits.turns[n.name];
258605
- if (o) patch[id3] = { ...n, rotateX: (n.rotateX ?? 0) + o.rotateX, rotateY: (n.rotateY ?? 0) + o.rotateY };
258624
+ if (o) patch2[id3] = { ...n, rotateX: (n.rotateX ?? 0) + o.rotateX, rotateY: (n.rotateY ?? 0) + o.rotateY };
258606
258625
  for (const c2 of n.childIds ?? []) visit2(c2);
258607
258626
  };
258608
258627
  for (const r of orbits.roots) visit2(r);
258609
- const ids2 = Object.keys(patch);
258610
- const shown2 = ids2.length ? { ...nodes, ...patch } : nodes;
258628
+ const ids2 = Object.keys(patch2);
258629
+ const shown2 = ids2.length ? { ...nodes, ...patch2 } : nodes;
258611
258630
  noteChanged(nodes, shown2, ids2);
258612
258631
  const out = { ...pose, nodes: shown2, animatedIds: ids2.length ? /* @__PURE__ */ new Set([...pose.animatedIds, ...ids2]) : pose.animatedIds, orbits };
258613
258632
  orbitMemo.set(pose, { orbits, pose: out });
@@ -258623,7 +258642,7 @@ function withSolo(pose, solo) {
258623
258642
  const on = new Set(solo.filter((id3) => nodes[id3]));
258624
258643
  const onTheWay = /* @__PURE__ */ new Set();
258625
258644
  for (const id3 of on) for (let n = nodes[nodes[id3]?.parentId ?? ""]; n; n = n.parentId ? nodes[n.parentId] : void 0) onTheWay.add(n.id);
258626
- const patch = {};
258645
+ const patch2 = {};
258627
258646
  const visit2 = (id3) => {
258628
258647
  const n = nodes[id3];
258629
258648
  if (!n || on.has(id3)) return;
@@ -258631,11 +258650,11 @@ function withSolo(pose, solo) {
258631
258650
  for (const c2 of n.childIds) visit2(c2);
258632
258651
  return;
258633
258652
  }
258634
- if (n.visible !== false) patch[id3] = { ...n, visible: false };
258653
+ if (n.visible !== false) patch2[id3] = { ...n, visible: false };
258635
258654
  };
258636
258655
  if (on.size) for (const c2 of nodes[frameId]?.childIds ?? []) visit2(c2);
258637
- const ids2 = Object.keys(patch);
258638
- const shown2 = ids2.length ? { ...nodes, ...patch } : nodes;
258656
+ const ids2 = Object.keys(patch2);
258657
+ const shown2 = ids2.length ? { ...nodes, ...patch2 } : nodes;
258639
258658
  noteChanged(nodes, shown2, ids2);
258640
258659
  const out = { ...pose, nodes: shown2, animatedIds: ids2.length ? /* @__PURE__ */ new Set([...pose.animatedIds, ...ids2]) : pose.animatedIds, solo };
258641
258660
  soloMemo.set(pose, { solo: key5, pose: out });
@@ -260439,7 +260458,6 @@ function retuneShaderAudio(node2, fillId) {
260439
260458
  }
260440
260459
  var init_shader_audio = __esm({
260441
260460
  "lib/motion/shader-audio.ts"() {
260442
- "use strict";
260443
260461
  init_shader_params();
260444
260462
  init_modifier_edit();
260445
260463
  init_keys();
@@ -260624,8 +260642,8 @@ function timeBoundsOf(s) {
260624
260642
  const width = s.timeViewWidth;
260625
260643
  const soundEnd = (audio) => Math.max(0, ...(audio ?? []).map(audioClipEnd));
260626
260644
  if (t3?.kind === "frame") {
260627
- const frame2 = s.document.nodes[t3.frameId];
260628
- return frame2 ? { duration: frameDuration(s.document.nodes, t3.frameId), fps: timelineFps(frame2.timeline), width, content: soundEnd(frame2.timeline?.audio) } : null;
260645
+ const frame3 = s.document.nodes[t3.frameId];
260646
+ return frame3 ? { duration: frameDuration(s.document.nodes, t3.frameId), fps: timelineFps(frame3.timeline), width, content: soundEnd(frame3.timeline?.audio) } : null;
260629
260647
  }
260630
260648
  const comp = t3?.kind === "composition" ? s.document.compositions?.[t3.compositionId] : void 0;
260631
260649
  return comp ? { duration: compositionDuration(comp), fps: comp.fps, width, content: soundEnd(comp.audio) } : null;
@@ -260652,7 +260670,7 @@ function snapTime(tr, t3) {
260652
260670
  return snapToFrame(at4, tr.fps);
260653
260671
  }
260654
260672
  function createMotionSlice(set4, get4) {
260655
- const put3 = (patch) => set4({ transport: { ...get4().transport, ...patch } });
260673
+ const put3 = (patch2) => set4({ transport: { ...get4().transport, ...patch2 } });
260656
260674
  const clock2 = (now2) => now2 ?? transportNow();
260657
260675
  const frameId = () => {
260658
260676
  const s = get4();
@@ -260814,9 +260832,9 @@ function createMotionSlice(set4, get4) {
260814
260832
  set4({ solo: cur.includes(id3) ? cur.filter((x2) => x2 !== id3) : [...cur, id3] });
260815
260833
  },
260816
260834
  onion: { on: false, count: 2, stepFrames: 3 },
260817
- setOnion: (patch) => {
260835
+ setOnion: (patch2) => {
260818
260836
  const cur = get4().onion;
260819
- const next2 = { ...cur, ...patch, count: Math.max(1, Math.min(8, Math.round(patch.count ?? cur.count))), stepFrames: Math.max(1, Math.min(30, Math.round(patch.stepFrames ?? cur.stepFrames))) };
260837
+ const next2 = { ...cur, ...patch2, count: Math.max(1, Math.min(8, Math.round(patch2.count ?? cur.count))), stepFrames: Math.max(1, Math.min(30, Math.round(patch2.stepFrames ?? cur.stepFrames))) };
260820
260838
  if (next2.on !== cur.on || next2.count !== cur.count || next2.stepFrames !== cur.stepFrames) set4({ onion: next2 });
260821
260839
  },
260822
260840
  timeViews: {},
@@ -261081,8 +261099,8 @@ function foldVariant(doc2, masterId, variantId, id3) {
261081
261099
  if ((k2 === "fontSize" || k2 === "lineHeight") && restyled) continue;
261082
261100
  props[k2] = value3;
261083
261101
  }
261084
- const patch = breakpointPatch(master, doc2, id3, props);
261085
- if ("responsive" in patch && !same2(patch.responsive, master.responsive)) nodes[m] = { ...master, responsive: patch.responsive };
261102
+ const patch2 = breakpointPatch(master, doc2, id3, props);
261103
+ if ("responsive" in patch2 && !same2(patch2.responsive, master.responsive)) nodes[m] = { ...master, responsive: patch2.responsive };
261086
261104
  const a = master.childIds ?? [], b = variant.childIds ?? [];
261087
261105
  if (a.length === b.length) a.forEach((c2, i2) => walk4(c2, b[i2], false));
261088
261106
  };
@@ -261350,11 +261368,11 @@ function shownRecordOf(nodes, doc2, id3) {
261350
261368
  const own2 = pinnedRecord(doc2, nodes[id3]);
261351
261369
  if (own2) return own2;
261352
261370
  for (let at4 = nodes[id3]?.parentId, hops = 0; at4 && hops < 64; at4 = nodes[at4]?.parentId, hops++) {
261353
- const frame2 = nodes[at4];
261354
- const pinned = pinnedRecord(doc2, frame2);
261371
+ const frame3 = nodes[at4];
261372
+ const pinned = pinnedRecord(doc2, frame3);
261355
261373
  if (pinned) return pinned;
261356
- if (frame2?.repeat) return repeatRecords(doc2, frame2.repeat)[0] ?? null;
261357
- const of = frame2?.route?.collectionId;
261374
+ if (frame3?.repeat) return repeatRecords(doc2, frame3.repeat)[0] ?? null;
261375
+ const of = frame3?.route?.collectionId;
261358
261376
  if (of && doc2.collections?.[of]) return repeatRecords(doc2, { collectionId: of })[0] ?? null;
261359
261377
  }
261360
261378
  return null;
@@ -261640,11 +261658,11 @@ var init_scroll = __esm({
261640
261658
 
261641
261659
  // lib/runtime/actions.ts
261642
261660
  function layerCenterIn(doc2, id3, frameId) {
261643
- const frame2 = doc2.nodes[frameId];
261661
+ const frame3 = doc2.nodes[frameId];
261644
261662
  const real = doc2.nodes[id3] ? id3 : id3.includes("::") ? id3.slice(0, id3.indexOf("::")) : id3;
261645
- if (!frame2 || !doc2.nodes[real] || frame2.width <= 0 || frame2.height <= 0) return null;
261663
+ if (!frame3 || !doc2.nodes[real] || frame3.width <= 0 || frame3.height <= 0) return null;
261646
261664
  const f2 = getWorldTransform(doc2, frameId), l = getWorldTransform(doc2, real);
261647
- return { x: (l.cx - (f2.cx - frame2.width / 2)) / frame2.width, y: (l.cy - (f2.cy - frame2.height / 2)) / frame2.height };
261665
+ return { x: (l.cx - (f2.cx - frame3.width / 2)) / frame3.width, y: (l.cy - (f2.cy - frame3.height / 2)) / frame3.height };
261648
261666
  }
261649
261667
  function begin(state, ctx2, id3, arrive) {
261650
261668
  const nodes = state.document.nodes;
@@ -262003,17 +262021,17 @@ var init_present_driver = __esm({
262003
262021
  // lib/runtime/store-adapter.ts
262004
262022
  function storePatch(prev, next2) {
262005
262023
  if (next2 === prev) return null;
262006
- const patch = {};
262007
- if (next2.document !== prev.document) patch.document = next2.document;
262008
- if (next2.screen !== prev.screen) patch.activePrototypeFrameId = next2.screen;
262009
- if (next2.overlays !== prev.overlays) patch.prototypeOverlays = next2.overlays;
262010
- if (next2.history !== prev.history) patch.prototypeHistory = next2.history;
262011
- if (next2.transition !== prev.transition) patch.prototypeTransition = next2.transition;
262012
- if (next2.playback !== prev.playback) patch.presentPlayback = next2.playback;
262013
- if (next2.varBackup !== prev.varBackup) patch.prototypeVarBackup = next2.varBackup;
262014
- if (next2.varGlides !== prev.varGlides) patch.prototypeVarGlides = next2.varGlides;
262015
- if (next2.scroll !== prev.scroll) patch.prototypeScrollState = next2.scroll;
262016
- return Object.keys(patch).length ? patch : null;
262024
+ const patch2 = {};
262025
+ if (next2.document !== prev.document) patch2.document = next2.document;
262026
+ if (next2.screen !== prev.screen) patch2.activePrototypeFrameId = next2.screen;
262027
+ if (next2.overlays !== prev.overlays) patch2.prototypeOverlays = next2.overlays;
262028
+ if (next2.history !== prev.history) patch2.prototypeHistory = next2.history;
262029
+ if (next2.transition !== prev.transition) patch2.prototypeTransition = next2.transition;
262030
+ if (next2.playback !== prev.playback) patch2.presentPlayback = next2.playback;
262031
+ if (next2.varBackup !== prev.varBackup) patch2.prototypeVarBackup = next2.varBackup;
262032
+ if (next2.varGlides !== prev.varGlides) patch2.prototypeVarGlides = next2.varGlides;
262033
+ if (next2.scroll !== prev.scroll) patch2.prototypeScrollState = next2.scroll;
262034
+ return Object.keys(patch2).length ? patch2 : null;
262017
262035
  }
262018
262036
  var runtimeOf;
262019
262037
  var init_store_adapter = __esm({
@@ -262312,7 +262330,7 @@ var init_plugin_store = __esm({
262312
262330
  setInstalled: (installed3) => set4({ installed: installed3 }),
262313
262331
  setManagerOpen: (managerOpen) => set4({ managerOpen }),
262314
262332
  upsertSession: (s) => set4((st) => ({ sessions: [...st.sessions.filter((x2) => x2.sessionId !== s.sessionId), s] })),
262315
- patchSession: (sessionId, patch) => set4((st) => ({ sessions: st.sessions.map((x2) => x2.sessionId === sessionId ? { ...x2, ...patch } : x2) })),
262333
+ patchSession: (sessionId, patch2) => set4((st) => ({ sessions: st.sessions.map((x2) => x2.sessionId === sessionId ? { ...x2, ...patch2 } : x2) })),
262316
262334
  removeSession: (sessionId) => set4((st) => ({ sessions: st.sessions.filter((x2) => x2.sessionId !== sessionId) })),
262317
262335
  toast: (message, opts = {}) => {
262318
262336
  announce(opts.source ? `${opts.source}: ${message}` : message, opts.error ? "assertive" : "polite");
@@ -262409,6 +262427,7 @@ function formatLimit(key5, max3) {
262409
262427
  var formatBytes;
262410
262428
  var init_limits2 = __esm({
262411
262429
  "lib/billing/limits.ts"() {
262430
+ "use strict";
262412
262431
  init_format();
262413
262432
  init_plans();
262414
262433
  formatBytes = formatFileSize;
@@ -270781,9 +270800,9 @@ var init_yjs = __esm({
270781
270800
  }
270782
270801
  }
270783
270802
  const nextClock = getState(store6, ownClientID);
270784
- const nextId3 = createID(ownClientID, nextClock);
270803
+ const nextId4 = createID(ownClientID, nextClock);
270785
270804
  const redoneItem = new Item(
270786
- nextId3,
270805
+ nextId4,
270787
270806
  left,
270788
270807
  left && left.lastId,
270789
270808
  right,
@@ -270792,7 +270811,7 @@ var init_yjs = __esm({
270792
270811
  item.parentSub,
270793
270812
  item.content.copy()
270794
270813
  );
270795
- item.redone = nextId3;
270814
+ item.redone = nextId4;
270796
270815
  keepItem(redoneItem, true);
270797
270816
  redoneItem.integrate(transaction, 0);
270798
270817
  return redoneItem;
@@ -272062,11 +272081,11 @@ function createReassembler(maxBytes = MAX_MESSAGE_BYTES) {
272062
272081
  let buf = null;
272063
272082
  let filled2 = 0;
272064
272083
  return {
272065
- push(frame2) {
272066
- const dec = createDecoder(frame2);
272084
+ push(frame3) {
272085
+ const dec = createDecoder(frame3);
272067
272086
  if (readVarUint(dec) !== MSG_CHUNK) {
272068
272087
  if (buf) throw new Error("Message interrupted mid-chunk");
272069
- return frame2;
272088
+ return frame3;
272070
272089
  }
272071
272090
  const total2 = readVarUint(dec);
272072
272091
  const part = readVarUint8Array(dec);
@@ -272209,7 +272228,7 @@ var init_client = __esm({
272209
272228
  send(msg) {
272210
272229
  const ws = this.ws;
272211
272230
  if (!ws || ws.readyState !== WebSocket.OPEN) return;
272212
- for (const frame2 of toFrames(msg)) ws.send(frame2);
272231
+ for (const frame3 of toFrames(msg)) ws.send(frame3);
272213
272232
  }
272214
272233
  canWrite() {
272215
272234
  return this.role === "owner" || this.role === "editor";
@@ -272841,6 +272860,96 @@ var init_binding = __esm({
272841
272860
  }
272842
272861
  });
272843
272862
 
272863
+ // lib/client/open-progress.ts
272864
+ function withDeadline(p2, ms2) {
272865
+ let timer;
272866
+ const deadline = new Promise((_, reject) => {
272867
+ timer = setTimeout(() => reject(new OpenTimeoutError()), ms2);
272868
+ });
272869
+ return Promise.race([p2, deadline]).finally(() => clearTimeout(timer));
272870
+ }
272871
+ async function trackOpen(run4, opts = {}) {
272872
+ const current4 = useOpenProgress.getState().open;
272873
+ if (current4 && !current4.error) {
272874
+ const joined = { stage: (s) => patch(current4.id, { stage: s }) };
272875
+ return run4(joined);
272876
+ }
272877
+ const id3 = nextId++;
272878
+ useOpenProgress.setState({ open: { id: id3, name: opts.name, still: opts.still, stage: "download" } });
272879
+ const handle = { stage: (s) => patch(id3, { stage: s }) };
272880
+ let result;
272881
+ try {
272882
+ result = await withDeadline(run4(handle), opts.timeoutMs ?? OPEN_TIMEOUT_MS);
272883
+ } catch (e) {
272884
+ const timedOut = e instanceof OpenTimeoutError || e instanceof Error && e.name === "TimeoutError";
272885
+ if (timedOut || (opts.showError?.(e) ?? true)) patch(id3, { error: timedOut ? "timeout" : "failed", retry: opts.retry });
272886
+ else finishOpen(id3);
272887
+ throw e;
272888
+ }
272889
+ if (opts.failed?.(result)) {
272890
+ patch(id3, { error: "failed", retry: opts.retry });
272891
+ return result;
272892
+ }
272893
+ const settling = opts.settle?.(result) ?? null;
272894
+ if (!settling) {
272895
+ finishOpen(id3);
272896
+ return result;
272897
+ }
272898
+ handle.stage("first-frame");
272899
+ void withDeadline(Promise.resolve(settling), FIRST_FRAME_CAP_MS).catch(() => {
272900
+ }).then(() => finishOpen(id3));
272901
+ return result;
272902
+ }
272903
+ function finishOpen(id3) {
272904
+ useOpenProgress.setState((s) => s.open?.id === id3 && !s.open.error ? { open: null } : s);
272905
+ }
272906
+ function reportOpenStage(stage) {
272907
+ const open4 = useOpenProgress.getState().open;
272908
+ if (open4 && !open4.error) patch(open4.id, { stage });
272909
+ }
272910
+ var useOpenProgress, OPEN_TIMEOUT_MS, FIRST_FRAME_CAP_MS, OpenTimeoutError, nextId, patch;
272911
+ var init_open_progress = __esm({
272912
+ "lib/client/open-progress.ts"() {
272913
+ init_esm();
272914
+ useOpenProgress = create2(() => ({ open: null }));
272915
+ OPEN_TIMEOUT_MS = 45e3;
272916
+ FIRST_FRAME_CAP_MS = 2e4;
272917
+ OpenTimeoutError = class extends Error {
272918
+ constructor() {
272919
+ super("Opening took too long");
272920
+ this.name = "OpenTimeoutError";
272921
+ }
272922
+ };
272923
+ nextId = 1;
272924
+ patch = (id3, p2) => useOpenProgress.setState((s) => s.open?.id === id3 ? { open: { ...s.open, ...p2 } } : s);
272925
+ }
272926
+ });
272927
+
272928
+ // lib/client/first-frame.ts
272929
+ async function firstFrameOf(docId) {
272930
+ if (useEditorStore.getState().document.id !== docId) {
272931
+ await new Promise((resolve7) => {
272932
+ const stop2 = useEditorStore.subscribe((s) => {
272933
+ if (s.document.id === docId) {
272934
+ stop2();
272935
+ resolve7();
272936
+ }
272937
+ });
272938
+ });
272939
+ }
272940
+ await frame();
272941
+ await frame();
272942
+ await loadsSettled(6e3);
272943
+ }
272944
+ var frame;
272945
+ var init_first_frame = __esm({
272946
+ "lib/client/first-frame.ts"() {
272947
+ init_editor_store();
272948
+ init_readiness();
272949
+ frame = () => new Promise((r) => typeof requestAnimationFrame === "undefined" ? setTimeout(r, 16) : requestAnimationFrame(() => r()));
272950
+ }
272951
+ });
272952
+
272844
272953
  // lib/storage/media-refs.ts
272845
272954
  function mediaHashes(value3) {
272846
272955
  const text = JSON.stringify(value3);
@@ -272985,6 +273094,8 @@ var init_capture = __esm({
272985
273094
  // lib/templates/use.ts
272986
273095
  var use_exports = {};
272987
273096
  __export(use_exports, {
273097
+ MEDIA_FETCH_TIMEOUT_MS: () => MEDIA_FETCH_TIMEOUT_MS2,
273098
+ PREPARE_BUDGET_MS: () => PREPARE_BUDGET_MS,
272988
273099
  ensureTemplateFonts: () => ensureTemplateFonts,
272989
273100
  ensureTemplateMedia: () => ensureTemplateMedia,
272990
273101
  prepareTemplate: () => prepareTemplate,
@@ -273000,27 +273111,33 @@ async function ensureTemplateFonts(t3) {
273000
273111
  }
273001
273112
  for (const family of fontsIn(t3.payload.nodes)) for (const w of weights.get(family) ?? [400]) ensureFontLoaded2(family, w, "normal");
273002
273113
  }
273003
- async function ensureTemplateMedia(t3) {
273004
- if (typeof window === "undefined" || !t3.payload.media.length) return;
273114
+ async function fetchOne(t3, hash3) {
273005
273115
  const { getMediaBlob: getMediaBlob2, putMedia: putMedia2 } = await Promise.resolve().then(() => (init_media_store(), media_store_exports));
273006
- await Promise.all(t3.payload.media.map(async (hash3) => {
273007
- if (await getMediaBlob2(hash3)) return;
273008
- for (const url4 of templateMediaSources(t3, hash3)) {
273009
- try {
273010
- const res = await fetch(url4, { credentials: "same-origin" });
273011
- if (res.ok) {
273012
- await putMedia2(await res.blob());
273013
- return;
273014
- }
273015
- } catch {
273116
+ if (await timeoutOf(getMediaBlob2(hash3).catch(() => null), 5e3, null)) return;
273117
+ for (const url4 of templateMediaSources(t3, hash3)) {
273118
+ try {
273119
+ const res = await fetch(url4, { credentials: "same-origin", signal: AbortSignal.timeout(MEDIA_FETCH_TIMEOUT_MS2) });
273120
+ if (res.ok) {
273121
+ await putMedia2(await res.blob());
273122
+ return;
273016
273123
  }
273124
+ } catch {
273017
273125
  }
273018
- }));
273126
+ }
273127
+ }
273128
+ async function ensureTemplateMedia(t3) {
273129
+ if (typeof window === "undefined" || !t3.payload.media.length) return;
273130
+ const queue2 = [...t3.payload.media];
273131
+ const worker2 = async () => {
273132
+ for (let h = queue2.shift(); h; h = queue2.shift()) await fetchOne(t3, h);
273133
+ };
273134
+ await Promise.all(Array.from({ length: Math.min(MEDIA_CONCURRENCY, queue2.length) }, worker2));
273019
273135
  }
273020
273136
  async function prepareTemplate(t3) {
273021
- await Promise.all([ensureTemplateFonts(t3), ensureTemplateMedia(t3)]);
273137
+ await timeoutOf(Promise.all([ensureTemplateFonts(t3), ensureTemplateMedia(t3)]).then(() => {
273138
+ }), PREPARE_BUDGET_MS, void 0);
273022
273139
  }
273023
- var templateMediaSources;
273140
+ var templateMediaSources, MEDIA_FETCH_TIMEOUT_MS2, PREPARE_BUDGET_MS, MEDIA_CONCURRENCY, timeoutOf;
273024
273141
  var init_use = __esm({
273025
273142
  "lib/templates/use.ts"() {
273026
273143
  "use strict";
@@ -273029,6 +273146,15 @@ var init_use = __esm({
273029
273146
  `/templates/media/${hash3}`,
273030
273147
  ...t3.meta.source !== "builtin" && t3.meta.id && !t3.meta.id.startsWith("user-") ? [`/api/templates/${encodeURIComponent(t3.meta.id)}/media/${hash3}`] : []
273031
273148
  ];
273149
+ MEDIA_FETCH_TIMEOUT_MS2 = 15e3;
273150
+ PREPARE_BUDGET_MS = 2e4;
273151
+ MEDIA_CONCURRENCY = 4;
273152
+ timeoutOf = (p2, ms2, fallback2) => {
273153
+ let timer;
273154
+ return Promise.race([p2, new Promise((r) => {
273155
+ timer = setTimeout(() => r(fallback2), ms2);
273156
+ })]).finally(() => clearTimeout(timer));
273157
+ };
273032
273158
  }
273033
273159
  });
273034
273160
 
@@ -288143,11 +288269,11 @@ var init_flac_demuxer = __esm({
288143
288269
  assert2(this.lastLoadedPos !== null);
288144
288270
  assert2(this.audioInfo);
288145
288271
  const startPos = this.lastLoadedPos;
288146
- const frame2 = await this.readNextFlacFrame({
288272
+ const frame3 = await this.readNextFlacFrame({
288147
288273
  startPos,
288148
288274
  isFirstPacket: this.loadedSamples.length === 0
288149
288275
  });
288150
- if (!frame2) {
288276
+ if (!frame3) {
288151
288277
  this.lastSampleLoaded = true;
288152
288278
  return;
288153
288279
  }
@@ -288155,13 +288281,13 @@ var init_flac_demuxer = __esm({
288155
288281
  const blockOffset = lastSample ? lastSample.blockOffset + lastSample.blockSize : 0;
288156
288282
  const sample = {
288157
288283
  blockOffset,
288158
- blockSize: frame2.blockSize,
288284
+ blockSize: frame3.blockSize,
288159
288285
  byteOffset: startPos,
288160
- byteSize: frame2.size
288286
+ byteSize: frame3.size
288161
288287
  };
288162
- this.lastLoadedPos = this.lastLoadedPos + frame2.size;
288288
+ this.lastLoadedPos = this.lastLoadedPos + frame3.size;
288163
288289
  this.loadedSamples.push(sample);
288164
- if (frame2.isLastFrame) {
288290
+ if (frame3.isLastFrame) {
288165
288291
  this.lastSampleLoaded = true;
288166
288292
  return;
288167
288293
  }
@@ -296171,14 +296297,14 @@ var init_encode = __esm({
296171
296297
  });
296172
296298
  encoder.configure(config2);
296173
296299
  const frameData = new Uint8Array(width * height * 4);
296174
- const frame2 = new VideoFrame(frameData, {
296300
+ const frame3 = new VideoFrame(frameData, {
296175
296301
  format: "RGBA",
296176
296302
  codedWidth: width,
296177
296303
  codedHeight: height,
296178
296304
  timestamp: 0
296179
296305
  });
296180
- encoder.encode(frame2, quantizer !== null ? buildQuantizerEncodeOptions(codec2, quantizer) : void 0);
296181
- frame2.close();
296306
+ encoder.encode(frame3, quantizer !== null ? buildQuantizerEncodeOptions(codec2, quantizer) : void 0);
296307
+ frame3.close();
296182
296308
  await encoder.flush();
296183
296309
  resolve7(true);
296184
296310
  } catch {
@@ -298589,30 +298715,30 @@ var init_id3 = __esm({
298589
298715
  }
298590
298716
  }
298591
298717
  while (reader.pos <= reader.bytes.length - reader.frameHeaderSize()) {
298592
- const frame2 = reader.readId3V2Frame();
298593
- if (!frame2) {
298718
+ const frame3 = reader.readId3V2Frame();
298719
+ if (!frame3) {
298594
298720
  break;
298595
298721
  }
298596
298722
  const frameStartPos = reader.pos;
298597
- const frameEndPos = reader.pos + frame2.size;
298723
+ const frameEndPos = reader.pos + frame3.size;
298598
298724
  let frameEncrypted = false;
298599
298725
  let frameCompressed = false;
298600
298726
  let frameUnsynchronized = false;
298601
298727
  if (header.majorVersion === 3) {
298602
- frameEncrypted = !!(frame2.flags & 1 << 6);
298603
- frameCompressed = !!(frame2.flags & 1 << 7);
298728
+ frameEncrypted = !!(frame3.flags & 1 << 6);
298729
+ frameCompressed = !!(frame3.flags & 1 << 7);
298604
298730
  } else if (header.majorVersion === 4) {
298605
- frameEncrypted = !!(frame2.flags & 1 << 2);
298606
- frameCompressed = !!(frame2.flags & 1 << 3);
298607
- frameUnsynchronized = !!(frame2.flags & 1 << 1) || !!(header.flags & Id3V2HeaderFlags.Unsynchronisation);
298731
+ frameEncrypted = !!(frame3.flags & 1 << 2);
298732
+ frameCompressed = !!(frame3.flags & 1 << 3);
298733
+ frameUnsynchronized = !!(frame3.flags & 1 << 1) || !!(header.flags & Id3V2HeaderFlags.Unsynchronisation);
298608
298734
  }
298609
298735
  if (frameEncrypted) {
298610
- Logging._warn(`Skipping encrypted ID3v2 frame ${frame2.id}`);
298736
+ Logging._warn(`Skipping encrypted ID3v2 frame ${frame3.id}`);
298611
298737
  reader.pos = frameEndPos;
298612
298738
  continue;
298613
298739
  }
298614
298740
  if (frameCompressed) {
298615
- Logging._warn(`Skipping compressed ID3v2 frame ${frame2.id}`);
298741
+ Logging._warn(`Skipping compressed ID3v2 frame ${frame3.id}`);
298616
298742
  reader.pos = frameEndPos;
298617
298743
  continue;
298618
298744
  }
@@ -298620,19 +298746,19 @@ var init_id3 = __esm({
298620
298746
  reader.ununsynchronizeRegion(reader.pos, frameEndPos);
298621
298747
  }
298622
298748
  tags.raw ??= {};
298623
- if (frame2.id === "TXXX") {
298749
+ if (frame3.id === "TXXX") {
298624
298750
  const txxx = tags.raw["TXXX"] ??= {};
298625
298751
  const encoding = reader.readId3V2TextEncoding();
298626
298752
  const description = reader.readId3V2Text(encoding, frameEndPos);
298627
298753
  const value3 = reader.readId3V2Text(encoding, frameEndPos);
298628
298754
  txxx[description] ??= value3;
298629
- } else if (frame2.id[0] === "T") {
298630
- tags.raw[frame2.id] ??= reader.readId3V2EncodingAndText(frameEndPos);
298755
+ } else if (frame3.id[0] === "T") {
298756
+ tags.raw[frame3.id] ??= reader.readId3V2EncodingAndText(frameEndPos);
298631
298757
  } else {
298632
- tags.raw[frame2.id] ??= reader.readBytes(frame2.size);
298758
+ tags.raw[frame3.id] ??= reader.readBytes(frame3.size);
298633
298759
  }
298634
298760
  reader.pos = frameStartPos;
298635
- switch (frame2.id) {
298761
+ switch (frame3.id) {
298636
298762
  case "TIT2":
298637
298763
  case "TT2":
298638
298764
  {
@@ -298807,7 +298933,7 @@ var init_id3 = __esm({
298807
298933
  break;
298808
298934
  default:
298809
298935
  {
298810
- reader.pos += frame2.size;
298936
+ reader.pos += frame3.size;
298811
298937
  }
298812
298938
  ;
298813
298939
  break;
@@ -298918,8 +299044,8 @@ var init_id3 = __esm({
298918
299044
  }
298919
299045
  if (nextPos <= this.bytes.length - this.frameHeaderSize()) {
298920
299046
  this.pos += size7;
298921
- const nextId3 = this.readAscii(4);
298922
- if (nextId3 !== "\0\0\0\0" && !/[0-9A-Z]{4}/.test(nextId3)) {
299047
+ const nextId4 = this.readAscii(4);
299048
+ if (nextId4 !== "\0\0\0\0" && !/[0-9A-Z]{4}/.test(nextId4)) {
298923
299049
  return false;
298924
299050
  }
298925
299051
  }
@@ -304773,8 +304899,8 @@ var init_media_source = __esm({
304773
304899
  const { numberOfChannels, numberOfFrames, sampleRate, timestamp } = audioSample;
304774
304900
  const CHUNK_SIZE = 2048;
304775
304901
  const outputs = [];
304776
- for (let frame2 = 0; frame2 < numberOfFrames; frame2 += CHUNK_SIZE) {
304777
- const frameCount2 = Math.min(CHUNK_SIZE, audioSample.numberOfFrames - frame2);
304902
+ for (let frame3 = 0; frame3 < numberOfFrames; frame3 += CHUNK_SIZE) {
304903
+ const frameCount2 = Math.min(CHUNK_SIZE, audioSample.numberOfFrames - frame3);
304778
304904
  const outputSize2 = frameCount2 * numberOfChannels * this.outputSampleSize;
304779
304905
  const outputBuffer = new ArrayBuffer(outputSize2);
304780
304906
  const outputView = new DataView(outputBuffer);
@@ -306088,9 +306214,9 @@ async function measure2(codec2, sampleRate, numberOfChannels) {
306088
306214
  const total2 = PROBE + MAX_LAG + 2048;
306089
306215
  const data = new Float32Array(total2 * numberOfChannels);
306090
306216
  for (let ch = 0; ch < numberOfChannels; ch++) data.set(signal, ch * total2);
306091
- const frame2 = new AudioData({ format: "f32-planar", sampleRate, numberOfFrames: total2, numberOfChannels, timestamp: 0, data });
306092
- enc2.encode(frame2);
306093
- frame2.close();
306217
+ const frame3 = new AudioData({ format: "f32-planar", sampleRate, numberOfFrames: total2, numberOfChannels, timestamp: 0, data });
306218
+ enc2.encode(frame3);
306219
+ frame3.close();
306094
306220
  await enc2.flush();
306095
306221
  enc2.close();
306096
306222
  if (failed2 || !config2) throw failed2 ?? new Error("no decoder config");
@@ -308978,7 +309104,7 @@ function viaWorker(channels, sampleRate) {
308978
309104
  };
308979
309105
  worker.onmessageerror = () => breakWorker("the analysis worker sent something that could not be read");
308980
309106
  }
308981
- const id3 = nextId++;
309107
+ const id3 = nextId2++;
308982
309108
  const answer2 = new Promise((resolve7, reject) => {
308983
309109
  waiting.set(id3, { resolve: resolve7, reject });
308984
309110
  worker.postMessage({ id: id3, channels: channels.map((c2) => c2.slice()), sampleRate });
@@ -309047,7 +309173,7 @@ async function ensureAnalyses(sound) {
309047
309173
  const hashes = new Set(sound.filter((c2) => !c2.muted).map((c2) => c2.mediaHash));
309048
309174
  await Promise.all([...hashes].map((h) => loadAnalysis(h)));
309049
309175
  }
309050
- var pending5, failed, RETRY_MS3, now, WORKER_TIMEOUT_MS, worker, workerBroken, nextId, waiting, warned;
309176
+ var pending5, failed, RETRY_MS3, now, WORKER_TIMEOUT_MS, worker, workerBroken, nextId2, waiting, warned;
309051
309177
  var init_audio_analysis_store = __esm({
309052
309178
  "lib/motion/audio-analysis-store.ts"() {
309053
309179
  "use strict";
@@ -309062,7 +309188,7 @@ var init_audio_analysis_store = __esm({
309062
309188
  WORKER_TIMEOUT_MS = 2e4;
309063
309189
  worker = null;
309064
309190
  workerBroken = false;
309065
- nextId = 1;
309191
+ nextId2 = 1;
309066
309192
  waiting = /* @__PURE__ */ new Map();
309067
309193
  warned = /* @__PURE__ */ new Set();
309068
309194
  if (typeof window !== "undefined") {
@@ -310449,28 +310575,28 @@ async function renderTemplateDetail(node2, doc2) {
310449
310575
  if (!img?.width || !img?.height) return null;
310450
310576
  return { bytes: thumbnailWebp(img), type: DETAIL_TYPE, width: img.width, height: img.height };
310451
310577
  }
310452
- async function render(frame2, doc2) {
310453
- const bytes2 = await renderThumbnailJpeg(frame2, doc2);
310578
+ async function render(frame3, doc2) {
310579
+ const bytes2 = await renderThumbnailJpeg(frame3, doc2);
310454
310580
  return bytes2 ? URL.createObjectURL(new Blob([bytes2], { type: "image/jpeg" })) : null;
310455
310581
  }
310456
- function usePageThumbnail(frame2, doc2) {
310457
- const cached3 = cache8.get(frame2);
310582
+ function usePageThumbnail(frame3, doc2) {
310583
+ const cached3 = cache8.get(frame3);
310458
310584
  const [url4, setUrl] = (0, import_react4.useState)(cached3?.url ?? null);
310459
310585
  (0, import_react4.useEffect)(() => {
310460
310586
  let cancelled = false;
310461
- const hit = cache8.get(frame2);
310587
+ const hit = cache8.get(frame3);
310462
310588
  if (hit && hit.doc === doc2) {
310463
310589
  setUrl(hit.url);
310464
310590
  return;
310465
310591
  }
310466
310592
  const run4 = async () => {
310467
- const next2 = await render(frame2, doc2);
310593
+ const next2 = await render(frame3, doc2);
310468
310594
  if (cancelled) {
310469
310595
  if (next2) URL.revokeObjectURL(next2);
310470
310596
  return;
310471
310597
  }
310472
- const prev = cache8.get(frame2)?.url;
310473
- cache8.set(frame2, { doc: doc2, url: next2 });
310598
+ const prev = cache8.get(frame3)?.url;
310599
+ cache8.set(frame3, { doc: doc2, url: next2 });
310474
310600
  if (prev && prev !== next2) URL.revokeObjectURL(prev);
310475
310601
  setUrl(next2);
310476
310602
  };
@@ -310483,7 +310609,7 @@ function usePageThumbnail(frame2, doc2) {
310483
310609
  cancelled = true;
310484
310610
  clearTimeout(timer);
310485
310611
  };
310486
- }, [frame2, doc2]);
310612
+ }, [frame3, doc2]);
310487
310613
  return url4;
310488
310614
  }
310489
310615
  var import_react4, THUMB_PX, SETTLE_MS, cache8;
@@ -310588,7 +310714,7 @@ async function deleteCloudTemplate(id3) {
310588
310714
  useCloudTemplates.setState((s) => ({ available: s.available.filter((x2) => x2.id !== id3) }));
310589
310715
  }
310590
310716
  async function fetchCloudTemplate(id3) {
310591
- const { template: template2, payload } = await api(`/api/templates/${encodeURIComponent(id3)}`, { cache: "no-store" });
310717
+ const { template: template2, payload } = await api(`/api/templates/${encodeURIComponent(id3)}`, { cache: "no-store", signal: AbortSignal.timeout(3e4) });
310592
310718
  return { meta: template2, payload };
310593
310719
  }
310594
310720
  async function searchTemplates(o = {}) {
@@ -310648,7 +310774,10 @@ async function documentFromSeed(seed2) {
310648
310774
  let template2 = seed2.template;
310649
310775
  if (!template2 && seed2.templateId) template2 = await (await Promise.resolve().then(() => (init_templates(), templates_exports))).fetchCloudTemplate(seed2.templateId);
310650
310776
  if (template2) {
310777
+ reportOpenStage("media");
310651
310778
  await prepareTemplate(template2);
310779
+ reportOpenStage("prepare");
310780
+ await new Promise((r) => setTimeout(r, 0));
310652
310781
  const doc2 = documentFromTemplate(template2, seed2.name ?? template2.meta.name, seed2.sizeId);
310653
310782
  if ((await Promise.resolve().then(() => (init_library_link(), library_link_exports))).libraryLink() !== "unlinked") return doc2;
310654
310783
  const { unlinkLibrary: unlinkLibrary2 } = await Promise.resolve().then(() => (init_libraries(), libraries_exports));
@@ -310698,6 +310827,7 @@ async function createNewCloudFile(place4 = {}, seed2 = {}) {
310698
310827
  const doc2 = await documentFromSeed(seed2);
310699
310828
  const body = { name: doc2.name, localDocId: doc2.id, workspaceId: activeTeamWorkspaceId(), pageCount: doc2.pages.length, ...place4 };
310700
310829
  let key5;
310830
+ reportOpenStage("create");
310701
310831
  try {
310702
310832
  ;
310703
310833
  ({ key: key5 } = await cloudApi.createFile(body));
@@ -310725,7 +310855,8 @@ function countTemplateUse(id3) {
310725
310855
  }
310726
310856
  async function createNewFileOrExplain(place4 = {}, seed2 = {}) {
310727
310857
  const result = await createNewFile(place4, seed2);
310728
- if (!result.ok && result.reason !== "plan") reportNewFileBlocked(result.reason);
310858
+ const loaderShows = result.ok === false && result.reason === "failed" && !!useOpenProgress.getState().open;
310859
+ if (!result.ok && result.reason !== "plan" && !loaderShows) reportNewFileBlocked(result.reason);
310729
310860
  return result;
310730
310861
  }
310731
310862
  async function createFreshFileOrExplain(place4 = {}, seed2 = {}) {
@@ -310744,6 +310875,7 @@ var init_new_file = __esm({
310744
310875
  init_page_presets();
310745
310876
  init_apply2();
310746
310877
  init_use();
310878
+ init_open_progress();
310747
310879
  init_editor_store();
310748
310880
  init_document_library();
310749
310881
  init_tab_mode();
@@ -310961,7 +311093,17 @@ async function openCloudFile(key5, opts = {}) {
310961
311093
  const run4 = (async () => {
310962
311094
  opening++;
310963
311095
  try {
310964
- await loadCloudFile(key5, opts);
311096
+ await trackOpen(async () => {
311097
+ await loadCloudFile(key5, opts);
311098
+ }, {
311099
+ retry: () => {
311100
+ void openCloudFile(key5, opts).catch(() => {
311101
+ });
311102
+ },
311103
+ // A refusal or a failed request: the file's page explains it (sign in, ask the owner). A timeout is the loader's.
311104
+ showError: () => false,
311105
+ settle: () => firstFrameOf(useEditorStore.getState().document.id)
311106
+ });
310965
311107
  } finally {
310966
311108
  opening--;
310967
311109
  }
@@ -310990,6 +311132,7 @@ async function loadCloudFile(key5, opts) {
310990
311132
  fetch(`/api/files/${key5}/snapshot`, { headers: { ...await authHeaders(), ...haveLocal ? { "x-have-snapshot-version": String(existing.version) } : {} } })
310991
311133
  ]);
310992
311134
  if (!res.ok) throw new ApiError(res.status, "Could not load file", "load_failed");
311135
+ reportOpenStage("open");
310993
311136
  const version7 = Number(res.headers.get("x-snapshot-version") ?? "0");
310994
311137
  if (res.status === 204 && haveLocal) {
310995
311138
  await useEditorStore.getState().openDocument(existing.docId);
@@ -311279,6 +311422,7 @@ function startCloudSync() {
311279
311422
  var status, readOnlyDoc, activeLink, statusListeners, notice, urlArmed, opening, syncStatus, canEdit, uploaded, MEDIA_UPLOAD_PARALLEL, pushTimer, pushing, dirty, pendingMedia, collab, collabSession, collabAnonymous, uploadedThumbs, thumbCheckedAt, THUMB_EVERY_MS, THUMB_MIN_GAP_MS, putThumbnail, openingFiles, mediaHealed, started2;
311280
311423
  var init_sync2 = __esm({
311281
311424
  "lib/client/cloud/sync.ts"() {
311425
+ "use strict";
311282
311426
  init_paint_repair();
311283
311427
  init_migrate();
311284
311428
  init_view();
@@ -311295,6 +311439,8 @@ var init_sync2 = __esm({
311295
311439
  init_private();
311296
311440
  init_tab_mode();
311297
311441
  init_editor_store();
311442
+ init_open_progress();
311443
+ init_first_frame();
311298
311444
  init_new_file();
311299
311445
  init_new_file_block();
311300
311446
  init_dist_node();
@@ -311738,8 +311884,8 @@ function tagFrameOrder(node2, tag2) {
311738
311884
  if (tag2.direction === "REVERSE") return fwd.reverse();
311739
311885
  return fwd.length > 2 ? [...fwd, ...fwd.slice(1, -1).reverse()] : fwd;
311740
311886
  }
311741
- function pixelFrameSVGBody(node2, frame2) {
311742
- const rgba = frameRGBA2(node2, frame2);
311887
+ function pixelFrameSVGBody(node2, frame3) {
311888
+ const rgba = frameRGBA2(node2, frame3);
311743
311889
  const cw = node2.width / node2.pixelWidth, ch = node2.height / node2.pixelHeight;
311744
311890
  const parts = [];
311745
311891
  for (const r of mergeRects(rgba, node2.pixelWidth, node2.pixelHeight)) {
@@ -311749,12 +311895,12 @@ function pixelFrameSVGBody(node2, frame2) {
311749
311895
  }
311750
311896
  return `<g shape-rendering="crispEdges">${parts.join("")}</g>`;
311751
311897
  }
311752
- function pixelFrameSVG(node2, frame2) {
311753
- return `<svg xmlns="http://www.w3.org/2000/svg" width="${fmt(node2.width)}" height="${fmt(node2.height)}" viewBox="0 0 ${fmt(node2.width)} ${fmt(node2.height)}">${pixelFrameSVGBody(node2, frame2)}</svg>`;
311898
+ function pixelFrameSVG(node2, frame3) {
311899
+ return `<svg xmlns="http://www.w3.org/2000/svg" width="${fmt(node2.width)}" height="${fmt(node2.height)}" viewBox="0 0 ${fmt(node2.width)} ${fmt(node2.height)}">${pixelFrameSVGBody(node2, frame3)}</svg>`;
311754
311900
  }
311755
- async function pixelFramePNG(node2, frame2, scale = 1) {
311901
+ async function pixelFramePNG(node2, frame3, scale = 1) {
311756
311902
  const s = Math.max(1, Math.round(scale));
311757
- return pngBlob(scaleRGBA(frameRGBA2(node2, frame2), node2.pixelWidth, node2.pixelHeight, s), node2.pixelWidth * s, node2.pixelHeight * s);
311903
+ return pngBlob(scaleRGBA(frameRGBA2(node2, frame3), node2.pixelWidth, node2.pixelHeight, s), node2.pixelWidth * s, node2.pixelHeight * s);
311758
311904
  }
311759
311905
  function spriteSheetLayout(node2, layout2, scale, imageName) {
311760
311906
  const s = Math.max(1, Math.round(scale));
@@ -311859,7 +312005,7 @@ var init_pixel_export = __esm({
311859
312005
  init_pixel_layers();
311860
312006
  init_cells();
311861
312007
  init_algorithms();
311862
- frameRGBA2 = (node2, frame2) => withPixelLayers(frameRGBA(node2, frame2), getPixelLayers(node2, frame2));
312008
+ frameRGBA2 = (node2, frame3) => withPixelLayers(frameRGBA(node2, frame3), getPixelLayers(node2, frame3));
311863
312009
  fmt = (v) => (Math.round(v * 1e3) / 1e3).toString();
311864
312010
  pngBlob = async (bytes2, w, h) => new Blob([await encodePng(w, h, bytes2)], { type: "image/png" });
311865
312011
  }
@@ -316926,17 +317072,17 @@ async function runPixelExport(node2, setting, doc2) {
316926
317072
  const grid = node2;
316927
317073
  const px5 = await Promise.resolve().then(() => (init_pixel_export(), pixel_export_exports));
316928
317074
  const layers2 = await Promise.resolve().then(() => (init_pixel_layers(), pixel_layers_exports));
316929
- const frame2 = Math.max(0, Math.min(grid.frames.length - 1, grid.activeFrame || 0));
317075
+ const frame3 = Math.max(0, Math.min(grid.frames.length - 1, grid.activeFrame || 0));
316930
317076
  const scale = Math.max(1, Math.round(setting.scale || 1));
316931
317077
  const name2 = exportFilename(node2, setting);
316932
317078
  switch (setting.format) {
316933
317079
  case "PNG":
316934
- await layers2.ensurePixelLayers(grid, doc2, frame2);
316935
- downloadBlob(await px5.pixelFramePNG(grid, frame2, scale), name2);
317080
+ await layers2.ensurePixelLayers(grid, doc2, frame3);
317081
+ downloadBlob(await px5.pixelFramePNG(grid, frame3, scale), name2);
316936
317082
  return true;
316937
317083
  case "SVG":
316938
- await layers2.ensurePixelLayers(grid, doc2, frame2);
316939
- downloadBlob(new Blob([px5.pixelFrameSVG(grid, frame2)], { type: "image/svg+xml" }), name2);
317084
+ await layers2.ensurePixelLayers(grid, doc2, frame3);
317085
+ downloadBlob(new Blob([px5.pixelFrameSVG(grid, frame3)], { type: "image/svg+xml" }), name2);
316940
317086
  return true;
316941
317087
  case "GIF": {
316942
317088
  await layers2.ensureAllPixelLayers(grid, doc2);
@@ -317738,9 +317884,9 @@ async function generateVideoFile(req, opts = {}) {
317738
317884
  if (req.startFrameIds?.length) {
317739
317885
  if (!model.startImage) throw new AiClientError(`${model.label} can\u2019t start from an image. Pick a Seedance or Veo 3.1 Fast model, or turn the start frame off.`, "bad_request", 0);
317740
317886
  if (!req.doc) throw new AiClientError("The start frame needs the document.", "not_ready", 0);
317741
- const frame2 = await renderStartFrame(req.doc, req.startFrameIds);
317742
- if (!frame2) throw new AiClientError("Could not render the start frame \u2014 the canvas may not be ready, or the layers have no visible area.", "not_ready", 0);
317743
- image = frame2;
317887
+ const frame3 = await renderStartFrame(req.doc, req.startFrameIds);
317888
+ if (!frame3) throw new AiClientError("Could not render the start frame \u2014 the canvas may not be ready, or the layers have no visible area.", "not_ready", 0);
317889
+ image = frame3;
317744
317890
  }
317745
317891
  const result = await requestVideo({
317746
317892
  model: model.id,
@@ -317813,9 +317959,9 @@ async function renderDocument(doc2, nodeIds, options) {
317813
317959
  if (options?.at !== void 0) {
317814
317960
  const { bakeMotion: bakeMotion3 } = await Promise.resolve().then(() => (init_pose(), pose_exports));
317815
317961
  for (const id3 of nodeIds) {
317816
- let frame2 = doc2.nodes[id3];
317817
- while (frame2 && !frame2.timeline && frame2.parentId && doc2.nodes[frame2.parentId]?.type !== "PAGE") frame2 = doc2.nodes[frame2.parentId];
317818
- if (frame2) doc2 = { ...doc2, nodes: bakeMotion3(doc2.nodes, frame2.id, options.at) };
317962
+ let frame3 = doc2.nodes[id3];
317963
+ while (frame3 && !frame3.timeline && frame3.parentId && doc2.nodes[frame3.parentId]?.type !== "PAGE") frame3 = doc2.nodes[frame3.parentId];
317964
+ if (frame3) doc2 = { ...doc2, nodes: bakeMotion3(doc2.nodes, frame3.id, options.at) };
317819
317965
  }
317820
317966
  }
317821
317967
  return selectionReferenceImages2(doc2, [...nodeIds], { maxEdge: options?.maxEdge, max: 8, format: "JPG", ...options?.bands ? { bands: options.bands } : {} });
@@ -317941,7 +318087,6 @@ function agentToolList() {
317941
318087
  var AGENT_CAPABILITIES, legacyCommandId, legacyTools, blobToDataUrl3, provided, legacyTool, legacyToolList;
317942
318088
  var init_agent = __esm({
317943
318089
  "lib/commands/agent.ts"() {
317944
- "use strict";
317945
318090
  init_types5();
317946
318091
  init_registry();
317947
318092
  init_errors();
@@ -318175,7 +318320,7 @@ function bbox2(boxes) {
318175
318320
  const maxX = Math.max(...boxes.map((b) => b.x + b.width)), maxY = Math.max(...boxes.map((b) => b.y + b.height));
318176
318321
  return { x: minX, y: minY, width: maxX - minX, height: maxY - minY };
318177
318322
  }
318178
- function inferAutoLayout(frame2, children) {
318323
+ function inferAutoLayout(frame3, children) {
318179
318324
  const kids = children.filter((c3) => c3.width >= 0 && c3.height >= 0);
318180
318325
  const empty2 = {
318181
318326
  layoutMode: "VERTICAL",
@@ -318195,7 +318340,7 @@ function inferAutoLayout(frame2, children) {
318195
318340
  const sepV = separation(kids, "VERTICAL");
318196
318341
  const sepH = separation(kids, "HORIZONTAL");
318197
318342
  let dir;
318198
- if (kids.length === 1) dir = frame2.width > frame2.height ? "HORIZONTAL" : "VERTICAL";
318343
+ if (kids.length === 1) dir = frame3.width > frame3.height ? "HORIZONTAL" : "VERTICAL";
318199
318344
  else if (rowsV.length !== colsH.length) dir = rowsV.length > colsH.length ? "VERTICAL" : "HORIZONTAL";
318200
318345
  else if (Math.abs(sepV - sepH) > 0.01) dir = sepV > sepH ? "VERTICAL" : "HORIZONTAL";
318201
318346
  else {
@@ -318227,8 +318372,8 @@ function inferAutoLayout(frame2, children) {
318227
318372
  const padding3 = {
318228
318373
  top: Math.max(0, Math.round(bb.y)),
318229
318374
  left: Math.max(0, Math.round(bb.x)),
318230
- bottom: Math.max(0, Math.round(frame2.height - (bb.y + bb.height))),
318231
- right: Math.max(0, Math.round(frame2.width - (bb.x + bb.width)))
318375
+ bottom: Math.max(0, Math.round(frame3.height - (bb.y + bb.height))),
318376
+ right: Math.max(0, Math.round(frame3.width - (bb.x + bb.width)))
318232
318377
  };
318233
318378
  const before = dir === "HORIZONTAL" ? padding3.left : padding3.top;
318234
318379
  const after = dir === "HORIZONTAL" ? padding3.right : padding3.bottom;
@@ -318270,7 +318415,7 @@ function applyLayoutSuggestion(doc2, nodeId2, s) {
318270
318415
  const nodes = { ...doc2.nodes };
318271
318416
  let host = original;
318272
318417
  if (host.type === "GROUP") {
318273
- const frame2 = createFrame({
318418
+ const frame3 = createFrame({
318274
318419
  id: host.id,
318275
318420
  name: host.name,
318276
318421
  x: host.x,
@@ -318287,7 +318432,7 @@ function applyLayoutSuggestion(doc2, nodeId2, s) {
318287
318432
  backgroundColor: { r: 1, g: 1, b: 1, a: 0 },
318288
318433
  clipsContent: false
318289
318434
  });
318290
- host = frame2;
318435
+ host = frame3;
318291
318436
  }
318292
318437
  const flow = new Set(flowChildren(doc2, host).map((c2) => c2.id));
318293
318438
  const rest = host.childIds.filter((id3) => !flow.has(id3));
@@ -318433,8 +318578,8 @@ function applyOverride(doc2, virtualId, props) {
318433
318578
  }
318434
318579
  function commitUpdates(ctx2, doc2, updates) {
318435
318580
  let next2 = doc2;
318436
- for (const [id3, patch] of updates) {
318437
- next2 = isVirtualId2(id3) ? applyOverride(next2, id3, patch) : updateNode(next2, id3, patch);
318581
+ for (const [id3, patch2] of updates) {
318582
+ next2 = isVirtualId2(id3) ? applyOverride(next2, id3, patch2) : updateNode(next2, id3, patch2);
318438
318583
  }
318439
318584
  next2 = applyInvariants(next2, updates.keys());
318440
318585
  ctx2.commit(next2);
@@ -318708,14 +318853,14 @@ function isSvgMarkup(text) {
318708
318853
  }
318709
318854
  function placeSvgLayers(doc2, parentId, svg, place4) {
318710
318855
  if (!doc2.nodes[parentId] || svg.length > MAX_SVG_LAYER_BYTES) return null;
318711
- const frame2 = createFrame({ name: place4.name, x: place4.cx, y: place4.cy, width: 1, height: 1, fills: [], backgroundColor: { r: 1, g: 1, b: 1, a: 0 }, clipsContent: false });
318712
- let next2 = addNode(doc2, frame2, parentId);
318856
+ const frame3 = createFrame({ name: place4.name, x: place4.cx, y: place4.cy, width: 1, height: 1, fills: [], backgroundColor: { r: 1, g: 1, b: 1, a: 0 }, clipsContent: false });
318857
+ let next2 = addNode(doc2, frame3, parentId);
318713
318858
  try {
318714
- next2 = importSVG(svg, next2, frame2.id);
318859
+ next2 = importSVG(svg, next2, frame3.id);
318715
318860
  } catch {
318716
318861
  return null;
318717
318862
  }
318718
- const kids = next2.nodes[frame2.id].childIds.map((id3) => next2.nodes[id3]).filter(Boolean);
318863
+ const kids = next2.nodes[frame3.id].childIds.map((id3) => next2.nodes[id3]).filter(Boolean);
318719
318864
  if (!kids.length) return null;
318720
318865
  const nodes = { ...next2.nodes };
318721
318866
  if (place4.intern) {
@@ -318728,8 +318873,8 @@ function placeSvgLayers(doc2, parentId, svg, place4) {
318728
318873
  const maxX = Math.max(...kids.map((k2) => k2.x + k2.width)), maxY = Math.max(...kids.map((k2) => k2.y + k2.height));
318729
318874
  for (const k2 of kids) nodes[k2.id] = { ...nodes[k2.id], x: k2.x - minX, y: k2.y - minY };
318730
318875
  const w = Math.max(1, maxX - minX), h = Math.max(1, maxY - minY);
318731
- nodes[frame2.id] = { ...nodes[frame2.id], x: Math.round(place4.cx - w / 2), y: Math.round(place4.cy - h / 2), width: w, height: h };
318732
- return { doc: { ...next2, nodes }, id: frame2.id };
318876
+ nodes[frame3.id] = { ...nodes[frame3.id], x: Math.round(place4.cx - w / 2), y: Math.round(place4.cy - h / 2), width: w, height: h };
318877
+ return { doc: { ...next2, nodes }, id: frame3.id };
318733
318878
  }
318734
318879
  var MAX_SVG_LAYER_BYTES;
318735
318880
  var init_svg_place = __esm({
@@ -319095,15 +319240,15 @@ var init_node = __esm({
319095
319240
  const changedKeys = /* @__PURE__ */ new Set();
319096
319241
  for (const u of args2.updates) {
319097
319242
  resolvedNodeOrThrow(doc2, u.id);
319098
- const patch = {};
319243
+ const patch2 = {};
319099
319244
  for (const [k2, v] of Object.entries(u.props)) {
319100
319245
  if (args2.strict && FORBIDDEN_PROPS.has(k2)) throw new ToolError(`update_nodes cannot change "${k2}". Use reparent, delete_nodes or create_node instead.`);
319101
319246
  if (FORBIDDEN_PROPS.has(k2) || v === void 0) continue;
319102
- patch[k2] = v;
319247
+ patch2[k2] = v;
319103
319248
  changedKeys.add(k2);
319104
319249
  }
319105
- if (args2.strict && !Object.keys(patch).length) throw new ToolError(`No properties given for "${u.id}".`);
319106
- patches.set(u.id, patch);
319250
+ if (args2.strict && !Object.keys(patch2).length) throw new ToolError(`No properties given for "${u.id}".`);
319251
+ patches.set(u.id, patch2);
319107
319252
  }
319108
319253
  commitUpdates(ctx2, doc2, patches);
319109
319254
  return { summary: `Updated ${plural2(patches.size, "layer")} (${[...changedKeys].slice(0, 6).join(", ")})`, data: { ids: [...patches.keys()] } };
@@ -319804,7 +319949,7 @@ var init_node = __esm({
319804
319949
 
319805
319950
  // lib/commands/text.ts
319806
319951
  function applyTypeStyle(node2, styles) {
319807
- const patch = { ...styles };
319952
+ const patch2 = { ...styles };
319808
319953
  const segments = node2.styledSegments;
319809
319954
  if (segments?.length) {
319810
319955
  const keys4 = Object.keys(styles);
@@ -319813,9 +319958,9 @@ function applyTypeStyle(node2, styles) {
319813
319958
  for (const k2 of keys4) delete next2[k2];
319814
319959
  return next2;
319815
319960
  }).filter((seg) => Object.keys(seg).length > 2);
319816
- patch.styledSegments = stripped;
319961
+ patch2.styledSegments = stripped;
319817
319962
  }
319818
- return patch;
319963
+ return patch2;
319819
319964
  }
319820
319965
  var textSet, TYPE_FIELDS, textSetTypography, textSearchFonts, textSetEffect;
319821
319966
  var init_text = __esm({
@@ -320186,8 +320331,8 @@ var init_text_path2 = __esm({
320186
320331
  if (!isClosedOutline(shape2) || shapeId === textId) throw new ToolError(`"${shape2.name}" (${shapeId}) has no closed outline to flow text into. Use an ellipse, rectangle, polygon, star, frame or a closed vector.`);
320187
320332
  const t3 = text;
320188
320333
  const area4 = { shapeId, ...args2.inset !== void 0 ? { inset: args2.inset } : t3.textArea?.inset !== void 0 ? { inset: t3.textArea.inset } : {} };
320189
- const patch = { textArea: area4, textPath: void 0, textAutoResize: "NONE", ...args2.fit ? { textFit: args2.fit } : {}, ...areaBoxPatch(doc2.nodes, t3, shapeId) };
320190
- commitUpdates(ctx2, doc2, /* @__PURE__ */ new Map([[textId, patch]]));
320334
+ const patch2 = { textArea: area4, textPath: void 0, textAutoResize: "NONE", ...args2.fit ? { textFit: args2.fit } : {}, ...areaBoxPatch(doc2.nodes, t3, shapeId) };
320335
+ commitUpdates(ctx2, doc2, /* @__PURE__ */ new Map([[textId, patch2]]));
320191
320336
  return { summary: `Flowed "${text.name}" into "${shape2.name}"`, data: { id: textId, shapeId } };
320192
320337
  }
320193
320338
  });
@@ -320550,7 +320695,7 @@ var init_paint = __esm({
320550
320695
  if (!n) continue;
320551
320696
  stack.push(...n.childIds ?? []);
320552
320697
  const rec = n;
320553
- const patch = {};
320698
+ const patch2 = {};
320554
320699
  let hit = 0;
320555
320700
  const paints = rec.fills;
320556
320701
  if (paints?.length) {
@@ -320579,7 +320724,7 @@ var init_paint = __esm({
320579
320724
  }
320580
320725
  return out;
320581
320726
  });
320582
- if (changed) patch.fills = next2;
320727
+ if (changed) patch2.fills = next2;
320583
320728
  }
320584
320729
  const strokes = rec.strokes;
320585
320730
  if (strokes?.length) {
@@ -320591,7 +320736,7 @@ var init_paint = __esm({
320591
320736
  hit++;
320592
320737
  return { ...s, color: c2 };
320593
320738
  });
320594
- if (changed) patch.strokes = next2;
320739
+ if (changed) patch2.strokes = next2;
320595
320740
  }
320596
320741
  const effects = effectsOf(n);
320597
320742
  if (effects.length) {
@@ -320605,18 +320750,18 @@ var init_paint = __esm({
320605
320750
  return { ...e, color: c2 };
320606
320751
  });
320607
320752
  if (changed) {
320608
- patch.effects = next2;
320609
- patch.shadows = void 0;
320610
- patch.blurs = void 0;
320753
+ patch2.effects = next2;
320754
+ patch2.shadows = void 0;
320755
+ patch2.blurs = void 0;
320611
320756
  }
320612
320757
  }
320613
320758
  const bg = swapColor(rec.backgroundColor);
320614
320759
  if (bg) {
320615
- patch.backgroundColor = bg;
320760
+ patch2.backgroundColor = bg;
320616
320761
  hit++;
320617
320762
  }
320618
320763
  if (hit) {
320619
- nodes[id3] = { ...n, ...patch };
320764
+ nodes[id3] = { ...n, ...patch2 };
320620
320765
  touched.push(id3);
320621
320766
  swaps += hit;
320622
320767
  }
@@ -321980,9 +322125,9 @@ function clipOr(doc2, id3, frameId) {
321980
322125
  if (!c2) throw new Error(`"${doc2.nodes[id3]?.name ?? id3}" is not a video layer.`);
321981
322126
  return c2;
321982
322127
  }
321983
- function withSound(node2, fill, patch) {
322128
+ function withSound(node2, fill, patch2) {
321984
322129
  const cur = fillsOf(node2)[fill]?.videoSound ?? { muted: true };
321985
- const next2 = { ...cur, ...patch };
322130
+ const next2 = { ...cur, ...patch2 };
321986
322131
  for (const k2 of Object.keys(next2)) if (next2[k2] === void 0) delete next2[k2];
321987
322132
  if (next2.muted === false) delete next2.muted;
321988
322133
  if (next2.offset !== void 0) {
@@ -322000,10 +322145,10 @@ function withSound(node2, fill, patch) {
322000
322145
  if (next2.fadeCurve !== "equalPower") delete next2.fadeCurve;
322001
322146
  return withVideoPaint(node2, fill, { videoSound: next2 });
322002
322147
  }
322003
- function editVideoSound(doc2, id3, frameId, patch) {
322148
+ function editVideoSound(doc2, id3, frameId, patch2) {
322004
322149
  const c2 = clipOr(doc2, id3, frameId);
322005
322150
  const len3 = c2.end - c2.start;
322006
- const p2 = { ...patch };
322151
+ const p2 = { ...patch2 };
322007
322152
  for (const k2 of ["fadeIn", "fadeOut"]) if (p2[k2] !== void 0) p2[k2] = Math.min(len3, p2[k2]);
322008
322153
  return withNode(doc2, withSound(doc2.nodes[id3], c2.fill, p2));
322009
322154
  }
@@ -322108,9 +322253,9 @@ function setVideoSpeed(doc2, id3, frameId, speed) {
322108
322253
  }
322109
322254
  return withNode(doc2, next2);
322110
322255
  }
322111
- function editVideoPaint(doc2, id3, frameId, patch) {
322256
+ function editVideoPaint(doc2, id3, frameId, patch2) {
322112
322257
  const c2 = clipOr(doc2, id3, frameId);
322113
- return withNode(doc2, withVideoPaint(doc2.nodes[id3], c2.fill, patch));
322258
+ return withNode(doc2, withVideoPaint(doc2.nodes[id3], c2.fill, patch2));
322114
322259
  }
322115
322260
  function splitVideo(doc2, id3, frameId, at4) {
322116
322261
  const c2 = clipOr(doc2, id3, frameId);
@@ -322216,7 +322361,7 @@ function crossfadeAudio(holder, aId, bId, ms2, sourceMs) {
322216
322361
  const aEnd = audioClipEnd(a);
322217
322362
  let overlap = aEnd - b.start;
322218
322363
  let next2 = holder;
322219
- const patch = (id3, p2) => {
322364
+ const patch2 = (id3, p2) => {
322220
322365
  next2 = editAudioClip(next2, id3, p2);
322221
322366
  };
322222
322367
  if (overlap < d) {
@@ -322226,13 +322371,13 @@ function crossfadeAudio(holder, aId, bId, ms2, sourceMs) {
322226
322371
  const fileLen = sourceMs?.(a.mediaHash);
322227
322372
  const tailRoom = fileLen !== void 0 ? Math.max(0, Math.floor((fileLen - a.out) / sa)) : Infinity;
322228
322373
  const tail = Math.min(need - head2, tailRoom);
322229
- if (tail > 0) patch(a.id, { out: Math.round(a.out + tail * sa) });
322230
- if (head2 > 0) patch(b.id, { start: b.start - head2, in: Math.round(b.in - head2 * sb) });
322374
+ if (tail > 0) patch2(a.id, { out: Math.round(a.out + tail * sa) });
322375
+ if (head2 > 0) patch2(b.id, { start: b.start - head2, in: Math.round(b.in - head2 * sb) });
322231
322376
  overlap = Math.max(0, overlap) + head2 + tail;
322232
322377
  }
322233
322378
  const fade = Math.max(1, Math.round(overlap));
322234
- patch(a.id, { fadeOut: fade, fadeCurve: "equalPower" });
322235
- patch(b.id, { fadeIn: fade, fadeCurve: "equalPower" });
322379
+ patch2(a.id, { fadeOut: fade, fadeCurve: "equalPower" });
322380
+ patch2(b.id, { fadeIn: fade, fadeCurve: "equalPower" });
322236
322381
  return next2;
322237
322382
  }
322238
322383
  function clipUnder(doc2, id3, frameId) {
@@ -322288,9 +322433,9 @@ var init_video_edit = __esm({
322288
322433
  init_time();
322289
322434
  init_video_clip();
322290
322435
  withNode = (doc2, node2) => doc2.nodes[node2.id] === node2 ? doc2 : { ...doc2, nodes: { ...doc2.nodes, [node2.id]: node2 } };
322291
- motionWith = (m, patch) => {
322292
- const next2 = { tracks: {}, ...m, ...patch };
322293
- for (const k2 of Object.keys(patch)) if (next2[k2] === void 0) delete next2[k2];
322436
+ motionWith = (m, patch2) => {
322437
+ const next2 = { tracks: {}, ...m, ...patch2 };
322438
+ for (const k2 of Object.keys(patch2)) if (next2[k2] === void 0) delete next2[k2];
322294
322439
  return !Object.keys(next2.tracks).length && next2.timeOffset === void 0 && next2.span === void 0 && next2.stagger === void 0 ? void 0 : next2;
322295
322440
  };
322296
322441
  videoNodeIdsOn = (doc2, frameId) => videoNodeIds(doc2.nodes).filter((id3) => id3 !== frameId && localTime(doc2.nodes, id3, frameId, 0) !== void 0);
@@ -322365,9 +322510,9 @@ function applyAudioOp(holder, op4, label3) {
322365
322510
  return { holder: made.composition, clip: made.id };
322366
322511
  }
322367
322512
  case "audio": {
322368
- const { kind: _k, clip, ...patch } = op4;
322513
+ const { kind: _k, clip, ...patch2 } = op4;
322369
322514
  void _k;
322370
- return { holder: editAudioClip(holder, audioOr(clip), patch) };
322515
+ return { holder: editAudioClip(holder, audioOr(clip), patch2) };
322371
322516
  }
322372
322517
  case "trimAudio":
322373
322518
  return { holder: trimAudioClip(holder, audioOr(op4.clip), op4.edge, op4.delta, op4.sourceMs) };
@@ -323219,10 +323364,10 @@ function constrained(kind, pos, size6, parentSize, start2, end, sizeProp) {
323219
323364
  return { place: { [start2]: px2(pos) }, style: {} };
323220
323365
  }
323221
323366
  }
323222
- function placedChild(node2, parent, frame2 = parent) {
323367
+ function placedChild(node2, parent, frame3 = parent) {
323223
323368
  const c2 = node2.constraints ?? { horizontal: "MIN", vertical: "MIN" };
323224
- const x2 = constrained(c2.horizontal, node2.x, node2.width, frame2.width, "left", "right", "width");
323225
- const y = constrained(c2.vertical, node2.y, node2.height, frame2.height, "top", "bottom", "height");
323369
+ const x2 = constrained(c2.horizontal, node2.x, node2.width, frame3.width, "left", "right", "width");
323370
+ const y = constrained(c2.vertical, node2.y, node2.height, frame3.height, "top", "bottom", "height");
323226
323371
  return { style: { ...limits(node2), ...x2.style, ...y.style }, place: { position: "absolute", ...x2.place, ...y.place } };
323227
323372
  }
323228
323373
  function siteLayout(node2, parent, layout2) {
@@ -323430,8 +323575,8 @@ var init_tokens2 = __esm({
323430
323575
  // lib/io/web/timeline.ts
323431
323576
  function frameWebMotion(doc2, frameId, style) {
323432
323577
  const nodes = doc2.nodes;
323433
- const frame2 = nodes[frameId];
323434
- if (!frame2 || !hasFrameMotion(nodes, frameId)) return null;
323578
+ const frame3 = nodes[frameId];
323579
+ if (!frame3 || !hasFrameMotion(nodes, frameId)) return null;
323435
323580
  const len3 = timelineDuration(nodes, frameId);
323436
323581
  if (!(len3 > 0)) return null;
323437
323582
  const steps = Math.max(1, Math.ceil(len3 / 1e3 * SAMPLE_RATE));
@@ -327805,7 +327950,7 @@ var init_package = __esm({
327805
327950
  "packages/runtime/package.json"() {
327806
327951
  package_default = {
327807
327952
  name: "@popcraft/runtime",
327808
- version: "0.43.1",
327953
+ version: "0.44.0",
327809
327954
  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.",
327810
327955
  license: "MIT",
327811
327956
  homepage: "https://popcraft.app/docs/exporting/nextjs",
@@ -352471,6 +352616,7 @@ function exportsOf(source3) {
352471
352616
  var CODE_LIMITS, packageOf;
352472
352617
  var init_source2 = __esm({
352473
352618
  "lib/code/source.ts"() {
352619
+ "use strict";
352474
352620
  CODE_LIMITS = { modules: 100, sourceLength: 2e5, packages: 12 };
352475
352621
  packageOf = (spec) => spec.split("/").slice(0, spec.startsWith("@") ? 2 : 1).join("/");
352476
352622
  }
@@ -353431,13 +353577,13 @@ async function drawShareFrame(doc2, frameId) {
353431
353577
  Promise.resolve().then(() => (init_export_fills(), export_fills_exports))
353432
353578
  ]);
353433
353579
  const renderer = getActiveRenderer2();
353434
- const frame2 = doc2.nodes[frameId];
353435
- if (!renderer || !frame2) return null;
353580
+ const frame3 = doc2.nodes[frameId];
353581
+ if (!renderer || !frame3) return null;
353436
353582
  const shown2 = documentForExport2(doc2);
353437
- const box2 = uprightBounds(getWorldTransform(shown2, frameId), frame2.width, frame2.height);
353583
+ const box2 = uprightBounds(getWorldTransform(shown2, frameId), frame3.width, frame3.height);
353438
353584
  const crop = shareCrop(box2.maxX - box2.minX, box2.maxY - box2.minY);
353439
353585
  const bounds2 = { minX: box2.minX + crop.x, minY: box2.minY + crop.y, maxX: box2.minX + crop.x + crop.w, maxY: box2.minY + crop.y + crop.h };
353440
- const pixels = await renderer.exportRegion([shown2.nodes[frameId] ?? frame2], bounds2, crop.scale, shown2, shown2.styles, void 0, true);
353586
+ const pixels = await renderer.exportRegion([shown2.nodes[frameId] ?? frame3], bounds2, crop.scale, shown2, shown2.styles, void 0, true);
353441
353587
  if (!pixels) return null;
353442
353588
  const png = await encodeImageData2(pixels, "PNG");
353443
353589
  if (png && png.size <= SHARE_MAX_BYTES) return { bytes: new Uint8Array(await png.arrayBuffer()), ext: "png" };
@@ -356351,8 +356497,8 @@ var init_vision = __esm({
356351
356497
  if (args2.parts) {
356352
356498
  if (ids2.length !== 1) throw new ToolError("Look at one frame part by part at a time.");
356353
356499
  if (args2.at && args2.at.length > 1) throw new ToolError("Look at a page part by part at one moment at a time.");
356354
- const frame2 = doc2.nodes[ids2[0]];
356355
- const parts = (frame2.childIds ?? []).map((c2) => doc2.nodes[c2]).filter((n) => !!n && n.visible !== false && n.layoutPositioning !== "ABSOLUTE" && n.height > 1);
356500
+ const frame3 = doc2.nodes[ids2[0]];
356501
+ const parts = (frame3.childIds ?? []).map((c2) => doc2.nodes[c2]).filter((n) => !!n && n.visible !== false && n.layoutPositioning !== "ABSOLUTE" && n.height > 1);
356356
356502
  const FOOT = 1e5;
356357
356503
  const tops = parts.map((n) => Math.max(0, n.y)).sort((a, b) => a - b);
356358
356504
  const bands = tops.length ? tops.map((y, i2) => {
@@ -356615,16 +356761,16 @@ function placeAudioClip(ctx2, compositionId2, o) {
356615
356761
  }
356616
356762
  function placeFrameAudioClip(ctx2, frameId, o) {
356617
356763
  const latest = ctx2.doc();
356618
- const frame2 = latest.nodes[frameId];
356619
- if (!frame2 || frame2.type !== "FRAME" && frame2.type !== "COMPONENT") throw new ToolError(`"${frameId}" is not a frame.`);
356620
- const made = addAudioClip(frameTimeline(latest.nodes, frame2.id), { mediaHash: o.mediaHash, name: o.name, duration: o.duration, start: o.start, lane: o.lane });
356764
+ const frame3 = latest.nodes[frameId];
356765
+ if (!frame3 || frame3.type !== "FRAME" && frame3.type !== "COMPONENT") throw new ToolError(`"${frameId}" is not a frame.`);
356766
+ const made = addAudioClip(frameTimeline(latest.nodes, frame3.id), { mediaHash: o.mediaHash, name: o.name, duration: o.duration, start: o.start, lane: o.lane });
356621
356767
  let next2 = made.composition;
356622
356768
  if (o.fadeIn !== void 0 || o.fadeOut !== void 0) next2 = editAudioClip(next2, made.id, { fadeIn: o.fadeIn, fadeOut: o.fadeOut });
356623
356769
  if (o.gain !== void 0) next2 = setGainKey(next2, made.id, 0, o.gain);
356624
356770
  if (o.loop) next2 = editAudioClip(next2, made.id, { loop: true });
356625
- ctx2.commit({ ...latest, nodes: { ...latest.nodes, [frame2.id]: { ...frame2, timeline: next2 } } });
356771
+ ctx2.commit({ ...latest, nodes: { ...latest.nodes, [frame3.id]: { ...frame3, timeline: next2 } } });
356626
356772
  const clip = next2.audio?.find((a) => a.id === made.id);
356627
- return { summary: `Added "${o.name}" (${(o.duration / 1e3).toFixed(1)} s) to "${frame2.name}"`, data: { frame: frame2.id, clip: made.id, mediaHash: o.mediaHash, duration: o.duration, lane: clip?.lane, start: clip?.start } };
356773
+ return { summary: `Added "${o.name}" (${(o.duration / 1e3).toFixed(1)} s) to "${frame3.name}"`, data: { frame: frame3.id, clip: made.id, mediaHash: o.mediaHash, duration: o.duration, lane: clip?.lane, start: clip?.start } };
356628
356774
  }
356629
356775
  var ORDERS2, order, orderIds, seed, pickOf, presetList, motionApplyPreset, motionStagger, motionCreateComponent, SCENE_TYPES, motionNewComposition, center, compositionOp, OP_LABELS, motionEditComposition, motionDetectOnsets, motionGetCompositions, motionCutToBeat, motionAddAudio, AUDIO_USE_IDS, motionGenerateAudio;
356630
356776
  var init_motion2 = __esm({
@@ -356929,10 +357075,10 @@ var init_motion2 = __esm({
356929
357075
  break;
356930
357076
  case "frame": {
356931
357077
  const clip = comp.clips.find((c2) => c2.id === clipOr2(op4.clip));
356932
- const [frame2] = scenesOf(doc2, [op4.frame]);
356933
- if (!frame2) throw new ToolError(`"${op4.frame}" is not a frame (or a layer in one).`);
357078
+ const [frame3] = scenesOf(doc2, [op4.frame]);
357079
+ if (!frame3) throw new ToolError(`"${op4.frame}" is not a frame (or a layer in one).`);
356934
357080
  const wholeOld = clip.in === 0 && Math.abs(clip.out - timelineDuration(doc2.nodes, clip.frameId)) < 1;
356935
- next2 = setClipFrame(comp, clip.id, frame2.id, timelineDuration(doc2.nodes, frame2.id), wholeOld);
357081
+ next2 = setClipFrame(comp, clip.id, frame3.id, timelineDuration(doc2.nodes, frame3.id), wholeOld);
356936
357082
  break;
356937
357083
  }
356938
357084
  case "rename":
@@ -357356,14 +357502,14 @@ var init_motion_av = __esm({
357356
357502
  }
357357
357503
  case "timing": {
357358
357504
  if (op4.speed !== void 0) next2 = wrap2(() => setVideoSpeed(next2, id3, frameId, op4.speed));
357359
- const patch = { ...op4.loop !== void 0 ? { videoLoop: op4.loop } : {}, ...op4.poster !== void 0 ? { videoPosterTime: op4.poster } : {}, ...op4.playback ? { videoPlayback: op4.playback } : {} };
357360
- if (Object.keys(patch).length) next2 = wrap2(() => editVideoPaint(next2, id3, frameId, patch));
357505
+ const patch2 = { ...op4.loop !== void 0 ? { videoLoop: op4.loop } : {}, ...op4.poster !== void 0 ? { videoPosterTime: op4.poster } : {}, ...op4.playback ? { videoPlayback: op4.playback } : {} };
357506
+ if (Object.keys(patch2).length) next2 = wrap2(() => editVideoPaint(next2, id3, frameId, patch2));
357361
357507
  break;
357362
357508
  }
357363
357509
  case "sound": {
357364
- const { kind: _k, ...patch } = op4;
357510
+ const { kind: _k, ...patch2 } = op4;
357365
357511
  void _k;
357366
- next2 = wrap2(() => editVideoSound(doc2, id3, frameId, patch));
357512
+ next2 = wrap2(() => editVideoSound(doc2, id3, frameId, patch2));
357367
357513
  break;
357368
357514
  }
357369
357515
  case "gainKey":
@@ -357405,13 +357551,13 @@ var init_motion_av = __esm({
357405
357551
  },
357406
357552
  run: (args2, ctx2) => {
357407
357553
  const doc2 = ctx2.doc();
357408
- const frame2 = doc2.nodes[args2.frame];
357409
- if (!frame2 || frame2.type !== "FRAME" && frame2.type !== "COMPONENT") throw new ToolError(`"${args2.frame}" is not a frame.`);
357410
- const tl = frameTimeline(doc2.nodes, frame2.id);
357411
- const r = applyAudioOp(tl, args2.op, `"${frame2.name}"`);
357412
- if (r.holder === tl) return { summary: "Nothing to change", data: { frame: frame2.id } };
357413
- ctx2.commit({ ...doc2, nodes: { ...doc2.nodes, [frame2.id]: { ...frame2, timeline: r.holder } } });
357414
- return { summary: `${args2.op.kind === "addAudio" ? "Added audio to" : "Edited audio of"} "${frame2.name}"`, data: { frame: frame2.id, ...r.clip ? { clip: r.clip } : {} } };
357554
+ const frame3 = doc2.nodes[args2.frame];
357555
+ if (!frame3 || frame3.type !== "FRAME" && frame3.type !== "COMPONENT") throw new ToolError(`"${args2.frame}" is not a frame.`);
357556
+ const tl = frameTimeline(doc2.nodes, frame3.id);
357557
+ const r = applyAudioOp(tl, args2.op, `"${frame3.name}"`);
357558
+ if (r.holder === tl) return { summary: "Nothing to change", data: { frame: frame3.id } };
357559
+ ctx2.commit({ ...doc2, nodes: { ...doc2.nodes, [frame3.id]: { ...frame3, timeline: r.holder } } });
357560
+ return { summary: `${args2.op.kind === "addAudio" ? "Added audio to" : "Edited audio of"} "${frame3.name}"`, data: { frame: frame3.id, ...r.clip ? { clip: r.clip } : {} } };
357415
357561
  }
357416
357562
  });
357417
357563
  }
@@ -357935,9 +358081,9 @@ var init_motion_keys = __esm({
357935
358081
  delete motion.stagger;
357936
358082
  }
357937
358083
  }
357938
- const patch = { ...patches.get(node2.id) ?? {}, motion: tidy(motion) };
357939
- if (l.label !== void 0) patch.timelineColor = l.label ?? void 0;
357940
- patches.set(node2.id, patch);
358084
+ const patch2 = { ...patches.get(node2.id) ?? {}, motion: tidy(motion) };
358085
+ if (l.label !== void 0) patch2.timelineColor = l.label ?? void 0;
358086
+ patches.set(node2.id, patch2);
357941
358087
  }
357942
358088
  commitUpdates(ctx2, doc2, patches);
357943
358089
  return { summary: `Timed ${plural2(patches.size, "layer")}`, data: { ids: [...patches.keys()] } };
@@ -358052,7 +358198,7 @@ var init_motion_rich = __esm({
358052
358198
  MS2 = 36e5;
358053
358199
  colorIn = external_exports.union([external_exports.string(), external_exports.object({ r: external_exports.number().min(0).max(1), g: external_exports.number().min(0).max(1), b: external_exports.number().min(0).max(1), a: external_exports.number().min(0).max(1).optional() })]).describe('"#rrggbb[aa]" or {r,g,b,a} (0\u20131).');
358054
358200
  colorOf = (c2) => typeof c2 === "string" ? parseHex(c2) : { a: 1, ...c2 };
358055
- put2 = (patches, id3, patch) => patches.set(id3, { ...patches.get(id3) ?? {}, ...patch });
358201
+ put2 = (patches, id3, patch2) => patches.set(id3, { ...patches.get(id3) ?? {}, ...patch2 });
358056
358202
  UNITS2 = ["letter", "word", "line"];
358057
358203
  ORDERS3 = ["forward", "reverse", "center", "random"];
358058
358204
  animatorFields = external_exports.object({
@@ -358312,12 +358458,12 @@ var init_motion_rich = __esm({
358312
358458
  case "place": {
358313
358459
  for (const l of op4.layers) {
358314
358460
  const layer2 = nodeOrThrow(doc2, l.id);
358315
- const patch = {};
358316
- if (l.rotateX !== void 0) patch.rotateX = l.rotateX;
358317
- if (l.rotateY !== void 0) patch.rotateY = l.rotateY;
358318
- if (l.z !== void 0) patch.z = l.z;
358319
- if (l.material) patch.material3d = { ...layer2.material3d, ...clean3(l.material) };
358320
- put2(patches, layer2.id, patch);
358461
+ const patch2 = {};
358462
+ if (l.rotateX !== void 0) patch2.rotateX = l.rotateX;
358463
+ if (l.rotateY !== void 0) patch2.rotateY = l.rotateY;
358464
+ if (l.z !== void 0) patch2.z = l.z;
358465
+ if (l.material) patch2.material3d = { ...layer2.material3d, ...clean3(l.material) };
358466
+ put2(patches, layer2.id, patch2);
358321
358467
  }
358322
358468
  commitUpdates(ctx2, doc2, patches);
358323
358469
  return { summary: `Placed ${plural2(op4.layers.length, "layer")} in 3D`, data: { ids: op4.layers.map((l) => l.id) } };
@@ -358379,8 +358525,8 @@ var init_motion_rich = __esm({
358379
358525
  playback.range = e.range;
358380
358526
  } else delete playback.range;
358381
358527
  }
358382
- const patch = {};
358383
- if (touchesPlayback) patch.playback = Object.keys(playback).length ? playback : void 0;
358528
+ const patch2 = {};
358529
+ if (touchesPlayback) patch2.playback = Object.keys(playback).length ? playback : void 0;
358384
358530
  if (e.properties) {
358385
358531
  const defs = componentDefinitions(doc2.nodes, comp);
358386
358532
  const values3 = { ...inst.componentProperties ?? {} };
@@ -358390,9 +358536,9 @@ var init_motion_rich = __esm({
358390
358536
  values3[name2] = def.type === "COLOR" ? colorOf(raw) : raw;
358391
358537
  if (def.type === "NUMBER" && typeof raw !== "number" || def.type === "BOOLEAN" && typeof raw !== "boolean" || def.type === "TEXT" && typeof raw !== "string") throw new ToolError(`${name2} is a ${def.type} property.`);
358392
358538
  }
358393
- patch.componentProperties = values3;
358539
+ patch2.componentProperties = values3;
358394
358540
  }
358395
- put2(patches, inst.id, patch);
358541
+ put2(patches, inst.id, patch2);
358396
358542
  }
358397
358543
  commitUpdates(ctx2, doc2, patches);
358398
358544
  return { summary: `Playback on ${plural2(patches.size, "instance")}`, data: { ids: [...patches.keys()] } };
@@ -358587,19 +358733,19 @@ var init_motion_rich = __esm({
358587
358733
  function frameOrThrow(doc2, id3) {
358588
358734
  nodeOrThrow(doc2, id3);
358589
358735
  const host = hostOrThrow(doc2, id3);
358590
- const frame2 = doc2.nodes[host];
358591
- if (frame2.type !== "FRAME") throw new ToolError(`"${frame2.name}" is a component: state machines belong to top-level frames.`);
358592
- return frame2;
358736
+ const frame3 = doc2.nodes[host];
358737
+ if (frame3.type !== "FRAME") throw new ToolError(`"${frame3.name}" is a component: state machines belong to top-level frames.`);
358738
+ return frame3;
358593
358739
  }
358594
358740
  function pick4(rec, key5, what) {
358595
358741
  const hit = rec[key5] ?? Object.values(rec).find((e) => e.name.toLowerCase() === key5.toLowerCase());
358596
358742
  if (!hit) throw new ToolError(`The machine has no ${what} "${key5}". It has: ${sortedValues(rec).map((e) => `${e.name} (${e.id})`).join(", ") || "none"}.`);
358597
358743
  return hit;
358598
358744
  }
358599
- function markerOrThrow(frame2, key5) {
358600
- const markers = frameTimelineOf(frame2).markers ?? [];
358745
+ function markerOrThrow(frame3, key5) {
358746
+ const markers = frameTimelineOf(frame3).markers ?? [];
358601
358747
  const m = markers.find((x2) => x2.id === key5) ?? markers.find((x2) => (x2.label ?? "").toLowerCase() === key5.toLowerCase());
358602
- if (!m) throw new ToolError(`"${frame2.name}" has no marker "${key5}". Add one with set_timeline (addMarkers).`);
358748
+ if (!m) throw new ToolError(`"${frame3.name}" has no marker "${key5}". Add one with set_timeline (addMarkers).`);
358603
358749
  return m.id;
358604
358750
  }
358605
358751
  function valueFor(input2, v, what) {
@@ -358628,21 +358774,21 @@ function guardsFor(sm, list2) {
358628
358774
  return { input: input2.id, ...op4 && op4 !== "eq" ? { op: op4 } : {}, ...g.value !== void 0 ? { value: valueFor(input2, g.value, "A guard") } : {} };
358629
358775
  });
358630
358776
  }
358631
- function applyOp(frame2, sm, op4) {
358777
+ function applyOp(frame3, sm, op4) {
358632
358778
  if (op4.kind === "create") {
358633
- if (sm) throw new ToolError(`"${frame2.name}" already has a state machine ("${sm.name}"). Edit it, or remove it first.`);
358634
- return { next: createStateMachine(frame2.timeline, op4.name) };
358779
+ if (sm) throw new ToolError(`"${frame3.name}" already has a state machine ("${sm.name}"). Edit it, or remove it first.`);
358780
+ return { next: createStateMachine(frame3.timeline, op4.name) };
358635
358781
  }
358636
- if (!sm) throw new ToolError(`"${frame2.name}" has no state machine. Create one first (op kind "create").`);
358782
+ if (!sm) throw new ToolError(`"${frame3.name}" has no state machine. Create one first (op kind "create").`);
358637
358783
  const stretchOf = (o, s) => {
358638
358784
  const out = { ...s };
358639
358785
  if (o.from !== void 0) {
358640
358786
  if (o.from === null) delete out.from;
358641
- else out.from = markerOrThrow(frame2, o.from);
358787
+ else out.from = markerOrThrow(frame3, o.from);
358642
358788
  }
358643
358789
  if (o.to !== void 0) {
358644
358790
  if (o.to === null) delete out.to;
358645
- else out.to = markerOrThrow(frame2, o.to);
358791
+ else out.to = markerOrThrow(frame3, o.to);
358646
358792
  }
358647
358793
  if (o.loop !== void 0) {
358648
358794
  if (o.loop) out.loop = true;
@@ -358824,7 +358970,7 @@ var init_motion_machine = __esm({
358824
358970
  };
358825
358971
  opsOf = (p2) => p2.ops ?? (p2.op ? [p2.op] : []);
358826
358972
  opsLabel = (ops2) => ops2.length && ops2.every((o) => o.kind === ops2[0].kind) ? OP_LABELS2[ops2[0].kind] : "Edit state machine";
358827
- frameTimelineOf = (frame2) => frame2.timeline ?? { duration: 0 };
358973
+ frameTimelineOf = (frame3) => frame3.timeline ?? { duration: 0 };
358828
358974
  stateRef = (sm, key5, allowAny = false) => allowAny && key5 === ANY_STATE ? ANY_STATE : pick4(sm.states, key5, "state").id;
358829
358975
  motionEditStateMachine = defineCommand({
358830
358976
  id: "motion.editStateMachine",
@@ -358851,22 +358997,22 @@ var init_motion_machine = __esm({
358851
358997
  const doc2 = ctx2.doc();
358852
358998
  const at4 = args2.id ?? ctx2.selection()[0];
358853
358999
  if (!at4) throw new ToolError("edit_state_machine needs the frame (id) or a selection.");
358854
- const frame2 = frameOrThrow(doc2, at4);
359000
+ const frame3 = frameOrThrow(doc2, at4);
358855
359001
  if (!!args2.op === !!args2.ops) throw new ToolError("edit_state_machine takes op or ops (not both).");
358856
359002
  const ops2 = opsOf(args2);
358857
- let next2 = machineOf(frame2);
359003
+ let next2 = machineOf(frame3);
358858
359004
  const added = [];
358859
359005
  for (const op4 of ops2) {
358860
- const r = applyOp(frame2, next2 ?? void 0, op4);
359006
+ const r = applyOp(frame3, next2 ?? void 0, op4);
358861
359007
  next2 = r.next;
358862
359008
  if (r.added) added.push(r.added);
358863
359009
  }
358864
- commitUpdates(ctx2, doc2, /* @__PURE__ */ new Map([[frame2.id, { stateMachine: next2 ?? void 0 }]]));
358865
- const sm = machineOf(ctx2.doc().nodes[frame2.id]);
359010
+ commitUpdates(ctx2, doc2, /* @__PURE__ */ new Map([[frame3.id, { stateMachine: next2 ?? void 0 }]]));
359011
+ const sm = machineOf(ctx2.doc().nodes[frame3.id]);
358866
359012
  const label3 = opsLabel(ops2);
358867
359013
  return {
358868
359014
  summary: next2 && sm ? `${label3} \u2014 "${sm.name}": ${plural2(Object.keys(sm.states).length, "state")}, ${plural2(Object.keys(sm.transitions).length, "transition")}` : label3,
358869
- data: { id: frame2.id, ...added.length ? { added: added[added.length - 1], addedAll: added } : {}, ...sm ? { stateMachine: sm } : {} }
359015
+ data: { id: frame3.id, ...added.length ? { added: added[added.length - 1], addedAll: added } : {}, ...sm ? { stateMachine: sm } : {} }
358870
359016
  };
358871
359017
  }
358872
359018
  });
@@ -358888,16 +359034,16 @@ var init_motion_machine = __esm({
358888
359034
  const doc2 = ctx2.doc();
358889
359035
  const at4 = args2.id ?? ctx2.selection()[0];
358890
359036
  if (!at4) throw new ToolError("get_state_machine needs the frame (id) or a selection.");
358891
- const frame2 = frameOrThrow(doc2, at4);
358892
- const sm = machineOf(frame2);
358893
- const tl = frameTimeline(doc2.nodes, frame2.id);
359037
+ const frame3 = frameOrThrow(doc2, at4);
359038
+ const sm = machineOf(frame3);
359039
+ const tl = frameTimeline(doc2.nodes, frame3.id);
358894
359040
  const markers = (tl.markers ?? []).map((m) => ({ id: m.id, t: m.t, ...m.label ? { label: m.label } : {} }));
358895
- if (!sm) return { summary: `"${frame2.name}" has no state machine`, data: { id: frame2.id, stateMachine: null, markers } };
358896
- const duration3 = timelineDuration(doc2.nodes, frame2.id);
359041
+ if (!sm) return { summary: `"${frame3.name}" has no state machine`, data: { id: frame3.id, stateMachine: null, markers } };
359042
+ const duration3 = timelineDuration(doc2.nodes, frame3.id);
358897
359043
  const states = sortedValues(sm.states).map((s) => ({ ...s, stretch: stateStretch(s, tl, duration3) }));
358898
359044
  return {
358899
359045
  summary: `"${sm.name}": ${plural2(states.length, "state")}, ${plural2(Object.keys(sm.inputs).length, "input")}, ${plural2(Object.keys(sm.listeners).length, "listener")}`,
358900
- data: { id: frame2.id, stateMachine: { ...sm, states, transitions: sortedValues(sm.transitions), inputs: sortedValues(sm.inputs), listeners: sortedValues(sm.listeners) }, markers }
359046
+ data: { id: frame3.id, stateMachine: { ...sm, states, transitions: sortedValues(sm.transitions), inputs: sortedValues(sm.inputs), listeners: sortedValues(sm.listeners) }, markers }
358901
359047
  };
358902
359048
  }
358903
359049
  });
@@ -359266,7 +359412,7 @@ function placeVideoScene(doc2, pageId2, compositionId2, file2, intoId) {
359266
359412
  if (!comp || !doc2.nodes[pageId2]) return null;
359267
359413
  const durationMs = Math.max(1, Math.round(file2.durationMs));
359268
359414
  const at4 = nextScenePosition(doc2, pageId2);
359269
- const frame2 = createFrame({
359415
+ const frame3 = createFrame({
359270
359416
  name: file2.name,
359271
359417
  ...at4,
359272
359418
  width: comp.width,
@@ -359274,26 +359420,26 @@ function placeVideoScene(doc2, pageId2, compositionId2, file2, intoId) {
359274
359420
  fills: [{ type: "SOLID", color: comp.background ?? { r: 0, g: 0, b: 0, a: 1 }, visible: true }],
359275
359421
  timeline: { duration: durationMs, fps: comp.fps }
359276
359422
  });
359277
- let next2 = addNode(doc2, frame2, pageId2);
359423
+ let next2 = addNode(doc2, frame3, pageId2);
359278
359424
  let nodeId2;
359279
359425
  const existing = intoId ? next2.nodes[intoId] : void 0;
359280
359426
  if (existing) {
359281
359427
  const oldParent = existing.parentId ? next2.nodes[existing.parentId] : void 0;
359282
359428
  const nodes = { ...next2.nodes };
359283
359429
  if (oldParent) nodes[oldParent.id] = { ...oldParent, childIds: oldParent.childIds.filter((c2) => c2 !== existing.id) };
359284
- nodes[frame2.id] = { ...nodes[frame2.id], childIds: [...nodes[frame2.id].childIds, existing.id] };
359285
- nodes[existing.id] = { ...existing, parentId: frame2.id, x: 0, y: 0, width: comp.width, height: comp.height, rotation: 0 };
359430
+ nodes[frame3.id] = { ...nodes[frame3.id], childIds: [...nodes[frame3.id].childIds, existing.id] };
359431
+ nodes[existing.id] = { ...existing, parentId: frame3.id, x: 0, y: 0, width: comp.width, height: comp.height, rotation: 0 };
359286
359432
  next2 = fillWithVideo({ ...next2, nodes }, existing.id, file2);
359287
359433
  nodeId2 = existing.id;
359288
359434
  } else {
359289
- const placed2 = placeVideoLayer(next2, frame2.id, file2, { cx: comp.width / 2, cy: comp.height / 2, width: comp.width, height: comp.height });
359435
+ const placed2 = placeVideoLayer(next2, frame3.id, file2, { cx: comp.width / 2, cy: comp.height / 2, width: comp.width, height: comp.height });
359290
359436
  next2 = placed2.doc;
359291
359437
  nodeId2 = placed2.nodeId;
359292
359438
  }
359293
- const withClip = addClip(comp, frame2.id, durationMs);
359439
+ const withClip = addClip(comp, frame3.id, durationMs);
359294
359440
  const clipId = withClip.clips.find((c2) => !comp.clips.some((o) => o.id === c2.id))?.id ?? "";
359295
359441
  next2 = repairDocumentCompositions({ ...next2, compositions: { ...next2.compositions, [comp.id]: withClip } });
359296
- return { doc: next2, frameId: frame2.id, nodeId: nodeId2, clipId };
359442
+ return { doc: next2, frameId: frame3.id, nodeId: nodeId2, clipId };
359297
359443
  }
359298
359444
  var init_media_placement = __esm({
359299
359445
  "lib/ai/media-placement.ts"() {
@@ -360289,10 +360435,10 @@ async function placePicture(imported, opts = {}) {
360289
360435
  Promise.resolve().then(() => (init_media_tool(), media_tool_exports))
360290
360436
  ]);
360291
360437
  const st = useEditorStore2.getState();
360292
- const frame2 = photoFrameOf2(st.document.nodes, opts.targetId !== void 0 ? opts.targetId : st.selection[0] ?? null);
360293
- if (frame2) {
360294
- st.fillPhotoFrame(frame2.id, imported.ref, { width: imported.width, height: imported.height }, imported.name, imported.credit);
360295
- return frame2.id;
360438
+ const frame3 = photoFrameOf2(st.document.nodes, opts.targetId !== void 0 ? opts.targetId : st.selection[0] ?? null);
360439
+ if (frame3) {
360440
+ st.fillPhotoFrame(frame3.id, imported.ref, { width: imported.width, height: imported.height }, imported.name, imported.credit);
360441
+ return frame3.id;
360296
360442
  }
360297
360443
  const point2 = opts.at ?? { x: st.camera.x, y: st.camera.y };
360298
360444
  return placeImage2(imported.ref, { w: imported.width, h: imported.height }, { kind: "point", ...point2 }, { name: imported.name, ...imported.credit ? { credit: imported.credit } : {} });
@@ -360322,10 +360468,10 @@ async function placeImportedPicture(ctx2, imported, at4, what, extra = {}) {
360322
360468
  if (at4.fillLayerId) {
360323
360469
  const doc2 = ctx2.doc();
360324
360470
  const target2 = nodeOrThrow(doc2, at4.fillLayerId);
360325
- const frame2 = photoFrameOf(doc2.nodes, target2.id);
360326
- if (frame2) {
360327
- ctx2.commit(fillPhotoFrame(doc2, frame2.id, imported.ref, { width: imported.width, height: imported.height }, imported.name, imported.credit));
360328
- return { summary: `Filled photo frame \u201C${frame2.name}\u201D with ${what}`, data: { id: frame2.id, ...extra } };
360471
+ const frame3 = photoFrameOf(doc2.nodes, target2.id);
360472
+ if (frame3) {
360473
+ ctx2.commit(fillPhotoFrame(doc2, frame3.id, imported.ref, { width: imported.width, height: imported.height }, imported.name, imported.credit));
360474
+ return { summary: `Filled photo frame \u201C${frame3.name}\u201D with ${what}`, data: { id: frame3.id, ...extra } };
360329
360475
  }
360330
360476
  if (!("fills" in target2)) throw new ToolError(`\u201C${target2.name}\u201D has no fills to put a picture in.`);
360331
360477
  const fill = client.photoFill({ type: "IMAGE", visible: true, opacity: 1 }, imported);
@@ -360808,11 +360954,11 @@ var init_prototype = __esm({
360808
360954
  const patches = /* @__PURE__ */ new Map();
360809
360955
  for (const id3 of ids2) {
360810
360956
  const node2 = doc2.nodes[id3];
360811
- const patch = {};
360957
+ const patch2 = {};
360812
360958
  if (replace || add3.length || args2.removeInteractions) {
360813
360959
  const drop = new Set(args2.removeInteractions ?? []);
360814
360960
  const next2 = [...(replace ?? node2.interactions ?? []).filter((ix) => !drop.has(ix.id)), ...add3];
360815
- patch.interactions = next2.length ? next2 : void 0;
360961
+ patch2.interactions = next2.length ? next2 : void 0;
360816
360962
  }
360817
360963
  if (args2.liveValues) {
360818
360964
  if ("characters" in args2.liveValues && node2.type !== "TEXT" && args2.liveValues.characters) throw new ToolError(`\u201C${node2.name}\u201D is not text, so it has no characters to bind.`);
@@ -360821,10 +360967,10 @@ var init_prototype = __esm({
360821
360967
  if (src) bound[prop] = src;
360822
360968
  else delete bound[prop];
360823
360969
  }
360824
- patch.boundExpressions = Object.keys(bound).length ? bound : void 0;
360970
+ patch2.boundExpressions = Object.keys(bound).length ? bound : void 0;
360825
360971
  }
360826
- if (args2.sharedElement !== void 0) patch.sharedElement = args2.sharedElement || void 0;
360827
- patches.set(id3, patch);
360972
+ if (args2.sharedElement !== void 0) patch2.sharedElement = args2.sharedElement || void 0;
360973
+ patches.set(id3, patch2);
360828
360974
  }
360829
360975
  commitUpdates(ctx2, doc2, patches);
360830
360976
  return { summary: `Edited the prototype on ${ids2.length === 1 ? "1 layer" : `${ids2.length} layers`}`, data: { ids: ids2 } };
@@ -361026,6 +361172,7 @@ function publishSite(key5, files, opts = {}) {
361026
361172
  var siteStatus, setSiteVersion, workspaceSites, deleteSite, renameSite;
361027
361173
  var init_sites = __esm({
361028
361174
  "lib/client/cloud/sites.ts"() {
361175
+ "use strict";
361029
361176
  init_files();
361030
361177
  init_upload2();
361031
361178
  init_api4();
@@ -367423,8 +367570,8 @@ function libraryMotionPreviews(libraryId, version7) {
367423
367570
  }
367424
367571
  return p2;
367425
367572
  }
367426
- async function updateLibraryListing(libraryId, patch) {
367427
- await api(`/api/libraries/${libraryId}`, { method: "PATCH", json: patch });
367573
+ async function updateLibraryListing(libraryId, patch2) {
367574
+ await api(`/api/libraries/${libraryId}`, { method: "PATCH", json: patch2 });
367428
367575
  await refreshLibraries();
367429
367576
  }
367430
367577
  async function unpublishLibrary(libraryId) {
@@ -367847,8 +367994,8 @@ function widgetCommands(id3) {
367847
367994
  const after = layoutWidget(tree);
367848
367995
  const sx = node2.widgetTree ? node2.width / before.width : 1;
367849
367996
  const sy = node2.widgetTree ? node2.height / before.height : 1;
367850
- const patch = { widgetTree: tree, widgetState: next2, width: after.width * sx, height: after.height * sy };
367851
- ctx2.commit(updateNode(ctx2.doc(), node2.id, patch), ctx2.actor.label ?? "Update widget");
367997
+ const patch2 = { widgetTree: tree, widgetState: next2, width: after.width * sx, height: after.height * sy };
367998
+ ctx2.commit(updateNode(ctx2.doc(), node2.id, patch2), ctx2.actor.label ?? "Update widget");
367852
367999
  return { summary: "Widget updated" };
367853
368000
  }
367854
368001
  }),
@@ -368757,7 +368904,7 @@ async function applyLayoutIr(ir, document2, pageId2, opts = {}) {
368757
368904
  let cursorX = siblings.reduce((m, n) => Math.max(m, n.x + n.width), 0) + (siblings.length ? 120 : 0);
368758
368905
  const cursorY = siblings.length ? Math.min(...siblings.map((n) => n.y)) : 0;
368759
368906
  for (const p2 of ir.pages) {
368760
- const frame2 = createFrame({
368907
+ const frame3 = createFrame({
368761
368908
  name: p2.name || name2,
368762
368909
  x: cursorX,
368763
368910
  y: cursorY,
@@ -368766,9 +368913,9 @@ async function applyLayoutIr(ir, document2, pageId2, opts = {}) {
368766
368913
  fills: [createSolidPaint(createColor(1, 1, 1))],
368767
368914
  clipsContent: true
368768
368915
  });
368769
- doc2 = addNode(doc2, frame2, pageId2);
368770
- added.push(frame2.id);
368771
- cursorX += frame2.width + 120;
368916
+ doc2 = addNode(doc2, frame3, pageId2);
368917
+ added.push(frame3.id);
368918
+ cursorX += frame3.width + 120;
368772
368919
  const items = [...p2.items || []].sort((a, b) => {
368773
368920
  const rank = (k2) => k2 === "rect" ? 0 : k2 === "image" ? 1 : 2;
368774
368921
  return rank(a.kind) - rank(b.kind);
@@ -368815,7 +368962,7 @@ async function applyLayoutIr(ir, document2, pageId2, opts = {}) {
368815
368962
  fills: [createSolidPaint(createColor(c2.r, c2.g, c2.b, c2.a))]
368816
368963
  });
368817
368964
  }
368818
- if (child) doc2 = addNode(doc2, child, frame2.id);
368965
+ if (child) doc2 = addNode(doc2, child, frame3.id);
368819
368966
  }
368820
368967
  }
368821
368968
  return { document: doc2, added };
@@ -368837,7 +368984,7 @@ var init_import_layout_ir = __esm({
368837
368984
 
368838
368985
  // lib/client/import/import-status.ts
368839
368986
  function beginImport(name2) {
368840
- const id3 = ++nextId2;
368987
+ const id3 = ++nextId3;
368841
368988
  useImportStatus.setState((s) => ({ jobs: [...s.jobs, { id: id3, name: name2, startedAt: Date.now() }] }));
368842
368989
  let ended = false;
368843
368990
  return () => {
@@ -368854,13 +369001,13 @@ async function trackImport(name2, task) {
368854
369001
  end();
368855
369002
  }
368856
369003
  }
368857
- var useImportStatus, nextId2;
369004
+ var useImportStatus, nextId3;
368858
369005
  var init_import_status = __esm({
368859
369006
  "lib/client/import/import-status.ts"() {
368860
369007
  "use strict";
368861
369008
  init_esm();
368862
369009
  useImportStatus = create2(() => ({ jobs: [], dismissed: [] }));
368863
- nextId2 = 0;
369010
+ nextId3 = 0;
368864
369011
  }
368865
369012
  });
368866
369013
 
@@ -368930,26 +369077,26 @@ function importLottie(input2, opts = {}) {
368930
369077
  const fps = nearestFps(anim.fr);
368931
369078
  if (Math.abs(fps - anim.fr) > 0.01) imp.notes.add(`The timeline runs at ${fps} fps (the file is ${anim.fr} fps; key times are kept exactly).`);
368932
369079
  const duration3 = Math.max(1, imp.ms(anim.op - anim.ip));
368933
- const frame2 = createFrame({ name: name2, x: 0, y: 0, width: anim.w, height: anim.h, fills: [], clipsContent: true });
368934
- frame2.timeline = {
369080
+ const frame3 = createFrame({ name: name2, x: 0, y: 0, width: anim.w, height: anim.h, fills: [], clipsContent: true });
369081
+ frame3.timeline = {
368935
369082
  duration: duration3,
368936
369083
  fps,
368937
369084
  ...anim.markers?.length ? { markers: anim.markers.map((m, i2) => ({ id: `lm${i2}`, t: Math.max(0, imp.ms(m.tm - anim.ip)), label: m.cm })) } : {}
368938
369085
  };
368939
- imp.add(frame2, null);
368940
- imp.layers(anim.layers ?? [], frame2.id, anim.ip, "", { w: anim.w, h: anim.h });
368941
- frame2.parentId = pageId2;
369086
+ imp.add(frame3, null);
369087
+ imp.layers(anim.layers ?? [], frame3.id, anim.ip, "", { w: anim.w, h: anim.h });
369088
+ frame3.parentId = pageId2;
368942
369089
  if (read6.stateMachines.length) {
368943
369090
  const byName = /* @__PURE__ */ new Map();
368944
- for (const n of Object.values(imp.nodes)) if (n.name && n.id !== frame2.id && !byName.has(n.name)) byName.set(n.name, n.id);
369091
+ for (const n of Object.values(imp.nodes)) if (n.name && n.id !== frame3.id && !byName.has(n.name)) byName.set(n.name, n.id);
368945
369092
  const first2 = read6.stateMachines[0];
368946
369093
  const { machine, notes } = stateMachineFromDotLottie({ raw: first2.raw, markers: anim.markers ?? [], ip: anim.ip, fr: anim.fr, nodeByName: (name3) => byName.get(name3) }, "sm1", first2.id);
368947
369094
  for (const n of notes) imp.notes.add(n);
368948
- if (machine) imp.nodes[frame2.id].stateMachine = machine;
369095
+ if (machine) imp.nodes[frame3.id].stateMachine = machine;
368949
369096
  if (read6.stateMachines.length > 1) imp.notes.add(`The file has ${read6.stateMachines.length} state machines: the first, \u201C${first2.id}\u201D, is imported.`);
368950
369097
  }
368951
369098
  const page = doc2.nodes[pageId2];
368952
- const nodes = { ...doc2.nodes, ...imp.nodes, [pageId2]: { ...page, childIds: [...page.childIds, frame2.id] } };
369099
+ const nodes = { ...doc2.nodes, ...imp.nodes, [pageId2]: { ...page, childIds: [...page.childIds, frame3.id] } };
368953
369100
  let pages2 = doc2.pages;
368954
369101
  if (imp.components.size) {
368955
369102
  const comps = createPage("Components");
@@ -368963,7 +369110,7 @@ function importLottie(input2, opts = {}) {
368963
369110
  nodes[comps.id] = comps;
368964
369111
  pages2 = [...pages2, comps.id];
368965
369112
  }
368966
- return { document: { ...doc2, pages: pages2, nodes }, frameId: frame2.id, notes: [...imp.notes], layerNodes: imp.layerNodes };
369113
+ return { document: { ...doc2, pages: pages2, nodes }, frameId: frame3.id, notes: [...imp.notes], layerNodes: imp.layerNodes };
368967
369114
  }
368968
369115
  var GEOMETRY, BLENDS, nearestFps, first, clamp013, Importer;
368969
369116
  var init_import = __esm({
@@ -397523,10 +397670,10 @@ async function importPdf(bytes2, document2, pageId2, opts = {}) {
397523
397670
  const page = await pdf.getPage(p2);
397524
397671
  const vp = page.getViewport({ scale: PX_PER_PT });
397525
397672
  const base = vp.transform;
397526
- const frame2 = createFrame({ name: pdf.numPages > 1 ? `${opts.name ?? "PDF"} ${p2}` : opts.name ?? "PDF", x: cursorX, y: cursorY, width: Math.round(vp.width), height: Math.round(vp.height), fills: [createSolidPaint(createColor(1, 1, 1))], strokes: [], clipsContent: true });
397527
- doc2 = addNode(doc2, frame2, pageId2);
397528
- added.push(frame2.id);
397529
- cursorX += frame2.width + 120;
397673
+ const frame3 = createFrame({ name: pdf.numPages > 1 ? `${opts.name ?? "PDF"} ${p2}` : opts.name ?? "PDF", x: cursorX, y: cursorY, width: Math.round(vp.width), height: Math.round(vp.height), fills: [createSolidPaint(createColor(1, 1, 1))], strokes: [], clipsContent: true });
397674
+ doc2 = addNode(doc2, frame3, pageId2);
397675
+ added.push(frame3.id);
397676
+ cursorX += frame3.width + 120;
397530
397677
  const children = [];
397531
397678
  const textRuns2 = [];
397532
397679
  const ops2 = await page.getOperatorList();
@@ -397646,7 +397793,7 @@ async function importPdf(bytes2, document2, pageId2, opts = {}) {
397646
397793
  textAutoResize: "WIDTH_AND_HEIGHT"
397647
397794
  }));
397648
397795
  }
397649
- for (const c2 of children) doc2 = addNode(doc2, c2, frame2.id);
397796
+ for (const c2 of children) doc2 = addNode(doc2, c2, frame3.id);
397650
397797
  page.cleanup();
397651
397798
  }
397652
397799
  await pdf.cleanup();
@@ -397865,8 +398012,8 @@ async function buildImportedDocument(file2) {
397865
398012
  const pageId2 = base.pages[0];
397866
398013
  const placed2 = placeSvgLayers2(base, pageId2, await file2.text(), { name: seedName, cx: 0, cy: 0, intern: (url4) => internDataUrl2(url4) });
397867
398014
  if (!placed2) return null;
397868
- const frame2 = placed2.doc.nodes[placed2.id];
397869
- const document2 = { ...placed2.doc, nodes: { ...placed2.doc.nodes, [placed2.id]: { ...frame2, x: 0, y: 0 } } };
398015
+ const frame3 = placed2.doc.nodes[placed2.id];
398016
+ const document2 = { ...placed2.doc, nodes: { ...placed2.doc.nodes, [placed2.id]: { ...frame3, x: 0, y: 0 } } };
397870
398017
  return { document: document2, frameIds: [placed2.id] };
397871
398018
  }
397872
398019
  if (ext === ".json" || ext === ".popcraft" || ext === ".vizpops") {
@@ -400603,7 +400750,7 @@ __export(sandbox_exports, {
400603
400750
  recordInSandbox: () => recordInSandbox
400604
400751
  });
400605
400752
  function onMessage(e) {
400606
- if (!frame || e.source !== frame.contentWindow) return;
400753
+ if (!frame2 || e.source !== frame2.contentWindow) return;
400607
400754
  const d = e.data;
400608
400755
  if (d?.kind !== "recorded" || typeof d.id !== "number") return;
400609
400756
  const done = pending6.get(d.id);
@@ -400616,7 +400763,7 @@ function onMessage(e) {
400616
400763
  }
400617
400764
  }
400618
400765
  function ensureFrame() {
400619
- if (ready2 && frame?.isConnected) return ready2;
400766
+ if (ready2 && frame2?.isConnected) return ready2;
400620
400767
  window.removeEventListener("message", onMessage);
400621
400768
  window.addEventListener("message", onMessage);
400622
400769
  const el = document.createElement("iframe");
@@ -400624,7 +400771,7 @@ function ensureFrame() {
400624
400771
  el.setAttribute("aria-hidden", "true");
400625
400772
  el.tabIndex = -1;
400626
400773
  el.style.cssText = "position:fixed;width:0;height:0;border:0;opacity:0;pointer-events:none;inset-inline-start:-9999px";
400627
- frame = el;
400774
+ frame2 = el;
400628
400775
  ready2 = new Promise((resolve7) => {
400629
400776
  const hello = (e) => {
400630
400777
  if (e.source !== el.contentWindow || e.data?.kind !== "ready") return;
@@ -400638,8 +400785,8 @@ function ensureFrame() {
400638
400785
  return ready2;
400639
400786
  }
400640
400787
  function resetFrame() {
400641
- frame?.remove();
400642
- frame = null;
400788
+ frame2?.remove();
400789
+ frame2 = null;
400643
400790
  ready2 = null;
400644
400791
  }
400645
400792
  async function recordInSandbox(source3, namespaces2, globals) {
@@ -400655,10 +400802,10 @@ async function recordInSandbox(source3, namespaces2, globals) {
400655
400802
  clearTimeout(backstop);
400656
400803
  resolve7(r);
400657
400804
  });
400658
- frame.contentWindow.postMessage({ kind: "record", id: id3, source: source3, namespaces: [...namespaces2], globals: { ...globals }, limits: { ...RECORD_LIMITS2 } }, "*");
400805
+ frame2.contentWindow.postMessage({ kind: "record", id: id3, source: source3, namespaces: [...namespaces2], globals: { ...globals }, limits: { ...RECORD_LIMITS2 } }, "*");
400659
400806
  });
400660
400807
  }
400661
- var FRAME_SOURCE, frame, ready2, next, pending6;
400808
+ var FRAME_SOURCE, frame2, ready2, next, pending6;
400662
400809
  var init_sandbox = __esm({
400663
400810
  "lib/agent/design-script/sandbox.ts"() {
400664
400811
  "use strict";
@@ -400682,7 +400829,7 @@ window.addEventListener('message', e => {
400682
400829
  })
400683
400830
  parent.postMessage({ kind: 'ready' }, '*')
400684
400831
  </script>`;
400685
- frame = null;
400832
+ frame2 = null;
400686
400833
  ready2 = null;
400687
400834
  next = 0;
400688
400835
  pending6 = /* @__PURE__ */ new Map();
@@ -401749,8 +401896,8 @@ function createLoupe() {
401749
401896
  el.style.left = `${x2}px`;
401750
401897
  el.style.top = `${y}px`;
401751
401898
  },
401752
- show(patch, hex10) {
401753
- for (let i2 = 0; i2 < cells.length; i2++) cells[i2].style.background = patch.cells[i2] ?? "transparent";
401899
+ show(patch2, hex10) {
401900
+ for (let i2 = 0; i2 < cells.length; i2++) cells[i2].style.background = patch2.cells[i2] ?? "transparent";
401754
401901
  label3.textContent = hex10 ?? "transparent";
401755
401902
  el.style.opacity = "1";
401756
401903
  },
@@ -401789,10 +401936,10 @@ function beginEyedrop(onPreview) {
401789
401936
  busy = true;
401790
401937
  last3 = now2;
401791
401938
  const { x: x2, y } = worldAt(e);
401792
- void samplePatchAtWorld(x2, y, LOUPE_RADIUS).then((patch) => {
401793
- if (patch) {
401794
- loupe.show(patch, hexOf2(patch.center));
401795
- onPreview?.(patch.center);
401939
+ void samplePatchAtWorld(x2, y, LOUPE_RADIUS).then((patch2) => {
401940
+ if (patch2) {
401941
+ loupe.show(patch2, hexOf2(patch2.center));
401942
+ onPreview?.(patch2.center);
401796
401943
  }
401797
401944
  }).catch(() => {
401798
401945
  }).finally(() => {
@@ -403153,24 +403300,24 @@ function checkDesign(doc2, roots) {
403153
403300
  const issues = [];
403154
403301
  const kind = doc2.settings?.kind ?? "CANVAS";
403155
403302
  for (const id3 of roots) {
403156
- const frame2 = doc2.nodes[id3];
403157
- if (!frame2 || frame2.type !== "FRAME") continue;
403158
- const size6 = `${Math.round(frame2.width)}\xD7${Math.round(frame2.height)}`;
403159
- const preset = frame2.print?.presetId ?? presetOf(doc2, Math.round(frame2.width), Math.round(frame2.height));
403303
+ const frame3 = doc2.nodes[id3];
403304
+ if (!frame3 || frame3.type !== "FRAME") continue;
403305
+ const size6 = `${Math.round(frame3.width)}\xD7${Math.round(frame3.height)}`;
403306
+ const preset = frame3.print?.presetId ?? presetOf(doc2, Math.round(frame3.width), Math.round(frame3.height));
403160
403307
  const min2 = preset && PAGE_PRESETS.find((p2) => p2.id === preset)?.category === "SOCIAL" ? MIN_TEXT_PX.SOCIAL : MIN_TEXT_PX[kind];
403161
403308
  const texts = paintedTexts(doc2, [id3]);
403162
- const box2 = { x: 0, y: 0, width: frame2.width, height: frame2.height };
403163
- const safe2 = preset ? presetSafeRect(preset, frame2.width, frame2.height) : null;
403309
+ const box2 = { x: 0, y: 0, width: frame3.width, height: frame3.height };
403310
+ const safe2 = preset ? presetSafeRect(preset, frame3.width, frame3.height) : null;
403164
403311
  const add3 = (i2) => {
403165
403312
  if (issues.length < MAX_ISSUES) issues.push({ size: size6, ...i2 });
403166
403313
  };
403167
- if (frame2.height > MAX_FRAME_PX || frame2.width > MAX_FRAME_PX) add3({ kind: "too-tall", layer: frame2.name, message: `The frame is ${Math.round(frame2.width)}\xD7${Math.round(frame2.height)}: past ${MAX_FRAME_PX} px it renders blank in thumbnails and exports. Tighten spacing, condense lists and drop repeated sections at this size.` });
403314
+ if (frame3.height > MAX_FRAME_PX || frame3.width > MAX_FRAME_PX) add3({ kind: "too-tall", layer: frame3.name, message: `The frame is ${Math.round(frame3.width)}\xD7${Math.round(frame3.height)}: past ${MAX_FRAME_PX} px it renders blank in thumbnails and exports. Tighten spacing, condense lists and drop repeated sections at this size.` });
403168
403315
  const moving = (textId) => animatedUp(doc2, textId.split("::")[0], id3);
403169
403316
  const tilted = (textId) => tiltedUp(doc2, textId.split("::")[0], id3);
403170
403317
  const visibleTexts = texts.filter((t3) => !clippedAway(doc2, t3, id3));
403171
403318
  for (const t3 of visibleTexts) {
403172
- const r = { x: t3.x - frame2.x, y: t3.y - frame2.y, width: t3.width, height: t3.height };
403173
- const at4 = t3.x >= frame2.x - 1 && t3.y >= frame2.y - 1 ? r : { x: t3.x, y: t3.y, width: t3.width, height: t3.height };
403319
+ const r = { x: t3.x - frame3.x, y: t3.y - frame3.y, width: t3.width, height: t3.height };
403320
+ const at4 = t3.x >= frame3.x - 1 && t3.y >= frame3.y - 1 ? r : { x: t3.x, y: t3.y, width: t3.width, height: t3.height };
403174
403321
  if (t3.contrast < t3.required) add3({ kind: "contrast", layer: t3.name, message: `${label2(t3)} reads at ${t3.contrast.toFixed(1)}:1 against what is behind it; it needs ${t3.required}:1. Darken or lighten it, or give it a plate.` });
403175
403322
  if (t3.fontSize < min2) add3({ kind: "small-text", layer: t3.name, message: `${label2(t3)} is ${t3.fontSize}px; at this size text should be at least ${min2}px.` });
403176
403323
  const partly = overlaps2(box2, at4) && !contains(box2, at4);
@@ -403191,21 +403338,21 @@ function checkDesign(doc2, roots) {
403191
403338
  n.childIds.forEach(walkInst);
403192
403339
  };
403193
403340
  walkInst(id3);
403194
- const seam = seamJump(doc2, frame2);
403341
+ const seam = seamJump(doc2, frame3);
403195
403342
  if (seam) add3({ kind: "seam", layer: seam.layer, message: seam.message });
403196
- const band = emptyBand(doc2, frame2);
403197
- if (band) add3({ kind: "empty-band", layer: frame2.name, message: band });
403343
+ const band = emptyBand(doc2, frame3);
403344
+ if (band) add3({ kind: "empty-band", layer: frame3.name, message: band });
403198
403345
  }
403199
403346
  return issues;
403200
403347
  }
403201
- function seamJump(doc2, frame2) {
403202
- const tl = frame2.timeline;
403203
- if (!tl || tl.audio?.length || tl.duration <= 0 || frame2.print?.transition || doc2.settings?.kind === "PRESENTATION") return null;
403204
- if (Object.values(doc2.compositions ?? {}).some((c2) => c2.clips.some((clip) => clip.frameId === frame2.id))) return null;
403205
- const end = tl.workArea ? tl.workArea[1] : timelineDuration(doc2.nodes, frame2.id);
403348
+ function seamJump(doc2, frame3) {
403349
+ const tl = frame3.timeline;
403350
+ if (!tl || tl.audio?.length || tl.duration <= 0 || frame3.print?.transition || doc2.settings?.kind === "PRESENTATION") return null;
403351
+ if (Object.values(doc2.compositions ?? {}).some((c2) => c2.clips.some((clip) => clip.frameId === frame3.id))) return null;
403352
+ const end = tl.workArea ? tl.workArea[1] : timelineDuration(doc2.nodes, frame3.id);
403206
403353
  const start2 = tl.workArea ? tl.workArea[0] : 0;
403207
403354
  const shown2 = (ms2) => {
403208
- const posed2 = evaluatePose(doc2.nodes, { kind: "frame", frameId: frame2.id }, ms2).nodes;
403355
+ const posed2 = evaluatePose(doc2.nodes, { kind: "frame", frameId: frame3.id }, ms2).nodes;
403209
403356
  const out = /* @__PURE__ */ new Map();
403210
403357
  const walk4 = (id3, alpha2, maskedIn = false) => {
403211
403358
  let hidden2 = maskedIn;
@@ -403227,7 +403374,7 @@ function seamJump(doc2, frame2) {
403227
403374
  walk4(c2, a2, hidden2);
403228
403375
  }
403229
403376
  };
403230
- walk4(frame2.id, 1);
403377
+ walk4(frame3.id, 1);
403231
403378
  return out;
403232
403379
  };
403233
403380
  const a = shown2(start2), b = shown2(end);
@@ -403268,8 +403415,8 @@ function animatedUp(doc2, id3, frameId) {
403268
403415
  }
403269
403416
  return false;
403270
403417
  }
403271
- function emptyBand(doc2, frame2) {
403272
- const H = Math.round(frame2.height), W = frame2.width;
403418
+ function emptyBand(doc2, frame3) {
403419
+ const H = Math.round(frame3.height), W = frame3.width;
403273
403420
  if (H < 200) return null;
403274
403421
  const filled2 = new Uint8Array(H);
403275
403422
  const walk4 = (id3, ox, oy, depth) => {
@@ -403282,7 +403429,7 @@ function emptyBand(doc2, frame2) {
403282
403429
  }
403283
403430
  for (const c2 of n.childIds) walk4(c2, x2, y, depth + 1);
403284
403431
  };
403285
- walk4(frame2.id, 0, 0, 0);
403432
+ walk4(frame3.id, 0, 0, 0);
403286
403433
  let best = 0, at4 = 0, run4 = 0;
403287
403434
  for (let r = 0; r <= H; r++) {
403288
403435
  if (r < H && !filled2[r]) {
@@ -404195,13 +404342,13 @@ var init_site3 = __esm({
404195
404342
  const patches = /* @__PURE__ */ new Map();
404196
404343
  for (const id3 of ids2) {
404197
404344
  let node2 = doc2.nodes[id3];
404198
- let patch = {};
404345
+ let patch2 = {};
404199
404346
  if (args2.reset) {
404200
- patch = resetOverrides(node2, args2.breakpoint, args2.reset === "all" ? void 0 : args2.reset);
404201
- node2 = { ...node2, ...patch };
404347
+ patch2 = resetOverrides(node2, args2.breakpoint, args2.reset === "all" ? void 0 : args2.reset);
404348
+ node2 = { ...node2, ...patch2 };
404202
404349
  }
404203
- if (args2.set) patch = { ...patch, ...breakpointPatch(node2, doc2, args2.breakpoint, args2.set) };
404204
- patches.set(id3, patch);
404350
+ if (args2.set) patch2 = { ...patch2, ...breakpointPatch(node2, doc2, args2.breakpoint, args2.set) };
404351
+ patches.set(id3, patch2);
404205
404352
  }
404206
404353
  commitUpdates(ctx2, doc2, patches);
404207
404354
  const names = ids2.map((id3) => doc2.nodes[id3].name).slice(0, 3).join(", ");
@@ -404354,14 +404501,14 @@ var init_site3 = __esm({
404354
404501
  run: (args2, ctx2) => {
404355
404502
  const { doc: doc2, ids: ids2 } = resolveTargets(ctx2, args2.id ? [args2.id] : void 0, "set_route");
404356
404503
  const id3 = ids2[0];
404357
- const frame2 = doc2.nodes[id3];
404358
- if (frame2.type !== "FRAME" || doc2.nodes[frame2.parentId ?? ""]?.type !== "PAGE") throw new ToolError(`"${frame2.name}" is not a top-level frame: only a screen has an address.`);
404504
+ const frame3 = doc2.nodes[id3];
404505
+ if (frame3.type !== "FRAME" || doc2.nodes[frame3.parentId ?? ""]?.type !== "PAGE") throw new ToolError(`"${frame3.name}" is not a top-level frame: only a screen has an address.`);
404359
404506
  const path = args2.path ? cleanPath(args2.path) : args2.path;
404360
404507
  if (path) {
404361
- const other = Object.values(doc2.nodes).find((n) => n.id !== id3 && n.parentId === frame2.parentId && n.route?.path && cleanPath(n.route.path) === path);
404508
+ const other = Object.values(doc2.nodes).find((n) => n.id !== id3 && n.parentId === frame3.parentId && n.route?.path && cleanPath(n.route.path) === path);
404362
404509
  if (other) throw new ToolError(`${path} is already "${other.name}".`);
404363
404510
  }
404364
- const next2 = { ...frame2.route };
404511
+ const next2 = { ...frame3.route };
404365
404512
  const put3 = (key5, value3) => {
404366
404513
  if (value3 === void 0) return;
404367
404514
  if (value3 === null || value3 === false || value3 === "") delete next2[key5];
@@ -404377,7 +404524,7 @@ var init_site3 = __esm({
404377
404524
  put3("access", args2.access);
404378
404525
  put3("collectionId", args2.collectionId);
404379
404526
  commitUpdates(ctx2, doc2, /* @__PURE__ */ new Map([[id3, { route: Object.keys(next2).length ? next2 : void 0 }]]));
404380
- return { summary: `${frame2.name}: ${path ?? "automatic address"}`, data: { id: id3, route: next2 } };
404527
+ return { summary: `${frame3.name}: ${path ?? "automatic address"}`, data: { id: id3, route: next2 } };
404381
404528
  }
404382
404529
  });
404383
404530
  breakpoint = external_exports.object({
@@ -405476,8 +405623,8 @@ var init_presentation_audio = __esm({
405476
405623
  run: async (args2, ctx2) => {
405477
405624
  const page = pageOf3(ctx2, args2.pageId);
405478
405625
  let base = ctx2.doc();
405479
- const patch = settingsOf(args2);
405480
- if (Object.keys(patch).length || !soundtrackOf(base, page)) base = doc(() => configure(base, page, patch));
405626
+ const patch2 = settingsOf(args2);
405627
+ if (Object.keys(patch2).length || !soundtrackOf(base, page)) base = doc(() => configure(base, page, patch2));
405481
405628
  const view2 = readDeck(base, page);
405482
405629
  const what = args2.what ?? "all";
405483
405630
  let frameIds = args2.slides;
@@ -405493,7 +405640,7 @@ var init_presentation_audio = __esm({
405493
405640
  throw new ToolError(result.errors[0]?.message ?? "Nothing was made.");
405494
405641
  }
405495
405642
  let latest = ctx2.doc();
405496
- if (Object.keys(patch).length || !soundtrackOf(latest, page)) latest = doc(() => configure(latest, page, patch));
405643
+ if (Object.keys(patch2).length || !soundtrackOf(latest, page)) latest = doc(() => configure(latest, page, patch2));
405497
405644
  const applied = doc(() => applyGeneration(latest, page, result));
405498
405645
  const { doc: next2, mix: mix4 } = await withMixTrim(applied, page);
405499
405646
  ctx2.commit(next2);
@@ -406566,7 +406713,7 @@ function generateStressDocument(opts = {}) {
406566
406713
  for (let f2 = 0; f2 < frames; f2++) {
406567
406714
  const col3 = f2 % cols;
406568
406715
  const row2 = Math.floor(f2 / cols);
406569
- const frame2 = createFrame({
406716
+ const frame3 = createFrame({
406570
406717
  name: `Screen ${f2 + 1}`,
406571
406718
  x: col3 * (FRAME_W + GAP),
406572
406719
  y: row2 * (FRAME_H + GAP),
@@ -406585,7 +406732,7 @@ function generateStressDocument(opts = {}) {
406585
406732
  width: 156,
406586
406733
  height: 88,
406587
406734
  cornerRadius: 12,
406588
- parentId: frame2.id,
406735
+ parentId: frame3.id,
406589
406736
  fills: [{ type: "SOLID", visible: true, opacity: 1, color: hslToRgb2(hue, 0.55, 0.62) }]
406590
406737
  });
406591
406738
  nodes[r.id] = r;
@@ -406598,7 +406745,7 @@ function generateStressDocument(opts = {}) {
406598
406745
  y: 24 + Math.floor(i2 / 2) * 100,
406599
406746
  width: 40,
406600
406747
  height: 40,
406601
- parentId: frame2.id
406748
+ parentId: frame3.id
406602
406749
  });
406603
406750
  nodes[e.id] = e;
406604
406751
  childIds.push(e.id);
@@ -406614,14 +406761,14 @@ function generateStressDocument(opts = {}) {
406614
406761
  width: 140,
406615
406762
  height: i2 === 0 ? 30 : 18,
406616
406763
  textAutoResize: "HEIGHT",
406617
- parentId: frame2.id
406764
+ parentId: frame3.id
406618
406765
  });
406619
406766
  nodes[t3.id] = t3;
406620
406767
  childIds.push(t3.id);
406621
406768
  }
406622
- frame2.childIds = childIds;
406623
- nodes[frame2.id] = frame2;
406624
- page.childIds.push(frame2.id);
406769
+ frame3.childIds = childIds;
406770
+ nodes[frame3.id] = frame3;
406771
+ page.childIds.push(frame3.id);
406625
406772
  }
406626
406773
  return { ...doc2, nodes };
406627
406774
  }
@@ -407419,9 +407566,9 @@ var init_editor_store = __esm({
407419
407566
  set4((st) => ({ document: { ...st.document, thumbnailNodeId: nodeId2 || void 0 } }));
407420
407567
  if (typeof window !== "undefined") window.dispatchEvent(new CustomEvent("popcraft-thumbnail-now"));
407421
407568
  },
407422
- setDocumentSettings: (patch) => {
407569
+ setDocumentSettings: (patch2) => {
407423
407570
  const { document: document2, recordState, commitState } = get4();
407424
- const settings = { ...document2.settings, ...patch };
407571
+ const settings = { ...document2.settings, ...patch2 };
407425
407572
  for (const k2 of Object.keys(settings)) if (settings[k2] === void 0) delete settings[k2];
407426
407573
  recordState("property", "Document settings");
407427
407574
  set4({ document: { ...document2, settings: Object.keys(settings).length ? settings : void 0 } });
@@ -407435,13 +407582,13 @@ var init_editor_store = __esm({
407435
407582
  set4({ document: next2 });
407436
407583
  commitState("Page setup");
407437
407584
  },
407438
- applyParagraphFormat: (nodeId2, patch) => {
407585
+ applyParagraphFormat: (nodeId2, patch2) => {
407439
407586
  const state = get4();
407440
407587
  const node2 = state.document.nodes[nodeId2];
407441
407588
  if (!node2 || node2.type !== "TEXT") return;
407442
407589
  const te2 = state.textEditState;
407443
407590
  const range3 = te2 && te2.nodeId === nodeId2 ? { start: Math.min(te2.cursor, te2.anchor), end: Math.max(te2.cursor, te2.anchor) } : null;
407444
- state.updateNodeProps(nodeId2, { paragraphs: withParagraphFormat(node2, range3, patch) });
407591
+ state.updateNodeProps(nodeId2, { paragraphs: withParagraphFormat(node2, range3, patch2) });
407445
407592
  },
407446
407593
  linkTextFrames: (fromId, toId) => {
407447
407594
  const state = get4();
@@ -407516,11 +407663,11 @@ var init_editor_store = __esm({
407516
407663
  const id3 = s.activePrototypeFrameId;
407517
407664
  if (!id3) return;
407518
407665
  s.focusOnNode(id3);
407519
- const frame2 = s.document.nodes[id3];
407520
- const cell = frame2?.pixelPerfect ? screenPixelCell(s.document, id3) : null;
407521
- if (frame2 && cell) {
407666
+ const frame3 = s.document.nodes[id3];
407667
+ const cell = frame3?.pixelPerfect ? screenPixelCell(s.document, id3) : null;
407668
+ if (frame3 && cell) {
407522
407669
  const t3 = getWorldTransform(s.document, id3);
407523
- set4({ camera: pixelPerfectCamera(canvasViewport(), { x: t3.cx - frame2.width / 2, y: t3.cy - frame2.height / 2, width: frame2.width, height: frame2.height }, cell) });
407670
+ set4({ camera: pixelPerfectCamera(canvasViewport(), { x: t3.cx - frame3.width / 2, y: t3.cy - frame3.height / 2, width: frame3.width, height: frame3.height }, cell) });
407524
407671
  }
407525
407672
  return;
407526
407673
  }
@@ -407643,10 +407790,10 @@ var init_editor_store = __esm({
407643
407790
  let document2 = st.document;
407644
407791
  targets.forEach((t3, i2) => {
407645
407792
  const p2 = pasted[i2 % pasted.length];
407646
- const patch = { x: t3.x, y: t3.y, width: t3.width, height: t3.height, rotation: t3.rotation };
407647
- document2 = updateNode(document2, p2.id, patch);
407793
+ const patch2 = { x: t3.x, y: t3.y, width: t3.width, height: t3.height, rotation: t3.rotation };
407794
+ document2 = updateNode(document2, p2.id, patch2);
407648
407795
  if (t3.parentId && p2.parentId !== t3.parentId) document2 = reparentNode(document2, p2.id, t3.parentId, (document2.nodes[t3.parentId]?.childIds.indexOf(t3.id) ?? -1) + 1);
407649
- if (i2 >= pasted.length) document2 = updateNode(document2, p2.id, patch);
407796
+ if (i2 >= pasted.length) document2 = updateNode(document2, p2.id, patch2);
407650
407797
  });
407651
407798
  for (const t3 of targets) document2 = removeNode(document2, t3.id);
407652
407799
  return { document: document2, selection: pasted.map((p2) => p2.id) };
@@ -407666,8 +407813,8 @@ var init_editor_store = __esm({
407666
407813
  navigatePrototype: (action3, firedOn, key5) => {
407667
407814
  const before = runtimeOf(get4());
407668
407815
  const step3 = runAction(before, action3, { driver: presentDriver, now: performance.now(), firedOn, key: key5, reducedMotion: prefersReducedMotion() });
407669
- const patch = storePatch(before, step3.state);
407670
- if (patch) set4(patch);
407816
+ const patch2 = storePatch(before, step3.state);
407817
+ if (patch2) set4(patch2);
407671
407818
  const run4 = (effects) => {
407672
407819
  for (const e of effects) {
407673
407820
  if (e.kind === "arrived") {
@@ -407690,16 +407837,16 @@ var init_editor_store = __esm({
407690
407837
  },
407691
407838
  setPrototypeScroll: (nodeId2, deltaX, deltaY) => {
407692
407839
  const before = runtimeOf(get4());
407693
- const patch = storePatch(before, scrollBy(before, nodeId2, deltaX, deltaY));
407694
- if (patch) set4(patch);
407840
+ const patch2 = storePatch(before, scrollBy(before, nodeId2, deltaX, deltaY));
407841
+ if (patch2) set4(patch2);
407695
407842
  },
407696
407843
  // Comment actions
407697
407844
  addComment: (comment) => set4((state) => ({
407698
407845
  comments: [...state.comments, comment]
407699
407846
  })),
407700
- updateComment: (commentId, patch) => set4((state) => ({
407847
+ updateComment: (commentId, patch2) => set4((state) => ({
407701
407848
  comments: state.comments.map(
407702
- (c2) => c2.id === commentId ? { ...c2, ...patch, updatedAt: Date.now() } : c2
407849
+ (c2) => c2.id === commentId ? { ...c2, ...patch2, updatedAt: Date.now() } : c2
407703
407850
  )
407704
407851
  })),
407705
407852
  deleteComment: (commentId) => set4((state) => ({
@@ -408811,10 +408958,10 @@ var init_editor_store = __esm({
408811
408958
  set4((st) => {
408812
408959
  let document2 = st.document;
408813
408960
  for (let i2 = 0; i2 < count2; i2++) {
408814
- const frame2 = createPrintPage(document2, st.currentPageId, { preset });
408815
- document2 = addNode(document2, frame2, st.currentPageId);
408816
- made.push(frame2.id);
408817
- const folds = foldGuidesAt(preset, frame2);
408961
+ const frame3 = createPrintPage(document2, st.currentPageId, { preset });
408962
+ document2 = addNode(document2, frame3, st.currentPageId);
408963
+ made.push(frame3.id);
408964
+ const folds = foldGuidesAt(preset, frame3);
408818
408965
  if (folds.length) {
408819
408966
  const page = document2.nodes[st.currentPageId];
408820
408967
  document2 = { ...document2, nodes: { ...document2.nodes, [st.currentPageId]: { ...page, guides: [...page.guides ?? [], ...folds] } } };
@@ -408836,10 +408983,10 @@ var init_editor_store = __esm({
408836
408983
  let document2 = st.document;
408837
408984
  const pageId2 = st.currentPageId;
408838
408985
  for (const id3 of ids2) {
408839
- const frame2 = document2.nodes[id3];
408840
- if (!frame2 || frame2.type !== "FRAME") continue;
408986
+ const frame3 = document2.nodes[id3];
408987
+ if (!frame3 || frame3.type !== "FRAME") continue;
408841
408988
  const page = document2.nodes[pageId2];
408842
- const stale = new Set(foldsOn(page.guides, frame2).map((g) => g.id));
408989
+ const stale = new Set(foldsOn(page.guides, frame3).map((g) => g.id));
408843
408990
  document2 = updateNode(document2, id3, { width: size6.width, height: size6.height });
408844
408991
  const resized = document2.nodes[id3];
408845
408992
  const guides = [...(page.guides ?? []).filter((g) => !stale.has(g.id)), ...foldGuidesAt(preset, resized)];
@@ -408865,12 +409012,12 @@ var init_editor_store = __esm({
408865
409012
  },
408866
409013
  addMasterPage: () => {
408867
409014
  const state = get4();
408868
- const frame2 = createMasterPage(state.document, state.currentPageId);
409015
+ const frame3 = createMasterPage(state.document, state.currentPageId);
408869
409016
  state.recordState("add", "Add master");
408870
- set4((st) => ({ document: addNode(st.document, frame2, st.currentPageId), selection: [frame2.id] }));
409017
+ set4((st) => ({ document: addNode(st.document, frame3, st.currentPageId), selection: [frame3.id] }));
408871
409018
  state.commitState("Add master");
408872
- get4().zoomToNodes([frame2.id], 0.1);
408873
- return frame2.id;
409019
+ get4().zoomToNodes([frame3.id], 0.1);
409020
+ return frame3.id;
408874
409021
  },
408875
409022
  setPageMaster: (pageIds, masterId) => {
408876
409023
  const state = get4();
@@ -410185,14 +410332,14 @@ var init_editor_store = __esm({
410185
410332
  const textEdit = state.textEditState;
410186
410333
  const charsLength = (node2.characters ?? "").length;
410187
410334
  const isFullSelection = !textEdit || textEdit.nodeId !== nodeId2 || textEdit.cursor === textEdit.anchor || Math.min(textEdit.cursor, textEdit.anchor) === 0 && Math.max(textEdit.cursor, textEdit.anchor) === charsLength;
410188
- let patch;
410335
+ let patch2;
410189
410336
  if (isFullSelection) {
410190
410337
  const segments = (node2.styledSegments ?? []).map((seg) => {
410191
410338
  const next2 = { ...seg };
410192
410339
  for (const key5 of Object.keys(styles)) delete next2[key5];
410193
410340
  return next2;
410194
410341
  }).filter((seg) => Object.keys(seg).length > 2);
410195
- patch = { ...styles, ...node2.styledSegments ? { styledSegments: segments } : {} };
410342
+ patch2 = { ...styles, ...node2.styledSegments ? { styledSegments: segments } : {} };
410196
410343
  } else {
410197
410344
  const start2 = Math.min(textEdit.cursor, textEdit.anchor);
410198
410345
  const end = Math.max(textEdit.cursor, textEdit.anchor);
@@ -410213,9 +410360,9 @@ var init_editor_store = __esm({
410213
410360
  });
410214
410361
  if (gapStart < end) punched.push({ start: gapStart, end, ...styles });
410215
410362
  punched.sort((a, b) => a.start - b.start);
410216
- patch = { styledSegments: punched };
410363
+ patch2 = { styledSegments: punched };
410217
410364
  }
410218
- get4().updateNodeProps(nodeId2, patch);
410365
+ get4().updateNodeProps(nodeId2, patch2);
410219
410366
  get4().recordState("APPLY_TEXT_STYLE", "Apply text style");
410220
410367
  if (typeof window !== "undefined") {
410221
410368
  window.dispatchEvent(new CustomEvent("popcraft-resync-text", { detail: { nodeId: nodeId2 } }));
@@ -410231,12 +410378,12 @@ var init_editor_store = __esm({
410231
410378
  return { document: updateNode(state.document, nodeId2, { interactions }) };
410232
410379
  });
410233
410380
  },
410234
- updateInteraction: (nodeId2, interactionId, patch) => {
410381
+ updateInteraction: (nodeId2, interactionId, patch2) => {
410235
410382
  set4((state) => {
410236
410383
  const node2 = state.document.nodes[nodeId2];
410237
410384
  if (!node2) return {};
410238
410385
  const interactions = (node2.interactions ?? []).map(
410239
- (ix) => ix.id === interactionId ? { ...ix, ...patch } : ix
410386
+ (ix) => ix.id === interactionId ? { ...ix, ...patch2 } : ix
410240
410387
  );
410241
410388
  return { document: updateNode(state.document, nodeId2, { interactions }) };
410242
410389
  });
@@ -410300,7 +410447,7 @@ var init_editor_store = __esm({
410300
410447
  const command = createCommand("CREATE_VARIABLE", "Create variable", documentBefore, documentAfter);
410301
410448
  set4({ document: documentAfter, history: pushCommand(state.history, command) });
410302
410449
  },
410303
- updateVariable: (variableId, patch) => {
410450
+ updateVariable: (variableId, patch2) => {
410304
410451
  const state = get4();
410305
410452
  if (!state.document.variables?.[variableId]) return;
410306
410453
  const documentBefore = state.document;
@@ -410310,7 +410457,7 @@ var init_editor_store = __esm({
410310
410457
  ...state.document.variables,
410311
410458
  [variableId]: {
410312
410459
  ...state.document.variables[variableId],
410313
- ...patch
410460
+ ...patch2
410314
410461
  }
410315
410462
  }
410316
410463
  };
@@ -413357,7 +413504,7 @@ init_resources();
413357
413504
  init_desktop();
413358
413505
  init_hypery();
413359
413506
  import { createInterface } from "node:readline";
413360
- var VERSION2 = "0.43.1";
413507
+ var VERSION2 = "0.44.0";
413361
413508
  var HELP = `popcraft ${VERSION2} \u2014 the PopCraft command line
413362
413509
 
413363
413510
  Files (headless, on .popcraft files):