@carbon/ai-chat-components 1.12.0 → 1.13.0-rc.2

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 (153) hide show
  1. package/custom-elements.json +4456 -4079
  2. package/es/components/chat-button/src/chat-button.scss.js +1 -1
  3. package/es/components/chat-history/src/chat-history.scss.js +1 -1
  4. package/es/components/chat-history/src/history-panel-item.js +0 -1
  5. package/es/components/chat-history/src/history-panel-item.js.map +1 -1
  6. package/es/components/chat-shell/src/panel-manager.d.ts +10 -0
  7. package/es/components/chat-shell/src/panel-manager.js +116 -1
  8. package/es/components/chat-shell/src/panel-manager.js.map +1 -1
  9. package/es/components/chat-shell/src/panel.d.ts +5 -0
  10. package/es/components/chat-shell/src/panel.js +16 -2
  11. package/es/components/chat-shell/src/panel.js.map +1 -1
  12. package/es/components/chat-shell/src/shell.d.ts +4 -0
  13. package/es/components/chat-shell/src/shell.js +72 -4
  14. package/es/components/chat-shell/src/shell.js.map +1 -1
  15. package/es/components/code-snippet/src/code-snippet.d.ts +3 -4
  16. package/es/components/code-snippet/src/code-snippet.js +4 -6
  17. package/es/components/code-snippet/src/code-snippet.js.map +1 -1
  18. package/es/components/code-snippet/src/codemirror/theme.js +2 -6
  19. package/es/components/code-snippet/src/codemirror/theme.js.map +1 -1
  20. package/es/components/code-snippet/src/layout-utils.d.ts +1 -3
  21. package/es/components/code-snippet/src/layout-utils.js.map +1 -1
  22. package/es/components/conversational-search/index.d.ts +9 -0
  23. package/es/components/conversational-search/index.js +9 -0
  24. package/es/components/conversational-search/index.js.map +1 -0
  25. package/es/components/conversational-search/src/citation-utils.d.ts +24 -0
  26. package/es/components/conversational-search/src/citation-utils.js +46 -0
  27. package/es/components/conversational-search/src/citation-utils.js.map +1 -0
  28. package/es/components/conversational-search/src/conversational-search-shell.d.ts +41 -0
  29. package/es/components/conversational-search/src/conversational-search-shell.js +116 -0
  30. package/es/components/conversational-search/src/conversational-search-shell.js.map +1 -0
  31. package/es/components/conversational-search/src/conversational-search-shell.scss.js +13 -0
  32. package/es/components/conversational-search/src/conversational-search-shell.scss.js.map +1 -0
  33. package/es/components/file-uploads/src/file-upload-item.js +3 -3
  34. package/es/components/file-uploads/src/file-upload-item.js.map +1 -1
  35. package/es/components/launcher/src/launcher.scss.js +1 -1
  36. package/es/components/markdown/src/markdown-token-tree.d.ts +2 -2
  37. package/es/components/markdown/src/markdown-token-tree.js.map +1 -1
  38. package/es/components/prompt-line/index.js +0 -2
  39. package/es/components/prompt-line/index.js.map +1 -1
  40. package/es/components/prompt-line/src/autocomplete-controller.js +13 -7
  41. package/es/components/prompt-line/src/autocomplete-controller.js.map +1 -1
  42. package/es/components/prompt-line/src/prompt-line-controller.d.ts +1 -1
  43. package/es/components/prompt-line/src/prompt-line-rich-loader.d.ts +7 -0
  44. package/es/components/prompt-line/src/prompt-line-rich-loader.js.map +1 -1
  45. package/es/components/prompt-line/src/prompt-line-rich-runtime.js +8 -2
  46. package/es/components/prompt-line/src/prompt-line-rich-runtime.js.map +1 -1
  47. package/es/components/prompt-line/src/prompt-line-shell.d.ts +42 -0
  48. package/es/components/prompt-line/src/prompt-line-shell.js +43 -1
  49. package/es/components/prompt-line/src/prompt-line-shell.js.map +1 -1
  50. package/es/components/prompt-line/src/prompt-line-shell.scss.js +1 -1
  51. package/es/components/prompt-line/src/prompt-line.d.ts +8 -2
  52. package/es/components/prompt-line/src/prompt-line.js +70 -10
  53. package/es/components/prompt-line/src/prompt-line.js.map +1 -1
  54. package/es/components/prompt-line/src/tiptap/index.d.ts +0 -2
  55. package/es/components/prompt-line/src/tiptap/index.js +0 -2
  56. package/es/components/prompt-line/src/tiptap/index.js.map +1 -1
  57. package/es/components/prompt-line/src/tiptap/resolve-config-items.d.ts +5 -1
  58. package/es/components/prompt-line/src/tiptap/resolve-config-items.js +9 -0
  59. package/es/components/prompt-line/src/tiptap/resolve-config-items.js.map +1 -1
  60. package/es/components/reasoning-steps/src/reasoning-step.js +2 -2
  61. package/es/components/reasoning-steps/src/reasoning-step.js.map +1 -1
  62. package/es/components/reasoning-steps/src/reasoning-step.scss.js +1 -1
  63. package/es/components/shared/dynamic-css-var-sheet.js +7 -6
  64. package/es/components/shared/dynamic-css-var-sheet.js.map +1 -1
  65. package/es/components/table/src/table.js +5 -7
  66. package/es/components/table/src/table.js.map +1 -1
  67. package/es/components/workspace-shell/src/workspace-shell.js +15 -5
  68. package/es/components/workspace-shell/src/workspace-shell.js.map +1 -1
  69. package/es/components/workspace-shell/src/workspace-shell.scss.js +1 -1
  70. package/es/globals/utils/iconTransform.d.ts +1 -1
  71. package/es/globals/utils/iconTransform.js.map +1 -1
  72. package/es/react/chat-shell.js +3 -0
  73. package/es/react/chat-shell.js.map +1 -1
  74. package/es/react/conversational-search-shell.d.ts +12 -0
  75. package/es/react/conversational-search-shell.js +32 -0
  76. package/es/react/conversational-search-shell.js.map +1 -0
  77. package/es-custom/components/chat-button/src/chat-button.scss.js +1 -1
  78. package/es-custom/components/chat-history/src/chat-history.scss.js +1 -1
  79. package/es-custom/components/chat-history/src/history-panel-item.js +0 -1
  80. package/es-custom/components/chat-history/src/history-panel-item.js.map +1 -1
  81. package/es-custom/components/chat-shell/src/panel-manager.d.ts +10 -0
  82. package/es-custom/components/chat-shell/src/panel-manager.js +116 -1
  83. package/es-custom/components/chat-shell/src/panel-manager.js.map +1 -1
  84. package/es-custom/components/chat-shell/src/panel.d.ts +5 -0
  85. package/es-custom/components/chat-shell/src/panel.js +16 -2
  86. package/es-custom/components/chat-shell/src/panel.js.map +1 -1
  87. package/es-custom/components/chat-shell/src/shell.d.ts +4 -0
  88. package/es-custom/components/chat-shell/src/shell.js +72 -4
  89. package/es-custom/components/chat-shell/src/shell.js.map +1 -1
  90. package/es-custom/components/code-snippet/src/code-snippet.d.ts +3 -4
  91. package/es-custom/components/code-snippet/src/code-snippet.js +4 -6
  92. package/es-custom/components/code-snippet/src/code-snippet.js.map +1 -1
  93. package/es-custom/components/code-snippet/src/codemirror/theme.js +2 -6
  94. package/es-custom/components/code-snippet/src/codemirror/theme.js.map +1 -1
  95. package/es-custom/components/code-snippet/src/layout-utils.d.ts +1 -3
  96. package/es-custom/components/code-snippet/src/layout-utils.js.map +1 -1
  97. package/es-custom/components/conversational-search/index.d.ts +9 -0
  98. package/es-custom/components/conversational-search/index.js +9 -0
  99. package/es-custom/components/conversational-search/index.js.map +1 -0
  100. package/es-custom/components/conversational-search/src/citation-utils.d.ts +24 -0
  101. package/es-custom/components/conversational-search/src/citation-utils.js +46 -0
  102. package/es-custom/components/conversational-search/src/citation-utils.js.map +1 -0
  103. package/es-custom/components/conversational-search/src/conversational-search-shell.d.ts +41 -0
  104. package/es-custom/components/conversational-search/src/conversational-search-shell.js +116 -0
  105. package/es-custom/components/conversational-search/src/conversational-search-shell.js.map +1 -0
  106. package/es-custom/components/conversational-search/src/conversational-search-shell.scss.js +13 -0
  107. package/es-custom/components/conversational-search/src/conversational-search-shell.scss.js.map +1 -0
  108. package/es-custom/components/file-uploads/src/file-upload-item.js +3 -3
  109. package/es-custom/components/file-uploads/src/file-upload-item.js.map +1 -1
  110. package/es-custom/components/launcher/src/launcher.scss.js +1 -1
  111. package/es-custom/components/markdown/src/markdown-token-tree.d.ts +2 -2
  112. package/es-custom/components/markdown/src/markdown-token-tree.js.map +1 -1
  113. package/es-custom/components/prompt-line/index.js +0 -2
  114. package/es-custom/components/prompt-line/index.js.map +1 -1
  115. package/es-custom/components/prompt-line/src/autocomplete-controller.js +13 -7
  116. package/es-custom/components/prompt-line/src/autocomplete-controller.js.map +1 -1
  117. package/es-custom/components/prompt-line/src/prompt-line-controller.d.ts +1 -1
  118. package/es-custom/components/prompt-line/src/prompt-line-rich-loader.d.ts +7 -0
  119. package/es-custom/components/prompt-line/src/prompt-line-rich-loader.js.map +1 -1
  120. package/es-custom/components/prompt-line/src/prompt-line-rich-runtime.js +8 -2
  121. package/es-custom/components/prompt-line/src/prompt-line-rich-runtime.js.map +1 -1
  122. package/es-custom/components/prompt-line/src/prompt-line-shell.d.ts +42 -0
  123. package/es-custom/components/prompt-line/src/prompt-line-shell.js +43 -1
  124. package/es-custom/components/prompt-line/src/prompt-line-shell.js.map +1 -1
  125. package/es-custom/components/prompt-line/src/prompt-line-shell.scss.js +1 -1
  126. package/es-custom/components/prompt-line/src/prompt-line.d.ts +8 -2
  127. package/es-custom/components/prompt-line/src/prompt-line.js +70 -10
  128. package/es-custom/components/prompt-line/src/prompt-line.js.map +1 -1
  129. package/es-custom/components/prompt-line/src/tiptap/index.d.ts +0 -2
  130. package/es-custom/components/prompt-line/src/tiptap/index.js +0 -2
  131. package/es-custom/components/prompt-line/src/tiptap/index.js.map +1 -1
  132. package/es-custom/components/prompt-line/src/tiptap/resolve-config-items.d.ts +5 -1
  133. package/es-custom/components/prompt-line/src/tiptap/resolve-config-items.js +9 -0
  134. package/es-custom/components/prompt-line/src/tiptap/resolve-config-items.js.map +1 -1
  135. package/es-custom/components/reasoning-steps/src/reasoning-step.js +2 -2
  136. package/es-custom/components/reasoning-steps/src/reasoning-step.js.map +1 -1
  137. package/es-custom/components/reasoning-steps/src/reasoning-step.scss.js +1 -1
  138. package/es-custom/components/shared/dynamic-css-var-sheet.js +7 -6
  139. package/es-custom/components/shared/dynamic-css-var-sheet.js.map +1 -1
  140. package/es-custom/components/table/src/table.js +5 -7
  141. package/es-custom/components/table/src/table.js.map +1 -1
  142. package/es-custom/components/workspace-shell/src/workspace-shell.js +15 -5
  143. package/es-custom/components/workspace-shell/src/workspace-shell.js.map +1 -1
  144. package/es-custom/components/workspace-shell/src/workspace-shell.scss.js +1 -1
  145. package/es-custom/globals/utils/iconTransform.d.ts +1 -1
  146. package/es-custom/globals/utils/iconTransform.js.map +1 -1
  147. package/es-custom/react/chat-shell.js +3 -0
  148. package/es-custom/react/chat-shell.js.map +1 -1
  149. package/es-custom/react/conversational-search-shell.d.ts +12 -0
  150. package/es-custom/react/conversational-search-shell.js +32 -0
  151. package/es-custom/react/conversational-search-shell.js.map +1 -0
  152. package/package.json +9 -9
  153. package/telemetry.yml +6 -4
@@ -94,7 +94,6 @@ function createCarbonTheme() {
94
94
  },
95
95
  // Editor content
96
96
  '.cm-content': {
97
- flexBasis: '0 !important',
98
97
  caretColor: 'var(--cds-text-primary, #161616)',
99
98
  },
100
99
  // The snippet's container element ([data-cds-aichat-snippet-id]) is the
