@superinterface/react 5.3.0-beta.0 → 5.3.0-beta.10

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 = messagesProps.messages.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
+ });
47485
47951
  });
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
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
+ }
47491
48007
  });
47492
48008
  });
47493
- return messageSentences.filter(function(ms) {
47494
- return !playedMessageSentences.find(function(pms) {
47495
- return pms.messageId === ms.messageId && pms.sentence === ms.sentence;
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
+ }
47496
48057
  });
47497
48058
  });
47498
- }, [
47499
- messagesProps,
47500
- playedMessageSentences
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
+ }
48092
+ });
48093
+ });
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,49 +48613,130 @@ 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 = [
@@ -47935,9 +48744,28 @@ var _excluded22 = [
47935
48744
  "play",
47936
48745
  "onEnd",
47937
48746
  "className",
47938
- "style"
48747
+ "style",
48748
+ "playback"
47939
48749
  ];
47940
- function ownKeys48(e, r) {
48750
+ function _objectWithoutProperties7(e, t) {
48751
+ if (null == e) return {};
48752
+ var o, r, i = _objectWithoutPropertiesLoose7(e, t);
48753
+ if (Object.getOwnPropertySymbols) {
48754
+ var n = Object.getOwnPropertySymbols(e);
48755
+ for(r = 0; r < n.length; r++)o = n[r], -1 === t.indexOf(o) && ({}).propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
48756
+ }
48757
+ return i;
48758
+ }
48759
+ function _objectWithoutPropertiesLoose7(r, e) {
48760
+ if (null == r) return {};
48761
+ var t = {};
48762
+ for(var n in r)if (({}).hasOwnProperty.call(r, n)) {
48763
+ if (-1 !== e.indexOf(n)) continue;
48764
+ t[n] = r[n];
48765
+ }
48766
+ return t;
48767
+ }
48768
+ function ownKeys50(e, r) {
47941
48769
  var t = Object.keys(e);
47942
48770
  if (Object.getOwnPropertySymbols) {
47943
48771
  var o = Object.getOwnPropertySymbols(e);
@@ -47947,30 +48775,30 @@ function ownKeys48(e, r) {
47947
48775
  }
47948
48776
  return t;
47949
48777
  }
47950
- function _objectSpread48(e) {
48778
+ function _objectSpread50(e) {
47951
48779
  for(var r = 1; r < arguments.length; r++){
47952
48780
  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) {
48781
+ r % 2 ? ownKeys50(Object(t), true).forEach(function(r2) {
48782
+ _defineProperty50(e, r2, t[r2]);
48783
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys50(Object(t)).forEach(function(r2) {
47956
48784
  Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
47957
48785
  });
47958
48786
  }
47959
48787
  return e;
47960
48788
  }
47961
- function _defineProperty48(e, r, t) {
47962
- return (r = _toPropertyKey48(r)) in e ? Object.defineProperty(e, r, {
48789
+ function _defineProperty50(e, r, t) {
48790
+ return (r = _toPropertyKey50(r)) in e ? Object.defineProperty(e, r, {
47963
48791
  value: t,
47964
48792
  enumerable: true,
47965
48793
  configurable: true,
47966
48794
  writable: true
47967
48795
  }) : e[r] = t, e;
47968
48796
  }
47969
- function _toPropertyKey48(t) {
47970
- var i = _toPrimitive48(t, "string");
48797
+ function _toPropertyKey50(t) {
48798
+ var i = _toPrimitive50(t, "string");
47971
48799
  return "symbol" == (typeof i === "undefined" ? "undefined" : _type_of(i)) ? i : i + "";
47972
48800
  }
47973
- function _toPrimitive48(t, r) {
48801
+ function _toPrimitive50(t, r) {
47974
48802
  if ("object" != (typeof t === "undefined" ? "undefined" : _type_of(t)) || !t) return t;
47975
48803
  var e = t[Symbol.toPrimitive];
47976
48804
  if (void 0 !== e) {
@@ -47980,24 +48808,6 @@ function _toPrimitive48(t, r) {
47980
48808
  }
47981
48809
  return ("string" === r ? String : Number)(t);
47982
48810
  }
47983
- function _objectWithoutProperties5(e, t) {
47984
- if (null == e) return {};
47985
- var o, r, i = _objectWithoutPropertiesLoose5(e, t);
47986
- if (Object.getOwnPropertySymbols) {
47987
- var n = Object.getOwnPropertySymbols(e);
47988
- for(r = 0; r < n.length; r++)o = n[r], -1 === t.indexOf(o) && ({}).propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
47989
- }
47990
- return i;
47991
- }
47992
- function _objectWithoutPropertiesLoose5(r, e) {
47993
- if (null == r) return {};
47994
- var t = {};
47995
- for(var n in r)if (({}).hasOwnProperty.call(r, n)) {
47996
- if (-1 !== e.indexOf(n)) continue;
47997
- t[n] = r[n];
47998
- }
47999
- return t;
48000
- }
48001
48811
  var Content9 = function(t0) {
48002
48812
  var $ = (0, import_react_compiler_runtime90.c)(4);
48003
48813
  var children = t0.children, className = t0.className, style = t0.style;
@@ -48021,27 +48831,35 @@ var Content9 = function(t0) {
48021
48831
  return t1;
48022
48832
  };
48023
48833
  var AudioRuntimeProvider = function(t0) {
48024
- var $ = (0, import_react_compiler_runtime90.c)(4);
48025
- var children = t0.children, play = t0.play, onEnd = t0.onEnd;
48834
+ var $ = (0, import_react_compiler_runtime90.c)(6);
48835
+ var children = t0.children, onEnd = t0.onEnd, playback = t0.playback;
48026
48836
  var audioThreadContext = useAudioThreadContext();
48027
48837
  if (audioThreadContext.audioRuntime) {
48028
48838
  return children;
48029
48839
  }
48030
48840
  var t1;
48031
- if ($[0] !== children || $[1] !== onEnd || $[2] !== play) {
48032
- t1 = /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(TtsAudioRuntimeProvider, {
48033
- play: play,
48034
- onEnd: onEnd,
48841
+ if ($[0] !== playback) {
48842
+ t1 = playback !== null && playback !== void 0 ? playback : {};
48843
+ $[0] = playback;
48844
+ $[1] = t1;
48845
+ } else {
48846
+ t1 = $[1];
48847
+ }
48848
+ var t2;
48849
+ if ($[2] !== children || $[3] !== onEnd || $[4] !== t1) {
48850
+ t2 = /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(TtsAudioRuntimeProvider, _objectSpread50(_objectSpread50({
48851
+ onEnd: onEnd
48852
+ }, t1), {}, {
48035
48853
  children: children
48036
- });
48037
- $[0] = children;
48038
- $[1] = onEnd;
48039
- $[2] = play;
48040
- $[3] = t1;
48854
+ }));
48855
+ $[2] = children;
48856
+ $[3] = onEnd;
48857
+ $[4] = t1;
48858
+ $[5] = t2;
48041
48859
  } else {
48042
- t1 = $[3];
48860
+ t2 = $[5];
48043
48861
  }
48044
- return t1;
48862
+ return t2;
48045
48863
  };
48046
48864
  var Provider5 = function(t0) {
48047
48865
  var $ = (0, import_react_compiler_runtime90.c)(9);
@@ -48050,7 +48868,7 @@ var Provider5 = function(t0) {
48050
48868
  if ($[0] !== t0) {
48051
48869
  var _t = t0;
48052
48870
  children = _t.children;
48053
- rest = _objectWithoutProperties5(_t, _excluded5);
48871
+ rest = _objectWithoutProperties7(_t, _excluded7);
48054
48872
  _t;
48055
48873
  $[0] = t0;
48056
48874
  $[1] = children;
@@ -48062,7 +48880,7 @@ var Provider5 = function(t0) {
48062
48880
  var audioThreadContext = useAudioThreadContext();
48063
48881
  var t1;
48064
48882
  if ($[3] !== audioThreadContext || $[4] !== rest) {
48065
- t1 = _objectSpread48(_objectSpread48({}, audioThreadContext), rest);
48883
+ t1 = _objectSpread50(_objectSpread50({}, audioThreadContext), rest);
48066
48884
  $[3] = audioThreadContext;
48067
48885
  $[4] = rest;
48068
48886
  $[5] = t1;
@@ -48084,76 +48902,91 @@ var Provider5 = function(t0) {
48084
48902
  return t2;
48085
48903
  };
48086
48904
  var Root16 = function(t0) {
48087
- var $ = (0, import_react_compiler_runtime90.c)(18);
48905
+ var $ = (0, import_react_compiler_runtime90.c)(22);
48088
48906
  var children;
48089
48907
  var className;
48090
48908
  var onEnd;
48091
48909
  var play;
48910
+ var playback;
48092
48911
  var rest;
48093
48912
  var style;
48094
48913
  if ($[0] !== t0) {
48095
48914
  var _t2 = t0;
48096
48915
  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);
48916
+ ref = _t2, children = ref.children, play = ref.play, onEnd = ref.onEnd, className = ref.className, style = ref.style, playback = ref.playback, ref;
48917
+ rest = _objectWithoutProperties7(_t2, _excluded22);
48099
48918
  _t2;
48100
48919
  $[0] = t0;
48101
48920
  $[1] = children;
48102
48921
  $[2] = className;
48103
48922
  $[3] = onEnd;
48104
48923
  $[4] = play;
48105
- $[5] = rest;
48106
- $[6] = style;
48924
+ $[5] = playback;
48925
+ $[6] = rest;
48926
+ $[7] = style;
48107
48927
  } else {
48108
48928
  children = $[1];
48109
48929
  className = $[2];
48110
48930
  onEnd = $[3];
48111
48931
  play = $[4];
48112
- rest = $[5];
48113
- style = $[6];
48932
+ playback = $[5];
48933
+ rest = $[6];
48934
+ style = $[7];
48114
48935
  }
48115
48936
  var t1;
48116
- if ($[7] !== children || $[8] !== className || $[9] !== style) {
48117
- t1 = /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(ToastsProvider, {
48118
- children: /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(Content9, {
48119
- className: className,
48120
- style: style,
48121
- children: children
48122
- })
48123
- });
48124
- $[7] = children;
48125
- $[8] = className;
48126
- $[9] = style;
48937
+ if ($[8] !== play || $[9] !== playback) {
48938
+ t1 = playback !== null && playback !== void 0 ? playback : play ? {
48939
+ play: play
48940
+ } : void 0;
48941
+ $[8] = play;
48942
+ $[9] = playback;
48127
48943
  $[10] = t1;
48128
48944
  } else {
48129
48945
  t1 = $[10];
48130
48946
  }
48947
+ var playbackOverrides = t1;
48131
48948
  var t2;
48132
- if ($[11] !== onEnd || $[12] !== play || $[13] !== t1) {
48133
- t2 = /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(AudioRuntimeProvider, {
48134
- play: play,
48135
- onEnd: onEnd,
48136
- children: t1
48949
+ if ($[11] !== children || $[12] !== className || $[13] !== style) {
48950
+ t2 = /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(ToastsProvider, {
48951
+ children: /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(Content9, {
48952
+ className: className,
48953
+ style: style,
48954
+ children: children
48955
+ })
48137
48956
  });
48138
- $[11] = onEnd;
48139
- $[12] = play;
48140
- $[13] = t1;
48957
+ $[11] = children;
48958
+ $[12] = className;
48959
+ $[13] = style;
48141
48960
  $[14] = t2;
48142
48961
  } else {
48143
48962
  t2 = $[14];
48144
48963
  }
48145
48964
  var t3;
48146
- if ($[15] !== rest || $[16] !== t2) {
48147
- t3 = /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(Provider5, _objectSpread48(_objectSpread48({}, rest), {}, {
48965
+ if ($[15] !== onEnd || $[16] !== playbackOverrides || $[17] !== t2) {
48966
+ t3 = /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(AudioRuntimeProvider, {
48967
+ onEnd: onEnd,
48968
+ playback: playbackOverrides,
48148
48969
  children: t2
48970
+ });
48971
+ $[15] = onEnd;
48972
+ $[16] = playbackOverrides;
48973
+ $[17] = t2;
48974
+ $[18] = t3;
48975
+ } else {
48976
+ t3 = $[18];
48977
+ }
48978
+ var t4;
48979
+ if ($[19] !== rest || $[20] !== t3) {
48980
+ t4 = /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(Provider5, _objectSpread50(_objectSpread50({}, rest), {}, {
48981
+ children: t3
48149
48982
  }));
48150
- $[15] = rest;
48151
- $[16] = t2;
48152
- $[17] = t3;
48983
+ $[19] = rest;
48984
+ $[20] = t3;
48985
+ $[21] = t4;
48153
48986
  } else {
48154
- t3 = $[17];
48987
+ t4 = $[21];
48155
48988
  }
48156
- return t3;
48989
+ return t4;
48157
48990
  };
48158
48991
  // src/components/threads/AudioThread/Visualization/index.tsx
48159
48992
  var import_react_compiler_runtime92 = require("react-compiler-runtime");
@@ -48277,7 +49110,7 @@ var useStatus = function() {
48277
49110
  };
48278
49111
  // src/components/threads/AudioThread/Visualization/index.tsx
48279
49112
  var import_jsx_runtime90 = require("react/jsx-runtime");
48280
- var _excluded6 = [
49113
+ var _excluded8 = [
48281
49114
  "children"
48282
49115
  ];
48283
49116
  var _excluded23 = [
@@ -48289,7 +49122,7 @@ var _excluded32 = [
48289
49122
  "height",
48290
49123
  "width"
48291
49124
  ];
48292
- function ownKeys49(e, r) {
49125
+ function ownKeys51(e, r) {
48293
49126
  var t = Object.keys(e);
48294
49127
  if (Object.getOwnPropertySymbols) {
48295
49128
  var o = Object.getOwnPropertySymbols(e);
@@ -48299,30 +49132,30 @@ function ownKeys49(e, r) {
48299
49132
  }
48300
49133
  return t;
48301
49134
  }
48302
- function _objectSpread49(e) {
49135
+ function _objectSpread51(e) {
48303
49136
  for(var r = 1; r < arguments.length; r++){
48304
49137
  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) {
49138
+ r % 2 ? ownKeys51(Object(t), true).forEach(function(r2) {
49139
+ _defineProperty51(e, r2, t[r2]);
49140
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys51(Object(t)).forEach(function(r2) {
48308
49141
  Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
48309
49142
  });
48310
49143
  }
48311
49144
  return e;
48312
49145
  }
48313
- function _defineProperty49(e, r, t) {
48314
- return (r = _toPropertyKey49(r)) in e ? Object.defineProperty(e, r, {
49146
+ function _defineProperty51(e, r, t) {
49147
+ return (r = _toPropertyKey51(r)) in e ? Object.defineProperty(e, r, {
48315
49148
  value: t,
48316
49149
  enumerable: true,
48317
49150
  configurable: true,
48318
49151
  writable: true
48319
49152
  }) : e[r] = t, e;
48320
49153
  }
48321
- function _toPropertyKey49(t) {
48322
- var i = _toPrimitive49(t, "string");
49154
+ function _toPropertyKey51(t) {
49155
+ var i = _toPrimitive51(t, "string");
48323
49156
  return "symbol" == (typeof i === "undefined" ? "undefined" : _type_of(i)) ? i : i + "";
48324
49157
  }
48325
- function _toPrimitive49(t, r) {
49158
+ function _toPrimitive51(t, r) {
48326
49159
  if ("object" != (typeof t === "undefined" ? "undefined" : _type_of(t)) || !t) return t;
48327
49160
  var e = t[Symbol.toPrimitive];
48328
49161
  if (void 0 !== e) {
@@ -48332,16 +49165,16 @@ function _toPrimitive49(t, r) {
48332
49165
  }
48333
49166
  return ("string" === r ? String : Number)(t);
48334
49167
  }
48335
- function _objectWithoutProperties6(e, t) {
49168
+ function _objectWithoutProperties8(e, t) {
48336
49169
  if (null == e) return {};
48337
- var o, r, i = _objectWithoutPropertiesLoose6(e, t);
49170
+ var o, r, i = _objectWithoutPropertiesLoose8(e, t);
48338
49171
  if (Object.getOwnPropertySymbols) {
48339
49172
  var n = Object.getOwnPropertySymbols(e);
48340
49173
  for(r = 0; r < n.length; r++)o = n[r], -1 === t.indexOf(o) && ({}).propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
48341
49174
  }
48342
49175
  return i;
48343
49176
  }
48344
- function _objectWithoutPropertiesLoose6(r, e) {
49177
+ function _objectWithoutPropertiesLoose8(r, e) {
48345
49178
  if (null == r) return {};
48346
49179
  var t = {};
48347
49180
  for(var n in r)if (({}).hasOwnProperty.call(r, n)) {
@@ -48394,7 +49227,7 @@ var Root17 = function(t0) {
48394
49227
  if ($[0] !== t0) {
48395
49228
  var _t = t0;
48396
49229
  children = _t.children;
48397
- rest = _objectWithoutProperties6(_t, _excluded6);
49230
+ rest = _objectWithoutProperties8(_t, _excluded8);
48398
49231
  _t;
48399
49232
  $[0] = t0;
48400
49233
  $[1] = children;
@@ -48406,7 +49239,7 @@ var Root17 = function(t0) {
48406
49239
  var t1;
48407
49240
  if ($[3] !== children || $[4] !== rest) {
48408
49241
  t1 = /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(Provider6, {
48409
- children: /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(import_themes60.Flex, _objectSpread49(_objectSpread49({
49242
+ children: /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(import_themes60.Flex, _objectSpread51(_objectSpread51({
48410
49243
  direction: "column",
48411
49244
  align: "center",
48412
49245
  justify: "center",
@@ -48433,7 +49266,7 @@ var BarsVisualizer2 = function(t0) {
48433
49266
  var _t2 = t0;
48434
49267
  var ref;
48435
49268
  ref = _t2, t1 = ref.height, t2 = ref.barWidth, ref;
48436
- rest = _objectWithoutProperties6(_t2, _excluded23);
49269
+ rest = _objectWithoutProperties8(_t2, _excluded23);
48437
49270
  _t2;
48438
49271
  $[0] = t0;
48439
49272
  $[1] = rest;
@@ -48451,7 +49284,7 @@ var BarsVisualizer2 = function(t0) {
48451
49284
  var t3 = status === "playing" ? "var(--accent-11)" : "var(--gray-11)";
48452
49285
  var t4;
48453
49286
  if ($[4] !== audioThreadContext.audioRuntime.assistant.visualizationAnalyser || $[5] !== barWidth || $[6] !== height || $[7] !== rest || $[8] !== t3) {
48454
- t4 = /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(BarsVisualizer, _objectSpread49({
49287
+ t4 = /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(BarsVisualizer, _objectSpread51({
48455
49288
  visualizationAnalyser: audioThreadContext.audioRuntime.assistant.visualizationAnalyser,
48456
49289
  backgroundColor: t3,
48457
49290
  height: height,
@@ -48478,7 +49311,7 @@ var AssistantVisualizationRoot = function(t0) {
48478
49311
  var _t3 = t0;
48479
49312
  var ref;
48480
49313
  ref = _t3, children = ref.children, t1 = ref.height, t2 = ref.width, ref;
48481
- rest = _objectWithoutProperties6(_t3, _excluded32);
49314
+ rest = _objectWithoutProperties8(_t3, _excluded32);
48482
49315
  _t3;
48483
49316
  $[0] = t0;
48484
49317
  $[1] = children;
@@ -48507,7 +49340,7 @@ var AssistantVisualizationRoot = function(t0) {
48507
49340
  }
48508
49341
  var t5;
48509
49342
  if ($[7] !== scale || $[8] !== t3 || $[9] !== t4) {
48510
- t5 = _objectSpread49({
49343
+ t5 = _objectSpread51({
48511
49344
  backgroundColor: t3,
48512
49345
  borderRadius: "9999px",
48513
49346
  scale: scale
@@ -48521,7 +49354,7 @@ var AssistantVisualizationRoot = function(t0) {
48521
49354
  }
48522
49355
  var t6;
48523
49356
  if ($[11] !== children || $[12] !== height || $[13] !== rest || $[14] !== t5 || $[15] !== width2) {
48524
- t6 = /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(import_themes60.Flex, _objectSpread49(_objectSpread49({
49357
+ t6 = /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(import_themes60.Flex, _objectSpread51(_objectSpread51({
48525
49358
  align: "center",
48526
49359
  justify: "center",
48527
49360
  height: height,
@@ -48552,7 +49385,7 @@ var AssistantVisualization = function(props) {
48552
49385
  }
48553
49386
  var t1;
48554
49387
  if ($[1] !== props) {
48555
- t1 = /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(AssistantVisualizationRoot, _objectSpread49(_objectSpread49({}, props), {}, {
49388
+ t1 = /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(AssistantVisualizationRoot, _objectSpread51(_objectSpread51({}, props), {}, {
48556
49389
  children: t0
48557
49390
  }));
48558
49391
  $[1] = props;
@@ -48586,7 +49419,7 @@ var AssistantInfo = function(props) {
48586
49419
  }
48587
49420
  var t2;
48588
49421
  if ($[3] !== props || $[4] !== t1) {
48589
- t2 = /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)(import_themes60.Flex, _objectSpread49(_objectSpread49({
49422
+ t2 = /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)(import_themes60.Flex, _objectSpread51(_objectSpread51({
48590
49423
  ml: "-22.5px",
48591
49424
  gap: "3",
48592
49425
  pt: "5"
@@ -48619,7 +49452,7 @@ var Visualization = function(props) {
48619
49452
  }
48620
49453
  var t2;
48621
49454
  if ($[2] !== props) {
48622
- t2 = /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)(Root17, _objectSpread49(_objectSpread49({}, props), {}, {
49455
+ t2 = /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)(Root17, _objectSpread51(_objectSpread51({}, props), {}, {
48623
49456
  children: [
48624
49457
  t0,
48625
49458
  t1
@@ -48709,7 +49542,7 @@ var StatusMessages = function(t0) {
48709
49542
  };
48710
49543
  // src/components/threads/AudioThread/Status/index.tsx
48711
49544
  var import_jsx_runtime92 = require("react/jsx-runtime");
48712
- function ownKeys50(e, r) {
49545
+ function ownKeys52(e, r) {
48713
49546
  var t = Object.keys(e);
48714
49547
  if (Object.getOwnPropertySymbols) {
48715
49548
  var o = Object.getOwnPropertySymbols(e);
@@ -48719,30 +49552,30 @@ function ownKeys50(e, r) {
48719
49552
  }
48720
49553
  return t;
48721
49554
  }
48722
- function _objectSpread50(e) {
49555
+ function _objectSpread52(e) {
48723
49556
  for(var r = 1; r < arguments.length; r++){
48724
49557
  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) {
49558
+ r % 2 ? ownKeys52(Object(t), true).forEach(function(r2) {
49559
+ _defineProperty52(e, r2, t[r2]);
49560
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys52(Object(t)).forEach(function(r2) {
48728
49561
  Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
48729
49562
  });
48730
49563
  }
48731
49564
  return e;
48732
49565
  }
48733
- function _defineProperty50(e, r, t) {
48734
- return (r = _toPropertyKey50(r)) in e ? Object.defineProperty(e, r, {
49566
+ function _defineProperty52(e, r, t) {
49567
+ return (r = _toPropertyKey52(r)) in e ? Object.defineProperty(e, r, {
48735
49568
  value: t,
48736
49569
  enumerable: true,
48737
49570
  configurable: true,
48738
49571
  writable: true
48739
49572
  }) : e[r] = t, e;
48740
49573
  }
48741
- function _toPropertyKey50(t) {
48742
- var i = _toPrimitive50(t, "string");
49574
+ function _toPropertyKey52(t) {
49575
+ var i = _toPrimitive52(t, "string");
48743
49576
  return "symbol" == (typeof i === "undefined" ? "undefined" : _type_of(i)) ? i : i + "";
48744
49577
  }
48745
- function _toPrimitive50(t, r) {
49578
+ function _toPrimitive52(t, r) {
48746
49579
  if ("object" != (typeof t === "undefined" ? "undefined" : _type_of(t)) || !t) return t;
48747
49580
  var e = t[Symbol.toPrimitive];
48748
49581
  if (void 0 !== e) {
@@ -48770,7 +49603,7 @@ var Status = function(props) {
48770
49603
  }
48771
49604
  var _t2;
48772
49605
  if ($[1] !== props) {
48773
- _t2 = /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(StatusMessages, _objectSpread50({
49606
+ _t2 = /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(StatusMessages, _objectSpread52({
48774
49607
  texts: _t
48775
49608
  }, props));
48776
49609
  $[1] = props;
@@ -48796,7 +49629,7 @@ var Status = function(props) {
48796
49629
  }
48797
49630
  var _t4;
48798
49631
  if ($[4] !== props) {
48799
- _t4 = /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(StatusMessages, _objectSpread50({
49632
+ _t4 = /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(StatusMessages, _objectSpread52({
48800
49633
  texts: _t3
48801
49634
  }, props));
48802
49635
  $[4] = props;
@@ -48818,7 +49651,7 @@ var Status = function(props) {
48818
49651
  }
48819
49652
  var _t6;
48820
49653
  if ($[7] !== props) {
48821
- _t6 = /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(StatusMessages, _objectSpread50({
49654
+ _t6 = /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(StatusMessages, _objectSpread52({
48822
49655
  texts: _t5
48823
49656
  }, props));
48824
49657
  $[7] = props;
@@ -48839,7 +49672,7 @@ var Status = function(props) {
48839
49672
  }
48840
49673
  var t1;
48841
49674
  if ($[10] !== props) {
48842
- t1 = /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(StatusMessages, _objectSpread50({
49675
+ t1 = /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(StatusMessages, _objectSpread52({
48843
49676
  texts: t0
48844
49677
  }, props));
48845
49678
  $[10] = props;
@@ -48855,7 +49688,7 @@ var import_themes63 = require("@radix-ui/themes");
48855
49688
  // src/components/threads/AudioThread/Form/MicIcon.tsx
48856
49689
  var import_react_compiler_runtime95 = require("react-compiler-runtime");
48857
49690
  var import_jsx_runtime93 = require("react/jsx-runtime");
48858
- function ownKeys51(e, r) {
49691
+ function ownKeys53(e, r) {
48859
49692
  var t = Object.keys(e);
48860
49693
  if (Object.getOwnPropertySymbols) {
48861
49694
  var o = Object.getOwnPropertySymbols(e);
@@ -48865,30 +49698,30 @@ function ownKeys51(e, r) {
48865
49698
  }
48866
49699
  return t;
48867
49700
  }
48868
- function _objectSpread51(e) {
49701
+ function _objectSpread53(e) {
48869
49702
  for(var r = 1; r < arguments.length; r++){
48870
49703
  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) {
49704
+ r % 2 ? ownKeys53(Object(t), true).forEach(function(r2) {
49705
+ _defineProperty53(e, r2, t[r2]);
49706
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys53(Object(t)).forEach(function(r2) {
48874
49707
  Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
48875
49708
  });
48876
49709
  }
48877
49710
  return e;
48878
49711
  }
48879
- function _defineProperty51(e, r, t) {
48880
- return (r = _toPropertyKey51(r)) in e ? Object.defineProperty(e, r, {
49712
+ function _defineProperty53(e, r, t) {
49713
+ return (r = _toPropertyKey53(r)) in e ? Object.defineProperty(e, r, {
48881
49714
  value: t,
48882
49715
  enumerable: true,
48883
49716
  configurable: true,
48884
49717
  writable: true
48885
49718
  }) : e[r] = t, e;
48886
49719
  }
48887
- function _toPropertyKey51(t) {
48888
- var i = _toPrimitive51(t, "string");
49720
+ function _toPropertyKey53(t) {
49721
+ var i = _toPrimitive53(t, "string");
48889
49722
  return "symbol" == (typeof i === "undefined" ? "undefined" : _type_of(i)) ? i : i + "";
48890
49723
  }
48891
- function _toPrimitive51(t, r) {
49724
+ function _toPrimitive53(t, r) {
48892
49725
  if ("object" != (typeof t === "undefined" ? "undefined" : _type_of(t)) || !t) return t;
48893
49726
  var e = t[Symbol.toPrimitive];
48894
49727
  if (void 0 !== e) {
@@ -48912,7 +49745,7 @@ var MicIcon = function(props) {
48912
49745
  }
48913
49746
  var t1;
48914
49747
  if ($[1] !== props) {
48915
- t1 = /* @__PURE__ */ (0, import_jsx_runtime93.jsx)("svg", _objectSpread51(_objectSpread51({
49748
+ t1 = /* @__PURE__ */ (0, import_jsx_runtime93.jsx)("svg", _objectSpread53(_objectSpread53({
48916
49749
  xmlns: "http://www.w3.org/2000/svg",
48917
49750
  fill: "currentColor",
48918
49751
  stroke: "currentColor",
@@ -49130,7 +49963,7 @@ var ActionButton = function() {
49130
49963
  };
49131
49964
  // src/components/threads/AudioThread/Form/index.tsx
49132
49965
  var import_jsx_runtime95 = require("react/jsx-runtime");
49133
- function ownKeys52(e, r) {
49966
+ function ownKeys54(e, r) {
49134
49967
  var t = Object.keys(e);
49135
49968
  if (Object.getOwnPropertySymbols) {
49136
49969
  var o = Object.getOwnPropertySymbols(e);
@@ -49140,30 +49973,30 @@ function ownKeys52(e, r) {
49140
49973
  }
49141
49974
  return t;
49142
49975
  }
49143
- function _objectSpread52(e) {
49976
+ function _objectSpread54(e) {
49144
49977
  for(var r = 1; r < arguments.length; r++){
49145
49978
  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) {
49979
+ r % 2 ? ownKeys54(Object(t), true).forEach(function(r2) {
49980
+ _defineProperty54(e, r2, t[r2]);
49981
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys54(Object(t)).forEach(function(r2) {
49149
49982
  Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
49150
49983
  });
49151
49984
  }
49152
49985
  return e;
49153
49986
  }
49154
- function _defineProperty52(e, r, t) {
49155
- return (r = _toPropertyKey52(r)) in e ? Object.defineProperty(e, r, {
49987
+ function _defineProperty54(e, r, t) {
49988
+ return (r = _toPropertyKey54(r)) in e ? Object.defineProperty(e, r, {
49156
49989
  value: t,
49157
49990
  enumerable: true,
49158
49991
  configurable: true,
49159
49992
  writable: true
49160
49993
  }) : e[r] = t, e;
49161
49994
  }
49162
- function _toPropertyKey52(t) {
49163
- var i = _toPrimitive52(t, "string");
49995
+ function _toPropertyKey54(t) {
49996
+ var i = _toPrimitive54(t, "string");
49164
49997
  return "symbol" == (typeof i === "undefined" ? "undefined" : _type_of(i)) ? i : i + "";
49165
49998
  }
49166
- function _toPrimitive52(t, r) {
49999
+ function _toPrimitive54(t, r) {
49167
50000
  if ("object" != (typeof t === "undefined" ? "undefined" : _type_of(t)) || !t) return t;
49168
50001
  var e = t[Symbol.toPrimitive];
49169
50002
  if (void 0 !== e) {
@@ -49261,7 +50094,7 @@ var Form = function(props) {
49261
50094
  }
49262
50095
  var t9;
49263
50096
  if ($[14] !== props || $[15] !== t7) {
49264
- t9 = /* @__PURE__ */ (0, import_jsx_runtime95.jsxs)(import_themes63.Flex, _objectSpread52(_objectSpread52({
50097
+ t9 = /* @__PURE__ */ (0, import_jsx_runtime95.jsxs)(import_themes63.Flex, _objectSpread54(_objectSpread54({
49265
50098
  direction: "column",
49266
50099
  align: "center"
49267
50100
  }, props), {}, {
@@ -49280,7 +50113,7 @@ var Form = function(props) {
49280
50113
  };
49281
50114
  // src/components/threads/AudioThread/index.tsx
49282
50115
  var import_jsx_runtime96 = require("react/jsx-runtime");
49283
- function ownKeys53(e, r) {
50116
+ function ownKeys55(e, r) {
49284
50117
  var t = Object.keys(e);
49285
50118
  if (Object.getOwnPropertySymbols) {
49286
50119
  var o = Object.getOwnPropertySymbols(e);
@@ -49290,30 +50123,30 @@ function ownKeys53(e, r) {
49290
50123
  }
49291
50124
  return t;
49292
50125
  }
49293
- function _objectSpread53(e) {
50126
+ function _objectSpread55(e) {
49294
50127
  for(var r = 1; r < arguments.length; r++){
49295
50128
  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) {
50129
+ r % 2 ? ownKeys55(Object(t), true).forEach(function(r2) {
50130
+ _defineProperty55(e, r2, t[r2]);
50131
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys55(Object(t)).forEach(function(r2) {
49299
50132
  Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
49300
50133
  });
49301
50134
  }
49302
50135
  return e;
49303
50136
  }
49304
- function _defineProperty53(e, r, t) {
49305
- return (r = _toPropertyKey53(r)) in e ? Object.defineProperty(e, r, {
50137
+ function _defineProperty55(e, r, t) {
50138
+ return (r = _toPropertyKey55(r)) in e ? Object.defineProperty(e, r, {
49306
50139
  value: t,
49307
50140
  enumerable: true,
49308
50141
  configurable: true,
49309
50142
  writable: true
49310
50143
  }) : e[r] = t, e;
49311
50144
  }
49312
- function _toPropertyKey53(t) {
49313
- var i = _toPrimitive53(t, "string");
50145
+ function _toPropertyKey55(t) {
50146
+ var i = _toPrimitive55(t, "string");
49314
50147
  return "symbol" == (typeof i === "undefined" ? "undefined" : _type_of(i)) ? i : i + "";
49315
50148
  }
49316
- function _toPrimitive53(t, r) {
50149
+ function _toPrimitive55(t, r) {
49317
50150
  if ("object" != (typeof t === "undefined" ? "undefined" : _type_of(t)) || !t) return t;
49318
50151
  var e = t[Symbol.toPrimitive];
49319
50152
  if (void 0 !== e) {
@@ -49342,7 +50175,7 @@ var AudioThread = function(props) {
49342
50175
  }
49343
50176
  var t3;
49344
50177
  if ($[3] !== props) {
49345
- t3 = /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)(Root16, _objectSpread53(_objectSpread53({}, props), {}, {
50178
+ t3 = /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)(Root16, _objectSpread55(_objectSpread55({}, props), {}, {
49346
50179
  children: [
49347
50180
  t0,
49348
50181
  t1,
@@ -49362,7 +50195,7 @@ AudioThread.Status = Status;
49362
50195
  AudioThread.Form = Form;
49363
50196
  // src/components/threads/AudioThreadDialog/index.tsx
49364
50197
  var import_jsx_runtime97 = require("react/jsx-runtime");
49365
- function ownKeys54(e, r) {
50198
+ function ownKeys56(e, r) {
49366
50199
  var t = Object.keys(e);
49367
50200
  if (Object.getOwnPropertySymbols) {
49368
50201
  var o = Object.getOwnPropertySymbols(e);
@@ -49372,30 +50205,30 @@ function ownKeys54(e, r) {
49372
50205
  }
49373
50206
  return t;
49374
50207
  }
49375
- function _objectSpread54(e) {
50208
+ function _objectSpread56(e) {
49376
50209
  for(var r = 1; r < arguments.length; r++){
49377
50210
  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) {
50211
+ r % 2 ? ownKeys56(Object(t), true).forEach(function(r2) {
50212
+ _defineProperty56(e, r2, t[r2]);
50213
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys56(Object(t)).forEach(function(r2) {
49381
50214
  Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
49382
50215
  });
49383
50216
  }
49384
50217
  return e;
49385
50218
  }
49386
- function _defineProperty54(e, r, t) {
49387
- return (r = _toPropertyKey54(r)) in e ? Object.defineProperty(e, r, {
50219
+ function _defineProperty56(e, r, t) {
50220
+ return (r = _toPropertyKey56(r)) in e ? Object.defineProperty(e, r, {
49388
50221
  value: t,
49389
50222
  enumerable: true,
49390
50223
  configurable: true,
49391
50224
  writable: true
49392
50225
  }) : e[r] = t, e;
49393
50226
  }
49394
- function _toPropertyKey54(t) {
49395
- var i = _toPrimitive54(t, "string");
50227
+ function _toPropertyKey56(t) {
50228
+ var i = _toPrimitive56(t, "string");
49396
50229
  return "symbol" == (typeof i === "undefined" ? "undefined" : _type_of(i)) ? i : i + "";
49397
50230
  }
49398
- function _toPrimitive54(t, r) {
50231
+ function _toPrimitive56(t, r) {
49399
50232
  if ("object" != (typeof t === "undefined" ? "undefined" : _type_of(t)) || !t) return t;
49400
50233
  var e = t[Symbol.toPrimitive];
49401
50234
  if (void 0 !== e) {
@@ -49422,7 +50255,7 @@ var AudioThreadDialog = function(props) {
49422
50255
  }
49423
50256
  var t2;
49424
50257
  if ($[2] !== props) {
49425
- t2 = /* @__PURE__ */ (0, import_jsx_runtime97.jsxs)(Root13, _objectSpread54(_objectSpread54({}, props), {}, {
50258
+ t2 = /* @__PURE__ */ (0, import_jsx_runtime97.jsxs)(Root13, _objectSpread56(_objectSpread56({}, props), {}, {
49426
50259
  children: [
49427
50260
  t0,
49428
50261
  t1
@@ -49440,7 +50273,7 @@ AudioThreadDialog.Trigger = Trigger;
49440
50273
  AudioThreadDialog.Content = Content8;
49441
50274
  // src/hooks/audioRuntimes/useWebrtcAudioRuntime/index.ts
49442
50275
  var import_react72 = require("react");
49443
- function asyncGeneratorStep12(n, t, e, r, o, a, c) {
50276
+ function asyncGeneratorStep13(n, t, e, r, o, a, c) {
49444
50277
  try {
49445
50278
  var i = n[a](c), u = i.value;
49446
50279
  } catch (n2) {
@@ -49448,16 +50281,16 @@ function asyncGeneratorStep12(n, t, e, r, o, a, c) {
49448
50281
  }
49449
50282
  i.done ? t(u) : Promise.resolve(u).then(r, o);
49450
50283
  }
49451
- function _asyncToGenerator12(n) {
50284
+ function _asyncToGenerator13(n) {
49452
50285
  return function() {
49453
50286
  var t = this, e = arguments;
49454
50287
  return new Promise(function(r, o) {
49455
50288
  var a = n.apply(t, e);
49456
50289
  function _next(n2) {
49457
- asyncGeneratorStep12(a, r, o, _next, _throw, "next", n2);
50290
+ asyncGeneratorStep13(a, r, o, _next, _throw, "next", n2);
49458
50291
  }
49459
50292
  function _throw(n2) {
49460
- asyncGeneratorStep12(a, r, o, _next, _throw, "throw", n2);
50293
+ asyncGeneratorStep13(a, r, o, _next, _throw, "throw", n2);
49461
50294
  }
49462
50295
  _next(void 0);
49463
50296
  });
@@ -49555,7 +50388,7 @@ var useWebrtcAudioRuntime = function() {
49555
50388
  };
49556
50389
  }, []);
49557
50390
  function _startSessionIfNeeded() {
49558
- _startSessionIfNeeded = _asyncToGenerator12(function() {
50391
+ _startSessionIfNeeded = _asyncToGenerator13(function() {
49559
50392
  return _ts_generator(this, function(_state) {
49560
50393
  switch(_state.label){
49561
50394
  case 0:
@@ -49578,7 +50411,7 @@ var useWebrtcAudioRuntime = function() {
49578
50411
  return _startSessionIfNeeded.apply(this, arguments);
49579
50412
  }
49580
50413
  function _initRealtimeSession() {
49581
- _initRealtimeSession = _asyncToGenerator12(function() {
50414
+ _initRealtimeSession = _asyncToGenerator13(function() {
49582
50415
  var peerConn, audioEl, openaiEventsDataChannel, ms, offer, searchParams_0, sdpResponse, answerSdp, answer, err1;
49583
50416
  return _ts_generator(this, function(_state) {
49584
50417
  switch(_state.label){
@@ -49626,7 +50459,7 @@ var useWebrtcAudioRuntime = function() {
49626
50459
  };
49627
50460
  openaiEventsDataChannel = peerConn.createDataChannel("oai-events");
49628
50461
  openaiEventsDataChannel.addEventListener("message", /* @__PURE__ */ function() {
49629
- var _ref8 = _asyncToGenerator12(function(e) {
50462
+ var _ref8 = _asyncToGenerator13(function(e) {
49630
50463
  var parsedData, searchParams, eventsResponse, reader, decoder, _ref, value, done, buffer, lines, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, line, event, ref;
49631
50464
  return _ts_generator(this, function(_state) {
49632
50465
  switch(_state.label){
@@ -49825,7 +50658,7 @@ var useWebrtcAudioRuntime = function() {
49825
50658
  return _initRealtimeSession.apply(this, arguments);
49826
50659
  }
49827
50660
  var start = /* @__PURE__ */ function() {
49828
- var _ref6 = _asyncToGenerator12(function() {
50661
+ var _ref6 = _asyncToGenerator13(function() {
49829
50662
  return _ts_generator(this, function(_state) {
49830
50663
  switch(_state.label){
49831
50664
  case 0:
@@ -49858,7 +50691,7 @@ var useWebrtcAudioRuntime = function() {
49858
50691
  };
49859
50692
  }();
49860
50693
  var pause = /* @__PURE__ */ function() {
49861
- var _ref7 = _asyncToGenerator12(function() {
50694
+ var _ref7 = _asyncToGenerator13(function() {
49862
50695
  return _ts_generator(this, function(_state) {
49863
50696
  if (!sessionStartedRef.current) return [
49864
50697
  2
@@ -49884,7 +50717,7 @@ var useWebrtcAudioRuntime = function() {
49884
50717
  webrtcAudioRuntime: {
49885
50718
  user: {
49886
50719
  start: function() {
49887
- var _start = _asyncToGenerator12(function() {
50720
+ var _start = _asyncToGenerator13(function() {
49888
50721
  return _ts_generator(this, function(_state) {
49889
50722
  return [
49890
50723
  2
@@ -50220,19 +51053,19 @@ function _temp12(rs) {
50220
51053
  var import_react_compiler_runtime104 = require("react-compiler-runtime");
50221
51054
  var import_react76 = require("react");
50222
51055
  var import_jsx_runtime100 = require("react/jsx-runtime");
50223
- var _excluded7 = [
51056
+ var _excluded9 = [
50224
51057
  "children"
50225
51058
  ];
50226
- function _objectWithoutProperties7(e, t) {
51059
+ function _objectWithoutProperties9(e, t) {
50227
51060
  if (null == e) return {};
50228
- var o, r, i = _objectWithoutPropertiesLoose7(e, t);
51061
+ var o, r, i = _objectWithoutPropertiesLoose9(e, t);
50229
51062
  if (Object.getOwnPropertySymbols) {
50230
51063
  var n = Object.getOwnPropertySymbols(e);
50231
51064
  for(r = 0; r < n.length; r++)o = n[r], -1 === t.indexOf(o) && ({}).propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
50232
51065
  }
50233
51066
  return i;
50234
51067
  }
50235
- function _objectWithoutPropertiesLoose7(r, e) {
51068
+ function _objectWithoutPropertiesLoose9(r, e) {
50236
51069
  if (null == r) return {};
50237
51070
  var t = {};
50238
51071
  for(var n in r)if (({}).hasOwnProperty.call(r, n)) {
@@ -50248,7 +51081,7 @@ var MarkdownProvider = function(t0) {
50248
51081
  if ($[0] !== t0) {
50249
51082
  var _t = t0;
50250
51083
  children = _t.children;
50251
- rest = _objectWithoutProperties7(_t, _excluded7);
51084
+ rest = _objectWithoutProperties9(_t, _excluded9);
50252
51085
  _t;
50253
51086
  $[0] = t0;
50254
51087
  $[1] = children;
@@ -50489,19 +51322,19 @@ var FileCitation = function(t0) {
50489
51322
  };
50490
51323
  // src/components/annotations/SourceAnnotation/index.tsx
50491
51324
  var import_jsx_runtime103 = require("react/jsx-runtime");
50492
- var _excluded8 = [
51325
+ var _excluded10 = [
50493
51326
  "children"
50494
51327
  ];
50495
- function _objectWithoutProperties8(e, t) {
51328
+ function _objectWithoutProperties10(e, t) {
50496
51329
  if (null == e) return {};
50497
- var o, r, i = _objectWithoutPropertiesLoose8(e, t);
51330
+ var o, r, i = _objectWithoutPropertiesLoose10(e, t);
50498
51331
  if (Object.getOwnPropertySymbols) {
50499
51332
  var n = Object.getOwnPropertySymbols(e);
50500
51333
  for(r = 0; r < n.length; r++)o = n[r], -1 === t.indexOf(o) && ({}).propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
50501
51334
  }
50502
51335
  return i;
50503
51336
  }
50504
- function _objectWithoutPropertiesLoose8(r, e) {
51337
+ function _objectWithoutPropertiesLoose10(r, e) {
50505
51338
  if (null == r) return {};
50506
51339
  var t = {};
50507
51340
  for(var n in r)if (({}).hasOwnProperty.call(r, n)) {
@@ -50517,7 +51350,7 @@ var SourceAnnotation = function(t0) {
50517
51350
  if ($[0] !== t0) {
50518
51351
  var _t = t0;
50519
51352
  children = _t.children;
50520
- rest = _objectWithoutProperties8(_t, _excluded8);
51353
+ rest = _objectWithoutProperties10(_t, _excluded10);
50521
51354
  _t;
50522
51355
  $[0] = t0;
50523
51356
  $[1] = children;
@@ -50792,19 +51625,19 @@ var Avatar6 = function(t0) {
50792
51625
  var import_react_compiler_runtime111 = require("react-compiler-runtime");
50793
51626
  var import_react79 = require("react");
50794
51627
  var import_jsx_runtime107 = require("react/jsx-runtime");
50795
- var _excluded9 = [
51628
+ var _excluded11 = [
50796
51629
  "children"
50797
51630
  ];
50798
- function _objectWithoutProperties9(e, t) {
51631
+ function _objectWithoutProperties11(e, t) {
50799
51632
  if (null == e) return {};
50800
- var o, r, i = _objectWithoutPropertiesLoose9(e, t);
51633
+ var o, r, i = _objectWithoutPropertiesLoose11(e, t);
50801
51634
  if (Object.getOwnPropertySymbols) {
50802
51635
  var n = Object.getOwnPropertySymbols(e);
50803
51636
  for(r = 0; r < n.length; r++)o = n[r], -1 === t.indexOf(o) && ({}).propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
50804
51637
  }
50805
51638
  return i;
50806
51639
  }
50807
- function _objectWithoutPropertiesLoose9(r, e) {
51640
+ function _objectWithoutPropertiesLoose11(r, e) {
50808
51641
  if (null == r) return {};
50809
51642
  var t = {};
50810
51643
  for(var n in r)if (({}).hasOwnProperty.call(r, n)) {
@@ -50820,7 +51653,7 @@ var ComponentsProvider = function(t0) {
50820
51653
  if ($[0] !== t0) {
50821
51654
  var _t = t0;
50822
51655
  children = _t.children;
50823
- rest = _objectWithoutProperties9(_t, _excluded9);
51656
+ rest = _objectWithoutProperties11(_t, _excluded11);
50824
51657
  _t;
50825
51658
  $[0] = t0;
50826
51659
  $[1] = children;