@carbon/ai-chat 0.1.6 → 0.1.7-alpha0

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 (144) hide show
  1. package/dist/cjs/{cds-aichat-internal.js → AppContainer.js} +615 -7203
  2. package/dist/cjs/Carousel.js +24 -16
  3. package/dist/cjs/Chat.js +813 -805
  4. package/dist/cjs/GenesysMessengerServiceDesk.js +60 -52
  5. package/dist/cjs/HumanAgentServiceImpl.js +103 -95
  6. package/dist/cjs/NiceDFOServiceDesk.js +56 -48
  7. package/dist/cjs/PDFViewerContainer.js +58 -149
  8. package/dist/cjs/ReactPlayer.js +2 -2
  9. package/dist/cjs/SFServiceDesk.js +66 -58
  10. package/dist/cjs/ServiceDeskImpl.js +2 -2
  11. package/dist/cjs/Table.js +457 -341
  12. package/dist/cjs/ZendeskServiceDesk.js +36 -28
  13. package/dist/cjs/_node-resolve_empty.js +2 -2
  14. package/dist/cjs/agentActions.js +5 -5
  15. package/dist/cjs/aiChatEntry.js +163 -144
  16. package/dist/cjs/anonymousUserIDStorage.js +8 -8
  17. package/dist/cjs/ar-dz.js +4 -4
  18. package/dist/cjs/ar-kw.js +4 -4
  19. package/dist/cjs/ar-ly.js +4 -4
  20. package/dist/cjs/ar-ma.js +4 -4
  21. package/dist/cjs/ar-sa.js +4 -4
  22. package/dist/cjs/ar-tn.js +4 -4
  23. package/dist/cjs/ar.js +4 -4
  24. package/dist/cjs/ar2.js +2 -2
  25. package/dist/cjs/cds-aichat-container.js +111 -23
  26. package/dist/cjs/cds-aichat-custom-element.js +42 -30
  27. package/dist/cjs/cs.js +4 -4
  28. package/dist/cjs/cs2.js +2 -2
  29. package/dist/cjs/de-at.js +4 -4
  30. package/dist/cjs/de-ch.js +4 -4
  31. package/dist/cjs/de.js +4 -4
  32. package/dist/cjs/de2.js +2 -2
  33. package/dist/cjs/en-au.js +4 -4
  34. package/dist/cjs/en-ca.js +4 -4
  35. package/dist/cjs/en-gb.js +4 -4
  36. package/dist/cjs/en-ie.js +4 -4
  37. package/dist/cjs/en-il.js +4 -4
  38. package/dist/cjs/en-nz.js +4 -4
  39. package/dist/cjs/es-do.js +4 -4
  40. package/dist/cjs/es-us.js +4 -4
  41. package/dist/cjs/es.js +4 -4
  42. package/dist/cjs/es2.js +2 -2
  43. package/dist/cjs/export.js +3 -3
  44. package/dist/cjs/export.legacy.js +3 -3
  45. package/dist/cjs/fontUtils.js +2 -2
  46. package/dist/cjs/fr-ca.js +4 -4
  47. package/dist/cjs/fr-ch.js +4 -4
  48. package/dist/cjs/fr.js +4 -4
  49. package/dist/cjs/fr2.js +2 -2
  50. package/dist/cjs/highlight_js.js +2 -2
  51. package/dist/cjs/it-ch.js +4 -4
  52. package/dist/cjs/it.js +4 -4
  53. package/dist/cjs/it2.js +2 -2
  54. package/dist/cjs/ja.js +4 -4
  55. package/dist/cjs/ja2.js +2 -2
  56. package/dist/cjs/ko.js +4 -4
  57. package/dist/cjs/ko2.js +2 -2
  58. package/dist/cjs/markdown.js +2362 -14
  59. package/dist/cjs/mockServiceDesk.js +42 -34
  60. package/dist/cjs/nl.js +4 -4
  61. package/dist/cjs/nl2.js +2 -2
  62. package/dist/cjs/pt-br.js +4 -4
  63. package/dist/cjs/pt-br2.js +2 -2
  64. package/dist/cjs/pt.js +4 -4
  65. package/dist/cjs/render.js +18 -10
  66. package/dist/cjs/zh-cn.js +4 -4
  67. package/dist/cjs/zh-tw.js +4 -4
  68. package/dist/cjs/zh-tw2.js +2 -2
  69. package/dist/cjs/zh.js +2 -2
  70. package/dist/es/{cds-aichat-internal.js → AppContainer.js} +1117 -7671
  71. package/dist/es/Carousel.js +16 -8
  72. package/dist/es/Chat.js +16 -8
  73. package/dist/es/GenesysMessengerServiceDesk.js +16 -8
  74. package/dist/es/HumanAgentServiceImpl.js +16 -8
  75. package/dist/es/NiceDFOServiceDesk.js +16 -8
  76. package/dist/es/PDFViewerContainer.js +16 -107
  77. package/dist/es/ReactPlayer.js +2 -2
  78. package/dist/es/SFServiceDesk.js +16 -8
  79. package/dist/es/ServiceDeskImpl.js +2 -2
  80. package/dist/es/Table.js +426 -310
  81. package/dist/es/ZendeskServiceDesk.js +16 -8
  82. package/dist/es/_node-resolve_empty.js +2 -2
  83. package/dist/es/agentActions.js +3 -3
  84. package/dist/es/aiChatEntry.js +136 -117
  85. package/dist/es/anonymousUserIDStorage.js +3 -3
  86. package/dist/es/ar-dz.js +3 -3
  87. package/dist/es/ar-kw.js +3 -3
  88. package/dist/es/ar-ly.js +3 -3
  89. package/dist/es/ar-ma.js +3 -3
  90. package/dist/es/ar-sa.js +3 -3
  91. package/dist/es/ar-tn.js +3 -3
  92. package/dist/es/ar.js +3 -3
  93. package/dist/es/ar2.js +2 -2
  94. package/dist/es/cds-aichat-container.js +103 -15
  95. package/dist/es/cds-aichat-custom-element.js +30 -18
  96. package/dist/es/cs.js +3 -3
  97. package/dist/es/cs2.js +2 -2
  98. package/dist/es/de-at.js +3 -3
  99. package/dist/es/de-ch.js +3 -3
  100. package/dist/es/de.js +3 -3
  101. package/dist/es/de2.js +2 -2
  102. package/dist/es/en-au.js +3 -3
  103. package/dist/es/en-ca.js +3 -3
  104. package/dist/es/en-gb.js +3 -3
  105. package/dist/es/en-ie.js +3 -3
  106. package/dist/es/en-il.js +3 -3
  107. package/dist/es/en-nz.js +3 -3
  108. package/dist/es/es-do.js +3 -3
  109. package/dist/es/es-us.js +3 -3
  110. package/dist/es/es.js +3 -3
  111. package/dist/es/es2.js +2 -2
  112. package/dist/es/export.js +3 -3
  113. package/dist/es/export.legacy.js +3 -3
  114. package/dist/es/fontUtils.js +2 -2
  115. package/dist/es/fr-ca.js +3 -3
  116. package/dist/es/fr-ch.js +3 -3
  117. package/dist/es/fr.js +3 -3
  118. package/dist/es/fr2.js +2 -2
  119. package/dist/es/highlight_js.js +2 -2
  120. package/dist/es/it-ch.js +3 -3
  121. package/dist/es/it.js +3 -3
  122. package/dist/es/it2.js +2 -2
  123. package/dist/es/ja.js +3 -3
  124. package/dist/es/ja2.js +2 -2
  125. package/dist/es/ko.js +3 -3
  126. package/dist/es/ko2.js +2 -2
  127. package/dist/es/markdown.js +2361 -15
  128. package/dist/es/mockServiceDesk.js +16 -8
  129. package/dist/es/nl.js +3 -3
  130. package/dist/es/nl2.js +2 -2
  131. package/dist/es/pt-br.js +3 -3
  132. package/dist/es/pt-br2.js +2 -2
  133. package/dist/es/pt.js +3 -3
  134. package/dist/es/render.js +17 -9
  135. package/dist/es/zh-cn.js +3 -3
  136. package/dist/es/zh-tw.js +3 -3
  137. package/dist/es/zh-tw2.js +2 -2
  138. package/dist/es/zh.js +2 -2
  139. package/dist/types/aiChatEntry.d.ts +69 -9
  140. package/package.json +27 -14
  141. package/dist/cjs/jstz.min.js +0 -43
  142. package/dist/cjs/markdown_attrs.js +0 -805
  143. package/dist/es/jstz.min.js +0 -41
  144. package/dist/es/markdown_attrs.js +0 -803
