@epam/ai-dial-chat-shared 1.3.0-dev.37 → 1.3.0-dev.372

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 (172) hide show
  1. package/components/ActionMenu/ActionMenu.d.ts +26 -0
  2. package/components/ActionMenu/ActionMenu.d.ts.map +1 -0
  3. package/components/ActionMenu/ActionMenu.js +50 -0
  4. package/components/ConfirmationDialog/ConfirmationDialog.d.ts +6 -1
  5. package/components/ConfirmationDialog/ConfirmationDialog.d.ts.map +1 -1
  6. package/components/ConfirmationDialog/ConfirmationDialog.js +11 -9
  7. package/components/ConfirmationIdentityCard/ConfirmationIdentityCard.module.scss.js +5 -4
  8. package/components/ConfirmationIdentityRow/ConfirmationIdentityRow.js +2 -2
  9. package/components/ConfirmationIdentityRow/ConfirmationIdentityRow.module.scss.js +3 -2
  10. package/components/ConfirmationView/ConfirmationFooter.d.ts.map +1 -1
  11. package/components/ConfirmationView/ConfirmationFooter.js +25 -26
  12. package/components/ConfirmationView/ConfirmationView.d.ts +2 -0
  13. package/components/ConfirmationView/ConfirmationView.d.ts.map +1 -1
  14. package/components/ConfirmationView/ConfirmationView.js +12 -12
  15. package/components/ConfirmationView/ConfirmationView.module.scss.js +6 -5
  16. package/components/DeleteConfirmationDrawer/DeleteConfirmationDrawer.d.ts +31 -0
  17. package/components/DeleteConfirmationDrawer/DeleteConfirmationDrawer.d.ts.map +1 -0
  18. package/components/DeleteConfirmationDrawer/DeleteConfirmationDrawer.js +36 -0
  19. package/components/DeleteConfirmationView/DeleteConfirmationView.d.ts +3 -0
  20. package/components/DeleteConfirmationView/DeleteConfirmationView.d.ts.map +1 -1
  21. package/components/DeleteConfirmationView/DeleteConfirmationView.js +36 -27
  22. package/components/DeleteConfirmationView/DeleteConfirmationView.module.scss.js +5 -4
  23. package/components/DeploymentIcon/DeploymentIcon.module.scss.js +3 -2
  24. package/components/EntityHeader/EntityHeader.js +1 -1
  25. package/components/InitialsAvatar/InitialsAvatar.d.ts +3 -0
  26. package/components/InitialsAvatar/InitialsAvatar.d.ts.map +1 -1
  27. package/components/InitialsAvatar/InitialsAvatar.js +4 -3
  28. package/components/ItemHeader/ItemHeader.d.ts +5 -1
  29. package/components/ItemHeader/ItemHeader.d.ts.map +1 -1
  30. package/components/ItemHeader/ItemHeader.js +4 -1
  31. package/components/ItemHeader/ItemHeader.module.scss.js +5 -4
  32. package/components/MarkdownRenderer/CodeBlock/CodeBlock.d.ts +6 -2
  33. package/components/MarkdownRenderer/CodeBlock/CodeBlock.d.ts.map +1 -1
  34. package/components/MarkdownRenderer/CodeBlock/CodeBlock.js +58 -58
  35. package/components/MarkdownRenderer/CodeBlock/CodeBlock.module.scss.js +9 -8
  36. package/components/MarkdownRenderer/CodeBlock/syntax-theme.d.ts.map +1 -1
  37. package/components/MarkdownRenderer/MDMessageViewer.d.ts +6 -2
  38. package/components/MarkdownRenderer/MDMessageViewer.d.ts.map +1 -1
  39. package/components/MarkdownRenderer/MDMessageViewer.js +14 -12
  40. package/components/MarkdownRenderer/MarkdownRenderer.d.ts +8 -0
  41. package/components/MarkdownRenderer/MarkdownRenderer.d.ts.map +1 -1
  42. package/components/MarkdownRenderer/MarkdownRenderer.js +146 -136
  43. package/components/MarkdownRenderer/MarkdownRenderer.module.scss.js +9 -8
  44. package/components/MarkdownRenderer/Math/MarkdownMathBlock.js +1 -1
  45. package/components/MarkdownRenderer/Math/MarkdownMathBlock.module.scss.js +5 -4
  46. package/components/MarkdownRenderer/PlainTextRenderer.js +1 -1
  47. package/components/MarkdownRenderer/Table/MarkdownTable.d.ts +4 -0
  48. package/components/MarkdownRenderer/Table/MarkdownTable.d.ts.map +1 -1
  49. package/components/MarkdownRenderer/Table/MarkdownTable.js +68 -63
  50. package/components/MarkdownRenderer/Table/MarkdownTable.module.scss.js +15 -13
  51. package/components/MarkdownRenderer/Table/TableHeader.module.scss.js +3 -2
  52. package/components/MarkdownRenderer/markdown-whitespace.js +2 -6
  53. package/components/NewVersionAlert/NewVersionAlert.d.ts +27 -0
  54. package/components/NewVersionAlert/NewVersionAlert.d.ts.map +1 -0
  55. package/components/NewVersionAlert/NewVersionAlert.js +28 -0
  56. package/components/NewVersionAlert/NewVersionAlert.module.scss.js +4 -0
  57. package/components/NotificationStack/NotificationStack.d.ts +48 -0
  58. package/components/NotificationStack/NotificationStack.d.ts.map +1 -0
  59. package/components/NotificationStack/NotificationStack.js +111 -0
  60. package/components/PanelEmptyState/PanelEmptyState.d.ts +12 -2
  61. package/components/PanelEmptyState/PanelEmptyState.d.ts.map +1 -1
  62. package/components/PanelEmptyState/PanelEmptyState.js +19 -9
  63. package/components/PanelEmptyState/PanelEmptyState.module.scss.js +6 -2
  64. package/components/ResourceSummary/ResourceSummary.module.scss.js +5 -4
  65. package/components/TextRefinementField/TextRefinementField.d.ts +4 -2
  66. package/components/TextRefinementField/TextRefinementField.d.ts.map +1 -1
  67. package/components/TextRefinementField/TextRefinementField.js +84 -55
  68. package/components/UnsavedChangesProvider/UnsavedChangesProvider.d.ts +22 -0
  69. package/components/UnsavedChangesProvider/UnsavedChangesProvider.d.ts.map +1 -0
  70. package/components/UnsavedChangesProvider/UnsavedChangesProvider.js +57 -0
  71. package/components/UnsavedChangesProvider/unsaved-changes-context.d.ts +44 -0
  72. package/components/UnsavedChangesProvider/unsaved-changes-context.d.ts.map +1 -0
  73. package/components/UnsavedChangesProvider/unsaved-changes-context.js +13 -0
  74. package/constants/breakpoint.d.ts +6 -0
  75. package/constants/breakpoint.d.ts.map +1 -1
  76. package/constants/breakpoint.js +2 -2
  77. package/conversation-transfer/conversation-transfer-queue.d.ts +16 -0
  78. package/conversation-transfer/conversation-transfer-queue.d.ts.map +1 -0
  79. package/conversation-transfer/conversation-transfer-queue.js +24 -0
  80. package/entry-points/markdown.d.ts +1 -0
  81. package/entry-points/markdown.d.ts.map +1 -1
  82. package/file-manager/DialFileManagerShell/DialFileManagerShell.d.ts +15 -0
  83. package/file-manager/DialFileManagerShell/DialFileManagerShell.d.ts.map +1 -1
  84. package/file-manager/DialFileManagerShell/DialFileManagerShell.js +330 -266
  85. package/file-manager/DialFileManagerShell/DialFileManagerShell.module.scss.js +8 -0
  86. package/file-manager/FileManagerAttachModal/FileManagerAttachModal.d.ts +7 -0
  87. package/file-manager/FileManagerAttachModal/FileManagerAttachModal.d.ts.map +1 -1
  88. package/file-manager/FileManagerAttachModal/FileManagerAttachModal.js +85 -80
  89. package/file-manager/FileManagerAttachModal/FileManagerAttachModal.module.scss.js +7 -0
  90. package/file-manager/OperationLoaderModal/OperationLoaderModal.d.ts +5 -0
  91. package/file-manager/OperationLoaderModal/OperationLoaderModal.d.ts.map +1 -1
  92. package/file-manager/OperationLoaderModal/OperationLoaderModal.js +25 -20
  93. package/file-manager/OperationLoaderModal/OperationLoaderModal.module.scss.js +4 -0
  94. package/file-manager/file-manager-controller.d.ts +11 -3
  95. package/file-manager/file-manager-controller.d.ts.map +1 -1
  96. package/file-manager/index.d.ts +1 -0
  97. package/file-manager/index.d.ts.map +1 -1
  98. package/file-manager/labels.d.ts +23 -2
  99. package/file-manager/labels.d.ts.map +1 -1
  100. package/file-manager/shell-styles.d.ts +37 -0
  101. package/file-manager/shell-styles.d.ts.map +1 -0
  102. package/file-manager/upload-batch.d.ts +46 -0
  103. package/file-manager/upload-batch.d.ts.map +1 -1
  104. package/file-manager/upload-batch.js +6 -2
  105. package/file-manager/upload-queue.d.ts +44 -4
  106. package/file-manager/upload-queue.d.ts.map +1 -1
  107. package/file-manager/upload-queue.js +45 -13
  108. package/file-manager.js +4 -4
  109. package/hooks/useAvailableHeightCap.js +1 -1
  110. package/hooks/useControlErrorAssociation.d.ts +3 -0
  111. package/hooks/useControlErrorAssociation.d.ts.map +1 -0
  112. package/hooks/useControlErrorAssociation.js +12 -0
  113. package/hooks/useIsMobile.js +1 -1
  114. package/hooks/useIsPhone.d.ts +3 -0
  115. package/hooks/useIsPhone.d.ts.map +1 -0
  116. package/hooks/useIsPhone.js +13 -0
  117. package/hooks/useIsTablet.d.ts +3 -0
  118. package/hooks/useIsTablet.d.ts.map +1 -0
  119. package/hooks/useIsTablet.js +13 -0
  120. package/hooks/useIsTextClipped.d.ts +26 -0
  121. package/hooks/useIsTextClipped.d.ts.map +1 -0
  122. package/hooks/useIsTextClipped.js +25 -0
  123. package/hooks/useIsVerticallyClamped.d.ts +16 -0
  124. package/hooks/useIsVerticallyClamped.d.ts.map +1 -0
  125. package/hooks/useIsVerticallyClamped.js +20 -0
  126. package/hooks/useTextRefinement.d.ts +1 -1
  127. package/hooks/useTextRefinement.d.ts.map +1 -1
  128. package/hooks/useTextRefinement.js +4 -4
  129. package/hooks/useUnsavedChangesGuard.js +1 -5
  130. package/hooks/useUnsavedChangesLeaveConfirmation.d.ts +12 -0
  131. package/hooks/useUnsavedChangesLeaveConfirmation.d.ts.map +1 -0
  132. package/hooks/useUnsavedChangesLeaveConfirmation.js +22 -0
  133. package/hooks/useUnsavedChangesLeaveGuard.d.ts +24 -0
  134. package/hooks/useUnsavedChangesLeaveGuard.d.ts.map +1 -0
  135. package/hooks/useUnsavedChangesLeaveGuard.js +24 -0
  136. package/index.css +3 -2
  137. package/index.d.ts +17 -0
  138. package/index.d.ts.map +1 -1
  139. package/index.js +93 -76
  140. package/markdown.js +3 -2
  141. package/models/auth.d.ts +2 -0
  142. package/models/auth.d.ts.map +1 -1
  143. package/models/chat.d.ts +2 -0
  144. package/models/chat.d.ts.map +1 -1
  145. package/models/conversation-classification.d.ts +5 -0
  146. package/models/conversation-classification.d.ts.map +1 -1
  147. package/models/conversation-classification.js +3 -1
  148. package/models/inline-segment.d.ts +11 -0
  149. package/models/inline-segment.d.ts.map +1 -0
  150. package/models/text-refinement.d.ts +6 -2
  151. package/models/text-refinement.d.ts.map +1 -1
  152. package/package.json +10 -17
  153. package/utils/base64-json.d.ts +14 -0
  154. package/utils/base64-json.d.ts.map +1 -0
  155. package/utils/base64-json.js +4 -0
  156. package/utils/dom.d.ts +8 -0
  157. package/utils/dom.d.ts.map +1 -0
  158. package/utils/dom.js +10 -0
  159. package/utils/format-price.js +10 -10
  160. package/utils/inline-segments.d.ts +38 -0
  161. package/utils/inline-segments.d.ts.map +1 -0
  162. package/utils/inline-segments.js +53 -0
  163. package/utils/latex.d.ts +4 -3
  164. package/utils/latex.d.ts.map +1 -1
  165. package/utils/latex.js +47 -41
  166. package/utils/markdown-html.d.ts +14 -0
  167. package/utils/markdown-html.d.ts.map +1 -0
  168. package/utils/markdown-html.js +11 -0
  169. package/utils/message-attachment-to-display.js +1 -1
  170. package/utils/mime-type.js +1 -1
  171. package/utils/prompt-variables.js +5 -9
  172. package/utils/syntax-highlighting.js +8 -8
