@superinterface/react 5.3.0-beta.2 → 5.3.0-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -47017,11 +47017,11 @@ ThreadDialog.Root = Root13;
47017
47017
  ThreadDialog.Trigger = Trigger;
47018
47018
  ThreadDialog.Content = Content8;
47019
47019
  // src/components/threads/AudioThreadDialog/index.tsx
47020
- var import_react_compiler_runtime100 = require("react-compiler-runtime");
47021
- // src/components/threads/AudioThread/index.tsx
47022
47020
  var import_react_compiler_runtime99 = require("react-compiler-runtime");
47021
+ // src/components/threads/AudioThread/index.tsx
47022
+ var import_react_compiler_runtime98 = require("react-compiler-runtime");
47023
47023
  // src/components/threads/AudioThread/Root/index.tsx
47024
- var import_react_compiler_runtime91 = require("react-compiler-runtime");
47024
+ var import_react_compiler_runtime90 = require("react-compiler-runtime");
47025
47025
  var import_themes58 = require("@radix-ui/themes");
47026
47026
  // src/contexts/threads/AudioThreadContext/index.ts
47027
47027
  var import_react62 = require("react");
@@ -47034,9 +47034,9 @@ var useAudioThreadContext = function() {
47034
47034
  return (0, import_react63.useContext)(AudioThreadContext);
47035
47035
  };
47036
47036
  // src/components/audioRuntimes/TtsAudioRuntimeProvider.tsx
47037
- var import_react_compiler_runtime90 = require("react-compiler-runtime");
47038
- // src/hooks/audioRuntimes/useTtsAudioRuntime/index.ts
47039
47037
  var import_react_compiler_runtime89 = require("react-compiler-runtime");
47038
+ // src/hooks/audioRuntimes/useTtsAudioRuntime/index.ts
47039
+ var import_react_compiler_runtime88 = require("react-compiler-runtime");
47040
47040
  var import_react68 = require("react");
47041
47041
  // src/hooks/misc/usePermission/index.ts
47042
47042
  var import_react_compiler_runtime86 = require("react-compiler-runtime");
@@ -47368,9 +47368,7 @@ var useRecorder = function(_ref) {
47368
47368
  });
47369
47369
  };
47370
47370
  // src/hooks/audioThreads/useMessageAudio/index.ts
47371
- var import_react_compiler_runtime88 = require("react-compiler-runtime");
47372
47371
  var import_react67 = require("react");
47373
- var import_compromise = __toESM(require("compromise"), 1);
47374
47372
  var import_howler = require("howler");
47375
47373
  var import_react_use_audio_player2 = require("react-use-audio-player");
47376
47374
  // src/hooks/audioThreads/useMessageAudio/lib/input.ts
@@ -47438,210 +47436,104 @@ function _toPrimitive47(t, r) {
47438
47436
  }
47439
47437
  return ("string" === r ? String : Number)(t);
47440
47438
  }
