drizzle-cube 0.4.36 → 0.4.38

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 (80) hide show
  1. package/dist/adapters/express/index.cjs +1 -1
  2. package/dist/adapters/express/index.js +3 -3
  3. package/dist/adapters/fastify/index.cjs +1 -1
  4. package/dist/adapters/fastify/index.js +3 -3
  5. package/dist/adapters/{handler-DzUX7CBs.cjs → handler-dHHEEbG9.cjs} +1 -1
  6. package/dist/adapters/{handler-J55KQKe5.js → handler-fto6TSVn.js} +1 -1
  7. package/dist/adapters/hono/index.cjs +1 -1
  8. package/dist/adapters/hono/index.js +3 -3
  9. package/dist/adapters/{mcp-transport-CjA5_6G_.cjs → mcp-transport-ro4OL4BW.cjs} +4 -4
  10. package/dist/adapters/{mcp-transport-x_A7Q5OL.js → mcp-transport-tB5a7Het.js} +70 -17
  11. package/dist/adapters/nextjs/index.cjs +1 -1
  12. package/dist/adapters/nextjs/index.js +3 -3
  13. package/dist/adapters/{utils-CDExg9uP.cjs → utils-2MwxiQ2o.cjs} +1 -1
  14. package/dist/adapters/{utils-DkKcpkx5.js → utils-_2o905Fi.js} +2 -1
  15. package/dist/adapters/utils.cjs +1 -1
  16. package/dist/adapters/utils.d.ts +2 -0
  17. package/dist/adapters/utils.js +1 -1
  18. package/dist/client/charts.js +3 -3
  19. package/dist/client/chunks/{DashboardEditModal-kWEk4KJC.js → DashboardEditModal-DrjEsyoO.js} +7 -7
  20. package/dist/client/chunks/DashboardEditModal-DrjEsyoO.js.map +1 -0
  21. package/dist/client/chunks/{FieldSearchModal-rB26lhBD.js → FieldSearchModal-BxQ5JhWz.js} +2 -2
  22. package/dist/client/chunks/{FieldSearchModal-rB26lhBD.js.map → FieldSearchModal-BxQ5JhWz.js.map} +1 -1
  23. package/dist/client/chunks/{analysis-builder-CdDPUAEU.js → analysis-builder-CmJhXXc7.js} +1863 -2554
  24. package/dist/client/chunks/analysis-builder-CmJhXXc7.js.map +1 -0
  25. package/dist/client/chunks/{analysis-builder-shared-3V70XUNW.js → analysis-builder-shared-BxHYfTzo.js} +1516 -722
  26. package/dist/client/chunks/analysis-builder-shared-BxHYfTzo.js.map +1 -0
  27. package/dist/client/chunks/{chart-data-table-BlkFWPhF.js → chart-data-table-CW_qZDpt.js} +11 -1
  28. package/dist/client/chunks/chart-data-table-CW_qZDpt.js.map +1 -0
  29. package/dist/client/chunks/{chart-kpi-delta-CUIjCDS3.js → chart-kpi-delta-BPexzOe7.js} +2 -2
  30. package/dist/client/chunks/{chart-kpi-delta-CUIjCDS3.js.map → chart-kpi-delta-BPexzOe7.js.map} +1 -1
  31. package/dist/client/chunks/{chart-kpi-number-CxlpSKYh.js → chart-kpi-number-BBtGBtZL.js} +3 -3
  32. package/dist/client/chunks/{chart-kpi-number-CxlpSKYh.js.map → chart-kpi-number-BBtGBtZL.js.map} +1 -1
  33. package/dist/client/chunks/{chart-kpi-text-C16fwohp.js → chart-kpi-text-BqHhmJEB.js} +2 -2
  34. package/dist/client/chunks/{chart-kpi-text-C16fwohp.js.map → chart-kpi-text-BqHhmJEB.js.map} +1 -1
  35. package/dist/client/chunks/{charts-loader-BFhQWB_d.js → charts-loader-gZjOqZwG.js} +5 -5
  36. package/dist/client/chunks/{charts-loader-BFhQWB_d.js.map → charts-loader-gZjOqZwG.js.map} +1 -1
  37. package/dist/client/chunks/{schema-visualization-qmLI8MGQ.js → schema-visualization-XLFzV_7p.js} +2 -2
  38. package/dist/client/chunks/{schema-visualization-qmLI8MGQ.js.map → schema-visualization-XLFzV_7p.js.map} +1 -1
  39. package/dist/client/chunks/{useDebounce-xfPFr2fi.js → useDebounce-C_wstEud.js} +2 -2
  40. package/dist/client/chunks/{useDebounce-xfPFr2fi.js.map → useDebounce-C_wstEud.js.map} +1 -1
  41. package/dist/client/chunks/{useExplainAI-6COjssus.js → useExplainAI-C9ytXRIC.js} +21 -18
  42. package/dist/client/chunks/{useExplainAI-6COjssus.js.map → useExplainAI-C9ytXRIC.js.map} +1 -1
  43. package/dist/client/chunks/{utils-nCeVL-Hm.js → utils-3FNmeZJR.js} +2 -2
  44. package/dist/client/chunks/{utils-nCeVL-Hm.js.map → utils-3FNmeZJR.js.map} +1 -1
  45. package/dist/client/chunks/{vendor-WzXX36hd.js → vendor-BPRWulB7.js} +2 -2
  46. package/dist/client/chunks/{vendor-WzXX36hd.js.map → vendor-BPRWulB7.js.map} +1 -1
  47. package/dist/client/components/AIAssistant/utils.d.ts +1 -1
  48. package/dist/client/components/AnalysisBuilder/LimitSection.d.ts +14 -0
  49. package/dist/client/components/AnalysisBuilder/types.d.ts +7 -0
  50. package/dist/client/components/AnalysisBuilder/utils/queryUtils.d.ts +1 -1
  51. package/dist/client/components/DataBrowser/DataBrowserSidebar.d.ts +16 -0
  52. package/dist/client/components/DataBrowser/DataBrowserTable.d.ts +16 -0
  53. package/dist/client/components/DataBrowser/DataBrowserToolbar.d.ts +22 -0
  54. package/dist/client/components/DataBrowser/index.d.ts +28 -0
  55. package/dist/client/components.js +3 -3
  56. package/dist/client/hooks/useAnalysisBuilderHook.d.ts +1 -0
  57. package/dist/client/hooks/useDataBrowser.d.ts +67 -0
  58. package/dist/client/hooks.js +3 -3
  59. package/dist/client/icons/types.d.ts +1 -0
  60. package/dist/client/icons.js +1 -1
  61. package/dist/client/index.d.ts +3 -0
  62. package/dist/client/index.js +774 -192
  63. package/dist/client/index.js.map +1 -1
  64. package/dist/client/providers/CubeApiProvider.d.ts +1 -0
  65. package/dist/client/providers.js +1 -1
  66. package/dist/client/stores/analysisBuilderStore.d.ts +2 -0
  67. package/dist/client/stores/dataBrowserStore.d.ts +34 -0
  68. package/dist/client/stores/slices/querySlice.d.ts +1 -0
  69. package/dist/client/styles.css +1 -1
  70. package/dist/client/types.d.ts +2 -0
  71. package/dist/client/utils.js +3 -3
  72. package/dist/client-bundle-stats.html +1 -1
  73. package/dist/server/index.cjs +3 -3
  74. package/dist/server/index.d.ts +18 -0
  75. package/dist/server/index.js +68 -15
  76. package/package.json +1 -1
  77. package/dist/client/chunks/DashboardEditModal-kWEk4KJC.js.map +0 -1
  78. package/dist/client/chunks/analysis-builder-CdDPUAEU.js.map +0 -1
  79. package/dist/client/chunks/analysis-builder-shared-3V70XUNW.js.map +0 -1
  80. package/dist/client/chunks/chart-data-table-BlkFWPhF.js.map +0 -1
@@ -1,15 +1,16 @@
1
- import { a as e, i as t, n, o as r, r as i, s as a, t as o } from "./vendor-WzXX36hd.js";
2
- import { S as s } from "./chart-data-table-BlkFWPhF.js";
3
- import { C as c, a as l, b as u, l as d, r as f, s as p } from "./useDebounce-xfPFr2fi.js";
4
- import { a as m, i as h } from "./useExplainAI-6COjssus.js";
5
- import { r as g, s as _ } from "./chart-funnel-C9JRW79j.js";
6
- import { A as v } from "./chart-activity-grid-wR2Twpo7.js";
7
- import { a as y, s as b, t as x } from "./retention-UEXlSdZ-.js";
8
- import { L as S, R as C, a as w, d as T, f as E, g as D, h as O, o as k, s as A, x as ee } from "./FieldSearchModal-rB26lhBD.js";
9
- import j, { createContext as M, memo as N, useCallback as P, useContext as F, useEffect as I, useMemo as L, useRef as te, useState as R } from "react";
10
- import { Fragment as z, jsx as B, jsxs as V } from "react/jsx-runtime";
1
+ import { a as e, i as t, n, o as r, r as i, s as a, t as o } from "./vendor-BPRWulB7.js";
2
+ import { S as s, d as c } from "./chart-data-table-CW_qZDpt.js";
3
+ import { C as l, D as u, E as d, O as f, T as p, a as m, b as h, l as g, n as _, r as v, s as y, t as b } from "./useDebounce-C_wstEud.js";
4
+ import { a as x, i as ee } from "./useExplainAI-C9ytXRIC.js";
5
+ import { r as te, s as S } from "./chart-funnel-C9JRW79j.js";
6
+ import { A as ne } from "./chart-activity-grid-wR2Twpo7.js";
7
+ import { a as C, s as w, t as T } from "./retention-UEXlSdZ-.js";
8
+ import { L as E, R as re, a as D, c as O, d as k, f as A, g as j, h as M, l as ie, o as N, s as P, t as ae, x as F } from "./FieldSearchModal-BxQ5JhWz.js";
9
+ import { n as oe } from "./charts-core-CJlGzwsW.js";
10
+ import I, { createContext as se, memo as L, useCallback as R, useContext as ce, useEffect as z, useMemo as B, useRef as V, useState as H } from "react";
11
+ import { Fragment as U, jsx as W, jsxs as G } from "react/jsx-runtime";
11
12
  //#region src/shared/date-utils.ts
