@carbon/ai-chat 1.3.2 → 1.4.0-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/dist/es/aiChatEntry.js +96 -132
  2. package/dist/es/aiChatEntry.js.map +1 -1
  3. package/dist/es/chat.ChatAppEntry.js +1808 -4924
  4. package/dist/es/chat.ChatAppEntry.js.map +1 -1
  5. package/dist/es/chat.LayoutCustomProperties.js +12 -0
  6. package/dist/es/chat.LayoutCustomProperties.js.map +1 -0
  7. package/dist/es/{chat.PageObjectId.js → chat.languages.js} +489 -227
  8. package/dist/es/chat.languages.js.map +1 -0
  9. package/dist/es/serverEntry.js +36 -9
  10. package/dist/es/serverEntry.js.map +1 -1
  11. package/dist/es/web-components/cds-aichat-container/index.js +31 -67
  12. package/dist/es/web-components/cds-aichat-container/index.js.map +1 -1
  13. package/dist/es/web-components/cds-aichat-custom-element/index.js +30 -66
  14. package/dist/es/web-components/cds-aichat-custom-element/index.js.map +1 -1
  15. package/dist/es-custom/aiChatEntry.js +96 -132
  16. package/dist/es-custom/aiChatEntry.js.map +1 -1
  17. package/dist/es-custom/chat.ChatAppEntry.js +1808 -4924
  18. package/dist/es-custom/chat.ChatAppEntry.js.map +1 -1
  19. package/dist/es-custom/chat.LayoutCustomProperties.js +12 -0
  20. package/dist/es-custom/chat.LayoutCustomProperties.js.map +1 -0
  21. package/dist/es-custom/{chat.PageObjectId.js → chat.languages.js} +489 -227
  22. package/dist/es-custom/chat.languages.js.map +1 -0
  23. package/dist/es-custom/serverEntry.js +36 -9
  24. package/dist/es-custom/serverEntry.js.map +1 -1
  25. package/dist/es-custom/web-components/cds-aichat-container/index.js +31 -67
  26. package/dist/es-custom/web-components/cds-aichat-container/index.js.map +1 -1
  27. package/dist/es-custom/web-components/cds-aichat-custom-element/index.js +30 -66
  28. package/dist/es-custom/web-components/cds-aichat-custom-element/index.js.map +1 -1
  29. package/dist/types/aiChatEntry.d.ts +4 -3
  30. package/dist/types/{serverEntry-ojFJl1OR.d.ts → serverEntry-BZ90jVeY.d.ts} +1026 -975
  31. package/dist/types/serverEntry.d.ts +3 -2
  32. package/package.json +8 -19
  33. package/telemetry.yml +0 -5
  34. package/dist/es/chat.PageObjectId.js.map +0 -1
  35. package/dist/es-custom/chat.PageObjectId.js.map +0 -1
@@ -1,8 +1,8 @@
1
- import { B as BusEventType } from "./chat.PageObjectId.js";
1
+ import { B as BusEventType } from "./chat.languages.js";
2
2
 
3
- export { g as ButtonItemKind, h as ButtonItemType, b as CancellationReason, c as CarbonTheme, n as ChainOfThoughtStepStatus, C as CornersType, E as ErrorType, F as FeedbackInteractionType, f as FileStatusValue, m as HumanAgentMessageType, H as HumanAgentsOnlineStatus, I as IFrameItemDisplayOption, o as MessageErrorState, i as MessageInputType, j as MessageResponseTypes, M as MessageSendSource, d as MinimizeButtonIconType, O as OnErrorType, k as OptionItemPreference, p as PageObjectId, P as PanelType, S as ScreenShareState, U as UserType, a as ViewChangeReason, V as ViewType, l as WidthOptions, W as WriteableElementName, e as enLanguagePack } from "./chat.PageObjectId.js";
3
+ export { h as ButtonItemKind, i as ButtonItemType, c as CancellationReason, d as CarbonTheme, C as CornersType, E as ErrorType, F as FeedbackInteractionType, g as FileStatusValue, n as HumanAgentMessageType, H as HumanAgentsOnlineStatus, I as IFrameItemDisplayOption, o as MessageErrorState, j as MessageInputType, k as MessageResponseTypes, M as MessageSendSource, f as MinimizeButtonIconType, O as OnErrorType, l as OptionItemPreference, P as PageObjectId, a as PanelType, R as ReasoningStepOpenState, S as ScreenShareState, U as UserType, b as ViewChangeReason, V as ViewType, m as WidthOptions, W as WriteableElementName, e as enLanguagePack } from "./chat.languages.js";
4
4
 
5
- export { LayoutCustomProperties } from "./serverEntry.js";
5
+ export { L as LayoutCustomProperties } from "./chat.LayoutCustomProperties.js";
6
6
 
7
7
  import { __decorate } from "tslib";
8
8
 
@@ -18,10 +18,14 @@ import { i as isBrowser, A as App } from "./chat.ChatAppEntry.js";
18
18
 
19
19
  import { carbonElement } from "@carbon/ai-chat-components/es/globals/decorators/index.js";
20
20
 
21
- import "lodash-es/isEqual.js";
21
+ export { ChainOfThoughtStepStatus } from "@carbon/ai-chat-components/es/components/chain-of-thought/src/types.js";
22
22
 
23
23
  import "dayjs";
24
24
 
25
+ import "dayjs/locale/en.js";
26
+
27
+ import "lodash-es/isEqual.js";
28
+
25
29
  import "dayjs/plugin/localizedFormat.js";
26
30
 
27
31
  import "lodash-es/merge.js";
@@ -32,10 +36,6 @@ import "lodash-es/mergeWith.js";
32
36
 
33
37
  import "react-intl";
34
38
 
35
- import "dayjs/locale/en.js";
36
-
37
- import "intl-messageformat";
38
-
39
39
  import "classnames";
40
40
 
41
41
  import "use-sync-external-store/shim";
@@ -58,45 +58,7 @@ import "@carbon/web-components/es/components/button/button.js";
58
58
 
59
59
  import "@carbon/icons/es/user--avatar/32.js";
60
60
 
61
- import "lit/decorators.js";
62
-
63
- import "markdown-it";
64
-
65
- import "dompurify";
66
-
67
- import "lit/directives/repeat.js";
68
-
69
- import "lit/directives/unsafe-html.js";
70
-
71
- import "lit/directive.js";
72
-
73
- import "@carbon/web-components/es/components/list/index.js";
74
-
75
- import "@carbon/web-components/es/components/data-table/index.js";
76
-
77
- import "@carbon/web-components/es/components/checkbox/index.js";
78
-
79
- import "@carbon/web-components/es/components/button/index.js";
80
-
81
- import "@carbon/web-components/es/components/layer/index.js";
82
-
83
- import "@carbon/web-components/es/globals/internal/icon-loader.js";
84
-
85
- import "@carbon/icons/es/download/16.js";
86
-
87
- import "lit-html/directives/repeat.js";
88
-
89
- import "@carbon/web-components/es/components/pagination/index.js";
90
-
91
- import "@carbon/web-components/es/components/select/index.js";
92
-
93
- import "@carbon/web-components/es/components/data-table/table-skeleton.js";
94
-
95
- import "@carbon/web-components/es/components/notification/actionable-notification.js";
96
-
97
- import "@carbon/web-components/es/components/notification/defs.js";
98
-
99
- import "@carbon/web-components/es/components/notification/actionable-notification-button.js";
61
+ import "@carbon/ai-chat-components/es/react/markdown.js";
100
62
 
101
63
  import "@carbon/icons/es/chat-bot/32.js";
102
64
 
@@ -104,6 +66,12 @@ import "@carbon/icons/es/checkmark--filled/16.js";
104
66
 
105
67
  import "@carbon/icons/es/headset/32.js";
106
68
 
69
+ import "@carbon/icons/es/chevron--down/16.js";
70
+
71
+ import "@carbon/ai-chat-components/es/react/reasoning-steps.js";
72
+
73
+ import "@carbon/ai-chat-components/es/react/reasoning-step.js";
74
+
107
75
  import "@carbon/web-components/es/components/loading/loading-icon.js";
