@promptbook/components 0.112.0-48 → 0.112.0-49

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/umd/index.umd.js CHANGED
@@ -30,7 +30,7 @@
30
30
  * @generated
31
31
  * @see https://github.com/webgptorg/promptbook
32
32
  */
33
- const PROMPTBOOK_ENGINE_VERSION = '0.112.0-48';
33
+ const PROMPTBOOK_ENGINE_VERSION = '0.112.0-49';
34
34
  /**
35
35
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
36
36
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -1509,10 +1509,22 @@
1509
1509
  */
1510
1510
  function prepareAvatarCanvas(canvas, context, size, devicePixelRatio) {
1511
1511
  const normalizedDevicePixelRatio = Math.max(1, Math.round(devicePixelRatio * 100) / 100);
1512
- canvas.width = Math.round(size * normalizedDevicePixelRatio);
1513
- canvas.height = Math.round(size * normalizedDevicePixelRatio);
1514
- canvas.style.width = `${size}px`;
1515
- canvas.style.height = `${size}px`;
1512
+ const nextCanvasWidth = Math.round(size * normalizedDevicePixelRatio);
1513
+ const nextCanvasHeight = Math.round(size * normalizedDevicePixelRatio);
1514
+ const nextCanvasStyleWidth = `${size}px`;
1515
+ const nextCanvasStyleHeight = `${size}px`;
1516
+ if (canvas.width !== nextCanvasWidth) {
1517
+ canvas.width = nextCanvasWidth;
1518
+ }
1519
+ if (canvas.height !== nextCanvasHeight) {
1520
+ canvas.height = nextCanvasHeight;
1521
+ }
1522
+ if (canvas.style.width !== nextCanvasStyleWidth) {
1523
+ canvas.style.width = nextCanvasStyleWidth;
1524
+ }
1525
+ if (canvas.style.height !== nextCanvasStyleHeight) {
1526
+ canvas.style.height = nextCanvasStyleHeight;
1527
+ }
1516
1528
  context.setTransform(normalizedDevicePixelRatio, 0, 0, normalizedDevicePixelRatio, 0, 0);
1517
1529
  context.clearRect(0, 0, size, size);
1518
1530
  }
@@ -26069,6 +26081,138 @@
26069
26081
  return currentValue + (targetValue - currentValue) * blend;
26070
26082
  }
26071
26083
 
26084
+ // Note: [💞] Ignore a discrepancy between file name and entity name
26085
+ /**
26086
+ * Next registration id used by the shared avatar animation scheduler.
26087
+ *
26088
+ * @private utility of the avatar rendering system
26089
+ */
26090
+ let nextAvatarAnimationListenerId = 1;
26091
+ /**
26092
+ * Active avatar animation callbacks keyed by their registration id.
26093
+ *
26094
+ * @private utility of the avatar rendering system
26095
+ */
26096
+ const avatarAnimationListeners = new Map();
26097
+ /**
26098
+ * Active shared animation-frame handle.
26099
+ *
26100
+ * @private utility of the avatar rendering system
26101
+ */
26102
+ let avatarAnimationFrameId = null;
26103
+ /**
26104
+ * Registers one avatar animation callback in the shared animation loop.
26105
+ *
26106
+ * @param avatarAnimationListener Frame callback invoked on every animation frame.
26107
+ * @returns Cleanup function that unregisters the callback.
26108
+ *
26109
+ * @private utility of the avatar rendering system
26110
+ */
26111
+ function retainAvatarAnimationListener(avatarAnimationListener) {
26112
+ if (typeof window === 'undefined') {
26113
+ return () => undefined;
26114
+ }
26115
+ const listenerId = nextAvatarAnimationListenerId++;
26116
+ avatarAnimationListeners.set(listenerId, avatarAnimationListener);
26117
+ ensureAvatarAnimationLoop();
26118
+ return () => {
26119
+ avatarAnimationListeners.delete(listenerId);
26120
+ if (avatarAnimationListeners.size === 0 && avatarAnimationFrameId !== null) {
26121
+ window.cancelAnimationFrame(avatarAnimationFrameId);
26122
+ avatarAnimationFrameId = null;
26123
+ }
26124
+ };
26125
+ }
26126
+ /**
26127
+ * Ensures the shared animation loop is running while at least one avatar listener is active.
26128
+ *
26129
+ * @private utility of the avatar rendering system
26130
+ */
26131
+ function ensureAvatarAnimationLoop() {
26132
+ if (avatarAnimationFrameId !== null || avatarAnimationListeners.size === 0 || typeof window === 'undefined') {
26133
+ return;
26134
+ }
26135
+ const runFrame = (now) => {
26136
+ avatarAnimationFrameId = null;
26137
+ for (const avatarAnimationListener of [...avatarAnimationListeners.values()]) {
26138
+ avatarAnimationListener(now);
26139
+ }
26140
+ ensureAvatarAnimationLoop();
26141
+ };
26142
+ avatarAnimationFrameId = window.requestAnimationFrame(runFrame);
26143
+ }
26144
+
26145
+ // Note: [💞] Ignore a discrepancy between file name and entity name
26146
+ /**
26147
+ * Shared `IntersectionObserver` callbacks grouped by observed element.
26148
+ *
26149
+ * @private utility of the avatar rendering system
26150
+ */
26151
+ const avatarVisibilityListeners = new Map();
26152
+ /**
26153
+ * Lazily created shared `IntersectionObserver` used by avatar canvases.
26154
+ *
26155
+ * @private utility of the avatar rendering system
26156
+ */
26157
+ let avatarVisibilityObserver = null;
26158
+ /**
26159
+ * Observes one avatar element and notifies the caller when it enters or leaves the viewport.
26160
+ *
26161
+ * @param element Observed avatar element.
26162
+ * @param avatarVisibilityListener Listener notified with the current visibility state.
26163
+ * @returns Cleanup function that stops observing the element.
26164
+ *
26165
+ * @private utility of the avatar rendering system
26166
+ */
26167
+ function observeAvatarVisibility(element, avatarVisibilityListener) {
26168
+ if (typeof window === 'undefined' || typeof IntersectionObserver === 'undefined') {
26169
+ avatarVisibilityListener(true);
26170
+ return () => undefined;
26171
+ }
26172
+ const observer = getAvatarVisibilityObserver();
26173
+ const elementListeners = avatarVisibilityListeners.get(element) || new Set();
26174
+ elementListeners.add(avatarVisibilityListener);
26175
+ avatarVisibilityListeners.set(element, elementListeners);
26176
+ observer.observe(element);
26177
+ return () => {
26178
+ const currentElementListeners = avatarVisibilityListeners.get(element);
26179
+ if (!currentElementListeners) {
26180
+ return;
26181
+ }
26182
+ currentElementListeners.delete(avatarVisibilityListener);
26183
+ if (currentElementListeners.size > 0) {
26184
+ return;
26185
+ }
26186
+ avatarVisibilityListeners.delete(element);
26187
+ observer.unobserve(element);
26188
+ };
26189
+ }
26190
+ /**
26191
+ * Creates the shared `IntersectionObserver` used by all avatar canvases.
26192
+ *
26193
+ * @returns Shared observer instance.
26194
+ *
26195
+ * @private utility of the avatar rendering system
26196
+ */
26197
+ function getAvatarVisibilityObserver() {
26198
+ if (avatarVisibilityObserver) {
26199
+ return avatarVisibilityObserver;
26200
+ }
26201
+ avatarVisibilityObserver = new IntersectionObserver((entries) => {
26202
+ for (const entry of entries) {
26203
+ const elementListeners = avatarVisibilityListeners.get(entry.target);
26204
+ if (!elementListeners) {
26205
+ continue;
26206
+ }
26207
+ const isVisible = entry.isIntersecting && entry.intersectionRatio > 0;
26208
+ for (const avatarVisibilityListener of elementListeners) {
26209
+ avatarVisibilityListener(isVisible);
26210
+ }
26211
+ }
26212
+ });
26213
+ return avatarVisibilityObserver;
26214
+ }
26215
+
26072
26216
  // Note: [💞] Ignore a discrepancy between file name and entity name