@@ -147,11 +146,8 @@ function createCarbonTheme() {
147
146
  '.cm-selectionMatch': {
148
147
  backgroundColor: 'var(--cds-highlight, #d0e2ff)',
149
148
  },
150
- '&.cm-focused .cm-selectionBackground': {
151
- backgroundColor: 'var(--cds-highlight, #d0e2ff) !important',
152
- },
153
- '&.cm-focused .cm-selectionMatch': {
154
- backgroundColor: 'var(--cds-highlight, #d0e2ff) !important',
149
+ '&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground': {
150
+ backgroundColor: 'var(--cds-highlight, #d0e2ff)',
155
151
  },
156
152
  // Native selection fallback
157
153
  '.cm-content ::selection': {
@@ -1 +1 @@
1
- {"version":3,"file":"theme.js","sources":["../../../../../src/components/code-snippet/src/codemirror/theme.ts"],"sourcesContent":["/*\n * Copyright IBM Corp. 2025, 2026\n *\n * This source code is licensed under the Apache-2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * @license\n */\n\nimport { EditorView, ViewPlugin, ViewUpdate } from '@codemirror/view';\nimport { HighlightStyle, syntaxHighlighting } from '@codemirror/language';\nimport { tags as t } from '@lezer/highlight';\n\n/**\n * Extension that makes the .cm-scroller element keyboard focusable.\n * This fixes the \"scrollable-region-focusable\" accessibility violation\n * by changing tabindex from -1 (programmatic focus only) to 0 (keyboard focusable).\n *\n * @returns CodeMirror extension\n */\nexport function makeScrollerFocusable() {\n return ViewPlugin.fromClass(\n class {\n constructor(view: EditorView) {\n this.updateScrollerTabIndex(view);\n }\n\n update(update: ViewUpdate) {\n // Re-apply on any update to ensure it persists\n this.updateScrollerTabIndex(update.view);\n }\n\n updateScrollerTabIndex(view: EditorView) {\n const scroller = view.scrollDOM;\n if (scroller && scroller.getAttribute('tabindex') === '-1') {\n scroller.setAttribute('tabindex', '0');\n }\n }\n }\n );\n}\n\n/**\n * Creates a CodeMirror theme that uses Carbon Design System CSS custom properties.\n * This allows the editor to automatically adapt to Carbon's light/dark themes.\n *\n * @example\n * ```typescript\n * import { EditorView } from 'codemirror';\n * import { createCarbonTheme, createCarbonHighlightStyle } from '@carbon/ai-chat-components/es/globals/codemirror/theme';\n * import { createCarbonFoldMarker, carbonFoldMarkerKeyHandler } from '@carbon/ai-chat-components/es/globals/codemirror/marker-utils';\n * import { lineNumbers, foldGutter } from '@codemirror/view';\n * import { javascript } from '@codemirror/lang-javascript';\n *\n * const editor = new EditorView({\n * parent: document.body,\n * extensions: [\n * createCarbonTheme(),\n * createCarbonHighlightStyle(),\n * lineNumbers(),\n * foldGutter({ markerDOM: createCarbonFoldMarker() }),\n * carbonFoldMarkerKeyHandler(), // Enable keyboard support for fold markers\n * javascript(),\n * ],\n * });\n * ```\n *\n * @returns CodeMirror theme extension\n */\nexport function createCarbonTheme() {\n return EditorView.theme({\n '.cm-editor': {\n background: 'var(--cds-layer, #ffffff)',\n color: 'var(--cds-text-primary, #161616)',\n },\n\n // Cursor / caret\n '.cm-cursor, .cm-dropCursor': {\n borderLeftColor: 'var(--cds-text-primary, #161616)',\n },\n\n // Gutters. Match the snippet surface (chat-shell-background) so the gutter\n // and code area read as one surface. The disabled state overrides both to\n // $layer in code-snippet.scss (:host([disabled])), keeping them matched.\n '.cm-gutters': {\n backgroundColor: 'var(--cds-chat-shell-background, #ffffff)',\n color: 'var(--cds-text-helper, #6f6f6f)',\n border: 'none',\n },\n\n '.cm-gutterElement .cm-lineNumbers': {\n textAlign: 'end',\n },\n\n '.cm-foldGutter': {\n paddingInlineEnd: '0.25rem',\n },\n\n // Editor content\n '.cm-content': {\n flexBasis: '0 !important',\n caretColor: 'var(--cds-text-primary, #161616)',\n },\n\n // The snippet's container element ([data-cds-aichat-snippet-id]) is the\n // single source of truth for height. It declares its own min/max-block-size\n // and overflow rules in code-snippet.scss; the scroller sits inside it and\n // should inherit those bounds rather than fight them with its own\n // independent floor/ceiling.\n '.cm-scroller': {\n fontFamily: \"var(--cds-code-01-font-family, 'IBM Plex Mono', monospace)\",\n fontSize: 'var(--cds-code-01-font-size, 0.875rem)',\n fontWeight: 'var(--cds-code-01-font-weight, 400)',\n letterSpacing: 'var(--cds-code-01-letter-spacing, 0.16px)',\n lineHeight: 'var(--cds-code-01-line-height, 1.5)',\n maxBlockSize: 'var(--cds-snippet-max-height, 16rem)',\n minBlockSize: 'var(--cds-snippet-min-height, auto)',\n },\n\n // Fold gutter / caret icons\n '.cm-foldGutter .cm-gutterElement': {\n display: 'flex',\n justifyContent: 'center',\n alignItems: 'center',\n width: '16px',\n },\n\n '.cm-foldGutter svg': {\n width: '12px',\n height: '12px',\n cursor: 'pointer',\n transition: 'transform 0.11s cubic-bezier(0.2, 0, 0.38, 0.9)',\n fill: 'var(--cds-icon-primary, #161616)',\n },\n\n \".cm-foldGutter svg[aria-expanded='true']\": {\n transform: 'rotate(0deg)',\n },\n\n \".cm-foldGutter svg[aria-expanded='false']\": {\n transform: 'rotate(-90deg)',\n },\n\n '.cm-foldGutter svg:focus': {\n outline: '2px solid var(--cds-focus, #0f62fe)',\n },\n\n // Search / selection highlights\n '.cm-searchMatch': {\n backgroundColor: 'var(--cds-highlight, #d0e2ff)',\n },\n '.cm-searchMatch-selected': {\n backgroundColor: 'var(--cds-highlight, #d0e2ff)',\n },\n '.cm-selectionBackground': {\n backgroundColor: 'var(--cds-highlight, #d0e2ff)',\n },\n '.cm-selectionMatch': {\n backgroundColor: 'var(--cds-highlight, #d0e2ff)',\n },\n\n '&.cm-focused .cm-selectionBackground': {\n backgroundColor: 'var(--cds-highlight, #d0e2ff) !important',\n },\n\n '&.cm-focused .cm-selectionMatch': {\n backgroundColor: 'var(--cds-highlight, #d0e2ff) !important',\n },\n\n // Native selection fallback\n '.cm-content ::selection': {\n backgroundColor: 'var(--cds-highlight, #d0e2ff) !important',\n },\n '&.cm-focused .cm-content ::selection': {\n backgroundColor: 'var(--cds-highlight, #d0e2ff) !important',\n },\n });\n}\n\n/**\n * Creates syntax highlighting styles using Carbon Design System CSS custom properties.\n * This provides color theming for code syntax that adapts to Carbon's light/dark themes.\n *\n * All syntax colors are defined using CSS custom properties (--cds-syntax-*) that can be\n * customized via your Carbon theme. Fallback values mirror VSCode Light defaults.\n *\n * @example\n * ```typescript\n * import { EditorView } from 'codemirror';\n * import { createCarbonTheme, createCarbonHighlightStyle } from '@carbon/ai-chat-components/es/globals/codemirror/theme';\n * import { python } from '@codemirror/lang-python';\n *\n * const editor = new EditorView({\n * parent: document.body,\n * extensions: [\n * createCarbonTheme(),\n * createCarbonHighlightStyle(),\n * python(),\n * ],\n * });\n * ```\n *\n * @returns CodeMirror syntax highlighting extension\n */\nexport function createCarbonHighlightStyle() {\n return syntaxHighlighting(carbonHighlightStyle);\n}\n\ntype StyleSpec = Parameters<typeof HighlightStyle.define>[0][number];\n\nconst TAG_REGISTRY = t as Record<string, unknown>;\n\nconst toVarName = (name: string) =>\n name\n .replace(/([a-z0-9])([A-Z])/g, '$1-$2')\n .replace(/([A-Za-z])([0-9])/g, '$1-$2')\n .toLowerCase();\n\nconst colorVar = (token: string) =>\n `var(--cds-syntax-${token}, var(--cds-text-primary, #161616))`;\n\nconst resolveTag = (tagName: string) => TAG_REGISTRY[tagName] as any;\n\nconst BASE_TAG_NAMES = [\n 'comment',\n 'lineComment',\n 'blockComment',\n 'docComment',\n 'name',\n 'variableName',\n 'typeName',\n 'tagName',\n 'propertyName',\n 'attributeName',\n 'className',\n 'labelName',\n 'namespace',\n 'macroName',\n 'literal',\n 'string',\n 'docString',\n 'character',\n 'attributeValue',\n 'number',\n 'integer',\n 'float',\n 'bool',\n 'regexp',\n 'escape',\n 'color',\n 'url',\n 'keyword',\n 'self',\n 'null',\n 'atom',\n 'unit',\n 'modifier',\n 'operatorKeyword',\n 'controlKeyword',\n 'definitionKeyword',\n 'moduleKeyword',\n 'operator',\n 'derefOperator',\n 'arithmeticOperator',\n 'logicOperator',\n 'bitwiseOperator',\n 'compareOperator',\n 'updateOperator',\n 'definitionOperator',\n 'typeOperator',\n 'controlOperator',\n 'punctuation',\n 'separator',\n 'bracket',\n 'angleBracket',\n 'squareBracket',\n 'paren',\n 'brace',\n 'content',\n 'heading',\n 'heading1',\n 'heading2',\n 'heading3',\n 'heading4',\n 'heading5',\n 'heading6',\n 'contentSeparator',\n 'list',\n 'quote',\n 'emphasis',\n 'strong',\n 'link',\n 'monospace',\n 'strikethrough',\n 'invalid',\n 'meta',\n 'documentMeta',\n 'annotation',\n 'processingInstruction',\n] as const;\n\nconst HEADING_TAG_NAMES = [\n 'heading',\n 'heading1',\n 'heading2',\n 'heading3',\n 'heading4',\n 'heading5',\n 'heading6',\n] as const;\n\nconst manualConfigs: Array<{\n tagName: string;\n style: Partial<Omit<StyleSpec, 'tag'>>;\n}> = [\n ...HEADING_TAG_NAMES.map((tagName) => ({\n tagName,\n style: {\n fontWeight: 'bold',\n textDecoration: 'underline',\n },\n })),\n { tagName: 'link', style: { textDecoration: 'underline' } },\n { tagName: 'emphasis', style: { fontStyle: 'italic' } },\n { tagName: 'strong', style: { fontWeight: 'bold' } },\n { tagName: 'strikethrough', style: { textDecoration: 'line-through' } },\n];\n\nconst MANUAL_TAG_NAMES = new Set(manualConfigs.map(({ tagName }) => tagName));\n\nconst manualTokenStyles: StyleSpec[] = manualConfigs\n .map(({ tagName, style }) => {\n const tag = resolveTag(tagName);\n if (!tag) {\n return null;\n }\n return {\n tag,\n color: colorVar(toVarName(tagName)),\n ...style,\n };\n })\n .filter(Boolean) as StyleSpec[];\n\nconst autoTagStyles: StyleSpec[] = BASE_TAG_NAMES.filter(\n (tagName) => !MANUAL_TAG_NAMES.has(tagName)\n)\n .map((tagName) => {\n const tag = resolveTag(tagName);\n if (!tag) {\n return null;\n }\n return {\n tag,\n color: colorVar(toVarName(tagName)),\n };\n })\n .filter(Boolean) as StyleSpec[];\n\nconst modifierTokenStyles: StyleSpec[] = [\n { tag: t.definition(t.variableName), color: colorVar('definition') },\n { tag: t.definition(t.propertyName), color: colorVar('definition') },\n { tag: t.definition(t.typeName), color: colorVar('definition') },\n { tag: t.definition(t.className), color: colorVar('definition') },\n { tag: t.constant(t.variableName), color: colorVar('constant') },\n { tag: t.constant(t.propertyName), color: colorVar('constant') },\n { tag: t.constant(t.typeName), color: colorVar('constant') },\n { tag: t.function(t.variableName), color: colorVar('function') },\n { tag: t.function(t.propertyName), color: colorVar('function') },\n { tag: t.function(t.typeName), color: colorVar('function') },\n { tag: t.standard(t.variableName), color: colorVar('standard') },\n { tag: t.standard(t.propertyName), color: colorVar('standard') },\n { tag: t.local(t.variableName), color: colorVar('local') },\n { tag: t.local(t.propertyName), color: colorVar('local') },\n { tag: t.special(t.variableName), color: colorVar('special') },\n { tag: t.special(t.propertyName), color: colorVar('special') },\n { tag: t.special(t.string), color: colorVar('special-string') },\n];\n\nconst carbonHighlightStyle = HighlightStyle.define([\n ...modifierTokenStyles,\n ...manualTokenStyles,\n ...autoTagStyles,\n]);\n"],"names":["t"],"mappings":";;;;;;;;;;;AAAA;;;;;;;AAOG;AAMH;;;;;;AAMG;SACa,qBAAqB,GAAA;IACnC,OAAO,UAAU,CAAC,SAAS,CACzB,MAAA;AACE,QAAA,WAAA,CAAY,IAAgB,EAAA;AAC1B,YAAA,IAAI,CAAC,sBAAsB,CAAC,IAAI,CAAC;QACnC;AAEA,QAAA,MAAM,CAAC,MAAkB,EAAA;;AAEvB,YAAA,IAAI,CAAC,sBAAsB,CAAC,MAAM,CAAC,IAAI,CAAC;QAC1C;AAEA,QAAA,sBAAsB,CAAC,IAAgB,EAAA;AACrC,YAAA,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS;YAC/B,IAAI,QAAQ,IAAI,QAAQ,CAAC,YAAY,CAAC,UAAU,CAAC,KAAK,IAAI,EAAE;AAC1D,gBAAA,QAAQ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AAiB;AACpB,IAAA,GAAG,aAAa;AACjB,CAAA,CAAC;;"}
1
+ {"version":3,"file":"theme.js","sources":["../../../../../src/components/code-snippet/src/codemirror/theme.ts"],"sourcesContent":["/*\n * Copyright IBM Corp. 2025, 2026\n *\n * This source code is licensed under the Apache-2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * @license\n */\n\nimport { EditorView, ViewPlugin, ViewUpdate } from '@codemirror/view';\nimport { HighlightStyle, syntaxHighlighting } from '@codemirror/language';\nimport { tags as t } from '@lezer/highlight';\n\n/**\n * Extension that makes the .cm-scroller element keyboard focusable.\n * This fixes the \"scrollable-region-focusable\" accessibility violation\n * by changing tabindex from -1 (programmatic focus only) to 0 (keyboard focusable).\n *\n * @returns CodeMirror extension\n */\nexport function makeScrollerFocusable() {\n return ViewPlugin.fromClass(\n class {\n constructor(view: EditorView) {\n this.updateScrollerTabIndex(view);\n }\n\n update(update: ViewUpdate) {\n // Re-apply on any update to ensure it persists\n this.updateScrollerTabIndex(update.view);\n }\n\n updateScrollerTabIndex(view: EditorView) {\n const scroller = view.scrollDOM;\n if (scroller && scroller.getAttribute('tabindex') === '-1') {\n scroller.setAttribute('tabindex', '0');\n }\n }\n }\n );\n}\n\n/**\n * Creates a CodeMirror theme that uses Carbon Design System CSS custom properties.\n * This allows the editor to automatically adapt to Carbon's light/dark themes.\n *\n * @example\n * ```typescript\n * import { EditorView } from 'codemirror';\n * import { createCarbonTheme, createCarbonHighlightStyle } from '@carbon/ai-chat-components/es/globals/codemirror/theme';\n * import { createCarbonFoldMarker, carbonFoldMarkerKeyHandler } from '@carbon/ai-chat-components/es/globals/codemirror/marker-utils';\n * import { lineNumbers, foldGutter } from '@codemirror/view';\n * import { javascript } from '@codemirror/lang-javascript';\n *\n * const editor = new EditorView({\n * parent: document.body,\n * extensions: [\n * createCarbonTheme(),\n * createCarbonHighlightStyle(),\n * lineNumbers(),\n * foldGutter({ markerDOM: createCarbonFoldMarker() }),\n * carbonFoldMarkerKeyHandler(), // Enable keyboard support for fold markers\n * javascript(),\n * ],\n * });\n * ```\n *\n * @returns CodeMirror theme extension\n */\nexport function createCarbonTheme() {\n return EditorView.theme({\n '.cm-editor': {\n background: 'var(--cds-layer, #ffffff)',\n color: 'var(--cds-text-primary, #161616)',\n },\n\n // Cursor / caret\n '.cm-cursor, .cm-dropCursor': {\n borderLeftColor: 'var(--cds-text-primary, #161616)',\n },\n\n // Gutters. Match the snippet surface (chat-shell-background) so the gutter\n // and code area read as one surface. The disabled state overrides both to\n // $layer in code-snippet.scss (:host([disabled])), keeping them matched.\n '.cm-gutters': {\n backgroundColor: 'var(--cds-chat-shell-background, #ffffff)',\n color: 'var(--cds-text-helper, #6f6f6f)',\n border: 'none',\n },\n\n '.cm-gutterElement .cm-lineNumbers': {\n textAlign: 'end',\n },\n\n '.cm-foldGutter': {\n paddingInlineEnd: '0.25rem',\n },\n\n // Editor content\n '.cm-content': {\n caretColor: 'var(--cds-text-primary, #161616)',\n },\n\n // The snippet's container element ([data-cds-aichat-snippet-id]) is the\n // single source of truth for height. It declares its own min/max-block-size\n // and overflow rules in code-snippet.scss; the scroller sits inside it and\n // should inherit those bounds rather than fight them with its own\n // independent floor/ceiling.\n '.cm-scroller': {\n fontFamily: \"var(--cds-code-01-font-family, 'IBM Plex Mono', monospace)\",\n fontSize: 'var(--cds-code-01-font-size, 0.875rem)',\n fontWeight: 'var(--cds-code-01-font-weight, 400)',\n letterSpacing: 'var(--cds-code-01-letter-spacing, 0.16px)',\n lineHeight: 'var(--cds-code-01-line-height, 1.5)',\n maxBlockSize: 'var(--cds-snippet-max-height, 16rem)',\n minBlockSize: 'var(--cds-snippet-min-height, auto)',\n },\n\n // Fold gutter / caret icons\n '.cm-foldGutter .cm-gutterElement': {\n display: 'flex',\n justifyContent: 'center',\n alignItems: 'center',\n width: '16px',\n },\n\n '.cm-foldGutter svg': {\n width: '12px',\n height: '12px',\n cursor: 'pointer',\n transition: 'transform 0.11s cubic-bezier(0.2, 0, 0.38, 0.9)',\n fill: 'var(--cds-icon-primary, #161616)',\n },\n\n \".cm-foldGutter svg[aria-expanded='true']\": {\n transform: 'rotate(0deg)',\n },\n\n \".cm-foldGutter svg[aria-expanded='false']\": {\n transform: 'rotate(-90deg)',\n },\n\n '.cm-foldGutter svg:focus': {\n outline: '2px solid var(--cds-focus, #0f62fe)',\n },\n\n // Search / selection highlights\n '.cm-searchMatch': {\n backgroundColor: 'var(--cds-highlight, #d0e2ff)',\n },\n '.cm-searchMatch-selected': {\n backgroundColor: 'var(--cds-highlight, #d0e2ff)',\n },\n '.cm-selectionBackground': {\n backgroundColor: 'var(--cds-highlight, #d0e2ff)',\n },\n '.cm-selectionMatch': {\n backgroundColor: 'var(--cds-highlight, #d0e2ff)',\n },\n\n '&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground':\n {\n backgroundColor: 'var(--cds-highlight, #d0e2ff)',\n },\n\n // Native selection fallback\n '.cm-content ::selection': {\n backgroundColor: 'var(--cds-highlight, #d0e2ff) !important',\n },\n '&.cm-focused .cm-content ::selection': {\n backgroundColor: 'var(--cds-highlight, #d0e2ff) !important',\n },\n });\n}\n\n/**\n * Creates syntax highlighting styles using Carbon Design System CSS custom properties.\n * This provides color theming for code syntax that adapts to Carbon's light/dark themes.\n *\n * All syntax colors are defined using CSS custom properties (--cds-syntax-*) that can be\n * customized via your Carbon theme. Fallback values mirror VSCode Light defaults.\n *\n * @example\n * ```typescript\n * import { EditorView } from 'codemirror';\n * import { createCarbonTheme, createCarbonHighlightStyle } from '@carbon/ai-chat-components/es/globals/codemirror/theme';\n * import { python } from '@codemirror/lang-python';\n *\n * const editor = new EditorView({\n * parent: document.body,\n * extensions: [\n * createCarbonTheme(),\n * createCarbonHighlightStyle(),\n * python(),\n * ],\n * });\n * ```\n *\n * @returns CodeMirror syntax highlighting extension\n */\nexport function createCarbonHighlightStyle() {\n return syntaxHighlighting(carbonHighlightStyle);\n}\n\ntype StyleSpec = Parameters<typeof HighlightStyle.define>[0][number];\n\nconst TAG_REGISTRY = t as Record<string, unknown>;\n\nconst toVarName = (name: string) =>\n name\n .replace(/([a-z0-9])([A-Z])/g, '$1-$2')\n .replace(/([A-Za-z])([0-9])/g, '$1-$2')\n .toLowerCase();\n\nconst colorVar = (token: string) =>\n `var(--cds-syntax-${token}, var(--cds-text-primary, #161616))`;\n\nconst resolveTag = (tagName: string) => TAG_REGISTRY[tagName] as any;\n\nconst BASE_TAG_NAMES = [\n 'comment',\n 'lineComment',\n 'blockComment',\n 'docComment',\n 'name',\n 'variableName',\n 'typeName',\n 'tagName',\n 'propertyName',\n 'attributeName',\n 'className',\n 'labelName',\n 'namespace',\n 'macroName',\n 'literal',\n 'string',\n 'docString',\n 'character',\n 'attributeValue',\n 'number',\n 'integer',\n 'float',\n 'bool',\n 'regexp',\n 'escape',\n 'color',\n 'url',\n 'keyword',\n 'self',\n 'null',\n 'atom',\n 'unit',\n 'modifier',\n 'operatorKeyword',\n 'controlKeyword',\n 'definitionKeyword',\n 'moduleKeyword',\n 'operator',\n 'derefOperator',\n 'arithmeticOperator',\n 'logicOperator',\n 'bitwiseOperator',\n 'compareOperator',\n 'updateOperator',\n 'definitionOperator',\n 'typeOperator',\n 'controlOperator',\n 'punctuation',\n 'separator',\n 'bracket',\n 'angleBracket',\n 'squareBracket',\n 'paren',\n 'brace',\n 'content',\n 'heading',\n 'heading1',\n 'heading2',\n 'heading3',\n 'heading4',\n 'heading5',\n 'heading6',\n 'contentSeparator',\n 'list',\n 'quote',\n 'emphasis',\n 'strong',\n 'link',\n 'monospace',\n 'strikethrough',\n 'invalid',\n 'meta',\n 'documentMeta',\n 'annotation',\n 'processingInstruction',\n] as const;\n\nconst HEADING_TAG_NAMES = [\n 'heading',\n 'heading1',\n 'heading2',\n 'heading3',\n 'heading4',\n 'heading5',\n 'heading6',\n] as const;\n\nconst manualConfigs: Array<{\n tagName: string;\n style: Partial<Omit<StyleSpec, 'tag'>>;\n}> = [\n ...HEADING_TAG_NAMES.map((tagName) => ({\n tagName,\n style: {\n fontWeight: 'bold',\n textDecoration: 'underline',\n },\n })),\n { tagName: 'link', style: { textDecoration: 'underline' } },\n { tagName: 'emphasis', style: { fontStyle: 'italic' } },\n { tagName: 'strong', style: { fontWeight: 'bold' } },\n { tagName: 'strikethrough', style: { textDecoration: 'line-through' } },\n];\n\nconst MANUAL_TAG_NAMES = new Set(manualConfigs.map(({ tagName }) => tagName));\n\nconst manualTokenStyles: StyleSpec[] = manualConfigs\n .map(({ tagName, style }) => {\n const tag = resolveTag(tagName);\n if (!tag) {\n return null;\n }\n return {\n tag,\n color: colorVar(toVarName(tagName)),\n ...style,\n };\n })\n .filter(Boolean) as StyleSpec[];\n\nconst autoTagStyles: StyleSpec[] = BASE_TAG_NAMES.filter(\n (tagName) => !MANUAL_TAG_NAMES.has(tagName)\n)\n .map((tagName) => {\n const tag = resolveTag(tagName);\n if (!tag) {\n return null;\n }\n return {\n tag,\n color: colorVar(toVarName(tagName)),\n };\n })\n .filter(Boolean) as StyleSpec[];\n\nconst modifierTokenStyles: StyleSpec[] = [\n { tag: t.definition(t.variableName), color: colorVar('definition') },\n { tag: t.definition(t.propertyName), color: colorVar('definition') },\n { tag: t.definition(t.typeName), color: colorVar('definition') },\n { tag: t.definition(t.className), color: colorVar('definition') },\n { tag: t.constant(t.variableName), color: colorVar('constant') },\n { tag: t.constant(t.propertyName), color: colorVar('constant') },\n { tag: t.constant(t.typeName), color: colorVar('constant') },\n { tag: t.function(t.variableName), color: colorVar('function') },\n { tag: t.function(t.propertyName), color: colorVar('function') },\n { tag: t.function(t.typeName), color: colorVar('function') },\n { tag: t.standard(t.variableName), color: colorVar('standard') },\n { tag: t.standard(t.propertyName), color: colorVar('standard') },\n { tag: t.local(t.variableName), color: colorVar('local') },\n { tag: t.local(t.propertyName), color: colorVar('local') },\n { tag: t.special(t.variableName), color: colorVar('special') },\n { tag: t.special(t.propertyName), color: colorVar('special') },\n { tag: t.special(t.string), color: colorVar('special-string') },\n];\n\nconst carbon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AAC1D,IAAA,EAAE,GAAG,EAAEA,IAAC,CAAC,OAAO,CAACA,IAAC,CAAC,YAAY,CAAC,EAAE,KAAK,EAAE,QAAQ,CAAC,SAAS,CAAC,EAAE;AAC9D,IAAA,EAAE,GAAG,EAAEA,IAAC,CAAC,OAAO,CAACA,IAAC,CAAC,YAAY,CAAC,EAAE,KAAK,EAAE,QAAQ,CAAC,SAAS,CAAC,EAAE;AAC9D,IAAA,EAAE,GAAG,EAAEA,IAAC,CAAC,OAAO,CAACA,IAAC,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,QAAQ,CAAC,gBAAgB,CAAC,EAAE;CAChE;AAED,MAAM,oBAAoB,GAAG,cAAc,CAAC,MAAM,CAAC;AACjD,IAAA,GAAG,mBAAmB;AACtB,IAAA,GAAG,iBAAiB;AACpB,IAAA,GAAG,aAAa;AACjB,CAAA,CAAC;;"}
@@ -8,9 +8,7 @@ interface ContainerStyleConfig {
8
8
  }
9
9
  /**
10
10
  * Container style properties as CSS custom properties.
11
- * Applied via the shared dynamic stylesheet (`setVarsForSelector`), not
12
- * `element.style.setProperty`, so a strict CSP can drop
13
- * `style-src-attr 'unsafe-inline'`.
11
+ * Applied via the shared dynamic stylesheet (`setVarsForSelector`).
14
12
  */
15
13
  export interface ContainerStyleProperties {
16
14
  '--cds-snippet-max-height'?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"layout-utils.js","sources":["../../../../src/components/code-snippet/src/layout-utils.ts"],"sourcesContent":["/*\n * Copyright IBM Corp. 2025, 2026\n *\n * This source code is licensed under the Apache-2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * @license\n */\n\ninterface ContainerStyleConfig {\n expanded: boolean;\n maxCollapsed: number;\n maxExpanded: number;\n minCollapsed: number;\n minExpanded: number;\n rowHeight: number;\n}\n\n/**\n * Container style properties as CSS custom properties.\n * Applied via the shared dynamic stylesheet (`setVarsForSelector`), not\n * `element.style.setProperty`, so a strict CSP can drop\n * `style-src-attr 'unsafe-inline'`.\n */\nexport interface ContainerStyleProperties {\n '--cds-snippet-max-height'?: string;\n '--cds-snippet-min-height'?: string;\n}\n\nexport function buildContainerStyles({\n expanded,\n maxCollapsed,\n maxExpanded,\n minCollapsed,\n minExpanded,\n rowHeight,\n}: ContainerStyleConfig): ContainerStyleProperties {\n const properties: ContainerStyleProperties = {};\n\n // Detect fill-container mode: when both max properties are 0\n const isFillMode = maxCollapsed === 0 && maxExpanded === 0;\n\n if (isFillMode) {\n // Fill-container mode: use 100% height with scrollbar\n properties['--cds-snippet-max-height'] = '100%';\n properties['--cds-snippet-min-height'] = 'auto';\n return properties;\n }\n\n // Existing row-based logic. `Infinity` opts into \"grow with content\" —\n // the relevant clamp is dropped so the snippet fits its content with no\n // internal scrollbar. Pair `maxCollapsedNumberOfRows: Infinity` and\n // `maxExpandedNumberOfRows: Infinity` (and optionally `min*=0`) to embed\n // the snippet inside another scrollable surface.\n if (expanded) {\n if (maxExpanded === Infinity) {\n properties['--cds-snippet-max-height'] = 'none';\n } else if (maxExpanded > 0) {\n properties['--cds-snippet-max-height'] = `${maxExpanded * rowHeight}px`;\n } else {\n // Remove the default CodeMirror max height so expanded snippets can grow to fit content\n properties['--cds-snippet-max-height'] = 'none';\n }\n if (minExpanded > 0 && minExpanded !== Infinity) {\n properties['--cds-snippet-min-height'] = `${minExpanded * rowHeight}px`;\n }\n } else {\n if (maxCollapsed === Infinity) {\n properties['--cds-snippet-max-height'] = 'none';\n } else if (maxCollapsed > 0) {\n properties['--cds-snippet-max-height'] = `${maxCollapsed * rowHeight}px`;\n }\n if (minCollapsed > 0 && minCollapsed !== Infinity) {\n properties['--cds-snippet-min-height'] = `${minCollapsed * rowHeight}px`;\n }\n }\n\n return properties;\n}\n\ninterface ShowMoreEvaluationInput {\n shadowRoot: ShadowRoot | null;\n rowHeight: number;\n expanded: boolean;\n maxCollapsed: number;\n maxExpanded: number;\n minExpanded: number;\n}\n\nexport function evaluateShowMoreButton({\n shadowRoot,\n rowHeight,\n expanded,\n maxCollapsed,\n maxExpanded,\n minExpanded,\n}: ShowMoreEvaluationInput): {\n shouldShowButton: boolean;\n shouldCollapse: boolean;\n} {\n // Hide button in fill-container mode or in unbounded grow mode — in both\n // cases the snippet either fills its host or fits its content and there is\n // no max to expand past, so the show-more affordance has nothing to do.\n const isFillMode = maxCollapsed === 0 && maxExpanded === 0;\n const isGrowMode = maxCollapsed === Infinity || maxExpanded === Infinity;\n if (isFillMode || isGrowMode) {\n return { shouldShowButton: false, shouldCollapse: false };\n }\n\n const editorNode = shadowRoot?.querySelector(`.cm-content`);\n\n if (!editorNode) {\n return { shouldShowButton: false, shouldCollapse: false };\n }\n\n const { height } = editorNode.getBoundingClientRect();\n\n const shouldShowButton =\n maxCollapsed > 0 &&\n (maxExpanded <= 0 || maxExpanded > maxCollapsed) &&\n height > maxCollapsed * rowHeight;\n\n const shouldCollapse =\n expanded && minExpanded > 0 && height <= minExpanded * rowHeight;\n\n return { shouldShowButton, shouldCollapse };\n}\n"],"names":[],"mappings":";;;;;;;AAAA;;;;;;;AAOG;AAsBG,SAAU,oBAAoB,CAAC,EACnC,QAAQ,EACR,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,WAAW,EACX,SAAS,GACY,EAAA;IACrB,MAAM,UAAU,GAA6B,EAAE;;IAG/C,MAAM,UAAU,GAAG,YAAY,KAAK,CAAC,IAAI,WAAW,KAAK,CAAC;IAE1D,IAAI,UAAU,EAAE;;AAEd,QAAA,UAAU,CAAC,0BAA0B,CAAC,GAAG,MAAM;AAC/C,QAAA,UAAU,CAAC,0BAA0B,CAAC,GAAG,MAAM;AAC/C,QAAA,OAAO,UAAU;IACnB;;;;;;IAOA,IAAI,QAAQ,EAAE;AACZ,QAAA,IAAI,WAAW,KAAK,QAAQ,EAAE;AAC5B,YAAA,UAAU,CAAC,0BAA0B,CAAC,GAAG,MAAM;QACjD;AAAO,aAAA,IAAI,WAAW,GAAG,CAAC,EAAE;YAC1B,UAAU,CAAC,0BAA0B,CAAC,GA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IAEA,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC,qBAAqB,EAAE;AAErD,IAAA,MAAM,gBAAgB,GACpB,YAAY,GAAG,CAAC;AAChB,SAAC,WAAW,IAAI,CAAC,IAAI,WAAW,GAAG,YAAY,CAAC;AAChD,QAAA,MAAM,GAAG,YAAY,GAAG,SAAS;AAEnC,IAAA,MAAM,cAAc,GAClB,QAAQ,IAAI,WAAW,GAAG,CAAC,IAAI,MAAM,IAAI,WAAW,GAAG,SAAS;AAElE,IAAA,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE;AAC7C;;"}
1
+ {"version":3,"file":"layout-utils.js","sources":["../../../../src/components/code-snippet/src/layout-utils.ts"],"sourcesContent":["/*\n * Copyright IBM Corp. 2025, 2026\n *\n * This source code is licensed under the Apache-2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * @license\n */\n\ninterface ContainerStyleConfig {\n expanded: boolean;\n maxCollapsed: number;\n maxExpanded: number;\n minCollapsed: number;\n minExpanded: number;\n rowHeight: number;\n}\n\n/**\n * Container style properties as CSS custom properties.\n * Applied via the shared dynamic stylesheet (`setVarsForSelector`).\n */\nexport interface ContainerStyleProperties {\n '--cds-snippet-max-height'?: string;\n '--cds-snippet-min-height'?: string;\n}\n\nexport function buildContainerStyles({\n expanded,\n maxCollapsed,\n maxExpanded,\n minCollapsed,\n minExpanded,\n rowHeight,\n}: ContainerStyleConfig): ContainerStyleProperties {\n const properties: ContainerStyleProperties = {};\n\n // Detect fill-container mode: when both max properties are 0\n const isFillMode = maxCollapsed === 0 && maxExpanded === 0;\n\n if (isFillMode) {\n // Fill-container mode: use 100% height with scrollbar\n properties['--cds-snippet-max-height'] = '100%';\n properties['--cds-snippet-min-height'] = 'auto';\n return properties;\n }\n\n // Existing row-based logic. `Infinity` opts into \"grow with content\" —\n // the relevant clamp is dropped so the snippet fits its content with no\n // internal scrollbar. Pair `maxCollapsedNumberOfRows: Infinity` and\n // `maxExpandedNumberOfRows: Infinity` (and optionally `min*=0`) to embed\n // the snippet inside another scrollable surface.\n if (expanded) {\n if (maxExpanded === Infinity) {\n properties['--cds-snippet-max-height'] = 'none';\n } else if (maxExpanded > 0) {\n properties['--cds-snippet-max-height'] = `${maxExpanded * rowHeight}px`;\n } else {\n // Remove the default CodeMirror max height so expanded snippets can grow to fit content\n properties['--cds-snippet-max-height'] = 'none';\n }\n if (minExpanded > 0 && minExpanded !== Infinity) {\n properties['--cds-snippet-min-height'] = `${minExpanded * rowHeight}px`;\n }\n } else {\n if (maxCollapsed === Infinity) {\n properties['--cds-snippet-max-height'] = 'none';\n } else if (maxCollapsed > 0) {\n properties['--cds-snippet-max-height'] = `${maxCollapsed * rowHeight}px`;\n }\n if (minCollapsed > 0 && minCollapsed !== Infinity) {\n properties['--cds-snippet-min-height'] = `${minCollapsed * rowHeight}px`;\n }\n }\n\n return properties;\n}\n\ninterface ShowMoreEvaluationInput {\n shadowRoot: ShadowRoot | null;\n rowHeight: number;\n expanded: boolean;\n maxCollapsed: number;\n maxExpanded: number;\n minExpanded: number;\n}\n\nexport function evaluateShowMoreButton({\n shadowRoot,\n rowHeight,\n expanded,\n maxCollapsed,\n maxExpanded,\n minExpanded,\n}: ShowMoreEvaluationInput): {\n shouldShowButton: boolean;\n shouldCollapse: boolean;\n} {\n // Hide button in fill-container mode or in unbounded grow mode — in both\n // cases the snippet either fills its host or fits its content and there is\n // no max to expand past, so the show-more affordance has nothing to do.\n const isFillMode = maxCollapsed === 0 && maxExpanded === 0;\n const isGrowMode = maxCollapsed === Infinity || maxExpanded === Infinity;\n if (isFillMode || isGrowMode) {\n return { shouldShowButton: false, shouldCollapse: false };\n }\n\n const editorNode = shadowRoot?.querySelector(`.cm-content`);\n\n if (!editorNode) {\n return { shouldShowButton: false, shouldCollapse: false };\n }\n\n const { height } = editorNode.getBoundingClientRect();\n\n const shouldShowButton =\n maxCollapsed > 0 &&\n (maxExpanded <= 0 || maxExpanded > maxCollapsed) &&\n height > maxCollapsed * rowHeight;\n\n const shouldCollapse =\n expanded && minExpanded > 0 && height <= minExpanded * rowHeight;\n\n return { shouldShowButton, shouldCollapse };\n}\n"],"names":[],"mappings":";;;;;;;AAAA;;;;;;;AAOG;AAoBG,SAAU,oBAAoB,CAAC,EACnC,QAAQ,EACR,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,WAAW,EACX,SAAS,GACY,EAAA;IACrB,MAAM,UAAU,GAA6B,EAAE;;IAG/C,MAAM,UAAU,GAAG,YAAY,KAAK,CAAC,IAAI,WAAW,KAAK,CAAC;IAE1D,IAAI,UAAU,EAAE;;AAEd,QAAA,UAAU,CAAC,0BAA0B,CAAC,GAAG,MAAM;AAC/C,QAAA,UAAU,CAAC,0BAA0B,CAAC,GAAG,MAAM;AAC/C,QAAA,OAAO,UAAU;IACnB;;;;;;IAOA,IAAI,QAAQ,EAAE;AACZ,QAAA,IAAI,WAAW,KAAK,QAAQ,EAAE;AAC5B,YAAA,UAAU,CAAC,0BAA0B,CAAC,GAAG,MAAM;QACjD;AAAO,aAAA,IAAI,WAAW,GAAG,CAAC,EAAE;YAC1B,UAAU,CAAC,0BAA0B,CAAC,GAAG,GAAG,WAAW,GAAG,SAAS,CAAA,EAAA,CAAI;QACzE;aAAO;;AAEL,YAAA,UAAU,CAAC,0BAA0B,CAAC,GAAG,MAAM;QACjD;QACA,IAAI,WAAW,GAAG,CAAC,IAAI,WAAW,KAAK,QAAQ,EAAE;YAC/C,UAAU,CAAC,0BAA0B,CAAC,GAAG,GAAG,WAAW,GAAG,SAAS,CAAA,EAAA,CAAI;QACzE;IACF;SAAO;AACL,QAAA,IAAI,YAAY,KAAK,QAAQ,EAAE;AAC7B,YAAA,UAAU,CAAC,0BAA0B,CAAC,GAAG,MAAM;QACjD;AAAO,aAAA,IAAI,YAAY,GAAG,CAAC,EAAE;YAC3B,UAAU,CAAC,0BAA0B,CAAC,GAAG,GAAG,YAAY,GAAG,SAAS,CAAA,EAAA,CAAI;QAC1E;QACA,IAAI,YAAY,GAAG,CAAC,IAAI,YAAY,KAAK,QAAQ,EAAE;YACjD,UAAU,CAAC,0BAA0B,CAAC,GAAG,GAAG,YAAY,GAAG,SAAS,CAAA,EAAA,CAAI;QAC1E;IACF;AAEA,IAAA,OAAO,UAAU;AACnB;AAWM,SAAU,sBAAsB,CAAC,EACrC,UAAU,EACV,SAAS,EACT,QAAQ,EACR,YAAY,EACZ,WAAW,EACX,WAAW,GACa,EAAA;;;;IAOxB,MAAM,UAAU,GAAG,YAAY,KAAK,CAAC,IAAI,WAAW,KAAK,CAAC;IAC1D,MAAM,UAAU,GAAG,YAAY,KAAK,QAAQ,IAAI,WAAW,KAAK,QAAQ;AACxE,IAAA,IAAI,UAAU,IAAI,UAAU,EAAE;QAC5B,OAAO,EAAE,gBAAgB,EAAE,KAAK,EAAE,cAAc,EAAE,KAAK,EAAE;IAC3D;IAEA,MAAM,UAAU,GAAG,UAAU,EAAE,aAAa,CAAC,CAAA,WAAA,CAAa,CAAC;IAE3D,IAAI,CAAC,UAAU,EAAE;QACf,OAAO,EAAE,gBAAgB,EAAE,KAAK,EAAE,cAAc,EAAE,KAAK,EAAE;IAC3D;IAEA,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC,qBAAqB,EAAE;AAErD,IAAA,MAAM,gBAAgB,GACpB,YAAY,GAAG,CAAC;AAChB,SAAC,WAAW,IAAI,CAAC,IAAI,WAAW,GAAG,YAAY,CAAC;AAChD,QAAA,MAAM,GAAG,YAAY,GAAG,SAAS;AAEnC,IAAA,MAAM,cAAc,GAClB,QAAQ,IAAI,WAAW,GAAG,CAAC,IAAI,MAAM,IAAI,WAAW,GAAG,SAAS;AAElE,IAAA,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE;AAC7C;;"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @license
3
+ *
4
+ * Copyright IBM Corp. 2026
5
+ *
6
+ * This source code is licensed under the Apache-2.0 license found in the
7
+ * LICENSE file in the root directory of this source tree.
8
+ */
9
+ import './src/conversational-search-shell.js';
@@ -0,0 +1,9 @@
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 './src/conversational-search-shell.js';
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * @license
3
+ *
4
+ * Copyright IBM Corp. 2026
5
+ *
6
+ * This source code is licensed under the Apache-2.0 license found in the
7
+ * LICENSE file in the root directory of this source tree.
8
+ */
9
+ /** A substring of an answer associated with a citation. */
10
+ export interface CitationRange {
11
+ /** Inclusive start offset in JavaScript string code units. */
12
+ start: number;
13
+ /** Exclusive end offset in JavaScript string code units. */
14
+ end: number;
15
+ }
16
+ /** The answer ranges associated with a citation. */
17
+ export interface CitationWithRanges {
18
+ /** Ranges to highlight; citations without ranges sort last. */
19
+ ranges?: readonly CitationRange[];
20
+ }
21
+ /** Wraps nonblank citation ranges in Markdown highlight delimiters. */
22
+ export declare function insertHighlightMarkdown(text: string, highlightCitation?: CitationWithRanges | null): string;
23
+ /** Moves citations without ranges to the end, preserving each group's order. */
24
+ export declare function sortCitations<T extends CitationWithRanges>(citations?: readonly T[] | null): T[] | null;
@@ -0,0 +1,46 @@
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
+ * @license
10
+ *
11
+ * Copyright IBM Corp. 2026
12
+ *
13
+ * This source code is licensed under the Apache-2.0 license found in the
14
+ * LICENSE file in the root directory of this source tree.
15
+ */
16
+ /** Wraps nonblank citation ranges in Markdown highlight delimiters. */
17
+ function insertHighlightMarkdown(text, highlightCitation) {
18
+ const ranges = highlightCitation?.ranges;
19
+ if (!ranges?.length) {
20
+ return text;
21
+ }
22
+ const sortedRanges = [...ranges].sort((a, b) => b.start - a.start);
23
+ let processedText = text;
24
+ for (const range of sortedRanges) {
25
+ const beforeHighlight = processedText.substring(0, range.start);
26
+ const highlight = processedText.substring(range.start, range.end);
27
+ const afterHighlight = processedText.substring(range.end);
28
+ if (highlight.trim()) {
29
+ processedText =
30
+ beforeHighlight + '==' + highlight + '==' + afterHighlight;
31
+ }
32
+ }
33
+ return processedText;
34
+ }
35
+ /** Moves citations without ranges to the end, preserving each group's order. */
36
+ function sortCitations(citations) {
37
+ if (!citations) {
38
+ return null;
39
+ }
40
+ const withRanges = citations.filter((citation) => citation.ranges?.length);
41
+ const withoutRanges = citations.filter((citation) => !citation.ranges?.length);
42
+ return withRanges.concat(withoutRanges);
43
+ }
44
+
45
+ export { insertHighlightMarkdown, sortCitations };
46
+ //# sourceMappingURL=citation-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"citation-utils.js","sources":["../../../../src/components/conversational-search/src/citation-utils.ts"],"sourcesContent":["/**\n * @license\n *\n * Copyright IBM Corp. 2026\n *\n * This source code is licensed under the Apache-2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n/** A substring of an answer associated with a citation. */\nexport interface CitationRange {\n /** Inclusive start offset in JavaScript string code units. */\n start: number;\n /** Exclusive end offset in JavaScript string code units. */\n end: number;\n}\n\n/** The answer ranges associated with a citation. */\nexport interface CitationWithRanges {\n /** Ranges to highlight; citations without ranges sort last. */\n ranges?: readonly CitationRange[];\n}\n\n/** Wraps nonblank citation ranges in Markdown highlight delimiters. */\nexport function insertHighlightMarkdown(\n text: string,\n highlightCitation?: CitationWithRanges | null\n): string {\n const ranges = highlightCitation?.ranges;\n if (!ranges?.length) {\n return text;\n }\n const sortedRanges = [...ranges].sort((a, b) => b.start - a.start);\n let processedText = text;\n for (const range of sortedRanges) {\n const beforeHighlight = processedText.substring(0, range.start);\n const highlight = processedText.substring(range.start, range.end);\n const afterHighlight = processedText.substring(range.end);\n if (highlight.trim()) {\n processedText =\n beforeHighlight + '==' + highlight + '==' + afterHighlight;\n }\n }\n return processedText;\n}\n\n/** Moves citations without ranges to the end, preserving each group's order. */\nexport function sortCitations<T extends CitationWithRanges>(\n citations?: readonly T[] | null\n): T[] | null {\n if (!citations) {\n return null;\n }\n const withRanges = citations.filter((citation) => citation.ranges?.length);\n const withoutRanges = citations.filter(\n (citation) => !citation.ranges?.length\n );\n return withRanges.concat(withoutRanges);\n}\n"],"names":[],"mappings":";;;;;;;AAAA;;;;;;;AAOG;AAgBH;AACM,SAAU,uBAAuB,CACrC,IAAY,EACZ,iBAA6C,EAAA;AAE7C,IAAA,MAAM,MAAM,GAAG,iBAAiB,EAAE,MAAM;AACxC,IAAA,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE;AACnB,QAAA,OAAO,IAAI;IACb;IACA,MAAM,YAAY,GAAG,CAAC,GAAG,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC;IAClE,IAAI,aAAa,GAAG,IAAI;AACxB,IAAA,KAAK,MAAM,KAAK,IAAI,YAAY,EAAE;AAChC,QAAA,MAAM,eAAe,GAAG,aAAa,CAAC,SAAS,CAAC,CAAC,EAAE,KAAK,CAAC,KAAK,CAAC;AAC/D,QAAA,MAAM,SAAS,GAAG,aAAa,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC;QACjE,MAAM,cAAc,GAAG,aAAa,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC;AACzD,QAAA,IAAI,SAAS,CAAC,IAAI,EAAE,EAAE;YACpB,aAAa;gBACX,eAAe,GAAG,IAAI,GAAG,SAAS,GAAG,IAAI,GAAG,cAAc;QAC9D;IACF;AACA,IAAA,OAAO,aAAa;AACtB;AAEA;AACM,SAAU,aAAa,CAC3B,SAA+B,EAAA;IAE/B,IAAI,CAAC,SAAS,EAAE;AACd,QAAA,OAAO,IAAI;IACb;AACA,IAAA,MAAM,UAAU,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC,QAAQ,KAAK,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;AAC1E,IAAA,MAAM,aAAa,GAAG,SAAS,CAAC,MAAM,CACpC,CAAC,QAAQ,KAAK,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CACvC;AACD,IAAA,OAAO,UAAU,CAAC,MAAM,CAAC,aAAa,CAAC;AACzC;;"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * @license
3
+ *
4
+ * Copyright IBM Corp. 2026
5
+ *
6
+ * This source code is licensed under the Apache-2.0 license found in the
7
+ * LICENSE file in the root directory of this source tree.
8
+ */
9
+ import { LitElement } from 'lit';
10
+ import '@carbon/web-components/es-custom/components/tag/tag.js';
11
+ /** The citation state requested by a toggle activation. */
12
+ export interface CitationToggleEventDetail {
13
+ /** Whether the host should show the citations region. */
14
+ open: boolean;
15
+ }
16
+ /**
17
+ * Lays out a slotted answer, a citations toggle, and host-supplied citations.
18
+ *
19
+ * @experimental
20
+ * @element cds-custom-aichat-conversational-search-shell
21
+ * @slot - The answer content, such as Markdown.
22
+ * @slot answer-error - An optional answer error, after the toggle.
23
+ * @slot citations - Citation content, including loading or error states.
24
+ * @csspart answer - The answer and toggle container.
25
+ * @fires {CustomEvent<CitationToggleEventDetail>} cds-custom-aichat-citations-toggle - Requests a citation state change.
26
+ */
27
+ declare class ConversationalSearchShell extends LitElement {
28
+ /** Host-controlled visibility of the citations region. */
29
+ citationsOpen: boolean;
30
+ /** Show the citation toggle when citations are available. */
31
+ showCitationsToggle: boolean;
32
+ /** Visible text on the citation toggle. */
33
+ citationsLabel: string;
34
+ /** Accessible name of the citation toggle. */
35
+ toggleLabel: string;
36
+ private _handleToggle;
37
+ render(): import("lit-html").TemplateResult<1>;
38
+ static get eventCitationsToggle(): string;
39
+ static styles: any;
40
+ }
41
+ export default ConversationalSearchShell;
@@ -0,0 +1,116 @@
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 { __decorate } from 'tslib';
9
+ import { LitElement, nothing, html } from 'lit';
10
+ import { property } from 'lit/decorators.js';
11
+ import { ChevronUp16, ChevronDown16 } from '@carbon/icons';
12
+ import '@carbon/web-components/es-custom/components/tag/tag.js';
13
+ import { iconLoader } from '@carbon/web-components/es-custom/globals/internal/icon-loader.js';
14
+ import { carbonElement } from '../../../globals/decorators/carbon-element.js';
15
+ import prefix from '../../../globals/settings.js';
16
+ import styles from './conversational-search-shell.scss.js';
17
+
18
+ /**
19
+ * @license
20
+ *
21
+ * Copyright IBM Corp. 2026
22
+ *
23
+ * This source code is licensed under the Apache-2.0 license found in the
24
+ * LICENSE file in the root directory of this source tree.
25
+ */
26
+ var ConversationalSearchShell_1;
27
+ const blockClass = `${prefix}-conversational-search-shell`;
28
+ /**
29
+ * Lays out a slotted answer, a citations toggle, and host-supplied citations.
30
+ *
31
+ * @experimental
32
+ * @element cds-custom-aichat-conversational-search-shell
33
+ * @slot - The answer content, such as Markdown.
34
+ * @slot answer-error - An optional answer error, after the toggle.
35
+ * @slot citations - Citation content, including loading or error states.
36
+ * @csspart answer - The answer and toggle container.
37
+ * @fires {CustomEvent<CitationToggleEventDetail>} cds-custom-aichat-citations-toggle - Requests a citation state change.
38
+ */
39
+ let ConversationalSearchShell = ConversationalSearchShell_1 = class ConversationalSearchShell extends LitElement {
40
+ constructor() {
41
+ super(...arguments);
42
+ /** Host-controlled visibility of the citations region. */
43
+ this.citationsOpen = false;
44
+ /** Show the citation toggle when citations are available. */
45
+ this.showCitationsToggle = false;
46
+ /** Visible text on the citation toggle. */
47
+ this.citationsLabel = 'Citations';
48
+ /** Accessible name of the citation toggle. */
49
+ this.toggleLabel = 'Toggle citations';
50
+ }
51
+ _handleToggle() {
52
+ const open = !this.citationsOpen;
53
+ this.dispatchEvent(new CustomEvent(ConversationalSearchShell_1.eventCitationsToggle, {
54
+ detail: { open },
55
+ bubbles: true,
56
+ composed: true,
57
+ }));
58
+ }
59
+ render() {
60
+ return html `
61
+ <div part="answer">
62
+ <slot></slot>
63
+ ${this.showCitationsToggle
64
+ ? html `
65
+ <div class="${blockClass}__toggle-container">
66
+ <button
67
+ type="button"
68
+ class="${blockClass}__toggle"
69
+ aria-label=${this.toggleLabel}
70
+ aria-expanded=${String(this.citationsOpen)}
71
+ aria-controls="citations"
72
+ @click=${this._handleToggle}>
73
+ <cds-custom-tag size="md" type="gray" .filter=${false}>
74
+ <span slot="icon" aria-hidden="true">
75
+ ${iconLoader(this.citationsOpen ? ChevronUp16 : ChevronDown16)}
76
+ </span>
77
+ ${this.citationsLabel}
78
+ </cds-custom-tag>
79
+ </button>
80
+ </div>
81
+ `
82
+ : nothing}
83
+ </div>
84
+ <slot name="answer-error"></slot>
85
+ <div
86
+ id="citations"
87
+ class="${blockClass}__citations"
88
+ ?hidden=${!this.citationsOpen}>
89
+ <slot name="citations"></slot>
90
+ </div>
91
+ `;
92
+ }
93
+ static get eventCitationsToggle() {
94
+ return `${prefix}-citations-toggle`;
95
+ }
96
+ };
97
+ ConversationalSearchShell.styles = styles;
98
+ __decorate([
99
+ property({ type: Boolean, attribute: 'citations-open' })
100
+ ], ConversationalSearchShell.prototype, "citationsOpen", void 0);
101
+ __decorate([
102
+ property({ type: Boolean, attribute: 'show-citations-toggle' })
103
+ ], ConversationalSearchShell.prototype, "showCitationsToggle", void 0);
104
+ __decorate([
105
+ property({ attribute: 'citations-label' })
106
+ ], ConversationalSearchShell.prototype, "citationsLabel", void 0);
107
+ __decorate([
108
+ property({ attribute: 'toggle-label' })
109
+ ], ConversationalSearchShell.prototype, "toggleLabel", void 0);
110
+ ConversationalSearchShell = ConversationalSearchShell_1 = __decorate([
111
+ carbonElement(blockClass)
112
+ ], ConversationalSearchShell);
113
+ var ConversationalSearchShellElement = ConversationalSearchShell;
114
+
115
+ export { ConversationalSearchShellElement as default };
116
+ //# sourceMappingURL=conversational-search-shell.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conversational-search-shell.js","sources":["../../../../src/components/conversational-search/src/conversational-search-shell.ts"],"sourcesContent":["/**\n * @license\n *\n * Copyright IBM Corp. 2026\n *\n * This source code is licensed under the Apache-2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n/* eslint jsdoc/check-tag-names: [\"error\", { \"definedTags\": [\"element\", \"slot\", \"csspart\"] }] */\n\nimport { LitElement, html, nothing } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { ChevronDown16, ChevronUp16 } from '@carbon/icons';\nimport '@carbon/web-components/es-custom/components/tag/tag.js';\nimport { iconLoader } from '@carbon/web-components/es-custom/globals/internal/icon-loader.js';\nimport { carbonElement } from '../../../globals/decorators/index.js';\nimport prefix from '../../../globals/settings.js';\nimport styles from './conversational-search-shell.scss?lit';\n\nconst blockClass = `${prefix}-conversational-search-shell`;\n\n/** The citation state requested by a toggle activation. */\nexport interface CitationToggleEventDetail {\n /** Whether the host should show the citations region. */\n open: boolean;\n}\n\n/**\n * Lays out a slotted answer, a citations toggle, and host-supplied citations.\n *\n * @experimental\n * @element cds-custom-aichat-conversational-search-shell\n * @slot - The answer content, such as Markdown.\n * @slot answer-error - An optional answer error, after the toggle.\n * @slot citations - Citation content, including loading or error states.\n * @csspart answer - The answer and toggle container.\n * @fires {CustomEvent<CitationToggleEventDetail>} cds-custom-aichat-citations-toggle - Requests a citation state change.\n */\n@carbonElement(blockClass)\nclass ConversationalSearchShell extends LitElement {\n /** Host-controlled visibility of the citations region. */\n @property({ type: Boolean, attribute: 'citations-open' })\n citationsOpen = false;\n\n /** Show the citation toggle when citations are available. */\n @property({ type: Boolean, attribute: 'show-citations-toggle' })\n showCitationsToggle = false;\n\n /** Visible text on the citation toggle. */\n @property({ attribute: 'citations-label' })\n citationsLabel = 'Citations';\n\n /** Accessible name of the citation toggle. */\n @property({ attribute: 'toggle-label' })\n toggleLabel = 'Toggle citations';\n\n private _handleToggle() {\n const open = !this.citationsOpen;\n this.dispatchEvent(\n new CustomEvent<CitationToggleEventDetail>(\n ConversationalSearchShell.eventCitationsToggle,\n {\n detail: { open },\n bubbles: true,\n composed: true,\n }\n )\n );\n }\n\n render() {\n return html`\n <div part=\"answer\">\n <slot></slot>\n ${\n this.showCitationsToggle\n ? html`\n <div class=\"${blockClass}__toggle-container\">\n <button\n type=\"button\"\n class=\"${blockClass}__toggle\"\n aria-label=${this.toggleLabel}\n aria-expanded=${String(this.citationsOpen)}\n aria-controls=\"citations\"\n @click=${this._handleToggle}>\n <cds-custom-tag size=\"md\" type=\"gray\" .filter=${false}>\n <span slot=\"icon\" aria-hidden=\"true\">\n ${iconLoader(\n this.citationsOpen ? ChevronUp16 : ChevronDown16\n )}\n </span>\n ${this.citationsLabel}\n </cds-custom-tag>\n </button>\n </div>\n `\n : nothing\n }\n </div>\n <slot name=\"answer-error\"></slot>\n <div\n id=\"citations\"\n class=\"${blockClass}__citations\"\n ?hidden=${!this.citationsOpen}>\n <slot name=\"citations\"></slot>\n </div>\n `;\n }\n\n static get eventCitationsToggle() {\n return `${prefix}-citations-toggle`;\n }\n\n static styles = styles;\n}\n\nexport default ConversationalSearchShell;\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA;;;;;;;AAOG;;AAaH,MAAM,UAAU,GAAG,CAAA,EAAG,MAAM,8BAA8B;AAQ1D;;;;;;;;;;AAUG;AAEH,IAAM,yBAAyB,GAAA,2BAAA,GAA/B,MAAM,yBAA0B,SAAQ,UAAU,CAAA;AAAlD,IAAA,WAAA,GAAA;;;QAGE,IAAA,CAAA,aAAa,GAAG,KAAK;;QAIrB,IAAA,CAAA,mBAAmB,GAAG,KAAK;;QAI3B,IAAA,CAAA,cAAc,GAAG,WAAW;;QAI5B,IAAA,CAAA,WAAW,GAAG,kBAAkB;IA4DlC;IA1DU,aAAa,GAAA;AACnB,QA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,IAAA,QAAQ,CAAC,EAAE,SAAS,EAAE,iBAAiB,EAAE;AACb,CAAA,EAAA,yBAAA,CAAA,SAAA,EAAA,gBAAA,EAAA,MAAA,CAAA;AAI7B,UAAA,CAAA;AADC,IAAA,QAAQ,CAAC,EAAE,SAAS,EAAE,cAAc,EAAE;AACN,CAAA,EAAA,yBAAA,CAAA,SAAA,EAAA,aAAA,EAAA,MAAA,CAAA;AAf7B,yBAAyB,GAAA,2BAAA,GAAA,UAAA,CAAA;IAD9B,aAAa,CAAC,UAAU;AACnB,CAAA,EAAA,yBAAyB,CA2E9B;AAED,uCAAe,yBAAyB;;"}
@@ -0,0 +1,13 @@
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 { css } from 'lit';
9
+
10
+ var styles = css([":host{display:block}.cds-custom-aichat-conversational-search-shell__toggle-container{padding-block-start:.75rem}.cds-custom-aichat-conversational-search-shell__toggle{align-items:center;background:transparent;border:0;border-radius:1rem;cursor:pointer;display:inline-flex;font:inherit;margin:0;padding:0}.cds-custom-aichat-conversational-search-shell__toggle:focus-visible{outline:2px solid var(--cds-focus,#0f62fe);outline-offset:2px}.cds-custom-aichat-conversational-search-shell__toggle:hover{--cds-tag-background-gray:var(--cds-tag-hover-gray,var(--cds-tag-hover-gray,#d1d1d1))}cds-custom-tag{border:1px solid var(--cds-tag-border-gray,var(--cds-tag-border-gray,#a8a8a8));margin:0;pointer-events:none}@keyframes cds-custom-aichat-conversational-search-citations-fade-in{0%{opacity:0}to{opacity:1}}.cds-custom-aichat-conversational-search-shell__citations{animation:cds-custom-aichat-conversational-search-citations-fade-in .4s cubic-bezier(0,0,.3,1) both;max-inline-size:400px;padding-block-start:1rem}@media (prefers-reduced-motion:reduce){.cds-custom-aichat-conversational-search-shell__citations{animation:none}}"]);
11
+
12
+ export { styles as default };
13
+ //# sourceMappingURL=conversational-search-shell.scss.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conversational-search-shell.scss.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;"}
@@ -249,14 +249,14 @@ let FileUploadItemElement = class FileUploadItemElement extends LitElement {
249
249
  }
250
250
  const rules = [];
251
251
  if (this._hasMediaPreview()) {
252
- rules.push('.cds-custom--file-filename { margin-inline-start: 2px !important; }');
252
+ rules.push(':host(cds-custom-file-uploader-item) p.cds-custom--file-filename { margin-inline-start: 2px; }');
253
253
  }
254
254
  if (this.readOnly) {
255
- rules.push('.cds-custom--file__state-container { display: none !important; }');
255
+ rules.push(':host .cds-custom--file__state-container { display: none; }');
256
256
  // Carbon hangs the chip's trailing padding off the status container, so
257
257
  // hiding it leaves the name flush to the edge against a 1rem leading margin.
258
258
  // Restate it on the name to even the two sides up.
259
- rules.push('.cds-custom--file-filename { margin-inline-end: 1rem !important; }');
259
+ rules.push('.cds-custom--file-filename { margin-inline-end: 1rem; }');
260
260
  }
261
261
  const nextText = rules.join('\n');
262
262
  if (this._injectedStyle?.textContent === nextText) {
@@ -1 +1 @@
1
- {"version":3,"file":"file-upload-item.js","sources":["../../../../src/components/file-uploads/src/file-upload-item.ts"],"sourcesContent":["/**\n * @license\n *\n * Copyright IBM Corp. 2026\n *\n * This source code is licensed under the Apache-2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport {\n css,\n html,\n LitElement,\n nothing,\n type PropertyValues,\n unsafeCSS,\n} from 'lit';\nimport { property, state } from 'lit/decorators.js';\n\nimport { carbonElement } from '../../../globals/decorators/carbon-element.js';\nimport { isBrowser } from '../../../globals/utils/browser-utils.js';\nimport prefix from '../../../globals/settings.js';\n\nimport '@carbon/web-components/es-custom/components/file-uploader/index.js';\n\nimport { iconLoader } from '@carbon/web-components/es-custom/globals/internal/icon-loader.js';\nimport PlayFilledAlt16 from '@carbon/icons/es/play--filled--alt/16.js';\n\nimport { pickFileTypeIcon } from './file-type-icon.js';\n\nimport type {\n FileUpload,\n FileRemoveEventDetail,\n} from '../../prompt-line/src/types.js';\nimport type { FileAttachment } from './types.js';\n\nimport styles from './file-upload-item.scss?lit';\n\n/**\n * Ids are scoped to their shadow root and each `cds-custom-file-uploader-item` has its\n * own, so a constant collides with nothing.\n */\nconst ERROR_MESSAGE_ID = 'cds-custom-aichat-file-upload-item-error';\n\ninterface SyncAttributeOptions {\n /** The element to set the attribute on. */\n element: Element;\n\n /** The qualified attribute name. */\n attribute: string;\n\n /** The value to set, or nothing to remove the attribute. */\n value?: string;\n}\n\n/** Sets `attribute` to `value`, or removes it when there is no value. */\nfunction syncAttribute({ element, attribute, value }: SyncAttributeOptions) {\n if (value) {\n element.setAttribute(attribute, value);\n } else {\n element.removeAttribute(attribute);\n }\n}\n\n/**\n * The name, type, and (when available) `File` behind the chip, resolved from\n * whichever input was supplied.\n */\ninterface ResolvedFile {\n name?: string;\n mimeType?: string;\n file?: File;\n url?: string;\n}\n\n/**\n * Renders a single file chip with an optional media preview or file-type icon.\n *\n * Serves both places a file appears. In the input area it is driven by `upload`,\n * which carries the live `File`, and shows upload status plus a remove button. In a\n * sent message it is driven by either input with `read-only` set: no status, no\n * remove affordance. `attachment` exists for the read-only case where there is no\n * `File` at all — a message restored from conversation history — since a `File`\n * cannot be serialized.\n *\n * @element cds-custom-aichat-file-upload-item\n * @fires {CustomEvent<FileRemoveEventDetail>} cds-custom-aichat-file-remove - Fired when the remove button is clicked\n */\n@carbonElement(`${prefix}-file-upload-item`)\nclass FileUploadItemElement extends LitElement {\n static styles = css`\n ${unsafeCSS(styles)}\n `;\n\n /**\n * The file to render. A {@link FileUpload} when the live `File` is to hand, as in\n * the input area; a {@link FileAttachment} when only metadata survives, as on a\n * message restored from conversation history.\n */\n @property({ type: Object, attribute: false })\n upload: FileUpload | FileAttachment | null = null;\n\n /**\n * Renders the chip without status or a remove button, for a file on a message\n * that has already been sent.\n */\n @property({ type: Boolean, attribute: 'read-only', reflect: true })\n readOnly = false;\n\n /** Label for the remove file button, used when no file name is available. */\n @property({ type: String, attribute: 'remove-file-label' })\n removeFileLabel = 'Remove file';\n\n /**\n * Accessible name for the remove button, with the file name already\n * interpolated by the caller. Falls back to {@link removeFileLabel}.\n */\n @property({ type: String, attribute: 'remove-file-named-label' })\n removeFileNamedLabel?: string;\n\n /** Label for the uploading status. */\n @property({ type: String, attribute: 'uploading-file-label' })\n uploadingFileLabel = 'Uploading';\n\n /** Text shown when the file's name is not known. */\n @property({ type: String, attribute: 'fallback-label' })\n fallbackLabel = 'Attachment';\n\n /**\n * A preview URL that failed to load, so the chip can fall back to a file-type\n * icon. Holds the URL rather than a flag, so a new one is tried afresh: a stated\n * URL can go dead between the send and the render — a signed link expires, or an\n * object URL outlives the page that minted it.\n */\n @state()\n private _failedPreviewURL: string | null = null;\n\n /** Object URL created for image/video previews. Revoked on disconnect or when the file changes. */\n private _objectURL: string | null = null;\n\n /** The File instance the current object URL was created for. */\n private _objectURLFile: File | null = null;\n\n /**\n * The chip's content, resolved from whichever shape `upload` holds. Stated name\n * and type win where they exist; a `File` supplies them otherwise. Both shapes may\n * carry a `File`, so this branches on the `File` rather than on the shape.\n */\n private get _resolved(): ResolvedFile | null {\n const value = this.upload;\n if (!value) {\n return null;\n }\n\n const attachment = value as FileAttachment;\n const file =\n (value as FileUpload).file instanceof File\n ? (value as FileUpload).file\n : undefined;\n\n if (file) {\n return {\n name: attachment.name ?? file.name,\n mimeType: attachment.mimeType ?? file.type,\n file,\n };\n }\n\n return {\n name: attachment.name,\n mimeType: attachment.mimeType,\n url: attachment.url,\n };\n }\n\n /**\n * Whether `upload` is a staged upload rather than a sent attachment. Keyed on\n * `status`, which only an upload has — an attachment may carry a `File` too, so\n * the `File` no longer tells the two apart.\n */\n private _isUpload(value: FileUpload | FileAttachment): value is FileUpload {\n return typeof (value as FileUpload).status === 'string';\n }\n\n /** Upload status, which only a staged file has. */\n private get _uploadStatus(): string {\n return this.upload && this._isUpload(this.upload) ? this.upload.status : '';\n }\n\n /** Error state, which only a staged file has. */\n private get _uploadError(): { isError: boolean; message: string } {\n if (!this.upload || !this._isUpload(this.upload)) {\n return { isError: false, message: '' };\n }\n return {\n isError: Boolean(this.upload.isError),\n message: this.upload.errorMessage || '',\n };\n }\n\n private _getOrCreateObjectURL(file: File): string | null {\n if (this._objectURLFile !== file) {\n if (this._objectURL) {\n URL.revokeObjectURL(this._objectURL);\n }\n this._objectURL = URL.createObjectURL(file);\n this._objectURLFile = file;\n }\n return this._objectURL;\n }\n\n private _hasMediaPreview(): boolean {\n const resolved = this._resolved;\n if (!resolved) {\n return false;\n }\n\n const type = resolved.mimeType ?? '';\n if (resolved.file) {\n return type.startsWith('image/') || type.startsWith('video/');\n }\n\n // With no `File` to build an object URL from, only a stated URL can stand in,\n // and only for an image that loads. Everything else falls back to a file-type\n // icon.\n return this._canPreviewURL(resolved.url) && type.startsWith('image/');\n }\n\n /** Whether a stated URL is usable as a preview source. */\n private _canPreviewURL(url: string | undefined): url is string {\n return Boolean(url) && url !== this._failedPreviewURL;\n }\n\n /**\n * Only the state the patched rules read can change what they say. The\n * `_injectedStyle` check keeps the first cycle covered — and retries on the next\n * one if Carbon's shadow root wasn't there to patch yet.\n */\n updated(changedProperties: PropertyValues) {\n if (\n !this._injectedStyle ||\n changedProperties.has('readOnly') ||\n changedProperties.has('upload') ||\n changedProperties.has('_failedPreviewURL')\n ) {\n this._syncInjectedStyles();\n }\n\n if (\n changedProperties.has('readOnly') ||\n changedProperties.has('upload') ||\n !this._syncedErrorState\n ) {\n this._syncErrorState();\n }\n }\n\n private _syncedErrorState = false;\n\n /**\n * Carbon leaves the failure message unreferenced and hides the invalid icon, so\n * the remove button — the chip's only focusable node — states no reason. The\n * message and the button are siblings in Carbon's shadow root, so the\n * `aria-describedby` is wired there: an id reference cannot cross the boundary.\n */\n private async _syncErrorState() {\n const { isError, message } = this._uploadError;\n const invalid = !this.readOnly && isError;\n\n // `aria-invalid` on a role-less host is dropped, so an input-area chip states\n // a role and names itself. A read-only chip is already a list item in the\n // message list.\n const label = this.readOnly ? undefined : this._resolved?.name;\n syncAttribute({\n element: this,\n attribute: 'role',\n value: this.readOnly ? undefined : 'group',\n });\n syncAttribute({ element: this, attribute: 'aria-label', value: label });\n syncAttribute({\n element: this,\n attribute: 'aria-invalid',\n value: invalid ? 'true' : undefined,\n });\n\n const inner = this.shadowRoot?.querySelector(\n 'cds-custom-file-uploader-item'\n ) as LitElement | null;\n if (!inner) {\n return;\n }\n\n // A failure also flips `state`, and Carbon re-renders that subtree — replacing\n // the button being described. Wait for the new one.\n await inner.updateComplete;\n\n const innerRoot = inner.shadowRoot;\n if (!innerRoot) {\n return;\n }\n this._syncedErrorState = true;\n\n // Carbon renders the requirement node even when it holds no message.\n const describedBy = invalid && message ? ERROR_MESSAGE_ID : undefined;\n\n const title = innerRoot.querySelector('.cds-custom--form-requirement__title');\n if (title) {\n syncAttribute({ element: title, attribute: 'id', value: describedBy });\n }\n\n const removeButton = innerRoot.querySelector('button.cds-custom--file-close');\n if (removeButton) {\n syncAttribute({\n element: removeButton,\n attribute: 'aria-describedby',\n value: describedBy,\n });\n }\n }\n\n /**\n * Carbon's `cds-custom-file-uploader-item` needs two things patched from inside its own\n * shadow root, because it exposes no `part=` for either.\n *\n * The filename margin is too wide when a media preview sits beside it. And the\n * status container is rendered unconditionally at `min-inline-size: 1.5rem` plus\n * `padding-inline-end: .75rem`, so in read-only mode — where there is no status\n * to show — it would leave 36px of dead space on the chip's trailing edge.\n */\n private _syncInjectedStyles() {\n const innerRoot = this.shadowRoot?.querySelector(\n 'cds-custom-file-uploader-item'\n )?.shadowRoot;\n if (!innerRoot) {\n return;\n }\n\n const rules: string[] = [];\n if (this._hasMediaPreview()) {\n rules.push(\n '.cds-custom--file-filename { margin-inline-start: 2px !important; }'\n );\n }\n if (this.readOnly) {\n rules.push('.cds-custom--file__state-container { display: none !important; }');\n // Carbon hangs the chip's trailing padding off the status container, so\n // hiding it leaves the name flush to the edge against a 1rem leading margin.\n // Restate it on the name to even the two sides up.\n rules.push('.cds-custom--file-filename { margin-inline-end: 1rem !important; }');\n }\n\n const nextText = rules.join('\\n');\n if (this._injectedStyle?.textContent === nextText) {\n return;\n }\n\n if (!this._injectedStyle) {\n this._injectedStyle = document.createElement('style');\n innerRoot.appendChild(this._injectedStyle);\n }\n this._injectedStyle.textContent = nextText;\n }\n\n /** The `<style>` patched into Carbon's shadow root. See `_syncInjectedStyles`. */\n private _injectedStyle: HTMLStyleElement | null = null;\n\n disconnectedCallback() {\n super.disconnectedCallback();\n if (this._objectURL) {\n URL.revokeObjectURL(this._objectURL);\n this._objectURL = null;\n this._objectURLFile = null;\n }\n }\n\n private _renderPreview() {\n const resolved = this._resolved;\n if (!resolved) {\n return nothing;\n }\n\n const { file, name, url } = resolved;\n const type = resolved.mimeType ?? '';\n\n // Image preview from the live File. An attachment without one falls through to\n // the URL branch below, and failing that to a file-type icon.\n if (file && type.startsWith('image/')) {\n const objectURL = this._getOrCreateObjectURL(file);\n if (!objectURL) {\n return nothing;\n }\n\n return html`<span class=\"${prefix}-file-upload-item__preview-wrapper\"\n ><img\n class=\"${prefix}-file-upload-item__preview\"\n src=\"${objectURL}\"\n width=\"36\"\n height=\"36\"\n alt=\"\"\n aria-hidden=\"true\"\n /></span>`;\n }\n\n // Video preview\n if (file && type.startsWith('video/')) {\n const objectURL = this._getOrCreateObjectURL(file);\n if (!objectURL) {\n return nothing;\n }\n\n const openVideo = () => {\n const newWindow = isBrowser()\n ? window.open('', '_blank', 'width=800,height=600')\n : null;\n\n if (!newWindow) {\n return;\n }\n\n const style = newWindow.document.createElement('style');\n style.textContent =\n '* { margin: 0; padding: 0; background: #000 } video { display: block; width: 100%; height: 100vh; object-fit: contain }';\n const video = newWindow.document.createElement('video');\n video.src = objectURL;\n video.controls = true;\n video.autoplay = true;\n newWindow.document.title = name ?? '';\n newWindow.document.head.appendChild(style);\n newWindow.document.body.appendChild(video);\n };\n\n return html`<button\n class=\"${prefix}-file-upload-item__preview-wrapper ${prefix}-file-upload-item__video-preview-wrapper\"\n type=\"button\"\n aria-label=\"Play video\"\n @click=\"${openVideo}\">\n <video\n class=\"${prefix}-file-upload-item__preview\"\n src=\"${objectURL}\"\n width=\"36\"\n height=\"36\"\n preload=\"metadata\"\n muted\n playsinline\n tabindex=\"-1\"\n aria-hidden=\"true\"\n @loadedmetadata=\"${(e: Event) => {\n (e.target as HTMLVideoElement).currentTime = 0.1;\n }}\"></video\n ><span class=\"${prefix}-file-upload-item__play-badge\" aria-hidden=\"true\"\n >${iconLoader(PlayFilledAlt16)}</span\n >\n </button>`;\n }\n\n // Image preview from a stated URL — an attachment whose file lives on a server\n // rather than in the page. No video equivalent: playback would stream the file\n // back, which a chip on a sent message has no business doing.\n if (this._canPreviewURL(url) && type.startsWith('image/')) {\n return html`<span class=\"${prefix}-file-upload-item__preview-wrapper\"\n ><img\n class=\"${prefix}-file-upload-item__preview\"\n src=\"${url}\"\n width=\"36\"\n height=\"36\"\n alt=\"\"\n aria-hidden=\"true\"\n @error=\"${() => {\n this._failedPreviewURL = url;\n }}\"\n /></span>`;\n }\n\n // File type icon (for supported icons)\n const icon = pickFileTypeIcon(name, type);\n if (icon) {\n return html`<span\n class=\"${prefix}-file-upload-item__icon\"\n aria-hidden=\"true\"\n >${iconLoader(icon)}</span\n >`;\n }\n\n return nothing;\n }\n\n private _handleRemove() {\n if (!this.upload) {\n return;\n }\n\n this.dispatchEvent(\n new CustomEvent<FileRemoveEventDetail>('cds-custom-aichat-file-remove', {\n detail: { fileId: this.upload.id },\n bubbles: true,\n composed: true,\n })\n );\n }\n\n render() {\n const resolved = this._resolved;\n if (!resolved) {\n return nothing;\n }\n\n // An empty state falls through Carbon's status switch, rendering no\n // affordance. `_syncInjectedStyles` collapses the container it still reserves.\n const state = this.readOnly ? '' : this._uploadStatus;\n const error = this._uploadError;\n\n return html`\n <cds-custom-file-uploader-item\n size=\"md\"\n .state=\"${state}\"\n .iconDescription=\"${\n state === 'uploading'\n ? this.uploadingFileLabel\n : this.removeFileNamedLabel || this.removeFileLabel\n }\"\n .errorSubject=\"${error.message}\"\n ?invalid=\"${!this.readOnly && error.isError}\"\n @cds-custom-file-uploader-item-deleted=\"${this._handleRemove}\">\n ${this._renderPreview()} ${resolved.name || this.fallbackLabel}\n </cds-custom-file-uploader-item>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'cds-custom-aichat-file-upload-item': FileUploadItemElement;\n }\n}\n\nexport default FileUploadItemElement;\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;;;;;;;AAOG;AA+BH;;;AAGG;AACH,MAAM,gBAAgB,GAAG,mCAAmC;AAa5D;AACA,SAAS,aAAa,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAwB,EAAA;IACxE,IAAI,KAAK,EAAE;AACT,QAAA,OAAO,CAAC,YAAY,CAAC,SAAS,EAAE,KAAK,CAAC;IACxC;SAAO;AACL,QAAA,OAAO,CAAC,eAAe,CAAC,SAAS,CAAC;IACpC;AACF;AAaA;;;;;;;;;;;;AAYG;AAEH,IAAM,qBAAqB,GAA3B,MAAM,qBAAsB,SAAQ,UAAU,CAAA;AAA9C,IAAA,WAAA,GAAA;;AAKE;;;;AAIG;QAEH,IAAA,CAAA,MAAM,GAAuC,IAAI;AAEjD;;;AAGG;QAEH,IAAA,CAAA,QAAQ,GAAG,KAAK;;QAIhB,IAAA,CAAA,eAAe,GAAG,aAAa;;QAW/B,IAAA,CAAA,kBAAkB,GAAG,WAAW;;QAIhC,IAAA,CAAA,aAAa,GAAG,YAAY;AAE5B;;;;;AAKG;QAEK,IAAA,CAAA,iBAAiB,GAAkB,IAAI;;QAGvC,IAAA,CAAA,UAAU,GAAkB,IAAI;;QAGhC,IAAA,CAAA,cAAc,GAAgB,IAAI;QAoHlC,IAAA,CAAA,iBAAiB,GAAG,KAAK;;QA2GzB,IAAA,CAAA,cAAc,GAA4B,IAAI;IAmKxD;AAhYE;;;;AAIG;AACH,IAAA,IAAY,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B;AACrC,CAAA,EAAA,qBAAqB,CAsb1B;AAQD,8BAAe,qBAAqB;;"}
1
+ {"version":3,"file":"file-upload-item.js","sources":["../../../../src/components/file-uploads/src/file-upload-item.ts"],"sourcesContent":["/**\n * @license\n *\n * Copyright IBM Corp. 2026\n *\n * This source code is licensed under the Apache-2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport {\n css,\n html,\n LitElement,\n nothing,\n type PropertyValues,\n unsafeCSS,\n} from 'lit';\nimport { property, state } from 'lit/decorators.js';\n\nimport { carbonElement } from '../../../globals/decorators/carbon-element.js';\nimport { isBrowser } from '../../../globals/utils/browser-utils.js';\nimport prefix from '../../../globals/settings.js';\n\nimport '@carbon/web-components/es-custom/components/file-uploader/index.js';\n\nimport { iconLoader } from '@carbon/web-components/es-custom/globals/internal/icon-loader.js';\nimport PlayFilledAlt16 from '@carbon/icons/es/play--filled--alt/16.js';\n\nimport { pickFileTypeIcon } from './file-type-icon.js';\n\nimport type {\n FileUpload,\n FileRemoveEventDetail,\n} from '../../prompt-line/src/types.js';\nimport type { FileAttachment } from './types.js';\n\nimport styles from './file-upload-item.scss?lit';\n\n/**\n * Ids are scoped to their shadow root and each `cds-custom-file-uploader-item` has its\n * own, so a constant collides with nothing.\n */\nconst ERROR_MESSAGE_ID = 'cds-custom-aichat-file-upload-item-error';\n\ninterface SyncAttributeOptions {\n /** The element to set the attribute on. */\n element: Element;\n\n /** The qualified attribute name. */\n attribute: string;\n\n /** The value to set, or nothing to remove the attribute. */\n value?: string;\n}\n\n/** Sets `attribute` to `value`, or removes it when there is no value. */\nfunction syncAttribute({ element, attribute, value }: SyncAttributeOptions) {\n if (value) {\n element.setAttribute(attribute, value);\n } else {\n element.removeAttribute(attribute);\n }\n}\n\n/**\n * The name, type, and (when available) `File` behind the chip, resolved from\n * whichever input was supplied.\n */\ninterface ResolvedFile {\n name?: string;\n mimeType?: string;\n file?: File;\n url?: string;\n}\n\n/**\n * Renders a single file chip with an optional media preview or file-type icon.\n *\n * Serves both places a file appears. In the input area it is driven by `upload`,\n * which carries the live `File`, and shows upload status plus a remove button. In a\n * sent message it is driven by either input with `read-only` set: no status, no\n * remove affordance. `attachment` exists for the read-only case where there is no\n * `File` at all — a message restored from conversation history — since a `File`\n * cannot be serialized.\n *\n * @element cds-custom-aichat-file-upload-item\n * @fires {CustomEvent<FileRemoveEventDetail>} cds-custom-aichat-file-remove - Fired when the remove button is clicked\n */\n@carbonElement(`${prefix}-file-upload-item`)\nclass FileUploadItemElement extends LitElement {\n static styles = css`\n ${unsafeCSS(styles)}\n `;\n\n /**\n * The file to render. A {@link FileUpload} when the live `File` is to hand, as in\n * the input area; a {@link FileAttachment} when only metadata survives, as on a\n * message restored from conversation history.\n */\n @property({ type: Object, attribute: false })\n upload: FileUpload | FileAttachment | null = null;\n\n /**\n * Renders the chip without status or a remove button, for a file on a message\n * that has already been sent.\n */\n @property({ type: Boolean, attribute: 'read-only', reflect: true })\n readOnly = false;\n\n /** Label for the remove file button, used when no file name is available. */\n @property({ type: String, attribute: 'remove-file-label' })\n removeFileLabel = 'Remove file';\n\n /**\n * Accessible name for the remove button, with the file name already\n * interpolated by the caller. Falls back to {@link removeFileLabel}.\n */\n @property({ type: String, attribute: 'remove-file-named-label' })\n removeFileNamedLabel?: string;\n\n /** Label for the uploading status. */\n @property({ type: String, attribute: 'uploading-file-label' })\n uploadingFileLabel = 'Uploading';\n\n /** Text shown when the file's name is not known. */\n @property({ type: String, attribute: 'fallback-label' })\n fallbackLabel = 'Attachment';\n\n /**\n * A preview URL that failed to load, so the chip can fall back to a file-type\n * icon. Holds the URL rather than a flag, so a new one is tried afresh: a stated\n * URL can go dead between the send and the render — a signed link expires, or an\n * object URL outlives the page that minted it.\n */\n @state()\n private _failedPreviewURL: string | null = null;\n\n /** Object URL created for image/video previews. Revoked on disconnect or when the file changes. */\n private _objectURL: string | null = null;\n\n /** The File instance the current object URL was created for. */\n private _objectURLFile: File | null = null;\n\n /**\n * The chip's content, resolved from whichever shape `upload` holds. Stated name\n * and type win where they exist; a `File` supplies them otherwise. Both shapes may\n * carry a `File`, so this branches on the `File` rather than on the shape.\n */\n private get _resolved(): ResolvedFile | null {\n const value = this.upload;\n if (!value) {\n return null;\n }\n\n const attachment = value as FileAttachment;\n const file =\n (value as FileUpload).file instanceof File\n ? (value as FileUpload).file\n : undefined;\n\n if (file) {\n return {\n name: attachment.name ?? file.name,\n mimeType: attachment.mimeType ?? file.type,\n file,\n };\n }\n\n return {\n name: attachment.name,\n mimeType: attachment.mimeType,\n url: attachment.url,\n };\n }\n\n /**\n * Whether `upload` is a staged upload rather than a sent attachment. Keyed on\n * `status`, which only an upload has — an attachment may carry a `File` too, so\n * the `File` no longer tells the two apart.\n */\n private _isUpload(value: FileUpload | FileAttachment): value is FileUpload {\n return typeof (value as FileUpload).status === 'string';\n }\n\n /** Upload status, which only a staged file has. */\n private get _uploadStatus(): string {\n return this.upload && this._isUpload(this.upload) ? this.upload.status : '';\n }\n\n /** Error state, which only a staged file has. */\n private get _uploadError(): { isError: boolean; message: string } {\n if (!this.upload || !this._isUpload(this.upload)) {\n return { isError: false, message: '' };\n }\n return {\n isError: Boolean(this.upload.isError),\n message: this.upload.errorMessage || '',\n };\n }\n\n private _getOrCreateObjectURL(file: File): string | null {\n if (this._objectURLFile !== file) {\n if (this._objectURL) {\n URL.revokeObjectURL(this._objectURL);\n }\n this._objectURL = URL.createObjectURL(file);\n this._objectURLFile = file;\n }\n return this._objectURL;\n }\n\n private _hasMediaPreview(): boolean {\n const resolved = this._resolved;\n if (!resolved) {\n return false;\n }\n\n const type = resolved.mimeType ?? '';\n if (resolved.file) {\n return type.startsWith('image/') || type.startsWith('video/');\n }\n\n // With no `File` to build an object URL from, only a stated URL can stand in,\n // and only for an image that loads. Everything else falls back to a file-type\n // icon.\n return this._canPreviewURL(resolved.url) && type.startsWith('image/');\n }\n\n /** Whether a stated URL is usable as a preview source. */\n private _canPreviewURL(url: string | undefined): url is string {\n return Boolean(url) && url !== this._failedPreviewURL;\n }\n\n /**\n * Only the state the patched rules read can change what they say. The\n * `_injectedStyle` check keeps the first cycle covered — and retries on the next\n * one if Carbon's shadow root wasn't there to patch yet.\n */\n updated(changedProperties: PropertyValues) {\n if (\n !this._injectedStyle ||\n changedProperties.has('readOnly') ||\n changedProperties.has('upload') ||\n changedProperties.has('_failedPreviewURL')\n ) {\n this._syncInjectedStyles();\n }\n\n if (\n changedProperties.has('readOnly') ||\n changedProperties.has('upload') ||\n !this._syncedErrorState\n ) {\n this._syncErrorState();\n }\n }\n\n private _syncedErrorState = false;\n\n /**\n * Carbon leaves the failure message unreferenced and hides the invalid icon, so\n * the remove button — the chip's only focusable node — states no reason. The\n * message and the button are siblings in Carbon's shadow root, so the\n * `aria-describedby` is wired there: an id reference cannot cross the boundary.\n */\n private async _syncErrorState() {\n const { isError, message } = this._uploadError;\n const invalid = !this.readOnly && isError;\n\n // `aria-invalid` on a role-less host is dropped, so an input-area chip states\n // a role and names itself. A read-only chip is already a list item in the\n // message list.\n const label = this.readOnly ? undefined : this._resolved?.name;\n syncAttribute({\n element: this,\n attribute: 'role',\n value: this.readOnly ? undefined : 'group',\n });\n syncAttribute({ element: this, attribute: 'aria-label', value: label });\n syncAttribute({\n element: this,\n attribute: 'aria-invalid',\n value: invalid ? 'true' : undefined,\n });\n\n const inner = this.shadowRoot?.querySelector(\n 'cds-custom-file-uploader-item'\n ) as LitElement | null;\n if (!inner) {\n return;\n }\n\n // A failure also flips `state`, and Carbon re-renders that subtree — replacing\n // the button being described. Wait for the new one.\n await inner.updateComplete;\n\n const innerRoot = inner.shadowRoot;\n if (!innerRoot) {\n return;\n }\n this._syncedErrorState = true;\n\n // Carbon renders the requirement node even when it holds no message.\n const describedBy = invalid && message ? ERROR_MESSAGE_ID : undefined;\n\n const title = innerRoot.querySelector('.cds-custom--form-requirement__title');\n if (title) {\n syncAttribute({ element: title, attribute: 'id', value: describedBy });\n }\n\n const removeButton = innerRoot.querySelector('button.cds-custom--file-close');\n if (removeButton) {\n syncAttribute({\n element: removeButton,\n attribute: 'aria-describedby',\n value: describedBy,\n });\n }\n }\n\n /**\n * Carbon's `cds-custom-file-uploader-item` needs two things patched from inside its own\n * shadow root, because it exposes no `part=` for either.\n *\n * The filename margin is too wide when a media preview sits beside it. And the\n * status container is rendered unconditionally at `min-inline-size: 1.5rem` plus\n * `padding-inline-end: .75rem`, so in read-only mode — where there is no status\n * to show — it would leave 36px of dead space on the chip's trailing edge.\n */\n private _syncInjectedStyles() {\n const innerRoot = this.shadowRoot?.querySelector(\n 'cds-custom-file-uploader-item'\n )?.shadowRoot;\n if (!innerRoot) {\n return;\n }\n\n const rules: string[] = [];\n if (this._hasMediaPreview()) {\n rules.push(\n ':host(cds-custom-file-uploader-item) p.cds-custom--file-filename { margin-inline-start: 2px; }'\n );\n }\n if (this.readOnly) {\n rules.push(':host .cds-custom--file__state-container { display: none; }');\n // Carbon hangs the chip's trailing padding off the status container, so\n // hiding it leaves the name flush to the edge against a 1rem leading margin.\n // Restate it on the name to even the two sides up.\n rules.push('.cds-custom--file-filename { margin-inline-end: 1rem; }');\n }\n\n const nextText = rules.join('\\n');\n if (this._injectedStyle?.textContent === nextText) {\n return;\n }\n\n if (!this._injectedStyle) {\n this._injectedStyle = document.createElement('style');\n innerRoot.appendChild(this._injectedStyle);\n }\n this._injectedStyle.textContent = nextText;\n }\n\n /** The `<style>` patched into Carbon's shadow root. See `_syncInjectedStyles`. */\n private _injectedStyle: HTMLStyleElement | null = null;\n\n disconnectedCallback() {\n super.disconnectedCallback();\n if (this._objectURL) {\n URL.revokeObjectURL(this._objectURL);\n this._objectURL = null;\n this._objectURLFile = null;\n }\n }\n\n private _renderPreview() {\n const resolved = this._resolved;\n if (!resolved) {\n return nothing;\n }\n\n const { file, name, url } = resolved;\n const type = resolved.mimeType ?? '';\n\n // Image preview from the live File. An attachment without one falls through to\n // the URL branch below, and failing that to a file-type icon.\n if (file && type.startsWith('image/')) {\n const objectURL = this._getOrCreateObjectURL(file);\n if (!objectURL) {\n return nothing;\n }\n\n return html`<span class=\"${prefix}-file-upload-item__preview-wrapper\"\n ><img\n class=\"${prefix}-file-upload-item__preview\"\n src=\"${objectURL}\"\n width=\"36\"\n height=\"36\"\n alt=\"\"\n aria-hidden=\"true\"\n /></span>`;\n }\n\n // Video preview\n if (file && type.startsWith('video/')) {\n const objectURL = this._getOrCreateObjectURL(file);\n if (!objectURL) {\n return nothing;\n }\n\n const openVideo = () => {\n const newWindow = isBrowser()\n ? window.open('', '_blank', 'width=800,height=600')\n : null;\n\n if (!newWindow) {\n return;\n }\n\n const style = newWindow.document.createElement('style');\n style.textContent =\n '* { margin: 0; padding: 0; background: #000 } video { display: block; width: 100%; height: 100vh; object-fit: contain }';\n const video = newWindow.document.createElement('video');\n video.src = objectURL;\n video.controls = true;\n video.autoplay = true;\n newWindow.document.title = name ?? '';\n newWindow.document.head.appendChild(style);\n newWindow.document.body.appendChild(video);\n };\n\n return html`<button\n class=\"${prefix}-file-upload-item__preview-wrapper ${prefix}-file-upload-item__video-preview-wrapper\"\n type=\"button\"\n aria-label=\"Play video\"\n @click=\"${openVideo}\">\n <video\n class=\"${prefix}-file-upload-item__preview\"\n src=\"${objectURL}\"\n width=\"36\"\n height=\"36\"\n preload=\"metadata\"\n muted\n playsinline\n tabindex=\"-1\"\n aria-hidden=\"true\"\n @loadedmetadata=\"${(e: Event) => {\n (e.target as HTMLVideoElement).currentTime = 0.1;\n }}\"></video\n ><span class=\"${prefix}-file-upload-item__play-badge\" aria-hidden=\"true\"\n >${iconLoader(PlayFilledAlt16)}</span\n >\n </button>`;\n }\n\n // Image preview from a stated URL — an attachment whose file lives on a server\n // rather than in the page. No video equivalent: playback would stream the file\n // back, which a chip on a sent message has no business doing.\n if (this._canPreviewURL(url) && type.startsWith('image/')) {\n return html`<span class=\"${prefix}-file-upload-item__preview-wrapper\"\n ><img\n class=\"${prefix}-file-upload-item__preview\"\n src=\"${url}\"\n width=\"36\"\n height=\"36\"\n alt=\"\"\n aria-hidden=\"true\"\n @error=\"${() => {\n this._failedPreviewURL = url;\n }}\"\n /></span>`;\n }\n\n // File type icon (for supported icons)\n const icon = pickFileTypeIcon(name, type);\n if (icon) {\n return html`<span\n class=\"${prefix}-file-upload-item__icon\"\n aria-hidden=\"true\"\n >${iconLoader(icon)}</span\n >`;\n }\n\n return nothing;\n }\n\n private _handleRemove() {\n if (!this.upload) {\n return;\n }\n\n this.dispatchEvent(\n new CustomEvent<FileRemoveEventDetail>('cds-custom-aichat-file-remove', {\n detail: { fileId: this.upload.id },\n bubbles: true,\n composed: true,\n })\n );\n }\n\n render() {\n const resolved = this._resolved;\n if (!resolved) {\n return nothing;\n }\n\n // An empty state falls through Carbon's status switch, rendering no\n // affordance. `_syncInjectedStyles` collapses the container it still reserves.\n const state = this.readOnly ? '' : this._uploadStatus;\n const error = this._uploadError;\n\n return html`\n <cds-custom-file-uploader-item\n size=\"md\"\n .state=\"${state}\"\n .iconDescription=\"${\n state === 'uploading'\n ? this.uploadingFileLabel\n : this.removeFileNamedLabel || this.removeFileLabel\n }\"\n .errorSubject=\"${error.message}\"\n ?invalid=\"${!this.readOnly && error.isError}\"\n @cds-custom-file-uploader-item-deleted=\"${this._handleRemove}\">\n ${this._renderPreview()} ${resolved.name || this.fallbackLabel}\n </cds-custom-file-uploader-item>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'cds-custom-aichat-file-upload-item': FileUploadItemElement;\n }\n}\n\nexport default FileUploadItemElement;\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;;;;;;;AAOG;AA+BH;;;AAGG;AACH,MAAM,gBAAgB,GAAG,mCAAmC;AAa5D;AACA,SAAS,aAAa,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAwB,EAAA;IACxE,IAAI,KAAK,EAAE;AACT,QAAA,OAAO,CAAC,YAAY,CAAC,SAAS,EAAE,KAAK,CAAC;IACxC;SAAO;AACL,QAAA,OAAO,CAAC,eAAe,C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