@malloydata/malloy-explorer 0.0.295-dev250710213205 → 0.0.299-dev250808170326

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 (68) hide show
  1. package/@flowtypes/components/MalloyExplorerProvider.flow.js +1 -1
  2. package/dist/cjs/index.cjs +1163 -573
  3. package/dist/cjs/index.cjs.map +1 -1
  4. package/dist/esm/index.js +1130 -540
  5. package/dist/esm/index.js.map +1 -1
  6. package/dist/malloy-explorer.css +1 -2
  7. package/dist/types/components/FieldToken.d.ts +5 -1
  8. package/dist/types/components/MalloyExplorerProvider.d.ts +1 -1
  9. package/dist/types/components/QueryPanel/AddMenu/AddAggregate.d.ts +1 -3
  10. package/dist/types/components/QueryPanel/AddMenu/AddEmptyNest.d.ts +1 -3
  11. package/dist/types/components/QueryPanel/AddMenu/AddGroupBy.d.ts +1 -3
  12. package/dist/types/components/QueryPanel/AddMenu/AddLimit.d.ts +1 -3
  13. package/dist/types/components/QueryPanel/AddMenu/AddMenu.d.ts +1 -3
  14. package/dist/types/components/QueryPanel/AddMenu/AddOrderBy.d.ts +1 -3
  15. package/dist/types/components/QueryPanel/AddMenu/AddView.d.ts +1 -3
  16. package/dist/types/components/QueryPanel/AddMenu/AddWhere.d.ts +0 -2
  17. package/dist/types/components/QueryPanel/Operations.d.ts +2 -3
  18. package/dist/types/components/QueryPanel/Parameters.d.ts +3 -3
  19. package/dist/types/components/QueryPanel/Query.d.ts +3 -4
  20. package/dist/types/components/QueryPanel/Source.d.ts +3 -3
  21. package/dist/types/components/QueryPanel/View.d.ts +2 -3
  22. package/dist/types/components/QueryPanel/ViewDefinition.d.ts +2 -3
  23. package/dist/types/components/QueryPanel/Visualization.d.ts +1 -2
  24. package/dist/types/components/QueryPanel/VizEditor/VizEditor.d.ts +1 -2
  25. package/dist/types/components/QueryPanel/VizEditor/VizEditorDialog.d.ts +1 -2
  26. package/dist/types/components/QueryPanel/VizEditor/VizEditorPopover.d.ts +1 -2
  27. package/dist/types/components/QueryPanel/VizEditor/styles.d.ts +3 -0
  28. package/dist/types/components/QueryPanel/VizEditor/utils.d.ts +3 -0
  29. package/dist/types/components/QueryPanel/operations/AggregateOperations.d.ts +3 -4
  30. package/dist/types/components/QueryPanel/operations/DrillOperations.d.ts +1 -2
  31. package/dist/types/components/QueryPanel/operations/FilterOperations.d.ts +2 -3
  32. package/dist/types/components/QueryPanel/operations/GroupByOperations.d.ts +2 -3
  33. package/dist/types/components/QueryPanel/operations/LimitOperation.d.ts +2 -3
  34. package/dist/types/components/QueryPanel/operations/NestOperation.d.ts +3 -5
  35. package/dist/types/components/QueryPanel/operations/OperationActionTitle.d.ts +0 -2
  36. package/dist/types/components/QueryPanel/operations/OrderByOperations.d.ts +2 -3
  37. package/dist/types/components/QueryPanel/operations/RenameDialog.d.ts +3 -4
  38. package/dist/types/components/QueryPanel/operations/SortableOperations.d.ts +3 -4
  39. package/dist/types/components/ResultPanel/DownloadButton.d.ts +6 -0
  40. package/dist/types/components/SourcePanel/FieldGroupList.d.ts +3 -1
  41. package/dist/types/components/SourcePanel/FieldTokenWithActions.d.ts +3 -2
  42. package/dist/types/components/SourcePanel/SearchResultList.d.ts +3 -1
  43. package/dist/types/components/SourcePanel/hooks/useOperations.d.ts +0 -4
  44. package/dist/types/components/primitives/DropdownMenu.d.ts +1 -1
  45. package/dist/types/components/primitives/utils/icon.d.ts +6 -0
  46. package/dist/types/components/utils/axis.d.ts +10 -0
  47. package/dist/types/components/utils/download.d.ts +44 -0
  48. package/dist/types/components/utils/download.spec.d.ts +1 -0
  49. package/dist/types/components/utils/icon.d.ts +3 -3
  50. package/dist/types/components/utils/segment.d.ts +1 -0
  51. package/dist/types/contexts/QueryEditorContext.d.ts +1 -10
  52. package/dist/types/hooks/useQueryBuilder.d.ts +2 -2
  53. package/dist/types/hooks/useQueryUpdate.d.ts +10 -0
  54. package/dist/types/hooks/useTopValues.d.ts +18 -0
  55. package/package.json +8 -8
  56. package/.editorconfig +0 -8
  57. package/.github/workflows/prerelease.yaml +0 -28
  58. package/.github/workflows/test.yaml +0 -26
  59. package/.gitmodules +0 -3
  60. package/.node-version +0 -1
  61. package/.prettierrc.js +0 -8
  62. package/.vscode/extensions.json +0 -6
  63. package/babel.config.cjs +0 -49
  64. package/eslint.config.mjs +0 -150
  65. package/index.html +0 -19
  66. package/jest.config.ts +0 -27
  67. package/postcss.config.mjs +0 -20
  68. package/vite.config.mts +0 -69
package/dist/esm/index.js CHANGED
@@ -15,9 +15,8 @@ var __superGet = (cls, obj, key2) => __reflectGet(__getProtoOf(cls), key2, obj);
15
15
  var _a, _b, _captureMap, _compiled, _pattern, _nameMap, _strategy, __EmulatedRegExp_instances, execCore_fn, _c;
16
16
  import { jsx, Fragment, jsxs } from "react/jsx-runtime";
17
17
  import * as React from "react";
18
- import React__default, { useLayoutEffect, useEffect, useMemo, useState, useRef, createElement, useContext, useCallback, createContext, memo, useReducer } from "react";
19
- import * as QB from "@malloydata/malloy-query-builder";
20
- import { ASTArrowQueryDefinition, ASTArrowViewDefinition, ASTSegmentViewDefinition, ASTNestViewOperation, ASTRefinementViewDefinition, ASTFilterWithLiteralEquality, ASTAnnotation, ASTOrderByViewOperation, ASTGroupByViewOperation, ASTAggregateViewOperation, ASTLimitViewOperation, ASTTimeTruncationExpression, ASTFilterWithFilterString, ASTReferenceExpression, ASTWhereViewOperation, ASTHavingViewOperation, ASTDrillViewOperation, ASTQuery } from "@malloydata/malloy-query-builder";
18
+ import React__default, { useLayoutEffect, useEffect, useMemo, createContext, useContext, useCallback, useState, useRef, createElement, memo, useReducer } from "react";
19
+ import { ASTQuery, ASTArrowQueryDefinition, ASTArrowViewDefinition, ASTSegmentViewDefinition, ASTNestViewOperation, ASTRefinementViewDefinition, ASTFilterWithLiteralEquality, ASTAnnotation, ASTLimitViewOperation, ASTOrderByViewOperation, ASTGroupByViewOperation, ASTAggregateViewOperation, ASTCalculateViewOperation, ASTTimeTruncationExpression, ASTFilterWithFilterString, ASTReferenceExpression, ASTWhereViewOperation, ASTHavingViewOperation, ASTDrillViewOperation, ASTReferenceQueryArrowSource } from "@malloydata/malloy-query-builder";
21
20
  import { Tag } from "@malloydata/malloy-tag";
22
21
  import { MalloyRenderer, isCoreVizPluginInstance } from "@malloydata/render";
23
22
  import { TemporalFilterExpression, BooleanFilterExpression, NumberFilterExpression, StringFilterExpression } from "@malloydata/malloy-filter";
@@ -3311,11 +3310,14 @@ var Root3$1 = Tooltip;
3311
3310
  var Trigger$4 = TooltipTrigger;
3312
3311
  var Portal$4 = TooltipPortal;
3313
3312
  var Content2$4 = TooltipContent;
