@superinterface/react 5.3.0-beta.3 → 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,215 +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
+ ]);
47496
47488
  var pickLockRef = (0, import_react67.useRef)(false);
47497
47489
  var currentSentenceRef = (0, import_react67.useRef)(null);
47498
47490
  var messagesProps = useMessages();
47499
- var t7;
47500
- var t8;
47501
- if ($[7] !== messagesProps.messages) {
47502
- t7 = function() {
47503
- var assistantsDesc = messagesProps.messages.filter(_temp9);
47504
- var assistantsAsc = _to_consumable_array(assistantsDesc).reverse();
47505
- setAudioQueue(function(prev) {
47506
- var prevById = new Map(prev.map(_temp24));
47507
- var next = [];
47508
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
47509
- try {
47510
- for(var _iterator = assistantsAsc[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
47511
- var m_0 = _step.value;
47512
- var _existing$nextIndex, _existing$stopped;
47513
- var inp = input({
47514
- message: m_0
47515
- });
47516
- if (inp == null) {
47517
- continue;
47518
- }
47519
- var sentences = segment(inp);
47520
- 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 {
47521
47529
  next.push({
47522
47530
  id: m_0.id,
47523
47531
  status: m_0.status,
47524
47532
  sentences: sentences,
47525
- nextIndex: Math.min((_existing$nextIndex = existing === null || existing === void 0 ? void 0 : existing.nextIndex) !== null && _existing$nextIndex !== void 0 ? _existing$nextIndex : 0, sentences.length),
47526
- 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
47527
47535
  });
47528
- }
47529
- } catch (err) {
47530
- _didIteratorError = true;
47531
- _iteratorError = err;
47532
- } finally{
47533
- try {
47534
- if (!_iteratorNormalCompletion && _iterator.return != null) {
47535
- _iterator.return();
47536
- }
47537
- } finally{
47538
- if (_didIteratorError) {
47539
- throw _iteratorError;
47540
- }
47541
- }
47542
- }
47543
- return next;
47544
- });
47545
- };
47546
- t8 = [
47547
- messagesProps.messages
47548
- ];
47549
- $[7] = messagesProps.messages;
47550
- $[8] = t7;
47551
- $[9] = t8;
47552
- } else {
47553
- t7 = $[8];
47554
- t8 = $[9];
47555
- }
47556
- (0, import_react67.useEffect)(t7, t8);
47557
- var t9;
47558
- if ($[10] !== audioPlayer || $[11] !== fullSentenceRegex || $[12] !== isAudioPlayed || $[13] !== nextAudioPlayer || $[14] !== superinterfaceContext) {
47559
- t9 = function(t102) {
47560
- var input2 = t102.input, onPlay = t102.onPlay, onStop = t102.onStop, onEnd_0 = t102.onEnd;
47561
- var searchParams = new URLSearchParams(_objectSpread47({
47562
- input: input2
47563
- }, superinterfaceContext.variables));
47564
- audioPlayer.load("".concat(superinterfaceContext.baseUrl, "/audio-runtimes/tts?").concat(searchParams), {
47565
- format: "mp3",
47566
- autoplay: isAudioPlayed,
47567
- html5: isHtmlAudioSupported,
47568
- onplay: onPlay,
47569
- onstop: onStop,
47570
- onload: function() {
47571
- var current = currentSentenceRef.current;
47572
- if (!current) {
47573
- return;
47574
- }
47575
- var msg = audioQueueRef.current.find(function(m_1) {
47576
- return m_1.id === current.messageId;
47577
- });
47578
- if (!msg) {
47579
- return;
47580
- }
47581
- var nextSentence = msg.sentences[msg.nextIndex];
47582
- if (!nextSentence) {
47583
- return;
47584
- }
47585
- if (!fullSentenceRegex.test(nextSentence)) {
47586
- return;
47587
- }
47588
- var nextSearchParams = new URLSearchParams(_objectSpread47({
47589
- input: nextSentence
47590
- }, superinterfaceContext.variables));
47591
- nextAudioPlayer.load("".concat(superinterfaceContext.baseUrl, "/audio-runtimes/tts?").concat(nextSearchParams), {
47592
- format: "mp3",
47593
- autoplay: false,
47594
- html5: isHtmlAudioSupported
47595
- });
47596
- },
47597
- onend: onEnd_0
47598
- });
47599
- };
47600
- $[10] = audioPlayer;
47601
- $[11] = fullSentenceRegex;
47602
- $[12] = isAudioPlayed;
47603
- $[13] = nextAudioPlayer;
47604
- $[14] = superinterfaceContext;
47605
- $[15] = t9;
47606
- } else {
47607
- t9 = $[15];
47608
- }
47609
- var defaultPlay = t9;
47610
- var t10;
47611
- t10 = passedPlay || defaultPlay;
47612
- var play = t10;
47613
- var t11;
47614
- var t12;
47615
- if ($[16] !== audioPlayer.playing || $[17] !== audioQueue || $[18] !== fullSentenceRegex || $[19] !== isPlaying || $[20] !== _onEnd || $[21] !== play) {
47616
- t11 = function() {
47617
- if (isPlaying) {
47618
- return;
47619
- }
47620
- if (audioPlayer.playing) {
47621
- return;
47622
- }
47623
- if (pickLockRef.current) {
47624
- return;
47625
- }
47626
- var candidate;
47627
- candidate = null;
47628
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
47629
- try {
47630
- for(var _iterator = audioQueue[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
47631
- var msg_0 = _step.value;
47632
- if (msg_0.stopped) {
47633
- continue;
47634
- }
47635
- var sentence = msg_0.sentences[msg_0.nextIndex];
47636
- if (!sentence) {
47637
- continue;
47638
- }
47639
- var isFull = isOptimistic({
47640
- id: msg_0.id
47641
- }) || msg_0.status !== "in_progress" || fullSentenceRegex.test(sentence);
47642
- if (isFull) {
47643
- candidate = {
47644
- messageId: msg_0.id,
47645
- sentence: sentence,
47646
- index: msg_0.nextIndex,
47647
- ownerStatus: msg_0.status
47648
- };
47649
- break;
47536
+ changed = true;
47650
47537
  }
47651
47538
  }
47652
47539
  } catch (err) {
@@ -47663,202 +47550,219 @@ var useMessageAudio = function(t0) {
47663
47550
  }
47664
47551
  }
47665
47552
  }
47666
- if (!candidate) {
47667
- 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
+ }
47668
47562
  }
47669
- pickLockRef.current = true;
47670
- setIsPlaying(true);
47671
- currentSentenceRef.current = {
47672
- messageId: candidate.messageId,
47673
- index: candidate.index
47674
- };
47675
- setAudioQueue(function(prev_0) {
47676
- return prev_0.map(function(m_2) {
47677
- return m_2.id === candidate.messageId ? _objectSpread47(_objectSpread47({}, m_2), {}, {
47678
- nextIndex: m_2.nextIndex + 1
47679
- }) : 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;
47680
47585
  });
47681
- });
47682
- play({
47683
- input: candidate.sentence,
47684
- onPlay: function() {
47685
- setIsAudioPlayed(true);
47686
- },
47687
- onStop: function() {
47688
- setAudioQueue(function(prev_1) {
47689
- return prev_1.map(function(m_3) {
47690
- return m_3.id === candidate.messageId ? _objectSpread47(_objectSpread47({}, m_3), {}, {
47691
- stopped: true
47692
- }) : m_3;
47693
- });
47694
- });
47695
- setIsPlaying(false);
47696
- currentSentenceRef.current = null;
47697
- pickLockRef.current = false;
47698
- },
47699
- onEnd: function() {
47700
- setIsPlaying(false);
47701
- currentSentenceRef.current = null;
47702
- pickLockRef.current = false;
47703
- var hasPending = audioQueueRef.current.some(_temp32);
47704
- if (!hasPending) {
47705
- _onEnd();
47706
- }
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;
47707
47641
  }
47708
- });
47709
- };
47710
- t12 = [
47711
- isPlaying,
47712
- audioPlayer.playing,
47713
- audioQueue,
47714
- play,
47715
- fullSentenceRegex,
47716
- _onEnd
47717
- ];
47718
- $[16] = audioPlayer.playing;
47719
- $[17] = audioQueue;
47720
- $[18] = fullSentenceRegex;
47721
- $[19] = isPlaying;
47722
- $[20] = _onEnd;
47723
- $[21] = play;
47724
- $[22] = t11;
47725
- $[23] = t12;
47726
- } else {
47727
- t11 = $[22];
47728
- t12 = $[23];
47729
- }
47730
- (0, import_react67.useEffect)(t11, t12);
47731
- var t13;
47732
- if ($[24] !== audioPlayer) {
47733
- t13 = [
47734
- audioPlayer
47735
- ];
47736
- $[24] = audioPlayer;
47737
- $[25] = t13;
47738
- } else {
47739
- t13 = $[25];
47740
- }
47741
- (0, import_react67.useEffect)(_temp42, t13);
47742
- var _ref3 = _sliced_to_array((0, import_react67.useState)(null), 2), audioEngine = _ref3[0], setAudioEngine = _ref3[1];
47743
- var isAudioEngineInited = (0, import_react67.useRef)(false);
47744
- var t14;
47745
- if ($[26] !== audioPlayer.playing) {
47746
- t14 = function() {
47747
- if (!audioPlayer.playing) {
47748
- return;
47749
47642
  }
47750
- if (isAudioEngineInited.current) {
47751
- 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
+ }
47752
47655
  }
47753
- isAudioEngineInited.current = true;
47754
- if (isHtmlAudioSupported) {
47755
- var audioContext = new AudioContext();
47756
- setAudioEngine({
47757
- source: audioContext.createMediaElementSource(import_howler.Howler._howls[0]._sounds[0]._node),
47758
- 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
+ });
47759
47683
  });
47760
- } else {
47761
- setAudioEngine({
47762
- source: import_howler.Howler.masterGain,
47763
- 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;
47764
47697
  });
47698
+ if (!hasPending) _onEnd();
47765
47699
  }
