@carbon/ai-chat 1.13.0 → 1.14.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 (31) hide show
  1. package/dist/css/chat-explainability-popover.css +161 -0
  2. package/dist/es/aiChatEntry.js +14 -2
  3. package/dist/es/aiChatEntry.js.map +1 -1
  4. package/dist/es/chat.ChatAppEntry.js +113 -21
  5. package/dist/es/chat.ChatAppEntry.js.map +1 -1
  6. package/dist/es/chat.index.js +581 -0
  7. package/dist/es/chat.index.js.map +1 -0
  8. package/dist/es/chat.languageUtils.js +2 -0
  9. package/dist/es/chat.languageUtils.js.map +1 -1
  10. package/dist/es/web-components/cds-aichat-container/index.js +10 -500
  11. package/dist/es/web-components/cds-aichat-container/index.js.map +1 -1
  12. package/dist/es/web-components/cds-aichat-custom-element/index.js +19 -227
  13. package/dist/es/web-components/cds-aichat-custom-element/index.js.map +1 -1
  14. package/dist/es-custom/aiChatEntry.js +14 -2
  15. package/dist/es-custom/aiChatEntry.js.map +1 -1
  16. package/dist/es-custom/chat.ChatAppEntry.js +113 -21
  17. package/dist/es-custom/chat.ChatAppEntry.js.map +1 -1
  18. package/dist/es-custom/chat.index.js +581 -0
  19. package/dist/es-custom/chat.index.js.map +1 -0
  20. package/dist/es-custom/chat.languageUtils.js +2 -0
  21. package/dist/es-custom/chat.languageUtils.js.map +1 -1
  22. package/dist/es-custom/web-components/cds-aichat-container/index.js +10 -500
  23. package/dist/es-custom/web-components/cds-aichat-container/index.js.map +1 -1
  24. package/dist/es-custom/web-components/cds-aichat-custom-element/index.js +19 -227
  25. package/dist/es-custom/web-components/cds-aichat-custom-element/index.js.map +1 -1
  26. package/dist/scss/_chat-explainability-popover.scss +154 -0
  27. package/dist/types/aiChatEntry.d.ts +2 -2
  28. package/dist/types/{serverEntry-CU81SMOz.d.ts → serverEntry-mONw-M8N.d.ts} +206 -47
  29. package/dist/types/serverEntry.d.ts +1 -1
  30. package/package.json +5 -5
  31. package/telemetry.yml +3 -24
