@athenaintel/react 0.10.28 → 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.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, unstable_useRemoteThreadListRuntime, Tools, useAui, AssistantRuntimeProvider, useComposerRuntime, MessagePartPrimitive, MessagePrimitive, useScrollLock, ActionBarPrimitive, AuiIf, ActionBarMorePrimitive, ThreadPrimitive, ComposerPrimitive, ErrorPrimitive, ThreadListPrimitive, ThreadListItemPrimitive } from "@assistant-ui/react";
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
- // If not in an iframe, we're ready immediately (standalone mode)
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.unstable_resumeRun({ parentId: lastMessageId });
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$7(ownerName) {
9101
- const SlotClone = /* @__PURE__ */ createSlotClone$7(ownerName);
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$7);
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$7(ownerName) {
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$8(children);
9129
- const props2 = mergeProps$7(slotProps, children.props);
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$7 = Symbol("radix.slottable");
9141
- function isSlottable$7(child) {
9142
- return React.isValidElement(child) && typeof child.type === "function" && "__radixId" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER$7;
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$7(slotProps, childProps) {
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$8(element) {
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$7(`Primitive.${node}`);
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$6(`Primitive.${node}`);
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$6(child));
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$6(element) {
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$5(`Primitive.${node}`);
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$4(`Primitive.${node}`);
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$2(`Primitive.${node}`);
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$1(`Primitive.${node}`);
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();
@@ -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 = useAthenaThreadId();
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 = unstable_useRemoteThreadListRuntime({
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$2(text2) {
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$2(result);
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$2(result);
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$2(argsText);
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$2(argsText);
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$2(argsText);
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$2(argsText);
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$2(result);
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$2(argsText);
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$2(result);
49722
+ const parsed = tryParseJson$1(result);
49969
49723
  spec.result = parsed ?? result;
49970
49724
  } else {
49971
49725
  spec.result = result;
@@ -50154,17 +49908,6 @@ ToolFallback.Content = ToolFallbackContent;
50154
49908
  ToolFallback.Args = ToolFallbackArgs;
50155
49909
  ToolFallback.Result = ToolFallbackResult;
50156
49910
  ToolFallback.Error = ToolFallbackError;
50157
- function getAssetInfo(assetId) {
50158
- return { name: assetId || "Document", icon: "doc" };
50159
- }
50160
- function tryParseJson$1(text2) {
50161
- try {
50162
- const p = JSON.parse(text2);
50163
- return typeof p === "object" && p !== null ? p : null;
50164
- } catch {
50165
- return null;
50166
- }
50167
- }
50168
49911
  const markdownPreviewExtensions = [
50169
49912
  StarterKit.configure({
50170
49913
  codeBlock: {
@@ -50213,10 +49956,10 @@ const AppendDocumentToolUIImpl = ({
50213
49956
  const typedArgs = args;
50214
49957
  const resultData = useMemo(() => {
50215
49958
  if (!result) return null;
50216
- if (typeof result === "string") return tryParseJson$1(result);
49959
+ if (typeof result === "string") return tryParseJson$2(result);
50217
49960
  if (typeof result === "object") {
50218
49961
  const obj = result;
50219
- if (typeof obj.result === "string") return tryParseJson$1(obj.result) ?? obj;
49962
+ if (typeof obj.result === "string") return tryParseJson$2(obj.result) ?? obj;
50220
49963
  return obj;
50221
49964
  }
50222
49965
  return null;
@@ -50298,11 +50041,11 @@ const AppendDocumentToolUI = memo(
50298
50041
  );
50299
50042
  AppendDocumentToolUI.displayName = "AppendDocumentToolUI";
50300
50043
  function normalizeResult$1(result) {
50301
- if (typeof result === "string") return tryParseJson$1(result) ?? result;
50044
+ if (typeof result === "string") return tryParseJson$2(result) ?? result;
50302
50045
  if (typeof result === "object" && result !== null) {
50303
50046
  const obj = result;
50304
50047
  if (typeof obj.result === "string")
50305
- return tryParseJson$1(obj.result) ?? obj.result;
50048
+ return tryParseJson$2(obj.result) ?? obj.result;
50306
50049
  return obj;
50307
50050
  }
50308
50051
  return result;
@@ -53544,7 +53287,7 @@ const useAthenaChatDefaultComponents = () => {
53544
53287
  return value;
53545
53288
  };
53546
53289
  const AthenaDefaultAssistantMessage = () => {
53547
- const { toolUIs, TextComponent, ReasoningComponent, EmptyComponent: EmptyComponent2, ActionBarComponent } = useAthenaChatDefaultComponents();
53290
+ const { toolUIs, TextComponent, ReasoningComponent, EmptyComponent: EmptyComponent2, ActionBarComponent, groupToolCalls } = useAthenaChatDefaultComponents();
53548
53291
  return /* @__PURE__ */ jsx(
53549
53292
  AthenaAssistantMessage,
53550
53293
  {
@@ -53552,7 +53295,8 @@ const AthenaDefaultAssistantMessage = () => {
53552
53295
  TextComponent,
53553
53296
  ReasoningComponent,
53554
53297
  EmptyComponent: EmptyComponent2,
53555
- ActionBarComponent
53298
+ ActionBarComponent,
53299
+ groupToolCalls
53556
53300
  }
53557
53301
  );
53558
53302
  };
@@ -53561,15 +53305,15 @@ const AthenaDefaultUserMessage = () => {
53561
53305
  return /* @__PURE__ */ jsx(AthenaUserMessage, { TextComponent });
53562
53306
  };
53563
53307
  const getReasoningTokensFromMetadata = (metadata) => {
53564
- if (!isRecord(metadata)) {
53308
+ if (!isRecord$1(metadata)) {
53565
53309
  return void 0;
53566
53310
  }
53567
53311
  const customMetadata = metadata.custom;
53568
- if (!isRecord(customMetadata)) {
53312
+ if (!isRecord$1(customMetadata)) {
53569
53313
  return void 0;
53570
53314
  }
53571
53315
  const athenaMetadata = customMetadata._athena;
53572
- if (!isRecord(athenaMetadata)) {
53316
+ if (!isRecord$1(athenaMetadata)) {
53573
53317
  return void 0;
53574
53318
  }
53575
53319
  const reasoningTokens = athenaMetadata.reasoningTokens;
@@ -53618,7 +53362,8 @@ const AthenaChat = ({
53618
53362
  toolUIs,
53619
53363
  mentionTools,
53620
53364
  welcomeSuggestions = DEFAULT_SUGGESTIONS,
53621
- components
53365
+ components,
53366
+ groupToolCalls = false
53622
53367
  }) => {
53623
53368
  var _a2, _b, _c;
53624
53369
  const athenaConfig = useAthenaConfig();
@@ -53656,9 +53401,10 @@ const AthenaChat = ({
53656
53401
  TextComponent: textComponent,
53657
53402
  ReasoningComponent: reasoningComponent,
53658
53403
  EmptyComponent: emptyComponent,
53659
- ActionBarComponent: actionBarComponent
53404
+ ActionBarComponent: actionBarComponent,
53405
+ groupToolCalls
53660
53406
  }),
53661
- [actionBarComponent, emptyComponent, mergedToolUIs, reasoningComponent, textComponent]
53407
+ [actionBarComponent, emptyComponent, groupToolCalls, mergedToolUIs, reasoningComponent, textComponent]
53662
53408
  );
53663
53409
  const AssistantMessageComponent = (components == null ? void 0 : components.AssistantMessage) ?? AthenaDefaultAssistantMessage;
53664
53410
  const UserMessageComponent = (components == null ? void 0 : components.UserMessage) ?? AthenaDefaultUserMessage;
@@ -53932,17 +53678,20 @@ const AthenaReasoningPart = ({
53932
53678
  ]
53933
53679
  }
53934
53680
  ) }),
53935
- /* @__PURE__ */ jsx(CollapsibleContent, { className: "pt-3", children: isRunning && !hasText ? /* @__PURE__ */ jsx("span", { className: "shimmer text-[13px] text-muted-foreground", children: "Analyzing..." }) : isRunning ? /* @__PURE__ */ jsx("div", { className: "whitespace-pre-wrap break-words text-[13px] leading-relaxed text-foreground", children: text2 }) : /* @__PURE__ */ jsx("div", { className: "aui-assistant-reasoning-body text-[13px] leading-relaxed", children: /* @__PURE__ */ jsx(EffectiveTextComponent, { ...reasoningTextProps }) }) })
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 }) }) })
53936
53682
  ]
53937
53683
  }
53938
53684
  );
53939
53685
  };
53686
+ const groupAdjacentToolCalls = (part) => part.type === "tool-call" ? ["group-tool"] : null;
53687
+ const noToolGrouping = () => null;
53940
53688
  const AthenaAssistantMessage = ({
53941
53689
  toolUIs,
53942
53690
  TextComponent = TiptapText,
53943
53691
  ReasoningComponent,
53944
53692
  EmptyComponent: EmptyComponent2 = AthenaAssistantMessageEmpty,
53945
- ActionBarComponent = AthenaAssistantActionBar
53693
+ ActionBarComponent = AthenaAssistantActionBar,
53694
+ groupToolCalls = false
53946
53695
  }) => {
53947
53696
  const effectiveReasoningComponent = ReasoningComponent ?? AthenaReasoningPart;
53948
53697
  const toolUIsWithNestedMessages = useMemo(() => {
@@ -53952,7 +53701,7 @@ const AthenaAssistantMessage = ({
53952
53701
  }
53953
53702
  return wrappedToolUIs;
53954
53703
  }, [toolUIs]);
53955
- const partsComponents = useMemo(
53704
+ const nestedPtcComponents = useMemo(
53956
53705
  () => ({
53957
53706
  Text: TextComponent,
53958
53707
  Reasoning: effectiveReasoningComponent,
@@ -53971,7 +53720,31 @@ const AthenaAssistantMessage = ({
53971
53720
  "data-role": "assistant",
53972
53721
  children: [
53973
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: [
53974
- /* @__PURE__ */ jsx(NestedPtcComponentsProvider, { components: partsComponents, children: /* @__PURE__ */ jsx(MessagePrimitive.Parts, { components: partsComponents }) }),
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
+ } }) }),
53975
53748
  /* @__PURE__ */ jsx(MessageError, {})
53976
53749
  ] }) }),
53977
53750
  /* @__PURE__ */ jsx("div", { className: "aui-assistant-message-footer mt-1 ml-2 flex", children: /* @__PURE__ */ jsx(ActionBarComponent, {}) })
@@ -53979,6 +53752,38 @@ const AthenaAssistantMessage = ({
53979
53752
  }
53980
53753
  );
53981
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
+ };
53982
53787
  const AthenaAssistantActionBar = ({ className }) => {
53983
53788
  const threadId = useAthenaThreadId();
53984
53789
  const { appUrl } = useAthenaConfig();
@@ -54164,7 +53969,7 @@ function buildPresentationNavigationMessage({
54164
53969
  assetType,
54165
53970
  slideNumber
54166
53971
  }) {
54167
- if (assetType !== "presentation" || typeof slideNumber !== "number" || !Number.isInteger(slideNumber) || slideNumber < 1) {
53972
+ if (!assetId.trim() || assetType !== "presentation" || typeof slideNumber !== "number" || !Number.isInteger(slideNumber) || slideNumber < 1) {
54168
53973
  return null;
54169
53974
  }
54170
53975
  return {
@@ -54191,13 +53996,24 @@ const AssetIframe = memo(
54191
53996
  apiKey,
54192
53997
  token
54193
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;
54194
54010
  const iframeSrc = useMemo(
54195
54011
  () => embedUrl ? buildAssetIframeSrc({
54196
54012
  embedUrl,
54197
54013
  assetType: tab.type,
54198
- slideNumber: tab.slideNumber
54014
+ slideNumber: initialSlideNumber
54199
54015
  }) : null,
54200
- [embedUrl, tab.slideNumber, tab.type]
54016
+ [embedUrl, initialSlideNumber, tab.type]
54201
54017
  );
54202
54018
  const navigationMessage = useMemo(
54203
54019
  () => buildPresentationNavigationMessage({
@@ -54207,11 +54023,22 @@ const AssetIframe = memo(
54207
54023
  }),
54208
54024
  [tab.id, tab.slideNumber, tab.type]
54209
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]);
54210
54034
  const postNavigationMessage = useCallback(() => {
54211
54035
  var _a2, _b;
54212
- if (!navigationMessage) return;
54213
- (_b = (_a2 = iframeRef.current) == null ? void 0 : _a2.contentWindow) == null ? void 0 : _b.postMessage(navigationMessage, "*");
54214
- }, [navigationMessage]);
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]);
54215
54042
  useEffect(() => {
54216
54043
  postNavigationMessage();
54217
54044
  }, [postNavigationMessage]);
@@ -54567,6 +54394,7 @@ export {
54567
54394
  CreateSheetToolUI,
54568
54395
  DEFAULT_API_URL,
54569
54396
  DEFAULT_APP_URL,
54397
+ DEFAULT_AUTO_OPEN_TOOLS,
54570
54398
  DEFAULT_BACKEND_URL,
54571
54399
  DescribeDatabaseToolUI,
54572
54400
  EmailSearchToolUI,
@@ -54620,7 +54448,7 @@ export {
54620
54448
  themeToStyleVars,
54621
54449
  themes,
54622
54450
  truncate,
54623
- tryParseJson$1 as tryParseJson,
54451
+ tryParseJson$2 as tryParseJson,
54624
54452
  useAppendToComposer,
54625
54453
  useAssetEmbed,
54626
54454
  useAssetPanelStore,