@luzmo/analytics-components-kit 1.0.1-alpha.140 → 1.0.1-alpha.142

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 (52) hide show
  1. package/README.md +17 -5
  2. package/angular/components/ai-interaction-textarea.component.ts +2 -0
  3. package/angular/components/grid.component.ts +2 -2
  4. package/angular/esm/components/ai-interaction-textarea.component.d.ts +2 -1
  5. package/angular/esm/components/ai-interaction-textarea.component.js +7 -2
  6. package/angular/esm/components/grid.component.d.ts +2 -2
  7. package/angular/esm/types/ai-chat.types.d.ts +1 -0
  8. package/angular/types/ai-chat.types.ts +1 -0
  9. package/components/ai-chat/ai-chat.d.ts +21 -1
  10. package/components/ai-chat/index.cjs +1 -1
  11. package/components/ai-chat/index.d.ts +1 -0
  12. package/components/ai-chat/index.js +3 -3
  13. package/components/ai-chat/request-contract.d.ts +38 -0
  14. package/components/{ai-chat-Dg2dvhDq.js → ai-chat-DlUYd_Cf.js} +211 -151
  15. package/components/ai-chat-rok8ar11.cjs +62 -0
  16. package/components/ai-interaction-textarea/ai-interaction-textarea.d.ts +6 -0
  17. package/components/ai-interaction-textarea/index.cjs +1 -1
  18. package/components/ai-interaction-textarea/index.js +1 -1
  19. package/components/{ai-interaction-textarea-DDVKMfTQ.cjs → ai-interaction-textarea-BGnQbDpJ.cjs} +2 -2
  20. package/components/{ai-interaction-textarea-ZDQPVgXC.js → ai-interaction-textarea-EdWcPK0w.js} +6 -3
  21. package/components/grid/grid.d.ts +4 -9
  22. package/components/grid/helpers/grid-effects.d.ts +1 -0
  23. package/components/grid/helpers/grid-events.d.ts +50 -0
  24. package/components/grid/helpers/grid-interactions.d.ts +91 -0
  25. package/components/grid/helpers/grid-item-management.d.ts +45 -0
  26. package/components/grid/helpers/grid-item-popover.d.ts +15 -0
  27. package/components/grid/helpers/grid-items.d.ts +9 -0
  28. package/components/grid/helpers/grid-keyboard-updates.d.ts +18 -0
  29. package/components/grid/helpers/grid-keydown-event.d.ts +18 -0
  30. package/components/grid/helpers/grid-popover-cleanup.d.ts +4 -0
  31. package/components/grid/helpers/grid-rendering.d.ts +63 -0
  32. package/components/grid/helpers/grid-stack-lifecycle.d.ts +26 -0
  33. package/components/grid/helpers/grid-theme.d.ts +16 -0
  34. package/components/grid/helpers/grid-update-cycle.d.ts +24 -0
  35. package/components/grid/index.cjs +1 -1
  36. package/components/grid/index.js +1 -1
  37. package/components/grid-BNbbl-9p.cjs +316 -0
  38. package/components/{grid-BW6LPvCu.js → grid-Ca-fxUK1.js} +2341 -1965
  39. package/components/index.cjs +1 -1
  40. package/components/index.js +5 -5
  41. package/components/item-data-picker-panel/index.cjs +1 -1
  42. package/components/item-data-picker-panel/index.js +1 -1
  43. package/components/slot-contents-picker/index.cjs +1 -1
  44. package/components/slot-contents-picker/index.js +1 -1
  45. package/components/slot-contents-picker/slot-contents-picker.d.ts +4 -2
  46. package/components/{slot-contents-picker-HRJuZQq5.cjs → slot-contents-picker-BO5lSTDz.cjs} +4 -4
  47. package/components/{slot-contents-picker-CgACNIVS.js → slot-contents-picker-Bw_G1BwZ.js} +112 -92
  48. package/custom-elements.json +1558 -17
  49. package/package.json +2 -2
  50. package/types/ai-chat.types.d.ts +1 -0
  51. package/components/ai-chat-CbqvVZDp.cjs +0 -60
  52. package/components/grid-xtLaTdhb.cjs +0 -316
@@ -220,20 +220,20 @@ function createDOMPurify() {
220
220
  let e = n.createElement("template");
221
221
  e.content && e.content.ownerDocument && (n = e.content.ownerDocument);
222
222
  }
