@luzmo/analytics-components-kit 1.2.1 → 1.4.0
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/README.md +8 -3
- package/angular/components/add-to-dashboard.ts +20 -6
- package/angular/components/data-fields-select.ts +5 -0
- package/angular/components/interactive-viz-item.ts +89 -24
- package/angular/components/item-grid-item-actions-menu.ts +5 -0
- package/angular/components/item-grid.ts +7 -0
- package/angular/components/item-option-color-picker.ts +28 -28
- package/angular/components/item-option-guidelines.ts +22 -1
- package/angular/components/item-option-multi-language-field.ts +7 -7
- package/angular/components/item-option-number-field.ts +14 -14
- package/angular/components/item-option-positions-number-field.ts +14 -14
- package/angular/components/item-option-radio-button-group.ts +7 -7
- package/angular/components/item-option-text-field.ts +7 -7
- package/angular/components/item-slot-picker-panel.ts +1 -1
- package/angular/components/item-slot-picker.ts +7 -7
- package/angular/esm/components/add-to-dashboard.d.ts +8 -4
- package/angular/esm/components/add-to-dashboard.js +23 -7
- package/angular/esm/components/data-fields-select.d.ts +2 -0
- package/angular/esm/components/data-fields-select.js +4 -0
- package/angular/esm/components/interactive-viz-item.d.ts +32 -11
- package/angular/esm/components/interactive-viz-item.js +99 -28
- package/angular/esm/components/item-grid-item-actions-menu.d.ts +2 -0
- package/angular/esm/components/item-grid-item-actions-menu.js +4 -0
- package/angular/esm/components/item-grid.d.ts +3 -1
- package/angular/esm/components/item-grid.js +9 -1
- package/angular/esm/components/item-option-color-picker.d.ts +10 -10
- package/angular/esm/components/item-option-color-picker.js +34 -34
- package/angular/esm/components/item-option-guidelines.d.ts +8 -2
- package/angular/esm/components/item-option-guidelines.js +26 -2
- package/angular/esm/components/item-option-multi-language-field.d.ts +3 -3
- package/angular/esm/components/item-option-multi-language-field.js +10 -10
- package/angular/esm/components/item-option-number-field.d.ts +5 -5
- package/angular/esm/components/item-option-number-field.js +18 -18
- package/angular/esm/components/item-option-positions-number-field.d.ts +5 -5
- package/angular/esm/components/item-option-positions-number-field.js +18 -18
- package/angular/esm/components/item-option-radio-button-group.d.ts +3 -3
- package/angular/esm/components/item-option-radio-button-group.js +10 -10
- package/angular/esm/components/item-option-text-field.d.ts +3 -3
- package/angular/esm/components/item-option-text-field.js +10 -10
- package/angular/esm/components/item-slot-picker-panel.d.ts +1 -1
- package/angular/esm/components/item-slot-picker-panel.js +1 -1
- package/angular/esm/components/item-slot-picker.d.ts +3 -3
- package/angular/esm/components/item-slot-picker.js +9 -9
- package/angular/package.json +2 -2
- package/components/add-to-dashboard/dashboard-actions.d.ts +2 -1
- package/components/add-to-dashboard/index.cjs +1 -1
- package/components/add-to-dashboard/index.js +1 -1
- package/components/{add-to-dashboard-NwsCPIlg.cjs → add-to-dashboard-BtzTZdjN.cjs} +1 -1
- package/components/{add-to-dashboard-NcVHlqrc.js → add-to-dashboard-Bu6S3qVz.js} +125 -120
- package/components/chart-helpers-BHxQbLBw.cjs +20 -0
- package/components/{chart-helpers-Dng_LGfq.js → chart-helpers-BKeMLhov.js} +53 -39
- package/components/filters/index.cjs +1 -1
- package/components/filters/index.js +1 -1
- package/components/{filters-CxIzuI5q.js → filters-DEpmh9Nj.js} +113 -102
- package/components/filters-LDXhe1Bp.cjs +187 -0
- package/components/index.cjs +1 -1
- package/components/index.js +6 -6
- package/components/interactive-viz-item/helpers/chart-helpers.d.ts +2 -1
- package/components/interactive-viz-item/index.cjs +1 -1
- package/components/interactive-viz-item/index.d.ts +1 -1
- package/components/interactive-viz-item/index.js +3 -3
- package/components/interactive-viz-item/interactive-viz-item.d.ts +47 -1
- package/components/interactive-viz-item/types.d.ts +4 -0
- package/components/interactive-viz-item-Cc3Ix95e.js +630 -0
- package/components/interactive-viz-item-SF12d97t.cjs +269 -0
- package/components/item-grid/item-grid.d.ts +1 -0
- 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/item-slot-picker-panel.d.ts +19 -1
- package/components/item-slot-picker-panel-Cw3UCK03.cjs +84 -0
- package/components/{item-slot-picker-panel-fJqEmxeD.js → item-slot-picker-panel-DprM9Rli.js} +64 -33
- package/custom-elements.json +3051 -2531
- package/grid-core/item-grid-base.d.ts +5 -4
- package/package.json +2 -2
- package/react/package.json +2 -2
- package/standalone/add-to-dashboard.js +40 -40
- package/standalone/chunks/{chart-helpers-DsIGsaDc.js → chart-helpers-DZsidiCl.js} +2 -2
- package/standalone/chunks/{choropleth-map-options.config-rUJsEJcm.js → choropleth-map-options.config-CDMjKnJD.js} +1 -1
- package/standalone/chunks/{color-range-utils-DxOtqAKB.js → color-range-utils-BVyHBRiq.js} +1 -1
- package/standalone/chunks/data-broker-DpSrH3IP.js +2 -0
- package/standalone/chunks/de-BkB0q1Eg.js +2 -0
- package/standalone/chunks/display-settings-binning-DhHlclWH.js +38 -0
- package/standalone/chunks/display-settings-datetime-C8xvOvi4.js +199 -0
- package/standalone/chunks/display-settings-grand-totals-CUpigDcs.js +26 -0
- package/standalone/chunks/display-settings-numeric-BLWF54Jx.js +172 -0
- package/standalone/chunks/display-settings-period-over-period-COd4tvUw.js +209 -0
- package/standalone/chunks/embed-Bv1ps-EM.js +260 -0
- package/standalone/chunks/en-DNsyAwgq.js +2 -0
- package/standalone/chunks/en-GB-Di3OzVdL.js +2 -0
- package/standalone/chunks/en-US-DNsyAwgq.js +2 -0
- package/standalone/chunks/es-Bo0jStZn.js +2 -0
- package/standalone/chunks/{filters-DKgJcQGP.js → filters-lhg_WVDK.js} +108 -108
- package/standalone/chunks/{formula-codemirror-BbyvNEVD.js → formula-codemirror-DZMzLE2I.js} +17 -17
- package/standalone/chunks/fr-Co_qVhhV.js +2 -0
- package/standalone/chunks/{heat-map-options.config-D93AeYFi.js → heat-map-options.config-DDQMD38W.js} +1 -1
- package/standalone/chunks/{heat-table-options.config-ZVML76FK.js → heat-table-options.config-B4K0Ygug.js} +1 -1
- package/standalone/chunks/{is-same-option-value-Di-A7Wmg.js → is-same-option-value-7kXNF4st.js} +1 -1
- package/standalone/chunks/item-option-action-button-group-Bl1HR1JK.js +35 -0
- package/standalone/chunks/item-option-base-DF24wTyv.js +38 -0
- package/standalone/chunks/item-option-color-palette-picker-MkIIn56p.js +22 -0
- package/standalone/chunks/item-option-color-picker-CxosMo_p.js +19 -0
- package/standalone/chunks/item-option-color-range-C7C70r4J.js +83 -0
- package/standalone/chunks/item-option-guidelines-iu8yWRzr.js +120 -0
- package/standalone/chunks/{item-option-multi-language-field-DPPpN2qg.js → item-option-multi-language-field-foanqCdr.js} +1 -1
- package/standalone/chunks/{item-option-number-field-CkqJjInE.js → item-option-number-field-ByVD4oq0.js} +1 -1
- package/standalone/chunks/item-option-panel-Bya-K7HH.js +316 -0
- package/standalone/chunks/{item-option-picker-BnwQPT9A.js → item-option-picker-CqNNVIML.js} +1 -1
- package/standalone/chunks/item-option-position-picker-BjCFVtDH.js +14 -0
- package/standalone/chunks/item-option-positions-number-field-BJJtXZL-.js +31 -0
- package/standalone/chunks/{item-option-radio-button-group-BkymJq3E.js → item-option-radio-button-group-C5bxsD85.js} +1 -1
- package/standalone/chunks/item-option-slider-DUXWz70B.js +18 -0
- package/standalone/chunks/item-option-switch-BHyJuOkP.js +12 -0
- package/standalone/chunks/{item-option-text-field-D7bkuhsv.js → item-option-text-field-rBZY9OX4.js} +1 -1
- package/standalone/chunks/{item-slot-picker-panel-D4BMxGs9.js → item-slot-picker-panel-BM82vSXi.js} +101 -99
- package/standalone/chunks/load-data-fields-for-datasets-DS9O1oyy.js +25 -0
- package/standalone/chunks/localize-DLl7tgQp.js +2 -0
- package/standalone/chunks/localized-decorator-DosMCCQo.js +2 -0
- package/standalone/chunks/{version-BW4Ixl63.js → localized-mixin-BWJj88bd.js} +1 -1
- package/standalone/chunks/nl-CQz2jrVx.js +2 -0
- package/standalone/chunks/{option-interaction-controller-BslAXAHF.js → option-interaction-controller-BuwRr21c.js} +1 -1
- package/standalone/chunks/{route-map-options.config-Dwy0JSVq.js → route-map-options.config-CGBkHnhM.js} +1 -1
- package/standalone/chunks/{spike-map-options.config-DFmuNxym.js → spike-map-options.config-CSenlJ_F.js} +1 -1
- package/standalone/interactive-viz-item.js +88 -84
- package/standalone/item-grid.js +10 -10
- package/standalone/manifest.json +46 -46
- package/types.d.ts +1 -1
- package/components/chart-helpers-ufZ6VbXs.cjs +0 -20
- package/components/filters-BPbPFOu5.cjs +0 -187
- package/components/interactive-viz-item-CwRRaCZB.js +0 -583
- package/components/interactive-viz-item-CxdrGRKc.cjs +0 -265
- package/components/item-slot-picker-panel-BhhN54IM.cjs +0 -82
- package/standalone/chunks/data-broker-DXDyIrj_.js +0 -2
- package/standalone/chunks/de-mdZT2W1G.js +0 -2
- package/standalone/chunks/display-settings-binning-Byffw2Kl.js +0 -38
- package/standalone/chunks/display-settings-datetime-CD52d6Sv.js +0 -199
- package/standalone/chunks/display-settings-grand-totals-Cky99LX9.js +0 -26
- package/standalone/chunks/display-settings-numeric-C9ea7Tgc.js +0 -172
- package/standalone/chunks/display-settings-period-over-period-BLSGumkD.js +0 -209
- package/standalone/chunks/embed-CBu7iQRx.js +0 -231
- package/standalone/chunks/en-CSboh17P.js +0 -2
- package/standalone/chunks/en-GB-HoXKQBOY.js +0 -2
- package/standalone/chunks/en-US-CSboh17P.js +0 -2
- package/standalone/chunks/es-Di5D8JFd.js +0 -2
- package/standalone/chunks/fr-DZku7iB9.js +0 -2
- package/standalone/chunks/item-option-action-button-group-BEAwPHVw.js +0 -35
- package/standalone/chunks/item-option-base-CRUxNhJQ.js +0 -38
- package/standalone/chunks/item-option-color-palette-picker-CBz61iZb.js +0 -22
- package/standalone/chunks/item-option-color-picker-lLvBPnKA.js +0 -19
- package/standalone/chunks/item-option-color-range-BqeatOei.js +0 -83
- package/standalone/chunks/item-option-guidelines-Cop8rM8y.js +0 -120
- package/standalone/chunks/item-option-panel-CzSKFCVl.js +0 -316
- package/standalone/chunks/item-option-position-picker-Bkc4JvJX.js +0 -14
- package/standalone/chunks/item-option-positions-number-field-Dr_315TE.js +0 -31
- package/standalone/chunks/item-option-slider-K_bsNci8.js +0 -18
- package/standalone/chunks/item-option-switch-DeihDHhM.js +0 -12
- package/standalone/chunks/load-data-fields-for-datasets-ClctSj6y.js +0 -25
- package/standalone/chunks/localize-DXRmGRe-.js +0 -2
- package/standalone/chunks/localized-decorator-DJVBmJVH.js +0 -2
- package/standalone/chunks/nl-CViTevL3.js +0 -2
|
@@ -106,6 +106,7 @@ export declare class ItemGridBase extends LuzmoElement {
|
|
|
106
106
|
private _gridElement;
|
|
107
107
|
private _gridItemElements;
|
|
108
108
|
private _grid?;
|
|
109
|
+
/** Renders an item whose type has no renderer registered with `registerRenderer`. */
|
|
109
110
|
defaultRenderer: GridItemRenderer;
|
|
110
111
|
private _activeItemElement?;
|
|
111
112
|
private _activeItemActionToggle?;
|
|
@@ -159,6 +160,7 @@ export declare class ItemGridBase extends LuzmoElement {
|
|
|
159
160
|
* Get the GridStack instance
|
|
160
161
|
*/
|
|
161
162
|
get grid(): GridStack | undefined;
|
|
163
|
+
/** The grid items paired with their rendered grid elements. */
|
|
162
164
|
get gridItems(): {
|
|
163
165
|
item: GridItemData;
|
|
164
166
|
element: HTMLElement;
|
|
@@ -200,11 +202,10 @@ export declare class ItemGridBase extends LuzmoElement {
|
|
|
200
202
|
* Programmatically trigger a toggle action on a grid item.
|
|
201
203
|
* Toggles the state (active→inactive, inactive→active) unless `active` is explicitly set.
|
|
202
204
|
* Waits for any pending render to complete before checking for the element.
|
|
205
|
+
* Resolves to the new active state (true if activated, false if deactivated), or undefined if the item is not found.
|
|
203
206
|
* @param itemId - The ID of the grid item
|
|
204
207
|
* @param action - The action name to trigger
|
|
205
|
-
* @param options - Optional configuration
|
|
206
|
-
* @param options.active - Force active state (true/false). If omitted, toggles the current state.
|
|
207
|
-
* @returns The new active state (true if activated, false if deactivated), or undefined if item not found
|
|
208
|
+
* @param options - Optional configuration. Set `active` to force the active state (true/false); if omitted, toggles the current state.
|
|
208
209
|
*/
|
|
209
210
|
triggerItemAction(itemId: string, action: string, options?: {
|
|
210
211
|
active?: boolean;
|
|
@@ -215,7 +216,7 @@ export declare class ItemGridBase extends LuzmoElement {
|
|
|
215
216
|
private _triggerControlledItemAction;
|
|
216
217
|
/**
|
|
217
218
|
* Deactivate all active items and dispatch deactivation events.
|
|
218
|
-
*
|
|
219
|
+
* Returns the number of items that were deactivated.
|
|
219
220
|
*/
|
|
220
221
|
deactivateItems(): number;
|
|
221
222
|
private _renderGrid;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@luzmo/analytics-components-kit",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/cumulio-internal/analytics-components-kit.git"
|
|
@@ -346,7 +346,7 @@
|
|
|
346
346
|
"@lit/context": "^1.1.5",
|
|
347
347
|
"@lit/localize": "^0.12.2",
|
|
348
348
|
"@lit/task": "^1.0.1",
|
|
349
|
-
"@luzmo/embed": "^7.5.0",
|
|
349
|
+
"@luzmo/embed": "^7.5.0 || ^8.0.0",
|
|
350
350
|
"@luzmo/icons": "^1.0.1-alpha.49",
|
|
351
351
|
"@luzmo/lucero": "^2.6.1",
|
|
352
352
|
"colorjs.io": "^0.5.2",
|
package/react/package.json
CHANGED
|
@@ -29,9 +29,9 @@
|
|
|
29
29
|
"peerDependencies": {
|
|
30
30
|
"@lit/react": "^1.0.6",
|
|
31
31
|
"react": "^18.0.0 || ^19.0.0",
|
|
32
|
-
"@luzmo/analytics-components-kit": "^1.
|
|
32
|
+
"@luzmo/analytics-components-kit": "^1.4.0"
|
|
33
33
|
},
|
|
34
|
-
"version": "1.
|
|
34
|
+
"version": "1.4.0",
|
|
35
35
|
"repository": {
|
|
36
36
|
"type": "git",
|
|
37
37
|
"url": "git+https://github.com/cumulio-internal/analytics-components-kit.git"
|
|
@@ -19,44 +19,44 @@
|
|
|
19
19
|
*
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
|
-
import{a as e,i as t,n,r,t as i}from"./chunks/version-BW4Ixl63.js";import{t as a}from"./chunks/localized-decorator-DJVBmJVH.js";import{t as o}from"./chunks/luzmoAngleDown-PNrItYzK.js";import{t as s}from"./chunks/luzmoAngleLeft-ebJO7ROy.js";import{t as c}from"./chunks/luzmoArrowsHorizontal-TohKbcQD.js";import{t as l}from"./chunks/luzmoPlus-Dyrrz0v8.js";import{d as u,f as d,o as f,p}from"./chunks/chart-helpers-DsIGsaDc.js";import{t as m}from"./chunks/data-broker-DXDyIrj_.js";import{t as h}from"./chunks/localize-DXRmGRe-.js";import{html as g,ifDefined as _,nothing as v,property as y,query as b,state as x,unsafeCSS as S}from"https://cdn.jsdelivr.net/npm/@luzmo/lucero@2.6.1/standalone/lit.js";import"https://cdn.jsdelivr.net/npm/@luzmo/lucero@2.6.1/standalone/action-button.js";import"https://cdn.jsdelivr.net/npm/@luzmo/lucero@2.6.1/standalone/button.js";import"https://cdn.jsdelivr.net/npm/@luzmo/lucero@2.6.1/standalone/checkbox.js";import"https://cdn.jsdelivr.net/npm/@luzmo/lucero@2.6.1/standalone/divider.js";import"https://cdn.jsdelivr.net/npm/@luzmo/lucero@2.6.1/standalone/field-group.js";import"https://cdn.jsdelivr.net/npm/@luzmo/lucero@2.6.1/standalone/icon.js";import"https://cdn.jsdelivr.net/npm/@luzmo/lucero@2.6.1/standalone/menu.js";import"https://cdn.jsdelivr.net/npm/@luzmo/lucero@2.6.1/standalone/notice.js";import"https://cdn.jsdelivr.net/npm/@luzmo/lucero@2.6.1/standalone/overlay.js";import"https://cdn.jsdelivr.net/npm/@luzmo/lucero@2.6.1/standalone/popover.js";import"https://cdn.jsdelivr.net/npm/@luzmo/lucero@2.6.1/standalone/progress-circle.js";import"https://cdn.jsdelivr.net/npm/@luzmo/lucero@2.6.1/standalone/search.js";import"https://cdn.jsdelivr.net/npm/@luzmo/lucero@2.6.1/standalone/tooltip.js";var C={icon:[32,32,`m9.3 7.3-9 9a1 1 0 0 0 0 1.4l9 9c1 1 2.3-.5 1.4-1.4L3.4 18H31c1.3 0 1.3-2 0-2H3.4l7.3-7.3c1-1-.5-2.3-1.4-1.4Z`],name:`arrow-left`},w={icon:[32,32,`m22.7 7.3 9 9c.4.4.4 1 0 1.4l-9 9c-1 1-2.4-.5-1.4-1.4l7.3-7.3H1c-1.3 0-1.3-2 0-2h27.6l-7.3-7.3c-1-1 .5-2.3 1.4-1.4z`],name:`arrow-right`},T={icon:[14,32,`m3.7 8.2 8 7a1 1 0 0 1 0 1.6l-8 7c-1 .8-2.3-.7-1.4-1.6L9.5 16 2.3 9.8c-1-1 .4-2.4 1.4-1.6z`],name:`angle-right`},E={icon:[32,32,`M13.1 2.05.53 26.55C-.797 29.136.63 32 4.43 32H27.6c3.8 0 5.23-2.865 3.9-5.45L18.9 2.05c-1.423-2.745-4.437-2.686-5.8 0zm4 .9 12.6 24.5c.72 1.43.04 2.55-2.1 2.55H4.43c-2.14 0-2.82-1.12-2.1-2.55L14.9 2.95c.614-1.268 1.586-1.268 2.2 0zM15 11v10c0 1.3 2 1.3 2 0V11c0-1.305-2-1.305-2 0zm-.5 14.5c0 1.961 3 1.961 3 0s-3-1.961-3 0z`],name:`alert-outline`},D={icon:[32,32,`m14 26c-1.4 0-1.4 2 0 2h4c1.4 0 1.4-2 0-2zM10 2C7.8 2 6 3.8 6 6v22c0 2.2 1.8 4 4 4h12c2.2 0 4-1.8 4-4V6C26 3.8 24.2 2 22 2Zm0 2h12c1.1 0 2 0.9 2 2v22c0 1.1-0.9 2-2 2H10C8.9 30 8 29.1 8 28V6C8 4.9 8.9 4 10 4Z`],name:`mobile`},O={icon:[32,32,`m12 26c-1.4 0-1.4 2 0 2h8c1.4 0 1.4-2 0-2zM6 0C3.8 0 2 1.8 2 4v24c0 2.2 1.8 4 4 4h20c2.2 0 4-1.8 4-4V4C30 1.8 28.2 0 26 0Zm0 2h20c1.1 0 2 0.9 2 2v24c0 1.1-0.9 2-2 2H6C4.9 30 4 29.1 4 28V4C4 2.9 4.9 2 6 2Z`],name:`tablet`},ee={icon:[40,32,`M7 2C5.4 2 4 3.4 4 5v19c0 1.6 1.4 3 3 3h26c1.6 0 3-1.4 3-3V5C36 3.4 34.6 2 33 2Zm0 2h26c0.6 0 1 0.4 1 1v19c0 0.6-0.4 1-1 1H7C6.4 25 6 24.6 6 24V5C6 4.4 6.4 4 7 4ZM1 25a1 1 0 0 0-1 1v1c0 2.7 2.3 5 5 5h30c2.7 0 5-2.3 5-5v-1a1 1 0 0 0-1-1zm1 2h36c0 1.7-1.3 3-3 3H5C3.3 30 2 28.7 2 27Z`],name:`laptop`},te={icon:[40,32,`m18.2 22-2.2 8.8 1.9 0.5L19.8 24h0.4l1.8 7.2 1.9-0.5L21.8 22ZM11 30a1 1 0 0 0-1 1 1 1 0 0 0 1 1h18a1 1 0 0 0 1-1 1 1 0 0 0-1-1zM3 0C1.4 0 0 1.4 0 3v18c0 1.6 1.4 3 3 3h34c1.6 0 3-1.4 3-3V3C40 1.4 38.6 0 37 0Zm0 2h34c0.6 0 1 0.4 1 1v18c0 0.6-0.4 1-1 1H3C2.4 22 2 21.6 2 21V3C2 2.4 2.4 2 3 2Z`],name:`desktop`},ne={icon:[32,32,`M24 0C22 0 20 0.8 18.5 2.2A0.9 0.9 0 0 0 18.5 2.2 0.9 0.9 0 0 0 18.4 2.3C18.4 2.3 18.4 2.3 18.3 2.3A0.9 0.9 0 0 0 18.2 2.5 0.9 0.9 0 0 0 18.2 2.5L13.2 7.5A0.9 0.9 0 0 0 13.2 7.5 0.9 0.9 0 0 0 13.1 7.6C13.1 7.6 13.1 7.6 13.1 7.6L13 7.7A0.9 0.9 0 0 0 12.8 8.1 0.9 0.9 0 0 0 12.8 8.1C11.7 9.5 11 11.2 11 13 11 16.4 13.2 19.5 16.5 20.6A0.9 0.9 0 0 0 17.6 20 0.9 0.9 0 0 0 17 18.9C14.5 18 12.8 15.7 12.8 13 12.8 11.5 13.4 10 14.4 8.9L19.6 3.6A0.9 0.9 0 0 0 19.7 3.6C20.8 2.5 22.4 1.8 24 1.8 27.4 1.8 30.2 4.6 30.2 8 30.2 9.6 29.5 11.2 28.4 12.3A0.9 0.9 0 0 0 28.4 12.4L23.4 17.4A0.9 0.9 0 0 0 23.4 18.6 0.9 0.9 0 0 0 24.6 18.6L29.5 13.8A0.9 0.9 0 0 0 29.7 13.7C29.7 13.6 29.7 13.6 29.7 13.6A0.9 0.9 0 0 0 29.8 13.5 0.9 0.9 0 0 0 29.8 13.4C31.2 12 32 10 32 8 32 3.6 28.4 0 24 0zM15.2 11.4A0.9 0.9 0 0 0 14.4 12 0.9 0.9 0 0 0 15 13.1C17.5 14 19.2 16.3 19.2 19 19.2 20.5 18.6 22 17.6 23.1L12.4 28.4A0.9 0.9 0 0 0 12.3 28.4C11.2 29.5 9.6 30.2 8 30.2 4.6 30.2 1.8 27.4 1.8 24 1.8 22.4 2.5 20.8 3.6 19.7A0.9 0.9 0 0 0 3.6 19.6L8.6 14.6A0.9 0.9 0 0 0 8.6 13.4 0.9 0.9 0 0 0 7.4 13.4L2.5 18.2A0.9 0.9 0 0 0 2.3 18.3C2.3 18.4 2.3 18.4 2.3 18.4A0.9 0.9 0 0 0 2.2 18.5 0.9 0.9 0 0 0 2.2 18.6C0.8 20 0 22 0 24 0 28.4 3.6 32 8 32 10 32 12 31.2 13.5 29.8 13.5 29.8 13.5 29.8 13.5 29.8A0.9 0.9 0 0 0 13.6 29.7C13.6 29.7 13.6 29.7 13.7 29.7A0.9 0.9 0 0 0 13.8 29.5 0.9 0.9 0 0 0 13.8 29.5L18.8 24.5 18.8 24.5A0.9 0.9 0 0 0 18.9 24.4C18.9 24.4 18.9 24.4 18.9 24.4L19 24.3A0.9 0.9 0 0 0 19.2 23.9C19.2 23.9 19.2 23.9 19.2 23.9 20.3 22.5 21 20.8 21 19 21 15.6 18.8 12.5 15.5 11.4A0.9 0.9 0 0 0 15.2 11.4z`],name:`link`},re={icon:[32,32,`M16 0a16 16 0 1 0 0 32 16 16 0 0 0 0-32Zm0 2a14 14 0 0 1 14 14 14 14 0 0 1-14 14A14 14 0 0 1 2 16 14 14 0 0 1 16 2Zm5.2 8.4-6.3 9-4.2-4.1c-1-1-2.3.5-1.4 1.4l5 5a1 1 0 0 0 1.5-.1l7-10c.8-1.1-.9-2.2-1.6-1.2z`],name:`check-circle-outline`},k=`:host{align-items:flex-end;gap:var(--luzmo-spacing-2);font-family:var(--luzmo-font-family);flex-direction:column;display:inline-flex}.trigger-spinner{--luzmo-progress-circle-size:var(--luzmo-icon-size-xs)}.trigger-chevron{margin-inline-start:var(--luzmo-spacing-1)}.picker{gap:var(--luzmo-spacing-3);width:var(--luzmo-add-to-dashboard-picker-width,var(--add-to-dashboard-picker-width));max-width:90vw;padding:var(--luzmo-spacing-2);color:var(--luzmo-font-color);font-size:var(--luzmo-font-size-s);flex-direction:column;display:flex}luzmo-search{width:100%}.list{max-height:var(--luzmo-add-to-dashboard-list-max-height,var(--add-to-dashboard-list-max-height));flex-direction:column;display:flex;overflow-y:auto}.menu{--luzmo-menu-max-height:none;flex:none;width:100%;overflow:visible}.create-row{--luzmo-menu-item-label-icon-color-default:var(--luzmo-primary)}.thumbnail{object-fit:cover;border:var(--luzmo-border-width) solid var(--luzmo-border-color);border-radius:var(--luzmo-border-radius);width:2.75rem;height:2rem}.drill-in{color:var(--luzmo-font-color-extra-dimmed)}.header{align-items:center;gap:var(--luzmo-spacing-2);display:flex}.header-title{font-weight:var(--luzmo-font-weight-bold);text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.empty{align-items:center;gap:var(--luzmo-spacing-3);padding:var(--luzmo-spacing-4);text-align:center;flex-direction:column;display:flex}.loading{padding:var(--luzmo-spacing-3);justify-content:center;display:flex}.screen-modes{gap:var(--luzmo-spacing-2);flex-direction:column;display:flex}.screen-mode{align-items:center;gap:var(--luzmo-spacing-2);display:flex}.screen-mode-size{color:var(--luzmo-font-color-extra-dimmed)}.footer{justify-content:flex-end;display:flex}.status{justify-content:flex-end;width:0;min-width:100%;display:flex}.status:empty{display:none}.alert{flex:none;inline-size:max-content}.alert-body{align-items:center;gap:var(--luzmo-spacing-3);block-size:1lh;min-inline-size:0;display:flex}.alert-text{min-inline-size:0;font-weight:var(--luzmo-font-weight-semibold);white-space:pre;display:flex}.alert[variant=negative] .alert-text{white-space:normal}.alert-name{min-inline-size:0;font-weight:var(--luzmo-font-weight-bold);text-overflow:ellipsis;white-space:nowrap;unicode-bidi:plaintext;overflow:hidden}.alert-open{flex:none}:host{--add-to-dashboard-picker-width:18rem;--add-to-dashboard-list-max-height:16rem}`,A=`0.1.0`,j=[`id`,`name`,`contents`,`modified_at`,`is_variant`,`original_id`],M=/* @__PURE__ */ new Set([`designer`,`owner`]),N=`flag_dashboard_variants`,P=[`desktop`,`tablet`,`mobile`];async function F(e,t,n){let r=[],i=t,a=0;for(let t of e){let e=n-r.length,o=await t(i,Math.max(e,1));e>0&&r.push(...o.rows.slice(0,e)),i=Math.max(0,i-o.count),a+=o.count}return{rows:r,total:a}}async function I(e){let t=await e.fetchApi(`/user`,{action:`get`,version:A,find:{where:{id:`me`},attributes:[`id`,`flags`]}});return{id:t.rows?.[0]?.id??``,flags:t.rows?.[0]?.flags??[]}}async function L(e,t){return(await e.fetchApi(`/authorization`,{action:`get`,version:A,find:{where:{id:t}}})).rows?.[0]}async function R(e,t,n){let r={...t,where:{...t.where,type:`dashboard`}},i=await e.fetchApi(`/securable`,{action:`get`,version:A,find:r},{signal:n});return{rows:i.rows??[],count:i.count??i.rows?.length??0}}function z(e){let t={modifyIds:/* @__PURE__ */ new Set,useOnlyIds:/* @__PURE__ */ new Set};for(let n of e?.access?.dashboards??[])n.rights?.Modify?t.modifyIds.add(n.id):n.rights?.Use&&t.useOnlyIds.add(n.id);return t}function B(){return{version:i,syncScreenModes:!0,views:P.map(e=>({screenModus:e,options:{theme:{id:`default`}},filterGroups:[],items:[]})),timezone:{type:`fixed`,id:`UTC`}}}function V(e){return e?{search:{match_types:[`name`,`description`],keyphrase:e,securable_types:[`dashboard`]}}:{}}function H(e,t){return{include:[{model:`User`,as:`allUsers`,attributes:[],required:!0,where:{id:e,...Object.fromEntries(Object.entries(t).map(([e,t])=>[`securableAccessRight.${e}`,t]))}}]}}async function U(e){let n=new m({apiUrl:e.apiUrl,authKey:e.authKey,authToken:e.authToken,skipNetworkListeners:!0}),[r,i]=await Promise.all([I(n),L(n,e.authKey)]),a=z(i),o=i?.type!==`embed`||M.has(i.role??``),s=!!r.id&&r.flags.includes(N),c=[...a.modifyIds,...s?a.useOnlyIds:[]],l=c.length>0?{id:{notIn:c}}:{},u=(t,n=!1)=>{let r=[...new Set((t.contents?.views??[]).map(e=>e.screenModus))];return{id:t.id,name:h(t.name??{},e.language),syncScreenModes:t.contents?.syncScreenModes!==!1,screenModes:r.length>0?r:[`desktop`],...n?{requiresVariant:n}:{}}},d,f=(e,t)=>async(r,i)=>{if(c.length===0)return{count:0,rows:[]};let o=r>0&&d?.search===e?d.rows:void 0;return o||(o=(await R(n,{where:{is_variant:!1,archived_at:null,id:{in:c}},attributes:j,...V(e)},t)).rows.map(e=>u(e,!a.modifyIds.has(e.id))).sort((e,t)=>e.name.localeCompare(t.name)),d={search:e,rows:o}),{count:o.length,rows:o.slice(r,r+i)}},p=(e,t,i,a)=>async(o,s)=>{let c=await R(n,{where:{is_variant:!1,archived_at:null,...l},attributes:j,...H(r.id,i),...V(e),limit:s,offset:o,order:[[`modified_at`,`desc`]]},t);return{count:c.count,rows:c.rows.map(e=>u(e,a))}},g=async(e,t,r,i)=>{await n.fetchApi(`/securable`,{action:`update`,version:A,id:e,properties:{append_item:{item:t,...r?.length?{screenModes:r}:{}}}},{signal:i})},_=async(e,t,r)=>{try{await g(e.id,t,r)}catch(t){throw await n.fetchApi(`/securable`,{action:`delete`,version:A,id:e.id}).catch(()=>void 0),t}},v=async(e,t)=>await n.fetchApi(`/securable`,{action:`create`,version:A,properties:{...e,type:`dashboard`},associations:t});return{async list(e,t){return r.id?await F([f(e.search,t.signal),...s?[p(e.search,t.signal,{flagUse:!0,flagModify:!1},!0)]:[],p(e.search,t.signal,{flagModify:!0},!1)],e.offset,e.limit):{rows:[],total:0}},async add(e,t,n,r){await g(e.id,t,n.screenModes,r.signal)},...o?{async create(t,n){let r=await v({name:n.name?{[e.language]:n.name}:{},contents:B()});return await _(r,t,void 0),u(r)}}:{},...s?{async listVariants(e,t){return(await R(n,{where:{is_variant:!0,original_id:e.id,archived_at:null},attributes:j,...H(r.id,{flagModify:!0}),order:[[`modified_at`,`desc`]]},t.signal)).rows.map(e=>u(e))}}:{},...s&&o?{async addToVariant(r,i,a){let o=(await R(n,{where:{id:r.id},attributes:[`id`,`name`,`contents`]})).rows[0];if(!o?.contents)throw Error(t(`The dashboard was not found.`,{desc:`Adding the chart to a variant failed because the original dashboard could not be loaded`}));let s=o.name??{},c=await v({name:a.name?{...s,[e.language]:a.name}:s,contents:o.contents},[{role:`original`,id:r.id}]);return await _(c,i,a.screenModes),u({...c,contents:c.contents??o.contents})}}:{}}}function W(e){let{theme:t,...n}=e.options??{};return{...f(e),options:n}}function G(e,t){let n=new Set(e),r=e.length+1;for(;n.has(t(r));)r+=1;return r}var K=20,q=300,J=8,Y=48,X=`__luzmo-new-dashboard`,Z=`__luzmo-new-variant`,Q=/* @__PURE__ */ new Map,ie=0,$=class extends n(d(p,{validSizes:Object.values(u)})){constructor(...e){super(...e),this.chart=null,this.dashboardActions=null,this.authKey=``,this.authToken=``,this.apiUrl=`https://api.luzmo.com`,this.placement=`bottom-end`,this.disabled=!1,this._open=!1,this._actions=null,this._step=`list`,this._rows=[],this._hasMore=!1,this._loading=!1,this._listFailed=!1,this._original=null,this._variants=[],this._variantsLoading=!1,this._variantsFailed=!1,this._pending=null,this._screenModes=[],this._saving=!1,this._status=null,this._triggerId=`add-to-dashboard-trigger-${++ie}`,this._search=``,this._actionsGeneration=0,this._reloadOnUpdate=!1}static get styles(){let e=super.styles??[];return[...Array.isArray(e)?e:[e],S(k)]}get _hasSource(){return!!this.dashboardActions||!!(this.authKey&&this.authToken)}connectedCallback(){super.connectedCallback(),this._status&&this._startFittingAlert()}disconnectedCallback(){super.disconnectedCallback(),this._handleClosed(),this._actionsGeneration+=1,this._saveAbort?.abort(),this._stopFittingAlert()}willUpdate(e){super.willUpdate(e),(e.has(`dashboardActions`)||e.has(`authKey`)||e.has(`authToken`)||e.has(`apiUrl`)||e.has(`language`))&&(this._actions=null,this._actionsGeneration+=1,this._open&&(this._listAbort?.abort(),this._variantsAbort?.abort(),this._step=`list`,this._original=null,this._pending=null,this._rows=[],this._open=this._hasSource,this._reloadOnUpdate=this._hasSource)),e.has(`disabled`)&&this.disabled&&(this._open=!1),e.has(`chart`)&&!this.chart&&this._handleClosed()}updated(e){super.updated(e),this._reloadOnUpdate&&(this._reloadOnUpdate=!1,this._loadList()),e.has(`_step`)&&this._open&&this._focusStep(),e.has(`_status`)&&(this._status?this._startFittingAlert():this._stopFittingAlert())}get _alertContainer(){let e=this.getRootNode();return this.parentElement??(e instanceof ShadowRoot?e.host:null)}_startFittingAlert(){this._fitAlert();let e=this._alertContainer;!this._alertResizeObserver&&e&&(this._alertResizeObserver=new ResizeObserver(()=>this._fitAlert()),this._alertResizeObserver.observe(this),this._alertResizeObserver.observe(e))}_stopFittingAlert(){this._alertResizeObserver?.disconnect(),this._alertResizeObserver=void 0}_fitAlert(){let e=this._noticeElement,t=this._alertContainer;if(!e||!t)return;let n=this.getBoundingClientRect(),r=t.getBoundingClientRect(),i=Number.parseFloat(getComputedStyle(t).paddingInlineStart)||0,a=(this.isLTR?n.right-r.left:r.right-n.left)-i;e.style.setProperty(`--luzmo-notice-max-inline-size`,`${Math.max(0,a)}px`)}async _resolveActions(){if(this.dashboardActions)return this.dashboardActions;let e={apiUrl:this.apiUrl,authKey:this.authKey,authToken:this.authToken,language:this.language},t=JSON.stringify(e),n=Q.get(t);return n||(Q.clear(),n=U(e),Q.set(t,n),n.catch(()=>Q.delete(t))),await n}_dispatch(e,t){let n=new CustomEvent(e,{detail:t,bubbles:!0,composed:!0});this.dispatchEvent(n)}_displayName(e){return e.name.trim()||t(`Untitled dashboard`,{desc:`Fallback name of a dashboard without a name`})}_variantName(n,r){let i=this._displayName(n);return t(e`${i} (variant ${r})`,{desc:`Name of a new dashboard variant`})}_screenModeChoices(){return[{name:`mobile`,label:t(`Smartphone`,{desc:`Screen mode name`}),size:`< 768px`,icon:D},{name:`tablet`,label:t(`Tablet`,{desc:`Screen mode name`}),size:`≥ 768px`,icon:O},{name:`desktop`,label:t(`Desktop`,{desc:`Screen mode name`}),size:`≥ 1200px`,icon:ee},{name:`largeScreen`,label:t(`Large screen`,{desc:`Screen mode name`}),size:`≥ 1600px`,icon:te},{name:`fixed`,label:t(`Fixed width`,{desc:`Screen mode name`}),icon:c}]}async _handleOpened(e){e.target===e.currentTarget&&(this._open=!0,this._step=`list`,this._search=``,this._original=null,this._pending=null,this._rows=[],await this.updateComplete,this._searchElement?.focus(),await this._loadList())}async _loadList(){let e=this._actionsGeneration;this._loading=!0,this._listFailed=!1;try{let t=this._actions??await this._resolveActions();if(e!==this._actionsGeneration)return;this._actions=t}catch(t){if(!this.isConnected||e!==this._actionsGeneration)return;console.error(`Failed to resolve the add to dashboard actions:`,t),this._loading=!1,this._listFailed=!0;return}this.isConnected&&this._open&&await this._loadPage(!1)}_handleClosed(e){e&&e.target!==e.currentTarget||(this._open=!1,clearTimeout(this._searchTimer),this._listAbort?.abort(),this._variantsAbort?.abort())}async _loadPage(e){let t=this._actions;if(!t)return;this._listAbort?.abort();let n=new AbortController;this._listAbort=n,this._loading=!0,this._listFailed=!1,e||(this._rows=[]);try{let e=await t.list({search:this._search,offset:this._rows.length,limit:K},{signal:n.signal});if(n.signal.aborted)return;this._rows=[...this._rows,...e.rows],this._hasMore=e.total===void 0?e.rows.length===K:this._rows.length<e.total}catch(e){if(n.signal.aborted)return;console.error(`Failed to load dashboards:`,e),this._listFailed=!0}finally{n.signal.aborted||(this._loading=!1)}}_handleSearchInput(e){this._search=String(e.target?.value??``),clearTimeout(this._searchTimer),this._searchTimer=setTimeout(()=>void this._loadPage(!1),q)}_handleListScroll(e){let t=e.target;this._hasMore&&!this._loading&&t.scrollHeight-t.scrollTop-t.clientHeight<=Y&&this._loadPage(!0)}_menuValue(e){return e.stopPropagation(),e.target.value??``}_handleListChange(e){let t=this._menuValue(e);if(t===X){this._actions?.create&&this._save({kind:`create`});return}let n=this._rows.find(e=>e.id===t);n&&(n.requiresVariant?(this._original=n,this._step=`variants`,this._loadVariants()):this._selectTarget({kind:`add`,dashboard:n,isVariant:!1},n))}_handleVariantChange(e){let t=this._menuValue(e),n=this._original;if(!n)return;if(t===Z){if(!this._actions?.addToVariant)return;let e=this._variants.map(e=>this._displayName(e)),t=this._variantName(n,G(e,e=>this._variantName(n,e)));this._selectTarget({kind:`variant`,original:n,name:t},n);return}let r=this._variants.find(e=>e.id===t);r&&this._selectTarget({kind:`add`,dashboard:r,isVariant:!0},r)}_selectTarget(e,t){t.syncScreenModes!==!1||!t.screenModes?.length?this._save(e):(this._pending=e,this._screenModes=[...t.screenModes??[]],this._step=`screenModes`)}async _loadVariants(){let e=this._actions,t=this._original;if(this._variantsAbort?.abort(),this._variants=[],this._variantsLoading=!1,this._variantsFailed=!1,!e?.listVariants||!t)return;let n=new AbortController;this._variantsAbort=n,this._variantsLoading=!0;try{let r=await e.listVariants(t,{signal:n.signal});n.signal.aborted||(this._variants=r)}catch(e){n.signal.aborted||(console.error(`Failed to load dashboard variants:`,e),this._variantsFailed=!0)}finally{n.signal.aborted||(this._variantsLoading=!1)}}_handleBack(){this._step===`screenModes`&&this._original?this._step=`variants`:(this._step=`list`,this._original=null),this._pending=null}_toggleScreenMode(e){this._screenModes=this._screenModes.includes(e)?this._screenModes.filter(t=>t!==e):[...this._screenModes,e]}_handleConfirmScreenModes(){this._pending&&this._screenModes.length>0&&this._save(this._pending,{screenModes:[...this._screenModes]})}async _save(e,t={}){let n=this._actions;if(!n||!this.chart||this._saving)return;this._open=!1,this._saving=!0,this._setStatus(null),this._saveAbort=new AbortController;let r=W(this.chart),i={signal:this._saveAbort.signal};try{let a;if(e.kind===`create`&&n.create)a=await n.create(r,t,i);else if(e.kind===`variant`&&n.addToVariant)a=await n.addToVariant(e.original,r,{...t,name:e.name},i);else if(e.kind===`add`)a=await n.add(e.dashboard,r,t,i)||e.dashboard;else return;if(i.signal.aborted)return;this._setStatus({kind:`success`,dashboard:a,isVariant:e.kind===`variant`||e.kind===`add`&&e.isVariant,openDashboard:n.openDashboard?.bind(n)}),this._dispatch(`luzmo-chart-added`,{dashboard:a})}catch(e){if(i.signal.aborted)return;console.error(`Failed to add the chart to a dashboard:`,e),this._setStatus({kind:`error`,message:e instanceof Error&&e.message?e.message:void 0}),this._dispatch(`luzmo-chart-add-failed`,{error:e})}finally{this._saving=!1}await this.updateComplete,this.isConnected&&this._isFocusLost()&&this._focusTrigger()}_setStatus(e){this._status=e}_focusTrigger(){this._triggerElement?.focus()}_isFocusLost(){return!document.activeElement||document.activeElement===document.body}async _handleNoticeClose(e){e.stopPropagation();let t=e.currentTarget.matches(`:focus-within`);this._setStatus(null),await this.updateComplete,t&&this._isFocusLost()&&this._focusTrigger()}async _focusStep(){let e=this._step===`list`?this._searchElement:this._backElement;await e?.updateComplete,e?.focus()}_renderRow(e){return g`
|
|
22
|
+
import{i as e,n as t,r as n,t as r}from"./chunks/localized-mixin-BWJj88bd.js";import{t as i}from"./chunks/localized-decorator-DosMCCQo.js";import{t as a}from"./chunks/luzmoAngleDown-PNrItYzK.js";import{t as o}from"./chunks/luzmoAngleLeft-ebJO7ROy.js";import{t as s}from"./chunks/luzmoArrowsHorizontal-TohKbcQD.js";import{t as c}from"./chunks/luzmoPlus-Dyrrz0v8.js";import{S as l,b as u,s as d,x as f}from"./chunks/chart-helpers-DZsidiCl.js";import{t as p}from"./chunks/data-broker-DpSrH3IP.js";import{t as m}from"./chunks/localize-DLl7tgQp.js";import{html as h,ifDefined as g,nothing as _,property as v,query as y,state as b,unsafeCSS as x}from"https://cdn.jsdelivr.net/npm/@luzmo/lucero@2.6.1/standalone/lit.js";import"https://cdn.jsdelivr.net/npm/@luzmo/lucero@2.6.1/standalone/action-button.js";import"https://cdn.jsdelivr.net/npm/@luzmo/lucero@2.6.1/standalone/button.js";import"https://cdn.jsdelivr.net/npm/@luzmo/lucero@2.6.1/standalone/checkbox.js";import"https://cdn.jsdelivr.net/npm/@luzmo/lucero@2.6.1/standalone/divider.js";import"https://cdn.jsdelivr.net/npm/@luzmo/lucero@2.6.1/standalone/field-group.js";import"https://cdn.jsdelivr.net/npm/@luzmo/lucero@2.6.1/standalone/icon.js";import"https://cdn.jsdelivr.net/npm/@luzmo/lucero@2.6.1/standalone/menu.js";import"https://cdn.jsdelivr.net/npm/@luzmo/lucero@2.6.1/standalone/notice.js";import"https://cdn.jsdelivr.net/npm/@luzmo/lucero@2.6.1/standalone/overlay.js";import"https://cdn.jsdelivr.net/npm/@luzmo/lucero@2.6.1/standalone/popover.js";import"https://cdn.jsdelivr.net/npm/@luzmo/lucero@2.6.1/standalone/progress-circle.js";import"https://cdn.jsdelivr.net/npm/@luzmo/lucero@2.6.1/standalone/search.js";import"https://cdn.jsdelivr.net/npm/@luzmo/lucero@2.6.1/standalone/tooltip.js";var S={icon:[32,32,`m9.3 7.3-9 9a1 1 0 0 0 0 1.4l9 9c1 1 2.3-.5 1.4-1.4L3.4 18H31c1.3 0 1.3-2 0-2H3.4l7.3-7.3c1-1-.5-2.3-1.4-1.4Z`],name:`arrow-left`},C={icon:[32,32,`m22.7 7.3 9 9c.4.4.4 1 0 1.4l-9 9c-1 1-2.4-.5-1.4-1.4l7.3-7.3H1c-1.3 0-1.3-2 0-2h27.6l-7.3-7.3c-1-1 .5-2.3 1.4-1.4z`],name:`arrow-right`},w={icon:[14,32,`m3.7 8.2 8 7a1 1 0 0 1 0 1.6l-8 7c-1 .8-2.3-.7-1.4-1.6L9.5 16 2.3 9.8c-1-1 .4-2.4 1.4-1.6z`],name:`angle-right`},T={icon:[32,32,`M13.1 2.05.53 26.55C-.797 29.136.63 32 4.43 32H27.6c3.8 0 5.23-2.865 3.9-5.45L18.9 2.05c-1.423-2.745-4.437-2.686-5.8 0zm4 .9 12.6 24.5c.72 1.43.04 2.55-2.1 2.55H4.43c-2.14 0-2.82-1.12-2.1-2.55L14.9 2.95c.614-1.268 1.586-1.268 2.2 0zM15 11v10c0 1.3 2 1.3 2 0V11c0-1.305-2-1.305-2 0zm-.5 14.5c0 1.961 3 1.961 3 0s-3-1.961-3 0z`],name:`alert-outline`},E={icon:[32,32,`m14 26c-1.4 0-1.4 2 0 2h4c1.4 0 1.4-2 0-2zM10 2C7.8 2 6 3.8 6 6v22c0 2.2 1.8 4 4 4h12c2.2 0 4-1.8 4-4V6C26 3.8 24.2 2 22 2Zm0 2h12c1.1 0 2 0.9 2 2v22c0 1.1-0.9 2-2 2H10C8.9 30 8 29.1 8 28V6C8 4.9 8.9 4 10 4Z`],name:`mobile`},D={icon:[32,32,`m12 26c-1.4 0-1.4 2 0 2h8c1.4 0 1.4-2 0-2zM6 0C3.8 0 2 1.8 2 4v24c0 2.2 1.8 4 4 4h20c2.2 0 4-1.8 4-4V4C30 1.8 28.2 0 26 0Zm0 2h20c1.1 0 2 0.9 2 2v24c0 1.1-0.9 2-2 2H6C4.9 30 4 29.1 4 28V4C4 2.9 4.9 2 6 2Z`],name:`tablet`},ee={icon:[40,32,`M7 2C5.4 2 4 3.4 4 5v19c0 1.6 1.4 3 3 3h26c1.6 0 3-1.4 3-3V5C36 3.4 34.6 2 33 2Zm0 2h26c0.6 0 1 0.4 1 1v19c0 0.6-0.4 1-1 1H7C6.4 25 6 24.6 6 24V5C6 4.4 6.4 4 7 4ZM1 25a1 1 0 0 0-1 1v1c0 2.7 2.3 5 5 5h30c2.7 0 5-2.3 5-5v-1a1 1 0 0 0-1-1zm1 2h36c0 1.7-1.3 3-3 3H5C3.3 30 2 28.7 2 27Z`],name:`laptop`},te={icon:[40,32,`m18.2 22-2.2 8.8 1.9 0.5L19.8 24h0.4l1.8 7.2 1.9-0.5L21.8 22ZM11 30a1 1 0 0 0-1 1 1 1 0 0 0 1 1h18a1 1 0 0 0 1-1 1 1 0 0 0-1-1zM3 0C1.4 0 0 1.4 0 3v18c0 1.6 1.4 3 3 3h34c1.6 0 3-1.4 3-3V3C40 1.4 38.6 0 37 0Zm0 2h34c0.6 0 1 0.4 1 1v18c0 0.6-0.4 1-1 1H3C2.4 22 2 21.6 2 21V3C2 2.4 2.4 2 3 2Z`],name:`desktop`},ne={icon:[32,32,`M24 0C22 0 20 0.8 18.5 2.2A0.9 0.9 0 0 0 18.5 2.2 0.9 0.9 0 0 0 18.4 2.3C18.4 2.3 18.4 2.3 18.3 2.3A0.9 0.9 0 0 0 18.2 2.5 0.9 0.9 0 0 0 18.2 2.5L13.2 7.5A0.9 0.9 0 0 0 13.2 7.5 0.9 0.9 0 0 0 13.1 7.6C13.1 7.6 13.1 7.6 13.1 7.6L13 7.7A0.9 0.9 0 0 0 12.8 8.1 0.9 0.9 0 0 0 12.8 8.1C11.7 9.5 11 11.2 11 13 11 16.4 13.2 19.5 16.5 20.6A0.9 0.9 0 0 0 17.6 20 0.9 0.9 0 0 0 17 18.9C14.5 18 12.8 15.7 12.8 13 12.8 11.5 13.4 10 14.4 8.9L19.6 3.6A0.9 0.9 0 0 0 19.7 3.6C20.8 2.5 22.4 1.8 24 1.8 27.4 1.8 30.2 4.6 30.2 8 30.2 9.6 29.5 11.2 28.4 12.3A0.9 0.9 0 0 0 28.4 12.4L23.4 17.4A0.9 0.9 0 0 0 23.4 18.6 0.9 0.9 0 0 0 24.6 18.6L29.5 13.8A0.9 0.9 0 0 0 29.7 13.7C29.7 13.6 29.7 13.6 29.7 13.6A0.9 0.9 0 0 0 29.8 13.5 0.9 0.9 0 0 0 29.8 13.4C31.2 12 32 10 32 8 32 3.6 28.4 0 24 0zM15.2 11.4A0.9 0.9 0 0 0 14.4 12 0.9 0.9 0 0 0 15 13.1C17.5 14 19.2 16.3 19.2 19 19.2 20.5 18.6 22 17.6 23.1L12.4 28.4A0.9 0.9 0 0 0 12.3 28.4C11.2 29.5 9.6 30.2 8 30.2 4.6 30.2 1.8 27.4 1.8 24 1.8 22.4 2.5 20.8 3.6 19.7A0.9 0.9 0 0 0 3.6 19.6L8.6 14.6A0.9 0.9 0 0 0 8.6 13.4 0.9 0.9 0 0 0 7.4 13.4L2.5 18.2A0.9 0.9 0 0 0 2.3 18.3C2.3 18.4 2.3 18.4 2.3 18.4A0.9 0.9 0 0 0 2.2 18.5 0.9 0.9 0 0 0 2.2 18.6C0.8 20 0 22 0 24 0 28.4 3.6 32 8 32 10 32 12 31.2 13.5 29.8 13.5 29.8 13.5 29.8 13.5 29.8A0.9 0.9 0 0 0 13.6 29.7C13.6 29.7 13.6 29.7 13.7 29.7A0.9 0.9 0 0 0 13.8 29.5 0.9 0.9 0 0 0 13.8 29.5L18.8 24.5 18.8 24.5A0.9 0.9 0 0 0 18.9 24.4C18.9 24.4 18.9 24.4 18.9 24.4L19 24.3A0.9 0.9 0 0 0 19.2 23.9C19.2 23.9 19.2 23.9 19.2 23.9 20.3 22.5 21 20.8 21 19 21 15.6 18.8 12.5 15.5 11.4A0.9 0.9 0 0 0 15.2 11.4z`],name:`link`},re={icon:[32,32,`M16 0a16 16 0 1 0 0 32 16 16 0 0 0 0-32Zm0 2a14 14 0 0 1 14 14 14 14 0 0 1-14 14A14 14 0 0 1 2 16 14 14 0 0 1 16 2Zm5.2 8.4-6.3 9-4.2-4.1c-1-1-2.3.5-1.4 1.4l5 5a1 1 0 0 0 1.5-.1l7-10c.8-1.1-.9-2.2-1.6-1.2z`],name:`check-circle-outline`},O=`:host{align-items:flex-end;gap:var(--luzmo-spacing-2);font-family:var(--luzmo-font-family);flex-direction:column;display:inline-flex}.trigger-spinner{--luzmo-progress-circle-size:var(--luzmo-icon-size-xs)}.trigger-chevron{margin-inline-start:var(--luzmo-spacing-1)}.picker{gap:var(--luzmo-spacing-3);width:var(--luzmo-add-to-dashboard-picker-width,var(--add-to-dashboard-picker-width));max-width:90vw;padding:var(--luzmo-spacing-2);color:var(--luzmo-font-color);font-size:var(--luzmo-font-size-s);flex-direction:column;display:flex}luzmo-search{width:100%}.list{max-height:var(--luzmo-add-to-dashboard-list-max-height,var(--add-to-dashboard-list-max-height));flex-direction:column;display:flex;overflow-y:auto}.menu{--luzmo-menu-max-height:none;flex:none;width:100%;overflow:visible}.create-row{--luzmo-menu-item-label-icon-color-default:var(--luzmo-primary)}.thumbnail{object-fit:cover;border:var(--luzmo-border-width) solid var(--luzmo-border-color);border-radius:var(--luzmo-border-radius);width:2.75rem;height:2rem}.drill-in{color:var(--luzmo-font-color-extra-dimmed)}.header{align-items:center;gap:var(--luzmo-spacing-2);display:flex}.header-title{font-weight:var(--luzmo-font-weight-bold);text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.empty{align-items:center;gap:var(--luzmo-spacing-3);padding:var(--luzmo-spacing-4);text-align:center;flex-direction:column;display:flex}.loading{padding:var(--luzmo-spacing-3);justify-content:center;display:flex}.screen-modes{gap:var(--luzmo-spacing-2);flex-direction:column;display:flex}.screen-mode{align-items:center;gap:var(--luzmo-spacing-2);display:flex}.screen-mode-size{color:var(--luzmo-font-color-extra-dimmed)}.footer{justify-content:flex-end;display:flex}.status{justify-content:flex-end;width:0;min-width:100%;display:flex}.status:empty{display:none}.alert{flex:none;inline-size:max-content}.alert-body{align-items:center;gap:var(--luzmo-spacing-3);block-size:1lh;min-inline-size:0;display:flex}.alert-text{min-inline-size:0;font-weight:var(--luzmo-font-weight-semibold);white-space:pre;display:flex}.alert[variant=negative] .alert-text{white-space:normal}.alert-name{min-inline-size:0;font-weight:var(--luzmo-font-weight-bold);text-overflow:ellipsis;white-space:nowrap;unicode-bidi:plaintext;overflow:hidden}.alert-open{flex:none}:host{--add-to-dashboard-picker-width:18rem;--add-to-dashboard-list-max-height:16rem}`,k=`0.1.107`,A=`0.1.0`,j=[`id`,`name`,`contents`,`modified_at`,`is_variant`,`original_id`],M=/* @__PURE__ */ new Set([`designer`,`owner`]),N=`flag_dashboard_variants`,P=[`desktop`,`tablet`,`mobile`];async function F(e,t,n){let r=[],i=t,a=0;for(let t of e){let e=n-r.length,o=await t(i,Math.max(e,1));e>0&&r.push(...o.rows.slice(0,e)),i=Math.max(0,i-o.count),a+=o.count}return{rows:r,total:a}}async function I(e,t){let n=(await e.fetchApi(`/user`,{action:`get`,version:A,find:{where:{id:`me`},attributes:[`id`,`flags`],...t?{include:[{model:`Organization`,attributes:[`id`]}]}:{}}})).rows?.[0];return{id:n?.id??``,flags:n?.flags??[],organizations:n?.organizations}}async function L(e,t){return(await e.fetchApi(`/authorization`,{action:`get`,version:A,find:{where:{id:t}}})).rows?.[0]}async function R(e,t,n){let r={...t,where:{...t.where,type:`dashboard`}},i=await e.fetchApi(`/securable`,{action:`get`,version:A,find:r},{signal:n});return{rows:i.rows??[],count:i.count??i.rows?.length??0}}function z(e){let t={modifyIds:/* @__PURE__ */ new Set,useOnlyIds:/* @__PURE__ */ new Set};for(let n of e?.access?.dashboards??[])n.rights?.Modify?t.modifyIds.add(n.id):n.rights?.Use&&t.useOnlyIds.add(n.id);return t}function B(){return{version:k,syncScreenModes:!0,views:P.map(e=>({screenModus:e,options:{theme:{id:`default`}},filterGroups:[],items:[]})),timezone:{type:`fixed`,id:`UTC`}}}function V(e){return e?{search:{match_types:[`name`,`description`],keyphrase:e,securable_types:[`dashboard`]}}:{}}function H(e,t){return{include:[{model:`User`,as:`allUsers`,attributes:[],required:!0,where:{id:e,...Object.fromEntries(Object.entries(t).map(([e,t])=>[`securableAccessRight.${e}`,t]))}}]}}async function U(e){let t=new p({apiUrl:e.apiUrl,authKey:e.authKey,authToken:e.authToken,skipNetworkListeners:!0}),r=await L(t,e.authKey),i=r?.type===`embed`,a=await I(t,!i),o=z(r),s=i?M.has(r.role??``):a.organizations?.[0]?.organizationRole?.flagEditor!==!1,c=!!a.id&&a.flags.includes(N),l=[...o.modifyIds,...c?o.useOnlyIds:[]],u=l.length>0?{id:{notIn:l}}:{},d=(t,n=!1)=>{let r=[...new Set((t.contents?.views??[]).map(e=>e.screenModus))];return{id:t.id,name:m(t.name??{},e.language),syncScreenModes:t.contents?.syncScreenModes!==!1,screenModes:r.length>0?r:[`desktop`],...n?{requiresVariant:n}:{}}},f,h=(e,n)=>async(r,i)=>{if(l.length===0)return{count:0,rows:[]};let a=r>0&&f?.search===e?f.rows:void 0;return a||(a=(await R(t,{where:{is_variant:!1,archived_at:null,id:{in:l}},attributes:j,...V(e)},n)).rows.map(e=>d(e,!o.modifyIds.has(e.id))).sort((e,t)=>e.name.localeCompare(t.name)),f={search:e,rows:a}),{count:a.length,rows:a.slice(r,r+i)}},g=(e,n,r,i)=>async(o,s)=>{let c=await R(t,{where:{is_variant:!1,archived_at:null,...u},attributes:j,...H(a.id,r),...V(e),limit:s,offset:o,order:[[`modified_at`,`desc`]]},n);return{count:c.count,rows:c.rows.map(e=>d(e,i))}},_=async(e,n,r,i)=>{await t.fetchApi(`/securable`,{action:`update`,version:A,id:e,properties:{append_item:{item:n,...r?.length?{screenModes:r}:{}}}},{signal:i})},v=async(e,n,r)=>{try{await _(e.id,n,r)}catch(n){throw await t.fetchApi(`/securable`,{action:`delete`,version:A,id:e.id}).catch(()=>void 0),n}},y=async(e,n)=>await t.fetchApi(`/securable`,{action:`create`,version:A,properties:{...e,type:`dashboard`},associations:n});return{async list(e,t){return a.id?await F([h(e.search,t.signal),...c?[g(e.search,t.signal,{flagUse:!0,flagModify:!1},!0)]:[],g(e.search,t.signal,{flagModify:!0},!1)],e.offset,e.limit):{rows:[],total:0}},async add(e,t,n,r){await _(e.id,t,n.screenModes,r.signal)},...s?{async create(t,n){let r=await y({name:n.name?{[e.language]:n.name}:{},contents:B()});return await v(r,t,void 0),d(r)}}:{},...c?{async listVariants(e,n){return(await R(t,{where:{is_variant:!0,original_id:e.id,archived_at:null},attributes:j,...H(a.id,{flagModify:!0}),order:[[`modified_at`,`desc`]]},n.signal)).rows.map(e=>d(e))}}:{},...c&&s?{async addToVariant(r,i,a){let o=(await R(t,{where:{id:r.id},attributes:[`id`,`name`,`contents`]})).rows[0];if(!o?.contents)throw Error(n(`The dashboard was not found.`,{desc:`Adding the chart to a variant failed because the original dashboard could not be loaded`}));let s=o.name??{},c=await y({name:a.name?{...s,[e.language]:a.name}:s,contents:o.contents},[{role:`original`,id:r.id}]);return await v(c,i,a.screenModes),d({...c,contents:c.contents??o.contents})}}:{}}}function W(e){let{theme:t,...n}=e.options??{};return{...d(e),options:n}}function G(e,t){let n=new Set(e),r=e.length+1;for(;n.has(t(r));)r+=1;return r}var K=20,q=300,J=8,Y=48,X=`__luzmo-new-dashboard`,Z=`__luzmo-new-variant`,Q=/* @__PURE__ */ new Map,ie=0,$=class extends r(f(l,{validSizes:Object.values(u)})){constructor(...e){super(...e),this.chart=null,this.dashboardActions=null,this.authKey=``,this.authToken=``,this.apiUrl=`https://api.luzmo.com`,this.placement=`bottom-end`,this.disabled=!1,this._open=!1,this._actions=null,this._step=`list`,this._rows=[],this._hasMore=!1,this._loading=!1,this._listFailed=!1,this._original=null,this._variants=[],this._variantsLoading=!1,this._variantsFailed=!1,this._pending=null,this._screenModes=[],this._saving=!1,this._status=null,this._triggerId=`add-to-dashboard-trigger-${++ie}`,this._search=``,this._actionsGeneration=0,this._reloadOnUpdate=!1}static get styles(){let e=super.styles??[];return[...Array.isArray(e)?e:[e],x(O)]}get _hasSource(){return!!this.dashboardActions||!!(this.authKey&&this.authToken)}connectedCallback(){super.connectedCallback(),this._status&&this._startFittingAlert()}disconnectedCallback(){super.disconnectedCallback(),this._handleClosed(),this._actionsGeneration+=1,this._saveAbort?.abort(),this._stopFittingAlert()}willUpdate(e){super.willUpdate(e),(e.has(`dashboardActions`)||e.has(`authKey`)||e.has(`authToken`)||e.has(`apiUrl`)||e.has(`language`))&&(this._actions=null,this._actionsGeneration+=1,this._open&&(this._listAbort?.abort(),this._variantsAbort?.abort(),this._step=`list`,this._original=null,this._pending=null,this._rows=[],this._open=this._hasSource,this._reloadOnUpdate=this._hasSource)),e.has(`disabled`)&&this.disabled&&(this._open=!1),e.has(`chart`)&&!this.chart&&this._handleClosed()}updated(e){super.updated(e),this._reloadOnUpdate&&(this._reloadOnUpdate=!1,this._loadList()),e.has(`_step`)&&this._open&&this._focusStep(),e.has(`_status`)&&(this._status?this._startFittingAlert():this._stopFittingAlert())}get _alertContainer(){let e=this.getRootNode();return this.parentElement??(e instanceof ShadowRoot?e.host:null)}_startFittingAlert(){this._fitAlert();let e=this._alertContainer;!this._alertResizeObserver&&e&&(this._alertResizeObserver=new ResizeObserver(()=>this._fitAlert()),this._alertResizeObserver.observe(this),this._alertResizeObserver.observe(e))}_stopFittingAlert(){this._alertResizeObserver?.disconnect(),this._alertResizeObserver=void 0}_fitAlert(){let e=this._noticeElement,t=this._alertContainer;if(!e||!t)return;let n=this.getBoundingClientRect(),r=t.getBoundingClientRect(),i=Number.parseFloat(getComputedStyle(t).paddingInlineStart)||0,a=(this.isLTR?n.right-r.left:r.right-n.left)-i;e.style.setProperty(`--luzmo-notice-max-inline-size`,`${Math.max(0,a)}px`)}async _resolveActions(){if(this.dashboardActions)return this.dashboardActions;let e={apiUrl:this.apiUrl,authKey:this.authKey,authToken:this.authToken,language:this.language},t=JSON.stringify(e),n=Q.get(t);return n||(Q.clear(),n=U(e),Q.set(t,n),n.catch(()=>Q.delete(t))),await n}_dispatch(e,t){let n=new CustomEvent(e,{detail:t,bubbles:!0,composed:!0});this.dispatchEvent(n)}_displayName(e){return e.name.trim()||n(`Untitled dashboard`,{desc:`Fallback name of a dashboard without a name`})}_variantName(t,r){let i=this._displayName(t);return n(e`${i} (variant ${r})`,{desc:`Name of a new dashboard variant`})}_screenModeChoices(){return[{name:`mobile`,label:n(`Smartphone`,{desc:`Screen mode name`}),size:`< 768px`,icon:E},{name:`tablet`,label:n(`Tablet`,{desc:`Screen mode name`}),size:`≥ 768px`,icon:D},{name:`desktop`,label:n(`Desktop`,{desc:`Screen mode name`}),size:`≥ 1200px`,icon:ee},{name:`largeScreen`,label:n(`Large screen`,{desc:`Screen mode name`}),size:`≥ 1600px`,icon:te},{name:`fixed`,label:n(`Fixed width`,{desc:`Screen mode name`}),icon:s}]}async _handleOpened(e){e.target===e.currentTarget&&(this._open=!0,this._step=`list`,this._search=``,this._original=null,this._pending=null,this._rows=[],await this.updateComplete,this._searchElement?.focus(),await this._loadList())}async _loadList(){let e=this._actionsGeneration;this._loading=!0,this._listFailed=!1;try{let t=this._actions??await this._resolveActions();if(e!==this._actionsGeneration)return;this._actions=t}catch(t){if(!this.isConnected||e!==this._actionsGeneration)return;console.error(`Failed to resolve the add to dashboard actions:`,t),this._loading=!1,this._listFailed=!0;return}this.isConnected&&this._open&&await this._loadPage(!1)}_handleClosed(e){e&&e.target!==e.currentTarget||(this._open=!1,clearTimeout(this._searchTimer),this._listAbort?.abort(),this._variantsAbort?.abort())}async _loadPage(e){let t=this._actions;if(!t)return;this._listAbort?.abort();let n=new AbortController;this._listAbort=n,this._loading=!0,this._listFailed=!1,e||(this._rows=[]);try{let e=await t.list({search:this._search,offset:this._rows.length,limit:K},{signal:n.signal});if(n.signal.aborted)return;this._rows=[...this._rows,...e.rows],this._hasMore=e.total===void 0?e.rows.length===K:this._rows.length<e.total}catch(e){if(n.signal.aborted)return;console.error(`Failed to load dashboards:`,e),this._listFailed=!0}finally{n.signal.aborted||(this._loading=!1)}}_handleSearchInput(e){this._search=String(e.target?.value??``),clearTimeout(this._searchTimer),this._searchTimer=setTimeout(()=>void this._loadPage(!1),q)}_handleListScroll(e){let t=e.target;this._hasMore&&!this._loading&&t.scrollHeight-t.scrollTop-t.clientHeight<=Y&&this._loadPage(!0)}_menuValue(e){return e.stopPropagation(),e.target.value??``}_handleListChange(e){let t=this._menuValue(e);if(t===X){this._actions?.create&&this._save({kind:`create`});return}let n=this._rows.find(e=>e.id===t);n&&(n.requiresVariant?(this._original=n,this._step=`variants`,this._loadVariants()):this._selectTarget({kind:`add`,dashboard:n,isVariant:!1},n))}_handleVariantChange(e){let t=this._menuValue(e),n=this._original;if(!n)return;if(t===Z){if(!this._actions?.addToVariant)return;let e=this._variants.map(e=>this._displayName(e)),t=this._variantName(n,G(e,e=>this._variantName(n,e)));this._selectTarget({kind:`variant`,original:n,name:t},n);return}let r=this._variants.find(e=>e.id===t);r&&this._selectTarget({kind:`add`,dashboard:r,isVariant:!0},r)}_selectTarget(e,t){t.syncScreenModes!==!1||!t.screenModes?.length?this._save(e):(this._pending=e,this._screenModes=[...t.screenModes??[]],this._step=`screenModes`)}async _loadVariants(){let e=this._actions,t=this._original;if(this._variantsAbort?.abort(),this._variants=[],this._variantsLoading=!1,this._variantsFailed=!1,!e?.listVariants||!t)return;let n=new AbortController;this._variantsAbort=n,this._variantsLoading=!0;try{let r=await e.listVariants(t,{signal:n.signal});n.signal.aborted||(this._variants=r)}catch(e){n.signal.aborted||(console.error(`Failed to load dashboard variants:`,e),this._variantsFailed=!0)}finally{n.signal.aborted||(this._variantsLoading=!1)}}_handleBack(){this._step===`screenModes`&&this._original?this._step=`variants`:(this._step=`list`,this._original=null),this._pending=null}_toggleScreenMode(e){this._screenModes=this._screenModes.includes(e)?this._screenModes.filter(t=>t!==e):[...this._screenModes,e]}_handleConfirmScreenModes(){this._pending&&this._screenModes.length>0&&this._save(this._pending,{screenModes:[...this._screenModes]})}async _save(e,t={}){let n=this._actions;if(!n||!this.chart||this._saving)return;this._open=!1,this._saving=!0,this._setStatus(null),this._saveAbort=new AbortController;let r=W(this.chart),i={signal:this._saveAbort.signal};try{let a;if(e.kind===`create`&&n.create)a=await n.create(r,t,i);else if(e.kind===`variant`&&n.addToVariant)a=await n.addToVariant(e.original,r,{...t,name:e.name},i);else if(e.kind===`add`)a=await n.add(e.dashboard,r,t,i)||e.dashboard;else return;if(i.signal.aborted)return;this._setStatus({kind:`success`,dashboard:a,isVariant:e.kind===`variant`||e.kind===`add`&&e.isVariant,openDashboard:n.openDashboard?.bind(n)}),this._dispatch(`luzmo-chart-added`,{dashboard:a})}catch(e){if(i.signal.aborted)return;console.error(`Failed to add the chart to a dashboard:`,e),this._setStatus({kind:`error`,message:e instanceof Error&&e.message?e.message:void 0}),this._dispatch(`luzmo-chart-add-failed`,{error:e})}finally{this._saving=!1}await this.updateComplete,this.isConnected&&this._isFocusLost()&&this._focusTrigger()}_setStatus(e){this._status=e}_focusTrigger(){this._triggerElement?.focus()}_isFocusLost(){return!document.activeElement||document.activeElement===document.body}async _handleNoticeClose(e){e.stopPropagation();let t=e.currentTarget.matches(`:focus-within`);this._setStatus(null),await this.updateComplete,t&&this._isFocusLost()&&this._focusTrigger()}async _focusStep(){let e=this._step===`list`?this._searchElement:this._backElement;await e?.updateComplete,e?.focus()}_renderRow(e){return h`
|
|
23
23
|
<luzmo-menu-item value=${e.id} no-wrap ?disabled=${this._saving}>
|
|
24
|
-
${e.thumbnailUrl?
|
|
24
|
+
${e.thumbnailUrl?h`<img slot="icon" class="thumbnail" alt="" src=${e.thumbnailUrl} />`:_}
|
|
25
25
|
${this._displayName(e)}
|
|
26
|
-
${e.requiresVariant?
|
|
26
|
+
${e.requiresVariant?h`<luzmo-icon slot="value" class="drill-in" size="xs" block .icon=${this.isLTR?w:o}></luzmo-icon>`:_}
|
|
27
27
|
</luzmo-menu-item>
|
|
28
|
-
`}_renderCreateRow(e,t,n,r=!1){let i=`${this._triggerId}-${e}-reason`;return
|
|
28
|
+
`}_renderCreateRow(e,t,n,r=!1){let i=`${this._triggerId}-${e}-reason`;return h`
|
|
29
29
|
<luzmo-menu-item
|
|
30
30
|
class="create-row"
|
|
31
31
|
value=${e}
|
|
32
32
|
label=${t}
|
|
33
|
-
aria-describedby=${
|
|
33
|
+
aria-describedby=${g(n?i:void 0)}
|
|
34
34
|
no-wrap
|
|
35
35
|
?disabled=${this._saving||r||!!n}
|
|
36
36
|
>
|
|
37
|
-
<luzmo-icon slot="icon" size="s" .icon=${
|
|
38
|
-
${t} ${n?
|
|
37
|
+
<luzmo-icon slot="icon" size="s" .icon=${c}></luzmo-icon>
|
|
38
|
+
${t} ${n?h`<span slot="description" id=${i}>${n}</span>`:_}
|
|
39
39
|
</luzmo-menu-item>
|
|
40
|
-
`}_renderLoading(){let e=
|
|
40
|
+
`}_renderLoading(){let e=n(`Loading`,{desc:`Loading spinner label`});return h`<div class="loading"><luzmo-progress-circle size="s" indeterminate .label=${e}></luzmo-progress-circle></div>`}async _handleRetry(e){let t=e();await this.updateComplete,this._isFocusLost()&&await this._focusStep(),await t}_renderEmpty(e,t){return h`
|
|
41
41
|
<div class="empty">
|
|
42
42
|
<span>${e}</span>
|
|
43
|
-
${
|
|
43
|
+
${t?h`<luzmo-button size="s" treatment="outline" @click=${()=>this._handleRetry(t)}>${n(`Retry`,{desc:`Retry a failed request`})}</luzmo-button>`:_}
|
|
44
44
|
</div>
|
|
45
|
-
`}_renderHeader(e){return
|
|
45
|
+
`}_renderHeader(e){return h`
|
|
46
46
|
<div class="header">
|
|
47
|
-
<luzmo-action-button size="s" quiet label=${
|
|
48
|
-
<luzmo-icon slot="icon" size="xs" .icon=${this.isLTR?C
|
|
47
|
+
<luzmo-action-button size="s" quiet label=${n(`Back`,{desc:`Go back to the previous step`})} @click=${this._handleBack}>
|
|
48
|
+
<luzmo-icon slot="icon" size="xs" .icon=${this.isLTR?S:C}></luzmo-icon>
|
|
49
49
|
</luzmo-action-button>
|
|
50
50
|
<span class="header-title" tabindex="-1"
|
|
51
51
|
>${e}<luzmo-tooltip self-managed show-only-if-truncated placement="top" .size=${this.size}>${e}</luzmo-tooltip></span
|
|
52
52
|
>
|
|
53
53
|
</div>
|
|
54
|
-
`}_renderList(){let e=this._actions&&!this._actions.create?
|
|
54
|
+
`}_renderList(){let e=this._actions&&!this._actions.create?n(`These credentials cannot create dashboards`,{id:`add-to-dashboard-cannot-create`,desc:`Why a new dashboard cannot be created`}):void 0;return h`
|
|
55
55
|
<luzmo-search
|
|
56
56
|
size="s"
|
|
57
57
|
border="none"
|
|
58
|
-
label=${
|
|
59
|
-
placeholder=${
|
|
58
|
+
label=${n(`Search dashboards`,{desc:`Label of the dashboard search field`})}
|
|
59
|
+
placeholder=${n(`Search dashboards`,{desc:`Label of the dashboard search field`})}
|
|
60
60
|
.value=${this._search}
|
|
61
61
|
@input=${this._handleSearchInput}
|
|
62
62
|
@submit=${e=>e.preventDefault()}
|
|
@@ -64,31 +64,31 @@ import{a as e,i as t,n,r,t as i}from"./chunks/version-BW4Ixl63.js";import{t as a
|
|
|
64
64
|
<luzmo-divider size="s"></luzmo-divider>
|
|
65
65
|
<div class="list" @scroll=${this._handleListScroll}>
|
|
66
66
|
<luzmo-menu class="menu" size="s" @change=${this._handleListChange} @close=${e=>e.stopPropagation()}>
|
|
67
|
-
${this._renderCreateRow(X,
|
|
67
|
+
${this._renderCreateRow(X,n(`New dashboard`,{desc:`Create a new dashboard for the chart`}),e,!this._actions)}
|
|
68
68
|
${this._rows.map(e=>this._renderRow(e))}
|
|
69
69
|
</luzmo-menu>
|
|
70
70
|
<div class="list-state" role="status" aria-live="polite">
|
|
71
|
-
${this._listFailed?this._renderEmpty(
|
|
72
|
-
${this._loading?this._renderLoading():
|
|
71
|
+
${this._listFailed?this._renderEmpty(n(`Failed to load dashboards`,{desc:`Dashboard list failed to load`}),()=>this._loadList()):!this._loading&&this._rows.length===0?this._renderEmpty(n(`No dashboards found`,{desc:`Dashboard list is empty`})):_}
|
|
72
|
+
${this._loading?this._renderLoading():_}
|
|
73
73
|
</div>
|
|
74
74
|
</div>
|
|
75
|
-
`}_renderVariants(e){let
|
|
75
|
+
`}_renderVariants(e){let t=this._actions?.addToVariant?void 0:n(`These credentials cannot create variants`,{id:`add-to-dashboard-cannot-create-variant`,desc:`Why a new dashboard variant cannot be created`}),r=!this._variantsLoading&&!this._variantsFailed;return h`
|
|
76
76
|
${this._renderHeader(this._displayName(e))}
|
|
77
77
|
<luzmo-divider size="s"></luzmo-divider>
|
|
78
78
|
<div class="list">
|
|
79
79
|
<luzmo-menu class="menu" size="s" @change=${this._handleVariantChange} @close=${e=>e.stopPropagation()}>
|
|
80
|
-
${this._renderCreateRow(Z,
|
|
80
|
+
${this._renderCreateRow(Z,n(`New variant`,{desc:`Create a new variant of a dashboard`}),t,!r)}
|
|
81
81
|
${this._variants.map(e=>this._renderRow(e))}
|
|
82
82
|
</luzmo-menu>
|
|
83
83
|
<div class="list-state" role="status" aria-live="polite">
|
|
84
|
-
${this._variantsFailed?this._renderEmpty(
|
|
85
|
-
${this._variantsLoading?this._renderLoading():
|
|
84
|
+
${this._variantsFailed?this._renderEmpty(n(`Failed to load variants`,{desc:`Variant list failed to load`}),()=>this._loadVariants()):!this._variantsLoading&&this._variants.length===0?this._renderEmpty(n(`No variants yet`,{desc:`Variant list is empty`})):_}
|
|
85
|
+
${this._variantsLoading?this._renderLoading():_}
|
|
86
86
|
</div>
|
|
87
87
|
</div>
|
|
88
|
-
`}_renderScreenModes(e){let
|
|
88
|
+
`}_renderScreenModes(e){let t=e.kind===`variant`?e.original:e.dashboard,r=e.kind===`variant`?e.name:this._displayName(t),i=t.screenModes??[];return h`
|
|
89
89
|
${this._renderHeader(r)}
|
|
90
|
-
<luzmo-field-group class="screen-modes" vertical label=${
|
|
91
|
-
${this._screenModeChoices().filter(e=>i.includes(e.name)).map(e=>
|
|
90
|
+
<luzmo-field-group class="screen-modes" vertical label=${n(`Screen modes`,{desc:`Label of the group of screen-mode checkboxes`})}>
|
|
91
|
+
${this._screenModeChoices().filter(e=>i.includes(e.name)).map(e=>h`
|
|
92
92
|
<luzmo-checkbox
|
|
93
93
|
size="s"
|
|
94
94
|
?checked=${this._screenModes.includes(e.name)}
|
|
@@ -97,17 +97,17 @@ import{a as e,i as t,n,r,t as i}from"./chunks/version-BW4Ixl63.js";import{t as a
|
|
|
97
97
|
<span class="screen-mode">
|
|
98
98
|
<luzmo-icon size="xs" block .icon=${e.icon}></luzmo-icon>
|
|
99
99
|
${e.label}
|
|
100
|
-
${e.size?
|
|
100
|
+
${e.size?h`<span class="screen-mode-size" dir="ltr">${e.size}</span>`:_}
|
|
101
101
|
</span>
|
|
102
102
|
</luzmo-checkbox>
|
|
103
103
|
`)}
|
|
104
104
|
</luzmo-field-group>
|
|
105
105
|
<div class="footer">
|
|
106
106
|
<luzmo-button size="s" variant="primary" ?disabled=${this._screenModes.length===0||this._saving} @click=${this._handleConfirmScreenModes}>
|
|
107
|
-
${
|
|
107
|
+
${n(`Confirm`,{desc:`Confirm the selected screen modes`})}
|
|
108
108
|
</luzmo-button>
|
|
109
109
|
</div>
|
|
110
|
-
`}_renderPicker(){return this._step===`screenModes`&&this._pending?this._renderScreenModes(this._pending):this._step===`variants`&&this._original?this._renderVariants(this._original):this._renderList()}_noticeLabels(){return{close:
|
|
110
|
+
`}_renderPicker(){return this._step===`screenModes`&&this._pending?this._renderScreenModes(this._pending):this._step===`variants`&&this._original?this._renderVariants(this._original):this._renderList()}_noticeLabels(){return{close:n(`Close`,{id:`add-to-dashboard-close`,desc:`Close the save result notice`})}}_renderStatus(){let e=this._status;if(!e)return _;if(e.kind===`error`)return h`
|
|
111
111
|
<luzmo-notice
|
|
112
112
|
class="alert"
|
|
113
113
|
size="s"
|
|
@@ -116,10 +116,10 @@ import{a as e,i as t,n,r,t as i}from"./chunks/version-BW4Ixl63.js";import{t as a
|
|
|
116
116
|
.labels=${this._noticeLabels()}
|
|
117
117
|
@luzmo-notice-close=${this._handleNoticeClose}
|
|
118
118
|
>
|
|
119
|
-
<luzmo-icon slot="icon" .icon=${
|
|
120
|
-
<span class="alert-text" dir="auto">${e.message??
|
|
119
|
+
<luzmo-icon slot="icon" .icon=${T}></luzmo-icon>
|
|
120
|
+
<span class="alert-text" dir="auto">${e.message??n(`Failed to copy item`,{desc:`Saving the chart to a dashboard failed`})}</span>
|
|
121
121
|
</luzmo-notice>
|
|
122
|
-
`;let
|
|
122
|
+
`;let t=this._displayName(e.dashboard),r=h`<strong class="alert-name" tabindex="-1">${t}<luzmo-tooltip self-managed show-only-if-truncated placement="top" .size=${this.size}>${t}</luzmo-tooltip></strong>`,i=e.openDashboard;return h`
|
|
123
123
|
<luzmo-notice
|
|
124
124
|
class="alert"
|
|
125
125
|
size="s"
|
|
@@ -130,16 +130,16 @@ import{a as e,i as t,n,r,t as i}from"./chunks/version-BW4Ixl63.js";import{t as a
|
|
|
130
130
|
>
|
|
131
131
|
<luzmo-icon slot="icon" .icon=${re}></luzmo-icon>
|
|
132
132
|
<div class="alert-body">
|
|
133
|
-
<span class="alert-text" dir="auto">${
|
|
134
|
-
${i&&!e.isVariant?
|
|
133
|
+
<span class="alert-text" dir="auto">${n(h`Item copied to ${r}`,{desc:`The chart was saved to a dashboard`})}</span>
|
|
134
|
+
${i&&!e.isVariant?h`
|
|
135
135
|
<luzmo-action-button class="alert-open" size="s" quiet @click=${()=>i(e.dashboard)}>
|
|
136
136
|
<luzmo-icon slot="icon" size="xs" .icon=${ne}></luzmo-icon>
|
|
137
|
-
${
|
|
137
|
+
${n(`Open`,{id:`add-to-dashboard-open`,desc:`Open the dashboard the chart was saved to`})}
|
|
138
138
|
</luzmo-action-button>
|
|
139
|
-
`:
|
|
139
|
+
`:_}
|
|
140
140
|
</div>
|
|
141
141
|
</luzmo-notice>
|
|
142
|
-
`}render(){if(!this.chart||!this._hasSource)return
|
|
142
|
+
`}render(){if(!this.chart||!this._hasSource)return _;let e=this._saving?n(`Adding to dashboard`,{desc:`The chart is being saved to a dashboard`}):n(`Add to dashboard`,{desc:`Button that opens the add to dashboard picker`});return h`
|
|
143
143
|
<luzmo-action-button
|
|
144
144
|
id=${this._triggerId}
|
|
145
145
|
class="trigger"
|
|
@@ -148,9 +148,9 @@ import{a as e,i as t,n,r,t as i}from"./chunks/version-BW4Ixl63.js";import{t as a
|
|
|
148
148
|
aria-expanded=${this._open?`true`:`false`}
|
|
149
149
|
?disabled=${this.disabled||this._saving}
|
|
150
150
|
>
|
|
151
|
-
${this._saving?
|
|
151
|
+
${this._saving?h`<luzmo-progress-circle class="trigger-spinner" slot="icon" indeterminate .label=${e}></luzmo-progress-circle>`:h`<luzmo-icon slot="icon" size="xs" .icon=${c}></luzmo-icon>`}
|
|
152
152
|
${e}
|
|
153
|
-
<luzmo-icon class="trigger-chevron" size="xs" .icon=${
|
|
153
|
+
<luzmo-icon class="trigger-chevron" size="xs" .icon=${a}></luzmo-icon>
|
|
154
154
|
</luzmo-action-button>
|
|
155
155
|
<luzmo-overlay
|
|
156
156
|
type="auto"
|
|
@@ -161,8 +161,8 @@ import{a as e,i as t,n,r,t as i}from"./chunks/version-BW4Ixl63.js";import{t as a
|
|
|
161
161
|
@luzmo-closed=${this._handleClosed}
|
|
162
162
|
>
|
|
163
163
|
<luzmo-popover>
|
|
164
|
-
<div class="picker">${this._open?this._renderPicker():
|
|
164
|
+
<div class="picker">${this._open?this._renderPicker():_}</div>
|
|
165
165
|
</luzmo-popover>
|
|
166
166
|
</luzmo-overlay>
|
|
167
167
|
<div class="status">${this._renderStatus()}</div>
|
|
168
|
-
`}};
|
|
168
|
+
`}};t([v({attribute:!1})],$.prototype,`chart`,void 0),t([v({attribute:!1})],$.prototype,`dashboardActions`,void 0),t([v({type:String,attribute:`auth-key`})],$.prototype,`authKey`,void 0),t([v({type:String,attribute:`auth-token`})],$.prototype,`authToken`,void 0),t([v({type:String,attribute:`api-url`})],$.prototype,`apiUrl`,void 0),t([v({type:String,reflect:!0})],$.prototype,`placement`,void 0),t([v({type:Boolean,reflect:!0})],$.prototype,`disabled`,void 0),t([b()],$.prototype,`_open`,void 0),t([b()],$.prototype,`_actions`,void 0),t([b()],$.prototype,`_step`,void 0),t([b()],$.prototype,`_rows`,void 0),t([b()],$.prototype,`_hasMore`,void 0),t([b()],$.prototype,`_loading`,void 0),t([b()],$.prototype,`_listFailed`,void 0),t([b()],$.prototype,`_original`,void 0),t([b()],$.prototype,`_variants`,void 0),t([b()],$.prototype,`_variantsLoading`,void 0),t([b()],$.prototype,`_variantsFailed`,void 0),t([b()],$.prototype,`_pending`,void 0),t([b()],$.prototype,`_screenModes`,void 0),t([b()],$.prototype,`_saving`,void 0),t([b()],$.prototype,`_status`,void 0),t([y(`.trigger`)],$.prototype,`_triggerElement`,void 0),t([y(`luzmo-search`)],$.prototype,`_searchElement`,void 0),t([y(`.header luzmo-action-button`)],$.prototype,`_backElement`,void 0),t([y(`luzmo-notice`)],$.prototype,`_noticeElement`,void 0),$=t([i()],$),typeof customElements<`u`&&!customElements.get(`luzmo-add-to-dashboard`)&&customElements.define(`luzmo-add-to-dashboard`,$);export{$ as LuzmoAddToDashboard,U as createDashboardActions};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
|
|
2
|
-
import{
|
|
2
|
+
import{n as e}from"./localized-mixin-BWJj88bd.js";import{LitElement as t,property as n}from"https://cdn.jsdelivr.net/npm/@luzmo/lucero@2.6.1/standalone/lit.js";var r=/* @__PURE__ */ new Set;new MutationObserver(()=>{let e=document.documentElement.dir===`rtl`?document.documentElement.dir:`ltr`;r.forEach(t=>{t.setAttribute(`dir`,e)})}).observe(document.documentElement,{attributes:!0,attributeFilter:[`dir`]});var i=e=>e.startManagingContentDirection!==void 0||e.tagName===`LUZMO-THEME`,a=(e=document)=>{let t=e.activeElement;for(;t?.shadowRoot&&t.shadowRoot.activeElement;)t=t.shadowRoot.activeElement;let n=t?[t]:[];for(;t;){let e=t.assignedSlot||t.parentElement||t.getRootNode()?.host;e&&n.push(e),t=e}return n};function o(e){class t extends e{get isLTR(){return this.dir===`ltr`}hasVisibleFocusInTree(){let e=a(this.getRootNode())[0];if(!e)return!1;try{return e.matches(`:focus-visible`)||e.matches(`.focus-visible`)}catch{return e.matches(`.focus-visible`)}}connectedCallback(){if(super.connectedCallback(),!this.hasAttribute(`dir`)){let e=this.assignedSlot||this.parentNode;for(;e!==document.documentElement&&!i(e);)e=e.assignedSlot||e.parentNode||e.host;if(this.dir=e.dir===`rtl`?e.dir:this.dir||`ltr`,e===document.documentElement)r.add(this);else{let{localName:t}=e;t.search(`-`)>-1&&!customElements.get(t)?
|
|
3
3
|
/* c8 ignore next 8 */
|
|
4
|
-
customElements.whenDefined(t).then(()=>{typeof e.startManagingContentDirection==`function`&&e.startManagingContentDirection(this)}):typeof e.startManagingContentDirection==`function`&&e.startManagingContentDirection(this)}this._dirParent=e}super.connectedCallback()}disconnectedCallback(){super.disconnectedCallback(),this._dirParent&&(this._dirParent===document.documentElement?r.delete(this):typeof this._dirParent.stopManagingContentDirection==`function`&&this._dirParent.stopManagingContentDirection(this),this.removeAttribute(`dir`))}}return t}var s=class extends o(t){},c=!0;try{document.body.querySelector(`:focus-visible`)}catch{c=!1}var l=e=>{if(e.shadowRoot==null||Object.hasOwn(e.dataset,`jsFocusVisible`))return()=>{};if(self.applyFocusVisiblePolyfill)self.applyFocusVisiblePolyfill(e.shadowRoot),e.manageAutoFocus&&e.manageAutoFocus();else{let t=()=>{self.applyFocusVisiblePolyfill&&e.shadowRoot&&self.applyFocusVisiblePolyfill(e.shadowRoot),e.manageAutoFocus&&e.manageAutoFocus()};return self.addEventListener(`focus-visible-polyfill-ready`,t,{once:!0}),()=>{self.removeEventListener(`focus-visible-polyfill-ready`,t)}}return()=>{}},u=e=>{let t=Symbol(`endPolyfillCoordination`);class n extends e{constructor(...e){super(...e),this[t]=null}connectedCallback(){super.connectedCallback&&super.connectedCallback(),c||requestAnimationFrame(()=>{this[t]??(this[t]=l(this))})}disconnectedCallback(){super.disconnectedCallback&&super.disconnectedCallback(),c||requestAnimationFrame(()=>{this[t]!=null&&(this[t](),this[t]=null)})}}return n};function d(){return new Promise(e=>requestAnimationFrame(()=>e()))}var f=class extends u(s){constructor(...e){super(...e),this.disabled=!1,this.autofocus=!1,this._tabIndex=0,this.manipulatingTabindex=!1,this.autofocusReady=Promise.resolve()}get tabIndex(){if(this.focusElement===this){let e=this.hasAttribute(`tabindex`)?Number(this.getAttribute(`tabindex`)):NaN;return Number.isNaN(e)?-1:e}let e=Number.parseFloat(this.hasAttribute(`tabindex`)&&this.getAttribute(`tabindex`)||`0`);return this.disabled||e<0?-1:this.focusElement?this._tabIndex:e}set tabIndex(e){if(this.manipulatingTabindex)this.manipulatingTabindex=!1;else if(this.focusElement===this){if(this.disabled)this._tabIndex=e;else if(e!==this._tabIndex){this._tabIndex=e;let t=``+e;this.manipulatingTabindex=!0,this.setAttribute(`tabindex`,t)}}else if(e===-1?this.addEventListener(`pointerdown`,this.onPointerdownManagementOfTabIndex):(this.manipulatingTabindex=!0,this.removeEventListener(`pointerdown`,this.onPointerdownManagementOfTabIndex)),e===-1||this.disabled){if(this.manipulatingTabindex=!0,this.setAttribute(`tabindex`,`-1`),this.removeAttribute(`focusable`),this.selfManageFocusElement)return;e===-1?this.focusElement?.removeAttribute(`tabindex`):(this._tabIndex=e,this.manageFocusElementTabindex(e))}else this.setAttribute(`focusable`,``),this.hasAttribute(`tabindex`)?this.removeAttribute(`tabindex`):this.manipulatingTabindex=!1,this._tabIndex=e,this.manageFocusElementTabindex(e)}onPointerdownManagementOfTabIndex(){this.tabIndex===-1&&setTimeout(()=>{this.tabIndex=0,this.focus({preventScroll:!0}),this.tabIndex=-1})}async manageFocusElementTabindex(e){this.focusElement||await this.updateComplete,e===null?this.focusElement.removeAttribute(`tabindex`):this.focusElement!==this&&(this.focusElement.tabIndex=e)}get focusElement(){throw Error(`Must implement focusElement getter!`)}get selfManageFocusElement(){return!1}focus(e){!this.disabled&&this.focusElement&&(this.focusElement===this?Reflect.apply(HTMLElement.prototype.focus,this,[e]):this.focusElement.focus(e))}blur(){let e=this.focusElement||this;e===this?HTMLElement.prototype.blur.apply(this):e.blur()}click(){if(this.disabled)return;let e=this.focusElement||this;e===this?HTMLElement.prototype.click.apply(this):e.click()}manageAutoFocus(){this.autofocus&&(this.dispatchEvent(new KeyboardEvent(`keydown`,{code:`Tab`})),this.focusElement.focus())}firstUpdated(e){super.firstUpdated(e),this.hasAttribute(`tabindex`)&&this.getAttribute(`tabindex`)===`-1`||this.setAttribute(`focusable`,``)}update(e){e.has(`disabled`)&&this.handleDisabledChanged(this.disabled,e.get(`disabled`)),super.update(e)}updated(e){super.updated(e),e.has(`disabled`)&&this.disabled&&this.blur()}async handleDisabledChanged(e,t){let n=()=>this.focusElement!==this&&this.focusElement.disabled!==void 0;e?(this.manipulatingTabindex=!0,this.setAttribute(`tabindex`,`-1`),await this.updateComplete,n()?this.focusElement.disabled=!0:this.setAttribute(`aria-disabled`,`true`)):t&&(this.manipulatingTabindex=!0,this.focusElement===this?this.setAttribute(`tabindex`,``+this._tabIndex):this.removeAttribute(`tabindex`),await this.updateComplete,n()?this.focusElement.disabled=!1:this.removeAttribute(`aria-disabled`))}async getUpdateComplete(){let e=await super.getUpdateComplete();return await this.autofocusReady,e}connectedCallback(){super.connectedCallback(),this.autofocus&&(this.autofocusReady=(async()=>{await d(),await d()})(),this.updateComplete.then(()=>this.manageAutoFocus()))}};e([n({type:Boolean,reflect:!0})],f.prototype,`disabled`,void 0),e([n({type:Boolean})],f.prototype,`autofocus`,void 0),e([n({type:Number})],f.prototype,`tabIndex`,null);var p={xxs:`xxs`,xs:`xs`,s:`s`,m:`m`,l:`l`,xl:`xl`,xxl:`xxl`};function m(t,{validSizes:r=[`s`,`m`,`l`,`xl`],noDefaultSize:i,defaultSize:a=`m`}={}){class o extends t{constructor(...e){super(...e),this._size=a}get size(){return this._size||a}set size(e){let t=i?null:a,n=e&&e.toLocaleLowerCase(),o=r.includes(n)?n:t;if(o&&this.setAttribute(`size`,o),this._size===o)return;let s=this._size;this._size=o,this.requestUpdate(`size`,s)}update(e){!this.hasAttribute(`size`)&&!i&&this.setAttribute(`size`,this.size),super.update(e)}}return e([n({type:String})],o.prototype,`size`,null),o}var h=/* @__PURE__ */ function(e){return e.Top=`top`,e.Bottom=`bottom`,e}({}),g=/* @__PURE__ */ function(e){return e.Asc=`asc`,e.Desc=`desc`,e}({}),_=/* @__PURE__ */ function(e){return e.Measure=`measure`,e.Category=`category`,e}({}),v=5,y=Array.isArray;function b(e){return typeof e==`string`}function x(e){let t={...e};return!t.datasetId&&t.set&&(t.datasetId=t.set),!t.set&&t.datasetId&&(t.set=t.datasetId),!t.columnId&&t.column&&(t.columnId=t.column),!t.column&&t.columnId&&(t.column=t.columnId),!t.formulaId&&t.formula&&(t.formulaId=t.formula),!t.formula&&t.formulaId&&(t.formula=t.formulaId),t}function S(e){return y(e)?e:Object.entries(e).map(([e,t])=>({name:e,content:y(t)?t:[]}))}function C(e){let t=/* @__PURE__ */ new Set;for(let n of e)for(let e of n.content){let n=e.datasetId??e.set;b(n)&&t.add(n)}return[...t]}function w(e){let t=S(e.slots??[]),n=e.options??{},r=n.interactivity;return{type:e.type,options:{...n,interactivity:{...r,scheduledExport:!1}},slots:t.map(e=>({...e,content:y(e.content)?e.content.map(e=>x(e)):[]})),filters:e.filters}}function T(e,t){return{...e,options:{...e.options,theme:{...e.options.theme,...t}}}}function E(e){let t=e.find(e=>e.name===`measure`||e.name===`measures`);if(t&&t.content.length>1)return!0;let n=e.find(e=>e.name===`legend`);return n?n.content.length>0:!1}function D(e){let t=[],n=e.options;switch(e.type){case`area-chart`:case`bar-chart`:case`column-chart`:if(t.push({type:`rankingPicker`,mutationType:`rankAndSort`,ranking:n.ranking??{active:!1,number:5,direction:h.Top},sort:n.sort??{direction:g.Desc,by:_.Measure},importance:100}),E(e.slots)){let r=e.type===`area-chart`,i=r?[{key:`stacked`,label:`Stacked`},{key:`unstacked`,label:`Unstacked`},{key:`100`,label:`100%`},{key:`stream`,label:`Stream`}]:[{key:`grouped`,label:`Grouped`},{key:`stacked`,label:`Stacked`},{key:`100`,label:`100%`}],a=r?`stacked`:`grouped`;t.push({type:`optionDropdown`,mutationType:`mode`,values:i,currentValue:n.mode??a,importance:90})}break;case`donut-chart`:{let e=n.display??{};t.push({type:`optionDropdown`,mutationType:`donutLabelDisplay`,values:[{key:`withLegend`,label:`With legend`},{key:`withLabels`,label:`With labels`}],currentValue:e.categoryLabels===!0?`withLabels`:`withLegend`,importance:90});break}case`bubble-chart`:{let e=n.display??{};t.push({type:`optionDropdown`,mutationType:`bubbleValues`,values:[{key:`none`,label:`No values`},{key:`absolute`,label:`Absolute`},{key:`percentage`,label:`Percentage`}],currentValue:e.bubbleValues??e.values??`none`,importance:100});break}}return t.sort((e,t)=>t.importance-e.importance)}function O(e,t,n){let r=e.options;switch(t){case`mode`:return{...e,options:{...r,mode:n}};case`donutLabelDisplay`:{let t={...r.display??{}};return n===`withLabels`?(t.legend=!1,t.categoryLabels=!0):(t.legend=!0,t.categoryLabels=!1),{...e,options:{...r,display:t}}}case`bubbleValues`:{let t={...r.display??{}};return t.bubbleLabels=t.bubbleLabels!==!1,t.bubbleValues=n,{...e,options:{...r,display:t}}}default:return e}}function k(e,t){switch(t.type){case`slots`:return{...e,slots:t.slotsContents};case`options`:return{...e,options:t.options};case`filters`:return{...e,filters:t.filters};case`chartAction`:return O(e,t.actionType,t.key);case`rankAndSort`:return{...e,options:{...e.options,ranking:t.ranking,sort:t.sort}};case`fullReplace`:return t.chart;default:return e}}export{T as a,h as c,p as d,m as f,C as i,_ as l,D as n,w as o,s as p,S as r,v as s,k as t,g as u};
|
|
4
|
+
customElements.whenDefined(t).then(()=>{typeof e.startManagingContentDirection==`function`&&e.startManagingContentDirection(this)}):typeof e.startManagingContentDirection==`function`&&e.startManagingContentDirection(this)}this._dirParent=e}super.connectedCallback()}disconnectedCallback(){super.disconnectedCallback(),this._dirParent&&(this._dirParent===document.documentElement?r.delete(this):typeof this._dirParent.stopManagingContentDirection==`function`&&this._dirParent.stopManagingContentDirection(this),this.removeAttribute(`dir`))}}return t}var s=class extends o(t){},c=!0;try{document.body.querySelector(`:focus-visible`)}catch{c=!1}var l=e=>{if(e.shadowRoot==null||Object.hasOwn(e.dataset,`jsFocusVisible`))return()=>{};if(self.applyFocusVisiblePolyfill)self.applyFocusVisiblePolyfill(e.shadowRoot),e.manageAutoFocus&&e.manageAutoFocus();else{let t=()=>{self.applyFocusVisiblePolyfill&&e.shadowRoot&&self.applyFocusVisiblePolyfill(e.shadowRoot),e.manageAutoFocus&&e.manageAutoFocus()};return self.addEventListener(`focus-visible-polyfill-ready`,t,{once:!0}),()=>{self.removeEventListener(`focus-visible-polyfill-ready`,t)}}return()=>{}},u=e=>{let t=Symbol(`endPolyfillCoordination`);class n extends e{constructor(...e){super(...e),this[t]=null}connectedCallback(){super.connectedCallback&&super.connectedCallback(),c||requestAnimationFrame(()=>{this[t]??(this[t]=l(this))})}disconnectedCallback(){super.disconnectedCallback&&super.disconnectedCallback(),c||requestAnimationFrame(()=>{this[t]!=null&&(this[t](),this[t]=null)})}}return n};function d(){return new Promise(e=>requestAnimationFrame(()=>e()))}var f=class extends u(s){constructor(...e){super(...e),this.disabled=!1,this.autofocus=!1,this._tabIndex=0,this.manipulatingTabindex=!1,this.autofocusReady=Promise.resolve()}get tabIndex(){if(this.focusElement===this){let e=this.hasAttribute(`tabindex`)?Number(this.getAttribute(`tabindex`)):NaN;return Number.isNaN(e)?-1:e}let e=Number.parseFloat(this.hasAttribute(`tabindex`)&&this.getAttribute(`tabindex`)||`0`);return this.disabled||e<0?-1:this.focusElement?this._tabIndex:e}set tabIndex(e){if(this.manipulatingTabindex)this.manipulatingTabindex=!1;else if(this.focusElement===this){if(this.disabled)this._tabIndex=e;else if(e!==this._tabIndex){this._tabIndex=e;let t=``+e;this.manipulatingTabindex=!0,this.setAttribute(`tabindex`,t)}}else if(e===-1?this.addEventListener(`pointerdown`,this.onPointerdownManagementOfTabIndex):(this.manipulatingTabindex=!0,this.removeEventListener(`pointerdown`,this.onPointerdownManagementOfTabIndex)),e===-1||this.disabled){if(this.manipulatingTabindex=!0,this.setAttribute(`tabindex`,`-1`),this.removeAttribute(`focusable`),this.selfManageFocusElement)return;e===-1?this.focusElement?.removeAttribute(`tabindex`):(this._tabIndex=e,this.manageFocusElementTabindex(e))}else this.setAttribute(`focusable`,``),this.hasAttribute(`tabindex`)?this.removeAttribute(`tabindex`):this.manipulatingTabindex=!1,this._tabIndex=e,this.manageFocusElementTabindex(e)}onPointerdownManagementOfTabIndex(){this.tabIndex===-1&&setTimeout(()=>{this.tabIndex=0,this.focus({preventScroll:!0}),this.tabIndex=-1})}async manageFocusElementTabindex(e){this.focusElement||await this.updateComplete,e===null?this.focusElement.removeAttribute(`tabindex`):this.focusElement!==this&&(this.focusElement.tabIndex=e)}get focusElement(){throw Error(`Must implement focusElement getter!`)}get selfManageFocusElement(){return!1}focus(e){!this.disabled&&this.focusElement&&(this.focusElement===this?Reflect.apply(HTMLElement.prototype.focus,this,[e]):this.focusElement.focus(e))}blur(){let e=this.focusElement||this;e===this?HTMLElement.prototype.blur.apply(this):e.blur()}click(){if(this.disabled)return;let e=this.focusElement||this;e===this?HTMLElement.prototype.click.apply(this):e.click()}manageAutoFocus(){this.autofocus&&(this.dispatchEvent(new KeyboardEvent(`keydown`,{code:`Tab`})),this.focusElement.focus())}firstUpdated(e){super.firstUpdated(e),this.hasAttribute(`tabindex`)&&this.getAttribute(`tabindex`)===`-1`||this.setAttribute(`focusable`,``)}update(e){e.has(`disabled`)&&this.handleDisabledChanged(this.disabled,e.get(`disabled`)),super.update(e)}updated(e){super.updated(e),e.has(`disabled`)&&this.disabled&&this.blur()}async handleDisabledChanged(e,t){let n=()=>this.focusElement!==this&&this.focusElement.disabled!==void 0;e?(this.manipulatingTabindex=!0,this.setAttribute(`tabindex`,`-1`),await this.updateComplete,n()?this.focusElement.disabled=!0:this.setAttribute(`aria-disabled`,`true`)):t&&(this.manipulatingTabindex=!0,this.focusElement===this?this.setAttribute(`tabindex`,``+this._tabIndex):this.removeAttribute(`tabindex`),await this.updateComplete,n()?this.focusElement.disabled=!1:this.removeAttribute(`aria-disabled`))}async getUpdateComplete(){let e=await super.getUpdateComplete();return await this.autofocusReady,e}connectedCallback(){super.connectedCallback(),this.autofocus&&(this.autofocusReady=(async()=>{await d(),await d()})(),this.updateComplete.then(()=>this.manageAutoFocus()))}};e([n({type:Boolean,reflect:!0})],f.prototype,`disabled`,void 0),e([n({type:Boolean})],f.prototype,`autofocus`,void 0),e([n({type:Number})],f.prototype,`tabIndex`,null);var p={xxs:`xxs`,xs:`xs`,s:`s`,m:`m`,l:`l`,xl:`xl`,xxl:`xxl`};function m(t,{validSizes:r=[`s`,`m`,`l`,`xl`],noDefaultSize:i,defaultSize:a=`m`}={}){class o extends t{constructor(...e){super(...e),this._size=a}get size(){return this._size||a}set size(e){let t=i?null:a,n=e&&e.toLocaleLowerCase(),o=r.includes(n)?n:t;if(o&&this.setAttribute(`size`,o),this._size===o)return;let s=this._size;this._size=o,this.requestUpdate(`size`,s)}update(e){!this.hasAttribute(`size`)&&!i&&this.setAttribute(`size`,this.size),super.update(e)}}return e([n({type:String})],o.prototype,`size`,null),o}function h(e){return e==null}function g(e){return typeof e==`string`||e instanceof String}function _(e){return!Number.isNaN(e)&&Number.isFinite(e)}function v(e){return typeof e==`boolean`}function y(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function b(e){return typeof e==`object`&&!!e&&Object.keys(e).length===0}var x=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function S(e){return typeof e==`string`&&x.test(e)}function C(e){let t=[],n=[];for(let r of e)S(r)?t.push(r):n.push(r);return{valid:t,invalid:n}}var w=/* @__PURE__ */ function(e){return e.Top=`top`,e.Bottom=`bottom`,e}({}),T=/* @__PURE__ */ function(e){return e.Asc=`asc`,e.Desc=`desc`,e}({}),E=/* @__PURE__ */ function(e){return e.Measure=`measure`,e.Category=`category`,e}({}),D=5,O=Array.isArray;function k(e){return typeof e==`string`}function A(e){let t={...e};return!t.datasetId&&t.set&&(t.datasetId=t.set),!t.set&&t.datasetId&&(t.set=t.datasetId),!t.columnId&&t.column&&(t.columnId=t.column),!t.column&&t.columnId&&(t.column=t.columnId),!t.formulaId&&t.formula&&S(t.formula)&&(t.formulaId=t.formula),!t.formula&&t.formulaId&&(t.formula=t.formulaId),t}function j(e){return O(e)?e:Object.entries(e).map(([e,t])=>({name:e,content:O(t)?t:[]}))}function M(e){let t=/* @__PURE__ */ new Set;for(let n of e)for(let e of n.content){let n=e.datasetId??e.set;k(n)&&t.add(n)}return[...t]}function N(e){let t=j(e.slots??[]),n=e.options??{},r=n.interactivity;return{type:e.type,options:{...n,interactivity:{...r,scheduledExport:!1}},slots:t.map(e=>({...e,content:O(e.content)?e.content.map(e=>A(e)):[]})),filters:e.filters,inlineData:e.inlineData}}function P(e,t){if(!t)return e;let n={...e};for(let[e,r]of Object.entries(t)){let t=n[e];n[e]=y(t)&&y(r)?{...t,...r}:r}return n}function F(e,t){return{...e,options:{...e.options,theme:{...e.options.theme,...t}}}}function I(e){let t=e.find(e=>e.name===`measure`||e.name===`measures`);if(t&&t.content.length>1)return!0;let n=e.find(e=>e.name===`legend`);return n?n.content.length>0:!1}function L(e){let t=[],n=e.options;switch(e.type){case`area-chart`:case`bar-chart`:case`column-chart`:if(e.inlineData||t.push({type:`rankingPicker`,mutationType:`rankAndSort`,ranking:n.ranking??{active:!1,number:5,direction:w.Top},sort:n.sort??{direction:T.Desc,by:E.Measure},importance:100}),I(e.slots)){let r=e.type===`area-chart`,i=r?[{key:`stacked`,label:`Stacked`},{key:`unstacked`,label:`Unstacked`},{key:`100`,label:`100%`},{key:`stream`,label:`Stream`}]:[{key:`grouped`,label:`Grouped`},{key:`stacked`,label:`Stacked`},{key:`100`,label:`100%`}],a=r?`stacked`:`grouped`;t.push({type:`optionDropdown`,mutationType:`mode`,values:i,currentValue:n.mode??a,importance:90})}break;case`donut-chart`:{let e=n.display??{};t.push({type:`optionDropdown`,mutationType:`donutLabelDisplay`,values:[{key:`withLegend`,label:`With legend`},{key:`withLabels`,label:`With labels`}],currentValue:e.categoryLabels===!0?`withLabels`:`withLegend`,importance:90});break}case`bubble-chart`:{let e=n.display??{};t.push({type:`optionDropdown`,mutationType:`bubbleValues`,values:[{key:`none`,label:`No values`},{key:`absolute`,label:`Absolute`},{key:`percentage`,label:`Percentage`}],currentValue:e.bubbleValues??e.values??`none`,importance:100});break}}return t.sort((e,t)=>t.importance-e.importance)}function R(e,t,n){let r=e.options;switch(t){case`mode`:return{...e,options:{...r,mode:n}};case`donutLabelDisplay`:{let t={...r.display??{}};return n===`withLabels`?(t.legend=!1,t.categoryLabels=!0):(t.legend=!0,t.categoryLabels=!1),{...e,options:{...r,display:t}}}case`bubbleValues`:{let t={...r.display??{}};return t.bubbleLabels=t.bubbleLabels!==!1,t.bubbleValues=n,{...e,options:{...r,display:t}}}default:return e}}function z(e,t){switch(t.type){case`slots`:return{...e,slots:t.slotsContents};case`options`:return{...e,options:t.options};case`filters`:return{...e,filters:t.filters};case`chartAction`:return R(e,t.actionType,t.key);case`rankAndSort`:return{...e,options:{...e.options,ranking:t.ranking,sort:t.sort}};case`fullReplace`:return t.chart;default:return e}}export{s as S,g as _,P as a,p as b,D as c,T as d,v as f,y as g,_ as h,M as i,w as l,b as m,L as n,F as o,h as p,j as r,N as s,z as t,E as u,S as v,m as x,C as y};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
|
|
2
|
-
import{t as e}from"./info-tooltip-options.config-DtfU5ZO8.js";import{t}from"./interactivity-options.config-09eXx6k6.js";import{n,t as r}from"./color-palettes-B41FvzWH.js";import{t as i}from"./map-tile-providers-DZT1QZX_.js";import{n as a,r as o,t as s}from"./color-range-utils-
|
|
2
|
+
import{t as e}from"./info-tooltip-options.config-DtfU5ZO8.js";import{t}from"./interactivity-options.config-09eXx6k6.js";import{n,t as r}from"./color-palettes-B41FvzWH.js";import{t as i}from"./map-tile-providers-DZT1QZX_.js";import{n as a,r as o,t as s}from"./color-range-utils-BVyHBRiq.js";var c=(e,t)=>{let n=`colors${t}`;return r()[e]?.[n]},l=[{key:`general`,type:`group`,open:!0,children:[{key:`display.title`,control:{type:`switch`,label:`Title`,default:!0}},{key:`display.legend`,control:{type:`switch`,label:`Legend`,default:!0}}]},{key:`map`,type:`group`,open:!0,children:[{key:`enabled.zoom`,control:{type:`switch`,label:`Zoom`,default:!0}},{key:`enabled.pan`,control:{type:`switch`,label:`Pan`,default:!0}},{key:`enabled.pitchBearing`,control:{type:`switch`,label:`Pitch & Rotate`,tooltip:`Use ctrl + drag`,default:!1}},{type:`divider`},{key:`vectorTileProvider`,control:{type:`picker`,label:`Map style`,default:`Basic`,enum:[`No Tiles`,`Basic`,`Bright`,`Dark`,`Fiord`,`Liberty`,`Pastel`,`Positron`,`Streets`,`Toner`,`Topographique`,`Voyager`,`3D buildings`],parseValue:e=>e?.name||`Basic`,toValue:e=>i[e]??{}}}]},{key:`colors`,type:`group`,open:!0,children:[{key:`opacity`,control:{type:`slider`,label:`Opacity`,default:.85,min:.2,max:1,step:.01}},{key:`colorsClassType`,control:{type:`picker`,label:`Colors type`,default:`sequential`,enum:[`sequential`,`divergent`,`manual`],calculateValue:({options:e})=>e?.colorsClass===`manual`?`manual`:r()?.[e?.colorsClass]?.type??`sequential`,toOptions:({options:e,value:t})=>{let i=e?.colorsClass??`PuBu`,c=e?.numberClasses??5,l=a(e?.manualValues?.ranges),u=i===`manual`?`manual`:i,d;t===`manual`?d=`manual`:t!==r()?.[e?.colorsClass]?.type&&(d=n(t??`sequential`)[0]);let f={...e,colorsClass:d};if(t===`manual`||e?.classification===`manual`){let e=s(c,t===`manual`?u:d,l);f.manualValues={...f.manualValues,ranges:o(e)}}else delete f?.manualValues?.ranges;return f}}},{key:`colorsClass`,control:{type:`color-palette-picker`,label:`Color palette`,hideLabel:!0,default:({options:e})=>{let t=r()?.[e?.colorsClass]?.type;return n(t??`sequential`)[0]},enum:({options:e})=>{let t=r()?.[e?.colorsClass]?.type;return n(t??`sequential`)},toOptions:({options:e,value:t})=>{let n={...e,colorsClass:t};if(e?.classification===`manual`){let r=c(t,e?.numberClasses??5);n.manualValues={...n.manualValues,ranges:e?.manualValues?.ranges?.map(e=>({...e,color:typeof e.val==`number`?r?.[e.val]:void 0}))}}return n}},visibleIf:({options:e})=>e?.colorsClass!==`manual`},{key:`manualValues.ranges`,control:{type:`color-range`,editRangeSize:!1,debounce:500,noValues:!0,noAlphaChannel:!0,label:`Manual range colors`,hideLabel:!0},calculateValue:({options:e})=>s(e?.numberClasses,e?.colorsClass,a(e?.manualValues?.ranges)),toOptions:({options:e,value:t})=>({...e,manualValues:{...e.manualValues,ranges:o(t)}}),visibleIf:({options:e})=>e?.colorsClass===`manual`}]},{key:`classification`,type:`group`,open:!0,children:[{key:`numberClasses`,control:{type:`picker`,label:`Number of classes`,default:`5`,enum:[`3`,`4`,`5`,`6`,`7`,`8`,`9`],parseValue:e=>e?.toString()??`5`,toOptions:({options:e,value:t})=>{let n=Number.parseInt(t,10)||5,r={...e,numberClasses:n};if(e?.classification===`manual`||e?.colorsClass===`manual`){let n=s(t,e?.colorsClass,a(e?.manualValues?.ranges));r.manualValues={...r.manualValues,ranges:o(n)}}return r}}},{key:`classification`,control:{type:`picker`,label:`Method`,default:`interval`,enum:[`interval`,`manual`,`quantile`,`continuous`],toOptions:({options:e,value:t})=>{let n={...e,classification:t};if(t===`manual`||e?.colorsClass===`manual`){let t=s(e?.numberClasses,e?.colorsClass,a(e?.manualValues?.ranges));n.manualValues={...n.manualValues,ranges:o(t)}}else delete n?.manualValues?.ranges;return n}}},{key:`manualValues.rangesValues`,control:{type:`color-range`,editRangeSize:!1,debounce:500,noValues:!1,readOnlyColorPicker:!0,label:`Manual range values`,hideLabel:!0,calculateValue:({options:e})=>s(e?.numberClasses,e?.colorsClass,a(e?.manualValues?.ranges)),toOptions:({options:e,value:t})=>({...e,manualValues:{...e.manualValues,ranges:o(t)}})},visibleIf:({options:e})=>e?.classification===`manual`}]},{key:`legend`,type:`group`,open:!1,children:[{key:`legend.type`,control:{type:`picker`,label:`Type`,default:`bar`,enum:[`bar`,`list`]}},{key:`legend.size`,control:{type:`radio-button-group`,label:`Size`,default:`M`,enum:[`S`,`M`,`L`]}},{key:`legend.position`,control:{type:`position-picker`,label:`Position`,default:`bottomLeft`,enum:[`topLeft`,`top`,`topRight`,`right`,`bottomRight`,`bottom`,`bottomLeft`,`left`]}}],visibleIf:({options:e})=>e?.display?.legend===!0},e(),t({select:{default:!0}})];export{l as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
|
|
2
|
-
import{t as e}from"./color-palettes-B41FvzWH.js";import{t}from"./embed-
|
|
2
|
+
import{t as e}from"./color-palettes-B41FvzWH.js";import{t}from"./embed-Bv1ps-EM.js";var n=(e,n=.1)=>{if(e.length<2)return`#AAAAAA`;let r=e.length,i=new t(e[r-2]).to(`oklab`),a=new t(e[r-1]).to(`oklab`),o=i.coords[0],s=a.coords[0],c=Math.min(1,Math.max(0,s+(s>o?1:-1)*n));return new t(`oklab`,[c,a.coords[1],a.coords[2]],a.alpha).to(`srgb`).toString({format:`hex`,precision:0})},r=e=>e?.map(e=>({color:e.color,value:e.val}))??[],i=e=>e?.map(e=>({color:e.color,val:e.value}))??[],a=(t,r,i)=>{t=typeof t==`string`?Number.parseInt(t,10):t,t=typeof t==`number`?Math.max(Math.min(t,9),3):5;let a=Array.isArray(i)?i:[],o=Math.min(...a.map(e=>e?.value??1/0)),s=Math.max(...a.map(e=>e?.value??-1/0)),c=!1,l=typeof o==`number`&&typeof s==`number`&&o!==1/0&&s!==-1/0?s-o:0;if(a.length>t)c=o!==1/0&&s!==-1/0,a=a.slice(0,t);else if(a.length<t)for(;a.length<t;)a.push({});let u=[],d=e();if(Object.keys(d).includes(r??``))u=d[r]?.[`colors${t}`]??[];else if(r===`manual`){if(u=a.map(e=>e.color).filter(e=>e!==void 0),u.length<t)for(;u.length<t;)u.push(n(u))}else u=d.PuBu?.[`colors${t}`]??[];if(u?.forEach((e,t)=>{a[t].color=e}),a.filter(e=>e.value===void 0)?.length>0){let e=o===1/0?0:o,n=l/(t-1)||100;for(let r=0;r<t;r++)a[r].value=Number((e+r*n).toFixed(10))}if(c){let e=o===1/0?0:o,n=l/(t-1)||100;for(let r=0;r<t;r++)a[r].value=Number((e+r*n).toFixed(10))}return a};export{r as n,i as r,a as t};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
|
|
2
|
+
import{v as e,y as t}from"./chart-helpers-DZsidiCl.js";var n=class{constructor(){this.listeners=/* @__PURE__ */ new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},r=new class extends n{#e;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e();return window.addEventListener(`visibilitychange`,t,!1),()=>{window.removeEventListener(`visibilitychange`,t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(e=>{typeof e==`boolean`?this.setFocused(e):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){let e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#e==`boolean`?this.#e:globalThis.document?.visibilityState!==`hidden`}},i={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},a=new class{#e=i;setTimeoutProvider(e){this.#e=e}setTimeout(e,t){return this.#e.setTimeout(e,t)}clearTimeout(e){this.#e.clearTimeout(e)}setInterval(e,t){return this.#e.setInterval(e,t)}clearInterval(e){this.#e.clearInterval(e)}};function o(e){setTimeout(e,0)}var s=typeof window>`u`||`Deno`in globalThis;function c(){}function l(e,t){return typeof e==`function`?e(t):e}function u(e){return typeof e==`number`&&e>=0&&e!==1/0}function d(e,t){return Math.max(e+(t||0)-Date.now(),0)}function f(e,t){return typeof e==`function`?e(t):e}function p(e,t){return typeof e==`function`?e(t):e}function m(e,t){let{type:n=`all`,exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:s}=e;if(o){if(r){if(t.queryHash!==g(o,t.options))return!1}else if(!v(t.queryKey,o))return!1}if(n!==`all`){let e=t.isActive();if(n===`active`&&!e||n===`inactive`&&e)return!1}return!(typeof s==`boolean`&&t.isStale()!==s||i&&i!==t.state.fetchStatus||a&&!a(t))}function h(e,t){let{exact:n,status:r,predicate:i,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(_(t.options.mutationKey)!==_(a))return!1}else if(!v(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function g(e,t){return(t?.queryKeyHashFn||_)(e)}function _(e){return JSON.stringify(e,(e,t)=>S(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):t)}function v(e,t){return e===t?!0:typeof e==typeof t&&e&&t&&typeof e==`object`&&typeof t==`object`?Object.keys(t).every(n=>v(e[n],t[n])):!1}var y=Object.prototype.hasOwnProperty;function b(e,t,n=0){if(e===t)return e;if(n>500)return t;let r=x(e)&&x(t);if(!r&&!(S(e)&&S(t)))return t;let i=(r?e:Object.keys(e)).length,a=r?t:Object.keys(t),o=a.length,s=r?Array(o):{},c=0;for(let l=0;l<o;l++){let o=r?l:a[l],u=e[o],d=t[o];if(u===d){s[o]=u,(r?l<i:y.call(e,o))&&c++;continue}if(u===null||d===null||typeof u!=`object`||typeof d!=`object`){s[o]=d;continue}let f=b(u,d,n+1);s[o]=f,f===u&&c++}return i===o&&c===i?e:s}function x(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function S(e){if(!C(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!C(n)||!n.hasOwnProperty(`isPrototypeOf`)||Object.getPrototypeOf(e)!==Object.prototype)}function C(e){return Object.prototype.toString.call(e)===`[object Object]`}function w(e){return new Promise(t=>{a.setTimeout(t,e)})}function T(e,t,n){return typeof n.structuralSharing==`function`?n.structuralSharing(e,t):n.structuralSharing===!1?t:b(e,t)}function E(e,t,n=0){let r=[...e,t];return n&&r.length>n?r.slice(1):r}function D(e,t,n=0){let r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var O=/* @__PURE__ */ Symbol();function k(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===O?()=>Promise.reject(/* @__PURE__ */ Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function A(e,t,n){let r=!1,i;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(i??=t(),r||(r=!0,i.aborted?n():i.addEventListener(`abort`,n,{once:!0})),i)}),e}var j=/* @__PURE__ */ (()=>{let e=()=>s;return{isServer(){return e()},setIsServer(t){e=t}}})();function M(){let e,t,n=new Promise((n,r)=>{e=n,t=r});n.status=`pending`,n.catch(()=>{});function r(e){Object.assign(n,e),delete n.resolve,delete n.reject}return n.resolve=t=>{r({status:`fulfilled`,value:t}),e(t)},n.reject=e=>{r({status:`rejected`,reason:e}),t(e)},n}var N=o;function P(){let e=[],t=0,n=e=>{e()},r=e=>{e()},i=N,a=r=>{t?e.push(r):i(()=>{n(r)})},o=()=>{let t=e;e=[],t.length&&i(()=>{r(()=>{t.forEach(e=>{n(e)})})})};return{batch:e=>{let n;t++;try{n=e()}finally{t--,t||o()}return n},batchCalls:e=>(...t)=>{a(()=>{e(...t)})},schedule:a,setNotifyFunction:e=>{n=e},setBatchNotifyFunction:e=>{r=e},setScheduler:e=>{i=e}}}var F=P(),I=new class extends n{#e=!0;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e(!0),n=()=>e(!1);return window.addEventListener(`online`,t,!1),window.addEventListener(`offline`,n,!1),()=>{window.removeEventListener(`online`,t),window.removeEventListener(`offline`,n)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#e!==e&&(this.#e=e,this.listeners.forEach(t=>{t(e)}))}isOnline(){return this.#e}};function L(e){return Math.min(1e3*2**e,3e4)}function R(e){return(e??`online`)!==`online`||I.isOnline()}var z=class extends Error{constructor(e){super(`CancelledError`),this.revert=e?.revert,this.silent=e?.silent}};function B(e){let t=!1,n=0,i,a=M(),o=()=>a.status!==`pending`,s=t=>{if(!o()){let n=new z(t);p(n),e.onCancel?.(n)}},c=()=>{t=!0},l=()=>{t=!1},u=()=>r.isFocused()&&(e.networkMode===`always`||I.isOnline())&&e.canRun(),d=()=>R(e.networkMode)&&e.canRun(),f=e=>{o()||(i?.(),a.resolve(e))},p=e=>{o()||(i?.(),a.reject(e))},m=()=>new Promise(t=>{i=e=>{(o()||u())&&t(e)},e.onPause?.()}).then(()=>{i=void 0,o()||e.onContinue?.()}),h=()=>{if(o())return;let r,i=n===0?e.initialPromise:void 0;try{r=i??e.fn()}catch(e){r=Promise.reject(e)}Promise.resolve(r).then(f).catch(r=>{if(o())return;let i=e.retry??(j.isServer()?0:3),a=e.retryDelay??L,s=typeof a==`function`?a(n,r):a,c=i===!0||typeof i==`number`&&n<i||typeof i==`function`&&i(n,r);t||!c?p(r):(n++,e.onFail?.(n,r),w(s).then(()=>u()?void 0:m()).then(()=>{t?p(r):h()}))})};return{promise:a,status:()=>a.status,cancel:s,continue:()=>(i?.(),a),cancelRetry:c,continueRetry:l,canStart:d,start:()=>(d()?h():m().then(h),a)}}var V=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),u(this.gcTime)&&(this.#e=a.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(j.isServer()?1/0:3e5))}clearGcTimeout(){this.#e!==void 0&&(a.clearTimeout(this.#e),this.#e=void 0)}};function H(e){return{onFetch:(t,n)=>{let r=t.options,i=t.fetchOptions?.meta?.fetchMore?.direction,a=t.state.data?.pages||[],o=t.state.data?.pageParams||[],s={pages:[],pageParams:[]},c=0,l=async()=>{let n=!1,l=e=>{A(e,()=>t.signal,()=>n=!0)},u=k(t.options,t.fetchOptions),d=async(e,r,i)=>{if(n)return Promise.reject(t.signal.reason);if(r==null&&e.pages.length)return Promise.resolve(e);let a=(()=>{let e={client:t.client,queryKey:t.queryKey,pageParam:r,direction:i?`backward`:`forward`,meta:t.options.meta};return l(e),e})(),o=await u(a),{maxPages:s}=t.options,c=i?D:E;return{pages:c(e.pages,o,s),pageParams:c(e.pageParams,r,s)}};if(i&&a.length){let e=i===`backward`,t=e?W:U,n={pages:a,pageParams:o};s=await d(n,t(r,n),e)}else{let t=e??a.length;do{let e=c===0?o[0]??r.initialPageParam:U(r,s);if(c>0&&e==null)break;s=await d(s,e),c++}while(c<t)}return s};t.fetchFn=t.options.persister?()=>t.options.persister?.(l,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):l}}}function U(e,{pages:t,pageParams:n}){let r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function W(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}var G=class extends V{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e){super(),this.#s=!1,this.#o=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#i=e.client,this.#r=this.#i.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#t=J(this.options),this.state=e.state??this.#t,this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return this.#e}get promise(){return this.#a?.promise}setOptions(e){if(this.options={...this.#o,...e},e?._type&&(this.#e=e._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let e=J(this.options);e.data!==void 0&&(this.setState(q(e.data,e.dataUpdatedAt)),this.#t=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus===`idle`&&this.#r.remove(this)}setData(e,t){let n=T(this.state.data,e,this.options);return this.#l({data:n,type:`success`,dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e){this.#l({type:`setState`,state:e})}cancel(e){let t=this.#a?.promise;return this.#a?.cancel(e),t?t.then(c).catch(c):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#t}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(e=>p(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===O||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0&&this.observers.some(e=>f(e.options.staleTime,this)===`static`)}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e===`static`?!1:this.state.isInvalidated?!0:!d(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#a?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#a?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#r.notify({type:`observerAdded`,query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(this.#a&&(this.#s||this.#c()?this.#a.cancel({revert:!0}):this.#a.cancelRetry()),this.scheduleGc()),this.#r.notify({type:`observerRemoved`,query:this,observer:e}))}getObserversCount(){return this.observers.length}#c(){return this.state.fetchStatus===`paused`&&this.state.status===`pending`}invalidate(){this.state.isInvalidated||this.#l({type:`invalidate`})}async fetch(e,t){if(this.state.fetchStatus!==`idle`&&this.#a?.status()!==`rejected`){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#a)return this.#a.continueRetry(),this.#a.promise}if(e&&this.setOptions(e),!this.options.queryFn){let e=this.observers.find(e=>e.options.queryFn);e&&this.setOptions(e.options)}let n=new AbortController,r=e=>{Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(this.#s=!0,n.signal)})},i=()=>{let e=k(this.options,t),n=(()=>{let e={client:this.#i,queryKey:this.queryKey,meta:this.meta};return r(e),e})();return this.#s=!1,this.options.persister?this.options.persister(e,n,this):e(n)},a=(()=>{let e={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#i,state:this.state,fetchFn:i};return r(e),e})();(this.#e===`infinite`?H(this.options.pages):this.options.behavior)?.onFetch(a,this),this.#n=this.state,(this.state.fetchStatus===`idle`||this.state.fetchMeta!==a.fetchOptions?.meta)&&this.#l({type:`fetch`,meta:a.fetchOptions?.meta}),this.#a=B({initialPromise:t?.initialPromise,fn:a.fetchFn,onCancel:e=>{e instanceof z&&e.revert&&this.setState({...this.#n,fetchStatus:`idle`}),n.abort()},onFail:(e,t)=>{this.#l({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#l({type:`pause`})},onContinue:()=>{this.#l({type:`continue`})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0});try{let e=await this.#a.start();if(e===void 0)throw Error(`${this.queryHash} data is undefined`);return this.setData(e),this.#r.config.onSuccess?.(e,this),this.#r.config.onSettled?.(e,this.state.error,this),e}catch(e){if(e instanceof z){if(e.silent)return this.#a.promise;if(e.revert){if(this.state.data===void 0)throw e;return this.state.data}}throw this.#l({type:`error`,error:e}),this.#r.config.onError?.(e,this),this.#r.config.onSettled?.(this.state.data,e,this),e}finally{this.scheduleGc()}}#l(e){let t=t=>{switch(e.type){case`failed`:return{...t,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case`pause`:return{...t,fetchStatus:`paused`};case`continue`:return{...t,fetchStatus:`fetching`};case`fetch`:return{...t,...K(t.data,this.options),fetchMeta:e.meta??null};case`success`:let n={...t,...q(e.data,e.dataUpdatedAt),dataUpdateCount:t.dataUpdateCount+1,...!e.manual&&{fetchStatus:`idle`,fetchFailureCount:0,fetchFailureReason:null}};return this.#n=e.manual?n:void 0,n;case`error`:let r=e.error;return{...t,error:r,errorUpdateCount:t.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:t.fetchFailureCount+1,fetchFailureReason:r,fetchStatus:`idle`,status:`error`,isInvalidated:!0};case`invalidate`:return{...t,isInvalidated:!0};case`setState`:return{...t,...e.state}}};this.state=t(this.state),F.batch(()=>{this.observers.forEach(e=>{e.onQueryUpdate()}),this.#r.notify({query:this,type:`updated`,action:e})})}};function K(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:R(t.networkMode)?`fetching`:`paused`,...e===void 0&&{error:null,status:`pending`}}}function q(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:`success`}}function J(e){let t=typeof e.initialData==`function`?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt==`function`?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?`success`:`pending`,fetchStatus:`idle`}}var Y=class extends V{#e;#t;#n;#r;constructor(e){super(),this.#e=e.client,this.mutationId=e.mutationId,this.#n=e.mutationCache,this.#t=[],this.state=e.state||X(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#n.notify({type:`observerAdded`,mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#n.notify({type:`observerRemoved`,mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status===`pending`?this.scheduleGc():this.#n.remove(this))}continue(){return this.#r?.continue()??this.execute(this.state.variables)}async execute(e){let t=()=>{this.#i({type:`continue`})},n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#r=B({fn:()=>this.options.mutationFn?this.options.mutationFn(e,n):Promise.reject(/* @__PURE__ */ Error(`No mutationFn found`)),onFail:(e,t)=>{this.#i({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#i({type:`pause`})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)});let r=this.state.status===`pending`,i=!this.#r.canStart();try{if(r)t();else{this.#i({type:`pending`,variables:e,isPaused:i}),this.#n.config.onMutate&&await this.#n.config.onMutate(e,this,n);let t=await this.options.onMutate?.(e,n);t!==this.state.context&&this.#i({type:`pending`,context:t,variables:e,isPaused:i})}let a=await this.#r.start();return await this.#n.config.onSuccess?.(a,e,this.state.context,this,n),await this.options.onSuccess?.(a,e,this.state.context,n),await this.#n.config.onSettled?.(a,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(a,null,e,this.state.context,n),this.#i({type:`success`,data:a}),a}catch(t){try{await this.#n.config.onError?.(t,e,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onError?.(t,e,this.state.context,n)}catch(e){Promise.reject(e)}try{await this.#n.config.onSettled?.(void 0,t,this.state.variables,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onSettled?.(void 0,t,e,this.state.context,n)}catch(e){Promise.reject(e)}throw this.#i({type:`error`,error:t}),t}finally{this.#n.runNext(this)}}#i(e){let t=t=>{switch(e.type){case`failed`:return{...t,failureCount:e.failureCount,failureReason:e.error};case`pause`:return{...t,isPaused:!0};case`continue`:return{...t,isPaused:!1};case`pending`:return{...t,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:`pending`,variables:e.variables,submittedAt:Date.now()};case`success`:return{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:`success`,isPaused:!1};case`error`:return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPaused:!1,status:`error`}}};this.state=t(this.state),F.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function X(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var Z=class extends n{constructor(e={}){super(),this.config=e,this.#e=/* @__PURE__ */ new Set,this.#t=/* @__PURE__ */ new Map,this.#n=0}#e;#t;#n;build(e,t,n){let r=new Y({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#e.add(e);let t=Q(e);if(typeof t==`string`){let n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:`added`,mutation:e})}remove(e){if(this.#e.delete(e)){let t=Q(e);if(typeof t==`string`){let n=this.#t.get(t);if(n){if(n.length>1){let t=n.indexOf(e);t!==-1&&n.splice(t,1)}else n[0]===e&&this.#t.delete(t)}}}this.notify({type:`removed`,mutation:e})}canRun(e){let t=Q(e);if(typeof t==`string`){let n=this.#t.get(t)?.find(e=>e.state.status===`pending`);return!n||n===e}return!0}runNext(e){let t=Q(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){F.batch(()=>{this.#e.forEach(e=>{this.notify({type:`removed`,mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(e=>h(t,e))}findAll(e={}){return this.getAll().filter(t=>h(e,t))}notify(e){F.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return F.batch(()=>Promise.all(e.map(e=>e.continue().catch(c))))}};function Q(e){return e.options.scope?.id}var ee=class extends n{constructor(e={}){super(),this.config=e,this.#e=/* @__PURE__ */ new Map}#e;build(e,t,n){let r=t.queryKey,i=t.queryHash??g(r,t),a=this.get(i);return a||(a=new G({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(a)),a}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:`added`,query:e}))}remove(e){let t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:`removed`,query:e}))}clear(){F.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(e=>m(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>m(e,t)):t}notify(e){F.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){F.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){F.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},te=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new ee,this.#t=e.mutationCache||new Z,this.#n=e.defaultOptions||{},this.#r=/* @__PURE__ */ new Map,this.#i=/* @__PURE__ */ new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=r.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=I.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:`fetching`}).length}isMutating(e){return this.#t.findAll({...e,status:`pending`}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),n=this.#e.build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(f(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,n){let r=this.defaultQueryOptions({queryKey:e}),i=this.#e.get(r.queryHash)?.state.data,a=l(t,i);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return F.batch(()=>this.#e.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,n)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;F.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return F.batch(()=>(n.findAll(e).forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,...e},t)))}cancelQueries(e,t={}){let n={revert:!0,...t},r=F.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(c).catch(c)}invalidateQueries(e,t={}){return F.batch(()=>(this.#e.findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType===`none`?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??`active`},t)))}refetchQueries(e,t={}){let n={...t,cancelRefetch:t.cancelRefetch??!0},r=F.batch(()=>this.#e.findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,n);return n.throwOnError||(t=t.catch(c)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(c)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t);return n.isStaleByTime(f(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(c).catch(c)}fetchInfiniteQuery(e){return e._type=`infinite`,this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(c).catch(c)}ensureInfiniteQueryData(e){return e._type=`infinite`,this.ensureQueryData(e)}resumePausedMutations(){return I.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(_(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{v(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(_(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{v(e,t.mutationKey)&&Object.assign(n,t.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||=g(t.queryKey,t),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!==`always`),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode=`offlineFirst`),t.queryFn===O&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},$=class n{constructor(e={}){this.availableDatasets=[],this.apiUrl=e.apiUrl||`https://api.luzmo.com`,this.apiVersion=e.apiVersion||`0.1.0`,this.authKey=e.authKey||``,this.authToken=e.authToken||``,this.queryClient=new te({defaultOptions:{queries:{staleTime:e.staleTime||3e5,gcTime:e.gcTime||6e5,retry:e.retry||3,retryDelay:e.retryDelay||(e=>Math.min(1e3*2**e,3e4))}}}),e.skipNetworkListeners||this.initNetworkListeners()}_normalizeUrl(e){try{let t=new URL(e);return t.origin+t.pathname.replace(/\/$/,``)}catch{return e}}configure(e={}){let t=e.apiUrl===void 0?void 0:this._normalizeUrl(e.apiUrl),n=this._normalizeUrl(this.apiUrl),r=e.authKey!==void 0&&e.authKey!==``&&e.authKey!==this.authKey||e.authToken!==void 0&&e.authToken!==``&&e.authToken!==this.authToken||t!==void 0&&t!==n;if(e.apiVersion&&(this.apiVersion=e.apiVersion),e.apiUrl!==void 0&&(this.apiUrl=e.apiUrl),e.authKey!==void 0&&(this.authKey=e.authKey),e.authToken!==void 0&&(this.authToken=e.authToken),r&&(this.queryClient.clear(),this.availableDatasets=[]),e.staleTime||e.gcTime||e.retry){let t={};e.staleTime&&(t.staleTime=e.staleTime),e.gcTime&&(t.gcTime=e.gcTime),e.retry&&(t.retry=e.retry),this.queryClient.setDefaultOptions({queries:{...this.queryClient.getDefaultOptions().queries,...t}})}}clearLocalCache(){this.queryClient.clear(),this.availableDatasets=[]}initNetworkListeners(){typeof window<`u`&&window.addEventListener(`online`,()=>{console.warn(`Network connection restored, refreshing data...`),this.refreshAll()})}getHeaders(e={}){return{"Content-Type":`application/json`,...e}}async fetchApi(e,t,n={}){let r=`${this.apiUrl}/${this.apiVersion}${e}`,i={method:n.method||`POST`,headers:this.getHeaders(n.headers),mode:`cors`,...n};t!==void 0&&(t.key=this.authKey,t.token=this.authToken,i.body=JSON.stringify(t));try{let t=await fetch(r,i);if(!t.ok){let n=await t.json().catch(()=>null);throw t.status===401||t.status===403?Error(`Authentication failed. Please check your API token.`):t.status===404?Error(`Resource not found: ${e}`):t.status===429?Error(`Rate limit exceeded. Please try again later.`):Error(n?.message||`API request failed with status ${t.status}`)}return await t.json()}catch(t){throw console.error(`API request to ${e} failed:`,t),t instanceof Error&&(t.endpoint=e,t.timestamp=(/* @__PURE__ */ new Date()).toISOString()),t}}async fetchAllDatasets(e={}){let t=e.offset||0,n=e.limit||50,r=[`datasets`,t,n];return await this.queryClient.fetchQuery({queryKey:r,queryFn:async()=>{let e={action:`get`,version:this.apiVersion,find:{where:{type:`dataset`},attributes:[`id`,`name`,`description`],limit:n,offset:t}},r=await this.fetchApi(`/securable`,e);return{data:r?.rows??[],pagination:{offset:t,limit:n,total:r?.count??0,pages:Math.ceil((r?.count??0)/n)}}}})}async searchDatasets(e,t){if(!e)return{data:[]};let n=[`datasets`,`search`,e,t];return await this.queryClient.fetchQuery({queryKey:n,queryFn:async()=>{let n={action:`get`,version:this.apiVersion,find:{where:{type:`dataset`}}};e?.length>0&&(n.find.search={match_types:[`name`],keyphrase:e}),t?.offset&&(n.find.offset=t?.offset),t?.limit&&(n.find.limit=t?.limit);let r=await this.fetchApi(`/securable`,n),i={data:r?.rows??[]};return t?.limit&&(i.pagination={offset:t?.offset??0,limit:t?.limit,total:r?.count??0,pages:Math.ceil((r?.count??0)/t?.limit)}),i}})}async fetchDatasetNames(e){if(!e||e.length===0)throw Error(`At least one dataset ID is required`);let{valid:n,invalid:r}=t(e);if(r.length>0&&console.warn(`[DataBroker] Invalid dataset IDs provided (not valid UUIDs): ${r.join(`, `)}. These will be skipped.`),n.length===0)throw Error(`No valid dataset IDs provided. Dataset IDs must be valid UUIDs.`);let i=[`dataset-names`,n,this.authKey,this.authToken];return await this.queryClient.fetchQuery({queryKey:i,queryFn:async()=>{let e={action:`get`,version:this.apiVersion,find:{where:{type:`dataset`,id:{in:n}},attributes:[`name`,`id`,`description`]}};return(await this.fetchApi(`/securable`,e))?.rows??[]}})}async fetchDatasetsWithColumnsAndFormulas(e){if(!e||e.length===0)throw Error(`At least one dataset ID is required`);let{valid:n,invalid:r}=t(e);if(r.length>0&&console.warn(`[DataBroker] Invalid dataset IDs provided (not valid UUIDs): ${r.join(`, `)}. These will be skipped.`),n.length===0)throw Error(`No valid dataset IDs provided. Dataset IDs must be valid UUIDs.`);let i=[`datasets`,n,this.authKey,this.authToken];return await this.queryClient.fetchQuery({queryKey:i,queryFn:async()=>{let e={action:`get`,version:this.apiVersion,find:{where:{type:`dataset`,id:{in:n}},attributes:[`name`,`id`,`description`],include:[{model:`Column`,attributes:[`id`,`name`,`description`,`type`,`subtype`,`format`,`hidden`,`lowestLevel`,`expression`,`duration_levels`,`duration_format`],separate:!0,order:[[`order`,`asc`]],include:[{model:`Column`,attributes:[`id`,`securable_id`,`hierarchy_enabled`,`currency_id`],as:`Joins`},{model:`HierarchyLevel`,attributes:[`id`,`level`,`name`],as:`HierarchyLevels`},{model:`Currency`,attributes:[`id`,`name`,`symbol`],as:`Currency`}]},{model:`Formula`,attributes:[`id`,`name`,`description`,`type`,`subtype`,`format`,`hidden`,`lowestLevel`,`expression`,`duration_levels`,`duration_format`],include:[{model:`Currency`,attributes:[`id`,`name`,`symbol`],as:`Currency`}]}]}};return(await this.fetchApi(`/securable`,e))?.rows??[]}})}async fetchData(e){if(!e)throw Error(`Query is required`);let t=[`data`,e];return await this.queryClient.fetchQuery({queryKey:t,queryFn:async()=>{let t={action:`get`,version:this.apiVersion,find:{queries:[e]}},n=await this.fetchApi(`/data`,t);return{data:n?.data||[],performance:n?.performance||{}}}})}getCachedData(e){let t=[`data`,e],n=this.queryClient.getQueryState(t),r=this.queryClient.getDefaultOptions().queries?.staleTime;if(n?.data&&!n.isInvalidated&&typeof r==`number`&&!(r!==1/0&&Date.now()-n.dataUpdatedAt>r))return n.data}async validate(e,t){if(!t?.expression)return{valid:!1};let n={action:`validate`,version:this.apiVersion,properties:t},r=await this.fetchApi(`/${e}`,n);return{valid:!!r?.valid,reason:r?.reason??r?.error,explanation:r?.explanation,type:r?.type}}async fetchTheme(e){if(!e)throw Error(`Theme ID is required`);let t=[`theme`,e];return await this.queryClient.fetchQuery({queryKey:t,queryFn:async()=>(await this.fetchApi(`/theme`,{action:`get`,version:this.apiVersion,find:{where:{id:e}}}))?.rows?.[0]})}refreshAll(){this.queryClient.refetchQueries()}invalidateDatasetData(e){e?(this.queryClient.invalidateQueries({queryKey:[`dataset`,e]}),this.queryClient.invalidateQueries({queryKey:[`columns`,e]})):this.queryClient.invalidateQueries({queryKey:[`datasets`]})}invalidateAll(){this.queryClient.clear()}static getInstance(e={}){return n.instance?Object.keys(e).length>0&&n.instance.configure(e):n.instance=new n(e),n.instance}async fetchDatasetsRecursive(n){if(!n||n.length===0)throw Error(`At least one dataset ID is required`);let{valid:r,invalid:i}=t(n);if(i.length>0&&console.warn(`[DataBroker] Invalid dataset IDs provided (not valid UUIDs): ${i.join(`, `)}. These will be skipped.`),r.length===0)throw Error(`No valid dataset IDs provided. Dataset IDs must be valid UUIDs.`);let a=[...new Set(r)],o=/* @__PURE__ */ new Set,s=/* @__PURE__ */ new Map,c=t=>{t&&e(t)&&!o.has(t)&&!a.includes(t)&&a.push(t)};for(;a.length>0;){let e=[];for(;a.length>0&&e.length<50;){let t=a.shift();o.has(t)||e.push(t)}if(e.length!==0)try{(await this.fetchDatasetsWithColumnsAndFormulas(e)).forEach(e=>{let t=this.postProcessDatasetMetadata(e);o.add(t.id),this.queryClient.setQueryData([`dataset`,t.id],t),(t.outgoingJoins??[]).map(e=>e.securable_id).filter(e=>!!e&&e!==t.id).forEach(e=>{c(e)}),s.set(t.id,t),this.availableDatasets.some(e=>e.id===t.id)||this.availableDatasets.push({id:t.id,name:t.name,columns:t.columns})})}catch(e){console.error(`Error fetching datasets recursively:`,e)}}return[...s.values()]}postProcessDatasetMetadata(e){let t=[],n=(e.columns??[]).map(e=>{let n=e.joins??(Array.isArray(e.joins)?e.joins:[]);Array.isArray(n)&&n.length>0&&t.push(...n);let{joins:r,...i}=e;return{...i,joins:n}});return{...e,columns:n,formulas:e.formulas??[],outgoingJoins:t,dateLoaded:/* @__PURE__ */ new Date}}getAvailableDatasets(){return this.availableDatasets}getLinkedDatasetsIds(e){let t=this.queryClient.getQueryData([`dataset`,e]);return t?(t.outgoingJoins??[]).map(e=>e.securable_id).filter(t=>!!t&&t!==e):[]}},ne=$.getInstance();export{ne as n,$ as t};
|