26073
26217
  /**
26074
26218
  * Active avatar instances currently consuming the shared pointer tracker.
@@ -26082,6 +26226,18 @@
26082
26226
  * @private utility of the avatar rendering system
26083
26227
  */
26084
26228
  let currentAvatarPointerSnapshot = null;
26229
+ /**
26230
+ * Monotonic version incremented whenever the shared pointer snapshot changes.
26231
+ *
26232
+ * @private utility of the avatar rendering system
26233
+ */
26234
+ let currentAvatarPointerSnapshotVersion = 0;
26235
+ /**
26236
+ * Monotonic version incremented whenever scrolling or resizing may invalidate cached avatar bounds.
26237
+ *
26238
+ * @private utility of the avatar rendering system
26239
+ */
26240
+ let currentAvatarViewportLayoutVersion = 0;
26085
26241
  /**
26086
26242
  * Cleanup function for the lazily attached global listeners.
26087
26243
  *
@@ -26119,6 +26275,26 @@
26119
26275
  function getAvatarPointerSnapshot() {
26120
26276
  return currentAvatarPointerSnapshot;
26121
26277
  }
26278
+ /**
26279
+ * Returns the current pointer snapshot version.
26280
+ *
26281
+ * @returns Monotonic pointer snapshot version.
26282
+ *
26283
+ * @private utility of the avatar rendering system
26284
+ */
26285
+ function getAvatarPointerSnapshotVersion() {
26286
+ return currentAvatarPointerSnapshotVersion;
26287
+ }
26288
+ /**
26289
+ * Returns the current viewport-layout version used to invalidate cached avatar bounds.
26290
+ *
26291
+ * @returns Monotonic viewport-layout version.
26292
+ *
26293
+ * @private utility of the avatar rendering system
26294
+ */
26295
+ function getAvatarViewportLayoutVersion() {
26296
+ return currentAvatarViewportLayoutVersion;
26297
+ }
26122
26298
  /**
26123
26299
  * Attaches the global pointer/touch listeners used by all live avatar canvases.
26124
26300
  *
@@ -26131,7 +26307,11 @@
26131
26307
  return () => undefined;
26132
26308
  }
26133
26309
  const clearPointerSnapshot = () => {
26310
+ if (currentAvatarPointerSnapshot === null) {
26311
+ return;
26312
+ }
26134
26313
  currentAvatarPointerSnapshot = null;
26314
+ currentAvatarPointerSnapshotVersion++;
26135
26315
  };
26136
26316
  const updatePointerSnapshot = (clientX, clientY, pointerType) => {
26137
26317
  currentAvatarPointerSnapshot = {
@@ -26140,6 +26320,10 @@
26140
26320
  isPointerActive: true,
26141
26321
  pointerType,
26142
26322
  };
26323
+ currentAvatarPointerSnapshotVersion++;
26324
+ };
26325
+ const invalidateViewportLayout = () => {
26326
+ currentAvatarViewportLayoutVersion++;
26143
26327
  };
26144
26328
  const handlePointerMove = (event) => {
26145
26329
  updatePointerSnapshot(event.clientX, event.clientY, normalizeAvatarPointerType(event.pointerType));
@@ -26175,6 +26359,8 @@
26175
26359
  window.addEventListener('touchmove', handleTouchEvent, { passive: true });
26176
26360
  window.addEventListener('touchend', clearPointerSnapshot, { passive: true });
26177
26361
  window.addEventListener('touchcancel', clearPointerSnapshot, { passive: true });
26362
+ window.addEventListener('scroll', invalidateViewportLayout, { passive: true, capture: true });
26363
+ window.addEventListener('resize', invalidateViewportLayout, { passive: true });
26178
26364
  return () => {
26179
26365
  window.removeEventListener('pointermove', handlePointerMove);
26180
26366
  window.removeEventListener('pointerdown', handlePointerDown);
@@ -26186,6 +26372,8 @@
26186
26372
  window.removeEventListener('touchmove', handleTouchEvent);
26187
26373
  window.removeEventListener('touchend', clearPointerSnapshot);
26188
26374
  window.removeEventListener('touchcancel', clearPointerSnapshot);
26375
+ window.removeEventListener('scroll', invalidateViewportLayout, true);
26376
+ window.removeEventListener('resize', invalidateViewportLayout);
26189
26377
  };
26190
26378
  }
26191
26379
  /**
@@ -28456,32 +28644,55 @@
28456
28644
  return avatarVisual;
28457
28645
  }
28458
28646
 
28647
+ /**
28648
+ * Resolves the stable avatar render inputs reused across multiple frames.
28649
+ *
28650
+ * @param options Avatar identity and visual selection.
28651
+ * @returns Stable render data ready to be used by `renderAvatarVisual`.
28652
+ *
28653
+ * @private shared helper for canvas avatar rendering
28654
+ */
28655
+ function resolveAvatarRenderDefinition(options) {
28656
+ const avatarDefinition = normalizeAvatarDefinition(options.avatarDefinition);
28657
+ const surface = options.surface || 'framed';
28658
+ return {
28659
+ avatarDefinition,
28660
+ avatarVisual: getAvatarVisualById(options.visualId),
28661
+ surface,
28662
+ palette: createAvatarPalette(avatarDefinition, surface),
28663
+ createRandom: createAvatarRandomFactory(avatarDefinition),
28664
+ };
28665
+ }
28459
28666
  /**
28460
28667
  * Renders one deterministic avatar frame into the provided canvas.
28461
28668
  *
28462
28669
  * @param options Rendering options.
28670
+ * @param resolvedAvatarRenderDefinition Optional stable render data reused between frames.
28463
28671
  *
28464
28672
  * @private shared helper for canvas avatar rendering
28465
28673
  */
