@burtson-labs/bandit-engine 2.0.167 → 2.1.0

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.
Files changed (237) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/LICENSE +189 -31
  3. package/NOTICE +26 -0
  4. package/README.md +15 -59
  5. package/dist/aiProviderStore-DKQCCDWF.mjs +8 -0
  6. package/dist/aiProviderStore-DKQCCDWF.mjs.map +1 -0
  7. package/dist/chat-VYZFUECC.mjs +10 -0
  8. package/dist/chat-VYZFUECC.mjs.map +1 -0
  9. package/dist/{chunk-GRPTCHFN.mjs → chunk-BJT6KPUG.mjs} +309 -154
  10. package/dist/chunk-BJT6KPUG.mjs.map +1 -0
  11. package/dist/{chunk-SZJB5FLZ.mjs → chunk-FCQN3LKT.mjs} +251 -77
  12. package/dist/chunk-FCQN3LKT.mjs.map +1 -0
  13. package/dist/chunk-HD4PJNPH.mjs +29034 -0
  14. package/dist/chunk-HD4PJNPH.mjs.map +1 -0
  15. package/dist/{chunk-HNXPDIWC.mjs → chunk-NI7BKLC7.mjs} +1 -1
  16. package/dist/chunk-NI7BKLC7.mjs.map +1 -0
  17. package/dist/index.d.mts +115 -57
  18. package/dist/index.d.ts +115 -57
  19. package/dist/index.js +15660 -7577
  20. package/dist/index.js.map +1 -1
  21. package/dist/index.mjs +16630 -142
  22. package/dist/index.mjs.map +1 -1
  23. package/dist/{memoryUtils-HGCYEUCD.mjs → memoryUtils-UBZ33DNA.mjs} +8 -3
  24. package/dist/memoryUtils-UBZ33DNA.mjs.map +1 -0
  25. package/dist/modelStore-SEC34WRM.mjs +8 -0
  26. package/dist/modelStore-SEC34WRM.mjs.map +1 -0
  27. package/dist/{public-DJa4Db00.d.mts → public-CKQQDOoy.d.mts} +8 -8
  28. package/dist/{public-DJa4Db00.d.ts → public-CKQQDOoy.d.ts} +8 -8
  29. package/dist/public-types.d.mts +1 -1
  30. package/dist/public-types.d.ts +1 -1
  31. package/docs/00_intro.md +2 -2
  32. package/docs/05_contributing.md +2 -2
  33. package/docs/06_licensing.md +18 -0
  34. package/docs/07_custom_tools.md +233 -0
  35. package/docs/README.md +2 -1
  36. package/package.json +23 -20
  37. package/dist/aiProviderStore-HY5G4QAK.mjs +0 -8
  38. package/dist/aiProviderStore-HY5G4QAK.mjs.map +0 -1
  39. package/dist/chat-6N5B7A7F.mjs +0 -15
  40. package/dist/chat-6N5B7A7F.mjs.map +0 -1
  41. package/dist/chat-provider.js +0 -10964
  42. package/dist/chat-provider.js.map +0 -1
  43. package/dist/chat-provider.mjs +0 -16
  44. package/dist/chat-provider.mjs.map +0 -1
  45. package/dist/chunk-46OGYEME.mjs +0 -5895
  46. package/dist/chunk-46OGYEME.mjs.map +0 -1
  47. package/dist/chunk-5BZWJQ5O.mjs +0 -516
  48. package/dist/chunk-5BZWJQ5O.mjs.map +0 -1
  49. package/dist/chunk-CABOLDNR.mjs +0 -216
  50. package/dist/chunk-CABOLDNR.mjs.map +0 -1
  51. package/dist/chunk-E5WMDLE3.mjs +0 -390
  52. package/dist/chunk-E5WMDLE3.mjs.map +0 -1
  53. package/dist/chunk-GRPTCHFN.mjs.map +0 -1
  54. package/dist/chunk-HNXPDIWC.mjs.map +0 -1
  55. package/dist/chunk-KDIL5WUL.mjs +0 -7323
  56. package/dist/chunk-KDIL5WUL.mjs.map +0 -1
  57. package/dist/chunk-N4BQ6HKL.mjs +0 -2945
  58. package/dist/chunk-N4BQ6HKL.mjs.map +0 -1
  59. package/dist/chunk-ONQMRE2G.mjs +0 -26
  60. package/dist/chunk-ONQMRE2G.mjs.map +0 -1
  61. package/dist/chunk-P4C5IRM5.mjs +0 -39
  62. package/dist/chunk-P4C5IRM5.mjs.map +0 -1
  63. package/dist/chunk-PK3LFBGC.mjs +0 -10575
  64. package/dist/chunk-PK3LFBGC.mjs.map +0 -1
  65. package/dist/chunk-SHYNXDRO.mjs +0 -11906
  66. package/dist/chunk-SHYNXDRO.mjs.map +0 -1
  67. package/dist/chunk-SZJB5FLZ.mjs.map +0 -1
  68. package/dist/chunk-US4TG745.mjs +0 -194
  69. package/dist/chunk-US4TG745.mjs.map +0 -1
  70. package/dist/management/management.js +0 -44217
  71. package/dist/management/management.js.map +0 -1
  72. package/dist/management/management.mjs +0 -16
  73. package/dist/management/management.mjs.map +0 -1
  74. package/dist/memoryUtils-HGCYEUCD.mjs.map +0 -1
  75. package/dist/modals/chat-modal/chat-modal.js +0 -19613
  76. package/dist/modals/chat-modal/chat-modal.js.map +0 -1
  77. package/dist/modals/chat-modal/chat-modal.mjs +0 -18
  78. package/dist/modals/chat-modal/chat-modal.mjs.map +0 -1
  79. package/dist/modelStore-TFNX4GEC.mjs +0 -8
  80. package/dist/modelStore-TFNX4GEC.mjs.map +0 -1
  81. package/dist/shared/custom-element.js +0 -73
  82. package/dist/shared/custom-element.js.map +0 -1
  83. package/dist/shared/custom-element.mjs +0 -7
  84. package/dist/shared/custom-element.mjs.map +0 -1
  85. package/docs/06_busl_licensing.md +0 -25
  86. package/docs/api_reference/.nojekyll +0 -1
  87. package/docs/api_reference/assets/bandit-docs.js +0 -462
  88. package/docs/api_reference/assets/highlight.css +0 -141
  89. package/docs/api_reference/assets/icons.js +0 -18
  90. package/docs/api_reference/assets/icons.svg +0 -1
  91. package/docs/api_reference/assets/main.js +0 -61
  92. package/docs/api_reference/assets/navigation.js +0 -1
  93. package/docs/api_reference/assets/search.js +0 -1
  94. package/docs/api_reference/assets/style.css +0 -1664
  95. package/docs/api_reference/classes/DebugLogger.html +0 -29
  96. package/docs/api_reference/classes/FeatureFlagService.html +0 -28
  97. package/docs/api_reference/classes/NotificationService.html +0 -21
  98. package/docs/api_reference/classes/StreamingTTSClient.html +0 -19
  99. package/docs/api_reference/classes/VectorDatabaseService.html +0 -63
  100. package/docs/api_reference/classes/VectorMigrationService.html +0 -27
  101. package/docs/api_reference/classes/VoiceService.html +0 -4
  102. package/docs/api_reference/enums/TTSState.html +0 -6
  103. package/docs/api_reference/functions/Chat.html +0 -1
  104. package/docs/api_reference/functions/ChatModal.html +0 -29
  105. package/docs/api_reference/functions/ChatProvider.html +0 -29
  106. package/docs/api_reference/functions/FeatureFlagProvider.html +0 -30
  107. package/docs/api_reference/functions/FeedbackButton.html +0 -29
  108. package/docs/api_reference/functions/FeedbackModal.html +0 -29
  109. package/docs/api_reference/functions/InterestsEditor.html +0 -5
  110. package/docs/api_reference/functions/Management.html +0 -1
  111. package/docs/api_reference/functions/NotificationProvider.html +0 -29
  112. package/docs/api_reference/functions/SubscriptionExpiredGuard.html +0 -31
  113. package/docs/api_reference/functions/SubscriptionExpiredModal.html +0 -31
  114. package/docs/api_reference/functions/defineCustomElement.html +0 -1
  115. package/docs/api_reference/functions/getCriticalConfig.html +0 -2
  116. package/docs/api_reference/functions/getFeatureMatrix.html +0 -1
  117. package/docs/api_reference/functions/getStreamingTTSClient.html +0 -1
  118. package/docs/api_reference/functions/getSystemConstants.html +0 -2
  119. package/docs/api_reference/functions/getTTSState.html +0 -1
  120. package/docs/api_reference/functions/handleHttpError.html +0 -2
  121. package/docs/api_reference/functions/handleSubscriptionUpgrade.html +0 -1
  122. package/docs/api_reference/functions/handleValidationError.html +0 -2
  123. package/docs/api_reference/functions/initializeCoreSystem.html +0 -2
  124. package/docs/api_reference/functions/isWorkspaceAdminRole.html +0 -6
  125. package/docs/api_reference/functions/pauseTTS.html +0 -1
  126. package/docs/api_reference/functions/previewTierUpgrade.html +0 -1
  127. package/docs/api_reference/functions/resolveManagementSections.html +0 -2
  128. package/docs/api_reference/functions/resumeTTS.html +0 -1
  129. package/docs/api_reference/functions/showInfoNotification.html +0 -2
  130. package/docs/api_reference/functions/showSuccessNotification.html +0 -2
  131. package/docs/api_reference/functions/speakWithStreaming.html +0 -1
  132. package/docs/api_reference/functions/stopTTS.html +0 -1
  133. package/docs/api_reference/functions/syncSubscriptionWithAPI.html +0 -1
  134. package/docs/api_reference/functions/updateSubscriptionTier.html +0 -2
  135. package/docs/api_reference/functions/useFeatureFlag.html +0 -2
  136. package/docs/api_reference/functions/useFeatureVisibility.html +0 -2
  137. package/docs/api_reference/functions/useFeatures.html +0 -2
  138. package/docs/api_reference/functions/useGatewayHealth.html +0 -1
  139. package/docs/api_reference/functions/useGatewayMemory.html +0 -1
  140. package/docs/api_reference/functions/useGatewayModels.html +0 -1
  141. package/docs/api_reference/functions/useGlobalTTS.html +0 -2
  142. package/docs/api_reference/functions/useManagementAccess.html +0 -2
  143. package/docs/api_reference/functions/useNotification.html +0 -1
  144. package/docs/api_reference/functions/useNotificationService.html +0 -6
  145. package/docs/api_reference/functions/useTTS.html +0 -2
  146. package/docs/api_reference/functions/useVectorStore.html +0 -13
  147. package/docs/api_reference/functions/useVoiceStore.html +0 -8
  148. package/docs/api_reference/functions/useVoices.html +0 -3
  149. package/docs/api_reference/functions/validateEnvironment.html +0 -2
  150. package/docs/api_reference/functions/validateSystemIntegrity.html +0 -2
  151. package/docs/api_reference/index.html +0 -916
  152. package/docs/api_reference/interfaces/AIChatRequest.html +0 -8
  153. package/docs/api_reference/interfaces/AIChatResponse.html +0 -3
  154. package/docs/api_reference/interfaces/AIGenerateRequest.html +0 -5
  155. package/docs/api_reference/interfaces/AIGenerateResponse.html +0 -3
  156. package/docs/api_reference/interfaces/AIMessage.html +0 -4
  157. package/docs/api_reference/interfaces/AIModel.html +0 -6
  158. package/docs/api_reference/interfaces/AIProviderConfig.html +0 -12
  159. package/docs/api_reference/interfaces/ChatConfig.html +0 -5
  160. package/docs/api_reference/interfaces/ChatModalProps.html +0 -7
  161. package/docs/api_reference/interfaces/CreateMemoryOptions.html +0 -7
  162. package/docs/api_reference/interfaces/FeatureEvaluation.html +0 -14
  163. package/docs/api_reference/interfaces/FeatureFlagConfig.html +0 -18
  164. package/docs/api_reference/interfaces/FeatureFlagContextValue.html +0 -16
  165. package/docs/api_reference/interfaces/FeatureFlagProviderProps.html +0 -4
  166. package/docs/api_reference/interfaces/FeedbackButtonProps.html +0 -19
  167. package/docs/api_reference/interfaces/FeedbackCategories.html +0 -6
  168. package/docs/api_reference/interfaces/FeedbackModalProps.html +0 -4
  169. package/docs/api_reference/interfaces/FeedbackPriorities.html +0 -5
  170. package/docs/api_reference/interfaces/FeedbackRequest.html +0 -12
  171. package/docs/api_reference/interfaces/FeedbackResponse.html +0 -7
  172. package/docs/api_reference/interfaces/FileUploadResult.html +0 -4
  173. package/docs/api_reference/interfaces/GatewayChatRequest.html +0 -13
  174. package/docs/api_reference/interfaces/GatewayChatResponse.html +0 -7
  175. package/docs/api_reference/interfaces/GatewayContract.html +0 -4
  176. package/docs/api_reference/interfaces/GatewayGenerateRequest.html +0 -8
  177. package/docs/api_reference/interfaces/GatewayGenerateResponse.html +0 -12
  178. package/docs/api_reference/interfaces/GatewayHealthResponse.html +0 -5
  179. package/docs/api_reference/interfaces/GatewayMemoryRecord.html +0 -7
  180. package/docs/api_reference/interfaces/GatewayMemoryResponse.html +0 -4
  181. package/docs/api_reference/interfaces/GatewayMessage.html +0 -5
  182. package/docs/api_reference/interfaces/GatewayMessageContent.html +0 -4
  183. package/docs/api_reference/interfaces/GatewayModel.html +0 -9
  184. package/docs/api_reference/interfaces/GatewayModelsResponse.html +0 -2
  185. package/docs/api_reference/interfaces/ManagementAccess.html +0 -5
  186. package/docs/api_reference/interfaces/ManagementAccessInput.html +0 -5
  187. package/docs/api_reference/interfaces/ManagementLink.html +0 -7
  188. package/docs/api_reference/interfaces/ManagementProps.html +0 -22
  189. package/docs/api_reference/interfaces/ManagementSectionDef.html +0 -10
  190. package/docs/api_reference/interfaces/MemorySearchFilters.html +0 -5
  191. package/docs/api_reference/interfaces/MigrationProgress.html +0 -6
  192. package/docs/api_reference/interfaces/MigrationStatus.html +0 -7
  193. package/docs/api_reference/interfaces/NotificationConfig.html +0 -5
  194. package/docs/api_reference/interfaces/NotificationContextType.html +0 -6
  195. package/docs/api_reference/interfaces/NotificationProviderProps.html +0 -4
  196. package/docs/api_reference/interfaces/PackageSettings.html +0 -22
  197. package/docs/api_reference/interfaces/SearchOptions.html +0 -6
  198. package/docs/api_reference/interfaces/SearchResult.html +0 -5
  199. package/docs/api_reference/interfaces/SubscriptionExpiredGuardProps.html +0 -7
  200. package/docs/api_reference/interfaces/SubscriptionExpiredModalProps.html +0 -6
  201. package/docs/api_reference/interfaces/TTSOptions.html +0 -5
  202. package/docs/api_reference/interfaces/TTSProgress.html +0 -6
  203. package/docs/api_reference/interfaces/TrialUsage.html +0 -6
  204. package/docs/api_reference/interfaces/UploadRequest.html +0 -9
  205. package/docs/api_reference/interfaces/UseTTSReturn.html +0 -14
  206. package/docs/api_reference/interfaces/VectorDocument.html +0 -11
  207. package/docs/api_reference/interfaces/VectorMemory.html +0 -12
  208. package/docs/api_reference/interfaces/VectorMemoryMetadata.html +0 -7
  209. package/docs/api_reference/interfaces/VectorStoreStatus.html +0 -7
  210. package/docs/api_reference/interfaces/VoiceModelsResponse.html +0 -4
  211. package/docs/api_reference/interfaces/VoiceState.html +0 -12
  212. package/docs/api_reference/media/02_gateway_api.md +0 -123
  213. package/docs/api_reference/media/05_cli_quickstart.md +0 -87
  214. package/docs/api_reference/media/LICENSE +0 -43
  215. package/docs/api_reference/media/PRE-PUSH-CHECKLIST.md +0 -10
  216. package/docs/api_reference/media/PROTECTION-NOTICE.md +0 -11
  217. package/docs/api_reference/media/README.md +0 -58
  218. package/docs/api_reference/modules.html +0 -136
  219. package/docs/api_reference/types/FeatureKey.html +0 -2
  220. package/docs/api_reference/types/FeatureMatrix.html +0 -2
  221. package/docs/api_reference/types/GatewayQueryOptions.html +0 -1
  222. package/docs/api_reference/types/LogContext.html +0 -14
  223. package/docs/api_reference/types/ManagementRequest.html +0 -1
  224. package/docs/api_reference/types/ManagementSectionId.html +0 -2
  225. package/docs/api_reference/types/SubscriptionTier.html +0 -2
  226. package/docs/api_reference/variables/DEFAULT_TIER_FEATURES.html +0 -2
  227. package/docs/api_reference/variables/FeatureFlagContext.html +0 -1
  228. package/docs/api_reference/variables/MANAGEMENT_SECTIONS.html +0 -1
  229. package/docs/api_reference/variables/OSS_DEFAULT_FEATURES.html +0 -2
  230. package/docs/api_reference/variables/SYSTEM_FLAGS.html +0 -2
  231. package/docs/api_reference/variables/authenticationService.html +0 -1
  232. package/docs/api_reference/variables/debugLogger-1.html +0 -1
  233. package/docs/api_reference/variables/featureFlagService-1.html +0 -2
  234. package/docs/api_reference/variables/notificationService-1.html +0 -1
  235. package/docs/api_reference/variables/vectorDatabaseService-1.html +0 -1
  236. package/docs/api_reference/variables/vectorMigrationService-1.html +0 -1
  237. package/docs/api_reference/variables/voiceService-1.html +0 -1
