@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.js CHANGED
@@ -354,7 +354,7 @@ var require_lib = __commonJS({
354
354
  Object.defineProperty(exports, "__esModule", {
355
355
  value: true
356
356
  });
357
- function _objectWithoutPropertiesLoose10(r, e) {
357
+ function _objectWithoutPropertiesLoose12(r, e) {
358
358
  if (null == r) return {};
359
359
  var t = {};
360
360
  for(var n in r)if (({}).hasOwnProperty.call(r, n)) {
@@ -721,7 +721,7 @@ var require_lib = __commonJS({
721
721
  PrimaryTopicNotAllowed: "Topic reference was used in a lexical context without topic binding.",
722
722
  PrimaryTopicRequiresSmartPipeline: 'Topic reference is used, but the pipelineOperator plugin was not passed a "proposal": "hack" or "smart" option.'
723
723
  });
724
- var _excluded10 = [
724
+ var _excluded12 = [
725
725
  "message"
726
726
  ];
727
727
  function defineHidden(obj, key2, value) {
@@ -796,7 +796,7 @@ var require_lib = __commonJS({
796
796
  }
797
797
  } : typeof template === "function" ? {
798
798
  message: template
799
- } : template, message = _ref.message, rest = _objectWithoutPropertiesLoose10(_ref, _excluded10);
799
+ } : template, message = _ref.message, rest = _objectWithoutPropertiesLoose12(_ref, _excluded12);
800
800
  var toMessage = typeof message === "string" ? function() {
801
801
  return message;
802
802
  } : message;
@@ -47220,7 +47220,6 @@ var useRecorder = function(_ref) {
47220
47220
  };
47221
47221
  // src/hooks/audioThreads/useMessageAudio/index.ts
47222
47222
  import { useMemo as useMemo17, useRef as useRef8, useState as useState9, useEffect as useEffect10, useCallback as useCallback7 } from "react";
47223
- import nlp from "compromise";
47224
47223
  import { Howler } from "howler";
47225
47224
  import { useAudioPlayer as useAudioPlayer2 } from "react-use-audio-player";
47226
47225
  // src/hooks/audioThreads/useMessageAudio/lib/input.ts
@@ -47288,198 +47287,851 @@ function _toPrimitive47(t, r) {
47288
47287
  }
47289
47288
  return ("string" === r ? String : Number)(t);
47290
47289
  }
47291
- var getMessageSentences = function(_ref) {
47292
- var messageId = _ref.messageId, input2 = _ref.input;
47293
- var sentences = nlp(input2).sentences().json();
47294
- return sentences.map(function(sentence) {
47295
- return {
47296
- messageId: messageId,
47297
- sentence: sentence.text
47298
- };
47299
- });
47290
+ function asyncGeneratorStep11(n, t, e, r, o, a, c) {
47291
+ try {
47292
+ var i = n[a](c), u = i.value;
47293
+ } catch (n2) {
47294
+ return void e(n2);
47295
+ }
47296
+ i.done ? t(u) : Promise.resolve(u).then(r, o);
47297
+ }
47298
+ function _asyncToGenerator11(n) {
47299
+ return function() {
47300
+ var t = this, e = arguments;
47301
+ return new Promise(function(r, o) {
47302
+ var a = n.apply(t, e);
47303
+ function _next(n2) {
47304
+ asyncGeneratorStep11(a, r, o, _next, _throw, "next", n2);
47305
+ }
47306
+ function _throw(n2) {
47307
+ asyncGeneratorStep11(a, r, o, _next, _throw, "throw", n2);
47308
+ }
47309
+ _next(void 0);
47310
+ });
47311
+ };
47312
+ }
47313
+ var THROTTLE_MS = 80;
47314
+ var MAX_SEG_CACHE = 256;
47315
+ var KEEP_FINISHED_MESSAGES = 12;
47316
+ var FULL_SENTENCE_REGEX = /[\.?!]$/;
47317
+ var hasLetters = function(s) {
47318
+ for(var i = 0; i < s.length; i++){
47319
+ var ch = s.charAt(i);
47320
+ if (ch.toLowerCase() !== ch.toUpperCase()) return true;
47321
+ }
47322
+ return false;
47323
+ };
47324
+ var isSentencePunct = function(ch) {
47325
+ return ch === "." || ch === "!" || ch === "?" || ch === "\u3002" || ch === "\uFF01" || ch === "\uFF1F";
47300
47326
  };
47301
- var useMessageAudio = function(_ref2) {
47302
- var _latestMessageProps$l2;
47303
- var _onEnd = _ref2.onEnd, passedPlay = _ref2.play, _ref2_fullSentenceRegex = _ref2.fullSentenceRegex, fullSentenceRegex = _ref2_fullSentenceRegex === void 0 ? /[\.?!]$/ : _ref2_fullSentenceRegex;
47327
+ var normalizeBoundaries = function(text) {
47328
+ var out = "";
47329
+ for(var i = 0; i < text.length; i++){
47330
+ var ch = text.charAt(i);
47331
+ out += ch;
47332
+ if (isSentencePunct(ch)) {
47333
+ var next = text.charAt(i + 1);
47334
+ if (next && next !== " " && hasLetters(next)) {
47335
+ out += " ";
47336
+ }
47337
+ }
47338
+ }
47339
+ return out;
47340
+ };
47341
+ var splitSentencesFast = function(raw) {
47342
+ var t = normalizeBoundaries(raw.replace(/\s+/g, " ").trim());
47343
+ if (!t) return [];
47344
+ var parts = t.split(RegExp("(?<=[.!?])\\s+(?=[^\\s])", "g"));
47345
+ var filtered = [];
47346
+ for(var i = 0; i < parts.length; i++){
47347
+ var p = parts[i].trim();
47348
+ if (p && hasLetters(p)) filtered.push(p);
47349
+ }
47350
+ return filtered;
47351
+ };
47352
+ var getIncrementalSegments = function(prev, nextInput, now) {
47353
+ if (!prev) return {
47354
+ input: nextInput,
47355
+ segments: splitSentencesFast(nextInput),
47356
+ touched: now
47357
+ };
47358
+ if (nextInput === prev.input) return {
47359
+ input: prev.input,
47360
+ segments: prev.segments,
47361
+ touched: now
47362
+ };
47363
+ if (nextInput.startsWith(prev.input)) {
47364
+ var prevSegments = prev.segments;
47365
+ var prevLast = prevSegments[prevSegments.length - 1] || "";
47366
+ var baseLen = prev.input.length - prevLast.length;
47367
+ if (baseLen >= 0 && prev.input.slice(baseLen) === prevLast) {
47368
+ var tail = nextInput.slice(baseLen);
47369
+ var tailSegments = splitSentencesFast(tail);
47370
+ var merged = prevSegments.length > 0 ? prevSegments.slice(0, -1).concat(tailSegments) : tailSegments;
47371
+ return {
47372
+ input: nextInput,
47373
+ segments: merged,
47374
+ touched: now
47375
+ };
47376
+ }
47377
+ }
47378
+ return {
47379
+ input: nextInput,
47380
+ segments: splitSentencesFast(nextInput),
47381
+ touched: now
47382
+ };
47383
+ };
47384
+ var segmentsEqual = function(a, b) {
47385
+ if (a === b) return true;
47386
+ if (a.length !== b.length) return false;
47387
+ for(var i = 0; i < a.length; i++){
47388
+ if (a[i] !== b[i]) return false;
47389
+ }
47390
+ return true;
47391
+ };
47392
+ var useMessageAudio = function(_ref) {
47393
+ var onEnd = _ref.onEnd, providedPlay = _ref.play, providedPlaySegments = _ref.playSegments, providedGetSegments = _ref.getSegments;
47304
47394
  var _useState9 = _sliced_to_array(useState9(false), 2), isAudioPlayed = _useState9[0], setIsAudioPlayed = _useState9[1];
47305
- var _useState91 = _sliced_to_array(useState9([]), 2), stoppedMessageIds = _useState91[0], setStoppedMessageIds = _useState91[1];
47306
- var _useState92 = _sliced_to_array(useState9([]), 2), playedMessageSentences = _useState92[0], setPlayedMessageSentences = _useState92[1];
47395
+ var isAudioPlayedRef = useRef8(false);
47307
47396
  var audioPlayer = useAudioPlayer2();
47308
47397
  var nextAudioPlayer = useAudioPlayer2();
47309
47398
  var superinterfaceContext = useSuperinterfaceContext();
47310
- var _useState93 = _sliced_to_array(useState9(false), 2), isPlaying = _useState93[0], setIsPlaying = _useState93[1];
47311
- var isLastSentencePlayedRef = useRef8(false);
47312
- var latestMessageProps = useLatestMessage();
47313
- var messagesProps = useMessages();
47399
+ var _useState91 = _sliced_to_array(useState9(false), 2), isPlaying = _useState91[0], setIsPlaying = _useState91[1];
47400
+ var _useState92 = _sliced_to_array(useState9([]), 2), audioQueue = _useState92[0], setAudioQueue = _useState92[1];
47401
+ var audioQueueRef = useRef8([]);
47314
47402
  useEffect10(function() {
47315
- if (!isPlaying) return;
47316
- isLastSentencePlayedRef.current = false;
47403
+ audioQueueRef.current = audioQueue;
47317
47404
  }, [
47318
- isPlaying
47405
+ audioQueue
47319
47406
  ]);
47320
- var unplayedMessageSentences = useMemo17(function() {
47321
- var playableMessages = messagesProps.messages.filter(function(message) {
47322
- if (message.role !== "assistant") return false;
47323
- if (stoppedMessageIds.includes(message.id)) return false;
47324
- return true;
47407
+ var pickLockRef = useRef8(false);
47408
+ var activeSegmentsRef = useRef8(0);
47409
+ var currentSegmentRef = useRef8(null);
47410
+ var onEndPendingRef = useRef8(false);
47411
+ var messagesProps = useMessages();
47412
+ var messagesByIdRef = useRef8(/* @__PURE__ */ new Map());
47413
+ var segCacheRef = useRef8(/* @__PURE__ */ new Map());
47414
+ var mirrorTimerRef = useRef8(null);
47415
+ var pendingMirrorRef = useRef8(false);
47416
+ var markAudioPlayed = useCallback7(function() {
47417
+ if (!isAudioPlayedRef.current) {
47418
+ isAudioPlayedRef.current = true;
47419
+ setIsAudioPlayed(true);
47420
+ }
47421
+ }, []);
47422
+ var segmentToText = useCallback7(function(segment) {
47423
+ if (typeof segment === "string") return segment;
47424
+ if (segment && (typeof segment === "undefined" ? "undefined" : _type_of(segment)) === "object" && "text" in segment) {
47425
+ var value = segment.text;
47426
+ if (typeof value === "string") return value;
47427
+ }
47428
+ if (segment == null) return void 0;
47429
+ var stringified = String(segment);
47430
+ return stringified.length > 0 ? stringified : void 0;
47431
+ }, []);
47432
+ var checkForCompletion = useCallback7(function() {
47433
+ if (activeSegmentsRef.current > 0) return;
47434
+ var hasPending = audioQueueRef.current.some(function(m) {
47435
+ return !m.stopped && (m.nextIndex < m.segments.length || m.status === "in_progress");
47325
47436
  });
47326
- var messageInputs = playableMessages.map(function(message_0) {
47327
- return {
47328
- message: message_0,
47329
- input: input({
47330
- message: message_0
47331
- })
47437
+ if (hasPending) {
47438
+ onEndPendingRef.current = true;
47439
+ return;
47440
+ }
47441
+ if (!onEndPendingRef.current) return;
47442
+ onEndPendingRef.current = false;
47443
+ onEnd();
47444
+ }, [
47445
+ onEnd
47446
+ ]);
47447
+ useEffect10(function() {
47448
+ if (mirrorTimerRef.current != null) {
47449
+ pendingMirrorRef.current = true;
47450
+ return;
47451
+ }
47452
+ var run = /* @__PURE__ */ function() {
47453
+ var _ref2 = _asyncToGenerator11(function() {
47454
+ 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;
47455
+ return _ts_generator(this, function(_state) {
47456
+ switch(_state.label){
47457
+ case 0:
47458
+ assistantsDesc = messagesProps.messages.filter(function(m_0) {
47459
+ return m_0.role === "assistant";
47460
+ });
47461
+ assistantsAsc = assistantsDesc.slice().reverse();
47462
+ nowTs = typeof performance !== "undefined" && performance.now ? performance.now() : Date.now();
47463
+ lastNIds = new Set(assistantsAsc.slice(Math.max(0, assistantsAsc.length - KEEP_FINISHED_MESSAGES)).map(function(m_1) {
47464
+ return String(m_1.id);
47465
+ }));
47466
+ prevQueue = audioQueueRef.current;
47467
+ prevById = new Map(prevQueue.map(function(p) {
47468
+ return [
47469
+ p.id,
47470
+ p
47471
+ ];
47472
+ }));
47473
+ prevUnfinishedIds = new Set(prevQueue.filter(function(m_2) {
47474
+ return !m_2.stopped && (m_2.status === "in_progress" || m_2.nextIndex < m_2.segments.length);
47475
+ }).map(function(m_3) {
47476
+ return m_3.id;
47477
+ }));
47478
+ streamingIds = new Set(assistantsAsc.filter(function(m_4) {
47479
+ return m_4.status === "in_progress";
47480
+ }).map(function(m_5) {
47481
+ return String(m_5.id);
47482
+ }));
47483
+ includeIds = /* @__PURE__ */ new Set();
47484
+ lastNIds.forEach(function(id) {
47485
+ return includeIds.add(id);
47486
+ });
47487
+ prevUnfinishedIds.forEach(function(id_0) {
47488
+ return includeIds.add(id_0);
47489
+ });
47490
+ streamingIds.forEach(function(id_1) {
47491
+ return includeIds.add(id_1);
47492
+ });
47493
+ segCache = segCacheRef.current;
47494
+ nextQueue = [];
47495
+ changed = false;
47496
+ touch = function(id_2, entry) {
47497
+ segCache.set(id_2, {
47498
+ input: entry.input,
47499
+ segments: entry.segments,
47500
+ touched: nowTs
47501
+ });
47502
+ };
47503
+ i = 0;
47504
+ _state.label = 1;
47505
+ case 1:
47506
+ if (!(i < assistantsAsc.length)) return [
47507
+ 3,
47508
+ 6
47509
+ ];
47510
+ m_6 = assistantsAsc[i];
47511
+ if (!includeIds.has(String(m_6.id))) return [
47512
+ 3,
47513
+ 5
47514
+ ];
47515
+ rawInput = input({
47516
+ message: m_6
47517
+ });
47518
+ if (rawInput == null) {
47519
+ segCache.delete(m_6.id);
47520
+ messagesByIdRef.current.delete(m_6.id);
47521
+ return [
47522
+ 3,
47523
+ 5
47524
+ ];
47525
+ }
47526
+ messagesByIdRef.current.set(m_6.id, m_6);
47527
+ prevEntry = segCache.get(m_6.id);
47528
+ nextEntry = void 0;
47529
+ playableSegments = void 0;
47530
+ if (!providedGetSegments) return [
47531
+ 3,
47532
+ 3
47533
+ ];
47534
+ return [
47535
+ 4,
47536
+ Promise.resolve(providedGetSegments({
47537
+ message: m_6,
47538
+ rawInput: rawInput
47539
+ }))
47540
+ ];
47541
+ case 2:
47542
+ customSegments = _state.sent();
47543
+ safeSegments = Array.isArray(customSegments) ? customSegments : [];
47544
+ nextEntry = {
47545
+ input: rawInput,
47546
+ segments: safeSegments,
47547
+ touched: nowTs
47548
+ };
47549
+ playableSegments = safeSegments;
47550
+ return [
47551
+ 3,
47552
+ 4
47553
+ ];
47554
+ case 3:
47555
+ base = getIncrementalSegments(prevEntry, rawInput, nowTs);
47556
+ nextEntry = {
47557
+ input: base.input,
47558
+ segments: base.segments,
47559
+ touched: nowTs
47560
+ };
47561
+ fullSegments = base.segments;
47562
+ readyCount = fullSegments.length;
47563
+ if (readyCount > 0 && !isOptimistic({
47564
+ id: m_6.id
47565
+ }) && m_6.status === "in_progress") {
47566
+ last3 = fullSegments[fullSegments.length - 1];
47567
+ if (last3 && !FULL_SENTENCE_REGEX.test(last3)) readyCount -= 1;
47568
+ }
47569
+ readySegments = fullSegments.slice(0, Math.max(0, readyCount));
47570
+ playableSegments = readyCount === fullSegments.length ? fullSegments : readySegments;
47571
+ _state.label = 4;
47572
+ case 4:
47573
+ touch(m_6.id, nextEntry);
47574
+ existing = prevById.get(m_6.id);
47575
+ nextIndex = Math.min((_existing$nextIndex = existing === null || existing === void 0 ? void 0 : existing.nextIndex) !== null && _existing$nextIndex !== void 0 ? _existing$nextIndex : 0, playableSegments.length);
47576
+ stopped = (_existing$stopped = existing === null || existing === void 0 ? void 0 : existing.stopped) !== null && _existing$stopped !== void 0 ? _existing$stopped : false;
47577
+ reuse = !!existing && existing.status === m_6.status && existing.rawInput === rawInput && existing.nextIndex === nextIndex && existing.stopped === stopped && segmentsEqual(existing.segments, playableSegments);
47578
+ if (reuse) {
47579
+ nextQueue.push(existing);
47580
+ } else {
47581
+ nextQueue.push({
47582
+ id: m_6.id,
47583
+ status: m_6.status,
47584
+ segments: playableSegments,
47585
+ nextIndex: nextIndex,
47586
+ stopped: stopped,
47587
+ rawInput: rawInput
47588
+ });
47589
+ changed = true;
47590
+ }
47591
+ _state.label = 5;
47592
+ case 5:
47593
+ i++;
47594
+ return [
47595
+ 3,
47596
+ 1
47597
+ ];
47598
+ case 6:
47599
+ unfinished = nextQueue.filter(function(m_7) {
47600
+ return !m_7.stopped && (m_7.status === "in_progress" || m_7.nextIndex < m_7.segments.length);
47601
+ });
47602
+ finished = nextQueue.filter(function(m_8) {
47603
+ return !(!m_8.stopped && (m_8.status === "in_progress" || m_8.nextIndex < m_8.segments.length));
47604
+ });
47605
+ prunedFinished = finished.length > KEEP_FINISHED_MESSAGES ? finished.slice(finished.length - KEEP_FINISHED_MESSAGES) : finished;
47606
+ combined = _to_consumable_array(unfinished).concat(_to_consumable_array(prunedFinished));
47607
+ if (combined.some(function(m_9) {
47608
+ return !m_9.stopped && (m_9.nextIndex < m_9.segments.length || m_9.status === "in_progress");
47609
+ })) {
47610
+ onEndPendingRef.current = true;
47611
+ }
47612
+ if (!changed) {
47613
+ if (combined.length !== prevQueue.length) {
47614
+ changed = true;
47615
+ } else {
47616
+ for(i_0 = 0; i_0 < combined.length; i_0++){
47617
+ if (combined[i_0] !== prevQueue[i_0]) {
47618
+ changed = true;
47619
+ break;
47620
+ }
47621
+ }
47622
+ }
47623
+ }
47624
+ idsInQueue = new Set(combined.map(function(m_10) {
47625
+ return m_10.id;
47626
+ }));
47627
+ _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
47628
+ try {
47629
+ for(_iterator = Array.from(segCache.keys())[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
47630
+ id_3 = _step.value;
47631
+ if (!idsInQueue.has(id_3)) segCache.delete(id_3);
47632
+ }
47633
+ } catch (err) {
47634
+ _didIteratorError = true;
47635
+ _iteratorError = err;
47636
+ } finally{
47637
+ try {
47638
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
47639
+ _iterator.return();
47640
+ }
47641
+ } finally{
47642
+ if (_didIteratorError) {
47643
+ throw _iteratorError;
47644
+ }
47645
+ }
47646
+ }
47647
+ _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
47648
+ try {
47649
+ for(_iterator1 = Array.from(messagesByIdRef.current.keys())[Symbol.iterator](); !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
47650
+ id_4 = _step1.value;
47651
+ if (!idsInQueue.has(id_4)) messagesByIdRef.current.delete(id_4);
47652
+ }
47653
+ } catch (err) {
47654
+ _didIteratorError1 = true;
47655
+ _iteratorError1 = err;
47656
+ } finally{
47657
+ try {
47658
+ if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
47659
+ _iterator1.return();
47660
+ }
47661
+ } finally{
47662
+ if (_didIteratorError1) {
47663
+ throw _iteratorError1;
47664
+ }
47665
+ }
47666
+ }
47667
+ if (changed) setAudioQueue(combined);
47668
+ if (segCache.size > MAX_SEG_CACHE) {
47669
+ entries = Array.from(segCache.entries());
47670
+ entries.sort(function(a, b) {
47671
+ return a[1].touched - b[1].touched;
47672
+ });
47673
+ toRemove = segCache.size - MAX_SEG_CACHE;
47674
+ for(i_1 = 0; i_1 < toRemove; i_1++)segCache.delete(entries[i_1][0]);
47675
+ }
47676
+ return [
47677
+ 2
47678
+ ];
47679
+ }
47680
+ });
47681
+ });
47682
+ return function run2() {
47683
+ return _ref2.apply(this, arguments);
47332
47684
  };
47333
- }).filter(function(_ref3) {
47334
- var input2 = _ref3.input;
47335
- return input2 !== null;
47685
+ }();
47686
+ var schedule = function() {
47687
+ mirrorTimerRef.current = window.setTimeout(/* @__PURE__ */ _asyncToGenerator11(function() {
47688
+ return _ts_generator(this, function(_state) {
47689
+ switch(_state.label){
47690
+ case 0:
47691
+ mirrorTimerRef.current = null;
47692
+ _state.label = 1;
47693
+ case 1:
47694
+ _state.trys.push([
47695
+ 1,
47696
+ ,
47697
+ 3,
47698
+ 4
47699
+ ]);
47700
+ return [
47701
+ 4,
47702
+ run()
47703
+ ];
47704
+ case 2:
47705
+ _state.sent();
47706
+ return [
47707
+ 3,
47708
+ 4
47709
+ ];
47710
+ case 3:
47711
+ if (pendingMirrorRef.current) {
47712
+ pendingMirrorRef.current = false;
47713
+ schedule();
47714
+ }
47715
+ return [
47716
+ 7
47717
+ ];
47718
+ case 4:
47719
+ return [
47720
+ 2
47721
+ ];
47722
+ }
47723
+ });
47724
+ }), THROTTLE_MS);
47725
+ };
47726
+ schedule();
47727
+ return function() {
47728
+ if (mirrorTimerRef.current != null) {
47729
+ clearTimeout(mirrorTimerRef.current);
47730
+ mirrorTimerRef.current = null;
47731
+ }
47732
+ pendingMirrorRef.current = false;
47733
+ };
47734
+ }, [
47735
+ messagesProps.messages,
47736
+ providedGetSegments
47737
+ ]);
47738
+ var defaultPlay = useCallback7(/* @__PURE__ */ function() {
47739
+ var _ref5 = _asyncToGenerator11(function(_ref4) {
47740
+ var input2, onPlay, onStop, onEnd_0, searchParams;
47741
+ return _ts_generator(this, function(_state) {
47742
+ switch(_state.label){
47743
+ case 0:
47744
+ input2 = _ref4.input, onPlay = _ref4.onPlay, onStop = _ref4.onStop, onEnd_0 = _ref4.onEnd;
47745
+ searchParams = new URLSearchParams(_objectSpread47({
47746
+ input: input2
47747
+ }, superinterfaceContext.variables));
47748
+ return [
47749
+ 4,
47750
+ new Promise(function(resolve) {
47751
+ var settled = false;
47752
+ var settle = function(cb) {
47753
+ if (settled) return;
47754
+ settled = true;
47755
+ cb();
47756
+ resolve();
47757
+ };
47758
+ audioPlayer.load("".concat(superinterfaceContext.baseUrl, "/audio-runtimes/tts?").concat(searchParams), {
47759
+ format: "mp3",
47760
+ autoplay: isAudioPlayedRef.current,
47761
+ html5: isHtmlAudioSupported,
47762
+ onplay: function() {
47763
+ markAudioPlayed();
47764
+ onPlay();
47765
+ },
47766
+ onstop: function() {
47767
+ settle(onStop);
47768
+ },
47769
+ onend: function() {
47770
+ settle(onEnd_0);
47771
+ },
47772
+ onload: function() {
47773
+ var current = currentSegmentRef.current;
47774
+ if (!current) return;
47775
+ var owner = audioQueueRef.current.find(function(m_11) {
47776
+ return m_11.id === current.messageId;
47777
+ });
47778
+ if (!owner) return;
47779
+ var nextSegment = owner.segments[current.nextIndex];
47780
+ if (!nextSegment) return;
47781
+ var nextText = segmentToText(nextSegment);
47782
+ if (!nextText) return;
47783
+ var nextSearchParams = new URLSearchParams(_objectSpread47({
47784
+ input: nextText
47785
+ }, superinterfaceContext.variables));
47786
+ nextAudioPlayer.load("".concat(superinterfaceContext.baseUrl, "/audio-runtimes/tts?").concat(nextSearchParams), {
47787
+ format: "mp3",
47788
+ autoplay: false,
47789
+ html5: isHtmlAudioSupported
47790
+ });
47791
+ }
47792
+ });
47793
+ })
47794
+ ];
47795
+ case 1:
47796
+ _state.sent();
47797
+ return [
47798
+ 2
47799
+ ];
47800
+ }
47801
+ });
47802
+ });
47803
+ return function(_x) {
47804
+ return _ref5.apply(this, arguments);
47805
+ };
47806
+ }(), [
47807
+ audioPlayer,
47808
+ nextAudioPlayer,
47809
+ superinterfaceContext,
47810
+ segmentToText
47811
+ ]);
47812
+ var playInternal = useCallback7(/* @__PURE__ */ function() {
47813
+ var _ref6 = _asyncToGenerator11(function(segment_0, handlers2) {
47814
+ var text, args;
47815
+ return _ts_generator(this, function(_state) {
47816
+ switch(_state.label){
47817
+ case 0:
47818
+ text = segmentToText(segment_0);
47819
+ if (!text) {
47820
+ handlers2.onEnd();
47821
+ return [
47822
+ 2
47823
+ ];
47824
+ }
47825
+ args = {
47826
+ input: text,
47827
+ onPlay: function() {
47828
+ markAudioPlayed();
47829
+ handlers2.onPlay();
47830
+ },
47831
+ onStop: handlers2.onStop,
47832
+ onEnd: handlers2.onEnd
47833
+ };
47834
+ if (!providedPlay) return [
47835
+ 3,
47836
+ 2
47837
+ ];
47838
+ return [
47839
+ 4,
47840
+ Promise.resolve(providedPlay(args))
47841
+ ];
47842
+ case 1:
47843
+ _state.sent();
47844
+ return [
47845
+ 2
47846
+ ];
47847
+ case 2:
47848
+ return [
47849
+ 4,
47850
+ defaultPlay(args)
47851
+ ];
47852
+ case 3:
47853
+ _state.sent();
47854
+ return [
47855
+ 2
47856
+ ];
47857
+ }
47858
+ });
47336
47859
  });
47337
- var messageSentences = messageInputs.flatMap(function(_ref4) {
47338
- var message_1 = _ref4.message, input_0 = _ref4.input;
47339
- return getMessageSentences({
47340
- messageId: message_1.id,
47341
- input: input_0
47860
+ return function(_x2, _x3) {
47861
+ return _ref6.apply(this, arguments);
47862
+ };
47863
+ }(), [
47864
+ segmentToText,
47865
+ providedPlay,
47866
+ defaultPlay,
47867
+ markAudioPlayed
47868
+ ]);
47869
+ var defaultPlaySegments = useCallback7(/* @__PURE__ */ function() {
47870
+ var _ref8 = _asyncToGenerator11(function(_ref7) {
47871
+ var segments, message, play, i_2, current_0;
47872
+ return _ts_generator(this, function(_state) {
47873
+ switch(_state.label){
47874
+ case 0:
47875
+ segments = _ref7.segments, message = _ref7.message, play = _ref7.play;
47876
+ i_2 = 0;
47877
+ _state.label = 1;
47878
+ case 1:
47879
+ if (!(i_2 < segments.length)) return [
47880
+ 3,
47881
+ 4
47882
+ ];
47883
+ return [
47884
+ 4,
47885
+ play(segments[i_2])
47886
+ ];
47887
+ case 2:
47888
+ _state.sent();
47889
+ current_0 = audioQueueRef.current.find(function(m_12) {
47890
+ return m_12.id === message.id;
47891
+ });
47892
+ if (!current_0 || current_0.stopped) return [
47893
+ 3,
47894
+ 4
47895
+ ];
47896
+ _state.label = 3;
47897
+ case 3:
47898
+ i_2++;
47899
+ return [
47900
+ 3,
47901
+ 1
47902
+ ];
47903
+ case 4:
47904
+ return [
47905
+ 2
47906
+ ];
47907
+ }
47342
47908
  });
47343
47909
  });
47344
- return messageSentences.filter(function(ms) {
47345
- return !playedMessageSentences.find(function(pms) {
47346
- return pms.messageId === ms.messageId && pms.sentence === ms.sentence;
47910
+ return function(_x4) {
47911
+ return _ref8.apply(this, arguments);
47912
+ };
47913
+ }(), []);
47914
+ var playSegmentsImpl = useCallback7(/* @__PURE__ */ function() {
47915
+ var _ref9 = _asyncToGenerator11(function(args_0) {
47916
+ return _ts_generator(this, function(_state) {
47917
+ switch(_state.label){
47918
+ case 0:
47919
+ if (!providedPlaySegments) return [
47920
+ 3,
47921
+ 2
47922
+ ];
47923
+ return [
47924
+ 4,
47925
+ Promise.resolve(providedPlaySegments(args_0))
47926
+ ];
47927
+ case 1:
47928
+ _state.sent();
47929
+ return [
47930
+ 2
47931
+ ];
47932
+ case 2:
47933
+ return [
47934
+ 4,
47935
+ defaultPlaySegments(args_0)
47936
+ ];
47937
+ case 3:
47938
+ _state.sent();
47939
+ return [
47940
+ 2
47941
+ ];
47942
+ }
47347
47943
  });
47348
47944
  });
47349
- }, [
47350
- messagesProps,
47351
- playedMessageSentences
47945
+ return function(_x5) {
47946
+ return _ref9.apply(this, arguments);
47947
+ };
47948
+ }(), [
47949
+ providedPlaySegments,
47950
+ defaultPlaySegments
47352
47951
  ]);
47353
- var defaultPlay = useCallback7(function(_ref5) {
47354
- var input_1 = _ref5.input, onPlay = _ref5.onPlay, onStop = _ref5.onStop, onEnd_0 = _ref5.onEnd;
47355
- var searchParams = new URLSearchParams(_objectSpread47({
47356
- input: input_1
47357
- }, superinterfaceContext.variables));
47358
- audioPlayer.load("".concat(superinterfaceContext.baseUrl, "/audio-runtimes/tts?").concat(searchParams), {
47359
- format: "mp3",
47360
- autoplay: isAudioPlayed,
47361
- html5: isHtmlAudioSupported,
47362
- onplay: onPlay,
47363
- onstop: onStop,
47364
- onload: function() {
47365
- var nextUnplayedMessageSentence = unplayedMessageSentences[1];
47366
- if (!nextUnplayedMessageSentence) return;
47367
- var isNextFullSentence = fullSentenceRegex.test(nextUnplayedMessageSentence.sentence);
47368
- if (!isNextFullSentence) return;
47369
- var nextSearchParams = new URLSearchParams(_objectSpread47({
47370
- input: nextUnplayedMessageSentence.sentence
47371
- }, superinterfaceContext.variables));
47372
- nextAudioPlayer.load("".concat(superinterfaceContext.baseUrl, "/audio-runtimes/tts?").concat(nextSearchParams), {
47373
- format: "mp3",
47374
- autoplay: false,
47375
- html5: isHtmlAudioSupported
47376
- });
47377
- },
47378
- onend: onEnd_0
47952
+ var handleStop = useCallback7(function(messageId) {
47953
+ setAudioQueue(function(prev) {
47954
+ return prev.map(function(m_13) {
47955
+ return m_13.id === messageId ? _objectSpread47(_objectSpread47({}, m_13), {}, {
47956
+ stopped: true
47957
+ }) : m_13;
47958
+ });
47379
47959
  });
47960
+ activeSegmentsRef.current = 0;
47961
+ setIsPlaying(false);
47962
+ currentSegmentRef.current = null;
47963
+ pickLockRef.current = false;
47964
+ checkForCompletion();
47380
47965
  }, [
47381
- superinterfaceContext,
47382
- unplayedMessageSentences,
47383
- audioPlayer,
47384
- nextAudioPlayer,
47385
- isAudioPlayed,
47386
- fullSentenceRegex
47966
+ checkForCompletion
47387
47967
  ]);
47388
- var play = useMemo17(function() {
47389
- return passedPlay || defaultPlay;
47968
+ var handleSegmentEnd = useCallback7(function() {
47969
+ if (activeSegmentsRef.current > 0) activeSegmentsRef.current -= 1;
47970
+ if (activeSegmentsRef.current === 0) {
47971
+ setIsPlaying(false);
47972
+ currentSegmentRef.current = null;
47973
+ pickLockRef.current = false;
47974
+ checkForCompletion();
47975
+ }
47390
47976
  }, [
47391
- passedPlay,
47392
- defaultPlay
47977
+ checkForCompletion
47393
47978
  ]);
47394
47979
  useEffect10(function() {
47395
47980
  if (isPlaying) return;
47396
- if (audioPlayer.playing) return;
47397
- if (!latestMessageProps.latestMessage) return;
47398
- if (latestMessageProps.latestMessage.role !== "assistant") return;
47399
- var firstUnplayedMessageSentence = unplayedMessageSentences[0];
47400
- if (!firstUnplayedMessageSentence) {
47401
- return;
47981
+ if (pickLockRef.current) return;
47982
+ if (audioQueue.length === 0) return;
47983
+ var candidate = null;
47984
+ for(var i_3 = 0; i_3 < audioQueue.length; i_3++){
47985
+ var msg = audioQueue[i_3];
47986
+ if (msg.stopped) continue;
47987
+ if (msg.nextIndex >= msg.segments.length) continue;
47988
+ var message_0 = messagesByIdRef.current.get(msg.id);
47989
+ if (!message_0) continue;
47990
+ candidate = {
47991
+ messageId: msg.id,
47992
+ message: message_0,
47993
+ rawInput: msg.rawInput,
47994
+ startIndex: msg.nextIndex,
47995
+ segments: msg.segments.slice(msg.nextIndex)
47996
+ };
47997
+ break;
47402
47998
  }
47403
- var isFullSentence = isOptimistic({
47404
- id: latestMessageProps.latestMessage.id
47405
- }) || latestMessageProps.latestMessage.status !== "in_progress" || fullSentenceRegex.test(firstUnplayedMessageSentence.sentence);
47406
- if (!isFullSentence) return;
47999
+ if (!candidate || candidate.segments.length === 0) return;
48000
+ pickLockRef.current = true;
47407
48001
  setIsPlaying(true);
47408
- setPlayedMessageSentences(function(prev) {
47409
- return _to_consumable_array(prev).concat([
47410
- firstUnplayedMessageSentence
47411
- ]);
48002
+ setAudioQueue(function(prev_0) {
48003
+ return prev_0.map(function(m_14) {
48004
+ return m_14.id === candidate.messageId ? _objectSpread47(_objectSpread47({}, m_14), {}, {
48005
+ nextIndex: m_14.segments.length
48006
+ }) : m_14;
48007
+ });
47412
48008
  });
47413
- var input_2 = firstUnplayedMessageSentence.sentence;
47414
- play({
47415
- input: input_2,
47416
- onPlay: function() {
47417
- setIsAudioPlayed(true);
47418
- },
47419
- onStop: function() {
47420
- setStoppedMessageIds(function(prev_0) {
47421
- return _to_consumable_array(prev_0).concat([
47422
- firstUnplayedMessageSentence.messageId
47423
- ]);
48009
+ var runPlayback = /* @__PURE__ */ function() {
48010
+ var _ref0 = _asyncToGenerator11(function() {
48011
+ var nextIndex_0, error;
48012
+ return _ts_generator(this, function(_state) {
48013
+ switch(_state.label){
48014
+ case 0:
48015
+ nextIndex_0 = candidate.startIndex;
48016
+ _state.label = 1;
48017
+ case 1:
48018
+ _state.trys.push([
48019
+ 1,
48020
+ 3,
48021
+ 4,
48022
+ 5
48023
+ ]);
48024
+ return [
48025
+ 4,
48026
+ playSegmentsImpl({
48027
+ segments: candidate.segments,
48028
+ startIndex: candidate.startIndex,
48029
+ message: candidate.message,
48030
+ play: function() {
48031
+ var _play = _asyncToGenerator11(function(segment_1) {
48032
+ return _ts_generator(this, function(_state) {
48033
+ switch(_state.label){
48034
+ case 0:
48035
+ activeSegmentsRef.current += 1;
48036
+ nextIndex_0 += 1;
48037
+ currentSegmentRef.current = {
48038
+ messageId: candidate.messageId,
48039
+ nextIndex: nextIndex_0
48040
+ };
48041
+ return [
48042
+ 4,
48043
+ playInternal(segment_1, {
48044
+ onPlay: function() {},
48045
+ onStop: function() {
48046
+ return handleStop(candidate.messageId);
48047
+ },
48048
+ onEnd: function() {
48049
+ return handleSegmentEnd();
48050
+ }
48051
+ })
48052
+ ];
48053
+ case 1:
48054
+ _state.sent();
48055
+ return [
48056
+ 2
48057
+ ];
48058
+ }
48059
+ });
48060
+ });
48061
+ function play(_x6) {
48062
+ return _play.apply(this, arguments);
48063
+ }
48064
+ return play;
48065
+ }()
48066
+ })
48067
+ ];
48068
+ case 2:
48069
+ _state.sent();
48070
+ return [
48071
+ 3,
48072
+ 5
48073
+ ];
48074
+ case 3:
48075
+ error = _state.sent();
48076
+ handleStop(candidate.messageId);
48077
+ console.error(error);
48078
+ return [
48079
+ 3,
48080
+ 5
48081
+ ];
48082
+ case 4:
48083
+ checkForCompletion();
48084
+ return [
48085
+ 7
48086
+ ];
48087
+ case 5:
48088
+ return [
48089
+ 2
48090
+ ];
48091
+ }
47424
48092
  });
47425
- setIsPlaying(false);
47426
- },
47427
- onEnd: function() {
47428
- setIsPlaying(false);
47429
- isLastSentencePlayedRef.current = unplayedMessageSentences.length === 1;
47430
- if (isLastSentencePlayedRef.current && latestMessageProps.latestMessage.status !== "in_progress") {
47431
- _onEnd();
47432
- isLastSentencePlayedRef.current = false;
47433
- }
47434
- }
47435
- });
47436
- }, [
47437
- unplayedMessageSentences,
47438
- isPlaying,
47439
- superinterfaceContext,
47440
- latestMessageProps,
47441
- audioPlayer,
47442
- nextAudioPlayer,
47443
- playedMessageSentences,
47444
- _onEnd,
47445
- play,
47446
- fullSentenceRegex
47447
- ]);
47448
- useEffect10(function() {
47449
- var _latestMessageProps$l;
47450
- if (isLastSentencePlayedRef.current && !isPlaying && unplayedMessageSentences.length === 0 && ((_latestMessageProps$l = latestMessageProps.latestMessage) === null || _latestMessageProps$l === void 0 ? void 0 : _latestMessageProps$l.status) !== "in_progress") {
47451
- _onEnd();
47452
- isLastSentencePlayedRef.current = false;
47453
- }
48093
+ });
48094
+ return function runPlayback2() {
48095
+ return _ref0.apply(this, arguments);
48096
+ };
48097
+ }();
48098
+ runPlayback();
47454
48099
  }, [
48100
+ audioQueue,
47455
48101
  isPlaying,
47456
- unplayedMessageSentences.length,
47457
- (_latestMessageProps$l2 = latestMessageProps.latestMessage) === null || _latestMessageProps$l2 === void 0 ? void 0 : _latestMessageProps$l2.status,
47458
- _onEnd
48102
+ playSegmentsImpl,
48103
+ playInternal,
48104
+ handleStop,
48105
+ handleSegmentEnd,
48106
+ checkForCompletion
47459
48107
  ]);
47460
48108
  useEffect10(function() {
47461
48109
  if (isHtmlAudioSupported) {
47462
- var _Howler$_howls$;
47463
- if (!(Howler !== null && Howler !== void 0 && (_Howler$_howls$ = Howler._howls[0]) !== null && _Howler$_howls$ !== void 0 && (_Howler$_howls$ = _Howler$_howls$._sounds[0]) !== null && _Howler$_howls$ !== void 0 && _Howler$_howls$._node)) return;
47464
- Howler._howls[0]._sounds[0]._node.crossOrigin = "anonymous";
48110
+ var _Howler$_howls;
48111
+ var node = Howler === null || Howler === void 0 || (_Howler$_howls = 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;
48112
+ if (node) node.crossOrigin = "anonymous";
47465
48113
  }
47466
48114
  }, [
47467
48115
  audioPlayer
47468
48116
  ]);
47469
- var _useState94 = _sliced_to_array(useState9(null), 2), audioEngine = _useState94[0], setAudioEngine = _useState94[1];
48117
+ var _useState93 = _sliced_to_array(useState9(null), 2), audioEngine = _useState93[0], setAudioEngine = _useState93[1];
47470
48118
  var isAudioEngineInited = useRef8(false);
47471
48119
  useEffect10(function() {
47472
48120
  if (!audioPlayer.playing) return;
47473
48121
  if (isAudioEngineInited.current) return;
47474
48122
  isAudioEngineInited.current = true;
47475
48123
  if (isHtmlAudioSupported) {
47476
- var audioContext = new AudioContext();
47477
- setAudioEngine({
47478
- // @ts-ignore-next-line
47479
- source: audioContext.createMediaElementSource(// @ts-ignore-next-line
47480
- Howler._howls[0]._sounds[0]._node),
47481
- audioContext: audioContext
47482
- });
48124
+ var _Howler$_howls2;
48125
+ var AudioCtx = window.AudioContext || window.webkitAudioContext;
48126
+ var audioContext = new AudioCtx();
48127
+ var node_0 = Howler === null || Howler === void 0 || (_Howler$_howls2 = 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;
48128
+ if (node_0) {
48129
+ setAudioEngine({
48130
+ // @ts-ignore-next-line
48131
+ source: audioContext.createMediaElementSource(node_0),
48132
+ audioContext: audioContext
48133
+ });
48134
+ }
47483
48135
  } else {
47484
48136
  setAudioEngine({
47485
48137
  source: Howler.masterGain,
@@ -47487,25 +48139,24 @@ var useMessageAudio = function(_ref2) {
47487
48139
  });
47488
48140
  }
47489
48141
  }, [
47490
- audioPlayer,
47491
- isAudioEngineInited
48142
+ audioPlayer
47492
48143
  ]);
47493
48144
  var visualizationAnalyser = useMemo17(function() {
47494
48145
  if (!audioEngine) return null;
47495
- var result = audioEngine.audioContext.createAnalyser();
48146
+ var analyser = audioEngine.audioContext.createAnalyser();
47496
48147
  audioEngine.source.connect(audioEngine.audioContext.destination);
47497
- audioEngine.source.connect(result);
47498
- return result;
48148
+ audioEngine.source.connect(analyser);
48149
+ return analyser;
47499
48150
  }, [
47500
48151
  audioEngine
47501
48152
  ]);
47502
48153
  var isPending = useMemo17(function() {
47503
- var _latestMessageProps$l3;
47504
- return isPlaying || unplayedMessageSentences.length > 0 || ((_latestMessageProps$l3 = latestMessageProps.latestMessage) === null || _latestMessageProps$l3 === void 0 ? void 0 : _latestMessageProps$l3.status) === "in_progress";
48154
+ return isPlaying || audioQueue.some(function(m_15) {
48155
+ return !m_15.stopped && (m_15.nextIndex < m_15.segments.length || m_15.status === "in_progress");
48156
+ });
47505
48157
  }, [
47506
48158
  isPlaying,
47507
- unplayedMessageSentences,
47508
- latestMessageProps
48159
+ audioQueue
47509
48160
  ]);
47510
48161
  return _objectSpread47(_objectSpread47({
47511
48162
  isPending: isPending,
@@ -47527,7 +48178,53 @@ var blobToData = function(blob) {
47527
48178
  });
47528
48179
  };
47529
48180
  // src/hooks/audioRuntimes/useTtsAudioRuntime/index.ts
47530
- function asyncGeneratorStep11(n, t, e, r, o, a, c) {
48181
+ var _excluded5 = [
48182
+ "onEnd"
48183
+ ];
48184
+ function ownKeys48(e, r) {
48185
+ var t = Object.keys(e);
48186
+ if (Object.getOwnPropertySymbols) {
48187
+ var o = Object.getOwnPropertySymbols(e);
48188
+ r && (o = o.filter(function(r2) {
48189
+ return Object.getOwnPropertyDescriptor(e, r2).enumerable;
48190
+ })), t.push.apply(t, o);
48191
+ }
48192
+ return t;
48193
+ }
48194
+ function _objectSpread48(e) {
48195
+ for(var r = 1; r < arguments.length; r++){
48196
+ var t = null != arguments[r] ? arguments[r] : {};
48197
+ r % 2 ? ownKeys48(Object(t), true).forEach(function(r2) {
48198
+ _defineProperty48(e, r2, t[r2]);
48199
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys48(Object(t)).forEach(function(r2) {
48200
+ Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
48201
+ });
48202
+ }
48203
+ return e;
48204
+ }
48205
+ function _defineProperty48(e, r, t) {
48206
+ return (r = _toPropertyKey48(r)) in e ? Object.defineProperty(e, r, {
48207
+ value: t,
48208
+ enumerable: true,
48209
+ configurable: true,
48210
+ writable: true
48211
+ }) : e[r] = t, e;
48212
+ }
48213
+ function _toPropertyKey48(t) {
48214
+ var i = _toPrimitive48(t, "string");
48215
+ return "symbol" == (typeof i === "undefined" ? "undefined" : _type_of(i)) ? i : i + "";
48216
+ }
48217
+ function _toPrimitive48(t, r) {
48218
+ if ("object" != (typeof t === "undefined" ? "undefined" : _type_of(t)) || !t) return t;
48219
+ var e = t[Symbol.toPrimitive];
48220
+ if (void 0 !== e) {
48221
+ var i = e.call(t, r || "default");
48222
+ if ("object" != (typeof i === "undefined" ? "undefined" : _type_of(i))) return i;
48223
+ throw new TypeError("@@toPrimitive must return a primitive value.");
48224
+ }
48225
+ return ("string" === r ? String : Number)(t);
48226
+ }
48227
+ function asyncGeneratorStep12(n, t, e, r, o, a, c) {
47531
48228
  try {
47532
48229
  var i = n[a](c), u = i.value;
47533
48230
  } catch (n2) {
@@ -47535,35 +48232,67 @@ function asyncGeneratorStep11(n, t, e, r, o, a, c) {
47535
48232
  }
47536
48233
  i.done ? t(u) : Promise.resolve(u).then(r, o);
47537
48234
  }
47538
- function _asyncToGenerator11(n) {
48235
+ function _asyncToGenerator12(n) {
47539
48236
  return function() {
47540
48237
  var t = this, e = arguments;
47541
48238
  return new Promise(function(r, o) {
47542
48239
  var a = n.apply(t, e);
47543
48240
  function _next(n2) {
47544
- asyncGeneratorStep11(a, r, o, _next, _throw, "next", n2);
48241
+ asyncGeneratorStep12(a, r, o, _next, _throw, "next", n2);
47545
48242
  }
47546
48243
  function _throw(n2) {
47547
- asyncGeneratorStep11(a, r, o, _next, _throw, "throw", n2);
48244
+ asyncGeneratorStep12(a, r, o, _next, _throw, "throw", n2);
47548
48245
  }
47549
48246
  _next(void 0);
47550
48247
  });
47551
48248
  };
47552
48249
  }
48250
+ function _objectWithoutProperties5(e, t) {
48251
+ if (null == e) return {};
48252
+ var o, r, i = _objectWithoutPropertiesLoose5(e, t);
48253
+ if (Object.getOwnPropertySymbols) {
48254
+ var n = Object.getOwnPropertySymbols(e);
48255
+ for(r = 0; r < n.length; r++)o = n[r], -1 === t.indexOf(o) && ({}).propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
48256
+ }
48257
+ return i;
48258
+ }
48259
+ function _objectWithoutPropertiesLoose5(r, e) {
48260
+ if (null == r) return {};
48261
+ var t = {};
48262
+ for(var n in r)if (({}).hasOwnProperty.call(r, n)) {
48263
+ if (-1 !== e.indexOf(n)) continue;
48264
+ t[n] = r[n];
48265
+ }
48266
+ return t;
48267
+ }
47553
48268
  var useTtsAudioRuntime = function(t0) {
47554
- var $ = _c88(30);
47555
- var play = t0.play, passedOnEnd = t0.onEnd;
48269
+ var $ = _c88(33);
48270
+ var overrides;
48271
+ var passedOnEnd;
48272
+ if ($[0] !== t0) {
48273
+ var _t = t0;
48274
+ var ref;
48275
+ ref = _t, passedOnEnd = ref.onEnd, ref;
48276
+ overrides = _objectWithoutProperties5(_t, _excluded5);
48277
+ _t;
48278
+ $[0] = t0;
48279
+ $[1] = overrides;
48280
+ $[2] = passedOnEnd;
48281
+ } else {
48282
+ overrides = $[1];
48283
+ passedOnEnd = $[2];
48284
+ }
47556
48285
  var addToast = useToasts().addToast;
47557
48286
  var queryClient = useQueryClient6();
47558
48287
  var threadContext = useSuperinterfaceContext();
47559
48288
  var t1;
47560
- if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
48289
+ if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
47561
48290
  t1 = {
47562
48291
  name: "microphone"
47563
48292
  };
47564
- $[0] = t1;
48293
+ $[3] = t1;
47565
48294
  } else {
47566
- t1 = $[0];
48295
+ t1 = $[3];
47567
48296
  }
47568
48297
  var microphonePermission = usePermission(t1);
47569
48298
  var createMessageProps = useCreateMessage({
@@ -47577,12 +48306,12 @@ var useTtsAudioRuntime = function(t0) {
47577
48306
  }
47578
48307
  });
47579
48308
  var t2;
47580
- if ($[1] !== createMessageProps) {
48309
+ if ($[4] !== createMessageProps) {
47581
48310
  t2 = {
47582
48311
  isStopOnSilence: true,
47583
48312
  onStart: _temp9,
47584
48313
  onStop: function() {
47585
- var _onStop = _asyncToGenerator11(function(_event, chunks) {
48314
+ var _onStop = _asyncToGenerator12(function(_event, chunks) {
47586
48315
  var blob, audioContent;
47587
48316
  return _ts_generator(this, function(_state) {
47588
48317
  switch(_state.label){
@@ -47611,10 +48340,10 @@ var useTtsAudioRuntime = function(t0) {
47611
48340
  return onStop;
47612
48341
  }()
47613
48342
  };
47614
- $[1] = createMessageProps;
47615
- $[2] = t2;
48343
+ $[4] = createMessageProps;
48344
+ $[5] = t2;
47616
48345
  } else {
47617
- t2 = $[2];
48346
+ t2 = $[5];
47618
48347
  }
47619
48348
  var recorderProps = useRecorder(t2);
47620
48349
  recorderProps;
@@ -47624,39 +48353,38 @@ var useTtsAudioRuntime = function(t0) {
47624
48353
  t3 = passedOnEnd;
47625
48354
  break bb0;
47626
48355
  }
47627
- var _t;
47628
- if ($[3] !== microphonePermission || $[4] !== recorderProps) {
47629
- _t = function() {
48356
+ var _t2;
48357
+ if ($[6] !== microphonePermission || $[7] !== recorderProps) {
48358
+ _t2 = function() {
47630
48359
  if (microphonePermission === "granted") {
47631
48360
  recorderProps.start();
47632
48361
  }
47633
48362
  };
47634
- $[3] = microphonePermission;
47635
- $[4] = recorderProps;
47636
- $[5] = _t;
48363
+ $[6] = microphonePermission;
48364
+ $[7] = recorderProps;
48365
+ $[8] = _t2;
47637
48366
  } else {
47638
- _t = $[5];
48367
+ _t2 = $[8];
47639
48368
  }
47640
- t3 = _t;
48369
+ t3 = _t2;
47641
48370
  }
47642
48371
  var onEnd = t3;
47643
48372
  var t4;
47644
- if ($[6] !== onEnd || $[7] !== play) {
47645
- t4 = {
47646
- play: play,
48373
+ if ($[9] !== onEnd || $[10] !== overrides) {
48374
+ t4 = _objectSpread48({
47647
48375
  onEnd: onEnd
47648
- };
47649
- $[6] = onEnd;
47650
- $[7] = play;
47651
- $[8] = t4;
48376
+ }, overrides);
48377
+ $[9] = onEnd;
48378
+ $[10] = overrides;
48379
+ $[11] = t4;
47652
48380
  } else {
47653
- t4 = $[8];
48381
+ t4 = $[11];
47654
48382
  }
47655
48383
  var messageAudioProps = useMessageAudio(t4);
47656
48384
  recorderProps;
47657
48385
  var t5;
47658
48386
  var t6;
47659
- if ($[9] !== createMessageProps.isPending || $[10] !== recorderProps.pause || $[11] !== recorderProps.resume || $[12] !== recorderProps.start || $[13] !== recorderProps.status || $[14] !== recorderProps.stop || $[15] !== recorderProps.visualizationAnalyser) {
48387
+ if ($[12] !== createMessageProps.isPending || $[13] !== recorderProps.pause || $[14] !== recorderProps.resume || $[15] !== recorderProps.start || $[16] !== recorderProps.status || $[17] !== recorderProps.stop || $[18] !== recorderProps.visualizationAnalyser) {
47660
48388
  t6 = {
47661
48389
  start: recorderProps.start,
47662
48390
  stop: recorderProps.stop,
@@ -47666,19 +48394,19 @@ var useTtsAudioRuntime = function(t0) {
47666
48394
  visualizationAnalyser: recorderProps.visualizationAnalyser,
47667
48395
  rawStatus: recorderProps.status
47668
48396
  };
47669
- $[9] = createMessageProps.isPending;
47670
- $[10] = recorderProps.pause;
47671
- $[11] = recorderProps.resume;
47672
- $[12] = recorderProps.start;
47673
- $[13] = recorderProps.status;
47674
- $[14] = recorderProps.stop;
47675
- $[15] = recorderProps.visualizationAnalyser;
47676
- $[16] = t6;
48397
+ $[12] = createMessageProps.isPending;
48398
+ $[13] = recorderProps.pause;
48399
+ $[14] = recorderProps.resume;
48400
+ $[15] = recorderProps.start;
48401
+ $[16] = recorderProps.status;
48402
+ $[17] = recorderProps.stop;
48403
+ $[18] = recorderProps.visualizationAnalyser;
48404
+ $[19] = t6;
47677
48405
  } else {
47678
- t6 = $[16];
48406
+ t6 = $[19];
47679
48407
  }
47680
48408
  var t7;
47681
- 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) {
48409
+ 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) {
47682
48410
  t7 = {
47683
48411
  play: messageAudioProps.play,
47684
48412
  pause: messageAudioProps.pause,
@@ -47691,32 +48419,32 @@ var useTtsAudioRuntime = function(t0) {
47691
48419
  isAudioPlayed: messageAudioProps.isAudioPlayed,
47692
48420
  rawStatus: void 0
47693
48421
  };
47694
- $[17] = messageAudioProps.isAudioPlayed;
47695
- $[18] = messageAudioProps.isPending;
47696
- $[19] = messageAudioProps.isReady;
47697
- $[20] = messageAudioProps.pause;
47698
- $[21] = messageAudioProps.paused;
47699
- $[22] = messageAudioProps.play;
47700
- $[23] = messageAudioProps.playing;
47701
- $[24] = messageAudioProps.stop;
47702
- $[25] = messageAudioProps.visualizationAnalyser;
47703
- $[26] = t7;
47704
- } else {
47705
- t7 = $[26];
48422
+ $[20] = messageAudioProps.isAudioPlayed;
48423
+ $[21] = messageAudioProps.isPending;
48424
+ $[22] = messageAudioProps.isReady;
48425
+ $[23] = messageAudioProps.pause;
48426
+ $[24] = messageAudioProps.paused;
48427
+ $[25] = messageAudioProps.play;
48428
+ $[26] = messageAudioProps.playing;
48429
+ $[27] = messageAudioProps.stop;
48430
+ $[28] = messageAudioProps.visualizationAnalyser;
48431
+ $[29] = t7;
48432
+ } else {
48433
+ t7 = $[29];
47706
48434
  }
47707
48435
  var t8;
47708
- if ($[27] !== t6 || $[28] !== t7) {
48436
+ if ($[30] !== t6 || $[31] !== t7) {
47709
48437
  t8 = {
47710
48438
  ttsAudioRuntime: {
47711
48439
  user: t6,
47712
48440
  assistant: t7
47713
48441
  }
47714
48442
  };
47715
- $[27] = t6;
47716
- $[28] = t7;
47717
- $[29] = t8;
48443
+ $[30] = t6;
48444
+ $[31] = t7;
48445
+ $[32] = t8;
47718
48446
  } else {
47719
- t8 = $[29];
48447
+ t8 = $[32];
47720
48448
  }
47721
48449
  t5 = t8;
47722
48450
  return t5;
@@ -47725,7 +48453,7 @@ function _temp9() {
47725
48453
  return _temp24.apply(this, arguments);
47726
48454
  }
47727
48455
  function _temp24() {
47728
- _temp24 = _asyncToGenerator11(function() {
48456
+ _temp24 = _asyncToGenerator12(function() {
47729
48457
  return _ts_generator(this, function(_state) {
47730
48458
  return [
47731
48459
  2
@@ -47736,49 +48464,130 @@ function _temp24() {
47736
48464
  }
47737
48465
  // src/components/audioRuntimes/TtsAudioRuntimeProvider.tsx
47738
48466
  import { jsx as _jsx87 } from "react/jsx-runtime";
48467
+ var _excluded6 = [
48468
+ "children",
48469
+ "onEnd"
48470
+ ];
48471
+ function ownKeys49(e, r) {
48472
+ var t = Object.keys(e);
48473
+ if (Object.getOwnPropertySymbols) {
48474
+ var o = Object.getOwnPropertySymbols(e);
48475
+ r && (o = o.filter(function(r2) {
48476
+ return Object.getOwnPropertyDescriptor(e, r2).enumerable;
48477
+ })), t.push.apply(t, o);
48478
+ }
48479
+ return t;
48480
+ }
48481
+ function _objectSpread49(e) {
48482
+ for(var r = 1; r < arguments.length; r++){
48483
+ var t = null != arguments[r] ? arguments[r] : {};
48484
+ r % 2 ? ownKeys49(Object(t), true).forEach(function(r2) {
48485
+ _defineProperty49(e, r2, t[r2]);
48486
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys49(Object(t)).forEach(function(r2) {
48487
+ Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
48488
+ });
48489
+ }
48490
+ return e;
48491
+ }
48492
+ function _defineProperty49(e, r, t) {
48493
+ return (r = _toPropertyKey49(r)) in e ? Object.defineProperty(e, r, {
48494
+ value: t,
48495
+ enumerable: true,
48496
+ configurable: true,
48497
+ writable: true
48498
+ }) : e[r] = t, e;
48499
+ }
48500
+ function _toPropertyKey49(t) {
48501
+ var i = _toPrimitive49(t, "string");
48502
+ return "symbol" == (typeof i === "undefined" ? "undefined" : _type_of(i)) ? i : i + "";
48503
+ }
48504
+ function _toPrimitive49(t, r) {
48505
+ if ("object" != (typeof t === "undefined" ? "undefined" : _type_of(t)) || !t) return t;
48506
+ var e = t[Symbol.toPrimitive];
48507
+ if (void 0 !== e) {
48508
+ var i = e.call(t, r || "default");
48509
+ if ("object" != (typeof i === "undefined" ? "undefined" : _type_of(i))) return i;
48510
+ throw new TypeError("@@toPrimitive must return a primitive value.");
48511
+ }
48512
+ return ("string" === r ? String : Number)(t);
48513
+ }
48514
+ function _objectWithoutProperties6(e, t) {
48515
+ if (null == e) return {};
48516
+ var o, r, i = _objectWithoutPropertiesLoose6(e, t);
48517
+ if (Object.getOwnPropertySymbols) {
48518
+ var n = Object.getOwnPropertySymbols(e);
48519
+ for(r = 0; r < n.length; r++)o = n[r], -1 === t.indexOf(o) && ({}).propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
48520
+ }
48521
+ return i;
48522
+ }
48523
+ function _objectWithoutPropertiesLoose6(r, e) {
48524
+ if (null == r) return {};
48525
+ var t = {};
48526
+ for(var n in r)if (({}).hasOwnProperty.call(r, n)) {
48527
+ if (-1 !== e.indexOf(n)) continue;
48528
+ t[n] = r[n];
48529
+ }
48530
+ return t;
48531
+ }
47739
48532
  var TtsAudioRuntimeProvider = function(t0) {
47740
- var $ = _c89(8);
47741
- var children = t0.children, play = t0.play, onEnd = t0.onEnd;
48533
+ var $ = _c89(12);
48534
+ var children;
48535
+ var onEnd;
48536
+ var overrides;
48537
+ if ($[0] !== t0) {
48538
+ var _t = t0;
48539
+ var ref;
48540
+ ref = _t, children = ref.children, onEnd = ref.onEnd, ref;
48541
+ overrides = _objectWithoutProperties6(_t, _excluded6);
48542
+ _t;
48543
+ $[0] = t0;
48544
+ $[1] = children;
48545
+ $[2] = onEnd;
48546
+ $[3] = overrides;
48547
+ } else {
48548
+ children = $[1];
48549
+ onEnd = $[2];
48550
+ overrides = $[3];
48551
+ }
47742
48552
  var t1;
47743
- if ($[0] !== onEnd || $[1] !== play) {
47744
- t1 = {
47745
- play: play,
48553
+ if ($[4] !== onEnd || $[5] !== overrides) {
48554
+ t1 = _objectSpread49({
47746
48555
  onEnd: onEnd
47747
- };
47748
- $[0] = onEnd;
47749
- $[1] = play;
47750
- $[2] = t1;
48556
+ }, overrides);
48557
+ $[4] = onEnd;
48558
+ $[5] = overrides;
48559
+ $[6] = t1;
47751
48560
  } else {
47752
- t1 = $[2];
48561
+ t1 = $[6];
47753
48562
  }
47754
48563
  var ttsAudioRuntime = useTtsAudioRuntime(t1).ttsAudioRuntime;
47755
48564
  var t2;
47756
- if ($[3] !== ttsAudioRuntime) {
48565
+ if ($[7] !== ttsAudioRuntime) {
47757
48566
  t2 = {
47758
48567
  audioRuntime: ttsAudioRuntime
47759
48568
  };
47760
- $[3] = ttsAudioRuntime;
47761
- $[4] = t2;
48569
+ $[7] = ttsAudioRuntime;
48570
+ $[8] = t2;
47762
48571
  } else {
47763
- t2 = $[4];
48572
+ t2 = $[8];
47764
48573
  }
47765
48574
  var t3;
47766
- if ($[5] !== children || $[6] !== t2) {
48575
+ if ($[9] !== children || $[10] !== t2) {
47767
48576
  t3 = /* @__PURE__ */ _jsx87(AudioThreadContext.Provider, {
47768
48577
  value: t2,
47769
48578
  children: children
47770
48579
  });
47771
- $[5] = children;
47772
- $[6] = t2;
47773
- $[7] = t3;
48580
+ $[9] = children;
48581
+ $[10] = t2;
48582
+ $[11] = t3;
47774
48583
  } else {
47775
- t3 = $[7];
48584
+ t3 = $[11];
47776
48585
  }
47777
48586
  return t3;
47778
48587
  };
47779
48588
  // src/components/threads/AudioThread/Root/index.tsx
47780
48589
  import { jsx as _jsx88 } from "react/jsx-runtime";
47781
- var _excluded5 = [
48590
+ var _excluded7 = [
47782
48591
  "children"
47783
48592
  ];
47784
48593
  var _excluded22 = [
@@ -47786,9 +48595,28 @@ var _excluded22 = [
47786
48595
  "play",
47787
48596
  "onEnd",
47788
48597
  "className",
47789
- "style"
48598
+ "style",
48599
+ "playback"
47790
48600
  ];
47791
- function ownKeys48(e, r) {
48601
+ function _objectWithoutProperties7(e, t) {
48602
+ if (null == e) return {};
48603
+ var o, r, i = _objectWithoutPropertiesLoose7(e, t);
48604
+ if (Object.getOwnPropertySymbols) {
48605
+ var n = Object.getOwnPropertySymbols(e);
48606
+ for(r = 0; r < n.length; r++)o = n[r], -1 === t.indexOf(o) && ({}).propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
48607
+ }
48608
+ return i;
48609
+ }
48610
+ function _objectWithoutPropertiesLoose7(r, e) {
48611
+ if (null == r) return {};
48612
+ var t = {};
48613
+ for(var n in r)if (({}).hasOwnProperty.call(r, n)) {
48614
+ if (-1 !== e.indexOf(n)) continue;
48615
+ t[n] = r[n];
48616
+ }
48617
+ return t;
48618
+ }
48619
+ function ownKeys50(e, r) {
47792
48620
  var t = Object.keys(e);
47793
48621
  if (Object.getOwnPropertySymbols) {
47794
48622
  var o = Object.getOwnPropertySymbols(e);
@@ -47798,30 +48626,30 @@ function ownKeys48(e, r) {
47798
48626
  }
47799
48627
  return t;
47800
48628
  }
47801
- function _objectSpread48(e) {
48629
+ function _objectSpread50(e) {
47802
48630
  for(var r = 1; r < arguments.length; r++){
47803
48631
  var t = null != arguments[r] ? arguments[r] : {};
47804
- r % 2 ? ownKeys48(Object(t), true).forEach(function(r2) {
47805
- _defineProperty48(e, r2, t[r2]);
47806
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys48(Object(t)).forEach(function(r2) {
48632
+ r % 2 ? ownKeys50(Object(t), true).forEach(function(r2) {
48633
+ _defineProperty50(e, r2, t[r2]);
48634
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys50(Object(t)).forEach(function(r2) {
47807
48635
  Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
47808
48636
  });
47809
48637
  }
47810
48638
  return e;
47811
48639
  }
47812
- function _defineProperty48(e, r, t) {
47813
- return (r = _toPropertyKey48(r)) in e ? Object.defineProperty(e, r, {
48640
+ function _defineProperty50(e, r, t) {
48641
+ return (r = _toPropertyKey50(r)) in e ? Object.defineProperty(e, r, {
47814
48642
  value: t,
47815
48643
  enumerable: true,
47816
48644
  configurable: true,
47817
48645
  writable: true
47818
48646
  }) : e[r] = t, e;
47819
48647
  }
47820
- function _toPropertyKey48(t) {
47821
- var i = _toPrimitive48(t, "string");
48648
+ function _toPropertyKey50(t) {
48649
+ var i = _toPrimitive50(t, "string");
47822
48650
  return "symbol" == (typeof i === "undefined" ? "undefined" : _type_of(i)) ? i : i + "";
47823
48651
  }
47824
- function _toPrimitive48(t, r) {
48652
+ function _toPrimitive50(t, r) {
47825
48653
  if ("object" != (typeof t === "undefined" ? "undefined" : _type_of(t)) || !t) return t;
47826
48654
  var e = t[Symbol.toPrimitive];
47827
48655
  if (void 0 !== e) {
@@ -47831,24 +48659,6 @@ function _toPrimitive48(t, r) {
47831
48659
  }
47832
48660
  return ("string" === r ? String : Number)(t);
47833
48661
  }
47834
- function _objectWithoutProperties5(e, t) {
47835
- if (null == e) return {};
47836
- var o, r, i = _objectWithoutPropertiesLoose5(e, t);
47837
- if (Object.getOwnPropertySymbols) {
47838
- var n = Object.getOwnPropertySymbols(e);
47839
- for(r = 0; r < n.length; r++)o = n[r], -1 === t.indexOf(o) && ({}).propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
47840
- }
47841
- return i;
47842
- }
47843
- function _objectWithoutPropertiesLoose5(r, e) {
47844
- if (null == r) return {};
47845
- var t = {};
47846
- for(var n in r)if (({}).hasOwnProperty.call(r, n)) {
47847
- if (-1 !== e.indexOf(n)) continue;
47848
- t[n] = r[n];
47849
- }
47850
- return t;
47851
- }
47852
48662
  var Content9 = function(t0) {
47853
48663
  var $ = _c90(4);
47854
48664
  var children = t0.children, className = t0.className, style = t0.style;
@@ -47872,27 +48682,35 @@ var Content9 = function(t0) {
47872
48682
  return t1;
47873
48683
  };
47874
48684
  var AudioRuntimeProvider = function(t0) {
47875
- var $ = _c90(4);
47876
- var children = t0.children, play = t0.play, onEnd = t0.onEnd;
48685
+ var $ = _c90(6);
48686
+ var children = t0.children, onEnd = t0.onEnd, playback = t0.playback;
47877
48687
  var audioThreadContext = useAudioThreadContext();
47878
48688
  if (audioThreadContext.audioRuntime) {
47879
48689
  return children;
47880
48690
  }
47881
48691
  var t1;
47882
- if ($[0] !== children || $[1] !== onEnd || $[2] !== play) {
47883
- t1 = /* @__PURE__ */ _jsx88(TtsAudioRuntimeProvider, {
47884
- play: play,
47885
- onEnd: onEnd,
48692
+ if ($[0] !== playback) {
48693
+ t1 = playback !== null && playback !== void 0 ? playback : {};
48694
+ $[0] = playback;
48695
+ $[1] = t1;
48696
+ } else {
48697
+ t1 = $[1];
48698
+ }
48699
+ var t2;
48700
+ if ($[2] !== children || $[3] !== onEnd || $[4] !== t1) {
48701
+ t2 = /* @__PURE__ */ _jsx88(TtsAudioRuntimeProvider, _objectSpread50(_objectSpread50({
48702
+ onEnd: onEnd
48703
+ }, t1), {}, {
47886
48704
  children: children
47887
- });
47888
- $[0] = children;
47889
- $[1] = onEnd;
47890
- $[2] = play;
47891
- $[3] = t1;
48705
+ }));
48706
+ $[2] = children;
48707
+ $[3] = onEnd;
48708
+ $[4] = t1;
48709
+ $[5] = t2;
47892
48710
  } else {
47893
- t1 = $[3];
48711
+ t2 = $[5];
47894
48712
  }
47895
- return t1;
48713
+ return t2;
47896
48714
  };
47897
48715
  var Provider5 = function(t0) {
47898
48716
  var $ = _c90(9);
@@ -47901,7 +48719,7 @@ var Provider5 = function(t0) {
47901
48719
  if ($[0] !== t0) {
47902
48720
  var _t = t0;
47903
48721
  children = _t.children;
47904
- rest = _objectWithoutProperties5(_t, _excluded5);
48722
+ rest = _objectWithoutProperties7(_t, _excluded7);
47905
48723
  _t;
47906
48724
  $[0] = t0;
47907
48725
  $[1] = children;
@@ -47913,7 +48731,7 @@ var Provider5 = function(t0) {
47913
48731
  var audioThreadContext = useAudioThreadContext();
47914
48732
  var t1;
47915
48733
  if ($[3] !== audioThreadContext || $[4] !== rest) {
47916
- t1 = _objectSpread48(_objectSpread48({}, audioThreadContext), rest);
48734
+ t1 = _objectSpread50(_objectSpread50({}, audioThreadContext), rest);
47917
48735
  $[3] = audioThreadContext;
47918
48736
  $[4] = rest;
47919
48737
  $[5] = t1;
@@ -47935,76 +48753,91 @@ var Provider5 = function(t0) {
47935
48753
  return t2;
47936
48754
  };
47937
48755
  var Root16 = function(t0) {
47938
- var $ = _c90(18);
48756
+ var $ = _c90(22);
47939
48757
  var children;
47940
48758
  var className;
47941
48759
  var onEnd;
47942
48760
  var play;
48761
+ var playback;
47943
48762
  var rest;
47944
48763
  var style;
47945
48764
  if ($[0] !== t0) {
47946
48765
  var _t2 = t0;
47947
48766
  var ref;
47948
- ref = _t2, children = ref.children, play = ref.play, onEnd = ref.onEnd, className = ref.className, style = ref.style, ref;
47949
- rest = _objectWithoutProperties5(_t2, _excluded22);
48767
+ ref = _t2, children = ref.children, play = ref.play, onEnd = ref.onEnd, className = ref.className, style = ref.style, playback = ref.playback, ref;
48768
+ rest = _objectWithoutProperties7(_t2, _excluded22);
47950
48769
  _t2;
47951
48770
  $[0] = t0;
47952
48771
  $[1] = children;
47953
48772
  $[2] = className;
47954
48773
  $[3] = onEnd;
47955
48774
  $[4] = play;
47956
- $[5] = rest;
47957
- $[6] = style;
48775
+ $[5] = playback;
48776
+ $[6] = rest;
48777
+ $[7] = style;
47958
48778
  } else {
47959
48779
  children = $[1];
47960
48780
  className = $[2];
47961
48781
  onEnd = $[3];
47962
48782
  play = $[4];
47963
- rest = $[5];
47964
- style = $[6];
48783
+ playback = $[5];
48784
+ rest = $[6];
48785
+ style = $[7];
47965
48786
  }
47966
48787
  var t1;
47967
- if ($[7] !== children || $[8] !== className || $[9] !== style) {
47968
- t1 = /* @__PURE__ */ _jsx88(ToastsProvider, {
47969
- children: /* @__PURE__ */ _jsx88(Content9, {
47970
- className: className,
47971
- style: style,
47972
- children: children
47973
- })
47974
- });
47975
- $[7] = children;
47976
- $[8] = className;
47977
- $[9] = style;
48788
+ if ($[8] !== play || $[9] !== playback) {
48789
+ t1 = playback !== null && playback !== void 0 ? playback : play ? {
48790
+ play: play
48791
+ } : void 0;
48792
+ $[8] = play;
48793
+ $[9] = playback;
47978
48794
  $[10] = t1;
47979
48795
  } else {
47980
48796
  t1 = $[10];
47981
48797
  }
48798
+ var playbackOverrides = t1;
47982
48799
  var t2;
47983
- if ($[11] !== onEnd || $[12] !== play || $[13] !== t1) {
47984
- t2 = /* @__PURE__ */ _jsx88(AudioRuntimeProvider, {
47985
- play: play,
47986
- onEnd: onEnd,
47987
- children: t1
48800
+ if ($[11] !== children || $[12] !== className || $[13] !== style) {
48801
+ t2 = /* @__PURE__ */ _jsx88(ToastsProvider, {
48802
+ children: /* @__PURE__ */ _jsx88(Content9, {
48803
+ className: className,
48804
+ style: style,
48805
+ children: children
48806
+ })
47988
48807
  });
47989
- $[11] = onEnd;
47990
- $[12] = play;
47991
- $[13] = t1;
48808
+ $[11] = children;
48809
+ $[12] = className;
48810
+ $[13] = style;
47992
48811
  $[14] = t2;
47993
48812
  } else {
47994
48813
  t2 = $[14];
47995
48814
  }
47996
48815
  var t3;
47997
- if ($[15] !== rest || $[16] !== t2) {
47998
- t3 = /* @__PURE__ */ _jsx88(Provider5, _objectSpread48(_objectSpread48({}, rest), {}, {
48816
+ if ($[15] !== onEnd || $[16] !== playbackOverrides || $[17] !== t2) {
48817
+ t3 = /* @__PURE__ */ _jsx88(AudioRuntimeProvider, {
48818
+ onEnd: onEnd,
48819
+ playback: playbackOverrides,
47999
48820
  children: t2
48821
+ });
48822
+ $[15] = onEnd;
48823
+ $[16] = playbackOverrides;
48824
+ $[17] = t2;
48825
+ $[18] = t3;
48826
+ } else {
48827
+ t3 = $[18];
48828
+ }
48829
+ var t4;
48830
+ if ($[19] !== rest || $[20] !== t3) {
48831
+ t4 = /* @__PURE__ */ _jsx88(Provider5, _objectSpread50(_objectSpread50({}, rest), {}, {
48832
+ children: t3
48000
48833
  }));
48001
- $[15] = rest;
48002
- $[16] = t2;
48003
- $[17] = t3;
48834
+ $[19] = rest;
48835
+ $[20] = t3;
48836
+ $[21] = t4;
48004
48837
  } else {
48005
- t3 = $[17];
48838
+ t4 = $[21];
48006
48839
  }
48007
- return t3;
48840
+ return t4;
48008
48841
  };
48009
48842
  // src/components/threads/AudioThread/Visualization/index.tsx
48010
48843
  import { c as _c92 } from "react-compiler-runtime";
@@ -48128,7 +48961,7 @@ var useStatus = function() {
48128
48961
  };
48129
48962
  // src/components/threads/AudioThread/Visualization/index.tsx
48130
48963
  import { jsx as _jsx90, jsxs as _jsxs31 } from "react/jsx-runtime";
48131
- var _excluded6 = [
48964
+ var _excluded8 = [
48132
48965
  "children"
48133
48966
  ];
48134
48967
  var _excluded23 = [
@@ -48140,7 +48973,7 @@ var _excluded32 = [
48140
48973
  "height",
48141
48974
  "width"
48142
48975
  ];
48143
- function ownKeys49(e, r) {
48976
+ function ownKeys51(e, r) {
48144
48977
  var t = Object.keys(e);
48145
48978
  if (Object.getOwnPropertySymbols) {
48146
48979
  var o = Object.getOwnPropertySymbols(e);
@@ -48150,30 +48983,30 @@ function ownKeys49(e, r) {
48150
48983
  }
48151
48984
  return t;
48152
48985
  }
48153
- function _objectSpread49(e) {
48986
+ function _objectSpread51(e) {
48154
48987
  for(var r = 1; r < arguments.length; r++){
48155
48988
  var t = null != arguments[r] ? arguments[r] : {};
48156
- r % 2 ? ownKeys49(Object(t), true).forEach(function(r2) {
48157
- _defineProperty49(e, r2, t[r2]);
48158
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys49(Object(t)).forEach(function(r2) {
48989
+ r % 2 ? ownKeys51(Object(t), true).forEach(function(r2) {
48990
+ _defineProperty51(e, r2, t[r2]);
48991
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys51(Object(t)).forEach(function(r2) {
48159
48992
  Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
48160
48993
  });
48161
48994
  }
48162
48995
  return e;
48163
48996
  }
48164
- function _defineProperty49(e, r, t) {
48165
- return (r = _toPropertyKey49(r)) in e ? Object.defineProperty(e, r, {
48997
+ function _defineProperty51(e, r, t) {
48998
+ return (r = _toPropertyKey51(r)) in e ? Object.defineProperty(e, r, {
48166
48999
  value: t,
48167
49000
  enumerable: true,
48168
49001
  configurable: true,
48169
49002
  writable: true
48170
49003
  }) : e[r] = t, e;
48171
49004
  }
48172
- function _toPropertyKey49(t) {
48173
- var i = _toPrimitive49(t, "string");
49005
+ function _toPropertyKey51(t) {
49006
+ var i = _toPrimitive51(t, "string");
48174
49007
  return "symbol" == (typeof i === "undefined" ? "undefined" : _type_of(i)) ? i : i + "";
48175
49008
  }
48176
- function _toPrimitive49(t, r) {
49009
+ function _toPrimitive51(t, r) {
48177
49010
  if ("object" != (typeof t === "undefined" ? "undefined" : _type_of(t)) || !t) return t;
48178
49011
  var e = t[Symbol.toPrimitive];
48179
49012
  if (void 0 !== e) {
@@ -48183,16 +49016,16 @@ function _toPrimitive49(t, r) {
48183
49016
  }
48184
49017
  return ("string" === r ? String : Number)(t);
48185
49018
  }
48186
- function _objectWithoutProperties6(e, t) {
49019
+ function _objectWithoutProperties8(e, t) {
48187
49020
  if (null == e) return {};
48188
- var o, r, i = _objectWithoutPropertiesLoose6(e, t);
49021
+ var o, r, i = _objectWithoutPropertiesLoose8(e, t);
48189
49022
  if (Object.getOwnPropertySymbols) {
48190
49023
  var n = Object.getOwnPropertySymbols(e);
48191
49024
  for(r = 0; r < n.length; r++)o = n[r], -1 === t.indexOf(o) && ({}).propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
48192
49025
  }
48193
49026
  return i;
48194
49027
  }
48195
- function _objectWithoutPropertiesLoose6(r, e) {
49028
+ function _objectWithoutPropertiesLoose8(r, e) {
48196
49029
  if (null == r) return {};
48197
49030
  var t = {};
48198
49031
  for(var n in r)if (({}).hasOwnProperty.call(r, n)) {
@@ -48245,7 +49078,7 @@ var Root17 = function(t0) {
48245
49078
  if ($[0] !== t0) {
48246
49079
  var _t = t0;
48247
49080
  children = _t.children;
48248
- rest = _objectWithoutProperties6(_t, _excluded6);
49081
+ rest = _objectWithoutProperties8(_t, _excluded8);
48249
49082
  _t;
48250
49083
  $[0] = t0;
48251
49084
  $[1] = children;
@@ -48257,7 +49090,7 @@ var Root17 = function(t0) {
48257
49090
  var t1;
48258
49091
  if ($[3] !== children || $[4] !== rest) {
48259
49092
  t1 = /* @__PURE__ */ _jsx90(Provider6, {
48260
- children: /* @__PURE__ */ _jsx90(Flex31, _objectSpread49(_objectSpread49({
49093
+ children: /* @__PURE__ */ _jsx90(Flex31, _objectSpread51(_objectSpread51({
48261
49094
  direction: "column",
48262
49095
  align: "center",
48263
49096
  justify: "center",
@@ -48284,7 +49117,7 @@ var BarsVisualizer2 = function(t0) {
48284
49117
  var _t2 = t0;
48285
49118
  var ref;
48286
49119
  ref = _t2, t1 = ref.height, t2 = ref.barWidth, ref;
48287
- rest = _objectWithoutProperties6(_t2, _excluded23);
49120
+ rest = _objectWithoutProperties8(_t2, _excluded23);
48288
49121
  _t2;
48289
49122
  $[0] = t0;
48290
49123
  $[1] = rest;
@@ -48302,7 +49135,7 @@ var BarsVisualizer2 = function(t0) {
48302
49135
  var t3 = status === "playing" ? "var(--accent-11)" : "var(--gray-11)";
48303
49136
  var t4;
48304
49137
  if ($[4] !== audioThreadContext.audioRuntime.assistant.visualizationAnalyser || $[5] !== barWidth || $[6] !== height || $[7] !== rest || $[8] !== t3) {
48305
- t4 = /* @__PURE__ */ _jsx90(BarsVisualizer, _objectSpread49({
49138
+ t4 = /* @__PURE__ */ _jsx90(BarsVisualizer, _objectSpread51({
48306
49139
  visualizationAnalyser: audioThreadContext.audioRuntime.assistant.visualizationAnalyser,
48307
49140
  backgroundColor: t3,
48308
49141
  height: height,
@@ -48329,7 +49162,7 @@ var AssistantVisualizationRoot = function(t0) {
48329
49162
  var _t3 = t0;
48330
49163
  var ref;
48331
49164
  ref = _t3, children = ref.children, t1 = ref.height, t2 = ref.width, ref;
48332
- rest = _objectWithoutProperties6(_t3, _excluded32);
49165
+ rest = _objectWithoutProperties8(_t3, _excluded32);
48333
49166
  _t3;
48334
49167
  $[0] = t0;
48335
49168
  $[1] = children;
@@ -48358,7 +49191,7 @@ var AssistantVisualizationRoot = function(t0) {
48358
49191
  }
48359
49192
  var t5;
48360
49193
  if ($[7] !== scale || $[8] !== t3 || $[9] !== t4) {
48361
- t5 = _objectSpread49({
49194
+ t5 = _objectSpread51({
48362
49195
  backgroundColor: t3,
48363
49196
  borderRadius: "9999px",
48364
49197
  scale: scale
@@ -48372,7 +49205,7 @@ var AssistantVisualizationRoot = function(t0) {
48372
49205
  }
48373
49206
  var t6;
48374
49207
  if ($[11] !== children || $[12] !== height || $[13] !== rest || $[14] !== t5 || $[15] !== width2) {
48375
- t6 = /* @__PURE__ */ _jsx90(Flex31, _objectSpread49(_objectSpread49({
49208
+ t6 = /* @__PURE__ */ _jsx90(Flex31, _objectSpread51(_objectSpread51({
48376
49209
  align: "center",
48377
49210
  justify: "center",
48378
49211
  height: height,
@@ -48403,7 +49236,7 @@ var AssistantVisualization = function(props) {
48403
49236
  }
48404
49237
  var t1;
48405
49238
  if ($[1] !== props) {
48406
- t1 = /* @__PURE__ */ _jsx90(AssistantVisualizationRoot, _objectSpread49(_objectSpread49({}, props), {}, {
49239
+ t1 = /* @__PURE__ */ _jsx90(AssistantVisualizationRoot, _objectSpread51(_objectSpread51({}, props), {}, {
48407
49240
  children: t0
48408
49241
  }));
48409
49242
  $[1] = props;
@@ -48437,7 +49270,7 @@ var AssistantInfo = function(props) {
48437
49270
  }
48438
49271
  var t2;
48439
49272
  if ($[3] !== props || $[4] !== t1) {
48440
- t2 = /* @__PURE__ */ _jsxs31(Flex31, _objectSpread49(_objectSpread49({
49273
+ t2 = /* @__PURE__ */ _jsxs31(Flex31, _objectSpread51(_objectSpread51({
48441
49274
  ml: "-22.5px",
48442
49275
  gap: "3",
48443
49276
  pt: "5"
@@ -48470,7 +49303,7 @@ var Visualization = function(props) {
48470
49303
  }
48471
49304
  var t2;
48472
49305
  if ($[2] !== props) {
48473
- t2 = /* @__PURE__ */ _jsxs31(Root17, _objectSpread49(_objectSpread49({}, props), {}, {
49306
+ t2 = /* @__PURE__ */ _jsxs31(Root17, _objectSpread51(_objectSpread51({}, props), {}, {
48474
49307
  children: [
48475
49308
  t0,
48476
49309
  t1
@@ -48560,7 +49393,7 @@ var StatusMessages = function(t0) {
48560
49393
  };
48561
49394
  // src/components/threads/AudioThread/Status/index.tsx
48562
49395
  import { jsx as _jsx92 } from "react/jsx-runtime";
48563
- function ownKeys50(e, r) {
49396
+ function ownKeys52(e, r) {
48564
49397
  var t = Object.keys(e);
48565
49398
  if (Object.getOwnPropertySymbols) {
48566
49399
  var o = Object.getOwnPropertySymbols(e);
@@ -48570,30 +49403,30 @@ function ownKeys50(e, r) {
48570
49403
  }
48571
49404
  return t;
48572
49405
  }
48573
- function _objectSpread50(e) {
49406
+ function _objectSpread52(e) {
48574
49407
  for(var r = 1; r < arguments.length; r++){
48575
49408
  var t = null != arguments[r] ? arguments[r] : {};
48576
- r % 2 ? ownKeys50(Object(t), true).forEach(function(r2) {
48577
- _defineProperty50(e, r2, t[r2]);
48578
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys50(Object(t)).forEach(function(r2) {
49409
+ r % 2 ? ownKeys52(Object(t), true).forEach(function(r2) {
49410
+ _defineProperty52(e, r2, t[r2]);
49411
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys52(Object(t)).forEach(function(r2) {
48579
49412
  Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
48580
49413
  });
48581
49414
  }
48582
49415
  return e;
48583
49416
  }
48584
- function _defineProperty50(e, r, t) {
48585
- return (r = _toPropertyKey50(r)) in e ? Object.defineProperty(e, r, {
49417
+ function _defineProperty52(e, r, t) {
49418
+ return (r = _toPropertyKey52(r)) in e ? Object.defineProperty(e, r, {
48586
49419
  value: t,
48587
49420
  enumerable: true,
48588
49421
  configurable: true,
48589
49422
  writable: true
48590
49423
  }) : e[r] = t, e;
48591
49424
  }
48592
- function _toPropertyKey50(t) {
48593
- var i = _toPrimitive50(t, "string");
49425
+ function _toPropertyKey52(t) {
49426
+ var i = _toPrimitive52(t, "string");
48594
49427
  return "symbol" == (typeof i === "undefined" ? "undefined" : _type_of(i)) ? i : i + "";
48595
49428
  }
48596
- function _toPrimitive50(t, r) {
49429
+ function _toPrimitive52(t, r) {
48597
49430
  if ("object" != (typeof t === "undefined" ? "undefined" : _type_of(t)) || !t) return t;
48598
49431
  var e = t[Symbol.toPrimitive];
48599
49432
  if (void 0 !== e) {
@@ -48621,7 +49454,7 @@ var Status = function(props) {
48621
49454
  }
48622
49455
  var _t2;
48623
49456
  if ($[1] !== props) {
48624
- _t2 = /* @__PURE__ */ _jsx92(StatusMessages, _objectSpread50({
49457
+ _t2 = /* @__PURE__ */ _jsx92(StatusMessages, _objectSpread52({
48625
49458
  texts: _t
48626
49459
  }, props));
48627
49460
  $[1] = props;
@@ -48647,7 +49480,7 @@ var Status = function(props) {
48647
49480
  }
48648
49481
  var _t4;
48649
49482
  if ($[4] !== props) {
48650
- _t4 = /* @__PURE__ */ _jsx92(StatusMessages, _objectSpread50({
49483
+ _t4 = /* @__PURE__ */ _jsx92(StatusMessages, _objectSpread52({
48651
49484
  texts: _t3
48652
49485
  }, props));
48653
49486
  $[4] = props;
@@ -48669,7 +49502,7 @@ var Status = function(props) {
48669
49502
  }
48670
49503
  var _t6;
48671
49504
  if ($[7] !== props) {
48672
- _t6 = /* @__PURE__ */ _jsx92(StatusMessages, _objectSpread50({
49505
+ _t6 = /* @__PURE__ */ _jsx92(StatusMessages, _objectSpread52({
48673
49506
  texts: _t5
48674
49507
  }, props));
48675
49508
  $[7] = props;
@@ -48690,7 +49523,7 @@ var Status = function(props) {
48690
49523
  }
48691
49524
  var t1;
48692
49525
  if ($[10] !== props) {
48693
- t1 = /* @__PURE__ */ _jsx92(StatusMessages, _objectSpread50({
49526
+ t1 = /* @__PURE__ */ _jsx92(StatusMessages, _objectSpread52({
48694
49527
  texts: t0
48695
49528
  }, props));
48696
49529
  $[10] = props;
@@ -48706,7 +49539,7 @@ import { Flex as Flex34 } from "@radix-ui/themes";
48706
49539
  // src/components/threads/AudioThread/Form/MicIcon.tsx
48707
49540
  import { c as _c95 } from "react-compiler-runtime";
48708
49541
  import { jsx as _jsx93 } from "react/jsx-runtime";
48709
- function ownKeys51(e, r) {
49542
+ function ownKeys53(e, r) {
48710
49543
  var t = Object.keys(e);
48711
49544
  if (Object.getOwnPropertySymbols) {
48712
49545
  var o = Object.getOwnPropertySymbols(e);
@@ -48716,30 +49549,30 @@ function ownKeys51(e, r) {
48716
49549
  }
48717
49550
  return t;
48718
49551
  }
48719
- function _objectSpread51(e) {
49552
+ function _objectSpread53(e) {
48720
49553
  for(var r = 1; r < arguments.length; r++){
48721
49554
  var t = null != arguments[r] ? arguments[r] : {};
48722
- r % 2 ? ownKeys51(Object(t), true).forEach(function(r2) {
48723
- _defineProperty51(e, r2, t[r2]);
48724
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys51(Object(t)).forEach(function(r2) {
49555
+ r % 2 ? ownKeys53(Object(t), true).forEach(function(r2) {
49556
+ _defineProperty53(e, r2, t[r2]);
49557
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys53(Object(t)).forEach(function(r2) {
48725
49558
  Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
48726
49559
  });
48727
49560
  }
48728
49561
  return e;
48729
49562
  }
48730
- function _defineProperty51(e, r, t) {
48731
- return (r = _toPropertyKey51(r)) in e ? Object.defineProperty(e, r, {
49563
+ function _defineProperty53(e, r, t) {
49564
+ return (r = _toPropertyKey53(r)) in e ? Object.defineProperty(e, r, {
48732
49565
  value: t,
48733
49566
  enumerable: true,
48734
49567
  configurable: true,
48735
49568
  writable: true
48736
49569
  }) : e[r] = t, e;
48737
49570
  }
48738
- function _toPropertyKey51(t) {
48739
- var i = _toPrimitive51(t, "string");
49571
+ function _toPropertyKey53(t) {
49572
+ var i = _toPrimitive53(t, "string");
48740
49573
  return "symbol" == (typeof i === "undefined" ? "undefined" : _type_of(i)) ? i : i + "";
48741
49574
  }
48742
- function _toPrimitive51(t, r) {
49575
+ function _toPrimitive53(t, r) {
48743
49576
  if ("object" != (typeof t === "undefined" ? "undefined" : _type_of(t)) || !t) return t;
48744
49577
  var e = t[Symbol.toPrimitive];
48745
49578
  if (void 0 !== e) {
@@ -48763,7 +49596,7 @@ var MicIcon = function(props) {
48763
49596
  }
48764
49597
  var t1;
48765
49598
  if ($[1] !== props) {
48766
- t1 = /* @__PURE__ */ _jsx93("svg", _objectSpread51(_objectSpread51({
49599
+ t1 = /* @__PURE__ */ _jsx93("svg", _objectSpread53(_objectSpread53({
48767
49600
  xmlns: "http://www.w3.org/2000/svg",
48768
49601
  fill: "currentColor",
48769
49602
  stroke: "currentColor",
@@ -48981,7 +49814,7 @@ var ActionButton = function() {
48981
49814
  };
48982
49815
  // src/components/threads/AudioThread/Form/index.tsx
48983
49816
  import { jsx as _jsx95, jsxs as _jsxs34 } from "react/jsx-runtime";
48984
- function ownKeys52(e, r) {
49817
+ function ownKeys54(e, r) {
48985
49818
  var t = Object.keys(e);
48986
49819
  if (Object.getOwnPropertySymbols) {
48987
49820
  var o = Object.getOwnPropertySymbols(e);
@@ -48991,30 +49824,30 @@ function ownKeys52(e, r) {
48991
49824
  }
48992
49825
  return t;
48993
49826
  }
48994
- function _objectSpread52(e) {
49827
+ function _objectSpread54(e) {
48995
49828
  for(var r = 1; r < arguments.length; r++){
48996
49829
  var t = null != arguments[r] ? arguments[r] : {};
48997
- r % 2 ? ownKeys52(Object(t), true).forEach(function(r2) {
48998
- _defineProperty52(e, r2, t[r2]);
48999
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys52(Object(t)).forEach(function(r2) {
49830
+ r % 2 ? ownKeys54(Object(t), true).forEach(function(r2) {
49831
+ _defineProperty54(e, r2, t[r2]);
49832
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys54(Object(t)).forEach(function(r2) {
49000
49833
  Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
49001
49834
  });
49002
49835
  }
49003
49836
  return e;
49004
49837
  }
49005
- function _defineProperty52(e, r, t) {
49006
- return (r = _toPropertyKey52(r)) in e ? Object.defineProperty(e, r, {
49838
+ function _defineProperty54(e, r, t) {
49839
+ return (r = _toPropertyKey54(r)) in e ? Object.defineProperty(e, r, {
49007
49840
  value: t,
49008
49841
  enumerable: true,
49009
49842
  configurable: true,
49010
49843
  writable: true
49011
49844
  }) : e[r] = t, e;
49012
49845
  }
49013
- function _toPropertyKey52(t) {
49014
- var i = _toPrimitive52(t, "string");
49846
+ function _toPropertyKey54(t) {
49847
+ var i = _toPrimitive54(t, "string");
49015
49848
  return "symbol" == (typeof i === "undefined" ? "undefined" : _type_of(i)) ? i : i + "";
49016
49849
  }
49017
- function _toPrimitive52(t, r) {
49850
+ function _toPrimitive54(t, r) {
49018
49851
  if ("object" != (typeof t === "undefined" ? "undefined" : _type_of(t)) || !t) return t;
49019
49852
  var e = t[Symbol.toPrimitive];
49020
49853
  if (void 0 !== e) {
@@ -49112,7 +49945,7 @@ var Form = function(props) {
49112
49945
  }
49113
49946
  var t9;
49114
49947
  if ($[14] !== props || $[15] !== t7) {
49115
- t9 = /* @__PURE__ */ _jsxs34(Flex34, _objectSpread52(_objectSpread52({
49948
+ t9 = /* @__PURE__ */ _jsxs34(Flex34, _objectSpread54(_objectSpread54({
49116
49949
  direction: "column",
49117
49950
  align: "center"
49118
49951
  }, props), {}, {
@@ -49131,7 +49964,7 @@ var Form = function(props) {
49131
49964
  };
49132
49965
  // src/components/threads/AudioThread/index.tsx
49133
49966
  import { jsx as _jsx96, jsxs as _jsxs35 } from "react/jsx-runtime";
49134
- function ownKeys53(e, r) {
49967
+ function ownKeys55(e, r) {
49135
49968
  var t = Object.keys(e);
49136
49969
  if (Object.getOwnPropertySymbols) {
49137
49970
  var o = Object.getOwnPropertySymbols(e);
@@ -49141,30 +49974,30 @@ function ownKeys53(e, r) {
49141
49974
  }
49142
49975
  return t;
49143
49976
  }
49144
- function _objectSpread53(e) {
49977
+ function _objectSpread55(e) {
49145
49978
  for(var r = 1; r < arguments.length; r++){
49146
49979
  var t = null != arguments[r] ? arguments[r] : {};
49147
- r % 2 ? ownKeys53(Object(t), true).forEach(function(r2) {
49148
- _defineProperty53(e, r2, t[r2]);
49149
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys53(Object(t)).forEach(function(r2) {
49980
+ r % 2 ? ownKeys55(Object(t), true).forEach(function(r2) {
49981
+ _defineProperty55(e, r2, t[r2]);
49982
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys55(Object(t)).forEach(function(r2) {
49150
49983
  Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
49151
49984
  });
49152
49985
  }
49153
49986
  return e;
49154
49987
  }
49155
- function _defineProperty53(e, r, t) {
49156
- return (r = _toPropertyKey53(r)) in e ? Object.defineProperty(e, r, {
49988
+ function _defineProperty55(e, r, t) {
49989
+ return (r = _toPropertyKey55(r)) in e ? Object.defineProperty(e, r, {
49157
49990
  value: t,
49158
49991
  enumerable: true,
49159
49992
  configurable: true,
49160
49993
  writable: true
49161
49994
  }) : e[r] = t, e;
49162
49995
  }
49163
- function _toPropertyKey53(t) {
49164
- var i = _toPrimitive53(t, "string");
49996
+ function _toPropertyKey55(t) {
49997
+ var i = _toPrimitive55(t, "string");
49165
49998
  return "symbol" == (typeof i === "undefined" ? "undefined" : _type_of(i)) ? i : i + "";
49166
49999
  }
49167
- function _toPrimitive53(t, r) {
50000
+ function _toPrimitive55(t, r) {
49168
50001
  if ("object" != (typeof t === "undefined" ? "undefined" : _type_of(t)) || !t) return t;
49169
50002
  var e = t[Symbol.toPrimitive];
49170
50003
  if (void 0 !== e) {
@@ -49193,7 +50026,7 @@ var AudioThread = function(props) {
49193
50026
  }
49194
50027
  var t3;
49195
50028
  if ($[3] !== props) {
49196
- t3 = /* @__PURE__ */ _jsxs35(Root16, _objectSpread53(_objectSpread53({}, props), {}, {
50029
+ t3 = /* @__PURE__ */ _jsxs35(Root16, _objectSpread55(_objectSpread55({}, props), {}, {
49197
50030
  children: [
49198
50031
  t0,
49199
50032
  t1,
@@ -49213,7 +50046,7 @@ AudioThread.Status = Status;
49213
50046
  AudioThread.Form = Form;
49214
50047
  // src/components/threads/AudioThreadDialog/index.tsx
49215
50048
  import { jsx as _jsx97, jsxs as _jsxs36 } from "react/jsx-runtime";
49216
- function ownKeys54(e, r) {
50049
+ function ownKeys56(e, r) {
49217
50050
  var t = Object.keys(e);
49218
50051
  if (Object.getOwnPropertySymbols) {
49219
50052
  var o = Object.getOwnPropertySymbols(e);
@@ -49223,30 +50056,30 @@ function ownKeys54(e, r) {
49223
50056
  }
49224
50057
  return t;
49225
50058
  }
49226
- function _objectSpread54(e) {
50059
+ function _objectSpread56(e) {
49227
50060
  for(var r = 1; r < arguments.length; r++){
49228
50061
  var t = null != arguments[r] ? arguments[r] : {};
49229
- r % 2 ? ownKeys54(Object(t), true).forEach(function(r2) {
49230
- _defineProperty54(e, r2, t[r2]);
49231
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys54(Object(t)).forEach(function(r2) {
50062
+ r % 2 ? ownKeys56(Object(t), true).forEach(function(r2) {
50063
+ _defineProperty56(e, r2, t[r2]);
50064
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys56(Object(t)).forEach(function(r2) {
49232
50065
  Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
49233
50066
  });
49234
50067
  }
49235
50068
  return e;
49236
50069
  }
49237
- function _defineProperty54(e, r, t) {
49238
- return (r = _toPropertyKey54(r)) in e ? Object.defineProperty(e, r, {
50070
+ function _defineProperty56(e, r, t) {
50071
+ return (r = _toPropertyKey56(r)) in e ? Object.defineProperty(e, r, {
49239
50072
  value: t,
49240
50073
  enumerable: true,
49241
50074
  configurable: true,
49242
50075
  writable: true
49243
50076
  }) : e[r] = t, e;
49244
50077
  }
49245
- function _toPropertyKey54(t) {
49246
- var i = _toPrimitive54(t, "string");
50078
+ function _toPropertyKey56(t) {
50079
+ var i = _toPrimitive56(t, "string");
49247
50080
  return "symbol" == (typeof i === "undefined" ? "undefined" : _type_of(i)) ? i : i + "";
49248
50081
  }
49249
- function _toPrimitive54(t, r) {
50082
+ function _toPrimitive56(t, r) {
49250
50083
  if ("object" != (typeof t === "undefined" ? "undefined" : _type_of(t)) || !t) return t;
49251
50084
  var e = t[Symbol.toPrimitive];
49252
50085
  if (void 0 !== e) {
@@ -49273,7 +50106,7 @@ var AudioThreadDialog = function(props) {
49273
50106
  }
49274
50107
  var t2;
49275
50108
  if ($[2] !== props) {
49276
- t2 = /* @__PURE__ */ _jsxs36(Root13, _objectSpread54(_objectSpread54({}, props), {}, {
50109
+ t2 = /* @__PURE__ */ _jsxs36(Root13, _objectSpread56(_objectSpread56({}, props), {}, {
49277
50110
  children: [
49278
50111
  t0,
49279
50112
  t1
@@ -49291,7 +50124,7 @@ AudioThreadDialog.Trigger = Trigger;
49291
50124
  AudioThreadDialog.Content = Content8;
49292
50125
  // src/hooks/audioRuntimes/useWebrtcAudioRuntime/index.ts
49293
50126
  import { useEffect as useEffect13, useMemo as useMemo20, useRef as useRef9, useState as useState12 } from "react";
49294
- function asyncGeneratorStep12(n, t, e, r, o, a, c) {
50127
+ function asyncGeneratorStep13(n, t, e, r, o, a, c) {
49295
50128
  try {
49296
50129
  var i = n[a](c), u = i.value;
49297
50130
  } catch (n2) {
@@ -49299,16 +50132,16 @@ function asyncGeneratorStep12(n, t, e, r, o, a, c) {
49299
50132
  }
49300
50133
  i.done ? t(u) : Promise.resolve(u).then(r, o);
49301
50134
  }
49302
- function _asyncToGenerator12(n) {
50135
+ function _asyncToGenerator13(n) {
49303
50136
  return function() {
49304
50137
  var t = this, e = arguments;
49305
50138
  return new Promise(function(r, o) {
49306
50139
  var a = n.apply(t, e);
49307
50140
  function _next(n2) {
49308
- asyncGeneratorStep12(a, r, o, _next, _throw, "next", n2);
50141
+ asyncGeneratorStep13(a, r, o, _next, _throw, "next", n2);
49309
50142
  }
49310
50143
  function _throw(n2) {
49311
- asyncGeneratorStep12(a, r, o, _next, _throw, "throw", n2);
50144
+ asyncGeneratorStep13(a, r, o, _next, _throw, "throw", n2);
49312
50145
  }
49313
50146
  _next(void 0);
49314
50147
  });
@@ -49406,7 +50239,7 @@ var useWebrtcAudioRuntime = function() {
49406
50239
  };
49407
50240
  }, []);
49408
50241
  function _startSessionIfNeeded() {
49409
- _startSessionIfNeeded = _asyncToGenerator12(function() {
50242
+ _startSessionIfNeeded = _asyncToGenerator13(function() {
49410
50243
  return _ts_generator(this, function(_state) {
49411
50244
  switch(_state.label){
49412
50245
  case 0:
@@ -49429,7 +50262,7 @@ var useWebrtcAudioRuntime = function() {
49429
50262
  return _startSessionIfNeeded.apply(this, arguments);
49430
50263
  }
49431
50264
  function _initRealtimeSession() {
49432
- _initRealtimeSession = _asyncToGenerator12(function() {
50265
+ _initRealtimeSession = _asyncToGenerator13(function() {
49433
50266
  var peerConn, audioEl, openaiEventsDataChannel, ms, offer, searchParams_0, sdpResponse, answerSdp, answer, err1;
49434
50267
  return _ts_generator(this, function(_state) {
49435
50268
  switch(_state.label){
@@ -49477,7 +50310,7 @@ var useWebrtcAudioRuntime = function() {
49477
50310
  };
49478
50311
  openaiEventsDataChannel = peerConn.createDataChannel("oai-events");
49479
50312
  openaiEventsDataChannel.addEventListener("message", /* @__PURE__ */ function() {
49480
- var _ref8 = _asyncToGenerator12(function(e) {
50313
+ var _ref8 = _asyncToGenerator13(function(e) {
49481
50314
  var parsedData, searchParams, eventsResponse, reader, decoder, _ref, value, done, buffer, lines, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, line, event, ref;
49482
50315
  return _ts_generator(this, function(_state) {
49483
50316
  switch(_state.label){
@@ -49676,7 +50509,7 @@ var useWebrtcAudioRuntime = function() {
49676
50509
  return _initRealtimeSession.apply(this, arguments);
49677
50510
  }
49678
50511
  var start = /* @__PURE__ */ function() {
49679
- var _ref6 = _asyncToGenerator12(function() {
50512
+ var _ref6 = _asyncToGenerator13(function() {
49680
50513
  return _ts_generator(this, function(_state) {
49681
50514
  switch(_state.label){
49682
50515
  case 0:
@@ -49709,7 +50542,7 @@ var useWebrtcAudioRuntime = function() {
49709
50542
  };
49710
50543
  }();
49711
50544
  var pause = /* @__PURE__ */ function() {
49712
- var _ref7 = _asyncToGenerator12(function() {
50545
+ var _ref7 = _asyncToGenerator13(function() {
49713
50546
  return _ts_generator(this, function(_state) {
49714
50547
  if (!sessionStartedRef.current) return [
49715
50548
  2
@@ -49735,7 +50568,7 @@ var useWebrtcAudioRuntime = function() {
49735
50568
  webrtcAudioRuntime: {
49736
50569
  user: {
49737
50570
  start: function() {
49738
- var _start = _asyncToGenerator12(function() {
50571
+ var _start = _asyncToGenerator13(function() {
49739
50572
  return _ts_generator(this, function(_state) {
49740
50573
  return [
49741
50574
  2
@@ -50071,19 +50904,19 @@ function _temp12(rs) {
50071
50904
  import { c as _c104 } from "react-compiler-runtime";
50072
50905
  import { useMemo as useMemo24 } from "react";
50073
50906
  import { jsx as _jsx100 } from "react/jsx-runtime";
50074
- var _excluded7 = [
50907
+ var _excluded9 = [
50075
50908
  "children"
50076
50909
  ];
50077
- function _objectWithoutProperties7(e, t) {
50910
+ function _objectWithoutProperties9(e, t) {
50078
50911
  if (null == e) return {};
50079
- var o, r, i = _objectWithoutPropertiesLoose7(e, t);
50912
+ var o, r, i = _objectWithoutPropertiesLoose9(e, t);
50080
50913
  if (Object.getOwnPropertySymbols) {
50081
50914
  var n = Object.getOwnPropertySymbols(e);
50082
50915
  for(r = 0; r < n.length; r++)o = n[r], -1 === t.indexOf(o) && ({}).propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
50083
50916
  }
50084
50917
  return i;
50085
50918
  }
50086
- function _objectWithoutPropertiesLoose7(r, e) {
50919
+ function _objectWithoutPropertiesLoose9(r, e) {
50087
50920
  if (null == r) return {};
50088
50921
  var t = {};
50089
50922
  for(var n in r)if (({}).hasOwnProperty.call(r, n)) {
@@ -50099,7 +50932,7 @@ var MarkdownProvider = function(t0) {
50099
50932
  if ($[0] !== t0) {
50100
50933
  var _t = t0;
50101
50934
  children = _t.children;
50102
- rest = _objectWithoutProperties7(_t, _excluded7);
50935
+ rest = _objectWithoutProperties9(_t, _excluded9);
50103
50936
  _t;
50104
50937
  $[0] = t0;
50105
50938
  $[1] = children;
@@ -50340,19 +51173,19 @@ var FileCitation = function(t0) {
50340
51173
  };
50341
51174
  // src/components/annotations/SourceAnnotation/index.tsx
50342
51175
  import { jsx as _jsx103 } from "react/jsx-runtime";
50343
- var _excluded8 = [
51176
+ var _excluded10 = [
50344
51177
  "children"
50345
51178
  ];
50346
- function _objectWithoutProperties8(e, t) {
51179
+ function _objectWithoutProperties10(e, t) {
50347
51180
  if (null == e) return {};
50348
- var o, r, i = _objectWithoutPropertiesLoose8(e, t);
51181
+ var o, r, i = _objectWithoutPropertiesLoose10(e, t);
50349
51182
  if (Object.getOwnPropertySymbols) {
50350
51183
  var n = Object.getOwnPropertySymbols(e);
50351
51184
  for(r = 0; r < n.length; r++)o = n[r], -1 === t.indexOf(o) && ({}).propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
50352
51185
  }
50353
51186
  return i;
50354
51187
  }
50355
- function _objectWithoutPropertiesLoose8(r, e) {
51188
+ function _objectWithoutPropertiesLoose10(r, e) {
50356
51189
  if (null == r) return {};
50357
51190
  var t = {};
50358
51191
  for(var n in r)if (({}).hasOwnProperty.call(r, n)) {
@@ -50368,7 +51201,7 @@ var SourceAnnotation = function(t0) {
50368
51201
  if ($[0] !== t0) {
50369
51202
  var _t = t0;
50370
51203
  children = _t.children;
50371
- rest = _objectWithoutProperties8(_t, _excluded8);
51204
+ rest = _objectWithoutProperties10(_t, _excluded10);
50372
51205
  _t;
50373
51206
  $[0] = t0;
50374
51207
  $[1] = children;
@@ -50643,19 +51476,19 @@ var Avatar6 = function(t0) {
50643
51476
  import { c as _c111 } from "react-compiler-runtime";
50644
51477
  import { useMemo as useMemo26 } from "react";
50645
51478
  import { jsx as _jsx107 } from "react/jsx-runtime";
50646
- var _excluded9 = [
51479
+ var _excluded11 = [
50647
51480
  "children"
50648
51481
  ];
50649
- function _objectWithoutProperties9(e, t) {
51482
+ function _objectWithoutProperties11(e, t) {
50650
51483
  if (null == e) return {};
50651
- var o, r, i = _objectWithoutPropertiesLoose9(e, t);
51484
+ var o, r, i = _objectWithoutPropertiesLoose11(e, t);
50652
51485
  if (Object.getOwnPropertySymbols) {
50653
51486
  var n = Object.getOwnPropertySymbols(e);
50654
51487
  for(r = 0; r < n.length; r++)o = n[r], -1 === t.indexOf(o) && ({}).propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
50655
51488
  }
50656
51489
  return i;
50657
51490
  }
50658
- function _objectWithoutPropertiesLoose9(r, e) {
51491
+ function _objectWithoutPropertiesLoose11(r, e) {
50659
51492
  if (null == r) return {};
50660
51493
  var t = {};
50661
51494
  for(var n in r)if (({}).hasOwnProperty.call(r, n)) {
@@ -50671,7 +51504,7 @@ var ComponentsProvider = function(t0) {
50671
51504
  if ($[0] !== t0) {
50672
51505
  var _t = t0;
50673
51506
  children = _t.children;
50674
- rest = _objectWithoutProperties9(_t, _excluded9);
51507
+ rest = _objectWithoutProperties11(_t, _excluded11);
50675
51508
  _t;
50676
51509
  $[0] = t0;
50677
51510
  $[1] = children;