@athenaintel/react 0.10.27 → 0.10.30
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/index.cjs +1083 -990
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +36 -25
- package/dist/index.js +1084 -991
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx, Fragment as Fragment$1, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { bindExternalStoreMessage, getExternalStoreMessages, INTERNAL, useAssistantTransportRuntime, useAuiState, useAssistantRuntime, useThread, useThreadList,
|
|
2
|
+
import { bindExternalStoreMessage, getExternalStoreMessages, INTERNAL, useAssistantTransportRuntime, useAuiState, useAssistantRuntime, useThread, useThreadList, useRemoteThreadListRuntime, Tools, useAui, AssistantRuntimeProvider, useComposerRuntime, MessagePartPrimitive, MessagePrimitive, useScrollLock, ActionBarPrimitive, AuiIf, ActionBarMorePrimitive, ThreadPrimitive, ComposerPrimitive, ErrorPrimitive, ThreadListPrimitive, ThreadListItemPrimitive } from "@assistant-ui/react";
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import React__default, { useMemo, useState, useRef, useEffect, useLayoutEffect, useContext, createContext, useCallback, useDebugValue, forwardRef, createRef, memo, createElement, version as version$1, useImperativeHandle } from "react";
|
|
5
5
|
import { A as AthenaAuthContext } from "./AthenaAuthContext-DQsdayH2.js";
|
|
@@ -129,6 +129,10 @@ function isTrustedOrigin({
|
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
131
|
const BRIDGE_TIMEOUT_MS = 2e3;
|
|
132
|
+
const TOKEN_REFRESH_BUFFER_MS = 5 * 60 * 1e3;
|
|
133
|
+
const TOKEN_REFRESH_RETRY_BASE_MS = 60 * 1e3;
|
|
134
|
+
const TOKEN_REFRESH_RETRY_MAX_MS = 5 * 60 * 1e3;
|
|
135
|
+
const DEFAULT_TOKEN_REFRESH_MS = 55 * 60 * 1e3;
|
|
132
136
|
const EMPTY_TRUSTED_ORIGINS = [];
|
|
133
137
|
const normalizeOrigin = (value) => {
|
|
134
138
|
try {
|
|
@@ -137,6 +141,20 @@ const normalizeOrigin = (value) => {
|
|
|
137
141
|
return null;
|
|
138
142
|
}
|
|
139
143
|
};
|
|
144
|
+
const getTokenRefreshDelay = (expiresAt, nowMs) => {
|
|
145
|
+
if (typeof expiresAt !== "string") {
|
|
146
|
+
return DEFAULT_TOKEN_REFRESH_MS;
|
|
147
|
+
}
|
|
148
|
+
const expiresAtMs = Date.parse(expiresAt);
|
|
149
|
+
if (!Number.isFinite(expiresAtMs)) {
|
|
150
|
+
return DEFAULT_TOKEN_REFRESH_MS;
|
|
151
|
+
}
|
|
152
|
+
return Math.max(TOKEN_REFRESH_RETRY_BASE_MS, expiresAtMs - nowMs - TOKEN_REFRESH_BUFFER_MS);
|
|
153
|
+
};
|
|
154
|
+
const getAuthRetryDelay = (retryAttempt) => {
|
|
155
|
+
const safeAttempt = Number.isFinite(retryAttempt) ? Math.max(0, Math.floor(retryAttempt)) : 0;
|
|
156
|
+
return Math.min(TOKEN_REFRESH_RETRY_MAX_MS, TOKEN_REFRESH_RETRY_BASE_MS * 2 ** safeAttempt);
|
|
157
|
+
};
|
|
140
158
|
function useParentBridge({
|
|
141
159
|
trustedOrigins = EMPTY_TRUSTED_ORIGINS
|
|
142
160
|
} = {}) {
|
|
@@ -159,8 +177,7 @@ function useParentBridge({
|
|
|
159
177
|
apiUrl: null,
|
|
160
178
|
backendUrl: null,
|
|
161
179
|
appUrl: null,
|
|
162
|
-
|
|
163
|
-
ready: !isInIframe
|
|
180
|
+
ready: false
|
|
164
181
|
});
|
|
165
182
|
const readySignalSent = useRef(false);
|
|
166
183
|
const configReceived = useRef(false);
|
|
@@ -187,7 +204,6 @@ function useParentBridge({
|
|
|
187
204
|
setState((prev) => ({
|
|
188
205
|
...prev,
|
|
189
206
|
token: event.data.token,
|
|
190
|
-
// If we got a token, we're ready even without config
|
|
191
207
|
ready: true
|
|
192
208
|
}));
|
|
193
209
|
}
|
|
@@ -205,6 +221,105 @@ function useParentBridge({
|
|
|
205
221
|
clearTimeout(timer);
|
|
206
222
|
};
|
|
207
223
|
}, [isInIframe, runtimeTrustedOrigins]);
|
|
224
|
+
useEffect(() => {
|
|
225
|
+
if (isInIframe) return;
|
|
226
|
+
if (typeof window === "undefined") return;
|
|
227
|
+
let cancelled = false;
|
|
228
|
+
let requestTimer = null;
|
|
229
|
+
let refreshTimer = null;
|
|
230
|
+
let controller = null;
|
|
231
|
+
let retryAttempt = 0;
|
|
232
|
+
const clearRequestTimer = () => {
|
|
233
|
+
if (requestTimer) {
|
|
234
|
+
clearTimeout(requestTimer);
|
|
235
|
+
requestTimer = null;
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
const clearRefreshTimer = () => {
|
|
239
|
+
if (refreshTimer) {
|
|
240
|
+
clearTimeout(refreshTimer);
|
|
241
|
+
refreshTimer = null;
|
|
242
|
+
}
|
|
243
|
+
};
|
|
244
|
+
const markReady = () => {
|
|
245
|
+
if (cancelled) return;
|
|
246
|
+
setState((prev) => prev.ready ? prev : { ...prev, ready: true });
|
|
247
|
+
};
|
|
248
|
+
const scheduleRefresh = (expiresAt) => {
|
|
249
|
+
clearRefreshTimer();
|
|
250
|
+
retryAttempt = 0;
|
|
251
|
+
const delay = getTokenRefreshDelay(expiresAt, Date.now());
|
|
252
|
+
refreshTimer = setTimeout(() => {
|
|
253
|
+
void fetchAuth({ markReadyOnFailure: false });
|
|
254
|
+
}, delay);
|
|
255
|
+
};
|
|
256
|
+
const scheduleRetry = () => {
|
|
257
|
+
clearRefreshTimer();
|
|
258
|
+
const delay = getAuthRetryDelay(retryAttempt);
|
|
259
|
+
retryAttempt += 1;
|
|
260
|
+
refreshTimer = setTimeout(() => {
|
|
261
|
+
void fetchAuth({ markReadyOnFailure: false });
|
|
262
|
+
}, delay);
|
|
263
|
+
};
|
|
264
|
+
const fetchAuth = async ({
|
|
265
|
+
markReadyOnFailure
|
|
266
|
+
}) => {
|
|
267
|
+
controller == null ? void 0 : controller.abort();
|
|
268
|
+
controller = new AbortController();
|
|
269
|
+
clearRequestTimer();
|
|
270
|
+
requestTimer = setTimeout(() => {
|
|
271
|
+
controller == null ? void 0 : controller.abort();
|
|
272
|
+
if (markReadyOnFailure) {
|
|
273
|
+
markReady();
|
|
274
|
+
}
|
|
275
|
+
}, BRIDGE_TIMEOUT_MS);
|
|
276
|
+
try {
|
|
277
|
+
const resp = await fetch("/_athena/auth", {
|
|
278
|
+
credentials: "include",
|
|
279
|
+
headers: { Accept: "application/json" },
|
|
280
|
+
signal: controller.signal
|
|
281
|
+
});
|
|
282
|
+
if (cancelled) return;
|
|
283
|
+
if (!resp.ok) {
|
|
284
|
+
if (resp.status === 404) {
|
|
285
|
+
markReady();
|
|
286
|
+
} else if (markReadyOnFailure) {
|
|
287
|
+
markReady();
|
|
288
|
+
scheduleRetry();
|
|
289
|
+
} else {
|
|
290
|
+
scheduleRetry();
|
|
291
|
+
}
|
|
292
|
+
return;
|
|
293
|
+
}
|
|
294
|
+
const data = await resp.json();
|
|
295
|
+
if (cancelled) return;
|
|
296
|
+
setState({
|
|
297
|
+
token: typeof data.token === "string" ? data.token : null,
|
|
298
|
+
apiUrl: typeof data.apiUrl === "string" ? data.apiUrl : null,
|
|
299
|
+
backendUrl: typeof data.backendUrl === "string" ? data.backendUrl : null,
|
|
300
|
+
appUrl: typeof data.appUrl === "string" ? data.appUrl : null,
|
|
301
|
+
ready: true
|
|
302
|
+
});
|
|
303
|
+
scheduleRefresh(data.expires_at);
|
|
304
|
+
} catch {
|
|
305
|
+
if (markReadyOnFailure) {
|
|
306
|
+
markReady();
|
|
307
|
+
}
|
|
308
|
+
if (!cancelled) {
|
|
309
|
+
scheduleRetry();
|
|
310
|
+
}
|
|
311
|
+
} finally {
|
|
312
|
+
clearRequestTimer();
|
|
313
|
+
}
|
|
314
|
+
};
|
|
315
|
+
void fetchAuth({ markReadyOnFailure: true });
|
|
316
|
+
return () => {
|
|
317
|
+
cancelled = true;
|
|
318
|
+
controller == null ? void 0 : controller.abort();
|
|
319
|
+
clearRequestTimer();
|
|
320
|
+
clearRefreshTimer();
|
|
321
|
+
};
|
|
322
|
+
}, [isInIframe]);
|
|
208
323
|
return state;
|
|
209
324
|
}
|
|
210
325
|
function useParentAuth() {
|
|
@@ -3893,7 +4008,7 @@ const twMerge = /* @__PURE__ */ createTailwindMerge(getDefaultConfig);
|
|
|
3893
4008
|
function cn(...inputs) {
|
|
3894
4009
|
return twMerge(clsx(inputs));
|
|
3895
4010
|
}
|
|
3896
|
-
function isRecord(value) {
|
|
4011
|
+
function isRecord$1(value) {
|
|
3897
4012
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
3898
4013
|
}
|
|
3899
4014
|
function $constructor(name, initializer2, params) {
|
|
@@ -8277,10 +8392,10 @@ const autoCloseInFlightSubgraphMessages = (msgs) => {
|
|
|
8277
8392
|
const beginIds = /* @__PURE__ */ new Set();
|
|
8278
8393
|
const endIds = /* @__PURE__ */ new Set();
|
|
8279
8394
|
for (const message of msgs) {
|
|
8280
|
-
if (!isRecord(message)) continue;
|
|
8395
|
+
if (!isRecord$1(message)) continue;
|
|
8281
8396
|
if (message.type === "ai" && Array.isArray(message.tool_calls)) {
|
|
8282
8397
|
for (const toolCall of message.tool_calls) {
|
|
8283
|
-
if (!isRecord(toolCall)) continue;
|
|
8398
|
+
if (!isRecord$1(toolCall)) continue;
|
|
8284
8399
|
const id = toolCall.id;
|
|
8285
8400
|
if (typeof id === "string") beginIds.add(id);
|
|
8286
8401
|
}
|
|
@@ -8346,7 +8461,7 @@ const contentToParts = (content) => {
|
|
|
8346
8461
|
const getNumberAtPath = (value, path) => {
|
|
8347
8462
|
let current = value;
|
|
8348
8463
|
for (const segment of path) {
|
|
8349
|
-
if (!isRecord(current)) {
|
|
8464
|
+
if (!isRecord$1(current)) {
|
|
8350
8465
|
return void 0;
|
|
8351
8466
|
}
|
|
8352
8467
|
current = current[segment];
|
|
@@ -8367,7 +8482,7 @@ const buildCustomMetadata = ({
|
|
|
8367
8482
|
}) => {
|
|
8368
8483
|
const customMetadata = additionalKwargs ? { ...additionalKwargs } : {};
|
|
8369
8484
|
const reasoningTokens = extractReasoningTokens({ usageMetadata, responseMetadata });
|
|
8370
|
-
const existingAthenaMetadata = isRecord(customMetadata._athena) ? customMetadata._athena : void 0;
|
|
8485
|
+
const existingAthenaMetadata = isRecord$1(customMetadata._athena) ? customMetadata._athena : void 0;
|
|
8371
8486
|
const athenaMetadata = {
|
|
8372
8487
|
...existingAthenaMetadata ?? {}
|
|
8373
8488
|
};
|
|
@@ -8386,9 +8501,9 @@ const buildCustomMetadata = ({
|
|
|
8386
8501
|
return Object.keys(customMetadata).length > 0 ? customMetadata : void 0;
|
|
8387
8502
|
};
|
|
8388
8503
|
const getSubgraphMessages = (artifact) => {
|
|
8389
|
-
if (!isRecord(artifact)) return void 0;
|
|
8504
|
+
if (!isRecord$1(artifact)) return void 0;
|
|
8390
8505
|
const subgraphState = artifact.subgraph_state;
|
|
8391
|
-
if (!isRecord(subgraphState)) return void 0;
|
|
8506
|
+
if (!isRecord$1(subgraphState)) return void 0;
|
|
8392
8507
|
const messages = subgraphState.messages;
|
|
8393
8508
|
return Array.isArray(messages) && messages.length > 0 ? messages : void 0;
|
|
8394
8509
|
};
|
|
@@ -9044,7 +9159,7 @@ const useAthenaRuntime = (config2) => {
|
|
|
9044
9159
|
if (status.isRunning) {
|
|
9045
9160
|
try {
|
|
9046
9161
|
const lastMessageId = ((_b = runtime.thread.getState().messages.at(-1)) == null ? void 0 : _b.id) ?? null;
|
|
9047
|
-
runtime.thread.
|
|
9162
|
+
runtime.thread.resumeRun({ parentId: lastMessageId });
|
|
9048
9163
|
} catch (resumeErr) {
|
|
9049
9164
|
if (IS_DEV) {
|
|
9050
9165
|
console.error("[AthenaSDK] Failed to resume running thread:", resumeErr);
|
|
@@ -9097,12 +9212,12 @@ function useComposedRefs(...refs) {
|
|
|
9097
9212
|
return React.useCallback(composeRefs(...refs), refs);
|
|
9098
9213
|
}
|
|
9099
9214
|
// @__NO_SIDE_EFFECTS__
|
|
9100
|
-
function createSlot
|
|
9101
|
-
const SlotClone = /* @__PURE__ */ createSlotClone
|
|
9215
|
+
function createSlot(ownerName) {
|
|
9216
|
+
const SlotClone = /* @__PURE__ */ createSlotClone(ownerName);
|
|
9102
9217
|
const Slot2 = React.forwardRef((props, forwardedRef) => {
|
|
9103
9218
|
const { children, ...slotProps } = props;
|
|
9104
9219
|
const childrenArray = React.Children.toArray(children);
|
|
9105
|
-
const slottable = childrenArray.find(isSlottable
|
|
9220
|
+
const slottable = childrenArray.find(isSlottable);
|
|
9106
9221
|
if (slottable) {
|
|
9107
9222
|
const newElement = slottable.props.children;
|
|
9108
9223
|
const newChildren = childrenArray.map((child) => {
|
|
@@ -9120,13 +9235,14 @@ function createSlot$7(ownerName) {
|
|
|
9120
9235
|
Slot2.displayName = `${ownerName}.Slot`;
|
|
9121
9236
|
return Slot2;
|
|
9122
9237
|
}
|
|
9238
|
+
var Slot = /* @__PURE__ */ createSlot("Slot");
|
|
9123
9239
|
// @__NO_SIDE_EFFECTS__
|
|
9124
|
-
function createSlotClone
|
|
9240
|
+
function createSlotClone(ownerName) {
|
|
9125
9241
|
const SlotClone = React.forwardRef((props, forwardedRef) => {
|
|
9126
9242
|
const { children, ...slotProps } = props;
|
|
9127
9243
|
if (React.isValidElement(children)) {
|
|
9128
|
-
const childrenRef = getElementRef$
|
|
9129
|
-
const props2 = mergeProps
|
|
9244
|
+
const childrenRef = getElementRef$1(children);
|
|
9245
|
+
const props2 = mergeProps(slotProps, children.props);
|
|
9130
9246
|
if (children.type !== React.Fragment) {
|
|
9131
9247
|
props2.ref = forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef;
|
|
9132
9248
|
}
|
|
@@ -9137,11 +9253,21 @@ function createSlotClone$7(ownerName) {
|
|
|
9137
9253
|
SlotClone.displayName = `${ownerName}.SlotClone`;
|
|
9138
9254
|
return SlotClone;
|
|
9139
9255
|
}
|
|
9140
|
-
var SLOTTABLE_IDENTIFIER
|
|
9141
|
-
|
|
9142
|
-
|
|
9256
|
+
var SLOTTABLE_IDENTIFIER = Symbol("radix.slottable");
|
|
9257
|
+
// @__NO_SIDE_EFFECTS__
|
|
9258
|
+
function createSlottable(ownerName) {
|
|
9259
|
+
const Slottable2 = ({ children }) => {
|
|
9260
|
+
return /* @__PURE__ */ jsx(Fragment$1, { children });
|
|
9261
|
+
};
|
|
9262
|
+
Slottable2.displayName = `${ownerName}.Slottable`;
|
|
9263
|
+
Slottable2.__radixId = SLOTTABLE_IDENTIFIER;
|
|
9264
|
+
return Slottable2;
|
|
9265
|
+
}
|
|
9266
|
+
var Slottable$1 = /* @__PURE__ */ createSlottable("Slottable");
|
|
9267
|
+
function isSlottable(child) {
|
|
9268
|
+
return React.isValidElement(child) && typeof child.type === "function" && "__radixId" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER;
|
|
9143
9269
|
}
|
|
9144
|
-
function mergeProps
|
|
9270
|
+
function mergeProps(slotProps, childProps) {
|
|
9145
9271
|
const overrideProps = { ...childProps };
|
|
9146
9272
|
for (const propName in childProps) {
|
|
9147
9273
|
const slotPropValue = slotProps[propName];
|
|
@@ -9165,7 +9291,7 @@ function mergeProps$7(slotProps, childProps) {
|
|
|
9165
9291
|
}
|
|
9166
9292
|
return { ...slotProps, ...overrideProps };
|
|
9167
9293
|
}
|
|
9168
|
-
function getElementRef$
|
|
9294
|
+
function getElementRef$1(element) {
|
|
9169
9295
|
var _a2, _b;
|
|
9170
9296
|
let getter = (_a2 = Object.getOwnPropertyDescriptor(element.props, "ref")) == null ? void 0 : _a2.get;
|
|
9171
9297
|
let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
@@ -9199,7 +9325,7 @@ var NODES$6 = [
|
|
|
9199
9325
|
"ul"
|
|
9200
9326
|
];
|
|
9201
9327
|
var Primitive$6 = NODES$6.reduce((primitive, node) => {
|
|
9202
|
-
const Slot2 = /* @__PURE__ */ createSlot
|
|
9328
|
+
const Slot2 = /* @__PURE__ */ createSlot(`Primitive.${node}`);
|
|
9203
9329
|
const Node4 = React.forwardRef((props, forwardedRef) => {
|
|
9204
9330
|
const { asChild, ...primitiveProps } = props;
|
|
9205
9331
|
const Comp = asChild ? Slot2 : node;
|
|
@@ -9374,89 +9500,6 @@ function composeContextScopes$2(...scopes) {
|
|
|
9374
9500
|
createScope.scopeName = baseScope.scopeName;
|
|
9375
9501
|
return createScope;
|
|
9376
9502
|
}
|
|
9377
|
-
// @__NO_SIDE_EFFECTS__
|
|
9378
|
-
function createSlot$6(ownerName) {
|
|
9379
|
-
const SlotClone = /* @__PURE__ */ createSlotClone$6(ownerName);
|
|
9380
|
-
const Slot2 = React.forwardRef((props, forwardedRef) => {
|
|
9381
|
-
const { children, ...slotProps } = props;
|
|
9382
|
-
const childrenArray = React.Children.toArray(children);
|
|
9383
|
-
const slottable = childrenArray.find(isSlottable$6);
|
|
9384
|
-
if (slottable) {
|
|
9385
|
-
const newElement = slottable.props.children;
|
|
9386
|
-
const newChildren = childrenArray.map((child) => {
|
|
9387
|
-
if (child === slottable) {
|
|
9388
|
-
if (React.Children.count(newElement) > 1) return React.Children.only(null);
|
|
9389
|
-
return React.isValidElement(newElement) ? newElement.props.children : null;
|
|
9390
|
-
} else {
|
|
9391
|
-
return child;
|
|
9392
|
-
}
|
|
9393
|
-
});
|
|
9394
|
-
return /* @__PURE__ */ jsx(SlotClone, { ...slotProps, ref: forwardedRef, children: React.isValidElement(newElement) ? React.cloneElement(newElement, void 0, newChildren) : null });
|
|
9395
|
-
}
|
|
9396
|
-
return /* @__PURE__ */ jsx(SlotClone, { ...slotProps, ref: forwardedRef, children });
|
|
9397
|
-
});
|
|
9398
|
-
Slot2.displayName = `${ownerName}.Slot`;
|
|
9399
|
-
return Slot2;
|
|
9400
|
-
}
|
|
9401
|
-
// @__NO_SIDE_EFFECTS__
|
|
9402
|
-
function createSlotClone$6(ownerName) {
|
|
9403
|
-
const SlotClone = React.forwardRef((props, forwardedRef) => {
|
|
9404
|
-
const { children, ...slotProps } = props;
|
|
9405
|
-
if (React.isValidElement(children)) {
|
|
9406
|
-
const childrenRef = getElementRef$7(children);
|
|
9407
|
-
const props2 = mergeProps$6(slotProps, children.props);
|
|
9408
|
-
if (children.type !== React.Fragment) {
|
|
9409
|
-
props2.ref = forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef;
|
|
9410
|
-
}
|
|
9411
|
-
return React.cloneElement(children, props2);
|
|
9412
|
-
}
|
|
9413
|
-
return React.Children.count(children) > 1 ? React.Children.only(null) : null;
|
|
9414
|
-
});
|
|
9415
|
-
SlotClone.displayName = `${ownerName}.SlotClone`;
|
|
9416
|
-
return SlotClone;
|
|
9417
|
-
}
|
|
9418
|
-
var SLOTTABLE_IDENTIFIER$6 = Symbol("radix.slottable");
|
|
9419
|
-
function isSlottable$6(child) {
|
|
9420
|
-
return React.isValidElement(child) && typeof child.type === "function" && "__radixId" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER$6;
|
|
9421
|
-
}
|
|
9422
|
-
function mergeProps$6(slotProps, childProps) {
|
|
9423
|
-
const overrideProps = { ...childProps };
|
|
9424
|
-
for (const propName in childProps) {
|
|
9425
|
-
const slotPropValue = slotProps[propName];
|
|
9426
|
-
const childPropValue = childProps[propName];
|
|
9427
|
-
const isHandler = /^on[A-Z]/.test(propName);
|
|
9428
|
-
if (isHandler) {
|
|
9429
|
-
if (slotPropValue && childPropValue) {
|
|
9430
|
-
overrideProps[propName] = (...args) => {
|
|
9431
|
-
const result = childPropValue(...args);
|
|
9432
|
-
slotPropValue(...args);
|
|
9433
|
-
return result;
|
|
9434
|
-
};
|
|
9435
|
-
} else if (slotPropValue) {
|
|
9436
|
-
overrideProps[propName] = slotPropValue;
|
|
9437
|
-
}
|
|
9438
|
-
} else if (propName === "style") {
|
|
9439
|
-
overrideProps[propName] = { ...slotPropValue, ...childPropValue };
|
|
9440
|
-
} else if (propName === "className") {
|
|
9441
|
-
overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(" ");
|
|
9442
|
-
}
|
|
9443
|
-
}
|
|
9444
|
-
return { ...slotProps, ...overrideProps };
|
|
9445
|
-
}
|
|
9446
|
-
function getElementRef$7(element) {
|
|
9447
|
-
var _a2, _b;
|
|
9448
|
-
let getter = (_a2 = Object.getOwnPropertyDescriptor(element.props, "ref")) == null ? void 0 : _a2.get;
|
|
9449
|
-
let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
9450
|
-
if (mayWarn) {
|
|
9451
|
-
return element.ref;
|
|
9452
|
-
}
|
|
9453
|
-
getter = (_b = Object.getOwnPropertyDescriptor(element, "ref")) == null ? void 0 : _b.get;
|
|
9454
|
-
mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
9455
|
-
if (mayWarn) {
|
|
9456
|
-
return element.props.ref;
|
|
9457
|
-
}
|
|
9458
|
-
return element.props.ref || element.ref;
|
|
9459
|
-
}
|
|
9460
9503
|
var NODES$5 = [
|
|
9461
9504
|
"a",
|
|
9462
9505
|
"button",
|
|
@@ -9477,7 +9520,7 @@ var NODES$5 = [
|
|
|
9477
9520
|
"ul"
|
|
9478
9521
|
];
|
|
9479
9522
|
var Primitive$5 = NODES$5.reduce((primitive, node) => {
|
|
9480
|
-
const Slot2 = /* @__PURE__ */ createSlot
|
|
9523
|
+
const Slot2 = /* @__PURE__ */ createSlot(`Primitive.${node}`);
|
|
9481
9524
|
const Node4 = React.forwardRef((props, forwardedRef) => {
|
|
9482
9525
|
const { asChild, ...primitiveProps } = props;
|
|
9483
9526
|
const Comp = asChild ? Slot2 : node;
|
|
@@ -9499,7 +9542,7 @@ var Presence = (props) => {
|
|
|
9499
9542
|
const { present, children } = props;
|
|
9500
9543
|
const presence = usePresence(present);
|
|
9501
9544
|
const child = typeof children === "function" ? children({ present: presence.isPresent }) : React.Children.only(children);
|
|
9502
|
-
const ref = useComposedRefs(presence.ref, getElementRef
|
|
9545
|
+
const ref = useComposedRefs(presence.ref, getElementRef(child));
|
|
9503
9546
|
const forceMount = typeof children === "function";
|
|
9504
9547
|
return forceMount || presence.isPresent ? React.cloneElement(child, { ref }) : null;
|
|
9505
9548
|
};
|
|
@@ -9598,7 +9641,7 @@ function usePresence(present) {
|
|
|
9598
9641
|
function getAnimationName(styles) {
|
|
9599
9642
|
return (styles == null ? void 0 : styles.animationName) || "none";
|
|
9600
9643
|
}
|
|
9601
|
-
function getElementRef
|
|
9644
|
+
function getElementRef(element) {
|
|
9602
9645
|
var _a2, _b;
|
|
9603
9646
|
let getter = (_a2 = Object.getOwnPropertyDescriptor(element.props, "ref")) == null ? void 0 : _a2.get;
|
|
9604
9647
|
let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
@@ -9751,89 +9794,6 @@ function getState(open) {
|
|
|
9751
9794
|
return open ? "open" : "closed";
|
|
9752
9795
|
}
|
|
9753
9796
|
var Root$1 = Collapsible$1;
|
|
9754
|
-
// @__NO_SIDE_EFFECTS__
|
|
9755
|
-
function createSlot$5(ownerName) {
|
|
9756
|
-
const SlotClone = /* @__PURE__ */ createSlotClone$5(ownerName);
|
|
9757
|
-
const Slot2 = React.forwardRef((props, forwardedRef) => {
|
|
9758
|
-
const { children, ...slotProps } = props;
|
|
9759
|
-
const childrenArray = React.Children.toArray(children);
|
|
9760
|
-
const slottable = childrenArray.find(isSlottable$5);
|
|
9761
|
-
if (slottable) {
|
|
9762
|
-
const newElement = slottable.props.children;
|
|
9763
|
-
const newChildren = childrenArray.map((child) => {
|
|
9764
|
-
if (child === slottable) {
|
|
9765
|
-
if (React.Children.count(newElement) > 1) return React.Children.only(null);
|
|
9766
|
-
return React.isValidElement(newElement) ? newElement.props.children : null;
|
|
9767
|
-
} else {
|
|
9768
|
-
return child;
|
|
9769
|
-
}
|
|
9770
|
-
});
|
|
9771
|
-
return /* @__PURE__ */ jsx(SlotClone, { ...slotProps, ref: forwardedRef, children: React.isValidElement(newElement) ? React.cloneElement(newElement, void 0, newChildren) : null });
|
|
9772
|
-
}
|
|
9773
|
-
return /* @__PURE__ */ jsx(SlotClone, { ...slotProps, ref: forwardedRef, children });
|
|
9774
|
-
});
|
|
9775
|
-
Slot2.displayName = `${ownerName}.Slot`;
|
|
9776
|
-
return Slot2;
|
|
9777
|
-
}
|
|
9778
|
-
// @__NO_SIDE_EFFECTS__
|
|
9779
|
-
function createSlotClone$5(ownerName) {
|
|
9780
|
-
const SlotClone = React.forwardRef((props, forwardedRef) => {
|
|
9781
|
-
const { children, ...slotProps } = props;
|
|
9782
|
-
if (React.isValidElement(children)) {
|
|
9783
|
-
const childrenRef = getElementRef$5(children);
|
|
9784
|
-
const props2 = mergeProps$5(slotProps, children.props);
|
|
9785
|
-
if (children.type !== React.Fragment) {
|
|
9786
|
-
props2.ref = forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef;
|
|
9787
|
-
}
|
|
9788
|
-
return React.cloneElement(children, props2);
|
|
9789
|
-
}
|
|
9790
|
-
return React.Children.count(children) > 1 ? React.Children.only(null) : null;
|
|
9791
|
-
});
|
|
9792
|
-
SlotClone.displayName = `${ownerName}.SlotClone`;
|
|
9793
|
-
return SlotClone;
|
|
9794
|
-
}
|
|
9795
|
-
var SLOTTABLE_IDENTIFIER$5 = Symbol("radix.slottable");
|
|
9796
|
-
function isSlottable$5(child) {
|
|
9797
|
-
return React.isValidElement(child) && typeof child.type === "function" && "__radixId" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER$5;
|
|
9798
|
-
}
|
|
9799
|
-
function mergeProps$5(slotProps, childProps) {
|
|
9800
|
-
const overrideProps = { ...childProps };
|
|
9801
|
-
for (const propName in childProps) {
|
|
9802
|
-
const slotPropValue = slotProps[propName];
|
|
9803
|
-
const childPropValue = childProps[propName];
|
|
9804
|
-
const isHandler = /^on[A-Z]/.test(propName);
|
|
9805
|
-
if (isHandler) {
|
|
9806
|
-
if (slotPropValue && childPropValue) {
|
|
9807
|
-
overrideProps[propName] = (...args) => {
|
|
9808
|
-
const result = childPropValue(...args);
|
|
9809
|
-
slotPropValue(...args);
|
|
9810
|
-
return result;
|
|
9811
|
-
};
|
|
9812
|
-
} else if (slotPropValue) {
|
|
9813
|
-
overrideProps[propName] = slotPropValue;
|
|
9814
|
-
}
|
|
9815
|
-
} else if (propName === "style") {
|
|
9816
|
-
overrideProps[propName] = { ...slotPropValue, ...childPropValue };
|
|
9817
|
-
} else if (propName === "className") {
|
|
9818
|
-
overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(" ");
|
|
9819
|
-
}
|
|
9820
|
-
}
|
|
9821
|
-
return { ...slotProps, ...overrideProps };
|
|
9822
|
-
}
|
|
9823
|
-
function getElementRef$5(element) {
|
|
9824
|
-
var _a2, _b;
|
|
9825
|
-
let getter = (_a2 = Object.getOwnPropertyDescriptor(element.props, "ref")) == null ? void 0 : _a2.get;
|
|
9826
|
-
let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
9827
|
-
if (mayWarn) {
|
|
9828
|
-
return element.ref;
|
|
9829
|
-
}
|
|
9830
|
-
getter = (_b = Object.getOwnPropertyDescriptor(element, "ref")) == null ? void 0 : _b.get;
|
|
9831
|
-
mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
9832
|
-
if (mayWarn) {
|
|
9833
|
-
return element.props.ref;
|
|
9834
|
-
}
|
|
9835
|
-
return element.props.ref || element.ref;
|
|
9836
|
-
}
|
|
9837
9797
|
var NODES$4 = [
|
|
9838
9798
|
"a",
|
|
9839
9799
|
"button",
|
|
@@ -9854,7 +9814,7 @@ var NODES$4 = [
|
|
|
9854
9814
|
"ul"
|
|
9855
9815
|
];
|
|
9856
9816
|
var Primitive$4 = NODES$4.reduce((primitive, node) => {
|
|
9857
|
-
const Slot2 = /* @__PURE__ */ createSlot
|
|
9817
|
+
const Slot2 = /* @__PURE__ */ createSlot(`Primitive.${node}`);
|
|
9858
9818
|
const Node4 = React.forwardRef((props, forwardedRef) => {
|
|
9859
9819
|
const { asChild, ...primitiveProps } = props;
|
|
9860
9820
|
const Comp = asChild ? Slot2 : node;
|
|
@@ -10092,89 +10052,6 @@ function handleAndDispatchCustomEvent(name, handler, detail, { discrete }) {
|
|
|
10092
10052
|
target.dispatchEvent(event);
|
|
10093
10053
|
}
|
|
10094
10054
|
}
|
|
10095
|
-
// @__NO_SIDE_EFFECTS__
|
|
10096
|
-
function createSlot$4(ownerName) {
|
|
10097
|
-
const SlotClone = /* @__PURE__ */ createSlotClone$4(ownerName);
|
|
10098
|
-
const Slot2 = React.forwardRef((props, forwardedRef) => {
|
|
10099
|
-
const { children, ...slotProps } = props;
|
|
10100
|
-
const childrenArray = React.Children.toArray(children);
|
|
10101
|
-
const slottable = childrenArray.find(isSlottable$4);
|
|
10102
|
-
if (slottable) {
|
|
10103
|
-
const newElement = slottable.props.children;
|
|
10104
|
-
const newChildren = childrenArray.map((child) => {
|
|
10105
|
-
if (child === slottable) {
|
|
10106
|
-
if (React.Children.count(newElement) > 1) return React.Children.only(null);
|
|
10107
|
-
return React.isValidElement(newElement) ? newElement.props.children : null;
|
|
10108
|
-
} else {
|
|
10109
|
-
return child;
|
|
10110
|
-
}
|
|
10111
|
-
});
|
|
10112
|
-
return /* @__PURE__ */ jsx(SlotClone, { ...slotProps, ref: forwardedRef, children: React.isValidElement(newElement) ? React.cloneElement(newElement, void 0, newChildren) : null });
|
|
10113
|
-
}
|
|
10114
|
-
return /* @__PURE__ */ jsx(SlotClone, { ...slotProps, ref: forwardedRef, children });
|
|
10115
|
-
});
|
|
10116
|
-
Slot2.displayName = `${ownerName}.Slot`;
|
|
10117
|
-
return Slot2;
|
|
10118
|
-
}
|
|
10119
|
-
// @__NO_SIDE_EFFECTS__
|
|
10120
|
-
function createSlotClone$4(ownerName) {
|
|
10121
|
-
const SlotClone = React.forwardRef((props, forwardedRef) => {
|
|
10122
|
-
const { children, ...slotProps } = props;
|
|
10123
|
-
if (React.isValidElement(children)) {
|
|
10124
|
-
const childrenRef = getElementRef$4(children);
|
|
10125
|
-
const props2 = mergeProps$4(slotProps, children.props);
|
|
10126
|
-
if (children.type !== React.Fragment) {
|
|
10127
|
-
props2.ref = forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef;
|
|
10128
|
-
}
|
|
10129
|
-
return React.cloneElement(children, props2);
|
|
10130
|
-
}
|
|
10131
|
-
return React.Children.count(children) > 1 ? React.Children.only(null) : null;
|
|
10132
|
-
});
|
|
10133
|
-
SlotClone.displayName = `${ownerName}.SlotClone`;
|
|
10134
|
-
return SlotClone;
|
|
10135
|
-
}
|
|
10136
|
-
var SLOTTABLE_IDENTIFIER$4 = Symbol("radix.slottable");
|
|
10137
|
-
function isSlottable$4(child) {
|
|
10138
|
-
return React.isValidElement(child) && typeof child.type === "function" && "__radixId" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER$4;
|
|
10139
|
-
}
|
|
10140
|
-
function mergeProps$4(slotProps, childProps) {
|
|
10141
|
-
const overrideProps = { ...childProps };
|
|
10142
|
-
for (const propName in childProps) {
|
|
10143
|
-
const slotPropValue = slotProps[propName];
|
|
10144
|
-
const childPropValue = childProps[propName];
|
|
10145
|
-
const isHandler = /^on[A-Z]/.test(propName);
|
|
10146
|
-
if (isHandler) {
|
|
10147
|
-
if (slotPropValue && childPropValue) {
|
|
10148
|
-
overrideProps[propName] = (...args) => {
|
|
10149
|
-
const result = childPropValue(...args);
|
|
10150
|
-
slotPropValue(...args);
|
|
10151
|
-
return result;
|
|
10152
|
-
};
|
|
10153
|
-
} else if (slotPropValue) {
|
|
10154
|
-
overrideProps[propName] = slotPropValue;
|
|
10155
|
-
}
|
|
10156
|
-
} else if (propName === "style") {
|
|
10157
|
-
overrideProps[propName] = { ...slotPropValue, ...childPropValue };
|
|
10158
|
-
} else if (propName === "className") {
|
|
10159
|
-
overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(" ");
|
|
10160
|
-
}
|
|
10161
|
-
}
|
|
10162
|
-
return { ...slotProps, ...overrideProps };
|
|
10163
|
-
}
|
|
10164
|
-
function getElementRef$4(element) {
|
|
10165
|
-
var _a2, _b;
|
|
10166
|
-
let getter = (_a2 = Object.getOwnPropertyDescriptor(element.props, "ref")) == null ? void 0 : _a2.get;
|
|
10167
|
-
let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
10168
|
-
if (mayWarn) {
|
|
10169
|
-
return element.ref;
|
|
10170
|
-
}
|
|
10171
|
-
getter = (_b = Object.getOwnPropertyDescriptor(element, "ref")) == null ? void 0 : _b.get;
|
|
10172
|
-
mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
10173
|
-
if (mayWarn) {
|
|
10174
|
-
return element.props.ref;
|
|
10175
|
-
}
|
|
10176
|
-
return element.props.ref || element.ref;
|
|
10177
|
-
}
|
|
10178
10055
|
var NODES$3 = [
|
|
10179
10056
|
"a",
|
|
10180
10057
|
"button",
|
|
@@ -10195,7 +10072,7 @@ var NODES$3 = [
|
|
|
10195
10072
|
"ul"
|
|
10196
10073
|
];
|
|
10197
10074
|
var Primitive$3 = NODES$3.reduce((primitive, node) => {
|
|
10198
|
-
const Slot2 = /* @__PURE__ */ createSlot
|
|
10075
|
+
const Slot2 = /* @__PURE__ */ createSlot(`Primitive.${node}`);
|
|
10199
10076
|
const Node4 = React.forwardRef((props, forwardedRef) => {
|
|
10200
10077
|
const { asChild, ...primitiveProps } = props;
|
|
10201
10078
|
const Comp = asChild ? Slot2 : node;
|
|
@@ -10217,100 +10094,6 @@ var Portal$1 = React.forwardRef((props, forwardedRef) => {
|
|
|
10217
10094
|
return container ? ReactDOM__default.createPortal(/* @__PURE__ */ jsx(Primitive$3.div, { ...portalProps, ref: forwardedRef }), container) : null;
|
|
10218
10095
|
});
|
|
10219
10096
|
Portal$1.displayName = PORTAL_NAME$1;
|
|
10220
|
-
// @__NO_SIDE_EFFECTS__
|
|
10221
|
-
function createSlot$3(ownerName) {
|
|
10222
|
-
const SlotClone = /* @__PURE__ */ createSlotClone$3(ownerName);
|
|
10223
|
-
const Slot2 = React.forwardRef((props, forwardedRef) => {
|
|
10224
|
-
const { children, ...slotProps } = props;
|
|
10225
|
-
const childrenArray = React.Children.toArray(children);
|
|
10226
|
-
const slottable = childrenArray.find(isSlottable$3);
|
|
10227
|
-
if (slottable) {
|
|
10228
|
-
const newElement = slottable.props.children;
|
|
10229
|
-
const newChildren = childrenArray.map((child) => {
|
|
10230
|
-
if (child === slottable) {
|
|
10231
|
-
if (React.Children.count(newElement) > 1) return React.Children.only(null);
|
|
10232
|
-
return React.isValidElement(newElement) ? newElement.props.children : null;
|
|
10233
|
-
} else {
|
|
10234
|
-
return child;
|
|
10235
|
-
}
|
|
10236
|
-
});
|
|
10237
|
-
return /* @__PURE__ */ jsx(SlotClone, { ...slotProps, ref: forwardedRef, children: React.isValidElement(newElement) ? React.cloneElement(newElement, void 0, newChildren) : null });
|
|
10238
|
-
}
|
|
10239
|
-
return /* @__PURE__ */ jsx(SlotClone, { ...slotProps, ref: forwardedRef, children });
|
|
10240
|
-
});
|
|
10241
|
-
Slot2.displayName = `${ownerName}.Slot`;
|
|
10242
|
-
return Slot2;
|
|
10243
|
-
}
|
|
10244
|
-
var Slot = /* @__PURE__ */ createSlot$3("Slot");
|
|
10245
|
-
// @__NO_SIDE_EFFECTS__
|
|
10246
|
-
function createSlotClone$3(ownerName) {
|
|
10247
|
-
const SlotClone = React.forwardRef((props, forwardedRef) => {
|
|
10248
|
-
const { children, ...slotProps } = props;
|
|
10249
|
-
if (React.isValidElement(children)) {
|
|
10250
|
-
const childrenRef = getElementRef$3(children);
|
|
10251
|
-
const props2 = mergeProps$3(slotProps, children.props);
|
|
10252
|
-
if (children.type !== React.Fragment) {
|
|
10253
|
-
props2.ref = forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef;
|
|
10254
|
-
}
|
|
10255
|
-
return React.cloneElement(children, props2);
|
|
10256
|
-
}
|
|
10257
|
-
return React.Children.count(children) > 1 ? React.Children.only(null) : null;
|
|
10258
|
-
});
|
|
10259
|
-
SlotClone.displayName = `${ownerName}.SlotClone`;
|
|
10260
|
-
return SlotClone;
|
|
10261
|
-
}
|
|
10262
|
-
var SLOTTABLE_IDENTIFIER$3 = Symbol("radix.slottable");
|
|
10263
|
-
// @__NO_SIDE_EFFECTS__
|
|
10264
|
-
function createSlottable$1(ownerName) {
|
|
10265
|
-
const Slottable2 = ({ children }) => {
|
|
10266
|
-
return /* @__PURE__ */ jsx(Fragment$1, { children });
|
|
10267
|
-
};
|
|
10268
|
-
Slottable2.displayName = `${ownerName}.Slottable`;
|
|
10269
|
-
Slottable2.__radixId = SLOTTABLE_IDENTIFIER$3;
|
|
10270
|
-
return Slottable2;
|
|
10271
|
-
}
|
|
10272
|
-
var Slottable$1 = /* @__PURE__ */ createSlottable$1("Slottable");
|
|
10273
|
-
function isSlottable$3(child) {
|
|
10274
|
-
return React.isValidElement(child) && typeof child.type === "function" && "__radixId" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER$3;
|
|
10275
|
-
}
|
|
10276
|
-
function mergeProps$3(slotProps, childProps) {
|
|
10277
|
-
const overrideProps = { ...childProps };
|
|
10278
|
-
for (const propName in childProps) {
|
|
10279
|
-
const slotPropValue = slotProps[propName];
|
|
10280
|
-
const childPropValue = childProps[propName];
|
|
10281
|
-
const isHandler = /^on[A-Z]/.test(propName);
|
|
10282
|
-
if (isHandler) {
|
|
10283
|
-
if (slotPropValue && childPropValue) {
|
|
10284
|
-
overrideProps[propName] = (...args) => {
|
|
10285
|
-
const result = childPropValue(...args);
|
|
10286
|
-
slotPropValue(...args);
|
|
10287
|
-
return result;
|
|
10288
|
-
};
|
|
10289
|
-
} else if (slotPropValue) {
|
|
10290
|
-
overrideProps[propName] = slotPropValue;
|
|
10291
|
-
}
|
|
10292
|
-
} else if (propName === "style") {
|
|
10293
|
-
overrideProps[propName] = { ...slotPropValue, ...childPropValue };
|
|
10294
|
-
} else if (propName === "className") {
|
|
10295
|
-
overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(" ");
|
|
10296
|
-
}
|
|
10297
|
-
}
|
|
10298
|
-
return { ...slotProps, ...overrideProps };
|
|
10299
|
-
}
|
|
10300
|
-
function getElementRef$3(element) {
|
|
10301
|
-
var _a2, _b;
|
|
10302
|
-
let getter = (_a2 = Object.getOwnPropertyDescriptor(element.props, "ref")) == null ? void 0 : _a2.get;
|
|
10303
|
-
let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
10304
|
-
if (mayWarn) {
|
|
10305
|
-
return element.ref;
|
|
10306
|
-
}
|
|
10307
|
-
getter = (_b = Object.getOwnPropertyDescriptor(element, "ref")) == null ? void 0 : _b.get;
|
|
10308
|
-
mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
10309
|
-
if (mayWarn) {
|
|
10310
|
-
return element.props.ref;
|
|
10311
|
-
}
|
|
10312
|
-
return element.props.ref || element.ref;
|
|
10313
|
-
}
|
|
10314
10097
|
var shim$1 = { exports: {} };
|
|
10315
10098
|
var useSyncExternalStoreShim_production = {};
|
|
10316
10099
|
/**
|
|
@@ -12403,89 +12186,6 @@ const arrow$2 = (options, deps) => {
|
|
|
12403
12186
|
options: [options, deps]
|
|
12404
12187
|
};
|
|
12405
12188
|
};
|
|
12406
|
-
// @__NO_SIDE_EFFECTS__
|
|
12407
|
-
function createSlot$2(ownerName) {
|
|
12408
|
-
const SlotClone = /* @__PURE__ */ createSlotClone$2(ownerName);
|
|
12409
|
-
const Slot2 = React.forwardRef((props, forwardedRef) => {
|
|
12410
|
-
const { children, ...slotProps } = props;
|
|
12411
|
-
const childrenArray = React.Children.toArray(children);
|
|
12412
|
-
const slottable = childrenArray.find(isSlottable$2);
|
|
12413
|
-
if (slottable) {
|
|
12414
|
-
const newElement = slottable.props.children;
|
|
12415
|
-
const newChildren = childrenArray.map((child) => {
|
|
12416
|
-
if (child === slottable) {
|
|
12417
|
-
if (React.Children.count(newElement) > 1) return React.Children.only(null);
|
|
12418
|
-
return React.isValidElement(newElement) ? newElement.props.children : null;
|
|
12419
|
-
} else {
|
|
12420
|
-
return child;
|
|
12421
|
-
}
|
|
12422
|
-
});
|
|
12423
|
-
return /* @__PURE__ */ jsx(SlotClone, { ...slotProps, ref: forwardedRef, children: React.isValidElement(newElement) ? React.cloneElement(newElement, void 0, newChildren) : null });
|
|
12424
|
-
}
|
|
12425
|
-
return /* @__PURE__ */ jsx(SlotClone, { ...slotProps, ref: forwardedRef, children });
|
|
12426
|
-
});
|
|
12427
|
-
Slot2.displayName = `${ownerName}.Slot`;
|
|
12428
|
-
return Slot2;
|
|
12429
|
-
}
|
|
12430
|
-
// @__NO_SIDE_EFFECTS__
|
|
12431
|
-
function createSlotClone$2(ownerName) {
|
|
12432
|
-
const SlotClone = React.forwardRef((props, forwardedRef) => {
|
|
12433
|
-
const { children, ...slotProps } = props;
|
|
12434
|
-
if (React.isValidElement(children)) {
|
|
12435
|
-
const childrenRef = getElementRef$2(children);
|
|
12436
|
-
const props2 = mergeProps$2(slotProps, children.props);
|
|
12437
|
-
if (children.type !== React.Fragment) {
|
|
12438
|
-
props2.ref = forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef;
|
|
12439
|
-
}
|
|
12440
|
-
return React.cloneElement(children, props2);
|
|
12441
|
-
}
|
|
12442
|
-
return React.Children.count(children) > 1 ? React.Children.only(null) : null;
|
|
12443
|
-
});
|
|
12444
|
-
SlotClone.displayName = `${ownerName}.SlotClone`;
|
|
12445
|
-
return SlotClone;
|
|
12446
|
-
}
|
|
12447
|
-
var SLOTTABLE_IDENTIFIER$2 = Symbol("radix.slottable");
|
|
12448
|
-
function isSlottable$2(child) {
|
|
12449
|
-
return React.isValidElement(child) && typeof child.type === "function" && "__radixId" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER$2;
|
|
12450
|
-
}
|
|
12451
|
-
function mergeProps$2(slotProps, childProps) {
|
|
12452
|
-
const overrideProps = { ...childProps };
|
|
12453
|
-
for (const propName in childProps) {
|
|
12454
|
-
const slotPropValue = slotProps[propName];
|
|
12455
|
-
const childPropValue = childProps[propName];
|
|
12456
|
-
const isHandler = /^on[A-Z]/.test(propName);
|
|
12457
|
-
if (isHandler) {
|
|
12458
|
-
if (slotPropValue && childPropValue) {
|
|
12459
|
-
overrideProps[propName] = (...args) => {
|
|
12460
|
-
const result = childPropValue(...args);
|
|
12461
|
-
slotPropValue(...args);
|
|
12462
|
-
return result;
|
|
12463
|
-
};
|
|
12464
|
-
} else if (slotPropValue) {
|
|
12465
|
-
overrideProps[propName] = slotPropValue;
|
|
12466
|
-
}
|
|
12467
|
-
} else if (propName === "style") {
|
|
12468
|
-
overrideProps[propName] = { ...slotPropValue, ...childPropValue };
|
|
12469
|
-
} else if (propName === "className") {
|
|
12470
|
-
overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(" ");
|
|
12471
|
-
}
|
|
12472
|
-
}
|
|
12473
|
-
return { ...slotProps, ...overrideProps };
|
|
12474
|
-
}
|
|
12475
|
-
function getElementRef$2(element) {
|
|
12476
|
-
var _a2, _b;
|
|
12477
|
-
let getter = (_a2 = Object.getOwnPropertyDescriptor(element.props, "ref")) == null ? void 0 : _a2.get;
|
|
12478
|
-
let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
12479
|
-
if (mayWarn) {
|
|
12480
|
-
return element.ref;
|
|
12481
|
-
}
|
|
12482
|
-
getter = (_b = Object.getOwnPropertyDescriptor(element, "ref")) == null ? void 0 : _b.get;
|
|
12483
|
-
mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
12484
|
-
if (mayWarn) {
|
|
12485
|
-
return element.props.ref;
|
|
12486
|
-
}
|
|
12487
|
-
return element.props.ref || element.ref;
|
|
12488
|
-
}
|
|
12489
12189
|
var NODES$2 = [
|
|
12490
12190
|
"a",
|
|
12491
12191
|
"button",
|
|
@@ -12506,7 +12206,7 @@ var NODES$2 = [
|
|
|
12506
12206
|
"ul"
|
|
12507
12207
|
];
|
|
12508
12208
|
var Primitive$2 = NODES$2.reduce((primitive, node) => {
|
|
12509
|
-
const Slot2 = /* @__PURE__ */ createSlot
|
|
12209
|
+
const Slot2 = /* @__PURE__ */ createSlot(`Primitive.${node}`);
|
|
12510
12210
|
const Node4 = React.forwardRef((props, forwardedRef) => {
|
|
12511
12211
|
const { asChild, ...primitiveProps } = props;
|
|
12512
12212
|
const Comp = asChild ? Slot2 : node;
|
|
@@ -12595,89 +12295,6 @@ function composeContextScopes$1(...scopes) {
|
|
|
12595
12295
|
createScope.scopeName = baseScope.scopeName;
|
|
12596
12296
|
return createScope;
|
|
12597
12297
|
}
|
|
12598
|
-
// @__NO_SIDE_EFFECTS__
|
|
12599
|
-
function createSlot$1(ownerName) {
|
|
12600
|
-
const SlotClone = /* @__PURE__ */ createSlotClone$1(ownerName);
|
|
12601
|
-
const Slot2 = React.forwardRef((props, forwardedRef) => {
|
|
12602
|
-
const { children, ...slotProps } = props;
|
|
12603
|
-
const childrenArray = React.Children.toArray(children);
|
|
12604
|
-
const slottable = childrenArray.find(isSlottable$1);
|
|
12605
|
-
if (slottable) {
|
|
12606
|
-
const newElement = slottable.props.children;
|
|
12607
|
-
const newChildren = childrenArray.map((child) => {
|
|
12608
|
-
if (child === slottable) {
|
|
12609
|
-
if (React.Children.count(newElement) > 1) return React.Children.only(null);
|
|
12610
|
-
return React.isValidElement(newElement) ? newElement.props.children : null;
|
|
12611
|
-
} else {
|
|
12612
|
-
return child;
|
|
12613
|
-
}
|
|
12614
|
-
});
|
|
12615
|
-
return /* @__PURE__ */ jsx(SlotClone, { ...slotProps, ref: forwardedRef, children: React.isValidElement(newElement) ? React.cloneElement(newElement, void 0, newChildren) : null });
|
|
12616
|
-
}
|
|
12617
|
-
return /* @__PURE__ */ jsx(SlotClone, { ...slotProps, ref: forwardedRef, children });
|
|
12618
|
-
});
|
|
12619
|
-
Slot2.displayName = `${ownerName}.Slot`;
|
|
12620
|
-
return Slot2;
|
|
12621
|
-
}
|
|
12622
|
-
// @__NO_SIDE_EFFECTS__
|
|
12623
|
-
function createSlotClone$1(ownerName) {
|
|
12624
|
-
const SlotClone = React.forwardRef((props, forwardedRef) => {
|
|
12625
|
-
const { children, ...slotProps } = props;
|
|
12626
|
-
if (React.isValidElement(children)) {
|
|
12627
|
-
const childrenRef = getElementRef$1(children);
|
|
12628
|
-
const props2 = mergeProps$1(slotProps, children.props);
|
|
12629
|
-
if (children.type !== React.Fragment) {
|
|
12630
|
-
props2.ref = forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef;
|
|
12631
|
-
}
|
|
12632
|
-
return React.cloneElement(children, props2);
|
|
12633
|
-
}
|
|
12634
|
-
return React.Children.count(children) > 1 ? React.Children.only(null) : null;
|
|
12635
|
-
});
|
|
12636
|
-
SlotClone.displayName = `${ownerName}.SlotClone`;
|
|
12637
|
-
return SlotClone;
|
|
12638
|
-
}
|
|
12639
|
-
var SLOTTABLE_IDENTIFIER$1 = Symbol("radix.slottable");
|
|
12640
|
-
function isSlottable$1(child) {
|
|
12641
|
-
return React.isValidElement(child) && typeof child.type === "function" && "__radixId" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER$1;
|
|
12642
|
-
}
|
|
12643
|
-
function mergeProps$1(slotProps, childProps) {
|
|
12644
|
-
const overrideProps = { ...childProps };
|
|
12645
|
-
for (const propName in childProps) {
|
|
12646
|
-
const slotPropValue = slotProps[propName];
|
|
12647
|
-
const childPropValue = childProps[propName];
|
|
12648
|
-
const isHandler = /^on[A-Z]/.test(propName);
|
|
12649
|
-
if (isHandler) {
|
|
12650
|
-
if (slotPropValue && childPropValue) {
|
|
12651
|
-
overrideProps[propName] = (...args) => {
|
|
12652
|
-
const result = childPropValue(...args);
|
|
12653
|
-
slotPropValue(...args);
|
|
12654
|
-
return result;
|
|
12655
|
-
};
|
|
12656
|
-
} else if (slotPropValue) {
|
|
12657
|
-
overrideProps[propName] = slotPropValue;
|
|
12658
|
-
}
|
|
12659
|
-
} else if (propName === "style") {
|
|
12660
|
-
overrideProps[propName] = { ...slotPropValue, ...childPropValue };
|
|
12661
|
-
} else if (propName === "className") {
|
|
12662
|
-
overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(" ");
|
|
12663
|
-
}
|
|
12664
|
-
}
|
|
12665
|
-
return { ...slotProps, ...overrideProps };
|
|
12666
|
-
}
|
|
12667
|
-
function getElementRef$1(element) {
|
|
12668
|
-
var _a2, _b;
|
|
12669
|
-
let getter = (_a2 = Object.getOwnPropertyDescriptor(element.props, "ref")) == null ? void 0 : _a2.get;
|
|
12670
|
-
let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
12671
|
-
if (mayWarn) {
|
|
12672
|
-
return element.ref;
|
|
12673
|
-
}
|
|
12674
|
-
getter = (_b = Object.getOwnPropertyDescriptor(element, "ref")) == null ? void 0 : _b.get;
|
|
12675
|
-
mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
12676
|
-
if (mayWarn) {
|
|
12677
|
-
return element.props.ref;
|
|
12678
|
-
}
|
|
12679
|
-
return element.props.ref || element.ref;
|
|
12680
|
-
}
|
|
12681
12298
|
var NODES$1 = [
|
|
12682
12299
|
"a",
|
|
12683
12300
|
"button",
|
|
@@ -12698,7 +12315,7 @@ var NODES$1 = [
|
|
|
12698
12315
|
"ul"
|
|
12699
12316
|
];
|
|
12700
12317
|
var Primitive$1 = NODES$1.reduce((primitive, node) => {
|
|
12701
|
-
const Slot2 = /* @__PURE__ */ createSlot
|
|
12318
|
+
const Slot2 = /* @__PURE__ */ createSlot(`Primitive.${node}`);
|
|
12702
12319
|
const Node4 = React.forwardRef((props, forwardedRef) => {
|
|
12703
12320
|
const { asChild, ...primitiveProps } = props;
|
|
12704
12321
|
const Comp = asChild ? Slot2 : node;
|
|
@@ -13040,98 +12657,6 @@ function composeContextScopes(...scopes) {
|
|
|
13040
12657
|
createScope.scopeName = baseScope.scopeName;
|
|
13041
12658
|
return createScope;
|
|
13042
12659
|
}
|
|
13043
|
-
// @__NO_SIDE_EFFECTS__
|
|
13044
|
-
function createSlot(ownerName) {
|
|
13045
|
-
const SlotClone = /* @__PURE__ */ createSlotClone(ownerName);
|
|
13046
|
-
const Slot2 = React.forwardRef((props, forwardedRef) => {
|
|
13047
|
-
const { children, ...slotProps } = props;
|
|
13048
|
-
const childrenArray = React.Children.toArray(children);
|
|
13049
|
-
const slottable = childrenArray.find(isSlottable);
|
|
13050
|
-
if (slottable) {
|
|
13051
|
-
const newElement = slottable.props.children;
|
|
13052
|
-
const newChildren = childrenArray.map((child) => {
|
|
13053
|
-
if (child === slottable) {
|
|
13054
|
-
if (React.Children.count(newElement) > 1) return React.Children.only(null);
|
|
13055
|
-
return React.isValidElement(newElement) ? newElement.props.children : null;
|
|
13056
|
-
} else {
|
|
13057
|
-
return child;
|
|
13058
|
-
}
|
|
13059
|
-
});
|
|
13060
|
-
return /* @__PURE__ */ jsx(SlotClone, { ...slotProps, ref: forwardedRef, children: React.isValidElement(newElement) ? React.cloneElement(newElement, void 0, newChildren) : null });
|
|
13061
|
-
}
|
|
13062
|
-
return /* @__PURE__ */ jsx(SlotClone, { ...slotProps, ref: forwardedRef, children });
|
|
13063
|
-
});
|
|
13064
|
-
Slot2.displayName = `${ownerName}.Slot`;
|
|
13065
|
-
return Slot2;
|
|
13066
|
-
}
|
|
13067
|
-
// @__NO_SIDE_EFFECTS__
|
|
13068
|
-
function createSlotClone(ownerName) {
|
|
13069
|
-
const SlotClone = React.forwardRef((props, forwardedRef) => {
|
|
13070
|
-
const { children, ...slotProps } = props;
|
|
13071
|
-
if (React.isValidElement(children)) {
|
|
13072
|
-
const childrenRef = getElementRef(children);
|
|
13073
|
-
const props2 = mergeProps(slotProps, children.props);
|
|
13074
|
-
if (children.type !== React.Fragment) {
|
|
13075
|
-
props2.ref = forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef;
|
|
13076
|
-
}
|
|
13077
|
-
return React.cloneElement(children, props2);
|
|
13078
|
-
}
|
|
13079
|
-
return React.Children.count(children) > 1 ? React.Children.only(null) : null;
|
|
13080
|
-
});
|
|
13081
|
-
SlotClone.displayName = `${ownerName}.SlotClone`;
|
|
13082
|
-
return SlotClone;
|
|
13083
|
-
}
|
|
13084
|
-
var SLOTTABLE_IDENTIFIER = Symbol("radix.slottable");
|
|
13085
|
-
// @__NO_SIDE_EFFECTS__
|
|
13086
|
-
function createSlottable(ownerName) {
|
|
13087
|
-
const Slottable2 = ({ children }) => {
|
|
13088
|
-
return /* @__PURE__ */ jsx(Fragment$1, { children });
|
|
13089
|
-
};
|
|
13090
|
-
Slottable2.displayName = `${ownerName}.Slottable`;
|
|
13091
|
-
Slottable2.__radixId = SLOTTABLE_IDENTIFIER;
|
|
13092
|
-
return Slottable2;
|
|
13093
|
-
}
|
|
13094
|
-
function isSlottable(child) {
|
|
13095
|
-
return React.isValidElement(child) && typeof child.type === "function" && "__radixId" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER;
|
|
13096
|
-
}
|
|
13097
|
-
function mergeProps(slotProps, childProps) {
|
|
13098
|
-
const overrideProps = { ...childProps };
|
|
13099
|
-
for (const propName in childProps) {
|
|
13100
|
-
const slotPropValue = slotProps[propName];
|
|
13101
|
-
const childPropValue = childProps[propName];
|
|
13102
|
-
const isHandler = /^on[A-Z]/.test(propName);
|
|
13103
|
-
if (isHandler) {
|
|
13104
|
-
if (slotPropValue && childPropValue) {
|
|
13105
|
-
overrideProps[propName] = (...args) => {
|
|
13106
|
-
const result = childPropValue(...args);
|
|
13107
|
-
slotPropValue(...args);
|
|
13108
|
-
return result;
|
|
13109
|
-
};
|
|
13110
|
-
} else if (slotPropValue) {
|
|
13111
|
-
overrideProps[propName] = slotPropValue;
|
|
13112
|
-
}
|
|
13113
|
-
} else if (propName === "style") {
|
|
13114
|
-
overrideProps[propName] = { ...slotPropValue, ...childPropValue };
|
|
13115
|
-
} else if (propName === "className") {
|
|
13116
|
-
overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(" ");
|
|
13117
|
-
}
|
|
13118
|
-
}
|
|
13119
|
-
return { ...slotProps, ...overrideProps };
|
|
13120
|
-
}
|
|
13121
|
-
function getElementRef(element) {
|
|
13122
|
-
var _a2, _b;
|
|
13123
|
-
let getter = (_a2 = Object.getOwnPropertyDescriptor(element.props, "ref")) == null ? void 0 : _a2.get;
|
|
13124
|
-
let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
13125
|
-
if (mayWarn) {
|
|
13126
|
-
return element.ref;
|
|
13127
|
-
}
|
|
13128
|
-
getter = (_b = Object.getOwnPropertyDescriptor(element, "ref")) == null ? void 0 : _b.get;
|
|
13129
|
-
mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
13130
|
-
if (mayWarn) {
|
|
13131
|
-
return element.props.ref;
|
|
13132
|
-
}
|
|
13133
|
-
return element.props.ref || element.ref;
|
|
13134
|
-
}
|
|
13135
12660
|
var NODES = [
|
|
13136
12661
|
"a",
|
|
13137
12662
|
"button",
|
|
@@ -13673,190 +13198,6 @@ function TooltipContent({
|
|
|
13673
13198
|
}
|
|
13674
13199
|
) });
|
|
13675
13200
|
}
|
|
13676
|
-
const AthenaContext = createContext(null);
|
|
13677
|
-
function useAthenaConfig() {
|
|
13678
|
-
const ctx = useContext(AthenaContext);
|
|
13679
|
-
if (!ctx) {
|
|
13680
|
-
throw new Error("[AthenaSDK] useAthenaConfig must be used within <AthenaProvider>");
|
|
13681
|
-
}
|
|
13682
|
-
return ctx;
|
|
13683
|
-
}
|
|
13684
|
-
const AthenaThreadIdContext = createContext(void 0);
|
|
13685
|
-
function useAthenaThreadId() {
|
|
13686
|
-
return useContext(AthenaThreadIdContext);
|
|
13687
|
-
}
|
|
13688
|
-
function useAthenaThreadListAdapter(config2) {
|
|
13689
|
-
const configRef = useRef(config2);
|
|
13690
|
-
configRef.current = config2;
|
|
13691
|
-
const auth = useMemo(
|
|
13692
|
-
() => ({ apiKey: config2.apiKey, token: config2.token }),
|
|
13693
|
-
[config2.apiKey, config2.token]
|
|
13694
|
-
);
|
|
13695
|
-
const unstable_Provider = useCallback(
|
|
13696
|
-
function AthenaThreadProvider({ children }) {
|
|
13697
|
-
const remoteId = useAuiState(
|
|
13698
|
-
(s) => {
|
|
13699
|
-
var _a2;
|
|
13700
|
-
return (_a2 = s.threadListItem) == null ? void 0 : _a2.remoteId;
|
|
13701
|
-
}
|
|
13702
|
-
);
|
|
13703
|
-
return /* @__PURE__ */ jsx(AthenaThreadIdContext.Provider, { value: remoteId, children });
|
|
13704
|
-
},
|
|
13705
|
-
[]
|
|
13706
|
-
);
|
|
13707
|
-
return useMemo(() => ({
|
|
13708
|
-
async list() {
|
|
13709
|
-
if (!auth.token && !auth.apiKey) {
|
|
13710
|
-
return { threads: [] };
|
|
13711
|
-
}
|
|
13712
|
-
try {
|
|
13713
|
-
const { threads } = await listThreads(configRef.current.backendUrl, auth, {
|
|
13714
|
-
...configRef.current.appId ? { app_id: configRef.current.appId } : {}
|
|
13715
|
-
});
|
|
13716
|
-
return {
|
|
13717
|
-
threads: threads.map((t) => ({
|
|
13718
|
-
status: "regular",
|
|
13719
|
-
remoteId: t.thread_id,
|
|
13720
|
-
title: t.title || void 0
|
|
13721
|
-
}))
|
|
13722
|
-
};
|
|
13723
|
-
} catch (err) {
|
|
13724
|
-
console.error("[AthenaSDK] adapter.list() failed:", err);
|
|
13725
|
-
return { threads: [] };
|
|
13726
|
-
}
|
|
13727
|
-
},
|
|
13728
|
-
async initialize(_threadId) {
|
|
13729
|
-
const remoteId = typeof crypto !== "undefined" && "randomUUID" in crypto ? crypto.randomUUID() : `thread_${Date.now()}_${Math.random().toString(36).slice(2, 10)}`;
|
|
13730
|
-
return { remoteId, externalId: void 0 };
|
|
13731
|
-
},
|
|
13732
|
-
async rename(_remoteId, _newTitle) {
|
|
13733
|
-
},
|
|
13734
|
-
async archive(remoteId) {
|
|
13735
|
-
await archiveThread(configRef.current.backendUrl, auth, remoteId);
|
|
13736
|
-
},
|
|
13737
|
-
async unarchive(_remoteId) {
|
|
13738
|
-
},
|
|
13739
|
-
async delete(remoteId) {
|
|
13740
|
-
await archiveThread(configRef.current.backendUrl, auth, remoteId);
|
|
13741
|
-
},
|
|
13742
|
-
async generateTitle(_remoteId, _messages) {
|
|
13743
|
-
return new ReadableStream({ start(c) {
|
|
13744
|
-
c.close();
|
|
13745
|
-
} });
|
|
13746
|
-
},
|
|
13747
|
-
async fetch(remoteId) {
|
|
13748
|
-
return {
|
|
13749
|
-
status: "regular",
|
|
13750
|
-
remoteId
|
|
13751
|
-
};
|
|
13752
|
-
},
|
|
13753
|
-
unstable_Provider
|
|
13754
|
-
}), [auth, unstable_Provider]);
|
|
13755
|
-
}
|
|
13756
|
-
const ThreadListRefreshContext = createContext(null);
|
|
13757
|
-
function useRefreshThreadList() {
|
|
13758
|
-
return useContext(ThreadListRefreshContext);
|
|
13759
|
-
}
|
|
13760
|
-
const LOCAL_ID_PREFIX = "__LOCALID_";
|
|
13761
|
-
const isLocalPlaceholder = (id) => !!id && id.startsWith(LOCAL_ID_PREFIX);
|
|
13762
|
-
function useAthenaThreadManager() {
|
|
13763
|
-
const runtime = useAssistantRuntime({ optional: true });
|
|
13764
|
-
const remoteId = useThread({
|
|
13765
|
-
optional: true,
|
|
13766
|
-
selector: (s) => {
|
|
13767
|
-
var _a2;
|
|
13768
|
-
const id = (_a2 = s.metadata) == null ? void 0 : _a2.remoteId;
|
|
13769
|
-
return isLocalPlaceholder(id) ? void 0 : id;
|
|
13770
|
-
}
|
|
13771
|
-
});
|
|
13772
|
-
const isThreadLoading = useThread({ optional: true, selector: (s) => s.isLoading }) ?? false;
|
|
13773
|
-
const isListLoading = useThreadList({ optional: true, selector: (s) => s.isLoading });
|
|
13774
|
-
const runtimeRef = useRef(runtime);
|
|
13775
|
-
runtimeRef.current = runtime;
|
|
13776
|
-
const switchToThread = useCallback(
|
|
13777
|
-
(id) => runtimeRef.current.threads.switchToThread(id),
|
|
13778
|
-
[]
|
|
13779
|
-
);
|
|
13780
|
-
const switchToNewThread = useCallback(
|
|
13781
|
-
() => runtimeRef.current.threads.switchToNewThread(),
|
|
13782
|
-
[]
|
|
13783
|
-
);
|
|
13784
|
-
const activeThreadId = remoteId ?? null;
|
|
13785
|
-
return useMemo(() => {
|
|
13786
|
-
if (!runtime || isListLoading == null) {
|
|
13787
|
-
return null;
|
|
13788
|
-
}
|
|
13789
|
-
return {
|
|
13790
|
-
activeThreadId,
|
|
13791
|
-
isListLoading,
|
|
13792
|
-
isThreadLoading,
|
|
13793
|
-
switchToThread,
|
|
13794
|
-
switchToNewThread
|
|
13795
|
-
};
|
|
13796
|
-
}, [runtime, activeThreadId, isListLoading, isThreadLoading, switchToThread, switchToNewThread]);
|
|
13797
|
-
}
|
|
13798
|
-
const POLL_DELAY_MS = 5e3;
|
|
13799
|
-
const POLL_INTERVAL_MS = 1e3;
|
|
13800
|
-
const POLL_MAX_DURATION_MS = 6e4;
|
|
13801
|
-
function useThreadTitlePolling(refresh) {
|
|
13802
|
-
const threadKey = useThread({
|
|
13803
|
-
optional: true,
|
|
13804
|
-
selector: (s) => {
|
|
13805
|
-
var _a2, _b;
|
|
13806
|
-
return ((_a2 = s.metadata) == null ? void 0 : _a2.remoteId) ?? ((_b = s.metadata) == null ? void 0 : _b.id) ?? s.threadId;
|
|
13807
|
-
}
|
|
13808
|
-
}) ?? null;
|
|
13809
|
-
const hasMessages = useThread({
|
|
13810
|
-
optional: true,
|
|
13811
|
-
selector: (s) => s.messages.length > 0
|
|
13812
|
-
}) ?? false;
|
|
13813
|
-
const currentTitle = useThreadList({
|
|
13814
|
-
optional: true,
|
|
13815
|
-
selector: (s) => {
|
|
13816
|
-
const main = s.threadItems[s.mainThreadId];
|
|
13817
|
-
return (main == null ? void 0 : main.title) ?? "";
|
|
13818
|
-
}
|
|
13819
|
-
}) ?? "";
|
|
13820
|
-
const hasTitle = currentTitle.trim().length > 0;
|
|
13821
|
-
const polledThreadsRef = useRef(/* @__PURE__ */ new Set());
|
|
13822
|
-
const refreshRef = useRef(refresh);
|
|
13823
|
-
refreshRef.current = refresh;
|
|
13824
|
-
useEffect(() => {
|
|
13825
|
-
if (!threadKey || hasTitle || !hasMessages) {
|
|
13826
|
-
return;
|
|
13827
|
-
}
|
|
13828
|
-
if (polledThreadsRef.current.has(threadKey)) {
|
|
13829
|
-
return;
|
|
13830
|
-
}
|
|
13831
|
-
polledThreadsRef.current.add(threadKey);
|
|
13832
|
-
let stopped = false;
|
|
13833
|
-
let intervalId = null;
|
|
13834
|
-
let maxTimeoutId = null;
|
|
13835
|
-
const stop = () => {
|
|
13836
|
-
stopped = true;
|
|
13837
|
-
if (intervalId !== null) {
|
|
13838
|
-
clearInterval(intervalId);
|
|
13839
|
-
intervalId = null;
|
|
13840
|
-
}
|
|
13841
|
-
if (maxTimeoutId !== null) {
|
|
13842
|
-
clearTimeout(maxTimeoutId);
|
|
13843
|
-
maxTimeoutId = null;
|
|
13844
|
-
}
|
|
13845
|
-
};
|
|
13846
|
-
const startTimeoutId = setTimeout(() => {
|
|
13847
|
-
if (stopped) return;
|
|
13848
|
-
refreshRef.current();
|
|
13849
|
-
intervalId = setInterval(() => {
|
|
13850
|
-
refreshRef.current();
|
|
13851
|
-
}, POLL_INTERVAL_MS);
|
|
13852
|
-
maxTimeoutId = setTimeout(stop, POLL_MAX_DURATION_MS - POLL_DELAY_MS);
|
|
13853
|
-
}, POLL_DELAY_MS);
|
|
13854
|
-
return () => {
|
|
13855
|
-
clearTimeout(startTimeoutId);
|
|
13856
|
-
stop();
|
|
13857
|
-
};
|
|
13858
|
-
}, [threadKey, hasTitle, hasMessages]);
|
|
13859
|
-
}
|
|
13860
13201
|
const createStoreImpl = (createState) => {
|
|
13861
13202
|
let state;
|
|
13862
13203
|
const listeners = /* @__PURE__ */ new Set();
|
|
@@ -14116,7 +13457,7 @@ const useAssetPanelStore = create()(
|
|
|
14116
13457
|
...t,
|
|
14117
13458
|
name: meta.name ?? t.name,
|
|
14118
13459
|
type: meta.type ?? t.type,
|
|
14119
|
-
slideNumber: meta.slideNumber
|
|
13460
|
+
slideNumber: "slideNumber" in meta ? meta.slideNumber : t.slideNumber
|
|
14120
13461
|
} : t
|
|
14121
13462
|
) : s.tabs;
|
|
14122
13463
|
return { isOpen: true, tabs, activeTabId: assetId };
|
|
@@ -14199,6 +13540,398 @@ const useAssetPanelStore = create()(
|
|
|
14199
13540
|
}
|
|
14200
13541
|
)
|
|
14201
13542
|
);
|
|
13543
|
+
function getAssetInfo(assetId) {
|
|
13544
|
+
return { name: assetId || "Document", icon: "doc" };
|
|
13545
|
+
}
|
|
13546
|
+
function tryParseJson$2(text2) {
|
|
13547
|
+
try {
|
|
13548
|
+
const p = JSON.parse(text2);
|
|
13549
|
+
return typeof p === "object" && p !== null ? p : null;
|
|
13550
|
+
} catch {
|
|
13551
|
+
return null;
|
|
13552
|
+
}
|
|
13553
|
+
}
|
|
13554
|
+
const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
13555
|
+
const normalizeResult$2 = (result) => {
|
|
13556
|
+
if (!result) return null;
|
|
13557
|
+
if (typeof result === "string") {
|
|
13558
|
+
const parsed = tryParseJson$2(result);
|
|
13559
|
+
if (isRecord(parsed)) return parsed;
|
|
13560
|
+
return null;
|
|
13561
|
+
}
|
|
13562
|
+
if (isRecord(result)) {
|
|
13563
|
+
const inner = result.result;
|
|
13564
|
+
if (typeof inner === "string") {
|
|
13565
|
+
const parsed = tryParseJson$2(inner);
|
|
13566
|
+
if (isRecord(parsed)) return parsed;
|
|
13567
|
+
} else if (isRecord(inner)) {
|
|
13568
|
+
return inner;
|
|
13569
|
+
}
|
|
13570
|
+
return result;
|
|
13571
|
+
}
|
|
13572
|
+
return null;
|
|
13573
|
+
};
|
|
13574
|
+
const pickAssetId = (...candidates) => {
|
|
13575
|
+
for (const candidate of candidates) {
|
|
13576
|
+
if (typeof candidate === "string" && candidate.startsWith("asset_")) {
|
|
13577
|
+
return candidate;
|
|
13578
|
+
}
|
|
13579
|
+
}
|
|
13580
|
+
return null;
|
|
13581
|
+
};
|
|
13582
|
+
const pickNumber = (...candidates) => {
|
|
13583
|
+
for (const candidate of candidates) {
|
|
13584
|
+
if (typeof candidate === "number" && Number.isFinite(candidate)) {
|
|
13585
|
+
return candidate;
|
|
13586
|
+
}
|
|
13587
|
+
}
|
|
13588
|
+
return void 0;
|
|
13589
|
+
};
|
|
13590
|
+
const autoOpen = (assetId, options = {}) => {
|
|
13591
|
+
const store = useAssetPanelStore.getState();
|
|
13592
|
+
if (!store.markAutoOpened(assetId)) return;
|
|
13593
|
+
const existing = store.tabs.find((tab) => tab.id === assetId);
|
|
13594
|
+
const keepCurrentSlide = options.preserveExistingSlide && existing;
|
|
13595
|
+
store.openAsset(assetId, {
|
|
13596
|
+
type: options.type ?? "unknown",
|
|
13597
|
+
...keepCurrentSlide || options.slideNumber === void 0 ? {} : { slideNumber: options.slideNumber }
|
|
13598
|
+
});
|
|
13599
|
+
};
|
|
13600
|
+
const openOnResult = (type, extra) => ({
|
|
13601
|
+
streamCall: async (reader) => {
|
|
13602
|
+
const { result } = await reader.response.get();
|
|
13603
|
+
const data = normalizeResult$2(result);
|
|
13604
|
+
const assetId = pickAssetId(
|
|
13605
|
+
data == null ? void 0 : data.asset_id,
|
|
13606
|
+
data == null ? void 0 : data.assetId,
|
|
13607
|
+
data == null ? void 0 : data.id
|
|
13608
|
+
);
|
|
13609
|
+
if (!assetId) return;
|
|
13610
|
+
let slideNumber;
|
|
13611
|
+
if ((extra == null ? void 0 : extra.slideNumberFrom) !== "args") {
|
|
13612
|
+
slideNumber = pickNumber(
|
|
13613
|
+
data == null ? void 0 : data.slide_number,
|
|
13614
|
+
data == null ? void 0 : data.slideNumber,
|
|
13615
|
+
data == null ? void 0 : data.targetSlideNumber,
|
|
13616
|
+
data == null ? void 0 : data.target_slide_number
|
|
13617
|
+
);
|
|
13618
|
+
}
|
|
13619
|
+
if (slideNumber === void 0 && (extra == null ? void 0 : extra.slideNumberFrom) !== "result") {
|
|
13620
|
+
const args = await reader.args.get().catch(() => null);
|
|
13621
|
+
slideNumber = pickNumber(
|
|
13622
|
+
args == null ? void 0 : args.slide_number,
|
|
13623
|
+
args == null ? void 0 : args.slideNumber,
|
|
13624
|
+
args == null ? void 0 : args.targetSlideNumber,
|
|
13625
|
+
args == null ? void 0 : args.target_slide_number
|
|
13626
|
+
);
|
|
13627
|
+
}
|
|
13628
|
+
autoOpen(assetId, {
|
|
13629
|
+
type,
|
|
13630
|
+
slideNumber,
|
|
13631
|
+
preserveExistingSlide: extra == null ? void 0 : extra.preserveExistingSlide
|
|
13632
|
+
});
|
|
13633
|
+
}
|
|
13634
|
+
});
|
|
13635
|
+
const openFromArgs = (type) => ({
|
|
13636
|
+
streamCall: async (reader) => {
|
|
13637
|
+
await reader.response.get();
|
|
13638
|
+
const args = await reader.args.get().catch(() => null);
|
|
13639
|
+
const assetId = pickAssetId(args == null ? void 0 : args.asset_id, args == null ? void 0 : args.assetId);
|
|
13640
|
+
if (!assetId) return;
|
|
13641
|
+
autoOpen(assetId, { type });
|
|
13642
|
+
}
|
|
13643
|
+
});
|
|
13644
|
+
const DEFAULT_AUTO_OPEN_TOOLS = {
|
|
13645
|
+
// Top-level asset creators
|
|
13646
|
+
create_new_document: openOnResult("document"),
|
|
13647
|
+
create_document_from_markdown: openOnResult("document"),
|
|
13648
|
+
create_new_sheet: openOnResult("spreadsheet"),
|
|
13649
|
+
create_powerpoint_deck: openOnResult("presentation"),
|
|
13650
|
+
create_new_notebook: openOnResult("notebook"),
|
|
13651
|
+
// Open / read existing assets
|
|
13652
|
+
open_asset_in_workspace: openFromArgs("unknown"),
|
|
13653
|
+
// Code execution that lands on a deck/slide
|
|
13654
|
+
execute_presentation_code: openOnResult("presentation"),
|
|
13655
|
+
// Media capture
|
|
13656
|
+
capture_moment: openOnResult("unknown"),
|
|
13657
|
+
// Studio PTC sub-calls (nested SDK commands)
|
|
13658
|
+
CreateWorkbook: openOnResult("spreadsheet"),
|
|
13659
|
+
AddSheet: openOnResult("spreadsheet"),
|
|
13660
|
+
OpenWorkbook: openOnResult("spreadsheet"),
|
|
13661
|
+
CreatePresentation: openOnResult("presentation"),
|
|
13662
|
+
OpenPresentation: openOnResult("presentation", { preserveExistingSlide: true }),
|
|
13663
|
+
AddSlide: openOnResult("presentation"),
|
|
13664
|
+
CreateDocument: openOnResult("document"),
|
|
13665
|
+
CreateParagraph: openOnResult("document"),
|
|
13666
|
+
OpenDocument: openOnResult("document")
|
|
13667
|
+
};
|
|
13668
|
+
const AthenaContext = createContext(null);
|
|
13669
|
+
function useAthenaConfig() {
|
|
13670
|
+
const ctx = useContext(AthenaContext);
|
|
13671
|
+
if (!ctx) {
|
|
13672
|
+
throw new Error("[AthenaSDK] useAthenaConfig must be used within <AthenaProvider>");
|
|
13673
|
+
}
|
|
13674
|
+
return ctx;
|
|
13675
|
+
}
|
|
13676
|
+
const AthenaThreadIdContext = createContext(void 0);
|
|
13677
|
+
function selectThreadListItemRemoteId(state) {
|
|
13678
|
+
var _a2;
|
|
13679
|
+
return (_a2 = state.threadListItem) == null ? void 0 : _a2.remoteId;
|
|
13680
|
+
}
|
|
13681
|
+
function useAthenaAuiThreadRemoteId() {
|
|
13682
|
+
return useAuiState(selectThreadListItemRemoteId);
|
|
13683
|
+
}
|
|
13684
|
+
function useAthenaThreadId() {
|
|
13685
|
+
return useContext(AthenaThreadIdContext);
|
|
13686
|
+
}
|
|
13687
|
+
function useAthenaThreadListAdapter(config2) {
|
|
13688
|
+
const configRef = useRef(config2);
|
|
13689
|
+
configRef.current = config2;
|
|
13690
|
+
const auth = useMemo(
|
|
13691
|
+
() => ({ apiKey: config2.apiKey, token: config2.token }),
|
|
13692
|
+
[config2.apiKey, config2.token]
|
|
13693
|
+
);
|
|
13694
|
+
const unstable_Provider = useCallback(
|
|
13695
|
+
function AthenaThreadProvider({ children }) {
|
|
13696
|
+
const remoteId = useAthenaAuiThreadRemoteId();
|
|
13697
|
+
return /* @__PURE__ */ jsx(AthenaThreadIdContext.Provider, { value: remoteId, children });
|
|
13698
|
+
},
|
|
13699
|
+
[]
|
|
13700
|
+
);
|
|
13701
|
+
return useMemo(() => ({
|
|
13702
|
+
async list() {
|
|
13703
|
+
if (!auth.token && !auth.apiKey) {
|
|
13704
|
+
return { threads: [] };
|
|
13705
|
+
}
|
|
13706
|
+
try {
|
|
13707
|
+
const { threads } = await listThreads(configRef.current.backendUrl, auth, {
|
|
13708
|
+
...configRef.current.appId ? { app_id: configRef.current.appId } : {}
|
|
13709
|
+
});
|
|
13710
|
+
return {
|
|
13711
|
+
threads: threads.map((t) => ({
|
|
13712
|
+
status: "regular",
|
|
13713
|
+
remoteId: t.thread_id,
|
|
13714
|
+
title: t.title || void 0
|
|
13715
|
+
}))
|
|
13716
|
+
};
|
|
13717
|
+
} catch (err) {
|
|
13718
|
+
console.error("[AthenaSDK] adapter.list() failed:", err);
|
|
13719
|
+
return { threads: [] };
|
|
13720
|
+
}
|
|
13721
|
+
},
|
|
13722
|
+
async initialize(_threadId) {
|
|
13723
|
+
const remoteId = typeof crypto !== "undefined" && "randomUUID" in crypto ? crypto.randomUUID() : `thread_${Date.now()}_${Math.random().toString(36).slice(2, 10)}`;
|
|
13724
|
+
return { remoteId, externalId: void 0 };
|
|
13725
|
+
},
|
|
13726
|
+
async rename(_remoteId, _newTitle) {
|
|
13727
|
+
},
|
|
13728
|
+
async archive(remoteId) {
|
|
13729
|
+
await archiveThread(configRef.current.backendUrl, auth, remoteId);
|
|
13730
|
+
},
|
|
13731
|
+
async unarchive(_remoteId) {
|
|
13732
|
+
},
|
|
13733
|
+
async delete(remoteId) {
|
|
13734
|
+
await archiveThread(configRef.current.backendUrl, auth, remoteId);
|
|
13735
|
+
},
|
|
13736
|
+
async generateTitle(_remoteId, _messages) {
|
|
13737
|
+
return new ReadableStream({ start(c) {
|
|
13738
|
+
c.close();
|
|
13739
|
+
} });
|
|
13740
|
+
},
|
|
13741
|
+
async fetch(remoteId) {
|
|
13742
|
+
return {
|
|
13743
|
+
status: "regular",
|
|
13744
|
+
remoteId
|
|
13745
|
+
};
|
|
13746
|
+
},
|
|
13747
|
+
unstable_Provider
|
|
13748
|
+
}), [auth, unstable_Provider]);
|
|
13749
|
+
}
|
|
13750
|
+
const ThreadListRefreshContext = createContext(null);
|
|
13751
|
+
function useRefreshThreadList() {
|
|
13752
|
+
return useContext(ThreadListRefreshContext);
|
|
13753
|
+
}
|
|
13754
|
+
const LOCAL_ID_PREFIX$1 = "__LOCALID_";
|
|
13755
|
+
const isLocalPlaceholder$1 = (id) => !!id && id.startsWith(LOCAL_ID_PREFIX$1);
|
|
13756
|
+
const selectHydratableThreadId = (state) => {
|
|
13757
|
+
var _a2;
|
|
13758
|
+
const remoteId = ((_a2 = state.metadata) == null ? void 0 : _a2.remoteId) ?? state.threadId;
|
|
13759
|
+
return isLocalPlaceholder$1(remoteId) ? null : remoteId;
|
|
13760
|
+
};
|
|
13761
|
+
const createHydrationKey = ({
|
|
13762
|
+
backendUrl,
|
|
13763
|
+
threadId,
|
|
13764
|
+
apiKey,
|
|
13765
|
+
token
|
|
13766
|
+
}) => {
|
|
13767
|
+
const authMode = token ? "bearer" : apiKey ? "api-key" : "none";
|
|
13768
|
+
return `${backendUrl}::${authMode}::${threadId}`;
|
|
13769
|
+
};
|
|
13770
|
+
function useActiveThreadStateHydration({
|
|
13771
|
+
backendUrl,
|
|
13772
|
+
apiKey,
|
|
13773
|
+
token
|
|
13774
|
+
}) {
|
|
13775
|
+
const runtime = useAssistantRuntime({ optional: true });
|
|
13776
|
+
const threadId = useThread({
|
|
13777
|
+
optional: true,
|
|
13778
|
+
selector: selectHydratableThreadId
|
|
13779
|
+
}) ?? null;
|
|
13780
|
+
const messageCount = useThread({
|
|
13781
|
+
optional: true,
|
|
13782
|
+
selector: (state) => state.messages.length
|
|
13783
|
+
}) ?? 0;
|
|
13784
|
+
const isRunning = useThread({
|
|
13785
|
+
optional: true,
|
|
13786
|
+
selector: (state) => state.isRunning
|
|
13787
|
+
}) ?? false;
|
|
13788
|
+
const activeThreadIdRef = useRef(threadId);
|
|
13789
|
+
activeThreadIdRef.current = threadId;
|
|
13790
|
+
const hydratedKeysRef = useRef(/* @__PURE__ */ new Set());
|
|
13791
|
+
useEffect(() => {
|
|
13792
|
+
if (!runtime || !threadId || isRunning || messageCount > 0) {
|
|
13793
|
+
return;
|
|
13794
|
+
}
|
|
13795
|
+
if (!token && !apiKey) {
|
|
13796
|
+
return;
|
|
13797
|
+
}
|
|
13798
|
+
const hydrationKey = createHydrationKey({
|
|
13799
|
+
backendUrl,
|
|
13800
|
+
threadId,
|
|
13801
|
+
apiKey,
|
|
13802
|
+
token
|
|
13803
|
+
});
|
|
13804
|
+
if (hydratedKeysRef.current.has(hydrationKey)) {
|
|
13805
|
+
return;
|
|
13806
|
+
}
|
|
13807
|
+
let cancelled = false;
|
|
13808
|
+
(async () => {
|
|
13809
|
+
try {
|
|
13810
|
+
const state = await getThreadState(backendUrl, { apiKey, token }, threadId);
|
|
13811
|
+
if (cancelled || activeThreadIdRef.current !== threadId) {
|
|
13812
|
+
return;
|
|
13813
|
+
}
|
|
13814
|
+
if (runtime.thread.getState().messages.length > 0) {
|
|
13815
|
+
return;
|
|
13816
|
+
}
|
|
13817
|
+
runtime.thread.importExternalState(state);
|
|
13818
|
+
hydratedKeysRef.current.add(hydrationKey);
|
|
13819
|
+
} catch (error2) {
|
|
13820
|
+
console.warn("[AthenaSDK] Failed to hydrate active thread state:", error2);
|
|
13821
|
+
}
|
|
13822
|
+
})();
|
|
13823
|
+
return () => {
|
|
13824
|
+
cancelled = true;
|
|
13825
|
+
};
|
|
13826
|
+
}, [apiKey, backendUrl, isRunning, messageCount, runtime, threadId, token]);
|
|
13827
|
+
}
|
|
13828
|
+
const LOCAL_ID_PREFIX = "__LOCALID_";
|
|
13829
|
+
const isLocalPlaceholder = (id) => !!id && id.startsWith(LOCAL_ID_PREFIX);
|
|
13830
|
+
const selectActiveThreadRemoteId = (state) => {
|
|
13831
|
+
const { mainThreadId, threadItems } = state;
|
|
13832
|
+
if (!mainThreadId) {
|
|
13833
|
+
return null;
|
|
13834
|
+
}
|
|
13835
|
+
const item = threadItems[mainThreadId];
|
|
13836
|
+
const remoteId = item ? item.remoteId ?? null : mainThreadId;
|
|
13837
|
+
return isLocalPlaceholder(remoteId) ? null : remoteId;
|
|
13838
|
+
};
|
|
13839
|
+
function useAthenaThreadManager() {
|
|
13840
|
+
const runtime = useAssistantRuntime({ optional: true });
|
|
13841
|
+
const activeThreadId = useThreadList({
|
|
13842
|
+
optional: true,
|
|
13843
|
+
selector: selectActiveThreadRemoteId
|
|
13844
|
+
}) ?? null;
|
|
13845
|
+
const isThreadLoading = useThread({ optional: true, selector: (s) => s.isLoading }) ?? false;
|
|
13846
|
+
const isListLoading = useThreadList({
|
|
13847
|
+
optional: true,
|
|
13848
|
+
selector: (s) => s.isLoading
|
|
13849
|
+
});
|
|
13850
|
+
const runtimeRef = useRef(runtime);
|
|
13851
|
+
runtimeRef.current = runtime;
|
|
13852
|
+
const switchToThread = useCallback(
|
|
13853
|
+
(id) => runtimeRef.current.threads.switchToThread(id),
|
|
13854
|
+
[]
|
|
13855
|
+
);
|
|
13856
|
+
const switchToNewThread = useCallback(
|
|
13857
|
+
() => runtimeRef.current.threads.switchToNewThread(),
|
|
13858
|
+
[]
|
|
13859
|
+
);
|
|
13860
|
+
return useMemo(() => {
|
|
13861
|
+
if (!runtime || isListLoading == null) {
|
|
13862
|
+
return null;
|
|
13863
|
+
}
|
|
13864
|
+
return {
|
|
13865
|
+
activeThreadId,
|
|
13866
|
+
isListLoading,
|
|
13867
|
+
isThreadLoading,
|
|
13868
|
+
switchToThread,
|
|
13869
|
+
switchToNewThread
|
|
13870
|
+
};
|
|
13871
|
+
}, [runtime, activeThreadId, isListLoading, isThreadLoading, switchToThread, switchToNewThread]);
|
|
13872
|
+
}
|
|
13873
|
+
const POLL_DELAY_MS = 5e3;
|
|
13874
|
+
const POLL_INTERVAL_MS = 1e3;
|
|
13875
|
+
const POLL_MAX_DURATION_MS = 6e4;
|
|
13876
|
+
function useThreadTitlePolling(refresh) {
|
|
13877
|
+
const threadKey = useThread({
|
|
13878
|
+
optional: true,
|
|
13879
|
+
selector: (s) => {
|
|
13880
|
+
var _a2, _b;
|
|
13881
|
+
return ((_a2 = s.metadata) == null ? void 0 : _a2.remoteId) ?? ((_b = s.metadata) == null ? void 0 : _b.id) ?? s.threadId;
|
|
13882
|
+
}
|
|
13883
|
+
}) ?? null;
|
|
13884
|
+
const hasMessages = useThread({
|
|
13885
|
+
optional: true,
|
|
13886
|
+
selector: (s) => s.messages.length > 0
|
|
13887
|
+
}) ?? false;
|
|
13888
|
+
const currentTitle = useThreadList({
|
|
13889
|
+
optional: true,
|
|
13890
|
+
selector: (s) => {
|
|
13891
|
+
const main = s.threadItems[s.mainThreadId];
|
|
13892
|
+
return (main == null ? void 0 : main.title) ?? "";
|
|
13893
|
+
}
|
|
13894
|
+
}) ?? "";
|
|
13895
|
+
const hasTitle = currentTitle.trim().length > 0;
|
|
13896
|
+
const polledThreadsRef = useRef(/* @__PURE__ */ new Set());
|
|
13897
|
+
const refreshRef = useRef(refresh);
|
|
13898
|
+
refreshRef.current = refresh;
|
|
13899
|
+
useEffect(() => {
|
|
13900
|
+
if (!threadKey || hasTitle || !hasMessages) {
|
|
13901
|
+
return;
|
|
13902
|
+
}
|
|
13903
|
+
if (polledThreadsRef.current.has(threadKey)) {
|
|
13904
|
+
return;
|
|
13905
|
+
}
|
|
13906
|
+
polledThreadsRef.current.add(threadKey);
|
|
13907
|
+
let stopped = false;
|
|
13908
|
+
let intervalId = null;
|
|
13909
|
+
let maxTimeoutId = null;
|
|
13910
|
+
const stop = () => {
|
|
13911
|
+
stopped = true;
|
|
13912
|
+
if (intervalId !== null) {
|
|
13913
|
+
clearInterval(intervalId);
|
|
13914
|
+
intervalId = null;
|
|
13915
|
+
}
|
|
13916
|
+
if (maxTimeoutId !== null) {
|
|
13917
|
+
clearTimeout(maxTimeoutId);
|
|
13918
|
+
maxTimeoutId = null;
|
|
13919
|
+
}
|
|
13920
|
+
};
|
|
13921
|
+
const startTimeoutId = setTimeout(() => {
|
|
13922
|
+
if (stopped) return;
|
|
13923
|
+
refreshRef.current();
|
|
13924
|
+
intervalId = setInterval(() => {
|
|
13925
|
+
refreshRef.current();
|
|
13926
|
+
}, POLL_INTERVAL_MS);
|
|
13927
|
+
maxTimeoutId = setTimeout(stop, POLL_MAX_DURATION_MS - POLL_DELAY_MS);
|
|
13928
|
+
}, POLL_DELAY_MS);
|
|
13929
|
+
return () => {
|
|
13930
|
+
clearTimeout(startTimeoutId);
|
|
13931
|
+
stop();
|
|
13932
|
+
};
|
|
13933
|
+
}, [threadKey, hasTitle, hasMessages]);
|
|
13934
|
+
}
|
|
14202
13935
|
const THEME_TO_CSS = {
|
|
14203
13936
|
primary: "--primary",
|
|
14204
13937
|
primaryForeground: "--primary-foreground",
|
|
@@ -14517,7 +14250,7 @@ function AthenaStandalone({
|
|
|
14517
14250
|
return /* @__PURE__ */ jsx(AssistantRuntimeProvider, { aui, runtime, children: /* @__PURE__ */ jsx(AthenaContext.Provider, { value: athenaConfig, children: /* @__PURE__ */ jsx(TooltipProvider, { children }) }) });
|
|
14518
14251
|
}
|
|
14519
14252
|
function useAthenaRuntimeHook(config2) {
|
|
14520
|
-
const remoteId =
|
|
14253
|
+
const remoteId = useAthenaAuiThreadRemoteId();
|
|
14521
14254
|
return useAthenaRuntime({
|
|
14522
14255
|
apiUrl: config2.apiUrl,
|
|
14523
14256
|
backendUrl: config2.backendUrl,
|
|
@@ -14596,7 +14329,7 @@ function AthenaWithThreadList({
|
|
|
14596
14329
|
() => useAthenaRuntimeHook(runtimeConfigRef.current),
|
|
14597
14330
|
[]
|
|
14598
14331
|
);
|
|
14599
|
-
const runtime =
|
|
14332
|
+
const runtime = useRemoteThreadListRuntime({
|
|
14600
14333
|
runtimeHook,
|
|
14601
14334
|
adapter
|
|
14602
14335
|
});
|
|
@@ -14632,11 +14365,27 @@ function AthenaWithThreadList({
|
|
|
14632
14365
|
citationLinks
|
|
14633
14366
|
});
|
|
14634
14367
|
return /* @__PURE__ */ jsx(AssistantRuntimeProvider, { aui, runtime, children: /* @__PURE__ */ jsx(AthenaContext.Provider, { value: athenaConfig, children: /* @__PURE__ */ jsx(ThreadListRefreshContext.Provider, { value: handleRefresh, children: /* @__PURE__ */ jsxs(TooltipProvider, { children: [
|
|
14368
|
+
/* @__PURE__ */ jsx(
|
|
14369
|
+
ActiveThreadStateHydrator,
|
|
14370
|
+
{
|
|
14371
|
+
backendUrl,
|
|
14372
|
+
apiKey,
|
|
14373
|
+
token
|
|
14374
|
+
}
|
|
14375
|
+
),
|
|
14635
14376
|
/* @__PURE__ */ jsx(AssetPanelThreadSync, {}),
|
|
14636
14377
|
/* @__PURE__ */ jsx(ThreadTitlePoller, { refresh: handleRefresh }),
|
|
14637
14378
|
children
|
|
14638
14379
|
] }) }) }) });
|
|
14639
14380
|
}
|
|
14381
|
+
function ActiveThreadStateHydrator({
|
|
14382
|
+
backendUrl,
|
|
14383
|
+
apiKey,
|
|
14384
|
+
token
|
|
14385
|
+
}) {
|
|
14386
|
+
useActiveThreadStateHydration({ backendUrl, apiKey, token });
|
|
14387
|
+
return null;
|
|
14388
|
+
}
|
|
14640
14389
|
function AssetPanelThreadSync() {
|
|
14641
14390
|
const threads = useAthenaThreadManager();
|
|
14642
14391
|
const setCurrentThread = useAssetPanelStore((s) => s.setCurrentThread);
|
|
@@ -14659,6 +14408,7 @@ function AthenaProvider({
|
|
|
14659
14408
|
model,
|
|
14660
14409
|
tools = [],
|
|
14661
14410
|
frontendTools = {},
|
|
14411
|
+
disableAutoOpen = false,
|
|
14662
14412
|
apiUrl,
|
|
14663
14413
|
backendUrl,
|
|
14664
14414
|
appUrl,
|
|
@@ -14676,6 +14426,10 @@ function AthenaProvider({
|
|
|
14676
14426
|
posthog: posthogProp
|
|
14677
14427
|
}) {
|
|
14678
14428
|
const frontendToolNames = useMemo(() => Object.keys(frontendTools), [frontendTools]);
|
|
14429
|
+
const effectiveFrontendTools = useMemo(
|
|
14430
|
+
() => disableAutoOpen ? frontendTools : { ...DEFAULT_AUTO_OPEN_TOOLS, ...frontendTools },
|
|
14431
|
+
[disableAutoOpen, frontendTools]
|
|
14432
|
+
);
|
|
14679
14433
|
const themeStyleVars = useMemo(() => theme ? themeToStyleVars(theme) : void 0, [theme]);
|
|
14680
14434
|
const configuredEnvironment = (config2 == null ? void 0 : config2.environment) ?? environment;
|
|
14681
14435
|
const environmentUrls = useMemo(
|
|
@@ -14715,7 +14469,7 @@ function AthenaProvider({
|
|
|
14715
14469
|
agent: agent2,
|
|
14716
14470
|
tools,
|
|
14717
14471
|
frontendToolIds: frontendToolNames,
|
|
14718
|
-
frontendTools,
|
|
14472
|
+
frontendTools: effectiveFrontendTools,
|
|
14719
14473
|
workbench,
|
|
14720
14474
|
knowledgeBase,
|
|
14721
14475
|
systemPrompt,
|
|
@@ -14739,7 +14493,7 @@ function AthenaProvider({
|
|
|
14739
14493
|
agent: agent2,
|
|
14740
14494
|
tools,
|
|
14741
14495
|
frontendToolIds: frontendToolNames,
|
|
14742
|
-
frontendTools,
|
|
14496
|
+
frontendTools: effectiveFrontendTools,
|
|
14743
14497
|
workbench,
|
|
14744
14498
|
knowledgeBase,
|
|
14745
14499
|
systemPrompt,
|
|
@@ -46362,7 +46116,7 @@ const DEFAULT_PILL_STYLE = "border-gray-300 bg-gray-50 text-gray-800 dark:border
|
|
|
46362
46116
|
function MentionNodeView({ node }) {
|
|
46363
46117
|
const { type, name, params } = node.attrs;
|
|
46364
46118
|
const config2 = getMentionConfig(type);
|
|
46365
|
-
const icon = isRecord(params) && typeof params.icon === "string" ? params.icon : (config2 == null ? void 0 : config2.style.icon) ?? "📎";
|
|
46119
|
+
const icon = isRecord$1(params) && typeof params.icon === "string" ? params.icon : (config2 == null ? void 0 : config2.style.icon) ?? "📎";
|
|
46366
46120
|
const pillStyle = PILL_STYLES[type] ?? DEFAULT_PILL_STYLE;
|
|
46367
46121
|
return /* @__PURE__ */ jsx(NodeViewWrapper, { as: "span", children: /* @__PURE__ */ jsxs(
|
|
46368
46122
|
"span",
|
|
@@ -49628,7 +49382,7 @@ function getToolMeta(toolName) {
|
|
|
49628
49382
|
const displayName = toolName.replace(/_/g, " ").replace(/\b\w/g, (c) => c.toUpperCase());
|
|
49629
49383
|
return { displayName, icon: Wrench };
|
|
49630
49384
|
}
|
|
49631
|
-
function tryParseJson$
|
|
49385
|
+
function tryParseJson$1(text2) {
|
|
49632
49386
|
try {
|
|
49633
49387
|
const parsed = JSON.parse(text2);
|
|
49634
49388
|
if (typeof parsed === "object" && parsed !== null) return parsed;
|
|
@@ -49638,7 +49392,7 @@ function tryParseJson$2(text2) {
|
|
|
49638
49392
|
}
|
|
49639
49393
|
function extractResultMessage(result) {
|
|
49640
49394
|
if (typeof result === "string") {
|
|
49641
|
-
const parsed = tryParseJson$
|
|
49395
|
+
const parsed = tryParseJson$1(result);
|
|
49642
49396
|
if (parsed && typeof parsed.message === "string") return parsed.message;
|
|
49643
49397
|
return null;
|
|
49644
49398
|
}
|
|
@@ -49650,7 +49404,7 @@ function extractResultMessage(result) {
|
|
|
49650
49404
|
}
|
|
49651
49405
|
function isResultSuccess(result) {
|
|
49652
49406
|
if (typeof result === "string") {
|
|
49653
|
-
const parsed = tryParseJson$
|
|
49407
|
+
const parsed = tryParseJson$1(result);
|
|
49654
49408
|
if (parsed) return parsed.success === true;
|
|
49655
49409
|
}
|
|
49656
49410
|
if (typeof result === "object" && result !== null) {
|
|
@@ -49672,7 +49426,7 @@ function extractAssetId$1(result) {
|
|
|
49672
49426
|
}
|
|
49673
49427
|
function extractAssetIdFromArgs(argsText) {
|
|
49674
49428
|
if (!argsText) return null;
|
|
49675
|
-
const parsed = tryParseJson$
|
|
49429
|
+
const parsed = tryParseJson$1(argsText);
|
|
49676
49430
|
if (!parsed) return null;
|
|
49677
49431
|
const id = parsed.asset_id ?? parsed.assetId;
|
|
49678
49432
|
if (typeof id === "string" && id.startsWith("asset_")) return id;
|
|
@@ -49702,7 +49456,7 @@ function isAssetTool(toolName, result) {
|
|
|
49702
49456
|
}
|
|
49703
49457
|
function extractTitle(argsText, result) {
|
|
49704
49458
|
if (argsText) {
|
|
49705
|
-
const args = tryParseJson$
|
|
49459
|
+
const args = tryParseJson$1(argsText);
|
|
49706
49460
|
if (args) {
|
|
49707
49461
|
const t = args.title ?? args.name ?? args.filename ?? args.sheet_name;
|
|
49708
49462
|
if (t) return t;
|
|
@@ -49783,7 +49537,7 @@ function ToolFallbackTrigger({
|
|
|
49783
49537
|
const success = isComplete && isResultSuccess(result);
|
|
49784
49538
|
const summary = useMemo(() => {
|
|
49785
49539
|
if (isRunning || !meta.describer || !argsText) return null;
|
|
49786
|
-
const parsed = tryParseJson$
|
|
49540
|
+
const parsed = tryParseJson$1(argsText);
|
|
49787
49541
|
if (!parsed) return null;
|
|
49788
49542
|
const desc = meta.describer(parsed);
|
|
49789
49543
|
return desc || null;
|
|
@@ -49892,7 +49646,7 @@ function ToolFallbackArgs({
|
|
|
49892
49646
|
...props
|
|
49893
49647
|
}) {
|
|
49894
49648
|
if (!argsText) return null;
|
|
49895
|
-
const parsed = tryParseJson$
|
|
49649
|
+
const parsed = tryParseJson$1(argsText);
|
|
49896
49650
|
if (!parsed) {
|
|
49897
49651
|
return /* @__PURE__ */ jsx("div", { className: cn("px-3", className), ...props, children: /* @__PURE__ */ jsx("pre", { className: "whitespace-pre-wrap text-xs text-muted-foreground", children: argsText }) });
|
|
49898
49652
|
}
|
|
@@ -49916,7 +49670,7 @@ function ToolFallbackResult({
|
|
|
49916
49670
|
const displayValue = useMemo(() => {
|
|
49917
49671
|
if (result === void 0) return "";
|
|
49918
49672
|
if (typeof result === "string") {
|
|
49919
|
-
const parsed = tryParseJson$
|
|
49673
|
+
const parsed = tryParseJson$1(result);
|
|
49920
49674
|
return parsed ? JSON.stringify(parsed, null, 2) : result;
|
|
49921
49675
|
}
|
|
49922
49676
|
return JSON.stringify(result, null, 2);
|
|
@@ -49960,12 +49714,12 @@ function CopyToolSpec({
|
|
|
49960
49714
|
const handleCopy = useCallback(() => {
|
|
49961
49715
|
const spec = { tool_name: toolName };
|
|
49962
49716
|
if (argsText) {
|
|
49963
|
-
const parsed = tryParseJson$
|
|
49717
|
+
const parsed = tryParseJson$1(argsText);
|
|
49964
49718
|
spec.arguments = parsed ?? argsText;
|
|
49965
49719
|
}
|
|
49966
49720
|
if (result !== void 0) {
|
|
49967
49721
|
if (typeof result === "string") {
|
|
49968
|
-
const parsed = tryParseJson$
|
|
49722
|
+
const parsed = tryParseJson$1(result);
|
|
49969
49723
|
spec.result = parsed ?? result;
|
|
49970
49724
|
} else {
|
|
49971
49725
|
spec.result = result;
|
|
@@ -50007,18 +49761,6 @@ function AssetToolCard({
|
|
|
50007
49761
|
const assetId = extractAssetId$1(result);
|
|
50008
49762
|
const title = extractTitle(argsText, result);
|
|
50009
49763
|
const assetType = toolMetaToAssetType(toolName);
|
|
50010
|
-
const wasCompleteAtMount = useRef(isComplete);
|
|
50011
|
-
useEffect(() => {
|
|
50012
|
-
if (isComplete && !isCancelled && assetId && !wasCompleteAtMount.current) {
|
|
50013
|
-
const store = useAssetPanelStore.getState();
|
|
50014
|
-
if (store.markAutoOpened(assetId)) {
|
|
50015
|
-
store.openAsset(assetId, {
|
|
50016
|
-
name: title ?? void 0,
|
|
50017
|
-
type: assetType
|
|
50018
|
-
});
|
|
50019
|
-
}
|
|
50020
|
-
}
|
|
50021
|
-
}, [isComplete, isCancelled, assetId, title, assetType]);
|
|
50022
49764
|
const success = isComplete && isResultSuccess(result);
|
|
50023
49765
|
return /* @__PURE__ */ jsxs("div", { className: cn(
|
|
50024
49766
|
"aui-tool-fallback-root my-3 w-full rounded-xl border border-border/60 bg-background py-2.5 shadow-sm",
|
|
@@ -50166,17 +49908,6 @@ ToolFallback.Content = ToolFallbackContent;
|
|
|
50166
49908
|
ToolFallback.Args = ToolFallbackArgs;
|
|
50167
49909
|
ToolFallback.Result = ToolFallbackResult;
|
|
50168
49910
|
ToolFallback.Error = ToolFallbackError;
|
|
50169
|
-
function getAssetInfo(assetId) {
|
|
50170
|
-
return { name: assetId || "Document", icon: "doc" };
|
|
50171
|
-
}
|
|
50172
|
-
function tryParseJson$1(text2) {
|
|
50173
|
-
try {
|
|
50174
|
-
const p = JSON.parse(text2);
|
|
50175
|
-
return typeof p === "object" && p !== null ? p : null;
|
|
50176
|
-
} catch {
|
|
50177
|
-
return null;
|
|
50178
|
-
}
|
|
50179
|
-
}
|
|
50180
49911
|
const markdownPreviewExtensions = [
|
|
50181
49912
|
StarterKit.configure({
|
|
50182
49913
|
codeBlock: {
|
|
@@ -50225,10 +49956,10 @@ const AppendDocumentToolUIImpl = ({
|
|
|
50225
49956
|
const typedArgs = args;
|
|
50226
49957
|
const resultData = useMemo(() => {
|
|
50227
49958
|
if (!result) return null;
|
|
50228
|
-
if (typeof result === "string") return tryParseJson$
|
|
49959
|
+
if (typeof result === "string") return tryParseJson$2(result);
|
|
50229
49960
|
if (typeof result === "object") {
|
|
50230
49961
|
const obj = result;
|
|
50231
|
-
if (typeof obj.result === "string") return tryParseJson$
|
|
49962
|
+
if (typeof obj.result === "string") return tryParseJson$2(obj.result) ?? obj;
|
|
50232
49963
|
return obj;
|
|
50233
49964
|
}
|
|
50234
49965
|
return null;
|
|
@@ -50310,11 +50041,11 @@ const AppendDocumentToolUI = memo(
|
|
|
50310
50041
|
);
|
|
50311
50042
|
AppendDocumentToolUI.displayName = "AppendDocumentToolUI";
|
|
50312
50043
|
function normalizeResult$1(result) {
|
|
50313
|
-
if (typeof result === "string") return tryParseJson$
|
|
50044
|
+
if (typeof result === "string") return tryParseJson$2(result) ?? result;
|
|
50314
50045
|
if (typeof result === "object" && result !== null) {
|
|
50315
50046
|
const obj = result;
|
|
50316
50047
|
if (typeof obj.result === "string")
|
|
50317
|
-
return tryParseJson$
|
|
50048
|
+
return tryParseJson$2(obj.result) ?? obj.result;
|
|
50318
50049
|
return obj;
|
|
50319
50050
|
}
|
|
50320
50051
|
return result;
|
|
@@ -50580,6 +50311,32 @@ function normalizeResult(result) {
|
|
|
50580
50311
|
function truncate(text2, max2) {
|
|
50581
50312
|
return text2.length > max2 ? `${text2.slice(0, max2)}...` : text2;
|
|
50582
50313
|
}
|
|
50314
|
+
function isSdkToolDebugEnabled() {
|
|
50315
|
+
var _a2, _b;
|
|
50316
|
+
try {
|
|
50317
|
+
const hostname = (_a2 = globalThis.location) == null ? void 0 : _a2.hostname;
|
|
50318
|
+
if (hostname === "localhost" || hostname === "127.0.0.1" || hostname === "::1") {
|
|
50319
|
+
return true;
|
|
50320
|
+
}
|
|
50321
|
+
return ((_b = globalThis.localStorage) == null ? void 0 : _b.getItem("athena:sdk:debug")) === "1";
|
|
50322
|
+
} catch {
|
|
50323
|
+
return false;
|
|
50324
|
+
}
|
|
50325
|
+
}
|
|
50326
|
+
function stringifyDebugPayload(payload) {
|
|
50327
|
+
return JSON.stringify(payload, (_key, value) => {
|
|
50328
|
+
if (typeof value === "string" && value.length > 800) {
|
|
50329
|
+
return `${value.slice(0, 800)}... [truncated ${value.length - 800} chars]`;
|
|
50330
|
+
}
|
|
50331
|
+
return value;
|
|
50332
|
+
});
|
|
50333
|
+
}
|
|
50334
|
+
function logDebugPayload(label, payload) {
|
|
50335
|
+
if (!isSdkToolDebugEnabled()) {
|
|
50336
|
+
return;
|
|
50337
|
+
}
|
|
50338
|
+
console.info(`${label} ${stringifyDebugPayload(payload)}`);
|
|
50339
|
+
}
|
|
50583
50340
|
function formatToolName(name) {
|
|
50584
50341
|
return name.replace(/_/g, " ").replace(/\b\w/g, (c) => c.toUpperCase());
|
|
50585
50342
|
}
|
|
@@ -50890,6 +50647,20 @@ function getNumberField(source, keys2) {
|
|
|
50890
50647
|
}
|
|
50891
50648
|
return null;
|
|
50892
50649
|
}
|
|
50650
|
+
const PRESENTATION_CODE_SLIDE_NUMBER_KEYS = [
|
|
50651
|
+
"slideNumber",
|
|
50652
|
+
"slide_number",
|
|
50653
|
+
"targetSlideNumber",
|
|
50654
|
+
"target_slide_number",
|
|
50655
|
+
"targetSlide",
|
|
50656
|
+
"target_slide"
|
|
50657
|
+
];
|
|
50658
|
+
const PRESENTATION_CODE_SLIDE_INDEX_KEYS = [
|
|
50659
|
+
"slideIndex",
|
|
50660
|
+
"slide_index",
|
|
50661
|
+
"targetSlideIndex",
|
|
50662
|
+
"target_slide_index"
|
|
50663
|
+
];
|
|
50893
50664
|
function getStudioAssetId({
|
|
50894
50665
|
args,
|
|
50895
50666
|
result
|
|
@@ -50897,41 +50668,42 @@ function getStudioAssetId({
|
|
|
50897
50668
|
const id = getStringField(result, ["asset_id", "assetId", "id"]) ?? getStringField(args, ["asset_id", "assetId", "id"]);
|
|
50898
50669
|
return (id == null ? void 0 : id.startsWith("asset_")) ? id : null;
|
|
50899
50670
|
}
|
|
50900
|
-
function
|
|
50901
|
-
const
|
|
50671
|
+
function getPresentationCodeDeckId(code2) {
|
|
50672
|
+
const match2 = code2.match(/\bdeck_id\s*=\s*["']([^"']+)["']/);
|
|
50673
|
+
const deckId = match2 == null ? void 0 : match2[1];
|
|
50674
|
+
return (deckId == null ? void 0 : deckId.startsWith("asset_")) ? deckId : null;
|
|
50675
|
+
}
|
|
50676
|
+
function getPresentationCodeSlideNumberFromFields(source) {
|
|
50677
|
+
const explicit = getNumberField(source, PRESENTATION_CODE_SLIDE_NUMBER_KEYS);
|
|
50902
50678
|
if (explicit != null && Number.isInteger(explicit) && explicit >= 1) {
|
|
50903
50679
|
return explicit;
|
|
50904
50680
|
}
|
|
50905
|
-
const zeroBasedIndex = getNumberField(
|
|
50681
|
+
const zeroBasedIndex = getNumberField(source, PRESENTATION_CODE_SLIDE_INDEX_KEYS);
|
|
50906
50682
|
if (zeroBasedIndex != null && Number.isInteger(zeroBasedIndex) && zeroBasedIndex >= 0) {
|
|
50907
50683
|
return zeroBasedIndex + 1;
|
|
50908
50684
|
}
|
|
50909
50685
|
return void 0;
|
|
50910
50686
|
}
|
|
50911
|
-
|
|
50912
|
-
const
|
|
50913
|
-
|
|
50914
|
-
|
|
50915
|
-
return false;
|
|
50916
|
-
}
|
|
50917
|
-
if (completedStudioToolEffects.size >= MAX_COMPLETED_STUDIO_TOOL_EFFECTS) {
|
|
50918
|
-
const oldest = completedStudioToolEffects.values().next().value;
|
|
50919
|
-
if (oldest) completedStudioToolEffects.delete(oldest);
|
|
50687
|
+
function getPresentationCodeSlideNumberFromText(text2) {
|
|
50688
|
+
const match2 = text2 == null ? void 0 : text2.match(/\bslide\s*(?:#|number\s*)?(\d+)\b/i);
|
|
50689
|
+
if (!match2) {
|
|
50690
|
+
return void 0;
|
|
50920
50691
|
}
|
|
50921
|
-
|
|
50922
|
-
return
|
|
50692
|
+
const slideNumber = Number.parseInt(match2[1] ?? "", 10);
|
|
50693
|
+
return Number.isInteger(slideNumber) && slideNumber >= 1 ? slideNumber : void 0;
|
|
50923
50694
|
}
|
|
50924
|
-
function
|
|
50925
|
-
|
|
50926
|
-
|
|
50927
|
-
|
|
50928
|
-
|
|
50929
|
-
|
|
50930
|
-
new CustomEvent("pptx-studio-navigate", {
|
|
50931
|
-
detail: { assetId, slideNumber: targetSlide }
|
|
50932
|
-
})
|
|
50695
|
+
function getPresentationCodeSlideNumber({
|
|
50696
|
+
args,
|
|
50697
|
+
result
|
|
50698
|
+
}) {
|
|
50699
|
+
return getPresentationCodeSlideNumberFromFields(args) ?? getPresentationCodeSlideNumberFromFields(result) ?? getPresentationCodeSlideNumberFromText(
|
|
50700
|
+
getStringField(args, ["summary", "title", "description"])
|
|
50933
50701
|
);
|
|
50934
50702
|
}
|
|
50703
|
+
function getAddSlideNumber(args) {
|
|
50704
|
+
const index2 = getNumberField(args, ["index"]);
|
|
50705
|
+
return index2 != null && Number.isInteger(index2) && index2 >= 0 ? index2 + 1 : void 0;
|
|
50706
|
+
}
|
|
50935
50707
|
function CreateAssetToolUIImpl({
|
|
50936
50708
|
icon: Icon2,
|
|
50937
50709
|
assetType,
|
|
@@ -50952,18 +50724,6 @@ function CreateAssetToolUIImpl({
|
|
|
50952
50724
|
const isCancelled = (status == null ? void 0 : status.type) === "incomplete" && status.reason === "cancelled";
|
|
50953
50725
|
const errorMsg = (status == null ? void 0 : status.type) === "incomplete" ? status.error : null;
|
|
50954
50726
|
const openAsset = useAssetPanelStore((s) => s.openAsset);
|
|
50955
|
-
const wasCompleteAtMount = useRef(isComplete);
|
|
50956
|
-
useEffect(() => {
|
|
50957
|
-
if (isComplete && !isCancelled && assetId && !wasCompleteAtMount.current) {
|
|
50958
|
-
const store = useAssetPanelStore.getState();
|
|
50959
|
-
if (store.markAutoOpened(assetId)) {
|
|
50960
|
-
store.openAsset(assetId, {
|
|
50961
|
-
name: createdName || name || void 0,
|
|
50962
|
-
type: assetType
|
|
50963
|
-
});
|
|
50964
|
-
}
|
|
50965
|
-
}
|
|
50966
|
-
}, [isComplete, isCancelled, assetId, createdName, name, assetType]);
|
|
50967
50727
|
const handleOpen = () => {
|
|
50968
50728
|
if (assetId) {
|
|
50969
50729
|
openAsset(assetId, {
|
|
@@ -51041,10 +50801,23 @@ const CreatePresentationToolUI = memo(
|
|
|
51041
50801
|
CreatePresentationToolUIImpl
|
|
51042
50802
|
);
|
|
51043
50803
|
CreatePresentationToolUI.displayName = "CreatePresentationToolUI";
|
|
50804
|
+
function openStudioAsset({
|
|
50805
|
+
assetId,
|
|
50806
|
+
assetType,
|
|
50807
|
+
slideNumber,
|
|
50808
|
+
preserveExistingSlide
|
|
50809
|
+
}) {
|
|
50810
|
+
const store = useAssetPanelStore.getState();
|
|
50811
|
+
const existing = store.tabs.find((tab) => tab.id === assetId);
|
|
50812
|
+
const shouldKeepCurrentSlide = preserveExistingSlide && existing;
|
|
50813
|
+
store.openAsset(assetId, {
|
|
50814
|
+
type: assetType,
|
|
50815
|
+
...!shouldKeepCurrentSlide && slideNumber !== void 0 ? { slideNumber } : {}
|
|
50816
|
+
});
|
|
50817
|
+
}
|
|
51044
50818
|
function StudioPtcToolUI({
|
|
51045
50819
|
config: config2,
|
|
51046
50820
|
toolName,
|
|
51047
|
-
toolCallId,
|
|
51048
50821
|
args,
|
|
51049
50822
|
result,
|
|
51050
50823
|
status
|
|
@@ -51059,42 +50832,57 @@ function StudioPtcToolUI({
|
|
|
51059
50832
|
const isComplete = (status == null ? void 0 : status.type) === "complete" || !status;
|
|
51060
50833
|
const isCancelled = (status == null ? void 0 : status.type) === "incomplete" && status.reason === "cancelled";
|
|
51061
50834
|
const errorMsg = (status == null ? void 0 : status.type) === "incomplete" ? String(status.error ?? status.reason ?? "Tool failed") : null;
|
|
51062
|
-
const openAsset = useAssetPanelStore((s) => s.openAsset);
|
|
51063
50835
|
const handleOpen = useCallback(() => {
|
|
51064
50836
|
if (!assetId) return;
|
|
51065
|
-
|
|
51066
|
-
|
|
51067
|
-
|
|
51068
|
-
|
|
51069
|
-
|
|
51070
|
-
|
|
50837
|
+
if (toolName === "AddSlide") {
|
|
50838
|
+
logDebugPayload("[Athena SDK AddSlide] manual open", {
|
|
50839
|
+
args: typedArgs,
|
|
50840
|
+
parsedResult: data,
|
|
50841
|
+
rawResult: result,
|
|
50842
|
+
assetId,
|
|
50843
|
+
slideNumber
|
|
50844
|
+
});
|
|
51071
50845
|
}
|
|
51072
|
-
|
|
50846
|
+
openStudioAsset({
|
|
50847
|
+
assetId,
|
|
50848
|
+
assetType: config2.assetType,
|
|
50849
|
+
slideNumber,
|
|
50850
|
+
preserveExistingSlide: config2.preserveExistingSlide
|
|
50851
|
+
});
|
|
50852
|
+
}, [
|
|
50853
|
+
assetId,
|
|
50854
|
+
config2.assetType,
|
|
50855
|
+
config2.preserveExistingSlide,
|
|
50856
|
+
data,
|
|
50857
|
+
result,
|
|
50858
|
+
slideNumber,
|
|
50859
|
+
toolName,
|
|
50860
|
+
typedArgs
|
|
50861
|
+
]);
|
|
51073
50862
|
useEffect(() => {
|
|
51074
|
-
if (
|
|
51075
|
-
return;
|
|
51076
|
-
}
|
|
51077
|
-
const effectKey = toolCallId ?? `${toolName ?? "studio-tool"}:${assetId}:${slideNumber ?? "asset"}`;
|
|
51078
|
-
if (!markStudioToolEffect(effectKey)) {
|
|
50863
|
+
if (toolName !== "AddSlide") {
|
|
51079
50864
|
return;
|
|
51080
50865
|
}
|
|
51081
|
-
|
|
51082
|
-
|
|
51083
|
-
|
|
51084
|
-
|
|
50866
|
+
logDebugPayload("[Athena SDK AddSlide] tool state", {
|
|
50867
|
+
args: typedArgs,
|
|
50868
|
+
parsedResult: data,
|
|
50869
|
+
rawResult: result,
|
|
50870
|
+
status,
|
|
50871
|
+
assetId,
|
|
50872
|
+
slideNumber,
|
|
50873
|
+
isComplete,
|
|
50874
|
+
isCancelled
|
|
51085
50875
|
});
|
|
51086
|
-
if (config2.assetType === "presentation") {
|
|
51087
|
-
dispatchPresentationNavigate(assetId, slideNumber);
|
|
51088
|
-
}
|
|
51089
50876
|
}, [
|
|
51090
50877
|
assetId,
|
|
51091
|
-
|
|
51092
|
-
config2.autoOpen,
|
|
50878
|
+
data,
|
|
51093
50879
|
isCancelled,
|
|
51094
50880
|
isComplete,
|
|
50881
|
+
result,
|
|
51095
50882
|
slideNumber,
|
|
51096
|
-
|
|
51097
|
-
toolName
|
|
50883
|
+
status,
|
|
50884
|
+
toolName,
|
|
50885
|
+
typedArgs
|
|
51098
50886
|
]);
|
|
51099
50887
|
return /* @__PURE__ */ jsx(
|
|
51100
50888
|
ToolCard,
|
|
@@ -51152,8 +50940,7 @@ const StudioCreateWorkbookToolUI = createStudioPtcToolUI(
|
|
|
51152
50940
|
},
|
|
51153
50941
|
doneLabel: () => "Workbook created",
|
|
51154
50942
|
getSubtitle: getNameSubtitle,
|
|
51155
|
-
openLabel: () => "Open workbook"
|
|
51156
|
-
autoOpen: true
|
|
50943
|
+
openLabel: () => "Open workbook"
|
|
51157
50944
|
}
|
|
51158
50945
|
);
|
|
51159
50946
|
const StudioAddSheetToolUI = createStudioPtcToolUI(
|
|
@@ -51171,8 +50958,7 @@ const StudioAddSheetToolUI = createStudioPtcToolUI(
|
|
|
51171
50958
|
return name ? `Sheet added: ${name}` : "Sheet added";
|
|
51172
50959
|
},
|
|
51173
50960
|
getSubtitle: (args) => getStringField(args, ["name", "sheetName", "sheet_name"]) ?? void 0,
|
|
51174
|
-
openLabel: () => "Open workbook"
|
|
51175
|
-
autoOpen: true
|
|
50961
|
+
openLabel: () => "Open workbook"
|
|
51176
50962
|
}
|
|
51177
50963
|
);
|
|
51178
50964
|
const StudioOpenWorkbookToolUI = createStudioPtcToolUI(
|
|
@@ -51183,8 +50969,7 @@ const StudioOpenWorkbookToolUI = createStudioPtcToolUI(
|
|
|
51183
50969
|
badge: "Sheet",
|
|
51184
50970
|
runningLabel: () => "Opening workbook...",
|
|
51185
50971
|
doneLabel: () => "Workbook opened",
|
|
51186
|
-
openLabel: () => "Open workbook"
|
|
51187
|
-
autoOpen: true
|
|
50972
|
+
openLabel: () => "Open workbook"
|
|
51188
50973
|
}
|
|
51189
50974
|
);
|
|
51190
50975
|
const StudioCreatePresentationToolUI = createStudioPtcToolUI(
|
|
@@ -51200,8 +50985,7 @@ const StudioCreatePresentationToolUI = createStudioPtcToolUI(
|
|
|
51200
50985
|
doneLabel: () => "Presentation created",
|
|
51201
50986
|
getSubtitle: getNameSubtitle,
|
|
51202
50987
|
getSlideNumber: () => 1,
|
|
51203
|
-
openLabel: () => "Open presentation"
|
|
51204
|
-
autoOpen: true
|
|
50988
|
+
openLabel: () => "Open presentation"
|
|
51205
50989
|
}
|
|
51206
50990
|
);
|
|
51207
50991
|
const StudioOpenPresentationToolUI = createStudioPtcToolUI(
|
|
@@ -51215,7 +50999,7 @@ const StudioOpenPresentationToolUI = createStudioPtcToolUI(
|
|
|
51215
50999
|
getSlideNumber: () => 1,
|
|
51216
51000
|
getSubtitle: (_args, _result, slideNumber) => slideNumber ? `Slide ${slideNumber}` : void 0,
|
|
51217
51001
|
openLabel: () => "Open presentation",
|
|
51218
|
-
|
|
51002
|
+
preserveExistingSlide: true
|
|
51219
51003
|
}
|
|
51220
51004
|
);
|
|
51221
51005
|
const StudioAddSlideToolUI = createStudioPtcToolUI(
|
|
@@ -51227,9 +51011,8 @@ const StudioAddSlideToolUI = createStudioPtcToolUI(
|
|
|
51227
51011
|
runningLabel: () => "Adding slide...",
|
|
51228
51012
|
doneLabel: (_args, slideNumber) => slideNumber ? `Slide ${slideNumber} added` : "Slide added",
|
|
51229
51013
|
getSubtitle: getSlideSubtitle,
|
|
51230
|
-
getSlideNumber,
|
|
51231
|
-
openLabel: (slideNumber) => slideNumber ? `Open slide ${slideNumber}` : "Open presentation"
|
|
51232
|
-
autoOpen: true
|
|
51014
|
+
getSlideNumber: (args) => getAddSlideNumber(args) ?? 1,
|
|
51015
|
+
openLabel: (slideNumber) => slideNumber ? `Open slide ${slideNumber}` : "Open presentation"
|
|
51233
51016
|
}
|
|
51234
51017
|
);
|
|
51235
51018
|
const StudioCreateDocumentToolUI = createStudioPtcToolUI(
|
|
@@ -51244,8 +51027,7 @@ const StudioCreateDocumentToolUI = createStudioPtcToolUI(
|
|
|
51244
51027
|
},
|
|
51245
51028
|
doneLabel: () => "Document created",
|
|
51246
51029
|
getSubtitle: getNameSubtitle,
|
|
51247
|
-
openLabel: () => "Open document"
|
|
51248
|
-
autoOpen: true
|
|
51030
|
+
openLabel: () => "Open document"
|
|
51249
51031
|
}
|
|
51250
51032
|
);
|
|
51251
51033
|
const StudioCreateParagraphToolUI = createStudioPtcToolUI(
|
|
@@ -51257,8 +51039,7 @@ const StudioCreateParagraphToolUI = createStudioPtcToolUI(
|
|
|
51257
51039
|
runningLabel: () => "Adding paragraph...",
|
|
51258
51040
|
doneLabel: () => "Paragraph added",
|
|
51259
51041
|
getSubtitle: getParagraphSubtitle,
|
|
51260
|
-
openLabel: () => "Open document"
|
|
51261
|
-
autoOpen: true
|
|
51042
|
+
openLabel: () => "Open document"
|
|
51262
51043
|
}
|
|
51263
51044
|
);
|
|
51264
51045
|
const StudioOpenDocumentToolUI = createStudioPtcToolUI(
|
|
@@ -51269,8 +51050,7 @@ const StudioOpenDocumentToolUI = createStudioPtcToolUI(
|
|
|
51269
51050
|
badge: "Doc",
|
|
51270
51051
|
runningLabel: () => "Opening document...",
|
|
51271
51052
|
doneLabel: () => "Document opened",
|
|
51272
|
-
openLabel: () => "Open document"
|
|
51273
|
-
autoOpen: true
|
|
51053
|
+
openLabel: () => "Open document"
|
|
51274
51054
|
}
|
|
51275
51055
|
);
|
|
51276
51056
|
const CreateEmailDraftToolUIImpl = ({
|
|
@@ -51778,7 +51558,7 @@ const ExecutePresentationCodeToolUIImpl = ({
|
|
|
51778
51558
|
const typedArgs = args;
|
|
51779
51559
|
const code2 = (typedArgs == null ? void 0 : typedArgs.code) ?? "";
|
|
51780
51560
|
const summary = (typedArgs == null ? void 0 : typedArgs.summary) ?? null;
|
|
51781
|
-
const deckIdFromArgs =
|
|
51561
|
+
const deckIdFromArgs = getStringField(typedArgs, ["deck_id", "deckId", "asset_id", "assetId"]) ?? getPresentationCodeDeckId(code2);
|
|
51782
51562
|
const isRunning = (status == null ? void 0 : status.type) === "running";
|
|
51783
51563
|
const isComplete = (status == null ? void 0 : status.type) === "complete";
|
|
51784
51564
|
const errorMsg = (status == null ? void 0 : status.type) === "incomplete" ? status.error : null;
|
|
@@ -51786,21 +51566,55 @@ const ExecutePresentationCodeToolUIImpl = ({
|
|
|
51786
51566
|
() => isComplete ? parsePythonResult(result) : null,
|
|
51787
51567
|
[result, isComplete]
|
|
51788
51568
|
);
|
|
51569
|
+
const resultData = useMemo(() => normalizeResult(result), [result]);
|
|
51789
51570
|
const outputText = parsed ? getExecutionTextOutput(parsed) : null;
|
|
51790
|
-
const
|
|
51571
|
+
const targetSlideNumber = getPresentationCodeSlideNumber({
|
|
51572
|
+
args: typedArgs,
|
|
51573
|
+
result: resultData
|
|
51574
|
+
});
|
|
51791
51575
|
const deckId = (parsed == null ? void 0 : parsed.deckId) ?? deckIdFromArgs;
|
|
51576
|
+
const assetId = (parsed == null ? void 0 : parsed.assetId) ?? ((deckId == null ? void 0 : deckId.startsWith("asset_")) ? deckId : null);
|
|
51792
51577
|
const hasError = parsed && (parsed.error || parsed.exception);
|
|
51793
51578
|
const openAsset = useAssetPanelStore((s) => s.openAsset);
|
|
51794
|
-
const wasCompleteAtMount = useRef(isComplete);
|
|
51795
51579
|
useEffect(() => {
|
|
51796
|
-
if (!isComplete
|
|
51580
|
+
if (!isComplete) {
|
|
51797
51581
|
return;
|
|
51798
51582
|
}
|
|
51799
|
-
|
|
51800
|
-
|
|
51801
|
-
|
|
51583
|
+
logDebugPayload("[Athena SDK execute_presentation_code] tool state", {
|
|
51584
|
+
args: typedArgs,
|
|
51585
|
+
parsedResult: resultData,
|
|
51586
|
+
status,
|
|
51587
|
+
assetId,
|
|
51588
|
+
deckId,
|
|
51589
|
+
targetSlideNumber,
|
|
51590
|
+
outputText
|
|
51591
|
+
});
|
|
51592
|
+
}, [
|
|
51593
|
+
assetId,
|
|
51594
|
+
deckId,
|
|
51595
|
+
isComplete,
|
|
51596
|
+
outputText,
|
|
51597
|
+
resultData,
|
|
51598
|
+
status,
|
|
51599
|
+
targetSlideNumber,
|
|
51600
|
+
typedArgs
|
|
51601
|
+
]);
|
|
51602
|
+
const openPresentation = useCallback(() => {
|
|
51603
|
+
if (!assetId) {
|
|
51604
|
+
return;
|
|
51802
51605
|
}
|
|
51803
|
-
|
|
51606
|
+
logDebugPayload("[Athena SDK execute_presentation_code] open deck", {
|
|
51607
|
+
args: typedArgs,
|
|
51608
|
+
parsedResult: resultData,
|
|
51609
|
+
assetId,
|
|
51610
|
+
deckId,
|
|
51611
|
+
targetSlideNumber
|
|
51612
|
+
});
|
|
51613
|
+
openAsset(assetId, {
|
|
51614
|
+
type: "presentation",
|
|
51615
|
+
...targetSlideNumber !== void 0 ? { slideNumber: targetSlideNumber } : {}
|
|
51616
|
+
});
|
|
51617
|
+
}, [assetId, deckId, openAsset, resultData, targetSlideNumber, typedArgs]);
|
|
51804
51618
|
return /* @__PURE__ */ jsxs(
|
|
51805
51619
|
ToolCard,
|
|
51806
51620
|
{
|
|
@@ -51823,11 +51637,11 @@ const ExecutePresentationCodeToolUIImpl = ({
|
|
|
51823
51637
|
"button",
|
|
51824
51638
|
{
|
|
51825
51639
|
type: "button",
|
|
51826
|
-
onClick:
|
|
51640
|
+
onClick: openPresentation,
|
|
51827
51641
|
className: "flex shrink-0 items-center gap-1.5 rounded-md border border-border/60 px-3 py-1.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted/50 hover:text-foreground",
|
|
51828
51642
|
children: [
|
|
51829
51643
|
/* @__PURE__ */ jsx(ExternalLink, { className: "size-3" }),
|
|
51830
|
-
"Open deck"
|
|
51644
|
+
targetSlideNumber ? `Open slide ${targetSlideNumber}` : "Open deck"
|
|
51831
51645
|
]
|
|
51832
51646
|
}
|
|
51833
51647
|
)
|
|
@@ -51886,15 +51700,6 @@ const OpenAssetToolUIImpl = ({
|
|
|
51886
51700
|
const isCancelled = (status == null ? void 0 : status.type) === "incomplete" && status.reason === "cancelled";
|
|
51887
51701
|
const errorMsg = (status == null ? void 0 : status.type) === "incomplete" ? status.error : null;
|
|
51888
51702
|
const openAsset = useAssetPanelStore((s) => s.openAsset);
|
|
51889
|
-
const wasCompleteAtMount = useRef(isComplete);
|
|
51890
|
-
useEffect(() => {
|
|
51891
|
-
if (isComplete && !isCancelled && assetId && !wasCompleteAtMount.current) {
|
|
51892
|
-
const store = useAssetPanelStore.getState();
|
|
51893
|
-
if (store.markAutoOpened(assetId)) {
|
|
51894
|
-
store.openAsset(assetId);
|
|
51895
|
-
}
|
|
51896
|
-
}
|
|
51897
|
-
}, [isComplete, isCancelled, assetId]);
|
|
51898
51703
|
return /* @__PURE__ */ jsx(
|
|
51899
51704
|
ToolCard,
|
|
51900
51705
|
{
|
|
@@ -52633,18 +52438,6 @@ const CaptureMomentToolUIImpl = ({
|
|
|
52633
52438
|
const isComplete = (status == null ? void 0 : status.type) === "complete" || !status;
|
|
52634
52439
|
const isCancelled = (status == null ? void 0 : status.type) === "incomplete" && status.reason === "cancelled";
|
|
52635
52440
|
const openAsset = useAssetPanelStore((s) => s.openAsset);
|
|
52636
|
-
const wasCompleteAtMount = useRef(isComplete);
|
|
52637
|
-
useEffect(() => {
|
|
52638
|
-
if (isComplete && !isCancelled && createdAssetId && !wasCompleteAtMount.current) {
|
|
52639
|
-
const store = useAssetPanelStore.getState();
|
|
52640
|
-
if (store.markAutoOpened(createdAssetId)) {
|
|
52641
|
-
store.openAsset(createdAssetId, {
|
|
52642
|
-
name: void 0,
|
|
52643
|
-
type: "unknown"
|
|
52644
|
-
});
|
|
52645
|
-
}
|
|
52646
|
-
}
|
|
52647
|
-
}, [isComplete, isCancelled, createdAssetId, resultType]);
|
|
52648
52441
|
const handleOpen = () => {
|
|
52649
52442
|
if (createdAssetId) {
|
|
52650
52443
|
openAsset(createdAssetId, {
|
|
@@ -52704,6 +52497,153 @@ const CaptureMomentToolUI = memo(
|
|
|
52704
52497
|
CaptureMomentToolUIImpl
|
|
52705
52498
|
);
|
|
52706
52499
|
CaptureMomentToolUI.displayName = "CaptureMomentToolUI";
|
|
52500
|
+
function normalizeContentResult(result) {
|
|
52501
|
+
if (Array.isArray(result)) {
|
|
52502
|
+
return result;
|
|
52503
|
+
}
|
|
52504
|
+
if (typeof result === "string") {
|
|
52505
|
+
try {
|
|
52506
|
+
const parsed = JSON.parse(result);
|
|
52507
|
+
return normalizeContentResult(parsed);
|
|
52508
|
+
} catch {
|
|
52509
|
+
return [];
|
|
52510
|
+
}
|
|
52511
|
+
}
|
|
52512
|
+
if (result && typeof result === "object") {
|
|
52513
|
+
const obj = result;
|
|
52514
|
+
if (Array.isArray(obj.result)) {
|
|
52515
|
+
return obj.result;
|
|
52516
|
+
}
|
|
52517
|
+
if (typeof obj.result === "string") {
|
|
52518
|
+
return normalizeContentResult(obj.result);
|
|
52519
|
+
}
|
|
52520
|
+
if (Array.isArray(obj.content)) {
|
|
52521
|
+
return obj.content;
|
|
52522
|
+
}
|
|
52523
|
+
}
|
|
52524
|
+
return [];
|
|
52525
|
+
}
|
|
52526
|
+
function getSlideScreenshotResult(result) {
|
|
52527
|
+
let text2 = null;
|
|
52528
|
+
let imageUrl = null;
|
|
52529
|
+
let mediaType = null;
|
|
52530
|
+
let s3Key = null;
|
|
52531
|
+
for (const item of normalizeContentResult(result)) {
|
|
52532
|
+
if (!item || typeof item !== "object") {
|
|
52533
|
+
continue;
|
|
52534
|
+
}
|
|
52535
|
+
const part = item;
|
|
52536
|
+
if (!text2 && part.type === "text" && typeof part.text === "string") {
|
|
52537
|
+
text2 = part.text;
|
|
52538
|
+
continue;
|
|
52539
|
+
}
|
|
52540
|
+
if (part.type !== "image") {
|
|
52541
|
+
continue;
|
|
52542
|
+
}
|
|
52543
|
+
const source = part.source && typeof part.source === "object" ? part.source : {};
|
|
52544
|
+
if (!imageUrl) {
|
|
52545
|
+
imageUrl = getStringField(source, ["presigned_url", "url"]) ?? getStringField(part, ["url", "image_url"]);
|
|
52546
|
+
}
|
|
52547
|
+
if (!mediaType) {
|
|
52548
|
+
mediaType = getStringField(source, ["media_type", "mime_type"]) ?? getStringField(part, ["media_type", "mime_type"]);
|
|
52549
|
+
}
|
|
52550
|
+
if (!s3Key) {
|
|
52551
|
+
s3Key = getStringField(source, ["data", "s3_key"]);
|
|
52552
|
+
}
|
|
52553
|
+
}
|
|
52554
|
+
return { text: text2, imageUrl, mediaType, s3Key };
|
|
52555
|
+
}
|
|
52556
|
+
const CaptureSlideScreenshotToolUIImpl = ({
|
|
52557
|
+
toolName,
|
|
52558
|
+
args,
|
|
52559
|
+
result,
|
|
52560
|
+
status
|
|
52561
|
+
}) => {
|
|
52562
|
+
const typedArgs = args;
|
|
52563
|
+
const assetId = getStringField(typedArgs, ["asset_id", "assetId"]);
|
|
52564
|
+
const slideNumber = getNumberField(typedArgs, ["slide_number", "slideNumber"]) ?? void 0;
|
|
52565
|
+
const { text: text2, imageUrl, mediaType } = useMemo(
|
|
52566
|
+
() => getSlideScreenshotResult(result),
|
|
52567
|
+
[result]
|
|
52568
|
+
);
|
|
52569
|
+
const isRunning = (status == null ? void 0 : status.type) === "running";
|
|
52570
|
+
const isComplete = (status == null ? void 0 : status.type) === "complete" || !status;
|
|
52571
|
+
const isCancelled = (status == null ? void 0 : status.type) === "incomplete" && status.reason === "cancelled";
|
|
52572
|
+
const errorMsg = (status == null ? void 0 : status.type) === "incomplete" ? String(status.error ?? status.reason ?? "Capture failed") : null;
|
|
52573
|
+
const openAsset = useAssetPanelStore((s) => s.openAsset);
|
|
52574
|
+
const handleOpenSlide = useCallback(() => {
|
|
52575
|
+
if (!assetId) {
|
|
52576
|
+
return;
|
|
52577
|
+
}
|
|
52578
|
+
openAsset(assetId, {
|
|
52579
|
+
type: "presentation",
|
|
52580
|
+
...slideNumber ? { slideNumber } : {}
|
|
52581
|
+
});
|
|
52582
|
+
}, [assetId, openAsset, slideNumber]);
|
|
52583
|
+
const subtitle = [
|
|
52584
|
+
slideNumber ? `Slide ${slideNumber}` : null,
|
|
52585
|
+
assetId ? truncate(assetId, 34) : null
|
|
52586
|
+
].filter((value) => Boolean(value)).join(" · ");
|
|
52587
|
+
return /* @__PURE__ */ jsxs(
|
|
52588
|
+
ToolCard,
|
|
52589
|
+
{
|
|
52590
|
+
icon: Camera,
|
|
52591
|
+
status: (status == null ? void 0 : status.type) ?? "complete",
|
|
52592
|
+
title: isRunning ? "Capturing slide screenshot..." : errorMsg ? "Slide screenshot failed" : "Slide screenshot captured",
|
|
52593
|
+
subtitle: subtitle || void 0,
|
|
52594
|
+
badge: slideNumber ? `Slide ${slideNumber}` : mediaType ?? void 0,
|
|
52595
|
+
toolName,
|
|
52596
|
+
args: typedArgs,
|
|
52597
|
+
result,
|
|
52598
|
+
error: errorMsg,
|
|
52599
|
+
children: [
|
|
52600
|
+
isComplete && !isCancelled && imageUrl && /* @__PURE__ */ jsxs("div", { className: "border-t border-border/40 p-3", children: [
|
|
52601
|
+
/* @__PURE__ */ jsx("div", { className: "overflow-hidden rounded-lg border border-border/50 bg-muted/20", children: /* @__PURE__ */ jsx(
|
|
52602
|
+
"img",
|
|
52603
|
+
{
|
|
52604
|
+
src: imageUrl,
|
|
52605
|
+
alt: slideNumber ? `Slide ${slideNumber} screenshot` : "Slide screenshot",
|
|
52606
|
+
className: "aspect-video w-full object-contain",
|
|
52607
|
+
loading: "lazy"
|
|
52608
|
+
}
|
|
52609
|
+
) }),
|
|
52610
|
+
text2 && /* @__PURE__ */ jsx("p", { className: "mt-2 text-[11px] leading-relaxed text-muted-foreground", children: truncate(text2, 160) })
|
|
52611
|
+
] }),
|
|
52612
|
+
isComplete && !isCancelled && assetId && /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-2 border-t border-border/40 px-4 py-2", children: [
|
|
52613
|
+
/* @__PURE__ */ jsxs(
|
|
52614
|
+
"button",
|
|
52615
|
+
{
|
|
52616
|
+
type: "button",
|
|
52617
|
+
onClick: handleOpenSlide,
|
|
52618
|
+
className: "flex items-center gap-1.5 rounded-md border border-border/60 px-3 py-1.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted/50 hover:text-foreground",
|
|
52619
|
+
children: [
|
|
52620
|
+
/* @__PURE__ */ jsx(ExternalLink, { className: "size-3" }),
|
|
52621
|
+
slideNumber ? `Open slide ${slideNumber}` : "Open presentation"
|
|
52622
|
+
]
|
|
52623
|
+
}
|
|
52624
|
+
),
|
|
52625
|
+
imageUrl && /* @__PURE__ */ jsxs(
|
|
52626
|
+
"a",
|
|
52627
|
+
{
|
|
52628
|
+
href: imageUrl,
|
|
52629
|
+
target: "_blank",
|
|
52630
|
+
rel: "noreferrer",
|
|
52631
|
+
className: "flex items-center gap-1.5 rounded-md border border-border/60 px-3 py-1.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted/50 hover:text-foreground",
|
|
52632
|
+
children: [
|
|
52633
|
+
/* @__PURE__ */ jsx(Image, { className: "size-3" }),
|
|
52634
|
+
"Open image"
|
|
52635
|
+
]
|
|
52636
|
+
}
|
|
52637
|
+
)
|
|
52638
|
+
] })
|
|
52639
|
+
]
|
|
52640
|
+
}
|
|
52641
|
+
);
|
|
52642
|
+
};
|
|
52643
|
+
const CaptureSlideScreenshotToolUI = memo(
|
|
52644
|
+
CaptureSlideScreenshotToolUIImpl
|
|
52645
|
+
);
|
|
52646
|
+
CaptureSlideScreenshotToolUI.displayName = "CaptureSlideScreenshotToolUI";
|
|
52707
52647
|
const TOOL_UI_REGISTRY = {
|
|
52708
52648
|
search: WebSearchToolUI,
|
|
52709
52649
|
browse: BrowseToolUI,
|
|
@@ -52731,6 +52671,7 @@ const TOOL_UI_REGISTRY = {
|
|
|
52731
52671
|
open_asset_in_workspace: OpenAssetToolUI,
|
|
52732
52672
|
// Media capture
|
|
52733
52673
|
capture_moment: CaptureMomentToolUI,
|
|
52674
|
+
capture_slide_screenshot: CaptureSlideScreenshotToolUI,
|
|
52734
52675
|
// Spreadsheet toolkit
|
|
52735
52676
|
update_sheet_range: UpdateSheetRangeToolUI,
|
|
52736
52677
|
// Database toolkit
|
|
@@ -53346,7 +53287,7 @@ const useAthenaChatDefaultComponents = () => {
|
|
|
53346
53287
|
return value;
|
|
53347
53288
|
};
|
|
53348
53289
|
const AthenaDefaultAssistantMessage = () => {
|
|
53349
|
-
const { toolUIs, TextComponent, ReasoningComponent, EmptyComponent: EmptyComponent2, ActionBarComponent } = useAthenaChatDefaultComponents();
|
|
53290
|
+
const { toolUIs, TextComponent, ReasoningComponent, EmptyComponent: EmptyComponent2, ActionBarComponent, groupToolCalls } = useAthenaChatDefaultComponents();
|
|
53350
53291
|
return /* @__PURE__ */ jsx(
|
|
53351
53292
|
AthenaAssistantMessage,
|
|
53352
53293
|
{
|
|
@@ -53354,7 +53295,8 @@ const AthenaDefaultAssistantMessage = () => {
|
|
|
53354
53295
|
TextComponent,
|
|
53355
53296
|
ReasoningComponent,
|
|
53356
53297
|
EmptyComponent: EmptyComponent2,
|
|
53357
|
-
ActionBarComponent
|
|
53298
|
+
ActionBarComponent,
|
|
53299
|
+
groupToolCalls
|
|
53358
53300
|
}
|
|
53359
53301
|
);
|
|
53360
53302
|
};
|
|
@@ -53363,15 +53305,15 @@ const AthenaDefaultUserMessage = () => {
|
|
|
53363
53305
|
return /* @__PURE__ */ jsx(AthenaUserMessage, { TextComponent });
|
|
53364
53306
|
};
|
|
53365
53307
|
const getReasoningTokensFromMetadata = (metadata) => {
|
|
53366
|
-
if (!isRecord(metadata)) {
|
|
53308
|
+
if (!isRecord$1(metadata)) {
|
|
53367
53309
|
return void 0;
|
|
53368
53310
|
}
|
|
53369
53311
|
const customMetadata = metadata.custom;
|
|
53370
|
-
if (!isRecord(customMetadata)) {
|
|
53312
|
+
if (!isRecord$1(customMetadata)) {
|
|
53371
53313
|
return void 0;
|
|
53372
53314
|
}
|
|
53373
53315
|
const athenaMetadata = customMetadata._athena;
|
|
53374
|
-
if (!isRecord(athenaMetadata)) {
|
|
53316
|
+
if (!isRecord$1(athenaMetadata)) {
|
|
53375
53317
|
return void 0;
|
|
53376
53318
|
}
|
|
53377
53319
|
const reasoningTokens = athenaMetadata.reasoningTokens;
|
|
@@ -53420,7 +53362,8 @@ const AthenaChat = ({
|
|
|
53420
53362
|
toolUIs,
|
|
53421
53363
|
mentionTools,
|
|
53422
53364
|
welcomeSuggestions = DEFAULT_SUGGESTIONS,
|
|
53423
|
-
components
|
|
53365
|
+
components,
|
|
53366
|
+
groupToolCalls = false
|
|
53424
53367
|
}) => {
|
|
53425
53368
|
var _a2, _b, _c;
|
|
53426
53369
|
const athenaConfig = useAthenaConfig();
|
|
@@ -53458,9 +53401,10 @@ const AthenaChat = ({
|
|
|
53458
53401
|
TextComponent: textComponent,
|
|
53459
53402
|
ReasoningComponent: reasoningComponent,
|
|
53460
53403
|
EmptyComponent: emptyComponent,
|
|
53461
|
-
ActionBarComponent: actionBarComponent
|
|
53404
|
+
ActionBarComponent: actionBarComponent,
|
|
53405
|
+
groupToolCalls
|
|
53462
53406
|
}),
|
|
53463
|
-
[actionBarComponent, emptyComponent, mergedToolUIs, reasoningComponent, textComponent]
|
|
53407
|
+
[actionBarComponent, emptyComponent, groupToolCalls, mergedToolUIs, reasoningComponent, textComponent]
|
|
53464
53408
|
);
|
|
53465
53409
|
const AssistantMessageComponent = (components == null ? void 0 : components.AssistantMessage) ?? AthenaDefaultAssistantMessage;
|
|
53466
53410
|
const UserMessageComponent = (components == null ? void 0 : components.UserMessage) ?? AthenaDefaultUserMessage;
|
|
@@ -53734,17 +53678,20 @@ const AthenaReasoningPart = ({
|
|
|
53734
53678
|
]
|
|
53735
53679
|
}
|
|
53736
53680
|
) }),
|
|
53737
|
-
/* @__PURE__ */ jsx(CollapsibleContent, { className: "pt-3", children: isRunning && !hasText ? /* @__PURE__ */ jsx("span", { className: "shimmer text-[13px] text-muted-foreground", children: "Analyzing..." }) :
|
|
53681
|
+
/* @__PURE__ */ jsx(CollapsibleContent, { className: "pt-3", children: isRunning && !hasText ? /* @__PURE__ */ jsx("span", { className: "shimmer text-[13px] text-muted-foreground", children: "Analyzing..." }) : /* @__PURE__ */ jsx("div", { className: "aui-assistant-reasoning-body text-[13px] leading-relaxed", children: /* @__PURE__ */ jsx(EffectiveTextComponent, { ...reasoningTextProps }) }) })
|
|
53738
53682
|
]
|
|
53739
53683
|
}
|
|
53740
53684
|
);
|
|
53741
53685
|
};
|
|
53686
|
+
const groupAdjacentToolCalls = (part) => part.type === "tool-call" ? ["group-tool"] : null;
|
|
53687
|
+
const noToolGrouping = () => null;
|
|
53742
53688
|
const AthenaAssistantMessage = ({
|
|
53743
53689
|
toolUIs,
|
|
53744
53690
|
TextComponent = TiptapText,
|
|
53745
53691
|
ReasoningComponent,
|
|
53746
53692
|
EmptyComponent: EmptyComponent2 = AthenaAssistantMessageEmpty,
|
|
53747
|
-
ActionBarComponent = AthenaAssistantActionBar
|
|
53693
|
+
ActionBarComponent = AthenaAssistantActionBar,
|
|
53694
|
+
groupToolCalls = false
|
|
53748
53695
|
}) => {
|
|
53749
53696
|
const effectiveReasoningComponent = ReasoningComponent ?? AthenaReasoningPart;
|
|
53750
53697
|
const toolUIsWithNestedMessages = useMemo(() => {
|
|
@@ -53754,7 +53701,7 @@ const AthenaAssistantMessage = ({
|
|
|
53754
53701
|
}
|
|
53755
53702
|
return wrappedToolUIs;
|
|
53756
53703
|
}, [toolUIs]);
|
|
53757
|
-
const
|
|
53704
|
+
const nestedPtcComponents = useMemo(
|
|
53758
53705
|
() => ({
|
|
53759
53706
|
Text: TextComponent,
|
|
53760
53707
|
Reasoning: effectiveReasoningComponent,
|
|
@@ -53773,7 +53720,31 @@ const AthenaAssistantMessage = ({
|
|
|
53773
53720
|
"data-role": "assistant",
|
|
53774
53721
|
children: [
|
|
53775
53722
|
/* @__PURE__ */ jsx(AthenaReasoningTextComponentContext.Provider, { value: TextComponent, children: /* @__PURE__ */ jsxs("div", { className: "aui-assistant-message-content wrap-break-word px-2 text-foreground leading-relaxed", children: [
|
|
53776
|
-
/* @__PURE__ */ jsx(NestedPtcComponentsProvider, { components:
|
|
53723
|
+
/* @__PURE__ */ jsx(NestedPtcComponentsProvider, { components: nestedPtcComponents, children: /* @__PURE__ */ jsx(MessagePrimitive.GroupedParts, { groupBy: groupToolCalls ? groupAdjacentToolCalls : noToolGrouping, children: ({ part, children }) => {
|
|
53724
|
+
var _a2, _b;
|
|
53725
|
+
switch (part.type) {
|
|
53726
|
+
case "group-tool":
|
|
53727
|
+
return /* @__PURE__ */ jsx(AthenaToolGroup, { count: ((_a2 = part.indices) == null ? void 0 : _a2.length) ?? 0, children });
|
|
53728
|
+
case "tool-call": {
|
|
53729
|
+
const ToolUI = toolUIsWithNestedMessages[part.toolName];
|
|
53730
|
+
const toolProps = part;
|
|
53731
|
+
return ToolUI ? /* @__PURE__ */ jsx(ToolUI, { ...toolProps }) : /* @__PURE__ */ jsx(ToolFallback, { ...toolProps });
|
|
53732
|
+
}
|
|
53733
|
+
case "reasoning": {
|
|
53734
|
+
const ReasoningRenderer = effectiveReasoningComponent;
|
|
53735
|
+
return /* @__PURE__ */ jsx(ReasoningRenderer, { ...part });
|
|
53736
|
+
}
|
|
53737
|
+
case "text": {
|
|
53738
|
+
const textPart = part;
|
|
53739
|
+
if (textPart.text === "" && ((_b = textPart.status) == null ? void 0 : _b.type) === "running") {
|
|
53740
|
+
return /* @__PURE__ */ jsx(EmptyComponent2, { status: textPart.status });
|
|
53741
|
+
}
|
|
53742
|
+
return /* @__PURE__ */ jsx(TextComponent, { ...textPart });
|
|
53743
|
+
}
|
|
53744
|
+
default:
|
|
53745
|
+
return null;
|
|
53746
|
+
}
|
|
53747
|
+
} }) }),
|
|
53777
53748
|
/* @__PURE__ */ jsx(MessageError, {})
|
|
53778
53749
|
] }) }),
|
|
53779
53750
|
/* @__PURE__ */ jsx("div", { className: "aui-assistant-message-footer mt-1 ml-2 flex", children: /* @__PURE__ */ jsx(ActionBarComponent, {}) })
|
|
@@ -53781,6 +53752,38 @@ const AthenaAssistantMessage = ({
|
|
|
53781
53752
|
}
|
|
53782
53753
|
);
|
|
53783
53754
|
};
|
|
53755
|
+
const AthenaToolGroup = ({ children, count: count2 }) => {
|
|
53756
|
+
const [expanded, setExpanded] = useState(false);
|
|
53757
|
+
return /* @__PURE__ */ jsxs("div", { className: "my-3 w-full overflow-hidden rounded-xl border border-border/60 bg-background shadow-sm", children: [
|
|
53758
|
+
/* @__PURE__ */ jsxs(
|
|
53759
|
+
"button",
|
|
53760
|
+
{
|
|
53761
|
+
type: "button",
|
|
53762
|
+
onClick: () => setExpanded((v) => !v),
|
|
53763
|
+
className: "flex w-full items-center gap-3 px-4 py-3 text-left transition-colors hover:bg-muted/20",
|
|
53764
|
+
"aria-expanded": expanded,
|
|
53765
|
+
children: [
|
|
53766
|
+
/* @__PURE__ */ jsx("div", { className: "flex size-8 shrink-0 items-center justify-center rounded-lg bg-muted/60 text-muted-foreground", children: /* @__PURE__ */ jsx(Layers, { className: "size-4" }) }),
|
|
53767
|
+
/* @__PURE__ */ jsx("div", { className: "min-w-0 flex-1", children: /* @__PURE__ */ jsxs("span", { className: "text-[13px] font-medium text-foreground", children: [
|
|
53768
|
+
count2,
|
|
53769
|
+
" tool ",
|
|
53770
|
+
count2 === 1 ? "call" : "calls"
|
|
53771
|
+
] }) }),
|
|
53772
|
+
/* @__PURE__ */ jsx(
|
|
53773
|
+
ChevronDown,
|
|
53774
|
+
{
|
|
53775
|
+
className: cn(
|
|
53776
|
+
"size-4 shrink-0 text-muted-foreground transition-transform duration-200",
|
|
53777
|
+
!expanded && "-rotate-90"
|
|
53778
|
+
)
|
|
53779
|
+
}
|
|
53780
|
+
)
|
|
53781
|
+
]
|
|
53782
|
+
}
|
|
53783
|
+
),
|
|
53784
|
+
expanded && /* @__PURE__ */ jsx("div", { className: "border-t border-border/40 bg-muted/5 px-3 pt-1 pb-2 [&>*]:my-2", children })
|
|
53785
|
+
] });
|
|
53786
|
+
};
|
|
53784
53787
|
const AthenaAssistantActionBar = ({ className }) => {
|
|
53785
53788
|
const threadId = useAthenaThreadId();
|
|
53786
53789
|
const { appUrl } = useAthenaConfig();
|
|
@@ -53840,10 +53843,37 @@ const AthenaUserMessage = ({
|
|
|
53840
53843
|
}
|
|
53841
53844
|
);
|
|
53842
53845
|
const embedCache = /* @__PURE__ */ new Map();
|
|
53846
|
+
function resolveAssetEmbedUrl({
|
|
53847
|
+
embedUrl,
|
|
53848
|
+
appUrl
|
|
53849
|
+
}) {
|
|
53850
|
+
if (!appUrl) {
|
|
53851
|
+
return embedUrl;
|
|
53852
|
+
}
|
|
53853
|
+
try {
|
|
53854
|
+
const resolvedEmbedUrl = new URL(embedUrl);
|
|
53855
|
+
const resolvedAppUrl = new URL(appUrl);
|
|
53856
|
+
if (!resolvedEmbedUrl.pathname.startsWith("/embed/")) {
|
|
53857
|
+
return embedUrl;
|
|
53858
|
+
}
|
|
53859
|
+
resolvedEmbedUrl.protocol = resolvedAppUrl.protocol;
|
|
53860
|
+
resolvedEmbedUrl.host = resolvedAppUrl.host;
|
|
53861
|
+
return resolvedEmbedUrl.toString();
|
|
53862
|
+
} catch {
|
|
53863
|
+
return embedUrl;
|
|
53864
|
+
}
|
|
53865
|
+
}
|
|
53843
53866
|
function useAssetEmbed(assetId, options = {
|
|
53844
53867
|
backendUrl: ""
|
|
53845
53868
|
}) {
|
|
53846
|
-
const {
|
|
53869
|
+
const {
|
|
53870
|
+
readOnly = false,
|
|
53871
|
+
expiresInSeconds = 60 * 60 * 24 * 30,
|
|
53872
|
+
backendUrl,
|
|
53873
|
+
appUrl,
|
|
53874
|
+
apiKey,
|
|
53875
|
+
token
|
|
53876
|
+
} = options;
|
|
53847
53877
|
const [embedUrl, setEmbedUrl] = useState(null);
|
|
53848
53878
|
const [isLoading, setIsLoading] = useState(false);
|
|
53849
53879
|
const [error2, setError] = useState(null);
|
|
@@ -53860,7 +53890,7 @@ function useAssetEmbed(assetId, options = {
|
|
|
53860
53890
|
return;
|
|
53861
53891
|
}
|
|
53862
53892
|
const authContext = hasToken ? "token" : apiKey ?? "anon";
|
|
53863
|
-
const cacheKey = `${assetId}:${readOnly}:${authContext}`;
|
|
53893
|
+
const cacheKey = `${assetId}:${readOnly}:${authContext}:${appUrl ?? ""}`;
|
|
53864
53894
|
const cached2 = embedCache.get(cacheKey);
|
|
53865
53895
|
if (cached2 && cached2.expiresAt > Date.now() / 1e3) {
|
|
53866
53896
|
setEmbedUrl(cached2.url);
|
|
@@ -53898,8 +53928,12 @@ function useAssetEmbed(assetId, options = {
|
|
|
53898
53928
|
}
|
|
53899
53929
|
return res.json();
|
|
53900
53930
|
}).then((data) => {
|
|
53901
|
-
|
|
53902
|
-
|
|
53931
|
+
const resolvedEmbedUrl = resolveAssetEmbedUrl({
|
|
53932
|
+
embedUrl: data.embed_url,
|
|
53933
|
+
appUrl
|
|
53934
|
+
});
|
|
53935
|
+
embedCache.set(cacheKey, { url: resolvedEmbedUrl, expiresAt: data.expires_at });
|
|
53936
|
+
setEmbedUrl(resolvedEmbedUrl);
|
|
53903
53937
|
setIsLoading(false);
|
|
53904
53938
|
}).catch((err) => {
|
|
53905
53939
|
if (err.name === "AbortError") return;
|
|
@@ -53907,7 +53941,7 @@ function useAssetEmbed(assetId, options = {
|
|
|
53907
53941
|
setIsLoading(false);
|
|
53908
53942
|
});
|
|
53909
53943
|
return () => controller.abort();
|
|
53910
|
-
}, [assetId, readOnly, expiresInSeconds, backendUrl, apiKey, hasToken]);
|
|
53944
|
+
}, [assetId, readOnly, expiresInSeconds, backendUrl, appUrl, apiKey, hasToken]);
|
|
53911
53945
|
return { embedUrl, isLoading, error: error2 };
|
|
53912
53946
|
}
|
|
53913
53947
|
const ABSOLUTE_URL_PATTERN = /^[a-zA-Z][a-zA-Z\d+\-.]*:/;
|
|
@@ -53930,6 +53964,21 @@ function buildAssetIframeSrc({
|
|
|
53930
53964
|
return `${embedUrl}${separator}slide=${targetSlide}`;
|
|
53931
53965
|
}
|
|
53932
53966
|
}
|
|
53967
|
+
function buildPresentationNavigationMessage({
|
|
53968
|
+
assetId,
|
|
53969
|
+
assetType,
|
|
53970
|
+
slideNumber
|
|
53971
|
+
}) {
|
|
53972
|
+
if (!assetId.trim() || assetType !== "presentation" || typeof slideNumber !== "number" || !Number.isInteger(slideNumber) || slideNumber < 1) {
|
|
53973
|
+
return null;
|
|
53974
|
+
}
|
|
53975
|
+
return {
|
|
53976
|
+
type: "NAVIGATE_TO_SLIDE",
|
|
53977
|
+
assetId,
|
|
53978
|
+
deckId: assetId,
|
|
53979
|
+
slideNumber
|
|
53980
|
+
};
|
|
53981
|
+
}
|
|
53933
53982
|
const ASSET_TYPE_CONFIG = {
|
|
53934
53983
|
presentation: { icon: Presentation, label: "Presentation" },
|
|
53935
53984
|
spreadsheet: { icon: FileSpreadsheet, label: "Spreadsheet" },
|
|
@@ -53939,20 +53988,60 @@ const ASSET_TYPE_CONFIG = {
|
|
|
53939
53988
|
};
|
|
53940
53989
|
const AssetIframe = memo(
|
|
53941
53990
|
({ tab }) => {
|
|
53942
|
-
const
|
|
53991
|
+
const iframeRef = useRef(null);
|
|
53992
|
+
const { backendUrl, appUrl, apiKey, token } = useAthenaConfig();
|
|
53943
53993
|
const { embedUrl, isLoading, error: error2 } = useAssetEmbed(tab.id, {
|
|
53944
53994
|
backendUrl,
|
|
53995
|
+
appUrl,
|
|
53945
53996
|
apiKey,
|
|
53946
53997
|
token
|
|
53947
53998
|
});
|
|
53999
|
+
const initialSlideRef = useRef({
|
|
54000
|
+
assetId: tab.id,
|
|
54001
|
+
slideNumber: tab.slideNumber
|
|
54002
|
+
});
|
|
54003
|
+
if (initialSlideRef.current.assetId !== tab.id) {
|
|
54004
|
+
initialSlideRef.current = {
|
|
54005
|
+
assetId: tab.id,
|
|
54006
|
+
slideNumber: tab.slideNumber
|
|
54007
|
+
};
|
|
54008
|
+
}
|
|
54009
|
+
const initialSlideNumber = initialSlideRef.current.slideNumber;
|
|
53948
54010
|
const iframeSrc = useMemo(
|
|
53949
54011
|
() => embedUrl ? buildAssetIframeSrc({
|
|
53950
54012
|
embedUrl,
|
|
53951
54013
|
assetType: tab.type,
|
|
53952
|
-
slideNumber:
|
|
54014
|
+
slideNumber: initialSlideNumber
|
|
53953
54015
|
}) : null,
|
|
53954
|
-
[embedUrl,
|
|
54016
|
+
[embedUrl, initialSlideNumber, tab.type]
|
|
53955
54017
|
);
|
|
54018
|
+
const navigationMessage = useMemo(
|
|
54019
|
+
() => buildPresentationNavigationMessage({
|
|
54020
|
+
assetId: tab.id,
|
|
54021
|
+
assetType: tab.type,
|
|
54022
|
+
slideNumber: tab.slideNumber
|
|
54023
|
+
}),
|
|
54024
|
+
[tab.id, tab.slideNumber, tab.type]
|
|
54025
|
+
);
|
|
54026
|
+
const navigationTargetOrigin = useMemo(() => {
|
|
54027
|
+
if (!iframeSrc) return null;
|
|
54028
|
+
try {
|
|
54029
|
+
return new URL(iframeSrc, window.location.href).origin;
|
|
54030
|
+
} catch {
|
|
54031
|
+
return null;
|
|
54032
|
+
}
|
|
54033
|
+
}, [iframeSrc]);
|
|
54034
|
+
const postNavigationMessage = useCallback(() => {
|
|
54035
|
+
var _a2, _b;
|
|
54036
|
+
if (!navigationMessage || !navigationTargetOrigin) return;
|
|
54037
|
+
(_b = (_a2 = iframeRef.current) == null ? void 0 : _a2.contentWindow) == null ? void 0 : _b.postMessage(
|
|
54038
|
+
navigationMessage,
|
|
54039
|
+
navigationTargetOrigin
|
|
54040
|
+
);
|
|
54041
|
+
}, [navigationMessage, navigationTargetOrigin]);
|
|
54042
|
+
useEffect(() => {
|
|
54043
|
+
postNavigationMessage();
|
|
54044
|
+
}, [postNavigationMessage]);
|
|
53956
54045
|
if (isLoading) {
|
|
53957
54046
|
return /* @__PURE__ */ jsx("div", { className: "flex h-full items-center justify-center", children: /* @__PURE__ */ jsxs("div", { className: "text-center", children: [
|
|
53958
54047
|
/* @__PURE__ */ jsx(LoaderCircle, { className: "mx-auto size-6 animate-spin text-muted-foreground" }),
|
|
@@ -53970,16 +54059,19 @@ const AssetIframe = memo(
|
|
|
53970
54059
|
return /* @__PURE__ */ jsx(
|
|
53971
54060
|
"iframe",
|
|
53972
54061
|
{
|
|
54062
|
+
ref: iframeRef,
|
|
53973
54063
|
src: iframeSrc,
|
|
53974
54064
|
width: "100%",
|
|
53975
54065
|
height: "100%",
|
|
53976
54066
|
frameBorder: "0",
|
|
53977
54067
|
allow: "fullscreen",
|
|
53978
54068
|
title: tab.name ?? `Asset ${tab.id}`,
|
|
53979
|
-
className: "h-full w-full"
|
|
54069
|
+
className: "h-full w-full",
|
|
54070
|
+
onLoad: postNavigationMessage
|
|
53980
54071
|
}
|
|
53981
54072
|
);
|
|
53982
|
-
}
|
|
54073
|
+
},
|
|
54074
|
+
(prev, next) => prev.tab.id === next.tab.id && prev.tab.name === next.tab.name && prev.tab.type === next.tab.type && prev.tab.slideNumber === next.tab.slideNumber
|
|
53983
54075
|
);
|
|
53984
54076
|
AssetIframe.displayName = "AssetIframe";
|
|
53985
54077
|
const PanelContent = ({
|
|
@@ -54302,6 +54394,7 @@ export {
|
|
|
54302
54394
|
CreateSheetToolUI,
|
|
54303
54395
|
DEFAULT_API_URL,
|
|
54304
54396
|
DEFAULT_APP_URL,
|
|
54397
|
+
DEFAULT_AUTO_OPEN_TOOLS,
|
|
54305
54398
|
DEFAULT_BACKEND_URL,
|
|
54306
54399
|
DescribeDatabaseToolUI,
|
|
54307
54400
|
EmailSearchToolUI,
|
|
@@ -54355,7 +54448,7 @@ export {
|
|
|
54355
54448
|
themeToStyleVars,
|
|
54356
54449
|
themes,
|
|
54357
54450
|
truncate,
|
|
54358
|
-
tryParseJson$
|
|
54451
|
+
tryParseJson$2 as tryParseJson,
|
|
54359
54452
|
useAppendToComposer,
|
|
54360
54453
|
useAssetEmbed,
|
|
54361
54454
|
useAssetPanelStore,
|