@superinterface/react 5.3.0-beta.1 → 5.3.0-beta.11

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
@@ -366,7 +366,7 @@ var require_lib = __commonJS({
366
366
  Object.defineProperty(exports2, "__esModule", {
367
367
  value: true
368
368
  });
369
- function _objectWithoutPropertiesLoose10(r, e) {
369
+ function _objectWithoutPropertiesLoose12(r, e) {
370
370
  if (null == r) return {};
371
371
  var t = {};
372
372
  for(var n in r)if (({}).hasOwnProperty.call(r, n)) {
@@ -733,7 +733,7 @@ var require_lib = __commonJS({
733
733
  PrimaryTopicNotAllowed: "Topic reference was used in a lexical context without topic binding.",
734
734
  PrimaryTopicRequiresSmartPipeline: 'Topic reference is used, but the pipelineOperator plugin was not passed a "proposal": "hack" or "smart" option.'
735
735
  });
736
- var _excluded10 = [
736
+ var _excluded12 = [
737
737
  "message"
738
738
  ];
739
739
  function defineHidden(obj, key2, value) {
@@ -808,7 +808,7 @@ var require_lib = __commonJS({
808
808
  }
809
809
  } : typeof template === "function" ? {
810
810
  message: template
811
- } : template, message = _ref.message, rest = _objectWithoutPropertiesLoose10(_ref, _excluded10);
811
+ } : template, message = _ref.message, rest = _objectWithoutPropertiesLoose12(_ref, _excluded12);
812
812
  var toMessage = typeof message === "string" ? function() {
813
813
  return message;
814
814
  } : message;
@@ -47369,7 +47369,6 @@ var useRecorder = function(_ref) {
47369
47369
  };
47370
47370
  // src/hooks/audioThreads/useMessageAudio/index.ts
47371
47371
  var import_react67 = require("react");
47372
- var import_compromise = __toESM(require("compromise"), 1);
47373
47372
  var import_howler = require("howler");
47374
47373
  var import_react_use_audio_player2 = require("react-use-audio-player");
47375
47374
  // src/hooks/audioThreads/useMessageAudio/lib/input.ts
@@ -47437,198 +47436,851 @@ function _toPrimitive47(t, r) {
47437
47436
  }
47438
47437
  return ("string" === r ? String : Number)(t);
47439
47438
  }
47440
- var getMessageSentences = function(_ref) {
47441
- var messageId = _ref.messageId, input2 = _ref.input;
47442
- var sentences = (0, import_compromise.default)(input2).sentences().json();
47443
- return sentences.map(function(sentence) {
47444
- return {
47445
- messageId: messageId,
47446
- sentence: sentence.text
47447
- };
47448
- });
47439
+ function asyncGeneratorStep11(n, t, e, r, o, a, c) {
47440
+ try {
47441
+ var i = n[a](c), u = i.value;
47442
+ } catch (n2) {
47443
+ return void e(n2);
47444
+ }
47445
+ i.done ? t(u) : Promise.resolve(u).then(r, o);
47446
+ }
47447
+ function _asyncToGenerator11(n) {
47448
+ return function() {
47449
+ var t = this, e = arguments;
47450
+ return new Promise(function(r, o) {
47451
+ var a = n.apply(t, e);
47452
+ function _next(n2) {
47453
+ asyncGeneratorStep11(a, r, o, _next, _throw, "next", n2);
47454
+ }
47455
+ function _throw(n2) {
47456
+ asyncGeneratorStep11(a, r, o, _next, _throw, "throw", n2);
47457
+ }
47458
+ _next(void 0);
47459
+ });
47460
+ };
47461
+ }
47462
+ var THROTTLE_MS = 80;
47463
+ var MAX_SEG_CACHE = 256;
47464
+ var KEEP_FINISHED_MESSAGES = 12;
47465
+ var FULL_SENTENCE_REGEX = /[\.?!]$/;
47466
+ var hasLetters = function(s) {
47467
+ for(var i = 0; i < s.length; i++){
47468
+ var ch = s.charAt(i);
47469
+ if (ch.toLowerCase() !== ch.toUpperCase()) return true;
47470
+ }
47471
+ return false;
47472
+ };
47473
+ var isSentencePunct = function(ch) {
47474
+ return ch === "." || ch === "!" || ch === "?" || ch === "\u3002" || ch === "\uFF01" || ch === "\uFF1F";
47449
47475
  };
47450
- var useMessageAudio = function(_ref2) {
47451
- var _latestMessageProps$l2;
47452
- var _onEnd = _ref2.onEnd, passedPlay = _ref2.play, _ref2_fullSentenceRegex = _ref2.fullSentenceRegex, fullSentenceRegex = _ref2_fullSentenceRegex === void 0 ? /[\.?!]$/ : _ref2_fullSentenceRegex;
47453
- var _ref = _sliced_to_array((0, import_react67.useState)(false), 2), isAudioPlayed = _ref[0], setIsAudioPlayed = _ref[1];
47454
- var _ref1 = _sliced_to_array((0, import_react67.useState)([]), 2), stoppedMessageIds = _ref1[0], setStoppedMessageIds = _ref1[1];
47455
- var _ref3 = _sliced_to_array((0, import_react67.useState)([]), 2), playedMessageSentences = _ref3[0], setPlayedMessageSentences = _ref3[1];
47476
+ var normalizeBoundaries = function(text) {
47477
+ var out = "";
47478
+ for(var i = 0; i < text.length; i++){
47479
+ var ch = text.charAt(i);
47480
+ out += ch;
47481
+ if (isSentencePunct(ch)) {
47482
+ var next = text.charAt(i + 1);
47483
+ if (next && next !== " " && hasLetters(next)) {
47484
+ out += " ";
47485
+ }
47486
+ }
47487
+ }
47488
+ return out;
47489
+ };
47490
+ var splitSentencesFast = function(raw) {
47491
+ var t = normalizeBoundaries(raw.replace(/\s+/g, " ").trim());
47492
+ if (!t) return [];
47493
+ var parts = t.split(RegExp("(?<=[.!?])\\s+(?=[^\\s])", "g"));
47494
+ var filtered = [];
47495
+ for(var i = 0; i < parts.length; i++){
47496
+ var p = parts[i].trim();
47497
+ if (p && hasLetters(p)) filtered.push(p);
47498
+ }
47499
+ return filtered;
47500
+ };
47501
+ var getIncrementalSegments = function(prev, nextInput, now) {
47502
+ if (!prev) return {
47503
+ input: nextInput,
47504
+ segments: splitSentencesFast(nextInput),
47505
+ touched: now
47506
+ };
47507
+ if (nextInput === prev.input) return {
47508
+ input: prev.input,
47509
+ segments: prev.segments,
47510
+ touched: now
47511
+ };
47512
+ if (nextInput.startsWith(prev.input)) {
47513
+ var prevSegments = prev.segments;
47514
+ var prevLast = prevSegments[prevSegments.length - 1] || "";
47515
+ var baseLen = prev.input.length - prevLast.length;
47516
+ if (baseLen >= 0 && prev.input.slice(baseLen) === prevLast) {
47517
+ var tail = nextInput.slice(baseLen);
47518
+ var tailSegments = splitSentencesFast(tail);
47519
+ var merged = prevSegments.length > 0 ? prevSegments.slice(0, -1).concat(tailSegments) : tailSegments;
47520
+ return {
47521
+ input: nextInput,
47522
+ segments: merged,
47523
+ touched: now
47524
+ };
47525
+ }
47526
+ }
47527
+ return {
47528
+ input: nextInput,
47529
+ segments: splitSentencesFast(nextInput),
47530
+ touched: now
47531
+ };
47532
+ };
47533
+ var segmentsEqual = function(a, b) {
47534
+ if (a === b) return true;
47535
+ if (a.length !== b.length) return false;
47536
+ for(var i = 0; i < a.length; i++){
47537
+ if (a[i] !== b[i]) return false;
47538
+ }
47539
+ return true;
47540
+ };
47541
+ var useMessageAudio = function(_ref) {
47542
+ var onEnd = _ref.onEnd, providedPlay = _ref.play, providedPlaySegments = _ref.playSegments, providedGetSegments = _ref.getSegments;
47543
+ var _$_ref = _sliced_to_array((0, import_react67.useState)(false), 2), isAudioPlayed = _$_ref[0], setIsAudioPlayed = _$_ref[1];
47544
+ var isAudioPlayedRef = (0, import_react67.useRef)(false);
47456
47545
  var audioPlayer = (0, import_react_use_audio_player2.useAudioPlayer)();
47457
47546
  var nextAudioPlayer = (0, import_react_use_audio_player2.useAudioPlayer)();
47458
47547
  var superinterfaceContext = useSuperinterfaceContext();
47459
- var _ref4 = _sliced_to_array((0, import_react67.useState)(false), 2), isPlaying = _ref4[0], setIsPlaying = _ref4[1];
47460
- var isLastSentencePlayedRef = (0, import_react67.useRef)(false);
47461
- var latestMessageProps = useLatestMessage();
47462
- var messagesProps = useMessages();
47548
+ var _$_ref1 = _sliced_to_array((0, import_react67.useState)(false), 2), isPlaying = _$_ref1[0], setIsPlaying = _$_ref1[1];
47549
+ var _$_ref2 = _sliced_to_array((0, import_react67.useState)([]), 2), audioQueue = _$_ref2[0], setAudioQueue = _$_ref2[1];
47550
+ var audioQueueRef = (0, import_react67.useRef)([]);
47463
47551
  (0, import_react67.useEffect)(function() {
47464
- if (!isPlaying) return;
47465
- isLastSentencePlayedRef.current = false;
47552
+ audioQueueRef.current = audioQueue;
47466
47553
  }, [
47467
- isPlaying
47554
+ audioQueue
47468
47555
  ]);
47469
- var unplayedMessageSentences = (0, import_react67.useMemo)(function() {
47470
- var playableMessages = _to_consumable_array(messagesProps.messages).reverse().filter(function(message) {
47471
- if (message.role !== "assistant") return false;
47472
- if (stoppedMessageIds.includes(message.id)) return false;
47473
- return true;
47556
+ var pickLockRef = (0, import_react67.useRef)(false);
47557
+ var activeSegmentsRef = (0, import_react67.useRef)(0);
47558
+ var currentSegmentRef = (0, import_react67.useRef)(null);
47559
+ var onEndPendingRef = (0, import_react67.useRef)(false);
47560
+ var messagesProps = useMessages();
47561
+ var messagesByIdRef = (0, import_react67.useRef)(/* @__PURE__ */ new Map());
47562
+ var segCacheRef = (0, import_react67.useRef)(/* @__PURE__ */ new Map());
47563
+ var mirrorTimerRef = (0, import_react67.useRef)(null);
47564
+ var pendingMirrorRef = (0, import_react67.useRef)(false);
47565
+ var markAudioPlayed = (0, import_react67.useCallback)(function() {
47566
+ if (!isAudioPlayedRef.current) {
47567
+ isAudioPlayedRef.current = true;
47568
+ setIsAudioPlayed(true);
47569
+ }
47570
+ }, []);
47571
+ var segmentToText = (0, import_react67.useCallback)(function(segment) {
47572
+ if (typeof segment === "string") return segment;
47573
+ if (segment && (typeof segment === "undefined" ? "undefined" : _type_of(segment)) === "object" && "text" in segment) {
47574
+ var value = segment.text;
47575
+ if (typeof value === "string") return value;
47576
+ }
47577
+ if (segment == null) return void 0;
47578
+ var stringified = String(segment);
47579
+ return stringified.length > 0 ? stringified : void 0;
47580
+ }, []);
47581
+ var checkForCompletion = (0, import_react67.useCallback)(function() {
47582
+ if (activeSegmentsRef.current > 0) return;
47583
+ var hasPending = audioQueueRef.current.some(function(m) {
47584
+ return !m.stopped && (m.nextIndex < m.segments.length || m.status === "in_progress");
47474
47585
  });
47475
- var messageInputs = playableMessages.map(function(message_0) {
47476
- return {
47477
- message: message_0,
47478
- input: input({
47479
- message: message_0
47480
- })
47586
+ if (hasPending) {
47587
+ onEndPendingRef.current = true;
47588
+ return;
47589
+ }
47590
+ if (!onEndPendingRef.current) return;
47591
+ onEndPendingRef.current = false;
47592
+ onEnd();
47593
+ }, [
47594
+ onEnd
47595
+ ]);
47596
+ (0, import_react67.useEffect)(function() {
47597
+ if (mirrorTimerRef.current != null) {
47598
+ pendingMirrorRef.current = true;
47599
+ return;
47600
+ }
47601
+ var run = /* @__PURE__ */ function() {
47602
+ var _ref2 = _asyncToGenerator11(function() {
47603
+ var assistantsDesc, assistantsAsc, nowTs, lastNIds, prevQueue, prevById, prevUnfinishedIds, streamingIds, includeIds, segCache, nextQueue, changed, touch, i, _existing$nextIndex, _existing$stopped, m_6, rawInput, prevEntry, nextEntry, playableSegments, customSegments, safeSegments, base, fullSegments, readyCount, last3, readySegments, existing, nextIndex, stopped, reuse, unfinished, finished, prunedFinished, combined, i_0, idsInQueue, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, id_3, _iteratorNormalCompletion1, _didIteratorError1, _iteratorError1, _iterator1, _step1, id_4, entries, toRemove, i_1;
47604
+ return _ts_generator(this, function(_state) {
47605
+ switch(_state.label){
47606
+ case 0:
47607
+ assistantsDesc = messagesProps.messages.filter(function(m_0) {
47608
+ return m_0.role === "assistant";
47609
+ });
47610
+ assistantsAsc = assistantsDesc.slice().reverse();
47611
+ nowTs = typeof performance !== "undefined" && performance.now ? performance.now() : Date.now();
47612
+ lastNIds = new Set(assistantsAsc.slice(Math.max(0, assistantsAsc.length - KEEP_FINISHED_MESSAGES)).map(function(m_1) {
47613
+ return String(m_1.id);
47614
+ }));
47615
+ prevQueue = audioQueueRef.current;
47616
+ prevById = new Map(prevQueue.map(function(p) {
47617
+ return [
47618
+ p.id,
47619
+ p
47620
+ ];
47621
+ }));
47622
+ prevUnfinishedIds = new Set(prevQueue.filter(function(m_2) {
47623
+ return !m_2.stopped && (m_2.status === "in_progress" || m_2.nextIndex < m_2.segments.length);
47624
+ }).map(function(m_3) {
47625
+ return m_3.id;
47626
+ }));
47627
+ streamingIds = new Set(assistantsAsc.filter(function(m_4) {
47628
+ return m_4.status === "in_progress";
47629
+ }).map(function(m_5) {
47630
+ return String(m_5.id);
47631
+ }));
47632
+ includeIds = /* @__PURE__ */ new Set();
47633
+ lastNIds.forEach(function(id) {
47634
+ return includeIds.add(id);
47635
+ });
47636
+ prevUnfinishedIds.forEach(function(id_0) {
47637
+ return includeIds.add(id_0);
47638
+ });
47639
+ streamingIds.forEach(function(id_1) {
47640
+ return includeIds.add(id_1);
47641
+ });
47642
+ segCache = segCacheRef.current;
47643
+ nextQueue = [];
47644
+ changed = false;
47645
+ touch = function(id_2, entry) {
47646
+ segCache.set(id_2, {
47647
+ input: entry.input,
47648
+ segments: entry.segments,
47649
+ touched: nowTs
47650
+ });
47651
+ };
47652
+ i = 0;
47653
+ _state.label = 1;
47654
+ case 1:
47655
+ if (!(i < assistantsAsc.length)) return [
47656
+ 3,
47657
+ 6
47658
+ ];
47659
+ m_6 = assistantsAsc[i];
47660
+ if (!includeIds.has(String(m_6.id))) return [
47661
+ 3,
47662
+ 5
47663
+ ];
47664
+ rawInput = input({
47665
+ message: m_6
47666
+ });
47667
+ if (rawInput == null) {
47668
+ segCache.delete(m_6.id);
47669
+ messagesByIdRef.current.delete(m_6.id);
47670
+ return [
47671
+ 3,
47672
+ 5
47673
+ ];
47674
+ }
47675
+ messagesByIdRef.current.set(m_6.id, m_6);
47676
+ prevEntry = segCache.get(m_6.id);
47677
+ nextEntry = void 0;
47678
+ playableSegments = void 0;
47679
+ if (!providedGetSegments) return [
47680
+ 3,
47681
+ 3
47682
+ ];
47683
+ return [
47684
+ 4,
47685
+ Promise.resolve(providedGetSegments({
47686
+ message: m_6,
47687
+ rawInput: rawInput
47688
+ }))
47689
+ ];
47690
+ case 2:
47691
+ customSegments = _state.sent();
47692
+ safeSegments = Array.isArray(customSegments) ? customSegments : [];
47693
+ nextEntry = {
47694
+ input: rawInput,
47695
+ segments: safeSegments,
47696
+ touched: nowTs
47697
+ };
47698
+ playableSegments = safeSegments;
47699
+ return [
47700
+ 3,
47701
+ 4
47702
+ ];
47703
+ case 3:
47704
+ base = getIncrementalSegments(prevEntry, rawInput, nowTs);
47705
+ nextEntry = {
47706
+ input: base.input,
47707
+ segments: base.segments,
47708
+ touched: nowTs
47709
+ };
47710
+ fullSegments = base.segments;
47711
+ readyCount = fullSegments.length;
47712
+ if (readyCount > 0 && !isOptimistic({
47713
+ id: m_6.id
47714
+ }) && m_6.status === "in_progress") {
47715
+ last3 = fullSegments[fullSegments.length - 1];
47716
+ if (last3 && !FULL_SENTENCE_REGEX.test(last3)) readyCount -= 1;
47717
+ }
47718
+ readySegments = fullSegments.slice(0, Math.max(0, readyCount));
47719
+ playableSegments = readyCount === fullSegments.length ? fullSegments : readySegments;
47720
+ _state.label = 4;
47721
+ case 4:
47722
+ touch(m_6.id, nextEntry);
47723
+ existing = prevById.get(m_6.id);
47724
+ nextIndex = Math.min((_existing$nextIndex = existing === null || existing === void 0 ? void 0 : existing.nextIndex) !== null && _existing$nextIndex !== void 0 ? _existing$nextIndex : 0, playableSegments.length);
47725
+ stopped = (_existing$stopped = existing === null || existing === void 0 ? void 0 : existing.stopped) !== null && _existing$stopped !== void 0 ? _existing$stopped : false;
47726
+ reuse = !!existing && existing.status === m_6.status && existing.rawInput === rawInput && existing.nextIndex === nextIndex && existing.stopped === stopped && segmentsEqual(existing.segments, playableSegments);
47727
+ if (reuse) {
47728
+ nextQueue.push(existing);
47729
+ } else {
47730
+ nextQueue.push({
47731
+ id: m_6.id,
47732
+ status: m_6.status,
47733
+ segments: playableSegments,
47734
+ nextIndex: nextIndex,
47735
+ stopped: stopped,
47736
+ rawInput: rawInput
47737
+ });
47738
+ changed = true;
47739
+ }
47740
+ _state.label = 5;
47741
+ case 5:
47742
+ i++;
47743
+ return [
47744
+ 3,
47745
+ 1
47746
+ ];
47747
+ case 6:
47748
+ unfinished = nextQueue.filter(function(m_7) {
47749
+ return !m_7.stopped && (m_7.status === "in_progress" || m_7.nextIndex < m_7.segments.length);
47750
+ });
47751
+ finished = nextQueue.filter(function(m_8) {
47752
+ return !(!m_8.stopped && (m_8.status === "in_progress" || m_8.nextIndex < m_8.segments.length));
47753
+ });
47754
+ prunedFinished = finished.length > KEEP_FINISHED_MESSAGES ? finished.slice(finished.length - KEEP_FINISHED_MESSAGES) : finished;
47755
+ combined = _to_consumable_array(unfinished).concat(_to_consumable_array(prunedFinished));
47756
+ if (combined.some(function(m_9) {
47757
+ return !m_9.stopped && (m_9.nextIndex < m_9.segments.length || m_9.status === "in_progress");
47758
+ })) {
47759
+ onEndPendingRef.current = true;
47760
+ }
47761
+ if (!changed) {
47762
+ if (combined.length !== prevQueue.length) {
47763
+ changed = true;
47764
+ } else {
47765
+ for(i_0 = 0; i_0 < combined.length; i_0++){
47766
+ if (combined[i_0] !== prevQueue[i_0]) {
47767
+ changed = true;
47768
+ break;
47769
+ }
47770
+ }
47771
+ }
47772
+ }
47773
+ idsInQueue = new Set(combined.map(function(m_10) {
47774
+ return m_10.id;
47775
+ }));
47776
+ _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
47777
+ try {
47778
+ for(_iterator = Array.from(segCache.keys())[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
47779
+ id_3 = _step.value;
47780
+ if (!idsInQueue.has(id_3)) segCache.delete(id_3);
47781
+ }
47782
+ } catch (err) {
47783
+ _didIteratorError = true;
47784
+ _iteratorError = err;
47785
+ } finally{
47786
+ try {
47787
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
47788
+ _iterator.return();
47789
+ }
47790
+ } finally{
47791
+ if (_didIteratorError) {
47792
+ throw _iteratorError;
47793
+ }
47794
+ }
47795
+ }
47796
+ _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
47797
+ try {
47798
+ for(_iterator1 = Array.from(messagesByIdRef.current.keys())[Symbol.iterator](); !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
47799
+ id_4 = _step1.value;
47800
+ if (!idsInQueue.has(id_4)) messagesByIdRef.current.delete(id_4);
47801
+ }
47802
+ } catch (err) {
47803
+ _didIteratorError1 = true;
47804
+ _iteratorError1 = err;
47805
+ } finally{
47806
+ try {
47807
+ if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
47808
+ _iterator1.return();
47809
+ }
47810
+ } finally{
47811
+ if (_didIteratorError1) {
47812
+ throw _iteratorError1;
47813
+ }
47814
+ }
47815
+ }
47816
+ if (changed) setAudioQueue(combined);
47817
+ if (segCache.size > MAX_SEG_CACHE) {
47818
+ entries = Array.from(segCache.entries());
47819
+ entries.sort(function(a, b) {
47820
+ return a[1].touched - b[1].touched;
47821
+ });
47822
+ toRemove = segCache.size - MAX_SEG_CACHE;
47823
+ for(i_1 = 0; i_1 < toRemove; i_1++)segCache.delete(entries[i_1][0]);
47824
+ }
47825
+ return [
47826
+ 2
47827
+ ];
47828
+ }
47829
+ });
47830
+ });
47831
+ return function run2() {
47832
+ return _ref2.apply(this, arguments);
47481
47833
  };
47482
- }).filter(function(_ref3) {
47483
- var input2 = _ref3.input;
47484
- return input2 !== null;
47834
+ }();
47835
+ var schedule = function() {
47836
+ mirrorTimerRef.current = window.setTimeout(/* @__PURE__ */ _asyncToGenerator11(function() {
47837
+ return _ts_generator(this, function(_state) {
47838
+ switch(_state.label){
47839
+ case 0:
47840
+ mirrorTimerRef.current = null;
47841
+ _state.label = 1;
47842
+ case 1:
47843
+ _state.trys.push([
47844
+ 1,
47845
+ ,
47846
+ 3,
47847
+ 4
47848
+ ]);
47849
+ return [
47850
+ 4,
47851
+ run()
47852
+ ];
47853
+ case 2:
47854
+ _state.sent();
47855
+ return [
47856
+ 3,
47857
+ 4
47858
+ ];
47859
+ case 3:
47860
+ if (pendingMirrorRef.current) {
47861
+ pendingMirrorRef.current = false;
47862
+ schedule();
47863
+ }
47864
+ return [
47865
+ 7
47866
+ ];
47867
+ case 4:
47868
+ return [
47869
+ 2
47870
+ ];
47871
+ }
47872
+ });
47873
+ }), THROTTLE_MS);
47874
+ };
47875
+ schedule();
47876
+ return function() {
47877
+ if (mirrorTimerRef.current != null) {
47878
+ clearTimeout(mirrorTimerRef.current);
47879
+ mirrorTimerRef.current = null;
47880
+ }
47881
+ pendingMirrorRef.current = false;
47882
+ };
47883
+ }, [
47884
+ messagesProps.messages,
47885
+ providedGetSegments
47886
+ ]);
47887
+ var defaultPlay = (0, import_react67.useCallback)(/* @__PURE__ */ function() {
47888
+ var _ref5 = _asyncToGenerator11(function(_ref4) {
47889
+ var input2, onPlay, onStop, onEnd_0, searchParams;
47890
+ return _ts_generator(this, function(_state) {
47891
+ switch(_state.label){
47892
+ case 0:
47893
+ input2 = _ref4.input, onPlay = _ref4.onPlay, onStop = _ref4.onStop, onEnd_0 = _ref4.onEnd;
47894
+ searchParams = new URLSearchParams(_objectSpread47({
47895
+ input: input2
47896
+ }, superinterfaceContext.variables));
47897
+ return [
47898
+ 4,
47899
+ new Promise(function(resolve) {
47900
+ var settled = false;
47901
+ var settle = function(cb) {
47902
+ if (settled) return;
47903
+ settled = true;
47904
+ cb();
47905
+ resolve();
47906
+ };
47907
+ audioPlayer.load("".concat(superinterfaceContext.baseUrl, "/audio-runtimes/tts?").concat(searchParams), {
47908
+ format: "mp3",
47909
+ autoplay: isAudioPlayedRef.current,
47910
+ html5: isHtmlAudioSupported,
47911
+ onplay: function() {
47912
+ markAudioPlayed();
47913
+ onPlay();
47914
+ },
47915
+ onstop: function() {
47916
+ settle(onStop);
47917
+ },
47918
+ onend: function() {
47919
+ settle(onEnd_0);
47920
+ },
47921
+ onload: function() {
47922
+ var current = currentSegmentRef.current;
47923
+ if (!current) return;
47924
+ var owner = audioQueueRef.current.find(function(m_11) {
47925
+ return m_11.id === current.messageId;
47926
+ });
47927
+ if (!owner) return;
47928
+ var nextSegment = owner.segments[current.nextIndex];
47929
+ if (!nextSegment) return;
47930
+ var nextText = segmentToText(nextSegment);
47931
+ if (!nextText) return;
47932
+ var nextSearchParams = new URLSearchParams(_objectSpread47({
47933
+ input: nextText
47934
+ }, superinterfaceContext.variables));
47935
+ nextAudioPlayer.load("".concat(superinterfaceContext.baseUrl, "/audio-runtimes/tts?").concat(nextSearchParams), {
47936
+ format: "mp3",
47937
+ autoplay: false,
47938
+ html5: isHtmlAudioSupported
47939
+ });
47940
+ }
47941
+ });
47942
+ })
47943
+ ];
47944
+ case 1:
47945
+ _state.sent();
47946
+ return [
47947
+ 2
47948
+ ];
47949
+ }
47950
+ });
47951
+ });
47952
+ return function(_x) {
47953
+ return _ref5.apply(this, arguments);
47954
+ };
47955
+ }(), [
47956
+ audioPlayer,
47957
+ nextAudioPlayer,
47958
+ superinterfaceContext,
47959
+ segmentToText
47960
+ ]);
47961
+ var playInternal = (0, import_react67.useCallback)(/* @__PURE__ */ function() {
47962
+ var _ref6 = _asyncToGenerator11(function(segment_0, handlers2) {
47963
+ var text, args;
47964
+ return _ts_generator(this, function(_state) {
47965
+ switch(_state.label){
47966
+ case 0:
47967
+ text = segmentToText(segment_0);
47968
+ if (!text) {
47969
+ handlers2.onEnd();
47970
+ return [
47971
+ 2
47972
+ ];
47973
+ }
47974
+ args = {
47975
+ input: text,
47976
+ onPlay: function() {
47977
+ markAudioPlayed();
47978
+ handlers2.onPlay();
47979
+ },
47980
+ onStop: handlers2.onStop,
47981
+ onEnd: handlers2.onEnd
47982
+ };
47983
+ if (!providedPlay) return [
47984
+ 3,
47985
+ 2
47986
+ ];
47987
+ return [
47988
+ 4,
47989
+ Promise.resolve(providedPlay(args))
47990
+ ];
47991
+ case 1:
47992
+ _state.sent();
47993
+ return [
47994
+ 2
47995
+ ];
47996
+ case 2:
47997
+ return [
47998
+ 4,
47999
+ defaultPlay(args)
48000
+ ];
48001
+ case 3:
48002
+ _state.sent();
48003
+ return [
48004
+ 2
48005
+ ];
48006
+ }
48007
+ });
47485
48008
  });
47486
- var messageSentences = messageInputs.flatMap(function(_ref4) {
47487
- var message_1 = _ref4.message, input_0 = _ref4.input;
47488
- return getMessageSentences({
47489
- messageId: message_1.id,
47490
- input: input_0
48009
+ return function(_x2, _x3) {
48010
+ return _ref6.apply(this, arguments);
48011
+ };
48012
+ }(), [
48013
+ segmentToText,
48014
+ providedPlay,
48015
+ defaultPlay,
48016
+ markAudioPlayed
48017
+ ]);
48018
+ var defaultPlaySegments = (0, import_react67.useCallback)(/* @__PURE__ */ function() {
48019
+ var _ref8 = _asyncToGenerator11(function(_ref7) {
48020
+ var segments, message, play, i_2, current_0;
48021
+ return _ts_generator(this, function(_state) {
48022
+ switch(_state.label){
48023
+ case 0:
48024
+ segments = _ref7.segments, message = _ref7.message, play = _ref7.play;
48025
+ i_2 = 0;
48026
+ _state.label = 1;
48027
+ case 1:
48028
+ if (!(i_2 < segments.length)) return [
48029
+ 3,
48030
+ 4
48031
+ ];
48032
+ return [
48033
+ 4,
48034
+ play(segments[i_2])
48035
+ ];
48036
+ case 2:
48037
+ _state.sent();
48038
+ current_0 = audioQueueRef.current.find(function(m_12) {
48039
+ return m_12.id === message.id;
48040
+ });
48041
+ if (!current_0 || current_0.stopped) return [
48042
+ 3,
48043
+ 4
48044
+ ];
48045
+ _state.label = 3;
48046
+ case 3:
48047
+ i_2++;
48048
+ return [
48049
+ 3,
48050
+ 1
48051
+ ];
48052
+ case 4:
48053
+ return [
48054
+ 2
48055
+ ];
48056
+ }
47491
48057
  });
47492
48058
  });
47493
- return messageSentences.filter(function(ms) {
47494
- return !playedMessageSentences.find(function(pms) {
47495
- return pms.messageId === ms.messageId && pms.sentence === ms.sentence;
48059
+ return function(_x4) {
48060
+ return _ref8.apply(this, arguments);
48061
+ };
48062
+ }(), []);
48063
+ var playSegmentsImpl = (0, import_react67.useCallback)(/* @__PURE__ */ function() {
48064
+ var _ref9 = _asyncToGenerator11(function(args_0) {
48065
+ return _ts_generator(this, function(_state) {
48066
+ switch(_state.label){
48067
+ case 0:
48068
+ if (!providedPlaySegments) return [
48069
+ 3,
48070
+ 2
48071
+ ];
48072
+ return [
48073
+ 4,
48074
+ Promise.resolve(providedPlaySegments(args_0))
48075
+ ];
48076
+ case 1:
48077
+ _state.sent();
48078
+ return [
48079
+ 2
48080
+ ];
48081
+ case 2:
48082
+ return [
48083
+ 4,
48084
+ defaultPlaySegments(args_0)
48085
+ ];
48086
+ case 3:
48087
+ _state.sent();
48088
+ return [
48089
+ 2
48090
+ ];
48091
+ }
47496
48092
  });
47497
48093
  });
47498
- }, [
47499
- messagesProps,
47500
- playedMessageSentences
48094
+ return function(_x5) {
48095
+ return _ref9.apply(this, arguments);
48096
+ };
48097
+ }(), [
48098
+ providedPlaySegments,
48099
+ defaultPlaySegments
47501
48100
  ]);
47502
- var defaultPlay = (0, import_react67.useCallback)(function(_ref5) {
47503
- var input_1 = _ref5.input, onPlay = _ref5.onPlay, onStop = _ref5.onStop, onEnd_0 = _ref5.onEnd;
47504
- var searchParams = new URLSearchParams(_objectSpread47({
47505
- input: input_1
47506
- }, superinterfaceContext.variables));
47507
- audioPlayer.load("".concat(superinterfaceContext.baseUrl, "/audio-runtimes/tts?").concat(searchParams), {
47508
- format: "mp3",
47509
- autoplay: isAudioPlayed,
47510
- html5: isHtmlAudioSupported,
47511
- onplay: onPlay,
47512
- onstop: onStop,
47513
- onload: function() {
47514
- var nextUnplayedMessageSentence = unplayedMessageSentences[1];
47515
- if (!nextUnplayedMessageSentence) return;
47516
- var isNextFullSentence = fullSentenceRegex.test(nextUnplayedMessageSentence.sentence);
47517
- if (!isNextFullSentence) return;
47518
- var nextSearchParams = new URLSearchParams(_objectSpread47({
47519
- input: nextUnplayedMessageSentence.sentence
47520
- }, superinterfaceContext.variables));
47521
- nextAudioPlayer.load("".concat(superinterfaceContext.baseUrl, "/audio-runtimes/tts?").concat(nextSearchParams), {
47522
- format: "mp3",
47523
- autoplay: false,
47524
- html5: isHtmlAudioSupported
47525
- });
47526
- },
47527
- onend: onEnd_0
48101
+ var handleStop = (0, import_react67.useCallback)(function(messageId) {
48102
+ setAudioQueue(function(prev) {
48103
+ return prev.map(function(m_13) {
48104
+ return m_13.id === messageId ? _objectSpread47(_objectSpread47({}, m_13), {}, {
48105
+ stopped: true
48106
+ }) : m_13;
48107
+ });
47528
48108
  });
48109
+ activeSegmentsRef.current = 0;
48110
+ setIsPlaying(false);
48111
+ currentSegmentRef.current = null;
48112
+ pickLockRef.current = false;
48113
+ checkForCompletion();
47529
48114
  }, [
47530
- superinterfaceContext,
47531
- unplayedMessageSentences,
47532
- audioPlayer,
47533
- nextAudioPlayer,
47534
- isAudioPlayed,
47535
- fullSentenceRegex
48115
+ checkForCompletion
47536
48116
  ]);
47537
- var play = (0, import_react67.useMemo)(function() {
47538
- return passedPlay || defaultPlay;
48117
+ var handleSegmentEnd = (0, import_react67.useCallback)(function() {
48118
+ if (activeSegmentsRef.current > 0) activeSegmentsRef.current -= 1;
48119
+ if (activeSegmentsRef.current === 0) {
48120
+ setIsPlaying(false);
48121
+ currentSegmentRef.current = null;
48122
+ pickLockRef.current = false;
48123
+ checkForCompletion();
48124
+ }
47539
48125
  }, [
47540
- passedPlay,
47541
- defaultPlay
48126
+ checkForCompletion
47542
48127
  ]);
47543
48128
  (0, import_react67.useEffect)(function() {
47544
48129
  if (isPlaying) return;
47545
- if (audioPlayer.playing) return;
47546
- if (!latestMessageProps.latestMessage) return;
47547
- if (latestMessageProps.latestMessage.role !== "assistant") return;
47548
- var firstUnplayedMessageSentence = unplayedMessageSentences[0];
47549
- if (!firstUnplayedMessageSentence) {
47550
- return;
48130
+ if (pickLockRef.current) return;
48131
+ if (audioQueue.length === 0) return;
48132
+ var candidate = null;
48133
+ for(var i_3 = 0; i_3 < audioQueue.length; i_3++){
48134
+ var msg = audioQueue[i_3];
48135
+ if (msg.stopped) continue;
48136
+ if (msg.nextIndex >= msg.segments.length) continue;
48137
+ var message_0 = messagesByIdRef.current.get(msg.id);
48138
+ if (!message_0) continue;
48139
+ candidate = {
48140
+ messageId: msg.id,
48141
+ message: message_0,
48142
+ rawInput: msg.rawInput,
48143
+ startIndex: msg.nextIndex,
48144
+ segments: msg.segments.slice(msg.nextIndex)
48145
+ };
48146
+ break;
47551
48147
  }
47552
- var isFullSentence = isOptimistic({
47553
- id: latestMessageProps.latestMessage.id
47554
- }) || latestMessageProps.latestMessage.status !== "in_progress" || fullSentenceRegex.test(firstUnplayedMessageSentence.sentence);
47555
- if (!isFullSentence) return;
48148
+ if (!candidate || candidate.segments.length === 0) return;
48149
+ pickLockRef.current = true;
47556
48150
  setIsPlaying(true);
47557
- setPlayedMessageSentences(function(prev) {
47558
- return _to_consumable_array(prev).concat([
47559
- firstUnplayedMessageSentence
47560
- ]);
48151
+ setAudioQueue(function(prev_0) {
48152
+ return prev_0.map(function(m_14) {
48153
+ return m_14.id === candidate.messageId ? _objectSpread47(_objectSpread47({}, m_14), {}, {
48154
+ nextIndex: m_14.segments.length
48155
+ }) : m_14;
48156
+ });
47561
48157
  });
47562
- var input_2 = firstUnplayedMessageSentence.sentence;
47563
- play({
47564
- input: input_2,
47565
- onPlay: function() {
47566
- setIsAudioPlayed(true);
47567
- },
47568
- onStop: function() {
47569
- setStoppedMessageIds(function(prev_0) {
47570
- return _to_consumable_array(prev_0).concat([
47571
- firstUnplayedMessageSentence.messageId
47572
- ]);
48158
+ var runPlayback = /* @__PURE__ */ function() {
48159
+ var _ref0 = _asyncToGenerator11(function() {
48160
+ var nextIndex_0, error;
48161
+ return _ts_generator(this, function(_state) {
48162
+ switch(_state.label){
48163
+ case 0:
48164
+ nextIndex_0 = candidate.startIndex;
48165
+ _state.label = 1;
48166
+ case 1:
48167
+ _state.trys.push([
48168
+ 1,
48169
+ 3,
48170
+ 4,
48171
+ 5
48172
+ ]);
48173
+ return [
48174
+ 4,
48175
+ playSegmentsImpl({
48176
+ segments: candidate.segments,
48177
+ startIndex: candidate.startIndex,
48178
+ message: candidate.message,
48179
+ play: function() {
48180
+ var _play = _asyncToGenerator11(function(segment_1) {
48181
+ return _ts_generator(this, function(_state) {
48182
+ switch(_state.label){
48183
+ case 0:
48184
+ activeSegmentsRef.current += 1;
48185
+ nextIndex_0 += 1;
48186
+ currentSegmentRef.current = {
48187
+ messageId: candidate.messageId,
48188
+ nextIndex: nextIndex_0
48189
+ };
48190
+ return [
48191
+ 4,
48192
+ playInternal(segment_1, {
48193
+ onPlay: function() {},
48194
+ onStop: function() {
48195
+ return handleStop(candidate.messageId);
48196
+ },
48197
+ onEnd: function() {
48198
+ return handleSegmentEnd();
48199
+ }
48200
+ })
48201
+ ];
48202
+ case 1:
48203
+ _state.sent();
48204
+ return [
48205
+ 2
48206
+ ];
48207
+ }
48208
+ });
48209
+ });
48210
+ function play(_x6) {
48211
+ return _play.apply(this, arguments);
48212
+ }
48213
+ return play;
48214
+ }()
48215
+ })
48216
+ ];
48217
+ case 2:
48218
+ _state.sent();
48219
+ return [
48220
+ 3,
48221
+ 5
48222
+ ];
48223
+ case 3:
48224
+ error = _state.sent();
48225
+ handleStop(candidate.messageId);
48226
+ console.error(error);
48227
+ return [
48228
+ 3,
48229
+ 5
48230
+ ];
48231
+ case 4:
48232
+ checkForCompletion();
48233
+ return [
48234
+ 7
48235
+ ];
48236
+ case 5:
48237
+ return [
48238
+ 2
48239
+ ];
48240
+ }
47573
48241
  });
47574
- setIsPlaying(false);
47575
- },
47576
- onEnd: function() {
47577
- setIsPlaying(false);
47578
- isLastSentencePlayedRef.current = unplayedMessageSentences.length === 1;
47579
- if (isLastSentencePlayedRef.current && latestMessageProps.latestMessage.status !== "in_progress") {
47580
- _onEnd();
47581
- isLastSentencePlayedRef.current = false;
47582
- }
47583
- }
47584
- });
47585
- }, [
47586
- unplayedMessageSentences,
47587
- isPlaying,
47588
- superinterfaceContext,
47589
- latestMessageProps,
47590
- audioPlayer,
47591
- nextAudioPlayer,
47592
- playedMessageSentences,
47593
- _onEnd,
47594
- play,
47595
- fullSentenceRegex
47596
- ]);
47597
- (0, import_react67.useEffect)(function() {
47598
- var _latestMessageProps$l;
47599
- if (isLastSentencePlayedRef.current && !isPlaying && unplayedMessageSentences.length === 0 && ((_latestMessageProps$l = latestMessageProps.latestMessage) === null || _latestMessageProps$l === void 0 ? void 0 : _latestMessageProps$l.status) !== "in_progress") {
47600
- _onEnd();
47601
- isLastSentencePlayedRef.current = false;
47602
- }
48242
+ });
48243
+ return function runPlayback2() {
48244
+ return _ref0.apply(this, arguments);
48245
+ };
48246
+ }();
48247
+ runPlayback();
47603
48248
  }, [
48249
+ audioQueue,
47604
48250
  isPlaying,
47605
- unplayedMessageSentences.length,
47606
- (_latestMessageProps$l2 = latestMessageProps.latestMessage) === null || _latestMessageProps$l2 === void 0 ? void 0 : _latestMessageProps$l2.status,
47607
- _onEnd
48251
+ playSegmentsImpl,
48252
+ playInternal,
48253
+ handleStop,
48254
+ handleSegmentEnd,
48255
+ checkForCompletion
47608
48256
  ]);
47609
48257
  (0, import_react67.useEffect)(function() {
47610
48258
  if (isHtmlAudioSupported) {
47611
- var _Howler$_howls$;
47612
- 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;
47613
- import_howler.Howler._howls[0]._sounds[0]._node.crossOrigin = "anonymous";
48259
+ var _Howler$_howls;
48260
+ var node = import_howler.Howler === null || import_howler.Howler === void 0 || (_Howler$_howls = import_howler.Howler._howls) === null || _Howler$_howls === void 0 || (_Howler$_howls = _Howler$_howls[0]) === null || _Howler$_howls === void 0 || (_Howler$_howls = _Howler$_howls._sounds) === null || _Howler$_howls === void 0 || (_Howler$_howls = _Howler$_howls[0]) === null || _Howler$_howls === void 0 ? void 0 : _Howler$_howls._node;
48261
+ if (node) node.crossOrigin = "anonymous";
47614
48262
  }
47615
48263
  }, [
47616
48264
  audioPlayer
47617
48265
  ]);
47618
- var _ref5 = _sliced_to_array((0, import_react67.useState)(null), 2), audioEngine = _ref5[0], setAudioEngine = _ref5[1];
48266
+ var _$_ref3 = _sliced_to_array((0, import_react67.useState)(null), 2), audioEngine = _$_ref3[0], setAudioEngine = _$_ref3[1];
47619
48267
  var isAudioEngineInited = (0, import_react67.useRef)(false);
47620
48268
  (0, import_react67.useEffect)(function() {
47621
48269
  if (!audioPlayer.playing) return;
47622
48270
  if (isAudioEngineInited.current) return;
47623
48271
  isAudioEngineInited.current = true;
47624
48272
  if (isHtmlAudioSupported) {
47625
- var audioContext = new AudioContext();
47626
- setAudioEngine({
47627
- // @ts-ignore-next-line
47628
- source: audioContext.createMediaElementSource(// @ts-ignore-next-line
47629
- import_howler.Howler._howls[0]._sounds[0]._node),
47630
- audioContext: audioContext
47631
- });
48273
+ var _Howler$_howls2;
48274
+ var AudioCtx = window.AudioContext || window.webkitAudioContext;
48275
+ var audioContext = new AudioCtx();
48276
+ var node_0 = import_howler.Howler === null || import_howler.Howler === void 0 || (_Howler$_howls2 = import_howler.Howler._howls) === null || _Howler$_howls2 === void 0 || (_Howler$_howls2 = _Howler$_howls2[0]) === null || _Howler$_howls2 === void 0 || (_Howler$_howls2 = _Howler$_howls2._sounds) === null || _Howler$_howls2 === void 0 || (_Howler$_howls2 = _Howler$_howls2[0]) === null || _Howler$_howls2 === void 0 ? void 0 : _Howler$_howls2._node;
48277
+ if (node_0) {
48278
+ setAudioEngine({
48279
+ // @ts-ignore-next-line
48280
+ source: audioContext.createMediaElementSource(node_0),
48281
+ audioContext: audioContext
48282
+ });
48283
+ }
47632
48284
  } else {
47633
48285
  setAudioEngine({
47634
48286
  source: import_howler.Howler.masterGain,
@@ -47636,25 +48288,24 @@ var useMessageAudio = function(_ref2) {
47636
48288
  });
47637
48289
  }
47638
48290
  }, [
47639
- audioPlayer,
47640
- isAudioEngineInited
48291
+ audioPlayer
47641
48292
  ]);
47642
48293
  var visualizationAnalyser = (0, import_react67.useMemo)(function() {
47643
48294
  if (!audioEngine) return null;
47644
- var result = audioEngine.audioContext.createAnalyser();
48295
+ var analyser = audioEngine.audioContext.createAnalyser();
47645
48296
  audioEngine.source.connect(audioEngine.audioContext.destination);
47646
- audioEngine.source.connect(result);
47647
- return result;
48297
+ audioEngine.source.connect(analyser);
48298
+ return analyser;
47648
48299
  }, [
47649
48300
  audioEngine
47650
48301
  ]);
47651
48302
  var isPending = (0, import_react67.useMemo)(function() {
47652
- var _latestMessageProps$l3;
47653
- return isPlaying || unplayedMessageSentences.length > 0 || ((_latestMessageProps$l3 = latestMessageProps.latestMessage) === null || _latestMessageProps$l3 === void 0 ? void 0 : _latestMessageProps$l3.status) === "in_progress";
48303
+ return isPlaying || audioQueue.some(function(m_15) {
48304
+ return !m_15.stopped && (m_15.nextIndex < m_15.segments.length || m_15.status === "in_progress");
48305
+ });
47654
48306
  }, [
47655
48307
  isPlaying,
47656
- unplayedMessageSentences,
47657
- latestMessageProps
48308
+ audioQueue
47658
48309
  ]);
47659
48310
  return _objectSpread47(_objectSpread47({
47660
48311
  isPending: isPending,
@@ -47676,7 +48327,53 @@ var blobToData = function(blob) {
47676
48327
  });
47677
48328
  };
47678
48329
  // src/hooks/audioRuntimes/useTtsAudioRuntime/index.ts
47679
- function asyncGeneratorStep11(n, t, e, r, o, a, c) {
48330
+ var _excluded5 = [
48331
+ "onEnd"
48332
+ ];
48333
+ function ownKeys48(e, r) {
48334
+ var t = Object.keys(e);
48335
+ if (Object.getOwnPropertySymbols) {
48336
+ var o = Object.getOwnPropertySymbols(e);
48337
+ r && (o = o.filter(function(r2) {
48338
+ return Object.getOwnPropertyDescriptor(e, r2).enumerable;
48339
+ })), t.push.apply(t, o);
48340
+ }
48341
+ return t;
48342
+ }
48343
+ function _objectSpread48(e) {
48344
+ for(var r = 1; r < arguments.length; r++){
48345
+ var t = null != arguments[r] ? arguments[r] : {};
48346
+ r % 2 ? ownKeys48(Object(t), true).forEach(function(r2) {
48347
+ _defineProperty48(e, r2, t[r2]);
48348
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys48(Object(t)).forEach(function(r2) {
48349
+ Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
48350
+ });
48351
+ }
48352
+ return e;
48353
+ }
48354
+ function _defineProperty48(e, r, t) {
48355
+ return (r = _toPropertyKey48(r)) in e ? Object.defineProperty(e, r, {
48356
+ value: t,
48357
+ enumerable: true,
48358
+ configurable: true,
48359
+ writable: true
48360
+ }) : e[r] = t, e;
48361
+ }
48362
+ function _toPropertyKey48(t) {
48363
+ var i = _toPrimitive48(t, "string");
48364
+ return "symbol" == (typeof i === "undefined" ? "undefined" : _type_of(i)) ? i : i + "";
48365
+ }
48366
+ function _toPrimitive48(t, r) {
48367
+ if ("object" != (typeof t === "undefined" ? "undefined" : _type_of(t)) || !t) return t;
48368
+ var e = t[Symbol.toPrimitive];
48369
+ if (void 0 !== e) {
48370
+ var i = e.call(t, r || "default");
48371
+ if ("object" != (typeof i === "undefined" ? "undefined" : _type_of(i))) return i;
48372
+ throw new TypeError("@@toPrimitive must return a primitive value.");
48373
+ }
48374
+ return ("string" === r ? String : Number)(t);
48375
+ }
48376
+ function asyncGeneratorStep12(n, t, e, r, o, a, c) {
47680
48377
  try {
47681
48378
  var i = n[a](c), u = i.value;
47682
48379
  } catch (n2) {
@@ -47684,35 +48381,67 @@ function asyncGeneratorStep11(n, t, e, r, o, a, c) {
47684
48381
  }
47685
48382
  i.done ? t(u) : Promise.resolve(u).then(r, o);
47686
48383
  }
47687
- function _asyncToGenerator11(n) {
48384
+ function _asyncToGenerator12(n) {
47688
48385
  return function() {
47689
48386
  var t = this, e = arguments;
47690
48387
  return new Promise(function(r, o) {
47691
48388
  var a = n.apply(t, e);
47692
48389
  function _next(n2) {
47693
- asyncGeneratorStep11(a, r, o, _next, _throw, "next", n2);
48390
+ asyncGeneratorStep12(a, r, o, _next, _throw, "next", n2);
47694
48391
  }
47695
48392
  function _throw(n2) {
47696
- asyncGeneratorStep11(a, r, o, _next, _throw, "throw", n2);
48393
+ asyncGeneratorStep12(a, r, o, _next, _throw, "throw", n2);
47697
48394
  }
47698
48395
  _next(void 0);
47699
48396
  });
47700
48397
  };
47701
48398
  }
48399
+ function _objectWithoutProperties5(e, t) {
48400
+ if (null == e) return {};
48401
+ var o, r, i = _objectWithoutPropertiesLoose5(e, t);
48402
+ if (Object.getOwnPropertySymbols) {
48403
+ var n = Object.getOwnPropertySymbols(e);
48404
+ for(r = 0; r < n.length; r++)o = n[r], -1 === t.indexOf(o) && ({}).propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
48405
+ }
48406
+ return i;
48407
+ }
48408
+ function _objectWithoutPropertiesLoose5(r, e) {
48409
+ if (null == r) return {};
48410
+ var t = {};
48411
+ for(var n in r)if (({}).hasOwnProperty.call(r, n)) {
48412
+ if (-1 !== e.indexOf(n)) continue;
48413
+ t[n] = r[n];
48414
+ }
48415
+ return t;
48416
+ }
47702
48417
  var useTtsAudioRuntime = function(t0) {
47703
- var $ = (0, import_react_compiler_runtime88.c)(30);
47704
- var play = t0.play, passedOnEnd = t0.onEnd;
48418
+ var $ = (0, import_react_compiler_runtime88.c)(33);
48419
+ var overrides;
48420
+ var passedOnEnd;
48421
+ if ($[0] !== t0) {
48422
+ var _t = t0;
48423
+ var ref;
48424
+ ref = _t, passedOnEnd = ref.onEnd, ref;
48425
+ overrides = _objectWithoutProperties5(_t, _excluded5);
48426
+ _t;
48427
+ $[0] = t0;
48428
+ $[1] = overrides;
48429
+ $[2] = passedOnEnd;
48430
+ } else {
48431
+ overrides = $[1];
48432
+ passedOnEnd = $[2];
48433
+ }
47705
48434
  var addToast = useToasts().addToast;
47706
48435
  var queryClient = (0, import_react_query10.useQueryClient)();
47707
48436
  var threadContext = useSuperinterfaceContext();
47708
48437
  var t1;
47709
- if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
48438
+ if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
47710
48439
  t1 = {
47711
48440
  name: "microphone"
47712
48441
  };
47713
- $[0] = t1;
48442
+ $[3] = t1;
47714
48443
  } else {
47715
- t1 = $[0];
48444
+ t1 = $[3];
47716
48445
  }
47717
48446
  var microphonePermission = usePermission(t1);
47718
48447
  var createMessageProps = useCreateMessage({
@@ -47726,12 +48455,12 @@ var useTtsAudioRuntime = function(t0) {
47726
48455
  }
47727
48456
  });
47728
48457
  var t2;
47729
- if ($[1] !== createMessageProps) {
48458
+ if ($[4] !== createMessageProps) {
47730
48459
  t2 = {
47731
48460
  isStopOnSilence: true,
47732
48461
  onStart: _temp9,
47733
48462
  onStop: function() {
47734
- var _onStop = _asyncToGenerator11(function(_event, chunks) {
48463
+ var _onStop = _asyncToGenerator12(function(_event, chunks) {
47735
48464
  var blob, audioContent;
47736
48465
  return _ts_generator(this, function(_state) {
47737
48466
  switch(_state.label){
@@ -47760,10 +48489,10 @@ var useTtsAudioRuntime = function(t0) {
47760
48489
  return onStop;
47761
48490
  }()
47762
48491
  };
47763
- $[1] = createMessageProps;
47764
- $[2] = t2;
48492
+ $[4] = createMessageProps;
48493
+ $[5] = t2;
47765
48494
  } else {
47766
- t2 = $[2];
48495
+ t2 = $[5];
47767
48496
  }
47768
48497
  var recorderProps = useRecorder(t2);
47769
48498
  recorderProps;
@@ -47773,39 +48502,38 @@ var useTtsAudioRuntime = function(t0) {
47773
48502
  t3 = passedOnEnd;
47774
48503
  break bb0;
47775
48504
  }
47776
- var _t;
47777
- if ($[3] !== microphonePermission || $[4] !== recorderProps) {
47778
- _t = function() {
48505
+ var _t2;
48506
+ if ($[6] !== microphonePermission || $[7] !== recorderProps) {
48507
+ _t2 = function() {
47779
48508
  if (microphonePermission === "granted") {
47780
48509
  recorderProps.start();
47781
48510
  }
47782
48511
  };
47783
- $[3] = microphonePermission;
47784
- $[4] = recorderProps;
47785
- $[5] = _t;
48512
+ $[6] = microphonePermission;
48513
+ $[7] = recorderProps;
48514
+ $[8] = _t2;
47786
48515
  } else {
47787
- _t = $[5];
48516
+ _t2 = $[8];
47788
48517
  }
47789
- t3 = _t;
48518
+ t3 = _t2;
47790
48519
  }
47791
48520
  var onEnd = t3;
47792
48521
  var t4;
47793
- if ($[6] !== onEnd || $[7] !== play) {
47794
- t4 = {
47795
- play: play,
48522
+ if ($[9] !== onEnd || $[10] !== overrides) {
48523
+ t4 = _objectSpread48({
47796
48524
  onEnd: onEnd
47797
- };
47798
- $[6] = onEnd;
47799
- $[7] = play;
47800
- $[8] = t4;
48525
+ }, overrides);
48526
+ $[9] = onEnd;
48527
+ $[10] = overrides;
48528
+ $[11] = t4;
47801
48529
  } else {
47802
- t4 = $[8];
48530
+ t4 = $[11];
47803
48531
  }
47804
48532
  var messageAudioProps = useMessageAudio(t4);
47805
48533
  recorderProps;
47806
48534
  var t5;
47807
48535
  var t6;
47808
- if ($[9] !== createMessageProps.isPending || $[10] !== recorderProps.pause || $[11] !== recorderProps.resume || $[12] !== recorderProps.start || $[13] !== recorderProps.status || $[14] !== recorderProps.stop || $[15] !== recorderProps.visualizationAnalyser) {
48536
+ if ($[12] !== createMessageProps.isPending || $[13] !== recorderProps.pause || $[14] !== recorderProps.resume || $[15] !== recorderProps.start || $[16] !== recorderProps.status || $[17] !== recorderProps.stop || $[18] !== recorderProps.visualizationAnalyser) {
47809
48537
  t6 = {
47810
48538
  start: recorderProps.start,
47811
48539
  stop: recorderProps.stop,
@@ -47815,19 +48543,19 @@ var useTtsAudioRuntime = function(t0) {
47815
48543
  visualizationAnalyser: recorderProps.visualizationAnalyser,
47816
48544
  rawStatus: recorderProps.status
47817
48545
  };
47818
- $[9] = createMessageProps.isPending;
47819
- $[10] = recorderProps.pause;
47820
- $[11] = recorderProps.resume;
47821
- $[12] = recorderProps.start;
47822
- $[13] = recorderProps.status;
47823
- $[14] = recorderProps.stop;
47824
- $[15] = recorderProps.visualizationAnalyser;
47825
- $[16] = t6;
48546
+ $[12] = createMessageProps.isPending;
48547
+ $[13] = recorderProps.pause;
48548
+ $[14] = recorderProps.resume;
48549
+ $[15] = recorderProps.start;
48550
+ $[16] = recorderProps.status;
48551
+ $[17] = recorderProps.stop;
48552
+ $[18] = recorderProps.visualizationAnalyser;
48553
+ $[19] = t6;
47826
48554
  } else {
47827
- t6 = $[16];
48555
+ t6 = $[19];
47828
48556
  }
47829
48557
  var t7;
47830
- if ($[17] !== messageAudioProps.isAudioPlayed || $[18] !== messageAudioProps.isPending || $[19] !== messageAudioProps.isReady || $[20] !== messageAudioProps.pause || $[21] !== messageAudioProps.paused || $[22] !== messageAudioProps.play || $[23] !== messageAudioProps.playing || $[24] !== messageAudioProps.stop || $[25] !== messageAudioProps.visualizationAnalyser) {
48558
+ if ($[20] !== messageAudioProps.isAudioPlayed || $[21] !== messageAudioProps.isPending || $[22] !== messageAudioProps.isReady || $[23] !== messageAudioProps.pause || $[24] !== messageAudioProps.paused || $[25] !== messageAudioProps.play || $[26] !== messageAudioProps.playing || $[27] !== messageAudioProps.stop || $[28] !== messageAudioProps.visualizationAnalyser) {
47831
48559
  t7 = {
47832
48560
  play: messageAudioProps.play,
47833
48561
  pause: messageAudioProps.pause,
@@ -47840,32 +48568,32 @@ var useTtsAudioRuntime = function(t0) {
47840
48568
  isAudioPlayed: messageAudioProps.isAudioPlayed,
47841
48569
  rawStatus: void 0
47842
48570
  };
47843
- $[17] = messageAudioProps.isAudioPlayed;
47844
- $[18] = messageAudioProps.isPending;
47845
- $[19] = messageAudioProps.isReady;
47846
- $[20] = messageAudioProps.pause;
47847
- $[21] = messageAudioProps.paused;
47848
- $[22] = messageAudioProps.play;
47849
- $[23] = messageAudioProps.playing;
47850
- $[24] = messageAudioProps.stop;
47851
- $[25] = messageAudioProps.visualizationAnalyser;
47852
- $[26] = t7;
47853
- } else {
47854
- t7 = $[26];
48571
+ $[20] = messageAudioProps.isAudioPlayed;
48572
+ $[21] = messageAudioProps.isPending;
48573
+ $[22] = messageAudioProps.isReady;
48574
+ $[23] = messageAudioProps.pause;
48575
+ $[24] = messageAudioProps.paused;
48576
+ $[25] = messageAudioProps.play;
48577
+ $[26] = messageAudioProps.playing;
48578
+ $[27] = messageAudioProps.stop;
48579
+ $[28] = messageAudioProps.visualizationAnalyser;
48580
+ $[29] = t7;
48581
+ } else {
48582
+ t7 = $[29];
47855
48583
  }
47856
48584
  var t8;
47857
- if ($[27] !== t6 || $[28] !== t7) {
48585
+ if ($[30] !== t6 || $[31] !== t7) {
47858
48586
  t8 = {
47859
48587
  ttsAudioRuntime: {
47860
48588
  user: t6,
47861
48589
  assistant: t7
47862
48590
  }
47863
48591
  };
47864
- $[27] = t6;
47865
- $[28] = t7;
47866
- $[29] = t8;
48592
+ $[30] = t6;
48593
+ $[31] = t7;
48594
+ $[32] = t8;
47867
48595
  } else {
47868
- t8 = $[29];
48596
+ t8 = $[32];
47869
48597
  }
47870
48598
  t5 = t8;
47871
48599
  return t5;
@@ -47874,7 +48602,7 @@ function _temp9() {
47874
48602
  return _temp24.apply(this, arguments);
47875
48603
  }
47876
48604
  function _temp24() {
47877
- _temp24 = _asyncToGenerator11(function() {
48605
+ _temp24 = _asyncToGenerator12(function() {
47878
48606
  return _ts_generator(this, function(_state) {
47879
48607
  return [
47880
48608
  2
@@ -47885,59 +48613,142 @@ function _temp24() {
47885
48613
  }
47886
48614
  // src/components/audioRuntimes/TtsAudioRuntimeProvider.tsx
47887
48615
  var import_jsx_runtime87 = require("react/jsx-runtime");
48616
+ var _excluded6 = [
48617
+ "children",
48618
+ "onEnd"
48619
+ ];
48620
+ function ownKeys49(e, r) {
48621
+ var t = Object.keys(e);
48622
+ if (Object.getOwnPropertySymbols) {
48623
+ var o = Object.getOwnPropertySymbols(e);
48624
+ r && (o = o.filter(function(r2) {
48625
+ return Object.getOwnPropertyDescriptor(e, r2).enumerable;
48626
+ })), t.push.apply(t, o);
48627
+ }
48628
+ return t;
48629
+ }
48630
+ function _objectSpread49(e) {
48631
+ for(var r = 1; r < arguments.length; r++){
48632
+ var t = null != arguments[r] ? arguments[r] : {};
48633
+ r % 2 ? ownKeys49(Object(t), true).forEach(function(r2) {
48634
+ _defineProperty49(e, r2, t[r2]);
48635
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys49(Object(t)).forEach(function(r2) {
48636
+ Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
48637
+ });
48638
+ }
48639
+ return e;
48640
+ }
48641
+ function _defineProperty49(e, r, t) {
48642
+ return (r = _toPropertyKey49(r)) in e ? Object.defineProperty(e, r, {
48643
+ value: t,
48644
+ enumerable: true,
48645
+ configurable: true,
48646
+ writable: true
48647
+ }) : e[r] = t, e;
48648
+ }
48649
+ function _toPropertyKey49(t) {
48650
+ var i = _toPrimitive49(t, "string");
48651
+ return "symbol" == (typeof i === "undefined" ? "undefined" : _type_of(i)) ? i : i + "";
48652
+ }
48653
+ function _toPrimitive49(t, r) {
48654
+ if ("object" != (typeof t === "undefined" ? "undefined" : _type_of(t)) || !t) return t;
48655
+ var e = t[Symbol.toPrimitive];
48656
+ if (void 0 !== e) {
48657
+ var i = e.call(t, r || "default");
48658
+ if ("object" != (typeof i === "undefined" ? "undefined" : _type_of(i))) return i;
48659
+ throw new TypeError("@@toPrimitive must return a primitive value.");
48660
+ }
48661
+ return ("string" === r ? String : Number)(t);
48662
+ }
48663
+ function _objectWithoutProperties6(e, t) {
48664
+ if (null == e) return {};
48665
+ var o, r, i = _objectWithoutPropertiesLoose6(e, t);
48666
+ if (Object.getOwnPropertySymbols) {
48667
+ var n = Object.getOwnPropertySymbols(e);
48668
+ for(r = 0; r < n.length; r++)o = n[r], -1 === t.indexOf(o) && ({}).propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
48669
+ }
48670
+ return i;
48671
+ }
48672
+ function _objectWithoutPropertiesLoose6(r, e) {
48673
+ if (null == r) return {};
48674
+ var t = {};
48675
+ for(var n in r)if (({}).hasOwnProperty.call(r, n)) {
48676
+ if (-1 !== e.indexOf(n)) continue;
48677
+ t[n] = r[n];
48678
+ }
48679
+ return t;
48680
+ }
47888
48681
  var TtsAudioRuntimeProvider = function(t0) {
47889
- var $ = (0, import_react_compiler_runtime89.c)(8);
47890
- var children = t0.children, play = t0.play, onEnd = t0.onEnd;
48682
+ var $ = (0, import_react_compiler_runtime89.c)(12);
48683
+ var children;
48684
+ var onEnd;
48685
+ var overrides;
48686
+ if ($[0] !== t0) {
48687
+ var _t = t0;
48688
+ var ref;
48689
+ ref = _t, children = ref.children, onEnd = ref.onEnd, ref;
48690
+ overrides = _objectWithoutProperties6(_t, _excluded6);
48691
+ _t;
48692
+ $[0] = t0;
48693
+ $[1] = children;
48694
+ $[2] = onEnd;
48695
+ $[3] = overrides;
48696
+ } else {
48697
+ children = $[1];
48698
+ onEnd = $[2];
48699
+ overrides = $[3];
48700
+ }
47891
48701
  var t1;
47892
- if ($[0] !== onEnd || $[1] !== play) {
47893
- t1 = {
47894
- play: play,
48702
+ if ($[4] !== onEnd || $[5] !== overrides) {
48703
+ t1 = _objectSpread49({
47895
48704
  onEnd: onEnd
47896
- };
47897
- $[0] = onEnd;
47898
- $[1] = play;
47899
- $[2] = t1;
48705
+ }, overrides);
48706
+ $[4] = onEnd;
48707
+ $[5] = overrides;
48708
+ $[6] = t1;
47900
48709
  } else {
47901
- t1 = $[2];
48710
+ t1 = $[6];
47902
48711
  }
47903
48712
  var ttsAudioRuntime = useTtsAudioRuntime(t1).ttsAudioRuntime;
47904
48713
  var t2;
47905
- if ($[3] !== ttsAudioRuntime) {
48714
+ if ($[7] !== ttsAudioRuntime) {
47906
48715
  t2 = {
47907
48716
  audioRuntime: ttsAudioRuntime
47908
48717
  };
47909
- $[3] = ttsAudioRuntime;
47910
- $[4] = t2;
48718
+ $[7] = ttsAudioRuntime;
48719
+ $[8] = t2;
47911
48720
  } else {
47912
- t2 = $[4];
48721
+ t2 = $[8];
47913
48722
  }
47914
48723
  var t3;
47915
- if ($[5] !== children || $[6] !== t2) {
48724
+ if ($[9] !== children || $[10] !== t2) {
47916
48725
  t3 = /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(AudioThreadContext.Provider, {
47917
48726
  value: t2,
47918
48727
  children: children
47919
48728
  });
47920
- $[5] = children;
47921
- $[6] = t2;
47922
- $[7] = t3;
48729
+ $[9] = children;
48730
+ $[10] = t2;
48731
+ $[11] = t3;
47923
48732
  } else {
47924
- t3 = $[7];
48733
+ t3 = $[11];
47925
48734
  }
47926
48735
  return t3;
47927
48736
  };
47928
48737
  // src/components/threads/AudioThread/Root/index.tsx
47929
48738
  var import_jsx_runtime88 = require("react/jsx-runtime");
47930
- var _excluded5 = [
48739
+ var _excluded7 = [
47931
48740
  "children"
47932
48741
  ];
47933
48742
  var _excluded22 = [
47934
48743
  "children",
47935
48744
  "play",
48745
+ "playSegments",
48746
+ "getSegments",
47936
48747
  "onEnd",
47937
48748
  "className",
47938
48749
  "style"
47939
48750
  ];
47940
- function ownKeys48(e, r) {
48751
+ function ownKeys50(e, r) {
47941
48752
  var t = Object.keys(e);
47942
48753
  if (Object.getOwnPropertySymbols) {
47943
48754
  var o = Object.getOwnPropertySymbols(e);
@@ -47947,30 +48758,30 @@ function ownKeys48(e, r) {
47947
48758
  }
47948
48759
  return t;
47949
48760
  }
47950
- function _objectSpread48(e) {
48761
+ function _objectSpread50(e) {
47951
48762
  for(var r = 1; r < arguments.length; r++){
47952
48763
  var t = null != arguments[r] ? arguments[r] : {};
47953
- r % 2 ? ownKeys48(Object(t), true).forEach(function(r2) {
47954
- _defineProperty48(e, r2, t[r2]);
47955
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys48(Object(t)).forEach(function(r2) {
48764
+ r % 2 ? ownKeys50(Object(t), true).forEach(function(r2) {
48765
+ _defineProperty50(e, r2, t[r2]);
48766
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys50(Object(t)).forEach(function(r2) {
47956
48767
  Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
47957
48768
  });
47958
48769
  }
47959
48770
  return e;
47960
48771
  }
47961
- function _defineProperty48(e, r, t) {
47962
- return (r = _toPropertyKey48(r)) in e ? Object.defineProperty(e, r, {
48772
+ function _defineProperty50(e, r, t) {
48773
+ return (r = _toPropertyKey50(r)) in e ? Object.defineProperty(e, r, {
47963
48774
  value: t,
47964
48775
  enumerable: true,
47965
48776
  configurable: true,
47966
48777
  writable: true
47967
48778
  }) : e[r] = t, e;
47968
48779
  }
47969
- function _toPropertyKey48(t) {
47970
- var i = _toPrimitive48(t, "string");
48780
+ function _toPropertyKey50(t) {
48781
+ var i = _toPrimitive50(t, "string");
47971
48782
  return "symbol" == (typeof i === "undefined" ? "undefined" : _type_of(i)) ? i : i + "";
47972
48783
  }
47973
- function _toPrimitive48(t, r) {
48784
+ function _toPrimitive50(t, r) {
47974
48785
  if ("object" != (typeof t === "undefined" ? "undefined" : _type_of(t)) || !t) return t;
47975
48786
  var e = t[Symbol.toPrimitive];
47976
48787
  if (void 0 !== e) {
@@ -47980,16 +48791,16 @@ function _toPrimitive48(t, r) {
47980
48791
  }
47981
48792
  return ("string" === r ? String : Number)(t);
47982
48793
  }
47983
- function _objectWithoutProperties5(e, t) {
48794
+ function _objectWithoutProperties7(e, t) {
47984
48795
  if (null == e) return {};
47985
- var o, r, i = _objectWithoutPropertiesLoose5(e, t);
48796
+ var o, r, i = _objectWithoutPropertiesLoose7(e, t);
47986
48797
  if (Object.getOwnPropertySymbols) {
47987
48798
  var n = Object.getOwnPropertySymbols(e);
47988
48799
  for(r = 0; r < n.length; r++)o = n[r], -1 === t.indexOf(o) && ({}).propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
47989
48800
  }
47990
48801
  return i;
47991
48802
  }
47992
- function _objectWithoutPropertiesLoose5(r, e) {
48803
+ function _objectWithoutPropertiesLoose7(r, e) {
47993
48804
  if (null == r) return {};
47994
48805
  var t = {};
47995
48806
  for(var n in r)if (({}).hasOwnProperty.call(r, n)) {
@@ -48021,25 +48832,29 @@ var Content9 = function(t0) {
48021
48832
  return t1;
48022
48833
  };
48023
48834
  var AudioRuntimeProvider = function(t0) {
48024
- var $ = (0, import_react_compiler_runtime90.c)(4);
48025
- var children = t0.children, play = t0.play, onEnd = t0.onEnd;
48835
+ var $ = (0, import_react_compiler_runtime90.c)(6);
48836
+ var children = t0.children, onEnd = t0.onEnd, play = t0.play, playSegments = t0.playSegments, getSegments = t0.getSegments;
48026
48837
  var audioThreadContext = useAudioThreadContext();
48027
48838
  if (audioThreadContext.audioRuntime) {
48028
48839
  return children;
48029
48840
  }
48030
48841
  var t1;
48031
- if ($[0] !== children || $[1] !== onEnd || $[2] !== play) {
48842
+ if ($[0] !== children || $[1] !== getSegments || $[2] !== onEnd || $[3] !== play || $[4] !== playSegments) {
48032
48843
  t1 = /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(TtsAudioRuntimeProvider, {
48033
- play: play,
48034
48844
  onEnd: onEnd,
48845
+ play: play,
48846
+ playSegments: playSegments,
48847
+ getSegments: getSegments,
48035
48848
  children: children
48036
48849
  });
48037
48850
  $[0] = children;
48038
- $[1] = onEnd;
48039
- $[2] = play;
48040
- $[3] = t1;
48851
+ $[1] = getSegments;
48852
+ $[2] = onEnd;
48853
+ $[3] = play;
48854
+ $[4] = playSegments;
48855
+ $[5] = t1;
48041
48856
  } else {
48042
- t1 = $[3];
48857
+ t1 = $[5];
48043
48858
  }
48044
48859
  return t1;
48045
48860
  };
@@ -48050,7 +48865,7 @@ var Provider5 = function(t0) {
48050
48865
  if ($[0] !== t0) {
48051
48866
  var _t = t0;
48052
48867
  children = _t.children;
48053
- rest = _objectWithoutProperties5(_t, _excluded5);
48868
+ rest = _objectWithoutProperties7(_t, _excluded7);
48054
48869
  _t;
48055
48870
  $[0] = t0;
48056
48871
  $[1] = children;
@@ -48062,7 +48877,7 @@ var Provider5 = function(t0) {
48062
48877
  var audioThreadContext = useAudioThreadContext();
48063
48878
  var t1;
48064
48879
  if ($[3] !== audioThreadContext || $[4] !== rest) {
48065
- t1 = _objectSpread48(_objectSpread48({}, audioThreadContext), rest);
48880
+ t1 = _objectSpread50(_objectSpread50({}, audioThreadContext), rest);
48066
48881
  $[3] = audioThreadContext;
48067
48882
  $[4] = rest;
48068
48883
  $[5] = t1;
@@ -48084,36 +48899,42 @@ var Provider5 = function(t0) {
48084
48899
  return t2;
48085
48900
  };
48086
48901
  var Root16 = function(t0) {
48087
- var $ = (0, import_react_compiler_runtime90.c)(18);
48902
+ var $ = (0, import_react_compiler_runtime90.c)(22);
48088
48903
  var children;
48089
48904
  var className;
48905
+ var getSegments;
48090
48906
  var onEnd;
48091
48907
  var play;
48908
+ var playSegments;
48092
48909
  var rest;
48093
48910
  var style;
48094
48911
  if ($[0] !== t0) {
48095
48912
  var _t2 = t0;
48096
48913
  var ref;
48097
- ref = _t2, children = ref.children, play = ref.play, onEnd = ref.onEnd, className = ref.className, style = ref.style, ref;
48098
- rest = _objectWithoutProperties5(_t2, _excluded22);
48914
+ ref = _t2, children = ref.children, play = ref.play, playSegments = ref.playSegments, getSegments = ref.getSegments, onEnd = ref.onEnd, className = ref.className, style = ref.style, ref;
48915
+ rest = _objectWithoutProperties7(_t2, _excluded22);
48099
48916
  _t2;
48100
48917
  $[0] = t0;
48101
48918
  $[1] = children;
48102
48919
  $[2] = className;
48103
- $[3] = onEnd;
48104
- $[4] = play;
48105
- $[5] = rest;
48106
- $[6] = style;
48920
+ $[3] = getSegments;
48921
+ $[4] = onEnd;
48922
+ $[5] = play;
48923
+ $[6] = playSegments;
48924
+ $[7] = rest;
48925
+ $[8] = style;
48107
48926
  } else {
48108
48927
  children = $[1];
48109
48928
  className = $[2];
48110
- onEnd = $[3];
48111
- play = $[4];
48112
- rest = $[5];
48113
- style = $[6];
48929
+ getSegments = $[3];
48930
+ onEnd = $[4];
48931
+ play = $[5];
48932
+ playSegments = $[6];
48933
+ rest = $[7];
48934
+ style = $[8];
48114
48935
  }
48115
48936
  var t1;
48116
- if ($[7] !== children || $[8] !== className || $[9] !== style) {
48937
+ if ($[9] !== children || $[10] !== className || $[11] !== style) {
48117
48938
  t1 = /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(ToastsProvider, {
48118
48939
  children: /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(Content9, {
48119
48940
  className: className,
@@ -48121,37 +48942,41 @@ var Root16 = function(t0) {
48121
48942
  children: children
48122
48943
  })
48123
48944
  });
48124
- $[7] = children;
48125
- $[8] = className;
48126
- $[9] = style;
48127
- $[10] = t1;
48945
+ $[9] = children;
48946
+ $[10] = className;
48947
+ $[11] = style;
48948
+ $[12] = t1;
48128
48949
  } else {
48129
- t1 = $[10];
48950
+ t1 = $[12];
48130
48951
  }
48131
48952
  var t2;
48132
- if ($[11] !== onEnd || $[12] !== play || $[13] !== t1) {
48953
+ if ($[13] !== getSegments || $[14] !== onEnd || $[15] !== play || $[16] !== playSegments || $[17] !== t1) {
48133
48954
  t2 = /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(AudioRuntimeProvider, {
48134
- play: play,
48135
48955
  onEnd: onEnd,
48956
+ play: play,
48957
+ playSegments: playSegments,
48958
+ getSegments: getSegments,
48136
48959
  children: t1
48137
48960
  });
48138
- $[11] = onEnd;
48139
- $[12] = play;
48140
- $[13] = t1;
48141
- $[14] = t2;
48961
+ $[13] = getSegments;
48962
+ $[14] = onEnd;
48963
+ $[15] = play;
48964
+ $[16] = playSegments;
48965
+ $[17] = t1;
48966
+ $[18] = t2;
48142
48967
  } else {
48143
- t2 = $[14];
48968
+ t2 = $[18];
48144
48969
  }
48145
48970
  var t3;
48146
- if ($[15] !== rest || $[16] !== t2) {
48147
- t3 = /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(Provider5, _objectSpread48(_objectSpread48({}, rest), {}, {
48971
+ if ($[19] !== rest || $[20] !== t2) {
48972
+ t3 = /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(Provider5, _objectSpread50(_objectSpread50({}, rest), {}, {
48148
48973
  children: t2
48149
48974
  }));
48150
- $[15] = rest;
48151
- $[16] = t2;
48152
- $[17] = t3;
48975
+ $[19] = rest;
48976
+ $[20] = t2;
48977
+ $[21] = t3;
48153
48978
  } else {
48154
- t3 = $[17];
48979
+ t3 = $[21];
48155
48980
  }
48156
48981
  return t3;
48157
48982
  };
@@ -48277,7 +49102,7 @@ var useStatus = function() {
48277
49102
  };
48278
49103
  // src/components/threads/AudioThread/Visualization/index.tsx
48279
49104
  var import_jsx_runtime90 = require("react/jsx-runtime");
48280
- var _excluded6 = [
49105
+ var _excluded8 = [
48281
49106
  "children"
48282
49107
  ];
48283
49108
  var _excluded23 = [
@@ -48289,7 +49114,7 @@ var _excluded32 = [
48289
49114
  "height",
48290
49115
  "width"
48291
49116
  ];
48292
- function ownKeys49(e, r) {
49117
+ function ownKeys51(e, r) {
48293
49118
  var t = Object.keys(e);
48294
49119
  if (Object.getOwnPropertySymbols) {
48295
49120
  var o = Object.getOwnPropertySymbols(e);
@@ -48299,30 +49124,30 @@ function ownKeys49(e, r) {
48299
49124
  }
48300
49125
  return t;
48301
49126
  }
48302
- function _objectSpread49(e) {
49127
+ function _objectSpread51(e) {
48303
49128
  for(var r = 1; r < arguments.length; r++){
48304
49129
  var t = null != arguments[r] ? arguments[r] : {};
48305
- r % 2 ? ownKeys49(Object(t), true).forEach(function(r2) {
48306
- _defineProperty49(e, r2, t[r2]);
48307
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys49(Object(t)).forEach(function(r2) {
49130
+ r % 2 ? ownKeys51(Object(t), true).forEach(function(r2) {
49131
+ _defineProperty51(e, r2, t[r2]);
49132
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys51(Object(t)).forEach(function(r2) {
48308
49133
  Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
48309
49134
  });
48310
49135
  }
48311
49136
  return e;
48312
49137
  }
48313
- function _defineProperty49(e, r, t) {
48314
- return (r = _toPropertyKey49(r)) in e ? Object.defineProperty(e, r, {
49138
+ function _defineProperty51(e, r, t) {
49139
+ return (r = _toPropertyKey51(r)) in e ? Object.defineProperty(e, r, {
48315
49140
  value: t,
48316
49141
  enumerable: true,
48317
49142
  configurable: true,
48318
49143
  writable: true
48319
49144
  }) : e[r] = t, e;
48320
49145
  }
48321
- function _toPropertyKey49(t) {
48322
- var i = _toPrimitive49(t, "string");
49146
+ function _toPropertyKey51(t) {
49147
+ var i = _toPrimitive51(t, "string");
48323
49148
  return "symbol" == (typeof i === "undefined" ? "undefined" : _type_of(i)) ? i : i + "";
48324
49149
  }
48325
- function _toPrimitive49(t, r) {
49150
+ function _toPrimitive51(t, r) {
48326
49151
  if ("object" != (typeof t === "undefined" ? "undefined" : _type_of(t)) || !t) return t;
48327
49152
  var e = t[Symbol.toPrimitive];
48328
49153
  if (void 0 !== e) {
@@ -48332,16 +49157,16 @@ function _toPrimitive49(t, r) {
48332
49157
  }
48333
49158
  return ("string" === r ? String : Number)(t);
48334
49159
  }
48335
- function _objectWithoutProperties6(e, t) {
49160
+ function _objectWithoutProperties8(e, t) {
48336
49161
  if (null == e) return {};
48337
- var o, r, i = _objectWithoutPropertiesLoose6(e, t);
49162
+ var o, r, i = _objectWithoutPropertiesLoose8(e, t);
48338
49163
  if (Object.getOwnPropertySymbols) {
48339
49164
  var n = Object.getOwnPropertySymbols(e);
48340
49165
  for(r = 0; r < n.length; r++)o = n[r], -1 === t.indexOf(o) && ({}).propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
48341
49166
  }
48342
49167
  return i;
48343
49168
  }
48344
- function _objectWithoutPropertiesLoose6(r, e) {
49169
+ function _objectWithoutPropertiesLoose8(r, e) {
48345
49170
  if (null == r) return {};
48346
49171
  var t = {};
48347
49172
  for(var n in r)if (({}).hasOwnProperty.call(r, n)) {
@@ -48394,7 +49219,7 @@ var Root17 = function(t0) {
48394
49219
  if ($[0] !== t0) {
48395
49220
  var _t = t0;
48396
49221
  children = _t.children;
48397
- rest = _objectWithoutProperties6(_t, _excluded6);
49222
+ rest = _objectWithoutProperties8(_t, _excluded8);
48398
49223
  _t;
48399
49224
  $[0] = t0;
48400
49225
  $[1] = children;
@@ -48406,7 +49231,7 @@ var Root17 = function(t0) {
48406
49231
  var t1;
48407
49232
  if ($[3] !== children || $[4] !== rest) {
48408
49233
  t1 = /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(Provider6, {
48409
- children: /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(import_themes60.Flex, _objectSpread49(_objectSpread49({
49234
+ children: /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(import_themes60.Flex, _objectSpread51(_objectSpread51({
48410
49235
  direction: "column",
48411
49236
  align: "center",
48412
49237
  justify: "center",
@@ -48433,7 +49258,7 @@ var BarsVisualizer2 = function(t0) {
48433
49258
  var _t2 = t0;
48434
49259
  var ref;
48435
49260
  ref = _t2, t1 = ref.height, t2 = ref.barWidth, ref;
48436
- rest = _objectWithoutProperties6(_t2, _excluded23);
49261
+ rest = _objectWithoutProperties8(_t2, _excluded23);
48437
49262
  _t2;
48438
49263
  $[0] = t0;
48439
49264
  $[1] = rest;
@@ -48451,7 +49276,7 @@ var BarsVisualizer2 = function(t0) {
48451
49276
  var t3 = status === "playing" ? "var(--accent-11)" : "var(--gray-11)";
48452
49277
  var t4;
48453
49278
  if ($[4] !== audioThreadContext.audioRuntime.assistant.visualizationAnalyser || $[5] !== barWidth || $[6] !== height || $[7] !== rest || $[8] !== t3) {
48454
- t4 = /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(BarsVisualizer, _objectSpread49({
49279
+ t4 = /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(BarsVisualizer, _objectSpread51({
48455
49280
  visualizationAnalyser: audioThreadContext.audioRuntime.assistant.visualizationAnalyser,
48456
49281
  backgroundColor: t3,
48457
49282
  height: height,
@@ -48478,7 +49303,7 @@ var AssistantVisualizationRoot = function(t0) {
48478
49303
  var _t3 = t0;
48479
49304
  var ref;
48480
49305
  ref = _t3, children = ref.children, t1 = ref.height, t2 = ref.width, ref;
48481
- rest = _objectWithoutProperties6(_t3, _excluded32);
49306
+ rest = _objectWithoutProperties8(_t3, _excluded32);
48482
49307
  _t3;
48483
49308
  $[0] = t0;
48484
49309
  $[1] = children;
@@ -48507,7 +49332,7 @@ var AssistantVisualizationRoot = function(t0) {
48507
49332
  }
48508
49333
  var t5;
48509
49334
  if ($[7] !== scale || $[8] !== t3 || $[9] !== t4) {
48510
- t5 = _objectSpread49({
49335
+ t5 = _objectSpread51({
48511
49336
  backgroundColor: t3,
48512
49337
  borderRadius: "9999px",
48513
49338
  scale: scale
@@ -48521,7 +49346,7 @@ var AssistantVisualizationRoot = function(t0) {
48521
49346
  }
48522
49347
  var t6;
48523
49348
  if ($[11] !== children || $[12] !== height || $[13] !== rest || $[14] !== t5 || $[15] !== width2) {
48524
- t6 = /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(import_themes60.Flex, _objectSpread49(_objectSpread49({
49349
+ t6 = /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(import_themes60.Flex, _objectSpread51(_objectSpread51({
48525
49350
  align: "center",
48526
49351
  justify: "center",
48527
49352
  height: height,
@@ -48552,7 +49377,7 @@ var AssistantVisualization = function(props) {
48552
49377
  }
48553
49378
  var t1;
48554
49379
  if ($[1] !== props) {
48555
- t1 = /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(AssistantVisualizationRoot, _objectSpread49(_objectSpread49({}, props), {}, {
49380
+ t1 = /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(AssistantVisualizationRoot, _objectSpread51(_objectSpread51({}, props), {}, {
48556
49381
  children: t0
48557
49382
  }));
48558
49383
  $[1] = props;
@@ -48586,7 +49411,7 @@ var AssistantInfo = function(props) {
48586
49411
  }
48587
49412
  var t2;
48588
49413
  if ($[3] !== props || $[4] !== t1) {
48589
- t2 = /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)(import_themes60.Flex, _objectSpread49(_objectSpread49({
49414
+ t2 = /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)(import_themes60.Flex, _objectSpread51(_objectSpread51({
48590
49415
  ml: "-22.5px",
48591
49416
  gap: "3",
48592
49417
  pt: "5"
@@ -48619,7 +49444,7 @@ var Visualization = function(props) {
48619
49444
  }
48620
49445
  var t2;
48621
49446
  if ($[2] !== props) {
48622
- t2 = /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)(Root17, _objectSpread49(_objectSpread49({}, props), {}, {
49447
+ t2 = /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)(Root17, _objectSpread51(_objectSpread51({}, props), {}, {
48623
49448
  children: [
48624
49449
  t0,
48625
49450
  t1
@@ -48709,7 +49534,7 @@ var StatusMessages = function(t0) {
48709
49534
  };
48710
49535
  // src/components/threads/AudioThread/Status/index.tsx
48711
49536
  var import_jsx_runtime92 = require("react/jsx-runtime");
48712
- function ownKeys50(e, r) {
49537
+ function ownKeys52(e, r) {
48713
49538
  var t = Object.keys(e);
48714
49539
  if (Object.getOwnPropertySymbols) {
48715
49540
  var o = Object.getOwnPropertySymbols(e);
@@ -48719,30 +49544,30 @@ function ownKeys50(e, r) {
48719
49544
  }
48720
49545
  return t;
48721
49546
  }
48722
- function _objectSpread50(e) {
49547
+ function _objectSpread52(e) {
48723
49548
  for(var r = 1; r < arguments.length; r++){
48724
49549
  var t = null != arguments[r] ? arguments[r] : {};
48725
- r % 2 ? ownKeys50(Object(t), true).forEach(function(r2) {
48726
- _defineProperty50(e, r2, t[r2]);
48727
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys50(Object(t)).forEach(function(r2) {
49550
+ r % 2 ? ownKeys52(Object(t), true).forEach(function(r2) {
49551
+ _defineProperty52(e, r2, t[r2]);
49552
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys52(Object(t)).forEach(function(r2) {
48728
49553
  Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
48729
49554
  });
48730
49555
  }
48731
49556
  return e;
48732
49557
  }
48733
- function _defineProperty50(e, r, t) {
48734
- return (r = _toPropertyKey50(r)) in e ? Object.defineProperty(e, r, {
49558
+ function _defineProperty52(e, r, t) {
49559
+ return (r = _toPropertyKey52(r)) in e ? Object.defineProperty(e, r, {
48735
49560
  value: t,
48736
49561
  enumerable: true,
48737
49562
  configurable: true,
48738
49563
  writable: true
48739
49564
  }) : e[r] = t, e;
48740
49565
  }
48741
- function _toPropertyKey50(t) {
48742
- var i = _toPrimitive50(t, "string");
49566
+ function _toPropertyKey52(t) {
49567
+ var i = _toPrimitive52(t, "string");
48743
49568
  return "symbol" == (typeof i === "undefined" ? "undefined" : _type_of(i)) ? i : i + "";
48744
49569
  }
48745
- function _toPrimitive50(t, r) {
49570
+ function _toPrimitive52(t, r) {
48746
49571
  if ("object" != (typeof t === "undefined" ? "undefined" : _type_of(t)) || !t) return t;
48747
49572
  var e = t[Symbol.toPrimitive];
48748
49573
  if (void 0 !== e) {
@@ -48770,7 +49595,7 @@ var Status = function(props) {
48770
49595
  }
48771
49596
  var _t2;
48772
49597
  if ($[1] !== props) {
48773
- _t2 = /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(StatusMessages, _objectSpread50({
49598
+ _t2 = /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(StatusMessages, _objectSpread52({
48774
49599
  texts: _t
48775
49600
  }, props));
48776
49601
  $[1] = props;
@@ -48796,7 +49621,7 @@ var Status = function(props) {
48796
49621
  }
48797
49622
  var _t4;
48798
49623
  if ($[4] !== props) {
48799
- _t4 = /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(StatusMessages, _objectSpread50({
49624
+ _t4 = /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(StatusMessages, _objectSpread52({
48800
49625
  texts: _t3
48801
49626
  }, props));
48802
49627
  $[4] = props;
@@ -48818,7 +49643,7 @@ var Status = function(props) {
48818
49643
  }
48819
49644
  var _t6;
48820
49645
  if ($[7] !== props) {
48821
- _t6 = /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(StatusMessages, _objectSpread50({
49646
+ _t6 = /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(StatusMessages, _objectSpread52({
48822
49647
  texts: _t5
48823
49648
  }, props));
48824
49649
  $[7] = props;
@@ -48839,7 +49664,7 @@ var Status = function(props) {
48839
49664
  }
48840
49665
  var t1;
48841
49666
  if ($[10] !== props) {
48842
- t1 = /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(StatusMessages, _objectSpread50({
49667
+ t1 = /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(StatusMessages, _objectSpread52({
48843
49668
  texts: t0
48844
49669
  }, props));
48845
49670
  $[10] = props;
@@ -48855,7 +49680,7 @@ var import_themes63 = require("@radix-ui/themes");
48855
49680
  // src/components/threads/AudioThread/Form/MicIcon.tsx
48856
49681
  var import_react_compiler_runtime95 = require("react-compiler-runtime");
48857
49682
  var import_jsx_runtime93 = require("react/jsx-runtime");
48858
- function ownKeys51(e, r) {
49683
+ function ownKeys53(e, r) {
48859
49684
  var t = Object.keys(e);
48860
49685
  if (Object.getOwnPropertySymbols) {
48861
49686
  var o = Object.getOwnPropertySymbols(e);
@@ -48865,30 +49690,30 @@ function ownKeys51(e, r) {
48865
49690
  }
48866
49691
  return t;
48867
49692
  }
48868
- function _objectSpread51(e) {
49693
+ function _objectSpread53(e) {
48869
49694
  for(var r = 1; r < arguments.length; r++){
48870
49695
  var t = null != arguments[r] ? arguments[r] : {};
48871
- r % 2 ? ownKeys51(Object(t), true).forEach(function(r2) {
48872
- _defineProperty51(e, r2, t[r2]);
48873
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys51(Object(t)).forEach(function(r2) {
49696
+ r % 2 ? ownKeys53(Object(t), true).forEach(function(r2) {
49697
+ _defineProperty53(e, r2, t[r2]);
49698
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys53(Object(t)).forEach(function(r2) {
48874
49699
  Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
48875
49700
  });
48876
49701
  }
48877
49702
  return e;
48878
49703
  }
48879
- function _defineProperty51(e, r, t) {
48880
- return (r = _toPropertyKey51(r)) in e ? Object.defineProperty(e, r, {
49704
+ function _defineProperty53(e, r, t) {
49705
+ return (r = _toPropertyKey53(r)) in e ? Object.defineProperty(e, r, {
48881
49706
  value: t,
48882
49707
  enumerable: true,
48883
49708
  configurable: true,
48884
49709
  writable: true
48885
49710
  }) : e[r] = t, e;
48886
49711
  }
48887
- function _toPropertyKey51(t) {
48888
- var i = _toPrimitive51(t, "string");
49712
+ function _toPropertyKey53(t) {
49713
+ var i = _toPrimitive53(t, "string");
48889
49714
  return "symbol" == (typeof i === "undefined" ? "undefined" : _type_of(i)) ? i : i + "";
48890
49715
  }
48891
- function _toPrimitive51(t, r) {
49716
+ function _toPrimitive53(t, r) {
48892
49717
  if ("object" != (typeof t === "undefined" ? "undefined" : _type_of(t)) || !t) return t;
48893
49718
  var e = t[Symbol.toPrimitive];
48894
49719
  if (void 0 !== e) {
@@ -48912,7 +49737,7 @@ var MicIcon = function(props) {
48912
49737
  }
48913
49738
  var t1;
48914
49739
  if ($[1] !== props) {
48915
- t1 = /* @__PURE__ */ (0, import_jsx_runtime93.jsx)("svg", _objectSpread51(_objectSpread51({
49740
+ t1 = /* @__PURE__ */ (0, import_jsx_runtime93.jsx)("svg", _objectSpread53(_objectSpread53({
48916
49741
  xmlns: "http://www.w3.org/2000/svg",
48917
49742
  fill: "currentColor",
48918
49743
  stroke: "currentColor",
@@ -49130,7 +49955,7 @@ var ActionButton = function() {
49130
49955
  };
49131
49956
  // src/components/threads/AudioThread/Form/index.tsx
49132
49957
  var import_jsx_runtime95 = require("react/jsx-runtime");
49133
- function ownKeys52(e, r) {
49958
+ function ownKeys54(e, r) {
49134
49959
  var t = Object.keys(e);
49135
49960
  if (Object.getOwnPropertySymbols) {
49136
49961
  var o = Object.getOwnPropertySymbols(e);
@@ -49140,30 +49965,30 @@ function ownKeys52(e, r) {
49140
49965
  }
49141
49966
  return t;
49142
49967
  }
49143
- function _objectSpread52(e) {
49968
+ function _objectSpread54(e) {
49144
49969
  for(var r = 1; r < arguments.length; r++){
49145
49970
  var t = null != arguments[r] ? arguments[r] : {};
49146
- r % 2 ? ownKeys52(Object(t), true).forEach(function(r2) {
49147
- _defineProperty52(e, r2, t[r2]);
49148
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys52(Object(t)).forEach(function(r2) {
49971
+ r % 2 ? ownKeys54(Object(t), true).forEach(function(r2) {
49972
+ _defineProperty54(e, r2, t[r2]);
49973
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys54(Object(t)).forEach(function(r2) {
49149
49974
  Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
49150
49975
  });
49151
49976
  }
49152
49977
  return e;
49153
49978
  }
49154
- function _defineProperty52(e, r, t) {
49155
- return (r = _toPropertyKey52(r)) in e ? Object.defineProperty(e, r, {
49979
+ function _defineProperty54(e, r, t) {
49980
+ return (r = _toPropertyKey54(r)) in e ? Object.defineProperty(e, r, {
49156
49981
  value: t,
49157
49982
  enumerable: true,
49158
49983
  configurable: true,
49159
49984
  writable: true
49160
49985
  }) : e[r] = t, e;
49161
49986
  }
49162
- function _toPropertyKey52(t) {
49163
- var i = _toPrimitive52(t, "string");
49987
+ function _toPropertyKey54(t) {
49988
+ var i = _toPrimitive54(t, "string");
49164
49989
  return "symbol" == (typeof i === "undefined" ? "undefined" : _type_of(i)) ? i : i + "";
49165
49990
  }
49166
- function _toPrimitive52(t, r) {
49991
+ function _toPrimitive54(t, r) {
49167
49992
  if ("object" != (typeof t === "undefined" ? "undefined" : _type_of(t)) || !t) return t;
49168
49993
  var e = t[Symbol.toPrimitive];
49169
49994
  if (void 0 !== e) {
@@ -49261,7 +50086,7 @@ var Form = function(props) {
49261
50086
  }
49262
50087
  var t9;
49263
50088
  if ($[14] !== props || $[15] !== t7) {
49264
- t9 = /* @__PURE__ */ (0, import_jsx_runtime95.jsxs)(import_themes63.Flex, _objectSpread52(_objectSpread52({
50089
+ t9 = /* @__PURE__ */ (0, import_jsx_runtime95.jsxs)(import_themes63.Flex, _objectSpread54(_objectSpread54({
49265
50090
  direction: "column",
49266
50091
  align: "center"
49267
50092
  }, props), {}, {
@@ -49280,7 +50105,7 @@ var Form = function(props) {
49280
50105
  };
49281
50106
  // src/components/threads/AudioThread/index.tsx
49282
50107
  var import_jsx_runtime96 = require("react/jsx-runtime");
49283
- function ownKeys53(e, r) {
50108
+ function ownKeys55(e, r) {
49284
50109
  var t = Object.keys(e);
49285
50110
  if (Object.getOwnPropertySymbols) {
49286
50111
  var o = Object.getOwnPropertySymbols(e);
@@ -49290,30 +50115,30 @@ function ownKeys53(e, r) {
49290
50115
  }
49291
50116
  return t;
49292
50117
  }
49293
- function _objectSpread53(e) {
50118
+ function _objectSpread55(e) {
49294
50119
  for(var r = 1; r < arguments.length; r++){
49295
50120
  var t = null != arguments[r] ? arguments[r] : {};
49296
- r % 2 ? ownKeys53(Object(t), true).forEach(function(r2) {
49297
- _defineProperty53(e, r2, t[r2]);
49298
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys53(Object(t)).forEach(function(r2) {
50121
+ r % 2 ? ownKeys55(Object(t), true).forEach(function(r2) {
50122
+ _defineProperty55(e, r2, t[r2]);
50123
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys55(Object(t)).forEach(function(r2) {
49299
50124
  Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
49300
50125
  });
49301
50126
  }
49302
50127
  return e;
49303
50128
  }
49304
- function _defineProperty53(e, r, t) {
49305
- return (r = _toPropertyKey53(r)) in e ? Object.defineProperty(e, r, {
50129
+ function _defineProperty55(e, r, t) {
50130
+ return (r = _toPropertyKey55(r)) in e ? Object.defineProperty(e, r, {
49306
50131
  value: t,
49307
50132
  enumerable: true,
49308
50133
  configurable: true,
49309
50134
  writable: true
49310
50135
  }) : e[r] = t, e;
49311
50136
  }
49312
- function _toPropertyKey53(t) {
49313
- var i = _toPrimitive53(t, "string");
50137
+ function _toPropertyKey55(t) {
50138
+ var i = _toPrimitive55(t, "string");
49314
50139
  return "symbol" == (typeof i === "undefined" ? "undefined" : _type_of(i)) ? i : i + "";
49315
50140
  }
49316
- function _toPrimitive53(t, r) {
50141
+ function _toPrimitive55(t, r) {
49317
50142
  if ("object" != (typeof t === "undefined" ? "undefined" : _type_of(t)) || !t) return t;
49318
50143
  var e = t[Symbol.toPrimitive];
49319
50144
  if (void 0 !== e) {
@@ -49342,7 +50167,7 @@ var AudioThread = function(props) {
49342
50167
  }
49343
50168
  var t3;
49344
50169
  if ($[3] !== props) {
49345
- t3 = /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)(Root16, _objectSpread53(_objectSpread53({}, props), {}, {
50170
+ t3 = /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)(Root16, _objectSpread55(_objectSpread55({}, props), {}, {
49346
50171
  children: [
49347
50172
  t0,
49348
50173
  t1,
@@ -49362,7 +50187,7 @@ AudioThread.Status = Status;
49362
50187
  AudioThread.Form = Form;
49363
50188
  // src/components/threads/AudioThreadDialog/index.tsx
49364
50189
  var import_jsx_runtime97 = require("react/jsx-runtime");
49365
- function ownKeys54(e, r) {
50190
+ function ownKeys56(e, r) {
49366
50191
  var t = Object.keys(e);
49367
50192
  if (Object.getOwnPropertySymbols) {
49368
50193
  var o = Object.getOwnPropertySymbols(e);
@@ -49372,30 +50197,30 @@ function ownKeys54(e, r) {
49372
50197
  }
49373
50198
  return t;
49374
50199
  }
49375
- function _objectSpread54(e) {
50200
+ function _objectSpread56(e) {
49376
50201
  for(var r = 1; r < arguments.length; r++){
49377
50202
  var t = null != arguments[r] ? arguments[r] : {};
49378
- r % 2 ? ownKeys54(Object(t), true).forEach(function(r2) {
49379
- _defineProperty54(e, r2, t[r2]);
49380
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys54(Object(t)).forEach(function(r2) {
50203
+ r % 2 ? ownKeys56(Object(t), true).forEach(function(r2) {
50204
+ _defineProperty56(e, r2, t[r2]);
50205
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys56(Object(t)).forEach(function(r2) {
49381
50206
  Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
49382
50207
  });
49383
50208
  }
49384
50209
  return e;
49385
50210
  }
49386
- function _defineProperty54(e, r, t) {
49387
- return (r = _toPropertyKey54(r)) in e ? Object.defineProperty(e, r, {
50211
+ function _defineProperty56(e, r, t) {
50212
+ return (r = _toPropertyKey56(r)) in e ? Object.defineProperty(e, r, {
49388
50213
  value: t,
49389
50214
  enumerable: true,
49390
50215
  configurable: true,
49391
50216
  writable: true
49392
50217
  }) : e[r] = t, e;
49393
50218
  }
49394
- function _toPropertyKey54(t) {
49395
- var i = _toPrimitive54(t, "string");
50219
+ function _toPropertyKey56(t) {
50220
+ var i = _toPrimitive56(t, "string");
49396
50221
  return "symbol" == (typeof i === "undefined" ? "undefined" : _type_of(i)) ? i : i + "";
49397
50222
  }
49398
- function _toPrimitive54(t, r) {
50223
+ function _toPrimitive56(t, r) {
49399
50224
  if ("object" != (typeof t === "undefined" ? "undefined" : _type_of(t)) || !t) return t;
49400
50225
  var e = t[Symbol.toPrimitive];
49401
50226
  if (void 0 !== e) {
@@ -49422,7 +50247,7 @@ var AudioThreadDialog = function(props) {
49422
50247
  }
49423
50248
  var t2;
49424
50249
  if ($[2] !== props) {
49425
- t2 = /* @__PURE__ */ (0, import_jsx_runtime97.jsxs)(Root13, _objectSpread54(_objectSpread54({}, props), {}, {
50250
+ t2 = /* @__PURE__ */ (0, import_jsx_runtime97.jsxs)(Root13, _objectSpread56(_objectSpread56({}, props), {}, {
49426
50251
  children: [
49427
50252
  t0,
49428
50253
  t1
@@ -49440,7 +50265,7 @@ AudioThreadDialog.Trigger = Trigger;
49440
50265
  AudioThreadDialog.Content = Content8;
49441
50266
  // src/hooks/audioRuntimes/useWebrtcAudioRuntime/index.ts
49442
50267
  var import_react72 = require("react");
49443
- function asyncGeneratorStep12(n, t, e, r, o, a, c) {
50268
+ function asyncGeneratorStep13(n, t, e, r, o, a, c) {
49444
50269
  try {
49445
50270
  var i = n[a](c), u = i.value;
49446
50271
  } catch (n2) {
@@ -49448,16 +50273,16 @@ function asyncGeneratorStep12(n, t, e, r, o, a, c) {
49448
50273
  }
49449
50274
  i.done ? t(u) : Promise.resolve(u).then(r, o);
49450
50275
  }
49451
- function _asyncToGenerator12(n) {
50276
+ function _asyncToGenerator13(n) {
49452
50277
  return function() {
49453
50278
  var t = this, e = arguments;
49454
50279
  return new Promise(function(r, o) {
49455
50280
  var a = n.apply(t, e);
49456
50281
  function _next(n2) {
49457
- asyncGeneratorStep12(a, r, o, _next, _throw, "next", n2);
50282
+ asyncGeneratorStep13(a, r, o, _next, _throw, "next", n2);
49458
50283
  }
49459
50284
  function _throw(n2) {
49460
- asyncGeneratorStep12(a, r, o, _next, _throw, "throw", n2);
50285
+ asyncGeneratorStep13(a, r, o, _next, _throw, "throw", n2);
49461
50286
  }
49462
50287
  _next(void 0);
49463
50288
  });
@@ -49555,7 +50380,7 @@ var useWebrtcAudioRuntime = function() {
49555
50380
  };
49556
50381
  }, []);
49557
50382
  function _startSessionIfNeeded() {
49558
- _startSessionIfNeeded = _asyncToGenerator12(function() {
50383
+ _startSessionIfNeeded = _asyncToGenerator13(function() {
49559
50384
  return _ts_generator(this, function(_state) {
49560
50385
  switch(_state.label){
49561
50386
  case 0:
@@ -49578,7 +50403,7 @@ var useWebrtcAudioRuntime = function() {
49578
50403
  return _startSessionIfNeeded.apply(this, arguments);
49579
50404
  }
49580
50405
  function _initRealtimeSession() {
49581
- _initRealtimeSession = _asyncToGenerator12(function() {
50406
+ _initRealtimeSession = _asyncToGenerator13(function() {
49582
50407
  var peerConn, audioEl, openaiEventsDataChannel, ms, offer, searchParams_0, sdpResponse, answerSdp, answer, err1;
49583
50408
  return _ts_generator(this, function(_state) {
49584
50409
  switch(_state.label){
@@ -49626,7 +50451,7 @@ var useWebrtcAudioRuntime = function() {
49626
50451
  };
49627
50452
  openaiEventsDataChannel = peerConn.createDataChannel("oai-events");
49628
50453
  openaiEventsDataChannel.addEventListener("message", /* @__PURE__ */ function() {
49629
- var _ref8 = _asyncToGenerator12(function(e) {
50454
+ var _ref8 = _asyncToGenerator13(function(e) {
49630
50455
  var parsedData, searchParams, eventsResponse, reader, decoder, _ref, value, done, buffer, lines, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, line, event, ref;
49631
50456
  return _ts_generator(this, function(_state) {
49632
50457
  switch(_state.label){
@@ -49825,7 +50650,7 @@ var useWebrtcAudioRuntime = function() {
49825
50650
  return _initRealtimeSession.apply(this, arguments);
49826
50651
  }
49827
50652
  var start = /* @__PURE__ */ function() {
49828
- var _ref6 = _asyncToGenerator12(function() {
50653
+ var _ref6 = _asyncToGenerator13(function() {
49829
50654
  return _ts_generator(this, function(_state) {
49830
50655
  switch(_state.label){
49831
50656
  case 0:
@@ -49858,7 +50683,7 @@ var useWebrtcAudioRuntime = function() {
49858
50683
  };
49859
50684
  }();
49860
50685
  var pause = /* @__PURE__ */ function() {
49861
- var _ref7 = _asyncToGenerator12(function() {
50686
+ var _ref7 = _asyncToGenerator13(function() {
49862
50687
  return _ts_generator(this, function(_state) {
49863
50688
  if (!sessionStartedRef.current) return [
49864
50689
  2
@@ -49884,7 +50709,7 @@ var useWebrtcAudioRuntime = function() {
49884
50709
  webrtcAudioRuntime: {
49885
50710
  user: {
49886
50711
  start: function() {
49887
- var _start = _asyncToGenerator12(function() {
50712
+ var _start = _asyncToGenerator13(function() {
49888
50713
  return _ts_generator(this, function(_state) {
49889
50714
  return [
49890
50715
  2
@@ -50220,19 +51045,19 @@ function _temp12(rs) {
50220
51045
  var import_react_compiler_runtime104 = require("react-compiler-runtime");
50221
51046
  var import_react76 = require("react");
50222
51047
  var import_jsx_runtime100 = require("react/jsx-runtime");
50223
- var _excluded7 = [
51048
+ var _excluded9 = [
50224
51049
  "children"
50225
51050
  ];
50226
- function _objectWithoutProperties7(e, t) {
51051
+ function _objectWithoutProperties9(e, t) {
50227
51052
  if (null == e) return {};
50228
- var o, r, i = _objectWithoutPropertiesLoose7(e, t);
51053
+ var o, r, i = _objectWithoutPropertiesLoose9(e, t);
50229
51054
  if (Object.getOwnPropertySymbols) {
50230
51055
  var n = Object.getOwnPropertySymbols(e);
50231
51056
  for(r = 0; r < n.length; r++)o = n[r], -1 === t.indexOf(o) && ({}).propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
50232
51057
  }
50233
51058
  return i;
50234
51059
  }
50235
- function _objectWithoutPropertiesLoose7(r, e) {
51060
+ function _objectWithoutPropertiesLoose9(r, e) {
50236
51061
  if (null == r) return {};
50237
51062
  var t = {};
50238
51063
  for(var n in r)if (({}).hasOwnProperty.call(r, n)) {
@@ -50248,7 +51073,7 @@ var MarkdownProvider = function(t0) {
50248
51073
  if ($[0] !== t0) {
50249
51074
  var _t = t0;
50250
51075
  children = _t.children;
50251
- rest = _objectWithoutProperties7(_t, _excluded7);
51076
+ rest = _objectWithoutProperties9(_t, _excluded9);
50252
51077
  _t;
50253
51078
  $[0] = t0;
50254
51079
  $[1] = children;
@@ -50489,19 +51314,19 @@ var FileCitation = function(t0) {
50489
51314
  };
50490
51315
  // src/components/annotations/SourceAnnotation/index.tsx
50491
51316
  var import_jsx_runtime103 = require("react/jsx-runtime");
50492
- var _excluded8 = [
51317
+ var _excluded10 = [
50493
51318
  "children"
50494
51319
  ];
50495
- function _objectWithoutProperties8(e, t) {
51320
+ function _objectWithoutProperties10(e, t) {
50496
51321
  if (null == e) return {};
50497
- var o, r, i = _objectWithoutPropertiesLoose8(e, t);
51322
+ var o, r, i = _objectWithoutPropertiesLoose10(e, t);
50498
51323
  if (Object.getOwnPropertySymbols) {
50499
51324
  var n = Object.getOwnPropertySymbols(e);
50500
51325
  for(r = 0; r < n.length; r++)o = n[r], -1 === t.indexOf(o) && ({}).propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
50501
51326
  }
50502
51327
  return i;
50503
51328
  }
50504
- function _objectWithoutPropertiesLoose8(r, e) {
51329
+ function _objectWithoutPropertiesLoose10(r, e) {
50505
51330
  if (null == r) return {};
50506
51331
  var t = {};
50507
51332
  for(var n in r)if (({}).hasOwnProperty.call(r, n)) {
@@ -50517,7 +51342,7 @@ var SourceAnnotation = function(t0) {
50517
51342
  if ($[0] !== t0) {
50518
51343
  var _t = t0;
50519
51344
  children = _t.children;
50520
- rest = _objectWithoutProperties8(_t, _excluded8);
51345
+ rest = _objectWithoutProperties10(_t, _excluded10);
50521
51346
  _t;
50522
51347
  $[0] = t0;
50523
51348
  $[1] = children;
@@ -50792,19 +51617,19 @@ var Avatar6 = function(t0) {
50792
51617
  var import_react_compiler_runtime111 = require("react-compiler-runtime");
50793
51618
  var import_react79 = require("react");
50794
51619
  var import_jsx_runtime107 = require("react/jsx-runtime");
50795
- var _excluded9 = [
51620
+ var _excluded11 = [
50796
51621
  "children"
50797
51622
  ];
50798
- function _objectWithoutProperties9(e, t) {
51623
+ function _objectWithoutProperties11(e, t) {
50799
51624
  if (null == e) return {};
50800
- var o, r, i = _objectWithoutPropertiesLoose9(e, t);
51625
+ var o, r, i = _objectWithoutPropertiesLoose11(e, t);
50801
51626
  if (Object.getOwnPropertySymbols) {
50802
51627
  var n = Object.getOwnPropertySymbols(e);
50803
51628
  for(r = 0; r < n.length; r++)o = n[r], -1 === t.indexOf(o) && ({}).propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
50804
51629
  }
50805
51630
  return i;
50806
51631
  }
50807
- function _objectWithoutPropertiesLoose9(r, e) {
51632
+ function _objectWithoutPropertiesLoose11(r, e) {
50808
51633
  if (null == r) return {};
50809
51634
  var t = {};
50810
51635
  for(var n in r)if (({}).hasOwnProperty.call(r, n)) {
@@ -50820,7 +51645,7 @@ var ComponentsProvider = function(t0) {
50820
51645
  if ($[0] !== t0) {
50821
51646
  var _t = t0;
50822
51647
  children = _t.children;
50823
- rest = _objectWithoutProperties9(_t, _excluded9);
51648
+ rest = _objectWithoutProperties11(_t, _excluded11);
50824
51649
  _t;
50825
51650
  $[0] = t0;
50826
51651
  $[1] = children;