@quillsql/react 2.16.3 → 2.16.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -17188,7 +17188,6 @@ var init_astProcessing = __esm({
17188
17188
  }
17189
17189
  if (numRetries === MAX_RETRIES) {
17190
17190
  console.error("[Error]: Max retries exceeded.");
17191
- console.info(`%c[Prompt]: ${aiPrompt}`, "color: dimgray");
17192
17191
  throw new Error(
17193
17192
  "Error: Couldn't process your request, please re-word your prompt."
17194
17193
  );
@@ -19406,19 +19405,19 @@ var require_pluralize = __commonJS({
19406
19405
  // src/Dashboard.tsx
19407
19406
  import {
19408
19407
  useContext as useContext20,
19409
- useEffect as useEffect18,
19410
- useState as useState23,
19408
+ useEffect as useEffect19,
19409
+ useState as useState24,
19411
19410
  useMemo as useMemo16,
19412
- useRef as useRef13
19411
+ useRef as useRef14
19413
19412
  } from "react";
19414
19413
 
19415
19414
  // src/Chart.tsx
19416
19415
  import {
19417
- useState as useState17,
19418
- useEffect as useEffect15,
19416
+ useState as useState18,
19417
+ useEffect as useEffect16,
19419
19418
  useContext as useContext16,
19420
19419
  useMemo as useMemo13,
19421
- useRef as useRef11
19420
+ useRef as useRef12
19422
19421
  } from "react";
19423
19422
 
19424
19423
  // src/utils/csv.ts
@@ -20398,11 +20397,13 @@ async function saveReport({
20398
20397
  rows: void 0,
20399
20398
  compareRows: void 0,
20400
20399
  dashboardItemId,
20400
+ ...dashboardItemId ? { reportId: dashboardItemId } : {},
20401
20401
  // Remove useNewNodeSql since backend will handle conversion
20402
20402
  clientId: publicKey,
20403
20403
  tenants,
20404
20404
  // Only include adminMode for 'create' task, not 'create-report'
20405
- ...isCreateTask && { adminMode }
20405
+ ...isCreateTask && { adminMode },
20406
+ section: report.section
20406
20407
  },
20407
20408
  getToken
20408
20409
  });
@@ -25558,15 +25559,15 @@ var PieChart_default = PieChartWrapper;
25558
25559
 
25559
25560
  // src/components/QuillTable.tsx
25560
25561
  init_valueFormatter();
25561
- import { useContext as useContext5, useEffect as useEffect7, useState as useState8 } from "react";
25562
+ import { useContext as useContext5, useEffect as useEffect8, useState as useState9 } from "react";
25562
25563
 
25563
25564
  // src/components/UiComponents.tsx
25564
25565
  import {
25565
25566
  forwardRef,
25566
25567
  useContext as useContext4,
25567
- useEffect as useEffect6,
25568
- useRef as useRef3,
25569
- useState as useState7
25568
+ useEffect as useEffect7,
25569
+ useRef as useRef4,
25570
+ useState as useState8
25570
25571
  } from "react";
25571
25572
 
25572
25573
  // src/assets/ArrowDownHeadIcon.tsx
@@ -25818,6 +25819,146 @@ import { useEffect as useEffect4, useState as useState5 } from "react";
25818
25819
  // src/hooks/useSelectOnKeyDown.tsx
25819
25820
  import { useEffect as useEffect5, useState as useState6 } from "react";
25820
25821
 
25822
+ // src/hooks/useResponsiveFirstChildWidth.ts
25823
+ import {
25824
+ useEffect as useEffect6,
25825
+ useLayoutEffect,
25826
+ useRef as useRef3,
25827
+ useState as useState7
25828
+ } from "react";
25829
+ var DEFAULT_MIN_WIDTH = 0;
25830
+ var parseNumericValue = (value) => {
25831
+ if (!value) {
25832
+ return 0;
25833
+ }
25834
+ const parsed = parseFloat(value);
25835
+ return Number.isFinite(parsed) ? parsed : 0;
25836
+ };
25837
+ var getHorizontalGap = (element, explicitGap) => {
25838
+ if (typeof explicitGap === "number") {
25839
+ return explicitGap;
25840
+ }
25841
+ const computedStyle = window.getComputedStyle(element);
25842
+ const columnGap = parseNumericValue(computedStyle.columnGap);
25843
+ if (columnGap > 0) {
25844
+ return columnGap;
25845
+ }
25846
+ const genericGap = parseNumericValue(computedStyle.gap);
25847
+ return genericGap;
25848
+ };
25849
+ var calculateFirstChildWidth = (element, options) => {
25850
+ const { gap, minWidth, maxWidth } = options;
25851
+ const computedStyle = window.getComputedStyle(element);
25852
+ const horizontalPadding = parseNumericValue(computedStyle.paddingLeft) + parseNumericValue(computedStyle.paddingRight);
25853
+ const availableWidth = Math.max(
25854
+ 0,
25855
+ element.clientWidth - horizontalPadding
25856
+ );
25857
+ const children = Array.from(element.children);
25858
+ if (!children.length) {
25859
+ return Math.max(minWidth ?? DEFAULT_MIN_WIDTH, 0);
25860
+ }
25861
+ const siblings = children.slice(1);
25862
+ const gapCount = Math.max(children.length - 1, 0);
25863
+ const effectiveGap = getHorizontalGap(element, gap) * gapCount;
25864
+ let siblingsWidth = 0;
25865
+ siblings.forEach((child) => {
25866
+ const rect = child.getBoundingClientRect();
25867
+ const childStyle = window.getComputedStyle(child);
25868
+ siblingsWidth += rect.width + parseNumericValue(childStyle.marginLeft) + parseNumericValue(childStyle.marginRight);
25869
+ });
25870
+ const rawWidth = Math.max(0, availableWidth - siblingsWidth - effectiveGap);
25871
+ const min2 = Math.max(minWidth ?? DEFAULT_MIN_WIDTH, 0);
25872
+ const max2 = typeof maxWidth === "number" && Number.isFinite(maxWidth) ? Math.max(maxWidth, min2) : void 0;
25873
+ const clampedWidth = max2 !== void 0 ? Math.min(Math.max(rawWidth, min2), max2) : Math.max(rawWidth, min2);
25874
+ return Math.floor(clampedWidth);
25875
+ };
25876
+ var useIsomorphicLayoutEffect = typeof window !== "undefined" ? useLayoutEffect : useEffect6;
25877
+ var useResponsiveFirstChildWidth = (containerRef, options = {}) => {
25878
+ const {
25879
+ gap,
25880
+ initialWidth = -1,
25881
+ minWidth = DEFAULT_MIN_WIDTH,
25882
+ maxWidth
25883
+ } = options;
25884
+ const [width, setWidth] = useState7(initialWidth);
25885
+ const previousWidthRef = useRef3(initialWidth);
25886
+ useIsomorphicLayoutEffect(() => {
25887
+ const element = containerRef?.current ?? null;
25888
+ if (!element || typeof window === "undefined") {
25889
+ return;
25890
+ }
25891
+ let frameId = null;
25892
+ const updateWidth = () => {
25893
+ if (!element.isConnected) {
25894
+ return;
25895
+ }
25896
+ const nextWidth = calculateFirstChildWidth(element, {
25897
+ gap,
25898
+ minWidth,
25899
+ maxWidth
25900
+ });
25901
+ if (frameId !== null) {
25902
+ cancelAnimationFrame(frameId);
25903
+ }
25904
+ frameId = window.requestAnimationFrame(() => {
25905
+ frameId = null;
25906
+ if (Math.abs(previousWidthRef.current - nextWidth) > 0.5) {
25907
+ previousWidthRef.current = nextWidth;
25908
+ setWidth(nextWidth);
25909
+ }
25910
+ });
25911
+ };
25912
+ if (typeof ResizeObserver === "undefined") {
25913
+ updateWidth();
25914
+ const handleResize = () => updateWidth();
25915
+ window.addEventListener("resize", handleResize);
25916
+ return () => {
25917
+ if (frameId !== null) {
25918
+ cancelAnimationFrame(frameId);
25919
+ }
25920
+ window.removeEventListener("resize", handleResize);
25921
+ };
25922
+ }
25923
+ const resizeObserver = new ResizeObserver(() => {
25924
+ updateWidth();
25925
+ });
25926
+ const observeChildren = () => {
25927
+ resizeObserver.observe(element);
25928
+ Array.from(element.children).forEach((child) => {
25929
+ resizeObserver.observe(child);
25930
+ });
25931
+ };
25932
+ observeChildren();
25933
+ updateWidth();
25934
+ const mutationObserver = new MutationObserver((mutations) => {
25935
+ mutations.forEach((mutation) => {
25936
+ mutation.addedNodes.forEach((node) => {
25937
+ if (node instanceof HTMLElement) {
25938
+ resizeObserver.observe(node);
25939
+ }
25940
+ });
25941
+ mutation.removedNodes.forEach((node) => {
25942
+ if (node instanceof HTMLElement) {
25943
+ resizeObserver.unobserve(node);
25944
+ }
25945
+ });
25946
+ });
25947
+ updateWidth();
25948
+ });
25949
+ mutationObserver.observe(element, { childList: true });
25950
+ return () => {
25951
+ if (frameId !== null) {
25952
+ cancelAnimationFrame(frameId);
25953
+ }
25954
+ resizeObserver.disconnect();
25955
+ mutationObserver.disconnect();
25956
+ };
25957
+ }, [containerRef?.current, gap, minWidth, maxWidth]);
25958
+ return width;
25959
+ };
25960
+ var useResponsiveFirstChildWidth_default = useResponsiveFirstChildWidth;
25961
+
25821
25962
  // src/components/UiComponents.tsx
25822
25963
  import { createPortal } from "react-dom";
25823
25964
 
@@ -25849,14 +25990,19 @@ var QuillTextInput = forwardRef(
25849
25990
  disabled
25850
25991
  }, ref) => {
25851
25992
  const [theme] = useContext4(ThemeContext);
25993
+ const isNumericWidth = typeof width === "number";
25994
+ const resolvedWidth = typeof width === "string" ? width : isNumericWidth ? width : "100%";
25852
25995
  return /* @__PURE__ */ jsxs18(
25853
25996
  "label",
25854
25997
  {
25855
25998
  style: {
25856
25999
  position: "relative",
25857
26000
  borderRadius: "6px",
25858
- width,
25859
- minWidth: width
26001
+ display: "flex",
26002
+ flexDirection: "column",
26003
+ width: resolvedWidth,
26004
+ minWidth: isNumericWidth ? width : 0,
26005
+ flex: isNumericWidth ? "0 0 auto" : "1 1 auto"
25860
26006
  },
25861
26007
  children: [
25862
26008
  label && /* @__PURE__ */ jsx26(
@@ -25878,6 +26024,7 @@ var QuillTextInput = forwardRef(
25878
26024
  ref,
25879
26025
  style: {
25880
26026
  display: "flex",
26027
+ flex: "1 1 auto",
25881
26028
  height: 40,
25882
26029
  minHeight: 40,
25883
26030
  maxHeight: 40,
@@ -25889,8 +26036,8 @@ var QuillTextInput = forwardRef(
25889
26036
  backgroundColor: theme?.backgroundColor,
25890
26037
  color: theme?.primaryTextColor,
25891
26038
  fontFamily: theme?.fontFamily,
25892
- width,
25893
- minWidth: width
26039
+ width: "100%",
26040
+ minWidth: 0
25894
26041
  },
25895
26042
  id: id2,
25896
26043
  value,
@@ -26260,10 +26407,10 @@ var MemoizedPopover = ({
26260
26407
  titlePaddingLeft = 0
26261
26408
  }) => {
26262
26409
  const [theme] = useContext4(ThemeContext);
26263
- const [rightAlignment, setRightAlignment] = useState7("auto");
26264
- const modalRef = useRef3(null);
26265
- const popoverRef = useRef3(null);
26266
- useEffect6(() => {
26410
+ const [rightAlignment, setRightAlignment] = useState8("auto");
26411
+ const modalRef = useRef4(null);
26412
+ const popoverRef = useRef4(null);
26413
+ useEffect7(() => {
26267
26414
  const listener = (event) => {
26268
26415
  const target = event.target;
26269
26416
  if (modalRef.current?.contains(target) || target.closest("[data-portal-ignore]") || ignoredRefs?.some(
@@ -26282,7 +26429,7 @@ var MemoizedPopover = ({
26282
26429
  document.removeEventListener("mousedown", listener);
26283
26430
  };
26284
26431
  }, [isOpen, ignoredRefs, setIsOpen, modalRef]);
26285
- useEffect6(() => {
26432
+ useEffect7(() => {
26286
26433
  updatePopoverPosition();
26287
26434
  window.addEventListener("resize", updatePopoverPosition);
26288
26435
  return () => {
@@ -26678,10 +26825,10 @@ var QuillModalComponent = ({
26678
26825
  title
26679
26826
  }) => {
26680
26827
  const [theme] = useContext4(ThemeContext);
26681
- const [rightAlignment, setRightAlignment] = useState7("auto");
26682
- const modalRef = useRef3(null);
26683
- const popoverRef = useRef3(null);
26684
- useEffect6(() => {
26828
+ const [rightAlignment, setRightAlignment] = useState8("auto");
26829
+ const modalRef = useRef4(null);
26830
+ const popoverRef = useRef4(null);
26831
+ useEffect7(() => {
26685
26832
  const listener = (event) => {
26686
26833
  if (modalRef?.current && !modalRef?.current?.contains(event.target)) {
26687
26834
  if (setIsOpen) setIsOpen(false);
@@ -26696,7 +26843,7 @@ var QuillModalComponent = ({
26696
26843
  document.removeEventListener("mousedown", listener);
26697
26844
  };
26698
26845
  }, [modalRef, setIsOpen, isOpen]);
26699
- useEffect6(() => {
26846
+ useEffect7(() => {
26700
26847
  updatePopoverPosition();
26701
26848
  window.addEventListener("resize", updatePopoverPosition);
26702
26849
  return () => {
@@ -26993,9 +27140,9 @@ var OverflowContainer = ({
26993
27140
  children,
26994
27141
  style: style2
26995
27142
  }) => {
26996
- const containerRef = useRef3(null);
26997
- const [showTopShadow, setShowTopShadow] = useState7(false);
26998
- const [showBottomShadow, setShowBottomShadow] = useState7(false);
27143
+ const containerRef = useRef4(null);
27144
+ const [showTopShadow, setShowTopShadow] = useState8(false);
27145
+ const [showBottomShadow, setShowBottomShadow] = useState8(false);
26999
27146
  const checkOverflow = () => {
27000
27147
  const container = containerRef.current;
27001
27148
  if (container) {
@@ -27006,7 +27153,7 @@ var OverflowContainer = ({
27006
27153
  );
27007
27154
  }
27008
27155
  };
27009
- useEffect6(() => {
27156
+ useEffect7(() => {
27010
27157
  const container = containerRef.current;
27011
27158
  if (container) {
27012
27159
  checkOverflow();
@@ -27160,10 +27307,10 @@ var QuillToolTipPortal = ({
27160
27307
  mirror = false
27161
27308
  }) => {
27162
27309
  const [theme] = useContext4(ThemeContext);
27163
- const [isOpen, setIsOpen] = useState7(false);
27164
- const tooltipRef = useRef3(null);
27165
- const triggerRef = useRef3(null);
27166
- const [tooltipPosition, setTooltipPosition] = useState7(void 0);
27310
+ const [isOpen, setIsOpen] = useState8(false);
27311
+ const tooltipRef = useRef4(null);
27312
+ const triggerRef = useRef4(null);
27313
+ const [tooltipPosition, setTooltipPosition] = useState8(void 0);
27167
27314
  const updatePosition = () => {
27168
27315
  if (triggerRef.current && tooltipRef.current) {
27169
27316
  const rect = triggerRef.current.getBoundingClientRect();
@@ -27188,7 +27335,7 @@ var QuillToolTipPortal = ({
27188
27335
  setTooltipPosition({ top, left });
27189
27336
  }
27190
27337
  };
27191
- useEffect6(() => {
27338
+ useEffect7(() => {
27192
27339
  if (isOpen) {
27193
27340
  const timer2 = setTimeout(() => {
27194
27341
  updatePosition();
@@ -27331,10 +27478,10 @@ var QuillPortal = ({
27331
27478
  showModal,
27332
27479
  setShowModal
27333
27480
  }) => {
27334
- const modalRef = useRef3(null);
27335
- const [popoverPosition, setPopoverPosition] = useState7(void 0);
27336
- const [z, setZ] = useState7(10);
27337
- const scrollableParentRef = useRef3(document.body);
27481
+ const modalRef = useRef4(null);
27482
+ const [popoverPosition, setPopoverPosition] = useState8(void 0);
27483
+ const [z, setZ] = useState8(10);
27484
+ const scrollableParentRef = useRef4(document.body);
27338
27485
  const updatePosition = () => {
27339
27486
  if (anchorRef.current) {
27340
27487
  requestAnimationFrame(() => {
@@ -27352,7 +27499,7 @@ var QuillPortal = ({
27352
27499
  });
27353
27500
  }
27354
27501
  };
27355
- useEffect6(() => {
27502
+ useEffect7(() => {
27356
27503
  let resizeObserver;
27357
27504
  let mutationObserver;
27358
27505
  if (showModal && anchorRef.current) {
@@ -27449,18 +27596,18 @@ function QuillTable({
27449
27596
  hideLabels,
27450
27597
  disableSort
27451
27598
  }) {
27452
- const [activeRows, setActiveRows] = useState8([]);
27453
- const [maxPage, setMaxPage] = useState8(1);
27454
- const [sortColumn, setSortColumn] = useState8(sort?.field || "");
27455
- const [sortDirection, setSortDirection] = useState8(sort?.direction || "desc");
27599
+ const [activeRows, setActiveRows] = useState9([]);
27600
+ const [maxPage, setMaxPage] = useState9(1);
27601
+ const [sortColumn, setSortColumn] = useState9(sort?.field || "");
27602
+ const [sortDirection, setSortDirection] = useState9(sort?.direction || "desc");
27456
27603
  const [theme] = useContext5(ThemeContext);
27457
- const [isPaginating, setIsPaginating] = useState8(true);
27458
- const [initialLoad, setInitialLoad] = useState8(true);
27459
- useEffect7(() => {
27604
+ const [isPaginating, setIsPaginating] = useState9(true);
27605
+ const [initialLoad, setInitialLoad] = useState9(true);
27606
+ useEffect8(() => {
27460
27607
  setSortColumn(sort?.field || "");
27461
27608
  setSortDirection(sort?.direction || "desc");
27462
27609
  }, [sort]);
27463
- useEffect7(() => {
27610
+ useEffect8(() => {
27464
27611
  if (rows?.length === 0 && isLoading) {
27465
27612
  return;
27466
27613
  }
@@ -27492,7 +27639,7 @@ function QuillTable({
27492
27639
  rowCount,
27493
27640
  isLoading
27494
27641
  ]);
27495
- useEffect7(() => {
27642
+ useEffect8(() => {
27496
27643
  if (rows.length <= currentPage * rowsPerPage) {
27497
27644
  onPageChange && onPageChange(0);
27498
27645
  setMaxPage(1);
@@ -29458,9 +29605,9 @@ import { useMemo as useMemo10 } from "react";
29458
29605
  // src/DateRangePicker/QuillDateRangePicker.tsx
29459
29606
  import {
29460
29607
  useContext as useContext9,
29461
- useEffect as useEffect9,
29462
- useRef as useRef5,
29463
- useState as useState10
29608
+ useEffect as useEffect10,
29609
+ useRef as useRef6,
29610
+ useState as useState11
29464
29611
  } from "react";
29465
29612
  import {
29466
29613
  startOfMonth as startOfMonth2,
@@ -29481,9 +29628,9 @@ import {
29481
29628
  import {
29482
29629
  useContext as useContext8,
29483
29630
  useMemo as useMemo7,
29484
- useRef as useRef4,
29485
- useState as useState9,
29486
- useEffect as useEffect8
29631
+ useRef as useRef5,
29632
+ useState as useState10,
29633
+ useEffect as useEffect9
29487
29634
  } from "react";
29488
29635
  import { createPortal as createPortal2 } from "react-dom";
29489
29636
  import { jsx as jsx38, jsxs as jsxs28 } from "react/jsx-runtime";
@@ -29498,9 +29645,9 @@ function QuillSelectComponent({
29498
29645
  hideEmptyOption
29499
29646
  }) {
29500
29647
  const [theme] = useContext8(ThemeContext);
29501
- const [showModal, setShowModal] = useState9(false);
29502
- const modalRef = useRef4(null);
29503
- const buttonRef = useRef4(null);
29648
+ const [showModal, setShowModal] = useState10(false);
29649
+ const modalRef = useRef5(null);
29650
+ const buttonRef = useRef5(null);
29504
29651
  useOnClickOutside_default(
29505
29652
  modalRef,
29506
29653
  (event) => {
@@ -29523,9 +29670,9 @@ function QuillSelectComponent({
29523
29670
  const nullLabel = useMemo7(() => {
29524
29671
  return sortedItems.some((item) => item.value === "-") ? "None" : "-";
29525
29672
  }, [sortedItems]);
29526
- const [popoverPosition, setPopoverPosition] = useState9(void 0);
29527
- const [z, setZ] = useState9(10);
29528
- const scrollableParentRef = useRef4(document.body);
29673
+ const [popoverPosition, setPopoverPosition] = useState10(void 0);
29674
+ const [z, setZ] = useState10(10);
29675
+ const scrollableParentRef = useRef5(document.body);
29529
29676
  const updatePosition = () => {
29530
29677
  if (buttonRef.current) {
29531
29678
  requestAnimationFrame(() => {
@@ -29543,7 +29690,7 @@ function QuillSelectComponent({
29543
29690
  });
29544
29691
  }
29545
29692
  };
29546
- useEffect8(() => {
29693
+ useEffect9(() => {
29547
29694
  let resizeObserver;
29548
29695
  let mutationObserver;
29549
29696
  if (showModal && buttonRef.current) {
@@ -29824,23 +29971,23 @@ function QuillDateRangePicker({
29824
29971
  }) {
29825
29972
  const [theme] = useContext9(ThemeContext);
29826
29973
  const [client] = useContext9(ClientContext);
29827
- const [anchorStartDate, setAnchorStartDate] = useState10(
29974
+ const [anchorStartDate, setAnchorStartDate] = useState11(
29828
29975
  getAnchorStartDate(dateRange.startDate, dateRange.endDate)
29829
29976
  );
29830
- const [anchorEndDate, setAnchorEndDate] = useState10(
29977
+ const [anchorEndDate, setAnchorEndDate] = useState11(
29831
29978
  getAnchorEndDate(dateRange.startDate, dateRange.endDate)
29832
29979
  );
29833
- const [localStartDate, setLocalStartDate] = useState10(
29980
+ const [localStartDate, setLocalStartDate] = useState11(
29834
29981
  dateRange.startDate
29835
29982
  );
29836
- const [localEndDate, setLocalEndDate] = useState10(
29983
+ const [localEndDate, setLocalEndDate] = useState11(
29837
29984
  dateRange.endDate
29838
29985
  );
29839
- const [localPreset, setLocalPreset] = useState10(preset);
29840
- const [showModal, setShowModal] = useState10(false);
29841
- const buttonRef = useRef5(null);
29842
- const modalRef = useRef5(null);
29843
- useEffect9(() => {
29986
+ const [localPreset, setLocalPreset] = useState11(preset);
29987
+ const [showModal, setShowModal] = useState11(false);
29988
+ const buttonRef = useRef6(null);
29989
+ const modalRef = useRef6(null);
29990
+ useEffect10(() => {
29844
29991
  setLocalEndDate(dateRange.endDate);
29845
29992
  setLocalStartDate(dateRange.startDate);
29846
29993
  setLocalPreset(preset || "");
@@ -30353,10 +30500,10 @@ function getAnchorEndDate(startDate, endDate) {
30353
30500
  // src/components/QuillMultiSelectWithCombo.tsx
30354
30501
  import React7, {
30355
30502
  useContext as useContext10,
30356
- useEffect as useEffect10,
30503
+ useEffect as useEffect11,
30357
30504
  useMemo as useMemo8,
30358
- useRef as useRef6,
30359
- useState as useState11
30505
+ useRef as useRef7,
30506
+ useState as useState12
30360
30507
  } from "react";
30361
30508
  import { createPortal as createPortal3 } from "react-dom";
30362
30509
  import { Fragment as Fragment4, jsx as jsx40, jsxs as jsxs30 } from "react/jsx-runtime";
@@ -30373,17 +30520,17 @@ function QuillMultiSelectComponentWithCombo({
30373
30520
  style: style2
30374
30521
  }) {
30375
30522
  const [theme] = useContext10(ThemeContext);
30376
- const [selectedOptions, setSelectedOptions] = useState11([]);
30377
- const [showModal, setShowModal] = useState11(false);
30378
- const modalRef = useRef6(null);
30379
- const buttonRef = useRef6(null);
30380
- const debounceTimeoutId = useRef6(null);
30523
+ const [selectedOptions, setSelectedOptions] = useState12([]);
30524
+ const [showModal, setShowModal] = useState12(false);
30525
+ const modalRef = useRef7(null);
30526
+ const buttonRef = useRef7(null);
30527
+ const debounceTimeoutId = useRef7(null);
30381
30528
  const [searchQuery, setSearchQuery] = React7.useState("");
30382
- const [exceedsLimit, setExceedsLimit] = useState11(false);
30383
- const [popoverPosition, setPopoverPosition] = useState11(void 0);
30384
- const [z, setZ] = useState11(10);
30385
- const scrollableParentRef = useRef6(document.body);
30386
- const selectAllRef = useRef6(null);
30529
+ const [exceedsLimit, setExceedsLimit] = useState12(false);
30530
+ const [popoverPosition, setPopoverPosition] = useState12(void 0);
30531
+ const [z, setZ] = useState12(10);
30532
+ const scrollableParentRef = useRef7(document.body);
30533
+ const selectAllRef = useRef7(null);
30387
30534
  let CheckboxState;
30388
30535
  ((CheckboxState2) => {
30389
30536
  CheckboxState2[CheckboxState2["SELECTED"] = 0] = "SELECTED";
@@ -30417,7 +30564,7 @@ function QuillMultiSelectComponentWithCombo({
30417
30564
  (elem) => elem.label ?? "-"
30418
30565
  ).join(", ");
30419
30566
  }, [options, value]);
30420
- const [selectAllCheckboxState, setSelectAllCheckboxState] = useState11(
30567
+ const [selectAllCheckboxState, setSelectAllCheckboxState] = useState12(
30421
30568
  (() => {
30422
30569
  if (value.length === 0) {
30423
30570
  return 1 /* UNSELECTED */;
@@ -30428,12 +30575,12 @@ function QuillMultiSelectComponentWithCombo({
30428
30575
  return 2 /* INDETERMINATE */;
30429
30576
  })()
30430
30577
  );
30431
- useEffect10(() => {
30578
+ useEffect11(() => {
30432
30579
  if (selectAllRef.current) {
30433
30580
  selectAllRef.current.indeterminate = selectAllCheckboxState === 2 /* INDETERMINATE */;
30434
30581
  }
30435
30582
  }, [selectAllCheckboxState, showModal]);
30436
- useEffect10(() => {
30583
+ useEffect11(() => {
30437
30584
  if (options.length > 0 && options?.[0]?.value === "EXCEEDS_LIMIT") {
30438
30585
  setExceedsLimit(true);
30439
30586
  } else {
@@ -30448,7 +30595,7 @@ function QuillMultiSelectComponentWithCombo({
30448
30595
  },
30449
30596
  showModal
30450
30597
  );
30451
- useEffect10(() => {
30598
+ useEffect11(() => {
30452
30599
  if (!value) {
30453
30600
  setSelectedOptions([]);
30454
30601
  } else {
@@ -30513,7 +30660,7 @@ function QuillMultiSelectComponentWithCombo({
30513
30660
  });
30514
30661
  }
30515
30662
  };
30516
- useEffect10(() => {
30663
+ useEffect11(() => {
30517
30664
  let resizeObserver;
30518
30665
  let mutationObserver;
30519
30666
  if (showModal && buttonRef.current) {
@@ -31020,8 +31167,8 @@ var ListboxTextInput = ({
31020
31167
  import React8, {
31021
31168
  useContext as useContext11,
31022
31169
  useMemo as useMemo9,
31023
- useRef as useRef7,
31024
- useState as useState12
31170
+ useRef as useRef8,
31171
+ useState as useState13
31025
31172
  } from "react";
31026
31173
  import { jsx as jsx41, jsxs as jsxs31 } from "react/jsx-runtime";
31027
31174
  function QuillSelectComponentWithCombo({
@@ -31035,9 +31182,9 @@ function QuillSelectComponentWithCombo({
31035
31182
  disabled
31036
31183
  }) {
31037
31184
  const [theme] = useContext11(ThemeContext);
31038
- const [showModal, setShowModal] = useState12(false);
31039
- const modalRef = useRef7(null);
31040
- const buttonRef = useRef7(null);
31185
+ const [showModal, setShowModal] = useState13(false);
31186
+ const modalRef = useRef8(null);
31187
+ const buttonRef = useRef8(null);
31041
31188
  const [searchQuery, setSearchQuery] = React8.useState("");
31042
31189
  const filteredItems = React8.useMemo(() => {
31043
31190
  if (searchQuery === "") {
@@ -31825,7 +31972,7 @@ var MetricDisplay = ({
31825
31972
  };
31826
31973
 
31827
31974
  // src/components/Dashboard/DataLoader.tsx
31828
- import { useContext as useContext13, useEffect as useEffect11, useMemo as useMemo11, useRef as useRef8, useState as useState13 } from "react";
31975
+ import { useContext as useContext13, useEffect as useEffect12, useMemo as useMemo11, useRef as useRef9, useState as useState14 } from "react";
31829
31976
  init_paginationProcessing();
31830
31977
  init_tableProcessing();
31831
31978
  import equal2 from "fast-deep-equal";
@@ -31944,10 +32091,10 @@ function DataLoader({
31944
32091
  ) : Object.values(reportFilters[item.id] ?? {}).map((f) => f.filter);
31945
32092
  }, [dashboardFilters, reportFilters, dashboardName, item.id]);
31946
32093
  const [schemaData] = useContext13(SchemaDataContext);
31947
- const [loading, setLoading] = useState13(true);
31948
- const [error, setError] = useState13(void 0);
31949
- const [previousPage, setPreviousPage] = useState13(0);
31950
- const [additionalProcessing, setAdditionalProcessing] = useState13(defaultAdditionalProcessing);
32094
+ const [loading, setLoading] = useState14(true);
32095
+ const [error, setError] = useState14(void 0);
32096
+ const [previousPage, setPreviousPage] = useState14(0);
32097
+ const [additionalProcessing, setAdditionalProcessing] = useState14(defaultAdditionalProcessing);
31951
32098
  const chartReport = useMemo11(() => {
31952
32099
  const report = (dashboardName ? dashboard : reports)[item.id];
31953
32100
  if (report) {
@@ -31964,17 +32111,17 @@ function DataLoader({
31964
32111
  reportFilters,
31965
32112
  dashboardFilters
31966
32113
  ]);
31967
- const previousFilters = useRef8(filters);
31968
- const previousUserFilters = useRef8(userFilters);
31969
- const previousTenants = useRef8(tenants);
31970
- const previousCustomFields = useRef8(schemaData.customFields);
31971
- const [rowCountIsLoading, setRowCountIsLoading] = useState13(false);
31972
- const rowsRequestId = useRef8(0);
31973
- const rowsAbortController = useRef8(null);
31974
- const rowCountRequestId = useRef8(0);
31975
- const rowCountAbortController = useRef8(null);
31976
- const updateTableRowsRequestId = useRef8(0);
31977
- const updateTableRowsAbortController = useRef8(null);
32114
+ const previousFilters = useRef9(filters);
32115
+ const previousUserFilters = useRef9(userFilters);
32116
+ const previousTenants = useRef9(tenants);
32117
+ const previousCustomFields = useRef9(schemaData.customFields);
32118
+ const [rowCountIsLoading, setRowCountIsLoading] = useState14(false);
32119
+ const rowsRequestId = useRef9(0);
32120
+ const rowsAbortController = useRef9(null);
32121
+ const rowCountRequestId = useRef9(0);
32122
+ const rowCountAbortController = useRef9(null);
32123
+ const updateTableRowsRequestId = useRef9(0);
32124
+ const updateTableRowsAbortController = useRef9(null);
31978
32125
  const fetchRowCount = async (processing) => {
31979
32126
  if (!client || !filters) {
31980
32127
  if (!rowCountAbortController.current) return;
@@ -32241,7 +32388,7 @@ function DataLoader({
32241
32388
  }
32242
32389
  }
32243
32390
  };
32244
- useEffect11(() => {
32391
+ useEffect12(() => {
32245
32392
  if (schemaData.isSchemaLoading || filterValuesEquivalent(
32246
32393
  previousFilters.current ?? contextFilters,
32247
32394
  filters
@@ -32271,7 +32418,7 @@ function DataLoader({
32271
32418
  schemaData.customFields,
32272
32419
  schemaData.isSchemaLoading
32273
32420
  ]);
32274
- useEffect11(() => {
32421
+ useEffect12(() => {
32275
32422
  const tempReport = (dashboardName ? dashboard : reports)[item.id];
32276
32423
  if (tempReport?.triggerReload) {
32277
32424
  fetchReportHelper(additionalProcessing);
@@ -32314,17 +32461,17 @@ var ChartDataLoader = ({
32314
32461
  (f) => f.filter
32315
32462
  ) : Object.values(reportFilters[item.id] ?? {}).map((f) => f.filter);
32316
32463
  }, [dashboardFilters, reportFilters, dashboardName, item.id]);
32317
- const [loading, setLoading] = useState13(true);
32318
- const [error, setError] = useState13(void 0);
32464
+ const [loading, setLoading] = useState14(true);
32465
+ const [error, setError] = useState14(void 0);
32319
32466
  const [client] = useContext13(ClientContext);
32320
32467
  const [schemaData] = useContext13(SchemaDataContext);
32321
- const previousFilters = useRef8(filters);
32322
- const previousUserFilters = useRef8(userFilters);
32323
- const previousDateBucket = useRef8(dateBucket);
32324
- const previousTenants = useRef8(tenants);
32325
- const previousCustomFields = useRef8(schemaData.customFields);
32326
- const fetchReportAbortController = useRef8(null);
32327
- const rowsRequestId = useRef8(0);
32468
+ const previousFilters = useRef9(filters);
32469
+ const previousUserFilters = useRef9(userFilters);
32470
+ const previousDateBucket = useRef9(dateBucket);
32471
+ const previousTenants = useRef9(tenants);
32472
+ const previousCustomFields = useRef9(schemaData.customFields);
32473
+ const fetchReportAbortController = useRef9(null);
32474
+ const rowsRequestId = useRef9(0);
32328
32475
  const chartReport = useMemo11(() => {
32329
32476
  const report = dashboardName ? dashboard[item.id] : reports[item.id];
32330
32477
  if (!report) {
@@ -32437,7 +32584,7 @@ var ChartDataLoader = ({
32437
32584
  }
32438
32585
  }
32439
32586
  };
32440
- useEffect11(() => {
32587
+ useEffect12(() => {
32441
32588
  if (!filters) {
32442
32589
  return;
32443
32590
  }
@@ -32472,7 +32619,7 @@ var ChartDataLoader = ({
32472
32619
  schemaData.customFields,
32473
32620
  schemaData.isSchemaLoading
32474
32621
  ]);
32475
- useEffect11(() => {
32622
+ useEffect12(() => {
32476
32623
  const tempReport = (dashboardName ? dashboard : reports)[item.id];
32477
32624
  if (tempReport && tempReport.triggerReload) {
32478
32625
  fetchReportHelper();
@@ -32554,7 +32701,7 @@ import {
32554
32701
  Geography,
32555
32702
  useMapContext
32556
32703
  } from "react-simple-maps";
32557
- import { useEffect as useEffect12, useMemo as useMemo12, useRef as useRef9, useState as useState14 } from "react";
32704
+ import { useEffect as useEffect13, useMemo as useMemo12, useRef as useRef10, useState as useState15 } from "react";
32558
32705
  init_valueFormatter();
32559
32706
  import { jsx as jsx45, jsxs as jsxs34 } from "react/jsx-runtime";
32560
32707
  var statesUrl = "https://cdn.jsdelivr.net/npm/us-atlas@3/states-10m.json";
@@ -32881,18 +33028,18 @@ function USMap({
32881
33028
  className,
32882
33029
  containerStyle
32883
33030
  }) {
32884
- const containerRef = useRef9(null);
32885
- const [hoveredState, setHoveredState] = useState14(
33031
+ const containerRef = useRef10(null);
33032
+ const [hoveredState, setHoveredState] = useState15(
32886
33033
  void 0
32887
33034
  );
32888
- const [hoveredCoords, setHoveredCoords] = useState14(void 0);
33035
+ const [hoveredCoords, setHoveredCoords] = useState15(void 0);
32889
33036
  const mappedData = data.reduce((acc, curr) => {
32890
33037
  acc[curr[xAxisField]?.toString()] = curr;
32891
33038
  return acc;
32892
33039
  }, {});
32893
33040
  const measureField = yAxisFields[0]?.field ?? xAxisField;
32894
- const [scaleLog, setScaleLog] = useState14(null);
32895
- useEffect12(() => {
33041
+ const [scaleLog, setScaleLog] = useState15(null);
33042
+ useEffect13(() => {
32896
33043
  import("d3-scale").then((scale) => {
32897
33044
  setScaleLog(() => scale.scaleLog);
32898
33045
  });
@@ -33072,18 +33219,18 @@ function WorldMap({
33072
33219
  className,
33073
33220
  containerStyle
33074
33221
  }) {
33075
- const containerRef = useRef9(null);
33076
- const [hoveredCountry, setHoveredCountry] = useState14(
33222
+ const containerRef = useRef10(null);
33223
+ const [hoveredCountry, setHoveredCountry] = useState15(
33077
33224
  void 0
33078
33225
  );
33079
- const [hoveredCoords, setHoveredCoords] = useState14(void 0);
33226
+ const [hoveredCoords, setHoveredCoords] = useState15(void 0);
33080
33227
  const mappedData = data.reduce((acc, curr) => {
33081
33228
  acc[curr[xAxisField]?.toString()] = curr;
33082
33229
  return acc;
33083
33230
  }, {});
33084
33231
  const measureField = yAxisFields[0]?.field ?? xAxisField;
33085
- const [scaleLog, setScaleLog] = useState14(null);
33086
- useEffect12(() => {
33232
+ const [scaleLog, setScaleLog] = useState15(null);
33233
+ useEffect13(() => {
33087
33234
  import("d3-scale").then((scale) => {
33088
33235
  setScaleLog(() => scale.scaleLog);
33089
33236
  });
@@ -33265,8 +33412,8 @@ function MapLayout({
33265
33412
  regionNames
33266
33413
  }) {
33267
33414
  const { projection } = useMapContext();
33268
- const [geoCentroid, setGeoCentroid] = useState14(null);
33269
- useEffect12(() => {
33415
+ const [geoCentroid, setGeoCentroid] = useState15(null);
33416
+ useEffect13(() => {
33270
33417
  import("d3-geo").then((geo) => {
33271
33418
  setGeoCentroid(() => geo.geoCentroid);
33272
33419
  });
@@ -33318,7 +33465,7 @@ function MapLayout({
33318
33465
  }
33319
33466
 
33320
33467
  // src/components/Chart/GaugeChart.tsx
33321
- import { useEffect as useEffect13, useRef as useRef10, useState as useState15 } from "react";
33468
+ import { useEffect as useEffect14, useRef as useRef11, useState as useState16 } from "react";
33322
33469
 
33323
33470
  // ../../node_modules/d3-transition/src/selection/index.js
33324
33471
  import { selection as selection3 } from "d3-selection";
@@ -34592,20 +34739,20 @@ function D3Gauge({
34592
34739
  colors,
34593
34740
  isAnimationActive
34594
34741
  }) {
34595
- const containerRef = useRef10(null);
34596
- const svgRef = useRef10(null);
34597
- const gaugeGroupRef = useRef10(null);
34598
- const needleRef = useRef10(null);
34599
- const needleOutlineRef = useRef10(null);
34600
- const textRef = useRef10(null);
34601
- const previousPercentageRef = useRef10(0);
34602
- const firstMountRef = useRef10(true);
34742
+ const containerRef = useRef11(null);
34743
+ const svgRef = useRef11(null);
34744
+ const gaugeGroupRef = useRef11(null);
34745
+ const needleRef = useRef11(null);
34746
+ const needleOutlineRef = useRef11(null);
34747
+ const textRef = useRef11(null);
34748
+ const previousPercentageRef = useRef11(0);
34749
+ const firstMountRef = useRef11(true);
34603
34750
  const startAngle = -(3 * Math.PI) / 4;
34604
34751
  const totalAngle = 3 * Math.PI / 2;
34605
- const [arc, setArc] = useState15(null);
34606
- const [interpolate, setInterpolate] = useState15(null);
34607
- const [select, setSelect] = useState15(null);
34608
- useEffect13(() => {
34752
+ const [arc, setArc] = useState16(null);
34753
+ const [interpolate, setInterpolate] = useState16(null);
34754
+ const [select, setSelect] = useState16(null);
34755
+ useEffect14(() => {
34609
34756
  import("d3-shape").then(({ arc: arc2 }) => {
34610
34757
  setArc(() => arc2);
34611
34758
  });
@@ -34616,7 +34763,7 @@ function D3Gauge({
34616
34763
  setSelect(() => select2);
34617
34764
  });
34618
34765
  }, []);
34619
- useEffect13(() => {
34766
+ useEffect14(() => {
34620
34767
  if (!containerRef.current || !select) return;
34621
34768
  const container = containerRef.current;
34622
34769
  select(container).select("svg").remove();
@@ -34633,7 +34780,7 @@ function D3Gauge({
34633
34780
  svgRef.current = null;
34634
34781
  };
34635
34782
  }, [colors, select]);
34636
- useEffect13(() => {
34783
+ useEffect14(() => {
34637
34784
  if (!containerRef.current || !svgRef.current || !gaugeGroupRef.current || !needleRef.current || !needleOutlineRef.current || !textRef.current || !arc || !interpolate || !select)
34638
34785
  return;
34639
34786
  const rect = containerRef.current.getBoundingClientRect();
@@ -34733,7 +34880,7 @@ function D3Gauge({
34733
34880
  arc,
34734
34881
  interpolate
34735
34882
  ]);
34736
- useEffect13(() => {
34883
+ useEffect14(() => {
34737
34884
  if (!containerRef.current) return;
34738
34885
  const observer = new ResizeObserver(() => {
34739
34886
  previousPercentageRef.current = percentage;
@@ -34752,7 +34899,7 @@ function D3Gauge({
34752
34899
 
34753
34900
  // src/components/QuillComponentTables.tsx
34754
34901
  init_paginationProcessing();
34755
- import { useState as useState16, useEffect as useEffect14, useContext as useContext15 } from "react";
34902
+ import { useState as useState17, useEffect as useEffect15, useContext as useContext15 } from "react";
34756
34903
  import { jsx as jsx47, jsxs as jsxs35 } from "react/jsx-runtime";
34757
34904
  var QuillTableSQLEditorComponent = ({
34758
34905
  rows,
@@ -34768,8 +34915,8 @@ var QuillTableSQLEditorComponent = ({
34768
34915
  setCurrentPage,
34769
34916
  hideLabels
34770
34917
  }) => {
34771
- const [sort, setSort] = useState16({ field: "", direction: "" });
34772
- const [page, setPage] = useState16(0);
34918
+ const [sort, setSort] = useState17({ field: "", direction: "" });
34919
+ const [page, setPage] = useState17(0);
34773
34920
  return /* @__PURE__ */ jsx47(
34774
34921
  QuillTable,
34775
34922
  {
@@ -34811,9 +34958,9 @@ var QuillTableReportBuilderComponent = ({
34811
34958
  setCurrentPage,
34812
34959
  disableSort
34813
34960
  }) => {
34814
- const [sort, setSort] = useState16({ field: "", direction: "" });
34815
- const [page, setPage] = useState16(0);
34816
- useEffect14(() => {
34961
+ const [sort, setSort] = useState17({ field: "", direction: "" });
34962
+ const [page, setPage] = useState17(0);
34963
+ useEffect15(() => {
34817
34964
  if (disableSort) {
34818
34965
  setSort({ field: "", direction: "" });
34819
34966
  }
@@ -34857,15 +35004,15 @@ var QuillTableComponent = ({
34857
35004
  currentPage,
34858
35005
  hideLabels
34859
35006
  }) => {
34860
- const [sort, setSort] = useState16({ field: "", direction: "" });
34861
- const [page, setPage] = useState16(0);
34862
- const [initialLoad, setInitialLoad] = useState16(true);
34863
- useEffect14(() => {
35007
+ const [sort, setSort] = useState17({ field: "", direction: "" });
35008
+ const [page, setPage] = useState17(0);
35009
+ const [initialLoad, setInitialLoad] = useState17(true);
35010
+ useEffect15(() => {
34864
35011
  if (initialLoad && !isLoading) {
34865
35012
  setInitialLoad(false);
34866
35013
  }
34867
35014
  }, [isLoading]);
34868
- useEffect14(() => {
35015
+ useEffect15(() => {
34869
35016
  setPage(currentPage || 0);
34870
35017
  }, [currentPage]);
34871
35018
  if (initialLoad) {
@@ -34919,15 +35066,15 @@ function QuillTableDashboardComponent({
34919
35066
  hideName
34920
35067
  }) {
34921
35068
  const [theme] = useContext15(ThemeContext);
34922
- const [initialLoad, setInitialLoad] = useState16(true);
35069
+ const [initialLoad, setInitialLoad] = useState17(true);
34923
35070
  const { downloadCSV: downloadCSV2 } = useExport(report?.id);
34924
- const [page, setPage] = useState16(0);
34925
- useEffect14(() => {
35071
+ const [page, setPage] = useState17(0);
35072
+ useEffect15(() => {
34926
35073
  if (!isLoading) {
34927
35074
  setInitialLoad(false);
34928
35075
  }
34929
35076
  }, [isLoading]);
34930
- useEffect14(() => {
35077
+ useEffect15(() => {
34931
35078
  if (rowCountIsLoading) {
34932
35079
  setPage(0);
34933
35080
  }
@@ -35101,12 +35248,12 @@ function Chart({
35101
35248
  filters,
35102
35249
  dashboardCustomFilters[allReportsById[reportId]?.dashboardName ?? ""]
35103
35250
  ]);
35104
- const previousFilters = useRef11(void 0);
35251
+ const previousFilters = useRef12(void 0);
35105
35252
  if (!equal3(previousFilters.current, filters)) {
35106
35253
  previousFilters.current = filters;
35107
35254
  }
35108
- const [filterValues, setFilterValues] = useState17({});
35109
- useEffect15(() => {
35255
+ const [filterValues, setFilterValues] = useState18({});
35256
+ useEffect16(() => {
35110
35257
  setFilterValues(
35111
35258
  Object.values(reportFilters[reportId] ?? {}).reduce((acc, f) => {
35112
35259
  acc[f.filter.label] = f.filter.filterType === "string" ? f.filter.stringFilterType === "multiselect" ? { values: f.filter.values, operator: "IN" } : { selectedValue: f.filter.selectedValue } : f.filter.filterType === "date_range" ? {
@@ -35121,7 +35268,7 @@ function Chart({
35121
35268
  }, {})
35122
35269
  );
35123
35270
  }, [reportFilters[reportId]]);
35124
- useEffect15(() => {
35271
+ useEffect16(() => {
35125
35272
  if (equal3(customReportFilters[reportId] ?? [], filters ?? [])) {
35126
35273
  return;
35127
35274
  }
@@ -35137,7 +35284,7 @@ function Chart({
35137
35284
  });
35138
35285
  };
35139
35286
  }, [filters]);
35140
- useEffect15(() => {
35287
+ useEffect16(() => {
35141
35288
  if (reportDateFilter) {
35142
35289
  const customDateFilter = previousFilters.current?.find(
35143
35290
  (f) => f.filterType === "date" /* Date */
@@ -35175,7 +35322,7 @@ function Chart({
35175
35322
  [reportId, allReportsById]
35176
35323
  );
35177
35324
  const report = useMemo13(() => reports[reportId], [reports, reportId]);
35178
- const [loading, setLoading] = useState17(true);
35325
+ const [loading, setLoading] = useState18(true);
35179
35326
  const [theme] = useContext16(ThemeContext);
35180
35327
  const colorMap = useMemo13(() => {
35181
35328
  if (mapColorsToFields && report && theme) {
@@ -35183,7 +35330,7 @@ function Chart({
35183
35330
  }
35184
35331
  }, [report, theme]);
35185
35332
  const [client, clientLoading] = useContext16(ClientContext);
35186
- const [error, setError] = useState17(void 0);
35333
+ const [error, setError] = useState18(void 0);
35187
35334
  const updateFilter = (filter, value, comparison) => {
35188
35335
  let filterValue = {};
35189
35336
  if (filter.filterType === "string" /* String */) {
@@ -35293,7 +35440,7 @@ function Chart({
35293
35440
  setLoading(false);
35294
35441
  }
35295
35442
  };
35296
- useEffect15(() => {
35443
+ useEffect16(() => {
35297
35444
  if (reportId === void 0 || reportId === "" || clientLoading || isDashboardsLoading) {
35298
35445
  return;
35299
35446
  }
@@ -35510,7 +35657,7 @@ var ChartDisplay = ({
35510
35657
  }
35511
35658
  return void 0;
35512
35659
  }, [config, specificReportFilters, specificDashboardFilters]);
35513
- const [page, setPage] = useState17(0);
35660
+ const [page, setPage] = useState18(0);
35514
35661
  if (loading) {
35515
35662
  return /* @__PURE__ */ jsx48("div", { className, style: containerStyle, children: /* @__PURE__ */ jsx48(LoadingComponent, {}) });
35516
35663
  } else if (config && !["metric", "table", "gauge", "US map", "World map"].includes(
@@ -35954,7 +36101,7 @@ function QuillChartComponent({
35954
36101
  }
35955
36102
 
35956
36103
  // src/components/Dashboard/TemplateChartComponent.tsx
35957
- import { useState as useState18 } from "react";
36104
+ import { useState as useState19 } from "react";
35958
36105
  import { jsx as jsx51 } from "react/jsx-runtime";
35959
36106
  function QuillTemplateChartComponent({
35960
36107
  report,
@@ -35962,7 +36109,7 @@ function QuillTemplateChartComponent({
35962
36109
  children,
35963
36110
  isLoading
35964
36111
  }) {
35965
- const [isSelected, setIsSelected] = useState18(false);
36112
+ const [isSelected, setIsSelected] = useState19(false);
35966
36113
  return /* @__PURE__ */ jsx51(
35967
36114
  "div",
35968
36115
  {
@@ -36049,10 +36196,10 @@ init_filterProcessing();
36049
36196
  import {
36050
36197
  forwardRef as forwardRef2,
36051
36198
  useContext as useContext19,
36052
- useEffect as useEffect16,
36199
+ useEffect as useEffect17,
36053
36200
  useMemo as useMemo14,
36054
- useRef as useRef12,
36055
- useState as useState19
36201
+ useRef as useRef13,
36202
+ useState as useState20
36056
36203
  } from "react";
36057
36204
  init_util();
36058
36205
  init_tableProcessing();
@@ -36547,10 +36694,10 @@ var FilterPopoverWrapper = ({
36547
36694
  }) => {
36548
36695
  const { tenants } = useContext19(TenantContext);
36549
36696
  const { eventTracking } = useContext19(EventTrackingContext);
36550
- const [isOpen, setIsOpen] = useState19(false);
36551
- const [uniqueValues, setUniqueValues] = useState19(void 0);
36552
- const [uniqueValuesIsLoading, setUniqueValuesIsLoading] = useState19(false);
36553
- const prevFiltersRef = useRef12("");
36697
+ const [isOpen, setIsOpen] = useState20(false);
36698
+ const [uniqueValues, setUniqueValues] = useState20(void 0);
36699
+ const [uniqueValuesIsLoading, setUniqueValuesIsLoading] = useState20(false);
36700
+ const prevFiltersRef = useRef13("");
36554
36701
  const columnInternals = useMemo14(() => {
36555
36702
  if (!tables) {
36556
36703
  return null;
@@ -36565,7 +36712,7 @@ var FilterPopoverWrapper = ({
36565
36712
  });
36566
36713
  return relevantColumns;
36567
36714
  }, [schema, tables]);
36568
- useEffect16(() => {
36715
+ useEffect17(() => {
36569
36716
  const currentFiltersString = JSON.stringify(priorFilters);
36570
36717
  if (currentFiltersString !== prevFiltersRef.current) {
36571
36718
  prevFiltersRef.current = currentFiltersString;
@@ -36635,7 +36782,7 @@ var FilterPopoverWrapper = ({
36635
36782
 
36636
36783
  // src/components/ReportBuilder/FilterModal.tsx
36637
36784
  init_Filter();
36638
- import { useState as useState20, useEffect as useEffect17, useMemo as useMemo15 } from "react";
36785
+ import { useState as useState21, useEffect as useEffect18, useMemo as useMemo15 } from "react";
36639
36786
  init_textProcessing();
36640
36787
  init_filterProcessing();
36641
36788
  import { format as format8, isValid as isValid5, parse as parse4, startOfToday as startOfToday2 } from "date-fns";
@@ -36657,32 +36804,32 @@ function FilterModal({
36657
36804
  MultiSelectComponent,
36658
36805
  reportBuilderColumns
36659
36806
  }) {
36660
- const [field, setField] = useState20("");
36661
- const [fieldOptions, setFieldOptions] = useState20([]);
36662
- const [fieldValues, setFieldValues] = useState20([]);
36663
- const [type, setType] = useState20(null);
36664
- const [value, setValue] = useState20(void 0);
36665
- const [selectedOptions, setSelectedOptions] = useState20([]);
36666
- const [operator, setOperator] = useState20(
36807
+ const [field, setField] = useState21("");
36808
+ const [fieldOptions, setFieldOptions] = useState21([]);
36809
+ const [fieldValues, setFieldValues] = useState21([]);
36810
+ const [type, setType] = useState21(null);
36811
+ const [value, setValue] = useState21(void 0);
36812
+ const [selectedOptions, setSelectedOptions] = useState21([]);
36813
+ const [operator, setOperator] = useState21(
36667
36814
  void 0
36668
36815
  );
36669
- const [operatorOptions, setOperatorOptions] = useState20([]);
36670
- const [unit, setUnit] = useState20("");
36671
- const [unitOptions, setUnitOptions] = useState20([]);
36672
- const [startDate, setStartDate] = useState20(
36816
+ const [operatorOptions, setOperatorOptions] = useState21([]);
36817
+ const [unit, setUnit] = useState21("");
36818
+ const [unitOptions, setUnitOptions] = useState21([]);
36819
+ const [startDate, setStartDate] = useState21(
36673
36820
  startOfToday2().toISOString().substring(0, 10)
36674
36821
  );
36675
- const [endDate, setEndDate] = useState20(
36822
+ const [endDate, setEndDate] = useState21(
36676
36823
  startOfToday2().toISOString().substring(0, 10)
36677
36824
  );
36678
- const [filterInitialized, setFilterInitialized] = useState20(false);
36679
- const [table, setTable] = useState20(void 0);
36825
+ const [filterInitialized, setFilterInitialized] = useState21(false);
36826
+ const [table, setTable] = useState21(void 0);
36680
36827
  const memoizedFieldValuesMap = useMemo15(
36681
36828
  () => fieldValuesMap,
36682
36829
  [JSON.stringify(fieldValuesMap)]
36683
36830
  );
36684
36831
  const memoizedFilter = useMemo15(() => filter, [JSON.stringify(filter)]);
36685
- useEffect17(() => {
36832
+ useEffect18(() => {
36686
36833
  if (!filter) {
36687
36834
  onFieldChange(field, fieldOptions, table);
36688
36835
  }
@@ -36727,7 +36874,7 @@ function FilterModal({
36727
36874
  ],
36728
36875
  [FieldType.Null]: [NullOperator.IsNotNull, NullOperator.IsNull]
36729
36876
  };
36730
- useEffect17(() => {
36877
+ useEffect18(() => {
36731
36878
  if (filter) {
36732
36879
  setField(filter.field);
36733
36880
  setTable(filter.table);
@@ -36755,7 +36902,7 @@ function FilterModal({
36755
36902
  }
36756
36903
  }
36757
36904
  }, [memoizedFilter]);
36758
- useEffect17(() => {
36905
+ useEffect18(() => {
36759
36906
  if (schema) {
36760
36907
  const fo = schema.flatMap((table2) => {
36761
36908
  if (tables && !tables.includes(table2.name)) {
@@ -37437,7 +37584,7 @@ function FilterModal({
37437
37584
  }
37438
37585
 
37439
37586
  // src/components/Dashboard/TemplateMetricComponent.tsx
37440
- import { useState as useState21 } from "react";
37587
+ import { useState as useState22 } from "react";
37441
37588
  import { jsx as jsx55 } from "react/jsx-runtime";
37442
37589
  function QuillTemplateMetricComponent({
37443
37590
  report,
@@ -37445,7 +37592,7 @@ function QuillTemplateMetricComponent({
37445
37592
  children,
37446
37593
  isLoading
37447
37594
  }) {
37448
- const [isSelected, setIsSelected] = useState21(false);
37595
+ const [isSelected, setIsSelected] = useState22(false);
37449
37596
  return /* @__PURE__ */ jsx55(
37450
37597
  "div",
37451
37598
  {
@@ -37474,7 +37621,7 @@ function QuillTemplateMetricComponent({
37474
37621
  }
37475
37622
 
37476
37623
  // src/components/Dashboard/TemplateTableComponent.tsx
37477
- import { useState as useState22 } from "react";
37624
+ import { useState as useState23 } from "react";
37478
37625
  import { jsx as jsx56 } from "react/jsx-runtime";
37479
37626
  function QuillTemplateTableComponent({
37480
37627
  report,
@@ -37485,7 +37632,7 @@ function QuillTemplateTableComponent({
37485
37632
  onPageChange,
37486
37633
  onSortChange
37487
37634
  }) {
37488
- const [isSelected, setIsSelected] = useState22(false);
37635
+ const [isSelected, setIsSelected] = useState23(false);
37489
37636
  return /* @__PURE__ */ jsx56(
37490
37637
  "div",
37491
37638
  {
@@ -37700,14 +37847,14 @@ function Dashboard({
37700
37847
  templateDashboardName,
37701
37848
  pagination = { rowsPerPage: 10, rowsPerRequest: 50 }
37702
37849
  }) {
37703
- const [userFilters, setUserFilters] = useState23({});
37704
- const [selectedSection, setSelectedSection] = useState23("");
37850
+ const [userFilters, setUserFilters] = useState24({});
37851
+ const [selectedSection, setSelectedSection] = useState24("");
37705
37852
  const dataLoaderUserFilters = useMemo16(() => {
37706
37853
  return (filters?.map((f) => convertCustomFilter(f)) ?? []).concat(
37707
37854
  Object.values(userFilters)
37708
37855
  );
37709
37856
  }, [filters, userFilters]);
37710
- useEffect18(() => {
37857
+ useEffect19(() => {
37711
37858
  onUserFiltersUpdated?.(Object.values(userFilters));
37712
37859
  }, [userFilters]);
37713
37860
  const {
@@ -37805,8 +37952,8 @@ function Dashboard({
37805
37952
  });
37806
37953
  return map;
37807
37954
  }, [data?.sections, data?.sectionOrder]);
37808
- const mounted = useRef13(false);
37809
- useEffect18(() => {
37955
+ const mounted = useRef14(false);
37956
+ useEffect19(() => {
37810
37957
  if (!mounted.current) {
37811
37958
  mounted.current = true;
37812
37959
  return;
@@ -37818,7 +37965,7 @@ function Dashboard({
37818
37965
  filters: populatedDashboardFilters ?? []
37819
37966
  });
37820
37967
  }, [filters, userFilters]);
37821
- useEffect18(() => {
37968
+ useEffect19(() => {
37822
37969
  customFilterDispatch({
37823
37970
  type: "ADD_CUSTOM_DASHBOARD_FILTERS",
37824
37971
  dashboardName: name2,
@@ -37832,31 +37979,31 @@ function Dashboard({
37832
37979
  const { dispatch: dashboardFiltersDispatch } = useContext20(
37833
37980
  DashboardFiltersContext
37834
37981
  );
37835
- const [fieldValuesMap, setFieldValuesMap] = useState23({});
37836
- const [fieldValuesIsLoaded, setFieldValuesIsLoaded] = useState23(false);
37837
- const [addFilterPopoverIsOpen, setAddFilterPopoverIsOpen] = useState23(false);
37838
- const [filterListIsOpen, setFilterListIsOpen] = useState23(false);
37982
+ const [fieldValuesMap, setFieldValuesMap] = useState24({});
37983
+ const [fieldValuesIsLoaded, setFieldValuesIsLoaded] = useState24(false);
37984
+ const [addFilterPopoverIsOpen, setAddFilterPopoverIsOpen] = useState24(false);
37985
+ const [filterListIsOpen, setFilterListIsOpen] = useState24(false);
37839
37986
  const [
37840
37987
  filterListAddFilterPopoverIsOpen,
37841
37988
  setFilterListAddFilterPopoverIsOpen
37842
- ] = useState23(false);
37989
+ ] = useState24(false);
37843
37990
  const presetOptions = useMemo16(() => {
37844
37991
  return populatedDashboardFilters?.[0]?.filterType === "date_range" ? convertPresetOptionsToSelectableList(
37845
37992
  populatedDashboardFilters[0].presetOptions ?? [],
37846
37993
  populatedDashboardFilters[0].defaultPresetRanges ?? []
37847
37994
  ) : defaultOptionsV2;
37848
37995
  }, [populatedDashboardFilters]);
37849
- const [filterValues, setFilterValues] = useState23({});
37850
- const prevNameRef = useRef13(name2);
37851
- const prevFlagsRef = useRef13(flags);
37852
- const prevClientRef = useRef13(client?.publicKey ?? "");
37853
- const addFilterPopoverButtonRef = useRef13(null);
37854
- const viewFiltersPopoverButtonRef = useRef13(null);
37855
- const previousFilters = useRef13(filters);
37996
+ const [filterValues, setFilterValues] = useState24({});
37997
+ const prevNameRef = useRef14(name2);
37998
+ const prevFlagsRef = useRef14(flags);
37999
+ const prevClientRef = useRef14(client?.publicKey ?? "");
38000
+ const addFilterPopoverButtonRef = useRef14(null);
38001
+ const viewFiltersPopoverButtonRef = useRef14(null);
38002
+ const previousFilters = useRef14(filters);
37856
38003
  if (!equal4(previousFilters.current, filters)) {
37857
38004
  previousFilters.current = filters;
37858
38005
  }
37859
- const isInitialLoadOfDashboardRef = useRef13(false);
38006
+ const isInitialLoadOfDashboardRef = useRef14(false);
37860
38007
  const referencedTables = useMemo16(() => {
37861
38008
  const sections = data?.sections || {};
37862
38009
  const tables2 = Object.values(sections).flatMap(
@@ -37864,7 +38011,7 @@ function Dashboard({
37864
38011
  ).flat();
37865
38012
  return Array.from(new Set(tables2));
37866
38013
  }, [data?.sections]);
37867
- useEffect18(() => {
38014
+ useEffect19(() => {
37868
38015
  if (prevNameRef.current === name2 && Object.values(data?.sections ?? {}).flat().length) {
37869
38016
  return;
37870
38017
  }
@@ -37884,8 +38031,8 @@ function Dashboard({
37884
38031
  prevFlagsRef.current = flags;
37885
38032
  });
37886
38033
  }, [name2, isClientLoading]);
37887
- const tenantMounted = useRef13(false);
37888
- useEffect18(() => {
38034
+ const tenantMounted = useRef14(false);
38035
+ useEffect19(() => {
37889
38036
  if (!tenantMounted.current) {
37890
38037
  tenantMounted.current = true;
37891
38038
  return;
@@ -37904,7 +38051,7 @@ function Dashboard({
37904
38051
  isInitialLoadOfDashboardRef.current = false;
37905
38052
  });
37906
38053
  }, [flags]);
37907
- useEffect18(() => {
38054
+ useEffect19(() => {
37908
38055
  if (prevClientRef.current === client?.publicKey) {
37909
38056
  return;
37910
38057
  }
@@ -37919,7 +38066,7 @@ function Dashboard({
37919
38066
  isInitialLoadOfDashboardRef.current = false;
37920
38067
  });
37921
38068
  }, [client?.publicKey]);
37922
- useEffect18(() => {
38069
+ useEffect19(() => {
37923
38070
  setFilterValues(
37924
38071
  Object.values(populatedDashboardFilters ?? {}).reduce((acc, f) => {
37925
38072
  acc[f.label] = f.filterType === "string" ? f.stringFilterType === "multiselect" ? { values: f.values, operator: "IN" } : { selectedValue: f.selectedValue } : f.filterType === "date_range" ? {
@@ -37934,7 +38081,7 @@ function Dashboard({
37934
38081
  }, {})
37935
38082
  );
37936
38083
  }, [populatedDashboardFilters]);
37937
- useEffect18(() => {
38084
+ useEffect19(() => {
37938
38085
  const dashboardDateFilter = populatedDashboardFilters?.find(
37939
38086
  (f) => f.filterType === "date_range"
37940
38087
  );
@@ -37971,7 +38118,7 @@ function Dashboard({
37971
38118
  });
37972
38119
  }
37973
38120
  }, [previousFilters.current]);
37974
- useEffect18(() => {
38121
+ useEffect19(() => {
37975
38122
  const fetchData = async () => {
37976
38123
  setFieldValuesIsLoaded(false);
37977
38124
  const newFieldValues = {};
@@ -38132,7 +38279,7 @@ function Dashboard({
38132
38279
  [filter.field]: filter
38133
38280
  }));
38134
38281
  };
38135
- useEffect18(() => {
38282
+ useEffect19(() => {
38136
38283
  if (onChangeLoading && isLoading) {
38137
38284
  onChangeLoading(isLoading);
38138
38285
  }
@@ -38777,10 +38924,10 @@ function QuillDashboardTemplate({
38777
38924
  const { dashboardConfig, dashboardConfigDispatch } = useContext20(
38778
38925
  DashboardConfigContext
38779
38926
  );
38780
- const [addItemModalIsOpen, setAddItemModalIsOpen] = useState23(false);
38781
- const [selectedTemplates, setSelectedTemplates] = useState23([]);
38782
- const [selectingTemplate, setSelectingTemplate] = useState23(false);
38783
- const [submittingTemplate, setSubmittingTemplate] = useState23(false);
38927
+ const [addItemModalIsOpen, setAddItemModalIsOpen] = useState24(false);
38928
+ const [selectedTemplates, setSelectedTemplates] = useState24([]);
38929
+ const [selectingTemplate, setSelectingTemplate] = useState24(false);
38930
+ const [submittingTemplate, setSubmittingTemplate] = useState24(false);
38784
38931
  const templateSections = data?.sections;
38785
38932
  const onSubmitTemplates = async () => {
38786
38933
  setSubmittingTemplate(true);
@@ -38925,9 +39072,9 @@ var QuillProvider_default = QuillProvider;
38925
39072
  // src/Table.tsx
38926
39073
  import {
38927
39074
  useContext as useContext21,
38928
- useEffect as useEffect19,
39075
+ useEffect as useEffect20,
38929
39076
  useMemo as useMemo17,
38930
- useState as useState24
39077
+ useState as useState25
38931
39078
  } from "react";
38932
39079
  init_Filter();
38933
39080
  init_paginationProcessing();
@@ -38945,7 +39092,7 @@ var Table = ({
38945
39092
  const [schemaData] = useContext21(SchemaDataContext);
38946
39093
  const { eventTracking } = useContext21(EventTrackingContext);
38947
39094
  const { allReportsById } = useAllReports();
38948
- const [loading, setLoading] = useState24(false);
39095
+ const [loading, setLoading] = useState25(false);
38949
39096
  const report = useMemo17(() => {
38950
39097
  return props.reportId ? allReportsById[props.reportId] : null;
38951
39098
  }, [allReportsById[props.reportId ?? ""]]);
@@ -38998,7 +39145,7 @@ var Table = ({
38998
39145
  setLoading(false);
38999
39146
  }
39000
39147
  };
39001
- useEffect19(() => {
39148
+ useEffect20(() => {
39002
39149
  if (props.reportId === void 0 || props.reportId === "" || clientLoading) {
39003
39150
  return;
39004
39151
  }
@@ -39032,7 +39179,7 @@ var Table = ({
39032
39179
  clientLoading,
39033
39180
  !reports[props.reportId ?? ""]
39034
39181
  ]);
39035
- const [page, setPage] = useState24(0);
39182
+ const [page, setPage] = useState25(0);
39036
39183
  if ("rows" in data && "columns" in data) {
39037
39184
  return /* @__PURE__ */ jsx59(
39038
39185
  QuillTable,
@@ -39093,21 +39240,20 @@ var Table_default = Table;
39093
39240
 
39094
39241
  // src/SQLEditor.tsx
39095
39242
  import {
39096
- useState as useState30,
39243
+ useState as useState31,
39097
39244
  useContext as useContext28,
39098
- useEffect as useEffect24,
39099
- useRef as useRef18,
39245
+ useEffect as useEffect25,
39246
+ useRef as useRef19,
39100
39247
  useMemo as useMemo22,
39101
39248
  useCallback as useCallback3
39102
39249
  } from "react";
39103
- import { flushSync as flushSync2 } from "react-dom";
39104
39250
  import MonacoEditor from "@monaco-editor/react";
39105
39251
 
39106
39252
  // src/ChartBuilder.tsx
39107
39253
  import {
39108
- useEffect as useEffect22,
39109
- useRef as useRef17,
39110
- useState as useState28,
39254
+ useEffect as useEffect23,
39255
+ useRef as useRef18,
39256
+ useState as useState29,
39111
39257
  useContext as useContext26,
39112
39258
  useMemo as useMemo21
39113
39259
  } from "react";
@@ -39133,9 +39279,9 @@ import {
39133
39279
  useCallback as useCallback2,
39134
39280
  useContext as useContext23,
39135
39281
  useMemo as useMemo18,
39136
- useState as useState25,
39137
- useEffect as useEffect20,
39138
- useRef as useRef14
39282
+ useState as useState26,
39283
+ useEffect as useEffect21,
39284
+ useRef as useRef15
39139
39285
  } from "react";
39140
39286
 
39141
39287
  // src/internals/ReportBuilder/PivotList.tsx
@@ -39599,44 +39745,44 @@ var PivotModal = ({
39599
39745
  reportBuilderState
39600
39746
  }) => {
39601
39747
  const { getToken, quillFetchWithToken } = useContext23(FetchContext);
39602
- const [isLoading, setIsLoading] = useState25(false);
39603
- const [previewLoading, setPreviewLoading] = useState25(false);
39604
- const [selectedPivotType, setSelectedPivotType] = useState25("recommended");
39605
- const [errors, setErrors] = useState25([]);
39748
+ const [isLoading, setIsLoading] = useState26(false);
39749
+ const [previewLoading, setPreviewLoading] = useState26(false);
39750
+ const [selectedPivotType, setSelectedPivotType] = useState26("recommended");
39751
+ const [errors, setErrors] = useState26([]);
39606
39752
  const [client] = useContext23(ClientContext);
39607
39753
  const [schemaData] = useContext23(SchemaDataContext);
39608
39754
  const { tenants } = useContext23(TenantContext);
39609
39755
  const { eventTracking } = useContext23(EventTrackingContext);
39610
- const rowFieldRef = useRef14(null);
39611
- const colFieldRef = useRef14(null);
39612
- const [pivotCardWidth, setPivotCardWidth] = useState25(420);
39613
- const [samplePivotTable, setSamplePivotTable] = useState25(null);
39614
- const [hasNoRecommendedPivots, sethasNoRecommendedPivots] = useState25(false);
39615
- const [isFetchingPivots, setIsFetchingPivots] = useState25(false);
39616
- const [allowedColumnFields, setAllowedColumnFields] = useState25([]);
39617
- const [allowedRowFields, setAllowedRowFields] = useState25([]);
39618
- const [allowedValueFields, setAllowedValueFields] = useState25([]);
39619
- const [uniqueValues, setUniqueValues] = useState25(initialUniqueValues);
39620
- const buttonRef = useRef14(null);
39621
- const [dateRanges, setDateRanges] = useState25({});
39622
- const [pivotError, setPivotError] = useState25("");
39623
- const [limitInput, setLimitInput] = useState25(
39756
+ const rowFieldRef = useRef15(null);
39757
+ const colFieldRef = useRef15(null);
39758
+ const [pivotCardWidth, setPivotCardWidth] = useState26(420);
39759
+ const [samplePivotTable, setSamplePivotTable] = useState26(null);
39760
+ const [hasNoRecommendedPivots, sethasNoRecommendedPivots] = useState26(false);
39761
+ const [isFetchingPivots, setIsFetchingPivots] = useState26(false);
39762
+ const [allowedColumnFields, setAllowedColumnFields] = useState26([]);
39763
+ const [allowedRowFields, setAllowedRowFields] = useState26([]);
39764
+ const [allowedValueFields, setAllowedValueFields] = useState26([]);
39765
+ const [uniqueValues, setUniqueValues] = useState26(initialUniqueValues);
39766
+ const buttonRef = useRef15(null);
39767
+ const [dateRanges, setDateRanges] = useState26({});
39768
+ const [pivotError, setPivotError] = useState26("");
39769
+ const [limitInput, setLimitInput] = useState26(
39624
39770
  pivotLimit?.toString() ?? "100"
39625
39771
  );
39626
- const [sortFieldInput, setSortFieldInput] = useState25(
39772
+ const [sortFieldInput, setSortFieldInput] = useState26(
39627
39773
  pivotSort?.sortField ?? ""
39628
39774
  );
39629
- const [sortDirectionInput, setSortDirectionInput] = useState25(
39775
+ const [sortDirectionInput, setSortDirectionInput] = useState26(
39630
39776
  pivotSort?.sortDirection ?? "ASC"
39631
39777
  );
39632
- const [showLimitInput, setShowLimitInput] = useState25(!!pivotLimit);
39633
- const [showSortInput, setShowSortInput] = useState25(!!pivotSort);
39634
- const [availableHeight, setAvailableHeight] = useState25(0);
39635
- const [pivotModalTopHeight, setPivotModalTopHeight] = useState25(450);
39636
- const [popoverPosition, setPopoverPosition] = useState25(
39778
+ const [showLimitInput, setShowLimitInput] = useState26(!!pivotLimit);
39779
+ const [showSortInput, setShowSortInput] = useState26(!!pivotSort);
39780
+ const [availableHeight, setAvailableHeight] = useState26(0);
39781
+ const [pivotModalTopHeight, setPivotModalTopHeight] = useState26(450);
39782
+ const [popoverPosition, setPopoverPosition] = useState26(
39637
39783
  "bottom"
39638
39784
  );
39639
- const popoverRef = useRef14(null);
39785
+ const popoverRef = useRef15(null);
39640
39786
  const getDistinctValues = async (fetchDistinct) => {
39641
39787
  if (!client) {
39642
39788
  return {
@@ -39723,7 +39869,7 @@ var PivotModal = ({
39723
39869
  setDateRanges(dateRangeByColumn || {});
39724
39870
  }
39725
39871
  };
39726
- useEffect20(() => {
39872
+ useEffect21(() => {
39727
39873
  const calculatePivotCardSize = () => {
39728
39874
  if (rowFieldRef.current && colFieldRef.current) {
39729
39875
  const rowFieldSize = rowFieldRef.current?.getBoundingClientRect();
@@ -39744,7 +39890,7 @@ var PivotModal = ({
39744
39890
  }, 500);
39745
39891
  }
39746
39892
  }, [showUpdatePivot, isOpen]);
39747
- useEffect20(() => {
39893
+ useEffect21(() => {
39748
39894
  const fetchPivotData = async () => {
39749
39895
  if (pivotRowField && data && columns && pivotAggregations?.every((p) => p?.valueField && p?.aggregationType)) {
39750
39896
  const pivot = {
@@ -39890,7 +40036,7 @@ var PivotModal = ({
39890
40036
  };
39891
40037
  fetchPivotData();
39892
40038
  }, [initialSelectedPivotTable]);
39893
- useEffect20(() => {
40039
+ useEffect21(() => {
39894
40040
  if (pivotRowField && data && columns) {
39895
40041
  getDistinctValues();
39896
40042
  getAllDateRangesByColumn();
@@ -39898,7 +40044,7 @@ var PivotModal = ({
39898
40044
  getDistinctValues();
39899
40045
  }
39900
40046
  }, [initialSelectedPivotTable, columns, data, pivotRowField]);
39901
- useEffect20(() => {
40047
+ useEffect21(() => {
39902
40048
  setAllowedFields(initialUniqueValues || {});
39903
40049
  setUniqueValues(initialUniqueValues);
39904
40050
  }, [initialUniqueValues, columns]);
@@ -39921,8 +40067,8 @@ var PivotModal = ({
39921
40067
  return map;
39922
40068
  }, {});
39923
40069
  }, [columns]);
39924
- const [selectedPivotTable, setSelectedPivotTable] = useState25(null);
39925
- useEffect20(() => {
40070
+ const [selectedPivotTable, setSelectedPivotTable] = useState26(null);
40071
+ useEffect21(() => {
39926
40072
  const fetchPivotTables = async () => {
39927
40073
  if (selectedPivotIndex === -1) {
39928
40074
  return null;
@@ -39974,8 +40120,8 @@ var PivotModal = ({
39974
40120
  };
39975
40121
  fetchPivotTables();
39976
40122
  }, [selectedPivotIndex, data, dateRange, createdPivots]);
39977
- const previousUniqueValuesRef = useRef14();
39978
- useEffect20(() => {
40123
+ const previousUniqueValuesRef = useRef15();
40124
+ useEffect21(() => {
39979
40125
  if (!uniqueValuesIsLoading && !equal5(uniqueValues, previousUniqueValuesRef.current)) {
39980
40126
  previousUniqueValuesRef.current = uniqueValues;
39981
40127
  setRecommendedPivotTables([]);
@@ -40450,11 +40596,11 @@ var PivotModal = ({
40450
40596
  }
40451
40597
  }, 500);
40452
40598
  };
40453
- const [recommendedPivotTables, setRecommendedPivotTables] = useState25(
40599
+ const [recommendedPivotTables, setRecommendedPivotTables] = useState26(
40454
40600
  []
40455
40601
  );
40456
- const [createdPivotTables, setCreatedPivotTables] = useState25([]);
40457
- useEffect20(() => {
40602
+ const [createdPivotTables, setCreatedPivotTables] = useState26([]);
40603
+ useEffect21(() => {
40458
40604
  const fetchPivotTables = async () => {
40459
40605
  const pts = await Promise.all(
40460
40606
  createdPivots.map(async (p) => {
@@ -40527,7 +40673,7 @@ var PivotModal = ({
40527
40673
  setPopoverPosition("bottom");
40528
40674
  }
40529
40675
  };
40530
- useEffect20(() => {
40676
+ useEffect21(() => {
40531
40677
  handleResize();
40532
40678
  window.addEventListener("resize", handleResize);
40533
40679
  const parentElement = parentRef?.current;
@@ -41353,12 +41499,12 @@ var validateReport = (formData, dashboardData, defaultDateFilter, allTables) =>
41353
41499
 
41354
41500
  // src/components/Chart/InternalChart.tsx
41355
41501
  import {
41356
- useState as useState26,
41357
- useEffect as useEffect21,
41502
+ useState as useState27,
41503
+ useEffect as useEffect22,
41358
41504
  useContext as useContext24,
41359
41505
  useMemo as useMemo19,
41360
- useRef as useRef15,
41361
- useLayoutEffect
41506
+ useRef as useRef16,
41507
+ useLayoutEffect as useLayoutEffect2
41362
41508
  } from "react";
41363
41509
  import { differenceInHours as differenceInHours2 } from "date-fns";
41364
41510
  init_Filter();
@@ -41503,8 +41649,8 @@ function InternalChart({
41503
41649
  reportDateFilter.defaultPresetRanges ?? []
41504
41650
  ) : defaultOptionsV2;
41505
41651
  }, [reportDateFilter]);
41506
- const [filterValues, setFilterValues] = useState26({});
41507
- useEffect21(() => {
41652
+ const [filterValues, setFilterValues] = useState27({});
41653
+ useEffect22(() => {
41508
41654
  if (reportDateFilter) {
41509
41655
  const customDateFilter = filters?.find(
41510
41656
  (f) => f.filterType === "date" /* Date */
@@ -41612,9 +41758,9 @@ function InternalChart({
41612
41758
  }));
41613
41759
  onDashboardFilterChange(filter.label, filterValue);
41614
41760
  };
41615
- const [filtersExpanded, setFiltersExpanded] = useState26(false);
41616
- const filtersContainerRef = useRef15(null);
41617
- const [visibleFilters, setVisibleFilters] = useState26([]);
41761
+ const [filtersExpanded, setFiltersExpanded] = useState27(false);
41762
+ const filtersContainerRef = useRef16(null);
41763
+ const [visibleFilters, setVisibleFilters] = useState27([]);
41618
41764
  const filtersOverflowing = useMemo19(() => {
41619
41765
  return visibleFilters.some((visible) => visible);
41620
41766
  }, [visibleFilters]);
@@ -41630,7 +41776,7 @@ function InternalChart({
41630
41776
  });
41631
41777
  setVisibleFilters(newVisibleItems);
41632
41778
  };
41633
- useLayoutEffect(() => {
41779
+ useLayoutEffect2(() => {
41634
41780
  requestAnimationFrame(() => measureItems());
41635
41781
  const handleResize = () => {
41636
41782
  measureItems();
@@ -41912,8 +42058,8 @@ init_dates();
41912
42058
  import React13, {
41913
42059
  useContext as useContext25,
41914
42060
  useMemo as useMemo20,
41915
- useRef as useRef16,
41916
- useState as useState27
42061
+ useRef as useRef17,
42062
+ useState as useState28
41917
42063
  } from "react";
41918
42064
  import { Fragment as Fragment12, jsx as jsx64, jsxs as jsxs46 } from "react/jsx-runtime";
41919
42065
  function QuillMultiSelectSectionList({
@@ -41931,10 +42077,10 @@ function QuillMultiSelectSectionList({
41931
42077
  owner
41932
42078
  }) {
41933
42079
  const [theme] = useContext25(ThemeContext);
41934
- const [showModal, setShowModal] = useState27(false);
41935
- const modalRef = useRef16(null);
41936
- const buttonRef = useRef16(null);
41937
- const debounceTimeoutId = useRef16(null);
42080
+ const [showModal, setShowModal] = useState28(false);
42081
+ const modalRef = useRef17(null);
42082
+ const buttonRef = useRef17(null);
42083
+ const debounceTimeoutId = useRef17(null);
41938
42084
  const [searchQuery, setSearchQuery] = React13.useState("");
41939
42085
  useOnClickOutside_default(
41940
42086
  modalRef,
@@ -42716,18 +42862,18 @@ function createReportFromForm(formData, report, eventTracking, selectedPivotTabl
42716
42862
  return newReport;
42717
42863
  }
42718
42864
  function ChartBuilderWithModal(props) {
42719
- const parentRef = useRef17(null);
42720
- const [modalWidth, setModalWidth] = useState28(200);
42721
- const [modalHeight, setModalHeight] = useState28(200);
42865
+ const parentRef = useRef18(null);
42866
+ const [modalWidth, setModalWidth] = useState29(200);
42867
+ const [modalHeight, setModalHeight] = useState29(200);
42722
42868
  const { isOpen, setIsOpen, title, isHorizontalView } = props;
42723
42869
  const Modal = props.ModalComponent ?? MemoizedModal;
42724
42870
  const { dashboardReports: dashboard } = useDashboardReports(
42725
42871
  props.destinationDashboard
42726
42872
  );
42727
- const [filtersEnabledState, setFiltersEnabledState] = useState28(
42873
+ const [filtersEnabledState, setFiltersEnabledState] = useState29(
42728
42874
  !!props.reportId
42729
42875
  );
42730
- useEffect22(() => {
42876
+ useEffect23(() => {
42731
42877
  function handleResize() {
42732
42878
  const screenSize = window.innerWidth;
42733
42879
  if (screenSize >= 1200) {
@@ -42843,20 +42989,22 @@ function ChartBuilder({
42843
42989
  const { dashboardConfig } = useContext26(DashboardConfigContext);
42844
42990
  const { tenants, flags } = useContext26(TenantContext);
42845
42991
  const report = useMemo21(() => {
42846
- return reportId && !tempReport ? allReportsById[reportId] : tempReport;
42992
+ const resolvedReport = reportId && !tempReport ? allReportsById[reportId] : tempReport;
42993
+ return resolvedReport;
42847
42994
  }, [reportId, tempReport, allReportsById]);
42848
- const [windowWidth, setWindowWidth] = useState28(1200);
42849
- const [rows, setRows] = useState28(report?.rows ?? []);
42850
- const [itemQuery, setItemQuery] = useState28(report?.itemQuery);
42851
- const [rowCount, setRowCount] = useState28(report?.rowCount ?? 0);
42852
- const [maxPage, setMaxPage] = useState28(0);
42853
- const [isLoading, setIsLoading] = useState28(false);
42854
- const [rowCountIsLoading, setRowCountIsLoading] = useState28(false);
42855
- const [isSubmitting, setIsSubmitting] = useState28(false);
42856
- const [pivotCardWidth, setPivotCardWidth] = useState28(665);
42857
- const [formWidth, setFormWidth] = useState28(665);
42858
- const inputRef = useRef17(null);
42859
- const selectRef = useRef17(null);
42995
+ const [windowWidth, setWindowWidth] = useState29(1200);
42996
+ const [rows, setRows] = useState29(report?.rows ?? []);
42997
+ const [itemQuery, setItemQuery] = useState29(report?.itemQuery);
42998
+ const [rowCount, setRowCount] = useState29(report?.rowCount ?? 0);
42999
+ const [maxPage, setMaxPage] = useState29(0);
43000
+ const [isLoading, setIsLoading] = useState29(false);
43001
+ const [rowCountIsLoading, setRowCountIsLoading] = useState29(false);
43002
+ const [isSubmitting, setIsSubmitting] = useState29(false);
43003
+ const MIN_FORM_WIDTH = 700;
43004
+ const [pivotCardWidth, setPivotCardWidth] = useState29(MIN_FORM_WIDTH);
43005
+ const [formWidth, setFormWidth] = useState29(MIN_FORM_WIDTH);
43006
+ const inputRef = useRef18(null);
43007
+ const selectRef = useRef18(null);
42860
43008
  const processColumns = (columns2) => {
42861
43009
  if (schemaData.schemaWithCustomFields) {
42862
43010
  const newProcessedColumns = columns2?.map((col) => {
@@ -42886,12 +43034,12 @@ function ChartBuilder({
42886
43034
  }
42887
43035
  return columns2;
42888
43036
  };
42889
- const [processedColumns, setProcessedColumns] = useState28(
43037
+ const [processedColumns, setProcessedColumns] = useState29(
42890
43038
  processColumns(report?.columnInternal ?? [])
42891
43039
  );
42892
- const [currentPage, setCurrentPage] = useState28(0);
42893
- const parentRef = useRef17(null);
42894
- const deleteRef = useRef17(null);
43040
+ const [currentPage, setCurrentPage] = useState29(0);
43041
+ const parentRef = useRef18(null);
43042
+ const deleteRef = useRef18(null);
42895
43043
  const modalPadding = 20;
42896
43044
  const deleteButtonMargin = -12;
42897
43045
  const { dashboardFilters } = useContext26(DashboardFiltersContext);
@@ -42913,7 +43061,7 @@ function ChartBuilder({
42913
43061
  setFilterIssues([]);
42914
43062
  }
42915
43063
  };
42916
- useEffect22(() => {
43064
+ useEffect23(() => {
42917
43065
  const handleResize = () => {
42918
43066
  setWindowWidth(window.innerWidth);
42919
43067
  if (inputRef.current && selectRef.current) {
@@ -42924,10 +43072,10 @@ function ChartBuilder({
42924
43072
  const spaceBetween = selectSize.left - inputSize.right;
42925
43073
  const gap = showDash ? (spaceBetween - selectWidth) / 2 : spaceBetween;
42926
43074
  const width = inputSize.width + 2 * gap + 2 * selectWidth;
42927
- setPivotCardWidth(width);
43075
+ setPivotCardWidth(Math.max(width, MIN_FORM_WIDTH));
42928
43076
  const deleteSize = deleteRef.current?.getBoundingClientRect();
42929
43077
  const deleteWidth = deleteSize?.width ?? 0;
42930
- setFormWidth(width + deleteWidth);
43078
+ setFormWidth(Math.max(width + deleteWidth, MIN_FORM_WIDTH));
42931
43079
  }
42932
43080
  };
42933
43081
  handleResize();
@@ -42936,7 +43084,7 @@ function ChartBuilder({
42936
43084
  window.removeEventListener("resize", handleResize);
42937
43085
  };
42938
43086
  }, [isOpen]);
42939
- const [dashboardOptions, setDashboardOptions] = useState28([]);
43087
+ const [dashboardOptions, setDashboardOptions] = useState29([]);
42940
43088
  const {
42941
43089
  reportFilters,
42942
43090
  loadFiltersForReport,
@@ -42944,9 +43092,9 @@ function ChartBuilder({
42944
43092
  abortLoadingFilters
42945
43093
  } = useContext26(ReportFiltersContext);
42946
43094
  const { reportsDispatch } = useContext26(ReportsContext);
42947
- const initialFilters = useRef17(reportFilters[report?.id ?? TEMP_REPORT_ID]);
42948
- const [reportFiltersLoaded, setReportFiltersLoaded] = useState28(!filtersEnabled);
42949
- useEffect22(() => {
43095
+ const initialFilters = useRef18(reportFilters[report?.id ?? TEMP_REPORT_ID]);
43096
+ const [reportFiltersLoaded, setReportFiltersLoaded] = useState29(!filtersEnabled);
43097
+ useEffect23(() => {
42950
43098
  if (!reportFilters[report?.id ?? TEMP_REPORT_ID]) {
42951
43099
  loadFiltersForReport(
42952
43100
  report?.id ?? TEMP_REPORT_ID,
@@ -42979,20 +43127,20 @@ function ChartBuilder({
42979
43127
  (f) => f.filter
42980
43128
  );
42981
43129
  }, [reportFilters, report?.id]);
42982
- const [showFilterModal, setShowFilterModal] = useState28(false);
42983
- const [filterIssues, setFilterIssues] = useState28([]);
42984
- const [showPivotPopover, setShowPivotPopover] = useState28(false);
42985
- const [isEdittingPivot, setIsEdittingPivot] = useState28(false);
42986
- const [selectedPivotIndex, setSelectedPivotIndex] = useState28(-1);
42987
- const [tableName, setTableName] = useState28(void 0);
42988
- const [includeCustomFields, setIncludeCustomFields] = useState28(
43130
+ const [showFilterModal, setShowFilterModal] = useState29(false);
43131
+ const [filterIssues, setFilterIssues] = useState29([]);
43132
+ const [showPivotPopover, setShowPivotPopover] = useState29(false);
43133
+ const [isEdittingPivot, setIsEdittingPivot] = useState29(false);
43134
+ const [selectedPivotIndex, setSelectedPivotIndex] = useState29(-1);
43135
+ const [tableName, setTableName] = useState29(void 0);
43136
+ const [includeCustomFields, setIncludeCustomFields] = useState29(
42989
43137
  report ? !!report.includeCustomFields : !!client?.featureFlags?.customFieldsEnabled
42990
43138
  );
42991
43139
  const selectedTable = schemaData.schema?.find(
42992
43140
  (t) => t.displayName === tableName
42993
43141
  );
42994
- const [pivotPopUpTitle, setPivotPopUpTitle] = useState28("Add pivot");
42995
- const [pivotError, setPivotError] = useState28(void 0);
43142
+ const [pivotPopUpTitle, setPivotPopUpTitle] = useState29("Add pivot");
43143
+ const [pivotError, setPivotError] = useState29(void 0);
42996
43144
  const pivotData = report?.pivotRows && report?.pivotColumns ? {
42997
43145
  rows: report.pivotRows,
42998
43146
  columns: report.pivotColumns,
@@ -43003,19 +43151,19 @@ function ChartBuilder({
43003
43151
  const columns = report?.columnInternal ?? [];
43004
43152
  const destinationDashboardName = report?.dashboardName || destinationDashboard;
43005
43153
  const query = report?.queryString;
43006
- const [loadingFormData, setLoadingFormData] = useState28(false);
43007
- const [triggeredEditChart, setTriggeredEditChart] = useState28(false);
43008
- const [createdPivots, setCreatedPivots] = useState28(
43154
+ const [loadingFormData, setLoadingFormData] = useState29(false);
43155
+ const [triggeredEditChart, setTriggeredEditChart] = useState29(false);
43156
+ const [createdPivots, setCreatedPivots] = useState29(
43009
43157
  report?.pivot ? [report.pivot] : cp
43010
43158
  );
43011
- const [recommendedPivots, setRecommendedPivots] = useState28(rp);
43012
- const [pivotRowField, setPivotRowField] = useState28(
43159
+ const [recommendedPivots, setRecommendedPivots] = useState29(rp);
43160
+ const [pivotRowField, setPivotRowField] = useState29(
43013
43161
  report?.pivot?.rowField
43014
43162
  );
43015
- const [pivotColumnField, setPivotColumnField] = useState28(
43163
+ const [pivotColumnField, setPivotColumnField] = useState29(
43016
43164
  report?.pivot?.columnField
43017
43165
  );
43018
- const [pivotAggregations, setPivotAggregations] = useState28(
43166
+ const [pivotAggregations, setPivotAggregations] = useState29(
43019
43167
  report?.pivot?.aggregations ?? [
43020
43168
  {
43021
43169
  valueField: report?.pivot?.valueField,
@@ -43024,10 +43172,10 @@ function ChartBuilder({
43024
43172
  }
43025
43173
  ]
43026
43174
  );
43027
- const [pivotLimit, setPivotLimit] = useState28(
43175
+ const [pivotLimit, setPivotLimit] = useState29(
43028
43176
  report?.pivot?.rowLimit
43029
43177
  );
43030
- const [pivotSort, setPivotSort] = useState28(
43178
+ const [pivotSort, setPivotSort] = useState29(
43031
43179
  report?.pivot?.sort && report?.pivot?.sortDirection && report?.pivot?.sortField ? {
43032
43180
  sortField: report.pivot.sortField,
43033
43181
  sortDirection: report.pivot.sortDirection
@@ -43040,16 +43188,17 @@ function ChartBuilder({
43040
43188
  rowsPerRequest: report?.chartType === "table" ? 50 : 500
43041
43189
  }
43042
43190
  };
43043
- const [currentProcessing, setCurrentProcessing] = useState28(baseProcessing);
43044
- const [customTenantAccess, setCustomTenantAccess] = useState28(
43191
+ const [currentProcessing, setCurrentProcessing] = useState29(baseProcessing);
43192
+ const [customTenantAccess, setCustomTenantAccess] = useState29(
43045
43193
  report?.flags === null ? false : !!Object.values(report?.flags ?? {}).length
43046
43194
  );
43047
- const [dateFieldOptions, setDateFieldOptions] = useState28([]);
43048
- const [allTables, setAllTables] = useState28([]);
43049
- const [customFieldTableRef, setCustomFieldTableRef] = useState28(false);
43050
- const [referencedColumns, setReferencedColumns] = useState28({});
43051
- const [referencedColumnsWithoutStar, setReferencedColumnsWithoutStar] = useState28({});
43052
- const [filterMap, setFilterMap] = useState28(report?.filterMap ?? {});
43195
+ const [dateFieldOptions, setDateFieldOptions] = useState29([]);
43196
+ const [allTables, setAllTables] = useState29([]);
43197
+ const [customFieldTableRef, setCustomFieldTableRef] = useState29(false);
43198
+ const [referencedColumns, setReferencedColumns] = useState29({});
43199
+ const [referencedColumnsWithoutStar, setReferencedColumnsWithoutStar] = useState29({});
43200
+ const [referencedTablesLoaded, setReferencedTablesLoaded] = useState29(false);
43201
+ const [filterMap, setFilterMap] = useState29(report?.filterMap ?? {});
43053
43202
  const canonicalFilterMap = useMemo21(() => {
43054
43203
  return Object.fromEntries(
43055
43204
  Object.entries(filterMap).filter(
@@ -43060,7 +43209,7 @@ function ChartBuilder({
43060
43209
  const validFilter = useMemo21(() => {
43061
43210
  return specificDashboardFilters.reduce(
43062
43211
  (acc, filter) => {
43063
- if (filter.filterType === "date_range" || filter.filterType === "tenant") {
43212
+ if (filter.filterType === "date_range" || filter.filterType === "tenant" || !referencedTablesLoaded) {
43064
43213
  acc[filter.label] = true;
43065
43214
  return acc;
43066
43215
  }
@@ -43075,8 +43224,8 @@ function ChartBuilder({
43075
43224
  },
43076
43225
  {}
43077
43226
  );
43078
- }, [specificDashboardFilters, filterMap, allTables]);
43079
- const [formFlags, setFormFlags] = useState28(
43227
+ }, [specificDashboardFilters, filterMap, allTables, referencedTablesLoaded]);
43228
+ const [formFlags, setFormFlags] = useState29(
43080
43229
  report?.flags ? Object.fromEntries(
43081
43230
  Object.entries(report.flags).map(([key, value]) => {
43082
43231
  if (value === ALL_TENANTS) {
@@ -43093,7 +43242,7 @@ function ChartBuilder({
43093
43242
  })
43094
43243
  ) : void 0
43095
43244
  );
43096
- const [defaultDateField, setDefaultDateField] = useState28({
43245
+ const [defaultDateField, setDefaultDateField] = useState29({
43097
43246
  table: dateFieldOptions[0]?.name || "",
43098
43247
  field: dateFieldOptions[0]?.columns[0]?.field || ""
43099
43248
  });
@@ -43192,23 +43341,40 @@ function ChartBuilder({
43192
43341
  return result;
43193
43342
  };
43194
43343
  const getReferencedTables = async (client2, dbTables, sqlQuery, reportBuilderState2, skipStar) => {
43195
- const { data: resp } = await quillFetchWithToken({
43196
- client: client2,
43197
- task: "astify",
43198
- metadata: reportBuilderState2 ? {
43199
- reportBuilderState: reportBuilderState2,
43200
- clientId: client2.clientId,
43201
- useNewNodeSql: true
43202
- } : {
43203
- query: sqlQuery,
43204
- clientId: client2.clientId,
43205
- useNewNodeSql: true
43344
+ const metadata = reportBuilderState2 ? {
43345
+ reportBuilderState: reportBuilderState2,
43346
+ clientId: client2.clientId,
43347
+ useNewNodeSql: true
43348
+ } : {
43349
+ query: sqlQuery,
43350
+ clientId: client2.clientId,
43351
+ useNewNodeSql: true
43352
+ };
43353
+ try {
43354
+ const { data: resp } = await quillFetchWithToken({
43355
+ client: client2,
43356
+ task: "astify",
43357
+ metadata
43358
+ });
43359
+ if (resp.success === false) {
43360
+ return getTablesHelper(getSelectFromAST({}), dbTables, skipStar);
43206
43361
  }
43207
- });
43208
- if (resp.success === false) {
43209
- return getTablesHelper(getSelectFromAST({}), dbTables, skipStar);
43362
+ return getTablesHelper(getSelectFromAST(resp.ast), dbTables, skipStar);
43363
+ } catch (error) {
43364
+ console.error(
43365
+ "[ChartBuilder#getReferencedTables] Failed to fetch referenced tables",
43366
+ {
43367
+ error,
43368
+ hasReportBuilderState: !!reportBuilderState2,
43369
+ hasSqlQuery: !!sqlQuery,
43370
+ skipStar: !!skipStar
43371
+ }
43372
+ );
43373
+ return {
43374
+ referencedTablesAndColumns: [],
43375
+ dateFields: []
43376
+ };
43210
43377
  }
43211
- return getTablesHelper(getSelectFromAST(resp.ast), dbTables, skipStar);
43212
43378
  };
43213
43379
  const getCurrentSection = () => {
43214
43380
  let id2 = report?.id ?? "";
@@ -43255,7 +43421,7 @@ function ChartBuilder({
43255
43421
  }
43256
43422
  return chartBuilderData;
43257
43423
  };
43258
- const [formData, setFormData] = useState28(
43424
+ const [formData, setFormData] = useState29(
43259
43425
  formFormDataFromReport(report, destinationSection ?? getCurrentSection())
43260
43426
  );
43261
43427
  const reportCustomFields = useMemo21(() => {
@@ -43309,7 +43475,7 @@ function ChartBuilder({
43309
43475
  const columnsObservedInRows = rows[0] ? Object.keys(rows[0]) : [];
43310
43476
  return columns.filter((col) => !columnsObservedInRows.includes(col.field));
43311
43477
  }, [rows]);
43312
- const [chartTypes, setChartTypes] = useState28(
43478
+ const [chartTypes, setChartTypes] = useState29(
43313
43479
  (() => {
43314
43480
  const data = formFormDataFromReport(
43315
43481
  report,
@@ -43378,12 +43544,12 @@ function ChartBuilder({
43378
43544
  customFieldsInTabularColumns,
43379
43545
  chartBuilderFormDataContainsCustomFields
43380
43546
  ]);
43381
- useEffect22(() => {
43547
+ useEffect23(() => {
43382
43548
  if (!loadingFormData && triggeredEditChart) {
43383
43549
  editChart();
43384
43550
  }
43385
43551
  }, [loadingFormData]);
43386
- useEffect22(() => {
43552
+ useEffect23(() => {
43387
43553
  async function getFormData() {
43388
43554
  if (!client) {
43389
43555
  return;
@@ -43424,6 +43590,7 @@ function ChartBuilder({
43424
43590
  setLoadingFormData(false);
43425
43591
  return;
43426
43592
  }
43593
+ setReferencedTablesLoaded(false);
43427
43594
  const result = await getReferencedTables(
43428
43595
  client,
43429
43596
  curSchemaData,
@@ -43501,12 +43668,13 @@ function ChartBuilder({
43501
43668
  curFormData.dateField ?? dateField,
43502
43669
  tableNames
43503
43670
  );
43671
+ setReferencedTablesLoaded(true);
43504
43672
  setLoadingFormData(false);
43505
43673
  }
43506
43674
  getFormData();
43507
43675
  }, []);
43508
- const ranMountQuery = useRef17(false);
43509
- useEffect22(() => {
43676
+ const ranMountQuery = useRef18(false);
43677
+ useEffect23(() => {
43510
43678
  if (runQueryOnMount && reportFiltersLoaded && filtersEnabled && !ranMountQuery.current) {
43511
43679
  ranMountQuery.current = true;
43512
43680
  handleRunQuery(baseProcessing, currentDashboardFilters);
@@ -43531,7 +43699,7 @@ function ChartBuilder({
43531
43699
  {}
43532
43700
  ) ?? {};
43533
43701
  }, [client?.allTenantTypes]);
43534
- const [selectedPivotTable, setSelectedPivotTable] = useState28(pivotData);
43702
+ const [selectedPivotTable, setSelectedPivotTable] = useState29(pivotData);
43535
43703
  const pivotCardTable = useMemo21(() => {
43536
43704
  return {
43537
43705
  pivot: formData.pivot,
@@ -43716,8 +43884,8 @@ function ChartBuilder({
43716
43884
  handleRunQuery(baseProcessing, updatedFilters);
43717
43885
  });
43718
43886
  };
43719
- const filtersEnabledRef = useRef17(filtersEnabled);
43720
- useEffect22(() => {
43887
+ const filtersEnabledRef = useRef18(filtersEnabled);
43888
+ useEffect23(() => {
43721
43889
  if (filtersEnabledRef.current !== filtersEnabled) {
43722
43890
  filtersEnabledRef.current = filtersEnabled;
43723
43891
  setCurrentPage(0);
@@ -44198,7 +44366,7 @@ function ChartBuilder({
44198
44366
  return;
44199
44367
  }
44200
44368
  let dashboardItemId = reportId ? reportId : void 0;
44201
- if (report && !isAdmin && formData.template) {
44369
+ if (report && !isAdmin && formData.template && !isEditingMode) {
44202
44370
  dashboardItemId = void 0;
44203
44371
  }
44204
44372
  const newReport = {
@@ -45460,16 +45628,22 @@ function ChartBuilder({
45460
45628
  )
45461
45629
  }
45462
45630
  ),
45463
- (!formData.dateField?.table || !formData.dateField?.field) && /* @__PURE__ */ jsx65("div", { style: { marginBottom: 8, marginTop: "auto" }, children: /* @__PURE__ */ jsx65(
45464
- ExclamationFilledIcon_default,
45631
+ referencedTablesLoaded && (!formData.dateField?.table || !formData.dateField?.field) && /* @__PURE__ */ jsx65(
45632
+ "div",
45465
45633
  {
45466
- height: 28,
45467
- width: 28,
45468
- style: {
45469
- color: "#dc143c"
45470
- }
45634
+ style: { marginBottom: 8, marginTop: "auto" },
45635
+ children: /* @__PURE__ */ jsx65(
45636
+ ExclamationFilledIcon_default,
45637
+ {
45638
+ height: 28,
45639
+ width: 28,
45640
+ style: {
45641
+ color: "#dc143c"
45642
+ }
45643
+ }
45644
+ )
45471
45645
  }
45472
- ) })
45646
+ )
45473
45647
  ] }),
45474
45648
  specificDashboardFilters.length > 0 && /* @__PURE__ */ jsx65(
45475
45649
  "div",
@@ -45540,10 +45714,13 @@ function ChartBuilder({
45540
45714
  hideEmptyOption: true
45541
45715
  }
45542
45716
  ),
45543
- !validFilter[filter.label] && /* @__PURE__ */ jsx65(
45717
+ referencedTablesLoaded && !validFilter[filter.label] && /* @__PURE__ */ jsx65(
45544
45718
  "div",
45545
45719
  {
45546
- style: { marginBottom: 8, marginTop: "auto" },
45720
+ style: {
45721
+ marginBottom: 8,
45722
+ marginTop: "auto"
45723
+ },
45547
45724
  children: /* @__PURE__ */ jsx65(
45548
45725
  ExclamationFilledIcon_default,
45549
45726
  {
@@ -45832,21 +46009,6 @@ function DashboardFilterModal({
45832
46009
  );
45833
46010
  }
45834
46011
 
45835
- // src/utils/width.ts
45836
- var updateFirstChildWidth = (containerRef, setState, options = { gap: 0 }) => {
45837
- if (containerRef.current) {
45838
- const element = containerRef.current;
45839
- const totalWidth = element.getBoundingClientRect().width;
45840
- const gapWidth = options.gap * (element.childElementCount - 1);
45841
- let siblingsWidth = 0;
45842
- const children = Array.from(containerRef.current.children);
45843
- for (let i = 1; i < children.length; i++) {
45844
- siblingsWidth += children[i].getBoundingClientRect().width;
45845
- }
45846
- setState(totalWidth - siblingsWidth - gapWidth);
45847
- }
45848
- };
45849
-
45850
46012
  // src/SQLEditor.tsx
45851
46013
  init_tableProcessing();
45852
46014
  init_queryConstructor();
@@ -46190,7 +46352,7 @@ init_astProcessing();
46190
46352
  init_constants();
46191
46353
 
46192
46354
  // src/hooks/useLongLoading.tsx
46193
- import { useContext as useContext27, useEffect as useEffect23, useState as useState29 } from "react";
46355
+ import { useContext as useContext27, useEffect as useEffect24, useState as useState30 } from "react";
46194
46356
  function useLongLoading(isLoading, meta) {
46195
46357
  const {
46196
46358
  origin,
@@ -46198,10 +46360,10 @@ function useLongLoading(isLoading, meta) {
46198
46360
  abnormalLoadTime = 15e3,
46199
46361
  loadDescription
46200
46362
  } = meta;
46201
- const [isLongLoading, setIsLongLoading] = useState29(false);
46202
- const [isAbnormalLoading, setIsAbnormalLoading] = useState29(false);
46363
+ const [isLongLoading, setIsLongLoading] = useState30(false);
46364
+ const [isAbnormalLoading, setIsAbnormalLoading] = useState30(false);
46203
46365
  const { eventTracking } = useContext27(EventTrackingContext);
46204
- useEffect23(() => {
46366
+ useEffect24(() => {
46205
46367
  let longTimer = null;
46206
46368
  let abnormalTimer = null;
46207
46369
  if (isLoading) {
@@ -46363,7 +46525,7 @@ function SQLEditor({
46363
46525
  onDiscardChanges,
46364
46526
  onSaveChanges,
46365
46527
  onCloseChartBuilder,
46366
- isChartBuilderEnabled = false,
46528
+ isChartBuilderEnabled = true,
46367
46529
  isAdminEnabled = false,
46368
46530
  chartBuilderOptions,
46369
46531
  chartBuilderTitle,
@@ -46382,7 +46544,15 @@ function SQLEditor({
46382
46544
  onClickChartElement,
46383
46545
  onRequestAddVirtualTable
46384
46546
  }) {
46385
- const [sqlPrompt, setSqlPrompt] = useState30("");
46547
+ const computedButtonLabel = addToDashboardButtonLabel === "Add to dashboard" ? reportId || report?.id ? "Save changes" : "Add to dashboard" : addToDashboardButtonLabel;
46548
+ const [sqlPrompt, setSqlPrompt] = useState31("");
46549
+ const sqlPromptFormRef = useRef19(null);
46550
+ const sqlPromptInputWidth = useResponsiveFirstChildWidth_default(sqlPromptFormRef, {
46551
+ gap: 12,
46552
+ initialWidth: 320,
46553
+ minWidth: 160
46554
+ });
46555
+ const normalizedSqlPromptWidth = sqlPromptInputWidth > 0 ? sqlPromptInputWidth : 160;
46386
46556
  const [client] = useContext28(ClientContext);
46387
46557
  const [theme] = useContext28(ThemeContext);
46388
46558
  const { tenants, flags } = useContext28(TenantContext);
@@ -46398,9 +46568,9 @@ function SQLEditor({
46398
46568
  const destinationDashboardConfig = useMemo22(() => {
46399
46569
  return dashboards?.find((d) => d.name === destinationDashboard);
46400
46570
  }, [dashboards, destinationDashboard]);
46401
- const [query, setQuery] = useState30(defaultQuery);
46402
- const [rows, setRows] = useState30([]);
46403
- const [columns, setColumns] = useState30([]);
46571
+ const [query, setQuery] = useState31(defaultQuery);
46572
+ const [rows, setRows] = useState31([]);
46573
+ const [columns, setColumns] = useState31([]);
46404
46574
  const [schemaData] = useContext28(SchemaDataContext);
46405
46575
  const { dashboardFilters } = useContext28(DashboardFiltersContext);
46406
46576
  const specificDashboardFilters = useMemo22(() => {
@@ -46408,37 +46578,32 @@ function SQLEditor({
46408
46578
  dashboardFilters[report?.dashboardName ?? destinationDashboard ?? ""] ?? {}
46409
46579
  ).map((f) => f.filter);
46410
46580
  }, [dashboardFilters, destinationDashboard]);
46411
- const [errorMessage, setErrorMessage] = useState30("");
46412
- const [sqlResponseLoading, setSqlResponseLoading] = useState30(false);
46581
+ const [errorMessage, setErrorMessage] = useState31("");
46582
+ const [sqlResponseLoading, setSqlResponseLoading] = useState31(false);
46413
46583
  useLongLoading(sqlResponseLoading, {
46414
46584
  origin: "SQLEditor",
46415
46585
  loadDescription: "Loading SQL response"
46416
46586
  });
46417
- const [sqlQueryLoading, setSqlQueryLoading] = useState30(false);
46587
+ const [sqlQueryLoading, setSqlQueryLoading] = useState31(false);
46418
46588
  useLongLoading(sqlQueryLoading, {
46419
46589
  origin: "SQLEditor",
46420
46590
  loadDescription: "Loading SQL query"
46421
46591
  });
46422
- const [isChartBuilderOpen, setIsChartBuilderOpen] = useState30(false);
46423
- const [displayTable, setDisplayTable] = useState30(false);
46424
- const [formattedRows, setFormattedRows] = useState30([]);
46425
- const formRef = useRef18(null);
46426
- const sidebarRef = useRef18(null);
46427
- const [searchBarWidth, setSearchBarWidth] = useState30(200);
46428
- const [showSearchBar, setShowSearchBar] = useState30(false);
46429
- const [filterBarWidth, setFilterBarWidth] = useState30(200);
46430
- const [rowCount, setRowCount] = useState30(void 0);
46431
- const [rowCountIsLoading, setRowCountIsLoading] = useState30(false);
46432
- const [maxPage, setMaxPage] = useState30(1);
46433
- const [tableSearchQuery, setTableSearchQuery] = useState30("");
46434
- const [lastSuccessfulQuery, setLastSuccessfulQuery] = useState30("");
46435
- const [isSaveQueryModalOpen, setIsSaveQueryModalOpen] = useState30(false);
46436
- const [tempReport, setTempReport] = useState30({
46592
+ const [isChartBuilderOpen, setIsChartBuilderOpen] = useState31(false);
46593
+ const [displayTable, setDisplayTable] = useState31(false);
46594
+ const [formattedRows, setFormattedRows] = useState31([]);
46595
+ const [rowCount, setRowCount] = useState31(void 0);
46596
+ const [rowCountIsLoading, setRowCountIsLoading] = useState31(false);
46597
+ const [maxPage, setMaxPage] = useState31(1);
46598
+ const [tableSearchQuery, setTableSearchQuery] = useState31("");
46599
+ const [lastSuccessfulQuery, setLastSuccessfulQuery] = useState31("");
46600
+ const [isSaveQueryModalOpen, setIsSaveQueryModalOpen] = useState31(false);
46601
+ const [tempReport, setTempReport] = useState31({
46437
46602
  ...EMPTY_INTERNAL_REPORT,
46438
46603
  ...report
46439
46604
  });
46440
- const tableRef = useRef18(null);
46441
- const [cachedHeight, setCachedHeight] = useState30(0);
46605
+ const tableRef = useRef19(null);
46606
+ const [cachedHeight, setCachedHeight] = useState31(0);
46442
46607
  const DEFAULT_ROWS_PER_PAGE = 5;
46443
46608
  const ROW_HEIGHT = 37;
46444
46609
  const TABLE_TAB_HEIGHT = 75;
@@ -46452,17 +46617,17 @@ function SQLEditor({
46452
46617
  schemaData.schemaWithCustomFields,
46453
46618
  destinationDashboardConfig?.tenantKeys
46454
46619
  ]);
46455
- useEffect24(() => {
46620
+ useEffect25(() => {
46456
46621
  if (tableRef.current) {
46457
46622
  setCachedHeight(tableRef.current.clientHeight);
46458
46623
  }
46459
46624
  }, [tableRef.current?.clientHeight]);
46460
- useEffect24(() => {
46625
+ useEffect25(() => {
46461
46626
  if (!data && !dashboardIsLoading) {
46462
46627
  reload();
46463
46628
  }
46464
46629
  }, [data, dashboardIsLoading]);
46465
- useEffect24(() => {
46630
+ useEffect25(() => {
46466
46631
  const loadReport = async () => {
46467
46632
  let reportToLoad;
46468
46633
  if (!client) {
@@ -46515,8 +46680,8 @@ function SQLEditor({
46515
46680
  rowsPerPage * 10
46516
46681
  )
46517
46682
  };
46518
- const [currentPage, setCurrentPage] = useState30(0);
46519
- const [currentSort, setCurrentSort] = useState30(void 0);
46683
+ const [currentPage, setCurrentPage] = useState31(0);
46684
+ const [currentSort, setCurrentSort] = useState31(void 0);
46520
46685
  const currentProcessing = useMemo22(() => {
46521
46686
  return {
46522
46687
  page: {
@@ -46537,29 +46702,14 @@ function SQLEditor({
46537
46702
  );
46538
46703
  }) ?? [];
46539
46704
  }, [tableSearchQuery, schemaData.schemaWithCustomFields]);
46540
- useEffect24(() => {
46541
- function handleResize() {
46542
- updateFirstChildWidth(formRef, setSearchBarWidth, { gap: 12 });
46543
- updateFirstChildWidth(sidebarRef, setFilterBarWidth, { gap: 12 });
46544
- setShowSearchBar(true);
46545
- }
46546
- (async () => {
46547
- await new Promise((resolve) => setTimeout(resolve, 30));
46548
- handleResize();
46549
- })();
46550
- window.addEventListener("resize", handleResize);
46551
- return () => {
46552
- window.removeEventListener("resize", handleResize);
46553
- };
46554
- }, []);
46555
- useEffect24(() => {
46705
+ useEffect25(() => {
46556
46706
  if (client) {
46557
46707
  setRows([]);
46558
46708
  setColumns([]);
46559
46709
  setDisplayTable(false);
46560
46710
  }
46561
46711
  }, [client?.publicKey]);
46562
- useEffect24(() => {
46712
+ useEffect25(() => {
46563
46713
  if (isChartBuilderOpen === false) {
46564
46714
  onCloseChartBuilder && onCloseChartBuilder();
46565
46715
  }
@@ -46705,25 +46855,35 @@ function SQLEditor({
46705
46855
  onChangeFields(tableInfo.columns);
46706
46856
  }
46707
46857
  const formData = report ? report : createInitialFormData(tableInfo.columns);
46708
- const newReport = {
46858
+ const baseReport = reportId ? tempReport : {
46709
46859
  ...tempReport,
46710
- ...formData,
46860
+ ...formData
46861
+ };
46862
+ const newReport = {
46863
+ ...baseReport,
46864
+ // In edit mode, preserve critical fields that shouldn't be overwritten
46865
+ ...reportId && tempReport.name ? { name: tempReport.name } : {},
46711
46866
  itemQuery: tableInfo.itemQuery,
46712
46867
  rowCount: tableInfo.rowCount ?? tableInfo.rows.length,
46713
46868
  rows: tempRows,
46714
46869
  columns: tableInfo.columns,
46715
- referencedTables: tableInfo.referencedTables
46870
+ referencedTables: tableInfo.referencedTables,
46871
+ queryString: query ?? tempReport.queryString ?? ""
46716
46872
  };
46717
- const cleaned = await cleanDashboardItem({
46718
- item: newReport,
46719
- dashboardFilters: newReport.filtersApplied,
46720
- client,
46721
- customFields: schemaData.customFields,
46722
- getToken,
46723
- tenants,
46724
- eventTracking
46725
- });
46726
- setTempReport(cleaned);
46873
+ if (reportId) {
46874
+ setTempReport(newReport);
46875
+ } else {
46876
+ const cleaned = await cleanDashboardItem({
46877
+ item: newReport,
46878
+ dashboardFilters: newReport.filtersApplied,
46879
+ client,
46880
+ customFields: schemaData.customFields,
46881
+ getToken,
46882
+ tenants,
46883
+ eventTracking
46884
+ });
46885
+ setTempReport(cleaned);
46886
+ }
46727
46887
  setLastSuccessfulQuery(query);
46728
46888
  } catch (e) {
46729
46889
  eventTracking?.logError?.({
@@ -46810,7 +46970,7 @@ function SQLEditor({
46810
46970
  }
46811
46971
  return getTablesHelper(getSelectFromAST(resp.ast), dbTables, skipStar);
46812
46972
  };
46813
- useEffect24(() => {
46973
+ useEffect25(() => {
46814
46974
  if (onChangeQuery) {
46815
46975
  onChangeQuery(query || "");
46816
46976
  }
@@ -46867,7 +47027,11 @@ function SQLEditor({
46867
47027
  style: {
46868
47028
  paddingTop: 16,
46869
47029
  paddingLeft: "20px",
46870
- paddingRight: "30px"
47030
+ paddingRight: "30px",
47031
+ width: "100%",
47032
+ maxWidth: 350,
47033
+ minWidth: 250,
47034
+ boxSizing: "border-box"
46871
47035
  },
46872
47036
  children: /* @__PURE__ */ jsx66(
46873
47037
  TextInputComponent,
@@ -46878,7 +47042,7 @@ function SQLEditor({
46878
47042
  },
46879
47043
  value: tableSearchQuery,
46880
47044
  id: "edit-name",
46881
- width: filterBarWidth
47045
+ width: "100%"
46882
47046
  }
46883
47047
  )
46884
47048
  }
@@ -46898,7 +47062,7 @@ function SQLEditor({
46898
47062
  ]
46899
47063
  }
46900
47064
  ),
46901
- /* @__PURE__ */ jsxs48(
47065
+ /* @__PURE__ */ jsx66(
46902
47066
  "div",
46903
47067
  {
46904
47068
  style: {
@@ -46910,404 +47074,385 @@ function SQLEditor({
46910
47074
  height: "100%",
46911
47075
  overflowX: "hidden"
46912
47076
  },
46913
- children: [
46914
- /* @__PURE__ */ jsx66(
46915
- "div",
46916
- {
46917
- style: {
46918
- display: "flex",
46919
- flexDirection: "column",
46920
- overflow: addToDashboardButtonLabel === "Add to dashboard" ? "visible" : "auto",
46921
- height: "100%"
46922
- },
46923
- children: /* @__PURE__ */ jsxs48(OverflowContainer, { children: [
46924
- /* @__PURE__ */ jsxs48(
46925
- "form",
46926
- {
46927
- ref: formRef,
46928
- onSubmit: (e) => {
46929
- e.preventDefault();
46930
- if (sqlPrompt.trim().length > 500) {
46931
- return;
46932
- }
46933
- debounceRunSqlPrompt();
46934
- },
46935
- style: {
46936
- display: "flex",
46937
- visibility: showSearchBar ? "visible" : "hidden",
46938
- flexDirection: "row",
46939
- gap: 12,
46940
- paddingTop: 16,
46941
- paddingBottom: 16
46942
- },
46943
- children: [
46944
- /* @__PURE__ */ jsx66(
46945
- TextInputComponent,
46946
- {
46947
- id: "ai-search",
46948
- value: sqlPrompt,
46949
- width: searchBarWidth,
46950
- onChange: (e) => setSqlPrompt(e.target.value),
46951
- placeholder: "Ask a question..."
46952
- }
46953
- ),
46954
- /* @__PURE__ */ jsx66(
46955
- QuillToolTip,
46956
- {
46957
- text: "Prompt must be less than 500 characters",
46958
- enabled: sqlPrompt.trim().length > 500,
46959
- displayBelow: true,
46960
- textStyle: {
46961
- maxWidth: "77px",
46962
- whiteSpace: "normal"
46963
- },
46964
- children: /* @__PURE__ */ jsx66(
46965
- ButtonComponent,
46966
- {
46967
- onClick: debounceRunSqlPrompt,
46968
- label: "Ask AI",
46969
- isLoading: sqlResponseLoading,
46970
- disabled: sqlPrompt.trim().length > 500
46971
- }
46972
- )
46973
- }
46974
- )
46975
- ]
46976
- }
46977
- ),
46978
- /* @__PURE__ */ jsx66(
46979
- "div",
46980
- {
46981
- style: {
46982
- minHeight: "max(210px, 20vh)",
46983
- maxHeight: "30%",
46984
- height: "20vh"
46985
- },
46986
- children: /* @__PURE__ */ jsx66(
46987
- SQLEditorComponent,
47077
+ children: /* @__PURE__ */ jsx66(
47078
+ "div",
47079
+ {
47080
+ style: {
47081
+ display: "flex",
47082
+ flexDirection: "column",
47083
+ overflow: addToDashboardButtonLabel === "Add to dashboard" ? "visible" : "auto",
47084
+ height: "100%"
47085
+ },
47086
+ children: /* @__PURE__ */ jsxs48(OverflowContainer, { children: [
47087
+ /* @__PURE__ */ jsxs48(
47088
+ "form",
47089
+ {
47090
+ ref: sqlPromptFormRef,
47091
+ onSubmit: (e) => {
47092
+ e.preventDefault();
47093
+ if (sqlPrompt.trim().length > 500) {
47094
+ return;
47095
+ }
47096
+ debounceRunSqlPrompt();
47097
+ },
47098
+ style: {
47099
+ display: "flex",
47100
+ flexDirection: "row",
47101
+ gap: 12,
47102
+ paddingTop: 16,
47103
+ paddingBottom: 16,
47104
+ flexWrap: "wrap",
47105
+ alignItems: "stretch",
47106
+ visibility: normalizedSqlPromptWidth > 0 ? "visible" : "hidden"
47107
+ },
47108
+ children: [
47109
+ /* @__PURE__ */ jsx66(
47110
+ TextInputComponent,
46988
47111
  {
46989
- query: query || "",
46990
- schema: filteredSchema,
46991
- databaseType: client?.databaseType ?? "postgresql",
46992
- clientName: client?.publicKey || "",
46993
- setQuery,
46994
- handleRunQuery: () => {
46995
- handleRunQuery(currentProcessing, true);
46996
- },
46997
- handleFixWithAI,
46998
- isNewQueryEnabled,
46999
- runQueryOnMount,
47000
- handleClearQuery,
47001
- theme,
47002
- defineEditorTheme,
47003
- setEditorTheme,
47004
- setEditorMounted: () => {
47005
- },
47006
- ButtonComponent,
47007
- SecondaryButtonComponent,
47008
- loading: sqlResponseLoading && schemaData.isSchemaLoading && dashboardIsLoading,
47009
- LoadingComponent
47112
+ id: "ai-search",
47113
+ value: sqlPrompt,
47114
+ width: normalizedSqlPromptWidth,
47115
+ onChange: (e) => setSqlPrompt(e.target.value),
47116
+ placeholder: "Ask a question..."
47010
47117
  }
47011
- )
47012
- }
47013
- ),
47014
- /* @__PURE__ */ jsx66(
47015
- "div",
47016
- {
47017
- style: {
47018
- display: "flex",
47019
- flexDirection: "row",
47020
- width: "100%",
47021
- justifyContent: addToDashboardButtonLabel === "Add to dashboard" ? "flex-end" : "flex-start"
47022
- },
47023
- children: /* @__PURE__ */ jsx66(
47024
- "div",
47118
+ ),
47119
+ /* @__PURE__ */ jsx66(
47120
+ QuillToolTip,
47025
47121
  {
47026
- style: {
47027
- display: "flex",
47028
- flexDirection: "row",
47029
- alignItems: "center",
47030
- height: 70
47122
+ text: "Prompt must be less than 500 characters",
47123
+ enabled: sqlPrompt.trim().length > 500,
47124
+ displayBelow: true,
47125
+ textStyle: {
47126
+ maxWidth: "77px",
47127
+ whiteSpace: "normal"
47031
47128
  },
47032
- children: /* @__PURE__ */ jsxs48("div", { style: { display: "flex", gap: 12 }, children: [
47033
- addToDashboardButtonLabel === "Add to dashboard" ? /* @__PURE__ */ jsx66(
47034
- SecondaryButtonComponent,
47035
- {
47036
- onClick: () => {
47037
- handleRunQuery(
47038
- {
47039
- page: pagination,
47040
- sort: void 0
47041
- },
47042
- true,
47043
- false,
47044
- true
47045
- );
47046
- },
47047
- label: "Run query"
47048
- }
47049
- ) : /* @__PURE__ */ jsx66(
47050
- ButtonComponent,
47051
- {
47052
- onClick: () => {
47053
- handleRunQuery(
47054
- {
47055
- page: pagination,
47056
- sort: void 0
47057
- },
47058
- true,
47059
- false,
47060
- true
47061
- );
47062
- },
47063
- label: "Run query"
47064
- }
47065
- ),
47066
- isAdminEnabled && !report && /* @__PURE__ */ jsx66(
47067
- SecondaryButtonComponent,
47068
- {
47069
- disabled: !!errorMessage || !(lastSuccessfulQuery === query) || !query,
47070
- onClick: async () => {
47071
- const isSelectStar = isSimpleSelectStarQuery(
47072
- query ?? ""
47073
- );
47074
- let tables = [];
47075
- let customFieldColumns = [];
47076
- if (client && isSelectStar && schemaData.customFields) {
47077
- const { referencedTablesAndColumns } = await getReferencedTables(
47078
- client,
47079
- query ?? "",
47080
- schemaData.schemaWithCustomFields,
47081
- isSelectStar
47082
- );
47083
- tables = referencedTablesAndColumns.map(
47084
- (ref) => ref.name
47085
- );
47086
- customFieldColumns = tables.map((table) => {
47087
- return (schemaData.customFields?.[table] ?? []).map((field) => field.field);
47088
- }).flat();
47089
- }
47090
- setTempReport({
47091
- ...tempReport,
47092
- id: TEMP_REPORT_ID,
47093
- rows,
47094
- columns: isSelectStar ? (
47095
- // so Automatic Custom Fields can be applied
47096
- columns.filter(
47097
- (col) => {
47098
- return !customFieldColumns.includes(
47099
- col.field
47100
- );
47101
- }
47102
- )
47103
- ) : columns,
47104
- includeCustomFields: isSelectStar,
47105
- columnInternal: columns,
47106
- rowCount: rowCount ?? 0,
47107
- queryString: query ?? "",
47108
- chartType: "table",
47109
- dashboardName: destinationDashboard
47110
- });
47111
- setIsSaveQueryModalOpen(true);
47112
- },
47113
- label: "Save query"
47114
- }
47115
- ),
47116
- isNewQueryEnabled && /* @__PURE__ */ jsx66(
47117
- SecondaryButtonComponent,
47118
- {
47119
- onClick: handleClearQuery,
47120
- label: "Clear query"
47121
- }
47122
- ),
47123
- addToDashboardButtonLabel === "Add to dashboard" && /* @__PURE__ */ jsx66(
47124
- ButtonComponent,
47125
- {
47126
- onClick: async () => {
47127
- onSaveChanges && onSaveChanges();
47128
- const isSelectStar = isSimpleSelectStarQuery(
47129
- query ?? ""
47130
- );
47131
- let tables = [];
47132
- let customFieldColumns = [];
47133
- if (client && isSelectStar && schemaData.customFields) {
47134
- const { referencedTablesAndColumns } = await getReferencedTables(
47135
- client,
47136
- query ?? "",
47137
- filteredSchema,
47138
- isSelectStar
47139
- );
47140
- tables = referencedTablesAndColumns.map(
47141
- (ref) => ref.name
47142
- );
47143
- customFieldColumns = tables.map((table) => {
47144
- return (schemaData.customFields?.[table] ?? []).map((field) => field.field);
47145
- }).flat();
47146
- }
47147
- setTempReport({
47148
- ...tempReport,
47149
- id: TEMP_REPORT_ID,
47150
- rows,
47151
- columns: isSelectStar ? (
47152
- // so Automatic Custom Fields can be applied
47153
- columns.filter(
47154
- (col) => {
47155
- return !customFieldColumns.includes(
47156
- col.field
47157
- );
47158
- }
47159
- )
47160
- ) : columns,
47161
- includeCustomFields: isSelectStar,
47162
- columnInternal: columns,
47163
- rowCount: rowCount ?? 0,
47164
- queryString: query ?? "",
47165
- dashboardName: report?.dashboardName ?? destinationDashboard
47166
- });
47167
- setIsChartBuilderOpen(true);
47168
- },
47169
- label: addToDashboardButtonLabel,
47170
- disabled: !!errorMessage || !(lastSuccessfulQuery === query) || !query,
47171
- tooltipText: !!errorMessage || !(lastSuccessfulQuery === query) ? "Please run a query" : ""
47172
- }
47173
- )
47174
- ] })
47129
+ children: /* @__PURE__ */ jsx66(
47130
+ ButtonComponent,
47131
+ {
47132
+ onClick: debounceRunSqlPrompt,
47133
+ label: "Ask AI",
47134
+ isLoading: sqlResponseLoading,
47135
+ disabled: sqlPrompt.trim().length > 500
47136
+ }
47137
+ )
47175
47138
  }
47176
47139
  )
47177
- }
47178
- ),
47179
- /* @__PURE__ */ jsxs48(
47180
- "div",
47181
- {
47182
- style: {
47183
- display: "flex",
47184
- flexDirection: "column",
47185
- // height: '100%',
47186
- padding: 0,
47187
- margin: 0,
47188
- border: "none",
47189
- outline: "none"
47190
- },
47191
- children: [
47192
- errorMessage && /* @__PURE__ */ jsx66(
47140
+ ]
47141
+ }
47142
+ ),
47143
+ /* @__PURE__ */ jsx66(
47144
+ "div",
47145
+ {
47146
+ style: {
47147
+ minHeight: "max(210px, 20vh)",
47148
+ maxHeight: "30%",
47149
+ height: "20vh"
47150
+ },
47151
+ children: /* @__PURE__ */ jsx66(
47152
+ SQLEditorComponent,
47153
+ {
47154
+ query: query || "",
47155
+ schema: filteredSchema,
47156
+ databaseType: client?.databaseType ?? "postgresql",
47157
+ clientName: client?.publicKey || "",
47158
+ setQuery,
47159
+ handleRunQuery: () => {
47160
+ handleRunQuery(currentProcessing, true);
47161
+ },
47162
+ handleFixWithAI,
47163
+ isNewQueryEnabled,
47164
+ runQueryOnMount,
47165
+ handleClearQuery,
47166
+ theme,
47167
+ defineEditorTheme,
47168
+ setEditorTheme,
47169
+ setEditorMounted: () => {
47170
+ },
47171
+ ButtonComponent,
47172
+ SecondaryButtonComponent,
47173
+ loading: sqlResponseLoading && schemaData.isSchemaLoading && dashboardIsLoading,
47174
+ LoadingComponent
47175
+ }
47176
+ )
47177
+ }
47178
+ ),
47179
+ /* @__PURE__ */ jsx66(
47180
+ "div",
47181
+ {
47182
+ style: {
47183
+ display: "flex",
47184
+ flexDirection: "row",
47185
+ width: "100%",
47186
+ justifyContent: addToDashboardButtonLabel === "Add to dashboard" ? "flex-end" : "flex-start"
47187
+ },
47188
+ children: /* @__PURE__ */ jsx66(
47189
+ "div",
47190
+ {
47191
+ style: {
47192
+ display: "flex",
47193
+ flexDirection: "row",
47194
+ alignItems: "center",
47195
+ height: 70
47196
+ },
47197
+ children: /* @__PURE__ */ jsxs48(
47193
47198
  "div",
47194
47199
  {
47195
47200
  style: {
47196
- fontFamily: theme?.fontFamily,
47197
- color: theme?.primaryTextColor,
47198
- fontSize: 15,
47199
- fontWeight: "400",
47200
- width: "100%"
47201
+ display: "flex",
47202
+ gap: 12
47201
47203
  },
47202
- children: /* @__PURE__ */ jsxs48(
47203
- "div",
47204
- {
47205
- style: {
47206
- display: "flex",
47207
- flexDirection: "row",
47208
- justifyContent: "space-between",
47209
- gap: 12,
47210
- background: "rgba(0,0,0,0.02)",
47211
- // TODO: change color
47212
- color: theme?.primaryTextColor,
47213
- fontFamily: theme?.fontFamily,
47214
- borderRadius: 6,
47215
- padding: 20,
47216
- marginBottom: 15,
47217
- width: "100%",
47218
- alignItems: "center"
47219
- },
47220
- children: [
47221
- errorMessage,
47222
- errorMessage !== "No data found" && errorMessage !== "No query found" && /* @__PURE__ */ jsx66(
47223
- SecondaryButtonComponent,
47204
+ children: [
47205
+ computedButtonLabel === "Add to dashboard" ? /* @__PURE__ */ jsx66(
47206
+ SecondaryButtonComponent,
47207
+ {
47208
+ onClick: () => {
47209
+ handleRunQuery(
47210
+ {
47211
+ page: pagination,
47212
+ sort: void 0
47213
+ },
47214
+ true,
47215
+ false,
47216
+ true
47217
+ );
47218
+ },
47219
+ label: "Run query"
47220
+ }
47221
+ ) : /* @__PURE__ */ jsx66(
47222
+ SecondaryButtonComponent,
47223
+ {
47224
+ onClick: () => {
47225
+ handleRunQuery(
47226
+ {
47227
+ page: pagination,
47228
+ sort: void 0
47229
+ },
47230
+ true,
47231
+ false,
47232
+ true
47233
+ );
47234
+ },
47235
+ label: "Run query"
47236
+ }
47237
+ ),
47238
+ isChartBuilderEnabled && /* @__PURE__ */ jsx66(
47239
+ "div",
47240
+ {
47241
+ style: {
47242
+ display: "flex",
47243
+ flexDirection: "row",
47244
+ alignItems: "center",
47245
+ justifyContent: "flex-end",
47246
+ width: "100%"
47247
+ },
47248
+ children: computedButtonLabel !== "Add to dashboard" ? /* @__PURE__ */ jsx66(
47249
+ ButtonComponent,
47224
47250
  {
47225
- onClick: handleFixWithAI,
47226
- label: "Fix with AI"
47251
+ onClick: async () => {
47252
+ onSaveChanges && onSaveChanges();
47253
+ setIsChartBuilderOpen(true);
47254
+ },
47255
+ label: computedButtonLabel,
47256
+ disabled: !!errorMessage || !(lastSuccessfulQuery === query)
47257
+ }
47258
+ ) : /* @__PURE__ */ jsx66(
47259
+ ButtonComponent,
47260
+ {
47261
+ onClick: async () => {
47262
+ onSaveChanges && onSaveChanges();
47263
+ const isSelectStar = isSimpleSelectStarQuery(query ?? "");
47264
+ let tables = [];
47265
+ let customFieldColumns = [];
47266
+ if (client && isSelectStar && schemaData.customFields) {
47267
+ const { referencedTablesAndColumns } = await getReferencedTables(
47268
+ client,
47269
+ query ?? "",
47270
+ filteredSchema,
47271
+ isSelectStar
47272
+ );
47273
+ tables = referencedTablesAndColumns.map(
47274
+ (ref) => ref.name
47275
+ );
47276
+ customFieldColumns = tables.map((table) => {
47277
+ return (schemaData.customFields?.[table] ?? []).map((field) => field.field);
47278
+ }).flat();
47279
+ }
47280
+ const newTempReport = {
47281
+ ...tempReport,
47282
+ id: reportId || report?.id || TEMP_REPORT_ID,
47283
+ rows,
47284
+ columns: isSelectStar ? (
47285
+ // so Automatic Custom Fields can be applied
47286
+ columns.filter(
47287
+ (col) => {
47288
+ return !customFieldColumns.includes(
47289
+ col.field
47290
+ );
47291
+ }
47292
+ )
47293
+ ) : columns,
47294
+ includeCustomFields: isSelectStar,
47295
+ columnInternal: columns,
47296
+ rowCount: rowCount ?? 0,
47297
+ queryString: query ?? "",
47298
+ dashboardName: report?.dashboardName ?? destinationDashboard
47299
+ };
47300
+ setTempReport(newTempReport);
47301
+ setIsChartBuilderOpen(true);
47302
+ },
47303
+ label: computedButtonLabel,
47304
+ disabled: !!errorMessage || !(lastSuccessfulQuery === query) || !query,
47305
+ tooltipText: !!errorMessage || !(lastSuccessfulQuery === query) ? "Please run a query" : ""
47227
47306
  }
47228
47307
  )
47229
- ]
47230
- }
47231
- )
47232
- }
47233
- ),
47234
- errorMessage || !displayTable ? null : /* @__PURE__ */ jsx66("div", { ref: tableRef, children: /* @__PURE__ */ jsx66(
47235
- TableComponent,
47236
- {
47237
- isLoading: sqlQueryLoading,
47238
- rows: formattedRows,
47239
- columns,
47240
- rowCount,
47241
- rowsPerPage,
47242
- rowCountIsLoading,
47243
- onPageChange,
47244
- onSortChange,
47245
- containerStyle: {
47246
- height: "calc(100vh - max(210px, 20vh) - 310px)",
47247
- minHeight: `calc(${DEFAULT_ROWS_PER_PAGE} * ${ROW_HEIGHT}px + ${TABLE_TAB_HEIGHT}px)`,
47248
- // at least 10 rows tall
47249
- maxHeight: "calc(100vh - max(210px, 20vh) - 310px)"
47250
- },
47251
- currentPage,
47252
- setCurrentPage
47308
+ }
47309
+ ),
47310
+ isAdminEnabled && !report && /* @__PURE__ */ jsx66(
47311
+ SecondaryButtonComponent,
47312
+ {
47313
+ disabled: !!errorMessage || !(lastSuccessfulQuery === query) || !query,
47314
+ onClick: async () => {
47315
+ const isSelectStar = isSimpleSelectStarQuery(
47316
+ query ?? ""
47317
+ );
47318
+ let tables = [];
47319
+ let customFieldColumns = [];
47320
+ if (client && isSelectStar && schemaData.customFields) {
47321
+ const { referencedTablesAndColumns } = await getReferencedTables(
47322
+ client,
47323
+ query ?? "",
47324
+ schemaData.schemaWithCustomFields,
47325
+ isSelectStar
47326
+ );
47327
+ tables = referencedTablesAndColumns.map(
47328
+ (ref) => ref.name
47329
+ );
47330
+ customFieldColumns = tables.map((table) => {
47331
+ return (schemaData.customFields?.[table] ?? []).map((field) => field.field);
47332
+ }).flat();
47333
+ }
47334
+ setTempReport({
47335
+ ...tempReport,
47336
+ id: TEMP_REPORT_ID,
47337
+ rows,
47338
+ columns: isSelectStar ? (
47339
+ // so Automatic Custom Fields can be applied
47340
+ columns.filter(
47341
+ (col) => {
47342
+ return !customFieldColumns.includes(
47343
+ col.field
47344
+ );
47345
+ }
47346
+ )
47347
+ ) : columns,
47348
+ includeCustomFields: isSelectStar,
47349
+ columnInternal: columns,
47350
+ rowCount: rowCount ?? 0,
47351
+ queryString: query ?? "",
47352
+ chartType: "table",
47353
+ dashboardName: destinationDashboard
47354
+ });
47355
+ setIsSaveQueryModalOpen(true);
47356
+ },
47357
+ label: "Save query"
47358
+ }
47359
+ ),
47360
+ isNewQueryEnabled && /* @__PURE__ */ jsx66(
47361
+ SecondaryButtonComponent,
47362
+ {
47363
+ onClick: handleClearQuery,
47364
+ label: "Clear query"
47365
+ }
47366
+ )
47367
+ ]
47253
47368
  }
47254
- ) })
47255
- ]
47256
- }
47257
- )
47258
- ] })
47259
- }
47260
- ),
47261
- isChartBuilderEnabled && /* @__PURE__ */ jsxs48(
47262
- "div",
47263
- {
47264
- style: {
47265
- display: "flex",
47266
- flexDirection: "row",
47267
- alignItems: "center",
47268
- justifyContent: "flex-end",
47269
- width: "100%",
47270
- gap: 12,
47271
- marginTop: 15,
47272
- marginBottom: 5
47273
- },
47274
- children: [
47275
- onDiscardChanges && /* @__PURE__ */ jsx66(
47276
- SecondaryButtonComponent,
47277
- {
47278
- onClick: onDiscardChanges,
47279
- label: "Discard changes"
47280
- }
47281
- ),
47282
- addToDashboardButtonLabel !== "Add to dashboard" && /* @__PURE__ */ jsx66(
47283
- ButtonComponent,
47284
- {
47285
- onClick: async () => {
47286
- onSaveChanges && onSaveChanges();
47287
- const updatedReport = {
47288
- ...tempReport,
47289
- id: TEMP_REPORT_ID,
47290
- rows,
47369
+ )
47370
+ }
47371
+ )
47372
+ }
47373
+ ),
47374
+ /* @__PURE__ */ jsxs48(
47375
+ "div",
47376
+ {
47377
+ style: {
47378
+ display: "flex",
47379
+ flexDirection: "column",
47380
+ // height: '100%',
47381
+ padding: 0,
47382
+ margin: 0,
47383
+ border: "none",
47384
+ outline: "none"
47385
+ },
47386
+ children: [
47387
+ errorMessage && /* @__PURE__ */ jsx66(
47388
+ "div",
47389
+ {
47390
+ style: {
47391
+ fontFamily: theme?.fontFamily,
47392
+ color: theme?.primaryTextColor,
47393
+ fontSize: 15,
47394
+ fontWeight: "400",
47395
+ width: "100%"
47396
+ },
47397
+ children: /* @__PURE__ */ jsxs48(
47398
+ "div",
47399
+ {
47400
+ style: {
47401
+ display: "flex",
47402
+ flexDirection: "row",
47403
+ justifyContent: "space-between",
47404
+ gap: 12,
47405
+ background: "rgba(0,0,0,0.02)",
47406
+ // TODO: change color
47407
+ color: theme?.primaryTextColor,
47408
+ fontFamily: theme?.fontFamily,
47409
+ borderRadius: 6,
47410
+ padding: 20,
47411
+ marginBottom: 15,
47412
+ width: "100%",
47413
+ alignItems: "center"
47414
+ },
47415
+ children: [
47416
+ errorMessage,
47417
+ errorMessage !== "No data found" && errorMessage !== "No query found" && /* @__PURE__ */ jsx66(
47418
+ SecondaryButtonComponent,
47419
+ {
47420
+ onClick: handleFixWithAI,
47421
+ label: "Fix with AI"
47422
+ }
47423
+ )
47424
+ ]
47425
+ }
47426
+ )
47427
+ }
47428
+ ),
47429
+ errorMessage || !displayTable ? null : /* @__PURE__ */ jsx66("div", { ref: tableRef, children: /* @__PURE__ */ jsx66(
47430
+ TableComponent,
47431
+ {
47432
+ isLoading: sqlQueryLoading,
47433
+ rows: formattedRows,
47291
47434
  columns,
47292
- columnInternal: columns,
47293
- rowCount: rowCount ?? 0,
47294
- queryString: query ?? "",
47295
- dashboardName: report?.dashboardName ?? destinationDashboard
47296
- // flags: flagsToAdd,
47297
- };
47298
- flushSync2(() => {
47299
- setTempReport(updatedReport);
47300
- });
47301
- setIsChartBuilderOpen(true);
47302
- },
47303
- label: addToDashboardButtonLabel,
47304
- disabled: !!errorMessage || !(lastSuccessfulQuery === query)
47305
- }
47306
- )
47307
- ]
47308
- }
47309
- )
47310
- ]
47435
+ rowCount,
47436
+ rowsPerPage,
47437
+ rowCountIsLoading,
47438
+ onPageChange,
47439
+ onSortChange,
47440
+ containerStyle: {
47441
+ height: "calc(100vh - max(210px, 20vh) - 310px)",
47442
+ minHeight: `calc(${DEFAULT_ROWS_PER_PAGE} * ${ROW_HEIGHT}px + ${TABLE_TAB_HEIGHT}px)`,
47443
+ // at least 10 rows tall
47444
+ maxHeight: "calc(100vh - max(210px, 20vh) - 310px)"
47445
+ },
47446
+ currentPage,
47447
+ setCurrentPage
47448
+ }
47449
+ ) })
47450
+ ]
47451
+ }
47452
+ )
47453
+ ] })
47454
+ }
47455
+ )
47311
47456
  }
47312
47457
  )
47313
47458
  ]
@@ -47352,7 +47497,7 @@ function SQLEditor({
47352
47497
  destinationSection,
47353
47498
  isAdmin: isAdminEnabled,
47354
47499
  title: chartBuilderTitle,
47355
- buttonLabel: addToDashboardButtonLabel,
47500
+ buttonLabel: computedButtonLabel,
47356
47501
  tempReport,
47357
47502
  reportId: reportId || report?.id,
47358
47503
  organizationName,
@@ -47451,10 +47596,10 @@ var SQLEditorComponent = ({
47451
47596
  loading,
47452
47597
  LoadingComponent = QuillLoadingComponent
47453
47598
  }) => {
47454
- const [editorKey, setEditorKey] = useState30(0);
47599
+ const [editorKey, setEditorKey] = useState31(0);
47455
47600
  const { eventTracking } = useContext28(EventTrackingContext);
47456
- const currentProvider = useRef18(null);
47457
- useEffect24(() => {
47601
+ const currentProvider = useRef19(null);
47602
+ useEffect25(() => {
47458
47603
  if (currentProvider.current) {
47459
47604
  currentProvider.current.dispose();
47460
47605
  if (schema && schema.length !== 0) {
@@ -47695,7 +47840,7 @@ function SchemaItem({
47695
47840
  index,
47696
47841
  onClick
47697
47842
  }) {
47698
- const [isOpen, setIsOpen] = useState30(index === 0);
47843
+ const [isOpen, setIsOpen] = useState31(index === 0);
47699
47844
  const schemaContainerStyle = {
47700
47845
  display: "flex",
47701
47846
  flexDirection: "column"
@@ -47924,14 +48069,14 @@ function SchemaItem({
47924
48069
  // src/ReportBuilder.tsx
47925
48070
  import {
47926
48071
  useContext as useContext32,
47927
- useEffect as useEffect28,
47928
- useRef as useRef20,
47929
- useState as useState36
48072
+ useEffect as useEffect29,
48073
+ useRef as useRef21,
48074
+ useState as useState37
47930
48075
  } from "react";
47931
48076
  init_constants();
47932
48077
 
47933
48078
  // src/hooks/useReportBuilder.tsx
47934
- import { useContext as useContext29, useEffect as useEffect25, useMemo as useMemo23, useState as useState31 } from "react";
48079
+ import { useContext as useContext29, useEffect as useEffect26, useMemo as useMemo23, useState as useState32 } from "react";
47935
48080
  init_tableProcessing();
47936
48081
  init_ReportBuilder();
47937
48082
  init_constants();
@@ -47982,18 +48127,18 @@ var useReportBuilderInternal = ({
47982
48127
  rowsPerPage: _rowsPerPage,
47983
48128
  rowsPerRequest: _rowsPerRequest
47984
48129
  };
47985
- const [openPopover, setOpenPopover] = useState31(null);
47986
- const [aiPrompt, setAiPrompt] = useState31("");
47987
- const [reportBuilderLoading, setReportBuilderLoading] = useState31(false);
47988
- const [tableLoading, setTableLoading] = useState31(false);
47989
- const [errorMessage, setErrorMessage] = useState31("");
47990
- const [unresolvedReportMessage, setUnresolvedReportMessage] = useState31("");
47991
- const [tables, setTables] = useState31([]);
47992
- const [columns, setColumns] = useState31([]);
47993
- const [filterStack, setFilterStack] = useState31([]);
47994
- const [pivot, setPivot] = useState31(null);
47995
- const [sort, setSort] = useState31([]);
47996
- const [limit, setLimit] = useState31(null);
48130
+ const [openPopover, setOpenPopover] = useState32(null);
48131
+ const [aiPrompt, setAiPrompt] = useState32("");
48132
+ const [reportBuilderLoading, setReportBuilderLoading] = useState32(false);
48133
+ const [tableLoading, setTableLoading] = useState32(false);
48134
+ const [errorMessage, setErrorMessage] = useState32("");
48135
+ const [unresolvedReportMessage, setUnresolvedReportMessage] = useState32("");
48136
+ const [tables, setTables] = useState32([]);
48137
+ const [columns, setColumns] = useState32([]);
48138
+ const [filterStack, setFilterStack] = useState32([]);
48139
+ const [pivot, setPivot] = useState32(null);
48140
+ const [sort, setSort] = useState32([]);
48141
+ const [limit, setLimit] = useState32(null);
47997
48142
  const reportBuilderState = useMemo23(() => {
47998
48143
  return {
47999
48144
  tables,
@@ -48004,28 +48149,28 @@ var useReportBuilderInternal = ({
48004
48149
  limit
48005
48150
  };
48006
48151
  }, [columns, filterStack, limit, pivot, sort, tables]);
48007
- const [stateStack, setStateStack] = useState31([]);
48008
- const [poppedStateStack, setPoppedStateStack] = useState31([]);
48009
- const [unfilteredUniqueValues, setUnfilteredUniqueValues] = useState31({});
48010
- const [unfilteredUniqueValuesIsLoading, setUnfilteredUniqueValuesIsLoading] = useState31(false);
48011
- const [filteredUniqueValues, setFilteredUniqueValues] = useState31(null);
48012
- const [filteredUniqueValuesIsLoading, setFilteredUniqueValuesIsLoading] = useState31(false);
48013
- const [columnUniqueValues, setColumnUniqueValues] = useState31({});
48014
- const [dateRanges, setDateRanges] = useState31(null);
48015
- const [tempReport, setTempReport] = useState31({
48152
+ const [stateStack, setStateStack] = useState32([]);
48153
+ const [poppedStateStack, setPoppedStateStack] = useState32([]);
48154
+ const [unfilteredUniqueValues, setUnfilteredUniqueValues] = useState32({});
48155
+ const [unfilteredUniqueValuesIsLoading, setUnfilteredUniqueValuesIsLoading] = useState32(false);
48156
+ const [filteredUniqueValues, setFilteredUniqueValues] = useState32(null);
48157
+ const [filteredUniqueValuesIsLoading, setFilteredUniqueValuesIsLoading] = useState32(false);
48158
+ const [columnUniqueValues, setColumnUniqueValues] = useState32({});
48159
+ const [dateRanges, setDateRanges] = useState32(null);
48160
+ const [tempReport, setTempReport] = useState32({
48016
48161
  ...EMPTY_INTERNAL_REPORT,
48017
48162
  pagination: REPORT_BUILDER_PAGINATION
48018
48163
  });
48019
- const [currentProcessing, setCurrentProcessing] = useState31({
48164
+ const [currentProcessing, setCurrentProcessing] = useState32({
48020
48165
  page: REPORT_BUILDER_PAGINATION
48021
48166
  });
48022
- const [previousPage, setPreviousPage] = useState31(0);
48023
- const [reportColumns, setReportColumns] = useState31([]);
48024
- const [reportRows, setReportRows] = useState31([]);
48025
- const [formattedRows, setFormattedRows] = useState31([]);
48026
- const [pivotData, setPivotData] = useState31(null);
48027
- const [numberOfRows, setNumberOfRows] = useState31(0);
48028
- const [rowCountIsLoading, setRowCountIsLoading] = useState31(false);
48167
+ const [previousPage, setPreviousPage] = useState32(0);
48168
+ const [reportColumns, setReportColumns] = useState32([]);
48169
+ const [reportRows, setReportRows] = useState32([]);
48170
+ const [formattedRows, setFormattedRows] = useState32([]);
48171
+ const [pivotData, setPivotData] = useState32(null);
48172
+ const [numberOfRows, setNumberOfRows] = useState32(0);
48173
+ const [rowCountIsLoading, setRowCountIsLoading] = useState32(false);
48029
48174
  const reportColumnsToStateColumns = useMemo23(() => {
48030
48175
  const positionMap = {};
48031
48176
  columns.forEach((column, index) => {
@@ -48044,28 +48189,28 @@ var useReportBuilderInternal = ({
48044
48189
  }
48045
48190
  });
48046
48191
  }, [columns, reportColumns]);
48047
- const [pivotRowField, setPivotRowField] = useState31(
48192
+ const [pivotRowField, setPivotRowField] = useState32(
48048
48193
  void 0
48049
48194
  );
48050
- const [pivotColumnField, setPivotColumnField] = useState31(
48195
+ const [pivotColumnField, setPivotColumnField] = useState32(
48051
48196
  void 0
48052
48197
  );
48053
- const [pivotAggregations, setPivotAggregations] = useState31([]);
48054
- const [pivotLimit, setPivotLimit] = useState31(void 0);
48055
- const [pivotSort, setPivotSort] = useState31(void 0);
48056
- const [pivotHint, setPivotHint] = useState31("");
48057
- const [pivotError, setPivotError] = useState31("");
48058
- const [createdPivots, setCreatedPivots] = useState31([]);
48059
- const [recommendedPivots, setRecommendedPivots] = useState31([]);
48060
- const [pivotPopUpTitle, setPivotPopUpTitle] = useState31("Add pivot");
48061
- const [showPivotPopover, setShowPivotPopover] = useState31(false);
48062
- const [isEditingPivot, setIsEditingPivot] = useState31(false);
48063
- const [selectedPivotIndex, setSelectedPivotIndex] = useState31(-1);
48198
+ const [pivotAggregations, setPivotAggregations] = useState32([]);
48199
+ const [pivotLimit, setPivotLimit] = useState32(void 0);
48200
+ const [pivotSort, setPivotSort] = useState32(void 0);
48201
+ const [pivotHint, setPivotHint] = useState32("");
48202
+ const [pivotError, setPivotError] = useState32("");
48203
+ const [createdPivots, setCreatedPivots] = useState32([]);
48204
+ const [recommendedPivots, setRecommendedPivots] = useState32([]);
48205
+ const [pivotPopUpTitle, setPivotPopUpTitle] = useState32("Add pivot");
48206
+ const [showPivotPopover, setShowPivotPopover] = useState32(false);
48207
+ const [isEditingPivot, setIsEditingPivot] = useState32(false);
48208
+ const [selectedPivotIndex, setSelectedPivotIndex] = useState32(-1);
48064
48209
  const [
48065
48210
  pivotRecommendationsEnabledState,
48066
48211
  setPivotRecommendationsEnabledState
48067
- ] = useState31(pivotRecommendationsEnabled);
48068
- const [askAILoading, setAskAILoading] = useState31(false);
48212
+ ] = useState32(pivotRecommendationsEnabled);
48213
+ const [askAILoading, setAskAILoading] = useState32(false);
48069
48214
  const loading = reportBuilderLoading || tableLoading;
48070
48215
  useLongLoading(reportBuilderLoading, {
48071
48216
  origin: "ReportBuilder",
@@ -49149,7 +49294,7 @@ var useReportBuilderInternal = ({
49149
49294
  flags: tempReport?.flags
49150
49295
  });
49151
49296
  };
49152
- useEffect25(() => {
49297
+ useEffect26(() => {
49153
49298
  if (!client) {
49154
49299
  return;
49155
49300
  }
@@ -49162,7 +49307,7 @@ var useReportBuilderInternal = ({
49162
49307
  clearAllState();
49163
49308
  }
49164
49309
  }, [client]);
49165
- useEffect25(() => {
49310
+ useEffect26(() => {
49166
49311
  const loadChart = async () => {
49167
49312
  let report;
49168
49313
  if (!client) {
@@ -49219,7 +49364,7 @@ var useReportBuilderInternal = ({
49219
49364
  loadChart();
49220
49365
  }
49221
49366
  }, [allReportsById[reportId || ""], client]);
49222
- useEffect25(() => {
49367
+ useEffect26(() => {
49223
49368
  if (initialTableName) {
49224
49369
  const tableColumns = filteredSchema.find((table) => {
49225
49370
  return table.name === initialTableName;
@@ -49239,7 +49384,7 @@ var useReportBuilderInternal = ({
49239
49384
  }
49240
49385
  }
49241
49386
  }, [filteredSchema, initialTableName]);
49242
- useEffect25(() => {
49387
+ useEffect26(() => {
49243
49388
  if (!data && !dashboardIsLoading) {
49244
49389
  reload();
49245
49390
  }
@@ -49447,7 +49592,7 @@ var useReportBuilder = ({
49447
49592
  init_ReportBuilder();
49448
49593
 
49449
49594
  // src/components/ReportBuilder/AddColumnModal.tsx
49450
- import { useState as useState32, useRef as useRef19, useMemo as useMemo24, useEffect as useEffect26, useContext as useContext30 } from "react";
49595
+ import { useState as useState33, useRef as useRef20, useMemo as useMemo24, useEffect as useEffect27, useContext as useContext30 } from "react";
49451
49596
  import {
49452
49597
  DndContext as DndContext2,
49453
49598
  closestCenter as closestCenter2,
@@ -49482,14 +49627,14 @@ function AddColumnModal({
49482
49627
  LoadingComponent = QuillLoadingComponent,
49483
49628
  onRequestAddVirtualTable
49484
49629
  }) {
49485
- const [primaryTable, setPrimaryTable] = useState32(
49630
+ const [primaryTable, setPrimaryTable] = useState33(
49486
49631
  selectedTables[0]?.name
49487
49632
  );
49488
49633
  const [theme] = useContext30(ThemeContext);
49489
- const [search, setSearch] = useState32("");
49490
- const [initialLoad, setInitialLoad] = useState32(true);
49491
- const textInputContainerRef = useRef19(null);
49492
- const [modalSelectedColumns, setModalSelectedColumns] = useState32(
49634
+ const [search, setSearch] = useState33("");
49635
+ const [initialLoad, setInitialLoad] = useState33(true);
49636
+ const textInputContainerRef = useRef20(null);
49637
+ const [modalSelectedColumns, setModalSelectedColumns] = useState33(
49493
49638
  selectedColumns.map((col) => `${col.table}.${col.field}`)
49494
49639
  );
49495
49640
  const columnOptions = useMemo24(() => {
@@ -49516,20 +49661,20 @@ function AddColumnModal({
49516
49661
  })
49517
49662
  );
49518
49663
  }, [schema, primaryTable]);
49519
- const [orderedColumnNames, setOrderedColumnNames] = useState32([]);
49664
+ const [orderedColumnNames, setOrderedColumnNames] = useState33([]);
49520
49665
  const isSelectedAllColumns = columnOptions.length === modalSelectedColumns.length;
49521
49666
  const searchResults = useMemo24(() => {
49522
49667
  return orderedColumnNames.filter((column) => {
49523
49668
  return columnOptions.includes(column) && (search.length === 0 || column.toLowerCase().includes(search.toLowerCase()) || snakeAndCamelCaseToTitleCase(column).toLowerCase().includes(search.toLowerCase()));
49524
49669
  });
49525
49670
  }, [search, columnOptions, orderedColumnNames]);
49526
- useEffect26(() => {
49671
+ useEffect27(() => {
49527
49672
  const remainingColumns = columnOptions.filter(
49528
49673
  (col) => !modalSelectedColumns.includes(col)
49529
49674
  );
49530
49675
  setOrderedColumnNames([...modalSelectedColumns, ...remainingColumns]);
49531
49676
  }, [columnOptions]);
49532
- useEffect26(() => {
49677
+ useEffect27(() => {
49533
49678
  if (!schemaLoading && initialLoad) {
49534
49679
  setTimeout(() => setInitialLoad(false), 200);
49535
49680
  }
@@ -50412,7 +50557,7 @@ var AddFilters = ({
50412
50557
  };
50413
50558
 
50414
50559
  // src/internals/ReportBuilder/PivotForm.tsx
50415
- import { useContext as useContext31, useEffect as useEffect27, useState as useState33 } from "react";
50560
+ import { useContext as useContext31, useEffect as useEffect28, useState as useState34 } from "react";
50416
50561
  init_textProcessing();
50417
50562
  init_pivotProcessing();
50418
50563
  import { jsx as jsx73, jsxs as jsxs53 } from "react/jsx-runtime";
@@ -50441,22 +50586,22 @@ function PivotForm({
50441
50586
  isLoading,
50442
50587
  pivotHint
50443
50588
  }) {
50444
- const [allowedColumnFields, setAllowedColumnFields] = useState33([]);
50445
- const [allowedRowFields, setAllowedRowFields] = useState33([]);
50446
- const [allowedValueFields, setAllowedValueFields] = useState33([]);
50589
+ const [allowedColumnFields, setAllowedColumnFields] = useState34([]);
50590
+ const [allowedRowFields, setAllowedRowFields] = useState34([]);
50591
+ const [allowedValueFields, setAllowedValueFields] = useState34([]);
50447
50592
  const [theme] = useContext31(ThemeContext);
50448
- const [limitInput, setLimitInput] = useState33(
50593
+ const [limitInput, setLimitInput] = useState34(
50449
50594
  pivotLimit?.toString() ?? ""
50450
50595
  );
50451
- const [sortFieldInput, setSortFieldInput] = useState33(
50596
+ const [sortFieldInput, setSortFieldInput] = useState34(
50452
50597
  pivotSort?.sortField ?? ""
50453
50598
  );
50454
- const [sortDirectionInput, setSortDirectionInput] = useState33(
50599
+ const [sortDirectionInput, setSortDirectionInput] = useState34(
50455
50600
  pivotSort?.sortDirection ?? ""
50456
50601
  );
50457
- const [showLimitInput, setShowLimitInput] = useState33(!!pivotLimit);
50458
- const [showSortInput, setShowSortInput] = useState33(!!pivotSort);
50459
- useEffect27(() => {
50602
+ const [showLimitInput, setShowLimitInput] = useState34(!!pivotLimit);
50603
+ const [showSortInput, setShowSortInput] = useState34(!!pivotSort);
50604
+ useEffect28(() => {
50460
50605
  if (uniqueValues) {
50461
50606
  const possibleColumns = getPossiblePivotFieldOptions(
50462
50607
  columns,
@@ -50467,12 +50612,12 @@ function PivotForm({
50467
50612
  setAllowedValueFields(possibleColumns.valueFields);
50468
50613
  }
50469
50614
  }, [columns, uniqueValues]);
50470
- useEffect27(() => {
50615
+ useEffect28(() => {
50471
50616
  setSortFieldInput(pivotSort?.sortField ?? "");
50472
50617
  setSortDirectionInput(pivotSort?.sortDirection ?? "");
50473
50618
  setShowSortInput(!!pivotSort);
50474
50619
  }, [pivotSort]);
50475
- useEffect27(() => {
50620
+ useEffect28(() => {
50476
50621
  setLimitInput(pivotLimit?.toString() ?? "");
50477
50622
  setShowLimitInput(!!pivotLimit);
50478
50623
  }, [pivotLimit]);
@@ -51084,7 +51229,7 @@ var AddPivot = ({
51084
51229
  };
51085
51230
 
51086
51231
  // src/components/ReportBuilder/AddLimitPopover.tsx
51087
- import { useState as useState34 } from "react";
51232
+ import { useState as useState35 } from "react";
51088
51233
  import { Fragment as Fragment14, jsx as jsx75, jsxs as jsxs55 } from "react/jsx-runtime";
51089
51234
  var LimitSentence = ({
51090
51235
  limit,
@@ -51099,7 +51244,7 @@ var LimitSentence = ({
51099
51244
  SecondaryButton = MemoizedSecondaryButton,
51100
51245
  disabled = false
51101
51246
  }) => {
51102
- const [isOpen, setIsOpen] = useState34(false);
51247
+ const [isOpen, setIsOpen] = useState35(false);
51103
51248
  const handleClickDelete = () => {
51104
51249
  setOpenPopover(null);
51105
51250
  handleDelete();
@@ -51141,7 +51286,7 @@ var AddLimitPopover = ({
51141
51286
  Button = MemoizedButton,
51142
51287
  SecondaryButton = MemoizedSecondaryButton
51143
51288
  }) => {
51144
- const [limit, setLimit] = useState34(initialLimit.toString());
51289
+ const [limit, setLimit] = useState35(initialLimit.toString());
51145
51290
  const MAX_LIMIT = 2147483647;
51146
51291
  return /* @__PURE__ */ jsxs55("div", { style: { display: "flex", flexDirection: "column", gap: 12 }, children: [
51147
51292
  /* @__PURE__ */ jsx75(
@@ -51382,7 +51527,7 @@ var AddLimit = ({
51382
51527
  };
51383
51528
 
51384
51529
  // src/components/ReportBuilder/AddSortPopover.tsx
51385
- import { useState as useState35 } from "react";
51530
+ import { useState as useState36 } from "react";
51386
51531
  init_textProcessing();
51387
51532
  import { Fragment as Fragment15, jsx as jsx77, jsxs as jsxs57 } from "react/jsx-runtime";
51388
51533
  var SORT_VALUE_TO_LABEL = {
@@ -51406,7 +51551,7 @@ var SortSentence = ({
51406
51551
  SecondaryButton = MemoizedSecondaryButton,
51407
51552
  disabled = false
51408
51553
  }) => {
51409
- const [isOpen, setIsOpen] = useState35(false);
51554
+ const [isOpen, setIsOpen] = useState36(false);
51410
51555
  const handleSetIsOpen = (isOpen2) => {
51411
51556
  setIsOpen(isOpen2);
51412
51557
  };
@@ -51458,8 +51603,8 @@ var AddSortPopover = ({
51458
51603
  Button = MemoizedButton,
51459
51604
  SecondaryButton = MemoizedSecondaryButton
51460
51605
  }) => {
51461
- const [sortColumn, setSortColumn] = useState35(column || "");
51462
- const [sortDirection, setSortDirection] = useState35(
51606
+ const [sortColumn, setSortColumn] = useState36(column || "");
51607
+ const [sortDirection, setSortDirection] = useState36(
51463
51608
  direction || "ASC"
51464
51609
  );
51465
51610
  return /* @__PURE__ */ jsxs57("div", { style: { display: "flex", flexDirection: "column", gap: 12 }, children: [
@@ -51940,12 +52085,11 @@ function ReportBuilder({
51940
52085
  const [theme] = useContext32(ThemeContext);
51941
52086
  const [client] = useContext32(ClientContext);
51942
52087
  const { getToken } = useContext32(FetchContext);
51943
- const parentRef = useRef20(null);
51944
- const askAIContainerRef = useRef20(null);
51945
- const [askAIInputWidth, setAskAIInputWidth] = useState36(-1);
51946
- const [isCopying, setIsCopying] = useState36(false);
51947
- const [isChartBuilderOpen, setIsChartBuilderOpen] = useState36(false);
51948
- const [isSaveQueryModalOpen, setIsSaveQueryModalOpen] = useState36(false);
52088
+ const parentRef = useRef21(null);
52089
+ const askAIFormRef = useRef21(null);
52090
+ const [isCopying, setIsCopying] = useState37(false);
52091
+ const [isChartBuilderOpen, setIsChartBuilderOpen] = useState37(false);
52092
+ const [isSaveQueryModalOpen, setIsSaveQueryModalOpen] = useState37(false);
51949
52093
  const reportBuilder = useReportBuilderInternal({
51950
52094
  reportId,
51951
52095
  initialTableName,
@@ -51985,6 +52129,12 @@ function ReportBuilder({
51985
52129
  onSaveQuery,
51986
52130
  onSaveReport
51987
52131
  } = reportBuilder;
52132
+ const askAIInputWidth = useResponsiveFirstChildWidth_default(askAIFormRef, {
52133
+ gap: 12,
52134
+ initialWidth: 320,
52135
+ minWidth: 160
52136
+ });
52137
+ const normalizedAskAIInputWidth = askAIInputWidth > 0 ? askAIInputWidth : 160;
51988
52138
  const copySQLToClipboard = async () => {
51989
52139
  let query = "";
51990
52140
  if (pivot && pivotData) {
@@ -52007,17 +52157,7 @@ function ReportBuilder({
52007
52157
  setTimeout(() => setIsCopying(false), 800);
52008
52158
  }
52009
52159
  };
52010
- useEffect28(() => {
52011
- function handleResize() {
52012
- updateFirstChildWidth(askAIContainerRef, setAskAIInputWidth, { gap: 12 });
52013
- }
52014
- handleResize();
52015
- window.addEventListener("resize", handleResize);
52016
- return () => {
52017
- window.removeEventListener("resize", handleResize);
52018
- };
52019
- }, []);
52020
- useEffect28(() => {
52160
+ useEffect29(() => {
52021
52161
  if (isChartBuilderOpen === false) {
52022
52162
  onCloseChartBuilder && onCloseChartBuilder();
52023
52163
  }
@@ -52135,10 +52275,10 @@ function ReportBuilder({
52135
52275
  /* @__PURE__ */ jsx81("div", { style: { width: "100%", minHeight: "30vh" } })
52136
52276
  ] }),
52137
52277
  /* @__PURE__ */ jsxs60(ContainerComponent, { children: [
52138
- isAIEnabled && /* @__PURE__ */ jsx81(
52278
+ isAIEnabled && /* @__PURE__ */ jsxs60(
52139
52279
  "form",
52140
52280
  {
52141
- ref: askAIContainerRef,
52281
+ ref: askAIFormRef,
52142
52282
  onSubmit: (event) => {
52143
52283
  event.preventDefault();
52144
52284
  },
@@ -52146,15 +52286,17 @@ function ReportBuilder({
52146
52286
  display: "flex",
52147
52287
  flexDirection: "row",
52148
52288
  gap: 12,
52149
- visibility: askAIInputWidth === -1 ? "hidden" : "visible"
52289
+ flexWrap: "wrap",
52290
+ alignItems: "stretch",
52291
+ visibility: normalizedAskAIInputWidth > 0 ? "visible" : "hidden"
52150
52292
  },
52151
- children: /* @__PURE__ */ jsxs60(Fragment16, { children: [
52293
+ children: [
52152
52294
  /* @__PURE__ */ jsx81(
52153
52295
  TextInputComponent,
52154
52296
  {
52155
52297
  id: "ask_ai_input_bar",
52156
52298
  value: aiPrompt,
52157
- width: askAIInputWidth,
52299
+ width: normalizedAskAIInputWidth,
52158
52300
  onChange: (e) => setAiPrompt(e.target.value),
52159
52301
  placeholder: "Ask a question..."
52160
52302
  }
@@ -52192,7 +52334,7 @@ function ReportBuilder({
52192
52334
  disabled: columns.length === 0 || loading
52193
52335
  }
52194
52336
  )
52195
- ] })
52337
+ ]
52196
52338
  }
52197
52339
  ),
52198
52340
  columns.length > 0 && /* @__PURE__ */ jsx81(
@@ -52449,10 +52591,10 @@ function ReportBuilder({
52449
52591
  // src/ChartEditor.tsx
52450
52592
  import {
52451
52593
  useContext as useContext33,
52452
- useEffect as useEffect29,
52594
+ useEffect as useEffect30,
52453
52595
  useMemo as useMemo26,
52454
- useRef as useRef21,
52455
- useState as useState37
52596
+ useRef as useRef22,
52597
+ useState as useState38
52456
52598
  } from "react";
52457
52599
  import { jsx as jsx82 } from "react/jsx-runtime";
52458
52600
  function ChartEditor({
@@ -52500,9 +52642,9 @@ function ChartEditor({
52500
52642
  onClickChartElement,
52501
52643
  onClickChartError
52502
52644
  }) {
52503
- const parentRef = useRef21(null);
52504
- const [modalWidth, setModalWidth] = useState37(200);
52505
- const [modalHeight, setModalHeight] = useState37(200);
52645
+ const parentRef = useRef22(null);
52646
+ const [modalWidth, setModalWidth] = useState38(200);
52647
+ const [modalHeight, setModalHeight] = useState38(200);
52506
52648
  const { addReport } = useDashboardReports(destinationDashboard);
52507
52649
  const { allReportsById } = useAllReports();
52508
52650
  const { tenants, flags } = useContext33(TenantContext);
@@ -52520,15 +52662,15 @@ function ChartEditor({
52520
52662
  (f) => f.filter
52521
52663
  );
52522
52664
  }, [dashboardFilters]);
52523
- const [filtersEnabled, setFiltersEnabled] = useState37(true);
52524
- const [chartBuilderKey, setChartBuilderKey] = useState37(0);
52665
+ const [filtersEnabled, setFiltersEnabled] = useState38(true);
52666
+ const [chartBuilderKey, setChartBuilderKey] = useState38(0);
52525
52667
  const dateFilter = Object.values(specificDashboardFilters).find(
52526
52668
  (filter) => filter.filterType === "date_range"
52527
52669
  );
52528
52670
  const dateRange = useMemo26(() => {
52529
52671
  return dateFilter?.startDate ? { start: dateFilter.startDate, end: dateFilter.endDate } : void 0;
52530
52672
  }, [dateFilter]);
52531
- useEffect29(() => {
52673
+ useEffect30(() => {
52532
52674
  function handleResize() {
52533
52675
  const screenSize = window.innerWidth;
52534
52676
  if (screenSize >= 1200) {
@@ -52576,7 +52718,7 @@ function ChartEditor({
52576
52718
  }
52577
52719
  addReport(report2);
52578
52720
  };
52579
- useEffect29(() => {
52721
+ useEffect30(() => {
52580
52722
  if (!isClientLoading && !report) {
52581
52723
  fetchReportHelper();
52582
52724
  }
@@ -52724,7 +52866,7 @@ function StaticChart({
52724
52866
  init_valueFormatter();
52725
52867
 
52726
52868
  // src/hooks/useTenants.ts
52727
- import { useContext as useContext34, useEffect as useEffect30 } from "react";
52869
+ import { useContext as useContext34, useEffect as useEffect31 } from "react";
52728
52870
  var useTenants = (dashboardName) => {
52729
52871
  const {
52730
52872
  tenants,
@@ -52738,12 +52880,12 @@ var useTenants = (dashboardName) => {
52738
52880
  getMappedTenantsForDashboard,
52739
52881
  getViewerTenantsByOwner
52740
52882
  } = useContext34(TenantContext);
52741
- useEffect30(() => {
52883
+ useEffect31(() => {
52742
52884
  if (dashboardName) {
52743
52885
  fetchViewerTenantsForDashboard(dashboardName);
52744
52886
  }
52745
52887
  }, [dashboardName, fetchViewerTenantsForDashboard]);
52746
- useEffect30(() => {
52888
+ useEffect31(() => {
52747
52889
  if (dashboardName) {
52748
52890
  fetchMappedTenantsForDashboard(dashboardName);
52749
52891
  }
@@ -52762,7 +52904,7 @@ var useTenants = (dashboardName) => {
52762
52904
  };
52763
52905
 
52764
52906
  // src/hooks/useQuill.ts
52765
- import { useContext as useContext35, useEffect as useEffect31, useMemo as useMemo27, useState as useState38 } from "react";
52907
+ import { useContext as useContext35, useEffect as useEffect32, useMemo as useMemo27, useState as useState39 } from "react";
52766
52908
  init_paginationProcessing();
52767
52909
  init_tableProcessing();
52768
52910
  init_dataProcessing();
@@ -52785,9 +52927,9 @@ var useQuill = (reportId, pagination) => {
52785
52927
  const [client, isClientLoading] = useContext35(ClientContext);
52786
52928
  const { tenants } = useContext35(TenantContext);
52787
52929
  const { eventTracking } = useContext35(EventTrackingContext);
52788
- const [loading, setLoading] = useState38(true);
52789
- const [error, setError] = useState38(void 0);
52790
- const [previousPage, setPreviousPage] = useState38(0);
52930
+ const [loading, setLoading] = useState39(true);
52931
+ const [error, setError] = useState39(void 0);
52932
+ const [previousPage, setPreviousPage] = useState39(0);
52791
52933
  const processedReport = useMemo27(() => {
52792
52934
  return reportId && allReportsById[reportId] ? convertInternalReportToReport(
52793
52935
  mergeComparisonRange(allReportsById[reportId]),
@@ -52796,7 +52938,7 @@ var useQuill = (reportId, pagination) => {
52796
52938
  "useQuill"
52797
52939
  ) : void 0;
52798
52940
  }, [reportId, reportId && allReportsById[reportId], specificReportFilters]);
52799
- const [additionalProcessing, setAdditionProcessing] = useState38(
52941
+ const [additionalProcessing, setAdditionProcessing] = useState39(
52800
52942
  pagination ? {
52801
52943
  page: pagination
52802
52944
  } : void 0
@@ -52945,7 +53087,7 @@ var useQuill = (reportId, pagination) => {
52945
53087
  setLoading(false);
52946
53088
  }
52947
53089
  };
52948
- useEffect31(() => {
53090
+ useEffect32(() => {
52949
53091
  if (isClientLoading) return;
52950
53092
  if (reportId && specificReportFilters) {
52951
53093
  fetchReportHelper(reportId, {
@@ -53012,7 +53154,7 @@ var useMemoizedRows = (reportId) => {
53012
53154
  };
53013
53155
 
53014
53156
  // src/hooks/useAskQuill.tsx
53015
- import { useContext as useContext36, useEffect as useEffect32, useState as useState39 } from "react";
53157
+ import { useContext as useContext36, useEffect as useEffect33, useState as useState40 } from "react";
53016
53158
  init_astProcessing();
53017
53159
  init_astFilterProcessing();
53018
53160
  init_pivotProcessing();
@@ -53045,8 +53187,8 @@ var useAskQuill = (dashboardName) => {
53045
53187
  const { tenants } = useContext36(TenantContext);
53046
53188
  const { getToken } = useContext36(FetchContext);
53047
53189
  const { eventTracking } = useContext36(EventTrackingContext);
53048
- const [astInfo, setAstInfo] = useState39(void 0);
53049
- const [data, setData] = useState39({
53190
+ const [astInfo, setAstInfo] = useState40(void 0);
53191
+ const [data, setData] = useState40({
53050
53192
  rows: [],
53051
53193
  columns: [],
53052
53194
  pivot: null,
@@ -53056,9 +53198,9 @@ var useAskQuill = (dashboardName) => {
53056
53198
  pivotColumnFields: [],
53057
53199
  pivotValueFields: []
53058
53200
  });
53059
- const [loading, setLoading] = useState39(false);
53060
- const [error, setError] = useState39(void 0);
53061
- const [ask, setAsk] = useState39(
53201
+ const [loading, setLoading] = useState40(false);
53202
+ const [error, setError] = useState40(void 0);
53203
+ const [ask, setAsk] = useState40(
53062
53204
  async () => void 0
53063
53205
  );
53064
53206
  const askHelper = async (query) => {
@@ -53258,7 +53400,7 @@ var useAskQuill = (dashboardName) => {
53258
53400
  });
53259
53401
  setLoading(false);
53260
53402
  };
53261
- useEffect32(() => {
53403
+ useEffect33(() => {
53262
53404
  setAsk(() => askHelper);
53263
53405
  }, [schemaData.schema]);
53264
53406
  return {
@@ -53272,13 +53414,13 @@ var useAskQuill = (dashboardName) => {
53272
53414
  };
53273
53415
 
53274
53416
  // src/hooks/useVirtualTables.tsx
53275
- import { useContext as useContext37, useState as useState40 } from "react";
53417
+ import { useContext as useContext37, useState as useState41 } from "react";
53276
53418
  var useVirtualTables = () => {
53277
53419
  const [schemaData, setSchemaData] = useContext37(SchemaDataContext);
53278
53420
  const { tenants } = useContext37(TenantContext);
53279
53421
  const { getToken, quillFetchWithToken } = useContext37(FetchContext);
53280
53422
  const { eventTracking } = useContext37(EventTrackingContext);
53281
- const [loadingTables, setLoadingTables] = useState40({});
53423
+ const [loadingTables, setLoadingTables] = useState41({});
53282
53424
  const handleReload = async (client, caller) => {
53283
53425
  setSchemaData({ ...schemaData, isSchemaLoading: true });
53284
53426
  setLoadingTables(