@luzmo/analytics-components-kit 1.0.3-beta.5 → 1.0.3-beta.6
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.
- package/components/ai-chat/ai-chat-request.d.ts +11 -0
- package/components/ai-chat/ai-chat.d.ts +59 -54
- package/components/ai-chat/ai-prompt-types.d.ts +93 -0
- package/components/ai-chat/index.cjs +1 -1
- package/components/ai-chat/index.d.ts +9 -4
- package/components/ai-chat/index.js +2 -2
- package/components/ai-chat/session/ai-chat-session-controller.d.ts +51 -0
- package/components/ai-chat/session/ai-chat-session-types.d.ts +86 -0
- package/components/ai-chat/session/ai-chat-session.d.ts +81 -0
- package/components/ai-chat/session/index.d.ts +2 -0
- package/components/ai-chat/{ai-chat-streaming.d.ts → stream/ai-chat-streaming.d.ts} +6 -0
- package/components/ai-chat/stream/analyst-handler.d.ts +3 -0
- package/components/ai-chat/stream/dashboard-handler.d.ts +4 -0
- package/components/ai-chat/stream/index.d.ts +8 -0
- package/components/ai-chat/stream/item-handler.d.ts +2 -0
- package/components/ai-chat/stream/registry.d.ts +5 -0
- package/components/ai-chat/stream/shared.d.ts +10 -0
- package/components/ai-chat/stream/types.d.ts +26 -0
- package/components/ai-chat-CY73iYCg.cjs +154 -0
- package/components/ai-chat-DVU9XiA2.js +1788 -0
- package/components/ai-interaction-textarea/index.cjs +1 -1
- package/components/ai-interaction-textarea/index.js +1 -1
- package/components/{ai-interaction-textarea-BXmgedJt.js → ai-interaction-textarea-DI98QoMZ.js} +3 -3
- package/components/{ai-interaction-textarea-CogE101T.cjs → ai-interaction-textarea-DqWt823F.cjs} +1 -1
- package/components/{base-BAzY-whv.js → base-D3ehdFno.js} +1 -1
- package/components/{base-CbpjVnVy.cjs → base-HUGXYn6t.cjs} +1 -1
- package/components/data-field/index.cjs +1 -1
- package/components/data-field/index.js +1 -1
- package/components/{data-field-97uH3l6o.cjs → data-field-DSzU9Apl.cjs} +1 -1
- package/components/{data-field-tfAMLb-d.js → data-field-DwSYggPc.js} +3 -3
- package/components/data-field-level/index.cjs +1 -1
- package/components/data-field-level/index.js +1 -1
- package/components/{data-field-level-BsDTHrJ6.js → data-field-level-BquNqRm1.js} +1 -1
- package/components/{data-field-level-6npuFtQo.cjs → data-field-level-CYUtLiIi.cjs} +1 -1
- package/components/data-field-panel/index.cjs +1 -1
- package/components/data-field-panel/index.js +1 -1
- package/components/{data-field-panel-Dv5nfM0z.cjs → data-field-panel-B_83HNyI.cjs} +1 -1
- package/components/{data-field-panel-P2t8d6sG.js → data-field-panel-Bqslx0EB.js} +3 -3
- package/components/data-fields-select/index.cjs +1 -1
- package/components/data-fields-select/index.js +1 -1
- package/components/{data-fields-select-B7vJTdZO.cjs → data-fields-select-BZj1cpL5.cjs} +1 -1
- package/components/{data-fields-select-DHnnYhbr.js → data-fields-select-t1ikPTLw.js} +1 -1
- package/components/dataset-selector-list/index.cjs +1 -1
- package/components/dataset-selector-list/index.js +1 -1
- package/components/{dataset-selector-list-DbCmavOc.cjs → dataset-selector-list-Bta-CGoN.cjs} +1 -1
- package/components/{dataset-selector-list-CXnDkIe2.js → dataset-selector-list-Ho8JnQp7.js} +1 -1
- package/components/dataset-selector-row/index.cjs +1 -1
- package/components/dataset-selector-row/index.js +1 -1
- package/components/{dataset-selector-row-BONcmdL2.js → dataset-selector-row-8hgsmMRg.js} +1 -1
- package/components/{dataset-selector-row-Bm60zTbF.cjs → dataset-selector-row-CKhHK1H5.cjs} +1 -1
- package/components/{de-B8ds_DbE.cjs → de-CVLDoWlp.cjs} +1 -1
- package/components/{de-DMnvmNFg.js → de-D2bZwq4D.js} +6 -1
- package/components/display-settings/index.cjs +1 -1
- package/components/display-settings/index.js +1 -1
- package/components/{display-settings-BLf7lBww.cjs → display-settings-Bmb0HUlu.cjs} +1 -1
- package/components/{display-settings-BLMrlvMS.js → display-settings-Di9dXtUM.js} +1 -1
- package/components/display-settings-binning/index.cjs +1 -1
- package/components/display-settings-binning/index.js +1 -1
- package/components/{display-settings-binning-hCJ0qkt5.js → display-settings-binning-B8qUIt6T.js} +2 -2
- package/components/{display-settings-binning-BAg6FoqJ.cjs → display-settings-binning-CpwCqvwm.cjs} +1 -1
- package/components/display-settings-datetime/index.cjs +1 -1
- package/components/display-settings-datetime/index.js +1 -1
- package/components/{display-settings-datetime-BzeNlKLC.cjs → display-settings-datetime-3M3DvzTN.cjs} +1 -1
- package/components/{display-settings-datetime-CCxok7d7.js → display-settings-datetime-C8JfjDJK.js} +2 -2
- package/components/display-settings-grand-totals/index.cjs +1 -1
- package/components/display-settings-grand-totals/index.js +1 -1
- package/components/{display-settings-grand-totals-HDpr3IJ5.cjs → display-settings-grand-totals-DMDa6C5k.cjs} +1 -1
- package/components/{display-settings-grand-totals-C1N1cehl.js → display-settings-grand-totals-kyfMh55D.js} +2 -2
- package/components/display-settings-numeric/index.cjs +1 -1
- package/components/display-settings-numeric/index.js +1 -1
- package/components/{display-settings-numeric-DSs20wUu.cjs → display-settings-numeric-B51KddXI.cjs} +1 -1
- package/components/{display-settings-numeric-oyCfBAGV.js → display-settings-numeric-Cw8Nx5s9.js} +2 -2
- package/components/display-settings-period-over-period/index.cjs +1 -1
- package/components/display-settings-period-over-period/index.js +1 -1
- package/components/{display-settings-period-over-period-h8bA3V5C.js → display-settings-period-over-period-B2AN0rwz.js} +2 -2
- package/components/{display-settings-period-over-period-CcX7vQnt.cjs → display-settings-period-over-period-CjjA2NqZ.cjs} +1 -1
- package/components/{es-Cc258uTs.js → es-9-jszdOJ.js} +6 -1
- package/components/{es-DGC51Dm9.cjs → es-Byjf7YBI.cjs} +1 -1
- package/components/filter-expression-picker/index.cjs +1 -1
- package/components/filter-expression-picker/index.js +1 -1
- package/components/{filter-expression-picker-DQP5lkn4.js → filter-expression-picker-Brn-vNUd.js} +1 -1
- package/components/{filter-expression-picker-BMJkgHu9.cjs → filter-expression-picker-DCFZKpBE.cjs} +1 -1
- package/components/filter-item/index.cjs +1 -1
- package/components/filter-item/index.js +1 -1
- package/components/{filter-item-BXcYNAAm.js → filter-item-BlSQe2nu.js} +4 -4
- package/components/{filter-item-D9m378Qo.cjs → filter-item-Cjrhb1RR.cjs} +1 -1
- package/components/filter-value-picker/index.cjs +1 -1
- package/components/filter-value-picker/index.js +1 -1
- package/components/{filter-value-picker-YIkbsWDP.cjs → filter-value-picker-BCckBdal.cjs} +1 -1
- package/components/{filter-value-picker-B-dzcjEo.js → filter-value-picker-CBetCjIs.js} +4 -4
- package/components/filter-value-picker-datetime/index.cjs +1 -1
- package/components/filter-value-picker-datetime/index.js +1 -1
- package/components/{filter-value-picker-datetime-BJMcnoKH.js → filter-value-picker-datetime-CT63jJDI.js} +1 -1
- package/components/{filter-value-picker-datetime-BrrmcjIE.cjs → filter-value-picker-datetime-CxM6HXe3.cjs} +1 -1
- package/components/filter-value-picker-hierarchy/index.cjs +1 -1
- package/components/filter-value-picker-hierarchy/index.js +1 -1
- package/components/{filter-value-picker-hierarchy-B9gDxYna.cjs → filter-value-picker-hierarchy-C5QZXiQz.cjs} +1 -1
- package/components/{filter-value-picker-hierarchy-UdDq0CZG.js → filter-value-picker-hierarchy-CAORy2A-.js} +2 -2
- package/components/filter-value-picker-numeric/index.cjs +1 -1
- package/components/filter-value-picker-numeric/index.js +1 -1
- package/components/{filter-value-picker-numeric-D_dgITCq.cjs → filter-value-picker-numeric-CtOfHaJR.cjs} +1 -1
- package/components/{filter-value-picker-numeric-EK515Z-Y.js → filter-value-picker-numeric-Fao-PKN7.js} +1 -1
- package/components/filters/index.cjs +1 -1
- package/components/filters/index.js +1 -1
- package/components/{filters-H2scDNLi.js → filters-CtWut3ce.js} +2 -2
- package/components/{filters-8ehwgopC.cjs → filters-DI0GTL9k.cjs} +1 -1
- package/components/{fr-BoZFY3Qe.cjs → fr-BVxPTfyF.cjs} +1 -1
- package/components/{fr-B32d4zcX.js → fr-DLf99-F8.js} +6 -1
- package/components/{get-dataset-name-CrWWViwN.cjs → get-dataset-name-CvZduuOo.cjs} +1 -1
- package/components/{get-dataset-name-7FdLQo10.js → get-dataset-name-EKmxKZU9.js} +1 -1
- package/components/index.cjs +1 -1
- package/components/index.js +58 -58
- package/components/item-grid/helpers/grid-item-popover.d.ts +7 -1
- package/components/item-grid/helpers/grid-rendering.d.ts +7 -1
- package/components/item-grid/index.cjs +1 -1
- package/components/item-grid/index.js +1 -1
- package/components/item-grid/item-grid.d.ts +8 -0
- package/components/{item-grid-CxblVEy3.cjs → item-grid-Bcez8lwg.cjs} +7 -7
- package/components/{item-grid-B-IFwriA.js → item-grid-DgxtJ0eX.js} +574 -564
- package/components/item-option/index.cjs +1 -1
- package/components/item-option/index.js +1 -1
- package/components/{item-option-ChsD18x9.cjs → item-option-BgYyAKSW.cjs} +1 -1
- package/components/{item-option-Buxnv89s.js → item-option-DjiTHr0r.js} +1 -1
- package/components/item-option-action-button-group/index.cjs +1 -1
- package/components/item-option-action-button-group/index.js +1 -1
- package/components/{item-option-action-button-group-Cw9EDbG-.cjs → item-option-action-button-group-DdqzgR08.cjs} +1 -1
- package/components/{item-option-action-button-group-QO_darH9.js → item-option-action-button-group-U5GCtFjg.js} +1 -1
- package/components/{item-option-base-DjQ5poaH.cjs → item-option-base-BeIdCZMp.cjs} +1 -1
- package/components/{item-option-base-DMmga0dv.js → item-option-base-DM3U9dbW.js} +1 -1
- package/components/item-option-color-palette-picker/index.cjs +1 -1
- package/components/item-option-color-palette-picker/index.js +1 -1
- package/components/{item-option-color-palette-picker-CiE_aWRI.js → item-option-color-palette-picker-BsMZ3IUR.js} +1 -1
- package/components/{item-option-color-palette-picker-gZvk4ODA.cjs → item-option-color-palette-picker-oj8nSb-q.cjs} +1 -1
- package/components/item-option-color-picker/index.cjs +1 -1
- package/components/item-option-color-picker/index.js +1 -1
- package/components/{item-option-color-picker-DCnGqBgT.cjs → item-option-color-picker-BJKGTrIi.cjs} +1 -1
- package/components/{item-option-color-picker-CUskqN3R.js → item-option-color-picker-B_pemZKJ.js} +1 -1
- package/components/item-option-color-range/index.cjs +1 -1
- package/components/item-option-color-range/index.js +1 -1
- package/components/{item-option-color-range-B24EAbUi.cjs → item-option-color-range-BOegJZim.cjs} +1 -1
- package/components/{item-option-color-range-BgHXTDvx.js → item-option-color-range-DW3rdMt5.js} +1 -1
- package/components/item-option-multi-language-field/index.cjs +1 -1
- package/components/item-option-multi-language-field/index.js +1 -1
- package/components/{item-option-multi-language-field-DDIu7Hns.cjs → item-option-multi-language-field-BQZ4Lmiy.cjs} +1 -1
- package/components/{item-option-multi-language-field-qngZBXHT.js → item-option-multi-language-field-CeYgkRzs.js} +1 -1
- package/components/item-option-number-field/index.cjs +1 -1
- package/components/item-option-number-field/index.js +1 -1
- package/components/{item-option-number-field-Cd-cfpaq.js → item-option-number-field-CFQyJG_w.js} +1 -1
- package/components/{item-option-number-field-CqrO1Xu0.cjs → item-option-number-field-T2L2jFCf.cjs} +1 -1
- package/components/item-option-panel/index.cjs +1 -1
- package/components/item-option-panel/index.js +1 -1
- package/components/{item-option-panel-B26_sDcj.cjs → item-option-panel-BOJmKPgY.cjs} +1 -1
- package/components/{item-option-panel-DZiOx_sn.js → item-option-panel-ChOItFmc.js} +2 -2
- package/components/item-option-picker/index.cjs +1 -1
- package/components/item-option-picker/index.js +1 -1
- package/components/{item-option-picker-B86AqAWp.cjs → item-option-picker-3krQktmk.cjs} +1 -1
- package/components/{item-option-picker-LRahjZUz.js → item-option-picker-IBP7QFLA.js} +1 -1
- package/components/item-option-position-picker/index.cjs +1 -1
- package/components/item-option-position-picker/index.js +1 -1
- package/components/{item-option-position-picker-Cbi2OygH.cjs → item-option-position-picker-BiLRWUWK.cjs} +1 -1
- package/components/{item-option-position-picker-NUpUlyPV.js → item-option-position-picker-DF54K_Mw.js} +1 -1
- package/components/item-option-positions-number-field/index.cjs +1 -1
- package/components/item-option-positions-number-field/index.js +1 -1
- package/components/{item-option-positions-number-field-BbIkX6wM.cjs → item-option-positions-number-field-B6qxN1x7.cjs} +1 -1
- package/components/{item-option-positions-number-field-ClPil6MM.js → item-option-positions-number-field-Dchzu5NS.js} +1 -1
- package/components/item-option-radio-button-group/index.cjs +1 -1
- package/components/item-option-radio-button-group/index.js +1 -1
- package/components/{item-option-radio-button-group-Bdd9sU4p.js → item-option-radio-button-group-BiOpqNXX.js} +1 -1
- package/components/{item-option-radio-button-group-BtYYhQyI.cjs → item-option-radio-button-group-DzI_2jB3.cjs} +1 -1
- package/components/item-option-slider/index.cjs +1 -1
- package/components/item-option-slider/index.js +1 -1
- package/components/{item-option-slider-32oGS1fd.cjs → item-option-slider-6E4VgJpv.cjs} +1 -1
- package/components/{item-option-slider-BJ7gVQXP.js → item-option-slider-Dba7mmcA.js} +1 -1
- package/components/item-option-switch/index.cjs +1 -1
- package/components/item-option-switch/index.js +1 -1
- package/components/{item-option-switch-BMVlfdx5.js → item-option-switch-BAYX5lTr.js} +1 -1
- package/components/{item-option-switch-BFk3biK9.cjs → item-option-switch-Dt4pzFNi.cjs} +1 -1
- package/components/item-option-text-field/index.cjs +1 -1
- package/components/item-option-text-field/index.js +1 -1
- package/components/{item-option-text-field-CWvgQ3pJ.cjs → item-option-text-field-BLOz4LvH.cjs} +1 -1
- package/components/{item-option-text-field-BoXwVo-B.js → item-option-text-field-CHalqTt1.js} +1 -1
- package/components/item-slot-drop/index.cjs +1 -1
- package/components/item-slot-drop/index.js +1 -1
- package/components/{item-slot-drop-CYRVCWF0.cjs → item-slot-drop-CNeF_Qmg.cjs} +1 -1
- package/components/{item-slot-drop-C0GmOMQY.js → item-slot-drop-n6UHgA-Q.js} +4 -4
- package/components/item-slot-drop-panel/index.cjs +1 -1
- package/components/item-slot-drop-panel/index.js +1 -1
- package/components/{item-slot-drop-panel-CoRFds3a.cjs → item-slot-drop-panel-Bh6PlCJx.cjs} +1 -1
- package/components/{item-slot-drop-panel-Ci3Soo16.js → item-slot-drop-panel-Hhp9_pDd.js} +3 -3
- package/components/item-slot-picker/index.cjs +1 -1
- package/components/item-slot-picker/index.js +1 -1
- package/components/{item-slot-picker-CmnJSYIF.cjs → item-slot-picker-7oF3vLwb.cjs} +1 -1
- package/components/{item-slot-picker-D1_NbL1A.js → item-slot-picker-BAMVwHtd.js} +5 -5
- package/components/item-slot-picker-panel/index.cjs +1 -1
- package/components/item-slot-picker-panel/index.js +1 -1
- package/components/{item-slot-picker-panel-B8VvKhRF.js → item-slot-picker-panel-BYCDx6Hk.js} +3 -3
- package/components/{item-slot-picker-panel-DzKodYTM.cjs → item-slot-picker-panel-C6mMlurQ.cjs} +1 -1
- package/components/{localized-mixin-DZuGq2Fm.js → localized-mixin-CpYxJczB.js} +1 -1
- package/components/{localized-mixin-Dujo7nlJ.cjs → localized-mixin-CxGNXOcg.cjs} +1 -1
- package/components/{nl-C9Ad2LdA.cjs → nl-D4uOyZ6h.cjs} +1 -1
- package/components/{nl-hCQgb1fB.js → nl-QLEhlKsI.js} +6 -1
- package/components/{set-locale-CXnxhP_B.js → set-locale-wsrhUZVV.js} +4 -4
- package/components/{set-locale-MCuEsOOu.cjs → set-locale-xSK2Wd4D.cjs} +1 -1
- package/components/slot-menu/index.cjs +1 -1
- package/components/slot-menu/index.js +1 -1
- package/components/{slot-menu-CYNYwJnU.js → slot-menu-B431N66z.js} +3 -3
- package/components/{slot-menu-CDAAPyFj.cjs → slot-menu-CIQRPLvx.cjs} +1 -1
- package/components/slot-menu-list/index.cjs +1 -1
- package/components/slot-menu-list/index.js +1 -1
- package/components/{slot-menu-list-DbWiuJDF.cjs → slot-menu-list-BROocU0s.cjs} +1 -1
- package/components/{slot-menu-list-DL-x5Ggl.js → slot-menu-list-Cdh09ie0.js} +1 -1
- package/components/utils/base.cjs +1 -1
- package/components/utils/base.js +2 -2
- package/components/{utils-BACUV6sE.js → utils-CJ3Vy98n.js} +1 -1
- package/components/{utils-DKSE_5u1.cjs → utils-iY1cKQaF.cjs} +1 -1
- package/components/utils.cjs +1 -1
- package/components/utils.js +2 -2
- package/components/viz-item-menu/index.cjs +1 -1
- package/components/viz-item-menu/index.js +1 -1
- package/components/{viz-item-menu-DXoKwAhV.js → viz-item-menu--FyB_XCf.js} +1 -1
- package/components/{viz-item-menu-yr7TQY8-.cjs → viz-item-menu-D20StIE_.cjs} +1 -1
- package/custom-elements.json +1460 -157
- package/package.json +1 -1
- package/react/components/ai-chat/stream/index.ts +1 -0
- package/react/components/ai-chat/stream/types.ts +29 -0
- package/react/components/ai-chat.component.ts +12 -12
- package/react/esm/components/ai-chat/stream/index.d.ts +1 -0
- package/react/esm/components/ai-chat/stream/index.js +1 -0
- package/react/esm/components/ai-chat/stream/types.d.ts +26 -0
- package/react/esm/components/ai-chat/stream/types.js +1 -0
- package/react/esm/components/ai-chat.component.d.ts +8 -8
- package/react/esm/components/ai-chat.component.js +8 -8
- package/types/ai-chat.types.d.ts +1 -1
- package/components/ai-chat/request-contract.d.ts +0 -56
- package/components/ai-chat-D9yB7Sw_.cjs +0 -151
- package/components/ai-chat-DkfD3BDG.js +0 -1258
|
@@ -0,0 +1,1788 @@
|
|
|
1
|
+
/*! * A kit of modern Luzmo Web Components for analytics in your web application.
|
|
2
|
+
*
|
|
3
|
+
* Copyright © 2026 Luzmo
|
|
4
|
+
* All rights reserved.
|
|
5
|
+
* Luzmo web components (“Luzmo Web Components”)
|
|
6
|
+
* must be used according to the Luzmo Terms of Service.
|
|
7
|
+
* This license allows users with a current active Luzmo account
|
|
8
|
+
* to use the Luzmo Web Components. This license terminates
|
|
9
|
+
* automatically if a user no longer has an active Luzmo account.
|
|
10
|
+
* Please view the Luzmo Terms of Service at: https://www.luzmo.com/information-pages/terms-of-use.
|
|
11
|
+
*
|
|
12
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
13
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
14
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
15
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
16
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
17
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
18
|
+
* SOFTWARE.
|
|
19
|
+
* */
|
|
20
|
+
import { i as e } from "./base-D3ehdFno.js";
|
|
21
|
+
import { t } from "./decorate-DKLaHs_w.js";
|
|
22
|
+
import "./ai-interaction-textarea-DI98QoMZ.js";
|
|
23
|
+
import { msg as n } from "@lit/localize/lit-localize";
|
|
24
|
+
import { luzmoEllipsisVertical as r, luzmoIcon as i, luzmoSpin as a } from "@luzmo/icons";
|
|
25
|
+
import "@luzmo/lucero/chat-message";
|
|
26
|
+
import "@luzmo/lucero/overlay";
|
|
27
|
+
import "@luzmo/lucero/popover";
|
|
28
|
+
import "@luzmo/lucero/progress-steps";
|
|
29
|
+
import { html as o, nothing as s, unsafeCSS as c } from "lit";
|
|
30
|
+
import { property as l, state as u } from "lit/decorators.js";
|
|
31
|
+
import { unsafeHTML as d } from "lit/directives/unsafe-html.js";
|
|
32
|
+
//#region node_modules/dompurify/dist/purify.es.mjs
|
|
33
|
+
var { entries: ee, setPrototypeOf: te, isFrozen: f, getPrototypeOf: p, getOwnPropertyDescriptor: ne } = Object, { freeze: m, seal: h, create: re } = Object, { apply: ie, construct: ae } = typeof Reflect < "u" && Reflect;
|
|
34
|
+
m ||= function(e) {
|
|
35
|
+
return e;
|
|
36
|
+
}, h ||= function(e) {
|
|
37
|
+
return e;
|
|
38
|
+
}, ie ||= function(e, t) {
|
|
39
|
+
var n = [...arguments].slice(2);
|
|
40
|
+
return e.apply(t, n);
|
|
41
|
+
}, ae ||= function(e) {
|
|
42
|
+
return new e(...[...arguments].slice(1));
|
|
43
|
+
};
|
|
44
|
+
var oe = y(Array.prototype.forEach), se = y(Array.prototype.lastIndexOf), ce = y(Array.prototype.pop), le = y(Array.prototype.push), ue = y(Array.prototype.splice), de = y(String.prototype.toLowerCase), fe = y(String.prototype.toString), pe = y(String.prototype.match), g = y(String.prototype.replace), me = y(String.prototype.indexOf), he = y(String.prototype.trim), _ = y(Object.prototype.hasOwnProperty), v = y(RegExp.prototype.test), ge = b(TypeError);
|
|
45
|
+
function y(e) {
|
|
46
|
+
return function(t) {
|
|
47
|
+
t instanceof RegExp && (t.lastIndex = 0);
|
|
48
|
+
var n = [...arguments].slice(1);
|
|
49
|
+
return ie(e, t, n);
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
function b(e) {
|
|
53
|
+
return function() {
|
|
54
|
+
return ae(e, [...arguments]);
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
function x(e, t) {
|
|
58
|
+
let n = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : de;
|
|
59
|
+
te && te(e, null);
|
|
60
|
+
let r = t.length;
|
|
61
|
+
for (; r--;) {
|
|
62
|
+
let i = t[r];
|
|
63
|
+
if (typeof i == "string") {
|
|
64
|
+
let e = n(i);
|
|
65
|
+
e !== i && (f(t) || (t[r] = e), i = e);
|
|
66
|
+
}
|
|
67
|
+
e[i] = !0;
|
|
68
|
+
}
|
|
69
|
+
return e;
|
|
70
|
+
}
|
|
71
|
+
function S(e) {
|
|
72
|
+
for (let t = 0; t < e.length; t++) _(e, t) || (e[t] = null);
|
|
73
|
+
return e;
|
|
74
|
+
}
|
|
75
|
+
function C(e) {
|
|
76
|
+
let t = re(null);
|
|
77
|
+
for (let [n, r] of ee(e)) _(e, n) && (Array.isArray(r) ? t[n] = S(r) : r && typeof r == "object" && r.constructor === Object ? t[n] = C(r) : t[n] = r);
|
|
78
|
+
return t;
|
|
79
|
+
}
|
|
80
|
+
function _e(e, t) {
|
|
81
|
+
for (; e !== null;) {
|
|
82
|
+
let n = ne(e, t);
|
|
83
|
+
if (n) {
|
|
84
|
+
if (n.get) return y(n.get);
|
|
85
|
+
if (typeof n.value == "function") return y(n.value);
|
|
86
|
+
}
|
|
87
|
+
e = p(e);
|
|
88
|
+
}
|
|
89
|
+
function n() {
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
return n;
|
|
93
|
+
}
|
|
94
|
+
var ve = m(/* @__PURE__ */ "a.abbr.acronym.address.area.article.aside.audio.b.bdi.bdo.big.blink.blockquote.body.br.button.canvas.caption.center.cite.code.col.colgroup.content.data.datalist.dd.decorator.del.details.dfn.dialog.dir.div.dl.dt.element.em.fieldset.figcaption.figure.font.footer.form.h1.h2.h3.h4.h5.h6.head.header.hgroup.hr.html.i.img.input.ins.kbd.label.legend.li.main.map.mark.marquee.menu.menuitem.meter.nav.nobr.ol.optgroup.option.output.p.picture.pre.progress.q.rp.rt.ruby.s.samp.search.section.select.shadow.slot.small.source.spacer.span.strike.strong.style.sub.summary.sup.table.tbody.td.template.textarea.tfoot.th.thead.time.tr.track.tt.u.ul.var.video.wbr".split(".")), ye = m(/* @__PURE__ */ "svg.a.altglyph.altglyphdef.altglyphitem.animatecolor.animatemotion.animatetransform.circle.clippath.defs.desc.ellipse.enterkeyhint.exportparts.filter.font.g.glyph.glyphref.hkern.image.inputmode.line.lineargradient.marker.mask.metadata.mpath.part.path.pattern.polygon.polyline.radialgradient.rect.stop.style.switch.symbol.text.textpath.title.tref.tspan.view.vkern".split(".")), be = m([
|
|
95
|
+
"feBlend",
|
|
96
|
+
"feColorMatrix",
|
|
97
|
+
"feComponentTransfer",
|
|
98
|
+
"feComposite",
|
|
99
|
+
"feConvolveMatrix",
|
|
100
|
+
"feDiffuseLighting",
|
|
101
|
+
"feDisplacementMap",
|
|
102
|
+
"feDistantLight",
|
|
103
|
+
"feDropShadow",
|
|
104
|
+
"feFlood",
|
|
105
|
+
"feFuncA",
|
|
106
|
+
"feFuncB",
|
|
107
|
+
"feFuncG",
|
|
108
|
+
"feFuncR",
|
|
109
|
+
"feGaussianBlur",
|
|
110
|
+
"feImage",
|
|
111
|
+
"feMerge",
|
|
112
|
+
"feMergeNode",
|
|
113
|
+
"feMorphology",
|
|
114
|
+
"feOffset",
|
|
115
|
+
"fePointLight",
|
|
116
|
+
"feSpecularLighting",
|
|
117
|
+
"feSpotLight",
|
|
118
|
+
"feTile",
|
|
119
|
+
"feTurbulence"
|
|
120
|
+
]), xe = m([
|
|
121
|
+
"animate",
|
|
122
|
+
"color-profile",
|
|
123
|
+
"cursor",
|
|
124
|
+
"discard",
|
|
125
|
+
"font-face",
|
|
126
|
+
"font-face-format",
|
|
127
|
+
"font-face-name",
|
|
128
|
+
"font-face-src",
|
|
129
|
+
"font-face-uri",
|
|
130
|
+
"foreignobject",
|
|
131
|
+
"hatch",
|
|
132
|
+
"hatchpath",
|
|
133
|
+
"mesh",
|
|
134
|
+
"meshgradient",
|
|
135
|
+
"meshpatch",
|
|
136
|
+
"meshrow",
|
|
137
|
+
"missing-glyph",
|
|
138
|
+
"script",
|
|
139
|
+
"set",
|
|
140
|
+
"solidcolor",
|
|
141
|
+
"unknown",
|
|
142
|
+
"use"
|
|
143
|
+
]), Se = m(/* @__PURE__ */ "math.menclose.merror.mfenced.mfrac.mglyph.mi.mlabeledtr.mmultiscripts.mn.mo.mover.mpadded.mphantom.mroot.mrow.ms.mspace.msqrt.mstyle.msub.msup.msubsup.mtable.mtd.mtext.mtr.munder.munderover.mprescripts".split(".")), Ce = m([
|
|
144
|
+
"maction",
|
|
145
|
+
"maligngroup",
|
|
146
|
+
"malignmark",
|
|
147
|
+
"mlongdiv",
|
|
148
|
+
"mscarries",
|
|
149
|
+
"mscarry",
|
|
150
|
+
"msgroup",
|
|
151
|
+
"mstack",
|
|
152
|
+
"msline",
|
|
153
|
+
"msrow",
|
|
154
|
+
"semantics",
|
|
155
|
+
"annotation",
|
|
156
|
+
"annotation-xml",
|
|
157
|
+
"mprescripts",
|
|
158
|
+
"none"
|
|
159
|
+
]), we = m(["#text"]), Te = m(/* @__PURE__ */ "accept.action.align.alt.autocapitalize.autocomplete.autopictureinpicture.autoplay.background.bgcolor.border.capture.cellpadding.cellspacing.checked.cite.class.clear.color.cols.colspan.controls.controlslist.coords.crossorigin.datetime.decoding.default.dir.disabled.disablepictureinpicture.disableremoteplayback.download.draggable.enctype.enterkeyhint.exportparts.face.for.headers.height.hidden.high.href.hreflang.id.inert.inputmode.integrity.ismap.kind.label.lang.list.loading.loop.low.max.maxlength.media.method.min.minlength.multiple.muted.name.nonce.noshade.novalidate.nowrap.open.optimum.part.pattern.placeholder.playsinline.popover.popovertarget.popovertargetaction.poster.preload.pubdate.radiogroup.readonly.rel.required.rev.reversed.role.rows.rowspan.spellcheck.scope.selected.shape.size.sizes.slot.span.srclang.start.src.srcset.step.style.summary.tabindex.title.translate.type.usemap.valign.value.width.wrap.xmlns.slot".split(".")), Ee = m(/* @__PURE__ */ "accent-height.accumulate.additive.alignment-baseline.amplitude.ascent.attributename.attributetype.azimuth.basefrequency.baseline-shift.begin.bias.by.class.clip.clippathunits.clip-path.clip-rule.color.color-interpolation.color-interpolation-filters.color-profile.color-rendering.cx.cy.d.dx.dy.diffuseconstant.direction.display.divisor.dur.edgemode.elevation.end.exponent.fill.fill-opacity.fill-rule.filter.filterunits.flood-color.flood-opacity.font-family.font-size.font-size-adjust.font-stretch.font-style.font-variant.font-weight.fx.fy.g1.g2.glyph-name.glyphref.gradientunits.gradienttransform.height.href.id.image-rendering.in.in2.intercept.k.k1.k2.k3.k4.kerning.keypoints.keysplines.keytimes.lang.lengthadjust.letter-spacing.kernelmatrix.kernelunitlength.lighting-color.local.marker-end.marker-mid.marker-start.markerheight.markerunits.markerwidth.maskcontentunits.maskunits.max.mask.mask-type.media.method.mode.min.name.numoctaves.offset.operator.opacity.order.orient.orientation.origin.overflow.paint-order.path.pathlength.patterncontentunits.patterntransform.patternunits.points.preservealpha.preserveaspectratio.primitiveunits.r.rx.ry.radius.refx.refy.repeatcount.repeatdur.restart.result.rotate.scale.seed.shape-rendering.slope.specularconstant.specularexponent.spreadmethod.startoffset.stddeviation.stitchtiles.stop-color.stop-opacity.stroke-dasharray.stroke-dashoffset.stroke-linecap.stroke-linejoin.stroke-miterlimit.stroke-opacity.stroke.stroke-width.style.surfacescale.systemlanguage.tabindex.tablevalues.targetx.targety.transform.transform-origin.text-anchor.text-decoration.text-rendering.textlength.type.u1.u2.unicode.values.viewbox.visibility.version.vert-adv-y.vert-origin-x.vert-origin-y.width.word-spacing.wrap.writing-mode.xchannelselector.ychannelselector.x.x1.x2.xmlns.y.y1.y2.z.zoomandpan".split(".")), De = m(/* @__PURE__ */ "accent.accentunder.align.bevelled.close.columnalign.columnlines.columnspacing.columnspan.denomalign.depth.dir.display.displaystyle.encoding.fence.frame.height.href.id.largeop.length.linethickness.lquote.lspace.mathbackground.mathcolor.mathsize.mathvariant.maxsize.minsize.movablelimits.notation.numalign.open.rowalign.rowlines.rowspacing.rowspan.rspace.rquote.scriptlevel.scriptminsize.scriptsizemultiplier.selection.separator.separators.stretchy.subscriptshift.supscriptshift.symmetric.voffset.width.xmlns".split(".")), Oe = m([
|
|
160
|
+
"xlink:href",
|
|
161
|
+
"xml:id",
|
|
162
|
+
"xlink:title",
|
|
163
|
+
"xml:space",
|
|
164
|
+
"xmlns:xlink"
|
|
165
|
+
]), ke = h(/\{\{[\w\W]*|[\w\W]*\}\}/gm), Ae = h(/<%[\w\W]*|[\w\W]*%>/gm), je = h(/\$\{[\w\W]*/gm), Me = h(/^data-[\-\w.\u00B7-\uFFFF]+$/), Ne = h(/^aria-[\-\w]+$/), Pe = h(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i), w = h(/^(?:\w+script|data):/i), T = h(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g), Fe = h(/^html$/i), E = h(/^[a-z][.\w]*(-[.\w]+)+$/i), Ie = /* @__PURE__ */ Object.freeze({
|
|
166
|
+
__proto__: null,
|
|
167
|
+
ARIA_ATTR: Ne,
|
|
168
|
+
ATTR_WHITESPACE: T,
|
|
169
|
+
CUSTOM_ELEMENT: E,
|
|
170
|
+
DATA_ATTR: Me,
|
|
171
|
+
DOCTYPE_NAME: Fe,
|
|
172
|
+
ERB_EXPR: Ae,
|
|
173
|
+
IS_ALLOWED_URI: Pe,
|
|
174
|
+
IS_SCRIPT_OR_DATA: w,
|
|
175
|
+
MUSTACHE_EXPR: ke,
|
|
176
|
+
TMPLIT_EXPR: je
|
|
177
|
+
}), D = {
|
|
178
|
+
element: 1,
|
|
179
|
+
text: 3,
|
|
180
|
+
progressingInstruction: 7,
|
|
181
|
+
comment: 8,
|
|
182
|
+
document: 9
|
|
183
|
+
}, Le = function() {
|
|
184
|
+
return typeof window > "u" ? null : window;
|
|
185
|
+
}, Re = function(e, t) {
|
|
186
|
+
if (typeof e != "object" || typeof e.createPolicy != "function") return null;
|
|
187
|
+
let n = null, r = "data-tt-policy-suffix";
|
|
188
|
+
t && t.hasAttribute(r) && (n = t.getAttribute(r));
|
|
189
|
+
let i = "dompurify" + (n ? "#" + n : "");
|
|
190
|
+
try {
|
|
191
|
+
return e.createPolicy(i, {
|
|
192
|
+
createHTML(e) {
|
|
193
|
+
return e;
|
|
194
|
+
},
|
|
195
|
+
createScriptURL(e) {
|
|
196
|
+
return e;
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
} catch {
|
|
200
|
+
return console.warn("TrustedTypes policy " + i + " could not be created."), null;
|
|
201
|
+
}
|
|
202
|
+
}, ze = function() {
|
|
203
|
+
return {
|
|
204
|
+
afterSanitizeAttributes: [],
|
|
205
|
+
afterSanitizeElements: [],
|
|
206
|
+
afterSanitizeShadowDOM: [],
|
|
207
|
+
beforeSanitizeAttributes: [],
|
|
208
|
+
beforeSanitizeElements: [],
|
|
209
|
+
beforeSanitizeShadowDOM: [],
|
|
210
|
+
uponSanitizeAttribute: [],
|
|
211
|
+
uponSanitizeElement: [],
|
|
212
|
+
uponSanitizeShadowNode: []
|
|
213
|
+
};
|
|
214
|
+
};
|
|
215
|
+
function Be() {
|
|
216
|
+
let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : Le(), t = (e) => Be(e);
|
|
217
|
+
if (t.version = "3.4.0", t.removed = [], !e || !e.document || e.document.nodeType !== D.document || !e.Element) return t.isSupported = !1, t;
|
|
218
|
+
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: d, DOMParser: te, trustedTypes: f } = e, p = c.prototype, ne = _e(p, "cloneNode"), h = _e(p, "remove"), ie = _e(p, "nextSibling"), ae = _e(p, "childNodes"), y = _e(p, "parentNode");
|
|
219
|
+
if (typeof o == "function") {
|
|
220
|
+
let e = n.createElement("template");
|
|
221
|
+
e.content && e.content.ownerDocument && (n = e.content.ownerDocument);
|
|
222
|
+
}
|
|
223
|
+
let b, S = "", { implementation: ke, createNodeIterator: Ae, createDocumentFragment: je, getElementsByTagName: Me } = n, { importNode: Ne } = r, w = ze();
|
|
224
|
+
t.isSupported = typeof ee == "function" && typeof y == "function" && ke && ke.createHTMLDocument !== void 0;
|
|
225
|
+
let { MUSTACHE_EXPR: T, ERB_EXPR: E, TMPLIT_EXPR: Ve, DATA_ATTR: He, ARIA_ATTR: Ue, IS_SCRIPT_OR_DATA: We, ATTR_WHITESPACE: Ge, CUSTOM_ELEMENT: Ke } = Ie, { IS_ALLOWED_URI: qe } = Ie, O = null, Je = x({}, [
|
|
226
|
+
...ve,
|
|
227
|
+
...ye,
|
|
228
|
+
...be,
|
|
229
|
+
...Se,
|
|
230
|
+
...we
|
|
231
|
+
]), k = null, Ye = x({}, [
|
|
232
|
+
...Te,
|
|
233
|
+
...Ee,
|
|
234
|
+
...De,
|
|
235
|
+
...Oe
|
|
236
|
+
]), A = Object.seal(re(null, {
|
|
237
|
+
tagNameCheck: {
|
|
238
|
+
writable: !0,
|
|
239
|
+
configurable: !1,
|
|
240
|
+
enumerable: !0,
|
|
241
|
+
value: null
|
|
242
|
+
},
|
|
243
|
+
attributeNameCheck: {
|
|
244
|
+
writable: !0,
|
|
245
|
+
configurable: !1,
|
|
246
|
+
enumerable: !0,
|
|
247
|
+
value: null
|
|
248
|
+
},
|
|
249
|
+
allowCustomizedBuiltInElements: {
|
|
250
|
+
writable: !0,
|
|
251
|
+
configurable: !1,
|
|
252
|
+
enumerable: !0,
|
|
253
|
+
value: !1
|
|
254
|
+
}
|
|
255
|
+
})), j = null, M = null, N = Object.seal(re(null, {
|
|
256
|
+
tagCheck: {
|
|
257
|
+
writable: !0,
|
|
258
|
+
configurable: !1,
|
|
259
|
+
enumerable: !0,
|
|
260
|
+
value: null
|
|
261
|
+
},
|
|
262
|
+
attributeCheck: {
|
|
263
|
+
writable: !0,
|
|
264
|
+
configurable: !1,
|
|
265
|
+
enumerable: !0,
|
|
266
|
+
value: null
|
|
267
|
+
}
|
|
268
|
+
})), Xe = !0, Ze = !0, Qe = !1, $e = !0, P = !1, F = !0, I = !1, L = !1, R = !1, z = !1, B = !1, V = !1, et = !0, tt = !1, nt = !0, H = !1, U = {}, W = null, rt = x({}, [
|
|
269
|
+
"annotation-xml",
|
|
270
|
+
"audio",
|
|
271
|
+
"colgroup",
|
|
272
|
+
"desc",
|
|
273
|
+
"foreignobject",
|
|
274
|
+
"head",
|
|
275
|
+
"iframe",
|
|
276
|
+
"math",
|
|
277
|
+
"mi",
|
|
278
|
+
"mn",
|
|
279
|
+
"mo",
|
|
280
|
+
"ms",
|
|
281
|
+
"mtext",
|
|
282
|
+
"noembed",
|
|
283
|
+
"noframes",
|
|
284
|
+
"noscript",
|
|
285
|
+
"plaintext",
|
|
286
|
+
"script",
|
|
287
|
+
"style",
|
|
288
|
+
"svg",
|
|
289
|
+
"template",
|
|
290
|
+
"thead",
|
|
291
|
+
"title",
|
|
292
|
+
"video",
|
|
293
|
+
"xmp"
|
|
294
|
+
]), it = null, at = x({}, [
|
|
295
|
+
"audio",
|
|
296
|
+
"video",
|
|
297
|
+
"img",
|
|
298
|
+
"source",
|
|
299
|
+
"image",
|
|
300
|
+
"track"
|
|
301
|
+
]), ot = null, st = x({}, [
|
|
302
|
+
"alt",
|
|
303
|
+
"class",
|
|
304
|
+
"for",
|
|
305
|
+
"id",
|
|
306
|
+
"label",
|
|
307
|
+
"name",
|
|
308
|
+
"pattern",
|
|
309
|
+
"placeholder",
|
|
310
|
+
"role",
|
|
311
|
+
"summary",
|
|
312
|
+
"title",
|
|
313
|
+
"value",
|
|
314
|
+
"style",
|
|
315
|
+
"xmlns"
|
|
316
|
+
]), ct = "http://www.w3.org/1998/Math/MathML", G = "http://www.w3.org/2000/svg", K = "http://www.w3.org/1999/xhtml", q = K, lt = !1, ut = null, dt = x({}, [
|
|
317
|
+
ct,
|
|
318
|
+
G,
|
|
319
|
+
K
|
|
320
|
+
], fe), ft = x({}, [
|
|
321
|
+
"mi",
|
|
322
|
+
"mo",
|
|
323
|
+
"mn",
|
|
324
|
+
"ms",
|
|
325
|
+
"mtext"
|
|
326
|
+
]), J = x({}, ["annotation-xml"]), pt = x({}, [
|
|
327
|
+
"title",
|
|
328
|
+
"style",
|
|
329
|
+
"font",
|
|
330
|
+
"a",
|
|
331
|
+
"script"
|
|
332
|
+
]), mt = null, ht = ["application/xhtml+xml", "text/html"], Y = null, X = null, gt = n.createElement("form"), _t = function(e) {
|
|
333
|
+
return e instanceof RegExp || e instanceof Function;
|
|
334
|
+
}, vt = function() {
|
|
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 = C(e), mt = ht.indexOf(e.PARSER_MEDIA_TYPE) === -1 ? "text/html" : e.PARSER_MEDIA_TYPE, Y = mt === "application/xhtml+xml" ? fe : de, O = _(e, "ALLOWED_TAGS") ? x({}, e.ALLOWED_TAGS, Y) : Je, k = _(e, "ALLOWED_ATTR") ? x({}, e.ALLOWED_ATTR, Y) : Ye, ut = _(e, "ALLOWED_NAMESPACES") ? x({}, e.ALLOWED_NAMESPACES, fe) : dt, ot = _(e, "ADD_URI_SAFE_ATTR") ? x(C(st), e.ADD_URI_SAFE_ATTR, Y) : st, it = _(e, "ADD_DATA_URI_TAGS") ? x(C(at), e.ADD_DATA_URI_TAGS, Y) : at, W = _(e, "FORBID_CONTENTS") ? x({}, e.FORBID_CONTENTS, Y) : rt, j = _(e, "FORBID_TAGS") ? x({}, e.FORBID_TAGS, Y) : C({}), M = _(e, "FORBID_ATTR") ? x({}, e.FORBID_ATTR, Y) : C({}), U = _(e, "USE_PROFILES") ? e.USE_PROFILES : !1, Xe = e.ALLOW_ARIA_ATTR !== !1, Ze = e.ALLOW_DATA_ATTR !== !1, Qe = e.ALLOW_UNKNOWN_PROTOCOLS || !1, $e = e.ALLOW_SELF_CLOSE_IN_ATTR !== !1, P = e.SAFE_FOR_TEMPLATES || !1, F = e.SAFE_FOR_XML !== !1, I = e.WHOLE_DOCUMENT || !1, z = e.RETURN_DOM || !1, B = e.RETURN_DOM_FRAGMENT || !1, V = e.RETURN_TRUSTED_TYPE || !1, R = e.FORCE_BODY || !1, et = e.SANITIZE_DOM !== !1, tt = e.SANITIZE_NAMED_PROPS || !1, nt = e.KEEP_CONTENT !== !1, H = e.IN_PLACE || !1, qe = e.ALLOWED_URI_REGEXP || Pe, q = e.NAMESPACE || K, ft = e.MATHML_TEXT_INTEGRATION_POINTS || ft, J = e.HTML_INTEGRATION_POINTS || J, A = e.CUSTOM_ELEMENT_HANDLING || re(null), e.CUSTOM_ELEMENT_HANDLING && _t(e.CUSTOM_ELEMENT_HANDLING.tagNameCheck) && (A.tagNameCheck = e.CUSTOM_ELEMENT_HANDLING.tagNameCheck), e.CUSTOM_ELEMENT_HANDLING && _t(e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck) && (A.attributeNameCheck = e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck), e.CUSTOM_ELEMENT_HANDLING && typeof e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements == "boolean" && (A.allowCustomizedBuiltInElements = e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements), P && (Ze = !1), B && (z = !0), U && (O = x({}, we), k = re(null), U.html === !0 && (x(O, ve), x(k, Te)), U.svg === !0 && (x(O, ye), x(k, Ee), x(k, Oe)), U.svgFilters === !0 && (x(O, be), x(k, Ee), x(k, Oe)), U.mathMl === !0 && (x(O, Se), x(k, De), x(k, Oe))), N.tagCheck = null, N.attributeCheck = null, e.ADD_TAGS && (typeof e.ADD_TAGS == "function" ? N.tagCheck = e.ADD_TAGS : (O === Je && (O = C(O)), x(O, e.ADD_TAGS, Y))), e.ADD_ATTR && (typeof e.ADD_ATTR == "function" ? N.attributeCheck = e.ADD_ATTR : (k === Ye && (k = C(k)), x(k, e.ADD_ATTR, Y))), e.ADD_URI_SAFE_ATTR && x(ot, e.ADD_URI_SAFE_ATTR, Y), e.FORBID_CONTENTS && (W === rt && (W = C(W)), x(W, e.FORBID_CONTENTS, Y)), e.ADD_FORBID_CONTENTS && (W === rt && (W = C(W)), x(W, e.ADD_FORBID_CONTENTS, Y)), nt && (O["#text"] = !0), I && x(O, [
|
|
338
|
+
"html",
|
|
339
|
+
"head",
|
|
340
|
+
"body"
|
|
341
|
+
]), O.table && (x(O, ["tbody"]), delete j.tbody), e.TRUSTED_TYPES_POLICY) {
|
|
342
|
+
if (typeof e.TRUSTED_TYPES_POLICY.createHTML != "function") throw ge("TRUSTED_TYPES_POLICY configuration option must provide a \"createHTML\" hook.");
|
|
343
|
+
if (typeof e.TRUSTED_TYPES_POLICY.createScriptURL != "function") throw ge("TRUSTED_TYPES_POLICY configuration option must provide a \"createScriptURL\" hook.");
|
|
344
|
+
b = e.TRUSTED_TYPES_POLICY, S = b.createHTML("");
|
|
345
|
+
} else b === void 0 && (b = Re(f, i)), b !== null && typeof S == "string" && (S = b.createHTML(""));
|
|
346
|
+
m && m(e), X = e;
|
|
347
|
+
}
|
|
348
|
+
}, yt = x({}, [
|
|
349
|
+
...ye,
|
|
350
|
+
...be,
|
|
351
|
+
...xe
|
|
352
|
+
]), bt = x({}, [...Se, ...Ce]), xt = function(e) {
|
|
353
|
+
let t = y(e);
|
|
354
|
+
(!t || !t.tagName) && (t = {
|
|
355
|
+
namespaceURI: q,
|
|
356
|
+
tagName: "template"
|
|
357
|
+
});
|
|
358
|
+
let n = de(e.tagName), r = de(t.tagName);
|
|
359
|
+
return ut[e.namespaceURI] ? e.namespaceURI === G ? t.namespaceURI === K ? n === "svg" : t.namespaceURI === ct ? n === "svg" && (r === "annotation-xml" || ft[r]) : !!yt[n] : e.namespaceURI === ct ? t.namespaceURI === K ? n === "math" : t.namespaceURI === G ? n === "math" && J[r] : !!bt[n] : e.namespaceURI === K ? t.namespaceURI === G && !J[r] || t.namespaceURI === ct && !ft[r] ? !1 : !bt[n] && (pt[n] || !yt[n]) : !!(mt === "application/xhtml+xml" && ut[e.namespaceURI]) : !1;
|
|
360
|
+
}, Z = function(e) {
|
|
361
|
+
le(t.removed, { element: e });
|
|
362
|
+
try {
|
|
363
|
+
y(e).removeChild(e);
|
|
364
|
+
} catch {
|
|
365
|
+
h(e);
|
|
366
|
+
}
|
|
367
|
+
}, Q = function(e, n) {
|
|
368
|
+
try {
|
|
369
|
+
le(t.removed, {
|
|
370
|
+
attribute: n.getAttributeNode(e),
|
|
371
|
+
from: n
|
|
372
|
+
});
|
|
373
|
+
} catch {
|
|
374
|
+
le(t.removed, {
|
|
375
|
+
attribute: null,
|
|
376
|
+
from: n
|
|
377
|
+
});
|
|
378
|
+
}
|
|
379
|
+
if (n.removeAttribute(e), e === "is") if (z || B) try {
|
|
380
|
+
Z(n);
|
|
381
|
+
} catch {}
|
|
382
|
+
else try {
|
|
383
|
+
n.setAttribute(e, "");
|
|
384
|
+
} catch {}
|
|
385
|
+
}, St = function(e) {
|
|
386
|
+
let t = null, r = null;
|
|
387
|
+
if (R) e = "<remove></remove>" + e;
|
|
388
|
+
else {
|
|
389
|
+
let t = pe(e, /^[\r\n\t ]+/);
|
|
390
|
+
r = t && t[0];
|
|
391
|
+
}
|
|
392
|
+
mt === "application/xhtml+xml" && q === K && (e = "<html xmlns=\"http://www.w3.org/1999/xhtml\"><head></head><body>" + e + "</body></html>");
|
|
393
|
+
let i = b ? b.createHTML(e) : e;
|
|
394
|
+
if (q === K) try {
|
|
395
|
+
t = new te().parseFromString(i, mt);
|
|
396
|
+
} catch {}
|
|
397
|
+
if (!t || !t.documentElement) {
|
|
398
|
+
t = ke.createDocument(q, "template", null);
|
|
399
|
+
try {
|
|
400
|
+
t.documentElement.innerHTML = lt ? S : i;
|
|
401
|
+
} catch {}
|
|
402
|
+
}
|
|
403
|
+
let a = t.body || t.documentElement;
|
|
404
|
+
return e && r && a.insertBefore(n.createTextNode(r), a.childNodes[0] || null), q === K ? Me.call(t, I ? "html" : "body")[0] : I ? t.documentElement : a;
|
|
405
|
+
}, Ct = function(e) {
|
|
406
|
+
return Ae.call(e.ownerDocument || e, e, l.SHOW_ELEMENT | l.SHOW_COMMENT | l.SHOW_TEXT | l.SHOW_PROCESSING_INSTRUCTION | l.SHOW_CDATA_SECTION, null);
|
|
407
|
+
}, wt = function(e) {
|
|
408
|
+
return e instanceof d && (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");
|
|
409
|
+
}, Tt = function(e) {
|
|
410
|
+
return typeof s == "function" && e instanceof s;
|
|
411
|
+
};
|
|
412
|
+
function $(e, n, r) {
|
|
413
|
+
oe(e, (e) => {
|
|
414
|
+
e.call(t, n, r, X);
|
|
415
|
+
});
|
|
416
|
+
}
|
|
417
|
+
let Et = function(e) {
|
|
418
|
+
let n = null;
|
|
419
|
+
if ($(w.beforeSanitizeElements, e, null), wt(e)) return Z(e), !0;
|
|
420
|
+
let r = Y(e.nodeName);
|
|
421
|
+
if ($(w.uponSanitizeElement, e, {
|
|
422
|
+
tagName: r,
|
|
423
|
+
allowedTags: O
|
|
424
|
+
}), F && e.hasChildNodes() && !Tt(e.firstElementChild) && v(/<[/\w!]/g, e.innerHTML) && v(/<[/\w!]/g, e.textContent) || F && e.namespaceURI === K && r === "style" && Tt(e.firstElementChild) || e.nodeType === D.progressingInstruction || F && e.nodeType === D.comment && v(/<[/\w]/g, e.data)) return Z(e), !0;
|
|
425
|
+
if (j[r] || !(N.tagCheck instanceof Function && N.tagCheck(r)) && !O[r]) {
|
|
426
|
+
if (!j[r] && Ot(r) && (A.tagNameCheck instanceof RegExp && v(A.tagNameCheck, r) || A.tagNameCheck instanceof Function && A.tagNameCheck(r))) return !1;
|
|
427
|
+
if (nt && !W[r]) {
|
|
428
|
+
let t = y(e) || e.parentNode, n = ae(e) || e.childNodes;
|
|
429
|
+
if (n && t) {
|
|
430
|
+
let r = n.length;
|
|
431
|
+
for (let i = r - 1; i >= 0; --i) {
|
|
432
|
+
let r = ne(n[i], !0);
|
|
433
|
+
r.__removalCount = (e.__removalCount || 0) + 1, t.insertBefore(r, ie(e));
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
return Z(e), !0;
|
|
438
|
+
}
|
|
439
|
+
return e instanceof c && !xt(e) || (r === "noscript" || r === "noembed" || r === "noframes") && v(/<\/no(script|embed|frames)/i, e.innerHTML) ? (Z(e), !0) : (P && e.nodeType === D.text && (n = e.textContent, oe([
|
|
440
|
+
T,
|
|
441
|
+
E,
|
|
442
|
+
Ve
|
|
443
|
+
], (e) => {
|
|
444
|
+
n = g(n, e, " ");
|
|
445
|
+
}), e.textContent !== n && (le(t.removed, { element: e.cloneNode() }), e.textContent = n)), $(w.afterSanitizeElements, e, null), !1);
|
|
446
|
+
}, Dt = function(e, t, r) {
|
|
447
|
+
if (M[t] || et && (t === "id" || t === "name") && (r in n || r in gt)) return !1;
|
|
448
|
+
if (!(Ze && !M[t] && v(He, t)) && !(Xe && v(Ue, t)) && !(N.attributeCheck instanceof Function && N.attributeCheck(t, e))) {
|
|
449
|
+
if (!k[t] || M[t]) {
|
|
450
|
+
if (!(Ot(e) && (A.tagNameCheck instanceof RegExp && v(A.tagNameCheck, e) || A.tagNameCheck instanceof Function && A.tagNameCheck(e)) && (A.attributeNameCheck instanceof RegExp && v(A.attributeNameCheck, t) || A.attributeNameCheck instanceof Function && A.attributeNameCheck(t, e)) || t === "is" && A.allowCustomizedBuiltInElements && (A.tagNameCheck instanceof RegExp && v(A.tagNameCheck, r) || A.tagNameCheck instanceof Function && A.tagNameCheck(r)))) return !1;
|
|
451
|
+
} else if (!ot[t] && !v(qe, g(r, Ge, "")) && !((t === "src" || t === "xlink:href" || t === "href") && e !== "script" && me(r, "data:") === 0 && it[e]) && !(Qe && !v(We, g(r, Ge, ""))) && r) return !1;
|
|
452
|
+
}
|
|
453
|
+
return !0;
|
|
454
|
+
}, Ot = function(e) {
|
|
455
|
+
return e !== "annotation-xml" && pe(e, Ke);
|
|
456
|
+
}, kt = function(e) {
|
|
457
|
+
$(w.beforeSanitizeAttributes, e, null);
|
|
458
|
+
let { attributes: n } = e;
|
|
459
|
+
if (!n || wt(e)) return;
|
|
460
|
+
let r = {
|
|
461
|
+
attrName: "",
|
|
462
|
+
attrValue: "",
|
|
463
|
+
keepAttr: !0,
|
|
464
|
+
allowedAttributes: k,
|
|
465
|
+
forceKeepAttr: void 0
|
|
466
|
+
}, i = n.length;
|
|
467
|
+
for (; i--;) {
|
|
468
|
+
let { name: a, namespaceURI: o, value: s } = n[i], c = Y(a), l = s, u = a === "value" ? l : he(l);
|
|
469
|
+
if (r.attrName = c, r.attrValue = u, r.keepAttr = !0, r.forceKeepAttr = void 0, $(w.uponSanitizeAttribute, e, r), u = r.attrValue, tt && (c === "id" || c === "name") && (Q(a, e), u = "user-content-" + u), F && v(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i, u)) {
|
|
470
|
+
Q(a, e);
|
|
471
|
+
continue;
|
|
472
|
+
}
|
|
473
|
+
if (c === "attributename" && pe(u, "href")) {
|
|
474
|
+
Q(a, e);
|
|
475
|
+
continue;
|
|
476
|
+
}
|
|
477
|
+
if (r.forceKeepAttr) continue;
|
|
478
|
+
if (!r.keepAttr) {
|
|
479
|
+
Q(a, e);
|
|
480
|
+
continue;
|
|
481
|
+
}
|
|
482
|
+
if (!$e && v(/\/>/i, u)) {
|
|
483
|
+
Q(a, e);
|
|
484
|
+
continue;
|
|
485
|
+
}
|
|
486
|
+
P && oe([
|
|
487
|
+
T,
|
|
488
|
+
E,
|
|
489
|
+
Ve
|
|
490
|
+
], (e) => {
|
|
491
|
+
u = g(u, e, " ");
|
|
492
|
+
});
|
|
493
|
+
let d = Y(e.nodeName);
|
|
494
|
+
if (!Dt(d, c, u)) {
|
|
495
|
+
Q(a, e);
|
|
496
|
+
continue;
|
|
497
|
+
}
|
|
498
|
+
if (b && typeof f == "object" && typeof f.getAttributeType == "function" && !o) switch (f.getAttributeType(d, c)) {
|
|
499
|
+
case "TrustedHTML":
|
|
500
|
+
u = b.createHTML(u);
|
|
501
|
+
break;
|
|
502
|
+
case "TrustedScriptURL":
|
|
503
|
+
u = b.createScriptURL(u);
|
|
504
|
+
break;
|
|
505
|
+
}
|
|
506
|
+
if (u !== l) try {
|
|
507
|
+
o ? e.setAttributeNS(o, a, u) : e.setAttribute(a, u), wt(e) ? Z(e) : ce(t.removed);
|
|
508
|
+
} catch {
|
|
509
|
+
Q(a, e);
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
$(w.afterSanitizeAttributes, e, null);
|
|
513
|
+
}, At = function(e) {
|
|
514
|
+
let t = null, n = Ct(e);
|
|
515
|
+
for ($(w.beforeSanitizeShadowDOM, e, null); t = n.nextNode();) $(w.uponSanitizeShadowNode, t, null), Et(t), kt(t), t.content instanceof a && At(t.content);
|
|
516
|
+
$(w.afterSanitizeShadowDOM, e, null);
|
|
517
|
+
};
|
|
518
|
+
return t.sanitize = function(e) {
|
|
519
|
+
let n = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, i = null, o = null, c = null, l = null;
|
|
520
|
+
if (lt = !e, lt && (e = "<!-->"), typeof e != "string" && !Tt(e)) if (typeof e.toString == "function") {
|
|
521
|
+
if (e = e.toString(), typeof e != "string") throw ge("dirty is not a string, aborting");
|
|
522
|
+
} else throw ge("toString is not a function");
|
|
523
|
+
if (!t.isSupported) return e;
|
|
524
|
+
if (L || vt(n), t.removed = [], typeof e == "string" && (H = !1), H) {
|
|
525
|
+
if (e.nodeName) {
|
|
526
|
+
let t = Y(e.nodeName);
|
|
527
|
+
if (!O[t] || j[t]) throw ge("root node is forbidden and cannot be sanitized in-place");
|
|
528
|
+
}
|
|
529
|
+
} else if (e instanceof s) i = St("<!---->"), o = i.ownerDocument.importNode(e, !0), o.nodeType === D.element && o.nodeName === "BODY" || o.nodeName === "HTML" ? i = o : i.appendChild(o);
|
|
530
|
+
else {
|
|
531
|
+
if (!z && !P && !I && e.indexOf("<") === -1) return b && V ? b.createHTML(e) : e;
|
|
532
|
+
if (i = St(e), !i) return z ? null : V ? S : "";
|
|
533
|
+
}
|
|
534
|
+
i && R && Z(i.firstChild);
|
|
535
|
+
let u = Ct(H ? e : i);
|
|
536
|
+
for (; c = u.nextNode();) Et(c), kt(c), c.content instanceof a && At(c.content);
|
|
537
|
+
if (H) return e;
|
|
538
|
+
if (z) {
|
|
539
|
+
if (P) {
|
|
540
|
+
i.normalize();
|
|
541
|
+
let e = i.innerHTML;
|
|
542
|
+
oe([
|
|
543
|
+
T,
|
|
544
|
+
E,
|
|
545
|
+
Ve
|
|
546
|
+
], (t) => {
|
|
547
|
+
e = g(e, t, " ");
|
|
548
|
+
}), i.innerHTML = e;
|
|
549
|
+
}
|
|
550
|
+
if (B) for (l = je.call(i.ownerDocument); i.firstChild;) l.appendChild(i.firstChild);
|
|
551
|
+
else l = i;
|
|
552
|
+
return (k.shadowroot || k.shadowrootmode) && (l = Ne.call(r, l, !0)), l;
|
|
553
|
+
}
|
|
554
|
+
let d = I ? i.outerHTML : i.innerHTML;
|
|
555
|
+
return I && O["!doctype"] && i.ownerDocument && i.ownerDocument.doctype && i.ownerDocument.doctype.name && v(Fe, i.ownerDocument.doctype.name) && (d = "<!DOCTYPE " + i.ownerDocument.doctype.name + ">\n" + d), P && oe([
|
|
556
|
+
T,
|
|
557
|
+
E,
|
|
558
|
+
Ve
|
|
559
|
+
], (e) => {
|
|
560
|
+
d = g(d, e, " ");
|
|
561
|
+
}), b && V ? b.createHTML(d) : d;
|
|
562
|
+
}, t.setConfig = function() {
|
|
563
|
+
vt(arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}), L = !0;
|
|
564
|
+
}, t.clearConfig = function() {
|
|
565
|
+
X = null, L = !1;
|
|
566
|
+
}, t.isValidAttribute = function(e, t, n) {
|
|
567
|
+
return X || vt({}), Dt(Y(e), Y(t), n);
|
|
568
|
+
}, t.addHook = function(e, t) {
|
|
569
|
+
typeof t == "function" && le(w[e], t);
|
|
570
|
+
}, t.removeHook = function(e, t) {
|
|
571
|
+
if (t !== void 0) {
|
|
572
|
+
let n = se(w[e], t);
|
|
573
|
+
return n === -1 ? void 0 : ue(w[e], n, 1)[0];
|
|
574
|
+
}
|
|
575
|
+
return ce(w[e]);
|
|
576
|
+
}, t.removeHooks = function(e) {
|
|
577
|
+
w[e] = [];
|
|
578
|
+
}, t.removeAllHooks = function() {
|
|
579
|
+
w = ze();
|
|
580
|
+
}, t;
|
|
581
|
+
}
|
|
582
|
+
var Ve = Be();
|
|
583
|
+
//#endregion
|
|
584
|
+
//#region src/components/ai-chat/ai-chat-request.ts
|
|
585
|
+
function He(e, t) {
|
|
586
|
+
return `${e.replace(/\/+$/, "")}/${t.replace(/^\/+|\/+$/g, "")}/aiprompt`;
|
|
587
|
+
}
|
|
588
|
+
function Ue(e) {
|
|
589
|
+
return e.type === "placeholder" ? null : {
|
|
590
|
+
...e,
|
|
591
|
+
version: e.version || "",
|
|
592
|
+
title: e.title || e.options?.title,
|
|
593
|
+
filters: e.filterGroups || [],
|
|
594
|
+
aichartId: e.aichartId || ""
|
|
595
|
+
};
|
|
596
|
+
}
|
|
597
|
+
function We(e, t) {
|
|
598
|
+
return [{
|
|
599
|
+
type: "text",
|
|
600
|
+
text: e
|
|
601
|
+
}, ...t.map((e) => ({
|
|
602
|
+
type: "dataset",
|
|
603
|
+
id: e
|
|
604
|
+
}))];
|
|
605
|
+
}
|
|
606
|
+
function Ge(e, t, n) {
|
|
607
|
+
return {
|
|
608
|
+
agent: e,
|
|
609
|
+
task: t,
|
|
610
|
+
stream: n.stream ?? !0,
|
|
611
|
+
response_mode: "mixed",
|
|
612
|
+
...n.conversationId ? { conversation_id: n.conversationId } : {},
|
|
613
|
+
...n.localeId ? { locale_id: n.localeId } : {}
|
|
614
|
+
};
|
|
615
|
+
}
|
|
616
|
+
function Ke(e) {
|
|
617
|
+
let t = We(e.prompt, e.datasetIds), n = e.chart ? Ue(e.chart) : null;
|
|
618
|
+
return n && t.push({
|
|
619
|
+
type: "item",
|
|
620
|
+
value: n
|
|
621
|
+
}), {
|
|
622
|
+
...Ge("item", e.task ?? "generate", e),
|
|
623
|
+
input: t
|
|
624
|
+
};
|
|
625
|
+
}
|
|
626
|
+
function qe(e) {
|
|
627
|
+
let t = We(e.prompt, e.datasetIds);
|
|
628
|
+
return e.dashboard && t.push({
|
|
629
|
+
type: "dashboard",
|
|
630
|
+
value: e.dashboard,
|
|
631
|
+
...e.currentScreenMode ? { current_screen_mode: e.currentScreenMode } : {}
|
|
632
|
+
}), {
|
|
633
|
+
...Ge("dashboard", "generate", e),
|
|
634
|
+
timezone_id: e.timezoneId ?? "UTC",
|
|
635
|
+
input: t
|
|
636
|
+
};
|
|
637
|
+
}
|
|
638
|
+
function O(e) {
|
|
639
|
+
return {
|
|
640
|
+
...Ge("analyst", "generate", e),
|
|
641
|
+
input: We(e.prompt, e.datasetIds)
|
|
642
|
+
};
|
|
643
|
+
}
|
|
644
|
+
function Je(e, t) {
|
|
645
|
+
switch (e) {
|
|
646
|
+
case "dashboard": return qe(t);
|
|
647
|
+
case "analyst": return O(t);
|
|
648
|
+
default: return Ke(t);
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
function k(e, t) {
|
|
652
|
+
let { authKey: n, authToken: r, apiVersion: i = "0.1.0" } = t;
|
|
653
|
+
return {
|
|
654
|
+
key: n,
|
|
655
|
+
token: r,
|
|
656
|
+
action: "create",
|
|
657
|
+
version: i,
|
|
658
|
+
properties: Je(e, t)
|
|
659
|
+
};
|
|
660
|
+
}
|
|
661
|
+
function Ye(e, t, n, r = "0.1.0", i = null) {
|
|
662
|
+
return {
|
|
663
|
+
key: t,
|
|
664
|
+
token: n,
|
|
665
|
+
action: "delete",
|
|
666
|
+
version: r,
|
|
667
|
+
properties: {
|
|
668
|
+
agent: "item",
|
|
669
|
+
restore_to_message_id: e,
|
|
670
|
+
...i ? { conversation_id: i } : {}
|
|
671
|
+
}
|
|
672
|
+
};
|
|
673
|
+
}
|
|
674
|
+
//#endregion
|
|
675
|
+
//#region src/components/ai-chat/stream/ai-chat-streaming.ts
|
|
676
|
+
function A() {
|
|
677
|
+
return {
|
|
678
|
+
id: "root",
|
|
679
|
+
step: "root",
|
|
680
|
+
status: "pending",
|
|
681
|
+
children: [{
|
|
682
|
+
id: "client-init",
|
|
683
|
+
step: "iqInit",
|
|
684
|
+
status: "inProgress",
|
|
685
|
+
description: "Thinking"
|
|
686
|
+
}]
|
|
687
|
+
};
|
|
688
|
+
}
|
|
689
|
+
function j(e) {
|
|
690
|
+
let t = e.progress;
|
|
691
|
+
return typeof t != "object" || !t ? !1 : "id" in t && "step" in t && "status" in t;
|
|
692
|
+
}
|
|
693
|
+
async function M(e) {
|
|
694
|
+
let t = await fetch(e.url, {
|
|
695
|
+
method: "POST",
|
|
696
|
+
headers: { "Content-Type": "application/json" },
|
|
697
|
+
mode: "cors",
|
|
698
|
+
body: JSON.stringify(e.body),
|
|
699
|
+
signal: e.signal
|
|
700
|
+
});
|
|
701
|
+
if (!t.ok) {
|
|
702
|
+
let e = await t.json().catch(() => null);
|
|
703
|
+
throw Error(e?.message || `API request failed with status ${t.status}`);
|
|
704
|
+
}
|
|
705
|
+
if (!t.body) throw Error("Response body is not readable");
|
|
706
|
+
return {
|
|
707
|
+
body: t.body,
|
|
708
|
+
conversationId: t.headers.get("x-conversation-id")
|
|
709
|
+
};
|
|
710
|
+
}
|
|
711
|
+
function N(e) {
|
|
712
|
+
let t = e.trim();
|
|
713
|
+
if (!t || t.startsWith(":") || t.startsWith("event:") || t.startsWith("id:")) return null;
|
|
714
|
+
let n = t;
|
|
715
|
+
return n.startsWith("data:") && (n = n.slice(5).trimStart()), !n || n === "[DONE]" ? null : JSON.parse(n);
|
|
716
|
+
}
|
|
717
|
+
function Xe(e, t) {
|
|
718
|
+
try {
|
|
719
|
+
let n = N(e);
|
|
720
|
+
n && t(n);
|
|
721
|
+
} catch {
|
|
722
|
+
console.error("Failed to parse stream line");
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
async function Ze(e, t) {
|
|
726
|
+
let n = e.getReader(), r = new TextDecoder(), i = "";
|
|
727
|
+
try {
|
|
728
|
+
for (;;) {
|
|
729
|
+
let { done: e, value: a } = await n.read();
|
|
730
|
+
if (e) break;
|
|
731
|
+
i += r.decode(a, { stream: !0 });
|
|
732
|
+
let o = i.split(/\r?\n/);
|
|
733
|
+
i = o.pop() ?? "";
|
|
734
|
+
for (let e of o) Xe(e, t);
|
|
735
|
+
}
|
|
736
|
+
i += r.decode();
|
|
737
|
+
let e = i.trim();
|
|
738
|
+
e && Xe(e, t);
|
|
739
|
+
} finally {
|
|
740
|
+
n.releaseLock();
|
|
741
|
+
}
|
|
742
|
+
}
|
|
743
|
+
//#endregion
|
|
744
|
+
//#region src/components/ai-chat/stream/shared.ts
|
|
745
|
+
function Qe(e) {
|
|
746
|
+
if (!e || typeof e != "object") return "";
|
|
747
|
+
let t = e.assistant_message;
|
|
748
|
+
if (!t || typeof t != "object") return "";
|
|
749
|
+
if (typeof t.message == "string") return t.message;
|
|
750
|
+
if (typeof t.text == "string") return t.text;
|
|
751
|
+
if (typeof t.summary == "string") return t.summary;
|
|
752
|
+
let n = t.content;
|
|
753
|
+
return typeof n == "string" ? n : n && typeof n == "object" && typeof n.text == "string" ? n.text : "";
|
|
754
|
+
}
|
|
755
|
+
function $e(e) {
|
|
756
|
+
return typeof e.text_delta == "string" ? e.text_delta : typeof e.chunk == "string" ? e.chunk : typeof e.message == "string" ? e.message : typeof e.summary == "string" ? e.summary : "";
|
|
757
|
+
}
|
|
758
|
+
function P(e) {
|
|
759
|
+
return $e(e) || Qe(e.result);
|
|
760
|
+
}
|
|
761
|
+
function F(e) {
|
|
762
|
+
return !!e.done || e.type === "finish" || e.type === "done" || "question" in e;
|
|
763
|
+
}
|
|
764
|
+
function I(e, t) {
|
|
765
|
+
let n = typeof e.conversation_id == "string" && e.conversation_id || typeof e.conversationId == "string" && e.conversationId;
|
|
766
|
+
n && t.callbacks.onConversationIdChange(n);
|
|
767
|
+
}
|
|
768
|
+
function L(e, t) {
|
|
769
|
+
return j(e) ? (t.callbacks.onProgress(e.progress), !0) : !1;
|
|
770
|
+
}
|
|
771
|
+
function R(e, t) {
|
|
772
|
+
if (!(e.error || e.type === "error" || typeof e.error_text == "string")) return !1;
|
|
773
|
+
let r = typeof e.error_text == "string" && e.error_text || typeof e.error == "string" && e.error || n("Something went wrong. Please try again.", { desc: "Generic error message shown in ai chat when the API request fails" });
|
|
774
|
+
return t.aiMessage.message = r, t.aiMessage.isError = !0, t.callbacks.onMessageUpdate(t.aiMessage), t.callbacks.onProgressCollapsed(!0), t.callbacks.dispatchResponseReceived(t.aiMessage, !0), !0;
|
|
775
|
+
}
|
|
776
|
+
function z(e, t) {
|
|
777
|
+
t && (e.state.progressCollapsed || (e.state.progressCollapsed = !0, e.callbacks.onProgressCollapsed(!0)), e.aiMessage.message = (e.aiMessage.message || "") + t, e.callbacks.onMessageUpdate(e.aiMessage));
|
|
778
|
+
}
|
|
779
|
+
function B(e, t, n = !1) {
|
|
780
|
+
t && (e.state.progressCollapsed = !0, e.callbacks.onProgressCollapsed(!0)), (n || t && e.aiMessage.message) && e.callbacks.dispatchResponseReceived(e.aiMessage, t);
|
|
781
|
+
}
|
|
782
|
+
function V(e) {
|
|
783
|
+
for (let t of e) if (t && typeof t == "object" && t.type === "item") {
|
|
784
|
+
let e = t.value;
|
|
785
|
+
if (e && typeof e == "object") return e;
|
|
786
|
+
}
|
|
787
|
+
return null;
|
|
788
|
+
}
|
|
789
|
+
function et(e) {
|
|
790
|
+
let t = e.chart ?? e.generatedChart;
|
|
791
|
+
if (t && typeof t == "object") return t;
|
|
792
|
+
let n = e.aiMessageAssets ?? e.ai_message_assets;
|
|
793
|
+
if (Array.isArray(n)) {
|
|
794
|
+
let e = V(n);
|
|
795
|
+
if (e) return e;
|
|
796
|
+
}
|
|
797
|
+
let r = e.result;
|
|
798
|
+
if (r && typeof r == "object") {
|
|
799
|
+
let e = r.assistant_message, t = e?.aiMessageAssets ?? e?.ai_message_assets;
|
|
800
|
+
if (Array.isArray(t)) return V(t);
|
|
801
|
+
}
|
|
802
|
+
return null;
|
|
803
|
+
}
|
|
804
|
+
//#endregion
|
|
805
|
+
//#region src/components/ai-chat/stream/analyst-handler.ts
|
|
806
|
+
function tt(e, t) {
|
|
807
|
+
if (I(e, t), L(e, t) || R(e, t)) return;
|
|
808
|
+
let n = P(e);
|
|
809
|
+
n && z(t, n), B(t, F(e), !!n);
|
|
810
|
+
}
|
|
811
|
+
//#endregion
|
|
812
|
+
//#region src/components/ai-chat/stream/dashboard-handler.ts
|
|
813
|
+
function nt(e) {
|
|
814
|
+
for (let t of e) if (t && typeof t == "object" && t.type === "dashboard") {
|
|
815
|
+
let e = t.value;
|
|
816
|
+
if (e && typeof e == "object" && Array.isArray(e.views)) return e;
|
|
817
|
+
}
|
|
818
|
+
return null;
|
|
819
|
+
}
|
|
820
|
+
function H(e) {
|
|
821
|
+
for (let t of e) if (t && typeof t == "object" && t.type === "dashboard") {
|
|
822
|
+
let e = t.name;
|
|
823
|
+
if (e && typeof e == "object") return e;
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
function U(e) {
|
|
827
|
+
if (e.views && Array.isArray(e.views)) return e;
|
|
828
|
+
let t = e.aiMessageAssets ?? e.ai_message_assets;
|
|
829
|
+
if (Array.isArray(t)) return nt(t);
|
|
830
|
+
let n = e.result;
|
|
831
|
+
if (n && typeof n == "object") {
|
|
832
|
+
let e = n.assistant_message, t = e?.aiMessageAssets ?? e?.ai_message_assets;
|
|
833
|
+
if (Array.isArray(t)) return nt(t);
|
|
834
|
+
}
|
|
835
|
+
return null;
|
|
836
|
+
}
|
|
837
|
+
function W(...e) {
|
|
838
|
+
return e.find(Array.isArray);
|
|
839
|
+
}
|
|
840
|
+
function rt(e, t) {
|
|
841
|
+
if (e.asset_type !== "dashboard") return;
|
|
842
|
+
let n = e.asset_delta ?? e.delta;
|
|
843
|
+
if (n && typeof n == "object") {
|
|
844
|
+
let e = n;
|
|
845
|
+
t.state.dashboardSnapshot = {
|
|
846
|
+
...t.state.dashboardSnapshot ?? { views: [] },
|
|
847
|
+
...e,
|
|
848
|
+
views: e.views ?? t.state.dashboardSnapshot?.views ?? []
|
|
849
|
+
};
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
function it(e, t, n) {
|
|
853
|
+
e.callbacks.dispatchDashboardGenerated({
|
|
854
|
+
dashboard: t,
|
|
855
|
+
conversationId: e.callbacks.getConversationId(),
|
|
856
|
+
...n ? { name: n } : {}
|
|
857
|
+
});
|
|
858
|
+
}
|
|
859
|
+
function at(e, t) {
|
|
860
|
+
if (I(e, t), L(e, t) || R(e, t)) return;
|
|
861
|
+
if (e.type === "interrupt") {
|
|
862
|
+
let n = typeof e.question == "string" && e.question || typeof e.text == "string" && e.text || null;
|
|
863
|
+
n && (t.state.interruptQuestion = n, z(t, n));
|
|
864
|
+
return;
|
|
865
|
+
}
|
|
866
|
+
if (e.type === "asset_start" && e.asset_type === "dashboard") {
|
|
867
|
+
t.state.dashboardSnapshot = { views: [] };
|
|
868
|
+
return;
|
|
869
|
+
}
|
|
870
|
+
if (e.type === "asset_delta") {
|
|
871
|
+
rt(e, t);
|
|
872
|
+
return;
|
|
873
|
+
}
|
|
874
|
+
let n = P(e);
|
|
875
|
+
n && z(t, n);
|
|
876
|
+
let r = U(e);
|
|
877
|
+
if (r) {
|
|
878
|
+
t.state.dashboardSnapshot = r;
|
|
879
|
+
let n = r.aiMessageAssets ?? r.ai_message_assets, i = e.aiMessageAssets ?? e.ai_message_assets, a = e.result?.assistant_message, o = W(n, i, a?.aiMessageAssets ?? a?.ai_message_assets), s = o ? H(o) : void 0;
|
|
880
|
+
s && (t.state.dashboardName = s);
|
|
881
|
+
}
|
|
882
|
+
let i = F(e);
|
|
883
|
+
i && t.state.dashboardSnapshot && it(t, t.state.dashboardSnapshot, t.state.dashboardName), B(t, i, !!n);
|
|
884
|
+
}
|
|
885
|
+
//#endregion
|
|
886
|
+
//#region src/components/ai-chat/stream/item-handler.ts
|
|
887
|
+
function ot(e, t) {
|
|
888
|
+
let n = e.asset_type;
|
|
889
|
+
if (n && n !== "item") return;
|
|
890
|
+
let r = e.asset_delta ?? e.delta;
|
|
891
|
+
r && typeof r == "object" && (t.state.itemSnapshot = {
|
|
892
|
+
...t.state.itemSnapshot,
|
|
893
|
+
...r
|
|
894
|
+
});
|
|
895
|
+
}
|
|
896
|
+
function st(e, t, n) {
|
|
897
|
+
n.aiMessage.hasChart = !0, typeof t.messageId == "string" && (n.aiMessage.apiMessageId = t.messageId);
|
|
898
|
+
let r = {
|
|
899
|
+
...t,
|
|
900
|
+
generatedChart: e,
|
|
901
|
+
conversationId: n.callbacks.getConversationId()
|
|
902
|
+
};
|
|
903
|
+
n.callbacks.dispatchChartGenerated(r);
|
|
904
|
+
let i = $e(t);
|
|
905
|
+
i ? z(n, i) : n.callbacks.onMessageUpdate(n.aiMessage);
|
|
906
|
+
}
|
|
907
|
+
function ct(e, t) {
|
|
908
|
+
if (I(e, t), L(e, t) || R(e, t)) return;
|
|
909
|
+
if (e.type === "asset_start" && e.asset_type === "item") {
|
|
910
|
+
t.state.itemSnapshot = null;
|
|
911
|
+
return;
|
|
912
|
+
}
|
|
913
|
+
if (e.type === "asset_delta") {
|
|
914
|
+
ot(e, t);
|
|
915
|
+
return;
|
|
916
|
+
}
|
|
917
|
+
let n = P(e);
|
|
918
|
+
n && z(t, n);
|
|
919
|
+
let r = F(e), i = et(e) ?? (r ? t.state.itemSnapshot : null);
|
|
920
|
+
if (i) {
|
|
921
|
+
st(i, e, t), r && B(t, !0, !!n);
|
|
922
|
+
return;
|
|
923
|
+
}
|
|
924
|
+
B(t, r, !!n);
|
|
925
|
+
}
|
|
926
|
+
//#endregion
|
|
927
|
+
//#region src/components/ai-chat/stream/registry.ts
|
|
928
|
+
function G(e) {
|
|
929
|
+
switch (e) {
|
|
930
|
+
case "dashboard": return at;
|
|
931
|
+
case "analyst": return tt;
|
|
932
|
+
default: return ct;
|
|
933
|
+
}
|
|
934
|
+
}
|
|
935
|
+
function K() {
|
|
936
|
+
return {
|
|
937
|
+
progressCollapsed: !1,
|
|
938
|
+
dashboardSnapshot: null,
|
|
939
|
+
dashboardName: void 0,
|
|
940
|
+
interruptQuestion: null,
|
|
941
|
+
itemSnapshot: null
|
|
942
|
+
};
|
|
943
|
+
}
|
|
944
|
+
//#endregion
|
|
945
|
+
//#region src/components/ai-chat/session/ai-chat-session.ts
|
|
946
|
+
function q() {
|
|
947
|
+
return `msg-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
|
|
948
|
+
}
|
|
949
|
+
var lt = class {
|
|
950
|
+
constructor(e, t = {}) {
|
|
951
|
+
this._uiBridgeCallbacks = {}, this._subscribers = /* @__PURE__ */ new Set(), this._state = {
|
|
952
|
+
messages: [],
|
|
953
|
+
selectedDatasets: [],
|
|
954
|
+
isGenerating: !1,
|
|
955
|
+
progress: null,
|
|
956
|
+
progressCollapsed: !1,
|
|
957
|
+
conversationId: null,
|
|
958
|
+
inflightMessage: null
|
|
959
|
+
}, this._abortController = null, this._inflightMessage = null, this._receivedProgress = !1, this._config = {
|
|
960
|
+
apiUrl: "https://api.luzmo.com",
|
|
961
|
+
apiVersion: "0.1.0",
|
|
962
|
+
stream: !0,
|
|
963
|
+
...e
|
|
964
|
+
}, this._hostCallbacks = t, this._state = {
|
|
965
|
+
...this._state,
|
|
966
|
+
messages: e.messages ? [...e.messages] : [],
|
|
967
|
+
selectedDatasets: e.selectedDatasets ? [...e.selectedDatasets] : [],
|
|
968
|
+
conversationId: e.conversationId ?? null,
|
|
969
|
+
isGenerating: e.isGenerating ?? !1,
|
|
970
|
+
progress: e.progress ?? null,
|
|
971
|
+
progressCollapsed: e.progressCollapsed ?? !1
|
|
972
|
+
};
|
|
973
|
+
}
|
|
974
|
+
get state() {
|
|
975
|
+
return this._state;
|
|
976
|
+
}
|
|
977
|
+
get isGenerating() {
|
|
978
|
+
return this._state.isGenerating;
|
|
979
|
+
}
|
|
980
|
+
subscribe(e) {
|
|
981
|
+
return this._subscribers.add(e), e(this._state), () => {
|
|
982
|
+
this._subscribers.delete(e);
|
|
983
|
+
};
|
|
984
|
+
}
|
|
985
|
+
setUiBridge(e) {
|
|
986
|
+
this._uiBridgeCallbacks = e;
|
|
987
|
+
}
|
|
988
|
+
updateConfig(e) {
|
|
989
|
+
this._config = {
|
|
990
|
+
...this._config,
|
|
991
|
+
...e
|
|
992
|
+
};
|
|
993
|
+
let t = {};
|
|
994
|
+
if ("conversationId" in e) {
|
|
995
|
+
let n = e.conversationId ?? null;
|
|
996
|
+
n !== this._state.conversationId && (t.conversationId = n);
|
|
997
|
+
}
|
|
998
|
+
if ("selectedDatasets" in e && e.selectedDatasets) {
|
|
999
|
+
let n = [...e.selectedDatasets];
|
|
1000
|
+
this._areSelectedDatasetsEqual(n, this._state.selectedDatasets) || (t.selectedDatasets = n);
|
|
1001
|
+
}
|
|
1002
|
+
if ("messages" in e && e.messages) {
|
|
1003
|
+
let n = [...e.messages];
|
|
1004
|
+
this._areChatMessagesEqual(n, this._state.messages) || (t.messages = n);
|
|
1005
|
+
}
|
|
1006
|
+
"isGenerating" in e && e.isGenerating !== this._state.isGenerating && (t.isGenerating = e.isGenerating), "progress" in e && (t.progress = e.progress ?? null), "progressCollapsed" in e && e.progressCollapsed !== this._state.progressCollapsed && (t.progressCollapsed = e.progressCollapsed), Object.keys(t).length > 0 && this._patchState(t);
|
|
1007
|
+
}
|
|
1008
|
+
setSelectedDatasets(e) {
|
|
1009
|
+
this._patchState({ selectedDatasets: [...e] }), this._emit("onDatasetsChanged", this._state.selectedDatasets);
|
|
1010
|
+
}
|
|
1011
|
+
addDataset(e) {
|
|
1012
|
+
this._state.selectedDatasets.some((t) => t.id === e.id) || (this._patchState({ selectedDatasets: [...this._state.selectedDatasets, e] }), this._emit("onDatasetsChanged", this._state.selectedDatasets));
|
|
1013
|
+
}
|
|
1014
|
+
removeDataset(e) {
|
|
1015
|
+
let t = this._state.selectedDatasets.filter((t) => t.id !== e);
|
|
1016
|
+
t.length !== this._state.selectedDatasets.length && (this._patchState({ selectedDatasets: t }), this._emit("onDatasetsChanged", this._state.selectedDatasets));
|
|
1017
|
+
}
|
|
1018
|
+
isDatasetRequirementMet() {
|
|
1019
|
+
return !this._config.requireDataset || this._state.selectedDatasets.length > 0;
|
|
1020
|
+
}
|
|
1021
|
+
getAiPromptUrl() {
|
|
1022
|
+
return He(this._config.apiUrl ?? "https://api.luzmo.com", this._config.apiVersion ?? "0.1.0");
|
|
1023
|
+
}
|
|
1024
|
+
buildRequestBody(e, t) {
|
|
1025
|
+
return k(this._config.agent, {
|
|
1026
|
+
prompt: e,
|
|
1027
|
+
datasetIds: t,
|
|
1028
|
+
authKey: this._config.authKey,
|
|
1029
|
+
authToken: this._config.authToken,
|
|
1030
|
+
conversationId: this._state.conversationId,
|
|
1031
|
+
chart: this._config.chart ?? null,
|
|
1032
|
+
dashboard: this._config.dashboard ?? null,
|
|
1033
|
+
currentScreenMode: this._config.currentScreenMode,
|
|
1034
|
+
localeId: this._config.localeId,
|
|
1035
|
+
timezoneId: this._config.timezoneId,
|
|
1036
|
+
task: this._config.task,
|
|
1037
|
+
modelPreference: this._config.modelPreference,
|
|
1038
|
+
apiVersion: this._config.apiVersion,
|
|
1039
|
+
stream: this._config.stream
|
|
1040
|
+
});
|
|
1041
|
+
}
|
|
1042
|
+
buildPromptSubmittedDetail(e, t, n) {
|
|
1043
|
+
return {
|
|
1044
|
+
prompt: e,
|
|
1045
|
+
selectedDatasets: t,
|
|
1046
|
+
datasetIds: n,
|
|
1047
|
+
agent: this._config.agent,
|
|
1048
|
+
request: this.buildRequestBody(e, n),
|
|
1049
|
+
url: this.getAiPromptUrl()
|
|
1050
|
+
};
|
|
1051
|
+
}
|
|
1052
|
+
async submit(e) {
|
|
1053
|
+
let t = e.datasetIds ?? this._state.selectedDatasets.map((e) => e.id);
|
|
1054
|
+
if (!this.isDatasetRequirementMet()) return;
|
|
1055
|
+
this.abortInflight();
|
|
1056
|
+
let n = {
|
|
1057
|
+
id: e.aiMessageId ?? q(),
|
|
1058
|
+
type: "ai",
|
|
1059
|
+
message: ""
|
|
1060
|
+
}, r = [...this._state.messages];
|
|
1061
|
+
if (!e.skipUserMessage) {
|
|
1062
|
+
let t = {
|
|
1063
|
+
id: q(),
|
|
1064
|
+
type: "user",
|
|
1065
|
+
message: e.prompt
|
|
1066
|
+
};
|
|
1067
|
+
r = [...r, t], this._emit("onMessageSent", t, [...this._state.selectedDatasets]);
|
|
1068
|
+
}
|
|
1069
|
+
r = [...r, n], this._inflightMessage = n, this._receivedProgress = !1, this._patchState({
|
|
1070
|
+
messages: r,
|
|
1071
|
+
isGenerating: !0,
|
|
1072
|
+
progress: A(),
|
|
1073
|
+
progressCollapsed: !1,
|
|
1074
|
+
inflightMessage: n
|
|
1075
|
+
});
|
|
1076
|
+
let i = t, a = [...this._state.selectedDatasets];
|
|
1077
|
+
if (this._hasCallback("onPromptSubmitted")) {
|
|
1078
|
+
let t = this.buildPromptSubmittedDetail(e.prompt, a, i);
|
|
1079
|
+
try {
|
|
1080
|
+
await this._invokeCallback("onPromptSubmitted", t);
|
|
1081
|
+
} catch (e) {
|
|
1082
|
+
e.name === "AbortError" ? this.abort() : (this._handleSubmitError(e, n), this._finalizeInflightMessage()), this._patchState({ isGenerating: !1 });
|
|
1083
|
+
}
|
|
1084
|
+
return;
|
|
1085
|
+
}
|
|
1086
|
+
let o = this.buildRequestBody(e.prompt, t), s = new AbortController();
|
|
1087
|
+
this._abortController = s;
|
|
1088
|
+
let c = G(this._config.agent), l = {
|
|
1089
|
+
aiMessage: n,
|
|
1090
|
+
callbacks: this._createStreamCallbacks(),
|
|
1091
|
+
state: K()
|
|
1092
|
+
}, u = this._config.fetchStreaming ?? M, d = !1;
|
|
1093
|
+
try {
|
|
1094
|
+
let { body: e, conversationId: t } = await u({
|
|
1095
|
+
url: this.getAiPromptUrl(),
|
|
1096
|
+
body: o,
|
|
1097
|
+
signal: s.signal
|
|
1098
|
+
});
|
|
1099
|
+
t && this._setConversationId(t), await Ze(e, (e) => c(e, l)), d = !0;
|
|
1100
|
+
} catch (e) {
|
|
1101
|
+
e.name !== "AbortError" && (this._handleSubmitError(e, n), d = !0);
|
|
1102
|
+
} finally {
|
|
1103
|
+
this._abortController === s && (d ? this._finalizeInflightMessage() : (this._removeInflightFromMessages(), this._inflightMessage = null, this._patchState({ inflightMessage: null })), this._patchState({ isGenerating: !1 }), this._abortController = null);
|
|
1104
|
+
}
|
|
1105
|
+
}
|
|
1106
|
+
async restore(e) {
|
|
1107
|
+
if (this._config.agent !== "item") return {};
|
|
1108
|
+
let t = Ye(e.restoreToMessageId, this._config.authKey, this._config.authToken, this._config.apiVersion, this._state.conversationId);
|
|
1109
|
+
if (this._patchState({
|
|
1110
|
+
isGenerating: !0,
|
|
1111
|
+
progress: null,
|
|
1112
|
+
progressCollapsed: !1
|
|
1113
|
+
}), this._hasCallback("onRestoreRequested")) {
|
|
1114
|
+
let n = {
|
|
1115
|
+
apiMessageId: e.restoreToMessageId,
|
|
1116
|
+
messageIndex: e.messageIndex,
|
|
1117
|
+
request: t,
|
|
1118
|
+
url: this.getAiPromptUrl()
|
|
1119
|
+
};
|
|
1120
|
+
try {
|
|
1121
|
+
await this._invokeCallback("onRestoreRequested", n);
|
|
1122
|
+
} finally {
|
|
1123
|
+
this._patchState({ isGenerating: !1 });
|
|
1124
|
+
}
|
|
1125
|
+
return {};
|
|
1126
|
+
}
|
|
1127
|
+
try {
|
|
1128
|
+
let n = await fetch(this.getAiPromptUrl(), {
|
|
1129
|
+
method: "POST",
|
|
1130
|
+
headers: { "Content-Type": "application/json" },
|
|
1131
|
+
mode: "cors",
|
|
1132
|
+
body: JSON.stringify(t)
|
|
1133
|
+
});
|
|
1134
|
+
if (!n.ok) {
|
|
1135
|
+
let e = await n.json().catch(() => null);
|
|
1136
|
+
throw Error(e?.message || `API request failed with status ${n.status}`);
|
|
1137
|
+
}
|
|
1138
|
+
let r = await n.json().catch(() => null), i = r?.generatedChart ?? (r ? et(r) : null), a = {
|
|
1139
|
+
...typeof r?.message == "string" ? { message: r.message } : {},
|
|
1140
|
+
...i ? { chart: {
|
|
1141
|
+
...r,
|
|
1142
|
+
generatedChart: i
|
|
1143
|
+
} } : {}
|
|
1144
|
+
}, o = e.messageIndex >= 0 && e.messageIndex < this._state.messages.length ? this._state.messages.slice(0, e.messageIndex + 1) : this._state.messages;
|
|
1145
|
+
return a.message && o[e.messageIndex]?.type === "ai" && (o[e.messageIndex] = {
|
|
1146
|
+
...o[e.messageIndex],
|
|
1147
|
+
message: a.message
|
|
1148
|
+
}), this._patchState({ messages: [...o] }), a.chart && this._emit("onChartGenerated", a.chart), a.message && o[e.messageIndex] && this._emit("onResponseReceived", o[e.messageIndex], !0), a;
|
|
1149
|
+
} finally {
|
|
1150
|
+
this._patchState({ isGenerating: !1 });
|
|
1151
|
+
}
|
|
1152
|
+
}
|
|
1153
|
+
buildRestoreRequest(e) {
|
|
1154
|
+
return Ye(e, this._config.authKey, this._config.authToken, this._config.apiVersion, this._state.conversationId);
|
|
1155
|
+
}
|
|
1156
|
+
abort() {
|
|
1157
|
+
this.abortInflight(), this._patchState({
|
|
1158
|
+
isGenerating: !1,
|
|
1159
|
+
progress: null,
|
|
1160
|
+
progressCollapsed: !1,
|
|
1161
|
+
inflightMessage: null
|
|
1162
|
+
});
|
|
1163
|
+
}
|
|
1164
|
+
abortInflight() {
|
|
1165
|
+
this._abortController?.abort(), this._abortController = null, this._removeEmptyInflightFromMessages(), this._inflightMessage = null;
|
|
1166
|
+
}
|
|
1167
|
+
_createStreamCallbacks() {
|
|
1168
|
+
return {
|
|
1169
|
+
onConversationIdChange: (e) => this._setConversationId(e),
|
|
1170
|
+
onProgress: (e) => {
|
|
1171
|
+
this._receivedProgress = !0, this._patchState({ progress: e });
|
|
1172
|
+
},
|
|
1173
|
+
onProgressCollapsed: (e) => {
|
|
1174
|
+
this._patchState({ progressCollapsed: e });
|
|
1175
|
+
},
|
|
1176
|
+
onMessageUpdate: (e) => {
|
|
1177
|
+
this._inflightMessage = e, this._upsertMessage(e), this._patchState({ inflightMessage: { ...e } });
|
|
1178
|
+
},
|
|
1179
|
+
dispatchChartGenerated: (e) => {
|
|
1180
|
+
this._emit("onChartGenerated", e);
|
|
1181
|
+
},
|
|
1182
|
+
dispatchDashboardGenerated: (e) => {
|
|
1183
|
+
this._emit("onDashboardGenerated", e);
|
|
1184
|
+
},
|
|
1185
|
+
dispatchResponseReceived: (e, t) => {
|
|
1186
|
+
this._emit("onResponseReceived", e, t);
|
|
1187
|
+
},
|
|
1188
|
+
getConversationId: () => this._state.conversationId
|
|
1189
|
+
};
|
|
1190
|
+
}
|
|
1191
|
+
_setConversationId(e) {
|
|
1192
|
+
this._config = {
|
|
1193
|
+
...this._config,
|
|
1194
|
+
conversationId: e
|
|
1195
|
+
}, this._patchState({ conversationId: e }), this._emit("onConversationIdChange", e);
|
|
1196
|
+
}
|
|
1197
|
+
_upsertMessage(e) {
|
|
1198
|
+
let t = this._state.messages.findIndex((t) => t.id === e.id);
|
|
1199
|
+
if (t === -1) {
|
|
1200
|
+
this._patchState({ messages: [...this._state.messages, { ...e }] });
|
|
1201
|
+
return;
|
|
1202
|
+
}
|
|
1203
|
+
let n = this._state.messages.map((n, r) => r === t ? { ...e } : n);
|
|
1204
|
+
this._patchState({ messages: n });
|
|
1205
|
+
}
|
|
1206
|
+
_finalizeInflightMessage() {
|
|
1207
|
+
this._inflightMessage && (this._state.progress && this._receivedProgress && (this._inflightMessage.progress = structuredClone(this._state.progress), this._upsertMessage(this._inflightMessage)), this._inflightMessage = null, this._receivedProgress = !1, this._patchState({
|
|
1208
|
+
progress: null,
|
|
1209
|
+
progressCollapsed: !1,
|
|
1210
|
+
inflightMessage: null
|
|
1211
|
+
}));
|
|
1212
|
+
}
|
|
1213
|
+
_removeInflightFromMessages() {
|
|
1214
|
+
this._inflightMessage && this._patchState({ messages: this._state.messages.filter((e) => e.id !== this._inflightMessage.id) });
|
|
1215
|
+
}
|
|
1216
|
+
_removeEmptyInflightFromMessages() {
|
|
1217
|
+
this._inflightMessage && !this._inflightMessage.message ? this._removeInflightFromMessages() : this._inflightMessage && this._finalizeInflightMessage();
|
|
1218
|
+
}
|
|
1219
|
+
_handleSubmitError(e, t) {
|
|
1220
|
+
t.message = n("Something went wrong. Please try again.", { desc: "Generic error message shown in ai chat when the API request fails" }), t.isError = !0, delete t.progress, this._inflightMessage = t, this._upsertMessage(t), this._patchState({
|
|
1221
|
+
inflightMessage: { ...t },
|
|
1222
|
+
progress: null,
|
|
1223
|
+
progressCollapsed: !1
|
|
1224
|
+
}), this._emit("onError", e, t), this._emit("onResponseReceived", t, !0, e);
|
|
1225
|
+
}
|
|
1226
|
+
_hasCallback(e) {
|
|
1227
|
+
return typeof this._hostCallbacks[e] == "function" || typeof this._uiBridgeCallbacks[e] == "function";
|
|
1228
|
+
}
|
|
1229
|
+
_emit(e, ...t) {
|
|
1230
|
+
this._invokeCallback(e, ...t);
|
|
1231
|
+
}
|
|
1232
|
+
async _invokeCallback(e, ...t) {
|
|
1233
|
+
let n = this._hostCallbacks[e], r = this._uiBridgeCallbacks[e];
|
|
1234
|
+
typeof n == "function" && await n(...t), typeof r == "function" && await r(...t);
|
|
1235
|
+
}
|
|
1236
|
+
_patchState(e) {
|
|
1237
|
+
this._state = {
|
|
1238
|
+
...this._state,
|
|
1239
|
+
...e
|
|
1240
|
+
}, this._emit("onStateChange", this._state);
|
|
1241
|
+
for (let e of this._subscribers) e(this._state);
|
|
1242
|
+
}
|
|
1243
|
+
_areSelectedDatasetsEqual(e, t) {
|
|
1244
|
+
return e.length === t.length ? e.every((e, n) => e.id === t[n]?.id) : !1;
|
|
1245
|
+
}
|
|
1246
|
+
_areChatMessagesEqual(e, t) {
|
|
1247
|
+
return e.length === t.length ? e.every((e, n) => {
|
|
1248
|
+
let r = t[n];
|
|
1249
|
+
return e.id === r?.id && e.apiMessageId === r?.apiMessageId && e.type === r?.type && e.message === r?.message && e.isError === r?.isError && e.hasChart === r?.hasChart && JSON.stringify(e.progress ?? null) === JSON.stringify(r?.progress ?? null);
|
|
1250
|
+
}) : !1;
|
|
1251
|
+
}
|
|
1252
|
+
};
|
|
1253
|
+
function ut(e, t) {
|
|
1254
|
+
return new lt(e, t);
|
|
1255
|
+
}
|
|
1256
|
+
//#endregion
|
|
1257
|
+
//#region src/components/ai-chat/session/ai-chat-session-controller.ts
|
|
1258
|
+
var dt = class {
|
|
1259
|
+
constructor(e) {
|
|
1260
|
+
this.options = e, this._session = null, this._ownsSession = !1, this._seededFromProps = !1, this._unsubscribe = null;
|
|
1261
|
+
}
|
|
1262
|
+
get current() {
|
|
1263
|
+
return this._session;
|
|
1264
|
+
}
|
|
1265
|
+
get state() {
|
|
1266
|
+
if (this._session) return this._session.state;
|
|
1267
|
+
let e = this.options.getSeed();
|
|
1268
|
+
return {
|
|
1269
|
+
messages: e.messages,
|
|
1270
|
+
selectedDatasets: e.selectedDatasets,
|
|
1271
|
+
isGenerating: !1,
|
|
1272
|
+
progress: null,
|
|
1273
|
+
progressCollapsed: !1,
|
|
1274
|
+
conversationId: e.conversationId,
|
|
1275
|
+
inflightMessage: null
|
|
1276
|
+
};
|
|
1277
|
+
}
|
|
1278
|
+
get ownsCurrentSession() {
|
|
1279
|
+
return this._ownsSession;
|
|
1280
|
+
}
|
|
1281
|
+
setSession(e) {
|
|
1282
|
+
if (!e) {
|
|
1283
|
+
this._clearSession();
|
|
1284
|
+
return;
|
|
1285
|
+
}
|
|
1286
|
+
this._ownsSession && this._session !== e && this._session?.abort(), this._ownsSession = !1, this._session = e, e.updateConfig(this.options.getConfig()), this._wire(e);
|
|
1287
|
+
}
|
|
1288
|
+
syncProperties(e) {
|
|
1289
|
+
if (!e.has("chatSession")) {
|
|
1290
|
+
if (this._createSessionIfMissing(), this._session) {
|
|
1291
|
+
let t = this.options.getConfig();
|
|
1292
|
+
Object.keys(t).some((t) => e.has(t)) && this._session.updateConfig(t);
|
|
1293
|
+
}
|
|
1294
|
+
(e.has("messages") || e.has("selectedDatasets")) && this._seedFromPropsOnce();
|
|
1295
|
+
}
|
|
1296
|
+
}
|
|
1297
|
+
requireSession() {
|
|
1298
|
+
return this._createSessionIfMissing(), this._session.updateConfig(this.options.getConfig()), this._session;
|
|
1299
|
+
}
|
|
1300
|
+
connect() {
|
|
1301
|
+
this._session && this._wire(this._session);
|
|
1302
|
+
}
|
|
1303
|
+
teardown() {
|
|
1304
|
+
this._unwire(), this._ownsSession &&= (this._session?.abort(), this._session = null, !1), this._seededFromProps = !1;
|
|
1305
|
+
}
|
|
1306
|
+
_createSessionIfMissing() {
|
|
1307
|
+
if (this._session) return;
|
|
1308
|
+
let e = this.options.getSeed();
|
|
1309
|
+
this._session = ut({
|
|
1310
|
+
...this.options.getConfig(),
|
|
1311
|
+
messages: e.messages.length > 0 ? [...e.messages] : void 0,
|
|
1312
|
+
selectedDatasets: e.selectedDatasets.length > 0 ? [...e.selectedDatasets] : void 0
|
|
1313
|
+
}), this._ownsSession = !0, this._seededFromProps = e.messages.length > 0 || e.selectedDatasets.length > 0, this._wire(this._session);
|
|
1314
|
+
}
|
|
1315
|
+
_clearSession() {
|
|
1316
|
+
this._unwire(), this._ownsSession && this._session?.abort(), this._session = null, this._ownsSession = !1;
|
|
1317
|
+
}
|
|
1318
|
+
_seedFromPropsOnce() {
|
|
1319
|
+
if (!this._ownsSession || this._seededFromProps) return;
|
|
1320
|
+
let e = this.requireSession(), t = this.options.getSeed(), n = {};
|
|
1321
|
+
e.state.messages.length === 0 && t.messages.length > 0 && (n.messages = [...t.messages]), e.state.selectedDatasets.length === 0 && t.selectedDatasets.length > 0 && (n.selectedDatasets = [...t.selectedDatasets]), Object.keys(n).length > 0 && (e.updateConfig(n), this._seededFromProps = !0);
|
|
1322
|
+
}
|
|
1323
|
+
_wire(e) {
|
|
1324
|
+
this._unwire(), e.setUiBridge(this.options.createDomBridge()), this._unsubscribe = e.subscribe(() => {
|
|
1325
|
+
this.options.onRenderNeeded();
|
|
1326
|
+
});
|
|
1327
|
+
}
|
|
1328
|
+
_unwire() {
|
|
1329
|
+
this._unsubscribe?.(), this._unsubscribe = null;
|
|
1330
|
+
}
|
|
1331
|
+
}, ft = ":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 .chat-messages-container::-webkit-scrollbar{width:var(--luzmo-ai-chat-scrollbar-width,var(--ai-chat-scrollbar-width))}:host .chat-messages-container::-webkit-scrollbar-track{background:var(--luzmo-ai-chat-scrollbar-track-background,var(--ai-chat-scrollbar-track-background));border-radius:var(--luzmo-ai-chat-scrollbar-track-border-radius,var(--ai-chat-scrollbar-track-border-radius))}:host .chat-messages-container::-webkit-scrollbar-thumb{background:var(--luzmo-ai-chat-scrollbar-thumb-background,var(--ai-chat-scrollbar-thumb-background));border-radius:var(--luzmo-ai-chat-scrollbar-thumb-border-radius,var(--ai-chat-scrollbar-thumb-border-radius))}:host .chat-messages-container::-webkit-scrollbar-thumb:hover{background:var(--luzmo-ai-chat-scrollbar-thumb-hover-background,var(--ai-chat-scrollbar-thumb-hover-background))}:host .chat-messages-container{scrollbar-width:var(--luzmo-scrollbar-width,thin);scrollbar-color:var(--luzmo-ai-chat-scrollbar-thumb-background,var(--ai-chat-scrollbar-thumb-background)) var(--luzmo-ai-chat-scrollbar-track-background,var(--ai-chat-scrollbar-track-background))}: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 .assistant-message-wrapper{justify-content:space-between;align-items:flex-start;gap:1rem;display:flex}:host .assistant-message-wrapper luzmo-chat-message{width:fit-content;display:contents}:host .assistant-context-menu-trigger{width:var(--luzmo-ai-chat-context-menu-trigger-size,var(--ai-chat-context-menu-trigger-size));height:var(--luzmo-ai-chat-context-menu-trigger-size,var(--ai-chat-context-menu-trigger-size));border:.0625rem solid var(--luzmo-ai-chat-context-menu-trigger-border-color,var(--ai-chat-context-menu-trigger-border-color));border-radius:var(--luzmo-ai-chat-context-menu-trigger-border-radius,var(--ai-chat-context-menu-trigger-border-radius));background:var(--luzmo-ai-chat-context-menu-trigger-background,var(--ai-chat-context-menu-trigger-background));color:var(--luzmo-ai-chat-context-menu-trigger-color,var(--ai-chat-context-menu-trigger-color));cursor:pointer;justify-content:center;align-items:center;padding:0;font-size:.875rem;line-height:1;transition:all .15s;display:inline-flex}:host .assistant-context-menu-trigger:hover{background:var(--luzmo-ai-chat-context-menu-trigger-hover-background,var(--ai-chat-context-menu-trigger-hover-background));border-color:var(--luzmo-ai-chat-context-menu-trigger-hover-border-color,var(--ai-chat-context-menu-trigger-hover-border-color));color:var(--luzmo-ai-chat-context-menu-trigger-hover-color,var(--ai-chat-context-menu-trigger-hover-color))}:host .assistant-context-menu-trigger:disabled{cursor:not-allowed;opacity:.6}:host .assistant-context-menu-trigger:disabled:hover{background:var(--luzmo-ai-chat-context-menu-trigger-background,var(--ai-chat-context-menu-trigger-background));border-color:var(--luzmo-ai-chat-context-menu-trigger-border-color,var(--ai-chat-context-menu-trigger-border-color));color:var(--luzmo-ai-chat-context-menu-trigger-color,var(--ai-chat-context-menu-trigger-color))}:host .assistant-context-menu-item{width:100%;color:var(--luzmo-font-color);text-align:start;cursor:pointer;font-family:var(--luzmo-ai-chat-context-menu-item-font-family,var(--ai-chat-context-menu-item-font-family));background:0 0;border:0;padding:.5rem .75rem}:host .assistant-context-menu-item:hover{background:var(--luzmo-ai-chat-context-menu-item-hover-background,var(--ai-chat-context-menu-item-hover-background))}:host .assistant-context-menu-item:disabled{opacity:.4;cursor:not-allowed}:host .assistant-context-menu-item:disabled:hover{background:0 0}: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)}}@media (prefers-reduced-motion:reduce){:host .assistant-context-menu-trigger{transition:none}:host .loading-message svg.spin{animation:none}}:host{--ai-chat-background:var(--luzmo-background-color);--ai-chat-border-radius:0;--ai-chat-padding:0;--ai-chat-gap:1rem;--ai-chat-border:none;--ai-chat-box-shadow:none;--ai-chat-loading-message-color:var(--luzmo-primary);--ai-chat-loading-message-icon-font-size:1rem;--ai-chat-error-message-color:var(--luzmo-danger,#dc3545);--ai-chat-scrollbar-width:var(--luzmo-scrollbar-size);--ai-chat-scrollbar-track-background:var(--luzmo-scrollbar-track-background);--ai-chat-scrollbar-track-border-radius:var(--luzmo-scrollbar-track-border-radius);--ai-chat-scrollbar-thumb-background:var(--luzmo-scrollbar-thumb-background);--ai-chat-scrollbar-thumb-border-radius:var(--luzmo-scrollbar-thumb-border-radius);--ai-chat-scrollbar-thumb-hover-background:var(--luzmo-scrollbar-thumb-hover-background);--ai-chat-context-menu-trigger-size:1.5rem;--ai-chat-context-menu-trigger-border-color:var(--luzmo-border-color);--ai-chat-context-menu-trigger-border-radius:.375rem;--ai-chat-context-menu-trigger-background:var(--luzmo-background-color,transparent);--ai-chat-context-menu-trigger-color:var(--luzmo-font-color,#5a5a5a);--ai-chat-context-menu-trigger-hover-background:var(--luzmo-background-color-hover,#4434ff14);--ai-chat-context-menu-trigger-hover-border-color:var(--luzmo-border-color-hover,var(--luzmo-border-color));--ai-chat-context-menu-trigger-hover-color:var(--luzmo-font-color,#5a5a5a);--ai-chat-context-menu-item-hover-background:var(--luzmo-background-color-hover,#4434ff14);--ai-chat-context-menu-item-font-family:var(--luzmo-font-family)}", J = class extends e {
|
|
1332
|
+
constructor(...e) {
|
|
1333
|
+
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.hideDatasetIcons = !1, this.disableDatasetModification = !1, this.hideSelectedDatasets = !1, this.disableColumnMentions = !1, this.requireDataset = !1, this.agent = "item", this.task = "generate", this.modelPreference = "performance", this.chatSession = null, this.conversationId = null, this.chart = null, this.dashboard = null, this.timezoneId = "UTC", this.apiVersion = "0.1.0", this.stream = !0, this.loadingMessage = null, this.initialPrompt = null, this._textareaValue = "", this._lastProcessedInitialPrompt = null, this._session = new dt({
|
|
1334
|
+
getConfig: () => this._buildSessionConfig(),
|
|
1335
|
+
getSeed: () => ({
|
|
1336
|
+
messages: this.messages,
|
|
1337
|
+
selectedDatasets: this.selectedDatasets,
|
|
1338
|
+
conversationId: this.conversationId
|
|
1339
|
+
}),
|
|
1340
|
+
createDomBridge: () => this._createDomBridgeCallbacks(),
|
|
1341
|
+
onRenderNeeded: () => {
|
|
1342
|
+
this.requestUpdate(), this.updateComplete.then(() => this._scrollToBottom());
|
|
1343
|
+
}
|
|
1344
|
+
});
|
|
1345
|
+
}
|
|
1346
|
+
static {
|
|
1347
|
+
this.styles = c(ft);
|
|
1348
|
+
}
|
|
1349
|
+
static {
|
|
1350
|
+
this.tagName = "luzmo-ai-chat";
|
|
1351
|
+
}
|
|
1352
|
+
get session() {
|
|
1353
|
+
return this._session.current;
|
|
1354
|
+
}
|
|
1355
|
+
_getRenderState() {
|
|
1356
|
+
return this._session.state;
|
|
1357
|
+
}
|
|
1358
|
+
_createDomBridgeCallbacks() {
|
|
1359
|
+
return {
|
|
1360
|
+
onMessageSent: (e, t) => {
|
|
1361
|
+
this.dispatchEvent(new CustomEvent("luzmo-message-sent", {
|
|
1362
|
+
detail: {
|
|
1363
|
+
message: e,
|
|
1364
|
+
selectedDatasets: t
|
|
1365
|
+
},
|
|
1366
|
+
bubbles: !0,
|
|
1367
|
+
composed: !0
|
|
1368
|
+
}));
|
|
1369
|
+
},
|
|
1370
|
+
onDatasetsChanged: (e) => {
|
|
1371
|
+
this.dispatchEvent(new CustomEvent("luzmo-datasets-changed", {
|
|
1372
|
+
detail: { selectedDatasets: e },
|
|
1373
|
+
bubbles: !0,
|
|
1374
|
+
composed: !0
|
|
1375
|
+
}));
|
|
1376
|
+
},
|
|
1377
|
+
onConversationIdChange: (e) => this._emitConversationIdChanged(e),
|
|
1378
|
+
onChartGenerated: (e) => {
|
|
1379
|
+
this.dispatchEvent(new CustomEvent("luzmo-chart-generated", {
|
|
1380
|
+
detail: { aiSampleChart: e },
|
|
1381
|
+
bubbles: !0,
|
|
1382
|
+
composed: !0
|
|
1383
|
+
}));
|
|
1384
|
+
},
|
|
1385
|
+
onDashboardGenerated: (e) => {
|
|
1386
|
+
this.dispatchEvent(new CustomEvent("luzmo-dashboard-generated", {
|
|
1387
|
+
detail: e,
|
|
1388
|
+
bubbles: !0,
|
|
1389
|
+
composed: !0
|
|
1390
|
+
}));
|
|
1391
|
+
},
|
|
1392
|
+
onResponseReceived: (e, t, n) => {
|
|
1393
|
+
this.dispatchEvent(new CustomEvent("luzmo-response-received", {
|
|
1394
|
+
detail: {
|
|
1395
|
+
message: e,
|
|
1396
|
+
done: t,
|
|
1397
|
+
...n === void 0 ? {} : { error: n }
|
|
1398
|
+
},
|
|
1399
|
+
bubbles: !0,
|
|
1400
|
+
composed: !0
|
|
1401
|
+
}));
|
|
1402
|
+
}
|
|
1403
|
+
};
|
|
1404
|
+
}
|
|
1405
|
+
_buildSessionConfig() {
|
|
1406
|
+
return {
|
|
1407
|
+
agent: this.agent,
|
|
1408
|
+
authKey: this.authKey,
|
|
1409
|
+
authToken: this.authToken,
|
|
1410
|
+
apiUrl: this.apiUrl,
|
|
1411
|
+
apiVersion: this.apiVersion,
|
|
1412
|
+
stream: this.stream,
|
|
1413
|
+
conversationId: this.conversationId,
|
|
1414
|
+
chart: this.chart,
|
|
1415
|
+
dashboard: this.dashboard,
|
|
1416
|
+
currentScreenMode: this.currentScreenMode,
|
|
1417
|
+
localeId: this.localeId,
|
|
1418
|
+
timezoneId: this.timezoneId,
|
|
1419
|
+
task: this.task,
|
|
1420
|
+
modelPreference: this.modelPreference,
|
|
1421
|
+
requireDataset: this.requireDataset
|
|
1422
|
+
};
|
|
1423
|
+
}
|
|
1424
|
+
_emitConversationIdChanged(e) {
|
|
1425
|
+
this.conversationId = e, this.dispatchEvent(new CustomEvent("luzmo-conversation-id-changed", {
|
|
1426
|
+
detail: { conversationId: e },
|
|
1427
|
+
bubbles: !0,
|
|
1428
|
+
composed: !0
|
|
1429
|
+
}));
|
|
1430
|
+
}
|
|
1431
|
+
async _restoreViaSession(e, t) {
|
|
1432
|
+
await this._session.requireSession().restore({
|
|
1433
|
+
restoreToMessageId: e,
|
|
1434
|
+
messageIndex: t
|
|
1435
|
+
});
|
|
1436
|
+
}
|
|
1437
|
+
async _handleRestoreState(e, t) {
|
|
1438
|
+
if (e.apiMessageId && this.agent === "item") try {
|
|
1439
|
+
await this._restoreViaSession(e.apiMessageId, t);
|
|
1440
|
+
} catch (e) {
|
|
1441
|
+
console.error("AI restore error:", e);
|
|
1442
|
+
}
|
|
1443
|
+
}
|
|
1444
|
+
_handleDatasetSelected(e) {
|
|
1445
|
+
this._session.requireSession().addDataset(e.detail);
|
|
1446
|
+
}
|
|
1447
|
+
_handleDatasetRemoved(e) {
|
|
1448
|
+
this._session.requireSession().removeDataset(e.detail.id);
|
|
1449
|
+
}
|
|
1450
|
+
async _submitViaSession(e, t = {}) {
|
|
1451
|
+
let n = this._session.requireSession();
|
|
1452
|
+
if (n.isDatasetRequirementMet()) {
|
|
1453
|
+
this._textareaValue = "";
|
|
1454
|
+
try {
|
|
1455
|
+
await n.submit({
|
|
1456
|
+
prompt: e,
|
|
1457
|
+
...t
|
|
1458
|
+
});
|
|
1459
|
+
} catch (e) {
|
|
1460
|
+
e.name !== "AbortError" && console.error("AI prompt session error:", e);
|
|
1461
|
+
}
|
|
1462
|
+
}
|
|
1463
|
+
}
|
|
1464
|
+
async _handlePromptSubmitted(e) {
|
|
1465
|
+
await this._submitViaSession(e.detail.prompt);
|
|
1466
|
+
}
|
|
1467
|
+
async _processInitialPrompt() {
|
|
1468
|
+
!this.initialPrompt || this.initialPrompt === this._lastProcessedInitialPrompt || this._session.requireSession().isDatasetRequirementMet() && (this._lastProcessedInitialPrompt = this.initialPrompt, await this._submitViaSession(this.initialPrompt, { skipUserMessage: !0 }));
|
|
1469
|
+
}
|
|
1470
|
+
connectedCallback() {
|
|
1471
|
+
super.connectedCallback(), this._session.connect();
|
|
1472
|
+
}
|
|
1473
|
+
disconnectedCallback() {
|
|
1474
|
+
super.disconnectedCallback(), this._session.teardown();
|
|
1475
|
+
}
|
|
1476
|
+
_scrollToBottom() {
|
|
1477
|
+
let e = this.shadowRoot?.querySelector(".chat-messages-container");
|
|
1478
|
+
e && requestAnimationFrame(() => {
|
|
1479
|
+
requestAnimationFrame(() => {
|
|
1480
|
+
e.scrollTop = e.scrollHeight;
|
|
1481
|
+
});
|
|
1482
|
+
});
|
|
1483
|
+
}
|
|
1484
|
+
updated(e) {
|
|
1485
|
+
super.updated?.(e), this._syncSession(e), this._handleInitialPromptChange();
|
|
1486
|
+
}
|
|
1487
|
+
_syncSession(e) {
|
|
1488
|
+
if (e.has("chatSession")) {
|
|
1489
|
+
this._session.setSession(this.chatSession);
|
|
1490
|
+
return;
|
|
1491
|
+
}
|
|
1492
|
+
this._session.syncProperties(e);
|
|
1493
|
+
}
|
|
1494
|
+
_handleInitialPromptChange() {
|
|
1495
|
+
this.initialPrompt && this.initialPrompt !== this._lastProcessedInitialPrompt ? this._processInitialPrompt() : this.initialPrompt || (this._lastProcessedInitialPrompt = null);
|
|
1496
|
+
}
|
|
1497
|
+
_sanitizeMessage(e) {
|
|
1498
|
+
return Ve.sanitize(e, {
|
|
1499
|
+
ALLOWED_TAGS: [
|
|
1500
|
+
"p",
|
|
1501
|
+
"br",
|
|
1502
|
+
"strong",
|
|
1503
|
+
"em",
|
|
1504
|
+
"b",
|
|
1505
|
+
"i",
|
|
1506
|
+
"u",
|
|
1507
|
+
"s",
|
|
1508
|
+
"code",
|
|
1509
|
+
"pre",
|
|
1510
|
+
"blockquote",
|
|
1511
|
+
"ul",
|
|
1512
|
+
"ol",
|
|
1513
|
+
"li",
|
|
1514
|
+
"a"
|
|
1515
|
+
],
|
|
1516
|
+
ALLOWED_ATTR: [
|
|
1517
|
+
"href",
|
|
1518
|
+
"title",
|
|
1519
|
+
"target",
|
|
1520
|
+
"rel"
|
|
1521
|
+
],
|
|
1522
|
+
ALLOW_DATA_ATTR: !1,
|
|
1523
|
+
FORBID_TAGS: [
|
|
1524
|
+
"script",
|
|
1525
|
+
"iframe",
|
|
1526
|
+
"object",
|
|
1527
|
+
"embed",
|
|
1528
|
+
"form",
|
|
1529
|
+
"input",
|
|
1530
|
+
"button"
|
|
1531
|
+
],
|
|
1532
|
+
FORBID_ATTR: [
|
|
1533
|
+
"onerror",
|
|
1534
|
+
"onload",
|
|
1535
|
+
"onclick",
|
|
1536
|
+
"onmouseover",
|
|
1537
|
+
"onfocus",
|
|
1538
|
+
"onblur"
|
|
1539
|
+
]
|
|
1540
|
+
});
|
|
1541
|
+
}
|
|
1542
|
+
_renderProgress() {
|
|
1543
|
+
let { progress: e, progressCollapsed: t } = this._getRenderState();
|
|
1544
|
+
return e?.children?.length ? o`
|
|
1545
|
+
<luzmo-progress-steps
|
|
1546
|
+
.progress=${e}
|
|
1547
|
+
?collapsed=${t}
|
|
1548
|
+
size="s"
|
|
1549
|
+
></luzmo-progress-steps>
|
|
1550
|
+
` : s;
|
|
1551
|
+
}
|
|
1552
|
+
_isLastAiMessageWithProgress(e, t) {
|
|
1553
|
+
for (let n = t.length - 1; n >= 0; n--) if (t[n].type === "ai" && t[n].progress?.children?.length) return t[n].id === e.id;
|
|
1554
|
+
return !1;
|
|
1555
|
+
}
|
|
1556
|
+
_renderRestoreMenu(e, t, a, c = !1) {
|
|
1557
|
+
if (!(this.agent === "item" && this.showAssistantContextMenu && e.hasChart && e.apiMessageId && !e.isError && e.id !== a)) return s;
|
|
1558
|
+
let l = `context-menu-trigger-${e.apiMessageId}`;
|
|
1559
|
+
return o`
|
|
1560
|
+
<div class="assistant-context-menu">
|
|
1561
|
+
<button
|
|
1562
|
+
id=${l}
|
|
1563
|
+
class="assistant-context-menu-trigger"
|
|
1564
|
+
type="button"
|
|
1565
|
+
aria-label=${n("Open restore menu", { desc: "Accessible label for the ai chat restore menu trigger" })}
|
|
1566
|
+
aria-haspopup="menu"
|
|
1567
|
+
?disabled=${c}
|
|
1568
|
+
>
|
|
1569
|
+
${i(r)}
|
|
1570
|
+
</button>
|
|
1571
|
+
<luzmo-overlay
|
|
1572
|
+
trigger="${l}@click"
|
|
1573
|
+
placement="bottom-end"
|
|
1574
|
+
>
|
|
1575
|
+
<luzmo-popover>
|
|
1576
|
+
<button
|
|
1577
|
+
class="assistant-context-menu-item"
|
|
1578
|
+
type="button"
|
|
1579
|
+
?disabled=${c}
|
|
1580
|
+
@click=${() => this._handleRestoreState(e, t)}
|
|
1581
|
+
>
|
|
1582
|
+
${n("Restore state", { desc: "Context menu action that restores the chart to this message state" })}
|
|
1583
|
+
</button>
|
|
1584
|
+
</luzmo-popover>
|
|
1585
|
+
</luzmo-overlay>
|
|
1586
|
+
</div>
|
|
1587
|
+
`;
|
|
1588
|
+
}
|
|
1589
|
+
_renderMessages() {
|
|
1590
|
+
let { messages: e, inflightMessage: t, isGenerating: n } = this._getRenderState(), r = t !== null, i = [...e].reverse().find((e) => e.type === "ai")?.id, a = e.filter((e) => !t || e.id !== t.id);
|
|
1591
|
+
return a.map((t) => {
|
|
1592
|
+
let c = !!t.progress?.children?.length, l = c && this._isLastAiMessageWithProgress(t, a), u = c && (r || n || !l), ee = c ? o`
|
|
1593
|
+
<luzmo-progress-steps
|
|
1594
|
+
.progress=${t.progress}
|
|
1595
|
+
?condensed=${u}
|
|
1596
|
+
collapsed
|
|
1597
|
+
no-animate
|
|
1598
|
+
size="s"
|
|
1599
|
+
></luzmo-progress-steps>
|
|
1600
|
+
` : s;
|
|
1601
|
+
if (t.type === "user") return o`
|
|
1602
|
+
<luzmo-chat-message
|
|
1603
|
+
avatar-placement="bottom"
|
|
1604
|
+
position="right"
|
|
1605
|
+
variant="primary"
|
|
1606
|
+
size="s"
|
|
1607
|
+
>
|
|
1608
|
+
${t.message}
|
|
1609
|
+
</luzmo-chat-message>
|
|
1610
|
+
`;
|
|
1611
|
+
let te = e.indexOf(t);
|
|
1612
|
+
return o`
|
|
1613
|
+
${ee}
|
|
1614
|
+
<div class="assistant-message-wrapper">
|
|
1615
|
+
<luzmo-chat-message
|
|
1616
|
+
class=${t.isError ? "error" : ""}
|
|
1617
|
+
role=${t.isError ? "alert" : s}
|
|
1618
|
+
avatar-placement="bottom"
|
|
1619
|
+
position="left"
|
|
1620
|
+
quiet
|
|
1621
|
+
size="s"
|
|
1622
|
+
>
|
|
1623
|
+
${d(this._sanitizeMessage(t.message))}
|
|
1624
|
+
</luzmo-chat-message>
|
|
1625
|
+
|
|
1626
|
+
${this._renderRestoreMenu(t, te, i, r)}
|
|
1627
|
+
</div>
|
|
1628
|
+
`;
|
|
1629
|
+
});
|
|
1630
|
+
}
|
|
1631
|
+
_renderStreamingResponse() {
|
|
1632
|
+
let { inflightMessage: e } = this._getRenderState();
|
|
1633
|
+
return e?.message ? o`
|
|
1634
|
+
<luzmo-chat-message
|
|
1635
|
+
avatar-placement="bottom"
|
|
1636
|
+
position="left"
|
|
1637
|
+
quiet
|
|
1638
|
+
size="s"
|
|
1639
|
+
>
|
|
1640
|
+
${d(this._sanitizeMessage(e.message))}
|
|
1641
|
+
</luzmo-chat-message>
|
|
1642
|
+
` : s;
|
|
1643
|
+
}
|
|
1644
|
+
_renderLoadingMessage() {
|
|
1645
|
+
let { isGenerating: e, progress: t } = this._getRenderState();
|
|
1646
|
+
if (!e || t?.children?.length) return s;
|
|
1647
|
+
let r = this.agent === "dashboard" ? !this.dashboard : this.chart?.type === "placeholder", c = this.agent === "dashboard" ? r ? n("Creating dashboard...", { desc: "Label for ai chat creating dashboard message" }) : n("Updating dashboard...", { desc: "Label for ai chat updating dashboard message" }) : r ? n("Creating item...", { desc: "Label for ai chat creating item message" }) : n("Updating item...", { desc: "Label for ai chat updating item message" });
|
|
1648
|
+
return o`
|
|
1649
|
+
<luzmo-chat-message
|
|
1650
|
+
avatar-placement="bottom"
|
|
1651
|
+
position="left"
|
|
1652
|
+
quiet
|
|
1653
|
+
size="s"
|
|
1654
|
+
>
|
|
1655
|
+
<div class="loading-message" role="status" aria-live="polite">
|
|
1656
|
+
<span class="icon-lg">${i(a, { className: "spin" })}</span>
|
|
1657
|
+
<span class="loading-message-text">${this.loadingMessage || c}</span>
|
|
1658
|
+
</div>
|
|
1659
|
+
</luzmo-chat-message>
|
|
1660
|
+
`;
|
|
1661
|
+
}
|
|
1662
|
+
_renderPlaceholderMessage() {
|
|
1663
|
+
return this._getRenderState().messages.length > 0 ? o`
|
|
1664
|
+
|
|
1665
|
+
` : o`
|
|
1666
|
+
<luzmo-chat-message
|
|
1667
|
+
avatar-placement="bottom"
|
|
1668
|
+
position="left"
|
|
1669
|
+
quiet
|
|
1670
|
+
size="s"
|
|
1671
|
+
>
|
|
1672
|
+
${this.agent === "dashboard" ? n("Describe how you want to edit this dashboard…", { desc: "Label for ai chat dashboard placeholder message" }) : n("Describe how you want to edit this item…", { desc: "Label for ai chat item placeholder message" })}
|
|
1673
|
+
</luzmo-chat-message>
|
|
1674
|
+
`;
|
|
1675
|
+
}
|
|
1676
|
+
render() {
|
|
1677
|
+
let { selectedDatasets: e, isGenerating: t } = this._getRenderState();
|
|
1678
|
+
return o`
|
|
1679
|
+
<div class="chat-container" role="region" aria-label=${n("AI Chat", { desc: "Accessible label for AI chat region" })}>
|
|
1680
|
+
<div class="chat-messages-container" role="log" aria-live="polite">
|
|
1681
|
+
${this._renderPlaceholderMessage()}
|
|
1682
|
+
${this._renderMessages()}
|
|
1683
|
+
${this._renderProgress()}
|
|
1684
|
+
${this._renderStreamingResponse()}
|
|
1685
|
+
${this._renderLoadingMessage()}
|
|
1686
|
+
</div>
|
|
1687
|
+
|
|
1688
|
+
<luzmo-ai-interaction-textarea
|
|
1689
|
+
role="group"
|
|
1690
|
+
aria-label=${n("AI prompt input", { desc: "Accessible label for the ai chat prompt input area" })}
|
|
1691
|
+
.value=${this._textareaValue}
|
|
1692
|
+
.selectedDatasets=${e}
|
|
1693
|
+
.placeholder=${this.placeholder}
|
|
1694
|
+
?disabled=${this.disabled}
|
|
1695
|
+
?is-generating=${t}
|
|
1696
|
+
?hide-dataset-button=${this.hideDatasetButton}
|
|
1697
|
+
?hide-dataset-icons=${this.hideDatasetIcons}
|
|
1698
|
+
?disable-dataset-modification=${this.disableDatasetModification}
|
|
1699
|
+
?hide-selected-datasets=${this.hideSelectedDatasets}
|
|
1700
|
+
?disable-column-mentions=${this.disableColumnMentions}
|
|
1701
|
+
?require-dataset=${this.requireDataset}
|
|
1702
|
+
auth-key=${this.authKey}
|
|
1703
|
+
auth-token=${this.authToken}
|
|
1704
|
+
api-url=${this.apiUrl}
|
|
1705
|
+
app-server=${this.appServer}
|
|
1706
|
+
?flag-opendata=${this.flagOpendata}
|
|
1707
|
+
@prompt-submitted=${this._handlePromptSubmitted}
|
|
1708
|
+
@dataset-selected=${this._handleDatasetSelected}
|
|
1709
|
+
@dataset-removed=${this._handleDatasetRemoved}
|
|
1710
|
+
></luzmo-ai-interaction-textarea>
|
|
1711
|
+
</div>
|
|
1712
|
+
`;
|
|
1713
|
+
}
|
|
1714
|
+
};
|
|
1715
|
+
//#endregion
|
|
1716
|
+
//#region src/components/ai-chat/index.ts
|
|
1717
|
+
t([l({ type: Array })], J.prototype, "messages", void 0), t([l({
|
|
1718
|
+
type: Array,
|
|
1719
|
+
attribute: "selected-datasets"
|
|
1720
|
+
})], J.prototype, "selectedDatasets", void 0), t([l({ type: String })], J.prototype, "placeholder", void 0), t([l({
|
|
1721
|
+
type: Boolean,
|
|
1722
|
+
reflect: !0
|
|
1723
|
+
})], J.prototype, "disabled", void 0), t([l({
|
|
1724
|
+
type: Boolean,
|
|
1725
|
+
attribute: "show-assistant-context-menu"
|
|
1726
|
+
})], J.prototype, "showAssistantContextMenu", void 0), t([l({
|
|
1727
|
+
type: String,
|
|
1728
|
+
attribute: "auth-key"
|
|
1729
|
+
})], J.prototype, "authKey", void 0), t([l({
|
|
1730
|
+
type: String,
|
|
1731
|
+
attribute: "auth-token"
|
|
1732
|
+
})], J.prototype, "authToken", void 0), t([l({
|
|
1733
|
+
type: String,
|
|
1734
|
+
attribute: "api-url"
|
|
1735
|
+
})], J.prototype, "apiUrl", void 0), t([l({
|
|
1736
|
+
type: String,
|
|
1737
|
+
attribute: "app-server"
|
|
1738
|
+
})], J.prototype, "appServer", void 0), t([l({
|
|
1739
|
+
type: Boolean,
|
|
1740
|
+
attribute: "flag-opendata"
|
|
1741
|
+
})], J.prototype, "flagOpendata", void 0), t([l({
|
|
1742
|
+
type: Boolean,
|
|
1743
|
+
attribute: "hide-dataset-button"
|
|
1744
|
+
})], J.prototype, "hideDatasetButton", void 0), t([l({
|
|
1745
|
+
type: Boolean,
|
|
1746
|
+
attribute: "hide-dataset-icons"
|
|
1747
|
+
})], J.prototype, "hideDatasetIcons", void 0), t([l({
|
|
1748
|
+
type: Boolean,
|
|
1749
|
+
attribute: "disable-dataset-modification"
|
|
1750
|
+
})], J.prototype, "disableDatasetModification", void 0), t([l({
|
|
1751
|
+
type: Boolean,
|
|
1752
|
+
attribute: "hide-selected-datasets"
|
|
1753
|
+
})], J.prototype, "hideSelectedDatasets", void 0), t([l({
|
|
1754
|
+
type: Boolean,
|
|
1755
|
+
attribute: "disable-column-mentions"
|
|
1756
|
+
})], J.prototype, "disableColumnMentions", void 0), t([l({
|
|
1757
|
+
type: Boolean,
|
|
1758
|
+
attribute: "require-dataset"
|
|
1759
|
+
})], J.prototype, "requireDataset", void 0), t([l({ type: String })], J.prototype, "agent", void 0), t([l({ type: String })], J.prototype, "task", void 0), t([l({
|
|
1760
|
+
type: String,
|
|
1761
|
+
attribute: "model-preference"
|
|
1762
|
+
})], J.prototype, "modelPreference", void 0), t([l({ attribute: !1 })], J.prototype, "chatSession", void 0), t([l({
|
|
1763
|
+
type: String,
|
|
1764
|
+
attribute: "conversation-id"
|
|
1765
|
+
})], J.prototype, "conversationId", void 0), t([l({
|
|
1766
|
+
type: Object,
|
|
1767
|
+
attribute: "chart"
|
|
1768
|
+
})], J.prototype, "chart", void 0), t([l({ type: Object })], J.prototype, "dashboard", void 0), t([l({
|
|
1769
|
+
type: String,
|
|
1770
|
+
attribute: "current-screen-mode"
|
|
1771
|
+
})], J.prototype, "currentScreenMode", void 0), t([l({
|
|
1772
|
+
type: String,
|
|
1773
|
+
attribute: "locale-id"
|
|
1774
|
+
})], J.prototype, "localeId", void 0), t([l({
|
|
1775
|
+
type: String,
|
|
1776
|
+
attribute: "timezone-id"
|
|
1777
|
+
})], J.prototype, "timezoneId", void 0), t([l({
|
|
1778
|
+
type: String,
|
|
1779
|
+
attribute: "api-version"
|
|
1780
|
+
})], J.prototype, "apiVersion", void 0), t([l({ converter: { fromAttribute: (e) => e !== "false" && e !== null } })], J.prototype, "stream", void 0), t([l({
|
|
1781
|
+
type: String,
|
|
1782
|
+
attribute: "loading-message"
|
|
1783
|
+
})], J.prototype, "loadingMessage", void 0), t([l({
|
|
1784
|
+
type: String,
|
|
1785
|
+
attribute: "initial-prompt"
|
|
1786
|
+
})], J.prototype, "initialPrompt", void 0), t([u()], J.prototype, "_textareaValue", void 0), customElements.get("luzmo-ai-chat") || customElements.define("luzmo-ai-chat", J);
|
|
1787
|
+
//#endregion
|
|
1788
|
+
export { qe as _, K as a, He as b, A as c, N as d, Ze as f, O as g, k as h, ut as i, M as l, Je as m, dt as n, G as o, Ye as p, lt as r, et as s, J as t, j as u, Ke as v, Ue as y };
|