@databrainhq/plugin 0.17.9-beta.30 → 0.17.9-beta.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/dist/{Accordion-D3DbH3Cx.mjs → Accordion-BhLebRAm.mjs} +32 -25
  2. package/dist/{Chart-7AGA9h2g.mjs → Chart-BLXiGOie.mjs} +361 -361
  3. package/dist/{CreateGlobalFilter-oHjA0P9O.mjs → CreateGlobalFilter-DJ75cI8r.mjs} +200 -200
  4. package/dist/{CreateMetricV2-BGDt9B3L.mjs → CreateMetricV2-DNSbMIqg.mjs} +20 -20
  5. package/dist/{DraggableItem-7fQUo0x4.mjs → DraggableItem-HJ4Wt8qx.mjs} +11 -11
  6. package/dist/{HorizontalStackTable-CH68bWy3.mjs → HorizontalStackTable-DadBH16u.mjs} +17 -17
  7. package/dist/{ManageMetricsV2-tyQYXoAT.mjs → ManageMetricsV2-DQ0F-Sxo.mjs} +3 -3
  8. package/dist/{MetricCardV2-C2n6LzkA.mjs → MetricCardV2-ndXX9kcc.mjs} +1251 -1170
  9. package/dist/{NoDataFound-N3gF0Pse.mjs → NoDataFound-C6lIIOZF.mjs} +1 -1
  10. package/dist/{NoDataState-C6hX-CHr.mjs → NoDataState-Dx5ksEt-.mjs} +2 -2
  11. package/dist/{Panel-BeWefwKs.mjs → Panel-oW--_1YF.mjs} +1 -1
  12. package/dist/{PivotTableV2-De4TXsMc.mjs → PivotTableV2-BufQEGso.mjs} +2 -2
  13. package/dist/{PivotTableV3-2nzDp4Nc.mjs → PivotTableV3-DwleqfW7.mjs} +4 -4
  14. package/dist/{Portal-C4N01WKg.mjs → Portal-CuJ3yA9x.mjs} +1222 -1200
  15. package/dist/{RadioButton-DvzkXfzO.mjs → RadioButton-BagXnWOk.mjs} +1 -1
  16. package/dist/{ScheduleEmail-PEzbadHC.mjs → ScheduleEmail-C_H0_DNM.mjs} +220 -220
  17. package/dist/{SearchMetricData-CxmDM20t.mjs → SearchMetricData-DPWkvX0c.mjs} +237 -237
  18. package/dist/{SortPanel-DQjM_vyk.mjs → SortPanel-DctP-Eyd.mjs} +110 -110
  19. package/dist/{Table-CvDTChaZ.mjs → Table-BSKvdU4q.mjs} +4 -4
  20. package/dist/{TagInputField-C9M_Ip9e.mjs → TagInputField-B09tGuSM.mjs} +6 -6
  21. package/dist/{TextAreaField-Q78INHKO.mjs → TextAreaField-CLmioFXe.mjs} +113 -113
  22. package/dist/{TimeSeriesSettings-C8lvzgja.mjs → TimeSeriesSettings-BS9LodDk.mjs} +2 -2
  23. package/dist/{cardQueryError-3MGl4pbM.mjs → cardQueryError-Jo2LkSBF.mjs} +810 -790
  24. package/dist/{chevron-down-Dxhk-Tao.mjs → chevron-down-CTH4bR6n.mjs} +107 -106
  25. package/dist/{conditionalFormatting-BuG_4wOq.mjs → conditionalFormatting-BU6BaaPb.mjs} +1 -1
  26. package/dist/{createGlobalFilter.module-DisUwLsO.mjs → createGlobalFilter.module-Cw_A7yeo.mjs} +1 -1
  27. package/dist/data.cjs +1 -1
  28. package/dist/data.mjs +1 -1
  29. package/dist/{echarts-BE7AhqVy.mjs → echarts-Dw5Z2Ho-.mjs} +2 -2
  30. package/dist/{metric.mutation-BRWn1UMi.mjs → metric.mutation-cOoqy5Bi.mjs} +1 -1
  31. package/dist/{permissions-B5UHxn_4.mjs → permissions-CxZW60Bd.mjs} +289 -261
  32. package/dist/{pluginV3Request-Dfy8fkbS.mjs → pluginV3Request-CQzo3G0-.mjs} +1 -1
  33. package/dist/{renderer-qB-6Euan.mjs → renderer-D1fTygev.mjs} +1 -1
  34. package/dist/{timeseries-Clp-TrGQ.mjs → timeseries-D_nzmvUF.mjs} +1347 -1304
  35. package/dist/{toTasteAppearance-cIHX7fPm.mjs → toTasteAppearance-C4jy9fG3.mjs} +1 -1
  36. package/dist/{useGuesTokenUsageLog-BtooXte_.mjs → useGuesTokenUsageLog-BgjAaf3E.mjs} +1 -1
  37. package/dist/{usePublishArchivedMetrics-CM4KQARj.mjs → usePublishArchivedMetrics-CM7fUNzL.mjs} +2 -2
  38. package/dist/{useQuery-D3fpbSfw.mjs → useQuery-DhtsBbBi.mjs} +1 -1
  39. package/dist/webcomponents.css +2 -2
  40. package/dist/webcomponents.es.js +483 -459
  41. package/dist/webcomponents.umd.js +153 -153
  42. package/package.json +1 -1
@@ -2,11 +2,11 @@ import "react";
2
2
  import "react-dom";
3
3
  import "react-dom/client";
4
4
  import { a as e, c as t, i as n, s as r } from "./cardStates-DiUMQ7_o.mjs";
5
- import { _t as i, p as a, vt as o } from "./pluginV3Request-Dfy8fkbS.mjs";
6
- import { K as s, et as c, it as l, l as u, ot as d } from "./metric.mutation-BRWn1UMi.mjs";
7
- import { Aa as f, Ar as p, Bt as m, Dr as h, Ei as g, Fa as _, Gr as ee, Gt as te, Hi as ne, It as re, Jt as ie, Ln as v, Lr as ae, Ni as oe, Nr as se, Or as ce, Ri as le, Rt as y, Sn as ue, Vr as de, Wt as b, Zr as fe, an as x, bn as pe, di as S, en as C, fn as me, gn as he, jt as ge, kr as _e, ln as ve, on as ye, pi as be, q as w, qa as xe, tn as Se, ui as Ce, un as we, wa as T, zr as Te, zt as Ee } from "./Portal-C4N01WKg.mjs";
8
- import { a as De } from "./timeseries-Clp-TrGQ.mjs";
9
- import { c as Oe, l as ke, m as Ae, n as je, s as Me, u as Ne } from "./RadioButton-DvzkXfzO.mjs";
5
+ import { _t as i, p as a, vt as o } from "./pluginV3Request-CQzo3G0-.mjs";
6
+ import { K as s, et as c, it as l, l as u, ot as d } from "./metric.mutation-cOoqy5Bi.mjs";
7
+ import { Aa as f, Ar as p, Bt as m, Dr as h, Ei as g, Fa as _, Gr as ee, Gt as te, Hi as ne, It as re, Jt as ie, Ln as v, Lr as ae, Ni as oe, Nr as se, Or as ce, Ri as le, Rt as y, Sn as ue, Vr as de, Wt as b, Zr as fe, an as x, bn as pe, di as S, en as C, fn as me, gn as he, jt as ge, kr as _e, ln as ve, on as ye, pi as be, q as w, qa as xe, tn as Se, ui as Ce, un as we, wa as T, zr as Te, zt as Ee } from "./Portal-CuJ3yA9x.mjs";
8
+ import { a as De } from "./timeseries-D_nzmvUF.mjs";
9
+ import { c as Oe, l as ke, m as Ae, n as je, s as Me, u as Ne } from "./RadioButton-BagXnWOk.mjs";
10
10
  import { useCallback as Pe, useEffect as Fe, useMemo as E, useRef as Ie, useState as D } from "react";
11
11
  //#region src/helpers/chartDisplayValue.ts
12
12
  var O = (e, t = /* @__PURE__ */ new WeakSet()) => {
@@ -36,7 +36,35 @@ var O = (e, t = /* @__PURE__ */ new WeakSet()) => {
36
36
  let n = JSON.stringify(e?.measures?.sort());
37
37
  return !t.has(n) && (t.add(n), !0);
38
38
  });
