@carbon/ai-chat-components 1.4.0 → 1.5.0-rc.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 (96) hide show
  1. package/custom-elements.json +1262 -709
  2. package/es/components/chat-history/src/chat-history.scss.js +1 -1
  3. package/es/components/chat-history/src/history-panel-item.d.ts +14 -0
  4. package/es/components/chat-history/src/history-panel-item.js +30 -0
  5. package/es/components/chat-history/src/history-panel-item.js.map +1 -1
  6. package/es/components/code-snippet/src/code-snippet.d.ts +5 -0
  7. package/es/components/code-snippet/src/code-snippet.js +17 -5
  8. package/es/components/code-snippet/src/code-snippet.js.map +1 -1
  9. package/es/components/feedback/src/feedback.d.ts +4 -0
  10. package/es/components/feedback/src/feedback.js +6 -4
  11. package/es/components/feedback/src/feedback.js.map +1 -1
  12. package/es/components/markdown/index.d.ts +3 -1
  13. package/es/components/markdown/index.js +1 -1
  14. package/es/components/markdown/src/markdown-renderer-types.d.ts +100 -0
  15. package/es/components/markdown/src/markdown-renderer-types.js +8 -0
  16. package/es/components/markdown/src/markdown-renderer-types.js.map +1 -0
  17. package/es/components/markdown/src/markdown-renderer.d.ts +14 -64
  18. package/es/components/markdown/src/markdown-renderer.js +110 -131
  19. package/es/components/markdown/src/markdown-renderer.js.map +1 -1
  20. package/es/components/markdown/src/markdown-token-tree.d.ts +50 -5
  21. package/es/components/markdown/src/markdown-token-tree.js +182 -47
  22. package/es/components/markdown/src/markdown-token-tree.js.map +1 -1
  23. package/es/components/markdown/src/markdown.d.ts +49 -1
  24. package/es/components/markdown/src/markdown.js +317 -106
  25. package/es/components/markdown/src/markdown.js.map +1 -1
  26. package/es/components/markdown/src/plugins/markdown-it-task-lists.js +2 -5
  27. package/es/components/markdown/src/plugins/markdown-it-task-lists.js.map +1 -1
  28. package/es/components/markdown/src/utils/lit-directives.d.ts +17 -0
  29. package/es/components/markdown/src/utils/lit-directives.js +84 -0
  30. package/es/components/markdown/src/utils/lit-directives.js.map +1 -0
  31. package/es/components/markdown/src/utils/plugin-fallback.d.ts +33 -0
  32. package/es/components/markdown/src/utils/plugin-fallback.js +216 -0
  33. package/es/components/markdown/src/utils/plugin-fallback.js.map +1 -0
  34. package/es/components/markdown/src/utils/streaming-table.d.ts +28 -0
  35. package/es/components/markdown/src/utils/streaming-table.js +86 -0
  36. package/es/components/markdown/src/utils/streaming-table.js.map +1 -0
  37. package/es/components/markdown/src/utils/table-helpers.d.ts +17 -0
  38. package/es/components/markdown/src/utils/table-helpers.js +104 -2
  39. package/es/components/markdown/src/utils/table-helpers.js.map +1 -1
  40. package/es/components/table/src/table.js +4 -1
  41. package/es/components/table/src/table.js.map +1 -1
  42. package/es/components/workspace-shell/src/workspace-shell.scss.js +1 -1
  43. package/es/react/markdown.d.ts +46 -2
  44. package/es/react/markdown.js +177 -20
  45. package/es/react/markdown.js.map +1 -1
  46. package/es-custom/components/chat-history/src/chat-history.scss.js +1 -1
  47. package/es-custom/components/chat-history/src/history-panel-item.d.ts +14 -0
  48. package/es-custom/components/chat-history/src/history-panel-item.js +30 -0
  49. package/es-custom/components/chat-history/src/history-panel-item.js.map +1 -1
  50. package/es-custom/components/code-snippet/src/code-snippet.d.ts +5 -0
  51. package/es-custom/components/code-snippet/src/code-snippet.js +17 -5
  52. package/es-custom/components/code-snippet/src/code-snippet.js.map +1 -1
  53. package/es-custom/components/feedback/src/feedback.d.ts +4 -0
  54. package/es-custom/components/feedback/src/feedback.js +6 -4
  55. package/es-custom/components/feedback/src/feedback.js.map +1 -1
  56. package/es-custom/components/markdown/index.d.ts +3 -1
  57. package/es-custom/components/markdown/index.js +1 -1
  58. package/es-custom/components/markdown/src/markdown-renderer-types.d.ts +100 -0
  59. package/es-custom/components/markdown/src/markdown-renderer-types.js +8 -0
  60. package/es-custom/components/markdown/src/markdown-renderer-types.js.map +1 -0
  61. package/es-custom/components/markdown/src/markdown-renderer.d.ts +14 -64
  62. package/es-custom/components/markdown/src/markdown-renderer.js +110 -131
  63. package/es-custom/components/markdown/src/markdown-renderer.js.map +1 -1
  64. package/es-custom/components/markdown/src/markdown-token-tree.d.ts +50 -5
  65. package/es-custom/components/markdown/src/markdown-token-tree.js +182 -47
  66. package/es-custom/components/markdown/src/markdown-token-tree.js.map +1 -1
  67. package/es-custom/components/markdown/src/markdown.d.ts +49 -1
  68. package/es-custom/components/markdown/src/markdown.js +317 -106
  69. package/es-custom/components/markdown/src/markdown.js.map +1 -1
  70. package/es-custom/components/markdown/src/plugins/markdown-it-task-lists.js +2 -5
  71. package/es-custom/components/markdown/src/plugins/markdown-it-task-lists.js.map +1 -1
  72. package/es-custom/components/markdown/src/utils/lit-directives.d.ts +17 -0
  73. package/es-custom/components/markdown/src/utils/lit-directives.js +84 -0
  74. package/es-custom/components/markdown/src/utils/lit-directives.js.map +1 -0
  75. package/es-custom/components/markdown/src/utils/plugin-fallback.d.ts +33 -0
  76. package/es-custom/components/markdown/src/utils/plugin-fallback.js +216 -0
  77. package/es-custom/components/markdown/src/utils/plugin-fallback.js.map +1 -0
  78. package/es-custom/components/markdown/src/utils/streaming-table.d.ts +28 -0
  79. package/es-custom/components/markdown/src/utils/streaming-table.js +86 -0
  80. package/es-custom/components/markdown/src/utils/streaming-table.js.map +1 -0
  81. package/es-custom/components/markdown/src/utils/table-helpers.d.ts +17 -0
  82. package/es-custom/components/markdown/src/utils/table-helpers.js +104 -2
  83. package/es-custom/components/markdown/src/utils/table-helpers.js.map +1 -1
  84. package/es-custom/components/table/src/table.js +4 -1
  85. package/es-custom/components/table/src/table.js.map +1 -1
  86. package/es-custom/components/workspace-shell/src/workspace-shell.scss.js +1 -1
  87. package/es-custom/react/markdown.d.ts +46 -2
  88. package/es-custom/react/markdown.js +177 -20
  89. package/es-custom/react/markdown.js.map +1 -1
  90. package/package.json +5 -4
  91. package/es/components/markdown/src/utils.d.ts +0 -4
  92. package/es/components/markdown/src/utils.js +0 -25
  93. package/es/components/markdown/src/utils.js.map +0 -1
  94. package/es-custom/components/markdown/src/utils.d.ts +0 -4
  95. package/es-custom/components/markdown/src/utils.js +0 -25
  96. package/es-custom/components/markdown/src/utils.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"markdown-it-task-lists.js","sources":["../../../../../src/components/markdown/src/plugins/markdown-it-task-lists.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;AAAA;;;;;;;AAOG;AAgBH,SAAS,mBAAmB,CAAC,EAAc,EAAA;AACzC,IAAA,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,EAAE,YAAY,EAAE,CAAC,KAAgB,KAAI;AAC/D,QAAA,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM;AAE3B,QAAA,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;AACtC,YAAA,MAAM,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC;;AAGvB,YAAA,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ,EAAE;gBAC3B;YACF;;AAGA,YAAA,IAAI,CAAC,GAAG,CAAC,IAAI,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,KAAK,gBAAgB,EAAE;gBACpD;YACF;AAEA,YAAA,MAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ;YAC/B,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE;gBACtC;YACF;;AAGA,YAAA,MAAM,UAAU,GAAG,QAAQ,CAAC,CAAC,CAAC;AAC9B,YAAA,IAAI,UAAU,CAAC,IAAI,KAAK,MAAM,EAAE;gBAC9B;YACF;YAEA,MAAM,KAAK,GAAG,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,iBAAiB,CAAC;YACzD,IAAI,CAAC,KAAK,EAAE;gBACV;YACF;YAEA,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC,KAAK,GAAG;YAChC,MAAM,aAAa,GAAG,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AAC,KAAK,GAAG,KAAK,OAAO,CAAC;AAC9D,YAAA,IAAI,UAAU,IAAI,CAAC,EAAE;gBACnB,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,iBAAiB;YAC3C;iBAAO;gBACL,KAAK,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAAC;YACzC;AACA,YAAA,aAAa,CAAC,KAAK,GAAG,KAAK;AAE3B,YAAA,MAAM,iBAAiB,GAAU,IAAI,KAAK,CAAC,KAAK,CAC9C,oBAAoB,EACpB,cAAc,EACd,CAAC,CACF;AACD,YAAA,iBAAiB,CAAC,OAAO,GAAG,EAAE;AAC9B,YAAA,iBAAiB,CAAC,KAAK,GAAG,CAAC,CAAC,SAAS,EAAE,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC;AAEnE,YAAA,MAAM,kBAAkB,GAAU,IAAI,KAAK,CAAC,KAAK,CAC/C,qBAAqB,EACrB,cAAc,EACd,EAAE,CACH;AACD,YAAA,kBAAkB,CAAC,OAAO,GAAG,EAAE;;AAG/B,YAAA,UAAU,CAAC,OAAO,GAAG,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;;AAG9D,YAAA,QAAQ,CAAC,OAAO,CAAC,iBAAiB,CAAC;AACnC,YAAA,QAAQ,CAAC,IAAI,CAAC,kBAAkB,CAAC;QACnC;AAEA,QAAA,OAAO,KAAK;AACd,IAAA,CAAC,CAAC;AACJ;;;;"}