47766
- };
47767
- $[26] = audioPlayer.playing;
47768
- $[27] = t14;
47769
- } else {
47770
- t14 = $[27];
47771
- }
47772
- var t15;
47773
- if ($[28] !== audioPlayer) {
47774
- t15 = [
47775
- audioPlayer
47776
- ];
47777
- $[28] = audioPlayer;
47778
- $[29] = t15;
47779
- } else {
47780
- t15 = $[29];
47781
- }
47782
- (0, import_react67.useEffect)(t14, t15);
47783
- var t16;
47784
- bb0: {
47785
- if (!audioEngine) {
47786
- t16 = null;
47787
- 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";
47788
47714
  }
47789
- var analyser;
47790
- if ($[30] !== audioEngine.audioContext || $[31] !== audioEngine.source) {
47791
- analyser = audioEngine.audioContext.createAnalyser();
47792
- audioEngine.source.connect(audioEngine.audioContext.destination);
47793
- audioEngine.source.connect(analyser);
47794
- $[30] = audioEngine.audioContext;
47795
- $[31] = audioEngine.source;
47796
- $[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
+ });
47797
47733
  } else {
47798
- analyser = $[32];
47799
- }
47800
- t16 = analyser;
47801
- }
47802
- var visualizationAnalyser = t16;
47803
- var t17;
47804
- var t18;
47805
- if ($[33] !== audioQueue || $[34] !== isPlaying) {
47806
- t18 = isPlaying || audioQueue.some(_temp52);
47807
- $[33] = audioQueue;
47808
- $[34] = isPlaying;
47809
- $[35] = t18;
47810
- } else {
47811
- t18 = $[35];
47812
- }
47813
- t17 = t18;
47814
- var isPending = t17;
47815
- var t19;
47816
- if ($[36] !== audioPlayer || $[37] !== isAudioPlayed || $[38] !== isPending || $[39] !== visualizationAnalyser) {
47817
- t19 = _objectSpread47(_objectSpread47({
47818
- isPending: isPending,
47819
- isAudioPlayed: isAudioPlayed
47820
- }, audioPlayer), {}, {
47821
- 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");
47822
47754
  });
47823
- $[36] = audioPlayer;
47824
- $[37] = isAudioPlayed;
47825
- $[38] = isPending;
47826
- $[39] = visualizationAnalyser;
47827
- $[40] = t19;
47828
- } else {
47829
- t19 = $[40];
47830
- }
47831
- return t19;
47755
+ }, [
47756
+ isPlaying,
47757
+ audioQueue
47758
+ ]);
47759
+ return _objectSpread47(_objectSpread47({
47760
+ isPending: isPending,
47761
+ isAudioPlayed: isAudioPlayed
47762
+ }, audioPlayer), {}, {
47763
+ visualizationAnalyser: visualizationAnalyser
47764
+ });
47832
47765
  };