@@ -13,36 +13,44 @@ is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND
13
13
  or implied. See the License for the specific language governing permissions and limitations under
14
14
  the License.
15
15
 
16
- @carbon/ai-chat 0.1.6
16
+ @carbon/ai-chat 0.1.7-alpha0
17
17
 
18
- Built: Feb 3 2025 9:58 am -05:00
18
+ Built: Feb 12 2025 9:14 am -05:00
19
19
 
20
20
 
21
21
 
22
22
  */
23
- import { aD as WA_CONSOLE_PREFIX, E as ErrorType, at as isConnectToAgent, y as isEmptyObject, i as MessageResponseTypes, aj as createMessageResponseForText, v as consoleError, ag as sleep } from './cds-aichat-internal.js';
23
+ import { aE as WA_CONSOLE_PREFIX, E as ErrorType, au as isConnectToAgent, G as isEmptyObject, j as MessageResponseTypes, ak as createMessageResponseForText, y as consoleError, ai as sleep } from './AppContainer.js';
24
24
  import { S as ServiceDeskImpl } from './ServiceDeskImpl.js';
25
- import 'lit';
26
- import 'lit/decorators.js';
27
25
  import 'react';
28
- import 'react-dom';
29
26
  import './highlight_js.js';
30
27
  import '@carbon/react';