28466
- function renderAvatarVisual(options) {
28467
- const normalizedAvatarDefinition = normalizeAvatarDefinition(options.avatarDefinition);
28468
- const avatarVisual = getAvatarVisualById(options.visualId);
28469
- const surface = options.surface || 'framed';
28674
+ function renderAvatarVisual(options, resolvedAvatarRenderDefinition) {
28675
+ const resolvedRenderDefinition = resolvedAvatarRenderDefinition ||
28676
+ resolveAvatarRenderDefinition({
28677
+ avatarDefinition: options.avatarDefinition,
28678
+ visualId: options.visualId,
28679
+ surface: options.surface,
28680
+ });
28470
28681
  const context = options.canvas.getContext('2d');
28471
28682
  if (!context) {
28472
28683
  throw new Error('2D canvas rendering context is unavailable.');
28473
28684
  }
28474
28685
  prepareAvatarCanvas(options.canvas, context, options.size, options.devicePixelRatio || 1);
28475
- avatarVisual.render({
28686
+ resolvedRenderDefinition.avatarVisual.render({
28476
28687
  canvas: options.canvas,
28477
28688
  context,
28478
28689
  size: options.size,
28479
28690
  devicePixelRatio: options.devicePixelRatio || 1,
28480
28691
  timeMs: options.timeMs,
28481
- avatarDefinition: normalizedAvatarDefinition,
28482
- palette: createAvatarPalette(normalizedAvatarDefinition, surface),
28483
- createRandom: createAvatarRandomFactory(normalizedAvatarDefinition),
28484
- surface,
28692
+ avatarDefinition: resolvedRenderDefinition.avatarDefinition,
28693
+ palette: resolvedRenderDefinition.palette,
28694
+ createRandom: resolvedRenderDefinition.createRandom,
28695
+ surface: resolvedRenderDefinition.surface,
28485
28696
  interaction: options.interaction || createIdleAvatarInteractionState(),
28486
28697
  });
28487
28698
  }
@@ -28492,6 +28703,14 @@
28492
28703
  * @private helper of `<Avatar/>`
28493
28704
  */
28494
28705
  const AVATAR_CANVAS_RADIUS_RATIO = 0.18;
28706
+ /**
28707
+ * Maximum time between layout-bound refreshes while pointer tracking is active.
28708
+ *
28709
+ * This keeps pointer-aware visuals aligned with chat/layout shifts without forcing a layout read every frame.
28710
+ *
28711
+ * @private helper of `<Avatar/>`
28712
+ */
28713
+ const ACTIVE_POINTER_BOUNDS_REFRESH_MS = 120;
28495
28714
  /**
28496
28715
  * Canvas-based deterministic avatar component.
28497
28716
  *
@@ -28502,21 +28721,58 @@
28502
28721
  const canvasRef = react.useRef(null);
28503
28722
  const animationStartRef = react.useRef(null);
28504
28723
  const interactionRuntimeStateRef = react.useRef(createAvatarInteractionRuntimeState());
28724
+ const avatarBoundsRef = react.useRef(null);
28725
+ const lastResolvedPointerVersionRef = react.useRef(-1);
28726
+ const lastResolvedViewportLayoutVersionRef = react.useRef(-1);
28727
+ const lastAvatarBoundsRefreshAtRef = react.useRef(0);
28505
28728
  const avatarColorsKey = avatarDefinition.colors.join('|');
28506
- const normalizedAvatarDefinition = react.useMemo(() => normalizeAvatarDefinition(avatarDefinition), [avatarDefinition.agentHash, avatarDefinition.agentName, avatarColorsKey]);
28507
- const avatarDefinitionKey = react.useMemo(() => createAvatarDefinitionKey(normalizedAvatarDefinition), [normalizedAvatarDefinition.agentHash, normalizedAvatarDefinition.agentName, normalizedAvatarDefinition.colors.join('|')]);
28508
- const avatarVisual = react.useMemo(() => getAvatarVisualById(visualId), [visualId]);
28729
+ const resolvedAvatarRenderDefinition = react.useMemo(() => resolveAvatarRenderDefinition({
28730
+ avatarDefinition,
28731
+ visualId,
28732
+ surface,
28733
+ }), [avatarDefinition.agentHash, avatarDefinition.agentName, avatarColorsKey, surface, visualId]);
28734
+ const avatarDefinitionKey = react.useMemo(() => createAvatarDefinitionKey(resolvedAvatarRenderDefinition.avatarDefinition), [
28735
+ resolvedAvatarRenderDefinition.avatarDefinition.agentHash,
28736
+ resolvedAvatarRenderDefinition.avatarDefinition.agentName,
28737
+ resolvedAvatarRenderDefinition.avatarDefinition.colors.join('|'),
28738
+ ]);
28739
+ const [isVisible, setIsVisible] = react.useState(true);
28740
+ react.useEffect(() => {
28741
+ const canvas = canvasRef.current;
28742
+ if (!canvas) {
28743
+ throw new Error('Avatar canvas is not mounted.');
28744
+ }
28745
+ return observeAvatarVisibility(canvas, setIsVisible);
28746
+ }, []);
28509
28747
  react.useEffect(() => {
28510
28748
  interactionRuntimeStateRef.current = createAvatarInteractionRuntimeState();
28511
- }, [avatarDefinitionKey, visualId]);
28749
+ avatarBoundsRef.current = null;
28750
+ lastResolvedPointerVersionRef.current = -1;
28751
+ lastResolvedViewportLayoutVersionRef.current = -1;
28752
+ lastAvatarBoundsRefreshAtRef.current = 0;
28753
+ }, [avatarDefinitionKey, isVisible, visualId]);
28754
+ react.useEffect(() => {
28755
+ const canvas = canvasRef.current;
28756
+ if (!canvas || typeof ResizeObserver === 'undefined') {
28757
+ return;
28758
+ }
28759
+ const resizeObserver = new ResizeObserver(() => {
28760
+ avatarBoundsRef.current = null;
28761
+ });
28762
+ resizeObserver.observe(canvas);
28763
+ return () => {
28764
+ resizeObserver.disconnect();
28765
+ };
28766
+ }, []);
28512
28767
  react.useEffect(() => {
28513
28768
  const canvas = canvasRef.current;
28514
28769
  if (!canvas) {
28515
28770
  throw new Error('Avatar canvas is not mounted.');
28516
28771
  }
28772
+ const avatarVisual = resolvedAvatarRenderDefinition.avatarVisual;
28517
28773
  const isDynamicAvatar = avatarVisual.isAnimated || avatarVisual.supportsPointerTracking === true;
28518
- const releasePointerTracking = avatarVisual.supportsPointerTracking ? retainAvatarPointerTracking() : null;
28519
- let animationFrameId = null;
28774
+ const shouldTrackPointer = avatarVisual.supportsPointerTracking === true && isVisible;
28775
+ const releasePointerTracking = shouldTrackPointer ? retainAvatarPointerTracking() : null;
28520
28776
  if (animationStartRef.current === null) {
28521
28777
  animationStartRef.current = performance.now();
28522
28778
  }
@@ -28524,7 +28780,18 @@
28524
28780
  const pointerSnapshot = avatarVisual.supportsPointerTracking ? getAvatarPointerSnapshot() : null;
28525
28781
  let interactionState = createIdleAvatarInteractionState();
28526
28782
  if (avatarVisual.supportsPointerTracking && pointerSnapshot) {
28527
- interactionRuntimeStateRef.current = stepAvatarInteractionRuntimeState(interactionRuntimeStateRef.current, resolveAvatarPointerTarget(canvas.getBoundingClientRect(), pointerSnapshot), now);
28783
+ const pointerSnapshotVersion = getAvatarPointerSnapshotVersion();
28784
+ const viewportLayoutVersion = getAvatarViewportLayoutVersion();
28785
+ if (avatarBoundsRef.current === null ||
28786
+ lastResolvedPointerVersionRef.current !== pointerSnapshotVersion ||
28787
+ lastResolvedViewportLayoutVersionRef.current !== viewportLayoutVersion ||
28788
+ now - lastAvatarBoundsRefreshAtRef.current >= ACTIVE_POINTER_BOUNDS_REFRESH_MS) {
28789
+ avatarBoundsRef.current = canvas.getBoundingClientRect();
28790
+ lastResolvedPointerVersionRef.current = pointerSnapshotVersion;
28791
+ lastResolvedViewportLayoutVersionRef.current = viewportLayoutVersion;
28792
+ lastAvatarBoundsRefreshAtRef.current = now;
28793
+ }
28794
+ interactionRuntimeStateRef.current = stepAvatarInteractionRuntimeState(interactionRuntimeStateRef.current, resolveAvatarPointerTarget(avatarBoundsRef.current, pointerSnapshot), now);
28528
28795
  interactionState = interactionRuntimeStateRef.current;
28529
28796
  }
28530
28797
  else if (avatarVisual.supportsPointerTracking) {
@@ -28533,35 +28800,35 @@
28533
28800
  }
28534
28801
  renderAvatarVisual({
28535
28802
  canvas,
28536
- avatarDefinition: normalizedAvatarDefinition,
28803
+ avatarDefinition: resolvedAvatarRenderDefinition.avatarDefinition,
28537
28804
  visualId,
28538
28805
  surface,
28539
28806
  size,
28540
28807
  timeMs: now - animationStartRef.current,
28541
28808
  devicePixelRatio: window.devicePixelRatio || 1,
28542
28809
  interaction: interactionState,
28543
- });
28544
- if (isDynamicAvatar) {
28545
- animationFrameId = window.requestAnimationFrame(renderFrame);
28546
- }
28810
+ }, resolvedAvatarRenderDefinition);
28547
28811
  };
28548
28812
  renderFrame(performance.now());
28813
+ if (!isDynamicAvatar || !isVisible) {
28814
+ return () => {
28815
+ releasePointerTracking === null || releasePointerTracking === void 0 ? void 0 : releasePointerTracking();
28816
+ };
28817
+ }
28818
+ const releaseAnimationListener = retainAvatarAnimationListener(renderFrame);
28549
28819
  return () => {
28550
- if (animationFrameId !== null) {
28551
- window.cancelAnimationFrame(animationFrameId);
28552
- }
28820
+ releaseAnimationListener();
28553
28821
  releasePointerTracking === null || releasePointerTracking === void 0 ? void 0 : releasePointerTracking();
28554
28822
  };
28555
28823
  }, [
28556
28824
  avatarDefinitionKey,
28557
- avatarVisual.isAnimated,
28558
- avatarVisual.supportsPointerTracking,
28559
- normalizedAvatarDefinition,
28825
+ isVisible,
28826
+ resolvedAvatarRenderDefinition,
28560
28827
  size,
28561
28828
  surface,
28562
28829
  visualId,
28563
28830
  ]);
28564
- return (jsxRuntime.jsx("canvas", { ref: canvasRef, title: title || `${normalizedAvatarDefinition.agentName} avatar`, className: className, style: {
28831
+ return (jsxRuntime.jsx("canvas", { ref: canvasRef, title: title || `${resolvedAvatarRenderDefinition.avatarDefinition.agentName} avatar`, className: className, style: {
28565
28832
  width: size,
28566
28833
  height: size,
28567
28834
  display: 'block',
@@ -49533,12 +49800,6 @@
49533
49800
  });
49534
49801
  }
49535
49802
  }
49536
- const staticConversationDelayConfig = {
49537
- ...FAST_FLOW,
49538
- beforeFirstMessage: 0,
49539
- // Show the full internal exchange immediately so the modal never opens as a blank panel.
49540
- showIntermediateMessages: messages.length,
49541
- };
49542
49803
  const agentName = ((_c = (_b = teamResult.conversation) === null || _b === void 0 ? void 0 : _b.find((entry) => entry.sender === 'AGENT' || entry.role === 'AGENT')) === null || _c === void 0 ? void 0 : _c.name) || 'Agent';
49543
49804
  const teammateConversationName = ((_e = (_d = teamResult.conversation) === null || _d === void 0 ? void 0 : _d.find((entry) => entry.sender === 'TEAMMATE' || entry.role === 'TEAMMATE')) === null || _e === void 0 ? void 0 : _e.name) || '';
49544
49805
  const teammateProfile = teammateUrl ? teamProfiles[teammateUrl] : undefined;
@@ -49575,7 +49836,12 @@
49575
49836
  avatarSrc: resolvedTeammateAvatar || undefined,
49576
49837
  },
49577
49838
  ];
49578
- return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { className: classNames(styles$5.searchModalHeader, styles$5.teamModalHeader), children: jsxRuntime.jsxs("div", { className: styles$5.teamHeaderParticipants, children: [jsxRuntime.jsx(TeamHeaderProfile, { label: resolvedAgentLabel, avatarSrc: resolvedAgentAvatar, avatarDefinition: resolvedAgentAvatarDefinition, avatarVisualId: resolvedAgentAvatarVisualId, fallbackColor: resolvedAgentHeaderColor }), jsxRuntime.jsx("span", { className: styles$5.teamHeaderDivider, children: "talking with" }), jsxRuntime.jsx(TeamHeaderProfile, { label: resolvedTeammateLabel, avatarSrc: resolvedTeammateAvatar, fallbackColor: "#0ea5e9", href: teammateLink })] }) }), jsxRuntime.jsxs("div", { className: styles$5.searchModalContent, children: [messages.length > 0 ? (jsxRuntime.jsx("div", { className: styles$5.teamChatContainer, children: jsxRuntime.jsx(MockedChat, { title: `Chat between ${resolvedAgentLabel} and ${resolvedTeammateLabel}`, messages: messages, participants: participants, isResettable: false, isPausable: false, isSaveButtonEnabled: false, isCopyButtonEnabled: false, visual: "STANDALONE", delayConfig: staticConversationDelayConfig }) })) : (jsxRuntime.jsx("div", { className: styles$5.noResults, children: "No teammate conversation available." })), (hasTeamToolCalls || hasTeamCitations) && (jsxRuntime.jsxs("div", { className: styles$5.teamToolCallSection, children: [hasTeamToolCalls && (jsxRuntime.jsxs("div", { className: styles$5.teamToolCallGroup, children: [jsxRuntime.jsx("div", { className: styles$5.teamToolCallHeading, children: "Actions" }), jsxRuntime.jsx("div", { className: styles$5.teamToolCallChips, children: teamToolCalls.map((toolCallEntry, index) => {
49839
+ return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { className: classNames(styles$5.searchModalHeader, styles$5.teamModalHeader), children: jsxRuntime.jsxs("div", { className: styles$5.teamHeaderParticipants, children: [jsxRuntime.jsx(TeamHeaderProfile, { label: resolvedAgentLabel, avatarSrc: resolvedAgentAvatar, avatarDefinition: resolvedAgentAvatarDefinition, avatarVisualId: resolvedAgentAvatarVisualId, fallbackColor: resolvedAgentHeaderColor }), jsxRuntime.jsx("span", { className: styles$5.teamHeaderDivider, children: "talking with" }), jsxRuntime.jsx(TeamHeaderProfile, { label: resolvedTeammateLabel, avatarSrc: resolvedTeammateAvatar, fallbackColor: "#0ea5e9", href: teammateLink })] }) }), jsxRuntime.jsxs("div", { className: styles$5.searchModalContent, children: [messages.length > 0 ? (jsxRuntime.jsx("div", { className: styles$5.teamChatContainer, children: jsxRuntime.jsx(MockedChat, { title: `Chat between ${resolvedAgentLabel} and ${resolvedTeammateLabel}`, messages: messages, participants: participants, isResettable: false, isPausable: false, isSaveButtonEnabled: false, isCopyButtonEnabled: false, layout: "STANDALONE", delayConfig: {
49840
+ // Note+TODO: For some strange reason, <MockedChat/> is not running and stays static on the initial frame, so doing this hack to force it to show the entire chat at once. Need to investigate why the animation is not running as expected and then just use `delayConfig={FAST_FLOW}`
49841
+ ...FAST_FLOW,
49842
+ beforeFirstMessage: 0,
49843
+ showIntermediateMessages: messages.length,
49844
+ }, visualMode: "BUBBLE_MODE" }) })) : (jsxRuntime.jsx("div", { className: styles$5.noResults, children: "No teammate conversation available." })), (hasTeamToolCalls || hasTeamCitations) && (jsxRuntime.jsxs("div", { className: styles$5.teamToolCallSection, children: [hasTeamToolCalls && (jsxRuntime.jsxs("div", { className: styles$5.teamToolCallGroup, children: [jsxRuntime.jsx("div", { className: styles$5.teamToolCallHeading, children: "Actions" }), jsxRuntime.jsx("div", { className: styles$5.teamToolCallChips, children: teamToolCalls.map((toolCallEntry, index) => {
49579
49845
  const chipletInfo = getToolCallChipletInfo(toolCallEntry.toolCall, undefined, toolTitles);
49580
49846
  const chipletText = buildToolCallChipText(chipletInfo);
49581
49847
  return (jsxRuntime.jsxs("button", { className: styles$5.completedToolCall, onClick: () => {
@@ -50514,7 +50780,7 @@
50514
50780
  * @public exported from `@promptbook/components`
50515
50781
  */
50516
50782
  function Chat(props) {
50517
- const { title = 'Chat', messages, onChange, onMessage, onActionButton, onQuickMessageButton, onReplyToMessage, onCancelReply, onReset, resetRequiresConfirmation = true, newChatButtonHref, onFeedback, feedbackMode = 'stars', feedbackTranslations, timingTranslations, onFileUpload, chatLocale, speechRecognition, placeholderMessageContent, defaultMessage, enterBehavior, resolveEnterBehavior, children, className, style, isAiTextHumanizedAndPromptbookified = true, isVoiceCalling = false, isFocusedOnLoad, participants = [], canReplyToMessage, replyingToMessage, extraActions, actionsContainer, saveFormats, isSaveButtonEnabled = true, isCopyButtonEnabled = true, buttonColor: buttonColorRaw, onUseTemplate, onCreateAgent, toolTitles, teammates, teamAgentProfiles, visual, visualMode = 'ARTICLE_MODE', effectConfigs, soundSystem, speechRecognitionLanguage, isSpeechPlaybackEnabled = true, elevenLabsVoiceId, chatUiTranslations, } = props;
50783
+ const { title = 'Chat', messages, onChange, onMessage, onActionButton, onQuickMessageButton, onReplyToMessage, onCancelReply, onReset, resetRequiresConfirmation = true, newChatButtonHref, onFeedback, feedbackMode = 'stars', feedbackTranslations, timingTranslations, onFileUpload, chatLocale, speechRecognition, placeholderMessageContent, defaultMessage, enterBehavior, resolveEnterBehavior, children, className, style, isAiTextHumanizedAndPromptbookified = true, isVoiceCalling = false, isFocusedOnLoad, participants = [], canReplyToMessage, replyingToMessage, extraActions, actionsContainer, saveFormats, isSaveButtonEnabled = true, isCopyButtonEnabled = true, buttonColor: buttonColorRaw, onUseTemplate, onCreateAgent, toolTitles, teammates, teamAgentProfiles, layout, visualMode = 'ARTICLE_MODE', effectConfigs, soundSystem, speechRecognitionLanguage, isSpeechPlaybackEnabled = true, elevenLabsVoiceId, chatUiTranslations, } = props;
50518
50784
  const buttonColor = react.useMemo(() => Color.from(buttonColorRaw || '#0066cc'), [buttonColorRaw]);
50519
50785
  const agentParticipant = react.useMemo(() => participants.find((participant) => participant.name === 'AGENT'), [participants]);
50520
50786
  const postprocessedMessages = useChatPostprocessedMessages({
@@ -50555,11 +50821,11 @@
50555
50821
  extraActions,
50556
50822
  isSaveButtonEnabled,
50557
50823
  });
50558
- const isConstrainedArticleMode = visualMode === 'ARTICLE_MODE' && visual === 'FULL_PAGE';
50824
+ const isConstrainedArticleMode = visualMode === 'ARTICLE_MODE' && layout === 'FULL_PAGE';
50559
50825
  useChatCompleteNotification(messages, soundSystem);
50560
50826
  return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [feedbackStatus && (jsxRuntime.jsx("div", { className: classNames(styles$5.feedbackStatus, feedbackStatus.variant === 'success'
50561
50827
  ? styles$5.feedbackStatusSuccess
50562
- : styles$5.feedbackStatusError), "aria-live": "polite", role: "status", children: feedbackStatus.message })), effectConfigs && effectConfigs.length > 0 && (jsxRuntime.jsx(ChatEffectsSystem, { messages: postprocessedMessages, effectConfigs: effectConfigs, soundSystem: soundSystem })), jsxRuntime.jsx("div", { className: classNames(className, styles$5.Chat, visual === 'STANDALONE' && styles$5.standaloneVisual, visual === 'FULL_PAGE' && styles$5.fullPageVisual, isConstrainedArticleMode && styles$5.constrainedArticleVisual, getChatCssClassName('Chat'), chatCssClassNames.chat), style, children: jsxRuntime.jsxs("div", { className: classNames(className, styles$5.chatMainFlow, getChatCssClassName('chatMainFlow'), chatCssClassNames.chatMainFlow), children: [children && jsxRuntime.jsx("div", { className: classNames(styles$5.chatChildren), children: children }), shouldShowScrollToBottom && (jsxRuntime.jsx("div", { className: styles$5.scrollToBottomContainer, children: jsxRuntime.jsxs("div", { className: styles$5.scrollToBottomWrapper, children: [jsxRuntime.jsx(SolidArrowButton, { "data-button-type": "custom", direction: "down", iconSize: 33, className: classNames(styles$5.scrollToBottom, scrollToBottomCssClassName), onClick: handleButtonClick(() => scrollToBottom()), "aria-label": ariaLabel, title: ariaLabel }), badgeLabel && (jsxRuntime.jsx("span", { className: styles$5.scrollToBottomBadge, "aria-live": "polite", role: "status", children: badgeLabel }))] }) })), isVoiceCalling && (jsxRuntime.jsx("div", { className: styles$5.voiceCallIndicatorBar, children: jsxRuntime.jsxs("div", { className: styles$5.voiceCallIndicator, children: [jsxRuntime.jsx("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "currentColor", children: jsxRuntime.jsx("path", { d: "M6.62 10.79c1.44 2.83 3.76 5.14 6.59 6.59l2.2-2.2c.27-.27.67-.36 1.02-.24 1.12.37 2.33.57 3.57.57.55 0 1 .45 1 1V20c0 .55-.45 1-1 1-9.39 0-17-7.61-17-17 0-.55.45-1 1-1h3.5c.55 0 1 .45 1 1 0 1.25.2 2.45.57 3.57.11.35.03.74-.25 1.02l-2.2 2.2z" }) }), jsxRuntime.jsx("span", { children: "Voice call active" }), jsxRuntime.jsx("div", { className: styles$5.voiceCallPulse })] }) })), jsxRuntime.jsx(ChatActionsBar, { actionsRef: actionsRef, actionsContainer: actionsContainer, messages: postprocessedMessages, participants: participants, title: title, onReset: onReset, resetRequiresConfirmation: resetRequiresConfirmation, newChatButtonHref: newChatButtonHref, onUseTemplate: onUseTemplate, extraActions: extraActions, saveFormats: saveFormats, isSaveButtonEnabled: isSaveButtonEnabled, shouldFadeActions: shouldFadeActions, shouldDisableActions: shouldDisableActions, chatUiTranslations: chatUiTranslations, onButtonClick: handleButtonClick }), jsxRuntime.jsx(ChatMessageList, { messages: postprocessedMessages, participants: participants, expandedMessageId: expandedMessageId, messageRatings: messageRatings, setExpandedMessageId: setExpandedMessageId, handleRating: handleRating, mode: mode, isCopyButtonEnabled: isCopyButtonEnabled, isFeedbackEnabled: isFeedbackEnabled, feedbackMode: feedbackMode, feedbackTranslations: feedbackTranslations, timingTranslations: timingTranslations, chatLocale: chatLocale, onCopy: handleCopy, onMessage: onMessage, onActionButton: onActionButton, onQuickMessageButton: onQuickMessageButton, onReplyToMessage: onReplyToMessage, canReplyToMessage: canReplyToMessage, onCreateAgent: onCreateAgent, toolTitles: toolTitles, teammates: teammates, teamAgentProfiles: teamAgentProfiles, visualMode: visualMode, soundSystem: soundSystem, onToolCallClick: openToolCall, onCitationClick: openCitation, setChatMessagesElement: setChatMessagesElement, onScroll: handleChatScroll, isSpeechPlaybackEnabled: isSpeechPlaybackEnabled, elevenLabsVoiceId: elevenLabsVoiceId, chatUiTranslations: chatUiTranslations, chatMessagesClassName: classNames(isConstrainedArticleMode && styles$5.articleModeChatMessages, getChatCssClassName('chatMessages'), chatCssClassNames.chatMessages), hasActions: hasActions }), onMessage && (jsxRuntime.jsx(ChatInputArea, { onMessage: onMessage, onChange: onChange, onFileUpload: onFileUpload, speechRecognition: speechRecognition, speechRecognitionLanguage: speechRecognitionLanguage, replyingToMessage: replyingToMessage, onCancelReply: onCancelReply, defaultMessage: defaultMessage, enterBehavior: enterBehavior, resolveEnterBehavior: resolveEnterBehavior, placeholderMessageContent: placeholderMessageContent || (chatUiTranslations === null || chatUiTranslations === void 0 ? void 0 : chatUiTranslations.inputPlaceholder), isFocusedOnLoad: isFocusedOnLoad, isMobile: isMobile, isVoiceCalling: isVoiceCalling, participants: participants, buttonColor: buttonColor, soundSystem: soundSystem, onButtonClick: handleButtonClick, chatUiTranslations: chatUiTranslations, chatInputClassName: classNames(isConstrainedArticleMode && styles$5.articleModeChatInput, getChatCssClassName('chatInput'), chatCssClassNames.chatInput) }))] }) }), jsxRuntime.jsx(ChatToolCallModal, { isOpen: toolCallModalOpen, toolCall: selectedToolCall, toolCallIdentity: selectedToolCallIdentity, onClose: closeToolCallModal, toolTitles: toolTitles, agentParticipant: agentParticipant, buttonColor: buttonColor, teamAgentProfiles: teamAgentProfiles, chatUiTranslations: chatUiTranslations, locale: chatLocale, availableTools: selectedMessageAvailableTools }), jsxRuntime.jsx(ChatCitationModal, { isOpen: citationModalOpen, citation: selectedCitation, participants: participants, soundSystem: soundSystem, onClose: closeCitationModal }), jsxRuntime.jsx(ChatRatingModal, { isOpen: ratingModalOpen, selectedMessage: selectedMessage, postprocessedMessages: postprocessedMessages, messages: messages, hoveredRating: hoveredRating, messageRatings: messageRatings, textRating: textRating, feedbackMode: feedbackMode, feedbackTranslations: feedbackTranslations, mode: mode, isMobile: isMobile, onClose: () => setRatingModalOpen(false), setHoveredRating: setHoveredRating, setMessageRatings: setMessageRatings, setSelectedMessage: setSelectedMessage, setTextRating: setTextRating, submitRating: submitRating })] }));
50828
+ : styles$5.feedbackStatusError), "aria-live": "polite", role: "status", children: feedbackStatus.message })), effectConfigs && effectConfigs.length > 0 && (jsxRuntime.jsx(ChatEffectsSystem, { messages: postprocessedMessages, effectConfigs: effectConfigs, soundSystem: soundSystem })), jsxRuntime.jsx("div", { className: classNames(className, styles$5.Chat, layout === 'STANDALONE' && styles$5.standaloneVisual, layout === 'FULL_PAGE' && styles$5.fullPageVisual, isConstrainedArticleMode && styles$5.constrainedArticleVisual, getChatCssClassName('Chat'), chatCssClassNames.chat), style, children: jsxRuntime.jsxs("div", { className: classNames(className, styles$5.chatMainFlow, getChatCssClassName('chatMainFlow'), chatCssClassNames.chatMainFlow), children: [children && jsxRuntime.jsx("div", { className: classNames(styles$5.chatChildren), children: children }), shouldShowScrollToBottom && (jsxRuntime.jsx("div", { className: styles$5.scrollToBottomContainer, children: jsxRuntime.jsxs("div", { className: styles$5.scrollToBottomWrapper, children: [jsxRuntime.jsx(SolidArrowButton, { "data-button-type": "custom", direction: "down", iconSize: 33, className: classNames(styles$5.scrollToBottom, scrollToBottomCssClassName), onClick: handleButtonClick(() => scrollToBottom()), "aria-label": ariaLabel, title: ariaLabel }), badgeLabel && (jsxRuntime.jsx("span", { className: styles$5.scrollToBottomBadge, "aria-live": "polite", role: "status", children: badgeLabel }))] }) })), isVoiceCalling && (jsxRuntime.jsx("div", { className: styles$5.voiceCallIndicatorBar, children: jsxRuntime.jsxs("div", { className: styles$5.voiceCallIndicator, children: [jsxRuntime.jsx("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "currentColor", children: jsxRuntime.jsx("path", { d: "M6.62 10.79c1.44 2.83 3.76 5.14 6.59 6.59l2.2-2.2c.27-.27.67-.36 1.02-.24 1.12.37 2.33.57 3.57.57.55 0 1 .45 1 1V20c0 .55-.45 1-1 1-9.39 0-17-7.61-17-17 0-.55.45-1 1-1h3.5c.55 0 1 .45 1 1 0 1.25.2 2.45.57 3.57.11.35.03.74-.25 1.02l-2.2 2.2z" }) }), jsxRuntime.jsx("span", { children: "Voice call active" }), jsxRuntime.jsx("div", { className: styles$5.voiceCallPulse })] }) })), jsxRuntime.jsx(ChatActionsBar, { actionsRef: actionsRef, actionsContainer: actionsContainer, messages: postprocessedMessages, participants: participants, title: title, onReset: onReset, resetRequiresConfirmation: resetRequiresConfirmation, newChatButtonHref: newChatButtonHref, onUseTemplate: onUseTemplate, extraActions: extraActions, saveFormats: saveFormats, isSaveButtonEnabled: isSaveButtonEnabled, shouldFadeActions: shouldFadeActions, shouldDisableActions: shouldDisableActions, chatUiTranslations: chatUiTranslations, onButtonClick: handleButtonClick }), jsxRuntime.jsx(ChatMessageList, { messages: postprocessedMessages, participants: participants, expandedMessageId: expandedMessageId, messageRatings: messageRatings, setExpandedMessageId: setExpandedMessageId, handleRating: handleRating, mode: mode, isCopyButtonEnabled: isCopyButtonEnabled, isFeedbackEnabled: isFeedbackEnabled, feedbackMode: feedbackMode, feedbackTranslations: feedbackTranslations, timingTranslations: timingTranslations, chatLocale: chatLocale, onCopy: handleCopy, onMessage: onMessage, onActionButton: onActionButton, onQuickMessageButton: onQuickMessageButton, onReplyToMessage: onReplyToMessage, canReplyToMessage: canReplyToMessage, onCreateAgent: onCreateAgent, toolTitles: toolTitles, teammates: teammates, teamAgentProfiles: teamAgentProfiles, visualMode: visualMode, soundSystem: soundSystem, onToolCallClick: openToolCall, onCitationClick: openCitation, setChatMessagesElement: setChatMessagesElement, onScroll: handleChatScroll, isSpeechPlaybackEnabled: isSpeechPlaybackEnabled, elevenLabsVoiceId: elevenLabsVoiceId, chatUiTranslations: chatUiTranslations, chatMessagesClassName: classNames(isConstrainedArticleMode && styles$5.articleModeChatMessages, getChatCssClassName('chatMessages'), chatCssClassNames.chatMessages), hasActions: hasActions }), onMessage && (jsxRuntime.jsx(ChatInputArea, { onMessage: onMessage, onChange: onChange, onFileUpload: onFileUpload, speechRecognition: speechRecognition, speechRecognitionLanguage: speechRecognitionLanguage, replyingToMessage: replyingToMessage, onCancelReply: onCancelReply, defaultMessage: defaultMessage, enterBehavior: enterBehavior, resolveEnterBehavior: resolveEnterBehavior, placeholderMessageContent: placeholderMessageContent || (chatUiTranslations === null || chatUiTranslations === void 0 ? void 0 : chatUiTranslations.inputPlaceholder), isFocusedOnLoad: isFocusedOnLoad, isMobile: isMobile, isVoiceCalling: isVoiceCalling, participants: participants, buttonColor: buttonColor, soundSystem: soundSystem, onButtonClick: handleButtonClick, chatUiTranslations: chatUiTranslations, chatInputClassName: classNames(isConstrainedArticleMode && styles$5.articleModeChatInput, getChatCssClassName('chatInput'), chatCssClassNames.chatInput) }))] }) }), jsxRuntime.jsx(ChatToolCallModal, { isOpen: toolCallModalOpen, toolCall: selectedToolCall, toolCallIdentity: selectedToolCallIdentity, onClose: closeToolCallModal, toolTitles: toolTitles, agentParticipant: agentParticipant, buttonColor: buttonColor, teamAgentProfiles: teamAgentProfiles, chatUiTranslations: chatUiTranslations, locale: chatLocale, availableTools: selectedMessageAvailableTools }), jsxRuntime.jsx(ChatCitationModal, { isOpen: citationModalOpen, citation: selectedCitation, participants: participants, soundSystem: soundSystem, onClose: closeCitationModal }), jsxRuntime.jsx(ChatRatingModal, { isOpen: ratingModalOpen, selectedMessage: selectedMessage, postprocessedMessages: postprocessedMessages, messages: messages, hoveredRating: hoveredRating, messageRatings: messageRatings, textRating: textRating, feedbackMode: feedbackMode, feedbackTranslations: feedbackTranslations, mode: mode, isMobile: isMobile, onClose: () => setRatingModalOpen(false), setHoveredRating: setHoveredRating, setMessageRatings: setMessageRatings, setSelectedMessage: setSelectedMessage, setTextRating: setTextRating, submitRating: submitRating })] }));
50563
50829
  }
50564
50830
 
50565
50831
  /**
@@ -51865,7 +52131,7 @@
51865
52131
  : styles.PromptbookAgentSeamlessIntegrationStatusPending) }), jsxRuntime.jsxs("div", { className: styles.PromptbookAgentSeamlessIntegrationText, children: [jsxRuntime.jsx("div", { className: styles.PromptbookAgentSeamlessIntegrationLabel, children: "Chat" }), jsxRuntime.jsx("div", { className: styles.PromptbookAgentSeamlessIntegrationHint, children: displayName })] }), jsxRuntime.jsx("span", { className: styles.PromptbookAgentSeamlessIntegrationScreenReaderOnly, children: connectionStatusText })] }), isOpen && (jsxRuntime.jsxs("div", { className: styles.PromptbookAgentSeamlessIntegrationWindow, id: windowId, children: [jsxRuntime.jsxs("div", { className: styles.PromptbookAgentSeamlessIntegrationHeader, style: { backgroundColor: color }, ref: setHeaderElement, children: [jsxRuntime.jsxs("div", { className: styles.PromptbookAgentSeamlessIntegrationTitleWrap, children: [jsxRuntime.jsx("div", { className: styles.PromptbookAgentSeamlessIntegrationTitle, children: displayName }), jsxRuntime.jsx("div", { className: styles.PromptbookAgentSeamlessIntegrationSubtitle, children: connectionStatusText })] }), isIframeUsed && (jsxRuntime.jsx("button", { className: styles.PromptbookAgentSeamlessIntegrationClose, onClick: () => setOpen(false), title: "Close", "aria-label": "Close chat", children: jsxRuntime.jsx(CloseIcon, {}) }))] }), jsxRuntime.jsx("div", { className: styles.PromptbookAgentSeamlessIntegrationContent, children: isIframeUsed ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [!isIframeLoaded && (jsxRuntime.jsxs("div", { className: styles.PromptbookAgentSeamlessIntegrationLoading, children: [jsxRuntime.jsx("div", { className: styles.PromptbookAgentSeamlessIntegrationLoadingShimmer }), jsxRuntime.jsx("div", { className: styles.PromptbookAgentSeamlessIntegrationLoadingSpinner }), jsxRuntime.jsx("div", { className: styles.PromptbookAgentSeamlessIntegrationLoadingTitle, children: "Preparing your chat" }), jsxRuntime.jsxs("div", { className: styles.PromptbookAgentSeamlessIntegrationLoadingText, children: ["Connecting to ", displayName, "..."] })] })), jsxRuntime.jsx("iframe", { src: agentUrl + '/chat?headless', className: styles.PromptbookAgentSeamlessIntegrationIframe, style: { opacity: isIframeLoaded ? 1 : 0 }, tabIndex: -1, onLoad: () => {
51866
52132
  setIsIframeLoaded(true);
51867
52133
  setIsChatConnected(true);
51868
- } })] })) : agent ? (jsxRuntime.jsx(AgentChat, { agent: agent, actionsContainer: headerElement, isFocusedOnLoad: isFocusedOnLoad, extraActions: jsxRuntime.jsx("button", { className: styles.PromptbookAgentSeamlessIntegrationClose, onClick: () => setOpen(false), title: "Close", "aria-label": "Close chat", children: jsxRuntime.jsx(CloseIcon, {}) }), visual: "STANDALONE" })) : error ? (jsxRuntime.jsxs("div", { className: styles.PromptbookAgentSeamlessIntegrationError, children: [jsxRuntime.jsx("div", { className: styles.PromptbookAgentSeamlessIntegrationErrorTitle, children: "Failed to connect to the agent" }), jsxRuntime.jsx("div", { className: styles.PromptbookAgentSeamlessIntegrationErrorMessage, children: error.message })] })) : (jsxRuntime.jsxs("div", { className: styles.PromptbookAgentSeamlessIntegrationLoading, children: [jsxRuntime.jsx("div", { className: styles.PromptbookAgentSeamlessIntegrationLoadingShimmer }), jsxRuntime.jsx("div", { className: styles.PromptbookAgentSeamlessIntegrationLoadingSpinner }), jsxRuntime.jsx("div", { className: styles.PromptbookAgentSeamlessIntegrationLoadingTitle, children: "Preparing your chat" }), jsxRuntime.jsxs("div", { className: styles.PromptbookAgentSeamlessIntegrationLoadingText, children: ["Connecting to ", displayName, "..."] })] })) })] }))] }));
52134
+ } })] })) : agent ? (jsxRuntime.jsx(AgentChat, { agent: agent, actionsContainer: headerElement, isFocusedOnLoad: isFocusedOnLoad, extraActions: jsxRuntime.jsx("button", { className: styles.PromptbookAgentSeamlessIntegrationClose, onClick: () => setOpen(false), title: "Close", "aria-label": "Close chat", children: jsxRuntime.jsx(CloseIcon, {}) }), layout: "STANDALONE" })) : error ? (jsxRuntime.jsxs("div", { className: styles.PromptbookAgentSeamlessIntegrationError, children: [jsxRuntime.jsx("div", { className: styles.PromptbookAgentSeamlessIntegrationErrorTitle, children: "Failed to connect to the agent" }), jsxRuntime.jsx("div", { className: styles.PromptbookAgentSeamlessIntegrationErrorMessage, children: error.message })] })) : (jsxRuntime.jsxs("div", { className: styles.PromptbookAgentSeamlessIntegrationLoading, children: [jsxRuntime.jsx("div", { className: styles.PromptbookAgentSeamlessIntegrationLoadingShimmer }), jsxRuntime.jsx("div", { className: styles.PromptbookAgentSeamlessIntegrationLoadingSpinner }), jsxRuntime.jsx("div", { className: styles.PromptbookAgentSeamlessIntegrationLoadingTitle, children: "Preparing your chat" }), jsxRuntime.jsxs("div", { className: styles.PromptbookAgentSeamlessIntegrationLoadingText, children: ["Connecting to ", displayName, "..."] })] })) })] }))] }));
51869
52135
  }
51870
52136
 
51871
52137
  /**