47833
- function _temp9(m) {
47834
- return m.role === "assistant";
47835
- }
47836
- function _temp24(p) {
47837
- return [
47838
- p.id,
47839
- p
47840
- ];
47841
- }
47842
- function _temp32(m_4) {
47843
- if (m_4.stopped) {
47844
- return false;
47845
- }
47846
- var hasMore = m_4.nextIndex < m_4.sentences.length;
47847
- var streaming = m_4.status === "in_progress";
47848
- return hasMore || streaming;
47849
- }
47850
- function _temp42() {
47851
- if (isHtmlAudioSupported) {
47852
- var _Howler$_howls$;
47853
- 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)) {
47854
- return;
47855
- }
47856
- import_howler.Howler._howls[0]._sounds[0]._node.crossOrigin = "anonymous";
47857
- }
47858
- }
47859
- function _temp52(m_5) {
47860
- return !m_5.stopped && (m_5.nextIndex < m_5.sentences.length || m_5.status === "in_progress");
47861
- }
47862
47766
  // src/hooks/audioRuntimes/useTtsAudioRuntime/index.ts
47863
47767
  var import_react_query10 = require("@tanstack/react-query");
47864
47768
  // src/hooks/audioRuntimes/useTtsAudioRuntime/blobToData.ts
@@ -47896,7 +47800,7 @@ function _asyncToGenerator11(n) {
47896
47800
  };
47897
47801
  }
