likec4 1.59.4 → 1.60.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 (96) hide show
  1. package/__app__/codegen/react.mjs +6 -6
  2. package/__app__/codegen/webcomponent.mjs +147 -69
  3. package/__app__/src/aichat/index.mjs +10 -5
  4. package/__app__/src/chunks/AIChat.mjs +1134 -693
  5. package/__app__/src/chunks/LikeC4Styles.mjs +3995 -1779
  6. package/__app__/src/chunks/ProjectsOverview.mjs +624 -334
  7. package/__app__/src/chunks/es.mjs +515 -335
  8. package/__app__/src/chunks/hooks.mjs +578 -369
  9. package/__app__/src/chunks/libs/@floating-ui.mjs +2720 -1966
  10. package/__app__/src/chunks/libs/@mantine.mjs +13920 -10057
  11. package/__app__/src/chunks/libs/@tanstack-ai.mjs +2266 -1146
  12. package/__app__/src/chunks/libs/@tanstack.mjs +3152 -1926
  13. package/__app__/src/chunks/libs/@xstate/react.mjs +2924 -1468
  14. package/__app__/src/chunks/libs/@xyflow/react.mjs +6627 -4067
  15. package/__app__/src/chunks/libs/bezier-js.mjs +1312 -726
  16. package/__app__/src/chunks/libs/d3.mjs +3219 -1505
  17. package/__app__/src/chunks/libs/fast-equals.mjs +434 -210
  18. package/__app__/src/chunks/libs/framer.mjs +9251 -3846
  19. package/__app__/src/chunks/libs/nanostores.mjs +174 -0
  20. package/__app__/src/chunks/libs/zod.mjs +4591 -2363
  21. package/__app__/src/chunks/rolldown-runtime.mjs +39 -23
  22. package/__app__/src/chunks/styled-system.mjs +2279 -1951
  23. package/__app__/src/fonts.css +112 -1
  24. package/__app__/src/main.mjs +40817 -21840
  25. package/__app__/src/style.css +18488 -1
  26. package/config/schema.json +122 -97
  27. package/dist/app/render-view-client.css +1 -1
  28. package/dist/app/render-view-client.js +508 -334
  29. package/dist/chunks/enableServer.mjs +1 -1
  30. package/dist/chunks/filenames.mjs +11 -9
  31. package/dist/chunks/generate-likec4.mjs +5 -0
  32. package/dist/chunks/index.d.mts +243 -183
  33. package/dist/chunks/index2.d.mts +2865 -1977
  34. package/dist/chunks/libs/@chevrotain/gast.mjs +27 -1
  35. package/dist/chunks/libs/@chevrotain/regexp-to-ast.mjs +81 -9
  36. package/dist/chunks/libs/@chevrotain/types.d.mts +4 -1
  37. package/dist/chunks/libs/@logtape/logtape.mjs +5 -4
  38. package/dist/chunks/libs/@lume/kiwi.mjs +1 -1
  39. package/dist/chunks/libs/@ts-graphviz/core.mjs +1 -1
  40. package/dist/chunks/libs/birpc.mjs +1 -1
  41. package/dist/chunks/libs/chevrotain-allstar.mjs +2 -2
  42. package/dist/chunks/libs/chevrotain.mjs +87 -35
  43. package/dist/chunks/libs/eventemitter3.mjs +1 -1
  44. package/dist/chunks/libs/json5.mjs +4 -4
  45. package/dist/chunks/libs/langium.d.mts +9038 -6193
  46. package/dist/chunks/libs/langium.mjs +16 -24
  47. package/dist/chunks/libs/merge-error-cause.mjs +1 -1
  48. package/dist/chunks/libs/p-limit.mjs +1 -0
  49. package/dist/chunks/libs/p-queue.mjs +1 -1
  50. package/dist/chunks/libs/package-manager-detector.mjs +1 -1
  51. package/dist/chunks/libs/pako.mjs +1 -1
  52. package/dist/chunks/libs/pretty-ms.mjs +1 -1
  53. package/dist/chunks/libs/remeda.mjs +1 -1
  54. package/dist/chunks/libs/ufo.mjs +1 -1
  55. package/dist/chunks/libs/unstorage.mjs +1 -1
  56. package/dist/chunks/libs/which.mjs +1 -1
  57. package/dist/chunks/node.mjs +59 -58
  58. package/dist/chunks/rolldown-runtime.mjs +1 -1
  59. package/dist/chunks/sequence-view.mjs +1 -1
  60. package/dist/chunks/vite-plugin.mjs +45 -45
  61. package/dist/cli/index.mjs +207 -1315
  62. package/dist/config/index.d.mts +2 -2
  63. package/dist/generators/likec4.d.mts +6578 -0
  64. package/dist/generators/likec4.mjs +1 -0
  65. package/dist/model/index.d.mts +4 -1
  66. package/dist/vite-plugin/index.d.mts +4 -1
  67. package/dist/vite-plugin/index.mjs +1 -1
  68. package/dist/vite-plugin/internal/chunks/rolldown-runtime.mjs +9 -0
  69. package/dist/vite-plugin/internal/index.d.mts +6 -5
  70. package/dist/vite-plugin/internal/index.mjs +83 -30
  71. package/generators/likec4/package.json +4 -0
  72. package/package.json +113 -106
  73. package/react/index.d.mts +8500 -26659
  74. package/react/index.mjs +534 -63936
  75. package/react/rolldown-runtime-DnkiqaRY.js +1 -0
  76. package/skills/likec4-dsl/SKILL.md +428 -0
  77. package/skills/likec4-dsl/evals/evals-public.json +202 -0
  78. package/skills/likec4-dsl/evals/grading-spec.json +589 -0
  79. package/skills/likec4-dsl/references/bridge-leanix-drawio.md +42 -0
  80. package/skills/likec4-dsl/references/cli.md +139 -0
  81. package/skills/likec4-dsl/references/configuration.md +266 -0
  82. package/skills/likec4-dsl/references/deployment.md +160 -0
  83. package/skills/likec4-dsl/references/dynamic-views.md +455 -0
  84. package/skills/likec4-dsl/references/examples.md +370 -0
  85. package/skills/likec4-dsl/references/identifier-validity.md +90 -0
  86. package/skills/likec4-dsl/references/include-predicates-wildcards.md +179 -0
  87. package/skills/likec4-dsl/references/model.md +151 -0
  88. package/skills/likec4-dsl/references/predicates.md +123 -0
  89. package/skills/likec4-dsl/references/relationships-bidirectional.md +176 -0
  90. package/skills/likec4-dsl/references/specification.md +75 -0
  91. package/skills/likec4-dsl/references/style-tokens-colors.md +150 -0
  92. package/skills/likec4-dsl/references/troubleshooting.md +96 -0
  93. package/skills/likec4-dsl/references/views.md +329 -0
  94. package/dist/chunks/libs/picomatch.mjs +0 -1
  95. package/dist/chunks/libs/zod.d.mts +0 -3840
  96. package/dist/chunks/libs/zod.mjs +0 -65
