igniteui-webcomponents 6.2.0 → 6.3.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (323) hide show
  1. package/components/accordion/accordion.js +1 -4
  2. package/components/accordion/accordion.js.map +1 -1
  3. package/components/button/themes/button/button.base.css.js +1 -1
  4. package/components/button/themes/button/button.base.css.js.map +1 -1
  5. package/components/button/themes/button/shared/button.common.css.js +1 -1
  6. package/components/button/themes/button/shared/button.common.css.js.map +1 -1
  7. package/components/button/themes/button/shared/button.fluent.css.js +1 -1
  8. package/components/button/themes/button/shared/button.fluent.css.js.map +1 -1
  9. package/components/button/themes/button/shared/button.indigo.css.js +1 -1
  10. package/components/button/themes/button/shared/button.indigo.css.js.map +1 -1
  11. package/components/button/themes/icon-button/icon-button.base.css.js +1 -1
  12. package/components/button/themes/icon-button/icon-button.base.css.js.map +1 -1
  13. package/components/button/themes/icon-button/shared/icon-button.bootstrap.css.js +1 -1
  14. package/components/button/themes/icon-button/shared/icon-button.bootstrap.css.js.map +1 -1
  15. package/components/button/themes/icon-button/shared/icon-button.fluent.css.js +1 -1
  16. package/components/button/themes/icon-button/shared/icon-button.fluent.css.js.map +1 -1
  17. package/components/button/themes/icon-button/shared/icon-button.indigo.css.js +1 -1
  18. package/components/button/themes/icon-button/shared/icon-button.indigo.css.js.map +1 -1
  19. package/components/button/themes/icon-button/shared/icon-button.material.css.js +1 -1
  20. package/components/button/themes/icon-button/shared/icon-button.material.css.js.map +1 -1
  21. package/components/button-group/themes/shared/button/button.bootstrap.css.js +1 -1
  22. package/components/button-group/themes/shared/button/button.bootstrap.css.js.map +1 -1
  23. package/components/button-group/themes/shared/button/button.common.css.js +1 -1
  24. package/components/button-group/themes/shared/button/button.common.css.js.map +1 -1
  25. package/components/button-group/themes/shared/button/button.indigo.css.js +1 -1
  26. package/components/button-group/themes/shared/button/button.indigo.css.js.map +1 -1
  27. package/components/calendar/days-view/days-view.js +1 -3
  28. package/components/calendar/days-view/days-view.js.map +1 -1
  29. package/components/calendar/months-view/months-view.js +1 -3
  30. package/components/calendar/months-view/months-view.js.map +1 -1
  31. package/components/calendar/themes/year-month-view.base.css.js +1 -1
  32. package/components/calendar/themes/year-month-view.base.css.js.map +1 -1
  33. package/components/calendar/years-view/years-view.js +1 -3
  34. package/components/calendar/years-view/years-view.js.map +1 -1
  35. package/components/carousel/carousel.js +0 -3
  36. package/components/carousel/carousel.js.map +1 -1
  37. package/components/chat/assets/file.png +0 -0
  38. package/components/chat/assets/json.png +0 -0
  39. package/components/chat/assets/link.png +0 -0
  40. package/components/chat/chat-input.d.ts +54 -0
  41. package/components/chat/chat-input.js +137 -0
  42. package/components/chat/chat-input.js.map +1 -0
  43. package/components/chat/chat-message-list.d.ts +70 -0
  44. package/components/chat/chat-message-list.js +89 -0
  45. package/components/chat/chat-message-list.js.map +1 -0
  46. package/components/chat/chat-message.d.ts +47 -0
  47. package/components/chat/chat-message.js +70 -0
  48. package/components/chat/chat-message.js.map +1 -0
  49. package/components/chat/chat-renderer.d.ts +14 -0
  50. package/components/chat/chat-renderer.js +39 -0
  51. package/components/chat/chat-renderer.js.map +1 -0
  52. package/components/chat/chat-state.d.ts +250 -0
  53. package/components/chat/chat-state.js +538 -0
  54. package/components/chat/chat-state.js.map +1 -0
  55. package/components/chat/chat.d.ts +177 -0
  56. package/components/chat/chat.js +250 -0
  57. package/components/chat/chat.js.map +1 -0
  58. package/components/chat/markdown-renderer.d.ts +72 -0
  59. package/components/chat/markdown-renderer.js +71 -0
  60. package/components/chat/markdown-renderer.js.map +1 -0
  61. package/components/chat/message-attachments.d.ts +38 -0
  62. package/components/chat/message-attachments.js +49 -0
  63. package/components/chat/message-attachments.js.map +1 -0
  64. package/components/chat/plain-text-renderer.d.ts +15 -0
  65. package/components/chat/plain-text-renderer.js +7 -0
  66. package/components/chat/plain-text-renderer.js.map +1 -0
  67. package/components/chat/themes/chat.base.css.d.ts +1 -0
  68. package/components/chat/themes/chat.base.css.js +3 -0
  69. package/components/chat/themes/chat.base.css.js.map +1 -0
  70. package/components/chat/themes/dark/chat.bootstrap.css.d.ts +1 -0
  71. package/components/chat/themes/dark/chat.bootstrap.css.js +3 -0
  72. package/components/chat/themes/dark/chat.bootstrap.css.js.map +1 -0
  73. package/components/chat/themes/dark/chat.fluent.css.d.ts +1 -0
  74. package/components/chat/themes/dark/chat.fluent.css.js +3 -0
  75. package/components/chat/themes/dark/chat.fluent.css.js.map +1 -0
  76. package/components/chat/themes/dark/chat.indigo.css.d.ts +1 -0
  77. package/components/chat/themes/dark/chat.indigo.css.js +3 -0
  78. package/components/chat/themes/dark/chat.indigo.css.js.map +1 -0
  79. package/components/chat/themes/dark/chat.material.css.d.ts +1 -0
  80. package/components/chat/themes/dark/chat.material.css.js +3 -0
  81. package/components/chat/themes/dark/chat.material.css.js.map +1 -0
  82. package/components/chat/themes/input.base.css.d.ts +1 -0
  83. package/components/chat/themes/input.base.css.js +3 -0
  84. package/components/chat/themes/input.base.css.js.map +1 -0
  85. package/components/chat/themes/input.d.ts +2 -0
  86. package/components/chat/themes/input.js +35 -0
  87. package/components/chat/themes/input.js.map +1 -0
  88. package/components/chat/themes/light/chat.bootstrap.css.d.ts +1 -0
  89. package/components/chat/themes/light/chat.bootstrap.css.js +3 -0
  90. package/components/chat/themes/light/chat.bootstrap.css.js.map +1 -0
  91. package/components/chat/themes/light/chat.fluent.css.d.ts +1 -0
  92. package/components/chat/themes/light/chat.fluent.css.js +3 -0
  93. package/components/chat/themes/light/chat.fluent.css.js.map +1 -0
  94. package/components/chat/themes/light/chat.indigo.css.d.ts +1 -0
  95. package/components/chat/themes/light/chat.indigo.css.js +3 -0
  96. package/components/chat/themes/light/chat.indigo.css.js.map +1 -0
  97. package/components/chat/themes/light/chat.material.css.d.ts +1 -0
  98. package/components/chat/themes/light/chat.material.css.js +3 -0
  99. package/components/chat/themes/light/chat.material.css.js.map +1 -0
  100. package/components/chat/themes/light/chat.shared.css.d.ts +1 -0
  101. package/components/chat/themes/light/chat.shared.css.js +3 -0
  102. package/components/chat/themes/light/chat.shared.css.js.map +1 -0
  103. package/components/chat/themes/message-attachments.base.css.d.ts +1 -0
  104. package/components/chat/themes/message-attachments.base.css.js +3 -0
  105. package/components/chat/themes/message-attachments.base.css.js.map +1 -0
  106. package/components/chat/themes/message-list.base.css.d.ts +1 -0
  107. package/components/chat/themes/message-list.base.css.js +3 -0
  108. package/components/chat/themes/message-list.base.css.js.map +1 -0
  109. package/components/chat/themes/message.base.css.d.ts +1 -0
  110. package/components/chat/themes/message.base.css.js +3 -0
  111. package/components/chat/themes/message.base.css.js.map +1 -0
  112. package/components/chat/themes/message.d.ts +2 -0
  113. package/components/chat/themes/message.js +28 -0
  114. package/components/chat/themes/message.js.map +1 -0
  115. package/components/chat/themes/shared/chat-message/chat-message.bootstrap.css.d.ts +1 -0
  116. package/components/chat/themes/shared/chat-message/chat-message.bootstrap.css.js +3 -0
  117. package/components/chat/themes/shared/chat-message/chat-message.bootstrap.css.js.map +1 -0
  118. package/components/chat/themes/shared/chat-message/chat-message.common.css.d.ts +1 -0
  119. package/components/chat/themes/shared/chat-message/chat-message.common.css.js +3 -0
  120. package/components/chat/themes/shared/chat-message/chat-message.common.css.js.map +1 -0
  121. package/components/chat/themes/shared/chat-message/chat-message.fluent.css.d.ts +1 -0
  122. package/components/chat/themes/shared/chat-message/chat-message.fluent.css.js +3 -0
  123. package/components/chat/themes/shared/chat-message/chat-message.fluent.css.js.map +1 -0
  124. package/components/chat/themes/shared/chat-message/chat-message.indigo.css.d.ts +1 -0
  125. package/components/chat/themes/shared/chat-message/chat-message.indigo.css.js +3 -0
  126. package/components/chat/themes/shared/chat-message/chat-message.indigo.css.js.map +1 -0
  127. package/components/chat/themes/shared/chat.bootstrap.css.d.ts +1 -0
  128. package/components/chat/themes/shared/chat.bootstrap.css.js +3 -0
  129. package/components/chat/themes/shared/chat.bootstrap.css.js.map +1 -0
  130. package/components/chat/themes/shared/chat.common.css.d.ts +1 -0
  131. package/components/chat/themes/shared/chat.common.css.js +3 -0
  132. package/components/chat/themes/shared/chat.common.css.js.map +1 -0
  133. package/components/chat/themes/shared/chat.indigo.css.d.ts +1 -0
  134. package/components/chat/themes/shared/chat.indigo.css.js +3 -0
  135. package/components/chat/themes/shared/chat.indigo.css.js.map +1 -0
  136. package/components/chat/themes/shared/input/input.bootstrap.css.d.ts +1 -0
  137. package/components/chat/themes/shared/input/input.bootstrap.css.js +3 -0
  138. package/components/chat/themes/shared/input/input.bootstrap.css.js.map +1 -0
  139. package/components/chat/themes/shared/input/input.common.css.d.ts +1 -0
  140. package/components/chat/themes/shared/input/input.common.css.js +3 -0
  141. package/components/chat/themes/shared/input/input.common.css.js.map +1 -0
  142. package/components/chat/themes/shared/input/input.fluent.css.d.ts +1 -0
  143. package/components/chat/themes/shared/input/input.fluent.css.js +3 -0
  144. package/components/chat/themes/shared/input/input.fluent.css.js.map +1 -0
  145. package/components/chat/themes/shared/input/input.indigo.css.d.ts +1 -0
  146. package/components/chat/themes/shared/input/input.indigo.css.js +3 -0
  147. package/components/chat/themes/shared/input/input.indigo.css.js.map +1 -0
  148. package/components/chat/themes/shared/input/input.material.css.d.ts +1 -0
  149. package/components/chat/themes/shared/input/input.material.css.js +3 -0
  150. package/components/chat/themes/shared/input/input.material.css.js.map +1 -0
  151. package/components/chat/themes/shared/message-attachments.common.css.d.ts +1 -0
  152. package/components/chat/themes/shared/message-attachments.common.css.js +3 -0
  153. package/components/chat/themes/shared/message-attachments.common.css.js.map +1 -0
  154. package/components/chat/themes/shared/message-list.common.css.d.ts +1 -0
  155. package/components/chat/themes/shared/message-list.common.css.js +3 -0
  156. package/components/chat/themes/shared/message-list.common.css.js.map +1 -0
  157. package/components/chat/themes/themes.d.ts +2 -0
  158. package/components/chat/themes/themes.js +48 -0
  159. package/components/chat/themes/themes.js.map +1 -0
  160. package/components/chat/types.d.ts +244 -0
  161. package/components/chat/types.js +15 -0
  162. package/components/chat/types.js.map +1 -0
  163. package/components/checkbox/themes/dark/switch/switch.bootstrap.css.js +1 -1
  164. package/components/checkbox/themes/dark/switch/switch.bootstrap.css.js.map +1 -1
  165. package/components/checkbox/themes/dark/switch/switch.fluent.css.js +1 -1
  166. package/components/checkbox/themes/dark/switch/switch.fluent.css.js.map +1 -1
  167. package/components/checkbox/themes/dark/switch/switch.indigo.css.js +1 -1
  168. package/components/checkbox/themes/dark/switch/switch.indigo.css.js.map +1 -1
  169. package/components/checkbox/themes/dark/switch/switch.material.css.js +1 -1
  170. package/components/checkbox/themes/dark/switch/switch.material.css.js.map +1 -1
  171. package/components/checkbox/themes/light/switch/switch.bootstrap.css.js +1 -1
  172. package/components/checkbox/themes/light/switch/switch.bootstrap.css.js.map +1 -1
  173. package/components/checkbox/themes/light/switch/switch.fluent.css.js +1 -1
  174. package/components/checkbox/themes/light/switch/switch.fluent.css.js.map +1 -1
  175. package/components/checkbox/themes/light/switch/switch.indigo.css.js +1 -1
  176. package/components/checkbox/themes/light/switch/switch.indigo.css.js.map +1 -1
  177. package/components/checkbox/themes/light/switch/switch.material.css.js +1 -1
  178. package/components/checkbox/themes/light/switch/switch.material.css.js.map +1 -1
  179. package/components/checkbox/themes/shared/switch/switch.bootstrap.css.js +1 -1
  180. package/components/checkbox/themes/shared/switch/switch.bootstrap.css.js.map +1 -1
  181. package/components/checkbox/themes/shared/switch/switch.common.css.js +1 -1
  182. package/components/checkbox/themes/shared/switch/switch.common.css.js.map +1 -1
  183. package/components/checkbox/themes/shared/switch/switch.fluent.css.js +1 -1
  184. package/components/checkbox/themes/shared/switch/switch.fluent.css.js.map +1 -1
  185. package/components/checkbox/themes/shared/switch/switch.indigo.css.js +1 -1
  186. package/components/checkbox/themes/shared/switch/switch.indigo.css.js.map +1 -1
  187. package/components/chip/themes/chip.base.css.js +1 -1
  188. package/components/chip/themes/chip.base.css.js.map +1 -1
  189. package/components/chip/themes/shared/chip.indigo.css.js +1 -1
  190. package/components/chip/themes/shared/chip.indigo.css.js.map +1 -1
  191. package/components/combo/controllers/navigation.js +1 -1
  192. package/components/combo/controllers/navigation.js.map +1 -1
  193. package/components/combo/themes/combo-item.base.css.js +1 -1
  194. package/components/combo/themes/combo-item.base.css.js.map +1 -1
  195. package/components/combo/themes/combo.base.css.js +1 -1
  196. package/components/combo/themes/combo.base.css.js.map +1 -1
  197. package/components/combo/themes/shared/combo.bootstrap.css.js +1 -1
  198. package/components/combo/themes/shared/combo.bootstrap.css.js.map +1 -1
  199. package/components/combo/themes/shared/combo.common.css.js +1 -1
  200. package/components/combo/themes/shared/combo.common.css.js.map +1 -1
  201. package/components/combo/themes/shared/combo.fluent.css.js +1 -1
  202. package/components/combo/themes/shared/combo.fluent.css.js.map +1 -1
  203. package/components/combo/themes/shared/combo.indigo.css.js +1 -1
  204. package/components/combo/themes/shared/combo.indigo.css.js.map +1 -1
  205. package/components/combo/themes/shared/combo.material.css.js +1 -1
  206. package/components/combo/themes/shared/combo.material.css.js.map +1 -1
  207. package/components/common/context.d.ts +5 -1
  208. package/components/common/context.js +2 -1
  209. package/components/common/context.js.map +1 -1
  210. package/components/common/controllers/key-bindings.js +4 -3
  211. package/components/common/controllers/key-bindings.js.map +1 -1
  212. package/components/common/definitions/defineAllComponents.js +2 -0
  213. package/components/common/definitions/defineAllComponents.js.map +1 -1
  214. package/components/common/i18n/chat.resources.d.ts +8 -0
  215. package/components/common/i18n/chat.resources.js +8 -0
  216. package/components/common/i18n/chat.resources.js.map +1 -0
  217. package/components/common/util.d.ts +14 -0
  218. package/components/common/util.js +51 -1
  219. package/components/common/util.js.map +1 -1
  220. package/components/date-picker/date-picker.js +2 -2
  221. package/components/date-picker/date-picker.js.map +1 -1
  222. package/components/date-picker/themes/shared/date-picker.common.css.js +1 -1
  223. package/components/date-picker/themes/shared/date-picker.common.css.js.map +1 -1
  224. package/components/date-range-picker/date-range-picker.js +0 -1
  225. package/components/date-range-picker/date-range-picker.js.map +1 -1
  226. package/components/date-range-picker/themes/shared/date-range-picker.bootstrap.css.js +1 -1
  227. package/components/date-range-picker/themes/shared/date-range-picker.bootstrap.css.js.map +1 -1
  228. package/components/date-range-picker/themes/shared/date-range-picker.common.css.js +1 -1
  229. package/components/date-range-picker/themes/shared/date-range-picker.common.css.js.map +1 -1
  230. package/components/date-time-input/date-time-input.js +1 -1
  231. package/components/date-time-input/date-time-input.js.map +1 -1
  232. package/components/dropdown/themes/dropdown-group.base.css.js +1 -1
  233. package/components/dropdown/themes/dropdown-group.base.css.js.map +1 -1
  234. package/components/dropdown/themes/dropdown-item.base.css.js +1 -1
  235. package/components/dropdown/themes/dropdown-item.base.css.js.map +1 -1
  236. package/components/dropdown/themes/shared/group/dropdown-group.fluent.css.js +1 -1
  237. package/components/dropdown/themes/shared/group/dropdown-group.fluent.css.js.map +1 -1
  238. package/components/dropdown/themes/shared/header/dropdown-header.common.css.js +1 -1
  239. package/components/dropdown/themes/shared/header/dropdown-header.common.css.js.map +1 -1
  240. package/components/dropdown/themes/shared/header/dropdown-header.indigo.css.js +1 -1
  241. package/components/dropdown/themes/shared/header/dropdown-header.indigo.css.js.map +1 -1
  242. package/components/dropdown/themes/shared/item/dropdown-item.indigo.css.js +1 -1
  243. package/components/dropdown/themes/shared/item/dropdown-item.indigo.css.js.map +1 -1
  244. package/components/expansion-panel/expansion-panel.js +0 -1
  245. package/components/expansion-panel/expansion-panel.js.map +1 -1
  246. package/components/expansion-panel/themes/expansion-panel.base.css.js +1 -1
  247. package/components/expansion-panel/themes/expansion-panel.base.css.js.map +1 -1
  248. package/components/expansion-panel/themes/shared/expansion-panel.indigo.css.js +1 -1
  249. package/components/expansion-panel/themes/shared/expansion-panel.indigo.css.js.map +1 -1
  250. package/components/file-input/themes/shared/file-input.bootstrap.css.js +1 -1
  251. package/components/file-input/themes/shared/file-input.bootstrap.css.js.map +1 -1
  252. package/components/input/themes/shared/input.bootstrap.css.js +1 -1
  253. package/components/input/themes/shared/input.bootstrap.css.js.map +1 -1
  254. package/components/input/themes/shared/input.common.css.js +1 -1
  255. package/components/input/themes/shared/input.common.css.js.map +1 -1
  256. package/components/input/themes/shared/input.fluent.css.js +1 -1
  257. package/components/input/themes/shared/input.fluent.css.js.map +1 -1
  258. package/components/input/themes/shared/input.indigo.css.js +1 -1
  259. package/components/input/themes/shared/input.indigo.css.js.map +1 -1
  260. package/components/input/themes/shared/input.material.css.js +1 -1
  261. package/components/input/themes/shared/input.material.css.js.map +1 -1
  262. package/components/list/themes/header.base.css.js +1 -1
  263. package/components/list/themes/header.base.css.js.map +1 -1
  264. package/components/list/themes/item.base.css.js +1 -1
  265. package/components/list/themes/item.base.css.js.map +1 -1
  266. package/components/list/themes/shared/header/list-header.indigo.css.js +1 -1
  267. package/components/list/themes/shared/header/list-header.indigo.css.js.map +1 -1
  268. package/components/list/themes/shared/item/list-item.indigo.css.js +1 -1
  269. package/components/list/themes/shared/item/list-item.indigo.css.js.map +1 -1
  270. package/components/rating/rating.js +0 -1
  271. package/components/rating/rating.js.map +1 -1
  272. package/components/select/themes/dark/select.bootstrap.css.js +1 -1
  273. package/components/select/themes/dark/select.bootstrap.css.js.map +1 -1
  274. package/components/select/themes/light/select.bootstrap.css.js +1 -1
  275. package/components/select/themes/light/select.bootstrap.css.js.map +1 -1
  276. package/components/select/themes/shared/select.bootstrap.css.js +1 -1
  277. package/components/select/themes/shared/select.bootstrap.css.js.map +1 -1
  278. package/components/select/themes/shared/select.common.css.js +1 -1
  279. package/components/select/themes/shared/select.common.css.js.map +1 -1
  280. package/components/select/themes/shared/select.material.css.js +1 -1
  281. package/components/select/themes/shared/select.material.css.js.map +1 -1
  282. package/components/slider/slider-base.js +0 -1
  283. package/components/slider/slider-base.js.map +1 -1
  284. package/components/tabs/tabs.js +0 -1
  285. package/components/tabs/tabs.js.map +1 -1
  286. package/components/textarea/themes/shared/textarea.bootstrap.css.js +1 -1
  287. package/components/textarea/themes/shared/textarea.bootstrap.css.js.map +1 -1
  288. package/components/textarea/themes/shared/textarea.common.css.js +1 -1
  289. package/components/textarea/themes/shared/textarea.common.css.js.map +1 -1
  290. package/components/textarea/themes/shared/textarea.fluent.css.js +1 -1
  291. package/components/textarea/themes/shared/textarea.fluent.css.js.map +1 -1
  292. package/components/textarea/themes/shared/textarea.indigo.css.js +1 -1
  293. package/components/textarea/themes/shared/textarea.indigo.css.js.map +1 -1
  294. package/components/textarea/themes/shared/textarea.material.css.js +1 -1
  295. package/components/textarea/themes/shared/textarea.material.css.js.map +1 -1
  296. package/components/textarea/themes/textarea.base.css.js +1 -1
  297. package/components/textarea/themes/textarea.base.css.js.map +1 -1
  298. package/components/tree/themes/item.base.css.js +1 -1
  299. package/components/tree/themes/item.base.css.js.map +1 -1
  300. package/components/tree/themes/shared/item.indigo.css.js +1 -1
  301. package/components/tree/themes/shared/item.indigo.css.js.map +1 -1
  302. package/components/tree/tree.js +3 -1
  303. package/components/tree/tree.js.map +1 -1
  304. package/components/tree/tree.navigation.js +3 -3
  305. package/components/tree/tree.navigation.js.map +1 -1
  306. package/components/tree/tree.selection.js +6 -2
  307. package/components/tree/tree.selection.js.map +1 -1
  308. package/custom-elements.json +8212 -6063
  309. package/igniteui-webcomponents.css-data.json +1 -1
  310. package/igniteui-webcomponents.html-data.json +1 -1
  311. package/index.d.ts +6 -0
  312. package/index.js +4 -0
  313. package/index.js.map +1 -1
  314. package/package.json +1 -1
  315. package/themes/dark/bootstrap.css +1 -1
  316. package/themes/dark/fluent.css +1 -1
  317. package/themes/dark/indigo.css +1 -1
  318. package/themes/dark/material.css +1 -1
  319. package/themes/light/bootstrap.css +1 -1
  320. package/themes/light/fluent.css +1 -1
  321. package/themes/light/indigo.css +1 -1
  322. package/themes/light/material.css +1 -1
  323. package/web-types.json +2 -2