108
76
 
109
77
  import "@carbon/web-components/es/components/loading/loading.js";
@@ -112,21 +80,11 @@ import "@carbon/icons/es/error--filled/16.js";
112
80
 
113
81
  import "@carbon/icons/es/attachment/16.js";
114
82
 
115
- import "@carbon/web-components/es/components/textarea/index.js";
116
-
117
- import "@carbon/web-components/es/components/icon-button/index.js";
118
-
119
- import "@carbon/icons/es/thumbs-down/16.js";
120
-
121
- import "@carbon/icons/es/thumbs-down--filled/16.js";
122
-
123
- import "@carbon/icons/es/thumbs-up/16.js";
124
-
125
- import "@carbon/icons/es/thumbs-up--filled/16.js";
83
+ import "@carbon/ai-chat-components/es/react/feedback-buttons.js";
126
84
 
127
- import "@carbon/web-components/es/components/tag/index.js";
85
+ import "@carbon/ai-chat-components/es/react/feedback.js";
128
86
 
129
- import "@carbon/web-components/es/components/chat-button/index.js";
87
+ import "@carbon/ai-chat-components/es/globals/settings.js";
130
88
 
131
89
  import "@carbon/icons/es/checkmark/16.js";
132
90
 
@@ -148,12 +106,14 @@ import "@carbon/web-components/es/components/skeleton-text/skeleton-text.js";
148
106
 
149
107
  import "@carbon/web-components/es/components/skeleton-placeholder/skeleton-placeholder.js";
150
108
 
151
- import "@carbon/icons/es/chevron--down/16.js";
152
-
153
109
  import "@carbon/icons/es/chevron--up/16.js";
154
110
 
155
111
  import "@carbon/icons/es/touch--interaction/16.js";
156
112
 
113
+ import "@carbon/ai-chat-components/es/react/chat-button.js";
114
+
115
+ import "@carbon/ai-chat-components/es/react/button.js";
116
+
157
117
  import "@carbon/icons/es/send/16.js";
158
118
 
159
119
  import "@carbon/icons/es/arrow--right/16.js";
@@ -182,18 +142,18 @@ import "@carbon/web-components/es/components/date-picker/date-picker-input.js";
182
142
 
183
143
  import "@carbon/web-components/es/components/date-picker/defs.js";
184
144
 
185
- import "@carbon/web-components/es/components/chat-button/chat-button.js";
186
-
187
145
  import "@carbon/web-components/es/components/dropdown/dropdown.js";
188
146
 
189
147
  import "@carbon/web-components/es/components/dropdown/dropdown-item.js";
190
148
 
191
- import "@carbon/web-components/es/components/inline-loading/index.js";
149
+ import "@carbon/ai-chat-components/es/react/chain-of-thought.js";
192
150
 
193
151
  import "@carbon/ai-chat-components/es/react/processing.js";
194
152
 
195
153
  import "@carbon/icons/es/restart/16.js";
196
154
 
155
+ import "@carbon/web-components/es/components/chat-button/chat-button.js";
156
+
197
157
  import "@carbon/icons/es/home/16.js";
198
158
 
199
159
  import "@carbon/icons/es/close--large/16.js";
@@ -214,6 +174,8 @@ import "@carbon/web-components/es/components/overflow-menu/overflow-menu-body.js
214
174
 
215
175
  import "@carbon/web-components/es/components/overflow-menu/overflow-menu-item.js";
216
176
 
177
+ import "lit/decorators.js";
178
+
217
179
  import "@carbon/web-components/es/components/ai-label/ai-label-action-button.js";
218
180
 
219
181
  import "@carbon/web-components/es/components/ai-label/ai-label.js";
@@ -224,17 +186,19 @@ import "@carbon/web-components/es/components/file-uploader/defs.js";
224
186
 
225
187
  import "@carbon/web-components/es/components/file-uploader/file-uploader-item.js";
226
188
 
189
+ import "@carbon/web-components/es/components/icon-button/index.js";
190
+
191
+ import "@carbon/web-components/es/globals/internal/icon-loader.js";
192
+
227
193
  import "@carbon/icons/es/stop--filled/16.js";
228
194
 
229
195
  import "@carbon/web-components/es/components/layer/layer.js";
230
196
 
231
- import "@carbon/icons/es/close/16.js";
232
-
233
197
  import "@carbon/icons/es/ai-launch/24.js";
234
198
 
235
199
  import "@carbon/icons/es/chat--launch/24.js";
236
200
 
237
- import "@carbon/web-components/es/components/tag/tag.js";
201
+ import "@carbon/icons/es/close/16.js";
238
202
 
