@lace-cloud/canvas 0.14.0 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -59,12 +59,12 @@ __export(index_exports, {
59
59
  Toast: () => import_feedback2.Toast,
60
60
  UnifiedSettingsPanel: () => UnifiedSettingsPanel,
61
61
  ValidationErrorBanner: () => ValidationErrorBanner,
62
- projectCanvasView: () => import_proto4.projectCanvasView,
62
+ projectCanvasView: () => import_proto7.projectCanvasView,
63
63
  useCanvas: () => useCanvas,
64
64
  useEngine: () => useEngine
65
65
  });
66
66
  module.exports = __toCommonJS(index_exports);
67
- var import_proto4 = require("@lace-cloud/proto");
67
+ var import_proto7 = require("@lace-cloud/proto");
68
68
  var import_feedback2 = require("@lace-cloud/ui/feedback");
69
69
 
70
70
  // src/App.tsx
@@ -328,8 +328,8 @@ var CanvasContext = (0, import_react3.createContext)({
328
328
  },
329
329
  engine: null,
330
330
  readOnly: false,
331
- localGroupCollapseOverrides: {},
332
- toggleLocalGroupCollapse: () => {
331
+ arrangement: {},
332
+ updateArrangement: () => {
333
333
  }
334
334
  });
335
335
  function useCanvas() {
@@ -341,6 +341,113 @@ function useEngine() {
341
341
  return engine;
342
342
  }
343
343
 
344
+ // src/utils/arrangement.ts
345
+ var import_proto = require("@lace-cloud/proto");
346
+ function splitCanvasPath(canvasPath) {
347
+ const lastDot = canvasPath.lastIndexOf(".");
348
+ if (lastDot === -1) return { parentPath: "", localId: canvasPath };
349
+ return { parentPath: canvasPath.slice(0, lastDot), localId: canvasPath.slice(lastDot + 1) };
350
+ }
351
+ function scopeKeyForCanvasPath(bundle, canvasPath) {
352
+ const { parentPath } = splitCanvasPath(canvasPath);
353
+ return (0, import_proto.resolveScopePath)(bundle, parentPath);
354
+ }
355
+ function cloneArrangement(arrangement) {
356
+ const next = {};
357
+ for (const [scope, entry] of Object.entries(arrangement)) {
358
+ next[scope] = {
359
+ nodes: entry.nodes ? { ...entry.nodes } : void 0,
360
+ groups: entry.groups ? { ...entry.groups } : void 0
361
+ };
362
+ }
363
+ return next;
364
+ }
365
+ function withNodePosition(bundle, arrangement, canvasPath, position) {
366
+ const scopeKey = scopeKeyForCanvasPath(bundle, canvasPath);
367
+ if (!scopeKey) return arrangement;
368
+ const { localId } = splitCanvasPath(canvasPath);
369
+ const next = cloneArrangement(arrangement);
370
+ const scopeEntry = next[scopeKey] ?? {};
371
+ next[scopeKey] = { ...scopeEntry, nodes: { ...scopeEntry.nodes, [localId]: position } };
372
+ return next;
373
+ }
374
+ function withNodePositions(bundle, arrangement, positions) {
375
+ let next = arrangement;
376
+ for (const [canvasPath, position] of Object.entries(positions)) {
377
+ next = withNodePosition(bundle, next, canvasPath, position);
378
+ }
379
+ return next;
380
+ }
381
+ function withGroupArrangement(bundle, arrangement, canvasPath, patch) {
382
+ const scopeKey = scopeKeyForCanvasPath(bundle, canvasPath);
383
+ if (!scopeKey) return arrangement;
384
+ const { localId } = splitCanvasPath(canvasPath);
385
+ const next = cloneArrangement(arrangement);
386
+ const scopeEntry = next[scopeKey] ?? {};
387
+ const existing = scopeEntry.groups?.[localId];
388
+ next[scopeKey] = {
389
+ ...scopeEntry,
390
+ groups: {
391
+ ...scopeEntry.groups,
392
+ [localId]: {
393
+ collapsed: patch.collapsed ?? existing?.collapsed ?? true,
394
+ label: patch.label ?? existing?.label
395
+ }
396
+ }
397
+ };
398
+ return next;
399
+ }
400
+ function setScopeEntry(arrangement, scopeKey, entry) {
401
+ const next = cloneArrangement(arrangement);
402
+ next[scopeKey] = entry;
403
+ return next;
404
+ }
405
+ function migrateUngroup(bundle, arrangement, groupCanvasPath, groupModuleKey, promoted = []) {
406
+ const parentScopeKey = scopeKeyForCanvasPath(bundle, groupCanvasPath);
407
+ const groupEntry = arrangement[groupModuleKey];
408
+ if (!parentScopeKey || !groupEntry) return arrangement;
409
+ const { localId } = splitCanvasPath(groupCanvasPath);
410
+ const parentEntry = arrangement[parentScopeKey] ?? {};
411
+ const remainingGroups = parentEntry.groups ? { ...parentEntry.groups } : void 0;
412
+ if (remainingGroups) delete remainingGroups[localId];
413
+ const renameMap = new Map(
414
+ promoted.filter((ref) => ref.scope === parentScopeKey && ref.sourceId).map((ref) => [ref.sourceId, ref.id])
415
+ );
416
+ const rename = (id) => renameMap.get(id) ?? id;
417
+ const migratedNodes = groupEntry.nodes ? Object.fromEntries(Object.entries(groupEntry.nodes).map(([id, pos]) => [rename(id), pos])) : void 0;
418
+ const migratedGroups = groupEntry.groups ? Object.fromEntries(Object.entries(groupEntry.groups).map(([id, g]) => [rename(id), g])) : void 0;
419
+ const groups = remainingGroups || migratedGroups ? { ...remainingGroups, ...migratedGroups } : void 0;
420
+ return setScopeEntry(arrangement, parentScopeKey, {
421
+ nodes: { ...parentEntry.nodes, ...migratedNodes },
422
+ groups
423
+ });
424
+ }
425
+ function gcArrangement(bundle, arrangement) {
426
+ const next = {};
427
+ let changed = false;
428
+ for (const [scopeKey, entry] of Object.entries(arrangement)) {
429
+ const mod = bundle.modules[scopeKey];
430
+ if (!mod) {
431
+ changed = true;
432
+ continue;
433
+ }
434
+ const liveIds = new Set((mod.modules ?? []).map((u) => u.id));
435
+ const nodeEntries = entry.nodes ? Object.entries(entry.nodes) : [];
436
+ const liveNodeEntries = nodeEntries.filter(([id]) => liveIds.has(id));
437
+ const groupEntries = entry.groups ? Object.entries(entry.groups) : [];
438
+ const liveGroupEntries = groupEntries.filter(([id]) => liveIds.has(id));
439
+ if (liveNodeEntries.length !== nodeEntries.length || liveGroupEntries.length !== groupEntries.length) {
440
+ changed = true;
441
+ }
442
+ const nodes = entry.nodes ? Object.fromEntries(liveNodeEntries) : void 0;
443
+ const groups = entry.groups ? Object.fromEntries(liveGroupEntries) : void 0;
444
+ if (nodes && Object.keys(nodes).length > 0 || groups && Object.keys(groups).length > 0) {
445
+ next[scopeKey] = { nodes, groups };
446
+ }
447
+ }
448
+ return changed ? next : arrangement;
449
+ }
450
+
344
451
  // src/components/nodes/GroupNode.tsx
345
452
  var import_GroupNode = require("./GroupNode-EY63N53G.css");
346
453
  var import_jsx_runtime4 = require("react/jsx-runtime");
@@ -465,7 +572,7 @@ var AggregatedPinRow = ({ pin, top }) => {
465
572
  };
466
573
  var GroupNode = ({ data }) => {
467
574
  const engine = useEngine();
468
- const { readOnly, toggleLocalGroupCollapse } = useCanvas();
575
+ const { readOnly, arrangement, updateArrangement } = useCanvas();
469
576
  const [editing, setEditing] = (0, import_react5.useState)(false);
470
577
  const [editValue, setEditValue] = (0, import_react5.useState)(data.label);
471
578
  const [hovered, setHovered] = (0, import_react5.useState)(false);
@@ -486,17 +593,16 @@ var GroupNode = ({ data }) => {
486
593
  },
487
594
  [data.label, readOnly]
488
595
  );
489
- const commitRename = (0, import_react5.useCallback)(async () => {
596
+ const commitRename = (0, import_react5.useCallback)(() => {
490
597
  setEditing(false);
491
598
  const trimmed = editValue.trim();
492
- if (trimmed && trimmed !== data.label) {
493
- try {
494
- await engine.updateGroup(data.groupId, { label: trimmed });
495
- } catch (err) {
496
- console.error("[GroupNode] rename failed:", err);
497
- }
599
+ const bundle = engine.getCurrentBundle();
600
+ if (trimmed && trimmed !== data.label && bundle) {
601
+ updateArrangement(
602
+ withGroupArrangement(bundle, arrangement, data.groupId, { label: trimmed })
603
+ );
498
604
  }
499
- }, [editValue, data.label, data.groupId, engine]);
605
+ }, [editValue, data.label, data.groupId, engine, arrangement, updateArrangement]);
500
606
  const onKeyDown = (0, import_react5.useCallback)(
501
607
  (e) => {
502
608
  e.stopPropagation();
@@ -506,30 +612,32 @@ var GroupNode = ({ data }) => {
506
612
  [commitRename]
507
613
  );
508
614
  const toggleCollapsed = (0, import_react5.useCallback)(
509
- async (e) => {
615
+ (e) => {
510
616
  e.stopPropagation();
511
- if (readOnly) {
512
- toggleLocalGroupCollapse(data.groupId, data.collapsed);
513
- return;
514
- }
515
- try {
516
- await engine.updateGroup(data.groupId, { collapsed: !data.collapsed });
517
- } catch (err) {
518
- console.error("[GroupNode] toggle collapsed failed:", err);
519
- }
617
+ const bundle = engine.getCurrentBundle();
618
+ if (!bundle) return;
619
+ updateArrangement(
620
+ withGroupArrangement(bundle, arrangement, data.groupId, { collapsed: !data.collapsed })
621
+ );
520
622
  },
521
- [engine, data.groupId, data.collapsed, readOnly, toggleLocalGroupCollapse]
623
+ [engine, data.groupId, data.collapsed, arrangement, updateArrangement]
522
624
  );
523
625
  const onUngroup = (0, import_react5.useCallback)(
524
626
  async (e) => {
525
627
  e.stopPropagation();
628
+ const bundle = engine.getCurrentBundle();
526
629
  try {
527
- await engine.deleteGroup(data.groupId);
630
+ const result = await engine.ungroup(data.groupId);
631
+ if (result.success && bundle) {
632
+ updateArrangement(
633
+ migrateUngroup(bundle, arrangement, data.groupId, data.moduleKey, result.created)
634
+ );
635
+ }
528
636
  } catch (err) {
529
637
  console.error("[GroupNode] ungroup failed:", err);
530
638
  }
531
639
  },
532
- [engine, data.groupId]
640
+ [engine, data.groupId, data.moduleKey, arrangement, updateArrangement]
533
641
  );
534
642
  const headerProps = {
535
643
  label: data.label,
@@ -1707,6 +1815,7 @@ function PredicateRow({ predicate }) {
1707
1815
  }
1708
1816
 
1709
1817
  // src/components/panels/RegistryBrowser.tsx
1818
+ var import_proto2 = require("@lace-cloud/proto");
1710
1819
  var import_ui4 = require("@lace-cloud/ui");
1711
1820
  var import_react11 = require("react");
1712
1821
  var import_RegistryBrowser = require("./RegistryBrowser-3G22I4EO.css");
@@ -1718,7 +1827,7 @@ function RegistryBrowser({
1718
1827
  showToast,
1719
1828
  onClose
1720
1829
  }) {
1721
- const { readOnly } = useCanvas();
1830
+ const { readOnly, arrangement, updateArrangement } = useCanvas();
1722
1831
  const [modules, setModules] = (0, import_react11.useState)([]);
1723
1832
  const [loading, setLoading] = (0, import_react11.useState)(true);
1724
1833
  const [error, setError] = (0, import_react11.useState)(null);
@@ -1783,6 +1892,23 @@ function RegistryBrowser({
1783
1892
  if (!result.success) {
1784
1893
  showToast(result.errors[0]?.message ?? "Failed to place module", "error");
1785
1894
  } else {
1895
+ const created = result.created[0];
1896
+ const bundle = engine.getCurrentBundle();
1897
+ if (created && bundle) {
1898
+ const scopeEntry = arrangement[created.scope] ?? {};
1899
+ const existingIds = Object.keys(scopeEntry.nodes ?? {});
1900
+ const slot = (0, import_proto2.resolveScopePositions)([...existingIds, created.id], scopeEntry.nodes).get(
1901
+ created.id
1902
+ );
1903
+ if (slot) {
1904
+ updateArrangement(
1905
+ setScopeEntry(arrangement, created.scope, {
1906
+ ...scopeEntry,
1907
+ nodes: { ...scopeEntry.nodes, [created.id]: slot }
1908
+ })
1909
+ );
1910
+ }
1911
+ }
1786
1912
  onClose();
1787
1913
  }
1788
1914
  } catch (err) {
@@ -1791,7 +1917,7 @@ function RegistryBrowser({
1791
1917
  setPlacing(null);
1792
1918
  }
1793
1919
  },
1794
- [engine, onClose, readOnly, showToast]
1920
+ [engine, arrangement, updateArrangement, onClose, readOnly, showToast]
1795
1921
  );
1796
1922
  return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_ui4.Panel, { title: "Registry", width: 380, onClose, scrollable: true, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "lace-registry-browser", children: [
1797
1923
  /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "lace-registry-browser__search", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
@@ -3536,8 +3662,47 @@ function extractNodeId(d, nodeIds) {
3536
3662
  }
3537
3663
 
3538
3664
  // src/hooks/useClipboard.ts
3665
+ var import_proto3 = require("@lace-cloud/proto");
3539
3666
  var import_react22 = require("react");
3540
- function useClipboard(engine, view, showToast, getSelectedIds, selectNodes, getContextMenuNodeId, dismissContextMenu, readOnly) {
3667
+ function placeCreatedClones(arrangement, sourceIds, created) {
3668
+ const parentPath = sourceIds.length > 0 ? splitCanvasPath(sourceIds[0]).parentPath : "";
3669
+ const byScope = /* @__PURE__ */ new Map();
3670
+ for (const ref of created) {
3671
+ if (!ref.sourceId) continue;
3672
+ const list = byScope.get(ref.scope) ?? [];
3673
+ list.push(ref);
3674
+ byScope.set(ref.scope, list);
3675
+ }
3676
+ let next = arrangement;
3677
+ const clonePaths = [];
3678
+ for (const [scopeKey, refs] of byScope) {
3679
+ const scopeEntry = next[scopeKey] ?? {};
3680
+ const sourcePositions = /* @__PURE__ */ new Map();
3681
+ for (const ref of refs) {
3682
+ const pos = scopeEntry.nodes?.[ref.sourceId];
3683
+ if (pos) sourcePositions.set(ref.sourceId, pos);
3684
+ }
3685
+ const xs = [...sourcePositions.values()].map((p) => p.x);
3686
+ const ys = [...sourcePositions.values()].map((p) => p.y);
3687
+ const minX = xs.length > 0 ? Math.min(...xs) : 0;
3688
+ const minY = ys.length > 0 ? Math.min(...ys) : 0;
3689
+ const existingIds = Object.keys(scopeEntry.nodes ?? {});
3690
+ const anchorMap = (0, import_proto3.resolveScopePositions)([...existingIds, "__paste_anchor__"], scopeEntry.nodes);
3691
+ const anchor = anchorMap.get("__paste_anchor__") ?? { x: 0, y: 0 };
3692
+ const newNodes = {};
3693
+ for (const ref of refs) {
3694
+ const src = sourcePositions.get(ref.sourceId) ?? { x: minX, y: minY };
3695
+ newNodes[ref.id] = { x: anchor.x + (src.x - minX), y: anchor.y + (src.y - minY) };
3696
+ clonePaths.push(parentPath ? `${parentPath}.${ref.id}` : ref.id);
3697
+ }
3698
+ next = setScopeEntry(next, scopeKey, {
3699
+ ...scopeEntry,
3700
+ nodes: { ...scopeEntry.nodes, ...newNodes }
3701
+ });
3702
+ }
3703
+ return { arrangement: next, clonePaths };
3704
+ }
3705
+ function useClipboard(engine, arrangement, updateArrangement, showToast, getSelectedIds, selectNodes, getContextMenuNodeId, dismissContextMenu, readOnly) {
3541
3706
  const clipboardRef = (0, import_react22.useRef)([]);
3542
3707
  const isCutRef = (0, import_react22.useRef)(false);
3543
3708
  const onCopy = (0, import_react22.useCallback)(() => {
@@ -3576,18 +3741,20 @@ function useClipboard(engine, view, showToast, getSelectedIds, selectNodes, getC
3576
3741
  }
3577
3742
  const ids = clipboardRef.current;
3578
3743
  try {
3579
- const prevIds = new Set((view?.nodes ?? []).map((n) => n.id));
3580
3744
  const result = await engine.copyInstances(ids);
3581
3745
  if (!result.success) {
3582
3746
  showToast(result.errors[0]?.message ?? "Paste failed", "error");
3583
3747
  return;
3584
3748
  }
3585
- const current = engine.getCurrentView();
3586
- const newIds = (current?.nodes ?? []).filter((n) => !prevIds.has(n.id) && !ids.includes(n.id)).map((n) => n.id);
3587
- if (newIds.length > 0) {
3588
- selectNodes(newIds);
3589
- } else if (!isCutRef.current) {
3590
- showToast("Paste produced no new nodes \u2014 nothing pasted", "error");
3749
+ const created = result.created.filter((c) => c.sourceId);
3750
+ if (created.length === 0) {
3751
+ if (!isCutRef.current) {
3752
+ showToast("Paste produced no new nodes \u2014 nothing pasted", "error");
3753
+ }
3754
+ } else {
3755
+ const { arrangement: next, clonePaths } = placeCreatedClones(arrangement, ids, created);
3756
+ updateArrangement(next);
3757
+ selectNodes(clonePaths);
3591
3758
  }
3592
3759
  if (isCutRef.current) {
3593
3760
  for (const id of ids) {
@@ -3604,7 +3771,7 @@ function useClipboard(engine, view, showToast, getSelectedIds, selectNodes, getC
3604
3771
  console.error("[Canvas] paste failed:", err);
3605
3772
  showToast("Paste failed \u2014 try again", "error");
3606
3773
  }
3607
- }, [engine, view, showToast, selectNodes, dismissContextMenu]);
3774
+ }, [engine, arrangement, updateArrangement, showToast, selectNodes, dismissContextMenu]);
3608
3775
  (0, import_react22.useEffect)(() => {
3609
3776
  if (readOnly) return;
3610
3777
  window.__canvasCopy = onCopy;
@@ -3857,6 +4024,7 @@ function useGroupLogic(nodes, edges, groups, newNodeIds, erroredNodeIds) {
3857
4024
  hidden: hiddenByAncestor,
3858
4025
  data: {
3859
4026
  groupId: group.id,
4027
+ moduleKey: group.module_key ?? "",
3860
4028
  label: group.label,
3861
4029
  memberCount: memberNodes.length,
3862
4030
  collapsed: true,
@@ -3888,6 +4056,7 @@ function useGroupLogic(nodes, edges, groups, newNodeIds, erroredNodeIds) {
3888
4056
  },
3889
4057
  data: {
3890
4058
  groupId: group.id,
4059
+ moduleKey: group.module_key ?? "",
3891
4060
  label: group.label,
3892
4061
  memberCount: memberNodes.length,
3893
4062
  collapsed: false,
@@ -4171,15 +4340,6 @@ function parseHandleId(handleId, prefix) {
4171
4340
  return name.length > 0 ? name : null;
4172
4341
  }
4173
4342
 
4174
- // src/utils/view-state.ts
4175
- function applyLocalGroupCollapseOverrides(view, overrides, readOnly) {
4176
- if (!readOnly || Object.keys(overrides).length === 0) return view;
4177
- return {
4178
- ...view,
4179
- groups: view.groups.map((g) => g.id in overrides ? { ...g, collapsed: overrides[g.id] } : g)
4180
- };
4181
- }
4182
-
4183
4343
  // src/Canvas.tsx
4184
4344
  var import_jsx_runtime21 = require("react/jsx-runtime");
4185
4345
  var nodeTypes = {
@@ -4457,7 +4617,7 @@ function CompositeEditor({
4457
4617
  );
4458
4618
  }
4459
4619
  function Canvas({ height, registryBaseUrl, apiToken }) {
4460
- const { state, readOnly, localGroupCollapseOverrides } = useCanvas();
4620
+ const { state, readOnly, arrangement, updateArrangement } = useCanvas();
4461
4621
  const engine = useEngine();
4462
4622
  const viewRef = (0, import_react32.useRef)(state.view);
4463
4623
  viewRef.current = state.view;
@@ -4495,7 +4655,8 @@ function Canvas({ height, registryBaseUrl, apiToken }) {
4495
4655
  }, []);
4496
4656
  const { onCopy, onCut, onPaste } = useClipboard(
4497
4657
  engine,
4498
- state.view,
4658
+ arrangement,
4659
+ updateArrangement,
4499
4660
  showToast,
4500
4661
  (0, import_react32.useCallback)(() => getSelectedIdsRef.current?.() ?? [], []),
4501
4662
  (0, import_react32.useCallback)((ids) => selectNodesRef.current?.(ids), []),
@@ -4532,11 +4693,12 @@ function Canvas({ height, registryBaseUrl, apiToken }) {
4532
4693
  };
4533
4694
  }, [onUndo, readOnly]);
4534
4695
  const onDragStop = (0, import_react32.useCallback)(
4535
- async (positions) => {
4536
- if (!engine || readOnly) return;
4537
- await engine.syncLayout(positions);
4696
+ (positions) => {
4697
+ const bundle = engine.getCurrentBundle();
4698
+ if (!bundle) return;
4699
+ updateArrangement(withNodePositions(bundle, arrangement, positions));
4538
4700
  },
4539
- [engine, readOnly]
4701
+ [engine, arrangement, updateArrangement]
4540
4702
  );
4541
4703
  const onConnect = (0, import_react32.useCallback)(
4542
4704
  async (conn) => {
@@ -4598,20 +4760,91 @@ function Canvas({ height, registryBaseUrl, apiToken }) {
4598
4760
  },
4599
4761
  [engine, showToast]
4600
4762
  );
4763
+ const onGroupSelected = (0, import_react32.useCallback)(async () => {
4764
+ const ids = getSelectedIdsRef.current?.() ?? [];
4765
+ const bundle = engine.getCurrentBundle();
4766
+ if (ids.length < 2 || !bundle) return;
4767
+ try {
4768
+ const label = `Group ${ids.length}`;
4769
+ const result = await engine.createGroup(ids);
4770
+ if (!result.success) {
4771
+ showToast(result.errors[0]?.message ?? "Failed to create group", "error");
4772
+ return;
4773
+ }
4774
+ const created = result.created[0];
4775
+ if (created?.moduleKey) {
4776
+ const migratedNodes = {};
4777
+ const memberPositions = [];
4778
+ for (const id of ids) {
4779
+ const scopeKey = scopeKeyForCanvasPath(bundle, id);
4780
+ const { localId } = splitCanvasPath(id);
4781
+ const position = scopeKey ? arrangement[scopeKey]?.nodes?.[localId] : void 0;
4782
+ if (position) {
4783
+ migratedNodes[localId] = position;
4784
+ memberPositions.push(position);
4785
+ }
4786
+ }
4787
+ let next = setScopeEntry(arrangement, created.moduleKey, { nodes: migratedNodes });
4788
+ const parentEntry = next[created.scope] ?? {};
4789
+ next = setScopeEntry(next, created.scope, {
4790
+ ...parentEntry,
4791
+ groups: { ...parentEntry.groups, [created.id]: { label, collapsed: true } }
4792
+ });
4793
+ if (memberPositions.length > 0) {
4794
+ const centroid = {
4795
+ x: memberPositions.reduce((sum, p) => sum + p.x, 0) / memberPositions.length,
4796
+ y: memberPositions.reduce((sum, p) => sum + p.y, 0) / memberPositions.length
4797
+ };
4798
+ const parentEntryWithGroup = next[created.scope] ?? {};
4799
+ next = setScopeEntry(next, created.scope, {
4800
+ ...parentEntryWithGroup,
4801
+ nodes: { ...parentEntryWithGroup.nodes, [created.id]: centroid }
4802
+ });
4803
+ }
4804
+ updateArrangement(next);
4805
+ }
4806
+ dismissContextMenu();
4807
+ } catch (err) {
4808
+ showToast(`Failed to create group: ${err.message}`, "error");
4809
+ }
4810
+ }, [engine, arrangement, updateArrangement, dismissContextMenu, showToast]);
4811
+ const performUngroup = (0, import_react32.useCallback)(
4812
+ async (groupId) => {
4813
+ const bundle = engine.getCurrentBundle();
4814
+ const group = state.view?.groups.find((g) => g.id === groupId);
4815
+ try {
4816
+ const result = await engine.ungroup(groupId);
4817
+ if (!result.success) {
4818
+ showToast(result.errors[0]?.message ?? "Failed to ungroup", "error");
4819
+ return;
4820
+ }
4821
+ if (bundle && group?.module_key) {
4822
+ updateArrangement(
4823
+ migrateUngroup(bundle, arrangement, groupId, group.module_key, result.created)
4824
+ );
4825
+ }
4826
+ dismissContextMenu();
4827
+ } catch (err) {
4828
+ showToast(`Failed to ungroup: ${err.message}`, "error");
4829
+ }
4830
+ },
4831
+ [engine, arrangement, updateArrangement, state.view, dismissContextMenu, showToast]
4832
+ );
4601
4833
  const onNodesDelete = (0, import_react32.useCallback)(
4602
4834
  async (nodes) => {
4603
4835
  if (!engine) return;
4604
4836
  for (const node of nodes) {
4605
- const result = node.type === "groupNode" ? (
4606
- // Delete on a group node → ungroup (remove container, keep instances)
4607
- await engine.deleteGroup(node.id)
4608
- ) : await engine.deleteInstance(node.id);
4837
+ if (node.type === "groupNode") {
4838
+ await performUngroup(node.id);
4839
+ continue;
4840
+ }
4841
+ const result = await engine.deleteInstance(node.id);
4609
4842
  if (!result.success) {
4610
4843
  showToast(result.errors[0]?.message ?? "Delete failed", "error");
4611
4844
  }
4612
4845
  }
4613
4846
  },
4614
- [engine, showToast]
4847
+ [engine, performUngroup, showToast]
4615
4848
  );
4616
4849
  const onClearGraph = (0, import_react32.useCallback)(async () => {
4617
4850
  if (!engine || !state.view) return;
@@ -4630,37 +4863,6 @@ function Canvas({ height, registryBaseUrl, apiToken }) {
4630
4863
  const onOpenPolicy = (0, import_react32.useCallback)(() => {
4631
4864
  setPolicyOpen(true);
4632
4865
  }, []);
4633
- const onGroupSelected = (0, import_react32.useCallback)(async () => {
4634
- const ids = getSelectedIdsRef.current?.() ?? [];
4635
- if (ids.length < 2 || !engine) return;
4636
- try {
4637
- const label = `Group ${ids.length}`;
4638
- const result = await engine.createGroup(label, ids);
4639
- if (!result.success) {
4640
- showToast(result.errors[0]?.message ?? "Failed to create group", "error");
4641
- return;
4642
- }
4643
- dismissContextMenu();
4644
- } catch (err) {
4645
- showToast(`Failed to create group: ${err.message}`, "error");
4646
- }
4647
- }, [engine, dismissContextMenu, showToast]);
4648
- const onUngroup = (0, import_react32.useCallback)(
4649
- async (groupId) => {
4650
- if (!engine) return;
4651
- try {
4652
- const result = await engine.deleteGroup(groupId);
4653
- if (!result.success) {
4654
- showToast(result.errors[0]?.message ?? "Failed to ungroup", "error");
4655
- return;
4656
- }
4657
- dismissContextMenu();
4658
- } catch (err) {
4659
- showToast(`Failed to ungroup: ${err.message}`, "error");
4660
- }
4661
- },
4662
- [engine, dismissContextMenu, showToast]
4663
- );
4664
4866
  if (state.loadError) {
4665
4867
  return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(ErrorState, { message: state.loadError });
4666
4868
  }
@@ -4680,11 +4882,7 @@ function Canvas({ height, registryBaseUrl, apiToken }) {
4680
4882
  }
4681
4883
  );
4682
4884
  }
4683
- const view = applyLocalGroupCollapseOverrides(
4684
- state.view,
4685
- localGroupCollapseOverrides,
4686
- readOnly
4687
- );
4885
+ const view = state.view;
4688
4886
  return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { style: { position: "relative", display: "flex", flexDirection: "column", height }, children: [
4689
4887
  /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_feedback.Toast, { toast }),
4690
4888
  /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
@@ -4695,7 +4893,7 @@ function Canvas({ height, registryBaseUrl, apiToken }) {
4695
4893
  onCut,
4696
4894
  onPaste,
4697
4895
  onGroupSelected,
4698
- onUngroup,
4896
+ onUngroup: performUngroup,
4699
4897
  onDismiss: dismissContextMenu
4700
4898
  }
4701
4899
  ),
@@ -4818,7 +5016,9 @@ function App({
4818
5016
  height = "100vh",
4819
5017
  readOnly = false,
4820
5018
  registryBaseUrl,
4821
- apiToken
5019
+ apiToken,
5020
+ arrangement: initialArrangement,
5021
+ onArrangementChange
4822
5022
  }) {
4823
5023
  const [state, setState] = (0, import_react35.useState)({
4824
5024
  view: null,
@@ -4828,10 +5028,18 @@ function App({
4828
5028
  viewportIntentSeq: 0,
4829
5029
  loadError: null
4830
5030
  });
4831
- const [localGroupCollapseOverrides, setLocalGroupCollapseOverrides] = (0, import_react35.useState)({});
4832
- const toggleLocalGroupCollapse = (0, import_react35.useCallback)((groupId, currentCollapsed) => {
4833
- setLocalGroupCollapseOverrides((prev) => ({ ...prev, [groupId]: !currentCollapsed }));
4834
- }, []);
5031
+ const [arrangement, setArrangementState] = (0, import_react35.useState)(initialArrangement ?? {});
5032
+ const updateArrangement = (0, import_react35.useCallback)(
5033
+ (next) => {
5034
+ setArrangementState(next);
5035
+ engine.setArrangement(next);
5036
+ onArrangementChange?.(next);
5037
+ },
5038
+ [engine, onArrangementChange]
5039
+ );
5040
+ (0, import_react35.useEffect)(() => {
5041
+ engine.setArrangement(arrangement);
5042
+ }, [engine]);
4835
5043
  const refitOnNextStateRef = (0, import_react35.useRef)(true);
4836
5044
  (0, import_react35.useEffect)(() => {
4837
5045
  refitOnNextStateRef.current = true;
@@ -4848,11 +5056,20 @@ function App({
4848
5056
  viewportIntentSeq: prev.viewportIntentSeq + (viewportIntent ? 1 : 0),
4849
5057
  loadError: null
4850
5058
  }));
5059
+ const bundle = engine.getCurrentBundle();
5060
+ if (bundle) {
5061
+ setArrangementState((prev) => {
5062
+ const gced = gcArrangement(bundle, prev);
5063
+ if (gced === prev) return prev;
5064
+ onArrangementChange?.(gced);
5065
+ return gced;
5066
+ });
5067
+ }
4851
5068
  } else if (event.type === "loadError") {
4852
5069
  setState((prev) => ({ ...prev, loading: false, loadError: event.message }));
4853
5070
  }
4854
5071
  });
4855
- }, [engine]);
5072
+ }, [engine, onArrangementChange]);
4856
5073
  const isDirty = state.view?.is_dirty;
4857
5074
  (0, import_react35.useEffect)(() => {
4858
5075
  if (isDirty === void 0) return;
@@ -4877,8 +5094,8 @@ function App({
4877
5094
  state,
4878
5095
  engine,
4879
5096
  readOnly,
4880
- localGroupCollapseOverrides,
4881
- toggleLocalGroupCollapse
5097
+ arrangement,
5098
+ updateArrangement
4882
5099
  },
4883
5100
  children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_react34.ReactFlowProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Canvas, { height, registryBaseUrl, apiToken }) })
4884
5101
  }
@@ -4886,7 +5103,7 @@ function App({
4886
5103
  }
4887
5104
 
4888
5105
  // src/connect-web-engine.ts
4889
- var import_proto = require("@lace-cloud/proto");
5106
+ var import_proto4 = require("@lace-cloud/proto");
4890
5107
 
4891
5108
  // src/generated/service.ts
4892
5109
  var import_wire4 = require("@bufbuild/protobuf/wire");
@@ -8415,23 +8632,46 @@ var ProviderConfig_ConfigEntry = {
8415
8632
  return message;
8416
8633
  }
8417
8634
  };
8418
- function createBaseGraphLayout() {
8419
- return { nodes: {}, groups: {} };
8635
+ function createBasePolicyResolution() {
8636
+ return {
8637
+ mode: "",
8638
+ policy_id: "",
8639
+ rules_fired: [],
8640
+ reason: "",
8641
+ approval_mode: "",
8642
+ condition_trace: [],
8643
+ is_authoring_time_preview: false
8644
+ };
8420
8645
  }
8421
- var GraphLayout = {
8646
+ var PolicyResolution = {
8422
8647
  encode(message, writer = new import_wire3.BinaryWriter()) {
8423
- globalThis.Object.entries(message.nodes).forEach(([key, value]) => {
8424
- GraphLayout_NodesEntry.encode({ key, value }, writer.uint32(10).fork()).join();
8425
- });
8426
- globalThis.Object.entries(message.groups).forEach(([key, value]) => {
8427
- GraphLayout_GroupsEntry.encode({ key, value }, writer.uint32(18).fork()).join();
8428
- });
8648
+ if (message.mode !== "") {
8649
+ writer.uint32(10).string(message.mode);
8650
+ }
8651
+ if (message.policy_id !== "") {
8652
+ writer.uint32(26).string(message.policy_id);
8653
+ }
8654
+ for (const v of message.rules_fired) {
8655
+ writer.uint32(34).string(v);
8656
+ }
8657
+ if (message.reason !== "") {
8658
+ writer.uint32(42).string(message.reason);
8659
+ }
8660
+ if (message.approval_mode !== "") {
8661
+ writer.uint32(50).string(message.approval_mode);
8662
+ }
8663
+ for (const v of message.condition_trace) {
8664
+ PolicyConditionTrace.encode(v, writer.uint32(58).fork()).join();
8665
+ }
8666
+ if (message.is_authoring_time_preview !== false) {
8667
+ writer.uint32(64).bool(message.is_authoring_time_preview);
8668
+ }
8429
8669
  return writer;
8430
8670
  },
8431
8671
  decode(input, length) {
8432
8672
  const reader = input instanceof import_wire3.BinaryReader ? input : new import_wire3.BinaryReader(input);
8433
8673
  const end = length === void 0 ? reader.len : reader.pos + length;
8434
- const message = createBaseGraphLayout();
8674
+ const message = createBasePolicyResolution();
8435
8675
  while (reader.pos < end) {
8436
8676
  const tag = reader.uint32();
8437
8677
  switch (tag >>> 3) {
@@ -8439,20 +8679,49 @@ var GraphLayout = {
8439
8679
  if (tag !== 10) {
8440
8680
  break;
8441
8681
  }
8442
- const entry1 = GraphLayout_NodesEntry.decode(reader, reader.uint32());
8443
- if (entry1.value !== void 0) {
8444
- message.nodes[entry1.key] = entry1.value;
8682
+ message.mode = reader.string();
8683
+ continue;
8684
+ }
8685
+ case 3: {
8686
+ if (tag !== 26) {
8687
+ break;
8445
8688
  }
8689
+ message.policy_id = reader.string();
8446
8690
  continue;
8447
8691
  }
8448
- case 2: {
8449
- if (tag !== 18) {
8692
+ case 4: {
8693
+ if (tag !== 34) {
8450
8694
  break;
8451
8695
  }
8452
- const entry2 = GraphLayout_GroupsEntry.decode(reader, reader.uint32());
8453
- if (entry2.value !== void 0) {
8454
- message.groups[entry2.key] = entry2.value;
8696
+ message.rules_fired.push(reader.string());
8697
+ continue;
8698
+ }
8699
+ case 5: {
8700
+ if (tag !== 42) {
8701
+ break;
8702
+ }
8703
+ message.reason = reader.string();
8704
+ continue;
8705
+ }
8706
+ case 6: {
8707
+ if (tag !== 50) {
8708
+ break;
8709
+ }
8710
+ message.approval_mode = reader.string();
8711
+ continue;
8712
+ }
8713
+ case 7: {
8714
+ if (tag !== 58) {
8715
+ break;
8716
+ }
8717
+ message.condition_trace.push(PolicyConditionTrace.decode(reader, reader.uint32()));
8718
+ continue;
8719
+ }
8720
+ case 8: {
8721
+ if (tag !== 64) {
8722
+ break;
8455
8723
  }
8724
+ message.is_authoring_time_preview = reader.bool();
8456
8725
  continue;
8457
8726
  }
8458
8727
  }
@@ -8465,705 +8734,42 @@ var GraphLayout = {
8465
8734
  },
8466
8735
  fromJSON(object) {
8467
8736
  return {
8468
- nodes: isObject2(object.nodes) ? globalThis.Object.entries(object.nodes).reduce(
8469
- (acc, [key, value]) => {
8470
- acc[key] = NodeLayout.fromJSON(value);
8471
- return acc;
8472
- },
8473
- {}
8474
- ) : {},
8475
- groups: isObject2(object.groups) ? globalThis.Object.entries(object.groups).reduce(
8476
- (acc, [key, value]) => {
8477
- acc[key] = NodeGroup.fromJSON(value);
8478
- return acc;
8479
- },
8480
- {}
8481
- ) : {}
8737
+ mode: isSet2(object.mode) ? globalThis.String(object.mode) : "",
8738
+ policy_id: isSet2(object.policyId) ? globalThis.String(object.policyId) : isSet2(object.policy_id) ? globalThis.String(object.policy_id) : "",
8739
+ rules_fired: globalThis.Array.isArray(object?.rulesFired) ? object.rulesFired.map((e) => globalThis.String(e)) : globalThis.Array.isArray(object?.rules_fired) ? object.rules_fired.map((e) => globalThis.String(e)) : [],
8740
+ reason: isSet2(object.reason) ? globalThis.String(object.reason) : "",
8741
+ approval_mode: isSet2(object.approvalMode) ? globalThis.String(object.approvalMode) : isSet2(object.approval_mode) ? globalThis.String(object.approval_mode) : "",
8742
+ condition_trace: globalThis.Array.isArray(object?.conditionTrace) ? object.conditionTrace.map((e) => PolicyConditionTrace.fromJSON(e)) : globalThis.Array.isArray(object?.condition_trace) ? object.condition_trace.map((e) => PolicyConditionTrace.fromJSON(e)) : [],
8743
+ is_authoring_time_preview: isSet2(object.isAuthoringTimePreview) ? globalThis.Boolean(object.isAuthoringTimePreview) : isSet2(object.is_authoring_time_preview) ? globalThis.Boolean(object.is_authoring_time_preview) : false
8482
8744
  };
8483
8745
  },
8484
8746
  toJSON(message) {
8485
8747
  const obj = {};
8486
- if (message.nodes) {
8487
- const entries = globalThis.Object.entries(message.nodes);
8488
- if (entries.length > 0) {
8489
- obj.nodes = {};
8490
- entries.forEach(([k, v]) => {
8491
- obj.nodes[k] = NodeLayout.toJSON(v);
8492
- });
8493
- }
8748
+ if (message.mode !== "") {
8749
+ obj.mode = message.mode;
8494
8750
  }
8495
- if (message.groups) {
8496
- const entries = globalThis.Object.entries(message.groups);
8497
- if (entries.length > 0) {
8498
- obj.groups = {};
8499
- entries.forEach(([k, v]) => {
8500
- obj.groups[k] = NodeGroup.toJSON(v);
8501
- });
8502
- }
8751
+ if (message.policy_id !== "") {
8752
+ obj.policyId = message.policy_id;
8753
+ }
8754
+ if (message.rules_fired?.length) {
8755
+ obj.rulesFired = message.rules_fired;
8756
+ }
8757
+ if (message.reason !== "") {
8758
+ obj.reason = message.reason;
8759
+ }
8760
+ if (message.approval_mode !== "") {
8761
+ obj.approvalMode = message.approval_mode;
8762
+ }
8763
+ if (message.condition_trace?.length) {
8764
+ obj.conditionTrace = message.condition_trace.map((e) => PolicyConditionTrace.toJSON(e));
8765
+ }
8766
+ if (message.is_authoring_time_preview !== false) {
8767
+ obj.isAuthoringTimePreview = message.is_authoring_time_preview;
8503
8768
  }
8504
8769
  return obj;
8505
8770
  },
8506
8771
  create(base) {
8507
- return GraphLayout.fromPartial(base ?? {});
8508
- },
8509
- fromPartial(object) {
8510
- const message = createBaseGraphLayout();
8511
- message.nodes = globalThis.Object.entries(object.nodes ?? {}).reduce(
8512
- (acc, [key, value]) => {
8513
- if (value !== void 0) {
8514
- acc[key] = NodeLayout.fromPartial(value);
8515
- }
8516
- return acc;
8517
- },
8518
- {}
8519
- );
8520
- message.groups = globalThis.Object.entries(object.groups ?? {}).reduce(
8521
- (acc, [key, value]) => {
8522
- if (value !== void 0) {
8523
- acc[key] = NodeGroup.fromPartial(value);
8524
- }
8525
- return acc;
8526
- },
8527
- {}
8528
- );
8529
- return message;
8530
- }
8531
- };
8532
- function createBaseGraphLayout_NodesEntry() {
8533
- return { key: "", value: void 0 };
8534
- }
8535
- var GraphLayout_NodesEntry = {
8536
- encode(message, writer = new import_wire3.BinaryWriter()) {
8537
- if (message.key !== "") {
8538
- writer.uint32(10).string(message.key);
8539
- }
8540
- if (message.value !== void 0) {
8541
- NodeLayout.encode(message.value, writer.uint32(18).fork()).join();
8542
- }
8543
- return writer;
8544
- },
8545
- decode(input, length) {
8546
- const reader = input instanceof import_wire3.BinaryReader ? input : new import_wire3.BinaryReader(input);
8547
- const end = length === void 0 ? reader.len : reader.pos + length;
8548
- const message = createBaseGraphLayout_NodesEntry();
8549
- while (reader.pos < end) {
8550
- const tag = reader.uint32();
8551
- switch (tag >>> 3) {
8552
- case 1: {
8553
- if (tag !== 10) {
8554
- break;
8555
- }
8556
- message.key = reader.string();
8557
- continue;
8558
- }
8559
- case 2: {
8560
- if (tag !== 18) {
8561
- break;
8562
- }
8563
- message.value = NodeLayout.decode(reader, reader.uint32());
8564
- continue;
8565
- }
8566
- }
8567
- if ((tag & 7) === 4 || tag === 0) {
8568
- break;
8569
- }
8570
- reader.skip(tag & 7);
8571
- }
8572
- return message;
8573
- },
8574
- fromJSON(object) {
8575
- return {
8576
- key: isSet2(object.key) ? globalThis.String(object.key) : "",
8577
- value: isSet2(object.value) ? NodeLayout.fromJSON(object.value) : void 0
8578
- };
8579
- },
8580
- toJSON(message) {
8581
- const obj = {};
8582
- if (message.key !== "") {
8583
- obj.key = message.key;
8584
- }
8585
- if (message.value !== void 0) {
8586
- obj.value = NodeLayout.toJSON(message.value);
8587
- }
8588
- return obj;
8589
- },
8590
- create(base) {
8591
- return GraphLayout_NodesEntry.fromPartial(base ?? {});
8592
- },
8593
- fromPartial(object) {
8594
- const message = createBaseGraphLayout_NodesEntry();
8595
- message.key = object.key ?? "";
8596
- message.value = object.value !== void 0 && object.value !== null ? NodeLayout.fromPartial(object.value) : void 0;
8597
- return message;
8598
- }
8599
- };
8600
- function createBaseGraphLayout_GroupsEntry() {
8601
- return { key: "", value: void 0 };
8602
- }
8603
- var GraphLayout_GroupsEntry = {
8604
- encode(message, writer = new import_wire3.BinaryWriter()) {
8605
- if (message.key !== "") {
8606
- writer.uint32(10).string(message.key);
8607
- }
8608
- if (message.value !== void 0) {
8609
- NodeGroup.encode(message.value, writer.uint32(18).fork()).join();
8610
- }
8611
- return writer;
8612
- },
8613
- decode(input, length) {
8614
- const reader = input instanceof import_wire3.BinaryReader ? input : new import_wire3.BinaryReader(input);
8615
- const end = length === void 0 ? reader.len : reader.pos + length;
8616
- const message = createBaseGraphLayout_GroupsEntry();
8617
- while (reader.pos < end) {
8618
- const tag = reader.uint32();
8619
- switch (tag >>> 3) {
8620
- case 1: {
8621
- if (tag !== 10) {
8622
- break;
8623
- }
8624
- message.key = reader.string();
8625
- continue;
8626
- }
8627
- case 2: {
8628
- if (tag !== 18) {
8629
- break;
8630
- }
8631
- message.value = NodeGroup.decode(reader, reader.uint32());
8632
- continue;
8633
- }
8634
- }
8635
- if ((tag & 7) === 4 || tag === 0) {
8636
- break;
8637
- }
8638
- reader.skip(tag & 7);
8639
- }
8640
- return message;
8641
- },
8642
- fromJSON(object) {
8643
- return {
8644
- key: isSet2(object.key) ? globalThis.String(object.key) : "",
8645
- value: isSet2(object.value) ? NodeGroup.fromJSON(object.value) : void 0
8646
- };
8647
- },
8648
- toJSON(message) {
8649
- const obj = {};
8650
- if (message.key !== "") {
8651
- obj.key = message.key;
8652
- }
8653
- if (message.value !== void 0) {
8654
- obj.value = NodeGroup.toJSON(message.value);
8655
- }
8656
- return obj;
8657
- },
8658
- create(base) {
8659
- return GraphLayout_GroupsEntry.fromPartial(base ?? {});
8660
- },
8661
- fromPartial(object) {
8662
- const message = createBaseGraphLayout_GroupsEntry();
8663
- message.key = object.key ?? "";
8664
- message.value = object.value !== void 0 && object.value !== null ? NodeGroup.fromPartial(object.value) : void 0;
8665
- return message;
8666
- }
8667
- };
8668
- function createBaseNodeGroup() {
8669
- return { id: "", label: "", node_ids: [], collapsed: false };
8670
- }
8671
- var NodeGroup = {
8672
- encode(message, writer = new import_wire3.BinaryWriter()) {
8673
- if (message.id !== "") {
8674
- writer.uint32(10).string(message.id);
8675
- }
8676
- if (message.label !== "") {
8677
- writer.uint32(18).string(message.label);
8678
- }
8679
- for (const v of message.node_ids) {
8680
- writer.uint32(26).string(v);
8681
- }
8682
- if (message.collapsed !== false) {
8683
- writer.uint32(32).bool(message.collapsed);
8684
- }
8685
- return writer;
8686
- },
8687
- decode(input, length) {
8688
- const reader = input instanceof import_wire3.BinaryReader ? input : new import_wire3.BinaryReader(input);
8689
- const end = length === void 0 ? reader.len : reader.pos + length;
8690
- const message = createBaseNodeGroup();
8691
- while (reader.pos < end) {
8692
- const tag = reader.uint32();
8693
- switch (tag >>> 3) {
8694
- case 1: {
8695
- if (tag !== 10) {
8696
- break;
8697
- }
8698
- message.id = reader.string();
8699
- continue;
8700
- }
8701
- case 2: {
8702
- if (tag !== 18) {
8703
- break;
8704
- }
8705
- message.label = reader.string();
8706
- continue;
8707
- }
8708
- case 3: {
8709
- if (tag !== 26) {
8710
- break;
8711
- }
8712
- message.node_ids.push(reader.string());
8713
- continue;
8714
- }
8715
- case 4: {
8716
- if (tag !== 32) {
8717
- break;
8718
- }
8719
- message.collapsed = reader.bool();
8720
- continue;
8721
- }
8722
- }
8723
- if ((tag & 7) === 4 || tag === 0) {
8724
- break;
8725
- }
8726
- reader.skip(tag & 7);
8727
- }
8728
- return message;
8729
- },
8730
- fromJSON(object) {
8731
- return {
8732
- id: isSet2(object.id) ? globalThis.String(object.id) : "",
8733
- label: isSet2(object.label) ? globalThis.String(object.label) : "",
8734
- node_ids: globalThis.Array.isArray(object?.nodeIds) ? object.nodeIds.map((e) => globalThis.String(e)) : globalThis.Array.isArray(object?.node_ids) ? object.node_ids.map((e) => globalThis.String(e)) : [],
8735
- collapsed: isSet2(object.collapsed) ? globalThis.Boolean(object.collapsed) : false
8736
- };
8737
- },
8738
- toJSON(message) {
8739
- const obj = {};
8740
- if (message.id !== "") {
8741
- obj.id = message.id;
8742
- }
8743
- if (message.label !== "") {
8744
- obj.label = message.label;
8745
- }
8746
- if (message.node_ids?.length) {
8747
- obj.nodeIds = message.node_ids;
8748
- }
8749
- if (message.collapsed !== false) {
8750
- obj.collapsed = message.collapsed;
8751
- }
8752
- return obj;
8753
- },
8754
- create(base) {
8755
- return NodeGroup.fromPartial(base ?? {});
8756
- },
8757
- fromPartial(object) {
8758
- const message = createBaseNodeGroup();
8759
- message.id = object.id ?? "";
8760
- message.label = object.label ?? "";
8761
- message.node_ids = object.node_ids?.map((e) => e) || [];
8762
- message.collapsed = object.collapsed ?? false;
8763
- return message;
8764
- }
8765
- };
8766
- function createBaseNodeLayout() {
8767
- return { position: void 0 };
8768
- }
8769
- var NodeLayout = {
8770
- encode(message, writer = new import_wire3.BinaryWriter()) {
8771
- if (message.position !== void 0) {
8772
- Position3.encode(message.position, writer.uint32(10).fork()).join();
8773
- }
8774
- return writer;
8775
- },
8776
- decode(input, length) {
8777
- const reader = input instanceof import_wire3.BinaryReader ? input : new import_wire3.BinaryReader(input);
8778
- const end = length === void 0 ? reader.len : reader.pos + length;
8779
- const message = createBaseNodeLayout();
8780
- while (reader.pos < end) {
8781
- const tag = reader.uint32();
8782
- switch (tag >>> 3) {
8783
- case 1: {
8784
- if (tag !== 10) {
8785
- break;
8786
- }
8787
- message.position = Position3.decode(reader, reader.uint32());
8788
- continue;
8789
- }
8790
- }
8791
- if ((tag & 7) === 4 || tag === 0) {
8792
- break;
8793
- }
8794
- reader.skip(tag & 7);
8795
- }
8796
- return message;
8797
- },
8798
- fromJSON(object) {
8799
- return { position: isSet2(object.position) ? Position3.fromJSON(object.position) : void 0 };
8800
- },
8801
- toJSON(message) {
8802
- const obj = {};
8803
- if (message.position !== void 0) {
8804
- obj.position = Position3.toJSON(message.position);
8805
- }
8806
- return obj;
8807
- },
8808
- create(base) {
8809
- return NodeLayout.fromPartial(base ?? {});
8810
- },
8811
- fromPartial(object) {
8812
- const message = createBaseNodeLayout();
8813
- message.position = object.position !== void 0 && object.position !== null ? Position3.fromPartial(object.position) : void 0;
8814
- return message;
8815
- }
8816
- };
8817
- function createBasePosition() {
8818
- return { x: 0, y: 0 };
8819
- }
8820
- var Position3 = {
8821
- encode(message, writer = new import_wire3.BinaryWriter()) {
8822
- if (message.x !== 0) {
8823
- writer.uint32(9).double(message.x);
8824
- }
8825
- if (message.y !== 0) {
8826
- writer.uint32(17).double(message.y);
8827
- }
8828
- return writer;
8829
- },
8830
- decode(input, length) {
8831
- const reader = input instanceof import_wire3.BinaryReader ? input : new import_wire3.BinaryReader(input);
8832
- const end = length === void 0 ? reader.len : reader.pos + length;
8833
- const message = createBasePosition();
8834
- while (reader.pos < end) {
8835
- const tag = reader.uint32();
8836
- switch (tag >>> 3) {
8837
- case 1: {
8838
- if (tag !== 9) {
8839
- break;
8840
- }
8841
- message.x = reader.double();
8842
- continue;
8843
- }
8844
- case 2: {
8845
- if (tag !== 17) {
8846
- break;
8847
- }
8848
- message.y = reader.double();
8849
- continue;
8850
- }
8851
- }
8852
- if ((tag & 7) === 4 || tag === 0) {
8853
- break;
8854
- }
8855
- reader.skip(tag & 7);
8856
- }
8857
- return message;
8858
- },
8859
- fromJSON(object) {
8860
- return {
8861
- x: isSet2(object.x) ? globalThis.Number(object.x) : 0,
8862
- y: isSet2(object.y) ? globalThis.Number(object.y) : 0
8863
- };
8864
- },
8865
- toJSON(message) {
8866
- const obj = {};
8867
- if (message.x !== 0) {
8868
- obj.x = message.x;
8869
- }
8870
- if (message.y !== 0) {
8871
- obj.y = message.y;
8872
- }
8873
- return obj;
8874
- },
8875
- create(base) {
8876
- return Position3.fromPartial(base ?? {});
8877
- },
8878
- fromPartial(object) {
8879
- const message = createBasePosition();
8880
- message.x = object.x ?? 0;
8881
- message.y = object.y ?? 0;
8882
- return message;
8883
- }
8884
- };
8885
- function createBaseLayoutsMap() {
8886
- return { layouts: {} };
8887
- }
8888
- var LayoutsMap = {
8889
- encode(message, writer = new import_wire3.BinaryWriter()) {
8890
- globalThis.Object.entries(message.layouts).forEach(([key, value]) => {
8891
- LayoutsMap_LayoutsEntry.encode({ key, value }, writer.uint32(10).fork()).join();
8892
- });
8893
- return writer;
8894
- },
8895
- decode(input, length) {
8896
- const reader = input instanceof import_wire3.BinaryReader ? input : new import_wire3.BinaryReader(input);
8897
- const end = length === void 0 ? reader.len : reader.pos + length;
8898
- const message = createBaseLayoutsMap();
8899
- while (reader.pos < end) {
8900
- const tag = reader.uint32();
8901
- switch (tag >>> 3) {
8902
- case 1: {
8903
- if (tag !== 10) {
8904
- break;
8905
- }
8906
- const entry1 = LayoutsMap_LayoutsEntry.decode(reader, reader.uint32());
8907
- if (entry1.value !== void 0) {
8908
- message.layouts[entry1.key] = entry1.value;
8909
- }
8910
- continue;
8911
- }
8912
- }
8913
- if ((tag & 7) === 4 || tag === 0) {
8914
- break;
8915
- }
8916
- reader.skip(tag & 7);
8917
- }
8918
- return message;
8919
- },
8920
- fromJSON(object) {
8921
- return {
8922
- layouts: isObject2(object.layouts) ? globalThis.Object.entries(object.layouts).reduce(
8923
- (acc, [key, value]) => {
8924
- acc[key] = GraphLayout.fromJSON(value);
8925
- return acc;
8926
- },
8927
- {}
8928
- ) : {}
8929
- };
8930
- },
8931
- toJSON(message) {
8932
- const obj = {};
8933
- if (message.layouts) {
8934
- const entries = globalThis.Object.entries(message.layouts);
8935
- if (entries.length > 0) {
8936
- obj.layouts = {};
8937
- entries.forEach(([k, v]) => {
8938
- obj.layouts[k] = GraphLayout.toJSON(v);
8939
- });
8940
- }
8941
- }
8942
- return obj;
8943
- },
8944
- create(base) {
8945
- return LayoutsMap.fromPartial(base ?? {});
8946
- },
8947
- fromPartial(object) {
8948
- const message = createBaseLayoutsMap();
8949
- message.layouts = globalThis.Object.entries(object.layouts ?? {}).reduce(
8950
- (acc, [key, value]) => {
8951
- if (value !== void 0) {
8952
- acc[key] = GraphLayout.fromPartial(value);
8953
- }
8954
- return acc;
8955
- },
8956
- {}
8957
- );
8958
- return message;
8959
- }
8960
- };
8961
- function createBaseLayoutsMap_LayoutsEntry() {
8962
- return { key: "", value: void 0 };
8963
- }
8964
- var LayoutsMap_LayoutsEntry = {
8965
- encode(message, writer = new import_wire3.BinaryWriter()) {
8966
- if (message.key !== "") {
8967
- writer.uint32(10).string(message.key);
8968
- }
8969
- if (message.value !== void 0) {
8970
- GraphLayout.encode(message.value, writer.uint32(18).fork()).join();
8971
- }
8972
- return writer;
8973
- },
8974
- decode(input, length) {
8975
- const reader = input instanceof import_wire3.BinaryReader ? input : new import_wire3.BinaryReader(input);
8976
- const end = length === void 0 ? reader.len : reader.pos + length;
8977
- const message = createBaseLayoutsMap_LayoutsEntry();
8978
- while (reader.pos < end) {
8979
- const tag = reader.uint32();
8980
- switch (tag >>> 3) {
8981
- case 1: {
8982
- if (tag !== 10) {
8983
- break;
8984
- }
8985
- message.key = reader.string();
8986
- continue;
8987
- }
8988
- case 2: {
8989
- if (tag !== 18) {
8990
- break;
8991
- }
8992
- message.value = GraphLayout.decode(reader, reader.uint32());
8993
- continue;
8994
- }
8995
- }
8996
- if ((tag & 7) === 4 || tag === 0) {
8997
- break;
8998
- }
8999
- reader.skip(tag & 7);
9000
- }
9001
- return message;
9002
- },
9003
- fromJSON(object) {
9004
- return {
9005
- key: isSet2(object.key) ? globalThis.String(object.key) : "",
9006
- value: isSet2(object.value) ? GraphLayout.fromJSON(object.value) : void 0
9007
- };
9008
- },
9009
- toJSON(message) {
9010
- const obj = {};
9011
- if (message.key !== "") {
9012
- obj.key = message.key;
9013
- }
9014
- if (message.value !== void 0) {
9015
- obj.value = GraphLayout.toJSON(message.value);
9016
- }
9017
- return obj;
9018
- },
9019
- create(base) {
9020
- return LayoutsMap_LayoutsEntry.fromPartial(base ?? {});
9021
- },
9022
- fromPartial(object) {
9023
- const message = createBaseLayoutsMap_LayoutsEntry();
9024
- message.key = object.key ?? "";
9025
- message.value = object.value !== void 0 && object.value !== null ? GraphLayout.fromPartial(object.value) : void 0;
9026
- return message;
9027
- }
9028
- };
9029
- function createBasePolicyResolution() {
9030
- return {
9031
- mode: "",
9032
- policy_id: "",
9033
- rules_fired: [],
9034
- reason: "",
9035
- approval_mode: "",
9036
- condition_trace: [],
9037
- is_authoring_time_preview: false
9038
- };
9039
- }
9040
- var PolicyResolution = {
9041
- encode(message, writer = new import_wire3.BinaryWriter()) {
9042
- if (message.mode !== "") {
9043
- writer.uint32(10).string(message.mode);
9044
- }
9045
- if (message.policy_id !== "") {
9046
- writer.uint32(26).string(message.policy_id);
9047
- }
9048
- for (const v of message.rules_fired) {
9049
- writer.uint32(34).string(v);
9050
- }
9051
- if (message.reason !== "") {
9052
- writer.uint32(42).string(message.reason);
9053
- }
9054
- if (message.approval_mode !== "") {
9055
- writer.uint32(50).string(message.approval_mode);
9056
- }
9057
- for (const v of message.condition_trace) {
9058
- PolicyConditionTrace.encode(v, writer.uint32(58).fork()).join();
9059
- }
9060
- if (message.is_authoring_time_preview !== false) {
9061
- writer.uint32(64).bool(message.is_authoring_time_preview);
9062
- }
9063
- return writer;
9064
- },
9065
- decode(input, length) {
9066
- const reader = input instanceof import_wire3.BinaryReader ? input : new import_wire3.BinaryReader(input);
9067
- const end = length === void 0 ? reader.len : reader.pos + length;
9068
- const message = createBasePolicyResolution();
9069
- while (reader.pos < end) {
9070
- const tag = reader.uint32();
9071
- switch (tag >>> 3) {
9072
- case 1: {
9073
- if (tag !== 10) {
9074
- break;
9075
- }
9076
- message.mode = reader.string();
9077
- continue;
9078
- }
9079
- case 3: {
9080
- if (tag !== 26) {
9081
- break;
9082
- }
9083
- message.policy_id = reader.string();
9084
- continue;
9085
- }
9086
- case 4: {
9087
- if (tag !== 34) {
9088
- break;
9089
- }
9090
- message.rules_fired.push(reader.string());
9091
- continue;
9092
- }
9093
- case 5: {
9094
- if (tag !== 42) {
9095
- break;
9096
- }
9097
- message.reason = reader.string();
9098
- continue;
9099
- }
9100
- case 6: {
9101
- if (tag !== 50) {
9102
- break;
9103
- }
9104
- message.approval_mode = reader.string();
9105
- continue;
9106
- }
9107
- case 7: {
9108
- if (tag !== 58) {
9109
- break;
9110
- }
9111
- message.condition_trace.push(PolicyConditionTrace.decode(reader, reader.uint32()));
9112
- continue;
9113
- }
9114
- case 8: {
9115
- if (tag !== 64) {
9116
- break;
9117
- }
9118
- message.is_authoring_time_preview = reader.bool();
9119
- continue;
9120
- }
9121
- }
9122
- if ((tag & 7) === 4 || tag === 0) {
9123
- break;
9124
- }
9125
- reader.skip(tag & 7);
9126
- }
9127
- return message;
9128
- },
9129
- fromJSON(object) {
9130
- return {
9131
- mode: isSet2(object.mode) ? globalThis.String(object.mode) : "",
9132
- policy_id: isSet2(object.policyId) ? globalThis.String(object.policyId) : isSet2(object.policy_id) ? globalThis.String(object.policy_id) : "",
9133
- rules_fired: globalThis.Array.isArray(object?.rulesFired) ? object.rulesFired.map((e) => globalThis.String(e)) : globalThis.Array.isArray(object?.rules_fired) ? object.rules_fired.map((e) => globalThis.String(e)) : [],
9134
- reason: isSet2(object.reason) ? globalThis.String(object.reason) : "",
9135
- approval_mode: isSet2(object.approvalMode) ? globalThis.String(object.approvalMode) : isSet2(object.approval_mode) ? globalThis.String(object.approval_mode) : "",
9136
- condition_trace: globalThis.Array.isArray(object?.conditionTrace) ? object.conditionTrace.map((e) => PolicyConditionTrace.fromJSON(e)) : globalThis.Array.isArray(object?.condition_trace) ? object.condition_trace.map((e) => PolicyConditionTrace.fromJSON(e)) : [],
9137
- is_authoring_time_preview: isSet2(object.isAuthoringTimePreview) ? globalThis.Boolean(object.isAuthoringTimePreview) : isSet2(object.is_authoring_time_preview) ? globalThis.Boolean(object.is_authoring_time_preview) : false
9138
- };
9139
- },
9140
- toJSON(message) {
9141
- const obj = {};
9142
- if (message.mode !== "") {
9143
- obj.mode = message.mode;
9144
- }
9145
- if (message.policy_id !== "") {
9146
- obj.policyId = message.policy_id;
9147
- }
9148
- if (message.rules_fired?.length) {
9149
- obj.rulesFired = message.rules_fired;
9150
- }
9151
- if (message.reason !== "") {
9152
- obj.reason = message.reason;
9153
- }
9154
- if (message.approval_mode !== "") {
9155
- obj.approvalMode = message.approval_mode;
9156
- }
9157
- if (message.condition_trace?.length) {
9158
- obj.conditionTrace = message.condition_trace.map((e) => PolicyConditionTrace.toJSON(e));
9159
- }
9160
- if (message.is_authoring_time_preview !== false) {
9161
- obj.isAuthoringTimePreview = message.is_authoring_time_preview;
9162
- }
9163
- return obj;
9164
- },
9165
- create(base) {
9166
- return PolicyResolution.fromPartial(base ?? {});
8772
+ return PolicyResolution.fromPartial(base ?? {});
9167
8773
  },
9168
8774
  fromPartial(object) {
9169
8775
  const message = createBasePolicyResolution();
@@ -11576,335 +11182,25 @@ var CopyInstancesAction = {
11576
11182
  return message;
11577
11183
  }
11578
11184
  };
11579
- function createBaseSyncLayoutAction() {
11580
- return { positions: {} };
11581
- }
11582
- var SyncLayoutAction = {
11583
- encode(message, writer = new import_wire4.BinaryWriter()) {
11584
- globalThis.Object.entries(message.positions).forEach(([key, value]) => {
11585
- SyncLayoutAction_PositionsEntry.encode({ key, value }, writer.uint32(10).fork()).join();
11586
- });
11587
- return writer;
11588
- },
11589
- decode(input, length) {
11590
- const reader = input instanceof import_wire4.BinaryReader ? input : new import_wire4.BinaryReader(input);
11591
- const end = length === void 0 ? reader.len : reader.pos + length;
11592
- const message = createBaseSyncLayoutAction();
11593
- while (reader.pos < end) {
11594
- const tag = reader.uint32();
11595
- switch (tag >>> 3) {
11596
- case 1: {
11597
- if (tag !== 10) {
11598
- break;
11599
- }
11600
- const entry1 = SyncLayoutAction_PositionsEntry.decode(reader, reader.uint32());
11601
- if (entry1.value !== void 0) {
11602
- message.positions[entry1.key] = entry1.value;
11603
- }
11604
- continue;
11605
- }
11606
- }
11607
- if ((tag & 7) === 4 || tag === 0) {
11608
- break;
11609
- }
11610
- reader.skip(tag & 7);
11611
- }
11612
- return message;
11613
- },
11614
- fromJSON(object) {
11615
- return {
11616
- positions: isObject3(object.positions) ? globalThis.Object.entries(object.positions).reduce(
11617
- (acc, [key, value]) => {
11618
- acc[key] = Position4.fromJSON(value);
11619
- return acc;
11620
- },
11621
- {}
11622
- ) : {}
11623
- };
11624
- },
11625
- toJSON(message) {
11626
- const obj = {};
11627
- if (message.positions) {
11628
- const entries = globalThis.Object.entries(message.positions);
11629
- if (entries.length > 0) {
11630
- obj.positions = {};
11631
- entries.forEach(([k, v]) => {
11632
- obj.positions[k] = Position4.toJSON(v);
11633
- });
11634
- }
11635
- }
11636
- return obj;
11637
- },
11638
- create(base) {
11639
- return SyncLayoutAction.fromPartial(base ?? {});
11640
- },
11641
- fromPartial(object) {
11642
- const message = createBaseSyncLayoutAction();
11643
- message.positions = globalThis.Object.entries(object.positions ?? {}).reduce(
11644
- (acc, [key, value]) => {
11645
- if (value !== void 0) {
11646
- acc[key] = Position4.fromPartial(value);
11647
- }
11648
- return acc;
11649
- },
11650
- {}
11651
- );
11652
- return message;
11653
- }
11654
- };
11655
- function createBaseSyncLayoutAction_PositionsEntry() {
11656
- return { key: "", value: void 0 };
11657
- }
11658
- var SyncLayoutAction_PositionsEntry = {
11659
- encode(message, writer = new import_wire4.BinaryWriter()) {
11660
- if (message.key !== "") {
11661
- writer.uint32(10).string(message.key);
11662
- }
11663
- if (message.value !== void 0) {
11664
- Position4.encode(message.value, writer.uint32(18).fork()).join();
11665
- }
11666
- return writer;
11667
- },
11668
- decode(input, length) {
11669
- const reader = input instanceof import_wire4.BinaryReader ? input : new import_wire4.BinaryReader(input);
11670
- const end = length === void 0 ? reader.len : reader.pos + length;
11671
- const message = createBaseSyncLayoutAction_PositionsEntry();
11672
- while (reader.pos < end) {
11673
- const tag = reader.uint32();
11674
- switch (tag >>> 3) {
11675
- case 1: {
11676
- if (tag !== 10) {
11677
- break;
11678
- }
11679
- message.key = reader.string();
11680
- continue;
11681
- }
11682
- case 2: {
11683
- if (tag !== 18) {
11684
- break;
11685
- }
11686
- message.value = Position4.decode(reader, reader.uint32());
11687
- continue;
11688
- }
11689
- }
11690
- if ((tag & 7) === 4 || tag === 0) {
11691
- break;
11692
- }
11693
- reader.skip(tag & 7);
11694
- }
11695
- return message;
11696
- },
11697
- fromJSON(object) {
11698
- return {
11699
- key: isSet3(object.key) ? globalThis.String(object.key) : "",
11700
- value: isSet3(object.value) ? Position4.fromJSON(object.value) : void 0
11701
- };
11702
- },
11703
- toJSON(message) {
11704
- const obj = {};
11705
- if (message.key !== "") {
11706
- obj.key = message.key;
11707
- }
11708
- if (message.value !== void 0) {
11709
- obj.value = Position4.toJSON(message.value);
11710
- }
11711
- return obj;
11712
- },
11713
- create(base) {
11714
- return SyncLayoutAction_PositionsEntry.fromPartial(base ?? {});
11715
- },
11716
- fromPartial(object) {
11717
- const message = createBaseSyncLayoutAction_PositionsEntry();
11718
- message.key = object.key ?? "";
11719
- message.value = object.value !== void 0 && object.value !== null ? Position4.fromPartial(object.value) : void 0;
11720
- return message;
11721
- }
11722
- };
11723
- function createBaseCreateGroupAction() {
11724
- return { label: "", node_ids: [] };
11725
- }
11726
- var CreateGroupAction = {
11727
- encode(message, writer = new import_wire4.BinaryWriter()) {
11728
- if (message.label !== "") {
11729
- writer.uint32(10).string(message.label);
11730
- }
11731
- for (const v of message.node_ids) {
11732
- writer.uint32(18).string(v);
11733
- }
11734
- return writer;
11735
- },
11736
- decode(input, length) {
11737
- const reader = input instanceof import_wire4.BinaryReader ? input : new import_wire4.BinaryReader(input);
11738
- const end = length === void 0 ? reader.len : reader.pos + length;
11739
- const message = createBaseCreateGroupAction();
11740
- while (reader.pos < end) {
11741
- const tag = reader.uint32();
11742
- switch (tag >>> 3) {
11743
- case 1: {
11744
- if (tag !== 10) {
11745
- break;
11746
- }
11747
- message.label = reader.string();
11748
- continue;
11749
- }
11750
- case 2: {
11751
- if (tag !== 18) {
11752
- break;
11753
- }
11754
- message.node_ids.push(reader.string());
11755
- continue;
11756
- }
11757
- }
11758
- if ((tag & 7) === 4 || tag === 0) {
11759
- break;
11760
- }
11761
- reader.skip(tag & 7);
11762
- }
11763
- return message;
11764
- },
11765
- fromJSON(object) {
11766
- return {
11767
- label: isSet3(object.label) ? globalThis.String(object.label) : "",
11768
- node_ids: globalThis.Array.isArray(object?.nodeIds) ? object.nodeIds.map((e) => globalThis.String(e)) : globalThis.Array.isArray(object?.node_ids) ? object.node_ids.map((e) => globalThis.String(e)) : []
11769
- };
11770
- },
11771
- toJSON(message) {
11772
- const obj = {};
11773
- if (message.label !== "") {
11774
- obj.label = message.label;
11775
- }
11776
- if (message.node_ids?.length) {
11777
- obj.nodeIds = message.node_ids;
11778
- }
11779
- return obj;
11780
- },
11781
- create(base) {
11782
- return CreateGroupAction.fromPartial(base ?? {});
11783
- },
11784
- fromPartial(object) {
11785
- const message = createBaseCreateGroupAction();
11786
- message.label = object.label ?? "";
11787
- message.node_ids = object.node_ids?.map((e) => e) || [];
11788
- return message;
11789
- }
11790
- };
11791
- function createBaseUpdateGroupAction() {
11792
- return { group_id: "", label: void 0, collapsed: void 0, node_ids: void 0 };
11793
- }
11794
- var UpdateGroupAction = {
11795
- encode(message, writer = new import_wire4.BinaryWriter()) {
11796
- if (message.group_id !== "") {
11797
- writer.uint32(10).string(message.group_id);
11798
- }
11799
- if (message.label !== void 0) {
11800
- writer.uint32(18).string(message.label);
11801
- }
11802
- if (message.collapsed !== void 0) {
11803
- writer.uint32(24).bool(message.collapsed);
11804
- }
11805
- if (message.node_ids !== void 0) {
11806
- UpdateGroupNodeIds.encode(message.node_ids, writer.uint32(34).fork()).join();
11807
- }
11808
- return writer;
11809
- },
11810
- decode(input, length) {
11811
- const reader = input instanceof import_wire4.BinaryReader ? input : new import_wire4.BinaryReader(input);
11812
- const end = length === void 0 ? reader.len : reader.pos + length;
11813
- const message = createBaseUpdateGroupAction();
11814
- while (reader.pos < end) {
11815
- const tag = reader.uint32();
11816
- switch (tag >>> 3) {
11817
- case 1: {
11818
- if (tag !== 10) {
11819
- break;
11820
- }
11821
- message.group_id = reader.string();
11822
- continue;
11823
- }
11824
- case 2: {
11825
- if (tag !== 18) {
11826
- break;
11827
- }
11828
- message.label = reader.string();
11829
- continue;
11830
- }
11831
- case 3: {
11832
- if (tag !== 24) {
11833
- break;
11834
- }
11835
- message.collapsed = reader.bool();
11836
- continue;
11837
- }
11838
- case 4: {
11839
- if (tag !== 34) {
11840
- break;
11841
- }
11842
- message.node_ids = UpdateGroupNodeIds.decode(reader, reader.uint32());
11843
- continue;
11844
- }
11845
- }
11846
- if ((tag & 7) === 4 || tag === 0) {
11847
- break;
11848
- }
11849
- reader.skip(tag & 7);
11850
- }
11851
- return message;
11852
- },
11853
- fromJSON(object) {
11854
- return {
11855
- group_id: isSet3(object.groupId) ? globalThis.String(object.groupId) : isSet3(object.group_id) ? globalThis.String(object.group_id) : "",
11856
- label: isSet3(object.label) ? globalThis.String(object.label) : void 0,
11857
- collapsed: isSet3(object.collapsed) ? globalThis.Boolean(object.collapsed) : void 0,
11858
- node_ids: isSet3(object.nodeIds) ? UpdateGroupNodeIds.fromJSON(object.nodeIds) : isSet3(object.node_ids) ? UpdateGroupNodeIds.fromJSON(object.node_ids) : void 0
11859
- };
11860
- },
11861
- toJSON(message) {
11862
- const obj = {};
11863
- if (message.group_id !== "") {
11864
- obj.groupId = message.group_id;
11865
- }
11866
- if (message.label !== void 0) {
11867
- obj.label = message.label;
11868
- }
11869
- if (message.collapsed !== void 0) {
11870
- obj.collapsed = message.collapsed;
11871
- }
11872
- if (message.node_ids !== void 0) {
11873
- obj.nodeIds = UpdateGroupNodeIds.toJSON(message.node_ids);
11874
- }
11875
- return obj;
11876
- },
11877
- create(base) {
11878
- return UpdateGroupAction.fromPartial(base ?? {});
11879
- },
11880
- fromPartial(object) {
11881
- const message = createBaseUpdateGroupAction();
11882
- message.group_id = object.group_id ?? "";
11883
- message.label = object.label ?? void 0;
11884
- message.collapsed = object.collapsed ?? void 0;
11885
- message.node_ids = object.node_ids !== void 0 && object.node_ids !== null ? UpdateGroupNodeIds.fromPartial(object.node_ids) : void 0;
11886
- return message;
11887
- }
11888
- };
11889
- function createBaseUpdateGroupNodeIds() {
11185
+ function createBaseCreateGroupAction() {
11890
11186
  return { node_ids: [] };
11891
11187
  }
11892
- var UpdateGroupNodeIds = {
11188
+ var CreateGroupAction = {
11893
11189
  encode(message, writer = new import_wire4.BinaryWriter()) {
11894
11190
  for (const v of message.node_ids) {
11895
- writer.uint32(10).string(v);
11191
+ writer.uint32(18).string(v);
11896
11192
  }
11897
11193
  return writer;
11898
11194
  },
11899
11195
  decode(input, length) {
11900
11196
  const reader = input instanceof import_wire4.BinaryReader ? input : new import_wire4.BinaryReader(input);
11901
11197
  const end = length === void 0 ? reader.len : reader.pos + length;
11902
- const message = createBaseUpdateGroupNodeIds();
11198
+ const message = createBaseCreateGroupAction();
11903
11199
  while (reader.pos < end) {
11904
11200
  const tag = reader.uint32();
11905
11201
  switch (tag >>> 3) {
11906
- case 1: {
11907
- if (tag !== 10) {
11202
+ case 2: {
11203
+ if (tag !== 18) {
11908
11204
  break;
11909
11205
  }
11910
11206
  message.node_ids.push(reader.string());
@@ -11931,18 +11227,18 @@ var UpdateGroupNodeIds = {
11931
11227
  return obj;
11932
11228
  },
11933
11229
  create(base) {
11934
- return UpdateGroupNodeIds.fromPartial(base ?? {});
11230
+ return CreateGroupAction.fromPartial(base ?? {});
11935
11231
  },
11936
11232
  fromPartial(object) {
11937
- const message = createBaseUpdateGroupNodeIds();
11233
+ const message = createBaseCreateGroupAction();
11938
11234
  message.node_ids = object.node_ids?.map((e) => e) || [];
11939
11235
  return message;
11940
11236
  }
11941
11237
  };
11942
- function createBaseDeleteGroupAction() {
11238
+ function createBaseUngroupAction() {
11943
11239
  return { group_id: "" };
11944
11240
  }
11945
- var DeleteGroupAction = {
11241
+ var UngroupAction = {
11946
11242
  encode(message, writer = new import_wire4.BinaryWriter()) {
11947
11243
  if (message.group_id !== "") {
11948
11244
  writer.uint32(10).string(message.group_id);
@@ -11952,7 +11248,7 @@ var DeleteGroupAction = {
11952
11248
  decode(input, length) {
11953
11249
  const reader = input instanceof import_wire4.BinaryReader ? input : new import_wire4.BinaryReader(input);
11954
11250
  const end = length === void 0 ? reader.len : reader.pos + length;
11955
- const message = createBaseDeleteGroupAction();
11251
+ const message = createBaseUngroupAction();
11956
11252
  while (reader.pos < end) {
11957
11253
  const tag = reader.uint32();
11958
11254
  switch (tag >>> 3) {
@@ -11984,10 +11280,10 @@ var DeleteGroupAction = {
11984
11280
  return obj;
11985
11281
  },
11986
11282
  create(base) {
11987
- return DeleteGroupAction.fromPartial(base ?? {});
11283
+ return UngroupAction.fromPartial(base ?? {});
11988
11284
  },
11989
11285
  fromPartial(object) {
11990
- const message = createBaseDeleteGroupAction();
11286
+ const message = createBaseUngroupAction();
11991
11287
  message.group_id = object.group_id ?? "";
11992
11288
  return message;
11993
11289
  }
@@ -13060,7 +12356,7 @@ var RedoAction = {
13060
12356
  }
13061
12357
  };
13062
12358
  function createBasePlaceModuleAction() {
13063
- return { name: "", system: "", version: "", organization: "", position: void 0 };
12359
+ return { name: "", system: "", version: "", organization: "" };
13064
12360
  }
13065
12361
  var PlaceModuleAction = {
13066
12362
  encode(message, writer = new import_wire4.BinaryWriter()) {
@@ -13076,9 +12372,6 @@ var PlaceModuleAction = {
13076
12372
  if (message.organization !== "") {
13077
12373
  writer.uint32(34).string(message.organization);
13078
12374
  }
13079
- if (message.position !== void 0) {
13080
- Position4.encode(message.position, writer.uint32(42).fork()).join();
13081
- }
13082
12375
  return writer;
13083
12376
  },
13084
12377
  decode(input, length) {
@@ -13116,13 +12409,6 @@ var PlaceModuleAction = {
13116
12409
  message.organization = reader.string();
13117
12410
  continue;
13118
12411
  }
13119
- case 5: {
13120
- if (tag !== 42) {
13121
- break;
13122
- }
13123
- message.position = Position4.decode(reader, reader.uint32());
13124
- continue;
13125
- }
13126
12412
  }
13127
12413
  if ((tag & 7) === 4 || tag === 0) {
13128
12414
  break;
@@ -13136,8 +12422,7 @@ var PlaceModuleAction = {
13136
12422
  name: isSet3(object.name) ? globalThis.String(object.name) : "",
13137
12423
  system: isSet3(object.system) ? globalThis.String(object.system) : "",
13138
12424
  version: isSet3(object.version) ? globalThis.String(object.version) : "",
13139
- organization: isSet3(object.organization) ? globalThis.String(object.organization) : "",
13140
- position: isSet3(object.position) ? Position4.fromJSON(object.position) : void 0
12425
+ organization: isSet3(object.organization) ? globalThis.String(object.organization) : ""
13141
12426
  };
13142
12427
  },
13143
12428
  toJSON(message) {
@@ -13154,9 +12439,6 @@ var PlaceModuleAction = {
13154
12439
  if (message.organization !== "") {
13155
12440
  obj.organization = message.organization;
13156
12441
  }
13157
- if (message.position !== void 0) {
13158
- obj.position = Position4.toJSON(message.position);
13159
- }
13160
12442
  return obj;
13161
12443
  },
13162
12444
  create(base) {
@@ -13168,7 +12450,6 @@ var PlaceModuleAction = {
13168
12450
  message.system = object.system ?? "";
13169
12451
  message.version = object.version ?? "";
13170
12452
  message.organization = object.organization ?? "";
13171
- message.position = object.position !== void 0 && object.position !== null ? Position4.fromPartial(object.position) : void 0;
13172
12453
  return message;
13173
12454
  }
13174
12455
  };
@@ -13182,10 +12463,7 @@ function createBaseAction() {
13182
12463
  rename_instance: void 0,
13183
12464
  delete_instance: void 0,
13184
12465
  copy_instances: void 0,
13185
- sync_layout: void 0,
13186
12466
  create_group: void 0,
13187
- update_group: void 0,
13188
- delete_group: void 0,
13189
12467
  set_variables: void 0,
13190
12468
  set_exports: void 0,
13191
12469
  set_terraform: void 0,
@@ -13196,7 +12474,8 @@ function createBaseAction() {
13196
12474
  undo: void 0,
13197
12475
  redo: void 0,
13198
12476
  place_module: void 0,
13199
- set_use_providers: void 0
12477
+ set_use_providers: void 0,
12478
+ ungroup: void 0
13200
12479
  };
13201
12480
  }
13202
12481
  var Action = {
@@ -13225,18 +12504,9 @@ var Action = {
13225
12504
  if (message.copy_instances !== void 0) {
13226
12505
  CopyInstancesAction.encode(message.copy_instances, writer.uint32(66).fork()).join();
13227
12506
  }
13228
- if (message.sync_layout !== void 0) {
13229
- SyncLayoutAction.encode(message.sync_layout, writer.uint32(74).fork()).join();
13230
- }
13231
12507
  if (message.create_group !== void 0) {
13232
12508
  CreateGroupAction.encode(message.create_group, writer.uint32(82).fork()).join();
13233
12509
  }
13234
- if (message.update_group !== void 0) {
13235
- UpdateGroupAction.encode(message.update_group, writer.uint32(90).fork()).join();
13236
- }
13237
- if (message.delete_group !== void 0) {
13238
- DeleteGroupAction.encode(message.delete_group, writer.uint32(98).fork()).join();
13239
- }
13240
12510
  if (message.set_variables !== void 0) {
13241
12511
  SetVariablesAction.encode(message.set_variables, writer.uint32(106).fork()).join();
13242
12512
  }
@@ -13270,6 +12540,9 @@ var Action = {
13270
12540
  if (message.set_use_providers !== void 0) {
13271
12541
  SetUseProvidersAction.encode(message.set_use_providers, writer.uint32(186).fork()).join();
13272
12542
  }
12543
+ if (message.ungroup !== void 0) {
12544
+ UngroupAction.encode(message.ungroup, writer.uint32(194).fork()).join();
12545
+ }
13273
12546
  return writer;
13274
12547
  },
13275
12548
  decode(input, length) {
@@ -13335,13 +12608,6 @@ var Action = {
13335
12608
  message.copy_instances = CopyInstancesAction.decode(reader, reader.uint32());
13336
12609
  continue;
13337
12610
  }
13338
- case 9: {
13339
- if (tag !== 74) {
13340
- break;
13341
- }
13342
- message.sync_layout = SyncLayoutAction.decode(reader, reader.uint32());
13343
- continue;
13344
- }
13345
12611
  case 10: {
13346
12612
  if (tag !== 82) {
13347
12613
  break;
@@ -13349,20 +12615,6 @@ var Action = {
13349
12615
  message.create_group = CreateGroupAction.decode(reader, reader.uint32());
13350
12616
  continue;
13351
12617
  }
13352
- case 11: {
13353
- if (tag !== 90) {
13354
- break;
13355
- }
13356
- message.update_group = UpdateGroupAction.decode(reader, reader.uint32());
13357
- continue;
13358
- }
13359
- case 12: {
13360
- if (tag !== 98) {
13361
- break;
13362
- }
13363
- message.delete_group = DeleteGroupAction.decode(reader, reader.uint32());
13364
- continue;
13365
- }
13366
12618
  case 13: {
13367
12619
  if (tag !== 106) {
13368
12620
  break;
@@ -13440,6 +12692,13 @@ var Action = {
13440
12692
  message.set_use_providers = SetUseProvidersAction.decode(reader, reader.uint32());
13441
12693
  continue;
13442
12694
  }
12695
+ case 24: {
12696
+ if (tag !== 194) {
12697
+ break;
12698
+ }
12699
+ message.ungroup = UngroupAction.decode(reader, reader.uint32());
12700
+ continue;
12701
+ }
13443
12702
  }
13444
12703
  if ((tag & 7) === 4 || tag === 0) {
13445
12704
  break;
@@ -13458,10 +12717,7 @@ var Action = {
13458
12717
  rename_instance: isSet3(object.renameInstance) ? RenameInstanceAction.fromJSON(object.renameInstance) : isSet3(object.rename_instance) ? RenameInstanceAction.fromJSON(object.rename_instance) : void 0,
13459
12718
  delete_instance: isSet3(object.deleteInstance) ? DeleteInstanceAction.fromJSON(object.deleteInstance) : isSet3(object.delete_instance) ? DeleteInstanceAction.fromJSON(object.delete_instance) : void 0,
13460
12719
  copy_instances: isSet3(object.copyInstances) ? CopyInstancesAction.fromJSON(object.copyInstances) : isSet3(object.copy_instances) ? CopyInstancesAction.fromJSON(object.copy_instances) : void 0,
13461
- sync_layout: isSet3(object.syncLayout) ? SyncLayoutAction.fromJSON(object.syncLayout) : isSet3(object.sync_layout) ? SyncLayoutAction.fromJSON(object.sync_layout) : void 0,
13462
12720
  create_group: isSet3(object.createGroup) ? CreateGroupAction.fromJSON(object.createGroup) : isSet3(object.create_group) ? CreateGroupAction.fromJSON(object.create_group) : void 0,
13463
- update_group: isSet3(object.updateGroup) ? UpdateGroupAction.fromJSON(object.updateGroup) : isSet3(object.update_group) ? UpdateGroupAction.fromJSON(object.update_group) : void 0,
13464
- delete_group: isSet3(object.deleteGroup) ? DeleteGroupAction.fromJSON(object.deleteGroup) : isSet3(object.delete_group) ? DeleteGroupAction.fromJSON(object.delete_group) : void 0,
13465
12721
  set_variables: isSet3(object.setVariables) ? SetVariablesAction.fromJSON(object.setVariables) : isSet3(object.set_variables) ? SetVariablesAction.fromJSON(object.set_variables) : void 0,
13466
12722
  set_exports: isSet3(object.setExports) ? SetExportsAction.fromJSON(object.setExports) : isSet3(object.set_exports) ? SetExportsAction.fromJSON(object.set_exports) : void 0,
13467
12723
  set_terraform: isSet3(object.setTerraform) ? SetTerraformAction.fromJSON(object.setTerraform) : isSet3(object.set_terraform) ? SetTerraformAction.fromJSON(object.set_terraform) : void 0,
@@ -13472,7 +12728,8 @@ var Action = {
13472
12728
  undo: isSet3(object.undo) ? UndoAction.fromJSON(object.undo) : void 0,
13473
12729
  redo: isSet3(object.redo) ? RedoAction.fromJSON(object.redo) : void 0,
13474
12730
  place_module: isSet3(object.placeModule) ? PlaceModuleAction.fromJSON(object.placeModule) : isSet3(object.place_module) ? PlaceModuleAction.fromJSON(object.place_module) : void 0,
13475
- set_use_providers: isSet3(object.setUseProviders) ? SetUseProvidersAction.fromJSON(object.setUseProviders) : isSet3(object.set_use_providers) ? SetUseProvidersAction.fromJSON(object.set_use_providers) : void 0
12731
+ set_use_providers: isSet3(object.setUseProviders) ? SetUseProvidersAction.fromJSON(object.setUseProviders) : isSet3(object.set_use_providers) ? SetUseProvidersAction.fromJSON(object.set_use_providers) : void 0,
12732
+ ungroup: isSet3(object.ungroup) ? UngroupAction.fromJSON(object.ungroup) : void 0
13476
12733
  };
13477
12734
  },
13478
12735
  toJSON(message) {
@@ -13501,18 +12758,9 @@ var Action = {
13501
12758
  if (message.copy_instances !== void 0) {
13502
12759
  obj.copyInstances = CopyInstancesAction.toJSON(message.copy_instances);
13503
12760
  }
13504
- if (message.sync_layout !== void 0) {
13505
- obj.syncLayout = SyncLayoutAction.toJSON(message.sync_layout);
13506
- }
13507
12761
  if (message.create_group !== void 0) {
13508
12762
  obj.createGroup = CreateGroupAction.toJSON(message.create_group);
13509
12763
  }
13510
- if (message.update_group !== void 0) {
13511
- obj.updateGroup = UpdateGroupAction.toJSON(message.update_group);
13512
- }
13513
- if (message.delete_group !== void 0) {
13514
- obj.deleteGroup = DeleteGroupAction.toJSON(message.delete_group);
13515
- }
13516
12764
  if (message.set_variables !== void 0) {
13517
12765
  obj.setVariables = SetVariablesAction.toJSON(message.set_variables);
13518
12766
  }
@@ -13546,6 +12794,9 @@ var Action = {
13546
12794
  if (message.set_use_providers !== void 0) {
13547
12795
  obj.setUseProviders = SetUseProvidersAction.toJSON(message.set_use_providers);
13548
12796
  }
12797
+ if (message.ungroup !== void 0) {
12798
+ obj.ungroup = UngroupAction.toJSON(message.ungroup);
12799
+ }
13549
12800
  return obj;
13550
12801
  },
13551
12802
  create(base) {
@@ -13561,10 +12812,7 @@ var Action = {
13561
12812
  message.rename_instance = object.rename_instance !== void 0 && object.rename_instance !== null ? RenameInstanceAction.fromPartial(object.rename_instance) : void 0;
13562
12813
  message.delete_instance = object.delete_instance !== void 0 && object.delete_instance !== null ? DeleteInstanceAction.fromPartial(object.delete_instance) : void 0;
13563
12814
  message.copy_instances = object.copy_instances !== void 0 && object.copy_instances !== null ? CopyInstancesAction.fromPartial(object.copy_instances) : void 0;
13564
- message.sync_layout = object.sync_layout !== void 0 && object.sync_layout !== null ? SyncLayoutAction.fromPartial(object.sync_layout) : void 0;
13565
12815
  message.create_group = object.create_group !== void 0 && object.create_group !== null ? CreateGroupAction.fromPartial(object.create_group) : void 0;
13566
- message.update_group = object.update_group !== void 0 && object.update_group !== null ? UpdateGroupAction.fromPartial(object.update_group) : void 0;
13567
- message.delete_group = object.delete_group !== void 0 && object.delete_group !== null ? DeleteGroupAction.fromPartial(object.delete_group) : void 0;
13568
12816
  message.set_variables = object.set_variables !== void 0 && object.set_variables !== null ? SetVariablesAction.fromPartial(object.set_variables) : void 0;
13569
12817
  message.set_exports = object.set_exports !== void 0 && object.set_exports !== null ? SetExportsAction.fromPartial(object.set_exports) : void 0;
13570
12818
  message.set_terraform = object.set_terraform !== void 0 && object.set_terraform !== null ? SetTerraformAction.fromPartial(object.set_terraform) : void 0;
@@ -13576,6 +12824,7 @@ var Action = {
13576
12824
  message.redo = object.redo !== void 0 && object.redo !== null ? RedoAction.fromPartial(object.redo) : void 0;
13577
12825
  message.place_module = object.place_module !== void 0 && object.place_module !== null ? PlaceModuleAction.fromPartial(object.place_module) : void 0;
13578
12826
  message.set_use_providers = object.set_use_providers !== void 0 && object.set_use_providers !== null ? SetUseProvidersAction.fromPartial(object.set_use_providers) : void 0;
12827
+ message.ungroup = object.ungroup !== void 0 && object.ungroup !== null ? UngroupAction.fromPartial(object.ungroup) : void 0;
13579
12828
  return message;
13580
12829
  }
13581
12830
  };
@@ -14650,16 +13899,13 @@ var BundleStateEvent = {
14650
13899
  }
14651
13900
  };
14652
13901
  function createBaseBundleState() {
14653
- return { bundle: void 0, layouts: {}, can_undo: false, can_redo: false, is_dirty: false };
13902
+ return { bundle: void 0, can_undo: false, can_redo: false, is_dirty: false };
14654
13903
  }
14655
13904
  var BundleState = {
14656
13905
  encode(message, writer = new import_wire4.BinaryWriter()) {
14657
13906
  if (message.bundle !== void 0) {
14658
13907
  Bundle.encode(message.bundle, writer.uint32(10).fork()).join();
14659
13908
  }
14660
- globalThis.Object.entries(message.layouts).forEach(([key, value]) => {
14661
- BundleState_LayoutsEntry.encode({ key, value }, writer.uint32(18).fork()).join();
14662
- });
14663
13909
  if (message.can_undo !== false) {
14664
13910
  writer.uint32(24).bool(message.can_undo);
14665
13911
  }
@@ -14685,16 +13931,6 @@ var BundleState = {
14685
13931
  message.bundle = Bundle.decode(reader, reader.uint32());
14686
13932
  continue;
14687
13933
  }
14688
- case 2: {
14689
- if (tag !== 18) {
14690
- break;
14691
- }
14692
- const entry2 = BundleState_LayoutsEntry.decode(reader, reader.uint32());
14693
- if (entry2.value !== void 0) {
14694
- message.layouts[entry2.key] = entry2.value;
14695
- }
14696
- continue;
14697
- }
14698
13934
  case 3: {
14699
13935
  if (tag !== 24) {
14700
13936
  break;
@@ -14727,13 +13963,6 @@ var BundleState = {
14727
13963
  fromJSON(object) {
14728
13964
  return {
14729
13965
  bundle: isSet3(object.bundle) ? Bundle.fromJSON(object.bundle) : void 0,
14730
- layouts: isObject3(object.layouts) ? globalThis.Object.entries(object.layouts).reduce(
14731
- (acc, [key, value]) => {
14732
- acc[key] = GraphLayout.fromJSON(value);
14733
- return acc;
14734
- },
14735
- {}
14736
- ) : {},
14737
13966
  can_undo: isSet3(object.canUndo) ? globalThis.Boolean(object.canUndo) : isSet3(object.can_undo) ? globalThis.Boolean(object.can_undo) : false,
14738
13967
  can_redo: isSet3(object.canRedo) ? globalThis.Boolean(object.canRedo) : isSet3(object.can_redo) ? globalThis.Boolean(object.can_redo) : false,
14739
13968
  is_dirty: isSet3(object.isDirty) ? globalThis.Boolean(object.isDirty) : isSet3(object.is_dirty) ? globalThis.Boolean(object.is_dirty) : false
@@ -14744,15 +13973,6 @@ var BundleState = {
14744
13973
  if (message.bundle !== void 0) {
14745
13974
  obj.bundle = Bundle.toJSON(message.bundle);
14746
13975
  }
14747
- if (message.layouts) {
14748
- const entries = globalThis.Object.entries(message.layouts);
14749
- if (entries.length > 0) {
14750
- obj.layouts = {};
14751
- entries.forEach(([k, v]) => {
14752
- obj.layouts[k] = GraphLayout.toJSON(v);
14753
- });
14754
- }
14755
- }
14756
13976
  if (message.can_undo !== false) {
14757
13977
  obj.canUndo = message.can_undo;
14758
13978
  }
@@ -14770,53 +13990,54 @@ var BundleState = {
14770
13990
  fromPartial(object) {
14771
13991
  const message = createBaseBundleState();
14772
13992
  message.bundle = object.bundle !== void 0 && object.bundle !== null ? Bundle.fromPartial(object.bundle) : void 0;
14773
- message.layouts = globalThis.Object.entries(object.layouts ?? {}).reduce(
14774
- (acc, [key, value]) => {
14775
- if (value !== void 0) {
14776
- acc[key] = GraphLayout.fromPartial(value);
14777
- }
14778
- return acc;
14779
- },
14780
- {}
14781
- );
14782
13993
  message.can_undo = object.can_undo ?? false;
14783
13994
  message.can_redo = object.can_redo ?? false;
14784
13995
  message.is_dirty = object.is_dirty ?? false;
14785
13996
  return message;
14786
13997
  }
14787
13998
  };
14788
- function createBaseBundleState_LayoutsEntry() {
14789
- return { key: "", value: void 0 };
13999
+ function createBaseBundleApplyResult() {
14000
+ return { success: false, errors: [], created: [] };
14790
14001
  }
14791
- var BundleState_LayoutsEntry = {
14002
+ var BundleApplyResult = {
14792
14003
  encode(message, writer = new import_wire4.BinaryWriter()) {
14793
- if (message.key !== "") {
14794
- writer.uint32(10).string(message.key);
14004
+ if (message.success !== false) {
14005
+ writer.uint32(8).bool(message.success);
14795
14006
  }
14796
- if (message.value !== void 0) {
14797
- GraphLayout.encode(message.value, writer.uint32(18).fork()).join();
14007
+ for (const v of message.errors) {
14008
+ GraphError.encode(v, writer.uint32(18).fork()).join();
14009
+ }
14010
+ for (const v of message.created) {
14011
+ CreatedRef.encode(v, writer.uint32(26).fork()).join();
14798
14012
  }
14799
14013
  return writer;
14800
14014
  },
14801
14015
  decode(input, length) {
14802
14016
  const reader = input instanceof import_wire4.BinaryReader ? input : new import_wire4.BinaryReader(input);
14803
14017
  const end = length === void 0 ? reader.len : reader.pos + length;
14804
- const message = createBaseBundleState_LayoutsEntry();
14018
+ const message = createBaseBundleApplyResult();
14805
14019
  while (reader.pos < end) {
14806
14020
  const tag = reader.uint32();
14807
14021
  switch (tag >>> 3) {
14808
14022
  case 1: {
14809
- if (tag !== 10) {
14023
+ if (tag !== 8) {
14810
14024
  break;
14811
14025
  }
14812
- message.key = reader.string();
14026
+ message.success = reader.bool();
14813
14027
  continue;
14814
14028
  }
14815
14029
  case 2: {
14816
14030
  if (tag !== 18) {
14817
14031
  break;
14818
14032
  }
14819
- message.value = GraphLayout.decode(reader, reader.uint32());
14033
+ message.errors.push(GraphError.decode(reader, reader.uint32()));
14034
+ continue;
14035
+ }
14036
+ case 3: {
14037
+ if (tag !== 26) {
14038
+ break;
14039
+ }
14040
+ message.created.push(CreatedRef.decode(reader, reader.uint32()));
14820
14041
  continue;
14821
14042
  }
14822
14043
  }
@@ -14829,62 +14050,87 @@ var BundleState_LayoutsEntry = {
14829
14050
  },
14830
14051
  fromJSON(object) {
14831
14052
  return {
14832
- key: isSet3(object.key) ? globalThis.String(object.key) : "",
14833
- value: isSet3(object.value) ? GraphLayout.fromJSON(object.value) : void 0
14053
+ success: isSet3(object.success) ? globalThis.Boolean(object.success) : false,
14054
+ errors: globalThis.Array.isArray(object?.errors) ? object.errors.map((e) => GraphError.fromJSON(e)) : [],
14055
+ created: globalThis.Array.isArray(object?.created) ? object.created.map((e) => CreatedRef.fromJSON(e)) : []
14834
14056
  };
14835
14057
  },
14836
14058
  toJSON(message) {
14837
14059
  const obj = {};
14838
- if (message.key !== "") {
14839
- obj.key = message.key;
14060
+ if (message.success !== false) {
14061
+ obj.success = message.success;
14840
14062
  }
14841
- if (message.value !== void 0) {
14842
- obj.value = GraphLayout.toJSON(message.value);
14063
+ if (message.errors?.length) {
14064
+ obj.errors = message.errors.map((e) => GraphError.toJSON(e));
14065
+ }
14066
+ if (message.created?.length) {
14067
+ obj.created = message.created.map((e) => CreatedRef.toJSON(e));
14843
14068
  }
14844
14069
  return obj;
14845
14070
  },
14846
14071
  create(base) {
14847
- return BundleState_LayoutsEntry.fromPartial(base ?? {});
14072
+ return BundleApplyResult.fromPartial(base ?? {});
14848
14073
  },
14849
14074
  fromPartial(object) {
14850
- const message = createBaseBundleState_LayoutsEntry();
14851
- message.key = object.key ?? "";
14852
- message.value = object.value !== void 0 && object.value !== null ? GraphLayout.fromPartial(object.value) : void 0;
14075
+ const message = createBaseBundleApplyResult();
14076
+ message.success = object.success ?? false;
14077
+ message.errors = object.errors?.map((e) => GraphError.fromPartial(e)) || [];
14078
+ message.created = object.created?.map((e) => CreatedRef.fromPartial(e)) || [];
14853
14079
  return message;
14854
14080
  }
14855
14081
  };
14856
- function createBaseBundleApplyResult() {
14857
- return { success: false, errors: [] };
14082
+ function createBaseCreatedRef() {
14083
+ return { scope: "", id: "", module_key: "", source_id: "" };
14858
14084
  }
14859
- var BundleApplyResult = {
14085
+ var CreatedRef = {
14860
14086
  encode(message, writer = new import_wire4.BinaryWriter()) {
14861
- if (message.success !== false) {
14862
- writer.uint32(8).bool(message.success);
14087
+ if (message.scope !== "") {
14088
+ writer.uint32(10).string(message.scope);
14863
14089
  }
14864
- for (const v of message.errors) {
14865
- GraphError.encode(v, writer.uint32(18).fork()).join();
14090
+ if (message.id !== "") {
14091
+ writer.uint32(18).string(message.id);
14092
+ }
14093
+ if (message.module_key !== "") {
14094
+ writer.uint32(26).string(message.module_key);
14095
+ }
14096
+ if (message.source_id !== "") {
14097
+ writer.uint32(34).string(message.source_id);
14866
14098
  }
14867
14099
  return writer;
14868
14100
  },
14869
14101
  decode(input, length) {
14870
14102
  const reader = input instanceof import_wire4.BinaryReader ? input : new import_wire4.BinaryReader(input);
14871
14103
  const end = length === void 0 ? reader.len : reader.pos + length;
14872
- const message = createBaseBundleApplyResult();
14104
+ const message = createBaseCreatedRef();
14873
14105
  while (reader.pos < end) {
14874
14106
  const tag = reader.uint32();
14875
14107
  switch (tag >>> 3) {
14876
14108
  case 1: {
14877
- if (tag !== 8) {
14109
+ if (tag !== 10) {
14878
14110
  break;
14879
14111
  }
14880
- message.success = reader.bool();
14112
+ message.scope = reader.string();
14881
14113
  continue;
14882
14114
  }
14883
14115
  case 2: {
14884
14116
  if (tag !== 18) {
14885
14117
  break;
14886
14118
  }
14887
- message.errors.push(GraphError.decode(reader, reader.uint32()));
14119
+ message.id = reader.string();
14120
+ continue;
14121
+ }
14122
+ case 3: {
14123
+ if (tag !== 26) {
14124
+ break;
14125
+ }
14126
+ message.module_key = reader.string();
14127
+ continue;
14128
+ }
14129
+ case 4: {
14130
+ if (tag !== 34) {
14131
+ break;
14132
+ }
14133
+ message.source_id = reader.string();
14888
14134
  continue;
14889
14135
  }
14890
14136
  }
@@ -14897,27 +14143,37 @@ var BundleApplyResult = {
14897
14143
  },
14898
14144
  fromJSON(object) {
14899
14145
  return {
14900
- success: isSet3(object.success) ? globalThis.Boolean(object.success) : false,
14901
- errors: globalThis.Array.isArray(object?.errors) ? object.errors.map((e) => GraphError.fromJSON(e)) : []
14146
+ scope: isSet3(object.scope) ? globalThis.String(object.scope) : "",
14147
+ id: isSet3(object.id) ? globalThis.String(object.id) : "",
14148
+ module_key: isSet3(object.moduleKey) ? globalThis.String(object.moduleKey) : isSet3(object.module_key) ? globalThis.String(object.module_key) : "",
14149
+ source_id: isSet3(object.sourceId) ? globalThis.String(object.sourceId) : isSet3(object.source_id) ? globalThis.String(object.source_id) : ""
14902
14150
  };
14903
14151
  },
14904
14152
  toJSON(message) {
14905
14153
  const obj = {};
14906
- if (message.success !== false) {
14907
- obj.success = message.success;
14154
+ if (message.scope !== "") {
14155
+ obj.scope = message.scope;
14908
14156
  }
14909
- if (message.errors?.length) {
14910
- obj.errors = message.errors.map((e) => GraphError.toJSON(e));
14157
+ if (message.id !== "") {
14158
+ obj.id = message.id;
14159
+ }
14160
+ if (message.module_key !== "") {
14161
+ obj.moduleKey = message.module_key;
14162
+ }
14163
+ if (message.source_id !== "") {
14164
+ obj.sourceId = message.source_id;
14911
14165
  }
14912
14166
  return obj;
14913
14167
  },
14914
14168
  create(base) {
14915
- return BundleApplyResult.fromPartial(base ?? {});
14169
+ return CreatedRef.fromPartial(base ?? {});
14916
14170
  },
14917
14171
  fromPartial(object) {
14918
- const message = createBaseBundleApplyResult();
14919
- message.success = object.success ?? false;
14920
- message.errors = object.errors?.map((e) => GraphError.fromPartial(e)) || [];
14172
+ const message = createBaseCreatedRef();
14173
+ message.scope = object.scope ?? "";
14174
+ message.id = object.id ?? "";
14175
+ message.module_key = object.module_key ?? "";
14176
+ message.source_id = object.source_id ?? "";
14921
14177
  return message;
14922
14178
  }
14923
14179
  };
@@ -16796,74 +16052,6 @@ var RenderError = {
16796
16052
  return message;
16797
16053
  }
16798
16054
  };
16799
- function createBasePosition2() {
16800
- return { x: 0, y: 0 };
16801
- }
16802
- var Position4 = {
16803
- encode(message, writer = new import_wire4.BinaryWriter()) {
16804
- if (message.x !== 0) {
16805
- writer.uint32(9).double(message.x);
16806
- }
16807
- if (message.y !== 0) {
16808
- writer.uint32(17).double(message.y);
16809
- }
16810
- return writer;
16811
- },
16812
- decode(input, length) {
16813
- const reader = input instanceof import_wire4.BinaryReader ? input : new import_wire4.BinaryReader(input);
16814
- const end = length === void 0 ? reader.len : reader.pos + length;
16815
- const message = createBasePosition2();
16816
- while (reader.pos < end) {
16817
- const tag = reader.uint32();
16818
- switch (tag >>> 3) {
16819
- case 1: {
16820
- if (tag !== 9) {
16821
- break;
16822
- }
16823
- message.x = reader.double();
16824
- continue;
16825
- }
16826
- case 2: {
16827
- if (tag !== 17) {
16828
- break;
16829
- }
16830
- message.y = reader.double();
16831
- continue;
16832
- }
16833
- }
16834
- if ((tag & 7) === 4 || tag === 0) {
16835
- break;
16836
- }
16837
- reader.skip(tag & 7);
16838
- }
16839
- return message;
16840
- },
16841
- fromJSON(object) {
16842
- return {
16843
- x: isSet3(object.x) ? globalThis.Number(object.x) : 0,
16844
- y: isSet3(object.y) ? globalThis.Number(object.y) : 0
16845
- };
16846
- },
16847
- toJSON(message) {
16848
- const obj = {};
16849
- if (message.x !== 0) {
16850
- obj.x = message.x;
16851
- }
16852
- if (message.y !== 0) {
16853
- obj.y = message.y;
16854
- }
16855
- return obj;
16856
- },
16857
- create(base) {
16858
- return Position4.fromPartial(base ?? {});
16859
- },
16860
- fromPartial(object) {
16861
- const message = createBasePosition2();
16862
- message.x = object.x ?? 0;
16863
- message.y = object.y ?? 0;
16864
- return message;
16865
- }
16866
- };
16867
16055
  function createBaseInputDef2() {
16868
16056
  return {
16869
16057
  name: "",
@@ -17249,7 +16437,7 @@ var ConnectWebEngine = class {
17249
16437
  this.subscribeAbort = null;
17250
16438
  this.listeners = /* @__PURE__ */ new Set();
17251
16439
  this.currentBundle = null;
17252
- this.currentLayouts = {};
16440
+ this.currentArrangement = {};
17253
16441
  this.currentCanUndo = false;
17254
16442
  this.currentCanRedo = false;
17255
16443
  this.currentIsDirty = false;
@@ -17275,6 +16463,18 @@ var ConnectWebEngine = class {
17275
16463
  getCurrentView() {
17276
16464
  return this.currentView;
17277
16465
  }
16466
+ getCurrentBundle() {
16467
+ return this.currentBundle;
16468
+ }
16469
+ /**
16470
+ * Replace the consumer-owned arrangement and re-project immediately —
16471
+ * a local view refresh, not a mutation, so it never carries a viewport
16472
+ * intent.
16473
+ */
16474
+ setArrangement(arrangement) {
16475
+ this.currentArrangement = arrangement;
16476
+ this.reproject();
16477
+ }
17278
16478
  requireSessionId() {
17279
16479
  if (!this._sessionId) throw new Error("No active session \u2014 call sessionOpen first");
17280
16480
  return this._sessionId;
@@ -17308,7 +16508,6 @@ var ConnectWebEngine = class {
17308
16508
  adoptState(state) {
17309
16509
  if (!state.bundle) return;
17310
16510
  this.currentBundle = state.bundle;
17311
- this.currentLayouts = state.layouts ?? {};
17312
16511
  this.currentCanUndo = state.can_undo;
17313
16512
  this.currentCanRedo = state.can_redo;
17314
16513
  this.currentIsDirty = state.is_dirty;
@@ -17317,8 +16516,8 @@ var ConnectWebEngine = class {
17317
16516
  }
17318
16517
  reproject() {
17319
16518
  if (!this.currentBundle) return;
17320
- const { id: moduleName } = (0, import_proto.parseModuleKey)(this.currentBundle.entry);
17321
- const view = (0, import_proto.projectCanvasView)(this.currentBundle, this.currentLayouts, {
16519
+ const { id: moduleName } = (0, import_proto4.parseModuleKey)(this.currentBundle.entry);
16520
+ const view = (0, import_proto4.projectCanvasView)(this.currentBundle, this.currentArrangement, {
17322
16521
  moduleName,
17323
16522
  canUndo: this.currentCanUndo,
17324
16523
  canRedo: this.currentCanRedo,
@@ -17438,7 +16637,7 @@ var ConnectWebEngine = class {
17438
16637
  this._sessionId = null;
17439
16638
  this.stopSubscribe();
17440
16639
  this.currentBundle = null;
17441
- this.currentLayouts = {};
16640
+ this.currentArrangement = {};
17442
16641
  this.currentView = null;
17443
16642
  return { status: res.status };
17444
16643
  }
@@ -17459,7 +16658,7 @@ var ConnectWebEngine = class {
17459
16658
  return {
17460
16659
  files_written: res.files_written.length > 0 ? res.files_written : void 0,
17461
16660
  files: Object.keys(res.files).length > 0 ? res.files : void 0,
17462
- diagnostics: res.diagnostics.map(import_proto.convertDiagnostic)
16661
+ diagnostics: res.diagnostics.map(import_proto4.convertDiagnostic)
17463
16662
  };
17464
16663
  }
17465
16664
  // ── Actions ──
@@ -17485,7 +16684,7 @@ var ConnectWebEngine = class {
17485
16684
  if (res.success) {
17486
16685
  await stateUpdated;
17487
16686
  }
17488
- return { success: res.success, errors };
16687
+ return { success: res.success, errors, created: res.created.map(convertCreatedRef) };
17489
16688
  }
17490
16689
  connect(source, target, sourceOutput, targetInput) {
17491
16690
  return this.applyAction({
@@ -17503,7 +16702,7 @@ var ConnectWebEngine = class {
17503
16702
  update_input: {
17504
16703
  instance_id: instanceId,
17505
16704
  input_name: inputName,
17506
- mode: (0, import_proto.modeToInputMode)(mode),
16705
+ mode: (0, import_proto4.modeToInputMode)(mode),
17507
16706
  value: value ?? void 0,
17508
16707
  variable: variable ?? "",
17509
16708
  expression: expression ?? ""
@@ -17516,7 +16715,7 @@ var ConnectWebEngine = class {
17516
16715
  instance_id: instanceId,
17517
16716
  inputs: inputs.map((i) => ({
17518
16717
  name: i.name,
17519
- mode: (0, import_proto.modeToInputMode)(i.mode),
16718
+ mode: (0, import_proto4.modeToInputMode)(i.mode),
17520
16719
  value: i.value ?? void 0,
17521
16720
  variable: i.variable ?? "",
17522
16721
  expression: i.expression ?? ""
@@ -17533,9 +16732,6 @@ var ConnectWebEngine = class {
17533
16732
  copyInstances(instanceIds) {
17534
16733
  return this.applyAction({ copy_instances: { instance_ids: instanceIds } });
17535
16734
  }
17536
- syncLayout(positions) {
17537
- return this.applyAction({ sync_layout: { positions } });
17538
- }
17539
16735
  setVariables(variables) {
17540
16736
  return this.applyAction({
17541
16737
  set_variables: {
@@ -17632,21 +16828,11 @@ var ConnectWebEngine = class {
17632
16828
  return this.applyAction({ redo: {} });
17633
16829
  }
17634
16830
  // ── Groups ──
17635
- createGroup(label, nodeIds) {
17636
- return this.applyAction({ create_group: { label, node_ids: nodeIds } });
17637
- }
17638
- updateGroup(groupId, updates) {
17639
- return this.applyAction({
17640
- update_group: {
17641
- group_id: groupId,
17642
- label: updates.label,
17643
- collapsed: updates.collapsed,
17644
- node_ids: updates.node_ids ? { node_ids: updates.node_ids } : void 0
17645
- }
17646
- });
16831
+ createGroup(nodeIds) {
16832
+ return this.applyAction({ create_group: { node_ids: nodeIds } });
17647
16833
  }
17648
- deleteGroup(groupId) {
17649
- return this.applyAction({ delete_group: { group_id: groupId } });
16834
+ ungroup(groupId) {
16835
+ return this.applyAction({ ungroup: { group_id: groupId } });
17650
16836
  }
17651
16837
  // ── Queries ──
17652
16838
  async queryNodeConfig(instanceId) {
@@ -17660,7 +16846,7 @@ var ConnectWebEngine = class {
17660
16846
  NodeConfigRequest,
17661
16847
  NodeConfig
17662
16848
  );
17663
- return (0, import_proto.convertNodeConfig)(res);
16849
+ return (0, import_proto4.convertNodeConfig)(res);
17664
16850
  }
17665
16851
  async queryEdgeConfig(source, target) {
17666
16852
  const req = {
@@ -17674,7 +16860,7 @@ var ConnectWebEngine = class {
17674
16860
  EdgeConfigRequest,
17675
16861
  EdgeConfig
17676
16862
  );
17677
- return (0, import_proto.convertEdgeConfig)(res);
16863
+ return (0, import_proto4.convertEdgeConfig)(res);
17678
16864
  }
17679
16865
  async querySettings() {
17680
16866
  const req = { session_id: this.requireSessionId() };
@@ -17684,7 +16870,7 @@ var ConnectWebEngine = class {
17684
16870
  QuerySettingsRequest,
17685
16871
  SettingsConfig
17686
16872
  );
17687
- return (0, import_proto.convertSettingsConfig)(res);
16873
+ return (0, import_proto4.convertSettingsConfig)(res);
17688
16874
  }
17689
16875
  async queryGraphSummary() {
17690
16876
  const req = { session_id: this.requireSessionId() };
@@ -17704,7 +16890,7 @@ var ConnectWebEngine = class {
17704
16890
  QueryValidateRequest,
17705
16891
  ValidateResponse
17706
16892
  );
17707
- return { errors: res.errors.map(import_proto.convertRenderError) };
16893
+ return { errors: res.errors.map(import_proto4.convertRenderError) };
17708
16894
  }
17709
16895
  async getModuleMetadata() {
17710
16896
  const req = { session_id: this.requireSessionId() };
@@ -17738,8 +16924,7 @@ var ConnectWebEngine = class {
17738
16924
  name: params.name,
17739
16925
  system: params.system,
17740
16926
  version: params.version,
17741
- organization: params.organization ?? "",
17742
- position: params.position
16927
+ organization: params.organization ?? ""
17743
16928
  }
17744
16929
  });
17745
16930
  }
@@ -17805,7 +16990,7 @@ var ConnectWebEngine = class {
17805
16990
  return;
17806
16991
  }
17807
16992
  if (event.generate_error) {
17808
- const diagnostics = event.generate_error.diagnostics.map(import_proto.convertDiagnostic);
16993
+ const diagnostics = event.generate_error.diagnostics.map(import_proto4.convertDiagnostic);
17809
16994
  this.emit({
17810
16995
  type: "generateError",
17811
16996
  message: event.generate_error.message,
@@ -17894,6 +17079,9 @@ function convertGraphError(e) {
17894
17079
  message: e.message
17895
17080
  };
17896
17081
  }
17082
+ function convertCreatedRef(r) {
17083
+ return { scope: r.scope, id: r.id, moduleKey: r.module_key, sourceId: r.source_id };
17084
+ }
17897
17085
  function protoModuleMetadataToCanvas(p) {
17898
17086
  return {
17899
17087
  id: p.id,
@@ -17996,7 +17184,7 @@ function consumeBytes(chunks, n) {
17996
17184
  }
17997
17185
 
17998
17186
  // src/post-message-engine.ts
17999
- var import_proto2 = require("@lace-cloud/proto");
17187
+ var import_proto5 = require("@lace-cloud/proto");
18000
17188
  var CALL_TIMEOUT_MS = 3e4;
18001
17189
  var INPUT_MODES = ["empty", "literal", "variable", "expression"];
18002
17190
  var PostMessageEngine = class {
@@ -18005,7 +17193,7 @@ var PostMessageEngine = class {
18005
17193
  this.pending = /* @__PURE__ */ new Map();
18006
17194
  this.listeners = /* @__PURE__ */ new Set();
18007
17195
  this.currentBundle = null;
18008
- this.currentLayouts = {};
17196
+ this.currentArrangement = {};
18009
17197
  this.currentCanUndo = false;
18010
17198
  this.currentCanRedo = false;
18011
17199
  this.currentIsDirty = false;
@@ -18067,18 +17255,43 @@ var PostMessageEngine = class {
18067
17255
  getCurrentView() {
18068
17256
  return this.currentView;
18069
17257
  }
17258
+ getCurrentBundle() {
17259
+ return this.currentBundle;
17260
+ }
17261
+ /**
17262
+ * Replace the consumer-owned arrangement and re-project immediately —
17263
+ * this is a local view refresh, not a mutation, so it never waits on a
17264
+ * round-trip and never carries a viewport intent (the consumer's camera
17265
+ * position is unaffected by a drag/collapse/rename it already applied
17266
+ * optimistically).
17267
+ */
17268
+ setArrangement(arrangement) {
17269
+ this.currentArrangement = arrangement;
17270
+ this.reproject();
17271
+ }
18070
17272
  emit(event) {
18071
17273
  for (const listener of this.listeners) listener(event);
18072
17274
  }
17275
+ reproject() {
17276
+ if (!this.currentBundle) return;
17277
+ const { id: moduleName } = (0, import_proto5.parseModuleKey)(this.currentBundle.entry);
17278
+ const view = (0, import_proto5.projectCanvasView)(this.currentBundle, this.currentArrangement, {
17279
+ moduleName,
17280
+ canUndo: this.currentCanUndo,
17281
+ canRedo: this.currentCanRedo,
17282
+ isDirty: this.currentIsDirty
17283
+ });
17284
+ this.currentView = view;
17285
+ this.emit({ type: "stateUpdated", view });
17286
+ }
18073
17287
  adoptState(state, viewportIntent) {
18074
17288
  if (!state.bundle) return;
18075
17289
  this.currentBundle = state.bundle;
18076
- this.currentLayouts = state.layouts ?? {};
18077
17290
  this.currentCanUndo = state.can_undo;
18078
17291
  this.currentCanRedo = state.can_redo;
18079
17292
  this.currentIsDirty = state.is_dirty;
18080
- const { id: moduleName } = (0, import_proto2.parseModuleKey)(this.currentBundle.entry);
18081
- const view = (0, import_proto2.projectCanvasView)(this.currentBundle, this.currentLayouts, {
17293
+ const { id: moduleName } = (0, import_proto5.parseModuleKey)(this.currentBundle.entry);
17294
+ const view = (0, import_proto5.projectCanvasView)(this.currentBundle, this.currentArrangement, {
18082
17295
  moduleName,
18083
17296
  canUndo: this.currentCanUndo,
18084
17297
  canRedo: this.currentCanRedo,
@@ -18138,13 +17351,15 @@ var PostMessageEngine = class {
18138
17351
  // `loadState` message the host emits after subscribing to the CLI.
18139
17352
  async applyAction(action) {
18140
17353
  const stateUpdated = this.nextStateUpdate();
18141
- const res = await this.call("action/apply", {
18142
- action
18143
- });
17354
+ const res = await this.call("action/apply", { action });
18144
17355
  if (res.success) {
18145
17356
  await stateUpdated;
18146
17357
  }
18147
- return { success: res.success, errors: res.errors };
17358
+ return {
17359
+ success: res.success,
17360
+ errors: res.errors,
17361
+ created: (res.created ?? []).map(convertCreatedRef2)
17362
+ };
18148
17363
  }
18149
17364
  // ── Session ──
18150
17365
  async sessionOpen(filePath, workspaceName) {
@@ -18213,9 +17428,6 @@ var PostMessageEngine = class {
18213
17428
  copyInstances(instanceIds) {
18214
17429
  return this.applyAction({ copy_instances: { instance_ids: instanceIds } });
18215
17430
  }
18216
- syncLayout(positions) {
18217
- return this.applyAction({ sync_layout: { positions } });
18218
- }
18219
17431
  setVariables(variables) {
18220
17432
  return this.applyAction({
18221
17433
  set_variables: {
@@ -18317,27 +17529,16 @@ var PostMessageEngine = class {
18317
17529
  name: params.name,
18318
17530
  system: params.system,
18319
17531
  version: params.version,
18320
- organization: params.organization ?? "",
18321
- position: params.position
17532
+ organization: params.organization ?? ""
18322
17533
  }
18323
17534
  });
18324
17535
  }
18325
17536
  // ── Groups ──
18326
- createGroup(label, nodeIds) {
18327
- return this.applyAction({ create_group: { label, node_ids: nodeIds } });
18328
- }
18329
- updateGroup(groupId, updates) {
18330
- return this.applyAction({
18331
- update_group: {
18332
- group_id: groupId,
18333
- label: updates.label,
18334
- collapsed: updates.collapsed,
18335
- node_ids: updates.node_ids ? { node_ids: updates.node_ids } : void 0
18336
- }
18337
- });
17537
+ createGroup(nodeIds) {
17538
+ return this.applyAction({ create_group: { node_ids: nodeIds } });
18338
17539
  }
18339
- deleteGroup(groupId) {
18340
- return this.applyAction({ delete_group: { group_id: groupId } });
17540
+ ungroup(groupId) {
17541
+ return this.applyAction({ ungroup: { group_id: groupId } });
18341
17542
  }
18342
17543
  // ── Queries ──
18343
17544
  queryNodeConfig(instanceId) {
@@ -18400,6 +17601,9 @@ var PostMessageEngine = class {
18400
17601
  });
18401
17602
  }
18402
17603
  };
17604
+ function convertCreatedRef2(r) {
17605
+ return { scope: r.scope, id: r.id, moduleKey: r.module_key, sourceId: r.source_id };
17606
+ }
18403
17607
  function convertPolicyResolution2(p) {
18404
17608
  return {
18405
17609
  mode: p.mode,
@@ -18441,11 +17645,12 @@ function modeToProtoInputMode(mode) {
18441
17645
  }
18442
17646
 
18443
17647
  // src/snapshot-engine.ts
18444
- var import_proto3 = require("@lace-cloud/proto");
17648
+ var import_proto6 = require("@lace-cloud/proto");
18445
17649
  var READ_ONLY_ERROR_MESSAGE = "SnapshotCanvasEngine is read-only";
18446
17650
  var READ_ONLY_RESULT = {
18447
17651
  success: false,
18448
- errors: [{ moduleKey: "", instanceId: "", inputName: "", message: READ_ONLY_ERROR_MESSAGE }]
17652
+ errors: [{ moduleKey: "", instanceId: "", inputName: "", message: READ_ONLY_ERROR_MESSAGE }],
17653
+ created: []
18449
17654
  };
18450
17655
  var EMPTY_NODE_CONFIG = {
18451
17656
  instance_id: "",
@@ -18475,16 +17680,20 @@ var SnapshotCanvasEngine = class {
18475
17680
  constructor(input) {
18476
17681
  this.loadPromise = null;
18477
17682
  this.view = null;
17683
+ this.bundle = null;
17684
+ this.listeners = /* @__PURE__ */ new Set();
18478
17685
  this.input = input;
18479
17686
  const injected = "bundleUrl" in input ? input.fetch : void 0;
18480
17687
  this.fetchImpl = injected ?? globalThis.fetch.bind(globalThis);
17688
+ this.meta = input.meta ?? {};
18481
17689
  if ("bundle" in input) {
18482
- this.view = this.projectInput(input.bundle, input.layouts ?? {}, input.meta ?? {});
17690
+ this.bundle = input.bundle;
17691
+ this.view = this.projectInput(input.bundle, input.arrangement, this.meta);
18483
17692
  }
18484
17693
  }
18485
- projectInput(bundle, layouts, meta) {
18486
- const { id: moduleName } = (0, import_proto3.parseModuleKey)(bundle.entry);
18487
- return (0, import_proto3.projectCanvasView)(bundle, layouts, {
17694
+ projectInput(bundle, arrangement, meta) {
17695
+ const { id: moduleName } = (0, import_proto6.parseModuleKey)(bundle.entry);
17696
+ return (0, import_proto6.projectCanvasView)(bundle, arrangement, {
18488
17697
  moduleName: meta.moduleName ?? moduleName,
18489
17698
  canUndo: meta.canUndo ?? false,
18490
17699
  canRedo: meta.canRedo ?? false,
@@ -18496,15 +17705,13 @@ var SnapshotCanvasEngine = class {
18496
17705
  if (!this.loadPromise) {
18497
17706
  const input = this.input;
18498
17707
  if (!("bundleUrl" in input)) {
18499
- throw new Error("SnapshotCanvasEngine: no view and no URLs to fetch");
17708
+ throw new Error("SnapshotCanvasEngine: no view and no URL to fetch");
18500
17709
  }
18501
17710
  this.loadPromise = (async () => {
18502
- const [bundleBytes, layouts] = await Promise.all([
18503
- this.fetchBytes(input.bundleUrl, "bundle", input.headers),
18504
- this.fetchLayouts(input.layoutsUrl, input.headers)
18505
- ]);
17711
+ const bundleBytes = await this.fetchBytes(input.bundleUrl, "bundle", input.headers);
18506
17712
  const bundle = Bundle.decode(bundleBytes);
18507
- const view = this.projectInput(bundle, layouts, input.meta ?? {});
17713
+ this.bundle = bundle;
17714
+ const view = this.projectInput(bundle, input.arrangement, this.meta);
18508
17715
  this.view = view;
18509
17716
  return view;
18510
17717
  })();
@@ -18525,25 +17732,23 @@ var SnapshotCanvasEngine = class {
18525
17732
  }
18526
17733
  return new Uint8Array(await res.arrayBuffer());
18527
17734
  }
18528
- // Layouts are an optional overlay, not IR — see the comment at the
18529
- // `Promise.all` call site. A FETCH failure here (most commonly a Run
18530
- // with no layoutsR2Key, 404) is not an engine-load failure; it degrades
18531
- // to the same empty layouts map the in-process constructor accepts. A
18532
- // DECODE failure is different — corrupt or truncated bytes are real
18533
- // breakage, not an absent-layouts 404 — so `decode` stays outside the
18534
- // catch and still surfaces as `loadError`.
18535
- async fetchLayouts(url, headers) {
18536
- let bytes;
18537
- try {
18538
- bytes = await this.fetchBytes(url, "layouts", headers);
18539
- } catch {
18540
- return {};
18541
- }
18542
- return LayoutsMap.decode(bytes).layouts ?? {};
18543
- }
18544
17735
  getCurrentView() {
18545
17736
  return this.view;
18546
17737
  }
17738
+ getCurrentBundle() {
17739
+ return this.bundle;
17740
+ }
17741
+ // Re-projecting from a new arrangement is a pure local recompute, not an
17742
+ // IR mutation — a read-only mount (portal's control-plane dashboard)
17743
+ // still lets users expand/collapse groups and drag nodes as view-only
17744
+ // operations, and this is the single projection site those operations
17745
+ // route through, same as the mutating engines.
17746
+ setArrangement(arrangement) {
17747
+ if (!this.bundle) return;
17748
+ const view = this.projectInput(this.bundle, arrangement, this.meta);
17749
+ this.view = view;
17750
+ for (const listener of this.listeners) listener({ type: "stateUpdated", view });
17751
+ }
18547
17752
  // ── Session ──────────────────────────────────────────────────────────
18548
17753
  async sessionOpen() {
18549
17754
  return this.loadView();
@@ -18589,9 +17794,6 @@ var SnapshotCanvasEngine = class {
18589
17794
  async copyInstances(_instanceIds) {
18590
17795
  return READ_ONLY_RESULT;
18591
17796
  }
18592
- async syncLayout(_positions) {
18593
- return READ_ONLY_RESULT;
18594
- }
18595
17797
  async setVariables(_variables) {
18596
17798
  return READ_ONLY_RESULT;
18597
17799
  }
@@ -18625,13 +17827,10 @@ var SnapshotCanvasEngine = class {
18625
17827
  async placeModule(_params) {
18626
17828
  return READ_ONLY_RESULT;
18627
17829
  }
18628
- async createGroup(_label, _nodeIds) {
17830
+ async createGroup(_nodeIds) {
18629
17831
  return READ_ONLY_RESULT;
18630
17832
  }
18631
- async updateGroup(_groupId, _updates) {
18632
- return READ_ONLY_RESULT;
18633
- }
18634
- async deleteGroup(_groupId) {
17833
+ async ungroup(_groupId) {
18635
17834
  return READ_ONLY_RESULT;
18636
17835
  }
18637
17836
  // ── Queries (best-effort / empty) ────────────────────────────────────
@@ -18682,6 +17881,7 @@ var SnapshotCanvasEngine = class {
18682
17881
  // ── Events ───────────────────────────────────────────────────────────
18683
17882
  onEvent(listener) {
18684
17883
  let cancelled = false;
17884
+ this.listeners.add(listener);
18685
17885
  const deliver = (view) => {
18686
17886
  if (cancelled) return;
18687
17887
  const event = { type: "stateUpdated", view };
@@ -18701,6 +17901,7 @@ var SnapshotCanvasEngine = class {
18701
17901
  }
18702
17902
  return () => {
18703
17903
  cancelled = true;
17904
+ this.listeners.delete(listener);
18704
17905
  };
18705
17906
  }
18706
17907
  };