47898
47802
  var useTtsAudioRuntime = function(t0) {
47899
- var $ = (0, import_react_compiler_runtime89.c)(30);
47803
+ var $ = (0, import_react_compiler_runtime88.c)(30);
47900
47804
  var play = t0.play, passedOnEnd = t0.onEnd;
47901
47805
  var addToast = useToasts().addToast;
47902
47806
  var queryClient = (0, import_react_query10.useQueryClient)();
@@ -47925,7 +47829,7 @@ var useTtsAudioRuntime = function(t0) {
47925
47829
  if ($[1] !== createMessageProps) {
47926
47830
  t2 = {
47927
47831
  isStopOnSilence: true,
47928
- onStart: _temp10,
47832
+ onStart: _temp9,
47929
47833
  onStop: function() {
47930
47834
  var _onStop = _asyncToGenerator11(function(_event, chunks) {
47931
47835
  var blob, audioContent;
@@ -48066,23 +47970,23 @@ var useTtsAudioRuntime = function(t0) {
48066
47970
  t5 = t8;
48067
47971
  return t5;
48068
47972
  };
48069
- function _temp10() {
48070
- return _temp25.apply(this, arguments);
47973
+ function _temp9() {
47974
+ return _temp24.apply(this, arguments);
48071
47975
  }
48072
- function _temp25() {
48073
- _temp25 = _asyncToGenerator11(function() {
47976
+ function _temp24() {
47977
+ _temp24 = _asyncToGenerator11(function() {
48074
47978
  return _ts_generator(this, function(_state) {
48075
47979
  return [
48076
47980
  2
48077
47981
  ];
48078
47982
  });
48079
47983
  });
48080
- return _temp25.apply(this, arguments);
47984
+ return _temp24.apply(this, arguments);
48081
47985
  }
48082
47986
  // src/components/audioRuntimes/TtsAudioRuntimeProvider.tsx
48083
47987
  var import_jsx_runtime87 = require("react/jsx-runtime");
48084
47988
  var TtsAudioRuntimeProvider = function(t0) {
48085
- var $ = (0, import_react_compiler_runtime90.c)(8);
47989
+ var $ = (0, import_react_compiler_runtime89.c)(8);
48086
47990
  var children = t0.children, play = t0.play, onEnd = t0.onEnd;
48087
47991
  var t1;
48088
47992
  if ($[0] !== onEnd || $[1] !== play) {
@@ -48195,7 +48099,7 @@ function _objectWithoutPropertiesLoose5(r, e) {
48195
48099
  return t;
48196
48100
  }
48197
48101
  var Content9 = function(t0) {
48198
- var $ = (0, import_react_compiler_runtime91.c)(4);
48102
+ var $ = (0, import_react_compiler_runtime90.c)(4);
48199
48103
  var children = t0.children, className = t0.className, style = t0.style;
48200
48104
  var t1;
48201
48105
  if ($[0] !== children || $[1] !== className || $[2] !== style) {
@@ -48217,7 +48121,7 @@ var Content9 = function(t0) {
48217
48121
  return t1;
48218
48122
  };
48219
48123
  var AudioRuntimeProvider = function(t0) {
48220
- var $ = (0, import_react_compiler_runtime91.c)(4);
48124
+ var $ = (0, import_react_compiler_runtime90.c)(4);
48221
48125
  var children = t0.children, play = t0.play, onEnd = t0.onEnd;
48222
48126
  var audioThreadContext = useAudioThreadContext();
48223
48127
  if (audioThreadContext.audioRuntime) {
@@ -48240,7 +48144,7 @@ var AudioRuntimeProvider = function(t0) {
48240
48144
  return t1;
48241
48145
  };
48242
48146
  var Provider5 = function(t0) {
48243
- var $ = (0, import_react_compiler_runtime91.c)(9);
48147
+ var $ = (0, import_react_compiler_runtime90.c)(9);
48244
48148
  var children;
48245
48149
  var rest;
48246
48150
  if ($[0] !== t0) {
@@ -48280,7 +48184,7 @@ var Provider5 = function(t0) {
48280
48184
  return t2;
48281
48185
  };
48282
48186
  var Root16 = function(t0) {
48283
- var $ = (0, import_react_compiler_runtime91.c)(18);
48187
+ var $ = (0, import_react_compiler_runtime90.c)(18);
48284
48188
  var children;
48285
48189
  var className;
48286
48190
  var onEnd;
@@ -48352,7 +48256,7 @@ var Root16 = function(t0) {
48352
48256
  return t3;
48353
48257
  };
48354
48258
  // src/components/threads/AudioThread/Visualization/index.tsx
48355
- var import_react_compiler_runtime93 = require("react-compiler-runtime");
48259
+ var import_react_compiler_runtime92 = require("react-compiler-runtime");
48356
48260
  var import_react71 = require("react");
48357
48261
  var import_lodash9 = __toESM(require("lodash"), 1);
48358
48262
  var import_themes60 = require("@radix-ui/themes");
@@ -48421,10 +48325,10 @@ var BarsVisualizer = function(_ref) {
48421
48325
  });
48422
48326
  };
48423
48327
  // src/hooks/audioThreads/useStatus/index.ts
48424
- var import_react_compiler_runtime92 = require("react-compiler-runtime");
48328
+ var import_react_compiler_runtime91 = require("react-compiler-runtime");
48425
48329
  var import_react70 = require("react");
48426
48330
  var useStatus = function() {
48427
- var $ = (0, import_react_compiler_runtime92.c)(2);
48331
+ var $ = (0, import_react_compiler_runtime91.c)(2);
48428
48332
  var audioRuntime = useAudioThreadContext().audioRuntime;
48429
48333
  var t0;
48430
48334
  bb0: {
@@ -48584,7 +48488,7 @@ var Provider6 = function(_ref) {
48584
48488
  });
48585
48489
  };
48586
48490
  var Root17 = function(t0) {
48587
- var $ = (0, import_react_compiler_runtime93.c)(6);
48491
+ var $ = (0, import_react_compiler_runtime92.c)(6);
48588
48492
  var children;
48589
48493
  var rest;
48590
48494
  if ($[0] !== t0) {
@@ -48621,7 +48525,7 @@ var Root17 = function(t0) {
48621
48525
  return t1;
48622
48526
  };
48623
48527
  var BarsVisualizer2 = function(t0) {
48624
- var $ = (0, import_react_compiler_runtime93.c)(10);
48528
+ var $ = (0, import_react_compiler_runtime92.c)(10);
48625
48529
  var rest;
48626
48530
  var t1;
48627
48531
  var t2;
@@ -48665,7 +48569,7 @@ var BarsVisualizer2 = function(t0) {
48665
48569
  return t4;
48666
48570
  };
48667
48571
  var AssistantVisualizationRoot = function(t0) {
48668
- var $ = (0, import_react_compiler_runtime93.c)(17);
48572
+ var $ = (0, import_react_compiler_runtime92.c)(17);
48669
48573
  var children;
48670
48574
  var rest;
48671
48575
  var t1;
@@ -48738,7 +48642,7 @@ var AssistantVisualizationRoot = function(t0) {
48738
48642
  return t6;
48739
48643
  };
48740
48644
  var AssistantVisualization = function(props) {
48741
- var $ = (0, import_react_compiler_runtime93.c)(3);
48645
+ var $ = (0, import_react_compiler_runtime92.c)(3);
48742
48646
  var t0;
48743
48647
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
48744
48648
  t0 = /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(BarsVisualizer2, {});
@@ -48761,7 +48665,7 @@ var AssistantVisualization = function(props) {
48761
48665
  AssistantVisualization.Root = AssistantVisualizationRoot;
48762
48666
  AssistantVisualization.BarsVisualizer = BarsVisualizer2;
48763
48667
  var AssistantInfo = function(props) {
48764
- var $ = (0, import_react_compiler_runtime93.c)(6);
48668
+ var $ = (0, import_react_compiler_runtime92.c)(6);
48765
48669
  var assistantNameContext = (0, import_react71.useContext)(AssistantNameContext);
48766
48670
  var t0;
48767
48671
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
@@ -48801,7 +48705,7 @@ var AssistantInfo = function(props) {
48801
48705
  return t2;
48802
48706
  };
48803
48707
  var Visualization = function(props) {
48804
- var $ = (0, import_react_compiler_runtime93.c)(4);
48708
+ var $ = (0, import_react_compiler_runtime92.c)(4);
48805
48709
  var t0;
48806
48710
  var t1;
48807
48711
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
@@ -48833,9 +48737,9 @@ Visualization.Provider = Provider6;
48833
48737
  Visualization.AssistantVisualization = AssistantVisualization;
48834
48738
  Visualization.AssistantInfo = AssistantInfo;
48835
48739
  // src/components/threads/AudioThread/Status/index.tsx
48836
- var import_react_compiler_runtime95 = require("react-compiler-runtime");
48837
- // src/components/threads/AudioThread/Status/StatusMessages.tsx
48838
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");
48839
48743
  var import_themes61 = require("@radix-ui/themes");
48840
48744
  var import_jsx_runtime91 = require("react/jsx-runtime");
48841
48745
  var html = function(_ref) {
@@ -48845,7 +48749,7 @@ var html = function(_ref) {
48845
48749
  }).join(""), "\n }");
48846
48750
  };
48847
48751
  var StatusMessages = function(t0) {
48848
- var $ = (0, import_react_compiler_runtime94.c)(9);
48752
+ var $ = (0, import_react_compiler_runtime93.c)(9);
48849
48753
  var texts = t0.texts, className = t0.className, style = t0.style;
48850
48754
  var t1;
48851
48755
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
@@ -48949,7 +48853,7 @@ function _toPrimitive50(t, r) {
48949
48853
  return ("string" === r ? String : Number)(t);
48950
48854
  }
48951
48855
  var Status = function(props) {
48952
- var $ = (0, import_react_compiler_runtime95.c)(12);
48856
+ var $ = (0, import_react_compiler_runtime94.c)(12);
48953
48857
  var status = useStatus().status;
48954
48858
  if (status === "recording") {
48955
48859
  var _t;
@@ -49046,10 +48950,10 @@ var Status = function(props) {
49046
48950
  return t1;
49047
48951
  };
49048
48952
  // src/components/threads/AudioThread/Form/index.tsx
49049
- var import_react_compiler_runtime98 = require("react-compiler-runtime");
48953
+ var import_react_compiler_runtime97 = require("react-compiler-runtime");
49050
48954
  var import_themes63 = require("@radix-ui/themes");
49051
48955
  // src/components/threads/AudioThread/Form/MicIcon.tsx
49052
- var import_react_compiler_runtime96 = require("react-compiler-runtime");
48956
+ var import_react_compiler_runtime95 = require("react-compiler-runtime");
49053
48957
  var import_jsx_runtime93 = require("react/jsx-runtime");
49054
48958
  function ownKeys51(e, r) {
49055
48959
  var t = Object.keys(e);
@@ -49095,7 +48999,7 @@ function _toPrimitive51(t, r) {
49095
48999
  return ("string" === r ? String : Number)(t);
49096
49000
  }
49097
49001
  var MicIcon = function(props) {
49098
- var $ = (0, import_react_compiler_runtime96.c)(3);
49002
+ var $ = (0, import_react_compiler_runtime95.c)(3);
49099
49003
  var t0;
49100
49004
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
49101
49005
  t0 = /* @__PURE__ */ (0, import_jsx_runtime93.jsx)("path", {
@@ -49127,12 +49031,12 @@ var MicIcon = function(props) {
49127
49031
  return t1;
49128
49032
  };
49129
49033
  // src/components/threads/AudioThread/Form/ActionButton/index.tsx
49130
- var import_react_compiler_runtime97 = require("react-compiler-runtime");
49034
+ var import_react_compiler_runtime96 = require("react-compiler-runtime");
49131
49035
  var import_themes62 = require("@radix-ui/themes");
49132
49036
  var import_react_icons17 = require("@radix-ui/react-icons");
49133
49037
  var import_jsx_runtime94 = require("react/jsx-runtime");
49134
49038
  var ActionButton = function() {
49135
- var $ = (0, import_react_compiler_runtime97.c)(27);
49039
+ var $ = (0, import_react_compiler_runtime96.c)(27);
49136
49040
  var status = useStatus().status;
49137
49041
  var audioThreadContext = useAudioThreadContext();
49138
49042
  var superinterfaceContext = useSuperinterfaceContext();
@@ -49370,7 +49274,7 @@ function _toPrimitive52(t, r) {
49370
49274
  return ("string" === r ? String : Number)(t);
49371
49275
  }
49372
49276
  var Form = function(props) {
49373
- var $ = (0, import_react_compiler_runtime98.c)(17);
49277
+ var $ = (0, import_react_compiler_runtime97.c)(17);
49374
49278
  var status = useStatus().status;
49375
49279
  var audioThreadContext = useAudioThreadContext();
49376
49280
  var t0 = status === "recording" ? "var(--accent-11)" : "var(--gray-11)";
@@ -49520,7 +49424,7 @@ function _toPrimitive53(t, r) {
49520
49424
  return ("string" === r ? String : Number)(t);
49521
49425
  }
49522
49426
  var AudioThread = function(props) {
49523
- var $ = (0, import_react_compiler_runtime99.c)(5);
49427
+ var $ = (0, import_react_compiler_runtime98.c)(5);
49524
49428
  var t0;
49525
49429
  var t1;
49526
49430
  var t2;
@@ -49602,7 +49506,7 @@ function _toPrimitive54(t, r) {
49602
49506
  return ("string" === r ? String : Number)(t);
49603
49507
  }
49604
49508
  var AudioThreadDialog = function(props) {
49605
- var $ = (0, import_react_compiler_runtime100.c)(4);
49509
+ var $ = (0, import_react_compiler_runtime99.c)(4);
49606
49510
  var t0;
49607
49511
  var t1;
49608
49512
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
@@ -50124,10 +50028,10 @@ var useWebrtcAudioRuntime = function() {
50124
50028
  ]);
50125
50029
  };
50126
50030
  // src/components/audioRuntimes/WebrtcAudioRuntimeProvider.tsx
50127
- var import_react_compiler_runtime101 = require("react-compiler-runtime");
50031
+ var import_react_compiler_runtime100 = require("react-compiler-runtime");
50128
50032
  var import_jsx_runtime98 = require("react/jsx-runtime");
50129
50033
  var WebrtcAudioRuntimeProvider = function(t0) {
50130
- var $ = (0, import_react_compiler_runtime101.c)(5);
50034
+ var $ = (0, import_react_compiler_runtime100.c)(5);
50131
50035
  var children = t0.children;
50132
50036
  var webrtcAudioRuntime = useWebrtcAudioRuntime().webrtcAudioRuntime;
50133
50037
  var t1;
@@ -50155,20 +50059,20 @@ var WebrtcAudioRuntimeProvider = function(t0) {
50155
50059
  return t2;
50156
50060
  };
50157
50061
  // src/components/gui/Gui/index.tsx
50158
- var import_react_compiler_runtime104 = require("react-compiler-runtime");
50062
+ var import_react_compiler_runtime103 = require("react-compiler-runtime");
50159
50063
  var import_react75 = require("react");
50160
50064
  var import_themes64 = require("@radix-ui/themes");
50161
50065
  // src/hooks/messages/useLatestAssistantMessage/index.ts
50162
- var import_react_compiler_runtime102 = require("react-compiler-runtime");
50066
+ var import_react_compiler_runtime101 = require("react-compiler-runtime");
50163
50067
  var import_react73 = require("react");
50164
50068
  var useLatestAssistantMessage = function() {
50165
- var $ = (0, import_react_compiler_runtime102.c)(4);
50069
+ var $ = (0, import_react_compiler_runtime101.c)(4);
50166
50070
  var _useMessages = useMessages(), messages2 = _useMessages.messages;
50167
50071
  var t0;
50168
50072
  var t1;
50169
50073
  if ($[0] !== messages2) {
50170
50074
  var _messages$find;
50171
- 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;
50172
50076
  $[0] = messages2;
50173
50077
  $[1] = t1;
50174
50078
  } else {
@@ -50187,21 +50091,21 @@ var useLatestAssistantMessage = function() {
50187
50091
  t0 = t2;
50188
50092
  return t0;
50189
50093
  };
50190
- function _temp11(message) {
50094
+ function _temp10(message) {
50191
50095
  return message.role === "assistant";
50192
50096
  }
50193
50097
  // src/hooks/messages/useLatestAssistantMessageWithContent/index.ts
50194
- var import_react_compiler_runtime103 = require("react-compiler-runtime");
50098
+ var import_react_compiler_runtime102 = require("react-compiler-runtime");
50195
50099
  var import_radash18 = require("radash");
50196
50100
  var import_react74 = require("react");
50197
50101
  var useLatestAssistantMessageWithContent = function() {
50198
- var $ = (0, import_react_compiler_runtime103.c)(4);
50102
+ var $ = (0, import_react_compiler_runtime102.c)(4);
50199
50103
  var _useMessages = useMessages(), messages2 = _useMessages.messages;
50200
50104
  var t0;
50201
50105
  var t1;
50202
50106
  if ($[0] !== messages2) {
50203
50107
  var _messages$find;
50204
- 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;
50205
50109
  $[0] = messages2;
50206
50110
  $[1] = t1;
50207
50111
  } else {
@@ -50220,16 +50124,16 @@ var useLatestAssistantMessageWithContent = function() {
50220
50124
  t0 = t2;
50221
50125
  return t0;
50222
50126
  };
50223
- function _temp12(content2) {
50127
+ function _temp11(content2) {
50224
50128
  return content2.type === "text" && !(0, import_radash18.isEmpty)(content2.text.value);
50225
50129
  }
50226
- function _temp26(message) {
50227
- return message.role === "assistant" && message.content.some(_temp12);
50130
+ function _temp25(message) {
50131
+ return message.role === "assistant" && message.content.some(_temp11);
50228
50132
  }
50229
50133
  // src/components/gui/Gui/index.tsx
50230
50134
  var import_jsx_runtime99 = require("react/jsx-runtime");
50231
50135
  var StartingToolCalls3 = function() {
50232
- var $ = (0, import_react_compiler_runtime104.c)(2);
50136
+ var $ = (0, import_react_compiler_runtime103.c)(2);
50233
50137
  var _useComponents = useComponents(), t0 = _useComponents.components;
50234
50138
  var StartingToolCalls4 = t0.StartingToolCalls;
50235
50139
  var t1;
@@ -50243,7 +50147,7 @@ var StartingToolCalls3 = function() {
50243
50147
  return t1;
50244
50148
  };
50245
50149
  var Content10 = function(t0) {
50246
- var $ = (0, import_react_compiler_runtime104.c)(5);
50150
+ var $ = (0, import_react_compiler_runtime103.c)(5);
50247
50151
  var latestRunStep = t0.latestRunStep;
50248
50152
  var t1;
50249
50153
  bb0: {
@@ -50297,14 +50201,14 @@ var Content10 = function(t0) {
50297
50201
  return t2;
50298
50202
  };
50299
50203
  var Progress2 = function(t0) {
50300
- var $ = (0, import_react_compiler_runtime104.c)(5);
50204
+ var $ = (0, import_react_compiler_runtime103.c)(5);
50301
50205
  var latestAssistantMessage = t0.latestAssistantMessage;
50302
50206
  var isMutatingMessage = useIsMutatingMessage();
50303
50207
  var t1;
50304
50208
  var t2;
50305
50209
  if ($[0] !== latestAssistantMessage.runSteps) {
50306
50210
  var _latestAssistantMessa;
50307
- 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;
50308
50212
  $[0] = latestAssistantMessage.runSteps;
50309
50213
  $[1] = t2;
50310
50214
  } else {
@@ -50347,7 +50251,7 @@ var Progress2 = function(t0) {
50347
50251
  return t4;
50348
50252
  };
50349
50253
  var Gui = function() {
50350
- var $ = (0, import_react_compiler_runtime104.c)(8);
50254
+ var $ = (0, import_react_compiler_runtime103.c)(8);
50351
50255
  var latestAssistantMessage = useLatestAssistantMessage().latestAssistantMessage;
50352
50256
  var latestAssistantMessageWithContent = useLatestAssistantMessageWithContent().latestAssistantMessageWithContent;
50353
50257
  if (!latestAssistantMessage || !latestAssistantMessageWithContent) {
@@ -50409,11 +50313,11 @@ var Gui = function() {
50409
50313
  }
50410
50314
  return t2;
50411
50315
  };
50412
- function _temp13(rs) {
50316
+ function _temp12(rs) {
50413
50317
  return rs.status === "in_progress";
50414
50318
  }
50415
50319
  // src/components/markdown/MarkdownProvider/index.tsx
50416
- var import_react_compiler_runtime105 = require("react-compiler-runtime");
50320
+ var import_react_compiler_runtime104 = require("react-compiler-runtime");
50417
50321
  var import_react76 = require("react");
50418
50322
  var import_jsx_runtime100 = require("react/jsx-runtime");
50419
50323
  var _excluded7 = [
@@ -50438,7 +50342,7 @@ function _objectWithoutPropertiesLoose7(r, e) {
50438
50342
  return t;
50439
50343
  }
50440
50344
  var MarkdownProvider = function(t0) {
50441
- var $ = (0, import_react_compiler_runtime105.c)(9);
50345
+ var $ = (0, import_react_compiler_runtime104.c)(9);
50442
50346
  var children;
50443
50347
  var rest;
50444
50348
  if ($[0] !== t0) {
@@ -50481,18 +50385,18 @@ var MarkdownProvider = function(t0) {
50481
50385
  return t3;
50482
50386
  };
50483
50387
  // src/components/annotations/SourceAnnotation/index.tsx
50484
- var import_react_compiler_runtime108 = require("react-compiler-runtime");
50485
- // src/components/annotations/SourceAnnotation/FileCitation/index.tsx
50486
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");
50487
50391
  var import_react77 = require("react");
50488
50392
  var import_react_icons18 = require("@radix-ui/react-icons");
50489
50393
  var import_themes66 = require("@radix-ui/themes");
50490
50394
  // src/components/annotations/SourceAnnotation/FileCitation/Content.tsx
50491
- var import_react_compiler_runtime106 = require("react-compiler-runtime");
50395
+ var import_react_compiler_runtime105 = require("react-compiler-runtime");
50492
50396
  var import_themes65 = require("@radix-ui/themes");
50493
50397
  var import_jsx_runtime101 = require("react/jsx-runtime");
50494
50398
  var Content11 = function(t0) {
50495
- var $ = (0, import_react_compiler_runtime106.c)(5);
50399
+ var $ = (0, import_react_compiler_runtime105.c)(5);
50496
50400
  var fileId = t0.fileId;
50497
50401
  var superinterfaceContext = useSuperinterfaceContext();
50498
50402
  var nextSearchParams = new URLSearchParams(superinterfaceContext.variables);
@@ -50558,7 +50462,7 @@ var Content11 = function(t0) {
50558
50462
  // src/components/annotations/SourceAnnotation/FileCitation/index.tsx
50559
50463
  var import_jsx_runtime102 = require("react/jsx-runtime");
50560
50464
  var FileCitation = function(t0) {
50561
- var $ = (0, import_react_compiler_runtime107.c)(18);
50465
+ var $ = (0, import_react_compiler_runtime106.c)(18);
50562
50466
  var annotation = t0.annotation;
50563
50467
  var _ref = _sliced_to_array((0, import_react77.useState)(null), 2), activeFileId = _ref[0], setActiveFileId = _ref[1];
50564
50468
  var t1;
@@ -50707,7 +50611,7 @@ function _objectWithoutPropertiesLoose8(r, e) {
50707
50611
  return t;
50708
50612
  }
50709
50613
  var SourceAnnotation = function(t0) {
50710
- var $ = (0, import_react_compiler_runtime108.c)(10);
50614
+ var $ = (0, import_react_compiler_runtime107.c)(10);
50711
50615
  var children;
50712
50616
  var rest;
50713
50617
  if ($[0] !== t0) {
@@ -50764,7 +50668,7 @@ var SourceAnnotation = function(t0) {
50764
50668
  return null;
50765
50669
  };
50766
50670
  // src/components/avatars/Avatar.tsx
50767
- var import_react_compiler_runtime111 = require("react-compiler-runtime");
50671
+ var import_react_compiler_runtime110 = require("react-compiler-runtime");
50768
50672
  // src/enums/index.ts
50769
50673
  var IconAvatarName = /* @__PURE__ */ function(IconAvatarName2) {
50770
50674
  IconAvatarName2["BACKPACK"] = "BACKPACK";
@@ -50789,7 +50693,7 @@ var AvatarType = /* @__PURE__ */ function(AvatarType2) {
50789
50693
  // src/components/avatars/Avatar.tsx
50790
50694
  var import_themes69 = require("@radix-ui/themes");
50791
50695
  // src/components/imageAvatars/ImageAvatar/index.tsx
50792
- var import_react_compiler_runtime109 = require("react-compiler-runtime");
50696
+ var import_react_compiler_runtime108 = require("react-compiler-runtime");
50793
50697
  var import_themes67 = require("@radix-ui/themes");
50794
50698
  // src/components/imageAvatars/ImageAvatar/lib/optimizedSrc/path.ts
50795
50699
  var width = function(_ref) {
@@ -50843,7 +50747,7 @@ var optimizedSrc = function(_ref) {
50843
50747
  // src/components/imageAvatars/ImageAvatar/index.tsx
50844
50748
  var import_jsx_runtime104 = require("react/jsx-runtime");
50845
50749
  var ImageAvatar = function(t0) {
50846
- var $ = (0, import_react_compiler_runtime109.c)(9);
50750
+ var $ = (0, import_react_compiler_runtime108.c)(9);
50847
50751
  var imageAvatar = t0.imageAvatar, size = t0.size, className = t0.className, style = t0.style;
50848
50752
  var superinterfaceContext = useSuperinterfaceContext();
50849
50753
  var t1;
@@ -50880,7 +50784,7 @@ var ImageAvatar = function(t0) {
50880
50784
  return t2;
50881
50785
  };
50882
50786
  // src/components/iconAvatars/IconAvatar.tsx
50883
- var import_react_compiler_runtime110 = require("react-compiler-runtime");
50787
+ var import_react_compiler_runtime109 = require("react-compiler-runtime");
50884
50788
  var import_react78 = require("react");
50885
50789
  var import_themes68 = require("@radix-ui/themes");
50886
50790
  // src/lib/iconAvatars/iconAvatarComponents.ts
@@ -50890,7 +50794,7 @@ var iconAvatarComponents = (_obj = {}, _define_property(_obj, IconAvatarName.BAC
50890
50794
  // src/components/iconAvatars/IconAvatar.tsx
50891
50795
  var import_jsx_runtime105 = require("react/jsx-runtime");
50892
50796
  var IconAvatar = function(t0) {
50893
- var $ = (0, import_react_compiler_runtime110.c)(7);
50797
+ var $ = (0, import_react_compiler_runtime109.c)(7);
50894
50798
  var iconAvatar = t0.iconAvatar, size = t0.size, className = t0.className, style = t0.style;
50895
50799
  var t1;
50896
50800
  t1 = iconAvatarComponents[iconAvatar.name];
@@ -50924,7 +50828,7 @@ var IconAvatar = function(t0) {
50924
50828
  // src/components/avatars/Avatar.tsx
50925
50829
  var import_jsx_runtime106 = require("react/jsx-runtime");
50926
50830
  var Avatar6 = function(t0) {
50927
- var $ = (0, import_react_compiler_runtime111.c)(14);
50831
+ var $ = (0, import_react_compiler_runtime110.c)(14);
50928
50832
  var avatar = t0.avatar, t1 = t0.size, className = t0.className, style = t0.style;
50929
50833
  var size = t1 === void 0 ? "1" : t1;
50930
50834
  if (avatar) {
@@ -50985,7 +50889,7 @@ var Avatar6 = function(t0) {
50985
50889
  return t2;
50986
50890
  };
50987
50891
  // src/components/components/ComponentsProvider.tsx
50988
- var import_react_compiler_runtime112 = require("react-compiler-runtime");
50892
+ var import_react_compiler_runtime111 = require("react-compiler-runtime");
50989
50893
  var import_react79 = require("react");
50990
50894
  var import_jsx_runtime107 = require("react/jsx-runtime");
50991
50895
  var _excluded9 = [
@@ -51010,7 +50914,7 @@ function _objectWithoutPropertiesLoose9(r, e) {
51010
50914
  return t;
51011
50915
  }
51012
50916
  var ComponentsProvider = function(t0) {
51013
- var $ = (0, import_react_compiler_runtime112.c)(9);
50917
+ var $ = (0, import_react_compiler_runtime111.c)(9);
51014
50918
  var children;
51015
50919
  var rest;
51016
50920
  if ($[0] !== t0) {
@@ -51053,11 +50957,11 @@ var ComponentsProvider = function(t0) {
51053
50957
  return t3;
51054
50958
  };
51055
50959
  // src/components/assistants/AssistantProvider/index.tsx
51056
- var import_react_compiler_runtime113 = require("react-compiler-runtime");
50960
+ var import_react_compiler_runtime112 = require("react-compiler-runtime");
51057
50961
  var import_jsx_runtime108 = require("react/jsx-runtime");
51058
50962
  var AssistantProvider = function(t0) {
51059
50963
  var _assistant$name;
51060
- var $ = (0, import_react_compiler_runtime113.c)(10);
50964
+ var $ = (0, import_react_compiler_runtime112.c)(10);
51061
50965
  var children = t0.children;
51062
50966
  var superinterfaceContext = useSuperinterfaceContext();
51063
50967
  var t1;