28
+ import 'classnames';
31
29
  import 'react-intl';
32
30
  import 'react-redux';
31
+ import 'tabbable';
32
+ import '@carbon/icons-react';
33
33
  import './markdown.js';
34
- import './markdown_attrs.js';
34
+ import 'tslib';
35
+ import 'lit';
36
+ import 'lit/decorators.js';
35
37
  import '@carbon/web-components/es/components/button/index.js';
36
38
  import '@carbon/web-components/es/components/overflow-menu/index.js';
37
39
  import 'lit/directives/unsafe-html.js';
40
+ import 'prop-types';
38
41
  import '@carbon/web-components/es/components/slug/index.js';
39
42
  import '@carbon/web-components/es/components/popover/defs.js';
40
43
  import '@carbon/web-components/es/components/slug/defs.js';
44
+ import '@floating-ui/react';
45
+ import 'react-dom';
41
46
  import '@carbon/web-components/es/components/slug/slug-action-button.js';
42
47
  import '@carbon/web-components/es/components/slug/slug.js';
48
+ import '@carbon/web-components/es/components/inline-loading/index.js';
49
+ import '@carbon/icon-helpers';
50
+ import '@carbon/icons';
51
+ import 'lit/directives/unsafe-svg.js';
43
52
  import '@carbon/web-components/es/components/textarea/index.js';
44
53
  import '@carbon/web-components/es/components/icon-button/index.js';
45
- import 'lit/directives/unsafe-svg.js';
46
54
  import '@carbon/web-components/es/components/tag/index.js';
47
55
  import '@carbon/web-components/es/components/chat-button/index.js';
48
56
  import '@carbon/web-components/es/components/button/button.js';
@@ -13,9 +13,9 @@ is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND
13
13
  or implied. See the License for the specific language governing permissions and limitations under
14
14
  the License.
15
15
 
16
- @carbon/ai-chat 0.1.6
16
+ @carbon/ai-chat 0.1.7-alpha0
17
17
 
18
- Built: Feb 3 2025 9:58 am -05:00
18
+ Built: Feb 12 2025 9:14 am -05:00
19
19
 
20
20
 
21
21
 
@@ -13,14 +13,14 @@ is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND
13
13
  or implied. See the License for the specific language governing permissions and limitations under
14
14
  the License.
15
15
 
16
- @carbon/ai-chat 0.1.6
16
+ @carbon/ai-chat 0.1.7-alpha0
17
17
 
18
- Built: Feb 3 2025 9:58 am -05:00
18
+ Built: Feb 12 2025 9:14 am -05:00
19
19
 
20
20
 
21
21
 
22
22
  */
23
- import { i as MessageResponseTypes, ac as uuid, ad as UUIDType } from './cds-aichat-internal.js';
23
+ import { j as MessageResponseTypes, ae as uuid, af as UUIDType } from './AppContainer.js';
24
24
 
25
25
  /**
26
26
  *
@@ -13,36 +13,44 @@ is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND
13
13
  or implied. See the License for the specific language governing permissions and limitations under
14
14
  the License.
15
15
 
16
- @carbon/ai-chat 0.1.6
16
+ @carbon/ai-chat 0.1.7-alpha0
17
17
 
18
- Built: Feb 3 2025 9:58 am -05:00
18
+ Built: Feb 12 2025 9:14 am -05:00
19
19
 
20
20
 
21
21
 
22
22
  */
