likec4 1.56.0 → 1.58.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 (207) hide show
  1. package/__app__/codegen/react.mjs +7 -8
  2. package/__app__/codegen/webcomponent.mjs +77 -736
  3. package/__app__/src/aichat/index.mjs +8 -0
  4. package/__app__/src/chunks/AIChat.mjs +959 -0
  5. package/__app__/src/chunks/DiagramActorProvider.mjs +7638 -0
  6. package/__app__/src/chunks/LikeC4Styles.mjs +1866 -0
  7. package/__app__/src/chunks/Markdown.mjs +146 -0
  8. package/__app__/src/chunks/NavigationPanel.mjs +61 -0
  9. package/__app__/src/chunks/ProjectsOverview.mjs +540 -0
  10. package/__app__/src/chunks/adhoc-editor.mjs +3386 -0
  11. package/__app__/src/chunks/es.mjs +439 -0
  12. package/__app__/src/chunks/hooks.mjs +145 -0
  13. package/__app__/src/chunks/libs/@dagrejs/dagre.mjs +1894 -0
  14. package/__app__/src/chunks/libs/@floating-ui.mjs +2218 -0
  15. package/__app__/src/chunks/libs/@mantine.mjs +12070 -0
  16. package/__app__/src/chunks/libs/@tabler/icons-react.mjs +252 -0
  17. package/__app__/src/chunks/libs/@tanstack-ai.mjs +1768 -0
  18. package/__app__/src/chunks/libs/@tanstack.mjs +2718 -0
  19. package/__app__/src/chunks/libs/@xstate/react.mjs +1982 -0
  20. package/__app__/src/chunks/libs/@xyflow/react.mjs +5256 -0
  21. package/__app__/src/chunks/libs/bezier-js.mjs +1003 -0
  22. package/__app__/src/chunks/libs/d3.mjs +2842 -0
  23. package/__app__/src/chunks/libs/fast-equals.mjs +268 -0
  24. package/__app__/src/chunks/libs/framer.mjs +5872 -0
  25. package/__app__/src/chunks/libs/remeda.mjs +642 -0
  26. package/__app__/src/chunks/libs/zod.mjs +3170 -0
  27. package/__app__/src/chunks/rolldown-runtime.mjs +23 -0
  28. package/__app__/src/chunks/styled-system.mjs +1040 -0
  29. package/__app__/src/fonts.css +1 -1
  30. package/__app__/src/main.mjs +14847 -1
  31. package/__app__/src/style.css +1 -1
  32. package/config/schema.json +14 -41
  33. package/dist/chunks/enableServer.mjs +1 -0
  34. package/dist/chunks/filenames.mjs +2 -2
  35. package/dist/chunks/index2.d.mts +2057 -722
  36. package/dist/chunks/libs/@chevrotain/gast.mjs +1 -1
  37. package/dist/chunks/libs/@logtape/logtape.mjs +4 -3
  38. package/dist/chunks/libs/@ts-graphviz/ast.mjs +3 -0
  39. package/dist/chunks/libs/@ts-graphviz/common.d.mts +9 -0
  40. package/dist/chunks/libs/@ts-graphviz/core.mjs +1 -0
  41. package/dist/chunks/libs/chevrotain-allstar.mjs +2 -2
  42. package/dist/chunks/libs/chevrotain.mjs +26 -26
  43. package/dist/chunks/libs/langium.d.mts +5 -5
  44. package/dist/chunks/libs/langium.mjs +10 -10
  45. package/dist/chunks/libs/merge-error-cause.mjs +1 -1
  46. package/dist/chunks/libs/pako.mjs +3 -1
  47. package/dist/chunks/libs/pretty-ms.mjs +1 -1
  48. package/dist/chunks/libs/remeda.mjs +1 -1
  49. package/dist/chunks/libs/ufo.mjs +1 -1
  50. package/dist/chunks/libs/unstorage.mjs +1 -1
  51. package/dist/chunks/libs/which.mjs +1 -1
  52. package/dist/chunks/libs/zod.d.mts +60 -25
  53. package/dist/chunks/libs/zod.mjs +65 -0
  54. package/dist/chunks/node.mjs +84 -56
  55. package/dist/chunks/sequence-view.mjs +1 -1
  56. package/dist/chunks/vite-plugin.mjs +593 -0
  57. package/dist/cli/index.mjs +184 -141
  58. package/dist/index.d.mts +2 -131
  59. package/dist/index.mjs +1 -1
  60. package/dist/model/index.d.mts +2 -2
  61. package/dist/vite-plugin/index.d.mts +53 -2
  62. package/dist/vite-plugin/index.mjs +1 -1
  63. package/dist/vite-plugin/internal/index.d.mts +327 -4
  64. package/dist/vite-plugin/internal/index.mjs +946 -1
  65. package/package.json +85 -72
  66. package/react/index.d.mts +174 -73
  67. package/react/index.mjs +42468 -38926
  68. package/vite-plugin-modules.d.ts +4 -0
  69. package/__app__/chunks/ColorSchemeToggle.mjs +0 -1
  70. package/__app__/chunks/DiagramActorProvider.mjs +0 -10
  71. package/__app__/chunks/Fallback.mjs +0 -1
  72. package/__app__/chunks/Header.mjs +0 -13
  73. package/__app__/chunks/IconRenderer.mjs +0 -1
  74. package/__app__/chunks/LikeC4Diagram.mjs +0 -19
  75. package/__app__/chunks/LikeC4ModelContext.mjs +0 -1
  76. package/__app__/chunks/LikeC4ModelContext2.mjs +0 -1
  77. package/__app__/chunks/LikeC4Styles.mjs +0 -48
  78. package/__app__/chunks/NavigationPanel.mjs +0 -1
  79. package/__app__/chunks/StaticLikeC4Diagram.mjs +0 -1
  80. package/__app__/chunks/ViewReact.mjs +0 -1
  81. package/__app__/chunks/__root.mjs +0 -1
  82. package/__app__/chunks/adhoc-editor.mjs +0 -1
  83. package/__app__/chunks/hooks.mjs +0 -1
  84. package/__app__/chunks/libs/@dagrejs/dagre.mjs +0 -1
  85. package/__app__/chunks/libs/@floating-ui/core.mjs +0 -1
  86. package/__app__/chunks/libs/@floating-ui/dom.mjs +0 -1
  87. package/__app__/chunks/libs/@floating-ui/react.mjs +0 -1
  88. package/__app__/chunks/libs/@mantine/core.mjs +0 -41
  89. package/__app__/chunks/libs/@mantine/hooks.mjs +0 -1
  90. package/__app__/chunks/libs/@nanostores/react.mjs +0 -1
  91. package/__app__/chunks/libs/@react-hookz/web.mjs +0 -1
  92. package/__app__/chunks/libs/@tabler/icons-react.mjs +0 -15
  93. package/__app__/chunks/libs/@tanstack/history.mjs +0 -1
  94. package/__app__/chunks/libs/@tanstack/react-router.mjs +0 -3
  95. package/__app__/chunks/libs/@tanstack/router-core.mjs +0 -1
  96. package/__app__/chunks/libs/@xstate/react.mjs +0 -1
  97. package/__app__/chunks/libs/@xstate/store.mjs +0 -1
  98. package/__app__/chunks/libs/@xyflow/react.mjs +0 -7
  99. package/__app__/chunks/libs/@zag-js/anatomy.mjs +0 -1
  100. package/__app__/chunks/libs/@zag-js/collection.mjs +0 -1
  101. package/__app__/chunks/libs/@zag-js/core.mjs +0 -1
  102. package/__app__/chunks/libs/@zag-js/react.mjs +0 -1
  103. package/__app__/chunks/libs/@zag-js/tree-view.mjs +0 -1
  104. package/__app__/chunks/libs/bezier-js.mjs +0 -1
  105. package/__app__/chunks/libs/d3-path.mjs +0 -1
  106. package/__app__/chunks/libs/d3-shape.mjs +0 -1
  107. package/__app__/chunks/libs/fast-equals.mjs +0 -1
  108. package/__app__/chunks/libs/framer-motion.mjs +0 -9
  109. package/__app__/chunks/libs/html-to-image.mjs +0 -2
  110. package/__app__/chunks/libs/motion-dom.mjs +0 -1
  111. package/__app__/chunks/libs/motion.mjs +0 -1
  112. package/__app__/chunks/libs/nanostores.mjs +0 -1
  113. package/__app__/chunks/libs/react-error-boundary.mjs +0 -1
  114. package/__app__/chunks/libs/react-resizable-panels.mjs +0 -1
  115. package/__app__/chunks/libs/remeda.mjs +0 -1
  116. package/__app__/chunks/libs/xstate.mjs +0 -1
  117. package/__app__/chunks/libs/zod.mjs +0 -39
  118. package/__app__/chunks/rolldown-runtime.mjs +0 -1
  119. package/__app__/chunks/safeCtx.mjs +0 -1
  120. package/__app__/chunks/searchParams.mjs +0 -1
  121. package/__app__/chunks/single-index.mjs +0 -1
  122. package/__app__/chunks/styled-system.mjs +0 -1
  123. package/__app__/chunks/styles.css.mjs +0 -1
  124. package/__app__/chunks/useLikeC4Project.mjs +0 -1
  125. package/__app__/chunks/useUpdateEffect.mjs +0 -1
  126. package/__app__/src/pages/AdHocViewEditor.mjs +0 -1
  127. package/__app__/src/pages/EmbedPage.mjs +0 -1
  128. package/__app__/src/pages/ExportPage.mjs +0 -1
  129. package/__app__/src/pages/ProjectsOverview.mjs +0 -1
  130. package/__app__/src/pages/ViewAsD2.mjs +0 -1
  131. package/__app__/src/pages/ViewAsDot.mjs +0 -1
  132. package/__app__/src/pages/ViewAsMmd.mjs +0 -1
  133. package/__app__/src/pages/ViewAsPuml.mjs +0 -1
  134. package/__app__/src/pages/ViewEditor.mjs +0 -1
  135. package/__app__/src/pages/ViewReact.mjs +0 -1
  136. package/__app__/src/routeTree.gen.mjs +0 -1
  137. package/__app__/src/routes/__root.mjs +0 -1
  138. package/__app__/src/routes/_single/adhoc.mjs +0 -1
  139. package/__app__/src/routes/_single/embed._viewId.mjs +0 -1
  140. package/__app__/src/routes/_single/export._viewId.mjs +0 -1
  141. package/__app__/src/routes/_single/route.mjs +0 -1
  142. package/__app__/src/routes/_single/single-index.mjs +0 -1
  143. package/__app__/src/routes/_single/view._viewId.d2.mjs +0 -1
  144. package/__app__/src/routes/_single/view._viewId.dot.mjs +0 -1
  145. package/__app__/src/routes/_single/view._viewId.index.mjs +0 -1
  146. package/__app__/src/routes/_single/view._viewId.mjs +0 -1
  147. package/__app__/src/routes/_single/view._viewId.mmd.mjs +0 -1
  148. package/__app__/src/routes/_single/view._viewId.puml.mjs +0 -1
  149. package/__app__/src/routes/_single/webcomponent._.mjs +0 -33
  150. package/__app__/src/routes/index.mjs +0 -1
  151. package/__app__/src/routes/project._projectId/-components.mjs +0 -1
  152. package/__app__/src/routes/project._projectId/adhoc.mjs +0 -1
  153. package/__app__/src/routes/project._projectId/embed._viewId.mjs +0 -1
  154. package/__app__/src/routes/project._projectId/export._viewId.mjs +0 -1
  155. package/__app__/src/routes/project._projectId/index.mjs +0 -1
  156. package/__app__/src/routes/project._projectId/route.mjs +0 -1
  157. package/__app__/src/routes/project._projectId/view._viewId.d2.mjs +0 -1
  158. package/__app__/src/routes/project._projectId/view._viewId.dot.mjs +0 -1
  159. package/__app__/src/routes/project._projectId/view._viewId.index.mjs +0 -1
  160. package/__app__/src/routes/project._projectId/view._viewId.mjs +0 -1
  161. package/__app__/src/routes/project._projectId/view._viewId.mmd.mjs +0 -1
  162. package/__app__/src/routes/project._projectId/view._viewId.puml.mjs +0 -1
  163. package/__app__/src/routes/projects.mjs +0 -1
  164. package/dist/chunks/libs/@chevrotain/utils.mjs +0 -1
  165. package/dist/chunks/libs/@hono/mcp.mjs +0 -45
  166. package/dist/chunks/libs/@hono/node-server.mjs +0 -1
  167. package/dist/chunks/libs/@logtape/logtape.d.mts +0 -1023
  168. package/dist/chunks/libs/@modelcontextprotocol/sdk.mjs +0 -12
  169. package/dist/chunks/libs/ajv.mjs +0 -1
  170. package/dist/chunks/libs/ansi-align.mjs +0 -2
  171. package/dist/chunks/libs/ansi-regex.mjs +0 -1
  172. package/dist/chunks/libs/ansi-styles.mjs +0 -1
  173. package/dist/chunks/libs/atomically.mjs +0 -1
  174. package/dist/chunks/libs/boxen.mjs +0 -22
  175. package/dist/chunks/libs/conf.mjs +0 -1
  176. package/dist/chunks/libs/defu.mjs +0 -1
  177. package/dist/chunks/libs/destr.mjs +0 -1
  178. package/dist/chunks/libs/find-up-simple.mjs +0 -1
  179. package/dist/chunks/libs/get-port.mjs +0 -1
  180. package/dist/chunks/libs/hono.mjs +0 -1
  181. package/dist/chunks/libs/is-docker.mjs +0 -1
  182. package/dist/chunks/libs/is-error-instance.mjs +0 -1
  183. package/dist/chunks/libs/is-inside-container.mjs +0 -1
  184. package/dist/chunks/libs/is-plain-obj.mjs +0 -1
  185. package/dist/chunks/libs/isexe.mjs +0 -1
  186. package/dist/chunks/libs/ky.mjs +0 -3
  187. package/dist/chunks/libs/p-debounce.mjs +0 -1
  188. package/dist/chunks/libs/p-limit.mjs +0 -1
  189. package/dist/chunks/libs/p-timeout.mjs +0 -1
  190. package/dist/chunks/libs/package-up.mjs +0 -1
  191. package/dist/chunks/libs/parse-ms.mjs +0 -1
  192. package/dist/chunks/libs/safe-stringify.mjs +0 -1
  193. package/dist/chunks/libs/strip-indent.mjs +0 -1
  194. package/dist/chunks/libs/tinyrainbow.mjs +0 -1
  195. package/dist/chunks/libs/ts-graphviz.d.mts +0 -12
  196. package/dist/chunks/libs/ts-graphviz.mjs +0 -4
  197. package/dist/chunks/libs/vscode-languageserver.mjs +0 -1
  198. package/dist/chunks/libs/word-wrap.mjs +0 -12
  199. package/dist/chunks/plugin.mjs +0 -400
  200. package/dist/vite-plugin/internal/chunks/libs/@nanostores/react.d.mts +0 -269
  201. package/dist/vite-plugin/internal/chunks/libs/@nanostores/react.mjs +0 -1
  202. package/dist/vite-plugin/internal/chunks/libs/birpc.mjs +0 -1
  203. package/dist/vite-plugin/internal/chunks/libs/fast-equals.mjs +0 -1
  204. package/dist/vite-plugin/internal/chunks/libs/nanostores.d.mts +0 -59
  205. package/dist/vite-plugin/internal/chunks/libs/nanostores.mjs +0 -1
  206. package/dist/vite-plugin/internal/chunks/libs/remeda.mjs +0 -1
  207. package/dist/vite-plugin/internal/chunks/rolldown-runtime.mjs +0 -1