@@ -0,0 +1,581 @@
1
+ import { __decorate } from "tslib";
2
+
3
+ import { css, LitElement, html } from "lit";
4
+
5
+ import { property, state } from "lit/decorators.js";
6
+
7
+ import React from "react";
8
+
9
+ import { createRoot } from "react-dom/client";
10
+
11
+ import { C as ChatAppEntry } from "./chat.ChatAppEntry.js";
12
+
13
+ import { carbonElement } from "@carbon/ai-chat-components/es/globals/decorators/index.js";
14
+
15
+ import { B as BusEventType } from "./chat.languageUtils.js";
16
+
17
+ let ChatContainerInternal = class ChatContainerInternal extends LitElement {
18
+ firstUpdated() {
19
+ if (this.config) {
20
+ this.renderReactApp();
21
+ }
22
+ }
23
+ updated(changedProperties) {
24
+ if (this.config && (changedProperties.has("config") || changedProperties.has("strings") || changedProperties.has("serviceDeskFactory") || changedProperties.has("serviceDesk") || changedProperties.has("onBeforeRender") || changedProperties.has("onAfterRender") || changedProperties.has("element"))) {
25
+ this.renderReactApp();
26
+ }
27
+ }
28
+ async renderReactApp() {
29
+ const container = this.ensureReactRoot();
30
+ this.root.render(React.createElement(ChatAppEntry, {
31
+ config: this.config,
32
+ strings: this.strings,
33
+ serviceDeskFactory: this.serviceDeskFactory,
34
+ serviceDesk: this.serviceDesk,
35
+ onBeforeRender: this.onBeforeRender,
36
+ onAfterRender: this.onAfterRender,
37
+ container,
38
+ element: this.element
39
+ }));
40
+ }
41
+ ensureReactRoot() {
42
+ if (!this.reactContainer) {
43
+ const container = document.createElement("div");
44
+ container.classList.add("cds-aichat--react-app");
45
+ this.shadowRoot.appendChild(container);
46
+ this.reactContainer = container;
47
+ }
48
+ if (!this.root) {
49
+ this.root = createRoot(this.reactContainer);
50
+ }
51
+ return this.reactContainer;
52
+ }
53
+ disconnectedCallback() {
54
+ this.root?.unmount();
55
+ super.disconnectedCallback();
56
+ }
57
+ };
58
+
59
+ ChatContainerInternal.styles = css`
60
+ :host {
61
+ display: block;
62
+ width: 100%;
63
+ height: 100%;
64
+ box-sizing: border-box;
65
+ z-index: var(--cds-aichat-z-index, auto);
66
+ }
67
+ `;
68
+
69
+ __decorate([ property({
70
+ type: Object
71
+ }) ], ChatContainerInternal.prototype, "config", void 0);
72
+
73
+ __decorate([ property({
74
+ type: Object
75
+ }) ], ChatContainerInternal.prototype, "strings", void 0);
76
+
77
+ __decorate([ property({
78
+ attribute: false
79
+ }) ], ChatContainerInternal.prototype, "serviceDeskFactory", void 0);
80
+
81
+ __decorate([ property({
82
+ type: Object
83
+ }) ], ChatContainerInternal.prototype, "serviceDesk", void 0);
84
+
85
+ __decorate([ property({
86
+ type: HTMLElement
87
+ }) ], ChatContainerInternal.prototype, "element", void 0);
88
+
89
+ __decorate([ property() ], ChatContainerInternal.prototype, "onBeforeRender", void 0);
90
+
91
+ __decorate([ property() ], ChatContainerInternal.prototype, "onAfterRender", void 0);
92
+
93
+ ChatContainerInternal = __decorate([ carbonElement("cds-aichat-internal") ], ChatContainerInternal);
94
+
95
+ const aiEnabledConverter = {
96
+ fromAttribute: value => {
97
+ if (value === null) {
98
+ return undefined;
99
+ }
100
+ const v = String(value).trim().toLowerCase();
101
+ const falsey = v === "false" || v === "0" || v === "off" || v === "no";
102
+ return !falsey;
103
+ }
104
+ };
105
+
106
+ const FLATTENED_PUBLIC_CONFIG_FIELDS = [ {
107
+ name: "onError",
108
+ options: {
109
+ attribute: false
110
+ }
111
+ }, {
112
+ name: "openChatByDefault",
113
+ options: {
114
+ type: Boolean,
115
+ attribute: "open-chat-by-default"
116
+ }
117
+ }, {
118
+ name: "disclaimer",
119
+ options: {
120
+ type: Object
121
+ }
122
+ }, {
123
+ name: "disableCustomElementMobileEnhancements",
124
+ options: {
125
+ type: Boolean,
126
+ attribute: "disable-custom-element-mobile-enhancements"
127
+ }
128
+ }, {
129
+ name: "debug",
130
+ options: {
131
+ type: Boolean
132
+ }
133
+ }, {
134
+ name: "exposeServiceManagerForTesting",
135
+ options: {
136
+ type: Boolean,
137
+ attribute: "expose-service-manager-for-testing"
138
+ }
139
+ }, {
140
+ name: "injectCarbonTheme",
141
+ options: {
142
+ type: String,
143
+ attribute: "inject-carbon-theme"
144
+ }
145
+ }, {
146
+ name: "aiEnabled",
147
+ options: {
148
+ attribute: "ai-enabled",
149
+ converter: aiEnabledConverter
150
+ },
151
+ resolveManually: true
152
+ }, {
153
+ name: "serviceDeskFactory",
154
+ options: {
155
+ attribute: false
156
+ }
157
+ }, {
158
+ name: "serviceDesk",
159
+ options: {
160
+ type: Object,
161
+ attribute: "service-desk"
162
+ }
163
+ }, {
164
+ name: "shouldTakeFocusIfOpensAutomatically",
165
+ options: {
166
+ type: Boolean,
167
+ attribute: "should-take-focus-if-opens-automatically"
168
+ }
169
+ }, {
170
+ name: "namespace",
171
+ options: {
172
+ type: String
173
+ }
174
+ }, {
175
+ name: "shouldSanitizeHTML",
176
+ options: {
177
+ type: Boolean,
178
+ attribute: "should-sanitize-html"
179
+ }
180
+ }, {
181
+ name: "header",
182
+ options: {
183
+ type: Object
184
+ }
185
+ }, {
186
+ name: "history",
187
+ options: {
188
+ type: Object
189
+ }
190
+ }, {
191
+ name: "layout",
192
+ options: {
193
+ type: Object
194
+ }
195
+ }, {
196
+ name: "messaging",
197
+ options: {
198
+ type: Object
199
+ }
200
+ }, {
201
+ name: "isReadonly",
202
+ options: {
203
+ type: Boolean,
204
+ attribute: "is-readonly"
205
+ }
206
+ }, {
207
+ name: "persistFeedback",
208
+ options: {
209
+ type: Boolean,
210
+ attribute: "persist-feedback"
211
+ }
212
+ }, {
213
+ name: "assistantName",
214
+ options: {
215
+ type: String,
216
+ attribute: "assistant-name"
217
+ }
218
+ }, {
219
+ name: "assistantAvatarUrl",
220
+ options: {
221
+ type: String
222
+ }
223
+ }, {
224
+ name: "locale",
225
+ options: {
226
+ type: String
227
+ }
228
+ }, {
229
+ name: "homescreen",
230
+ options: {
231
+ type: Object
232
+ }
233
+ }, {
234
+ name: "launcher",
235
+ options: {
236
+ type: Object
237
+ }
238
+ }, {
239
+ name: "input",
240
+ options: {
241
+ type: Object
242
+ }
243
+ }, {
244
+ name: "upload",
245
+ options: {
246
+ attribute: false,
247
+ type: Object
248
+ }
249
+ }, {
250
+ name: "strings",
251
+ options: {
252
+ type: Object
253
+ }
254
+ }, {
255
+ name: "keyboardShortcuts",
256
+ options: {
257
+ type: Object
258
+ }
259
+ } ];
260
+
261
+ function resolveFlattenedConfig(source) {
262
+ const resolved = {
263
+ ...source.config ?? {}
264
+ };
265
+ for (const field of FLATTENED_PUBLIC_CONFIG_FIELDS) {
266
+ if ("resolveManually" in field && field.resolveManually) {
267
+ continue;
268
+ }
269
+ const value = source[field.name];
270
+ if (value !== undefined) {
271
+ resolved[field.name] = value;
272
+ }
273
+ }
274
+ if (source.aiDisabled === true) {
275
+ resolved.aiEnabled = false;
276
+ } else if (source.aiEnabled !== undefined) {
277
+ resolved.aiEnabled = source.aiEnabled;
278
+ }
279
+ return resolved;
280
+ }
281
+
282
+ function buildFlattenedProperties() {
283
+ const properties = {
284
+ config: {
285
+ attribute: false,
286
+ type: Object
287
+ },
288
+ aiDisabled: {
289
+ type: Boolean,
290
+ attribute: "ai-disabled"
291
+ }
292
+ };
293
+ for (const field of FLATTENED_PUBLIC_CONFIG_FIELDS) {
294
+ properties[field.name] = field.options;
295
+ }
296
+ return properties;
297
+ }
298
+
299
+ class FlattenedConfigElement extends LitElement {
300
+ get resolvedConfig() {
301
+ return resolveFlattenedConfig(this);
302
+ }
303
+ }
304
+
305
+ FlattenedConfigElement.properties = buildFlattenedProperties();
306
+
307
+ let ChatContainer = class ChatContainer extends FlattenedConfigElement {
308
+ constructor() {
309
+ super(...arguments);
310
+ this._userDefinedSlotNames = [];
311
+ this._customFooterSlotNames = [];
312
+ this._writeableElementSlots = [];
313
+ this._userDefinedStateBySlot = {};
314
+ this._customFooterStateBySlot = {};
315
+ this._callbackElements = new Map;
316
+ this._callbackFooterElements = new Map;
317
+ this.userDefinedHandler = event => {
318
+ const {slot} = event.data;
319
+ if (!this._userDefinedSlotNames.includes(slot)) {
320
+ this._userDefinedSlotNames = [ ...this._userDefinedSlotNames, slot ];
321
+ }
322
+ };
323
+ this.customFooterHandler = event => {
324
+ const {slotName} = event.data;
325
+ if (!this._customFooterSlotNames.includes(slotName)) {
326
+ this._customFooterSlotNames = [ ...this._customFooterSlotNames, slotName ];
327
+ }
328
+ };
329
+ this.enhancedCustomFooterHandler = event => {
330
+ const {slotName, message, messageItem, additionalData} = event.data;
331
+ if (!this._customFooterSlotNames.includes(slotName)) {
332
+ this._customFooterSlotNames = [ ...this._customFooterSlotNames, slotName ];
333
+ }
334
+ this._customFooterStateBySlot = {
335
+ ...this._customFooterStateBySlot,
336
+ [slotName]: {
337
+ slotName,
338
+ message,
339
+ messageItem,
340
+ additionalData
341
+ }
342
+ };
343
+ };
344
+ this.enhancedUserDefinedHandler = event => {
345
+ const {slot} = event.data;
346
+ if (!this._userDefinedSlotNames.includes(slot)) {
347
+ this._userDefinedSlotNames = [ ...this._userDefinedSlotNames, slot ];
348
+ }
349
+ this._userDefinedStateBySlot = {
350
+ ...this._userDefinedStateBySlot,
351
+ [slot]: {
352
+ fullMessage: event.data.fullMessage,
353
+ messageItem: event.data.message
354
+ }
355
+ };
356
+ };
357
+ this.enhancedUserDefinedChunkHandler = event => {
358
+ const {slot, chunk} = event.data;
359
+ if (!this._userDefinedSlotNames.includes(slot)) {
360
+ this._userDefinedSlotNames = [ ...this._userDefinedSlotNames, slot ];
361
+ }
362
+ if ("complete_item" in chunk) {
363
+ this._userDefinedStateBySlot = {
364
+ ...this._userDefinedStateBySlot,
365
+ [slot]: {
366
+ messageItem: chunk.complete_item
367
+ }
368
+ };
369
+ } else if ("partial_item" in chunk) {
370
+ const existing = this._userDefinedStateBySlot[slot];
371
+ this._userDefinedStateBySlot = {
372
+ ...this._userDefinedStateBySlot,
373
+ [slot]: {
374
+ ...existing,
375
+ partialItems: [ ...existing?.partialItems ?? [], chunk.partial_item ]
376
+ }
377
+ };
378
+ }
379
+ };
380
+ this.restartHandler = () => {
381
+ this._userDefinedStateBySlot = {};
382
+ this._userDefinedSlotNames = [];
383
+ for (const el of this._callbackElements.values()) {
384
+ el.remove();
385
+ }
386
+ this._callbackElements.clear();
387
+ if (this.renderCustomMessageFooter) {
388
+ this._customFooterStateBySlot = {};
389
+ this._customFooterSlotNames = [];
390
+ for (const el of this._callbackFooterElements.values()) {
391
+ el.remove();
392
+ }
393
+ this._callbackFooterElements.clear();
394
+ }
395
+ };
396
+ this.onBeforeRenderOverride = async instance => {
397
+ this._instance = instance;
398
+ if (this.onViewPreChange) {
399
+ this._instance.on({
400
+ type: BusEventType.VIEW_PRE_CHANGE,
401
+ handler: this.onViewPreChange
402
+ });
403
+ }
404
+ if (this.onViewChange) {
405
+ this._instance.on({
406
+ type: BusEventType.VIEW_CHANGE,
407
+ handler: this.onViewChange
408
+ });
409
+ }
410
+ if (this.renderUserDefinedResponse) {
411
+ this._instance.on({
412
+ type: BusEventType.USER_DEFINED_RESPONSE,
413
+ handler: this.enhancedUserDefinedHandler
414
+ });
415
+ this._instance.on({
416
+ type: BusEventType.CHUNK_USER_DEFINED_RESPONSE,
417
+ handler: this.enhancedUserDefinedChunkHandler
418
+ });
419
+ } else {
420
+ this._instance.on({
421
+ type: BusEventType.USER_DEFINED_RESPONSE,
422
+ handler: this.userDefinedHandler
423
+ });
424
+ this._instance.on({
425
+ type: BusEventType.CHUNK_USER_DEFINED_RESPONSE,
426
+ handler: this.userDefinedHandler
427
+ });
428
+ }
429
+ this._instance.on({
430
+ type: BusEventType.CUSTOM_FOOTER_SLOT,
431
+ handler: this.renderCustomMessageFooter ? this.enhancedCustomFooterHandler : this.customFooterHandler
432
+ });
433
+ if (this.renderUserDefinedResponse || this.renderCustomMessageFooter) {
434
+ this._instance.on({
435
+ type: BusEventType.RESTART_CONVERSATION,
436
+ handler: this.restartHandler
437
+ });
438
+ }
439
+ this.addWriteableElementSlots();
440
+ this.attachWriteableElements();
441
+ await (this.onBeforeRender?.(instance));
442
+ };
443
+ }
444
+ syncCallbackRenderedElements() {
445
+ for (const [slot, slotState] of Object.entries(this._userDefinedStateBySlot)) {
446
+ const newContent = this.renderUserDefinedResponse?.(slotState, this._instance) ?? null;
447
+ if (!newContent) {
448
+ const existing = this._callbackElements.get(slot);
449
+ if (existing) {
450
+ existing.remove();
451
+ this._callbackElements.delete(slot);
452
+ }
453
+ continue;
454
+ }
455
+ let wrapper = this._callbackElements.get(slot);
456
+ if (!wrapper) {
457
+ wrapper = document.createElement("div");
458
+ wrapper.setAttribute("slot", slot);
459
+ this._callbackElements.set(slot, wrapper);
460
+ this.appendChild(wrapper);
461
+ }
462
+ wrapper.replaceChildren(newContent);
463
+ }
464
+ for (const [slot, el] of this._callbackElements.entries()) {
465
+ if (!(slot in this._userDefinedStateBySlot)) {
466
+ el.remove();
467
+ this._callbackElements.delete(slot);
468
+ }
469
+ }
470
+ }
471
+ syncCallbackRenderedFooterElements() {
472
+ for (const [slotName, slotState] of Object.entries(this._customFooterStateBySlot)) {
473
+ const newContent = this.renderCustomMessageFooter?.(slotState, this._instance) ?? null;
474
+ if (!newContent) {
475
+ const existing = this._callbackFooterElements.get(slotName);
476
+ if (existing) {
477
+ existing.remove();
478
+ this._callbackFooterElements.delete(slotName);
479
+ }
480
+ continue;
481
+ }
482
+ let wrapper = this._callbackFooterElements.get(slotName);
483
+ if (!wrapper) {
484
+ wrapper = document.createElement("div");
485
+ wrapper.setAttribute("slot", slotName);
486
+ this._callbackFooterElements.set(slotName, wrapper);
487
+ this.appendChild(wrapper);
488
+ }
489
+ wrapper.replaceChildren(newContent);
490
+ }
491
+ for (const [slotName, el] of this._callbackFooterElements.entries()) {
492
+ if (!(slotName in this._customFooterStateBySlot)) {
493
+ el.remove();
494
+ this._callbackFooterElements.delete(slotName);
495
+ }
496
+ }
497
+ }
498
+ addWriteableElementSlots() {
499
+ const writeableElementSlots = [];
500
+ Object.keys(this._instance.writeableElements).forEach(writeableElementKey => {
501
+ writeableElementSlots.push(writeableElementKey);
502
+ });
503
+ this._writeableElementSlots = writeableElementSlots;
504
+ }
505
+ attachWriteableElements() {
506
+ const writeableElements = this._instance?.writeableElements;
507
+ if (!writeableElements) {
508
+ return;
509
+ }
510
+ Object.entries(writeableElements).forEach(([slot, element]) => {
511
+ if (!element) {
512
+ return;
513
+ }
514
+ element.setAttribute("slot", slot);
515
+ if (!element.isConnected) {
516
+ this.appendChild(element);
517
+ }
518
+ });
519
+ }
520
+ render() {
521
+ if (this.renderUserDefinedResponse) {
522
+ this.syncCallbackRenderedElements();
523
+ }
524
+ if (this.renderCustomMessageFooter) {
525
+ this.syncCallbackRenderedFooterElements();
526
+ }
527
+ return html`<cds-aichat-internal
528
+ .config=${this.resolvedConfig}
529
+ .onAfterRender=${this.onAfterRender}
530
+ .onBeforeRender=${this.onBeforeRenderOverride}
531
+ .element=${this.element}
532
+ >
533
+ ${this._writeableElementSlots.map(slot => html`<slot name=${slot} slot=${slot}></slot>`)}
534
+ ${this._userDefinedSlotNames.map(slot => html`<slot name=${slot} slot=${slot}></slot>`)}
535
+ ${this.renderCustomMessageFooter ? this._customFooterSlotNames.map(slot => html`<slot name=${slot} slot=${slot}></slot>`) : this._customFooterSlotNames.map(slot => html`<div slot=${slot}><slot name=${slot}></slot></div>`)}
536
+ </cds-aichat-internal>`;
537
+ }
538
+ };
539
+
540
+ __decorate([ property({
541
+ type: HTMLElement
542
+ }) ], ChatContainer.prototype, "element", void 0);
543
+
544
+ __decorate([ property({
545
+ attribute: false
546
+ }) ], ChatContainer.prototype, "onBeforeRender", void 0);
547
+
548
+ __decorate([ property({
549
+ attribute: false
550
+ }) ], ChatContainer.prototype, "onAfterRender", void 0);
551
+
552
+ __decorate([ property() ], ChatContainer.prototype, "onViewPreChange", void 0);
553
+
554
+ __decorate([ property() ], ChatContainer.prototype, "onViewChange", void 0);
555
+
556
+ __decorate([ property({
557
+ attribute: false
558
+ }) ], ChatContainer.prototype, "renderUserDefinedResponse", void 0);
559
+
560
+ __decorate([ property({
561
+ attribute: false
562
+ }) ], ChatContainer.prototype, "renderCustomMessageFooter", void 0);
563
+
564
+ __decorate([ state() ], ChatContainer.prototype, "_userDefinedSlotNames", void 0);
565
+
566
+ __decorate([ state() ], ChatContainer.prototype, "_customFooterSlotNames", void 0);
567
+
568
+ __decorate([ state() ], ChatContainer.prototype, "_writeableElementSlots", void 0);
569
+
570
+ __decorate([ state() ], ChatContainer.prototype, "_instance", void 0);
571
+
572
+ __decorate([ state() ], ChatContainer.prototype, "_userDefinedStateBySlot", void 0);
573
+
574
+ __decorate([ state() ], ChatContainer.prototype, "_customFooterStateBySlot", void 0);
575
+
576
+ ChatContainer = __decorate([ carbonElement("cds-aichat-container") ], ChatContainer);
577
+
578
+ var ChatContainer_default = ChatContainer;
579
+
580
+ export { ChatContainer_default as C, FlattenedConfigElement as F };
581
+ //# sourceMappingURL=chat.index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chat.index.js","sources":["../../../../src/web-components/cds-aichat-container/cds-aichat-internal.tsx","../../../../src/web-components/shared/flattenedPublicConfig.ts","../../../../src/web-components/shared/FlattenedConfigElement.ts","../../../../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 { css, LitElement, PropertyValues } from \"lit\";\nimport { property } from \"lit/decorators.js\";\nimport React from \"react\";\nimport { createRoot, Root } from \"react-dom/client\";\n\nimport ChatAppEntry 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 static styles = css`\n :host {\n display: block;\n width: 100%;\n height: 100%;\n box-sizing: border-box;\n z-index: var(--cds-aichat-z-index, auto);\n }\n `;\n\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 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 <ChatAppEntry\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. 2026\n *\n * This source code is licensed under the Apache-2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * @license\n */\n\n/**\n * Single source of truth for the {@link PublicConfig} fields that the\n * `cds-aichat-container` and `cds-aichat-custom-element` web components expose\n * as flattened top-level attributes/properties.\n *\n * Both components build their Lit reactive properties and reconstruct a\n * `PublicConfig` from this one table, so every config field is declared in\n * exactly one place. Adding a field to {@link PublicConfig} requires adding a\n * single entry here — the compile-time guard at the bottom of this file fails\n * the build until that happens.\n */\n\nimport type { ComplexAttributeConverter, PropertyDeclaration } from \"lit\";\n\nimport { PublicConfig } from \"../../types/config/PublicConfig\";\n\n/**\n * A single flattened-config field: a {@link PublicConfig} key plus the exact\n * Lit property options used to expose it on the web components.\n */\nexport interface FlattenedConfigFieldEntry {\n /** The {@link PublicConfig} key this entry maps to. */\n readonly name: keyof PublicConfig;\n /** The Lit property declaration options for this field. */\n readonly options: PropertyDeclaration;\n /**\n * When true, {@link resolveFlattenedConfig} skips this field in its generic\n * loop because its resolution rule is non-uniform. Only `aiEnabled` uses\n * this — it is resolved together with the synthetic `aiDisabled` opt-out.\n */\n readonly resolveManually?: boolean;\n}\n\n/**\n * Custom converter for the `ai-enabled` attribute so HTML authors can write\n * `ai-enabled=\"false\" | \"0\" | \"off\" | \"no\"`, while an absent attribute stays\n * `undefined` (so defaults apply further down the stack).\n */\nconst aiEnabledConverter: ComplexAttributeConverter<boolean | undefined> = {\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/**\n * Every {@link PublicConfig} field exposed as a flattened attribute/property\n * on the web components, with the exact Lit property options for each.\n *\n * `as const satisfies` keeps the `name` values as string literals (required by\n * the exhaustiveness guard below) while type-checking every entry.\n */\nexport const FLATTENED_PUBLIC_CONFIG_FIELDS = [\n { name: \"onError\", options: { attribute: false } },\n {\n name: \"openChatByDefault\",\n options: { type: Boolean, attribute: \"open-chat-by-default\" },\n },\n { name: \"disclaimer\", options: { type: Object } },\n {\n name: \"disableCustomElementMobileEnhancements\",\n options: {\n type: Boolean,\n attribute: \"disable-custom-element-mobile-enhancements\",\n },\n },\n { name: \"debug\", options: { type: Boolean } },\n {\n name: \"exposeServiceManagerForTesting\",\n options: { type: Boolean, attribute: \"expose-service-manager-for-testing\" },\n },\n {\n name: \"injectCarbonTheme\",\n options: { type: String, attribute: \"inject-carbon-theme\" },\n },\n {\n name: \"aiEnabled\",\n options: { attribute: \"ai-enabled\", converter: aiEnabledConverter },\n resolveManually: true,\n },\n { name: \"serviceDeskFactory\", options: { attribute: false } },\n {\n name: \"serviceDesk\",\n options: { type: Object, attribute: \"service-desk\" },\n },\n {\n name: \"shouldTakeFocusIfOpensAutomatically\",\n options: {\n type: Boolean,\n attribute: \"should-take-focus-if-opens-automatically\",\n },\n },\n { name: \"namespace\", options: { type: String } },\n {\n name: \"shouldSanitizeHTML\",\n options: { type: Boolean, attribute: \"should-sanitize-html\" },\n },\n { name: \"header\", options: { type: Object } },\n { name: \"history\", options: { type: Object } },\n { name: \"layout\", options: { type: Object } },\n { name: \"messaging\", options: { type: Object } },\n { name: \"isReadonly\", options: { type: Boolean, attribute: \"is-readonly\" } },\n {\n name: \"persistFeedback\",\n options: { type: Boolean, attribute: \"persist-feedback\" },\n },\n {\n name: \"assistantName\",\n options: { type: String, attribute: \"assistant-name\" },\n },\n // Note: no explicit `attribute` — Lit derives `assistantavatarurl`.\n { name: \"assistantAvatarUrl\", options: { type: String } },\n { name: \"locale\", options: { type: String } },\n { name: \"homescreen\", options: { type: Object } },\n { name: \"launcher\", options: { type: Object } },\n { name: \"input\", options: { type: Object } },\n { name: \"upload\", options: { attribute: false, type: Object } },\n { name: \"strings\", options: { type: Object } },\n { name: \"keyboardShortcuts\", options: { type: Object } },\n] as const satisfies readonly FlattenedConfigFieldEntry[];\n\n/**\n * The shape consumed by {@link resolveFlattenedConfig}: any flattened\n * {@link PublicConfig} field, plus the base `config` object and the synthetic\n * `aiDisabled` opt-out. Both web components structurally satisfy this.\n */\nexport interface FlattenedConfigSource extends Partial<PublicConfig> {\n /** Base config object; flattened fields override individual keys on it. */\n config?: PublicConfig;\n /** Synthetic opt-out attribute; when true it forces `aiEnabled` to false. */\n aiDisabled?: boolean;\n}\n\n/**\n * Builds a {@link PublicConfig} from a flattened source by layering each\n * defined flattened field over the base `config` object.\n *\n * Pure and DOM-free so it can be unit tested directly.\n *\n * @param source - The web component (or any object) carrying flattened fields.\n * @returns The reconstructed `PublicConfig`.\n */\nexport function resolveFlattenedConfig(\n source: FlattenedConfigSource,\n): PublicConfig {\n const resolved: PublicConfig = { ...(source.config ?? {}) };\n\n for (const field of FLATTENED_PUBLIC_CONFIG_FIELDS) {\n // aiEnabled is resolved together with aiDisabled below.\n if (\"resolveManually\" in field && field.resolveManually) {\n continue;\n }\n const value = source[field.name];\n if (value !== undefined) {\n (resolved as Record<string, unknown>)[field.name] = value;\n }\n }\n\n // aiEnabled / aiDisabled precedence is non-uniform: an explicit aiDisabled\n // attribute always wins over ai-enabled.\n if (source.aiDisabled === true) {\n resolved.aiEnabled = false;\n } else if (source.aiEnabled !== undefined) {\n resolved.aiEnabled = source.aiEnabled;\n }\n\n return resolved;\n}\n\n/**\n * Compile-time exhaustiveness guard.\n *\n * `_AssertTableCoversPublicConfig` fails to compile unless the set of field\n * names in {@link FLATTENED_PUBLIC_CONFIG_FIELDS} is exactly `keyof\n * PublicConfig`. Adding a field to {@link PublicConfig} without adding it to\n * the table — or vice versa — breaks the build here.\n */\ntype Equals<A, B> =\n (<T>() => T extends A ? 1 : 2) extends <T>() => T extends B ? 1 : 2\n ? true\n : false;\ntype Expect<T extends true> = T;\ntype FlattenedFieldName =\n (typeof FLATTENED_PUBLIC_CONFIG_FIELDS)[number][\"name\"];\n\n// The `_` prefix matches the lint config's varsIgnorePattern; this alias only\n// exists to be type-checked.\ntype _AssertTableCoversPublicConfig = Expect<\n Equals<FlattenedFieldName, keyof PublicConfig>\n>;\n","/*\n * Copyright IBM Corp. 2026\n *\n * This source code is licensed under the Apache-2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * @license\n */\n\n/**\n * Shared Lit base class for the web components that expose a flattened\n * {@link PublicConfig} surface (`cds-aichat-container` and\n * `cds-aichat-custom-element`).\n *\n * It contributes every flattened reactive property from the single\n * {@link FLATTENED_PUBLIC_CONFIG_FIELDS} table and derives `resolvedConfig`\n * from that same table, so each config field is defined in exactly one place.\n */\n\nimport { LitElement } from \"lit\";\nimport type { PropertyDeclaration, PropertyDeclarations } from \"lit\";\n\nimport { PublicConfig } from \"../../types/config/PublicConfig\";\nimport {\n FLATTENED_PUBLIC_CONFIG_FIELDS,\n resolveFlattenedConfig,\n} from \"./flattenedPublicConfig\";\n\n/**\n * Builds the Lit `static properties` object from the shared field table plus\n * the synthetic `config` (base config object) and `aiDisabled` (opt-out)\n * properties.\n */\nfunction buildFlattenedProperties(): PropertyDeclarations {\n const properties: Record<string, PropertyDeclaration> = {\n config: { attribute: false, type: Object },\n aiDisabled: { type: Boolean, attribute: \"ai-disabled\" },\n };\n for (const field of FLATTENED_PUBLIC_CONFIG_FIELDS) {\n properties[field.name] = field.options;\n }\n return properties;\n}\n\n/**\n * Declaration merging gives the instance typed access to `this.history`,\n * `this.debug`, ... without re-listing every {@link PublicConfig} field and\n * without emitting any runtime class field (so nothing shadows the accessors\n * Lit installs from `static properties`).\n */\n// eslint-disable-next-line @typescript-eslint/no-empty-interface\ninterface FlattenedConfigElement extends Partial<PublicConfig> {}\n\n/**\n * Base class contributing all flattened `PublicConfig` reactive properties.\n * Not registered as a custom element — only the concrete subclasses are.\n */\nabstract class FlattenedConfigElement extends LitElement {\n static properties: PropertyDeclarations = buildFlattenedProperties();\n\n /** Base config object. Flattened properties layer on top of this. */\n config?: PublicConfig;\n\n /**\n * Optional explicit opt-out attribute. If present, it wins over `ai-enabled`.\n * Not a {@link PublicConfig} field — it resolves into `config.aiEnabled`.\n */\n aiDisabled?: boolean;\n\n /**\n * The {@link PublicConfig} reconstructed from `config` plus every defined\n * flattened property.\n */\n protected get resolvedConfig(): PublicConfig {\n return resolveFlattenedConfig(this);\n }\n}\n\nexport { FlattenedConfigElement };\n","/*\n * Copyright IBM Corp. 2025, 2026\n *\n * This source code is licensed under the Apache-2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * @license\n */\n\n/**\n * This is the exposed web component for a basic floating chat.\n */\n\nimport \"./cds-aichat-internal\";\n\nimport { html } from \"lit\";\nimport { property, state } from \"lit/decorators.js\";\n\nimport { carbonElement } from \"@carbon/ai-chat-components/es/globals/decorators/index.js\";\nimport { PublicConfig } from \"../../types/config/PublicConfig\";\nimport { FlattenedConfigElement } from \"../shared/FlattenedConfigElement\";\nimport { ChatInstance } from \"../../types/instance/ChatInstance\";\nimport {\n BusEventChunkUserDefinedResponse,\n BusEventCustomFooterSlot,\n BusEventType,\n BusEventUserDefinedResponse,\n BusEventViewChange,\n BusEventViewPreChange,\n} from \"../../types/events/eventBusTypes\";\nimport type {\n RenderCustomMessageFooterState,\n RenderUserDefinedState,\n WCRenderCustomMessageFooter,\n WCRenderUserDefinedResponse,\n} from \"../../types/component/ChatContainer\";\n\n/**\n * The cds-aichat-container managing creating slotted elements for user_defined responses, custom message footers, 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 FlattenedConfigElement {\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 * Called before a view change (the chat opening or closing). Async — return a\n * Promise to defer the view change until it resolves.\n *\n * This is an opt-in observation hook. Unlike `cds-aichat-custom-element`, the\n * container has no wrapping element to size, so no default visibility\n * behavior runs when this property is omitted.\n */\n @property()\n onViewPreChange?: (event: BusEventViewPreChange) => Promise<void> | void;\n\n /**\n * Called when a view change (the chat opening or closing) is complete.\n *\n * This is an opt-in observation hook. Unlike `cds-aichat-custom-element`, the\n * container has no wrapping element to size, so no default visibility\n * behavior runs when this property is omitted.\n */\n @property()\n onViewChange?: (event: BusEventViewChange, instance: ChatInstance) => void;\n\n /**\n * Optional callback to render user defined responses. When provided, the library manages all event listening,\n * slot tracking, streaming state, and element lifecycle. The callback receives the accumulated state and should\n * return an HTMLElement or null.\n *\n * When this property is not set, the existing event + manual slot approach continues to work.\n */\n @property({ attribute: false })\n renderUserDefinedResponse?: WCRenderUserDefinedResponse;\n\n /**\n * Optional callback to render custom message footers. When provided, the library manages all event listening,\n * slot tracking, and element lifecycle. The callback receives the accumulated state and should\n * return an HTMLElement or null.\n *\n * When this property is not set, the existing event + manual slot approach continues to work.\n */\n @property({ attribute: false })\n renderCustomMessageFooter?: WCRenderCustomMessageFooter;\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 custom footers.\n */\n @state()\n _customFooterSlotNames: 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 * Accumulated state per slot for user_defined responses when renderUserDefinedResponse is provided.\n */\n @state()\n _userDefinedStateBySlot: Record<string, RenderUserDefinedState> = {};\n\n /**\n * Accumulated state per slot for custom message footers when renderCustomMessageFooter is provided.\n */\n @state()\n _customFooterStateBySlot: Record<string, RenderCustomMessageFooterState> = {};\n\n /**\n * Tracks the wrapper elements created by the callback rendering path.\n */\n private _callbackElements = new Map<string, HTMLElement>();\n\n /**\n * Tracks the wrapper elements created by the custom-footer callback rendering path.\n */\n private _callbackFooterElements = new Map<string, HTMLElement>();\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 /**\n * Adds the slot attribute to the element for the custom_footer_slot type and then injects it into the component by\n * updating this._customFooterSlotNames;\n */\n customFooterHandler = (event: BusEventCustomFooterSlot) => {\n // This element already has `slotName` as an attribute.\n const { slotName } = event.data;\n if (!this._customFooterSlotNames.includes(slotName)) {\n this._customFooterSlotNames = [...this._customFooterSlotNames, slotName];\n }\n };\n\n /**\n * Enhanced handler for CUSTOM_FOOTER_SLOT when the renderCustomMessageFooter callback is provided.\n * Tracks both slot names and the full per-slot state used by the callback rendering path.\n */\n private enhancedCustomFooterHandler = (event: BusEventCustomFooterSlot) => {\n const { slotName, message, messageItem, additionalData } = event.data;\n if (!this._customFooterSlotNames.includes(slotName)) {\n this._customFooterSlotNames = [...this._customFooterSlotNames, slotName];\n }\n this._customFooterStateBySlot = {\n ...this._customFooterStateBySlot,\n [slotName]: {\n slotName,\n message,\n messageItem,\n additionalData: additionalData as Record<string, unknown> | undefined,\n },\n };\n };\n\n /**\n * Enhanced handler for USER_DEFINED_RESPONSE when renderUserDefinedResponse callback is provided.\n * Tracks both slot names and full message state per slot.\n */\n private enhancedUserDefinedHandler = (event: BusEventUserDefinedResponse) => {\n const { slot } = event.data;\n if (!this._userDefinedSlotNames.includes(slot)) {\n this._userDefinedSlotNames = [...this._userDefinedSlotNames, slot];\n }\n this._userDefinedStateBySlot = {\n ...this._userDefinedStateBySlot,\n [slot]: {\n fullMessage: event.data.fullMessage,\n messageItem: event.data.message,\n },\n };\n };\n\n /**\n * Enhanced handler for CHUNK_USER_DEFINED_RESPONSE when renderUserDefinedResponse callback is provided.\n * Handles both complete_item and partial_item chunks, accumulating state per slot.\n */\n private enhancedUserDefinedChunkHandler = (\n event: BusEventChunkUserDefinedResponse,\n ) => {\n const { slot, chunk } = event.data;\n if (!this._userDefinedSlotNames.includes(slot)) {\n this._userDefinedSlotNames = [...this._userDefinedSlotNames, slot];\n }\n\n if (\"complete_item\" in chunk) {\n this._userDefinedStateBySlot = {\n ...this._userDefinedStateBySlot,\n [slot]: { messageItem: chunk.complete_item },\n };\n } else if (\"partial_item\" in chunk) {\n const existing = this._userDefinedStateBySlot[slot];\n this._userDefinedStateBySlot = {\n ...this._userDefinedStateBySlot,\n [slot]: {\n ...existing,\n partialItems: [...(existing?.partialItems ?? []), chunk.partial_item],\n },\n };\n }\n };\n\n /**\n * Handles RESTART_CONVERSATION when the renderUserDefinedResponse and/or renderCustomMessageFooter\n * callback is provided. Clears all accumulated state and removes callback-rendered elements from the DOM.\n *\n * The custom-footer cleanup is guarded by renderCustomMessageFooter so the legacy footer passthrough\n * path (which the host clears itself) is left untouched.\n */\n private restartHandler = () => {\n this._userDefinedStateBySlot = {};\n this._userDefinedSlotNames = [];\n for (const el of this._callbackElements.values()) {\n el.remove();\n }\n this._callbackElements.clear();\n\n if (this.renderCustomMessageFooter) {\n this._customFooterStateBySlot = {};\n this._customFooterSlotNames = [];\n for (const el of this._callbackFooterElements.values()) {\n el.remove();\n }\n this._callbackFooterElements.clear();\n }\n };\n\n /**\n * Synchronizes callback-rendered elements in the light DOM based on current state.\n * Called from render() when renderUserDefinedResponse is provided.\n */\n private syncCallbackRenderedElements() {\n for (const [slot, slotState] of Object.entries(\n this._userDefinedStateBySlot,\n )) {\n const newContent =\n this.renderUserDefinedResponse?.(slotState, this._instance) ?? null;\n\n if (!newContent) {\n const existing = this._callbackElements.get(slot);\n if (existing) {\n existing.remove();\n this._callbackElements.delete(slot);\n }\n continue;\n }\n\n let wrapper = this._callbackElements.get(slot);\n if (!wrapper) {\n wrapper = document.createElement(\"div\");\n wrapper.setAttribute(\"slot\", slot);\n this._callbackElements.set(slot, wrapper);\n this.appendChild(wrapper);\n }\n\n wrapper.replaceChildren(newContent);\n }\n\n // Clean up wrappers for slots that no longer exist in state\n for (const [slot, el] of this._callbackElements.entries()) {\n if (!(slot in this._userDefinedStateBySlot)) {\n el.remove();\n this._callbackElements.delete(slot);\n }\n }\n }\n\n /**\n * Synchronizes custom-footer callback-rendered elements in the light DOM based on current state.\n * Called from render() when renderCustomMessageFooter is provided. Direct analogue of\n * syncCallbackRenderedElements().\n */\n private syncCallbackRenderedFooterElements() {\n for (const [slotName, slotState] of Object.entries(\n this._customFooterStateBySlot,\n )) {\n const newContent =\n this.renderCustomMessageFooter?.(slotState, this._instance) ?? null;\n\n if (!newContent) {\n const existing = this._callbackFooterElements.get(slotName);\n if (existing) {\n existing.remove();\n this._callbackFooterElements.delete(slotName);\n }\n continue;\n }\n\n let wrapper = this._callbackFooterElements.get(slotName);\n if (!wrapper) {\n wrapper = document.createElement(\"div\");\n wrapper.setAttribute(\"slot\", slotName);\n this._callbackFooterElements.set(slotName, wrapper);\n this.appendChild(wrapper);\n }\n\n wrapper.replaceChildren(newContent);\n }\n\n // Clean up wrappers for slots that no longer exist in state\n for (const [slotName, el] of this._callbackFooterElements.entries()) {\n if (!(slotName in this._customFooterStateBySlot)) {\n el.remove();\n this._callbackFooterElements.delete(slotName);\n }\n }\n }\n\n onBeforeRenderOverride = async (instance: ChatInstance) => {\n this._instance = instance;\n\n // Opt-in view-change observation hooks. The float container manages its own\n // visibility, so there is no default handler — a prop is only subscribed\n // when the consumer provides it.\n if (this.onViewPreChange) {\n this._instance.on({\n type: BusEventType.VIEW_PRE_CHANGE,\n handler: this.onViewPreChange,\n });\n }\n if (this.onViewChange) {\n this._instance.on({\n type: BusEventType.VIEW_CHANGE,\n handler: this.onViewChange,\n });\n }\n\n if (this.renderUserDefinedResponse) {\n // Enhanced path: library manages full state for callback rendering\n this._instance.on({\n type: BusEventType.USER_DEFINED_RESPONSE,\n handler: this.enhancedUserDefinedHandler,\n });\n this._instance.on({\n type: BusEventType.CHUNK_USER_DEFINED_RESPONSE,\n handler: this.enhancedUserDefinedChunkHandler,\n });\n } else {\n // Legacy path: container only tracks slot names\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 }\n\n // Enhanced path manages full per-slot state for callback rendering; the\n // legacy path only tracks slot names for manual slotting.\n this._instance.on({\n type: BusEventType.CUSTOM_FOOTER_SLOT,\n handler: this.renderCustomMessageFooter\n ? this.enhancedCustomFooterHandler\n : this.customFooterHandler,\n });\n\n // A single RESTART_CONVERSATION subscription clears whichever callback\n // paths are active. Registered once so the handler does not fire twice\n // when both callbacks are provided.\n if (this.renderUserDefinedResponse || this.renderCustomMessageFooter) {\n this._instance.on({\n type: BusEventType.RESTART_CONVERSATION,\n handler: this.restartHandler,\n });\n }\n\n this.addWriteableElementSlots();\n this.attachWriteableElements();\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 private attachWriteableElements() {\n const writeableElements = this._instance?.writeableElements;\n if (!writeableElements) {\n return;\n }\n\n Object.entries(writeableElements).forEach(([slot, element]) => {\n if (!element) {\n return;\n }\n\n element.setAttribute(\"slot\", slot);\n\n if (!element.isConnected) {\n this.appendChild(element);\n }\n });\n }\n\n /**\n * Renders the template while passing in class functionality\n */\n render() {\n if (this.renderUserDefinedResponse) {\n this.syncCallbackRenderedElements();\n }\n if (this.renderCustomMessageFooter) {\n this.syncCallbackRenderedFooterElements();\n }\n\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`<slot name=${slot} slot=${slot}></slot>`,\n )}\n ${this._userDefinedSlotNames.map(\n (slot) => html`<slot name=${slot} slot=${slot}></slot>`,\n )}\n ${this.renderCustomMessageFooter\n ? this._customFooterSlotNames.map(\n (slot) => html`<slot name=${slot} slot=${slot}></slot>`,\n )\n : this._customFooterSlotNames.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 /**\n * Called before a view change (the chat opening or closing). Async — return a Promise to defer the view\n * change until it resolves. This is an opt-in observation hook with no default visibility behavior.\n */\n onViewPreChange?: (event: BusEventViewPreChange) => Promise<void> | void;\n\n /**\n * Called when a view change (the chat opening or closing) is complete. This is an opt-in observation hook\n * with no default visibility behavior.\n */\n onViewChange?: (event: BusEventViewChange, instance: ChatInstance) => void;\n\n /**\n * Optional callback to render user defined responses. When provided, the library manages all event listening,\n * slot tracking, streaming state, and element lifecycle.\n */\n renderUserDefinedResponse?: WCRenderUserDefinedResponse;\n\n /**\n * Optional callback to render custom message footers. When provided, the library manages all event listening,\n * slot tracking, and element lifecycle. When omitted, the legacy event + manual slot approach continues to work.\n */\n renderCustomMessageFooter?: WCRenderCustomMessageFooter;\n}\n\nexport { CdsAiChatContainerAttributes };\nexport default ChatContainer;\n"],"names":["ChatContainerInternal","LitElement","firstUpdated","this","config","renderReactApp","updated","changedProperties","has","container","ensureReactRoot","root","render","React","ChatAppEntry","strings","serviceDeskFactory","serviceDesk","onBeforeRender","onAfterRender","element","reactContainer","document","createElement","classList","add","shadowRoot","appendChild","createRoot","disconnectedCallback","unmount","super","styles","css","__decorate","property","type","Object","prototype","attribute","HTMLElement","carbonElement","aiEnabledConverter","fromAttribute","value","undefined","v","String","trim","toLowerCase","falsey","FLATTENED_PUBLIC_CONFIG_FIELDS","name","options","Boolean","converter","resolveManually","resolveFlattenedConfig","source","resolved","field","aiDisabled","aiEnabled","buildFlattenedProperties","properties","FlattenedConfigElement","resolvedConfig","ChatContainer","constructor","_userDefinedSlotNames","_customFooterSlotNames","_writeableElementSlots","_userDefinedStateBySlot","_customFooterStateBySlot","_callbackElements","Map","_callbackFooterElements","userDefinedHandler","event","slot","data","includes","customFooterHandler","slotName","enhancedCustomFooterHandler","message","messageItem","additionalData","enhancedUserDefinedHandler","fullMessage","enhancedUserDefinedChunkHandler","chunk","complete_item","existing","partialItems","partial_item","restartHandler","el","values","remove","clear","renderCustomMessageFooter","onBeforeRenderOverride","async","instance","_instance","onViewPreChange","on","BusEventType","VIEW_PRE_CHANGE","handler","onViewChange","VIEW_CHANGE","renderUserDefinedResponse","USER_DEFINED_RESPONSE","CHUNK_USER_DEFINED_RESPONSE","CUSTOM_FOOTER_SLOT","RESTART_CONVERSATION","addWriteableElementSlots","attachWriteableElements","syncCallbackRenderedElements","slotState","entries","newContent","get","delete","wrapper","setAttribute","set","replaceChildren","syncCallbackRenderedFooterElements","writeableElementSlots","keys","writeableElements","forEach","writeableElementKey","push","isConnected","html","map","state","ChatContainer_default"],"mappings":";;;;;;;;;;;;;;;;AAgCA,IAAMA,wBAAN,MAAMA,8BAA8BC;EAoDlC,YAAAC;IACE,IAAIC,KAAKC,QAAQ;MACfD,KAAKE;AACP;AACF;EAEA,OAAAC,CAAQC;IAEN,IACEJ,KAAKC,WACJG,kBAAkBC,IAAI,aACrBD,kBAAkBC,IAAI,cACtBD,kBAAkBC,IAAI,yBACtBD,kBAAkBC,IAAI,kBACtBD,kBAAkBC,IAAI,qBACtBD,kBAAkBC,IAAI,oBACtBD,kBAAkBC,IAAI,aACxB;MACAL,KAAKE;AACP;AACF;EAYA,oBAAMA;IACJ,MAAMI,YAAYN,KAAKO;IAEvBP,KAAKQ,KAAKC,OACRC,oBAACC,cAAY;MACXV,QAAQD,KAAKC;MACbW,SAASZ,KAAKY;MACdC,oBAAoBb,KAAKa;MACzBC,aAAad,KAAKc;MAClBC,gBAAgBf,KAAKe;MACrBC,eAAehB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