23
- import { _ as __decorate, c as carbonElement, o } from './cds-aichat-internal.js';
24
- export { A as AgentMessageType, a as AgentsOnlineStatus, B as BusEventType, d as ButtonItemKind, b as ButtonItemType, C as CarbonTheme, e as CatastrophicErrorType, p as ChatHeaderObjectType, f as CornersType, g as CustomEventType, E as ErrorType, F as FeedbackInteractionType, h as FileStatusValue, H as HomeScreenBackgroundType, I as IFrameItemDisplayOption, L as LauncherType, M as MessageInputType, i as MessageResponseTypes, j as MessageSendSource, k as MinimizeButtonIconType, O as OnErrorType, l as OptionItemPreference, S as ScreenShareState, T as TourEndReason, m as TourStartReason, V as ViewChangeReason, n as ViewType, W as WriteableElementName } from './cds-aichat-internal.js';
25
- import React__default, { useState, useRef, useMemo, useCallback } from 'react';
26
- import { LitElement, html } from 'lit';
27
- import { property, state } from 'lit/decorators.js';
28
- import 'react-dom';
23
+ import { c as carbonElement, o, A as AppContainerExport } from './AppContainer.js';
24
+ export { a as AgentMessageType, b as AgentsOnlineStatus, B as BusEventType, e as ButtonItemKind, d as ButtonItemType, C as CarbonTheme, f as CatastrophicErrorType, q as ChatHeaderObjectType, g as CornersType, h as CustomEventType, E as ErrorType, F as FeedbackInteractionType, i as FileStatusValue, H as HomeScreenBackgroundType, I as IFrameItemDisplayOption, L as LauncherType, M as MessageInputType, j as MessageResponseTypes, k as MessageSendSource, l as MinimizeButtonIconType, O as OnErrorType, m as OptionItemPreference, S as ScreenShareState, T as TourEndReason, n as TourStartReason, V as ViewChangeReason, p as ViewType, W as WriteableElementName } from './AppContainer.js';
25
+ import { __decorate } from 'tslib';
26
+ import { LitElement, css } from 'lit';
27
+ import React__default, { useRef, useState, useEffect, useCallback, useMemo } from 'react';
28
+ import { createPortal } from 'react-dom';
29
29
  import './highlight_js.js';
30
30
  import '@carbon/react';
31
+ import 'classnames';
31
32
  import 'react-intl';
32
33
  import 'react-redux';
34
+ import 'tabbable';
35
+ import '@carbon/icons-react';
33
36
  import './markdown.js';
34
- import './markdown_attrs.js';
37
+ import 'lit/decorators.js';
35
38
  import '@carbon/web-components/es/components/button/index.js';
36
39
  import '@carbon/web-components/es/components/overflow-menu/index.js';
37
40
  import 'lit/directives/unsafe-html.js';
41
+ import 'prop-types';
38
42
  import '@carbon/web-components/es/components/slug/index.js';
39
43
  import '@carbon/web-components/es/components/popover/defs.js';
40
44
  import '@carbon/web-components/es/components/slug/defs.js';
45
+ import '@floating-ui/react';
41
46
  import '@carbon/web-components/es/components/slug/slug-action-button.js';
42
47
  import '@carbon/web-components/es/components/slug/slug.js';
48
+ import '@carbon/web-components/es/components/inline-loading/index.js';
49
+ import '@carbon/icon-helpers';
50
+ import '@carbon/icons';
51
+ import 'lit/directives/unsafe-svg.js';
43
52
  import '@carbon/web-components/es/components/textarea/index.js';
44
53
  import '@carbon/web-components/es/components/icon-button/index.js';
45
- import 'lit/directives/unsafe-svg.js';
46
54
  import '@carbon/web-components/es/components/tag/index.js';
47
55
  import '@carbon/web-components/es/components/chat-button/index.js';
48
56
  import '@carbon/web-components/es/components/button/button.js';
@@ -63,105 +71,14 @@ import '@carbon/web-components/es/components/layer/index.js';
63
71
  *
64
72
  */
65
73
  /**
66
- * The component adds slots for writeable elements and user_defined responses and then injects the elements for them
67
- * into slots.
74
+ * Status of the chain of thought step.
68
75
  */