@@ -0,0 +1,959 @@
1
+ import { i as e } from "./rolldown-runtime.mjs";
2
+ import { u as t } from "./libs/@tanstack.mjs";
3
+ import { W as n, h as r, z as i } from "./libs/remeda.mjs";
4
+ import { M as a, Tt as o, X as s, Yt as c, _ as l, b as u, h as d, mt as f, pt as p, q as m, r as h, z as g } from "./libs/@mantine.mjs";
5
+ import { C as _, N as v, _ as y, x as b } from "./styled-system.mjs";
6
+ import { o as x, t as ee } from "./libs/@tabler/icons-react.mjs";
7
+ import { i as S, n as C, r as w, t as te } from "./Markdown.mjs";
8
+ import { f as ne, p as re, t as ie, u as T } from "./hooks.mjs";
9
+ import { l as E, m as ae } from "./libs/framer.mjs";
10
+ import { a as D, c as O, i as oe, n as k, o as A, r as j, s as M, t as N } from "./libs/zod.mjs";
11
+ import { a as P, i as se, n as ce, r as le, t as ue } from "./libs/@tanstack-ai.mjs";
12
+ import { createContext as de, use as fe, useEffect as pe, useRef as F, useState as me } from "react";
13
+ import { c as I } from "react/compiler-runtime";
14
+ import { Fragment as L, jsx as R, jsxs as z } from "react/jsx-runtime";
15
+ import { RichText as he, nonNullable as ge, nonexhaustive as _e } from "@likec4/core";
16
+ import { ElementShapes as ve } from "@likec4/core/styles";
17
+ import { AIAdapter as ye } from "likec4:rpc";
18
+ //#region ../../node_modules/.pnpm/nanostores@1.3.0/node_modules/nanostores/computed/index.js
19
+ var computedStore = (e, t, n) => {
20
+ Array.isArray(e) || (e = [e]);
21
+ let r, i, set = () => {
22
+ if (i === S.epoch) return;
23
+ i = S.epoch;
24
+ let n = e.map((e) => e.get());
25
+ if (!r || n.some((e, t) => e !== r[t])) {
26
+ r = n;
27
+ let e = t(...n);
28
+ e && e.then && e.t ? e.then((e) => {
29
+ r === n && a.set(e);
30
+ }) : (a.set(e), i = S.epoch);
31
+ }
32
+ }, a = /* @__PURE__ */ w(void 0), o = a.get;
33
+ a.get = () => (set(), o());
34
+ let s, c = n ? () => {
35
+ clearTimeout(s), s = setTimeout(set);
36
+ } : set;
37
+ return ne(a, () => {
38
+ let t = e.map((e) => e.listen(c));
39
+ return set(), () => {
40
+ for (let e of t) e();
41
+ };
42
+ }), a;
43
+ }, batched = /* @__NO_SIDE_EFFECTS__ */ (e, t) => computedStore(e, t, !0), B = de(null);
44
+ function useChatContext() {
45
+ return ge(fe(B), "useChatContext: ChatProvider is not provided");
46
+ }
47
+ //#endregion
48
+ //#region src/aichat/ChatInput.tsx
49
+ function ChatInput() {
50
+ let e = I(22), { sendMessage: t, isLoading: n, messages: r, clear: i, stop: o } = useChatContext(), [s, c] = me(""), l = F(null), t0;
51
+ e[0] !== n || e[1] !== t || e[2] !== s ? (t0 = () => {
52
+ !s.trim() || n || (t(s), c(""));
53
+ }, e[0] = n, e[1] = t, e[2] = s, e[3] = t0) : t0 = e[3];
54
+ let u = t0, t1;
55
+ e[4] === Symbol.for("react.memo_cache_sentinel") ? (t1 = (e) => c(e.target.value), e[4] = t1) : t1 = e[4];
56
+ let t2;
57
+ e[5] === u ? t2 = e[6] : (t2 = (e) => {
58
+ e.key === "Enter" && !e.shiftKey && !e.ctrlKey && !e.metaKey && (e.preventDefault(), u());
59
+ }, e[5] = u, e[6] = t2);
60
+ let d;
61
+ e[7] !== n || e[8] !== t2 || e[9] !== s ? (d = /* @__PURE__ */ R(a, {
62
+ flex: 1,
63
+ className: "chat-input",
64
+ placeholder: "Your question...",
65
+ value: s,
66
+ onChange: t1,
67
+ onKeyDown: t2,
68
+ disabled: n,
69
+ ref: l,
70
+ loading: n,
71
+ autosize: !0,
72
+ minRows: 1
73
+ }), e[7] = n, e[8] = t2, e[9] = s, e[10] = d) : d = e[10];
74
+ let p;
75
+ e[11] !== i || e[12] !== n || e[13] !== r.length ? (p = r.length > 0 && !n && /* @__PURE__ */ R(m, {
76
+ size: "sm",
77
+ color: "red",
78
+ variant: "light",
79
+ onClick: () => i(),
80
+ children: "Clear"
81
+ }), e[11] = i, e[12] = n, e[13] = r.length, e[14] = p) : p = e[14];
82
+ let h;
83
+ e[15] !== n || e[16] !== o ? (h = n && /* @__PURE__ */ R(f, {
84
+ color: "red",
85
+ variant: "light",
86
+ onClick: () => o(),
87
+ children: /* @__PURE__ */ R(ee, {})
88
+ }), e[15] = n, e[16] = o, e[17] = h) : h = e[17];
89
+ let g;
90
+ return e[18] !== d || e[19] !== p || e[20] !== h ? (g = /* @__PURE__ */ z(b, { children: [
91
+ d,
92
+ p,
93
+ h
94
+ ] }), e[18] = d, e[19] = p, e[20] = h, e[21] = g) : g = e[21], g;
95
+ }
96
+ //#endregion
97
+ //#region src/aichat/ChatMessage.tsx
98
+ function ChatMessages() {
99
+ let e = I(7), { messages: t, error: n } = useChatContext(), r;
100
+ e[0] === t ? r = e[1] : (r = t.map(_temp), e[0] = t, e[1] = r);
101
+ let i;
102
+ e[2] === n ? i = e[3] : (i = n && /* @__PURE__ */ R(l, {
103
+ styles: { icon: { alignSelf: "flex-start" } },
104
+ color: "red",
105
+ title: "Oops, something went wrong",
106
+ withCloseButton: !1,
107
+ children: /* @__PURE__ */ z(y, {
108
+ fontSize: "sm",
109
+ fontFamily: "mono",
110
+ whiteSpace: "pre",
111
+ my: "xs",
112
+ children: [n.message, n.stack && "\n" + n.stack]
113
+ })
114
+ }), e[2] = n, e[3] = i);
115
+ let a;
116
+ return e[4] !== r || e[5] !== i ? (a = /* @__PURE__ */ z(L, { children: [r, i] }), e[4] = r, e[5] = i, e[6] = a) : a = e[6], a;
117
+ }
118
+ function _temp(e) {
119
+ return /* @__PURE__ */ R(ChatMessage, { message: e }, e.id);
120
+ }
121
+ var ChatMessage = (e) => {
122
+ let t = I(4), { message: n } = e, r = n.role, i;
123
+ t[0] === Symbol.for("react.memo_cache_sentinel") ? (i = v({
124
+ color: "text.bright",
125
+ alignSelf: "flex-end",
126
+ paddingInline: "2",
127
+ paddingBlock: "1",
128
+ marginInlineEnd: "2",
129
+ rounded: "sm",
130
+ backgroundColor: "default.hover",
131
+ whiteSpace: "pre-wrap"
132
+ }), t[0] = i) : i = t[0];
133
+ let a = r === "user" ? UserMessageTextPart : MarkdownTextPart, o;
134
+ return t[1] !== n || t[2] !== a ? (o = /* @__PURE__ */ R(ue, {
135
+ message: n,
136
+ userClassName: i,
137
+ textPartRenderer: a
138
+ }), t[1] = n, t[2] = a, t[3] = o) : o = t[3], o;
139
+ }, UserMessageTextPart = (e) => {
140
+ let t = I(2), { content: n } = e, r;
141
+ return t[0] === n ? r = t[1] : (r = /* @__PURE__ */ R(L, { children: n }), t[0] = n, t[1] = r), r;
142
+ }, MarkdownTextPart = (e) => {
143
+ let t = I(4), { content: n } = e, r;
144
+ t[0] === n ? r = t[1] : (r = he.from({ md: n }), t[0] = n, t[1] = r);
145
+ let i;
146
+ return t[2] === r ? i = t[3] : (i = /* @__PURE__ */ R(te, {
147
+ textScale: .95,
148
+ value: r
149
+ }), t[2] = r, t[3] = i), i;
150
+ }, V = /* @__PURE__ */ w(""), H = /* @__PURE__ */ w("closed"), be = /* @__PURE__ */ batched([V, H], (e, t) => ({
151
+ log: e,
152
+ status: t
153
+ }));
154
+ function useSemanticLayoutLog() {
155
+ return C(be);
156
+ }
157
+ function closeSemanticLayoutLog() {
158
+ H.set("closed"), V.set("");
159
+ }
160
+ //#endregion
161
+ //#region src/aichat/SemanticLayoutLog.tsx
162
+ function SemanticLayoutLog() {
163
+ let e = I(6), { log: t, status: n } = useSemanticLayoutLog();
164
+ if (n === "closed") return null;
165
+ let r = n === "completed", i;
166
+ e[0] === Symbol.for("react.memo_cache_sentinel") ? (i = /* @__PURE__ */ R(h, {
167
+ order: 4,
168
+ children: "Semantic Layout"
169
+ }), e[0] = i) : i = e[0];
170
+ let a = t || "Waiting for response...", o;
171
+ e[1] === a ? o = e[2] : (o = /* @__PURE__ */ R(y, {
172
+ whiteSpace: "pre-wrap",
173
+ children: a
174
+ }), e[1] = a, e[2] = o);
175
+ let s;
176
+ return e[3] !== r || e[4] !== o ? (s = /* @__PURE__ */ R(u, {
177
+ size: "xl",
178
+ opened: !0,
179
+ onClose: closeSemanticLayoutLog,
180
+ closeOnEscape: r,
181
+ withCloseButton: r,
182
+ closeOnClickOutside: r,
183
+ title: i,
184
+ children: o
185
+ }), e[3] = r, e[4] = o, e[5] = s) : s = e[5], s;
186
+ }
187
+ //#endregion
188
+ //#region ../vite-plugin/src/ai/tools.ts
189
+ var U = M({
190
+ id: O().meta({ description: "Node ID" }),
191
+ title: O(),
192
+ shape: N(ve),
193
+ color: O().meta({ description: "Node color, from theme or custom" }),
194
+ icon: O().nullish(),
195
+ parentId: O().nullish().meta({ description: "Parent node ID (if node is nested)" }),
196
+ children: k(O()).nullish().meta({ description: "Nested node IDs (if node is compound)" }),
197
+ x: A(),
198
+ y: A(),
199
+ width: A(),
200
+ height: A(),
201
+ modelFqn: O().nullish().meta({ description: "Model element FQN (if node has reference)" })
202
+ }), xe = P({
203
+ name: "read_ui",
204
+ description: "Read current UI state. Use arguments to include additional data.",
205
+ needsApproval: !1,
206
+ inputSchema: M({
207
+ selectedNode: j().default(!1).meta({ description: "Include selected node (if any)" }),
208
+ nodes: j().default(!1).meta({ description: "Include all nodes from the view" })
209
+ }),
210
+ outputSchema: M({
211
+ projectId: O(),
212
+ editMode: j().meta({ description: "Whether the UI is in edit mode" }),
213
+ view: M({
214
+ id: O(),
215
+ title: O(),
216
+ type: N([
217
+ "element",
218
+ "deployment",
219
+ "dynamic"
220
+ ]).meta({ description: "Type of the current view" })
221
+ }).meta({ description: "Current view" }),
222
+ nodes: k(U).nullish(),
223
+ selectedNode: U.nullish()
224
+ })
225
+ }), Se = P({
226
+ name: "update_ui",
227
+ description: "Update UI state by executing a command.",
228
+ needsApproval: !1,
229
+ inputSchema: M({ command: oe("type", [M({
230
+ type: D("focus"),
231
+ elementId: O().meta({ description: "Element ID (FQN)" })
232
+ }).meta({ description: "Focus UI on an element by its FQN" }), M({ type: D("fitview") }).meta({ description: "Zoom out to fit all elements in the viewport, and clear any selection/focus" })]) }),
233
+ outputSchema: M({})
234
+ }), Ce = P({
235
+ name: "navigate_to",
236
+ description: "Navigates UI to another view",
237
+ needsApproval: !1,
238
+ inputSchema: M({ viewId: O().meta({ description: "View ID" }) }),
239
+ outputSchema: M({})
240
+ }), DoubleIndexedKV = class {
241
+ constructor() {
242
+ this.keyToValue = /* @__PURE__ */ new Map(), this.valueToKey = /* @__PURE__ */ new Map();
243
+ }
244
+ set(e, t) {
245
+ this.keyToValue.set(e, t), this.valueToKey.set(t, e);
246
+ }
247
+ getByKey(e) {
248
+ return this.keyToValue.get(e);
249
+ }
250
+ getByValue(e) {
251
+ return this.valueToKey.get(e);
252
+ }
253
+ clear() {
254
+ this.keyToValue.clear(), this.valueToKey.clear();
255
+ }
256
+ }, Registry = class {
257
+ constructor(e) {
258
+ this.generateIdentifier = e, this.kv = new DoubleIndexedKV();
259
+ }
260
+ register(e, t) {
261
+ this.kv.getByValue(e) || (t ||= this.generateIdentifier(e), this.kv.set(t, e));
262
+ }
263
+ clear() {
264
+ this.kv.clear();
265
+ }
266
+ getIdentifier(e) {
267
+ return this.kv.getByValue(e);
268
+ }
269
+ getValue(e) {
270
+ return this.kv.getByKey(e);
271
+ }
272
+ }, ClassRegistry = class extends Registry {
273
+ constructor() {
274
+ super((e) => e.name), this.classToAllowedProps = /* @__PURE__ */ new Map();
275
+ }
276
+ register(e, t) {
277
+ typeof t == "object" ? (t.allowProps && this.classToAllowedProps.set(e, t.allowProps), super.register(e, t.identifier)) : super.register(e, t);
278
+ }
279
+ getAllowedProps(e) {
280
+ return this.classToAllowedProps.get(e);
281
+ }
282
+ };
283
+ //#endregion
284
+ //#region ../../node_modules/.pnpm/superjson@2.2.6/node_modules/superjson/dist/util.js
285
+ function valuesOfObj(e) {
286
+ if ("values" in Object) return Object.values(e);
287
+ let t = [];
288
+ for (let n in e) e.hasOwnProperty(n) && t.push(e[n]);
289
+ return t;
290
+ }
291
+ function find(e, t) {
292
+ let n = valuesOfObj(e);
293
+ if ("find" in n) return n.find(t);
294
+ let r = n;
295
+ for (let e = 0; e < r.length; e++) {
296
+ let n = r[e];
297
+ if (t(n)) return n;
298
+ }
299
+ }
300
+ function forEach(e, t) {
301
+ Object.entries(e).forEach(([e, n]) => t(n, e));
302
+ }
303
+ function includes(e, t) {
304
+ return e.indexOf(t) !== -1;
305
+ }
306
+ function findArr(e, t) {
307
+ for (let n = 0; n < e.length; n++) {
308
+ let r = e[n];
309
+ if (t(r)) return r;
310
+ }
311
+ }
312
+ //#endregion
313
+ //#region ../../node_modules/.pnpm/superjson@2.2.6/node_modules/superjson/dist/custom-transformer-registry.js
314
+ var CustomTransformerRegistry = class {
315
+ constructor() {
316
+ this.transfomers = {};
317
+ }
318
+ register(e) {
319
+ this.transfomers[e.name] = e;
320
+ }
321
+ findApplicable(e) {
322
+ return find(this.transfomers, (t) => t.isApplicable(e));
323
+ }
324
+ findByName(e) {
325
+ return this.transfomers[e];
326
+ }
327
+ }, we = /* @__PURE__ */ e((e) => Object.prototype.toString.call(e).slice(8, -1), "getType"), isUndefined = (e) => e === void 0, isNull = (e) => e === null, W = /* @__PURE__ */ e((e) => typeof e != "object" || !e || e === Object.prototype ? !1 : Object.getPrototypeOf(e) === null ? !0 : Object.getPrototypeOf(e) === Object.prototype, "isPlainObject"), isEmptyObject = (e) => W(e) && Object.keys(e).length === 0, G = /* @__PURE__ */ e((e) => Array.isArray(e), "isArray"), isString = (e) => typeof e == "string", isNumber = (e) => typeof e == "number" && !isNaN(e), isBoolean = (e) => typeof e == "boolean", isRegExp = (e) => e instanceof RegExp, isMap = (e) => e instanceof Map, isSet = (e) => e instanceof Set, isSymbol = (e) => we(e) === "Symbol", isDate = (e) => e instanceof Date && !isNaN(e.valueOf()), isError = (e) => e instanceof Error, isNaNValue = (e) => typeof e == "number" && isNaN(e), isPrimitive = (e) => isBoolean(e) || isNull(e) || isUndefined(e) || isNumber(e) || isString(e) || isSymbol(e), isBigint = (e) => typeof e == "bigint", isInfinite = (e) => e === Infinity || e === -Infinity, isTypedArray = (e) => ArrayBuffer.isView(e) && !(e instanceof DataView), isURL = (e) => e instanceof URL, escapeKey = (e) => e.replace(/\\/g, "\\\\").replace(/\./g, "\\."), stringifyPath = (e) => e.map(String).map(escapeKey).join("."), parsePath = (e, t) => {
328
+ let n = [], r = "";
329
+ for (let i = 0; i < e.length; i++) {
330
+ let a = e.charAt(i);
331
+ if (!t && a === "\\") {
332
+ let t = e.charAt(i + 1);
333
+ if (t === "\\") {
334
+ r += "\\", i++;
335
+ continue;
336
+ } else if (t !== ".") throw Error("invalid path");
337
+ }
338
+ if (a === "\\" && e.charAt(i + 1) === ".") {
339
+ r += ".", i++;
340
+ continue;
341
+ }
342
+ if (a === ".") {
343
+ n.push(r), r = "";
344
+ continue;
345
+ }
346
+ r += a;
347
+ }
348
+ let i = r;
349
+ return n.push(i), n;
350
+ };
351
+ //#endregion
352
+ //#region ../../node_modules/.pnpm/superjson@2.2.6/node_modules/superjson/dist/transformer.js
353
+ function simpleTransformation(e, t, n, r) {
354
+ return {
355
+ isApplicable: e,
356
+ annotation: t,
357
+ transform: n,
358
+ untransform: r
359
+ };
360
+ }
361
+ var K = [
362
+ simpleTransformation(isUndefined, "undefined", () => null, () => void 0),
363
+ simpleTransformation(isBigint, "bigint", (e) => e.toString(), (e) => typeof BigInt < "u" ? BigInt(e) : (console.error("Please add a BigInt polyfill."), e)),
364
+ simpleTransformation(isDate, "Date", (e) => e.toISOString(), (e) => new Date(e)),
365
+ simpleTransformation(isError, "Error", (e, t) => {
366
+ let n = {
367
+ name: e.name,
368
+ message: e.message
369
+ };
370
+ return "cause" in e && (n.cause = e.cause), t.allowedErrorProps.forEach((t) => {
371
+ n[t] = e[t];
372
+ }), n;
373
+ }, (e, t) => {
374
+ let n = Error(e.message, { cause: e.cause });
375
+ return n.name = e.name, n.stack = e.stack, t.allowedErrorProps.forEach((t) => {
376
+ n[t] = e[t];
377
+ }), n;
378
+ }),
379
+ simpleTransformation(isRegExp, "regexp", (e) => "" + e, (e) => {
380
+ let t = e.slice(1, e.lastIndexOf("/")), n = e.slice(e.lastIndexOf("/") + 1);
381
+ return new RegExp(t, n);
382
+ }),
383
+ simpleTransformation(isSet, "set", (e) => [...e.values()], (e) => new Set(e)),
384
+ simpleTransformation(isMap, "map", (e) => [...e.entries()], (e) => new Map(e)),
385
+ simpleTransformation((e) => isNaNValue(e) || isInfinite(e), "number", (e) => isNaNValue(e) ? "NaN" : e > 0 ? "Infinity" : "-Infinity", Number),
386
+ simpleTransformation((e) => e === 0 && 1 / e == -Infinity, "number", () => "-0", Number),
387
+ simpleTransformation(isURL, "URL", (e) => e.toString(), (e) => new URL(e))
388
+ ];
389
+ function compositeTransformation(e, t, n, r) {
390
+ return {
391
+ isApplicable: e,
392
+ annotation: t,
393
+ transform: n,
394
+ untransform: r
395
+ };
396
+ }
397
+ var q = compositeTransformation((e, t) => isSymbol(e) ? !!t.symbolRegistry.getIdentifier(e) : !1, (e, t) => ["symbol", t.symbolRegistry.getIdentifier(e)], (e) => e.description, (e, t, n) => {
398
+ let r = n.symbolRegistry.getValue(t[1]);
399
+ if (!r) throw Error("Trying to deserialize unknown symbol");
400
+ return r;
401
+ }), Te = [
402
+ Int8Array,
403
+ Uint8Array,
404
+ Int16Array,
405
+ Uint16Array,
406
+ Int32Array,
407
+ Uint32Array,
408
+ Float32Array,
409
+ Float64Array,
410
+ Uint8ClampedArray
411
+ ].reduce((e, t) => (e[t.name] = t, e), {}), J = compositeTransformation(isTypedArray, (e) => ["typed-array", e.constructor.name], (e) => [...e], (e, t) => {
412
+ let n = Te[t[1]];
413
+ if (!n) throw Error("Trying to deserialize unknown typed array");
414
+ return new n(e);
415
+ });
416
+ function isInstanceOfRegisteredClass(e, t) {
417
+ return e?.constructor ? !!t.classRegistry.getIdentifier(e.constructor) : !1;
418
+ }
419
+ var Y = compositeTransformation(isInstanceOfRegisteredClass, (e, t) => ["class", t.classRegistry.getIdentifier(e.constructor)], (e, t) => {
420
+ let n = t.classRegistry.getAllowedProps(e.constructor);
421
+ if (!n) return { ...e };
422
+ let r = {};
423
+ return n.forEach((t) => {
424
+ r[t] = e[t];
425
+ }), r;
426
+ }, (e, t, n) => {
427
+ let r = n.classRegistry.getValue(t[1]);
428
+ if (!r) throw Error(`Trying to deserialize unknown class '${t[1]}' - check https://github.com/blitz-js/superjson/issues/116#issuecomment-773996564`);
429
+ return Object.assign(Object.create(r.prototype), e);
430
+ }), X = compositeTransformation((e, t) => !!t.customTransformerRegistry.findApplicable(e), (e, t) => ["custom", t.customTransformerRegistry.findApplicable(e).name], (e, t) => t.customTransformerRegistry.findApplicable(e).serialize(e), (e, t, n) => {
431
+ let r = n.customTransformerRegistry.findByName(t[1]);
432
+ if (!r) throw Error("Trying to deserialize unknown custom value");
433
+ return r.deserialize(e);
434
+ }), Ee = [
435
+ Y,
436
+ q,
437
+ X,
438
+ J
439
+ ], transformValue = (e, t) => {
440
+ let n = findArr(Ee, (n) => n.isApplicable(e, t));
441
+ if (n) return {
442
+ value: n.transform(e, t),
443
+ type: n.annotation(e, t)
444
+ };
445
+ let r = findArr(K, (n) => n.isApplicable(e, t));
446
+ if (r) return {
447
+ value: r.transform(e, t),
448
+ type: r.annotation
449
+ };
450
+ }, Z = {};
451
+ K.forEach((e) => {
452
+ Z[e.annotation] = e;
453
+ });
454
+ var untransformValue = (e, t, n) => {
455
+ if (G(t)) switch (t[0]) {
456
+ case "symbol": return q.untransform(e, t, n);
457
+ case "class": return Y.untransform(e, t, n);
458
+ case "custom": return X.untransform(e, t, n);
459
+ case "typed-array": return J.untransform(e, t, n);
460
+ default: throw Error("Unknown transformation: " + t);
461
+ }
462
+ else {
463
+ let r = Z[t];
464
+ if (!r) throw Error("Unknown transformation: " + t);
465
+ return r.untransform(e, n);
466
+ }
467
+ }, getNthKey = (e, t) => {
468
+ if (t > e.size) throw Error("index out of bounds");
469
+ let n = e.keys();
470
+ for (; t > 0;) n.next(), t--;
471
+ return n.next().value;
472
+ };
473
+ function validatePath(e) {
474
+ if (includes(e, "__proto__")) throw Error("__proto__ is not allowed as a property");
475
+ if (includes(e, "prototype")) throw Error("prototype is not allowed as a property");
476
+ if (includes(e, "constructor")) throw Error("constructor is not allowed as a property");
477
+ }
478
+ var getDeep = (e, t) => {
479
+ validatePath(t);
480
+ for (let n = 0; n < t.length; n++) {
481
+ let r = t[n];
482
+ if (isSet(e)) e = getNthKey(e, +r);
483
+ else if (isMap(e)) {
484
+ let i = +r, a = +t[++n] == 0 ? "key" : "value", o = getNthKey(e, i);
485
+ switch (a) {
486
+ case "key":
487
+ e = o;
488
+ break;
489
+ case "value":
490
+ e = e.get(o);
491
+ break;
492
+ }
493
+ } else e = e[r];
494
+ }
495
+ return e;
496
+ }, setDeep = (e, t, n) => {
497
+ if (validatePath(t), t.length === 0) return n(e);
498
+ let r = e;
499
+ for (let e = 0; e < t.length - 1; e++) {
500
+ let n = t[e];
501
+ if (G(r)) {
502
+ let e = +n;
503
+ r = r[e];
504
+ } else if (W(r)) r = r[n];
505
+ else if (isSet(r)) {
506
+ let e = +n;
507
+ r = getNthKey(r, e);
508
+ } else if (isMap(r)) {
509
+ if (e === t.length - 2) break;
510
+ let i = +n, a = +t[++e] == 0 ? "key" : "value", o = getNthKey(r, i);
511
+ switch (a) {
512
+ case "key":
513
+ r = o;
514
+ break;
515
+ case "value":
516
+ r = r.get(o);
517
+ break;
518
+ }
519
+ }
520
+ }
521
+ let i = t[t.length - 1];
522
+ if (G(r) ? r[+i] = n(r[+i]) : W(r) && (r[i] = n(r[i])), isSet(r)) {
523
+ let e = getNthKey(r, +i), t = n(e);
524
+ e !== t && (r.delete(e), r.add(t));
525
+ }
526
+ if (isMap(r)) {
527
+ let e = +t[t.length - 2], a = getNthKey(r, e);
528
+ switch (+i == 0 ? "key" : "value") {
529
+ case "key": {
530
+ let e = n(a);
531
+ r.set(e, r.get(a)), e !== a && r.delete(a);
532
+ break;
533
+ }
534
+ case "value":
535
+ r.set(a, n(r.get(a)));
536
+ break;
537
+ }
538
+ }
539
+ return e;
540
+ }, enableLegacyPaths = (e) => e < 1;
541
+ function traverse(e, t, n, r = []) {
542
+ if (!e) return;
543
+ let i = enableLegacyPaths(n);
544
+ if (!G(e)) {
545
+ forEach(e, (e, a) => traverse(e, t, n, [...r, ...parsePath(a, i)]));
546
+ return;
547
+ }
548
+ let [a, o] = e;
549
+ o && forEach(o, (e, a) => {
550
+ traverse(e, t, n, [...r, ...parsePath(a, i)]);
551
+ }), t(a, r);
552
+ }
553
+ function applyValueAnnotations(e, t, n, r) {
554
+ return traverse(t, (t, n) => {
555
+ e = setDeep(e, n, (e) => untransformValue(e, t, r));
556
+ }, n), e;
557
+ }
558
+ function applyReferentialEqualityAnnotations(e, t, n) {
559
+ let r = enableLegacyPaths(n);
560
+ function apply(t, n) {
561
+ let i = getDeep(e, parsePath(n, r));
562
+ t.map((e) => parsePath(e, r)).forEach((t) => {
563
+ e = setDeep(e, t, () => i);
564
+ });
565
+ }
566
+ if (G(t)) {
567
+ let [n, i] = t;
568
+ n.forEach((t) => {
569
+ e = setDeep(e, parsePath(t, r), () => e);
570
+ }), i && forEach(i, apply);
571
+ } else forEach(t, apply);
572
+ return e;
573
+ }
574
+ var isDeep = (e, t) => W(e) || G(e) || isMap(e) || isSet(e) || isError(e) || isInstanceOfRegisteredClass(e, t);
575
+ function addIdentity(e, t, n) {
576
+ let r = n.get(e);
577
+ r ? r.push(t) : n.set(e, [t]);
578
+ }
579
+ function generateReferentialEqualityAnnotations(e, t) {
580
+ let n = {}, r;
581
+ return e.forEach((e) => {
582
+ if (e.length <= 1) return;
583
+ t || (e = e.map((e) => e.map(String)).sort((e, t) => e.length - t.length));
584
+ let [i, ...a] = e;
585
+ i.length === 0 ? r = a.map(stringifyPath) : n[stringifyPath(i)] = a.map(stringifyPath);
586
+ }), r ? isEmptyObject(n) ? [r] : [r, n] : isEmptyObject(n) ? void 0 : n;
587
+ }
588
+ var walker = (e, t, n, r, i = [], a = [], o = /* @__PURE__ */ new Map()) => {
589
+ let s = isPrimitive(e);
590
+ if (!s) {
591
+ addIdentity(e, i, t);
592
+ let n = o.get(e);
593
+ if (n) return r ? { transformedValue: null } : n;
594
+ }
595
+ if (!isDeep(e, n)) {
596
+ let t = transformValue(e, n), r = t ? {
597
+ transformedValue: t.value,
598
+ annotations: [t.type]
599
+ } : { transformedValue: e };
600
+ return s || o.set(e, r), r;
601
+ }
602
+ if (includes(a, e)) return { transformedValue: null };
603
+ let c = transformValue(e, n), l = c?.value ?? e, u = G(l) ? [] : {}, d = {};
604
+ forEach(l, (s, c) => {
605
+ if (c === "__proto__" || c === "constructor" || c === "prototype") throw Error(`Detected property ${c}. This is a prototype pollution risk, please remove it from your object.`);
606
+ let l = walker(s, t, n, r, [...i, c], [...a, e], o);
607
+ u[c] = l.transformedValue, G(l.annotations) ? d[escapeKey(c)] = l.annotations : W(l.annotations) && forEach(l.annotations, (e, t) => {
608
+ d[escapeKey(c) + "." + t] = e;
609
+ });
610
+ });
611
+ let f = isEmptyObject(d) ? {
612
+ transformedValue: u,
613
+ annotations: c ? [c.type] : void 0
614
+ } : {
615
+ transformedValue: u,
616
+ annotations: c ? [c.type, d] : d
617
+ };
618
+ return s || o.set(e, f), f;
619
+ };
620
+ //#endregion
621
+ //#region ../../node_modules/.pnpm/is-what@5.5.0/node_modules/is-what/dist/getType.js
622
+ function getType(e) {
623
+ return Object.prototype.toString.call(e).slice(8, -1);
624
+ }
625
+ //#endregion
626
+ //#region ../../node_modules/.pnpm/is-what@5.5.0/node_modules/is-what/dist/isArray.js
627
+ function isArray(e) {
628
+ return getType(e) === "Array";
629
+ }
630
+ //#endregion
631
+ //#region ../../node_modules/.pnpm/is-what@5.5.0/node_modules/is-what/dist/isPlainObject.js
632
+ function isPlainObject(e) {
633
+ if (getType(e) !== "Object") return !1;
634
+ let t = Object.getPrototypeOf(e);
635
+ return !!t && t.constructor === Object && t === Object.prototype;
636
+ }
637
+ //#endregion
638
+ //#region ../../node_modules/.pnpm/copy-anything@4.0.5/node_modules/copy-anything/dist/index.js
639
+ function assignProp(e, t, n, r, i) {
640
+ let a = {}.propertyIsEnumerable.call(r, t) ? "enumerable" : "nonenumerable";
641
+ a === "enumerable" && (e[t] = n), i && a === "nonenumerable" && Object.defineProperty(e, t, {
642
+ value: n,
643
+ enumerable: !1,
644
+ writable: !0,
645
+ configurable: !0
646
+ });
647
+ }
648
+ function copy(e, t = {}) {
649
+ if (isArray(e)) return e.map((e) => copy(e, t));
650
+ if (!isPlainObject(e)) return e;
651
+ let n = Object.getOwnPropertyNames(e), r = Object.getOwnPropertySymbols(e);
652
+ return [...n, ...r].reduce((n, r) => {
653
+ if (r === "__proto__" || isArray(t.props) && !t.props.includes(r)) return n;
654
+ let i = e[r];
655
+ return assignProp(n, r, copy(i, t), e, t.nonenumerable), n;
656
+ }, {});
657
+ }
658
+ //#endregion
659
+ //#region ../../node_modules/.pnpm/superjson@2.2.6/node_modules/superjson/dist/index.js
660
+ var SuperJSON = class {
661
+ constructor({ dedupe: e = !1 } = {}) {
662
+ this.classRegistry = new ClassRegistry(), this.symbolRegistry = new Registry((e) => e.description ?? ""), this.customTransformerRegistry = new CustomTransformerRegistry(), this.allowedErrorProps = [], this.dedupe = e;
663
+ }
664
+ serialize(e) {
665
+ let t = /* @__PURE__ */ new Map(), n = walker(e, t, this, this.dedupe), r = { json: n.transformedValue };
666
+ n.annotations && (r.meta = {
667
+ ...r.meta,
668
+ values: n.annotations
669
+ });
670
+ let i = generateReferentialEqualityAnnotations(t, this.dedupe);
671
+ return i && (r.meta = {
672
+ ...r.meta,
673
+ referentialEqualities: i
674
+ }), r.meta && (r.meta.v = 1), r;
675
+ }
676
+ deserialize(e, t) {
677
+ let { json: n, meta: r } = e, i = t?.inPlace ? n : copy(n);
678
+ return r?.values && (i = applyValueAnnotations(i, r.values, r.v ?? 0, this)), r?.referentialEqualities && (i = applyReferentialEqualityAnnotations(i, r.referentialEqualities, r.v ?? 0)), i;
679
+ }
680
+ stringify(e) {
681
+ return JSON.stringify(this.serialize(e));
682
+ }
683
+ parse(e) {
684
+ return this.deserialize(JSON.parse(e), { inPlace: !0 });
685
+ }
686
+ registerClass(e, t) {
687
+ this.classRegistry.register(e, t);
688
+ }
689
+ registerSymbol(e, t) {
690
+ this.symbolRegistry.register(e, t);
691
+ }
692
+ registerCustom(e, t) {
693
+ this.customTransformerRegistry.register({
694
+ name: t,
695
+ ...e
696
+ });
697
+ }
698
+ allowErrorProps(...e) {
699
+ this.allowedErrorProps.push(...e);
700
+ }
701
+ };
702
+ SuperJSON.defaultInstance = new SuperJSON(), SuperJSON.serialize = SuperJSON.defaultInstance.serialize.bind(SuperJSON.defaultInstance), SuperJSON.deserialize = SuperJSON.defaultInstance.deserialize.bind(SuperJSON.defaultInstance), SuperJSON.stringify = SuperJSON.defaultInstance.stringify.bind(SuperJSON.defaultInstance), SuperJSON.parse = SuperJSON.defaultInstance.parse.bind(SuperJSON.defaultInstance), SuperJSON.registerClass = SuperJSON.defaultInstance.registerClass.bind(SuperJSON.defaultInstance), SuperJSON.registerSymbol = SuperJSON.defaultInstance.registerSymbol.bind(SuperJSON.defaultInstance), SuperJSON.registerCustom = SuperJSON.defaultInstance.registerCustom.bind(SuperJSON.defaultInstance), SuperJSON.allowErrorProps = SuperJSON.defaultInstance.allowErrorProps.bind(SuperJSON.defaultInstance), SuperJSON.serialize, SuperJSON.deserialize;
703
+ var De = SuperJSON.stringify, Oe = SuperJSON.parse;
704
+ SuperJSON.registerClass, SuperJSON.registerCustom, SuperJSON.registerSymbol, SuperJSON.allowErrorProps;
705
+ //#endregion
706
+ //#region src/aichat/useChat.tsx
707
+ function mapToNodeData(e) {
708
+ return ({ id: t, data: n, ...r }) => {
709
+ let i = n.icon ?? void 0;
710
+ i === "none" && (i = void 0);
711
+ let a = e.parentLookup.get(t)?.values().map((e) => e.id).toArray();
712
+ return {
713
+ id: t,
714
+ title: n.title,
715
+ shape: n.shape,
716
+ color: n.color,
717
+ icon: i,
718
+ parentId: r.parentId,
719
+ children: a,
720
+ x: n.x,
721
+ y: n.y,
722
+ width: r.measured?.width ?? r.width ?? r.initialWidth ?? 0,
723
+ height: r.measured?.height ?? r.height ?? r.initialHeight ?? 0,
724
+ ..."modelFqn" in n && n.modelFqn && { modelFqn: n.modelFqn }
725
+ };
726
+ };
727
+ }
728
+ function useChatTools() {
729
+ let e = I(11), { id: a } = ie(), o = t(), s = T(), c;
730
+ if (e[0] !== s || e[1] !== o || e[2] !== a) {
731
+ let t1;
732
+ e[4] === o ? t1 = e[5] : (t1 = (e) => {
733
+ let { viewId: t } = e;
734
+ return o({
735
+ to: "./",
736
+ params: (e) => ({
737
+ ...e,
738
+ viewId: t
739
+ })
740
+ }), {};
741
+ }, e[4] = o, e[5] = t1);
742
+ let t2;
743
+ e[6] !== s || e[7] !== a ? (t2 = (e) => {
744
+ let { view: t, focusedNode: o, xynodes: c, xystore: l, toggledFeatures: u, features: d } = s.getContext(), f = u.enableReadOnly ?? d.enableReadOnly, p = mapToNodeData(l.getState()), m = e.nodes === !0 && r(c, p) || void 0, h = e.selectedNode === !0 && n(c, i((e) => !!e.selected || e.id === o), (e) => e ? p(e) : void 0);
745
+ return {
746
+ projectId: a,
747
+ editMode: !f,
748
+ view: {
749
+ id: t.id,
750
+ title: t.title ?? "",
751
+ type: t._type
752
+ },
753
+ ...m && { nodes: m },
754
+ ...h && { selectedNode: h }
755
+ };
756
+ }, e[6] = s, e[7] = a, e[8] = t2) : t2 = e[8];
757
+ let t3;
758
+ e[9] === s ? t3 = e[10] : (t3 = (e) => {
759
+ let { command: t } = e;
760
+ bb50: switch (t.type) {
761
+ case "focus":
762
+ s.focusOnElement(t.elementId);
763
+ break bb50;
764
+ case "fitview":
765
+ s.fitDiagram();
766
+ break bb50;
767
+ default: _e(t);
768
+ }
769
+ return {};
770
+ }, e[9] = s, e[10] = t3), c = le(Ce.client(t1), xe.client(t2), Se.client(t3)), e[0] = s, e[1] = o, e[2] = a, e[3] = c;
771
+ } else c = e[3];
772
+ return c;
773
+ }
774
+ var Q = {
775
+ key: "likec4.ai.chat.messages",
776
+ read() {
777
+ try {
778
+ let e = sessionStorage.getItem(this.key);
779
+ return e ? Oe(e) : [];
780
+ } catch {
781
+ return [];
782
+ }
783
+ },
784
+ write(e) {
785
+ try {
786
+ if (e.length === 0) {
787
+ sessionStorage.removeItem(this.key);
788
+ return;
789
+ }
790
+ sessionStorage.setItem(this.key, De(e));
791
+ } catch {}
792
+ }
793
+ };
794
+ function useChat(e) {
795
+ let t = I(7), n;
796
+ t[0] === Symbol.for("react.memo_cache_sentinel") ? (n = {
797
+ connection: se("/__likec4_ai"),
798
+ initialMessages: Q.read()
799
+ }, t[0] = n) : n = t[0];
800
+ let r = n, i = useChatTools(), a;
801
+ t[1] !== e || t[2] !== i ? (a = {
802
+ ...r,
803
+ ...e,
804
+ tools: i
805
+ }, t[1] = e, t[2] = i, t[3] = a) : a = t[3];
806
+ let o = ce(a), t3, s;
807
+ return t[4] === o.messages ? (t3 = t[5], s = t[6]) : (t3 = () => {
808
+ Q.write(o.messages);
809
+ }, s = [o.messages], t[4] = o.messages, t[5] = t3, t[6] = s), pe(t3, s), o;
810
+ }
811
+ //#endregion
812
+ //#region src/aichat/AIChat.tsx
813
+ var $ = {
814
+ key: "likec4.ai.chat.position",
815
+ read() {
816
+ try {
817
+ let e = localStorage.getItem(this.key);
818
+ return e ? JSON.parse(e) : null;
819
+ } catch {
820
+ return null;
821
+ }
822
+ },
823
+ write(e) {
824
+ try {
825
+ if (e === null) return localStorage.removeItem(this.key), e;
826
+ localStorage.setItem(this.key, JSON.stringify(e));
827
+ } catch {}
828
+ return e;
829
+ }
830
+ };
831
+ function AIChatComponent() {
832
+ let e = F(null);
833
+ e.current ||= $.read() ?? {
834
+ right: 16,
835
+ bottom: 100
836
+ };
837
+ let onPositionChange = (t) => {
838
+ e.current = $.write({
839
+ left: t.x,
840
+ top: t.y
841
+ });
842
+ }, [t, n] = c({
843
+ key: "likec4.ai.chat.collapsed",
844
+ defaultValue: !0
845
+ });
846
+ return /* @__PURE__ */ z(L, { children: [/* @__PURE__ */ z(ae, { children: [!t && /* @__PURE__ */ R(g, {
847
+ w: 300,
848
+ pos: "fixed",
849
+ className: v({
850
+ rounded: "md",
851
+ padding: "xs",
852
+ shadow: "md",
853
+ layerStyle: "likec4.panel"
854
+ }),
855
+ constrainToViewport: !0,
856
+ constrainOffset: 8,
857
+ excludeDragHandleSelector: ".chat-input",
858
+ initialPosition: e.current,
859
+ onPositionChange,
860
+ children: /* @__PURE__ */ R(AIChatWindowContent, { onClose: () => n(!0) })
861
+ }), t && /* @__PURE__ */ R(E.div, {
862
+ initial: {
863
+ opacity: .1,
864
+ translateX: "10%"
865
+ },
866
+ animate: {
867
+ opacity: 1,
868
+ translateX: 0
869
+ },
870
+ exit: {
871
+ translateX: "50%",
872
+ opacity: .1
873
+ },
874
+ style: {
875
+ position: "fixed",
876
+ right: 8,
877
+ bottom: 60,
878
+ zIndex: 1e3
879
+ },
880
+ children: /* @__PURE__ */ R(d, {
881
+ label: "Show AI Assistant",
882
+ color: "dark",
883
+ fz: "xs",
884
+ children: /* @__PURE__ */ R(f, {
885
+ size: "lg",
886
+ variant: "gradient",
887
+ onClick: () => n(!1),
888
+ children: /* @__PURE__ */ R(x, { stroke: 1.5 })
889
+ })
890
+ })
891
+ }, "collapsed")] }), /* @__PURE__ */ R(SemanticLayoutLog, {})] });
892
+ }
893
+ function AIChatWindowContent(e) {
894
+ let t = I(15), { onClose: n } = e, r = F(null), t1;
895
+ t[0] === Symbol.for("react.memo_cache_sentinel") ? (t1 = () => {
896
+ r.current?.scrollIntoView();
897
+ }, t[0] = t1) : t1 = t[0];
898
+ let i = t1, t2;
899
+ t[1] === Symbol.for("react.memo_cache_sentinel") ? (t2 = () => {
900
+ i();
901
+ }, t[1] = t2) : t2 = t[1], re(t2, 100);
902
+ let a;
903
+ t[2] === Symbol.for("react.memo_cache_sentinel") ? (a = { onChunk: i }, t[2] = a) : a = t[2];
904
+ let c = useChat(a), l;
905
+ t[3] === Symbol.for("react.memo_cache_sentinel") ? (l = /* @__PURE__ */ z(b, { children: [/* @__PURE__ */ R(y, {
906
+ textStyle: "likec4.panel",
907
+ noUserSelect: !0,
908
+ children: "AI Assistant"
909
+ }), /* @__PURE__ */ R(s, {
910
+ size: "xs",
911
+ radius: "sm",
912
+ variant: "light",
913
+ children: ye
914
+ })] }), t[3] = l) : l = t[3];
915
+ let u;
916
+ t[4] === n ? u = t[5] : (u = /* @__PURE__ */ z(b, {
917
+ cursor: "move",
918
+ justify: "space-between",
919
+ children: [l, /* @__PURE__ */ R(p, {
920
+ size: "sm",
921
+ onClick: (e) => {
922
+ e.stopPropagation(), n();
923
+ }
924
+ })]
925
+ }), t[4] = n, t[5] = u);
926
+ let d;
927
+ t[6] === Symbol.for("react.memo_cache_sentinel") ? (d = { content: v({ display: "contents" }) }, t[6] = d) : d = t[6];
928
+ let f;
929
+ t[7] === Symbol.for("react.memo_cache_sentinel") ? (f = /* @__PURE__ */ R(ChatMessages, {}), t[7] = f) : f = t[7];
930
+ let m, h;
931
+ t[8] === Symbol.for("react.memo_cache_sentinel") ? (m = /* @__PURE__ */ R(o, {
932
+ scrollbars: "y",
933
+ w: "100%",
934
+ flex: 1,
935
+ mih: 250,
936
+ mah: 350,
937
+ classNames: d,
938
+ children: /* @__PURE__ */ z(_, { children: [f, /* @__PURE__ */ R("div", {
939
+ ref: r,
940
+ style: { height: 2 }
941
+ })] })
942
+ }), h = /* @__PURE__ */ R(ChatInput, {}), t[8] = m, t[9] = h) : (m = t[8], h = t[9]);
943
+ let g;
944
+ t[10] === u ? g = t[11] : (g = /* @__PURE__ */ z(_, {
945
+ w: "100%",
946
+ children: [
947
+ u,
948
+ m,
949
+ h
950
+ ]
951
+ }), t[10] = u, t[11] = g);
952
+ let x;
953
+ return t[12] !== c || t[13] !== g ? (x = /* @__PURE__ */ R(B, {
954
+ value: c,
955
+ children: g
956
+ }), t[12] = c, t[13] = g, t[14] = x) : x = t[14], x;
957
+ }
958
+ //#endregion
959
+ export { AIChatComponent as default };