@superinterface/react 3.10.3 → 3.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -403,6 +403,9 @@ __export(src_exports, {
403
403
  useMessages: function() {
404
404
  return useMessages;
405
405
  },
406
+ useRealtimeWebRTCAudioRuntime: function() {
407
+ return useRealtimeWebRTCAudioRuntime;
408
+ },
406
409
  useSuperinterfaceContext: function() {
407
410
  return useSuperinterfaceContext;
408
411
  },
@@ -411,6 +414,9 @@ __export(src_exports, {
411
414
  },
412
415
  useThreadDialogContext: function() {
413
416
  return useThreadDialogContext;
417
+ },
418
+ useTtsAudioRuntime: function() {
419
+ return useTtsAudioRuntime;
414
420
  }
415
421
  });
416
422
  module.exports = __toCommonJS(src_exports);
@@ -2873,11 +2879,11 @@ function _asyncToGenerator3(n) {
2873
2879
  }
2874
2880
  var threadRunRequiresAction = /* @__PURE__ */ function() {
2875
2881
  var _ref2 = _asyncToGenerator3(function(_ref) {
2876
- var value, queryClient, messagesQueryKey, superinterfaceContext, toolCalls, toolOutputs;
2882
+ var value, superinterfaceContext, toolCalls, toolOutputs;
2877
2883
  return _ts_generator(this, function(_state) {
2878
2884
  switch(_state.label){
2879
2885
  case 0:
2880
- value = _ref.value, queryClient = _ref.queryClient, messagesQueryKey = _ref.messagesQueryKey, superinterfaceContext = _ref.superinterfaceContext;
2886
+ value = _ref.value, superinterfaceContext = _ref.superinterfaceContext;
2881
2887
  if (!(value.data.required_action.type === "submit_client_tool_outputs")) return [
2882
2888
  3,
2883
2889
  2
@@ -8764,124 +8770,20 @@ var import_react_compiler_runtime51 = require("react-compiler-runtime");
8764
8770
  var import_themes58 = require("@radix-ui/themes");
8765
8771
  // src/contexts/threads/AudioThreadContext/index.ts
8766
8772
  var import_react58 = require("react");
8767
- function asyncGeneratorStep10(n, t, e, r, o, a, c) {
8768
- try {
8769
- var i = n[a](c), u = i.value;
8770
- } catch (n2) {
8771
- return void e(n2);
8772
- }
8773
- i.done ? t(u) : Promise.resolve(u).then(r, o);
8774
- }
8775
- function _asyncToGenerator10(n) {
8776
- return function() {
8777
- var t = this, e = arguments;
8778
- return new Promise(function(r, o) {
8779
- var a = n.apply(t, e);
8780
- function _next(n2) {
8781
- asyncGeneratorStep10(a, r, o, _next, _throw, "next", n2);
8782
- }
8783
- function _throw(n2) {
8784
- asyncGeneratorStep10(a, r, o, _next, _throw, "throw", n2);
8785
- }
8786
- _next(void 0);
8787
- });
8788
- };
8789
- }
8790
8773
  var AudioThreadContext = /* @__PURE__ */ (0, import_react58.createContext)({
8791
- status: "idle",
8792
- recorderProps: {
8793
- status: "idle",
8794
- start: function() {
8795
- var _start = _asyncToGenerator10(function() {
8796
- return _ts_generator(this, function(_state) {
8797
- return [
8798
- 2
8799
- ];
8800
- });
8801
- });
8802
- function start() {
8803
- return _start.apply(this, arguments);
8804
- }
8805
- return start;
8806
- }(),
8807
- stop: function() {
8808
- var _stop = _asyncToGenerator10(function() {
8809
- return _ts_generator(this, function(_state) {
8810
- return [
8811
- 2
8812
- ];
8813
- });
8814
- });
8815
- function stop() {
8816
- return _stop.apply(this, arguments);
8817
- }
8818
- return stop;
8819
- }(),
8820
- pause: function() {
8821
- var _pause = _asyncToGenerator10(function() {
8822
- return _ts_generator(this, function(_state) {
8823
- return [
8824
- 2
8825
- ];
8826
- });
8827
- });
8828
- function pause() {
8829
- return _pause.apply(this, arguments);
8830
- }
8831
- return pause;
8832
- }(),
8833
- resume: function() {
8834
- var _resume = _asyncToGenerator10(function() {
8835
- return _ts_generator(this, function(_state) {
8836
- return [
8837
- 2
8838
- ];
8839
- });
8840
- });
8841
- function resume() {
8842
- return _resume.apply(this, arguments);
8843
- }
8844
- return resume;
8845
- }(),
8846
- visualizationAnalyser: null
8847
- },
8848
- // @ts-ignore-next-line
8849
- messageAudioProps: {
8850
- visualizationAnalyser: null,
8851
- playing: false,
8852
- paused: false,
8853
- isReady: false,
8854
- play: function() {
8855
- var _play = _asyncToGenerator10(function() {
8856
- return _ts_generator(this, function(_state) {
8857
- return [
8858
- 2
8859
- ];
8860
- });
8861
- });
8862
- function play() {
8863
- return _play.apply(this, arguments);
8864
- }
8865
- return play;
8866
- }(),
8867
- pause: function() {
8868
- var _pause2 = _asyncToGenerator10(function() {
8869
- return _ts_generator(this, function(_state) {
8870
- return [
8871
- 2
8872
- ];
8873
- });
8874
- });
8875
- function pause() {
8876
- return _pause2.apply(this, arguments);
8877
- }
8878
- return pause;
8879
- }()
8880
- }
8774
+ audioRuntime: null
8881
8775
  });
8776
+ // src/hooks/threads/useAudioThreadContext/index.ts
8777
+ var import_react59 = require("react");
8778
+ var useAudioThreadContext = function() {
8779
+ return (0, import_react59.useContext)(AudioThreadContext);
8780
+ };
8781
+ // src/hooks/audioRuntimes/useTtsAudioRuntime/index.ts
8782
+ var import_react_compiler_runtime50 = require("react-compiler-runtime");
8783
+ var import_react64 = require("react");
8882
8784
  // src/hooks/misc/usePermission/index.ts
8883
8785
  var import_react_compiler_runtime47 = require("react-compiler-runtime");
8884
- var import_react59 = require("react");
8786
+ var import_react60 = require("react");
8885
8787
  // src/hooks/misc/usePermission/util.ts
8886
8788
  var noop = function() {};
8887
8789
  function on(obj) {
@@ -8905,7 +8807,7 @@ function off(obj) {
8905
8807
  // src/hooks/misc/usePermission/index.ts
8906
8808
  var usePermission = function(permissionDesc) {
8907
8809
  var $ = (0, import_react_compiler_runtime47.c)(3);
8908
- var _ref = _sliced_to_array((0, import_react59.useState)(""), 2), state = _ref[0], setState = _ref[1];
8810
+ var _ref = _sliced_to_array((0, import_react60.useState)(""), 2), state = _ref[0], setState = _ref[1];
8909
8811
  var t0;
8910
8812
  var t1;
8911
8813
  if ($[0] !== permissionDesc) {
@@ -8944,86 +8846,19 @@ var usePermission = function(permissionDesc) {
8944
8846
  t0 = $[1];
8945
8847
  t1 = $[2];
8946
8848
  }
8947
- (0, import_react59.useEffect)(t0, t1);
8849
+ (0, import_react60.useEffect)(t0, t1);
8948
8850
  return state;
8949
8851
  };
8950
- // src/components/threads/AudioThread/Root/lib/blobToData.ts
8951
- var blobToData = function(blob) {
8952
- return new Promise(function(resolve) {
8953
- var reader = new FileReader();
8954
- reader.onloadend = function() {
8955
- return resolve(reader.result);
8956
- };
8957
- reader.readAsDataURL(blob);
8958
- });
8959
- };
8960
- // src/hooks/audioThreads/useStatus/index.ts
8961
- var import_react_compiler_runtime48 = require("react-compiler-runtime");
8962
- var import_react60 = require("react");
8963
- var useStatus = function(t0) {
8964
- var $ = (0, import_react_compiler_runtime48.c)(2);
8965
- var messageAudioProps = t0.messageAudioProps, recorderProps = t0.recorderProps, createMessageProps = t0.createMessageProps;
8966
- var latestMessageProps = useLatestMessage();
8967
- var t1;
8968
- bb0: {
8969
- var _latestMessageProps$l;
8970
- if (recorderProps.status === "recording") {
8971
- t1 = "recording";
8972
- break bb0;
8973
- }
8974
- if (createMessageProps.isPending) {
8975
- t1 = "creatingMessage";
8976
- break bb0;
8977
- }
8978
- if (messageAudioProps.paused || !messageAudioProps.isAudioPlayed) {
8979
- t1 = "playerPaused";
8980
- break bb0;
8981
- }
8982
- if (messageAudioProps.playing || messageAudioProps.isPending) {
8983
- t1 = "playing";
8984
- break bb0;
8985
- }
8986
- if (!messageAudioProps.isAudioPlayed && !messageAudioProps.isReady) {
8987
- t1 = "loading";
8988
- break bb0;
8989
- }
8990
- if (((_latestMessageProps$l = latestMessageProps.latestMessage) === null || _latestMessageProps$l === void 0 ? void 0 : _latestMessageProps$l.status) === "in_progress") {
8991
- t1 = "creatingMessage";
8992
- break bb0;
8993
- }
8994
- if (recorderProps.status === "idle") {
8995
- t1 = "idle";
8996
- break bb0;
8997
- }
8998
- if (recorderProps.status === "paused") {
8999
- t1 = "recorderPaused";
9000
- break bb0;
9001
- }
9002
- t1 = "loading";
9003
- }
9004
- var status = t1;
9005
- var t2;
9006
- if ($[0] !== status) {
9007
- t2 = {
9008
- status: status
9009
- };
9010
- $[0] = status;
9011
- $[1] = t2;
9012
- } else {
9013
- t2 = $[1];
9014
- }
9015
- return t2;
9016
- };
9017
8852
  // src/hooks/audioThreads/useRecorder/index.ts
9018
8853
  var import_dayjs3 = __toESM(require("dayjs"), 1);
9019
8854
  var import_use_audio_capture = require("use-audio-capture");
9020
8855
  var import_react62 = require("react");
9021
8856
  var import_react_use_audio_player = require("react-use-audio-player");
9022
8857
  // src/hooks/misc/useInterval.ts
9023
- var import_react_compiler_runtime49 = require("react-compiler-runtime");
8858
+ var import_react_compiler_runtime48 = require("react-compiler-runtime");
9024
8859
  var import_react61 = require("react");
9025
8860
  var useInterval = function(callback, delay) {
9026
- var $ = (0, import_react_compiler_runtime49.c)(5);
8861
+ var $ = (0, import_react_compiler_runtime48.c)(5);
9027
8862
  var savedCallback = (0, import_react61.useRef)(_temp10);
9028
8863
  var t0;
9029
8864
  if ($[0] !== callback) {
@@ -9106,7 +8941,7 @@ function _toPrimitive44(t, r) {
9106
8941
  }
9107
8942
  return ("string" === r ? String : Number)(t);
9108
8943
  }
9109
- function asyncGeneratorStep11(n, t, e, r, o, a, c) {
8944
+ function asyncGeneratorStep10(n, t, e, r, o, a, c) {
9110
8945
  try {
9111
8946
  var i = n[a](c), u = i.value;
9112
8947
  } catch (n2) {
@@ -9114,16 +8949,16 @@ function asyncGeneratorStep11(n, t, e, r, o, a, c) {
9114
8949
  }
9115
8950
  i.done ? t(u) : Promise.resolve(u).then(r, o);
9116
8951
  }
9117
- function _asyncToGenerator11(n) {
8952
+ function _asyncToGenerator10(n) {
9118
8953
  return function() {
9119
8954
  var t = this, e = arguments;
9120
8955
  return new Promise(function(r, o) {
9121
8956
  var a = n.apply(t, e);
9122
8957
  function _next(n2) {
9123
- asyncGeneratorStep11(a, r, o, _next, _throw, "next", n2);
8958
+ asyncGeneratorStep10(a, r, o, _next, _throw, "next", n2);
9124
8959
  }
9125
8960
  function _throw(n2) {
9126
- asyncGeneratorStep11(a, r, o, _next, _throw, "throw", n2);
8961
+ asyncGeneratorStep10(a, r, o, _next, _throw, "throw", n2);
9127
8962
  }
9128
8963
  _next(void 0);
9129
8964
  });
@@ -9156,7 +8991,7 @@ var useRecorder = function(_ref) {
9156
8991
  setNoiseStart(null);
9157
8992
  },
9158
8993
  onStop: function() {
9159
- var _onStop2 = _asyncToGenerator11(function() {
8994
+ var _onStop2 = _asyncToGenerator10(function() {
9160
8995
  var _arguments = arguments;
9161
8996
  return _ts_generator(this, function(_state) {
9162
8997
  switch(_state.label){
@@ -9276,7 +9111,7 @@ var useRecorder = function(_ref) {
9276
9111
  });
9277
9112
  };
9278
9113
  // src/hooks/audioThreads/useMessageAudio/index.ts
9279
- var import_react_compiler_runtime50 = require("react-compiler-runtime");
9114
+ var import_react_compiler_runtime49 = require("react-compiler-runtime");
9280
9115
  var import_react63 = require("react");
9281
9116
  var import_compromise = __toESM(require("compromise"), 1);
9282
9117
  var import_howler = require("howler");
@@ -9358,7 +9193,8 @@ var getMessageSentences = function(_ref) {
9358
9193
  });
9359
9194
  };
9360
9195
  var useMessageAudio = function(t0) {
9361
- var $ = (0, import_react_compiler_runtime50.c)(50);
9196
+ var _latestMessageProps$l;
9197
+ var $ = (0, import_react_compiler_runtime49.c)(50);
9362
9198
  var _onEnd = t0.onEnd, passedPlay = t0.play;
9363
9199
  var _ref = _sliced_to_array((0, import_react63.useState)(false), 2), isAudioPlayed = _ref[0], setIsAudioPlayed = _ref[1];
9364
9200
  var t1;
@@ -9468,7 +9304,7 @@ var useMessageAudio = function(t0) {
9468
9304
  var searchParams = new URLSearchParams(_objectSpread45({
9469
9305
  input: input_0
9470
9306
  }, superinterfaceContext.variables));
9471
- audioPlayer.load("".concat(superinterfaceContext.baseUrl, "/tts?").concat(searchParams), {
9307
+ audioPlayer.load("".concat(superinterfaceContext.baseUrl, "/audio-runtimes/tts?").concat(searchParams), {
9472
9308
  format: "mp3",
9473
9309
  autoplay: isAudioPlayed,
9474
9310
  html5: isHtmlAudioSupported,
@@ -9486,7 +9322,7 @@ var useMessageAudio = function(t0) {
9486
9322
  var nextSearchParams = new URLSearchParams(_objectSpread45({
9487
9323
  input: nextUnplayedMessageSentence.sentence
9488
9324
  }, superinterfaceContext.variables));
9489
- nextAudioPlayer.load("".concat(superinterfaceContext.baseUrl, "/tts?").concat(nextSearchParams), {
9325
+ nextAudioPlayer.load("".concat(superinterfaceContext.baseUrl, "/audio-runtimes/tts?").concat(nextSearchParams), {
9490
9326
  format: "mp3",
9491
9327
  autoplay: false,
9492
9328
  html5: isHtmlAudioSupported
@@ -9673,7 +9509,7 @@ var useMessageAudio = function(t0) {
9673
9509
  }
9674
9510
  var visualizationAnalyser = t11;
9675
9511
  var t12;
9676
- t12 = isPlaying || unplayedMessageSentences.length > 0;
9512
+ t12 = isPlaying || unplayedMessageSentences.length > 0 || ((_latestMessageProps$l = latestMessageProps.latestMessage) === null || _latestMessageProps$l === void 0 ? void 0 : _latestMessageProps$l.status) === "in_progress";
9677
9513
  var isPending = t12;
9678
9514
  var t13;
9679
9515
  if ($[45] !== audioPlayer || $[46] !== isAudioPlayed || $[47] !== isPending || $[48] !== visualizationAnalyser) {
@@ -9702,74 +9538,20 @@ function _temp11() {
9702
9538
  import_howler.Howler._howls[0]._sounds[0]._node.crossOrigin = "anonymous";
9703
9539
  }
9704
9540
  }
9705
- // src/components/threads/AudioThread/Root/index.tsx
9541
+ // src/hooks/audioRuntimes/useTtsAudioRuntime/index.ts
9706
9542
  var import_react_query10 = require("@tanstack/react-query");
9707
- var import_jsx_runtime82 = require("react/jsx-runtime");
9708
- var _excluded5 = [
9709
- "children"
9710
- ];
9711
- function ownKeys46(e, r) {
9712
- var t = Object.keys(e);
9713
- if (Object.getOwnPropertySymbols) {
9714
- var o = Object.getOwnPropertySymbols(e);
9715
- r && (o = o.filter(function(r2) {
9716
- return Object.getOwnPropertyDescriptor(e, r2).enumerable;
9717
- })), t.push.apply(t, o);
9718
- }
9719
- return t;
9720
- }
9721
- function _objectSpread46(e) {
9722
- for(var r = 1; r < arguments.length; r++){
9723
- var t = null != arguments[r] ? arguments[r] : {};
9724
- r % 2 ? ownKeys46(Object(t), true).forEach(function(r2) {
9725
- _defineProperty46(e, r2, t[r2]);
9726
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys46(Object(t)).forEach(function(r2) {
9727
- Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
9728
- });
9729
- }
9730
- return e;
9731
- }
9732
- function _defineProperty46(e, r, t) {
9733
- return (r = _toPropertyKey46(r)) in e ? Object.defineProperty(e, r, {
9734
- value: t,
9735
- enumerable: true,
9736
- configurable: true,
9737
- writable: true
9738
- }) : e[r] = t, e;
9739
- }
9740
- function _toPropertyKey46(t) {
9741
- var i = _toPrimitive46(t, "string");
9742
- return "symbol" == (typeof i === "undefined" ? "undefined" : _type_of(i)) ? i : i + "";
9743
- }
9744
- function _toPrimitive46(t, r) {
9745
- if ("object" != (typeof t === "undefined" ? "undefined" : _type_of(t)) || !t) return t;
9746
- var e = t[Symbol.toPrimitive];
9747
- if (void 0 !== e) {
9748
- var i = e.call(t, r || "default");
9749
- if ("object" != (typeof i === "undefined" ? "undefined" : _type_of(i))) return i;
9750
- throw new TypeError("@@toPrimitive must return a primitive value.");
9751
- }
9752
- return ("string" === r ? String : Number)(t);
9753
- }
9754
- function _objectWithoutProperties5(e, t) {
9755
- if (null == e) return {};
9756
- var o, r, i = _objectWithoutPropertiesLoose5(e, t);
9757
- if (Object.getOwnPropertySymbols) {
9758
- var s = Object.getOwnPropertySymbols(e);
9759
- for(r = 0; r < s.length; r++)o = s[r], t.includes(o) || ({}).propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
9760
- }
9761
- return i;
9762
- }
9763
- function _objectWithoutPropertiesLoose5(r, e) {
9764
- if (null == r) return {};
9765
- var t = {};
9766
- for(var n in r)if (({}).hasOwnProperty.call(r, n)) {
9767
- if (e.includes(n)) continue;
9768
- t[n] = r[n];
9769
- }
9770
- return t;
9771
- }
9772
- function asyncGeneratorStep12(n, t, e, r, o, a, c) {
9543
+ // src/hooks/audioRuntimes/useTtsAudioRuntime/blobToData.ts
9544
+ var blobToData = function(blob) {
9545
+ return new Promise(function(resolve) {
9546
+ var reader = new FileReader();
9547
+ reader.onloadend = function() {
9548
+ return resolve(reader.result);
9549
+ };
9550
+ reader.readAsDataURL(blob);
9551
+ });
9552
+ };
9553
+ // src/hooks/audioRuntimes/useTtsAudioRuntime/index.ts
9554
+ function asyncGeneratorStep11(n, t, e, r, o, a, c) {
9773
9555
  try {
9774
9556
  var i = n[a](c), u = i.value;
9775
9557
  } catch (n2) {
@@ -9777,27 +9559,37 @@ function asyncGeneratorStep12(n, t, e, r, o, a, c) {
9777
9559
  }
9778
9560
  i.done ? t(u) : Promise.resolve(u).then(r, o);
9779
9561
  }
9780
- function _asyncToGenerator12(n) {
9562
+ function _asyncToGenerator11(n) {
9781
9563
  return function() {
9782
9564
  var t = this, e = arguments;
9783
9565
  return new Promise(function(r, o) {
9784
9566
  var a = n.apply(t, e);
9785
9567
  function _next(n2) {
9786
- asyncGeneratorStep12(a, r, o, _next, _throw, "next", n2);
9568
+ asyncGeneratorStep11(a, r, o, _next, _throw, "next", n2);
9787
9569
  }
9788
9570
  function _throw(n2) {
9789
- asyncGeneratorStep12(a, r, o, _next, _throw, "throw", n2);
9571
+ asyncGeneratorStep11(a, r, o, _next, _throw, "throw", n2);
9790
9572
  }
9791
9573
  _next(void 0);
9792
9574
  });
9793
9575
  };
9794
9576
  }
9795
- var Content8 = function(t0) {
9796
- var $ = (0, import_react_compiler_runtime51.c)(24);
9797
- var children = t0.children, className = t0.className, style = t0.style, play = t0.play;
9577
+ var useTtsAudioRuntime = function(t0) {
9578
+ var $ = (0, import_react_compiler_runtime50.c)(30);
9579
+ var play = t0.play;
9798
9580
  var addToast = useToasts().addToast;
9799
9581
  var queryClient = (0, import_react_query10.useQueryClient)();
9800
9582
  var threadContext = useSuperinterfaceContext();
9583
+ var t1;
9584
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
9585
+ t1 = {
9586
+ name: "microphone"
9587
+ };
9588
+ $[0] = t1;
9589
+ } else {
9590
+ t1 = $[0];
9591
+ }
9592
+ var microphonePermission = usePermission(t1);
9801
9593
  var createMessageProps = useCreateMessage({
9802
9594
  onError: function(error) {
9803
9595
  createMessageDefaultOnError({
@@ -9808,13 +9600,13 @@ var Content8 = function(t0) {
9808
9600
  recorderProps.start();
9809
9601
  }
9810
9602
  });
9811
- var t1;
9812
- if ($[0] !== createMessageProps) {
9813
- t1 = {
9603
+ var t2;
9604
+ if ($[1] !== createMessageProps) {
9605
+ t2 = {
9814
9606
  isStopOnSilence: true,
9815
9607
  onStart: _temp12,
9816
9608
  onStop: function() {
9817
- var _onStop = _asyncToGenerator12(function(_event, chunks) {
9609
+ var _onStop = _asyncToGenerator11(function(_event, chunks) {
9818
9610
  var blob, audioContent;
9819
9611
  return _ts_generator(this, function(_state) {
9820
9612
  switch(_state.label){
@@ -9843,22 +9635,12 @@ var Content8 = function(t0) {
9843
9635
  return onStop;
9844
9636
  }()
9845
9637
  };
9846
- $[0] = createMessageProps;
9847
- $[1] = t1;
9848
- } else {
9849
- t1 = $[1];
9850
- }
9851
- var recorderProps = useRecorder(t1);
9852
- var t2;
9853
- if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
9854
- t2 = {
9855
- name: "microphone"
9856
- };
9638
+ $[1] = createMessageProps;
9857
9639
  $[2] = t2;
9858
9640
  } else {
9859
9641
  t2 = $[2];
9860
9642
  }
9861
- var microphonePermission = usePermission(t2);
9643
+ var recorderProps = useRecorder(t2);
9862
9644
  var t3;
9863
9645
  if ($[3] !== microphonePermission || $[4] !== recorderProps) {
9864
9646
  t3 = function() {
@@ -9885,81 +9667,91 @@ var Content8 = function(t0) {
9885
9667
  t4 = $[8];
9886
9668
  }
9887
9669
  var messageAudioProps = useMessageAudio(t4);
9888
- var t5 = recorderProps;
9889
- var t6;
9890
- if ($[9] !== createMessageProps || $[10] !== messageAudioProps || $[11] !== t5) {
9891
- t6 = {
9892
- recorderProps: t5,
9893
- createMessageProps: createMessageProps,
9894
- messageAudioProps: messageAudioProps
9670
+ recorderProps;
9671
+ recorderProps;
9672
+ recorderProps;
9673
+ recorderProps;
9674
+ recorderProps;
9675
+ recorderProps;
9676
+ recorderProps;
9677
+ var t5;
9678
+ var t6 = recorderProps;
9679
+ var t7 = recorderProps;
9680
+ var t8 = recorderProps;
9681
+ var t9 = recorderProps;
9682
+ var t10 = recorderProps;
9683
+ var t11 = recorderProps;
9684
+ var t12;
9685
+ if ($[9] !== createMessageProps.isPending || $[10] !== t10.visualizationAnalyser || $[11] !== t11.status || $[12] !== t6.start || $[13] !== t7.stop || $[14] !== t8.pause || $[15] !== t9.resume) {
9686
+ t12 = {
9687
+ start: t6.start,
9688
+ stop: t7.stop,
9689
+ pause: t8.pause,
9690
+ resume: t9.resume,
9691
+ isPending: createMessageProps.isPending,
9692
+ visualizationAnalyser: t10.visualizationAnalyser,
9693
+ rawStatus: t11.status
9895
9694
  };
9896
- $[9] = createMessageProps;
9897
- $[10] = messageAudioProps;
9898
- $[11] = t5;
9899
- $[12] = t6;
9695
+ $[9] = createMessageProps.isPending;
9696
+ $[10] = t10.visualizationAnalyser;
9697
+ $[11] = t11.status;
9698
+ $[12] = t6.start;
9699
+ $[13] = t7.stop;
9700
+ $[14] = t8.pause;
9701
+ $[15] = t9.resume;
9702
+ $[16] = t12;
9900
9703
  } else {
9901
- t6 = $[12];
9704
+ t12 = $[16];
9902
9705
  }
9903
- var status = useStatus(t6).status;
9904
- var t7 = recorderProps;
9905
- var t8;
9906
- if ($[13] !== messageAudioProps || $[14] !== status || $[15] !== t7) {
9907
- t8 = {
9908
- status: status,
9909
- recorderProps: t7,
9910
- messageAudioProps: messageAudioProps
9706
+ var t13;
9707
+ 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) {
9708
+ t13 = {
9709
+ play: messageAudioProps.play,
9710
+ pause: messageAudioProps.pause,
9711
+ stop: messageAudioProps.stop,
9712
+ visualizationAnalyser: messageAudioProps.visualizationAnalyser,
9713
+ playing: messageAudioProps.playing,
9714
+ paused: messageAudioProps.paused,
9715
+ isPending: messageAudioProps.isPending,
9716
+ isReady: messageAudioProps.isReady,
9717
+ isAudioPlayed: messageAudioProps.isAudioPlayed,
9718
+ rawStatus: void 0
9911
9719
  };
9912
- $[13] = messageAudioProps;
9913
- $[14] = status;
9914
- $[15] = t7;
9915
- $[16] = t8;
9916
- } else {
9917
- t8 = $[16];
9918
- }
9919
- var t9;
9920
- if ($[17] !== children || $[18] !== className || $[19] !== style) {
9921
- t9 = /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(import_themes58.Flex, {
9922
- direction: "column",
9923
- flexGrow: "1",
9924
- p: "9",
9925
- className: className,
9926
- style: style,
9927
- children: children
9928
- });
9929
- $[17] = children;
9930
- $[18] = className;
9931
- $[19] = style;
9932
- $[20] = t9;
9933
- } else {
9934
- t9 = $[20];
9935
- }
9936
- var t10;
9937
- if ($[21] !== t8 || $[22] !== t9) {
9938
- t10 = /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(AudioThreadContext.Provider, {
9939
- value: t8,
9940
- children: t9
9941
- });
9942
- $[21] = t8;
9943
- $[22] = t9;
9944
- $[23] = t10;
9720
+ $[17] = messageAudioProps.isAudioPlayed;
9721
+ $[18] = messageAudioProps.isPending;
9722
+ $[19] = messageAudioProps.isReady;
9723
+ $[20] = messageAudioProps.pause;
9724
+ $[21] = messageAudioProps.paused;
9725
+ $[22] = messageAudioProps.play;
9726
+ $[23] = messageAudioProps.playing;
9727
+ $[24] = messageAudioProps.stop;
9728
+ $[25] = messageAudioProps.visualizationAnalyser;
9729
+ $[26] = t13;
9730
+ } else {
9731
+ t13 = $[26];
9732
+ }
9733
+ var t14;
9734
+ if ($[27] !== t12 || $[28] !== t13) {
9735
+ t14 = {
9736
+ ttsAudioRuntime: {
9737
+ user: t12,
9738
+ assistant: t13
9739
+ }
9740
+ };
9741
+ $[27] = t12;
9742
+ $[28] = t13;
9743
+ $[29] = t14;
9945
9744
  } else {
9946
- t10 = $[23];
9745
+ t14 = $[29];
9947
9746
  }
9948
- return t10;
9949
- };
9950
- var Root12 = function(_ref) {
9951
- var children = _ref.children, rest = _objectWithoutProperties5(_ref, _excluded5);
9952
- return /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(ToastsProvider, {
9953
- children: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(Content8, _objectSpread46(_objectSpread46({}, rest), {}, {
9954
- children: children
9955
- }))
9956
- });
9747
+ t5 = t14;
9748
+ return t5;
9957
9749
  };
9958
9750
  function _temp12() {
9959
9751
  return _temp23.apply(this, arguments);
9960
9752
  }
9961
9753
  function _temp23() {
9962
- _temp23 = _asyncToGenerator12(function() {
9754
+ _temp23 = _asyncToGenerator11(function() {
9963
9755
  return _ts_generator(this, function(_state) {
9964
9756
  return [
9965
9757
  2
@@ -9968,15 +9760,207 @@ function _temp23() {
9968
9760
  });
9969
9761
  return _temp23.apply(this, arguments);
9970
9762
  }
9763
+ // src/components/threads/AudioThread/Root/index.tsx
9764
+ var import_jsx_runtime82 = require("react/jsx-runtime");
9765
+ var _excluded5 = [
9766
+ "children"
9767
+ ];
9768
+ var _excluded22 = [
9769
+ "children",
9770
+ "play",
9771
+ "className",
9772
+ "style"
9773
+ ];
9774
+ function ownKeys46(e, r) {
9775
+ var t = Object.keys(e);
9776
+ if (Object.getOwnPropertySymbols) {
9777
+ var o = Object.getOwnPropertySymbols(e);
9778
+ r && (o = o.filter(function(r2) {
9779
+ return Object.getOwnPropertyDescriptor(e, r2).enumerable;
9780
+ })), t.push.apply(t, o);
9781
+ }
9782
+ return t;
9783
+ }
9784
+ function _objectSpread46(e) {
9785
+ for(var r = 1; r < arguments.length; r++){
9786
+ var t = null != arguments[r] ? arguments[r] : {};
9787
+ r % 2 ? ownKeys46(Object(t), true).forEach(function(r2) {
9788
+ _defineProperty46(e, r2, t[r2]);
9789
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys46(Object(t)).forEach(function(r2) {
9790
+ Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
9791
+ });
9792
+ }
9793
+ return e;
9794
+ }
9795
+ function _defineProperty46(e, r, t) {
9796
+ return (r = _toPropertyKey46(r)) in e ? Object.defineProperty(e, r, {
9797
+ value: t,
9798
+ enumerable: true,
9799
+ configurable: true,
9800
+ writable: true
9801
+ }) : e[r] = t, e;
9802
+ }
9803
+ function _toPropertyKey46(t) {
9804
+ var i = _toPrimitive46(t, "string");
9805
+ return "symbol" == (typeof i === "undefined" ? "undefined" : _type_of(i)) ? i : i + "";
9806
+ }
9807
+ function _toPrimitive46(t, r) {
9808
+ if ("object" != (typeof t === "undefined" ? "undefined" : _type_of(t)) || !t) return t;
9809
+ var e = t[Symbol.toPrimitive];
9810
+ if (void 0 !== e) {
9811
+ var i = e.call(t, r || "default");
9812
+ if ("object" != (typeof i === "undefined" ? "undefined" : _type_of(i))) return i;
9813
+ throw new TypeError("@@toPrimitive must return a primitive value.");
9814
+ }
9815
+ return ("string" === r ? String : Number)(t);
9816
+ }
9817
+ function _objectWithoutProperties5(e, t) {
9818
+ if (null == e) return {};
9819
+ var o, r, i = _objectWithoutPropertiesLoose5(e, t);
9820
+ if (Object.getOwnPropertySymbols) {
9821
+ var s = Object.getOwnPropertySymbols(e);
9822
+ for(r = 0; r < s.length; r++)o = s[r], t.includes(o) || ({}).propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
9823
+ }
9824
+ return i;
9825
+ }
9826
+ function _objectWithoutPropertiesLoose5(r, e) {
9827
+ if (null == r) return {};
9828
+ var t = {};
9829
+ for(var n in r)if (({}).hasOwnProperty.call(r, n)) {
9830
+ if (e.includes(n)) continue;
9831
+ t[n] = r[n];
9832
+ }
9833
+ return t;
9834
+ }
9835
+ var Content8 = function(_ref) {
9836
+ var children = _ref.children, className = _ref.className, style = _ref.style;
9837
+ return /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(import_themes58.Flex, {
9838
+ direction: "column",
9839
+ flexGrow: "1",
9840
+ p: "9",
9841
+ className: className,
9842
+ style: style,
9843
+ children: children
9844
+ });
9845
+ };
9846
+ var TtsAudioRuntime = function(t0) {
9847
+ var $ = (0, import_react_compiler_runtime51.c)(7);
9848
+ var children = t0.children, play = t0.play;
9849
+ var t1;
9850
+ if ($[0] !== play) {
9851
+ t1 = {
9852
+ play: play
9853
+ };
9854
+ $[0] = play;
9855
+ $[1] = t1;
9856
+ } else {
9857
+ t1 = $[1];
9858
+ }
9859
+ var ttsAudioRuntime = useTtsAudioRuntime(t1).ttsAudioRuntime;
9860
+ var t2;
9861
+ if ($[2] !== ttsAudioRuntime) {
9862
+ t2 = {
9863
+ audioRuntime: ttsAudioRuntime
9864
+ };
9865
+ $[2] = ttsAudioRuntime;
9866
+ $[3] = t2;
9867
+ } else {
9868
+ t2 = $[3];
9869
+ }
9870
+ var t3;
9871
+ if ($[4] !== children || $[5] !== t2) {
9872
+ t3 = /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(AudioThreadContext.Provider, {
9873
+ value: t2,
9874
+ children: children
9875
+ });
9876
+ $[4] = children;
9877
+ $[5] = t2;
9878
+ $[6] = t3;
9879
+ } else {
9880
+ t3 = $[6];
9881
+ }
9882
+ return t3;
9883
+ };
9884
+ var AudioRuntimeProvider = function(t0) {
9885
+ var $ = (0, import_react_compiler_runtime51.c)(3);
9886
+ var children = t0.children, play = t0.play;
9887
+ var audioThreadContext = useAudioThreadContext();
9888
+ if (audioThreadContext.audioRuntime) {
9889
+ return children;
9890
+ }
9891
+ var t1;
9892
+ if ($[0] !== children || $[1] !== play) {
9893
+ t1 = /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(TtsAudioRuntime, {
9894
+ play: play,
9895
+ children: children
9896
+ });
9897
+ $[0] = children;
9898
+ $[1] = play;
9899
+ $[2] = t1;
9900
+ } else {
9901
+ t1 = $[2];
9902
+ }
9903
+ return t1;
9904
+ };
9905
+ var Provider5 = function(t0) {
9906
+ var $ = (0, import_react_compiler_runtime51.c)(9);
9907
+ var children;
9908
+ var rest;
9909
+ if ($[0] !== t0) {
9910
+ var _t = t0;
9911
+ children = _t.children;
9912
+ rest = _objectWithoutProperties5(_t, _excluded5);
9913
+ _t;
9914
+ $[0] = t0;
9915
+ $[1] = children;
9916
+ $[2] = rest;
9917
+ } else {
9918
+ children = $[1];
9919
+ rest = $[2];
9920
+ }
9921
+ var audioThreadContext = useAudioThreadContext();
9922
+ var t1;
9923
+ if ($[3] !== audioThreadContext || $[4] !== rest) {
9924
+ t1 = _objectSpread46(_objectSpread46({}, audioThreadContext), rest);
9925
+ $[3] = audioThreadContext;
9926
+ $[4] = rest;
9927
+ $[5] = t1;
9928
+ } else {
9929
+ t1 = $[5];
9930
+ }
9931
+ var t2;
9932
+ if ($[6] !== children || $[7] !== t1) {
9933
+ t2 = /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(AudioThreadContext.Provider, {
9934
+ value: t1,
9935
+ children: children
9936
+ });
9937
+ $[6] = children;
9938
+ $[7] = t1;
9939
+ $[8] = t2;
9940
+ } else {
9941
+ t2 = $[8];
9942
+ }
9943
+ return t2;
9944
+ };
9945
+ var Root12 = function(_ref2) {
9946
+ var children = _ref2.children, play = _ref2.play, className = _ref2.className, style = _ref2.style, rest = _objectWithoutProperties5(_ref2, _excluded22);
9947
+ return /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(Provider5, _objectSpread46(_objectSpread46({}, rest), {}, {
9948
+ children: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(AudioRuntimeProvider, {
9949
+ play: play,
9950
+ children: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(ToastsProvider, {
9951
+ children: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(Content8, {
9952
+ className: className,
9953
+ style: style,
9954
+ children: children
9955
+ })
9956
+ })
9957
+ })
9958
+ }));
9959
+ };
9971
9960
  // src/components/threads/AudioThread/Visualization/index.tsx
9972
- var import_react66 = require("react");
9961
+ var import_react67 = require("react");
9973
9962
  var import_lodash9 = __toESM(require("lodash"), 1);
9974
9963
  var import_themes60 = require("@radix-ui/themes");
9975
- // src/hooks/threads/useAudioThreadContext/index.ts
9976
- var import_react64 = require("react");
9977
- var useAudioThreadContext = function() {
9978
- return (0, import_react64.useContext)(AudioThreadContext);
9979
- };
9980
9964
  // src/components/threads/AudioThread/BarsVisualizer/index.tsx
9981
9965
  var import_lodash8 = __toESM(require("lodash"), 1);
9982
9966
  var import_themes59 = require("@radix-ui/themes");
@@ -10041,6 +10025,57 @@ var BarsVisualizer = function(_ref) {
10041
10025
  })
10042
10026
  });
10043
10027
  };
10028
+ // src/hooks/audioThreads/useStatus/index.ts
10029
+ var import_react_compiler_runtime52 = require("react-compiler-runtime");
10030
+ var import_react66 = require("react");
10031
+ var useStatus = function() {
10032
+ var $ = (0, import_react_compiler_runtime52.c)(2);
10033
+ var audioRuntime = useAudioThreadContext().audioRuntime;
10034
+ var t0;
10035
+ bb0: {
10036
+ if (audioRuntime.user.rawStatus === "recording") {
10037
+ t0 = "recording";
10038
+ break bb0;
10039
+ }
10040
+ if (audioRuntime.user.isPending) {
10041
+ t0 = "creatingMessage";
10042
+ break bb0;
10043
+ }
10044
+ if (audioRuntime.assistant.paused || !audioRuntime.assistant.isAudioPlayed) {
10045
+ t0 = "playerPaused";
10046
+ break bb0;
10047
+ }
10048
+ if (audioRuntime.assistant.playing || audioRuntime.assistant.isPending) {
10049
+ t0 = "playing";
10050
+ break bb0;
10051
+ }
10052
+ if (!audioRuntime.assistant.isAudioPlayed && !audioRuntime.assistant.isReady) {
10053
+ t0 = "loading";
10054
+ break bb0;
10055
+ }
10056
+ if (audioRuntime.user.rawStatus === "idle") {
10057
+ t0 = "idle";
10058
+ break bb0;
10059
+ }
10060
+ if (audioRuntime.user.rawStatus === "paused") {
10061
+ t0 = "recorderPaused";
10062
+ break bb0;
10063
+ }
10064
+ t0 = "loading";
10065
+ }
10066
+ var status = t0;
10067
+ var t1;
10068
+ if ($[0] !== status) {
10069
+ t1 = {
10070
+ status: status
10071
+ };
10072
+ $[0] = status;
10073
+ $[1] = t1;
10074
+ } else {
10075
+ t1 = $[1];
10076
+ }
10077
+ return t1;
10078
+ };
10044
10079
  // src/components/threads/AudioThread/Visualization/index.tsx
10045
10080
  var import_jsx_runtime84 = require("react/jsx-runtime");
10046
10081
  function ownKeys47(e, r) {
@@ -10087,10 +10122,11 @@ function _toPrimitive47(t, r) {
10087
10122
  return ("string" === r ? String : Number)(t);
10088
10123
  }
10089
10124
  var Visualization = function(props) {
10125
+ var status = useStatus().status;
10090
10126
  var audioThreadContext = useAudioThreadContext();
10091
- var assistantNameContext = (0, import_react66.useContext)(AssistantNameContext);
10092
- var _ref = _sliced_to_array((0, import_react66.useState)(0), 2), scale = _ref[0], setScale = _ref[1];
10093
- var draw = (0, import_react66.useCallback)(function(_ref) {
10127
+ var assistantNameContext = (0, import_react67.useContext)(AssistantNameContext);
10128
+ var _ref = _sliced_to_array((0, import_react67.useState)(0), 2), scale = _ref[0], setScale = _ref[1];
10129
+ var draw = (0, import_react67.useCallback)(function(_ref) {
10094
10130
  var visualizationAnalyser = _ref.visualizationAnalyser;
10095
10131
  if (!visualizationAnalyser) {
10096
10132
  setScale(1);
@@ -10105,9 +10141,9 @@ var Visualization = function(props) {
10105
10141
  });
10106
10142
  });
10107
10143
  }, []);
10108
- (0, import_react66.useEffect)(function() {
10144
+ (0, import_react67.useEffect)(function() {
10109
10145
  draw({
10110
- visualizationAnalyser: audioThreadContext.recorderProps.visualizationAnalyser
10146
+ visualizationAnalyser: audioThreadContext.audioRuntime.user.visualizationAnalyser
10111
10147
  });
10112
10148
  }, [
10113
10149
  draw,
@@ -10127,13 +10163,13 @@ var Visualization = function(props) {
10127
10163
  height: "200px",
10128
10164
  width: "200px",
10129
10165
  style: {
10130
- backgroundColor: audioThreadContext.status === "playing" ? "var(--accent-4)" : "var(--gray-4)",
10166
+ backgroundColor: status === "playing" ? "var(--accent-4)" : "var(--gray-4)",
10131
10167
  borderRadius: "9999px",
10132
10168
  scale: scale
10133
10169
  },
10134
10170
  children: /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(BarsVisualizer, {
10135
- visualizationAnalyser: audioThreadContext.messageAudioProps.visualizationAnalyser,
10136
- backgroundColor: audioThreadContext.status === "playing" ? "var(--accent-11)" : "var(--gray-11)",
10171
+ visualizationAnalyser: audioThreadContext.audioRuntime.assistant.visualizationAnalyser,
10172
+ backgroundColor: status === "playing" ? "var(--accent-11)" : "var(--gray-11)",
10137
10173
  height: "40px",
10138
10174
  barWidth: "24px"
10139
10175
  })
@@ -10153,7 +10189,7 @@ var Visualization = function(props) {
10153
10189
  }));
10154
10190
  };
10155
10191
  // src/components/threads/AudioThread/Status/index.tsx
10156
- var import_react_compiler_runtime52 = require("react-compiler-runtime");
10192
+ var import_react_compiler_runtime53 = require("react-compiler-runtime");
10157
10193
  // src/components/threads/AudioThread/Status/StatusMessages.tsx
10158
10194
  var import_themes61 = require("@radix-ui/themes");
10159
10195
  var import_jsx_runtime85 = require("react/jsx-runtime");
@@ -10233,9 +10269,9 @@ function _toPrimitive48(t, r) {
10233
10269
  return ("string" === r ? String : Number)(t);
10234
10270
  }
10235
10271
  var Status = function(props) {
10236
- var $ = (0, import_react_compiler_runtime52.c)(12);
10237
- var audioThreadContext = useAudioThreadContext();
10238
- if (audioThreadContext.status === "recording") {
10272
+ var $ = (0, import_react_compiler_runtime53.c)(12);
10273
+ var status = useStatus().status;
10274
+ if (status === "recording") {
10239
10275
  var _t;
10240
10276
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
10241
10277
  _t = [
@@ -10264,7 +10300,7 @@ var Status = function(props) {
10264
10300
  "recorderPaused",
10265
10301
  "idle",
10266
10302
  "playerPaused"
10267
- ].includes(audioThreadContext.status)) {
10303
+ ].includes(status)) {
10268
10304
  var _t3;
10269
10305
  if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
10270
10306
  _t3 = [
@@ -10286,7 +10322,7 @@ var Status = function(props) {
10286
10322
  }
10287
10323
  return _t4;
10288
10324
  }
10289
- if (audioThreadContext.status === "playing") {
10325
+ if (status === "playing") {
10290
10326
  var _t5;
10291
10327
  if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
10292
10328
  _t5 = [
@@ -10330,7 +10366,7 @@ var Status = function(props) {
10330
10366
  return t1;
10331
10367
  };
10332
10368
  // src/components/threads/AudioThread/Form/index.tsx
10333
- var import_react_compiler_runtime54 = require("react-compiler-runtime");
10369
+ var import_react_compiler_runtime55 = require("react-compiler-runtime");
10334
10370
  var import_themes63 = require("@radix-ui/themes");
10335
10371
  // src/components/threads/AudioThread/Form/MicIcon.tsx
10336
10372
  var import_jsx_runtime87 = require("react/jsx-runtime");
@@ -10394,15 +10430,16 @@ var MicIcon = function(props) {
10394
10430
  }));
10395
10431
  };
10396
10432
  // src/components/threads/AudioThread/Form/ActionButton/index.tsx
10397
- var import_react_compiler_runtime53 = require("react-compiler-runtime");
10433
+ var import_react_compiler_runtime54 = require("react-compiler-runtime");
10398
10434
  var import_themes62 = require("@radix-ui/themes");
10399
10435
  var import_react_icons17 = require("@radix-ui/react-icons");
10400
10436
  var import_jsx_runtime88 = require("react/jsx-runtime");
10401
10437
  var ActionButton = function() {
10402
- var $ = (0, import_react_compiler_runtime53.c)(27);
10438
+ var $ = (0, import_react_compiler_runtime54.c)(27);
10439
+ var status = useStatus().status;
10403
10440
  var audioThreadContext = useAudioThreadContext();
10404
10441
  var superinterfaceContext = useSuperinterfaceContext();
10405
- if (audioThreadContext.status === "recording") {
10442
+ if (status === "recording") {
10406
10443
  var _t;
10407
10444
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
10408
10445
  _t = /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(import_react_icons17.PauseIcon, {});
@@ -10411,19 +10448,19 @@ var ActionButton = function() {
10411
10448
  _t = $[0];
10412
10449
  }
10413
10450
  var t1;
10414
- if ($[1] !== audioThreadContext.recorderProps.pause) {
10451
+ if ($[1] !== audioThreadContext.audioRuntime.user.pause) {
10415
10452
  t1 = /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(import_themes62.Flex, {
10416
10453
  mr: "3",
10417
10454
  ml: "-7",
10418
10455
  children: /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(import_themes62.IconButton, {
10419
- onClick: audioThreadContext.recorderProps.pause,
10456
+ onClick: audioThreadContext.audioRuntime.user.pause,
10420
10457
  color: "gray",
10421
10458
  variant: "soft",
10422
10459
  size: "1",
10423
10460
  children: _t
10424
10461
  })
10425
10462
  });
10426
- $[1] = audioThreadContext.recorderProps.pause;
10463
+ $[1] = audioThreadContext.audioRuntime.user.pause;
10427
10464
  $[2] = t1;
10428
10465
  } else {
10429
10466
  t1 = $[2];
@@ -10436,15 +10473,15 @@ var ActionButton = function() {
10436
10473
  t2 = $[3];
10437
10474
  }
10438
10475
  var t3;
10439
- if ($[4] !== audioThreadContext.recorderProps.stop) {
10476
+ if ($[4] !== audioThreadContext.audioRuntime.user.stop) {
10440
10477
  t3 = /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(import_themes62.IconButton, {
10441
- onClick: audioThreadContext.recorderProps.stop,
10478
+ onClick: audioThreadContext.audioRuntime.user.stop,
10442
10479
  highContrast: true,
10443
10480
  variant: "soft",
10444
10481
  size: "4",
10445
10482
  children: t2
10446
10483
  });
10447
- $[4] = audioThreadContext.recorderProps.stop;
10484
+ $[4] = audioThreadContext.audioRuntime.user.stop;
10448
10485
  $[5] = t3;
10449
10486
  } else {
10450
10487
  t3 = $[5];
@@ -10466,7 +10503,7 @@ var ActionButton = function() {
10466
10503
  }
10467
10504
  return t4;
10468
10505
  }
10469
- if (audioThreadContext.status === "recorderPaused") {
10506
+ if (status === "recorderPaused") {
10470
10507
  var _t2;
10471
10508
  if ($[9] === Symbol.for("react.memo_cache_sentinel")) {
10472
10509
  _t2 = /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(import_react_icons17.ResumeIcon, {});
@@ -10475,48 +10512,48 @@ var ActionButton = function() {
10475
10512
  _t2 = $[9];
10476
10513
  }
10477
10514
  var _t3;
10478
- if ($[10] !== audioThreadContext.recorderProps.resume) {
10515
+ if ($[10] !== audioThreadContext.audioRuntime.user.resume) {
10479
10516
  _t3 = /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(import_themes62.IconButton, {
10480
- onClick: audioThreadContext.recorderProps.resume,
10517
+ onClick: audioThreadContext.audioRuntime.user.resume,
10481
10518
  color: "red",
10482
10519
  size: "4",
10483
10520
  children: _t2
10484
10521
  });
10485
- $[10] = audioThreadContext.recorderProps.resume;
10522
+ $[10] = audioThreadContext.audioRuntime.user.resume;
10486
10523
  $[11] = _t3;
10487
10524
  } else {
10488
10525
  _t3 = $[11];
10489
10526
  }
10490
10527
  return _t3;
10491
10528
  }
10492
- if (audioThreadContext.status === "idle") {
10529
+ if (status === "idle") {
10493
10530
  var _t4;
10494
- if ($[12] !== audioThreadContext.recorderProps) {
10531
+ if ($[12] !== audioThreadContext.audioRuntime.user) {
10495
10532
  _t4 = /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(import_themes62.IconButton, {
10496
10533
  onClick: function() {
10497
- return audioThreadContext.recorderProps.start();
10534
+ return audioThreadContext.audioRuntime.user.start();
10498
10535
  },
10499
10536
  size: "4",
10500
10537
  color: "red"
10501
10538
  });
10502
- $[12] = audioThreadContext.recorderProps;
10539
+ $[12] = audioThreadContext.audioRuntime.user;
10503
10540
  $[13] = _t4;
10504
10541
  } else {
10505
10542
  _t4 = $[13];
10506
10543
  }
10507
10544
  return _t4;
10508
10545
  }
10509
- if (audioThreadContext.status === "playing") {
10546
+ if (status === "playing") {
10510
10547
  var _t5;
10511
- if ($[14] !== audioThreadContext.messageAudioProps || $[15] !== audioThreadContext.recorderProps || $[16] !== superinterfaceContext.createMessageAbortControllerRef.current) {
10548
+ if ($[14] !== audioThreadContext.audioRuntime.assistant || $[15] !== audioThreadContext.audioRuntime.user || $[16] !== superinterfaceContext.createMessageAbortControllerRef.current) {
10512
10549
  _t5 = function() {
10513
10550
  var _superinterfaceContex;
10514
- audioThreadContext.messageAudioProps.stop();
10551
+ audioThreadContext.audioRuntime.assistant.stop();
10515
10552
  (_superinterfaceContex = superinterfaceContext.createMessageAbortControllerRef.current) === null || _superinterfaceContex === void 0 || _superinterfaceContex.abort();
10516
- audioThreadContext.recorderProps.start();
10553
+ audioThreadContext.audioRuntime.user.start();
10517
10554
  };
10518
- $[14] = audioThreadContext.messageAudioProps;
10519
- $[15] = audioThreadContext.recorderProps;
10555
+ $[14] = audioThreadContext.audioRuntime.assistant;
10556
+ $[15] = audioThreadContext.audioRuntime.user;
10520
10557
  $[16] = superinterfaceContext.createMessageAbortControllerRef.current;
10521
10558
  $[17] = _t5;
10522
10559
  } else {
@@ -10545,13 +10582,13 @@ var ActionButton = function() {
10545
10582
  }
10546
10583
  return _t7;
10547
10584
  }
10548
- if (audioThreadContext.status === "playerPaused") {
10585
+ if (status === "playerPaused") {
10549
10586
  var _t8;
10550
- if ($[21] !== audioThreadContext.messageAudioProps) {
10587
+ if ($[21] !== audioThreadContext.audioRuntime.assistant) {
10551
10588
  _t8 = function() {
10552
- return audioThreadContext.messageAudioProps.play();
10589
+ return audioThreadContext.audioRuntime.assistant.play();
10553
10590
  };
10554
- $[21] = audioThreadContext.messageAudioProps;
10591
+ $[21] = audioThreadContext.audioRuntime.assistant;
10555
10592
  $[22] = _t8;
10556
10593
  } else {
10557
10594
  _t8 = $[22];
@@ -10636,9 +10673,10 @@ function _toPrimitive50(t, r) {
10636
10673
  return ("string" === r ? String : Number)(t);
10637
10674
  }
10638
10675
  var Form = function(props) {
10639
- var $ = (0, import_react_compiler_runtime54.c)(17);
10676
+ var $ = (0, import_react_compiler_runtime55.c)(17);
10677
+ var status = useStatus().status;
10640
10678
  var audioThreadContext = useAudioThreadContext();
10641
- var t0 = audioThreadContext.status === "recording" ? "var(--accent-11)" : "var(--gray-11)";
10679
+ var t0 = status === "recording" ? "var(--accent-11)" : "var(--gray-11)";
10642
10680
  var t1;
10643
10681
  if ($[0] !== t0) {
10644
10682
  t1 = /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(import_themes63.Flex, {
@@ -10656,7 +10694,7 @@ var Form = function(props) {
10656
10694
  } else {
10657
10695
  t1 = $[1];
10658
10696
  }
10659
- var t2 = audioThreadContext.status === "recording" ? "var(--accent-4)" : "var(--gray-4)";
10697
+ var t2 = status === "recording" ? "var(--accent-4)" : "var(--gray-4)";
10660
10698
  var t3;
10661
10699
  if ($[2] !== t2) {
10662
10700
  t3 = {
@@ -10668,16 +10706,16 @@ var Form = function(props) {
10668
10706
  } else {
10669
10707
  t3 = $[3];
10670
10708
  }
10671
- var t4 = audioThreadContext.status === "recording" ? "var(--accent-11)" : "var(--gray-11)";
10709
+ var t4 = status === "recording" ? "var(--accent-11)" : "var(--gray-11)";
10672
10710
  var t5;
10673
- if ($[4] !== audioThreadContext.recorderProps.visualizationAnalyser || $[5] !== t4) {
10711
+ if ($[4] !== audioThreadContext.audioRuntime.user.visualizationAnalyser || $[5] !== t4) {
10674
10712
  t5 = /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(BarsVisualizer, {
10675
- visualizationAnalyser: audioThreadContext.recorderProps.visualizationAnalyser,
10713
+ visualizationAnalyser: audioThreadContext.audioRuntime.user.visualizationAnalyser,
10676
10714
  backgroundColor: t4,
10677
10715
  height: "20px",
10678
10716
  barWidth: "12px"
10679
10717
  });
10680
- $[4] = audioThreadContext.recorderProps.visualizationAnalyser;
10718
+ $[4] = audioThreadContext.audioRuntime.user.visualizationAnalyser;
10681
10719
  $[5] = t4;
10682
10720
  $[6] = t5;
10683
10721
  } else {
@@ -10855,9 +10893,441 @@ var AudioThreadDialog = function(props) {
10855
10893
  AudioThreadDialog.Root = Root9;
10856
10894
  AudioThreadDialog.Trigger = Trigger;
10857
10895
  AudioThreadDialog.Content = Content7;
10896
+ // src/hooks/audioRuntimes/useRealtimeWebRTCAudioRuntime/index.ts
10897
+ var import_react68 = require("react");
10898
+ function asyncGeneratorStep12(n, t, e, r, o, a, c) {
10899
+ try {
10900
+ var i = n[a](c), u = i.value;
10901
+ } catch (n2) {
10902
+ return void e(n2);
10903
+ }
10904
+ i.done ? t(u) : Promise.resolve(u).then(r, o);
10905
+ }
10906
+ function _asyncToGenerator12(n) {
10907
+ return function() {
10908
+ var t = this, e = arguments;
10909
+ return new Promise(function(r, o) {
10910
+ var a = n.apply(t, e);
10911
+ function _next(n2) {
10912
+ asyncGeneratorStep12(a, r, o, _next, _throw, "next", n2);
10913
+ }
10914
+ function _throw(n2) {
10915
+ asyncGeneratorStep12(a, r, o, _next, _throw, "throw", n2);
10916
+ }
10917
+ _next(void 0);
10918
+ });
10919
+ };
10920
+ }
10921
+ var useRealtimeWebRTCAudioRuntime = function() {
10922
+ var startSessionIfNeeded = function startSessionIfNeeded() {
10923
+ return _startSessionIfNeeded.apply(this, arguments);
10924
+ };
10925
+ var initRealtimeSession = function initRealtimeSession() {
10926
+ return _initRealtimeSession.apply(this, arguments);
10927
+ };
10928
+ var buildAnalyzers = function buildAnalyzers(localStream, audioEl_0) {
10929
+ try {
10930
+ var audioCtx1 = new AudioContext();
10931
+ var micSource = audioCtx1.createMediaStreamSource(localStream);
10932
+ var micAnalyser = audioCtx1.createAnalyser();
10933
+ micSource.connect(micAnalyser);
10934
+ userAnalyserRef.current = micAnalyser;
10935
+ audioEl_0.addEventListener("canplay", function() {
10936
+ var audioCtx2 = new AudioContext();
10937
+ var remoteSource = audioCtx2.createMediaElementSource(audioEl_0);
10938
+ var remoteAnalyser = audioCtx2.createAnalyser();
10939
+ remoteSource.connect(remoteAnalyser);
10940
+ remoteSource.connect(audioCtx2.destination);
10941
+ assistantAnalyserRef.current = remoteAnalyser;
10942
+ });
10943
+ } catch (err_0) {
10944
+ console.warn("Could not build analyzers:", err_0);
10945
+ }
10946
+ };
10947
+ var _ref = _sliced_to_array((0, import_react68.useState)("idle"), 2), recorderStatus = _ref[0], setRecorderStatus = _ref[1];
10948
+ var superinterfaceContext = useSuperinterfaceContext();
10949
+ var _ref1 = _sliced_to_array((0, import_react68.useState)(false), 2), userIsPending = _ref1[0], setUserIsPending = _ref1[1];
10950
+ var _ref2 = _sliced_to_array((0, import_react68.useState)(false), 2), assistantPlaying = _ref2[0], setAssistantPlaying = _ref2[1];
10951
+ var _ref3 = _sliced_to_array((0, import_react68.useState)(false), 2), assistantPaused = _ref3[0], setAssistantPaused = _ref3[1];
10952
+ var _ref4 = _sliced_to_array((0, import_react68.useState)(true), 2), assistantIsPending = _ref4[0], setAssistantIsPending = _ref4[1];
10953
+ var _ref5 = _sliced_to_array((0, import_react68.useState)(false), 2), assistantIsReady = _ref5[0], setAssistantIsReady = _ref5[1];
10954
+ var _ref6 = _sliced_to_array((0, import_react68.useState)(false), 2), assistantAudioPlayed = _ref6[0], setAssistantAudioPlayed = _ref6[1];
10955
+ var sessionStartedRef = (0, import_react68.useRef)(false);
10956
+ var pcRef = (0, import_react68.useRef)(null);
10957
+ var localStreamRef = (0, import_react68.useRef)(null);
10958
+ var remoteStreamRef = (0, import_react68.useRef)(null);
10959
+ var userAnalyserRef = (0, import_react68.useRef)(null);
10960
+ var assistantAnalyserRef = (0, import_react68.useRef)(null);
10961
+ var assistantAudioElRef = (0, import_react68.useRef)(null);
10962
+ (0, import_react68.useEffect)(function() {
10963
+ return function() {
10964
+ if (pcRef.current) {
10965
+ pcRef.current.close();
10966
+ pcRef.current = null;
10967
+ }
10968
+ if (assistantAudioElRef.current) {
10969
+ assistantAudioElRef.current.srcObject = null;
10970
+ }
10971
+ };
10972
+ }, []);
10973
+ function _startSessionIfNeeded() {
10974
+ _startSessionIfNeeded = _asyncToGenerator12(function() {
10975
+ return _ts_generator(this, function(_state) {
10976
+ switch(_state.label){
10977
+ case 0:
10978
+ if (sessionStartedRef.current) return [
10979
+ 2
10980
+ ];
10981
+ sessionStartedRef.current = true;
10982
+ return [
10983
+ 4,
10984
+ initRealtimeSession()
10985
+ ];
10986
+ case 1:
10987
+ _state.sent();
10988
+ return [
10989
+ 2
10990
+ ];
10991
+ }
10992
+ });
10993
+ });
10994
+ return _startSessionIfNeeded.apply(this, arguments);
10995
+ }
10996
+ function _initRealtimeSession() {
10997
+ _initRealtimeSession = _asyncToGenerator12(function() {
10998
+ var peerConn, audioEl, ms, offer, searchParams, sdpResponse, answerSdp, answer, err;
10999
+ return _ts_generator(this, function(_state) {
11000
+ switch(_state.label){
11001
+ case 0:
11002
+ _state.trys.push([
11003
+ 0,
11004
+ 7,
11005
+ ,
11006
+ 8
11007
+ ]);
11008
+ setUserIsPending(true);
11009
+ peerConn = new RTCPeerConnection();
11010
+ pcRef.current = peerConn;
11011
+ audioEl = document.createElement("audio");
11012
+ audioEl.autoplay = true;
11013
+ assistantAudioElRef.current = audioEl;
11014
+ peerConn.ontrack = function(evt) {
11015
+ remoteStreamRef.current = evt.streams[0];
11016
+ audioEl.srcObject = evt.streams[0];
11017
+ setAssistantIsPending(false);
11018
+ setAssistantPlaying(true);
11019
+ setAssistantPaused(false);
11020
+ setAssistantAudioPlayed(true);
11021
+ };
11022
+ peerConn.createDataChannel("unused-negotiation-only");
11023
+ peerConn.addEventListener("datachannel", function(event) {
11024
+ var channel = event.channel;
11025
+ if (channel.label === "thread-events") {
11026
+ channel.onmessage = function(_ref) {
11027
+ var data2 = _ref.data;
11028
+ console.log("Data channel message:", data2);
11029
+ var parsedData = JSON.parse(data2);
11030
+ if (parsedData.event === "thread.created") {
11031
+ threadCreated({
11032
+ value: parsedData,
11033
+ superinterfaceContext: superinterfaceContext
11034
+ });
11035
+ } else if (parsedData.event === "thread.run.requires_action") {
11036
+ threadRunRequiresAction({
11037
+ value: parsedData,
11038
+ superinterfaceContext: superinterfaceContext
11039
+ });
11040
+ }
11041
+ };
11042
+ }
11043
+ });
11044
+ return [
11045
+ 4,
11046
+ navigator.mediaDevices.getUserMedia({
11047
+ audio: true
11048
+ })
11049
+ ];
11050
+ case 1:
11051
+ ms = _state.sent();
11052
+ localStreamRef.current = ms;
11053
+ ms.getTracks().forEach(function(t) {
11054
+ peerConn.addTrack(t, ms);
11055
+ });
11056
+ setRecorderStatus("idle");
11057
+ return [
11058
+ 4,
11059
+ peerConn.createOffer()
11060
+ ];
11061
+ case 2:
11062
+ offer = _state.sent();
11063
+ return [
11064
+ 4,
11065
+ peerConn.setLocalDescription(offer)
11066
+ ];
11067
+ case 3:
11068
+ _state.sent();
11069
+ searchParams = new URLSearchParams(variableParams({
11070
+ variables: superinterfaceContext.variables,
11071
+ superinterfaceContext: superinterfaceContext
11072
+ }));
11073
+ return [
11074
+ 4,
11075
+ fetch("".concat(superinterfaceContext.baseUrl, "/audio-runtimes/webrtc?").concat(searchParams), {
11076
+ method: "POST",
11077
+ body: offer.sdp,
11078
+ headers: {
11079
+ "Content-Type": "application/sdp"
11080
+ }
11081
+ })
11082
+ ];
11083
+ case 4:
11084
+ sdpResponse = _state.sent();
11085
+ return [
11086
+ 4,
11087
+ sdpResponse.text()
11088
+ ];
11089
+ case 5:
11090
+ answerSdp = _state.sent();
11091
+ answer = {
11092
+ type: "answer",
11093
+ sdp: answerSdp
11094
+ };
11095
+ return [
11096
+ 4,
11097
+ peerConn.setRemoteDescription(answer)
11098
+ ];
11099
+ case 6:
11100
+ _state.sent();
11101
+ buildAnalyzers(ms, audioEl);
11102
+ setUserIsPending(false);
11103
+ setAssistantIsPending(false);
11104
+ setAssistantIsReady(true);
11105
+ setAssistantPlaying(true);
11106
+ return [
11107
+ 3,
11108
+ 8
11109
+ ];
11110
+ case 7:
11111
+ err = _state.sent();
11112
+ console.error("Error initRealtimeSession:", err);
11113
+ setUserIsPending(false);
11114
+ setRecorderStatus("stopped");
11115
+ setAssistantPlaying(false);
11116
+ setAssistantPaused(false);
11117
+ setAssistantIsPending(false);
11118
+ setAssistantIsReady(false);
11119
+ setAssistantAudioPlayed(false);
11120
+ return [
11121
+ 3,
11122
+ 8
11123
+ ];
11124
+ case 8:
11125
+ return [
11126
+ 2
11127
+ ];
11128
+ }
11129
+ });
11130
+ });
11131
+ return _initRealtimeSession.apply(this, arguments);
11132
+ }
11133
+ return (0, import_react68.useMemo)(function() {
11134
+ return {
11135
+ realtimeWebRTCAudioRuntime: {
11136
+ user: {
11137
+ start: function() {
11138
+ var _start = _asyncToGenerator12(function() {
11139
+ return _ts_generator(this, function(_state) {
11140
+ switch(_state.label){
11141
+ case 0:
11142
+ return [
11143
+ 4,
11144
+ startSessionIfNeeded()
11145
+ ];
11146
+ case 1:
11147
+ _state.sent();
11148
+ setRecorderStatus("recording");
11149
+ if (localStreamRef.current) {
11150
+ localStreamRef.current.getAudioTracks().forEach(function(t_0) {
11151
+ return t_0.enabled = true;
11152
+ });
11153
+ }
11154
+ return [
11155
+ 2
11156
+ ];
11157
+ }
11158
+ });
11159
+ });
11160
+ function start() {
11161
+ return _start.apply(this, arguments);
11162
+ }
11163
+ return start;
11164
+ }(),
11165
+ pause: function() {
11166
+ var _pause = _asyncToGenerator12(function() {
11167
+ return _ts_generator(this, function(_state) {
11168
+ if (!sessionStartedRef.current) return [
11169
+ 2
11170
+ ];
11171
+ setRecorderStatus("paused");
11172
+ if (localStreamRef.current) {
11173
+ localStreamRef.current.getAudioTracks().forEach(function(t_1) {
11174
+ return t_1.enabled = false;
11175
+ });
11176
+ }
11177
+ return [
11178
+ 2
11179
+ ];
11180
+ });
11181
+ });
11182
+ function pause() {
11183
+ return _pause.apply(this, arguments);
11184
+ }
11185
+ return pause;
11186
+ }(),
11187
+ resume: function() {
11188
+ var _resume = _asyncToGenerator12(function() {
11189
+ return _ts_generator(this, function(_state) {
11190
+ if (!sessionStartedRef.current) return [
11191
+ 2
11192
+ ];
11193
+ setRecorderStatus("recording");
11194
+ if (localStreamRef.current) {
11195
+ localStreamRef.current.getAudioTracks().forEach(function(t_2) {
11196
+ return t_2.enabled = true;
11197
+ });
11198
+ }
11199
+ return [
11200
+ 2
11201
+ ];
11202
+ });
11203
+ });
11204
+ function resume() {
11205
+ return _resume.apply(this, arguments);
11206
+ }
11207
+ return resume;
11208
+ }(),
11209
+ stop: function() {
11210
+ var _stop = _asyncToGenerator12(function() {
11211
+ return _ts_generator(this, function(_state) {
11212
+ if (!sessionStartedRef.current) return [
11213
+ 2
11214
+ ];
11215
+ setRecorderStatus("stopped");
11216
+ if (localStreamRef.current) {
11217
+ localStreamRef.current.getTracks().forEach(function(track) {
11218
+ return track.stop();
11219
+ });
11220
+ }
11221
+ return [
11222
+ 2
11223
+ ];
11224
+ });
11225
+ });
11226
+ function stop() {
11227
+ return _stop.apply(this, arguments);
11228
+ }
11229
+ return stop;
11230
+ }(),
11231
+ isPending: userIsPending,
11232
+ visualizationAnalyser: userAnalyserRef.current,
11233
+ rawStatus: recorderStatus
11234
+ },
11235
+ assistant: {
11236
+ play: function() {
11237
+ var _play = _asyncToGenerator12(function() {
11238
+ return _ts_generator(this, function(_state) {
11239
+ switch(_state.label){
11240
+ case 0:
11241
+ return [
11242
+ 4,
11243
+ startSessionIfNeeded()
11244
+ ];
11245
+ case 1:
11246
+ _state.sent();
11247
+ setAssistantPaused(false);
11248
+ setAssistantPlaying(true);
11249
+ if (assistantAudioElRef.current) {
11250
+ assistantAudioElRef.current.play().catch(function(err_1) {
11251
+ console.error("Assistant play error:", err_1);
11252
+ });
11253
+ }
11254
+ return [
11255
+ 2
11256
+ ];
11257
+ }
11258
+ });
11259
+ });
11260
+ function play() {
11261
+ return _play.apply(this, arguments);
11262
+ }
11263
+ return play;
11264
+ }(),
11265
+ pause: function() {
11266
+ var _pause2 = _asyncToGenerator12(function() {
11267
+ return _ts_generator(this, function(_state) {
11268
+ if (!sessionStartedRef.current) return [
11269
+ 2
11270
+ ];
11271
+ setAssistantPaused(true);
11272
+ setAssistantPlaying(false);
11273
+ if (assistantAudioElRef.current) {
11274
+ assistantAudioElRef.current.pause();
11275
+ }
11276
+ return [
11277
+ 2
11278
+ ];
11279
+ });
11280
+ });
11281
+ function pause() {
11282
+ return _pause2.apply(this, arguments);
11283
+ }
11284
+ return pause;
11285
+ }(),
11286
+ stop: function() {
11287
+ var _stop2 = _asyncToGenerator12(function() {
11288
+ return _ts_generator(this, function(_state) {
11289
+ if (!sessionStartedRef.current) return [
11290
+ 2
11291
+ ];
11292
+ setAssistantPaused(false);
11293
+ setAssistantPlaying(false);
11294
+ if (assistantAudioElRef.current) {
11295
+ assistantAudioElRef.current.pause();
11296
+ assistantAudioElRef.current.currentTime = 0;
11297
+ }
11298
+ return [
11299
+ 2
11300
+ ];
11301
+ });
11302
+ });
11303
+ function stop() {
11304
+ return _stop2.apply(this, arguments);
11305
+ }
11306
+ return stop;
11307
+ }(),
11308
+ visualizationAnalyser: assistantAnalyserRef.current,
11309
+ playing: assistantPlaying,
11310
+ paused: assistantPaused,
11311
+ isPending: assistantIsPending,
11312
+ isReady: assistantIsReady,
11313
+ isAudioPlayed: assistantAudioPlayed,
11314
+ rawStatus: void 0
11315
+ }
11316
+ }
11317
+ };
11318
+ }, [
11319
+ recorderStatus,
11320
+ userIsPending,
11321
+ assistantPlaying,
11322
+ assistantPaused,
11323
+ assistantIsPending,
11324
+ assistantIsReady,
11325
+ assistantAudioPlayed
11326
+ ]);
11327
+ };
10858
11328
  // src/components/markdown/MarkdownProvider/index.tsx
10859
- var import_react_compiler_runtime55 = require("react-compiler-runtime");
10860
- var import_react67 = require("react");
11329
+ var import_react_compiler_runtime56 = require("react-compiler-runtime");
11330
+ var import_react69 = require("react");
10861
11331
  var import_jsx_runtime92 = require("react/jsx-runtime");
10862
11332
  var _excluded6 = [
10863
11333
  "children"
@@ -10881,7 +11351,7 @@ function _objectWithoutPropertiesLoose6(r, e) {
10881
11351
  return t;
10882
11352
  }
10883
11353
  var MarkdownProvider = function(t0) {
10884
- var $ = (0, import_react_compiler_runtime55.c)(9);
11354
+ var $ = (0, import_react_compiler_runtime56.c)(9);
10885
11355
  var children;
10886
11356
  var rest;
10887
11357
  if ($[0] !== t0) {
@@ -10924,18 +11394,18 @@ var MarkdownProvider = function(t0) {
10924
11394
  return t3;
10925
11395
  };
10926
11396
  // src/components/annotations/SourceAnnotation/index.tsx
10927
- var import_react_compiler_runtime58 = require("react-compiler-runtime");
11397
+ var import_react_compiler_runtime59 = require("react-compiler-runtime");
10928
11398
  // src/components/annotations/SourceAnnotation/FileCitation/index.tsx
10929
- var import_react_compiler_runtime57 = require("react-compiler-runtime");
10930
- var import_react68 = require("react");
11399
+ var import_react_compiler_runtime58 = require("react-compiler-runtime");
11400
+ var import_react70 = require("react");
10931
11401
  var import_react_icons18 = require("@radix-ui/react-icons");
10932
11402
  var import_themes65 = require("@radix-ui/themes");
10933
11403
  // src/components/annotations/SourceAnnotation/FileCitation/Content.tsx
10934
- var import_react_compiler_runtime56 = require("react-compiler-runtime");
11404
+ var import_react_compiler_runtime57 = require("react-compiler-runtime");
10935
11405
  var import_themes64 = require("@radix-ui/themes");
10936
11406
  var import_jsx_runtime93 = require("react/jsx-runtime");
10937
11407
  var Content9 = function(t0) {
10938
- var $ = (0, import_react_compiler_runtime56.c)(5);
11408
+ var $ = (0, import_react_compiler_runtime57.c)(5);
10939
11409
  var fileId = t0.fileId;
10940
11410
  var superinterfaceContext = useSuperinterfaceContext();
10941
11411
  var nextSearchParams = new URLSearchParams(superinterfaceContext.variables);
@@ -11001,9 +11471,9 @@ var Content9 = function(t0) {
11001
11471
  // src/components/annotations/SourceAnnotation/FileCitation/index.tsx
11002
11472
  var import_jsx_runtime94 = require("react/jsx-runtime");
11003
11473
  var FileCitation = function(t0) {
11004
- var $ = (0, import_react_compiler_runtime57.c)(18);
11474
+ var $ = (0, import_react_compiler_runtime58.c)(18);
11005
11475
  var annotation = t0.annotation;
11006
- var _ref = _sliced_to_array((0, import_react68.useState)(null), 2), activeFileId = _ref[0], setActiveFileId = _ref[1];
11476
+ var _ref = _sliced_to_array((0, import_react70.useState)(null), 2), activeFileId = _ref[0], setActiveFileId = _ref[1];
11007
11477
  var t1;
11008
11478
  if ($[0] !== annotation.file_citation.file_id) {
11009
11479
  t1 = function() {
@@ -11150,7 +11620,7 @@ function _objectWithoutPropertiesLoose7(r, e) {
11150
11620
  return t;
11151
11621
  }
11152
11622
  var SourceAnnotation = function(t0) {
11153
- var $ = (0, import_react_compiler_runtime58.c)(10);
11623
+ var $ = (0, import_react_compiler_runtime59.c)(10);
11154
11624
  var children;
11155
11625
  var rest;
11156
11626
  if ($[0] !== t0) {
@@ -11207,7 +11677,7 @@ var SourceAnnotation = function(t0) {
11207
11677
  return null;
11208
11678
  };
11209
11679
  // src/components/avatars/Avatar.tsx
11210
- var import_react_compiler_runtime61 = require("react-compiler-runtime");
11680
+ var import_react_compiler_runtime62 = require("react-compiler-runtime");
11211
11681
  // src/lib/enums/index.ts
11212
11682
  var IconAvatarName = /* @__PURE__ */ function(IconAvatarName2) {
11213
11683
  IconAvatarName2["BACKPACK"] = "BACKPACK";
@@ -11232,7 +11702,7 @@ var AvatarType = /* @__PURE__ */ function(AvatarType2) {
11232
11702
  // src/components/avatars/Avatar.tsx
11233
11703
  var import_themes68 = require("@radix-ui/themes");
11234
11704
  // src/components/imageAvatars/ImageAvatar/index.tsx
11235
- var import_react_compiler_runtime59 = require("react-compiler-runtime");
11705
+ var import_react_compiler_runtime60 = require("react-compiler-runtime");
11236
11706
  var import_themes66 = require("@radix-ui/themes");
11237
11707
  // src/components/imageAvatars/ImageAvatar/lib/optimizedSrc/path.ts
11238
11708
  var width = function(_ref) {
@@ -11286,7 +11756,7 @@ var optimizedSrc = function(_ref) {
11286
11756
  // src/components/imageAvatars/ImageAvatar/index.tsx
11287
11757
  var import_jsx_runtime96 = require("react/jsx-runtime");
11288
11758
  var ImageAvatar = function(t0) {
11289
- var $ = (0, import_react_compiler_runtime59.c)(9);
11759
+ var $ = (0, import_react_compiler_runtime60.c)(9);
11290
11760
  var imageAvatar = t0.imageAvatar, size = t0.size, className = t0.className, style = t0.style;
11291
11761
  var superinterfaceContext = useSuperinterfaceContext();
11292
11762
  var t1;
@@ -11323,8 +11793,8 @@ var ImageAvatar = function(t0) {
11323
11793
  return t2;
11324
11794
  };
11325
11795
  // src/components/iconAvatars/IconAvatar.tsx
11326
- var import_react_compiler_runtime60 = require("react-compiler-runtime");
11327
- var import_react69 = require("react");
11796
+ var import_react_compiler_runtime61 = require("react-compiler-runtime");
11797
+ var import_react71 = require("react");
11328
11798
  var import_themes67 = require("@radix-ui/themes");
11329
11799
  // src/lib/iconAvatars/iconAvatarComponents.ts
11330
11800
  var import_react_icons19 = require("@radix-ui/react-icons");
@@ -11333,7 +11803,7 @@ var iconAvatarComponents = (_obj = {}, _define_property(_obj, IconAvatarName.BAC
11333
11803
  // src/components/iconAvatars/IconAvatar.tsx
11334
11804
  var import_jsx_runtime97 = require("react/jsx-runtime");
11335
11805
  var IconAvatar = function(t0) {
11336
- var $ = (0, import_react_compiler_runtime60.c)(7);
11806
+ var $ = (0, import_react_compiler_runtime61.c)(7);
11337
11807
  var iconAvatar = t0.iconAvatar, size = t0.size, className = t0.className, style = t0.style;
11338
11808
  var t1;
11339
11809
  t1 = iconAvatarComponents[iconAvatar.name];
@@ -11367,7 +11837,7 @@ var IconAvatar = function(t0) {
11367
11837
  // src/components/avatars/Avatar.tsx
11368
11838
  var import_jsx_runtime98 = require("react/jsx-runtime");
11369
11839
  var Avatar6 = function(t0) {
11370
- var $ = (0, import_react_compiler_runtime61.c)(14);
11840
+ var $ = (0, import_react_compiler_runtime62.c)(14);
11371
11841
  var avatar = t0.avatar, t1 = t0.size, className = t0.className, style = t0.style;
11372
11842
  var size = t1 === void 0 ? "1" : t1;
11373
11843
  if (avatar) {
@@ -11428,12 +11898,12 @@ var Avatar6 = function(t0) {
11428
11898
  return t2;
11429
11899
  };
11430
11900
  // src/components/components/ComponentsProvider.tsx
11431
- var import_react_compiler_runtime62 = require("react-compiler-runtime");
11432
- var import_react71 = require("react");
11901
+ var import_react_compiler_runtime63 = require("react-compiler-runtime");
11902
+ var import_react73 = require("react");
11433
11903
  // src/hooks/components/useComponents.ts
11434
- var import_react70 = require("react");
11904
+ var import_react72 = require("react");
11435
11905
  var useComponents = function() {
11436
- return (0, import_react70.useContext)(ComponentsContext);
11906
+ return (0, import_react72.useContext)(ComponentsContext);
11437
11907
  };
11438
11908
  // src/components/components/ComponentsProvider.tsx
11439
11909
  var import_jsx_runtime99 = require("react/jsx-runtime");
@@ -11459,7 +11929,7 @@ function _objectWithoutPropertiesLoose8(r, e) {
11459
11929
  return t;
11460
11930
  }
11461
11931
  var ComponentsProvider = function(t0) {
11462
- var $ = (0, import_react_compiler_runtime62.c)(9);
11932
+ var $ = (0, import_react_compiler_runtime63.c)(9);
11463
11933
  var children;
11464
11934
  var rest;
11465
11935
  if ($[0] !== t0) {
@@ -11502,11 +11972,11 @@ var ComponentsProvider = function(t0) {
11502
11972
  return t3;
11503
11973
  };
11504
11974
  // src/components/assistants/AssistantProvider/index.tsx
11505
- var import_react_compiler_runtime63 = require("react-compiler-runtime");
11975
+ var import_react_compiler_runtime64 = require("react-compiler-runtime");
11506
11976
  var import_jsx_runtime100 = require("react/jsx-runtime");
11507
11977
  var AssistantProvider = function(t0) {
11508
11978
  var _assistant$name;
11509
- var $ = (0, import_react_compiler_runtime63.c)(10);
11979
+ var $ = (0, import_react_compiler_runtime64.c)(10);
11510
11980
  var children = t0.children;
11511
11981
  var superinterfaceContext = useSuperinterfaceContext();
11512
11982
  var t1;
@@ -11589,8 +12059,10 @@ var AssistantProvider = function(t0) {
11589
12059
  useMessageContext: useMessageContext,
11590
12060
  useMessageFormContext: useMessageFormContext,
11591
12061
  useMessages: useMessages,
12062
+ useRealtimeWebRTCAudioRuntime: useRealtimeWebRTCAudioRuntime,
11592
12063
  useSuperinterfaceContext: useSuperinterfaceContext,
11593
12064
  useThreadContext: useThreadContext,
11594
- useThreadDialogContext: useThreadDialogContext
12065
+ useThreadDialogContext: useThreadDialogContext,
12066
+ useTtsAudioRuntime: useTtsAudioRuntime
11595
12067
  });
11596
12068
  //# sourceMappingURL=index.cjs.map