@likec4/core 1.46.4 → 1.48.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (181) hide show
  1. package/LICENSE +1 -1
  2. package/dist/_chunks/Builder.view-element.mjs +3284 -0
  3. package/dist/_chunks/LikeC4Model.d.mts +1287 -0
  4. package/dist/_chunks/LikeC4Styles.mjs +691 -0
  5. package/dist/_chunks/RichText.d.mts +84 -0
  6. package/dist/_chunks/RichText.mjs +148 -0
  7. package/dist/_chunks/_aux.d.mts +289 -0
  8. package/dist/_chunks/_aux.mjs +18 -0
  9. package/dist/_chunks/_types.d.mts +781 -0
  10. package/dist/_chunks/_types2.d.mts +38 -0
  11. package/dist/_chunks/assignTagColors.mjs +24 -0
  12. package/dist/_chunks/calcDriftsFromSnapshot.mjs +379 -0
  13. package/dist/_chunks/connection.mjs +0 -0
  14. package/dist/_chunks/const.d.mts +43 -0
  15. package/dist/_chunks/const.mjs +33 -0
  16. package/dist/_chunks/expression-model.d.mts +192 -0
  17. package/dist/_chunks/expression-model.mjs +103 -0
  18. package/dist/_chunks/expression.d.mts +347 -0
  19. package/dist/_chunks/expression.mjs +107 -0
  20. package/dist/_chunks/find.d.mts +82 -0
  21. package/dist/_chunks/find.mjs +646 -0
  22. package/dist/_chunks/find2.d.mts +78 -0
  23. package/dist/_chunks/find2.mjs +287 -0
  24. package/dist/_chunks/fqnRef.d.mts +58 -0
  25. package/dist/_chunks/fqnRef.mjs +41 -0
  26. package/dist/_chunks/geometry.mjs +335 -0
  27. package/dist/_chunks/index.d.mts +169 -0
  28. package/dist/_chunks/index2.d.mts +937 -0
  29. package/dist/_chunks/index3.d.mts +146 -0
  30. package/dist/_chunks/index4.d.mts +62 -0
  31. package/dist/_chunks/index5.d.mts +42 -0
  32. package/dist/_chunks/index6.d.mts +43 -0
  33. package/dist/{shared/core.OtRNdMxy.d.mts → _chunks/index7.d.mts} +113 -197
  34. package/dist/_chunks/index8.d.mts +144 -0
  35. package/dist/_chunks/invariant.mjs +18 -0
  36. package/dist/_chunks/iterable.mjs +146 -0
  37. package/dist/_chunks/libs/@mantine/colors-generator.mjs +3416 -0
  38. package/dist/_chunks/libs/@ungap/structured-clone.mjs +213 -0
  39. package/dist/_chunks/libs/bail.mjs +14 -0
  40. package/dist/_chunks/libs/ccount.mjs +25 -0
  41. package/dist/_chunks/libs/character-entities-html4.mjs +263 -0
  42. package/dist/_chunks/libs/character-entities-legacy.mjs +117 -0
  43. package/dist/_chunks/libs/character-entities.mjs +2136 -0
  44. package/dist/_chunks/libs/comma-separated-tokens.mjs +18 -0
  45. package/dist/_chunks/libs/decode-named-character-reference.mjs +21 -0
  46. package/dist/_chunks/libs/defu.mjs +42 -0
  47. package/dist/_chunks/libs/devlop.mjs +5 -0
  48. package/dist/_chunks/libs/escape-string-regexp.mjs +8 -0
  49. package/dist/_chunks/libs/extend.mjs +77 -0
  50. package/dist/_chunks/libs/graphology-dag.mjs +703 -0
  51. package/dist/_chunks/libs/graphology-types.d.mts +601 -0
  52. package/dist/_chunks/libs/graphology.d.mts +6 -0
  53. package/dist/_chunks/libs/graphology.mjs +4565 -0
  54. package/dist/_chunks/libs/hast-util-sanitize.mjs +863 -0
  55. package/dist/_chunks/libs/hast-util-to-html.mjs +2696 -0
  56. package/dist/_chunks/libs/is-plain-obj.mjs +9 -0
  57. package/dist/_chunks/libs/longest-streak.mjs +30 -0
  58. package/dist/_chunks/libs/markdown-table.mjs +290 -0
  59. package/dist/_chunks/libs/mdast-util-find-and-replace.mjs +653 -0
  60. package/dist/_chunks/libs/mdast-util-from-markdown.mjs +8522 -0
  61. package/dist/_chunks/libs/mdast-util-gfm.mjs +2393 -0
  62. package/dist/_chunks/libs/mdast-util-to-hast.mjs +1803 -0
  63. package/dist/_chunks/libs/micromark-extension-gfm.mjs +2243 -0
  64. package/dist/_chunks/libs/mnemonist.d.mts +254 -0
  65. package/dist/_chunks/libs/mnemonist.mjs +1978 -0
  66. package/dist/_chunks/libs/natural-compare-lite.mjs +42 -0
  67. package/dist/_chunks/libs/rehype-sanitize.mjs +29 -0
  68. package/dist/_chunks/libs/rehype-stringify.mjs +34 -0
  69. package/dist/_chunks/libs/remark-gfm.mjs +36 -0
  70. package/dist/_chunks/libs/remark-github-blockquote-alert.mjs +100 -0
  71. package/dist/_chunks/libs/remark-parse.mjs +39 -0
  72. package/dist/_chunks/libs/remark-rehype.mjs +171 -0
  73. package/dist/_chunks/libs/remeda.mjs +702 -0
  74. package/dist/_chunks/libs/trough.mjs +158 -0
  75. package/dist/_chunks/libs/unified.mjs +2212 -0
  76. package/dist/_chunks/mnemonist.d.mts +1 -0
  77. package/dist/_chunks/mnemonist.mjs +0 -0
  78. package/dist/_chunks/model.mjs +1898 -0
  79. package/dist/_chunks/model2.mjs +0 -0
  80. package/dist/_chunks/relationships-view.mjs +132 -0
  81. package/dist/_chunks/rolldown-runtime.mjs +42 -0
  82. package/dist/{shared/core.C_3y3eqV.d.mts → _chunks/scalar.d.mts} +13 -43
  83. package/dist/_chunks/scalar.mjs +84 -0
  84. package/dist/_chunks/utils.mjs +483 -0
  85. package/dist/builder/index.d.mts +11 -773
  86. package/dist/builder/index.mjs +631 -978
  87. package/dist/compute-view/index.d.mts +90 -27
  88. package/dist/compute-view/index.mjs +253 -83
  89. package/dist/compute-view/relationships-view/index.d.mts +16 -51
  90. package/dist/compute-view/relationships-view/index.mjs +6 -184
  91. package/dist/geometry/index.d.mts +2 -109
  92. package/dist/geometry/index.mjs +2 -327
  93. package/dist/index.d.mts +18 -20
  94. package/dist/index.mjs +27 -18
  95. package/dist/model/connection/deployment/index.d.mts +12 -15
  96. package/dist/model/connection/deployment/index.mjs +9 -2
  97. package/dist/model/connection/index.d.mts +14 -75
  98. package/dist/model/connection/index.mjs +10 -3
  99. package/dist/model/connection/model/index.d.mts +12 -15
  100. package/dist/model/connection/model/index.mjs +8 -2
  101. package/dist/model/index.d.mts +15 -57
  102. package/dist/model/index.mjs +11 -4
  103. package/dist/styles/index.d.mts +9 -117
  104. package/dist/styles/index.mjs +26 -59
  105. package/dist/types/RichText.d.mts +3 -0
  106. package/dist/types/RichText.mjs +7 -0
  107. package/dist/types/_aux.d.mts +3 -4
  108. package/dist/types/_aux.mjs +2 -7
  109. package/dist/types/expression-model.d.mts +6 -190
  110. package/dist/types/expression-model.mjs +6 -108
  111. package/dist/types/expression.d.mts +5 -6
  112. package/dist/types/expression.mjs +6 -112
  113. package/dist/types/fqnRef.d.mts +4 -60
  114. package/dist/types/fqnRef.mjs +6 -44
  115. package/dist/types/index.d.mts +9 -47
  116. package/dist/types/index.mjs +14 -16
  117. package/dist/types/scalar.d.mts +2 -2
  118. package/dist/types/scalar.mjs +7 -4
  119. package/dist/utils/graphology/index.d.mts +2 -1864
  120. package/dist/utils/graphology/index.mjs +3 -1
  121. package/dist/utils/index.d.mts +11 -124
  122. package/dist/utils/index.mjs +16 -43
  123. package/dist/utils/iterable/index.d.mts +9 -132
  124. package/dist/utils/iterable/index.mjs +2 -61
  125. package/dist/utils/mnemonist.d.mts +2 -0
  126. package/dist/utils/mnemonist.mjs +12 -0
  127. package/package.json +18 -22
  128. package/compute-view/relationships/package.json +0 -4
  129. package/dist/shared/core.3ZhnKAlZ.mjs +0 -106
  130. package/dist/shared/core.78IWAHAE.mjs +0 -332
  131. package/dist/shared/core.B85MJLTf.mjs +0 -5
  132. package/dist/shared/core.BFd1lU9R.mjs +0 -29
  133. package/dist/shared/core.BKlholso.mjs +0 -3
  134. package/dist/shared/core.BPGOjone.d.mts +0 -46
  135. package/dist/shared/core.BYdtmqY5.mjs +0 -1255
  136. package/dist/shared/core.BZCgljZd.d.mts +0 -83
  137. package/dist/shared/core.BbE4y-yl.mjs +0 -177
  138. package/dist/shared/core.BhNcrwzK.mjs +0 -7
  139. package/dist/shared/core.BkVA6gjl.mjs +0 -5
  140. package/dist/shared/core.BoYfZOBm.mjs +0 -3
  141. package/dist/shared/core.BsSXS-_R.mjs +0 -7
  142. package/dist/shared/core.BspBF3SJ.mjs +0 -3944
  143. package/dist/shared/core.BvPm_-u3.d.mts +0 -334
  144. package/dist/shared/core.C-Jdx7xo.d.mts +0 -1263
  145. package/dist/shared/core.C3JowhaZ.mjs +0 -32
  146. package/dist/shared/core.C4x8aaWa.mjs +0 -27
  147. package/dist/shared/core.CBLX4mT8.mjs +0 -28411
  148. package/dist/shared/core.CLSZtnFh.mjs +0 -69
  149. package/dist/shared/core.CRhT4Iio.mjs +0 -785
  150. package/dist/shared/core.CbT8JVYL.mjs +0 -5
  151. package/dist/shared/core.CdNCAwq7.mjs +0 -176
  152. package/dist/shared/core.ClTP6-TN.d.mts +0 -87
  153. package/dist/shared/core.CmGY9blO.mjs +0 -6717
  154. package/dist/shared/core.CmPXpJ8l.mjs +0 -21
  155. package/dist/shared/core.Coi_LOUZ.mjs +0 -7
  156. package/dist/shared/core.CqAJJpK_.mjs +0 -3
  157. package/dist/shared/core.Ctj2S3bD.d.mts +0 -466
  158. package/dist/shared/core.CywrQs86.d.mts +0 -31
  159. package/dist/shared/core.D00YbOhQ.d.mts +0 -300
  160. package/dist/shared/core.D0WZutNd.mjs +0 -94
  161. package/dist/shared/core.D4npX2q8.mjs +0 -18
  162. package/dist/shared/core.DB0Ue5Wx.d.mts +0 -70
  163. package/dist/shared/core.DEK-BO3_.mjs +0 -1206
  164. package/dist/shared/core.DH7TXqXf.mjs +0 -136
  165. package/dist/shared/core.DRJma0Ol.mjs +0 -22
  166. package/dist/shared/core.DSalPD6v.mjs +0 -1352
  167. package/dist/shared/core.DVfPJPJj.mjs +0 -2200
  168. package/dist/shared/core.DXhDWKFZ.d.mts +0 -3
  169. package/dist/shared/core.DbfO90vF.mjs +0 -434
  170. package/dist/shared/core.DcS-0zys.mjs +0 -10
  171. package/dist/shared/core.DeDCYTDR.d.mts +0 -98
  172. package/dist/shared/core.DpKY_3NF.d.mts +0 -504
  173. package/dist/shared/core.Dt0v3djy.d.mts +0 -41
  174. package/dist/shared/core.FZ305VYd.mjs +0 -21
  175. package/dist/shared/core.RfnaEmgA.mjs +0 -7
  176. package/dist/shared/core.oSV6SRfk.mjs +0 -13
  177. package/dist/shared/core.om36dXXW.mjs +0 -41
  178. package/dist/shared/core.q10OP9oJ.mjs +0 -5
  179. package/dist/shared/core.uFk_o9X6.mjs +0 -13
  180. package/dist/shared/core.xeuDd__E.mjs +0 -300
  181. package/dist/shared/core.xgoPk2RG.mjs +0 -4989