69
- let ChatContainerReact = class ChatContainerReact extends LitElement {
70
- constructor() {
71
- super(...arguments);
72
- /**
73
- * The existing array of slots for all user_defined components.
74
- */
75
- this._userDefinedElements = [];
76
- /**
77
- * The existing array of slot names for all writeable elements.
78
- */
79
- this._writeableElementSlots = [];
80
- /**
81
- * Adds the slot attribute to the element for the user_defined response type and then injects it into the component by
82
- * updating this._userDefinedElements;
83
- */
84
- this._userDefinedHandler = (event) => {
85
- // This element already has `slot` as an attribute.
86
- const { element } = event.data;
87
- if (!this._userDefinedElements.includes(element)) {
88
- this._userDefinedElements = [...this._userDefinedElements, element];
89
- }
90
- };
91
- this._onBeforeRenderOverride = (instance) => {
92
- if (instance) {
93
- this._instance = instance;
94
- this._instance.on({ type: "userDefinedResponse" /* BusEventType.USER_DEFINED_RESPONSE */, handler: this._userDefinedHandler });
95
- this._instance.on({ type: "chunk:userDefinedResponse" /* BusEventType.CHUNK_USER_DEFINED_RESPONSE */, handler: this._userDefinedHandler });
96
- this._addWriteableElementSlots();
97
- this.onBeforeRender?.(instance);
98
- }
99
- };
100
- }
101
- _addWriteableElementSlots() {
102
- const writeableElementSlots = [this._instance.customPanels.getPanel().hostElement];
103
- Object.keys(this._instance.writeableElements).forEach(writeableElementKey => {
104
- const element = this._instance.writeableElements[writeableElementKey];
105
- element.setAttribute('slot', writeableElementKey);
106
- writeableElementSlots.push(element);
107
- });
108
- this._writeableElementSlots = writeableElementSlots;
109
- }
110
- createRenderRoot() {
111
- return this;
112
- }
113
- render() {
114
- return html `<style>
115
- cds-aichat-react {
116
- width: 100%;
117
- height: 100%;
118
- }
119
- </style>
120
- <cds-aichat-internal
121
- .config=${this.config}
122
- .onAfterRender=${this.onAfterRender}
123
- .onBeforeRender=${this._onBeforeRenderOverride}
124
- .renderUserDefinedResponse=${this.renderUserDefinedResponse}
125
- .renderWriteableElements=${this.renderWriteableElements}
126
- isReact
127
- .forceReact17Mode=${this.forceReact17Mode}
128
- >
129
- ${this._writeableElementSlots.map(element => html `${element}`)}
130
- ${this._userDefinedElements.map(element => html `${element}`)}
131
- </cds-aichat-internal>`;
132
- }
133
- };
134
- __decorate([
135
- property({ type: Object })
136
- ], ChatContainerReact.prototype, "config", void 0);
137
- __decorate([
138
- property()
139
- ], ChatContainerReact.prototype, "onBeforeRender", void 0);
140
- __decorate([
141
- property()
142
- ], ChatContainerReact.prototype, "onAfterRender", void 0);
143
- __decorate([
144
- property({ type: Boolean })
145
- ], ChatContainerReact.prototype, "forceReact17Mode", void 0);
146
- __decorate([
147
- property()
148
- ], ChatContainerReact.prototype, "renderUserDefinedResponse", void 0);
149
- __decorate([
150
- property({ type: Object })
151
- ], ChatContainerReact.prototype, "renderWriteableElements", void 0);
152
- __decorate([
153
- state()
154
- ], ChatContainerReact.prototype, "_userDefinedElements", void 0);
155
- __decorate([
156
- state()
157
- ], ChatContainerReact.prototype, "_writeableElementSlots", void 0);
158
- __decorate([
159
- state()
160
- ], ChatContainerReact.prototype, "_instance", void 0);
161
- ChatContainerReact = __decorate([
162
- carbonElement('cds-aichat-react')
163
- ], ChatContainerReact);
164
- var ChatContainerReact$1 = ChatContainerReact;
76
+ var ChainOfThoughtStepStatus;
77
+ (function (ChainOfThoughtStepStatus) {
78
+ ChainOfThoughtStepStatus["PROCESSING"] = "processing";
79
+ ChainOfThoughtStepStatus["FAILURE"] = "failure";
80
+ ChainOfThoughtStepStatus["SUCCESS"] = "success";
81
+ })(ChainOfThoughtStepStatus || (ChainOfThoughtStepStatus = {}));
165
82
 
166
83
  /**
167
84
  *
@@ -178,17 +95,118 @@ var ChatContainerReact$1 = ChatContainerReact;
178
95
  *
179
96
  */
180
97
  /**
181
- * This is the React component for people injecting a classic floating web chat. It simply takes properties and
182
- * forwards them into the web component ChatContainer.
98
+ * This component creates a custom element protected by a ShadowRoot to render the React application into. It creates
99
+ * slotted elements for user_defined responses and for writable elements.
100
+ *
101
+ * The corresponding slots are defined within the React application and are rendered in place.
102
+ */
103
+ /**
104
+ * Create a web component to host the React application. We do this so we can provide custom elements and user_defined responses as
105
+ * slotted content so they maintain their own styling in a safe way.
183
106
  */