@@ -0,0 +1,38 @@
1
+ import { Components } from 'react-markdown';
2
+ import { InlineTextSegment, TextSegment } from '../models/inline-segment';
3
+ /** Minimal hast shapes the inline-segment plugin reads and writes. */
4
+ interface HastNode {
5
+ type: string;
6
+ tagName?: string;
7
+ value?: string;
8
+ properties?: Record<string, unknown>;
9
+ children?: HastNode[];
10
+ }
11
+ /** Markdown source with inline segments replaced by placeholder tokens. */
12
+ export interface InlineSegmentSource {
13
+ /** Markdown source to render, with one token per inline segment. */
14
+ source: string;
15
+ /** Inline segments in token order; a token's number is its index here. */
16
+ inlineSegments: InlineTextSegment[];
17
+ }
18
+ /**
19
+ * Returns the markdown source for `segments`, with every inline segment
20
+ * replaced by a placeholder token, or the plain concatenated text (and no
21
+ * inline segments) when a string run already contains a token character.
22
+ */
23
+ export declare const buildInlineSegmentSource: (segments: TextSegment[]) => InlineSegmentSource;
24
+ /**
25
+ * Returns a rehype plugin that turns each placeholder token from
26
+ * {@link buildInlineSegmentSource} into an inline-segment element, or into
27
+ * the segment's literal text inside code, preformatted and link elements and
28
+ * inside `href`/`src` values. Run it after sanitization, which would strip
29
+ * the element.
30
+ */
31
+ export declare const createRehypeInlineSegments: (inlineSegments: InlineTextSegment[]) => () => (tree: HastNode) => void;
32
+ /**
33
+ * Returns the react-markdown component overrides that render each
34
+ * inline-segment element as its segment's `node`.
35
+ */
36
+ export declare const createInlineSegmentComponents: (inlineSegments: InlineTextSegment[]) => Components;
37
+ export {};
38
+ //# sourceMappingURL=inline-segments.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inline-segments.d.ts","sourceRoot":"","sources":["../../src/utils/inline-segments.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AA6B/E,sEAAsE;AACtE,UAAU,QAAQ;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACrC,QAAQ,CAAC,EAAE,QAAQ,EAAE,CAAC;CACvB;AAED,2EAA2E;AAC3E,MAAM,WAAW,mBAAmB;IAClC,oEAAoE;IACpE,MAAM,EAAE,MAAM,CAAC;IACf,0EAA0E;IAC1E,cAAc,EAAE,iBAAiB,EAAE,CAAC;CACrC;AAQD;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,GACnC,UAAU,WAAW,EAAE,KACtB,mBAuBF,CAAC;AA+EF;;;;;;GAMG;AACH,eAAO,MAAM,0BAA0B,GACpC,gBAAgB,iBAAiB,EAAE,YAAY,MAAM,QAAQ,SAE7D,CAAC;AAQJ;;;GAGG;AACH,eAAO,MAAM,6BAA6B,GACxC,gBAAgB,iBAAiB,EAAE,KAClC,UAWF,CAAC"}
@@ -0,0 +1,53 @@
1
+ //#region src/utils/inline-segments.ts
2
+ var e = "", t = "", n = RegExp(`${e}(\\d+)${t}`, "g"), r = RegExp(`${encodeURI(e)}(\\d+)${encodeURI(t)}`, "gi"), i = "dial-inline-segment", a = /* @__PURE__ */ new Set([
3
+ "code",
4
+ "pre",
5
+ "a"
6
+ ]), o = ["href", "src"], s = (e) => typeof e != "string", c = (n) => n.includes(e) || n.includes(t), l = (n) => {
7
+ if (n.some((e) => !s(e) && c(e))) return {
8
+ source: n.map((e) => s(e) ? e.text : e).join(""),
9
+ inlineSegments: []
10
+ };
11
+ let r = [];
12
+ return {
13
+ source: n.map((n) => s(n) ? (r.push(n), `${e}${r.length - 1}${t}`) : n).join(""),
14
+ inlineSegments: r
15
+ };
16
+ }, u = (e, t) => e.replace(n, (e, n) => t[Number(n)]?.text ?? e), d = (e) => {
17
+ let t = [], r = 0;
18
+ for (let a of e.matchAll(n)) a.index > r && t.push({
19
+ type: "text",
20
+ value: e.slice(r, a.index)
21
+ }), t.push({
22
+ type: "element",
23
+ tagName: i,
24
+ properties: { dataIndex: Number(a[1]) },
25
+ children: []
26
+ }), r = a.index + a[0].length;
27
+ return r < e.length && t.push({
28
+ type: "text",
29
+ value: e.slice(r)
30
+ }), t;
31
+ }, f = (e, t) => {
32
+ e.properties != null && o.forEach((n) => {
33
+ let i = e.properties?.[n];
34
+ typeof i == "string" && e.properties && (e.properties[n] = u(i, t).replace(r, (e, n) => {
35
+ let r = t[Number(n)]?.text;
36
+ return r == null ? e : encodeURI(r);
37
+ }));
38
+ });
39
+ }, p = (e, t, n) => {
40
+ if (f(e, t), e.children == null) return;
41
+ let r = n || e.tagName != null && a.has(e.tagName);
42
+ e.children = e.children.flatMap((e) => e.type !== "text" || e.value == null ? (p(e, t, r), [e]) : r ? [{
43
+ ...e,
44
+ value: u(e.value, t)
45
+ }] : d(e.value));
46
+ }, m = (e) => () => (t) => {
47
+ p(t, e, !1);
48
+ }, h = (e) => {
49
+ let t = ({ node: t }) => e[Number(t?.properties?.dataIndex)]?.node ?? null;
50
+ return { [i]: t };
51
+ };
52
+ //#endregion
53
+ export { l as buildInlineSegmentSource, h as createInlineSegmentComponents, m as createRehypeInlineSegments };
package/utils/latex.d.ts CHANGED
@@ -13,9 +13,10 @@
13
13
  * open, not against the few characters after the amount: `$1 - \frac{3}{p} < 1$` reads as