@@ -0,0 +1,538 @@
1
+ import { html, nothing } from 'lit';
2
+ import { ifDefined } from 'lit/directives/if-defined.js';
3
+ import { createRef, ref } from 'lit/directives/ref.js';
4
+ import { enterKey } from '../common/controllers/key-bindings.js';
5
+ import { IgcChatResourceStringEN } from '../common/i18n/chat.resources.js';
6
+ import { partMap } from '../common/part-map.js';
7
+ import { registerIconFromText } from '../icon/icon.registry.js';
8
+ import { DefaultChatRenderer } from './chat-renderer.js';
9
+ import { PlainTextRenderer } from './plain-text-renderer.js';
10
+ import { copyIcon, regenerateIcon, thumbDownIcon, thumbUpIcon, } from './types.js';
11
+ export class ChatState {
12
+ get _sharedTooltip() {
13
+ return this._sharedTooltipRef?.value;
14
+ }
15
+ getIconName(fileType) {
16
+ if (fileType?.startsWith('image')) {
17
+ return 'file-image';
18
+ }
19
+ return 'file-document';
20
+ }
21
+ renderDefaultAttachmentHeaderText(attachment, message) {
22
+ return html `
23
+ ${html `${message.sender !== this.currentUserId
24
+ ? html `${attachment.type === 'image' ||
25
+ attachment.file?.type.startsWith('image/')
26
+ ? html `<igc-icon
27
+ name="image"
28
+ collection="material"
29
+ part="attachment-icon"
30
+ ></igc-icon>`
31
+ : html `<igc-icon
32
+ name="file"
33
+ collection="material"
34
+ part="attachment-icon"
35
+ ></igc-icon>`}`
36
+ : nothing} <span part="file-name">${attachment.name}</span>`}
37
+ `;
38
+ }
39
+ handleHeaderClick(attachment) {
40
+ this.emitEvent('igcAttachmentClick', { detail: attachment });
41
+ }
42
+ showTooltip(ev, text) {
43
+ if (!this._sharedTooltip)
44
+ return;
45
+ this._sharedTooltip.message = text;
46
+ this._sharedTooltip.hideDelay = 300;
47
+ this._sharedTooltip.show(ev.composedPath()[0]);
48
+ }
49
+ get messages() {
50
+ return this._messages;
51
+ }
52
+ set messages(value) {
53
+ this._messages = value;
54
+ this._host.requestUpdate();
55
+ }
56
+ get options() {
57
+ return this._options;
58
+ }
59
+ set options(value) {
60
+ this._options = value;
61
+ this._host.requestUpdate();
62
+ if (this._host.updateContextValue) {
63
+ this._host.updateContextValue();
64
+ }
65
+ }
66
+ get currentUserId() {
67
+ return this._options?.currentUserId ?? 'user';
68
+ }
69
+ get suggestionsPosition() {
70
+ return this._options?.suggestionsPosition ?? this._suggestionsPosition;
71
+ }
72
+ get stopTypingDelay() {
73
+ return this._options?.stopTypingDelay ?? this._stopTypingDelay;
74
+ }
75
+ get textArea() {
76
+ return this._textArea;
77
+ }
78
+ set textArea(value) {
79
+ this._textArea = value;
80
+ }
81
+ get textAreaRef() {
82
+ return this._textAreaRef;
83
+ }
84
+ get inputAttachments() {
85
+ return this._inputAttachments;
86
+ }
87
+ set inputAttachments(value) {
88
+ this._inputAttachments = value;
89
+ this._host.requestUpdate();
90
+ if (this._host.updateContextValue) {
91
+ this._host.updateContextValue();
92
+ }
93
+ }
94
+ get inputValue() {
95
+ return this._inputValue;
96
+ }
97
+ set inputValue(value) {
98
+ this._inputValue = value;
99
+ this._host.requestUpdate();
100
+ if (this._host.updateContextValue) {
101
+ this._host.updateContextValue();
102
+ }
103
+ }
104
+ get defaultTemplates() {
105
+ return this._defaultTemplates;
106
+ }
107
+ set defaultTemplates(templates) {
108
+ this._defaultTemplates = { ...templates };
109
+ }
110
+ get mergedTemplates() {
111
+ return { ...this._defaultTemplates, ...this.options?.templates };
112
+ }
113
+ get chatRenderer() {
114
+ if (!this._chatRenderer ||
115
+ this._chatRenderer !== this.options?.messageRenderer) {
116
+ this._chatRenderer = new DefaultChatRenderer(this.options?.messageRenderer ?? new PlainTextRenderer(), this.mergedTemplates);
117
+ this.options?.messageRenderer?.init?.();
118
+ }
119
+ return this._chatRenderer;
120
+ }
121
+ constructor(chat) {
122
+ this._textArea = null;
123
+ this._messages = [];
124
+ this._inputAttachments = [];
125
+ this._inputValue = '';
126
+ this._acceptedTypesCache = null;
127
+ this._suggestionsPosition = 'below-messages';
128
+ this._stopTypingDelay = 3000;
129
+ this._isTyping = false;
130
+ this._lastTyped = Date.now();
131
+ this._fileIcon = new URL('./assets/file.png', import.meta.url).href;
132
+ this._jsonIcon = new URL('./assets/json.png', import.meta.url).href;
133
+ this._linkIcon = new URL('./assets/link.png', import.meta.url).href;
134
+ this._textAreaRef = createRef();
135
+ this._attachmentsButtonInputRef = createRef();
136
+ this._sharedTooltipRef = createRef();
137
+ this.resourceStrings = IgcChatResourceStringEN;
138
+ this._defaultTemplates = {
139
+ attachmentTemplate: (att, m) => this.renderDefaultAttachmentTemplate(att, m),
140
+ attachmentsTemplate: (m, _ctx) => this.renderDefaultAttachmentsTemplate(m),
141
+ attachmentHeaderTemplate: (att, msg) => this.renderDefaultAttachmentHeader(att, msg),
142
+ attachmentContentTemplate: (att) => this.renderDefaultAttachmentContent(att),
143
+ messageAuthorTemplate: () => { },
144
+ messageTemplate: (m, ctx) => this.renderDefaultMessageTemplate(m, ctx),
145
+ messageActionsTemplate: (message) => this.renderDefaultMessageActionsTemplate(message),
146
+ suggestionPrefixTemplate: () => { },
147
+ typingIndicatorTemplate: () => this.renderDefaultTypingIndicator(),
148
+ textInputTemplate: () => this.renderDefaultTextArea(),
149
+ textAreaActionsTemplate: () => this.renderDefaultActionsArea(),
150
+ textAreaAttachmentsTemplate: (attachments) => this.renderDefaultAttachmentsArea(attachments),
151
+ };
152
+ this.renderDefaultAttachmentsArea = (attachments) => {
153
+ return html `${attachments?.map((attachment, index) => html `
154
+ <div part="attachment-wrapper" role="listitem">
155
+ <igc-chip removable @igcRemove=${() => this.removeAttachment(index)}>
156
+ <igc-icon
157
+ slot="prefix"
158
+ name=${this.getIconName(attachment.file?.type ?? attachment.type)}
159
+ collection="material"
160
+ ></igc-icon>
161
+ <span part="attachment-name">${attachment.name}</span>
162
+ </igc-chip>
163
+ </div>
164
+ `)} `;
165
+ };
166
+ this.renderDefaultTextArea = () => {
167
+ return html ` <igc-textarea
168
+ part="text-input"
169
+ ${ref(this._textAreaRef)}
170
+ .placeholder=${this.options?.inputPlaceholder}
171
+ resize="auto"
172
+ rows="1"
173
+ .value=${this.inputValue}
174
+ @igcInput=${this.handleInput}
175
+ @focus=${this.handleFocus}
176
+ @blur=${this.handleBlur}
177
+ ></igc-textarea>`;
178
+ };
179
+ this.renderDefaultFileUploadButton = () => {
180
+ if (this.options?.disableInputAttachments)
181
+ return html ``;
182
+ return html `
183
+ <label for="input_attachments" part="upload-button">
184
+ <igc-icon-button
185
+ variant="flat"
186
+ name="attachment"
187
+ collection="material"
188
+ @click=${() => this._attachmentsButtonInputRef?.value?.click()}
189
+ ></igc-icon-button>
190
+ <input
191
+ type="file"
192
+ id="input_attachments"
193
+ name="input_attachments"
194
+ ${ref(this._attachmentsButtonInputRef)}
195
+ multiple
196
+ accept=${ifDefined(this.options?.acceptedFiles === '' ? undefined : this.options?.acceptedFiles)}
197
+ @change=${this.handleFileUpload}>
198
+ </input>
199
+ </label>
200
+ `;
201
+ };
202
+ this.renderDefaultSendButton = () => {
203
+ return html ` <igc-icon-button
204
+ aria-label="Send message"
205
+ name="send-message"
206
+ collection="material"
207
+ variant="contained"
208
+ part="send-button"
209
+ ?disabled=${!this.inputValue.trim() && this.inputAttachments.length === 0}
210
+ @click=${this.sendMessage}
211
+ ></igc-icon-button>`;
212
+ };
213
+ this.renderDefaultActionsArea = () => {
214
+ return html ` ${this.renderDefaultFileUploadButton()}
215
+ ${this.renderDefaultSendButton()}`;
216
+ };
217
+ this.renderDefaultTypingIndicator = () => {
218
+ return html `<div part="typing-indicator">
219
+ <div part="typing-dot"></div>
220
+ <div part="typing-dot"></div>
221
+ <div part="typing-dot"></div>
222
+ </div>`;
223
+ };
224
+ this.renderDefaultMessageTemplate = (m, ctx) => {
225
+ const templates = { ...this._defaultTemplates, ...ctx.templates };
226
+ return html `
227
+ ${templates.messageAuthorTemplate(m) ?? nothing}
228
+ ${ctx?.textContent ?? m.text}
229
+ ${m.attachments?.length
230
+ ? html `<igc-message-attachments .message=${m}>
231
+ </igc-message-attachments>`
232
+ : nothing}
233
+ ${templates.messageActionsTemplate(m) ?? nothing}
234
+ `;
235
+ };
236
+ this.renderDefaultAttachmentHeader = (attachment, message) => {
237
+ return this.renderDefaultAttachmentHeaderText(attachment, message);
238
+ };
239
+ this.renderDefaultAttachmentContent = (attachment) => {
240
+ const ext = this.getFileExtension(attachment.name);
241
+ const isImage = this.isImageAttachment(attachment);
242
+ const url = isImage
243
+ ? this.getURL(attachment)
244
+ : (this._fileIconMap[ext] ?? this._fileIconMap['default']);
245
+ const partName = isImage ? 'image-attachment' : 'file-attachment';
246
+ return html `<img part="${partName}" src=${url} alt=${attachment.name} />`;
247
+ };
248
+ this.renderDefaultMessageActionsTemplate = (message) => {
249
+ const isLastMessage = message === this.messages.at(-1);
250
+ return message?.sender !== this.currentUserId &&
251
+ message?.text.trim() &&
252
+ (!isLastMessage || !this._isTyping)
253
+ ? html `<div>
254
+ <igc-icon-button
255
+ id="copy-response-button"
256
+ @pointerenter=${(ev) => this.showTooltip(ev, this.resourceStrings.reactionCopyResponse)}
257
+ name="copy-response"
258
+ collection="material"
259
+ variant="flat"
260
+ @click=${(e) => this.handleMessageActionClick(e, message)}
261
+ ></igc-icon-button>
262
+ <igc-icon-button
263
+ id="good-response-button"
264
+ @pointerenter=${(ev) => this.showTooltip(ev, this.resourceStrings.reactionGoodResponse)}
265
+ name="good-response"
266
+ collection="material"
267
+ variant="flat"
268
+ @click=${(e) => this.handleMessageActionClick(e, message)}
269
+ ></igc-icon-button>
270
+ <igc-icon-button
271
+ id="bad-response-button"
272
+ @pointerenter=${(ev) => this.showTooltip(ev, this.resourceStrings.reactionBadResponse)}
273
+ name="bad-response"
274
+ variant="flat"
275
+ collection="material"
276
+ @click=${(e) => this.handleMessageActionClick(e, message)}
277
+ ></igc-icon-button>
278
+ <igc-icon-button
279
+ id="redo-button"
280
+ @pointerenter=${(ev) => this.showTooltip(ev, this.resourceStrings.reactionRedo)}
281
+ name="redo"
282
+ variant="flat"
283
+ collection="material"
284
+ @click=${(e) => this.handleMessageActionClick(e, message)}
285
+ ></igc-icon-button>
286
+ <igc-tooltip
287
+ id="sharedTooltip"
288
+ ${ref(this._sharedTooltipRef)}
289
+ ></igc-tooltip>
290
+ </div>`
291
+ : nothing;
292
+ };
293
+ this.handleMessageActionClick = (event, message) => {
294
+ const reaction = event.target.getAttribute('name');
295
+ this.emitEvent('igcMessageReact', {
296
+ detail: { message, reaction },
297
+ });
298
+ };
299
+ this.renderDefaultAttachmentTemplate = (att, msg) => {
300
+ const isCurrentUser = msg.sender === this.currentUserId;
301
+ const attachmentParts = {
302
+ attachment: true,
303
+ sent: isCurrentUser,
304
+ };
305
+ const contentParts = {
306
+ 'attachment-content': true,
307
+ sent: isCurrentUser,
308
+ };
309
+ const headerParts = {
310
+ 'attachment-header': true,
311
+ sent: isCurrentUser,
312
+ };
313
+ const content = html `<div part=${partMap(contentParts)}>
314
+ ${this.mergedTemplates.attachmentContentTemplate(att)}
315
+ </div>`;
316
+ const header = html ` <div
317
+ part=${partMap(headerParts)}
318
+ role="button"
319
+ @click=${() => this.handleHeaderClick(att)}
320
+ >
321
+ <div part="details">
322
+ ${this.mergedTemplates.attachmentHeaderTemplate(att, msg)}
323
+ </div>
324
+ </div>`;
325
+ return html `<div part=${partMap(attachmentParts)}>
326
+ ${isCurrentUser ? content : nothing} ${header}
327
+ ${!isCurrentUser ? content : nothing}
328
+ </div> `;
329
+ };
330
+ this.renderDefaultAttachmentsTemplate = (m) => {
331
+ return html `
332
+ ${(m.attachments ?? []).map((att) => this.mergedTemplates.attachmentTemplate(att, m)) || nothing}
333
+ `;
334
+ };
335
+ this.handleInput = ({ detail }) => {
336
+ if (detail === this.inputValue)
337
+ return;
338
+ this.inputValue = detail;
339
+ this.emitEvent('igcInputChange', { detail: { value: this.inputValue } });
340
+ };
341
+ this.emitEvent = (name, args) => {
342
+ return this._host.emitEvent(name, args);
343
+ };
344
+ this.addMessage = (message) => {
345
+ const newMessage = {
346
+ id: message.id ?? Date.now().toString(),
347
+ text: message.text,
348
+ sender: message.sender ?? this.currentUserId,
349
+ timestamp: message.timestamp ?? new Date(),
350
+ attachments: message.attachments || [],
351
+ };
352
+ const allowed = this.emitEvent('igcMessageCreated', {
353
+ detail: newMessage,
354
+ cancelable: true,
355
+ });
356
+ if (allowed) {
357
+ if (!this.messages.some((msg) => msg.id === newMessage.id)) {
358
+ this.messages = [...this.messages, newMessage];
359
+ }
360
+ this.inputValue = '';
361
+ this.inputAttachments = [];
362
+ }
363
+ };
364
+ this.getURL = (attachment) => {
365
+ if (attachment.url) {
366
+ return attachment.url;
367
+ }
368
+ if (attachment.file) {
369
+ return URL.createObjectURL(attachment.file);
370
+ }
371
+ return '';
372
+ };
373
+ this._fileIconMap = {
374
+ pdf: this._fileIcon,
375
+ doc: this._fileIcon,
376
+ docx: this._fileIcon,
377
+ xls: this._fileIcon,
378
+ xlsx: this._fileIcon,
379
+ txt: this._fileIcon,
380
+ json: this._jsonIcon,
381
+ link: this._linkIcon,
382
+ default: this._fileIcon,
383
+ };
384
+ this.handleKeyDown = (e) => {
385
+ if (e.key.toLowerCase() === enterKey.toLowerCase() && !e.shiftKey) {
386
+ e.preventDefault();
387
+ this.sendMessage();
388
+ }
389
+ else {
390
+ this._lastTyped = Date.now();
391
+ if (!this._isTyping) {
392
+ this.emitEvent('igcTypingChange', {
393
+ detail: { isTyping: true },
394
+ });
395
+ this._isTyping = true;
396
+ }
397
+ const stopTypingDelay = this.stopTypingDelay;
398
+ setTimeout(() => {
399
+ if (this._isTyping &&
400
+ stopTypingDelay &&
401
+ this._lastTyped + stopTypingDelay < Date.now()) {
402
+ this.emitEvent('igcTypingChange', {
403
+ detail: { isTyping: false },
404
+ });
405
+ this._isTyping = false;
406
+ }
407
+ }, stopTypingDelay);
408
+ }
409
+ };
410
+ this.handleFocus = () => {
411
+ this.emitEvent('igcInputFocus');
412
+ };
413
+ this.handleBlur = () => {
414
+ this.emitEvent('igcInputBlur');
415
+ };
416
+ this.sendMessage = () => {
417
+ if (!this.inputValue.trim() && this.inputAttachments.length === 0)
418
+ return;
419
+ this.addMessage({
420
+ text: this.inputValue,
421
+ attachments: this.inputAttachments,
422
+ });
423
+ this.inputValue = '';
424
+ if (this._textArea) {
425
+ this._textArea.style.height = 'auto';
426
+ }
427
+ this._host.updateComplete.then(() => {
428
+ this._textArea?.focus();
429
+ });
430
+ };
431
+ this.handleFileUpload = (e) => {
432
+ const input = e.target;
433
+ if (!input.files || input.files.length === 0)
434
+ return;
435
+ const files = Array.from(input.files);
436
+ this.attachFiles(files);
437
+ this._host.requestUpdate();
438
+ };
439
+ this.removeAttachment = (index) => {
440
+ const allowed = this.emitEvent('igcAttachmentChange', {
441
+ detail: this.inputAttachments.filter((_, i) => i !== index),
442
+ cancelable: true,
443
+ });
444
+ if (allowed) {
445
+ this.inputAttachments = this.inputAttachments.filter((_, i) => i !== index);
446
+ }
447
+ };
448
+ this.handleSuggestionClick = (suggestion) => {
449
+ this.addMessage({ text: suggestion });
450
+ if (this.textArea) {
451
+ this.textArea.focus();
452
+ }
453
+ };
454
+ this.updateAcceptedTypesCache = () => {
455
+ if (!this.options?.acceptedFiles) {
456
+ this._acceptedTypesCache = null;
457
+ return;
458
+ }
459
+ const types = this.options?.acceptedFiles
460
+ .split(',')
461
+ .map((type) => type.trim().toLowerCase());
462
+ this._acceptedTypesCache = {
463
+ extensions: new Set(types.filter((t) => t.startsWith('.'))),
464
+ mimeTypes: new Set(types.filter((t) => !t.startsWith('.') && !t.endsWith('/*'))),
465
+ wildcardTypes: new Set(types.filter((t) => t.endsWith('/*')).map((t) => t.slice(0, -2))),
466
+ };
467
+ };
468
+ this.isFileTypeAccepted = (file, type = '') => {
469
+ if (!this._acceptedTypesCache)
470
+ return true;
471
+ if (file === null && type === '')
472
+ return false;
473
+ const fileType = file != null ? file.type.toLowerCase() : type.toLowerCase();
474
+ const fileExtension = file != null
475
+ ? `.${file.name.split('.').pop()?.toLowerCase()}`
476
+ : `.${type.split('/').pop()?.toLowerCase()}`;
477
+ if (this._acceptedTypesCache.extensions.has(fileExtension)) {
478
+ return true;
479
+ }
480
+ if (this._acceptedTypesCache.mimeTypes.has(fileType)) {
481
+ return true;
482
+ }
483
+ const [fileBaseType] = fileType.split('/');
484
+ return this._acceptedTypesCache.wildcardTypes.has(fileBaseType);
485
+ };
486
+ this._host = chat;
487
+ registerIconFromText('copy-response', copyIcon, 'material');
488
+ registerIconFromText('good-response', thumbUpIcon, 'material');
489
+ registerIconFromText('bad-response', thumbDownIcon, 'material');
490
+ registerIconFromText('redo', regenerateIcon, 'material');
491
+ }
492
+ attachFiles(files) {
493
+ const newAttachments = [];
494
+ let count = this.inputAttachments.length;
495
+ files.forEach((file) => {
496
+ if (this.inputAttachments.find((a) => a.name === file.name)) {
497
+ return;
498
+ }
499
+ const isImage = file.type.startsWith('image/');
500
+ newAttachments.push({
501
+ id: Date.now().toString() + count++,
502
+ url: URL.createObjectURL(file),
503
+ name: file.name,
504
+ file: file,
505
+ thumbnail: isImage ? URL.createObjectURL(file) : undefined,
506
+ });
507
+ });
508
+ const allowed = this.emitEvent('igcAttachmentChange', {
509
+ detail: [...this.inputAttachments, ...newAttachments],
510
+ cancelable: true,
511
+ });
512
+ if (allowed) {
513
+ this.inputAttachments = [...this.inputAttachments, ...newAttachments];
514
+ }
515
+ }
516
+ isImageAttachment(attachment) {
517
+ return (attachment.type === 'image' ||
518
+ !!attachment.file?.type.startsWith('image/'));
519
+ }
520
+ getFileExtension(fileName) {
521
+ const parts = fileName.split('.');
522
+ if (parts.length > 1) {
523
+ return parts.pop().toLowerCase();
524
+ }
525
+ return '';
526
+ }
527
+ updateOptions(options) {
528
+ this.options = { ...this.options, ...options };
529
+ }
530
+ hasSlotContent(name) {
531
+ return (this._host.renderRoot.querySelector(`slot[name=${name}]`)
532
+ ?.childNodes.length !== 0);
533
+ }
534
+ }
535
+ export function createChatState(host) {
536
+ return new ChatState(host);
537
+ }
538
+ //# sourceMappingURL=chat-state.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chat-state.js","sourceRoot":"","sources":["../../../src/components/chat/chat-state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAuB,MAAM,KAAK,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,SAAS,EAAY,GAAG,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO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,gBAAgB,EAAE,GAAG,cAAc,CAAC,CAAC;QACxE,CAAC;IACH,CAAC;IAYO,iBAAiB,CAAC,UAAgC;QACxD,OAAO,CACL,UAAU,CAAC,IAAI,KAAK,OAAO;YAC3B,CAAC,CAAC,UAAU,CAAC,IAAI,EAAE,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAC7C,CAAC;IACJ,CAAC;IAcO,gBAAgB,CAAC,QAAgB;QACvC,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAClC,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACrB,OAAO,KAAK,CAAC,GAAG,EAAG,CAAC,WAAW,EAAE,CAAC;QACpC,CAAC;QACD,OAAO,EAAE,CAAC;IACZ,CAAC;IAmGM,aAAa,CAAC,OAAgC;QACnD,IAAI,CAAC,OAAO,GAAG,EAAE,GAAG,IAAI,CAAC,OAAO,EAAE,GAAG,OAAO,EAAE,CAAC;IACjD,CAAC;IAgEM,cAAc,CAAC,IAAY;QAChC,OAAO,CACL,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,aAAa,CAAkB,aAAa,IAAI,GAAG,CAAC;YACxE,EAAE,UAAU,CAAC,MAAM,KAAK,CAAC,CAC5B,CAAC;IACJ,CAAC;CAEF;AAED,MAAM,UAAU,eAAe,CAAC,IAAsB;IACpD,OAAO,IAAI,SAAS,CAAC,IAAI,CAAC,CAAC;AAC7B,CAAC","sourcesContent":["import { html, nothing, type TemplateResult } from 'lit';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { createRef, type Ref, ref } from 'lit/directives/ref.js';\nimport { enterKey } from '../common/controllers/key-bindings.js';\nimport { IgcChatResourceStringEN } from '../common/i18n/chat.resources.js';\nimport { partMap } from '../common/part-map.js';\nimport { registerIconFromText } from '../icon/icon.registry.js';\nimport type IgcTextareaComponent from '../textarea/textarea.js';\nimport type IgcTooltipComponent from '../tooltip/tooltip.js';\nimport type IgcChatComponent from './chat.js';\nimport type { IgcChatComponentEventMap } from './chat.js';\nimport { DefaultChatRenderer } from './chat-renderer.js';\nimport { PlainTextRenderer } from './plain-text-renderer.js';\nimport {\n copyIcon,\n type IgcChatOptions,\n type IgcChatTemplates,\n type IgcMessage,\n type IgcMessageAttachment,\n regenerateIcon,\n thumbDownIcon,\n thumbUpIcon,\n} from './types.js';\n\n/**\n * Internal state manager for the `<igc-chat>` component.\n *\n * Manages messages, input value, attachments, options, and event emissions.\n */\nexport class ChatState {\n //#region Internal properties and state /** The host `<igc-chat>` component instance */\n private readonly _host: IgcChatComponent;\n /** Reference to the text area input component */\n private _textArea: IgcTextareaComponent | null = null;\n /** The current list of messages */\n private _messages: IgcMessage[] = [];\n /** Chat options/configuration */\n private _options?: IgcChatOptions;\n /** List of current input attachments */\n private _inputAttachments: IgcMessageAttachment[] = [];\n /** Current input text */\n private _inputValue = '';\n /**\n * Cache of accepted file types, organized into extensions, mimeTypes, and wildcardTypes\n */\n private _acceptedTypesCache: {\n extensions: Set<string>;\n mimeTypes: Set<string>;\n wildcardTypes: Set<string>;\n } | null = null;\n /** Default position of the suggestions */\n private _suggestionsPosition: 'below-input' | 'below-messages' =\n 'below-messages';\n /** Default time in milliseconds before dispatching stop typing event */\n private _stopTypingDelay = 3000;\n\n private _isTyping = false;\n private _lastTyped = Date.now();\n\n private _fileIcon = new URL('./assets/file.png', import.meta.url).href;\n private _jsonIcon = new URL('./assets/json.png', import.meta.url).href;\n private _linkIcon = new URL('./assets/link.png', import.meta.url).href;\n\n private readonly _textAreaRef = createRef<IgcTextareaComponent>();\n private readonly _attachmentsButtonInputRef = createRef<HTMLInputElement>();\n private readonly _sharedTooltipRef = createRef<IgcTooltipComponent>();\n\n private _chatRenderer?: DefaultChatRenderer;\n private resourceStrings = IgcChatResourceStringEN;\n\n /** Default templates of the chat components */\n private _defaultTemplates: Required<IgcChatTemplates> = {\n attachmentTemplate: (att: IgcMessageAttachment, m: IgcMessage) =>\n this.renderDefaultAttachmentTemplate(att, m),\n attachmentsTemplate: (\n m: IgcMessage,\n _ctx: { templates: Partial<IgcChatTemplates> }\n ) => this.renderDefaultAttachmentsTemplate(m),\n attachmentHeaderTemplate: (att: IgcMessageAttachment, msg: IgcMessage) =>\n this.renderDefaultAttachmentHeader(att, msg),\n attachmentContentTemplate: (att: IgcMessageAttachment) =>\n this.renderDefaultAttachmentContent(att),\n messageAuthorTemplate: () => {},\n messageTemplate: (\n m: IgcMessage,\n ctx: { textContent: unknown; templates: Partial<IgcChatTemplates> }\n ) => this.renderDefaultMessageTemplate(m, ctx),\n messageActionsTemplate: (message: IgcMessage) =>\n this.renderDefaultMessageActionsTemplate(message),\n suggestionPrefixTemplate: () => {},\n typingIndicatorTemplate: () => this.renderDefaultTypingIndicator(),\n textInputTemplate: () => this.renderDefaultTextArea(),\n textAreaActionsTemplate: () => this.renderDefaultActionsArea(),\n textAreaAttachmentsTemplate: (attachments: IgcMessageAttachment[]) =>\n this.renderDefaultAttachmentsArea(attachments),\n };\n\n /** The tooltip component used for showing action tooltips. */\n private get _sharedTooltip(): IgcTooltipComponent | undefined {\n return this._sharedTooltipRef?.value;\n }\n\n private getIconName(fileType: string | undefined): string {\n if (fileType?.startsWith('image')) {\n return 'file-image';\n }\n return 'file-document';\n }\n //#endregion\n\n // #region Default renderers\n\n /**\n * Default attachments area template used when no custom template is provided.\n * Renders the list of input attachments as chips.\n * @returns TemplateResult containing the attachments area\n */\n private renderDefaultAttachmentsArea = (\n attachments: IgcMessageAttachment[]\n ): TemplateResult => {\n return html`${attachments?.map(\n (attachment, index) => html`\n <div part=\"attachment-wrapper\" role=\"listitem\">\n <igc-chip removable @igcRemove=${() => this.removeAttachment(index)}>\n <igc-icon\n slot=\"prefix\"\n name=${this.getIconName(attachment.file?.type ?? attachment.type)}\n collection=\"material\"\n ></igc-icon>\n <span part=\"attachment-name\">${attachment.name}</span>\n </igc-chip>\n </div>\n `\n )} `;\n };\n\n /**\n * Default text area template used when no custom template is provided.\n * Renders a text area for user input.\n * @returns TemplateResult containing the text area\n */\n private renderDefaultTextArea = (): TemplateResult => {\n return html` <igc-textarea\n part=\"text-input\"\n ${ref(this._textAreaRef)}\n .placeholder=${this.options?.inputPlaceholder}\n resize=\"auto\"\n rows=\"1\"\n .value=${this.inputValue}\n @igcInput=${this.handleInput}\n @focus=${this.handleFocus}\n @blur=${this.handleBlur}\n ></igc-textarea>`;\n };\n\n /**\n * Default file upload button template used when no custom template is provided.\n * Renders a file input for attaching files.\n * @returns TemplateResult containing the file upload button\n */\n private renderDefaultFileUploadButton = (): TemplateResult => {\n if (this.options?.disableInputAttachments) return html``;\n return html`\n <label for=\"input_attachments\" part=\"upload-button\">\n <igc-icon-button\n variant=\"flat\"\n name=\"attachment\"\n collection=\"material\"\n @click=${() => this._attachmentsButtonInputRef?.value?.click()}\n ></igc-icon-button>\n <input\n type=\"file\"\n id=\"input_attachments\"\n name=\"input_attachments\"\n ${ref(this._attachmentsButtonInputRef)}\n multiple\n accept=${ifDefined(this.options?.acceptedFiles === '' ? undefined : this.options?.acceptedFiles)}\n @change=${this.handleFileUpload}>\n </input>\n </label>\n `;\n };\n\n /**\n * Default send button template used when no custom template is provided.\n * Renders a send button that submits the current input value and attachments.\n * @returns TemplateResult containing the send button\n */\n private renderDefaultSendButton = (): TemplateResult => {\n return html` <igc-icon-button\n aria-label=\"Send message\"\n name=\"send-message\"\n collection=\"material\"\n variant=\"contained\"\n part=\"send-button\"\n ?disabled=${!this.inputValue.trim() && this.inputAttachments.length === 0}\n @click=${this.sendMessage}\n ></igc-icon-button>`;\n };\n\n private renderDefaultActionsArea = () => {\n return html` ${this.renderDefaultFileUploadButton()}\n ${this.renderDefaultSendButton()}`;\n };\n /**\n * Default typing indicator template used when no custom template is provided.\n * Renders a simple typing indicator with three dots.\n * @returns TemplateResult containing the typing indicator\n */\n private renderDefaultTypingIndicator = (): TemplateResult => {\n return html`<div part=\"typing-indicator\">\n <div part=\"typing-dot\"></div>\n <div part=\"typing-dot\"></div>\n <div part=\"typing-dot\"></div>\n </div>`;\n };\n\n /**\n * Default message template used when no custom template is provided.\n * Renders the message text, sanitized for security.\n * @param message The chat message to render\n * @returns TemplateResult containing the rendered message\n */\n private renderDefaultMessageTemplate = (\n m: IgcMessage,\n ctx: { textContent: unknown; templates: Partial<IgcChatTemplates> }\n ) => {\n const templates = { ...this._defaultTemplates, ...ctx.templates };\n return html`\n ${templates.messageAuthorTemplate(m) ?? nothing}\n ${ctx?.textContent ?? m.text}\n ${m.attachments?.length\n ? html`<igc-message-attachments .message=${m}>\n </igc-message-attachments>`\n : nothing}\n ${templates.messageActionsTemplate(m) ?? nothing}\n `;\n };\n\n private renderDefaultAttachmentHeaderText(\n attachment: IgcMessageAttachment,\n message: IgcMessage\n ) {\n return html`\n ${html`${message.sender !== this.currentUserId\n ? html`${attachment.type === 'image' ||\n attachment.file?.type.startsWith('image/')\n ? html`<igc-icon\n name=\"image\"\n collection=\"material\"\n part=\"attachment-icon\"\n ></igc-icon>`\n : html`<igc-icon\n name=\"file\"\n collection=\"material\"\n part=\"attachment-icon\"\n ></igc-icon>`}`\n : nothing} <span part=\"file-name\">${attachment.name}</span>`}\n `;\n }\n\n private handleHeaderClick(attachment: IgcMessageAttachment) {\n this.emitEvent('igcAttachmentClick', { detail: attachment });\n }\n /**\n * Default attachment header template used when no custom template is provided.\n * Renders the attachment icon and name.\n * @param attachment The message attachment to render\n * @returns TemplateResult containing the rendered attachment header\n */\n private renderDefaultAttachmentHeader = (\n attachment: IgcMessageAttachment,\n message: IgcMessage\n ) => {\n return this.renderDefaultAttachmentHeaderText(attachment, message);\n };\n\n /**\n * Default attachment content template used when no custom template is provided.\n * Renders the attachment content based on its type.\n * @param attachment The message attachment to render\n * @returns TemplateResult containing the rendered attachment content\n */\n private renderDefaultAttachmentContent = (\n attachment: IgcMessageAttachment\n ) => {\n const ext = this.getFileExtension(attachment.name);\n const isImage = this.isImageAttachment(attachment);\n const url = isImage\n ? this.getURL(attachment)\n : (this._fileIconMap[ext] ?? this._fileIconMap['default']);\n const partName = isImage ? 'image-attachment' : 'file-attachment';\n return html`<img part=\"${partName}\" src=${url} alt=${attachment.name} />`;\n };\n\n private renderDefaultMessageActionsTemplate = (\n message: IgcMessage\n ): unknown => {\n const isLastMessage = message === this.messages.at(-1);\n return message?.sender !== this.currentUserId &&\n message?.text.trim() &&\n (!isLastMessage || !this._isTyping)\n ? html`<div>\n <igc-icon-button\n id=\"copy-response-button\"\n @pointerenter=${(ev: PointerEvent) =>\n this.showTooltip(ev, this.resourceStrings.reactionCopyResponse)}\n name=\"copy-response\"\n collection=\"material\"\n variant=\"flat\"\n @click=${(e: MouseEvent) =>\n this.handleMessageActionClick(e, message)}\n ></igc-icon-button>\n <igc-icon-button\n id=\"good-response-button\"\n @pointerenter=${(ev: PointerEvent) =>\n this.showTooltip(ev, this.resourceStrings.reactionGoodResponse)}\n name=\"good-response\"\n collection=\"material\"\n variant=\"flat\"\n @click=${(e: MouseEvent) =>\n this.handleMessageActionClick(e, message)}\n ></igc-icon-button>\n <igc-icon-button\n id=\"bad-response-button\"\n @pointerenter=${(ev: PointerEvent) =>\n this.showTooltip(ev, this.resourceStrings.reactionBadResponse)}\n name=\"bad-response\"\n variant=\"flat\"\n collection=\"material\"\n @click=${(e: MouseEvent) =>\n this.handleMessageActionClick(e, message)}\n ></igc-icon-button>\n <igc-icon-button\n id=\"redo-button\"\n @pointerenter=${(ev: PointerEvent) =>\n this.showTooltip(ev, this.resourceStrings.reactionRedo)}\n name=\"redo\"\n variant=\"flat\"\n collection=\"material\"\n @click=${(e: MouseEvent) =>\n this.handleMessageActionClick(e, message)}\n ></igc-icon-button>\n <igc-tooltip\n id=\"sharedTooltip\"\n ${ref(this._sharedTooltipRef)}\n ></igc-tooltip>\n </div>`\n : nothing;\n };\n\n private handleMessageActionClick = (\n event: MouseEvent,\n message: IgcMessage\n ): void => {\n const reaction = (event.target as HTMLElement).getAttribute('name');\n this.emitEvent('igcMessageReact', {\n detail: { message, reaction },\n });\n };\n\n private renderDefaultAttachmentTemplate = (\n att: IgcMessageAttachment,\n msg: IgcMessage\n ) => {\n const isCurrentUser = msg.sender === this.currentUserId;\n const attachmentParts = {\n attachment: true,\n sent: isCurrentUser,\n };\n const contentParts = {\n 'attachment-content': true,\n sent: isCurrentUser,\n };\n const headerParts = {\n 'attachment-header': true,\n sent: isCurrentUser,\n };\n\n const content = html`<div part=${partMap(contentParts)}>\n ${this.mergedTemplates.attachmentContentTemplate(att)}\n </div>`;\n const header = html` <div\n part=${partMap(headerParts)}\n role=\"button\"\n @click=${() => this.handleHeaderClick(att)}\n >\n <div part=\"details\">\n ${this.mergedTemplates.attachmentHeaderTemplate(att, msg)}\n </div>\n </div>`;\n\n return html`<div part=${partMap(attachmentParts)}>\n ${isCurrentUser ? content : nothing} ${header}\n ${!isCurrentUser ? content : nothing}\n </div> `;\n };\n\n private renderDefaultAttachmentsTemplate = (m: IgcMessage) => {\n return html`\n ${(m.attachments ?? []).map((att: IgcMessageAttachment) =>\n this.mergedTemplates.attachmentTemplate(att, m)\n ) || nothing}\n `;\n };\n\n private showTooltip(ev: PointerEvent, text: string) {\n if (!this._sharedTooltip) return;\n this._sharedTooltip.message = text;\n this._sharedTooltip.hideDelay = 300;\n this._sharedTooltip.show(ev.composedPath()[0] as any);\n }\n\n // #endregion\n\n //#region Public properties\n /**\n * Gets the list of chat messages.\n */\n public get messages(): IgcMessage[] {\n return this._messages;\n }\n\n /**\n * Sets the list of chat messages.\n */\n public set messages(value: IgcMessage[]) {\n this._messages = value;\n this._host.requestUpdate();\n }\n\n /**\n * Gets current chat options.\n */\n public get options(): IgcChatOptions | undefined {\n return this._options;\n }\n\n /**\n * Sets chat options and requests host update.\n */\n public set options(value: IgcChatOptions) {\n this._options = value;\n this._host.requestUpdate();\n // Notify context consumers about the state change\n if (this._host.updateContextValue) {\n this._host.updateContextValue();\n }\n }\n\n /**\n * Gets the current user ID from options or returns 'user' as fallback.\n */\n public get currentUserId(): string {\n return this._options?.currentUserId ?? 'user';\n }\n\n /**\n * Gets the current suggestionsPosition from options or returns the default value 'below-messages'.\n */\n public get suggestionsPosition(): string {\n return this._options?.suggestionsPosition ?? this._suggestionsPosition;\n }\n\n /**\n * Gets the current stopTypingDelay from options or returns the default value `3000`.\n */\n public get stopTypingDelay(): number {\n return this._options?.stopTypingDelay ?? this._stopTypingDelay;\n }\n\n /**\n * Gets the text area component.\n */\n public get textArea(): IgcTextareaComponent | null {\n return this._textArea;\n }\n\n /**\n * Sets the text area component.\n */\n public set textArea(value: IgcTextareaComponent) {\n this._textArea = value;\n }\n\n /**\n * Gets the text area component.\n */\n public get textAreaRef(): Ref<IgcTextareaComponent> {\n return this._textAreaRef;\n }\n\n /**\n * Gets the list of attachments currently attached to input.\n */\n public get inputAttachments(): IgcMessageAttachment[] {\n return this._inputAttachments;\n }\n\n /**\n * Sets the input attachments and requests host update.\n */\n public set inputAttachments(value: IgcMessageAttachment[]) {\n this._inputAttachments = value;\n this._host.requestUpdate(); // Notify the host component to re-render\n // Notify context consumers about the state change\n if (this._host.updateContextValue) {\n this._host.updateContextValue();\n }\n }\n\n /**\n * Gets the current input value.\n */\n public get inputValue(): string {\n return this._inputValue;\n }\n\n /**\n * Sets the current input value and requests host update.\n */\n public set inputValue(value: string) {\n this._inputValue = value;\n this._host.requestUpdate();\n // Notify context consumers about the state change\n if (this._host.updateContextValue) {\n this._host.updateContextValue();\n }\n }\n\n /** Returns all default templates applied in the chat component. */\n public get defaultTemplates(): Required<IgcChatTemplates> {\n return this._defaultTemplates;\n }\n\n /** Sets the default templates applied in the chat component. */\n public set defaultTemplates(templates: Required<IgcChatTemplates>) {\n this._defaultTemplates = { ...templates };\n }\n\n public get mergedTemplates(): Required<IgcChatTemplates> {\n return { ...this._defaultTemplates, ...this.options?.templates };\n }\n\n public get chatRenderer(): DefaultChatRenderer | undefined {\n if (\n !this._chatRenderer ||\n this._chatRenderer !== this.options?.messageRenderer\n ) {\n this._chatRenderer = new DefaultChatRenderer(\n this.options?.messageRenderer ?? new PlainTextRenderer(),\n this.mergedTemplates\n );\n this.options?.messageRenderer?.init?.();\n }\n return this._chatRenderer;\n }\n\n /**\n * Handles input text changes.\n * Updates internal inputValue and emits 'igcInputChange' event.\n * @param e Input event from the text area\n */\n private handleInput = ({ detail }: CustomEvent<string>) => {\n if (detail === this.inputValue) return;\n\n this.inputValue = detail;\n this.emitEvent('igcInputChange', { detail: { value: this.inputValue } });\n };\n //#endregion\n\n /**\n * Creates an instance of ChatState.\n * @param chat The host `<igc-chat>` component.\n */\n constructor(chat: IgcChatComponent) {\n this._host = chat;\n registerIconFromText('copy-response', copyIcon, 'material');\n registerIconFromText('good-response', thumbUpIcon, 'material');\n registerIconFromText('bad-response', thumbDownIcon, 'material');\n registerIconFromText('redo', regenerateIcon, 'material');\n }\n\n //#region Event handlers\n\n /**\n * Emits a custom event from the host component.\n * @param name Event name (key of IgcChatComponentEventMap)\n * @param args Event detail or options\n * @returns true if event was not canceled, false otherwise\n */\n public emitEvent = (name: keyof IgcChatComponentEventMap, args?: any) => {\n return this._host.emitEvent(name, args);\n };\n\n // /**\n // * Handles input text changes.\n // * Updates internal inputValue and emits 'igcInputChange' event.\n // * @param e Input event from the text area\n // */\n // private handleInputChange = (value: string): void => {\n // if (value === this.inputValue) return;\n\n // this.inputValue = value;\n // this.emitEvent('igcInputChange', { detail: { value: this.inputValue } });\n // };\n\n //#endregion\n\n //#region Public API\n\n /**\n * Adds a new chat message.\n * Emits 'igcMessageCreated' event which can be canceled to prevent adding.\n * Clears input value and attachments on success.\n * @param message Partial message object with optional id, sender, timestamp\n */\n public addMessage = (message: {\n id?: string;\n text: string;\n sender?: string;\n timestamp?: Date;\n attachments?: IgcMessageAttachment[];\n }): void => {\n const newMessage: IgcMessage = {\n id: message.id ?? Date.now().toString(),\n text: message.text,\n sender: message.sender ?? this.currentUserId,\n timestamp: message.timestamp ?? new Date(),\n attachments: message.attachments || [],\n };\n\n const allowed = this.emitEvent('igcMessageCreated', {\n detail: newMessage,\n cancelable: true,\n });\n\n if (allowed) {\n if (!this.messages.some((msg) => msg.id === newMessage.id)) {\n this.messages = [...this.messages, newMessage];\n }\n this.inputValue = '';\n this.inputAttachments = [];\n }\n };\n\n /**\n * Adds files as attachments to the input.\n * Emits 'igcAttachmentChange' event which can be canceled to prevent adding.\n * @param files Array of File objects to attach\n */\n public attachFiles(files: File[]) {\n const newAttachments: IgcMessageAttachment[] = [];\n let count = this.inputAttachments.length;\n files.forEach((file) => {\n if (this.inputAttachments.find((a) => a.name === file.name)) {\n return;\n }\n\n const isImage = file.type.startsWith('image/');\n newAttachments.push({\n id: Date.now().toString() + count++,\n url: URL.createObjectURL(file),\n name: file.name,\n file: file,\n thumbnail: isImage ? URL.createObjectURL(file) : undefined,\n });\n });\n\n const allowed = this.emitEvent('igcAttachmentChange', {\n detail: [...this.inputAttachments, ...newAttachments],\n cancelable: true,\n });\n if (allowed) {\n this.inputAttachments = [...this.inputAttachments, ...newAttachments];\n }\n }\n\n private getURL = (attachment: IgcMessageAttachment): string => {\n if (attachment.url) {\n return attachment.url;\n }\n if (attachment.file) {\n return URL.createObjectURL(attachment.file);\n }\n return '';\n };\n\n private isImageAttachment(attachment: IgcMessageAttachment): boolean {\n return (\n attachment.type === 'image' ||\n !!attachment.file?.type.startsWith('image/')\n );\n }\n\n private _fileIconMap: Record<string, string> = {\n pdf: this._fileIcon,\n doc: this._fileIcon,\n docx: this._fileIcon,\n xls: this._fileIcon,\n xlsx: this._fileIcon,\n txt: this._fileIcon,\n json: this._jsonIcon,\n link: this._linkIcon,\n default: this._fileIcon, // A fallback icon\n };\n\n private getFileExtension(fileName: string): string {\n const parts = fileName.split('.');\n if (parts.length > 1) {\n return parts.pop()!.toLowerCase();\n }\n return '';\n }\n\n public handleKeyDown = (e: KeyboardEvent) => {\n if (e.key.toLowerCase() === enterKey.toLowerCase() && !e.shiftKey) {\n e.preventDefault();\n this.sendMessage();\n } else {\n this._lastTyped = Date.now();\n if (!this._isTyping) {\n this.emitEvent('igcTypingChange', {\n detail: { isTyping: true },\n });\n this._isTyping = true;\n }\n\n const stopTypingDelay = this.stopTypingDelay;\n setTimeout(() => {\n if (\n this._isTyping &&\n stopTypingDelay &&\n this._lastTyped + stopTypingDelay < Date.now()\n ) {\n this.emitEvent('igcTypingChange', {\n detail: { isTyping: false },\n });\n this._isTyping = false;\n }\n }, stopTypingDelay);\n }\n };\n\n private handleFocus = () => {\n this.emitEvent('igcInputFocus');\n };\n\n private handleBlur = () => {\n this.emitEvent('igcInputBlur');\n };\n\n private sendMessage = () => {\n if (!this.inputValue.trim() && this.inputAttachments.length === 0) return;\n\n this.addMessage({\n text: this.inputValue,\n attachments: this.inputAttachments,\n });\n this.inputValue = '';\n\n if (this._textArea) {\n this._textArea.style.height = 'auto';\n }\n\n this._host.updateComplete.then(() => {\n this._textArea?.focus();\n });\n };\n\n private handleFileUpload = (e: Event) => {\n const input = e.target as HTMLInputElement;\n if (!input.files || input.files.length === 0) return;\n\n const files = Array.from(input.files);\n this.attachFiles(files);\n this._host.requestUpdate();\n };\n\n /**\n * Removes an attachment by index.\n * Emits 'igcAttachmentChange' event which can be canceled to prevent removal.\n * @param index Index of the attachment to remove\n */\n private removeAttachment = (index: number): void => {\n const allowed = this.emitEvent('igcAttachmentChange', {\n detail: this.inputAttachments.filter((_, i) => i !== index),\n cancelable: true,\n });\n if (allowed) {\n this.inputAttachments = this.inputAttachments.filter(\n (_, i) => i !== index\n );\n }\n };\n\n /**\n * Handles when a suggestion is clicked.\n * Adds the suggestion as a new message and focuses the text area.\n * @param suggestion The suggestion string clicked\n */\n public handleSuggestionClick = (suggestion: string): void => {\n this.addMessage({ text: suggestion });\n if (this.textArea) {\n this.textArea.focus();\n }\n };\n\n /**\n * Updates the chat options partially.\n * @param options Partial options to merge with current options\n */\n public updateOptions(options: Partial<IgcChatOptions>): void {\n this.options = { ...this.options, ...options };\n }\n\n /**\n * Updates the internal cache for accepted file types.\n * Parses the acceptedFiles string option into extensions, mimeTypes, and wildcard types.\n */\n public updateAcceptedTypesCache = () => {\n if (!this.options?.acceptedFiles) {\n this._acceptedTypesCache = null;\n return;\n }\n\n const types = this.options?.acceptedFiles\n .split(',')\n .map((type) => type.trim().toLowerCase());\n this._acceptedTypesCache = {\n extensions: new Set(types.filter((t) => t.startsWith('.'))),\n mimeTypes: new Set(\n types.filter((t) => !t.startsWith('.') && !t.endsWith('/*'))\n ),\n wildcardTypes: new Set(\n types.filter((t) => t.endsWith('/*')).map((t) => t.slice(0, -2))\n ),\n };\n };\n\n /**\n * Checks if a file's type or extension is accepted by the chat's acceptedFiles setting.\n * @param file File object to check\n * @param type Optional MIME type override if no file provided\n * @returns True if accepted, false otherwise\n */\n public isFileTypeAccepted = (file: File, type = ''): boolean => {\n if (!this._acceptedTypesCache) return true;\n\n if (file === null && type === '') return false;\n\n const fileType =\n file != null ? file.type.toLowerCase() : type.toLowerCase();\n const fileExtension =\n file != null\n ? `.${file.name.split('.').pop()?.toLowerCase()}`\n : `.${type.split('/').pop()?.toLowerCase()}`;\n\n // Check file extension\n if (this._acceptedTypesCache.extensions.has(fileExtension)) {\n return true;\n }\n\n // Check exact MIME type\n if (this._acceptedTypesCache.mimeTypes.has(fileType)) {\n return true;\n }\n\n // Check wildcard MIME types\n const [fileBaseType] = fileType.split('/');\n return this._acceptedTypesCache.wildcardTypes.has(fileBaseType);\n };\n\n /**\n * Checks if a slot is empty.\n * @param name Slot name to check\n * @returns True if the slot has content, false otherwise\n */\n public hasSlotContent(name: string): boolean {\n return (\n this._host.renderRoot.querySelector<HTMLSlotElement>(`slot[name=${name}]`)\n ?.childNodes.length !== 0\n );\n }\n //#endregion\n}\n\nexport function createChatState(host: IgcChatComponent): ChatState {\n return new ChatState(host);\n}\n"]}