184
- const CWXChatContainer = o({
107
+ let ChatContainerReact = class ChatContainerReact extends LitElement {
108
+ static { this.styles = css `
109
+ :host {
110
+ width: 100%;
111
+ height: 100%;
112
+ }
113
+ `; }
114
+ };
115
+ ChatContainerReact = __decorate([
116
+ carbonElement('cds-aichat-react')
117
+ ], ChatContainerReact);
118
+ // Wrap the custom element as a React component
119
+ const ReactChatContainer = React__default.memo(o({
185
120
  tagName: 'cds-aichat-react',
186
- elementClass: ChatContainerReact$1,
121
+ elementClass: ChatContainerReact,
187
122
  react: React__default,
188
- });
189
- function ChatContainer({ config, onBeforeRender, onAfterRender, renderUserDefinedResponse, renderWriteableElements, forceReact17Mode, }) {
190
- return (React__default.createElement(CWXChatContainer, { config: config, onBeforeRender: onBeforeRender, onAfterRender: onAfterRender, renderUserDefinedResponse: renderUserDefinedResponse, renderWriteableElements: renderWriteableElements, forceReact17Mode: forceReact17Mode }));
123
+ }));
124
+ /**
125
+ * The ChatContainer controls rendering the React application into the ShadowRoot of the cds-aichat-react web component.
126
+ * It also injects the writeable element and user_defined response slots into said web component.
127
+ */
128
+ function ChatContainer({ onBeforeRender, onAfterRender, config, renderUserDefinedResponse, renderWriteableElements, }) {
129
+ const wrapperRef = useRef(null); // Ref for the React wrapper component
130
+ const [wrapper, setWrapper] = useState(null);
131
+ const [container, setContainer] = useState(null); // Actual element we render the React Portal to in the Shadowroot.
132
+ const [userDefinedElements, setUserDefinedElements] = useState([]);
133
+ const [writeableElementSlots, setWriteableElementSlots] = useState([]);
134
+ const [currentInstance, setCurrentInstance] = useState(null);
135
+ /**
136
+ * Setup the DOM nodes of both the web component to be able to inject slotted content into it, and the element inside the
137
+ * ShadowRoot we will inject our React application into.
138
+ */
139
+ useEffect(() => {
140
+ if (wrapperRef.current) {
141
+ const wrapperElement = wrapperRef.current;
142
+ // We need to check if the element in the ShadowRoot we are render the React application to exists.
143
+ // If it doesn't, we need to create and append it.
144
+ // When the web chat is destroyed (either via a config change or by calling instance.destroy), this element is
145
+ // removed again. When the chat is destroyed the instance is set to null. The useEffect watches the instance
146
+ // value and runs if it changes, re-creating the container element if needed.
147
+ let reactElement = wrapperElement.shadowRoot?.querySelector('.cds--aichat-react-app');
148
+ if (!reactElement) {
149
+ reactElement = document.createElement('div');
150
+ reactElement.classList.add('cds--aichat-react-app');
151
+ wrapperElement.shadowRoot.appendChild(reactElement);
152
+ }
153
+ if (wrapperElement !== wrapper) {
154
+ setWrapper(wrapperElement);
155
+ }
156
+ if (reactElement !== container) {
157
+ setContainer(reactElement);
158
+ }
159
+ }
160
+ }, [container, wrapper, currentInstance]);
161
+ /**
162
+ * Here we write the slotted elements into the wrapper so they are passed into the application to be rendered in their slot.
163
+ */
164
+ useEffect(() => {
165
+ if (wrapper) {
166
+ const combinedNodes = [...userDefinedElements, ...writeableElementSlots];
167
+ const currentNodes = Array.from(wrapper.childNodes);
168
+ const newNodesSet = new Set(combinedNodes);
169
+ // Remove nodes no longer present
170
+ currentNodes.forEach(node => {
171
+ if (!newNodesSet.has(node)) {
172
+ wrapper.removeChild(node);
173
+ }
174
+ });
175
+ // Append new nodes that aren't already in the container
176
+ combinedNodes.forEach(node => {
177
+ if (!currentNodes.includes(node)) {
178
+ wrapper.appendChild(node);
179
+ }
180
+ });
181
+ }
182
+ }, [userDefinedElements, writeableElementSlots, wrapper]);
183
+ const userDefinedHandler = useCallback((event) => {
184
+ const { element } = event.data;
185
+ setUserDefinedElements(previousUserDefinedElements => [...previousUserDefinedElements, element]);
186
+ }, []);
187
+ const onBeforeRenderOverride = useCallback((instance) => {
188
+ if (instance) {
189
+ const addWriteableElementSlots = () => {
190
+ const slots = Object.entries(instance.writeableElements).map(writeableElement => {
191
+ const [key, element] = writeableElement;
192
+ element.setAttribute('slot', key); // Assign slot attributes dynamically
193
+ return element;
194
+ });
195
+ slots.push(instance.customPanels.getPanel().hostElement);
196
+ setWriteableElementSlots(slots);
197
+ };
198
+ instance.on({ type: "userDefinedResponse" /* BusEventType.USER_DEFINED_RESPONSE */, handler: userDefinedHandler });
199
+ instance.on({ type: "chunk:userDefinedResponse" /* BusEventType.CHUNK_USER_DEFINED_RESPONSE */, handler: userDefinedHandler });
200
+ addWriteableElementSlots();
201
+ onBeforeRender?.(instance);
202
+ }
203
+ }, [onBeforeRender, userDefinedHandler]);
204
+ return (React__default.createElement(React__default.Fragment, null,
205
+ React__default.createElement(ReactChatContainer, { ref: wrapperRef }),
206
+ container &&
207
+ createPortal(React__default.createElement(AppContainerExport, { config: config, renderUserDefinedResponse: renderUserDefinedResponse, renderWriteableElements: renderWriteableElements, onBeforeRender: onBeforeRenderOverride, onAfterRender: onAfterRender, container: container, setParentInstance: setCurrentInstance }), container)));
191
208
  }
209
+ const ChatContainerExport = React__default.memo(ChatContainer);
192
210
 
193
211
  /**
194
212
  *
@@ -237,7 +255,8 @@ function ChatCustomElement({ config, onBeforeRender, onAfterRender, renderUserDe
237
255
  instance.on({ type: "view:change" /* BusEventType.VIEW_CHANGE */, handler: onViewChange || defaultViewChangeHandler });