@@ -1,309 +1,475 @@
1
- import { i as e } from "./rolldown-runtime.mjs";
2
- import { c as t } from "./libs/@tanstack.mjs";
3
- import { C as n, F as r, N as i, O as a, _ as o, b as s, c, j as l, k as u, m as d, t as f, v as p, y as m } from "./hooks.mjs";
4
- import { At as h, C as g, F as _, H as v, Z as ee, _t as te, b as y, et as b, nn as ne, r as re, v as ie, vt as x } from "./libs/@mantine.mjs";
5
- import { C as S, L as C, T as w, y as T } from "./styled-system.mjs";
6
- import { i as ae, m as oe } from "./libs/framer.mjs";
7
- import { a as E, c as D, i as se, n as O, o as k, r as A, s as j, t as M } from "./libs/zod.mjs";
8
- import { a as N, i as ce, n as le, r as ue, t as de } from "./libs/@tanstack-ai.mjs";
9
- import { createContext as fe, use as pe, useEffect as me, useRef as P, useState as he } from "react";
10
- import { c as F } from "react/compiler-runtime";
11
- import { Fragment as I, jsx as L, jsxs as R } from "react/jsx-runtime";
12
- import { RichText as ge, nonNullable as _e, nonexhaustive as ve } from "@likec4/core";
13
- import { ElementShapes as ye } from "@likec4/core/styles";
14
- import { AIAdapter as be } from "likec4:rpc";
15
- //#region ../../node_modules/.pnpm/nanostores@1.5.3/node_modules/nanostores/computed/index.js
16
- var computedStore = (e, t, n) => {
17
- Array.isArray(e) || (e = [e]);
18
- let r, i, set = () => {
19
- if (i === s.epoch) return;
20
- i = s.epoch;
21
- let n = e.map((e) => e.get());
22
- if (!r?.every((t, r) => e[r].eq(t, n[r]))) {
23
- r = n;
24
- let e = t(...n);
25
- e && e.then && e.t ? e.then((e) => {
26
- r === n && a.set(e);
27
- }) : (a.set(e), i = s.epoch);
1
+ import { i as __name } from "./rolldown-runtime.mjs";
2
+ import { c as useNavigate } from "./libs/@tanstack.mjs";
3
+ import { A as r, E as IconSparkles, M as t$1, O as t, T as IconPlayerStopFilled, _ as useStore, b as useTimeoutEffect, c as Markdown, m as useDiagram, t as useCurrentProject } from "./hooks.mjs";
4
+ import { At as ScrollAreaAutosize, C as Modal, F as Textarea, H as FloatingWindow, Z as Button, _t as CloseButton, b as Notification, et as Badge, nn as useLocalStorage, r as Title, v as Tooltip, vt as ActionIcon } from "./libs/@mantine.mjs";
5
+ import { C as HStack, L as css, T as VStack, y as Txt } from "./styled-system.mjs";
6
+ import { i as nanostoresGlobal, n as onMount, r as atom } from "./libs/nanostores.mjs";
7
+ import { i as m, m as AnimatePresence } from "./libs/framer.mjs";
8
+ import { a as literal, c as string, i as discriminatedUnion, n as array, o as number, r as boolean, s as object, t as _enum } from "./libs/zod.mjs";
9
+ import { a as toolDefinition, i as fetchServerSentEvents, n as useChat$1, r as clientTools, t as ChatMessage$1 } from "./libs/@tanstack-ai.mjs";
10
+ import { createContext, use, useEffect, useRef, useState } from "react";
11
+ import { c } from "react/compiler-runtime";
12
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
13
+ import { RichText, nonNullable, nonexhaustive } from "@likec4/core";
14
+ import { ElementShapes } from "@likec4/core/styles";
15
+ import { AIAdapter } from "likec4:rpc";
16
+ //#region ../../node_modules/.pnpm/nanostores@1.5.5/node_modules/nanostores/computed/index.js
17
+ var computedStore = (stores, cb, batched) => {
18
+ if (!Array.isArray(stores)) stores = [stores];
19
+ let previousArgs;
20
+ let currentEpoch;
21
+ let set = () => {
22
+ if (currentEpoch === nanostoresGlobal.epoch) return;
23
+ currentEpoch = nanostoresGlobal.epoch;
24
+ let args = stores.map(($store) => $store.get());
25
+ if (!previousArgs?.every((arg, i) => stores[i].eq(arg, args[i]))) {
26
+ previousArgs = args;
27
+ let value = cb(...args);
28
+ if (value && value.then && value.t) value.then((asyncValue) => {
29
+ if (previousArgs === args) $computed.set(asyncValue);
30
+ });
31
+ else {
32
+ $computed.set(value);
33
+ currentEpoch = nanostoresGlobal.epoch;
34
+ }
28
35
  }
29
- }, a = /* @__PURE__ */ m(), o = a.get;
30
- a.get = () => (set(), o());
31
- let c, l = n ? () => {
32
- clearTimeout(c), c = setTimeout(set);
36
+ };
37
+ let $computed = /* @__PURE__ */ atom();
38
+ let get = $computed.get;
39
+ $computed.get = () => {
40
+ set();
41
+ return get();
42
+ };
43
+ let timer;
44
+ let run = batched ? () => {
45
+ clearTimeout(timer);
46
+ timer = setTimeout(set);
33
47
  } : set;
34
- return p(a, () => {
35
- let t = e.map((e) => e.listen(l));
36
- return set(), () => {
37
- for (let e of t) e();
48
+ onMount($computed, () => {
49
+ let unbinds = stores.map(($store) => $store.listen(run));
50
+ set();
51
+ return () => {
52
+ for (let unbind of unbinds) unbind();
38
53
  };
39
- }), a;
40
- }, batched = /* @__NO_SIDE_EFFECTS__ */ (e, t) => computedStore(e, t, !0), z = fe(null);
54
+ });
55
+ return $computed;
56
+ };
57
+ var batched = /* @__NO_SIDE_EFFECTS__ */ (stores, fn) => computedStore(stores, fn, true);
58
+ //#endregion
59
+ //#region src/aichat/ChatContext.tsx
60
+ var ChatContext = createContext(null);
41
61
  function useChatContext() {
42
- return _e(pe(z), "useChatContext: ChatProvider is not provided");
62
+ return nonNullable(use(ChatContext), "useChatContext: ChatProvider is not provided");
43
63
  }
44
64
  //#endregion
45
65
  //#region src/aichat/ChatInput.tsx
46
66
  function ChatInput() {
47
- let e = F(22), { sendMessage: t, isLoading: n, messages: r, clear: i, stop: o } = useChatContext(), [s, c] = he(""), l = P(null), t0;
48
- e[0] !== n || e[1] !== t || e[2] !== s ? (t0 = () => {
49
- s.trim() && !n && (t(s), c(""));
50
- }, e[0] = n, e[1] = t, e[2] = s, e[3] = t0) : t0 = e[3];
51
- let u = t0, t1;
52
- e[4] === Symbol.for("react.memo_cache_sentinel") ? (t1 = (e) => c(e.target.value), e[4] = t1) : t1 = e[4];
67
+ const $ = c(22);
68
+ const { sendMessage, isLoading, messages, clear, stop } = useChatContext();
69
+ const [value, setValue] = useState("");
70
+ const inputRef = useRef(null);
71
+ let t0;
72
+ if ($[0] !== isLoading || $[1] !== sendMessage || $[2] !== value) {
73
+ t0 = () => {
74
+ if (!value.trim() || isLoading) return;
75
+ sendMessage(value);
76
+ setValue("");
77
+ };
78
+ $[0] = isLoading;
79
+ $[1] = sendMessage;
80
+ $[2] = value;
81
+ $[3] = t0;
82
+ } else t0 = $[3];
83
+ const handleSubmit = t0;
84
+ let t1;
85
+ if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
86
+ t1 = (e) => setValue(e.target.value);
87
+ $[4] = t1;
88
+ } else t1 = $[4];
53
89
  let t2;
54
- e[5] === u ? t2 = e[6] : (t2 = (e) => {
55
- e.key === "Enter" && !e.shiftKey && !e.ctrlKey && !e.metaKey && (e.preventDefault(), u());
56
- }, e[5] = u, e[6] = t2);
57
- let d;
58
- e[7] !== n || e[8] !== t2 || e[9] !== s ? (d = /* @__PURE__ */ L(_, {
59
- flex: 1,
60
- className: "chat-input",
61
- placeholder: "Your question...",
62
- value: s,
63
- onChange: t1,
64
- onKeyDown: t2,
65
- disabled: n,
66
- ref: l,
67
- loading: n,
68
- autosize: !0,
69
- minRows: 1
70
- }), e[7] = n, e[8] = t2, e[9] = s, e[10] = d) : d = e[10];
71
- let f;
72
- e[11] !== i || e[12] !== n || e[13] !== r.length ? (f = r.length > 0 && !n && /* @__PURE__ */ L(ee, {
73
- size: "sm",
74
- color: "red",
75
- variant: "light",
76
- onClick: () => i(),
77
- children: "Clear"
78
- }), e[11] = i, e[12] = n, e[13] = r.length, e[14] = f) : f = e[14];
79
- let p;
80
- e[15] !== n || e[16] !== o ? (p = n && /* @__PURE__ */ L(x, {
81
- color: "red",
82
- variant: "light",
83
- onClick: () => o(),
84
- children: /* @__PURE__ */ L(a, {})
85
- }), e[15] = n, e[16] = o, e[17] = p) : p = e[17];
86
- let m;
87
- return e[18] !== d || e[19] !== f || e[20] !== p ? (m = /* @__PURE__ */ R(S, { children: [
88
- d,
89
- f,
90
- p
91
- ] }), e[18] = d, e[19] = f, e[20] = p, e[21] = m) : m = e[21], m;
90
+ if ($[5] !== handleSubmit) {
91
+ t2 = (e_0) => {
92
+ if (e_0.key === "Enter" && !e_0.shiftKey && !e_0.ctrlKey && !e_0.metaKey) {
93
+ e_0.preventDefault();
94
+ handleSubmit();
95
+ }
96
+ };
97
+ $[5] = handleSubmit;
98
+ $[6] = t2;
99
+ } else t2 = $[6];
100
+ let t3;
101
+ if ($[7] !== isLoading || $[8] !== t2 || $[9] !== value) {
102
+ t3 = /* @__PURE__ */ jsx(Textarea, {
103
+ flex: 1,
104
+ className: "chat-input",
105
+ placeholder: "Your question...",
106
+ value,
107
+ onChange: t1,
108
+ onKeyDown: t2,
109
+ disabled: isLoading,
110
+ ref: inputRef,
111
+ loading: isLoading,
112
+ autosize: true,
113
+ minRows: 1
114
+ });
115
+ $[7] = isLoading;
116
+ $[8] = t2;
117
+ $[9] = value;
118
+ $[10] = t3;
119
+ } else t3 = $[10];
120
+ let t4;
121
+ if ($[11] !== clear || $[12] !== isLoading || $[13] !== messages.length) {
122
+ t4 = messages.length > 0 && !isLoading && /* @__PURE__ */ jsx(Button, {
123
+ size: "sm",
124
+ color: "red",
125
+ variant: "light",
126
+ onClick: () => clear(),
127
+ children: "Clear"
128
+ });
129
+ $[11] = clear;
130
+ $[12] = isLoading;
131
+ $[13] = messages.length;
132
+ $[14] = t4;
133
+ } else t4 = $[14];
134
+ let t5;
135
+ if ($[15] !== isLoading || $[16] !== stop) {
136
+ t5 = isLoading && /* @__PURE__ */ jsx(ActionIcon, {
137
+ color: "red",
138
+ variant: "light",
139
+ onClick: () => stop(),
140
+ children: /* @__PURE__ */ jsx(IconPlayerStopFilled, {})
141
+ });
142
+ $[15] = isLoading;
143
+ $[16] = stop;
144
+ $[17] = t5;
145
+ } else t5 = $[17];
146
+ let t6;
147
+ if ($[18] !== t3 || $[19] !== t4 || $[20] !== t5) {
148
+ t6 = /* @__PURE__ */ jsxs(HStack, { children: [
149
+ t3,
150
+ t4,
151
+ t5
152
+ ] });
153
+ $[18] = t3;
154
+ $[19] = t4;
155
+ $[20] = t5;
156
+ $[21] = t6;
157
+ } else t6 = $[21];
158
+ return t6;
92
159
  }
93
160
  //#endregion
94
161
  //#region src/aichat/ChatMessage.tsx
95
162
  function ChatMessages() {
96
- let e = F(7), { messages: t, error: n } = useChatContext(), r;
97
- e[0] === t ? r = e[1] : (r = t.map(_temp), e[0] = t, e[1] = r);
98
- let i;
99
- e[2] === n ? i = e[3] : (i = n && /* @__PURE__ */ L(y, {
100
- styles: { icon: { alignSelf: "flex-start" } },
101
- color: "red",
102
- title: "Oops, something went wrong",
103
- withCloseButton: !1,
104
- children: /* @__PURE__ */ R(T, {
105
- fontSize: "sm",
106
- fontFamily: "mono",
107
- whiteSpace: "pre",
108
- my: "xs",
109
- children: [n.message, n.stack && "\n" + n.stack]
110
- })
111
- }), e[2] = n, e[3] = i);
112
- let a;
113
- return e[4] !== r || e[5] !== i ? (a = /* @__PURE__ */ R(I, { children: [r, i] }), e[4] = r, e[5] = i, e[6] = a) : a = e[6], a;
163
+ const $ = c(7);
164
+ const { messages, error } = useChatContext();
165
+ let t0;
166
+ if ($[0] !== messages) {
167
+ t0 = messages.map(_temp);
168
+ $[0] = messages;
169
+ $[1] = t0;
170
+ } else t0 = $[1];
171
+ let t1;
172
+ if ($[2] !== error) {
173
+ t1 = error && /* @__PURE__ */ jsx(Notification, {
174
+ styles: { icon: { alignSelf: "flex-start" } },
175
+ color: "red",
176
+ title: "Oops, something went wrong",
177
+ withCloseButton: false,
178
+ children: /* @__PURE__ */ jsxs(Txt, {
179
+ fontSize: "sm",
180
+ fontFamily: "mono",
181
+ whiteSpace: "pre",
182
+ my: "xs",
183
+ children: [error.message, error.stack && "\n" + error.stack]
184
+ })
185
+ });
186
+ $[2] = error;
187
+ $[3] = t1;
188
+ } else t1 = $[3];
189
+ let t2;
190
+ if ($[4] !== t0 || $[5] !== t1) {
191
+ t2 = /* @__PURE__ */ jsxs(Fragment$1, { children: [t0, t1] });
192
+ $[4] = t0;
193
+ $[5] = t1;
194
+ $[6] = t2;
195
+ } else t2 = $[6];
196
+ return t2;
114
197
  }
115
- function _temp(e) {
116
- return /* @__PURE__ */ L(ChatMessage, { message: e }, e.id);
198
+ function _temp(message) {
199
+ return /* @__PURE__ */ jsx(ChatMessage, { message }, message.id);
117
200
  }
118
- var ChatMessage = (e) => {
119
- let t = F(4), { message: n } = e, r = n.role, i;
120
- t[0] === Symbol.for("react.memo_cache_sentinel") ? (i = C({
121
- color: "text.bright",
122
- alignSelf: "flex-end",
123
- paddingInline: "2",
124
- paddingBlock: "1",
125
- marginInlineEnd: "2",
126
- rounded: "sm",
127
- backgroundColor: "surface.hover",
128
- whiteSpace: "pre-wrap"
129
- }), t[0] = i) : i = t[0];
130
- let a = r === "user" ? UserMessageTextPart : MarkdownTextPart, o;
131
- return t[1] !== n || t[2] !== a ? (o = /* @__PURE__ */ L(de, {
132
- message: n,
133
- userClassName: i,
134
- textPartRenderer: a
135
- }), t[1] = n, t[2] = a, t[3] = o) : o = t[3], o;
136
- }, UserMessageTextPart = (e) => {
137
- let t = F(2), { content: n } = e, r;
138
- return t[0] === n ? r = t[1] : (r = /* @__PURE__ */ L(I, { children: n }), t[0] = n, t[1] = r), r;
139
- }, MarkdownTextPart = (e) => {
140
- let t = F(4), { content: n } = e, r;
141
- t[0] === n ? r = t[1] : (r = ge.from({ md: n }), t[0] = n, t[1] = r);
142
- let i;
143
- return t[2] === r ? i = t[3] : (i = /* @__PURE__ */ L(c, {
144
- textScale: .95,
145
- value: r
146
- }), t[2] = r, t[3] = i), i;
147
- }, B = /* @__PURE__ */ m(""), V = /* @__PURE__ */ m("closed"), xe = /* @__PURE__ */ batched([B, V], (e, t) => ({
148
- log: e,
149
- status: t
201
+ var ChatMessage = (t0) => {
202
+ const $ = c(4);
203
+ const { message } = t0;
204
+ const role = message.role;
205
+ let t1;
206
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
207
+ t1 = css({
208
+ color: "text.bright",
209
+ alignSelf: "flex-end",
210
+ paddingInline: "2",
211
+ paddingBlock: "1",
212
+ marginInlineEnd: "2",
213
+ rounded: "sm",
214
+ backgroundColor: "surface.hover",
215
+ whiteSpace: "pre-wrap"
216
+ });
217
+ $[0] = t1;
218
+ } else t1 = $[0];
219
+ const t2 = role === "user" ? UserMessageTextPart : MarkdownTextPart;
220
+ let t3;
221
+ if ($[1] !== message || $[2] !== t2) {
222
+ t3 = /* @__PURE__ */ jsx(ChatMessage$1, {
223
+ message,
224
+ userClassName: t1,
225
+ textPartRenderer: t2
226
+ });
227
+ $[1] = message;
228
+ $[2] = t2;
229
+ $[3] = t3;
230
+ } else t3 = $[3];
231
+ return t3;
232
+ };
233
+ var UserMessageTextPart = (t0) => {
234
+ const $ = c(2);
235
+ const { content } = t0;
236
+ let t1;
237
+ if ($[0] !== content) {
238
+ t1 = /* @__PURE__ */ jsx(Fragment$1, { children: content });
239
+ $[0] = content;
240
+ $[1] = t1;
241
+ } else t1 = $[1];
242
+ return t1;
243
+ };
244
+ var MarkdownTextPart = (t0) => {
245
+ const $ = c(4);
246
+ const { content } = t0;
247
+ let t1;
248
+ if ($[0] !== content) {
249
+ t1 = RichText.from({ md: content });
250
+ $[0] = content;
251
+ $[1] = t1;
252
+ } else t1 = $[1];
253
+ let t2;
254
+ if ($[2] !== t1) {
255
+ t2 = /* @__PURE__ */ jsx(Markdown, {
256
+ textScale: .95,
257
+ value: t1
258
+ });
259
+ $[2] = t1;
260
+ $[3] = t2;
261
+ } else t2 = $[3];
262
+ return t2;
263
+ };
264
+ //#endregion
265
+ //#region src/aichat/semantic-layout-log-state.ts
266
+ var $log = /* @__PURE__ */ atom("");
267
+ var $status = /* @__PURE__ */ atom("closed");
268
+ var $state = /* @__PURE__ */ batched([$log, $status], (log, status) => ({
269
+ log,
270
+ status
150
271
  }));
151
272
  function useSemanticLayoutLog() {
152
- return o(xe);
273
+ return useStore($state);
153
274
  }
154
275
  function closeSemanticLayoutLog() {
155
- V.set("closed"), B.set("");
276
+ $status.set("closed");
277
+ $log.set("");
156
278
  }
157
279
  //#endregion
158
280
  //#region src/aichat/SemanticLayoutLog.tsx
281
+ /**
282
+ * Modal that shows the log of the semantic layout application
283
+ * (For internal debugging purposes)
284
+ */
159
285
  function SemanticLayoutLog() {
160
- let e = F(6), { log: t, status: n } = useSemanticLayoutLog();
161
- if (n === "closed") return null;
162
- let r = n === "completed", i;
163
- e[0] === Symbol.for("react.memo_cache_sentinel") ? (i = /* @__PURE__ */ L(re, {
164
- order: 4,
165
- children: "Semantic Layout"
166
- }), e[0] = i) : i = e[0];
167
- let a = t || "Waiting for response...", o;
168
- e[1] === a ? o = e[2] : (o = /* @__PURE__ */ L(T, {
169
- whiteSpace: "pre-wrap",
170
- children: a
171
- }), e[1] = a, e[2] = o);
172
- let s;
173
- return e[3] !== r || e[4] !== o ? (s = /* @__PURE__ */ L(g, {
174
- size: "xl",
175
- opened: !0,
176
- onClose: closeSemanticLayoutLog,
177
- closeOnEscape: r,
178
- withCloseButton: r,
179
- closeOnClickOutside: r,
180
- title: i,
181
- children: o
182
- }), e[3] = r, e[4] = o, e[5] = s) : s = e[5], s;
286
+ const $ = c(6);
287
+ const { log, status } = useSemanticLayoutLog();
288
+ if (status === "closed") return null;
289
+ const closable = status === "completed";
290
+ let t0;
291
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
292
+ t0 = /* @__PURE__ */ jsx(Title, {
293
+ order: 4,
294
+ children: "Semantic Layout"
295
+ });
296
+ $[0] = t0;
297
+ } else t0 = $[0];
298
+ const t1 = log || "Waiting for response...";
299
+ let t2;
300
+ if ($[1] !== t1) {
301
+ t2 = /* @__PURE__ */ jsx(Txt, {
302
+ whiteSpace: "pre-wrap",
303
+ children: t1
304
+ });
305
+ $[1] = t1;
306
+ $[2] = t2;
307
+ } else t2 = $[2];
308
+ let t3;
309
+ if ($[3] !== closable || $[4] !== t2) {
310
+ t3 = /* @__PURE__ */ jsx(Modal, {
311
+ size: "xl",
312
+ opened: true,
313
+ onClose: closeSemanticLayoutLog,
314
+ closeOnEscape: closable,
315
+ withCloseButton: closable,
316
+ closeOnClickOutside: closable,
317
+ title: t0,
318
+ children: t2
319
+ });
320
+ $[3] = closable;
321
+ $[4] = t2;
322
+ $[5] = t3;
323
+ } else t3 = $[5];
324
+ return t3;
183
325
  }
184
326
  //#endregion
185
327
  //#region ../vite-plugin/src/ai/tools.ts
186
- var H = j({
187
- id: D().meta({ description: "Node ID" }),
188
- title: D(),
189
- shape: M(ye),
190
- color: D().meta({ description: "Node color, from theme or custom" }),
191
- icon: D().nullish(),
192
- parentId: D().nullish().meta({ description: "Parent node ID (if node is nested)" }),
193
- children: O(D()).nullish().meta({ description: "Nested node IDs (if node is compound)" }),
194
- x: k(),
195
- y: k(),
196
- width: k(),
197
- height: k(),
198
- modelFqn: D().nullish().meta({ description: "Model element FQN (if node has reference)" })
199
- }), Se = N({
328
+ var nodeSchema = object({
329
+ id: string().meta({ description: "Node ID" }),
330
+ title: string(),
331
+ shape: _enum(ElementShapes),
332
+ color: string().meta({ description: "Node color, from theme or custom" }),
333
+ icon: string().nullish(),
334
+ parentId: string().nullish().meta({ description: "Parent node ID (if node is nested)" }),
335
+ children: array(string()).nullish().meta({ description: "Nested node IDs (if node is compound)" }),
336
+ x: number(),
337
+ y: number(),
338
+ width: number(),
339
+ height: number(),
340
+ modelFqn: string().nullish().meta({ description: "Model element FQN (if node has reference)" })
341
+ });
342
+ var readUiStateDef = toolDefinition({
200
343
  name: "read_ui",
201
344
  description: "Read current UI state. Use arguments to include additional data.",
202
- needsApproval: !1,
203
- inputSchema: j({
204
- selectedNode: A().default(!1).meta({ description: "Include selected node (if any)" }),
205
- nodes: A().default(!1).meta({ description: "Include all nodes from the view" })
345
+ needsApproval: false,
346
+ inputSchema: object({
347
+ selectedNode: boolean().default(false).meta({ description: "Include selected node (if any)" }),
348
+ nodes: boolean().default(false).meta({ description: "Include all nodes from the view" })
206
349
  }),
207
- outputSchema: j({
208
- projectId: D(),
209
- editMode: A().meta({ description: "Whether the UI is in edit mode" }),
210
- view: j({
211
- id: D(),
212
- title: D(),
213
- type: M([
350
+ outputSchema: object({
351
+ projectId: string(),
352
+ editMode: boolean().meta({ description: "Whether the UI is in edit mode" }),
353
+ view: object({
354
+ id: string(),
355
+ title: string(),
356
+ type: _enum([
214
357
  "element",
215
358
  "deployment",
216
359
  "dynamic"
217
360
  ]).meta({ description: "Type of the current view" })
218
361
  }).meta({ description: "Current view" }),
219
- nodes: O(H).nullish(),
220
- selectedNode: H.nullish()
362
+ nodes: array(nodeSchema).nullish(),
363
+ selectedNode: nodeSchema.nullish()
221
364
  })
222
- }), Ce = j({
223
- type: E("focus"),
224
- elementId: D().meta({ description: "Element ID (FQN)" })
225
- }).meta({ description: "Focus UI on an element by its FQN" }), we = j({ type: E("fitview") }).meta({ description: "Zoom out to fit all elements in the viewport, and clear any selection/focus" }), Te = N({
365
+ });
366
+ var focusCommand = object({
367
+ type: literal("focus"),
368
+ elementId: string().meta({ description: "Element ID (FQN)" })
369
+ }).meta({ description: "Focus UI on an element by its FQN" });
370
+ var fitViewCommand = object({ type: literal("fitview") }).meta({ description: "Zoom out to fit all elements in the viewport, and clear any selection/focus" });
371
+ var updateUiStateDef = toolDefinition({
226
372
  name: "update_ui",
227
373
  description: "Update UI state by executing a command.",
228
- needsApproval: !1,
229
- inputSchema: j({ command: se("type", [Ce, we]) }),
230
- outputSchema: j({})
231
- }), Ee = N({
374
+ needsApproval: false,
375
+ inputSchema: object({ command: discriminatedUnion("type", [focusCommand, fitViewCommand]) }),
376
+ outputSchema: object({})
377
+ });
378
+ var navigateToDef = toolDefinition({
232
379
  name: "navigate_to",
233
380
  description: "Navigates UI to another view",
234
- needsApproval: !1,
235
- inputSchema: j({ viewId: D().meta({ description: "View ID" }) }),
236
- outputSchema: j({})
237
- }), DoubleIndexedKV = class {
381
+ needsApproval: false,
382
+ inputSchema: object({ viewId: string().meta({ description: "View ID" }) }),
383
+ outputSchema: object({})
384
+ });
385
+ //#endregion
386
+ //#region ../../node_modules/.pnpm/superjson@2.2.6/node_modules/superjson/dist/double-indexed-kv.js
387
+ var DoubleIndexedKV = class {
238
388
  constructor() {
239
- this.keyToValue = /* @__PURE__ */ new Map(), this.valueToKey = /* @__PURE__ */ new Map();
389
+ this.keyToValue = /* @__PURE__ */ new Map();
390
+ this.valueToKey = /* @__PURE__ */ new Map();
240
391
  }
241
- set(e, t) {
242
- this.keyToValue.set(e, t), this.valueToKey.set(t, e);
392
+ set(key, value) {
393
+ this.keyToValue.set(key, value);
394
+ this.valueToKey.set(value, key);
243
395
  }
244
- getByKey(e) {
245
- return this.keyToValue.get(e);
396
+ getByKey(key) {
397
+ return this.keyToValue.get(key);
246
398
  }
247
- getByValue(e) {
248
- return this.valueToKey.get(e);
399
+ getByValue(value) {
400
+ return this.valueToKey.get(value);
249
401
  }
250
402
  clear() {
251
- this.keyToValue.clear(), this.valueToKey.clear();
403
+ this.keyToValue.clear();
404
+ this.valueToKey.clear();
252
405
  }
253
- }, Registry = class {
254
- constructor(e) {
255
- this.generateIdentifier = e, this.kv = new DoubleIndexedKV();
406
+ };
407
+ //#endregion
408
+ //#region ../../node_modules/.pnpm/superjson@2.2.6/node_modules/superjson/dist/registry.js
409
+ var Registry = class {
410
+ constructor(generateIdentifier) {
411
+ this.generateIdentifier = generateIdentifier;
412
+ this.kv = new DoubleIndexedKV();
256
413
  }
257
- register(e, t) {
258
- this.kv.getByValue(e) || (t ||= this.generateIdentifier(e), this.kv.set(t, e));
414
+ register(value, identifier) {
415
+ if (this.kv.getByValue(value)) return;
416
+ if (!identifier) identifier = this.generateIdentifier(value);
417
+ this.kv.set(identifier, value);
259
418
  }
260
419
  clear() {
261
420
  this.kv.clear();
262
421
  }
263
- getIdentifier(e) {
264
- return this.kv.getByValue(e);
422
+ getIdentifier(value) {
423
+ return this.kv.getByValue(value);
265
424
  }
266
- getValue(e) {
267
- return this.kv.getByKey(e);
425
+ getValue(identifier) {
426
+ return this.kv.getByKey(identifier);
268
427
  }
269
- }, ClassRegistry = class extends Registry {
428
+ };
429
+ //#endregion
430
+ //#region ../../node_modules/.pnpm/superjson@2.2.6/node_modules/superjson/dist/class-registry.js
431
+ var ClassRegistry = class extends Registry {
270
432
  constructor() {
271
- super((e) => e.name), this.classToAllowedProps = /* @__PURE__ */ new Map();
433
+ super((c) => c.name);
434
+ this.classToAllowedProps = /* @__PURE__ */ new Map();
272
435
  }
273
- register(e, t) {
274
- typeof t == "object" ? (t.allowProps && this.classToAllowedProps.set(e, t.allowProps), super.register(e, t.identifier)) : super.register(e, t);
436
+ register(value, options) {
437
+ if (typeof options === "object") {
438
+ if (options.allowProps) this.classToAllowedProps.set(value, options.allowProps);
439
+ super.register(value, options.identifier);
440
+ } else super.register(value, options);
275
441
  }
276
- getAllowedProps(e) {
277
- return this.classToAllowedProps.get(e);
442
+ getAllowedProps(value) {
443
+ return this.classToAllowedProps.get(value);
278
444
  }
279
445
  };
280
446
  //#endregion
281
447
  //#region ../../node_modules/.pnpm/superjson@2.2.6/node_modules/superjson/dist/util.js
282
- function valuesOfObj(e) {
283
- if ("values" in Object) return Object.values(e);
284
- let t = [];
285
- for (let n in e) e.hasOwnProperty(n) && t.push(e[n]);
286
- return t;
448
+ function valuesOfObj(record) {
449
+ if ("values" in Object) return Object.values(record);
450
+ const values = [];
451
+ for (const key in record) if (record.hasOwnProperty(key)) values.push(record[key]);
452
+ return values;
287
453
  }
288
- function find(e, t) {
289
- let n = valuesOfObj(e);
290
- if ("find" in n) return n.find(t);
291
- let r = n;
292
- for (let e = 0; e < r.length; e++) {
293
- let n = r[e];
294
- if (t(n)) return n;
454
+ function find(record, predicate) {
455
+ const values = valuesOfObj(record);
456
+ if ("find" in values) return values.find(predicate);
457
+ const valuesNotNever = values;
458
+ for (let i = 0; i < valuesNotNever.length; i++) {
459
+ const value = valuesNotNever[i];
460
+ if (predicate(value)) return value;
295
461
  }
296
462
  }
297
- function forEach(e, t) {
298
- Object.entries(e).forEach(([e, n]) => t(n, e));
463
+ function forEach(record, run) {
464
+ Object.entries(record).forEach(([key, value]) => run(value, key));
299
465
  }
300
- function includes(e, t) {
301
- return e.indexOf(t) !== -1;
466
+ function includes(arr, value) {
467
+ return arr.indexOf(value) !== -1;
302
468
  }
303
- function findArr(e, t) {
304
- for (let n = 0; n < e.length; n++) {
305
- let r = e[n];
306
- if (t(r)) return r;
469
+ function findArr(record, predicate) {
470
+ for (let i = 0; i < record.length; i++) {
471
+ const value = record[i];
472
+ if (predicate(value)) return value;
307
473
  }
308
474
  }
309
475
  //#endregion
@@ -312,91 +478,150 @@ var CustomTransformerRegistry = class {
312
478
  constructor() {
313
479
  this.transfomers = {};
314
480
  }
315
- register(e) {
316
- this.transfomers[e.name] = e;
481
+ register(transformer) {
482
+ this.transfomers[transformer.name] = transformer;
317
483
  }
318
- findApplicable(e) {
319
- return find(this.transfomers, (t) => t.isApplicable(e));
484
+ findApplicable(v) {
485
+ return find(this.transfomers, (transformer) => transformer.isApplicable(v));
320
486
  }
321
- findByName(e) {
322
- return this.transfomers[e];
487
+ findByName(name) {
488
+ return this.transfomers[name];
323
489
  }
324
- }, De = /* @__PURE__ */ e((e) => Object.prototype.toString.call(e).slice(8, -1), "getType"), isUndefined = (e) => e === void 0, isNull = (e) => e === null, U = /* @__PURE__ */ e((e) => typeof e != "object" || !e || e === Object.prototype ? !1 : Object.getPrototypeOf(e) === null || Object.getPrototypeOf(e) === Object.prototype, "isPlainObject"), isEmptyObject = (e) => U(e) && Object.keys(e).length === 0, W = /* @__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) => De(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) => {
325
- let n = [], r = "";
326
- for (let i = 0; i < e.length; i++) {
327
- let a = e.charAt(i);
328
- if (!t && a === "\\") {
329
- let t = e.charAt(i + 1);
330
- if (t === "\\") {
331
- r += "\\", i++;
490
+ };
491
+ //#endregion
492
+ //#region ../../node_modules/.pnpm/superjson@2.2.6/node_modules/superjson/dist/is.js
493
+ var getType$1 = /* @__PURE__ */ __name((payload) => Object.prototype.toString.call(payload).slice(8, -1), "getType");
494
+ var isUndefined = (payload) => typeof payload === "undefined";
495
+ var isNull = (payload) => payload === null;
496
+ var isPlainObject$1 = /* @__PURE__ */ __name((payload) => {
497
+ if (typeof payload !== "object" || payload === null) return false;
498
+ if (payload === Object.prototype) return false;
499
+ if (Object.getPrototypeOf(payload) === null) return true;
500
+ return Object.getPrototypeOf(payload) === Object.prototype;
501
+ }, "isPlainObject");
502
+ var isEmptyObject = (payload) => isPlainObject$1(payload) && Object.keys(payload).length === 0;
503
+ var isArray$1 = /* @__PURE__ */ __name((payload) => Array.isArray(payload), "isArray");
504
+ var isString = (payload) => typeof payload === "string";
505
+ var isNumber = (payload) => typeof payload === "number" && !isNaN(payload);
506
+ var isBoolean = (payload) => typeof payload === "boolean";
507
+ var isRegExp = (payload) => payload instanceof RegExp;
508
+ var isMap = (payload) => payload instanceof Map;
509
+ var isSet = (payload) => payload instanceof Set;
510
+ var isSymbol = (payload) => getType$1(payload) === "Symbol";
511
+ var isDate = (payload) => payload instanceof Date && !isNaN(payload.valueOf());
512
+ var isError = (payload) => payload instanceof Error;
513
+ var isNaNValue = (payload) => typeof payload === "number" && isNaN(payload);
514
+ var isPrimitive = (payload) => isBoolean(payload) || isNull(payload) || isUndefined(payload) || isNumber(payload) || isString(payload) || isSymbol(payload);
515
+ var isBigint = (payload) => typeof payload === "bigint";
516
+ var isInfinite = (payload) => payload === Infinity || payload === -Infinity;
517
+ var isTypedArray = (payload) => ArrayBuffer.isView(payload) && !(payload instanceof DataView);
518
+ var isURL = (payload) => payload instanceof URL;
519
+ //#endregion
520
+ //#region ../../node_modules/.pnpm/superjson@2.2.6/node_modules/superjson/dist/pathstringifier.js
521
+ var escapeKey = (key) => key.replace(/\\/g, "\\\\").replace(/\./g, "\\.");
522
+ var stringifyPath = (path) => path.map(String).map(escapeKey).join(".");
523
+ var parsePath = (string, legacyPaths) => {
524
+ const result = [];
525
+ let segment = "";
526
+ for (let i = 0; i < string.length; i++) {
527
+ let char = string.charAt(i);
528
+ if (!legacyPaths && char === "\\") {
529
+ const escaped = string.charAt(i + 1);
530
+ if (escaped === "\\") {
531
+ segment += "\\";
532
+ i++;
332
533
  continue;
333
- }
334
- if (t !== ".") throw Error("invalid path");
534
+ } else if (escaped !== ".") throw Error("invalid path");
335
535
  }
336
- if (a === "\\" && e.charAt(i + 1) === ".") {
337
- r += ".", i++;
536
+ if (char === "\\" && string.charAt(i + 1) === ".") {
537
+ segment += ".";
538
+ i++;
338
539
  continue;
339
540
  }
340
- if (a === ".") {
341
- n.push(r), r = "";
541
+ if (char === ".") {
542
+ result.push(segment);
543
+ segment = "";
342
544
  continue;
343
545
  }
344
- r += a;
546
+ segment += char;
345
547
  }
346
- let i = r;
347
- return n.push(i), n;
548
+ const lastSegment = segment;
549
+ result.push(lastSegment);
550
+ return result;
348
551
  };
349
552
  //#endregion
350
553
  //#region ../../node_modules/.pnpm/superjson@2.2.6/node_modules/superjson/dist/transformer.js
351
- function simpleTransformation(e, t, n, r) {
554
+ function simpleTransformation(isApplicable, annotation, transform, untransform) {
352
555
  return {
353
- isApplicable: e,
354
- annotation: t,
355
- transform: n,
356
- untransform: r
556
+ isApplicable,
557
+ annotation,
558
+ transform,
559
+ untransform
357
560
  };
358
561
  }
359
- var G = [
562
+ var simpleRules = [
360
563
  simpleTransformation(isUndefined, "undefined", () => null, () => void 0),
361
- simpleTransformation(isBigint, "bigint", (e) => e.toString(), (e) => typeof BigInt < "u" ? BigInt(e) : (console.error("Please add a BigInt polyfill."), e)),
362
- simpleTransformation(isDate, "Date", (e) => e.toISOString(), (e) => new Date(e)),
363
- simpleTransformation(isError, "Error", (e, t) => {
364
- let n = {
365
- name: e.name,
366
- message: e.message
564
+ simpleTransformation(isBigint, "bigint", (v) => v.toString(), (v) => {
565
+ if (typeof BigInt !== "undefined") return BigInt(v);
566
+ console.error("Please add a BigInt polyfill.");
567
+ return v;
568
+ }),
569
+ simpleTransformation(isDate, "Date", (v) => v.toISOString(), (v) => new Date(v)),
570
+ simpleTransformation(isError, "Error", (v, superJson) => {
571
+ const baseError = {
572
+ name: v.name,
573
+ message: v.message
367
574
  };
368
- return "cause" in e && (n.cause = e.cause), t.allowedErrorProps.forEach((t) => {
369
- n[t] = e[t];
370
- }), n;
371
- }, (e, t) => {
372
- let n = Error(e.message, { cause: e.cause });
373
- return n.name = e.name, n.stack = e.stack, t.allowedErrorProps.forEach((t) => {
374
- n[t] = e[t];
375
- }), n;
575
+ if ("cause" in v) baseError.cause = v.cause;
576
+ superJson.allowedErrorProps.forEach((prop) => {
577
+ baseError[prop] = v[prop];
578
+ });
579
+ return baseError;
580
+ }, (v, superJson) => {
581
+ const e = new Error(v.message, { cause: v.cause });
582
+ e.name = v.name;
583
+ e.stack = v.stack;
584
+ superJson.allowedErrorProps.forEach((prop) => {
585
+ e[prop] = v[prop];
586
+ });
587
+ return e;
376
588
  }),
377
- simpleTransformation(isRegExp, "regexp", (e) => "" + e, (e) => {
378
- let t = e.slice(1, e.lastIndexOf("/")), n = e.slice(e.lastIndexOf("/") + 1);
379
- return new RegExp(t, n);
589
+ simpleTransformation(isRegExp, "regexp", (v) => "" + v, (regex) => {
590
+ const body = regex.slice(1, regex.lastIndexOf("/"));
591
+ const flags = regex.slice(regex.lastIndexOf("/") + 1);
592
+ return new RegExp(body, flags);
380
593
  }),
381
- simpleTransformation(isSet, "set", (e) => [...e.values()], (e) => new Set(e)),
382
- simpleTransformation(isMap, "map", (e) => [...e.entries()], (e) => new Map(e)),
383
- simpleTransformation((e) => isNaNValue(e) || isInfinite(e), "number", (e) => isNaNValue(e) ? "NaN" : e > 0 ? "Infinity" : "-Infinity", Number),
384
- simpleTransformation((e) => e === 0 && 1 / e == -Infinity, "number", () => "-0", Number),
385
- simpleTransformation(isURL, "URL", (e) => e.toString(), (e) => new URL(e))
594
+ simpleTransformation(isSet, "set", (v) => [...v.values()], (v) => new Set(v)),
595
+ simpleTransformation(isMap, "map", (v) => [...v.entries()], (v) => new Map(v)),
596
+ simpleTransformation((v) => isNaNValue(v) || isInfinite(v), "number", (v) => {
597
+ if (isNaNValue(v)) return "NaN";
598
+ if (v > 0) return "Infinity";
599
+ else return "-Infinity";
600
+ }, Number),
601
+ simpleTransformation((v) => v === 0 && 1 / v === -Infinity, "number", () => {
602
+ return "-0";
603
+ }, Number),
604
+ simpleTransformation(isURL, "URL", (v) => v.toString(), (v) => new URL(v))
386
605
  ];
387
- function compositeTransformation(e, t, n, r) {
606
+ function compositeTransformation(isApplicable, annotation, transform, untransform) {
388
607
  return {
389
- isApplicable: e,
390
- annotation: t,
391
- transform: n,
392
- untransform: r
608
+ isApplicable,
609
+ annotation,
610
+ transform,
611
+ untransform
393
612
  };
394
613
  }
395
- var K = compositeTransformation((e, t) => isSymbol(e) ? !!t.symbolRegistry.getIdentifier(e) : !1, (e, t) => ["symbol", t.symbolRegistry.getIdentifier(e)], (e) => e.description, (e, t, n) => {
396
- let r = n.symbolRegistry.getValue(t[1]);
397
- if (!r) throw Error("Trying to deserialize unknown symbol");
398
- return r;
399
- }), q = [
614
+ var symbolRule = compositeTransformation((s, superJson) => {
615
+ if (isSymbol(s)) return !!superJson.symbolRegistry.getIdentifier(s);
616
+ return false;
617
+ }, (s, superJson) => {
618
+ return ["symbol", superJson.symbolRegistry.getIdentifier(s)];
619
+ }, (v) => v.description, (_, a, superJson) => {
620
+ const value = superJson.symbolRegistry.getValue(a[1]);
621
+ if (!value) throw new Error("Trying to deserialize unknown symbol");
622
+ return value;
623
+ });
624
+ var constructorToName = [
400
625
  Int8Array,
401
626
  Uint8Array,
402
627
  Int16Array,
@@ -406,451 +631,619 @@ var K = compositeTransformation((e, t) => isSymbol(e) ? !!t.symbolRegistry.getId
406
631
  Float32Array,
407
632
  Float64Array,
408
633
  Uint8ClampedArray
409
- ].reduce((e, t) => (e[t.name] = t, e), {}), J = compositeTransformation(isTypedArray, (e) => ["typed-array", e.constructor.name], (e) => [...e], (e, t) => {
410
- let n = q[t[1]];
411
- if (!n) throw Error("Trying to deserialize unknown typed array");
412
- return new n(e);
634
+ ].reduce((obj, ctor) => {
635
+ obj[ctor.name] = ctor;
636
+ return obj;
637
+ }, {});
638
+ var typedArrayRule = compositeTransformation(isTypedArray, (v) => ["typed-array", v.constructor.name], (v) => [...v], (v, a) => {
639
+ const ctor = constructorToName[a[1]];
640
+ if (!ctor) throw new Error("Trying to deserialize unknown typed array");
641
+ return new ctor(v);
413
642
  });
414
- function isInstanceOfRegisteredClass(e, t) {
415
- return e?.constructor ? !!t.classRegistry.getIdentifier(e.constructor) : !1;
643
+ function isInstanceOfRegisteredClass(potentialClass, superJson) {
644
+ if (potentialClass?.constructor) return !!superJson.classRegistry.getIdentifier(potentialClass.constructor);
645
+ return false;
416
646
  }
417
- var Y = compositeTransformation(isInstanceOfRegisteredClass, (e, t) => ["class", t.classRegistry.getIdentifier(e.constructor)], (e, t) => {
418
- let n = t.classRegistry.getAllowedProps(e.constructor);
419
- if (!n) return { ...e };
420
- let r = {};
421
- return n.forEach((t) => {
422
- r[t] = e[t];
423
- }), r;
424
- }, (e, t, n) => {
425
- let r = n.classRegistry.getValue(t[1]);
426
- if (!r) throw Error(`Trying to deserialize unknown class '${t[1]}' - check https://github.com/blitz-js/superjson/issues/116#issuecomment-773996564`);
427
- return Object.assign(Object.create(r.prototype), e);
428
- }), 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) => {
429
- let r = n.customTransformerRegistry.findByName(t[1]);
430
- if (!r) throw Error("Trying to deserialize unknown custom value");
431
- return r.deserialize(e);
432
- }), Oe = [
433
- Y,
434
- K,
435
- X,
436
- J
437
- ], transformValue = (e, t) => {
438
- let n = findArr(Oe, (n) => n.isApplicable(e, t));
439
- if (n) return {
440
- value: n.transform(e, t),
441
- type: n.annotation(e, t)
647
+ var classRule = compositeTransformation(isInstanceOfRegisteredClass, (clazz, superJson) => {
648
+ return ["class", superJson.classRegistry.getIdentifier(clazz.constructor)];
649
+ }, (clazz, superJson) => {
650
+ const allowedProps = superJson.classRegistry.getAllowedProps(clazz.constructor);
651
+ if (!allowedProps) return { ...clazz };
652
+ const result = {};
653
+ allowedProps.forEach((prop) => {
654
+ result[prop] = clazz[prop];
655
+ });
656
+ return result;
657
+ }, (v, a, superJson) => {
658
+ const clazz = superJson.classRegistry.getValue(a[1]);
659
+ if (!clazz) throw new Error(`Trying to deserialize unknown class '${a[1]}' - check https://github.com/blitz-js/superjson/issues/116#issuecomment-773996564`);
660
+ return Object.assign(Object.create(clazz.prototype), v);
661
+ });
662
+ var customRule = compositeTransformation((value, superJson) => {
663
+ return !!superJson.customTransformerRegistry.findApplicable(value);
664
+ }, (value, superJson) => {
665
+ return ["custom", superJson.customTransformerRegistry.findApplicable(value).name];
666
+ }, (value, superJson) => {
667
+ return superJson.customTransformerRegistry.findApplicable(value).serialize(value);
668
+ }, (v, a, superJson) => {
669
+ const transformer = superJson.customTransformerRegistry.findByName(a[1]);
670
+ if (!transformer) throw new Error("Trying to deserialize unknown custom value");
671
+ return transformer.deserialize(v);
672
+ });
673
+ var compositeRules = [
674
+ classRule,
675
+ symbolRule,
676
+ customRule,
677
+ typedArrayRule
678
+ ];
679
+ var transformValue = (value, superJson) => {
680
+ const applicableCompositeRule = findArr(compositeRules, (rule) => rule.isApplicable(value, superJson));
681
+ if (applicableCompositeRule) return {
682
+ value: applicableCompositeRule.transform(value, superJson),
683
+ type: applicableCompositeRule.annotation(value, superJson)
442
684
  };
443
- let r = findArr(G, (n) => n.isApplicable(e, t));
444
- if (r) return {
445
- value: r.transform(e, t),
446
- type: r.annotation
685
+ const applicableSimpleRule = findArr(simpleRules, (rule) => rule.isApplicable(value, superJson));
686
+ if (applicableSimpleRule) return {
687
+ value: applicableSimpleRule.transform(value, superJson),
688
+ type: applicableSimpleRule.annotation
447
689
  };
448
- }, Z = {};
449
- G.forEach((e) => {
450
- Z[e.annotation] = e;
690
+ };
691
+ var simpleRulesByAnnotation = {};
692
+ simpleRules.forEach((rule) => {
693
+ simpleRulesByAnnotation[rule.annotation] = rule;
451
694
  });
452
- var untransformValue = (e, t, n) => {
453
- if (W(t)) switch (t[0]) {
454
- case "symbol": return K.untransform(e, t, n);
455
- case "class": return Y.untransform(e, t, n);
456
- case "custom": return X.untransform(e, t, n);
457
- case "typed-array": return J.untransform(e, t, n);
458
- default: throw Error("Unknown transformation: " + t);
695
+ var untransformValue = (json, type, superJson) => {
696
+ if (isArray$1(type)) switch (type[0]) {
697
+ case "symbol": return symbolRule.untransform(json, type, superJson);
698
+ case "class": return classRule.untransform(json, type, superJson);
699
+ case "custom": return customRule.untransform(json, type, superJson);
700
+ case "typed-array": return typedArrayRule.untransform(json, type, superJson);
701
+ default: throw new Error("Unknown transformation: " + type);
459
702
  }
460
703
  else {
461
- let r = Z[t];
462
- if (!r) throw Error("Unknown transformation: " + t);
463
- return r.untransform(e, n);
464
- }
465
- }, getNthKey = (e, t) => {
466
- if (t > e.size) throw Error("index out of bounds");
467
- let n = e.keys();
468
- for (; t > 0;) n.next(), t--;
469
- return n.next().value;
704
+ const transformation = simpleRulesByAnnotation[type];
705
+ if (!transformation) throw new Error("Unknown transformation: " + type);
706
+ return transformation.untransform(json, superJson);
707
+ }
708
+ };
709
+ //#endregion
710
+ //#region ../../node_modules/.pnpm/superjson@2.2.6/node_modules/superjson/dist/accessDeep.js
711
+ var getNthKey = (value, n) => {
712
+ if (n > value.size) throw new Error("index out of bounds");
713
+ const keys = value.keys();
714
+ while (n > 0) {
715
+ keys.next();
716
+ n--;
717
+ }
718
+ return keys.next().value;
470
719
  };
471
- function validatePath(e) {
472
- if (includes(e, "__proto__")) throw Error("__proto__ is not allowed as a property");
473
- if (includes(e, "prototype")) throw Error("prototype is not allowed as a property");
474
- if (includes(e, "constructor")) throw Error("constructor is not allowed as a property");
720
+ function validatePath(path) {
721
+ if (includes(path, "__proto__")) throw new Error("__proto__ is not allowed as a property");
722
+ if (includes(path, "prototype")) throw new Error("prototype is not allowed as a property");
723
+ if (includes(path, "constructor")) throw new Error("constructor is not allowed as a property");
475
724
  }
476
- var getDeep = (e, t) => {
477
- validatePath(t);
478
- for (let n = 0; n < t.length; n++) {
479
- let r = t[n];
480
- if (isSet(e)) e = getNthKey(e, +r);
481
- else if (isMap(e)) {
482
- let i = +r, a = +t[++n] == 0 ? "key" : "value", o = getNthKey(e, i);
483
- switch (a) {
725
+ var getDeep = (object, path) => {
726
+ validatePath(path);
727
+ for (let i = 0; i < path.length; i++) {
728
+ const key = path[i];
729
+ if (isSet(object)) object = getNthKey(object, +key);
730
+ else if (isMap(object)) {
731
+ const row = +key;
732
+ const type = +path[++i] === 0 ? "key" : "value";
733
+ const keyOfRow = getNthKey(object, row);
734
+ switch (type) {
484
735
  case "key":
485
- e = o;
736
+ object = keyOfRow;
486
737
  break;
487
- case "value": e = e.get(o);
738
+ case "value": object = object.get(keyOfRow);
488
739
  }
489
- } else e = e[r];
490
- }
491
- return e;
492
- }, setDeep = (e, t, n) => {
493
- if (validatePath(t), t.length === 0) return n(e);
494
- let r = e;
495
- for (let e = 0; e < t.length - 1; e++) {
496
- let n = t[e];
497
- if (W(r)) {
498
- let e = +n;
499
- r = r[e];
500
- } else if (U(r)) r = r[n];
501
- else if (isSet(r)) {
502
- let e = +n;
503
- r = getNthKey(r, e);
504
- } else if (isMap(r)) {
505
- if (e === t.length - 2) break;
506
- let i = +n, a = +t[++e] == 0 ? "key" : "value", o = getNthKey(r, i);
507
- switch (a) {
740
+ } else object = object[key];
741
+ }
742
+ return object;
743
+ };
744
+ var setDeep = (object, path, mapper) => {
745
+ validatePath(path);
746
+ if (path.length === 0) return mapper(object);
747
+ let parent = object;
748
+ for (let i = 0; i < path.length - 1; i++) {
749
+ const key = path[i];
750
+ if (isArray$1(parent)) {
751
+ const index = +key;
752
+ parent = parent[index];
753
+ } else if (isPlainObject$1(parent)) parent = parent[key];
754
+ else if (isSet(parent)) {
755
+ const row = +key;
756
+ parent = getNthKey(parent, row);
757
+ } else if (isMap(parent)) {
758
+ if (i === path.length - 2) break;
759
+ const row = +key;
760
+ const type = +path[++i] === 0 ? "key" : "value";
761
+ const keyOfRow = getNthKey(parent, row);
762
+ switch (type) {
508
763
  case "key":
509
- r = o;
764
+ parent = keyOfRow;
510
765
  break;
511
- case "value": r = r.get(o);
766
+ case "value": parent = parent.get(keyOfRow);
512
767
  }
513
768
  }
514
769
  }
515
- let i = t[t.length - 1];
516
- if (W(r) ? r[+i] = n(r[+i]) : U(r) && (r[i] = n(r[i])), isSet(r)) {
517
- let e = getNthKey(r, +i), t = n(e);
518
- e !== t && (r.delete(e), r.add(t));
770
+ const lastKey = path[path.length - 1];
771
+ if (isArray$1(parent)) parent[+lastKey] = mapper(parent[+lastKey]);
772
+ else if (isPlainObject$1(parent)) parent[lastKey] = mapper(parent[lastKey]);
773
+ if (isSet(parent)) {
774
+ const oldValue = getNthKey(parent, +lastKey);
775
+ const newValue = mapper(oldValue);
776
+ if (oldValue !== newValue) {
777
+ parent.delete(oldValue);
778
+ parent.add(newValue);
779
+ }
519
780
  }
520
- if (isMap(r)) {
521
- let e = +t[t.length - 2], a = getNthKey(r, e);
522
- switch (+i == 0 ? "key" : "value") {
781
+ if (isMap(parent)) {
782
+ const row = +path[path.length - 2];
783
+ const keyToRow = getNthKey(parent, row);
784
+ switch (+lastKey === 0 ? "key" : "value") {
523
785
  case "key": {
524
- let e = n(a);
525
- r.set(e, r.get(a)), e !== a && r.delete(a);
786
+ const newKey = mapper(keyToRow);
787
+ parent.set(newKey, parent.get(keyToRow));
788
+ if (newKey !== keyToRow) parent.delete(keyToRow);
526
789
  break;
527
790
  }
528
- case "value": r.set(a, n(r.get(a)));
791
+ case "value": parent.set(keyToRow, mapper(parent.get(keyToRow)));
529
792
  }
530
793
  }
531
- return e;
532
- }, enableLegacyPaths = (e) => e < 1;
533
- function traverse(e, t, n, r = []) {
534
- if (!e) return;
535
- let i = enableLegacyPaths(n);
536
- if (!W(e)) {
537
- forEach(e, (e, a) => traverse(e, t, n, [...r, ...parsePath(a, i)]));
794
+ return object;
795
+ };
796
+ //#endregion
797
+ //#region ../../node_modules/.pnpm/superjson@2.2.6/node_modules/superjson/dist/plainer.js
798
+ var enableLegacyPaths = (version) => version < 1;
799
+ function traverse(tree, walker, version, origin = []) {
800
+ if (!tree) return;
801
+ const legacyPaths = enableLegacyPaths(version);
802
+ if (!isArray$1(tree)) {
803
+ forEach(tree, (subtree, key) => traverse(subtree, walker, version, [...origin, ...parsePath(key, legacyPaths)]));
538
804
  return;
539
805
  }
540
- let [a, o] = e;
541
- o && forEach(o, (e, a) => {
542
- traverse(e, t, n, [...r, ...parsePath(a, i)]);
543
- }), t(a, r);
806
+ const [nodeValue, children] = tree;
807
+ if (children) forEach(children, (child, key) => {
808
+ traverse(child, walker, version, [...origin, ...parsePath(key, legacyPaths)]);
809
+ });
810
+ walker(nodeValue, origin);
544
811
  }
545
- function applyValueAnnotations(e, t, n, r) {
546
- return traverse(t, (t, n) => {
547
- e = setDeep(e, n, (e) => untransformValue(e, t, r));
548
- }, n), e;
812
+ function applyValueAnnotations(plain, annotations, version, superJson) {
813
+ traverse(annotations, (type, path) => {
814
+ plain = setDeep(plain, path, (v) => untransformValue(v, type, superJson));
815
+ }, version);
816
+ return plain;
549
817
  }
550
- function applyReferentialEqualityAnnotations(e, t, n) {
551
- let r = enableLegacyPaths(n);
552
- function apply(t, n) {
553
- let i = getDeep(e, parsePath(n, r));
554
- t.map((e) => parsePath(e, r)).forEach((t) => {
555
- e = setDeep(e, t, () => i);
818
+ function applyReferentialEqualityAnnotations(plain, annotations, version) {
819
+ const legacyPaths = enableLegacyPaths(version);
820
+ function apply(identicalPaths, path) {
821
+ const object = getDeep(plain, parsePath(path, legacyPaths));
822
+ identicalPaths.map((path) => parsePath(path, legacyPaths)).forEach((identicalObjectPath) => {
823
+ plain = setDeep(plain, identicalObjectPath, () => object);
556
824
  });
557
825
  }
558
- if (W(t)) {
559
- let [n, i] = t;
560
- n.forEach((t) => {
561
- e = setDeep(e, parsePath(t, r), () => e);
562
- }), i && forEach(i, apply);
563
- } else forEach(t, apply);
564
- return e;
826
+ if (isArray$1(annotations)) {
827
+ const [root, other] = annotations;
828
+ root.forEach((identicalPath) => {
829
+ plain = setDeep(plain, parsePath(identicalPath, legacyPaths), () => plain);
830
+ });
831
+ if (other) forEach(other, apply);
832
+ } else forEach(annotations, apply);
833
+ return plain;
565
834
  }
566
- var isDeep = (e, t) => U(e) || W(e) || isMap(e) || isSet(e) || isError(e) || isInstanceOfRegisteredClass(e, t);
567
- function addIdentity(e, t, n) {
568
- let r = n.get(e);
569
- r ? r.push(t) : n.set(e, [t]);
835
+ var isDeep = (object, superJson) => isPlainObject$1(object) || isArray$1(object) || isMap(object) || isSet(object) || isError(object) || isInstanceOfRegisteredClass(object, superJson);
836
+ function addIdentity(object, path, identities) {
837
+ const existingSet = identities.get(object);
838
+ if (existingSet) existingSet.push(path);
839
+ else identities.set(object, [path]);
570
840
  }
571
- function generateReferentialEqualityAnnotations(e, t) {
572
- let n = {}, r;
573
- return e.forEach((e) => {
574
- if (e.length <= 1) return;
575
- t || (e = e.map((e) => e.map(String)).sort((e, t) => e.length - t.length));
576
- let [i, ...a] = e;
577
- i.length === 0 ? r = a.map(stringifyPath) : n[stringifyPath(i)] = a.map(stringifyPath);
578
- }), r ? isEmptyObject(n) ? [r] : [r, n] : isEmptyObject(n) ? void 0 : n;
841
+ function generateReferentialEqualityAnnotations(identitites, dedupe) {
842
+ const result = {};
843
+ let rootEqualityPaths = void 0;
844
+ identitites.forEach((paths) => {
845
+ if (paths.length <= 1) return;
846
+ if (!dedupe) paths = paths.map((path) => path.map(String)).sort((a, b) => a.length - b.length);
847
+ const [representativePath, ...identicalPaths] = paths;
848
+ if (representativePath.length === 0) rootEqualityPaths = identicalPaths.map(stringifyPath);
849
+ else result[stringifyPath(representativePath)] = identicalPaths.map(stringifyPath);
850
+ });
851
+ if (rootEqualityPaths) {
852
+ if (isEmptyObject(result)) return [rootEqualityPaths];
853
+ else return [rootEqualityPaths, result];
854
+ } else return isEmptyObject(result) ? void 0 : result;
579
855
  }
580
- var walker = (e, t, n, r, i = [], a = [], o = /* @__PURE__ */ new Map()) => {
581
- let s = isPrimitive(e);
582
- if (!s) {
583
- addIdentity(e, i, t);
584
- let n = o.get(e);
585
- if (n) return r ? { transformedValue: null } : n;
586
- }
587
- if (!isDeep(e, n)) {
588
- let t = transformValue(e, n), r = t ? {
589
- transformedValue: t.value,
590
- annotations: [t.type]
591
- } : { transformedValue: e };
592
- return s || o.set(e, r), r;
593
- }
594
- if (includes(a, e)) return { transformedValue: null };
595
- let c = transformValue(e, n), l = c?.value ?? e, u = W(l) ? [] : {}, d = {};
596
- forEach(l, (s, c) => {
597
- if (c === "__proto__" || c === "constructor" || c === "prototype") throw Error(`Detected property ${c}. This is a prototype pollution risk, please remove it from your object.`);
598
- let l = walker(s, t, n, r, [...i, c], [...a, e], o);
599
- u[c] = l.transformedValue, W(l.annotations) ? d[escapeKey(c)] = l.annotations : U(l.annotations) && forEach(l.annotations, (e, t) => {
600
- d[escapeKey(c) + "." + t] = e;
856
+ var walker = (object, identities, superJson, dedupe, path = [], objectsInThisPath = [], seenObjects = /* @__PURE__ */ new Map()) => {
857
+ const primitive = isPrimitive(object);
858
+ if (!primitive) {
859
+ addIdentity(object, path, identities);
860
+ const seen = seenObjects.get(object);
861
+ if (seen) return dedupe ? { transformedValue: null } : seen;
862
+ }
863
+ if (!isDeep(object, superJson)) {
864
+ const transformed = transformValue(object, superJson);
865
+ const result = transformed ? {
866
+ transformedValue: transformed.value,
867
+ annotations: [transformed.type]
868
+ } : { transformedValue: object };
869
+ if (!primitive) seenObjects.set(object, result);
870
+ return result;
871
+ }
872
+ if (includes(objectsInThisPath, object)) return { transformedValue: null };
873
+ const transformationResult = transformValue(object, superJson);
874
+ const transformed = transformationResult?.value ?? object;
875
+ const transformedValue = isArray$1(transformed) ? [] : {};
876
+ const innerAnnotations = {};
877
+ forEach(transformed, (value, index) => {
878
+ if (index === "__proto__" || index === "constructor" || index === "prototype") throw new Error(`Detected property ${index}. This is a prototype pollution risk, please remove it from your object.`);
879
+ const recursiveResult = walker(value, identities, superJson, dedupe, [...path, index], [...objectsInThisPath, object], seenObjects);
880
+ transformedValue[index] = recursiveResult.transformedValue;
881
+ if (isArray$1(recursiveResult.annotations)) innerAnnotations[escapeKey(index)] = recursiveResult.annotations;
882
+ else if (isPlainObject$1(recursiveResult.annotations)) forEach(recursiveResult.annotations, (tree, key) => {
883
+ innerAnnotations[escapeKey(index) + "." + key] = tree;
601
884
  });
602
885
  });
603
- let f = isEmptyObject(d) ? {
604
- transformedValue: u,
605
- annotations: c ? [c.type] : void 0
886
+ const result = isEmptyObject(innerAnnotations) ? {
887
+ transformedValue,
888
+ annotations: !!transformationResult ? [transformationResult.type] : void 0
606
889
  } : {
607
- transformedValue: u,
608
- annotations: c ? [c.type, d] : d
890
+ transformedValue,
891
+ annotations: !!transformationResult ? [transformationResult.type, innerAnnotations] : innerAnnotations
609
892
  };
610
- return s || o.set(e, f), f;
893
+ if (!primitive) seenObjects.set(object, result);
894
+ return result;
611
895
  };
612
896
  //#endregion
613
897
  //#region ../../node_modules/.pnpm/is-what@5.5.0/node_modules/is-what/dist/getType.js
614
- function getType(e) {
615
- return Object.prototype.toString.call(e).slice(8, -1);
898
+ /** Returns the object type of the given payload */
899
+ function getType(payload) {
900
+ return Object.prototype.toString.call(payload).slice(8, -1);
616
901
  }
617
902
  //#endregion
618
903
  //#region ../../node_modules/.pnpm/is-what@5.5.0/node_modules/is-what/dist/isArray.js
619
- function isArray(e) {
620
- return getType(e) === "Array";
904
+ /** Returns whether the payload is an array */
905
+ function isArray(payload) {
906
+ return getType(payload) === "Array";
621
907
  }
622
908
  //#endregion
623
909
  //#region ../../node_modules/.pnpm/is-what@5.5.0/node_modules/is-what/dist/isPlainObject.js
624
- function isPlainObject(e) {
625
- if (getType(e) !== "Object") return !1;
626
- let t = Object.getPrototypeOf(e);
627
- return !!t && t.constructor === Object && t === Object.prototype;
910
+ /**
911
+ * Returns whether the payload is a plain JavaScript object (excluding special classes or objects
912
+ * with other prototypes)
913
+ */
914
+ function isPlainObject(payload) {
915
+ if (getType(payload) !== "Object") return false;
916
+ const prototype = Object.getPrototypeOf(payload);
917
+ return !!prototype && prototype.constructor === Object && prototype === Object.prototype;
628
918
  }
629
919
  //#endregion
630
920
  //#region ../../node_modules/.pnpm/copy-anything@4.0.5/node_modules/copy-anything/dist/index.js
631
- function assignProp(e, t, n, r, i) {
632
- let a = {}.propertyIsEnumerable.call(r, t) ? "enumerable" : "nonenumerable";
633
- a === "enumerable" && (e[t] = n), i && a === "nonenumerable" && Object.defineProperty(e, t, {
634
- value: n,
635
- enumerable: !1,
636
- writable: !0,
637
- configurable: !0
921
+ function assignProp(carry, key, newVal, originalObject, includeNonenumerable) {
922
+ const propType = {}.propertyIsEnumerable.call(originalObject, key) ? "enumerable" : "nonenumerable";
923
+ if (propType === "enumerable") carry[key] = newVal;
924
+ if (includeNonenumerable && propType === "nonenumerable") Object.defineProperty(carry, key, {
925
+ value: newVal,
926
+ enumerable: false,
927
+ writable: true,
928
+ configurable: true
638
929
  });
639
930
  }
640
- function copy(e, t = {}) {
641
- if (isArray(e)) return e.map((e) => copy(e, t));
642
- if (!isPlainObject(e)) return e;
643
- let n = Object.getOwnPropertyNames(e), r = Object.getOwnPropertySymbols(e);
644
- return [...n, ...r].reduce((n, r) => {
645
- if (r === "__proto__" || isArray(t.props) && !t.props.includes(r)) return n;
646
- let i = e[r];
647
- return assignProp(n, r, copy(i, t), e, t.nonenumerable), n;
931
+ /**
932
+ * Copy (clone) an object and all its props recursively to get rid of any prop referenced of the
933
+ * original object. Arrays are also cloned, however objects inside arrays are still linked.
934
+ *
935
+ * @param target Target can be anything
936
+ * @param [options={}] See type {@link Options} for more details.
937
+ *
938
+ * - `{ props: ['key1'] }` will only copy the `key1` property. When using this you will need to cast
939
+ * the return type manually (in order to keep the TS implementation in here simple I didn't
940
+ * built a complex auto resolved type for those few cases people want to use this option)
941
+ * - `{ nonenumerable: true }` will copy all non-enumerable properties. Default is `{}`
942
+ *
943
+ * @returns The target with replaced values
944
+ */
945
+ function copy(target, options = {}) {
946
+ if (isArray(target)) return target.map((item) => copy(item, options));
947
+ if (!isPlainObject(target)) return target;
948
+ const props = Object.getOwnPropertyNames(target);
949
+ const symbols = Object.getOwnPropertySymbols(target);
950
+ return [...props, ...symbols].reduce((carry, key) => {
951
+ if (key === "__proto__") return carry;
952
+ if (isArray(options.props) && !options.props.includes(key)) return carry;
953
+ const val = target[key];
954
+ assignProp(carry, key, copy(val, options), target, options.nonenumerable);
955
+ return carry;
648
956
  }, {});
649
957
  }
650
958
  //#endregion
651
959
  //#region ../../node_modules/.pnpm/superjson@2.2.6/node_modules/superjson/dist/index.js
652
960
  var SuperJSON = class {
653
- constructor({ dedupe: e = !1 } = {}) {
654
- this.classRegistry = new ClassRegistry(), this.symbolRegistry = new Registry((e) => e.description ?? ""), this.customTransformerRegistry = new CustomTransformerRegistry(), this.allowedErrorProps = [], this.dedupe = e;
655
- }
656
- serialize(e) {
657
- let t = /* @__PURE__ */ new Map(), n = walker(e, t, this, this.dedupe), r = { json: n.transformedValue };
658
- n.annotations && (r.meta = {
659
- ...r.meta,
660
- values: n.annotations
661
- });
662
- let i = generateReferentialEqualityAnnotations(t, this.dedupe);
663
- return i && (r.meta = {
664
- ...r.meta,
665
- referentialEqualities: i
666
- }), r.meta && (r.meta.v = 1), r;
961
+ /**
962
+ * @param dedupeReferentialEqualities If true, SuperJSON will make sure only one instance of referentially equal objects are serialized and the rest are replaced with `null`.
963
+ */
964
+ constructor({ dedupe = false } = {}) {
965
+ this.classRegistry = new ClassRegistry();
966
+ this.symbolRegistry = new Registry((s) => s.description ?? "");
967
+ this.customTransformerRegistry = new CustomTransformerRegistry();
968
+ this.allowedErrorProps = [];
969
+ this.dedupe = dedupe;
667
970
  }
668
- deserialize(e, t) {
669
- let { json: n, meta: r } = e, i = t?.inPlace ? n : copy(n);
670
- return r?.values && (i = applyValueAnnotations(i, r.values, r.v ?? 0, this)), r?.referentialEqualities && (i = applyReferentialEqualityAnnotations(i, r.referentialEqualities, r.v ?? 0)), i;
971
+ serialize(object) {
972
+ const identities = /* @__PURE__ */ new Map();
973
+ const output = walker(object, identities, this, this.dedupe);
974
+ const res = { json: output.transformedValue };
975
+ if (output.annotations) res.meta = {
976
+ ...res.meta,
977
+ values: output.annotations
978
+ };
979
+ const equalityAnnotations = generateReferentialEqualityAnnotations(identities, this.dedupe);
980
+ if (equalityAnnotations) res.meta = {
981
+ ...res.meta,
982
+ referentialEqualities: equalityAnnotations
983
+ };
984
+ if (res.meta) res.meta.v = 1;
985
+ return res;
671
986
  }
672
- stringify(e) {
673
- return JSON.stringify(this.serialize(e));
987
+ deserialize(payload, options) {
988
+ const { json, meta } = payload;
989
+ let result = options?.inPlace ? json : copy(json);
990
+ if (meta?.values) result = applyValueAnnotations(result, meta.values, meta.v ?? 0, this);
991
+ if (meta?.referentialEqualities) result = applyReferentialEqualityAnnotations(result, meta.referentialEqualities, meta.v ?? 0);
992
+ return result;
674
993
  }
675
- parse(e) {
676
- return this.deserialize(JSON.parse(e), { inPlace: !0 });
994
+ stringify(object) {
995
+ return JSON.stringify(this.serialize(object));
677
996
  }
678
- registerClass(e, t) {
679
- this.classRegistry.register(e, t);
997
+ parse(string) {
998
+ return this.deserialize(JSON.parse(string), { inPlace: true });
680
999
  }
681
- registerSymbol(e, t) {
682
- this.symbolRegistry.register(e, t);
1000
+ registerClass(v, options) {
1001
+ this.classRegistry.register(v, options);
683
1002
  }
684
- registerCustom(e, t) {
1003
+ registerSymbol(v, identifier) {
1004
+ this.symbolRegistry.register(v, identifier);
1005
+ }
1006
+ registerCustom(transformer, name) {
685
1007
  this.customTransformerRegistry.register({
686
- name: t,
687
- ...e
1008
+ name,
1009
+ ...transformer
688
1010
  });
689
1011
  }
690
- allowErrorProps(...e) {
691
- this.allowedErrorProps.push(...e);
1012
+ allowErrorProps(...props) {
1013
+ this.allowedErrorProps.push(...props);
692
1014
  }
693
1015
  };
694
- 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;
695
- var ke = SuperJSON.stringify, Ae = SuperJSON.parse;
696
- SuperJSON.registerClass, SuperJSON.registerCustom, SuperJSON.registerSymbol, SuperJSON.allowErrorProps;
1016
+ SuperJSON.defaultInstance = new SuperJSON();
1017
+ SuperJSON.serialize = SuperJSON.defaultInstance.serialize.bind(SuperJSON.defaultInstance);
1018
+ SuperJSON.deserialize = SuperJSON.defaultInstance.deserialize.bind(SuperJSON.defaultInstance);
1019
+ SuperJSON.stringify = SuperJSON.defaultInstance.stringify.bind(SuperJSON.defaultInstance);
1020
+ SuperJSON.parse = SuperJSON.defaultInstance.parse.bind(SuperJSON.defaultInstance);
1021
+ SuperJSON.registerClass = SuperJSON.defaultInstance.registerClass.bind(SuperJSON.defaultInstance);
1022
+ SuperJSON.registerSymbol = SuperJSON.defaultInstance.registerSymbol.bind(SuperJSON.defaultInstance);
1023
+ SuperJSON.registerCustom = SuperJSON.defaultInstance.registerCustom.bind(SuperJSON.defaultInstance);
1024
+ SuperJSON.allowErrorProps = SuperJSON.defaultInstance.allowErrorProps.bind(SuperJSON.defaultInstance);
1025
+ SuperJSON.serialize;
1026
+ SuperJSON.deserialize;
1027
+ var stringify = SuperJSON.stringify;
1028
+ var parse = SuperJSON.parse;
1029
+ SuperJSON.registerClass;
1030
+ SuperJSON.registerCustom;
1031
+ SuperJSON.registerSymbol;
1032
+ SuperJSON.allowErrorProps;
697
1033
  //#endregion
698
1034
  //#region src/aichat/useChat.tsx
699
- function mapToNodeData(e) {
700
- return ({ id: t, data: n, ...r }) => {
701
- let i = n.icon ?? void 0;
702
- i === "none" && (i = void 0);
703
- let a = e.parentLookup.get(t)?.values().map((e) => e.id).toArray();
1035
+ function mapToNodeData(storeState) {
1036
+ return ({ id, data, ...node }) => {
1037
+ let icon = data.icon ?? void 0;
1038
+ if (icon === "none") icon = void 0;
1039
+ let children = storeState.parentLookup.get(id)?.values().map((child) => child.id).toArray();
704
1040
  return {
705
- id: t,
706
- title: n.title,
707
- shape: n.shape,
708
- color: n.color,
709
- icon: i,
710
- parentId: r.parentId,
711
- children: a,
712
- x: n.x,
713
- y: n.y,
714
- width: r.measured?.width ?? r.width ?? r.initialWidth ?? 0,
715
- height: r.measured?.height ?? r.height ?? r.initialHeight ?? 0,
716
- ..."modelFqn" in n && n.modelFqn && { modelFqn: n.modelFqn }
1041
+ id,
1042
+ title: data.title,
1043
+ shape: data.shape,
1044
+ color: data.color,
1045
+ icon,
1046
+ parentId: node.parentId,
1047
+ children,
1048
+ x: data.x,
1049
+ y: data.y,
1050
+ width: node.measured?.width ?? node.width ?? node.initialWidth ?? 0,
1051
+ height: node.measured?.height ?? node.height ?? node.initialHeight ?? 0,
1052
+ ..."modelFqn" in data && data.modelFqn && { modelFqn: data.modelFqn }
717
1053
  };
718
1054
  };
719
1055
  }
720
1056
  function useChatTools() {
721
- let e = F(11), { id: n } = f(), a = t(), o = d(), s;
722
- if (e[0] !== o || e[1] !== a || e[2] !== n) {
1057
+ const $ = c(11);
1058
+ const { id: projectId } = useCurrentProject();
1059
+ const navigate = useNavigate();
1060
+ const diagram = useDiagram();
1061
+ let t0;
1062
+ if ($[0] !== diagram || $[1] !== navigate || $[2] !== projectId) {
723
1063
  let t1;
724
- e[4] === a ? t1 = e[5] : (t1 = (e) => {
725
- let { viewId: t } = e;
726
- return a({
727
- to: "./",
728
- params: (e) => ({
729
- ...e,
730
- viewId: t
731
- })
732
- }), {};
733
- }, e[4] = a, e[5] = t1);
1064
+ if ($[4] !== navigate) {
1065
+ t1 = (t2) => {
1066
+ const { viewId } = t2;
1067
+ navigate({
1068
+ to: "./",
1069
+ params: (current) => ({
1070
+ ...current,
1071
+ viewId
1072
+ })
1073
+ });
1074
+ return {};
1075
+ };
1076
+ $[4] = navigate;
1077
+ $[5] = t1;
1078
+ } else t1 = $[5];
734
1079
  let t2;
735
- e[6] !== o || e[7] !== n ? (t2 = (e) => {
736
- let { view: t, focusedNode: a, xynodes: s, xystore: c, toggledFeatures: u, features: d } = o.getContext(), f = u.enableReadOnly ?? d.enableReadOnly, p = mapToNodeData(c.getState()), m = e.nodes === !0 && l(s, p) || void 0, h = e.selectedNode === !0 && r(s, i((e) => !!e.selected || e.id === a), (e) => e ? p(e) : void 0);
737
- return {
738
- projectId: n,
739
- editMode: !f,
740
- view: {
741
- id: t.id,
742
- title: t.title ?? "",
743
- type: t._type
744
- },
745
- ...m && { nodes: m },
746
- ...h && { selectedNode: h }
1080
+ if ($[6] !== diagram || $[7] !== projectId) {
1081
+ t2 = (params) => {
1082
+ const { view, focusedNode, xynodes, xystore, toggledFeatures, features } = diagram.getContext();
1083
+ const isReadOnly = toggledFeatures.enableReadOnly ?? features.enableReadOnly;
1084
+ const toNodeData = mapToNodeData(xystore.getState());
1085
+ const nodes = params.nodes === true && t(xynodes, toNodeData) || void 0;
1086
+ const selectedNode = params.selectedNode === true && t$1(xynodes, r((n) => !!n.selected || n.id === focusedNode), (n_0) => n_0 ? toNodeData(n_0) : void 0);
1087
+ return {
1088
+ projectId,
1089
+ editMode: !isReadOnly,
1090
+ view: {
1091
+ id: view.id,
1092
+ title: view.title ?? "",
1093
+ type: view._type
1094
+ },
1095
+ ...nodes && { nodes },
1096
+ ...selectedNode && { selectedNode }
1097
+ };
747
1098
  };
748
- }, e[6] = o, e[7] = n, e[8] = t2) : t2 = e[8];
1099
+ $[6] = diagram;
1100
+ $[7] = projectId;
1101
+ $[8] = t2;
1102
+ } else t2 = $[8];
749
1103
  let t3;
750
- e[9] === o ? t3 = e[10] : (t3 = (e) => {
751
- let { command: t } = e;
752
- bb50: switch (t.type) {
753
- case "focus":
754
- o.focusOnElement(t.elementId);
755
- break bb50;
756
- case "fitview":
757
- o.fitDiagram();
758
- break bb50;
759
- default: ve(t);
760
- }
761
- return {};
762
- }, e[9] = o, e[10] = t3), s = ue(Ee.client(t1), Se.client(t2), Te.client(t3)), e[0] = o, e[1] = a, e[2] = n, e[3] = s;
763
- } else s = e[3];
764
- return s;
1104
+ if ($[9] !== diagram) {
1105
+ t3 = (t4) => {
1106
+ const { command } = t4;
1107
+ bb50: switch (command.type) {
1108
+ case "focus":
1109
+ diagram.focusOnElement(command.elementId);
1110
+ break bb50;
1111
+ case "fitview":
1112
+ diagram.fitDiagram();
1113
+ break bb50;
1114
+ default: nonexhaustive(command);
1115
+ }
1116
+ return {};
1117
+ };
1118
+ $[9] = diagram;
1119
+ $[10] = t3;
1120
+ } else t3 = $[10];
1121
+ t0 = clientTools(navigateToDef.client(t1), readUiStateDef.client(t2), updateUiStateDef.client(t3));
1122
+ $[0] = diagram;
1123
+ $[1] = navigate;
1124
+ $[2] = projectId;
1125
+ $[3] = t0;
1126
+ } else t0 = $[3];
1127
+ return t0;
765
1128
  }
766
- var Q = {
1129
+ var storage$1 = {
767
1130
  key: "likec4.ai.chat.messages",
768
1131
  read() {
769
1132
  try {
770
- let e = sessionStorage.getItem(this.key);
771
- return e ? Ae(e) : [];
1133
+ const stored = sessionStorage.getItem(this.key);
1134
+ if (!stored) return [];
1135
+ return parse(stored);
772
1136
  } catch {
773
1137
  return [];
774
1138
  }
775
1139
  },
776
- write(e) {
1140
+ write(messages) {
777
1141
  try {
778
- if (e.length === 0) {
1142
+ if (messages.length === 0) {
779
1143
  sessionStorage.removeItem(this.key);
780
1144
  return;
781
1145
  }
782
- sessionStorage.setItem(this.key, ke(e));
1146
+ sessionStorage.setItem(this.key, stringify(messages));
783
1147
  } catch {}
784
1148
  }
785
1149
  };
786
- function useChat(e) {
787
- let t = F(7), n;
788
- t[0] === Symbol.for("react.memo_cache_sentinel") ? (n = {
789
- connection: ce("/__likec4_ai"),
790
- initialMessages: Q.read()
791
- }, t[0] = n) : n = t[0];
792
- let r = n, i = useChatTools(), a;
793
- t[1] !== e || t[2] !== i ? (a = {
794
- ...r,
795
- ...e,
796
- tools: i
797
- }, t[1] = e, t[2] = i, t[3] = a) : a = t[3];
798
- let o = le(a), t3, s;
799
- return t[4] === o.messages ? (t3 = t[5], s = t[6]) : (t3 = () => {
800
- Q.write(o.messages);
801
- }, s = [o.messages], t[4] = o.messages, t[5] = t3, t[6] = s), me(t3, s), o;
1150
+ function useChat(options) {
1151
+ const $ = c(7);
1152
+ let t0;
1153
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
1154
+ t0 = {
1155
+ connection: fetchServerSentEvents("/__likec4_ai"),
1156
+ initialMessages: storage$1.read()
1157
+ };
1158
+ $[0] = t0;
1159
+ } else t0 = $[0];
1160
+ const memoProps = t0;
1161
+ const t1 = useChatTools();
1162
+ let t2;
1163
+ if ($[1] !== options || $[2] !== t1) {
1164
+ t2 = {
1165
+ ...memoProps,
1166
+ ...options,
1167
+ tools: t1
1168
+ };
1169
+ $[1] = options;
1170
+ $[2] = t1;
1171
+ $[3] = t2;
1172
+ } else t2 = $[3];
1173
+ const chat = useChat$1(t2);
1174
+ let t3;
1175
+ let t4;
1176
+ if ($[4] !== chat.messages) {
1177
+ t3 = () => {
1178
+ storage$1.write(chat.messages);
1179
+ };
1180
+ t4 = [chat.messages];
1181
+ $[4] = chat.messages;
1182
+ $[5] = t3;
1183
+ $[6] = t4;
1184
+ } else {
1185
+ t3 = $[5];
1186
+ t4 = $[6];
1187
+ }
1188
+ useEffect(t3, t4);
1189
+ return chat;
802
1190
  }
803
1191
  //#endregion
804
1192
  //#region src/aichat/AIChat.tsx
805
- var $ = {
1193
+ var storage = {
806
1194
  key: "likec4.ai.chat.position",
807
1195
  read() {
808
1196
  try {
809
- let e = localStorage.getItem(this.key);
810
- return e ? JSON.parse(e) : null;
1197
+ const stored = localStorage.getItem(this.key);
1198
+ if (!stored) return null;
1199
+ return JSON.parse(stored);
811
1200
  } catch {
812
1201
  return null;
813
1202
  }
814
1203
  },
815
- write(e) {
1204
+ write(position) {
816
1205
  try {
817
- if (e === null) return localStorage.removeItem(this.key), e;
818
- localStorage.setItem(this.key, JSON.stringify(e));
1206
+ if (position === null) {
1207
+ localStorage.removeItem(this.key);
1208
+ return position;
1209
+ }
1210
+ localStorage.setItem(this.key, JSON.stringify(position));
819
1211
  } catch {}
820
- return e;
1212
+ return position;
821
1213
  }
822
1214
  };
823
1215
  function AIChatComponent() {
824
- let e = P(null);
825
- e.current ||= $.read() ?? {
1216
+ const initialPosition = useRef(null);
1217
+ if (!initialPosition.current) initialPosition.current = storage.read() ?? {
826
1218
  right: 16,
827
1219
  bottom: 100
828
1220
  };
829
- let onPositionChange = (t) => {
830
- e.current = $.write({
831
- left: t.x,
832
- top: t.y
1221
+ const onPositionChange = (pos) => {
1222
+ initialPosition.current = storage.write({
1223
+ left: pos.x,
1224
+ top: pos.y
833
1225
  });
834
- }, [t, n] = ne({
1226
+ };
1227
+ const [isCollapsed, setCollapsed] = useLocalStorage({
835
1228
  key: "likec4.ai.chat.collapsed",
836
- defaultValue: !0
1229
+ defaultValue: true
837
1230
  });
838
- return /* @__PURE__ */ R(I, { children: [/* @__PURE__ */ R(oe, { children: [!t && /* @__PURE__ */ L(v, {
1231
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs(AnimatePresence, { children: [!isCollapsed && /* @__PURE__ */ jsx(FloatingWindow, {
839
1232
  w: 300,
840
1233
  pos: "fixed",
841
- className: C({
1234
+ className: css({
842
1235
  rounded: "md",
843
1236
  padding: "xs",
844
1237
  shadow: "md",
845
1238
  layerStyle: "likec4.panel"
846
1239
  }),
847
- constrainToViewport: !0,
1240
+ constrainToViewport: true,
848
1241
  constrainOffset: 8,
849
1242
  excludeDragHandleSelector: ".chat-input",
850
- initialPosition: e.current,
1243
+ initialPosition: initialPosition.current,
851
1244
  onPositionChange,
852
- children: /* @__PURE__ */ L(AIChatWindowContent, { onClose: () => n(!0) })
853
- }), t && /* @__PURE__ */ L(ae.div, {
1245
+ children: /* @__PURE__ */ jsx(AIChatWindowContent, { onClose: () => setCollapsed(true) })
1246
+ }), isCollapsed && /* @__PURE__ */ jsx(m.div, {
854
1247
  initial: {
855
1248
  opacity: .1,
856
1249
  translateX: "10%"
@@ -869,83 +1262,131 @@ function AIChatComponent() {
869
1262
  bottom: 60,
870
1263
  zIndex: 1e3
871
1264
  },
872
- children: /* @__PURE__ */ L(ie, {
1265
+ children: /* @__PURE__ */ jsx(Tooltip, {
873
1266
  label: "Show AI Assistant",
874
1267
  color: "dark",
875
1268
  fz: "xs",
876
- children: /* @__PURE__ */ L(x, {
1269
+ children: /* @__PURE__ */ jsx(ActionIcon, {
877
1270
  size: "lg",
878
1271
  variant: "gradient",
879
- onClick: () => n(!1),
880
- children: /* @__PURE__ */ L(u, { stroke: 1.5 })
1272
+ onClick: () => setCollapsed(false),
1273
+ children: /* @__PURE__ */ jsx(IconSparkles, { stroke: 1.5 })
881
1274
  })
882
1275
  })
883
- }, "collapsed")] }), /* @__PURE__ */ L(SemanticLayoutLog, {})] });
1276
+ }, "collapsed")] }), /* @__PURE__ */ jsx(SemanticLayoutLog, {})] });
884
1277
  }
885
- function AIChatWindowContent(e) {
886
- let t = F(15), { onClose: r } = e, i = P(null), t1;
887
- t[0] === Symbol.for("react.memo_cache_sentinel") ? (t1 = () => {
888
- i.current?.scrollIntoView();
889
- }, t[0] = t1) : t1 = t[0];
890
- let a = t1, t2;
891
- t[1] === Symbol.for("react.memo_cache_sentinel") ? (t2 = () => {
892
- a();
893
- }, t[1] = t2) : t2 = t[1], n(t2, 100);
894
- let o;
895
- t[2] === Symbol.for("react.memo_cache_sentinel") ? (o = { onChunk: a }, t[2] = o) : o = t[2];
896
- let s = useChat(o), c;
897
- t[3] === Symbol.for("react.memo_cache_sentinel") ? (c = /* @__PURE__ */ R(S, { children: [/* @__PURE__ */ L(T, {
898
- textStyle: "likec4.panel",
899
- nouserselect: !0,
900
- children: "AI Assistant"
901
- }), /* @__PURE__ */ L(b, {
902
- size: "xs",
903
- radius: "sm",
904
- variant: "light",
905
- children: be
906
- })] }), t[3] = c) : c = t[3];
907
- let l;
908
- t[4] === r ? l = t[5] : (l = /* @__PURE__ */ R(S, {
909
- cursor: "move",
910
- justify: "space-between",
911
- children: [c, /* @__PURE__ */ L(te, {
912
- size: "sm",
913
- onClick: (e) => {
914
- e.stopPropagation(), r();
915
- }
916
- })]
917
- }), t[4] = r, t[5] = l);
918
- let u;
919
- t[6] === Symbol.for("react.memo_cache_sentinel") ? (u = { content: C({ display: "contents" }) }, t[6] = u) : u = t[6];
920
- let d;
921
- t[7] === Symbol.for("react.memo_cache_sentinel") ? (d = /* @__PURE__ */ L(ChatMessages, {}), t[7] = d) : d = t[7];
922
- let f, p;
923
- t[8] === Symbol.for("react.memo_cache_sentinel") ? (f = /* @__PURE__ */ L(h, {
924
- scrollbars: "y",
925
- w: "100%",
926
- flex: 1,
927
- mih: 250,
928
- mah: 350,
929
- classNames: u,
930
- children: /* @__PURE__ */ R(w, { children: [d, /* @__PURE__ */ L("div", {
931
- ref: i,
932
- style: { height: 2 }
933
- })] })
934
- }), p = /* @__PURE__ */ L(ChatInput, {}), t[8] = f, t[9] = p) : (f = t[8], p = t[9]);
935
- let m;
936
- t[10] === l ? m = t[11] : (m = /* @__PURE__ */ R(w, {
937
- w: "100%",
938
- children: [
939
- l,
940
- f,
941
- p
942
- ]
943
- }), t[10] = l, t[11] = m);
944
- let g;
945
- return t[12] !== s || t[13] !== m ? (g = /* @__PURE__ */ L(z, {
946
- value: s,
947
- children: m
948
- }), t[12] = s, t[13] = m, t[14] = g) : g = t[14], g;
1278
+ function AIChatWindowContent(t0) {
1279
+ const $ = c(15);
1280
+ const { onClose } = t0;
1281
+ const scrollAnchorRef = useRef(null);
1282
+ let t1;
1283
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
1284
+ t1 = () => {
1285
+ scrollAnchorRef.current?.scrollIntoView();
1286
+ };
1287
+ $[0] = t1;
1288
+ } else t1 = $[0];
1289
+ const scrollIntoView = t1;
1290
+ let t2;
1291
+ if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
1292
+ t2 = () => {
1293
+ scrollIntoView();
1294
+ };
1295
+ $[1] = t2;
1296
+ } else t2 = $[1];
1297
+ useTimeoutEffect(t2, 100);
1298
+ let t3;
1299
+ if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
1300
+ t3 = { onChunk: scrollIntoView };
1301
+ $[2] = t3;
1302
+ } else t3 = $[2];
1303
+ const chat = useChat(t3);
1304
+ let t4;
1305
+ if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
1306
+ t4 = /* @__PURE__ */ jsxs(HStack, { children: [/* @__PURE__ */ jsx(Txt, {
1307
+ textStyle: "likec4.panel",
1308
+ nouserselect: true,
1309
+ children: "AI Assistant"
1310
+ }), /* @__PURE__ */ jsx(Badge, {
1311
+ size: "xs",
1312
+ radius: "sm",
1313
+ variant: "light",
1314
+ children: AIAdapter
1315
+ })] });
1316
+ $[3] = t4;
1317
+ } else t4 = $[3];
1318
+ let t5;
1319
+ if ($[4] !== onClose) {
1320
+ t5 = /* @__PURE__ */ jsxs(HStack, {
1321
+ cursor: "move",
1322
+ justify: "space-between",
1323
+ children: [t4, /* @__PURE__ */ jsx(CloseButton, {
1324
+ size: "sm",
1325
+ onClick: (e) => {
1326
+ e.stopPropagation();
1327
+ onClose();
1328
+ }
1329
+ })]
1330
+ });
1331
+ $[4] = onClose;
1332
+ $[5] = t5;
1333
+ } else t5 = $[5];
1334
+ let t6;
1335
+ if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
1336
+ t6 = { content: css({ display: "contents" }) };
1337
+ $[6] = t6;
1338
+ } else t6 = $[6];
1339
+ let t7;
1340
+ if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
1341
+ t7 = /* @__PURE__ */ jsx(ChatMessages, {});
1342
+ $[7] = t7;
1343
+ } else t7 = $[7];
1344
+ let t8;
1345
+ let t9;
1346
+ if ($[8] === Symbol.for("react.memo_cache_sentinel")) {
1347
+ t8 = /* @__PURE__ */ jsx(ScrollAreaAutosize, {
1348
+ scrollbars: "y",
1349
+ w: "100%",
1350
+ flex: 1,
1351
+ mih: 250,
1352
+ mah: 350,
1353
+ classNames: t6,
1354
+ children: /* @__PURE__ */ jsxs(VStack, { children: [t7, /* @__PURE__ */ jsx("div", {
1355
+ ref: scrollAnchorRef,
1356
+ style: { height: 2 }
1357
+ })] })
1358
+ });
1359
+ t9 = /* @__PURE__ */ jsx(ChatInput, {});
1360
+ $[8] = t8;
1361
+ $[9] = t9;
1362
+ } else {
1363
+ t8 = $[8];
1364
+ t9 = $[9];
1365
+ }
1366
+ let t10;
1367
+ if ($[10] !== t5) {
1368
+ t10 = /* @__PURE__ */ jsxs(VStack, {
1369
+ w: "100%",
1370
+ children: [
1371
+ t5,
1372
+ t8,
1373
+ t9
1374
+ ]
1375
+ });
1376
+ $[10] = t5;
1377
+ $[11] = t10;
1378
+ } else t10 = $[11];
1379
+ let t11;
1380
+ if ($[12] !== chat || $[13] !== t10) {
1381
+ t11 = /* @__PURE__ */ jsx(ChatContext, {
1382
+ value: chat,
1383
+ children: t10
1384
+ });
1385
+ $[12] = chat;
1386
+ $[13] = t10;
1387
+ $[14] = t11;
1388
+ } else t11 = $[14];
1389
+ return t11;
949
1390
  }
950
1391
  //#endregion
951
1392
  export { AIChatComponent as default };