@@ -1,516 +0,0 @@
1
- import {
2
- Check,
3
- Copy,
4
- MarkdownImage,
5
- getHighlightTree,
6
- markdownSanitizeSchema,
7
- maybeHandleFileLinkClick,
8
- renderLowlightChildren
9
- } from "./chunk-KDIL5WUL.mjs";
10
-
11
- // src/components/StreamingMarkdown.tsx
12
- import React, { useEffect, useMemo, useRef, useState } from "react";
13
- import { Box, Tooltip, IconButton } from "@mui/material";
14
- import ReactMarkdown from "react-markdown";
15
- import remarkGfm from "remark-gfm";
16
- import rehypeRaw from "rehype-raw";
17
- import rehypeSanitize from "rehype-sanitize";
18
- import { useTheme, alpha } from "@mui/material/styles";
19
- import { jsx, jsxs } from "react/jsx-runtime";
20
- var StreamingMarkdown = ({
21
- content,
22
- isStreaming = false,
23
- sources
24
- }) => {
25
- const theme = useTheme();
26
- const showCursor = isStreaming && content.trim().length > 0;
27
- const showLoader = isStreaming && content.trim().length === 0;
28
- const prevSanitizedRef = useRef("");
29
- const containerRef = useRef(null);
30
- const stableSourcesRef = useRef([]);
31
- const effectiveSources = useMemo(() => {
32
- if (Array.isArray(sources) && sources.length > 0) {
33
- stableSourcesRef.current = sources;
34
- return sources;
35
- }
36
- if (sources === void 0) {
37
- return stableSourcesRef.current;
38
- }
39
- stableSourcesRef.current = [];
40
- return [];
41
- }, [sources]);
42
- const normalizeTables = (markdown) => {
43
- const lines = markdown.split("\n");
44
- const output = [];
45
- let inTable = false;
46
- let tableRows = [];
47
- const flushTable = () => {
48
- if (tableRows.length === 0) return;
49
- const maxCols = Math.max(...tableRows.map((r) => r.length));
50
- const padded = tableRows.map((row) => [...row, ...Array(maxCols - row.length).fill("")]);
51
- const header = padded[0];
52
- const separator = Array(maxCols).fill("---");
53
- output.push("| " + header.join(" | ") + " |");
54
- output.push("| " + separator.join(" | ") + " |");
55
- for (let i = 1; i < padded.length; i++) {
56
- const row = padded[i];
57
- if (row.every((cell) => /^-+$/.test(cell))) continue;
58
- output.push("| " + row.join(" | ") + " |");
59
- }
60
- tableRows = [];
61
- inTable = false;
62
- };
63
- for (const line of lines) {
64
- if (/^\s*\|.*\|\s*$/.test(line)) {
65
- inTable = true;
66
- const cells = line.trim().slice(1, -1).split("|").map((c) => c.trim());
67
- tableRows.push(cells);
68
- } else {
69
- if (inTable) flushTable();
70
- output.push(line);
71
- }
72
- }
73
- if (inTable) flushTable();
74
- return output.join("\n");
75
- };
76
- const sanitizeMarkdown = (raw) => {
77
- let sanitized = raw.replace(/<[/]?start_of_turn>|<[/]?end[_]?of[_]?turn>/gi, "");
78
- sanitized = sanitized.replace(/<div class="MuiBox-root[^"]*"[^>]*>([\s\S]*?)<\/div>/g, (_, inner) => inner.trim()).replace(/<div[^>]*>\s*<\/div>/g, "");
79
- sanitized = sanitized.replace(/\r?\n\s*:\s*/g, ": ");
80
- sanitized = sanitized.replace(/\r?\n\s*,\s*/g, ", ");
81
- sanitized = normalizeTables(sanitized);
82
- return sanitized;
83
- };
84
- const sanitizedContent = sanitizeMarkdown(content);
85
- const contentWithSources = useMemo(() => {
86
- if (!effectiveSources.length || isStreaming) {
87
- return sanitizedContent;
88
- }
89
- const existingSection = /\*\*Sources?\*\*/i.test(sanitizedContent);
90
- if (existingSection) {
91
- return sanitizedContent;
92
- }
93
- const listMarkdown = effectiveSources.map((doc, index) => `- ${index + 1}. ${doc.name}`).join("\n");
94
- return `${sanitizedContent}
95
-
96
- **Sources**
97
- ${listMarkdown}`;
98
- }, [sanitizedContent, effectiveSources, isStreaming]);
99
- const escapeHtml = (str) => str.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/\"/g, "&quot;").replace(/'/g, "&#39;");
100
- const isPlainAppend = (s) => {
101
- return !/[`*_\[\]<>|#~]/.test(s);
102
- };
103
- let renderContent = contentWithSources;
104
- if (isStreaming) {
105
- const prev = prevSanitizedRef.current;
106
- let i = 0;
107
- const max = Math.min(prev.length, sanitizedContent.length);
108
- while (i < max && prev.charCodeAt(i) === sanitizedContent.charCodeAt(i)) i++;
109
- const base = sanitizedContent.slice(0, i);
110
- const appended = sanitizedContent.slice(i);
111
- if (appended && isPlainAppend(appended)) {
112
- const parts = appended.split(/(\s+)/);
113
- let delayMs = 0;
114
- const step = 42;
115
- const wrapped = parts.map((p) => {
116
- if (/^\s+$/.test(p) || p === "") return p;
117
- const safe = escapeHtml(p);
118
- const out = `<span class="bl-fade-word" data-bl-delay="${delayMs}">${safe}</span>`;
119
- delayMs += step;
120
- return out;
121
- }).join("");
122
- renderContent = base + wrapped;
123
- }
124
- }
125
- useEffect(() => {
126
- prevSanitizedRef.current = contentWithSources;
127
- }, [contentWithSources]);
128
- useEffect(() => {
129
- if (!containerRef.current) return;
130
- const nodes = containerRef.current.querySelectorAll(".bl-fade-word");
131
- nodes.forEach((node) => {
132
- const delay = node.getAttribute("data-bl-delay");
133
- if (delay) {
134
- node.style.setProperty("--bl-delay", `${delay}ms`);
135
- node.style.animationDelay = `${delay}ms`;
136
- }
137
- });
138
- }, [renderContent, sanitizedContent, isStreaming]);
139
- const MarkRenderer = ({ children, ...props }) => {
140
- const inlineBg = theme.palette.mode === "dark" ? alpha(theme.palette.common.white, 0.06) : alpha(theme.palette.text.primary, 0.06);
141
- const inlineBorder = `1px solid ${alpha(theme.palette.text.primary, 0.15)}`;
142
- return /* @__PURE__ */ jsx(
143
- Box,
144
- {
145
- component: "span",
146
- sx: {
147
- display: "inline-block",
148
- backgroundColor: inlineBg,
149
- border: inlineBorder,
150
- color: "inherit",
151
- padding: "0.15em 0.35em",
152
- borderRadius: "4px",
153
- fontWeight: 500,
154
- fontSize: "0.92em",
155
- lineHeight: 1.4,
156
- whiteSpace: "normal",
157
- width: "fit-content",
158
- maxWidth: "100%",
159
- fontFamily: "ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace"
160
- },
161
- ...props,
162
- children
163
- }
164
- );
165
- };
166
- const LinkRenderer = ({ href, children, ...props }) => /* @__PURE__ */ jsx(
167
- "a",
168
- {
169
- href,
170
- target: "_blank",
171
- rel: "noopener noreferrer",
172
- onClick: (e) => maybeHandleFileLinkClick(e, href),
173
- style: {
174
- color: theme.palette.info?.main ?? theme.palette.primary.main,
175
- textDecoration: "underline",
176
- textUnderlineOffset: "2px"
177
- },
178
- ...props,
179
- children
180
- }
181
- );
182
- const CodeRenderer = ({ node: _node, className, children, ...props }) => {
183
- const match = /language-([\w-]+)/.exec(className || "");
184
- const requestedLanguage = match?.[1]?.toLowerCase() ?? "";
185
- const codeText = String(children).replace(/\n$/, "");
186
- const isProbablyBlock = codeText.includes("\n") || Boolean(requestedLanguage);
187
- const [copied, setCopied] = useState(false);
188
- const handleCopy = () => {
189
- void navigator.clipboard.writeText(codeText);
190
- setCopied(true);
191
- setTimeout(() => setCopied(false), 2e3);
192
- };
193
- const highlightTree = useMemo(
194
- () => isProbablyBlock ? getHighlightTree(codeText, requestedLanguage) : null,
195
- [isProbablyBlock, codeText, requestedLanguage]
196
- );
197
- const highlightedNodes = useMemo(
198
- () => highlightTree ? renderLowlightChildren(
199
- (highlightTree.children || []).filter(
200
- (node) => node.type === "element" || node.type === "text"
201
- ),
202
- `hl-${requestedLanguage || "auto"}`
203
- ) : [],
204
- [highlightTree, requestedLanguage]
205
- );
206
- const dataLanguage = highlightTree && highlightTree.data && typeof highlightTree.data === "object" && "language" in highlightTree.data ? String(highlightTree.data.language ?? "") : "";
207
- if (!highlightTree) {
208
- const inlineBg = theme.palette.mode === "dark" ? alpha(theme.palette.common.white, 0.06) : alpha(theme.palette.text.primary, 0.06);
209
- const inlineBorder = `1px solid ${alpha(theme.palette.text.primary, 0.15)}`;
210
- return /* @__PURE__ */ jsx(
211
- "code",
212
- {
213
- style: {
214
- borderRadius: 4,
215
- fontSize: "0.92em",
216
- fontFamily: "ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace",
217
- backgroundColor: inlineBg,
218
- border: inlineBorder,
219
- padding: "0.15em 0.35em"
220
- },
221
- ...props,
222
- children
223
- }
224
- );
225
- }
226
- const resolvedLanguage = (requestedLanguage || dataLanguage || "code").toString();
227
- const languageLabel = resolvedLanguage.toUpperCase();
228
- const languageClass = resolvedLanguage.toLowerCase();
229
- const highlightColors = theme.palette.mode === "dark" ? {
230
- background: "#0f172a",
231
- text: "#e2e8f0",
232
- keyword: "#c792ea",
233
- string: "#7fdbca",
234
- number: "#f78c6c",
235
- comment: "#64748b",
236
- function: "#82aaff",
237
- variable: "#f07178"
238
- } : {
239
- background: "#f4f6ff",
240
- text: "#1e293b",
241
- keyword: "#7c3aed",
242
- string: "#0f766e",
243
- number: "#b45309",
244
- comment: "#6b7280",
245
- function: "#2563eb",
246
- variable: "#d97706"
247
- };
248
- return /* @__PURE__ */ jsxs(
249
- Box,
250
- {
251
- sx: {
252
- borderRadius: "4px",
253
- overflow: "auto",
254
- my: "0.5rem",
255
- px: 0,
256
- py: 0,
257
- mt: 1,
258
- mb: 0.5,
259
- fontSize: "0.9rem",
260
- position: "relative",
261
- fontFamily: "ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace",
262
- width: "100%",
263
- maxWidth: "100%"
264
- },
265
- children: [
266
- /* @__PURE__ */ jsxs(
267
- Box,
268
- {
269
- sx: {
270
- px: 2,
271
- py: 1,
272
- bgcolor: theme.palette.mode === "dark" ? alpha(theme.palette.common.white, 0.04) : alpha(theme.palette.text.primary, 0.04),
273
- color: theme.palette.text.secondary,
274
- fontSize: "0.75rem",
275
- borderBottom: `1px solid ${alpha(theme.palette.text.primary, 0.1)}`,
276
- display: "flex",
277
- justifyContent: "space-between",
278
- alignItems: "center",
279
- fontFamily: "inherit"
280
- },
281
- children: [
282
- /* @__PURE__ */ jsx("span", { children: languageLabel }),
283
- /* @__PURE__ */ jsx(Tooltip, { title: copied ? "Copied!" : "Copy", arrow: true, children: /* @__PURE__ */ jsx(
284
- IconButton,
285
- {
286
- size: "small",
287
- onClick: handleCopy,
288
- sx: {
289
- color: copied ? theme.palette.success.main : theme.palette.text.secondary,
290
- "&:hover": { color: theme.palette.text.primary },
291
- padding: "4px"
292
- },
293
- children: copied ? /* @__PURE__ */ jsx(Check, { fontSize: "small" }) : /* @__PURE__ */ jsx(Copy, { fontSize: "small" })
294
- }
295
- ) })
296
- ]
297
- }
298
- ),
299
- /* @__PURE__ */ jsx(
300
- Box,
301
- {
302
- sx: {
303
- overflowX: "auto",
304
- maxWidth: "100%",
305
- "& .hljs": {
306
- display: "block",
307
- overflowX: "auto",
308
- padding: "16px",
309
- margin: 0,
310
- backgroundColor: highlightColors.background,
311
- color: highlightColors.text,
312
- fontSize: "0.9rem"
313
- },
314
- "& .hljs-comment, & .hljs-quote": {
315
- color: highlightColors.comment,
316
- fontStyle: "italic"
317
- },
318
- "& .hljs-keyword, & .hljs-selector-tag, & .hljs-literal, & .hljs-built_in": {
319
- color: highlightColors.keyword
320
- },
321
- "& .hljs-string, & .hljs-doctag, & .hljs-template-tag, & .hljs-attr": {
322
- color: highlightColors.string
323
- },
324
- "& .hljs-number, & .hljs-symbol, & .hljs-bullet, & .hljs-meta": {
325
- color: highlightColors.number
326
- },
327
- "& .hljs-title, & .hljs-section, & .hljs-selector-id, & .hljs-function": {
328
- color: highlightColors.function
329
- },
330
- "& .hljs-variable, & .hljs-params, & .hljs-property": {
331
- color: highlightColors.variable
332
- }
333
- },
334
- children: /* @__PURE__ */ jsx("pre", { className: `hljs language-${languageClass}`, ...props, children: /* @__PURE__ */ jsx("code", { className: "hljs", children: highlightedNodes }) })
335
- }
336
- )
337
- ]
338
- }
339
- );
340
- };
341
- const EmRenderer = ({ children, ...props }) => {
342
- const onlyChild = Array.isArray(children) && children.length === 1 ? children[0] : null;
343
- if (onlyChild && React.isValidElement(onlyChild) && typeof onlyChild.props?.className === "string" && onlyChild.props.className.includes("MuiBox-root")) {
344
- const inner = onlyChild.props.children;
345
- if (typeof inner === "string" && inner.trim().toUpperCase() === "CODE") {
346
- return null;
347
- }
348
- return /* @__PURE__ */ jsx(
349
- Box,
350
- {
351
- sx: {
352
- fontFamily: "monospace",
353
- fontSize: "0.9rem",
354
- backgroundColor: theme.palette.background.default,
355
- color: theme.palette.text.primary,
356
- padding: "12px 16px",
357
- borderRadius: "4px",
358
- border: `1px solid ${theme.palette.divider}`,
359
- my: 1,
360
- display: "inline-block"
361
- },
362
- children: inner
363
- }
364
- );
365
- }
366
- return /* @__PURE__ */ jsx("em", { ...props, children });
367
- };
368
- const TableRenderer = ({ children, ...props }) => /* @__PURE__ */ jsx(Box, { sx: { overflowX: "auto", my: 1 }, children: /* @__PURE__ */ jsx("table", { style: { borderCollapse: "collapse", width: "100%" }, ...props, children }) });
369
- const OrderedListRenderer = ({ children, ...props }) => /* @__PURE__ */ jsx("ol", { style: { paddingLeft: 24, marginLeft: 16, listStyleType: "decimal" }, ...props, children });
370
- const UnorderedListRenderer = ({ children, ...props }) => /* @__PURE__ */ jsx(
371
- "ul",
372
- {
373
- style: {
374
- paddingLeft: "1.5rem",
375
- marginTop: "0.5rem",
376
- marginBottom: "0.25rem",
377
- listStyle: "disc"
378
- },
379
- ...props,
380
- children
381
- }
382
- );
383
- const BlockQuoteRenderer = ({ children, ...props }) => /* @__PURE__ */ jsx(
384
- Box,
385
- {
386
- component: "blockquote",
387
- sx: {
388
- borderLeft: `4px solid ${theme.palette.divider}`,
389
- pl: 2,
390
- ml: 0,
391
- color: theme.palette.text.secondary
392
- },
393
- ...props,
394
- children
395
- }
396
- );
397
- const TableHeaderRenderer = ({ children, ...props }) => /* @__PURE__ */ jsx(
398
- "th",
399
- {
400
- style: {
401
- border: "1px solid #ddd",
402
- padding: "8px",
403
- backgroundColor: theme.palette.mode === "dark" ? "#333" : "#f2f2f2",
404
- textAlign: "left"
405
- },
406
- ...props,
407
- children
408
- }
409
- );
410
- const TableCellRenderer = ({ children, ...props }) => /* @__PURE__ */ jsx(
411
- "td",
412
- {
413
- style: {
414
- border: "1px solid #ddd",
415
- padding: "8px"
416
- },
417
- ...props,
418
- children
419
- }
420
- );
421
- const ParagraphRenderer = ({ children, ...props }) => /* @__PURE__ */ jsx("p", { style: { marginTop: "0.5rem", marginBottom: "0.5rem" }, ...props, children });
422
- const components = {
423
- mark: MarkRenderer,
424
- code: CodeRenderer,
425
- a: LinkRenderer,
426
- img: MarkdownImage,
427
- em: EmRenderer,
428
- table: TableRenderer,
429
- ol: OrderedListRenderer,
430
- ul: UnorderedListRenderer,
431
- blockquote: BlockQuoteRenderer,
432
- th: TableHeaderRenderer,
433
- td: TableCellRenderer,
434
- p: ParagraphRenderer
435
- };
436
- return /* @__PURE__ */ jsx(
437
- Box,
438
- {
439
- ref: containerRef,
440
- sx: {
441
- // Settle the whole block to full color a beat after streaming ends.
442
- transition: "opacity 380ms ease-out, transform 220ms ease-out",
443
- "& .cursor": {
444
- display: showCursor ? "inline" : "none",
445
- animation: "blink 1s step-start infinite"
446
- },
447
- "@keyframes blink": {
448
- "50%": { opacity: 0 }
449
- },
450
- // Each newly-written word focuses in — blur→sharp, a tiny rise, and fade —
451
- // like ink settling onto the page as the typewriter writes.
452
- "& .bl-fade-word": {
453
- opacity: 0,
454
- animation: "bl-fade-in 480ms cubic-bezier(0.22, 1, 0.36, 1) forwards"
455
- },
456
- "@keyframes bl-fade-in": {
457
- from: { opacity: 0, filter: "blur(3px)", transform: "translateY(2px)" },
458
- to: { opacity: 1, filter: "blur(0)", transform: "translateY(0)" }
459
- },
460
- // Dimmed while streaming, then brightens to full color once the answer lands.
461
- opacity: isStreaming ? 0.86 : 1,
462
- transform: isStreaming ? "translateY(0.25px)" : "none",
463
- // Reduce layout jumpiness between updates
464
- "& p:last-child": { marginBottom: 0 },
465
- // Add min height when showing loader to prevent layout shift
466
- minHeight: showLoader ? "40px" : "auto"
467
- },
468
- children: showLoader ? (
469
- // Show loading indicator when streaming but no content yet
470
- /* @__PURE__ */ jsx(Box, { sx: { display: "flex", alignItems: "center", minHeight: "40px", pl: 2 }, children: /* @__PURE__ */ jsxs("div", { className: "typing-only", children: [
471
- /* @__PURE__ */ jsx("span", { className: "dot" }),
472
- /* @__PURE__ */ jsx("span", { className: "dot" }),
473
- /* @__PURE__ */ jsx("span", { className: "dot" })
474
- ] }) })
475
- ) : /* @__PURE__ */ jsx(
476
- ReactMarkdown,
477
- {
478
- remarkPlugins: [remarkGfm],
479
- rehypePlugins: [rehypeRaw, [rehypeSanitize, markdownSanitizeSchema]],
480
- components,
481
- children: (renderContent || sanitizedContent) + (showCursor ? " \u258A" : "")
482
- }
483
- )
484
- }
485
- );
486
- };
487
- var arePropsEqual = (prev, next) => {
488
- if (prev.content !== next.content || prev.isStreaming !== next.isStreaming) {
489
- return false;
490
- }
491
- const a = prev.sources;
492
- const b = next.sources;
493
- if (a === b) return true;
494
- if (!a || !b || a.length !== b.length) return false;
495
- return a.every((s, i) => s.id === b[i].id && s.name === b[i].name);
496
- };
497
- var StreamingMarkdown_default = React.memo(StreamingMarkdown, arePropsEqual);
498
-
499
- // src/utils/installedApp.ts
500
- var isNativeShell = () => {
501
- if (typeof window === "undefined") return false;
502
- const cap = window.Capacitor;
503
- return typeof cap?.isNativePlatform === "function" && cap.isNativePlatform() === true;
504
- };
505
- var isStandalonePwa = () => {
506
- if (typeof window === "undefined") return false;
507
- const nav = window.navigator;
508
- return window.matchMedia?.("(display-mode: standalone)").matches || nav.standalone === true;
509
- };
510
-
511
- export {
512
- StreamingMarkdown_default,
513
- isNativeShell,
514
- isStandalonePwa
515
- };
516
- //# sourceMappingURL=chunk-5BZWJQ5O.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/components/StreamingMarkdown.tsx","../src/utils/installedApp.ts"],"sourcesContent":["/*\n * Copyright (c) 2025 Burtson Labs LLC.\n * SPDX-License-Identifier: BUSL-1.1\n * See LICENSE for the applicable terms.\n */\n\n\nimport React, { useEffect, useMemo, useRef, useState } from \"react\";\nimport { Box, Tooltip, IconButton } from \"@mui/material\";\nimport ReactMarkdown from \"react-markdown\";\nimport remarkGfm from \"remark-gfm\";\nimport rehypeRaw from \"rehype-raw\";\nimport rehypeSanitize from \"rehype-sanitize\";\nimport { useTheme, alpha } from \"@mui/material/styles\";\nimport type { Element, Text, Root } from \"hast\";\nimport type { Components, ExtraProps } from \"react-markdown\";\nimport type { ComponentPropsWithoutRef, ReactNode } from \"react\";\n\n// react-markdown 10 dropped its CodeProps export and the `inline` flag;\n// block vs inline is inferred from the content below.\ntype CodeProps = ComponentPropsWithoutRef<\"code\"> & ExtraProps;\nimport { getHighlightTree } from \"../utils/lowlight\";\nimport { MarkdownImage, markdownSanitizeSchema, renderLowlightChildren } from \"../utils/markdownRendering\";\nimport { CheckIcon, ContentCopyIcon } from \"../icons\";\nimport { maybeHandleFileLinkClick } from \"../utils/openFileLink\";\n\ninterface SourceSummary {\n id: string;\n name: string;\n}\n\ninterface StreamingMarkdownProps {\n content: string;\n isStreaming?: boolean;\n sources?: SourceSummary[];\n}\n\nconst StreamingMarkdown: React.FC<StreamingMarkdownProps> = ({\n content,\n isStreaming = false,\n sources,\n}) => {\n const theme = useTheme();\n const showCursor = isStreaming && content.trim().length > 0;\n const showLoader = isStreaming && content.trim().length === 0; // Show loader when streaming but no content yet\n const prevSanitizedRef = useRef<string>(\"\");\n const containerRef = useRef<HTMLDivElement | null>(null);\n const stableSourcesRef = useRef<SourceSummary[]>([]);\n\n const effectiveSources = useMemo(() => {\n if (Array.isArray(sources) && sources.length > 0) {\n stableSourcesRef.current = sources;\n return sources;\n }\n\n if (sources === undefined) {\n return stableSourcesRef.current;\n }\n\n stableSourcesRef.current = [];\n return [];\n }, [sources]);\n\n const normalizeTables = (markdown: string): string => {\n const lines = markdown.split(\"\\n\");\n const output: string[] = [];\n let inTable = false;\n let tableRows: string[][] = [];\n\n const flushTable = () => {\n if (tableRows.length === 0) return;\n const maxCols = Math.max(...tableRows.map((r) => r.length));\n const padded = tableRows.map((row) => [...row, ...Array(maxCols - row.length).fill(\"\")]);\n const header = padded[0];\n const separator = Array(maxCols).fill(\"---\");\n output.push(\"| \" + header.join(\" | \") + \" |\");\n output.push(\"| \" + separator.join(\" | \") + \" |\");\n for (let i = 1; i < padded.length; i++) {\n const row = padded[i];\n if (row.every((cell) => /^-+$/.test(cell))) continue;\n output.push(\"| \" + row.join(\" | \") + \" |\");\n }\n tableRows = [];\n inTable = false;\n };\n\n for (const line of lines) {\n if (/^\\s*\\|.*\\|\\s*$/.test(line)) {\n inTable = true;\n const cells = line.trim().slice(1, -1).split(\"|\").map((c) => c.trim());\n tableRows.push(cells);\n } else {\n if (inTable) flushTable();\n output.push(line);\n }\n }\n if (inTable) flushTable();\n return output.join(\"\\n\");\n };\n\n const sanitizeMarkdown = (raw: string): string => {\n let sanitized = raw.replace(/<[/]?start_of_turn>|<[/]?end[_]?of[_]?turn>/gi, \"\");\n // Unwrap Box wrappers\n sanitized = sanitized\n .replace(/<div class=\"MuiBox-root[^\"]*\"[^>]*>([\\s\\S]*?)<\\/div>/g, (_, inner) => inner.trim())\n .replace(/<div[^>]*>\\s*<\\/div>/g, \"\");\n // Collapse newline before common punctuation\n sanitized = sanitized.replace(/\\r?\\n\\s*:\\s*/g, \": \");\n sanitized = sanitized.replace(/\\r?\\n\\s*,\\s*/g, \", \");\n // Normalize pipe tables\n sanitized = normalizeTables(sanitized);\n return sanitized;\n };\n\n const sanitizedContent = sanitizeMarkdown(content);\n\n const contentWithSources = useMemo(() => {\n if (!effectiveSources.length || isStreaming) {\n return sanitizedContent;\n }\n\n const existingSection = /\\*\\*Sources?\\*\\*/i.test(sanitizedContent);\n if (existingSection) {\n return sanitizedContent;\n }\n\n const listMarkdown = effectiveSources\n .map((doc, index) => `- ${index + 1}. ${doc.name}`)\n .join(\"\\n\");\n\n return `${sanitizedContent}\\n\\n**Sources**\\n${listMarkdown}`;\n }, [sanitizedContent, effectiveSources, isStreaming]);\n\n // Helpers for safe per-word fade wrapping\n const escapeHtml = (str: string) =>\n str\n .replace(/&/g, \"&amp;\")\n .replace(/</g, \"&lt;\")\n .replace(/>/g, \"&gt;\")\n .replace(/\\\"/g, \"&quot;\")\n .replace(/'/g, \"&#39;\");\n\n const isPlainAppend = (s: string) => {\n // Avoid wrapping when the delta includes markdown/code/meta characters\n return !/[`*_\\[\\]<>|#~]/.test(s);\n };\n\n // Compute a render string where newly appended words fade in with a stagger\n let renderContent = contentWithSources;\n if (isStreaming) {\n const prev = prevSanitizedRef.current;\n // Find common prefix length to identify newly appended tail\n let i = 0;\n const max = Math.min(prev.length, sanitizedContent.length);\n while (i < max && prev.charCodeAt(i) === sanitizedContent.charCodeAt(i)) i++;\n const base = sanitizedContent.slice(0, i);\n const appended = sanitizedContent.slice(i);\n if (appended && isPlainAppend(appended)) {\n const parts = appended.split(/(\\s+)/); // keep whitespace tokens\n let delayMs = 0;\n const step = 42; // gentle stagger between words for smoother reveal\n const wrapped = parts\n .map((p) => {\n if (/^\\s+$/.test(p) || p === \"\") return p; // preserve whitespace\n const safe = escapeHtml(p);\n const out = `<span class=\\\"bl-fade-word\\\" data-bl-delay=\\\"${delayMs}\\\">${safe}</span>`;\n delayMs += step;\n return out;\n })\n .join(\"\");\n renderContent = base + wrapped;\n }\n }\n\n // After compute: update ref for next render\n useEffect(() => {\n prevSanitizedRef.current = contentWithSources;\n }, [contentWithSources]);\n\n useEffect(() => {\n if (!containerRef.current) return;\n const nodes = containerRef.current.querySelectorAll<HTMLElement>(\".bl-fade-word\");\n nodes.forEach((node) => {\n const delay = node.getAttribute(\"data-bl-delay\");\n if (delay) {\n node.style.setProperty(\"--bl-delay\", `${delay}ms`);\n node.style.animationDelay = `${delay}ms`;\n }\n });\n }, [renderContent, sanitizedContent, isStreaming]);\n\n type MarkProps = ComponentPropsWithoutRef<\"mark\">;\n type AnchorProps = ComponentPropsWithoutRef<\"a\">;\n type EmProps = ComponentPropsWithoutRef<\"em\">;\n type TableProps = ComponentPropsWithoutRef<\"table\">;\n type TableCellProps = ComponentPropsWithoutRef<\"td\">;\n type TableHeaderProps = ComponentPropsWithoutRef<\"th\">;\n type ParagraphProps = ComponentPropsWithoutRef<\"p\">;\n type BlockQuoteProps = ComponentPropsWithoutRef<\"blockquote\">;\n type OrderedListProps = ComponentPropsWithoutRef<\"ol\">;\n type UnorderedListProps = ComponentPropsWithoutRef<\"ul\">;\n\n const MarkRenderer: React.FC<MarkProps> = ({ children, ...props }) => {\n const inlineBg = theme.palette.mode === \"dark\"\n ? alpha(theme.palette.common.white, 0.06)\n : alpha(theme.palette.text.primary, 0.06);\n const inlineBorder = `1px solid ${alpha(theme.palette.text.primary, 0.15)}`;\n return (\n <Box\n component=\"span\"\n sx={{\n display: \"inline-block\",\n backgroundColor: inlineBg,\n border: inlineBorder,\n color: \"inherit\",\n padding: \"0.15em 0.35em\",\n borderRadius: \"4px\",\n fontWeight: 500,\n fontSize: \"0.92em\",\n lineHeight: 1.4,\n whiteSpace: \"normal\",\n width: \"fit-content\",\n maxWidth: \"100%\",\n fontFamily:\n \"ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace\",\n }}\n {...props}\n >\n {children}\n </Box>\n );\n };\n\n const LinkRenderer: React.FC<AnchorProps> = ({ href, children, ...props }) => (\n <a\n href={href}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n // Standalone PWAs can't download — route file links to the share sheet.\n onClick={(e) => maybeHandleFileLinkClick(e, href)}\n style={{\n color: theme.palette.info?.main ?? theme.palette.primary.main,\n textDecoration: \"underline\",\n textUnderlineOffset: \"2px\",\n }}\n {...props}\n >\n {children}\n </a>\n );\n\n const CodeRenderer: React.FC<CodeProps> = ({ node: _node, className, children, ...props }) => {\n const match = /language-([\\w-]+)/.exec(className || \"\");\n const requestedLanguage = match?.[1]?.toLowerCase() ?? \"\";\n const codeText = String(children).replace(/\\n$/, \"\");\n const isProbablyBlock = codeText.includes(\"\\n\") || Boolean(requestedLanguage);\n\n const [copied, setCopied] = useState(false);\n const handleCopy = () => {\n void navigator.clipboard.writeText(codeText);\n setCopied(true);\n setTimeout(() => setCopied(false), 2000);\n };\n\n\n const highlightTree = useMemo<Root | null>(\n () => (isProbablyBlock ? getHighlightTree(codeText, requestedLanguage) : null),\n [isProbablyBlock, codeText, requestedLanguage]\n );\n\n const highlightedNodes = useMemo<ReactNode[]>(\n () =>\n highlightTree\n ? renderLowlightChildren(\n (highlightTree.children || []).filter(\n (node): node is Element | Text => node.type === \"element\" || node.type === \"text\"\n ),\n `hl-${requestedLanguage || \"auto\"}`\n )\n : [],\n [highlightTree, requestedLanguage]\n );\n\n const dataLanguage =\n highlightTree &&\n highlightTree.data &&\n typeof highlightTree.data === \"object\" &&\n \"language\" in highlightTree.data\n ? String((highlightTree.data as { language?: unknown }).language ?? \"\")\n : \"\";\n\n if (!highlightTree) {\n const inlineBg = theme.palette.mode === \"dark\"\n ? alpha(theme.palette.common.white, 0.06)\n : alpha(theme.palette.text.primary, 0.06);\n const inlineBorder = `1px solid ${alpha(theme.palette.text.primary, 0.15)}`;\n return (\n <code\n style={{\n borderRadius: 4,\n fontSize: \"0.92em\",\n fontFamily: \"ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace\",\n backgroundColor: inlineBg,\n border: inlineBorder,\n padding: \"0.15em 0.35em\",\n }}\n {...props}\n >\n {children}\n </code>\n );\n }\n\n const resolvedLanguage = (requestedLanguage || dataLanguage || \"code\").toString();\n const languageLabel = resolvedLanguage.toUpperCase();\n const languageClass = resolvedLanguage.toLowerCase();\n\n const highlightColors = theme.palette.mode === \"dark\"\n ? {\n background: \"#0f172a\",\n text: \"#e2e8f0\",\n keyword: \"#c792ea\",\n string: \"#7fdbca\",\n number: \"#f78c6c\",\n comment: \"#64748b\",\n function: \"#82aaff\",\n variable: \"#f07178\",\n }\n : {\n background: \"#f4f6ff\",\n text: \"#1e293b\",\n keyword: \"#7c3aed\",\n string: \"#0f766e\",\n number: \"#b45309\",\n comment: \"#6b7280\",\n function: \"#2563eb\",\n variable: \"#d97706\",\n };\n\n return (\n <Box\n sx={{\n borderRadius: \"4px\",\n overflow: \"auto\",\n my: \"0.5rem\",\n px: 0,\n py: 0,\n mt: 1,\n mb: 0.5,\n fontSize: \"0.9rem\",\n position: \"relative\",\n fontFamily: \"ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace\",\n width: \"100%\",\n maxWidth: \"100%\",\n }}\n >\n <Box\n sx={{\n px: 2,\n py: 1,\n bgcolor: theme.palette.mode === \"dark\"\n ? alpha(theme.palette.common.white, 0.04)\n : alpha(theme.palette.text.primary, 0.04),\n color: theme.palette.text.secondary,\n fontSize: \"0.75rem\",\n borderBottom: `1px solid ${alpha(theme.palette.text.primary, 0.1)}`,\n display: \"flex\",\n justifyContent: \"space-between\",\n alignItems: \"center\",\n fontFamily: \"inherit\",\n }}\n >\n <span>{languageLabel}</span>\n <Tooltip title={copied ? \"Copied!\" : \"Copy\"} arrow>\n <IconButton\n size=\"small\"\n onClick={handleCopy}\n sx={{\n color: copied ? theme.palette.success.main : theme.palette.text.secondary,\n \"&:hover\": { color: theme.palette.text.primary },\n padding: \"4px\",\n }}\n >\n {copied ? <CheckIcon fontSize=\"small\" /> : <ContentCopyIcon fontSize=\"small\" />}\n </IconButton>\n </Tooltip>\n </Box>\n <Box\n sx={{\n overflowX: \"auto\",\n maxWidth: \"100%\",\n '& .hljs': {\n display: 'block',\n overflowX: 'auto',\n padding: '16px',\n margin: 0,\n backgroundColor: highlightColors.background,\n color: highlightColors.text,\n fontSize: '0.9rem',\n },\n '& .hljs-comment, & .hljs-quote': {\n color: highlightColors.comment,\n fontStyle: 'italic',\n },\n '& .hljs-keyword, & .hljs-selector-tag, & .hljs-literal, & .hljs-built_in': {\n color: highlightColors.keyword,\n },\n '& .hljs-string, & .hljs-doctag, & .hljs-template-tag, & .hljs-attr': {\n color: highlightColors.string,\n },\n '& .hljs-number, & .hljs-symbol, & .hljs-bullet, & .hljs-meta': {\n color: highlightColors.number,\n },\n '& .hljs-title, & .hljs-section, & .hljs-selector-id, & .hljs-function': {\n color: highlightColors.function,\n },\n '& .hljs-variable, & .hljs-params, & .hljs-property': {\n color: highlightColors.variable,\n },\n }}\n >\n <pre className={`hljs language-${languageClass}`} {...props}>\n <code className=\"hljs\">{highlightedNodes}</code>\n </pre>\n </Box>\n </Box>\n );\n };\n\n const EmRenderer: React.FC<EmProps> = ({ children, ...props }) => {\n const onlyChild = Array.isArray(children) && children.length === 1 ? children[0] : null;\n if (\n onlyChild &&\n React.isValidElement<{ className?: unknown; children?: ReactNode }>(onlyChild) &&\n typeof onlyChild.props?.className === \"string\" &&\n onlyChild.props.className.includes(\"MuiBox-root\")\n ) {\n const inner = onlyChild.props.children as ReactNode;\n if (typeof inner === \"string\" && inner.trim().toUpperCase() === \"CODE\") {\n return null;\n }\n return (\n <Box\n sx={{\n fontFamily: \"monospace\",\n fontSize: \"0.9rem\",\n backgroundColor: theme.palette.background.default,\n color: theme.palette.text.primary,\n padding: \"12px 16px\",\n borderRadius: \"4px\",\n border: `1px solid ${theme.palette.divider}`,\n my: 1,\n display: \"inline-block\",\n }}\n >\n {inner}\n </Box>\n );\n }\n return <em {...props}>{children}</em>;\n };\n\n const TableRenderer: React.FC<TableProps> = ({ children, ...props }) => (\n <Box sx={{ overflowX: \"auto\", my: 1 }}>\n <table style={{ borderCollapse: \"collapse\", width: \"100%\" }} {...props}>\n {children}\n </table>\n </Box>\n );\n\n const OrderedListRenderer: React.FC<OrderedListProps> = ({ children, ...props }) => (\n <ol style={{ paddingLeft: 24, marginLeft: 16, listStyleType: \"decimal\" }} {...props}>\n {children}\n </ol>\n );\n\n const UnorderedListRenderer: React.FC<UnorderedListProps> = ({ children, ...props }) => (\n <ul\n style={{\n paddingLeft: \"1.5rem\",\n marginTop: \"0.5rem\",\n marginBottom: \"0.25rem\",\n listStyle: \"disc\",\n }}\n {...props}\n >\n {children}\n </ul>\n );\n\n const BlockQuoteRenderer: React.FC<BlockQuoteProps> = ({ children, ...props }) => (\n <Box\n component=\"blockquote\"\n sx={{\n borderLeft: `4px solid ${theme.palette.divider}`,\n pl: 2,\n ml: 0,\n color: theme.palette.text.secondary,\n }}\n {...props}\n >\n {children}\n </Box>\n );\n\n const TableHeaderRenderer: React.FC<TableHeaderProps> = ({ children, ...props }) => (\n <th\n style={{\n border: \"1px solid #ddd\",\n padding: \"8px\",\n backgroundColor: theme.palette.mode === \"dark\" ? \"#333\" : \"#f2f2f2\",\n textAlign: \"left\",\n }}\n {...props}\n >\n {children}\n </th>\n );\n\n const TableCellRenderer: React.FC<TableCellProps> = ({ children, ...props }) => (\n <td\n style={{\n border: \"1px solid #ddd\",\n padding: \"8px\",\n }}\n {...props}\n >\n {children}\n </td>\n );\n\n const ParagraphRenderer: React.FC<ParagraphProps> = ({ children, ...props }) => (\n <p style={{ marginTop: \"0.5rem\", marginBottom: \"0.5rem\" }} {...props}>\n {children}\n </p>\n );\n\n const components: Components = {\n mark: MarkRenderer,\n code: CodeRenderer,\n a: LinkRenderer,\n img: MarkdownImage,\n em: EmRenderer,\n table: TableRenderer,\n ol: OrderedListRenderer,\n ul: UnorderedListRenderer,\n blockquote: BlockQuoteRenderer,\n th: TableHeaderRenderer,\n td: TableCellRenderer,\n p: ParagraphRenderer,\n };\n\n return (\n <Box\n ref={containerRef}\n sx={{\n // Settle the whole block to full color a beat after streaming ends.\n transition: \"opacity 380ms ease-out, transform 220ms ease-out\",\n \"& .cursor\": {\n display: showCursor ? \"inline\" : \"none\",\n animation: \"blink 1s step-start infinite\",\n },\n \"@keyframes blink\": {\n \"50%\": { opacity: 0 },\n },\n // Each newly-written word focuses in — blur→sharp, a tiny rise, and fade —\n // like ink settling onto the page as the typewriter writes.\n \"& .bl-fade-word\": {\n opacity: 0,\n animation: \"bl-fade-in 480ms cubic-bezier(0.22, 1, 0.36, 1) forwards\",\n },\n \"@keyframes bl-fade-in\": {\n from: { opacity: 0, filter: \"blur(3px)\", transform: \"translateY(2px)\" },\n to: { opacity: 1, filter: \"blur(0)\", transform: \"translateY(0)\" },\n },\n // Dimmed while streaming, then brightens to full color once the answer lands.\n opacity: isStreaming ? 0.86 : 1,\n transform: isStreaming ? \"translateY(0.25px)\" : \"none\",\n // Reduce layout jumpiness between updates\n \"& p:last-child\": { marginBottom: 0 },\n // Add min height when showing loader to prevent layout shift\n minHeight: showLoader ? \"40px\" : \"auto\",\n }}\n >\n {showLoader ? (\n // Show loading indicator when streaming but no content yet\n <Box sx={{ display: \"flex\", alignItems: \"center\", minHeight: \"40px\", pl: 2 }}>\n <div className=\"typing-only\">\n <span className=\"dot\" />\n <span className=\"dot\" />\n <span className=\"dot\" />\n </div>\n </Box>\n ) : (\n <ReactMarkdown\n remarkPlugins={[remarkGfm]}\n rehypePlugins={[rehypeRaw, [rehypeSanitize, markdownSanitizeSchema]]}\n components={components}\n >\n {(renderContent || sanitizedContent) + (showCursor ? \" ▊\" : \"\")}\n </ReactMarkdown>\n )}\n </Box>\n );\n};\n\n// Skip re-rendering (and re-parsing markdown) when nothing this component cares\n// about changed. Critical for long chats: without this, every streamed token\n// re-parses the markdown of EVERY prior message — the main source of mid-stream\n// jank / \"thread-locky\" feel. Only the actively-streaming message (whose content\n// changes each flush) re-renders.\nconst arePropsEqual = (\n prev: StreamingMarkdownProps,\n next: StreamingMarkdownProps,\n): boolean => {\n if (prev.content !== next.content || prev.isStreaming !== next.isStreaming) {\n return false;\n }\n const a = prev.sources;\n const b = next.sources;\n if (a === b) return true;\n if (!a || !b || a.length !== b.length) return false;\n return a.every((s, i) => s.id === b[i].id && s.name === b[i].name);\n};\n\nexport default React.memo(StreamingMarkdown, arePropsEqual);\n","/*\n * Copyright (c) 2025 Burtson Labs LLC.\n * SPDX-License-Identifier: BUSL-1.1\n * See LICENSE for the applicable terms.\n */\n\n/**\n * \"Is this running as an installed app?\" — either a home-screen PWA in\n * standalone display mode, or the Capacitor native shell (which injects\n * `window.Capacitor` before the page loads). The engine can't import\n * @capacitor/core (it's a host-app dependency), so the native check reads\n * the global directly.\n *\n * Layout code that sizes to the real webview / hides browser chrome should\n * key off this rather than the standalone media query alone — WKWebView\n * reports display-mode \"browser\", so the native app would otherwise get\n * the in-browser layout.\n */\nexport const isNativeShell = (): boolean => {\n if (typeof window === \"undefined\") return false;\n const cap = (window as unknown as { Capacitor?: { isNativePlatform?: () => boolean } }).Capacitor;\n return typeof cap?.isNativePlatform === \"function\" && cap.isNativePlatform() === true;\n};\n\nexport const isStandalonePwa = (): boolean => {\n if (typeof window === \"undefined\") return false;\n const nav = window.navigator as Navigator & { standalone?: boolean };\n return window.matchMedia?.(\"(display-mode: standalone)\").matches || nav.standalone === true;\n};\n\nexport const isInstalledApp = (): boolean => isStandalonePwa() || isNativeShell();\n"],"mappings":";;;;;;;;;;;AAOA,OAAO,SAAS,WAAW,SAAS,QAAQ,gBAAgB;AAC5D,SAAS,KAAK,SAAS,kBAAkB;AACzC,OAAO,mBAAmB;AAC1B,OAAO,eAAe;AACtB,OAAO,eAAe;AACtB,OAAO,oBAAoB;AAC3B,SAAS,UAAU,aAAa;AAmM1B,cAoJE,YApJF;AA3KN,IAAM,oBAAsD,CAAC;AAAA,EAC3D;AAAA,EACA,cAAc;AAAA,EACd;AACF,MAAM;AACJ,QAAM,QAAQ,SAAS;AACvB,QAAM,aAAa,eAAe,QAAQ,KAAK,EAAE,SAAS;AAC1D,QAAM,aAAa,eAAe,QAAQ,KAAK,EAAE,WAAW;AAC5D,QAAM,mBAAmB,OAAe,EAAE;AAC1C,QAAM,eAAe,OAA8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