@@ -0,0 +1,691 @@
1
+ import { B as t, D as e, M as e$3, O as e$1, Q as t$4, Z as t$7, b as t$1, j as e$2, nt as t$2, t as t$5, tt as t$3, w as t$6, z as e$4 } from "./libs/remeda.mjs";
2
+ import { h as memoizeProp } from "./utils.mjs";
3
+ import { r as nonexhaustive, t as invariant } from "./invariant.mjs";
4
+ import { n as chroma_js_default, t as generateColors } from "./libs/@mantine/colors-generator.mjs";
5
+ import { n as import_default_map, r as import_default_weak_map } from "./libs/mnemonist.mjs";
6
+ import { t as defu } from "./libs/defu.mjs";
7
+ import { g as isStepEdgeId } from "./scalar.mjs";
8
+
9
+ //#region ../../styled-system/preset/dist/_chunks/defaults.mjs
10
+ const blue$1 = {
11
+ fill: "#3b82f6",
12
+ stroke: "#2563eb",
13
+ hiContrast: "#eff6ff",
14
+ loContrast: "#bfdbfe"
15
+ };
16
+ const sky$1 = {
17
+ fill: "#0284c7",
18
+ stroke: "#0369a1",
19
+ hiContrast: "#f0f9ff",
20
+ loContrast: "#B6ECF7"
21
+ };
22
+ const slate$1 = {
23
+ fill: "#64748b",
24
+ stroke: "#475569",
25
+ hiContrast: "#f8fafc",
26
+ loContrast: "#cbd5e1"
27
+ };
28
+ const ElementColors = {
29
+ primary: blue$1,
30
+ blue: blue$1,
31
+ secondary: sky$1,
32
+ sky: sky$1,
33
+ muted: slate$1,
34
+ slate: slate$1,
35
+ gray: {
36
+ fill: "#737373",
37
+ stroke: "#525252",
38
+ hiContrast: "#fafafa",
39
+ loContrast: "#d4d4d4"
40
+ },
41
+ red: {
42
+ fill: "#AC4D39",
43
+ stroke: "#853A2D",
44
+ hiContrast: "#FBD3CB",
45
+ loContrast: "#f5b2a3"
46
+ },
47
+ green: {
48
+ fill: "#428a4f",
49
+ stroke: "#2d5d39",
50
+ hiContrast: "#f8fafc",
51
+ loContrast: "#c2f0c2"
52
+ },
53
+ amber: {
54
+ fill: "#A35829",
55
+ stroke: "#7E451D",
56
+ hiContrast: "#FFE0C2",
57
+ loContrast: "#f9b27c"
58
+ },
59
+ indigo: {
60
+ fill: "#6366f1",
61
+ stroke: "#4f46e5",
62
+ hiContrast: "#eef2ff",
63
+ loContrast: "#c7d2fe"
64
+ }
65
+ };
66
+ const gray = {
67
+ line: "#8D8D8D",
68
+ labelBg: "#18191B",
69
+ label: "#C9C9C9"
70
+ };
71
+ const slate = {
72
+ line: "#64748b",
73
+ labelBg: "#0f172a",
74
+ label: "#cbd5e1"
75
+ };
76
+ const blue = {
77
+ line: "#3b82f6",
78
+ labelBg: "#172554",
79
+ label: "#60a5fa"
80
+ };
81
+ const sky = {
82
+ line: "#0ea5e9",
83
+ labelBg: "#082f49",
84
+ label: "#38bdf8"
85
+ };
86
+ const RelationshipColors = {
87
+ amber: {
88
+ line: "#b45309",
89
+ labelBg: "#78350f",
90
+ label: "#FFE0C2"
91
+ },
92
+ blue,
93
+ gray,
94
+ green: {
95
+ line: "#15803d",
96
+ labelBg: "#052e16",
97
+ label: "#22c55e"
98
+ },
99
+ indigo: {
100
+ line: "#6366f1",
101
+ labelBg: "#1e1b4b",
102
+ label: "#818cf8"
103
+ },
104
+ muted: slate,
105
+ primary: blue,
106
+ red: {
107
+ line: "#AC4D39",
108
+ labelBg: "#b91c1c",
109
+ label: "#f5b2a3"
110
+ },
111
+ secondary: sky,
112
+ sky,
113
+ slate
114
+ };
115
+ const defaultSizes = {
116
+ sizes: {
117
+ xs: {
118
+ width: 180,
119
+ height: 100
120
+ },
121
+ sm: {
122
+ width: 240,
123
+ height: 135
124
+ },
125
+ md: {
126
+ width: 320,
127
+ height: 180
128
+ },
129
+ lg: {
130
+ width: 420,
131
+ height: 234
132
+ },
133
+ xl: {
134
+ width: 520,
135
+ height: 290
136
+ }
137
+ },
138
+ spacing: {
139
+ xs: 8,
140
+ sm: 10,
141
+ md: 16,
142
+ lg: 24,
143
+ xl: 32
144
+ },
145
+ textSizes: {
146
+ xs: 13.33,
147
+ sm: 16,
148
+ md: 19.2,
149
+ lg: 23.04,
150
+ xl: 27.65
151
+ },
152
+ iconSizes: {
153
+ xs: 24,
154
+ sm: 36,
155
+ md: 60,
156
+ lg: 82,
157
+ xl: 90
158
+ }
159
+ };
160
+ const Sizes = [
161
+ "xs",
162
+ "sm",
163
+ "md",
164
+ "lg",
165
+ "xl"
166
+ ];
167
+ const IconPositions = [
168
+ "left",
169
+ "right",
170
+ "top",
171
+ "bottom"
172
+ ];
173
+ const BorderStyles = [
174
+ "solid",
175
+ "dashed",
176
+ "dotted",
177
+ "none"
178
+ ];
179
+ const ElementShapes = [
180
+ "rectangle",
181
+ "person",
182
+ "browser",
183
+ "mobile",
184
+ "cylinder",
185
+ "storage",
186
+ "queue",
187
+ "bucket",
188
+ "document"
189
+ ];
190
+ const ThemeColors = [
191
+ "amber",
192
+ "blue",
193
+ "gray",
194
+ "slate",
195
+ "green",
196
+ "indigo",
197
+ "muted",
198
+ "primary",
199
+ "red",
200
+ "secondary",
201
+ "sky"
202
+ ];
203
+ const DefaultTagColors = [
204
+ "tomato",
205
+ "grass",
206
+ "blue",
207
+ "ruby",
208
+ "orange",
209
+ "indigo",
210
+ "pink",
211
+ "teal",
212
+ "purple",
213
+ "amber",
214
+ "crimson",
215
+ "red",
216
+ "lime",
217
+ "yellow",
218
+ "violet"
219
+ ];
220
+ const defaultTheme$1 = {
221
+ colors: ThemeColors.reduce((acc, key) => {
222
+ acc[key] = {
223
+ elements: ElementColors[key],
224
+ relationships: RelationshipColors[key]
225
+ };
226
+ return acc;
227
+ }, {}),
228
+ ...defaultSizes
229
+ };
230
+
231
+ //#endregion
232
+ //#region src/styles/compute-color-values.ts
233
+ const CONTRAST_MIN_WITH_FOREGROUND = 60;
234
+ const CONTRAST_START_TONE_DIFFERENCE = 2;
235
+ const CONTRAST_STEP_TONE_DIFFERENCE = 1;
236
+ function computeColorValues(color) {
237
+ invariant(chroma_js_default.valid(color), `Invalid color: ${color}`);
238
+ const colors = generateColors(color);
239
+ const fillColor = colors[6];
240
+ const contrastedColors = getContrastedColorsAPCA(fillColor);
241
+ return {
242
+ elements: {
243
+ fill: fillColor,
244
+ stroke: colors[7],
245
+ ...contrastedColors
246
+ },
247
+ relationships: {
248
+ line: colors[4],
249
+ label: colors[3],
250
+ labelBg: colors[9]
251
+ }
252
+ };
253
+ }
254
+ function getContrastedColorsAPCA(refColor) {
255
+ const refColorChroma = chroma_js_default(refColor);
256
+ let lightColorRgb = refColorChroma.brighten(CONTRAST_START_TONE_DIFFERENCE);
257
+ let darkColorRgb = refColorChroma.darken(CONTRAST_START_TONE_DIFFERENCE);
258
+ let previousLight;
259
+ let previousDark;
260
+ let contrastWithLight;
261
+ let contrastWithDark;
262
+ do {
263
+ previousLight = lightColorRgb;
264
+ previousDark = darkColorRgb;
265
+ lightColorRgb = lightColorRgb.brighten(CONTRAST_STEP_TONE_DIFFERENCE);
266
+ darkColorRgb = darkColorRgb.darken(CONTRAST_STEP_TONE_DIFFERENCE);
267
+ contrastWithLight = chroma_js_default.contrastAPCA(refColorChroma, lightColorRgb);
268
+ contrastWithDark = chroma_js_default.contrastAPCA(refColorChroma, darkColorRgb);
269
+ } while (Math.abs(contrastWithLight) < CONTRAST_MIN_WITH_FOREGROUND && Math.abs(contrastWithDark) < CONTRAST_MIN_WITH_FOREGROUND && (!t(lightColorRgb, previousLight) || !t(darkColorRgb, previousDark)));
270
+ if (Math.abs(contrastWithLight) > Math.abs(contrastWithDark)) return {
271
+ hiContrast: lightColorRgb.brighten(.4).hex(),
272
+ loContrast: lightColorRgb.hex()
273
+ };
274
+ else return {
275
+ hiContrast: darkColorRgb.darken(.4).hex(),
276
+ loContrast: darkColorRgb.hex()
277
+ };
278
+ }
279
+
280
+ //#endregion
281
+ //#region src/styles/defaults.ts
282
+ const styleDefaults = {
283
+ color: "primary",
284
+ size: "md",
285
+ opacity: 15,
286
+ shape: "rectangle",
287
+ group: {
288
+ opacity: 15,
289
+ border: "dashed"
290
+ },
291
+ relationship: {
292
+ color: "gray",
293
+ line: "dashed",
294
+ arrow: "normal"
295
+ }
296
+ };
297
+
298
+ //#endregion
299
+ //#region src/styles/theme.ts
300
+ const defaultTheme = defaultTheme$1;
301
+
302
+ //#endregion
303
+ //#region src/types/_common.ts
304
+ /**
305
+ * Allows only exact properties of `U` to be present in `T` and omits undefined values
306
+ *
307
+ * See {@link Exact} for more details (this version is non-deep)
308
+ */
309
+ function exact(a) {
310
+ return t$1(a, (v) => v === void 0);
311
+ }
312
+
313
+ //#endregion
314
+ //#region src/types/const.ts
315
+ function isOnStage(value, stage) {
316
+ return value[_stage] === stage;
317
+ }
318
+ /**
319
+ * Property name to store the stage of the model
320
+ *
321
+ * @internal
322
+ */
323
+ const _stage = "_stage";
324
+ /**
325
+ * Property name to store type information, used to identify the type of the view
326
+ *
327
+ * @internal
328
+ */
329
+ const _type = "_type";
330
+ /**
331
+ * Property name to store layout type information, used to identify the type of the layout*
332
+ * @internal
333
+ */
334
+ const _layout = "_layout";
335
+
336
+ //#endregion
337
+ //#region src/types/model-deployment.ts
338
+ function isDeploymentNode(el) {
339
+ return e(el.kind) && !e(el.element);
340
+ }
341
+ function isDeployedInstance(el) {
342
+ return e(el.element) && !e(el.kind);
343
+ }
344
+
345
+ //#endregion
346
+ //#region src/types/model-logical.ts
347
+ /**
348
+ * Ensures that the sizes are set to default values if they are not set
349
+ */
350
+ function ensureSizes({ size, padding, textSize, iconSize, ...rest }, defaultSize = defaultStyle.defaults.size) {
351
+ size ??= defaultSize;
352
+ textSize ??= size;
353
+ padding ??= size;
354
+ iconSize ??= size;
355
+ return {
356
+ ...rest,
357
+ size,
358
+ padding,
359
+ textSize,
360
+ iconSize
361
+ };
362
+ }
363
+
364
+ //#endregion
365
+ //#region src/types/model-spec.ts
366
+ /**
367
+ * Checks if tag color is defined in the specification
368
+ * Expects HEX, `rgb(...)` or `rgba(...)` color
369
+ */
370
+ function isTagColorSpecified(spec) {
371
+ const color = typeof spec === "string" ? spec : spec.color;
372
+ return color.startsWith("#") || color.startsWith("rgb");
373
+ }
374
+
375
+ //#endregion
376
+ //#region src/types/operators.ts
377
+ function isTagEqual(operator) {
378
+ return "tag" in operator;
379
+ }
380
+ function isKindEqual(operator) {
381
+ return "kind" in operator;
382
+ }
383
+ function isParticipantOperator(operator) {
384
+ return "participant" in operator;
385
+ }
386
+ function isNotOperator(operator) {
387
+ return "not" in operator;
388
+ }
389
+ function isAndOperator(operator) {
390
+ return "and" in operator;
391
+ }
392
+ function isOrOperator(operator) {
393
+ return "or" in operator;
394
+ }
395
+ function whereOperatorAsPredicate(operator) {
396
+ switch (true) {
397
+ case isParticipantOperator(operator): {
398
+ const participant = operator.participant;
399
+ return participantIs(participant, whereOperatorAsPredicate(operator.operator));
400
+ }
401
+ case isTagEqual(operator): {
402
+ if (e$1(operator.tag) || "eq" in operator.tag) {
403
+ const tag = e$1(operator.tag) ? operator.tag : operator.tag.eq;
404
+ return (value) => {
405
+ return Array.isArray(value.tags) && value.tags.includes(tag);
406
+ };
407
+ }
408
+ const tag = operator.tag.neq;
409
+ return (value) => {
410
+ return !Array.isArray(value.tags) || !value.tags.includes(tag);
411
+ };
412
+ }
413
+ case isKindEqual(operator): {
414
+ if (e$1(operator.kind) || "eq" in operator.kind) {
415
+ const kind = e$1(operator.kind) ? operator.kind : operator.kind.eq;
416
+ return (value) => {
417
+ return value.kind === kind;
418
+ };
419
+ }
420
+ const kind = operator.kind.neq;
421
+ return (value) => {
422
+ return e$2(value.kind) || value.kind !== kind;
423
+ };
424
+ }
425
+ case isNotOperator(operator): return e$3(whereOperatorAsPredicate(operator.not));
426
+ case isAndOperator(operator): return t$2(operator.and.map(whereOperatorAsPredicate));
427
+ case isOrOperator(operator): return t$3(operator.or.map(whereOperatorAsPredicate));
428
+ default: nonexhaustive(operator);
429
+ }
430
+ }
431
+ function participantIs(participant, predicate) {
432
+ return (value) => {
433
+ if (!value.source || !value.target) return false;
434
+ switch (participant) {
435
+ case "source": return predicate(value.source);
436
+ case "target": return predicate(value.target);
437
+ }
438
+ };
439
+ }
440
+
441
+ //#endregion
442
+ //#region src/types/view.ts
443
+ function isViewRulePredicate(rule) {
444
+ return "include" in rule || "exclude" in rule;
445
+ }
446
+ function isViewRuleStyle(rule) {
447
+ return "targets" in rule && "style" in rule;
448
+ }
449
+ function isComputedView(view) {
450
+ return view._stage === "computed";
451
+ }
452
+ function isDiagramView(view) {
453
+ return view._stage === "layouted";
454
+ }
455
+ function isElementView(view) {
456
+ return view._type === "element";
457
+ }
458
+ function isScopedElementView(view) {
459
+ return isElementView(view) && e(view.viewOf);
460
+ }
461
+ function isExtendsElementView(view) {
462
+ return isElementView(view) && e(view.extends);
463
+ }
464
+ function isDeploymentView(view) {
465
+ return view._type === "deployment";
466
+ }
467
+ function isDynamicView(view) {
468
+ return view._type === "dynamic";
469
+ }
470
+
471
+ //#endregion
472
+ //#region src/types/view-common.ts
473
+ function isViewRuleGlobalStyle(rule) {
474
+ return "styleId" in rule;
475
+ }
476
+ function isViewRuleGlobalPredicateRef(rule) {
477
+ return "predicateId" in rule;
478
+ }
479
+ function isAutoLayoutDirection(autoLayout) {
480
+ return autoLayout === "TB" || autoLayout === "BT" || autoLayout === "LR" || autoLayout === "RL";
481
+ }
482
+ function isViewRuleAutoLayout(rule) {
483
+ return "direction" in rule;
484
+ }
485
+
486
+ //#endregion
487
+ //#region src/types/view-parsed.dynamic.ts
488
+ function getParallelStepsPrefix(id) {
489
+ if (isStepEdgeId(id) && id.includes(".")) return id.slice(0, id.indexOf(".") + 1);
490
+ return null;
491
+ }
492
+ function isDynamicStep(step) {
493
+ return !!step && !("__series" in step || "__parallel" in step);
494
+ }
495
+ function isDynamicStepsParallel(step) {
496
+ return !!step && "__parallel" in step && e$4(step.__parallel);
497
+ }
498
+ function isDynamicStepsSeries(step) {
499
+ return !!step && "__series" in step && e$4(step.__series);
500
+ }
501
+
502
+ //#endregion
503
+ //#region src/types/view-parsed.element.ts
504
+ function isViewRuleGroup(rule) {
505
+ return "title" in rule && "groupRules" in rule && Array.isArray(rule.groupRules);
506
+ }
507
+ function isViewRuleRank(rule) {
508
+ return "rank" in rule && Array.isArray(rule.targets);
509
+ }
510
+
511
+ //#endregion
512
+ //#region src/styles/compute-compound-colors.ts
513
+ /**
514
+ * Compute color values for compound nodes (for six depth levels)
515
+ *
516
+ * @param base The base element colors
517
+ */
518
+ function computeCompoundColorValues(base, depth) {
519
+ const d = depth ?? 6;
520
+ let fill = chroma_js_default(base.fill);
521
+ let stroke = chroma_js_default(base.stroke);
522
+ const isFillTooLight = fill.luminance() > .8;
523
+ const colors = t$4(t$5(chroma_js_default.scale(isFillTooLight ? [fill.darken(.02).desaturate(.05), fill.darken(.1).desaturate(.1)] : [fill.shade(.12, "lch").desaturate(.05), fill.shade(.35, "lch").desaturate(.4)]).mode("oklch").correctLightness().colors(d, null), chroma_js_default.scale(isFillTooLight ? [stroke.darken(.04).desaturate(.05), stroke.darken(.12).desaturate(.1)] : [stroke.shade(.15, "lch").desaturate(.08), stroke.shade(.4, "lch").desaturate(.4)]).mode("oklch").correctLightness().colors(d, null)), t$6(([fill, stroke]) => ({
524
+ ...base,
525
+ fill: fill.hex(),
526
+ stroke: stroke.hex()
527
+ })));
528
+ invariant(colors.length === d, `Expected ${d} colors, got ${colors.length}`);
529
+ return colors;
530
+ }
531
+
532
+ //#endregion
533
+ //#region src/styles/LikeC4Styles.ts
534
+ const defaultStyle = {
535
+ theme: defaultTheme,
536
+ defaults: styleDefaults
537
+ };
538
+ /**
539
+ * Styles of a LikeC4 project
540
+ *
541
+ * Accepts an array of LikeC4ProjectStylesConfig objects as a parameter
542
+ * and constructs a LikeC4Styles merged with the default styles.
543
+ *
544
+ * The class provides methods to get the default element colors, relationship
545
+ * colors, group colors, font size in pixels, padding in pixels, and to compute
546
+ * the ThemeColorValues from a given color.
547
+ */
548
+ var LikeC4Styles = class LikeC4Styles {
549
+ theme;
550
+ defaults;
551
+ static DEFAULT = new LikeC4Styles(defaultStyle);
552
+ static from(...configs) {
553
+ if (t$7(configs, 1)) return new LikeC4Styles(defu(...configs, defaultStyle));
554
+ return this.DEFAULT;
555
+ }
556
+ constructor(config) {
557
+ this.config = config;
558
+ this.theme = config.theme;
559
+ this.defaults = config.defaults;
560
+ }
561
+ /**
562
+ * Default element colors
563
+ */
564
+ get elementColors() {
565
+ return this.theme.colors[this.defaults.color].elements;
566
+ }
567
+ /**
568
+ * Default relationship colors
569
+ */
570
+ get relationshipColors() {
571
+ return this.theme.colors[this.defaults.relationship.color].relationships;
572
+ }
573
+ /**
574
+ * Default group colors
575
+ */
576
+ get groupColors() {
577
+ const color = this.defaults.group?.color;
578
+ if (!color) return this.elementColors;
579
+ return memoizeProp(this, "defaultGroup", () => ({
580
+ ...this.elementColors,
581
+ ...this.theme.colors[color].elements
582
+ }));
583
+ }
584
+ isDefaultColor(color) {
585
+ return color === this.defaults.color;
586
+ }
587
+ /**
588
+ * Get color values
589
+ *
590
+ * @param color - The color to use
591
+ * @default color From the defaults
592
+ */
593
+ colors(color) {
594
+ color ??= this.defaults.color;
595
+ if (this.isThemeColor(color)) return this.theme.colors[color];
596
+ throw new Error(`Unknown color: ${color}`);
597
+ }
598
+ compoundColorsCache = new import_default_weak_map.default((baseElementColors) => new import_default_map.default((depth) => computeCompoundColorValues(baseElementColors, depth)));
599
+ /**
600
+ * Get colors for compound nodes
601
+ *
602
+ * @param baseElementColors - The base element colors to compute from
603
+ */
604
+ colorsForCompounds(baseElementColors, depth) {
605
+ return this.compoundColorsCache.get(baseElementColors).get(depth ?? 6);
606
+ }
607
+ /**
608
+ * Get font size in pixels
609
+ *
610
+ * @param textSize - The text size to use
611
+ * @default textSize From the defaults
612
+ */
613
+ fontSize(textSize) {
614
+ textSize ??= this.defaults.text ?? this.defaults.size;
615
+ return this.theme.textSizes[textSize];
616
+ }
617
+ /**
618
+ * Get padding in pixels
619
+ *
620
+ * @param paddingSize - The padding size to use
621
+ * @default paddingSize From the defaults
622
+ */
623
+ padding(paddingSize) {
624
+ paddingSize ??= this.defaults.padding ?? this.defaults.size;
625
+ return this.theme.spacing[paddingSize];
626
+ }
627
+ /**
628
+ * Get icon size in pixels
629
+ *
630
+ * @param iconSize - The icon size to use
631
+ * @default iconSize From the defaults
632
+ */
633
+ iconSize(iconSize) {
634
+ iconSize ??= this.defaults.size;
635
+ return this.theme.iconSizes[iconSize];
636
+ }
637
+ isThemeColor(color) {
638
+ return color in this.theme.colors;
639
+ }
640
+ /**
641
+ * Calculate sizes and values based on the node styles
642
+ *
643
+ * @example
644
+ * ```typescript
645
+ * const { sizes, values } = styles.nodeSizes(node.style)
646
+ *
647
+ * // sizes
648
+ * sizes.size // enum Size
649
+ * sizes.padding // enum SpacingSize
650
+ * sizes.textSize // enum TextSize
651
+ * sizes.iconSize // enum ShapeSize
652
+ *
653
+ * // values
654
+ * values.sizes // { width: number, height: number }
655
+ * values.padding // number
656
+ * values.textSize // number
657
+ * values.iconSize // number
658
+ * ```
659
+ */
660
+ nodeSizes(nodestyles) {
661
+ const sizes = ensureSizes(nodestyles, this.defaults.size);
662
+ return {
663
+ sizes,
664
+ values: {
665
+ sizes: this.theme.sizes[sizes.size],
666
+ padding: this.padding(sizes.padding),
667
+ textSize: this.fontSize(sizes.textSize),
668
+ iconSize: this.iconSize(sizes.iconSize)
669
+ }
670
+ };
671
+ }
672
+ /**
673
+ * Compute ThemeColorValues from a given color
674
+ * @param color - HEX, RGB, RGBA, etc.
675
+ */
676
+ computeFrom(color) {
677
+ if (this.isThemeColor(color)) return this.theme.colors[color];
678
+ return memoizeProp(this, `compute-${color}`, () => {
679
+ if (!chroma_js_default.valid(color)) throw new Error(`Invalid color value: "${color}"`);
680
+ return computeColorValues(color);
681
+ });
682
+ }
683
+ equals(other) {
684
+ if (other === this) return true;
685
+ if (this.constructor !== other.constructor) return false;
686
+ return t(this.config, other.config);
687
+ }
688
+ };
689
+
690
+ //#endregion
691
+ export { isDeployedInstance as A, BorderStyles as B, isNotOperator as C, whereOperatorAsPredicate as D, isTagEqual as E, isOnStage as F, ThemeColors as G, ElementShapes as H, exact as I, defaultTheme as L, _layout as M, _stage as N, isTagColorSpecified as O, _type as P, styleDefaults as R, isKindEqual as S, isParticipantOperator as T, IconPositions as U, DefaultTagColors as V, Sizes as W, isExtendsElementView as _, isDynamicStep as a, isViewRuleStyle as b, isAutoLayoutDirection as c, isViewRuleGlobalStyle as d, isComputedView as f, isElementView as g, isDynamicView as h, getParallelStepsPrefix as i, isDeploymentNode as j, ensureSizes as k, isViewRuleAutoLayout as l, isDiagramView as m, isViewRuleGroup as n, isDynamicStepsParallel as o, isDeploymentView as p, isViewRuleRank as r, isDynamicStepsSeries as s, LikeC4Styles as t, isViewRuleGlobalPredicateRef as u, isScopedElementView as v, isOrOperator as w, isAndOperator as x, isViewRulePredicate as y, computeColorValues as z };