239
203
  let ChatContainerReact = class ChatContainerReact extends LitElement {
240
204
  firstUpdated(changedProperties) {
@@ -261,29 +225,29 @@ const ReactChatContainer = React.memo(createComponent({
261
225
  }));
262
226
 
263
227
  function ChatContainer(props) {
264
- const {onBeforeRender: onBeforeRender, onAfterRender: onAfterRender, strings: strings, serviceDeskFactory: serviceDeskFactory, serviceDesk: serviceDesk, renderUserDefinedResponse: renderUserDefinedResponse, renderWriteableElements: renderWriteableElements, element: element, onError: onError, openChatByDefault: openChatByDefault, disclaimer: disclaimer, disableCustomElementMobileEnhancements: disableCustomElementMobileEnhancements, debug: debug, exposeServiceManagerForTesting: exposeServiceManagerForTesting, injectCarbonTheme: injectCarbonTheme, aiEnabled: aiEnabled, shouldTakeFocusIfOpensAutomatically: shouldTakeFocusIfOpensAutomatically, namespace: namespace, enableFocusTrap: enableFocusTrap, shouldSanitizeHTML: shouldSanitizeHTML, header: header, layout: layout, messaging: messaging, isReadonly: isReadonly, assistantName: assistantName, locale: locale, homescreen: homescreen, launcher: launcher, input: input} = props;
228
+ const {onBeforeRender, onAfterRender, strings, serviceDeskFactory, serviceDesk, renderUserDefinedResponse, renderWriteableElements, element, onError, openChatByDefault, disclaimer, disableCustomElementMobileEnhancements, debug, exposeServiceManagerForTesting, injectCarbonTheme, aiEnabled, shouldTakeFocusIfOpensAutomatically, namespace, enableFocusTrap, shouldSanitizeHTML, header, layout, messaging, isReadonly, assistantName, locale, homescreen, launcher, input} = props;
265
229
  const config = useMemo(() => ({
266
- onError: onError,
267
- openChatByDefault: openChatByDefault,
268
- disclaimer: disclaimer,
269
- disableCustomElementMobileEnhancements: disableCustomElementMobileEnhancements,
270
- debug: debug,
271
- exposeServiceManagerForTesting: exposeServiceManagerForTesting,
272
- injectCarbonTheme: injectCarbonTheme,
273
- aiEnabled: aiEnabled,
274
- shouldTakeFocusIfOpensAutomatically: shouldTakeFocusIfOpensAutomatically,
275
- namespace: namespace,
276
- enableFocusTrap: enableFocusTrap,
277
- shouldSanitizeHTML: shouldSanitizeHTML,
278
- header: header,
279
- layout: layout,
280
- messaging: messaging,
281
- isReadonly: isReadonly,
282
- assistantName: assistantName,
283
- locale: locale,
284
- homescreen: homescreen,
285
- launcher: launcher,
286
- input: input
230
+ onError,
231
+ openChatByDefault,
232
+ disclaimer,
233
+ disableCustomElementMobileEnhancements,
234
+ debug,
235
+ exposeServiceManagerForTesting,
236
+ injectCarbonTheme,
237
+ aiEnabled,
238
+ shouldTakeFocusIfOpensAutomatically,
239
+ namespace,
240
+ enableFocusTrap,
241
+ shouldSanitizeHTML,
242
+ header,
243
+ layout,
244
+ messaging,
245
+ isReadonly,
246
+ assistantName,
247
+ locale,
248
+ homescreen,
249
+ launcher,
250
+ input
287
251
  }), [ onError, openChatByDefault, disclaimer, disableCustomElementMobileEnhancements, debug, exposeServiceManagerForTesting, injectCarbonTheme, aiEnabled, shouldTakeFocusIfOpensAutomatically, namespace, enableFocusTrap, shouldSanitizeHTML, header, layout, messaging, isReadonly, assistantName, locale, homescreen, launcher, input ]);
288
252
  const wrapperRef = useRef(null);
289
253
  const [wrapper, setWrapper] = useState(null);
@@ -349,33 +313,33 @@ function ChatContainer(props) {
349
313
  onBeforeRender?.(instance);
350
314
  }
351
315
  }, [ onBeforeRender ]);
352
- if (!isBrowser) {
316
+ if (!isBrowser()) {
353
317
  return null;
354
318
  }
355
319
  return React.createElement(React.Fragment, null, React.createElement(ReactChatContainer, {
356
320
  ref: wrapperRef
357
321
  }), container && createPortal(React.createElement(App, {
358
322
  key: "stable-chat-instance",
359
- config: config,
360
- strings: strings,
361
- serviceDeskFactory: serviceDeskFactory,
362
- serviceDesk: serviceDesk,
363
- renderUserDefinedResponse: renderUserDefinedResponse,
364
- renderWriteableElements: renderWriteableElements,
323
+ config,
324
+ strings,
325
+ serviceDeskFactory,
326
+ serviceDesk,
327
+ renderUserDefinedResponse,
328
+ renderWriteableElements,
365
329
  onBeforeRender: onBeforeRenderOverride,
366
- onAfterRender: onAfterRender,
367
- container: container,
330
+ onAfterRender,
331
+ container,
368
332
  setParentInstance: setCurrentInstance,
369
- element: element,
333
+ element,
370
334
  chatWrapper: wrapper
371
335
  }), container));
372
336
  }
373
337
 
374
- const customElementStylesheet = isBrowser && typeof CSSStyleSheet !== "undefined" ? new CSSStyleSheet : null;
338
+ const customElementStylesheet = isBrowser() && typeof CSSStyleSheet !== "undefined" ? new CSSStyleSheet : null;
375
339
 
376
340
  const hideStyles = `\n .cds-aichat--hidden {\n width: 0 !important;\n height: 0 !important;\n min-width: 0 !important;\n min-height: 0 !important;\n max-width: 0 !important;\n max-height: 0 !important;\n inline-size: 0 !important;\n block-size: 0 !important;\n min-inline-size: 0 !important;\n min-block-size: 0 !important;\n max-inline-size: 0 !important;\n max-block-size: 0 !important;\n overflow: hidden !important;\n }\n`;
377
341
 
378
- if (isBrowser && !document.getElementById("cds-aichat-custom-element-styles")) {
342
+ if (isBrowser() && !document.getElementById("cds-aichat-custom-element-styles")) {
379
343
  if (customElementStylesheet && "replaceSync" in customElementStylesheet) {
380
344
  customElementStylesheet.replaceSync(hideStyles);
381
345
  document.adoptedStyleSheets = [ ...document.adoptedStyleSheets, customElementStylesheet ];
@@ -388,7 +352,7 @@ if (isBrowser && !document.getElementById("cds-aichat-custom-element-styles")) {
388
352
  }
389
353
 
390
354
  function ChatCustomElement(props) {
391
- const {strings: strings, serviceDeskFactory: serviceDeskFactory, serviceDesk: serviceDesk, onBeforeRender: onBeforeRender, onAfterRender: onAfterRender, renderUserDefinedResponse: renderUserDefinedResponse, renderWriteableElements: renderWriteableElements, className: className, id: id, onViewChange: onViewChange, onViewPreChange: onViewPreChange, onError: onError, openChatByDefault: openChatByDefault, disclaimer: disclaimer, disableCustomElementMobileEnhancements: disableCustomElementMobileEnhancements, debug: debug, exposeServiceManagerForTesting: exposeServiceManagerForTesting, injectCarbonTheme: injectCarbonTheme, aiEnabled: aiEnabled, shouldTakeFocusIfOpensAutomatically: shouldTakeFocusIfOpensAutomatically, namespace: namespace, enableFocusTrap: enableFocusTrap, shouldSanitizeHTML: shouldSanitizeHTML, header: header, layout: layout, messaging: messaging, isReadonly: isReadonly, assistantName: assistantName, locale: locale, homescreen: homescreen, launcher: launcher, input: input} = props;
355
+ const {strings, serviceDeskFactory, serviceDesk, onBeforeRender, onAfterRender, renderUserDefinedResponse, renderWriteableElements, className, id, onViewChange, onViewPreChange, onError, openChatByDefault, disclaimer, disableCustomElementMobileEnhancements, debug, exposeServiceManagerForTesting, injectCarbonTheme, aiEnabled, shouldTakeFocusIfOpensAutomatically, namespace, enableFocusTrap, shouldSanitizeHTML, header, layout, messaging, isReadonly, assistantName, locale, homescreen, launcher, input} = props;
392
356
  const [customElement, setCustomElement] = useState();
393
357
  const onBeforeRenderOverride = useCallback(async instance => {
394
358
  function defaultViewChangeHandler(event) {
@@ -413,39 +377,39 @@ function ChatCustomElement(props) {
413
377
  return onBeforeRender?.(instance);
414
378
  }, [ onViewPreChange, onViewChange, onBeforeRender, customElement ]);
415
379
  return React.createElement("div", {
416
- className: className,
417
- id: id,
380
+ className,
381
+ id,
418
382
  ref: setCustomElement
419
383
  }, customElement && React.createElement(ChatContainer, {
420
- onError: onError,
421
- openChatByDefault: openChatByDefault,
422
- disclaimer: disclaimer,
423
- disableCustomElementMobileEnhancements: disableCustomElementMobileEnhancements,
424
- debug: debug,
425
- exposeServiceManagerForTesting: exposeServiceManagerForTesting,
426
- injectCarbonTheme: injectCarbonTheme,
427
- aiEnabled: aiEnabled,
428
- shouldTakeFocusIfOpensAutomatically: shouldTakeFocusIfOpensAutomatically,
429
- namespace: namespace,
430
- enableFocusTrap: enableFocusTrap,
431
- shouldSanitizeHTML: shouldSanitizeHTML,
432
- header: header,
433
- layout: layout,
434
- messaging: messaging,
435
- isReadonly: isReadonly,
436
- assistantName: assistantName,
437
- locale: locale,
438
- homescreen: homescreen,
439
- launcher: launcher,
440
- strings: strings,
441
- serviceDeskFactory: serviceDeskFactory,
442
- serviceDesk: serviceDesk,
384
+ onError,
385
+ openChatByDefault,
386
+ disclaimer,
387
+ disableCustomElementMobileEnhancements,
388
+ debug,
389
+ exposeServiceManagerForTesting,
390
+ injectCarbonTheme,
391
+ aiEnabled,
392
+ shouldTakeFocusIfOpensAutomatically,
393
+ namespace,
394
+ enableFocusTrap,
395
+ shouldSanitizeHTML,
396
+ header,
397
+ layout,
398
+ messaging,
399
+ isReadonly,
400
+ assistantName,
401
+ locale,
402
+ homescreen,
403
+ launcher,
404
+ strings,
405
+ serviceDeskFactory,
406
+ serviceDesk,
443
407
  onBeforeRender: onBeforeRenderOverride,
444
- onAfterRender: onAfterRender,
445
- renderUserDefinedResponse: renderUserDefinedResponse,
446
- renderWriteableElements: renderWriteableElements,
408
+ onAfterRender,
409
+ renderUserDefinedResponse,
410
+ renderWriteableElements,
447
411
  element: customElement,
448
- input: input
412
+ input
449
413
  }));
450
414
  }
451
415
 
@@ -1 +1 @@
1
- {"version":3,"file":"aiChatEntry.js","sources":["../../../../src/react/ChatContainer.tsx","../../../../src/react/ChatCustomElement.tsx"],"sourcesContent":["/*\n * Copyright IBM Corp. 2025\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 { createComponent } from \"@lit/react\";\nimport { css, LitElement, PropertyValues } from \"lit\";\nimport React, {\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { createPortal } from \"react-dom\";\n\nimport App from \"../chat/ChatAppEntry\";\nimport { carbonElement } from \"@carbon/ai-chat-components/es/globals/decorators/index.js\";\nimport { ChatContainerProps } from \"../types/component/ChatContainer\";\nimport { ChatInstance } from \"../types/instance/ChatInstance\";\nimport { PublicConfig } from \"../types/config/PublicConfig\";\nimport { isBrowser } from \"../chat/utils/browserUtils\";\n\n/**\n * This component creates a custom element protected by a shadow DOM to render the React application into. It creates\n * slotted elements for user_defined responses and for writable elements.\n *\n * The corresponding slots are defined within the React application and are rendered in place.\n */\n\n/**\n * Create a web component to host the React application. We do this so we can provide custom elements and user_defined responses as\n * slotted content so they maintain their own styling in a safe way.\n */\n@carbonElement(\"cds-aichat-react\")\nclass ChatContainerReact extends LitElement {\n static styles = css`\n :host {\n width: 100%;\n height: 100%;\n }\n `;\n\n /**\n * Dispatch a custom event when the shadow DOM is ready\n * This ensures React can safely access shadowRoot\n */\n firstUpdated(changedProperties: PropertyValues) {\n super.firstUpdated(changedProperties);\n this.dispatchEvent(new CustomEvent(\"shadow-ready\", { bubbles: true }));\n }\n}\n\n// Wrap the custom element as a React component\nconst ReactChatContainer = React.memo(\n createComponent({\n tagName: \"cds-aichat-react\",\n elementClass: ChatContainerReact,\n react: React,\n }),\n);\n\n/**\n * The ChatContainer controls rendering the React application into the shadow DOM of the cds-aichat-react web component.\n * It also injects the writeable element and user_defined response slots into said web component.\n *\n * @category React\n */\nfunction ChatContainer(props: ChatContainerProps) {\n const {\n onBeforeRender,\n onAfterRender,\n strings,\n serviceDeskFactory,\n serviceDesk,\n renderUserDefinedResponse,\n renderWriteableElements,\n element,\n // Flattened PublicConfig properties\n onError,\n openChatByDefault,\n disclaimer,\n disableCustomElementMobileEnhancements,\n debug,\n exposeServiceManagerForTesting,\n injectCarbonTheme,\n aiEnabled,\n shouldTakeFocusIfOpensAutomatically,\n namespace,\n enableFocusTrap,\n shouldSanitizeHTML,\n header,\n layout,\n messaging,\n isReadonly,\n assistantName,\n locale,\n homescreen,\n launcher,\n input,\n } = props;\n // Reconstruct PublicConfig from flattened props\n const config = useMemo(\n (): PublicConfig => ({\n onError,\n openChatByDefault,\n disclaimer,\n disableCustomElementMobileEnhancements,\n debug,\n exposeServiceManagerForTesting,\n injectCarbonTheme,\n aiEnabled,\n shouldTakeFocusIfOpensAutomatically,\n namespace,\n enableFocusTrap,\n shouldSanitizeHTML,\n header,\n layout,\n messaging,\n isReadonly,\n assistantName,\n locale,\n homescreen,\n launcher,\n input,\n }),\n [\n onError,\n openChatByDefault,\n disclaimer,\n disableCustomElementMobileEnhancements,\n debug,\n exposeServiceManagerForTesting,\n injectCarbonTheme,\n aiEnabled,\n shouldTakeFocusIfOpensAutomatically,\n namespace,\n enableFocusTrap,\n shouldSanitizeHTML,\n header,\n layout,\n messaging,\n isReadonly,\n assistantName,\n locale,\n homescreen,\n launcher,\n input,\n ],\n );\n const wrapperRef = useRef(null); // Ref for the React wrapper component\n const [wrapper, setWrapper] = useState(null);\n const [container, setContainer] = useState<HTMLElement | null>(null); // Actual element we render the React Portal to in the Shadowroot.\n\n const [writeableElementSlots, setWriteableElementSlots] = useState<\n HTMLElement[]\n >([]);\n const [currentInstance, setCurrentInstance] = useState<ChatInstance>(null);\n\n /**\n * Setup the DOM nodes of both the web component to be able to inject slotted content into it, and the element inside the\n * shadow DOM we will inject our React application into.\n */\n useEffect(() => {\n if (!wrapperRef.current) {\n return null; // Early return when there's nothing to set up because the element isn't ready.\n }\n\n let eventListenerAdded = false;\n\n const wrapperElement = wrapperRef.current as unknown as ChatContainerReact;\n\n // We need to check if the element in the shadow DOM we are render the React application to exists.\n // If it doesn't, we need to create and append it.\n\n const handleShadowReady = () => {\n // Now we know shadowRoot is definitely available\n let reactElement = wrapperElement.shadowRoot.querySelector(\n \".cds-aichat--react-app\",\n ) as HTMLElement;\n\n if (!reactElement) {\n reactElement = document.createElement(\"div\");\n reactElement.classList.add(\"cds-aichat--react-app\");\n wrapperElement.shadowRoot.appendChild(reactElement);\n }\n\n if (wrapperElement !== wrapper) {\n setWrapper(wrapperElement);\n }\n if (reactElement !== container) {\n setContainer(reactElement);\n }\n };\n\n if (wrapperElement.shadowRoot) {\n // Already ready\n handleShadowReady();\n } else {\n // Wait for ready event\n eventListenerAdded = true;\n wrapperElement.addEventListener(\"shadow-ready\", handleShadowReady, {\n once: true,\n });\n }\n\n return () => {\n if (eventListenerAdded) {\n wrapperElement.removeEventListener(\"shadow-ready\", handleShadowReady);\n }\n };\n }, [container, wrapper, currentInstance]);\n\n /**\n * Here we write the slotted elements into the wrapper so they are passed into the application to be rendered in their slot.\n */\n useEffect(() => {\n if (wrapper) {\n const combinedNodes: HTMLElement[] = [...writeableElementSlots];\n const currentNodes: HTMLElement[] = Array.from(\n wrapper.childNodes,\n ) as HTMLElement[];\n\n // Append new nodes that aren't already in the container\n combinedNodes.forEach((node) => {\n if (!currentNodes.includes(node)) {\n wrapper.appendChild(node);\n }\n });\n }\n }, [writeableElementSlots, wrapper]);\n\n const onBeforeRenderOverride = useCallback(\n (instance: ChatInstance) => {\n if (instance) {\n const addWriteableElementSlots = () => {\n const slots: HTMLElement[] = Object.entries(\n instance.writeableElements,\n ).map((writeableElement) => {\n const [key, element] = writeableElement;\n element.setAttribute(\"slot\", key); // Assign slot attributes dynamically\n return element;\n });\n setWriteableElementSlots(slots);\n };\n\n addWriteableElementSlots();\n onBeforeRender?.(instance);\n }\n },\n [onBeforeRender],\n );\n\n // If we are in SSR mode, just short circuit here. This prevents all of our window.* and document.* stuff from trying\n // to run and erroring out.\n if (!isBrowser) {\n return null;\n }\n\n return (\n <>\n <ReactChatContainer ref={wrapperRef} />\n {container &&\n createPortal(\n <App\n key=\"stable-chat-instance\" // Prevent remounting on config changes\n config={config}\n strings={strings}\n serviceDeskFactory={serviceDeskFactory}\n serviceDesk={serviceDesk}\n renderUserDefinedResponse={renderUserDefinedResponse}\n renderWriteableElements={renderWriteableElements}\n onBeforeRender={onBeforeRenderOverride}\n onAfterRender={onAfterRender}\n container={container}\n setParentInstance={setCurrentInstance}\n element={element}\n chatWrapper={wrapper}\n />,\n container, // Render AppContainer into the shadowRoot\n )}\n </>\n );\n}\n\nexport { ChatContainer, ChatContainerProps };\n","/*\n * Copyright IBM Corp. 2025\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 React, { useCallback, useState } from \"react\";\n\nimport { ChatInstance } from \"../types/instance/ChatInstance\";\nimport {\n BusEventType,\n BusEventViewChange,\n BusEventViewPreChange,\n} from \"../types/events/eventBusTypes\";\nimport { ChatContainer, ChatContainerProps } from \"./ChatContainer\";\nimport { isBrowser } from \"../chat/utils/browserUtils\";\n\n/**\n * Properties for the ChatContainer React component. This interface extends\n * {@link ChatContainerProps} and {@link PublicConfig} with additional component-specific props, flattening all\n * config properties as top-level props for better TypeScript IntelliSense.\n *\n * @category React\n */\ninterface ChatCustomElementProps extends ChatContainerProps {\n /**\n * A CSS class name that will be added to the custom element. This class must define the size of the\n * your custom element (width and height or using logical inline-size/block-size).\n *\n * You can make use of onViewPreChange and/or onViewChange to mutate this className value so have open/close animations.\n *\n * By default, the chat will just set the chat shell to a 0x0 size and mark everything but the launcher (is you are using it)\n * as display: none; if the chat is set to closed.\n */\n className: string;\n\n /**\n * An optional id that will be added to the custom element.\n */\n id?: string;\n\n /**\n * Called before a view change (chat opening/closing). The chat will hide the chat shell inside your custom element\n * to prevent invisible keyboard stops when the view change is *complete*.\n *\n * Use this callback to update your className value *before* the view change happens if you want to add any open/close\n * animations to your custom element before the chat shell inner contents are hidden. It is async and so you can\n * tie it to native the AnimationEvent and only return when your animations have completed.\n *\n * A common pattern is to use this for when the chat is closing and to use onViewChange for when the chat opens.\n *\n * Note that this function can only be provided before Carbon AI Chat is loaded as it is registered before the\n * chat renders. After Carbon AI Chat is loaded, the callback will not be updated.\n */\n onViewPreChange?: (\n event: BusEventViewPreChange,\n instance: ChatInstance,\n ) => Promise<void> | void;\n\n /**\n * Called when the chat view change is complete. If no callback is provided here, the default behavior will be to set\n * the chat shell to 0x0 size and set all inner contents aside from the launcher, if you are using it, to display: none.\n * The inner contents of the chat shell (aside from the launcher if you are using it) are always set to display: none\n * regardless of what is configured with this callback to prevent invisible tab stops and screen reader issues.\n *\n * Use this callback to update your className value when the chat has finished being opened or closed.\n *\n * You can provide a different callback here if you want custom animation behavior when the chat is opened or closed.\n * The animation behavior defined here will run in concert with the chat inside your custom container being hidden.\n *\n * If you want to run animations before the inner contents of the chat shell is shrunk and the inner contents are hidden,\n * make use of onViewPreChange.\n *\n * A common pattern is to use this for when the chat is opening and to use onViewPreChange for when the chat closes.\n *\n * Note that this function can only be provided before Carbon AI Chat is loaded as it is registered before the\n * chat renders. After Carbon AI Chat is loaded, the callback will not be updated.\n */\n onViewChange?: (event: BusEventViewChange, instance: ChatInstance) => void;\n}\n\nconst customElementStylesheet =\n isBrowser && typeof CSSStyleSheet !== \"undefined\"\n ? new CSSStyleSheet()\n : null;\n\nconst hideStyles = `\n .cds-aichat--hidden {\n width: 0 !important;\n height: 0 !important;\n min-width: 0 !important;\n min-height: 0 !important;\n max-width: 0 !important;\n max-height: 0 !important;\n inline-size: 0 !important;\n block-size: 0 !important;\n min-inline-size: 0 !important;\n min-block-size: 0 !important;\n max-inline-size: 0 !important;\n max-block-size: 0 !important;\n overflow: hidden !important;\n }\n`;\n\n// Inject styles using adopted stylesheets when available, fallback to style element\nif (isBrowser && !document.getElementById(\"cds-aichat-custom-element-styles\")) {\n if (customElementStylesheet && \"replaceSync\" in customElementStylesheet) {\n customElementStylesheet.replaceSync(hideStyles);\n document.adoptedStyleSheets = [\n ...document.adoptedStyleSheets,\n customElementStylesheet,\n ];\n } else {\n // Fallback for when adoptedStyleSheets are not supported\n const style = document.createElement(\"style\");\n style.id = \"cds-aichat-custom-element-styles\";\n style.textContent = hideStyles;\n document.head.appendChild(style);\n }\n}\n\n/**\n * This is the React component for people injecting a Carbon AI Chat with a custom element.\n *\n * It provides said element any class or id defined on itself for styling. It then calls ChatContainer with the custom\n * element passed in as a property to be used instead of generating an element with the default properties for a\n * floating chat.\n *\n * @category React\n */\nfunction ChatCustomElement(props: ChatCustomElementProps) {\n const {\n strings,\n serviceDeskFactory,\n serviceDesk,\n onBeforeRender,\n onAfterRender,\n renderUserDefinedResponse,\n renderWriteableElements,\n className,\n id,\n onViewChange,\n onViewPreChange,\n // Flattened PublicConfig properties\n onError,\n openChatByDefault,\n disclaimer,\n disableCustomElementMobileEnhancements,\n debug,\n exposeServiceManagerForTesting,\n injectCarbonTheme,\n aiEnabled,\n shouldTakeFocusIfOpensAutomatically,\n namespace,\n enableFocusTrap,\n shouldSanitizeHTML,\n header,\n layout,\n messaging,\n isReadonly,\n assistantName,\n locale,\n homescreen,\n launcher,\n input,\n } = props;\n\n const [customElement, setCustomElement] = useState<HTMLDivElement>();\n\n const onBeforeRenderOverride = useCallback(\n async (instance: ChatInstance) => {\n /**\n * A default handler for the \"view:change\" event. This will be used to show or hide the Carbon AI Chat main window\n * by adding/removing a CSS class that sets the element size to 0x0 when hidden.\n */\n function defaultViewChangeHandler(event: BusEventViewChange) {\n if (customElement) {\n if (event.newViewState.mainWindow) {\n // Show: remove the hidden class, let the provided className handle sizing\n customElement.classList.remove(\"cds-aichat--hidden\");\n } else {\n // Hide: add the hidden class to set size to 0x0\n customElement.classList.add(\"cds-aichat--hidden\");\n }\n }\n }\n\n if (onViewPreChange) {\n instance.on({\n type: BusEventType.VIEW_PRE_CHANGE,\n handler: onViewPreChange,\n });\n }\n\n instance.on({\n type: BusEventType.VIEW_CHANGE,\n handler: onViewChange || defaultViewChangeHandler,\n });\n\n return onBeforeRender?.(instance);\n },\n [onViewPreChange, onViewChange, onBeforeRender, customElement],\n );\n\n return (\n <div className={className} id={id} ref={setCustomElement}>\n {customElement && (\n <ChatContainer\n // Flattened PublicConfig properties\n onError={onError}\n openChatByDefault={openChatByDefault}\n disclaimer={disclaimer}\n disableCustomElementMobileEnhancements={\n disableCustomElementMobileEnhancements\n }\n debug={debug}\n exposeServiceManagerForTesting={exposeServiceManagerForTesting}\n injectCarbonTheme={injectCarbonTheme}\n aiEnabled={aiEnabled}\n shouldTakeFocusIfOpensAutomatically={\n shouldTakeFocusIfOpensAutomatically\n }\n namespace={namespace}\n enableFocusTrap={enableFocusTrap}\n shouldSanitizeHTML={shouldSanitizeHTML}\n header={header}\n layout={layout}\n messaging={messaging}\n isReadonly={isReadonly}\n assistantName={assistantName}\n locale={locale}\n homescreen={homescreen}\n launcher={launcher}\n // Other ChatContainer props\n strings={strings}\n serviceDeskFactory={serviceDeskFactory}\n serviceDesk={serviceDesk}\n onBeforeRender={onBeforeRenderOverride}\n onAfterRender={onAfterRender}\n renderUserDefinedResponse={renderUserDefinedResponse}\n renderWriteableElements={renderWriteableElements}\n element={customElement}\n input={input}\n />\n )}\n </div>\n );\n}\n\nexport { ChatCustomElement, ChatCustomElementProps };\n"],"names":["ChatContainerReact","LitElement","firstUpdated","changedProperties","super","this","dispatchEvent","CustomEvent","bubbles","styles","css","__decorate","carbonElement","ReactChatContainer","React","memo","createComponent","tagName","elementClass","react","ChatContainer","props","onBeforeRender","onAfterRender","strings","serviceDeskFactory","serviceDesk","renderUserDefinedResponse","renderWriteableElements","element","onError","openChatByDefault","disclaimer","disableCustomElementMobileEnhancements","debug","exposeServiceManagerForTesting","injectCarbonTheme","aiEnabled","shouldTakeFocusIfOpensAutomatically","namespace","enableFocusTrap","shouldSanitizeHTML","header","layout","messaging","isReadonly","assistantName","locale","homescreen","launcher","input","config","useMemo","wrapperRef","useRef","wrapper","setWrapper","useState","container","setContainer","writeableElementSlots","setWriteableElementSlots","currentInstance","setCurrentInstance","useEffect","current","eventListenerAdded","wrapperElement","handleShadowReady","reactElement","shadowRoot","querySelector","document","createElement","classList","add","appendChild","addEventListener","once","removeEventListener","combinedNodes","currentNodes","Array","from","childNodes","forEach","node","includes","onBeforeRenderOverride","useCallback","instance","addWriteableElementSlots","slots","Object","entries","writeableElements","map","writeableElement","key","setAttribute","isBrowser","Fragment","ref","createPortal","App","setParentInstance","chatWrapper","customElementStylesheet","CSSStyleSheet","hideStyles","getElementById","replaceSync","adoptedStyleSheets","style","id","textContent","head","ChatCustomElement","className","onViewChange","onViewPreChange","customElement","setCustomElement","async","defaultViewChangeHandler","event","newViewState","mainWindow","remove","on","type","BusEventType","VIEW_PRE_CHANGE","handler","VIEW_CHANGE"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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mCC,WACnCA,WAASC,iBACTA,iBAAeC,oBACfA,oBAAkBC,QAClBA,QAAMC,QACNA,QAAMC,WACNA,WAASC,YACTA,YAAUC,eACVA,eAAaC,QACbA,QAAMC,YACNA,YAAUC,UACVA,UAAQC,OACRA,SACE7B;EAEJ,OAAOoG,eAAeC,oBAAoBjE;EAE1C,MAAM+B,yBAAyBC,YAC7BkC,MAAOjC;IAKL,SAASkC,yBAAyBC;MAChC,IAAIJ,eAAe;QACjB,IAAII,MAAMC,aAAaC,YAAY;UAEjCN,cAAc/C,UAAUsD,OAAO;AACjC,eAAO;UAELP,cAAc/C,UAAUC,IAAI;AAC9B;AACF;AACF;IAEA,IAAI6C,iBAAiB;MACnB9B,SAASuC,GAAG;QACVC,MAAMC,aAAaC;QACnBC,SAASb;;AAEb;IAEA9B,SAASuC,GAAG;MACVC,MAAMC,aAAaG;MACnBD,SAASd,gBAAgBK;;IAG3B,OAAOtG,iBAAiBoE;KAE1B,EAAC8B,iBAAiBD,cAAcjG,gBAAgBmG;EAGlD,OACE3G,MAAA2D,cAAA,OAAA;IAAK6C,WAAWA;IAAWJ,IAAIA;IAAIZ,KAAKoB;KACrCD,iBACC3G,oBAACM;IAECU,SAASA;IACTC,mBAAmBA;IACnBC,YAAYA;IACZC,wCACEA;IAEFC,OAAOA;IACPC,gCAAgCA;IAChCC,mBAAmBA;IACnBC,WAAWA;IACXC,qCACEA;IAEFC,WAAWA;IACXC,iBAAiBA;IACjBC,oBAAoBA;IACpBC,QAAQA;IACRC,QAAQA;IACRC,WAAWA;IACXC,YAAYA;IACZC,eAAeA;IACfC,QAAQA;IACRC,YAAYA;IACZC,UAAUA;IAEVzB,SAASA;IACTC,oBAAoBA;IACpBC,aAAaA;IACbJ,gBAAgBkE;IAChBjE,eAAeA;IACfI,2BAA2BA;IAC3BC,yBAAyBA;IACzBC,SAAS4F;IACTvE,OAAOA;;AAKjB;;"}
1
+ {"version":3,"file":"aiChatEntry.js","sources":["../../../../src/react/ChatContainer.tsx","../../../../src/react/ChatCustomElement.tsx"],"sourcesContent":["/*\n * Copyright IBM Corp. 2025\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 { createComponent } from \"@lit/react\";\nimport { css, LitElement, PropertyValues } from \"lit\";\nimport React, {\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { createPortal } from \"react-dom\";\n\nimport App from \"../chat/ChatAppEntry\";\nimport { carbonElement } from \"@carbon/ai-chat-components/es/globals/decorators/index.js\";\nimport { ChatContainerProps } from \"../types/component/ChatContainer\";\nimport { ChatInstance } from \"../types/instance/ChatInstance\";\nimport { PublicConfig } from \"../types/config/PublicConfig\";\nimport { isBrowser } from \"../chat/utils/browserUtils\";\n\n/**\n * This component creates a custom element protected by a shadow DOM to render the React application into. It creates\n * slotted elements for user_defined responses and for writable elements.\n *\n * The corresponding slots are defined within the React application and are rendered in place.\n */\n\n/**\n * Create a web component to host the React application. We do this so we can provide custom elements and user_defined responses as\n * slotted content so they maintain their own styling in a safe way.\n */\n@carbonElement(\"cds-aichat-react\")\nclass ChatContainerReact extends LitElement {\n static styles = css`\n :host {\n width: 100%;\n height: 100%;\n }\n `;\n\n /**\n * Dispatch a custom event when the shadow DOM is ready\n * This ensures React can safely access shadowRoot\n */\n firstUpdated(changedProperties: PropertyValues) {\n super.firstUpdated(changedProperties);\n this.dispatchEvent(new CustomEvent(\"shadow-ready\", { bubbles: true }));\n }\n}\n\n// Wrap the custom element as a React component\nconst ReactChatContainer = React.memo(\n createComponent({\n tagName: \"cds-aichat-react\",\n elementClass: ChatContainerReact,\n react: React,\n }),\n);\n\n/**\n * The ChatContainer controls rendering the React application into the shadow DOM of the cds-aichat-react web component.\n * It also injects the writeable element and user_defined response slots into said web component.\n *\n * @category React\n */\nfunction ChatContainer(props: ChatContainerProps) {\n const {\n onBeforeRender,\n onAfterRender,\n strings,\n serviceDeskFactory,\n serviceDesk,\n renderUserDefinedResponse,\n renderWriteableElements,\n element,\n // Flattened PublicConfig properties\n onError,\n openChatByDefault,\n disclaimer,\n disableCustomElementMobileEnhancements,\n debug,\n exposeServiceManagerForTesting,\n injectCarbonTheme,\n aiEnabled,\n shouldTakeFocusIfOpensAutomatically,\n namespace,\n enableFocusTrap,\n shouldSanitizeHTML,\n header,\n layout,\n messaging,\n isReadonly,\n assistantName,\n locale,\n homescreen,\n launcher,\n input,\n } = props;\n // Reconstruct PublicConfig from flattened props\n const config = useMemo(\n (): PublicConfig => ({\n onError,\n openChatByDefault,\n disclaimer,\n disableCustomElementMobileEnhancements,\n debug,\n exposeServiceManagerForTesting,\n injectCarbonTheme,\n aiEnabled,\n shouldTakeFocusIfOpensAutomatically,\n namespace,\n enableFocusTrap,\n shouldSanitizeHTML,\n header,\n layout,\n messaging,\n isReadonly,\n assistantName,\n locale,\n homescreen,\n launcher,\n input,\n }),\n [\n onError,\n openChatByDefault,\n disclaimer,\n disableCustomElementMobileEnhancements,\n debug,\n exposeServiceManagerForTesting,\n injectCarbonTheme,\n aiEnabled,\n shouldTakeFocusIfOpensAutomatically,\n namespace,\n enableFocusTrap,\n shouldSanitizeHTML,\n header,\n layout,\n messaging,\n isReadonly,\n assistantName,\n locale,\n homescreen,\n launcher,\n input,\n ],\n );\n const wrapperRef = useRef(null); // Ref for the React wrapper component\n const [wrapper, setWrapper] = useState(null);\n const [container, setContainer] = useState<HTMLElement | null>(null); // Actual element we render the React Portal to in the Shadowroot.\n\n const [writeableElementSlots, setWriteableElementSlots] = useState<\n HTMLElement[]\n >([]);\n const [currentInstance, setCurrentInstance] = useState<ChatInstance>(null);\n\n /**\n * Setup the DOM nodes of both the web component to be able to inject slotted content into it, and the element inside the\n * shadow DOM we will inject our React application into.\n */\n useEffect(() => {\n if (!wrapperRef.current) {\n return null; // Early return when there's nothing to set up because the element isn't ready.\n }\n\n let eventListenerAdded = false;\n\n const wrapperElement = wrapperRef.current as unknown as ChatContainerReact;\n\n // We need to check if the element in the shadow DOM we are render the React application to exists.\n // If it doesn't, we need to create and append it.\n\n const handleShadowReady = () => {\n // Now we know shadowRoot is definitely available\n let reactElement = wrapperElement.shadowRoot.querySelector(\n \".cds-aichat--react-app\",\n ) as HTMLElement;\n\n if (!reactElement) {\n reactElement = document.createElement(\"div\");\n reactElement.classList.add(\"cds-aichat--react-app\");\n wrapperElement.shadowRoot.appendChild(reactElement);\n }\n\n if (wrapperElement !== wrapper) {\n setWrapper(wrapperElement);\n }\n if (reactElement !== container) {\n setContainer(reactElement);\n }\n };\n\n if (wrapperElement.shadowRoot) {\n // Already ready\n handleShadowReady();\n } else {\n // Wait for ready event\n eventListenerAdded = true;\n wrapperElement.addEventListener(\"shadow-ready\", handleShadowReady, {\n once: true,\n });\n }\n\n return () => {\n if (eventListenerAdded) {\n wrapperElement.removeEventListener(\"shadow-ready\", handleShadowReady);\n }\n };\n }, [container, wrapper, currentInstance]);\n\n /**\n * Here we write the slotted elements into the wrapper so they are passed into the application to be rendered in their slot.\n */\n useEffect(() => {\n if (wrapper) {\n const combinedNodes: HTMLElement[] = [...writeableElementSlots];\n const currentNodes: HTMLElement[] = Array.from(\n wrapper.childNodes,\n ) as HTMLElement[];\n\n // Append new nodes that aren't already in the container\n combinedNodes.forEach((node) => {\n if (!currentNodes.includes(node)) {\n wrapper.appendChild(node);\n }\n });\n }\n }, [writeableElementSlots, wrapper]);\n\n const onBeforeRenderOverride = useCallback(\n (instance: ChatInstance) => {\n if (instance) {\n const addWriteableElementSlots = () => {\n const slots: HTMLElement[] = Object.entries(\n instance.writeableElements,\n ).map((writeableElement) => {\n const [key, element] = writeableElement;\n element.setAttribute(\"slot\", key); // Assign slot attributes dynamically\n return element;\n });\n setWriteableElementSlots(slots);\n };\n\n addWriteableElementSlots();\n onBeforeRender?.(instance);\n }\n },\n [onBeforeRender],\n );\n\n // If we are in SSR mode, just short circuit here. This prevents all of our window.* and document.* stuff from trying\n // to run and erroring out.\n if (!isBrowser()) {\n return null;\n }\n\n return (\n <>\n <ReactChatContainer ref={wrapperRef} />\n {container &&\n createPortal(\n <App\n key=\"stable-chat-instance\" // Prevent remounting on config changes\n config={config}\n strings={strings}\n serviceDeskFactory={serviceDeskFactory}\n serviceDesk={serviceDesk}\n renderUserDefinedResponse={renderUserDefinedResponse}\n renderWriteableElements={renderWriteableElements}\n onBeforeRender={onBeforeRenderOverride}\n onAfterRender={onAfterRender}\n container={container}\n setParentInstance={setCurrentInstance}\n element={element}\n chatWrapper={wrapper}\n />,\n container, // Render AppContainer into the shadowRoot\n )}\n </>\n );\n}\n\nexport { ChatContainer, ChatContainerProps };\n","/*\n * Copyright IBM Corp. 2025\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 React, { useCallback, useState } from \"react\";\n\nimport { ChatInstance } from \"../types/instance/ChatInstance\";\nimport {\n BusEventType,\n BusEventViewChange,\n BusEventViewPreChange,\n} from \"../types/events/eventBusTypes\";\nimport { ChatContainer, ChatContainerProps } from \"./ChatContainer\";\nimport { isBrowser } from \"../chat/utils/browserUtils\";\n\n/**\n * Properties for the ChatContainer React component. This interface extends\n * {@link ChatContainerProps} and {@link PublicConfig} with additional component-specific props, flattening all\n * config properties as top-level props for better TypeScript IntelliSense.\n *\n * @category React\n */\ninterface ChatCustomElementProps extends ChatContainerProps {\n /**\n * A CSS class name that will be added to the custom element. This class must define the size of the\n * your custom element (width and height or using logical inline-size/block-size).\n *\n * You can make use of onViewPreChange and/or onViewChange to mutate this className value so have open/close animations.\n *\n * By default, the chat will just set the chat shell to a 0x0 size and mark everything but the launcher (is you are using it)\n * as display: none; if the chat is set to closed.\n */\n className: string;\n\n /**\n * An optional id that will be added to the custom element.\n */\n id?: string;\n\n /**\n * Called before a view change (chat opening/closing). The chat will hide the chat shell inside your custom element\n * to prevent invisible keyboard stops when the view change is *complete*.\n *\n * Use this callback to update your className value *before* the view change happens if you want to add any open/close\n * animations to your custom element before the chat shell inner contents are hidden. It is async and so you can\n * tie it to native the AnimationEvent and only return when your animations have completed.\n *\n * A common pattern is to use this for when the chat is closing and to use onViewChange for when the chat opens.\n *\n * Note that this function can only be provided before Carbon AI Chat is loaded as it is registered before the\n * chat renders. After Carbon AI Chat is loaded, the callback will not be updated.\n */\n onViewPreChange?: (\n event: BusEventViewPreChange,\n instance: ChatInstance,\n ) => Promise<void> | void;\n\n /**\n * Called when the chat view change is complete. If no callback is provided here, the default behavior will be to set\n * the chat shell to 0x0 size and set all inner contents aside from the launcher, if you are using it, to display: none.\n * The inner contents of the chat shell (aside from the launcher if you are using it) are always set to display: none\n * regardless of what is configured with this callback to prevent invisible tab stops and screen reader issues.\n *\n * Use this callback to update your className value when the chat has finished being opened or closed.\n *\n * You can provide a different callback here if you want custom animation behavior when the chat is opened or closed.\n * The animation behavior defined here will run in concert with the chat inside your custom container being hidden.\n *\n * If you want to run animations before the inner contents of the chat shell is shrunk and the inner contents are hidden,\n * make use of onViewPreChange.\n *\n * A common pattern is to use this for when the chat is opening and to use onViewPreChange for when the chat closes.\n *\n * Note that this function can only be provided before Carbon AI Chat is loaded as it is registered before the\n * chat renders. After Carbon AI Chat is loaded, the callback will not be updated.\n */\n onViewChange?: (event: BusEventViewChange, instance: ChatInstance) => void;\n}\n\nconst customElementStylesheet =\n isBrowser() && typeof CSSStyleSheet !== \"undefined\"\n ? new CSSStyleSheet()\n : null;\n\nconst hideStyles = `\n .cds-aichat--hidden {\n width: 0 !important;\n height: 0 !important;\n min-width: 0 !important;\n min-height: 0 !important;\n max-width: 0 !important;\n max-height: 0 !important;\n inline-size: 0 !important;\n block-size: 0 !important;\n min-inline-size: 0 !important;\n min-block-size: 0 !important;\n max-inline-size: 0 !important;\n max-block-size: 0 !important;\n overflow: hidden !important;\n }\n`;\n\n// Inject styles using adopted stylesheets when available, fallback to style element\nif (\n isBrowser() &&\n !document.getElementById(\"cds-aichat-custom-element-styles\")\n) {\n if (customElementStylesheet && \"replaceSync\" in customElementStylesheet) {\n customElementStylesheet.replaceSync(hideStyles);\n document.adoptedStyleSheets = [\n ...document.adoptedStyleSheets,\n customElementStylesheet,\n ];\n } else {\n // Fallback for when adoptedStyleSheets are not supported\n const style = document.createElement(\"style\");\n style.id = \"cds-aichat-custom-element-styles\";\n style.textContent = hideStyles;\n document.head.appendChild(style);\n }\n}\n\n/**\n * This is the React component for people injecting a Carbon AI Chat with a custom element.\n *\n * It provides said element any class or id defined on itself for styling. It then calls ChatContainer with the custom\n * element passed in as a property to be used instead of generating an element with the default properties for a\n * floating chat.\n *\n * @category React\n */\nfunction ChatCustomElement(props: ChatCustomElementProps) {\n const {\n strings,\n serviceDeskFactory,\n serviceDesk,\n onBeforeRender,\n onAfterRender,\n renderUserDefinedResponse,\n renderWriteableElements,\n className,\n id,\n onViewChange,\n onViewPreChange,\n // Flattened PublicConfig properties\n onError,\n openChatByDefault,\n disclaimer,\n disableCustomElementMobileEnhancements,\n debug,\n exposeServiceManagerForTesting,\n injectCarbonTheme,\n aiEnabled,\n shouldTakeFocusIfOpensAutomatically,\n namespace,\n enableFocusTrap,\n shouldSanitizeHTML,\n header,\n layout,\n messaging,\n isReadonly,\n assistantName,\n locale,\n homescreen,\n launcher,\n input,\n } = props;\n\n const [customElement, setCustomElement] = useState<HTMLDivElement>();\n\n const onBeforeRenderOverride = useCallback(\n async (instance: ChatInstance) => {\n /**\n * A default handler for the \"view:change\" event. This will be used to show or hide the Carbon AI Chat main window\n * by adding/removing a CSS class that sets the element size to 0x0 when hidden.\n */\n function defaultViewChangeHandler(event: BusEventViewChange) {\n if (customElement) {\n if (event.newViewState.mainWindow) {\n // Show: remove the hidden class, let the provided className handle sizing\n customElement.classList.remove(\"cds-aichat--hidden\");\n } else {\n // Hide: add the hidden class to set size to 0x0\n customElement.classList.add(\"cds-aichat--hidden\");\n }\n }\n }\n\n if (onViewPreChange) {\n instance.on({\n type: BusEventType.VIEW_PRE_CHANGE,\n handler: onViewPreChange,\n });\n }\n\n instance.on({\n type: BusEventType.VIEW_CHANGE,\n handler: onViewChange || defaultViewChangeHandler,\n });\n\n return onBeforeRender?.(instance);\n },\n [onViewPreChange, onViewChange, onBeforeRender, customElement],\n );\n\n return (\n <div className={className} id={id} ref={setCustomElement}>\n {customElement && (\n <ChatContainer\n // Flattened PublicConfig properties\n onError={onError}\n openChatByDefault={openChatByDefault}\n disclaimer={disclaimer}\n disableCustomElementMobileEnhancements={\n disableCustomElementMobileEnhancements\n }\n debug={debug}\n exposeServiceManagerForTesting={exposeServiceManagerForTesting}\n injectCarbonTheme={injectCarbonTheme}\n aiEnabled={aiEnabled}\n shouldTakeFocusIfOpensAutomatically={\n shouldTakeFocusIfOpensAutomatically\n }\n namespace={namespace}\n enableFocusTrap={enableFocusTrap}\n shouldSanitizeHTML={shouldSanitizeHTML}\n header={header}\n layout={layout}\n messaging={messaging}\n isReadonly={isReadonly}\n assistantName={assistantName}\n locale={locale}\n homescreen={homescreen}\n launcher={launcher}\n // Other ChatContainer props\n strings={strings}\n serviceDeskFactory={serviceDeskFactory}\n serviceDesk={serviceDesk}\n onBeforeRender={onBeforeRenderOverride}\n onAfterRender={onAfterRender}\n renderUserDefinedResponse={renderUserDefinedResponse}\n renderWriteableElements={renderWriteableElements}\n element={customElement}\n input={input}\n />\n )}\n </div>\n );\n}\n\nexport { ChatCustomElement, ChatCustomElementProps };\n"],"names":["ChatContainerReact","LitElement","firstUpdated","changedProperties","super","this","dispatchEvent","CustomEvent","bubbles","styles","css","__decorate","carbonElement","ReactChatContainer","React","memo","createComponent","tagName","elementClass","react","ChatContainer","props","onBeforeRender","onAfterRender","strings","serviceDeskFactory","serviceDesk","renderUserDefinedResponse","renderWriteableElements","element","onError","openChatByDefault","disclaimer","disableCustomElementMobileEnhancements","debug","exposeServiceManagerForTesting","injectCarbonTheme","aiEnabled","shouldTakeFocusIfOpensAutomatically","namespace","enableFocusTrap","shouldSanitizeHTML","header","layout","messaging","isReadonly","assistantName","locale","homescreen","launcher","input","config","useMemo","wrapperRef","useRef","wrapper","setWrapper","useState","container","setContainer","writeableElementSlots","setWriteableElementSlots","currentInstance","setCurrentInstance","useEffect","current","eventListenerAdded","wrapperElement","handleShadowReady","reactElement","shadowRoot","querySelector","document","createElement","classList","add","appendChild","addEventListener","once","removeEventListener","combinedNodes","currentNodes","Array","from","childNodes","forEach","node","includes","onBeforeRenderOverride","useCallback","instance","addWriteableElementSlots","slots","Object","entries","writeableElements","map","writeableElement","key","setAttribute","isBrowser","Fragment","ref","createPortal","App","setParentInstance","chatWrapper","customElementStylesheet","CSSStyleSheet","hideStyles","getElementById","replaceSync","adoptedStyleSheets","style","id","textContent","head","ChatCustomElement","className","onViewChange","onViewPreChange","customElement","setCustomElement","async","defaultViewChangeHandler","event","newViewState","mainWindow","remove","on","type","BusEventType","VIEW_PRE_CHANGE","handler","VIEW_CHANGE"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCA,IAAMA,qBAAN,MAAMA,2BAA2BC;EAY/B,YAAAC,CAAaC;IACXC,MAAMF,aAAaC;IACnBE,KAAKC,cAAc,IAAIC,YAAY,gBAAgB;MAAEC,SAAS;;AAChE;;;AAdOR,mBAAAS,SAASC,GAAG;;;;;;;AADfV,qBAAkBW,WAAA,EADvBC,cAAc,uBACTZ;;AAmBN,MAAMa,qBAAqBC,MAAMC,KAC/BC,gBAAgB;EACdC,SAAS;EACTC,cAAclB;EACdmB,OAAOL;;;AAUX,SAASM,cAAcC;EACrB,OAAMC,gBACUC,eACDC,SACNC,oBACWC,aACPC,2BACcC,yBACFC,SAChBC,SAEAC,mBACUC,YACPC,wCAC4BC,OACjCC,gCACyBC,mBACbC,WACRC,qCAC0BC,WAC1BC,iBACM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