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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (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 +1803 -4918
  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 +1803 -4918
  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
@@ -12,7 +12,7 @@ import { A as App } from "../../chat.ChatAppEntry.js";
12
12
 
13
13
  import { carbonElement } from "@carbon/ai-chat-components/es/globals/decorators/index.js";
14
14
 
15
- import { B as BusEventType } from "../../chat.PageObjectId.js";
15
+ import { B as BusEventType } from "../../chat.languages.js";
16
16
 
17
17
  import "lodash-es/isEqual.js";
18
18
 
@@ -28,10 +28,6 @@ import "lodash-es/mergeWith.js";
28
28
 
29
29
  import "react-intl";
30
30
 
31
- import "dayjs/locale/en.js";
32
-
33
- import "intl-messageformat";
34
-
35
31
  import "react-dom";
36
32
 
37
33
  import "classnames";
@@ -58,43 +54,7 @@ import "@carbon/web-components/es/components/button/button.js";
58
54
 
59
55
  import "@carbon/icons/es/user--avatar/32.js";
60
56
 
61
- import "markdown-it";
62
-
63
- import "dompurify";
64
-
65
- import "lit/directives/repeat.js";
66
-
67
- import "lit/directives/unsafe-html.js";
68
-
69
- import "lit/directive.js";
70
-
71
- import "@carbon/web-components/es/components/list/index.js";
72
-
73
- import "@carbon/web-components/es/components/data-table/index.js";
74
-
75
- import "@carbon/web-components/es/components/checkbox/index.js";
76
-
77
- import "@carbon/web-components/es/components/button/index.js";
78
-
79
- import "@carbon/web-components/es/components/layer/index.js";
80
-
81
- import "@carbon/web-components/es/globals/internal/icon-loader.js";
82
-
83
- import "@carbon/icons/es/download/16.js";
84
-
85
- import "lit-html/directives/repeat.js";
86
-
87
- import "@carbon/web-components/es/components/pagination/index.js";
88
-
89
- import "@carbon/web-components/es/components/select/index.js";
90
-
91
- import "@carbon/web-components/es/components/data-table/table-skeleton.js";
92
-
93
- import "@carbon/web-components/es/components/notification/actionable-notification.js";
94
-
95
- import "@carbon/web-components/es/components/notification/defs.js";
96
-
97
- import "@carbon/web-components/es/components/notification/actionable-notification-button.js";
57
+ import "@carbon/ai-chat-components/es/react/markdown.js";
98
58
 
99
59
  import "@carbon/icons/es/chat-bot/32.js";
100
60
 
@@ -102,6 +62,12 @@ import "@carbon/icons/es/checkmark--filled/16.js";
102
62
 
103
63
  import "@carbon/icons/es/headset/32.js";
104
64
 
65
+ import "@carbon/icons/es/chevron--down/16.js";
66
+
67
+ import "@carbon/ai-chat-components/es/react/reasoning-steps.js";
68
+
69
+ import "@carbon/ai-chat-components/es/react/reasoning-step.js";
70
+
105
71
  import "@carbon/web-components/es/components/loading/loading-icon.js";
106
72
 
107
73
  import "@carbon/web-components/es/components/loading/loading.js";
@@ -110,21 +76,11 @@ import "@carbon/icons/es/error--filled/16.js";
110
76
 
111
77
  import "@carbon/icons/es/attachment/16.js";
112
78
 
113
- import "@carbon/web-components/es/components/textarea/index.js";
114
-
115
- import "@carbon/web-components/es/components/icon-button/index.js";
116
-
117
- import "@carbon/icons/es/thumbs-down/16.js";
118
-
119
- import "@carbon/icons/es/thumbs-down--filled/16.js";
120
-
121
- import "@carbon/icons/es/thumbs-up/16.js";
122
-
123
- import "@carbon/icons/es/thumbs-up--filled/16.js";
79
+ import "@carbon/ai-chat-components/es/react/feedback-buttons.js";
124
80
 
125
- import "@carbon/web-components/es/components/tag/index.js";
81
+ import "@carbon/ai-chat-components/es/react/feedback.js";
126
82
 
127
- import "@carbon/web-components/es/components/chat-button/index.js";
83
+ import "@carbon/ai-chat-components/es/globals/settings.js";
128
84
 
129
85
  import "@carbon/icons/es/checkmark/16.js";
130
86
 
@@ -146,12 +102,14 @@ import "@carbon/web-components/es/components/skeleton-text/skeleton-text.js";
146
102
 
147
103
  import "@carbon/web-components/es/components/skeleton-placeholder/skeleton-placeholder.js";
148
104
 
149
- import "@carbon/icons/es/chevron--down/16.js";
150
-
151
105
  import "@carbon/icons/es/chevron--up/16.js";
152
106
 
153
107
  import "@carbon/icons/es/touch--interaction/16.js";
154
108
 
109
+ import "@carbon/ai-chat-components/es/react/chat-button.js";
110
+
111
+ import "@carbon/ai-chat-components/es/react/button.js";
112
+
155
113
  import "@carbon/icons/es/send/16.js";
156
114
 
157
115
  import "@carbon/icons/es/arrow--right/16.js";
@@ -180,18 +138,18 @@ import "@carbon/web-components/es/components/date-picker/date-picker-input.js";
180
138
 
181
139
  import "@carbon/web-components/es/components/date-picker/defs.js";
182
140
 
183
- import "@carbon/web-components/es/components/chat-button/chat-button.js";
184
-
185
141
  import "@carbon/web-components/es/components/dropdown/dropdown.js";
186
142
 
187
143
  import "@carbon/web-components/es/components/dropdown/dropdown-item.js";
188
144
 
189
- import "@carbon/web-components/es/components/inline-loading/index.js";
145
+ import "@carbon/ai-chat-components/es/react/chain-of-thought.js";
190
146
 
191
147
  import "@carbon/ai-chat-components/es/react/processing.js";
192
148
 
193
149
  import "@carbon/icons/es/restart/16.js";
194
150
 
151
+ import "@carbon/web-components/es/components/chat-button/chat-button.js";
152
+
195
153
  import "@carbon/icons/es/home/16.js";
196
154
 
197
155
  import "@carbon/icons/es/close--large/16.js";
@@ -222,17 +180,23 @@ import "@carbon/web-components/es/components/file-uploader/defs.js";
222
180
 
223
181
  import "@carbon/web-components/es/components/file-uploader/file-uploader-item.js";
224
182
 
183
+ import "@carbon/web-components/es/components/icon-button/index.js";
184
+
185
+ import "@carbon/web-components/es/globals/internal/icon-loader.js";
186
+
225
187
  import "@carbon/icons/es/stop--filled/16.js";
226
188
 
227
189
  import "@carbon/web-components/es/components/layer/layer.js";
228
190
 
229
- import "@carbon/icons/es/close/16.js";
230
-
231
191
  import "@carbon/icons/es/ai-launch/24.js";
232
192
 
233
193
  import "@carbon/icons/es/chat--launch/24.js";
234
194
 
235
- import "@carbon/web-components/es/components/tag/tag.js";
195
+ import "@carbon/icons/es/close/16.js";
196
+
197
+ import "@carbon/ai-chat-components/es/components/chain-of-thought/src/types.js";
198
+
199
+ import "dayjs/locale/en.js";
236
200
 
237
201
  let ChatContainerInternal = class ChatContainerInternal extends LitElement {
238
202
  firstUpdated() {
@@ -257,7 +221,7 @@ let ChatContainerInternal = class ChatContainerInternal extends LitElement {
257
221
  serviceDesk: this.serviceDesk,
258
222
  onBeforeRender: this.onBeforeRender,
259
223
  onAfterRender: this.onAfterRender,
260
- container: container,
224
+ container,
261
225
  element: this.element
262
226
  }));
263
227
  }