@@ -0,0 +1,17 @@
1
+ import { TemplateResult } from "lit";
2
+ import { Directive, Part, PartInfo } from "lit/directive.js";
3
+ declare class SpreadAttrs extends Directive {
4
+ render(_attrs: Record<string, unknown>): symbol;
5
+ update(part: any, [attrs]: [Record<string, unknown>]): symbol;
6
+ }
7
+ export declare const spread: (_attrs: Record<string, unknown>) => import("lit-html/directive.js").DirectiveResult<typeof SpreadAttrs>;
8
+ export declare const sanitizeHtmlContent: (content: string) => string;
9
+ declare class HtmlContainer extends Directive {
10
+ private slotElement;
11
+ private lastOpeningHtml;
12
+ constructor(partInfo: PartInfo);
13
+ render(_openingHtml: string, _childTemplate: TemplateResult, _sanitize: boolean): symbol;
14
+ update(part: Part, [openingHtml, childTemplate, sanitize]: [string, TemplateResult, boolean]): symbol;
15
+ }
16
+ export declare const htmlContainer: (_openingHtml: string, _childTemplate: TemplateResult, _sanitize: boolean) => import("lit-html/directive.js").DirectiveResult<typeof HtmlContainer>;
17
+ export {};
@@ -0,0 +1,84 @@
1
+ /**
2
+ * Copyright IBM Corp. 2025
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ import DOMPurify from 'dompurify';
9
+ import { nothing, render } from 'lit';
10
+ import { directive, Directive, PartType } from 'lit/directive.js';
11
+ import { HTML_CONTAINER_SLOT } from './html-helpers.js';
12
+
13
+ /*
14
+ * Copyright IBM Corp. 2025, 2026
15
+ *
16
+ * This source code is licensed under the Apache-2.0 license found in the
17
+ * LICENSE file in the root directory of this source tree.
18
+ *
19
+ * @license
20
+ */
21
+ // Generic attribute spread for Lit templates
22
+ class SpreadAttrs extends Directive {
23
+ render(_attrs) {
24
+ return nothing;
25
+ }
26
+ update(part, [attrs]) {
27
+ const el = part.element;
28
+ for (const [k, v] of Object.entries(attrs ?? {})) {
29
+ if (v === false || v === null || v === undefined) {
30
+ el.removeAttribute(k);
31
+ }
32
+ else if (v === true) {
33
+ el.setAttribute(k, "");
34
+ }
35
+ else {
36
+ el.setAttribute(k, String(v));
37
+ }
38
+ }
39
+ return nothing;
40
+ }
41
+ }
42
+ const spread = directive(SpreadAttrs);
43
+ const sanitizeHtmlContent = (content) => DOMPurify.sanitize(content, {
44
+ ADD_ATTR: ["data-aichat-markdown"],
45
+ CUSTOM_ELEMENT_HANDLING: {
46
+ tagNameCheck: () => true, // Allow custom elements
47
+ attributeNameCheck: () => true,
48
+ allowCustomizedBuiltInElements: true,
49
+ },
50
+ });
51
+ class HtmlContainer extends Directive {
52
+ constructor(partInfo) {
53
+ super(partInfo);
54
+ this.slotElement = null;
55
+ this.lastOpeningHtml = "";
56
+ if (partInfo.type !== PartType.ELEMENT) {
57
+ throw new Error("HtmlContainer must be used on an element");
58
+ }
59
+ }
60
+ render(_openingHtml, _childTemplate, _sanitize) {
61
+ return nothing;
62
+ }
63
+ update(part, [openingHtml, childTemplate, sanitize]) {
64
+ const host = part.element;
65
+ if (!this.slotElement || this.lastOpeningHtml !== openingHtml) {
66
+ this.lastOpeningHtml = openingHtml;
67
+ let content = `${openingHtml}${HTML_CONTAINER_SLOT}`;
68
+ if (sanitize && content) {
69
+ content = sanitizeHtmlContent(content);
70
+ }
71
+ const fragment = document.createRange().createContextualFragment(content);
72
+ host.replaceChildren(...Array.from(fragment.childNodes));
73
+ this.slotElement = host.querySelector("[data-aichat-markdown]");
74
+ }
75
+ if (this.slotElement) {
76
+ render(childTemplate, this.slotElement);
77
+ }
78
+ return nothing;
79
+ }
80
+ }
81
+ const htmlContainer = directive(HtmlContainer);
82
+
83
+ export { htmlContainer, sanitizeHtmlContent, spread };
84
+ //# sourceMappingURL=lit-directives.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lit-directives.js","sources":["../../../../../src/components/markdown/src/utils/lit-directives.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;AAOG;AAeH;AACA,MAAM,WAAY,SAAQ,SAAS,CAAA;AACjC,IAAA,MAAM,CAAC,MAA+B,EAAA;AACpC,QAAA,OAAO,OAAO;IAChB;AACA,IAAA,MAAM,CAAC,IAAS,EAAE,CAAC,KAAK,CAA4B,EAAA;AAClD,QAAA,MAAM,EAAE,GAAG,IAAI,CAAC,OAAkB;AAClC,QAAA,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,IAAI,EAAE,CAAC,EAAE;AAChD,Y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IAAI,CAAC,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,eAAe,KAAK,WAAW,EAAE;AAC7D,YAAA,IAAI,CAAC,eAAe,GAAG,WAAW;AAClC,YAAA,IAAI,OAAO,GAAG,CAAA,EAAG,WAAW,CAAA,EAAG,mBAAmB,EAAE;AACpD,YAAA,IAAI,QAAQ,IAAI,OAAO,EAAE;AACvB,gBAAA,OAAO,GAAG,mBAAmB,CAAC,OAAO,CAAC;YACxC;YAEA,MAAM,QAAQ,GAAG,QAAQ,CAAC,WAAW,EAAE,CAAC,wBAAwB,CAAC,OAAO,CAAC;AACzE,YAAA,IAAI,CAAC,eAAe,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;YACxD,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,aAAa,CAAC,wBAAwB,CAAC;QACjE;AAEA,QAAA,IAAI,IAAI,CAAC,WAAW,EAAE;AACpB,YAAA,MAAM,CAAC,aAAa,EAAE,IAAI,CAAC,WAAW,CAAC;QACzC;AAEA,QAAA,OAAO,OAAO;IAChB;AACD;MAEY,aAAa,GAAG,SAAS,CAAC,aAAa;;;;"}
@@ -0,0 +1,33 @@
1
+ import { TemplateResult } from "lit";
2
+ import MarkdownIt, { Token } from "markdown-it";
3
+ import { type TokenTree } from "../markdown-token-tree.js";
4
+ import type { RenderTokenTreeOptions } from "../markdown-renderer-types.js";
5
+ /**
6
+ * True when the renderer can dispatch `token` itself (hand-written Lit
7
+ * template). False when an unknown plugin-introduced token type or tag should
8
+ * route through `md.renderer.render()`.
9
+ */
10
+ export declare function isNativelyHandled(token: Partial<Token>): boolean;
11
+ /**
12
+ * True when the token's type is in the curated delegation allow-list and a
13
+ * user-supplied markdown-it plugin has overridden (or added) the matching
14
+ * `md.renderer.rules[type]`. Native dispatch sites consult this to decide
15
+ * whether to route through `md.renderer.render()` instead of the hand-written
16
+ * Lit template.
17
+ */
18
+ export declare function shouldDelegateToPluginRule(token: Partial<Token>, md: MarkdownIt | undefined): boolean;
19
+ /**
20
+ * Renders an unknown token via markdown-it's HTML renderer and emits a named
21
+ * `<slot>` placeholder. The markdown element adopts a light-DOM
22
+ * `<div slot="…">` host containing the sanitized HTML so consumer-supplied
23
+ * CSS (e.g. KaTeX's stylesheet) reaches the rendered output.
24
+ *
25
+ * For leaf token types in {@link PLUGIN_DELEGABLE_TOKEN_TYPES} the rendered
26
+ * HTML is cached on the {@link TokenTree} node and inherited across
27
+ * `diffTokenTree` calls when the underlying token is unchanged — so a stable
28
+ * earlier-in-document fence/image/etc. doesn't re-invoke the plugin's rule on
29
+ * every streaming chunk. The cache is tagged with the `MarkdownIt` instance
30
+ * that produced it; a plugin swap (which builds a fresh instance) invalidates
31
+ * the cache automatically.
32
+ */
33
+ export declare function renderFallback(token: Token, node: TokenTree, md: MarkdownIt, sanitize: boolean, options: RenderTokenTreeOptions): TemplateResult;
@@ -0,0 +1,216 @@
1
+ /**
2
+ * Copyright IBM Corp. 2025
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ import { html } from 'lit';
9
+ import { PLUGIN_DELEGABLE_TOKEN_TYPES, getPluginOverriddenRules } from '../markdown-token-tree.js';
10
+ import { sanitizeHtmlContent } from './lit-directives.js';
11
+
12
+ /*
13
+ * Copyright IBM Corp. 2025, 2026
14
+ *
15
+ * This source code is licensed under the Apache-2.0 license found in the
16
+ * LICENSE file in the root directory of this source tree.
17
+ *
18
+ * @license
19
+ */
20
+ /**
21
+ * Slot-name prefix shared by every plugin-fallback descriptor. The element
22
+ * suffixes a render-scoped sequence number; the markdown component uses this
23
+ * prefix when adopting the light-DOM host so external observers can target
24
+ * plugin output with CSS or query selectors.
25
+ *
26
+ * @internal
27
+ */
28
+ const PLUGIN_FALLBACK_SLOT_PREFIX = "cds-custom-aichat-markdown-renderer-pluginFallback";
29
+ // Token types our hand-written renderer handles natively (no markdown-it
30
+ // fallback needed).
31
+ const NATIVELY_HANDLED_TOKEN_TYPES = new Set([
32
+ "root",
33
+ "text",
34
+ "code_inline",
35
+ "fence",
36
+ "html_block",
37
+ "html_inline",
38
+ "html_container",
39
+ "inline",
40
+ ]);
41
+ // HTML tags whose paired open/close (or self-contained leaf) is rendered by
42
+ // `renderWithStaticTag`. Anything else falls through to the markdown-it
43
+ // renderer fallback.
44
+ const NATIVELY_HANDLED_TAGS = new Set([
45
+ "p",
46
+ "blockquote",
47
+ "pre",
48
+ "h1",
49
+ "h2",
50
+ "h3",
51
+ "h4",
52
+ "h5",
53
+ "h6",
54
+ "ul",
55
+ "ol",
56
+ "li",
57
+ "cds-custom-checkbox",
58
+ "strong",
59
+ "em",
60
+ "code",
61
+ "del",
62
+ "sub",
63
+ "sup",
64
+ "span",
65
+ "i",
66
+ "b",
67
+ "small",
68
+ "mark",
69
+ "ins",
70
+ "s",
71
+ "kbd",
72
+ "var",
73
+ "samp",
74
+ "cite",
75
+ "abbr",
76
+ "dfn",
77
+ "time",
78
+ "q",
79
+ "a",
80
+ "table",
81
+ "img",
82
+ // Table internals — their open/close pairs are walked into via children.
83
+ "thead",
84
+ "tbody",
85
+ "tr",
86
+ "th",
87
+ "td",
88
+ // Task-list checkbox input element produced by markdown-it-task-lists.
89
+ "input",
90
+ ]);
91
+ /**
92
+ * True when the renderer can dispatch `token` itself (hand-written Lit
93
+ * template). False when an unknown plugin-introduced token type or tag should
94
+ * route through `md.renderer.render()`.
95
+ */
96
+ function isNativelyHandled(token) {
97
+ if (token.type && NATIVELY_HANDLED_TOKEN_TYPES.has(token.type)) {
98
+ return true;
99
+ }
100
+ if (token.tag && NATIVELY_HANDLED_TAGS.has(token.tag)) {
101
+ return true;
102
+ }
103
+ return false;
104
+ }
105
+ /**
106
+ * True when the token's type is in the curated delegation allow-list and a
107
+ * user-supplied markdown-it plugin has overridden (or added) the matching
108
+ * `md.renderer.rules[type]`. Native dispatch sites consult this to decide
109
+ * whether to route through `md.renderer.render()` instead of the hand-written
110
+ * Lit template.
111
+ */
112
+ function shouldDelegateToPluginRule(token, md) {
113
+ if (!token.type || !md) {
114
+ return false;
115
+ }
116
+ if (!PLUGIN_DELEGABLE_TOKEN_TYPES.has(token.type)) {
117
+ return false;
118
+ }
119
+ return getPluginOverriddenRules(md).has(token.type);
120
+ }
121
+ function synthesizeCloseToken(openToken) {
122
+ const closeType = openToken.type.replace(/_open$/, "_close");
123
+ return {
124
+ type: closeType,
125
+ tag: openToken.tag,
126
+ nesting: -1,
127
+ level: Math.max(0, openToken.level - 1),
128
+ content: "",
129
+ attrs: null,
130
+ children: null,
131
+ markup: openToken.markup,
132
+ block: openToken.block,
133
+ hidden: false,
134
+ map: null,
135
+ info: "",
136
+ meta: null,
137
+ };
138
+ }
139
+ /**
140
+ * Re-emits the original flat markdown-it token sequence beneath `node` so the
141
+ * sequence can be passed to `md.renderer.render()`. `inline` tokens are emitted
142
+ * as-is (markdown-it's renderer reads their `.children` directly).
143
+ */
144
+ function flattenSubtree(node) {
145
+ const tokens = [];
146
+ for (const child of node.children) {
147
+ const t = child.token;
148
+ if (t.type === "inline") {
149
+ tokens.push(t);
150
+ }
151
+ else if (t.nesting === 1) {
152
+ tokens.push(t);
153
+ tokens.push(...flattenSubtree(child));
154
+ tokens.push(synthesizeCloseToken(t));
155
+ }
156
+ else {
157
+ tokens.push(t);
158
+ }
159
+ }
160
+ return tokens;
161
+ }
162
+ /**
163
+ * Builds the flat token slice to hand to `md.renderer.render()` for a token the
164
+ * native renderer doesn't handle. Leaf tokens render alone; paired-container
165
+ * opens reassemble `[open, ...children, close]` from the tree.
166
+ */
167
+ function sliceForFallback(token, node) {
168
+ if (token.nesting === 1) {
169
+ return [token, ...flattenSubtree(node), synthesizeCloseToken(token)];
170
+ }
171
+ return [token];
172
+ }
173
+ /**
174
+ * Renders an unknown token via markdown-it's HTML renderer and emits a named
175
+ * `<slot>` placeholder. The markdown element adopts a light-DOM
176
+ * `<div slot="…">` host containing the sanitized HTML so consumer-supplied
177
+ * CSS (e.g. KaTeX's stylesheet) reaches the rendered output.
178
+ *
179
+ * For leaf token types in {@link PLUGIN_DELEGABLE_TOKEN_TYPES} the rendered
180
+ * HTML is cached on the {@link TokenTree} node and inherited across
181
+ * `diffTokenTree` calls when the underlying token is unchanged — so a stable
182
+ * earlier-in-document fence/image/etc. doesn't re-invoke the plugin's rule on
183
+ * every streaming chunk. The cache is tagged with the `MarkdownIt` instance
184
+ * that produced it; a plugin swap (which builds a fresh instance) invalidates
185
+ * the cache automatically.
186
+ */
187
+ function renderFallback(token, node, md, sanitize, options) {
188
+ let safe;
189
+ if (node?.cachedHtml && node.cachedHtml.md === md) {
190
+ safe = node.cachedHtml.html;
191
+ }
192
+ else {
193
+ const slice = sliceForFallback(token, node);
194
+ const htmlStr = md.renderer.render(slice, md.options, {});
195
+ safe = sanitize ? sanitizeHtmlContent(htmlStr) : htmlStr;
196
+ if (node &&
197
+ typeof token.type === "string" &&
198
+ PLUGIN_DELEGABLE_TOKEN_TYPES.has(token.type)) {
199
+ node.cachedHtml = { md, html: safe };
200
+ }
201
+ }
202
+ const index = options.pluginSlotCounter?.next() ?? 0;
203
+ const slotName = `${PLUGIN_FALLBACK_SLOT_PREFIX}-${index}`;
204
+ options.recordCustomRender?.({
205
+ slotName,
206
+ kind: "pluginFallback",
207
+ token,
208
+ node,
209
+ html: safe,
210
+ isInline: token.block === false,
211
+ });
212
+ return html `<slot name=${slotName}></slot>`;
213
+ }
214
+
215
+ export { PLUGIN_FALLBACK_SLOT_PREFIX, isNativelyHandled, renderFallback, shouldDelegateToPluginRule };
216
+ //# sourceMappingURL=plugin-fallback.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin-fallback.js","sources":["../../../../../src/components/markdown/src/utils/plugin-fallback.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;;;AAAA;;;;;;;AAOG;AAaH;;;;;;;AAOG;AACI,MAAM,2BAA2B,GACtC;AAEF;AACA;AACA,MAAM,4BAA4B,GA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C,iBAAiB,EAAE,IAAI,EAAE,IAAI,CAAC;AACpD,IAAA,MAAM,QAAQ,GAAG,CAAA,EAAG,2BAA2B,CAAA,CAAA,EAAI,KAAK,EAAE;IAC1D,OAAO,CAAC,kBAAkB,GAAG;QAC3B,QAAQ;AACR,QAAA,IAAI,EAAE,gBAAgB;QACtB,KAAK;QACL,IAAI;AACJ,QAAA,IAAI,EAAE,IAAI;AACV,QAAA,QAAQ,EAAE,KAAK,CAAC,KAAK,KAAK,KAAK;AAChC,KAAA,CAAC;AACF,IAAA,OAAO,IAAI,CAAA,CAAA,WAAA,EAAc,QAAQ,UAAU;AAC7C;;;;"}
@@ -0,0 +1,28 @@
1
+ import type { TokenTree } from "../markdown-token-tree.js";
2
+ /**
3
+ * True if the right-most leaf of the tree is a `table` token. A trailing table
4
+ * is one that sits at the end of the current markdown output, not just at the
5
+ * end of an arbitrary subtree — so we follow only the rightmost branch.
6
+ */
7
+ export declare function hasTrailingTableToken(node: TokenTree): boolean;
8
+ /**
9
+ * True if any table token in the tree has a sibling that follows it. Used to
10
+ * detect that the streaming author has moved past a table, so we can exit the
11
+ * "table loading" hold and render the live table.
12
+ */
13
+ export declare function hasNodeAfterTable(node: TokenTree): boolean;
14
+ /**
15
+ * True when a table at `currentIndex` inside `parentChildren` has no
16
+ * siblings after it — i.e. it is currently the last child of its parent.
17
+ * The streaming-table renderer uses this to decide whether the live table
18
+ * should show its skeleton/loading state.
19
+ */
20
+ export declare function isTableAtStreamingTail(parentChildren: readonly unknown[], currentIndex: number): boolean;
21
+ /**
22
+ * Heuristic that returns true when the last non-empty line of the markdown
23
+ * source looks like an in-progress table row or separator. markdown-it can
24
+ * momentarily stop recognizing the table token while a row is half-written, so
25
+ * the streaming-table hold uses this to avoid flickering between table and
26
+ * non-table renderings.
27
+ */
28
+ export declare function hasLikelyPartialTableTail(markdown: string): boolean;
@@ -0,0 +1,86 @@
1
+ /**
2
+ * Copyright IBM Corp. 2025
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ /*
9
+ * Copyright IBM Corp. 2025, 2026
10
+ *
11
+ * This source code is licensed under the Apache-2.0 license found in the
12
+ * LICENSE file in the root directory of this source tree.
13
+ *
14
+ * @license
15
+ */
16
+ /**
17
+ * True if the right-most leaf of the tree is a `table` token. A trailing table
18
+ * is one that sits at the end of the current markdown output, not just at the
19
+ * end of an arbitrary subtree — so we follow only the rightmost branch.
20
+ */
21
+ function hasTrailingTableToken(node) {
22
+ if (node.token.tag === "table") {
23
+ return true;
24
+ }
25
+ const children = node.children || [];
26
+ if (children.length === 0) {
27
+ return false;
28
+ }
29
+ return hasTrailingTableToken(children[children.length - 1]);
30
+ }
31
+ /**
32
+ * True if any table token in the tree has a sibling that follows it. Used to
33
+ * detect that the streaming author has moved past a table, so we can exit the
34
+ * "table loading" hold and render the live table.
35
+ */
36
+ function hasNodeAfterTable(node) {
37
+ const children = node.children || [];
38
+ for (let index = 0; index < children.length; index++) {
39
+ const child = children[index];
40
+ if (child.token.tag === "table" && index < children.length - 1) {
41
+ return true;
42
+ }
43
+ if (hasNodeAfterTable(child)) {
44
+ return true;
45
+ }
46
+ }
47
+ return false;
48
+ }
49
+ /**
50
+ * True when a table at `currentIndex` inside `parentChildren` has no
51
+ * siblings after it — i.e. it is currently the last child of its parent.
52
+ * The streaming-table renderer uses this to decide whether the live table
53
+ * should show its skeleton/loading state.
54
+ */
55
+ function isTableAtStreamingTail(parentChildren, currentIndex) {
56
+ return currentIndex >= parentChildren.length - 1;
57
+ }
58
+ /**
59
+ * Heuristic that returns true when the last non-empty line of the markdown
60
+ * source looks like an in-progress table row or separator. markdown-it can
61
+ * momentarily stop recognizing the table token while a row is half-written, so
62
+ * the streaming-table hold uses this to avoid flickering between table and
63
+ * non-table renderings.
64
+ */
65
+ function hasLikelyPartialTableTail(markdown) {
66
+ const normalized = markdown.replace(/\r/g, "");
67
+ const lines = normalized.split("\n");
68
+ let index = lines.length - 1;
69
+ while (index >= 0 && lines[index].trim() === "") {
70
+ index--;
71
+ }
72
+ if (index < 0) {
73
+ return false;
74
+ }
75
+ const lastLine = lines[index].trim();
76
+ // During streaming, partially emitted table rows frequently end with a pipe
77
+ // and markdown-it can temporarily stop recognizing the table token.
78
+ if (lastLine.startsWith("|") || lastLine.endsWith("|")) {
79
+ return true;
80
+ }
81
+ // Keep loading mode if the tail still looks like a table separator row.
82
+ return /^\|?[\s:-]+(\|[\s:-]+)+\|?$/.test(lastLine);
83
+ }
84
+
85
+ export { hasLikelyPartialTableTail, hasNodeAfterTable, hasTrailingTableToken, isTableAtStreamingTail };
86
+ //# sourceMappingURL=streaming-table.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"streaming-table.js","sources":["../../../../../src/components/markdown/src/utils/streaming-table.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;AAAA;;;;;;;AAOG;AAIH;;;;AAIG;AACG,SAAU,qBAAqB,CAAC,IAAe,EAAA;IACnD,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,KAAK,OAAO,EAAE;AAC9B,QAAA,OAAO,IAAI;IACb;AAEA,IAAA,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,IAAI,EAAE;AACpC,IAAA,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE;AACzB,QAAA,OAAO,KAAK;IACd;IAEA,OAAO,qBAAqB,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AAC7D;AAEA;;;;AAIG;AACG,SAAU,iBAAiB,CAAC,IAAe,EAAA;AAC/C,IAAA,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,IAAI,EAAE;AACpC,IAAA,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,QAAQ,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE;AACpD,QAAA,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC;AAC7B,QAAA,IAAI,KAAK,CAAC,KAAK,CAAC,GAAG,KAAK,OAAO,IAAI,KAAK,GAAG,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE;AAC9D,YAAA,OAAO,IAAI;QACb;AACA,QAAA,IAAI,iBAAiB,CAAC,KAAK,CAAC,EAAE;AAC5B,YAAA,OAAO,IAAI;QACb;IACF;AACA,IAAA,OAAO,KAAK;AACd;AAEA;;;;;AAKG;AACG,SAAU,sBAAsB,CACpC,cAAkC,EAClC,YAAoB,EAAA;AAEpB,IAAA,OAAO,YAAY,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC;AAClD;AAEA;;;;;;AAMG;AACG,SAAU,yBAAyB,CAAC,QAAgB,EAAA;IACxD,MAAM,UAAU,GAAG,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC;IAC9C,MAAM,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC;AACpC,IAAA,IAAI,KAAK,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC;AAE5B,IAAA,OAAO,KAAK,IAAI,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;AAC/C,QAAA,KAAK,EAAE;IACT;AAEA,IAAA,IAAI,KAAK,GAAG,CAAC,EAAE;AACb,QAAA,OAAO,KAAK;IACd;IAEA,MAAM,QAAQ,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE;;;AAIpC,IAAA,IAAI,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;AACtD,QAAA,OAAO,IAAI;IACb;;AAGA,IAAA,OAAO,6BAA6B,CAAC,IAAI,CAAC,QAAQ,CAAC;AACrD;;;;"}
@@ -1,3 +1,6 @@
1
+ import { TemplateResult } from "lit";
2
+ import type { Token } from "markdown-it";
3
+ import type { RenderTokenTreeOptions } from "../markdown-renderer-types.js";
1
4
  import type { TokenTree } from "../markdown-token-tree";
