@athenaintel/react 0.13.0 → 0.15.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/dist/chat/ComposerEditorContext.d.ts +6 -0
- package/dist/chat-ui/auth/sign-in-card.d.ts +57 -0
- package/dist/chat-ui/composer/composer-action.d.ts +12 -0
- package/dist/chat-ui/composer/pending-attachment-uploads.d.ts +5 -0
- package/dist/chat-ui/composer/tiptap-composer.d.ts +35 -0
- package/dist/chat-ui/index.d.ts +34 -0
- package/dist/chat-ui/lib/asset-urls.d.ts +6 -0
- package/dist/chat-ui/mentions/mention-chip.d.ts +38 -0
- package/dist/chat-ui/mentions/mention-extension.d.ts +35 -0
- package/dist/chat-ui/mentions/suggestions/components/get-scope-name.d.ts +15 -0
- package/dist/chat-ui/mentions/suggestions/components/mention-icon.d.ts +10 -0
- package/dist/chat-ui/mentions/suggestions/components/mention-suggestion-list.d.ts +22 -0
- package/dist/chat-ui/mentions/suggestions/components/mention-suggestion-popup.d.ts +9 -0
- package/dist/chat-ui/mentions/suggestions/components/menu-breadcrumbs.d.ts +10 -0
- package/dist/chat-ui/mentions/suggestions/components/menu-item.d.ts +12 -0
- package/dist/chat-ui/mentions/suggestions/components/menu-list.d.ts +13 -0
- package/dist/chat-ui/mentions/suggestions/components/menu-skeleton.d.ts +4 -0
- package/dist/chat-ui/mentions/suggestions/components/menu-summary.d.ts +13 -0
- package/dist/chat-ui/mentions/suggestions/components/use-keyboard-navigation.d.ts +19 -0
- package/dist/chat-ui/mentions/suggestions/components/use-menu-navigation.d.ts +64 -0
- package/dist/chat-ui/mentions/suggestions/components/utils.d.ts +8 -0
- package/dist/chat-ui/mentions/suggestions/data/api-client.d.ts +41 -0
- package/dist/chat-ui/mentions/suggestions/data/item-cache.d.ts +76 -0
- package/dist/chat-ui/mentions/suggestions/data/orchestrator.d.ts +29 -0
- package/dist/chat-ui/mentions/suggestions/data/scope-registry.d.ts +105 -0
- package/dist/chat-ui/mentions/suggestions/data/sources/asset-type-icons.d.ts +25 -0
- package/dist/chat-ui/mentions/suggestions/data/sources/index.d.ts +59 -0
- package/dist/chat-ui/mentions/suggestions/data/types.d.ts +156 -0
- package/dist/chat-ui/mentions/suggestions/data/use-mention-suggestions.d.ts +37 -0
- package/dist/chat-ui/mentions/suggestions/data/use-menu-items.d.ts +34 -0
- package/dist/chat-ui/mentions/suggestions/data/utils/filter-items.d.ts +13 -0
- package/dist/chat-ui/mentions/suggestions/data/utils/match-query.d.ts +5 -0
- package/dist/chat-ui/mentions/suggestions/data/utils/score-match.d.ts +5 -0
- package/dist/chat-ui/mentions/suggestions/mention-suggestions.extension.d.ts +25 -0
- package/dist/chat-ui/mentions/suggestions/shims.d.ts +19 -0
- package/dist/chat-ui/messages/message-components.d.ts +58 -0
- package/dist/chat-ui/messages/running-indicator.d.ts +10 -0
- package/dist/chat-ui/thread/chat-composer-dock.d.ts +34 -0
- package/dist/chat-ui/thread/chat-thread-shell.d.ts +97 -0
- package/dist/chat-ui/thread/composer-send-or-stop.d.ts +67 -0
- package/dist/chat-ui.cjs +2084 -0
- package/dist/chat-ui.cjs.map +1 -0
- package/dist/chat-ui.js +2085 -0
- package/dist/chat-ui.js.map +1 -0
- package/dist/composer-send-or-stop-C5AVmcwO.js +32733 -0
- package/dist/composer-send-or-stop-C5AVmcwO.js.map +1 -0
- package/dist/composer-send-or-stop-RPudYkWR.cjs +32748 -0
- package/dist/composer-send-or-stop-RPudYkWR.cjs.map +1 -0
- package/dist/index.cjs +8968 -36580
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +8485 -36097
- package/dist/index.js.map +1 -1
- package/dist/mentions/mention-suggestion-list.d.ts +1 -1
- package/dist/mentions/use-mention-suggestions.d.ts +3 -2
- package/dist/styles.css +1 -1
- package/dist/threads/api.d.ts +1 -0
- package/dist/threads/conversation-list-fetcher.d.ts +40 -0
- package/package.json +17 -5
- package/src/chat-ui/styles/theme.css +30 -0
- package/src/chat-ui/tailwind-preset.js +57 -0
- package/dist/mentions/scope-registry.d.ts +0 -21
- package/dist/mentions/types.d.ts +0 -39
package/dist/chat-ui.js
ADDED
|
@@ -0,0 +1,2085 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
+
import { a4 as createLucideIcon, W as Node, z as mergeAttributes, a0 as Extension, av as Suggestion, at as useFloating, au as FloatingPortal, q as autoUpdate, o as offset, k as flip, s as shift, ar as getFilteredItems, aY as getFetchState, aZ as getEntry, a_ as updateFetchState, az as addItems, ay as registerSource, a$ as bindScopes, aq as useStore, ag as FileText, a6 as Workflow, aj as BookOpen, aM as Sheet, aK as Table, ah as Database, ai as Calendar, aa as Mail, aL as Image, a9 as Monitor, aI as Code, aN as Camera, ab as LayoutGrid, ac as HardDrive, a8 as Package, a5 as Wrench, a7 as Users, aJ as Search, ad as Globe, ae as FolderKanban, af as Folder, aU as File$1, t as cn, ax as Store, b0 as getSearchScope, b1 as assetTypeToThumb, b2 as fetchGraphQL, b3 as PAGINATED_ASSETS_QUERY, b4 as WORKSPACE_MEMBERS_QUERY, b5 as SIMPLE_SEARCH_QUERY, b6 as assetTypeToIcon, b7 as useMentionAuth, aB as createScopeRegistry, aA as createItemCache, an as useEditor, ap as StarterKit, aE as Placeholder, ao as EditorContent } from "./composer-send-or-stop-C5AVmcwO.js";
|
|
5
|
+
import { b8, b9, ba, bb, bc, aQ, aP, bd, aR, be, bf, bg, bh, bi, bj, bk, bl, bm, bn, bo, bp, bq, br, bs, bt, bu, bv, bw, bx, by, bz, bA } from "./composer-send-or-stop-C5AVmcwO.js";
|
|
6
|
+
import { jsx, jsxs, Fragment as Fragment$1 } from "react/jsx-runtime";
|
|
7
|
+
import { useEffect, useState, useRef, Fragment, useImperativeHandle, forwardRef, useCallback, useMemo, useId } from "react";
|
|
8
|
+
import { useAui, unstable_useComposerInput } from "@assistant-ui/react";
|
|
9
|
+
import "@assistant-ui/tap";
|
|
10
|
+
import "statewire";
|
|
11
|
+
import "@assistant-ui/store";
|
|
12
|
+
import "@assistant-ui/react-statewire";
|
|
13
|
+
const mentionHandlersByThread = /* @__PURE__ */ new Map();
|
|
14
|
+
function registerChatAssetMentionHandler(threadId, handler) {
|
|
15
|
+
mentionHandlersByThread.set(threadId, handler);
|
|
16
|
+
return () => {
|
|
17
|
+
if (mentionHandlersByThread.get(threadId) === handler) {
|
|
18
|
+
mentionHandlersByThread.delete(threadId);
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* @license lucide-react v0.575.0 - ISC
|
|
24
|
+
*
|
|
25
|
+
* This source code is licensed under the ISC license.
|
|
26
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
27
|
+
*/
|
|
28
|
+
const __iconNode$k = [
|
|
29
|
+
["path", { d: "M10 12h4", key: "a56b0p" }],
|
|
30
|
+
["path", { d: "M10 8h4", key: "1sr2af" }],
|
|
31
|
+
["path", { d: "M14 21v-3a2 2 0 0 0-4 0v3", key: "1rgiei" }],
|
|
32
|
+
[
|
|
33
|
+
"path",
|
|
34
|
+
{
|
|
35
|
+
d: "M6 10H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-2",
|
|
36
|
+
key: "secmi2"
|
|
37
|
+
}
|
|
38
|
+
],
|
|
39
|
+
["path", { d: "M6 21V5a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v16", key: "16ra0t" }]
|
|
40
|
+
];
|
|
41
|
+
const Building2 = createLucideIcon("building-2", __iconNode$k);
|
|
42
|
+
/**
|
|
43
|
+
* @license lucide-react v0.575.0 - ISC
|
|
44
|
+
*
|
|
45
|
+
* This source code is licensed under the ISC license.
|
|
46
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
47
|
+
*/
|
|
48
|
+
const __iconNode$j = [
|
|
49
|
+
["path", { d: "M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z", key: "p7xjir" }]
|
|
50
|
+
];
|
|
51
|
+
const Cloud = createLucideIcon("cloud", __iconNode$j);
|
|
52
|
+
/**
|
|
53
|
+
* @license lucide-react v0.575.0 - ISC
|
|
54
|
+
*
|
|
55
|
+
* This source code is licensed under the ISC license.
|
|
56
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
57
|
+
*/
|
|
58
|
+
const __iconNode$i = [
|
|
59
|
+
[
|
|
60
|
+
"path",
|
|
61
|
+
{
|
|
62
|
+
d: "M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",
|
|
63
|
+
key: "1nclc0"
|
|
64
|
+
}
|
|
65
|
+
],
|
|
66
|
+
["circle", { cx: "12", cy: "12", r: "3", key: "1v7zrd" }]
|
|
67
|
+
];
|
|
68
|
+
const Eye = createLucideIcon("eye", __iconNode$i);
|
|
69
|
+
/**
|
|
70
|
+
* @license lucide-react v0.575.0 - ISC
|
|
71
|
+
*
|
|
72
|
+
* This source code is licensed under the ISC license.
|
|
73
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
74
|
+
*/
|
|
75
|
+
const __iconNode$h = [
|
|
76
|
+
[
|
|
77
|
+
"path",
|
|
78
|
+
{
|
|
79
|
+
d: "M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",
|
|
80
|
+
key: "1oefj6"
|
|
81
|
+
}
|
|
82
|
+
],
|
|
83
|
+
["path", { d: "M14 2v5a1 1 0 0 0 1 1h5", key: "wfsgrz" }],
|
|
84
|
+
["path", { d: "M10 12.5 8 15l2 2.5", key: "1tg20x" }],
|
|
85
|
+
["path", { d: "m14 12.5 2 2.5-2 2.5", key: "yinavb" }]
|
|
86
|
+
];
|
|
87
|
+
const FileCode = createLucideIcon("file-code", __iconNode$h);
|
|
88
|
+
/**
|
|
89
|
+
* @license lucide-react v0.575.0 - ISC
|
|
90
|
+
*
|
|
91
|
+
* This source code is licensed under the ISC license.
|
|
92
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
93
|
+
*/
|
|
94
|
+
const __iconNode$g = [
|
|
95
|
+
[
|
|
96
|
+
"path",
|
|
97
|
+
{
|
|
98
|
+
d: "M3 14h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-7a9 9 0 0 1 18 0v7a2 2 0 0 1-2 2h-1a2 2 0 0 1-2-2v-3a2 2 0 0 1 2-2h3",
|
|
99
|
+
key: "1xhozi"
|
|
100
|
+
}
|
|
101
|
+
]
|
|
102
|
+
];
|
|
103
|
+
const Headphones = createLucideIcon("headphones", __iconNode$g);
|
|
104
|
+
/**
|
|
105
|
+
* @license lucide-react v0.575.0 - ISC
|
|
106
|
+
*
|
|
107
|
+
* This source code is licensed under the ISC license.
|
|
108
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
109
|
+
*/
|
|
110
|
+
const __iconNode$f = [
|
|
111
|
+
["path", { d: "m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4", key: "g0fldk" }],
|
|
112
|
+
["path", { d: "m21 2-9.6 9.6", key: "1j0ho8" }],
|
|
113
|
+
["circle", { cx: "7.5", cy: "15.5", r: "5.5", key: "yqb3hr" }]
|
|
114
|
+
];
|
|
115
|
+
const Key = createLucideIcon("key", __iconNode$f);
|
|
116
|
+
/**
|
|
117
|
+
* @license lucide-react v0.575.0 - ISC
|
|
118
|
+
*
|
|
119
|
+
* This source code is licensed under the ISC license.
|
|
120
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
121
|
+
*/
|
|
122
|
+
const __iconNode$e = [
|
|
123
|
+
["path", { d: "M10 8h.01", key: "1r9ogq" }],
|
|
124
|
+
["path", { d: "M12 12h.01", key: "1mp3jc" }],
|
|
125
|
+
["path", { d: "M14 8h.01", key: "1primd" }],
|
|
126
|
+
["path", { d: "M16 12h.01", key: "1l6xoz" }],
|
|
127
|
+
["path", { d: "M18 8h.01", key: "emo2bl" }],
|
|
128
|
+
["path", { d: "M6 8h.01", key: "x9i8wu" }],
|
|
129
|
+
["path", { d: "M7 16h10", key: "wp8him" }],
|
|
130
|
+
["path", { d: "M8 12h.01", key: "czm47f" }],
|
|
131
|
+
["rect", { width: "20", height: "16", x: "2", y: "4", rx: "2", key: "18n3k1" }]
|
|
132
|
+
];
|
|
133
|
+
const Keyboard = createLucideIcon("keyboard", __iconNode$e);
|
|
134
|
+
/**
|
|
135
|
+
* @license lucide-react v0.575.0 - ISC
|
|
136
|
+
*
|
|
137
|
+
* This source code is licensed under the ISC license.
|
|
138
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
139
|
+
*/
|
|
140
|
+
const __iconNode$d = [
|
|
141
|
+
["rect", { width: "7", height: "9", x: "3", y: "3", rx: "1", key: "10lvy0" }],
|
|
142
|
+
["rect", { width: "7", height: "5", x: "14", y: "3", rx: "1", key: "16une8" }],
|
|
143
|
+
["rect", { width: "7", height: "9", x: "14", y: "12", rx: "1", key: "1hutg5" }],
|
|
144
|
+
["rect", { width: "7", height: "5", x: "3", y: "16", rx: "1", key: "ldoo1y" }]
|
|
145
|
+
];
|
|
146
|
+
const LayoutDashboard = createLucideIcon("layout-dashboard", __iconNode$d);
|
|
147
|
+
/**
|
|
148
|
+
* @license lucide-react v0.575.0 - ISC
|
|
149
|
+
*
|
|
150
|
+
* This source code is licensed under the ISC license.
|
|
151
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
152
|
+
*/
|
|
153
|
+
const __iconNode$c = [
|
|
154
|
+
["path", { d: "m16 6 4 14", key: "ji33uf" }],
|
|
155
|
+
["path", { d: "M12 6v14", key: "1n7gus" }],
|
|
156
|
+
["path", { d: "M8 8v12", key: "1gg7y9" }],
|
|
157
|
+
["path", { d: "M4 4v16", key: "6qkkli" }]
|
|
158
|
+
];
|
|
159
|
+
const Library = createLucideIcon("library", __iconNode$c);
|
|
160
|
+
/**
|
|
161
|
+
* @license lucide-react v0.575.0 - ISC
|
|
162
|
+
*
|
|
163
|
+
* This source code is licensed under the ISC license.
|
|
164
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
165
|
+
*/
|
|
166
|
+
const __iconNode$b = [
|
|
167
|
+
["path", { d: "M12 19v3", key: "npa21l" }],
|
|
168
|
+
["path", { d: "M19 10v2a7 7 0 0 1-14 0v-2", key: "1vc78b" }],
|
|
169
|
+
["rect", { x: "9", y: "2", width: "6", height: "13", rx: "3", key: "s6n7sd" }]
|
|
170
|
+
];
|
|
171
|
+
const Mic = createLucideIcon("mic", __iconNode$b);
|
|
172
|
+
/**
|
|
173
|
+
* @license lucide-react v0.575.0 - ISC
|
|
174
|
+
*
|
|
175
|
+
* This source code is licensed under the ISC license.
|
|
176
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
177
|
+
*/
|
|
178
|
+
const __iconNode$a = [
|
|
179
|
+
[
|
|
180
|
+
"path",
|
|
181
|
+
{
|
|
182
|
+
d: "M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z",
|
|
183
|
+
key: "e79jfc"
|
|
184
|
+
}
|
|
185
|
+
],
|
|
186
|
+
["circle", { cx: "13.5", cy: "6.5", r: ".5", fill: "currentColor", key: "1okk4w" }],
|
|
187
|
+
["circle", { cx: "17.5", cy: "10.5", r: ".5", fill: "currentColor", key: "f64h9f" }],
|
|
188
|
+
["circle", { cx: "6.5", cy: "12.5", r: ".5", fill: "currentColor", key: "qy21gx" }],
|
|
189
|
+
["circle", { cx: "8.5", cy: "7.5", r: ".5", fill: "currentColor", key: "fotxhn" }]
|
|
190
|
+
];
|
|
191
|
+
const Palette = createLucideIcon("palette", __iconNode$a);
|
|
192
|
+
/**
|
|
193
|
+
* @license lucide-react v0.575.0 - ISC
|
|
194
|
+
*
|
|
195
|
+
* This source code is licensed under the ISC license.
|
|
196
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
197
|
+
*/
|
|
198
|
+
const __iconNode$9 = [
|
|
199
|
+
["rect", { width: "18", height: "18", x: "3", y: "3", rx: "2", key: "afitv7" }],
|
|
200
|
+
["path", { d: "M3 9h18", key: "1pudct" }],
|
|
201
|
+
["path", { d: "M9 21V9", key: "1oto5p" }]
|
|
202
|
+
];
|
|
203
|
+
const PanelsTopLeft = createLucideIcon("panels-top-left", __iconNode$9);
|
|
204
|
+
/**
|
|
205
|
+
* @license lucide-react v0.575.0 - ISC
|
|
206
|
+
*
|
|
207
|
+
* This source code is licensed under the ISC license.
|
|
208
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
209
|
+
*/
|
|
210
|
+
const __iconNode$8 = [
|
|
211
|
+
[
|
|
212
|
+
"path",
|
|
213
|
+
{
|
|
214
|
+
d: "M15.707 21.293a1 1 0 0 1-1.414 0l-1.586-1.586a1 1 0 0 1 0-1.414l5.586-5.586a1 1 0 0 1 1.414 0l1.586 1.586a1 1 0 0 1 0 1.414z",
|
|
215
|
+
key: "nt11vn"
|
|
216
|
+
}
|
|
217
|
+
],
|
|
218
|
+
[
|
|
219
|
+
"path",
|
|
220
|
+
{
|
|
221
|
+
d: "m18 13-1.375-6.874a1 1 0 0 0-.746-.776L3.235 2.028a1 1 0 0 0-1.207 1.207L5.35 15.879a1 1 0 0 0 .776.746L13 18",
|
|
222
|
+
key: "15qc1e"
|
|
223
|
+
}
|
|
224
|
+
],
|
|
225
|
+
["path", { d: "m2.3 2.3 7.286 7.286", key: "1wuzzi" }],
|
|
226
|
+
["circle", { cx: "11", cy: "11", r: "2", key: "xmgehs" }]
|
|
227
|
+
];
|
|
228
|
+
const PenTool = createLucideIcon("pen-tool", __iconNode$8);
|
|
229
|
+
/**
|
|
230
|
+
* @license lucide-react v0.575.0 - ISC
|
|
231
|
+
*
|
|
232
|
+
* This source code is licensed under the ISC license.
|
|
233
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
234
|
+
*/
|
|
235
|
+
const __iconNode$7 = [
|
|
236
|
+
[
|
|
237
|
+
"path",
|
|
238
|
+
{
|
|
239
|
+
d: "M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384",
|
|
240
|
+
key: "9njp5v"
|
|
241
|
+
}
|
|
242
|
+
]
|
|
243
|
+
];
|
|
244
|
+
const Phone = createLucideIcon("phone", __iconNode$7);
|
|
245
|
+
/**
|
|
246
|
+
* @license lucide-react v0.575.0 - ISC
|
|
247
|
+
*
|
|
248
|
+
* This source code is licensed under the ISC license.
|
|
249
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
250
|
+
*/
|
|
251
|
+
const __iconNode$6 = [
|
|
252
|
+
["rect", { width: "14", height: "20", x: "5", y: "2", rx: "2", ry: "2", key: "1yt0o3" }],
|
|
253
|
+
["path", { d: "M12 18h.01", key: "mhygvu" }]
|
|
254
|
+
];
|
|
255
|
+
const Smartphone = createLucideIcon("smartphone", __iconNode$6);
|
|
256
|
+
/**
|
|
257
|
+
* @license lucide-react v0.575.0 - ISC
|
|
258
|
+
*
|
|
259
|
+
* This source code is licensed under the ISC license.
|
|
260
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
261
|
+
*/
|
|
262
|
+
const __iconNode$5 = [
|
|
263
|
+
[
|
|
264
|
+
"path",
|
|
265
|
+
{
|
|
266
|
+
d: "M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",
|
|
267
|
+
key: "1s2grr"
|
|
268
|
+
}
|
|
269
|
+
],
|
|
270
|
+
["path", { d: "M20 2v4", key: "1rf3ol" }],
|
|
271
|
+
["path", { d: "M22 4h-4", key: "gwowj6" }],
|
|
272
|
+
["circle", { cx: "4", cy: "20", r: "2", key: "6kqj1y" }]
|
|
273
|
+
];
|
|
274
|
+
const Sparkles = createLucideIcon("sparkles", __iconNode$5);
|
|
275
|
+
/**
|
|
276
|
+
* @license lucide-react v0.575.0 - ISC
|
|
277
|
+
*
|
|
278
|
+
* This source code is licensed under the ISC license.
|
|
279
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
280
|
+
*/
|
|
281
|
+
const __iconNode$4 = [
|
|
282
|
+
[
|
|
283
|
+
"path",
|
|
284
|
+
{ d: "M21 10.656V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.344", key: "2acyp4" }
|
|
285
|
+
],
|
|
286
|
+
["path", { d: "m9 11 3 3L22 4", key: "1pflzl" }]
|
|
287
|
+
];
|
|
288
|
+
const SquareCheckBig = createLucideIcon("square-check-big", __iconNode$4);
|
|
289
|
+
/**
|
|
290
|
+
* @license lucide-react v0.575.0 - ISC
|
|
291
|
+
*
|
|
292
|
+
* This source code is licensed under the ISC license.
|
|
293
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
294
|
+
*/
|
|
295
|
+
const __iconNode$3 = [
|
|
296
|
+
[
|
|
297
|
+
"path",
|
|
298
|
+
{
|
|
299
|
+
d: "M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",
|
|
300
|
+
key: "r04s7s"
|
|
301
|
+
}
|
|
302
|
+
]
|
|
303
|
+
];
|
|
304
|
+
const Star = createLucideIcon("star", __iconNode$3);
|
|
305
|
+
/**
|
|
306
|
+
* @license lucide-react v0.575.0 - ISC
|
|
307
|
+
*
|
|
308
|
+
* This source code is licensed under the ISC license.
|
|
309
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
310
|
+
*/
|
|
311
|
+
const __iconNode$2 = [
|
|
312
|
+
["path", { d: "M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2", key: "975kel" }],
|
|
313
|
+
["circle", { cx: "12", cy: "7", r: "4", key: "17ys0d" }]
|
|
314
|
+
];
|
|
315
|
+
const User = createLucideIcon("user", __iconNode$2);
|
|
316
|
+
/**
|
|
317
|
+
* @license lucide-react v0.575.0 - ISC
|
|
318
|
+
*
|
|
319
|
+
* This source code is licensed under the ISC license.
|
|
320
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
321
|
+
*/
|
|
322
|
+
const __iconNode$1 = [
|
|
323
|
+
[
|
|
324
|
+
"path",
|
|
325
|
+
{
|
|
326
|
+
d: "m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",
|
|
327
|
+
key: "ftymec"
|
|
328
|
+
}
|
|
329
|
+
],
|
|
330
|
+
["rect", { x: "2", y: "6", width: "14", height: "12", rx: "2", key: "158x01" }]
|
|
331
|
+
];
|
|
332
|
+
const Video = createLucideIcon("video", __iconNode$1);
|
|
333
|
+
/**
|
|
334
|
+
* @license lucide-react v0.575.0 - ISC
|
|
335
|
+
*
|
|
336
|
+
* This source code is licensed under the ISC license.
|
|
337
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
338
|
+
*/
|
|
339
|
+
const __iconNode = [
|
|
340
|
+
[
|
|
341
|
+
"path",
|
|
342
|
+
{
|
|
343
|
+
d: "M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",
|
|
344
|
+
key: "1xq2db"
|
|
345
|
+
}
|
|
346
|
+
]
|
|
347
|
+
];
|
|
348
|
+
const Zap = createLucideIcon("zap", __iconNode);
|
|
349
|
+
function makeMentionUrl(attrs) {
|
|
350
|
+
if (attrs.type === "tool") {
|
|
351
|
+
return `mention://tool?name=${encodeURIComponent(attrs.id)}&description=${encodeURIComponent(attrs.description ?? "")}`;
|
|
352
|
+
}
|
|
353
|
+
if (attrs.type === "asset") {
|
|
354
|
+
const params2 = new URLSearchParams({ asset_ids: attrs.id });
|
|
355
|
+
if (attrs.assetType) params2.set("assetType", attrs.assetType);
|
|
356
|
+
return `/dashboard/spaces?${params2.toString()}`;
|
|
357
|
+
}
|
|
358
|
+
if (attrs.type === "tab") {
|
|
359
|
+
const params2 = new URLSearchParams({
|
|
360
|
+
tab_id: attrs.id,
|
|
361
|
+
url: attrs.url ?? "",
|
|
362
|
+
title: attrs.title ?? attrs.name
|
|
363
|
+
});
|
|
364
|
+
return `mention://webpage?${params2.toString()}`;
|
|
365
|
+
}
|
|
366
|
+
const params = new URLSearchParams();
|
|
367
|
+
params.set("id", attrs.id);
|
|
368
|
+
if (attrs.assetType) params.set("assetType", attrs.assetType);
|
|
369
|
+
if (attrs.thumbnailUrl) params.set("thumb", attrs.thumbnailUrl);
|
|
370
|
+
return `mention://${encodeURIComponent(attrs.type)}?${params.toString()}`;
|
|
371
|
+
}
|
|
372
|
+
function parseMentionAnchorAttributes({
|
|
373
|
+
href,
|
|
374
|
+
textContent
|
|
375
|
+
}) {
|
|
376
|
+
const url = new URL(href);
|
|
377
|
+
const isWebpage = url.hostname === "webpage";
|
|
378
|
+
return {
|
|
379
|
+
type: isWebpage ? "tab" : url.hostname || "tool",
|
|
380
|
+
name: (textContent == null ? void 0 : textContent.replace(/^@/, "")) || "",
|
|
381
|
+
id: isWebpage ? url.searchParams.get("tab_id") || "" : url.searchParams.get("name") || url.searchParams.get("id") || "",
|
|
382
|
+
title: url.searchParams.get("title") || "",
|
|
383
|
+
url: url.searchParams.get("url") || "",
|
|
384
|
+
description: url.searchParams.get("description") || "",
|
|
385
|
+
thumbnailUrl: url.searchParams.get("thumb") || "",
|
|
386
|
+
fallbackIcon: "",
|
|
387
|
+
assetType: url.searchParams.get("assetType") || ""
|
|
388
|
+
};
|
|
389
|
+
}
|
|
390
|
+
const MentionExtension = Node.create({
|
|
391
|
+
name: "mention",
|
|
392
|
+
group: "inline",
|
|
393
|
+
inline: true,
|
|
394
|
+
selectable: false,
|
|
395
|
+
atom: true,
|
|
396
|
+
addAttributes() {
|
|
397
|
+
return {
|
|
398
|
+
type: { default: "tool" },
|
|
399
|
+
name: { default: "" },
|
|
400
|
+
id: { default: "" },
|
|
401
|
+
title: { default: "" },
|
|
402
|
+
url: { default: "" },
|
|
403
|
+
description: { default: "" },
|
|
404
|
+
thumbnailUrl: { default: "" },
|
|
405
|
+
fallbackIcon: { default: "" },
|
|
406
|
+
assetType: { default: "" }
|
|
407
|
+
};
|
|
408
|
+
},
|
|
409
|
+
parseHTML() {
|
|
410
|
+
return [
|
|
411
|
+
{
|
|
412
|
+
tag: "span[data-mention]",
|
|
413
|
+
getAttrs: (dom) => {
|
|
414
|
+
var _a;
|
|
415
|
+
const el = dom;
|
|
416
|
+
return {
|
|
417
|
+
type: el.getAttribute("data-type") || "tool",
|
|
418
|
+
name: el.getAttribute("data-name") || ((_a = el.textContent) == null ? void 0 : _a.replace(/^@/, "")) || "",
|
|
419
|
+
id: el.getAttribute("data-id") || "",
|
|
420
|
+
title: el.getAttribute("data-title") || "",
|
|
421
|
+
url: el.getAttribute("data-url") || "",
|
|
422
|
+
description: el.getAttribute("data-description") || "",
|
|
423
|
+
thumbnailUrl: el.getAttribute("data-thumbnail-url") || "",
|
|
424
|
+
fallbackIcon: el.getAttribute("data-fallback-icon") || "",
|
|
425
|
+
assetType: el.getAttribute("data-asset-type") || ""
|
|
426
|
+
};
|
|
427
|
+
}
|
|
428
|
+
},
|
|
429
|
+
{
|
|
430
|
+
tag: "a[href^='mention://']",
|
|
431
|
+
getAttrs: (dom) => {
|
|
432
|
+
const el = dom;
|
|
433
|
+
return parseMentionAnchorAttributes({
|
|
434
|
+
href: el.href,
|
|
435
|
+
textContent: el.textContent
|
|
436
|
+
});
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
];
|
|
440
|
+
},
|
|
441
|
+
renderHTML({ node, HTMLAttributes }) {
|
|
442
|
+
const thumbnailUrl = node.attrs.thumbnailUrl;
|
|
443
|
+
const children = [];
|
|
444
|
+
if (thumbnailUrl) {
|
|
445
|
+
children.push([
|
|
446
|
+
"img",
|
|
447
|
+
{
|
|
448
|
+
src: thumbnailUrl,
|
|
449
|
+
alt: "",
|
|
450
|
+
class: "mention-chip-icon",
|
|
451
|
+
draggable: "false"
|
|
452
|
+
}
|
|
453
|
+
]);
|
|
454
|
+
}
|
|
455
|
+
children.push(["span", { class: "mention-chip-text" }, node.attrs.name]);
|
|
456
|
+
return [
|
|
457
|
+
"span",
|
|
458
|
+
mergeAttributes(HTMLAttributes, {
|
|
459
|
+
"data-mention": "",
|
|
460
|
+
"data-type": node.attrs.type,
|
|
461
|
+
"data-name": node.attrs.name,
|
|
462
|
+
"data-id": node.attrs.id,
|
|
463
|
+
"data-title": node.attrs.title || "",
|
|
464
|
+
"data-url": node.attrs.url || "",
|
|
465
|
+
"data-thumbnail-url": node.attrs.thumbnailUrl || "",
|
|
466
|
+
"data-asset-type": node.attrs.assetType || "",
|
|
467
|
+
class: "mention-chip"
|
|
468
|
+
}),
|
|
469
|
+
...children
|
|
470
|
+
];
|
|
471
|
+
},
|
|
472
|
+
renderText({ node }) {
|
|
473
|
+
const url = makeMentionUrl({
|
|
474
|
+
id: node.attrs.id,
|
|
475
|
+
type: node.attrs.type,
|
|
476
|
+
name: node.attrs.name,
|
|
477
|
+
title: node.attrs.title,
|
|
478
|
+
url: node.attrs.url,
|
|
479
|
+
description: node.attrs.description,
|
|
480
|
+
thumbnailUrl: node.attrs.thumbnailUrl,
|
|
481
|
+
assetType: node.attrs.assetType
|
|
482
|
+
});
|
|
483
|
+
return `[@${node.attrs.name}](${url})`;
|
|
484
|
+
}
|
|
485
|
+
});
|
|
486
|
+
const MentionSuggestionsExtension = Extension.create({
|
|
487
|
+
name: "mentionSuggestions",
|
|
488
|
+
addOptions() {
|
|
489
|
+
return {
|
|
490
|
+
store: null,
|
|
491
|
+
callbacks: null
|
|
492
|
+
};
|
|
493
|
+
},
|
|
494
|
+
addProseMirrorPlugins() {
|
|
495
|
+
const callbacks = this.options.callbacks;
|
|
496
|
+
return [
|
|
497
|
+
Suggestion({
|
|
498
|
+
editor: this.editor,
|
|
499
|
+
char: "@",
|
|
500
|
+
allowSpaces: false,
|
|
501
|
+
startOfLine: false,
|
|
502
|
+
allowedPrefixes: [" ", " ", "\n", "\r", "(", "[", "{", '"', "'", " "],
|
|
503
|
+
items: () => [],
|
|
504
|
+
command: ({ editor, range, props }) => {
|
|
505
|
+
var _a, _b, _c;
|
|
506
|
+
const item = props;
|
|
507
|
+
if (item.navigatesToScope || item.isNavigationOnly) return;
|
|
508
|
+
editor.chain().focus().deleteRange(range).insertContent({
|
|
509
|
+
type: "mention",
|
|
510
|
+
attrs: {
|
|
511
|
+
type: item.type,
|
|
512
|
+
name: item.name,
|
|
513
|
+
id: item.type === "tab" && typeof ((_a = item.extra) == null ? void 0 : _a.tabId) === "number" ? String(item.extra.tabId) : item.id,
|
|
514
|
+
title: item.type === "tab" && typeof ((_b = item.extra) == null ? void 0 : _b.title) === "string" ? item.extra.title : item.name,
|
|
515
|
+
url: item.url ?? "",
|
|
516
|
+
description: item.description ?? "",
|
|
517
|
+
thumbnailUrl: item.thumbnailUrl ?? "",
|
|
518
|
+
fallbackIcon: item.fallbackIcon ?? "",
|
|
519
|
+
assetType: typeof ((_c = item.extra) == null ? void 0 : _c.athenaOriginalType) === "string" ? item.extra.athenaOriginalType : ""
|
|
520
|
+
}
|
|
521
|
+
}).insertContent(" ").run();
|
|
522
|
+
},
|
|
523
|
+
render: () => ({
|
|
524
|
+
onStart: (props) => {
|
|
525
|
+
callbacks == null ? void 0 : callbacks.onStart({
|
|
526
|
+
query: props.query,
|
|
527
|
+
command: (item) => props.command(item),
|
|
528
|
+
clientRect: props.clientRect ?? null,
|
|
529
|
+
editor: props.editor
|
|
530
|
+
});
|
|
531
|
+
},
|
|
532
|
+
onUpdate: (props) => {
|
|
533
|
+
callbacks == null ? void 0 : callbacks.onUpdate({
|
|
534
|
+
query: props.query,
|
|
535
|
+
command: (item) => props.command(item),
|
|
536
|
+
clientRect: props.clientRect ?? null,
|
|
537
|
+
editor: props.editor
|
|
538
|
+
});
|
|
539
|
+
},
|
|
540
|
+
onKeyDown: ({ event }) => {
|
|
541
|
+
return (callbacks == null ? void 0 : callbacks.onKeyDown(event)) ?? false;
|
|
542
|
+
},
|
|
543
|
+
onExit: () => {
|
|
544
|
+
callbacks == null ? void 0 : callbacks.onExit();
|
|
545
|
+
}
|
|
546
|
+
})
|
|
547
|
+
})
|
|
548
|
+
];
|
|
549
|
+
}
|
|
550
|
+
});
|
|
551
|
+
const MentionSuggestionPopup = ({ clientRect, children }) => {
|
|
552
|
+
const { refs, floatingStyles } = useFloating({
|
|
553
|
+
placement: "bottom-start",
|
|
554
|
+
middleware: [offset(10), flip(), shift({ padding: 8 })],
|
|
555
|
+
whileElementsMounted: autoUpdate
|
|
556
|
+
});
|
|
557
|
+
useEffect(() => {
|
|
558
|
+
if (clientRect) {
|
|
559
|
+
refs.setPositionReference({
|
|
560
|
+
getBoundingClientRect: () => clientRect() ?? new DOMRect()
|
|
561
|
+
});
|
|
562
|
+
}
|
|
563
|
+
}, [clientRect, refs]);
|
|
564
|
+
return /* @__PURE__ */ jsx(FloatingPortal, { children: /* @__PURE__ */ jsx(
|
|
565
|
+
"div",
|
|
566
|
+
{
|
|
567
|
+
ref: refs.setFloating,
|
|
568
|
+
style: floatingStyles,
|
|
569
|
+
className: "z-[9999]",
|
|
570
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
571
|
+
children
|
|
572
|
+
}
|
|
573
|
+
) });
|
|
574
|
+
};
|
|
575
|
+
const MAX_ERROR_RETRIES = 3;
|
|
576
|
+
function selectItems(store, scope, query, _targetCount, parentScope) {
|
|
577
|
+
const state = store.state;
|
|
578
|
+
const scopeId = typeof scope === "string" ? scope : scope.id;
|
|
579
|
+
const parentScopeId = parentScope ? typeof parentScope === "string" ? parentScope : parentScope.id : void 0;
|
|
580
|
+
const items = getFilteredItems(state.cache, scopeId, query);
|
|
581
|
+
let isFetching = false;
|
|
582
|
+
let hasMore = true;
|
|
583
|
+
try {
|
|
584
|
+
const fetchState = getFetchState(state.registry, scopeId, query, parentScopeId);
|
|
585
|
+
isFetching = fetchState.isFetching;
|
|
586
|
+
hasMore = fetchState.hasNextPage;
|
|
587
|
+
} catch {
|
|
588
|
+
hasMore = false;
|
|
589
|
+
}
|
|
590
|
+
return { items, isFetching, hasMore };
|
|
591
|
+
}
|
|
592
|
+
function triggerFetchIfNeeded(store, scope, query, _targetCount, parentScope) {
|
|
593
|
+
const scopeId = typeof scope === "string" ? scope : scope.id;
|
|
594
|
+
const parentScopeId = parentScope ? typeof parentScope === "string" ? parentScope : parentScope.id : void 0;
|
|
595
|
+
const state = store.state;
|
|
596
|
+
let entry;
|
|
597
|
+
try {
|
|
598
|
+
entry = getEntry(state.registry, scopeId, parentScopeId);
|
|
599
|
+
} catch {
|
|
600
|
+
return;
|
|
601
|
+
}
|
|
602
|
+
const fetchState = getFetchState(state.registry, scopeId, query, parentScopeId);
|
|
603
|
+
if (fetchState.isFetching || !fetchState.hasNextPage || fetchState.error) {
|
|
604
|
+
return;
|
|
605
|
+
}
|
|
606
|
+
const meta = fetchState.meta || {};
|
|
607
|
+
if ((meta.fetchAttempts || 0) >= 10) return;
|
|
608
|
+
updateFetchState(state.registry, scopeId, query, { isFetching: true }, parentScopeId);
|
|
609
|
+
store.setState((prev) => ({ ...prev }));
|
|
610
|
+
const sourceFn = entry.sourceFn;
|
|
611
|
+
const sourceConfig = entry.sourceConfig;
|
|
612
|
+
sourceFn({
|
|
613
|
+
scope: scopeId,
|
|
614
|
+
query,
|
|
615
|
+
fetchState,
|
|
616
|
+
sourceConfig
|
|
617
|
+
}).then((result) => {
|
|
618
|
+
var _a, _b;
|
|
619
|
+
const currentState = store.state;
|
|
620
|
+
addItems(currentState.cache, result.items, scopeId);
|
|
621
|
+
if (result.sources) {
|
|
622
|
+
for (const src of result.sources) {
|
|
623
|
+
try {
|
|
624
|
+
getEntry(currentState.registry, src.scope);
|
|
625
|
+
} catch {
|
|
626
|
+
registerSource(
|
|
627
|
+
currentState.registry,
|
|
628
|
+
src.scope,
|
|
629
|
+
src.sourceFn,
|
|
630
|
+
src.sourceConfig,
|
|
631
|
+
src.isFlat
|
|
632
|
+
);
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
if (result.bindings) {
|
|
637
|
+
for (const binding of result.bindings) {
|
|
638
|
+
bindScopes(currentState.registry, binding.browseScope, binding.searchScope);
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
const currentMeta = fetchState.meta || {};
|
|
642
|
+
const consumed = ((_a = result.pagination) == null ? void 0 : _a.consumedCount) ?? result.items.length;
|
|
643
|
+
const newValidated = (currentMeta.validatedCount || 0) + consumed;
|
|
644
|
+
updateFetchState(
|
|
645
|
+
currentState.registry,
|
|
646
|
+
scopeId,
|
|
647
|
+
query,
|
|
648
|
+
{
|
|
649
|
+
isFetching: false,
|
|
650
|
+
hasNextPage: ((_b = result.pagination) == null ? void 0 : _b.hasMore) ?? false,
|
|
651
|
+
error: null,
|
|
652
|
+
meta: {
|
|
653
|
+
...currentMeta,
|
|
654
|
+
...result.meta,
|
|
655
|
+
validatedCount: newValidated,
|
|
656
|
+
fetchAttempts: (currentMeta.fetchAttempts || 0) + 1,
|
|
657
|
+
errorAttempts: 0
|
|
658
|
+
}
|
|
659
|
+
},
|
|
660
|
+
parentScopeId
|
|
661
|
+
);
|
|
662
|
+
store.setState((prev) => ({ ...prev }));
|
|
663
|
+
}).catch((error) => {
|
|
664
|
+
console.error(`[orchestrator] Fetch error for scope ${scopeId}:`, error);
|
|
665
|
+
const currentState = store.state;
|
|
666
|
+
const currentMeta = fetchState.meta || {};
|
|
667
|
+
const errorAttempts = (currentMeta.errorAttempts || 0) + 1;
|
|
668
|
+
const retriable = errorAttempts < MAX_ERROR_RETRIES;
|
|
669
|
+
updateFetchState(
|
|
670
|
+
currentState.registry,
|
|
671
|
+
scopeId,
|
|
672
|
+
query,
|
|
673
|
+
{
|
|
674
|
+
isFetching: false,
|
|
675
|
+
hasNextPage: retriable,
|
|
676
|
+
error: retriable ? null : error instanceof Error ? error : new Error(String(error)),
|
|
677
|
+
meta: { ...currentMeta, errorAttempts }
|
|
678
|
+
},
|
|
679
|
+
parentScopeId
|
|
680
|
+
);
|
|
681
|
+
store.setState((prev) => ({ ...prev }));
|
|
682
|
+
});
|
|
683
|
+
}
|
|
684
|
+
function useMenuItems(store, options) {
|
|
685
|
+
const { scope, query = "", minItems = 50, parentScope } = options;
|
|
686
|
+
const [targetCount, setTargetCount] = useState(minItems);
|
|
687
|
+
useEffect(() => {
|
|
688
|
+
setTargetCount(minItems);
|
|
689
|
+
}, [scope, query, minItems]);
|
|
690
|
+
const snapshot = useStore(
|
|
691
|
+
store,
|
|
692
|
+
() => selectItems(store, scope, query, targetCount, parentScope)
|
|
693
|
+
);
|
|
694
|
+
useEffect(() => {
|
|
695
|
+
if (snapshot.items.length < targetCount && snapshot.hasMore && !snapshot.isFetching) {
|
|
696
|
+
triggerFetchIfNeeded(store, scope, query, targetCount, parentScope);
|
|
697
|
+
}
|
|
698
|
+
}, [
|
|
699
|
+
store,
|
|
700
|
+
scope,
|
|
701
|
+
query,
|
|
702
|
+
targetCount,
|
|
703
|
+
parentScope,
|
|
704
|
+
snapshot.items.length,
|
|
705
|
+
snapshot.hasMore,
|
|
706
|
+
snapshot.isFetching
|
|
707
|
+
]);
|
|
708
|
+
const loadMore = () => {
|
|
709
|
+
if (snapshot.hasMore && !snapshot.isFetching) {
|
|
710
|
+
setTargetCount((prev) => prev + 50);
|
|
711
|
+
}
|
|
712
|
+
};
|
|
713
|
+
return {
|
|
714
|
+
items: snapshot.items,
|
|
715
|
+
isFetching: snapshot.isFetching,
|
|
716
|
+
hasMore: snapshot.hasMore,
|
|
717
|
+
loadMore,
|
|
718
|
+
targetCount
|
|
719
|
+
// Expose for debugging
|
|
720
|
+
};
|
|
721
|
+
}
|
|
722
|
+
const KNOWN_SCOPE_NAMES = {
|
|
723
|
+
root: "All",
|
|
724
|
+
global_search: "Search",
|
|
725
|
+
// Legacy order: my_spaces, favorites, assets, folders, tools, toolkits, team, workspace, drives
|
|
726
|
+
my_spaces: "My Spaces",
|
|
727
|
+
favorites: "Favorites",
|
|
728
|
+
athena_assets: "Assets",
|
|
729
|
+
athena_folders: "Folders",
|
|
730
|
+
tools: "Tools",
|
|
731
|
+
toolkits: "Toolkits",
|
|
732
|
+
team: "Team",
|
|
733
|
+
workspace: "Workspace",
|
|
734
|
+
drive_catalogs: "Drives",
|
|
735
|
+
athena_projects: "Projects",
|
|
736
|
+
athena_browse_profiles: "Browse Profiles",
|
|
737
|
+
// Additional scopes
|
|
738
|
+
asset_search: "Search"
|
|
739
|
+
};
|
|
740
|
+
function getScopeName(scope, store) {
|
|
741
|
+
const knownName = KNOWN_SCOPE_NAMES[scope];
|
|
742
|
+
if (knownName) {
|
|
743
|
+
return knownName;
|
|
744
|
+
}
|
|
745
|
+
const { cache } = store.state;
|
|
746
|
+
const allItems = Object.values(cache.items);
|
|
747
|
+
const item = allItems.find((item2) => item2.navigatesToScope === scope);
|
|
748
|
+
if (item) {
|
|
749
|
+
return item.name;
|
|
750
|
+
}
|
|
751
|
+
return scope.split("_").map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join(" ");
|
|
752
|
+
}
|
|
753
|
+
const MentionMenuSection = {
|
|
754
|
+
CURRENT_WEBPAGE: "current-webpage",
|
|
755
|
+
OTHER_WEBPAGES: "other-webpages",
|
|
756
|
+
LIBRARY: "library"
|
|
757
|
+
};
|
|
758
|
+
const ICON_MAP = {
|
|
759
|
+
// General
|
|
760
|
+
file: File$1,
|
|
761
|
+
"file-text": FileText,
|
|
762
|
+
"file-code": FileCode,
|
|
763
|
+
folder: Folder,
|
|
764
|
+
"folder-kanban": FolderKanban,
|
|
765
|
+
globe: Globe,
|
|
766
|
+
search: Search,
|
|
767
|
+
star: Star,
|
|
768
|
+
users: Users,
|
|
769
|
+
user: User,
|
|
770
|
+
wrench: Wrench,
|
|
771
|
+
package: Package,
|
|
772
|
+
"building-2": Building2,
|
|
773
|
+
"hard-drive": HardDrive,
|
|
774
|
+
"layout-grid": LayoutGrid,
|
|
775
|
+
zap: Zap,
|
|
776
|
+
eye: Eye,
|
|
777
|
+
// Chrome tools
|
|
778
|
+
camera: Camera,
|
|
779
|
+
keyboard: Keyboard,
|
|
780
|
+
code: Code,
|
|
781
|
+
monitor: Monitor,
|
|
782
|
+
// Asset types
|
|
783
|
+
image: Image,
|
|
784
|
+
video: Video,
|
|
785
|
+
headphones: Headphones,
|
|
786
|
+
mic: Mic,
|
|
787
|
+
mail: Mail,
|
|
788
|
+
calendar: Calendar,
|
|
789
|
+
phone: Phone,
|
|
790
|
+
database: Database,
|
|
791
|
+
table: Table,
|
|
792
|
+
sheet: Sheet,
|
|
793
|
+
palette: Palette,
|
|
794
|
+
"pen-tool": PenTool,
|
|
795
|
+
layout: PanelsTopLeft,
|
|
796
|
+
"layout-dashboard": LayoutDashboard,
|
|
797
|
+
library: Library,
|
|
798
|
+
"book-open": BookOpen,
|
|
799
|
+
sparkles: Sparkles,
|
|
800
|
+
"check-square": SquareCheckBig,
|
|
801
|
+
key: Key,
|
|
802
|
+
smartphone: Smartphone,
|
|
803
|
+
cloud: Cloud,
|
|
804
|
+
workflow: Workflow,
|
|
805
|
+
presentation: FileText
|
|
806
|
+
// Fallback for presentation type
|
|
807
|
+
};
|
|
808
|
+
function MentionIcon({
|
|
809
|
+
fallbackIcon,
|
|
810
|
+
thumbnailUrl,
|
|
811
|
+
alt,
|
|
812
|
+
className = "w-4 h-4 flex-shrink-0"
|
|
813
|
+
}) {
|
|
814
|
+
if (thumbnailUrl) {
|
|
815
|
+
return /* @__PURE__ */ jsx("img", { src: thumbnailUrl, alt: alt ?? "", className });
|
|
816
|
+
}
|
|
817
|
+
const Icon = fallbackIcon ? ICON_MAP[fallbackIcon] : void 0;
|
|
818
|
+
if (Icon) return /* @__PURE__ */ jsx(Icon, { className });
|
|
819
|
+
if (fallbackIcon) return /* @__PURE__ */ jsx("span", { className: "text-sm flex-shrink-0", children: fallbackIcon });
|
|
820
|
+
return /* @__PURE__ */ jsx(File$1, { className });
|
|
821
|
+
}
|
|
822
|
+
function MenuItemRow({
|
|
823
|
+
item,
|
|
824
|
+
isSelected,
|
|
825
|
+
onMouseEnter,
|
|
826
|
+
onClick,
|
|
827
|
+
showArrow
|
|
828
|
+
}) {
|
|
829
|
+
var _a, _b;
|
|
830
|
+
const hasTwoLines = item.type === "tool" && item.description || item.type === "user" && item.email || item.type === "workspace_item" && item.description || item.type === "tab" && item.description;
|
|
831
|
+
return /* @__PURE__ */ jsxs(
|
|
832
|
+
"div",
|
|
833
|
+
{
|
|
834
|
+
role: "button",
|
|
835
|
+
tabIndex: -1,
|
|
836
|
+
onClick,
|
|
837
|
+
onMouseEnter,
|
|
838
|
+
className: cn(
|
|
839
|
+
"mention-item flex items-center justify-between gap-2 px-2 py-1.5 rounded cursor-pointer transition-colors",
|
|
840
|
+
"hover:bg-gray-100",
|
|
841
|
+
item.menuSection === MentionMenuSection.CURRENT_WEBPAGE && !isSelected && "bg-sky-50/70",
|
|
842
|
+
isSelected && "bg-gray-100 is-selected"
|
|
843
|
+
),
|
|
844
|
+
children: [
|
|
845
|
+
/* @__PURE__ */ jsx("span", { className: `flex items-center flex-shrink-0 ${hasTwoLines ? "self-start mt-0.5" : ""}`, children: /* @__PURE__ */ jsx(
|
|
846
|
+
MentionIcon,
|
|
847
|
+
{
|
|
848
|
+
fallbackIcon: item.fallbackIcon,
|
|
849
|
+
thumbnailUrl: item.thumbnailUrl,
|
|
850
|
+
alt: item.name
|
|
851
|
+
}
|
|
852
|
+
) }),
|
|
853
|
+
hasTwoLines ? /* @__PURE__ */ jsxs("div", { className: "flex-1 flex flex-col gap-0 min-w-0 -mt-0.5", children: [
|
|
854
|
+
/* @__PURE__ */ jsxs("span", { className: "text-sm leading-tight flex items-center gap-1.5", children: [
|
|
855
|
+
item.name,
|
|
856
|
+
((_a = item.extra) == null ? void 0 : _a.isAdminOnly) && /* @__PURE__ */ jsx("span", { className: "w-1.5 h-1.5 rounded-full bg-purple-400 flex-shrink-0" })
|
|
857
|
+
] }),
|
|
858
|
+
/* @__PURE__ */ jsx("span", { className: "text-xs text-gray-500 leading-tight mt-0.5 truncate", children: item.type === "user" ? item.email : item.description })
|
|
859
|
+
] }) : /* @__PURE__ */ jsxs("span", { className: "flex-1 text-sm truncate min-w-0 flex items-center gap-1.5", children: [
|
|
860
|
+
item.name,
|
|
861
|
+
((_b = item.extra) == null ? void 0 : _b.isAdminOnly) && /* @__PURE__ */ jsx("span", { className: "w-1.5 h-1.5 rounded-full bg-purple-400 flex-shrink-0" })
|
|
862
|
+
] }),
|
|
863
|
+
showArrow && /* @__PURE__ */ jsx("div", { className: "flex items-center gap-1 flex-shrink-0", children: /* @__PURE__ */ jsx("span", { className: "text-gray-400 text-sm px-1 rounded transition-all cursor-pointer hover:text-gray-600 hover:bg-gray-200", children: "→" }) })
|
|
864
|
+
]
|
|
865
|
+
}
|
|
866
|
+
);
|
|
867
|
+
}
|
|
868
|
+
function MenuSkeleton() {
|
|
869
|
+
return /* @__PURE__ */ jsx("div", { className: "px-1 py-1", children: [1, 2, 3, 4].map((i) => /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 px-2 py-1.5 rounded animate-pulse", children: [
|
|
870
|
+
/* @__PURE__ */ jsx("div", { className: "w-4 h-4 bg-gray-200 rounded flex-shrink-0" }),
|
|
871
|
+
/* @__PURE__ */ jsx("div", { className: "h-3.5 bg-gray-200 rounded flex-1", style: { maxWidth: `${50 + i * 10}%` } })
|
|
872
|
+
] }, i)) });
|
|
873
|
+
}
|
|
874
|
+
function MenuList({
|
|
875
|
+
items,
|
|
876
|
+
selectedIndex,
|
|
877
|
+
isLoading,
|
|
878
|
+
hasMore,
|
|
879
|
+
onSelect,
|
|
880
|
+
onMouseEnter,
|
|
881
|
+
onLoadMore
|
|
882
|
+
}) {
|
|
883
|
+
const selectedRef = useRef(null);
|
|
884
|
+
useEffect(() => {
|
|
885
|
+
var _a;
|
|
886
|
+
(_a = selectedRef.current) == null ? void 0 : _a.scrollIntoView({ block: "nearest" });
|
|
887
|
+
}, [selectedIndex]);
|
|
888
|
+
if (isLoading && items.length === 0) return /* @__PURE__ */ jsx(MenuSkeleton, {});
|
|
889
|
+
if (items.length === 0) {
|
|
890
|
+
return /* @__PURE__ */ jsx("div", { className: "px-1 py-1", children: /* @__PURE__ */ jsxs("div", { className: "px-2 py-9 text-center text-sm text-gray-500", children: [
|
|
891
|
+
/* @__PURE__ */ jsx("div", { className: "mb-1", children: "No results found" }),
|
|
892
|
+
/* @__PURE__ */ jsx("div", { className: "text-xs text-gray-400", children: "Try a different search or go back" })
|
|
893
|
+
] }) });
|
|
894
|
+
}
|
|
895
|
+
return /* @__PURE__ */ jsxs("div", { className: "px-1 py-1", children: [
|
|
896
|
+
items.map((item, index) => {
|
|
897
|
+
var _a;
|
|
898
|
+
const previousSection = (_a = items[index - 1]) == null ? void 0 : _a.menuSection;
|
|
899
|
+
const startsOtherWebpages = item.menuSection === MentionMenuSection.OTHER_WEBPAGES && previousSection !== MentionMenuSection.OTHER_WEBPAGES;
|
|
900
|
+
const startsLibrary = item.menuSection === MentionMenuSection.LIBRARY && (previousSection === MentionMenuSection.CURRENT_WEBPAGE || previousSection === MentionMenuSection.OTHER_WEBPAGES);
|
|
901
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
902
|
+
startsOtherWebpages && /* @__PURE__ */ jsx("div", { className: "px-2 pb-1 pt-2 text-[11px] font-medium uppercase tracking-wide text-gray-400", children: "Other webpages in this group" }),
|
|
903
|
+
startsLibrary && /* @__PURE__ */ jsx("div", { className: "mx-2 my-1 border-t border-gray-100" }),
|
|
904
|
+
/* @__PURE__ */ jsx("div", { ref: index === selectedIndex ? selectedRef : void 0, children: /* @__PURE__ */ jsx(
|
|
905
|
+
MenuItemRow,
|
|
906
|
+
{
|
|
907
|
+
item,
|
|
908
|
+
isSelected: index === selectedIndex,
|
|
909
|
+
onMouseEnter: () => onMouseEnter(index),
|
|
910
|
+
onClick: () => onSelect(item),
|
|
911
|
+
showArrow: !!item.navigatesToScope
|
|
912
|
+
}
|
|
913
|
+
) })
|
|
914
|
+
] }, item.id);
|
|
915
|
+
}),
|
|
916
|
+
isLoading && items.length > 0 && /* @__PURE__ */ jsx("div", { className: "px-2 py-2 text-center", children: /* @__PURE__ */ jsx("span", { className: "text-xs text-gray-400", children: "Loading more..." }) }),
|
|
917
|
+
hasMore && !isLoading && onLoadMore && /* @__PURE__ */ jsx(
|
|
918
|
+
"button",
|
|
919
|
+
{
|
|
920
|
+
type: "button",
|
|
921
|
+
onClick: onLoadMore,
|
|
922
|
+
className: "w-full px-2 py-1.5 text-xs text-gray-500 hover:text-gray-700 hover:bg-gray-50 rounded transition-colors text-center",
|
|
923
|
+
children: "··· Load more"
|
|
924
|
+
}
|
|
925
|
+
)
|
|
926
|
+
] });
|
|
927
|
+
}
|
|
928
|
+
function MenuBreadcrumbs({
|
|
929
|
+
scopePath,
|
|
930
|
+
onNavigate
|
|
931
|
+
}) {
|
|
932
|
+
return /* @__PURE__ */ jsx("div", { className: "flex items-center gap-1 text-xs text-gray-600 min-w-0", children: scopePath.map((item, index) => {
|
|
933
|
+
const isLast = index === scopePath.length - 1;
|
|
934
|
+
const isClickable = !isLast;
|
|
935
|
+
return /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-1 min-w-0", children: [
|
|
936
|
+
isClickable ? /* @__PURE__ */ jsx(
|
|
937
|
+
"button",
|
|
938
|
+
{
|
|
939
|
+
type: "button",
|
|
940
|
+
onClick: () => onNavigate(item.id),
|
|
941
|
+
className: "truncate hover:underline cursor-pointer transition-all hover:text-gray-800",
|
|
942
|
+
title: `Go to ${item.name}`,
|
|
943
|
+
children: item.name
|
|
944
|
+
}
|
|
945
|
+
) : /* @__PURE__ */ jsx("span", { className: "truncate font-medium text-gray-800", children: item.name }),
|
|
946
|
+
!isLast && /* @__PURE__ */ jsx("span", { className: "text-gray-400 flex-shrink-0", children: "→" })
|
|
947
|
+
] }, item.id);
|
|
948
|
+
}) });
|
|
949
|
+
}
|
|
950
|
+
function MenuSummary({
|
|
951
|
+
scopePath,
|
|
952
|
+
onNavigate,
|
|
953
|
+
onBackClick,
|
|
954
|
+
isFetching
|
|
955
|
+
}) {
|
|
956
|
+
if (scopePath.length <= 1 && !isFetching) return null;
|
|
957
|
+
return /* @__PURE__ */ jsx("div", { className: "border-t border-gray-200 px-2 py-2 bg-gray-50", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-2", children: [
|
|
958
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 flex-1 min-w-0", children: [
|
|
959
|
+
scopePath.length > 1 && /* @__PURE__ */ jsx(MenuBreadcrumbs, { scopePath, onNavigate }),
|
|
960
|
+
isFetching && /* @__PURE__ */ jsx("span", { className: "flex-shrink-0 inline-block w-3 h-3 border border-gray-400 border-t-transparent rounded-full animate-spin" })
|
|
961
|
+
] }),
|
|
962
|
+
onBackClick && /* @__PURE__ */ jsxs(
|
|
963
|
+
"button",
|
|
964
|
+
{
|
|
965
|
+
type: "button",
|
|
966
|
+
onClick: onBackClick,
|
|
967
|
+
className: "text-xs text-gray-600 hover:text-gray-800 px-2 py-1 rounded hover:bg-gray-200 transition-colors flex items-center gap-1 flex-shrink-0",
|
|
968
|
+
title: "Go back (or press ←)",
|
|
969
|
+
children: [
|
|
970
|
+
/* @__PURE__ */ jsx("span", { children: "←" }),
|
|
971
|
+
/* @__PURE__ */ jsx("span", { children: "Back" })
|
|
972
|
+
]
|
|
973
|
+
}
|
|
974
|
+
)
|
|
975
|
+
] }) });
|
|
976
|
+
}
|
|
977
|
+
function useKeyboardNavigation(ref, opts) {
|
|
978
|
+
const { items, selectedIndex, setSelectedIndex, onSelect, onBack, onClose } = opts;
|
|
979
|
+
useImperativeHandle(
|
|
980
|
+
ref,
|
|
981
|
+
() => ({
|
|
982
|
+
onKeyDown: (event) => {
|
|
983
|
+
if (items.length === 0 && event.key !== "Escape") return false;
|
|
984
|
+
switch (event.key) {
|
|
985
|
+
case "ArrowDown": {
|
|
986
|
+
const next = (selectedIndex + 1) % items.length;
|
|
987
|
+
setSelectedIndex(next);
|
|
988
|
+
return true;
|
|
989
|
+
}
|
|
990
|
+
case "ArrowUp": {
|
|
991
|
+
const prev = (selectedIndex - 1 + items.length) % items.length;
|
|
992
|
+
setSelectedIndex(prev);
|
|
993
|
+
return true;
|
|
994
|
+
}
|
|
995
|
+
case "Enter": {
|
|
996
|
+
const item = items[selectedIndex];
|
|
997
|
+
if (item) onSelect(item);
|
|
998
|
+
return true;
|
|
999
|
+
}
|
|
1000
|
+
case "ArrowLeft": {
|
|
1001
|
+
if (onBack) {
|
|
1002
|
+
onBack();
|
|
1003
|
+
return true;
|
|
1004
|
+
}
|
|
1005
|
+
return false;
|
|
1006
|
+
}
|
|
1007
|
+
case "Backspace": {
|
|
1008
|
+
return false;
|
|
1009
|
+
}
|
|
1010
|
+
case "ArrowRight": {
|
|
1011
|
+
const item = items[selectedIndex];
|
|
1012
|
+
if (item == null ? void 0 : item.navigatesToScope) {
|
|
1013
|
+
onSelect(item);
|
|
1014
|
+
return true;
|
|
1015
|
+
}
|
|
1016
|
+
return false;
|
|
1017
|
+
}
|
|
1018
|
+
case "Escape": {
|
|
1019
|
+
onClose();
|
|
1020
|
+
return true;
|
|
1021
|
+
}
|
|
1022
|
+
default:
|
|
1023
|
+
return false;
|
|
1024
|
+
}
|
|
1025
|
+
}
|
|
1026
|
+
}),
|
|
1027
|
+
[items, selectedIndex, setSelectedIndex, onSelect, onBack, onClose]
|
|
1028
|
+
);
|
|
1029
|
+
}
|
|
1030
|
+
function getCurrentScope(state) {
|
|
1031
|
+
const lastEntry = state.scopeStack[state.scopeStack.length - 1];
|
|
1032
|
+
return (lastEntry == null ? void 0 : lastEntry.scope) ?? "root";
|
|
1033
|
+
}
|
|
1034
|
+
function getSelectedIndex(state) {
|
|
1035
|
+
const lastEntry = state.scopeStack[state.scopeStack.length - 1];
|
|
1036
|
+
return (lastEntry == null ? void 0 : lastEntry.selectedIndex) ?? 0;
|
|
1037
|
+
}
|
|
1038
|
+
function useMenuNavigation() {
|
|
1039
|
+
const [store] = useState(() => {
|
|
1040
|
+
const baseStore = new Store({
|
|
1041
|
+
scopeStack: [{ scope: "root", selectedIndex: 0 }],
|
|
1042
|
+
query: "",
|
|
1043
|
+
isActive: false
|
|
1044
|
+
});
|
|
1045
|
+
const navigationStore = baseStore;
|
|
1046
|
+
navigationStore.navigateTo = (scope, currentSelectedIndex, options) => {
|
|
1047
|
+
const state = baseStore.state;
|
|
1048
|
+
const updatedStack = [...state.scopeStack];
|
|
1049
|
+
if (updatedStack.length > 0) {
|
|
1050
|
+
updatedStack[updatedStack.length - 1] = {
|
|
1051
|
+
...updatedStack[updatedStack.length - 1],
|
|
1052
|
+
selectedIndex: currentSelectedIndex
|
|
1053
|
+
};
|
|
1054
|
+
}
|
|
1055
|
+
const newStack = [
|
|
1056
|
+
...updatedStack,
|
|
1057
|
+
{
|
|
1058
|
+
scope,
|
|
1059
|
+
selectedIndex: 0,
|
|
1060
|
+
breadcrumbLabel: options == null ? void 0 : options.breadcrumbLabel,
|
|
1061
|
+
parentScope: options == null ? void 0 : options.parentScope
|
|
1062
|
+
}
|
|
1063
|
+
];
|
|
1064
|
+
baseStore.setState((prev) => ({
|
|
1065
|
+
...prev,
|
|
1066
|
+
scopeStack: newStack,
|
|
1067
|
+
query: ""
|
|
1068
|
+
}));
|
|
1069
|
+
};
|
|
1070
|
+
navigationStore.navigateBack = () => {
|
|
1071
|
+
const state = baseStore.state;
|
|
1072
|
+
if (state.scopeStack.length <= 1) {
|
|
1073
|
+
return;
|
|
1074
|
+
}
|
|
1075
|
+
const newStack = state.scopeStack.slice(0, -1);
|
|
1076
|
+
baseStore.setState((prev) => ({
|
|
1077
|
+
...prev,
|
|
1078
|
+
scopeStack: newStack,
|
|
1079
|
+
query: ""
|
|
1080
|
+
}));
|
|
1081
|
+
};
|
|
1082
|
+
navigationStore.setQuery = (query) => {
|
|
1083
|
+
baseStore.setState((prev) => ({ ...prev, query }));
|
|
1084
|
+
};
|
|
1085
|
+
navigationStore.open = () => {
|
|
1086
|
+
baseStore.setState(() => ({
|
|
1087
|
+
scopeStack: [{ scope: "root", selectedIndex: 0 }],
|
|
1088
|
+
query: "",
|
|
1089
|
+
isActive: true
|
|
1090
|
+
}));
|
|
1091
|
+
};
|
|
1092
|
+
navigationStore.close = () => {
|
|
1093
|
+
baseStore.setState(() => ({
|
|
1094
|
+
scopeStack: [{ scope: "root", selectedIndex: 0 }],
|
|
1095
|
+
query: "",
|
|
1096
|
+
isActive: false
|
|
1097
|
+
}));
|
|
1098
|
+
};
|
|
1099
|
+
return navigationStore;
|
|
1100
|
+
});
|
|
1101
|
+
return store;
|
|
1102
|
+
}
|
|
1103
|
+
function clearTextAfterTrigger(editor) {
|
|
1104
|
+
const { state } = editor;
|
|
1105
|
+
const { from: cursorPos } = state.selection;
|
|
1106
|
+
const backwardText = state.doc.textBetween(0, cursorPos, void 0, "");
|
|
1107
|
+
const triggerIndex = backwardText.lastIndexOf("@");
|
|
1108
|
+
if (triggerIndex === -1) return;
|
|
1109
|
+
const offset2 = backwardText.length - triggerIndex;
|
|
1110
|
+
const from = cursorPos - offset2 + 1;
|
|
1111
|
+
const to = cursorPos;
|
|
1112
|
+
if (from < to) {
|
|
1113
|
+
const tr = state.tr.deleteRange(from, to);
|
|
1114
|
+
editor.view.dispatch(tr);
|
|
1115
|
+
}
|
|
1116
|
+
}
|
|
1117
|
+
const MentionSuggestionList = forwardRef(({ store, editor, query, command, closeMenu }, ref) => {
|
|
1118
|
+
const [selectedIndexOverride, setSelectedIndexOverride] = useState(null);
|
|
1119
|
+
const navStore = useMenuNavigation();
|
|
1120
|
+
const currentScopeId = useStore(navStore, (s) => getCurrentScope(s));
|
|
1121
|
+
const navSelectedIndex = useStore(navStore, (s) => getSelectedIndex(s));
|
|
1122
|
+
const selectedIndex = selectedIndexOverride ?? navSelectedIndex;
|
|
1123
|
+
const scopeStack = useStore(navStore, (s) => s.scopeStack);
|
|
1124
|
+
let effectiveScopeId = currentScopeId;
|
|
1125
|
+
if (query) {
|
|
1126
|
+
try {
|
|
1127
|
+
const searchScope = getSearchScope(store.state.registry, currentScopeId);
|
|
1128
|
+
if (searchScope) {
|
|
1129
|
+
effectiveScopeId = searchScope;
|
|
1130
|
+
}
|
|
1131
|
+
} catch {
|
|
1132
|
+
}
|
|
1133
|
+
}
|
|
1134
|
+
const { items, isFetching, hasMore, loadMore } = useMenuItems(store, {
|
|
1135
|
+
scope: effectiveScopeId,
|
|
1136
|
+
query,
|
|
1137
|
+
minItems: 50,
|
|
1138
|
+
parentScope: currentScopeId !== effectiveScopeId ? currentScopeId : void 0
|
|
1139
|
+
});
|
|
1140
|
+
useEffect(() => {
|
|
1141
|
+
setSelectedIndexOverride(null);
|
|
1142
|
+
}, [query, effectiveScopeId]);
|
|
1143
|
+
const scopePath = scopeStack.map((entry) => ({
|
|
1144
|
+
id: entry.scope,
|
|
1145
|
+
name: entry.breadcrumbLabel ?? getScopeName(entry.scope, store)
|
|
1146
|
+
}));
|
|
1147
|
+
const handleSelect = useCallback(
|
|
1148
|
+
(item) => {
|
|
1149
|
+
if (item.navigatesToScope) {
|
|
1150
|
+
navStore.navigateTo(item.navigatesToScope, selectedIndex, {
|
|
1151
|
+
breadcrumbLabel: item.name,
|
|
1152
|
+
parentScope: currentScopeId
|
|
1153
|
+
});
|
|
1154
|
+
clearTextAfterTrigger(editor);
|
|
1155
|
+
setSelectedIndexOverride(null);
|
|
1156
|
+
return;
|
|
1157
|
+
}
|
|
1158
|
+
command(item);
|
|
1159
|
+
},
|
|
1160
|
+
[command, editor, navStore, selectedIndex, currentScopeId]
|
|
1161
|
+
);
|
|
1162
|
+
const handleBack = useCallback(() => {
|
|
1163
|
+
navStore.navigateBack();
|
|
1164
|
+
clearTextAfterTrigger(editor);
|
|
1165
|
+
setSelectedIndexOverride(null);
|
|
1166
|
+
}, [editor, navStore]);
|
|
1167
|
+
const handleBreadcrumbNavigate = useCallback(
|
|
1168
|
+
(targetScopeId) => {
|
|
1169
|
+
const targetIdx = scopeStack.findIndex((entry) => entry.scope === targetScopeId);
|
|
1170
|
+
if (targetIdx >= 0) {
|
|
1171
|
+
const popsNeeded = scopeStack.length - 1 - targetIdx;
|
|
1172
|
+
for (let i = 0; i < popsNeeded; i++) {
|
|
1173
|
+
navStore.navigateBack();
|
|
1174
|
+
}
|
|
1175
|
+
clearTextAfterTrigger(editor);
|
|
1176
|
+
setSelectedIndexOverride(null);
|
|
1177
|
+
}
|
|
1178
|
+
},
|
|
1179
|
+
[editor, navStore, scopeStack]
|
|
1180
|
+
);
|
|
1181
|
+
useKeyboardNavigation(ref, {
|
|
1182
|
+
items,
|
|
1183
|
+
selectedIndex,
|
|
1184
|
+
onSelect: handleSelect,
|
|
1185
|
+
onBack: currentScopeId !== "root" ? handleBack : void 0,
|
|
1186
|
+
onClose: () => closeMenu(true),
|
|
1187
|
+
setSelectedIndex: (idx) => {
|
|
1188
|
+
setSelectedIndexOverride(idx);
|
|
1189
|
+
}
|
|
1190
|
+
});
|
|
1191
|
+
return /* @__PURE__ */ jsxs("div", { className: "bg-white border border-gray-300 rounded shadow-lg min-w-[280px] max-w-[380px] max-h-[320px] flex flex-col", children: [
|
|
1192
|
+
/* @__PURE__ */ jsx("div", { className: "flex-1 overflow-y-auto", children: /* @__PURE__ */ jsx(
|
|
1193
|
+
MenuList,
|
|
1194
|
+
{
|
|
1195
|
+
items,
|
|
1196
|
+
selectedIndex,
|
|
1197
|
+
isLoading: isFetching,
|
|
1198
|
+
hasMore,
|
|
1199
|
+
onSelect: handleSelect,
|
|
1200
|
+
onMouseEnter: (idx) => {
|
|
1201
|
+
setSelectedIndexOverride(idx);
|
|
1202
|
+
},
|
|
1203
|
+
onLoadMore: loadMore
|
|
1204
|
+
}
|
|
1205
|
+
) }),
|
|
1206
|
+
/* @__PURE__ */ jsx(
|
|
1207
|
+
MenuSummary,
|
|
1208
|
+
{
|
|
1209
|
+
scopePath,
|
|
1210
|
+
onNavigate: handleBreadcrumbNavigate,
|
|
1211
|
+
onBackClick: currentScopeId !== "root" ? handleBack : void 0,
|
|
1212
|
+
isFetching
|
|
1213
|
+
}
|
|
1214
|
+
)
|
|
1215
|
+
] });
|
|
1216
|
+
});
|
|
1217
|
+
MentionSuggestionList.displayName = "MentionSuggestionList";
|
|
1218
|
+
function assetToMenuItem(asset) {
|
|
1219
|
+
const isFolder = asset.athenaOriginalType === "folder";
|
|
1220
|
+
return {
|
|
1221
|
+
id: asset.id,
|
|
1222
|
+
name: asset.title || "Untitled",
|
|
1223
|
+
type: isFolder ? "folder" : "asset",
|
|
1224
|
+
thumbnailUrl: assetTypeToThumb(asset.athenaOriginalType),
|
|
1225
|
+
fallbackIcon: assetTypeToIcon(asset.athenaOriginalType),
|
|
1226
|
+
navigatesToScope: isFolder ? asset.id : void 0,
|
|
1227
|
+
visibleInScopes: /* @__PURE__ */ new Set(),
|
|
1228
|
+
updatedAt: asset.updatedAt ?? void 0,
|
|
1229
|
+
extra: {
|
|
1230
|
+
athenaOriginalType: asset.athenaOriginalType,
|
|
1231
|
+
parentFolderId: asset.parentFolderId
|
|
1232
|
+
}
|
|
1233
|
+
};
|
|
1234
|
+
}
|
|
1235
|
+
async function querySimpleSearch(auth, opts) {
|
|
1236
|
+
var _a, _b;
|
|
1237
|
+
const searchRequest = {
|
|
1238
|
+
query: ((_a = opts.query) == null ? void 0 : _a.trim()) || "",
|
|
1239
|
+
type: opts.includeTypes || [],
|
|
1240
|
+
notType: opts.excludeTypes || [],
|
|
1241
|
+
limit: opts.limit,
|
|
1242
|
+
offset: opts.offset
|
|
1243
|
+
};
|
|
1244
|
+
const input = {
|
|
1245
|
+
searchRequest,
|
|
1246
|
+
returnFullAsset: true,
|
|
1247
|
+
shouldCalculateTotal: false,
|
|
1248
|
+
sort: { field: "UPDATED_AT", direction: "DESC" },
|
|
1249
|
+
filterColumns: { isArchived: false, isHidden: false }
|
|
1250
|
+
};
|
|
1251
|
+
const data = await fetchGraphQL(
|
|
1252
|
+
auth,
|
|
1253
|
+
SIMPLE_SEARCH_QUERY,
|
|
1254
|
+
{ input }
|
|
1255
|
+
);
|
|
1256
|
+
const assets = ((_b = data.simpleSearch) == null ? void 0 : _b.assets) || [];
|
|
1257
|
+
return {
|
|
1258
|
+
items: assets.map(assetToMenuItem),
|
|
1259
|
+
hasMore: assets.length === opts.limit
|
|
1260
|
+
};
|
|
1261
|
+
}
|
|
1262
|
+
const CATEGORY_DEFS = {
|
|
1263
|
+
favorites: { name: "Favorites", icon: "star", scope: "favorites" },
|
|
1264
|
+
assets: { name: "Assets", icon: "file-text", scope: "athena_assets" },
|
|
1265
|
+
projects: { name: "Projects", icon: "folder-kanban", scope: "athena_projects" },
|
|
1266
|
+
browse_profiles: { name: "Browse Profiles", icon: "globe", scope: "athena_browse_profiles" },
|
|
1267
|
+
folders: { name: "Folders", icon: "folder", scope: "athena_folders" },
|
|
1268
|
+
team: { name: "Team", icon: "users", scope: "team" },
|
|
1269
|
+
drives: { name: "Drives", icon: "hard-drive", scope: "drive_catalogs" }
|
|
1270
|
+
};
|
|
1271
|
+
function webpageDescription(webpage) {
|
|
1272
|
+
try {
|
|
1273
|
+
const hostname = new URL(webpage.url).hostname;
|
|
1274
|
+
return webpage.isCurrent ? `${webpage.title} · ${hostname}` : hostname;
|
|
1275
|
+
} catch {
|
|
1276
|
+
return webpage.title;
|
|
1277
|
+
}
|
|
1278
|
+
}
|
|
1279
|
+
function webpageToMenuItem(webpage) {
|
|
1280
|
+
return {
|
|
1281
|
+
id: `webpage-tab-${webpage.tabId}`,
|
|
1282
|
+
name: webpage.isCurrent ? "This webpage" : webpage.title,
|
|
1283
|
+
type: "tab",
|
|
1284
|
+
thumbnailUrl: assetTypeToThumb("web_page"),
|
|
1285
|
+
fallbackIcon: "globe",
|
|
1286
|
+
visibleInScopes: /* @__PURE__ */ new Set(["root"]),
|
|
1287
|
+
description: webpageDescription(webpage),
|
|
1288
|
+
url: webpage.url,
|
|
1289
|
+
menuSection: webpage.isCurrent ? MentionMenuSection.CURRENT_WEBPAGE : MentionMenuSection.OTHER_WEBPAGES,
|
|
1290
|
+
extra: {
|
|
1291
|
+
tabId: webpage.tabId,
|
|
1292
|
+
title: webpage.title,
|
|
1293
|
+
isCurrent: webpage.isCurrent
|
|
1294
|
+
}
|
|
1295
|
+
};
|
|
1296
|
+
}
|
|
1297
|
+
function buildRootMenuItems({
|
|
1298
|
+
categories,
|
|
1299
|
+
webpages
|
|
1300
|
+
}) {
|
|
1301
|
+
const webpageItems = webpages.map(webpageToMenuItem);
|
|
1302
|
+
const categoryItems = categories.filter((cat) => CATEGORY_DEFS[cat]).map((cat) => {
|
|
1303
|
+
const def = CATEGORY_DEFS[cat];
|
|
1304
|
+
return {
|
|
1305
|
+
id: cat,
|
|
1306
|
+
name: def.name,
|
|
1307
|
+
type: "menu",
|
|
1308
|
+
fallbackIcon: def.icon,
|
|
1309
|
+
visibleInScopes: /* @__PURE__ */ new Set(["root"]),
|
|
1310
|
+
navigatesToScope: def.scope,
|
|
1311
|
+
isNavigationOnly: true,
|
|
1312
|
+
menuSection: MentionMenuSection.LIBRARY
|
|
1313
|
+
};
|
|
1314
|
+
});
|
|
1315
|
+
return [...webpageItems, ...categoryItems];
|
|
1316
|
+
}
|
|
1317
|
+
const transformRootCategories = async (context) => {
|
|
1318
|
+
const { sourceConfig } = context;
|
|
1319
|
+
const items = buildRootMenuItems({
|
|
1320
|
+
categories: sourceConfig.categories,
|
|
1321
|
+
webpages: sourceConfig.getWebpages()
|
|
1322
|
+
});
|
|
1323
|
+
return { items, pagination: { hasMore: false } };
|
|
1324
|
+
};
|
|
1325
|
+
const fetchAssets = async (context) => {
|
|
1326
|
+
const { query, fetchState, sourceConfig } = context;
|
|
1327
|
+
const limit = sourceConfig.limit ?? 50;
|
|
1328
|
+
const meta = fetchState.meta || {};
|
|
1329
|
+
const offset2 = meta.validatedCount || 0;
|
|
1330
|
+
const result = await querySimpleSearch(sourceConfig.auth, {
|
|
1331
|
+
query,
|
|
1332
|
+
limit,
|
|
1333
|
+
offset: offset2,
|
|
1334
|
+
excludeTypes: ["folder", "catalog", "spaces", "session", "table", "task_item"]
|
|
1335
|
+
});
|
|
1336
|
+
return {
|
|
1337
|
+
items: result.items,
|
|
1338
|
+
pagination: { hasMore: result.hasMore }
|
|
1339
|
+
};
|
|
1340
|
+
};
|
|
1341
|
+
const fetchFavorites = async (context) => {
|
|
1342
|
+
const { query, fetchState, sourceConfig } = context;
|
|
1343
|
+
const limit = sourceConfig.limit ?? 50;
|
|
1344
|
+
const meta = fetchState.meta || {};
|
|
1345
|
+
const offset2 = meta.validatedCount || 0;
|
|
1346
|
+
const data = await fetchGraphQL(
|
|
1347
|
+
sourceConfig.auth,
|
|
1348
|
+
PAGINATED_ASSETS_QUERY,
|
|
1349
|
+
{
|
|
1350
|
+
limit,
|
|
1351
|
+
offset: offset2,
|
|
1352
|
+
parentFolderId: null,
|
|
1353
|
+
filterTypes: null,
|
|
1354
|
+
filterColumns: {
|
|
1355
|
+
isFavorited: true,
|
|
1356
|
+
isArchived: false,
|
|
1357
|
+
isHidden: false
|
|
1358
|
+
}
|
|
1359
|
+
}
|
|
1360
|
+
);
|
|
1361
|
+
const assets = data.getPaginatedAssetsForWorkspace || [];
|
|
1362
|
+
const items = assets.map(assetToMenuItem);
|
|
1363
|
+
return {
|
|
1364
|
+
items,
|
|
1365
|
+
pagination: { hasMore: assets.length === limit }
|
|
1366
|
+
};
|
|
1367
|
+
};
|
|
1368
|
+
const fetchFolders = async (context) => {
|
|
1369
|
+
const { query, fetchState, sourceConfig } = context;
|
|
1370
|
+
const limit = sourceConfig.limit ?? 50;
|
|
1371
|
+
const meta = fetchState.meta || {};
|
|
1372
|
+
const offset2 = meta.validatedCount || 0;
|
|
1373
|
+
const result = await querySimpleSearch(sourceConfig.auth, {
|
|
1374
|
+
query,
|
|
1375
|
+
limit,
|
|
1376
|
+
offset: offset2,
|
|
1377
|
+
includeTypes: ["folder"]
|
|
1378
|
+
});
|
|
1379
|
+
return {
|
|
1380
|
+
items: result.items,
|
|
1381
|
+
pagination: { hasMore: result.hasMore }
|
|
1382
|
+
};
|
|
1383
|
+
};
|
|
1384
|
+
const fetchFolderContents = async (context) => {
|
|
1385
|
+
const { scope, query, fetchState, sourceConfig } = context;
|
|
1386
|
+
const limit = sourceConfig.limit ?? 50;
|
|
1387
|
+
const meta = fetchState.meta || {};
|
|
1388
|
+
const offset2 = meta.validatedCount || 0;
|
|
1389
|
+
const parentFolderId = scope === "internal_drive" ? null : scope;
|
|
1390
|
+
const data = await fetchGraphQL(
|
|
1391
|
+
sourceConfig.auth,
|
|
1392
|
+
PAGINATED_ASSETS_QUERY,
|
|
1393
|
+
{
|
|
1394
|
+
limit,
|
|
1395
|
+
offset: offset2,
|
|
1396
|
+
parentFolderId,
|
|
1397
|
+
filterTypes: null,
|
|
1398
|
+
filterColumns: {
|
|
1399
|
+
isArchived: false,
|
|
1400
|
+
isHidden: false,
|
|
1401
|
+
...query ? { title: [{ op: "LIKE", value: `%${query}%` }] } : {}
|
|
1402
|
+
}
|
|
1403
|
+
}
|
|
1404
|
+
);
|
|
1405
|
+
const rawAssets = data.getPaginatedAssetsForWorkspace || [];
|
|
1406
|
+
const assets = rawAssets.filter(
|
|
1407
|
+
(a) => a.athenaConvertedType !== "catalog" && a.athenaOriginalType !== "catalog"
|
|
1408
|
+
);
|
|
1409
|
+
const items = assets.map(assetToMenuItem);
|
|
1410
|
+
return {
|
|
1411
|
+
items,
|
|
1412
|
+
pagination: {
|
|
1413
|
+
hasMore: rawAssets.length === limit,
|
|
1414
|
+
consumedCount: rawAssets.length
|
|
1415
|
+
}
|
|
1416
|
+
};
|
|
1417
|
+
};
|
|
1418
|
+
const fetchTypedAssets = async (context) => {
|
|
1419
|
+
const { query, fetchState, sourceConfig } = context;
|
|
1420
|
+
const limit = sourceConfig.limit ?? 50;
|
|
1421
|
+
const meta = fetchState.meta || {};
|
|
1422
|
+
const offset2 = meta.validatedCount || 0;
|
|
1423
|
+
const result = await querySimpleSearch(sourceConfig.auth, {
|
|
1424
|
+
query,
|
|
1425
|
+
limit,
|
|
1426
|
+
offset: offset2,
|
|
1427
|
+
includeTypes: sourceConfig.includeOnlyTypes
|
|
1428
|
+
});
|
|
1429
|
+
return {
|
|
1430
|
+
items: result.items,
|
|
1431
|
+
pagination: { hasMore: result.hasMore }
|
|
1432
|
+
};
|
|
1433
|
+
};
|
|
1434
|
+
const fetchTeam = async (context) => {
|
|
1435
|
+
const { sourceConfig } = context;
|
|
1436
|
+
const { auth } = sourceConfig;
|
|
1437
|
+
if (!auth.workspaceId) {
|
|
1438
|
+
return { items: [], pagination: { hasMore: false } };
|
|
1439
|
+
}
|
|
1440
|
+
const data = await fetchGraphQL(
|
|
1441
|
+
auth,
|
|
1442
|
+
WORKSPACE_MEMBERS_QUERY,
|
|
1443
|
+
{ workspaceId: auth.workspaceId }
|
|
1444
|
+
);
|
|
1445
|
+
const members = data.getUsersInWorkspace || [];
|
|
1446
|
+
const items = members.map((member) => {
|
|
1447
|
+
const displayName = [member.firstName, member.lastName].filter(Boolean).join(" ").trim() || member.email || "Unknown User";
|
|
1448
|
+
return {
|
|
1449
|
+
id: member.email || member.id,
|
|
1450
|
+
name: displayName,
|
|
1451
|
+
type: "user",
|
|
1452
|
+
fallbackIcon: "user",
|
|
1453
|
+
visibleInScopes: /* @__PURE__ */ new Set(),
|
|
1454
|
+
email: member.email ?? void 0,
|
|
1455
|
+
extra: { isAdmin: member.isAdmin }
|
|
1456
|
+
};
|
|
1457
|
+
});
|
|
1458
|
+
return { items, pagination: { hasMore: false } };
|
|
1459
|
+
};
|
|
1460
|
+
const fetchDrives = async (context) => {
|
|
1461
|
+
const { fetchState, sourceConfig } = context;
|
|
1462
|
+
const meta = fetchState.meta || {};
|
|
1463
|
+
const offset2 = meta.validatedCount || 0;
|
|
1464
|
+
const result = await querySimpleSearch(sourceConfig.auth, {
|
|
1465
|
+
limit: 50,
|
|
1466
|
+
offset: offset2,
|
|
1467
|
+
includeTypes: ["catalog"]
|
|
1468
|
+
});
|
|
1469
|
+
const items = result.items.map((item) => ({
|
|
1470
|
+
...item,
|
|
1471
|
+
type: "drive_catalog",
|
|
1472
|
+
fallbackIcon: "hard-drive",
|
|
1473
|
+
isNavigationOnly: true,
|
|
1474
|
+
navigatesToScope: item.id
|
|
1475
|
+
}));
|
|
1476
|
+
const sources = items.map((item) => ({
|
|
1477
|
+
scope: item.id,
|
|
1478
|
+
sourceFn: fetchFolderContents,
|
|
1479
|
+
sourceConfig: { auth: sourceConfig.auth, limit: 50 }
|
|
1480
|
+
}));
|
|
1481
|
+
return {
|
|
1482
|
+
items,
|
|
1483
|
+
pagination: { hasMore: result.hasMore },
|
|
1484
|
+
sources
|
|
1485
|
+
};
|
|
1486
|
+
};
|
|
1487
|
+
const fetchGlobalSearch = async (context) => {
|
|
1488
|
+
const { query, fetchState, sourceConfig } = context;
|
|
1489
|
+
if (!(query == null ? void 0 : query.trim())) return { items: [], pagination: { hasMore: false } };
|
|
1490
|
+
const meta = fetchState.meta || {};
|
|
1491
|
+
const offset2 = meta.validatedCount || 0;
|
|
1492
|
+
const result = await querySimpleSearch(sourceConfig.auth, {
|
|
1493
|
+
query,
|
|
1494
|
+
limit: 50,
|
|
1495
|
+
offset: offset2,
|
|
1496
|
+
excludeTypes: ["table", "catalog", "spaces", "task_item", "session"]
|
|
1497
|
+
});
|
|
1498
|
+
return {
|
|
1499
|
+
items: result.items,
|
|
1500
|
+
pagination: { hasMore: result.hasMore }
|
|
1501
|
+
};
|
|
1502
|
+
};
|
|
1503
|
+
function webpageMentionFingerprint(webpages) {
|
|
1504
|
+
return JSON.stringify(
|
|
1505
|
+
webpages.map(({ tabId, title, url, isCurrent }) => [
|
|
1506
|
+
tabId,
|
|
1507
|
+
title,
|
|
1508
|
+
url,
|
|
1509
|
+
isCurrent
|
|
1510
|
+
])
|
|
1511
|
+
);
|
|
1512
|
+
}
|
|
1513
|
+
const ROOT_MENTION_CATEGORIES = [
|
|
1514
|
+
"favorites",
|
|
1515
|
+
"assets",
|
|
1516
|
+
"projects",
|
|
1517
|
+
"browse_profiles",
|
|
1518
|
+
"folders",
|
|
1519
|
+
"team",
|
|
1520
|
+
"drives"
|
|
1521
|
+
];
|
|
1522
|
+
function buildStore({
|
|
1523
|
+
auth,
|
|
1524
|
+
getWebpages,
|
|
1525
|
+
rootCategories
|
|
1526
|
+
}) {
|
|
1527
|
+
const registry = createScopeRegistry();
|
|
1528
|
+
const cache = createItemCache();
|
|
1529
|
+
registerSource(registry, "root", transformRootCategories, {
|
|
1530
|
+
categories: [...rootCategories],
|
|
1531
|
+
getWebpages
|
|
1532
|
+
});
|
|
1533
|
+
registerSource(registry, "global_search", fetchGlobalSearch, { auth });
|
|
1534
|
+
bindScopes(registry, "root", "global_search");
|
|
1535
|
+
registerSource(registry, "athena_assets", fetchAssets, { auth, limit: 50 });
|
|
1536
|
+
registerSource(registry, "favorites", fetchFavorites, { auth, limit: 50 });
|
|
1537
|
+
registerSource(
|
|
1538
|
+
registry,
|
|
1539
|
+
"athena_folders",
|
|
1540
|
+
fetchFolders,
|
|
1541
|
+
{ auth, limit: 50 },
|
|
1542
|
+
true
|
|
1543
|
+
/* isFlat */
|
|
1544
|
+
);
|
|
1545
|
+
registerSource(registry, "internal_drive", fetchFolderContents, { auth, limit: 50 });
|
|
1546
|
+
registerSource(registry, "athena_projects", fetchTypedAssets, {
|
|
1547
|
+
auth,
|
|
1548
|
+
includeOnlyTypes: ["project"],
|
|
1549
|
+
limit: 50
|
|
1550
|
+
});
|
|
1551
|
+
registerSource(registry, "athena_browse_profiles", fetchTypedAssets, {
|
|
1552
|
+
auth,
|
|
1553
|
+
includeOnlyTypes: ["browse_profile"],
|
|
1554
|
+
limit: 50
|
|
1555
|
+
});
|
|
1556
|
+
registerSource(registry, "team", fetchTeam, { auth });
|
|
1557
|
+
registerSource(registry, "drive_catalogs", fetchDrives, { auth });
|
|
1558
|
+
return new Store({ registry, cache });
|
|
1559
|
+
}
|
|
1560
|
+
function useMentionSuggestions({
|
|
1561
|
+
webpages,
|
|
1562
|
+
rootCategories = ROOT_MENTION_CATEGORIES
|
|
1563
|
+
}) {
|
|
1564
|
+
const auth = useMentionAuth();
|
|
1565
|
+
const webpagesRef = useRef(webpages);
|
|
1566
|
+
webpagesRef.current = webpages;
|
|
1567
|
+
const store = useMemo(
|
|
1568
|
+
() => buildStore({
|
|
1569
|
+
auth,
|
|
1570
|
+
getWebpages: () => webpagesRef.current,
|
|
1571
|
+
rootCategories
|
|
1572
|
+
}),
|
|
1573
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1574
|
+
[
|
|
1575
|
+
auth.backendUrl,
|
|
1576
|
+
auth.accessToken,
|
|
1577
|
+
auth.apiKey,
|
|
1578
|
+
auth.workspaceId,
|
|
1579
|
+
auth.userId,
|
|
1580
|
+
rootCategories.join(",")
|
|
1581
|
+
]
|
|
1582
|
+
);
|
|
1583
|
+
const invalidate = useMemo(
|
|
1584
|
+
() => (scope) => {
|
|
1585
|
+
const state = store.state;
|
|
1586
|
+
const { registry, cache } = state;
|
|
1587
|
+
if (cache.items) {
|
|
1588
|
+
for (const item of Object.values(cache.items)) {
|
|
1589
|
+
item.visibleInScopes.delete(scope);
|
|
1590
|
+
}
|
|
1591
|
+
for (const [id, item] of Object.entries(cache.items)) {
|
|
1592
|
+
if (item.visibleInScopes.size === 0) {
|
|
1593
|
+
delete cache.items[id];
|
|
1594
|
+
}
|
|
1595
|
+
}
|
|
1596
|
+
}
|
|
1597
|
+
if (registry.entries[scope]) {
|
|
1598
|
+
registry.entries[scope].fetchStates = {};
|
|
1599
|
+
}
|
|
1600
|
+
store.setState((prev) => ({ ...prev }));
|
|
1601
|
+
},
|
|
1602
|
+
[store]
|
|
1603
|
+
);
|
|
1604
|
+
const webpageFingerprint = webpageMentionFingerprint(webpages);
|
|
1605
|
+
const previousWebpageFingerprintRef = useRef(null);
|
|
1606
|
+
useEffect(() => {
|
|
1607
|
+
if (previousWebpageFingerprintRef.current === webpageFingerprint) return;
|
|
1608
|
+
previousWebpageFingerprintRef.current = webpageFingerprint;
|
|
1609
|
+
invalidate("root");
|
|
1610
|
+
}, [invalidate, webpageFingerprint]);
|
|
1611
|
+
return { store, invalidate };
|
|
1612
|
+
}
|
|
1613
|
+
class PendingAttachmentUploads {
|
|
1614
|
+
constructor() {
|
|
1615
|
+
__publicField(this, "pending", /* @__PURE__ */ new Set());
|
|
1616
|
+
}
|
|
1617
|
+
track(upload) {
|
|
1618
|
+
this.pending.add(upload);
|
|
1619
|
+
void upload.then(
|
|
1620
|
+
() => this.pending.delete(upload),
|
|
1621
|
+
() => this.pending.delete(upload)
|
|
1622
|
+
);
|
|
1623
|
+
return upload;
|
|
1624
|
+
}
|
|
1625
|
+
async waitForIdle() {
|
|
1626
|
+
while (this.pending.size > 0) {
|
|
1627
|
+
await Promise.allSettled([...this.pending]);
|
|
1628
|
+
}
|
|
1629
|
+
}
|
|
1630
|
+
}
|
|
1631
|
+
const SubmitKeybind = Extension.create({
|
|
1632
|
+
name: "submitKeybind",
|
|
1633
|
+
priority: 1e3,
|
|
1634
|
+
addOptions() {
|
|
1635
|
+
return { onSubmit: () => {
|
|
1636
|
+
}, isMentionOpen: () => false };
|
|
1637
|
+
},
|
|
1638
|
+
addKeyboardShortcuts() {
|
|
1639
|
+
return {
|
|
1640
|
+
Enter: () => {
|
|
1641
|
+
if (this.options.isMentionOpen()) return false;
|
|
1642
|
+
this.options.onSubmit();
|
|
1643
|
+
return true;
|
|
1644
|
+
},
|
|
1645
|
+
"Shift-Enter": () => {
|
|
1646
|
+
this.editor.commands.setHardBreak();
|
|
1647
|
+
return true;
|
|
1648
|
+
}
|
|
1649
|
+
};
|
|
1650
|
+
}
|
|
1651
|
+
});
|
|
1652
|
+
const MENTION_STYLES = `
|
|
1653
|
+
.mention-chip {
|
|
1654
|
+
display: inline-flex;
|
|
1655
|
+
align-items: center;
|
|
1656
|
+
gap: 4px;
|
|
1657
|
+
background: rgba(148, 163, 184, 0.1);
|
|
1658
|
+
color: #475569;
|
|
1659
|
+
border: 1px solid #cbd5e1;
|
|
1660
|
+
border-radius: 6px;
|
|
1661
|
+
padding: 1px 6px;
|
|
1662
|
+
font-size: 0.85em;
|
|
1663
|
+
font-weight: 500;
|
|
1664
|
+
white-space: nowrap;
|
|
1665
|
+
user-select: all;
|
|
1666
|
+
vertical-align: middle;
|
|
1667
|
+
height: 20px;
|
|
1668
|
+
line-height: 1;
|
|
1669
|
+
}
|
|
1670
|
+
.mention-chip-icon {
|
|
1671
|
+
width: 14px;
|
|
1672
|
+
height: 14px;
|
|
1673
|
+
flex-shrink: 0;
|
|
1674
|
+
}
|
|
1675
|
+
.mention-chip-text {
|
|
1676
|
+
white-space: nowrap;
|
|
1677
|
+
overflow: hidden;
|
|
1678
|
+
text-overflow: ellipsis;
|
|
1679
|
+
max-width: 180px;
|
|
1680
|
+
}
|
|
1681
|
+
.ProseMirror {
|
|
1682
|
+
outline: none;
|
|
1683
|
+
min-height: 36px;
|
|
1684
|
+
max-height: 120px;
|
|
1685
|
+
overflow-y: auto;
|
|
1686
|
+
}
|
|
1687
|
+
.ProseMirror p {
|
|
1688
|
+
margin: 0;
|
|
1689
|
+
}
|
|
1690
|
+
.ProseMirror p.is-editor-empty:first-child::before {
|
|
1691
|
+
content: attr(data-placeholder);
|
|
1692
|
+
float: left;
|
|
1693
|
+
color: #9ca3af;
|
|
1694
|
+
pointer-events: none;
|
|
1695
|
+
height: 0;
|
|
1696
|
+
}
|
|
1697
|
+
`;
|
|
1698
|
+
function plainTextToTiptapContent(text) {
|
|
1699
|
+
return {
|
|
1700
|
+
type: "doc",
|
|
1701
|
+
content: text.split("\n").map((line) => ({
|
|
1702
|
+
type: "paragraph",
|
|
1703
|
+
...line.length > 0 ? { content: [{ type: "text", text: line }] } : {}
|
|
1704
|
+
}))
|
|
1705
|
+
};
|
|
1706
|
+
}
|
|
1707
|
+
const NO_WEBPAGES = [];
|
|
1708
|
+
const TiptapComposer = forwardRef(({ placeholder = "Message Athena... (type @ to mention)", threadId, disabled = false, webpages = NO_WEBPAGES, rootCategories, onDraftStateChange }, outerRef) => {
|
|
1709
|
+
const aui = useAui();
|
|
1710
|
+
const composerInput = unstable_useComposerInput();
|
|
1711
|
+
const applyingRuntimeTextRef = useRef(false);
|
|
1712
|
+
const listRef = useRef(null);
|
|
1713
|
+
const pendingUploadsRef = useRef(new PendingAttachmentUploads());
|
|
1714
|
+
const submitInFlightRef = useRef(false);
|
|
1715
|
+
const { store } = useMentionSuggestions({ webpages, rootCategories });
|
|
1716
|
+
const [popupOpen, setPopupOpen] = useState(false);
|
|
1717
|
+
const popupOpenRef = useRef(false);
|
|
1718
|
+
const [popupProps, setPopupProps] = useState(null);
|
|
1719
|
+
const callbacksRef = useRef({
|
|
1720
|
+
onStart: (props) => {
|
|
1721
|
+
setPopupOpen(true);
|
|
1722
|
+
popupOpenRef.current = true;
|
|
1723
|
+
setPopupProps(props);
|
|
1724
|
+
},
|
|
1725
|
+
onUpdate: (props) => {
|
|
1726
|
+
setPopupProps(props);
|
|
1727
|
+
},
|
|
1728
|
+
onKeyDown: (event) => {
|
|
1729
|
+
var _a;
|
|
1730
|
+
return ((_a = listRef.current) == null ? void 0 : _a.onKeyDown(event)) ?? false;
|
|
1731
|
+
},
|
|
1732
|
+
onExit: () => {
|
|
1733
|
+
setPopupOpen(false);
|
|
1734
|
+
popupOpenRef.current = false;
|
|
1735
|
+
setPopupProps(null);
|
|
1736
|
+
}
|
|
1737
|
+
});
|
|
1738
|
+
const editorRef = useRef(null);
|
|
1739
|
+
const handleSubmit = useCallback(async () => {
|
|
1740
|
+
if (disabled) return;
|
|
1741
|
+
if (submitInFlightRef.current) return;
|
|
1742
|
+
submitInFlightRef.current = true;
|
|
1743
|
+
try {
|
|
1744
|
+
await pendingUploadsRef.current.waitForIdle();
|
|
1745
|
+
const ed = editorRef.current;
|
|
1746
|
+
if (!ed) return;
|
|
1747
|
+
const text = ed.getText({ blockSeparator: "\n" }).trim();
|
|
1748
|
+
if (!text) return;
|
|
1749
|
+
if (!composerInput.canSend) return;
|
|
1750
|
+
composerInput.setText(text);
|
|
1751
|
+
composerInput.send({ steer: false });
|
|
1752
|
+
ed.commands.clearContent();
|
|
1753
|
+
onDraftStateChange == null ? void 0 : onDraftStateChange(false);
|
|
1754
|
+
} finally {
|
|
1755
|
+
submitInFlightRef.current = false;
|
|
1756
|
+
}
|
|
1757
|
+
}, [composerInput, disabled, onDraftStateChange]);
|
|
1758
|
+
const handleSubmitRef = useRef(handleSubmit);
|
|
1759
|
+
handleSubmitRef.current = handleSubmit;
|
|
1760
|
+
const addAttachment = useCallback(
|
|
1761
|
+
(file) => pendingUploadsRef.current.track(aui.composer.addAttachment(file)),
|
|
1762
|
+
[aui]
|
|
1763
|
+
);
|
|
1764
|
+
const handlePaste = useCallback(
|
|
1765
|
+
(_view, event) => {
|
|
1766
|
+
var _a;
|
|
1767
|
+
const items = (_a = event.clipboardData) == null ? void 0 : _a.items;
|
|
1768
|
+
if (!items) return false;
|
|
1769
|
+
let handled = false;
|
|
1770
|
+
for (const item of items) {
|
|
1771
|
+
if (item.type.startsWith("image/")) {
|
|
1772
|
+
event.preventDefault();
|
|
1773
|
+
const blob = item.getAsFile();
|
|
1774
|
+
if (blob) {
|
|
1775
|
+
const ext = item.type.split("/")[1] || "png";
|
|
1776
|
+
const file = new File([blob], `pasted-image-${Date.now()}.${ext}`, { type: item.type });
|
|
1777
|
+
void addAttachment(file).catch((error) => {
|
|
1778
|
+
console.error("[attach] Pasted image upload failed:", error);
|
|
1779
|
+
});
|
|
1780
|
+
}
|
|
1781
|
+
handled = true;
|
|
1782
|
+
}
|
|
1783
|
+
}
|
|
1784
|
+
return handled;
|
|
1785
|
+
},
|
|
1786
|
+
[addAttachment]
|
|
1787
|
+
);
|
|
1788
|
+
const handleDrop = useCallback(
|
|
1789
|
+
(_view, event) => {
|
|
1790
|
+
var _a;
|
|
1791
|
+
const files = (_a = event.dataTransfer) == null ? void 0 : _a.files;
|
|
1792
|
+
if (!(files == null ? void 0 : files.length)) return false;
|
|
1793
|
+
let handled = false;
|
|
1794
|
+
for (const file of files) {
|
|
1795
|
+
if (file.type.startsWith("image/")) {
|
|
1796
|
+
event.preventDefault();
|
|
1797
|
+
void addAttachment(file).catch((error) => {
|
|
1798
|
+
console.error("[attach] Dropped image upload failed:", error);
|
|
1799
|
+
});
|
|
1800
|
+
handled = true;
|
|
1801
|
+
}
|
|
1802
|
+
}
|
|
1803
|
+
return handled;
|
|
1804
|
+
},
|
|
1805
|
+
[addAttachment]
|
|
1806
|
+
);
|
|
1807
|
+
const editor = useEditor({
|
|
1808
|
+
editable: !disabled,
|
|
1809
|
+
extensions: [
|
|
1810
|
+
StarterKit.configure({
|
|
1811
|
+
heading: false,
|
|
1812
|
+
blockquote: false,
|
|
1813
|
+
bulletList: false,
|
|
1814
|
+
orderedList: false,
|
|
1815
|
+
codeBlock: false,
|
|
1816
|
+
horizontalRule: false
|
|
1817
|
+
}),
|
|
1818
|
+
Placeholder.configure({ placeholder }),
|
|
1819
|
+
MentionExtension,
|
|
1820
|
+
MentionSuggestionsExtension.configure({
|
|
1821
|
+
store,
|
|
1822
|
+
callbacks: callbacksRef.current
|
|
1823
|
+
}),
|
|
1824
|
+
SubmitKeybind.configure({
|
|
1825
|
+
onSubmit: () => void handleSubmitRef.current(),
|
|
1826
|
+
isMentionOpen: () => popupOpenRef.current
|
|
1827
|
+
})
|
|
1828
|
+
],
|
|
1829
|
+
editorProps: {
|
|
1830
|
+
attributes: {
|
|
1831
|
+
class: "w-full resize-none bg-transparent px-1.5 py-2 text-sm leading-snug outline-none"
|
|
1832
|
+
},
|
|
1833
|
+
handlePaste,
|
|
1834
|
+
handleDrop
|
|
1835
|
+
},
|
|
1836
|
+
onUpdate: ({ editor: updatedEditor }) => {
|
|
1837
|
+
const nextText = updatedEditor.getText({ blockSeparator: "\n" });
|
|
1838
|
+
if (!applyingRuntimeTextRef.current) {
|
|
1839
|
+
composerInput.setText(nextText);
|
|
1840
|
+
}
|
|
1841
|
+
onDraftStateChange == null ? void 0 : onDraftStateChange(nextText.trim().length > 0);
|
|
1842
|
+
},
|
|
1843
|
+
immediatelyRender: false
|
|
1844
|
+
});
|
|
1845
|
+
editorRef.current = editor;
|
|
1846
|
+
useEffect(() => {
|
|
1847
|
+
editor == null ? void 0 : editor.setEditable(!disabled);
|
|
1848
|
+
}, [disabled, editor]);
|
|
1849
|
+
useEffect(() => {
|
|
1850
|
+
if (!editor) return;
|
|
1851
|
+
const editorText = editor.getText({ blockSeparator: "\n" });
|
|
1852
|
+
if (editorText === composerInput.value) return;
|
|
1853
|
+
applyingRuntimeTextRef.current = true;
|
|
1854
|
+
editor.commands.setContent(plainTextToTiptapContent(composerInput.value));
|
|
1855
|
+
applyingRuntimeTextRef.current = false;
|
|
1856
|
+
onDraftStateChange == null ? void 0 : onDraftStateChange(composerInput.value.trim().length > 0);
|
|
1857
|
+
}, [composerInput.value, editor, onDraftStateChange]);
|
|
1858
|
+
const insertAssetMention = useCallback((asset) => {
|
|
1859
|
+
const currentEditor = editorRef.current;
|
|
1860
|
+
if (!currentEditor) throw new Error("The chat composer is not ready.");
|
|
1861
|
+
currentEditor.chain().focus().insertContent({
|
|
1862
|
+
type: "mention",
|
|
1863
|
+
attrs: {
|
|
1864
|
+
type: "asset",
|
|
1865
|
+
name: asset.title,
|
|
1866
|
+
id: asset.id,
|
|
1867
|
+
assetType: asset.assetType
|
|
1868
|
+
}
|
|
1869
|
+
}).insertContent(" ").run();
|
|
1870
|
+
}, []);
|
|
1871
|
+
useEffect(
|
|
1872
|
+
() => registerChatAssetMentionHandler(threadId, insertAssetMention),
|
|
1873
|
+
[insertAssetMention, threadId]
|
|
1874
|
+
);
|
|
1875
|
+
useImperativeHandle(
|
|
1876
|
+
outerRef,
|
|
1877
|
+
() => ({ submit: handleSubmit, addAttachment, insertAssetMention }),
|
|
1878
|
+
[addAttachment, handleSubmit, insertAssetMention]
|
|
1879
|
+
);
|
|
1880
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
1881
|
+
/* @__PURE__ */ jsx("style", { children: MENTION_STYLES }),
|
|
1882
|
+
/* @__PURE__ */ jsx(
|
|
1883
|
+
"div",
|
|
1884
|
+
{
|
|
1885
|
+
className: "flex-1 min-w-0",
|
|
1886
|
+
"aria-label": "Message composer",
|
|
1887
|
+
"aria-disabled": disabled,
|
|
1888
|
+
children: /* @__PURE__ */ jsx(EditorContent, { editor })
|
|
1889
|
+
}
|
|
1890
|
+
),
|
|
1891
|
+
popupOpen && popupProps && editor && /* @__PURE__ */ jsx(MentionSuggestionPopup, { clientRect: popupProps.clientRect, children: /* @__PURE__ */ jsx(
|
|
1892
|
+
MentionSuggestionList,
|
|
1893
|
+
{
|
|
1894
|
+
ref: listRef,
|
|
1895
|
+
store,
|
|
1896
|
+
editor,
|
|
1897
|
+
query: popupProps.query,
|
|
1898
|
+
command: (item) => popupProps.command(item),
|
|
1899
|
+
closeMenu: () => {
|
|
1900
|
+
setPopupOpen(false);
|
|
1901
|
+
editor.commands.focus();
|
|
1902
|
+
}
|
|
1903
|
+
}
|
|
1904
|
+
) })
|
|
1905
|
+
] });
|
|
1906
|
+
});
|
|
1907
|
+
TiptapComposer.displayName = "TiptapComposer";
|
|
1908
|
+
const SignInCard = ({
|
|
1909
|
+
buildLabel,
|
|
1910
|
+
subtitle,
|
|
1911
|
+
children,
|
|
1912
|
+
error,
|
|
1913
|
+
notice,
|
|
1914
|
+
primaryLabel,
|
|
1915
|
+
primaryPendingLabel,
|
|
1916
|
+
isPending,
|
|
1917
|
+
disabled = false,
|
|
1918
|
+
onPrimary,
|
|
1919
|
+
footer
|
|
1920
|
+
}) => (
|
|
1921
|
+
// `min-h-full` centers the card in hosts whose root is not a flex container.
|
|
1922
|
+
/* @__PURE__ */ jsx("div", { className: "flex min-h-full flex-1 flex-col items-center justify-center bg-muted/20 p-5", children: /* @__PURE__ */ jsxs("div", { className: "w-full max-w-sm space-y-5 rounded-2xl border bg-background/95 p-5 shadow-sm", children: [
|
|
1923
|
+
/* @__PURE__ */ jsxs("div", { className: "text-center", children: [
|
|
1924
|
+
/* @__PURE__ */ jsx("h2", { className: "text-base font-semibold tracking-tight text-foreground", children: "Sign in to Athena" }),
|
|
1925
|
+
buildLabel ? /* @__PURE__ */ jsx("p", { className: "mt-1 text-[11px] font-medium uppercase tracking-wide text-muted-foreground", children: buildLabel }) : null,
|
|
1926
|
+
subtitle ? /* @__PURE__ */ jsx("p", { className: "mt-1.5 text-xs leading-relaxed text-muted-foreground", children: subtitle }) : null
|
|
1927
|
+
] }),
|
|
1928
|
+
children ? /* @__PURE__ */ jsx("div", { className: "space-y-3", children }) : null,
|
|
1929
|
+
notice ? /* @__PURE__ */ jsx("p", { className: "text-xs leading-relaxed text-muted-foreground", children: notice }) : null,
|
|
1930
|
+
/* @__PURE__ */ jsx("div", { role: "status", "aria-live": "polite", children: error ? /* @__PURE__ */ jsx("p", { className: "text-xs text-destructive", children: error }) : null }),
|
|
1931
|
+
/* @__PURE__ */ jsx(
|
|
1932
|
+
"button",
|
|
1933
|
+
{
|
|
1934
|
+
type: "button",
|
|
1935
|
+
className: "h-10 w-full rounded-lg bg-primary px-4 text-sm font-semibold text-primary-foreground shadow-sm transition-colors hover:bg-primary/90 disabled:cursor-not-allowed disabled:opacity-40",
|
|
1936
|
+
onClick: onPrimary,
|
|
1937
|
+
disabled: isPending || disabled,
|
|
1938
|
+
children: isPending ? primaryPendingLabel : primaryLabel
|
|
1939
|
+
}
|
|
1940
|
+
),
|
|
1941
|
+
footer
|
|
1942
|
+
] }) })
|
|
1943
|
+
);
|
|
1944
|
+
const SignInSelect = ({ id, label, value, options, onChange, hint }) => /* @__PURE__ */ jsxs("div", { className: "space-y-1.5", children: [
|
|
1945
|
+
/* @__PURE__ */ jsx(
|
|
1946
|
+
"label",
|
|
1947
|
+
{
|
|
1948
|
+
htmlFor: id,
|
|
1949
|
+
className: "text-[10px] font-semibold uppercase tracking-wider text-muted-foreground",
|
|
1950
|
+
children: label
|
|
1951
|
+
}
|
|
1952
|
+
),
|
|
1953
|
+
/* @__PURE__ */ jsx(
|
|
1954
|
+
"select",
|
|
1955
|
+
{
|
|
1956
|
+
id,
|
|
1957
|
+
className: "h-10 w-full rounded-lg border bg-background px-3 text-sm outline-none transition-shadow focus:ring-2 focus:ring-ring/20",
|
|
1958
|
+
value,
|
|
1959
|
+
onChange: (event) => onChange(event.target.value),
|
|
1960
|
+
children: options.map((option) => /* @__PURE__ */ jsx("option", { value: option.value, children: option.label }, option.value))
|
|
1961
|
+
}
|
|
1962
|
+
),
|
|
1963
|
+
hint ? /* @__PURE__ */ jsx("p", { className: "px-1 text-[10px] text-muted-foreground", children: hint }) : null
|
|
1964
|
+
] });
|
|
1965
|
+
const SignInTextField = ({ label, placeholder, value, onChange, type = "text", className }) => /* @__PURE__ */ jsxs("label", { className: "block space-y-1", children: [
|
|
1966
|
+
/* @__PURE__ */ jsx("span", { className: "text-[10px] font-semibold uppercase tracking-wide text-muted-foreground", children: label }),
|
|
1967
|
+
/* @__PURE__ */ jsx(
|
|
1968
|
+
"input",
|
|
1969
|
+
{
|
|
1970
|
+
className: cn(
|
|
1971
|
+
"h-9 w-full rounded-md border bg-background px-2.5 text-xs outline-none focus:ring-2 focus:ring-ring/20",
|
|
1972
|
+
className
|
|
1973
|
+
),
|
|
1974
|
+
type,
|
|
1975
|
+
placeholder,
|
|
1976
|
+
value,
|
|
1977
|
+
onChange: (event) => onChange(event.target.value)
|
|
1978
|
+
}
|
|
1979
|
+
)
|
|
1980
|
+
] });
|
|
1981
|
+
const SignInFallbackSection = ({ isOpen, onToggle, label, children }) => {
|
|
1982
|
+
const contentId = useId();
|
|
1983
|
+
return /* @__PURE__ */ jsxs("div", { className: "border-t pt-3", children: [
|
|
1984
|
+
/* @__PURE__ */ jsxs(
|
|
1985
|
+
"button",
|
|
1986
|
+
{
|
|
1987
|
+
type: "button",
|
|
1988
|
+
"aria-expanded": isOpen,
|
|
1989
|
+
"aria-controls": contentId,
|
|
1990
|
+
className: "w-full text-left text-[11px] font-medium text-muted-foreground hover:text-foreground",
|
|
1991
|
+
onClick: onToggle,
|
|
1992
|
+
children: [
|
|
1993
|
+
isOpen ? "Hide" : "Show",
|
|
1994
|
+
" ",
|
|
1995
|
+
label
|
|
1996
|
+
]
|
|
1997
|
+
}
|
|
1998
|
+
),
|
|
1999
|
+
isOpen ? /* @__PURE__ */ jsx("div", { id: contentId, className: "mt-3 space-y-2", children }) : null
|
|
2000
|
+
] });
|
|
2001
|
+
};
|
|
2002
|
+
const SignInSecondaryButton = ({ onClick, disabled = false, children }) => /* @__PURE__ */ jsx(
|
|
2003
|
+
"button",
|
|
2004
|
+
{
|
|
2005
|
+
type: "button",
|
|
2006
|
+
className: "h-9 w-full rounded-lg border bg-background text-xs font-medium hover:bg-muted disabled:opacity-40",
|
|
2007
|
+
disabled,
|
|
2008
|
+
onClick,
|
|
2009
|
+
children
|
|
2010
|
+
}
|
|
2011
|
+
);
|
|
2012
|
+
const SignInConsent = ({ checked, onChange, children }) => /* @__PURE__ */ jsxs("label", { className: "flex cursor-pointer items-start gap-2.5 rounded-lg border bg-muted/30 p-3 text-xs leading-relaxed text-muted-foreground", children: [
|
|
2013
|
+
/* @__PURE__ */ jsx(
|
|
2014
|
+
"input",
|
|
2015
|
+
{
|
|
2016
|
+
type: "checkbox",
|
|
2017
|
+
className: "mt-0.5 h-4 w-4 shrink-0 accent-primary",
|
|
2018
|
+
checked,
|
|
2019
|
+
onChange: (event) => onChange(event.target.checked)
|
|
2020
|
+
}
|
|
2021
|
+
),
|
|
2022
|
+
/* @__PURE__ */ jsx("span", { children })
|
|
2023
|
+
] });
|
|
2024
|
+
export {
|
|
2025
|
+
b8 as BranchPicker,
|
|
2026
|
+
b9 as COMPOSER_DOCK_CLASS,
|
|
2027
|
+
ba as COMPOSER_EDITOR_ROW_CLASS,
|
|
2028
|
+
bb as COMPOSER_SURFACE_CLASS,
|
|
2029
|
+
bc as COMPOSER_TOOLBAR_CLASS,
|
|
2030
|
+
aQ as ChatComposerDock,
|
|
2031
|
+
aP as ChatThreadShell,
|
|
2032
|
+
bd as ComposerSendButton,
|
|
2033
|
+
aR as ComposerSendOrStop,
|
|
2034
|
+
be as ComposerStopButton,
|
|
2035
|
+
bf as IconButton,
|
|
2036
|
+
bg as MarkdownText,
|
|
2037
|
+
bh as MentionAuthCtx,
|
|
2038
|
+
bi as MentionChip,
|
|
2039
|
+
MentionExtension,
|
|
2040
|
+
MentionIcon,
|
|
2041
|
+
bj as MentionLink,
|
|
2042
|
+
MentionMenuSection,
|
|
2043
|
+
MentionSuggestionList,
|
|
2044
|
+
MentionSuggestionPopup,
|
|
2045
|
+
MentionSuggestionsExtension,
|
|
2046
|
+
MenuList,
|
|
2047
|
+
PendingAttachmentUploads,
|
|
2048
|
+
ROOT_MENTION_CATEGORIES,
|
|
2049
|
+
SIMPLE_SEARCH_QUERY,
|
|
2050
|
+
SignInCard,
|
|
2051
|
+
SignInConsent,
|
|
2052
|
+
SignInFallbackSection,
|
|
2053
|
+
SignInSecondaryButton,
|
|
2054
|
+
SignInSelect,
|
|
2055
|
+
SignInTextField,
|
|
2056
|
+
bk as SmallIconButton,
|
|
2057
|
+
bl as THREAD_HEADER_ACTIONS_CLASS,
|
|
2058
|
+
bm as THREAD_HEADER_CLASS,
|
|
2059
|
+
bn as THREAD_HEADER_ICON_CLASS,
|
|
2060
|
+
bo as THREAD_HEADER_PILL_CLASS,
|
|
2061
|
+
bp as THREAD_PANEL_CLASS,
|
|
2062
|
+
bq as THREAD_SCROLL_TO_BOTTOM_CLASS,
|
|
2063
|
+
br as TextShimmerLoader,
|
|
2064
|
+
bs as ThreadRunningIndicator,
|
|
2065
|
+
TiptapComposer,
|
|
2066
|
+
bt as UserMessage,
|
|
2067
|
+
assetTypeToIcon,
|
|
2068
|
+
assetTypeToThumb,
|
|
2069
|
+
buildRootMenuItems,
|
|
2070
|
+
bu as configureAssetIconBasePath,
|
|
2071
|
+
bv as createAssistantMessage,
|
|
2072
|
+
bw as createOlympusAssetUrl,
|
|
2073
|
+
fetchGraphQL,
|
|
2074
|
+
makeMentionUrl,
|
|
2075
|
+
bx as normalizeAthenaMentionHtml,
|
|
2076
|
+
parseMentionAnchorAttributes,
|
|
2077
|
+
by as parseMentionUrl,
|
|
2078
|
+
bz as parseMentionsInText,
|
|
2079
|
+
plainTextToTiptapContent,
|
|
2080
|
+
bA as resolveComposerAction,
|
|
2081
|
+
useMentionAuth,
|
|
2082
|
+
useMentionSuggestions,
|
|
2083
|
+
webpageMentionFingerprint
|
|
2084
|
+
};
|
|
2085
|
+
//# sourceMappingURL=chat-ui.js.map
|