47441
- var segment = function(input2) {
47442
- return (0, import_compromise.default)(input2).sentences().json().map(function(s) {
47443
- return s.text;
47444
- });
47439
+ var splitSentencesFast = function(text) {
47440
+ var t = text.replace(/\s+/g, " ").trim();
47441
+ if (!t) return [];
47442
+ var parts = t.split(RegExp("(?<=[.!?])\\s+(?=[^\\s])", "g"));
47443
+ return parts;
47445
47444
  };
47446
- var useMessageAudio = function(t0) {
47447
- var $ = (0, import_react_compiler_runtime88.c)(41);
47448
- var _onEnd = t0.onEnd, passedPlay = t0.play, t1 = t0.fullSentenceRegex;
47449
- var t2;
47450
- if ($[0] !== t1) {
47451
- t2 = t1 === void 0 ? /[\.?!]$/ : t1;
47452
- $[0] = t1;
47453
- $[1] = t2;
47454
- } else {
47455
- t2 = $[1];
47445
+ var getIncrementalSentences = function(prev, nextInput) {
47446
+ if (!prev) {
47447
+ return {
47448
+ input: nextInput,
47449
+ sentences: splitSentencesFast(nextInput)
47450
+ };
47451
+ }
47452
+ if (nextInput === prev.input) {
47453
+ return prev;
47454
+ }
47455
+ if (nextInput.startsWith(prev.input)) {
47456
+ var _prev$sentences;
47457
+ var prevLast = (_prev$sentences = prev.sentences[prev.sentences.length - 1]) !== null && _prev$sentences !== void 0 ? _prev$sentences : "";
47458
+ var baseLen = prev.input.length - prevLast.length;
47459
+ if (baseLen >= 0 && prev.input.slice(baseLen) === prevLast) {
47460
+ var tail = nextInput.slice(baseLen);
47461
+ var tailSegments = splitSentencesFast(tail);
47462
+ var merged = prev.sentences.length > 0 ? _to_consumable_array(prev.sentences.slice(0, -1)).concat(_to_consumable_array(tailSegments)) : tailSegments;
47463
+ return {
47464
+ input: nextInput,
47465
+ sentences: merged
47466
+ };
47467
+ }
47456
47468
  }
47457
- var fullSentenceRegex = t2;
47458
- var _ref = _sliced_to_array((0, import_react67.useState)(false), 2), isAudioPlayed = _ref[0], setIsAudioPlayed = _ref[1];
47469
+ return {
47470
+ input: nextInput,
47471
+ sentences: splitSentencesFast(nextInput)
47472
+ };
47473
+ };
47474
+ var useMessageAudio = function(_ref) {
47475
+ var _onEnd = _ref.onEnd, passedPlay = _ref.play, _ref_fullSentenceRegex = _ref.fullSentenceRegex, fullSentenceRegex = _ref_fullSentenceRegex === void 0 ? /[\.?!]$/ : _ref_fullSentenceRegex;
47476
+ var _$_ref = _sliced_to_array((0, import_react67.useState)(false), 2), isAudioPlayed = _$_ref[0], setIsAudioPlayed = _$_ref[1];
47459
47477
  var audioPlayer = (0, import_react_use_audio_player2.useAudioPlayer)();
47460
47478
  var nextAudioPlayer = (0, import_react_use_audio_player2.useAudioPlayer)();
47461
47479
  var superinterfaceContext = useSuperinterfaceContext();
47462
- var _ref1 = _sliced_to_array((0, import_react67.useState)(false), 2), isPlaying = _ref1[0], setIsPlaying = _ref1[1];
47463
- var t3;
47464
- if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
47465
- t3 = [];
47466
- $[2] = t3;
47467
- } else {
47468
- t3 = $[2];
47469
- }
47470
- var _ref2 = _sliced_to_array((0, import_react67.useState)(t3), 2), audioQueue = _ref2[0], setAudioQueue = _ref2[1];
47471
- var t4;
47472
- if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
47473
- t4 = [];
47474
- $[3] = t4;
47475
- } else {
47476
- t4 = $[3];
47477
- }
47478
- var audioQueueRef = (0, import_react67.useRef)(t4);
47479
- var t5;
47480
- var t6;
47481
- if ($[4] !== audioQueue) {
47482
- t5 = function() {
47483
- audioQueueRef.current = audioQueue;
47484
- };
47485
- t6 = [
47486
- audioQueue
47487
- ];
47488
- $[4] = audioQueue;
47489
- $[5] = t5;
47490
- $[6] = t6;
47491
- } else {
47492
- t5 = $[5];
47493
- t6 = $[6];
47494
- }
47495
- (0, import_react67.useEffect)(t5, t6);
47480
+ var _$_ref1 = _sliced_to_array((0, import_react67.useState)(false), 2), isPlaying = _$_ref1[0], setIsPlaying = _$_ref1[1];
47481
+ var _$_ref2 = _sliced_to_array((0, import_react67.useState)([]), 2), audioQueue = _$_ref2[0], setAudioQueue = _$_ref2[1];
47482
+ var audioQueueRef = (0, import_react67.useRef)([]);
47483
+ (0, import_react67.useEffect)(function() {
47484
+ audioQueueRef.current = audioQueue;
47485
+ }, [
47486
+ audioQueue
47487
+ ]);
47488
+ var pickLockRef = (0, import_react67.useRef)(false);
47496
47489
  var currentSentenceRef = (0, import_react67.useRef)(null);
47497
47490
  var messagesProps = useMessages();
47498
- var t7;
47499
- var t8;
47500
- if ($[7] !== messagesProps.messages) {
47501
- t7 = function() {
47502
- var assistants = messagesProps.messages.filter(_temp9);
47503
- setAudioQueue(function(prev) {
47504
- var prevById = new Map(prev.map(_temp24));
47505
- var next = [];
47506
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
47507
- try {
47508
- for(var _iterator = assistants[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
47509
- var m_0 = _step.value;
47510
- var _existing$nextIndex, _existing$stopped;
47511
- var inp = input({
47512
- message: m_0
47513
- });
47514
- if (inp == null) {
47515
- continue;
47516
- }
47517
- var sentences = segment(inp);
47518
- var existing = prevById.get(m_0.id);
47491
+ var segCacheRef = (0, import_react67.useRef)(/* @__PURE__ */ new Map());
47492
+ (0, import_react67.useEffect)(function() {
47493
+ var assistantsDesc = messagesProps.messages.filter(function(m) {
47494
+ return m.role === "assistant";
47495
+ });
47496
+ var assistantsAsc = _to_consumable_array(assistantsDesc).reverse();
47497
+ setAudioQueue(function(prev) {
47498
+ var prevById = new Map(prev.map(function(p) {
47499
+ return [
47500
+ p.id,
47501
+ p
47502
+ ];
47503
+ }));
47504
+ var changed = false;
47505
+ var next = [];
47506
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
47507
+ try {
47508
+ for(var _iterator = assistantsAsc[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
47509
+ var m_0 = _step.value;
47510
+ var _existing$nextIndex, _existing$stopped;
47511
+ var inp = input({
47512
+ message: m_0
47513
+ });
47514
+ if (inp == null) continue;
47515
+ var prevSeg = segCacheRef.current.get(m_0.id);
47516
+ var nextSeg = getIncrementalSentences(prevSeg, inp);
47517
+ if (!prevSeg || nextSeg.input !== prevSeg.input) {
47518
+ segCacheRef.current.set(m_0.id, nextSeg);
47519
+ }
47520
+ var existing = prevById.get(m_0.id);
47521
+ var sentences = nextSeg.sentences;
47522
+ var nextIndex = Math.min((_existing$nextIndex = existing === null || existing === void 0 ? void 0 : existing.nextIndex) !== null && _existing$nextIndex !== void 0 ? _existing$nextIndex : 0, sentences.length);
47523
+ var stopped = (_existing$stopped = existing === null || existing === void 0 ? void 0 : existing.stopped) !== null && _existing$stopped !== void 0 ? _existing$stopped : false;
47524
+ var reuseExisting = !!existing && existing.status === m_0.status && existing.sentences === sentences && // same array ref -> no change
47525
+ existing.nextIndex === nextIndex && existing.stopped === stopped;
47526
+ if (reuseExisting) {
47527
+ next.push(existing);
47528
+ } else {
47519
47529
  next.push({
47520
47530
  id: m_0.id,
47521
47531
  status: m_0.status,
47522
47532
  sentences: sentences,
47523
- nextIndex: Math.min((_existing$nextIndex = existing === null || existing === void 0 ? void 0 : existing.nextIndex) !== null && _existing$nextIndex !== void 0 ? _existing$nextIndex : 0, sentences.length),
47524
- stopped: (_existing$stopped = existing === null || existing === void 0 ? void 0 : existing.stopped) !== null && _existing$stopped !== void 0 ? _existing$stopped : false
47533
+ nextIndex: nextIndex,
47534
+ stopped: stopped
47525
47535
  });
47526
- }
47527
- } catch (err) {
47528
- _didIteratorError = true;
47529
- _iteratorError = err;
47530
- } finally{
47531
- try {
47532
- if (!_iteratorNormalCompletion && _iterator.return != null) {
47533
- _iterator.return();
47534
- }
47535
- } finally{
47536
- if (_didIteratorError) {
47537
- throw _iteratorError;
47538
- }
47539
- }
47540
- }
47541
- return next;
47542
- });
47543
- };
47544
- t8 = [
47545
- messagesProps.messages
47546
- ];
47547
- $[7] = messagesProps.messages;
47548
- $[8] = t7;
47549
- $[9] = t8;
47550
- } else {
47551
- t7 = $[8];
47552
- t8 = $[9];
47553
- }
47554
- (0, import_react67.useEffect)(t7, t8);
47555
- var t9;
47556
- if ($[10] !== audioPlayer || $[11] !== fullSentenceRegex || $[12] !== isAudioPlayed || $[13] !== nextAudioPlayer || $[14] !== superinterfaceContext) {
47557
- t9 = function(t102) {
47558
- var input2 = t102.input, onPlay = t102.onPlay, onStop = t102.onStop, onEnd_0 = t102.onEnd;
47559
- var searchParams = new URLSearchParams(_objectSpread47({
47560
- input: input2
47561
- }, superinterfaceContext.variables));
47562
- audioPlayer.load("".concat(superinterfaceContext.baseUrl, "/audio-runtimes/tts?").concat(searchParams), {
47563
- format: "mp3",
47564
- autoplay: isAudioPlayed,
47565
- html5: isHtmlAudioSupported,
47566
- onplay: onPlay,
47567
- onstop: onStop,
47568
- onload: function() {
47569
- var current = currentSentenceRef.current;
47570
- if (!current) {
47571
- return;
47572
- }
47573
- var msg = audioQueueRef.current.find(function(m_1) {
47574
- return m_1.id === current.messageId;
47575
- });
47576
- if (!msg) {
47577
- return;
47578
- }
47579
- var nextSentence = msg.sentences[msg.nextIndex];
47580
- if (!nextSentence) {
47581
- return;
47582
- }
47583
- if (!fullSentenceRegex.test(nextSentence)) {
47584
- return;
47585
- }
47586
- var nextSearchParams = new URLSearchParams(_objectSpread47({
47587
- input: nextSentence
47588
- }, superinterfaceContext.variables));
47589
- nextAudioPlayer.load("".concat(superinterfaceContext.baseUrl, "/audio-runtimes/tts?").concat(nextSearchParams), {
47590
- format: "mp3",
47591
- autoplay: false,
47592
- html5: isHtmlAudioSupported
47593
- });
47594
- },
47595
- onend: onEnd_0
47596
- });
47597
- };
47598
- $[10] = audioPlayer;
47599
- $[11] = fullSentenceRegex;
47600
- $[12] = isAudioPlayed;
47601
- $[13] = nextAudioPlayer;
47602
- $[14] = superinterfaceContext;
47603
- $[15] = t9;
47604
- } else {
47605
- t9 = $[15];
47606
- }
47607
- var defaultPlay = t9;
47608
- var t10;
47609
- t10 = passedPlay || defaultPlay;
47610
- var play = t10;
47611
- var t11;
47612
- var t12;
47613
- if ($[16] !== audioPlayer.playing || $[17] !== audioQueue || $[18] !== fullSentenceRegex || $[19] !== isPlaying || $[20] !== _onEnd || $[21] !== play) {
47614
- t11 = function() {
47615
- if (isPlaying) {
47616
- return;
47617
- }
47618
- if (audioPlayer.playing) {
47619
- return;
47620
- }
47621
- var candidate;
47622
- candidate = null;
47623
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
47624
- try {
47625
- for(var _iterator = audioQueue[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
47626
- var msg_0 = _step.value;
47627
- if (msg_0.stopped) {
47628
- continue;
47629
- }
47630
- var sentence = msg_0.sentences[msg_0.nextIndex];
47631
- if (!sentence) {
47632
- continue;
47633
- }
47634
- var isFull = isOptimistic({
47635
- id: msg_0.id
47636
- }) || msg_0.status !== "in_progress" || fullSentenceRegex.test(sentence);
47637
- if (isFull) {
47638
- candidate = {
47639
- messageId: msg_0.id,
47640
- sentence: sentence,
47641
- index: msg_0.nextIndex,
47642
- ownerStatus: msg_0.status
47643
- };
47644
- break;
47536
+ changed = true;
47645
47537
  }
47646
47538
  }
47647
47539
  } catch (err) {
@@ -47658,199 +47550,219 @@ var useMessageAudio = function(t0) {
47658
47550
  }
47659
47551
  }
47660
47552
  }
47661
- if (!candidate) {
47662
- return;
47553
+ if (next.length !== prev.length) {
47554
+ changed = true;
47555
+ } else {
47556
+ for(var i = 0; i < next.length; i++){
47557
+ if (next[i] !== prev[i]) {
47558
+ changed = true;
47559
+ break;
47560
+ }
47561
+ }
47663
47562
  }
47664
- setIsPlaying(true);
47665
- currentSentenceRef.current = {
47666
- messageId: candidate.messageId,
47667
- index: candidate.index
47668
- };
47669
- setAudioQueue(function(prev_0) {
47670
- return prev_0.map(function(m_2) {
47671
- return m_2.id === candidate.messageId ? _objectSpread47(_objectSpread47({}, m_2), {}, {
47672
- nextIndex: m_2.nextIndex + 1
47673
- }) : m_2;
47563
+ return changed ? next : prev;
47564
+ });
47565
+ }, [
47566
+ messagesProps.messages
47567
+ ]);
47568
+ var defaultPlay = (0, import_react67.useCallback)(function(_ref2) {
47569
+ var input2 = _ref2.input, onPlay = _ref2.onPlay, onStop = _ref2.onStop, onEnd_0 = _ref2.onEnd;
47570
+ var searchParams = new URLSearchParams(_objectSpread47({
47571
+ input: input2
47572
+ }, superinterfaceContext.variables));
47573
+ audioPlayer.load("".concat(superinterfaceContext.baseUrl, "/audio-runtimes/tts?").concat(searchParams), {
47574
+ format: "mp3",
47575
+ autoplay: isAudioPlayed,
47576
+ // first call false; then true for snappier chaining
47577
+ html5: isHtmlAudioSupported,
47578
+ onplay: onPlay,
47579
+ onstop: onStop,
47580
+ onload: function() {
47581
+ var current = currentSentenceRef.current;
47582
+ if (!current) return;
47583
+ var msg = audioQueueRef.current.find(function(m_1) {
47584
+ return m_1.id === current.messageId;
47674
47585
  });
47675
- });
47676
- play({
47677
- input: candidate.sentence,
47678
- onPlay: function() {
47679
- return setIsAudioPlayed(true);
47680
- },
47681
- onStop: function() {
47682
- setAudioQueue(function(prev_1) {
47683
- return prev_1.map(function(m_3) {
47684
- return m_3.id === candidate.messageId ? _objectSpread47(_objectSpread47({}, m_3), {}, {
47685
- stopped: true
47686
- }) : m_3;
47687
- });
47688
- });
47689
- setIsPlaying(false);
47690
- currentSentenceRef.current = null;
47691
- },
47692
- onEnd: function() {
47693
- setIsPlaying(false);
47694
- currentSentenceRef.current = null;
47695
- var hasPending = audioQueueRef.current.some(_temp32);
47696
- if (!hasPending) {
47697
- _onEnd();
47698
- }
47586
+ if (!msg) return;
47587
+ var nextSentence = msg.sentences[msg.nextIndex];
47588
+ if (!nextSentence) return;
47589
+ if (!fullSentenceRegex.test(nextSentence)) return;
47590
+ var nextSearchParams = new URLSearchParams(_objectSpread47({
47591
+ input: nextSentence
47592
+ }, superinterfaceContext.variables));
47593
+ nextAudioPlayer.load("".concat(superinterfaceContext.baseUrl, "/audio-runtimes/tts?").concat(nextSearchParams), {
47594
+ format: "mp3",
47595
+ autoplay: false,
47596
+ html5: isHtmlAudioSupported
47597
+ });
47598
+ },
47599
+ onend: onEnd_0
47600
+ });
47601
+ }, [
47602
+ superinterfaceContext,
47603
+ audioPlayer,
47604
+ nextAudioPlayer,
47605
+ isAudioPlayed,
47606
+ fullSentenceRegex
47607
+ ]);
47608
+ var play = (0, import_react67.useMemo)(function() {
47609
+ return passedPlay || defaultPlay;
47610
+ }, [
47611
+ passedPlay,
47612
+ defaultPlay
47613
+ ]);
47614
+ (0, import_react67.useEffect)(function() {
47615
+ if (isPlaying) return;
47616
+ if (audioPlayer.playing) return;
47617
+ if (pickLockRef.current) return;
47618
+ var candidate = null;
47619
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
47620
+ try {
47621
+ for(var _iterator = audioQueue[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
47622
+ var msg_0 = _step.value;
47623
+ if (msg_0.stopped) continue;
47624
+ var sentence = msg_0.sentences[msg_0.nextIndex];
47625
+ while(sentence && !/\S/.test(sentence)){
47626
+ msg_0.nextIndex++;
47627
+ sentence = msg_0.sentences[msg_0.nextIndex];
47628
+ }
47629
+ if (!sentence) continue;
47630
+ var isFull = isOptimistic({
47631
+ id: msg_0.id
47632
+ }) || msg_0.status !== "in_progress" || fullSentenceRegex.test(sentence);
47633
+ if (isFull) {
47634
+ candidate = {
47635
+ messageId: msg_0.id,
47636
+ sentence: sentence,
47637
+ index: msg_0.nextIndex,
47638
+ ownerStatus: msg_0.status
47639
+ };
47640
+ break;
47699
47641
  }
47700
- });
47701
- };
47702
- t12 = [
47703
- isPlaying,
47704
- audioPlayer.playing,
47705
- audioQueue,
47706
- play,
47707
- fullSentenceRegex,
47708
- _onEnd
47709
- ];
47710
- $[16] = audioPlayer.playing;
47711
- $[17] = audioQueue;
47712
- $[18] = fullSentenceRegex;
47713
- $[19] = isPlaying;
47714
- $[20] = _onEnd;
47715
- $[21] = play;
47716
- $[22] = t11;
47717
- $[23] = t12;
47718
- } else {
47719
- t11 = $[22];
47720
- t12 = $[23];
47721
- }
47722
- (0, import_react67.useEffect)(t11, t12);
47723
- var t13;
47724
- if ($[24] !== audioPlayer) {
47725
- t13 = [
47726
- audioPlayer
47727
- ];
47728
- $[24] = audioPlayer;
47729
- $[25] = t13;
47730
- } else {
47731
- t13 = $[25];
47732
- }
47733
- (0, import_react67.useEffect)(_temp42, t13);
47734
- var _ref3 = _sliced_to_array((0, import_react67.useState)(null), 2), audioEngine = _ref3[0], setAudioEngine = _ref3[1];
47735
- var isAudioEngineInited = (0, import_react67.useRef)(false);
47736
- var t14;
47737
- if ($[26] !== audioPlayer.playing) {
47738
- t14 = function() {
47739
- if (!audioPlayer.playing) {
47740
- return;
47741
47642
  }
47742
- if (isAudioEngineInited.current) {
47743
- return;
47643
+ } catch (err) {
47644
+ _didIteratorError = true;
47645
+ _iteratorError = err;
47646
+ } finally{
47647
+ try {
47648
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
47649
+ _iterator.return();
47650
+ }
47651
+ } finally{
47652
+ if (_didIteratorError) {
47653
+ throw _iteratorError;
47654
+ }
47744
47655
  }
47745
- isAudioEngineInited.current = true;
47746
- if (isHtmlAudioSupported) {
47747
- var audioContext = new AudioContext();
47748
- setAudioEngine({
47749
- source: audioContext.createMediaElementSource(import_howler.Howler._howls[0]._sounds[0]._node),
47750
- audioContext: audioContext
47656
+ }
47657
+ if (!candidate) return;
47658
+ pickLockRef.current = true;
47659
+ setIsPlaying(true);
47660
+ currentSentenceRef.current = {
47661
+ messageId: candidate.messageId,
47662
+ index: candidate.index
47663
+ };
47664
+ setAudioQueue(function(prev_0) {
47665
+ return prev_0.map(function(m_2) {
47666
+ return m_2.id === candidate.messageId ? _objectSpread47(_objectSpread47({}, m_2), {}, {
47667
+ nextIndex: m_2.nextIndex + 1
47668
+ }) : m_2;
47669
+ });
47670
+ });
47671
+ play({
47672
+ input: candidate.sentence,
47673
+ onPlay: function() {
47674
+ return setIsAudioPlayed(true);
47675
+ },
47676
+ onStop: function() {
47677
+ setAudioQueue(function(prev_1) {
47678
+ return prev_1.map(function(m_3) {
47679
+ return m_3.id === candidate.messageId ? _objectSpread47(_objectSpread47({}, m_3), {}, {
47680
+ stopped: true
47681
+ }) : m_3;
47682
+ });
47751
47683
  });
47752
- } else {
47753
- setAudioEngine({
47754
- source: import_howler.Howler.masterGain,
47755
- audioContext: import_howler.Howler.ctx
47684
+ setIsPlaying(false);
47685
+ currentSentenceRef.current = null;
47686
+ pickLockRef.current = false;
47687
+ },
47688
+ onEnd: function() {
47689
+ setIsPlaying(false);
47690
+ currentSentenceRef.current = null;
47691
+ pickLockRef.current = false;
47692
+ var hasPending = audioQueueRef.current.some(function(m_4) {
47693
+ if (m_4.stopped) return false;
47694
+ var hasMore = m_4.nextIndex < m_4.sentences.length;
47695
+ var streaming = m_4.status === "in_progress";
47696
+ return hasMore || streaming;
47756
47697
  });
47698
+ if (!hasPending) _onEnd();
47757
47699
  }
47758
- };
47759
- $[26] = audioPlayer.playing;
47760
- $[27] = t14;
47761
- } else {
47762
- t14 = $[27];
47763
- }
47764
- var t15;
47765
- if ($[28] !== audioPlayer) {
47766
- t15 = [
47767
- audioPlayer
47768
- ];
47769
- $[28] = audioPlayer;
47770
- $[29] = t15;
47771
- } else {
47772
- t15 = $[29];
47773
- }
47774
- (0, import_react67.useEffect)(t14, t15);
47775
- var t16;
47776
- bb0: {
47777
- if (!audioEngine) {
47778
- t16 = null;
47779
- break bb0;
47700
+ });
47701
+ }, [
47702
+ isPlaying,
47703
+ audioPlayer.playing,
47704
+ audioQueue,
47705
+ play,
47706
+ fullSentenceRegex,
47707
+ _onEnd
47708
+ ]);
47709
+ (0, import_react67.useEffect)(function() {
47710
+ if (isHtmlAudioSupported) {
47711
+ var _Howler$_howls$;
47712
+ if (!(import_howler.Howler !== null && import_howler.Howler !== void 0 && (_Howler$_howls$ = import_howler.Howler._howls[0]) !== null && _Howler$_howls$ !== void 0 && (_Howler$_howls$ = _Howler$_howls$._sounds[0]) !== null && _Howler$_howls$ !== void 0 && _Howler$_howls$._node)) return;
47713
+ import_howler.Howler._howls[0]._sounds[0]._node.crossOrigin = "anonymous";
47780
47714
  }
47781
- var analyser;
47782
- if ($[30] !== audioEngine.audioContext || $[31] !== audioEngine.source) {
47783
- analyser = audioEngine.audioContext.createAnalyser();
47784
- audioEngine.source.connect(audioEngine.audioContext.destination);
47785
- audioEngine.source.connect(analyser);
47786
- $[30] = audioEngine.audioContext;
47787
- $[31] = audioEngine.source;
47788
- $[32] = analyser;
47715
+ }, [
47716
+ audioPlayer
47717
+ ]);
47718
+ var _$_ref3 = _sliced_to_array((0, import_react67.useState)(null), 2), audioEngine = _$_ref3[0], setAudioEngine = _$_ref3[1];
47719
+ var isAudioEngineInited = (0, import_react67.useRef)(false);
47720
+ (0, import_react67.useEffect)(function() {
47721
+ if (!audioPlayer.playing) return;
47722
+ if (isAudioEngineInited.current) return;
47723
+ isAudioEngineInited.current = true;
47724
+ if (isHtmlAudioSupported) {
47725
+ var _Howler$_howls$2;
47726
+ var audioContext = new AudioContext();
47727
+ setAudioEngine({
47728
+ // @ts-ignore-next-line
47729
+ source: audioContext.createMediaElementSource(// @ts-ignore-next-line
47730
+ (_Howler$_howls$2 = import_howler.Howler._howls[0]) === null || _Howler$_howls$2 === void 0 || (_Howler$_howls$2 = _Howler$_howls$2._sounds[0]) === null || _Howler$_howls$2 === void 0 ? void 0 : _Howler$_howls$2._node),
47731
+ audioContext: audioContext
47732
+ });
47789
47733
  } else {
47790
- analyser = $[32];
47791
- }
47792
- t16 = analyser;
47793
- }
47794
- var visualizationAnalyser = t16;
47795
- var t17;
47796
- var t18;
47797
- if ($[33] !== audioQueue || $[34] !== isPlaying) {
47798
- t18 = isPlaying || audioQueue.some(_temp52);
47799
- $[33] = audioQueue;
47800
- $[34] = isPlaying;
47801
- $[35] = t18;
47802
- } else {
47803
- t18 = $[35];
47804
- }
47805
- t17 = t18;
47806
- var isPending = t17;
47807
- var t19;
47808
- if ($[36] !== audioPlayer || $[37] !== isAudioPlayed || $[38] !== isPending || $[39] !== visualizationAnalyser) {
47809
- t19 = _objectSpread47(_objectSpread47({
47810
- isPending: isPending,
47811
- isAudioPlayed: isAudioPlayed
47812
- }, audioPlayer), {}, {
47813
- visualizationAnalyser: visualizationAnalyser
47734
+ setAudioEngine({
47735
+ source: import_howler.Howler.masterGain,
47736
+ audioContext: import_howler.Howler.ctx
47737
+ });
47738
+ }
47739
+ }, [
47740
+ audioPlayer
47741
+ ]);
47742
+ var visualizationAnalyser = (0, import_react67.useMemo)(function() {
47743
+ if (!audioEngine) return null;
47744
+ var analyser = audioEngine.audioContext.createAnalyser();
47745
+ audioEngine.source.connect(audioEngine.audioContext.destination);
47746
+ audioEngine.source.connect(analyser);
47747
+ return analyser;
47748
+ }, [
47749
+ audioEngine
47750
+ ]);
47751
+ var isPending = (0, import_react67.useMemo)(function() {
47752
+ return isPlaying || audioQueue.some(function(m_5) {
47753
+ return !m_5.stopped && (m_5.nextIndex < m_5.sentences.length || m_5.status === "in_progress");
47814
47754
  });
47815
- $[36] = audioPlayer;
47816
- $[37] = isAudioPlayed;
47817
- $[38] = isPending;
47818
- $[39] = visualizationAnalyser;
47819
- $[40] = t19;
47820
- } else {
47821
- t19 = $[40];
47822
- }
47823
- return t19;
47755
+ }, [
47756
+ isPlaying,
47757
+ audioQueue
47758
+ ]);
47759
+ return _objectSpread47(_objectSpread47({
47760
+ isPending: isPending,
47761
+ isAudioPlayed: isAudioPlayed
47762
+ }, audioPlayer), {}, {
47763
+ visualizationAnalyser: visualizationAnalyser
47764
+ });
47824
47765
  };
47825
- function _temp9(m) {
47826
- return m.role === "assistant";
47827
- }
47828
- function _temp24(p) {
47829
- return [
47830
- p.id,
47831
- p
47832
- ];
47833
- }
47834
- function _temp32(m_4) {
47835
- if (m_4.stopped) {
47836
- return false;
47837
- }
47838
- var hasMore = m_4.nextIndex < m_4.sentences.length;
47839
- var streaming = m_4.status === "in_progress";
47840
- return hasMore || streaming;
47841
- }
47842
- function _temp42() {
47843
- if (isHtmlAudioSupported) {
47844
- var _Howler$_howls$;
47845
- if (!(import_howler.Howler !== null && import_howler.Howler !== void 0 && (_Howler$_howls$ = import_howler.Howler._howls[0]) !== null && _Howler$_howls$ !== void 0 && (_Howler$_howls$ = _Howler$_howls$._sounds[0]) !== null && _Howler$_howls$ !== void 0 && _Howler$_howls$._node)) {
47846
- return;
47847
- }
47848
- import_howler.Howler._howls[0]._sounds[0]._node.crossOrigin = "anonymous";
47849
- }
47850
- }
47851
- function _temp52(m_5) {
47852
- return !m_5.stopped && (m_5.nextIndex < m_5.sentences.length || m_5.status === "in_progress");
47853
- }
47854
47766
  // src/hooks/audioRuntimes/useTtsAudioRuntime/index.ts
47855
47767
  var import_react_query10 = require("@tanstack/react-query");
47856
47768
  // src/hooks/audioRuntimes/useTtsAudioRuntime/blobToData.ts
@@ -47888,7 +47800,7 @@ function _asyncToGenerator11(n) {
47888
47800
  };
47889
47801
  }
47890
47802
  var useTtsAudioRuntime = function(t0) {
47891
- var $ = (0, import_react_compiler_runtime89.c)(30);
47803
+ var $ = (0, import_react_compiler_runtime88.c)(30);
47892
47804
  var play = t0.play, passedOnEnd = t0.onEnd;
47893
47805
  var addToast = useToasts().addToast;
47894
47806
  var queryClient = (0, import_react_query10.useQueryClient)();
@@ -47917,7 +47829,7 @@ var useTtsAudioRuntime = function(t0) {
47917
47829
  if ($[1] !== createMessageProps) {
47918
47830
  t2 = {
47919
47831
  isStopOnSilence: true,
47920
- onStart: _temp10,
47832
+ onStart: _temp9,
47921
47833
  onStop: function() {
47922
47834
  var _onStop = _asyncToGenerator11(function(_event, chunks) {
47923
47835
  var blob, audioContent;
@@ -48058,23 +47970,23 @@ var useTtsAudioRuntime = function(t0) {
48058
47970
  t5 = t8;
48059
47971
  return t5;
48060
47972
  };
48061
- function _temp10() {
48062
- return _temp25.apply(this, arguments);
47973
+ function _temp9() {
47974
+ return _temp24.apply(this, arguments);
48063
47975
  }
48064
- function _temp25() {
48065
- _temp25 = _asyncToGenerator11(function() {
47976
+ function _temp24() {
47977
+ _temp24 = _asyncToGenerator11(function() {
48066
47978
  return _ts_generator(this, function(_state) {
48067
47979
  return [
48068
47980
  2
48069
47981
  ];
48070
47982
  });
48071
47983
  });
48072
- return _temp25.apply(this, arguments);
47984
+ return _temp24.apply(this, arguments);
48073
47985
  }
48074
47986
  // src/components/audioRuntimes/TtsAudioRuntimeProvider.tsx
48075
47987
  var import_jsx_runtime87 = require("react/jsx-runtime");
48076
47988
  var TtsAudioRuntimeProvider = function(t0) {
48077
- var $ = (0, import_react_compiler_runtime90.c)(8);
47989
+ var $ = (0, import_react_compiler_runtime89.c)(8);
48078
47990
  var children = t0.children, play = t0.play, onEnd = t0.onEnd;
48079
47991
  var t1;
48080
47992
  if ($[0] !== onEnd || $[1] !== play) {
@@ -48187,7 +48099,7 @@ function _objectWithoutPropertiesLoose5(r, e) {
48187
48099
  return t;
48188
48100
  }
48189
48101
  var Content9 = function(t0) {
48190
- var $ = (0, import_react_compiler_runtime91.c)(4);
48102
+ var $ = (0, import_react_compiler_runtime90.c)(4);
48191
48103
  var children = t0.children, className = t0.className, style = t0.style;
48192
48104
  var t1;
48193
48105
  if ($[0] !== children || $[1] !== className || $[2] !== style) {
@@ -48209,7 +48121,7 @@ var Content9 = function(t0) {
48209
48121
  return t1;
48210
48122
  };
48211
48123
  var AudioRuntimeProvider = function(t0) {
48212
- var $ = (0, import_react_compiler_runtime91.c)(4);
48124
+ var $ = (0, import_react_compiler_runtime90.c)(4);
48213
48125
  var children = t0.children, play = t0.play, onEnd = t0.onEnd;
48214
48126
  var audioThreadContext = useAudioThreadContext();
48215
48127
  if (audioThreadContext.audioRuntime) {
@@ -48232,7 +48144,7 @@ var AudioRuntimeProvider = function(t0) {
48232
48144
  return t1;
48233
48145
  };
48234
48146
  var Provider5 = function(t0) {
48235
- var $ = (0, import_react_compiler_runtime91.c)(9);
48147
+ var $ = (0, import_react_compiler_runtime90.c)(9);
48236
48148
  var children;
48237
48149
  var rest;
48238
48150
  if ($[0] !== t0) {
@@ -48272,7 +48184,7 @@ var Provider5 = function(t0) {
48272
48184
  return t2;
48273
48185
  };
48274
48186
  var Root16 = function(t0) {
48275
- var $ = (0, import_react_compiler_runtime91.c)(18);
48187
+ var $ = (0, import_react_compiler_runtime90.c)(18);
48276
48188
  var children;
48277
48189
  var className;
48278
48190
  var onEnd;
@@ -48344,7 +48256,7 @@ var Root16 = function(t0) {
48344
48256
  return t3;
48345
48257
  };
48346
48258
  // src/components/threads/AudioThread/Visualization/index.tsx
48347
- var import_react_compiler_runtime93 = require("react-compiler-runtime");
48259
+ var import_react_compiler_runtime92 = require("react-compiler-runtime");
48348
48260
  var import_react71 = require("react");
48349
48261
  var import_lodash9 = __toESM(require("lodash"), 1);
48350
48262
  var import_themes60 = require("@radix-ui/themes");
@@ -48413,10 +48325,10 @@ var BarsVisualizer = function(_ref) {
48413
48325
  });
48414
48326
  };
48415
48327
  // src/hooks/audioThreads/useStatus/index.ts
48416
- var import_react_compiler_runtime92 = require("react-compiler-runtime");
48328
+ var import_react_compiler_runtime91 = require("react-compiler-runtime");
48417
48329
  var import_react70 = require("react");
48418
48330
  var useStatus = function() {
48419
- var $ = (0, import_react_compiler_runtime92.c)(2);
48331
+ var $ = (0, import_react_compiler_runtime91.c)(2);
48420
48332
  var audioRuntime = useAudioThreadContext().audioRuntime;
48421
48333
  var t0;
48422
48334
  bb0: {
@@ -48576,7 +48488,7 @@ var Provider6 = function(_ref) {
48576
48488
  });
48577
48489
  };
48578
48490
  var Root17 = function(t0) {
48579
- var $ = (0, import_react_compiler_runtime93.c)(6);
48491
+ var $ = (0, import_react_compiler_runtime92.c)(6);
48580
48492
  var children;
48581
48493
  var rest;
48582
48494
  if ($[0] !== t0) {
@@ -48613,7 +48525,7 @@ var Root17 = function(t0) {
48613
48525
  return t1;
48614
48526
  };
48615
48527
  var BarsVisualizer2 = function(t0) {
48616
- var $ = (0, import_react_compiler_runtime93.c)(10);
48528
+ var $ = (0, import_react_compiler_runtime92.c)(10);
48617
48529
  var rest;
48618
48530
  var t1;
48619
48531
  var t2;
@@ -48657,7 +48569,7 @@ var BarsVisualizer2 = function(t0) {
48657
48569
  return t4;
48658
48570
  };
48659
48571
  var AssistantVisualizationRoot = function(t0) {
48660
- var $ = (0, import_react_compiler_runtime93.c)(17);
48572
+ var $ = (0, import_react_compiler_runtime92.c)(17);
48661
48573
  var children;
48662
48574
  var rest;
48663
48575
  var t1;
@@ -48730,7 +48642,7 @@ var AssistantVisualizationRoot = function(t0) {
48730
48642
  return t6;
48731
48643
  };
48732
48644
  var AssistantVisualization = function(props) {
48733
- var $ = (0, import_react_compiler_runtime93.c)(3);
48645
+ var $ = (0, import_react_compiler_runtime92.c)(3);
48734
48646
  var t0;
48735
48647
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
48736
48648
  t0 = /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(BarsVisualizer2, {});
@@ -48753,7 +48665,7 @@ var AssistantVisualization = function(props) {
48753
48665
  AssistantVisualization.Root = AssistantVisualizationRoot;
48754
48666
  AssistantVisualization.BarsVisualizer = BarsVisualizer2;
48755
48667
  var AssistantInfo = function(props) {
48756
- var $ = (0, import_react_compiler_runtime93.c)(6);
48668
+ var $ = (0, import_react_compiler_runtime92.c)(6);
48757
48669
  var assistantNameContext = (0, import_react71.useContext)(AssistantNameContext);
48758
48670
  var t0;
48759
48671
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
@@ -48793,7 +48705,7 @@ var AssistantInfo = function(props) {
48793
48705
  return t2;
48794
48706
  };
48795
48707
  var Visualization = function(props) {
48796
- var $ = (0, import_react_compiler_runtime93.c)(4);
48708
+ var $ = (0, import_react_compiler_runtime92.c)(4);
48797
48709
  var t0;
48798
48710
  var t1;
48799
48711
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
@@ -48825,9 +48737,9 @@ Visualization.Provider = Provider6;
48825
48737
  Visualization.AssistantVisualization = AssistantVisualization;
48826
48738
  Visualization.AssistantInfo = AssistantInfo;
48827
48739
  // src/components/threads/AudioThread/Status/index.tsx
48828
- var import_react_compiler_runtime95 = require("react-compiler-runtime");
48829
- // src/components/threads/AudioThread/Status/StatusMessages.tsx
48830
48740
  var import_react_compiler_runtime94 = require("react-compiler-runtime");
48741
+ // src/components/threads/AudioThread/Status/StatusMessages.tsx
48742
+ var import_react_compiler_runtime93 = require("react-compiler-runtime");
48831
48743
  var import_themes61 = require("@radix-ui/themes");
48832
48744
  var import_jsx_runtime91 = require("react/jsx-runtime");
48833
48745
  var html = function(_ref) {
@@ -48837,7 +48749,7 @@ var html = function(_ref) {
48837
48749
  }).join(""), "\n }");
48838
48750
  };
48839
48751
  var StatusMessages = function(t0) {
48840
- var $ = (0, import_react_compiler_runtime94.c)(9);
48752
+ var $ = (0, import_react_compiler_runtime93.c)(9);
48841
48753
  var texts = t0.texts, className = t0.className, style = t0.style;
48842
48754
  var t1;
48843
48755
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
@@ -48941,7 +48853,7 @@ function _toPrimitive50(t, r) {
48941
48853
  return ("string" === r ? String : Number)(t);
48942
48854
  }
48943
48855
  var Status = function(props) {
48944
- var $ = (0, import_react_compiler_runtime95.c)(12);
48856
+ var $ = (0, import_react_compiler_runtime94.c)(12);
48945
48857
  var status = useStatus().status;
48946
48858
  if (status === "recording") {
48947
48859
  var _t;
@@ -49038,10 +48950,10 @@ var Status = function(props) {
49038
48950
  return t1;
49039
48951
  };
49040
48952
  // src/components/threads/AudioThread/Form/index.tsx
49041
- var import_react_compiler_runtime98 = require("react-compiler-runtime");
48953
+ var import_react_compiler_runtime97 = require("react-compiler-runtime");
49042
48954
  var import_themes63 = require("@radix-ui/themes");
49043
48955
  // src/components/threads/AudioThread/Form/MicIcon.tsx
49044
- var import_react_compiler_runtime96 = require("react-compiler-runtime");
48956
+ var import_react_compiler_runtime95 = require("react-compiler-runtime");
49045
48957
  var import_jsx_runtime93 = require("react/jsx-runtime");
49046
48958
  function ownKeys51(e, r) {
49047
48959
  var t = Object.keys(e);
@@ -49087,7 +48999,7 @@ function _toPrimitive51(t, r) {
49087
48999
  return ("string" === r ? String : Number)(t);
49088
49000
  }
49089
49001
  var MicIcon = function(props) {
49090
- var $ = (0, import_react_compiler_runtime96.c)(3);
49002
+ var $ = (0, import_react_compiler_runtime95.c)(3);
49091
49003
  var t0;
49092
49004
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
49093
49005
  t0 = /* @__PURE__ */ (0, import_jsx_runtime93.jsx)("path", {
@@ -49119,12 +49031,12 @@ var MicIcon = function(props) {
49119
49031
  return t1;
49120
49032
  };
49121
49033
  // src/components/threads/AudioThread/Form/ActionButton/index.tsx
49122
- var import_react_compiler_runtime97 = require("react-compiler-runtime");
49034
+ var import_react_compiler_runtime96 = require("react-compiler-runtime");
49123
49035
  var import_themes62 = require("@radix-ui/themes");
49124
49036
  var import_react_icons17 = require("@radix-ui/react-icons");
49125
49037
  var import_jsx_runtime94 = require("react/jsx-runtime");
49126
49038
  var ActionButton = function() {
49127
- var $ = (0, import_react_compiler_runtime97.c)(27);
49039
+ var $ = (0, import_react_compiler_runtime96.c)(27);
49128
49040
  var status = useStatus().status;
49129
49041
  var audioThreadContext = useAudioThreadContext();
49130
49042
  var superinterfaceContext = useSuperinterfaceContext();
@@ -49362,7 +49274,7 @@ function _toPrimitive52(t, r) {
49362
49274
  return ("string" === r ? String : Number)(t);
49363
49275
  }
49364
49276
  var Form = function(props) {
49365
- var $ = (0, import_react_compiler_runtime98.c)(17);
49277
+ var $ = (0, import_react_compiler_runtime97.c)(17);
49366
49278
  var status = useStatus().status;
49367
49279
  var audioThreadContext = useAudioThreadContext();
49368
49280
  var t0 = status === "recording" ? "var(--accent-11)" : "var(--gray-11)";
@@ -49512,7 +49424,7 @@ function _toPrimitive53(t, r) {
49512
49424
  return ("string" === r ? String : Number)(t);
49513
49425
  }
49514
49426
  var AudioThread = function(props) {
49515
- var $ = (0, import_react_compiler_runtime99.c)(5);
49427
+ var $ = (0, import_react_compiler_runtime98.c)(5);
49516
49428
  var t0;
49517
49429
  var t1;
49518
49430
  var t2;
@@ -49594,7 +49506,7 @@ function _toPrimitive54(t, r) {
49594
49506
  return ("string" === r ? String : Number)(t);
49595
49507
  }
49596
49508
  var AudioThreadDialog = function(props) {
49597
- var $ = (0, import_react_compiler_runtime100.c)(4);
49509
+ var $ = (0, import_react_compiler_runtime99.c)(4);
49598
49510
  var t0;
49599
49511
  var t1;
49600
49512
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
@@ -50116,10 +50028,10 @@ var useWebrtcAudioRuntime = function() {
50116
50028
  ]);
50117
50029
  };
50118
50030
  // src/components/audioRuntimes/WebrtcAudioRuntimeProvider.tsx
50119
- var import_react_compiler_runtime101 = require("react-compiler-runtime");
50031
+ var import_react_compiler_runtime100 = require("react-compiler-runtime");
50120
50032
  var import_jsx_runtime98 = require("react/jsx-runtime");
50121
50033
  var WebrtcAudioRuntimeProvider = function(t0) {
50122
- var $ = (0, import_react_compiler_runtime101.c)(5);
50034
+ var $ = (0, import_react_compiler_runtime100.c)(5);
50123
50035
  var children = t0.children;
50124
50036
  var webrtcAudioRuntime = useWebrtcAudioRuntime().webrtcAudioRuntime;
50125
50037
  var t1;
@@ -50147,20 +50059,20 @@ var WebrtcAudioRuntimeProvider = function(t0) {
50147
50059
  return t2;
50148
50060
  };
50149
50061
  // src/components/gui/Gui/index.tsx
50150
- var import_react_compiler_runtime104 = require("react-compiler-runtime");
50062
+ var import_react_compiler_runtime103 = require("react-compiler-runtime");
50151
50063
  var import_react75 = require("react");
50152
50064
  var import_themes64 = require("@radix-ui/themes");
50153
50065
  // src/hooks/messages/useLatestAssistantMessage/index.ts
50154
- var import_react_compiler_runtime102 = require("react-compiler-runtime");
50066
+ var import_react_compiler_runtime101 = require("react-compiler-runtime");
50155
50067
  var import_react73 = require("react");
50156
50068
  var useLatestAssistantMessage = function() {
50157
- var $ = (0, import_react_compiler_runtime102.c)(4);
50069
+ var $ = (0, import_react_compiler_runtime101.c)(4);
50158
50070
  var _useMessages = useMessages(), messages2 = _useMessages.messages;
50159
50071
  var t0;
50160
50072
  var t1;
50161
50073
  if ($[0] !== messages2) {
50162
50074
  var _messages$find;
50163
- t1 = (_messages$find = messages2.find(_temp11)) !== null && _messages$find !== void 0 ? _messages$find : null;
50075
+ t1 = (_messages$find = messages2.find(_temp10)) !== null && _messages$find !== void 0 ? _messages$find : null;
50164
50076
  $[0] = messages2;
50165
50077
  $[1] = t1;
50166
50078
  } else {
@@ -50179,21 +50091,21 @@ var useLatestAssistantMessage = function() {
50179
50091
  t0 = t2;
50180
50092
  return t0;
50181
50093
  };
50182
- function _temp11(message) {
50094
+ function _temp10(message) {
50183
50095
  return message.role === "assistant";
50184
50096
  }
50185
50097
  // src/hooks/messages/useLatestAssistantMessageWithContent/index.ts
50186
- var import_react_compiler_runtime103 = require("react-compiler-runtime");
50098
+ var import_react_compiler_runtime102 = require("react-compiler-runtime");
50187
50099
  var import_radash18 = require("radash");
50188
50100
  var import_react74 = require("react");
50189
50101
  var useLatestAssistantMessageWithContent = function() {
50190
- var $ = (0, import_react_compiler_runtime103.c)(4);
50102
+ var $ = (0, import_react_compiler_runtime102.c)(4);
50191
50103
  var _useMessages = useMessages(), messages2 = _useMessages.messages;
50192
50104
  var t0;
50193
50105
  var t1;
50194
50106
  if ($[0] !== messages2) {
50195
50107
  var _messages$find;
50196
- t1 = (_messages$find = messages2.find(_temp26)) !== null && _messages$find !== void 0 ? _messages$find : null;
50108
+ t1 = (_messages$find = messages2.find(_temp25)) !== null && _messages$find !== void 0 ? _messages$find : null;
50197
50109
  $[0] = messages2;
50198
50110
  $[1] = t1;
50199
50111
  } else {
@@ -50212,16 +50124,16 @@ var useLatestAssistantMessageWithContent = function() {
50212
50124
  t0 = t2;
50213
50125
  return t0;
50214
50126
  };
50215
- function _temp12(content2) {
50127
+ function _temp11(content2) {
50216
50128
  return content2.type === "text" && !(0, import_radash18.isEmpty)(content2.text.value);
50217
50129
  }
50218
- function _temp26(message) {
50219
- return message.role === "assistant" && message.content.some(_temp12);
50130
+ function _temp25(message) {
50131
+ return message.role === "assistant" && message.content.some(_temp11);
50220
50132
  }
50221
50133
  // src/components/gui/Gui/index.tsx
50222
50134
  var import_jsx_runtime99 = require("react/jsx-runtime");
50223
50135
  var StartingToolCalls3 = function() {
50224
- var $ = (0, import_react_compiler_runtime104.c)(2);
50136
+ var $ = (0, import_react_compiler_runtime103.c)(2);
50225
50137
  var _useComponents = useComponents(), t0 = _useComponents.components;
50226
50138
  var StartingToolCalls4 = t0.StartingToolCalls;
50227
50139
  var t1;
@@ -50235,7 +50147,7 @@ var StartingToolCalls3 = function() {
50235
50147
  return t1;
50236
50148
  };
50237
50149
  var Content10 = function(t0) {
50238
- var $ = (0, import_react_compiler_runtime104.c)(5);
50150
+ var $ = (0, import_react_compiler_runtime103.c)(5);
50239
50151
  var latestRunStep = t0.latestRunStep;
50240
50152
  var t1;
50241
50153
  bb0: {
@@ -50289,14 +50201,14 @@ var Content10 = function(t0) {
50289
50201
  return t2;
50290
50202
  };
50291
50203
  var Progress2 = function(t0) {
50292
- var $ = (0, import_react_compiler_runtime104.c)(5);
50204
+ var $ = (0, import_react_compiler_runtime103.c)(5);
50293
50205
  var latestAssistantMessage = t0.latestAssistantMessage;
50294
50206
  var isMutatingMessage = useIsMutatingMessage();
50295
50207
  var t1;
50296
50208
  var t2;
50297
50209
  if ($[0] !== latestAssistantMessage.runSteps) {
50298
50210
  var _latestAssistantMessa;
50299
- t2 = (_latestAssistantMessa = latestAssistantMessage.runSteps.find(_temp13)) !== null && _latestAssistantMessa !== void 0 ? _latestAssistantMessa : null;
50211
+ t2 = (_latestAssistantMessa = latestAssistantMessage.runSteps.find(_temp12)) !== null && _latestAssistantMessa !== void 0 ? _latestAssistantMessa : null;
50300
50212
  $[0] = latestAssistantMessage.runSteps;
50301
50213
  $[1] = t2;
50302
50214
  } else {
@@ -50339,7 +50251,7 @@ var Progress2 = function(t0) {
50339
50251
  return t4;
50340
50252
  };
50341
50253
  var Gui = function() {
50342
- var $ = (0, import_react_compiler_runtime104.c)(8);
50254
+ var $ = (0, import_react_compiler_runtime103.c)(8);
50343
50255
  var latestAssistantMessage = useLatestAssistantMessage().latestAssistantMessage;
50344
50256
  var latestAssistantMessageWithContent = useLatestAssistantMessageWithContent().latestAssistantMessageWithContent;
50345
50257
  if (!latestAssistantMessage || !latestAssistantMessageWithContent) {
@@ -50401,11 +50313,11 @@ var Gui = function() {
50401
50313
  }
50402
50314
  return t2;
50403
50315
  };
50404
- function _temp13(rs) {
50316
+ function _temp12(rs) {
50405
50317
  return rs.status === "in_progress";
50406
50318
  }
50407
50319
  // src/components/markdown/MarkdownProvider/index.tsx
50408
- var import_react_compiler_runtime105 = require("react-compiler-runtime");
50320
+ var import_react_compiler_runtime104 = require("react-compiler-runtime");
50409
50321
  var import_react76 = require("react");
50410
50322
  var import_jsx_runtime100 = require("react/jsx-runtime");
50411
50323
  var _excluded7 = [
@@ -50430,7 +50342,7 @@ function _objectWithoutPropertiesLoose7(r, e) {
50430
50342
  return t;
50431
50343
  }
50432
50344
  var MarkdownProvider = function(t0) {
50433
- var $ = (0, import_react_compiler_runtime105.c)(9);
50345
+ var $ = (0, import_react_compiler_runtime104.c)(9);
50434
50346
  var children;
50435
50347
  var rest;
50436
50348
  if ($[0] !== t0) {
@@ -50473,18 +50385,18 @@ var MarkdownProvider = function(t0) {
50473
50385
  return t3;
50474
50386
  };
50475
50387
  // src/components/annotations/SourceAnnotation/index.tsx
50476
- var import_react_compiler_runtime108 = require("react-compiler-runtime");
50477
- // src/components/annotations/SourceAnnotation/FileCitation/index.tsx
50478
50388
  var import_react_compiler_runtime107 = require("react-compiler-runtime");
50389
+ // src/components/annotations/SourceAnnotation/FileCitation/index.tsx
50390
+ var import_react_compiler_runtime106 = require("react-compiler-runtime");
50479
50391
  var import_react77 = require("react");
50480
50392
  var import_react_icons18 = require("@radix-ui/react-icons");
50481
50393
  var import_themes66 = require("@radix-ui/themes");
50482
50394
  // src/components/annotations/SourceAnnotation/FileCitation/Content.tsx
50483
- var import_react_compiler_runtime106 = require("react-compiler-runtime");
50395
+ var import_react_compiler_runtime105 = require("react-compiler-runtime");
50484
50396
  var import_themes65 = require("@radix-ui/themes");
50485
50397
  var import_jsx_runtime101 = require("react/jsx-runtime");
50486
50398
  var Content11 = function(t0) {
50487
- var $ = (0, import_react_compiler_runtime106.c)(5);
50399
+ var $ = (0, import_react_compiler_runtime105.c)(5);
50488
50400
  var fileId = t0.fileId;
50489
50401
  var superinterfaceContext = useSuperinterfaceContext();
50490
50402
  var nextSearchParams = new URLSearchParams(superinterfaceContext.variables);
@@ -50550,7 +50462,7 @@ var Content11 = function(t0) {
50550
50462
  // src/components/annotations/SourceAnnotation/FileCitation/index.tsx
50551
50463
  var import_jsx_runtime102 = require("react/jsx-runtime");
50552
50464
  var FileCitation = function(t0) {
50553
- var $ = (0, import_react_compiler_runtime107.c)(18);
50465
+ var $ = (0, import_react_compiler_runtime106.c)(18);
50554
50466
  var annotation = t0.annotation;
50555
50467
  var _ref = _sliced_to_array((0, import_react77.useState)(null), 2), activeFileId = _ref[0], setActiveFileId = _ref[1];
50556
50468
  var t1;
@@ -50699,7 +50611,7 @@ function _objectWithoutPropertiesLoose8(r, e) {
50699
50611
  return t;
50700
50612
  }
50701
50613
  var SourceAnnotation = function(t0) {
50702
- var $ = (0, import_react_compiler_runtime108.c)(10);
50614
+ var $ = (0, import_react_compiler_runtime107.c)(10);
50703
50615
  var children;
50704
50616
  var rest;
50705
50617
  if ($[0] !== t0) {
@@ -50756,7 +50668,7 @@ var SourceAnnotation = function(t0) {
50756
50668
  return null;
50757
50669
  };
50758
50670
  // src/components/avatars/Avatar.tsx
50759
- var import_react_compiler_runtime111 = require("react-compiler-runtime");
50671
+ var import_react_compiler_runtime110 = require("react-compiler-runtime");
50760
50672
  // src/enums/index.ts
50761
50673
  var IconAvatarName = /* @__PURE__ */ function(IconAvatarName2) {
50762
50674
  IconAvatarName2["BACKPACK"] = "BACKPACK";
@@ -50781,7 +50693,7 @@ var AvatarType = /* @__PURE__ */ function(AvatarType2) {
50781
50693
  // src/components/avatars/Avatar.tsx
50782
50694
  var import_themes69 = require("@radix-ui/themes");
50783
50695
  // src/components/imageAvatars/ImageAvatar/index.tsx
50784
- var import_react_compiler_runtime109 = require("react-compiler-runtime");
50696
+ var import_react_compiler_runtime108 = require("react-compiler-runtime");
50785
50697
  var import_themes67 = require("@radix-ui/themes");
50786
50698
  // src/components/imageAvatars/ImageAvatar/lib/optimizedSrc/path.ts
50787
50699
  var width = function(_ref) {
@@ -50835,7 +50747,7 @@ var optimizedSrc = function(_ref) {
50835
50747
  // src/components/imageAvatars/ImageAvatar/index.tsx
50836
50748
  var import_jsx_runtime104 = require("react/jsx-runtime");
50837
50749
  var ImageAvatar = function(t0) {
50838
- var $ = (0, import_react_compiler_runtime109.c)(9);
50750
+ var $ = (0, import_react_compiler_runtime108.c)(9);
50839
50751
  var imageAvatar = t0.imageAvatar, size = t0.size, className = t0.className, style = t0.style;
50840
50752
  var superinterfaceContext = useSuperinterfaceContext();
50841
50753
  var t1;
@@ -50872,7 +50784,7 @@ var ImageAvatar = function(t0) {
50872
50784
  return t2;
50873
50785
  };
50874
50786
  // src/components/iconAvatars/IconAvatar.tsx
50875
- var import_react_compiler_runtime110 = require("react-compiler-runtime");
50787
+ var import_react_compiler_runtime109 = require("react-compiler-runtime");
50876
50788
  var import_react78 = require("react");
50877
50789
  var import_themes68 = require("@radix-ui/themes");
50878
50790
  // src/lib/iconAvatars/iconAvatarComponents.ts
@@ -50882,7 +50794,7 @@ var iconAvatarComponents = (_obj = {}, _define_property(_obj, IconAvatarName.BAC
50882
50794
  // src/components/iconAvatars/IconAvatar.tsx
50883
50795
  var import_jsx_runtime105 = require("react/jsx-runtime");
50884
50796
  var IconAvatar = function(t0) {
50885
- var $ = (0, import_react_compiler_runtime110.c)(7);
50797
+ var $ = (0, import_react_compiler_runtime109.c)(7);
50886
50798
  var iconAvatar = t0.iconAvatar, size = t0.size, className = t0.className, style = t0.style;
50887
50799
  var t1;
50888
50800
  t1 = iconAvatarComponents[iconAvatar.name];
@@ -50916,7 +50828,7 @@ var IconAvatar = function(t0) {
50916
50828
  // src/components/avatars/Avatar.tsx
50917
50829
  var import_jsx_runtime106 = require("react/jsx-runtime");
50918
50830
  var Avatar6 = function(t0) {
50919
- var $ = (0, import_react_compiler_runtime111.c)(14);
50831
+ var $ = (0, import_react_compiler_runtime110.c)(14);
50920
50832
  var avatar = t0.avatar, t1 = t0.size, className = t0.className, style = t0.style;
50921
50833
  var size = t1 === void 0 ? "1" : t1;
50922
50834
  if (avatar) {
@@ -50977,7 +50889,7 @@ var Avatar6 = function(t0) {
50977
50889
  return t2;
50978
50890
  };
50979
50891
  // src/components/components/ComponentsProvider.tsx
50980
- var import_react_compiler_runtime112 = require("react-compiler-runtime");
50892
+ var import_react_compiler_runtime111 = require("react-compiler-runtime");
50981
50893
  var import_react79 = require("react");
50982
50894
  var import_jsx_runtime107 = require("react/jsx-runtime");
50983
50895
  var _excluded9 = [
@@ -51002,7 +50914,7 @@ function _objectWithoutPropertiesLoose9(r, e) {
51002
50914
  return t;
51003
50915
  }
51004
50916
  var ComponentsProvider = function(t0) {
51005
- var $ = (0, import_react_compiler_runtime112.c)(9);
50917
+ var $ = (0, import_react_compiler_runtime111.c)(9);
51006
50918
  var children;
51007
50919
  var rest;
51008
50920
  if ($[0] !== t0) {
@@ -51045,11 +50957,11 @@ var ComponentsProvider = function(t0) {
51045
50957
  return t3;
51046
50958
  };
51047
50959
  // src/components/assistants/AssistantProvider/index.tsx
51048
- var import_react_compiler_runtime113 = require("react-compiler-runtime");
50960
+ var import_react_compiler_runtime112 = require("react-compiler-runtime");
51049
50961
  var import_jsx_runtime108 = require("react/jsx-runtime");
51050
50962
  var AssistantProvider = function(t0) {
51051
50963
  var _assistant$name;
51052
- var $ = (0, import_react_compiler_runtime113.c)(10);
50964
+ var $ = (0, import_react_compiler_runtime112.c)(10);
51053
50965
  var children = t0.children;
51054
50966
  var superinterfaceContext = useSuperinterfaceContext();
51055
50967
  var t1;