2
5
  export declare const DEFAULT_PAGINATION_SUPPLEMENTAL_TEXT: ({ count, }: {
3
6
  count: number;
@@ -29,3 +32,17 @@ export declare function extractTableData(tableNode: TokenTree): {
29
32
  * text content without HTML formatting.
30
33
  */
31
34
  export declare function extractTextContent(node: TokenTree): string;
35
+ /**
36
+ * Renders the body of the `case "table"` branch of `renderWithStaticTag`.
37
+ *
38
+ * Lives outside the renderer's switch because it covers three flows: streaming
39
+ * loading state, default Carbon-table rendering, and the `customRenderers.table`
40
+ * slot override.
41
+ *
42
+ * `renderToken` is the recursive renderer the caller dispatched from, passed in
43
+ * to avoid a cycle with `markdown-renderer.ts`. `slotName` is non-undefined when
44
+ * the consumer registered a `table` custom renderer, in which case the result is
45
+ * wrapped in a named `<slot>` and an override descriptor is reported via
46
+ * `recordCustomRender`.
47
+ */
48
+ export declare function renderTable(token: Token, node: TokenTree, attrs: Record<string, string>, options: RenderTokenTreeOptions, renderToken: (node: TokenTree, options: RenderTokenTreeOptions) => TemplateResult, slotName: string | undefined): TemplateResult;
@@ -5,8 +5,13 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
+ import { html } from 'lit';
9
+ import { repeat } from 'lit/directives/repeat.js';
10
+ import { combineConsecutiveHtmlInline } from './html-helpers.js';
11
+ import { isTableAtStreamingTail } from './streaming-table.js';
12
+
8
13
  /*
9
- * Copyright IBM Corp. 2025
14
+ * Copyright IBM Corp. 2025, 2026
10
15
  *
11
16
  * This source code is licensed under the Apache-2.0 license found in the
12
17
  * LICENSE file in the root directory of this source tree.
@@ -101,6 +106,103 @@ function extractRenderableChildren(node) {
101
106
  }
102
107
  return node.children;
103
108
  }
109
+ /**
110
+ * Renders the body of the `case "table"` branch of `renderWithStaticTag`.
111
+ *
112
+ * Lives outside the renderer's switch because it covers three flows: streaming
113
+ * loading state, default Carbon-table rendering, and the `customRenderers.table`
114
+ * slot override.
115
+ *
116
+ * `renderToken` is the recursive renderer the caller dispatched from, passed in
117
+ * to avoid a cycle with `markdown-renderer.ts`. `slotName` is non-undefined when
118
+ * the consumer registered a `table` custom renderer, in which case the result is
119
+ * wrapped in a named `<slot>` and an override descriptor is reported via
120
+ * `recordCustomRender`.
121
+ */
122
+ function renderTable(token, node, attrs, options, renderToken, slotName) {
123
+ const { streaming, forceTableLoading, context: parentContext, tableFilterPlaceholderText, tablePreviousPageText, tableNextPageText, tableItemsPerPageText, tableDownloadLabelText, tableLocale, tableGetPaginationSupplementalText, tableGetPaginationStatusText, } = options;
124
+ // Determine if we should show loading state during streaming
125
+ let isLoading = Boolean(forceTableLoading);
126
+ if (!isLoading &&
127
+ streaming &&
128
+ parentContext?.parentChildren &&
129
+ parentContext?.currentIndex !== undefined) {
130
+ isLoading = isTableAtStreamingTail(parentContext.parentChildren, parentContext.currentIndex);
131
+ }
132
+ const renderCellTokens = (tokens, contextOverrides = {}) => {
133
+ // Same as block/inline rendering: merge split raw HTML (e.g. `<a>…</a>`)
134
+ // so each cell is not rendered as separate unsafeHTML + text chunks.
135
+ const normalizedTokens = combineConsecutiveHtmlInline(tokens);
136
+ return html `${repeat(normalizedTokens, (child, index) => `cell-${index}:${child.token.type}:${child.token.tag}`, (child, index) => renderToken(child, {
137
+ ...options,
138
+ context: {
139
+ ...options.context,
140
+ ...contextOverrides,
141
+ parentChildren: normalizedTokens,
142
+ currentIndex: index,
143
+ },
144
+ }))}`;
145
+ };
146
+ const createCellContent = (cell, contextOverrides) => ({
147
+ text: cell.text,
148
+ template: cell.tokens
149
+ ? renderCellTokens(cell.tokens, contextOverrides)
150
+ : null,
151
+ });
152
+ // Only extract and process table data when not loading to avoid unnecessary work.
153
+ // During loading, the table shows a skeleton and doesn't need the actual data.
154
+ let headers = [];
155
+ let tableRows = [];
156
+ if (!isLoading) {
157
+ const extractedData = extractTableData(node);
158
+ headers = extractedData.headers.map((cell) => createCellContent(cell, { isInThead: true }));
159
+ tableRows = extractedData.rows.map((row) => ({
160
+ cells: row.map((cell) => createCellContent(cell)),
161
+ }));
162
+ }
163
+ // Always return the same structure to allow Lit to reuse the table element.
164
+ // When isLoading is true, the table component will show a skeleton state.
165
+ // When isLoading is false, it will show the actual data.
166
+ // This prevents recreating the table element and preserves its internal state.
167
+ const defaultTableTemplate = html `<div class="cds-custom-aichat-table--square">
168
+ <cds-custom-aichat-table
169
+ data-rounded
170
+ .headers=${headers}
171
+ .rows=${tableRows}
172
+ .loading=${isLoading}
173
+ .filterPlaceholderText=${tableFilterPlaceholderText}
174
+ .previousPageText=${tablePreviousPageText}
175
+ .nextPageText=${tableNextPageText}
176
+ .itemsPerPageText=${tableItemsPerPageText}
177
+ .downloadLabelText=${tableDownloadLabelText}
178
+ .locale=${tableLocale}
179
+ .getPaginationSupplementalText=${tableGetPaginationSupplementalText}
180
+ .getPaginationStatusText=${tableGetPaginationStatusText}
181
+ ...=${attrs}
182
+ ></cds-custom-aichat-table>
183
+ </div>`;
184
+ if (slotName !== undefined) {
185
+ // For the override path we pass the raw extracted cell data (not the
186
+ // Lit-wrapped TableCellContent) so consumers can render however they
187
+ // like. Extract once even when loading so the consumer always gets
188
+ // the data — they can read `isLoading` to choose a skeleton state.
189
+ const { headers: dataHeaders, rows: dataRows } = extractTableData(node);
190
+ options.recordCustomRender?.({
191
+ slotName,
192
+ kind: "table",
193
+ token,
194
+ node,
195
+ data: {
196
+ headers: dataHeaders,
197
+ rows: dataRows,
198
+ isStreaming: !!streaming,
199
+ isLoading,
200
+ },
201
+ });
202
+ return html `<slot name=${slotName}>${defaultTableTemplate}</slot>`;
203
+ }
204
+ return defaultTableTemplate;
205
+ }
104
206
 
105
- export { DEFAULT_PAGINATION_STATUS_TEXT, DEFAULT_PAGINATION_SUPPLEMENTAL_TEXT, extractTableData, extractTextContent };
207
+ export { DEFAULT_PAGINATION_STATUS_TEXT, DEFAULT_PAGINATION_SUPPLEMENTAL_TEXT, extractTableData, extractTextContent, renderTable };
106
208
  //# sourceMappingURL=table-helpers.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"table-helpers.js","sources":["../../../../../src/components/markdown/src/utils/table-helpers.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;AAAA;;;;;;;AAOG;AAIH;AACO,MAAM,oCAAoC,GAAG,CAAC,EACnD,KAAK,GAGN,KAAK,CAAA,EAAG,KAAK;MACD,8BAA8B,GAAG,CAAC,EAC7C,KAAK,EACL,GAAG,EACH,KAAK,GAKN,KAAK,CAAA,EAAG,KAAK,IAAI,GAAG,CAAA,IAAA,EAAO,KAAK,CAAA,MAAA;AAOjC;;;;;;AAMG;AACG,SAAU,gBAAgB,CAAC,SAAoB,EAAA;IAInD,MAAM,OAAO,GAAoB,EAAE;IACnC,MAAM,IAAI,GAAsB,EAAE;AAElC,IAAA,KAAK,MAAM,KAAK,IAAI,SAAS,CAAC,QAAQ,EAAE;QACtC,IAAI,KAAK,CAAC,KAAK,CAAC,GAAG,KAAK,OAAO,EAAE;;AAE/B,YAAA,KAAK,MAAM,UAAU,IAAI,KAAK,CAAC,QAAQ,EAAE;gBACvC,IAAI,UAAU,CAAC,KAAK,CAAC,GAAG,KAAK,IAAI,EAAE;AACjC,oBAAA,KAAK,MAAM,OAAO,IAAI,UAAU,CAAC,QAAQ,EAAE;wBACzC,IAAI,OAAO,CAAC,KAAK,CAAC,GAAG,KAAK,IAAI,EAAE;4BAC9B,OAAO,CAAC,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;wBACxC;oBACF;gBACF;YACF;QACF;aAAO,IAAI,KAAK,CAAC,KAAK,CAAC,GAAG,KAAK,OAAO,EAAE;;AAEtC,YAAA,KAAK,MAAM,UAAU,IAAI,KAAK,CAAC,QAAQ,EAAE;gBACvC,IAAI,UAAU,CAAC,KAAK,CAAC,GAAG,KAAK,IAAI,EAAE;oBACjC,MAAM,GAAG,GAAoB,EAAE;AAC/B,oBAAA,KAAK,MAAM,OAAO,IAAI,UAAU,CAAC,QAAQ,EAAE;wBACzC,IAAI,OAAO,CAAC,KAAK,CAA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,CAAC,IAAe,EAAA;IAChD,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE;QAC9B,MAAM,SAAS,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;AAClC,QAAA,IACE,SAAS,CAAC,KAAK,CAAC,IAAI,KAAK,QAAQ;AACjC,YAAA,SAAS,CAAC,QAAQ;AAClB,YAAA,SAAS,CAAC,QAAQ,CAAC,MAAM,EACzB;YACA,OAAO,SAAS,CAAC,QAAQ;QAC3B;IACF;IAEA,OAAO,IAAI,CAAC,QAAQ;AACtB;;;;"}
1
+ {"version":3,"file":"table-helpers.js","sources":["../../../../../src/components/markdown/src/utils/table-helpers.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;AAOG;AAeH;AACO,MAAM,oCAAoC,GAAG,CAAC,EACnD,KAAK,GAGN,KAAK,CAAA,EAAG,KAAK;MACD,8BAA8B,GAAG,CAAC,EAC7C,KAAK,EACL,GAAG,EACH,KAAK,GAKN,KAAK,CAAA,EAAG,KAAK,IAAI,GAAG,CAAA,IAAA,EAAO,KAAK,CAAA,MAAA;AAOjC;;;;;;AAMG;AACG,SAAU,gBAAgB,CAAC,SAAoB,EAAA;IAInD,MAAM,OAAO,GAAoB,EAAE;IACnC,MAAM,IAAI,GAAsB,EAAE;AAElC,IAAA,KAAK,MAAM,KAAK,IAAI,SAAS,CAAC,QAAQ,EAAE;QACtC,IAAI,KAAK,CAAC,KAAK,CAAC,GAAG,KAAK,OAAO,EAAE;;AAE/B,YAAA,KAAK,MAAM,UAAU,IAAI,KAAK,CAAC,QAAQ,EAAE;gBACvC,IAAI,UAAU,CAAC,KAAK,CAAC,GAAG,KAAK,IAAI,EAAE;AACjC,oBAAA,KAAK,MAAM,OAAO,IAAI,UAAU,CAAC,QAAQ,EAAE;wBACzC,IAAI,OAAO,CAAC,KAAK,CAAC,GAAG,KAAK,IAAI,EAAE;4BAC9B,OAAO,CAAC,IAAI,CA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