@principal-ai/subsystems-react 0.56.21 → 0.56.23
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.d.ts +5 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/stories/Canvases/Aggregate/aggregateViewLargeFixture.d.ts +12 -0
- package/dist/stories/Canvases/Aggregate/aggregateViewLargeFixture.d.ts.map +1 -0
- package/dist/stories/Canvases/Aggregate/aggregateViewLargeFixture.js +4 -0
- package/dist/stories/Canvases/Aggregate/aggregateViewLargeFixture.js.map +1 -0
- package/dist/subsystem/C4Graph.d.ts +2 -69
- package/dist/subsystem/C4Graph.d.ts.map +1 -1
- package/dist/subsystem/C4Graph.js +8 -154
- package/dist/subsystem/C4Graph.js.map +1 -1
- package/dist/subsystem/C4NodeCard.d.ts +1 -47
- package/dist/subsystem/C4NodeCard.d.ts.map +1 -1
- package/dist/subsystem/C4NodeCard.js +6 -141
- package/dist/subsystem/C4NodeCard.js.map +1 -1
- package/dist/subsystem/ContainersPanel.d.ts +33 -0
- package/dist/subsystem/ContainersPanel.d.ts.map +1 -0
- package/dist/subsystem/ContainersPanel.js +116 -0
- package/dist/subsystem/ContainersPanel.js.map +1 -0
- package/dist/subsystem/SubsystemAggregateGraph.d.ts +14 -0
- package/dist/subsystem/SubsystemAggregateGraph.d.ts.map +1 -1
- package/dist/subsystem/SubsystemAggregateGraph.js +116 -69
- package/dist/subsystem/SubsystemAggregateGraph.js.map +1 -1
- package/dist/subsystem/SubsystemComponentGraph.d.ts +18 -1
- package/dist/subsystem/SubsystemComponentGraph.d.ts.map +1 -1
- package/dist/subsystem/SubsystemComponentGraph.js +143 -21
- package/dist/subsystem/SubsystemComponentGraph.js.map +1 -1
- package/dist/subsystem/containerCard.d.ts +132 -0
- package/dist/subsystem/containerCard.d.ts.map +1 -0
- package/dist/subsystem/containerCard.js +167 -0
- package/dist/subsystem/containerCard.js.map +1 -0
- package/dist/subsystem/graphChrome.d.ts +11 -8
- package/dist/subsystem/graphChrome.d.ts.map +1 -1
- package/dist/subsystem/graphChrome.js +11 -9
- package/dist/subsystem/graphChrome.js.map +1 -1
- package/dist/subsystem/graphMorph.d.ts +142 -0
- package/dist/subsystem/graphMorph.d.ts.map +1 -0
- package/dist/subsystem/graphMorph.js +177 -0
- package/dist/subsystem/graphMorph.js.map +1 -0
- package/dist/subsystem/model.d.ts +89 -0
- package/dist/subsystem/model.d.ts.map +1 -1
- package/dist/subsystem/model.js +224 -15
- package/dist/subsystem/model.js.map +1 -1
- package/dist/subsystem/nodes.d.ts +9 -3
- package/dist/subsystem/nodes.d.ts.map +1 -1
- package/dist/subsystem/nodes.js +134 -82
- package/dist/subsystem/nodes.js.map +1 -1
- package/dist/utils/elkLayout.d.ts +11 -0
- package/dist/utils/elkLayout.d.ts.map +1 -1
- package/dist/utils/elkLayout.js +4 -3
- package/dist/utils/elkLayout.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +6 -0
- package/src/stories/Canvases/Aggregate/AggregateFrameGraph.stories.tsx +140 -2
- package/src/stories/Canvases/Aggregate/aggregateViewLargeFixture.ts +14 -0
- package/src/stories/Canvases/Subsystem/ContainerFrames.stories.tsx +132 -0
- package/src/subsystem/C4Graph.tsx +20 -180
- package/src/subsystem/C4NodeCard.tsx +34 -202
- package/src/subsystem/ContainersPanel.tsx +239 -0
- package/src/subsystem/SubsystemAggregateGraph.tsx +146 -78
- package/src/subsystem/SubsystemComponentGraph.tsx +222 -25
- package/src/subsystem/containerCard.tsx +264 -0
- package/src/subsystem/graphChrome.tsx +11 -9
- package/src/subsystem/graphMorph.tsx +212 -0
- package/src/subsystem/model.collapse.test.ts +128 -0
- package/src/subsystem/model.ts +306 -16
- package/src/subsystem/nodes.group.test.tsx +125 -16
- package/src/subsystem/nodes.tsx +201 -91
- package/src/utils/elkLayout.ts +16 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version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ACpB,mFAAmF;IACnF,KAAK,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,UAAU,CAAA;KAAE,CAAC;IAC5C,0EAA0E;IAC1E,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,EAClC,KAAK,EACL,IAAI,EACJ,SAAS,EACT,KAAK,EACL,QAAQ,EACR,KAAK,EACL,UAAU,EACV,KAAK,EACL,QAAgB,GACjB,EAAE,wBAAwB,+BA8G1B"}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* The shared card vocabulary a container draws with — on the C4 canvas as a
|
|
4
|
+
* `C4NodeCard`, and on the component graph as a process / package frame.
|
|
5
|
+
*
|
|
6
|
+
* Both canvases draw the same two rows at the top of a container: the label
|
|
7
|
+
* (two lines, kind glyph on the right) and the technology row (brand mark,
|
|
8
|
+
* technology, member count). Keeping the rows and their metrics here is what
|
|
9
|
+
* lets the two cards read as one notation, and what keeps each card's chrome a
|
|
10
|
+
* known quantity for the layout that has to reserve room for it.
|
|
11
|
+
*/
|
|
12
|
+
import { useTheme } from '@principal-ade/industry-theme';
|
|
13
|
+
import { TechMark } from './techIcons';
|
|
14
|
+
/**
|
|
15
|
+
* Card box for a container: a wide rectangle. A container carries four things
|
|
16
|
+
* at once (technology row, label, description, and the notation gap it still
|
|
17
|
+
* has), and a strip would force the last two to wrap hard.
|
|
18
|
+
*/
|
|
19
|
+
export const NODE_W = 250;
|
|
20
|
+
export const NODE_H = 150;
|
|
21
|
+
/**
|
|
22
|
+
* Fixed label slot, so the description below sits at the same y on every card
|
|
23
|
+
* even when a label is one line rather than two.
|
|
24
|
+
*/
|
|
25
|
+
export const LABEL_SLOT_H = 40;
|
|
26
|
+
/**
|
|
27
|
+
* The technology row's height, pinned for the same reason as the label slot: the
|
|
28
|
+
* row is a line of text plus an optional 16px brand mark, so its natural height
|
|
29
|
+
* depends on which of those are present. Pinning it makes the card's chrome a
|
|
30
|
+
* known quantity, which is what lets `descriptionLineBudget` say how many
|
|
31
|
+
* description lines fit — and lets the footer pad and the header pad agree about
|
|
32
|
+
* where the card's content actually ends.
|
|
33
|
+
*/
|
|
34
|
+
export const TECH_SLOT_H = 18;
|
|
35
|
+
/** The card's own vertical padding (`padding: '10px 12px'`). */
|
|
36
|
+
export const CARD_PAD_Y = 10;
|
|
37
|
+
/** The card's own horizontal padding. */
|
|
38
|
+
export const CARD_PAD_X = 12;
|
|
39
|
+
/** The card's flex `gap`, between each of its rows. */
|
|
40
|
+
export const CARD_GAP = 3;
|
|
41
|
+
/**
|
|
42
|
+
* Breathing room between a grown container's own chrome and the components nested
|
|
43
|
+
* inside it.
|
|
44
|
+
*
|
|
45
|
+
* The description is hidden while grown, so the components land where the
|
|
46
|
+
* description would have been — immediately under the technology row. Without
|
|
47
|
+
* this the gap is the width of one row gap, which reads as the components being
|
|
48
|
+
* crowded against the header while the sides and footer sit `OPEN_SIDE_PAD` away.
|
|
49
|
+
* This is not chrome: nothing is drawn in it.
|
|
50
|
+
*/
|
|
51
|
+
export const OPEN_HEADER_AIR = 16;
|
|
52
|
+
/**
|
|
53
|
+
* Space a *grown* container reserves above its nested components: the card's own
|
|
54
|
+
* padding, its label slot, its technology row, the gaps between them, and a little
|
|
55
|
+
* air. The description is hidden while grown, so it is not part of this.
|
|
56
|
+
*
|
|
57
|
+
* Derived from the same constants the card is built from, rather than written as
|
|
58
|
+
* a literal, so it cannot drift from `descriptionLineBudget` — which subtracts
|
|
59
|
+
* exactly this chrome (and no air) to decide how much description a closed card
|
|
60
|
+
* can show. Those two disagreeing is how a card ends up taller than the box ELK
|
|
61
|
+
* laid out for it.
|
|
62
|
+
*
|
|
63
|
+
* The graph hands this to ELK as the compound parent's top padding rather than
|
|
64
|
+
* nudging the children down itself — so the parent's size and the children's
|
|
65
|
+
* placement are still one ELK fit, not our arithmetic layered on top of it.
|
|
66
|
+
*/
|
|
67
|
+
export const OPEN_HEADER_PAD = CARD_PAD_Y * 2 + LABEL_SLOT_H + CARD_GAP + TECH_SLOT_H + CARD_GAP + OPEN_HEADER_AIR;
|
|
68
|
+
/**
|
|
69
|
+
* The drill-down affordance, in the card's own box. Extracted from the button's
|
|
70
|
+
* style so the reserved footer cannot drift from the thing it is reserving for —
|
|
71
|
+
* the two numbers are the same number.
|
|
72
|
+
*/
|
|
73
|
+
export const TOGGLE_SIZE = 22;
|
|
74
|
+
export const TOGGLE_INSET = 6;
|
|
75
|
+
/**
|
|
76
|
+
* Space a *grown* container reserves below its nested components, so the last row
|
|
77
|
+
* does not sit under the collapse affordance.
|
|
78
|
+
*
|
|
79
|
+
* The toggle is absolutely positioned, so it takes no space in the card's flow and
|
|
80
|
+
* ELK knows nothing about it: without this the parent is fitted to its children
|
|
81
|
+
* alone and the final row is drawn straight through the button. Reserving the
|
|
82
|
+
* toggle's own reach plus a little air keeps that an ELK fit too, rather than
|
|
83
|
+
* something we nudge afterwards.
|
|
84
|
+
*/
|
|
85
|
+
export const OPEN_FOOTER_PAD = TOGGLE_INSET + TOGGLE_SIZE + 8;
|
|
86
|
+
/**
|
|
87
|
+
* Space a *grown* container reserves to the left and right of its nested
|
|
88
|
+
* components.
|
|
89
|
+
*
|
|
90
|
+
* Deliberately the footer's number rather than its own: the nested cards should
|
|
91
|
+
* sit in one uniform inset, not a wider one at the bottom than at the sides. Both
|
|
92
|
+
* are wider than the card's own 12px text inset — the label and technology row are
|
|
93
|
+
* the container's chrome and sit flush with its padding, while the nested cards
|
|
94
|
+
* are separate boxes it contains, and at the same inset they read as part of that
|
|
95
|
+
* chrome rather than held inside it.
|
|
96
|
+
*/
|
|
97
|
+
export const OPEN_SIDE_PAD = OPEN_FOOTER_PAD;
|
|
98
|
+
/**
|
|
99
|
+
* The two rows at the top of every container card: label, then technology.
|
|
100
|
+
*
|
|
101
|
+
* Heights are pinned (`LABEL_SLOT_H`, `TECH_SLOT_H`) so the rows land at the same
|
|
102
|
+
* y on every card and the chrome below them can be reserved exactly — see
|
|
103
|
+
* `OPEN_HEADER_PAD`.
|
|
104
|
+
*/
|
|
105
|
+
export function ContainerCardHeader({ label, Icon, iconLabel, color, topLabel, brand, hasTechRow, count, centered = false, }) {
|
|
106
|
+
const { theme } = useTheme();
|
|
107
|
+
const muted = theme.colors.textMuted ?? theme.colors.textSecondary;
|
|
108
|
+
return (_jsxs(_Fragment, { children: [_jsxs("span", { style: {
|
|
109
|
+
display: 'flex',
|
|
110
|
+
alignItems: 'flex-start',
|
|
111
|
+
justifyContent: centered ? 'center' : 'space-between',
|
|
112
|
+
gap: 6,
|
|
113
|
+
height: LABEL_SLOT_H,
|
|
114
|
+
// Without this the slot shrinks when the content exceeds the card's fixed
|
|
115
|
+
// height, and `descriptionLineBudget`'s chrome stops being the chrome —
|
|
116
|
+
// measured at 39.11px instead of 40 the moment the description ran long.
|
|
117
|
+
flexShrink: 0,
|
|
118
|
+
minWidth: 0,
|
|
119
|
+
}, children: [_jsx("span", { style: {
|
|
120
|
+
fontFamily: theme.fonts.body,
|
|
121
|
+
fontWeight: 600,
|
|
122
|
+
fontSize: theme.fontSizes[2],
|
|
123
|
+
color: theme.colors.text,
|
|
124
|
+
lineHeight: 1.25,
|
|
125
|
+
maxHeight: LABEL_SLOT_H,
|
|
126
|
+
display: '-webkit-box',
|
|
127
|
+
WebkitLineClamp: 2,
|
|
128
|
+
WebkitBoxOrient: 'vertical',
|
|
129
|
+
overflow: 'hidden',
|
|
130
|
+
textAlign: centered ? 'center' : 'left',
|
|
131
|
+
minWidth: 0,
|
|
132
|
+
}, children: label }), Icon && (_jsx("span", { "aria-label": iconLabel, style: {
|
|
133
|
+
display: 'inline-flex',
|
|
134
|
+
flexShrink: 0,
|
|
135
|
+
color,
|
|
136
|
+
// Nudge down so the glyph optically centres on the first text line.
|
|
137
|
+
marginTop: 3,
|
|
138
|
+
}, children: _jsx(Icon, { size: 16, strokeWidth: 2.25 }) }))] }), _jsxs("span", { style: {
|
|
139
|
+
display: 'flex',
|
|
140
|
+
alignItems: 'center',
|
|
141
|
+
justifyContent: centered ? 'center' : 'space-between',
|
|
142
|
+
gap: 6,
|
|
143
|
+
fontFamily: theme.fonts.monospace,
|
|
144
|
+
fontSize: theme.fontSizes[0],
|
|
145
|
+
color: muted,
|
|
146
|
+
letterSpacing: 0.5,
|
|
147
|
+
textTransform: 'uppercase',
|
|
148
|
+
minWidth: 0,
|
|
149
|
+
// Pinned, like the label slot above it: an empty row would otherwise be
|
|
150
|
+
// zero-height and the description budget would have to guess which cards
|
|
151
|
+
// have a technology row. Empty stays zero — a person has no technology.
|
|
152
|
+
...(hasTechRow ? { height: TECH_SLOT_H, flexShrink: 0 } : {}),
|
|
153
|
+
}, children: [topLabel && (_jsxs("span", { style: { display: 'flex', alignItems: 'center', gap: 6, minWidth: 0 }, children: [brand && _jsx(TechMark, { brand: brand }), _jsx("span", { style: {
|
|
154
|
+
fontWeight: 600,
|
|
155
|
+
whiteSpace: 'nowrap',
|
|
156
|
+
overflow: 'hidden',
|
|
157
|
+
textOverflow: 'ellipsis',
|
|
158
|
+
minWidth: 0,
|
|
159
|
+
}, children: topLabel })] })), count && (_jsxs("span", { style: {
|
|
160
|
+
flexShrink: 0,
|
|
161
|
+
letterSpacing: 0,
|
|
162
|
+
display: 'inline-flex',
|
|
163
|
+
alignItems: 'center',
|
|
164
|
+
gap: 4,
|
|
165
|
+
}, children: [count.value, _jsx(count.Icon, { size: 12, strokeWidth: 2.25 })] }))] })] }));
|
|
166
|
+
}
|
|
167
|
+
//# sourceMappingURL=containerCard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"containerCard.js","sourceRoot":"","sources":["../../src/subsystem/containerCard.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAEzD,OAA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edgesReconnectable: false;
|
|
24
24
|
};
|
|
25
25
|
/**
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* `z-index: auto`, and leans on DOM order (edges first, nodes second) to keep
|
|
29
|
-
* nodes on top. Nodes carry an inline `z-index: 0`, which on its own does not
|
|
30
|
-
* reliably beat the edge layer, so an edge routing into a boundary frame's top
|
|
31
|
-
* border paints *over* that frame's label. Lift the whole node layer above the
|
|
32
|
-
* edge layer once for every graph that spreads `GRAPH_NAV_PROPS`.
|
|
26
|
+
* Class on every canvas that spreads `GRAPH_NAV_PROPS`; scopes `GRAPH_LAYER_CSS`
|
|
27
|
+
* so it only touches our canvases.
|
|
33
28
|
*
|
|
34
|
-
*
|
|
29
|
+
* Paint order rides React Flow's own per-element z-indices. The viewport is one
|
|
30
|
+
* stacking context holding the edge layer (one absolutely positioned `<svg>` per
|
|
31
|
+
* edge, `z-index` = the deepest nested endpoint's depth) and the node layer
|
|
32
|
+
* (each node `z-index` = its nesting depth, a child always one above its
|
|
33
|
+
* parent). Neither layer may be lifted as a whole: a boundary frame is a filled
|
|
34
|
+
* container card, so a line between two members has to paint *above* the frame
|
|
35
|
+
* that holds them yet *below* the member cards — and that is exactly the
|
|
36
|
+
* interleave the per-element indices give (edge depth ≥ frame depth, and at
|
|
37
|
+
* equal depth the node layer wins by DOM order).
|
|
35
38
|
*/
|
|
36
39
|
export declare const GRAPH_CANVAS_CLASS = "subsystem-graph-canvas";
|
|
37
40
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graphChrome.d.ts","sourceRoot":"","sources":["../../src/subsystem/graphChrome.tsx"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;;AASH,eAAO,MAAM,eAAe;;;;;;;;;;;;;CAaO,CAAC;AAEpC
|
|
1
|
+
{"version":3,"file":"graphChrome.d.ts","sourceRoot":"","sources":["../../src/subsystem/graphChrome.tsx"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;;AASH,eAAO,MAAM,eAAe;;;;;;;;;;;;;CAaO,CAAC;AAEpC;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,kBAAkB,2BAA2B,CAAC;AAE3D;;;;;;;GAOG;AACH,eAAO,MAAM,iBAAiB,8BAA8B,CAAC;AAE7D,0DAA0D;AAC1D,eAAO,MAAM,mBAAmB,MAAM,CAAC;AAEvC,iDAAiD;AACjD,eAAO,MAAM,mBAAmB,MAAM,CAAC;AAEvC,eAAO,MAAM,eAAe,QAI3B,CAAC;AAEF,gFAAgF;AAChF,wBAAgB,eAAe,gCAE9B;AAED;;;GAGG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;CAQM,CAAC;AAEpC,kFAAkF;AAClF,wBAAgB,WAAW,CAAC,EAC1B,cAAqB,EACrB,YAAmB,GACpB,GAAE;IAAE,cAAc,CAAC,EAAE,OAAO,CAAC;IAAC,YAAY,CAAC,EAAE,OAAO,CAAA;CAAO,+BAO3D"}
|
|
@@ -24,15 +24,18 @@ export const GRAPH_NAV_PROPS = {
|
|
|
24
24
|
edgesReconnectable: false,
|
|
25
25
|
};
|
|
26
26
|
/**
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
* `z-index: auto`, and leans on DOM order (edges first, nodes second) to keep
|
|
30
|
-
* nodes on top. Nodes carry an inline `z-index: 0`, which on its own does not
|
|
31
|
-
* reliably beat the edge layer, so an edge routing into a boundary frame's top
|
|
32
|
-
* border paints *over* that frame's label. Lift the whole node layer above the
|
|
33
|
-
* edge layer once for every graph that spreads `GRAPH_NAV_PROPS`.
|
|
27
|
+
* Class on every canvas that spreads `GRAPH_NAV_PROPS`; scopes `GRAPH_LAYER_CSS`
|
|
28
|
+
* so it only touches our canvases.
|
|
34
29
|
*
|
|
35
|
-
*
|
|
30
|
+
* Paint order rides React Flow's own per-element z-indices. The viewport is one
|
|
31
|
+
* stacking context holding the edge layer (one absolutely positioned `<svg>` per
|
|
32
|
+
* edge, `z-index` = the deepest nested endpoint's depth) and the node layer
|
|
33
|
+
* (each node `z-index` = its nesting depth, a child always one above its
|
|
34
|
+
* parent). Neither layer may be lifted as a whole: a boundary frame is a filled
|
|
35
|
+
* container card, so a line between two members has to paint *above* the frame
|
|
36
|
+
* that holds them yet *below* the member cards — and that is exactly the
|
|
37
|
+
* interleave the per-element indices give (edge depth ≥ frame depth, and at
|
|
38
|
+
* equal depth the node layer wins by DOM order).
|
|
36
39
|
*/
|
|
37
40
|
export const GRAPH_CANVAS_CLASS = 'subsystem-graph-canvas';
|
|
38
41
|
/**
|
|
@@ -49,7 +52,6 @@ export const LAYOUT_FLIP_EDGE_MS = 180;
|
|
|
49
52
|
/** Node slide duration to the new layout, ms. */
|
|
50
53
|
export const LAYOUT_FLIP_NODE_MS = 320;
|
|
51
54
|
export const GRAPH_LAYER_CSS = `
|
|
52
|
-
.${GRAPH_CANVAS_CLASS} .react-flow__nodes { z-index: 1; }
|
|
53
55
|
.${GRAPH_CANVAS_CLASS} .react-flow__edges { transition: opacity ${LAYOUT_FLIP_EDGE_MS}ms ease; }
|
|
54
56
|
.${LAYOUT_FLIP_CLASS} .react-flow__edges { opacity: 0; }
|
|
55
57
|
.${LAYOUT_FLIP_CLASS} .react-flow__node { transition: transform ${LAYOUT_FLIP_NODE_MS}ms cubic-bezier(0.4, 0, 0.2, 1); }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graphChrome.js","sourceRoot":"","sources":["../../src/subsystem/graphChrome.tsx"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;AAEH,OAAO,EACL,UAAU,EACV,iBAAiB,EACjB,QAAQ,GAET,MAAM,eAAe,CAAC;AAEvB,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,OAAO,EAAE,IAAI;IACb,OAAO,EAAE,CAAC;IACV,SAAS,EAAE,IAAI;IACf,WAAW,EAAE,IAAI;IACjB,YAAY,EAAE,KAAK;IACnB,WAAW,EAAE,IAAI;IACjB,iBAAiB,EAAE,KAAK;IACxB,cAAc,EAAE,KAAK;IACr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B,WAAW,EAAE,KAAK;IAClB,YAAY,EAAE,KAAK;IACnB,WAAW,EAAE,KAAK;IAClB,iBAAiB,EAAE,KAAK;IACxB,kBAAkB,EAAE,KAAK;IACzB,gBAAgB,EAAE,KAAK;CACU,CAAC;AAEpC,kFAAkF;AAClF,MAAM,UAAU,WAAW,CAAC,EAC1B,cAAc,GAAG,IAAI,EACrB,YAAY,GAAG,IAAI,MACqC,EAAE;IAC1D,OAAO,CACL,8BACG,cAAc,IAAI,KAAC,UAAU,IAAC,OAAO,EAAE,iBAAiB,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,GAAI,EACnF,YAAY,IAAI,KAAC,QAAQ,IAAC,QAAQ,QAAC,WAAW,QAAC,eAAe,SAAG,IACjE,CACJ,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The drill-down morph — the vocabulary a graph uses to grow, shrink, slide and
|
|
3
|
+
* fade its boxes between two ELK layouts, shared by the C4 canvas and the
|
|
4
|
+
* component graph so a container animates the same way on either.
|
|
5
|
+
*
|
|
6
|
+
* Nothing here knows about a particular node type. A graph diffs two layouts
|
|
7
|
+
* (`diffLayoutRects`), stamps the result on its nodes as `MorphNodeData`, and
|
|
8
|
+
* each node view turns that into a position-only FLIP (`useFlip`) plus a fade
|
|
9
|
+
* (`useFade`) through `useMorphStyle`. Size is never animated here: a box that
|
|
10
|
+
* grows transitions its own `width`/`height`, so a scale on the wrapper would
|
|
11
|
+
* distort its text and fight that transition.
|
|
12
|
+
*/
|
|
13
|
+
import type { CSSProperties } from 'react';
|
|
14
|
+
/** How long a box takes to glide and grow, in ms. */
|
|
15
|
+
export declare const MORPH_MS = 420;
|
|
16
|
+
/**
|
|
17
|
+
* How long boxes arriving or leaving take to fade, in ms. The morph is
|
|
18
|
+
* sequenced: the fade runs first, and the surviving boxes wait it out before
|
|
19
|
+
* they move and grow (`moveDelayMs`). So the reveal clock is
|
|
20
|
+
* `FADE_MS + MORPH_MS`, not just `MORPH_MS`.
|
|
21
|
+
*/
|
|
22
|
+
export declare const FADE_MS = 200;
|
|
23
|
+
/** Flow-space rect of a box node or a frame. */
|
|
24
|
+
export interface FlowRect {
|
|
25
|
+
x: number;
|
|
26
|
+
y: number;
|
|
27
|
+
width: number;
|
|
28
|
+
height: number;
|
|
29
|
+
}
|
|
30
|
+
/** A box's travel for the morph: its flow rect before → after. */
|
|
31
|
+
export interface FrameGrow {
|
|
32
|
+
from: FlowRect;
|
|
33
|
+
to: FlowRect;
|
|
34
|
+
}
|
|
35
|
+
/** What a node carries so its view can take part in the morph. */
|
|
36
|
+
export interface MorphNodeData {
|
|
37
|
+
/** FLIP: absolute flow rects — where this box was, and where it now is. */
|
|
38
|
+
growFrom?: FlowRect;
|
|
39
|
+
frameRect?: FlowRect;
|
|
40
|
+
/** Arriving in this layout — fades in. */
|
|
41
|
+
entering?: boolean;
|
|
42
|
+
/** Gone from this layout — kept for the morph, fades out. */
|
|
43
|
+
leaving?: boolean;
|
|
44
|
+
/** The move/grow waits this long for the fade to finish, in ms. */
|
|
45
|
+
moveDelayMs?: number;
|
|
46
|
+
}
|
|
47
|
+
/** The slice of a laid-out graph the morph reads rects from. */
|
|
48
|
+
export interface MorphLayout {
|
|
49
|
+
nodes: ReadonlyArray<{
|
|
50
|
+
id: string;
|
|
51
|
+
position: {
|
|
52
|
+
x: number;
|
|
53
|
+
y: number;
|
|
54
|
+
};
|
|
55
|
+
parentId?: string;
|
|
56
|
+
width?: number | null;
|
|
57
|
+
height?: number | null;
|
|
58
|
+
}>;
|
|
59
|
+
/** Frame rects, already absolute. */
|
|
60
|
+
groupBounds: ReadonlyMap<string, FlowRect>;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* A node's rect in **absolute** flow space, walking the parent chain.
|
|
64
|
+
*
|
|
65
|
+
* `groupBounds` is already absolute; a leaf's `position` is relative to its
|
|
66
|
+
* parent, so each ancestor's origin is added in turn.
|
|
67
|
+
*
|
|
68
|
+
* The FLIP needs absolute rects, not parent-relative ones. React Flow places a
|
|
69
|
+
* node at its new absolute position (parent origin + relative position) and
|
|
70
|
+
* moves children along with the parent's *wrapper* — while our FLIP transform
|
|
71
|
+
* lives on the node's inner div, which the children do not inherit. So a node's
|
|
72
|
+
* own transform must cover its full absolute delta; rebasing it to the parent
|
|
73
|
+
* would leave it short by exactly the parent's movement (the "subtle drift"
|
|
74
|
+
* before a leaving box disappears).
|
|
75
|
+
*/
|
|
76
|
+
export declare function absoluteRectOf(layout: MorphLayout, id: string): FlowRect | null;
|
|
77
|
+
/**
|
|
78
|
+
* Every box whose rect changes between two layouts, so frames *and* cards grow,
|
|
79
|
+
* shrink and slide together. `null` when nothing moved (e.g. the initial paint),
|
|
80
|
+
* so a caller can tell "no morph" from "a morph of nothing".
|
|
81
|
+
*
|
|
82
|
+
* Covers nested boxes too: rects are absolute (`absoluteRectOf`), so a child's
|
|
83
|
+
* transform covers its full delta rather than fighting its parent's wrapper.
|
|
84
|
+
*/
|
|
85
|
+
export declare function diffLayoutRects(prev: MorphLayout, next: MorphLayout): Map<string, FrameGrow> | null;
|
|
86
|
+
/**
|
|
87
|
+
* Whether committing a layout should also move the camera.
|
|
88
|
+
*
|
|
89
|
+
* A morph — a commit that has rects to FLIP from — must not. Every element
|
|
90
|
+
* already on screen is sliding from the rect the reader last saw it at, and that
|
|
91
|
+
* anchoring *is* the morph; a viewport move on top of it makes each card's
|
|
92
|
+
* on-screen path the sum of two independent animations, so nothing lands where
|
|
93
|
+
* the FLIP said it would.
|
|
94
|
+
*
|
|
95
|
+
* A commit with no `grows` is a genuine change: the first paint, a new system, a
|
|
96
|
+
* different element set, or the grid fallback after an ELK failure. There is no
|
|
97
|
+
* continuity to preserve there and the content may genuinely not be on screen, so
|
|
98
|
+
* fit. An *empty* map fits for the same reason — no element is anchoring, so there
|
|
99
|
+
* is nothing a camera move could contradict.
|
|
100
|
+
*
|
|
101
|
+
* @param grows the rects to animate from, exactly as the nodes received them.
|
|
102
|
+
*/
|
|
103
|
+
export declare function shouldRefitCamera(grows: Map<string, FrameGrow> | null): boolean;
|
|
104
|
+
/**
|
|
105
|
+
* FLIP between two absolute flow rects: render transformed back onto `from`,
|
|
106
|
+
* then release onto `to`.
|
|
107
|
+
*
|
|
108
|
+
* The step back **must** happen while rendering, not in an effect. An effect runs
|
|
109
|
+
* after the browser has already painted, so the element is painted at its new
|
|
110
|
+
* position for one frame and only then jumps back — a visible teleport, which is
|
|
111
|
+
* the exact thing this hook exists to remove. Adjusting state during render lets
|
|
112
|
+
* React apply the transform in the same commit, so the new position is never
|
|
113
|
+
* painted untransformed.
|
|
114
|
+
*
|
|
115
|
+
* The rects are keyed by value: a graph mints fresh rect objects each layout, so
|
|
116
|
+
* comparing identity would re-fire the whole morph on unrelated re-renders.
|
|
117
|
+
*/
|
|
118
|
+
export declare function useFlip(from: FlowRect | undefined, to: FlowRect | undefined): {
|
|
119
|
+
flipping: boolean;
|
|
120
|
+
placed: boolean;
|
|
121
|
+
dx: number;
|
|
122
|
+
dy: number;
|
|
123
|
+
};
|
|
124
|
+
/**
|
|
125
|
+
* Opacity for a box arriving or leaving the layout. An arriving box mounts
|
|
126
|
+
* hidden and fades in; a leaving box is kept (out of the new layout) for the
|
|
127
|
+
* morph, then fades out — a removal reads as a fade, not a pop.
|
|
128
|
+
*/
|
|
129
|
+
export declare function useFade(entering?: boolean, leaving?: boolean): {
|
|
130
|
+
opacity: number;
|
|
131
|
+
transition: string | undefined;
|
|
132
|
+
};
|
|
133
|
+
/**
|
|
134
|
+
* The position-only morph for a node's wrapper: the FLIP slide and the fade, as
|
|
135
|
+
* inline style. Size is left to the node's own transition, so the two compose
|
|
136
|
+
* without either fighting the other.
|
|
137
|
+
*
|
|
138
|
+
* `transform: none` needs no transition, and a box that only changed *size* has
|
|
139
|
+
* nothing to slide — so neither is listed unless it is actually animating.
|
|
140
|
+
*/
|
|
141
|
+
export declare function useMorphStyle(data: MorphNod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IAAI,CAAC;KACxB,CAAC,CAAC;IACH,qCAAqC;IACrC,WAAW,EAAE,WAAW,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;CAC5C;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,WAAW,EAAE,EAAE,EAAE,MAAM,GAAG,QAAQ,GAAG,IAAI,CAY/E;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,WAAW,GAAG,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,IAAI,CAkBnG;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,IAAI,GAAG,OAAO,CAE/E;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,QAAQ,GAAG,SAAS,EAAE,EAAE,EAAE,QAAQ,GAAG,SAAS;;;;;EAmB3E;AAED;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,QAAQ,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,OAAO;;;EAU5D;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,aAAa,GAAG,aAAa,CAehE"}
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The drill-down morph — the vocabulary a graph uses to grow, shrink, slide and
|
|
3
|
+
* fade its boxes between two ELK layouts, shared by the C4 canvas and the
|
|
4
|
+
* component graph so a container animates the same way on either.
|
|
5
|
+
*
|
|
6
|
+
* Nothing here knows about a particular node type. A graph diffs two layouts
|
|
7
|
+
* (`diffLayoutRects`), stamps the result on its nodes as `MorphNodeData`, and
|
|
8
|
+
* each node view turns that into a position-only FLIP (`useFlip`) plus a fade
|
|
9
|
+
* (`useFade`) through `useMorphStyle`. Size is never animated here: a box that
|
|
10
|
+
* grows transitions its own `width`/`height`, so a scale on the wrapper would
|
|
11
|
+
* distort its text and fight that transition.
|
|
12
|
+
*/
|
|
13
|
+
import { useEffect, useState } from 'react';
|
|
14
|
+
/** How long a box takes to glide and grow, in ms. */
|
|
15
|
+
export const MORPH_MS = 420;
|
|
16
|
+
/**
|
|
17
|
+
* How long boxes arriving or leaving take to fade, in ms. The morph is
|
|
18
|
+
* sequenced: the fade runs first, and the surviving boxes wait it out before
|
|
19
|
+
* they move and grow (`moveDelayMs`). So the reveal clock is
|
|
20
|
+
* `FADE_MS + MORPH_MS`, not just `MORPH_MS`.
|
|
21
|
+
*/
|
|
22
|
+
export const FADE_MS = 200;
|
|
23
|
+
/**
|
|
24
|
+
* A node's rect in **absolute** flow space, walking the parent chain.
|
|
25
|
+
*
|
|
26
|
+
* `groupBounds` is already absolute; a leaf's `position` is relative to its
|
|
27
|
+
* parent, so each ancestor's origin is added in turn.
|
|
28
|
+
*
|
|
29
|
+
* The FLIP needs absolute rects, not parent-relative ones. React Flow places a
|
|
30
|
+
* node at its new absolute position (parent origin + relative position) and
|
|
31
|
+
* moves children along with the parent's *wrapper* — while our FLIP transform
|
|
32
|
+
* lives on the node's inner div, which the children do not inherit. So a node's
|
|
33
|
+
* own transform must cover its full absolute delta; rebasing it to the parent
|
|
34
|
+
* would leave it short by exactly the parent's movement (the "subtle drift"
|
|
35
|
+
* before a leaving box disappears).
|
|
36
|
+
*/
|
|
37
|
+
export function absoluteRectOf(layout, id) {
|
|
38
|
+
const frame = layout.groupBounds.get(id);
|
|
39
|
+
if (frame)
|
|
40
|
+
return { x: frame.x, y: frame.y, width: frame.width, height: frame.height };
|
|
41
|
+
const node = layout.nodes.find((n) => n.id === id);
|
|
42
|
+
if (!node)
|
|
43
|
+
return null;
|
|
44
|
+
const origin = node.parentId ? absoluteRectOf(layout, node.parentId) : null;
|
|
45
|
+
return {
|
|
46
|
+
x: (origin?.x ?? 0) + node.position.x,
|
|
47
|
+
y: (origin?.y ?? 0) + node.position.y,
|
|
48
|
+
width: node.width ?? 0,
|
|
49
|
+
height: node.height ?? 0,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Every box whose rect changes between two layouts, so frames *and* cards grow,
|
|
54
|
+
* shrink and slide together. `null` when nothing moved (e.g. the initial paint),
|
|
55
|
+
* so a caller can tell "no morph" from "a morph of nothing".
|
|
56
|
+
*
|
|
57
|
+
* Covers nested boxes too: rects are absolute (`absoluteRectOf`), so a child's
|
|
58
|
+
* transform covers its full delta rather than fighting its parent's wrapper.
|
|
59
|
+
*/
|
|
60
|
+
export function diffLayoutRects(prev, next) {
|
|
61
|
+
const grows = new Map();
|
|
62
|
+
const ids = new Set([
|
|
63
|
+
...prev.groupBounds.keys(),
|
|
64
|
+
...next.groupBounds.keys(),
|
|
65
|
+
...prev.nodes.map((n) => n.id),
|
|
66
|
+
...next.nodes.map((n) => n.id),
|
|
67
|
+
]);
|
|
68
|
+
for (const id of ids) {
|
|
69
|
+
const from = absoluteRectOf(prev, id);
|
|
70
|
+
const to = absoluteRectOf(next, id);
|
|
71
|
+
if (!from || !to)
|
|
72
|
+
continue;
|
|
73
|
+
if (from.x === to.x && from.y === to.y && from.width === to.width && from.height === to.height) {
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
grows.set(id, { from, to });
|
|
77
|
+
}
|
|
78
|
+
return grows.size > 0 ? grows : null;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Whether committing a layout should also move the camera.
|
|
82
|
+
*
|
|
83
|
+
* A morph — a commit that has rects to FLIP from — must not. Every element
|
|
84
|
+
* already on screen is sliding from the rect the reader last saw it at, and that
|
|
85
|
+
* anchoring *is* the morph; a viewport move on top of it makes each card's
|
|
86
|
+
* on-screen path the sum of two independent animations, so nothing lands where
|
|
87
|
+
* the FLIP said it would.
|
|
88
|
+
*
|
|
89
|
+
* A commit with no `grows` is a genuine change: the first paint, a new system, a
|
|
90
|
+
* different element set, or the grid fallback after an ELK failure. There is no
|
|
91
|
+
* continuity to preserve there and the content may genuinely not be on screen, so
|
|
92
|
+
* fit. An *empty* map fits for the same reason — no element is anchoring, so there
|
|
93
|
+
* is nothing a camera move could contradict.
|
|
94
|
+
*
|
|
95
|
+
* @param grows the rects to animate from, exactly as the nodes received them.
|
|
96
|
+
*/
|
|
97
|
+
export function shouldRefitCamera(grows) {
|
|
98
|
+
return !grows || grows.size === 0;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* FLIP between two absolute flow rects: render transformed back onto `from`,
|
|
102
|
+
* then release onto `to`.
|
|
103
|
+
*
|
|
104
|
+
* The step back **must** happen while rendering, not in an effect. An effect runs
|
|
105
|
+
* after the browser has already painted, so the element is painted at its new
|
|
106
|
+
* position for one frame and only then jumps back — a visible teleport, which is
|
|
107
|
+
* the exact thing this hook exists to remove. Adjusting state during render lets
|
|
108
|
+
* React apply the transform in the same commit, so the new position is never
|
|
109
|
+
* painted untransformed.
|
|
110
|
+
*
|
|
111
|
+
* The rects are keyed by value: a graph mints fresh rect objects each layout, so
|
|
112
|
+
* comparing identity would re-fire the whole morph on unrelated re-renders.
|
|
113
|
+
*/
|
|
114
|
+
export function useFlip(from, to) {
|
|
115
|
+
const key = from && to ? `${from.x},${from.y},${to.x},${to.y}` : '';
|
|
116
|
+
const [lastKey, setLastKey] = useState(key);
|
|
117
|
+
const [placed, setPlaced] = useState(!key);
|
|
118
|
+
if (key !== lastKey) {
|
|
119
|
+
setLastKey(key);
|
|
120
|
+
setPlaced(false);
|
|
121
|
+
}
|
|
122
|
+
useEffect(() => {
|
|
123
|
+
if (!key)
|
|
124
|
+
return;
|
|
125
|
+
const raf = requestAnimationFrame(() => setPlaced(true));
|
|
126
|
+
return () => cancelAnimationFrame(raf);
|
|
127
|
+
}, [key]);
|
|
128
|
+
return {
|
|
129
|
+
flipping: key !== '',
|
|
130
|
+
placed,
|
|
131
|
+
dx: from && to ? from.x - to.x : 0,
|
|
132
|
+
dy: from && to ? from.y - to.y : 0,
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Opacity for a box arriving or leaving the layout. An arriving box mounts
|
|
137
|
+
* hidden and fades in; a leaving box is kept (out of the new layout) for the
|
|
138
|
+
* morph, then fades out — a removal reads as a fade, not a pop.
|
|
139
|
+
*/
|
|
140
|
+
export function useFade(entering, leaving) {
|
|
141
|
+
const animate = entering === true || leaving === true;
|
|
142
|
+
const [shown, setShown] = useState(entering !== true);
|
|
143
|
+
useEffect(() => {
|
|
144
|
+
if (!animate)
|
|
145
|
+
return;
|
|
146
|
+
const raf = requestAnimationFrame(() => setShown(leaving !== true));
|
|
147
|
+
return () => cancelAnimationFrame(raf);
|
|
148
|
+
}, [animate, entering, leaving]);
|
|
149
|
+
if (!animate)
|
|
150
|
+
return { opacity: 1, transition: undefined };
|
|
151
|
+
return { opacity: shown ? 1 : 0, transition: `opacity ${FADE_MS}ms ease` };
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* The position-only morph for a node's wrapper: the FLIP slide and the fade, as
|
|
155
|
+
* inline style. Size is left to the node's own transition, so the two compose
|
|
156
|
+
* without either fighting the other.
|
|
157
|
+
*
|
|
158
|
+
* `transform: none` needs no transition, and a box that only changed *size* has
|
|
159
|
+
* nothing to slide — so neither is listed unless it is actually animating.
|
|
160
|
+
*/
|
|
161
|
+
export function useMorphStyle(data) {
|
|
162
|
+
const { growFrom, frameRect, entering, leaving, moveDelayMs = 0 } = data;
|
|
163
|
+
const { flipping, placed, dx, dy } = useFlip(growFrom, frameRect);
|
|
164
|
+
const sliding = flipping && (dx !== 0 || dy !== 0);
|
|
165
|
+
const fade = useFade(entering, leaving);
|
|
166
|
+
const transitions = [
|
|
167
|
+
...(fade.transition ? [fade.transition] : []),
|
|
168
|
+
...(sliding && placed ? [`transform ${MORPH_MS}ms ease-out ${moveDelayMs}ms`] : []),
|
|
169
|
+
];
|
|
170
|
+
return {
|
|
171
|
+
transformOrigin: 'top left',
|
|
172
|
+
transform: sliding && !placed ? `translate(${dx}px, ${dy}px)` : 'none',
|
|
173
|
+
transition: transitions.length > 0 ? transitions.join(', ') : 'none',
|
|
174
|
+
opacity: fade.opacity,
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
//# sourceMappingURL=graphMorph.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graphMorph.js","sourceRoot":"","sources":["../../src/subsystem/graphMorph.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAG5C,qDAAqD;AACrD,MAAM,CAAC,MAAM,QAAQ,GAAG,GAAG,CAAC;AAE5B;;;;;GAKG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,GAAG,CAAC;AAkC3B;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,cAAc,CAAC,MAAmB,EAAE,EAAU;IAC5D,MAAM,KAAK,GAAG,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IACzC,IAAI,KAAK;QAAE,OAAO,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC;IACvF,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;IACnD,IAAI,CAAC,IAAI;QAAE,OAAO,IAAI,CAAC;IACvB,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,cAAc,CAAC,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAC5E,OAAO;QACL,CAAC,EAAE,CAAC,MAAM,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