@@ -311,7 +275,7 @@ let ChatContainer = class ChatContainer extends LitElement {
311
275
  this._userDefinedSlotNames = [];
312
276
  this._writeableElementSlots = [];
313
277
  this.userDefinedHandler = event => {
314
- const {slot: slot} = event.data;
278
+ const {slot} = event.data;
315
279
  if (!this._userDefinedSlotNames.includes(slot)) {
316
280
  this._userDefinedSlotNames = [ ...this._userDefinedSlotNames, slot ];
317
281
  }
@@ -574,7 +538,7 @@ __decorate([ state() ], ChatContainer.prototype, "_instance", void 0);
574
538
 
575
539
  ChatContainer = __decorate([ carbonElement("cds-aichat-container") ], ChatContainer);
576
540
 
577
- var ChatContainer$1 = ChatContainer;
541
+ var ChatContainer_default = ChatContainer;
578
542
 
579
- export { ChatContainer$1 as default };
543
+ export { ChatContainer_default as default };
580
544
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../../../src/web-components/cds-aichat-container/cds-aichat-internal.tsx","../../../../../../src/web-components/cds-aichat-container/index.ts"],"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\n/**\n * This component is mostly a pass-through. Its takes any properties passed into the ChatContainer\n * custom element and then renders the React Carbon AI Chat application while passing in properties.\n */\n\nimport { LitElement, PropertyValues } from \"lit\";\nimport { property } from \"lit/decorators.js\";\nimport React from \"react\";\nimport { createRoot, Root } from \"react-dom/client\";\n\nimport App from \"../../chat/ChatAppEntry\";\nimport { carbonElement } from \"@carbon/ai-chat-components/es/globals/decorators/index.js\";\nimport { PublicConfig } from \"../../types/config/PublicConfig\";\nimport { ChatInstance } from \"../../types/instance/ChatInstance\";\nimport { DeepPartial } from \"../../types/utilities/DeepPartial\";\nimport { LanguagePack } from \"../../types/config/PublicConfig\";\nimport type {\n ServiceDesk,\n ServiceDeskFactoryParameters,\n ServiceDeskPublicConfig,\n} from \"../../types/config/ServiceDeskConfig\";\n\n@carbonElement(\"cds-aichat-internal\")\nclass ChatContainerInternal extends LitElement {\n /**\n * The config to use to load Carbon AI Chat. Note that the \"onLoad\" property is overridden by this component. If you\n * need to perform any actions after Carbon AI Chat been loaded, use the \"onBeforeRender\" or \"onAfterRender\" props.\n */\n @property({ type: Object })\n config: PublicConfig;\n\n /** Optional partial language pack overrides */\n @property({ type: Object })\n strings?: DeepPartial<LanguagePack>;\n\n /** A factory for the {@link ServiceDesk} integration. */\n @property({ attribute: false })\n serviceDeskFactory?: (\n parameters: ServiceDeskFactoryParameters,\n ) => Promise<ServiceDesk>;\n\n /** Public configuration for the service desk integration. */\n @property({ type: Object })\n serviceDesk?: ServiceDeskPublicConfig;\n\n /**\n * The optional HTML element to mount the chat to.\n */\n @property({ type: HTMLElement })\n element?: HTMLElement;\n\n /**\n * This function is called before the render function of Carbon AI Chat is called. This function can return a Promise\n * which will cause Carbon AI Chat to wait for it before rendering.\n */\n @property()\n onBeforeRender: (instance: ChatInstance) => Promise<void> | void;\n\n /**\n * This function is called after the render function of Carbon AI Chat is called. This function can return a Promise\n * which will cause Carbon AI Chat to wait for it before rendering.\n */\n @property()\n onAfterRender: (instance: ChatInstance) => Promise<void> | void;\n\n firstUpdated() {\n // Render the React component with any updated properties if necessary\n const style = document.createElement(\"style\");\n style.textContent = `\n :host {\n display: block;\n width: 100%;\n height: 100%;\n box-sizing: border-box;\n ${this.element ? \"\" : \"z-index: var(--cds-aichat-z-index);\"}\n }\n `;\n this.appendChild(style);\n if (this.config) {\n this.renderReactApp();\n }\n }\n\n updated(changedProperties: PropertyValues) {\n // Re-render React app when config or other properties change\n if (\n this.config &&\n (changedProperties.has(\"config\") ||\n changedProperties.has(\"strings\") ||\n changedProperties.has(\"serviceDeskFactory\") ||\n changedProperties.has(\"serviceDesk\") ||\n changedProperties.has(\"onBeforeRender\") ||\n changedProperties.has(\"onAfterRender\") ||\n changedProperties.has(\"element\"))\n ) {\n this.renderReactApp();\n }\n }\n\n /**\n * Track if a previous React 18+ root was already created so we don't create a memory leak on re-renders.\n */\n root: Root;\n\n /**\n * Cache the container we hand to React so we can reuse it between renders.\n */\n reactContainer?: HTMLDivElement;\n\n async renderReactApp() {\n const container = this.ensureReactRoot();\n\n this.root.render(\n <App\n config={this.config}\n strings={this.strings}\n serviceDeskFactory={this.serviceDeskFactory}\n serviceDesk={this.serviceDesk}\n onBeforeRender={this.onBeforeRender}\n onAfterRender={this.onAfterRender}\n container={container}\n element={this.element}\n />,\n );\n }\n\n private ensureReactRoot(): HTMLDivElement {\n if (!this.reactContainer) {\n const container = document.createElement(\"div\");\n container.classList.add(\"cds-aichat--react-app\");\n this.shadowRoot.appendChild(container);\n this.reactContainer = container;\n }\n\n // Make sure we only create one root and reuse it for prop updates.\n if (!this.root) {\n this.root = createRoot(this.reactContainer);\n }\n\n return this.reactContainer;\n }\n\n disconnectedCallback(): void {\n this.root?.unmount();\n super.disconnectedCallback();\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"cds-aichat-internal\": ChatContainerInternal;\n }\n}\n\nexport default ChatContainerInternal;\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\n/**\n * This is the exposed web component for a basic floating chat.\n */\n\nimport \"./cds-aichat-internal\";\n\nimport { html, LitElement } from \"lit\";\nimport { property, state } from \"lit/decorators.js\";\n\nimport { carbonElement } from \"@carbon/ai-chat-components/es/globals/decorators/index.js\";\nimport {\n PublicConfig,\n OnErrorData,\n DisclaimerPublicConfig,\n CarbonTheme,\n HeaderConfig,\n LayoutConfig,\n PublicConfigMessaging,\n InputConfig,\n} from \"../../types/config/PublicConfig\";\nimport { DeepPartial } from \"../../types/utilities/DeepPartial\";\nimport { LanguagePack } from \"../../types/config/PublicConfig\";\nimport { HomeScreenConfig } from \"../../types/config/HomeScreenConfig\";\nimport { LauncherConfig } from \"../../types/config/LauncherConfig\";\nimport type {\n ServiceDesk,\n ServiceDeskFactoryParameters,\n ServiceDeskPublicConfig,\n} from \"../../types/config/ServiceDeskConfig\";\nimport { ChatInstance } from \"../../types/instance/ChatInstance\";\nimport {\n BusEventChunkUserDefinedResponse,\n BusEventType,\n BusEventUserDefinedResponse,\n} from \"../../types/events/eventBusTypes\";\n\n/**\n * The cds-aichat-container managing creating slotted elements for user_defined responses and writable elements.\n * It then passes that slotted content into cds-aichat-internal. That component will boot up the full chat application\n * and pass the slotted elements into their slots.\n */\n@carbonElement(\"cds-aichat-container\")\nclass ChatContainer extends LitElement {\n @property({ attribute: false, type: Object })\n config?: PublicConfig;\n\n // Flattened PublicConfig properties\n @property({ attribute: false })\n onError?: (data: OnErrorData) => void;\n\n @property({ type: Boolean, attribute: \"open-chat-by-default\" })\n openChatByDefault?: boolean;\n\n @property({ type: Object })\n disclaimer?: DisclaimerPublicConfig;\n\n @property({\n type: Boolean,\n attribute: \"disable-custom-element-mobile-enhancements\",\n })\n disableCustomElementMobileEnhancements?: boolean;\n\n @property({ type: Boolean })\n debug?: boolean;\n\n @property({ type: Boolean, attribute: \"expose-service-manager-for-testing\" })\n exposeServiceManagerForTesting?: boolean;\n\n @property({ type: String, attribute: \"inject-carbon-theme\" })\n injectCarbonTheme?: CarbonTheme;\n\n @property({\n attribute: \"ai-enabled\",\n // Custom converter so HTML authors can write ai-enabled=\"false\" | \"0\" | \"off\" | \"no\"\n // and absence keeps it undefined (so defaults apply further down the stack).\n converter: {\n fromAttribute: (value: string | null) => {\n if (value === null) {\n return undefined; // attribute absent -> leave undefined to use defaults\n }\n const v = String(value).trim().toLowerCase();\n const falsey = v === \"false\" || v === \"0\" || v === \"off\" || v === \"no\";\n // Any presence that's not an explicit falsey string is treated as true\n return !falsey;\n },\n },\n })\n aiEnabled?: boolean;\n\n // Optional explicit opt-out attribute. If present, it wins over ai-enabled.\n @property({ type: Boolean, attribute: \"ai-disabled\" })\n aiDisabled?: boolean;\n\n @property({\n type: Boolean,\n attribute: \"should-take-focus-if-opens-automatically\",\n })\n shouldTakeFocusIfOpensAutomatically?: boolean;\n\n @property({ type: String })\n namespace?: string;\n\n @state()\n private enableFocusTrap?: boolean;\n\n @property({ type: Boolean, attribute: \"should-sanitize-html\" })\n shouldSanitizeHTML?: boolean;\n\n @property({ type: Object })\n header?: HeaderConfig;\n\n @property({ type: Object })\n input?: InputConfig;\n\n @property({ type: Object })\n layout?: LayoutConfig;\n\n @property({ type: Object })\n messaging?: PublicConfigMessaging;\n\n @property({ type: Boolean, attribute: \"is-readonly\" })\n isReadonly?: boolean;\n\n @property({ type: String, attribute: \"assistant-name\" })\n assistantName?: string;\n\n @property({ type: String })\n locale?: string;\n\n @property({ type: Object })\n homescreen?: HomeScreenConfig;\n\n @property({ type: Object })\n launcher?: LauncherConfig;\n\n /** Optional partial language pack overrides */\n @property({ type: Object })\n strings?: DeepPartial<LanguagePack>;\n\n /**\n * A factory to create a {@link ServiceDesk} integration instance.\n */\n @property({ attribute: false })\n serviceDeskFactory?: (\n parameters: ServiceDeskFactoryParameters,\n ) => Promise<ServiceDesk>;\n\n /**\n * Public configuration for the service desk integration.\n */\n @property({ type: Object, attribute: \"service-desk\" })\n serviceDesk?: ServiceDeskPublicConfig;\n\n /**\n * The element to render to instead of the default float element.\n *\n * @internal\n */\n @property({ type: HTMLElement })\n element?: HTMLElement;\n\n /**\n * This function is called before the render function of Carbon AI Chat is called. This function can return a Promise\n * which will cause Carbon AI Chat to wait for it before rendering.\n */\n @property({ attribute: false })\n onBeforeRender: (instance: ChatInstance) => Promise<void> | void;\n\n /**\n * This function is called after the render function of Carbon AI Chat is called.\n */\n @property({ attribute: false })\n onAfterRender: (instance: ChatInstance) => Promise<void> | void;\n\n /**\n * The existing array of slot names for all user_defined components.\n */\n @state()\n _userDefinedSlotNames: string[] = [];\n\n /**\n * The existing array of slot names for all writeable elements.\n */\n @state()\n _writeableElementSlots: string[] = [];\n\n /**\n * The chat instance.\n */\n @state()\n _instance: ChatInstance;\n\n /**\n * Adds the slot attribute to the element for the user_defined response type and then injects it into the component by\n * updating this._userDefinedSlotNames;\n */\n userDefinedHandler = (\n event: BusEventUserDefinedResponse | BusEventChunkUserDefinedResponse,\n ) => {\n // This element already has `slot` as an attribute.\n const { slot } = event.data;\n if (!this._userDefinedSlotNames.includes(slot)) {\n this._userDefinedSlotNames = [...this._userDefinedSlotNames, slot];\n }\n };\n\n private get resolvedConfig(): PublicConfig {\n const baseConfig = this.config ?? {};\n const resolvedConfig: PublicConfig = { ...baseConfig };\n\n if (this.onError !== undefined) {\n resolvedConfig.onError = this.onError;\n }\n if (this.openChatByDefault !== undefined) {\n resolvedConfig.openChatByDefault = this.openChatByDefault;\n }\n if (this.disclaimer !== undefined) {\n resolvedConfig.disclaimer = this.disclaimer;\n }\n if (this.disableCustomElementMobileEnhancements !== undefined) {\n resolvedConfig.disableCustomElementMobileEnhancements =\n this.disableCustomElementMobileEnhancements;\n }\n if (this.debug !== undefined) {\n resolvedConfig.debug = this.debug;\n }\n if (this.exposeServiceManagerForTesting !== undefined) {\n resolvedConfig.exposeServiceManagerForTesting =\n this.exposeServiceManagerForTesting;\n }\n if (this.injectCarbonTheme !== undefined) {\n resolvedConfig.injectCarbonTheme = this.injectCarbonTheme;\n }\n if (this.serviceDeskFactory !== undefined) {\n resolvedConfig.serviceDeskFactory = this.serviceDeskFactory;\n }\n if (this.serviceDesk !== undefined) {\n resolvedConfig.serviceDesk = this.serviceDesk;\n }\n if (this.shouldTakeFocusIfOpensAutomatically !== undefined) {\n resolvedConfig.shouldTakeFocusIfOpensAutomatically =\n this.shouldTakeFocusIfOpensAutomatically;\n }\n if (this.namespace !== undefined) {\n resolvedConfig.namespace = this.namespace;\n }\n if (this.enableFocusTrap !== undefined) {\n resolvedConfig.enableFocusTrap = this.enableFocusTrap;\n }\n if (this.shouldSanitizeHTML !== undefined) {\n resolvedConfig.shouldSanitizeHTML = this.shouldSanitizeHTML;\n }\n if (this.header !== undefined) {\n resolvedConfig.header = this.header;\n }\n if (this.input !== undefined) {\n resolvedConfig.input = this.input;\n }\n if (this.layout !== undefined) {\n resolvedConfig.layout = this.layout;\n }\n if (this.messaging !== undefined) {\n resolvedConfig.messaging = this.messaging;\n }\n if (this.isReadonly !== undefined) {\n resolvedConfig.isReadonly = this.isReadonly;\n }\n if (this.assistantName !== undefined) {\n resolvedConfig.assistantName = this.assistantName;\n }\n if (this.locale !== undefined) {\n resolvedConfig.locale = this.locale;\n }\n if (this.homescreen !== undefined) {\n resolvedConfig.homescreen = this.homescreen;\n }\n if (this.launcher !== undefined) {\n resolvedConfig.launcher = this.launcher;\n }\n if (this.strings !== undefined) {\n resolvedConfig.strings = this.strings;\n }\n\n if (this.aiDisabled === true) {\n resolvedConfig.aiEnabled = false;\n } else if (this.aiEnabled !== undefined) {\n resolvedConfig.aiEnabled = this.aiEnabled;\n }\n\n return resolvedConfig;\n }\n\n onBeforeRenderOverride = async (instance: ChatInstance) => {\n this._instance = instance;\n this._instance.on({\n type: BusEventType.USER_DEFINED_RESPONSE,\n handler: this.userDefinedHandler,\n });\n this._instance.on({\n type: BusEventType.CHUNK_USER_DEFINED_RESPONSE,\n handler: this.userDefinedHandler,\n });\n this.addWriteableElementSlots();\n await this.onBeforeRender?.(instance);\n };\n\n addWriteableElementSlots() {\n const writeableElementSlots: string[] = [];\n Object.keys(this._instance.writeableElements).forEach(\n (writeableElementKey) => {\n writeableElementSlots.push(writeableElementKey);\n },\n );\n this._writeableElementSlots = writeableElementSlots;\n }\n\n /**\n * Renders the template while passing in class functionality\n */\n render() {\n return html`<cds-aichat-internal\n .config=${this.resolvedConfig}\n .onAfterRender=${this.onAfterRender}\n .onBeforeRender=${this.onBeforeRenderOverride}\n .element=${this.element}\n >\n ${this._writeableElementSlots.map(\n (slot) => html`<div slot=${slot}><slot name=${slot}></slot></div>`,\n )}\n ${this._userDefinedSlotNames.map(\n (slot) => html`<div slot=${slot}><slot name=${slot}></slot></div>`,\n )}\n </cds-aichat-internal>`;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"cds-aichat-container\": ChatContainer;\n }\n}\n\n/**\n * Attributes interface for the cds-aichat-container web component.\n * This interface extends {@link PublicConfig} with additional component-specific props,\n * flattening all config properties as top-level properties for better TypeScript IntelliSense.\n *\n * @category Web component\n */\ninterface CdsAiChatContainerAttributes extends PublicConfig {\n /**\n * This function is called before the render function of Carbon AI Chat is called. This function can return a Promise\n * which will cause Carbon AI Chat to wait for it before rendering.\n */\n onBeforeRender?: (instance: ChatInstance) => Promise<void> | void;\n\n /**\n * This function is called after the render function of Carbon AI Chat is called.\n */\n onAfterRender?: (instance: ChatInstance) => Promise<void> | void;\n}\n\nexport { CdsAiChatContainerAttributes };\nexport default ChatContainer;\n"],"names":["ChatContainerInternal","LitElement","firstUpdated","style","document","createElement","textContent","this","element","appendChild","config","renderReactApp","updated","changedProperties","has","container","ensureReactRoot","root","render","React","App","strings","serviceDeskFactory","serviceDesk","onBeforeRender","onAfterRender","reactContainer","classList","add","shadowRoot","createRoot","disconnectedCallback","unmount","super","__decorate","property","type","Object","prototype","attribute","HTMLElement","carbonElement","ChatContainer","constructor","_userDefinedSlotNames","_writeableElementSlots","userDefinedHandler","event","slot","data","includes","onBeforeRenderOverride","async","instance","_instance","on","BusEventType","USER_DEFINED_RESPONSE","handler","CHUNK_USER_DEFINED_RESPONSE","addWriteableElementSlots","resolvedConfig","baseConfig","onError","undefined","openChatByDefault","disclaimer","disableCustomElementMobileEnhancements","debug","exposeServiceManagerForTesting","injectCarbonTheme","shouldTakeFocusIfOpensAutomatically","namespace","enableFocusTrap","shouldSanitizeHTML","header","input","layout","messaging","isReadonly","assistantName","locale","homescreen","launcher","aiDisabled","aiEnabled","writeableElementSlots","keys","writeableElements","forEach","writeableElementKey","push","html","map","Boolean","String","converter","fromAttribute","value","v","trim","toLowerCase","falsey","state","ChatContainer$1"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,IAAMA,wBAAN,MAAMA,8BAA8BC;EA0ClC,YAAAC;IAEE,MAAMC,QAAQC,SAASC,cAAc;IACrCF,MAAMG,cAAc,mIAMdC,KAAKC,UAAU,KAAK;IAG1BD,KAAKE,YAAYN;IACjB,IAAII,KAAKG,QAAQ;MACfH,KAAKI;AACP;AACF;EAEA,OAAAC,CAAQC;IAEN,IACEN,KAAKG,WACJG,kBAAkBC,IAAI,aACrBD,kBAAkBC,IAAI,cACtBD,kBAAkBC,IAAI,yBACtBD,kBAAkBC,IAAI,kBACtBD,kBAAkBC,IAAI,qBACtBD,kBAAkBC,IAAI,oBACtBD,kBAAkBC,IAAI,aACxB;MACAP,KAAKI;AACP;AACF;EAYA,oBAAMA;IACJ,MAAMI,YAAYR,KAAKS;IAEvBT,KAAKU,KAAKC,OACRC,oBAACC,KAAG;MACFV,QAAQH,KAAKG;MACbW,SAASd,KAAKc;MACdC,oBAAoBf,KAAKe;MACzBC,aAAahB,KAAKgB;MAClBC,gBAAgBjB,KAAKiB;MACrBC,eAAelB,KAAKkB;MACpBV,WAAWA;MACXP,SAASD,KAAKC;;AAGpB;EAEQ,eAAAQ;IACN,KAAKT,KAAKmB,gBAAgB;MACxB,MAAMX,YAAYX,SAASC,cAAc;MACzCU,UAAUY,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EK,cAAAJ,WAAA;;AAGpBJ,WAAA,EADCC,SAAS;EAAEC,MAAMC;MACIK,cAAAJ,WAAA;;AAGtBJ,WAAA,EADCC,SAAS;EAAEC,MAAMC;MACgBK,cAAAJ,WAAA;;AAGlCJ,WAAA,EADCC,SAAS;EAAEC,MAAM0D;EAASvD,WAAW;MACjBG,cAAAJ,WAAA;;AAGrBJ,WAAA,EADCC,SAAS;EAAEC,MAAM2D;EAAQxD,WAAW;MACdG,cAAAJ,WAAA;;AAGvBJ,WAAA,EADCC,SAAS;EAAEC,MAAM2D;MACFrD,cAAAJ,WAAA;;AAGhBJ,WAAA,EADCC,SAAS;EAAEC,MAAMC;MACYK,cAAAJ,WAAA;;AAG9BJ,WAAA,EADCC,SAAS;EAAEC,MAAMC;MACQK,cAAAJ,WAAA;;AAI1BJ,WAAA,EADCC,SAAS;EAAEC,MAAMC;MACkBK,cAAAJ,WAAA;;AAMpCJ,WAAA,EADCC,SAAS;EAAEI,WAAW;MAGGG,cAAAJ,WAAA;;AAM1BJ,WAAA,EADCC,SAAS;EAAEC,MAAMC;EAAQE,WAAW;MACCG,cAAAJ,WAAA;;AAQtCJ,WAAA,EADCC,SAAS;EAAEC,MAAMI;MACIE,cAAAJ,WAAA;;AAOtBJ,WAAA,EADCC,SAAS;EAAEI,WAAW;MAC0CG,cAAAJ,WAAA;;AAMjEJ,WAAA,EADCC,SAAS;EAAEI,WAAW;MACyCG,cAAAJ,WAAA;;AAMhEJ,WAAA,EADCqE,WACoC7D,cAAAJ,WAAA;;AAMrCJ,WAAA,EADCqE,WACqC7D,cAAAJ,WAAA;;AAMtCJ,WAAA,EADCqE,WACuB7D,cAAAJ,WAAA;;AApJpBI,gBAAaR,WAAA,EADlBO,cAAc,2BACTC;;AAiUN,IAAA8D,kBAAe9D;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../../../../src/web-components/cds-aichat-container/cds-aichat-internal.tsx","../../../../../../src/web-components/cds-aichat-container/index.ts"],"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\n/**\n * This component is mostly a pass-through. Its takes any properties passed into the ChatContainer\n * custom element and then renders the React Carbon AI Chat application while passing in properties.\n */\n\nimport { LitElement, PropertyValues } from \"lit\";\nimport { property } from \"lit/decorators.js\";\nimport React from \"react\";\nimport { createRoot, Root } from \"react-dom/client\";\n\nimport App from \"../../chat/ChatAppEntry\";\nimport { carbonElement } from \"@carbon/ai-chat-components/es/globals/decorators/index.js\";\nimport { PublicConfig } from \"../../types/config/PublicConfig\";\nimport { ChatInstance } from \"../../types/instance/ChatInstance\";\nimport { DeepPartial } from \"../../types/utilities/DeepPartial\";\nimport { LanguagePack } from \"../../types/config/PublicConfig\";\nimport type {\n ServiceDesk,\n ServiceDeskFactoryParameters,\n ServiceDeskPublicConfig,\n} from \"../../types/config/ServiceDeskConfig\";\n\n@carbonElement(\"cds-aichat-internal\")\nclass ChatContainerInternal extends LitElement {\n /**\n * The config to use to load Carbon AI Chat. Note that the \"onLoad\" property is overridden by this component. If you\n * need to perform any actions after Carbon AI Chat been loaded, use the \"onBeforeRender\" or \"onAfterRender\" props.\n */\n @property({ type: Object })\n config: PublicConfig;\n\n /** Optional partial language pack overrides */\n @property({ type: Object })\n strings?: DeepPartial<LanguagePack>;\n\n /** A factory for the {@link ServiceDesk} integration. */\n @property({ attribute: false })\n serviceDeskFactory?: (\n parameters: ServiceDeskFactoryParameters,\n ) => Promise<ServiceDesk>;\n\n /** Public configuration for the service desk integration. */\n @property({ type: Object })\n serviceDesk?: ServiceDeskPublicConfig;\n\n /**\n * The optional HTML element to mount the chat to.\n */\n @property({ type: HTMLElement })\n element?: HTMLElement;\n\n /**\n * This function is called before the render function of Carbon AI Chat is called. This function can return a Promise\n * which will cause Carbon AI Chat to wait for it before rendering.\n */\n @property()\n onBeforeRender: (instance: ChatInstance) => Promise<void> | void;\n\n /**\n * This function is called after the render function of Carbon AI Chat is called. This function can return a Promise\n * which will cause Carbon AI Chat to wait for it before rendering.\n */\n @property()\n onAfterRender: (instance: ChatInstance) => Promise<void> | void;\n\n firstUpdated() {\n // Render the React component with any updated properties if necessary\n const style = document.createElement(\"style\");\n style.textContent = `\n :host {\n display: block;\n width: 100%;\n height: 100%;\n box-sizing: border-box;\n ${this.element ? \"\" : \"z-index: var(--cds-aichat-z-index);\"}\n }\n `;\n this.appendChild(style);\n if (this.config) {\n this.renderReactApp();\n }\n }\n\n updated(changedProperties: PropertyValues) {\n // Re-render React app when config or other properties change\n if (\n this.config &&\n (changedProperties.has(\"config\") ||\n changedProperties.has(\"strings\") ||\n changedProperties.has(\"serviceDeskFactory\") ||\n changedProperties.has(\"serviceDesk\") ||\n changedProperties.has(\"onBeforeRender\") ||\n changedProperties.has(\"onAfterRender\") ||\n changedProperties.has(\"element\"))\n ) {\n this.renderReactApp();\n }\n }\n\n /**\n * Track if a previous React 18+ root was already created so we don't create a memory leak on re-renders.\n */\n root: Root;\n\n /**\n * Cache the container we hand to React so we can reuse it between renders.\n */\n reactContainer?: HTMLDivElement;\n\n async renderReactApp() {\n const container = this.ensureReactRoot();\n\n this.root.render(\n <App\n config={this.config}\n strings={this.strings}\n serviceDeskFactory={this.serviceDeskFactory}\n serviceDesk={this.serviceDesk}\n onBeforeRender={this.onBeforeRender}\n onAfterRender={this.onAfterRender}\n container={container}\n element={this.element}\n />,\n );\n }\n\n private ensureReactRoot(): HTMLDivElement {\n if (!this.reactContainer) {\n const container = document.createElement(\"div\");\n container.classList.add(\"cds-aichat--react-app\");\n this.shadowRoot.appendChild(container);\n this.reactContainer = container;\n }\n\n // Make sure we only create one root and reuse it for prop updates.\n if (!this.root) {\n this.root = createRoot(this.reactContainer);\n }\n\n return this.reactContainer;\n }\n\n disconnectedCallback(): void {\n this.root?.unmount();\n super.disconnectedCallback();\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"cds-aichat-internal\": ChatContainerInternal;\n }\n}\n\nexport default ChatContainerInternal;\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\n/**\n * This is the exposed web component for a basic floating chat.\n */\n\nimport \"./cds-aichat-internal\";\n\nimport { html, LitElement } from \"lit\";\nimport { property, state } from \"lit/decorators.js\";\n\nimport { carbonElement } from \"@carbon/ai-chat-components/es/globals/decorators/index.js\";\nimport {\n PublicConfig,\n OnErrorData,\n DisclaimerPublicConfig,\n CarbonTheme,\n HeaderConfig,\n LayoutConfig,\n PublicConfigMessaging,\n InputConfig,\n} from \"../../types/config/PublicConfig\";\nimport { DeepPartial } from \"../../types/utilities/DeepPartial\";\nimport { LanguagePack } from \"../../types/config/PublicConfig\";\nimport { HomeScreenConfig } from \"../../types/config/HomeScreenConfig\";\nimport { LauncherConfig } from \"../../types/config/LauncherConfig\";\nimport type {\n ServiceDesk,\n ServiceDeskFactoryParameters,\n ServiceDeskPublicConfig,\n} from \"../../types/config/ServiceDeskConfig\";\nimport { ChatInstance } from \"../../types/instance/ChatInstance\";\nimport {\n BusEventChunkUserDefinedResponse,\n BusEventType,\n BusEventUserDefinedResponse,\n} from \"../../types/events/eventBusTypes\";\n\n/**\n * The cds-aichat-container managing creating slotted elements for user_defined responses and writable elements.\n * It then passes that slotted content into cds-aichat-internal. That component will boot up the full chat application\n * and pass the slotted elements into their slots.\n */\n@carbonElement(\"cds-aichat-container\")\nclass ChatContainer extends LitElement {\n @property({ attribute: false, type: Object })\n config?: PublicConfig;\n\n // Flattened PublicConfig properties\n @property({ attribute: false })\n onError?: (data: OnErrorData) => void;\n\n @property({ type: Boolean, attribute: \"open-chat-by-default\" })\n openChatByDefault?: boolean;\n\n @property({ type: Object })\n disclaimer?: DisclaimerPublicConfig;\n\n @property({\n type: Boolean,\n attribute: \"disable-custom-element-mobile-enhancements\",\n })\n disableCustomElementMobileEnhancements?: boolean;\n\n @property({ type: Boolean })\n debug?: boolean;\n\n @property({ type: Boolean, attribute: \"expose-service-manager-for-testing\" })\n exposeServiceManagerForTesting?: boolean;\n\n @property({ type: String, attribute: \"inject-carbon-theme\" })\n injectCarbonTheme?: CarbonTheme;\n\n @property({\n attribute: \"ai-enabled\",\n // Custom converter so HTML authors can write ai-enabled=\"false\" | \"0\" | \"off\" | \"no\"\n // and absence keeps it undefined (so defaults apply further down the stack).\n converter: {\n fromAttribute: (value: string | null) => {\n if (value === null) {\n return undefined; // attribute absent -> leave undefined to use defaults\n }\n const v = String(value).trim().toLowerCase();\n const falsey = v === \"false\" || v === \"0\" || v === \"off\" || v === \"no\";\n // Any presence that's not an explicit falsey string is treated as true\n return !falsey;\n },\n },\n })\n aiEnabled?: boolean;\n\n // Optional explicit opt-out attribute. If present, it wins over ai-enabled.\n @property({ type: Boolean, attribute: \"ai-disabled\" })\n aiDisabled?: boolean;\n\n @property({\n type: Boolean,\n attribute: \"should-take-focus-if-opens-automatically\",\n })\n shouldTakeFocusIfOpensAutomatically?: boolean;\n\n @property({ type: String })\n namespace?: string;\n\n @state()\n private enableFocusTrap?: boolean;\n\n @property({ type: Boolean, attribute: \"should-sanitize-html\" })\n shouldSanitizeHTML?: boolean;\n\n @property({ type: Object })\n header?: HeaderConfig;\n\n @property({ type: Object })\n input?: InputConfig;\n\n @property({ type: Object })\n layout?: LayoutConfig;\n\n @property({ type: Object })\n messaging?: PublicConfigMessaging;\n\n @property({ type: Boolean, attribute: \"is-readonly\" })\n isReadonly?: boolean;\n\n @property({ type: String, attribute: \"assistant-name\" })\n assistantName?: string;\n\n @property({ type: String })\n locale?: string;\n\n @property({ type: Object })\n homescreen?: HomeScreenConfig;\n\n @property({ type: Object })\n launcher?: LauncherConfig;\n\n /** Optional partial language pack overrides */\n @property({ type: Object })\n strings?: DeepPartial<LanguagePack>;\n\n /**\n * A factory to create a {@link ServiceDesk} integration instance.\n */\n @property({ attribute: false })\n serviceDeskFactory?: (\n parameters: ServiceDeskFactoryParameters,\n ) => Promise<ServiceDesk>;\n\n /**\n * Public configuration for the service desk integration.\n */\n @property({ type: Object, attribute: \"service-desk\" })\n serviceDesk?: ServiceDeskPublicConfig;\n\n /**\n * The element to render to instead of the default float element.\n *\n * @internal\n */\n @property({ type: HTMLElement })\n element?: HTMLElement;\n\n /**\n * This function is called before the render function of Carbon AI Chat is called. This function can return a Promise\n * which will cause Carbon AI Chat to wait for it before rendering.\n */\n @property({ attribute: false })\n onBeforeRender: (instance: ChatInstance) => Promise<void> | void;\n\n /**\n * This function is called after the render function of Carbon AI Chat is called.\n */\n @property({ attribute: false })\n onAfterRender: (instance: ChatInstance) => Promise<void> | void;\n\n /**\n * The existing array of slot names for all user_defined components.\n */\n @state()\n _userDefinedSlotNames: string[] = [];\n\n /**\n * The existing array of slot names for all writeable elements.\n */\n @state()\n _writeableElementSlots: string[] = [];\n\n /**\n * The chat instance.\n */\n @state()\n _instance: ChatInstance;\n\n /**\n * Adds the slot attribute to the element for the user_defined response type and then injects it into the component by\n * updating this._userDefinedSlotNames;\n */\n userDefinedHandler = (\n event: BusEventUserDefinedResponse | BusEventChunkUserDefinedResponse,\n ) => {\n // This element already has `slot` as an attribute.\n const { slot } = event.data;\n if (!this._userDefinedSlotNames.includes(slot)) {\n this._userDefinedSlotNames = [...this._userDefinedSlotNames, slot];\n }\n };\n\n private get resolvedConfig(): PublicConfig {\n const baseConfig = this.config ?? {};\n const resolvedConfig: PublicConfig = { ...baseConfig };\n\n if (this.onError !== undefined) {\n resolvedConfig.onError = this.onError;\n }\n if (this.openChatByDefault !== undefined) {\n resolvedConfig.openChatByDefault = this.openChatByDefault;\n }\n if (this.disclaimer !== undefined) {\n resolvedConfig.disclaimer = this.disclaimer;\n }\n if (this.disableCustomElementMobileEnhancements !== undefined) {\n resolvedConfig.disableCustomElementMobileEnhancements =\n this.disableCustomElementMobileEnhancements;\n }\n if (this.debug !== undefined) {\n resolvedConfig.debug = this.debug;\n }\n if (this.exposeServiceManagerForTesting !== undefined) {\n resolvedConfig.exposeServiceManagerForTesting =\n this.exposeServiceManagerForTesting;\n }\n if (this.injectCarbonTheme !== undefined) {\n resolvedConfig.injectCarbonTheme = this.injectCarbonTheme;\n }\n if (this.serviceDeskFactory !== undefined) {\n resolvedConfig.serviceDeskFactory = this.serviceDeskFactory;\n }\n if (this.serviceDesk !== undefined) {\n resolvedConfig.serviceDesk = this.serviceDesk;\n }\n if (this.shouldTakeFocusIfOpensAutomatically !== undefined) {\n resolvedConfig.shouldTakeFocusIfOpensAutomatically =\n this.shouldTakeFocusIfOpensAutomatically;\n }\n if (this.namespace !== undefined) {\n resolvedConfig.namespace = this.namespace;\n }\n if (this.enableFocusTrap !== undefined) {\n resolvedConfig.enableFocusTrap = this.enableFocusTrap;\n }\n if (this.shouldSanitizeHTML !== undefined) {\n resolvedConfig.shouldSanitizeHTML = this.shouldSanitizeHTML;\n }\n if (this.header !== undefined) {\n resolvedConfig.header = this.header;\n }\n if (this.input !== undefined) {\n resolvedConfig.input = this.input;\n }\n if (this.layout !== undefined) {\n resolvedConfig.layout = this.layout;\n }\n if (this.messaging !== undefined) {\n resolvedConfig.messaging = this.messaging;\n }\n if (this.isReadonly !== undefined) {\n resolvedConfig.isReadonly = this.isReadonly;\n }\n if (this.assistantName !== undefined) {\n resolvedConfig.assistantName = this.assistantName;\n }\n if (this.locale !== undefined) {\n resolvedConfig.locale = this.locale;\n }\n if (this.homescreen !== undefined) {\n resolvedConfig.homescreen = this.homescreen;\n }\n if (this.launcher !== undefined) {\n resolvedConfig.launcher = this.launcher;\n }\n if (this.strings !== undefined) {\n resolvedConfig.strings = this.strings;\n }\n\n if (this.aiDisabled === true) {\n resolvedConfig.aiEnabled = false;\n } else if (this.aiEnabled !== undefined) {\n resolvedConfig.aiEnabled = this.aiEnabled;\n }\n\n return resolvedConfig;\n }\n\n onBeforeRenderOverride = async (instance: ChatInstance) => {\n this._instance = instance;\n this._instance.on({\n type: BusEventType.USER_DEFINED_RESPONSE,\n handler: this.userDefinedHandler,\n });\n this._instance.on({\n type: BusEventType.CHUNK_USER_DEFINED_RESPONSE,\n handler: this.userDefinedHandler,\n });\n this.addWriteableElementSlots();\n await this.onBeforeRender?.(instance);\n };\n\n addWriteableElementSlots() {\n const writeableElementSlots: string[] = [];\n Object.keys(this._instance.writeableElements).forEach(\n (writeableElementKey) => {\n writeableElementSlots.push(writeableElementKey);\n },\n );\n this._writeableElementSlots = writeableElementSlots;\n }\n\n /**\n * Renders the template while passing in class functionality\n */\n render() {\n return html`<cds-aichat-internal\n .config=${this.resolvedConfig}\n .onAfterRender=${this.onAfterRender}\n .onBeforeRender=${this.onBeforeRenderOverride}\n .element=${this.element}\n >\n ${this._writeableElementSlots.map(\n (slot) => html`<div slot=${slot}><slot name=${slot}></slot></div>`,\n )}\n ${this._userDefinedSlotNames.map(\n (slot) => html`<div slot=${slot}><slot name=${slot}></slot></div>`,\n )}\n </cds-aichat-internal>`;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"cds-aichat-container\": ChatContainer;\n }\n}\n\n/**\n * Attributes interface for the cds-aichat-container web component.\n * This interface extends {@link PublicConfig} with additional component-specific props,\n * flattening all config properties as top-level properties for better TypeScript IntelliSense.\n *\n * @category Web component\n */\ninterface CdsAiChatContainerAttributes extends PublicConfig {\n /**\n * This function is called before the render function of Carbon AI Chat is called. This function can return a Promise\n * which will cause Carbon AI Chat to wait for it before rendering.\n */\n onBeforeRender?: (instance: ChatInstance) => Promise<void> | void;\n\n /**\n * This function is called after the render function of Carbon AI Chat is called.\n */\n onAfterRender?: (instance: ChatInstance) => Promise<void> | void;\n}\n\nexport { CdsAiChatContainerAttributes };\nexport default ChatContainer;\n"],"names":["ChatContainerInternal","LitElement","firstUpdated","style","document","createElement","textContent","this","element","appendChild","config","renderReactApp","updated","changedProperties","has","container","ensureReactRoot","root","render","React","App","strings","serviceDeskFactory","serviceDesk","onBeforeRender","onAfterRender","reactContainer","classList","add","shadowRoot","createRoot","disconnectedCallback","unmount","super","__decorate","property","type","Object","prototype","attribute","HTMLElement","carbonElement","ChatContainer","constructor","_userDefinedSlotNames","_writeableElementSlots","userDefinedHandler","event","slot","data","includes","onBeforeRenderOverride","async","instance","_instance","on","BusEventType","USER_DEFINED_RESPONSE","handler","CHUNK_USER_DEFINED_RESPONSE","addWriteableElementSlots","resolvedConfig","baseConfig","onError","undefined","openChatByDefault","disclaimer","disableCustomElementMobileEnhancements","debug","exposeServiceManagerForTesting","injectCarbonTheme","shouldTakeFocusIfOpensAutomatically","namespace","enableFocusTrap","shouldSanitizeHTML","header","input","layout","messaging","isReadonly","assistantName","locale","homescreen","launcher","aiDisabled","aiEnabled","writeableElementSlots","keys","writeableElements","forEach","writeableElementKey","push","html","map","Boolean","String","converter","fromAttribute","value","v","trim","toLowerCase","falsey","state","ChatContainer_default"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,IAAMA,wBAAN,MAAMA,8BAA8BC;EA0ClC,YAAAC;IAEE,MAAMC,QAAQC,SAASC,cAAc;IACrCF,MAAMG,cAAc,mIAMdC,KAAKC,UAAU,KAAK;IAG1BD,KAAKE,YAAYN;IACjB,IAAII,KAAKG,QAAQ;MACfH,KAAKI;AACP;AACF;EAEA,OAAAC,CAAQC;IAEN,IACEN,KAAKG,WACJG,kBAAkBC,IAAI,aACrBD,kBAAkBC,IAAI,cACtBD,kBAAkBC,IAAI,yBACtBD,kBAAkBC,IAAI,kBACtBD,kBAAkBC,IAAI,qBACtBD,kBAAkBC,IAAI,oBACtBD,kBAAkBC,IAAI,aACxB;MACAP,KAAKI;AACP;AACF;EAYA,oBAAMA;IACJ,MAAMI,YAAYR,KAAKS;IAEvBT,KAAKU,KAAKC,O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A,EADCqE,WACqC7D,cAAAJ,WAAA;;AAMtCJ,WAAA,EADCqE,WACuB7D,cAAAJ,WAAA;;AApJpBI,gBAAaR,WAAA,EADlBO,cAAc,2BACTC;;AAiUN,IAAA8D,wBAAe9D;;"}
@@ -8,7 +8,7 @@ import { property, state } from "lit/decorators.js";
8
8
 
9
9
  import { carbonElement } from "@carbon/ai-chat-components/es/globals/decorators/index.js";
10
10
 
11
- import { B as BusEventType } from "../../chat.PageObjectId.js";
11
+ import { B as BusEventType } from "../../chat.languages.js";
12
12
 
13
13
  import "react";
14
14
 
@@ -30,10 +30,6 @@ import "lodash-es/mergeWith.js";
30
30
 
31
31
  import "react-intl";
32
32
 
33
- import "dayjs/locale/en.js";
34
-
35
- import "intl-messageformat";
36
-
37
33
  import "react-dom";
38
34
 
39
35
  import "classnames";
@@ -60,43 +56,7 @@ import "@carbon/web-components/es/components/button/button.js";
60
56
 
61
57
  import "@carbon/icons/es/user--avatar/32.js";
62
58
 
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";
59
+ import "@carbon/ai-chat-components/es/react/markdown.js";
100
60
 
101
61
  import "@carbon/icons/es/chat-bot/32.js";
102
62
 
@@ -104,6 +64,12 @@ import "@carbon/icons/es/checkmark--filled/16.js";
104
64
 
105
65
  import "@carbon/icons/es/headset/32.js";
106
66
 
67
+ import "@carbon/icons/es/chevron--down/16.js";
68
+
69
+ import "@carbon/ai-chat-components/es/react/reasoning-steps.js";
70
+
71
+ import "@carbon/ai-chat-components/es/react/reasoning-step.js";
72
+
107
73
  import "@carbon/web-components/es/components/loading/loading-icon.js";
108
74
 
109
75
  import "@carbon/web-components/es/components/loading/loading.js";
@@ -112,21 +78,11 @@ import "@carbon/icons/es/error--filled/16.js";
112
78
 
113
79
  import "@carbon/icons/es/attachment/16.js";
114
80
 
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";
81
+ import "@carbon/ai-chat-components/es/react/feedback-buttons.js";
126
82
 
127
- import "@carbon/web-components/es/components/tag/index.js";
83
+ import "@carbon/ai-chat-components/es/react/feedback.js";
128
84
 
129
- import "@carbon/web-components/es/components/chat-button/index.js";
85
+ import "@carbon/ai-chat-components/es/globals/settings.js";
130
86
 
131
87
  import "@carbon/icons/es/checkmark/16.js";
132
88
 
@@ -148,12 +104,14 @@ import "@carbon/web-components/es/components/skeleton-text/skeleton-text.js";
148
104
 
149
105
  import "@carbon/web-components/es/components/skeleton-placeholder/skeleton-placeholder.js";
150
106
 
151
- import "@carbon/icons/es/chevron--down/16.js";
152
-
153
107
  import "@carbon/icons/es/chevron--up/16.js";
154
108
 
155
109
  import "@carbon/icons/es/touch--interaction/16.js";
156
110
 
111
+ import "@carbon/ai-chat-components/es/react/chat-button.js";
112
+
113
+ import "@carbon/ai-chat-components/es/react/button.js";
114
+
157
115
  import "@carbon/icons/es/send/16.js";
158
116
 
159
117
  import "@carbon/icons/es/arrow--right/16.js";
@@ -182,18 +140,18 @@ import "@carbon/web-components/es/components/date-picker/date-picker-input.js";
182
140
 
183
141
  import "@carbon/web-components/es/components/date-picker/defs.js";
184
142
 
185
- import "@carbon/web-components/es/components/chat-button/chat-button.js";
186
-
187
143
  import "@carbon/web-components/es/components/dropdown/dropdown.js";
188
144
 
189
145
  import "@carbon/web-components/es/components/dropdown/dropdown-item.js";
190
146
 
191
- import "@carbon/web-components/es/components/inline-loading/index.js";
147
+ import "@carbon/ai-chat-components/es/react/chain-of-thought.js";
192
148
 
193
149
  import "@carbon/ai-chat-components/es/react/processing.js";
194
150
 
195
151
  import "@carbon/icons/es/restart/16.js";
196
152
 
153
+ import "@carbon/web-components/es/components/chat-button/chat-button.js";
154
+
197
155
  import "@carbon/icons/es/home/16.js";
198
156
 
199
157
  import "@carbon/icons/es/close--large/16.js";
@@ -224,17 +182,23 @@ import "@carbon/web-components/es/components/file-uploader/defs.js";
224
182
 
225
183
  import "@carbon/web-components/es/components/file-uploader/file-uploader-item.js";
226
184
 
185
+ import "@carbon/web-components/es/components/icon-button/index.js";
186
+
187
+ import "@carbon/web-components/es/globals/internal/icon-loader.js";
188
+
227
189
  import "@carbon/icons/es/stop--filled/16.js";
228
190
 
229
191
  import "@carbon/web-components/es/components/layer/layer.js";
230
192
 
231
- import "@carbon/icons/es/close/16.js";
232
-
233
193
  import "@carbon/icons/es/ai-launch/24.js";
234
194
 
235
195
  import "@carbon/icons/es/chat--launch/24.js";
236
196
 
237
- import "@carbon/web-components/es/components/tag/tag.js";
197
+ import "@carbon/icons/es/close/16.js";
198
+
199
+ import "@carbon/ai-chat-components/es/components/chain-of-thought/src/types.js";
200
+
201
+ import "dayjs/locale/en.js";
238
202
 
239
203
  var ChatCustomElement_1;
240
204
 
@@ -251,7 +215,7 @@ let ChatCustomElement = ChatCustomElement_1 = class ChatCustomElement extends Li
251
215
  }
252
216
  };