3314
- const QueryEditorContext = /* @__PURE__ */ React.createContext({});
3313
+ const QueryEditorContext = /* @__PURE__ */ React.createContext({
3314
+ setQuery: () => {
3315
+ }
3316
+ });
3315
3317
  function useQueryBuilder(source, query) {
3316
3318
  return useMemo(() => {
3317
3319
  if (source) {
3318
- return new QB.ASTQuery({
3320
+ return new ASTQuery({
3319
3321
  query,
3320
3322
  source
3321
3323
  });
@@ -3399,10 +3401,29 @@ const findNestView = (currentView, remainingPath) => {
3399
3401
  }
3400
3402
  return null;
3401
3403
  };
3404
+ const UpdateQueryContext = /* @__PURE__ */ createContext({
3405
+ updateQuery: () => {
3406
+ console.warn("Missing <MalloyExplorerProvider>");
3407
+ }
3408
+ });
3409
+ function useUpdateQuery() {
3410
+ const {
3411
+ updateQuery
3412
+ } = useContext(UpdateQueryContext);
3413
+ return updateQuery;
3414
+ }
3415
+ const TopValuesContext = /* @__PURE__ */ createContext({});
3416
+ function useTopValues() {
3417
+ const {
3418
+ topValues
3419
+ } = useContext(TopValuesContext);
3420
+ return topValues;
3421
+ }
3402
3422
  function MalloyExplorerProvider({
3403
3423
  source,
3404
3424
  query,
3405
- onQueryChange,
3425
+ onQueryChange = () => {
3426
+ },
3406
3427
  focusedNestViewPath,
3407
3428
  onFocusedNestViewPathChange,
3408
3429
  children,
@@ -3410,20 +3431,32 @@ function MalloyExplorerProvider({
3410
3431
  onDrill
3411
3432
  }) {
3412
3433
  const rootQuery = useQueryBuilder(source, query);
3434
+ const updateQuery = useCallback(() => {
3435
+ onQueryChange == null ? void 0 : onQueryChange(rootQuery == null ? void 0 : rootQuery.build());
3436
+ }, [onQueryChange, rootQuery]);
3413
3437
  return /* @__PURE__ */ jsx(TooltipProvider, {
3414
3438
  children: /* @__PURE__ */ jsx(MalloyQueryFocusProvider, {
3415
3439
  rootQuery,
3416
3440
  focusedNestViewPath,
3417
3441
  onFocusedNestViewPathChange,
3418
- children: /* @__PURE__ */ jsx(QueryEditorContext.Provider, {
3442
+ children: /* @__PURE__ */ jsx(UpdateQueryContext.Provider, {
3419
3443
  value: {
3420
- source,
3421
- rootQuery,
3422
- setQuery: onQueryChange,
3423
- topValues,
3424
- onDrill
3444
+ updateQuery
3425
3445
  },
3426
- children
3446
+ children: /* @__PURE__ */ jsx(TopValuesContext.Provider, {
3447
+ value: {
3448
+ topValues
3449
+ },
3450
+ children: /* @__PURE__ */ jsx(QueryEditorContext.Provider, {
3451
+ value: {
3452
+ source,
3453
+ rootQuery,
3454
+ setQuery: onQueryChange,
3455
+ onDrill
3456
+ },
3457
+ children
3458
+ })
3459
+ })
3427
3460
  })
3428
3461
  })
3429
3462
  });
@@ -3795,6 +3828,7 @@ const SvgInfo = (props2) => /* @__PURE__ */ React.createElement("svg", { xmlns:
3795
3828
  const SvgError = (props2) => /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", height: "24px", viewBox: "0 -960 960 960", width: "24px", fill: "currentColor", ...props2 }, /* @__PURE__ */ React.createElement("path", { d: "M480-280q17 0 28.5-11.5T520-320q0-17-11.5-28.5T480-360q-17 0-28.5 11.5T440-320q0 17 11.5 28.5T480-280Zm-40-160h80v-240h-80v240ZM330-120 120-330v-300l210-210h300l210 210v300L630-120H330Zm34-80h232l164-164v-232L596-760H364L200-596v232l164 164Zm116-280Z" }));
3796
3829
  const SvgRefresh = (props2) => /* @__PURE__ */ React.createElement("svg", { height: 20, viewBox: "0 0 20 20", width: 20, xmlns: "http://www.w3.org/2000/svg", ...props2 }, /* @__PURE__ */ React.createElement("g", { fill: "none", stroke: "currentColor" }, /* @__PURE__ */ React.createElement("path", { d: "m17.08 11.15c.01.16.02.32.02.49 0 3.89-3.16 7.05-7.05 7.05-3.89-.01-7.05-3.16-7.05-7.06 0-3.89 3.16-7.05 7.05-7.05.85 0 1.66.15 2.41.42", strokeWidth: 1.1 }), /* @__PURE__ */ React.createElement("path", { d: "m9.9 2 2.89 2.89-3 3.01" })));
3797
3830
  const SvgSidebarCollapse = (props2) => /* @__PURE__ */ React.createElement("svg", { height: 24, viewBox: "0 0 24 24", width: 24, xmlns: "http://www.w3.org/2000/svg", fill: "currentColor", stroke: "none", ...props2 }, /* @__PURE__ */ React.createElement("path", { fill: "currentColor", stroke: "none", d: "m20 24h-16c-2.2 0-4-1.8-4-4v-16c0-2.2 1.8-4 4-4h16c2.2 0 4 1.8 4 4v16c0 2.2-1.8 4-4 4zm-16-22c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2v-16c0-1.1-.9-2-2-2z" }), /* @__PURE__ */ React.createElement("path", { fill: "currentColor", d: "m8 24c-.6 0-1-.4-1-1v-22c0-.6.4-1 1-1s1 .4 1 1v22c0 .6-.4 1-1 1z" }), /* @__PURE__ */ React.createElement("path", { fill: "currentColor", d: "m14 13c-.3 0-.5-.1-.7-.3-.4-.4-.4-1 0-1.4l3-3c.4-.4 1-.4 1.4 0s.4 1 0 1.4l-3 3c-.2.2-.4.3-.7.3z" }), /* @__PURE__ */ React.createElement("path", { fill: "currentColor", d: "m17 16c-.3 0-.5-.1-.7-.3l-3-3c-.4-.4-.4-1 0-1.4s1-.4 1.4 0l3 3c.4.4.4 1 0 1.4-.2.2-.4.3-.7.3z" }));
3831
+ const SvgDownload = (props2) => /* @__PURE__ */ React.createElement("svg", { width: "24px", height: "24px", viewBox: "0 0 80 80", fill: "currentColor", ...props2 }, /* @__PURE__ */ React.createElement("g", null, /* @__PURE__ */ React.createElement("path", { d: "M19.5833333,78.3333333 L74.4166667,78.3333333 L74.4166667,70.5 L19.5833333,70.5 L19.5833333,78.3333333 Z M74.4166667,35.25 L58.75,35.25 L58.75,11.75 L35.25,11.75 L35.25,35.25 L19.5833333,35.25 L47,62.6666667 L74.4166667,35.25 Z", fillRule: "nonzero", fill: "var(--vscode-icon-foreground)" })));
3798
3832
  const SvgFilterSliders = (props2) => /* @__PURE__ */ React.createElement("svg", { fill: "none", height: 24, viewBox: "0 0 24 24", width: 24, xmlns: "http://www.w3.org/2000/svg", ...props2 }, /* @__PURE__ */ React.createElement("path", { d: "m11 8h10m-10 0c0 1.65685-1.34315 3-3 3s-3-1.34315-3-3m6 0c0-1.65685-1.34315-3-3-3s-3 1.34315-3 3m0 0h-2m10 8h-10m10 0c0-1.6569 1.3431-3 3-3s3 1.3431 3 3m-6 0c0 1.6569 1.3431 3 3 3s3-1.3431 3-3m0 0h2", stroke: "currentColor", strokeWidth: 1.5 }));
3799
3833
  const SvgVizBarChart = (props2) => /* @__PURE__ */ React.createElement("svg", { width: "110px", height: "110px", viewBox: "15 15 80 80", xmlns: "http://www.w3.org/2000/svg", xmlnsXlink: "http://www.w3.org/1999/xlink", ...props2 }, /* @__PURE__ */ React.createElement("g", { id: "viz_bar_chart", stroke: "none", strokeWidth: 1, fill: "none", fillRule: "evenodd" }, /* @__PURE__ */ React.createElement("g", { id: "Group-3", transform: "translate(20.000000, 24.000000)", fill: "currentColor" }, /* @__PURE__ */ React.createElement("g", { id: "Group-2", transform: "translate(34.500000, 31.000000) rotate(-270.000000) translate(-34.500000, -31.000000) translate(3.500000, -3.500000)" }, /* @__PURE__ */ React.createElement("path", { d: "M-26.056314,30.056314 L34.943686,30.056314 C37.152825,30.056314 38.943686,31.847175 38.943686,34.056314 L38.943686,34.943686 C38.943686,37.152825 37.152825,38.943686 34.943686,38.943686 L-26.056314,38.943686 C-28.265453,38.943686 -30.056314,37.152825 -30.056314,34.943686 L-30.056314,34.056314 C-30.056314,31.847175 -28.265453,30.056314 -26.056314,30.056314 Z", id: "Rectangle-Copy-59", transform: "translate(4.443686, 34.500000) rotate(-90.000000) translate(-4.443686, -34.500000) " }), /* @__PURE__ */ React.createElement("path", { d: "M-0.491247385,37.8466366 L44.9281075,37.8466366 C47.1372465,37.8466366 48.9281075,39.6374976 48.9281075,41.8466366 L48.9281075,42.7340086 C48.9281075,44.9431476 47.1372465,46.7340086 44.9281075,46.7340086 L-0.491247385,46.7340086 C-2.70038638,46.7340086 -4.49124739,44.9431476 -4.49124739,42.7340086 L-4.49124739,41.8466366 C-4.49124739,39.6374976 -2.70038638,37.8466366 -0.491247385,37.8466366 Z", id: "Rectangle-Copy-62", transform: "translate(22.218430, 42.290323) rotate(-90.000000) translate(-22.218430, -42.290323) " }), /* @__PURE__ */ React.createElement("path", { d: "M23.3837854,43.9469253 L56.6025627,43.9469253 C58.8117017,43.9469253 60.6025627,45.7377863 60.6025627,47.9469253 L60.6025627,48.8342973 C60.6025627,51.0434363 58.8117017,52.8342973 56.6025627,52.8342973 L23.3837854,52.8342973 C21.1746464,52.8342973 19.3837854,51.0434363 19.3837854,48.8342973 L19.3837854,47.9469253 C19.3837854,45.7377863 21.1746464,43.9469253 23.3837854,43.9469253 Z", id: "Rectangle-Copy-66", transform: "translate(39.993174, 48.390611) rotate(-90.000000) translate(-39.993174, -48.390611) " }), /* @__PURE__ */ React.createElement("path", { d: "M46.7286345,49.7286345 L68.8072017,49.7286345 C71.0163407,49.7286345 72.8072017,51.5194955 72.8072017,53.7286345 L72.8072017,54.1927983 C72.8072017,56.4019373 71.0163407,58.1927983 68.8072017,58.1927983 L46.7286345,58.1927983 C44.5194955,58.1927983 42.7286345,56.4019373 42.7286345,54.1927983 L42.7286345,53.7286345 C42.7286345,51.5194955 44.5194955,49.7286345 46.7286345,49.7286345 Z", id: "Rectangle-Copy-67", transform: "translate(57.767918, 53.960716) rotate(-90.000000) translate(-57.767918, -53.960716) " })))));
3800
3834
  const SvgVizBoolean = (props2) => /* @__PURE__ */ React.createElement("svg", { width: "110px", height: "110px", viewBox: "15 15 80 80", xmlns: "http://www.w3.org/2000/svg", xmlnsXlink: "http://www.w3.org/1999/xlink", ...props2 }, /* @__PURE__ */ React.createElement("g", { id: "viz_boolean", stroke: "none", strokeWidth: 1, fill: "none", fillRule: "evenodd" }, /* @__PURE__ */ React.createElement("g", { id: "noun_switch_3350414-2", transform: "translate(20.000000, 22.000000)", fill: "currentColor", fillRule: "nonzero" }, /* @__PURE__ */ React.createElement("g", { id: "noun_switch_3350414" }, /* @__PURE__ */ React.createElement("path", { d: "M15.2972028,30.8 L54.7027972,30.8 C63.151209,30.8 70,23.9051851 70,15.4 C70,6.89481485 63.151209,0 54.7027972,0 L15.2972028,0 C6.84879098,0 0,6.89481485 0,15.4 C0,23.9051851 6.84879098,30.8 15.2972028,30.8 Z M15.2972028,6.16 L54.7027972,6.16 C59.7718443,6.16 63.8811189,10.2968889 63.8811189,15.4 C63.8811189,20.5031111 59.7718443,24.64 54.7027972,24.64 L15.2972028,24.64 C10.2281557,24.64 6.11888112,20.5031111 6.11888112,15.4 C6.11888112,10.2968889 10.2281557,6.16 15.2972028,6.16 Z", id: "Shape" }), /* @__PURE__ */ React.createElement("path", { d: "M19.6340542,21.9997804 C22.2930484,22.0215224 24.7022661,20.4273668 25.7348338,17.9629544 C26.7674016,15.4985421 26.2191958,12.6510518 24.3466309,10.7523518 C22.474066,8.85365189 19.6473211,8.27908795 17.1885612,9.29740315 C14.7298014,10.3157183 13.125,12.7256064 13.125,15.3998806 C13.125,19.0240523 16.0305897,21.9703156 19.6340542,21.9997804 L19.6340542,21.9997804 Z", id: "Path" }), /* @__PURE__ */ React.createElement("path", { d: "M54.7027971,35.2 L15.2972025,35.2 C6.84879081,35.2 0,42.094815 0,50.6 C0,59.105185 6.84879081,66 15.2972025,66 L54.7027971,66 C63.151209,66 70,59.1051851 70,50.6 C70,42.0948149 63.151209,35.2 54.7027971,35.2 L54.7027971,35.2 Z M54.7027971,59.84 L15.2972025,59.84 C10.2281554,59.84 6.11888082,55.7031111 6.11888082,50.6 C6.11888082,45.4968889 10.2281554,41.36 15.2972025,41.36 L54.7027971,41.36 C59.7718442,41.36 63.8811189,45.4968889 63.8811189,50.6 C63.8811189,55.7031111 59.7718442,59.84 54.7027971,59.84 L54.7027971,59.84 Z", id: "Shape" }), /* @__PURE__ */ React.createElement("path", { d: "M50.3659458,44.0002196 C47.7069516,43.9784776 45.2977339,45.5726332 44.2651662,48.0370456 C43.2325984,50.5014579 43.7808042,53.3489482 45.6533691,55.2476482 C47.525934,57.1463481 50.3526789,57.720912 52.8114388,56.7025969 C55.2701986,55.6842817 56.875,53.2743936 56.875,50.6001194 C56.875,46.9759477 53.9694103,44.0296844 50.3659458,44.0002196 Z", id: "Path" })))));
@@ -3837,6 +3871,7 @@ const ICON_MAP = {
3837
3871
  refresh: SvgRefresh,
3838
3872
  sidebarCollapse: SvgSidebarCollapse,
3839
3873
  filterSliders: SvgFilterSliders,
3874
+ download: SvgDownload,
3840
3875
  // Operations
3841
3876
  aggregate: SvgInsertMeasure,
3842
3877
  dimension: SvgTypeIconString,
@@ -3904,11 +3939,11 @@ function Icon({
3904
3939
  return null;
3905
3940
  }
3906
3941
  return /* @__PURE__ */ jsx(IconComponent, {
3907
- ..._stylex.props(styles$Q.main, colorVariants$3[color], customStyle),
3942
+ ..._stylex.props(styles$R.main, colorVariants$3[color], customStyle),
3908
3943
  "data-testid": `icon-${color}-${name}`
3909
3944
  });
3910
3945
  }
3911
- const styles$Q = {
3946
+ const styles$R = {
3912
3947
  main: {
3913
3948
  display: "mly1rg5ohu",
3914
3949
  width: "mly1kky2od",
@@ -3977,18 +4012,18 @@ function Badge({
3977
4012
  customStyle
3978
4013
  }) {
3979
4014
  return /* @__PURE__ */ jsxs("div", {
3980
- ..._stylex.props(styles$P.main, colorVariants$2[color], customStyle),
4015
+ ..._stylex.props(styles$Q.main, colorVariants$2[color], customStyle),
3981
4016
  children: [icon && /* @__PURE__ */ jsx(Icon, {
3982
4017
  color,
3983
4018
  name: icon
3984
4019
  }), /* @__PURE__ */ jsx("div", {
3985
4020
  "data-testid": "badge-label",
3986
- ..._stylex.props(fontStyles.badge, styles$P.label),
4021
+ ..._stylex.props(fontStyles.badge, styles$Q.label),
3987
4022
  children: label
3988
4023
  })]
3989
4024
  });
3990
4025
  }
3991
- const styles$P = {
4026
+ const styles$Q = {
3992
4027
  main: {
3993
4028
  display: "mly3nfvp2",
3994
4029
  height: "mly1qx5ct2",
@@ -4070,10 +4105,10 @@ function Divider({
4070
4105
  customStyle
4071
4106
  }) {
4072
4107
  return /* @__PURE__ */ jsx("div", {
4073
- ..._stylex.props(styles$O.main, orientationVariants[orientation], customStyle)
4108
+ ..._stylex.props(styles$P.main, orientationVariants[orientation], customStyle)
4074
4109
  });
4075
4110
  }
4076
- const styles$O = {
4111
+ const styles$P = {
4077
4112
  main: {
4078
4113
  background: "mly1xnbgy5",
4079
4114
  backgroundAttachment: null,
@@ -4879,7 +4914,7 @@ function Button({
4879
4914
  ...props2
4880
4915
  }) {
4881
4916
  const button = /* @__PURE__ */ jsxs("button", {
4882
- ..._stylex.props(styles$N.main, colorVariants$1[variant], sizeVariants$1[size2], customStyle),
4917
+ ..._stylex.props(styles$O.main, colorVariants$1[variant], sizeVariants$1[size2], customStyle),
4883
4918
  type: "button",
4884
4919
  disabled: isDisabled,
4885
4920
  ...props2,
@@ -4889,9 +4924,9 @@ function Button({
4889
4924
  },
4890
4925
  children: [icon && /* @__PURE__ */ jsx(Icon, {
4891
4926
  name: icon,
4892
- customStyle: styles$N.icon
4927
+ customStyle: styles$O.icon
4893
4928
  }), label && /* @__PURE__ */ jsx("div", {
4894
- ..._stylex.props(variant === "primary" ? fontStyles.emphasized : fontStyles.body, styles$N.label),
4929
+ ..._stylex.props(variant === "primary" ? fontStyles.emphasized : fontStyles.body, styles$O.label),
4895
4930
  children: label
4896
4931
  })]
4897
4932
  }), isDisabled && /* @__PURE__ */ jsx("div", {
@@ -4918,7 +4953,7 @@ function Button({
4918
4953
  return button;
4919
4954
  }
4920
4955
  }
4921
- const styles$N = {
4956
+ const styles$O = {
4922
4957
  main: {
4923
4958
  display: "mly3nfvp2",
4924
4959
  flexDirection: "mlydt5ytf",
@@ -5169,7 +5204,7 @@ function Token({
5169
5204
  }) {
5170
5205
  const isInteractive = onClick !== void 0 || asButtonTrigger;
5171
5206
  const token2 = /* @__PURE__ */ jsxs("div", {
5172
- ..._stylex.props(tokenStyles.main, tokenColorVariants[color], tokenSizeVariants[size2], !isInteractive && styles$M.nonInteractive, customStyle),
5207
+ ..._stylex.props(tokenStyles.main, tokenColorVariants[color], tokenSizeVariants[size2], !isInteractive && styles$N.nonInteractive, customStyle),
5173
5208
  ...dragProps == null ? void 0 : dragProps.attributes,
5174
5209
  ...dragProps == null ? void 0 : dragProps.listeners,
5175
5210
  children: [icon && /* @__PURE__ */ jsx(Icon, {
@@ -5206,7 +5241,7 @@ function Token({
5206
5241
  })]
5207
5242
  }) : token2;
5208
5243
  }
5209
- const styles$M = {
5244
+ const styles$N = {
5210
5245
  nonInteractive: {
5211
5246
  cursor: "mlyt0e3qv",
5212
5247
  background: "mly1np9qvj",
@@ -5230,7 +5265,7 @@ function TokenGroup({
5230
5265
  }) {
5231
5266
  const count2 = React.Children.count(children);
5232
5267
  return /* @__PURE__ */ jsx("div", {
5233
- ..._stylex.props(styles$L.main, customStyle),
5268
+ ..._stylex.props(styles$M.main, customStyle),
5234
5269
  children: React.Children.map(children, (child, index2) => /* @__PURE__ */ React.cloneElement(child, {
5235
5270
  customStyle: {
5236
5271
  ...child.props.customStyle,
@@ -5241,16 +5276,16 @@ function TokenGroup({
5241
5276
  });
5242
5277
  }
5243
5278
  const getChildStyle = (index2, count2) => {
5244
- if (count2 === 1) return styles$L.onlyChild;
5245
- if (index2 === 0) return styles$L.firstChild;
5246
- if (index2 === count2 - 1) return styles$L.lastChild;
5247
- return styles$L.innerChild;
5279
+ if (count2 === 1) return styles$M.onlyChild;
5280
+ if (index2 === 0) return styles$M.firstChild;
5281
+ if (index2 === count2 - 1) return styles$M.lastChild;
5282
+ return styles$M.innerChild;
5248
5283
  };
5249
5284
  const getTokenColor = (child, groupColor) => {
5250
5285
  const childColor = child.props.color;
5251
5286
  return childColor === void 0 ? groupColor : childColor;
5252
5287
  };
5253
- const styles$L = {
5288
+ const styles$M = {
5254
5289
  main: {
5255
5290
  display: "mlyrvj5dj",
5256
5291
  gridAutoFlow: "mly1mt1orb",
@@ -5322,7 +5357,7 @@ function ErrorIcon({
5322
5357
  },
5323
5358
  children: /* @__PURE__ */ jsx(Icon, {
5324
5359
  name: "warning",
5325
- customStyle: styles$K.errorIcon
5360
+ customStyle: styles$L.errorIcon
5326
5361
  })
5327
5362
  })
5328
5363
  }), /* @__PURE__ */ jsx(TooltipPortal, {
@@ -5335,7 +5370,7 @@ function ErrorIcon({
5335
5370
  })]
5336
5371
  });
5337
5372
  }
5338
- const styles$K = {
5373
+ const styles$L = {
5339
5374
  errorIcon: {
5340
5375
  color: "mly1e2nbdu",
5341
5376
  $$css: true
@@ -5380,22 +5415,22 @@ function EditableToken({
5380
5415
  className: "mly78zum5 mly6s0dn4"
5381
5416
  },
5382
5417
  children: [/* @__PURE__ */ jsxs("div", {
5383
- ..._stylex.props(tokenStyles.main, tokenColorVariants[color], tokenSizeVariants[size2], isFocused && styles$J.focused, !!errorMessage && styles$J.hasError, customStyle),
5418
+ ..._stylex.props(tokenStyles.main, tokenColorVariants[color], tokenSizeVariants[size2], isFocused && styles$K.focused, !!errorMessage && styles$K.hasError, customStyle),
5384
5419
  children: [icon && /* @__PURE__ */ jsx(Icon, {
5385
5420
  name: icon,
5386
- customStyle: styles$J.icon
5421
+ customStyle: styles$K.icon
5387
5422
  }), /* @__PURE__ */ jsxs("span", {
5388
5423
  ...{
5389
5424
  className: "mlywz0xwf"
5390
5425
  },
5391
5426
  children: [/* @__PURE__ */ jsx("span", {
5392
- ..._stylex.props(fontStyles.body, styles$J.placeholder),
5427
+ ..._stylex.props(fontStyles.body, styles$K.placeholder),
5393
5428
  style: {
5394
5429
  whiteSpaceCollapse: "preserve"
5395
5430
  },
5396
5431
  children: value
5397
5432
  }), /* @__PURE__ */ jsx("input", {
5398
- ..._stylex.props(styles$J.input, fontStyles.body),
5433
+ ..._stylex.props(styles$K.input, fontStyles.body),
5399
5434
  ref: inputRef,
5400
5435
  pattern: type === "number" ? "^-?[0-9.]*$" : void 0,
5401
5436
  value,
@@ -5420,7 +5455,7 @@ function EditableToken({
5420
5455
  })]
5421
5456
  });
5422
5457
  }
5423
- const styles$J = {
5458
+ const styles$K = {
5424
5459
  focused: {
5425
5460
  background: "mlyotlr4g",
5426
5461
  backgroundAttachment: null,
@@ -7762,12 +7797,12 @@ function TextInput({
7762
7797
  }
7763
7798
  };
7764
7799
  return /* @__PURE__ */ jsxs("div", {
7765
- ..._stylex.props(styles$I.main, isFocused && styles$I.focused, sizeVariants[size2], customStyle),
7800
+ ..._stylex.props(styles$J.main, isFocused && styles$J.focused, sizeVariants[size2], customStyle),
7766
7801
  children: [icon && /* @__PURE__ */ jsx(Icon, {
7767
7802
  name: icon,
7768
7803
  color: "secondary"
7769
7804
  }), /* @__PURE__ */ jsx("input", {
7770
- ..._stylex.props(fontStyles.body, styles$I.input),
7805
+ ..._stylex.props(fontStyles.body, styles$J.input),
7771
7806
  value,
7772
7807
  placeholder,
7773
7808
  onChange: handleChange,
@@ -7775,7 +7810,7 @@ function TextInput({
7775
7810
  onBlur: handleBlur,
7776
7811
  onKeyDown
7777
7812
  }), hasClear && /* @__PURE__ */ jsx("button", {
7778
- ..._stylex.props(fontStyles.supporting, styles$I.actionButton, value === "" && styles$I.hidden),
7813
+ ..._stylex.props(fontStyles.supporting, styles$J.actionButton, value === "" && styles$J.hidden),
7779
7814
  ref: buttonRef,
7780
7815
  onClick: () => onChange(""),
7781
7816
  tabIndex: 0,
@@ -7783,7 +7818,7 @@ function TextInput({
7783
7818
  })]
7784
7819
  });
7785
7820
  }
7786
- const styles$I = {
7821
+ const styles$J = {
7787
7822
  main: {
7788
7823
  display: "mly78zum5",
7789
7824
  alignItems: "mly6s0dn4",
@@ -7992,7 +8027,7 @@ function SelectorToken({
7992
8027
  onValueChange: handleValueChange,
7993
8028
  required: true,
7994
8029
  children: [/* @__PURE__ */ jsxs(Trigger$3, {
7995
- ..._stylex.props(tokenStyles.main, styles$H.selectTrigger, tokenColorVariants[color], tokenSizeVariants[size2], customStyle),
8030
+ ..._stylex.props(tokenStyles.main, styles$I.selectTrigger, tokenColorVariants[color], tokenSizeVariants[size2], customStyle),
7996
8031
  children: [icon && /* @__PURE__ */ jsx(Icon, {
7997
8032
  name: icon,
7998
8033
  customStyle: tokenStyles.icon
@@ -8019,7 +8054,7 @@ function SelectorToken({
8019
8054
  size: "compact",
8020
8055
  icon: "search",
8021
8056
  hasClear: true,
8022
- customStyle: styles$H.searchInput,
8057
+ customStyle: styles$I.searchInput,
8023
8058
  onKeyDown: (event) => {
8024
8059
  const excludedKeys = ["ArrowUp", "ArrowDown"];
8025
8060
  if (!excludedKeys.includes(event.key)) {
@@ -8050,21 +8085,21 @@ function SelectItem({
8050
8085
  ...props2
8051
8086
  }) {
8052
8087
  return /* @__PURE__ */ jsxs(Item$1, {
8053
- ..._stylex.props(fontStyles.body, styles$H.selectItem),
8088
+ ..._stylex.props(fontStyles.body, styles$I.selectItem),
8054
8089
  value,
8055
8090
  ...props2,
8056
8091
  children: [value === selectedValue ? /* @__PURE__ */ jsx(Icon, {
8057
8092
  name: "radioChecked",
8058
- customStyle: styles$H.radioChecked
8093
+ customStyle: styles$I.radioChecked
8059
8094
  }) : /* @__PURE__ */ jsx(Icon, {
8060
8095
  name: "radioUnchecked",
8061
- customStyle: styles$H.radioUnchecked
8096
+ customStyle: styles$I.radioUnchecked
8062
8097
  }), /* @__PURE__ */ jsx(ItemText, {
8063
8098
  children
8064
8099
  })]
8065
8100
  });
8066
8101
  }
8067
- const styles$H = {
8102
+ const styles$I = {
8068
8103
  selectTrigger: {
8069
8104
  whiteSpace: "mlyuxw1ft",
8070
8105
  overflow: "mlyb3r6kr",
@@ -8154,7 +8189,7 @@ function Card({
8154
8189
  customStyle
8155
8190
  }) {
8156
8191
  return /* @__PURE__ */ jsxs("div", {
8157
- ..._stylex.props(styles$G.container, customStyle),
8192
+ ..._stylex.props(styles$H.container, customStyle),
8158
8193
  children: [/* @__PURE__ */ jsx("div", {
8159
8194
  ...{
8160
8195
  className: "mly1717udv"
@@ -8168,7 +8203,7 @@ function Card({
8168
8203
  })]
8169
8204
  });
8170
8205
  }
8171
- const styles$G = {
8206
+ const styles$H = {
8172
8207
  container: {
8173
8208
  display: "mly78zum5",
8174
8209
  flexDirection: "mlydt5ytf",
@@ -8261,7 +8296,7 @@ function CollapsiblePanel({
8261
8296
  },
8262
8297
  children: [icon && /* @__PURE__ */ jsx(Icon, {
8263
8298
  name: icon,
8264
- customStyle: styles$F.icon
8299
+ customStyle: styles$G.icon
8265
8300
  }), /* @__PURE__ */ jsx("div", {
8266
8301
  ...{
8267
8302
  className: "mlyuxw1ft mlyb3r6kr mlylyipyv mlyehqz9p mly1ghz6dp mly117nqv4"
@@ -8303,7 +8338,7 @@ function CollapsiblePanel({
8303
8338
  })]
8304
8339
  });
8305
8340
  }
8306
- const styles$F = {
8341
+ const styles$G = {
8307
8342
  icon: {
8308
8343
  $$css: true
8309
8344
  }
@@ -8335,10 +8370,10 @@ function CollapsibleListItem({
8335
8370
  className: "mly78zum5 mlydt5ytf mly1iyjqo2 mlyb3r6kr"
8336
8371
  },
8337
8372
  children: [/* @__PURE__ */ jsx("span", {
8338
- ..._stylex.props(fontStyles.body, styles$E.label),
8373
+ ..._stylex.props(fontStyles.body, styles$F.label),
8339
8374
  children: label
8340
8375
  }), sublabel && /* @__PURE__ */ jsx("span", {
8341
- ..._stylex.props(fontStyles.supporting, styles$E.sublabel),
8376
+ ..._stylex.props(fontStyles.supporting, styles$F.sublabel),
8342
8377
  children: sublabel
8343
8378
  })]
8344
8379
  })]
@@ -8350,7 +8385,7 @@ function CollapsibleListItem({
8350
8385
  })]
8351
8386
  });
8352
8387
  }
8353
- const styles$E = {
8388
+ const styles$F = {
8354
8389
  label: {
8355
8390
  flexGrow: "mly1iyjqo2",
8356
8391
  fontWeight: "mly1xlr1w8",
@@ -19164,7 +19199,7 @@ function Spinner({
19164
19199
  } = SIZES[size2];
19165
19200
  const frameSize = diameter + border * 2;
19166
19201
  return /* @__PURE__ */ jsx("div", {
19167
- ..._stylex.props(styles$D.root, customStyle),
19202
+ ..._stylex.props(styles$E.root, customStyle),
19168
19203
  children: /* @__PURE__ */ jsx("span", {
19169
19204
  "aria-valuetext": "Loading",
19170
19205
  ...{
@@ -19184,7 +19219,7 @@ function Spinner({
19184
19219
  })
19185
19220
  });
19186
19221
  }
19187
- const styles$D = {
19222
+ const styles$E = {
19188
19223
  root: {
19189
19224
  alignItems: "mly6s0dn4",
19190
19225
  display: "mly3nfvp2",
@@ -22253,7 +22288,7 @@ function toArray() {
22253
22288
  m.millisecond()
22254
22289
  ];
22255
22290
  }
22256
- function toObject() {
22291
+ function toObject$1() {
22257
22292
  var m = this;
22258
22293
  return {
22259
22294
  years: m.year(),
@@ -22691,7 +22726,7 @@ proto.set = stringSet;
22691
22726
  proto.startOf = startOf;
22692
22727
  proto.subtract = subtract$1;
22693
22728
  proto.toArray = toArray;
22694
- proto.toObject = toObject;
22729
+ proto.toObject = toObject$1;
22695
22730
  proto.toDate = toDate;
22696
22731
  proto.toISOString = toISOString;
22697
22732
  proto.inspect = inspect;
@@ -23582,7 +23617,7 @@ const Popover = ({
23582
23617
  })
23583
23618
  });
23584
23619
  };
23585
- const styles$C = {
23620
+ const styles$D = {
23586
23621
  wrapper: {
23587
23622
  position: "mly1n2onr6",
23588
23623
  $$css: true
@@ -23634,7 +23669,7 @@ const SelectDropdown = ({
23634
23669
  setOpen(false);
23635
23670
  };
23636
23671
  return /* @__PURE__ */ jsxs("div", {
23637
- ..._stylex.props(styles$C.wrapper, customStyle),
23672
+ ..._stylex.props(styles$D.wrapper, customStyle),
23638
23673
  children: [/* @__PURE__ */ jsxs("button", {
23639
23674
  type: "button",
23640
23675
  autoFocus,
@@ -23702,7 +23737,7 @@ function SelectList({
23702
23737
  const [hoveredIndex, setHoveredIndex] = useState(null);
23703
23738
  return /* @__PURE__ */ jsx(ScrollableArea, {
23704
23739
  children: /* @__PURE__ */ jsx("div", {
23705
- ..._stylex.props(styles$C.selectListDiv, customStyle),
23740
+ ..._stylex.props(styles$D.selectListDiv, customStyle),
23706
23741
  children: options.reduce((result, option2, index2) => {
23707
23742
  const isSelected = value !== void 0 && valueEqual(value, option2.value);
23708
23743
  if (option2.divider) {
@@ -23734,8 +23769,8 @@ function SelectList({
23734
23769
  }), /* @__PURE__ */ jsx(Icon, {
23735
23770
  name: "checkmark",
23736
23771
  customStyle: {
23737
- ...styles$C.checkIcon,
23738
- ...isSelected ? styles$C.checkIconSelected : void 0
23772
+ ...styles$D.checkIcon,
23773
+ ...isSelected ? styles$D.checkIconSelected : void 0
23739
23774
  }
23740
23775
  }), /* @__PURE__ */ jsx("span", {
23741
23776
  ...{
@@ -23787,7 +23822,7 @@ const DateInput = ({
23787
23822
  setTempValue(hooks.utc(value).format(format2));
23788
23823
  }, [value, format2]);
23789
23824
  return /* @__PURE__ */ jsx("input", {
23790
- ..._stylex.props(customStyle, isActive ? styles$B.active : null),
23825
+ ..._stylex.props(customStyle, isActive ? styles$C.active : null),
23791
23826
  type: "text",
23792
23827
  placeholder: placeholder || format2,
23793
23828
  value: tempValue,
@@ -23822,7 +23857,7 @@ function guessUnits(moment2, isDateTime) {
23822
23857
  }
23823
23858
  return isDateTime ? "second" : "day";
23824
23859
  }
23825
- const styles$B = {
23860
+ const styles$C = {
23826
23861
  active: {
23827
23862
  backgroundColor: "mly1vzefiq",
23828
23863
  $$css: true
@@ -23934,7 +23969,7 @@ function DatePicker({
23934
23969
  });
23935
23970
  };
23936
23971
  return /* @__PURE__ */ jsxs("div", {
23937
- ..._stylex.props(styles$A.outer, customStyle),
23972
+ ..._stylex.props(styles$B.outer, customStyle),
23938
23973
  ref: forwardRef,
23939
23974
  children: [/* @__PURE__ */ jsxs("div", {
23940
23975
  ...{
@@ -24250,7 +24285,7 @@ function DatePicker({
24250
24285
  })]
24251
24286
  });
24252
24287
  }
24253
- const styles$A = {
24288
+ const styles$B = {
24254
24289
  outer: {
24255
24290
  userSelect: "mly87ps6o",
24256
24291
  fontSize: "mlymhiqyu",
@@ -24336,7 +24371,7 @@ function Banner({
24336
24371
  className: "mly1q4ynmn mlyh8yej3 mly5yr21d mly78zum5 mlydt5ytf mly1kmqopl mly16zck5j"
24337
24372
  },
24338
24373
  children: [/* @__PURE__ */ jsxs("div", {
24339
- ..._stylex.props(styles$z.header, variantColors[variant], children ? styles$z.headerWithContent : null),
24374
+ ..._stylex.props(styles$A.header, variantColors[variant], children ? styles$A.headerWithContent : null),
24340
24375
  children: [/* @__PURE__ */ jsx("div", {
24341
24376
  ...{
24342
24377
  className: "mly1qx5ct2 mly78zum5 mlyl56j7k mly6s0dn4"
@@ -24349,22 +24384,22 @@ function Banner({
24349
24384
  className: "mly78zum5 mlydt5ytf mlyb3r6kr"
24350
24385
  },
24351
24386
  children: [/* @__PURE__ */ jsx("div", {
24352
- ..._stylex.props(styles$z.title, fontStyles.emphasized),
24387
+ ..._stylex.props(styles$A.title, fontStyles.emphasized),
24353
24388
  children: title
24354
24389
  }), /* @__PURE__ */ jsx("div", {
24355
- ..._stylex.props(styles$z.description, fontStyles.supporting),
24390
+ ..._stylex.props(styles$A.description, fontStyles.supporting),
24356
24391
  children: description
24357
24392
  })]
24358
24393
  })]
24359
24394
  }), children && /* @__PURE__ */ jsx("div", {
24360
- ..._stylex.props(styles$z.content, fontStyles.body),
24395
+ ..._stylex.props(styles$A.content, fontStyles.body),
24361
24396
  children: /* @__PURE__ */ jsx(ScrollableArea, {
24362
24397
  children
24363
24398
  })
24364
24399
  })]
24365
24400
  });
24366
24401
  }
24367
- const styles$z = {
24402
+ const styles$A = {
24368
24403
  header: {
24369
24404
  borderRadius: "mly1q4ynmn",
24370
24405
  borderStartStartRadius: null,
@@ -24506,14 +24541,14 @@ function AccordionList({
24506
24541
  onExpandedItemChange: handleExpandedItemChange
24507
24542
  },
24508
24543
  children: /* @__PURE__ */ jsx("div", {
24509
- ..._stylex.props(styles$y.main, customStyle),
24544
+ ..._stylex.props(styles$z.main, customStyle),
24510
24545
  children: React.Children.map(children, (child) => /* @__PURE__ */ jsxs(Fragment, {
24511
24546
  children: [child, /* @__PURE__ */ jsx(Divider, {})]
24512
24547
  }))
24513
24548
  })
24514
24549
  });
24515
24550
  }
24516
- const styles$y = {
24551
+ const styles$z = {
24517
24552
  main: {
24518
24553
  display: "mly78zum5",
24519
24554
  flexDirection: "mlydt5ytf",
@@ -24550,10 +24585,10 @@ function AccordionListItem({
24550
24585
  className: "mly78zum5 mlydt5ytf mlyb3r6kr mly1iyjqo2"
24551
24586
  },
24552
24587
  children: [/* @__PURE__ */ jsx("span", {
24553
- ..._stylex.props(fontStyles.body, styles$x.label),
24588
+ ..._stylex.props(fontStyles.body, styles$y.label),
24554
24589
  children: label
24555
24590
  }), sublabel && /* @__PURE__ */ jsx("span", {
24556
- ..._stylex.props(fontStyles.supporting, styles$x.sublabel),
24591
+ ..._stylex.props(fontStyles.supporting, styles$y.sublabel),
24557
24592
  children: sublabel
24558
24593
  })]
24559
24594
  }), badge && badge, endIcon && endIcon]
@@ -24565,7 +24600,7 @@ function AccordionListItem({
24565
24600
  })]
24566
24601
  });
24567
24602
  }
24568
- const styles$x = {
24603
+ const styles$y = {
24569
24604
  label: {
24570
24605
  flexGrow: "mly1iyjqo2",
24571
24606
  fontWeight: "mly1xlr1w8",
@@ -25850,7 +25885,7 @@ function DropdownMenu({
25850
25885
  children: trigger
25851
25886
  }), /* @__PURE__ */ jsx(Portal2, {
25852
25887
  children: /* @__PURE__ */ jsx(Content2, {
25853
- ..._stylex.props(fontStyles.body, styles$w.content),
25888
+ ..._stylex.props(fontStyles.body, styles$x.content),
25854
25889
  side: "bottom",
25855
25890
  align: "start",
25856
25891
  sideOffset: 4,
@@ -25877,22 +25912,22 @@ function DropdownMenuItem({
25877
25912
  disabled,
25878
25913
  children: [icon && /* @__PURE__ */ jsx(Icon, {
25879
25914
  name: icon,
25880
- customStyle: styles$w.icon
25915
+ customStyle: styles$x.icon
25881
25916
  }), /* @__PURE__ */ jsxs("div", {
25882
25917
  ...{
25883
25918
  className: "mly78zum5 mlydt5ytf mly1iyjqo2"
25884
25919
  },
25885
25920
  children: [/* @__PURE__ */ jsx("span", {
25886
- ..._stylex.props(fontStyles.body, styles$w.label),
25921
+ ..._stylex.props(fontStyles.body, styles$x.label),
25887
25922
  children: label
25888
25923
  }), sublabel && /* @__PURE__ */ jsx("span", {
25889
- ..._stylex.props(fontStyles.supporting, styles$w.sublabel),
25924
+ ..._stylex.props(fontStyles.supporting, styles$x.sublabel),
25890
25925
  children: sublabel
25891
25926
  })]
25892
25927
  })]
25893
25928
  });
25894
25929
  }
25895
- const styles$w = {
25930
+ const styles$x = {
25896
25931
  content: {
25897
25932
  display: "mly78zum5",
25898
25933
  flexDirection: "mlydt5ytf",
@@ -25976,7 +26011,7 @@ function QueryActionBar({
25976
26011
  children: [/* @__PURE__ */ jsx(Icon, {
25977
26012
  name: "filterSliders"
25978
26013
  }), /* @__PURE__ */ jsx("div", {
25979
- ..._stylex.props(fontStyles.largeBody, styles$v.title),
26014
+ ..._stylex.props(fontStyles.largeBody, styles$w.title),
25980
26015
  children: "Query"
25981
26016
  })]
25982
26017
  }), /* @__PURE__ */ jsxs("div", {
@@ -25986,9 +26021,9 @@ function QueryActionBar({
25986
26021
  children: [/* @__PURE__ */ jsx(Button, {
25987
26022
  onClick: () => {
25988
26023
  focusMainView();
25989
- setQuery == null ? void 0 : setQuery(void 0);
26024
+ setQuery(void 0);
25990
26025
  },
25991
- isDisabled: !rootQuery || (rootQuery == null ? void 0 : rootQuery.isEmpty()),
26026
+ isDisabled: !rootQuery || rootQuery.isEmpty(),
25992
26027
  label: "Clear",
25993
26028
  variant: "flat",
25994
26029
  size: "compact"
@@ -26021,13 +26056,13 @@ function QueryActionBar({
26021
26056
  })]
26022
26057
  });
26023
26058
  }
26024
- const styles$v = {
26059
+ const styles$w = {
26025
26060
  title: {
26026
26061
  fontWeight: "mly1xlr1w8",
26027
26062
  $$css: true
26028
26063
  }
26029
26064
  };
26030
- const styles$u = {
26065
+ const styles$v = {
26031
26066
  labelWithIcon: {
26032
26067
  display: "mly78zum5",
26033
26068
  alignItems: "mly6s0dn4",
@@ -26198,6 +26233,7 @@ function fieldToIcon(field) {
26198
26233
  break;
26199
26234
  case "dimension":
26200
26235
  case "measure":
26236
+ case "calculate":
26201
26237
  icon = atomicTypeToIcon(field.type.kind);
26202
26238
  break;
26203
26239
  case "join":
@@ -26209,8 +26245,7 @@ function fieldToIcon(field) {
26209
26245
  function relationshipToIcon(relationship) {
26210
26246
  return relationshipMap[relationship];
26211
26247
  }
26212
- function viewToVisualizationIcon(view) {
26213
- const currentTag = view.getTag();
26248
+ function tagToVisualization(currentTag) {
26214
26249
  const currentRenderer = tagToRenderer(currentTag) ?? "table";
26215
26250
  return `viz_${currentRenderer}`;
26216
26251
  }
@@ -26230,6 +26265,7 @@ const fieldKindMap = {
26230
26265
  view: "purple",
26231
26266
  dimension: "cyan",
26232
26267
  measure: "green",
26268
+ calculate: "green",
26233
26269
  join: void 0
26234
26270
  };
26235
26271
  const relationshipMap = {
@@ -26239,31 +26275,36 @@ const relationshipMap = {
26239
26275
  };
26240
26276
  function FieldToken({
26241
26277
  field,
26278
+ additionalSiblings,
26242
26279
  hoverActions,
26243
26280
  hoverActionsVisible,
26244
26281
  ...props2
26245
26282
  }) {
26283
+ const [isHovered, setIsHovered] = React.useState(false);
26246
26284
  let label = field.name;
26247
26285
  if (field.kind === "dimension" && (field.type.kind === "timestamp_type" || field.type.kind === "date_type")) {
26248
26286
  if (field.type.timeframe) {
26249
26287
  label += `.${field.type.timeframe}`;
26250
26288
  }
26251
26289
  }
26290
+ const showHover = (isHovered || hoverActionsVisible) && !!hoverActions;
26252
26291
  return /* @__PURE__ */ jsxs("div", {
26292
+ onMouseEnter: () => setIsHovered(true),
26293
+ onMouseLeave: () => setIsHovered(false),
26253
26294
  ...{
26254
26295
  0: {
26255
- className: "mly78zum5 mly6s0dn4 mly1nhvcw1 mly1jnr06f mly28fmrt mly1x0xcia"
26296
+ className: "mly78zum5 mly6s0dn4 mly1nhvcw1 mly1jnr06f"
26256
26297
  },
26257
26298
  1: {
26258
26299
  className: "mly78zum5 mly6s0dn4 mly1nhvcw1 mly1jnr06f mlym9y5t7"
26259
26300
  }
26260
- }[!!hoverActionsVisible << 0],
26301
+ }[!!showHover << 0],
26261
26302
  children: [/* @__PURE__ */ jsx(Token, {
26262
26303
  label,
26263
26304
  color: fieldKindToColor(field.kind),
26264
26305
  icon: fieldToIcon(field),
26265
26306
  ...props2
26266
- }), hoverActions && /* @__PURE__ */ jsx("div", {
26307
+ }), additionalSiblings, showHover && /* @__PURE__ */ jsx("div", {
26267
26308
  ...{
26268
26309
  className: "mly1vsucm1 mly2lah0s"
26269
26310
  },
@@ -26279,7 +26320,7 @@ function DrillOperations({
26279
26320
  }
26280
26321
  return /* @__PURE__ */ jsxs("div", {
26281
26322
  children: [/* @__PURE__ */ jsx("div", {
26282
- ..._stylex.props(styles$u.title),
26323
+ ..._stylex.props(styles$v.title),
26283
26324
  children: "drills"
26284
26325
  }), /* @__PURE__ */ jsx("div", {
26285
26326
  ...{
@@ -30254,32 +30295,32 @@ function BadgeForField({
30254
30295
  label: "view",
30255
30296
  icon: "view_filled",
30256
30297
  color: "purple",
30257
- customStyle: styles$t.noBackground
30298
+ customStyle: styles$u.noBackground
30258
30299
  });
30259
30300
  } else if (field.kind === "dimension") {
30260
30301
  return /* @__PURE__ */ jsx(Badge, {
30261
30302
  label: "dimension",
30262
30303
  icon: fieldToIcon(field),
30263
30304
  color: "cyan",
30264
- customStyle: styles$t.noBackground
30305
+ customStyle: styles$u.noBackground
30265
30306
  });
30266
30307
  } else if (field.kind === "measure") {
30267
30308
  return /* @__PURE__ */ jsx(Badge, {
30268
30309
  label: "measure",
30269
30310
  icon: fieldToIcon(field),
30270
30311
  color: "green",
30271
- customStyle: styles$t.noBackground
30312
+ customStyle: styles$u.noBackground
30272
30313
  });
30273
30314
  } else if (field.kind === "join") {
30274
30315
  return /* @__PURE__ */ jsx(Badge, {
30275
30316
  label: "join",
30276
30317
  icon: fieldToIcon(field),
30277
30318
  color: "gray",
30278
- customStyle: styles$t.noBackground
30319
+ customStyle: styles$u.noBackground
30279
30320
  });
30280
30321
  }
30281
30322
  }
30282
- const styles$t = {
30323
+ const styles$u = {
30283
30324
  noBackground: {
30284
30325
  backgroundColor: "mlyjbqb8w",
30285
30326
  $$css: true
@@ -30588,7 +30629,7 @@ var Content$1 = DialogContent;
30588
30629
  var Title = DialogTitle;
30589
30630
  var Description = DialogDescription;
30590
30631
  var Close = DialogClose;
30591
- const styles$s = {
30632
+ const styles$t = {
30592
30633
  left: {
30593
30634
  display: "mly78zum5",
30594
30635
  justifyContent: "mly1lvf691",
@@ -30599,6 +30640,12 @@ const styles$s = {
30599
30640
  justifyContent: "mly1rfj78v",
30600
30641
  $$css: true
30601
30642
  },
30643
+ nest: {
30644
+ gridColumn: "mly623te4",
30645
+ gridColumnStart: null,
30646
+ gridColumnEnd: null,
30647
+ $$css: true
30648
+ },
30602
30649
  heading: {
30603
30650
  gridColumn: "mly623te4",
30604
30651
  gridColumnStart: null,
@@ -30722,11 +30769,11 @@ function HoverCard({
30722
30769
  customStyle
30723
30770
  }) {
30724
30771
  return /* @__PURE__ */ jsx("div", {
30725
- ..._stylex.props(styles$r.container, fontStyles.body, customStyle),
30772
+ ..._stylex.props(styles$s.container, fontStyles.body, customStyle),
30726
30773
  children
30727
30774
  });
30728
30775
  }
30729
- const styles$r = {
30776
+ const styles$s = {
30730
30777
  container: {
30731
30778
  boxShadow: "mly5n1uv4",
30732
30779
  backgroundColor: "mly12peec7",
@@ -30763,7 +30810,7 @@ function InfoHover({
30763
30810
  children: [/* @__PURE__ */ jsx(Trigger$4, {
30764
30811
  asChild: true,
30765
30812
  children: /* @__PURE__ */ jsx("div", {
30766
- ..._stylex.props(styles$s.infoTrigger, fontStyles.body),
30813
+ ..._stylex.props(styles$t.infoTrigger, fontStyles.body),
30767
30814
  children: /* @__PURE__ */ jsx(Icon, {
30768
30815
  name: "info",
30769
30816
  color: "disabled"
@@ -30774,7 +30821,7 @@ function InfoHover({
30774
30821
  side: "right",
30775
30822
  align: "start",
30776
30823
  children: /* @__PURE__ */ jsx(HoverCard, {
30777
- customStyle: styles$s.card,
30824
+ customStyle: styles$t.card,
30778
30825
  children: info
30779
30826
  })
30780
30827
  })
@@ -30896,9 +30943,9 @@ const PillInput = ({
30896
30943
  commitValue();
30897
30944
  });
30898
30945
  return /* @__PURE__ */ jsx("div", {
30899
- ..._stylex.props(fontStyles.body, styles$q.main),
30946
+ ..._stylex.props(fontStyles.body, styles$r.main),
30900
30947
  children: /* @__PURE__ */ jsxs("div", {
30901
- ..._stylex.props(styles$q.content, customStyle),
30948
+ ..._stylex.props(styles$r.content, customStyle),
30902
30949
  onKeyUp,
30903
30950
  onClick: () => {
30904
30951
  var _a2;
@@ -30964,7 +31011,7 @@ const Pill = ({
30964
31011
  onClick,
30965
31012
  tabIndex: 0,
30966
31013
  ref: forwardRef,
30967
- ..._stylex.props(styles$q.pill, colorVariants[color]),
31014
+ ..._stylex.props(styles$r.pill, colorVariants[color]),
30968
31015
  children: [children, /* @__PURE__ */ jsx("div", {
30969
31016
  title: "Remove",
30970
31017
  ...{
@@ -30979,7 +31026,7 @@ const Pill = ({
30979
31026
  })]
30980
31027
  });
30981
31028
  };
30982
- const styles$q = {
31029
+ const styles$r = {
30983
31030
  main: {
30984
31031
  borderRadius: "mly12oqio5",
30985
31032
  borderStartStartRadius: null,
@@ -31111,6 +31158,20 @@ const colorVariants = {
31111
31158
  $$css: true
31112
31159
  }
31113
31160
  };
31161
+ function setAtPath(current, path, value) {
31162
+ const newCurrent = {
31163
+ ...current
31164
+ };
31165
+ let target = newCurrent;
31166
+ for (let i2 = 0; i2 < path.length - 1; i2++) {
31167
+ if (typeof target[path[i2]] !== "object") {
31168
+ target[path[i2]] = {};
31169
+ }
31170
+ target = target[path[i2]];
31171
+ }
31172
+ target[path[path.length - 1]] = value;
31173
+ return newCurrent;
31174
+ }
31114
31175
  function OneOfEditor({
31115
31176
  view,
31116
31177
  name,
@@ -31121,7 +31182,7 @@ function OneOfEditor({
31121
31182
  }) {
31122
31183
  return /* @__PURE__ */ jsxs(Fragment, {
31123
31184
  children: [/* @__PURE__ */ jsx("div", {
31124
- ..._stylex.props(styles$s.label, styles$s.left),
31185
+ ..._stylex.props(styles$t.label, styles$t.left),
31125
31186
  children: /* @__PURE__ */ jsxs("label", {
31126
31187
  children: [option2.title ?? name, ":"]
31127
31188
  })
@@ -31156,6 +31217,15 @@ function OneOfEditor({
31156
31217
  current,
31157
31218
  option: subOption
31158
31219
  }, key2);
31220
+ case "object":
31221
+ return /* @__PURE__ */ jsx(OneOfObjectEditor, {
31222
+ view,
31223
+ name,
31224
+ path,
31225
+ updateCurrent,
31226
+ current,
31227
+ option: subOption
31228
+ }, key2);
31159
31229
  }
31160
31230
  return null;
31161
31231
  })]
@@ -31172,7 +31242,7 @@ function OneOfStringEditor({
31172
31242
  if (option2.enum) {
31173
31243
  return /* @__PURE__ */ jsxs(Fragment, {
31174
31244
  children: [/* @__PURE__ */ jsx("div", {
31175
- ..._stylex.props(styles$s.left),
31245
+ ..._stylex.props(styles$t.left),
31176
31246
  children: /* @__PURE__ */ jsx("input", {
31177
31247
  type: "radio",
31178
31248
  checked: isString2 && option2.enum.includes(current),
@@ -31203,7 +31273,7 @@ function OneOfStringEditor({
31203
31273
  } else {
31204
31274
  return /* @__PURE__ */ jsxs(Fragment, {
31205
31275
  children: [/* @__PURE__ */ jsx("div", {
31206
- ..._stylex.props(styles$s.left),
31276
+ ..._stylex.props(styles$t.left),
31207
31277
  children: /* @__PURE__ */ jsx("input", {
31208
31278
  type: "radio",
31209
31279
  checked: isString2,
@@ -31241,7 +31311,7 @@ function OneOfNumberEditor({
31241
31311
  const [value, setValue] = useState(isNumber2 ? current : option2.minimum ?? 0);
31242
31312
  return /* @__PURE__ */ jsxs(Fragment, {
31243
31313
  children: [/* @__PURE__ */ jsx("div", {
31244
- ..._stylex.props(styles$s.left),
31314
+ ..._stylex.props(styles$t.left),
31245
31315
  children: /* @__PURE__ */ jsx("input", {
31246
31316
  type: "radio",
31247
31317
  checked: isNumber2,
@@ -31265,10 +31335,10 @@ function OneOfNumberEditor({
31265
31335
  valueAsNumber
31266
31336
  }
31267
31337
  }) => {
31268
- setValue(value);
31338
+ setValue(valueAsNumber);
31269
31339
  updateCurrent(path, valueAsNumber);
31270
31340
  },
31271
- ..._stylex.props(styles$s.input)
31341
+ ..._stylex.props(styles$t.input)
31272
31342
  }), /* @__PURE__ */ jsx("div", {})]
31273
31343
  });
31274
31344
  }
@@ -31281,7 +31351,7 @@ function OneOfArrayEditor({
31281
31351
  const [value, setValue] = useState(isArray2 ? current : []);
31282
31352
  return /* @__PURE__ */ jsxs(Fragment, {
31283
31353
  children: [/* @__PURE__ */ jsx("div", {
31284
- ..._stylex.props(styles$s.left),
31354
+ ..._stylex.props(styles$t.left),
31285
31355
  children: /* @__PURE__ */ jsx("input", {
31286
31356
  type: "radio",
31287
31357
  checked: isArray2,
@@ -31304,6 +31374,48 @@ function OneOfArrayEditor({
31304
31374
  }), /* @__PURE__ */ jsx("div", {})]
31305
31375
  });
31306
31376
  }
31377
+ function OneOfObjectEditor({
31378
+ path,
31379
+ current,
31380
+ option: option2,
31381
+ updateCurrent,
31382
+ view
31383
+ }) {
31384
+ const isObject2 = current != null && typeof current === "object" && !Array.isArray(current);
31385
+ const [objectValue, setObjectValue] = useState(isObject2 ? current : {});
31386
+ return /* @__PURE__ */ jsxs(Fragment, {
31387
+ children: [/* @__PURE__ */ jsx("div", {
31388
+ ..._stylex.props(styles$t.left),
31389
+ children: /* @__PURE__ */ jsx("input", {
31390
+ type: "radio",
31391
+ checked: isObject2,
31392
+ onChange: ({
31393
+ target: {
31394
+ checked
31395
+ }
31396
+ }) => {
31397
+ if (checked) {
31398
+ updateCurrent(path, objectValue);
31399
+ }
31400
+ }
31401
+ })
31402
+ }), /* @__PURE__ */ jsx("div", {
31403
+ ..._stylex.props(styles$t.nest, styles$t.editorGrid),
31404
+ children: /* @__PURE__ */ jsx(ObjectEditor, {
31405
+ current: objectValue,
31406
+ updateCurrent: (path2, value) => {
31407
+ const [_2, ...subPath] = path2;
31408
+ setObjectValue(setAtPath(objectValue, subPath, value));
31409
+ updateCurrent(path2, value);
31410
+ },
31411
+ view,
31412
+ name: "",
31413
+ path,
31414
+ option: option2
31415
+ })
31416
+ })]
31417
+ });
31418
+ }
31307
31419
  function ArrayEditor({
31308
31420
  name,
31309
31421
  path,
@@ -31313,7 +31425,7 @@ function ArrayEditor({
31313
31425
  }) {
31314
31426
  return /* @__PURE__ */ jsxs(Fragment, {
31315
31427
  children: [/* @__PURE__ */ jsx("div", {
31316
- ..._stylex.props(styles$s.left, styles$s.label),
31428
+ ..._stylex.props(styles$t.left, styles$t.label),
31317
31429
  children: /* @__PURE__ */ jsxs("label", {
31318
31430
  children: [option2.title ?? name, ":"]
31319
31431
  })
@@ -31334,14 +31446,15 @@ function NumberEditor$1({
31334
31446
  option: option2,
31335
31447
  updateCurrent
31336
31448
  }) {
31449
+ const [value, setValue] = React.useState(current ?? option2.minimum);
31337
31450
  return /* @__PURE__ */ jsxs(Fragment, {
31338
31451
  children: [/* @__PURE__ */ jsx("div", {
31339
- ..._stylex.props(styles$s.left, styles$s.label),
31452
+ ..._stylex.props(styles$t.left, styles$t.label),
31340
31453
  children: /* @__PURE__ */ jsxs("label", {
31341
31454
  children: [option2.title ?? name, ":"]
31342
31455
  })
31343
31456
  }), /* @__PURE__ */ jsx("input", {
31344
- value: current,
31457
+ value,
31345
31458
  type: "number",
31346
31459
  min: option2.minimum,
31347
31460
  max: option2.maximum,
@@ -31350,9 +31463,10 @@ function NumberEditor$1({
31350
31463
  valueAsNumber
31351
31464
  }
31352
31465
  }) => {
31466
+ setValue(valueAsNumber);
31353
31467
  updateCurrent(path, valueAsNumber);
31354
31468
  },
31355
- ..._stylex.props(styles$s.input)
31469
+ ..._stylex.props(styles$t.input)
31356
31470
  }, name), option2.description ? /* @__PURE__ */ jsx(InfoHover, {
31357
31471
  info: option2.description
31358
31472
  }) : /* @__PURE__ */ jsx("div", {})]
@@ -31368,7 +31482,7 @@ function StringEditor$1({
31368
31482
  if (option2.enum) {
31369
31483
  return /* @__PURE__ */ jsxs(Fragment, {
31370
31484
  children: [/* @__PURE__ */ createElement("div", {
31371
- ..._stylex.props(styles$s.left, styles$s.label),
31485
+ ..._stylex.props(styles$t.left, styles$t.label),
31372
31486
  key: `${name}-label`
31373
31487
  }, /* @__PURE__ */ jsxs("label", {
31374
31488
  children: [option2.title ?? name, ":"]
@@ -31388,7 +31502,7 @@ function StringEditor$1({
31388
31502
  } else {
31389
31503
  return /* @__PURE__ */ jsxs(Fragment, {
31390
31504
  children: [/* @__PURE__ */ createElement("div", {
31391
- ..._stylex.props(styles$s.left, styles$s.label),
31505
+ ..._stylex.props(styles$t.left, styles$t.label),
31392
31506
  key: `${name}-label`
31393
31507
  }, /* @__PURE__ */ jsxs("label", {
31394
31508
  children: [option2.title ?? name, ":"]
@@ -31416,14 +31530,14 @@ function BooleanEditor({
31416
31530
  }) {
31417
31531
  return /* @__PURE__ */ jsxs(Fragment, {
31418
31532
  children: [/* @__PURE__ */ jsx("div", {
31419
- ..._stylex.props(styles$s.left),
31533
+ ..._stylex.props(styles$t.left),
31420
31534
  children: /* @__PURE__ */ jsxs("label", {
31421
- ..._stylex.props(styles$s.label),
31535
+ ..._stylex.props(styles$t.label),
31422
31536
  htmlFor: `${name}-checkbox`,
31423
31537
  children: [option2.title ?? name, ":"]
31424
31538
  }, `${name}-label`)
31425
31539
  }), /* @__PURE__ */ jsx("div", {
31426
- ..._stylex.props(styles$s.right),
31540
+ ..._stylex.props(styles$t.right),
31427
31541
  children: /* @__PURE__ */ jsx("input", {
31428
31542
  type: "checkbox",
31429
31543
  checked: current,
@@ -31472,7 +31586,7 @@ function FieldEditor({
31472
31586
  });
31473
31587
  return /* @__PURE__ */ jsxs(Fragment, {
31474
31588
  children: [/* @__PURE__ */ jsx("div", {
31475
- ..._stylex.props(styles$s.left, styles$s.label),
31589
+ ..._stylex.props(styles$t.left, styles$t.label),
31476
31590
  children: /* @__PURE__ */ jsxs("label", {
31477
31591
  children: [option2.title ?? name, ":"]
31478
31592
  })
@@ -31548,11 +31662,12 @@ function ObjectEditor({
31548
31662
  option: option2,
31549
31663
  updateCurrent
31550
31664
  }) {
31551
- const [isExpanded, setIsExpanded] = useState(path.length === 0);
31665
+ const [isExpanded, setIsExpanded] = useState(path.length === 0 || !name);
31552
31666
  return /* @__PURE__ */ jsxs(Fragment, {
31553
31667
  children: [name ? /* @__PURE__ */ jsxs(Fragment, {
31554
31668
  children: [/* @__PURE__ */ jsxs("div", {
31555
- ..._stylex.props(styles$s.label, styles$s.heading),
31669
+ ..._stylex.props(styles$t.label, styles$t.heading),
31670
+ onClick: () => setIsExpanded(!isExpanded),
31556
31671
  children: [/* @__PURE__ */ jsx("label", {
31557
31672
  children: option2.title ?? name
31558
31673
  }), option2.description ? /* @__PURE__ */ jsx(InfoHover, {
@@ -31639,40 +31754,29 @@ function ObjectEditor({
31639
31754
  }
31640
31755
  return null;
31641
31756
  }) : null, /* @__PURE__ */ jsx("div", {
31642
- ..._stylex.props(styles$s.divider)
31757
+ ..._stylex.props(styles$t.divider)
31643
31758
  })]
31644
31759
  });
31645
31760
  }
31646
31761
  function VizEditor({
31647
- rootQuery,
31648
31762
  view,
31649
31763
  plugin,
31650
31764
  setOpen
31651
31765
  }) {
31652
- const {
31653
- setQuery
31654
- } = useContext(QueryEditorContext);
31766
+ const updateQuery = useUpdateQuery();
31655
31767
  const [current, setCurrent] = useState(plugin.getSettings());
31656
- console.info("RendererEditor current settings:", current);
31657
31768
  const schema = plugin.getSchema();
31658
31769
  const updateCurrent = (path, value) => {
31659
- const newCurrent = {
31660
- ...current
31661
- };
31662
- let target = newCurrent;
31663
- for (let i2 = 0; i2 < path.length - 1; i2++) {
31664
- if (!(path[i2] in target)) {
31665
- target[path[i2]] = {};
31666
- }
31667
- target = target[path[i2]];
31668
- }
31669
- target[path[path.length - 1]] = value;
31770
+ const newCurrent = setAtPath(current, path, value);
31670
31771
  setCurrent(newCurrent);
31671
31772
  };
31773
+ React.useEffect(() => {
31774
+ console.info("RendererEditor current settings:", current);
31775
+ }, [current]);
31672
31776
  return /* @__PURE__ */ jsxs("div", {
31673
- ..._stylex.props(styles$s.editor),
31777
+ ..._stylex.props(styles$t.editor),
31674
31778
  children: [/* @__PURE__ */ jsx("div", {
31675
- ..._stylex.props(styles$s.editorGrid),
31779
+ ..._stylex.props(styles$t.editorGrid),
31676
31780
  children: /* @__PURE__ */ jsx(ObjectEditor, {
31677
31781
  view,
31678
31782
  name: "",
@@ -31682,13 +31786,13 @@ function VizEditor({
31682
31786
  updateCurrent
31683
31787
  })
31684
31788
  }), /* @__PURE__ */ jsxs("div", {
31685
- ..._stylex.props(styles$s.editorRow),
31789
+ ..._stylex.props(styles$t.editorRow),
31686
31790
  children: [/* @__PURE__ */ jsx(Button, {
31687
31791
  label: "Cancel",
31688
31792
  onClick: () => {
31689
31793
  setOpen(false);
31690
31794
  },
31691
- customStyle: styles$s.editorCell
31795
+ customStyle: styles$t.editorCell
31692
31796
  }), /* @__PURE__ */ jsx(Button, {
31693
31797
  variant: "primary",
31694
31798
  label: "Apply",
@@ -31703,10 +31807,10 @@ function VizEditor({
31703
31807
  view.getOrAddAnnotations().add(new ASTAnnotation({
31704
31808
  value
31705
31809
  }));
31706
- setQuery == null ? void 0 : setQuery(rootQuery.build());
31810
+ updateQuery();
31707
31811
  setOpen(false);
31708
31812
  },
31709
- customStyle: styles$s.editorCell
31813
+ customStyle: styles$t.editorCell
31710
31814
  })]
31711
31815
  })]
31712
31816
  });
@@ -31916,7 +32020,6 @@ const dialogStyles = {
31916
32020
  }
31917
32021
  };
31918
32022
  function VizEditorDialog({
31919
- rootQuery,
31920
32023
  plugin,
31921
32024
  view,
31922
32025
  customStyle,
@@ -31933,7 +32036,7 @@ function VizEditorDialog({
31933
32036
  children: /* @__PURE__ */ jsx(Overlay, {
31934
32037
  ..._stylex.props(dialogStyles.overlay),
31935
32038
  children: /* @__PURE__ */ jsxs(Content$1, {
31936
- ..._stylex.props(fontStyles.body, dialogStyles.content, styles$p.content, customStyle),
32039
+ ..._stylex.props(fontStyles.body, dialogStyles.content, styles$q.content, customStyle),
31937
32040
  children: [/* @__PURE__ */ jsxs(Title, {
31938
32041
  ..._stylex.props(dialogStyles.title),
31939
32042
  children: ["Visualization Settings", /* @__PURE__ */ jsx(Close, {
@@ -31946,7 +32049,6 @@ function VizEditorDialog({
31946
32049
  ..._stylex.props(dialogStyles.displayNone),
31947
32050
  children: "Edit visualization parameters"
31948
32051
  }), /* @__PURE__ */ jsx(VizEditor, {
31949
- rootQuery,
31950
32052
  view,
31951
32053
  plugin,
31952
32054
  setOpen
@@ -31956,7 +32058,7 @@ function VizEditorDialog({
31956
32058
  })
31957
32059
  });
31958
32060
  }
31959
- const styles$p = {
32061
+ const styles$q = {
31960
32062
  content: {
31961
32063
  maxWidth: "mly14zcgw3",
31962
32064
  width: "mly14rvwrp",
@@ -31965,12 +32067,9 @@ const styles$p = {
31965
32067
  }
31966
32068
  };
31967
32069
  function Visualization$1({
31968
- rootQuery,
31969
32070
  view
31970
32071
  }) {
31971
- const {
31972
- setQuery
31973
- } = useContext(QueryEditorContext);
32072
+ const updateQuery = useUpdateQuery();
31974
32073
  const renderer = useMemo(() => new MalloyRenderer(), []);
31975
32074
  const [currentRenderer, setCurrentRenderer] = useState("table");
31976
32075
  const [plugin, setPlugin] = useState();
@@ -32015,7 +32114,7 @@ function Visualization$1({
32015
32114
  }, [renderer, view, tag]);
32016
32115
  const updateViz = (renderer2) => {
32017
32116
  view.setTagProperty(["viz"], renderer2, RENDERER_PREFIX);
32018
- setQuery == null ? void 0 : setQuery(rootQuery.build());
32117
+ updateQuery();
32019
32118
  };
32020
32119
  const items = VIZ_RENDERERS.map((viz) => ({
32021
32120
  icon: /* @__PURE__ */ jsx(Icon, {
@@ -32026,7 +32125,7 @@ function Visualization$1({
32026
32125
  onClick: () => updateViz(viz)
32027
32126
  }));
32028
32127
  const tokens2 = [/* @__PURE__ */ jsx(SelectorToken, {
32029
- customStyle: styles$o.first,
32128
+ customStyle: styles$p.first,
32030
32129
  icon: `viz_${currentRenderer}`,
32031
32130
  value: currentRenderer,
32032
32131
  items,
@@ -32036,7 +32135,7 @@ function Visualization$1({
32036
32135
  tokens2.push(/* @__PURE__ */ jsx(Token, {
32037
32136
  icon: "gear",
32038
32137
  onClick: () => setOpen(true),
32039
- customStyle: styles$o.trigger,
32138
+ customStyle: styles$p.trigger,
32040
32139
  tooltip: "Edit Settings..."
32041
32140
  }, "gear"));
32042
32141
  }
@@ -32044,23 +32143,22 @@ function Visualization$1({
32044
32143
  tokens2.push(/* @__PURE__ */ jsx(Token, {
32045
32144
  icon: "warning",
32046
32145
  tooltip: error,
32047
- customStyle: styles$o.trigger
32146
+ customStyle: styles$p.trigger
32048
32147
  }));
32049
32148
  }
32050
32149
  return /* @__PURE__ */ jsxs(Fragment, {
32051
32150
  children: [/* @__PURE__ */ jsx(TokenGroup, {
32052
- customStyle: styles$o.group,
32151
+ customStyle: styles$p.group,
32053
32152
  children: tokens2
32054
32153
  }), /* @__PURE__ */ jsx(VizEditorDialog, {
32055
32154
  open,
32056
32155
  setOpen,
32057
- rootQuery,
32058
32156
  plugin,
32059
32157
  view
32060
32158
  })]
32061
32159
  });
32062
32160
  }
32063
- const styles$o = {
32161
+ const styles$p = {
32064
32162
  trigger: {
32065
32163
  height: "mly1ktj5wk",
32066
32164
  $$css: true
@@ -32097,7 +32195,7 @@ function ViewAttributeTable({
32097
32195
  }) {
32098
32196
  const dimensions = viewInfo.schema.fields.filter((f2) => f2.kind === "dimension");
32099
32197
  return /* @__PURE__ */ jsx("div", {
32100
- ..._stylex.props(styles$n.attributeTableContainer, style),
32198
+ ..._stylex.props(styles$o.attributeTableContainer, style),
32101
32199
  children: /* @__PURE__ */ jsx("table", {
32102
32200
  ...{
32103
32201
  className: "mly1mwwwfo mly9f619 mlyh8yej3 mly5yr21d"
@@ -32135,9 +32233,9 @@ function ViewAttributeTableRow({
32135
32233
  className: "mlydpxx8g"
32136
32234
  },
32137
32235
  children: [/* @__PURE__ */ jsx("td", {
32138
- ..._stylex.props(styles$n.attributeTableKeyCell, fontStyles.supporting),
32236
+ ..._stylex.props(styles$o.attributeTableKeyCell, fontStyles.supporting),
32139
32237
  children: /* @__PURE__ */ jsx("div", {
32140
- ..._stylex.props(styles$n.attributeTableKeyCellContent, fontStyles.supporting),
32238
+ ..._stylex.props(styles$o.attributeTableKeyCellContent, fontStyles.supporting),
32141
32239
  children: attribute
32142
32240
  })
32143
32241
  }), /* @__PURE__ */ jsx("td", {
@@ -32148,7 +32246,7 @@ function ViewAttributeTableRow({
32148
32246
  })]
32149
32247
  });
32150
32248
  }
32151
- const styles$n = {
32249
+ const styles$o = {
32152
32250
  attributeTableContainer: {
32153
32251
  padding: "mlye8ttls",
32154
32252
  paddingInline: null,
@@ -32197,9 +32295,7 @@ function TopValuesTable({
32197
32295
  field,
32198
32296
  path
32199
32297
  }) {
32200
- const {
32201
- topValues
32202
- } = useContext(QueryEditorContext);
32298
+ const topValues = useTopValues();
32203
32299
  const fieldPath = [...path, field.name].join(".");
32204
32300
  const fieldTopValues = topValues == null ? void 0 : topValues.find((entry) => entry.fieldName === fieldPath);
32205
32301
  if (!fieldTopValues) {
@@ -32280,12 +32376,12 @@ function RichText({
32280
32376
  });
32281
32377
  return /* @__PURE__ */ jsx("div", {
32282
32378
  ref,
32283
- ..._stylex.props(multiLine && styles$m.preWrap, multiLine && styles$m.breakWord, customStyle),
32379
+ ..._stylex.props(multiLine && styles$n.preWrap, multiLine && styles$n.breakWord, customStyle),
32284
32380
  ...props2,
32285
32381
  children: formatted
32286
32382
  });
32287
32383
  }
32288
- const styles$m = {
32384
+ const styles$n = {
32289
32385
  preWrap: {
32290
32386
  whiteSpace: "mly126k92a",
32291
32387
  $$css: true
@@ -32314,7 +32410,7 @@ function HoverText({
32314
32410
  onMouseEnter: () => setIsTriggerHovered(true),
32315
32411
  onMouseLeave: () => setIsTriggerHovered(false),
32316
32412
  onPointerMove: (e) => e.preventDefault(),
32317
- customStyle: [fontStyles.supporting, styles$l.text],
32413
+ customStyle: [fontStyles.supporting, styles$m.text],
32318
32414
  children: text2
32319
32415
  })
32320
32416
  }), /* @__PURE__ */ jsx(Portal$4, {
@@ -32333,7 +32429,7 @@ function HoverText({
32333
32429
  })]
32334
32430
  });
32335
32431
  }
32336
- const styles$l = {
32432
+ const styles$m = {
32337
32433
  text: {
32338
32434
  overflow: "mlyb3r6kr",
32339
32435
  overflowX: null,
@@ -32360,7 +32456,7 @@ function FieldHoverCard({
32360
32456
  details = /* @__PURE__ */ jsx(ViewAttributeTable, {
32361
32457
  viewInfo: field,
32362
32458
  isCompact: true,
32363
- style: styles$k.viewAttributeTable
32459
+ style: styles$l.viewAttributeTable
32364
32460
  });
32365
32461
  } else if (field.kind === "dimension") {
32366
32462
  details = /* @__PURE__ */ jsx(TopValuesTable, {
@@ -32369,7 +32465,7 @@ function FieldHoverCard({
32369
32465
  });
32370
32466
  }
32371
32467
  return /* @__PURE__ */ jsxs(HoverCard, {
32372
- customStyle: styles$k.container,
32468
+ customStyle: styles$l.container,
32373
32469
  children: [/* @__PURE__ */ jsxs("div", {
32374
32470
  ref,
32375
32471
  children: [/* @__PURE__ */ jsx("div", {
@@ -32380,10 +32476,10 @@ function FieldHoverCard({
32380
32476
  field
32381
32477
  })
32382
32478
  }), /* @__PURE__ */ jsx("div", {
32383
- ..._stylex.props(fontStyles.supporting, styles$k.path),
32479
+ ..._stylex.props(fontStyles.supporting, styles$l.path),
32384
32480
  children: pathString
32385
32481
  }), /* @__PURE__ */ jsx("div", {
32386
- ..._stylex.props(fontStyles.emphasized, styles$k.title),
32482
+ ..._stylex.props(fontStyles.emphasized, styles$l.title),
32387
32483
  children: field.name
32388
32484
  }), description && /* @__PURE__ */ jsx(HoverText, {
32389
32485
  text: description,
@@ -32394,7 +32490,7 @@ function FieldHoverCard({
32394
32490
  })]
32395
32491
  });
32396
32492
  }
32397
- const styles$k = {
32493
+ const styles$l = {
32398
32494
  container: {
32399
32495
  width: "mlybl57os",
32400
32496
  maxHeight: "mlyq3t0pi",
@@ -32572,9 +32668,7 @@ function BooleanFilterCore({
32572
32668
  });
32573
32669
  }
32574
32670
  function useSearch(searchTerm, fieldPath) {
32575
- const {
32576
- topValues
32577
- } = useContext(QueryEditorContext);
32671
+ const topValues = useTopValues();
32578
32672
  if (topValues && searchTerm) {
32579
32673
  let searchValues = topValues;
32580
32674
  if (fieldPath) {
@@ -32629,7 +32723,7 @@ function ValueList({
32629
32723
  children: (stringSearchResults == null ? void 0 : stringSearchResults.length) ? stringSearchResults.map((value) => /* @__PURE__ */ jsxs("div", {
32630
32724
  role: "menuitem",
32631
32725
  tabIndex: -1,
32632
- ..._stylex.props(addMenuStyles.item, styles$j.valueItem),
32726
+ ..._stylex.props(addMenuStyles.item, styles$k.valueItem),
32633
32727
  onClick: () => onClick(value),
32634
32728
  children: [/* @__PURE__ */ jsx(Value, {
32635
32729
  value
@@ -32653,10 +32747,10 @@ function Value({
32653
32747
  label: value.fieldValue ?? "∅",
32654
32748
  icon: "filter",
32655
32749
  color: "purple",
32656
- customStyle: styles$j.token
32750
+ customStyle: styles$k.token
32657
32751
  });
32658
32752
  }
32659
- const styles$j = {
32753
+ const styles$k = {
32660
32754
  valueItem: {
32661
32755
  height: "mly1qx5ct2",
32662
32756
  paddingTop: "mly1y1aw1k",
@@ -32832,7 +32926,7 @@ const StringFilterCore = ({
32832
32926
  setSearchValue("");
32833
32927
  }
32834
32928
  },
32835
- customStyle: styles$i.valueList,
32929
+ customStyle: styles$j.valueList,
32836
32930
  showPath: false,
32837
32931
  filter: (value) => !currentFilter.values.includes(value),
32838
32932
  hideNoMatchMessage: true
@@ -32903,7 +32997,7 @@ function stringFilterChangeType(filter, type) {
32903
32997
  };
32904
32998
  }
32905
32999
  }
32906
- const styles$i = {
33000
+ const styles$j = {
32907
33001
  valueList: {
32908
33002
  maxHeight: "mly3d5gib",
32909
33003
  width: "mly1hfn5x7",
@@ -33855,7 +33949,7 @@ function FieldList({
33855
33949
  ..._stylex.props(customStyle),
33856
33950
  children: groups.length ? groups.map((group) => /* @__PURE__ */ jsxs("div", {
33857
33951
  children: [/* @__PURE__ */ jsx("div", {
33858
- ..._stylex.props(addMenuStyles.item, styles$h.fieldItem, styles$h.sticky),
33952
+ ..._stylex.props(addMenuStyles.item, styles$i.fieldItem, styles$i.sticky),
33859
33953
  "data-disabled": "true",
33860
33954
  children: group.name
33861
33955
  }), group.fields.map((field) => isFilterOperation && (field.kind === "dimension" || field.kind === "measure") ? /* @__PURE__ */ jsx(FilterPopover, {
@@ -33865,7 +33959,7 @@ function FieldList({
33865
33959
  anchor: /* @__PURE__ */ jsx("div", {
33866
33960
  role: "menuitem",
33867
33961
  tabIndex: -1,
33868
- ..._stylex.props(addMenuStyles.item, styles$h.fieldItem),
33962
+ ..._stylex.props(addMenuStyles.item, styles$i.fieldItem),
33869
33963
  children: /* @__PURE__ */ jsx(PopoverTrigger, {
33870
33964
  asChild: true,
33871
33965
  children: /* @__PURE__ */ jsx(FieldToken, {
@@ -33892,7 +33986,7 @@ function FieldList({
33892
33986
  }, group.name + ":" + field.name) : /* @__PURE__ */ jsx("div", {
33893
33987
  role: "menuitem",
33894
33988
  tabIndex: -1,
33895
- ..._stylex.props(addMenuStyles.item, styles$h.fieldItem),
33989
+ ..._stylex.props(addMenuStyles.item, styles$i.fieldItem),
33896
33990
  children: /* @__PURE__ */ jsx(FieldToken, {
33897
33991
  field,
33898
33992
  onClick: () => onAddOperation(field, group.path),
@@ -33915,7 +34009,7 @@ function FieldList({
33915
34009
  })
33916
34010
  });
33917
34011
  }
33918
- const styles$h = {
34012
+ const styles$i = {
33919
34013
  fieldItem: {
33920
34014
  height: "mly1qx5ct2",
33921
34015
  paddingTop: "mly1y1aw1k",
@@ -33944,7 +34038,7 @@ function FieldMenu({
33944
34038
  }) {
33945
34039
  const [search, setSearch] = useState("");
33946
34040
  return /* @__PURE__ */ jsxs("div", {
33947
- ..._stylex.props(addMenuStyles.content, styles$g.content),
34041
+ ..._stylex.props(addMenuStyles.content, styles$h.content),
33948
34042
  role: "menu",
33949
34043
  children: [/* @__PURE__ */ jsx("div", {
33950
34044
  ..._stylex.props(addMenuStyles.item),
@@ -33970,12 +34064,48 @@ function FieldMenu({
33970
34064
  })]
33971
34065
  });
33972
34066
  }
33973
- const styles$g = {
34067
+ const styles$h = {
33974
34068
  content: {
33975
34069
  maxHeight: "mly3d5gib",
33976
34070
  $$css: true
33977
34071
  }
33978
34072
  };
34073
+ const getPrimaryAxis = (view) => {
34074
+ const schema = view.getOutputSchema();
34075
+ return getPrimaryAxisFromSchema(schema);
34076
+ };
34077
+ const getPrimaryAxisFromSchema = (schema) => {
34078
+ let primaryAxisField = void 0;
34079
+ primaryAxisField = findAxisFieldByAnnotation(schema.fields) || findAxisFieldByType(schema.fields) || findDefaultAxisField(schema.fields);
34080
+ return primaryAxisField;
34081
+ };
34082
+ const findAxisFieldByAnnotation = (fields) => {
34083
+ return fields.find((field) => {
34084
+ if (field.kind === "dimension" && field.annotations && field.annotations.find((annotation) => annotation.value === "# x")) {
34085
+ return true;
34086
+ }
34087
+ return false;
34088
+ });
34089
+ };
34090
+ const findAxisFieldByType = (fields) => {
34091
+ return fields.find((field) => {
34092
+ if (field.kind === "dimension") {
34093
+ const dimension = field;
34094
+ if (dimension.type.kind === "date_type" || dimension.type.kind === "timestamp_type") {
34095
+ return true;
34096
+ }
34097
+ }
34098
+ return false;
34099
+ });
34100
+ };
34101
+ const findDefaultAxisField = (fields) => {
34102
+ return fields.find((field) => {
34103
+ if (field.kind === "dimension") {
34104
+ return true;
34105
+ }
34106
+ return false;
34107
+ });
34108
+ };
33979
34109
  function toFullName(path, name) {
33980
34110
  return [...path || [], name].join(".");
33981
34111
  }
@@ -34054,6 +34184,34 @@ function addGroupBy(view, field, path) {
34054
34184
  segment.addTimestampGroupBy(field.name, path, "second");
34055
34185
  } else {
34056
34186
  segment.addGroupBy(field.name, path, rename);
34187
+ recomputePartitionByAndPrimaryAxis(segment);
34188
+ }
34189
+ }
34190
+ function recomputePartitionByAndPrimaryAxis(segment) {
34191
+ var _a2;
34192
+ const primaryAxis = getPrimaryAxisFromSchema(segment.getOutputSchema());
34193
+ const groupBys = segment.operations.items.filter((op) => op.kind === "group_by");
34194
+ const movingAverages = segment.operations.items.filter((op) => op.kind === "calculate" && op.expression.kind === "moving_average");
34195
+ const canSmooth = primaryAxis !== null && (primaryAxis == null ? void 0 : primaryAxis.kind) === "dimension" && (primaryAxis.type.kind === "timestamp_type" || primaryAxis.type.kind === "date_type");
34196
+ if (!canSmooth) {
34197
+ movingAverages.forEach((operation) => {
34198
+ operation.delete();
34199
+ segment.addAggregate(operation.getFieldInfo().name);
34200
+ });
34201
+ } else {
34202
+ const nonPrimaryGroupByNames = groupBys.filter((gb) => gb.name !== primaryAxis.name);
34203
+ movingAverages.forEach((operation) => {
34204
+ operation.expression.edit();
34205
+ operation.expression.setPartitionFields(nonPrimaryGroupByNames.map((gb) => gb.field.getReference()).filter((ref) => !!ref));
34206
+ });
34207
+ const primaryTimeAxisOperation = groupBys.find((gb) => gb.name === primaryAxis.name);
34208
+ if (primaryTimeAxisOperation) {
34209
+ const expression = (_a2 = primaryTimeAxisOperation.field) == null ? void 0 : _a2.expression;
34210
+ if (expression && expression.kind === "time_truncation") {
34211
+ const truncationExpression = primaryTimeAxisOperation.field.expression;
34212
+ truncationExpression.truncation = "day";
34213
+ }
34214
+ }
34057
34215
  }
34058
34216
  }
34059
34217
  function addAggregate(view, field, path) {
@@ -34131,7 +34289,7 @@ function OperationActionTitle({
34131
34289
  return !(segment == null ? void 0 : segment.hasField(field.name, path)) && isNotAnnotatedFilteredField(field);
34132
34290
  };
34133
34291
  return /* @__PURE__ */ jsxs("div", {
34134
- ..._stylex.props(styles$u.title, hoverStyles.main),
34292
+ ..._stylex.props(styles$v.title, hoverStyles.main),
34135
34293
  children: [/* @__PURE__ */ jsx("div", {
34136
34294
  children: title
34137
34295
  }), /* @__PURE__ */ jsx("div", {
@@ -34165,16 +34323,13 @@ function OperationActionTitle({
34165
34323
  });
34166
34324
  }
34167
34325
  function RenameDialog({
34168
- rootQuery,
34169
34326
  view,
34170
34327
  target,
34171
34328
  open,
34172
34329
  setOpen
34173
34330
  }) {
34174
34331
  const [name, setName] = useState("");
34175
- const {
34176
- setQuery
34177
- } = useContext(QueryEditorContext);
34332
+ const updateQuery = useUpdateQuery();
34178
34333
  useEffect(() => {
34179
34334
  if (target) {
34180
34335
  setName(target.name);
@@ -34184,8 +34339,9 @@ function RenameDialog({
34184
34339
  return null;
34185
34340
  }
34186
34341
  const onRename = () => {
34342
+ target.edit();
34187
34343
  target.name = name;
34188
- setQuery == null ? void 0 : setQuery(rootQuery == null ? void 0 : rootQuery.build());
34344
+ updateQuery();
34189
34345
  setOpen(false);
34190
34346
  };
34191
34347
  const {
@@ -34248,15 +34404,12 @@ function RenameDialog({
34248
34404
  });
34249
34405
  }
34250
34406
  function SortableOperations({
34251
- rootQuery,
34252
34407
  segment,
34253
34408
  view,
34254
34409
  operations,
34255
34410
  kind
34256
34411
  }) {
34257
- const {
34258
- setQuery
34259
- } = useContext(QueryEditorContext);
34412
+ const updateQuery = useUpdateQuery();
34260
34413
  const sensors = useSensors(useSensor(PointerSensor));
34261
34414
  const items = useMemo(() => {
34262
34415
  return operations.map((operation) => ({
@@ -34278,7 +34431,7 @@ function SortableOperations({
34278
34431
  const oldIndex = names.indexOf(active.id);
34279
34432
  const newIndex = names.indexOf(over.id);
34280
34433
  segment.reorderFields(arrayMove(names, oldIndex, newIndex));
34281
- setQuery == null ? void 0 : setQuery(rootQuery.build());
34434
+ updateQuery();
34282
34435
  }
34283
34436
  }
34284
34437
  const {
@@ -34290,7 +34443,7 @@ function SortableOperations({
34290
34443
  types: ["dimension"],
34291
34444
  onClick: (field, path) => {
34292
34445
  addGroupBy(view, field, path);
34293
- setQuery == null ? void 0 : setQuery(rootQuery.build());
34446
+ updateQuery();
34294
34447
  }
34295
34448
  } : {
34296
34449
  title: "aggregate",
@@ -34298,17 +34451,16 @@ function SortableOperations({
34298
34451
  types: ["measure"],
34299
34452
  onClick: (field, path) => {
34300
34453
  addAggregate(view, field, path);
34301
- setQuery == null ? void 0 : setQuery(rootQuery.build());
34454
+ updateQuery();
34302
34455
  }
34303
34456
  };
34304
34457
  return /* @__PURE__ */ jsxs("div", {
34305
34458
  children: [/* @__PURE__ */ jsx(OperationActionTitle, {
34306
- rootQuery,
34307
34459
  view,
34308
34460
  fields,
34309
34461
  ...props2
34310
34462
  }), /* @__PURE__ */ jsx("div", {
34311
- ..._stylex.props(styles$u.tokenContainer),
34463
+ ..._stylex.props(styles$v.tokenContainer),
34312
34464
  children: /* @__PURE__ */ jsx(DndContext, {
34313
34465
  sensors,
34314
34466
  collisionDetection: closestCenter,
@@ -34316,7 +34468,6 @@ function SortableOperations({
34316
34468
  children: /* @__PURE__ */ jsx(SortableContext, {
34317
34469
  items,
34318
34470
  children: items.map((item) => /* @__PURE__ */ jsx(SortableOperation, {
34319
- rootQuery,
34320
34471
  id: item.id,
34321
34472
  color: kind === "group_by" ? "cyan" : "green",
34322
34473
  view,
@@ -34329,18 +34480,16 @@ function SortableOperations({
34329
34480
  }
34330
34481
  const NULL_PATH = [];
34331
34482
  function SortableOperation({
34332
- rootQuery,
34333
34483
  id,
34334
34484
  view,
34335
34485
  operation,
34336
34486
  color
34337
34487
  }) {
34338
34488
  var _a2;
34339
- const {
34340
- setQuery
34341
- } = useContext(QueryEditorContext);
34489
+ const updateQuery = useUpdateQuery();
34342
34490
  const fieldInfo = operation.getFieldInfo();
34343
- const path = ((_a2 = operation.field.getReference()) == null ? void 0 : _a2.path) ?? NULL_PATH;
34491
+ const field = operation instanceof ASTCalculateViewOperation ? null : operation.field;
34492
+ const path = operation instanceof ASTCalculateViewOperation ? operation.expression.node.field_reference.path ?? NULL_PATH : ((_a2 = operation.field.getReference()) == null ? void 0 : _a2.path) ?? NULL_PATH;
34344
34493
  const {
34345
34494
  attributes,
34346
34495
  listeners,
@@ -34360,6 +34509,18 @@ function SortableOperation({
34360
34509
  transform: CSS$1.Transform.toString(transform2),
34361
34510
  transition
34362
34511
  };
34512
+ const primaryAxis = useMemo(() => {
34513
+ return getPrimaryAxis(view);
34514
+ }, [view]);
34515
+ const canSmooth = operation.kind === "aggregate" && primaryAxis !== null && (primaryAxis == null ? void 0 : primaryAxis.kind) === "dimension" && (primaryAxis.type.kind === "timestamp_type" || primaryAxis.type.kind === "date_type");
34516
+ const enableSmoothing = useCallback((operation2) => {
34517
+ if (!canSmooth) {
34518
+ return;
34519
+ }
34520
+ operation2.convertToCalculateMovingAverage(operation2.name + "_smoothed", 7);
34521
+ recomputePartitionByAndPrimaryAxis(view.getOrAddDefaultSegment());
34522
+ updateQuery();
34523
+ }, [canSmooth, updateQuery, view]);
34363
34524
  const hoverActions = useMemo(() => {
34364
34525
  return /* @__PURE__ */ jsxs(Fragment, {
34365
34526
  children: [/* @__PURE__ */ jsx(DropdownMenu, {
@@ -34370,7 +34531,14 @@ function SortableOperation({
34370
34531
  tooltip: "More Actions"
34371
34532
  }),
34372
34533
  onOpenChange: setHoverActionsVisible,
34373
- children: [/* @__PURE__ */ jsx(DropdownMenuItem, {
34534
+ children: [canSmooth ? /* @__PURE__ */ jsx(DropdownMenuItem, {
34535
+ label: "Add smoothing",
34536
+ onClick: () => {
34537
+ if (operation instanceof ASTAggregateViewOperation) {
34538
+ enableSmoothing(operation);
34539
+ }
34540
+ }
34541
+ }, "smoothing") : null, /* @__PURE__ */ jsx(DropdownMenuItem, {
34374
34542
  label: "Rename",
34375
34543
  onClick: () => {
34376
34544
  setRenameTarget(operation);
@@ -34380,12 +34548,21 @@ function SortableOperation({
34380
34548
  }, [...path, fieldInfo.name].join(".")), /* @__PURE__ */ jsx(ClearButton, {
34381
34549
  onClick: () => {
34382
34550
  operation.delete();
34383
- setQuery == null ? void 0 : setQuery(rootQuery == null ? void 0 : rootQuery.build());
34551
+ recomputePartitionByAndPrimaryAxis(view.getOrAddDefaultSegment());
34552
+ updateQuery();
34384
34553
  }
34385
34554
  })]
34386
34555
  });
34387
- }, [fieldInfo, operation, path, rootQuery, setQuery]);
34388
- const granular = granularityMenuItems(fieldInfo, operation.field);
34556
+ }, [canSmooth, enableSmoothing, fieldInfo.name, operation, path, updateQuery, view]);
34557
+ const hasSmoothedField = useMemo(() => {
34558
+ return view.getOrAddDefaultSegment().operations.items.some((operation2) => {
34559
+ return operation2.kind === "calculate";
34560
+ });
34561
+ }, [view]);
34562
+ const granular = granularityMenuItems(fieldInfo, field);
34563
+ if (hasSmoothedField && granular && operation.name === (primaryAxis == null ? void 0 : primaryAxis.name)) {
34564
+ granular.options = granular.options.filter((option2) => option2.value === "day");
34565
+ }
34389
34566
  let icon = "orderBy";
34390
34567
  if (fieldInfo.kind === "dimension" || fieldInfo.kind === "measure") {
34391
34568
  icon = atomicTypeToIcon(fieldInfo.type.kind);
@@ -34394,7 +34571,7 @@ function SortableOperation({
34394
34571
  id,
34395
34572
  ref: setNodeRef,
34396
34573
  style,
34397
- children: [granular ? /* @__PURE__ */ jsxs("div", {
34574
+ children: [field && granular ? /* @__PURE__ */ jsxs("div", {
34398
34575
  ...{
34399
34576
  0: {
34400
34577
  className: "mly78zum5 mly6s0dn4 mly1nhvcw1 mly1jnr06f mly11ogjb6 mly1g9of4s"
@@ -34417,8 +34594,8 @@ function SortableOperation({
34417
34594
  color,
34418
34595
  value: granular.value,
34419
34596
  onChange: (granulation) => {
34420
- if (operation.field.expression instanceof ASTTimeTruncationExpression) operation.field.expression.truncation = granulation;
34421
- setQuery == null ? void 0 : setQuery(rootQuery.build());
34597
+ if (field.expression instanceof ASTTimeTruncationExpression) field.expression.truncation = granulation;
34598
+ updateQuery();
34422
34599
  },
34423
34600
  items: granular.options
34424
34601
  })]
@@ -34428,7 +34605,7 @@ function SortableOperation({
34428
34605
  },
34429
34606
  children: hoverActions
34430
34607
  })]
34431
- }) : /* @__PURE__ */ jsx(FieldToken, {
34608
+ }) : operation instanceof ASTCalculateViewOperation ? /* @__PURE__ */ jsx(FieldToken, {
34432
34609
  field: fieldInfo,
34433
34610
  color,
34434
34611
  hoverActionsVisible,
@@ -34445,9 +34622,67 @@ function SortableOperation({
34445
34622
  dragProps: {
34446
34623
  attributes,
34447
34624
  listeners
34448
- }
34625
+ },
34626
+ additionalSiblings: /* @__PURE__ */ jsx(SelectorToken, {
34627
+ color,
34628
+ value: "" + (operation.expression.node.rows_preceding ?? 7),
34629
+ onChange: (value) => {
34630
+ if (value === "1") {
34631
+ view.getOrAddDefaultSegment().operations.add(new ASTAggregateViewOperation({
34632
+ kind: "aggregate",
34633
+ field: {
34634
+ expression: {
34635
+ kind: "field_reference",
34636
+ name: operation.expression.node.field_reference.name
34637
+ }
34638
+ }
34639
+ }));
34640
+ operation.delete();
34641
+ updateQuery();
34642
+ } else {
34643
+ operation.expression.edit();
34644
+ operation.expression.rowsPreceding = parseInt(value, 10);
34645
+ updateQuery();
34646
+ }
34647
+ },
34648
+ items: [{
34649
+ label: "7d",
34650
+ value: "7"
34651
+ }, {
34652
+ label: "14d",
34653
+ value: "14"
34654
+ }, {
34655
+ label: "28d",
34656
+ value: "28"
34657
+ }, {
34658
+ label: "30d",
34659
+ value: "30"
34660
+ }, {
34661
+ label: "Remove smoothing",
34662
+ value: "1"
34663
+ }]
34664
+ })
34665
+ }) : /* @__PURE__ */ jsx(Fragment, {
34666
+ children: /* @__PURE__ */ jsx(FieldToken, {
34667
+ field: fieldInfo,
34668
+ color,
34669
+ hoverActionsVisible,
34670
+ hoverActions,
34671
+ tooltip: /* @__PURE__ */ jsx(FieldHoverCard, {
34672
+ field: fieldInfo,
34673
+ path
34674
+ }),
34675
+ tooltipProps: {
34676
+ side: "right",
34677
+ align: "start",
34678
+ alignOffset: 28
34679
+ },
34680
+ dragProps: {
34681
+ attributes,
34682
+ listeners
34683
+ }
34684
+ })
34449
34685
  }), /* @__PURE__ */ jsx(RenameDialog, {
34450
- rootQuery,
34451
34686
  view,
34452
34687
  target: renameTarget,
34453
34688
  open: renameOpen,
@@ -34458,7 +34693,7 @@ function SortableOperation({
34458
34693
  const DateGranulation = ["day", "week", "month", "quarter", "year"];
34459
34694
  const TimestampGranulation = ["second", "minute", "hour", "day", "week", "month", "quarter", "year"];
34460
34695
  function granularityMenuItems(fieldInfo, field) {
34461
- if (fieldInfo.kind !== "dimension" || !(field.expression instanceof ASTTimeTruncationExpression)) {
34696
+ if (!field || fieldInfo.kind !== "dimension" || !(field.expression instanceof ASTTimeTruncationExpression)) {
34462
34697
  return null;
34463
34698
  }
34464
34699
  if (fieldInfo.type.kind === "timestamp_type") {
@@ -34488,13 +34723,11 @@ const customStyles = {
34488
34723
  }
34489
34724
  };
34490
34725
  function GroupByOperations({
34491
- rootQuery,
34492
34726
  segment,
34493
34727
  view,
34494
34728
  groupBys
34495
34729
  }) {
34496
34730
  return /* @__PURE__ */ jsx(SortableOperations, {
34497
- rootQuery,
34498
34731
  segment,
34499
34732
  view,
34500
34733
  operations: groupBys,
@@ -34737,34 +34970,30 @@ function displayTimeFromMoment(momentObj) {
34737
34970
  return momentObj.moment;
34738
34971
  }
34739
34972
  function FilterOperations({
34740
- rootQuery,
34741
34973
  filters
34742
34974
  }) {
34743
- const {
34744
- setQuery
34745
- } = useContext(QueryEditorContext);
34975
+ const updateQuery = useUpdateQuery();
34746
34976
  if (filters.length === 0) {
34747
34977
  return null;
34748
34978
  }
34749
34979
  return /* @__PURE__ */ jsxs("div", {
34750
34980
  children: [/* @__PURE__ */ jsx("div", {
34751
- ..._stylex.props(styles$u.title),
34981
+ ..._stylex.props(styles$v.title),
34752
34982
  children: "filter by"
34753
34983
  }), /* @__PURE__ */ jsx("div", {
34754
- ..._stylex.props(styles$u.tokenContainer),
34984
+ ..._stylex.props(styles$v.tokenContainer),
34755
34985
  children: filters.map((filterOperation, key2) => {
34756
34986
  return /* @__PURE__ */ jsx(ErrorElement, {
34757
34987
  fallback: /* @__PURE__ */ jsxs("div", {
34758
34988
  children: ["Invalid filter", /* @__PURE__ */ jsx(ClearButton, {
34759
34989
  onClick: () => {
34760
34990
  filterOperation.delete();
34761
- setQuery == null ? void 0 : setQuery(rootQuery.build());
34991
+ updateQuery();
34762
34992
  }
34763
34993
  })]
34764
34994
  }),
34765
34995
  children: /* @__PURE__ */ jsx(SingleFilterOperation, {
34766
- filterOperation,
34767
- rootQuery
34996
+ filterOperation
34768
34997
  })
34769
34998
  }, key2);
34770
34999
  })
@@ -34772,18 +35001,15 @@ function FilterOperations({
34772
35001
  });
34773
35002
  }
34774
35003
  function SingleFilterOperation({
34775
- rootQuery,
34776
35004
  filterOperation
34777
35005
  }) {
34778
- const {
34779
- setQuery
34780
- } = useContext(QueryEditorContext);
35006
+ const updateQuery = useUpdateQuery();
34781
35007
  const setFilter = useCallback((filter2) => {
34782
35008
  if (filterOperation.filter instanceof ASTFilterWithFilterString) {
34783
35009
  filterOperation.filter.setFilter(filter2);
34784
35010
  }
34785
- setQuery == null ? void 0 : setQuery(rootQuery.build());
34786
- }, [filterOperation.filter, rootQuery, setQuery]);
35011
+ updateQuery();
35012
+ }, [filterOperation.filter, updateQuery]);
34787
35013
  const {
34788
35014
  filter
34789
35015
  } = filterOperation;
@@ -34827,25 +35053,22 @@ function SingleFilterOperation({
34827
35053
  children: /* @__PURE__ */ jsx(ClearButton, {
34828
35054
  onClick: () => {
34829
35055
  filterOperation.delete();
34830
- setQuery == null ? void 0 : setQuery(rootQuery.build());
35056
+ updateQuery();
34831
35057
  }
34832
35058
  })
34833
35059
  })]
34834
35060
  });
34835
35061
  }
34836
35062
  function LimitOperation({
34837
- rootQuery,
34838
35063
  limit
34839
35064
  }) {
34840
- const {
34841
- setQuery
34842
- } = useContext(QueryEditorContext);
35065
+ const updateQuery = useUpdateQuery();
34843
35066
  if (!limit) {
34844
35067
  return null;
34845
35068
  }
34846
35069
  return /* @__PURE__ */ jsxs("div", {
34847
35070
  children: [/* @__PURE__ */ jsx("div", {
34848
- ..._stylex.props(styles$u.title),
35071
+ ..._stylex.props(styles$v.title),
34849
35072
  children: "limit"
34850
35073
  }), /* @__PURE__ */ jsxs("div", {
34851
35074
  ..._stylex.props(hoverStyles.main),
@@ -34854,7 +35077,7 @@ function LimitOperation({
34854
35077
  value: limit.limit,
34855
35078
  onChange: (value) => {
34856
35079
  limit.limit = value;
34857
- setQuery == null ? void 0 : setQuery(rootQuery.build());
35080
+ updateQuery();
34858
35081
  },
34859
35082
  errorMessage: limit.limit < 0 ? "Limit must be positive" : void 0
34860
35083
  }), /* @__PURE__ */ jsx("div", {
@@ -34862,7 +35085,7 @@ function LimitOperation({
34862
35085
  children: /* @__PURE__ */ jsx(ClearButton, {
34863
35086
  onClick: () => {
34864
35087
  limit.delete();
34865
- setQuery == null ? void 0 : setQuery(rootQuery.build());
35088
+ updateQuery();
34866
35089
  }
34867
35090
  })
34868
35091
  })]
@@ -34870,13 +35093,11 @@ function LimitOperation({
34870
35093
  });
34871
35094
  }
34872
35095
  function AggregateOperations({
34873
- rootQuery,
34874
35096
  segment,
34875
35097
  view,
34876
35098
  aggregates
34877
35099
  }) {
34878
35100
  return /* @__PURE__ */ jsx(SortableOperations, {
34879
- rootQuery,
34880
35101
  segment,
34881
35102
  view,
34882
35103
  operations: aggregates,
@@ -34884,21 +35105,18 @@ function AggregateOperations({
34884
35105
  });
34885
35106
  }
34886
35107
  function OrderByOperations({
34887
- rootQuery,
34888
35108
  orderBys
34889
35109
  }) {
34890
- const {
34891
- setQuery
34892
- } = useContext(QueryEditorContext);
35110
+ const updateQuery = useUpdateQuery();
34893
35111
  if (orderBys.length === 0) {
34894
35112
  return null;
34895
35113
  }
34896
35114
  return /* @__PURE__ */ jsxs("div", {
34897
35115
  children: [/* @__PURE__ */ jsx("div", {
34898
- ..._stylex.props(styles$u.title),
35116
+ ..._stylex.props(styles$v.title),
34899
35117
  children: "order by"
34900
35118
  }), /* @__PURE__ */ jsx("div", {
34901
- ..._stylex.props(styles$u.tokenContainer),
35119
+ ..._stylex.props(styles$v.tokenContainer),
34902
35120
  children: orderBys.map((orderBy) => {
34903
35121
  const {
34904
35122
  fieldReference
@@ -34929,7 +35147,7 @@ function OrderByOperations({
34929
35147
  value: orderBy.direction ?? "asc",
34930
35148
  onChange: (direction) => {
34931
35149
  orderBy.direction = direction;
34932
- setQuery == null ? void 0 : setQuery(rootQuery.build());
35150
+ updateQuery();
34933
35151
  }
34934
35152
  })]
34935
35153
  }), /* @__PURE__ */ jsx("div", {
@@ -34937,7 +35155,7 @@ function OrderByOperations({
34937
35155
  children: /* @__PURE__ */ jsx(ClearButton, {
34938
35156
  onClick: () => {
34939
35157
  orderBy.delete();
34940
- setQuery == null ? void 0 : setQuery(rootQuery.build());
35158
+ updateQuery();
34941
35159
  }
34942
35160
  })
34943
35161
  })]
@@ -34947,7 +35165,6 @@ function OrderByOperations({
34947
35165
  });
34948
35166
  }
34949
35167
  function View({
34950
- rootQuery,
34951
35168
  view
34952
35169
  }) {
34953
35170
  return /* @__PURE__ */ jsxs("div", {
@@ -34957,10 +35174,8 @@ function View({
34957
35174
  gap: 8
34958
35175
  },
34959
35176
  children: [/* @__PURE__ */ jsx(Visualization$1, {
34960
- rootQuery,
34961
35177
  view
34962
35178
  }), /* @__PURE__ */ jsx(ViewDefinition, {
34963
- rootQuery,
34964
35179
  view,
34965
35180
  viewDef: view.definition
34966
35181
  })]
@@ -34984,7 +35199,7 @@ function AddItem({
34984
35199
  children: /* @__PURE__ */ jsxs("div", {
34985
35200
  role: "menuitem",
34986
35201
  tabIndex: -1,
34987
- ..._stylex.props(addMenuStyles.item, addMenuStyles.clickable, open ? styles$f.open : null),
35202
+ ..._stylex.props(addMenuStyles.item, addMenuStyles.clickable, open ? styles$g.open : null),
34988
35203
  onClick: doOnClick,
34989
35204
  "data-disabled": disabled ? "true" : void 0,
34990
35205
  children: [/* @__PURE__ */ jsxs("div", {
@@ -35008,7 +35223,7 @@ function AddItem({
35008
35223
  }) : null]
35009
35224
  });
35010
35225
  }
35011
- const styles$f = {
35226
+ const styles$g = {
35012
35227
  open: {
35013
35228
  background: "mly16o7sp0",
35014
35229
  backgroundAttachment: null,
@@ -35025,12 +35240,9 @@ const styles$f = {
35025
35240
  }
35026
35241
  };
35027
35242
  function AddLimit({
35028
- rootQuery,
35029
35243
  view
35030
35244
  }) {
35031
- const {
35032
- setQuery
35033
- } = useContext(QueryEditorContext);
35245
+ const updateQuery = useUpdateQuery();
35034
35246
  const segment = getSegmentIfPresent(view);
35035
35247
  const hasLimit = segment ? segmentHasLimit(segment) : false;
35036
35248
  return /* @__PURE__ */ jsx(AddItem, {
@@ -35042,17 +35254,14 @@ function AddLimit({
35042
35254
  onClick: () => {
35043
35255
  const segment2 = view.getOrAddDefaultSegment();
35044
35256
  segment2.setLimit(10);
35045
- setQuery == null ? void 0 : setQuery(rootQuery.build());
35257
+ updateQuery();
35046
35258
  }
35047
35259
  });
35048
35260
  }
35049
35261
  function AddEmptyNest({
35050
- rootQuery,
35051
35262
  view
35052
35263
  }) {
35053
- const {
35054
- setQuery
35055
- } = useContext(QueryEditorContext);
35264
+ const updateQuery = useUpdateQuery();
35056
35265
  return /* @__PURE__ */ jsx(AddItem, {
35057
35266
  icon: /* @__PURE__ */ jsx(Icon, {
35058
35267
  name: "nest"
@@ -35062,7 +35271,7 @@ function AddEmptyNest({
35062
35271
  const segment = view.getOrAddDefaultSegment();
35063
35272
  const nestNo = segmentNestNo(segment, `Nest`);
35064
35273
  segment.addEmptyNest(nestNo > 1 ? `Nest ${nestNo}` : `Nest`);
35065
- setQuery == null ? void 0 : setQuery(rootQuery.build());
35274
+ updateQuery();
35066
35275
  }
35067
35276
  });
35068
35277
  }
@@ -35083,10 +35292,10 @@ function AddFieldItem({
35083
35292
  onAddOperation,
35084
35293
  isFilterOperation,
35085
35294
  search,
35086
- customStyle: styles$e.list
35295
+ customStyle: styles$f.list
35087
35296
  });
35088
35297
  }
35089
- const styles$e = {
35298
+ const styles$f = {
35090
35299
  list: {
35091
35300
  minWidth: "mly2ixbly",
35092
35301
  maxWidth: "mly1j9u4d2",
@@ -35094,13 +35303,10 @@ const styles$e = {
35094
35303
  }
35095
35304
  };
35096
35305
  function AddOrderBy({
35097
- rootQuery,
35098
35306
  view,
35099
35307
  search
35100
35308
  }) {
35101
- const {
35102
- setQuery
35103
- } = useContext(QueryEditorContext);
35309
+ const updateQuery = useUpdateQuery();
35104
35310
  const outputSchemaFields = view.getOutputSchema().fields;
35105
35311
  const segment = getSegmentIfPresent(view);
35106
35312
  const fields = useMemo(() => outputSchemaFields.filter((field) => field.kind === "dimension").filter((field) => ORDERABLE_TYPES$1.includes(field.type.kind)).filter((field) => segment ? !segmentHasOrderBy(segment, field.name) : true), [outputSchemaFields, segment]);
@@ -35112,7 +35318,7 @@ function AddOrderBy({
35112
35318
  types: ["dimension"],
35113
35319
  onAddOperation: (field) => {
35114
35320
  addOrderBy(view, field);
35115
- setQuery == null ? void 0 : setQuery(rootQuery.build());
35321
+ updateQuery();
35116
35322
  },
35117
35323
  disabledMessage: "There must be at least one field in the output to order by.",
35118
35324
  search
@@ -35120,13 +35326,10 @@ function AddOrderBy({
35120
35326
  }
35121
35327
  const ORDERABLE_TYPES$1 = ["string_type", "number_type", "boolean_type", "date_type", "timestamp_type"];
35122
35328
  function AddGroupBy({
35123
- rootQuery,
35124
35329
  view,
35125
35330
  search
35126
35331
  }) {
35127
- const {
35128
- setQuery
35129
- } = useContext(QueryEditorContext);
35332
+ const updateQuery = useUpdateQuery();
35130
35333
  const {
35131
35334
  fields
35132
35335
  } = getInputSchemaFromViewParent(view);
@@ -35143,19 +35346,16 @@ function AddGroupBy({
35143
35346
  filter,
35144
35347
  onAddOperation: (field, path) => {
35145
35348
  addGroupBy(view, field, path);
35146
- setQuery == null ? void 0 : setQuery(rootQuery.build());
35349
+ updateQuery();
35147
35350
  },
35148
35351
  search
35149
35352
  });
35150
35353
  }
35151
35354
  function AddAggregate({
35152
- rootQuery,
35153
35355
  view,
35154
35356
  search
35155
35357
  }) {
35156
- const {
35157
- setQuery
35158
- } = useContext(QueryEditorContext);
35358
+ const updateQuery = useUpdateQuery();
35159
35359
  const {
35160
35360
  fields
35161
35361
  } = getInputSchemaFromViewParent(view);
@@ -35172,7 +35372,7 @@ function AddAggregate({
35172
35372
  filter,
35173
35373
  onAddOperation: (field, path) => {
35174
35374
  addAggregate(view, field, path);
35175
- setQuery == null ? void 0 : setQuery(rootQuery.build());
35375
+ updateQuery();
35176
35376
  },
35177
35377
  search
35178
35378
  });
@@ -35181,10 +35381,7 @@ function AddWhere({
35181
35381
  view,
35182
35382
  search
35183
35383
  }) {
35184
- const {
35185
- rootQuery,
35186
- setQuery
35187
- } = React.useContext(QueryEditorContext);
35384
+ const updateQuery = useUpdateQuery();
35188
35385
  const {
35189
35386
  fields
35190
35387
  } = getInputSchemaFromViewParent(view);
@@ -35198,7 +35395,7 @@ function AddWhere({
35198
35395
  onAddOperation: (field, path, filter) => {
35199
35396
  if (filter && (field.kind === "dimension" || field.kind === "measure")) {
35200
35397
  addFilter(view, field, path, filter);
35201
- setQuery == null ? void 0 : setQuery(rootQuery == null ? void 0 : rootQuery.build());
35398
+ updateQuery();
35202
35399
  }
35203
35400
  },
35204
35401
  isFilterOperation: true,
@@ -35207,15 +35404,18 @@ function AddWhere({
35207
35404
  }
35208
35405
  const FILTERABLE_TYPES$1 = /* @__PURE__ */ new Set(["string_type", "boolean_type", "number_type", "date_type", "timestamp_type"]);
35209
35406
  function AddView({
35210
- rootQuery,
35211
35407
  view,
35212
35408
  search
35213
35409
  }) {
35214
35410
  const {
35215
- setQuery
35411
+ rootQuery
35216
35412
  } = useContext(QueryEditorContext);
35413
+ const updateQuery = useUpdateQuery();
35217
35414
  const allFields = getInputSchemaFromViewParent(view).fields;
35218
35415
  const fields = useMemo(() => allFields.filter((field) => field.kind === "view" && !isIndexView(field)), [allFields]);
35416
+ if (!rootQuery) {
35417
+ return null;
35418
+ }
35219
35419
  return /* @__PURE__ */ jsx(AddFieldItem, {
35220
35420
  label: "Add view",
35221
35421
  icon: "view",
@@ -35229,20 +35429,17 @@ function AddView({
35229
35429
  } else {
35230
35430
  addNest(view, field);
35231
35431
  }
35232
- setQuery == null ? void 0 : setQuery(rootQuery.build());
35432
+ updateQuery();
35233
35433
  },
35234
35434
  search
35235
35435
  });
35236
35436
  }
35237
35437
  function AddMenu({
35238
- rootQuery,
35239
35438
  view
35240
35439
  }) {
35241
35440
  const [open, setOpen] = useState(false);
35242
35441
  const [active, setActive] = useState("");
35243
- const {
35244
- setQuery
35245
- } = useContext(QueryEditorContext);
35442
+ const updateQuery = useUpdateQuery();
35246
35443
  const [search, setSearch] = useState("");
35247
35444
  const segment = getSegmentIfPresent(view);
35248
35445
  const toggleActive = (toggle) => {
@@ -35283,7 +35480,7 @@ function AddMenu({
35283
35480
  value: search,
35284
35481
  onChange: setSearch,
35285
35482
  placeholder: "Search...",
35286
- customStyle: styles$d.search
35483
+ customStyle: styles$e.search
35287
35484
  })
35288
35485
  }), /* @__PURE__ */ jsx(Divider, {}), /* @__PURE__ */ jsxs("div", {
35289
35486
  ...{
@@ -35306,7 +35503,7 @@ function AddMenu({
35306
35503
  } else {
35307
35504
  addNest(view, field);
35308
35505
  }
35309
- setQuery == null ? void 0 : setQuery(rootQuery.build());
35506
+ updateQuery();
35310
35507
  },
35311
35508
  search
35312
35509
  }), /* @__PURE__ */ jsx(Divider, {}), /* @__PURE__ */ jsx(ValueList, {
@@ -35322,7 +35519,7 @@ function AddMenu({
35322
35519
  values: [value.fieldValue ?? "∅"]
35323
35520
  }
35324
35521
  });
35325
- setQuery == null ? void 0 : setQuery(rootQuery.build());
35522
+ updateQuery();
35326
35523
  }
35327
35524
  })]
35328
35525
  }) : /* @__PURE__ */ jsxs("div", {
@@ -35359,7 +35556,6 @@ function AddMenu({
35359
35556
  onClick: () => toggleActive("view"),
35360
35557
  open: active === "view"
35361
35558
  }), /* @__PURE__ */ jsx(Divider, {}), /* @__PURE__ */ jsx(AddLimit, {
35362
- rootQuery,
35363
35559
  view
35364
35560
  }), /* @__PURE__ */ jsx(AddItem, {
35365
35561
  icon: /* @__PURE__ */ jsx(Icon, {
@@ -35369,7 +35565,6 @@ function AddMenu({
35369
35565
  onClick: () => toggleActive("order_by"),
35370
35566
  open: active === "order_by"
35371
35567
  }), /* @__PURE__ */ jsx(AddEmptyNest, {
35372
- rootQuery,
35373
35568
  view
35374
35569
  })]
35375
35570
  }), /* @__PURE__ */ jsxs("div", {
@@ -35378,23 +35573,18 @@ function AddMenu({
35378
35573
  overflowY: "auto"
35379
35574
  },
35380
35575
  children: [active === "group_by" && /* @__PURE__ */ jsx(AddGroupBy, {
35381
- rootQuery,
35382
35576
  view,
35383
35577
  search
35384
35578
  }), active === "aggregate" && /* @__PURE__ */ jsx(AddAggregate, {
35385
- rootQuery,
35386
35579
  view,
35387
35580
  search
35388
35581
  }), active === "where" && /* @__PURE__ */ jsx(AddWhere, {
35389
- rootQuery,
35390
35582
  view,
35391
35583
  search
35392
35584
  }), active === "view" && /* @__PURE__ */ jsx(AddView, {
35393
- rootQuery,
35394
35585
  view,
35395
35586
  search
35396
35587
  }), active === "order_by" && /* @__PURE__ */ jsx(AddOrderBy, {
35397
- rootQuery,
35398
35588
  view,
35399
35589
  search
35400
35590
  })]
@@ -35404,7 +35594,7 @@ function AddMenu({
35404
35594
  })]
35405
35595
  });
35406
35596
  }
35407
- const styles$d = {
35597
+ const styles$e = {
35408
35598
  search: {
35409
35599
  width: "mlyh8yej3",
35410
35600
  $$css: true
@@ -35440,7 +35630,6 @@ function FocusableView({
35440
35630
  });
35441
35631
  }
35442
35632
  function NestOperations({
35443
- rootQuery,
35444
35633
  view,
35445
35634
  nests
35446
35635
  }) {
@@ -35448,22 +35637,18 @@ function NestOperations({
35448
35637
  return null;
35449
35638
  }
35450
35639
  return /* @__PURE__ */ jsx("div", {
35451
- ..._stylex.props(styles$u.tokenContainer),
35640
+ ..._stylex.props(styles$v.tokenContainer),
35452
35641
  children: nests.map((nest) => /* @__PURE__ */ jsx(NestOperation, {
35453
- rootQuery,
35454
35642
  view,
35455
35643
  nest
35456
35644
  }, nest.name))
35457
35645
  });
35458
35646
  }
35459
35647
  function NestOperation({
35460
- rootQuery,
35461
35648
  view,
35462
35649
  nest
35463
35650
  }) {
35464
- const {
35465
- setQuery
35466
- } = useContext(QueryEditorContext);
35651
+ const updateQuery = useUpdateQuery();
35467
35652
  const [renameOpen, setRenameOpen] = useState(false);
35468
35653
  const parentNestViewPath = useContext(NestViewPathContext);
35469
35654
  const {
@@ -35484,7 +35669,7 @@ function NestOperation({
35484
35669
  onClick: () => {
35485
35670
  focusNestView([...parentNestViewPath]);
35486
35671
  nest2.delete();
35487
- setQuery == null ? void 0 : setQuery(rootQuery.build());
35672
+ updateQuery();
35488
35673
  }
35489
35674
  }), /* @__PURE__ */ jsx(DropdownMenuItem, {
35490
35675
  label: "Rename",
@@ -35493,7 +35678,6 @@ function NestOperation({
35493
35678
  }
35494
35679
  })]
35495
35680
  }), /* @__PURE__ */ jsx(AddMenu, {
35496
- rootQuery,
35497
35681
  view: nest2.view
35498
35682
  })]
35499
35683
  });
@@ -35505,17 +35689,15 @@ function NestOperation({
35505
35689
  },
35506
35690
  children: [/* @__PURE__ */ jsx(CollapsiblePanel, {
35507
35691
  title: nest.name,
35508
- icon: viewToVisualizationIcon(nest.view),
35692
+ icon: tagToVisualization(nest.view.getTag()),
35509
35693
  defaultOpen: true,
35510
35694
  controls: getControls(nest),
35511
35695
  collapsedControls: getControls(nest),
35512
35696
  isFocused: isNestViewFocused([...parentNestViewPath, nest.name]),
35513
35697
  children: /* @__PURE__ */ jsx(View, {
35514
- rootQuery,
35515
35698
  view: nest.view
35516
35699
  })
35517
35700
  }), /* @__PURE__ */ jsx(RenameDialog, {
35518
- rootQuery,
35519
35701
  view,
35520
35702
  target: nest,
35521
35703
  open: renameOpen,
@@ -35525,7 +35707,6 @@ function NestOperation({
35525
35707
  });
35526
35708
  }
35527
35709
  function Operations({
35528
- rootQuery,
35529
35710
  view,
35530
35711
  viewDef
35531
35712
  }) {
@@ -35543,7 +35724,7 @@ function Operations({
35543
35724
  segment.operations.items.forEach((operation) => {
35544
35725
  if (operation instanceof ASTGroupByViewOperation) {
35545
35726
  groupBys.push(operation);
35546
- } else if (operation instanceof ASTAggregateViewOperation) {
35727
+ } else if (operation instanceof ASTAggregateViewOperation || operation instanceof ASTCalculateViewOperation) {
35547
35728
  aggregates.push(operation);
35548
35729
  } else if (operation instanceof ASTWhereViewOperation) {
35549
35730
  filters.push(operation);
@@ -35564,66 +35745,53 @@ function Operations({
35564
35745
  className: "mly1tpqehw mly10lvyaf"
35565
35746
  },
35566
35747
  children: [/* @__PURE__ */ jsx(GroupByOperations, {
35567
- rootQuery,
35568
35748
  segment,
35569
35749
  view,
35570
35750
  groupBys
35571
35751
  }), /* @__PURE__ */ jsx(AggregateOperations, {
35572
- rootQuery,
35573
35752
  segment,
35574
35753
  view,
35575
35754
  aggregates
35576
35755
  }), /* @__PURE__ */ jsx(DrillOperations, {
35577
- rootQuery,
35578
35756
  drills
35579
35757
  }), /* @__PURE__ */ jsx(FilterOperations, {
35580
- rootQuery,
35581
35758
  filters
35582
35759
  }), /* @__PURE__ */ jsx(OrderByOperations, {
35583
- rootQuery,
35584
35760
  orderBys
35585
35761
  }), /* @__PURE__ */ jsx(NestOperations, {
35586
- rootQuery,
35587
35762
  view,
35588
35763
  nests
35589
35764
  }), /* @__PURE__ */ jsx(LimitOperation, {
35590
- rootQuery,
35591
35765
  limit
35592
35766
  })]
35593
35767
  });
35594
35768
  }
35595
35769
  function ViewDefinition({
35596
- rootQuery,
35597
35770
  view,
35598
35771
  viewDef
35599
35772
  }) {
35600
35773
  if (viewDef instanceof ASTArrowViewDefinition) {
35601
35774
  return /* @__PURE__ */ jsx(ViewDefinition, {
35602
- rootQuery,
35603
35775
  view,
35604
35776
  viewDef: viewDef.view
35605
35777
  });
35606
35778
  } else if (viewDef instanceof ASTRefinementViewDefinition) {
35607
35779
  return /* @__PURE__ */ jsxs("div", {
35608
35780
  children: [/* @__PURE__ */ jsx(ViewDefinition, {
35609
- rootQuery,
35610
35781
  view,
35611
35782
  viewDef: viewDef.base
35612
35783
  }), /* @__PURE__ */ jsx(ViewDefinition, {
35613
- rootQuery,
35614
35784
  view,
35615
35785
  viewDef: viewDef.refinement
35616
35786
  })]
35617
35787
  });
35618
35788
  } else if (viewDef instanceof ASTSegmentViewDefinition) {
35619
35789
  return /* @__PURE__ */ jsx(Operations, {
35620
- rootQuery,
35621
35790
  view,
35622
35791
  viewDef
35623
35792
  });
35624
35793
  } else {
35625
35794
  return /* @__PURE__ */ jsx(CollapsingView, {
35626
- rootQuery,
35627
35795
  viewDef
35628
35796
  });
35629
35797
  }
@@ -35660,11 +35828,11 @@ function CollapsingView({
35660
35828
  })]
35661
35829
  }), !collapsed && /* @__PURE__ */ jsx(ViewAttributeTable, {
35662
35830
  viewInfo: viewDef.getViewInfo(),
35663
- style: styles$c.preview
35831
+ style: styles$d.preview
35664
35832
  })]
35665
35833
  });
35666
35834
  }
35667
- const styles$c = {
35835
+ const styles$d = {
35668
35836
  preview: {
35669
35837
  height: "mlyt7dq6l",
35670
35838
  maxHeight: "mly1hkcv85",
@@ -35692,14 +35860,21 @@ const styles$c = {
35692
35860
  }
35693
35861
  };
35694
35862
  function Query({
35695
- rootQuery,
35696
- query,
35697
- setQuery
35863
+ definition
35698
35864
  }) {
35699
35865
  const {
35700
35866
  focusMainView,
35701
35867
  isMainViewFocused
35702
35868
  } = useQueryFocus();
35869
+ const {
35870
+ rootQuery,
35871
+ setQuery
35872
+ } = useContext(QueryEditorContext);
35873
+ const updateQuery = useUpdateQuery();
35874
+ if (!rootQuery) {
35875
+ return null;
35876
+ }
35877
+ const isEmpty = rootQuery.isEmpty();
35703
35878
  return /* @__PURE__ */ jsx(FocusableView, {
35704
35879
  children: /* @__PURE__ */ jsxs(CollapsiblePanel, {
35705
35880
  title: "Main query",
@@ -35718,44 +35893,41 @@ function Query({
35718
35893
  label: "Clear query",
35719
35894
  onClick: () => {
35720
35895
  focusMainView();
35721
- setQuery == null ? void 0 : setQuery(void 0);
35896
+ setQuery(void 0);
35722
35897
  },
35723
- disabled: rootQuery.isEmpty()
35898
+ disabled: isEmpty
35724
35899
  }), /* @__PURE__ */ jsx(DropdownMenuItem, {
35725
35900
  icon: "nest",
35726
35901
  label: "Nest query",
35727
35902
  onClick: () => {
35728
- if (rootQuery.definition instanceof ASTArrowQueryDefinition) {
35729
- rootQuery.definition.view.convertToNest("Nest");
35903
+ if (definition instanceof ASTArrowQueryDefinition) {
35904
+ definition.view.convertToNest("Nest");
35730
35905
  }
35731
- setQuery == null ? void 0 : setQuery(rootQuery.build());
35906
+ updateQuery();
35732
35907
  },
35733
- disabled: rootQuery.isEmpty() || !(rootQuery.definition instanceof ASTArrowQueryDefinition)
35908
+ disabled: isEmpty || !(definition instanceof ASTArrowQueryDefinition)
35734
35909
  })]
35735
35910
  }) : /* @__PURE__ */ jsx(Fragment, {})
35736
- }), query.definition instanceof ASTArrowQueryDefinition ? /* @__PURE__ */ jsx(AddMenu, {
35737
- rootQuery,
35738
- view: query.definition
35911
+ }), definition instanceof ASTArrowQueryDefinition ? /* @__PURE__ */ jsx(AddMenu, {
35912
+ view: definition
35739
35913
  }) : null]
35740
35914
  }),
35741
35915
  collapsedControls: /* @__PURE__ */ jsx(Icon, {
35742
- name: viewToVisualizationIcon(query)
35916
+ name: tagToVisualization(rootQuery.getTag())
35743
35917
  }),
35744
- children: [query.definition instanceof ASTArrowQueryDefinition ? /* @__PURE__ */ jsxs("div", {
35918
+ children: [definition instanceof ASTArrowQueryDefinition ? /* @__PURE__ */ jsxs("div", {
35745
35919
  style: {
35746
35920
  display: "flex",
35747
35921
  flexDirection: "column",
35748
35922
  gap: 8
35749
35923
  },
35750
- children: [!query.isEmpty() && /* @__PURE__ */ jsx(Visualization$1, {
35751
- rootQuery,
35752
- view: query
35924
+ children: [!isEmpty && /* @__PURE__ */ jsx(Visualization$1, {
35925
+ view: rootQuery
35753
35926
  }), /* @__PURE__ */ jsx(ViewDefinition, {
35754
- rootQuery,
35755
- view: query.definition,
35756
- viewDef: query.definition.view
35927
+ view: definition,
35928
+ viewDef: definition.view
35757
35929
  })]
35758
- }) : null, query.isEmpty() ? /* @__PURE__ */ jsx("div", {
35930
+ }) : null, isEmpty ? /* @__PURE__ */ jsx("div", {
35759
35931
  ...{
35760
35932
  className: "mly78zum5 mlyl56j7k mly6s0dn4 mlyng8ra"
35761
35933
  },
@@ -35777,27 +35949,27 @@ function Query({
35777
35949
  });
35778
35950
  }
35779
35951
  function Source({
35780
- rootQuery
35952
+ definition
35781
35953
  }) {
35782
- if (rootQuery.definition instanceof ASTArrowQueryDefinition) {
35954
+ if (definition instanceof ASTArrowQueryDefinition) {
35783
35955
  return /* @__PURE__ */ jsx("div", {
35784
- ..._stylex.props(styles$u.queryCard, styles$b.content),
35956
+ ..._stylex.props(styles$v.queryCard, styles$c.content),
35785
35957
  children: /* @__PURE__ */ jsxs("div", {
35786
- ..._stylex.props(styles$u.labelWithIcon),
35958
+ ..._stylex.props(styles$v.labelWithIcon),
35787
35959
  children: [/* @__PURE__ */ jsx(Icon, {
35788
35960
  name: "database"
35789
35961
  }), /* @__PURE__ */ jsx("div", {
35790
35962
  ...{
35791
35963
  className: "mlyb3r6kr mlylyipyv mly117nqv4"
35792
35964
  },
35793
- children: rootQuery.definition.as.ArrowQueryDefinition().source.as.ReferenceQueryArrowSource().name
35965
+ children: definition.source.getSourceInfo().name
35794
35966
  })]
35795
35967
  })
35796
35968
  });
35797
35969
  }
35798
35970
  return null;
35799
35971
  }
35800
- const styles$b = {
35972
+ const styles$c = {
35801
35973
  content: {
35802
35974
  display: "mlyrvj5dj",
35803
35975
  gridAutoFlow: "mly1mt1orb",
@@ -35848,15 +36020,15 @@ function DateLiteralEditor({
35848
36020
  children: [/* @__PURE__ */ jsx(Trigger$2, {
35849
36021
  asChild: true,
35850
36022
  children: /* @__PURE__ */ jsx("div", {
35851
- ..._stylex.props(tokenStyles.main, styles$a.wrapper, customStyle),
36023
+ ..._stylex.props(tokenStyles.main, styles$b.wrapper, customStyle),
35852
36024
  children: /* @__PURE__ */ jsx(DateInput, {
35853
36025
  value: hooks.utc(date).toDate(),
35854
36026
  setValue: onSetValue,
35855
36027
  units,
35856
36028
  onFocus: () => setOpen(true),
35857
36029
  customStyle: {
35858
- ...styles$a.input,
35859
- ...isDate2 ? styles$a.dateInput : styles$a.timestampInput
36030
+ ...styles$b.input,
36031
+ ...isDate2 ? styles$b.dateInput : styles$b.timestampInput
35860
36032
  },
35861
36033
  forwardRef: input
35862
36034
  })
@@ -35872,14 +36044,14 @@ function DateLiteralEditor({
35872
36044
  setValue: onSetValue,
35873
36045
  units,
35874
36046
  maxLevel: units,
35875
- customStyle: styles$a.datePicker,
36047
+ customStyle: styles$b.datePicker,
35876
36048
  forwardRef: picker
35877
36049
  })
35878
36050
  })
35879
36051
  })]
35880
36052
  });
35881
36053
  }
35882
- const styles$a = {
36054
+ const styles$b = {
35883
36055
  input: {
35884
36056
  border: "mly1gs6z28",
35885
36057
  borderWidth: null,
@@ -36127,13 +36299,13 @@ function LiteralValueEditor({
36127
36299
  }
36128
36300
  }
36129
36301
  function Parameters({
36130
- rootQuery
36302
+ definition
36131
36303
  }) {
36132
- const {
36133
- setQuery
36134
- } = useContext(QueryEditorContext);
36135
- if (rootQuery.definition instanceof ASTArrowQueryDefinition) {
36136
- const source = rootQuery.definition.as.ArrowQueryDefinition().source.as.ReferenceQueryArrowSource();
36304
+ const updateQuery = useUpdateQuery();
36305
+ if (definition instanceof ASTArrowQueryDefinition && definition.source instanceof ASTReferenceQueryArrowSource) {
36306
+ const {
36307
+ source
36308
+ } = definition;
36137
36309
  const sourceParameters = source.getSourceParameters();
36138
36310
  if (!sourceParameters || sourceParameters.length === 0) {
36139
36311
  return null;
@@ -36147,7 +36319,7 @@ function Parameters({
36147
36319
  children: sourceParameters.map((parameter) => {
36148
36320
  var _a2;
36149
36321
  return /* @__PURE__ */ jsxs(TokenGroup, {
36150
- customStyle: styles$9.tokenGroup,
36322
+ customStyle: styles$a.tokenGroup,
36151
36323
  children: [/* @__PURE__ */ jsx(Token, {
36152
36324
  icon: atomicTypeToIcon(parameter.type.kind),
36153
36325
  label: parameter.name
@@ -36156,7 +36328,7 @@ function Parameters({
36156
36328
  value: ((_a2 = source.tryGetParameter(parameter.name)) == null ? void 0 : _a2.parameter.value) ?? parameter.default_value,
36157
36329
  setValue: (value) => {
36158
36330
  source.setParameter(parameter.name, value);
36159
- setQuery == null ? void 0 : setQuery(rootQuery.build());
36331
+ updateQuery();
36160
36332
  }
36161
36333
  })]
36162
36334
  }, parameter.name);
@@ -36166,7 +36338,7 @@ function Parameters({
36166
36338
  }
36167
36339
  return null;
36168
36340
  }
36169
- const styles$9 = {
36341
+ const styles$a = {
36170
36342
  tokenGroup: {
36171
36343
  display: "mly78zum5",
36172
36344
  $$css: true
@@ -36174,27 +36346,27 @@ const styles$9 = {
36174
36346
  };
36175
36347
  function QueryEditor() {
36176
36348
  const {
36177
- rootQuery,
36178
- setQuery
36349
+ rootQuery
36179
36350
  } = useContext(QueryEditorContext);
36180
36351
  if (!rootQuery) {
36181
36352
  console.error("Missing <MalloyExplorerProvider>");
36182
36353
  return null;
36183
36354
  }
36355
+ const {
36356
+ definition
36357
+ } = rootQuery;
36184
36358
  return /* @__PURE__ */ jsxs("div", {
36185
- ..._stylex.props(fontStyles.body, styles$8.main),
36359
+ ..._stylex.props(fontStyles.body, styles$9.main),
36186
36360
  children: [/* @__PURE__ */ jsx(Source, {
36187
- rootQuery
36361
+ definition
36188
36362
  }), /* @__PURE__ */ jsx(Parameters, {
36189
- rootQuery
36363
+ definition
36190
36364
  }), /* @__PURE__ */ jsx(Query, {
36191
- rootQuery,
36192
- query: rootQuery,
36193
- setQuery
36365
+ definition
36194
36366
  })]
36195
36367
  });
36196
36368
  }
36197
- const styles$8 = {
36369
+ const styles$9 = {
36198
36370
  main: {
36199
36371
  display: "mly78zum5",
36200
36372
  flexDirection: "mlydt5ytf",
@@ -36244,7 +36416,7 @@ function BookmarkedView({
36244
36416
  label: "view",
36245
36417
  icon: "view_filled",
36246
36418
  color: "purple",
36247
- customStyle: styles$7.viewBadge
36419
+ customStyle: styles$8.viewBadge
36248
36420
  }), /* @__PURE__ */ jsx(Button, {
36249
36421
  variant: "default",
36250
36422
  size: "compact",
@@ -36260,14 +36432,14 @@ function BookmarkedView({
36260
36432
  })]
36261
36433
  })]
36262
36434
  }),
36263
- customStyle: styles$7.card,
36435
+ customStyle: styles$8.card,
36264
36436
  children: /* @__PURE__ */ jsx(ViewAttributeTable, {
36265
36437
  viewInfo
36266
36438
  })
36267
36439
  })
36268
36440
  });
36269
36441
  }
36270
- const styles$7 = {
36442
+ const styles$8 = {
36271
36443
  viewBadge: {
36272
36444
  backgroundColor: "mlyjbqb8w",
36273
36445
  $$css: true
@@ -36290,7 +36462,7 @@ function EmptyQueryDisplay({
36290
36462
  className: "mly1bpp3o7 mly78zum5 mlydt5ytf mlyl56j7k mly6s0dn4"
36291
36463
  },
36292
36464
  children: [/* @__PURE__ */ jsx("div", {
36293
- ..._stylex.props(styles$6.header, fontStyles.emphasized),
36465
+ ..._stylex.props(styles$7.header, fontStyles.emphasized),
36294
36466
  children: "Start with a Bookmarked View"
36295
36467
  }), /* @__PURE__ */ jsx("div", {
36296
36468
  ...{
@@ -36306,7 +36478,7 @@ function EmptyQueryDisplay({
36306
36478
  })
36307
36479
  });
36308
36480
  }
36309
- const styles$6 = {
36481
+ const styles$7 = {
36310
36482
  header: {
36311
36483
  paddingBottom: "mly1l90r2v",
36312
36484
  $$css: true
@@ -36500,7 +36672,7 @@ function RunInfoHover({
36500
36672
  children: [/* @__PURE__ */ jsx(Trigger$4, {
36501
36673
  asChild: true,
36502
36674
  children: /* @__PURE__ */ jsxs("div", {
36503
- ..._stylex.props(styles$5.triggerContentContainer, fontStyles.body),
36675
+ ..._stylex.props(styles$6.triggerContentContainer, fontStyles.body),
36504
36676
  children: [/* @__PURE__ */ jsx(Icon, {
36505
36677
  name: "info",
36506
36678
  color: "disabled"
@@ -36511,7 +36683,7 @@ function RunInfoHover({
36511
36683
  side: HOVER_SIDE,
36512
36684
  align: HOVER_ALIGN,
36513
36685
  children: /* @__PURE__ */ jsx(HoverCard, {
36514
- customStyle: styles$5.card,
36686
+ customStyle: styles$6.card,
36515
36687
  children: /* @__PURE__ */ jsxs(Fragment, {
36516
36688
  children: [runInfo.customContent, (runInfo == null ? void 0 : runInfo.performanceAspects) && Object.entries(runInfo.performanceAspects).map(([aspect, properties2]) => {
36517
36689
  return /* @__PURE__ */ jsx("div", {
@@ -36529,7 +36701,7 @@ function RunInfoHover({
36529
36701
  href: runInfo.queryLink.href,
36530
36702
  target: "_blank",
36531
36703
  rel: "noreferrer",
36532
- ..._stylex.props(styles$5.link, fontStyles.link),
36704
+ ..._stylex.props(styles$6.link, fontStyles.link),
36533
36705
  children: runInfo.queryLink.linkText
36534
36706
  })]
36535
36707
  })
@@ -36538,7 +36710,7 @@ function RunInfoHover({
36538
36710
  })]
36539
36711
  });
36540
36712
  }
36541
- const styles$5 = {
36713
+ const styles$6 = {
36542
36714
  card: {
36543
36715
  maxWidth: "mly1dc814f",
36544
36716
  $$css: true
@@ -36733,7 +36905,7 @@ function RenderedResult({
36733
36905
  query: stableQuery,
36734
36906
  source
36735
36907
  });
36736
- setQuery == null ? void 0 : setQuery(rootQuery.build());
36908
+ setQuery(rootQuery.build());
36737
36909
  },
36738
36910
  tableConfig: {
36739
36911
  enableDrill: true
@@ -36789,7 +36961,7 @@ function LoadingDisplay({
36789
36961
  },
36790
36962
  children: [/* @__PURE__ */ jsx(Spinner, {
36791
36963
  size: "large",
36792
- customStyle: styles$4.spinner
36964
+ customStyle: styles$5.spinner
36793
36965
  }), /* @__PURE__ */ jsx("div", {
36794
36966
  ..._stylex.props(fontStyles.emphasized),
36795
36967
  children: `${EXECUTION_STATES[executionState]} query...`
@@ -36813,7 +36985,7 @@ function useTimeElapsedMillis(queryResolutionStartMillis) {
36813
36985
  }, [queryResolutionStartMillis]);
36814
36986
  return time;
36815
36987
  }
36816
- const styles$4 = {
36988
+ const styles$5 = {
36817
36989
  spinner: {
36818
36990
  marginBottom: "mly1e56ztr",
36819
36991
  $$css: true
@@ -36882,6 +37054,383 @@ function CopyToClipboard({
36882
37054
  }
36883
37055
  });
36884
37056
  }
37057
+ class DataWriter {
37058
+ constructor(stream, result) {
37059
+ this.stream = stream;
37060
+ this.result = result;
37061
+ }
37062
+ }
37063
+ class JSONWriter extends DataWriter {
37064
+ async process(data) {
37065
+ this.stream.write("[\n");
37066
+ let first = true;
37067
+ for await (const row of data) {
37068
+ if (first) {
37069
+ first = false;
37070
+ } else {
37071
+ this.stream.write(",\n");
37072
+ }
37073
+ const json2 = JSON.stringify(toObject(this.result.schema.fields.filter((field) => field.kind === "dimension"), row.record_value), null, 2);
37074
+ const jsonLines = json2.split("\n");
37075
+ for (let i2 = 0; i2 < jsonLines.length; i2++) {
37076
+ const line = jsonLines[i2];
37077
+ this.stream.write(` ${line}`);
37078
+ if (i2 < jsonLines.length - 1) {
37079
+ this.stream.write("\n");
37080
+ }
37081
+ }
37082
+ }
37083
+ this.stream.write("\n]\n");
37084
+ this.stream.close();
37085
+ }
37086
+ }
37087
+ class CSVWriter extends DataWriter {
37088
+ constructor() {
37089
+ super(...arguments);
37090
+ this.columnSeparator = ",";
37091
+ this.rowSeparator = "\n";
37092
+ this.quoteCharacter = '"';
37093
+ this.includeHeader = true;
37094
+ this.emptyCell = "";
37095
+ }
37096
+ escape(value) {
37097
+ const hasInnerQuote = value.includes(this.quoteCharacter);
37098
+ const hasInnerCommas = value.includes(this.columnSeparator);
37099
+ const hasNewline = value.includes(this.rowSeparator);
37100
+ const needsQuoting = hasInnerCommas || hasInnerQuote || hasNewline;
37101
+ if (hasInnerQuote) {
37102
+ value = value.replace(new RegExp(this.quoteCharacter, "g"), this.quoteCharacter + this.quoteCharacter);
37103
+ }
37104
+ if (needsQuoting) {
37105
+ value = this.quoteCharacter + value + this.quoteCharacter;
37106
+ }
37107
+ return value;
37108
+ }
37109
+ // Re-using the old stringify method for sanity.
37110
+ stringify(value) {
37111
+ switch (value.kind) {
37112
+ case "string_cell":
37113
+ return this.escape(value.string_value);
37114
+ case "boolean_cell":
37115
+ return JSON.stringify(value.boolean_value);
37116
+ case "number_cell":
37117
+ return JSON.stringify(value.number_value);
37118
+ case "date_cell":
37119
+ return value.date_value;
37120
+ case "timestamp_cell":
37121
+ return value.timestamp_value;
37122
+ case "json_cell":
37123
+ return this.escape(value.json_value);
37124
+ case "null_cell":
37125
+ return this.emptyCell;
37126
+ case "sql_native_cell":
37127
+ return this.escape(value.sql_native_value);
37128
+ }
37129
+ return "";
37130
+ }
37131
+ // Extra weight to be added because of nested tables inside the cells.
37132
+ getColWeight(fields) {
37133
+ let numKeys = 0;
37134
+ for (const field of fields) {
37135
+ numKeys = numKeys + 1;
37136
+ if (field.type.kind === "array_type" && field.type.element_type.kind === "record_type") {
37137
+ const weight = this.getColWeight(field.type.element_type.fields) - 1;
37138
+ numKeys = numKeys + weight;
37139
+ }
37140
+ }
37141
+ return numKeys;
37142
+ }
37143
+ // Get header row along with extra empty spaces for nested children.
37144
+ getHeaderRow(fields) {
37145
+ const csv = [];
37146
+ let width = 0;
37147
+ for (const field of fields) {
37148
+ csv.push(this.escape(field.name));
37149
+ width++;
37150
+ if (field.type.kind === "array_type" && field.type.element_type.kind === "record_type") {
37151
+ const numKeys = this.getColWeight(field.type.element_type.fields) - 1;
37152
+ width = width + numKeys;
37153
+ for (let i2 = 0; i2 < numKeys; i2++) {
37154
+ csv.push(this.emptyCell);
37155
+ }
37156
+ }
37157
+ }
37158
+ return {
37159
+ rows: [csv.join(this.columnSeparator)],
37160
+ length: 1,
37161
+ width
37162
+ };
37163
+ }
37164
+ // Merge the child matrices i.e. merge the columns into one bigger matrix i.e. CSV.
37165
+ mergeMatrices(matrices) {
37166
+ const maxLength = Math.max(...matrices.map((matrix) => matrix.length));
37167
+ const matrixWidth = matrices.reduce((sum, matrix) => sum + matrix.width, 0);
37168
+ const csvMatrix = [];
37169
+ for (let i2 = 0; i2 < maxLength; i2++) {
37170
+ const csvRow = [];
37171
+ for (const matrix of matrices) {
37172
+ if (i2 < matrix.length) {
37173
+ csvRow.push(matrix.rows[i2]);
37174
+ } else {
37175
+ const emptyCells = Array(matrix.width).fill(this.emptyCell);
37176
+ csvRow.push(...emptyCells);
37177
+ }
37178
+ }
37179
+ csvMatrix.push(csvRow.join(this.columnSeparator));
37180
+ }
37181
+ return {
37182
+ rows: csvMatrix,
37183
+ length: maxLength,
37184
+ width: matrixWidth
37185
+ };
37186
+ }
37187
+ // Gets CSV for a data cell that has nested data.
37188
+ getChildMatrix(fields, value) {
37189
+ if (value.kind !== "array_cell") {
37190
+ return {
37191
+ rows: ["Invalid data found, value is not an array"],
37192
+ length: 1,
37193
+ width: 1
37194
+ };
37195
+ } else if (value.array_value.length === 0) {
37196
+ return {
37197
+ rows: [""],
37198
+ length: 1,
37199
+ width: 1
37200
+ };
37201
+ }
37202
+ const csvMatrix = [];
37203
+ const header = this.getHeaderRow(fields);
37204
+ csvMatrix.push(...header.rows);
37205
+ const width = header.width;
37206
+ let rowCount = 1;
37207
+ for (const row of value.array_value) {
37208
+ if (row.kind === "record_cell") {
37209
+ const rowMatrix = this.getRowMatrix(fields, row.record_value);
37210
+ rowCount = rowCount + rowMatrix.length;
37211
+ csvMatrix.push(...rowMatrix.rows);
37212
+ }
37213
+ }
37214
+ return {
37215
+ rows: csvMatrix,
37216
+ length: rowCount,
37217
+ width
37218
+ };
37219
+ }
37220
+ // Creates CSV content for one row of data.
37221
+ getRowMatrix(fields, row) {
37222
+ const matrices = [];
37223
+ for (let idx = 0; idx < fields.length; idx++) {
37224
+ const field = fields[idx];
37225
+ const val = row[idx];
37226
+ if (field.type.kind === "array_type" && field.type.element_type.kind === "record_type") {
37227
+ const cell = this.getChildMatrix(field.type.element_type.fields, val);
37228
+ matrices.push(cell);
37229
+ } else {
37230
+ const cell = {
37231
+ rows: [this.stringify(val)],
37232
+ length: 1,
37233
+ width: 1
37234
+ };
37235
+ matrices.push(cell);
37236
+ }
37237
+ }
37238
+ return this.mergeMatrices(matrices);
37239
+ }
37240
+ async process(data) {
37241
+ let headerDefined = false;
37242
+ for await (const row of data) {
37243
+ const fields = this.result.schema.fields.filter((field) => field.kind === "dimension");
37244
+ if (!headerDefined && this.includeHeader) {
37245
+ const header = this.getHeaderRow(fields);
37246
+ this.stream.write(header.rows[0]);
37247
+ this.stream.write(this.rowSeparator);
37248
+ headerDefined = true;
37249
+ }
37250
+ const rowCsv = this.getRowMatrix(fields, row.record_value);
37251
+ for (const line of rowCsv.rows) {
37252
+ this.stream.write(line);
37253
+ this.stream.write(this.rowSeparator);
37254
+ }
37255
+ }
37256
+ this.stream.close();
37257
+ }
37258
+ }
37259
+ function toObject(fields, data) {
37260
+ const result = {};
37261
+ for (let idx = 0; idx < fields.length; idx++) {
37262
+ const field = fields[idx];
37263
+ const value = data[idx];
37264
+ switch (value.kind) {
37265
+ case "string_cell":
37266
+ result[field.name] = value.string_value;
37267
+ break;
37268
+ case "boolean_cell":
37269
+ result[field.name] = value.boolean_value;
37270
+ break;
37271
+ case "date_cell":
37272
+ result[field.name] = value.date_value;
37273
+ break;
37274
+ case "timestamp_cell":
37275
+ result[field.name] = value.timestamp_value;
37276
+ break;
37277
+ case "number_cell":
37278
+ result[field.name] = value.number_value;
37279
+ break;
37280
+ case "json_cell":
37281
+ result[field.name] = value.json_value;
37282
+ break;
37283
+ case "record_cell":
37284
+ result[field.name] = toObject(fields, value.record_value);
37285
+ break;
37286
+ case "array_cell":
37287
+ if (field.type.kind === "array_type" && field.type.element_type.kind === "record_type") {
37288
+ const ary = [];
37289
+ for (const cell of value.array_value) {
37290
+ if (cell.kind === "record_cell") {
37291
+ ary.push(toObject(field.type.element_type.fields, cell.record_value));
37292
+ }
37293
+ }
37294
+ result[field.name] = ary;
37295
+ }
37296
+ break;
37297
+ case "null_cell":
37298
+ result[field.name] = null;
37299
+ break;
37300
+ case "sql_native_cell":
37301
+ result[field.name] = value.sql_native_value;
37302
+ break;
37303
+ }
37304
+ }
37305
+ return result;
37306
+ }
37307
+ async function* dataIterator(result) {
37308
+ var _a2;
37309
+ if (((_a2 = result.data) == null ? void 0 : _a2.kind) === "array_cell") {
37310
+ for (const row of result.data.array_value) {
37311
+ if (row.kind === "record_cell") {
37312
+ yield row;
37313
+ }
37314
+ }
37315
+ }
37316
+ }
37317
+ function DownloadButton({
37318
+ name = "malloy",
37319
+ result
37320
+ }) {
37321
+ const [href, setHref] = useState("");
37322
+ const [fileName, setFileName] = useState("");
37323
+ const [format2, _setFormat] = useState("csv");
37324
+ useEffect(() => {
37325
+ const createBlob = async () => {
37326
+ if (!result) {
37327
+ setHref("");
37328
+ return;
37329
+ }
37330
+ const writeStream = new MemoryWriteStream();
37331
+ let writer;
37332
+ let type;
37333
+ let fileName2;
37334
+ if (format2 === "json") {
37335
+ writer = new JSONWriter(writeStream, result);
37336
+ type = "text/json";
37337
+ fileName2 = `${name}.json`;
37338
+ } else {
37339
+ writer = new CSVWriter(writeStream, result);
37340
+ type = "text/csv";
37341
+ fileName2 = `${name}.csv`;
37342
+ }
37343
+ const rowStream = dataIterator(result);
37344
+ await writer.process(rowStream);
37345
+ writeStream.close();
37346
+ const data = writeStream.data;
37347
+ const blob = new Blob([data], {
37348
+ type
37349
+ });
37350
+ setHref(window.URL.createObjectURL(blob));
37351
+ setFileName(fileName2);
37352
+ };
37353
+ void createBlob();
37354
+ }, [name, format2, result]);
37355
+ useEffect(() => {
37356
+ return () => {
37357
+ if (href) {
37358
+ window.URL.revokeObjectURL(href);
37359
+ }
37360
+ };
37361
+ }, [href]);
37362
+ if (href) {
37363
+ return /* @__PURE__ */ jsxs("a", {
37364
+ href,
37365
+ download: fileName,
37366
+ ...props(styles$4.link, fontStyles.body),
37367
+ children: [/* @__PURE__ */ jsx(Icon, {
37368
+ name: "download"
37369
+ }), /* @__PURE__ */ jsx("div", {
37370
+ children: "Download CSV"
37371
+ })]
37372
+ });
37373
+ } else {
37374
+ return null;
37375
+ }
37376
+ }
37377
+ class MemoryWriteStream {
37378
+ constructor() {
37379
+ this._data = [];
37380
+ }
37381
+ write(data) {
37382
+ this._data.push(data);
37383
+ }
37384
+ close() {
37385
+ }
37386
+ get data() {
37387
+ return this._data.join("");
37388
+ }
37389
+ }
37390
+ const styles$4 = {
37391
+ link: {
37392
+ display: "mly78zum5",
37393
+ alignContent: "mlyc26acl",
37394
+ gap: "mly167g77z",
37395
+ rowGap: null,
37396
+ columnGap: null,
37397
+ textDecoration: "mly1hl2dhg",
37398
+ textDecorationColor: null,
37399
+ textDecorationLine: null,
37400
+ textDecorationStyle: null,
37401
+ textDecorationThickness: null,
37402
+ background: "mly1md70p1 mly14hn1a8 mlywghvya",
37403
+ backgroundAttachment: null,
37404
+ backgroundClip: null,
37405
+ backgroundColor: null,
37406
+ backgroundImage: null,
37407
+ backgroundOrigin: null,
37408
+ backgroundPosition: null,
37409
+ backgroundPositionX: null,
37410
+ backgroundPositionY: null,
37411
+ backgroundRepeat: null,
37412
+ backgroundSize: null,
37413
+ borderRadius: "mlyur7f20",
37414
+ borderStartStartRadius: null,
37415
+ borderStartEndRadius: null,
37416
+ borderEndStartRadius: null,
37417
+ borderEndEndRadius: null,
37418
+ borderTopLeftRadius: null,
37419
+ borderTopRightRadius: null,
37420
+ borderBottomLeftRadius: null,
37421
+ borderBottomRightRadius: null,
37422
+ padding: "mlyfawy5m",
37423
+ paddingInline: null,
37424
+ paddingStart: null,
37425
+ paddingLeft: null,
37426
+ paddingEnd: null,
37427
+ paddingRight: null,
37428
+ paddingBlock: null,
37429
+ paddingTop: null,
37430
+ paddingBottom: null,
37431
+ $$css: true
37432
+ }
37433
+ };
36885
37434
  var Tab = /* @__PURE__ */ function(Tab2) {
36886
37435
  Tab2["RESULTS"] = "Results";
36887
37436
  Tab2["MALLOY"] = "Malloy";
@@ -36896,7 +37445,7 @@ function ResultPanel({
36896
37445
  submittedQuery,
36897
37446
  options
36898
37447
  }) {
36899
- var _a2, _b2, _c2;
37448
+ var _a2, _b2, _c2, _d;
36900
37449
  const [tab, setTab] = useState(Tab.MALLOY);
36901
37450
  const malloyText = (_a2 = useQueryBuilder(source, draftQuery)) == null ? void 0 : _a2.toMalloy();
36902
37451
  const views = source.schema.fields.filter((f2) => f2.kind === "view");
@@ -36954,6 +37503,8 @@ function ResultPanel({
36954
37503
  }), tab !== Tab.RESULTS && clipboardText && /* @__PURE__ */ jsx(CopyToClipboard, {
36955
37504
  text: clipboardText,
36956
37505
  label: "Copy Code"
37506
+ }), tab === Tab.RESULTS && /* @__PURE__ */ jsx(DownloadButton, {
37507
+ result: (_b2 = submittedQuery == null ? void 0 : submittedQuery.response) == null ? void 0 : _b2.result
36957
37508
  })]
36958
37509
  }), /* @__PURE__ */ jsxs("div", {
36959
37510
  ...{
@@ -37003,7 +37554,7 @@ function ResultPanel({
37003
37554
  ...{
37004
37555
  className: "mlywp4ipm mlyh8yej3 mly5yr21d mly9f619"
37005
37556
  },
37006
- children: ((_c2 = (_b2 = submittedQuery == null ? void 0 : submittedQuery.response) == null ? void 0 : _b2.result) == null ? void 0 : _c2.sql) && /* @__PURE__ */ jsx(CodeBlock, {
37557
+ children: ((_d = (_c2 = submittedQuery == null ? void 0 : submittedQuery.response) == null ? void 0 : _c2.result) == null ? void 0 : _d.sql) && /* @__PURE__ */ jsx(CodeBlock, {
37007
37558
  code: submittedQuery.response.result.sql,
37008
37559
  language: "sql"
37009
37560
  })
@@ -37259,7 +37810,7 @@ function useOperations(view, field, path) {
37259
37810
  const groupByDisabledReason = useMemo(() => {
37260
37811
  const segment = getSegmentIfPresent(view);
37261
37812
  if ((matchingFieldItem == null ? void 0 : matchingFieldItem.field.kind) !== "dimension") {
37262
- return "Grouping is only available on a dimenion.";
37813
+ return "Grouping is only available on a dimension.";
37263
37814
  }
37264
37815
  if (segment == null ? void 0 : segment.hasField(field.name, path)) {
37265
37816
  return "Cannot group by a field already in the view.";
@@ -37314,145 +37865,44 @@ function useOperations(view, field, path) {
37314
37865
  return "";
37315
37866
  }, [matchingFieldItem, view, path, field.name, fullName]);
37316
37867
  return {
37317
- isGroupByAllowed: !groupByDisabledReason,
37318
37868
  groupByDisabledReason,
37319
- isAggregateAllowed: !aggregateDisabledReason,
37320
37869
  aggregateDisabledReason,
37321
- isFilterAllowed: !filterDisabledReason,
37322
37870
  filterDisabledReason,
37323
- isOrderByAllowed: !orderByDisabledReason,
37324
37871
  orderByDisabledReason
37325
37872
  };
37326
37873
  }
37327
37874
  const FILTERABLE_TYPES = ["string_type", "boolean_type", "number_type", "date_type", "timestamp_type"];
37328
37875
  const ORDERABLE_TYPES = ["string_type", "number_type", "boolean_type", "date_type", "timestamp_type"];
37329
37876
  function FieldTokenWithActions({
37877
+ rootQuery,
37330
37878
  field,
37331
37879
  path,
37332
37880
  viewDef
37333
37881
  }) {
37334
- const {
37335
- rootQuery,
37336
- setQuery
37337
- } = React__default.useContext(QueryEditorContext);
37338
37882
  const {
37339
37883
  focusedNestView
37340
37884
  } = useQueryFocus();
37885
+ const updateQuery = useUpdateQuery();
37341
37886
  const view = focusedNestView ?? viewDef;
37342
- const {
37343
- groupByDisabledReason,
37344
- aggregateDisabledReason,
37345
- filterDisabledReason,
37346
- orderByDisabledReason
37347
- } = useOperations(view, field, path);
37348
- const [isFilterPopoverOpen, setIsFilterPopoverOpen] = useState();
37887
+ const [isFilterPopoverOpen, setIsFilterPopoverOpen] = useState(false);
37349
37888
  const [isTooltipOpen, setIsTooltipOpen] = useState(false);
37350
- const handleAddOperationAction = (operation, filter) => {
37351
- if (field.kind === "dimension" || field.kind === "measure") {
37352
- if (operation === "groupBy" && !groupByDisabledReason) {
37353
- addGroupBy(view, field, path);
37354
- } else if (operation === "aggregate" && !aggregateDisabledReason) {
37355
- addAggregate(view, field, path);
37356
- } else if (operation === "orderBy" && !orderByDisabledReason) {
37357
- addOrderByFromSource(view, path, field.name);
37358
- } else if (operation === "filter" && !filterDisabledReason && filter) {
37359
- addFilter(view, field, path, filter);
37360
- }
37361
- setQuery == null ? void 0 : setQuery(rootQuery == null ? void 0 : rootQuery.build());
37362
- }
37363
- };
37364
- const handleSetView = () => {
37365
- if (field.kind === "view" && (rootQuery == null ? void 0 : rootQuery.isEmpty())) {
37366
- rootQuery == null ? void 0 : rootQuery.setView(field.name);
37367
- setQuery == null ? void 0 : setQuery(rootQuery == null ? void 0 : rootQuery.build());
37368
- }
37369
- };
37370
- const handleAddView = () => {
37371
- if (field.kind === "view") {
37372
- addNest(view, field);
37373
- setQuery == null ? void 0 : setQuery(rootQuery == null ? void 0 : rootQuery.build());
37374
- }
37375
- };
37889
+ const showHover = isFilterPopoverOpen || isTooltipOpen;
37376
37890
  return /* @__PURE__ */ jsx(FieldToken, {
37377
37891
  field,
37378
- hoverActions: field.kind === "view" ? /* @__PURE__ */ jsxs(Fragment, {
37379
- children: [/* @__PURE__ */ jsx(ActionButton, {
37380
- icon: "insert",
37381
- disabled: !(rootQuery == null ? void 0 : rootQuery.isEmpty()),
37382
- onClick: handleSetView,
37383
- tooltip: !(rootQuery == null ? void 0 : rootQuery.isEmpty()) ? "Can only add a view to an empty query." : "Add view",
37384
- onTooltipOpenChange: setIsTooltipOpen
37385
- }), /* @__PURE__ */ jsx(ActionButton, {
37386
- icon: "nest",
37387
- onClick: handleAddView,
37388
- tooltip: "Add as new nested query",
37389
- onTooltipOpenChange: setIsTooltipOpen
37390
- })]
37391
- }) : field.kind === "measure" ? /* @__PURE__ */ jsxs(Fragment, {
37392
- children: [/* @__PURE__ */ jsx(ActionButton, {
37393
- icon: "aggregate",
37394
- tooltip: aggregateDisabledReason || "Add as aggregate",
37395
- disabled: !!aggregateDisabledReason,
37396
- onClick: () => handleAddOperationAction("aggregate"),
37397
- onTooltipOpenChange: setIsTooltipOpen
37398
- }), /* @__PURE__ */ jsx(FilterPopover, {
37399
- fieldInfo: field,
37400
- path,
37401
- setFilter: (filter) => handleAddOperationAction("filter", filter),
37402
- trigger: /* @__PURE__ */ jsx(ActionButton, {
37403
- icon: "filter",
37404
- tooltip: filterDisabledReason || "Add as filter",
37405
- disabled: !!filterDisabledReason,
37406
- onTooltipOpenChange: setIsTooltipOpen
37407
- }),
37408
- onOpenChange: setIsFilterPopoverOpen,
37409
- layoutProps: {
37410
- align: "start"
37411
- }
37412
- }), /* @__PURE__ */ jsx(ActionButton, {
37413
- icon: "orderBy",
37414
- tooltip: orderByDisabledReason || "Add as order by",
37415
- disabled: !!orderByDisabledReason,
37416
- onClick: () => handleAddOperationAction("orderBy"),
37417
- onTooltipOpenChange: setIsTooltipOpen
37418
- })]
37419
- }) : field.kind === "dimension" ? /* @__PURE__ */ jsxs(Fragment, {
37420
- children: [/* @__PURE__ */ jsx(ActionButton, {
37421
- icon: "groupBy",
37422
- tooltip: groupByDisabledReason || "Add as group by",
37423
- disabled: !!groupByDisabledReason,
37424
- onClick: () => handleAddOperationAction("groupBy"),
37425
- onTooltipOpenChange: setIsTooltipOpen
37426
- }), /* @__PURE__ */ jsx(FilterPopover, {
37427
- fieldInfo: field,
37428
- path,
37429
- setFilter: (filter) => handleAddOperationAction("filter", filter),
37430
- trigger: /* @__PURE__ */ jsx(ActionButton, {
37431
- icon: "filter",
37432
- tooltip: filterDisabledReason || "Add as filter",
37433
- disabled: !!filterDisabledReason,
37434
- onTooltipOpenChange: setIsTooltipOpen
37435
- }),
37436
- onOpenChange: setIsFilterPopoverOpen,
37437
- layoutProps: {
37438
- align: "start"
37439
- }
37440
- }), /* @__PURE__ */ jsx(ActionButton, {
37441
- icon: "orderBy",
37442
- tooltip: orderByDisabledReason || "Add as order by",
37443
- disabled: !!orderByDisabledReason,
37444
- onClick: () => handleAddOperationAction("orderBy"),
37445
- onTooltipOpenChange: setIsTooltipOpen
37446
- })]
37447
- }) : null,
37448
- onClick: field.kind === "dimension" && !groupByDisabledReason ? () => handleAddOperationAction("groupBy") : field.kind === "measure" && !aggregateDisabledReason ? () => handleAddOperationAction("aggregate") : field.kind === "view" ? () => {
37449
- if (rootQuery == null ? void 0 : rootQuery.isEmpty()) {
37450
- handleSetView();
37451
- } else {
37452
- handleAddView();
37892
+ hoverActions: /* @__PURE__ */ jsx(QueryEditorActions, {
37893
+ rootQuery,
37894
+ field,
37895
+ view,
37896
+ path,
37897
+ setIsFilterPopoverOpen,
37898
+ setIsTooltipOpen
37899
+ }),
37900
+ onClick: () => {
37901
+ if (queryEditorClick(rootQuery, view, field, path)) {
37902
+ updateQuery();
37453
37903
  }
37454
- } : void 0,
37455
- hoverActionsVisible: isFilterPopoverOpen || isTooltipOpen,
37904
+ },
37905
+ hoverActionsVisible: showHover,
37456
37906
  tooltip: /* @__PURE__ */ jsx(FieldHoverCard, {
37457
37907
  field,
37458
37908
  path
@@ -37488,8 +37938,146 @@ function ActionButton({
37488
37938
  })]
37489
37939
  });
37490
37940
  }
37941
+ function QueryEditorActions({
37942
+ rootQuery,
37943
+ view,
37944
+ field,
37945
+ path,
37946
+ setIsTooltipOpen,
37947
+ setIsFilterPopoverOpen
37948
+ }) {
37949
+ const updateQuery = useUpdateQuery();
37950
+ const {
37951
+ groupByDisabledReason,
37952
+ aggregateDisabledReason,
37953
+ filterDisabledReason,
37954
+ orderByDisabledReason
37955
+ } = useOperations(view, field, path);
37956
+ const handleAddOperationAction = (operation, filter) => {
37957
+ if (field.kind === "dimension" || field.kind === "measure") {
37958
+ if (operation === "groupBy" && !groupByDisabledReason) {
37959
+ addGroupBy(view, field, path);
37960
+ } else if (operation === "aggregate" && !aggregateDisabledReason) {
37961
+ addAggregate(view, field, path);
37962
+ } else if (operation === "orderBy" && !orderByDisabledReason) {
37963
+ addOrderByFromSource(view, path, field.name);
37964
+ } else if (operation === "filter" && !filterDisabledReason && filter) {
37965
+ addFilter(view, field, path, filter);
37966
+ }
37967
+ updateQuery();
37968
+ }
37969
+ };
37970
+ const handleSetView = () => {
37971
+ if (field.kind === "view" && rootQuery.isEmpty()) {
37972
+ rootQuery.setView(field.name);
37973
+ updateQuery();
37974
+ }
37975
+ };
37976
+ const handleAddView = () => {
37977
+ if (field.kind === "view") {
37978
+ addNest(view, field);
37979
+ updateQuery();
37980
+ }
37981
+ };
37982
+ return field.kind === "view" ? /* @__PURE__ */ jsxs(Fragment, {
37983
+ children: [/* @__PURE__ */ jsx(ActionButton, {
37984
+ icon: "insert",
37985
+ disabled: !rootQuery.isEmpty(),
37986
+ onClick: handleSetView,
37987
+ tooltip: !rootQuery.isEmpty() ? "Can only add a view to an empty query." : "Add view",
37988
+ onTooltipOpenChange: setIsTooltipOpen
37989
+ }), /* @__PURE__ */ jsx(ActionButton, {
37990
+ icon: "nest",
37991
+ onClick: handleAddView,
37992
+ tooltip: "Add as new nested query",
37993
+ onTooltipOpenChange: setIsTooltipOpen
37994
+ })]
37995
+ }) : field.kind === "measure" ? /* @__PURE__ */ jsxs(Fragment, {
37996
+ children: [/* @__PURE__ */ jsx(ActionButton, {
37997
+ icon: "aggregate",
37998
+ tooltip: aggregateDisabledReason || "Add as aggregate",
37999
+ disabled: !!aggregateDisabledReason,
38000
+ onClick: () => handleAddOperationAction("aggregate"),
38001
+ onTooltipOpenChange: setIsTooltipOpen
38002
+ }), /* @__PURE__ */ jsx(FilterPopover, {
38003
+ fieldInfo: field,
38004
+ path,
38005
+ setFilter: (filter) => handleAddOperationAction("filter", filter),
38006
+ trigger: /* @__PURE__ */ jsx(ActionButton, {
38007
+ icon: "filter",
38008
+ tooltip: filterDisabledReason || "Add as filter",
38009
+ disabled: !!filterDisabledReason,
38010
+ onTooltipOpenChange: setIsTooltipOpen
38011
+ }),
38012
+ onOpenChange: setIsFilterPopoverOpen,
38013
+ layoutProps: {
38014
+ align: "start"
38015
+ }
38016
+ }), /* @__PURE__ */ jsx(ActionButton, {
38017
+ icon: "orderBy",
38018
+ tooltip: orderByDisabledReason || "Add as order by",
38019
+ disabled: !!orderByDisabledReason,
38020
+ onClick: () => handleAddOperationAction("orderBy"),
38021
+ onTooltipOpenChange: setIsTooltipOpen
38022
+ })]
38023
+ }) : field.kind === "dimension" ? /* @__PURE__ */ jsxs(Fragment, {
38024
+ children: [/* @__PURE__ */ jsx(ActionButton, {
38025
+ icon: "groupBy",
38026
+ tooltip: groupByDisabledReason || "Add as group by",
38027
+ disabled: !!groupByDisabledReason,
38028
+ onClick: () => handleAddOperationAction("groupBy"),
38029
+ onTooltipOpenChange: setIsTooltipOpen
38030
+ }), /* @__PURE__ */ jsx(FilterPopover, {
38031
+ fieldInfo: field,
38032
+ path,
38033
+ setFilter: (filter) => handleAddOperationAction("filter", filter),
38034
+ trigger: /* @__PURE__ */ jsx(ActionButton, {
38035
+ icon: "filter",
38036
+ tooltip: filterDisabledReason || "Add as filter",
38037
+ disabled: !!filterDisabledReason,
38038
+ onTooltipOpenChange: setIsTooltipOpen
38039
+ }),
38040
+ onOpenChange: setIsFilterPopoverOpen,
38041
+ layoutProps: {
38042
+ align: "start"
38043
+ }
38044
+ }), /* @__PURE__ */ jsx(ActionButton, {
38045
+ icon: "orderBy",
38046
+ tooltip: orderByDisabledReason || "Add as order by",
38047
+ disabled: !!orderByDisabledReason,
38048
+ onClick: () => handleAddOperationAction("orderBy"),
38049
+ onTooltipOpenChange: setIsTooltipOpen
38050
+ })]
38051
+ }) : null;
38052
+ }
38053
+ function queryEditorClick(rootQuery, view, field, path) {
38054
+ const segment = getSegmentIfPresent(view);
38055
+ if (field.kind === "dimension") {
38056
+ if (!(segment == null ? void 0 : segment.hasField(field.name, path))) {
38057
+ addGroupBy(view, field, path);
38058
+ } else {
38059
+ return false;
38060
+ }
38061
+ } else if (field.kind === "measure") {
38062
+ if (!(segment == null ? void 0 : segment.hasField(field.name, path))) {
38063
+ addAggregate(view, field, path);
38064
+ } else {
38065
+ return false;
38066
+ }
38067
+ } else if (field.kind === "view") {
38068
+ if (rootQuery.isEmpty()) {
38069
+ rootQuery.setView(field.name);
38070
+ } else {
38071
+ addNest(view, field);
38072
+ }
38073
+ } else {
38074
+ return false;
38075
+ }
38076
+ return true;
38077
+ }
37491
38078
  const FIELD_KIND_ORDER = ["dimension", "measure", "view"];
37492
38079
  function SearchResultList({
38080
+ rootQuery,
37493
38081
  source,
37494
38082
  items
37495
38083
  }) {
@@ -37499,10 +38087,7 @@ function SearchResultList({
37499
38087
  items: groupFieldItemsByPath(source, group.items)
37500
38088
  }));
37501
38089
  }, [source, items]);
37502
- const {
37503
- rootQuery
37504
- } = React.useContext(QueryEditorContext);
37505
- const viewDef = rootQuery == null ? void 0 : rootQuery.definition;
38090
+ const viewDef = rootQuery.definition;
37506
38091
  if (!(viewDef instanceof ASTArrowQueryDefinition)) {
37507
38092
  return null;
37508
38093
  }
@@ -37539,6 +38124,7 @@ function SearchResultList({
37539
38124
  field,
37540
38125
  path
37541
38126
  }) => /* @__PURE__ */ jsx(FieldTokenWithActions, {
38127
+ rootQuery,
37542
38128
  field,
37543
38129
  path,
37544
38130
  viewDef
@@ -37565,6 +38151,7 @@ const getSublabelFromPath = (source, path) => {
37565
38151
  return path.length > 0 ? `joined to ${[...path.slice(0, -1), source.name].join(" > ")}` : void 0;
37566
38152
  };
37567
38153
  function FieldGroupList({
38154
+ rootQuery,
37568
38155
  source,
37569
38156
  fieldItems,
37570
38157
  fieldGroupType
@@ -37584,10 +38171,7 @@ function FieldGroupList({
37584
38171
  group
37585
38172
  }) => group === fieldGroupType)) == null ? void 0 : _a2.items) ?? [];
37586
38173
  }, [fieldGroupsByKindByPath, fieldGroupType]);
37587
- const {
37588
- rootQuery
37589
- } = React.useContext(QueryEditorContext);
37590
- const viewDef = rootQuery == null ? void 0 : rootQuery.definition;
38174
+ const viewDef = rootQuery.definition;
37591
38175
  if (!(viewDef instanceof ASTArrowQueryDefinition)) {
37592
38176
  return null;
37593
38177
  }
@@ -37604,6 +38188,7 @@ function FieldGroupList({
37604
38188
  field,
37605
38189
  path
37606
38190
  }) => /* @__PURE__ */ jsx(FieldTokenWithActions, {
38191
+ rootQuery,
37607
38192
  field,
37608
38193
  path,
37609
38194
  viewDef
@@ -37616,7 +38201,8 @@ function SourcePanel({
37616
38201
  onRefresh
37617
38202
  }) {
37618
38203
  const {
37619
- source
38204
+ source,
38205
+ rootQuery
37620
38206
  } = React.useContext(QueryEditorContext);
37621
38207
  const [searchQuery, setSearchQuery] = React.useState("");
37622
38208
  const {
@@ -37639,7 +38225,7 @@ function SourcePanel({
37639
38225
  return [];
37640
38226
  }, [fieldItems, searchQuery]);
37641
38227
  const isSearchActive = !!searchQuery;
37642
- if (!source) {
38228
+ if (!source || !rootQuery) {
37643
38229
  return null;
37644
38230
  }
37645
38231
  return /* @__PURE__ */ jsxs("div", {
@@ -37694,6 +38280,7 @@ function SourcePanel({
37694
38280
  className: "mly78zum5 mlydt5ytf mlyysyzu8 mly1iyjqo2"
37695
38281
  },
37696
38282
  children: isSearchActive ? /* @__PURE__ */ jsx(SearchResultList, {
38283
+ rootQuery,
37697
38284
  source,
37698
38285
  items: searchResultItems
37699
38286
  }) : /* @__PURE__ */ jsxs(AccordionList, {
@@ -37710,6 +38297,7 @@ function SourcePanel({
37710
38297
  color: "cyan"
37711
38298
  }),
37712
38299
  children: /* @__PURE__ */ jsx(FieldGroupList, {
38300
+ rootQuery,
37713
38301
  source,
37714
38302
  fieldItems,
37715
38303
  fieldGroupType: "dimension"
@@ -37726,6 +38314,7 @@ function SourcePanel({
37726
38314
  color: "green"
37727
38315
  }),
37728
38316
  children: /* @__PURE__ */ jsx(FieldGroupList, {
38317
+ rootQuery,
37729
38318
  source,
37730
38319
  fieldItems,
37731
38320
  fieldGroupType: "measure"
@@ -37742,6 +38331,7 @@ function SourcePanel({
37742
38331
  color: "purple"
37743
38332
  }),
37744
38333
  children: /* @__PURE__ */ jsx(FieldGroupList, {
38334
+ rootQuery,
37745
38335
  source,
37746
38336
  fieldItems,
37747
38337
  fieldGroupType: "view"