@luzmo/analytics-components-kit 1.0.1-alpha.144 → 1.0.1-alpha.146

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 (160) hide show
  1. package/angular/esm/types/ai-chat.types.d.ts +3 -0
  2. package/angular/tsconfig.json +3 -0
  3. package/angular/types/ai-chat.types.ts +5 -0
  4. package/components/ai-chat/ai-chat-streaming.d.ts +14 -0
  5. package/components/ai-chat/ai-chat.d.ts +43 -5
  6. package/components/ai-chat/index.cjs +1 -1
  7. package/components/ai-chat/index.d.ts +3 -0
  8. package/components/ai-chat/index.js +6 -6
  9. package/components/ai-chat/request-contract.d.ts +2 -0
  10. package/components/{ai-chat-CEX2VQeq.js → ai-chat-BEjlRutF.js} +262 -99
  11. package/components/ai-chat-BH0PuNwY.cjs +113 -0
  12. package/components/ai-interaction-textarea/index.cjs +1 -1
  13. package/components/ai-interaction-textarea/index.js +3 -3
  14. package/components/data-fields-select/index.cjs +1 -1
  15. package/components/data-fields-select/index.js +3 -3
  16. package/components/{data-fields-select-dbn1KG3y.js → data-fields-select-CHOKEMb2.js} +1 -1
  17. package/components/{data-fields-select-Byfdph5v.cjs → data-fields-select-_WjjNpcl.cjs} +1 -1
  18. package/components/dataset-selector-list/index.cjs +1 -1
  19. package/components/dataset-selector-list/index.js +2 -2
  20. package/components/{dataset-selector-list-BDSXGUDh.js → dataset-selector-list-C5FvwP-r.js} +1 -1
  21. package/components/{dataset-selector-list-CH3lwAjJ.cjs → dataset-selector-list-DYsi3LBF.cjs} +1 -1
  22. package/components/dataset-selector-row/index.cjs +1 -1
  23. package/components/dataset-selector-row/index.js +3 -3
  24. package/components/{dataset-selector-row-DPyGMP__.js → dataset-selector-row-BKIFTyJl.js} +1 -1
  25. package/components/{dataset-selector-row-DdTnaQ6w.cjs → dataset-selector-row-Qwz9WmR4.cjs} +1 -1
  26. package/components/display-settings/index.cjs +1 -1
  27. package/components/display-settings/index.js +2 -2
  28. package/components/display-settings-binning/index.cjs +1 -1
  29. package/components/display-settings-binning/index.js +3 -3
  30. package/components/{display-settings-binning-DP9oFC6h.js → display-settings-binning-B58LCqmn.js} +1 -1
  31. package/components/{display-settings-binning-C9VF0K9q.cjs → display-settings-binning-Bte25mmH.cjs} +1 -1
  32. package/components/display-settings-datetime/index.cjs +1 -1
  33. package/components/display-settings-datetime/index.js +3 -3
  34. package/components/{display-settings-datetime-C3LDVEcH.cjs → display-settings-datetime-DAL8zjtk.cjs} +1 -1
  35. package/components/{display-settings-datetime-DxBUXAuH.js → display-settings-datetime-DxSNsem7.js} +1 -1
  36. package/components/display-settings-grand-totals/index.cjs +1 -1
  37. package/components/display-settings-grand-totals/index.js +3 -3
  38. package/components/{display-settings-grand-totals-C3QlInwU.cjs → display-settings-grand-totals-NWow1vhX.cjs} +1 -1
  39. package/components/{display-settings-grand-totals-BiGxXuw2.js → display-settings-grand-totals-Poa2qL3U.js} +1 -1
  40. package/components/display-settings-numeric/index.cjs +1 -1
  41. package/components/display-settings-numeric/index.js +3 -3
  42. package/components/{display-settings-numeric-BvLDL-qP.js → display-settings-numeric-CTaS1NhY.js} +1 -1
  43. package/components/{display-settings-numeric-CyoTJKZv.cjs → display-settings-numeric-eG0gr9Jn.cjs} +1 -1
  44. package/components/display-settings-period-over-period/index.cjs +1 -1
  45. package/components/display-settings-period-over-period/index.js +3 -3
  46. package/components/{display-settings-period-over-period-CvvgRCVH.js → display-settings-period-over-period-D9r-6vbW.js} +1 -1
  47. package/components/{display-settings-period-over-period-Cdmaf_Rw.cjs → display-settings-period-over-period-DjB0K-Zj.cjs} +1 -1
  48. package/components/draggable-data-field/index.cjs +1 -1
  49. package/components/draggable-data-field/index.js +3 -3
  50. package/components/{draggable-data-field-C_zHA_mn.js → draggable-data-field-BIWzuhyP.js} +1 -1
  51. package/components/{draggable-data-field-CbF7N-o7.cjs → draggable-data-field-Cez4-c6O.cjs} +1 -1
  52. package/components/draggable-data-field-level/index.cjs +1 -1
  53. package/components/draggable-data-field-level/index.js +2 -2
  54. package/components/draggable-data-fields-panel/index.cjs +1 -1
  55. package/components/draggable-data-fields-panel/index.js +4 -4
  56. package/components/{draggable-data-fields-panel-DOdI9NaC.cjs → draggable-data-fields-panel-B0DzaGsv.cjs} +1 -1
  57. package/components/{draggable-data-fields-panel-D7oa6gGZ.js → draggable-data-fields-panel-C3IwyVQh.js} +1 -1
  58. package/components/droppable-slot/index.cjs +1 -1
  59. package/components/droppable-slot/index.js +3 -3
  60. package/components/{droppable-slot-oB61SQKO.js → droppable-slot-BEKnuzJd.js} +1 -1
  61. package/components/{droppable-slot-DtFdADiO.cjs → droppable-slot-CHtF9RZo.cjs} +1 -1
  62. package/components/edit-filters/index.cjs +1 -1
  63. package/components/edit-filters/index.js +10 -10
  64. package/components/{edit-filters-B29YfSBe.js → edit-filters-BHiGSnrn.js} +1 -1
  65. package/components/{edit-filters-geWHEBCw.cjs → edit-filters-CoVNGAfA.cjs} +1 -1
  66. package/components/edit-item/index.cjs +1 -1
  67. package/components/edit-item/index.js +2 -2
  68. package/components/edit-option/index.cjs +1 -1
  69. package/components/edit-option/index.js +2 -2
  70. package/components/edit-option-action-button-group/index.cjs +1 -1
  71. package/components/edit-option-action-button-group/index.js +2 -2
  72. package/components/edit-option-color-palette-picker/index.cjs +1 -1
  73. package/components/edit-option-color-palette-picker/index.js +2 -2
  74. package/components/edit-option-color-picker/index.cjs +1 -1
  75. package/components/edit-option-color-picker/index.js +2 -2
  76. package/components/edit-option-color-range/index.cjs +1 -1
  77. package/components/edit-option-color-range/index.js +2 -2
  78. package/components/edit-option-multi-language-field/index.cjs +1 -1
  79. package/components/edit-option-multi-language-field/index.js +2 -2
  80. package/components/edit-option-number-field/index.cjs +1 -1
  81. package/components/edit-option-number-field/index.js +2 -2
  82. package/components/edit-option-picker/index.cjs +1 -1
  83. package/components/edit-option-picker/index.js +2 -2
  84. package/components/edit-option-position-picker/index.cjs +1 -1
  85. package/components/edit-option-position-picker/index.js +2 -2
  86. package/components/edit-option-positions-number-field/index.cjs +1 -1
  87. package/components/edit-option-positions-number-field/index.js +2 -2
  88. package/components/edit-option-radio-button-group/index.cjs +1 -1
  89. package/components/edit-option-radio-button-group/index.js +2 -2
  90. package/components/edit-option-slider/index.cjs +1 -1
  91. package/components/edit-option-slider/index.js +2 -2
  92. package/components/edit-option-switch/index.cjs +1 -1
  93. package/components/edit-option-switch/index.js +2 -2
  94. package/components/edit-option-text-field/index.cjs +1 -1
  95. package/components/edit-option-text-field/index.js +2 -2
  96. package/components/{es-cTUhzLmn.js → es-CjgYaJJY.js} +1 -0
  97. package/components/es-D8zLt69A.cjs +20 -0
  98. package/components/filter-expression-picker/index.cjs +1 -1
  99. package/components/filter-expression-picker/index.js +3 -3
  100. package/components/{filter-expression-picker-D83ya_dt.js → filter-expression-picker-Bbu8Bd25.js} +1 -1
  101. package/components/{filter-expression-picker-wOcgU2No.cjs → filter-expression-picker-Dc3K44W0.cjs} +1 -1
  102. package/components/filter-item/index.cjs +1 -1
  103. package/components/filter-item/index.js +9 -9
  104. package/components/{filter-item-ByKzQ-fl.cjs → filter-item-C7i8LLr-.cjs} +1 -1
  105. package/components/{filter-item-BdnrbMUW.js → filter-item-DmzZL5Wr.js} +2 -2
  106. package/components/filter-value-picker/index.cjs +1 -1
  107. package/components/filter-value-picker/index.js +6 -6
  108. package/components/{filter-value-picker-Co9Vka2J.cjs → filter-value-picker-CwQLOgTl.cjs} +1 -1
  109. package/components/{filter-value-picker-B2BjJuIa.js → filter-value-picker-Vq-PfjoU.js} +1 -1
  110. package/components/filter-value-picker-datetime/index.cjs +1 -1
  111. package/components/filter-value-picker-datetime/index.js +3 -3
  112. package/components/{filter-value-picker-datetime-BzMfKPkZ.cjs → filter-value-picker-datetime-By3czRqA.cjs} +1 -1
  113. package/components/{filter-value-picker-datetime-BOheBbvB.js → filter-value-picker-datetime-Cf60JAgg.js} +1 -1
  114. package/components/filter-value-picker-hierarchy/index.cjs +1 -1
  115. package/components/filter-value-picker-hierarchy/index.js +3 -3
  116. package/components/{filter-value-picker-hierarchy-Cwq8GLp4.js → filter-value-picker-hierarchy-CL1YmeY9.js} +1 -1
  117. package/components/{filter-value-picker-hierarchy-Dgdj-xqx.cjs → filter-value-picker-hierarchy-CpvItjbb.cjs} +1 -1
  118. package/components/filter-value-picker-numeric/index.cjs +1 -1
  119. package/components/filter-value-picker-numeric/index.js +3 -3
  120. package/components/{filter-value-picker-numeric-CHFRRe1f.js → filter-value-picker-numeric-CDUGCKAy.js} +1 -1
  121. package/components/{filter-value-picker-numeric-CZrRBHuR.cjs → filter-value-picker-numeric-Dq143AGo.cjs} +1 -1
  122. package/components/grid/index.cjs +1 -1
  123. package/components/grid/index.js +3 -3
  124. package/components/{grid-BxeX-SG-.cjs → grid-By5MAIqI.cjs} +9 -8
  125. package/components/{grid-CfCH13sk.js → grid-DN9I7DDY.js} +9 -8
  126. package/components/index.cjs +1 -1
  127. package/components/index.js +27 -27
  128. package/components/item-data-drop-panel/index.cjs +1 -1
  129. package/components/item-data-drop-panel/index.js +4 -4
  130. package/components/{item-data-drop-panel-BNf_N7GH.js → item-data-drop-panel-hXvAIkBq.js} +1 -1
  131. package/components/{item-data-drop-panel-Dcj5Gz29.cjs → item-data-drop-panel-jxlsaggu.cjs} +1 -1
  132. package/components/item-data-picker-panel/index.cjs +1 -1
  133. package/components/item-data-picker-panel/index.js +5 -5
  134. package/components/{item-data-picker-panel-OK_nMbm4.js → item-data-picker-panel-C7wyaWko.js} +1 -1
  135. package/components/{item-data-picker-panel-GD6CRais.cjs → item-data-picker-panel-sWJGFZ7e.cjs} +1 -1
  136. package/components/{localized-mixin-BmZhC9XV.cjs → localized-mixin-BhUvOsd7.cjs} +1 -1
  137. package/components/{localized-mixin-CgQFYGOU.js → localized-mixin-HngLqDZn.js} +1 -1
  138. package/components/{set-locale-CRNDDu2d.js → set-locale-C3o6ooUV.js} +1 -1
  139. package/components/{set-locale-DjOkyNGu.cjs → set-locale-CdlBx8s9.cjs} +1 -1
  140. package/components/slot-contents-picker/index.cjs +1 -1
  141. package/components/slot-contents-picker/index.js +4 -4
  142. package/components/{slot-contents-picker-BjqOUNKU.cjs → slot-contents-picker-CBxXz7nw.cjs} +11 -1
  143. package/components/{slot-contents-picker-BNWBIypw.js → slot-contents-picker-DrDo62G7.js} +11 -1
  144. package/components/slot-menu/index.cjs +1 -1
  145. package/components/slot-menu/index.js +2 -2
  146. package/components/slot-menu-list/index.cjs +1 -1
  147. package/components/slot-menu-list/index.js +2 -2
  148. package/components/utils/base.cjs +1 -1
  149. package/components/utils/base.js +2 -2
  150. package/components/utils.cjs +1 -1
  151. package/components/utils.js +1 -1
  152. package/components/viz-item-menu/index.cjs +1 -1
  153. package/components/viz-item-menu/index.js +3 -3
  154. package/components/{viz-item-menu-_DLQJFWj.js → viz-item-menu-BX_S-XUm.js} +1 -1
  155. package/components/{viz-item-menu-BNgd025g.cjs → viz-item-menu-CGhptlJg.cjs} +1 -1
  156. package/custom-elements.json +192 -10
  157. package/package.json +1 -1
  158. package/types/ai-chat.types.d.ts +3 -0
  159. package/components/ai-chat-PZrWiUxE.cjs +0 -90
  160. package/components/es-CNpZK6tJ.cjs +0 -20