223
- let h, g = "", { implementation: We, createNodeIterator: Ge, createDocumentFragment: Ke, getElementsByTagName: qe } = n, { importNode: Je } = r, _ = _createHooksMap();
224
- t.isSupported = typeof entries == "function" && typeof m == "function" && We && We.createHTMLDocument !== void 0;
225
- let { MUSTACHE_EXPR: v, ERB_EXPR: y, TMPLIT_EXPR: b, DATA_ATTR: Ye, ARIA_ATTR: Xe, IS_SCRIPT_OR_DATA: Ze, ATTR_WHITESPACE: Qe, CUSTOM_ELEMENT: $e } = EXPRESSIONS, { IS_ALLOWED_URI: et } = EXPRESSIONS, x = null, tt = addToSet({}, [
223
+ let h, g = "", { implementation: _, createNodeIterator: We, createDocumentFragment: Ge, getElementsByTagName: Ke } = n, { importNode: qe } = r, v = _createHooksMap();
224
+ t.isSupported = typeof entries == "function" && typeof m == "function" && _ && _.createHTMLDocument !== void 0;
225
+ let { MUSTACHE_EXPR: y, ERB_EXPR: b, TMPLIT_EXPR: x, DATA_ATTR: Je, ARIA_ATTR: Ye, IS_SCRIPT_OR_DATA: Xe, ATTR_WHITESPACE: Ze, CUSTOM_ELEMENT: Qe } = EXPRESSIONS, { IS_ALLOWED_URI: $e } = EXPRESSIONS, S = null, et = addToSet({}, [
226
226
  ...html$1,
227
227
  ...svg$1,
228
228
  ...svgFilters,
229
229
  ...mathMl$1,
230
230
  ...text
231
- ]), S = null, nt = addToSet({}, [
231
+ ]), C = null, tt = addToSet({}, [
232
232
  ...html$2,
233
233
  ...svg,
234
234
  ...mathMl,
235
235
  ...xml
236
- ]), C = Object.seal(create(null, {
236
+ ]), w = Object.seal(create(null, {
237
237
  tagNameCheck: {
238
238
  writable: !0,
239
239
  configurable: !1,
@@ -252,7 +252,7 @@ function createDOMPurify() {
252
252
  enumerable: !0,
253
253
  value: !1
254
254
  }
255
- })), w = null, rt = null, T = Object.seal(create(null, {
255
+ })), T = null, E = null, D = Object.seal(create(null, {
256
256
  tagCheck: {
257
257
  writable: !0,
258
258
  configurable: !1,
@@ -265,7 +265,7 @@ function createDOMPurify() {
265
265
  enumerable: !0,
266
266
  value: null
267
267
  }
268
- })), it = !0, at = !0, ot = !1, st = !0, E = !1, D = !0, O = !1, k = !1, A = !1, j = !1, M = !1, N = !1, ct = !0, lt = !1, P = !0, F = !1, I = {}, L = null, R = addToSet({}, [
268
+ })), 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, st = addToSet({}, [
269
269
  "annotation-xml",
270
270
  "audio",
271
271
  "colgroup",
@@ -291,14 +291,14 @@ function createDOMPurify() {
291
291
  "title",
292
292
  "video",
293
293
  "xmp"
294
- ]), ut = null, dt = addToSet({}, [
294
+ ]), ct = null, lt = addToSet({}, [
295
295
  "audio",
296
296
  "video",
297
297
  "img",
298
298
  "source",
299
299
  "image",
300
300
  "track"
301
- ]), z = null, ft = addToSet({}, [
301
+ ]), ut = null, dt = addToSet({}, [
302
302
  "alt",
303
303
  "class",
304
304
  "for",
@@ -313,58 +313,58 @@ function createDOMPurify() {
313
313
  "value",
314
314
  "style",
315
315
  "xmlns"
316
- ]), B = "http://www.w3.org/1998/Math/MathML", V = "http://www.w3.org/2000/svg", H = "http://www.w3.org/1999/xhtml", U = H, W = !1, G = null, pt = addToSet({}, [
317
- B,
316
+ ]), V = "http://www.w3.org/1998/Math/MathML", H = "http://www.w3.org/2000/svg", U = "http://www.w3.org/1999/xhtml", W = U, ft = !1, pt = null, mt = addToSet({}, [
318
317
  V,
319
- H
320
- ], stringToString), K = addToSet({}, [
318
+ H,
319
+ U
320
+ ], stringToString), G = addToSet({}, [
321
321
  "mi",
322
322
  "mo",
323
323
  "mn",
324
324
  "ms",
325
325
  "mtext"
326
- ]), q = addToSet({}, ["annotation-xml"]), mt = addToSet({}, [
326
+ ]), K = addToSet({}, ["annotation-xml"]), ht = addToSet({}, [
327
327
  "title",
328
328
  "style",
329
329
  "font",
330
330
  "a",
331
331
  "script"
332
- ]), J = null, ht = ["application/xhtml+xml", "text/html"], Y = null, X = null, gt = n.createElement("form"), _t = function(e) {
332
+ ]), q = null, gt = ["application/xhtml+xml", "text/html"], J = null, Y = null, _t = n.createElement("form"), vt = function(e) {
333
333
  return e instanceof RegExp || e instanceof Function;
334
- }, vt = function() {
334
+ }, yt = function() {
335
335
  let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
336
- if (!(X && X === e)) {
337
- 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, x = objectHasOwnProperty(e, "ALLOWED_TAGS") ? addToSet({}, e.ALLOWED_TAGS, Y) : tt, S = objectHasOwnProperty(e, "ALLOWED_ATTR") ? addToSet({}, e.ALLOWED_ATTR, Y) : nt, G = objectHasOwnProperty(e, "ALLOWED_NAMESPACES") ? addToSet({}, e.ALLOWED_NAMESPACES, stringToString) : pt, z = objectHasOwnProperty(e, "ADD_URI_SAFE_ATTR") ? addToSet(clone(ft), e.ADD_URI_SAFE_ATTR, Y) : ft, ut = objectHasOwnProperty(e, "ADD_DATA_URI_TAGS") ? addToSet(clone(dt), e.ADD_DATA_URI_TAGS, Y) : dt, L = objectHasOwnProperty(e, "FORBID_CONTENTS") ? addToSet({}, e.FORBID_CONTENTS, Y) : R, w = objectHasOwnProperty(e, "FORBID_TAGS") ? addToSet({}, e.FORBID_TAGS, Y) : clone({}), rt = objectHasOwnProperty(e, "FORBID_ATTR") ? addToSet({}, e.FORBID_ATTR, Y) : clone({}), I = objectHasOwnProperty(e, "USE_PROFILES") ? e.USE_PROFILES : !1, it = e.ALLOW_ARIA_ATTR !== !1, at = e.ALLOW_DATA_ATTR !== !1, ot = e.ALLOW_UNKNOWN_PROTOCOLS || !1, st = e.ALLOW_SELF_CLOSE_IN_ATTR !== !1, E = e.SAFE_FOR_TEMPLATES || !1, D = e.SAFE_FOR_XML !== !1, O = e.WHOLE_DOCUMENT || !1, j = e.RETURN_DOM || !1, M = e.RETURN_DOM_FRAGMENT || !1, N = e.RETURN_TRUSTED_TYPE || !1, A = e.FORCE_BODY || !1, ct = e.SANITIZE_DOM !== !1, lt = e.SANITIZE_NAMED_PROPS || !1, P = e.KEEP_CONTENT !== !1, F = e.IN_PLACE || !1, et = e.ALLOWED_URI_REGEXP || IS_ALLOWED_URI, U = e.NAMESPACE || H, K = e.MATHML_TEXT_INTEGRATION_POINTS || K, q = e.HTML_INTEGRATION_POINTS || q, C = e.CUSTOM_ELEMENT_HANDLING || {}, e.CUSTOM_ELEMENT_HANDLING && _t(e.CUSTOM_ELEMENT_HANDLING.tagNameCheck) && (C.tagNameCheck = e.CUSTOM_ELEMENT_HANDLING.tagNameCheck), e.CUSTOM_ELEMENT_HANDLING && _t(e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck) && (C.attributeNameCheck = e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck), e.CUSTOM_ELEMENT_HANDLING && typeof e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements == "boolean" && (C.allowCustomizedBuiltInElements = e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements), E && (at = !1), M && (j = !0), I && (x = addToSet({}, text), S = [], I.html === !0 && (addToSet(x, html$1), addToSet(S, html$2)), I.svg === !0 && (addToSet(x, svg$1), addToSet(S, svg), addToSet(S, xml)), I.svgFilters === !0 && (addToSet(x, svgFilters), addToSet(S, svg), addToSet(S, xml)), I.mathMl === !0 && (addToSet(x, mathMl$1), addToSet(S, mathMl), addToSet(S, xml))), e.ADD_TAGS && (typeof e.ADD_TAGS == "function" ? T.tagCheck = e.ADD_TAGS : (x === tt && (x = clone(x)), addToSet(x, e.ADD_TAGS, Y))), e.ADD_ATTR && (typeof e.ADD_ATTR == "function" ? T.attributeCheck = e.ADD_ATTR : (S === nt && (S = clone(S)), addToSet(S, e.ADD_ATTR, Y))), e.ADD_URI_SAFE_ATTR && addToSet(z, e.ADD_URI_SAFE_ATTR, Y), e.FORBID_CONTENTS && (L === R && (L = clone(L)), addToSet(L, e.FORBID_CONTENTS, Y)), e.ADD_FORBID_CONTENTS && (L === R && (L = clone(L)), addToSet(L, e.ADD_FORBID_CONTENTS, Y)), P && (x["#text"] = !0), O && addToSet(x, [
336
+ if (!(Y && Y === e)) {
337
+ if ((!e || typeof e != "object") && (e = {}), e = clone(e), q = gt.indexOf(e.PARSER_MEDIA_TYPE) === -1 ? "text/html" : e.PARSER_MEDIA_TYPE, J = q === "application/xhtml+xml" ? stringToString : stringToLowerCase, S = objectHasOwnProperty(e, "ALLOWED_TAGS") ? addToSet({}, e.ALLOWED_TAGS, J) : et, C = objectHasOwnProperty(e, "ALLOWED_ATTR") ? addToSet({}, e.ALLOWED_ATTR, J) : tt, pt = objectHasOwnProperty(e, "ALLOWED_NAMESPACES") ? addToSet({}, e.ALLOWED_NAMESPACES, stringToString) : mt, ut = objectHasOwnProperty(e, "ADD_URI_SAFE_ATTR") ? addToSet(clone(dt), e.ADD_URI_SAFE_ATTR, J) : dt, ct = objectHasOwnProperty(e, "ADD_DATA_URI_TAGS") ? addToSet(clone(lt), e.ADD_DATA_URI_TAGS, J) : lt, B = objectHasOwnProperty(e, "FORBID_CONTENTS") ? addToSet({}, e.FORBID_CONTENTS, J) : st, T = objectHasOwnProperty(e, "FORBID_TAGS") ? addToSet({}, e.FORBID_TAGS, J) : clone({}), E = objectHasOwnProperty(e, "FORBID_ATTR") ? addToSet({}, e.FORBID_ATTR, J) : 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, W = e.NAMESPACE || U, G = e.MATHML_TEXT_INTEGRATION_POINTS || G, K = e.HTML_INTEGRATION_POINTS || K, w = e.CUSTOM_ELEMENT_HANDLING || {}, e.CUSTOM_ELEMENT_HANDLING && vt(e.CUSTOM_ELEMENT_HANDLING.tagNameCheck) && (w.tagNameCheck = e.CUSTOM_ELEMENT_HANDLING.tagNameCheck), e.CUSTOM_ELEMENT_HANDLING && vt(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, J))), e.ADD_ATTR && (typeof e.ADD_ATTR == "function" ? D.attributeCheck = e.ADD_ATTR : (C === tt && (C = clone(C)), addToSet(C, e.ADD_ATTR, J))), e.ADD_URI_SAFE_ATTR && addToSet(ut, e.ADD_URI_SAFE_ATTR, J), e.FORBID_CONTENTS && (B === st && (B = clone(B)), addToSet(B, e.FORBID_CONTENTS, J)), e.ADD_FORBID_CONTENTS && (B === st && (B = clone(B)), addToSet(B, e.ADD_FORBID_CONTENTS, J)), L && (S["#text"] = !0), j && addToSet(S, [
338
338
  "html",
339
339
  "head",
340
340
  "body"
341
- ]), x.table && (addToSet(x, ["tbody"]), delete w.tbody), e.TRUSTED_TYPES_POLICY) {
341
+ ]), S.table && (addToSet(S, ["tbody"]), delete T.tbody), e.TRUSTED_TYPES_POLICY) {
342
342
  if (typeof e.TRUSTED_TYPES_POLICY.createHTML != "function") throw typeErrorCreate("TRUSTED_TYPES_POLICY configuration option must provide a \"createHTML\" hook.");
343
343
  if (typeof e.TRUSTED_TYPES_POLICY.createScriptURL != "function") throw typeErrorCreate("TRUSTED_TYPES_POLICY configuration option must provide a \"createScriptURL\" hook.");
344
344
  h = e.TRUSTED_TYPES_POLICY, g = h.createHTML("");
345
345
  } else h === void 0 && (h = _createTrustedTypesPolicy(f, i)), h !== null && typeof g == "string" && (g = h.createHTML(""));
346
- freeze && freeze(e), X = e;
346
+ freeze && freeze(e), Y = e;
347
347
  }
348
- }, yt = addToSet({}, [
348
+ }, bt = addToSet({}, [
349
349
  ...svg$1,
350
350
  ...svgFilters,
351
351
  ...svgDisallowed
352
- ]), bt = addToSet({}, [...mathMl$1, ...mathMlDisallowed]), xt = function(e) {
352
+ ]), xt = addToSet({}, [...mathMl$1, ...mathMlDisallowed]), St = function(e) {
353
353
  let t = m(e);
354
354
  (!t || !t.tagName) && (t = {
355
- namespaceURI: U,
355
+ namespaceURI: W,
356
356
  tagName: "template"
357
357
  });
358
358
  let n = stringToLowerCase(e.tagName), r = stringToLowerCase(t.tagName);
359
- return G[e.namespaceURI] ? e.namespaceURI === V ? t.namespaceURI === H ? n === "svg" : t.namespaceURI === B ? n === "svg" && (r === "annotation-xml" || K[r]) : !!yt[n] : e.namespaceURI === B ? t.namespaceURI === H ? n === "math" : t.namespaceURI === V ? n === "math" && q[r] : !!bt[n] : e.namespaceURI === H ? t.namespaceURI === V && !q[r] || t.namespaceURI === B && !K[r] ? !1 : !bt[n] && (mt[n] || !yt[n]) : !!(J === "application/xhtml+xml" && G[e.namespaceURI]) : !1;
360
- }, Z = function(e) {
359
+ return pt[e.namespaceURI] ? e.namespaceURI === H ? t.namespaceURI === U ? n === "svg" : t.namespaceURI === V ? n === "svg" && (r === "annotation-xml" || G[r]) : !!bt[n] : e.namespaceURI === V ? t.namespaceURI === U ? n === "math" : t.namespaceURI === H ? n === "math" && K[r] : !!xt[n] : e.namespaceURI === U ? t.namespaceURI === H && !K[r] || t.namespaceURI === V && !G[r] ? !1 : !xt[n] && (ht[n] || !bt[n]) : !!(q === "application/xhtml+xml" && pt[e.namespaceURI]) : !1;
360
+ }, X = function(e) {
361
361
  arrayPush(t.removed, { element: e });
362
362
  try {
363
363
  m(e).removeChild(e);
364
364
  } catch {
365
365
  Ve(e);
366
366
  }
367
- }, Q = function(e, n) {
367
+ }, Z = function(e, n) {
368
368
  try {
369
369
  arrayPush(t.removed, {
370
370
  attribute: n.getAttributeNode(e),
@@ -376,55 +376,55 @@ function createDOMPurify() {
376
376
  from: n
377
377
  });
378
378
  }
379
- if (n.removeAttribute(e), e === "is") if (j || M) try {
380
- Z(n);
379
+ if (n.removeAttribute(e), e === "is") if (P || F) try {
380
+ X(n);
381
381
  } catch {}
382
382
  else try {
383
383
  n.setAttribute(e, "");
384
384
  } catch {}
385
- }, St = function(e) {
385
+ }, Ct = function(e) {
386
386
  let t = null, r = null;
387
- if (A) e = "<remove></remove>" + e;
387
+ if (N) e = "<remove></remove>" + e;
388
388
  else {
389
389
  let t = stringMatch(e, /^[\r\n\t ]+/);
390
390
  r = t && t[0];
391
391
  }
392
- J === "application/xhtml+xml" && U === H && (e = "<html xmlns=\"http://www.w3.org/1999/xhtml\"><head></head><body>" + e + "</body></html>");
392
+ q === "application/xhtml+xml" && W === U && (e = "<html xmlns=\"http://www.w3.org/1999/xhtml\"><head></head><body>" + e + "</body></html>");
393
393
  let i = h ? h.createHTML(e) : e;
394
- if (U === H) try {
395
- t = new ze().parseFromString(i, J);
394
+ if (W === U) try {
395
+ t = new ze().parseFromString(i, q);
396
396
  } catch {}
397
397
  if (!t || !t.documentElement) {
398
- t = We.createDocument(U, "template", null);
398
+ t = _.createDocument(W, "template", null);
399
399
  try {
400
- t.documentElement.innerHTML = W ? g : i;
400
+ t.documentElement.innerHTML = ft ? g : i;
401
401
  } catch {}
402
402
  }
403
403
  let a = t.body || t.documentElement;
404
- return e && r && a.insertBefore(n.createTextNode(r), a.childNodes[0] || null), U === H ? qe.call(t, O ? "html" : "body")[0] : O ? t.documentElement : a;
405
- }, Ct = function(e) {
406
- return Ge.call(e.ownerDocument || e, e, u.SHOW_ELEMENT | u.SHOW_COMMENT | u.SHOW_TEXT | u.SHOW_PROCESSING_INSTRUCTION | u.SHOW_CDATA_SECTION, null);
404
+ return e && r && a.insertBefore(n.createTextNode(r), a.childNodes[0] || null), W === U ? Ke.call(t, j ? "html" : "body")[0] : j ? t.documentElement : a;
407
405
  }, wt = function(e) {
406
+ return We.call(e.ownerDocument || e, e, u.SHOW_ELEMENT | u.SHOW_COMMENT | u.SHOW_TEXT | u.SHOW_PROCESSING_INSTRUCTION | u.SHOW_CDATA_SECTION, null);
407
+ }, Q = function(e) {
408
408
  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");
409
409
  }, Tt = function(e) {
410
410
  return typeof c == "function" && e instanceof c;
411
411
  };
412
412
  function $(e, n, r) {
413
413
  arrayForEach(e, (e) => {
414
- e.call(t, n, r, X);
414
+ e.call(t, n, r, Y);
415
415
  });
416
416
  }
417
417
  let Et = function(e) {
418
418
  let n = null;
419
- if ($(_.beforeSanitizeElements, e, null), wt(e)) return Z(e), !0;
420
- let r = Y(e.nodeName);
421
- if ($(_.uponSanitizeElement, e, {
419
+ if ($(v.beforeSanitizeElements, e, null), Q(e)) return X(e), !0;
420
+ let r = J(e.nodeName);
421
+ if ($(v.uponSanitizeElement, e, {
422
422
  tagName: r,
423
- allowedTags: x
424
- }), D && e.hasChildNodes() && !Tt(e.firstElementChild) && regExpTest(/<[/\w!]/g, e.innerHTML) && regExpTest(/<[/\w!]/g, e.textContent) || e.nodeType === NODE_TYPE.progressingInstruction || D && e.nodeType === NODE_TYPE.comment && regExpTest(/<[/\w]/g, e.data)) return Z(e), !0;
425
- if (!(T.tagCheck instanceof Function && T.tagCheck(r)) && (!x[r] || w[r])) {
426
- if (!w[r] && Ot(r) && (C.tagNameCheck instanceof RegExp && regExpTest(C.tagNameCheck, r) || C.tagNameCheck instanceof Function && C.tagNameCheck(r))) return !1;
427
- if (P && !L[r]) {
423
+ allowedTags: S
424
+ }), 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 X(e), !0;
425
+ if (!(D.tagCheck instanceof Function && D.tagCheck(r)) && (!S[r] || T[r])) {
426
+ if (!T[r] && Ot(r) && (w.tagNameCheck instanceof RegExp && regExpTest(w.tagNameCheck, r) || w.tagNameCheck instanceof Function && w.tagNameCheck(r))) return !1;
427
+ if (L && !B[r]) {
428
428
  let t = m(e) || e.parentNode, n = Ue(e) || e.childNodes;
429
429
  if (n && t) {
430
430
  let r = n.length;
@@ -434,65 +434,65 @@ function createDOMPurify() {
434
434
  }
435
435
  }
436
436
  }
437
- return Z(e), !0;
437
+ return X(e), !0;
438
438
  }
439
- return e instanceof l && !xt(e) || (r === "noscript" || r === "noembed" || r === "noframes") && regExpTest(/<\/no(script|embed|frames)/i, e.innerHTML) ? (Z(e), !0) : (E && e.nodeType === NODE_TYPE.text && (n = e.textContent, arrayForEach([
440
- v,
439
+ return e instanceof l && !St(e) || (r === "noscript" || r === "noembed" || r === "noframes") && regExpTest(/<\/no(script|embed|frames)/i, e.innerHTML) ? (X(e), !0) : (k && e.nodeType === NODE_TYPE.text && (n = e.textContent, arrayForEach([
441
440
  y,
442
- b
441
+ b,
442
+ x
443
443
  ], (e) => {
444
444
  n = stringReplace(n, e, " ");
445
- }), e.textContent !== n && (arrayPush(t.removed, { element: e.cloneNode() }), e.textContent = n)), $(_.afterSanitizeElements, e, null), !1);
445
+ }), e.textContent !== n && (arrayPush(t.removed, { element: e.cloneNode() }), e.textContent = n)), $(v.afterSanitizeElements, e, null), !1);
446
446
  }, Dt = function(e, t, r) {
447
- if (ct && (t === "id" || t === "name") && (r in n || r in gt)) return !1;
448
- if (!(at && !rt[t] && regExpTest(Ye, t)) && !(it && regExpTest(Xe, t)) && !(T.attributeCheck instanceof Function && T.attributeCheck(t, e))) {
449
- if (!S[t] || rt[t]) {
450
- if (!(Ot(e) && (C.tagNameCheck instanceof RegExp && regExpTest(C.tagNameCheck, e) || C.tagNameCheck instanceof Function && C.tagNameCheck(e)) && (C.attributeNameCheck instanceof RegExp && regExpTest(C.attributeNameCheck, t) || C.attributeNameCheck instanceof Function && C.attributeNameCheck(t, e)) || t === "is" && C.allowCustomizedBuiltInElements && (C.tagNameCheck instanceof RegExp && regExpTest(C.tagNameCheck, r) || C.tagNameCheck instanceof Function && C.tagNameCheck(r)))) return !1;
451
- } else if (!z[t] && !regExpTest(et, stringReplace(r, Qe, "")) && !((t === "src" || t === "xlink:href" || t === "href") && e !== "script" && stringIndexOf(r, "data:") === 0 && ut[e]) && !(ot && !regExpTest(Ze, stringReplace(r, Qe, ""))) && r) return !1;
447
+ if (at && (t === "id" || t === "name") && (r in n || r in _t)) return !1;
448
+ if (!(O && !E[t] && regExpTest(Je, t)) && !(nt && regExpTest(Ye, t)) && !(D.attributeCheck instanceof Function && D.attributeCheck(t, e))) {
449
+ if (!C[t] || E[t]) {
450
+ 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;
451
+ } else if (!ut[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;
452
452
  }
453
453
  return !0;
454
454
  }, Ot = function(e) {
455
- return e !== "annotation-xml" && stringMatch(e, $e);
455
+ return e !== "annotation-xml" && stringMatch(e, Qe);
456
456
  }, kt = function(e) {
457
- $(_.beforeSanitizeAttributes, e, null);
457
+ $(v.beforeSanitizeAttributes, e, null);
458
458
  let { attributes: n } = e;
459
- if (!n || wt(e)) return;
459
+ if (!n || Q(e)) return;
460
460
  let r = {
461
461
  attrName: "",
462
462
  attrValue: "",
463
463
  keepAttr: !0,
464
- allowedAttributes: S,
464
+ allowedAttributes: C,
465
465
  forceKeepAttr: void 0
466
466
  }, i = n.length;
467
467
  for (; i--;) {
468
- let { name: a, namespaceURI: o, value: s } = n[i], c = Y(a), l = s, u = a === "value" ? l : stringTrim(l);
469
- if (r.attrName = c, r.attrValue = u, r.keepAttr = !0, r.forceKeepAttr = void 0, $(_.uponSanitizeAttribute, e, r), u = r.attrValue, lt && (c === "id" || c === "name") && (Q(a, e), u = "user-content-" + u), D && regExpTest(/((--!?|])>)|<\/(style|title|textarea)/i, u)) {
470
- Q(a, e);
468
+ let { name: a, namespaceURI: o, value: s } = n[i], c = J(a), l = s, u = a === "value" ? l : stringTrim(l);
469
+ if (r.attrName = c, r.attrValue = u, r.keepAttr = !0, r.forceKeepAttr = void 0, $(v.uponSanitizeAttribute, e, r), u = r.attrValue, ot && (c === "id" || c === "name") && (Z(a, e), u = "user-content-" + u), A && regExpTest(/((--!?|])>)|<\/(style|title|textarea)/i, u)) {
470
+ Z(a, e);
471
471
  continue;
472
472
  }
473
473
  if (c === "attributename" && stringMatch(u, "href")) {
474
- Q(a, e);
474
+ Z(a, e);
475
475
  continue;
476
476
  }
477
477
  if (r.forceKeepAttr) continue;
478
478
  if (!r.keepAttr) {
479
- Q(a, e);
479
+ Z(a, e);
480
480
  continue;
481
481
  }
482
- if (!st && regExpTest(/\/>/i, u)) {
483
- Q(a, e);
482
+ if (!it && regExpTest(/\/>/i, u)) {
483
+ Z(a, e);
484
484
  continue;
485
485
  }
486
- E && arrayForEach([
487
- v,
486
+ k && arrayForEach([
488
487
  y,
489
- b
488
+ b,
489
+ x
490
490
  ], (e) => {
491
491
  u = stringReplace(u, e, " ");
492
492
  });
493
- let d = Y(e.nodeName);
493
+ let d = J(e.nodeName);
494
494
  if (!Dt(d, c, u)) {
495
- Q(a, e);
495
+ Z(a, e);
496
496
  continue;
497
497
  }
498
498
  if (h && typeof f == "object" && typeof f.getAttributeType == "function" && !o) switch (f.getAttributeType(d, c)) {
@@ -504,73 +504,101 @@ function createDOMPurify() {
504
504
  break;
505
505
  }
506
506
  if (u !== l) try {
507
- o ? e.setAttributeNS(o, a, u) : e.setAttribute(a, u), wt(e) ? Z(e) : arrayPop(t.removed);
507
+ o ? e.setAttributeNS(o, a, u) : e.setAttribute(a, u), Q(e) ? X(e) : arrayPop(t.removed);
508
508
  } catch {
509
- Q(a, e);
509
+ Z(a, e);
510
510
  }
511
511
  }
512
- $(_.afterSanitizeAttributes, e, null);
512
+ $(v.afterSanitizeAttributes, e, null);
513
513
  }, At = function e(t) {
514
- let n = null, r = Ct(t);
515
- for ($(_.beforeSanitizeShadowDOM, t, null); n = r.nextNode();) $(_.uponSanitizeShadowNode, n, null), Et(n), kt(n), n.content instanceof a && e(n.content);
516
- $(_.afterSanitizeShadowDOM, t, null);
514
+ let n = null, r = wt(t);
515
+ for ($(v.beforeSanitizeShadowDOM, t, null); n = r.nextNode();) $(v.uponSanitizeShadowNode, n, null), Et(n), kt(n), n.content instanceof a && e(n.content);
516
+ $(v.afterSanitizeShadowDOM, t, null);
517
517
  };
518
518
  return t.sanitize = function(e) {
519
519
  let n = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, i = null, o = null, s = null, l = null;
520
- if (W = !e, W && (e = "<!-->"), typeof e != "string" && !Tt(e)) if (typeof e.toString == "function") {
520
+ if (ft = !e, ft && (e = "<!-->"), typeof e != "string" && !Tt(e)) if (typeof e.toString == "function") {
521
521
  if (e = e.toString(), typeof e != "string") throw typeErrorCreate("dirty is not a string, aborting");
522
522
  } else throw typeErrorCreate("toString is not a function");
523
523
  if (!t.isSupported) return e;
524
- if (k || vt(n), t.removed = [], typeof e == "string" && (F = !1), F) {
524
+ if (M || yt(n), t.removed = [], typeof e == "string" && (R = !1), R) {
525
525
  if (e.nodeName) {
526
- let t = Y(e.nodeName);
527
- if (!x[t] || w[t]) throw typeErrorCreate("root node is forbidden and cannot be sanitized in-place");
526
+ let t = J(e.nodeName);
527
+ if (!S[t] || T[t]) throw typeErrorCreate("root node is forbidden and cannot be sanitized in-place");
528
528
  }
529
- } else if (e instanceof c) i = St("<!---->"), o = i.ownerDocument.importNode(e, !0), o.nodeType === NODE_TYPE.element && o.nodeName === "BODY" || o.nodeName === "HTML" ? i = o : i.appendChild(o);
529
+ } else if (e instanceof c) i = Ct("<!---->"), o = i.ownerDocument.importNode(e, !0), o.nodeType === NODE_TYPE.element && o.nodeName === "BODY" || o.nodeName === "HTML" ? i = o : i.appendChild(o);
530
530
  else {
531
- if (!j && !E && !O && e.indexOf("<") === -1) return h && N ? h.createHTML(e) : e;
532
- if (i = St(e), !i) return j ? null : N ? g : "";
531
+ if (!P && !k && !j && e.indexOf("<") === -1) return h && I ? h.createHTML(e) : e;
532
+ if (i = Ct(e), !i) return P ? null : I ? g : "";
533
533
  }
534
- i && A && Z(i.firstChild);
535
- let u = Ct(F ? e : i);
534
+ i && N && X(i.firstChild);
535
+ let u = wt(R ? e : i);
536
536
  for (; s = u.nextNode();) Et(s), kt(s), s.content instanceof a && At(s.content);
537
- if (F) return e;
538
- if (j) {
539
- if (M) for (l = Ke.call(i.ownerDocument); i.firstChild;) l.appendChild(i.firstChild);
537
+ if (R) return e;
538
+ if (P) {
539
+ if (F) for (l = Ge.call(i.ownerDocument); i.firstChild;) l.appendChild(i.firstChild);
540
540
  else l = i;
541
- return (S.shadowroot || S.shadowrootmode) && (l = Je.call(r, l, !0)), l;
541
+ return (C.shadowroot || C.shadowrootmode) && (l = qe.call(r, l, !0)), l;
542
542
  }
543
- let d = O ? i.outerHTML : i.innerHTML;
544
- return O && x["!doctype"] && i.ownerDocument && i.ownerDocument.doctype && i.ownerDocument.doctype.name && regExpTest(DOCTYPE_NAME, i.ownerDocument.doctype.name) && (d = "<!DOCTYPE " + i.ownerDocument.doctype.name + ">\n" + d), E && arrayForEach([
545
- v,
543
+ let d = j ? i.outerHTML : i.innerHTML;
544
+ return j && S["!doctype"] && i.ownerDocument && i.ownerDocument.doctype && i.ownerDocument.doctype.name && regExpTest(DOCTYPE_NAME, i.ownerDocument.doctype.name) && (d = "<!DOCTYPE " + i.ownerDocument.doctype.name + ">\n" + d), k && arrayForEach([
546
545
  y,
547
- b
546
+ b,
547
+ x
548
548
  ], (e) => {
549
549
  d = stringReplace(d, e, " ");
550
- }), h && N ? h.createHTML(d) : d;
550
+ }), h && I ? h.createHTML(d) : d;
551
551
  }, t.setConfig = function() {
552
- vt(arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}), k = !0;
552
+ yt(arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}), M = !0;
553
553
  }, t.clearConfig = function() {
554
- X = null, k = !1;
554
+ Y = null, M = !1;
555
555
  }, t.isValidAttribute = function(e, t, n) {
556
- return X || vt({}), Dt(Y(e), Y(t), n);
556
+ return Y || yt({}), Dt(J(e), J(t), n);
557
557
  }, t.addHook = function(e, t) {
558
- typeof t == "function" && arrayPush(_[e], t);
558
+ typeof t == "function" && arrayPush(v[e], t);
559
559
  }, t.removeHook = function(e, t) {
560
560
  if (t !== void 0) {
561
- let n = arrayLastIndexOf(_[e], t);
562
- return n === -1 ? void 0 : arraySplice(_[e], n, 1)[0];
561
+ let n = arrayLastIndexOf(v[e], t);
562
+ return n === -1 ? void 0 : arraySplice(v[e], n, 1)[0];
563
563
  }
564
- return arrayPop(_[e]);
564
+ return arrayPop(v[e]);
565
565
  }, t.removeHooks = function(e) {
566
- _[e] = [];
566
+ v[e] = [];
567
567
  }, t.removeAllHooks = function() {
568
- _ = _createHooksMap();
568
+ v = _createHooksMap();
569
569
  }, t;
570
570
  }
571
- 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));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;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-ai-interaction-textarea{flex-grow:0;flex-shrink:0}: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}", LuzmoAiChat = class extends LuzmoElement {
571
+ 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-ai-interaction-textarea{flex-grow:0;flex-shrink:0}: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}";
572
+ function buildAiMessageRequest(e) {
573
+ let { prompt: t, datasetIds: n, authKey: r, authToken: i, conversationId: a, chart: o, modelPreference: s, apiVersion: c = "0.1.0" } = e;
574
+ return {
575
+ key: r,
576
+ token: i,
577
+ action: "create",
578
+ version: c,
579
+ properties: {
580
+ content: {
581
+ role: "user",
582
+ content: t
583
+ },
584
+ ...a ? { conversation_id: a } : {}
585
+ },
586
+ options: {
587
+ available_datasets: n,
588
+ ...n.length > 0 ? { dataset_id: n[0] } : {},
589
+ ...o ? { chart: {
590
+ ...o,
591
+ title: o.title || o.options.title,
592
+ filters: o.filterGroups || [],
593
+ aichartId: o.aichartId || ""
594
+ } } : {},
595
+ model_preference: s
596
+ }
597
+ };
598
+ }
599
+ var LuzmoAiChat = class extends LuzmoElement {
572
600
  constructor(...e) {
573
- 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.conversationId = null, this.chart = null, this._isGenerating = !1, this._textareaValue = "";
601
+ 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._isGeneratingInternal = !1, this._textareaValue = "";
574
602
  }
575
603
  static {
576
604
  this.styles = unsafeCSS(ai_chat_module_default);
@@ -581,41 +609,30 @@ var purify = createDOMPurify(), ai_chat_module_default = ":host{box-sizing:borde
581
609
  _generateMessageId() {
582
610
  return `msg-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
583
611
  }
584
- async _sendMessage(e, t) {
585
- let n = `${this.apiUrl}/0.1.0/aimessage`, r = {
586
- key: this.authKey,
587
- token: this.authToken,
588
- action: "create",
589
- version: "0.1.0",
590
- properties: {
591
- content: {
592
- role: "user",
593
- content: e
594
- },
595
- ...!!this.conversationId && { conversation_id: this.conversationId }
596
- },
597
- options: {
598
- available_datasets: t,
599
- ...t.length > 0 && { dataset_id: t[0] },
600
- ...this.chart && { chart: {
601
- ...this.chart,
602
- title: this.chart.title || this.chart.options.title,
603
- filters: this.chart.filterGroups || [],
604
- aichartId: this.chart.aichartId || ""
605
- } },
606
- model_preference: this.modelPreference
607
- }
608
- }, i = await fetch(n, {
612
+ _buildRequestBody(e, t) {
613
+ return buildAiMessageRequest({
614
+ prompt: e,
615
+ datasetIds: t,
616
+ authKey: this.authKey,
617
+ authToken: this.authToken,
618
+ conversationId: this.conversationId,
619
+ chart: this.chart,
620
+ modelPreference: this.modelPreference,
621
+ apiVersion: this.apiVersion
622
+ });
623
+ }
624
+ async _sendMessage(e) {
625
+ let t = `${this.apiUrl}/${this.apiVersion}/aimessage`, n = await fetch(t, {
609
626
  method: "POST",
610
627
  headers: { "Content-Type": "application/json" },
611
628
  mode: "cors",
612
- body: JSON.stringify(r)
629
+ body: JSON.stringify(e)
613
630
  });
614
- if (!i.ok) {
615
- let e = await i.json().catch(() => null);
616
- throw Error(e?.message || `API request failed with status ${i.status}`);
631
+ if (!n.ok) {
632
+ let e = await n.json().catch(() => null);
633
+ throw Error(e?.message || `API request failed with status ${n.status}`);
617
634
  }
618
- return await i.json();
635
+ return await n.json();
619
636
  }
620
637
  async _addUserMessage(e, t) {
621
638
  let n = {
@@ -633,7 +650,7 @@ var purify = createDOMPurify(), ai_chat_module_default = ":host{box-sizing:borde
633
650
  })), await this.updateComplete, this._scrollToBottom();
634
651
  }
635
652
  _prepareForAIResponse() {
636
- this._isGenerating = !0;
653
+ this._isGeneratingInternal = !0;
637
654
  let e = {
638
655
  id: this._generateMessageId(),
639
656
  type: "ai",
@@ -646,7 +663,9 @@ var purify = createDOMPurify(), ai_chat_module_default = ":host{box-sizing:borde
646
663
  detail: { aiSampleChart: e },
647
664
  bubbles: !0,
648
665
  composed: !0
649
- })), e.message && (t.message = e.message, this.messages = [...this.messages.slice(0, -1), { ...t }], this.dispatchEvent(new CustomEvent("luzmo-response-received", {
666
+ }));
667
+ let n = e.message || e.error || e.clarificationQuestion;
668
+ n && (t.message = n, this.messages = [...this.messages.slice(0, -1), { ...t }], this.dispatchEvent(new CustomEvent("luzmo-response-received", {
650
669
  detail: {
651
670
  message: t,
652
671
  done: !0
@@ -661,7 +680,7 @@ var purify = createDOMPurify(), ai_chat_module_default = ":host{box-sizing:borde
661
680
  let t = e.functionResponse.explanation;
662
681
  t && typeof t == "string" && (n = e.functionResponse.explanation);
663
682
  } else n = e.functionResponse;
664
- n && (t.message = n, this.messages = [...this.messages.slice(0, -1), { ...t }]), this.dispatchEvent(new CustomEvent("luzmo-response-received", {
683
+ 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", {
665
684
  detail: {
666
685
  message: t,
667
686
  done: !0
@@ -671,7 +690,7 @@ var purify = createDOMPurify(), ai_chat_module_default = ":host{box-sizing:borde
671
690
  }));
672
691
  }
673
692
  _processAIResponse(e, t) {
674
- e.generatedChart === void 0 ? (e.functionResponse?.error !== void 0 || typeof e.functionResponse == "string") && this._handleErrorResponse(e, t) : this._handleChartResponse(e, t);
693
+ e.generatedChart === void 0 ? (e.functionResponse?.error !== void 0 || typeof e.functionResponse == "string" || e.clarificationQuestion === "string") && this._handleErrorResponse(e, t) : this._handleChartResponse(e, t);
675
694
  }
676
695
  _handleAPIError(e) {
677
696
  console.error("AI Chart Generation Error:", e);
@@ -690,15 +709,44 @@ var purify = createDOMPurify(), ai_chat_module_default = ":host{box-sizing:borde
690
709
  }));
691
710
  }
692
711
  async _finalizeAIResponse() {
693
- this._isGenerating = !1, await this.updateComplete, this._scrollToBottom();
712
+ this._isGeneratingInternal = !1, await this.updateComplete, this._scrollToBottom();
713
+ }
714
+ _handleDatasetSelected(e) {
715
+ let t = e.detail;
716
+ this.selectedDatasets.some((e) => e.id === t.id) || (this.selectedDatasets = [...this.selectedDatasets, t], this._emitDatasetsChanged());
717
+ }
718
+ _handleDatasetRemoved(e) {
719
+ let t = e.detail;
720
+ this.selectedDatasets = this.selectedDatasets.filter((e) => e.id !== t.id), this._emitDatasetsChanged();
721
+ }
722
+ _emitDatasetsChanged() {
723
+ this.dispatchEvent(new CustomEvent("luzmo-datasets-changed", {
724
+ detail: { selectedDatasets: this.selectedDatasets },
725
+ bubbles: !0,
726
+ composed: !0
727
+ }));
694
728
  }
695
729
  async _handlePromptSubmitted(e) {
696
- let { prompt: t, selectedDatasets: n } = e.detail;
697
- await this._addUserMessage(t, n);
698
- let r = await this._prepareForAIResponse();
730
+ let { prompt: t, selectedDatasets: n } = e.detail, r = n.map((e) => e.id), i = this._buildRequestBody(t, r);
731
+ if (await this._addUserMessage(t, n), this.requestMode === "external") {
732
+ let e = {
733
+ prompt: t,
734
+ selectedDatasets: n,
735
+ datasetIds: r,
736
+ request: i,
737
+ url: `${this.apiUrl}/${this.apiVersion}/aimessage`
738
+ };
739
+ this.dispatchEvent(new CustomEvent("luzmo-prompt-submitted", {
740
+ detail: e,
741
+ bubbles: !0,
742
+ composed: !0
743
+ }));
744
+ return;
745
+ }
746
+ let a = await this._prepareForAIResponse();
699
747
  try {
700
- let e = n.map((e) => e.id), i = await this._sendMessage(t, e);
701
- this._processAIResponse(i, r);
748
+ let e = await this._sendMessage(i);
749
+ this._processAIResponse(e, a);
702
750
  } catch (e) {
703
751
  this._handleAPIError(e);
704
752
  } finally {
@@ -780,6 +828,7 @@ var purify = createDOMPurify(), ai_chat_module_default = ":host{box-sizing:borde
780
828
  `);
781
829
  }
782
830
  render() {
831
+ let e = this.requestMode === "external" ? this.isGenerating : this._isGeneratingInternal;
783
832
  return html`
784
833
  <div class="chat-container">
785
834
  <div class="chat-messages-container">
@@ -791,7 +840,7 @@ var purify = createDOMPurify(), ai_chat_module_default = ":host{box-sizing:borde
791
840
  .selectedDatasets=${this.selectedDatasets}
792
841
  .placeholder=${this.placeholder}
793
842
  ?disabled=${this.disabled}
794
- ?is-generating=${this._isGenerating}
843
+ ?is-generating=${e}
795
844
  ?hide-dataset-button=${this.hideDatasetButton}
796
845
  auth-key=${this.authKey}
797
846
  auth-token=${this.authToken}
@@ -799,6 +848,8 @@ var purify = createDOMPurify(), ai_chat_module_default = ":host{box-sizing:borde
799
848
  app-server=${this.appServer}
800
849
  ?flag-opendata=${this.flagOpendata}
801
850
  @prompt-submitted=${this._handlePromptSubmitted}
851
+ @dataset-selected=${this._handleDatasetSelected}
852
+ @dataset-removed=${this._handleDatasetRemoved}
802
853
  ></luzmo-ai-interaction-textarea>
803
854
  </div>
804
855
  `;
@@ -835,10 +886,19 @@ __decorate([property({ type: Array })], LuzmoAiChat.prototype, "messages", void
835
886
  type: String,
836
887
  attribute: "model-preference"
837
888
  })], LuzmoAiChat.prototype, "modelPreference", void 0), __decorate([property({
889
+ type: String,
890
+ attribute: "request-mode"
891
+ })], LuzmoAiChat.prototype, "requestMode", void 0), __decorate([property({
892
+ type: Boolean,
893
+ attribute: "is-generating"
894
+ })], LuzmoAiChat.prototype, "isGenerating", void 0), __decorate([property({
838
895
  type: String,
839
896
  attribute: "conversation-id"
840
897
  })], LuzmoAiChat.prototype, "conversationId", void 0), __decorate([property({
841
898
  type: Object,
842
899
  attribute: "chart"
843
- })], LuzmoAiChat.prototype, "chart", void 0), __decorate([state()], LuzmoAiChat.prototype, "_isGenerating", void 0), __decorate([state()], LuzmoAiChat.prototype, "_textareaValue", void 0), customElements.get("luzmo-ai-chat") || customElements.define("luzmo-ai-chat", LuzmoAiChat);
844
- export { LuzmoAiChat as t };
900
+ })], LuzmoAiChat.prototype, "chart", void 0), __decorate([property({
901
+ type: String,
902
+ attribute: "api-version"
903
+ })], LuzmoAiChat.prototype, "apiVersion", 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);
904
+ export { buildAiMessageRequest as n, LuzmoAiChat as t };