12
- function ne(e) {
13
+ function le(e) {
13
14
  let t = /* @__PURE__ */ new Date(), n = e.toLowerCase().trim(), r = t.getUTCFullYear(), i = t.getUTCMonth(), a = t.getUTCDate(), o = t.getUTCDay();
14
15
  if (n === "today") {
15
16
  let e = new Date(t);
@@ -122,7 +123,7 @@ function ne(e) {
122
123
  }
123
124
  return null;
124
125
  }
125
- function re(e) {
126
+ function ue(e) {
126
127
  if (Array.isArray(e)) {
127
128
  if (e.length < 2) return null;
128
129
  let t = new Date(e[0]), n = new Date(e[1]);
@@ -131,12 +132,12 @@ function re(e) {
131
132
  end: n
132
133
  });
133
134
  }
134
- return ne(e);
135
+ return le(e);
135
136
  }
136
- function H(e) {
137
+ function de(e) {
137
138
  return e.toISOString().split("T")[0];
138
139
  }
139
- function ie(e, t) {
140
+ function fe(e, t) {
140
141
  let n = t.getTime() - e.getTime(), r = Math.ceil(n / (1e3 * 60 * 60 * 24)), i = new Date(e);
141
142
  i.setUTCDate(i.getUTCDate() - 1), i.setUTCHours(23, 59, 59, 999);
142
143
  let a = new Date(i);
@@ -147,27 +148,27 @@ function ie(e, t) {
147
148
  }
148
149
  //#endregion
149
150
  //#region src/client/components/AnalysisBuilder/utils/filterUtils.ts
150
- function ae(e, t) {
151
+ function pe(e, t) {
151
152
  for (let n of e) if ("type" in n && "filters" in n) {
152
- let e = ae(n.filters, t);
153
+ let e = pe(n.filters, t);
153
154
  if (e) return e;
154
155
  } else if ("member" in n) {
155
156
  let e = n;
156
157
  if (e.member === t && e.operator === "inDateRange" && e.dateRange) return { dateRange: e.dateRange };
157
158
  }
158
159
  }
159
- function oe(e, t) {
160
- let n = ae(t, e);
160
+ function me(e, t) {
161
+ let n = pe(t, e);
161
162
  if (!n?.dateRange) return;
162
- let r = re(n.dateRange);
163
+ let r = ue(n.dateRange);
163
164
  if (!r) return;
164
- let i = ie(r.start, r.end);
165
- return [[H(r.start), H(r.end)], [H(i.start), H(i.end)]];
165
+ let i = fe(r.start, r.end);
166
+ return [[de(r.start), de(r.end)], [de(i.start), de(i.end)]];
166
167
  }
167
- function se(e, t) {
168
+ function he(e, t) {
168
169
  return e.reduce((e, n) => {
169
170
  if ("type" in n && "filters" in n) {
170
- let r = n, i = se(r.filters, t);
171
+ let r = n, i = he(r.filters, t);
171
172
  i.length > 0 && e.push({
172
173
  type: r.type,
173
174
  filters: i
@@ -181,11 +182,11 @@ function se(e, t) {
181
182
  }
182
183
  //#endregion
183
184
  //#region src/client/components/AnalysisBuilder/utils/queryUtils.ts
184
- function ce(e, t, n, r, i = !1) {
185
- let a = t.filter((e) => e.isTimeDimension && e.enableComparison).map((e) => e.field), o = n;
186
- if (!i) for (let e of a) o = se(o, e);
187
- o = o.filter((e) => ee(e));
188
- let s = {
185
+ function ge(e, t, n, r, i = !1, a) {
186
+ let o = t.filter((e) => e.isTimeDimension && e.enableComparison).map((e) => e.field), s = n;
187
+ if (!i) for (let e of o) s = he(s, e);
188
+ s = s.filter((e) => F(e));
189
+ let c = {
189
190
  measures: e.map((e) => e.field),
190
191
  dimensions: t.filter((e) => !e.isTimeDimension).map((e) => e.field),
191
192
  timeDimensions: t.filter((e) => e.isTimeDimension).map((e) => {
@@ -194,45 +195,828 @@ function ce(e, t, n, r, i = !1) {
194
195
  granularity: e.granularity || "day"
195
196
  };
196
197
  if (e.enableComparison) {
197
- let r = oe(e.field, n);
198
+ let r = me(e.field, n);
198
199
  r && (t.compareDateRange = r);
199
200
  }
200
201
  return t;
201
202
  }),
202
- filters: o.length > 0 ? o : void 0,
203
- order: r && Object.keys(r).length > 0 ? r : void 0
203
+ filters: s.length > 0 ? s : void 0,
204
+ order: r && Object.keys(r).length > 0 ? r : void 0,
205
+ limit: a ?? void 0
204
206
  };
205
- return s.measures?.length === 0 && delete s.measures, s.dimensions?.length === 0 && delete s.dimensions, s.timeDimensions?.length === 0 && delete s.timeDimensions, s;
207
+ return c.measures?.length === 0 && delete c.measures, c.dimensions?.length === 0 && delete c.dimensions, c.timeDimensions?.length === 0 && delete c.timeDimensions, c;
206
208
  }
207
- function U() {
209
+ function K() {
208
210
  return {
209
211
  metrics: [],
210
212
  breakdowns: [],
211
213
  filters: [],
212
214
  order: void 0,
215
+ limit: void 0,
213
216
  validationStatus: "idle",
214
217
  validationError: null
215
218
  };
216
219
  }
217
220
  //#endregion
221
+ //#region src/client/components/AnalysisBuilder/FilterConfigModal.tsx
222
+ var _e = c("close"), ve = c("chevronDown"), q = c("dimension"), J = c("timeDimension"), Y = c("measure");
223
+ function ye({ filter: e, schema: t, onSave: n, onCancel: r, anchorElement: i }) {
224
+ let [a, o] = H(e), [s, c] = H(!1), [m, h] = H(!1), [g, v] = H(!1), [y, x] = H("this_month"), [ee, te] = H(1), [S, ne] = H(""), [C, w] = H(null), [T, E] = H(-1), re = V(null), D = V(null), k = b(S, 300), A = O(a.member, t), j = A?.field.type || "string", M = j === "time", N = A?.fieldType === "measure", P = A?.fieldType === "dimension", ae = ie(a.member, t), F = f[a.operator], oe = p(j), I = M && a.operator === "inDateRange", se = R(() => [
225
+ "equals",
226
+ "notEquals",
227
+ "in",
228
+ "notIn"
229
+ ].includes(a.operator) && P && !M, [
230
+ a.operator,
231
+ P,
232
+ M
233
+ ])(), { values: L, loading: ce, error: B, searchValues: le } = _(a.member, se);
234
+ z(() => {
235
+ if (!i) {
236
+ w(null);
237
+ return;
238
+ }
239
+ let e = i.getBoundingClientRect(), t = e.top, n = window.innerHeight - e.bottom, r = t > 500 || t > n, a = Math.max(16, Math.min(e.left, window.innerWidth - 400 - 16));
240
+ w(r ? {
241
+ bottom: window.innerHeight - e.top + 8,
242
+ left: a
243
+ } : {
244
+ top: e.bottom + 8,
245
+ left: a
246
+ });
247
+ }, [i]), z(() => {
248
+ let e = (e) => {
249
+ re.current && !re.current.contains(e.target) && (c(!1), h(!1), v(!1));
250
+ };
251
+ return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
252
+ }, []), z(() => {
253
+ m && se && le && le("", !0), m || E(-1);
254
+ }, [
255
+ m,
256
+ se,
257
+ le
258
+ ]), z(() => {
259
+ if (T >= 0 && D.current) {
260
+ let e = D.current.children[T];
261
+ e && e.scrollIntoView({ block: "nearest" });
262
+ }
263
+ }, [T]), z(() => {
264
+ m && se && le && k !== void 0 && le(k);
265
+ }, [
266
+ k,
267
+ m,
268
+ se,
269
+ le
270
+ ]), z(() => {
271
+ if (!(!I || !a.dateRange)) if (Array.isArray(a.dateRange)) x("custom");
272
+ else {
273
+ let e = a.dateRange.match(/^last (\d+) (days|weeks|months|quarters|years)$/), t = !e && a.dateRange.match(/^last (day|week|month|quarter|year)$/);
274
+ if (e) {
275
+ let [, t, n] = e;
276
+ x(`last_n_${n}`), te(parseInt(t) || 1);
277
+ } else if (t) {
278
+ let [, e] = t;
279
+ x(`last_n_${e === "day" ? "days" : e === "week" ? "weeks" : e === "month" ? "months" : e === "quarter" ? "quarters" : "years"}`), te(1);
280
+ } else {
281
+ let e = !1;
282
+ for (let t of u) if (t.value !== "custom" && !d(t.value) && l(t.value) === a.dateRange) {
283
+ x(t.value), e = !0;
284
+ break;
285
+ }
286
+ e || x("custom");
287
+ }
288
+ }
289
+ }, [a.dateRange, I]);
290
+ let ue = R((e) => {
291
+ o({
292
+ member: a.member,
293
+ operator: e,
294
+ values: []
295
+ }), c(!1);
296
+ }, [a.member]), de = R((e, t) => {
297
+ let n = t?.shiftKey ?? !1, r = a.values || [];
298
+ F?.supportsMultipleValues ? (r.includes(e) ? o({
299
+ ...a,
300
+ values: r.filter((t) => t !== e)
301
+ }) : o({
302
+ ...a,
303
+ values: [...r, e]
304
+ }), n || h(!1)) : (o({
305
+ ...a,
306
+ values: [e]
307
+ }), h(!1)), ne(""), E(-1);
308
+ }, [a, F?.supportsMultipleValues]), fe = R((e) => {
309
+ let t = (a.values || []).filter((t) => t !== e);
310
+ o({
311
+ ...a,
312
+ values: t
313
+ });
314
+ }, [a]), pe = R((e) => {
315
+ if (!(!m || L.length === 0)) switch (e.key) {
316
+ case "ArrowDown":
317
+ e.preventDefault(), E((e) => e < L.length - 1 ? e + 1 : 0);
318
+ break;
319
+ case "ArrowUp":
320
+ e.preventDefault(), E((e) => e > 0 ? e - 1 : L.length - 1);
321
+ break;
322
+ case "Enter":
323
+ e.preventDefault(), T >= 0 && T < L.length && de(L[T], { shiftKey: e.shiftKey });
324
+ break;
325
+ case "Escape":
326
+ e.preventDefault(), h(!1), E(-1);
327
+ break;
328
+ }
329
+ }, [
330
+ m,
331
+ L,
332
+ T,
333
+ de
334
+ ]), me = R((e) => {
335
+ let t = e.target.value;
336
+ if (F?.valueType === "number") {
337
+ let e = parseFloat(t);
338
+ isNaN(e) ? (t === "" || t === "-") && o({
339
+ ...a,
340
+ values: []
341
+ }) : o({
342
+ ...a,
343
+ values: [e]
344
+ });
345
+ } else o({
346
+ ...a,
347
+ values: t ? [t] : []
348
+ });
349
+ }, [a, F?.valueType]), he = R((e) => {
350
+ let t = parseFloat(e.target.value), n = [isNaN(t) ? "" : t, (a.values?.length >= 2 ? a.values : ["", ""])[1]].filter((e) => e !== "");
351
+ o({
352
+ ...a,
353
+ values: n
354
+ });
355
+ }, [a]), ge = R((e) => {
356
+ let t = parseFloat(e.target.value), n = [(a.values?.length >= 2 ? a.values : ["", ""])[0], isNaN(t) ? "" : t].filter((e) => e !== "");
357
+ o({
358
+ ...a,
359
+ values: n
360
+ });
361
+ }, [a]), K = R((e) => {
362
+ let t = e.target.value;
363
+ o({
364
+ ...a,
365
+ values: t ? [t] : []
366
+ });
367
+ }, [a]), ye = R((e) => {
368
+ x(e), v(!1);
369
+ let t;
370
+ if (e === "custom") {
371
+ let e = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
372
+ t = [e, e];
373
+ } else t = d(e) ? l(e, ee) : l(e);
374
+ o({
375
+ ...a,
376
+ dateRange: t
377
+ });
378
+ }, [a, ee]), be = R((e) => {
379
+ if (te(e), d(y)) {
380
+ let t = l(y, e);
381
+ o({
382
+ ...a,
383
+ dateRange: t
384
+ });
385
+ }
386
+ }, [a, y]), xe = R((e) => {
387
+ let t = e.target.value, n = (Array.isArray(a.dateRange) ? a.dateRange : [a.dateRange || "", ""])[1] || t;
388
+ o({
389
+ ...a,
390
+ dateRange: [t, n]
391
+ });
392
+ }, [a]), Se = R((e) => {
393
+ let t = e.target.value, n = (Array.isArray(a.dateRange) ? a.dateRange : ["", a.dateRange || ""])[0] || t;
394
+ o({
395
+ ...a,
396
+ dateRange: [n, t]
397
+ });
398
+ }, [a]), Ce = oe.find((e) => e.operator === a.operator)?.label || a.operator, we = u.find((e) => e.value === y)?.label || "Select range", Te = M ? J : N ? Y : q, Ee = () => F?.requiresValues ? I ? /* @__PURE__ */ G("div", {
399
+ className: "dc:space-y-2",
400
+ children: [
401
+ /* @__PURE__ */ G("div", {
402
+ className: "dc:relative",
403
+ children: [/* @__PURE__ */ G("button", {
404
+ onClick: () => {
405
+ c(!1), h(!1), v(!g);
406
+ },
407
+ className: "dc:w-full dc:flex dc:items-center dc:justify-between dc:text-left dc:text-sm dc:border border-dc-border dc:rounded dc:px-3 dc:py-2 bg-dc-surface text-dc-text hover:bg-dc-surface-hover",
408
+ children: [/* @__PURE__ */ W("span", {
409
+ className: "dc:truncate",
410
+ children: we
411
+ }), /* @__PURE__ */ W(ve, { className: `dc:w-4 dc:h-4 text-dc-text-muted dc:shrink-0 dc:ml-2 dc:transition-transform ${g ? "dc:rotate-180" : ""}` })]
412
+ }), g && /* @__PURE__ */ W("div", {
413
+ className: "dc:absolute dc:z-[60] dc:left-0 dc:right-0 dc:mt-1 bg-dc-surface dc:border border-dc-border dc:rounded dc:shadow-lg dc:max-h-48 dc:overflow-y-auto",
414
+ children: u.map((e) => /* @__PURE__ */ W("button", {
415
+ onClick: () => ye(e.value),
416
+ className: `dc:w-full dc:text-left dc:px-3 dc:py-2 dc:text-sm hover:bg-dc-surface-hover ${e.value === y ? "bg-dc-primary/10 text-dc-primary" : "text-dc-text"}`,
417
+ children: e.label
418
+ }, e.value))
419
+ })]
420
+ }),
421
+ d(y) && /* @__PURE__ */ G("div", {
422
+ className: "dc:flex dc:items-center dc:gap-2",
423
+ children: [/* @__PURE__ */ W("input", {
424
+ type: "number",
425
+ min: "1",
426
+ max: "1000",
427
+ value: ee,
428
+ onChange: (e) => be(Math.max(1, parseInt(e.target.value) || 1)),
429
+ className: "dc:flex-1 dc:text-sm dc:border border-dc-border dc:rounded dc:px-3 dc:py-2 bg-dc-surface text-dc-text dc:w-20"
430
+ }), /* @__PURE__ */ W("span", {
431
+ className: "dc:text-sm text-dc-text-muted",
432
+ children: y.replace("last_n_", "")
433
+ })]
434
+ }),
435
+ y === "custom" && /* @__PURE__ */ G("div", {
436
+ className: "dc:flex dc:items-center dc:gap-2",
437
+ children: [
438
+ /* @__PURE__ */ W("input", {
439
+ type: "date",
440
+ value: Array.isArray(a.dateRange) ? a.dateRange[0] : "",
441
+ onChange: xe,
442
+ className: "dc:flex-1 dc:text-sm dc:border border-dc-border dc:rounded dc:px-2 dc:py-2 bg-dc-surface text-dc-text"
443
+ }),
444
+ /* @__PURE__ */ W("span", {
445
+ className: "dc:text-sm text-dc-text-muted",
446
+ children: "to"
447
+ }),
448
+ /* @__PURE__ */ W("input", {
449
+ type: "date",
450
+ value: Array.isArray(a.dateRange) ? a.dateRange[1] : "",
451
+ onChange: Se,
452
+ className: "dc:flex-1 dc:text-sm dc:border border-dc-border dc:rounded dc:px-2 dc:py-2 bg-dc-surface text-dc-text"
453
+ })
454
+ ]
455
+ })
456
+ ]
457
+ }) : a.operator === "between" || a.operator === "notBetween" ? /* @__PURE__ */ G("div", {
458
+ className: "dc:flex dc:items-center dc:gap-2",
459
+ children: [
460
+ /* @__PURE__ */ W("input", {
461
+ type: "number",
462
+ value: a.values?.[0] ?? "",
463
+ onChange: he,
464
+ placeholder: "Min",
465
+ className: "dc:flex-1 dc:text-sm dc:border border-dc-border dc:rounded dc:px-3 dc:py-2 bg-dc-surface text-dc-text"
466
+ }),
467
+ /* @__PURE__ */ W("span", {
468
+ className: "dc:text-sm text-dc-text-muted",
469
+ children: "to"
470
+ }),
471
+ /* @__PURE__ */ W("input", {
472
+ type: "number",
473
+ value: a.values?.[1] ?? "",
474
+ onChange: ge,
475
+ placeholder: "Max",
476
+ className: "dc:flex-1 dc:text-sm dc:border border-dc-border dc:rounded dc:px-3 dc:py-2 bg-dc-surface text-dc-text"
477
+ })
478
+ ]
479
+ }) : F?.valueType === "date" ? /* @__PURE__ */ W("input", {
480
+ type: "date",
481
+ value: a.values?.[0] || "",
482
+ onChange: K,
483
+ className: "dc:w-full dc:text-sm dc:border border-dc-border dc:rounded dc:px-3 dc:py-2 bg-dc-surface text-dc-text"
484
+ }) : F?.valueType === "number" ? /* @__PURE__ */ W("input", {
485
+ type: "number",
486
+ value: a.values?.[0] ?? "",
487
+ onChange: me,
488
+ placeholder: "Enter number",
489
+ className: "dc:w-full dc:text-sm dc:border border-dc-border dc:rounded dc:px-3 dc:py-2 bg-dc-surface text-dc-text"
490
+ }) : se ? /* @__PURE__ */ G("div", {
491
+ className: "dc:space-y-2",
492
+ children: [
493
+ a.values && a.values.length > 0 && /* @__PURE__ */ W("div", {
494
+ className: "dc:flex dc:flex-wrap dc:gap-1.5",
495
+ children: a.values.map((e, t) => /* @__PURE__ */ G("span", {
496
+ className: "dc:inline-flex dc:items-center dc:gap-1 bg-dc-primary/10 text-dc-primary dc:text-sm dc:px-2 dc:py-1 dc:rounded",
497
+ children: [/* @__PURE__ */ W("span", {
498
+ className: "dc:max-w-[150px] dc:truncate",
499
+ children: String(e)
500
+ }), /* @__PURE__ */ W("button", {
501
+ onClick: () => fe(e),
502
+ className: "hover:text-dc-danger",
503
+ children: /* @__PURE__ */ W(_e, { className: "dc:w-3.5 dc:h-3.5" })
504
+ })]
505
+ }, t))
506
+ }),
507
+ /* @__PURE__ */ G("div", {
508
+ className: "dc:relative",
509
+ children: [/* @__PURE__ */ G("button", {
510
+ onClick: () => {
511
+ c(!1), v(!1), h(!m);
512
+ },
513
+ className: "dc:w-full dc:flex dc:items-center dc:justify-between dc:text-left dc:text-sm dc:border border-dc-border dc:rounded dc:px-3 dc:py-2 bg-dc-surface text-dc-text hover:bg-dc-surface-hover",
514
+ children: [/* @__PURE__ */ W("span", {
515
+ className: "text-dc-text-muted dc:truncate",
516
+ children: ce ? "Loading..." : "Select value..."
517
+ }), /* @__PURE__ */ W(ve, { className: `dc:w-4 dc:h-4 text-dc-text-muted dc:shrink-0 dc:ml-2 dc:transition-transform ${m ? "dc:rotate-180" : ""}` })]
518
+ }), m && /* @__PURE__ */ G("div", {
519
+ className: "dc:absolute dc:z-[60] dc:left-0 dc:right-0 dc:mt-1 bg-dc-surface dc:border border-dc-border dc:rounded dc:shadow-lg dc:max-h-56 dc:overflow-hidden",
520
+ children: [/* @__PURE__ */ W("div", {
521
+ className: "dc:p-2 dc:border-b border-dc-border",
522
+ children: /* @__PURE__ */ W("input", {
523
+ type: "text",
524
+ value: S,
525
+ onChange: (e) => {
526
+ ne(e.target.value), E(-1);
527
+ },
528
+ onKeyDown: pe,
529
+ placeholder: "Search...",
530
+ className: "dc:w-full dc:text-sm dc:border border-dc-border dc:rounded dc:px-3 dc:py-2 bg-dc-surface text-dc-text",
531
+ autoFocus: !0
532
+ })
533
+ }), /* @__PURE__ */ W("div", {
534
+ ref: D,
535
+ className: "dc:max-h-40 dc:overflow-y-auto",
536
+ children: ce ? /* @__PURE__ */ W("div", {
537
+ className: "dc:px-3 dc:py-2 dc:text-sm text-dc-text-muted",
538
+ children: "Loading..."
539
+ }) : B ? /* @__PURE__ */ G("div", {
540
+ className: "dc:px-3 dc:py-2 dc:text-sm text-dc-error",
541
+ children: ["Error: ", B]
542
+ }) : L.length === 0 ? /* @__PURE__ */ W("div", {
543
+ className: "dc:px-3 dc:py-2 dc:text-sm text-dc-text-muted",
544
+ children: "No values found"
545
+ }) : L.map((e, t) => {
546
+ let n = a.values?.includes(e);
547
+ return /* @__PURE__ */ G("button", {
548
+ onClick: (t) => de(e, t),
549
+ className: `dc:w-full dc:text-left dc:px-3 dc:py-2 dc:text-sm dc:transition-colors ${t === T ? "bg-dc-surface-hover" : ""} ${n ? "bg-dc-primary/10 text-dc-primary" : "text-dc-text hover:bg-dc-surface-hover"}`,
550
+ children: [String(e), n && /* @__PURE__ */ W("span", {
551
+ className: "dc:float-right",
552
+ children: "✓"
553
+ })]
554
+ }, `${e}-${t}`);
555
+ })
556
+ })]
557
+ })]
558
+ }),
559
+ F?.supportsMultipleValues && /* @__PURE__ */ W("p", {
560
+ className: "dc:text-xs text-dc-text-muted",
561
+ children: "Hold Shift to select multiple values"
562
+ })
563
+ ]
564
+ }) : /* @__PURE__ */ W("input", {
565
+ type: "text",
566
+ value: a.values?.[0] ?? "",
567
+ onChange: me,
568
+ placeholder: "Enter value...",
569
+ className: "dc:w-full dc:text-sm dc:border border-dc-border dc:rounded dc:px-3 dc:py-2 bg-dc-surface text-dc-text placeholder-dc-text-muted"
570
+ }) : /* @__PURE__ */ W("div", {
571
+ className: "dc:text-sm text-dc-text-muted dc:italic dc:py-2",
572
+ children: "No value required"
573
+ });
574
+ return /* @__PURE__ */ W(U, { children: /* @__PURE__ */ W("div", {
575
+ className: `dc:fixed dc:inset-0 bg-dc-overlay dc:z-50 ${C ? "" : "dc:flex dc:items-center dc:justify-center dc:p-4"}`,
576
+ onClick: r,
577
+ children: /* @__PURE__ */ G("div", {
578
+ ref: re,
579
+ className: C ? "bg-dc-surface rounded-lg border border-dc-border" : "bg-dc-surface rounded-lg border border-dc-border max-w-md w-full",
580
+ style: {
581
+ ...C ? {
582
+ position: "fixed",
583
+ ...C,
584
+ maxWidth: "400px",
585
+ width: "100%"
586
+ } : {},
587
+ boxShadow: "var(--dc-shadow-xl)"
588
+ },
589
+ onClick: (e) => e.stopPropagation(),
590
+ children: [
591
+ /* @__PURE__ */ G("div", {
592
+ className: "dc:flex dc:items-center dc:justify-between dc:p-4 dc:border-b border-dc-border",
593
+ children: [/* @__PURE__ */ W("h2", {
594
+ className: "dc:text-lg dc:font-semibold text-dc-text",
595
+ children: "Edit Filter"
596
+ }), /* @__PURE__ */ W("button", {
597
+ onClick: r,
598
+ className: "dc:p-1 text-dc-text-muted hover:text-dc-text dc:transition-colors",
599
+ children: /* @__PURE__ */ W(_e, { className: "dc:w-5 dc:h-5" })
600
+ })]
601
+ }),
602
+ /* @__PURE__ */ G("div", {
603
+ className: "dc:p-4 dc:space-y-4",
604
+ children: [
605
+ /* @__PURE__ */ G("div", { children: [/* @__PURE__ */ W("label", {
606
+ className: "dc:block dc:text-sm dc:font-medium text-dc-text-secondary dc:mb-2",
607
+ children: "Field"
608
+ }), /* @__PURE__ */ G("div", {
609
+ className: "dc:flex dc:items-center dc:gap-2 dc:p-3 bg-dc-surface-secondary dc:rounded",
610
+ children: [/* @__PURE__ */ W(Te, { className: "dc:w-5 dc:h-5 text-dc-filter-text" }), /* @__PURE__ */ W("span", {
611
+ className: "dc:text-sm dc:font-medium text-dc-text",
612
+ children: ae
613
+ })]
614
+ })] }),
615
+ /* @__PURE__ */ G("div", { children: [/* @__PURE__ */ W("label", {
616
+ className: "dc:block dc:text-sm dc:font-medium text-dc-text-secondary dc:mb-2",
617
+ children: "Operator"
618
+ }), /* @__PURE__ */ G("div", {
619
+ className: "dc:relative",
620
+ children: [/* @__PURE__ */ G("button", {
621
+ onClick: () => {
622
+ h(!1), v(!1), c(!s);
623
+ },
624
+ className: "dc:w-full dc:flex dc:items-center dc:justify-between dc:text-left dc:text-sm dc:border border-dc-border dc:rounded dc:px-3 dc:py-2 bg-dc-surface text-dc-text hover:bg-dc-surface-hover",
625
+ children: [/* @__PURE__ */ W("span", {
626
+ className: "dc:truncate",
627
+ children: Ce
628
+ }), /* @__PURE__ */ W(ve, { className: `dc:w-4 dc:h-4 text-dc-text-muted dc:shrink-0 dc:ml-2 dc:transition-transform ${s ? "dc:rotate-180" : ""}` })]
629
+ }), s && /* @__PURE__ */ W("div", {
630
+ className: "dc:absolute dc:z-[60] dc:left-0 dc:right-0 dc:mt-1 bg-dc-surface dc:border border-dc-border dc:rounded dc:shadow-lg dc:max-h-48 dc:overflow-y-auto",
631
+ children: oe.map((e) => /* @__PURE__ */ W("button", {
632
+ onClick: () => ue(e.operator),
633
+ className: `dc:w-full dc:text-left dc:px-3 dc:py-2 dc:text-sm hover:bg-dc-surface-hover ${e.operator === a.operator ? "bg-dc-primary/10 text-dc-primary" : "text-dc-text"}`,
634
+ children: e.label
635
+ }, e.operator))
636
+ })]
637
+ })] }),
638
+ /* @__PURE__ */ G("div", { children: [/* @__PURE__ */ W("label", {
639
+ className: "dc:block dc:text-sm dc:font-medium text-dc-text-secondary dc:mb-2",
640
+ children: "Value"
641
+ }), Ee()] })
642
+ ]
643
+ }),
644
+ /* @__PURE__ */ G("div", {
645
+ className: "dc:flex dc:items-center dc:justify-end dc:gap-2 dc:p-4 dc:border-t border-dc-border",
646
+ children: [/* @__PURE__ */ W("button", {
647
+ onClick: r,
648
+ className: "dc:px-4 dc:py-2 dc:text-sm dc:font-medium text-dc-text-secondary hover:text-dc-text dc:transition-colors",
649
+ children: "Cancel"
650
+ }), /* @__PURE__ */ W("button", {
651
+ onClick: () => n(a),
652
+ className: "dc:px-4 dc:py-2 dc:text-sm dc:font-medium text-dc-primary-content bg-dc-primary hover:bg-dc-primary-hover dc:rounded dc:transition-colors",
653
+ children: "Save"
654
+ })]
655
+ })
656
+ ]
657
+ })
658
+ }) });
659
+ }
660
+ //#endregion
661
+ //#region src/client/components/AnalysisBuilder/AnalysisFilterItem.tsx
662
+ var be = c("close"), xe = c("dimension"), Se = c("timeDimension"), Ce = c("measure");
663
+ function we({ filter: e, schema: t, onRemove: n, onUpdate: r }) {
664
+ let [i, a] = H(!1), o = V(null), s = O(e.member, t), c = (s?.field.type || "string") === "time", l = s?.fieldType === "measure", u = ie(e.member, t), d = f[e.operator], p = d?.label || e.operator, m = Te(e, d), h = c ? Se : l ? Ce : xe;
665
+ return /* @__PURE__ */ G(U, { children: [/* @__PURE__ */ G("div", {
666
+ className: "dc:flex dc:items-start dc:gap-2 dc:px-2 dc:py-1.5 bg-dc-surface-secondary dc:rounded-lg dc:group hover:bg-dc-surface-tertiary dc:transition-all dc:duration-150 dc:w-full",
667
+ children: [
668
+ /* @__PURE__ */ W("span", {
669
+ className: `dc:w-6 dc:h-6 dc:flex dc:items-center dc:justify-center dc:rounded ${c ? "bg-dc-time-dimension" : l ? "bg-dc-measure" : "bg-dc-dimension"} ${c ? "text-dc-time-dimension-text" : l ? "text-dc-measure-text" : "text-dc-dimension-text"} dc:flex-shrink-0 dc:mt-0.5`,
670
+ children: h && /* @__PURE__ */ W(h, { className: "dc:w-4 dc:h-4" })
671
+ }),
672
+ /* @__PURE__ */ W("button", {
673
+ ref: o,
674
+ onClick: () => a(!0),
675
+ className: "dc:flex-1 dc:min-w-0 dc:text-left",
676
+ title: `${u} ${p} ${m}`,
677
+ children: /* @__PURE__ */ G("div", {
678
+ className: "dc:text-sm text-dc-text dc:break-words",
679
+ children: [
680
+ /* @__PURE__ */ W("span", {
681
+ className: "dc:font-medium",
682
+ children: u
683
+ }),
684
+ /* @__PURE__ */ W("span", {
685
+ className: "text-dc-text-muted dc:mx-1",
686
+ children: p
687
+ }),
688
+ /* @__PURE__ */ W("span", {
689
+ className: "text-dc-primary",
690
+ children: m
691
+ })
692
+ ]
693
+ })
694
+ }),
695
+ /* @__PURE__ */ W("button", {
696
+ onClick: n,
697
+ className: "dc:p-1 text-dc-text-muted hover:text-dc-danger dc:opacity-100 dc:sm:opacity-0 dc:sm:group-hover:opacity-100 dc:transition-opacity dc:flex-shrink-0 dc:mt-0.5",
698
+ title: "Remove filter",
699
+ children: be && /* @__PURE__ */ W(be, { className: "dc:w-4 dc:h-4" })
700
+ })
701
+ ]
702
+ }), i && /* @__PURE__ */ W(ye, {
703
+ filter: e,
704
+ schema: t,
705
+ onSave: (e) => {
706
+ r(e), a(!1);
707
+ },
708
+ onCancel: () => a(!1),
709
+ anchorElement: o.current
710
+ })] });
711
+ }
712
+ function Te(e, t) {
713
+ if (!t?.requiresValues) return "";
714
+ if (e.dateRange) return Array.isArray(e.dateRange) ? `${e.dateRange[0]} to ${e.dateRange[1]}` : e.dateRange;
715
+ let n = e.values || [];
716
+ return n.length === 0 ? "(empty)" : n.length === 1 ? String(n[0]) : n.length === 2 ? `${n[0]}, ${n[1]}` : `${n[0]}, ${n[1]}, +${n.length - 2} more`;
717
+ }
718
+ //#endregion
719
+ //#region src/client/components/AnalysisBuilder/AnalysisFilterGroup.tsx
720
+ var Ee = c("add"), De = c("close");
721
+ function Oe(e) {
722
+ return "member" in e && typeof e.member == "string";
723
+ }
724
+ function ke(e) {
725
+ return "type" in e && (e.type === "and" || e.type === "or");
726
+ }
727
+ function Ae({ group: e, schema: t, onUpdate: n, onRemove: r, onAddFilter: i, depth: a = 0, hideRemoveButton: o = !1 }) {
728
+ let [s, c] = H(!1), l = V(null);
729
+ z(() => {
730
+ let e = (e) => {
731
+ l.current && !l.current.contains(e.target) && c(!1);
732
+ };
733
+ return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
734
+ }, []);
735
+ let u = R(() => {
736
+ let t = e.type === "and" ? "or" : "and";
737
+ n({
738
+ ...e,
739
+ type: t
740
+ });
741
+ }, [e, n]), d = R((t, r) => {
742
+ let i = [...e.filters];
743
+ i[t] = r, n({
744
+ ...e,
745
+ filters: i
746
+ });
747
+ }, [e, n]), f = R((t) => {
748
+ let i = e.filters.filter((e, n) => n !== t);
749
+ i.length === 0 ? r() : n({
750
+ ...e,
751
+ filters: i
752
+ });
753
+ }, [
754
+ e,
755
+ n,
756
+ r,
757
+ a
758
+ ]), p = R((t) => {
759
+ let r = {
760
+ type: t,
761
+ filters: []
762
+ };
763
+ n({
764
+ ...e,
765
+ filters: [...e.filters, r]
766
+ }), c(!1);
767
+ }, [e, n]), m = R(() => {
768
+ i([]), c(!1);
769
+ }, [i]), h = R((e) => (t = []) => {
770
+ i([e, ...t]);
771
+ }, [i]), g = () => a % 2 == 0 ? "border-dc-border" : "border-dc-border dark:border-dc-border", _ = () => e.type === "and" ? "bg-dc-info-bg/50" : "bg-dc-warning-bg/50", v = e.filters.length, y = v === 1 ? "condition" : "conditions";
772
+ return /* @__PURE__ */ G("div", {
773
+ className: `dc:border ${g()} dc:rounded-lg bg-dc-surface dc:w-full`,
774
+ children: [/* @__PURE__ */ G("div", {
775
+ className: `dc:flex dc:items-center dc:justify-between dc:px-2 dc:py-1.5 dc:border-b border-dc-border/50 dc:rounded-t-lg ${_()}`,
776
+ children: [/* @__PURE__ */ G("div", {
777
+ className: "dc:flex dc:items-center dc:gap-2",
778
+ children: [/* @__PURE__ */ W("button", {
779
+ onClick: u,
780
+ className: `dc:px-2 dc:py-0.5 dc:text-xs dc:font-semibold dc:rounded dc:transition-colors ${e.type === "and" ? "bg-dc-info-bg text-dc-info dc:hover:opacity-80" : "bg-dc-warning-bg text-dc-warning dc:hover:opacity-80"}`,
781
+ title: `Click to switch to ${e.type === "and" ? "OR" : "AND"}`,
782
+ children: e.type.toUpperCase()
783
+ }), /* @__PURE__ */ G("span", {
784
+ className: "dc:text-xs text-dc-text-muted",
785
+ children: [
786
+ v,
787
+ " ",
788
+ y
789
+ ]
790
+ })]
791
+ }), /* @__PURE__ */ G("div", {
792
+ className: "dc:flex dc:items-center dc:gap-1",
793
+ children: [/* @__PURE__ */ G("div", {
794
+ className: "dc:relative",
795
+ ref: l,
796
+ children: [/* @__PURE__ */ W("button", {
797
+ onClick: () => c(!s),
798
+ className: "dc:p-1 text-dc-text-secondary hover:text-dc-primary hover:bg-dc-surface-hover dc:rounded dc:transition-colors",
799
+ title: "Add condition",
800
+ children: /* @__PURE__ */ W(Ee, { className: "dc:w-4 dc:h-4" })
801
+ }), s && /* @__PURE__ */ G("div", {
802
+ className: "dc:absolute dc:right-0 dc:mt-1 dc:z-40 bg-dc-surface dc:border border-dc-border dc:rounded dc:shadow-lg dc:py-1 dc:min-w-[120px]",
803
+ children: [
804
+ /* @__PURE__ */ W("button", {
805
+ onClick: m,
806
+ className: "dc:w-full dc:text-left dc:px-3 dc:py-1.5 dc:text-xs text-dc-text hover:bg-dc-surface-hover",
807
+ children: "Add Filter"
808
+ }),
809
+ /* @__PURE__ */ W("button", {
810
+ onClick: () => p("and"),
811
+ className: "dc:w-full dc:text-left dc:px-3 dc:py-1.5 dc:text-xs text-dc-text hover:bg-dc-surface-hover",
812
+ children: "Add AND Group"
813
+ }),
814
+ /* @__PURE__ */ W("button", {
815
+ onClick: () => p("or"),
816
+ className: "dc:w-full dc:text-left dc:px-3 dc:py-1.5 dc:text-xs text-dc-text hover:bg-dc-surface-hover",
817
+ children: "Add OR Group"
818
+ })
819
+ ]
820
+ })]
821
+ }), !o && /* @__PURE__ */ W("button", {
822
+ onClick: r,
823
+ className: "dc:p-1 text-dc-text-muted hover:text-dc-danger dc:transition-colors",
824
+ title: "Remove group",
825
+ children: /* @__PURE__ */ W(De, { className: "dc:w-4 dc:h-4" })
826
+ })]
827
+ })]
828
+ }), /* @__PURE__ */ W("div", {
829
+ className: "dc:p-1.5 dc:flex dc:flex-wrap dc:gap-2",
830
+ children: e.filters.length === 0 ? /* @__PURE__ */ G("div", {
831
+ className: "dc:text-center dc:py-3",
832
+ children: [/* @__PURE__ */ W("p", {
833
+ className: "dc:text-xs text-dc-text-muted dc:mb-1",
834
+ children: "No conditions in this group"
835
+ }), /* @__PURE__ */ W("button", {
836
+ onClick: () => i([]),
837
+ className: "dc:text-xs text-dc-primary dc:hover:underline",
838
+ children: "Add a filter"
839
+ })]
840
+ }) : e.filters.map((e, n) => Oe(e) ? /* @__PURE__ */ W(we, {
841
+ filter: e,
842
+ schema: t,
843
+ onUpdate: (e) => d(n, e),
844
+ onRemove: () => f(n)
845
+ }, `filter-${n}`) : ke(e) ? /* @__PURE__ */ W(Ae, {
846
+ group: e,
847
+ schema: t,
848
+ onUpdate: (e) => d(n, e),
849
+ onRemove: () => f(n),
850
+ onAddFilter: h(n),
851
+ depth: a + 1
852
+ }, `group-${n}`) : null)
853
+ })]
854
+ });
855
+ }
856
+ //#endregion
857
+ //#region src/client/components/AnalysisBuilder/AnalysisFilterSection.tsx
858
+ var je = c("add");
859
+ function Me(e) {
860
+ return "member" in e && typeof e.member == "string";
861
+ }
862
+ function Ne(e) {
863
+ return "type" in e && (e.type === "and" || e.type === "or");
864
+ }
865
+ function Pe(e) {
866
+ let t = 0;
867
+ for (let n of e) Me(n) ? t++ : Ne(n) && (t += Pe(n.filters));
868
+ return t;
869
+ }
870
+ function Fe(e) {
871
+ let t = [];
872
+ for (let n of e) Me(n) ? t.push(n.member) : Ne(n) && t.push(...Fe(n.filters));
873
+ return t;
874
+ }
875
+ function Ie(e, t, n) {
876
+ if (t.length === 0) return e.length === 0 ? [n] : e.length === 1 && Me(e[0]) ? [{
877
+ type: "and",
878
+ filters: [e[0], n]
879
+ }] : e.length === 1 && Ne(e[0]) ? [{
880
+ ...e[0],
881
+ filters: [...e[0].filters, n]
882
+ }] : [{
883
+ type: "and",
884
+ filters: [...e, n]
885
+ }];
886
+ let [r, ...i] = t, a = [...e], o = a[r];
887
+ return Ne(o) && (i.length === 0 ? a[r] = {
888
+ ...o,
889
+ filters: [...o.filters, n]
890
+ } : a[r] = {
891
+ ...o,
892
+ filters: Ie(o.filters, i, n)
893
+ }), a;
894
+ }
895
+ function Le({ filters: e, schema: t, onFiltersChange: n, onFieldDropped: r, dimensionsOnly: i = !1 }) {
896
+ let [a, o] = H(!1), [s, c] = H(!1), u = V([]), d = Pe(e), f = R((e) => {
897
+ e.preventDefault(), e.stopPropagation(), c(!0);
898
+ }, []), p = R((e) => {
899
+ e.preventDefault(), e.stopPropagation(), c(!1);
900
+ }, []), m = R((e) => {
901
+ e.preventDefault(), e.stopPropagation(), c(!1);
902
+ try {
903
+ let t = JSON.parse(e.dataTransfer.getData("text/plain"));
904
+ t.field && r && r(t.field);
905
+ } catch {}
906
+ }, [r]), h = Fe(e), g = R((t, r, i) => {
907
+ let a = t.type === "time", s = a ? "inDateRange" : "equals", c = {
908
+ member: t.name,
909
+ operator: s,
910
+ values: []
911
+ };
912
+ a && s === "inDateRange" && (c.dateRange = l("this_month")), n(Ie(e, u.current, c)), o(!1), u.current = [];
913
+ }, [e, n]), _ = R((t, r) => {
914
+ let i = [...e];
915
+ i[t] = r, n(i);
916
+ }, [e, n]), v = R((t) => {
917
+ let r = e.filter((e, n) => n !== t);
918
+ if (r.length === 1 && Ne(r[0])) {
919
+ let e = r[0];
920
+ if (e.filters.length === 1) {
921
+ n([e.filters[0]]);
922
+ return;
923
+ }
924
+ }
925
+ n(r);
926
+ }, [e, n]), y = R(() => {
927
+ n([]);
928
+ }, [n]), b = R(() => {
929
+ u.current = [], o(!0);
930
+ }, []), x = R((e) => (t = []) => {
931
+ u.current = [...e, ...t], o(!0);
932
+ }, []), ee = (n, r, i = []) => {
933
+ let a = [...i, r];
934
+ return Me(n) ? /* @__PURE__ */ W(we, {
935
+ filter: n,
936
+ schema: t,
937
+ onUpdate: (e) => _(r, e),
938
+ onRemove: () => v(r)
939
+ }, `filter-${a.join("-")}`) : Ne(n) ? /* @__PURE__ */ W(Ae, {
940
+ group: n,
941
+ schema: t,
942
+ onUpdate: (e) => _(r, e),
943
+ onRemove: () => v(r),
944
+ onAddFilter: x(a),
945
+ hideRemoveButton: e.length === 1
946
+ }, `group-${a.join("-")}`) : null;
947
+ };
948
+ return /* @__PURE__ */ G("div", { children: [
949
+ /* @__PURE__ */ G("button", {
950
+ onClick: b,
951
+ className: "dc:flex dc:items-center dc:justify-between dc:mb-3 dc:w-full dc:py-1 dc:px-2 dc:-ml-2 dc:rounded-lg hover:bg-dc-primary/10 dc:transition-colors dc:group",
952
+ title: "Add filter",
953
+ children: [/* @__PURE__ */ G(oe, { children: ["Filter", d > 0 && /* @__PURE__ */ G("span", {
954
+ className: "dc:ml-1.5 dc:text-xs dc:font-normal text-dc-text-muted dc:normal-case dc:tracking-normal",
955
+ children: [
956
+ "(",
957
+ d,
958
+ ")"
959
+ ]
960
+ })] }), /* @__PURE__ */ G("div", {
961
+ className: "dc:flex dc:items-center dc:gap-2",
962
+ children: [d > 0 && /* @__PURE__ */ W("span", {
963
+ role: "button",
964
+ tabIndex: 0,
965
+ onClick: (e) => {
966
+ e.stopPropagation(), y();
967
+ },
968
+ onKeyDown: (e) => {
969
+ (e.key === "Enter" || e.key === " ") && (e.stopPropagation(), y());
970
+ },
971
+ className: "dc:text-xs text-dc-text-muted hover:text-dc-error dc:underline dc:cursor-pointer",
972
+ children: "Clear all"
973
+ }), /* @__PURE__ */ W(je, { className: "dc:w-5 dc:h-5 text-dc-text-secondary group-hover:text-dc-primary dc:transition-colors" })]
974
+ })]
975
+ }),
976
+ /* @__PURE__ */ W("div", {
977
+ onDragOver: r ? f : void 0,
978
+ onDragLeave: r ? p : void 0,
979
+ onDrop: r ? m : void 0,
980
+ className: `dc:p-2 dc:-mx-2 dc:rounded-lg dc:border-2 dc:border-dashed dc:transition-all ${s ? "border-dc-primary bg-dc-primary/5" : "border-transparent"}`,
981
+ children: e.length === 0 ? /* @__PURE__ */ W("p", {
982
+ className: `dc:text-sm ${s ? "text-dc-primary dc:font-medium" : "text-dc-text-muted"}`,
983
+ children: s ? "Drop to add filter" : "No filters applied"
984
+ }) : /* @__PURE__ */ W("div", {
985
+ className: "dc:flex dc:flex-wrap dc:gap-2",
986
+ children: e.map((e, t) => ee(e, t))
987
+ })
988
+ }),
989
+ /* @__PURE__ */ W(ae, {
990
+ isOpen: a,
991
+ onClose: () => {
992
+ o(!1), u.current = [];
993
+ },
994
+ onSelect: g,
995
+ mode: i ? "dimensionFilter" : "filter",
996
+ schema: t,
997
+ selectedFields: h
998
+ })
999
+ ] });
1000
+ }
1001
+ //#endregion
218
1002
  //#region src/client/shared/chartDefaults.ts
219
- function le(e) {
1003
+ function Re(e) {
220
1004
  return e.isTimeDimension;
221
1005
  }
222
- function ue(e) {
223
- return e.find(le);
1006
+ function ze(e) {
1007
+ return e.find(Re);
224
1008
  }
225
- function de(e) {
1009
+ function Be(e) {
226
1010
  return e.find((e) => !e.isTimeDimension);
227
1011
  }
228
- function fe(e) {
1012
+ function Ve(e) {
229
1013
  return e.filter((e) => !e.isTimeDimension);
230
1014
  }
231
- function pe(e) {
232
- return e.filter(le);
1015
+ function He(e) {
1016
+ return e.filter(Re);
233
1017
  }
234
- function W(e, t, n) {
235
- let r = t.length, i = fe(n).length, a = pe(n).length, o = n.length;
1018
+ function Ue(e, t, n) {
1019
+ let r = t.length, i = Ve(n).length, a = He(n).length, o = n.length;
236
1020
  switch (e) {
237
1021
  case "table":
238
1022
  case "markdown": return { available: !0 };
@@ -315,7 +1099,7 @@ function W(e, t, n) {
315
1099
  default: return { available: !0 };
316
1100
  }
317
1101
  }
318
- function me(e, t) {
1102
+ function We(e, t) {
319
1103
  let n = [
320
1104
  "activityGrid",
321
1105
  "area",
@@ -333,23 +1117,23 @@ function me(e, t) {
333
1117
  "table",
334
1118
  "treemap"
335
1119
  ], r = {};
336
- for (let i of n) r[i] = W(i, e, t);
1120
+ for (let i of n) r[i] = Ue(i, e, t);
337
1121
  return r;
338
1122
  }
339
- function he(e, t, n) {
340
- if (W(n, e, t).available || e.length === 0 && t.length === 0) return n;
341
- let r = pe(t).length > 0, i = fe(t).length > 0, a = e.length > 0;
1123
+ function Ge(e, t, n) {
1124
+ if (Ue(n, e, t).available || e.length === 0 && t.length === 0) return n;
1125
+ let r = He(t).length > 0, i = Ve(t).length > 0, a = e.length > 0;
342
1126
  return r && a ? "line" : i && a ? "bar" : a && !i && !r ? "kpiNumber" : "table";
343
1127
  }
344
- function ge(e, t, n) {
345
- let r = he(e, t, n);
1128
+ function Ke(e, t, n) {
1129
+ let r = Ge(e, t, n);
346
1130
  return {
347
1131
  chartType: r,
348
- chartConfig: _e(r, e, t)
1132
+ chartConfig: qe(r, e, t)
349
1133
  };
350
1134
  }
351
- function _e(e, t, n) {
352
- let r = ue(n), i = de(n), a = fe(n), o = n;
1135
+ function qe(e, t, n) {
1136
+ let r = ze(n), i = Be(n), a = Ve(n), o = n;
353
1137
  switch (e) {
354
1138
  case "line":
355
1139
  case "area": return {
@@ -402,35 +1186,35 @@ function _e(e, t, n) {
402
1186
  };
403
1187
  }
404
1188
  }
405
- function ve(e, t, n, r) {
406
- if (r && W(n, e, t).available) return null;
407
- let i = he(e, t, n);
1189
+ function Je(e, t, n, r) {
1190
+ if (r && Ue(n, e, t).available) return null;
1191
+ let i = Ge(e, t, n);
408
1192
  return i === n ? null : i;
409
1193
  }
410
1194
  //#endregion
411
1195
  //#region src/client/components/AnalysisBuilder/ExplainAIPanel.tsx
412
- function G(e) {
1196
+ function Ye(e) {
413
1197
  return typeof e == "string" ? e : typeof e == "object" && e ? JSON.stringify(e) : String(e ?? "");
414
1198
  }
415
- var ye = {
1199
+ var Xe = {
416
1200
  good: "bg-dc-success-bg text-dc-success border-dc-success",
417
1201
  warning: "bg-dc-warning-bg text-dc-warning border-dc-warning",
418
1202
  critical: "bg-dc-danger-bg text-dc-error border-dc-error"
419
- }, K = {
1203
+ }, Ze = {
420
1204
  critical: "bg-dc-danger-bg text-dc-error",
421
1205
  warning: "bg-dc-warning-bg text-dc-warning",
422
1206
  suggestion: "bg-dc-accent-bg text-dc-accent"
423
- }, q = {
1207
+ }, Qe = {
424
1208
  high: "text-dc-error",
425
1209
  medium: "text-dc-warning",
426
1210
  low: "text-dc-text-muted"
427
1211
  };
428
- function J({ assessment: e, reason: t }) {
429
- return /* @__PURE__ */ V("div", {
430
- className: `dc:p-4 dc:rounded-lg dc:border ${ye[e]}`,
431
- children: [/* @__PURE__ */ B("div", {
1212
+ function $e({ assessment: e, reason: t }) {
1213
+ return /* @__PURE__ */ G("div", {
1214
+ className: `dc:p-4 dc:rounded-lg dc:border ${Xe[e]}`,
1215
+ children: [/* @__PURE__ */ W("div", {
432
1216
  className: "dc:flex dc:items-center dc:gap-2 dc:mb-1",
433
- children: /* @__PURE__ */ V("span", {
1217
+ children: /* @__PURE__ */ G("span", {
434
1218
  className: "dc:font-semibold dc:uppercase dc:text-base",
435
1219
  children: [
436
1220
  e === "good" && "✓ ",
@@ -443,33 +1227,33 @@ function J({ assessment: e, reason: t }) {
443
1227
  }[e]
444
1228
  ]
445
1229
  })
446
- }), /* @__PURE__ */ B("p", {
1230
+ }), /* @__PURE__ */ W("p", {
447
1231
  className: "dc:text-sm",
448
- children: G(t)
1232
+ children: Ye(t)
449
1233
  })]
450
1234
  });
451
1235
  }
452
- function be({ issue: e }) {
453
- return /* @__PURE__ */ V("div", {
1236
+ function et({ issue: e }) {
1237
+ return /* @__PURE__ */ G("div", {
454
1238
  className: "dc:flex dc:items-start dc:gap-2 dc:py-2",
455
- children: [/* @__PURE__ */ V("span", {
456
- className: `dc:text-sm ${q[e.severity]}`,
1239
+ children: [/* @__PURE__ */ G("span", {
1240
+ className: `dc:text-sm ${Qe[e.severity]}`,
457
1241
  children: [
458
1242
  e.severity === "high" && "●",
459
1243
  e.severity === "medium" && "○",
460
1244
  e.severity === "low" && "○"
461
1245
  ]
462
- }), /* @__PURE__ */ B("span", {
1246
+ }), /* @__PURE__ */ W("span", {
463
1247
  className: "dc:text-sm text-dc-text-secondary",
464
- children: G(e.description)
1248
+ children: Ye(e.description)
465
1249
  })]
466
1250
  });
467
1251
  }
468
- function xe({ text: e }) {
469
- let [t, n] = j.useState(!1), r = j.useRef(null);
470
- return j.useEffect(() => () => {
1252
+ function tt({ text: e }) {
1253
+ let [t, n] = I.useState(!1), r = I.useRef(null);
1254
+ return I.useEffect(() => () => {
471
1255
  r.current && clearTimeout(r.current);
472
- }, []), /* @__PURE__ */ B("button", {
1256
+ }, []), /* @__PURE__ */ W("button", {
473
1257
  onClick: async () => {
474
1258
  try {
475
1259
  await navigator.clipboard.writeText(e), n(!0), r.current && clearTimeout(r.current), r.current = setTimeout(() => n(!1), 2e3);
@@ -482,110 +1266,110 @@ function xe({ text: e }) {
482
1266
  children: t ? "Copied!" : "Copy"
483
1267
  });
484
1268
  }
485
- function Se({ rec: e }) {
486
- return /* @__PURE__ */ V("div", {
1269
+ function nt({ rec: e }) {
1270
+ return /* @__PURE__ */ G("div", {
487
1271
  className: "dc:p-4 dc:border border-dc-border dc:rounded-lg bg-dc-surface",
488
1272
  children: [
489
- /* @__PURE__ */ V("div", {
1273
+ /* @__PURE__ */ G("div", {
490
1274
  className: "dc:flex dc:items-center dc:gap-2 dc:mb-2",
491
- children: [/* @__PURE__ */ B("span", {
492
- className: `dc:px-2 dc:py-0.5 dc:text-xs dc:font-medium dc:rounded ${K[e.severity]}`,
1275
+ children: [/* @__PURE__ */ W("span", {
1276
+ className: `dc:px-2 dc:py-0.5 dc:text-xs dc:font-medium dc:rounded ${Ze[e.severity]}`,
493
1277
  children: {
494
1278
  index: "INDEX",
495
1279
  table: "TABLE",
496
1280
  cube: "CUBE",
497
1281
  general: "TIP"
498
1282
  }[e.type]
499
- }), /* @__PURE__ */ B("h5", {
1283
+ }), /* @__PURE__ */ W("h5", {
500
1284
  className: "dc:font-medium text-dc-text",
501
- children: G(e.title)
1285
+ children: Ye(e.title)
502
1286
  })]
503
1287
  }),
504
- /* @__PURE__ */ B("p", {
1288
+ /* @__PURE__ */ W("p", {
505
1289
  className: "dc:text-sm text-dc-text-secondary dc:mb-3",
506
- children: G(e.description)
1290
+ children: Ye(e.description)
507
1291
  }),
508
- e.sql && /* @__PURE__ */ B("div", {
1292
+ e.sql && /* @__PURE__ */ W("div", {
509
1293
  className: "dc:mt-2",
510
- children: /* @__PURE__ */ B(D, {
1294
+ children: /* @__PURE__ */ W(j, {
511
1295
  code: e.sql,
512
1296
  language: "sql",
513
- headerRight: /* @__PURE__ */ B(xe, { text: e.sql })
1297
+ headerRight: /* @__PURE__ */ W(tt, { text: e.sql })
514
1298
  })
515
1299
  }),
516
- e.cubeCode && /* @__PURE__ */ V("div", {
1300
+ e.cubeCode && /* @__PURE__ */ G("div", {
517
1301
  className: "dc:mt-2",
518
- children: [e.cubeName && /* @__PURE__ */ V("p", {
1302
+ children: [e.cubeName && /* @__PURE__ */ G("p", {
519
1303
  className: "dc:text-xs text-dc-text-muted dc:mb-1",
520
1304
  children: [
521
1305
  "Add to ",
522
- /* @__PURE__ */ B("code", {
1306
+ /* @__PURE__ */ W("code", {
523
1307
  className: "bg-dc-surface-secondary dc:px-1 dc:rounded",
524
1308
  children: e.cubeName
525
1309
  }),
526
1310
  " cube:"
527
1311
  ]
528
- }), /* @__PURE__ */ V("div", {
1312
+ }), /* @__PURE__ */ G("div", {
529
1313
  className: "dc:relative",
530
- children: [/* @__PURE__ */ B("pre", {
1314
+ children: [/* @__PURE__ */ W("pre", {
531
1315
  className: "dc:p-3 dc:text-xs bg-dc-surface-secondary dc:rounded dc:overflow-x-auto dc:font-mono text-dc-text",
532
1316
  children: e.cubeCode
533
- }), /* @__PURE__ */ B("div", {
1317
+ }), /* @__PURE__ */ W("div", {
534
1318
  className: "dc:absolute dc:top-1 dc:right-1",
535
- children: /* @__PURE__ */ B(xe, { text: e.cubeCode })
1319
+ children: /* @__PURE__ */ W(tt, { text: e.cubeCode })
536
1320
  })]
537
1321
  })]
538
1322
  }),
539
- e.estimatedImpact && /* @__PURE__ */ V("p", {
1323
+ e.estimatedImpact && /* @__PURE__ */ G("p", {
540
1324
  className: "dc:text-xs text-dc-text-muted dc:mt-2",
541
1325
  children: [
542
- /* @__PURE__ */ B("strong", { children: "Expected impact:" }),
1326
+ /* @__PURE__ */ W("strong", { children: "Expected impact:" }),
543
1327
  " ",
544
- G(e.estimatedImpact)
1328
+ Ye(e.estimatedImpact)
545
1329
  ]
546
1330
  })
547
1331
  ]
548
1332
  });
549
1333
  }
550
- function Ce({ analysis: e, onClose: t, onClear: n }) {
1334
+ function rt({ analysis: e, onClose: t, onClear: n }) {
551
1335
  let r = t || n;
552
- return j.useEffect(() => {
1336
+ return I.useEffect(() => {
553
1337
  let e = (e) => {
554
1338
  e.key === "Escape" && r && r();
555
1339
  };
556
1340
  return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
557
- }, [r]), j.useEffect(() => (document.body.style.overflow = "hidden", () => {
1341
+ }, [r]), I.useEffect(() => (document.body.style.overflow = "hidden", () => {
558
1342
  document.body.style.overflow = "";
559
- }), []), /* @__PURE__ */ V("div", {
1343
+ }), []), /* @__PURE__ */ G("div", {
560
1344
  className: "dc:fixed dc:inset-0 dc:z-50 dc:flex dc:items-center dc:justify-center dc:p-4 bg-black/50",
561
- children: [/* @__PURE__ */ B("div", {
1345
+ children: [/* @__PURE__ */ W("div", {
562
1346
  className: "dc:absolute dc:inset-0",
563
1347
  onClick: r,
564
1348
  "aria-hidden": "true"
565
- }), /* @__PURE__ */ V("div", {
1349
+ }), /* @__PURE__ */ G("div", {
566
1350
  className: "dc:relative dc:w-full dc:max-w-4xl dc:max-h-[90vh] bg-dc-surface dc:rounded-lg dc:shadow-xl dc:flex dc:flex-col",
567
1351
  children: [
568
- /* @__PURE__ */ V("div", {
1352
+ /* @__PURE__ */ G("div", {
569
1353
  className: "dc:flex dc:items-center dc:justify-between dc:px-6 dc:py-4 dc:border-b border-dc-border dc:flex-shrink-0",
570
- children: [/* @__PURE__ */ V("div", {
1354
+ children: [/* @__PURE__ */ G("div", {
571
1355
  className: "dc:flex dc:items-center dc:gap-3",
572
- children: [/* @__PURE__ */ B("span", {
1356
+ children: [/* @__PURE__ */ W("span", {
573
1357
  className: "dc:text-lg",
574
1358
  children: "✨"
575
- }), /* @__PURE__ */ B("h3", {
1359
+ }), /* @__PURE__ */ W("h3", {
576
1360
  className: "dc:text-lg dc:font-semibold text-dc-text",
577
1361
  children: "AI Performance Analysis"
578
1362
  })]
579
- }), /* @__PURE__ */ B("button", {
1363
+ }), /* @__PURE__ */ W("button", {
580
1364
  onClick: r,
581
1365
  className: "dc:p-2 dc:rounded-lg hover:bg-dc-surface-hover text-dc-text-secondary hover:text-dc-text dc:transition-colors",
582
1366
  "aria-label": "Close",
583
- children: /* @__PURE__ */ B("svg", {
1367
+ children: /* @__PURE__ */ W("svg", {
584
1368
  className: "dc:w-5 dc:h-5",
585
1369
  fill: "none",
586
1370
  stroke: "currentColor",
587
1371
  viewBox: "0 0 24 24",
588
- children: /* @__PURE__ */ B("path", {
1372
+ children: /* @__PURE__ */ W("path", {
589
1373
  strokeLinecap: "round",
590
1374
  strokeLinejoin: "round",
591
1375
  strokeWidth: 2,
@@ -594,65 +1378,65 @@ function Ce({ analysis: e, onClose: t, onClear: n }) {
594
1378
  })
595
1379
  })]
596
1380
  }),
597
- /* @__PURE__ */ V("div", {
1381
+ /* @__PURE__ */ G("div", {
598
1382
  className: "dc:flex-1 dc:overflow-y-auto dc:px-6 dc:py-4 dc:space-y-6",
599
1383
  children: [
600
- /* @__PURE__ */ B(J, {
1384
+ /* @__PURE__ */ W($e, {
601
1385
  assessment: e.assessment,
602
1386
  reason: e.assessmentReason
603
1387
  }),
604
- /* @__PURE__ */ V("div", { children: [/* @__PURE__ */ B("h4", {
1388
+ /* @__PURE__ */ G("div", { children: [/* @__PURE__ */ W("h4", {
605
1389
  className: "dc:text-sm dc:font-semibold text-dc-text-muted dc:uppercase dc:mb-2",
606
1390
  children: "Summary"
607
- }), /* @__PURE__ */ B("p", {
1391
+ }), /* @__PURE__ */ W("p", {
608
1392
  className: "text-dc-text",
609
- children: G(e.summary)
1393
+ children: Ye(e.summary)
610
1394
  })] }),
611
- e.queryUnderstanding && /* @__PURE__ */ V("div", { children: [/* @__PURE__ */ B("h4", {
1395
+ e.queryUnderstanding && /* @__PURE__ */ G("div", { children: [/* @__PURE__ */ W("h4", {
612
1396
  className: "dc:text-sm dc:font-semibold text-dc-text-muted dc:uppercase dc:mb-2",
613
1397
  children: "Query Analysis"
614
- }), /* @__PURE__ */ B("p", {
1398
+ }), /* @__PURE__ */ W("p", {
615
1399
  className: "text-dc-text-secondary",
616
- children: G(e.queryUnderstanding)
1400
+ children: Ye(e.queryUnderstanding)
617
1401
  })] }),
618
- e.issues && e.issues.length > 0 && /* @__PURE__ */ V("div", { children: [/* @__PURE__ */ V("h4", {
1402
+ e.issues && e.issues.length > 0 && /* @__PURE__ */ G("div", { children: [/* @__PURE__ */ G("h4", {
619
1403
  className: "dc:text-sm dc:font-semibold text-dc-text-muted dc:uppercase dc:mb-2",
620
1404
  children: [
621
1405
  "Issues Found (",
622
1406
  e.issues.length,
623
1407
  ")"
624
1408
  ]
625
- }), /* @__PURE__ */ B("div", {
1409
+ }), /* @__PURE__ */ W("div", {
626
1410
  className: "dc:space-y-1 bg-dc-surface-secondary dc:rounded-lg dc:p-3",
627
- children: e.issues.map((e, t) => /* @__PURE__ */ B(be, { issue: e }, t))
1411
+ children: e.issues.map((e, t) => /* @__PURE__ */ W(et, { issue: e }, t))
628
1412
  })] }),
629
- e.recommendations && e.recommendations.length > 0 && /* @__PURE__ */ V("div", { children: [/* @__PURE__ */ V("h4", {
1413
+ e.recommendations && e.recommendations.length > 0 && /* @__PURE__ */ G("div", { children: [/* @__PURE__ */ G("h4", {
630
1414
  className: "dc:text-sm dc:font-semibold text-dc-text-muted dc:uppercase dc:mb-3",
631
1415
  children: [
632
1416
  "Recommendations (",
633
1417
  e.recommendations.length,
634
1418
  ")"
635
1419
  ]
636
- }), /* @__PURE__ */ B("div", {
1420
+ }), /* @__PURE__ */ W("div", {
637
1421
  className: "dc:space-y-4",
638
- children: e.recommendations.map((e, t) => /* @__PURE__ */ B(Se, { rec: e }, t))
1422
+ children: e.recommendations.map((e, t) => /* @__PURE__ */ W(nt, { rec: e }, t))
639
1423
  })] }),
640
- (!e.recommendations || e.recommendations.length === 0) && /* @__PURE__ */ B("div", {
1424
+ (!e.recommendations || e.recommendations.length === 0) && /* @__PURE__ */ W("div", {
641
1425
  className: "text-dc-text-muted dc:italic dc:p-4 bg-dc-surface-secondary dc:rounded-lg",
642
1426
  children: "No specific recommendations. The query appears to be well-optimized."
643
1427
  })
644
1428
  ]
645
1429
  }),
646
- /* @__PURE__ */ V("div", {
1430
+ /* @__PURE__ */ G("div", {
647
1431
  className: "dc:flex dc:items-center dc:justify-between dc:px-6 dc:py-3 dc:border-t border-dc-border dc:flex-shrink-0 bg-dc-surface-secondary",
648
- children: [e._meta && /* @__PURE__ */ V("div", {
1432
+ children: [e._meta && /* @__PURE__ */ G("div", {
649
1433
  className: "dc:text-xs text-dc-text-muted",
650
1434
  children: [
651
1435
  "Model: ",
652
1436
  e._meta.model,
653
1437
  e._meta.usingUserKey && " (using your API key)"
654
1438
  ]
655
- }), /* @__PURE__ */ B("button", {
1439
+ }), /* @__PURE__ */ W("button", {
656
1440
  onClick: r,
657
1441
  className: "dc:px-4 dc:py-2 dc:text-sm dc:font-medium dc:rounded-lg bg-dc-primary text-white hover:bg-dc-primary-hover dc:transition-colors",
658
1442
  children: "Close"
@@ -664,93 +1448,93 @@ function Ce({ analysis: e, onClose: t, onClear: n }) {
664
1448
  }
665
1449
  //#endregion
666
1450
  //#region src/client/components/AnalysisBuilder/ExecutionPlanPanel.tsx
667
- var we = N(function({ sql: e, sqlLoading: t = !1, sqlError: n, sqlPlaceholder: r = "Add metrics to generate SQL", explainResult: i, explainLoading: a = !1, explainHasRun: o = !1, explainError: s, runExplain: c, aiAnalysis: l, aiAnalysisLoading: u = !1, aiAnalysisError: d, runAIAnalysis: f, clearAIAnalysis: p, enableAI: m = !1, query: h, title: g = "Generated SQL", height: _ = "16rem" }) {
668
- let [v, y] = R(!1), [b, x] = R(!1), S = e ? e.sql + (e.params && e.params.length > 0 ? "\n\n-- Parameters:\n" + JSON.stringify(e.params, null, 2) : "") : "", C = () => {
1451
+ var it = L(function({ sql: e, sqlLoading: t = !1, sqlError: n, sqlPlaceholder: r = "Add metrics to generate SQL", explainResult: i, explainLoading: a = !1, explainHasRun: o = !1, explainError: s, runExplain: c, aiAnalysis: l, aiAnalysisLoading: u = !1, aiAnalysisError: d, runAIAnalysis: f, clearAIAnalysis: p, enableAI: m = !1, query: h, title: g = "Generated SQL", height: _ = "16rem" }) {
1452
+ let [v, y] = H(!1), [b, x] = H(!1), ee = e ? e.sql + (e.params && e.params.length > 0 ? "\n\n-- Parameters:\n" + JSON.stringify(e.params, null, 2) : "") : "", te = () => {
669
1453
  f && i && h && (f(i, h), x(!0));
670
- }, w = () => {
1454
+ }, S = () => {
671
1455
  x(!1);
672
- }, T = m && i ? /* @__PURE__ */ B("button", {
673
- onClick: C,
1456
+ }, ne = m && i ? /* @__PURE__ */ W("button", {
1457
+ onClick: te,
674
1458
  disabled: u,
675
1459
  className: "dc:px-2 dc:py-1 dc:text-xs dc:font-medium dc:rounded bg-dc-accent text-white hover:bg-dc-accent-hover dc:disabled:opacity-50 dc:disabled:cursor-not-allowed dc:flex dc:items-center dc:gap-1",
676
- children: u ? /* @__PURE__ */ V(z, { children: [/* @__PURE__ */ B("span", {
1460
+ children: u ? /* @__PURE__ */ G(U, { children: [/* @__PURE__ */ W("span", {
677
1461
  className: "dc:animate-spin",
678
1462
  children: "⟳"
679
- }), "Analyzing..."] }) : /* @__PURE__ */ B(z, { children: "✨ AI Analysis" })
1463
+ }), "Analyzing..."] }) : /* @__PURE__ */ W(U, { children: "✨ AI Analysis" })
680
1464
  }) : null;
681
- return /* @__PURE__ */ V("div", {
1465
+ return /* @__PURE__ */ G("div", {
682
1466
  className: "dc:space-y-3",
683
1467
  children: [
684
- t ? /* @__PURE__ */ V(z, { children: [/* @__PURE__ */ B("h4", {
1468
+ t ? /* @__PURE__ */ G(U, { children: [/* @__PURE__ */ W("h4", {
685
1469
  className: "dc:text-sm dc:font-semibold text-dc-text dc:mb-2",
686
1470
  children: g
687
- }), /* @__PURE__ */ B("div", {
1471
+ }), /* @__PURE__ */ W("div", {
688
1472
  className: "bg-dc-surface-secondary dc:border border-dc-border dc:rounded dc:p-3 text-dc-text-muted dc:text-sm dc:animate-pulse",
689
1473
  style: { height: _ },
690
1474
  children: "Loading SQL..."
691
- })] }) : n ? /* @__PURE__ */ V(z, { children: [/* @__PURE__ */ B("h4", {
1475
+ })] }) : n ? /* @__PURE__ */ G(U, { children: [/* @__PURE__ */ W("h4", {
692
1476
  className: "dc:text-sm dc:font-semibold text-dc-text dc:mb-2",
693
1477
  children: g
694
- }), /* @__PURE__ */ B("div", {
1478
+ }), /* @__PURE__ */ W("div", {
695
1479
  className: "text-dc-error dc:text-sm bg-dc-danger-bg dc:p-3 dc:rounded dc:border border-dc-error",
696
1480
  style: { height: _ },
697
1481
  children: n.message
698
- })] }) : e ? /* @__PURE__ */ B(D, {
699
- code: S,
1482
+ })] }) : e ? /* @__PURE__ */ W(j, {
1483
+ code: ee,
700
1484
  language: "sql",
701
1485
  title: g,
702
1486
  height: _,
703
- headerRight: /* @__PURE__ */ V(z, { children: [/* @__PURE__ */ V("label", {
1487
+ headerRight: /* @__PURE__ */ G(U, { children: [/* @__PURE__ */ G("label", {
704
1488
  className: "dc:flex dc:items-center dc:gap-1 dc:text-xs text-dc-text-secondary dc:cursor-pointer",
705
- children: [/* @__PURE__ */ B("input", {
1489
+ children: [/* @__PURE__ */ W("input", {
706
1490
  type: "checkbox",
707
1491
  checked: v,
708
1492
  onChange: (e) => y(e.target.checked),
709
1493
  className: "dc:w-3 dc:h-3 dc:rounded border-dc-border text-dc-accent focus:ring-dc-accent"
710
1494
  }), "Include timing"]
711
- }), /* @__PURE__ */ B("button", {
1495
+ }), /* @__PURE__ */ W("button", {
712
1496
  onClick: () => c({ analyze: v }),
713
1497
  disabled: a,
714
1498
  className: "dc:px-2 dc:py-1 dc:text-xs dc:font-medium dc:rounded dc:border border-dc-border bg-dc-surface hover:bg-dc-surface-hover text-dc-text-secondary hover:text-dc-text dc:transition-colors dc:disabled:opacity-50 dc:disabled:cursor-not-allowed",
715
1499
  children: a ? "Running..." : "Explain Plan"
716
1500
  })] })
717
- }) : /* @__PURE__ */ V(z, { children: [/* @__PURE__ */ B("h4", {
1501
+ }) : /* @__PURE__ */ G(U, { children: [/* @__PURE__ */ W("h4", {
718
1502
  className: "dc:text-sm dc:font-semibold text-dc-text dc:mb-2",
719
1503
  children: g
720
- }), /* @__PURE__ */ B("div", {
1504
+ }), /* @__PURE__ */ W("div", {
721
1505
  className: "bg-dc-surface-secondary dc:border border-dc-border dc:rounded dc:p-3 text-dc-text-muted dc:text-sm",
722
1506
  style: { height: _ },
723
1507
  children: r
724
1508
  })] }),
725
- o && /* @__PURE__ */ B("div", { children: a ? /* @__PURE__ */ V("div", {
1509
+ o && /* @__PURE__ */ W("div", { children: a ? /* @__PURE__ */ G("div", {
726
1510
  className: "bg-dc-surface-secondary dc:border border-dc-border dc:rounded dc:p-3 text-dc-text-muted dc:text-sm dc:animate-pulse",
727
1511
  children: [
728
1512
  "Running EXPLAIN",
729
1513
  v ? " ANALYZE" : "",
730
1514
  "..."
731
1515
  ]
732
- }) : s ? /* @__PURE__ */ V("div", {
1516
+ }) : s ? /* @__PURE__ */ G("div", {
733
1517
  className: "text-dc-error dc:text-sm bg-dc-danger-bg dc:p-3 dc:rounded dc:border border-dc-error",
734
1518
  children: [
735
- /* @__PURE__ */ B("strong", { children: "Explain Error:" }),
1519
+ /* @__PURE__ */ W("strong", { children: "Explain Error:" }),
736
1520
  " ",
737
1521
  s.message
738
1522
  ]
739
- }) : i ? /* @__PURE__ */ V("div", {
1523
+ }) : i ? /* @__PURE__ */ G("div", {
740
1524
  className: "dc:space-y-3",
741
1525
  children: [
742
- /* @__PURE__ */ V("div", {
1526
+ /* @__PURE__ */ G("div", {
743
1527
  className: "dc:flex dc:flex-wrap dc:items-center dc:gap-2",
744
1528
  children: [
745
- /* @__PURE__ */ B("span", {
1529
+ /* @__PURE__ */ W("span", {
746
1530
  className: "dc:px-2 dc:py-1 dc:text-xs dc:font-medium bg-dc-accent text-white dc:rounded",
747
1531
  children: i.summary.database.toUpperCase()
748
1532
  }),
749
- i.summary.hasSequentialScans && /* @__PURE__ */ B("span", {
1533
+ i.summary.hasSequentialScans && /* @__PURE__ */ W("span", {
750
1534
  className: "dc:px-2 dc:py-1 dc:text-xs dc:font-medium bg-dc-warning-bg text-dc-warning dc:border border-dc-warning dc:rounded",
751
1535
  children: "Sequential Scans Detected"
752
1536
  }),
753
- i.summary.usedIndexes.length > 0 && /* @__PURE__ */ V("span", {
1537
+ i.summary.usedIndexes.length > 0 && /* @__PURE__ */ G("span", {
754
1538
  className: "dc:px-2 dc:py-1 dc:text-xs dc:font-medium bg-dc-success-bg text-dc-success dc:border border-dc-success dc:rounded",
755
1539
  children: [
756
1540
  i.summary.usedIndexes.length,
@@ -759,7 +1543,7 @@ var we = N(function({ sql: e, sqlLoading: t = !1, sqlError: n, sqlPlaceholder: r
759
1543
  " Used"
760
1544
  ]
761
1545
  }),
762
- i.summary.executionTime !== void 0 && /* @__PURE__ */ V("span", {
1546
+ i.summary.executionTime !== void 0 && /* @__PURE__ */ G("span", {
763
1547
  className: "dc:px-2 dc:py-1 dc:text-xs dc:font-medium bg-dc-surface-secondary text-dc-text-secondary dc:border border-dc-border dc:rounded",
764
1548
  children: [
765
1549
  "Execution: ",
@@ -767,7 +1551,7 @@ var we = N(function({ sql: e, sqlLoading: t = !1, sqlError: n, sqlPlaceholder: r
767
1551
  "ms"
768
1552
  ]
769
1553
  }),
770
- i.summary.planningTime !== void 0 && /* @__PURE__ */ V("span", {
1554
+ i.summary.planningTime !== void 0 && /* @__PURE__ */ G("span", {
771
1555
  className: "dc:px-2 dc:py-1 dc:text-xs dc:font-medium bg-dc-surface-secondary text-dc-text-secondary dc:border border-dc-border dc:rounded",
772
1556
  children: [
773
1557
  "Planning: ",
@@ -775,60 +1559,61 @@ var we = N(function({ sql: e, sqlLoading: t = !1, sqlError: n, sqlPlaceholder: r
775
1559
  "ms"
776
1560
  ]
777
1561
  }),
778
- i.summary.totalCost !== void 0 && /* @__PURE__ */ V("span", {
1562
+ i.summary.totalCost !== void 0 && /* @__PURE__ */ G("span", {
779
1563
  className: "dc:px-2 dc:py-1 dc:text-xs dc:font-medium bg-dc-surface-secondary text-dc-text-secondary dc:border border-dc-border dc:rounded",
780
1564
  children: ["Cost: ", i.summary.totalCost.toFixed(2)]
781
1565
  })
782
1566
  ]
783
1567
  }),
784
- i.summary.usedIndexes.length > 0 && /* @__PURE__ */ V("div", {
1568
+ i.summary.usedIndexes.length > 0 && /* @__PURE__ */ G("div", {
785
1569
  className: "dc:text-xs text-dc-text-muted",
786
1570
  children: [
787
- /* @__PURE__ */ B("strong", { children: "Indexes:" }),
1571
+ /* @__PURE__ */ W("strong", { children: "Indexes:" }),
788
1572
  " ",
789
1573
  i.summary.usedIndexes.join(", ")
790
1574
  ]
791
1575
  }),
792
- /* @__PURE__ */ B(D, {
1576
+ /* @__PURE__ */ W(j, {
793
1577
  code: i.raw,
794
1578
  language: "sql",
795
1579
  title: `Execution Plan (${i.summary.database})`,
796
1580
  height: "16rem",
797
- headerRight: T
1581
+ headerRight: ne
798
1582
  })
799
1583
  ]
800
1584
  }) : null }),
801
- d && /* @__PURE__ */ V("div", {
1585
+ d && /* @__PURE__ */ G("div", {
802
1586
  className: "text-dc-error dc:text-sm bg-dc-danger-bg dc:p-3 dc:rounded dc:border border-dc-error",
803
1587
  children: [
804
- /* @__PURE__ */ B("strong", { children: "AI Analysis Error:" }),
1588
+ /* @__PURE__ */ W("strong", { children: "AI Analysis Error:" }),
805
1589
  " ",
806
1590
  d.message
807
1591
  ]
808
1592
  }),
809
- b && l && /* @__PURE__ */ B(Ce, {
1593
+ b && l && /* @__PURE__ */ W(rt, {
810
1594
  analysis: l,
811
- onClose: w
1595
+ onClose: S
812
1596
  })
813
1597
  ]
814
1598
  });
815
1599
  });
816
1600
  //#endregion
817
1601
  //#region src/client/adapters/queryModeAdapter.ts
818
- function Te() {
1602
+ function at() {
819
1603
  return {
820
1604
  metrics: [],
821
1605
  breakdowns: [],
822
1606
  filters: [],
823
1607
  order: void 0,
1608
+ limit: void 0,
824
1609
  validationStatus: "idle",
825
1610
  validationError: null
826
1611
  };
827
1612
  }
828
- function Ee(e) {
1613
+ function ot(e) {
829
1614
  return e.map((e) => e.field);
830
1615
  }
831
- function De(e, t) {
1616
+ function st(e, t) {
832
1617
  let n = [], r = [];
833
1618
  for (let i of e) if (i.isTimeDimension) {
834
1619
  let e = {
@@ -836,7 +1621,7 @@ function De(e, t) {
836
1621
  granularity: i.granularity || "day"
837
1622
  };
838
1623
  if (i.enableComparison) {
839
- let n = oe(i.field, t);
1624
+ let n = me(i.field, t);
840
1625
  n && (e.compareDateRange = n);
841
1626
  }
842
1627
  r.push(e);
@@ -846,31 +1631,31 @@ function De(e, t) {
846
1631
  timeDimensions: r
847
1632
  };
848
1633
  }
849
- function Oe(e) {
850
- let { dimensions: t, timeDimensions: n } = De(e.breakdowns, e.filters), r = {
851
- measures: Ee(e.metrics),
1634
+ function ct(e) {
1635
+ let { dimensions: t, timeDimensions: n } = st(e.breakdowns, e.filters), r = {
1636
+ measures: ot(e.metrics),
852
1637
  dimensions: t
853
1638
  };
854
- return n.length > 0 && (r.timeDimensions = n), e.filters.length > 0 && (r.filters = e.filters), e.order && Object.keys(e.order).length > 0 && (r.order = e.order), r;
1639
+ return n.length > 0 && (r.timeDimensions = n), e.filters.length > 0 && (r.filters = e.filters), e.order && Object.keys(e.order).length > 0 && (r.order = e.order), e.limit != null && (r.limit = e.limit), r;
855
1640
  }
856
- function ke(e) {
1641
+ function lt(e) {
857
1642
  return e.map((e, t) => ({
858
- id: T(),
1643
+ id: k(),
859
1644
  field: e,
860
- label: E(t)
1645
+ label: A(t)
861
1646
  }));
862
1647
  }
863
- function Ae(e) {
1648
+ function ut(e) {
864
1649
  let t = [];
865
1650
  if (e.dimensions) for (let n of e.dimensions) t.push({
866
- id: T(),
1651
+ id: k(),
867
1652
  field: n,
868
1653
  isTimeDimension: !1
869
1654
  });
870
1655
  if (e.timeDimensions) for (let n of e.timeDimensions) {
871
1656
  let e = !!(n.compareDateRange && n.compareDateRange.length > 0);
872
1657
  t.push({
873
- id: T(),
1658
+ id: k(),
874
1659
  field: n.dimension,
875
1660
  granularity: n.granularity,
876
1661
  isTimeDimension: !0,
@@ -879,24 +1664,25 @@ function Ae(e) {
879
1664
  }
880
1665
  return t;
881
1666
  }
882
- function je(e) {
1667
+ function dt(e) {
883
1668
  return {
884
- metrics: ke(e.measures || []),
885
- breakdowns: Ae(e),
1669
+ metrics: lt(e.measures || []),
1670
+ breakdowns: ut(e),
886
1671
  filters: e.filters || [],
887
1672
  order: e.order,
1673
+ limit: e.limit,
888
1674
  validationStatus: "idle",
889
1675
  validationError: null
890
1676
  };
891
1677
  }
892
- function Me(e) {
1678
+ function ft(e) {
893
1679
  return typeof e == "object" && !!e && "queries" in e && Array.isArray(e.queries);
894
1680
  }
895
- var Y = {
1681
+ var X = {
896
1682
  type: "query",
897
1683
  createInitial() {
898
1684
  return {
899
- queryStates: [Te()],
1685
+ queryStates: [at()],
900
1686
  activeQueryIndex: 0,
901
1687
  mergeStrategy: "concat"
902
1688
  };
@@ -916,22 +1702,22 @@ var Y = {
916
1702
  load(e) {
917
1703
  if (e.analysisType !== "query") throw Error(`Cannot load ${e.analysisType} config with query adapter`);
918
1704
  let t = e;
919
- if (Me(t.query)) {
920
- let e = t.query, n = e.queries.map(je);
921
- return n.length === 0 && n.push(Te()), {
1705
+ if (ft(t.query)) {
1706
+ let e = t.query, n = e.queries.map(dt);
1707
+ return n.length === 0 && n.push(at()), {
922
1708
  queryStates: n,
923
1709
  activeQueryIndex: 0,
924
1710
  mergeStrategy: e.mergeStrategy || "concat"
925
1711
  };
926
1712
  }
927
1713
  return {
928
- queryStates: [je(t.query)],
1714
+ queryStates: [dt(t.query)],
929
1715
  activeQueryIndex: 0,
930
1716
  mergeStrategy: "concat"
931
1717
  };
932
1718
  },
933
1719
  save(e, t, n) {
934
- let r = e.queryStates.map(Oe), i = r.length === 1 && e.mergeStrategy === "concat" ? r[0] : {
1720
+ let r = e.queryStates.map(ct), i = r.length === 1 && e.mergeStrategy === "concat" ? r[0] : {
935
1721
  queries: r,
936
1722
  mergeStrategy: e.mergeStrategy
937
1723
  };
@@ -975,36 +1761,36 @@ var Y = {
975
1761
  }
976
1762
  };
977
1763
  }
978
- }, X = /* @__PURE__ */ new Map(), Ne = !1;
979
- function Pe() {
980
- Ne ||= (X.has("query") || X.set("query", Y), X.has("funnel") || X.set("funnel", A), X.has("flow") || X.set("flow", k), X.has("retention") || X.set("retention", w), !0);
1764
+ }, Z = /* @__PURE__ */ new Map(), pt = !1;
1765
+ function mt() {
1766
+ pt ||= (Z.has("query") || Z.set("query", X), Z.has("funnel") || Z.set("funnel", P), Z.has("flow") || Z.set("flow", N), Z.has("retention") || Z.set("retention", D), !0);
981
1767
  }
982
- var Z = {
1768
+ var Q = {
983
1769
  register(e) {
984
- X.has(e.type) && console.warn(`[adapterRegistry] Overwriting existing adapter for type: ${e.type}`), X.set(e.type, e);
1770
+ Z.has(e.type) && console.warn(`[adapterRegistry] Overwriting existing adapter for type: ${e.type}`), Z.set(e.type, e);
985
1771
  },
986
1772
  get(e) {
987
- Pe();
988
- let t = X.get(e);
989
- if (!t) throw Error(`[adapterRegistry] No adapter registered for type: ${e}. Available types: ${Array.from(X.keys()).join(", ") || "none"}`);
1773
+ mt();
1774
+ let t = Z.get(e);
1775
+ if (!t) throw Error(`[adapterRegistry] No adapter registered for type: ${e}. Available types: ${Array.from(Z.keys()).join(", ") || "none"}`);
990
1776
  return t;
991
1777
  },
992
1778
  has(e) {
993
- return Pe(), X.has(e);
1779
+ return mt(), Z.has(e);
994
1780
  },
995
1781
  getRegisteredTypes() {
996
- return Pe(), Array.from(X.keys());
1782
+ return mt(), Array.from(Z.keys());
997
1783
  },
998
1784
  clear() {
999
- X.clear(), Ne = !1;
1785
+ Z.clear(), pt = !1;
1000
1786
  }
1001
- }, Fe = () => ({
1787
+ }, ht = () => ({
1002
1788
  analysisType: "query",
1003
1789
  charts: {
1004
- query: Y.getDefaultChartConfig(),
1005
- funnel: A.getDefaultChartConfig(),
1006
- flow: k.getDefaultChartConfig(),
1007
- retention: w.getDefaultChartConfig()
1790
+ query: X.getDefaultChartConfig(),
1791
+ funnel: P.getDefaultChartConfig(),
1792
+ flow: N.getDefaultChartConfig(),
1793
+ retention: D.getDefaultChartConfig()
1008
1794
  },
1009
1795
  activeViews: {
1010
1796
  query: "chart",
@@ -1014,12 +1800,12 @@ var Z = {
1014
1800
  },
1015
1801
  userManuallySelectedChart: !1,
1016
1802
  localPaletteName: "default"
1017
- }), Ie = (e, t, n) => ({
1018
- ...Fe(),
1803
+ }), gt = (e, t, n) => ({
1804
+ ...ht(),
1019
1805
  setAnalysisType: (t) => {
1020
1806
  e((e) => {
1021
1807
  let n = { ...e.charts };
1022
- n[t] || (n[t] = Z.get(t).getDefaultChartConfig());
1808
+ n[t] || (n[t] = Q.get(t).getDefaultChartConfig());
1023
1809
  let r = { ...e.activeViews };
1024
1810
  return r[t] || (r[t] = "chart"), {
1025
1811
  analysisType: t,
@@ -1166,11 +1952,11 @@ var Z = {
1166
1952
  });
1167
1953
  },
1168
1954
  save: () => {
1169
- let e = t(), n = Z.get(e.analysisType), r = n.extractState(e);
1955
+ let e = t(), n = Q.get(e.analysisType), r = n.extractState(e);
1170
1956
  return n.save(r, e.charts, e.activeViews[e.analysisType] ?? e.activeView ?? "chart");
1171
1957
  },
1172
1958
  load: (n) => {
1173
- let r = Z.get(n.analysisType);
1959
+ let r = Q.get(n.analysisType);
1174
1960
  if (!r.canLoad(n)) {
1175
1961
  console.warn("[coreSlice] Invalid config, cannot load");
1176
1962
  return;
@@ -1191,7 +1977,7 @@ var Z = {
1191
1977
  });
1192
1978
  },
1193
1979
  saveWorkspace: () => {
1194
- let e = t(), n = e, r = Z.get("query"), i = r.extractState(n), a = r.save(i, e.charts, e.activeViews.query ?? e.activeView ?? "chart"), o = Z.get("funnel"), s = o.extractState(n), c = o.save(s, e.charts, e.activeViews.funnel ?? e.activeView ?? "chart"), l = Z.get("flow"), u = l.extractState(n), d = l.save(u, e.charts, e.activeViews.flow ?? e.activeView ?? "chart"), f = Z.get("retention"), p = f.extractState(n), m = f.save(p, e.charts, e.activeViews.retention ?? e.activeView ?? "chart");
1980
+ let e = t(), n = e, r = Q.get("query"), i = r.extractState(n), a = r.save(i, e.charts, e.activeViews.query ?? e.activeView ?? "chart"), o = Q.get("funnel"), s = o.extractState(n), c = o.save(s, e.charts, e.activeViews.funnel ?? e.activeView ?? "chart"), l = Q.get("flow"), u = l.extractState(n), d = l.save(u, e.charts, e.activeViews.flow ?? e.activeView ?? "chart"), f = Q.get("retention"), p = f.extractState(n), m = f.save(p, e.charts, e.activeViews.retention ?? e.activeView ?? "chart");
1195
1981
  return {
1196
1982
  version: 1,
1197
1983
  activeType: e.analysisType,
@@ -1204,7 +1990,7 @@ var Z = {
1204
1990
  };
1205
1991
  },
1206
1992
  loadWorkspace: (n) => {
1207
- let r = Z.get("query"), i = Z.get("funnel"), a = Z.get("flow"), o = Z.get("retention"), s = {}, c = {}, l = {}, u = {}, d = { ...t().charts }, f = { ...t().activeViews };
1993
+ let r = Q.get("query"), i = Q.get("funnel"), a = Q.get("flow"), o = Q.get("retention"), s = {}, c = {}, l = {}, u = {}, d = { ...t().charts }, f = { ...t().activeViews };
1208
1994
  n.modes.query && r.canLoad(n.modes.query) && (s = r.load(n.modes.query), d = {
1209
1995
  ...d,
1210
1996
  ...n.modes.query.charts
@@ -1228,22 +2014,22 @@ var Z = {
1228
2014
  ...u
1229
2015
  });
1230
2016
  }
1231
- }), Le = () => ({
1232
- queryStates: [U()],
2017
+ }), _t = () => ({
2018
+ queryStates: [K()],
1233
2019
  activeQueryIndex: 0,
1234
2020
  mergeStrategy: "concat"
1235
- }), Re = (e, t, n) => ({
1236
- ...Le(),
2021
+ }), vt = (e, t, n) => ({
2022
+ ..._t(),
1237
2023
  setQueryStates: (t) => e({ queryStates: t }),
1238
2024
  updateQueryState: (t, n) => e((e) => {
1239
2025
  let r = [...e.queryStates];
1240
- return r[t] = n(r[t] || U()), { queryStates: r };
2026
+ return r[t] = n(r[t] || K()), { queryStates: r };
1241
2027
  }),
1242
2028
  setActiveQueryIndex: (t) => e({ activeQueryIndex: t }),
1243
2029
  setMergeStrategy: (t) => e({ mergeStrategy: t }),
1244
2030
  addQuery: () => e((e) => {
1245
- let t = e.queryStates[e.activeQueryIndex] || U(), n = {
1246
- ...U(),
2031
+ let t = e.queryStates[e.activeQueryIndex] || K(), n = {
2032
+ ...K(),
1247
2033
  metrics: [...t.metrics],
1248
2034
  breakdowns: [...t.breakdowns],
1249
2035
  filters: [...t.filters]
@@ -1262,10 +2048,10 @@ var Z = {
1262
2048
  };
1263
2049
  }),
1264
2050
  addMetric: (t, n) => e((e) => {
1265
- let r = e.activeQueryIndex, i = [...e.queryStates], a = i[r] || U(), o = {
1266
- id: T(),
2051
+ let r = e.activeQueryIndex, i = [...e.queryStates], a = i[r] || K(), o = {
2052
+ id: k(),
1267
2053
  field: t,
1268
- label: n || E(a.metrics.length)
2054
+ label: n || A(a.metrics.length)
1269
2055
  };
1270
2056
  return i[r] = {
1271
2057
  ...a,
@@ -1273,7 +2059,7 @@ var Z = {
1273
2059
  }, { queryStates: i };
1274
2060
  }),
1275
2061
  removeMetric: (t) => e((e) => {
1276
- let n = e.activeQueryIndex, r = [...e.queryStates], i = r[n] || U(), a = i.metrics.find((e) => e.id === t)?.field, o = i.metrics.filter((e) => e.id !== t), s = i.order;
2062
+ let n = e.activeQueryIndex, r = [...e.queryStates], i = r[n] || K(), a = i.metrics.find((e) => e.id === t)?.field, o = i.metrics.filter((e) => e.id !== t), s = i.order;
1277
2063
  return a && s && s[a] && (s = { ...s }, delete s[a], Object.keys(s).length === 0 && (s = void 0)), r[n] = {
1278
2064
  ...i,
1279
2065
  metrics: o,
@@ -1281,16 +2067,16 @@ var Z = {
1281
2067
  }, { queryStates: r };
1282
2068
  }),
1283
2069
  toggleMetric: (t) => e((e) => {
1284
- let n = e.activeQueryIndex, r = [...e.queryStates], i = r[n] || U(), a = i.metrics.findIndex((e) => e.field === t);
2070
+ let n = e.activeQueryIndex, r = [...e.queryStates], i = r[n] || K(), a = i.metrics.findIndex((e) => e.field === t);
1285
2071
  if (a >= 0) r[n] = {
1286
2072
  ...i,
1287
2073
  metrics: i.metrics.filter((e, t) => t !== a)
1288
2074
  };
1289
2075
  else {
1290
2076
  let e = {
1291
- id: T(),
2077
+ id: k(),
1292
2078
  field: t,
1293
- label: E(i.metrics.length)
2079
+ label: A(i.metrics.length)
1294
2080
  };
1295
2081
  r[n] = {
1296
2082
  ...i,
@@ -1300,17 +2086,17 @@ var Z = {
1300
2086
  return { queryStates: r };
1301
2087
  }),
1302
2088
  reorderMetrics: (t, n) => e((e) => {
1303
- let r = e.activeQueryIndex, i = [...e.queryStates], a = i[r] || U(), o = [...a.metrics], [s] = o.splice(t, 1);
2089
+ let r = e.activeQueryIndex, i = [...e.queryStates], a = i[r] || K(), o = [...a.metrics], [s] = o.splice(t, 1);
1304
2090
  return o.splice(n, 0, s), i[r] = {
1305
2091
  ...a,
1306
2092
  metrics: o
1307
2093
  }, { queryStates: i };
1308
2094
  }),
1309
2095
  addBreakdown: (t, n, r) => e((e) => {
1310
- let i = e.activeQueryIndex, a = [...e.queryStates], o = a[i] || U();
2096
+ let i = e.activeQueryIndex, a = [...e.queryStates], o = a[i] || K();
1311
2097
  if (n && o.breakdowns.some((e) => e.isTimeDimension)) return e;
1312
2098
  let s = {
1313
- id: T(),
2099
+ id: k(),
1314
2100
  field: t,
1315
2101
  isTimeDimension: n,
1316
2102
  granularity: n ? r || "month" : void 0
@@ -1321,7 +2107,7 @@ var Z = {
1321
2107
  }, { queryStates: a };
1322
2108
  }),
1323
2109
  removeBreakdown: (t) => e((e) => {
1324
- let n = e.activeQueryIndex, r = [...e.queryStates], i = r[n] || U(), a = i.breakdowns.find((e) => e.id === t)?.field, o = i.breakdowns.filter((e) => e.id !== t), s = i.order;
2110
+ let n = e.activeQueryIndex, r = [...e.queryStates], i = r[n] || K(), a = i.breakdowns.find((e) => e.id === t)?.field, o = i.breakdowns.filter((e) => e.id !== t), s = i.order;
1325
2111
  return a && s && s[a] && (s = { ...s }, delete s[a], Object.keys(s).length === 0 && (s = void 0)), r[n] = {
1326
2112
  ...i,
1327
2113
  breakdowns: o,
@@ -1329,7 +2115,7 @@ var Z = {
1329
2115
  }, { queryStates: r };
1330
2116
  }),
1331
2117
  toggleBreakdown: (t, n, r) => e((e) => {
1332
- let i = e.activeQueryIndex, a = [...e.queryStates], o = a[i] || U(), s = o.breakdowns.findIndex((e) => e.field === t);
2118
+ let i = e.activeQueryIndex, a = [...e.queryStates], o = a[i] || K(), s = o.breakdowns.findIndex((e) => e.field === t);
1333
2119
  if (s >= 0) a[i] = {
1334
2120
  ...o,
1335
2121
  breakdowns: o.breakdowns.filter((e, t) => t !== s)
@@ -1337,7 +2123,7 @@ var Z = {
1337
2123
  else {
1338
2124
  if (n && o.breakdowns.some((e) => e.isTimeDimension)) return e;
1339
2125
  let s = {
1340
- id: T(),
2126
+ id: k(),
1341
2127
  field: t,
1342
2128
  isTimeDimension: n,
1343
2129
  granularity: n ? r || "month" : void 0
@@ -1360,20 +2146,20 @@ var Z = {
1360
2146
  }, { queryStates: o };
1361
2147
  }),
1362
2148
  toggleBreakdownComparison: (t) => e((e) => {
1363
- let { mergeStrategy: n, activeQueryIndex: r, queryStates: i, charts: a, analysisType: o } = e, s = [...i], l = n === "merge" && r > 0 ? 0 : r, u = s[l].breakdowns.find((e) => e.id === t), d = u && !u.enableComparison, f = s[l].breakdowns.map((e) => e.id === t ? {
2149
+ let { mergeStrategy: n, activeQueryIndex: r, queryStates: i, charts: a, analysisType: o } = e, s = [...i], c = n === "merge" && r > 0 ? 0 : r, u = s[c].breakdowns.find((e) => e.id === t), d = u && !u.enableComparison, f = s[c].breakdowns.map((e) => e.id === t ? {
1364
2150
  ...e,
1365
2151
  enableComparison: !e.enableComparison
1366
2152
  } : e.isTimeDimension && e.enableComparison ? {
1367
2153
  ...e,
1368
2154
  enableComparison: !1
1369
2155
  } : e);
1370
- s[l] = {
1371
- ...s[l],
2156
+ s[c] = {
2157
+ ...s[c],
1372
2158
  breakdowns: f
1373
2159
  };
1374
2160
  let p = { queryStates: s };
1375
2161
  if (d && u?.isTimeDimension && u.field) {
1376
- let t = s[l].filters || [];
2162
+ let t = s[c].filters || [];
1377
2163
  if (!t.some((e) => {
1378
2164
  if ("member" in e) {
1379
2165
  let t = e;
@@ -1385,10 +2171,10 @@ var Z = {
1385
2171
  member: u.field,
1386
2172
  operator: "inDateRange",
1387
2173
  values: [],
1388
- dateRange: c("last_n_months", 3)
2174
+ dateRange: l("last_n_months", 3)
1389
2175
  };
1390
- s[l] = {
1391
- ...s[l],
2176
+ s[c] = {
2177
+ ...s[c],
1392
2178
  filters: [...t, e]
1393
2179
  }, p.queryStates = s;
1394
2180
  }
@@ -1407,7 +2193,7 @@ var Z = {
1407
2193
  return p;
1408
2194
  }),
1409
2195
  reorderBreakdowns: (t, n) => e((e) => {
1410
- let r = e.activeQueryIndex, i = [...e.queryStates], a = i[r] || U(), o = [...a.breakdowns], [s] = o.splice(t, 1);
2196
+ let r = e.activeQueryIndex, i = [...e.queryStates], a = i[r] || K(), o = [...a.breakdowns], [s] = o.splice(t, 1);
1411
2197
  return o.splice(n, 0, s), i[r] = {
1412
2198
  ...a,
1413
2199
  breakdowns: o
@@ -1421,7 +2207,7 @@ var Z = {
1421
2207
  }, { queryStates: r };
1422
2208
  }),
1423
2209
  dropFieldToFilter: (t) => e((e) => {
1424
- let n = e.activeQueryIndex, r = [...e.queryStates], i = r[n] || U(), a = i.filters || [];
2210
+ let n = e.activeQueryIndex, r = [...e.queryStates], i = r[n] || K(), a = i.filters || [];
1425
2211
  if (a.some((e) => "member" in e && e.member === t)) return e;
1426
2212
  let o = {
1427
2213
  member: t,
@@ -1445,15 +2231,22 @@ var Z = {
1445
2231
  }, { queryStates: r };
1446
2232
  }),
1447
2233
  setOrder: (t, n) => e((e) => {
1448
- let r = e.activeQueryIndex, i = [...e.queryStates], a = i[r] || U(), o = { ...a.order || {} };
2234
+ let r = e.activeQueryIndex, i = [...e.queryStates], a = i[r] || K(), o = { ...a.order || {} };
1449
2235
  return n === null ? delete o[t] : o[t] = n, i[r] = {
1450
2236
  ...a,
1451
2237
  order: Object.keys(o).length > 0 ? o : void 0
1452
2238
  }, { queryStates: i };
1453
2239
  }),
2240
+ setLimit: (t) => e((e) => {
2241
+ let n = e.activeQueryIndex, r = [...e.queryStates];
2242
+ return r[n] = {
2243
+ ...r[n],
2244
+ limit: t
2245
+ }, { queryStates: r };
2246
+ }),
1454
2247
  getCurrentState: () => {
1455
2248
  let e = t();
1456
- return e.queryStates[e.activeQueryIndex] || U();
2249
+ return e.queryStates[e.activeQueryIndex] || K();
1457
2250
  },
1458
2251
  getMergeKeys: () => {
1459
2252
  let e = t();
@@ -1466,12 +2259,12 @@ var Z = {
1466
2259
  return e.queryStates.length <= 1 ? !1 : e.queryStates.filter((e) => e.metrics.length > 0 || e.breakdowns.length > 0).length > 1;
1467
2260
  },
1468
2261
  buildCurrentQuery: () => {
1469
- let e = t(), n = e.queryStates[e.activeQueryIndex] || U();
1470
- return ce(n.metrics, n.breakdowns, n.filters, n.order);
2262
+ let e = t(), n = e.queryStates[e.activeQueryIndex] || K();
2263
+ return ge(n.metrics, n.breakdowns, n.filters, n.order, !1, n.limit);
1471
2264
  },
1472
2265
  buildAllQueries: () => {
1473
2266
  let e = t(), n = e.queryStates[0]?.breakdowns || [];
1474
- return e.queryStates.map((t, r) => ce(t.metrics, e.mergeStrategy === "merge" && r > 0 ? n : t.breakdowns, t.filters, t.order));
2267
+ return e.queryStates.map((t, r) => ge(t.metrics, e.mergeStrategy === "merge" && r > 0 ? n : t.breakdowns, t.filters, t.order, !1, t.limit));
1475
2268
  },
1476
2269
  buildMultiQueryConfig: () => {
1477
2270
  let e = t();
@@ -1484,18 +2277,18 @@ var Z = {
1484
2277
  queryLabels: n.map((e, t) => `Q${t + 1}`)
1485
2278
  };
1486
2279
  }
1487
- }), ze = () => ({
2280
+ }), yt = () => ({
1488
2281
  funnelCube: null,
1489
2282
  funnelSteps: [],
1490
2283
  activeFunnelStepIndex: 0,
1491
2284
  funnelTimeDimension: null,
1492
2285
  funnelBindingKey: null,
1493
2286
  stepTimeToConvert: []
1494
- }), Be = (e, t, n) => ({
1495
- ...ze(),
2287
+ }), bt = (e, t, n) => ({
2288
+ ...yt(),
1496
2289
  addFunnelStep: () => e((e) => {
1497
2290
  let t = e.funnelSteps[e.funnelSteps.length - 1], n = {
1498
- id: T(),
2291
+ id: k(),
1499
2292
  name: `Step ${e.funnelSteps.length + 1}`,
1500
2293
  cube: e.funnelCube || "",
1501
2294
  filters: t?.filters ? JSON.parse(JSON.stringify(t.filters)) : [],
@@ -1560,7 +2353,7 @@ var Z = {
1560
2353
  let e = t();
1561
2354
  return e.analysisType !== "funnel" || !e.funnelBindingKey || !e.funnelTimeDimension || e.funnelSteps.length < 2 ? !1 : e.funnelSteps.filter((e) => e.cube && e.name).length >= 2;
1562
2355
  }
1563
- }), Ve = () => ({
2356
+ }), xt = () => ({
1564
2357
  flowCube: null,
1565
2358
  flowBindingKey: null,
1566
2359
  flowTimeDimension: null,
@@ -1572,8 +2365,8 @@ var Z = {
1572
2365
  stepsAfter: 3,
1573
2366
  eventDimension: null,
1574
2367
  joinStrategy: "auto"
1575
- }), He = (e, t, n) => ({
1576
- ...Ve(),
2368
+ }), St = (e, t, n) => ({
2369
+ ...xt(),
1577
2370
  setFlowCube: (t) => e(() => ({
1578
2371
  flowCube: t,
1579
2372
  flowBindingKey: null,
@@ -1643,8 +2436,8 @@ var Z = {
1643
2436
  joinStrategy: e.joinStrategy
1644
2437
  } };
1645
2438
  }
1646
- }), Ue = () => ({ ...y }), We = (e, t, n) => ({
1647
- ...Ue(),
2439
+ }), Ct = () => ({ ...C }), wt = (e, t, n) => ({
2440
+ ...Ct(),
1648
2441
  setRetentionCube: (t) => e(() => ({
1649
2442
  retentionCube: t,
1650
2443
  retentionTimeDimension: null,
@@ -1719,22 +2512,22 @@ var Z = {
1719
2512
  warnings: r
1720
2513
  };
1721
2514
  }
1722
- }), Ge = {
2515
+ }), Tt = {
1723
2516
  isOpen: !1,
1724
2517
  userPrompt: "",
1725
2518
  isGenerating: !1,
1726
2519
  error: null,
1727
2520
  hasGeneratedQuery: !1,
1728
2521
  previousState: null
1729
- }, Ke = () => ({
2522
+ }, Et = () => ({
1730
2523
  activeTab: "query",
1731
2524
  activeView: "chart",
1732
2525
  displayLimit: 100,
1733
2526
  showFieldModal: !1,
1734
2527
  fieldModalMode: "metrics",
1735
- aiState: Ge
1736
- }), qe = (e, t, n) => ({
1737
- ...Ke(),
2528
+ aiState: Tt
2529
+ }), Dt = (e, t, n) => ({
2530
+ ...Et(),
1738
2531
  setActiveTab: (t) => e({ activeTab: t }),
1739
2532
  setActiveView: (t) => e((e) => ({
1740
2533
  activeView: t,
@@ -1804,7 +2597,7 @@ var Z = {
1804
2597
  if (!t) return e;
1805
2598
  let n = e.activeQueryIndex, r = [...e.queryStates];
1806
2599
  return r[n] = {
1807
- ...r[n] || U(),
2600
+ ...r[n] || K(),
1808
2601
  metrics: t.metrics,
1809
2602
  breakdowns: t.breakdowns,
1810
2603
  filters: t.filters
@@ -1818,19 +2611,19 @@ var Z = {
1818
2611
  displayConfig: t.displayConfig
1819
2612
  }
1820
2613
  },
1821
- aiState: { ...Ge }
2614
+ aiState: { ...Tt }
1822
2615
  };
1823
2616
  })
1824
2617
  });
1825
2618
  //#endregion
1826
2619
  //#region src/client/stores/analysisBuilderStore.tsx
1827
- function Je(e) {
2620
+ function Ot(e) {
1828
2621
  let t = e.filters ? [...e.filters] : [], n = e.timeDimensions || [], r = [...(e.dimensions || []).map((e) => ({
1829
- id: T(),
2622
+ id: k(),
1830
2623
  field: e,
1831
2624
  isTimeDimension: !1
1832
2625
  })), ...n.map((e) => ({
1833
- id: T(),
2626
+ id: k(),
1834
2627
  field: e.dimension,
1835
2628
  granularity: e.granularity,
1836
2629
  isTimeDimension: !0,
@@ -1856,24 +2649,24 @@ function Je(e) {
1856
2649
  }
1857
2650
  }
1858
2651
  return {
1859
- ...U(),
2652
+ ...K(),
1860
2653
  metrics: (e.measures || []).map((e, t) => ({
1861
- id: T(),
2654
+ id: k(),
1862
2655
  field: e,
1863
- label: E(t)
2656
+ label: A(t)
1864
2657
  })),
1865
2658
  breakdowns: r,
1866
2659
  filters: i,
1867
2660
  order: e.order
1868
2661
  };
1869
2662
  }
1870
- function Ye(e) {
2663
+ function kt(e) {
1871
2664
  return "queries" in e && Array.isArray(e.queries);
1872
2665
  }
1873
- function Xe(e) {
2666
+ function At(e) {
1874
2667
  if (e.initialAnalysisType === "funnel" && e.initialFunnelState) {
1875
- let t = A.getDefaultChartConfig();
1876
- return A.save({
2668
+ let t = P.getDefaultChartConfig();
2669
+ return P.save({
1877
2670
  funnelCube: e.initialFunnelState.funnelCube ?? null,
1878
2671
  funnelSteps: e.initialFunnelState.funnelSteps || [],
1879
2672
  activeFunnelStepIndex: 0,
@@ -1886,8 +2679,8 @@ function Xe(e) {
1886
2679
  } }, e.initialActiveView || "chart");
1887
2680
  }
1888
2681
  if (e.initialAnalysisType === "flow" && e.initialFlowState) {
1889
- let t = k.getDefaultChartConfig();
1890
- return k.save({
2682
+ let t = N.getDefaultChartConfig();
2683
+ return N.save({
1891
2684
  flowCube: e.initialFlowState.flowCube ?? null,
1892
2685
  flowBindingKey: e.initialFlowState.flowBindingKey ?? null,
1893
2686
  flowTimeDimension: e.initialFlowState.flowTimeDimension ?? null,
@@ -1906,12 +2699,12 @@ function Xe(e) {
1906
2699
  } }, e.initialActiveView || "chart");
1907
2700
  }
1908
2701
  if (e.initialAnalysisType === "retention" && e.initialRetentionState) {
1909
- let t = w.getDefaultChartConfig(), n = {
2702
+ let t = D.getDefaultChartConfig(), n = {
1910
2703
  chartType: e.initialChartConfig?.chartType || t.chartType,
1911
2704
  chartConfig: e.initialChartConfig?.chartConfig || t.chartConfig,
1912
2705
  displayConfig: e.initialChartConfig?.displayConfig || t.displayConfig
1913
- }, r = b(x);
1914
- return w.save({
2706
+ }, r = w(T);
2707
+ return D.save({
1915
2708
  retentionCube: e.initialRetentionState.retentionCube ?? null,
1916
2709
  retentionBindingKey: e.initialRetentionState.retentionBindingKey ?? null,
1917
2710
  retentionTimeDimension: e.initialRetentionState.retentionTimeDimension ?? null,
@@ -1926,9 +2719,9 @@ function Xe(e) {
1926
2719
  }
1927
2720
  if (e.initialQuery) {
1928
2721
  let t = e.initialQuery, n, r = "concat";
1929
- Ye(t) ? (n = t.queries.map(Je), t.mergeStrategy && (r = t.mergeStrategy)) : n = [Je(t)];
1930
- let i = Y.getDefaultChartConfig();
1931
- return Y.save({
2722
+ kt(t) ? (n = t.queries.map(Ot), t.mergeStrategy && (r = t.mergeStrategy)) : n = [Ot(t)];
2723
+ let i = X.getDefaultChartConfig();
2724
+ return X.save({
1932
2725
  queryStates: n,
1933
2726
  activeQueryIndex: 0,
1934
2727
  mergeStrategy: r
@@ -1939,37 +2732,37 @@ function Xe(e) {
1939
2732
  } }, e.initialActiveView || "chart");
1940
2733
  }
1941
2734
  if (e.initialChartConfig) {
1942
- let t = Y.getDefaultChartConfig(), n = {
2735
+ let t = X.getDefaultChartConfig(), n = {
1943
2736
  chartType: e.initialChartConfig.chartType || t.chartType,
1944
2737
  chartConfig: e.initialChartConfig.chartConfig || t.chartConfig,
1945
2738
  displayConfig: e.initialChartConfig.displayConfig || t.displayConfig
1946
2739
  };
1947
- return Y.save({
1948
- queryStates: [U()],
2740
+ return X.save({
2741
+ queryStates: [K()],
1949
2742
  activeQueryIndex: 0,
1950
2743
  mergeStrategy: "concat"
1951
2744
  }, { query: n }, e.initialActiveView || "chart");
1952
2745
  }
1953
- return e.initialActiveView ? Y.save({
1954
- queryStates: [U()],
2746
+ return e.initialActiveView ? X.save({
2747
+ queryStates: [K()],
1955
2748
  activeQueryIndex: 0,
1956
2749
  mergeStrategy: "concat"
1957
- }, { query: Y.getDefaultChartConfig() }, e.initialActiveView) : null;
2750
+ }, { query: X.getDefaultChartConfig() }, e.initialActiveView) : null;
1958
2751
  }
1959
- function Ze(e, t) {
2752
+ function jt(e, t) {
1960
2753
  return {
1961
2754
  reset: () => {
1962
2755
  e({
1963
- ...Fe(),
1964
- ...Le(),
1965
- ...ze(),
1966
- ...Ve(),
1967
- ...Ue(),
2756
+ ...ht(),
2757
+ ..._t(),
2758
+ ...yt(),
2759
+ ...xt(),
2760
+ ...Ct(),
1968
2761
  charts: {
1969
- query: Y.getDefaultChartConfig(),
1970
- funnel: A.getDefaultChartConfig(),
1971
- flow: k.getDefaultChartConfig(),
1972
- retention: w.getDefaultChartConfig()
2762
+ query: X.getDefaultChartConfig(),
2763
+ funnel: P.getDefaultChartConfig(),
2764
+ flow: N.getDefaultChartConfig(),
2765
+ retention: D.getDefaultChartConfig()
1973
2766
  },
1974
2767
  activeViews: {
1975
2768
  query: "chart",
@@ -1982,62 +2775,62 @@ function Ze(e, t) {
1982
2775
  clearCurrentMode: () => e((e) => {
1983
2776
  switch (e.analysisType) {
1984
2777
  case "funnel": return {
1985
- ...ze(),
2778
+ ...yt(),
1986
2779
  charts: {
1987
2780
  ...e.charts,
1988
- funnel: A.getDefaultChartConfig()
2781
+ funnel: P.getDefaultChartConfig()
1989
2782
  }
1990
2783
  };
1991
2784
  case "flow": return {
1992
- ...Ve(),
2785
+ ...xt(),
1993
2786
  charts: {
1994
2787
  ...e.charts,
1995
- flow: k.getDefaultChartConfig()
2788
+ flow: N.getDefaultChartConfig()
1996
2789
  }
1997
2790
  };
1998
2791
  case "retention": return {
1999
- ...Ue(),
2792
+ ...Ct(),
2000
2793
  charts: {
2001
2794
  ...e.charts,
2002
- retention: w.getDefaultChartConfig()
2795
+ retention: D.getDefaultChartConfig()
2003
2796
  }
2004
2797
  };
2005
2798
  default: return {
2006
- ...Le(),
2799
+ ..._t(),
2007
2800
  userManuallySelectedChart: !1,
2008
2801
  charts: {
2009
2802
  ...e.charts,
2010
- query: Y.getDefaultChartConfig()
2803
+ query: X.getDefaultChartConfig()
2011
2804
  }
2012
2805
  };
2013
2806
  }
2014
2807
  }),
2015
2808
  clearQuery: () => e((e) => {
2016
2809
  let t = [...e.queryStates];
2017
- return t[e.activeQueryIndex] = U(), {
2810
+ return t[e.activeQueryIndex] = K(), {
2018
2811
  queryStates: t,
2019
2812
  userManuallySelectedChart: !1,
2020
2813
  charts: {
2021
2814
  ...e.charts,
2022
- query: Y.getDefaultChartConfig()
2815
+ query: X.getDefaultChartConfig()
2023
2816
  }
2024
2817
  };
2025
2818
  }),
2026
2819
  getValidation: () => {
2027
- let e = t(), n = Z.get(e.analysisType), r = n.extractState(e);
2820
+ let e = t(), n = Q.get(e.analysisType), r = n.extractState(e);
2028
2821
  return n.validate(r);
2029
2822
  }
2030
2823
  };
2031
2824
  }
2032
- function Qe(n = {}) {
2033
- let r = Xe(n), o = (e, t, n) => ({
2034
- ...Ie(e, t, n),
2035
- ...Re(e, t, n),
2036
- ...Be(e, t, n),
2037
- ...He(e, t, n),
2038
- ...We(e, t, n),
2039
- ...qe(e, t, n),
2040
- ...Ze(e, t)
2825
+ function Mt(n = {}) {
2826
+ let r = At(n), o = (e, t, n) => ({
2827
+ ...gt(e, t, n),
2828
+ ...vt(e, t, n),
2829
+ ...bt(e, t, n),
2830
+ ...St(e, t, n),
2831
+ ...wt(e, t, n),
2832
+ ...Dt(e, t, n),
2833
+ ...jt(e, t)
2041
2834
  });
2042
2835
  if (n.disableLocalStorage) {
2043
2836
  let t = a()(i(e(o), { name: "AnalysisBuilderStore (no-persist)" }));
@@ -2046,10 +2839,10 @@ function Qe(n = {}) {
2046
2839
  return a()(i(e(t(o, {
2047
2840
  name: n.storageKey || "drizzle-cube-analysis-builder-v3",
2048
2841
  partialize: (e) => e.saveWorkspace(),
2049
- merge: (e, t) => e && C(e) ? {
2842
+ merge: (e, t) => e && re(e) ? {
2050
2843
  ...t,
2051
2844
  _persistedWorkspace: e
2052
- } : e && S(e) ? {
2845
+ } : e && E(e) ? {
2053
2846
  ...t,
2054
2847
  _persistedConfig: e
2055
2848
  } : r ? {
@@ -2072,10 +2865,10 @@ function Qe(n = {}) {
2072
2865
  }
2073
2866
  })), { name: "AnalysisBuilderStore" }));
2074
2867
  }
2075
- var $e = M(null);
2076
- function et({ children: e, initialQuery: t, initialChartConfig: n, disableLocalStorage: r, storageKey: i, initialAnalysisType: a, initialFunnelState: o, initialFlowState: s, initialRetentionState: c, initialActiveView: l }) {
2077
- let u = te(null);
2078
- return u.current ||= Qe({
2868
+ var Nt = se(null);
2869
+ function Pt({ children: e, initialQuery: t, initialChartConfig: n, disableLocalStorage: r, storageKey: i, initialAnalysisType: a, initialFunnelState: o, initialFlowState: s, initialRetentionState: c, initialActiveView: l }) {
2870
+ let u = V(null);
2871
+ return u.current ||= Mt({
2079
2872
  initialQuery: t,
2080
2873
  initialChartConfig: n,
2081
2874
  disableLocalStorage: r,
@@ -2085,22 +2878,22 @@ function et({ children: e, initialQuery: t, initialChartConfig: n, disableLocalS
2085
2878
  initialFlowState: s,
2086
2879
  initialRetentionState: c,
2087
2880
  initialActiveView: l
2088
- }), /* @__PURE__ */ B($e.Provider, {
2881
+ }), /* @__PURE__ */ W(Nt.Provider, {
2089
2882
  value: u.current,
2090
2883
  children: e
2091
2884
  });
2092
2885
  }
2093
- function Q(e) {
2094
- let t = F($e);
2886
+ function $(e) {
2887
+ let t = ce(Nt);
2095
2888
  if (!t) throw Error("useAnalysisBuilderStore must be used within AnalysisBuilderStoreProvider");
2096
2889
  return r(t, e);
2097
2890
  }
2098
- function tt() {
2099
- let e = F($e);
2891
+ function Ft() {
2892
+ let e = ce(Nt);
2100
2893
  if (!e) throw Error("useAnalysisBuilderStoreApi must be used within AnalysisBuilderStoreProvider");
2101
2894
  return e;
2102
2895
  }
2103
- var nt = (e) => e.queryStates[e.activeQueryIndex] || U(), rt = (e) => nt(e).metrics, it = (e) => nt(e).breakdowns, at = (e) => nt(e).filters, $ = (e) => {
2896
+ var It = (e) => e.queryStates[e.activeQueryIndex] || K(), Lt = (e) => It(e).metrics, Rt = (e) => It(e).breakdowns, zt = (e) => It(e).filters, Bt = (e) => {
2104
2897
  let t = e.charts[e.analysisType];
2105
2898
  return t ? {
2106
2899
  chartType: t.chartType,
@@ -2115,18 +2908,18 @@ var nt = (e) => e.queryStates[e.activeQueryIndex] || U(), rt = (e) => nt(e).metr
2115
2908
  showTooltip: !0
2116
2909
  }
2117
2910
  };
2118
- }, ot = (e) => ({
2911
+ }, Vt = (e) => ({
2119
2912
  activeTab: e.activeTab,
2120
2913
  activeView: e.activeView,
2121
2914
  displayLimit: e.displayLimit,
2122
2915
  showFieldModal: e.showFieldModal,
2123
2916
  fieldModalMode: e.fieldModalMode
2124
- }), st = (e) => ({
2917
+ }), Ht = (e) => ({
2125
2918
  queryStates: e.queryStates,
2126
2919
  activeQueryIndex: e.activeQueryIndex,
2127
2920
  mergeStrategy: e.mergeStrategy,
2128
2921
  isMultiQueryMode: e.analysisType === "query" && e.queryStates.length > 1
2129
- }), ct = (e) => ({
2922
+ }), Ut = (e) => ({
2130
2923
  funnelCube: e.funnelCube,
2131
2924
  funnelSteps: e.funnelSteps,
2132
2925
  activeFunnelStepIndex: e.activeFunnelStepIndex,
@@ -2137,16 +2930,16 @@ var nt = (e) => e.queryStates[e.activeQueryIndex] || U(), rt = (e) => nt(e).metr
2137
2930
  });
2138
2931
  //#endregion
2139
2932
  //#region src/client/utils/multiQueryValidation.ts
2140
- function lt(e) {
2933
+ function Wt(e) {
2141
2934
  return e.timeDimensions || [];
2142
2935
  }
2143
- function ut(e) {
2936
+ function Gt(e) {
2144
2937
  let t = [];
2145
2938
  if (e.length < 2) return t;
2146
- let n = lt(e[0]);
2939
+ let n = Wt(e[0]);
2147
2940
  if (n.length === 0) return t;
2148
2941
  for (let r = 1; r < e.length; r++) {
2149
- let i = lt(e[r]);
2942
+ let i = Wt(e[r]);
2150
2943
  if (i.length === 0 && n.length > 0) {
2151
2944
  t.push({
2152
2945
  type: "missing_time_dimension",
@@ -2172,7 +2965,7 @@ function ut(e) {
2172
2965
  }
2173
2966
  return t;
2174
2967
  }
2175
- function dt(e, t) {
2968
+ function Kt(e, t) {
2176
2969
  let n = [];
2177
2970
  if (e.length < 2 || t.length === 0) return n;
2178
2971
  for (let r = 0; r < e.length; r++) {
@@ -2186,7 +2979,7 @@ function dt(e, t) {
2186
2979
  }
2187
2980
  return n;
2188
2981
  }
2189
- function ft(e) {
2982
+ function qt(e) {
2190
2983
  let t = [];
2191
2984
  if (e.length < 2) return t;
2192
2985
  let n = /* @__PURE__ */ new Map();
@@ -2205,7 +2998,7 @@ function ft(e) {
2205
2998
  affectedMeasures: r
2206
2999
  }), t;
2207
3000
  }
2208
- function pt(e) {
3001
+ function Jt(e) {
2209
3002
  let t = [];
2210
3003
  if (e.length < 2) return t;
2211
3004
  let n = e.map((e) => e.timeDimensions?.[0]?.dateRange);
@@ -2215,39 +3008,39 @@ function pt(e) {
2215
3008
  message: "Queries have different date ranges - some data points may be missing in merged results"
2216
3009
  }), t;
2217
3010
  }
2218
- function mt(e, t, n = []) {
3011
+ function Yt(e, t, n = []) {
2219
3012
  let r = [], i = [];
2220
3013
  return e.length < 2 ? {
2221
3014
  isValid: !0,
2222
3015
  errors: r,
2223
3016
  warnings: i
2224
- } : (i.push(...ft(e)), i.push(...pt(e)), t === "merge" && (r.push(...ut(e)), n.length > 0 && r.push(...dt(e, n))), {
3017
+ } : (i.push(...qt(e)), i.push(...Jt(e)), t === "merge" && (r.push(...Gt(e)), n.length > 0 && r.push(...Kt(e, n))), {
2225
3018
  isValid: r.length === 0,
2226
3019
  errors: r,
2227
3020
  warnings: i
2228
3021
  });
2229
3022
  }
2230
- function ht(e) {
3023
+ function Xt(e) {
2231
3024
  return e.filter((e) => (e.measures?.length || 0) + (e.dimensions?.length || 0) + (e.timeDimensions?.length || 0) > 0).length >= 2;
2232
3025
  }
2233
- function gt(e) {
3026
+ function Zt(e) {
2234
3027
  if (e.isValid && e.warnings.length === 0) return "Configuration is valid";
2235
3028
  let t = [];
2236
3029
  return e.errors.length > 0 && t.push(`${e.errors.length} error${e.errors.length > 1 ? "s" : ""}`), e.warnings.length > 0 && t.push(`${e.warnings.length} warning${e.warnings.length > 1 ? "s" : ""}`), t.join(", ");
2237
3030
  }
2238
3031
  //#endregion
2239
3032
  //#region src/client/hooks/useAnalysisQueryBuilder.ts
2240
- function _t() {
2241
- let e = Q((e) => e.queryStates), t = Q((e) => e.activeQueryIndex), n = Q((e) => e.mergeStrategy), r = Q((e) => e.setActiveQueryIndex), i = Q((e) => e.setMergeStrategy), a = Q((e) => e.addQuery), o = Q((e) => e.removeQuery), s = Q((e) => e.getCurrentState), c = Q((e) => e.getMergeKeys), l = Q((e) => e.isMultiQueryMode), u = s(), d = l(), f = c(), p = L(() => {
3033
+ function Qt() {
3034
+ let e = $((e) => e.queryStates), t = $((e) => e.activeQueryIndex), n = $((e) => e.mergeStrategy), r = $((e) => e.setActiveQueryIndex), i = $((e) => e.setMergeStrategy), a = $((e) => e.addQuery), o = $((e) => e.removeQuery), s = $((e) => e.getCurrentState), c = $((e) => e.getMergeKeys), l = $((e) => e.isMultiQueryMode), u = s(), d = l(), f = c(), p = B(() => {
2242
3035
  let n = e[t] || u;
2243
- return ce(n.metrics, n.breakdowns, n.filters, n.order);
3036
+ return ge(n.metrics, n.breakdowns, n.filters, n.order, !1, n.limit);
2244
3037
  }, [
2245
3038
  e,
2246
3039
  t,
2247
3040
  u
2248
- ]), m = L(() => {
3041
+ ]), m = B(() => {
2249
3042
  let t = e[0]?.breakdowns || [];
2250
- return e.map((e, r) => ce(e.metrics, n === "merge" && r > 0 ? t : e.breakdowns, e.filters, e.order));
3043
+ return e.map((e, r) => ge(e.metrics, n === "merge" && r > 0 ? t : e.breakdowns, e.filters, e.order, !1, e.limit));
2251
3044
  }, [e, n]);
2252
3045
  return {
2253
3046
  queryState: u,
@@ -2258,7 +3051,7 @@ function _t() {
2258
3051
  mergeKeys: f,
2259
3052
  currentQuery: p,
2260
3053
  allQueries: m,
2261
- multiQueryConfig: L(() => {
3054
+ multiQueryConfig: B(() => {
2262
3055
  if (e.length <= 1) return null;
2263
3056
  let t = m.filter((e) => e.measures && e.measures.length > 0 || e.dimensions && e.dimensions.length > 0 || e.timeDimensions && e.timeDimensions.length > 0);
2264
3057
  return t.length < 2 ? null : {
@@ -2273,13 +3066,13 @@ function _t() {
2273
3066
  n,
2274
3067
  f
2275
3068
  ]),
2276
- multiQueryValidation: L(() => d ? mt(m, n, f || []) : null, [
3069
+ multiQueryValidation: B(() => d ? Yt(m, n, f || []) : null, [
2277
3070
  d,
2278
3071
  m,
2279
3072
  n,
2280
3073
  f
2281
3074
  ]),
2282
- isValidQuery: L(() => p.measures && p.measures.length > 0 || p.dimensions && p.dimensions.length > 0 || p.timeDimensions && p.timeDimensions.length > 0, [p]),
3075
+ isValidQuery: B(() => p.measures && p.measures.length > 0 || p.dimensions && p.dimensions.length > 0 || p.timeDimensions && p.timeDimensions.length > 0, [p]),
2283
3076
  setActiveQueryIndex: r,
2284
3077
  setMergeStrategy: i,
2285
3078
  addQuery: a,
@@ -2288,10 +3081,10 @@ function _t() {
2288
3081
  }
2289
3082
  //#endregion
2290
3083
  //#region src/client/hooks/useAnalysisCombinedFields.ts
2291
- function vt(e) {
3084
+ function $t(e) {
2292
3085
  let { queryState: t, queryStates: n, isMultiQueryMode: r, mergeStrategy: i, activeQueryIndex: a } = e;
2293
3086
  return {
2294
- combinedMetrics: L(() => {
3087
+ combinedMetrics: B(() => {
2295
3088
  if (!r) return t.metrics;
2296
3089
  let e = /* @__PURE__ */ new Set(), i = [];
2297
3090
  for (let t = 0; t < n.length; t++) {
@@ -2310,7 +3103,7 @@ function vt(e) {
2310
3103
  n,
2311
3104
  t.metrics
2312
3105
  ]),
2313
- combinedBreakdowns: L(() => {
3106
+ combinedBreakdowns: B(() => {
2314
3107
  if (!r) return t.breakdowns;
2315
3108
  let e = /* @__PURE__ */ new Set(), i = [];
2316
3109
  for (let t of n) for (let n of t.breakdowns) e.has(n.field) || (e.add(n.field), i.push(n));
@@ -2320,7 +3113,7 @@ function vt(e) {
2320
3113
  n,
2321
3114
  t.breakdowns
2322
3115
  ]),
2323
- effectiveBreakdowns: L(() => i === "merge" && a > 0 ? n[0]?.breakdowns || [] : t.breakdowns, [
3116
+ effectiveBreakdowns: B(() => i === "merge" && a > 0 ? n[0]?.breakdowns || [] : t.breakdowns, [
2324
3117
  i,
2325
3118
  a,
2326
3119
  n,
@@ -2330,129 +3123,129 @@ function vt(e) {
2330
3123
  }
2331
3124
  //#endregion
2332
3125
  //#region src/client/hooks/useAnalysisQueryExecution.ts
2333
- function yt(e) {
2334
- let { currentQuery: t, allQueries: n, multiQueryConfig: r, isMultiQueryMode: i, isValidQuery: a, initialData: o, mergeStrategy: s, funnelBindingKey: c, isFunnelModeEnabled: _, analysisType: y, serverFunnelQuery: b, serverFlowQuery: x, serverRetentionQuery: S, retentionValidation: C } = e, { getFieldLabel: w } = v(), T = y === "funnel" || _, E = y === "flow", D = y === "retention", O = y === "query" && i, k = y === "query" && !i, A = y === "funnel" && !!b, ee = L(() => A || !T || !c || n.length < 2 ? null : g(n, c), [
2335
- A,
2336
- T,
3126
+ function en(e) {
3127
+ let { currentQuery: t, allQueries: n, multiQueryConfig: r, isMultiQueryMode: i, isValidQuery: a, initialData: o, mergeStrategy: s, funnelBindingKey: c, isFunnelModeEnabled: l, analysisType: u, serverFunnelQuery: d, serverFlowQuery: f, serverRetentionQuery: p, retentionValidation: _ } = e, { getFieldLabel: b } = ne(), S = u === "funnel" || l, C = u === "flow", w = u === "retention", T = u === "query" && i, E = u === "query" && !i, re = u === "funnel" && !!d, D = B(() => re || !S || !c || n.length < 2 ? null : te(n, c), [
3128
+ re,
3129
+ S,
2337
3130
  c,
2338
3131
  n
2339
- ]), j = u(t, {
2340
- skip: !a || !k,
3132
+ ]), O = h(t, {
3133
+ skip: !a || !E,
2341
3134
  debounceMs: 300
2342
- }), M = d(r, {
2343
- skip: !r || !O,
3135
+ }), k = g(r, {
3136
+ skip: !r || !T,
2344
3137
  debounceMs: 300
2345
- }), N = p(ee, {
2346
- skip: !T || !ee && !b,
3138
+ }), A = y(D, {
3139
+ skip: !S || !D && !d,
2347
3140
  debounceMs: 300,
2348
- prebuiltServerQuery: A ? b : void 0
2349
- }), F = l(x ?? null, {
2350
- skip: !E || !x,
3141
+ prebuiltServerQuery: re ? d : void 0
3142
+ }), j = m(f ?? null, {
3143
+ skip: !C || !f,
2351
3144
  debounceMs: 300
2352
- }), I = f(S ?? null, {
2353
- skip: !D || !S,
3145
+ }), M = v(p ?? null, {
3146
+ skip: !w || !p,
2354
3147
  debounceMs: 300,
2355
- getFieldLabel: w
2356
- }), te = h({
3148
+ getFieldLabel: b
3149
+ }), ie = ee({
2357
3150
  queries: i ? n : [t],
2358
3151
  isMultiQueryMode: i,
2359
- skip: !a || T || E || D
2360
- }), R = m(N.serverQuery, { skip: !T || !N.serverQuery }), z = m(F.serverQuery, { skip: !E || !F.serverQuery }), B = m(S, { skip: !D || !S }), V = D ? I.isLoading || I.isDebouncing : E ? F.isLoading || F.isDebouncing : T ? N.isExecuting || N.isDebouncing : O ? M.isLoading : j.isLoading, ne = D ? I.isFetching : E ? F.isFetching : T ? N.isExecuting : O ? M.isFetching : j.isFetching, re = D ? I.error : E ? F.error : T ? N.error : O ? M.error : j.error, H = !!(j.debouncedQuery || M.debouncedConfig || !N.isDebouncing || !F.isDebouncing || !I.isDebouncing), ie = P((e) => {
2361
- D ? I.execute(e) : E ? F.refetch(e) : T ? N.execute(e) : O ? M.refetch(e) : j.refetch(e);
3152
+ skip: !a || S || C || w
3153
+ }), N = x(A.serverQuery, { skip: !S || !A.serverQuery }), P = x(j.serverQuery, { skip: !C || !j.serverQuery }), ae = x(p, { skip: !w || !p }), F = w ? M.isLoading || M.isDebouncing : C ? j.isLoading || j.isDebouncing : S ? A.isExecuting || A.isDebouncing : T ? k.isLoading : O.isLoading, oe = w ? M.isFetching : C ? j.isFetching : S ? A.isExecuting : T ? k.isFetching : O.isFetching, I = w ? M.error : C ? j.error : S ? A.error : T ? k.error : O.error, se = !!(O.debouncedQuery || k.debouncedConfig || !A.isDebouncing || !j.isDebouncing || !M.isDebouncing), L = R((e) => {
3154
+ w ? M.execute(e) : C ? j.refetch(e) : S ? A.execute(e) : T ? k.refetch(e) : O.refetch(e);
2362
3155
  }, [
2363
- D,
2364
- E,
3156
+ w,
3157
+ C,
3158
+ S,
2365
3159
  T,
2366
- O,
2367
- I,
2368
- F,
2369
- N,
2370
3160
  M,
2371
- j
2372
- ]), ae = L(() => {
2373
- let e = D ? I.chartData : E ? F.data : T ? N.chartData : O ? M.data : j.rawData;
2374
- return o && o.length > 0 && !e ? "success" : a ? V && !e ? "loading" : ne && e ? "refreshing" : re ? "error" : e ? "success" : "idle" : "idle";
3161
+ j,
3162
+ A,
3163
+ k,
3164
+ O
3165
+ ]), ce = B(() => {
3166
+ let e = w ? M.chartData : C ? j.data : S ? A.chartData : T ? k.data : O.rawData;
3167
+ return o && o.length > 0 && !e ? "success" : a ? F && !e ? "loading" : oe && e ? "refreshing" : I ? "error" : e ? "success" : "idle" : "idle";
2375
3168
  }, [
2376
3169
  a,
2377
- V,
2378
- ne,
2379
- re,
2380
- j.rawData,
2381
- M.data,
2382
- N.chartData,
2383
- F.data,
2384
- I.chartData,
3170
+ F,
3171
+ oe,
3172
+ I,
3173
+ O.rawData,
3174
+ k.data,
3175
+ A.chartData,
3176
+ j.data,
3177
+ M.chartData,
2385
3178
  o,
2386
- O,
2387
3179
  T,
2388
- E,
2389
- D
2390
- ]), oe = L(() => D && I.chartData ? I.chartData.rows.map((e) => ({
3180
+ S,
3181
+ C,
3182
+ w
3183
+ ]), z = B(() => w && M.chartData ? M.chartData.rows.map((e) => ({
2391
3184
  "Retention.period": `P${e.period}`,
2392
3185
  "Retention.rate": e.retentionRate,
2393
3186
  "Retention.retained": e.retainedUsers,
2394
3187
  "Retention.cohortSize": e.cohortSize,
2395
3188
  "Retention.segment": e.breakdownValue || "All Users"
2396
- })) : E && F.data ? [F.data] : T && N.chartData ? N.chartData : O && M.data ? M.data : j.rawData ? j.rawData : o && o.length > 0 ? o : null, [
2397
- j.rawData,
2398
- M.data,
2399
- N.chartData,
2400
- F.data,
2401
- I.chartData,
3189
+ })) : C && j.data ? [j.data] : S && A.chartData ? A.chartData : T && k.data ? k.data : O.rawData ? O.rawData : o && o.length > 0 ? o : null, [
3190
+ O.rawData,
3191
+ k.data,
3192
+ A.chartData,
3193
+ j.data,
3194
+ M.chartData,
2402
3195
  o,
2403
- O,
2404
3196
  T,
2405
- E,
2406
- D
2407
- ]), se = L(() => T && N.stepResults ? N.stepResults.map((e) => e.data) : !O || !M.perQueryData ? null : M.perQueryData, [
2408
- O,
3197
+ S,
3198
+ C,
3199
+ w
3200
+ ]), V = B(() => S && A.stepResults ? A.stepResults.map((e) => e.data) : !T || !k.perQueryData ? null : k.perQueryData, [
2409
3201
  T,
2410
- M.perQueryData,
2411
- N.stepResults
2412
- ]), ce = T && N.executedQueries?.length > 0 ? N.executedQueries : null, U = T ? N.serverQuery : null, le = T ? R.debugData : null, ue = E ? F.serverQuery : null, de = E ? F.data : null, fe = E ? z.debugData : null, pe = D ? S ?? null : null, W = D ? I.chartData : null, me = D ? B.debugData : null, he = L(() => D ? I.needsRefresh : E ? F.needsRefresh : T ? N.needsRefresh : O ? !1 : j.needsRefresh, [
2413
- D,
2414
- E,
3202
+ S,
3203
+ k.perQueryData,
3204
+ A.stepResults
3205
+ ]), H = S && A.executedQueries?.length > 0 ? A.executedQueries : null, U = S ? A.serverQuery : null, W = S ? N.debugData : null, G = C ? j.serverQuery : null, le = C ? j.data : null, ue = C ? P.debugData : null, de = w ? p ?? null : null, fe = w ? M.chartData : null, pe = w ? ae.debugData : null, me = B(() => w ? M.needsRefresh : C ? j.needsRefresh : S ? A.needsRefresh : T ? !1 : O.needsRefresh, [
3206
+ w,
3207
+ C,
3208
+ S,
2415
3209
  T,
2416
- O,
2417
- I.needsRefresh,
2418
- F.needsRefresh,
2419
- N.needsRefresh,
2420
- j.needsRefresh
2421
- ]), ge = L(() => {
2422
- if (k && j.warnings) return j.warnings;
2423
- }, [k, j.warnings]);
3210
+ M.needsRefresh,
3211
+ j.needsRefresh,
3212
+ A.needsRefresh,
3213
+ O.needsRefresh
3214
+ ]), he = B(() => {
3215
+ if (E && O.warnings) return O.warnings;
3216
+ }, [E, O.warnings]);
2424
3217
  return {
2425
- executionStatus: ae,
2426
- executionResults: oe,
2427
- perQueryResults: se,
2428
- isLoading: V,
2429
- isFetching: ne,
2430
- error: re,
2431
- debugDataPerQuery: te.debugDataPerQuery,
2432
- hasDebounced: H,
2433
- refetch: ie,
2434
- funnelExecutedQueries: ce,
3218
+ executionStatus: ce,
3219
+ executionResults: z,
3220
+ perQueryResults: V,
3221
+ isLoading: F,
3222
+ isFetching: oe,
3223
+ error: I,
3224
+ debugDataPerQuery: ie.debugDataPerQuery,
3225
+ hasDebounced: se,
3226
+ refetch: L,
3227
+ funnelExecutedQueries: H,
2435
3228
  funnelServerQuery: U,
2436
- funnelDebugData: le,
2437
- flowServerQuery: ue,
2438
- flowChartData: de,
2439
- flowDebugData: fe,
2440
- retentionServerQuery: pe,
2441
- retentionChartData: W,
2442
- retentionDebugData: me,
2443
- retentionValidation: C ?? null,
2444
- needsRefresh: he,
2445
- warnings: ge
3229
+ funnelDebugData: W,
3230
+ flowServerQuery: G,
3231
+ flowChartData: le,
3232
+ flowDebugData: ue,
3233
+ retentionServerQuery: de,
3234
+ retentionChartData: fe,
3235
+ retentionDebugData: pe,
3236
+ retentionValidation: _ ?? null,
3237
+ needsRefresh: me,
3238
+ warnings: he
2446
3239
  };
2447
3240
  }
2448
3241
  //#endregion
2449
3242
  //#region src/client/hooks/useAnalysisChartDefaults.ts
2450
- function bt(e) {
2451
- let { externalColorPalette: t, combinedMetrics: r, combinedBreakdowns: i, hasDebounced: a } = e, o = Q((e) => e.analysisType), { chartType: s, chartConfig: c, displayConfig: l } = Q(n($)), u = Q((e) => e.userManuallySelectedChart), d = Q((e) => e.localPaletteName), f = Q((e) => e.setChartTypeManual), p = Q((e) => e.setChartConfig), m = Q((e) => e.setDisplayConfig), h = Q((e) => e.setFunnelChartType), g = Q((e) => e.setFunnelChartConfig), _ = Q((e) => e.setFunnelDisplayConfig), v = Q((e) => e.setLocalPaletteName), y = Q((e) => e.setUserManuallySelectedChart), b = P((e) => {
3243
+ function tn(e) {
3244
+ let { externalColorPalette: t, combinedMetrics: r, combinedBreakdowns: i, hasDebounced: a } = e, o = $((e) => e.analysisType), { chartType: s, chartConfig: c, displayConfig: l } = $(n(Bt)), u = $((e) => e.userManuallySelectedChart), d = $((e) => e.localPaletteName), f = $((e) => e.setChartTypeManual), p = $((e) => e.setChartConfig), m = $((e) => e.setDisplayConfig), h = $((e) => e.setFunnelChartType), g = $((e) => e.setFunnelChartConfig), _ = $((e) => e.setFunnelDisplayConfig), v = $((e) => e.setLocalPaletteName), y = $((e) => e.setUserManuallySelectedChart), b = R((e) => {
2452
3245
  if (o === "funnel") h(e);
2453
3246
  else {
2454
3247
  f(e);
2455
- let { chartConfig: t } = ge(r, i, e);
3248
+ let { chartConfig: t } = Ke(r, i, e);
2456
3249
  p(t);
2457
3250
  }
2458
3251
  }, [
@@ -2462,25 +3255,25 @@ function bt(e) {
2462
3255
  h,
2463
3256
  f,
2464
3257
  p
2465
- ]), x = P((e) => {
3258
+ ]), x = R((e) => {
2466
3259
  o === "funnel" ? g(e) : p(e);
2467
3260
  }, [
2468
3261
  o,
2469
3262
  g,
2470
3263
  p
2471
- ]), S = P((e) => {
3264
+ ]), ee = R((e) => {
2472
3265
  o === "funnel" ? _(e) : m(e);
2473
3266
  }, [
2474
3267
  o,
2475
3268
  _,
2476
3269
  m
2477
- ]), C = L(() => me(r, i), [r, i]), w = L(() => t ? Array.isArray(t) && typeof t[0] == "string" ? {
3270
+ ]), te = B(() => We(r, i), [r, i]), S = B(() => t ? Array.isArray(t) && typeof t[0] == "string" ? {
2478
3271
  name: "custom",
2479
3272
  label: "Custom",
2480
3273
  colors: t,
2481
3274
  gradient: t
2482
- } : t : O(d), [t, d]), T = te("");
2483
- return I(() => {
3275
+ } : t : M(d), [t, d]), ne = V("");
3276
+ return z(() => {
2484
3277
  if (!a || r.length === 0 && i.length === 0) return;
2485
3278
  let e = JSON.stringify({
2486
3279
  metrics: r.map((e) => e.field),
@@ -2489,14 +3282,14 @@ function bt(e) {
2489
3282
  isTime: e.isTimeDimension
2490
3283
  }))
2491
3284
  });
2492
- if (e === T.current) return;
2493
- T.current = e;
2494
- let t = ve(r, i, s, u);
3285
+ if (e === ne.current) return;
3286
+ ne.current = e;
3287
+ let t = Je(r, i, s, u);
2495
3288
  if (t) {
2496
- let { chartConfig: e } = ge(r, i, t);
3289
+ let { chartConfig: e } = Ke(r, i, t);
2497
3290
  b(t), x(e), y(!1);
2498
3291
  } else if ((r.length > 0 || i.length > 0) && !c.xAxis?.length && !c.yAxis?.length && !c.series?.length) {
2499
- let { chartConfig: e } = ge(r, i, s);
3292
+ let { chartConfig: e } = Ke(r, i, s);
2500
3293
  x(e);
2501
3294
  }
2502
3295
  }, [
@@ -2513,20 +3306,20 @@ function bt(e) {
2513
3306
  chartType: s,
2514
3307
  chartConfig: c,
2515
3308
  displayConfig: l,
2516
- colorPalette: w,
3309
+ colorPalette: S,
2517
3310
  localPaletteName: d,
2518
- chartAvailability: C,
3311
+ chartAvailability: te,
2519
3312
  userManuallySelectedChart: u,
2520
3313
  setChartType: b,
2521
3314
  setChartConfig: x,
2522
- setDisplayConfig: S,
3315
+ setDisplayConfig: ee,
2523
3316
  setLocalPaletteName: v
2524
3317
  };
2525
3318
  }
2526
3319
  //#endregion
2527
3320
  //#region src/client/hooks/useAnalysisUIState.ts
2528
- function xt() {
2529
- let e = Q((e) => e.activeTab), t = Q((e) => e.activeView), n = Q((e) => e.displayLimit), r = Q((e) => e.showFieldModal), i = Q((e) => e.fieldModalMode), a = Q((e) => e.userManuallySelectedChart), o = Q((e) => e.setActiveTab), s = Q((e) => e.setActiveView), c = Q((e) => e.setDisplayLimit), l = Q((e) => e.closeFieldModal), [u, d] = R(0);
3321
+ function nn() {
3322
+ let e = $((e) => e.activeTab), t = $((e) => e.activeView), n = $((e) => e.displayLimit), r = $((e) => e.showFieldModal), i = $((e) => e.fieldModalMode), a = $((e) => e.userManuallySelectedChart), o = $((e) => e.setActiveTab), s = $((e) => e.setActiveView), c = $((e) => e.setDisplayLimit), l = $((e) => e.closeFieldModal), [u, d] = H(0);
2530
3323
  return {
2531
3324
  activeTab: e,
2532
3325
  activeView: t,
@@ -2544,42 +3337,42 @@ function xt() {
2544
3337
  }
2545
3338
  //#endregion
2546
3339
  //#region src/client/utils/shareUtils.ts
2547
- var St = o(), Ct = 1800, wt = "share=";
2548
- function Tt(e) {
2549
- return (0, St.compressToEncodedURIComponent)(JSON.stringify(e));
3340
+ var rn = o(), an = 1800, on = "share=";
3341
+ function sn(e) {
3342
+ return (0, rn.compressToEncodedURIComponent)(JSON.stringify(e));
2550
3343
  }
2551
- function Et(e) {
3344
+ function cn(e) {
2552
3345
  try {
2553
- let t = (0, St.decompressFromEncodedURIComponent)(e);
3346
+ let t = (0, rn.decompressFromEncodedURIComponent)(e);
2554
3347
  if (!t) return null;
2555
3348
  let n = JSON.parse(t);
2556
- return S(n) ? n : (console.warn("[shareUtils] Invalid AnalysisConfig in share URL"), null);
3349
+ return E(n) ? n : (console.warn("[shareUtils] Invalid AnalysisConfig in share URL"), null);
2557
3350
  } catch {
2558
3351
  return null;
2559
3352
  }
2560
3353
  }
2561
- function Dt(e) {
2562
- let t = Tt(e);
3354
+ function ln(e) {
3355
+ let t = sn(e);
2563
3356
  return {
2564
- ok: t.length <= Ct,
3357
+ ok: t.length <= an,
2565
3358
  size: t.length,
2566
- maxSize: Ct
3359
+ maxSize: an
2567
3360
  };
2568
3361
  }
2569
- function Ot(e) {
2570
- let t = Tt(e);
2571
- if (t.length <= Ct) return {
3362
+ function un(e) {
3363
+ let t = sn(e);
3364
+ if (t.length <= an) return {
2572
3365
  encoded: t,
2573
3366
  queryOnly: !1
2574
3367
  };
2575
- let n = Tt({
3368
+ let n = sn({
2576
3369
  version: e.version,
2577
3370
  analysisType: e.analysisType,
2578
3371
  activeView: e.activeView,
2579
3372
  charts: {},
2580
3373
  query: e.query
2581
3374
  });
2582
- return n.length <= Ct ? {
3375
+ return n.length <= an ? {
2583
3376
  encoded: n,
2584
3377
  queryOnly: !0
2585
3378
  } : {
@@ -2587,40 +3380,40 @@ function Ot(e) {
2587
3380
  queryOnly: !0
2588
3381
  };
2589
3382
  }
2590
- function kt(e) {
2591
- let { encoded: t } = Ot(e);
2592
- return t ? `${window.location.origin}${window.location.pathname}#${wt}${t}` : null;
3383
+ function dn(e) {
3384
+ let { encoded: t } = un(e);
3385
+ return t ? `${window.location.origin}${window.location.pathname}#${on}${t}` : null;
2593
3386
  }
2594
- function At() {
3387
+ function fn() {
2595
3388
  if (typeof window > "u") return null;
2596
3389
  let e = window.location.hash;
2597
- return !e || !e.startsWith(`#${wt}`) ? null : e.slice(7);
3390
+ return !e || !e.startsWith(`#${on}`) ? null : e.slice(7);
2598
3391
  }
2599
- function jt() {
3392
+ function pn() {
2600
3393
  if (typeof window > "u") return;
2601
3394
  let e = new URL(window.location.href);
2602
3395
  e.hash = "", window.history.replaceState(null, "", e.toString());
2603
3396
  }
2604
- function Mt() {
2605
- let e = At();
2606
- return e ? Et(e) : null;
3397
+ function mn() {
3398
+ let e = fn();
3399
+ return e ? cn(e) : null;
2607
3400
  }
2608
3401
  //#endregion
2609
3402
  //#region src/client/hooks/useAnalysisInitialization.ts
2610
- function Nt(e) {
2611
- let { currentQuery: t, isValidQuery: n, chartType: r, chartConfig: i, displayConfig: a, onQueryChange: o, onChartConfigChange: s } = e, c = Q((e) => e.load), l = te(!1);
2612
- I(() => {
3403
+ function hn(e) {
3404
+ let { currentQuery: t, isValidQuery: n, chartType: r, chartConfig: i, displayConfig: a, onQueryChange: o, onChartConfigChange: s } = e, c = $((e) => e.load), l = V(!1);
3405
+ z(() => {
2613
3406
  if (l.current) return;
2614
3407
  l.current = !0;
2615
- let e = Mt();
2616
- e && (c(e), jt());
2617
- }, [c]), I(() => {
3408
+ let e = mn();
3409
+ e && (c(e), pn());
3410
+ }, [c]), z(() => {
2618
3411
  o && n && o(t);
2619
3412
  }, [
2620
3413
  t,
2621
3414
  n,
2622
3415
  o
2623
- ]), I(() => {
3416
+ ]), z(() => {
2624
3417
  s && s({
2625
3418
  chartType: r,
2626
3419
  chartConfig: i,
@@ -2635,99 +3428,99 @@ function Nt(e) {
2635
3428
  }
2636
3429
  //#endregion
2637
3430
  //#region src/client/hooks/useAnalysisBuilderHook.ts
2638
- function Pt(e = {}) {
2639
- let { initialData: t, externalColorPalette: n, onQueryChange: r, onChartConfigChange: i } = e, { features: a } = s(), o = tt(), c = _t(), l = vt({
3431
+ function gn(e = {}) {
3432
+ let { initialData: t, externalColorPalette: n, onQueryChange: r, onChartConfigChange: i } = e, { features: a } = s(), o = Ft(), c = Qt(), l = $t({
2640
3433
  queryState: c.queryState,
2641
3434
  queryStates: c.queryStates,
2642
3435
  isMultiQueryMode: c.isMultiQueryMode,
2643
3436
  mergeStrategy: c.mergeStrategy,
2644
3437
  activeQueryIndex: c.activeQueryIndex
2645
- }), u = Q((e) => e.funnelBindingKey), d = Q((e) => e.analysisType), f = Q((e) => e.funnelCube), p = Q((e) => e.funnelSteps), m = Q((e) => e.activeFunnelStepIndex), h = Q((e) => e.funnelTimeDimension), g = L(() => d !== "funnel" || !u?.dimension || !h || !p || p.length < 2 ? !1 : p.every((e) => e.filters.length > 0), [
3438
+ }), u = $((e) => e.funnelBindingKey), d = $((e) => e.analysisType), f = $((e) => e.funnelCube), p = $((e) => e.funnelSteps), m = $((e) => e.activeFunnelStepIndex), h = $((e) => e.funnelTimeDimension), g = B(() => d !== "funnel" || !u?.dimension || !h || !p || p.length < 2 ? !1 : p.every((e) => e.filters.length > 0), [
2646
3439
  d,
2647
3440
  u,
2648
3441
  h,
2649
3442
  p
2650
- ]), _ = Q((e) => e.charts.funnel?.chartType) || "funnel", v = Q((e) => e.charts.funnel?.chartConfig), y = L(() => v || {}, [v]), b = Q((e) => e.flowCube), x = Q((e) => e.flowBindingKey), S = Q((e) => e.flowTimeDimension), C = Q((e) => e.eventDimension), w = Q((e) => e.startingStep), T = Q((e) => e.stepsBefore), E = Q((e) => e.stepsAfter), D = Q((e) => e.joinStrategy), O = Q((e) => e.charts.flow?.displayConfig), k = L(() => O || {
3443
+ ]), _ = $((e) => e.charts.funnel?.chartType) || "funnel", v = $((e) => e.charts.funnel?.chartConfig), y = B(() => v || {}, [v]), b = $((e) => e.flowCube), x = $((e) => e.flowBindingKey), ee = $((e) => e.flowTimeDimension), te = $((e) => e.eventDimension), S = $((e) => e.startingStep), ne = $((e) => e.stepsBefore), C = $((e) => e.stepsAfter), w = $((e) => e.joinStrategy), T = $((e) => e.charts.flow?.displayConfig), E = B(() => T || {
2651
3444
  showLegend: !0,
2652
3445
  showGrid: !0,
2653
3446
  showTooltip: !0
2654
- }, [O]), A = Q((e) => e.charts.flow?.chartType) || "sankey", ee = Q((e) => e.buildFunnelQueryFromSteps), j = L(() => d === "funnel" ? ee() : null, [
3447
+ }, [T]), re = $((e) => e.charts.flow?.chartType) || "sankey", D = $((e) => e.buildFunnelQueryFromSteps), O = B(() => d === "funnel" ? D() : null, [
2655
3448
  d,
2656
- ee,
3449
+ D,
2657
3450
  p
2658
- ]), M = Q((e) => e.buildFlowQuery), N = L(() => d === "flow" ? M() : null, [
3451
+ ]), k = $((e) => e.buildFlowQuery), A = B(() => d === "flow" ? k() : null, [
2659
3452
  d,
2660
- M,
3453
+ k,
2661
3454
  b,
2662
3455
  x,
3456
+ ee,
3457
+ te,
2663
3458
  S,
2664
- C,
2665
- w,
2666
- T,
2667
- E,
2668
- A,
2669
- D
2670
- ]), F = Q((e) => e.retentionCube), I = Q((e) => e.retentionBindingKey), R = Q((e) => e.retentionTimeDimension), z = Q((e) => e.retentionDateRange), B = Q((e) => e.retentionCohortFilters), V = Q((e) => e.retentionActivityFilters), ne = Q((e) => e.retentionBreakdowns), re = Q((e) => e.retentionViewGranularity), H = Q((e) => e.retentionPeriods), ie = Q((e) => e.retentionType), ae = Q((e) => e.buildRetentionQuery), oe = Q((e) => e.getRetentionValidation), se = Q((e) => e.charts.retention?.displayConfig), ce = Q((e) => e.setRetentionCube), U = Q((e) => e.setRetentionBindingKey), le = Q((e) => e.setRetentionTimeDimension), ue = Q((e) => e.setRetentionDateRange), de = Q((e) => e.setRetentionCohortFilters), fe = Q((e) => e.setRetentionActivityFilters), pe = Q((e) => e.setRetentionBreakdowns), W = Q((e) => e.addRetentionBreakdown), me = Q((e) => e.removeRetentionBreakdown), he = Q((e) => e.setRetentionViewGranularity), ge = Q((e) => e.setRetentionPeriods), _e = Q((e) => e.setRetentionType), ve = L(() => d === "retention" ? ae() : null, [
2671
- d,
2672
- ae,
2673
- F,
2674
- I,
2675
- R,
2676
- z,
2677
3459
  ne,
3460
+ C,
2678
3461
  re,
2679
- H,
2680
- ie,
2681
- B,
2682
- V
2683
- ]), G = L(() => d === "retention" ? oe() : null, [
3462
+ w
3463
+ ]), j = $((e) => e.retentionCube), M = $((e) => e.retentionBindingKey), ie = $((e) => e.retentionTimeDimension), N = $((e) => e.retentionDateRange), P = $((e) => e.retentionCohortFilters), ae = $((e) => e.retentionActivityFilters), F = $((e) => e.retentionBreakdowns), oe = $((e) => e.retentionViewGranularity), I = $((e) => e.retentionPeriods), se = $((e) => e.retentionType), L = $((e) => e.buildRetentionQuery), ce = $((e) => e.getRetentionValidation), z = $((e) => e.charts.retention?.displayConfig), H = $((e) => e.setRetentionCube), U = $((e) => e.setRetentionBindingKey), W = $((e) => e.setRetentionTimeDimension), G = $((e) => e.setRetentionDateRange), le = $((e) => e.setRetentionCohortFilters), ue = $((e) => e.setRetentionActivityFilters), de = $((e) => e.setRetentionBreakdowns), fe = $((e) => e.addRetentionBreakdown), pe = $((e) => e.removeRetentionBreakdown), me = $((e) => e.setRetentionViewGranularity), he = $((e) => e.setRetentionPeriods), ge = $((e) => e.setRetentionType), K = B(() => d === "retention" ? L() : null, [
2684
3464
  d,
2685
- oe,
3465
+ L,
3466
+ j,
3467
+ M,
3468
+ ie,
3469
+ N,
2686
3470
  F,
3471
+ oe,
2687
3472
  I,
2688
- R,
2689
- z
2690
- ]), ye = L(() => d === "retention" ? ve !== null : d === "flow" ? N !== null : d === "funnel" ? j !== null : c.isValidQuery ?? !1, [
3473
+ se,
3474
+ P,
3475
+ ae
3476
+ ]), _e = B(() => d === "retention" ? ce() : null, [
2691
3477
  d,
2692
- ve,
2693
- N,
3478
+ ce,
2694
3479
  j,
3480
+ M,
3481
+ ie,
3482
+ N
3483
+ ]), ve = B(() => d === "retention" ? K !== null : d === "flow" ? A !== null : d === "funnel" ? O !== null : c.isValidQuery ?? !1, [
3484
+ d,
3485
+ K,
3486
+ A,
3487
+ O,
2695
3488
  c.isValidQuery
2696
- ]), K = yt({
3489
+ ]), q = en({
2697
3490
  currentQuery: c.currentQuery,
2698
3491
  allQueries: c.allQueries,
2699
3492
  multiQueryConfig: c.multiQueryConfig,
2700
3493
  isMultiQueryMode: c.isMultiQueryMode,
2701
- isValidQuery: ye,
3494
+ isValidQuery: ve,
2702
3495
  initialData: t,
2703
3496
  mergeStrategy: c.mergeStrategy,
2704
3497
  funnelBindingKey: u,
2705
3498
  isFunnelModeEnabled: g,
2706
3499
  analysisType: d,
2707
- serverFunnelQuery: j,
2708
- serverFlowQuery: N,
2709
- serverRetentionQuery: ve,
2710
- retentionValidation: G
2711
- }), q = bt({
3500
+ serverFunnelQuery: O,
3501
+ serverFlowQuery: A,
3502
+ serverRetentionQuery: K,
3503
+ retentionValidation: _e
3504
+ }), J = tn({
2712
3505
  externalColorPalette: n,
2713
3506
  combinedMetrics: l.combinedMetrics,
2714
3507
  combinedBreakdowns: l.combinedBreakdowns,
2715
- hasDebounced: K.hasDebounced
2716
- }), J = xt();
2717
- Nt({
3508
+ hasDebounced: q.hasDebounced
3509
+ }), Y = nn();
3510
+ hn({
2718
3511
  currentQuery: c.currentQuery,
2719
3512
  isValidQuery: c.isValidQuery ?? !1,
2720
- chartType: q.chartType,
2721
- chartConfig: q.chartConfig,
2722
- displayConfig: q.displayConfig,
3513
+ chartType: J.chartType,
3514
+ chartConfig: J.chartConfig,
3515
+ displayConfig: J.displayConfig,
2723
3516
  onQueryChange: r,
2724
3517
  onChartConfigChange: i
2725
3518
  });
2726
- let be = Q((e) => e.openMetricsModal), xe = Q((e) => e.addMetric), Se = Q((e) => e.removeMetric), Ce = Q((e) => e.toggleMetric), we = Q((e) => e.reorderMetrics), Te = Q((e) => e.openBreakdownsModal), Ee = Q((e) => e.addBreakdown), De = Q((e) => e.removeBreakdown), Oe = Q((e) => e.toggleBreakdown), ke = Q((e) => e.setBreakdownGranularity), Ae = Q((e) => e.toggleBreakdownComparison), je = Q((e) => e.reorderBreakdowns), Me = Q((e) => e.setFilters), Y = Q((e) => e.dropFieldToFilter), X = Q((e) => e.setOrder), Ne = Q((e) => e.clearQuery), Pe = Q((e) => e.clearCurrentMode), Z = Q((e) => e.setFunnelBindingKey), Fe = Q((e) => e.setAnalysisType), Ie = Q((e) => e.setFunnelCube), Le = Q((e) => e.addFunnelStep), Re = Q((e) => e.removeFunnelStep), ze = Q((e) => e.updateFunnelStep), Be = Q((e) => e.setActiveFunnelStepIndex), Ve = Q((e) => e.reorderFunnelSteps), He = Q((e) => e.setFunnelTimeDimension), Ue = Q((e) => e.charts.funnel?.displayConfig), We = L(() => Ue || {
3519
+ let ye = $((e) => e.openMetricsModal), be = $((e) => e.addMetric), xe = $((e) => e.removeMetric), Se = $((e) => e.toggleMetric), Ce = $((e) => e.reorderMetrics), we = $((e) => e.openBreakdownsModal), Te = $((e) => e.addBreakdown), Ee = $((e) => e.removeBreakdown), De = $((e) => e.toggleBreakdown), Oe = $((e) => e.setBreakdownGranularity), ke = $((e) => e.toggleBreakdownComparison), Ae = $((e) => e.reorderBreakdowns), je = $((e) => e.setFilters), Me = $((e) => e.dropFieldToFilter), Ne = $((e) => e.setOrder), Pe = $((e) => e.setLimit), Fe = $((e) => e.clearQuery), Ie = $((e) => e.clearCurrentMode), Le = $((e) => e.setFunnelBindingKey), Re = $((e) => e.setAnalysisType), ze = $((e) => e.setFunnelCube), Be = $((e) => e.addFunnelStep), Ve = $((e) => e.removeFunnelStep), He = $((e) => e.updateFunnelStep), Ue = $((e) => e.setActiveFunnelStepIndex), We = $((e) => e.reorderFunnelSteps), Ge = $((e) => e.setFunnelTimeDimension), Ke = $((e) => e.charts.funnel?.displayConfig), qe = B(() => Ke || {
2727
3520
  showLegend: !0,
2728
3521
  showGrid: !0,
2729
3522
  showTooltip: !0
2730
- }, [Ue]), Ge = Q((e) => e.setFunnelDisplayConfig), Ke = Q((e) => e.setFlowCube), qe = Q((e) => e.setFlowBindingKey), Je = Q((e) => e.setFlowTimeDimension), Ye = Q((e) => e.setEventDimension), Xe = Q((e) => e.setStartingStepName), Ze = Q((e) => e.setStartingStepFilters), Qe = Q((e) => e.setStepsBefore), $e = Q((e) => e.setStepsAfter), et = Q((e) => e.setJoinStrategy), nt = P((e) => {
3523
+ }, [Ke]), Je = $((e) => e.setFunnelDisplayConfig), Ye = $((e) => e.setFlowCube), Xe = $((e) => e.setFlowBindingKey), Ze = $((e) => e.setFlowTimeDimension), Qe = $((e) => e.setEventDimension), $e = $((e) => e.setStartingStepName), et = $((e) => e.setStartingStepFilters), tt = $((e) => e.setStepsBefore), nt = $((e) => e.setStepsAfter), rt = $((e) => e.setJoinStrategy), it = R((e) => {
2731
3524
  o.setState((t) => ({ charts: {
2732
3525
  ...t.charts,
2733
3526
  flow: {
@@ -2739,7 +3532,7 @@ function Pt(e = {}) {
2739
3532
  displayConfig: e
2740
3533
  }
2741
3534
  } }));
2742
- }, [o]), rt = P((e) => {
3535
+ }, [o]), at = R((e) => {
2743
3536
  o.setState((t) => ({ charts: {
2744
3537
  ...t.charts,
2745
3538
  retention: {
@@ -2751,8 +3544,8 @@ function Pt(e = {}) {
2751
3544
  displayConfig: e
2752
3545
  }
2753
3546
  } }));
2754
- }, [o]), it = Q((e) => e.aiState), at = Q((e) => e.openAI), $ = Q((e) => e.closeAI), ot = Q((e) => e.setAIPrompt), st = Q((e) => e.setAIGenerating), ct = Q((e) => e.setAIError), lt = Q((e) => e.setAIHasGeneratedQuery), ut = Q((e) => e.saveAIPreviousState), dt = Q((e) => e.restoreAIPreviousState), ft = te("idle"), pt = ye, mt = Q((e) => e.getValidation), ht = L(() => mt(), [
2755
- mt,
3547
+ }, [o]), ot = $((e) => e.aiState), st = $((e) => e.openAI), ct = $((e) => e.closeAI), lt = $((e) => e.setAIPrompt), ut = $((e) => e.setAIGenerating), dt = $((e) => e.setAIError), ft = $((e) => e.setAIHasGeneratedQuery), X = $((e) => e.saveAIPreviousState), Z = $((e) => e.restoreAIPreviousState), pt = V("idle"), mt = ve, Q = $((e) => e.getValidation), ht = B(() => Q(), [
3548
+ Q,
2756
3549
  c.queryStates,
2757
3550
  d,
2758
3551
  p,
@@ -2760,46 +3553,46 @@ function Pt(e = {}) {
2760
3553
  h,
2761
3554
  b,
2762
3555
  x,
3556
+ ee,
3557
+ te,
2763
3558
  S,
3559
+ ne,
2764
3560
  C,
2765
- w,
2766
- T,
2767
- E,
2768
- D
2769
- ]), gt = P((e, t, n, r) => {
2770
- J.fieldModalMode === "metrics" && t === "measure" ? Ce(e.name) : J.fieldModalMode === "breakdown" && (d === "retention" && t === "dimension" ? W({ field: e.name }) : Oe(e.name, t === "timeDimension")), r || J.closeFieldModal();
3561
+ w
3562
+ ]), gt = R((e, t, n, r) => {
3563
+ Y.fieldModalMode === "metrics" && t === "measure" ? Se(e.name) : Y.fieldModalMode === "breakdown" && (d === "retention" && t === "dimension" ? fe({ field: e.name }) : De(e.name, t === "timeDimension")), r || Y.closeFieldModal();
2771
3564
  }, [
2772
- J,
2773
- Ce,
2774
- Oe,
2775
- W,
3565
+ Y,
3566
+ Se,
3567
+ De,
3568
+ fe,
2776
3569
  d
2777
- ]), St = P(async () => {
3570
+ ]), _t = R(async () => {
2778
3571
  if (a?.aiEndpoint) {
2779
- ut(), st(!0), ct(null);
3572
+ X(), ut(!0), dt(null);
2780
3573
  try {
2781
- await new Promise((e) => setTimeout(e, 1e3)), lt(!0);
3574
+ await new Promise((e) => setTimeout(e, 1e3)), ft(!0);
2782
3575
  } catch (e) {
2783
- ct(e instanceof Error ? e.message : "Failed to generate query");
3576
+ dt(e instanceof Error ? e.message : "Failed to generate query");
2784
3577
  } finally {
2785
- st(!1);
3578
+ ut(!1);
2786
3579
  }
2787
3580
  }
2788
3581
  }, [
2789
3582
  a?.aiEndpoint,
3583
+ X,
2790
3584
  ut,
2791
- st,
2792
- ct,
2793
- lt
2794
- ]), Ct = P(() => {
2795
- $(), lt(!1);
2796
- }, [$, lt]), wt = P(() => {
2797
- dt(), $();
2798
- }, [dt, $]), Tt = P(async () => {
2799
- ft.current = "copied", setTimeout(() => {
2800
- ft.current = "idle";
3585
+ dt,
3586
+ ft
3587
+ ]), vt = R(() => {
3588
+ ct(), ft(!1);
3589
+ }, [ct, ft]), yt = R(() => {
3590
+ Z(), ct();
3591
+ }, [Z, ct]), bt = R(async () => {
3592
+ pt.current = "copied", setTimeout(() => {
3593
+ pt.current = "idle";
2801
3594
  }, 2e3);
2802
- }, []), Et = P(() => {
3595
+ }, []), xt = R(() => {
2803
3596
  let e = o.getState();
2804
3597
  return e.analysisType === "funnel" ? e.buildFunnelQueryFromSteps() || e.buildCurrentQuery() : e.queryStates.length > 1 ? {
2805
3598
  queries: e.buildAllQueries(),
@@ -2809,23 +3602,23 @@ function Pt(e = {}) {
2809
3602
  funnelBindingKey: e.funnelBindingKey,
2810
3603
  stepTimeToConvert: e.stepTimeToConvert
2811
3604
  } : e.buildCurrentQuery();
2812
- }, [o]), Dt = P(() => {
3605
+ }, [o]), St = R(() => {
2813
3606
  let e = o.getState(), t = e.charts[e.analysisType];
2814
3607
  return t ? {
2815
3608
  chartType: t.chartType,
2816
3609
  chartConfig: t.chartConfig,
2817
3610
  displayConfig: t.displayConfig
2818
3611
  } : {
2819
- chartType: q.chartType,
2820
- chartConfig: q.chartConfig,
2821
- displayConfig: q.displayConfig
3612
+ chartType: J.chartType,
3613
+ chartConfig: J.chartConfig,
3614
+ displayConfig: J.displayConfig
2822
3615
  };
2823
3616
  }, [
2824
3617
  o,
2825
- q.chartType,
2826
- q.chartConfig,
2827
- q.displayConfig
2828
- ]), Ot = P(() => o.getState().analysisType, [o]);
3618
+ J.chartType,
3619
+ J.chartConfig,
3620
+ J.displayConfig
3621
+ ]), Ct = R(() => o.getState().analysisType, [o]);
2829
3622
  return {
2830
3623
  queryState: c.queryState,
2831
3624
  queryStates: c.queryStates,
@@ -2846,154 +3639,155 @@ function Pt(e = {}) {
2846
3639
  funnelTimeDimension: h,
2847
3640
  funnelChartType: _,
2848
3641
  funnelChartConfig: y,
2849
- funnelDisplayConfig: We,
3642
+ funnelDisplayConfig: qe,
2850
3643
  flowCube: b,
2851
3644
  flowBindingKey: x,
2852
- flowTimeDimension: S,
2853
- eventDimension: C,
2854
- startingStep: w,
2855
- stepsBefore: T,
2856
- stepsAfter: E,
2857
- joinStrategy: D,
2858
- flowDisplayConfig: k,
2859
- retentionCube: F,
2860
- retentionBindingKey: I,
2861
- retentionTimeDimension: R,
2862
- retentionDateRange: z,
2863
- retentionCohortFilters: B,
2864
- retentionActivityFilters: V,
2865
- retentionBreakdowns: ne,
2866
- retentionViewGranularity: re,
2867
- retentionPeriods: H,
2868
- retentionType: ie,
2869
- retentionDisplayConfig: se,
2870
- executionStatus: K.executionStatus,
2871
- executionResults: K.executionResults,
2872
- perQueryResults: K.perQueryResults,
2873
- isLoading: K.isLoading,
2874
- isFetching: K.isFetching,
2875
- error: K.error,
2876
- isValidQuery: ye,
2877
- debugDataPerQuery: K.debugDataPerQuery,
2878
- needsRefresh: K.needsRefresh,
2879
- warnings: K.warnings,
2880
- funnelExecutedQueries: K.funnelExecutedQueries,
2881
- funnelServerQuery: K.funnelServerQuery,
2882
- funnelDebugData: K.funnelDebugData,
2883
- flowServerQuery: K.flowServerQuery,
2884
- flowDebugData: K.flowDebugData,
2885
- retentionServerQuery: K.retentionServerQuery,
2886
- retentionDebugData: K.retentionDebugData,
2887
- retentionChartData: K.retentionChartData,
2888
- retentionValidation: K.retentionValidation,
2889
- chartType: q.chartType,
2890
- chartConfig: q.chartConfig,
2891
- displayConfig: q.displayConfig,
2892
- colorPalette: q.colorPalette,
2893
- localPaletteName: q.localPaletteName,
2894
- chartAvailability: q.chartAvailability,
3645
+ flowTimeDimension: ee,
3646
+ eventDimension: te,
3647
+ startingStep: S,
3648
+ stepsBefore: ne,
3649
+ stepsAfter: C,
3650
+ joinStrategy: w,
3651
+ flowDisplayConfig: E,
3652
+ retentionCube: j,
3653
+ retentionBindingKey: M,
3654
+ retentionTimeDimension: ie,
3655
+ retentionDateRange: N,
3656
+ retentionCohortFilters: P,
3657
+ retentionActivityFilters: ae,
3658
+ retentionBreakdowns: F,
3659
+ retentionViewGranularity: oe,
3660
+ retentionPeriods: I,
3661
+ retentionType: se,
3662
+ retentionDisplayConfig: z,
3663
+ executionStatus: q.executionStatus,
3664
+ executionResults: q.executionResults,
3665
+ perQueryResults: q.perQueryResults,
3666
+ isLoading: q.isLoading,
3667
+ isFetching: q.isFetching,
3668
+ error: q.error,
3669
+ isValidQuery: ve,
3670
+ debugDataPerQuery: q.debugDataPerQuery,
3671
+ needsRefresh: q.needsRefresh,
3672
+ warnings: q.warnings,
3673
+ funnelExecutedQueries: q.funnelExecutedQueries,
3674
+ funnelServerQuery: q.funnelServerQuery,
3675
+ funnelDebugData: q.funnelDebugData,
3676
+ flowServerQuery: q.flowServerQuery,
3677
+ flowDebugData: q.flowDebugData,
3678
+ retentionServerQuery: q.retentionServerQuery,
3679
+ retentionDebugData: q.retentionDebugData,
3680
+ retentionChartData: q.retentionChartData,
3681
+ retentionValidation: q.retentionValidation,
3682
+ chartType: J.chartType,
3683
+ chartConfig: J.chartConfig,
3684
+ displayConfig: J.displayConfig,
3685
+ colorPalette: J.colorPalette,
3686
+ localPaletteName: J.localPaletteName,
3687
+ chartAvailability: J.chartAvailability,
2895
3688
  combinedMetrics: l.combinedMetrics,
2896
3689
  combinedBreakdowns: l.combinedBreakdowns,
2897
3690
  effectiveBreakdowns: l.effectiveBreakdowns,
2898
- activeTab: J.activeTab,
2899
- activeView: J.activeView,
2900
- displayLimit: J.displayLimit,
2901
- showFieldModal: J.showFieldModal,
2902
- fieldModalMode: J.fieldModalMode,
2903
- activeTableIndex: J.activeTableIndex,
2904
- userManuallySelectedChart: J.userManuallySelectedChart,
3691
+ activeTab: Y.activeTab,
3692
+ activeView: Y.activeView,
3693
+ displayLimit: Y.displayLimit,
3694
+ showFieldModal: Y.showFieldModal,
3695
+ fieldModalMode: Y.fieldModalMode,
3696
+ activeTableIndex: Y.activeTableIndex,
3697
+ userManuallySelectedChart: Y.userManuallySelectedChart,
2905
3698
  aiState: {
2906
- isOpen: it.isOpen,
2907
- userPrompt: it.userPrompt,
2908
- isGenerating: it.isGenerating,
2909
- error: it.error,
2910
- hasGeneratedQuery: it.hasGeneratedQuery
3699
+ isOpen: ot.isOpen,
3700
+ userPrompt: ot.userPrompt,
3701
+ isGenerating: ot.isGenerating,
3702
+ error: ot.error,
3703
+ hasGeneratedQuery: ot.hasGeneratedQuery
2911
3704
  },
2912
- shareButtonState: ft.current,
2913
- canShare: pt,
3705
+ shareButtonState: pt.current,
3706
+ canShare: mt,
2914
3707
  adapterValidation: ht,
2915
3708
  actions: {
2916
3709
  setActiveQueryIndex: c.setActiveQueryIndex,
2917
3710
  setMergeStrategy: c.setMergeStrategy,
2918
- openMetricsModal: be,
2919
- addMetric: xe,
2920
- removeMetric: Se,
2921
- toggleMetric: Ce,
2922
- reorderMetrics: we,
2923
- openBreakdownsModal: Te,
2924
- addBreakdown: Ee,
2925
- removeBreakdown: De,
2926
- toggleBreakdown: Oe,
2927
- setBreakdownGranularity: ke,
2928
- toggleBreakdownComparison: Ae,
2929
- reorderBreakdowns: je,
2930
- setFilters: Me,
2931
- dropFieldToFilter: Y,
2932
- setOrder: X,
3711
+ openMetricsModal: ye,
3712
+ addMetric: be,
3713
+ removeMetric: xe,
3714
+ toggleMetric: Se,
3715
+ reorderMetrics: Ce,
3716
+ openBreakdownsModal: we,
3717
+ addBreakdown: Te,
3718
+ removeBreakdown: Ee,
3719
+ toggleBreakdown: De,
3720
+ setBreakdownGranularity: Oe,
3721
+ toggleBreakdownComparison: ke,
3722
+ reorderBreakdowns: Ae,
3723
+ setFilters: je,
3724
+ dropFieldToFilter: Me,
3725
+ setOrder: Ne,
3726
+ setLimit: Pe,
2933
3727
  addQuery: c.addQuery,
2934
3728
  removeQuery: c.removeQuery,
2935
- setFunnelBindingKey: Z,
2936
- setAnalysisType: Fe,
2937
- setFunnelCube: Ie,
2938
- addFunnelStep: Le,
2939
- removeFunnelStep: Re,
2940
- updateFunnelStep: ze,
2941
- setActiveFunnelStepIndex: Be,
2942
- reorderFunnelSteps: Ve,
2943
- setFunnelTimeDimension: He,
2944
- setFunnelDisplayConfig: Ge,
2945
- setFlowCube: Ke,
2946
- setFlowBindingKey: qe,
2947
- setFlowTimeDimension: Je,
2948
- setEventDimension: Ye,
2949
- setStartingStepName: Xe,
2950
- setStartingStepFilters: Ze,
2951
- setStepsBefore: Qe,
2952
- setStepsAfter: $e,
2953
- setJoinStrategy: et,
2954
- setFlowDisplayConfig: nt,
2955
- setRetentionCube: ce,
3729
+ setFunnelBindingKey: Le,
3730
+ setAnalysisType: Re,
3731
+ setFunnelCube: ze,
3732
+ addFunnelStep: Be,
3733
+ removeFunnelStep: Ve,
3734
+ updateFunnelStep: He,
3735
+ setActiveFunnelStepIndex: Ue,
3736
+ reorderFunnelSteps: We,
3737
+ setFunnelTimeDimension: Ge,
3738
+ setFunnelDisplayConfig: Je,
3739
+ setFlowCube: Ye,
3740
+ setFlowBindingKey: Xe,
3741
+ setFlowTimeDimension: Ze,
3742
+ setEventDimension: Qe,
3743
+ setStartingStepName: $e,
3744
+ setStartingStepFilters: et,
3745
+ setStepsBefore: tt,
3746
+ setStepsAfter: nt,
3747
+ setJoinStrategy: rt,
3748
+ setFlowDisplayConfig: it,
3749
+ setRetentionCube: H,
2956
3750
  setRetentionBindingKey: U,
2957
- setRetentionTimeDimension: le,
2958
- setRetentionDateRange: ue,
2959
- setRetentionCohortFilters: de,
2960
- setRetentionActivityFilters: fe,
2961
- setRetentionBreakdowns: pe,
2962
- addRetentionBreakdown: W,
2963
- removeRetentionBreakdown: me,
2964
- setRetentionViewGranularity: he,
2965
- setRetentionPeriods: ge,
2966
- setRetentionType: _e,
2967
- setRetentionDisplayConfig: rt,
2968
- setChartType: q.setChartType,
2969
- setChartConfig: q.setChartConfig,
2970
- setDisplayConfig: q.setDisplayConfig,
2971
- setLocalPaletteName: q.setLocalPaletteName,
2972
- setActiveTab: J.setActiveTab,
2973
- setActiveView: J.setActiveView,
2974
- setDisplayLimit: J.setDisplayLimit,
2975
- closeFieldModal: J.closeFieldModal,
2976
- setActiveTableIndex: J.setActiveTableIndex,
2977
- openAI: at,
2978
- closeAI: $,
2979
- setAIPrompt: ot,
2980
- generateAI: St,
2981
- acceptAI: Ct,
2982
- cancelAI: wt,
2983
- share: Tt,
2984
- clearQuery: Ne,
2985
- clearCurrentMode: Pe,
2986
- refetch: K.refetch,
3751
+ setRetentionTimeDimension: W,
3752
+ setRetentionDateRange: G,
3753
+ setRetentionCohortFilters: le,
3754
+ setRetentionActivityFilters: ue,
3755
+ setRetentionBreakdowns: de,
3756
+ addRetentionBreakdown: fe,
3757
+ removeRetentionBreakdown: pe,
3758
+ setRetentionViewGranularity: me,
3759
+ setRetentionPeriods: he,
3760
+ setRetentionType: ge,
3761
+ setRetentionDisplayConfig: at,
3762
+ setChartType: J.setChartType,
3763
+ setChartConfig: J.setChartConfig,
3764
+ setDisplayConfig: J.setDisplayConfig,
3765
+ setLocalPaletteName: J.setLocalPaletteName,
3766
+ setActiveTab: Y.setActiveTab,
3767
+ setActiveView: Y.setActiveView,
3768
+ setDisplayLimit: Y.setDisplayLimit,
3769
+ closeFieldModal: Y.closeFieldModal,
3770
+ setActiveTableIndex: Y.setActiveTableIndex,
3771
+ openAI: st,
3772
+ closeAI: ct,
3773
+ setAIPrompt: lt,
3774
+ generateAI: _t,
3775
+ acceptAI: vt,
3776
+ cancelAI: yt,
3777
+ share: bt,
3778
+ clearQuery: Fe,
3779
+ clearCurrentMode: Ie,
3780
+ refetch: q.refetch,
2987
3781
  handleFieldSelected: gt
2988
3782
  },
2989
- getQueryConfig: Et,
2990
- getChartConfig: Dt,
2991
- getAnalysisType: Ot
3783
+ getQueryConfig: xt,
3784
+ getChartConfig: St,
3785
+ getAnalysisType: Ct
2992
3786
  };
2993
3787
  }
2994
3788
  //#endregion
2995
3789
  //#region src/client/utils/funnelValidation.ts
2996
- function Ft(e, t) {
3790
+ function _n(e, t) {
2997
3791
  let n = [];
2998
3792
  if (!t?.cubes) return n;
2999
3793
  if (typeof e.dimension == "string") {
@@ -3017,7 +3811,7 @@ function Ft(e, t) {
3017
3811
  }
3018
3812
  return n;
3019
3813
  }
3020
- function It(e) {
3814
+ function vn(e) {
3021
3815
  let t = [];
3022
3816
  for (let n = 0; n < e.length; n++) {
3023
3817
  let r = e[n], i = r.query;
@@ -3029,17 +3823,17 @@ function It(e) {
3029
3823
  }
3030
3824
  return t;
3031
3825
  }
3032
- function Lt(e, t) {
3826
+ function yn(e, t) {
3033
3827
  if (typeof e.dimension == "string") return !0;
3034
- let n = _(t);
3828
+ let n = S(t);
3035
3829
  return n ? e.dimension.some((e) => e.cube === n) : !1;
3036
3830
  }
3037
- function Rt(e, t) {
3831
+ function bn(e, t) {
3038
3832
  let n = [];
3039
3833
  for (let r = 0; r < t.length; r++) {
3040
3834
  let i = t[r];
3041
- if (!Lt(e, i.query)) {
3042
- let e = _(i.query) || "unknown";
3835
+ if (!yn(e, i.query)) {
3836
+ let e = S(i.query) || "unknown";
3043
3837
  n.push({
3044
3838
  type: "cross_cube",
3045
3839
  message: `Step ${r + 1} uses cube "${e}" but no binding key mapping exists for it`,
@@ -3049,26 +3843,26 @@ function Rt(e, t) {
3049
3843
  }
3050
3844
  return n;
3051
3845
  }
3052
- function zt(e) {
3846
+ function xn(e) {
3053
3847
  return e ? /^P(?:\d+Y)?(?:\d+M)?(?:\d+W)?(?:\d+D)?(?:T(?:\d+H)?(?:\d+M)?(?:\d+S)?)?$/.test(e) ? null : {
3054
3848
  type: "time_window",
3055
3849
  message: `Invalid time window format "${e}". Expected ISO 8601 duration (e.g., P7D, PT1H)`
3056
3850
  } : null;
3057
3851
  }
3058
- function Bt(e, t) {
3852
+ function Sn(e, t) {
3059
3853
  let n = [], r = [];
3060
3854
  e.steps.length < 2 && n.push({
3061
3855
  type: "general",
3062
3856
  message: "Funnel requires at least 2 steps"
3063
- }), e.bindingKey?.dimension ? (n.push(...Ft(e.bindingKey, t)), n.push(...Rt(e.bindingKey, e.steps))) : n.push({
3857
+ }), e.bindingKey?.dimension ? (n.push(..._n(e.bindingKey, t)), n.push(...bn(e.bindingKey, e.steps))) : n.push({
3064
3858
  type: "binding_key",
3065
3859
  message: "Binding key dimension is required"
3066
- }), n.push(...It(e.steps));
3860
+ }), n.push(...vn(e.steps));
3067
3861
  for (let t = 0; t < e.steps.length; t++) {
3068
- let r = e.steps[t], i = zt(r.timeToConvert);
3862
+ let r = e.steps[t], i = xn(r.timeToConvert);
3069
3863
  i && (i.stepIndex = t, n.push(i));
3070
3864
  }
3071
- let i = zt(e.globalTimeWindow);
3865
+ let i = xn(e.globalTimeWindow);
3072
3866
  return i && n.push(i), e.steps.length > 5 && r.push({
3073
3867
  type: "general",
3074
3868
  message: "Funnels with more than 5 steps may have reduced performance"
@@ -3078,7 +3872,7 @@ function Bt(e, t) {
3078
3872
  warnings: r
3079
3873
  };
3080
3874
  }
3081
- function Vt(e, t) {
3875
+ function Cn(e, t) {
3082
3876
  return t < 2 ? {
3083
3877
  isValid: !1,
3084
3878
  message: "Add at least 2 steps for funnel"
@@ -3087,7 +3881,7 @@ function Vt(e, t) {
3087
3881
  message: "Select a binding key dimension"
3088
3882
  } : { isValid: !0 };
3089
3883
  }
3090
- function Ht(e) {
3884
+ function wn(e) {
3091
3885
  if (!e?.cubes) return [];
3092
3886
  let t = [];
3093
3887
  for (let n of e.cubes) if (n.dimensions) for (let e of n.dimensions) (e.type === "string" || e.type === "number") && t.push({
@@ -3097,7 +3891,7 @@ function Ht(e) {
3097
3891
  });
3098
3892
  return t;
3099
3893
  }
3100
- function Ut(e) {
3894
+ function Tn(e) {
3101
3895
  if (!e?.dimension) return "Select binding key...";
3102
3896
  if (typeof e.dimension == "string") return e.dimension.split(".")[1] || e.dimension;
3103
3897
  if (e.dimension.length > 0) {
@@ -3107,6 +3901,6 @@ function Ut(e) {
3107
3901
  return "Select binding key...";
3108
3902
  }
3109
3903
  //#endregion
3110
- export { st as A, et as C, at as D, nt as E, Ce as F, Q as M, tt as N, ct as O, we as P, ut as S, $ as T, ft as _, Rt as a, dt as b, Pt as c, Et as d, kt as f, pt as g, Mt as h, Ft as i, ot as j, rt as k, Tt as l, At as m, Ut as n, Bt as o, Dt as p, Vt as r, It as s, Ht as t, Ot as u, gt as v, it as w, mt as x, ht as y };
3904
+ export { Ht as A, Pt as C, zt as D, It as E, rt as F, Le as I, $ as M, Ft as N, Ut as O, it as P, Gt as S, Bt as T, qt as _, bn as a, Kt as b, gn as c, cn as d, dn as f, Jt as g, mn as h, _n as i, Vt as j, Lt as k, sn as l, fn as m, Tn as n, Sn as o, ln as p, Cn as r, vn as s, wn as t, un as u, Zt as v, Rt as w, Yt as x, Xt as y };
3111
3905
 
3112
- //# sourceMappingURL=analysis-builder-shared-3V70XUNW.js.map
3906
+ //# sourceMappingURL=analysis-builder-shared-BxHYfTzo.js.map