253
217
  this.userDefinedHandler = event => {
254
- const {slot: slot} = event.data;
218
+ const {slot} = event.data;
255
219
  if (!this._userDefinedSlotNames.includes(slot)) {
256
220
  this._userDefinedSlotNames = [ ...this._userDefinedSlotNames, slot ];
257
221
  }
@@ -533,7 +497,7 @@ __decorate([ state() ], ChatCustomElement.prototype, "_instance", void 0);
533
497
 
534
498
  ChatCustomElement = ChatCustomElement_1 = __decorate([ carbonElement("cds-aichat-custom-element") ], ChatCustomElement);
535
499
 
536
- var ChatCustomElement$1 = ChatCustomElement;
500
+ var ChatCustomElement_default = ChatCustomElement;
537
501
 
538
- export { ChatCustomElement$1 as default };
502
+ export { ChatCustomElement_default as default };
539
503
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../../../src/web-components/cds-aichat-custom-element/index.ts"],"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\n// Ensure the container custom element is registered whenever the\n// custom element module is imported by re-exporting its exports.\n// This prevents bundlers (and our own multi-entry Rollup build)\n// from pruning the side-effect-only import.\nexport { default as __cds_aichat_container_register } from \"../cds-aichat-container\";\nimport \"../cds-aichat-container\";\n\nimport { html, LitElement } from \"lit\";\nimport { property, state } from \"lit/decorators.js\";\n\nimport { carbonElement } from \"@carbon/ai-chat-components/es/globals/decorators/index.js\";\nimport {\n PublicConfig,\n OnErrorData,\n DisclaimerPublicConfig,\n CarbonTheme,\n HeaderConfig,\n LayoutConfig,\n PublicConfigMessaging,\n LanguagePack,\n InputConfig,\n} from \"../../types/config/PublicConfig\";\nimport { DeepPartial } from \"../../types/utilities/DeepPartial\";\nimport { HomeScreenConfig } from \"../../types/config/HomeScreenConfig\";\nimport { LauncherConfig } from \"../../types/config/LauncherConfig\";\nimport type {\n ServiceDesk,\n ServiceDeskFactoryParameters,\n ServiceDeskPublicConfig,\n} from \"../../types/config/ServiceDeskConfig\";\nimport { ChatInstance } from \"../../types/instance/ChatInstance\";\nimport {\n BusEventChunkUserDefinedResponse,\n BusEventType,\n BusEventUserDefinedResponse,\n BusEventViewChange,\n BusEventViewPreChange,\n} from \"../../types/events/eventBusTypes\";\n\n/**\n * cds-aichat-custom-element will is a pass through to cds-aichat-container. It takes any user_defined and writeable element\n * slotted content and forwards it to cds-aichat-container. It also will setup the custom element with a default viewChange\n * pattern (e.g. hiding and showing the custom element when the chat should be open/closed) if a onViewChange property is not\n * defined. Finally, it registers the custom element with cds-aichat-container so a default \"floating\" element will not be created.\n *\n * The custom element should be sized using external CSS. When hidden, the 'cds-aichat--hidden' class is added to set dimensions to 0x0.\n */\n@carbonElement(\"cds-aichat-custom-element\")\nclass ChatCustomElement extends LitElement {\n @property({ attribute: false, type: Object })\n config?: PublicConfig;\n\n /**\n * Shared stylesheet for hiding styles.\n */\n private static hideSheet = new CSSStyleSheet();\n static {\n // Hide styles that override any external sizing\n ChatCustomElement.hideSheet.replaceSync(`\n :host {\n display: block;\n }\n :host(.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 display: block !important;\n }\n `);\n }\n\n /**\n * Adopt our stylesheet into every shadowRoot.\n */\n protected createRenderRoot(): ShadowRoot {\n // Lits default createRenderRoot actually returns a ShadowRoot\n const root = super.createRenderRoot() as ShadowRoot;\n\n // now TS knows root.adoptedStyleSheets exists\n root.adoptedStyleSheets = [\n ...root.adoptedStyleSheets,\n ChatCustomElement.hideSheet,\n ];\n return root;\n }\n\n // Flattened PublicConfig properties\n @property({ attribute: false })\n onError?: (data: OnErrorData) => void;\n\n @property({ type: Boolean, attribute: \"open-chat-by-default\" })\n openChatByDefault?: boolean;\n\n @property({ type: Object })\n disclaimer?: DisclaimerPublicConfig;\n\n @property({\n type: Boolean,\n attribute: \"disable-custom-element-mobile-enhancements\",\n })\n disableCustomElementMobileEnhancements?: boolean;\n\n @property({ type: Boolean })\n debug?: boolean;\n\n @property({ type: Boolean, attribute: \"expose-service-manager-for-testing\" })\n exposeServiceManagerForTesting?: boolean;\n\n @property({ type: String, attribute: \"inject-carbon-theme\" })\n injectCarbonTheme?: CarbonTheme;\n\n @property({\n attribute: \"ai-enabled\",\n converter: {\n fromAttribute: (value: string | null) => {\n if (value === null) {\n return undefined;\n }\n const v = String(value).trim().toLowerCase();\n const falsey = v === \"false\" || v === \"0\" || v === \"off\" || v === \"no\";\n return !falsey;\n },\n },\n })\n aiEnabled?: boolean;\n\n @property({ type: Boolean, attribute: \"ai-disabled\" })\n aiDisabled?: boolean;\n\n @property({\n type: Boolean,\n attribute: \"should-take-focus-if-opens-automatically\",\n })\n shouldTakeFocusIfOpensAutomatically?: boolean;\n\n @property({ type: String })\n namespace?: string;\n\n @state()\n private enableFocusTrap?: boolean;\n\n @property({ type: Boolean, attribute: \"should-sanitize-html\" })\n shouldSanitizeHTML?: boolean;\n\n @property({ type: Object })\n header?: HeaderConfig;\n\n @property({ type: Object })\n input?: InputConfig;\n\n @property({ type: Object })\n layout?: LayoutConfig;\n\n @property({ type: Object })\n messaging?: PublicConfigMessaging;\n\n @property({ type: Boolean, attribute: \"is-readonly\" })\n isReadonly?: boolean;\n\n @property({ type: String, attribute: \"assistant-name\" })\n assistantName?: string;\n\n @property({ type: String })\n locale?: string;\n\n @property({ type: Object })\n homescreen?: HomeScreenConfig;\n\n @property({ type: Object })\n launcher?: LauncherConfig;\n\n /** A factory for the {@link ServiceDesk} integration. */\n @property({ attribute: false })\n serviceDeskFactory?: (\n parameters: ServiceDeskFactoryParameters,\n ) => Promise<ServiceDesk>;\n\n /** Public configuration for the service desk integration. */\n @property({ type: Object, attribute: \"service-desk\" })\n serviceDesk?: ServiceDeskPublicConfig;\n\n /** Optional partial language pack overrides */\n @property({ type: Object })\n strings?: DeepPartial<LanguagePack>;\n\n /**\n * This function is called before the render function of Carbon AI Chat is called. This function can return a Promise\n * which will cause Carbon AI Chat to wait for it before rendering.\n */\n @property({ attribute: false })\n onBeforeRender?: (instance: ChatInstance) => Promise<void> | void;\n\n /**\n * This function is called after the render function of Carbon AI Chat is called.\n */\n @property({ attribute: false })\n onAfterRender?: (instance: ChatInstance) => Promise<void> | void;\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 CSS class name values on this element 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 @property()\n onViewPreChange?: (event: BusEventViewPreChange) => 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 @property()\n onViewChange?: (event: BusEventViewChange, instance: ChatInstance) => void;\n\n @state()\n private _userDefinedSlotNames: string[] = [];\n\n @state()\n private _writeableElementSlots: string[] = [];\n\n @state()\n private _instance!: ChatInstance;\n\n private defaultViewChangeHandler = (event: BusEventViewChange) => {\n if (event.newViewState.mainWindow) {\n this.classList.remove(\"cds-aichat--hidden\");\n } else {\n this.classList.add(\"cds-aichat--hidden\");\n }\n };\n\n private userDefinedHandler = (\n event: BusEventUserDefinedResponse | BusEventChunkUserDefinedResponse,\n ) => {\n const { slot } = event.data;\n if (!this._userDefinedSlotNames.includes(slot)) {\n this._userDefinedSlotNames = [...this._userDefinedSlotNames, slot];\n }\n };\n\n private get resolvedConfig(): PublicConfig {\n const baseConfig = this.config ?? {};\n const resolvedConfig: PublicConfig = { ...baseConfig };\n\n if (this.onError !== undefined) {\n resolvedConfig.onError = this.onError;\n }\n if (this.openChatByDefault !== undefined) {\n resolvedConfig.openChatByDefault = this.openChatByDefault;\n }\n if (this.disclaimer !== undefined) {\n resolvedConfig.disclaimer = this.disclaimer;\n }\n if (this.disableCustomElementMobileEnhancements !== undefined) {\n resolvedConfig.disableCustomElementMobileEnhancements =\n this.disableCustomElementMobileEnhancements;\n }\n if (this.debug !== undefined) {\n resolvedConfig.debug = this.debug;\n }\n if (this.exposeServiceManagerForTesting !== undefined) {\n resolvedConfig.exposeServiceManagerForTesting =\n this.exposeServiceManagerForTesting;\n }\n if (this.injectCarbonTheme !== undefined) {\n resolvedConfig.injectCarbonTheme = this.injectCarbonTheme;\n }\n if (this.serviceDeskFactory !== undefined) {\n resolvedConfig.serviceDeskFactory = this.serviceDeskFactory;\n }\n if (this.serviceDesk !== undefined) {\n resolvedConfig.serviceDesk = this.serviceDesk;\n }\n if (this.shouldTakeFocusIfOpensAutomatically !== undefined) {\n resolvedConfig.shouldTakeFocusIfOpensAutomatically =\n this.shouldTakeFocusIfOpensAutomatically;\n }\n if (this.namespace !== undefined) {\n resolvedConfig.namespace = this.namespace;\n }\n if (this.enableFocusTrap !== undefined) {\n resolvedConfig.enableFocusTrap = this.enableFocusTrap;\n }\n if (this.shouldSanitizeHTML !== undefined) {\n resolvedConfig.shouldSanitizeHTML = this.shouldSanitizeHTML;\n }\n if (this.header !== undefined) {\n resolvedConfig.header = this.header;\n }\n if (this.input !== undefined) {\n resolvedConfig.input = this.input;\n }\n if (this.layout !== undefined) {\n resolvedConfig.layout = this.layout;\n }\n if (this.messaging !== undefined) {\n resolvedConfig.messaging = this.messaging;\n }\n if (this.isReadonly !== undefined) {\n resolvedConfig.isReadonly = this.isReadonly;\n }\n if (this.assistantName !== undefined) {\n resolvedConfig.assistantName = this.assistantName;\n }\n if (this.locale !== undefined) {\n resolvedConfig.locale = this.locale;\n }\n if (this.homescreen !== undefined) {\n resolvedConfig.homescreen = this.homescreen;\n }\n if (this.launcher !== undefined) {\n resolvedConfig.launcher = this.launcher;\n }\n if (this.strings !== undefined) {\n resolvedConfig.strings = this.strings;\n }\n\n if (this.aiDisabled === true) {\n resolvedConfig.aiEnabled = false;\n } else if (this.aiEnabled !== undefined) {\n resolvedConfig.aiEnabled = this.aiEnabled;\n }\n\n return resolvedConfig;\n }\n\n private onBeforeRenderOverride = async (instance: ChatInstance) => {\n this._instance = instance;\n if (this.onViewPreChange) {\n this._instance.on({\n type: BusEventType.VIEW_PRE_CHANGE,\n handler: this.onViewPreChange,\n });\n }\n this._instance.on({\n type: BusEventType.VIEW_CHANGE,\n handler: this.onViewChange || this.defaultViewChangeHandler,\n });\n this._instance.on({\n type: BusEventType.USER_DEFINED_RESPONSE,\n handler: this.userDefinedHandler,\n });\n this._instance.on({\n type: BusEventType.CHUNK_USER_DEFINED_RESPONSE,\n handler: this.userDefinedHandler,\n });\n this.addWriteableElementSlots();\n await this.onBeforeRender?.(instance);\n };\n\n private addWriteableElementSlots() {\n this._writeableElementSlots = Object.keys(this._instance.writeableElements);\n }\n\n render() {\n return html`\n <cds-aichat-container\n .config=${this.resolvedConfig}\n .onAfterRender=${this.onAfterRender}\n .onBeforeRender=${this.onBeforeRenderOverride}\n .element=${this}\n >\n ${this._writeableElementSlots.map(\n (slot) => html`<div slot=${slot}><slot name=${slot}></slot></div>`,\n )}\n ${this._userDefinedSlotNames.map(\n (slot) => html`<div slot=${slot}><slot name=${slot}></slot></div>`,\n )}\n </cds-aichat-container>\n `;\n }\n}\n\n/**\n * Attributes interface for the cds-aichat-custom-element web component.\n * This interface extends {@link CdsAiChatContainerAttributes} and {@link PublicConfig} with additional component-specific props,\n * flattening all config properties as top-level properties for better TypeScript IntelliSense.\n *\n * @category Web component\n */\ninterface CdsAiChatCustomElementAttributes extends PublicConfig {\n /**\n * This function is called before the render function of Carbon AI Chat is called. This function can return a Promise\n * which will cause Carbon AI Chat to wait for it before rendering.\n */\n onBeforeRender?: (instance: ChatInstance) => Promise<void> | void;\n\n /**\n * This function is called after the render function of Carbon AI Chat is called.\n */\n onAfterRender?: (instance: ChatInstance) => Promise<void> | void;\n\n /**\n * An optional listener for \"view:change\" events. Such a listener is required when using a custom element in order\n * to control the visibility of the Carbon AI Chat main window. If no callback is provided here, a default one will be\n * used that injects styling into the app that will show and hide the Carbon AI Chat main window and also change the\n * size of the custom element so it doesn't take up space when the main window is closed.\n *\n * You can provide a different callback here if you want custom behavior such as an animation when the main window\n * is opened or closed.\n *\n * Note that this function can only be provided before Carbon AI Chat is loaded. After Carbon AI Chat is loaded, the event\n * handler will not be updated.\n */\n onViewChange?: (event: BusEventViewChange, instance: ChatInstance) => void;\n}\n\nexport { CdsAiChatCustomElementAttributes };\n\nexport default ChatCustomElement;\n"],"names":["ChatCustomElement","ChatCustomElement_1","LitElement","constructor","this","_userDefinedSlotNames","_writeableElementSlots","defaultViewChangeHandler","event","newViewState","mainWindow","classList","remove","add","userDefinedHandler","slot","data","includes","onBeforeRenderOverride","async","instance","_instance","onViewPreChange","on","type","BusEventType","VIEW_PRE_CHANGE","handler","VIEW_CHANGE","onViewChange","USER_DEFINED_RESPONSE","CHUNK_USER_DEFINED_RESPONSE","addWriteableElementSlots","onBeforeRender","createRenderRoot","root","super","adoptedStyleSheets","hideSheet","resolvedConfig","baseConfig","config","onError","undefined","openChatByDefault","disclaimer","disableCustomElementMobileEnhancements","debug","exposeServiceManagerForTesting","injectCarbonTheme","serviceDeskFactory","serviceDesk","shouldTakeFocusIfOpensAutomatically","namespace","enableFocusTrap","shouldSanitizeHTML","header","input","layout","messaging","isReadonly","assistantName","locale","homescreen","launcher","strings","aiDisabled","aiEnabled","Object","keys","writeableElements","render","html","onAfterRender","map","CSSStyleSheet","replaceSync","__decorate","property","attribute","prototype","Boolean","String","converter","fromAttribute","value","v","trim","toLowerCase","falsey","state","carbonElement","ChatCustomElement$1"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyDA,IAAMA,oBAAiBC,sBAAvB,MAAMD,0BAA0BE;EAAhC,WAAAC;;IAuMUC,KAAAC,wBAAkC;IAGlCD,KAAAE,yBAAmC;IAKnCF,KAAAG,2BAA4BC;MAClC,IAAIA,MAAMC,aAAaC,YAAY;QACjCN,KAAKO,UAAUC,OAAO;AACxB,aAAO;QACLR,KAAKO,UAAUE,IAAI;AACrB;;IAGMT,KAAAU,qBACNN;MAEA,OAAMO,MAAEA,QAASP,MAAMQ;MACvB,KAAKZ,KAAKC,sBAAsBY,SAASF,OAAO;QAC9CX,KAAKC,wBAAwB,KAAID,KAAKC,uBAAuBU;AAC/D;;IAyFMX,KAAAc,yBAAyBC,MAAOC;MACtChB,KAAKiB,YAAYD;MACjB,IAAIhB,KAAKkB,iBAAiB;QACxBlB,KAAKiB,UAAUE,GAAG;UAChBC,MAAMC,aAAa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,SAAS;EAAEC,WAAW;MAC2C/E,kBAAAgF,WAAA;;AAMlEH,WAAA,EADCC,SAAS;EAAEC,WAAW;MAC0C/E,kBAAAgF,WAAA;;AAgBjEH,WAAA,EADCC,cACwE9E,kBAAAgF,WAAA;;AAsBzEH,WAAA,EADCC,cAC0E9E,kBAAAgF,WAAA;;AAGnEH,WAAA,EADPa,WAC4C1F,kBAAAgF,WAAA;;AAGrCH,WAAA,EADPa,WAC6C1F,kBAAAgF,WAAA;;AAGtCH,WAAA,EADPa,WACgC1F,kBAAAgF,WAAA;;AA7M7BhF,oBAAiBC,sBAAA4E,WAAA,EADtBc,cAAc,gCACT3F;;AAyYN,IAAA4F,sBAAe5F;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../../../../src/web-components/cds-aichat-custom-element/index.ts"],"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\n// Ensure the container custom element is registered whenever the\n// custom element module is imported by re-exporting its exports.\n// This prevents bundlers (and our own multi-entry Rollup build)\n// from pruning the side-effect-only import.\nexport { default as __cds_aichat_container_register } from \"../cds-aichat-container\";\nimport \"../cds-aichat-container\";\n\nimport { html, LitElement } from \"lit\";\nimport { property, state } from \"lit/decorators.js\";\n\nimport { carbonElement } from \"@carbon/ai-chat-components/es/globals/decorators/index.js\";\nimport {\n PublicConfig,\n OnErrorData,\n DisclaimerPublicConfig,\n CarbonTheme,\n HeaderConfig,\n LayoutConfig,\n PublicConfigMessaging,\n LanguagePack,\n InputConfig,\n} from \"../../types/config/PublicConfig\";\nimport { DeepPartial } from \"../../types/utilities/DeepPartial\";\nimport { HomeScreenConfig } from \"../../types/config/HomeScreenConfig\";\nimport { LauncherConfig } from \"../../types/config/LauncherConfig\";\nimport type {\n ServiceDesk,\n ServiceDeskFactoryParameters,\n ServiceDeskPublicConfig,\n} from \"../../types/config/ServiceDeskConfig\";\nimport { ChatInstance } from \"../../types/instance/ChatInstance\";\nimport {\n BusEventChunkUserDefinedResponse,\n BusEventType,\n BusEventUserDefinedResponse,\n BusEventViewChange,\n BusEventViewPreChange,\n} from \"../../types/events/eventBusTypes\";\n\n/**\n * cds-aichat-custom-element will is a pass through to cds-aichat-container. It takes any user_defined and writeable element\n * slotted content and forwards it to cds-aichat-container. It also will setup the custom element with a default viewChange\n * pattern (e.g. hiding and showing the custom element when the chat should be open/closed) if a onViewChange property is not\n * defined. Finally, it registers the custom element with cds-aichat-container so a default \"floating\" element will not be created.\n *\n * The custom element should be sized using external CSS. When hidden, the 'cds-aichat--hidden' class is added to set dimensions to 0x0.\n */\n@carbonElement(\"cds-aichat-custom-element\")\nclass ChatCustomElement extends LitElement {\n @property({ attribute: false, type: Object })\n config?: PublicConfig;\n\n /**\n * Shared stylesheet for hiding styles.\n */\n private static hideSheet = new CSSStyleSheet();\n static {\n // Hide styles that override any external sizing\n ChatCustomElement.hideSheet.replaceSync(`\n :host {\n display: block;\n }\n :host(.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 display: block !important;\n }\n `);\n }\n\n /**\n * Adopt our stylesheet into every shadowRoot.\n */\n protected createRenderRoot(): ShadowRoot {\n // Lits default createRenderRoot actually returns a ShadowRoot\n const root = super.createRenderRoot() as ShadowRoot;\n\n // now TS knows root.adoptedStyleSheets exists\n root.adoptedStyleSheets = [\n ...root.adoptedStyleSheets,\n ChatCustomElement.hideSheet,\n ];\n return root;\n }\n\n // Flattened PublicConfig properties\n @property({ attribute: false })\n onError?: (data: OnErrorData) => void;\n\n @property({ type: Boolean, attribute: \"open-chat-by-default\" })\n openChatByDefault?: boolean;\n\n @property({ type: Object })\n disclaimer?: DisclaimerPublicConfig;\n\n @property({\n type: Boolean,\n attribute: \"disable-custom-element-mobile-enhancements\",\n })\n disableCustomElementMobileEnhancements?: boolean;\n\n @property({ type: Boolean })\n debug?: boolean;\n\n @property({ type: Boolean, attribute: \"expose-service-manager-for-testing\" })\n exposeServiceManagerForTesting?: boolean;\n\n @property({ type: String, attribute: \"inject-carbon-theme\" })\n injectCarbonTheme?: CarbonTheme;\n\n @property({\n attribute: \"ai-enabled\",\n converter: {\n fromAttribute: (value: string | null) => {\n if (value === null) {\n return undefined;\n }\n const v = String(value).trim().toLowerCase();\n const falsey = v === \"false\" || v === \"0\" || v === \"off\" || v === \"no\";\n return !falsey;\n },\n },\n })\n aiEnabled?: boolean;\n\n @property({ type: Boolean, attribute: \"ai-disabled\" })\n aiDisabled?: boolean;\n\n @property({\n type: Boolean,\n attribute: \"should-take-focus-if-opens-automatically\",\n })\n shouldTakeFocusIfOpensAutomatically?: boolean;\n\n @property({ type: String })\n namespace?: string;\n\n @state()\n private enableFocusTrap?: boolean;\n\n @property({ type: Boolean, attribute: \"should-sanitize-html\" })\n shouldSanitizeHTML?: boolean;\n\n @property({ type: Object })\n header?: HeaderConfig;\n\n @property({ type: Object })\n input?: InputConfig;\n\n @property({ type: Object })\n layout?: LayoutConfig;\n\n @property({ type: Object })\n messaging?: PublicConfigMessaging;\n\n @property({ type: Boolean, attribute: \"is-readonly\" })\n isReadonly?: boolean;\n\n @property({ type: String, attribute: \"assistant-name\" })\n assistantName?: string;\n\n @property({ type: String })\n locale?: string;\n\n @property({ type: Object })\n homescreen?: HomeScreenConfig;\n\n @property({ type: Object })\n launcher?: LauncherConfig;\n\n /** A factory for the {@link ServiceDesk} integration. */\n @property({ attribute: false })\n serviceDeskFactory?: (\n parameters: ServiceDeskFactoryParameters,\n ) => Promise<ServiceDesk>;\n\n /** Public configuration for the service desk integration. */\n @property({ type: Object, attribute: \"service-desk\" })\n serviceDesk?: ServiceDeskPublicConfig;\n\n /** Optional partial language pack overrides */\n @property({ type: Object })\n strings?: DeepPartial<LanguagePack>;\n\n /**\n * This function is called before the render function of Carbon AI Chat is called. This function can return a Promise\n * which will cause Carbon AI Chat to wait for it before rendering.\n */\n @property({ attribute: false })\n onBeforeRender?: (instance: ChatInstance) => Promise<void> | void;\n\n /**\n * This function is called after the render function of Carbon AI Chat is called.\n */\n @property({ attribute: false })\n onAfterRender?: (instance: ChatInstance) => Promise<void> | void;\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 CSS class name values on this element 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 @property()\n onViewPreChange?: (event: BusEventViewPreChange) => 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 @property()\n onViewChange?: (event: BusEventViewChange, instance: ChatInstance) => void;\n\n @state()\n private _userDefinedSlotNames: string[] = [];\n\n @state()\n private _writeableElementSlots: string[] = [];\n\n @state()\n private _instance!: ChatInstance;\n\n private defaultViewChangeHandler = (event: BusEventViewChange) => {\n if (event.newViewState.mainWindow) {\n this.classList.remove(\"cds-aichat--hidden\");\n } else {\n this.classList.add(\"cds-aichat--hidden\");\n }\n };\n\n private userDefinedHandler = (\n event: BusEventUserDefinedResponse | BusEventChunkUserDefinedResponse,\n ) => {\n const { slot } = event.data;\n if (!this._userDefinedSlotNames.includes(slot)) {\n this._userDefinedSlotNames = [...this._userDefinedSlotNames, slot];\n }\n };\n\n private get resolvedConfig(): PublicConfig {\n const baseConfig = this.config ?? {};\n const resolvedConfig: PublicConfig = { ...baseConfig };\n\n if (this.onError !== undefined) {\n resolvedConfig.onError = this.onError;\n }\n if (this.openChatByDefault !== undefined) {\n resolvedConfig.openChatByDefault = this.openChatByDefault;\n }\n if (this.disclaimer !== undefined) {\n resolvedConfig.disclaimer = this.disclaimer;\n }\n if (this.disableCustomElementMobileEnhancements !== undefined) {\n resolvedConfig.disableCustomElementMobileEnhancements =\n this.disableCustomElementMobileEnhancements;\n }\n if (this.debug !== undefined) {\n resolvedConfig.debug = this.debug;\n }\n if (this.exposeServiceManagerForTesting !== undefined) {\n resolvedConfig.exposeServiceManagerForTesting =\n this.exposeServiceManagerForTesting;\n }\n if (this.injectCarbonTheme !== undefined) {\n resolvedConfig.injectCarbonTheme = this.injectCarbonTheme;\n }\n if (this.serviceDeskFactory !== undefined) {\n resolvedConfig.serviceDeskFactory = this.serviceDeskFactory;\n }\n if (this.serviceDesk !== undefined) {\n resolvedConfig.serviceDesk = this.serviceDesk;\n }\n if (this.shouldTakeFocusIfOpensAutomatically !== undefined) {\n resolvedConfig.shouldTakeFocusIfOpensAutomatically =\n this.shouldTakeFocusIfOpensAutomatically;\n }\n if (this.namespace !== undefined) {\n resolvedConfig.namespace = this.namespace;\n }\n if (this.enableFocusTrap !== undefined) {\n resolvedConfig.enableFocusTrap = this.enableFocusTrap;\n }\n if (this.shouldSanitizeHTML !== undefined) {\n resolvedConfig.shouldSanitizeHTML = this.shouldSanitizeHTML;\n }\n if (this.header !== undefined) {\n resolvedConfig.header = this.header;\n }\n if (this.input !== undefined) {\n resolvedConfig.input = this.input;\n }\n if (this.layout !== undefined) {\n resolvedConfig.layout = this.layout;\n }\n if (this.messaging !== undefined) {\n resolvedConfig.messaging = this.messaging;\n }\n if (this.isReadonly !== undefined) {\n resolvedConfig.isReadonly = this.isReadonly;\n }\n if (this.assistantName !== undefined) {\n resolvedConfig.assistantName = this.assistantName;\n }\n if (this.locale !== undefined) {\n resolvedConfig.locale = this.locale;\n }\n if (this.homescreen !== undefined) {\n resolvedConfig.homescreen = this.homescreen;\n }\n if (this.launcher !== undefined) {\n resolvedConfig.launcher = this.launcher;\n }\n if (this.strings !== undefined) {\n resolvedConfig.strings = this.strings;\n }\n\n if (this.aiDisabled === true) {\n resolvedConfig.aiEnabled = false;\n } else if (this.aiEnabled !== undefined) {\n resolvedConfig.aiEnabled = this.aiEnabled;\n }\n\n return resolvedConfig;\n }\n\n private onBeforeRenderOverride = async (instance: ChatInstance) => {\n this._instance = instance;\n if (this.onViewPreChange) {\n this._instance.on({\n type: BusEventType.VIEW_PRE_CHANGE,\n handler: this.onViewPreChange,\n });\n }\n this._instance.on({\n type: BusEventType.VIEW_CHANGE,\n handler: this.onViewChange || this.defaultViewChangeHandler,\n });\n this._instance.on({\n type: BusEventType.USER_DEFINED_RESPONSE,\n handler: this.userDefinedHandler,\n });\n this._instance.on({\n type: BusEventType.CHUNK_USER_DEFINED_RESPONSE,\n handler: this.userDefinedHandler,\n });\n this.addWriteableElementSlots();\n await this.onBeforeRender?.(instance);\n };\n\n private addWriteableElementSlots() {\n this._writeableElementSlots = Object.keys(this._instance.writeableElements);\n }\n\n render() {\n return html`\n <cds-aichat-container\n .config=${this.resolvedConfig}\n .onAfterRender=${this.onAfterRender}\n .onBeforeRender=${this.onBeforeRenderOverride}\n .element=${this}\n >\n ${this._writeableElementSlots.map(\n (slot) => html`<div slot=${slot}><slot name=${slot}></slot></div>`,\n )}\n ${this._userDefinedSlotNames.map(\n (slot) => html`<div slot=${slot}><slot name=${slot}></slot></div>`,\n )}\n </cds-aichat-container>\n `;\n }\n}\n\n/**\n * Attributes interface for the cds-aichat-custom-element web component.\n * This interface extends {@link CdsAiChatContainerAttributes} and {@link PublicConfig} with additional component-specific props,\n * flattening all config properties as top-level properties for better TypeScript IntelliSense.\n *\n * @category Web component\n */\ninterface CdsAiChatCustomElementAttributes extends PublicConfig {\n /**\n * This function is called before the render function of Carbon AI Chat is called. This function can return a Promise\n * which will cause Carbon AI Chat to wait for it before rendering.\n */\n onBeforeRender?: (instance: ChatInstance) => Promise<void> | void;\n\n /**\n * This function is called after the render function of Carbon AI Chat is called.\n */\n onAfterRender?: (instance: ChatInstance) => Promise<void> | void;\n\n /**\n * An optional listener for \"view:change\" events. Such a listener is required when using a custom element in order\n * to control the visibility of the Carbon AI Chat main window. If no callback is provided here, a default one will be\n * used that injects styling into the app that will show and hide the Carbon AI Chat main window and also change the\n * size of the custom element so it doesn't take up space when the main window is closed.\n *\n * You can provide a different callback here if you want custom behavior such as an animation when the main window\n * is opened or closed.\n *\n * Note that this function can only be provided before Carbon AI Chat is loaded. After Carbon AI Chat is loaded, the event\n * handler will not be updated.\n */\n onViewChange?: (event: BusEventViewChange, instance: ChatInstance) => void;\n}\n\nexport { CdsAiChatCustomElementAttributes };\n\nexport default ChatCustomElement;\n"],"names":["ChatCustomElement","ChatCustomElement_1","LitElement","constructor","this","_userDefinedSlotNames","_writeableElementSlots","defaultViewChangeHandler","event","newViewState","mainWindow","classList","remove","add","userDefinedHandler","slot","data","includes","onBeforeRenderOverride","async","instance","_instance","onViewPreChange","on","type","BusEventType","VIEW_PRE_CHANGE","handler","VIEW_CHANGE","onViewChange","USER_DEFINED_RESPONSE","CHUNK_USER_DEFINED_RESPONSE","addWriteableElementSlots","onBeforeRender","createRenderRoot","root","super","adoptedStyleSheets","hideSheet","resolvedConfig","baseConfig","config","onError","undefined","openChatByDefault","disclaimer","disableCustomElementMobileEnhancements","debug","exposeServiceManagerForTesting","injectCarbonTheme","serviceDeskFactory","serviceDesk","shouldTakeFocusIfOpensAutomatically","namespace","enableFocusTrap","shouldSanitizeHTML","header","input","layout","messaging","isReadonly","assistantName","locale","homescreen","launcher","strings","aiDisabled","aiEnabled","Object","keys","writeableElements","render","html","onAfterRender","map","CSSStyleSheet","replaceSync","__decorate","property","attribute","prototype","Boolean","String","converter","fromAttribute","value","v","trim","toLowerCase","falsey","state","carbonElement","ChatCustomElement_default"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyDA,IAAMA,oBAAiBC,sBAAvB,MAAMD,0BAA0BE;EAAhC,WAAAC;;IAuMUC,KAAAC,wBAAkC;IAGlCD,KAAAE,yBAAmC;IAKnCF,KAAAG,2BAA4BC;MAClC,IAAIA,MAAMC,aAAaC,YAAY;QACjCN,KAAKO,UAAUC,OAAO;AACxB,aAAO;QACLR,KAAKO,UAAUE,IAAI;AACrB;;IAGMT,KAAAU,qBACNN;MAEA,OAAMO,QAAWP,MAAMQ;MACvB,KAAKZ,KAAKC,sBAAsBY,SAASF,OAAO;QAC9CX,KAAKC,wBAAwB,KAAID,KAAKC,uBAAuBU;AAC/D;;IAyFMX,KAAAc,yBAAyBC,MAAOC;MACtChB,KAAKiB,YAAYD;MACjB,IAAIhB,KAAKkB,iBAAiB;QACxBlB,KAAKiB,UAAUE,GAAG;UAChBC,MAAMC,aAAaC;UACnBC,SAASvB,KAAKkB;;AAElB;MACAlB,KAAKiB,UAAUE,GAAG;QAChBC,MAAMC,aAAaG;QACnBD,SAASvB,KAAKyB,gBAAgBzB,K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