likec4 1.27.0 → 1.27.1

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.
@@ -21779,6 +21779,10 @@ function useReducedMotion() {
21779
21779
  const [shouldReduceMotion] = useState(prefersReducedMotion.current);
21780
21780
  return shouldReduceMotion;
21781
21781
  }
21782
+ function useReducedMotionConfig() {
21783
+ const reducedMotionPreference = useReducedMotion(), { reducedMotion } = useContext(MotionConfigContext);
21784
+ return reducedMotion === "never" ? !1 : reducedMotion === "always" ? !0 : reducedMotionPreference;
21785
+ }
21782
21786
  const wrap = (min2, max2, v) => {
21783
21787
  const rangeSize = max2 - min2;
21784
21788
  return ((v - min2) % rangeSize + rangeSize) % rangeSize + min2;
@@ -29050,6 +29054,9 @@ const { valueOf, toString: toString$1 } = Object.prototype, isEqual = (a2, b2) =
29050
29054
  }
29051
29055
  return a2 !== a2 && b2 !== b2;
29052
29056
  };
29057
+ function useDeepCompareEffect(callback, deps, effectHook = useEffect, ...effectHookRestArgs) {
29058
+ useCustomCompareEffect(callback, deps, isEqual, effectHook, ...effectHookRestArgs);
29059
+ }
29053
29060
  function useFirstMountState() {
29054
29061
  const isFirstMount = useRef(!0);
29055
29062
  return useEffect(() => {
@@ -30821,7 +30828,7 @@ const ZIndexes$1 = {
30821
30828
  }, MinZoom = 0.05, MaxZoom = 2;
30822
30829
  var Base;
30823
30830
  ((Base2) => {
30824
- const _setDimmed = (v, dimmed) => v.data.dimmed === dimmed ? v : {
30831
+ const _setDimmed = (v, dimmed) => (v.data.dimmed ?? !1) === dimmed ? v : {
30825
30832
  ...v,
30826
30833
  data: {
30827
30834
  ...v.data,
@@ -30832,7 +30839,7 @@ var Base;
30832
30839
  return arg2 !== void 0 ? _setDimmed(arg1, arg2) : (v) => _setDimmed(v, arg1);
30833
30840
  }
30834
30841
  Base2.setDimmed = setDimmed;
30835
- const _setHovered = (v, hovered) => v.data.hovered === hovered ? v : {
30842
+ const _setHovered = (v, hovered) => (v.data.hovered ?? !1) === hovered ? v : {
30836
30843
  ...v,
30837
30844
  data: {
30838
30845
  ...v.data,
@@ -34862,7 +34869,7 @@ function CompoundNodeContainer({
34862
34869
  "data-compound-title-inverse": opacity < 0.5
34863
34870
  },
34864
34871
  ...isDimmed !== !1 && {
34865
- "likec4-dimmed": isDimmed
34872
+ "data-likec4-dimmed": isDimmed
34866
34873
  },
34867
34874
  style: {
34868
34875
  ...style2,
@@ -35020,6 +35027,7 @@ const isSelected$1 = ".react-flow__edge.selected", edgeStroke = "--xy-edge-strok
35020
35027
  display: "none"
35021
35028
  }
35022
35029
  }), hideOnReducedGraphics = css(_hideOnReducedGraphics), edgePathBg = css(_hideOnReducedGraphics, {
35030
+ fill: "[none]",
35023
35031
  strokeWidth: "calc(var(--xy-edge-stroke-width) + 2)",
35024
35032
  strokeOpacity: 0.08,
35025
35033
  transitionProperty: "stroke-width, stroke-opacity",
@@ -35041,6 +35049,7 @@ const isSelected$1 = ".react-flow__edge.selected", edgeStroke = "--xy-edge-strok
35041
35049
  fill: "[var(--xy-edge-stroke)]",
35042
35050
  stroke: "[var(--xy-edge-stroke)]"
35043
35051
  }), cssEdgePath = css({
35052
+ fill: "[none]",
35044
35053
  strokeDashoffset: 10,
35045
35054
  _noReduceGraphics: {
35046
35055
  transition: "stroke 130ms ease-out,stroke-width 130ms ease-out"
@@ -35184,7 +35193,7 @@ const translate = {
35184
35193
  },
35185
35194
  _noReduceGraphics: {
35186
35195
  mixBlendMode: {
35187
- base: "plus-lighter",
35196
+ _dark: "plus-lighter",
35188
35197
  _light: "screen"
35189
35198
  }
35190
35199
  },
@@ -35193,9 +35202,6 @@ const translate = {
35193
35202
  },
35194
35203
  _reduceGraphicsOnPan: {
35195
35204
  display: "none"
35196
- },
35197
- _whenPanning: {
35198
- mixBlendMode: "normal"
35199
35205
  }
35200
35206
  }), labelsva = sva({
35201
35207
  slots: ["root", "stepNumber", "labelContents", "labelText", "labelTechnology"],
@@ -35298,7 +35304,7 @@ function EdgeLabel({
35298
35304
  }
35299
35305
  const toCssVarValue = (value) => {
35300
35306
  if (value !== void 0)
35301
- return e$2(value) ? `${value}px` : value;
35307
+ return e$2(value) ? `${Math.round(value)}px` : value;
35302
35308
  };
35303
35309
  function EdgeLabelContainer({
35304
35310
  edgeProps: {
@@ -35627,9 +35633,6 @@ const EdgePath = forwardRef(({
35627
35633
  "react-flow__edge-path",
35628
35634
  "react-flow__edge-interaction",
35629
35635
  cssEdgePath
35630
- // css({
35631
- // strokeDasharray: strokeDasharray,
35632
- // }),
35633
35636
  ),
35634
35637
  d: svgPath,
35635
35638
  style: style2,
@@ -35776,6 +35779,7 @@ const container$2 = css({
35776
35779
  display: "flex",
35777
35780
  alignItems: "center",
35778
35781
  justifyContent: "center",
35782
+ pointerEvents: "none",
35779
35783
  _after: {
35780
35784
  content: '" "',
35781
35785
  position: "absolute",
@@ -35896,7 +35900,7 @@ const indicator = css({
35896
35900
  },
35897
35901
  stroke: "likec4.palette.loContrast",
35898
35902
  fill: "[none]",
35899
- strokeWidth: 6,
35903
+ strokeWidth: 8,
35900
35904
  strokeOpacity: 0.8,
35901
35905
  visibility: "hidden",
35902
35906
  pointerEvents: "none",
@@ -35904,25 +35908,14 @@ const indicator = css({
35904
35908
  stroke: "[color-mix(in srgb, {colors.likec4.palette.fill} 50%,rgb(121, 121, 121))]"
35905
35909
  },
35906
35910
  _whenFocused: {
35907
- strokeWidth: 12,
35908
35911
  visibility: "visible"
35909
35912
  },
35910
35913
  _groupFocusVisible: {
35911
- strokeWidth: 12,
35912
35914
  visibility: "visible"
35913
35915
  },
35914
35916
  _whenSelected: {
35915
35917
  animationStyle: "indicator",
35916
35918
  visibility: "visible"
35917
- },
35918
- _shapeQueue: {
35919
- strokeWidth: 8
35920
- },
35921
- _shapeCylinder: {
35922
- strokeWidth: 8
35923
- },
35924
- _shapeStorage: {
35925
- strokeWidth: 8
35926
35919
  }
35927
35920
  }), fillElementFill = css({
35928
35921
  fill: "likec4.palette.fill"
@@ -36183,7 +36176,7 @@ const iconSize$2 = "--icon-size", title$4 = css.raw({
36183
36176
  display: "none"
36184
36177
  },
36185
36178
  _smallZoom: {
36186
- visibility: "hidden"
36179
+ display: "none"
36187
36180
  }
36188
36181
  }), technology = css.raw({
36189
36182
  flex: "0 0 auto",
@@ -36204,7 +36197,7 @@ const iconSize$2 = "--icon-size", title$4 = css.raw({
36204
36197
  display: "none"
36205
36198
  },
36206
36199
  _smallZoom: {
36207
- visibility: "hidden"
36200
+ display: "none"
36208
36201
  }
36209
36202
  }), varIconSize = `var(${iconSize$2})`, elementIcon$2 = css({
36210
36203
  flex: `0 0 ${varIconSize}`,
@@ -36253,6 +36246,7 @@ const iconSize$2 = "--icon-size", title$4 = css.raw({
36253
36246
  paddingLeft: "calc(var(--likec4-spacing) + 8px)",
36254
36247
  paddingRight: "calc(var(--likec4-spacing) + 8px)",
36255
36248
  overflow: "hidden",
36249
+ pointerEvents: "none",
36256
36250
  gap: "12px",
36257
36251
  _shapeQueue: {
36258
36252
  paddingLeft: "46px",
@@ -36647,7 +36641,7 @@ function Link({
36647
36641
  value,
36648
36642
  size: size2 = "md"
36649
36643
  }) {
36650
- const isNormalSize = size2 === "md", url = new URL(value.url, window.location.href).toString();
36644
+ const isNormalSize = size2 === "md", url = value.url.includes("://") ? value.url : new window.URL(value.url, window.location.href).toString();
36651
36645
  return /* @__PURE__ */ jsx(CopyButton$1, { value: url, children: ({ copied, copy }) => /* @__PURE__ */ jsxs(
36652
36646
  Anchor,
36653
36647
  {
@@ -36979,7 +36973,7 @@ const curve = d3line().curve(curveCatmullRomOpen).x((d2) => d2.x).y((d2) => d2.y
36979
36973
  setLabelPos((current) => isSamePoint(current, point2) ? current : point2);
36980
36974
  }, [edgePath]), useDebouncedEffect(
36981
36975
  () => {
36982
- !labelBBox || labelBBox.x === labelPos.x && labelBBox.y === labelPos.y || xyflow2.updateEdgeData(id2, {
36976
+ !labelBBox || labelBBox.x === labelPos.x && labelBBox.y === labelPos.y || diagram.updateEdgeData(id2, {
36983
36977
  labelXY: {
36984
36978
  x: labelPos.x,
36985
36979
  y: labelPos.y
@@ -37003,15 +36997,12 @@ const curve = d3line().curve(curveCatmullRomOpen).x((d2) => d2.x).y((d2) => d2.y
37003
36997
  };
37004
36998
  if (!isSamePoint(pointer2, clientPoint)) {
37005
36999
  setIsControlPointDragging(!0), hasMoved = !0, pointer2 = clientPoint;
37006
- const { x: x2, y: y2 } = xyflow2.screenToFlowPosition(pointer2, { snapToGrid: !1 });
37007
- xyflow2.updateEdgeData(id2, (xyedge) => {
37008
- const cp = (xyedge.data.controlPoints ?? controlPoints).slice();
37009
- return cp[index2] = {
37010
- x: Math.round(x2),
37011
- y: Math.round(y2)
37012
- }, {
37013
- controlPoints: cp
37014
- };
37000
+ const { x: x2, y: y2 } = xyflow2.screenToFlowPosition(pointer2, { snapToGrid: !1 }), cp = controlPoints.slice();
37001
+ cp[index2] = {
37002
+ x: Math.round(x2),
37003
+ y: Math.round(y2)
37004
+ }, diagram.updateEdgeData(id2, {
37005
+ controlPoints: cp
37015
37006
  });
37016
37007
  }
37017
37008
  e22.stopPropagation();
@@ -37032,10 +37023,8 @@ const curve = d3line().curve(curveCatmullRomOpen).x((d2) => d2.x).y((d2) => d2.y
37032
37023
  const onPointerUp = (e22) => {
37033
37024
  const newControlPoints = controlPoints.slice();
37034
37025
  newControlPoints.splice(index2, 1), e22.stopPropagation(), setTimeout(() => {
37035
- xyflow2.updateEdgeData(id2, { controlPoints: newControlPoints }), diagram.scheduleSaveManualLayout();
37036
- }, 10), domNode.removeEventListener("pointerup", onPointerUp, {
37037
- capture: !0
37038
- }), e22.stopPropagation();
37026
+ diagram.updateEdgeData(id2, { controlPoints: newControlPoints }), diagram.scheduleSaveManualLayout();
37027
+ }, 10);
37039
37028
  };
37040
37029
  domNode.addEventListener("pointerup", onPointerUp, {
37041
37030
  once: !0,
@@ -37054,25 +37043,25 @@ const curve = d3line().curve(curveCatmullRomOpen).x((d2) => d2.x).y((d2) => d2.y
37054
37043
  }
37055
37044
  }, onEdgePointerDown = (e2) => {
37056
37045
  const { domNode } = xyflowStore.getState();
37057
- !domNode || e2.pointerType !== "mouse" || e2.button === 2 && (xyflow2.updateEdgeData(id2, (edge) => {
37058
- const points2 = [
37059
- new VectorImpl(sourceX, sourceY),
37060
- ...controlPoints.map(vector) || [],
37061
- new VectorImpl(targetX, targetY)
37062
- ];
37063
- let pointer2 = { x: e2.clientX, y: e2.clientY };
37064
- const newPoint = vector(xyflow2.screenToFlowPosition(pointer2, { snapToGrid: !1 }));
37065
- let insertionIndex = 0, minDistance = 1 / 0;
37066
- for (let i2 = 0; i2 < points2.length - 1; i2++) {
37067
- const a2 = points2[i2], b2 = points2[i2 + 1], fromCurrentToNext = b2.sub(a2), fromCurrentToNew = newPoint.sub(a2), fromNextToNew = newPoint.sub(b2);
37068
- if (fromCurrentToNext.dot(fromCurrentToNew) * fromCurrentToNext.dot(fromNextToNew) < 0) {
37069
- const distanceToEdge = Math.abs(fromCurrentToNext.cross(fromCurrentToNew).abs() / fromCurrentToNext.abs());
37070
- distanceToEdge < minDistance && (minDistance = distanceToEdge, insertionIndex = i2);
37071
- }
37046
+ if (!domNode || e2.pointerType !== "mouse" || e2.button !== 2)
37047
+ return;
37048
+ const points2 = [
37049
+ new VectorImpl(sourceX, sourceY),
37050
+ ...controlPoints.map(vector) || [],
37051
+ new VectorImpl(targetX, targetY)
37052
+ ];
37053
+ let pointer2 = { x: e2.clientX, y: e2.clientY };
37054
+ const newPoint = vector(xyflow2.screenToFlowPosition(pointer2, { snapToGrid: !1 }));
37055
+ let insertionIndex = 0, minDistance = 1 / 0;
37056
+ for (let i2 = 0; i2 < points2.length - 1; i2++) {
37057
+ const a2 = points2[i2], b2 = points2[i2 + 1], fromCurrentToNext = b2.sub(a2), fromCurrentToNew = newPoint.sub(a2), fromNextToNew = newPoint.sub(b2);
37058
+ if (fromCurrentToNext.dot(fromCurrentToNew) * fromCurrentToNext.dot(fromNextToNew) < 0) {
37059
+ const distanceToEdge = Math.abs(fromCurrentToNext.cross(fromCurrentToNew).abs() / fromCurrentToNext.abs());
37060
+ distanceToEdge < minDistance && (minDistance = distanceToEdge, insertionIndex = i2);
37072
37061
  }
37073
- const newControlPoints = edge.data.controlPoints?.slice() || [];
37074
- return newControlPoints.splice(insertionIndex, 0, newPoint), { controlPoints: newControlPoints };
37075
- }), diagram.scheduleSaveManualLayout(), e2.stopPropagation());
37062
+ }
37063
+ const newControlPoints = controlPoints.slice() || [];
37064
+ newControlPoints.splice(insertionIndex, 0, newPoint), diagram.updateEdgeData(id2, { controlPoints: newControlPoints }), diagram.scheduleSaveManualLayout(), e2.stopPropagation();
37076
37065
  };
37077
37066
  let zIndex = ZIndexes$1.Edge;
37078
37067
  (hovered || active) && (zIndex = ZIndexes$1.Element + 1);
@@ -37114,7 +37103,7 @@ const curve = d3line().curve(curveCatmullRomOpen).x((d2) => d2.x).y((d2) => d2.y
37114
37103
  }
37115
37104
  )
37116
37105
  ] }),
37117
- enableEdgeEditing && controlPoints.length > 0 && /* @__PURE__ */ jsx(EdgeLabelRenderer, { children: /* @__PURE__ */ jsx(
37106
+ enableEdgeEditing && controlPoints.length > 0 && (selected2 || hovered || isControlPointDragging) && /* @__PURE__ */ jsx(EdgeLabelRenderer, { children: /* @__PURE__ */ jsx(
37118
37107
  EdgeContainer,
37119
37108
  {
37120
37109
  component: "svg",
@@ -37432,10 +37421,15 @@ function OpacityOption({
37432
37421
  );
37433
37422
  }
37434
37423
  const toolbarTitle = css({
37424
+ color: "mantine.colors.dimmed",
37435
37425
  fontSize: "10px",
37436
37426
  fontWeight: 600,
37427
+ maxWidth: "220px",
37437
37428
  cursor: "default",
37438
- userSelect: "all"
37429
+ userSelect: "all",
37430
+ textOverflow: "ellipsis",
37431
+ overflow: "hidden",
37432
+ whiteSpace: "nowrap"
37439
37433
  }), useSelectedNodesCount = () => useDiagramContext((s2) => s2.xynodes.filter((x2) => x2.selected).length);
37440
37434
  function Toolbar({ title: title2, children: children2, nodeProps, ...props }) {
37441
37435
  const selectedNodesCount = useSelectedNodesCount(), {
@@ -37469,7 +37463,7 @@ function Toolbar({ title: title2, children: children2, nodeProps, ...props }) {
37469
37463
  onDoubleClick: stopPropagation$1,
37470
37464
  withBorder: !0,
37471
37465
  children: /* @__PURE__ */ jsxs(Stack, { gap: "6px", children: [
37472
- /* @__PURE__ */ jsx(Box$1, { px: "4px", children: /* @__PURE__ */ jsx(Text, { c: "dimmed", className: toolbarTitle, children: title2 }) }),
37466
+ /* @__PURE__ */ jsx(Box$1, { px: "4px", children: /* @__PURE__ */ jsx(Text, { className: toolbarTitle, children: title2 }) }),
37473
37467
  /* @__PURE__ */ jsx(Group, { gap: 4, children: children2 })
37474
37468
  ] })
37475
37469
  }
@@ -41278,8 +41272,8 @@ const ElementDetailsButtonWithHandler$1 = (props) => {
41278
41272
  ancestorsFqn(subjectId).reverse().forEach((id2) => {
41279
41273
  tree.expand(id2);
41280
41274
  }), tree.select(subjectId);
41281
- }, [subjectId]), /* @__PURE__ */ jsxs(Group, { ref: root2, gap: "xs", wrap: "nowrap", pos: "relative", children: [
41282
- enableSelectSubject && /* @__PURE__ */ jsxs(Fragment$1, { children: [
41275
+ }, [subjectId]), /* @__PURE__ */ jsxs(Group, { ref: root2, gap: "xs", pos: "relative", children: [
41276
+ enableSelectSubject && /* @__PURE__ */ jsxs(Group, { gap: 4, wrap: "nowrap", children: [
41283
41277
  /* @__PURE__ */ jsx(
41284
41278
  Box$1,
41285
41279
  {
@@ -41383,7 +41377,7 @@ const ElementDetailsButtonWithHandler$1 = (props) => {
41383
41377
  }
41384
41378
  ) })
41385
41379
  ] }),
41386
- enableChangeScope && /* @__PURE__ */ jsxs(Fragment$1, { children: [
41380
+ enableChangeScope && /* @__PURE__ */ jsxs(Group, { gap: 4, wrap: "nowrap", children: [
41387
41381
  enableSelectSubject && /* @__PURE__ */ jsx(
41388
41382
  Box$1,
41389
41383
  {
@@ -42348,11 +42342,10 @@ function ElementDetails({
42348
42342
  }
42349
42343
  ) });
42350
42344
  }
42351
- const backdropBlur = "--_blur", backdropOpacity = "--_opacity", borderRadius = "8px", dialog = css({
42345
+ const backdropBlur = "--_blur", backdropOpacity = "--_opacity", borderRadius = "--_border-radius", dialog = css({
42352
42346
  boxSizing: "border-box",
42353
42347
  margin: 0,
42354
42348
  position: "fixed",
42355
- inset: "3rem",
42356
42349
  width: "auto",
42357
42350
  height: "auto",
42358
42351
  maxWidth: "100vw",
@@ -42361,8 +42354,7 @@ const backdropBlur = "--_blur", backdropOpacity = "--_opacity", borderRadius = "
42361
42354
  shadow: "xl",
42362
42355
  border: "transparent",
42363
42356
  outline: "none",
42364
- borderRadius,
42365
- padding: "6px",
42357
+ borderRadius: `var(${borderRadius})`,
42366
42358
  [backdropBlur]: "0px",
42367
42359
  [backdropOpacity]: "0%",
42368
42360
  _backdrop: {
@@ -42373,32 +42365,53 @@ const backdropBlur = "--_blur", backdropOpacity = "--_opacity", borderRadius = "
42373
42365
  _light: `[rgb(15 15 15/ var(${backdropOpacity}))]`
42374
42366
  }
42375
42367
  },
42376
- mdDown: {
42377
- borderRadius: "sm",
42378
- inset: "2rem",
42379
- width: "calc(100vw - 4rem)",
42380
- height: "calc(100vh - 4rem)"
42381
- },
42382
42368
  smDown: {
42369
+ [borderRadius]: "0px",
42383
42370
  border: "none",
42384
42371
  inset: 0,
42385
42372
  padding: 0,
42386
42373
  width: "100vw",
42387
42374
  height: "100vh"
42375
+ },
42376
+ sm: {
42377
+ [borderRadius]: "6px",
42378
+ padding: "6px",
42379
+ inset: "1rem",
42380
+ width: "calc(100vw - 2rem)",
42381
+ height: "calc(100vh - 2rem)"
42382
+ },
42383
+ md: {
42384
+ inset: "2rem",
42385
+ width: "calc(100vw - 4rem)",
42386
+ height: "calc(100vh - 4rem)"
42387
+ },
42388
+ lg: {
42389
+ inset: "4rem",
42390
+ width: "calc(100vw - 8rem)",
42391
+ height: "calc(100vh - 8rem)"
42392
+ },
42393
+ xl: {
42394
+ [borderRadius]: "8px",
42395
+ padding: "8px",
42396
+ inset: "5rem",
42397
+ width: "calc(100vw - 10rem)",
42398
+ height: "calc(100vh - 10rem)"
42388
42399
  }
42389
42400
  }), body = css({
42390
42401
  position: "relative",
42391
42402
  containerName: "overlay-dialog",
42392
42403
  containerType: "size",
42393
42404
  border: "0 solid transparent",
42394
- borderRadius: `calc(${borderRadius} - 2px)`,
42395
42405
  background: "mantine.colors.body",
42396
42406
  overflow: "hidden",
42397
42407
  width: "100%",
42398
- height: "100%"
42408
+ height: "100%",
42409
+ sm: {
42410
+ borderRadius: `calc(var(${borderRadius}) - 2px)`
42411
+ }
42399
42412
  }), Overlay = forwardRef(
42400
42413
  ({ children: children2, onClose, className, classes: classes2, ...rest }, ref) => {
42401
- const [opened, setOpened] = useState(!1), dialogRef = useRef(null), isClosingRef = useRef(!1), onCloseRef = useSyncedRef(onClose), close = useDebouncedCallback(
42414
+ const [opened, setOpened] = useState(!1), dialogRef = useRef(null), isClosingRef = useRef(!1), motionNotReduced = useReducedMotionConfig() !== !0, onCloseRef = useSyncedRef(onClose), close = useDebouncedCallback(
42402
42415
  () => {
42403
42416
  isClosingRef.current || (isClosingRef.current = !0, onCloseRef.current());
42404
42417
  },
@@ -42421,33 +42434,35 @@ const backdropBlur = "--_blur", backdropOpacity = "--_opacity", borderRadius = "
42421
42434
  {
42422
42435
  ref: useMergedRef(dialogRef, ref),
42423
42436
  className: cx(RemoveScroll.classNames.fullWidth, dialog, classes2?.dialog, className),
42424
- initial: {
42425
- [backdropBlur]: "0px",
42426
- [backdropOpacity]: "0%",
42427
- scale: 1.075,
42428
- opacity: 0.2
42429
- // originY: 0.45,
42430
- // translateY: '-10px',
42431
- },
42432
- animate: {
42433
- [backdropBlur]: "8px",
42434
- [backdropOpacity]: "60%",
42435
- scale: 1,
42436
- opacity: 1,
42437
- // translateY: '0px',
42438
- transition: {
42439
- delay: 0.06
42440
- // duration: 0.2,
42437
+ layout: !0,
42438
+ ...motionNotReduced ? {
42439
+ initial: {
42440
+ [backdropBlur]: "0px",
42441
+ [backdropOpacity]: "0%",
42442
+ scale: 1.075,
42443
+ opacity: 0
42444
+ },
42445
+ animate: {
42446
+ [backdropBlur]: "8px",
42447
+ [backdropOpacity]: "60%",
42448
+ scale: 1,
42449
+ opacity: 1,
42450
+ transition: {
42451
+ delay: 0.075
42452
+ }
42453
+ },
42454
+ exit: {
42455
+ scale: 1.3,
42456
+ opacity: 0,
42457
+ translateY: -10,
42458
+ [backdropBlur]: "0px",
42459
+ [backdropOpacity]: "0%"
42460
+ }
42461
+ } : {
42462
+ initial: {
42463
+ [backdropBlur]: "8px",
42464
+ [backdropOpacity]: "60%"
42441
42465
  }
42442
- },
42443
- exit: {
42444
- scale: 1.3,
42445
- opacity: 0,
42446
- [backdropBlur]: "0px",
42447
- [backdropOpacity]: "0%"
42448
- // transition: {
42449
- // duration: 0.2,
42450
- // },
42451
42466
  },
42452
42467
  onClick: (e2) => {
42453
42468
  if (e2.stopPropagation(), e2.target?.nodeName?.toUpperCase() === "DIALOG") {
@@ -43753,7 +43768,7 @@ const sized = (height = Sizes$1.hodeHeight) => ({
43753
43768
  function nodeData(element, ctx) {
43754
43769
  let diagramNode = ctx.diagramNodes.get(element.id);
43755
43770
  const ancestor = diagramNode ?? C(
43756
- element.ancestors().toArray(),
43771
+ [...element.ancestors()],
43757
43772
  m((ancestor2) => ctx.diagramNodes.get(ancestor2.id)),
43758
43773
  T(n$5),
43759
43774
  d()
@@ -44096,7 +44111,7 @@ const selector$3 = (state) => ({
44096
44111
  ),
44097
44112
  /* @__PURE__ */ jsx(Group, { gap: "xs", wrap: "nowrap", ml: "sm", children: /* @__PURE__ */ jsx(SelectEdge, { edge, view }) })
44098
44113
  ] }) }) }));
44099
- function Fallback$1({ error, resetErrorBoundary }) {
44114
+ function Fallback$2({ error, resetErrorBoundary }) {
44100
44115
  const errorString = error instanceof Error ? error.message : "Unknown error";
44101
44116
  return /* @__PURE__ */ jsx(Box$1, { pos: "fixed", top: 0, left: 0, w: "100%", p: 0, style: { zIndex: 1e3 }, children: /* @__PURE__ */ jsxs(
44102
44117
  Notification,
@@ -44141,7 +44156,7 @@ const selectOverlays = (s2) => s2.context.overlays.map((overlay) => {
44141
44156
  }).filter(l$2), compareSelectOverlays = (a2, b2) => a2.length === b2.length && a2.every((overlay, i2) => overlay.actorRef === b2[i2].actorRef), Overlays = memo$2(({ overlaysActorRef }) => {
44142
44157
  const xyflowDomNode = useXYStore((s2) => s2.domNode), xyflowRendererDom = useMemo(() => xyflowDomNode?.querySelector(".react-flow__renderer") ?? null, [
44143
44158
  xyflowDomNode
44144
- ]), overlays = xstateReact_cjsExports.useSelector(overlaysActorRef, selectOverlays, compareSelectOverlays), isMotionReduced = useReducedMotion() ?? !1, isActiveOverlay = overlays.length > 0;
44159
+ ]), overlays = xstateReact_cjsExports.useSelector(overlaysActorRef, selectOverlays, compareSelectOverlays), isMotionReduced = useReducedMotionConfig() ?? !1, isActiveOverlay = overlays.length > 0;
44145
44160
  useEffect(() => {
44146
44161
  !xyflowRendererDom || isMotionReduced || animate(xyflowRendererDom, {
44147
44162
  opacity: isActiveOverlay ? 0.7 : 1,
@@ -44186,7 +44201,7 @@ const selectOverlays = (s2) => s2.context.overlays.map((overlay) => {
44186
44201
  nonexhaustive(overlay);
44187
44202
  }
44188
44203
  });
44189
- return /* @__PURE__ */ jsx(DiagramFeatures.Overlays, { children: /* @__PURE__ */ jsx(reactErrorBoundary_cjsExports.ErrorBoundary, { FallbackComponent: Fallback$1, onReset: () => overlaysActorRef.send({ type: "close.all" }), children: /* @__PURE__ */ jsx(LayoutGroup, { children: /* @__PURE__ */ jsx(AnimatePresence, { children: overlaysReact }) }) }) });
44204
+ return /* @__PURE__ */ jsx(DiagramFeatures.Overlays, { children: /* @__PURE__ */ jsx(reactErrorBoundary_cjsExports.ErrorBoundary, { FallbackComponent: Fallback$2, onReset: () => overlaysActorRef.send({ type: "close.all" }), children: /* @__PURE__ */ jsx(LayoutGroup, { children: /* @__PURE__ */ jsx(AnimatePresence, { children: overlaysReact }) }) }) });
44190
44205
  });
44191
44206
  Overlays.displayName = "Overlays";
44192
44207
  const root$1 = css({
@@ -45477,10 +45492,17 @@ const autolayoutButton = css({
45477
45492
  closeDelay: 100,
45478
45493
  ...props,
45479
45494
  children: [
45480
- /* @__PURE__ */ jsx(HoverCardTarget, { children: /* @__PURE__ */ jsxs(ActionIcon, { c: "orange", children: [
45481
- /* @__PURE__ */ jsx(Overlay$1, { color: "orange.lightHover", backgroundOpacity: 1 }),
45482
- /* @__PURE__ */ jsx(IconAlertTriangle, {})
45483
- ] }) }),
45495
+ /* @__PURE__ */ jsx(HoverCardTarget, { children: /* @__PURE__ */ jsx(
45496
+ ActionIcon,
45497
+ {
45498
+ color: "orange",
45499
+ c: "orange",
45500
+ className: css({
45501
+ bg: "mantine.colors.orange.light"
45502
+ }),
45503
+ children: /* @__PURE__ */ jsx(IconAlertTriangle, {})
45504
+ }
45505
+ ) }),
45484
45506
  /* @__PURE__ */ jsx(HoverCardDropdown, { p: "0", children: /* @__PURE__ */ jsxs(
45485
45507
  Notification,
45486
45508
  {
@@ -51532,7 +51554,7 @@ class Rect {
51532
51554
  this.maxX = this.minX + Math.ceil(width), this.maxY = this.minY + Math.ceil(height), parent && parent.children.push(this);
51533
51555
  }
51534
51556
  }
51535
- class Compound extends Rect {
51557
+ class CompoundRect extends Rect {
51536
51558
  constructor(xynode, parent = null) {
51537
51559
  super(xynode, parent), this.parent = parent;
51538
51560
  }
@@ -51552,39 +51574,39 @@ function createLayoutConstraints(xyflowApi, editingNodeIds) {
51552
51574
  return ancestors;
51553
51575
  }, ancestorsOfDraggingNodes = new Set(
51554
51576
  editingNodeIds.flatMap(ancestorsOf)
51555
- ), traverse = new Array();
51556
- for (const [, xynode] of nodeLookup)
51557
- n$1(xynode.parentId) && traverse.push({
51558
- xynode,
51559
- parent: null
51560
- });
51577
+ ), traverse = [...nodeLookup.values()].flatMap(
51578
+ (x2) => x2.parentId ? [] : { xynode: x2, parent: null }
51579
+ );
51561
51580
  for (; traverse.length > 0; ) {
51562
- const { xynode, parent } = traverse.shift(), shouldTraverse = !editingNodeIds.includes(xynode.id) && (xynode.type === "compound-element" || xynode.type === "compound-deployment" || xynode.type === "view-group") && ancestorsOfDraggingNodes.has(xynode.id), rect = shouldTraverse ? new Compound(xynode, parent) : new Leaf(xynode, parent);
51563
- rects.set(xynode.id, rect), shouldTraverse && parentLookup.get(xynode.id)?.forEach((child) => {
51564
- traverse.push({
51565
- xynode: child,
51566
- parent: rect
51581
+ const { xynode, parent } = traverse.shift();
51582
+ if (!editingNodeIds.includes(xynode.id) && xynode.type !== "element" && xynode.type !== "deployment" && ancestorsOfDraggingNodes.has(xynode.id)) {
51583
+ const rect = new CompoundRect(xynode, parent);
51584
+ rects.set(xynode.id, rect), parentLookup.get(xynode.id)?.forEach((child) => {
51585
+ traverse.push({
51586
+ xynode: child,
51587
+ parent: rect
51588
+ });
51567
51589
  });
51568
- });
51590
+ } else
51591
+ rects.set(xynode.id, new Leaf(xynode, parent));
51569
51592
  }
51570
51593
  const rectsToUpdate = [...rects.values()];
51571
51594
  applyConstraints2(rectsToUpdate);
51572
51595
  function applyConstraints2(targets) {
51573
- targets.filter((x2) => x2 instanceof Compound).forEach((r2) => {
51596
+ for (const r2 of targets) {
51597
+ if (!(r2 instanceof CompoundRect))
51598
+ continue;
51574
51599
  applyConstraints2(r2.children);
51575
- const childrenBB = r2.children.reduce((acc, r22) => ({
51576
- minX: Math.min(acc.minX, r22.minX),
51577
- minY: Math.min(acc.minY, r22.minY),
51578
- maxX: Math.max(acc.maxX, r22.maxX),
51579
- maxY: Math.max(acc.maxY, r22.maxY)
51580
- }), {
51600
+ const childrenBB = {
51581
51601
  minX: 1 / 0,
51582
51602
  minY: 1 / 0,
51583
51603
  maxX: -1 / 0,
51584
51604
  maxY: -1 / 0
51585
- });
51605
+ };
51606
+ for (const child of r2.children)
51607
+ childrenBB.minX = Math.min(childrenBB.minX, child.minX), childrenBB.minY = Math.min(childrenBB.minY, child.minY), childrenBB.maxX = Math.max(childrenBB.maxX, child.maxX), childrenBB.maxY = Math.max(childrenBB.maxY, child.maxY);
51586
51608
  r2.minX = childrenBB.minX - Rect.LeftPadding, r2.minY = childrenBB.minY - Rect.TopPadding, r2.maxX = childrenBB.maxX + Rect.RightPadding, r2.maxY = childrenBB.maxY + Rect.BottomPadding;
51587
- });
51609
+ }
51588
51610
  }
51589
51611
  function updateXYFlowNodes() {
51590
51612
  applyConstraints2(rectsToUpdate), xyflowApi.getState().triggerNodeChanges(
@@ -51594,7 +51616,7 @@ function createLayoutConstraints(xyflowApi, editingNodeIds) {
51594
51616
  dragging: !1,
51595
51617
  position: r2.position,
51596
51618
  positionAbsolute: r2.positionAbsolute
51597
- }), r2 instanceof Compound && acc.push({
51619
+ }), r2 instanceof CompoundRect && acc.push({
51598
51620
  id: r2.id,
51599
51621
  type: "dimensions",
51600
51622
  setAttributes: !0,
@@ -51603,52 +51625,49 @@ function createLayoutConstraints(xyflowApi, editingNodeIds) {
51603
51625
  );
51604
51626
  }
51605
51627
  let animationFrameId = null;
51606
- function onMove(updater) {
51628
+ function onMove() {
51607
51629
  rectsToUpdate.length !== 0 && (animationFrameId ??= requestAnimationFrame(() => {
51608
- animationFrameId = null, updater(
51609
- C(
51610
- editingNodeIds,
51611
- T((id2) => rects.has(id2) && nodeLookup.has(id2)),
51612
- m((id2) => ({
51613
- rect: nonNullable(rects.get(id2)),
51614
- node: nonNullable(nodeLookup.get(id2))
51615
- }))
51616
- )
51617
- ), updateXYFlowNodes();
51630
+ animationFrameId = null;
51631
+ const { nodeLookup: nodeLookup2 } = xyflowApi.getState();
51632
+ for (const id2 of editingNodeIds) {
51633
+ const rect = nonNullable(rects.get(id2)), node2 = nonNullable(nodeLookup2.get(id2));
51634
+ rect.positionAbsolute = node2.internals.positionAbsolute;
51635
+ }
51636
+ updateXYFlowNodes();
51618
51637
  }));
51619
51638
  }
51620
51639
  return {
51640
+ rects,
51621
51641
  updateXYFlowNodes,
51622
51642
  onMove
51623
51643
  };
51624
51644
  }
51625
51645
  function useLayoutConstraints() {
51626
51646
  const xystore = useXYStoreApi(), diagram = useDiagram(), solverRef = useRef(void 0);
51627
- return useMemo(() => ({
51628
- onNodeDragStart: (_event, xynode) => {
51629
- diagram.cancelSaveManualLayout();
51630
- const { nodeLookup } = xystore.getState(), draggingNodes = C(
51631
- Array.from(nodeLookup.values()),
51632
- T((n2) => n2.dragging === !0 || n2.id === xynode.id || n2.selected === !0),
51633
- T((n2) => n2.draggable !== !1),
51634
- m((x2) => x2.id)
51635
- );
51636
- i$9(draggingNodes, 1) && (solverRef.current = createLayoutConstraints(xystore, draggingNodes));
51637
- },
51638
- onNodeDrag: () => {
51639
- solverRef.current?.onMove((nodes) => {
51640
- nodes.forEach(({ rect, node: node2 }) => {
51641
- rect.positionAbsolute = node2.internals.positionAbsolute;
51642
- });
51643
- });
51644
- },
51645
- onNodeDragStop: () => {
51646
- solverRef.current?.updateXYFlowNodes(), diagram.scheduleSaveManualLayout(), solverRef.current = void 0;
51647
- }
51648
- }), [xystore, diagram]);
51647
+ return useMemo(() => {
51648
+ let wasPending = !1;
51649
+ const initial = { x: 0, y: 0 };
51650
+ let moved = !1;
51651
+ return {
51652
+ onNodeDragStart: (_event, xynode) => {
51653
+ wasPending = diagram.cancelSaveManualLayout();
51654
+ const { nodeLookup } = xystore.getState(), draggingNodes = C(
51655
+ Array.from(nodeLookup.values()),
51656
+ T((n2) => n2.draggable !== !1 && (n2.dragging === !0 || n2.id === xynode.id || n2.selected === !0))
51657
+ );
51658
+ i$9(draggingNodes, 1) && (solverRef.current = createLayoutConstraints(xystore, m(draggingNodes, (x2) => x2.id))), initial.x = _event.clientX, initial.y = _event.clientY, moved = !1;
51659
+ },
51660
+ onNodeDrag: (_event) => {
51661
+ moved = Math.abs(_event.clientX - initial.x) > 4 || Math.abs(_event.clientY - initial.y) > 4, solverRef.current?.onMove();
51662
+ },
51663
+ onNodeDragStop: (_event) => {
51664
+ moved = Math.abs(_event.clientX - initial.x) > 4 || Math.abs(_event.clientY - initial.y) > 4, console.log("moved", moved), (wasPending || moved) && diagram.scheduleSaveManualLayout(), solverRef.current = void 0;
51665
+ }
51666
+ };
51667
+ }, [xystore, diagram]);
51649
51668
  }
51650
51669
  const selectXYProps = (ctx) => ({
51651
- initialized: ctx.initialized,
51670
+ initialized: ctx.initialized.xydata && ctx.initialized.xyflow,
51652
51671
  nodes: ctx.xynodes,
51653
51672
  edges: ctx.xyedges,
51654
51673
  pannable: ctx.pannable,
@@ -51685,14 +51704,14 @@ const selectXYProps = (ctx) => ({
51685
51704
  onEdgeClick,
51686
51705
  onCanvasClick,
51687
51706
  onCanvasDblClick
51688
- } = useDiagramEventHandlers(), notReadOnly = !enableReadOnly, layoutConstraints = useLayoutConstraints(), $isPanning = usePanningAtom(), isPanning = useTimeout(() => {
51689
- $isPanning.set(!0);
51690
- }, 160), notPanning = useTimeout(() => {
51707
+ } = useDiagramEventHandlers(), notReadOnly = !enableReadOnly, isReducedGraphics = useIsReducedGraphics(), layoutConstraints = useLayoutConstraints(), $isPanning = usePanningAtom(), isPanning = useTimeout(() => {
51708
+ $isPanning.get() || $isPanning.set(!0);
51709
+ }, isReducedGraphics ? 150 : 350), notPanning = useDebouncedCallback$1(() => {
51691
51710
  isPanning.clear(), $isPanning.get() && $isPanning.set(!1);
51692
51711
  }, 120), onMove = useCallbackRef((event) => {
51693
- event && ($isPanning.get() || isPanning.start(), notPanning.clear(), notPanning.start());
51712
+ event && ($isPanning.get() || isPanning.start(), notPanning());
51694
51713
  }), onMoveEnd = useCallbackRef((event, viewport) => {
51695
- notPanning.start(), diagram.send({ type: "xyflow.viewportMoved", viewport, manually: !!event });
51714
+ notPanning.flush(), diagram.send({ type: "xyflow.viewportMoved", viewport, manually: !!event });
51696
51715
  }), onViewportResize = useCallbackRef(() => {
51697
51716
  diagram.send({ type: "xyflow.resized" });
51698
51717
  });
@@ -52567,8 +52586,8 @@ function updateActiveWalkthrough({ context: context2 }) {
52567
52586
  });
52568
52587
  }),
52569
52588
  xynodes: context2.xynodes.map((node2) => {
52570
- const active = step.source === node2.id || step.target === node2.id;
52571
- return Base.setDimmed(node2, !active);
52589
+ const dimmed = step.source !== node2.id && step.target !== node2.id;
52590
+ return Base.setDimmed(node2, dimmed);
52572
52591
  })
52573
52592
  };
52574
52593
  }
@@ -52753,6 +52772,7 @@ const diagramMachine = xstate_cjsExports.setup({
52753
52772
  overlaysActorLogic
52754
52773
  },
52755
52774
  guards: {
52775
+ isReady: ({ context: context2 }) => context2.initialized.xydata && context2.initialized.xyflow,
52756
52776
  "enabled: FitView": ({ context: context2 }) => context2.features.enableFitView,
52757
52777
  "enabled: FocusMode": ({ context: context2 }) => context2.features.enableFocusMode,
52758
52778
  "enabled: Readonly": ({ context: context2 }) => context2.features.enableReadOnly,
@@ -52844,15 +52864,17 @@ const diagramMachine = xstate_cjsExports.setup({
52844
52864
  console.warn("At least 2 nodes must be selected to align");
52845
52865
  return;
52846
52866
  }
52847
- const constraints = createLayoutConstraints(xystore, nodesToAlign), aligner = getAligner(mode);
52848
- constraints.onMove((nodes) => {
52849
- aligner.computeLayout(nodes.map(({ node: node2 }) => toNodeRect(node2))), nodes.forEach(({ rect, node: node2 }) => {
52850
- rect.positionAbsolute = {
52851
- ...rect.positionAbsolute,
52852
- ...aligner.applyPosition(toNodeRect(node2))
52853
- };
52854
- });
52855
- });
52867
+ const constraints = createLayoutConstraints(xystore, nodesToAlign), aligner = getAligner(mode), nodes = nodesToAlign.map((id2) => ({
52868
+ node: nonNullable(nodeLookup.get(id2)),
52869
+ rect: nonNullable(constraints.rects.get(id2))
52870
+ }));
52871
+ aligner.computeLayout(nodes.map(({ node: node2 }) => toNodeRect(node2)));
52872
+ for (const { rect, node: node2 } of nodes)
52873
+ rect.positionAbsolute = {
52874
+ ...rect.positionAbsolute,
52875
+ ...aligner.applyPosition(toNodeRect(node2))
52876
+ };
52877
+ constraints.updateXYFlowNodes();
52856
52878
  },
52857
52879
  updateFeatures: xstate_cjsExports.enqueueActions(({ enqueue, system, event }) => {
52858
52880
  xstate_cjsExports.assertEvent(event, "update.features");
@@ -52875,6 +52897,12 @@ const diagramMachine = xstate_cjsExports.setup({
52875
52897
  type: "close.all"
52876
52898
  }
52877
52899
  ),
52900
+ startSyncLayout: xstate_cjsExports.assign(({ context: context2, spawn, self: self2 }) => ({
52901
+ syncLayoutActorRef: spawn("syncManualLayoutActorLogic", {
52902
+ id: "syncLayout",
52903
+ input: { parent: self2, viewId: context2.view.id }
52904
+ })
52905
+ })),
52878
52906
  stopSyncLayout: xstate_cjsExports.enqueueActions(({ context: context2, enqueue }) => {
52879
52907
  enqueue.sendTo(context2.syncLayoutActorRef, { type: "stop" }), enqueue.stopChild(context2.syncLayoutActorRef), enqueue.assign({
52880
52908
  syncLayoutActorRef: null
@@ -52897,11 +52925,16 @@ const diagramMachine = xstate_cjsExports.setup({
52897
52925
  initial: "initializing",
52898
52926
  context: ({ input: input2, self: self2, spawn }) => ({
52899
52927
  ...input2,
52928
+ xyedges: [],
52929
+ xynodes: [],
52900
52930
  features: { ...AllDisabled },
52901
52931
  toggledFeatures: DiagramToggledFeaturesPersistence.read() ?? {
52902
52932
  enableReadOnly: !0
52903
52933
  },
52904
- initialized: !1,
52934
+ initialized: {
52935
+ xydata: !1,
52936
+ xyflow: !1
52937
+ },
52905
52938
  viewportChangedManually: !1,
52906
52939
  lastOnNavigate: null,
52907
52940
  lastClickedNode: null,
@@ -52914,10 +52947,7 @@ const diagramMachine = xstate_cjsExports.setup({
52914
52947
  },
52915
52948
  viewport: { x: 0, y: 0, zoom: 1 },
52916
52949
  xyflow: null,
52917
- syncLayoutActorRef: spawn("syncManualLayoutActorLogic", {
52918
- id: "syncLayout",
52919
- input: { parent: self2, viewId: input2.view.id }
52920
- }),
52950
+ syncLayoutActorRef: null,
52921
52951
  activeWalkthrough: null
52922
52952
  }),
52923
52953
  // entry: ({ spawn }) => spawn(layoutActor, { id: 'layout', input: { parent: self } }),
@@ -52925,30 +52955,54 @@ const diagramMachine = xstate_cjsExports.setup({
52925
52955
  initializing: {
52926
52956
  on: {
52927
52957
  "xyflow.init": {
52928
- actions: [
52929
- xstate_cjsExports.assign(({ context: context2, event }) => ({
52930
- initialized: !0,
52931
- xyflow: event.instance,
52932
- navigationHistory: {
52933
- currentIndex: 0,
52934
- history: [{
52935
- viewId: context2.view.id,
52936
- fromNode: null,
52937
- viewport: { ...event.instance.getViewport() }
52938
- }]
52939
- }
52940
- })),
52941
- xstate_cjsExports.enqueueActions(({ enqueue, check }) => {
52942
- check("enabled: FitView") && enqueue({
52943
- type: "xyflow:fitDiagram",
52944
- params: { duration: 0 }
52945
- });
52946
- })
52947
- ],
52948
- target: "ready"
52958
+ actions: xstate_cjsExports.assign(({ context: context2, event }) => ({
52959
+ initialized: {
52960
+ ...context2.initialized,
52961
+ xyflow: !0
52962
+ },
52963
+ xyflow: event.instance
52964
+ })),
52965
+ target: "isReady"
52966
+ },
52967
+ "update.view": {
52968
+ actions: xstate_cjsExports.assign(({ context: context2, event, spawn, self: self2 }) => ({
52969
+ initialized: {
52970
+ ...context2.initialized,
52971
+ xydata: !0
52972
+ },
52973
+ view: event.view,
52974
+ xynodes: event.xynodes,
52975
+ xyedges: event.xyedges
52976
+ })),
52977
+ target: "isReady"
52949
52978
  }
52950
52979
  }
52951
52980
  },
52981
+ isReady: {
52982
+ always: [{
52983
+ guard: "isReady",
52984
+ actions: [
52985
+ {
52986
+ type: "xyflow:fitDiagram",
52987
+ params: { duration: 0 }
52988
+ },
52989
+ "startSyncLayout",
52990
+ xstate_cjsExports.assign(({ context: context2 }) => ({
52991
+ navigationHistory: {
52992
+ currentIndex: 0,
52993
+ history: [{
52994
+ viewId: context2.view.id,
52995
+ fromNode: null,
52996
+ viewport: { ...context2.xyflow.getViewport() }
52997
+ }]
52998
+ }
52999
+ }))
53000
+ ],
53001
+ target: "ready"
53002
+ }, {
53003
+ target: "initializing"
53004
+ }]
53005
+ },
52952
53006
  ready: {
52953
53007
  initial: "idle",
52954
53008
  on: {
@@ -53282,14 +53336,6 @@ const diagramMachine = xstate_cjsExports.setup({
53282
53336
  })
53283
53337
  }
53284
53338
  ],
53285
- exit: xstate_cjsExports.assign({
53286
- syncLayoutActorRef: ({ self: self2, context: context2, spawn }) => spawn("syncManualLayoutActorLogic", {
53287
- id: "syncLayout",
53288
- systemId: "syncLayout",
53289
- input: { parent: self2, viewId: context2.view.id }
53290
- })
53291
- // lastOnNavigate: null,
53292
- }),
53293
53339
  on: {
53294
53340
  "update.view": {
53295
53341
  actions: xstate_cjsExports.enqueueActions(({ enqueue, context: context2, event }) => {
@@ -53306,9 +53352,10 @@ const diagramMachine = xstate_cjsExports.setup({
53306
53352
  }), enqueue.raise({ type: "fitDiagram" }, { id: "fitDiagram", delay: 80 })) : (enqueue({
53307
53353
  type: "xyflow:setViewportCenter",
53308
53354
  params: getBBoxCenter(event.view.bounds)
53309
- }), enqueue.raise({ type: "fitDiagram", duration: 200 }, { id: "fitDiagram", delay: 25 })), enqueue.assign(updateNavigationHistory), enqueue.assign(mergeXYNodesEdges), enqueue.assign({
53355
+ }), enqueue.raise({ type: "fitDiagram", duration: 200 }, { id: "fitDiagram", delay: 25 })), enqueue.assign(updateNavigationHistory), enqueue.assign({
53356
+ ...mergeXYNodesEdges({ context: context2, event }),
53310
53357
  lastOnNavigate: null
53311
- });
53358
+ }), enqueue("startSyncLayout");
53312
53359
  }),
53313
53360
  target: "#idle"
53314
53361
  }
@@ -53349,14 +53396,10 @@ const diagramMachine = xstate_cjsExports.setup({
53349
53396
  actions: [
53350
53397
  xstate_cjsExports.assign(updateNavigationHistory),
53351
53398
  xstate_cjsExports.enqueueActions(({ enqueue, event, check, context: context2 }) => {
53352
- if (check("is another view")) {
53353
- const viewId = event.view.id;
53399
+ const isAnotherView = check("is another view");
53400
+ if (isAnotherView) {
53354
53401
  enqueue("closeAllOverlays"), enqueue("stopSyncLayout"), enqueue.assign({
53355
- focusedNode: null,
53356
- syncLayoutActorRef: ({ self: self2, spawn }) => spawn("syncManualLayoutActorLogic", {
53357
- id: "syncLayout",
53358
- input: { parent: self2, viewId }
53359
- })
53402
+ focusedNode: null
53360
53403
  });
53361
53404
  const { fromNode, toNode } = findCorrespondingNode(context2, event);
53362
53405
  fromNode && toNode ? (enqueue({
@@ -53372,11 +53415,11 @@ const diagramMachine = xstate_cjsExports.setup({
53372
53415
  type: "xyflow:setViewportCenter",
53373
53416
  params: getBBoxCenter(event.view.bounds)
53374
53417
  }), enqueue.raise({ type: "fitDiagram", duration: 200 }, { id: "fitDiagram", delay: 25 }));
53375
- } else
53376
- enqueue.sendTo((c2) => c2.context.syncLayoutActorRef, { type: "synced" }), context2.viewportChangedManually || enqueue.raise({ type: "fitDiagram" }, { id: "fitDiagram", delay: 50 });
53377
- enqueue.assign(mergeXYNodesEdges), enqueue.assign({
53418
+ }
53419
+ enqueue.assign({
53420
+ ...mergeXYNodesEdges({ context: context2, event }),
53378
53421
  lastOnNavigate: null
53379
- });
53422
+ }), isAnotherView ? enqueue("startSyncLayout") : (enqueue.sendTo((c2) => c2.context.syncLayoutActorRef, { type: "synced" }), context2.viewportChangedManually || enqueue.raise({ type: "fitDiagram" }, { id: "fitDiagram", delay: 50 }));
53380
53423
  })
53381
53424
  ]
53382
53425
  },
@@ -53394,7 +53437,12 @@ const diagramMachine = xstate_cjsExports.setup({
53394
53437
  xstate_cjsExports.assign({
53395
53438
  xyflow: null,
53396
53439
  xystore: null,
53397
- initialized: !1,
53440
+ xyedges: [],
53441
+ xynodes: [],
53442
+ initialized: {
53443
+ xydata: !1,
53444
+ xyflow: !1
53445
+ },
53398
53446
  syncLayoutActorRef: null
53399
53447
  })
53400
53448
  ]
@@ -53403,62 +53451,64 @@ function findCorrespondingNode(context2, event) {
53403
53451
  const fromNodeId = context2.lastOnNavigate?.fromNode, fromNode = fromNodeId && context2.view.nodes.find((n2) => n2.id === fromNodeId), fromRef = fromNode && nodeRef(fromNode), toNode = fromRef && event.view.nodes.find((n2) => nodeRef(n2) === fromRef);
53404
53452
  return { fromNode, toNode };
53405
53453
  }
53406
- function DiagramActorProvider({ input: input2, children: children2 }) {
53407
- const handlersRef = useDiagramEventHandlersRef(), xystore = useStoreApi(), logic = useMemo(() => diagramMachine.provide({
53408
- actions: {
53409
- "trigger:NavigateTo": (_, { viewId }) => {
53410
- handlersRef.current.onNavigateTo?.(viewId);
53411
- },
53412
- "trigger:OnChange": (_, params) => {
53413
- handlersRef.current.onChange?.(params);
53454
+ const selectToggledFeatures = (state) => state.context.toggledFeatures;
53455
+ function DiagramActorProvider({
53456
+ input: {
53457
+ view,
53458
+ ...inputs
53459
+ },
53460
+ where,
53461
+ children: children2
53462
+ }) {
53463
+ const handlersRef = useDiagramEventHandlersRef(), xystore = useStoreApi(), actorRef = xstateReact_cjsExports.useActorRef(
53464
+ diagramMachine.provide({
53465
+ actions: {
53466
+ "trigger:NavigateTo": (_, { viewId }) => {
53467
+ handlersRef.current.onNavigateTo?.(viewId);
53468
+ },
53469
+ "trigger:OnChange": (_, params) => {
53470
+ handlersRef.current.onChange?.(params);
53471
+ },
53472
+ "trigger:OpenSource": (_, params) => {
53473
+ handlersRef.current.onOpenSource?.(params);
53474
+ }
53414
53475
  },
53415
- "trigger:OpenSource": (_, params) => {
53416
- handlersRef.current.onOpenSource?.(params);
53417
- }
53418
- },
53419
- actors: {
53420
- syncManualLayoutActorLogic: syncManualLayoutActorLogic.provide({
53421
- actions: {
53422
- "trigger:OnChange": (_, params) => {
53423
- handlersRef.current.onChange?.(params);
53476
+ actors: {
53477
+ syncManualLayoutActorLogic: syncManualLayoutActorLogic.provide({
53478
+ actions: {
53479
+ "trigger:OnChange": (_, params) => {
53480
+ handlersRef.current.onChange?.(params);
53481
+ }
53424
53482
  }
53425
- }
53426
- })
53427
- }
53428
- }), [handlersRef]), actorRef = xstateReact_cjsExports.useActorRef(
53429
- logic,
53483
+ })
53484
+ }
53485
+ }),
53430
53486
  {
53431
- id: `diagram:${input2.view.id}`,
53487
+ id: `diagram:${view.id}`,
53432
53488
  systemId: "diagram",
53433
53489
  // ...inspector,
53434
53490
  input: {
53435
53491
  xystore,
53436
- ...input2
53492
+ view,
53493
+ ...inputs
53437
53494
  }
53438
53495
  }
53439
- );
53440
- return /* @__PURE__ */ jsxs(DiagramActorSafeContext, { value: actorRef, children: [
53441
- /* @__PURE__ */ jsx(SyncStore, { input: input2, actorRef }),
53442
- /* @__PURE__ */ jsx(DiagramActorToggledFeatures, { actorRef, children: children2 })
53443
- ] });
53444
- }
53445
- const SyncStore = ({ input: { view, xyedges, xynodes, ...inputs }, actorRef }) => {
53446
- const features = useEnabledFeatures();
53496
+ ), features = useEnabledFeatures();
53447
53497
  useUpdateEffect(() => {
53448
53498
  actorRef.send({ type: "update.inputs", inputs });
53449
- }, [actorRef, inputs]), useEffect(() => {
53499
+ }, [inputs]), useEffect(() => {
53450
53500
  actorRef.send({ type: "update.features", features });
53451
- }, [actorRef, features]);
53452
- const frameReq = useRef(null);
53453
- return useUpdateEffect(() => (frameReq.current = requestAnimationFrame(() => {
53454
- frameReq.current = null, actorRef.send({ type: "update.view", view, xyedges, xynodes });
53455
- }), () => {
53456
- frameReq.current != null && cancelAnimationFrame(frameReq.current), frameReq.current = null;
53457
- }), [actorRef, view, xyedges, xynodes]), null;
53458
- }, selectToggledFeatures = (state) => state.context.toggledFeatures;
53459
- function DiagramActorToggledFeatures({ children: children2, actorRef }) {
53501
+ }, [features]);
53502
+ const { xyedges, xynodes } = useViewToNodesEdges({
53503
+ view,
53504
+ where,
53505
+ nodesSelectable: inputs.nodesSelectable
53506
+ });
53507
+ useDeepCompareEffect(() => {
53508
+ actorRef.send({ type: "update.view", view, xyedges, xynodes });
53509
+ }, [view, xyedges, xynodes]);
53460
53510
  const toggledFeatures = xstateReact_cjsExports.useSelector(actorRef, selectToggledFeatures, shallowEqual);
53461
- return /* @__PURE__ */ jsx(DiagramFeatures, { overrides: toggledFeatures, children: children2 });
53511
+ return /* @__PURE__ */ jsx(DiagramActorSafeContext, { value: actorRef, children: /* @__PURE__ */ jsx(DiagramFeatures, { overrides: toggledFeatures, children: children2 }) });
53462
53512
  }
53463
53513
  function LikeC4Diagram({
53464
53514
  onCanvasClick,
@@ -53502,11 +53552,7 @@ function LikeC4Diagram({
53502
53552
  reactFlowProps = {},
53503
53553
  children: children2
53504
53554
  }) {
53505
- const hasLikec4model = !!useLikeC4Model$1(), initialRef = useRef(null), xyNodesEdges = useViewToNodesEdges({
53506
- view,
53507
- where,
53508
- nodesSelectable
53509
- }), isDynamicView = view.__ === "dynamic";
53555
+ const hasLikec4model = !!useLikeC4Model$1(), initialRef = useRef(null), isDynamicView = view.__ === "dynamic";
53510
53556
  initialRef.current == null && (initialRef.current = {
53511
53557
  defaultEdges: [],
53512
53558
  defaultNodes: [],
@@ -53569,8 +53615,8 @@ function LikeC4Diagram({
53569
53615
  view,
53570
53616
  pannable,
53571
53617
  zoomable,
53572
- fitViewPadding,
53573
- ...xyNodesEdges
53618
+ nodesSelectable,
53619
+ fitViewPadding
53574
53620
  },
53575
53621
  children: /* @__PURE__ */ jsx(ControlsCustomLayoutProvider, { value: renderControls ?? null, children: /* @__PURE__ */ jsx(
53576
53622
  LikeC4DiagramXYFlow,
@@ -53637,7 +53683,7 @@ function StaticLikeC4Diagram({
53637
53683
  }
53638
53684
  );
53639
53685
  }
53640
- function Fallback({ error, resetErrorBoundary }) {
53686
+ function Fallback$1({ error, resetErrorBoundary }) {
53641
53687
  const router = useRouter();
53642
53688
  return isNotFound(error) ? /* @__PURE__ */ jsx(Container, { my: "md", children: /* @__PURE__ */ jsxs(Alert, { variant: "light", color: "orange", children: [
53643
53689
  /* @__PURE__ */ jsxs(Text, { c: "orange", fz: "md", children: [
@@ -53740,7 +53786,7 @@ const cssWebcomponentView = css({
53740
53786
  });
53741
53787
  function RouteComponent$2() {
53742
53788
  const { $likec4data, IconRenderer: IconRenderer2 } = Route$j.useLoaderData();
53743
- return /* @__PURE__ */ jsx(LikeC4ModelContext, { likec4data: $likec4data, children: /* @__PURE__ */ jsx(Box$1, { className: cssViewOutlet, children: /* @__PURE__ */ jsx(reactErrorBoundary_cjsExports.ErrorBoundary, { FallbackComponent: Fallback, children: /* @__PURE__ */ jsx(IconRendererProvider, { value: IconRenderer2, children: /* @__PURE__ */ jsx(Outlet, {}) }) }) }) });
53789
+ return /* @__PURE__ */ jsx(Box$1, { className: cssViewOutlet, children: /* @__PURE__ */ jsx(reactErrorBoundary_cjsExports.ErrorBoundary, { FallbackComponent: Fallback$1, children: /* @__PURE__ */ jsx(LikeC4ModelContext, { likec4data: $likec4data, children: /* @__PURE__ */ jsx(IconRendererProvider, { value: IconRenderer2, children: /* @__PURE__ */ jsx(Outlet, {}) }) }) }) });
53744
53790
  }
53745
53791
  const Route$i = createFileRoute("/")({
53746
53792
  beforeLoad: () => {
@@ -53853,7 +53899,7 @@ const Route$g = createFileRoute("/project/$projectId")({
53853
53899
  });
53854
53900
  function RouteComponent() {
53855
53901
  const { $likec4data, IconRenderer: IconRenderer2 } = Route$g.useLoaderData();
53856
- return /* @__PURE__ */ jsx(LikeC4ModelContext, { likec4data: $likec4data, children: /* @__PURE__ */ jsx(Box$1, { className: cssViewOutlet, children: /* @__PURE__ */ jsx(reactErrorBoundary_cjsExports.ErrorBoundary, { FallbackComponent: Fallback, children: /* @__PURE__ */ jsx(IconRendererProvider, { value: IconRenderer2, children: /* @__PURE__ */ jsx(Outlet, {}) }) }) }) });
53902
+ return /* @__PURE__ */ jsx(Box$1, { className: cssViewOutlet, children: /* @__PURE__ */ jsx(reactErrorBoundary_cjsExports.ErrorBoundary, { FallbackComponent: Fallback$1, children: /* @__PURE__ */ jsx(LikeC4ModelContext, { likec4data: $likec4data, children: /* @__PURE__ */ jsx(IconRendererProvider, { value: IconRenderer2, children: /* @__PURE__ */ jsx(Outlet, {}) }) }) }) });
53857
53903
  }
53858
53904
  const Route$f = createFileRoute("/project/$projectId/")({
53859
53905
  component: () => {
@@ -54565,8 +54611,42 @@ function ExportButton({ diagram }) {
54565
54611
  ] });
54566
54612
  }
54567
54613
  const Route$d = createFileRoute("/_single/view/$viewId")({
54568
- component: ViewLayout$2
54614
+ component: ViewLayout$2,
54615
+ errorComponent: ({ error, reset }) => /* @__PURE__ */ jsx(Fallback, { error, resetErrorBoundary: reset })
54569
54616
  });
54617
+ function Fallback({ error, resetErrorBoundary }) {
54618
+ const router = useRouter(), { viewId } = Route$d.useParams();
54619
+ return useUpdateEffect(() => {
54620
+ resetErrorBoundary();
54621
+ }, [viewId]), isNotFound(error) ? /* @__PURE__ */ jsx(Container, { my: "md", children: /* @__PURE__ */ jsxs(Alert, { variant: "light", color: "orange", children: [
54622
+ /* @__PURE__ */ jsxs(Text, { c: "orange", fz: "md", children: [
54623
+ "The diagram",
54624
+ " ",
54625
+ /* @__PURE__ */ jsx(Code, { color: "orange", children: viewId }),
54626
+ " ",
54627
+ "does not exist or contains errors"
54628
+ ] }),
54629
+ /* @__PURE__ */ jsx(
54630
+ Button,
54631
+ {
54632
+ onClick: () => {
54633
+ resetErrorBoundary(), router.navigate({
54634
+ to: "/",
54635
+ search: !0
54636
+ });
54637
+ },
54638
+ variant: "light",
54639
+ color: "orange",
54640
+ mt: "lg",
54641
+ size: "xs",
54642
+ children: "Go to overview"
54643
+ }
54644
+ )
54645
+ ] }) }) : /* @__PURE__ */ jsx(Container, { my: "md", children: /* @__PURE__ */ jsxs(Alert, { variant: "filled", color: "red", title: "Something went wrong", children: [
54646
+ /* @__PURE__ */ jsx(Code, { block: !0, color: "red", children: error.stack ?? error.message }),
54647
+ /* @__PURE__ */ jsx(Button, { onClick: resetErrorBoundary, color: "red", variant: "white", mt: "lg", size: "xs", children: "Try again" })
54648
+ ] }) });
54649
+ }
54570
54650
  function ViewLayout$2() {
54571
54651
  return /* @__PURE__ */ jsxs(Fragment$1, { children: [
54572
54652
  /* @__PURE__ */ jsx(Outlet, {}),