@@ -22,7 +22,8 @@ import { t as __decorate } from "./decorate-Da6S_xrw.js";
22
22
  import { msg } from "@lit/localize/lit-localize";
23
23
  import { luzmoIcon, luzmoSpin } from "@luzmo/icons";
24
24
  import "@luzmo/lucero/chat-message";
25
- import { html, unsafeCSS } from "lit";
25
+ import "@luzmo/lucero/progress-steps";
26
+ import { html, nothing, unsafeCSS } from "lit";
26
27
  import { property, state } from "lit/decorators.js";
27
28
  import { unsafeHTML } from "lit/directives/unsafe-html.js";
28
29
  var { entries, setPrototypeOf, isFrozen, getPrototypeOf, getOwnPropertyDescriptor } = Object, { freeze, seal, create } = Object, { apply, construct } = typeof Reflect < "u" && Reflect;
@@ -217,7 +218,7 @@ var html$1 = freeze(/* @__PURE__ */ "a.abbr.acronym.address.area.article.aside.a
217
218
  function createDOMPurify() {
218
219
  let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : getGlobal(), t = (e) => createDOMPurify(e);
219
220
  if (t.version = "3.3.1", t.removed = [], !e || !e.document || e.document.nodeType !== NODE_TYPE.document || !e.Element) return t.isSupported = !1, t;
220
- let { document: n } = e, r = n, i = r.currentScript, { DocumentFragment: a, HTMLTemplateElement: o, Node: s, Element: c, NodeFilter: l, NamedNodeMap: d = e.NamedNodeMap || e.MozNamedAttrMap, HTMLFormElement: Re, DOMParser: ze, trustedTypes: f } = e, p = c.prototype, Be = lookupGetter(p, "cloneNode"), Ve = lookupGetter(p, "remove"), He = lookupGetter(p, "nextSibling"), Ue = lookupGetter(p, "childNodes"), m = lookupGetter(p, "parentNode");
221
+ let { document: n } = e, r = n, i = r.currentScript, { DocumentFragment: a, HTMLTemplateElement: o, Node: s, Element: c, NodeFilter: l, NamedNodeMap: u = e.NamedNodeMap || e.MozNamedAttrMap, HTMLFormElement: Re, DOMParser: ze, trustedTypes: f } = e, p = c.prototype, Be = lookupGetter(p, "cloneNode"), Ve = lookupGetter(p, "remove"), He = lookupGetter(p, "nextSibling"), Ue = lookupGetter(p, "childNodes"), m = lookupGetter(p, "parentNode");
221
222
  if (typeof o == "function") {
222
223
  let e = n.createElement("template");
223
224
  e.content && e.content.ownerDocument && (n = e.content.ownerDocument);
@@ -267,7 +268,7 @@ function createDOMPurify() {
267
268
  enumerable: !0,
268
269
  value: null
269
270
  }
270
- })), nt = !0, O = !0, rt = !1, it = !0, k = !1, A = !0, j = !1, M = !1, N = !1, P = !1, F = !1, I = !1, at = !0, ot = !1, L = !0, R = !1, z = {}, B = null, V = addToSet({}, [
271
+ })), nt = !0, O = !0, rt = !1, it = !0, k = !1, A = !0, j = !1, M = !1, N = !1, P = !1, F = !1, I = !1, at = !0, ot = !1, st = !0, L = !1, R = {}, z = null, B = addToSet({}, [
271
272
  "annotation-xml",
272
273
  "audio",
273
274
  "colgroup",
@@ -293,14 +294,14 @@ function createDOMPurify() {
293
294
  "title",
294
295
  "video",
295
296
  "xmp"
296
- ]), st = null, ct = addToSet({}, [
297
+ ]), ct = null, lt = addToSet({}, [
297
298
  "audio",
298
299
  "video",
299
300
  "img",
300
301
  "source",
301
302
  "image",
302
303
  "track"
303
- ]), lt = null, ut = addToSet({}, [
304
+ ]), V = null, ut = addToSet({}, [
304
305
  "alt",
305
306
  "class",
306
307
  "for",
@@ -336,7 +337,7 @@ function createDOMPurify() {
336
337
  }, vt = function() {
337
338
  let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
338
339
  if (!(X && X === e)) {
339
- if ((!e || typeof e != "object") && (e = {}), e = clone(e), J = ht.indexOf(e.PARSER_MEDIA_TYPE) === -1 ? "text/html" : e.PARSER_MEDIA_TYPE, Y = J === "application/xhtml+xml" ? stringToString : stringToLowerCase, S = objectHasOwnProperty(e, "ALLOWED_TAGS") ? addToSet({}, e.ALLOWED_TAGS, Y) : et, C = objectHasOwnProperty(e, "ALLOWED_ATTR") ? addToSet({}, e.ALLOWED_ATTR, Y) : tt, ft = objectHasOwnProperty(e, "ALLOWED_NAMESPACES") ? addToSet({}, e.ALLOWED_NAMESPACES, stringToString) : pt, lt = objectHasOwnProperty(e, "ADD_URI_SAFE_ATTR") ? addToSet(clone(ut), e.ADD_URI_SAFE_ATTR, Y) : ut, st = objectHasOwnProperty(e, "ADD_DATA_URI_TAGS") ? addToSet(clone(ct), e.ADD_DATA_URI_TAGS, Y) : ct, B = objectHasOwnProperty(e, "FORBID_CONTENTS") ? addToSet({}, e.FORBID_CONTENTS, Y) : V, T = objectHasOwnProperty(e, "FORBID_TAGS") ? addToSet({}, e.FORBID_TAGS, Y) : clone({}), E = objectHasOwnProperty(e, "FORBID_ATTR") ? addToSet({}, e.FORBID_ATTR, Y) : clone({}), z = objectHasOwnProperty(e, "USE_PROFILES") ? e.USE_PROFILES : !1, nt = e.ALLOW_ARIA_ATTR !== !1, O = e.ALLOW_DATA_ATTR !== !1, rt = e.ALLOW_UNKNOWN_PROTOCOLS || !1, it = e.ALLOW_SELF_CLOSE_IN_ATTR !== !1, k = e.SAFE_FOR_TEMPLATES || !1, A = e.SAFE_FOR_XML !== !1, j = e.WHOLE_DOCUMENT || !1, P = e.RETURN_DOM || !1, F = e.RETURN_DOM_FRAGMENT || !1, I = e.RETURN_TRUSTED_TYPE || !1, N = e.FORCE_BODY || !1, at = e.SANITIZE_DOM !== !1, ot = e.SANITIZE_NAMED_PROPS || !1, L = e.KEEP_CONTENT !== !1, R = e.IN_PLACE || !1, $e = e.ALLOWED_URI_REGEXP || IS_ALLOWED_URI, G = e.NAMESPACE || W, K = e.MATHML_TEXT_INTEGRATION_POINTS || K, q = e.HTML_INTEGRATION_POINTS || q, w = e.CUSTOM_ELEMENT_HANDLING || {}, e.CUSTOM_ELEMENT_HANDLING && _t(e.CUSTOM_ELEMENT_HANDLING.tagNameCheck) && (w.tagNameCheck = e.CUSTOM_ELEMENT_HANDLING.tagNameCheck), e.CUSTOM_ELEMENT_HANDLING && _t(e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck) && (w.attributeNameCheck = e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck), e.CUSTOM_ELEMENT_HANDLING && typeof e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements == "boolean" && (w.allowCustomizedBuiltInElements = e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements), k && (O = !1), F && (P = !0), z && (S = addToSet({}, text), C = [], z.html === !0 && (addToSet(S, html$1), addToSet(C, html$2)), z.svg === !0 && (addToSet(S, svg$1), addToSet(C, svg), addToSet(C, xml)), z.svgFilters === !0 && (addToSet(S, svgFilters), addToSet(C, svg), addToSet(C, xml)), z.mathMl === !0 && (addToSet(S, mathMl$1), addToSet(C, mathMl), addToSet(C, xml))), e.ADD_TAGS && (typeof e.ADD_TAGS == "function" ? D.tagCheck = e.ADD_TAGS : (S === et && (S = clone(S)), addToSet(S, e.ADD_TAGS, Y))), e.ADD_ATTR && (typeof e.ADD_ATTR == "function" ? D.attributeCheck = e.ADD_ATTR : (C === tt && (C = clone(C)), addToSet(C, e.ADD_ATTR, Y))), e.ADD_URI_SAFE_ATTR && addToSet(lt, e.ADD_URI_SAFE_ATTR, Y), e.FORBID_CONTENTS && (B === V && (B = clone(B)), addToSet(B, e.FORBID_CONTENTS, Y)), e.ADD_FORBID_CONTENTS && (B === V && (B = clone(B)), addToSet(B, e.ADD_FORBID_CONTENTS, Y)), L && (S["#text"] = !0), j && addToSet(S, [
340
+ if ((!e || typeof e != "object") && (e = {}), e = clone(e), J = ht.indexOf(e.PARSER_MEDIA_TYPE) === -1 ? "text/html" : e.PARSER_MEDIA_TYPE, Y = J === "application/xhtml+xml" ? stringToString : stringToLowerCase, S = objectHasOwnProperty(e, "ALLOWED_TAGS") ? addToSet({}, e.ALLOWED_TAGS, Y) : et, C = objectHasOwnProperty(e, "ALLOWED_ATTR") ? addToSet({}, e.ALLOWED_ATTR, Y) : tt, ft = objectHasOwnProperty(e, "ALLOWED_NAMESPACES") ? addToSet({}, e.ALLOWED_NAMESPACES, stringToString) : pt, V = objectHasOwnProperty(e, "ADD_URI_SAFE_ATTR") ? addToSet(clone(ut), e.ADD_URI_SAFE_ATTR, Y) : ut, ct = objectHasOwnProperty(e, "ADD_DATA_URI_TAGS") ? addToSet(clone(lt), e.ADD_DATA_URI_TAGS, Y) : lt, z = objectHasOwnProperty(e, "FORBID_CONTENTS") ? addToSet({}, e.FORBID_CONTENTS, Y) : B, T = objectHasOwnProperty(e, "FORBID_TAGS") ? addToSet({}, e.FORBID_TAGS, Y) : clone({}), E = objectHasOwnProperty(e, "FORBID_ATTR") ? addToSet({}, e.FORBID_ATTR, Y) : clone({}), R = objectHasOwnProperty(e, "USE_PROFILES") ? e.USE_PROFILES : !1, nt = e.ALLOW_ARIA_ATTR !== !1, O = e.ALLOW_DATA_ATTR !== !1, rt = e.ALLOW_UNKNOWN_PROTOCOLS || !1, it = e.ALLOW_SELF_CLOSE_IN_ATTR !== !1, k = e.SAFE_FOR_TEMPLATES || !1, A = e.SAFE_FOR_XML !== !1, j = e.WHOLE_DOCUMENT || !1, P = e.RETURN_DOM || !1, F = e.RETURN_DOM_FRAGMENT || !1, I = e.RETURN_TRUSTED_TYPE || !1, N = e.FORCE_BODY || !1, at = e.SANITIZE_DOM !== !1, ot = e.SANITIZE_NAMED_PROPS || !1, st = e.KEEP_CONTENT !== !1, L = e.IN_PLACE || !1, $e = e.ALLOWED_URI_REGEXP || IS_ALLOWED_URI, G = e.NAMESPACE || W, K = e.MATHML_TEXT_INTEGRATION_POINTS || K, q = e.HTML_INTEGRATION_POINTS || q, w = e.CUSTOM_ELEMENT_HANDLING || {}, e.CUSTOM_ELEMENT_HANDLING && _t(e.CUSTOM_ELEMENT_HANDLING.tagNameCheck) && (w.tagNameCheck = e.CUSTOM_ELEMENT_HANDLING.tagNameCheck), e.CUSTOM_ELEMENT_HANDLING && _t(e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck) && (w.attributeNameCheck = e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck), e.CUSTOM_ELEMENT_HANDLING && typeof e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements == "boolean" && (w.allowCustomizedBuiltInElements = e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements), k && (O = !1), F && (P = !0), R && (S = addToSet({}, text), C = [], R.html === !0 && (addToSet(S, html$1), addToSet(C, html$2)), R.svg === !0 && (addToSet(S, svg$1), addToSet(C, svg), addToSet(C, xml)), R.svgFilters === !0 && (addToSet(S, svgFilters), addToSet(C, svg), addToSet(C, xml)), R.mathMl === !0 && (addToSet(S, mathMl$1), addToSet(C, mathMl), addToSet(C, xml))), e.ADD_TAGS && (typeof e.ADD_TAGS == "function" ? D.tagCheck = e.ADD_TAGS : (S === et && (S = clone(S)), addToSet(S, e.ADD_TAGS, Y))), e.ADD_ATTR && (typeof e.ADD_ATTR == "function" ? D.attributeCheck = e.ADD_ATTR : (C === tt && (C = clone(C)), addToSet(C, e.ADD_ATTR, Y))), e.ADD_URI_SAFE_ATTR && addToSet(V, e.ADD_URI_SAFE_ATTR, Y), e.FORBID_CONTENTS && (z === B && (z = clone(z)), addToSet(z, e.FORBID_CONTENTS, Y)), e.ADD_FORBID_CONTENTS && (z === B && (z = clone(z)), addToSet(z, e.ADD_FORBID_CONTENTS, Y)), st && (S["#text"] = !0), j && addToSet(S, [
340
341
  "html",
341
342
  "head",
342
343
  "body"
@@ -407,7 +408,7 @@ function createDOMPurify() {
407
408
  }, Ct = function(e) {
408
409
  return We.call(e.ownerDocument || e, e, l.SHOW_ELEMENT | l.SHOW_COMMENT | l.SHOW_TEXT | l.SHOW_PROCESSING_INSTRUCTION | l.SHOW_CDATA_SECTION, null);
409
410
  }, wt = function(e) {
410
- return e instanceof Re && (typeof e.nodeName != "string" || typeof e.textContent != "string" || typeof e.removeChild != "function" || !(e.attributes instanceof d) || typeof e.removeAttribute != "function" || typeof e.setAttribute != "function" || typeof e.namespaceURI != "string" || typeof e.insertBefore != "function" || typeof e.hasChildNodes != "function");
411
+ return e instanceof Re && (typeof e.nodeName != "string" || typeof e.textContent != "string" || typeof e.removeChild != "function" || !(e.attributes instanceof u) || typeof e.removeAttribute != "function" || typeof e.setAttribute != "function" || typeof e.namespaceURI != "string" || typeof e.insertBefore != "function" || typeof e.hasChildNodes != "function");
411
412
  }, Tt = function(e) {
412
413
  return typeof s == "function" && e instanceof s;
413
414
  };
@@ -426,7 +427,7 @@ function createDOMPurify() {
426
427
  }), A && e.hasChildNodes() && !Tt(e.firstElementChild) && regExpTest(/<[/\w!]/g, e.innerHTML) && regExpTest(/<[/\w!]/g, e.textContent) || e.nodeType === NODE_TYPE.progressingInstruction || A && e.nodeType === NODE_TYPE.comment && regExpTest(/<[/\w]/g, e.data)) return Z(e), !0;
427
428
  if (!(D.tagCheck instanceof Function && D.tagCheck(r)) && (!S[r] || T[r])) {
428
429
  if (!T[r] && Ot(r) && (w.tagNameCheck instanceof RegExp && regExpTest(w.tagNameCheck, r) || w.tagNameCheck instanceof Function && w.tagNameCheck(r))) return !1;
429
- if (L && !B[r]) {
430
+ if (st && !z[r]) {
430
431
  let t = m(e) || e.parentNode, n = Ue(e) || e.childNodes;
431
432
  if (n && t) {
432
433
  let r = n.length;
@@ -450,7 +451,7 @@ function createDOMPurify() {
450
451
  if (!(O && !E[t] && regExpTest(Je, t)) && !(nt && regExpTest(Ye, t)) && !(D.attributeCheck instanceof Function && D.attributeCheck(t, e))) {
451
452
  if (!C[t] || E[t]) {
452
453
  if (!(Ot(e) && (w.tagNameCheck instanceof RegExp && regExpTest(w.tagNameCheck, e) || w.tagNameCheck instanceof Function && w.tagNameCheck(e)) && (w.attributeNameCheck instanceof RegExp && regExpTest(w.attributeNameCheck, t) || w.attributeNameCheck instanceof Function && w.attributeNameCheck(t, e)) || t === "is" && w.allowCustomizedBuiltInElements && (w.tagNameCheck instanceof RegExp && regExpTest(w.tagNameCheck, r) || w.tagNameCheck instanceof Function && w.tagNameCheck(r)))) return !1;
453
- } else if (!lt[t] && !regExpTest($e, stringReplace(r, Ze, "")) && !((t === "src" || t === "xlink:href" || t === "href") && e !== "script" && stringIndexOf(r, "data:") === 0 && st[e]) && !(rt && !regExpTest(Xe, stringReplace(r, Ze, ""))) && r) return !1;
454
+ } else if (!V[t] && !regExpTest($e, stringReplace(r, Ze, "")) && !((t === "src" || t === "xlink:href" || t === "href") && e !== "script" && stringIndexOf(r, "data:") === 0 && ct[e]) && !(rt && !regExpTest(Xe, stringReplace(r, Ze, ""))) && r) return !1;
454
455
  }
455
456
  return !0;
456
457
  }, Ot = function(e) {
@@ -523,7 +524,7 @@ function createDOMPurify() {
523
524
  if (e = e.toString(), typeof e != "string") throw typeErrorCreate("dirty is not a string, aborting");
524
525
  } else throw typeErrorCreate("toString is not a function");
525
526
  if (!t.isSupported) return e;
526
- if (M || vt(n), t.removed = [], typeof e == "string" && (R = !1), R) {
527
+ if (M || vt(n), t.removed = [], typeof e == "string" && (L = !1), L) {
527
528
  if (e.nodeName) {
528
529
  let t = Y(e.nodeName);
529
530
  if (!S[t] || T[t]) throw typeErrorCreate("root node is forbidden and cannot be sanitized in-place");
@@ -534,9 +535,9 @@ function createDOMPurify() {
534
535
  if (i = St(e), !i) return P ? null : I ? g : "";
535
536
  }
536
537
  i && N && Z(i.firstChild);
537
- let u = Ct(R ? e : i);
538
+ let u = Ct(L ? e : i);
538
539
  for (; c = u.nextNode();) Et(c), kt(c), c.content instanceof a && At(c.content);
539
- if (R) return e;
540
+ if (L) return e;
540
541
  if (P) {
541
542
  if (F) for (l = Ge.call(i.ownerDocument); i.firstChild;) l.appendChild(i.firstChild);
542
543
  else l = i;
@@ -570,9 +571,69 @@ function createDOMPurify() {
570
571
  v = _createHooksMap();
571
572
  }, t;
572
573
  }
573
- var purify = createDOMPurify(), ai_chat_module_default = ":host{box-sizing:border-box;flex-direction:column;width:100%;height:100%;display:flex}:host .chat-container{background:var(--luzmo-ai-chat-background,var(--ai-chat-background));border-radius:var(--luzmo-ai-chat-border-radius,var(--ai-chat-border-radius));width:100%;height:100%;min-height:0;padding:var(--luzmo-ai-chat-padding,var(--ai-chat-padding));gap:var(--luzmo-ai-chat-gap,var(--ai-chat-gap));border:var(--luzmo-ai-chat-border,var(--ai-chat-border));box-shadow:var(--luzmo-ai-chat-box-shadow,var(--ai-chat-box-shadow));box-sizing:border-box;flex-direction:column;flex:1;display:flex;overflow:hidden}:host .chat-messages-container{gap:var(--luzmo-ai-chat-gap,var(--ai-chat-gap));flex-direction:column;flex:1;min-height:0;display:flex;overflow:auto}:host luzmo-chat-message{--luzmo-primary:rgba(var(--luzmo-primary-rgb),.08);--chat-message-primary-text-color:var(--luzmo-font-color);--chat-message-primary-border-color:transparent}:host luzmo-chat-message.error{color:var(--luzmo-ai-chat-error-message-color,var(--ai-chat-error-message-color))}:host luzmo-ai-interaction-textarea{flex-grow:0;flex-shrink:0}:host .loading-message{color:var(--luzmo-font-color);align-items:center;gap:.5rem;display:flex}:host .loading-message svg{color:var(--luzmo-ai-chat-loading-message-color,var(--ai-chat-loading-message-color));font-size:var(--luzmo-ai-chat-loading-message-icon-font-size,var(--ai-chat-loading-message-icon-font-size,1rem));justify-content:center;align-items:center;display:flex}:host .loading-message svg.spin{animation:1s linear infinite spin}@keyframes spin{to{transform:rotate(360deg)}}:host{--ai-chat-background:var(--luzmo-background-color);--ai-chat-border-radius:0;--ai-chat-padding:0;--ai-chat-gap:1rem;--ai-chat-max-height:none;--ai-chat-messages-flex:1;--ai-chat-border:none;--ai-chat-box-shadow:none;--ai-chat-loading-message-color:var(--luzmo-primary);--ai-chat-error-message-color:var(--luzmo-danger,#dc3545)}";
574
+ var purify = createDOMPurify();
575
+ function createInitialProgress() {
576
+ return {
577
+ id: "root",
578
+ step: "root",
579
+ status: "pending",
580
+ children: [{
581
+ id: "client-init",
582
+ step: "iqInit",
583
+ status: "inProgress",
584
+ description: "Thinking"
585
+ }]
586
+ };
587
+ }
588
+ function hasProgressChunk(e) {
589
+ let t = e.progress;
590
+ return typeof t != "object" || !t ? !1 : "id" in t && "step" in t && "status" in t;
591
+ }
592
+ async function fetchStreamingResponse(e) {
593
+ let t = await fetch(e.url, {
594
+ method: "POST",
595
+ headers: { "Content-Type": "application/json" },
596
+ mode: "cors",
597
+ body: JSON.stringify(e.body),
598
+ signal: e.signal
599
+ });
600
+ if (!t.ok) {
601
+ let e = await t.json().catch(() => null);
602
+ throw Error(e?.message || `API request failed with status ${t.status}`);
603
+ }
604
+ if (!t.body) throw Error("Response body is not readable");
605
+ return {
606
+ body: t.body,
607
+ conversationId: t.headers.get("x-conversation-id")
608
+ };
609
+ }
610
+ async function readNdjsonStream(e, t) {
611
+ let n = e.getReader(), r = new TextDecoder(), i = "";
612
+ try {
613
+ for (;;) {
614
+ let { done: e, value: a } = await n.read();
615
+ if (e) break;
616
+ i += r.decode(a, { stream: !0 });
617
+ let o = i.split("\n");
618
+ i = o.pop() ?? "";
619
+ for (let e of o) if (e.trim()) try {
620
+ t(JSON.parse(e));
621
+ } catch {
622
+ console.error("Failed to parse NDJSON line:", e);
623
+ }
624
+ }
625
+ if (i += r.decode(), i.trim()) try {
626
+ t(JSON.parse(i));
627
+ } catch {
628
+ console.error("Failed to parse final NDJSON buffer:", i);
629
+ }
630
+ } finally {
631
+ n.releaseLock();
632
+ }
633
+ }
634
+ var ai_chat_module_default = ":host{box-sizing:border-box;flex-direction:column;width:100%;height:100%;display:flex}:host .chat-container{background:var(--luzmo-ai-chat-background,var(--ai-chat-background));border-radius:var(--luzmo-ai-chat-border-radius,var(--ai-chat-border-radius));width:100%;height:100%;min-height:0;padding:var(--luzmo-ai-chat-padding,var(--ai-chat-padding));gap:var(--luzmo-ai-chat-gap,var(--ai-chat-gap));border:var(--luzmo-ai-chat-border,var(--ai-chat-border));box-shadow:var(--luzmo-ai-chat-box-shadow,var(--ai-chat-box-shadow));box-sizing:border-box;flex-direction:column;flex:1;display:flex;overflow:hidden}:host .chat-messages-container{gap:var(--luzmo-ai-chat-gap,var(--ai-chat-gap));flex-direction:column;flex:1;min-height:0;display:flex;overflow:auto}:host luzmo-chat-message{--luzmo-primary:rgba(var(--luzmo-primary-rgb),.08);--chat-message-primary-text-color:var(--luzmo-font-color);--chat-message-primary-border-color:transparent}:host luzmo-chat-message.error{color:var(--luzmo-ai-chat-error-message-color,var(--ai-chat-error-message-color))}:host luzmo-ai-interaction-textarea{flex-grow:0;flex-shrink:0}:host luzmo-progress-steps{padding:0 .25rem}:host .loading-message{color:var(--luzmo-font-color);align-items:center;gap:.5rem;display:flex}:host .loading-message svg{color:var(--luzmo-ai-chat-loading-message-color,var(--ai-chat-loading-message-color));font-size:var(--luzmo-ai-chat-loading-message-icon-font-size,var(--ai-chat-loading-message-icon-font-size,1rem));justify-content:center;align-items:center;display:flex}:host .loading-message svg.spin{animation:1s linear infinite spin}@keyframes spin{to{transform:rotate(360deg)}}:host{--ai-chat-background:var(--luzmo-background-color);--ai-chat-border-radius:0;--ai-chat-padding:0;--ai-chat-gap:1rem;--ai-chat-max-height:none;--ai-chat-messages-flex:1;--ai-chat-border:none;--ai-chat-box-shadow:none;--ai-chat-loading-message-color:var(--luzmo-primary);--ai-chat-error-message-color:var(--luzmo-danger,#dc3545)}";
574
635
  function buildAiMessageRequest(e) {
575
- let { prompt: t, datasetIds: n, authKey: r, authToken: i, conversationId: a, chart: o, modelPreference: s, apiVersion: c = "0.1.0" } = e;
636
+ let { prompt: t, datasetIds: n, authKey: r, authToken: i, conversationId: a, chart: o, modelPreference: s, apiVersion: c = "0.1.0", stream: l = !0 } = e;
576
637
  return {
577
638
  key: r,
578
639
  token: i,
@@ -587,9 +648,11 @@ function buildAiMessageRequest(e) {
587
648
  },
588
649
  options: {
589
650
  available_datasets: n,
651
+ stream: l,
590
652
  ...n.length > 0 ? { dataset_id: n[0] } : {},
591
- ...o ? { chart: {
653
+ ...o && o.type !== "placeholder" ? { chart: {
592
654
  ...o,
655
+ version: o.version || "",
593
656
  title: o.title || o.options.title,
594
657
  filters: o.filterGroups || [],
595
658
  aichartId: o.aichartId || ""
@@ -600,7 +663,7 @@ function buildAiMessageRequest(e) {
600
663
  }
601
664
  var LuzmoAiChat = class extends LuzmoElement {
602
665
  constructor(...e) {
603
- super(...e), this.messages = [], this.selectedDatasets = [], this.placeholder = "Describe your change", this.disabled = !1, this.showAssistantContextMenu = !1, this.authKey = "", this.authToken = "", this.apiUrl = "https://api.luzmo.com", this.appServer = "https://app.luzmo.com", this.flagOpendata = !1, this.hideDatasetButton = !1, this.modelPreference = "performance", this.requestMode = "internal", this.isGenerating = !1, this.conversationId = null, this.chart = null, this.apiVersion = "0.1.0", this.loadingMessage = null, this._isGeneratingInternal = !1, this._textareaValue = "";
666
+ super(...e), this.messages = [], this.selectedDatasets = [], this.placeholder = "Describe your change", this.disabled = !1, this.showAssistantContextMenu = !1, this.authKey = "", this.authToken = "", this.apiUrl = "https://api.luzmo.com", this.appServer = "https://app.luzmo.com", this.flagOpendata = !1, this.hideDatasetButton = !1, this.modelPreference = "performance", this.requestMode = "internal", this.isGenerating = !1, this.conversationId = null, this.chart = null, this.apiVersion = "0.1.0", this.stream = !0, this.loadingMessage = null, this.initialPrompt = null, this.progress = null, this.progressCollapsed = !1, this._progress = null, this._progressCollapsed = !1, this._isGeneratingInternal = !1, this._textareaValue = "", this._abortController = null, this._inflightAiMessage = null, this._lastProcessedInitialPrompt = null, this._receivedProgress = !1;
604
667
  }
605
668
  static {
606
669
  this.styles = unsafeCSS(ai_chat_module_default);
@@ -620,21 +683,75 @@ var LuzmoAiChat = class extends LuzmoElement {
620
683
  conversationId: this.conversationId,
621
684
  chart: this.chart,
622
685
  modelPreference: this.modelPreference,
623
- apiVersion: this.apiVersion
686
+ apiVersion: this.apiVersion,
687
+ stream: this.stream
624
688
  });
625
689
  }
626
- async _sendMessage(e) {
627
- let t = `${this.apiUrl}/${this.apiVersion}/aimessage`, n = await fetch(t, {
628
- method: "POST",
629
- headers: { "Content-Type": "application/json" },
630
- mode: "cors",
631
- body: JSON.stringify(e)
632
- });
633
- if (!n.ok) {
634
- let e = await n.json().catch(() => null);
635
- throw Error(e?.message || `API request failed with status ${n.status}`);
690
+ _finalizeInflightMessage() {
691
+ this._inflightAiMessage &&= (this._progress && this._receivedProgress && (this._inflightAiMessage.progress = structuredClone(this._progress), this._updateMessage(this._inflightAiMessage)), this._progress = null, this._progressCollapsed = !1, this._receivedProgress = !1, null);
692
+ }
693
+ async _sendStreamingMessage(e, t) {
694
+ this._abortController && (this._abortController.abort(), this._inflightAiMessage && !this._inflightAiMessage.message && (this.messages = this.messages.filter((e) => e.id !== this._inflightAiMessage.id))), this._finalizeInflightMessage(), this._inflightAiMessage = t;
695
+ let n = new AbortController();
696
+ this._abortController = n, this._progress = createInitialProgress(), this._progressCollapsed = !1, this._receivedProgress = !1;
697
+ let r = !1;
698
+ try {
699
+ let { body: i, conversationId: a } = await fetchStreamingResponse({
700
+ url: `${this.apiUrl}/${this.apiVersion}/aimessage`,
701
+ body: e,
702
+ signal: n.signal
703
+ });
704
+ a && (this.conversationId = a), await readNdjsonStream(i, (e) => this._processStreamChunk(e, t)), r = !0;
705
+ } finally {
706
+ this._abortController === n && (r ? this._finalizeInflightMessage() : this._inflightAiMessage = null, this._isGeneratingInternal = !1, this._abortController = null);
636
707
  }
637
- return await n.json();
708
+ }
709
+ _processStreamChunk(e, t) {
710
+ if (hasProgressChunk(e) && (this._receivedProgress = !0, this._progress = e.progress), e.error) {
711
+ t.message = e.error, t.isError = !0, this._updateMessage(t), this._progress = null, this._progressCollapsed = !1, this.dispatchEvent(new CustomEvent("luzmo-response-received", {
712
+ detail: {
713
+ message: t,
714
+ done: !0
715
+ },
716
+ bubbles: !0,
717
+ composed: !0
718
+ }));
719
+ return;
720
+ }
721
+ let n = e.chart ?? e.generatedChart;
722
+ if (n) {
723
+ let r = {
724
+ ...e,
725
+ generatedChart: n,
726
+ conversationId: this.conversationId
727
+ };
728
+ this.dispatchEvent(new CustomEvent("luzmo-chart-generated", {
729
+ detail: { aiSampleChart: r },
730
+ bubbles: !0,
731
+ composed: !0
732
+ }));
733
+ let i = typeof e.chunk == "string" && e.chunk || typeof e.message == "string" && e.message;
734
+ i && (t.message = (t.message || "") + i), this._updateMessage(t), (e.done || "question" in e) && (this._progressCollapsed = !0, t.message && this.dispatchEvent(new CustomEvent("luzmo-response-received", {
735
+ detail: {
736
+ message: t,
737
+ done: !0
738
+ },
739
+ bubbles: !0,
740
+ composed: !0
741
+ })));
742
+ return;
743
+ }
744
+ let r = typeof e.chunk == "string" && e.chunk || typeof e.message == "string" && e.message || "";
745
+ r && (this._progressCollapsed ||= !0, t.message = (t.message || "") + r, this._updateMessage(t));
746
+ let i = e.done || "question" in e;
747
+ i && (this._progressCollapsed = !0), (r || i && t.message) && this.dispatchEvent(new CustomEvent("luzmo-response-received", {
748
+ detail: {
749
+ message: t,
750
+ done: !!i
751
+ },
752
+ bubbles: !0,
753
+ composed: !0
754
+ }));
638
755
  }
639
756
  _addUserMessage(e, t) {
640
757
  let n = {
@@ -651,6 +768,9 @@ var LuzmoAiChat = class extends LuzmoElement {
651
768
  composed: !0
652
769
  }));
653
770
  }
771
+ _updateMessage(e) {
772
+ this.messages = this.messages.map((t) => t.id === e.id ? { ...e } : t);
773
+ }
654
774
  _prepareForAIResponse() {
655
775
  this._isGeneratingInternal = !0;
656
776
  let e = {
@@ -660,42 +780,20 @@ var LuzmoAiChat = class extends LuzmoElement {
660
780
  };
661
781
  return this.messages = [...this.messages, e], e;
662
782
  }
663
- _handleChartResponse(e, t) {
664
- this.dispatchEvent(new CustomEvent("luzmo-chart-generated", {
665
- detail: { aiSampleChart: e },
666
- bubbles: !0,
667
- composed: !0
668
- }));
669
- let n = e.message || e.error || e.clarificationQuestion;
670
- n && (t.message = n, this.messages = [...this.messages.slice(0, -1), { ...t }], this.dispatchEvent(new CustomEvent("luzmo-response-received", {
671
- detail: {
672
- message: t,
673
- done: !0
674
- },
675
- bubbles: !0,
676
- composed: !0
677
- })));
678
- }
679
- _handleErrorResponse(e, t) {
680
- let n = null;
681
- if (e.functionResponse?.error) {
682
- let t = e.functionResponse.explanation;
683
- t && typeof t == "string" && (n = e.functionResponse.explanation);
684
- } else n = e.functionResponse;
685
- n ||= e.message || e.error || e.clarificationQuestion || null, n && (t.message = n, this.messages = [...this.messages.slice(0, -1), { ...t }]), this.dispatchEvent(new CustomEvent("luzmo-response-received", {
686
- detail: {
687
- message: t,
688
- done: !0
689
- },
690
- bubbles: !0,
691
- composed: !0
692
- }));
693
- }
694
- _processAIResponse(e, t) {
695
- e.generatedChart === void 0 ? (e.functionResponse?.error !== void 0 || typeof e.functionResponse == "string" || e.clarificationQuestion === "string") && this._handleErrorResponse(e, t) : this._handleChartResponse(e, t);
696
- }
697
783
  _handleAPIError(e, t) {
698
- t.message = msg("Something went wrong. Please try again.", { desc: "Generic error message shown in ai chat when the API request fails" }), t.isError = !0, this.messages = [...this.messages.slice(0, -1), { ...t }], this.dispatchEvent(new CustomEvent("luzmo-response-received", {
784
+ console.error("AI Chart Generation Error:", e), this._progress = null, this._progressCollapsed = !1;
785
+ let r = msg("Something went wrong. Please try again.", { desc: "Generic error message shown in ai chat when the API request fails" });
786
+ if (t) t.message = r, t.isError = !0, delete t.progress, this._updateMessage(t);
787
+ else {
788
+ let e = {
789
+ id: this._generateMessageId(),
790
+ type: "ai",
791
+ message: r,
792
+ isError: !0
793
+ };
794
+ this.messages = [...this.messages, e], t = e;
795
+ }
796
+ this.dispatchEvent(new CustomEvent("luzmo-response-received", {
699
797
  detail: {
700
798
  message: t,
701
799
  error: e
@@ -736,16 +834,42 @@ var LuzmoAiChat = class extends LuzmoElement {
736
834
  }));
737
835
  return;
738
836
  }
739
- let a = await this._prepareForAIResponse();
837
+ let a = this._prepareForAIResponse();
740
838
  try {
741
- let e = await this._sendMessage(i);
742
- this._processAIResponse(e, a);
839
+ await this._sendStreamingMessage(i, a);
743
840
  } catch (e) {
744
- this._handleAPIError(e, a);
745
- } finally {
746
- this._isGeneratingInternal = !1;
841
+ e.name !== "AbortError" && this._handleAPIError(e, a);
747
842
  }
748
843
  }
844
+ async _processInitialPrompt() {
845
+ if (!this.initialPrompt || this.initialPrompt === this._lastProcessedInitialPrompt) return;
846
+ this._lastProcessedInitialPrompt = this.initialPrompt;
847
+ let e = this.selectedDatasets.map((e) => e.id), t = this._buildRequestBody(this.initialPrompt, e), n = `${this.apiUrl}/${this.apiVersion}/aimessage`;
848
+ if (this.requestMode === "external") {
849
+ let r = {
850
+ prompt: this.initialPrompt,
851
+ selectedDatasets: this.selectedDatasets,
852
+ datasetIds: e,
853
+ request: t,
854
+ url: n
855
+ };
856
+ this.dispatchEvent(new CustomEvent("luzmo-prompt-submitted", {
857
+ detail: r,
858
+ bubbles: !0,
859
+ composed: !0
860
+ }));
861
+ return;
862
+ }
863
+ let r = this._prepareForAIResponse();
864
+ try {
865
+ await this._sendStreamingMessage(t, r);
866
+ } catch (e) {
867
+ e.name !== "AbortError" && this._handleAPIError(e, r);
868
+ }
869
+ }
870
+ disconnectedCallback() {
871
+ super.disconnectedCallback(), this._abortController?.abort(), this._abortController = null, this._finalizeInflightMessage(), this._isGeneratingInternal = !1;
872
+ }
749
873
  _scrollToBottom() {
750
874
  let e = this.shadowRoot?.querySelector(".chat-messages-container");
751
875
  e && requestAnimationFrame(() => {
@@ -755,7 +879,7 @@ var LuzmoAiChat = class extends LuzmoElement {
755
879
  });
756
880
  }
757
881
  updated(e) {
758
- super.updated?.(e), e.has("messages") && this.updateComplete.then(() => this._scrollToBottom());
882
+ super.updated?.(e), (e.has("messages") || e.has("_progress") || e.has("progress")) && this.updateComplete.then(() => this._scrollToBottom()), this.initialPrompt && this.initialPrompt !== this._lastProcessedInitialPrompt ? this._processInitialPrompt() : this.initialPrompt || (this._lastProcessedInitialPrompt = null);
759
883
  }
760
884
  _sanitizeMessage(e) {
761
885
  return purify.sanitize(e, {
@@ -802,8 +926,26 @@ var LuzmoAiChat = class extends LuzmoElement {
802
926
  ]
803
927
  });
804
928
  }
929
+ _renderProgress() {
930
+ let e = this.requestMode === "external" ? this.progress : this._progress, t = this.requestMode === "external" ? this.progressCollapsed : this._progressCollapsed;
931
+ return e?.children?.length ? html`
932
+ <luzmo-progress-steps
933
+ .progress=${e}
934
+ ?collapsed=${t}
935
+ size="s"
936
+ ></luzmo-progress-steps>
937
+ ` : nothing;
938
+ }
805
939
  _renderMessages() {
806
- return this.messages.map((e) => e.type === "user" ? html`
940
+ return this.messages.filter((e) => !this._inflightAiMessage || e.id !== this._inflightAiMessage.id).map((e) => {
941
+ let t = e.progress?.children?.length ? html`
942
+ <luzmo-progress-steps
943
+ .progress=${e.progress}
944
+ collapsed
945
+ size="s"
946
+ ></luzmo-progress-steps>
947
+ ` : nothing;
948
+ return e.type === "user" ? html`
807
949
  <luzmo-chat-message
808
950
  avatar-placement="bottom"
809
951
  position="right"
@@ -812,33 +954,46 @@ var LuzmoAiChat = class extends LuzmoElement {
812
954
  >
813
955
  ${e.message}
814
956
  </luzmo-chat-message>
815
- ` : html`
816
- <luzmo-chat-message
817
- class=${e.isError ? "error" : ""}
818
- avatar-placement="bottom"
819
- position="left"
820
- quiet
821
- size="s"
822
- >
823
- ${unsafeHTML(this._sanitizeMessage(e.message))}
824
- </luzmo-chat-message>
825
- `);
957
+ ` : html`
958
+ ${t}
959
+ <luzmo-chat-message
960
+ class=${e.isError ? "error" : ""}
961
+ avatar-placement="bottom"
962
+ position="left"
963
+ quiet
964
+ size="s"
965
+ >
966
+ ${unsafeHTML(this._sanitizeMessage(e.message))}
967
+ </luzmo-chat-message>
968
+ `;
969
+ });
970
+ }
971
+ _renderStreamingResponse() {
972
+ return this._inflightAiMessage?.message ? html`
973
+ <luzmo-chat-message
974
+ avatar-placement="bottom"
975
+ position="left"
976
+ quiet
977
+ size="s"
978
+ >
979
+ ${unsafeHTML(this._sanitizeMessage(this._inflightAiMessage.message))}
980
+ </luzmo-chat-message>
981
+ ` : nothing;
826
982
  }
827
983
  _renderLoadingMessage() {
828
- return this.isGenerating || this._isGeneratingInternal ? html`
829
- <luzmo-chat-message
830
- avatar-placement="bottom"
831
- position="left"
832
- quiet
833
- size="s"
834
- >
835
- <div class="loading-message">
836
- <span class="icon-lg">${luzmoIcon(luzmoSpin, { className: "spin" })}</span>
837
- <span class="loading-message-text">${this.loadingMessage || (this.chart?.type === "placeholder" ? msg("Creating item...", { desc: "Label for ai chat creating item message" }) : msg("Updating item...", { desc: "Label for ai chat updating item message" }))}</span>
838
- </div>
839
- </luzmo-chat-message>
840
- ` : html`
841
-
984
+ let e = this.requestMode === "external" ? this.isGenerating : this._isGeneratingInternal, t = this.requestMode === "external" ? this.progress : this._progress;
985
+ return !e || t?.children?.length ? nothing : html`
986
+ <luzmo-chat-message
987
+ avatar-placement="bottom"
988
+ position="left"
989
+ quiet
990
+ size="s"
991
+ >
992
+ <div class="loading-message">
993
+ <span class="icon-lg">${luzmoIcon(luzmoSpin, { className: "spin" })}</span>
994
+ <span class="loading-message-text">${this.loadingMessage || (this.chart?.type === "placeholder" ? msg("Creating item...", { desc: "Label for ai chat creating item message" }) : msg("Updating item...", { desc: "Label for ai chat updating item message" }))}</span>
995
+ </div>
996
+ </luzmo-chat-message>
842
997
  `;
843
998
  }
844
999
  _renderPlaceholderMessage() {
@@ -862,6 +1017,8 @@ var LuzmoAiChat = class extends LuzmoElement {
862
1017
  <div class="chat-messages-container">
863
1018
  ${this._renderPlaceholderMessage()}
864
1019
  ${this._renderMessages()}
1020
+ ${this._renderProgress()}
1021
+ ${this._renderStreamingResponse()}
865
1022
  ${this._renderLoadingMessage()}
866
1023
  </div>
867
1024
 
@@ -930,8 +1087,14 @@ __decorate([property({ type: Array })], LuzmoAiChat.prototype, "messages", void
930
1087
  })], LuzmoAiChat.prototype, "chart", void 0), __decorate([property({
931
1088
  type: String,
932
1089
  attribute: "api-version"
933
- })], LuzmoAiChat.prototype, "apiVersion", void 0), __decorate([property({
1090
+ })], LuzmoAiChat.prototype, "apiVersion", void 0), __decorate([property({ converter: { fromAttribute: (e) => e !== "false" && e !== null } })], LuzmoAiChat.prototype, "stream", void 0), __decorate([property({
934
1091
  type: String,
935
1092
  attribute: "loading-message"
936
- })], LuzmoAiChat.prototype, "loadingMessage", void 0), __decorate([state()], LuzmoAiChat.prototype, "_isGeneratingInternal", void 0), __decorate([state()], LuzmoAiChat.prototype, "_textareaValue", void 0), customElements.get("luzmo-ai-chat") || customElements.define("luzmo-ai-chat", LuzmoAiChat);
937
- export { buildAiMessageRequest as n, LuzmoAiChat as t };
1093
+ })], LuzmoAiChat.prototype, "loadingMessage", void 0), __decorate([property({
1094
+ type: String,
1095
+ attribute: "initial-prompt"
1096
+ })], LuzmoAiChat.prototype, "initialPrompt", void 0), __decorate([property({ type: Object })], LuzmoAiChat.prototype, "progress", void 0), __decorate([property({
1097
+ type: Boolean,
1098
+ attribute: "progress-collapsed"
1099
+ })], LuzmoAiChat.prototype, "progressCollapsed", void 0), __decorate([state()], LuzmoAiChat.prototype, "_progress", void 0), __decorate([state()], LuzmoAiChat.prototype, "_progressCollapsed", void 0), __decorate([state()], LuzmoAiChat.prototype, "_isGeneratingInternal", void 0), __decorate([state()], LuzmoAiChat.prototype, "_textareaValue", void 0), customElements.get("luzmo-ai-chat") || customElements.define("luzmo-ai-chat", LuzmoAiChat);
1100
+ export { hasProgressChunk as a, fetchStreamingResponse as i, buildAiMessageRequest as n, readNdjsonStream as o, createInitialProgress as r, LuzmoAiChat as t };