39
- }, Be = (e) => e?.dataMartColumnAlias || e?.name || "", Ve = ({ configuration: e, savedConfiguration: t }) => e.table?.name?.trim() ? e : t?.table?.name?.trim() ? t : e, He = (e) => !!e && e.operandType === "number", Ue = (e) => e.configType === "AGGREGATE" ? "number" : e.helperFunction ? "string" : e.cast?.value && e?.cast?.value !== "NONE" ? e?.cast?.value : e.datatype, j = (e, t = []) => {
39
+ }, Be = (e) => e?.dataMartColumnAlias || e?.name || "", Ve = ({ configuration: e, savedConfiguration: t }) => e.table?.name?.trim() ? e : t?.table?.name?.trim() ? t : e, j = (e) => {
40
+ let t = /* @__PURE__ */ new Map();
41
+ e.alias && e.name && t.set(e.alias, e.name);
42
+ for (let n of e.joins || []) n.alias && n.name && t.set(n.alias, n.name);
43
+ return t;
44
+ }, M = (e, t, n) => {
45
+ let r = e.firstOperand, i = e.secondOperand, a = r?.parentAlias ? t.get(r.parentAlias) : void 0, o = i?.parentAlias ? t.get(i.parentAlias) : void 0;
46
+ return !a || !o || !r?.columnName || !i?.columnName ? !1 : n.some((e) => e.parentTableName === a && e.parentColumnName === r.columnName && e.childTableName === o && e.childColumnName === i.columnName || e.parentTableName === o && e.parentColumnName === i.columnName && e.childTableName === a && e.childColumnName === r.columnName);
47
+ }, He = (e, t) => {
48
+ let n = e.table, r = n?.joins || [];
49
+ if (!r.length || !t.length) return e;
50
+ let i = j(n), a = !1, o = r.map((e) => {
51
+ let n = e.conditions || [], r = n.filter((e) => {
52
+ let n = M(e, i, t);
53
+ return a ||= n, !n;
54
+ });
55
+ return r.length === n.length ? e : {
56
+ ...e,
57
+ conditions: r
58
+ };
59
+ });
60
+ return a ? {
61
+ ...e,
62
+ table: {
63
+ ...n,
64
+ joins: o
65
+ }
66
+ } : e;
67
+ }, Ue = (e, t, n) => M(e, j(t), n), We = (e) => !!e && e.operandType === "number", Ge = (e) => e.configType === "AGGREGATE" ? "number" : e.helperFunction ? "string" : e.cast?.value && e?.cast?.value !== "NONE" ? e?.cast?.value : e.datatype, N = (e, t = []) => {
40
68
  let n = new Set(t.filter((e) => e?.name).map((e) => e.name));
41
69
  return e.filter((e) => ["ASC", "DESC"].includes(e?.defaultSort || "")).map((e) => {
42
70
  let t = se.includes(e?.helperFunction || ""), n = b([e])?.dimensions?.[0];
@@ -52,18 +80,18 @@ var O = (e, t = /* @__PURE__ */ new WeakSet()) => {
52
80
  formattedColumn: t && e ? n : void 0
53
81
  };
54
82
  }).filter((e) => e?.name && !n.has(e.name));
55
- }, We = (e = [], t = []) => e.filter((e) => e?.type !== "selected_column" || t.some((t) => t?.alias === e?.name)), M = (e = [], t = []) => {
56
- let n = We(e, t);
57
- return [...n, ...j(t, n)];
58
- }, N = "This metric could not run. Change a field or filter and try again.", Ge = (e, n, i) => {
83
+ }, Ke = (e = [], t = []) => e.filter((e) => e?.type !== "selected_column" || t.some((t) => t?.alias === e?.name)), P = (e = [], t = []) => {
84
+ let n = Ke(e, t);
85
+ return [...n, ...N(t, n)];
86
+ }, qe = "This metric could not run. Change a field or filter and try again.", Je = (e, n, i) => {
59
87
  let a = r(e), o = t(e, {
60
- fallback: N,
88
+ fallback: qe,
61
89
  surface: "builder"
62
90
  });
63
91
  return n("builder", o, a?.details?.legacyCode, { metricId: i }), o;
64
- }, Ke = (e, t) => t && typeof e == "string" && e && n(t) === e ? t : void 0, P = (e) => `'${e}'`, qe = (e, t, n) => {
65
- let r = t?.table, i = r?.joins || [], a = (e, t) => n.find((n) => n?.tableName === e && (!t || !n?.schemaName || n.schemaName === t)), o = (e) => {
66
- let t = a(e?.name, e?.schema);
92
+ }, F = (e, t) => t && typeof e == "string" && e && n(t) === e ? t : void 0, Ye = (e) => `'${e}'`, Xe = (e, t, n, r = []) => {
93
+ let i = t?.table, a = i?.joins || [], o = (e, t) => n.find((n) => n?.tableName === e && (!t || !n?.schemaName || n.schemaName === t)), s = (e) => {
94
+ let t = o(e?.name, e?.schema);
67
95
  return t ? t.label || t.tableName : void 0;
68
96
  };
69
97
  if (!e.tableExists) return {
@@ -77,61 +105,61 @@ var O = (e, t = /* @__PURE__ */ new WeakSet()) => {
77
105
  hint: "Ask your admin to unhide it in the datamart, or pick fields from one table."
78
106
  };
79
107
  if (!e.relationshipPresent) {
80
- let e = o(r), t = o(i[0]);
108
+ let e = s(i), t = s(a[0]);
81
109
  return {
82
110
  code: "JOIN_PATH_MISSING",
83
- message: e && t ? `Tables ${P(e)} and ${P(t)} are not linked in the datamart.` : "The tables in this metric are not linked in the datamart.",
111
+ message: e && t ? `Tables ${Ye(e)} and ${Ye(t)} are not linked in the datamart.` : "The tables in this metric are not linked in the datamart.",
84
112
  hint: "Ask your admin to add a relationship, or pick fields from one table."
85
113
  };
86
114
  }
87
- let s = {};
88
- r?.alias && (s[r.alias] = r);
89
- for (let e of i) e?.alias && (s[e.alias] = e);
90
- let c = (e) => {
115
+ let c = {};
116
+ i?.alias && (c[i.alias] = i);
117
+ for (let e of a) e?.alias && (c[e.alias] = e);
118
+ let l = (e) => {
91
119
  if (!e?.columnName || !e.parentAlias) return !1;
92
- let t = s[e.parentAlias], n = t && a(t.name, t.schema);
120
+ let t = c[e.parentAlias], n = t && o(t.name, t.schema);
93
121
  return n ? !new Set((n.columns?.length ? n.columns : (n.columnsWithDataType || []).map((e) => e?.name)).filter(Boolean)).has(e.columnName) : !1;
94
- }, l = (e) => {
95
- let t = o(s[e.parentAlias]);
96
- return t ? ` in table ${P(t)}` : "";
97
- }, u = i.flatMap((e) => e?.conditions || []).flatMap((e) => [e?.firstOperand, e?.secondOperand]).find(c);
98
- if (u) return {
122
+ }, u = (e) => {
123
+ let t = s(c[e.parentAlias]);
124
+ return t ? ` in table ${Ye(t)}` : "";
125
+ }, d = a.flatMap((e) => (e?.conditions || []).flatMap((e) => Ue(e, i, r) ? [] : [e?.firstOperand, e?.secondOperand])).find(l);
126
+ if (d) return {
99
127
  code: "JOIN_COLUMN_HIDDEN",
100
- message: `A column${l(u)} is hidden from viewers, but this join needs it.`,
128
+ message: `A column${u(d)} is hidden from viewers, but this join needs it.`,
101
129
  hint: "Ask your admin to unhide it in the datamart, or pick another dimension."
102
130
  };
103
- let d = [...t?.dimensions || [], ...t?.aggregates || []].find((e) => e?.type !== "custom" && c(e));
131
+ let f = [...t?.dimensions || [], ...t?.aggregates || []].find((e) => e?.type !== "custom" && l(e));
104
132
  return {
105
133
  code: "JOIN_COLUMN_HIDDEN",
106
- message: `A column${d ? l(d) : ""} is hidden from viewers, but this metric uses it.`,
134
+ message: `A column${f ? u(f) : ""} is hidden from viewers, but this metric uses it.`,
107
135
  hint: "Ask your admin to unhide it in the datamart, or pick another column."
108
136
  };
109
- }, Je = ({ type: e, firstOperand: t, secondOperand: n }) => e === "METRIC" || oe.includes(t?.helperFunction || "") || oe.includes(n?.helperFunction || "") ? "AGGREGATE" : "DIMENSION", Ye = ({ clientId: r, shouldApplyClientDataScope: oe, clientSubsetData: O, setChartSettings: k, setError: Le, dbName: A = "", chartSettings: j, setData: N, setQuery: Ke, setLoading: P, setGroupByList: Ye, data: F, limit: Xe, setDatasetSettings: Ze, token: Qe, workspaceId: $e, isDatabaseTenancy: et, companyTenancyType: tt, clientColumnType: nt, setDrillDownSettings: rt, drillDownSettings: I, datasourceId: it, datasetSettings: L, dashboardId: at, id: R, companyId: ot, isIncrementalJoin: z, onServerEvent: st, metricEncryptedQuery: ct, rlsConditions: lt, isFrontendApp: ut, encryptedClientId: dt }) => {
110
- let { mutate: ft } = u(), pt = xe(), [mt, ht] = D(null), B = Pe((t) => {
111
- let r = typeof t == "string" && t && e() === "viewer" ? Ge(t, pt, R) : t;
137
+ }, Ze = ({ type: e, firstOperand: t, secondOperand: n }) => e === "METRIC" || oe.includes(t?.helperFunction || "") || oe.includes(n?.helperFunction || "") ? "AGGREGATE" : "DIMENSION", Qe = ({ clientId: r, shouldApplyClientDataScope: oe, clientSubsetData: O, setChartSettings: k, setError: Le, dbName: A = "", chartSettings: j, setData: M, setQuery: Ue, setLoading: N, setGroupByList: qe, data: F, limit: Ye, setDatasetSettings: Qe, token: $e, workspaceId: et, isDatabaseTenancy: tt, companyTenancyType: nt, clientColumnType: rt, setDrillDownSettings: it, drillDownSettings: I, datasourceId: at, datasetSettings: L, dashboardId: ot, id: R, companyId: st, isIncrementalJoin: z, onServerEvent: ct, metricEncryptedQuery: lt, rlsConditions: ut, isFrontendApp: dt, encryptedClientId: ft }) => {
138
+ let { mutate: pt } = u(), mt = xe(), [ht, gt] = D(null), B = Pe((t) => {
139
+ let r = typeof t == "string" && t && e() === "viewer" ? Je(t, mt, R) : t;
112
140
  if (typeof r == "string" || r == null) {
113
- ht(null), Le(r);
141
+ gt(null), Le(r);
114
142
  return;
115
143
  }
116
- ht(r), Le(n(r));
144
+ gt(r), Le(n(r));
117
145
  }, [
118
146
  Le,
119
- pt,
147
+ mt,
120
148
  R
121
- ]), [gt, _t] = D(!0), [V, vt] = D(), [H, yt] = D([]), [bt, xt] = D([]), [St, Ct] = D([]), [wt, Tt] = D({
149
+ ]), [_t, vt] = D(!0), [V, yt] = D(), [H, bt] = D([]), [xt, St] = D([]), [Ct, wt] = D([]), [Tt, Et] = D({
122
150
  data: [],
123
151
  error: "",
124
152
  isLoading: !1,
125
153
  currentValue: ""
126
- }), [U, W] = D(Te), [G, K] = D([]), [q, J] = D([]), [Et, Dt] = D({
154
+ }), [U, W] = D(Te), [G, K] = D([]), [q, J] = D([]), [Dt, Ot] = D({
127
155
  value: "",
128
156
  label: ""
129
- }), [Ot, kt] = D([]), [At, jt] = D([]), [Y, Mt] = D([]), { data: Nt } = _(), Pt = tt || (et ? "DATABASE" : "TABLE"), Ft = tt || Nt?.companyTenancyType || (et ? "DATABASE" : void 0), It = !!et || je(Ft), { mutate: Lt, error: Rt } = w(), X = E(() => {
157
+ }), [kt, At] = D([]), [jt, Mt] = D([]), [Y, Nt] = D([]), { data: Pt } = _(), Ft = nt || (tt ? "DATABASE" : "TABLE"), It = nt || Pt?.companyTenancyType || (tt ? "DATABASE" : void 0), Lt = !!tt || je(It), { mutate: Rt, error: zt } = w(), X = E(() => {
130
158
  if (z) {
131
159
  if (U?.table?.name && V?.tableName) {
132
160
  if (U?.table?.joins?.length) return H?.filter((e) => e.tableName === U?.table?.name || U?.table?.joins?.[0]?.name === e.tableName);
133
161
  {
134
- let e = St?.filter((e) => e?.parentTableName === U?.table?.name || e?.childTableName === U?.table?.name);
162
+ let e = Ct?.filter((e) => e?.parentTableName === U?.table?.name || e?.childTableName === U?.table?.name);
135
163
  return H?.filter((t) => t.tableName === U?.table?.name || e?.flatMap((e) => [e?.parentTableName, e?.childTableName]).includes(t.tableName));
136
164
  }
137
165
  }
@@ -143,8 +171,8 @@ var O = (e, t = /* @__PURE__ */ new WeakSet()) => {
143
171
  V,
144
172
  U,
145
173
  z,
146
- St
147
- ]), zt = E(() => U.dimensions.length > 1 && !!U.aggregates.length, [U.dimensions, U.aggregates]), Bt = E(() => [
174
+ Ct
175
+ ]), Bt = E(() => U.dimensions.length > 1 && !!U.aggregates.length, [U.dimensions, U.aggregates]), Vt = E(() => [
148
176
  T.boxplot,
149
177
  T.funnel,
150
178
  T.funnelV2,
@@ -160,19 +188,19 @@ var O = (e, t = /* @__PURE__ */ new WeakSet()) => {
160
188
  T.singleValue,
161
189
  T.timeSeries,
162
190
  T.treeMap
163
- ].includes(j.chartType), [j.chartType]), Z = E(() => G.length + q.length === 0, [G, q]), Vt = E(() => [ee, S].includes(A?.toLowerCase() || ""), [A]), Ht = E(() => ({ sorting: {
191
+ ].includes(j.chartType), [j.chartType]), Z = E(() => G.length + q.length === 0, [G, q]), Ht = E(() => [ee, S].includes(A?.toLowerCase() || ""), [A]), Ut = E(() => ({ sorting: {
164
192
  isEnabled: !0,
165
193
  isEnabledAutoSort: !1,
166
194
  sortingType: "both-axis",
167
195
  list: G,
168
196
  setList: K
169
- } }), [G]), Ut = E(() => ({ sorting: {
197
+ } }), [G]), Wt = E(() => ({ sorting: {
170
198
  isEnabled: !0,
171
199
  isEnabledAutoSort: !1,
172
200
  sortingType: "both-axis",
173
201
  list: q,
174
202
  setList: J
175
- } }), [q]), Wt = E(() => j.chartType === T.timeSeries, [j.chartType]), Gt = Ie(null), Kt = E(() => V ? V?.type === "custom" ? {
203
+ } }), [q]), Gt = E(() => j.chartType === T.timeSeries, [j.chartType]), Kt = Ie(null), qt = E(() => V ? V?.type === "custom" ? {
176
204
  value: `none^^^^^^${V?.sql}^^^^^^${V?.alias || "dbn_sql_table"}^^^^^^custom`,
177
205
  label: V?.alias || "dbn_sql_table",
178
206
  icon: "table"
@@ -184,8 +212,8 @@ var O = (e, t = /* @__PURE__ */ new WeakSet()) => {
184
212
  value: "",
185
213
  label: "",
186
214
  icon: "table"
187
- }, [V]), qt = E(() => {
188
- let [e, t, n, r] = Et.value?.split("^^^^^^"), i = r === "custom" ? n || "dbn_sql_table" : `${C(e, A)}_${t?.replaceAll(" ", "_")?.replace("*", "_")}`;
215
+ }, [V]), Jt = E(() => {
216
+ let [e, t, n, r] = Dt.value?.split("^^^^^^"), i = r === "custom" ? n || "dbn_sql_table" : `${C(e, A)}_${t?.replaceAll(" ", "_")?.replace("*", "_")}`;
189
217
  return r === "custom" ? (X?.find((e) => e.tableName === n)?.columnsWithDataType || [])?.map((e) => ({
190
218
  value: `${n}^^^^^^${e.name}^^^^^^${e.dataType || ""}^^^^^^none^^^^^^${n}`,
191
219
  label: `${e?.label || e.dataMartColumnAlias || e.name}`,
@@ -211,18 +239,18 @@ var O = (e, t = /* @__PURE__ */ new WeakSet()) => {
211
239
  })) || [];
212
240
  }, [
213
241
  X,
214
- Et.value,
242
+ Dt.value,
215
243
  A
216
- ]), Jt = E(() => {
244
+ ]), Yt = E(() => {
217
245
  let e = U?.table?.joins?.map((e) => X?.find((t) => t?.schemaName === e?.schema && t?.tableName === e?.name))?.filter((e) => e) || [], t = X?.find((e) => e?.schemaName === U?.table?.schema && e?.tableName === U?.table?.name);
218
246
  return (t ? [t, ...e?.filter((e) => e?.tableName !== t?.tableName) || []] : e || [])?.map((e) => ({
219
247
  value: `${e.schemaName}^^^^^^${e.tableName}`,
220
248
  label: ze(e),
221
249
  table: e
222
250
  })) || [];
223
- }, [U, X]), Yt = E(() => {
251
+ }, [U, X]), Xt = E(() => {
224
252
  j?.pivotTableSettings2;
225
- let e = j?.chartType === T.timeSeries, [t, n, r] = Et?.value?.split("^^^^^^");
253
+ let e = j?.chartType === T.timeSeries, [t, n, r] = Dt?.value?.split("^^^^^^");
226
254
  return [...q, ...G?.filter((t) => !(x(t.cast?.value?.toLowerCase() || t.datatype?.toLowerCase()) && e))].filter((e) => e.table?.type === "custom" ? e.table?.alias === r : e.table?.tableName === n && e.table?.schemaName === t)?.map((e) => ({
227
255
  value: `${e.parentAlias}^^^^^^${e.name || e.alias}^^^^^^${e.datatype}^^^^^^${e?.table?.schemaName}^^^^^^${e.table?.tableName}^^^^^^new`,
228
256
  label: `${te(e) || e?.alias}`,
@@ -232,14 +260,14 @@ var O = (e, t = /* @__PURE__ */ new WeakSet()) => {
232
260
  }, [
233
261
  j?.pivotTableSettings2,
234
262
  j.chartType,
235
- Et?.value,
263
+ Dt?.value,
236
264
  q,
237
265
  G
238
- ]), Xt = E(() => {
266
+ ]), Zt = E(() => {
239
267
  if (!V) return [];
240
- let e = U?.table?.joins?.map((e) => X?.find((t) => t?.schemaName === e?.schema && t?.tableName === e?.name))?.filter((e) => e) || [], t = X?.find((e) => et ? e?.tableName === U?.table?.name : e?.tableName === U?.table?.name && e?.schemaName === U?.table?.schema);
268
+ let e = U?.table?.joins?.map((e) => X?.find((t) => t?.schemaName === e?.schema && t?.tableName === e?.name))?.filter((e) => e) || [], t = X?.find((e) => tt ? e?.tableName === U?.table?.name : e?.tableName === U?.table?.name && e?.schemaName === U?.table?.schema);
241
269
  return (t ? [...e, t] : [...e]).flatMap((e) => {
242
- let t = X?.find((t) => et ? t?.tableName === e?.tableName : t?.tableName === e?.tableName && t?.schemaName === e?.schemaName) || e, n = t?.type === "custom" ? t?.alias || "dbn_sql_table" : `${C(t?.schemaName, A)}_${t?.tableName?.replaceAll(" ", "_")?.replace("*", "_")}`;
270
+ let t = X?.find((t) => tt ? t?.tableName === e?.tableName : t?.tableName === e?.tableName && t?.schemaName === e?.schemaName) || e, n = t?.type === "custom" ? t?.alias || "dbn_sql_table" : `${C(t?.schemaName, A)}_${t?.tableName?.replaceAll(" ", "_")?.replace("*", "_")}`;
243
271
  return t?.columnsWithDataType?.map((e) => ({
244
272
  alias: Be(e),
245
273
  label: e?.label || e?.dataMartColumnAlias || e?.name,
@@ -265,15 +293,15 @@ var O = (e, t = /* @__PURE__ */ new WeakSet()) => {
265
293
  A,
266
294
  U?.table,
267
295
  X
268
- ]), Zt = E(() => {
269
- let [e, t, n, r] = Et?.value?.split("^^^^^^"), i = r === "custom" ? n || "dbn_sql_table" : `${C(e, A)}_${t?.replaceAll(" ", "_")?.replace("*", "_")}`, a = qt?.filter((e) => {
296
+ ]), Qt = E(() => {
297
+ let [e, t, n, r] = Dt?.value?.split("^^^^^^"), i = r === "custom" ? n || "dbn_sql_table" : `${C(e, A)}_${t?.replaceAll(" ", "_")?.replace("*", "_")}`, a = Jt?.filter((e) => {
270
298
  let [t, n] = e?.value?.split("^^^^^^");
271
299
  return ![...G, ...q].some((e) => t === e?.parentAlias && n === e?.name && !e?.helperFunction);
272
300
  })?.map((e) => ({
273
301
  ...e,
274
302
  badge: "Default"
275
303
  })), o = [...q, ...G].filter((r) => r?.table?.type === "custom" ? r?.table?.alias === n : r?.table?.tableName === t && r?.table?.schemaName === e)?.map((e) => {
276
- let t = Ue(e);
304
+ let t = Ge(e);
277
305
  return {
278
306
  value: `${e?.parentAlias}^^^^^^${e?.name || e?.alias}^^^^^^${t}^^^^^^${e?.table?.schemaName}^^^^^^${e?.table?.tableName}^^^^^^${e?.helperFunction}^^^^^^${e?.alias}^^^^^^${e?.configType}^^^^^^${e?.isApplyTimezone}`,
279
307
  label: `${te(e)}`,
@@ -293,14 +321,14 @@ var O = (e, t = /* @__PURE__ */ new WeakSet()) => {
293
321
  }, [
294
322
  q,
295
323
  G,
296
- qt,
297
- Et
298
- ]), Qt = (e, t) => {
324
+ Jt,
325
+ Dt
326
+ ]), $t = (e, t) => {
299
327
  let n = e?.cast?.value === "NONE" ? void 0 : e?.cast?.value, r = t || n || e?.datatype;
300
328
  if (r) {
301
329
  if (x(r)) return j.chartType === T.timeSeries ? [] : p;
302
330
  if (Ce.includes(r?.toLowerCase()) || r?.toLowerCase()?.startsWith("decimal") || r?.toLowerCase()?.startsWith("numeric")) return h;
303
- if (g.includes(r?.toLowerCase()) || r?.toLowerCase()?.includes("char")) return Vt ? r?.toLowerCase() === "keyword" || r?.toLowerCase().includes("keyword") || e?.datatype?.toLowerCase() === "keyword" || e?.name && e.name.endsWith(".keyword") || r && (g.includes(r?.toLowerCase()) || r?.toLowerCase()?.includes("char")) && !r?.toLowerCase().includes("text") ? [
331
+ if (g.includes(r?.toLowerCase()) || r?.toLowerCase()?.includes("char")) return Ht ? r?.toLowerCase() === "keyword" || r?.toLowerCase().includes("keyword") || e?.datatype?.toLowerCase() === "keyword" || e?.name && e.name.endsWith(".keyword") || r && (g.includes(r?.toLowerCase()) || r?.toLowerCase()?.includes("char")) && !r?.toLowerCase().includes("text") ? [
304
332
  {
305
333
  value: "lowercase",
306
334
  label: "Lowercase"
@@ -329,13 +357,13 @@ var O = (e, t = /* @__PURE__ */ new WeakSet()) => {
329
357
  let n = e?.uniqueId || e?.alias;
330
358
  n && t.set(n, e);
331
359
  }), Ee(e, A || "", [...t.values()]);
332
- }, $t = (e, t) => e?.isDataMartLabel ? Q([e])?.[0] === t : e?.alias === t, en = (e, t) => e?.find((e) => $t(e, t)), tn = (e, t) => {
360
+ }, en = (e, t) => e?.isDataMartLabel ? Q([e])?.[0] === t : e?.alias === t, tn = (e, t) => e?.find((e) => en(e, t)), nn = (e, t) => {
333
361
  if ((t || F)?.length) {
334
362
  let n = Object.keys((t || F)?.[0] || {});
335
363
  return e.filter((e) => n.includes(e));
336
364
  }
337
365
  return [];
338
- }, nn = ({ datatype: e, operator: t }) => {
366
+ }, rn = ({ datatype: e, operator: t }) => {
339
367
  let n = e?.toLowerCase(), r = t === "IS NULL" || t === "IS NOT NULL", i = t === "IN" || t === "NOT IN", a = t === "=", o = t === "LIKE" || t === "LIKE (case sensitive)" || t === "REGEX", s = x(n), c = [
340
368
  "<>",
341
369
  "<",
@@ -344,39 +372,39 @@ var O = (e, t = /* @__PURE__ */ new WeakSet()) => {
344
372
  ">="
345
373
  ].includes(t), l = Ce.includes(n) || n?.startsWith("decimal") || n?.startsWith("numeric");
346
374
  return r ? "NULL" : t === "BETWEEN" ? "DATE_RANGE" : o ? "INPUT_TEXT_FIELD" : s && (a && !i || c) ? "TIME_FILTER" : l && !r ? i ? "MULTI_FILTER_DROPDOWN" : "INPUT_NUMBER_FIELD" : i ? "MULTI_FILTER_DROPDOWN" : "FILTER_DROPDOWN";
347
- }, rn = (e) => {
348
- if (e) return H?.find((t) => e?.type === "custom" || t?.type === "custom" ? t?.alias === e?.alias : t?.schemaName === e?.schemaName && t?.tableName === e?.tableName);
349
375
  }, an = (e) => {
376
+ if (e) return H?.find((t) => e?.type === "custom" || t?.type === "custom" ? t?.alias === e?.alias : t?.schemaName === e?.schemaName && t?.tableName === e?.tableName);
377
+ }, on = (e) => {
350
378
  let t = (e) => e?.schema ? `${e.schema}.${e.name}` : e?.name || "", n = (e) => e?.schemaName ? `${e.schemaName}.${e.tableName}` : e?.tableName || "", r = e?.table?.type === "custom" || !!Me({
351
379
  candidates: H || [],
352
380
  getName: n,
353
381
  target: t(e?.table),
354
- companyTenancyType: Pt,
382
+ companyTenancyType: Ft,
355
383
  dbName: A
356
384
  }), i = (e?.table?.joins || []).every((e) => !!Me({
357
385
  candidates: H || [],
358
386
  getName: n,
359
387
  target: t(e),
360
- companyTenancyType: Pt,
388
+ companyTenancyType: Ft,
361
389
  dbName: A
362
- })), a = ke(e?.table?.joins || [], O?.relationships || [], !0, Pt, A, e?.table), o = Oe(e, O?.tableList || [], !0, Pt, A);
390
+ })), a = O?.relationships || [], o = ke(e?.table?.joins || [], a, !0, Ft, A, e?.table), s = Oe(He(e, a), O?.tableList || [], !0, Ft, A);
363
391
  return {
364
- isValid: r && i && a && o,
392
+ isValid: r && i && o && s,
365
393
  tableExists: r,
366
394
  joinsExist: i,
367
- relationshipPresent: a,
368
- columnPresent: o,
369
- tenancyType: Pt
395
+ relationshipPresent: o,
396
+ columnPresent: s,
397
+ tenancyType: Ft
370
398
  };
371
- }, on = () => {
372
- Ke(""), P(!1), H?.length ? vt(H?.[0]) : vt(void 0), N([]), kt([]), jt([]), K([]), J([]), W(Te), k((e) => ({
399
+ }, sn = () => {
400
+ Ue(""), N(!1), H?.length ? yt(H?.[0]) : yt(void 0), M([]), At([]), Mt([]), K([]), J([]), W(Te), k((e) => ({
373
401
  ...e,
374
402
  isDynamicSeries: !1,
375
403
  seriesField: "ungrouped",
376
404
  seriesOptions: []
377
405
  }));
378
- }, sn = ({ chartType: e, chartDimensions: t, chartMetrics: n, chartAggregateColumns: r, resultData: i, configAggregates: a, pivotHeaderColumns: o, chartTimeColumns: s, seriesName: c, isRemoveGroupBy: l }) => {
379
- let u = t ?? tn(Q(G), i || F), d = n ?? tn(Q(q), i || F), f = r ?? tn(Q(q.filter((e) => e.configType === "AGGREGATE")), i || F), p = ae;
406
+ }, cn = ({ chartType: e, chartDimensions: t, chartMetrics: n, chartAggregateColumns: r, resultData: i, configAggregates: a, pivotHeaderColumns: o, chartTimeColumns: s, seriesName: c, isRemoveGroupBy: l }) => {
407
+ let u = t ?? nn(Q(G), i || F), d = n ?? nn(Q(q), i || F), f = r ?? nn(Q(q.filter((e) => e.configType === "AGGREGATE")), i || F), p = ae;
380
408
  if ([
381
409
  T.progressBar,
382
410
  T.linearGauge,
@@ -609,19 +637,19 @@ var O = (e, t = /* @__PURE__ */ new WeakSet()) => {
609
637
  seriesField: l ? "" : c || e?.seriesField,
610
638
  isMultiDimension: !l && !!(c || e?.seriesField && e?.seriesField !== "ungrouped")
611
639
  }));
612
- }, cn = () => {
640
+ }, ln = () => {
613
641
  if (!I?.isEnableGroupBy || !I?.configV2?.isEnable) return;
614
642
  let e = I.configV2.levels?.find((e) => e?.isEnable) || I.configV2.levels?.[0], t = [...e?.dimensions || [], ...e?.measures || []];
615
643
  return t.length ? t : void 0;
616
- }, ln = (e) => {
617
- let t = cn();
644
+ }, un = (e) => {
645
+ let t = ln();
618
646
  if (!t) return;
619
647
  let { dimensions: n, aggregates: r } = b(t);
620
648
  return {
621
649
  ...e,
622
650
  dimensions: n,
623
651
  aggregates: r,
624
- orders: We(e?.orders || [], t)
652
+ orders: Ke(e?.orders || [], t)
625
653
  };
626
654
  }, $ = ({ prevConfiguration: e, onSuccess: n, prevLimit: i, chartFieldParams: a, updatedDims: o, updatedMetrics: u, selectedMainTable: p, isTimeseriesAction: m, isPivotAction: h, isGroupByAction: g, isAddComparisonAction: _, sqlChartType: ee, updatedSqlColumnList: te, updatedTable: re, isRemoveGroupBy: v, queryConfiguration: ae }) => {
627
655
  let se = !!ae, ce = I?.isEnableGroupBy && I?.configV2?.isEnable ? he({
@@ -642,7 +670,7 @@ var O = (e, t = /* @__PURE__ */ new WeakSet()) => {
642
670
  T.row,
643
671
  T.horizontalStack
644
672
  ].includes(y);
645
- ue && Tt({
673
+ ue && Et({
646
674
  data: [],
647
675
  error: "",
648
676
  isLoading: !1,
@@ -657,11 +685,11 @@ var O = (e, t = /* @__PURE__ */ new WeakSet()) => {
657
685
  } : void 0;
658
686
  S && W(S);
659
687
  let _e = {
660
- selectedTable: re || Kt,
688
+ selectedTable: re || qt,
661
689
  selectedJoins: [],
662
690
  configuration: {
663
691
  ...S || U,
664
- limit: i || Xe
692
+ limit: i || Ye
665
693
  },
666
694
  clientColumn: {
667
695
  value: "",
@@ -685,8 +713,8 @@ var O = (e, t = /* @__PURE__ */ new WeakSet()) => {
685
713
  selectedCustomColumns: [],
686
714
  selectedManageColumns: [],
687
715
  selectedNewManageColumns: [],
688
- createdFilters: Ot,
689
- createdSorts: At,
716
+ createdFilters: kt,
717
+ createdSorts: jt,
690
718
  comparisonLagSettings: ne,
691
719
  selectedCustomGroups: [],
692
720
  selectedGroupColumns: [],
@@ -698,7 +726,7 @@ var O = (e, t = /* @__PURE__ */ new WeakSet()) => {
698
726
  newDatasetSettings: {
699
727
  configuration: {
700
728
  ...S || U,
701
- limit: i || Xe
729
+ limit: i || Ye
702
730
  },
703
731
  metrics: (S || U).aggregates?.map((e) => ({
704
732
  as: e.alias,
@@ -726,10 +754,10 @@ var O = (e, t = /* @__PURE__ */ new WeakSet()) => {
726
754
  previousSelectedDims: G,
727
755
  previousSelectedMetrics: q
728
756
  }) : void 0;
729
- if (Ze(_e), B(""), P(!0), N([]), be && rt((e) => ({
757
+ if (Qe(_e), B(""), N(!0), M([]), be && it((e) => ({
730
758
  ...e,
731
759
  configV2: be
732
- })), ce && rt((e) => ({
760
+ })), ce && it((e) => ({
733
761
  ...e,
734
762
  isEnableGroupBy: !1,
735
763
  isEnableCrossFilter: !1,
@@ -737,12 +765,12 @@ var O = (e, t = /* @__PURE__ */ new WeakSet()) => {
737
765
  drillType: "",
738
766
  configV2: void 0
739
767
  })), (_e.newDatasetSettings?.selectedDims?.length || 0) + (_e.newDatasetSettings?.selectedMetrics?.length || 0) === 0) {
740
- on();
768
+ sn();
741
769
  return;
742
770
  }
743
771
  let w = me || S || U, xe = [], Se = [], Ce = [];
744
772
  if (ue) {
745
- let e = j.pivotTableSettings2?.headers || [], { headerColumns: t, nonHeaderColumns: n } = (o || G).reduce((t, n) => (e.some((e) => $t(n, e)) ? t.headerColumns.push(n) : t.nonHeaderColumns.push(n), t), {
773
+ let e = j.pivotTableSettings2?.headers || [], { headerColumns: t, nonHeaderColumns: n } = (o || G).reduce((t, n) => (e.some((e) => en(n, e)) ? t.headerColumns.push(n) : t.nonHeaderColumns.push(n), t), {
746
774
  headerColumns: [],
747
775
  nonHeaderColumns: []
748
776
  });
@@ -756,7 +784,7 @@ var O = (e, t = /* @__PURE__ */ new WeakSet()) => {
756
784
  ...w,
757
785
  dimensions: a,
758
786
  aggregates: i,
759
- orders: M(w?.orders || [], r)
787
+ orders: P(w?.orders || [], r)
760
788
  }, W(w);
761
789
  }
762
790
  let we = {
@@ -771,7 +799,7 @@ var O = (e, t = /* @__PURE__ */ new WeakSet()) => {
771
799
  return x(t);
772
800
  });
773
801
  if (!r) {
774
- B("Date column is not found for Timeseries chart"), P(!1), N([]), Ke("");
802
+ B("Date column is not found for Timeseries chart"), N(!1), M([]), Ue("");
775
803
  return;
776
804
  }
777
805
  let i = {
@@ -783,7 +811,7 @@ var O = (e, t = /* @__PURE__ */ new WeakSet()) => {
783
811
  }, A) }
784
812
  };
785
813
  K((e) => e?.map((e) => e.alias === r.alias ? i : e));
786
- let a = n ? en(o || G, e) : void 0, s = a ? [i, a] : [i];
814
+ let a = n ? tn(o || G, e) : void 0, s = a ? [i, a] : [i];
787
815
  Te = s, Ee = u || q;
788
816
  let c = [...s, ...Ee], { aggregates: l, dimensions: d } = b(c), f = [{
789
817
  method: "ASC",
@@ -794,7 +822,7 @@ var O = (e, t = /* @__PURE__ */ new WeakSet()) => {
794
822
  ...w,
795
823
  dimensions: d,
796
824
  aggregates: l,
797
- orders: M([...f, ...We(w?.orders || [], c).filter((e) => e?.name !== r?.alias && !f.some((t) => t?.name === e?.name))], c)
825
+ orders: P([...f, ...Ke(w?.orders || [], c).filter((e) => e?.name !== r?.alias && !f.some((t) => t?.name === e?.name))], c)
798
826
  }, W(w);
799
827
  }
800
828
  let Oe = {
@@ -803,14 +831,14 @@ var O = (e, t = /* @__PURE__ */ new WeakSet()) => {
803
831
  chartAggregateColumns: Q(Ee.filter((e) => e.configType === "AGGREGATE"))
804
832
  }, ke = [], Ae = [];
805
833
  if (pe) {
806
- let e = j?.seriesField || "", t = e && e !== "ungrouped" ? en(o || G, e) : void 0, n = (o || G)?.[0], r = t ? [n, t] : [n];
834
+ let e = j?.seriesField || "", t = e && e !== "ungrouped" ? tn(o || G, e) : void 0, n = (o || G)?.[0], r = t ? [n, t] : [n];
807
835
  Ae = u || q, ke = r;
808
836
  let i = [...r, ...Ae], { aggregates: a, dimensions: s } = b(i);
809
837
  w = {
810
838
  ...w,
811
839
  dimensions: s,
812
840
  aggregates: a,
813
- orders: M(w?.orders || [], i),
841
+ orders: P(w?.orders || [], i),
814
842
  isApplyMetricFilter: !0,
815
843
  rlsConditions: (S || U)?.rlsConditions || []
816
844
  }, W(w);
@@ -830,7 +858,7 @@ var O = (e, t = /* @__PURE__ */ new WeakSet()) => {
830
858
  method: "=",
831
859
  parentAlias: `${C(e?.table?.schemaName || "", A)}_${e?.table?.tableName}`,
832
860
  type: "client",
833
- value: nt === "NUMBER" ? Number(r) : r,
861
+ value: rt === "NUMBER" ? Number(r) : r,
834
862
  relationOperator: "AND",
835
863
  isApplyTimezone: !1
836
864
  })) || [];
@@ -840,10 +868,10 @@ var O = (e, t = /* @__PURE__ */ new WeakSet()) => {
840
868
  dbName: A,
841
869
  orderCount: w?.orders?.length || 0,
842
870
  dimensionCount: w?.dimensions?.length || 0
843
- }), B("Error: Select list must be in order by clause if distinct is used"), N([]), P(!1);
871
+ }), B("Error: Select list must be in order by clause if distinct is used"), M([]), N(!1);
844
872
  return;
845
873
  }
846
- let E = an(w);
874
+ let E = on(w);
847
875
  if (!E.isValid) {
848
876
  c("generate-metric-blocked", {
849
877
  reason: "INVALID_DATASET_CONFIG",
@@ -855,46 +883,46 @@ var O = (e, t = /* @__PURE__ */ new WeakSet()) => {
855
883
  subsetTableCount: H?.length || 0,
856
884
  ...l(w)
857
885
  });
858
- let e = t(qe(E, w, O?.tableList || []), { surface: "builder" });
859
- s("metric.builder_validation_failed", { error_code: e.code }), pt("builder", e, void 0, { metricId: R }), B(e), N([]), Ke(""), P(!1);
886
+ let e = t(Xe(E, w, O?.tableList || [], O?.relationships || []), { surface: "builder" });
887
+ s("metric.builder_validation_failed", { error_code: e.code }), mt("builder", e, void 0, { metricId: R }), B(e), M([]), Ue(""), N(!1);
860
888
  return;
861
889
  }
862
890
  let Ie = Date.now();
863
891
  c("generate-metric-start", {
864
- hasWorkspaceId: !!$e,
865
- hasDatasourceId: !!it,
866
- hasToken: !!Qe,
892
+ hasWorkspaceId: !!et,
893
+ hasDatasourceId: !!at,
894
+ hasToken: !!$e,
867
895
  chartType: y,
868
- limit: i || Xe,
896
+ limit: i || Ye,
869
897
  clientColumnFilterCount: Fe?.length || 0,
870
- isDatabaseTenancy: !!et,
898
+ isDatabaseTenancy: !!tt,
871
899
  ...l(w)
872
- }), Lt({
900
+ }), Rt({
873
901
  data: {
874
902
  cId: r,
875
903
  configuration: {
876
904
  ...w,
877
- filters: !It && Fe?.length ? [...w?.filters, ...Fe] : w?.filters,
878
- limit: i || Xe
905
+ filters: !Lt && Fe?.length ? [...w?.filters, ...Fe] : w?.filters,
906
+ limit: i || Ye
879
907
  },
880
- id: $e,
881
- datasourceId: it,
882
- dashboardId: at,
908
+ id: et,
909
+ datasourceId: at,
910
+ dashboardId: ot,
883
911
  isCreateMetric: !0
884
912
  },
885
- token: Qe
913
+ token: $e
886
914
  }, {
887
915
  onSuccess(e) {
888
916
  let t = e?.error, r = e?.data, i = e?.query;
889
- i &&= f(i, ot || "");
917
+ i &&= f(i, st || "");
890
918
  let s = e?.metaData;
891
- if (t || Rt) {
919
+ if (t || zt) {
892
920
  c("generate-metric-failed", {
893
921
  source: "response-error",
894
922
  durationMs: Date.now() - Ie,
895
- hasGenerateError: !!Rt,
896
- ...d(t || Rt)
897
- }), B(Ge(t || Rt, pt, R)), P(!1), N([]), Ke("");
923
+ hasGenerateError: !!zt,
924
+ ...d(t || zt)
925
+ }), B(Je(t || zt, mt, R)), N(!1), M([]), Ue("");
898
926
  return;
899
927
  }
900
928
  if ((!r || !i) && c("generate-metric-indeterminate", {
@@ -909,9 +937,9 @@ var O = (e, t = /* @__PURE__ */ new WeakSet()) => {
909
937
  columnCount: Object.keys(r?.[0] || {}).length,
910
938
  queryLength: i?.length || 0,
911
939
  chartType: y
912
- }), B(""), P(!1);
940
+ }), B(""), N(!1);
913
941
  let e = [...w?.aggregates?.map((e) => e?.alias), ...w?.dimensions?.map((e) => e?.alias)], t = (t) => Array.isArray(t) ? A?.toLowerCase() === "redshift" ? ye(e, t) : t : [], n = ge(r, o || G, u || q);
914
- n = t(n), n = Re(n), N(() => n), sn(ue ? {
942
+ n = t(n), n = Re(n), M(() => n), cn(ue ? {
915
943
  ...we,
916
944
  resultData: n,
917
945
  configAggregates: S?.aggregates,
@@ -930,7 +958,7 @@ var O = (e, t = /* @__PURE__ */ new WeakSet()) => {
930
958
  chartTimeColumns: a?.chartTimeColumns,
931
959
  seriesName: a?.seriesName,
932
960
  isRemoveGroupBy: v
933
- }), _ || Ke(i), Ye?.(ie(s?.groupbyColumnList));
961
+ }), _ || Ue(i), qe?.(ie(s?.groupbyColumnList));
934
962
  }
935
963
  n?.();
936
964
  },
@@ -939,10 +967,10 @@ var O = (e, t = /* @__PURE__ */ new WeakSet()) => {
939
967
  source: "network",
940
968
  durationMs: Date.now() - Ie,
941
969
  ...d(e)
942
- }), B(Ge(e, pt, R)), P(!1), N([]), Ke("");
970
+ }), B(Je(e, mt, R)), N(!1), M([]), Ue("");
943
971
  }
944
972
  });
945
- }, un = (e, t) => {
973
+ }, dn = (e, t) => {
946
974
  let n = (e) => H?.find((t) => t.tableName === e), r = (t) => {
947
975
  let r = n(t)?.schemaName || e.schemaName;
948
976
  return `${C(r, A)}_${t.replaceAll(" ", "_")?.replace("*", "_")}`;
@@ -979,7 +1007,7 @@ var O = (e, t = /* @__PURE__ */ new WeakSet()) => {
979
1007
  }
980
1008
  };
981
1009
  return s(e.tableName), o;
982
- }, dn = (e, t, n) => {
1010
+ }, fn = (e, t, n) => {
983
1011
  let r = n.find((n) => n.parentTableName === e.tableName && n.childTableName === t.tableName || n.parentTableName === t.tableName && n.childTableName === e.tableName), i = e.type === "custom" ? e.alias || "dbn_sql_table" : `${C(e?.schemaName, A)}_${e.tableName.replaceAll(" ", "_")?.replace("*", "_")}`, a = t.type === "custom" ? t.alias || "dbn_sql_table" : `${C(t?.schemaName, A)}_${t.tableName.replaceAll(" ", "_")?.replace("*", "_")}`, o = r?.parentTableName === e.tableName, s = r ? [{
984
1012
  alias: o ? a : i,
985
1013
  name: o ? t.tableName : e.tableName,
@@ -1006,7 +1034,7 @@ var O = (e, t = /* @__PURE__ */ new WeakSet()) => {
1006
1034
  schema: o ? e.schemaName : t.schemaName,
1007
1035
  type: o ? e.type === "custom" ? "custom" : "default" : t.type === "custom" ? "custom" : "default"
1008
1036
  };
1009
- }, fn = ({ column: e, table: t, sorting: n, type: r, identifier: a }) => {
1037
+ }, pn = ({ column: e, table: t, sorting: n, type: r, identifier: a }) => {
1010
1038
  let s = [...G], c = [...q], l = t.type === "custom" ? t.alias || "dbn_sql_table" : `${C(t?.schemaName, A)}_${t.tableName.replaceAll(" ", "_")?.replace("*", "_")}`;
1011
1039
  if (Z) {
1012
1040
  let e = t.type === "custom" ? {
@@ -1018,9 +1046,9 @@ var O = (e, t = /* @__PURE__ */ new WeakSet()) => {
1018
1046
  label: `${t.schemaName}.${t.tableName}`,
1019
1047
  icon: "table"
1020
1048
  };
1021
- Dt(e), vt(t), K([]), J([]), kt([]), jt([]);
1049
+ Ot(e), yt(t), K([]), J([]), At([]), Mt([]);
1022
1050
  }
1023
- let u = z ? [] : un(t, St || []), d = e?.alias || e?.dataMartColumnAlias || e?.name, f = [
1051
+ let u = z ? [] : dn(t, Ct || []), d = e?.alias || e?.dataMartColumnAlias || e?.name, f = [
1024
1052
  "dimensions",
1025
1053
  "metrics",
1026
1054
  "aggregate_dimensions",
@@ -1069,7 +1097,7 @@ var O = (e, t = /* @__PURE__ */ new WeakSet()) => {
1069
1097
  return s = [...n.ArrayElementSwap(e, t, i)], s;
1070
1098
  }
1071
1099
  return s = [...i], i;
1072
- }), st?.(i, g);
1100
+ }), ct?.(i, g);
1073
1101
  break;
1074
1102
  case "METRIC":
1075
1103
  J((t) => {
@@ -1081,7 +1109,7 @@ var O = (e, t = /* @__PURE__ */ new WeakSet()) => {
1081
1109
  return c = [...n.ArrayElementSwap(e, t, i)], c;
1082
1110
  }
1083
1111
  return c = [...i], i;
1084
- }), st?.(o, g);
1112
+ }), ct?.(o, g);
1085
1113
  break;
1086
1114
  default: console.warn("Invalid Drop");
1087
1115
  }
@@ -1097,7 +1125,7 @@ var O = (e, t = /* @__PURE__ */ new WeakSet()) => {
1097
1125
  ...U,
1098
1126
  dimensions: oe,
1099
1127
  aggregates: ae,
1100
- orders: M(U?.orders || [], v),
1128
+ orders: P(U?.orders || [], v),
1101
1129
  table: Z ? {
1102
1130
  alias: l,
1103
1131
  id: t.id,
@@ -1109,7 +1137,7 @@ var O = (e, t = /* @__PURE__ */ new WeakSet()) => {
1109
1137
  }, le = H?.find((e) => e.tableName === U?.table?.name);
1110
1138
  se && le && !U?.table?.joins?.length && (ce = {
1111
1139
  ...ce,
1112
- table: dn(le, t, St || [])
1140
+ table: fn(le, t, Ct || [])
1113
1141
  }), W(ce), $({
1114
1142
  prevConfiguration: ce,
1115
1143
  chartFieldParams: {
@@ -1125,24 +1153,24 @@ var O = (e, t = /* @__PURE__ */ new WeakSet()) => {
1125
1153
  updatedMetrics: r === "METRIC" ? Z ? [_] : [...c] : void 0,
1126
1154
  selectedMainTable: Z ? t : void 0
1127
1155
  });
1128
- }, pn = (e, t) => {
1156
+ }, mn = (e, t) => {
1129
1157
  let n = e.isAliasRenamed ? e.generatedAlias : e.alias, r = t !== n;
1130
1158
  return {
1131
1159
  isAliasRenamed: r || void 0,
1132
1160
  generatedAlias: r ? n : void 0
1133
1161
  };
1134
- }, mn = ({ alias: e, column: t, type: n, cast: r, isColumnCasted: i }) => {
1162
+ }, hn = ({ alias: e, column: t, type: n, cast: r, isColumnCasted: i }) => {
1135
1163
  let a = A?.toLowerCase() === "opensearch" ? e.replaceAll(" ", "_")?.replace("*", "_") : e, o = [...G, ...q].filter((e) => e?.alias !== t?.alias).map((e) => e?.alias).filter((e) => !!e), s = Se(a, o, () => y(4)?.toLowerCase(), { caseInsensitive: A?.toLowerCase() === be }), c = n === "DIMENSION" ? G?.map((e) => e.alias === t.alias ? {
1136
1164
  ...e,
1137
1165
  alias: s,
1138
- ...pn(e, s),
1166
+ ...mn(e, s),
1139
1167
  cast: r,
1140
1168
  helperFunction: i ? void 0 : e.helperFunction,
1141
1169
  type: i && e.type === "HELPER_FUNCTION" ? "DEFAULT" : e.type
1142
1170
  } : e) : G, l = n === "METRIC" ? q?.map((e) => e.alias === t.alias ? {
1143
1171
  ...e,
1144
1172
  alias: s,
1145
- ...pn(e, s),
1173
+ ...mn(e, s),
1146
1174
  cast: r,
1147
1175
  helperFunction: i ? void 0 : e.helperFunction,
1148
1176
  configType: i ? "DIMENSION" : e.configType
@@ -1168,17 +1196,17 @@ var O = (e, t = /* @__PURE__ */ new WeakSet()) => {
1168
1196
  previousSelectedDims: G,
1169
1197
  previousSelectedMetrics: q
1170
1198
  }) : I?.configV2;
1171
- (n === "DIMENSION" || n === "METRIC" && I?.configV2?.levels?.length) && (n === "DIMENSION" && Mt(d.drillFilters || []), rt((e) => ({
1199
+ (n === "DIMENSION" || n === "METRIC" && I?.configV2?.levels?.length) && (n === "DIMENSION" && Nt(d.drillFilters || []), it((e) => ({
1172
1200
  ...e,
1173
1201
  drilldownChartSettings: n === "DIMENSION" ? d.drilldownChartSettings : e.drilldownChartSettings,
1174
1202
  configV2: f
1175
- }))), jt((e) => e.filter((e) => u?.some((t) => t.alias === (e.columnName?.column?.alias || e.columnName?.label))));
1203
+ }))), Mt((e) => e.filter((e) => u?.some((t) => t.alias === (e.columnName?.column?.alias || e.columnName?.label))));
1176
1204
  let { aggregates: p, dimensions: m } = b(u), h = {
1177
1205
  ...U,
1178
1206
  dimensions: m,
1179
1207
  aggregates: p,
1180
1208
  drillFilters: d.drillFilters,
1181
- orders: M(U?.orders || [], u)
1209
+ orders: P(U?.orders || [], u)
1182
1210
  };
1183
1211
  W(h), $({
1184
1212
  prevConfiguration: h,
@@ -1191,9 +1219,9 @@ var O = (e, t = /* @__PURE__ */ new WeakSet()) => {
1191
1219
  updatedDims: n === "DIMENSION" ? c : void 0,
1192
1220
  updatedMetrics: n === "METRIC" ? l : void 0
1193
1221
  });
1194
- }, hn = ({ column: e, helperFunction: t, type: n, functionConfiguration: r, percentileValue: i, partitionBy: o, partitionByColumns: s }) => {
1222
+ }, gn = ({ column: e, helperFunction: t, type: n, functionConfiguration: r, percentileValue: i, partitionBy: o, partitionByColumns: s }) => {
1195
1223
  let c = t.value === "NONE", l = le?.includes(t?.value || "") && G?.length && G?.[0]?.helperFunction !== "distinct", u = l ? `${ue("distinct of", A || "")} ${G?.[0]?.dataMartColumnAlias || G?.[0]?.name}` : "", d = `${c ? e.dataMartColumnAlias || e.name : `${ue(`${t.label?.toLowerCase()} of`, A || "")} ${e.dataMartColumnAlias || e.name}`}`;
1196
- [...G, ...q].some((e) => d === e?.alias) && (d = `${d}_${y(4)?.toLowerCase()}`), d = A?.toLowerCase() === "opensearch" ? d.replaceAll(" ", "_")?.replace("*", "_") : d, st?.(a, e.dataMartColumnAlias || e.name);
1224
+ [...G, ...q].some((e) => d === e?.alias) && (d = `${d}_${y(4)?.toLowerCase()}`), d = A?.toLowerCase() === "opensearch" ? d.replaceAll(" ", "_")?.replace("*", "_") : d, ct?.(a, e.dataMartColumnAlias || e.name);
1197
1225
  let f = n === "DIMENSION" ? G?.map((n) => n.alias === e.alias ? {
1198
1226
  ...n,
1199
1227
  helperFunction: t.value,
@@ -1241,17 +1269,17 @@ var O = (e, t = /* @__PURE__ */ new WeakSet()) => {
1241
1269
  previousSelectedDims: G,
1242
1270
  previousSelectedMetrics: q
1243
1271
  }) : I?.configV2;
1244
- (n === "DIMENSION" || n === "METRIC" && I?.configV2?.levels?.length) && (n === "DIMENSION" && Mt(h.drillFilters || []), rt((e) => ({
1272
+ (n === "DIMENSION" || n === "METRIC" && I?.configV2?.levels?.length) && (n === "DIMENSION" && Nt(h.drillFilters || []), it((e) => ({
1245
1273
  ...e,
1246
1274
  drilldownChartSettings: n === "DIMENSION" ? h.drilldownChartSettings : e.drilldownChartSettings,
1247
1275
  configV2: g
1248
- }))), jt((e) => e.filter((e) => m?.some((t) => t.alias === (e.columnName?.column?.alias || e.columnName?.label))));
1276
+ }))), Mt((e) => e.filter((e) => m?.some((t) => t.alias === (e.columnName?.column?.alias || e.columnName?.label))));
1249
1277
  let { aggregates: _, dimensions: ee } = b(m), te = {
1250
1278
  ...U,
1251
1279
  dimensions: ee,
1252
1280
  aggregates: _,
1253
1281
  drillFilters: h.drillFilters,
1254
- orders: M(U?.orders || [], m)
1282
+ orders: P(U?.orders || [], m)
1255
1283
  };
1256
1284
  W(te), $({
1257
1285
  prevConfiguration: te,
@@ -1264,18 +1292,18 @@ var O = (e, t = /* @__PURE__ */ new WeakSet()) => {
1264
1292
  updatedDims: n === "DIMENSION" || l ? f : void 0,
1265
1293
  updatedMetrics: n === "METRIC" ? p : void 0
1266
1294
  });
1267
- }, gn = ({ type: e, listType: t, selectedColumns: n, newColumn: r, editColumn: i }) => {
1295
+ }, _n = ({ type: e, listType: t, selectedColumns: n, newColumn: r, editColumn: i }) => {
1268
1296
  if (e !== t) return n;
1269
1297
  let a = (e) => i?.uniqueId ? e?.uniqueId === i.uniqueId : i ? e === i || !!i.arithmeticConfig && e?.arithmeticConfig === i.arithmeticConfig : !1;
1270
1298
  return i ? [...n?.filter((e) => !a(e)), r] : [...n, r];
1271
- }, _n = ({ alias: e, column: t, type: n, editCol: r, editColumn: i }) => {
1299
+ }, vn = ({ alias: e, column: t, type: n, editCol: r, editColumn: i }) => {
1272
1300
  if (!t) return;
1273
- let a = A?.toLowerCase() === "opensearch" ? e.replaceAll(" ", "_")?.replace("*", "_") : e, o = i || (r ? (n === "DIMENSION" ? G : q).find((e) => e?.alias === r) : void 0), s = [...G, ...q].filter((e) => o?.uniqueId ? e?.uniqueId !== o.uniqueId : !o || !(e === o || o.arithmeticConfig && e?.arithmeticConfig === o.arithmeticConfig)).map((e) => e?.alias).filter((e) => !!e), c = Se(a, s, () => y(4)?.toLowerCase(), { caseInsensitive: A?.toLowerCase() === be }), l = He(t.firstOperand) ? void 0 : t.firstOperand, u = He(t.secondOperand) ? void 0 : t.secondOperand, d = l || u;
1301
+ let a = A?.toLowerCase() === "opensearch" ? e.replaceAll(" ", "_")?.replace("*", "_") : e, o = i || (r ? (n === "DIMENSION" ? G : q).find((e) => e?.alias === r) : void 0), s = [...G, ...q].filter((e) => o?.uniqueId ? e?.uniqueId !== o.uniqueId : !o || !(e === o || o.arithmeticConfig && e?.arithmeticConfig === o.arithmeticConfig)).map((e) => e?.alias).filter((e) => !!e), c = Se(a, s, () => y(4)?.toLowerCase(), { caseInsensitive: A?.toLowerCase() === be }), l = We(t.firstOperand) ? void 0 : t.firstOperand, u = We(t.secondOperand) ? void 0 : t.secondOperand, d = l || u;
1274
1302
  if (!d) return;
1275
1303
  let f = {
1276
1304
  uniqueId: o?.uniqueId || y(10),
1277
1305
  alias: c,
1278
- configType: Je({
1306
+ configType: Ze({
1279
1307
  type: n,
1280
1308
  firstOperand: l,
1281
1309
  secondOperand: u
@@ -1298,13 +1326,13 @@ var O = (e, t = /* @__PURE__ */ new WeakSet()) => {
1298
1326
  type: "ARITHMETIC",
1299
1327
  arithmeticConfig: t,
1300
1328
  label: c
1301
- }, p = gn({
1329
+ }, p = _n({
1302
1330
  type: n,
1303
1331
  listType: "DIMENSION",
1304
1332
  editColumn: o,
1305
1333
  newColumn: f,
1306
1334
  selectedColumns: G
1307
- }), m = gn({
1335
+ }), m = _n({
1308
1336
  type: n,
1309
1337
  listType: "METRIC",
1310
1338
  editColumn: o,
@@ -1361,7 +1389,7 @@ var O = (e, t = /* @__PURE__ */ new WeakSet()) => {
1361
1389
  updatedDims: n === "DIMENSION" ? p : void 0,
1362
1390
  updatedMetrics: n === "METRIC" ? m : void 0
1363
1391
  });
1364
- }, vn = (e, t, n, r, i) => {
1392
+ }, yn = (e, t, n, r, i) => {
1365
1393
  let a = [...t, ...n].map((e) => e.parentAlias).filter(Boolean), o = i.map((e) => {
1366
1394
  let t = e.columnName.badge?.toLowerCase();
1367
1395
  if (!e.columnName.value || t === "new") return null;
@@ -1393,10 +1421,10 @@ var O = (e, t = /* @__PURE__ */ new WeakSet()) => {
1393
1421
  };
1394
1422
  return Fe(() => {
1395
1423
  let e = O?.error, t = O;
1396
- if (e || !O) B(e ? Ge(e, pt, R) : void 0);
1424
+ if (e || !O) B(e ? Je(e, mt, R) : void 0);
1397
1425
  else if (t?.tableList?.length) {
1398
1426
  let e = t?.tableList || [], n = t?.relationships || [];
1399
- Ct(n);
1427
+ wt(n);
1400
1428
  let r = ((e) => {
1401
1429
  let t = Array.from(new Set(e.filter((e) => e.tableName.endsWith("*")).map((e) => e.tableName)));
1402
1430
  if (t.length === 0) return e;
@@ -1464,11 +1492,11 @@ var O = (e, t = /* @__PURE__ */ new WeakSet()) => {
1464
1492
  wildcard: e.wildcard
1465
1493
  };
1466
1494
  }));
1467
- yt(r), r?.length && !R && vt(r?.[0]);
1495
+ bt(r), r?.length && !R && yt(r?.[0]);
1468
1496
  }
1469
1497
  }, [
1470
1498
  O,
1471
- Nt?.dataMartTables,
1499
+ Pt?.dataMartTables,
1472
1500
  R
1473
1501
  ]), Fe(() => {
1474
1502
  let e = [...G || [], ...q || []].filter((e) => e.transform && e.transform !== "original").map((e) => ({
@@ -1493,26 +1521,26 @@ var O = (e, t = /* @__PURE__ */ new WeakSet()) => {
1493
1521
  q,
1494
1522
  k
1495
1523
  ]), Fe(() => {
1496
- if (!L && R && gt && H?.length) {
1524
+ if (!L && R && _t && H?.length) {
1497
1525
  let e = H[0];
1498
- vt(e), ct && (P(!0), ft({
1526
+ yt(e), lt && (N(!0), pt({
1499
1527
  data: {
1500
- query: ct,
1501
- companyId: ot,
1502
- workspaceId: $e,
1528
+ query: lt,
1529
+ companyId: st,
1530
+ workspaceId: et,
1503
1531
  metricId: R,
1504
1532
  isCustomSql: !0,
1505
1533
  databaseName: A || "",
1506
- datasourceId: it
1534
+ datasourceId: at
1507
1535
  },
1508
- token: Qe || "",
1509
- isFrontendApp: ut,
1510
- encryptedClientId: dt || ""
1536
+ token: $e || "",
1537
+ isFrontendApp: dt,
1538
+ encryptedClientId: ft || ""
1511
1539
  }, {
1512
1540
  onSuccess(t) {
1513
1541
  let n = t?.data;
1514
1542
  if (Array.isArray(n) && n.length) {
1515
- N(Re(n));
1543
+ M(Re(n));
1516
1544
  let t = j?.xAxis, r = j?.yAxisList || [], i = e || {}, a = `${C(i?.schemaName || "", A)}_${(i?.tableName || "").replaceAll(" ", "_")?.replace("*", "_")}`, o = (e) => {
1517
1545
  let t = {
1518
1546
  percentile_cont_: "PERCENTILE_CONT",
@@ -1556,86 +1584,86 @@ var O = (e, t = /* @__PURE__ */ new WeakSet()) => {
1556
1584
  }, c = [], l = [];
1557
1585
  t && c.push(s(t, "DIMENSION", 0)), r.forEach((e, t) => l.push(s(e, "METRIC", t))), c.length && K(c), l.length && J(l);
1558
1586
  }
1559
- P(!1);
1587
+ N(!1);
1560
1588
  },
1561
1589
  onError() {
1562
- P(!1);
1590
+ N(!1);
1563
1591
  }
1564
- })), _t(!1);
1592
+ })), vt(!1);
1565
1593
  return;
1566
1594
  }
1567
- if (L && R && gt && H?.length) {
1568
- let e = L?.configuration || Te, t = !ke(e?.table?.joins || [], O?.relationships || [], !0, Pt, A, e?.table) || !Oe(e, O?.tableList || [], !0, Pt, A), n = L?.newDatasetSettings?.isChatMode || !1, r = Ae(L, rn), i = r?.newDatasetSettings?.selectedMainTable || (n ? H?.[0] : void 0), a = r?.newDatasetSettings?.selectedDims || [], o = r?.newDatasetSettings?.selectedMetrics || [], s = {
1595
+ if (L && R && _t && H?.length) {
1596
+ let e = L?.configuration || Te, t = O?.relationships || [], n = !ke(e?.table?.joins || [], t, !0, Ft, A, e?.table) || !Oe(He(e, t), O?.tableList || [], !0, Ft, A), r = L?.newDatasetSettings?.isChatMode || !1, i = Ae(L, an), a = i?.newDatasetSettings?.selectedMainTable || (r ? H?.[0] : void 0), o = i?.newDatasetSettings?.selectedDims || [], s = i?.newDatasetSettings?.selectedMetrics || [], c = {
1569
1597
  ...L?.configuration || Te,
1570
- rlsConditions: lt
1598
+ rlsConditions: ut
1571
1599
  };
1572
- if (W(s), kt(L?.createdFilters?.map((e) => ({
1600
+ if (W(c), At(L?.createdFilters?.map((e) => ({
1573
1601
  ...e,
1574
1602
  tableName: me(e.tableName),
1575
1603
  columnName: me(e.columnName)
1576
- }))?.filter((e) => e.type !== "client") || []), jt(L?.createdSorts?.map((e) => ({
1604
+ }))?.filter((e) => e.type !== "client") || []), Mt(L?.createdSorts?.map((e) => ({
1577
1605
  ...e,
1578
1606
  columnName: me(e.columnName),
1579
1607
  tableName: me(e.tableName)
1580
- })) || []), Dt(L?.selectedTable?.value ? me(L.selectedTable) : {
1608
+ })) || []), Ot(L?.selectedTable?.value ? me(L.selectedTable) : {
1581
1609
  label: "",
1582
1610
  value: ""
1583
- }), K(a), J(o), vt(i), t && !n) {
1584
- B("Something went wrong! Please try again later."), N([]), Ke(""), P(!1), _t(!1);
1611
+ }), K(o), J(s), yt(a), n && !r) {
1612
+ B("Something went wrong! Please try again later."), M([]), Ue(""), N(!1), vt(!1);
1585
1613
  return;
1586
1614
  }
1587
- if (n) {
1588
- _t(!1);
1615
+ if (r) {
1616
+ vt(!1);
1589
1617
  return;
1590
1618
  }
1591
1619
  $({
1592
- selectedMainTable: i,
1593
- prevConfiguration: s,
1594
- updatedMetrics: o,
1595
- updatedDims: a,
1620
+ selectedMainTable: a,
1621
+ prevConfiguration: c,
1622
+ updatedMetrics: s,
1623
+ updatedDims: o,
1596
1624
  chartFieldParams: {
1597
- chartDimensions: Q(a),
1598
- chartMetrics: Q(o)
1625
+ chartDimensions: Q(o),
1626
+ chartMetrics: Q(s)
1599
1627
  }
1600
- }), _t(!1);
1628
+ }), vt(!1);
1601
1629
  }
1602
1630
  }, [
1603
1631
  L,
1604
1632
  R,
1605
- gt,
1633
+ _t,
1606
1634
  H,
1607
- lt,
1608
- Qe,
1609
1635
  ut,
1636
+ $e,
1610
1637
  dt,
1611
- Pt,
1638
+ ft,
1639
+ Ft,
1612
1640
  A
1613
1641
  ]), {
1614
1642
  selectedMainTable: V,
1615
1643
  companySubsetTableList: X,
1616
- setSelectedMainTable: vt,
1617
- pivotDrillState: wt,
1618
- setPivotDrillState: Tt,
1644
+ setSelectedMainTable: yt,
1645
+ pivotDrillState: Tt,
1646
+ setPivotDrillState: Et,
1619
1647
  configuration: U,
1620
1648
  selectedDims: G,
1621
1649
  selectedMetrics: q,
1622
- onDropColumn: fn,
1623
- functionOptions: Qt,
1624
- dimModifiers: Ht,
1625
- metricModifiers: Ut,
1626
- isTimeSeries: Wt,
1627
- editorRef: Gt,
1628
- onChangeAlias: mn,
1629
- onChangeHelperFunction: hn,
1650
+ onDropColumn: pn,
1651
+ functionOptions: $t,
1652
+ dimModifiers: Ut,
1653
+ metricModifiers: Wt,
1654
+ isTimeSeries: Gt,
1655
+ editorRef: Kt,
1656
+ onChangeAlias: hn,
1657
+ onChangeHelperFunction: gn,
1630
1658
  onRemoveColumn: ({ column: e, type: t }) => {
1631
- let n = At.filter((t) => {
1659
+ let n = jt.filter((t) => {
1632
1660
  if (!t.columnName.value) return !1;
1633
1661
  let n = t.columnName.badge?.toLowerCase();
1634
1662
  if (n === "new") return (t.columnName.column?.alias || t.columnName.label) !== e.alias;
1635
1663
  let [r, i] = t.columnName.value?.split("^^^^^^");
1636
1664
  return n === "custom" || n === "group by" ? e.sql !== i : !0;
1637
1665
  });
1638
- switch (jt(n), t) {
1666
+ switch (Mt(n), t) {
1639
1667
  case "DIMENSION":
1640
1668
  K((t) => t.filter((t) => t.uniqueId ? t.uniqueId !== e?.uniqueId : t.alias !== e.alias));
1641
1669
  break;
@@ -1652,8 +1680,8 @@ var O = (e, t = /* @__PURE__ */ new WeakSet()) => {
1652
1680
  T.horizontalStack
1653
1681
  ].includes(j?.chartType), o, s = !1;
1654
1682
  a && (r.length === 2 && i.length === 1 ? o = Q([r[1]])?.[0] : s = !0);
1655
- let c = [...r, ...i], l = [...G, ...q], u = M(re(n).filter((e) => e.name), c), d = U.table;
1656
- z && (d = vn(d, G.filter((t) => t.uniqueId ? t.uniqueId !== e?.uniqueId : t.alias !== e.alias), q.filter((t) => t.uniqueId ? t.uniqueId !== e?.uniqueId : t.alias !== e.alias), Ot, n));
1683
+ let c = [...r, ...i], l = [...G, ...q], u = P(re(n).filter((e) => e.name), c), d = U.table;
1684
+ z && (d = yn(d, G.filter((t) => t.uniqueId ? t.uniqueId !== e?.uniqueId : t.alias !== e.alias), q.filter((t) => t.uniqueId ? t.uniqueId !== e?.uniqueId : t.alias !== e.alias), kt, n));
1657
1685
  let f = {
1658
1686
  ...U,
1659
1687
  dimensions: U.dimensions.filter((t) => t.uniqueId ? t.uniqueId !== e?.uniqueId : t.alias !== e.alias),
@@ -1676,13 +1704,13 @@ var O = (e, t = /* @__PURE__ */ new WeakSet()) => {
1676
1704
  updatedMetrics: t === "METRIC" ? q.filter((t) => t.uniqueId ? t.uniqueId !== e?.uniqueId : t.alias !== e.alias) : void 0
1677
1705
  });
1678
1706
  },
1679
- selectedTable: Kt,
1680
- createdSorts: At,
1681
- setCreatedSorts: jt,
1707
+ selectedTable: qt,
1708
+ createdSorts: jt,
1709
+ setCreatedSorts: Mt,
1682
1710
  onApplyFilter: (e, t, n) => {
1683
1711
  let r = U.table;
1684
1712
  if (t) {
1685
- z && (r = vn(r, G, q, [], At));
1713
+ z && (r = yn(r, G, q, [], jt));
1686
1714
  let t = {
1687
1715
  ...U,
1688
1716
  filters: [],
@@ -1690,11 +1718,11 @@ var O = (e, t = /* @__PURE__ */ new WeakSet()) => {
1690
1718
  };
1691
1719
  $({
1692
1720
  prevConfiguration: t,
1693
- queryConfiguration: ln(t)
1721
+ queryConfiguration: un(t)
1694
1722
  }), e();
1695
1723
  return;
1696
1724
  }
1697
- let i = Ot.filter((e, t) => t !== n)?.map((e) => {
1725
+ let i = kt.filter((e, t) => t !== n)?.map((e) => {
1698
1726
  let [t, n, r, i, a, o, s, c] = e?.columnName.value?.split("^^^^^^"), l = e?.operator?.value || "=", u = e?.value?.timeValue ? "time" : "default", d, f, p = e?.columnName?.dimension?.isApplyTimezone;
1699
1727
  return e?.columnName?.badge === "New" && !e?.value?.timeValue && (u = c === "DIMENSION" ? "dimension" : "agr"), u === "agr" && (d = U?.aggregates?.find((e) => e.alias === s)), (u === "time" || u === "dimension") && (f = U?.dimensions?.find((e) => e.alias === s)), e?.type === "custom" ? {
1700
1728
  isApplyTimezone: !!p,
@@ -1729,7 +1757,7 @@ var O = (e, t = /* @__PURE__ */ new WeakSet()) => {
1729
1757
  dimension: f
1730
1758
  };
1731
1759
  });
1732
- z && (r = vn(r, G, q, Ot.filter((e, t) => t !== n), At));
1760
+ z && (r = yn(r, G, q, kt.filter((e, t) => t !== n), jt));
1733
1761
  let a = {
1734
1762
  ...U,
1735
1763
  filters: i,
@@ -1737,25 +1765,25 @@ var O = (e, t = /* @__PURE__ */ new WeakSet()) => {
1737
1765
  };
1738
1766
  W(a), $({
1739
1767
  prevConfiguration: a,
1740
- queryConfiguration: ln(a)
1768
+ queryConfiguration: un(a)
1741
1769
  }), e();
1742
1770
  },
1743
1771
  onApplySort: (e, t, n) => {
1744
1772
  let r = U.table;
1745
1773
  if (t) {
1746
- z && (r = vn(r, G, q, Ot, []));
1747
- let t = M([], [...G, ...q]), n = {
1774
+ z && (r = yn(r, G, q, kt, []));
1775
+ let t = P([], [...G, ...q]), n = {
1748
1776
  ...U,
1749
1777
  orders: t,
1750
1778
  table: r
1751
1779
  };
1752
1780
  $({
1753
1781
  prevConfiguration: n,
1754
- queryConfiguration: ln(n)
1782
+ queryConfiguration: un(n)
1755
1783
  }), e();
1756
1784
  return;
1757
1785
  }
1758
- let i = At.filter((e, t) => t !== n)?.map((e) => {
1786
+ let i = jt.filter((e, t) => t !== n)?.map((e) => {
1759
1787
  let t = e.columnName.badge?.toLowerCase(), n = e.method.value, r = e.columnName.column;
1760
1788
  if (!e.columnName.value) return {
1761
1789
  method: "",
@@ -1783,8 +1811,8 @@ var O = (e, t = /* @__PURE__ */ new WeakSet()) => {
1783
1811
  method: e.method.value,
1784
1812
  name: `${a}.${o}`
1785
1813
  };
1786
- }), a = M(i.filter((e) => e.name), [...G, ...q]);
1787
- z && (r = vn(r, G, q, Ot, At.filter((e, t) => t !== n)));
1814
+ }), a = P(i.filter((e) => e.name), [...G, ...q]);
1815
+ z && (r = yn(r, G, q, kt, jt.filter((e, t) => t !== n)));
1788
1816
  let o = {
1789
1817
  ...U,
1790
1818
  orders: a.filter((e) => e.name),
@@ -1792,14 +1820,14 @@ var O = (e, t = /* @__PURE__ */ new WeakSet()) => {
1792
1820
  };
1793
1821
  W(o), $({
1794
1822
  prevConfiguration: o,
1795
- queryConfiguration: ln(o)
1823
+ queryConfiguration: un(o)
1796
1824
  }), e();
1797
1825
  },
1798
- sortColumnOptions: Yt,
1799
- filterColumnOptions: Zt,
1800
- createdFilters: Ot,
1801
- setCreatedFilters: kt,
1802
- getFilterDropDownType: nn,
1826
+ sortColumnOptions: Xt,
1827
+ filterColumnOptions: Qt,
1828
+ createdFilters: kt,
1829
+ setCreatedFilters: At,
1830
+ getFilterDropDownType: rn,
1803
1831
  onSelectTimeSeries: (e) => {
1804
1832
  if (e !== T.timeSeries) return;
1805
1833
  let t = G.find((e) => {
@@ -1841,13 +1869,13 @@ var O = (e, t = /* @__PURE__ */ new WeakSet()) => {
1841
1869
  updatedDims: G?.map((e) => e.alias === t.alias ? r : e)
1842
1870
  });
1843
1871
  },
1844
- setChartFields: sn,
1872
+ setChartFields: cn,
1845
1873
  resetCharSettings: (e) => {
1846
1874
  let t = [...G, ...q], { aggregates: n, dimensions: r } = b(t), i = {
1847
1875
  ...U,
1848
1876
  dimensions: r,
1849
1877
  aggregates: n,
1850
- orders: M(U?.orders || [], t)
1878
+ orders: P(U?.orders || [], t)
1851
1879
  };
1852
1880
  W(i), $({
1853
1881
  prevConfiguration: i,
@@ -1869,7 +1897,7 @@ var O = (e, t = /* @__PURE__ */ new WeakSet()) => {
1869
1897
  headerColumns: [],
1870
1898
  nonHeaderColumns: []
1871
1899
  }), o = e?.map((e) => `${e.columnName};;${e.value}`).join(";;");
1872
- Tt((e) => ({
1900
+ Et((e) => ({
1873
1901
  ...e,
1874
1902
  data: e.data.filter((e) => e.key !== o),
1875
1903
  error: "",
@@ -1893,7 +1921,7 @@ var O = (e, t = /* @__PURE__ */ new WeakSet()) => {
1893
1921
  ...s,
1894
1922
  ...q,
1895
1923
  ...i
1896
- ], { aggregates: u, dimensions: d } = b(l), f = M(re(At), l), p = {
1924
+ ], { aggregates: u, dimensions: d } = b(l), f = P(re(jt), l), p = {
1897
1925
  ...U,
1898
1926
  dimensions: d,
1899
1927
  aggregates: u,
@@ -1911,26 +1939,26 @@ var O = (e, t = /* @__PURE__ */ new WeakSet()) => {
1911
1939
  method: "=",
1912
1940
  parentAlias: `${C(e.table?.schemaName || "", A)}_${e.table?.tableName}`,
1913
1941
  type: "client",
1914
- value: nt === "NUMBER" ? Number(r) : r,
1942
+ value: rt === "NUMBER" ? Number(r) : r,
1915
1943
  relationOperator: "AND",
1916
1944
  isApplyTimezone: !1
1917
1945
  })) || [];
1918
- Lt({
1946
+ Rt({
1919
1947
  data: {
1920
1948
  cId: r,
1921
1949
  configuration: {
1922
1950
  ...p,
1923
- filters: !It && _?.length ? [...p?.filters, ..._] : p?.filters
1951
+ filters: !Lt && _?.length ? [...p?.filters, ..._] : p?.filters
1924
1952
  },
1925
- id: $e,
1926
- datasourceId: it,
1927
- dashboardId: at,
1953
+ id: et,
1954
+ datasourceId: at,
1955
+ dashboardId: ot,
1928
1956
  isCreateMetric: !0
1929
1957
  },
1930
- token: Qe
1958
+ token: $e
1931
1959
  }, { onSuccess(e) {
1932
1960
  let t = e?.error, n = e?.data;
1933
- if (t?.message) Tt((e) => ({
1961
+ if (t?.message) Et((e) => ({
1934
1962
  ...e,
1935
1963
  error: t?.message,
1936
1964
  isLoading: !1,
@@ -1938,7 +1966,7 @@ var O = (e, t = /* @__PURE__ */ new WeakSet()) => {
1938
1966
  }));
1939
1967
  else {
1940
1968
  let e = Re(ge(Array.isArray(n) ? n : [], G, q));
1941
- Tt((t) => ({
1969
+ Et((t) => ({
1942
1970
  data: [...t.data, {
1943
1971
  key: o,
1944
1972
  data: e
@@ -1958,7 +1986,7 @@ var O = (e, t = /* @__PURE__ */ new WeakSet()) => {
1958
1986
  } });
1959
1987
  },
1960
1988
  onSelectPivotTable: (e, t) => {
1961
- Tt({
1989
+ Et({
1962
1990
  data: [],
1963
1991
  error: "",
1964
1992
  isLoading: !1,
@@ -1978,7 +2006,7 @@ var O = (e, t = /* @__PURE__ */ new WeakSet()) => {
1978
2006
  ...c,
1979
2007
  dimensions: s,
1980
2008
  aggregates: o,
1981
- orders: M(c.orders || [], a)
2009
+ orders: P(c.orders || [], a)
1982
2010
  };
1983
2011
  W(l), $({
1984
2012
  prevConfiguration: l,
@@ -1997,11 +2025,11 @@ var O = (e, t = /* @__PURE__ */ new WeakSet()) => {
1997
2025
  });
1998
2026
  },
1999
2027
  onChangeChartGroupByValue: (e) => {
2000
- let t = e || j?.seriesField || "", n = t && t !== "ungrouped" ? en(G, t) : void 0, r = G?.[0], i = n ? [r, n] : [r], a = [...i, ...q], { aggregates: o, dimensions: s } = b(a), c = {
2028
+ let t = e || j?.seriesField || "", n = t && t !== "ungrouped" ? tn(G, t) : void 0, r = G?.[0], i = n ? [r, n] : [r], a = [...i, ...q], { aggregates: o, dimensions: s } = b(a), c = {
2001
2029
  ...U,
2002
2030
  dimensions: s,
2003
2031
  aggregates: o,
2004
- orders: M(U?.orders || [], a),
2032
+ orders: P(U?.orders || [], a),
2005
2033
  isApplyMetricFilter: !0
2006
2034
  };
2007
2035
  W(c), $({
@@ -2031,7 +2059,7 @@ var O = (e, t = /* @__PURE__ */ new WeakSet()) => {
2031
2059
  alias: `${e.value} of ${i.name}`
2032
2060
  };
2033
2061
  K((e) => e?.map((e) => e.alias === i.alias ? o : e));
2034
- let s = r ? en(G, n) : void 0, c = s ? [o, s] : [o], l = [...c, ...q], { aggregates: u, dimensions: d } = b(l), f = [{
2062
+ let s = r ? tn(G, n) : void 0, c = s ? [o, s] : [o], l = [...c, ...q], { aggregates: u, dimensions: d } = b(l), f = [{
2035
2063
  method: "ASC",
2036
2064
  name: a,
2037
2065
  type: "selected_column"
@@ -2054,18 +2082,18 @@ var O = (e, t = /* @__PURE__ */ new WeakSet()) => {
2054
2082
  updatedDims: G?.map((e) => e.alias === i.alias ? o : e)
2055
2083
  });
2056
2084
  },
2057
- isDisableChartDrillDown: Bt,
2058
- isAllowDrillDown: zt,
2085
+ isDisableChartDrillDown: Vt,
2086
+ isAllowDrillDown: Bt,
2059
2087
  onChangeDrillDown: (e, t, n, r) => {
2060
2088
  let i = r !== void 0;
2061
- n && (t ? (rt((e) => ({
2089
+ n && (t ? (it((e) => ({
2062
2090
  ...e,
2063
2091
  isEnableGroupBy: !0
2064
- })), Mt([])) : (rt((e) => ({
2092
+ })), Nt([])) : (it((e) => ({
2065
2093
  ...e,
2066
2094
  isEnableGroupBy: !1,
2067
2095
  drilldownChartSettings: void 0
2068
- })), Mt([])));
2096
+ })), Nt([])));
2069
2097
  let a = (r || 0) > 0 && Y.length ? Y.slice(0, -1) : [], o = e?.name, s = G?.[G.length > Y.length ? Y.length : 0]?.alias, c = i ? a : n ? [] : G.length > Y.length && s ? [...Y, {
2070
2098
  columnName: s,
2071
2099
  value: o
@@ -2081,7 +2109,7 @@ var O = (e, t = /* @__PURE__ */ new WeakSet()) => {
2081
2109
  chartType: u ? "table" : d?.chartType
2082
2110
  },
2083
2111
  onSuccess: () => {
2084
- Mt(c), u || rt((e) => ({
2112
+ Nt(c), u || it((e) => ({
2085
2113
  ...e,
2086
2114
  drilldownChartSettings: [...e.drilldownChartSettings?.filter((e) => e.name !== s) || [], {
2087
2115
  name: s,
@@ -2092,7 +2120,7 @@ var O = (e, t = /* @__PURE__ */ new WeakSet()) => {
2092
2120
  });
2093
2121
  },
2094
2122
  drillFilters: Y,
2095
- selectedJoinColumnOptions: qt,
2123
+ selectedJoinColumnOptions: Jt,
2096
2124
  onChangeLimit: async (e) => {
2097
2125
  $({ prevLimit: e });
2098
2126
  },
@@ -2128,7 +2156,7 @@ var O = (e, t = /* @__PURE__ */ new WeakSet()) => {
2128
2156
  ...U,
2129
2157
  dimensions: c,
2130
2158
  aggregates: s,
2131
- orders: M(U?.orders || [], o)
2159
+ orders: P(U?.orders || [], o)
2132
2160
  };
2133
2161
  W(l), $({
2134
2162
  prevConfiguration: l,
@@ -2146,11 +2174,11 @@ var O = (e, t = /* @__PURE__ */ new WeakSet()) => {
2146
2174
  updatedMetrics: t
2147
2175
  });
2148
2176
  },
2149
- joinTableOption: Jt,
2150
- currentSelectedTable: Et,
2151
- setCurrentSelectedTable: Dt,
2152
- arithmeticColumnOptions: Xt,
2153
- onSaveArithMetricOption: _n,
2177
+ joinTableOption: Yt,
2178
+ currentSelectedTable: Dt,
2179
+ setCurrentSelectedTable: Ot,
2180
+ arithmeticColumnOptions: Zt,
2181
+ onSaveArithMetricOption: vn,
2154
2182
  onSaveMetricFilter: Pe((e, t) => {
2155
2183
  let n = (e) => (e || "").trim().toLowerCase(), r = n(e.name), i = n(t);
2156
2184
  if ((U?.rlsConditions || []).some((e) => {
@@ -2162,7 +2190,7 @@ var O = (e, t = /* @__PURE__ */ new WeakSet()) => {
2162
2190
  isApplyMetricFilter: !0,
2163
2191
  rlsConditions: [...(U?.rlsConditions || []).filter((n) => n.name !== e.name && (!t || n.name !== t)), e]
2164
2192
  };
2165
- return W(a), Ze((e) => e && {
2193
+ return W(a), Qe((e) => e && {
2166
2194
  ...e,
2167
2195
  configuration: a,
2168
2196
  newDatasetSettings: e.newDatasetSettings ? {
@@ -2173,14 +2201,14 @@ var O = (e, t = /* @__PURE__ */ new WeakSet()) => {
2173
2201
  }, [
2174
2202
  U,
2175
2203
  $,
2176
- Ze
2204
+ Qe
2177
2205
  ]),
2178
2206
  onRemoveMetricFilter: Pe((e) => {
2179
2207
  let t = {
2180
2208
  ...U,
2181
2209
  rlsConditions: (U?.rlsConditions || []).filter((t) => t.name !== e)
2182
2210
  };
2183
- W(t), Ze((e) => e && {
2211
+ W(t), Qe((e) => e && {
2184
2212
  ...e,
2185
2213
  configuration: t,
2186
2214
  newDatasetSettings: e.newDatasetSettings ? {
@@ -2191,7 +2219,7 @@ var O = (e, t = /* @__PURE__ */ new WeakSet()) => {
2191
2219
  }, [
2192
2220
  U,
2193
2221
  $,
2194
- Ze
2222
+ Qe
2195
2223
  ]),
2196
2224
  onChangeMetricFilterValue: Pe((e, t, n, r, i, a) => {
2197
2225
  let o = (U?.rlsConditions || []).map((o) => o.name === e ? r ? {
@@ -2233,12 +2261,12 @@ var O = (e, t = /* @__PURE__ */ new WeakSet()) => {
2233
2261
  };
2234
2262
  W(s), $({ prevConfiguration: s });
2235
2263
  }, [U, $]),
2236
- builderError: mt
2264
+ builderError: ht
2237
2265
  };
2238
2266
  };
2239
2267
  //#endregion
2240
2268
  //#region src/core/metric-builder/permissions.ts
2241
- function F(e, t) {
2269
+ function $e(e, t) {
2242
2270
  return {
2243
2271
  canCreateMetric: !!e?.isAllowedToCreateMetrics && !t?.disableMetricCreation,
2244
2272
  canManageMetrics: !!e?.isAllowedManageMetrics && !t?.disableManageMetrics,
@@ -2259,4 +2287,4 @@ function F(e, t) {
2259
2287
  };
2260
2288
  }
2261
2289
  //#endregion
2262
- export { A as a, Ye as i, Ke as n, ze as o, M as r, Re as s, F as t };
2290
+ export { A as a, Qe as i, F as n, ze as o, P as r, Re as s, $e as t };