238
256
  return onBeforeRender?.(instance);
239
257
  }, [onBeforeRender, onViewChange, customElement]);
240
- return (React__default.createElement("div", { className: className, id: id, ref: setCustomElement }, customElement && (React__default.createElement(ChatContainer, { config: useConfig, onBeforeRender: onBeforeRenderOverride, onAfterRender: onAfterRender, renderUserDefinedResponse: renderUserDefinedResponse, renderWriteableElements: renderWriteableElements }))));
258
+ return (React__default.createElement("div", { className: className, id: id, ref: setCustomElement }, customElement && (React__default.createElement(ChatContainerExport, { config: useConfig, onBeforeRender: onBeforeRenderOverride, onAfterRender: onAfterRender, renderUserDefinedResponse: renderUserDefinedResponse, renderWriteableElements: renderWriteableElements }))));
241
259
  }
260
+ const ChatCustomElementExport = React__default.memo(ChatCustomElement);
242
261
 
243
- export { ChatContainer, ChatCustomElement };
262
+ export { ChainOfThoughtStepStatus, ChatContainerExport as ChatContainer, ChatCustomElementExport as ChatCustomElement };
@@ -13,14 +13,14 @@ is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND
13
13
  or implied. See the License for the specific language governing permissions and limitations under
14
14
  the License.
15
15
 
16
- @carbon/ai-chat 0.1.6
16
+ @carbon/ai-chat 0.1.7-alpha0
17
17
 
18
- Built: Feb 3 2025 9:58 am -05:00
18
+ Built: Feb 12 2025 9:14 am -05:00
19
19
 
20
20
 
21
21
 
22
22
  */
23
- import { bE as IS_SESSION_STORAGE, e7 as isSecureHost, ac as uuid, ad as UUIDType } from './cds-aichat-internal.js';
23
+ import { bE as IS_SESSION_STORAGE, e7 as isSecureHost, ae as uuid, af as UUIDType } from './AppContainer.js';
24
24
 
25
25
  /*! js-cookie v3.0.5 | MIT */
26
26
  /* eslint-disable no-var */
package/dist/es/ar-dz.js CHANGED
@@ -13,15 +13,15 @@ is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND
13
13
  or implied. See the License for the specific language governing permissions and limitations under
14
14
  the License.
15
15
 
16
- @carbon/ai-chat 0.1.6
16
+ @carbon/ai-chat 0.1.7-alpha0
17
17
 
18
- Built: Feb 3 2025 9:58 am -05:00
18
+ Built: Feb 12 2025 9:14 am -05:00
19
19
 
20
20
 
21
21
 
22
22
  */
23
23
  import { g as getDefaultExportFromCjs, c as commonjsGlobal } from './highlight_js.js';
24
- import { e6 as dayjs_minExports } from './cds-aichat-internal.js';
24
+ import { e6 as dayjs_minExports } from './AppContainer.js';
25
25
 