14
14
  * a price for one character and as LaTeX for the rest of the line.
15
15
  *
16
- * The `\(...\)`/`\[...\]` delimiters LLMs commonly emit are deliberately left as-is: they are
17
- * recognized directly by `micromark-extension-llm-math`, which the consuming app's bundler
18
- * config aliases in place of the default `micromark-extension-math` used by `remark-math`.
16
+ * The `\(...\)`/`\[...\]` delimiters LLMs commonly emit are left as-is around a formula: they
17
+ * are recognized directly by `micromark-extension-llm-math`, which the consuming app's bundler
18
+ * config aliases in place of the default `micromark-extension-math` used by `remark-math`. A
19
+ * pair wrapping a link or a URL is escaped prose and is turned back into literal brackets.
19
20
  */
20
21
  export declare const preprocessLaTeX: (content: string) => string;
21
22
  //# sourceMappingURL=latex.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"latex.d.ts","sourceRoot":"","sources":["../../src/utils/latex.ts"],"names":[],"mappings":"AA0SA;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,eAAe,GAAI,SAAS,MAAM,KAAG,MAoEjD,CAAC"}
1
+ {"version":3,"file":"latex.d.ts","sourceRoot":"","sources":["../../src/utils/latex.ts"],"names":[],"mappings":"AAuWA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,eAAe,GAAI,SAAS,MAAM,KAAG,MAoEjD,CAAC"}
package/utils/latex.js CHANGED
@@ -1,15 +1,23 @@
1
1
  //#region src/utils/latex.ts
