@feathery/react 2.50.1 → 2.51.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/cjs/Form/index.d.ts.map +1 -1
- package/cjs/assistant/AssistantChat.d.ts +2 -1
- package/cjs/assistant/AssistantChat.d.ts.map +1 -1
- package/cjs/assistant/ToolStatus.d.ts +2 -1
- package/cjs/assistant/ToolStatus.d.ts.map +1 -1
- package/cjs/assistant/icons.d.ts +2 -0
- package/cjs/assistant/icons.d.ts.map +1 -1
- package/cjs/assistant/voice/audioPlayer.d.ts +30 -0
- package/cjs/assistant/voice/audioPlayer.d.ts.map +1 -0
- package/cjs/assistant/voice/useAssistantVoice.d.ts +34 -0
- package/cjs/assistant/voice/useAssistantVoice.d.ts.map +1 -0
- package/cjs/assistant/voice/voiceMic.d.ts +17 -0
- package/cjs/assistant/voice/voiceMic.d.ts.map +1 -0
- package/cjs/{fthry_AssistantChat.Bv_PnXs-.js → fthry_AssistantChat.B45jvKBe.js} +662 -153
- package/cjs/{fthry_FormControl.BAksZlDz.js → fthry_FormControl.EOj0LE3M.js} +1 -1
- package/cjs/{fthry_InlineTooltip.DplyptTz.js → fthry_InlineTooltip.BhdsWEoD.js} +1 -1
- package/cjs/{fthry_PaymentMethodField.DpnN0V1H.js → fthry_PaymentMethodField.DYVjg4Fj.js} +3 -3
- package/cjs/{fthry_Placeholder.5Mvr4ask.js → fthry_Placeholder.CcwNoUeW.js} +1 -1
- package/cjs/{fthry_ShowEyeIcon.5HKujzSD.js → fthry_ShowEyeIcon.DuZqZCnN.js} +1 -1
- package/cjs/{fthry_TabsElement.CxiHTqRU.js → fthry_TabsElement.COJxjNgU.js} +1 -1
- package/cjs/{fthry_auto-track.DV30-QdL.js → fthry_auto-track.B15NDwyR.js} +2 -2
- package/cjs/{fthry_highlighted-body-TPN3WLV5.CtyrCPuE.js → fthry_highlighted-body-TPN3WLV5.DVEo7HUb.js} +3 -3
- package/cjs/{fthry_index.D0tdVxWg.js → fthry_index.2QppVzJs.js} +7 -7
- package/cjs/fthry_index.5X9_5jk4.js +4107 -0
- package/cjs/{fthry_index.DXBYYUOP.js → fthry_index.5xuF2U9h.js} +1 -1
- package/cjs/{fthry_index.lC_5XhON.js → fthry_index.B4C3wGGx.js} +35 -33
- package/cjs/{fthry_index.0UtK4ObD.js → fthry_index.B7S5dgOG.js} +2 -2
- package/cjs/{fthry_index.DmtMegnj.js → fthry_index.BBp1wUpf.js} +4 -4
- package/cjs/{fthry_index.9V9ezpt1.js → fthry_index.BU6ItWDI.js} +4 -4
- package/cjs/{fthry_index.CG2qDLCN.js → fthry_index.BkdG1KiI.js} +3 -3
- package/cjs/{fthry_index.B-vFxNO_.js → fthry_index.BoejAzGy.js} +5 -5
- package/cjs/{fthry_index.DBDbbLL1.js → fthry_index.CDnYVEIO.js} +2 -2
- package/cjs/{fthry_index.B2kwLyNr.js → fthry_index.CEqgOh3U.js} +1 -1
- package/cjs/{fthry_index.DO90MI7L.js → fthry_index.CJ3Hch09.js} +1 -1
- package/cjs/{fthry_index.DFZUCN27.js → fthry_index.CacFIYgr.js} +1 -1
- package/cjs/{fthry_index.GZc-hNji.js → fthry_index.Cmuje9sY.js} +4 -4
- package/cjs/{fthry_index.C5BkZnrm.js → fthry_index.CqhOLSKT.js} +5 -5
- package/cjs/{fthry_index.BQKxTWNQ.js → fthry_index.CvfYbjM3.js} +2 -2
- package/cjs/{fthry_index.Bp0-0Hpt.js → fthry_index.CyHvGApA.js} +4 -4
- package/cjs/{fthry_index.D698F2zZ.js → fthry_index.D0m2Paql.js} +5 -5
- package/cjs/{fthry_index.CB082HFt.js → fthry_index.DJW8jwjF.js} +5 -5
- package/cjs/{fthry_index.DSxhyu57.js → fthry_index.DNDEeQCP.js} +1 -1
- package/cjs/{fthry_index.BUVzO2k5.js → fthry_index.DOmwK88R.js} +1 -1
- package/cjs/{fthry_index.CXiwWMaB.js → fthry_index.DPeoLKPF.js} +1 -1
- package/cjs/{fthry_index.DNf7jYzX.js → fthry_index.DaU9mnVx.js} +3 -3
- package/cjs/{fthry_index.B9iGCw8F.js → fthry_index.DjKpsFXX.js} +2 -2
- package/cjs/{fthry_index.BPYIEjMq.js → fthry_index.DzwfTsQg.js} +10 -10
- package/cjs/{fthry_index.CVkyw_dk.js → fthry_index.HB6IRHEd.js} +2 -2
- package/cjs/{fthry_index.Byf43ZJS.js → fthry_index.RBFHmwlK.js} +3 -3
- package/cjs/{fthry_index.Cbfqikpc.js → fthry_index.Z-VNWfPY.js} +2 -2
- package/cjs/{fthry_index.Dx62aGHl.js → fthry_index.isQxfXbE.js} +1 -1
- package/cjs/{fthry_index.C_0LGAaW.js → fthry_index.j-6Dmxvi.js} +1 -1
- package/cjs/{fthry_index.CXpQuMt1.js → fthry_index.l-vIwCek.js} +1 -1
- package/cjs/{fthry_index.OHud4Plq.js → fthry_index.sb9ekedx.js} +2 -2
- package/cjs/{fthry_index.umd.DCBQBTfy.js → fthry_index.umd.BsAzT2x5.js} +1 -1
- package/cjs/{fthry_input.3B0IH5fK.js → fthry_input.BN_eHBxf.js} +1 -1
- package/cjs/fthry_logging.B-EvoWue.js +24 -0
- package/cjs/fthry_logging.DwsvHsLI.js +29 -0
- package/cjs/{fthry_mermaid-O7DHMXV3.BwkCSjZC.js → fthry_mermaid-O7DHMXV3.Dk3DbMjU.js} +3 -3
- package/cjs/{fthry_script.Dfvbhz8G.js → fthry_script.CMlEfgqJ.js} +1 -1
- package/cjs/{fthry_styles.BecNWwfa.js → fthry_styles.CDAJkFkv.js} +1 -1
- package/cjs/{fthry_useElementSize.D9fwVm32.js → fthry_useElementSize.CdR9C9j1.js} +1 -1
- package/cjs/{fthry_useSalesforceSync.B8WpZf2e.js → fthry_useSalesforceSync.BbSpWhT1.js} +1 -1
- package/cjs/{fthry_webfontloader.maDTrAYi.js → fthry_webfontloader.CRX0Ppbc.js} +1 -1
- package/cjs/index.js +1 -1
- package/cjs/thumbnail-renderer.js +1 -1
- package/cjs/utils/formHelperFunctions.d.ts +1 -0
- package/cjs/utils/formHelperFunctions.d.ts.map +1 -1
- package/dist/Form/index.d.ts.map +1 -1
- package/dist/assistant/AssistantChat.d.ts +2 -1
- package/dist/assistant/AssistantChat.d.ts.map +1 -1
- package/dist/assistant/ToolStatus.d.ts +2 -1
- package/dist/assistant/ToolStatus.d.ts.map +1 -1
- package/dist/assistant/icons.d.ts +2 -0
- package/dist/assistant/icons.d.ts.map +1 -1
- package/dist/assistant/voice/audioPlayer.d.ts +30 -0
- package/dist/assistant/voice/audioPlayer.d.ts.map +1 -0
- package/dist/assistant/voice/useAssistantVoice.d.ts +34 -0
- package/dist/assistant/voice/useAssistantVoice.d.ts.map +1 -0
- package/dist/assistant/voice/voiceMic.d.ts +17 -0
- package/dist/assistant/voice/voiceMic.d.ts.map +1 -0
- package/dist/{fthry_AssistantChat.BWUYjfwA.js → fthry_AssistantChat.DT_xLu9j.js} +662 -153
- package/dist/{fthry_FormControl.gQmC3Q_5.js → fthry_FormControl.CjDYAhmh.js} +1 -1
- package/dist/{fthry_InlineTooltip.M1XQiZpn.js → fthry_InlineTooltip.BXJBh9xO.js} +1 -1
- package/dist/{fthry_PaymentMethodField.DEs0It74.js → fthry_PaymentMethodField.Bmc0ADLl.js} +3 -3
- package/dist/{fthry_Placeholder.B8e4W9VJ.js → fthry_Placeholder.D2CT1bF2.js} +1 -1
- package/dist/{fthry_ShowEyeIcon.DdLap_w9.js → fthry_ShowEyeIcon.2gnnZQwI.js} +1 -1
- package/dist/{fthry_TabsElement.DpJTusbm.js → fthry_TabsElement.CmDA3WMs.js} +1 -1
- package/dist/{fthry_auto-track.HTzxPnUa.js → fthry_auto-track.C318Fmfp.js} +2 -2
- package/dist/{fthry_highlighted-body-TPN3WLV5.kj3f_DpN.js → fthry_highlighted-body-TPN3WLV5.DvjFQ-wQ.js} +3 -3
- package/dist/{fthry_index.CIqCJp4_.js → fthry_index.BAS9Rj3B.js} +4 -4
- package/dist/{fthry_index.CVJtI2Xl.js → fthry_index.BBVonB9-.js} +1 -1
- package/dist/{fthry_index.CkW0oER4.js → fthry_index.BGwZT3G8.js} +5 -5
- package/dist/{fthry_index.DfrV6A68.js → fthry_index.BIOOaSUh.js} +4 -4
- package/dist/{fthry_index.DzM7hukc.js → fthry_index.BMLNnooL.js} +2 -2
- package/dist/{fthry_index.BBhLiIOO.js → fthry_index.BdT62ac-.js} +4 -4
- package/dist/{fthry_index.BDiGpbY8.js → fthry_index.Bh5Hgqlr.js} +2 -2
- package/dist/{fthry_index.DXY-WeCY.js → fthry_index.BiAwHsSn.js} +4 -4
- package/dist/{fthry_index.D4NYHwF9.js → fthry_index.BmPja_lN.js} +7 -7
- package/dist/{fthry_index.Dt6zQK3e.js → fthry_index.BxsXFBiA.js} +4 -4
- package/dist/{fthry_index.CyvJ8-bB.js → fthry_index.CHcVd9z4.js} +2 -2
- package/dist/{fthry_index.ptJrcCPy.js → fthry_index.CI4tFg9l.js} +36 -34
- package/dist/{fthry_index.C4_1X7GA.js → fthry_index.CREmWhTB.js} +5 -5
- package/dist/{fthry_index.DTmSNKnS.js → fthry_index.CSdrmFzH.js} +5 -5
- package/dist/{fthry_index.r1TNpIHy.js → fthry_index.CUyyWToU.js} +1 -1
- package/dist/{fthry_index.D0Cgvg7i.js → fthry_index.ClcVCvSd.js} +3 -3
- package/dist/{fthry_index.Bo8U-enX.js → fthry_index.CmEl9AjF.js} +1 -1
- package/dist/{fthry_index.CNFIYUXl.js → fthry_index.CxZihOJg.js} +2 -2
- package/dist/{fthry_index.CWe8WGnw.js → fthry_index.D0VQUqXz.js} +1 -1
- package/dist/{fthry_index.D1WDrqdZ.js → fthry_index.D2U9Y4Jc.js} +1 -1
- package/dist/fthry_index.D7coWJsd.js +4105 -0
- package/dist/{fthry_index.Dav1_JFe.js → fthry_index.DGl27K_w.js} +1 -1
- package/dist/{fthry_index.D7yot10w.js → fthry_index.DlEhwT48.js} +1 -1
- package/dist/{fthry_index.Bx652TAg.js → fthry_index.Dmsa_IWB.js} +1 -1
- package/dist/{fthry_index.C0iUe75-.js → fthry_index.Dvdg0UC6.js} +1 -1
- package/dist/{fthry_index.DIAR7NXW.js → fthry_index.DxoyRmcK.js} +2 -2
- package/dist/{fthry_index.BNN_GnRE.js → fthry_index.SqN7TeCH.js} +2 -2
- package/dist/{fthry_index.B8mrrhCT.js → fthry_index.Vno16k5B.js} +3 -3
- package/dist/{fthry_index.znErF4eB.js → fthry_index.ZMPDKzng.js} +2 -2
- package/dist/{fthry_index.CQOB3Ugj.js → fthry_index.cZ4fV2Jh.js} +3 -3
- package/dist/{fthry_index.Bq05T75f.js → fthry_index.eGwSNYvd.js} +1 -1
- package/dist/{fthry_index.DpXk-u8o.js → fthry_index.fOZIYWtf.js} +10 -10
- package/dist/{fthry_index.umd.C9mURNOx.js → fthry_index.umd.xldORs1x.js} +1 -1
- package/dist/{fthry_input.C-ByVjA4.js → fthry_input.6Rwsft76.js} +1 -1
- package/dist/fthry_logging.B1LWsZ3K.js +22 -0
- package/dist/fthry_logging.DWvo9mx5.js +27 -0
- package/dist/fthry_mermaid-O7DHMXV3.CpHtnz5w.js +8 -0
- package/dist/{fthry_script.DvAaqiBk.js → fthry_script.DNhdCztr.js} +1 -1
- package/dist/{fthry_styles.DwzdoBlX.js → fthry_styles.DPXDsQxq.js} +1 -1
- package/dist/{fthry_useElementSize.9DmbhgBu.js → fthry_useElementSize.orrnTjTM.js} +1 -1
- package/dist/{fthry_useSalesforceSync.qRdq0wu3.js → fthry_useSalesforceSync.C66IFKe6.js} +1 -1
- package/dist/{fthry_webfontloader.B5npG4_8.js → fthry_webfontloader.BZYYUrT8.js} +1 -1
- package/dist/index.js +2 -2
- package/dist/thumbnail-renderer.js +1 -1
- package/dist/utils/formHelperFunctions.d.ts +1 -0
- package/dist/utils/formHelperFunctions.d.ts.map +1 -1
- package/package.json +2 -1
- package/umd/129.ec2bd9be8700ef0450ee.js +1 -0
- package/umd/762.4a580055e4cb2c97c28f.js +2 -0
- package/umd/762.4a580055e4cb2c97c28f.js.LICENSE.txt +56 -0
- package/umd/968.2ad2025393b417351f94.js +1 -0
- package/umd/AssistantChat.f4f1a5ab9a911c339fd1.js +1 -0
- package/umd/index.js +1 -1
- package/dist/fthry_mermaid-O7DHMXV3.BLTan-1s.js +0 -8
- package/umd/AssistantChat.4c90e588cefb3c7dcc90.js +0 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var index$1 = require('./fthry_index.
|
|
3
|
+
var index$1 = require('./fthry_index.B4C3wGGx.js');
|
|
4
4
|
var React = require('react');
|
|
5
5
|
var clsx = require('./fthry_clsx.BtxeOLZW.js');
|
|
6
6
|
var ReactJSXRuntime = require('react/jsx-runtime');
|
|
7
7
|
var ReactDOM = require('react-dom');
|
|
8
|
-
var index$2 = require('./fthry_index.
|
|
8
|
+
var index$2 = require('./fthry_index.5xuF2U9h.js');
|
|
9
9
|
|
|
10
10
|
// src/errors/ai-sdk-error.ts
|
|
11
11
|
var marker = "vercel.ai.error";
|
|
@@ -9763,7 +9763,444 @@ var FullscreenIcon = function (props) { return (index$1.jsxs("svg", index$1.__as
|
|
|
9763
9763
|
var MinusIcon = function (props) { return (index$1.jsx("svg", index$1.__assign({ width: '16', height: '16', viewBox: '0 0 24 24', fill: 'none' }, props, { children: index$1.jsx("path", { d: 'M5 12h14', stroke: 'currentColor', strokeWidth: '2', strokeLinecap: 'round' }) }))); };
|
|
9764
9764
|
var ChevronsLeftIcon = function (props) { return (index$1.jsxs("svg", index$1.__assign({ width: '16', height: '16', viewBox: '0 0 24 24', fill: 'none' }, props, { children: [index$1.jsx("path", { d: 'm11 17-5-5 5-5', stroke: 'currentColor', strokeWidth: '2', strokeLinecap: 'round', strokeLinejoin: 'round' }), index$1.jsx("path", { d: 'm18 17-5-5 5-5', stroke: 'currentColor', strokeWidth: '2', strokeLinecap: 'round', strokeLinejoin: 'round' })] }))); };
|
|
9765
9765
|
var ChevronsRightIcon = function (props) { return (index$1.jsxs("svg", index$1.__assign({ width: '16', height: '16', viewBox: '0 0 24 24', fill: 'none' }, props, { children: [index$1.jsx("path", { d: 'm6 17 5-5-5-5', stroke: 'currentColor', strokeWidth: '2', strokeLinecap: 'round', strokeLinejoin: 'round' }), index$1.jsx("path", { d: 'm13 17 5-5-5-5', stroke: 'currentColor', strokeWidth: '2', strokeLinecap: 'round', strokeLinejoin: 'round' })] }))); };
|
|
9766
|
-
var LinkIcon = function (props) { return (index$1.jsxs("svg", index$1.__assign({ width: '12', height: '12', viewBox: '0 0 24 24', fill: 'none' }, props, { children: [index$1.jsx("path", { d: 'M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71', stroke: 'currentColor', strokeWidth: '2', strokeLinecap: 'round', strokeLinejoin: 'round' }), index$1.jsx("path", { d: 'M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71', stroke: 'currentColor', strokeWidth: '2', strokeLinecap: 'round', strokeLinejoin: 'round' })] }))); };
|
|
9766
|
+
var LinkIcon = function (props) { return (index$1.jsxs("svg", index$1.__assign({ width: '12', height: '12', viewBox: '0 0 24 24', fill: 'none' }, props, { children: [index$1.jsx("path", { d: 'M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71', stroke: 'currentColor', strokeWidth: '2', strokeLinecap: 'round', strokeLinejoin: 'round' }), index$1.jsx("path", { d: 'M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71', stroke: 'currentColor', strokeWidth: '2', strokeLinecap: 'round', strokeLinejoin: 'round' })] }))); };
|
|
9767
|
+
var MicIcon = function (props) { return (index$1.jsxs("svg", index$1.__assign({ width: '20', height: '20', viewBox: '0 0 24 24', fill: 'none' }, props, { children: [index$1.jsx("rect", { x: '9', y: '3', width: '6', height: '12', rx: '3', stroke: 'currentColor', strokeWidth: '2' }), index$1.jsx("path", { d: 'M5 11a7 7 0 0 0 14 0', stroke: 'currentColor', strokeWidth: '2', strokeLinecap: 'round' }), index$1.jsx("path", { d: 'M12 18v3', stroke: 'currentColor', strokeWidth: '2', strokeLinecap: 'round' })] }))); };
|
|
9768
|
+
var WaveformIcon = function (props) { return (index$1.jsxs("svg", index$1.__assign({ width: '18', height: '18', viewBox: '0 0 24 24', fill: 'none' }, props, { children: [index$1.jsx("path", { d: 'M4 12v0', stroke: 'currentColor', strokeWidth: '2', strokeLinecap: 'round' }), index$1.jsx("path", { d: 'M8 9v6', stroke: 'currentColor', strokeWidth: '2', strokeLinecap: 'round' }), index$1.jsx("path", { d: 'M12 5v14', stroke: 'currentColor', strokeWidth: '2', strokeLinecap: 'round' }), index$1.jsx("path", { d: 'M16 9v6', stroke: 'currentColor', strokeWidth: '2', strokeLinecap: 'round' }), index$1.jsx("path", { d: 'M20 11v2', stroke: 'currentColor', strokeWidth: '2', strokeLinecap: 'round' })] }))); };
|
|
9769
|
+
|
|
9770
|
+
function base64ToBytes(base64) {
|
|
9771
|
+
var binary = index$1.featheryWindow().atob(base64);
|
|
9772
|
+
var bytes = new Uint8Array(binary.length);
|
|
9773
|
+
for (var i = 0; i < binary.length; i++)
|
|
9774
|
+
bytes[i] = binary.charCodeAt(i);
|
|
9775
|
+
return bytes;
|
|
9776
|
+
}
|
|
9777
|
+
// Reveal text slightly ahead of the audio so it reads naturally rather than lagging
|
|
9778
|
+
var REVEAL_LEAD = 1.5;
|
|
9779
|
+
// Play the turn's audio clip by clip, reporting progress to drive the text reveal
|
|
9780
|
+
var AudioPlayer = /** @class */ (function () {
|
|
9781
|
+
function AudioPlayer(opts) {
|
|
9782
|
+
if (opts === void 0) { opts = {}; }
|
|
9783
|
+
this.building = [];
|
|
9784
|
+
this.queue = [];
|
|
9785
|
+
this.playIndex = 0;
|
|
9786
|
+
this.ended = false;
|
|
9787
|
+
this.playing = false;
|
|
9788
|
+
this.audio = null;
|
|
9789
|
+
this.objectUrl = null;
|
|
9790
|
+
this.rafId = null;
|
|
9791
|
+
this.opts = opts;
|
|
9792
|
+
}
|
|
9793
|
+
Object.defineProperty(AudioPlayer.prototype, "isPlaying", {
|
|
9794
|
+
get: function () {
|
|
9795
|
+
return this.playing;
|
|
9796
|
+
},
|
|
9797
|
+
enumerable: false,
|
|
9798
|
+
configurable: true
|
|
9799
|
+
});
|
|
9800
|
+
AudioPlayer.prototype.pushChunk = function (base64) {
|
|
9801
|
+
this.building.push(base64ToBytes(base64));
|
|
9802
|
+
};
|
|
9803
|
+
// The sentence's audio is fully sent, queue it (with its text) and keep playback moving
|
|
9804
|
+
AudioPlayer.prototype.pushSegment = function (text) {
|
|
9805
|
+
this.queue.push({ text: text, bytes: this.building });
|
|
9806
|
+
this.building = [];
|
|
9807
|
+
this.playing = true;
|
|
9808
|
+
this.playNext();
|
|
9809
|
+
};
|
|
9810
|
+
// No more clips coming
|
|
9811
|
+
AudioPlayer.prototype.end = function () {
|
|
9812
|
+
this.ended = true;
|
|
9813
|
+
this.playNext();
|
|
9814
|
+
};
|
|
9815
|
+
// Cut playback and drop anything queued
|
|
9816
|
+
AudioPlayer.prototype.skip = function () {
|
|
9817
|
+
this.teardown();
|
|
9818
|
+
};
|
|
9819
|
+
AudioPlayer.prototype.playNext = function () {
|
|
9820
|
+
var _this = this;
|
|
9821
|
+
var _a, _b, _c, _d;
|
|
9822
|
+
if (this.audio)
|
|
9823
|
+
return;
|
|
9824
|
+
var clip = this.queue[this.playIndex];
|
|
9825
|
+
if (!clip) {
|
|
9826
|
+
if (this.ended && this.playing) {
|
|
9827
|
+
this.playing = false;
|
|
9828
|
+
(_b = (_a = this.opts).onIdle) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
9829
|
+
}
|
|
9830
|
+
return;
|
|
9831
|
+
}
|
|
9832
|
+
if (clip.bytes.length === 0) {
|
|
9833
|
+
// TTS produced no audio for this sentence, credit its text to keep the reveal moving
|
|
9834
|
+
(_d = (_c = this.opts).onSegmentEnd) === null || _d === void 0 ? void 0 : _d.call(_c, clip.text);
|
|
9835
|
+
this.playIndex += 1;
|
|
9836
|
+
this.playNext();
|
|
9837
|
+
return;
|
|
9838
|
+
}
|
|
9839
|
+
var url = URL.createObjectURL(new Blob(clip.bytes, { type: 'audio/mpeg' }));
|
|
9840
|
+
var audio = new Audio(url);
|
|
9841
|
+
this.audio = audio;
|
|
9842
|
+
this.objectUrl = url;
|
|
9843
|
+
audio.onplaying = function () {
|
|
9844
|
+
var _a, _b;
|
|
9845
|
+
if (_this.audio !== audio)
|
|
9846
|
+
return;
|
|
9847
|
+
(_b = (_a = _this.opts).onSegmentStart) === null || _b === void 0 ? void 0 : _b.call(_a, clip.text);
|
|
9848
|
+
_this.startReveal(audio, clip.text);
|
|
9849
|
+
};
|
|
9850
|
+
audio.onended = function () { return _this.finishClip(audio, clip.text); };
|
|
9851
|
+
audio.onerror = function () { return _this.finishClip(audio, clip.text); };
|
|
9852
|
+
audio.play().catch(function () { return _this.finishClip(audio, clip.text); });
|
|
9853
|
+
};
|
|
9854
|
+
// Drive the text reveal from the clip's playback position
|
|
9855
|
+
AudioPlayer.prototype.startReveal = function (audio, text) {
|
|
9856
|
+
var _this = this;
|
|
9857
|
+
var win = index$1.featheryWindow();
|
|
9858
|
+
var tick = function () {
|
|
9859
|
+
var _a, _b;
|
|
9860
|
+
if (_this.audio !== audio) {
|
|
9861
|
+
_this.rafId = null;
|
|
9862
|
+
return;
|
|
9863
|
+
}
|
|
9864
|
+
var d = audio.duration;
|
|
9865
|
+
var fraction = d && isFinite(d) && d > 0
|
|
9866
|
+
? Math.min(1, (audio.currentTime / d) * REVEAL_LEAD)
|
|
9867
|
+
: 0;
|
|
9868
|
+
(_b = (_a = _this.opts).onSegmentProgress) === null || _b === void 0 ? void 0 : _b.call(_a, text, fraction);
|
|
9869
|
+
_this.rafId = win.requestAnimationFrame(tick);
|
|
9870
|
+
};
|
|
9871
|
+
this.rafId = win.requestAnimationFrame(tick);
|
|
9872
|
+
};
|
|
9873
|
+
AudioPlayer.prototype.stopReveal = function () {
|
|
9874
|
+
if (this.rafId !== null) {
|
|
9875
|
+
index$1.featheryWindow().cancelAnimationFrame(this.rafId);
|
|
9876
|
+
this.rafId = null;
|
|
9877
|
+
}
|
|
9878
|
+
};
|
|
9879
|
+
AudioPlayer.prototype.finishClip = function (audio, text) {
|
|
9880
|
+
var _a, _b;
|
|
9881
|
+
if (this.audio !== audio)
|
|
9882
|
+
return;
|
|
9883
|
+
this.stopReveal();
|
|
9884
|
+
(_b = (_a = this.opts).onSegmentEnd) === null || _b === void 0 ? void 0 : _b.call(_a, text);
|
|
9885
|
+
audio.pause();
|
|
9886
|
+
audio.src = '';
|
|
9887
|
+
this.audio = null;
|
|
9888
|
+
if (this.objectUrl) {
|
|
9889
|
+
URL.revokeObjectURL(this.objectUrl);
|
|
9890
|
+
this.objectUrl = null;
|
|
9891
|
+
}
|
|
9892
|
+
this.playIndex += 1;
|
|
9893
|
+
this.playNext();
|
|
9894
|
+
};
|
|
9895
|
+
AudioPlayer.prototype.teardown = function () {
|
|
9896
|
+
var _a, _b;
|
|
9897
|
+
this.stopReveal();
|
|
9898
|
+
if (this.audio) {
|
|
9899
|
+
this.audio.pause();
|
|
9900
|
+
this.audio.src = '';
|
|
9901
|
+
this.audio = null;
|
|
9902
|
+
}
|
|
9903
|
+
if (this.objectUrl) {
|
|
9904
|
+
URL.revokeObjectURL(this.objectUrl);
|
|
9905
|
+
this.objectUrl = null;
|
|
9906
|
+
}
|
|
9907
|
+
this.building = [];
|
|
9908
|
+
this.queue = [];
|
|
9909
|
+
this.playIndex = 0;
|
|
9910
|
+
this.ended = false;
|
|
9911
|
+
this.playing = false;
|
|
9912
|
+
(_b = (_a = this.opts).onIdle) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
9913
|
+
};
|
|
9914
|
+
return AudioPlayer;
|
|
9915
|
+
}());
|
|
9916
|
+
|
|
9917
|
+
// CDN-hosted so consumers don't have to serve the WASM/model assets
|
|
9918
|
+
var VAD_ASSET_BASE = 'https://cdn.jsdelivr.net/npm/@ricky0123/vad-web@0.0.30/dist/';
|
|
9919
|
+
var ORT_ASSET_BASE = 'https://cdn.jsdelivr.net/npm/onnxruntime-web@1.27.0/dist/';
|
|
9920
|
+
// Clips under ~0.4s are noise, STT hallucinates words on them
|
|
9921
|
+
var MIN_SAMPLES = 6400;
|
|
9922
|
+
var VoiceMic = /** @class */ (function () {
|
|
9923
|
+
function VoiceMic(opts) {
|
|
9924
|
+
this.vad = null;
|
|
9925
|
+
this.paused = false;
|
|
9926
|
+
this.opts = opts;
|
|
9927
|
+
}
|
|
9928
|
+
VoiceMic.prototype.start = function () {
|
|
9929
|
+
return index$1.__awaiter(this, void 0, void 0, function () {
|
|
9930
|
+
var _a, MicVAD_1, vadUtils_1, vadLog, _b;
|
|
9931
|
+
var _this = this;
|
|
9932
|
+
return index$1.__generator(this, function (_d) {
|
|
9933
|
+
switch (_d.label) {
|
|
9934
|
+
case 0:
|
|
9935
|
+
_d.trys.push([0, 4, , 5]);
|
|
9936
|
+
return [4 /*yield*/, Promise.resolve().then(function () { return require('./fthry_index.5X9_5jk4.js'); }).then(function (n) { return n.index; })];
|
|
9937
|
+
case 1:
|
|
9938
|
+
_a = _d.sent(), MicVAD_1 = _a.MicVAD, vadUtils_1 = _a.utils;
|
|
9939
|
+
return [4 /*yield*/, Promise.resolve().then(function () { return require('./fthry_logging.DwsvHsLI.js'); }).then(function (n) { return n.logging; })];
|
|
9940
|
+
case 2:
|
|
9941
|
+
vadLog = (_d.sent()).log;
|
|
9942
|
+
vadLog.debug = function () { return undefined; };
|
|
9943
|
+
_b = this;
|
|
9944
|
+
return [4 /*yield*/, MicVAD_1.new({
|
|
9945
|
+
baseAssetPath: VAD_ASSET_BASE,
|
|
9946
|
+
onnxWASMBasePath: ORT_ASSET_BASE,
|
|
9947
|
+
getStream: function () {
|
|
9948
|
+
return index$1.featheryWindow().navigator.mediaDevices.getUserMedia({
|
|
9949
|
+
audio: {
|
|
9950
|
+
echoCancellation: true,
|
|
9951
|
+
noiseSuppression: true,
|
|
9952
|
+
autoGainControl: true
|
|
9953
|
+
}
|
|
9954
|
+
});
|
|
9955
|
+
},
|
|
9956
|
+
onSpeechStart: function () {
|
|
9957
|
+
if (!_this.paused)
|
|
9958
|
+
_this.opts.onSpeechStart();
|
|
9959
|
+
},
|
|
9960
|
+
onSpeechEnd: function (audio) {
|
|
9961
|
+
if (_this.paused || audio.length < MIN_SAMPLES)
|
|
9962
|
+
return;
|
|
9963
|
+
var wav = new Blob([vadUtils_1.encodeWAV(audio)], {
|
|
9964
|
+
type: 'audio/wav'
|
|
9965
|
+
});
|
|
9966
|
+
_this.opts.onUtterance(wav);
|
|
9967
|
+
}
|
|
9968
|
+
})];
|
|
9969
|
+
case 3:
|
|
9970
|
+
_b.vad = _d.sent();
|
|
9971
|
+
this.vad.start();
|
|
9972
|
+
return [2 /*return*/, true];
|
|
9973
|
+
case 4:
|
|
9974
|
+
_d.sent();
|
|
9975
|
+
this.vad = null;
|
|
9976
|
+
return [2 /*return*/, false];
|
|
9977
|
+
case 5: return [2 /*return*/];
|
|
9978
|
+
}
|
|
9979
|
+
});
|
|
9980
|
+
});
|
|
9981
|
+
};
|
|
9982
|
+
// Hot only during the user's turn, off while the assistant thinks and speaks
|
|
9983
|
+
VoiceMic.prototype.pause = function () {
|
|
9984
|
+
var _a;
|
|
9985
|
+
this.paused = true;
|
|
9986
|
+
(_a = this.vad) === null || _a === void 0 ? void 0 : _a.pause();
|
|
9987
|
+
};
|
|
9988
|
+
VoiceMic.prototype.resume = function () {
|
|
9989
|
+
var _a;
|
|
9990
|
+
this.paused = false;
|
|
9991
|
+
(_a = this.vad) === null || _a === void 0 ? void 0 : _a.start();
|
|
9992
|
+
};
|
|
9993
|
+
VoiceMic.prototype.destroy = function () {
|
|
9994
|
+
var _a;
|
|
9995
|
+
(_a = this.vad) === null || _a === void 0 ? void 0 : _a.destroy();
|
|
9996
|
+
this.vad = null;
|
|
9997
|
+
};
|
|
9998
|
+
return VoiceMic;
|
|
9999
|
+
}());
|
|
10000
|
+
function probeMicAvailable() {
|
|
10001
|
+
var _a;
|
|
10002
|
+
try {
|
|
10003
|
+
var md = (_a = index$1.featheryWindow().navigator) === null || _a === void 0 ? void 0 : _a.mediaDevices;
|
|
10004
|
+
return !!md && typeof md.getUserMedia === 'function';
|
|
10005
|
+
}
|
|
10006
|
+
catch (_b) {
|
|
10007
|
+
return false;
|
|
10008
|
+
}
|
|
10009
|
+
}
|
|
10010
|
+
|
|
10011
|
+
var nonWhitespace = function (text) { return text.replace(/\s/g, '').length; };
|
|
10012
|
+
function useAssistantVoice(_a) {
|
|
10013
|
+
var _this = this;
|
|
10014
|
+
var status = _a.status, sendMessage = _a.sendMessage, setMessages = _a.setMessages, ensureThread = _a.ensureThread, voiceActiveRef = _a.voiceActiveRef, pendingAudioRef = _a.pendingAudioRef, voiceDataRef = _a.voiceDataRef;
|
|
10015
|
+
var _b = index$1.__read(React.useState('idle'), 2), voiceState = _b[0], setVoiceStateRaw = _b[1];
|
|
10016
|
+
var _c = index$1.__read(React.useState(probeMicAvailable), 1), micAvailable = _c[0];
|
|
10017
|
+
// Characters of the reply whose audio clip has begun playing, driving the in-order text reveal
|
|
10018
|
+
var _d = index$1.__read(React.useState(0), 2), spokenChars = _d[0], setSpokenChars = _d[1];
|
|
10019
|
+
// True while this turn's audio is queued or playing, keeping the reveal paced after the stream closes
|
|
10020
|
+
var _e = index$1.__read(React.useState(false), 2), audioDraining = _e[0], setAudioDraining = _e[1];
|
|
10021
|
+
var stateRef = React.useRef('idle');
|
|
10022
|
+
var statusRef = React.useRef(status);
|
|
10023
|
+
var micRef = React.useRef(null);
|
|
10024
|
+
var playerRef = React.useRef(null);
|
|
10025
|
+
// Non-whitespace chars of clips already finished, progress adds the in-flight clip on top
|
|
10026
|
+
var baseRef = React.useRef(0);
|
|
10027
|
+
// Set when the user taps skip, muting the rest of this turn's audio
|
|
10028
|
+
var skippedRef = React.useRef(false);
|
|
10029
|
+
var setVoiceState = React.useCallback(function (next) {
|
|
10030
|
+
stateRef.current = next;
|
|
10031
|
+
setVoiceStateRaw(next);
|
|
10032
|
+
}, []);
|
|
10033
|
+
// Return to listening once the turn ends (done or errored) and audio has drained
|
|
10034
|
+
var maybeFinishSpeaking = React.useCallback(function () {
|
|
10035
|
+
var _a, _b;
|
|
10036
|
+
if (!voiceActiveRef.current)
|
|
10037
|
+
return;
|
|
10038
|
+
if (statusRef.current !== 'ready' && statusRef.current !== 'error')
|
|
10039
|
+
return;
|
|
10040
|
+
if ((_a = playerRef.current) === null || _a === void 0 ? void 0 : _a.isPlaying)
|
|
10041
|
+
return;
|
|
10042
|
+
if (stateRef.current === 'transcribing' ||
|
|
10043
|
+
stateRef.current === 'thinking' ||
|
|
10044
|
+
stateRef.current === 'speaking') {
|
|
10045
|
+
(_b = micRef.current) === null || _b === void 0 ? void 0 : _b.resume();
|
|
10046
|
+
setVoiceState('listening');
|
|
10047
|
+
}
|
|
10048
|
+
}, [voiceActiveRef, setVoiceState]);
|
|
10049
|
+
var handleUtterance = React.useCallback(function (wav) {
|
|
10050
|
+
var _a, _b;
|
|
10051
|
+
if (stateRef.current !== 'recording' && stateRef.current !== 'listening')
|
|
10052
|
+
return;
|
|
10053
|
+
pendingAudioRef.current = wav;
|
|
10054
|
+
(_a = micRef.current) === null || _a === void 0 ? void 0 : _a.pause();
|
|
10055
|
+
(_b = playerRef.current) === null || _b === void 0 ? void 0 : _b.skip();
|
|
10056
|
+
baseRef.current = 0;
|
|
10057
|
+
skippedRef.current = false;
|
|
10058
|
+
setSpokenChars(0);
|
|
10059
|
+
setVoiceState('transcribing');
|
|
10060
|
+
ensureThread();
|
|
10061
|
+
// Send an empty user message so the turn anchors on it like a typed one
|
|
10062
|
+
sendMessage({ text: '' });
|
|
10063
|
+
}, [pendingAudioRef, ensureThread, sendMessage, setVoiceState]);
|
|
10064
|
+
// Mic is created once, route through a ref to reach the current handler
|
|
10065
|
+
var handleUtteranceRef = React.useRef(handleUtterance);
|
|
10066
|
+
handleUtteranceRef.current = handleUtterance;
|
|
10067
|
+
var startVoice = React.useCallback(function () { return index$1.__awaiter(_this, void 0, void 0, function () {
|
|
10068
|
+
var player, mic, ok;
|
|
10069
|
+
return index$1.__generator(this, function (_a) {
|
|
10070
|
+
switch (_a.label) {
|
|
10071
|
+
case 0:
|
|
10072
|
+
if (stateRef.current !== 'idle' && stateRef.current !== 'error')
|
|
10073
|
+
return [2 /*return*/];
|
|
10074
|
+
player = new AudioPlayer({
|
|
10075
|
+
onSegmentStart: function () {
|
|
10076
|
+
if (voiceActiveRef.current)
|
|
10077
|
+
setVoiceState('speaking');
|
|
10078
|
+
},
|
|
10079
|
+
onSegmentProgress: function (text, fraction) {
|
|
10080
|
+
return setSpokenChars(baseRef.current + Math.floor(nonWhitespace(text) * fraction));
|
|
10081
|
+
},
|
|
10082
|
+
onSegmentEnd: function (text) {
|
|
10083
|
+
baseRef.current += nonWhitespace(text);
|
|
10084
|
+
setSpokenChars(baseRef.current);
|
|
10085
|
+
},
|
|
10086
|
+
onIdle: function () {
|
|
10087
|
+
setAudioDraining(false);
|
|
10088
|
+
maybeFinishSpeaking();
|
|
10089
|
+
}
|
|
10090
|
+
});
|
|
10091
|
+
mic = new VoiceMic({
|
|
10092
|
+
onSpeechStart: function () {
|
|
10093
|
+
if (stateRef.current === 'listening')
|
|
10094
|
+
setVoiceState('recording');
|
|
10095
|
+
},
|
|
10096
|
+
onUtterance: function (wav) { return handleUtteranceRef.current(wav); }
|
|
10097
|
+
});
|
|
10098
|
+
playerRef.current = player;
|
|
10099
|
+
micRef.current = mic;
|
|
10100
|
+
voiceActiveRef.current = true;
|
|
10101
|
+
// Stays 'loading' until the VAD assets finish downloading, only then is the mic live
|
|
10102
|
+
setVoiceState('loading');
|
|
10103
|
+
return [4 /*yield*/, mic.start()];
|
|
10104
|
+
case 1:
|
|
10105
|
+
ok = _a.sent();
|
|
10106
|
+
if (!ok) {
|
|
10107
|
+
voiceActiveRef.current = false;
|
|
10108
|
+
setVoiceState('error');
|
|
10109
|
+
}
|
|
10110
|
+
else {
|
|
10111
|
+
setVoiceState('listening');
|
|
10112
|
+
}
|
|
10113
|
+
return [2 /*return*/];
|
|
10114
|
+
}
|
|
10115
|
+
});
|
|
10116
|
+
}); }, [voiceActiveRef, maybeFinishSpeaking, setVoiceState]);
|
|
10117
|
+
var stopVoice = React.useCallback(function () {
|
|
10118
|
+
var _a, _b;
|
|
10119
|
+
(_a = micRef.current) === null || _a === void 0 ? void 0 : _a.destroy();
|
|
10120
|
+
micRef.current = null;
|
|
10121
|
+
(_b = playerRef.current) === null || _b === void 0 ? void 0 : _b.skip();
|
|
10122
|
+
playerRef.current = null;
|
|
10123
|
+
pendingAudioRef.current = null;
|
|
10124
|
+
voiceActiveRef.current = false;
|
|
10125
|
+
setVoiceState('idle');
|
|
10126
|
+
}, [voiceActiveRef, pendingAudioRef, setVoiceState]);
|
|
10127
|
+
var skipSpeaking = React.useCallback(function () {
|
|
10128
|
+
var _a;
|
|
10129
|
+
if (stateRef.current !== 'speaking')
|
|
10130
|
+
return;
|
|
10131
|
+
skippedRef.current = true;
|
|
10132
|
+
(_a = playerRef.current) === null || _a === void 0 ? void 0 : _a.skip();
|
|
10133
|
+
// Audio is muted, so reveal the rest of the reply text immediately
|
|
10134
|
+
setSpokenChars(Number.MAX_SAFE_INTEGER);
|
|
10135
|
+
}, []);
|
|
10136
|
+
// Route the transient transcript + audio parts coming off the chat stream
|
|
10137
|
+
React.useEffect(function () {
|
|
10138
|
+
voiceDataRef.current = function (part) {
|
|
10139
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
10140
|
+
if (!voiceActiveRef.current)
|
|
10141
|
+
return;
|
|
10142
|
+
if (part.type === 'data-audio') {
|
|
10143
|
+
if ((_a = part.data) === null || _a === void 0 ? void 0 : _a.done)
|
|
10144
|
+
(_b = playerRef.current) === null || _b === void 0 ? void 0 : _b.end();
|
|
10145
|
+
else if (((_c = part.data) === null || _c === void 0 ? void 0 : _c.chunk) && !skippedRef.current)
|
|
10146
|
+
(_d = playerRef.current) === null || _d === void 0 ? void 0 : _d.pushChunk(part.data.chunk);
|
|
10147
|
+
}
|
|
10148
|
+
else if (part.type === 'data-segment' && ((_e = part.data) === null || _e === void 0 ? void 0 : _e.text)) {
|
|
10149
|
+
if (skippedRef.current)
|
|
10150
|
+
return;
|
|
10151
|
+
setAudioDraining(true);
|
|
10152
|
+
(_f = playerRef.current) === null || _f === void 0 ? void 0 : _f.pushSegment(part.data.text);
|
|
10153
|
+
}
|
|
10154
|
+
else if (part.type === 'data-transcript' && ((_g = part.data) === null || _g === void 0 ? void 0 : _g.text)) {
|
|
10155
|
+
var text_1 = part.data.text;
|
|
10156
|
+
// Transcript is in, the agent is now working on the reply
|
|
10157
|
+
if (stateRef.current === 'transcribing')
|
|
10158
|
+
setVoiceState('thinking');
|
|
10159
|
+
// Fill the empty user message this turn was sent with
|
|
10160
|
+
setMessages(function (prev) {
|
|
10161
|
+
for (var i = prev.length - 1; i >= 0; i--) {
|
|
10162
|
+
if (prev[i].role === 'user') {
|
|
10163
|
+
var next = index$1.__spreadArray([], index$1.__read(prev), false);
|
|
10164
|
+
next[i] = index$1.__assign(index$1.__assign({}, prev[i]), { parts: [{ type: 'text', text: text_1 }] });
|
|
10165
|
+
return next;
|
|
10166
|
+
}
|
|
10167
|
+
}
|
|
10168
|
+
return index$1.__spreadArray(index$1.__spreadArray([], index$1.__read(prev), false), [
|
|
10169
|
+
{ id: index$1.v4(), role: 'user', parts: [{ type: 'text', text: text_1 }] }
|
|
10170
|
+
], false);
|
|
10171
|
+
});
|
|
10172
|
+
}
|
|
10173
|
+
};
|
|
10174
|
+
return function () {
|
|
10175
|
+
voiceDataRef.current = null;
|
|
10176
|
+
};
|
|
10177
|
+
}, [voiceDataRef, voiceActiveRef, setMessages, setVoiceState]);
|
|
10178
|
+
React.useEffect(function () {
|
|
10179
|
+
statusRef.current = status;
|
|
10180
|
+
// A turn that ends with the user message still empty had no usable transcript, drop it
|
|
10181
|
+
if ((status === 'ready' || status === 'error') && voiceActiveRef.current) {
|
|
10182
|
+
setMessages(function (prev) {
|
|
10183
|
+
var _a;
|
|
10184
|
+
var last = prev[prev.length - 1];
|
|
10185
|
+
var emptyUser = (last === null || last === void 0 ? void 0 : last.role) === 'user' &&
|
|
10186
|
+
!((_a = last.parts) !== null && _a !== void 0 ? _a : []).some(function (p) { var _a; return p.type === 'text' && ((_a = p.text) !== null && _a !== void 0 ? _a : '').trim(); });
|
|
10187
|
+
return emptyUser ? prev.slice(0, -1) : prev;
|
|
10188
|
+
});
|
|
10189
|
+
}
|
|
10190
|
+
maybeFinishSpeaking();
|
|
10191
|
+
}, [status, maybeFinishSpeaking, voiceActiveRef, setMessages]);
|
|
10192
|
+
React.useEffect(function () { return function () { return stopVoice(); }; }, [stopVoice]);
|
|
10193
|
+
return {
|
|
10194
|
+
voiceState: voiceState,
|
|
10195
|
+
voiceActive: voiceState !== 'idle' && voiceState !== 'error',
|
|
10196
|
+
micAvailable: micAvailable,
|
|
10197
|
+
spokenChars: spokenChars,
|
|
10198
|
+
audioDraining: audioDraining,
|
|
10199
|
+
startVoice: startVoice,
|
|
10200
|
+
stopVoice: stopVoice,
|
|
10201
|
+
skipSpeaking: skipSpeaking
|
|
10202
|
+
};
|
|
10203
|
+
}
|
|
9767
10204
|
|
|
9768
10205
|
var DEFAULT_CHAT_COLOR = '#6b7280';
|
|
9769
10206
|
var GRAY_50 = '#f9fafb';
|
|
@@ -9840,10 +10277,6 @@ var TOOL_LABELS = {
|
|
|
9840
10277
|
running: 'Reading the form...',
|
|
9841
10278
|
done: 'Reviewed the form'
|
|
9842
10279
|
},
|
|
9843
|
-
getFuserSnapshot: {
|
|
9844
|
-
running: 'Looking up your submission...',
|
|
9845
|
-
done: 'Reviewed the submission'
|
|
9846
|
-
},
|
|
9847
10280
|
getExtractionSnapshot: {
|
|
9848
10281
|
running: 'Reading extraction setup...',
|
|
9849
10282
|
done: 'Reviewed the extraction setup'
|
|
@@ -9871,6 +10304,10 @@ var TOOL_LABELS = {
|
|
|
9871
10304
|
queryHub: {
|
|
9872
10305
|
running: 'Searching records on file...',
|
|
9873
10306
|
done: 'Searched the records on file'
|
|
10307
|
+
},
|
|
10308
|
+
querySubmissions: {
|
|
10309
|
+
running: 'Searching submissions...',
|
|
10310
|
+
done: 'Searched submissions'
|
|
9874
10311
|
}
|
|
9875
10312
|
};
|
|
9876
10313
|
function readPartType(part) {
|
|
@@ -10003,12 +10440,13 @@ var shimmerCss = {
|
|
|
10003
10440
|
}
|
|
10004
10441
|
};
|
|
10005
10442
|
var ToolChunk = function (_a) {
|
|
10006
|
-
var rows = _a.rows, followedByText = _a.followedByText, turnFinished = _a.turnFinished, _b = _a.
|
|
10443
|
+
var rows = _a.rows, followedByText = _a.followedByText, turnFinished = _a.turnFinished, _b = _a.audioPending, audioPending = _b === void 0 ? false : _b, _c = _a.linkColor, linkColor = _c === void 0 ? DEFAULT_CHAT_COLOR : _c, _d = _a.isFirstChunk, isFirstChunk = _d === void 0 ? false : _d;
|
|
10007
10444
|
var isRunning = rows.some(function (r) { return isRunningState(r.state); });
|
|
10008
|
-
|
|
10009
|
-
var
|
|
10445
|
+
// Voice: keep showing "Working on it" until the following reply's audio arrives
|
|
10446
|
+
var chunkDone = !isRunning && !audioPending && (followedByText || turnFinished);
|
|
10447
|
+
var shouldCollapse = !isRunning && !audioPending && followedByText;
|
|
10010
10448
|
var defaultExpanded = !shouldCollapse;
|
|
10011
|
-
var
|
|
10449
|
+
var _e = index$1.__read(React.useState(null), 2), override = _e[0], setOverride = _e[1];
|
|
10012
10450
|
var expanded = override !== null && override !== void 0 ? override : defaultExpanded;
|
|
10013
10451
|
var toggle = function () { return setOverride(!expanded); };
|
|
10014
10452
|
// Match the message bubble's horizontal padding
|
|
@@ -51306,14 +51744,14 @@ ${e}</tr>
|
|
|
51306
51744
|
Please report this to https://github.com/markedjs/marked.`,e){let r="<p>An error occurred:</p><pre>"+T(n.message+"",true)+"</pre>";return t?Promise.resolve(r):r}if(t)return Promise.reject(n);throw n}}};var L$1=new D;function g(u,e){return L$1.parse(u,e)}g.options=g.setOptions=function(u){return L$1.setOptions(u),g.defaults=L$1.defaults,G(g.defaults),g};g.getDefaults=M;g.defaults=O;g.use=function(...u){return L$1.use(...u),g.defaults=L$1.defaults,G(g.defaults),g};g.walkTokens=function(u,e){return L$1.walkTokens(u,e)};g.parseInline=L$1.parseInline;g.Parser=b;g.parser=b.parse;g.Renderer=y$1;g.TextRenderer=$;g.Lexer=x;g.lexer=x.lex;g.Tokenizer=w;g.Hooks=P;g.parse=g;g.options;g.setOptions;g.use;g.walkTokens;g.parseInline;b.parse;x.lex;
|
|
51307
51745
|
|
|
51308
51746
|
var En=300,Hn="300px",Dn=500;function Lt(e={}){let{immediate:t=false,debounceDelay:o=En,rootMargin:n=Hn,idleTimeout:r=Dn}=e,[s,a]=React.useState(false),l=React.useRef(null),i=React.useRef(null),c=React.useRef(null),d=React.useMemo(()=>p=>{let g=Date.now();return window.setTimeout(()=>{p({didTimeout:false,timeRemaining:()=>Math.max(0,50-(Date.now()-g))});},1)},[]),u=React.useMemo(()=>typeof window!="undefined"&&window.requestIdleCallback?(p,g)=>window.requestIdleCallback(p,g):d,[d]),m=React.useMemo(()=>typeof window!="undefined"&&window.cancelIdleCallback?p=>window.cancelIdleCallback(p):p=>{clearTimeout(p);},[]);return React.useEffect(()=>{if(t){a(true);return}let p=l.current;if(!p)return;i.current&&(clearTimeout(i.current),i.current=null),c.current&&(m(c.current),c.current=null);let g=()=>{i.current&&(clearTimeout(i.current),i.current=null),c.current&&(m(c.current),c.current=null);},h=x=>{c.current=u(w=>{w.timeRemaining()>0||w.didTimeout?(a(true),x.disconnect()):c.current=u(()=>{a(true),x.disconnect();},{timeout:r/2});},{timeout:r});},b=x=>{g(),i.current=window.setTimeout(()=>{var I,H;let w=x.takeRecords();(w.length===0||(H=(I=w.at(-1))==null?void 0:I.isIntersecting)!=null&&H)&&h(x);},o);},f=(x,w)=>{x.isIntersecting?b(w):g();},T=new IntersectionObserver(x=>{for(let w of x)f(w,T);},{rootMargin:n,threshold:0});return T.observe(p),()=>{i.current&&clearTimeout(i.current),c.current&&m(c.current),T.disconnect();}},[t,o,n,r,m,u]),{shouldRender:s,containerRef:l}}var Rt=/\s/,On=/^\s+$/,Vn=new Set(["code","pre","svg","math","annotation"]),jn=e=>typeof e=="object"&&e!==null&&"type"in e&&e.type==="element",Fn=e=>e.some(t=>jn(t)&&Vn.has(t.tagName)),zn=e=>{let t=[],o="",n=false;for(let r of e){let s=Rt.test(r);s!==n&&o&&(t.push(o),o=""),o+=r,n=s;}return o&&t.push(o),t},_n=e=>{let t=[],o="";for(let n of e)Rt.test(n)?o+=n:(o&&(t.push(o),o=""),t.push(n));return o&&t.push(o),t},qn=(e,t,o,n,r)=>({type:"element",tagName:"span",properties:{"data-sd-animate":true,style:r?`--sd-animation:sd-${t};--sd-duration:0ms;--sd-easing:${n}`:`--sd-animation:sd-${t};--sd-duration:${o}ms;--sd-easing:${n}`},children:[{type:"text",value:e}]}),$n=(e,t,o,n,r)=>{let s=t.at(-1);if(!(s&&"children"in s))return;if(Fn(t))return SKIP;let a=s,l=a.children.indexOf(e);if(l===-1)return;let i=e.value;if(!i.trim()){r.count+=i.length;return}let c=o.sep==="char"?_n(i):zn(i),d=n.prevContentLength,u=c.map(m=>{let p=r.count;if(r.count+=m.length,On.test(m))return {type:"text",value:m};let g=d>0&&p<d;return qn(m,o.animation,o.duration,o.easing,g)});return a.children.splice(l,1,...u),l+u.length},Wn=0;function be(e){var s,a,l,i;let t={animation:(s=e==null?void 0:e.animation)!=null?s:"fadeIn",duration:(a=e==null?void 0:e.duration)!=null?a:150,easing:(l=e==null?void 0:e.easing)!=null?l:"ease",sep:(i=e==null?void 0:e.sep)!=null?i:"word"},o={prevContentLength:0,lastRenderCharCount:0},n=Wn++,r=()=>c=>{let d={count:0};visitParents(c,"text",(u,m)=>$n(u,m,t,o,d)),o.lastRenderCharCount=d.count,o.prevContentLength=0;};return Object.defineProperty(r,"name",{value:`rehypeAnimate$${n}`}),{name:"animate",type:"animate",rehypePlugin:r,setPrevContentLength(c){o.prevContentLength=c;},getLastRenderCharCount(){let c=o.lastRenderCharCount;return o.lastRenderCharCount=0,c}}}be();var Qe=React.createContext(false),et=()=>React.useContext(Qe);var he=(...e)=>twMerge(clsx.clsx(e)),Jn=(e,t)=>{if(!e||!t)return t;let o=`${e}:`;return t.split(/\s+/).filter(Boolean).map(n=>n.startsWith(o)?n:`${e}:${n}`).join(" ")},Ht=e=>e?(...t)=>Jn(e,twMerge(clsx.clsx(t))):he,J=(e,t,o)=>{let n=typeof t=="string"?new Blob([t],{type:o}):t,r=URL.createObjectURL(n),s=document.createElement("a");s.href=r,s.download=e,document.body.appendChild(s),s.click(),document.body.removeChild(s),URL.revokeObjectURL(r);};var Se=React.createContext(he),y=()=>React.useContext(Se);var Yn=he("block","before:content-[counter(line)]","before:inline-block","before:[counter-increment:line]","before:w-6","before:mr-4","before:text-[13px]","before:text-right","before:text-muted-foreground/50","before:font-mono","before:select-none"),Qn=e=>{let t={};for(let o of e.split(";")){let n=o.indexOf(":");if(n>0){let r=o.slice(0,n).trim(),s=o.slice(n+1).trim();r&&s&&(t[r]=s);}}return t},Bt=React.memo(({children:e,result:t,language:o,className:n,startLine:r,...s})=>{let a=y(),l=React.useMemo(()=>a(Yn),[a]),i=React.useMemo(()=>{let c={};return t.bg&&(c["--sdm-bg"]=t.bg),t.fg&&(c["--sdm-fg"]=t.fg),t.rootStyle&&Object.assign(c,Qn(t.rootStyle)),c},[t.bg,t.fg,t.rootStyle]);return ReactJSXRuntime.jsx("div",{className:a(n,"overflow-hidden rounded-md border border-border bg-background p-4 text-sm"),"data-language":o,"data-streamdown":"code-block-body",...s,children:ReactJSXRuntime.jsx("pre",{className:a(n,"bg-[var(--sdm-bg,inherit]","dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit)]"),style:i,children:ReactJSXRuntime.jsx("code",{className:a("[counter-increment:line_0] [counter-reset:line]"),style:r&&r>1?{counterReset:`line ${r-1}`}:void 0,children:t.tokens.map((c,d)=>ReactJSXRuntime.jsx("span",{className:l,children:c.length===0||c.length===1&&c[0].content===""?`
|
|
51309
|
-
`:c.map((u,m)=>{let p={},g=!!u.bgColor;if(u.color&&(p["--sdm-c"]=u.color),u.bgColor&&(p["--sdm-tbg"]=u.bgColor),u.htmlStyle)for(let[h,b]of Object.entries(u.htmlStyle))h==="color"?p["--sdm-c"]=b:h==="background-color"?(p["--sdm-tbg"]=b,g=true):p[h]=b;return ReactJSXRuntime.jsx("span",{className:a("text-[var(--sdm-c,inherit)]","dark:text-[var(--shiki-dark,var(--sdm-c,inherit))]",g&&"bg-[var(--sdm-tbg)]",g&&"dark:bg-[var(--shiki-dark-bg,var(--sdm-tbg))]"),style:p,...u.htmlAttrs,children:u.content},m)})},d))})})})},(e,t)=>e.result===t.result&&e.language===t.language&&e.className===t.className&&e.startLine===t.startLine);var tt=({className:e,language:t,style:o,isIncomplete:n,...r})=>{let s=y();return ReactJSXRuntime.jsx("div",{className:s("my-4 flex w-full flex-col gap-2 rounded-xl border border-border bg-sidebar p-2",e),"data-incomplete":n||void 0,"data-language":t,"data-streamdown":"code-block",style:{contentVisibility:"auto",containIntrinsicSize:"auto 200px",...o},...r})};var ot=React.createContext({code:""}),Ee=()=>React.useContext(ot);var nt=({language:e})=>{let t=y();return ReactJSXRuntime.jsx("div",{className:t("flex h-8 items-center text-muted-foreground text-xs"),"data-language":e,"data-streamdown":"code-block-header",children:ReactJSXRuntime.jsx("span",{className:t("ml-1 font-mono lowercase"),children:e})})};var sr=/\n+$/,ar=React.lazy(()=>Promise.resolve().then(function () { return require('./fthry_highlighted-body-TPN3WLV5.
|
|
51747
|
+
`:c.map((u,m)=>{let p={},g=!!u.bgColor;if(u.color&&(p["--sdm-c"]=u.color),u.bgColor&&(p["--sdm-tbg"]=u.bgColor),u.htmlStyle)for(let[h,b]of Object.entries(u.htmlStyle))h==="color"?p["--sdm-c"]=b:h==="background-color"?(p["--sdm-tbg"]=b,g=true):p[h]=b;return ReactJSXRuntime.jsx("span",{className:a("text-[var(--sdm-c,inherit)]","dark:text-[var(--shiki-dark,var(--sdm-c,inherit))]",g&&"bg-[var(--sdm-tbg)]",g&&"dark:bg-[var(--shiki-dark-bg,var(--sdm-tbg))]"),style:p,...u.htmlAttrs,children:u.content},m)})},d))})})})},(e,t)=>e.result===t.result&&e.language===t.language&&e.className===t.className&&e.startLine===t.startLine);var tt=({className:e,language:t,style:o,isIncomplete:n,...r})=>{let s=y();return ReactJSXRuntime.jsx("div",{className:s("my-4 flex w-full flex-col gap-2 rounded-xl border border-border bg-sidebar p-2",e),"data-incomplete":n||void 0,"data-language":t,"data-streamdown":"code-block",style:{contentVisibility:"auto",containIntrinsicSize:"auto 200px",...o},...r})};var ot=React.createContext({code:""}),Ee=()=>React.useContext(ot);var nt=({language:e})=>{let t=y();return ReactJSXRuntime.jsx("div",{className:t("flex h-8 items-center text-muted-foreground text-xs"),"data-language":e,"data-streamdown":"code-block-header",children:ReactJSXRuntime.jsx("span",{className:t("ml-1 font-mono lowercase"),children:e})})};var sr=/\n+$/,ar=React.lazy(()=>Promise.resolve().then(function () { return require('./fthry_highlighted-body-TPN3WLV5.DVEo7HUb.js'); }).then(e=>({default:e.HighlightedCodeBlockBody}))),rt=({code:e,language:t,className:o,children:n,isIncomplete:r=false,startLine:s,...a})=>{let l=y(),i=React.useMemo(()=>e.replace(sr,""),[e]),c=React.useMemo(()=>({bg:"transparent",fg:"inherit",tokens:i.split(`
|
|
51310
51748
|
`).map(d=>[{content:d,color:"inherit",bgColor:"transparent",htmlStyle:{},offset:0}])}),[i]);return ReactJSXRuntime.jsx(ot.Provider,{value:{code:e},children:ReactJSXRuntime.jsxs(tt,{isIncomplete:r,language:t,children:[ReactJSXRuntime.jsx(nt,{language:t}),n?ReactJSXRuntime.jsx("div",{className:l("pointer-events-none sticky top-2 z-10 -mt-10 flex h-8 items-center justify-end"),children:ReactJSXRuntime.jsx("div",{className:l("pointer-events-auto flex shrink-0 items-center gap-2 rounded-md border border-sidebar bg-sidebar/80 px-1.5 py-1 supports-[backdrop-filter]:bg-sidebar/70 supports-[backdrop-filter]:backdrop-blur"),"data-streamdown":"code-block-actions",children:n})}):null,ReactJSXRuntime.jsx(React.Suspense,{fallback:ReactJSXRuntime.jsx(Bt,{className:o,language:t,result:c,startLine:s,...a}),children:ReactJSXRuntime.jsx(ar,{className:o,code:i,language:t,raw:c,startLine:s,...a})})]})})};var Vt=e=>ReactJSXRuntime.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:ReactJSXRuntime.jsx("path",{clipRule:"evenodd",d:"M15.5607 3.99999L15.0303 4.53032L6.23744 13.3232C5.55403 14.0066 4.44599 14.0066 3.76257 13.3232L4.2929 12.7929L3.76257 13.3232L0.969676 10.5303L0.439346 9.99999L1.50001 8.93933L2.03034 9.46966L4.82323 12.2626C4.92086 12.3602 5.07915 12.3602 5.17678 12.2626L13.9697 3.46966L14.5 2.93933L15.5607 3.99999Z",fill:"currentColor",fillRule:"evenodd"})}),jt=e=>ReactJSXRuntime.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:ReactJSXRuntime.jsx("path",{clipRule:"evenodd",d:"M2.75 0.5C1.7835 0.5 1 1.2835 1 2.25V9.75C1 10.7165 1.7835 11.5 2.75 11.5H3.75H4.5V10H3.75H2.75C2.61193 10 2.5 9.88807 2.5 9.75V2.25C2.5 2.11193 2.61193 2 2.75 2H8.25C8.38807 2 8.5 2.11193 8.5 2.25V3H10V2.25C10 1.2835 9.2165 0.5 8.25 0.5H2.75ZM7.75 4.5C6.7835 4.5 6 5.2835 6 6.25V13.75C6 14.7165 6.7835 15.5 7.75 15.5H13.25C14.2165 15.5 15 14.7165 15 13.75V6.25C15 5.2835 14.2165 4.5 13.25 4.5H7.75ZM7.5 6.25C7.5 6.11193 7.61193 6 7.75 6H13.25C13.3881 6 13.5 6.11193 13.5 6.25V13.75C13.5 13.8881 13.3881 14 13.25 14H7.75C7.61193 14 7.5 13.8881 7.5 13.75V6.25Z",fill:"currentColor",fillRule:"evenodd"})}),Ft=e=>ReactJSXRuntime.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:ReactJSXRuntime.jsx("path",{clipRule:"evenodd",d:"M8.75 1V1.75V8.68934L10.7197 6.71967L11.25 6.18934L12.3107 7.25L11.7803 7.78033L8.70711 10.8536C8.31658 11.2441 7.68342 11.2441 7.29289 10.8536L4.21967 7.78033L3.68934 7.25L4.75 6.18934L5.28033 6.71967L7.25 8.68934V1.75V1H8.75ZM13.5 9.25V13.5H2.5V9.25V8.5H1V9.25V14C1 14.5523 1.44771 15 2 15H14C14.5523 15 15 14.5523 15 14V9.25V8.5H13.5V9.25Z",fill:"currentColor",fillRule:"evenodd"})}),zt=e=>ReactJSXRuntime.jsxs("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:[ReactJSXRuntime.jsx("path",{d:"M8 0V4",stroke:"currentColor",strokeWidth:"1.5"}),ReactJSXRuntime.jsx("path",{d:"M8 16V12",opacity:"0.5",stroke:"currentColor",strokeWidth:"1.5"}),ReactJSXRuntime.jsx("path",{d:"M3.29773 1.52783L5.64887 4.7639",opacity:"0.9",stroke:"currentColor",strokeWidth:"1.5"}),ReactJSXRuntime.jsx("path",{d:"M12.7023 1.52783L10.3511 4.7639",opacity:"0.1",stroke:"currentColor",strokeWidth:"1.5"}),ReactJSXRuntime.jsx("path",{d:"M12.7023 14.472L10.3511 11.236",opacity:"0.4",stroke:"currentColor",strokeWidth:"1.5"}),ReactJSXRuntime.jsx("path",{d:"M3.29773 14.472L5.64887 11.236",opacity:"0.6",stroke:"currentColor",strokeWidth:"1.5"}),ReactJSXRuntime.jsx("path",{d:"M15.6085 5.52783L11.8043 6.7639",opacity:"0.2",stroke:"currentColor",strokeWidth:"1.5"}),ReactJSXRuntime.jsx("path",{d:"M0.391602 10.472L4.19583 9.23598",opacity:"0.7",stroke:"currentColor",strokeWidth:"1.5"}),ReactJSXRuntime.jsx("path",{d:"M15.6085 10.4722L11.8043 9.2361",opacity:"0.3",stroke:"currentColor",strokeWidth:"1.5"}),ReactJSXRuntime.jsx("path",{d:"M0.391602 5.52783L4.19583 6.7639",opacity:"0.8",stroke:"currentColor",strokeWidth:"1.5"})]}),_t=e=>ReactJSXRuntime.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:ReactJSXRuntime.jsx("path",{clipRule:"evenodd",d:"M1 5.25V6H2.5V5.25V2.5H5.25H6V1H5.25H2C1.44772 1 1 1.44772 1 2V5.25ZM5.25 14.9994H6V13.4994H5.25H2.5V10.7494V9.99939H1V10.7494V13.9994C1 14.5517 1.44772 14.9994 2 14.9994H5.25ZM15 10V10.75V14C15 14.5523 14.5523 15 14 15H10.75H10V13.5H10.75H13.5V10.75V10H15ZM10.75 1H10V2.5H10.75H13.5V5.25V6H15V5.25V2C15 1.44772 14.5523 1 14 1H10.75Z",fill:"currentColor",fillRule:"evenodd"})}),qt=e=>ReactJSXRuntime.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:ReactJSXRuntime.jsx("path",{clipRule:"evenodd",d:"M13.5 8C13.5 4.96643 11.0257 2.5 7.96452 2.5C5.42843 2.5 3.29365 4.19393 2.63724 6.5H5.25H6V8H5.25H0.75C0.335787 8 0 7.66421 0 7.25V2.75V2H1.5V2.75V5.23347C2.57851 2.74164 5.06835 1 7.96452 1C11.8461 1 15 4.13001 15 8C15 11.87 11.8461 15 7.96452 15C5.62368 15 3.54872 13.8617 2.27046 12.1122L1.828 11.5066L3.03915 10.6217L3.48161 11.2273C4.48831 12.6051 6.12055 13.5 7.96452 13.5C11.0257 13.5 13.5 11.0336 13.5 8Z",fill:"currentColor",fillRule:"evenodd"})}),$t=e=>ReactJSXRuntime.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:ReactJSXRuntime.jsx("path",{clipRule:"evenodd",d:"M12.4697 13.5303L13 14.0607L14.0607 13L13.5303 12.4697L9.06065 7.99999L13.5303 3.53032L14.0607 2.99999L13 1.93933L12.4697 2.46966L7.99999 6.93933L3.53032 2.46966L2.99999 1.93933L1.93933 2.99999L2.46966 3.53032L6.93933 7.99999L2.46966 12.4697L1.93933 13L2.99999 14.0607L3.53032 13.5303L7.99999 9.06065L12.4697 13.5303Z",fill:"currentColor",fillRule:"evenodd"})}),Wt=e=>ReactJSXRuntime.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:ReactJSXRuntime.jsx("path",{clipRule:"evenodd",d:"M13.5 10.25V13.25C13.5 13.3881 13.3881 13.5 13.25 13.5H2.75C2.61193 13.5 2.5 13.3881 2.5 13.25L2.5 2.75C2.5 2.61193 2.61193 2.5 2.75 2.5H5.75H6.5V1H5.75H2.75C1.7835 1 1 1.7835 1 2.75V13.25C1 14.2165 1.7835 15 2.75 15H13.25C14.2165 15 15 14.2165 15 13.25V10.25V9.5H13.5V10.25ZM9 1H9.75H14.2495C14.6637 1 14.9995 1.33579 14.9995 1.75V6.25V7H13.4995V6.25V3.56066L8.53033 8.52978L8 9.06011L6.93934 7.99945L7.46967 7.46912L12.4388 2.5H9.75H9V1Z",fill:"currentColor",fillRule:"evenodd"})}),Zt=e=>ReactJSXRuntime.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:ReactJSXRuntime.jsx("path",{clipRule:"evenodd",d:"M1.5 6.5C1.5 3.73858 3.73858 1.5 6.5 1.5C9.26142 1.5 11.5 3.73858 11.5 6.5C11.5 9.26142 9.26142 11.5 6.5 11.5C3.73858 11.5 1.5 9.26142 1.5 6.5ZM6.5 0C2.91015 0 0 2.91015 0 6.5C0 10.0899 2.91015 13 6.5 13C8.02469 13 9.42677 12.475 10.5353 11.596L13.9697 15.0303L14.5 15.5607L15.5607 14.5L15.0303 13.9697L11.596 10.5353C12.475 9.42677 13 8.02469 13 6.5C13 2.91015 10.0899 0 6.5 0ZM4.125 5.875H4.75H5.875V4.75V4.125H7.125V4.75V5.875H8.25H8.875V7.125H8.25H7.125V8.25V8.875H5.875V8.25V7.125H4.75H4.125V5.875Z",fill:"currentColor",fillRule:"evenodd"})}),Xt=e=>ReactJSXRuntime.jsx("svg",{color:"currentColor",height:16,strokeLinejoin:"round",viewBox:"0 0 16 16",width:16,...e,children:ReactJSXRuntime.jsx("path",{clipRule:"evenodd",d:"M1.5 6.5C1.5 3.73858 3.73858 1.5 6.5 1.5C9.26142 1.5 11.5 3.73858 11.5 6.5C11.5 9.26142 9.26142 11.5 6.5 11.5C3.73858 11.5 1.5 9.26142 1.5 6.5ZM6.5 0C2.91015 0 0 2.91015 0 6.5C0 10.0899 2.91015 13 6.5 13C8.02469 13 9.42677 12.475 10.5353 11.596L13.9697 15.0303L14.5 15.5607L15.5607 14.5L15.0303 13.9697L11.596 10.5353C12.475 9.42677 13 8.02469 13 6.5C13 2.91015 10.0899 0 6.5 0ZM4.125 5.875H4.75H8.25H8.875V7.125H8.25H4.75H4.125V5.875Z",fill:"currentColor",fillRule:"evenodd"})});var we={CheckIcon:Vt,CopyIcon:jt,DownloadIcon:Ft,ExternalLinkIcon:Wt,Loader2Icon:zt,Maximize2Icon:_t,RotateCcwIcon:qt,XIcon:$t,ZoomInIcon:Zt,ZoomOutIcon:Xt},Kt=React.createContext(we),mr=(e,t)=>{if(e===t)return true;if(!(e&&t))return e===t;let o=Object.keys(e),n=Object.keys(t);return o.length!==n.length?false:o.every(r=>e[r]===t[r])},st=({icons:e,children:t})=>{let o=React.useRef(e),n=React.useRef(e?{...we,...e}:we);mr(o.current,e)||(o.current=e,n.current=e?{...we,...e}:we);let r=n.current;return ReactJSXRuntime.jsx(Kt.Provider,{value:r,children:t})},L=()=>React.useContext(Kt);var He={copyCode:"Copy Code",downloadFile:"Download file",downloadDiagram:"Download diagram",downloadDiagramAsSvg:"Download diagram as SVG",downloadDiagramAsPng:"Download diagram as PNG",downloadDiagramAsMmd:"Download diagram as MMD",viewFullscreen:"View fullscreen",exitFullscreen:"Exit fullscreen",mermaidFormatSvg:"SVG",mermaidFormatPng:"PNG",mermaidFormatMmd:"MMD",copyTable:"Copy table",copyTableAsMarkdown:"Copy table as Markdown",copyTableAsCsv:"Copy table as CSV",copyTableAsTsv:"Copy table as TSV",downloadTable:"Download table",downloadTableAsCsv:"Download table as CSV",downloadTableAsMarkdown:"Download table as Markdown",tableFormatMarkdown:"Markdown",tableFormatCsv:"CSV",tableFormatTsv:"TSV",imageNotAvailable:"Image not available",downloadImage:"Download image",openExternalLink:"Open external link?",externalLinkWarning:"You're about to visit an external website.",close:"Close",copyLink:"Copy link",copied:"Copied",openLink:"Open link"},De=React.createContext(He),B=()=>React.useContext(De);var Be=({onCopy:e,onError:t,timeout:o=2e3,children:n,className:r,code:s,...a})=>{let l=y(),[i,c]=React.useState(false),d=React.useRef(0),{code:u}=Ee(),{isAnimating:m}=React.useContext(R),p=B(),g=s!=null?s:u,h=async()=>{var T;if(typeof window=="undefined"||!((T=navigator==null?void 0:navigator.clipboard)!=null&&T.writeText)){t==null||t(new Error("Clipboard API not available"));return}try{i||(await navigator.clipboard.writeText(g),c(!0),e==null||e(),d.current=window.setTimeout(()=>c(!1),o));}catch(x){t==null||t(x);}};React.useEffect(()=>()=>{window.clearTimeout(d.current);},[]);let b=L(),f=i?b.CheckIcon:b.CopyIcon;return ReactJSXRuntime.jsx("button",{className:l("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",r),"data-streamdown":"code-block-copy-button",disabled:m,onClick:h,title:p.copyCode,type:"button",...a,children:n!=null?n:ReactJSXRuntime.jsx(f,{size:14})})};var Gt={"1c":"1c","1c-query":"1cq",abap:"abap","actionscript-3":"as",ada:"ada",adoc:"adoc","angular-html":"html","angular-ts":"ts",apache:"conf",apex:"cls",apl:"apl",applescript:"applescript",ara:"ara",asciidoc:"adoc",asm:"asm",astro:"astro",awk:"awk",ballerina:"bal",bash:"sh",bat:"bat",batch:"bat",be:"be",beancount:"beancount",berry:"berry",bibtex:"bib",bicep:"bicep",blade:"blade.php",bsl:"bsl",c:"c","c#":"cs","c++":"cpp",cadence:"cdc",cairo:"cairo",cdc:"cdc",clarity:"clar",clj:"clj",clojure:"clj","closure-templates":"soy",cmake:"cmake",cmd:"cmd",cobol:"cob",codeowners:"CODEOWNERS",codeql:"ql",coffee:"coffee",coffeescript:"coffee","common-lisp":"lisp",console:"sh",coq:"v",cpp:"cpp",cql:"cql",crystal:"cr",cs:"cs",csharp:"cs",css:"css",csv:"csv",cue:"cue",cypher:"cql",d:"d",dart:"dart",dax:"dax",desktop:"desktop",diff:"diff",docker:"dockerfile",dockerfile:"dockerfile",dotenv:"env","dream-maker":"dm",edge:"edge",elisp:"el",elixir:"ex",elm:"elm","emacs-lisp":"el",erb:"erb",erl:"erl",erlang:"erl",f:"f","f#":"fs",f03:"f03",f08:"f08",f18:"f18",f77:"f77",f90:"f90",f95:"f95",fennel:"fnl",fish:"fish",fluent:"ftl",for:"for","fortran-fixed-form":"f","fortran-free-form":"f90",fs:"fs",fsharp:"fs",fsl:"fsl",ftl:"ftl",gdresource:"tres",gdscript:"gd",gdshader:"gdshader",genie:"gs",gherkin:"feature","git-commit":"gitcommit","git-rebase":"gitrebase",gjs:"js",gleam:"gleam","glimmer-js":"js","glimmer-ts":"ts",glsl:"glsl",gnuplot:"plt",go:"go",gql:"gql",graphql:"graphql",groovy:"groovy",gts:"gts",hack:"hack",haml:"haml",handlebars:"hbs",haskell:"hs",haxe:"hx",hbs:"hbs",hcl:"hcl",hjson:"hjson",hlsl:"hlsl",hs:"hs",html:"html","html-derivative":"html",http:"http",hxml:"hxml",hy:"hy",imba:"imba",ini:"ini",jade:"jade",java:"java",javascript:"js",jinja:"jinja",jison:"jison",jl:"jl",js:"js",json:"json",json5:"json5",jsonc:"jsonc",jsonl:"jsonl",jsonnet:"jsonnet",jssm:"jssm",jsx:"jsx",julia:"jl",kotlin:"kt",kql:"kql",kt:"kt",kts:"kts",kusto:"kql",latex:"tex",lean:"lean",lean4:"lean",less:"less",liquid:"liquid",lisp:"lisp",lit:"lit",llvm:"ll",log:"log",logo:"logo",lua:"lua",luau:"luau",make:"mak",makefile:"mak",markdown:"md",marko:"marko",matlab:"m",md:"md",mdc:"mdc",mdx:"mdx",mediawiki:"wiki",mermaid:"mmd",mips:"s",mipsasm:"s",mmd:"mmd",mojo:"mojo",move:"move",nar:"nar",narrat:"narrat",nextflow:"nf",nf:"nf",nginx:"conf",nim:"nim",nix:"nix",nu:"nu",nushell:"nu",objc:"m","objective-c":"m","objective-cpp":"mm",ocaml:"ml",pascal:"pas",perl:"pl",perl6:"p6",php:"php",plsql:"pls",po:"po",polar:"polar",postcss:"pcss",pot:"pot",potx:"potx",powerquery:"pq",powershell:"ps1",prisma:"prisma",prolog:"pl",properties:"properties",proto:"proto",protobuf:"proto",ps:"ps",ps1:"ps1",pug:"pug",puppet:"pp",purescript:"purs",py:"py",python:"py",ql:"ql",qml:"qml",qmldir:"qmldir",qss:"qss",r:"r",racket:"rkt",raku:"raku",razor:"cshtml",rb:"rb",reg:"reg",regex:"regex",regexp:"regexp",rel:"rel",riscv:"s",rs:"rs",rst:"rst",ruby:"rb",rust:"rs",sas:"sas",sass:"sass",scala:"scala",scheme:"scm",scss:"scss",sdbl:"sdbl",sh:"sh",shader:"shader",shaderlab:"shader",shell:"sh",shellscript:"sh",shellsession:"sh",smalltalk:"st",solidity:"sol",soy:"soy",sparql:"rq",spl:"spl",splunk:"spl",sql:"sql","ssh-config":"config",stata:"do",styl:"styl",stylus:"styl",svelte:"svelte",swift:"swift","system-verilog":"sv",systemd:"service",talon:"talon",talonscript:"talon",tasl:"tasl",tcl:"tcl",templ:"templ",terraform:"tf",tex:"tex",tf:"tf",tfvars:"tfvars",toml:"toml",ts:"ts","ts-tags":"ts",tsp:"tsp",tsv:"tsv",tsx:"tsx",turtle:"ttl",twig:"twig",typ:"typ",typescript:"ts",typespec:"tsp",typst:"typ",v:"v",vala:"vala",vb:"vb",verilog:"v",vhdl:"vhdl",vim:"vim",viml:"vim",vimscript:"vim",vue:"vue","vue-html":"html","vue-vine":"vine",vy:"vy",vyper:"vy",wasm:"wasm",wenyan:"wy",wgsl:"wgsl",wiki:"wiki",wikitext:"wiki",wit:"wit",wl:"wl",wolfram:"wl",xml:"xml",xsl:"xsl",yaml:"yaml",yml:"yml",zenscript:"zs",zig:"zig",zsh:"zsh",\u6587\u8A00:"wy"},at=({onDownload:e,onError:t,language:o,children:n,className:r,code:s,...a})=>{let l=y(),{code:i}=Ee(),{isAnimating:c}=React.useContext(R),d=B(),u=L(),m=s!=null?s:i,g=`file.${o&&o in Gt?Gt[o]:"txt"}`,h="text/plain",b=()=>{try{J(g,m,h),e==null||e();}catch(f){t==null||t(f);}};return ReactJSXRuntime.jsx("button",{className:l("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",r),"data-streamdown":"code-block-download-button",disabled:c,onClick:b,title:d.downloadFile,type:"button",...a,children:n!=null?n:ReactJSXRuntime.jsx(u.DownloadIcon,{size:14})})};var Ae=()=>{let{Loader2Icon:e}=L(),t=y();return ReactJSXRuntime.jsxs("div",{className:t("w-full divide-y divide-border overflow-hidden rounded-xl border border-border"),children:[ReactJSXRuntime.jsx("div",{className:t("h-[46px] w-full bg-muted/80")}),ReactJSXRuntime.jsx("div",{className:t("flex w-full items-center justify-center p-4"),children:ReactJSXRuntime.jsx(e,{className:t("size-4 animate-spin")})})]})};var xr=/\.[^/.]+$/,to=({node:e,className:t,src:o,alt:n,onLoad:r,onError:s,...a})=>{let{DownloadIcon:l}=L(),i=y(),c=React.useRef(null),[d,u]=React.useState(false),[m,p]=React.useState(false),g=B(),h=a.width!=null||a.height!=null,b=(d||h)&&!m,f=m&&!h;React.useEffect(()=>{let k=c.current;if(k!=null&&k.complete){let I=k.naturalWidth>0;u(I),p(!I);}},[]);let T=React.useCallback(k=>{u(true),p(false),r==null||r(k);},[r]),x=React.useCallback(k=>{u(false),p(true),s==null||s(k);},[s]),w=async()=>{if(o)try{let I=await(await fetch(o)).blob(),S=new URL(o,window.location.origin).pathname.split("/").pop()||"",F=S.split(".").pop(),z=S.includes(".")&&F!==void 0&&F.length<=4,q="";if(z)q=S;else {let A=I.type,K="png";A.includes("jpeg")||A.includes("jpg")?K="jpg":A.includes("png")?K="png":A.includes("svg")?K="svg":A.includes("gif")?K="gif":A.includes("webp")&&(K="webp"),q=`${(n||S||"image").replace(xr,"")}.${K}`;}J(q,I,I.type);}catch(k){window.open(o,"_blank");}};return o?ReactJSXRuntime.jsxs("div",{className:i("group relative my-4 inline-block"),"data-streamdown":"image-wrapper",children:[ReactJSXRuntime.jsx("img",{alt:n,className:i("max-w-full rounded-lg",f&&"hidden",t),"data-streamdown":"image",onError:x,onLoad:T,ref:c,src:o,...a}),f&&ReactJSXRuntime.jsx("span",{className:i("text-muted-foreground text-xs italic"),"data-streamdown":"image-fallback",children:g.imageNotAvailable}),ReactJSXRuntime.jsx("div",{className:i("pointer-events-none absolute inset-0 hidden rounded-lg bg-black/10 group-hover:block")}),b&&ReactJSXRuntime.jsx("button",{className:i("absolute right-2 bottom-2 flex h-8 w-8 cursor-pointer items-center justify-center rounded-md border border-border bg-background/90 shadow-sm backdrop-blur-sm transition-all duration-200 hover:bg-background","opacity-0 group-hover:opacity-100"),onClick:w,title:g.downloadImage,type:"button",children:ReactJSXRuntime.jsx(l,{size:14})})]}):null};var ke=0,le=()=>{ke+=1,ke===1&&(document.body.style.overflow="hidden");},ce=()=>{ke=Math.max(0,ke-1),ke===0&&(document.body.style.overflow="");};var ro=({url:e,isOpen:t,onClose:o,onConfirm:n})=>{let{CheckIcon:r,CopyIcon:s,ExternalLinkIcon:a,XIcon:l}=L(),i=y(),[c,d]=React.useState(false),u=B(),m=React.useCallback(async()=>{try{await navigator.clipboard.writeText(e),d(!0),setTimeout(()=>d(!1),2e3);}catch(g){}},[e]),p=React.useCallback(()=>{n(),o();},[n,o]);return React.useEffect(()=>{if(t){le();let g=h=>{h.key==="Escape"&&o();};return document.addEventListener("keydown",g),()=>{document.removeEventListener("keydown",g),ce();}}},[t,o]),t?ReactJSXRuntime.jsx("div",{className:i("fixed inset-0 z-50 flex items-center justify-center bg-background/50 backdrop-blur-sm"),"data-streamdown":"link-safety-modal",onClick:o,onKeyDown:g=>{g.key==="Escape"&&o();},role:"button",tabIndex:0,children:ReactJSXRuntime.jsxs("div",{className:i("relative mx-4 flex w-full max-w-md flex-col gap-4 rounded-xl border bg-background p-6 shadow-lg"),onClick:g=>g.stopPropagation(),onKeyDown:g=>g.stopPropagation(),role:"presentation",children:[ReactJSXRuntime.jsx("button",{className:i("absolute top-4 right-4 rounded-md p-1 text-muted-foreground transition-all hover:bg-muted hover:text-foreground"),onClick:o,title:u.close,type:"button",children:ReactJSXRuntime.jsx(l,{size:16})}),ReactJSXRuntime.jsxs("div",{className:i("flex flex-col gap-2"),children:[ReactJSXRuntime.jsxs("div",{className:i("flex items-center gap-2 font-semibold text-lg"),children:[ReactJSXRuntime.jsx(a,{size:20}),ReactJSXRuntime.jsx("span",{children:u.openExternalLink})]}),ReactJSXRuntime.jsx("p",{className:i("text-muted-foreground text-sm"),children:u.externalLinkWarning})]}),ReactJSXRuntime.jsx("div",{className:i("break-all rounded-md bg-muted p-3 font-mono text-sm",e.length>100&&"max-h-32 overflow-y-auto"),children:e}),ReactJSXRuntime.jsxs("div",{className:i("flex gap-2"),children:[ReactJSXRuntime.jsx("button",{className:i("flex flex-1 items-center justify-center gap-2 rounded-md border bg-background px-4 py-2 font-medium text-sm transition-all hover:bg-muted"),onClick:m,type:"button",children:c?ReactJSXRuntime.jsxs(ReactJSXRuntime.Fragment,{children:[ReactJSXRuntime.jsx(r,{size:14}),ReactJSXRuntime.jsx("span",{children:u.copied})]}):ReactJSXRuntime.jsxs(ReactJSXRuntime.Fragment,{children:[ReactJSXRuntime.jsx(s,{size:14}),ReactJSXRuntime.jsx("span",{children:u.copyLink})]})}),ReactJSXRuntime.jsxs("button",{className:i("flex flex-1 items-center justify-center gap-2 rounded-md bg-primary px-4 py-2 font-medium text-primary-foreground text-sm transition-all hover:bg-primary/90"),onClick:p,type:"button",children:[ReactJSXRuntime.jsx(a,{size:14}),ReactJSXRuntime.jsx("span",{children:u.openLink})]})]})]})}):null};var Oe=React.createContext(null),lt=()=>React.useContext(Oe),Mi=()=>{var t;let e=lt();return (t=e==null?void 0:e.code)!=null?t:null},de=()=>{var t;let e=lt();return (t=e==null?void 0:e.mermaid)!=null?t:null};var so=e=>{var o;let t=lt();return t!=null&&t.renderers&&e&&(o=t.renderers.find(n=>Array.isArray(n.language)?n.language.includes(e):n.language===e))!=null?o:null};var ao=(e,t)=>{var n;let o=(n=void 0)!=null?n:5;return new Promise((r,s)=>{let a="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(e))),l=new Image;l.crossOrigin="anonymous",l.onload=()=>{let i=document.createElement("canvas"),c=l.width*o,d=l.height*o;i.width=c,i.height=d;let u=i.getContext("2d");if(!u){s(new Error("Failed to create 2D canvas context for PNG export"));return}u.drawImage(l,0,0,c,d),i.toBlob(m=>{if(!m){s(new Error("Failed to create PNG blob"));return}r(m);},"image/png");},l.onerror=()=>s(new Error("Failed to load SVG image")),l.src=a;})};var lo=({chart:e,children:t,className:o,onDownload:n,config:r,onError:s})=>{let a=y(),[l,i]=React.useState(false),c=React.useRef(null),{isAnimating:d}=React.useContext(R),u=L(),m=de(),p=B(),g=async h=>{try{if(h==="mmd"){J("diagram.mmd",e,"text/plain"),i(!1),n==null||n(h);return}if(!m){s==null||s(new Error("Mermaid plugin not available"));return}let b=m.getMermaid(r),f=e.split("").reduce((w,k)=>(w<<5)-w+k.charCodeAt(0)|0,0),T=`mermaid-${Math.abs(f)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:x}=await b.render(T,e);if(!x){s==null||s(new Error("SVG not found. Please wait for the diagram to render."));return}if(h==="svg"){J("diagram.svg",x,"image/svg+xml"),i(!1),n==null||n(h);return}if(h==="png"){let w=await ao(x);J("diagram.png",w,"image/png"),n==null||n(h),i(!1);return}}catch(b){s==null||s(b);}};return React.useEffect(()=>{let h=b=>{let f=b.composedPath();c.current&&!f.includes(c.current)&&i(false);};return document.addEventListener("mousedown",h),()=>{document.removeEventListener("mousedown",h);}},[]),ReactJSXRuntime.jsxs("div",{className:a("relative"),ref:c,children:[ReactJSXRuntime.jsx("button",{className:a("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",o),disabled:d,onClick:()=>i(!l),title:p.downloadDiagram,type:"button",children:t!=null?t:ReactJSXRuntime.jsx(u.DownloadIcon,{size:14})}),l?ReactJSXRuntime.jsxs("div",{className:a("absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg"),children:[ReactJSXRuntime.jsx("button",{className:a("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>g("svg"),title:p.downloadDiagramAsSvg,type:"button",children:p.mermaidFormatSvg}),ReactJSXRuntime.jsx("button",{className:a("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>g("png"),title:p.downloadDiagramAsPng,type:"button",children:p.mermaidFormatPng}),ReactJSXRuntime.jsx("button",{className:a("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>g("mmd"),title:p.downloadDiagramAsMmd,type:"button",children:p.mermaidFormatMmd})]}):null]})};var po=({chart:e,config:t,onFullscreen:o,onExit:n,className:r,...s})=>{let{Maximize2Icon:a,XIcon:l}=L(),i=y(),[c,d]=React.useState(false),{isAnimating:u,controls:m}=React.useContext(R),p=B(),g=(()=>{if(typeof m=="boolean")return m;let b=m.mermaid;return b===false?false:b===true||b===void 0?true:b.panZoom!==false})(),h=()=>{d(!c);};return React.useEffect(()=>{if(c){le();let b=f=>{f.key==="Escape"&&d(false);};return document.addEventListener("keydown",b),()=>{document.removeEventListener("keydown",b),ce();}}},[c]),React.useEffect(()=>{c?o==null||o():n&&n();},[c,o,n]),ReactJSXRuntime.jsxs(ReactJSXRuntime.Fragment,{children:[ReactJSXRuntime.jsx("button",{className:i("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",r),disabled:u,onClick:h,title:p.viewFullscreen,type:"button",...s,children:ReactJSXRuntime.jsx(a,{size:14})}),c?ReactDOM.createPortal(ReactJSXRuntime.jsxs("div",{className:i("fixed inset-0 z-50 flex items-center justify-center bg-background/95 backdrop-blur-sm"),onClick:h,onKeyDown:b=>{b.key==="Escape"&&h();},role:"button",tabIndex:0,children:[ReactJSXRuntime.jsx("button",{className:i("absolute top-4 right-4 z-10 rounded-md p-2 text-muted-foreground transition-all hover:bg-muted hover:text-foreground"),onClick:h,title:p.exitFullscreen,type:"button",children:ReactJSXRuntime.jsx(l,{size:20})}),ReactJSXRuntime.jsx("div",{className:i("flex size-full items-center justify-center p-4"),onClick:b=>b.stopPropagation(),onKeyDown:b=>b.stopPropagation(),role:"presentation",children:ReactJSXRuntime.jsx(uo,{chart:e,className:i("size-full [&_svg]:h-auto [&_svg]:w-auto"),config:t,fullscreen:true,showControls:g})})]}),document.body):null]})};var ue=e=>{var s,a;let t=[],o=[],n=e.querySelectorAll("thead th");for(let l of n)t.push(((s=l.textContent)==null?void 0:s.trim())||"");let r=e.querySelectorAll("tbody tr");for(let l of r){let i=[],c=l.querySelectorAll("td");for(let d of c)i.push(((a=d.textContent)==null?void 0:a.trim())||"");o.push(i);}return {headers:t,rows:o}},oe=e=>{let{headers:t,rows:o}=e,n=l=>{let i=false,c=false;for(let d of l){if(d==='"'){i=true,c=true;break}(d===","||d===`
|
|
51311
51749
|
`)&&(i=true);}return i?c?`"${l.replace(/"/g,'""')}"`:`"${l}"`:l},r=t.length>0?o.length+1:o.length,s=new Array(r),a=0;t.length>0&&(s[a]=t.map(n).join(","),a+=1);for(let l of o)s[a]=l.map(n).join(","),a+=1;return s.join(`
|
|
51312
51750
|
`)},ct=e=>{let{headers:t,rows:o}=e,n=l=>{let i=false;for(let d of l)if(d===" "||d===`
|
|
51313
51751
|
`||d==="\r"){i=true;break}if(!i)return l;let c=[];for(let d of l)d===" "?c.push("\\t"):d===`
|
|
51314
51752
|
`?c.push("\\n"):d==="\r"?c.push("\\r"):c.push(d);return c.join("")},r=t.length>0?o.length+1:o.length,s=new Array(r),a=0;t.length>0&&(s[a]=t.map(n).join(" "),a+=1);for(let l of o)s[a]=l.map(n).join(" "),a+=1;return s.join(`
|
|
51315
51753
|
`)},Ve=e=>{let t=false;for(let n of e)if(n==="\\"||n==="|"){t=true;break}if(!t)return e;let o=[];for(let n of e)n==="\\"?o.push("\\\\"):n==="|"?o.push("\\|"):o.push(n);return o.join("")},ne=e=>{let{headers:t,rows:o}=e;if(t.length===0)return "";let n=new Array(o.length+2),r=0,s=t.map(l=>Ve(l));n[r]=`| ${s.join(" | ")} |`,r+=1;let a=new Array(t.length);for(let l=0;l<t.length;l+=1)a[l]="---";n[r]=`| ${a.join(" | ")} |`,r+=1;for(let l of o)if(l.length<t.length){let i=new Array(t.length);for(let c=0;c<t.length;c+=1)i[c]=c<l.length?Ve(l[c]):"";n[r]=`| ${i.join(" | ")} |`,r+=1;}else {let i=l.map(c=>Ve(c));n[r]=`| ${i.join(" | ")} |`,r+=1;}return n.join(`
|
|
51316
|
-
`)};var Te=({children:e,className:t,onCopy:o,onError:n,timeout:r=2e3})=>{let s=y(),[a,l]=React.useState(false),[i,c]=React.useState(false),d=React.useRef(null),u=React.useRef(0),{isAnimating:m}=React.useContext(R),p=B(),g=async f=>{var T,x;if(typeof window=="undefined"||!((T=navigator==null?void 0:navigator.clipboard)!=null&&T.write)){n==null||n(new Error("Clipboard API not available"));return}try{let w=(x=d.current)==null?void 0:x.closest('[data-streamdown="table-wrapper"]'),k=w==null?void 0:w.querySelector("table");if(!k){n==null||n(new Error("Table not found"));return}let I=ue(k),F=({csv:oe,tsv:ct,md:ne}[f]||ne)(I),z=new ClipboardItem({"text/plain":new Blob([F],{type:"text/plain"}),"text/html":new Blob([k.outerHTML],{type:"text/html"})});await navigator.clipboard.write([z]),c(!0),l(!1),o==null||o(f),u.current=window.setTimeout(()=>c(!1),r);}catch(w){n==null||n(w);}};React.useEffect(()=>{let f=T=>{let x=T.composedPath();d.current&&!x.includes(d.current)&&l(false);};return document.addEventListener("mousedown",f),()=>{document.removeEventListener("mousedown",f),window.clearTimeout(u.current);}},[]);let h=L(),b=i?h.CheckIcon:h.CopyIcon;return ReactJSXRuntime.jsxs("div",{className:s("relative"),ref:d,children:[ReactJSXRuntime.jsx("button",{className:s("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:m,onClick:()=>l(!a),title:p.copyTable,type:"button",children:e!=null?e:ReactJSXRuntime.jsx(b,{height:14,width:14})}),a?ReactJSXRuntime.jsxs("div",{className:s("absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg"),children:[ReactJSXRuntime.jsx("button",{className:s("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>g("md"),title:p.copyTableAsMarkdown,type:"button",children:p.tableFormatMarkdown}),ReactJSXRuntime.jsx("button",{className:s("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>g("csv"),title:p.copyTableAsCsv,type:"button",children:p.tableFormatCsv}),ReactJSXRuntime.jsx("button",{className:s("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>g("tsv"),title:p.copyTableAsTsv,type:"button",children:p.tableFormatTsv})]}):null]})};var Pe=({children:e,className:t,onDownload:o,onError:n})=>{let r=y(),[s,a]=React.useState(false),l=React.useRef(null),{isAnimating:i}=React.useContext(R),c=B(),d=L(),u=m=>{var p;try{let g=(p=l.current)==null?void 0:p.closest('[data-streamdown="table-wrapper"]'),h=g==null?void 0:g.querySelector("table");if(!h){n==null||n(new Error("Table not found"));return}let b=ue(h),f=m==="csv"?oe(b):ne(b);J(`table.${m==="csv"?"csv":"md"}`,f,m==="csv"?"text/csv":"text/markdown"),a(!1),o==null||o(m);}catch(g){n==null||n(g);}};return React.useEffect(()=>{let m=p=>{let g=p.composedPath();l.current&&!g.includes(l.current)&&a(false);};return document.addEventListener("mousedown",m),()=>{document.removeEventListener("mousedown",m);}},[]),ReactJSXRuntime.jsxs("div",{className:r("relative"),ref:l,children:[ReactJSXRuntime.jsx("button",{className:r("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:i,onClick:()=>a(!s),title:c.downloadTable,type:"button",children:e!=null?e:ReactJSXRuntime.jsx(d.DownloadIcon,{size:14})}),s?ReactJSXRuntime.jsxs("div",{className:r("absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg"),children:[ReactJSXRuntime.jsx("button",{className:r("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>u("csv"),title:c.downloadTableAsCsv,type:"button",children:c.tableFormatCsv}),ReactJSXRuntime.jsx("button",{className:r("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>u("markdown"),title:c.downloadTableAsMarkdown,type:"button",children:c.tableFormatMarkdown})]}):null]})};var wo=({children:e,className:t,showCopy:o=true,showDownload:n=true})=>{let{Maximize2Icon:r,XIcon:s}=L(),a=y(),[l,i]=React.useState(false),{isAnimating:c}=React.useContext(R),d=B(),u=()=>{i(true);},m=()=>{i(false);};return React.useEffect(()=>{if(l){le();let p=g=>{g.key==="Escape"&&i(false);};return document.addEventListener("keydown",p),()=>{document.removeEventListener("keydown",p),ce();}}},[l]),ReactJSXRuntime.jsxs(ReactJSXRuntime.Fragment,{children:[ReactJSXRuntime.jsx("button",{className:a("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:c,onClick:u,title:d.viewFullscreen,type:"button",children:ReactJSXRuntime.jsx(r,{size:14})}),l?ReactDOM.createPortal(ReactJSXRuntime.jsx("div",{"aria-label":d.viewFullscreen,"aria-modal":"true",className:a("fixed inset-0 z-50 flex flex-col bg-background"),"data-streamdown":"table-fullscreen",onClick:m,onKeyDown:p=>{p.key==="Escape"&&m();},role:"dialog",children:ReactJSXRuntime.jsxs("div",{className:a("flex h-full flex-col"),onClick:p=>p.stopPropagation(),onKeyDown:p=>p.stopPropagation(),role:"presentation",children:[ReactJSXRuntime.jsxs("div",{className:a("flex items-center justify-end gap-1 p-4"),children:[o?ReactJSXRuntime.jsx(Te,{}):null,n?ReactJSXRuntime.jsx(Pe,{}):null,ReactJSXRuntime.jsx("button",{className:a("rounded-md p-1 text-muted-foreground transition-all hover:bg-muted hover:text-foreground"),onClick:m,title:d.exitFullscreen,type:"button",children:ReactJSXRuntime.jsx(s,{size:20})})]}),ReactJSXRuntime.jsx("div",{className:a("flex-1 overflow-auto p-4 pt-0 [&_thead]:sticky [&_thead]:top-0 [&_thead]:z-10"),children:ReactJSXRuntime.jsx("table",{className:a("w-full border-collapse border border-border"),"data-streamdown":"table",children:e})})]})}),document.body):null]})};var ko=({children:e,className:t,showControls:o,showCopy:n=true,showDownload:r=true,showFullscreen:s=true,...a})=>{let l=y(),i=o&&n,c=o&&r,d=o&&s,u=i||c||d;return ReactJSXRuntime.jsxs("div",{className:l("my-4 flex flex-col gap-2 rounded-lg border border-border bg-sidebar p-2"),"data-streamdown":"table-wrapper",children:[u?ReactJSXRuntime.jsxs("div",{className:l("flex items-center justify-end gap-1"),children:[i?ReactJSXRuntime.jsx(Te,{}):null,c?ReactJSXRuntime.jsx(Pe,{}):null,d?ReactJSXRuntime.jsx(wo,{showCopy:i,showDownload:c,children:e}):null]}):null,ReactJSXRuntime.jsx("div",{className:l("border-collapse overflow-x-auto overflow-y-auto rounded-md border border-border bg-background"),children:ReactJSXRuntime.jsx("table",{className:l("w-full divide-y divide-border",t),"data-streamdown":"table",...a,children:e})})]})};var Gr=/startLine=(\d+)/,Yr=React.lazy(()=>Promise.resolve().then(function () { return require('./fthry_mermaid-O7DHMXV3.BwkCSjZC.js'); }).then(e=>({default:e.Mermaid}))),Qr=/language-([^\s]+)/;function _e(e,t){if(!(e!=null&&e.position||t!=null&&t.position))return true;if(!(e!=null&&e.position&&(t!=null&&t.position)))return false;let o=e.position.start,n=t.position.start,r=e.position.end,s=t.position.end;return (o==null?void 0:o.line)===(n==null?void 0:n.line)&&(o==null?void 0:o.column)===(n==null?void 0:n.column)&&(r==null?void 0:r.line)===(s==null?void 0:s.line)&&(r==null?void 0:r.column)===(s==null?void 0:s.column)}function E(e,t){return e.className===t.className&&_e(e.node,t.node)}var pt=(e,t)=>typeof e=="boolean"?e:e[t]!==false,ut=(e,t)=>{if(typeof e=="boolean")return e;let o=e.table;return o===false?false:o===true||o===void 0?true:o[t]!==false},xo=(e,t)=>{if(typeof e=="boolean")return e;let o=e.code;return o===false?false:o===true||o===void 0?true:o[t]!==false},je=(e,t)=>{if(typeof e=="boolean")return e;let o=e.mermaid;return o===false?false:o===true||o===void 0?true:o[t]!==false},gt=React.memo(({children:e,className:t,node:o,...n})=>{let r=y();return ReactJSXRuntime.jsx("ol",{className:r("list-inside list-decimal whitespace-normal [li_&]:pl-6",t),"data-streamdown":"ordered-list",...n,children:e})},(e,t)=>E(e,t));gt.displayName="MarkdownOl";var To=React.memo(({children:e,className:t,node:o,...n})=>{let r=y();return ReactJSXRuntime.jsx("li",{className:r("py-1 [&>p]:inline",t),"data-streamdown":"list-item",...n,children:e})},(e,t)=>e.className===t.className&&_e(e.node,t.node));To.displayName="MarkdownLi";var Po=React.memo(({children:e,className:t,node:o,...n})=>{let r=y();return ReactJSXRuntime.jsx("ul",{className:r("list-inside list-disc whitespace-normal [li_&]:pl-6",t),"data-streamdown":"unordered-list",...n,children:e})},(e,t)=>E(e,t));Po.displayName="MarkdownUl";var Mo=React.memo(({className:e,node:t,...o})=>{let n=y();return ReactJSXRuntime.jsx("hr",{className:n("my-6 border-border",e),"data-streamdown":"horizontal-rule",...o})},(e,t)=>E(e,t));Mo.displayName="MarkdownHr";var Io=React.memo(({children:e,className:t,node:o,...n})=>{let r=y();return ReactJSXRuntime.jsx("span",{className:r("font-semibold",t),"data-streamdown":"strong",...n,children:e})},(e,t)=>E(e,t));Io.displayName="MarkdownStrong";var es=({children:e,className:t,href:o,node:n,...r})=>{let s=y(),{linkSafety:a}=React.useContext(R),[l,i]=React.useState(false),c=o==="streamdown:incomplete-link",d=React.useCallback(async g=>{if(!(!(a!=null&&a.enabled&&o)||c)){if(g.preventDefault(),a.onLinkCheck&&await a.onLinkCheck(o)){window.open(o,"_blank","noreferrer");return}i(true);}},[a,o,c]),u=React.useCallback(()=>{o&&window.open(o,"_blank","noreferrer");},[o]),m=React.useCallback(()=>{i(false);},[]),p={url:o!=null?o:"",isOpen:l,onClose:m,onConfirm:u};return a!=null&&a.enabled&&o?ReactJSXRuntime.jsxs(ReactJSXRuntime.Fragment,{children:[ReactJSXRuntime.jsx("button",{className:s("wrap-anywhere appearance-none text-left font-medium text-primary underline",t),"data-incomplete":c,"data-streamdown":"link",onClick:d,type:"button",children:e}),a.renderModal?a.renderModal(p):ReactJSXRuntime.jsx(ro,{...p})]}):ReactJSXRuntime.jsx("a",{className:s("wrap-anywhere font-medium text-primary underline",t),"data-incomplete":c,"data-streamdown":"link",href:o,rel:"noreferrer",target:"_blank",...r,children:e})},No=React.memo(es,(e,t)=>E(e,t)&&e.href===t.href);No.displayName="MarkdownA";var Lo=React.memo(({children:e,className:t,node:o,...n})=>{let r=y();return ReactJSXRuntime.jsx("h1",{className:r("mt-6 mb-2 font-semibold text-3xl",t),"data-streamdown":"heading-1",...n,children:e})},(e,t)=>E(e,t));Lo.displayName="MarkdownH1";var Ro=React.memo(({children:e,className:t,node:o,...n})=>{let r=y();return ReactJSXRuntime.jsx("h2",{className:r("mt-6 mb-2 font-semibold text-2xl",t),"data-streamdown":"heading-2",...n,children:e})},(e,t)=>E(e,t));Ro.displayName="MarkdownH2";var So=React.memo(({children:e,className:t,node:o,...n})=>{let r=y();return ReactJSXRuntime.jsx("h3",{className:r("mt-6 mb-2 font-semibold text-xl",t),"data-streamdown":"heading-3",...n,children:e})},(e,t)=>E(e,t));So.displayName="MarkdownH3";var Eo=React.memo(({children:e,className:t,node:o,...n})=>{let r=y();return ReactJSXRuntime.jsx("h4",{className:r("mt-6 mb-2 font-semibold text-lg",t),"data-streamdown":"heading-4",...n,children:e})},(e,t)=>E(e,t));Eo.displayName="MarkdownH4";var Ho=React.memo(({children:e,className:t,node:o,...n})=>{let r=y();return ReactJSXRuntime.jsx("h5",{className:r("mt-6 mb-2 font-semibold text-base",t),"data-streamdown":"heading-5",...n,children:e})},(e,t)=>E(e,t));Ho.displayName="MarkdownH5";var Do=React.memo(({children:e,className:t,node:o,...n})=>{let r=y();return ReactJSXRuntime.jsx("h6",{className:r("mt-6 mb-2 font-semibold text-sm",t),"data-streamdown":"heading-6",...n,children:e})},(e,t)=>E(e,t));Do.displayName="MarkdownH6";var Bo=React.memo(({children:e,className:t,node:o,...n})=>{let{controls:r}=React.useContext(R),s=pt(r,"table"),a=ut(r,"copy"),l=ut(r,"download"),i=ut(r,"fullscreen");return ReactJSXRuntime.jsx(ko,{className:t,showControls:s,showCopy:a,showDownload:l,showFullscreen:i,...n,children:e})},(e,t)=>E(e,t));Bo.displayName="MarkdownTable";var Ao=React.memo(({children:e,className:t,node:o,...n})=>{let r=y();return ReactJSXRuntime.jsx("thead",{className:r("bg-muted/80",t),"data-streamdown":"table-header",...n,children:e})},(e,t)=>E(e,t));Ao.displayName="MarkdownThead";var Oo=React.memo(({children:e,className:t,node:o,...n})=>{let r=y();return ReactJSXRuntime.jsx("tbody",{className:r("divide-y divide-border",t),"data-streamdown":"table-body",...n,children:e})},(e,t)=>E(e,t));Oo.displayName="MarkdownTbody";var Vo=React.memo(({children:e,className:t,node:o,...n})=>{let r=y();return ReactJSXRuntime.jsx("tr",{className:r("border-border",t),"data-streamdown":"table-row",...n,children:e})},(e,t)=>E(e,t));Vo.displayName="MarkdownTr";var jo=React.memo(({children:e,className:t,node:o,...n})=>{let r=y();return ReactJSXRuntime.jsx("th",{className:r("whitespace-nowrap px-4 py-2 text-left font-semibold text-sm",t),"data-streamdown":"table-header-cell",...n,children:e})},(e,t)=>E(e,t));jo.displayName="MarkdownTh";var Fo=React.memo(({children:e,className:t,node:o,...n})=>{let r=y();return ReactJSXRuntime.jsx("td",{className:r("px-4 py-2 text-sm",t),"data-streamdown":"table-cell",...n,children:e})},(e,t)=>E(e,t));Fo.displayName="MarkdownTd";var zo=React.memo(({children:e,className:t,node:o,...n})=>{let r=y();return ReactJSXRuntime.jsx("blockquote",{className:r("my-4 border-muted-foreground/30 border-l-4 pl-4 text-muted-foreground italic",t),"data-streamdown":"blockquote",...n,children:e})},(e,t)=>E(e,t));zo.displayName="MarkdownBlockquote";var _o=React.memo(({children:e,className:t,node:o,...n})=>{let r=y();return ReactJSXRuntime.jsx("sup",{className:r("text-sm",t),"data-streamdown":"superscript",...n,children:e})},(e,t)=>E(e,t));_o.displayName="MarkdownSup";var qo=React.memo(({children:e,className:t,node:o,...n})=>{let r=y();return ReactJSXRuntime.jsx("sub",{className:r("text-sm",t),"data-streamdown":"subscript",...n,children:e})},(e,t)=>E(e,t));qo.displayName="MarkdownSub";var $o=React.memo(({children:e,className:t,node:o,...n})=>{if("data-footnotes"in n){let s=i=>{var m,p;if(!React.isValidElement(i))return false;let c=Array.isArray(i.props.children)?i.props.children:[i.props.children],d=false,u=false;for(let g of c)if(g){if(typeof g=="string")g.trim()!==""&&(d=true);else if(React.isValidElement(g))if(((m=g.props)==null?void 0:m["data-footnote-backref"])!==void 0)u=true;else {let h=Array.isArray(g.props.children)?g.props.children:[g.props.children];for(let b of h){if(typeof b=="string"&&b.trim()!==""){d=true;break}if(React.isValidElement(b)&&((p=b.props)==null?void 0:p["data-footnote-backref"])===void 0){d=true;break}}}}return u&&!d},a=Array.isArray(e)?e.map(i=>{if(!React.isValidElement(i))return i;if(i.type===gt){let d=(Array.isArray(i.props.children)?i.props.children:[i.props.children]).filter(u=>!s(u));return d.length===0?null:{...i,props:{...i.props,children:d}}}return i}):e;return (Array.isArray(a)?a.some(i=>i!==null):a!==null)?ReactJSXRuntime.jsx("section",{className:t,...n,children:a}):null}return ReactJSXRuntime.jsx("section",{className:t,...n,children:e})},(e,t)=>E(e,t));$o.displayName="MarkdownSection";var ts=({node:e,className:t,children:o,...n})=>{var k,I;let r=y(),s=!("data-block"in n),{mermaid:a,controls:l}=React.useContext(R),i=de(),c=et(),d=t==null?void 0:t.match(Qr),u=(k=d==null?void 0:d.at(1))!=null?k:"",m=so(u);if(s)return ReactJSXRuntime.jsx("code",{className:r("rounded bg-muted px-1.5 py-0.5 font-mono text-sm",t),"data-streamdown":"inline-code",...n,children:o});let p=(I=e==null?void 0:e.properties)==null?void 0:I.metastring,g=p==null?void 0:p.match(Gr),h=g?Number.parseInt(g[1],10):void 0,b=h!==void 0&&h>=1?h:void 0,f="";if(React.isValidElement(o)&&o.props&&typeof o.props=="object"&&"children"in o.props&&typeof o.props.children=="string"?f=o.props.children:typeof o=="string"&&(f=o),m){let H=m.component;return ReactJSXRuntime.jsx(React.Suspense,{fallback:ReactJSXRuntime.jsx(Ae,{}),children:ReactJSXRuntime.jsx(H,{code:f,isIncomplete:c,language:u})})}if(u==="mermaid"&&i){let H=pt(l,"mermaid"),S=je(l,"download"),F=je(l,"copy"),z=je(l,"fullscreen"),q=je(l,"panZoom"),A=H&&(S||F||z);return ReactJSXRuntime.jsx(React.Suspense,{fallback:ReactJSXRuntime.jsx(Ae,{}),children:ReactJSXRuntime.jsxs("div",{className:r("group relative my-4 flex w-full flex-col gap-2 rounded-xl border border-border bg-sidebar p-2",t),"data-streamdown":"mermaid-block",children:[ReactJSXRuntime.jsx("div",{className:r("flex h-8 items-center text-muted-foreground text-xs"),children:ReactJSXRuntime.jsx("span",{className:r("ml-1 font-mono lowercase"),children:"mermaid"})}),A?ReactJSXRuntime.jsx("div",{className:r("pointer-events-none sticky top-2 z-10 -mt-10 flex h-8 items-center justify-end"),children:ReactJSXRuntime.jsxs("div",{className:r("pointer-events-auto flex shrink-0 items-center gap-2 rounded-md border border-sidebar bg-sidebar/80 px-1.5 py-1 supports-[backdrop-filter]:bg-sidebar/70 supports-[backdrop-filter]:backdrop-blur"),"data-streamdown":"mermaid-block-actions",children:[S?ReactJSXRuntime.jsx(lo,{chart:f,config:a==null?void 0:a.config}):null,F?ReactJSXRuntime.jsx(Be,{code:f}):null,z?ReactJSXRuntime.jsx(po,{chart:f,config:a==null?void 0:a.config}):null]})}):null,ReactJSXRuntime.jsx("div",{className:r("rounded-md border border-border bg-background"),children:ReactJSXRuntime.jsx(Yr,{chart:f,config:a==null?void 0:a.config,showControls:q})})]})})}let T=pt(l,"code"),x=xo(l,"download"),w=xo(l,"copy");return ReactJSXRuntime.jsx(rt,{className:t,code:f,isIncomplete:c,language:u,startLine:b,children:T?ReactJSXRuntime.jsxs(ReactJSXRuntime.Fragment,{children:[x?ReactJSXRuntime.jsx(at,{code:f,language:u}):null,w?ReactJSXRuntime.jsx(Be,{}):null]}):null})},Wo=React.memo(ts,(e,t)=>e.className===t.className&&_e(e.node,t.node));Wo.displayName="MarkdownCode";var Zo=React.memo(to,(e,t)=>e.className===t.className&&_e(e.node,t.node));Zo.displayName="MarkdownImg";var Xo=React.memo(({children:e,node:t,...o})=>{let r=(Array.isArray(e)?e:[e]).filter(s=>s!=null&&s!=="");if(r.length===1&&React.isValidElement(r[0])){let s=r[0].props.node,a=s==null?void 0:s.tagName;if(a==="img")return ReactJSXRuntime.jsx(ReactJSXRuntime.Fragment,{children:e});if(a==="code"&&"data-block"in r[0].props)return ReactJSXRuntime.jsx(ReactJSXRuntime.Fragment,{children:e})}return ReactJSXRuntime.jsx("p",{...o,children:e})},(e,t)=>E(e,t));Xo.displayName="MarkdownParagraph";var Jo={ol:gt,li:To,ul:Po,hr:Mo,strong:Io,a:No,h1:Lo,h2:Ro,h3:So,h4:Eo,h5:Ho,h6:Do,table:Bo,thead:Ao,tbody:Oo,tr:Vo,th:jo,td:Fo,blockquote:zo,code:Wo,img:Zo,pre:({children:e})=>React.isValidElement(e)?React.cloneElement(e,{"data-block":"true"}):e,sup:_o,sub:qo,p:Xo,section:$o};var os=/[\u0590-\u08FF\uFB1D-\uFDFF\uFE70-\uFEFF]/,ns=/\p{L}/u;function qe(e){let t=e.replace(/^#{1,6}\s+/gm,"").replace(/(\*{1,3}|_{1,3})/g,"").replace(/`[^`]*`/g,"").replace(/\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/^[\s>*\-+\d.]+/gm,"");for(let o of t){if(os.test(o))return "rtl";if(ns.test(o))return "ltr"}return "ltr"}var rs=/^[ \t]{0,3}(`{3,}|~{3,})/,ss=/^\|?[ \t]*:?-{1,}:?[ \t]*(\|[ \t]*:?-{1,}:?[ \t]*)*\|?$/,bt=e=>{let t=e.split(`
|
|
51754
|
+
`)};var Te=({children:e,className:t,onCopy:o,onError:n,timeout:r=2e3})=>{let s=y(),[a,l]=React.useState(false),[i,c]=React.useState(false),d=React.useRef(null),u=React.useRef(0),{isAnimating:m}=React.useContext(R),p=B(),g=async f=>{var T,x;if(typeof window=="undefined"||!((T=navigator==null?void 0:navigator.clipboard)!=null&&T.write)){n==null||n(new Error("Clipboard API not available"));return}try{let w=(x=d.current)==null?void 0:x.closest('[data-streamdown="table-wrapper"]'),k=w==null?void 0:w.querySelector("table");if(!k){n==null||n(new Error("Table not found"));return}let I=ue(k),F=({csv:oe,tsv:ct,md:ne}[f]||ne)(I),z=new ClipboardItem({"text/plain":new Blob([F],{type:"text/plain"}),"text/html":new Blob([k.outerHTML],{type:"text/html"})});await navigator.clipboard.write([z]),c(!0),l(!1),o==null||o(f),u.current=window.setTimeout(()=>c(!1),r);}catch(w){n==null||n(w);}};React.useEffect(()=>{let f=T=>{let x=T.composedPath();d.current&&!x.includes(d.current)&&l(false);};return document.addEventListener("mousedown",f),()=>{document.removeEventListener("mousedown",f),window.clearTimeout(u.current);}},[]);let h=L(),b=i?h.CheckIcon:h.CopyIcon;return ReactJSXRuntime.jsxs("div",{className:s("relative"),ref:d,children:[ReactJSXRuntime.jsx("button",{className:s("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:m,onClick:()=>l(!a),title:p.copyTable,type:"button",children:e!=null?e:ReactJSXRuntime.jsx(b,{height:14,width:14})}),a?ReactJSXRuntime.jsxs("div",{className:s("absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg"),children:[ReactJSXRuntime.jsx("button",{className:s("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>g("md"),title:p.copyTableAsMarkdown,type:"button",children:p.tableFormatMarkdown}),ReactJSXRuntime.jsx("button",{className:s("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>g("csv"),title:p.copyTableAsCsv,type:"button",children:p.tableFormatCsv}),ReactJSXRuntime.jsx("button",{className:s("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>g("tsv"),title:p.copyTableAsTsv,type:"button",children:p.tableFormatTsv})]}):null]})};var Pe=({children:e,className:t,onDownload:o,onError:n})=>{let r=y(),[s,a]=React.useState(false),l=React.useRef(null),{isAnimating:i}=React.useContext(R),c=B(),d=L(),u=m=>{var p;try{let g=(p=l.current)==null?void 0:p.closest('[data-streamdown="table-wrapper"]'),h=g==null?void 0:g.querySelector("table");if(!h){n==null||n(new Error("Table not found"));return}let b=ue(h),f=m==="csv"?oe(b):ne(b);J(`table.${m==="csv"?"csv":"md"}`,f,m==="csv"?"text/csv":"text/markdown"),a(!1),o==null||o(m);}catch(g){n==null||n(g);}};return React.useEffect(()=>{let m=p=>{let g=p.composedPath();l.current&&!g.includes(l.current)&&a(false);};return document.addEventListener("mousedown",m),()=>{document.removeEventListener("mousedown",m);}},[]),ReactJSXRuntime.jsxs("div",{className:r("relative"),ref:l,children:[ReactJSXRuntime.jsx("button",{className:r("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:i,onClick:()=>a(!s),title:c.downloadTable,type:"button",children:e!=null?e:ReactJSXRuntime.jsx(d.DownloadIcon,{size:14})}),s?ReactJSXRuntime.jsxs("div",{className:r("absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg"),children:[ReactJSXRuntime.jsx("button",{className:r("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>u("csv"),title:c.downloadTableAsCsv,type:"button",children:c.tableFormatCsv}),ReactJSXRuntime.jsx("button",{className:r("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),onClick:()=>u("markdown"),title:c.downloadTableAsMarkdown,type:"button",children:c.tableFormatMarkdown})]}):null]})};var wo=({children:e,className:t,showCopy:o=true,showDownload:n=true})=>{let{Maximize2Icon:r,XIcon:s}=L(),a=y(),[l,i]=React.useState(false),{isAnimating:c}=React.useContext(R),d=B(),u=()=>{i(true);},m=()=>{i(false);};return React.useEffect(()=>{if(l){le();let p=g=>{g.key==="Escape"&&i(false);};return document.addEventListener("keydown",p),()=>{document.removeEventListener("keydown",p),ce();}}},[l]),ReactJSXRuntime.jsxs(ReactJSXRuntime.Fragment,{children:[ReactJSXRuntime.jsx("button",{className:a("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:c,onClick:u,title:d.viewFullscreen,type:"button",children:ReactJSXRuntime.jsx(r,{size:14})}),l?ReactDOM.createPortal(ReactJSXRuntime.jsx("div",{"aria-label":d.viewFullscreen,"aria-modal":"true",className:a("fixed inset-0 z-50 flex flex-col bg-background"),"data-streamdown":"table-fullscreen",onClick:m,onKeyDown:p=>{p.key==="Escape"&&m();},role:"dialog",children:ReactJSXRuntime.jsxs("div",{className:a("flex h-full flex-col"),onClick:p=>p.stopPropagation(),onKeyDown:p=>p.stopPropagation(),role:"presentation",children:[ReactJSXRuntime.jsxs("div",{className:a("flex items-center justify-end gap-1 p-4"),children:[o?ReactJSXRuntime.jsx(Te,{}):null,n?ReactJSXRuntime.jsx(Pe,{}):null,ReactJSXRuntime.jsx("button",{className:a("rounded-md p-1 text-muted-foreground transition-all hover:bg-muted hover:text-foreground"),onClick:m,title:d.exitFullscreen,type:"button",children:ReactJSXRuntime.jsx(s,{size:20})})]}),ReactJSXRuntime.jsx("div",{className:a("flex-1 overflow-auto p-4 pt-0 [&_thead]:sticky [&_thead]:top-0 [&_thead]:z-10"),children:ReactJSXRuntime.jsx("table",{className:a("w-full border-collapse border border-border"),"data-streamdown":"table",children:e})})]})}),document.body):null]})};var ko=({children:e,className:t,showControls:o,showCopy:n=true,showDownload:r=true,showFullscreen:s=true,...a})=>{let l=y(),i=o&&n,c=o&&r,d=o&&s,u=i||c||d;return ReactJSXRuntime.jsxs("div",{className:l("my-4 flex flex-col gap-2 rounded-lg border border-border bg-sidebar p-2"),"data-streamdown":"table-wrapper",children:[u?ReactJSXRuntime.jsxs("div",{className:l("flex items-center justify-end gap-1"),children:[i?ReactJSXRuntime.jsx(Te,{}):null,c?ReactJSXRuntime.jsx(Pe,{}):null,d?ReactJSXRuntime.jsx(wo,{showCopy:i,showDownload:c,children:e}):null]}):null,ReactJSXRuntime.jsx("div",{className:l("border-collapse overflow-x-auto overflow-y-auto rounded-md border border-border bg-background"),children:ReactJSXRuntime.jsx("table",{className:l("w-full divide-y divide-border",t),"data-streamdown":"table",...a,children:e})})]})};var Gr=/startLine=(\d+)/,Yr=React.lazy(()=>Promise.resolve().then(function () { return require('./fthry_mermaid-O7DHMXV3.Dk3DbMjU.js'); }).then(e=>({default:e.Mermaid}))),Qr=/language-([^\s]+)/;function _e(e,t){if(!(e!=null&&e.position||t!=null&&t.position))return true;if(!(e!=null&&e.position&&(t!=null&&t.position)))return false;let o=e.position.start,n=t.position.start,r=e.position.end,s=t.position.end;return (o==null?void 0:o.line)===(n==null?void 0:n.line)&&(o==null?void 0:o.column)===(n==null?void 0:n.column)&&(r==null?void 0:r.line)===(s==null?void 0:s.line)&&(r==null?void 0:r.column)===(s==null?void 0:s.column)}function E(e,t){return e.className===t.className&&_e(e.node,t.node)}var pt=(e,t)=>typeof e=="boolean"?e:e[t]!==false,ut=(e,t)=>{if(typeof e=="boolean")return e;let o=e.table;return o===false?false:o===true||o===void 0?true:o[t]!==false},xo=(e,t)=>{if(typeof e=="boolean")return e;let o=e.code;return o===false?false:o===true||o===void 0?true:o[t]!==false},je=(e,t)=>{if(typeof e=="boolean")return e;let o=e.mermaid;return o===false?false:o===true||o===void 0?true:o[t]!==false},gt=React.memo(({children:e,className:t,node:o,...n})=>{let r=y();return ReactJSXRuntime.jsx("ol",{className:r("list-inside list-decimal whitespace-normal [li_&]:pl-6",t),"data-streamdown":"ordered-list",...n,children:e})},(e,t)=>E(e,t));gt.displayName="MarkdownOl";var To=React.memo(({children:e,className:t,node:o,...n})=>{let r=y();return ReactJSXRuntime.jsx("li",{className:r("py-1 [&>p]:inline",t),"data-streamdown":"list-item",...n,children:e})},(e,t)=>e.className===t.className&&_e(e.node,t.node));To.displayName="MarkdownLi";var Po=React.memo(({children:e,className:t,node:o,...n})=>{let r=y();return ReactJSXRuntime.jsx("ul",{className:r("list-inside list-disc whitespace-normal [li_&]:pl-6",t),"data-streamdown":"unordered-list",...n,children:e})},(e,t)=>E(e,t));Po.displayName="MarkdownUl";var Mo=React.memo(({className:e,node:t,...o})=>{let n=y();return ReactJSXRuntime.jsx("hr",{className:n("my-6 border-border",e),"data-streamdown":"horizontal-rule",...o})},(e,t)=>E(e,t));Mo.displayName="MarkdownHr";var Io=React.memo(({children:e,className:t,node:o,...n})=>{let r=y();return ReactJSXRuntime.jsx("span",{className:r("font-semibold",t),"data-streamdown":"strong",...n,children:e})},(e,t)=>E(e,t));Io.displayName="MarkdownStrong";var es=({children:e,className:t,href:o,node:n,...r})=>{let s=y(),{linkSafety:a}=React.useContext(R),[l,i]=React.useState(false),c=o==="streamdown:incomplete-link",d=React.useCallback(async g=>{if(!(!(a!=null&&a.enabled&&o)||c)){if(g.preventDefault(),a.onLinkCheck&&await a.onLinkCheck(o)){window.open(o,"_blank","noreferrer");return}i(true);}},[a,o,c]),u=React.useCallback(()=>{o&&window.open(o,"_blank","noreferrer");},[o]),m=React.useCallback(()=>{i(false);},[]),p={url:o!=null?o:"",isOpen:l,onClose:m,onConfirm:u};return a!=null&&a.enabled&&o?ReactJSXRuntime.jsxs(ReactJSXRuntime.Fragment,{children:[ReactJSXRuntime.jsx("button",{className:s("wrap-anywhere appearance-none text-left font-medium text-primary underline",t),"data-incomplete":c,"data-streamdown":"link",onClick:d,type:"button",children:e}),a.renderModal?a.renderModal(p):ReactJSXRuntime.jsx(ro,{...p})]}):ReactJSXRuntime.jsx("a",{className:s("wrap-anywhere font-medium text-primary underline",t),"data-incomplete":c,"data-streamdown":"link",href:o,rel:"noreferrer",target:"_blank",...r,children:e})},No=React.memo(es,(e,t)=>E(e,t)&&e.href===t.href);No.displayName="MarkdownA";var Lo=React.memo(({children:e,className:t,node:o,...n})=>{let r=y();return ReactJSXRuntime.jsx("h1",{className:r("mt-6 mb-2 font-semibold text-3xl",t),"data-streamdown":"heading-1",...n,children:e})},(e,t)=>E(e,t));Lo.displayName="MarkdownH1";var Ro=React.memo(({children:e,className:t,node:o,...n})=>{let r=y();return ReactJSXRuntime.jsx("h2",{className:r("mt-6 mb-2 font-semibold text-2xl",t),"data-streamdown":"heading-2",...n,children:e})},(e,t)=>E(e,t));Ro.displayName="MarkdownH2";var So=React.memo(({children:e,className:t,node:o,...n})=>{let r=y();return ReactJSXRuntime.jsx("h3",{className:r("mt-6 mb-2 font-semibold text-xl",t),"data-streamdown":"heading-3",...n,children:e})},(e,t)=>E(e,t));So.displayName="MarkdownH3";var Eo=React.memo(({children:e,className:t,node:o,...n})=>{let r=y();return ReactJSXRuntime.jsx("h4",{className:r("mt-6 mb-2 font-semibold text-lg",t),"data-streamdown":"heading-4",...n,children:e})},(e,t)=>E(e,t));Eo.displayName="MarkdownH4";var Ho=React.memo(({children:e,className:t,node:o,...n})=>{let r=y();return ReactJSXRuntime.jsx("h5",{className:r("mt-6 mb-2 font-semibold text-base",t),"data-streamdown":"heading-5",...n,children:e})},(e,t)=>E(e,t));Ho.displayName="MarkdownH5";var Do=React.memo(({children:e,className:t,node:o,...n})=>{let r=y();return ReactJSXRuntime.jsx("h6",{className:r("mt-6 mb-2 font-semibold text-sm",t),"data-streamdown":"heading-6",...n,children:e})},(e,t)=>E(e,t));Do.displayName="MarkdownH6";var Bo=React.memo(({children:e,className:t,node:o,...n})=>{let{controls:r}=React.useContext(R),s=pt(r,"table"),a=ut(r,"copy"),l=ut(r,"download"),i=ut(r,"fullscreen");return ReactJSXRuntime.jsx(ko,{className:t,showControls:s,showCopy:a,showDownload:l,showFullscreen:i,...n,children:e})},(e,t)=>E(e,t));Bo.displayName="MarkdownTable";var Ao=React.memo(({children:e,className:t,node:o,...n})=>{let r=y();return ReactJSXRuntime.jsx("thead",{className:r("bg-muted/80",t),"data-streamdown":"table-header",...n,children:e})},(e,t)=>E(e,t));Ao.displayName="MarkdownThead";var Oo=React.memo(({children:e,className:t,node:o,...n})=>{let r=y();return ReactJSXRuntime.jsx("tbody",{className:r("divide-y divide-border",t),"data-streamdown":"table-body",...n,children:e})},(e,t)=>E(e,t));Oo.displayName="MarkdownTbody";var Vo=React.memo(({children:e,className:t,node:o,...n})=>{let r=y();return ReactJSXRuntime.jsx("tr",{className:r("border-border",t),"data-streamdown":"table-row",...n,children:e})},(e,t)=>E(e,t));Vo.displayName="MarkdownTr";var jo=React.memo(({children:e,className:t,node:o,...n})=>{let r=y();return ReactJSXRuntime.jsx("th",{className:r("whitespace-nowrap px-4 py-2 text-left font-semibold text-sm",t),"data-streamdown":"table-header-cell",...n,children:e})},(e,t)=>E(e,t));jo.displayName="MarkdownTh";var Fo=React.memo(({children:e,className:t,node:o,...n})=>{let r=y();return ReactJSXRuntime.jsx("td",{className:r("px-4 py-2 text-sm",t),"data-streamdown":"table-cell",...n,children:e})},(e,t)=>E(e,t));Fo.displayName="MarkdownTd";var zo=React.memo(({children:e,className:t,node:o,...n})=>{let r=y();return ReactJSXRuntime.jsx("blockquote",{className:r("my-4 border-muted-foreground/30 border-l-4 pl-4 text-muted-foreground italic",t),"data-streamdown":"blockquote",...n,children:e})},(e,t)=>E(e,t));zo.displayName="MarkdownBlockquote";var _o=React.memo(({children:e,className:t,node:o,...n})=>{let r=y();return ReactJSXRuntime.jsx("sup",{className:r("text-sm",t),"data-streamdown":"superscript",...n,children:e})},(e,t)=>E(e,t));_o.displayName="MarkdownSup";var qo=React.memo(({children:e,className:t,node:o,...n})=>{let r=y();return ReactJSXRuntime.jsx("sub",{className:r("text-sm",t),"data-streamdown":"subscript",...n,children:e})},(e,t)=>E(e,t));qo.displayName="MarkdownSub";var $o=React.memo(({children:e,className:t,node:o,...n})=>{if("data-footnotes"in n){let s=i=>{var m,p;if(!React.isValidElement(i))return false;let c=Array.isArray(i.props.children)?i.props.children:[i.props.children],d=false,u=false;for(let g of c)if(g){if(typeof g=="string")g.trim()!==""&&(d=true);else if(React.isValidElement(g))if(((m=g.props)==null?void 0:m["data-footnote-backref"])!==void 0)u=true;else {let h=Array.isArray(g.props.children)?g.props.children:[g.props.children];for(let b of h){if(typeof b=="string"&&b.trim()!==""){d=true;break}if(React.isValidElement(b)&&((p=b.props)==null?void 0:p["data-footnote-backref"])===void 0){d=true;break}}}}return u&&!d},a=Array.isArray(e)?e.map(i=>{if(!React.isValidElement(i))return i;if(i.type===gt){let d=(Array.isArray(i.props.children)?i.props.children:[i.props.children]).filter(u=>!s(u));return d.length===0?null:{...i,props:{...i.props,children:d}}}return i}):e;return (Array.isArray(a)?a.some(i=>i!==null):a!==null)?ReactJSXRuntime.jsx("section",{className:t,...n,children:a}):null}return ReactJSXRuntime.jsx("section",{className:t,...n,children:e})},(e,t)=>E(e,t));$o.displayName="MarkdownSection";var ts=({node:e,className:t,children:o,...n})=>{var k,I;let r=y(),s=!("data-block"in n),{mermaid:a,controls:l}=React.useContext(R),i=de(),c=et(),d=t==null?void 0:t.match(Qr),u=(k=d==null?void 0:d.at(1))!=null?k:"",m=so(u);if(s)return ReactJSXRuntime.jsx("code",{className:r("rounded bg-muted px-1.5 py-0.5 font-mono text-sm",t),"data-streamdown":"inline-code",...n,children:o});let p=(I=e==null?void 0:e.properties)==null?void 0:I.metastring,g=p==null?void 0:p.match(Gr),h=g?Number.parseInt(g[1],10):void 0,b=h!==void 0&&h>=1?h:void 0,f="";if(React.isValidElement(o)&&o.props&&typeof o.props=="object"&&"children"in o.props&&typeof o.props.children=="string"?f=o.props.children:typeof o=="string"&&(f=o),m){let H=m.component;return ReactJSXRuntime.jsx(React.Suspense,{fallback:ReactJSXRuntime.jsx(Ae,{}),children:ReactJSXRuntime.jsx(H,{code:f,isIncomplete:c,language:u})})}if(u==="mermaid"&&i){let H=pt(l,"mermaid"),S=je(l,"download"),F=je(l,"copy"),z=je(l,"fullscreen"),q=je(l,"panZoom"),A=H&&(S||F||z);return ReactJSXRuntime.jsx(React.Suspense,{fallback:ReactJSXRuntime.jsx(Ae,{}),children:ReactJSXRuntime.jsxs("div",{className:r("group relative my-4 flex w-full flex-col gap-2 rounded-xl border border-border bg-sidebar p-2",t),"data-streamdown":"mermaid-block",children:[ReactJSXRuntime.jsx("div",{className:r("flex h-8 items-center text-muted-foreground text-xs"),children:ReactJSXRuntime.jsx("span",{className:r("ml-1 font-mono lowercase"),children:"mermaid"})}),A?ReactJSXRuntime.jsx("div",{className:r("pointer-events-none sticky top-2 z-10 -mt-10 flex h-8 items-center justify-end"),children:ReactJSXRuntime.jsxs("div",{className:r("pointer-events-auto flex shrink-0 items-center gap-2 rounded-md border border-sidebar bg-sidebar/80 px-1.5 py-1 supports-[backdrop-filter]:bg-sidebar/70 supports-[backdrop-filter]:backdrop-blur"),"data-streamdown":"mermaid-block-actions",children:[S?ReactJSXRuntime.jsx(lo,{chart:f,config:a==null?void 0:a.config}):null,F?ReactJSXRuntime.jsx(Be,{code:f}):null,z?ReactJSXRuntime.jsx(po,{chart:f,config:a==null?void 0:a.config}):null]})}):null,ReactJSXRuntime.jsx("div",{className:r("rounded-md border border-border bg-background"),children:ReactJSXRuntime.jsx(Yr,{chart:f,config:a==null?void 0:a.config,showControls:q})})]})})}let T=pt(l,"code"),x=xo(l,"download"),w=xo(l,"copy");return ReactJSXRuntime.jsx(rt,{className:t,code:f,isIncomplete:c,language:u,startLine:b,children:T?ReactJSXRuntime.jsxs(ReactJSXRuntime.Fragment,{children:[x?ReactJSXRuntime.jsx(at,{code:f,language:u}):null,w?ReactJSXRuntime.jsx(Be,{}):null]}):null})},Wo=React.memo(ts,(e,t)=>e.className===t.className&&_e(e.node,t.node));Wo.displayName="MarkdownCode";var Zo=React.memo(to,(e,t)=>e.className===t.className&&_e(e.node,t.node));Zo.displayName="MarkdownImg";var Xo=React.memo(({children:e,node:t,...o})=>{let r=(Array.isArray(e)?e:[e]).filter(s=>s!=null&&s!=="");if(r.length===1&&React.isValidElement(r[0])){let s=r[0].props.node,a=s==null?void 0:s.tagName;if(a==="img")return ReactJSXRuntime.jsx(ReactJSXRuntime.Fragment,{children:e});if(a==="code"&&"data-block"in r[0].props)return ReactJSXRuntime.jsx(ReactJSXRuntime.Fragment,{children:e})}return ReactJSXRuntime.jsx("p",{...o,children:e})},(e,t)=>E(e,t));Xo.displayName="MarkdownParagraph";var Jo={ol:gt,li:To,ul:Po,hr:Mo,strong:Io,a:No,h1:Lo,h2:Ro,h3:So,h4:Eo,h5:Ho,h6:Do,table:Bo,thead:Ao,tbody:Oo,tr:Vo,th:jo,td:Fo,blockquote:zo,code:Wo,img:Zo,pre:({children:e})=>React.isValidElement(e)?React.cloneElement(e,{"data-block":"true"}):e,sup:_o,sub:qo,p:Xo,section:$o};var os=/[\u0590-\u08FF\uFB1D-\uFDFF\uFE70-\uFEFF]/,ns=/\p{L}/u;function qe(e){let t=e.replace(/^#{1,6}\s+/gm,"").replace(/(\*{1,3}|_{1,3})/g,"").replace(/`[^`]*`/g,"").replace(/\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/^[\s>*\-+\d.]+/gm,"");for(let o of t){if(os.test(o))return "rtl";if(ns.test(o))return "ltr"}return "ltr"}var rs=/^[ \t]{0,3}(`{3,}|~{3,})/,ss=/^\|?[ \t]*:?-{1,}:?[ \t]*(\|[ \t]*:?-{1,}:?[ \t]*)*\|?$/,bt=e=>{let t=e.split(`
|
|
51317
51755
|
`),o=null,n=0;for(let r of t){let s=rs.exec(r);if(o===null){if(s){let a=s[1];o=a[0],n=a.length;}}else if(s){let a=s[1],l=a[0],i=a.length;l===o&&i>=n&&(o=null,n=0);}}return o!==null},Ko=e=>{let t=e.split(`
|
|
51318
51756
|
`);for(let o of t){let n=o.trim();if(n.length>0&&n.includes("|")&&ss.test(n))return true}return false};var Uo=()=>e=>{visit(e,"html",(t,o,n)=>{!n||typeof o!="number"||(n.children[o]={type:"text",value:t.value});});};var Yo=[],Qo={allowDangerousHtml:true},$e=new WeakMap,yt=class{constructor(){this.cache=new Map;this.keyCache=new WeakMap;this.maxSize=100;}generateCacheKey(t){let o=this.keyCache.get(t);if(o)return o;let n=t.rehypePlugins,r=t.remarkPlugins,s=t.remarkRehypeOptions;if(!(n||r||s)){let u="default";return this.keyCache.set(t,u),u}let a=u=>{if(!u||u.length===0)return "";let m="";for(let p=0;p<u.length;p+=1){let g=u[p];if(p>0&&(m+=","),Array.isArray(g)){let[h,b]=g;if(typeof h=="function"){let f=$e.get(h);f||(f=h.name,$e.set(h,f)),m+=f;}else m+=String(h);m+=":",m+=JSON.stringify(b);}else if(typeof g=="function"){let h=$e.get(g);h||(h=g.name,$e.set(g,h)),m+=h;}else m+=String(g);}return m},l=a(n),i=a(r),c=s?JSON.stringify(s):"",d=`${i}::${l}::${c}`;return this.keyCache.set(t,d),d}get(t){let o=this.generateCacheKey(t),n=this.cache.get(o);return n&&(this.cache.delete(o),this.cache.set(o,n)),n}set(t,o){let n=this.generateCacheKey(t);if(this.cache.size>=this.maxSize){let r=this.cache.keys().next().value;r&&this.cache.delete(r);}this.cache.set(n,o);}clear(){this.cache.clear();}},en=new yt,wt=e=>{let t=gs(e),o=e.children||"",n=t.runSync(t.parse(o),o);return ks(n,e)},gs=e=>{let t=en.get(e);if(t)return t;let o=hs(e);return en.set(e,o),o},bs=e=>e.some(t=>Array.isArray(t)?t[0]===rehypeRaw:t===rehypeRaw),hs=e=>{let t=e.rehypePlugins||Yo,o=e.remarkPlugins||Yo,n=bs(t)?o:[...o,Uo],r=e.remarkRehypeOptions?{...Qo,...e.remarkRehypeOptions}:Qo;return unified().use(remarkParse).use(n).use(remarkRehype,r).use(t)},tn=e=>e,ys=(e,t,o,n)=>{o?e.children.splice(t,1):e.children[t]={type:"text",value:n};},ws=(e,t)=>{var o;for(let n in urlAttributes)if(Object.hasOwn(urlAttributes,n)&&Object.hasOwn(e.properties,n)){let r=e.properties[n],s=urlAttributes[n];(s===null||s.includes(e.tagName))&&(e.properties[n]=(o=t(String(r||""),n,e))!=null?o:void 0);}},Cs=(e,t,o,n,r,s)=>{let a=false;return n?a=!n.includes(e.tagName):r&&(a=r.includes(e.tagName)),!a&&s&&typeof t=="number"&&(a=!s(e,t,o)),a},ks=(e,t)=>{let{allowElement:o,allowedElements:n,disallowedElements:r,skipHtml:s,unwrapDisallowed:a,urlTransform:l}=t;if(o||n||r||s||l){let c=l||tn;visit(e,(d,u,m)=>{if(d.type==="raw"&&m&&typeof u=="number")return ys(m,u,s,d.value),u;if(d.type==="element"&&(ws(d,c),Cs(d,u,m,n,r,o)&&m&&typeof u=="number"))return a&&d.children?m.children.splice(u,1,...d.children):m.children.splice(u,1),u});}return toJsxRuntime(e,{Fragment:ReactJSXRuntime.Fragment,components:t.components,ignoreInvalidStyle:true,jsx:ReactJSXRuntime.jsx,jsxs:ReactJSXRuntime.jsxs,passKeys:true,passNode:true})};var xs=/\[\^[\w-]{1,200}\](?!:)/,Ts=/\[\^[\w-]{1,200}\]:/;var Ps=/<(\w+)[\s>]/,Ms=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),on=new Map,nn=new Map,Is=e=>{let t=e.toLowerCase(),o=on.get(t);if(o)return o;let n=new RegExp(`<${t}(?=[\\s>/])[^>]*>`,"gi");return on.set(t,n),n},Ns=e=>{let t=e.toLowerCase(),o=nn.get(t);if(o)return o;let n=new RegExp(`</${t}(?=[\\s>])[^>]*>`,"gi");return nn.set(t,n),n},rn=(e,t)=>{if(Ms.has(t.toLowerCase()))return 0;let o=e.match(Is(t));if(!o)return 0;let n=0;for(let r of o)r.trimEnd().endsWith("/>")||(n+=1);return n},sn=(e,t)=>{let o=e.match(Ns(t));return o?o.length:0},Ls=e=>{let t=0;for(let o=0;o<e.length-1;o+=1)e[o]==="$"&&e[o+1]==="$"&&(t+=1,o+=1);return t},Ct=e=>{let t=xs.test(e),o=Ts.test(e);if(t||o)return [e];let n=x.lex(e,{gfm:true}),r=[],s=[],a=false;for(let l of n){let i=l.raw,c=r.length;if(s.length>0){r[c-1]+=i;let d=s.at(-1),u=rn(i,d),m=sn(i,d);for(let p=0;p<u;p+=1)s.push(d);for(let p=0;p<m;p+=1)s.length>0&&s.at(-1)===d&&s.pop();continue}if(l.type==="html"&&l.block){let d=i.match(Ps);if(d){let u=d[1],m=rn(i,u),p=sn(i,u);m>p&&s.push(u);}}if(c>0&&!a){let d=r[c-1];if(Ls(d)%2===1){r[c-1]=d+i;continue}}r.push(i),l.type!=="space"&&(a=l.type==="code");}return r};var an=(e,t)=>{if(!t.length)return e;let o=e;for(let n of t){let r=new RegExp(`(<${n}(?=[\\s>/])[^>]*>)([\\s\\S]*?)(</${n}\\s*>)`,"gi");o=o.replace(r,(s,a,l,i)=>{let c=l.replace(/\n\n/g,`
|
|
51319
51757
|
<!---->
|
|
@@ -52956,7 +53394,7 @@ var DEFAULT_MODES = [
|
|
|
52956
53394
|
var AssistantChat = function (_a) {
|
|
52957
53395
|
var _b, _c;
|
|
52958
53396
|
var _d;
|
|
52959
|
-
var instanceId = _a.instanceId, getTargets = _a.getTargets, getJwt = _a.getJwt, baseUrl = _a.baseUrl, _e = _a.bottom, bottom = _e === void 0 ? 20 : _e, color = _a.color, _f = _a.workflowActions, workflowActions =
|
|
53397
|
+
var instanceId = _a.instanceId, getTargets = _a.getTargets, getJwt = _a.getJwt, baseUrl = _a.baseUrl, _e = _a.bottom, bottom = _e === void 0 ? 20 : _e, color = _a.color, _f = _a.voiceEnabled, voiceEnabled = _f === void 0 ? false : _f, _g = _a.workflowActions, workflowActions = _g === void 0 ? [] : _g, _h = _a.allowedModes, allowedModes = _h === void 0 ? DEFAULT_MODES : _h, onLayoutChange = _a.onLayoutChange;
|
|
52960
53398
|
var headers = React.useMemo(function () {
|
|
52961
53399
|
if (getJwt)
|
|
52962
53400
|
return function () { return ({ Authorization: "Bearer ".concat(getJwt()) }); };
|
|
@@ -52983,14 +53421,14 @@ var AssistantChat = function (_a) {
|
|
|
52983
53421
|
}
|
|
52984
53422
|
return body;
|
|
52985
53423
|
};
|
|
52986
|
-
var
|
|
52987
|
-
var
|
|
53424
|
+
var _j = index$1.__read(React.useState(false), 2), isOpen = _j[0], setIsOpen = _j[1];
|
|
53425
|
+
var _k = index$1.__read(React.useState(readStoredMode), 2), mode = _k[0], setModeState = _k[1];
|
|
52988
53426
|
var setMode = React.useCallback(function (next) {
|
|
52989
53427
|
setModeState(next);
|
|
52990
53428
|
writeStoredMode(next);
|
|
52991
53429
|
}, []);
|
|
52992
|
-
var
|
|
52993
|
-
var
|
|
53430
|
+
var _l = index$1.__read(React.useState(readStoredSidebarWidth), 2), sidebarWidth = _l[0], setSidebarWidth = _l[1];
|
|
53431
|
+
var _m = index$1.__read(React.useState(false), 2), isResizing = _m[0], setIsResizing = _m[1];
|
|
52994
53432
|
React.useEffect(function () {
|
|
52995
53433
|
var onWindowResize = function () {
|
|
52996
53434
|
setSidebarWidth(function (w) {
|
|
@@ -53036,17 +53474,20 @@ var AssistantChat = function (_a) {
|
|
|
53036
53474
|
setSidebarWidth(DEFAULT_SIDEBAR_WIDTH);
|
|
53037
53475
|
writeStoredSidebarWidth(DEFAULT_SIDEBAR_WIDTH);
|
|
53038
53476
|
}, []);
|
|
53039
|
-
var
|
|
53040
|
-
var
|
|
53041
|
-
var
|
|
53042
|
-
var
|
|
53043
|
-
var
|
|
53044
|
-
var
|
|
53045
|
-
var messagesEndRef = React.useRef(null);
|
|
53477
|
+
var _o = index$1.__read(React.useState(''), 2), input = _o[0], setInput = _o[1];
|
|
53478
|
+
var _p = index$1.__read(React.useState([]), 2), threads = _p[0], setThreads = _p[1];
|
|
53479
|
+
var _q = index$1.__read(React.useState(null), 2), activeThreadId = _q[0], setActiveThreadId = _q[1];
|
|
53480
|
+
var _r = index$1.__read(React.useState(false), 2), isDropdownOpen = _r[0], setIsDropdownOpen = _r[1];
|
|
53481
|
+
var _s = index$1.__read(React.useState(false), 2), isModeMenuOpen = _s[0], setIsModeMenuOpen = _s[1];
|
|
53482
|
+
var _t = index$1.__read(React.useState(null), 2), actionTooltip = _t[0], setActionTooltip = _t[1];
|
|
53046
53483
|
var messagesContainerRef = React.useRef(null);
|
|
53047
53484
|
// Suppresses auto-scroll when the user has scrolled up to read earlier content
|
|
53048
53485
|
var atBottomRef = React.useRef(true);
|
|
53049
53486
|
var BOTTOM_THRESHOLD_PX = 60;
|
|
53487
|
+
// Voice state read while sending a request and while routing its streamed data parts
|
|
53488
|
+
var voiceActiveRef = React.useRef(false);
|
|
53489
|
+
var pendingAudioRef = React.useRef(null);
|
|
53490
|
+
var voiceDataRef = React.useRef(null);
|
|
53050
53491
|
var handleMessagesScroll = React.useCallback(function () {
|
|
53051
53492
|
var el = messagesContainerRef.current;
|
|
53052
53493
|
if (!el)
|
|
@@ -53054,23 +53495,77 @@ var AssistantChat = function (_a) {
|
|
|
53054
53495
|
var distance = el.scrollHeight - el.scrollTop - el.clientHeight;
|
|
53055
53496
|
atBottomRef.current = distance < BOTTOM_THRESHOLD_PX;
|
|
53056
53497
|
}, []);
|
|
53498
|
+
// Keep the newest content anchored at the bottom, pushing older content up
|
|
53499
|
+
var pinToBottom = React.useCallback(function () {
|
|
53500
|
+
var el = messagesContainerRef.current;
|
|
53501
|
+
if (!el || !atBottomRef.current)
|
|
53502
|
+
return;
|
|
53503
|
+
el.scrollTop = el.scrollHeight;
|
|
53504
|
+
}, []);
|
|
53057
53505
|
var colors = React.useMemo(function () { return getChatColors(color || DEFAULT_CHAT_COLOR); }, [color]);
|
|
53058
53506
|
var makeChat = function (threadId, initialMessages, initialTitle) {
|
|
53059
53507
|
if (initialMessages === void 0) { initialMessages = []; }
|
|
53060
53508
|
var resolvedThreadId = threadId;
|
|
53061
53509
|
var titleGenerated = !!initialTitle;
|
|
53510
|
+
// Title the thread from its first user message, whether typed or a voice transcript
|
|
53511
|
+
var triggerTitle = function (userText) {
|
|
53512
|
+
if (titleGenerated || !userText)
|
|
53513
|
+
return;
|
|
53514
|
+
titleGenerated = true;
|
|
53515
|
+
var currentThreadId = resolvedThreadId || null;
|
|
53516
|
+
var titleContext = {};
|
|
53517
|
+
var targets = getTargets();
|
|
53518
|
+
if (targets.length > 0)
|
|
53519
|
+
titleContext.targets = targets;
|
|
53520
|
+
if (instanceId) {
|
|
53521
|
+
var stepKey = getCurrentStepKey(instanceId);
|
|
53522
|
+
if (stepKey)
|
|
53523
|
+
titleContext.current_step = stepKey;
|
|
53524
|
+
}
|
|
53525
|
+
generateThreadTitle(baseUrl, headers, currentThreadId, userText, titleContext).then(function (title) {
|
|
53526
|
+
if (!title)
|
|
53527
|
+
return;
|
|
53528
|
+
setThreads(function (prev) {
|
|
53529
|
+
return prev.map(function (t) {
|
|
53530
|
+
return t.id === currentThreadId || t.chat === chat ? index$1.__assign(index$1.__assign({}, t), { title: title }) : t;
|
|
53531
|
+
});
|
|
53532
|
+
});
|
|
53533
|
+
});
|
|
53534
|
+
};
|
|
53062
53535
|
var chatTransport = new DefaultChatTransport({
|
|
53063
53536
|
api: baseUrl,
|
|
53064
53537
|
headers: headers,
|
|
53065
53538
|
body: function () { return (index$1.__assign(index$1.__assign({}, buildChatBody()), { thread_id: resolvedThreadId || null })); },
|
|
53066
53539
|
fetch: function (url, init) { return index$1.__awaiter(void 0, void 0, void 0, function () {
|
|
53067
|
-
var res,
|
|
53068
|
-
var _a, _b, _c;
|
|
53069
|
-
return index$1.__generator(this, function (
|
|
53070
|
-
switch (
|
|
53071
|
-
case 0:
|
|
53540
|
+
var res, form, audio, threadId;
|
|
53541
|
+
var _a, _b, _c, _d;
|
|
53542
|
+
return index$1.__generator(this, function (_e) {
|
|
53543
|
+
switch (_e.label) {
|
|
53544
|
+
case 0:
|
|
53545
|
+
if (!voiceActiveRef.current) return [3 /*break*/, 2];
|
|
53546
|
+
form = new FormData();
|
|
53547
|
+
form.append('payload', typeof (init === null || init === void 0 ? void 0 : init.body) === 'string'
|
|
53548
|
+
? init.body
|
|
53549
|
+
: JSON.stringify((_a = init === null || init === void 0 ? void 0 : init.body) !== null && _a !== void 0 ? _a : {}));
|
|
53550
|
+
audio = pendingAudioRef.current;
|
|
53551
|
+
if (audio) {
|
|
53552
|
+
form.append('audio', audio, 'speech.wav');
|
|
53553
|
+
pendingAudioRef.current = null;
|
|
53554
|
+
}
|
|
53555
|
+
return [4 /*yield*/, fetch("".concat(baseUrl, "voice/turn/"), {
|
|
53556
|
+
method: 'POST',
|
|
53557
|
+
headers: headers(),
|
|
53558
|
+
body: form,
|
|
53559
|
+
signal: init === null || init === void 0 ? void 0 : init.signal
|
|
53560
|
+
})];
|
|
53072
53561
|
case 1:
|
|
53073
|
-
res =
|
|
53562
|
+
res = _e.sent();
|
|
53563
|
+
return [3 /*break*/, 4];
|
|
53564
|
+
case 2: return [4 /*yield*/, fetch(url, init)];
|
|
53565
|
+
case 3:
|
|
53566
|
+
res = _e.sent();
|
|
53567
|
+
_e.label = 4;
|
|
53568
|
+
case 4:
|
|
53074
53569
|
threadId = res.headers.get('X-Thread-Id');
|
|
53075
53570
|
if (threadId && !resolvedThreadId) {
|
|
53076
53571
|
resolvedThreadId = threadId;
|
|
@@ -53090,38 +53585,7 @@ var AssistantChat = function (_a) {
|
|
|
53090
53585
|
});
|
|
53091
53586
|
});
|
|
53092
53587
|
}
|
|
53093
|
-
|
|
53094
|
-
titleMessage = (_c = (_b = (_a = chat.messages.find(function (m) { return m.role === 'user'; })) === null || _a === void 0 ? void 0 : _a.parts) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.text;
|
|
53095
|
-
if (titleMessage) {
|
|
53096
|
-
titleGenerated = true;
|
|
53097
|
-
currentThreadId_1 = resolvedThreadId || threadId || null;
|
|
53098
|
-
titleContext = {};
|
|
53099
|
-
targets = getTargets();
|
|
53100
|
-
if (targets.length > 0)
|
|
53101
|
-
titleContext.targets = targets;
|
|
53102
|
-
if (instanceId) {
|
|
53103
|
-
stepKey = getCurrentStepKey(instanceId);
|
|
53104
|
-
if (stepKey)
|
|
53105
|
-
titleContext.current_step = stepKey;
|
|
53106
|
-
}
|
|
53107
|
-
generateThreadTitle(baseUrl, headers, currentThreadId_1, titleMessage, titleContext).then(function (title) {
|
|
53108
|
-
if (!title)
|
|
53109
|
-
return;
|
|
53110
|
-
if (currentThreadId_1) {
|
|
53111
|
-
setThreads(function (prev) {
|
|
53112
|
-
return prev.map(function (t) {
|
|
53113
|
-
return t.id === currentThreadId_1 ? index$1.__assign(index$1.__assign({}, t), { title: title }) : t;
|
|
53114
|
-
});
|
|
53115
|
-
});
|
|
53116
|
-
}
|
|
53117
|
-
else {
|
|
53118
|
-
setThreads(function (prev) {
|
|
53119
|
-
return prev.map(function (t) { return (t.chat === chat ? index$1.__assign(index$1.__assign({}, t), { title: title }) : t); });
|
|
53120
|
-
});
|
|
53121
|
-
}
|
|
53122
|
-
});
|
|
53123
|
-
}
|
|
53124
|
-
}
|
|
53588
|
+
triggerTitle((_d = (_c = (_b = chat.messages.find(function (m) { return m.role === 'user'; })) === null || _b === void 0 ? void 0 : _b.parts) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.text);
|
|
53125
53589
|
return [2 /*return*/, res];
|
|
53126
53590
|
}
|
|
53127
53591
|
});
|
|
@@ -53131,6 +53595,12 @@ var AssistantChat = function (_a) {
|
|
|
53131
53595
|
transport: chatTransport,
|
|
53132
53596
|
messages: initialMessages,
|
|
53133
53597
|
sendAutomaticallyWhen: lastAssistantMessageIsCompleteWithToolCalls,
|
|
53598
|
+
onData: function (part) {
|
|
53599
|
+
var _a, _b;
|
|
53600
|
+
if ((part === null || part === void 0 ? void 0 : part.type) === 'data-transcript')
|
|
53601
|
+
triggerTitle((_a = part.data) === null || _a === void 0 ? void 0 : _a.text);
|
|
53602
|
+
(_b = voiceDataRef.current) === null || _b === void 0 ? void 0 : _b.call(voiceDataRef, part);
|
|
53603
|
+
},
|
|
53134
53604
|
onToolCall: function (_a) {
|
|
53135
53605
|
var toolCall = _a.toolCall;
|
|
53136
53606
|
return index$1.__awaiter(void 0, void 0, void 0, function () {
|
|
@@ -53250,9 +53720,9 @@ var AssistantChat = function (_a) {
|
|
|
53250
53720
|
var readyChat = React.useMemo(function () { return makeChat(null); }, [headers, getTargets, getJwt]);
|
|
53251
53721
|
var activeThread = threads.find(function (t) { return t.id === activeThreadId; });
|
|
53252
53722
|
var activeChat = (_d = activeThread === null || activeThread === void 0 ? void 0 : activeThread.chat) !== null && _d !== void 0 ? _d : readyChat;
|
|
53253
|
-
var
|
|
53723
|
+
var _u = useChat({
|
|
53254
53724
|
chat: activeChat
|
|
53255
|
-
}), rawMessages =
|
|
53725
|
+
}), rawMessages = _u.messages, sendMessage = _u.sendMessage, setMessages = _u.setMessages, status = _u.status, error = _u.error;
|
|
53256
53726
|
var messages = React.useMemo(function () {
|
|
53257
53727
|
var e_1, _a;
|
|
53258
53728
|
var _b, _c;
|
|
@@ -53281,25 +53751,14 @@ var AssistantChat = function (_a) {
|
|
|
53281
53751
|
return combined;
|
|
53282
53752
|
}, [rawMessages]);
|
|
53283
53753
|
React.useEffect(function () {
|
|
53284
|
-
|
|
53285
|
-
|
|
53286
|
-
return;
|
|
53287
|
-
(_a = messagesEndRef.current) === null || _a === void 0 ? void 0 : _a.scrollIntoView({ behavior: 'smooth' });
|
|
53288
|
-
}, [messages]);
|
|
53754
|
+
pinToBottom();
|
|
53755
|
+
}, [messages, pinToBottom]);
|
|
53289
53756
|
React.useEffect(function () {
|
|
53290
53757
|
if (status !== 'ready')
|
|
53291
53758
|
return;
|
|
53292
|
-
|
|
53293
|
-
return;
|
|
53294
|
-
var id = index$1.featheryWindow().requestAnimationFrame(function () {
|
|
53295
|
-
var _a;
|
|
53296
|
-
(_a = messagesEndRef.current) === null || _a === void 0 ? void 0 : _a.scrollIntoView({
|
|
53297
|
-
behavior: 'smooth',
|
|
53298
|
-
block: 'end'
|
|
53299
|
-
});
|
|
53300
|
-
});
|
|
53759
|
+
var id = index$1.featheryWindow().requestAnimationFrame(pinToBottom);
|
|
53301
53760
|
return function () { return index$1.featheryWindow().cancelAnimationFrame(id); };
|
|
53302
|
-
}, [status]);
|
|
53761
|
+
}, [status, pinToBottom]);
|
|
53303
53762
|
var fetchThreads = React.useCallback(function () { return index$1.__awaiter(void 0, void 0, void 0, function () {
|
|
53304
53763
|
var data;
|
|
53305
53764
|
return index$1.__generator(this, function (_a) {
|
|
@@ -53322,6 +53781,7 @@ var AssistantChat = function (_a) {
|
|
|
53322
53781
|
fetchThreads();
|
|
53323
53782
|
}, [isOpen, fetchThreads]);
|
|
53324
53783
|
var handleNewThread = function () {
|
|
53784
|
+
stopVoice();
|
|
53325
53785
|
atBottomRef.current = true;
|
|
53326
53786
|
var id = index$1.v4();
|
|
53327
53787
|
var now = new Date().toISOString();
|
|
@@ -53344,6 +53804,7 @@ var AssistantChat = function (_a) {
|
|
|
53344
53804
|
return index$1.__generator(this, function (_c) {
|
|
53345
53805
|
switch (_c.label) {
|
|
53346
53806
|
case 0:
|
|
53807
|
+
stopVoice();
|
|
53347
53808
|
atBottomRef.current = true;
|
|
53348
53809
|
if ((_a = threads.find(function (t) { return t.id === id; })) === null || _a === void 0 ? void 0 : _a.chat) {
|
|
53349
53810
|
setActiveThreadId(id);
|
|
@@ -53385,45 +53846,15 @@ var AssistantChat = function (_a) {
|
|
|
53385
53846
|
}
|
|
53386
53847
|
});
|
|
53387
53848
|
}); };
|
|
53388
|
-
|
|
53389
|
-
|
|
53390
|
-
|
|
53391
|
-
var now_1 = new Date().toISOString();
|
|
53392
|
-
if (!activeThreadId) {
|
|
53393
|
-
// First send, register readyChat as a real thread entry
|
|
53394
|
-
var id_1 = index$1.v4();
|
|
53395
|
-
setThreads(function (prev) { return index$1.__spreadArray([
|
|
53396
|
-
{
|
|
53397
|
-
id: id_1,
|
|
53398
|
-
title: 'New Chat',
|
|
53399
|
-
created_at: now_1,
|
|
53400
|
-
updated_at: now_1,
|
|
53401
|
-
isTemporary: true,
|
|
53402
|
-
chat: activeChat
|
|
53403
|
-
}
|
|
53404
|
-
], index$1.__read(prev), false); });
|
|
53405
|
-
setActiveThreadId(id_1);
|
|
53406
|
-
}
|
|
53407
|
-
else {
|
|
53408
|
-
if (activeThread && !activeThread.title) {
|
|
53409
|
-
setThreads(function (prev) { return index$1.__spreadArray([
|
|
53410
|
-
index$1.__assign(index$1.__assign({}, activeThread), { title: 'New Chat', updated_at: now_1 })
|
|
53411
|
-
], index$1.__read(prev.filter(function (t) { return t.id !== activeThreadId; })), false); });
|
|
53412
|
-
}
|
|
53413
|
-
}
|
|
53414
|
-
sendMessage({ text: input });
|
|
53415
|
-
setInput('');
|
|
53416
|
-
}
|
|
53417
|
-
};
|
|
53418
|
-
var handleWorkflowAction = function (action) {
|
|
53419
|
-
if (status !== 'ready')
|
|
53420
|
-
return;
|
|
53849
|
+
// First send of a thread registers it as a real entry, for both text and voice
|
|
53850
|
+
var registerActiveThread = React.useCallback(function () {
|
|
53851
|
+
atBottomRef.current = true;
|
|
53421
53852
|
var now = new Date().toISOString();
|
|
53422
53853
|
if (!activeThreadId) {
|
|
53423
|
-
var
|
|
53854
|
+
var id_1 = index$1.v4();
|
|
53424
53855
|
setThreads(function (prev) { return index$1.__spreadArray([
|
|
53425
53856
|
{
|
|
53426
|
-
id:
|
|
53857
|
+
id: id_1,
|
|
53427
53858
|
title: 'New Chat',
|
|
53428
53859
|
created_at: now,
|
|
53429
53860
|
updated_at: now,
|
|
@@ -53431,13 +53862,38 @@ var AssistantChat = function (_a) {
|
|
|
53431
53862
|
chat: activeChat
|
|
53432
53863
|
}
|
|
53433
53864
|
], index$1.__read(prev), false); });
|
|
53434
|
-
setActiveThreadId(
|
|
53865
|
+
setActiveThreadId(id_1);
|
|
53435
53866
|
}
|
|
53436
53867
|
else if (activeThread && !activeThread.title) {
|
|
53437
53868
|
setThreads(function (prev) { return index$1.__spreadArray([
|
|
53438
53869
|
index$1.__assign(index$1.__assign({}, activeThread), { title: 'New Chat', updated_at: now })
|
|
53439
53870
|
], index$1.__read(prev.filter(function (t) { return t.id !== activeThreadId; })), false); });
|
|
53440
53871
|
}
|
|
53872
|
+
}, [activeThreadId, activeThread, activeChat]);
|
|
53873
|
+
var _v = useAssistantVoice({
|
|
53874
|
+
status: status,
|
|
53875
|
+
sendMessage: function (message) { return sendMessage(message); },
|
|
53876
|
+
setMessages: setMessages,
|
|
53877
|
+
ensureThread: registerActiveThread,
|
|
53878
|
+
voiceActiveRef: voiceActiveRef,
|
|
53879
|
+
pendingAudioRef: pendingAudioRef,
|
|
53880
|
+
voiceDataRef: voiceDataRef
|
|
53881
|
+
}), voiceState = _v.voiceState, voiceActive = _v.voiceActive, micAvailable = _v.micAvailable, spokenChars = _v.spokenChars, audioDraining = _v.audioDraining, startVoice = _v.startVoice, stopVoice = _v.stopVoice, skipSpeaking = _v.skipSpeaking;
|
|
53882
|
+
// Voice: keep the view pinned to the bottom as the reply reveals during playback
|
|
53883
|
+
React.useEffect(function () {
|
|
53884
|
+
pinToBottom();
|
|
53885
|
+
}, [spokenChars, audioDraining, pinToBottom]);
|
|
53886
|
+
var handleSend = function () {
|
|
53887
|
+
if (input.trim() && status === 'ready') {
|
|
53888
|
+
registerActiveThread();
|
|
53889
|
+
sendMessage({ text: input });
|
|
53890
|
+
setInput('');
|
|
53891
|
+
}
|
|
53892
|
+
};
|
|
53893
|
+
var handleWorkflowAction = function (action) {
|
|
53894
|
+
if (status !== 'ready')
|
|
53895
|
+
return;
|
|
53896
|
+
registerActiveThread();
|
|
53441
53897
|
sendMessage({
|
|
53442
53898
|
parts: [
|
|
53443
53899
|
{ type: 'text', text: action.name },
|
|
@@ -53460,6 +53916,20 @@ var AssistantChat = function (_a) {
|
|
|
53460
53916
|
// Only show threads that have had at least one message sent
|
|
53461
53917
|
var visibleThreads = threads.filter(function (t) { return t.title; });
|
|
53462
53918
|
var isLoading = status === 'submitted' || status === 'streaming';
|
|
53919
|
+
var composerButtonCss = {
|
|
53920
|
+
padding: '10px',
|
|
53921
|
+
backgroundColor: colors.primary,
|
|
53922
|
+
color: 'white',
|
|
53923
|
+
border: 'none',
|
|
53924
|
+
borderRadius: '8px',
|
|
53925
|
+
cursor: 'pointer',
|
|
53926
|
+
display: 'flex',
|
|
53927
|
+
alignItems: 'center',
|
|
53928
|
+
justifyContent: 'center',
|
|
53929
|
+
transition: 'background-color 0.2s',
|
|
53930
|
+
':hover:not(:disabled)': { backgroundColor: colors.hover },
|
|
53931
|
+
':disabled': { backgroundColor: colors.disabled, cursor: 'not-allowed' }
|
|
53932
|
+
};
|
|
53463
53933
|
var layoutSide = mode === 'sidebar-left'
|
|
53464
53934
|
? 'left'
|
|
53465
53935
|
: mode === 'sidebar-right'
|
|
@@ -53611,7 +54081,10 @@ var AssistantChat = function (_a) {
|
|
|
53611
54081
|
justifyContent: 'center',
|
|
53612
54082
|
borderRadius: '4px',
|
|
53613
54083
|
':hover': { backgroundColor: 'rgba(255, 255, 255, 0.1)' }
|
|
53614
|
-
} }, { children: index$1.jsx(ModeTriggerIcon, {}) })), index$1.jsx("button", index$1.__assign({ type: 'button', onClick: function () {
|
|
54084
|
+
} }, { children: index$1.jsx(ModeTriggerIcon, {}) })), index$1.jsx("button", index$1.__assign({ type: 'button', onClick: function () {
|
|
54085
|
+
stopVoice();
|
|
54086
|
+
setIsOpen(false);
|
|
54087
|
+
}, css: {
|
|
53615
54088
|
background: 'none',
|
|
53616
54089
|
border: 'none',
|
|
53617
54090
|
color: 'white',
|
|
@@ -53759,9 +54232,10 @@ var AssistantChat = function (_a) {
|
|
|
53759
54232
|
fontSize: '14px',
|
|
53760
54233
|
marginTop: '40px'
|
|
53761
54234
|
} }, { children: "How can I help?" }))), messages.map(function (message, mIdx) {
|
|
54235
|
+
var _a;
|
|
53762
54236
|
return message.role === 'user' ? (
|
|
53763
|
-
//
|
|
53764
|
-
index$1.jsx("div", index$1.__assign({ css: {
|
|
54237
|
+
// Show the bubble only once its transcript lands, not as an empty placeholder
|
|
54238
|
+
((_a = message.parts) !== null && _a !== void 0 ? _a : []).some(function (p) { var _a; return p.type === 'text' && ((_a = p.text) !== null && _a !== void 0 ? _a : '').trim(); }) ? (index$1.jsx("div", index$1.__assign({ css: {
|
|
53765
54239
|
display: 'flex',
|
|
53766
54240
|
justifyContent: 'flex-end'
|
|
53767
54241
|
} }, { children: index$1.jsx("div", index$1.__assign({ css: {
|
|
@@ -53778,14 +54252,34 @@ var AssistantChat = function (_a) {
|
|
|
53778
54252
|
.filter(function (part) { return !part.hidden; })
|
|
53779
54253
|
.map(function (part, index) {
|
|
53780
54254
|
return part.type === 'text' ? (index$1.jsx("span", { children: part.text }, index)) : null;
|
|
53781
|
-
}) })) }), message.id)) : (index$1.jsx(React.Fragment, { children: (function () {
|
|
54255
|
+
}) })) }), message.id)) : null) : (index$1.jsx(React.Fragment, { children: (function () {
|
|
53782
54256
|
var isLastMsg = mIdx === messages.length - 1;
|
|
53783
54257
|
var chunks = mergeAssistantParts(message.parts);
|
|
53784
54258
|
var lastPart = message.parts[message.parts.length - 1];
|
|
53785
54259
|
var turnFinished = !isLastMsg ||
|
|
53786
54260
|
(status === 'ready' && (lastPart === null || lastPart === void 0 ? void 0 : lastPart.type) === 'text');
|
|
54261
|
+
// Voice: reveal parts top-to-bottom, paced by how much audio has played
|
|
54262
|
+
var paceByAudio = voiceActiveRef.current &&
|
|
54263
|
+
isLastMsg &&
|
|
54264
|
+
(isLoading || audioDraining);
|
|
54265
|
+
var revealable = paceByAudio ? spokenChars : Infinity;
|
|
54266
|
+
var blocked = false;
|
|
53787
54267
|
return chunks.map(function (chunk, chunkIdx) {
|
|
54268
|
+
if (blocked)
|
|
54269
|
+
return null;
|
|
53788
54270
|
if (chunk.kind === 'text') {
|
|
54271
|
+
// Reveal up to the spoken budget, whitespace is free so the trailing "?" isn't held back
|
|
54272
|
+
var revealLen = 0;
|
|
54273
|
+
while (revealLen < chunk.text.length &&
|
|
54274
|
+
(revealable > 0 || /\s/.test(chunk.text[revealLen]))) {
|
|
54275
|
+
if (!/\s/.test(chunk.text[revealLen]))
|
|
54276
|
+
revealable -= 1;
|
|
54277
|
+
revealLen += 1;
|
|
54278
|
+
}
|
|
54279
|
+
if (revealLen < chunk.text.length)
|
|
54280
|
+
blocked = true;
|
|
54281
|
+
if (revealLen <= 0)
|
|
54282
|
+
return null;
|
|
53789
54283
|
return (index$1.jsx("div", index$1.__assign({ css: {
|
|
53790
54284
|
display: 'flex',
|
|
53791
54285
|
justifyContent: 'flex-start'
|
|
@@ -53799,37 +54293,50 @@ var AssistantChat = function (_a) {
|
|
|
53799
54293
|
color: GRAY_800,
|
|
53800
54294
|
overflowWrap: 'anywhere',
|
|
53801
54295
|
wordBreak: 'break-word'
|
|
53802
|
-
} }, { children: index$1.jsx(MarkdownText, { text: chunk.text, isStreaming: isLoading &&
|
|
54296
|
+
} }, { children: index$1.jsx(MarkdownText, { text: chunk.text.slice(0, revealLen), isStreaming: isLoading &&
|
|
53803
54297
|
isLastMsg &&
|
|
53804
54298
|
chunkIdx === chunks.length - 1 }) })) }), chunk.key));
|
|
53805
54299
|
}
|
|
53806
54300
|
var followedByText = chunks
|
|
53807
54301
|
.slice(chunkIdx + 1)
|
|
53808
54302
|
.some(function (c) { return c.kind === 'text'; });
|
|
54303
|
+
// Hold the tool's working state until the followup reply's audio begins
|
|
54304
|
+
var audioPending = paceByAudio && followedByText && revealable <= 0;
|
|
53809
54305
|
return (index$1.jsx("div", index$1.__assign({ css: {
|
|
53810
54306
|
display: 'flex',
|
|
53811
54307
|
justifyContent: 'flex-start',
|
|
53812
54308
|
maxWidth: '80%',
|
|
53813
54309
|
minWidth: 0
|
|
53814
|
-
} }, { children: index$1.jsx(ToolChunk, { rows: chunk.rows, turnFinished: turnFinished, followedByText: followedByText, linkColor: colors.primary, isFirstChunk: chunkIdx === 0 }) }), chunk.key));
|
|
54310
|
+
} }, { children: index$1.jsx(ToolChunk, { rows: chunk.rows, turnFinished: turnFinished, followedByText: followedByText, audioPending: audioPending, linkColor: colors.primary, isFirstChunk: chunkIdx === 0 }) }), chunk.key));
|
|
53815
54311
|
});
|
|
53816
54312
|
})() }, message.id));
|
|
53817
54313
|
}), (function () {
|
|
54314
|
+
var _a;
|
|
53818
54315
|
if (!isLoading)
|
|
53819
54316
|
return null;
|
|
53820
54317
|
var last = messages[messages.length - 1];
|
|
53821
54318
|
if (!last)
|
|
53822
54319
|
return null;
|
|
53823
|
-
|
|
53824
|
-
|
|
53825
|
-
var
|
|
53826
|
-
|
|
53827
|
-
|
|
53828
|
-
|
|
53829
|
-
|
|
53830
|
-
|
|
53831
|
-
|
|
53832
|
-
|
|
54320
|
+
var parts = last.parts || [];
|
|
54321
|
+
var isContent = function (p) {
|
|
54322
|
+
var _a;
|
|
54323
|
+
if ((p === null || p === void 0 ? void 0 : p.type) === 'text')
|
|
54324
|
+
return ((_a = p.text) !== null && _a !== void 0 ? _a : '').trim().length > 0;
|
|
54325
|
+
var t = typeof (p === null || p === void 0 ? void 0 : p.type) === 'string' ? p.type : '';
|
|
54326
|
+
return t.startsWith('tool-') || t === 'dynamic-tool';
|
|
54327
|
+
};
|
|
54328
|
+
var hasContent = parts.some(isContent);
|
|
54329
|
+
if (last.role === 'user') {
|
|
54330
|
+
// Wait for the user's (transcribed) message to be visible before showing the indicator
|
|
54331
|
+
if (!hasContent)
|
|
54332
|
+
return null;
|
|
54333
|
+
}
|
|
54334
|
+
else {
|
|
54335
|
+
// Voice: keep the indicator up while a leading reply is held waiting for its audio
|
|
54336
|
+
var held = voiceActiveRef.current &&
|
|
54337
|
+
spokenChars <= 0 &&
|
|
54338
|
+
((_a = parts.find(isContent)) === null || _a === void 0 ? void 0 : _a.type) === 'text';
|
|
54339
|
+
if (hasContent && !held)
|
|
53833
54340
|
return null;
|
|
53834
54341
|
}
|
|
53835
54342
|
return index$1.jsx(ToolChunkPlaceholder, {});
|
|
@@ -53839,7 +54346,7 @@ var AssistantChat = function (_a) {
|
|
|
53839
54346
|
backgroundColor: '#fef2f2',
|
|
53840
54347
|
color: '#dc2626',
|
|
53841
54348
|
fontSize: '14px'
|
|
53842
|
-
} }, { children: "Something went wrong. Please try again." })))
|
|
54349
|
+
} }, { children: "Something went wrong. Please try again." })))] })), workflowActions.length > 0 && (index$1.jsxs("div", index$1.__assign({ css: {
|
|
53843
54350
|
position: 'relative',
|
|
53844
54351
|
zIndex: 1,
|
|
53845
54352
|
borderTop: "1px solid ".concat(GRAY_200),
|
|
@@ -53890,7 +54397,27 @@ var AssistantChat = function (_a) {
|
|
|
53890
54397
|
padding: '12px 16px',
|
|
53891
54398
|
borderTop: "1px solid ".concat(GRAY_200),
|
|
53892
54399
|
backgroundColor: GRAY_50
|
|
53893
|
-
} }, { children: [index$1.
|
|
54400
|
+
} }, { children: [voiceActive ? (index$1.jsxs("button", index$1.__assign({ type: 'button', onClick: voiceState === 'speaking' ? skipSpeaking : undefined, css: {
|
|
54401
|
+
flex: 1,
|
|
54402
|
+
display: 'flex',
|
|
54403
|
+
alignItems: 'center',
|
|
54404
|
+
gap: '8px',
|
|
54405
|
+
padding: '10px 14px',
|
|
54406
|
+
border: "1px solid ".concat(GRAY_200),
|
|
54407
|
+
borderRadius: '8px',
|
|
54408
|
+
backgroundColor: 'white',
|
|
54409
|
+
fontSize: '14px',
|
|
54410
|
+
color: GRAY_800,
|
|
54411
|
+
cursor: voiceState === 'speaking' ? 'pointer' : 'default'
|
|
54412
|
+
} }, { children: [index$1.jsx(WaveformIcon, { css: { color: colors.primary } }), voiceState === 'loading'
|
|
54413
|
+
? 'Loading…'
|
|
54414
|
+
: voiceState === 'transcribing'
|
|
54415
|
+
? 'Transcribing…'
|
|
54416
|
+
: voiceState === 'thinking'
|
|
54417
|
+
? 'Thinking…'
|
|
54418
|
+
: voiceState === 'speaking'
|
|
54419
|
+
? 'Tap to skip'
|
|
54420
|
+
: 'Listening…'] }))) : (index$1.jsx("input", { type: 'text', value: input, onChange: function (e) { return setInput(e.target.value); }, onKeyDown: handleKeyDown, placeholder: 'Type a message...', css: {
|
|
53894
54421
|
flex: 1,
|
|
53895
54422
|
padding: '10px 14px',
|
|
53896
54423
|
border: "1px solid ".concat(GRAY_200),
|
|
@@ -53901,25 +54428,7 @@ var AssistantChat = function (_a) {
|
|
|
53901
54428
|
':focus': {
|
|
53902
54429
|
borderColor: colors.primary
|
|
53903
54430
|
}
|
|
53904
|
-
} }), index$1.jsx("button", index$1.__assign({ type: 'button', onClick: handleSend, disabled: isLoading || !input.trim(), css: {
|
|
53905
|
-
padding: '10px',
|
|
53906
|
-
backgroundColor: colors.primary,
|
|
53907
|
-
color: 'white',
|
|
53908
|
-
border: 'none',
|
|
53909
|
-
borderRadius: '8px',
|
|
53910
|
-
cursor: 'pointer',
|
|
53911
|
-
display: 'flex',
|
|
53912
|
-
alignItems: 'center',
|
|
53913
|
-
justifyContent: 'center',
|
|
53914
|
-
transition: 'background-color 0.2s',
|
|
53915
|
-
':hover:not(:disabled)': {
|
|
53916
|
-
backgroundColor: colors.hover
|
|
53917
|
-
},
|
|
53918
|
-
':disabled': {
|
|
53919
|
-
backgroundColor: colors.disabled,
|
|
53920
|
-
cursor: 'not-allowed'
|
|
53921
|
-
}
|
|
53922
|
-
} }, { children: index$1.jsx(SendIcon, {}) }))] }))] })));
|
|
54431
|
+
} })), voiceActive ? (index$1.jsx("button", index$1.__assign({ type: 'button', onClick: stopVoice, "aria-label": 'Exit voice mode', css: composerButtonCss }, { children: index$1.jsx(CloseIcon, {}) }))) : !voiceEnabled || input.trim() ? (index$1.jsx("button", index$1.__assign({ type: 'button', onClick: handleSend, disabled: isLoading || !input.trim(), css: composerButtonCss }, { children: index$1.jsx(SendIcon, {}) }))) : (index$1.jsx("button", index$1.__assign({ type: 'button', onClick: startVoice, disabled: isLoading || !micAvailable, "aria-label": 'Start voice mode', title: micAvailable ? undefined : 'Microphone unavailable', css: composerButtonCss }, { children: index$1.jsx(MicIcon, {}) })))] }))] })));
|
|
53923
54432
|
};
|
|
53924
54433
|
|
|
53925
54434
|
var AssistantChat$1 = /*#__PURE__*/Object.freeze({
|