26
26
  function _mergeNamespaces(n, m) {
27
27
  m.forEach(function (e) {
package/dist/es/ar-kw.js CHANGED
@@ -13,15 +13,15 @@ is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND
13
13
  or implied. See the License for the specific language governing permissions and limitations under
14
14
  the License.
15
15
 
16
- @carbon/ai-chat 0.1.6
16
+ @carbon/ai-chat 0.1.7-alpha0
17
17
 
18
- Built: Feb 3 2025 9:58 am -05:00
18
+ Built: Feb 12 2025 9:14 am -05:00
19
19
 
20
20
 
21
21
 
22
22
  */
23
23
  import { g as getDefaultExportFromCjs, c as commonjsGlobal } from './highlight_js.js';
24
- import { e6 as dayjs_minExports } from './cds-aichat-internal.js';
24
+ import { e6 as dayjs_minExports } from './AppContainer.js';
25
25
 
26
26
  function _mergeNamespaces(n, m) {
27
27
  m.forEach(function (e) {
package/dist/es/ar-ly.js CHANGED
@@ -13,15 +13,15 @@ is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND
13
13
  or implied. See the License for the specific language governing permissions and limitations under
14
14
  the License.
15
15
 
16
- @carbon/ai-chat 0.1.6
16
+ @carbon/ai-chat 0.1.7-alpha0
17
17
 
18
- Built: Feb 3 2025 9:58 am -05:00
18
+ Built: Feb 12 2025 9:14 am -05:00
19
19
 
20
20
 
21
21
 
22
22
  */
23
23
  import { g as getDefaultExportFromCjs, c as commonjsGlobal } from './highlight_js.js';
24
- import { e6 as dayjs_minExports } from './cds-aichat-internal.js';
24
+ import { e6 as dayjs_minExports } from './AppContainer.js';
25
25
 
26
26
  function _mergeNamespaces(n, m) {
27
27
  m.forEach(function (e) {
package/dist/es/ar-ma.js CHANGED
@@ -13,15 +13,15 @@ is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND
13
13
  or implied. See the License for the specific language governing permissions and limitations under
14
14
  the License.
15
15
 
16
- @carbon/ai-chat 0.1.6
16
+ @carbon/ai-chat 0.1.7-alpha0
17
17
 
18
- Built: Feb 3 2025 9:58 am -05:00
18
+ Built: Feb 12 2025 9:14 am -05:00
19
19
 
20
20
 
21
21
 
22
22
  */
23
23
  import { g as getDefaultExportFromCjs, c as commonjsGlobal } from './highlight_js.js';
24
- import { e6 as dayjs_minExports } from './cds-aichat-internal.js';
24
+ import { e6 as dayjs_minExports } from './AppContainer.js';
25
25
 
26
26
  function _mergeNamespaces(n, m) {
27
27
  m.forEach(function (e) {
package/dist/es/ar-sa.js CHANGED
@@ -13,15 +13,15 @@ is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND
13
13
  or implied. See the License for the specific language governing permissions and limitations under
14
14
  the License.
15
15
 
16
- @carbon/ai-chat 0.1.6
16
+ @carbon/ai-chat 0.1.7-alpha0
17
17
 
18
- Built: Feb 3 2025 9:58 am -05:00
18
+ Built: Feb 12 2025 9:14 am -05:00
19
19
 
20
20
 
21
21
 
22
22
  */
23
23
  import { g as getDefaultExportFromCjs, c as commonjsGlobal } from './highlight_js.js';
24
- import { e6 as dayjs_minExports } from './cds-aichat-internal.js';
24
+ import { e6 as dayjs_minExports } from './AppContainer.js';
25
25
 
26
26
  function _mergeNamespaces(n, m) {
27
27
  m.forEach(function (e) {
package/dist/es/ar-tn.js CHANGED
@@ -13,15 +13,15 @@ is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND
13
13
  or implied. See the License for the specific language governing permissions and limitations under
14
14
  the License.
15
15
 
16
- @carbon/ai-chat 0.1.6
16
+ @carbon/ai-chat 0.1.7-alpha0
17
17
 
18
- Built: Feb 3 2025 9:58 am -05:00
18
+ Built: Feb 12 2025 9:14 am -05:00
19
19
 
20
20
 
21
21
 
22
22
  */
23
23
  import { g as getDefaultExportFromCjs, c as commonjsGlobal } from './highlight_js.js';
24
- import { e6 as dayjs_minExports } from './cds-aichat-internal.js';
24
+ import { e6 as dayjs_minExports } from './AppContainer.js';
25
25
 
26
26
  function _mergeNamespaces(n, m) {
27
27
  m.forEach(function (e) {
package/dist/es/ar.js CHANGED
@@ -13,15 +13,15 @@ is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND
13
13
  or implied. See the License for the specific language governing permissions and limitations under
14
14
  the License.
15
15
 
16
- @carbon/ai-chat 0.1.6
16
+ @carbon/ai-chat 0.1.7-alpha0
17
17
 
18
- Built: Feb 3 2025 9:58 am -05:00
18
+ Built: Feb 12 2025 9:14 am -05:00
19
19
 
20
20
 
21
21
 
22
22
  */
23
23
  import { g as getDefaultExportFromCjs, c as commonjsGlobal } from './highlight_js.js';
24
- import { e6 as dayjs_minExports } from './cds-aichat-internal.js';
24
+ import { e6 as dayjs_minExports } from './AppContainer.js';
25
25
 
26
26
  function _mergeNamespaces(n, m) {
27
27
  m.forEach(function (e) {
package/dist/es/ar2.js CHANGED
@@ -13,9 +13,9 @@ is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND
13
13
  or implied. See the License for the specific language governing permissions and limitations under
14
14
  the License.
15
15
 
16
- @carbon/ai-chat 0.1.6
16
+ @carbon/ai-chat 0.1.7-alpha0
17
17
 
18
- Built: Feb 3 2025 9:58 am -05:00
18
+ Built: Feb 12 2025 9:14 am -05:00
19
19
 
20
20
 
21
21