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.
- package/__app__/codegen/react.mjs +6 -6
- package/__app__/codegen/webcomponent.mjs +147 -69
- package/__app__/src/aichat/index.mjs +10 -5
- package/__app__/src/chunks/AIChat.mjs +1134 -693
- package/__app__/src/chunks/LikeC4Styles.mjs +3995 -1779
- package/__app__/src/chunks/ProjectsOverview.mjs +624 -334
- package/__app__/src/chunks/es.mjs +515 -335
- package/__app__/src/chunks/hooks.mjs +578 -369
- package/__app__/src/chunks/libs/@floating-ui.mjs +2720 -1966
- package/__app__/src/chunks/libs/@mantine.mjs +13920 -10057
- package/__app__/src/chunks/libs/@tanstack-ai.mjs +2266 -1146
- package/__app__/src/chunks/libs/@tanstack.mjs +3152 -1926
- package/__app__/src/chunks/libs/@xstate/react.mjs +2924 -1468
- package/__app__/src/chunks/libs/@xyflow/react.mjs +6627 -4067
- package/__app__/src/chunks/libs/bezier-js.mjs +1312 -726
- package/__app__/src/chunks/libs/d3.mjs +3219 -1505
- package/__app__/src/chunks/libs/fast-equals.mjs +434 -210
- package/__app__/src/chunks/libs/framer.mjs +9251 -3846
- package/__app__/src/chunks/libs/nanostores.mjs +174 -0
- package/__app__/src/chunks/libs/zod.mjs +4591 -2363
- package/__app__/src/chunks/rolldown-runtime.mjs +39 -23
- package/__app__/src/chunks/styled-system.mjs +2279 -1951
- package/__app__/src/fonts.css +112 -1
- package/__app__/src/main.mjs +40817 -21840
- package/__app__/src/style.css +18488 -1
- package/config/schema.json +122 -97
- package/dist/app/render-view-client.css +1 -1
- package/dist/app/render-view-client.js +508 -334
- package/dist/chunks/enableServer.mjs +1 -1
- package/dist/chunks/filenames.mjs +11 -9
- package/dist/chunks/generate-likec4.mjs +5 -0
- package/dist/chunks/index.d.mts +243 -183
- package/dist/chunks/index2.d.mts +2865 -1977
- package/dist/chunks/libs/@chevrotain/gast.mjs +27 -1
- package/dist/chunks/libs/@chevrotain/regexp-to-ast.mjs +81 -9
- package/dist/chunks/libs/@chevrotain/types.d.mts +4 -1
- package/dist/chunks/libs/@logtape/logtape.mjs +5 -4
- package/dist/chunks/libs/@lume/kiwi.mjs +1 -1
- package/dist/chunks/libs/@ts-graphviz/core.mjs +1 -1
- package/dist/chunks/libs/birpc.mjs +1 -1
- package/dist/chunks/libs/chevrotain-allstar.mjs +2 -2
- package/dist/chunks/libs/chevrotain.mjs +87 -35
- package/dist/chunks/libs/eventemitter3.mjs +1 -1
- package/dist/chunks/libs/json5.mjs +4 -4
- package/dist/chunks/libs/langium.d.mts +9038 -6193
- package/dist/chunks/libs/langium.mjs +16 -24
- package/dist/chunks/libs/merge-error-cause.mjs +1 -1
- package/dist/chunks/libs/p-limit.mjs +1 -0
- package/dist/chunks/libs/p-queue.mjs +1 -1
- package/dist/chunks/libs/package-manager-detector.mjs +1 -1
- package/dist/chunks/libs/pako.mjs +1 -1
- package/dist/chunks/libs/pretty-ms.mjs +1 -1
- package/dist/chunks/libs/remeda.mjs +1 -1
- package/dist/chunks/libs/ufo.mjs +1 -1
- package/dist/chunks/libs/unstorage.mjs +1 -1
- package/dist/chunks/libs/which.mjs +1 -1
- package/dist/chunks/node.mjs +59 -58
- package/dist/chunks/rolldown-runtime.mjs +1 -1
- package/dist/chunks/sequence-view.mjs +1 -1
- package/dist/chunks/vite-plugin.mjs +45 -45
- package/dist/cli/index.mjs +207 -1315
- package/dist/config/index.d.mts +2 -2
- package/dist/generators/likec4.d.mts +6578 -0
- package/dist/generators/likec4.mjs +1 -0
- package/dist/model/index.d.mts +4 -1
- package/dist/vite-plugin/index.d.mts +4 -1
- package/dist/vite-plugin/index.mjs +1 -1
- package/dist/vite-plugin/internal/chunks/rolldown-runtime.mjs +9 -0
- package/dist/vite-plugin/internal/index.d.mts +6 -5
- package/dist/vite-plugin/internal/index.mjs +83 -30
- package/generators/likec4/package.json +4 -0
- package/package.json +113 -106
- package/react/index.d.mts +8500 -26659
- package/react/index.mjs +534 -63936
- package/react/rolldown-runtime-DnkiqaRY.js +1 -0
- package/skills/likec4-dsl/SKILL.md +428 -0
- package/skills/likec4-dsl/evals/evals-public.json +202 -0
- package/skills/likec4-dsl/evals/grading-spec.json +589 -0
- package/skills/likec4-dsl/references/bridge-leanix-drawio.md +42 -0
- package/skills/likec4-dsl/references/cli.md +139 -0
- package/skills/likec4-dsl/references/configuration.md +266 -0
- package/skills/likec4-dsl/references/deployment.md +160 -0
- package/skills/likec4-dsl/references/dynamic-views.md +455 -0
- package/skills/likec4-dsl/references/examples.md +370 -0
- package/skills/likec4-dsl/references/identifier-validity.md +90 -0
- package/skills/likec4-dsl/references/include-predicates-wildcards.md +179 -0
- package/skills/likec4-dsl/references/model.md +151 -0
- package/skills/likec4-dsl/references/predicates.md +123 -0
- package/skills/likec4-dsl/references/relationships-bidirectional.md +176 -0
- package/skills/likec4-dsl/references/specification.md +75 -0
- package/skills/likec4-dsl/references/style-tokens-colors.md +150 -0
- package/skills/likec4-dsl/references/troubleshooting.md +96 -0
- package/skills/likec4-dsl/references/views.md +329 -0
- package/dist/chunks/libs/picomatch.mjs +0 -1
- package/dist/chunks/libs/zod.d.mts +0 -3840
- package/dist/chunks/libs/zod.mjs +0 -65
|
@@ -1,309 +1,475 @@
|
|
|
1
|
-
import { i as
|
|
2
|
-
import { c as
|
|
3
|
-
import {
|
|
4
|
-
import { At as
|
|
5
|
-
import { C as
|
|
6
|
-
import { i as
|
|
7
|
-
import {
|
|
8
|
-
import { a as
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
if (
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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
|
-
}
|
|
30
|
-
|
|
31
|
-
let
|
|
32
|
-
|
|
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
|
-
|
|
35
|
-
let
|
|
36
|
-
|
|
37
|
-
|
|
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
|
-
})
|
|
40
|
-
|
|
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
|
|
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
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
let
|
|
52
|
-
|
|
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
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
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
|
-
|
|
97
|
-
|
|
98
|
-
let
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
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(
|
|
116
|
-
return /* @__PURE__ */
|
|
198
|
+
function _temp(message) {
|
|
199
|
+
return /* @__PURE__ */ jsx(ChatMessage, { message }, message.id);
|
|
117
200
|
}
|
|
118
|
-
var ChatMessage = (
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
let
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
|
|
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
|
|
273
|
+
return useStore($state);
|
|
153
274
|
}
|
|
154
275
|
function closeSemanticLayoutLog() {
|
|
155
|
-
|
|
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
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
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
|
|
187
|
-
id:
|
|
188
|
-
title:
|
|
189
|
-
shape:
|
|
190
|
-
color:
|
|
191
|
-
icon:
|
|
192
|
-
parentId:
|
|
193
|
-
children:
|
|
194
|
-
x:
|
|
195
|
-
y:
|
|
196
|
-
width:
|
|
197
|
-
height:
|
|
198
|
-
modelFqn:
|
|
199
|
-
})
|
|
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:
|
|
203
|
-
inputSchema:
|
|
204
|
-
selectedNode:
|
|
205
|
-
nodes:
|
|
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:
|
|
208
|
-
projectId:
|
|
209
|
-
editMode:
|
|
210
|
-
view:
|
|
211
|
-
id:
|
|
212
|
-
title:
|
|
213
|
-
type:
|
|
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:
|
|
220
|
-
selectedNode:
|
|
362
|
+
nodes: array(nodeSchema).nullish(),
|
|
363
|
+
selectedNode: nodeSchema.nullish()
|
|
221
364
|
})
|
|
222
|
-
})
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
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:
|
|
229
|
-
inputSchema:
|
|
230
|
-
outputSchema:
|
|
231
|
-
})
|
|
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:
|
|
235
|
-
inputSchema:
|
|
236
|
-
outputSchema:
|
|
237
|
-
})
|
|
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()
|
|
389
|
+
this.keyToValue = /* @__PURE__ */ new Map();
|
|
390
|
+
this.valueToKey = /* @__PURE__ */ new Map();
|
|
240
391
|
}
|
|
241
|
-
set(
|
|
242
|
-
this.keyToValue.set(
|
|
392
|
+
set(key, value) {
|
|
393
|
+
this.keyToValue.set(key, value);
|
|
394
|
+
this.valueToKey.set(value, key);
|
|
243
395
|
}
|
|
244
|
-
getByKey(
|
|
245
|
-
return this.keyToValue.get(
|
|
396
|
+
getByKey(key) {
|
|
397
|
+
return this.keyToValue.get(key);
|
|
246
398
|
}
|
|
247
|
-
getByValue(
|
|
248
|
-
return this.valueToKey.get(
|
|
399
|
+
getByValue(value) {
|
|
400
|
+
return this.valueToKey.get(value);
|
|
249
401
|
}
|
|
250
402
|
clear() {
|
|
251
|
-
this.keyToValue.clear()
|
|
403
|
+
this.keyToValue.clear();
|
|
404
|
+
this.valueToKey.clear();
|
|
252
405
|
}
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
|
|
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(
|
|
258
|
-
this.kv.getByValue(
|
|
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(
|
|
264
|
-
return this.kv.getByValue(
|
|
422
|
+
getIdentifier(value) {
|
|
423
|
+
return this.kv.getByValue(value);
|
|
265
424
|
}
|
|
266
|
-
getValue(
|
|
267
|
-
return this.kv.getByKey(
|
|
425
|
+
getValue(identifier) {
|
|
426
|
+
return this.kv.getByKey(identifier);
|
|
268
427
|
}
|
|
269
|
-
}
|
|
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((
|
|
433
|
+
super((c) => c.name);
|
|
434
|
+
this.classToAllowedProps = /* @__PURE__ */ new Map();
|
|
272
435
|
}
|
|
273
|
-
register(
|
|
274
|
-
typeof
|
|
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(
|
|
277
|
-
return this.classToAllowedProps.get(
|
|
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(
|
|
283
|
-
if ("values" in Object) return Object.values(
|
|
284
|
-
|
|
285
|
-
for (
|
|
286
|
-
return
|
|
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(
|
|
289
|
-
|
|
290
|
-
if ("find" in
|
|
291
|
-
|
|
292
|
-
for (let
|
|
293
|
-
|
|
294
|
-
if (
|
|
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(
|
|
298
|
-
Object.entries(
|
|
463
|
+
function forEach(record, run) {
|
|
464
|
+
Object.entries(record).forEach(([key, value]) => run(value, key));
|
|
299
465
|
}
|
|
300
|
-
function includes(
|
|
301
|
-
return
|
|
466
|
+
function includes(arr, value) {
|
|
467
|
+
return arr.indexOf(value) !== -1;
|
|
302
468
|
}
|
|
303
|
-
function findArr(
|
|
304
|
-
for (let
|
|
305
|
-
|
|
306
|
-
if (
|
|
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(
|
|
316
|
-
this.transfomers[
|
|
481
|
+
register(transformer) {
|
|
482
|
+
this.transfomers[transformer.name] = transformer;
|
|
317
483
|
}
|
|
318
|
-
findApplicable(
|
|
319
|
-
return find(this.transfomers, (
|
|
484
|
+
findApplicable(v) {
|
|
485
|
+
return find(this.transfomers, (transformer) => transformer.isApplicable(v));
|
|
320
486
|
}
|
|
321
|
-
findByName(
|
|
322
|
-
return this.transfomers[
|
|
487
|
+
findByName(name) {
|
|
488
|
+
return this.transfomers[name];
|
|
323
489
|
}
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
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 (
|
|
337
|
-
|
|
536
|
+
if (char === "\\" && string.charAt(i + 1) === ".") {
|
|
537
|
+
segment += ".";
|
|
538
|
+
i++;
|
|
338
539
|
continue;
|
|
339
540
|
}
|
|
340
|
-
if (
|
|
341
|
-
|
|
541
|
+
if (char === ".") {
|
|
542
|
+
result.push(segment);
|
|
543
|
+
segment = "";
|
|
342
544
|
continue;
|
|
343
545
|
}
|
|
344
|
-
|
|
546
|
+
segment += char;
|
|
345
547
|
}
|
|
346
|
-
|
|
347
|
-
|
|
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(
|
|
554
|
+
function simpleTransformation(isApplicable, annotation, transform, untransform) {
|
|
352
555
|
return {
|
|
353
|
-
isApplicable
|
|
354
|
-
annotation
|
|
355
|
-
transform
|
|
356
|
-
untransform
|
|
556
|
+
isApplicable,
|
|
557
|
+
annotation,
|
|
558
|
+
transform,
|
|
559
|
+
untransform
|
|
357
560
|
};
|
|
358
561
|
}
|
|
359
|
-
var
|
|
562
|
+
var simpleRules = [
|
|
360
563
|
simpleTransformation(isUndefined, "undefined", () => null, () => void 0),
|
|
361
|
-
simpleTransformation(isBigint, "bigint", (
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
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
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
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", (
|
|
378
|
-
|
|
379
|
-
|
|
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", (
|
|
382
|
-
simpleTransformation(isMap, "map", (
|
|
383
|
-
simpleTransformation((
|
|
384
|
-
|
|
385
|
-
|
|
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(
|
|
606
|
+
function compositeTransformation(isApplicable, annotation, transform, untransform) {
|
|
388
607
|
return {
|
|
389
|
-
isApplicable
|
|
390
|
-
annotation
|
|
391
|
-
transform
|
|
392
|
-
untransform
|
|
608
|
+
isApplicable,
|
|
609
|
+
annotation,
|
|
610
|
+
transform,
|
|
611
|
+
untransform
|
|
393
612
|
};
|
|
394
613
|
}
|
|
395
|
-
var
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
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((
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
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(
|
|
415
|
-
|
|
643
|
+
function isInstanceOfRegisteredClass(potentialClass, superJson) {
|
|
644
|
+
if (potentialClass?.constructor) return !!superJson.classRegistry.getIdentifier(potentialClass.constructor);
|
|
645
|
+
return false;
|
|
416
646
|
}
|
|
417
|
-
var
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
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
|
-
|
|
444
|
-
if (
|
|
445
|
-
value:
|
|
446
|
-
type:
|
|
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
|
-
}
|
|
449
|
-
|
|
450
|
-
|
|
690
|
+
};
|
|
691
|
+
var simpleRulesByAnnotation = {};
|
|
692
|
+
simpleRules.forEach((rule) => {
|
|
693
|
+
simpleRulesByAnnotation[rule.annotation] = rule;
|
|
451
694
|
});
|
|
452
|
-
var untransformValue = (
|
|
453
|
-
if (
|
|
454
|
-
case "symbol": return
|
|
455
|
-
case "class": return
|
|
456
|
-
case "custom": return
|
|
457
|
-
case "typed-array": return
|
|
458
|
-
default: throw Error("Unknown transformation: " +
|
|
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
|
-
|
|
462
|
-
if (!
|
|
463
|
-
return
|
|
464
|
-
}
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
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(
|
|
472
|
-
if (includes(
|
|
473
|
-
if (includes(
|
|
474
|
-
if (includes(
|
|
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 = (
|
|
477
|
-
validatePath(
|
|
478
|
-
for (let
|
|
479
|
-
|
|
480
|
-
if (isSet(
|
|
481
|
-
else if (isMap(
|
|
482
|
-
|
|
483
|
-
|
|
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
|
-
|
|
736
|
+
object = keyOfRow;
|
|
486
737
|
break;
|
|
487
|
-
case "value":
|
|
738
|
+
case "value": object = object.get(keyOfRow);
|
|
488
739
|
}
|
|
489
|
-
} else
|
|
490
|
-
}
|
|
491
|
-
return
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
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
|
-
|
|
764
|
+
parent = keyOfRow;
|
|
510
765
|
break;
|
|
511
|
-
case "value":
|
|
766
|
+
case "value": parent = parent.get(keyOfRow);
|
|
512
767
|
}
|
|
513
768
|
}
|
|
514
769
|
}
|
|
515
|
-
|
|
516
|
-
if (
|
|
517
|
-
|
|
518
|
-
|
|
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(
|
|
521
|
-
|
|
522
|
-
|
|
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
|
-
|
|
525
|
-
|
|
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":
|
|
791
|
+
case "value": parent.set(keyToRow, mapper(parent.get(keyToRow)));
|
|
529
792
|
}
|
|
530
793
|
}
|
|
531
|
-
return
|
|
532
|
-
}
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
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
|
-
|
|
541
|
-
|
|
542
|
-
traverse(
|
|
543
|
-
})
|
|
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(
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
},
|
|
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(
|
|
551
|
-
|
|
552
|
-
function apply(
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
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 (
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
})
|
|
563
|
-
|
|
564
|
-
|
|
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 = (
|
|
567
|
-
function addIdentity(
|
|
568
|
-
|
|
569
|
-
|
|
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(
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
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 = (
|
|
581
|
-
|
|
582
|
-
if (!
|
|
583
|
-
addIdentity(
|
|
584
|
-
|
|
585
|
-
if (
|
|
586
|
-
}
|
|
587
|
-
if (!isDeep(
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
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
|
-
|
|
604
|
-
transformedValue
|
|
605
|
-
annotations:
|
|
886
|
+
const result = isEmptyObject(innerAnnotations) ? {
|
|
887
|
+
transformedValue,
|
|
888
|
+
annotations: !!transformationResult ? [transformationResult.type] : void 0
|
|
606
889
|
} : {
|
|
607
|
-
transformedValue
|
|
608
|
-
annotations:
|
|
890
|
+
transformedValue,
|
|
891
|
+
annotations: !!transformationResult ? [transformationResult.type, innerAnnotations] : innerAnnotations
|
|
609
892
|
};
|
|
610
|
-
|
|
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
|
-
|
|
615
|
-
|
|
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
|
-
|
|
620
|
-
|
|
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
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
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(
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
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
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
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
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
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
|
-
|
|
669
|
-
|
|
670
|
-
|
|
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
|
-
|
|
673
|
-
|
|
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
|
-
|
|
676
|
-
return
|
|
994
|
+
stringify(object) {
|
|
995
|
+
return JSON.stringify(this.serialize(object));
|
|
677
996
|
}
|
|
678
|
-
|
|
679
|
-
this.
|
|
997
|
+
parse(string) {
|
|
998
|
+
return this.deserialize(JSON.parse(string), { inPlace: true });
|
|
680
999
|
}
|
|
681
|
-
|
|
682
|
-
this.
|
|
1000
|
+
registerClass(v, options) {
|
|
1001
|
+
this.classRegistry.register(v, options);
|
|
683
1002
|
}
|
|
684
|
-
|
|
1003
|
+
registerSymbol(v, identifier) {
|
|
1004
|
+
this.symbolRegistry.register(v, identifier);
|
|
1005
|
+
}
|
|
1006
|
+
registerCustom(transformer, name) {
|
|
685
1007
|
this.customTransformerRegistry.register({
|
|
686
|
-
name
|
|
687
|
-
...
|
|
1008
|
+
name,
|
|
1009
|
+
...transformer
|
|
688
1010
|
});
|
|
689
1011
|
}
|
|
690
|
-
allowErrorProps(...
|
|
691
|
-
this.allowedErrorProps.push(...
|
|
1012
|
+
allowErrorProps(...props) {
|
|
1013
|
+
this.allowedErrorProps.push(...props);
|
|
692
1014
|
}
|
|
693
1015
|
};
|
|
694
|
-
SuperJSON.defaultInstance = new SuperJSON()
|
|
695
|
-
|
|
696
|
-
SuperJSON.
|
|
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(
|
|
700
|
-
return ({ id
|
|
701
|
-
let
|
|
702
|
-
|
|
703
|
-
let
|
|
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
|
|
706
|
-
title:
|
|
707
|
-
shape:
|
|
708
|
-
color:
|
|
709
|
-
icon
|
|
710
|
-
parentId:
|
|
711
|
-
children
|
|
712
|
-
x:
|
|
713
|
-
y:
|
|
714
|
-
width:
|
|
715
|
-
height:
|
|
716
|
-
..."modelFqn" in
|
|
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
|
-
|
|
722
|
-
|
|
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
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
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
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
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
|
-
|
|
1099
|
+
$[6] = diagram;
|
|
1100
|
+
$[7] = projectId;
|
|
1101
|
+
$[8] = t2;
|
|
1102
|
+
} else t2 = $[8];
|
|
749
1103
|
let t3;
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
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
|
|
1129
|
+
var storage$1 = {
|
|
767
1130
|
key: "likec4.ai.chat.messages",
|
|
768
1131
|
read() {
|
|
769
1132
|
try {
|
|
770
|
-
|
|
771
|
-
|
|
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(
|
|
1140
|
+
write(messages) {
|
|
777
1141
|
try {
|
|
778
|
-
if (
|
|
1142
|
+
if (messages.length === 0) {
|
|
779
1143
|
sessionStorage.removeItem(this.key);
|
|
780
1144
|
return;
|
|
781
1145
|
}
|
|
782
|
-
sessionStorage.setItem(this.key,
|
|
1146
|
+
sessionStorage.setItem(this.key, stringify(messages));
|
|
783
1147
|
} catch {}
|
|
784
1148
|
}
|
|
785
1149
|
};
|
|
786
|
-
function useChat(
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
let
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
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
|
-
|
|
810
|
-
|
|
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(
|
|
1204
|
+
write(position) {
|
|
816
1205
|
try {
|
|
817
|
-
if (
|
|
818
|
-
|
|
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
|
|
1212
|
+
return position;
|
|
821
1213
|
}
|
|
822
1214
|
};
|
|
823
1215
|
function AIChatComponent() {
|
|
824
|
-
|
|
825
|
-
|
|
1216
|
+
const initialPosition = useRef(null);
|
|
1217
|
+
if (!initialPosition.current) initialPosition.current = storage.read() ?? {
|
|
826
1218
|
right: 16,
|
|
827
1219
|
bottom: 100
|
|
828
1220
|
};
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
left:
|
|
832
|
-
top:
|
|
1221
|
+
const onPositionChange = (pos) => {
|
|
1222
|
+
initialPosition.current = storage.write({
|
|
1223
|
+
left: pos.x,
|
|
1224
|
+
top: pos.y
|
|
833
1225
|
});
|
|
834
|
-
}
|
|
1226
|
+
};
|
|
1227
|
+
const [isCollapsed, setCollapsed] = useLocalStorage({
|
|
835
1228
|
key: "likec4.ai.chat.collapsed",
|
|
836
|
-
defaultValue:
|
|
1229
|
+
defaultValue: true
|
|
837
1230
|
});
|
|
838
|
-
return /* @__PURE__ */
|
|
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:
|
|
1234
|
+
className: css({
|
|
842
1235
|
rounded: "md",
|
|
843
1236
|
padding: "xs",
|
|
844
1237
|
shadow: "md",
|
|
845
1238
|
layerStyle: "likec4.panel"
|
|
846
1239
|
}),
|
|
847
|
-
constrainToViewport:
|
|
1240
|
+
constrainToViewport: true,
|
|
848
1241
|
constrainOffset: 8,
|
|
849
1242
|
excludeDragHandleSelector: ".chat-input",
|
|
850
|
-
initialPosition:
|
|
1243
|
+
initialPosition: initialPosition.current,
|
|
851
1244
|
onPositionChange,
|
|
852
|
-
children: /* @__PURE__ */
|
|
853
|
-
}),
|
|
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__ */
|
|
1265
|
+
children: /* @__PURE__ */ jsx(Tooltip, {
|
|
873
1266
|
label: "Show AI Assistant",
|
|
874
1267
|
color: "dark",
|
|
875
1268
|
fz: "xs",
|
|
876
|
-
children: /* @__PURE__ */
|
|
1269
|
+
children: /* @__PURE__ */ jsx(ActionIcon, {
|
|
877
1270
|
size: "lg",
|
|
878
1271
|
variant: "gradient",
|
|
879
|
-
onClick: () =>
|
|
880
|
-
children: /* @__PURE__ */
|
|
1272
|
+
onClick: () => setCollapsed(false),
|
|
1273
|
+
children: /* @__PURE__ */ jsx(IconSparkles, { stroke: 1.5 })
|
|
881
1274
|
})
|
|
882
1275
|
})
|
|
883
|
-
}, "collapsed")] }), /* @__PURE__ */
|
|
1276
|
+
}, "collapsed")] }), /* @__PURE__ */ jsx(SemanticLayoutLog, {})] });
|
|
884
1277
|
}
|
|
885
|
-
function AIChatWindowContent(
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
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 };
|