2
- var e = /\$\\ce\{/g, t = /\$\\pu\{/g, n = /\$\\\\ce\{[^}]*\}\$/g, r = /\$\\\\pu\{[^}]*\}\$/g, i = /\$\$([\s\S]*?)\$\$/g, a = /^[ \t]*\r?\n/, o = /\r?\n[ \t]*$/, s = /\d+(?:,\d{3})*(?:\.\d+)?(?:[KMBkmb])?/y, c = /\s|[^a-zA-Z\d]/y, l = /[\^_\\]/y, u = /(?:[<>]|\\(?:le|leq|ll|ge|geq|gg|ne|neq|approx|equiv|sim|simeq|cong|in|notin|subset|subseteq|supset|supseteq|to|rightarrow|leftarrow|mapsto|implies|iff)\b)/y, d = /\\[a-zA-Z]|[\^_]/, f = (i) => {
2
+ var e = /\$\\ce\{/g, t = /\$\\pu\{/g, n = /\$\\\\ce\{[^}]*\}\$/g, r = /\$\\\\pu\{[^}]*\}\$/g, i = /\]\(|:\/\//, a = {
3
+ "[": "]",
4
+ "(": ")"
5
+ }, o = {
6
+ "[": "&#91;",
7
+ "]": "&#93;",
8
+ "(": "&#40;",
9
+ ")": "&#41;"
10
+ }, s = /\$\$([\s\S]*?)\$\$/g, c = /^[ \t]*\r?\n/, l = /\r?\n[ \t]*$/, u = /\d+(?:,\d{3})*(?:\.\d+)?(?:[KMBkmb])?/y, d = /\s|[^a-zA-Z\d]/y, f = /[\^_\\]/y, p = /(?:[<>]|\\(?:le|leq|ll|ge|geq|gg|ne|neq|approx|equiv|sim|simeq|cong|in|notin|subset|subseteq|supset|supseteq|to|rightarrow|leftarrow|mapsto|implies|iff)\b)/y, m = /\\[a-zA-Z]|[\^_]/, h = (i) => {
3
11
  let a = i.replace(e, "$\\\\ce{");
4
12
  return a = a.replace(t, "$\\\\pu{"), a = a.replace(n, (e) => `$${e}$`), a = a.replace(r, (e) => `$${e}$`), a;
5
- }, p = (e) => {
13
+ }, g = (e) => {
6
14
  let t = [], n = -1, r = -1;
7
15
  for (let i = 0; i < e.length; i++) {
8
16
  let a = e[i];
9
17
  a === "`" && i + 2 < e.length && e[i + 1] === "`" && e[i + 2] === "`" ? r === -1 ? (r = i, i += 2) : (t.push([r, i + 2]), r = -1, i += 2) : a === "`" && r === -1 && (n === -1 ? n = i : (t.push([n, i]), n = -1));
10
18
  }
11
19
  return t;
12
- }, m = (e, t) => {
20
+ }, _ = (e, t) => {
13
21
  let n = 0, r = t.length - 1;
14
22
  for (; n <= r;) {
15
23
  let i = Math.floor((n + r) / 2), [a, o] = t[i];
@@ -17,60 +25,58 @@ var e = /\$\\ce\{/g, t = /\$\\pu\{/g, n = /\$\\\\ce\{[^}]*\}\$/g, r = /\$\\\\pu\
17
25
  e < a ? r = i - 1 : n = i + 1;
18
26
  }
19
27
  return !1;
20
- }, h = (e, t, n) => (e.lastIndex = n, e.exec(t)), g = /\s/, _ = (e, t) => {
28
+ }, v = (e, t, n) => (e.lastIndex = n, e.exec(t)), y = /\s/, b = (e, t) => {
21
29
  let n = t;
22
- for (; n < e.length && g.test(e[n]);) n++;
30
+ for (; n < e.length && y.test(e[n]);) n++;
23
31
  return n;
24
- }, v = (e) => {
32
+ }, x = (e) => {
25
33
  if (!e.includes("$$")) return e;
26
- let t = p(e), n = [], r = 0, s;
27
- for (i.lastIndex = 0; (s = i.exec(e)) !== null;) {
28
- let i = s.index, c = i + s[0].length, l = s[1];
29
- if (m(i, t)) continue;
30
- let u = e.lastIndexOf("\n", i - 1) + 1;
31
- if (e.slice(u, i).trim() !== "") continue;
32
- let d = e.indexOf("\n", c), f = e.slice(c, d === -1 ? e.length : d);
33
- if (!l.includes("\n") && (f.trim() !== "" || l.trim() === "")) continue;
34
- let p = l.replace(a, "").replace(o, "");
35
- n.push(e.slice(r, i)), n.push(`$$\n${p}\n$$${f.trim() === "" ? "" : "\n"}`), r = c;
34
+ let t = g(e), n = [], r = 0, i;
35
+ for (s.lastIndex = 0; (i = s.exec(e)) !== null;) {
36
+ let a = i.index, o = a + i[0].length, s = i[1];
37
+ if (_(a, t)) continue;
38
+ let u = e.lastIndexOf("\n", a - 1) + 1;
39
+ if (e.slice(u, a).trim() !== "") continue;
40
+ let d = e.indexOf("\n", o), f = e.slice(o, d === -1 ? e.length : d);
41
+ if (!s.includes("\n") && (f.trim() !== "" || s.trim() === "")) continue;
42
+ let p = s.replace(c, "").replace(l, "");
43
+ n.push(e.slice(r, a)), n.push(`$$\n${p}\n$$${f.trim() === "" ? "" : "\n"}`), r = o;
36
44
  }
37
45
  return n.push(e.substring(r)), n.join("");
38
- }, y = (e, t) => {
39
- let n = h(s, e, t + 1);
46
+ }, S = (e) => {
47
+ if (!e.includes("\\[") && !e.includes("\\(")) return e;
48
+ let t = g(e), n = [], r = 0;
49
+ for (let s = 0; s < e.length - 1; s++) {
50
+ let c = e[s + 1], l = a[c];
51
+ if (e[s] !== "\\" || l == null || s > 0 && e[s - 1] === "\\" || _(s, t)) continue;
52
+ let u = e.indexOf(`\\${l}`, s + 2);
53
+ u !== -1 && i.test(e.slice(s + 2, u)) && (n.push(e.slice(r, s), o[c], e.slice(s + 2, u), o[l]), r = u + 2, s = u + 1);
54
+ }
55
+ return r === 0 ? e : (n.push(e.substring(r)), n.join(""));
56
+ }, C = (e, t) => {
57
+ let n = v(u, e, t + 1);
40
58
  return n ? t + 1 + n[0].length : -1;
41
- }, b = (e, t) => t >= e.length ? !0 : !(!h(c, e, t) || h(l, e, t) || h(u, e, _(e, t))), x = (e, t) => {
59
+ }, w = (e, t) => t >= e.length || !(!v(d, e, t) || v(f, e, t) || v(p, e, b(e, t))), T = (e, t) => {
42
60
  let n = [];
43
61
  for (let r = 0; r < e.length; r++) {
44
62
  if (e[r] !== "$") continue;
45
63
  let i = r;
46
64
  for (; i + 1 < e.length && e[i + 1] === "$";) i++;
47
- if (i > r) {
48
- r = i;
49
- continue;
50
- }
51
- r > 0 && e[r - 1] === "\\" || m(r, t) || n.push(r);
65
+ i > r ? r = i : r > 0 && e[r - 1] === "\\" || _(r, t) || n.push(r);
52
66
  }
53
67
  return n;
54
- }, S = (e, t, n, r) => {
68
+ }, E = (e, t, n, r) => {
55
69
  if (n <= t + 1 || e[n - 1] === "`") return !1;
56
70
  for (let i = t + 1; i < n; i++) if (e[i] === "\n" || e[i] === "$" && !(e[i - 1] === "\\" || r.has(i))) return !1;
57
71
  return !0;
58
- }, C = (e, t, n, r) => n !== void 0 && S(e, t, n, r) && d.test(e.slice(t + 1, n)), w = (e) => {
59
- if (!e.includes("$")) return e;
60
- let t = e;
61
- (e.includes("\\ce{") || e.includes("\\pu{")) && (t = f(e)), t = v(t);
62
- let n = p(t), r = x(t, n), i = /* @__PURE__ */ new Map(), a = -1;
72
+ }, D = (e, t, n, r) => n !== void 0 && E(e, t, n, r) && m.test(e.slice(t + 1, n)), O = (e) => {
73
+ let t = S(e);
74
+ if (!t.includes("$")) return t;
75
+ (t.includes("\\ce{") || t.includes("\\pu{")) && (t = h(t)), t = x(t);
76
+ let n = g(t), r = T(t, n), i = /* @__PURE__ */ new Map(), a = -1;
63
77
  for (let e = 0; e < r.length; e++) {
64
- let n = r[e], o = y(t, n);
65
- if (o !== -1 && b(t, o) && (a !== -1 || !C(t, n, r[e + 1], i))) {
66
- i.set(n, "\\$"), a === -1 && r[e + 1] === o && (i.set(o, "\\$"), e++);
67
- continue;
68
- }
69
- if (a === -1) {
70
- a = n;
71
- continue;
72
- }
73
- S(t, a, n, i) ? (i.set(a, "$$"), i.set(n, "$$"), a = -1) : a = n;
78
+ let n = r[e], o = C(t, n);
79
+ o !== -1 && w(t, o) && (a !== -1 || !D(t, n, r[e + 1], i)) ? (i.set(n, "\\$"), a === -1 && r[e + 1] === o && (i.set(o, "\\$"), e++)) : a === -1 ? a = n : E(t, a, n, i) ? (i.set(a, "$$"), i.set(n, "$$"), a = -1) : a = n;
74
80
  }
75
81
  if (i.size === 0) return t;
76
82
  let o = [], s = 0;
@@ -78,4 +84,4 @@ var e = /\$\\ce\{/g, t = /\$\\pu\{/g, n = /\$\\\\ce\{[^}]*\}\$/g, r = /\$\\\\pu\
78
84
  return o.push(t.substring(s)), o.join("");
79
85
  };
80
86
  //#endregion
81
- export { w as preprocessLaTeX };
87
+ export { O as preprocessLaTeX };
@@ -0,0 +1,14 @@
1
+ /** Minimal hast shape this plugin reads and writes. */
2
+ interface HastNode {
3
+ type: string;
4
+ value?: string;
5
+ children?: HastNode[];
6
+ }
7
+ /**
8
+ * Rehype plugin that turns every raw HTML node into a text node, so markup in
9
+ * the source renders as the literal characters the author typed instead of
10
+ * being dropped by sanitization.
11
+ */
12
+ export declare const rehypeRawAsText: () => (tree: HastNode) => void;
13
+ export {};
14
+ //# sourceMappingURL=markdown-html.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"markdown-html.d.ts","sourceRoot":"","sources":["../../src/utils/markdown-html.ts"],"names":[],"mappings":"AAAA,uDAAuD;AACvD,UAAU,QAAQ;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,QAAQ,EAAE,CAAC;CACvB;AAcD;;;;GAIG;AACH,eAAO,MAAM,eAAe,SAAU,MAAM,QAAQ,SAEnD,CAAC"}
@@ -0,0 +1,11 @@
1
+ //#region src/utils/markdown-html.ts
2
+ var e = (t) => {
3
+ t.children != null && (t.children = t.children.map((t) => t.type === "raw" ? {
4
+ type: "text",
5
+ value: t.value ?? ""
6
+ } : (e(t), t)));
7
+ }, t = () => (t) => {
8
+ e(t);
9
+ };
10
+ //#endregion
11
+ export { t as rehypeRawAsText };
@@ -3,7 +3,7 @@ import { AttachmentType as t } from "../types/attachment.js";
3
3
  import { getAttachmentTypeFromMime as n, inferMimeTypeFromPath as r } from "./mime-type.js";
4
4
  //#region src/utils/message-attachment-to-display.ts
5
5
  var i = (e, t, n) => {
6
- if (!(!e?.startsWith(n) || !t)) return `data:${e};base64,${t}`;
6
+ if (e?.startsWith(n) && t) return `data:${e};base64,${t}`;
7
7
  }, a = (a, o = {}) => {
8
8
  let s = n(a.type), c = s === t.Image, l = s === t.Audio, u = a.url && a.reference_url && !a.reference_type, d = a.url ?? a.data ?? a.title, f = (a.url == null && a.reference_url != null ? a.reference_type ?? r(a.reference_url) : void 0) ?? a.type ?? "", p;
9
9
  c && (a.url ? p = o.resolvePreviewUrl?.(a) ?? a.url : a.data && (p = i(a.type, a.data, "image/")));
@@ -71,7 +71,7 @@ var r = {
71
71
  return n[t] ?? t;
72
72
  }, o = (e) => e.split(/[?#]/)[0], s = (e) => {
73
73
  let t = o(e), n = t.lastIndexOf(".");
74
- if (n !== -1) return r[t.slice(n + 1).toLowerCase()];
74
+ return n === -1 ? void 0 : r[t.slice(n + 1).toLowerCase()];
75
75
  }, c = (t) => t?.startsWith("image/") ? e.Image : t?.startsWith("audio/") ? e.Audio : e.File;
76
76
  //#endregion
77
77
  export { c as getAttachmentTypeFromMime, i as getBaseMimeType, s as inferMimeTypeFromPath, a as normalizeMimeType, o as stripUrlQueryAndFragment };
@@ -1,5 +1,5 @@
1
1
  //#region src/utils/prompt-variables.ts
2
- var e = /\{\{([^{}]+)\}\}/g, t = "cat-prompt-variable", n = new Set(["code", "pre"]), r = (n) => {
2
+ var e = /\{\{([^{}]+)\}\}/g, t = "cat-prompt-variable", n = /* @__PURE__ */ new Set(["code", "pre"]), r = (n) => {
3
3
  e.lastIndex = 0;
4
4
  let r = [], i = 0, a = e.exec(n);
5
5
  for (; a != null;) a.index > i && r.push({
@@ -21,14 +21,10 @@ var e = /\{\{([^{}]+)\}\}/g, t = "cat-prompt-variable", n = new Set(["code", "pr
21
21
  }, i = (e) => {
22
22
  if (e.children == null || e.tagName != null && n.has(e.tagName)) return;
23
23
  let t = [];
24
- for (let n of e.children) {
25
- if (n.type === "text" && n.value != null) {
26
- let e = r(n.value);
27
- t.push(...e ?? [n]);
28
- continue;
29
- }
30
- i(n), t.push(n);
31
- }
24
+ for (let n of e.children) if (n.type === "text" && n.value != null) {
25
+ let e = r(n.value);
26
+ t.push(...e ?? [n]);
27
+ } else i(n), t.push(n);
32
28
  e.children = t;
33
29
  }, a = () => (e) => {
34
30
  i(e);
@@ -1,13 +1,13 @@
1
1
  //#region src/utils/syntax-highlighting.ts
2
- var e = 5e4, t = 2e3, n = (n) => {
3
- if (n.length > e) return !1;
4
- let r = 0;
5
- for (let e = 0; e < n.length; e++) {
6
- let i = n[e];
7
- if (i === "\n" || i === "\r") r = 0;
8
- else if (++r > t) return !1;
2
+ var e = (e) => {
3
+ if (e.length > 5e4) return !1;
4
+ let t = 0;
5
+ for (let n = 0; n < e.length; n++) {
6
+ let r = e[n];
7
+ if (r === "\n" || r === "\r") t = 0;
8
+ else if (++t > 2e3) return !1;
9
9
  }
10
10
  return !0;
11
11
  };
12
12
  //#endregion
13
- export { n as isSyntaxHighlightingAllowed };
13
+ export { e as isSyntaxHighlightingAllowed };