{"version":3,"file":"pv-components-visualizations.mjs","names":["$slots","computePosition","flip","offset","shift","getComputedStyle","unwrapElement","toValue","$props","$emit","$attrs","$attrs","$emit","$emit","$slots","$emit","$slots","$slots","$attrs","$emit","$slots","$slots","$attrs","$emit","$slots","$emit","$emit","$emit","$props"],"sources":["../../../src/components/charts/themes.ts","../../../src/functions/colorPalette.ts","../../../src/functions/colorThemes.ts","../../../src/components/base/PvSpinner/PvSpinner.vue","../../../src/components/base/PvSpinner/PvSpinner.vue","../../../src/functions/loadAgCharts.ts","../../../src/functions/formatting.ts","../../../src/components/charts/PvChart/constants.ts","../../../src/components/charts/PvChart/functions.ts","../../../src/components/charts/PvChart/PvChart.vue","../../../src/components/charts/PvChart/PvChart.vue","../../../src/components/charts/widgetOptions.ts","../../../src/components/charts/PvChartWidget/PvChartWidget.vue","../../../src/components/charts/PvChartWidget/PvChartWidget.vue","../../../src/components/base/PvCard/PvCard.vue","../../../src/components/base/PvCard/PvCard.vue","../../../src/components/base/PvButton/helpers.ts","../../../src/web-components/utils.ts","../../../src/components/base/baseProps.ts","../../../src/components/base/PvIcon/PvIcon.vue","../../../src/components/base/PvIcon/PvIcon.vue","../../../src/components/base/PvCounterBadge/PvCounterBadge.vue","../../../src/components/base/PvCounterBadge/PvCounterBadge.vue","../../../src/components/base/PvButton/PvButton.vue","../../../src/components/base/PvButton/PvButton.vue","../../../../node_modules/.pnpm/@floating-ui+utils@0.2.11/node_modules/@floating-ui/utils/dist/floating-ui.utils.mjs","../../../../node_modules/.pnpm/@floating-ui+core@1.7.5/node_modules/@floating-ui/core/dist/floating-ui.core.mjs","../../../../node_modules/.pnpm/@floating-ui+utils@0.2.11/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.mjs","../../../../node_modules/.pnpm/@floating-ui+dom@1.7.6/node_modules/@floating-ui/dom/dist/floating-ui.dom.mjs","../../../../node_modules/.pnpm/vue-demi@0.14.10_vue@3.5.32_typescript@5.9.3_/node_modules/vue-demi/lib/index.mjs","../../../../node_modules/.pnpm/@floating-ui+vue@1.1.11_vue@3.5.32_typescript@5.9.3_/node_modules/@floating-ui/vue/dist/floating-ui.vue.mjs","../../../src/composables/useSlotPresence.ts","../../../src/components/base/PvPopoverV2/useHoverPopoverGroup.ts","../../../src/components/base/PvPopoverV2/PvPopoverV2.vue","../../../src/components/base/PvPopoverV2/PvPopoverV2.vue","../../../src/components/base/PvTooltipV2/PvTooltipV2.vue","../../../src/components/base/PvTooltipV2/PvTooltipV2.vue","../../../src/components/base/PvSegmentedControl/PvSegmentedControl.vue","../../../src/components/base/PvSegmentedControl/PvSegmentedControl.vue","../../../src/components/charts/chart-components/maps/topologies/hawaiiStateTopology.ts","../../../src/components/charts/chart-components/maps/topologies/alaskaStateTopology.ts","../../../src/components/charts/chart-components/maps/topologies/usStateTopology.ts","../../../src/components/charts/chart-components/maps/useTopology.ts","../../../src/components/charts/chart-components/maps/MapGradient.vue","../../../src/components/charts/chart-components/maps/MapGradient.vue","../../../src/components/base/PvSearchInput/PvSearchInput.vue","../../../src/components/base/PvSearchInput/PvSearchInput.vue","../../../src/components/base/PvCompanyLogo/PvCompanyLogo.vue","../../../src/components/base/PvCompanyLogo/PvCompanyLogo.vue","../../../src/components/base/PvAvatar/PvAvatar.vue","../../../src/components/base/PvAvatar/PvAvatar.vue","../../../src/components/base/PvTooltip/PvTooltip.vue","../../../src/components/base/PvTooltip/PvTooltip.vue","../../../src/components/base/PvSelectButton/PvSelectButtonTrigger/PvSelectButtonTrigger.vue","../../../src/components/base/PvSelectButton/PvSelectButtonTrigger/PvSelectButtonTrigger.vue","../../../src/components/base/PvMenu/PvMenuEmptyState.vue","../../../src/components/base/PvMenu/cascadeUtils.ts","../../../src/components/base/PvMenu/items/PvMenuBaseItem.vue","../../../src/components/base/PvMenu/items/PvMenuBaseItem.vue","../../../src/components/base/PvSwitch/PvSwitch.vue","../../../src/components/base/PvSwitch/PvSwitch.vue","../../../src/components/base/PvActionButton/PvActionButton.vue","../../../src/components/base/PvActionButton/PvActionButton.vue","../../../src/components/base/PvMenu/items/PvMenuItemAction.vue","../../../src/components/base/PvMenu/items/PvMenuItemAction.vue","../../../src/components/base/PvMenu/symbols.ts","../../../src/components/base/PvMenu/items/PvMenuItemVariant.vue","../../../src/components/base/PvMenu/items/PvMenuItemVariant.vue","../../../src/components/base/PvMenu/items/PvMenuItem.vue","../../../src/components/base/PvMenu/items/PvMenuItem.vue","../../../src/components/base/PvPopover/PvPopover.vue","../../../src/components/base/PvPopover/PvPopover.vue","../../../src/components/base/PvMenu/PvMenu.vue","../../../src/components/base/PvMenu/PvMenu.vue","../../../src/components/base/PvSelectButton/PvSelectButton.vue","../../../src/components/base/PvSelectButton/PvSelectButton.vue","../../../src/components/charts/chart-components/maps/MapRegionSelector.vue","../../../src/components/charts/chart-components/maps/MapRegionSelector.vue","../../../src/components/charts/PvMapChart/PvMapChart.vue","../../../src/components/charts/PvMapChart/PvMapChart.vue","../../../src/components/charts/PvDataWidget/PvDataWidgetTable.vue","../../../src/components/charts/PvDataWidget/PvDataWidgetTable.vue","../../../src/components/charts/PvDataWidget/constants.ts","../../../src/components/charts/PvDataTableWithChart/constants.ts","../../../src/components/tables/PvDataTable/table-components/formatting.ts","../../../src/components/tables/PvDataTable/helpers.ts","../../../src/components/charts/PvDataTableWithChart/helpers.ts","../../../src/components/charts/PvDataWidget/helpers.ts","../../../src/components/charts/PvDataWidget/PvDataWidget.vue","../../../src/components/charts/PvDataWidget/PvDataWidget.vue","../../../src/components/base/PvDropdown/PvDropdown.vue","../../../src/components/base/PvDropdown/PvDropdown.vue","../../../src/components/base/PvTag/PvTag.vue","../../../src/components/base/PvTag/PvTag.vue","../../../src/components/base/PvModal/PvModal.vue","../../../src/components/base/PvModal/PvModal.vue","../../../src/components/base/PvBanner/types.ts","../../../src/components/base/PvBanner/PvBanner.vue","../../../src/components/base/PvSuggestionTag/PvSuggestionTag.vue","../../../src/components/base/PvSuggestionTag/PvSuggestionTag.vue","../../../src/components/base/PvDateTime/useDateTime.ts","../../../src/composables/useResizable.ts","../../../src/components/base/PvResizeHandle/PvResizeHandle.vue","../../../src/components/base/PvResizeHandle/PvResizeHandle.vue","../../../src/components/base/PvDrawer/PvDrawer.vue","../../../src/components/base/PvDrawer/PvDrawer.vue","../../../src/components/base/PvTextArea/PvTextArea.vue","../../../src/components/base/PvMenu/PvMenuControlPanel.vue","../../../src/components/base/PvMenu/PvMenuControlPanel.vue","../../../src/components/base/PvMultiSelectButton/PvMultiSelectButton.vue","../../../src/components/base/PvMultiSelectButton/PvMultiSelectButton.vue","../../../src/components/base/PvInput/PvInput.vue","../../../src/components/base/PvSortableList/PvSortableList.vue","../../../src/components/base/PvSortableList/PvSortableList.vue","../../../src/components/base/PvPagination/usePagination.ts","../../../src/components/base/PvPagination/PvPagination.vue","../../../src/components/base/PvPagination/PvPagination.vue","../../../src/components/base/PvSkeleton/PvSkeleton.vue","../../../src/components/base/PvSkeleton/PvSkeleton.vue","../../../src/components/base/PvBoxPlot/helpers.ts","../../../src/components/base/PvFilterPanel/filterOptionValue.ts","../../../src/components/base/PvFilterPanel/filterOptionDisplay.ts","../../../src/components/base/PvFilterPanel/aggregateFilterModel.ts","../../../src/functions/filterSearchDisplay.ts","../../../src/components/base/PvFilterPanel/usePvFilterStore.ts","../../../src/components/base/PvQueryBuilderInput/useQueryBuilder.ts","../../../src/components/base/PvQueryBuilderInput/QueryFormatter.vue","../../../src/components/base/PvQueryBuilderInput/QueryFormatter.vue","../../../src/components/base/PvQueryBuilderInput/PvQueryBuilderInput.vue","../../../src/components/base/PvQueryBuilderInput/PvQueryBuilderInput.vue","../../../src/components/base/PvMenu/useMenuPosition.ts","../../../src/composables/useColorTheme.ts","../../../src/composables/useCustomColorTheme.ts","../../../src/functions/imageColors.ts","../../../src/composables/useImageColors.ts","../../../src/functions/rum.ts","../../../src/components/tables/symbols.ts","../../../src/components/tables/PvDataTable/table-components/GroupBySelector.vue","../../../src/components/tables/PvDataTable/table-components/GroupBySelector.vue","../../../src/components/tables/PvDataTable/table-components/RowLoadingCellRenderer.vue","../../../src/components/tables/PvDataTable/table-components/ColDefCellRenderer.vue","../../../src/components/tables/PvDataTable/table-components/ColDefCellRenderer.vue","../../../src/components/tables/PvDataTable/useFocus.ts","../../../src/components/tables/PvDataTable/table-components/GroupedCellRenderer.vue","../../../src/components/tables/PvDataTable/table-components/GroupedCellRenderer.vue","../../../src/components/tables/PvDataTable/table-components/AutoGroupColDefRenderer.vue","../../../src/components/tables/PvDataTable/table-components/AutoGroupColDefRenderer.vue","../../../src/functions/aggregations.ts","../../../src/components/tables/PvDataTable/table-components/GroupAggCellRenderer.vue","../../../src/components/tables/PvDataTable/table-components/GroupAggCellRenderer.vue","../../../src/components/tables/PvDataTable/filters/filterHelpers.ts","../../../src/components/tables/PvDataTable/useFilterStore.ts","../../../src/components/tables/PvDataTable/useSetFilter.ts","../../../src/components/tables/PvDataTable/table-components/FilterGroupMenu.vue","../../../src/components/tables/PvDataTable/table-components/FilterGroupMenu.vue","../../../src/components/tables/PvDataTable/table-components/SetFilter.vue","../../../src/components/tables/PvDataTable/table-components/SetFilter.vue","../../../src/components/tables/PvDataTable/table-components/horizontalFilterFit.ts","../../../src/components/tables/PvDataTable/table-components/FilterPanel.vue","../../../src/components/tables/PvDataTable/table-components/FilterPanel.vue","../../../src/components/tables/PvDataTable/table-components/HeaderCellRenderer.vue","../../../src/components/tables/PvDataTable/table-components/HeaderCellRenderer.vue","../../../src/components/tables/themes.ts","../../../src/components/tables/PvDataTable/table-components/ExportMenu.vue","../../../src/components/tables/PvDataTable/table-components/ExportMenu.vue","../../../src/components/tables/PvDataTable/table-components/PaginationPanel.vue","../../../src/components/tables/PvDataTable/table-components/PaginationPanel.vue","../../../src/components/tables/PvDataTable/useGridSizing.ts","../../../src/components/tables/PvDataTable/table-components/PivotTableSkeleton.vue","../../../src/components/tables/PvDataTable/table-components/PivotTableSkeleton.vue","../../../src/components/tables/PvDataTable/table-components/TagCellRenderer.vue","../../../src/components/tables/PvDataTable/table-components/TagCellRenderer.vue","../../../src/components/tables/PvDataTable/table-components/RowCountCellRenderer.vue","../../../src/components/tables/PvDataTable/table-components/RowCountCellRenderer.vue","../../../src/components/tables/PvDataTable/table-components/TableSearch.vue","../../../src/components/tables/PvDataTable/table-components/TableSearch.vue","../../../src/components/tables/PvDataTable/table-components/PvPivotGroupHeader.vue","../../../src/components/tables/PvDataTable/table-components/PvPivotGroupHeader.vue","../../../src/components/tables/PvDataTable/table-components/TableTooltip.vue","../../../src/components/tables/PvDataTable/table-components/TableTooltip.vue","../../../src/components/tables/PvDataTable/PvDataTable.vue","../../../src/components/tables/PvDataTable/PvDataTable.vue","../../../src/components/charts/PvDataTableWithChart/table-chart-components/PvTableOverlayMenuItemRenderer.vue","../../../src/components/charts/PvDataTableWithChart/table-chart-components/PvTableOverlayMenuItemRenderer.vue","../../../src/components/charts/PvDataTableWithChart/table-chart-components/PvTableOptionsPanel.vue","../../../src/components/charts/PvDataTableWithChart/table-chart-components/PvTableOptionsPanel.vue","../../../src/components/charts/PvDataTableWithChart/table-chart-components/PvBenchmarkChips.vue","../../../src/components/charts/PvDataTableWithChart/table-chart-components/PvBenchmarkChips.vue","../../../src/components/charts/PvDataTableWithChart/chartTypeRegistry.ts","../../../src/components/charts/PvDataTableWithChart/table-chart-components/PvChartOptionsPanel.vue","../../../src/components/charts/PvDataTableWithChart/table-chart-components/PvChartOptionsPanel.vue","../../../src/components/charts/PvDataTableWithChart/scatterAxisUtils.ts","../../../src/components/charts/PvDataTableWithChart/crosslineHelpers.ts","../../../src/components/charts/PvDataTableWithChart/useBenchmarkOverlays.ts","../../../src/components/charts/PvDataTableWithChart/PvDataTableWithChart.vue","../../../src/components/charts/PvDataTableWithChart/PvDataTableWithChart.vue","../../../src/components/charts/PvDataWidget/usePvDataWidgetData.ts"],"sourcesContent":["import type { AgChartTheme, AgChartThemeParams, AgThemeOverrides, CssColor } from \"ag-charts-enterprise\";\n\nconst monochromeFills: CssColor[] = [\n  \"#49EADE\",\n  \"#33DED1\",\n  \"#36C5BA\",\n  \"#2CA8A1\",\n  \"#218C88\",\n  \"#176F6F\",\n  \"#0D5256\",\n  \"#02363D\",\n  \"#01262B\",\n];\n\nexport const multicolorFills: CssColor[] = [\n  \"#009999CC\",\n  \"#16696D\",\n  \"#FF7A4E\",\n  \"#C97AEB\",\n  \"#F2AD0D\",\n  \"#7C8AF4\",\n  \"#95C54C\",\n  \"#E34F8C\",\n  \"#2FB85A\",\n  \"#FB9C0D\",\n  \"#4D9FF2\",\n  \"#9C5CF2\",\n  \"#78DDE6\",\n  \"#E85E33\",\n  \"#3E83E4\",\n];\n\nexport const SCATTER_MARKER_STROKE = \"#7C8AF4\";\nconst SCATTER_MARKER_FILL = \"#FFFFFF\";\nconst SCATTER_MARKER_SIZE = 12;\nconst SCATTER_MARKER_STROKE_WIDTH = 4;\n\n// Scatter markers are white with a colored outline; hovering fills the marker with that color.\n// Without a color, each series is outlined in its own palette color and keeps AG's hover style.\nfunction createScatterOverrides(color?: string): AgThemeOverrides[\"scatter\"] {\n  return {\n    series: {\n      size: SCATTER_MARKER_SIZE,\n      fill: SCATTER_MARKER_FILL,\n      strokeWidth: SCATTER_MARKER_STROKE_WIDTH,\n      ...(color && {\n        stroke: color,\n        highlightStyle: {\n          item: {\n            fill: color,\n            stroke: color,\n            strokeWidth: SCATTER_MARKER_STROKE_WIDTH,\n          },\n        },\n      }),\n    },\n  };\n}\n\nconst baseOverrides: AgThemeOverrides = {\n  common: {\n    title: {\n      enabled: false,\n    },\n    zoom: {\n      enabled: false,\n    },\n    seriesArea: {\n      padding: {\n        bottom: 10,\n      },\n    },\n    axes: {\n      number: {\n        crosshair: {\n          enabled: true,\n        },\n        label: {\n          enabled: true,\n        },\n      },\n      category: {\n        crosshair: {\n          enabled: false,\n        },\n        label: {\n          autoRotate: true,\n        },\n      },\n    },\n    legend: {\n      toggleSeries: false,\n      preventHidingAll: true,\n    },\n  },\n  bar: {\n    series: {\n      cornerRadius: 6,\n      highlight: {\n        highlightedItem: {\n          fillOpacity: 1,\n        },\n        unhighlightedSeries: {\n          opacity: 0.2,\n        },\n      },\n    },\n  },\n  scatter: createScatterOverrides(SCATTER_MARKER_STROKE),\n};\n\nconst baseParams: AgChartThemeParams = {\n  fontFamily: \"Inter, sans-serif\",\n  chromeFontFamily: \"Inter, sans-serif\",\n};\n\nexport const PitViperAGChartsMonochromeThemeName = \"pv-ag-chart-monochrome\";\nexport const PitViperAGChartsMonochromeTheme: AgChartTheme = {\n  palette: {\n    fills: monochromeFills,\n  },\n  overrides: baseOverrides,\n  params: baseParams,\n};\n\nexport const PitViperAGChartsMulticolorThemeName = \"pv-ag-chart-multicolor\";\nexport const PitViperAGChartsMulticolorTheme: AgChartTheme = {\n  palette: {\n    fills: multicolorFills,\n  },\n  overrides: baseOverrides,\n  params: baseParams,\n};\n\n/**\n * Build a Pit Viper AG Charts theme that uses the given series fills and keeps the rest of the\n * Pit Viper chart styling. Each scatter series is outlined in its own palette color.\n * An empty list gives `PitViperAGChartsMulticolorTheme`.\n */\nexport const createPitViperAGChartsTheme = (fills: string[]): AgChartTheme => {\n  if (!fills.length) return PitViperAGChartsMulticolorTheme;\n  return {\n    // Without strokes, AG outlines series (e.g. scatter markers) in its own default colors.\n    palette: { fills, strokes: fills },\n    overrides: { ...baseOverrides, scatter: createScatterOverrides() },\n    params: baseParams,\n  };\n};\n","/**\n * Builds a 15-color chart palette from 1-4 picked colors.\n *\n * Works in OKLab/OKLCH so distances match what people see.\n * One pick gives a monochrome ramp; 2-4 picks are adjusted for readability on a\n * white chart, then the palette is filled by farthest-point selection from\n * hue families derived from the picks. Every adjustment adds a plain-language note.\n */\n\ntype Lab = [number, number, number];\ninterface Lch {\n  l: number;\n  c: number;\n  h: number;\n}\n\ninterface AdjustedPick {\n  lch: Lch;\n  neutral: boolean;\n  /** Original hex, kept when the pick needed no adjustment. */\n  keep?: string;\n}\n\nexport interface GeneratedColorPalette {\n  colors: string[];\n  /** Plain-language notes describing each adjustment, in order. */\n  notes: string[];\n  /**\n   * The same notes grouped by the picked color they are about: `pickNotes[0]` is about the first\n   * pick. Notes about the whole palette (e.g. all picks are gray) appear only in `notes`.\n   */\n  pickNotes: string[][];\n}\n\ntype AddNote = (message: string, pick?: number) => void;\n\nconst createNotes = (pickCount: number) => {\n  const notes: string[] = [];\n  const pickNotes: string[][] = Array.from({ length: pickCount }, () => []);\n  const add: AddNote = (message, pick) => {\n    notes.push(message);\n    if (pick !== undefined) pickNotes[pick].push(message);\n  };\n  return { notes, pickNotes, add };\n};\n\nexport const TURQUOISE_PRIMARY = \"#36C5BA\";\nexport const DEFAULT_PALETTE_SIZE = 15;\nexport const MAX_SOURCE_COLORS = 4;\nexport const MAX_PALETTE_SIZE = 64;\n\n/** Palette size as a whole number in 0-64. Non-numbers give the default size. */\nconst toPaletteSize = (count: number) =>\n  Number.isFinite(count) ? Math.min(Math.max(Math.floor(count), 0), MAX_PALETTE_SIZE) : DEFAULT_PALETTE_SIZE;\n\nconst MAX_LIGHTNESS = 0.8;\nconst MIN_CHROMA = 0.07;\nconst MAX_CHROMA = 0.2;\nconst NEUTRAL_CHROMA = 0.03;\nconst MIN_DISTANCE_PAIR = 0.16;\nconst MIN_DISTANCE_MULTI = 0.1;\nconst MIN_DISTANCE_BEFORE_HUE_ROTATE_MULTI = 0.06;\n// Hue families used when every pick is gray: teal, orange, purple, green.\nconst GRAY_FALLBACK_HUES = [195, 30, 280, 130];\n\nconst clamp = (value: number, min: number, max: number) => Math.min(max, Math.max(min, value));\n\n/** Normalizes `#abc`, `abc`, `#aabbcc` to uppercase `#AABBCC`. Returns null when invalid. */\nexport const normalizeHex = (value: string): string | null => {\n  let hex = value.trim().replace(/^#/, \"\");\n  if (/^[0-9a-fA-F]{3}$/.test(hex)) {\n    hex = hex\n      .split(\"\")\n      .map((char) => char + char)\n      .join(\"\");\n  }\n  return /^[0-9a-fA-F]{6}$/.test(hex) ? `#${hex.toUpperCase()}` : null;\n};\n\nconst srgbToLinear = (value: number) => (value <= 0.04045 ? value / 12.92 : ((value + 0.055) / 1.055) ** 2.4);\nconst linearToSrgb = (value: number) => (value <= 0.0031308 ? 12.92 * value : 1.055 * value ** (1 / 2.4) - 0.055);\n\nconst hexToOklab = (hex: string): Lab => {\n  const value = parseInt(hex.slice(1), 16);\n  const r = srgbToLinear(((value >> 16) & 255) / 255);\n  const g = srgbToLinear(((value >> 8) & 255) / 255);\n  const b = srgbToLinear((value & 255) / 255);\n  const l = Math.cbrt(0.4122214708 * r + 0.5363325363 * g + 0.0514459929 * b);\n  const m = Math.cbrt(0.2119034982 * r + 0.6806995451 * g + 0.1073969566 * b);\n  const s = Math.cbrt(0.0883024619 * r + 0.2817188376 * g + 0.6299787005 * b);\n  return [\n    0.2104542553 * l + 0.793617785 * m - 0.0040720468 * s,\n    1.9779984951 * l - 2.428592205 * m + 0.4505937099 * s,\n    0.0259040371 * l + 0.7827717662 * m - 0.808675766 * s,\n  ];\n};\n\nconst oklabToOklch = ([l, a, b]: Lab): Lch => ({\n  l,\n  c: Math.hypot(a, b),\n  h: ((Math.atan2(b, a) * 180) / Math.PI + 360) % 360,\n});\n\nconst oklchToOklab = ({ l, c, h }: Lch): Lab => [\n  l,\n  c * Math.cos((h * Math.PI) / 180),\n  c * Math.sin((h * Math.PI) / 180),\n];\n\nconst oklabToLinearRgb = ([l, a, b]: Lab): Lab => {\n  const l3 = (l + 0.3963377774 * a + 0.2158037573 * b) ** 3;\n  const m3 = (l - 0.1055613458 * a - 0.0638541728 * b) ** 3;\n  const s3 = (l - 0.0894841775 * a - 1.291485548 * b) ** 3;\n  return [\n    4.0767416621 * l3 - 3.3077115913 * m3 + 0.2309699292 * s3,\n    -1.2684380046 * l3 + 2.6097574011 * m3 - 0.3413193965 * s3,\n    -0.0041960863 * l3 - 0.7034186147 * m3 + 1.707614701 * s3,\n  ];\n};\n\nconst inGamut = (rgb: Lab) => rgb.every((channel) => channel >= -5e-4 && channel <= 1.0005);\n\n// Lowers chroma until the color fits in sRGB.\nconst clampChroma = (lch: Lch): Lch => {\n  let { c } = lch;\n  while (c > 0 && !inGamut(oklabToLinearRgb(oklchToOklab({ ...lch, c })))) {\n    c -= 0.004;\n  }\n  return { ...lch, c: Math.max(0, c) };\n};\n\nconst oklchToHex = (lch: Lch): string =>\n  \"#\" +\n  oklabToLinearRgb(oklchToOklab(clampChroma(lch)))\n    .map((channel) => Math.round(clamp(linearToSrgb(clamp(channel, 0, 1)), 0, 1) * 255))\n    .map((channel) => channel.toString(16).padStart(2, \"0\"))\n    .join(\"\")\n    .toUpperCase();\n\nconst labDistance = (a: Lab, b: Lab) => Math.hypot(a[0] - b[0], a[1] - b[1], a[2] - b[2]);\n\n/** Perceptual (OKLab) distance between two `#RRGGBB` colors. About 0.02 is a just-noticeable difference. */\nexport const colorDistance = (a: string, b: string): number => labDistance(hexToOklab(a), hexToOklab(b));\n\nconst hueDistance = (a: number, b: number) => {\n  const distance = Math.abs(a - b) % 360;\n  return distance > 180 ? 360 - distance : distance;\n};\n\nconst wrapHue = (hue: number) => ((hue % 360) + 360) % 360;\n\n// Yellows and greens need more lightness to read as their hue.\nconst minLightness = (hue: number) => (hue >= 75 && hue <= 125 ? 0.68 : 0.42);\n\nconst adjustPick = (hex: string, name: string, addNote: (message: string) => void): AdjustedPick => {\n  const original = oklabToOklch(hexToOklab(hex));\n  const neutral = original.c < NEUTRAL_CHROMA;\n  const lch = { ...original };\n  const reasons: string[] = [];\n  const lightnessFloor = neutral ? 0.38 : minLightness(original.h);\n\n  if (original.l < lightnessFloor) {\n    lch.l = lightnessFloor;\n    reasons.push(\"too dark to read on a white chart\");\n  } else if (original.l > MAX_LIGHTNESS) {\n    lch.l = MAX_LIGHTNESS;\n    reasons.push(\"too light to read on a white chart\");\n  }\n\n  if (!neutral) {\n    if (original.c < MIN_CHROMA) {\n      lch.c = MIN_CHROMA;\n      reasons.push(\"too dull next to the other colors\");\n    } else if (original.c > MAX_CHROMA) {\n      lch.c = MAX_CHROMA;\n      reasons.push(\"too intense\");\n    }\n  }\n\n  if (reasons.length) {\n    addNote(`${name} (${hex}) was ${reasons.join(\" and \")}, so we adjusted it.`);\n  }\n  return { lch, neutral, keep: reasons.length ? undefined : hex };\n};\n\n// Hue families the fill colors are drawn from: the picks plus in-between and complementary hues.\nconst buildHueFamilies = (hues: number[]): number[] => {\n  const families = [...hues];\n  const addFamily = (hue: number, minGap = 22) => {\n    if (!families.some((family) => hueDistance(family, hue) < minGap)) {\n      families.push(hue);\n    }\n  };\n\n  if (hues.length === 2) {\n    const [first, second] = hues;\n    const gap = hueDistance(first, second);\n    const direction = wrapHue(second - first) <= 180 ? 1 : -1;\n    const along = (t: number) => wrapHue(first + direction * gap * t);\n    if (gap >= 50) {\n      addFamily(along(1 / 3));\n      addFamily(along(2 / 3));\n      if (gap > 150) addFamily(wrapHue(first + 90 * -direction));\n    } else {\n      addFamily(wrapHue(first + 35));\n      addFamily(wrapHue(first - 35));\n      addFamily(wrapHue(first + 180), 30);\n    }\n    return families;\n  }\n\n  const sorted = [...hues].sort((a, b) => a - b);\n  let largestGap = 0;\n  sorted.forEach((hue, index) => {\n    const next = sorted[(index + 1) % sorted.length];\n    const gap = wrapHue(next - hue) || 360;\n    largestGap = Math.max(largestGap, gap);\n    if (gap >= 60 && gap < 360) addFamily(wrapHue(hue + gap / 2));\n  });\n\n  if (largestGap >= 310) {\n    const first = hues[0];\n    addFamily(wrapHue(first + 35));\n    addFamily(wrapHue(first - 35));\n    addFamily(wrapHue(first + 180), 30);\n  }\n  return families;\n};\n\n/**\n * Builds a monochrome ramp around one color, ordered so neighbors in the palette differ most.\n * @param name Display name for the color used in notes. Defaults to \"Your color\".\n */\nexport function generateMonochromePalette(\n  hex: string = TURQUOISE_PRIMARY,\n  count = DEFAULT_PALETTE_SIZE,\n  name = \"Your color\",\n): GeneratedColorPalette {\n  count = toPaletteSize(count);\n  if (!count) return { colors: [], notes: [], pickNotes: [] };\n  const { notes, pickNotes, add } = createNotes(1);\n  const pick = adjustPick(normalizeHex(hex) ?? TURQUOISE_PRIMARY, name, (message) => add(message, 0));\n  const { h: hue, l: lightness } = pick.lch;\n  const chroma = pick.neutral ? pick.lch.c : Math.max(pick.lch.c, 0.06);\n  const minL = hue >= 75 && hue <= 125 ? 0.56 : 0.28;\n  const maxL = 0.88;\n  const steps = Array.from({ length: count }, (_, index) => minL + ((maxL - minL) * index) / Math.max(count - 1, 1));\n\n  let anchor = 0;\n  steps.forEach((step, index) => {\n    if (Math.abs(step - lightness) < Math.abs(steps[anchor] - lightness)) anchor = index;\n  });\n  steps[anchor] = lightness;\n\n  const shades = steps.map((step, index) => {\n    if (index === anchor) return pick.keep ?? oklchToHex(pick.lch);\n    const distance = Math.abs(step - lightness) / Math.max(lightness - minL, maxL - lightness);\n    const c = pick.neutral ? chroma : chroma * (1 - 0.5 * distance ** 1.5);\n    return oklchToHex({ l: step, c, h: wrapHue(hue + (step - lightness) * -14) });\n  });\n\n  const order = [anchor];\n  while (order.length < count) {\n    let bestIndex = -1;\n    let bestGap = -1;\n    steps.forEach((step, index) => {\n      if (order.includes(index)) return;\n      const gap = Math.min(...order.map((ordered) => Math.abs(step - steps[ordered])));\n      if (gap > bestGap + 1e-9) {\n        bestGap = gap;\n        bestIndex = index;\n      }\n    });\n    order.push(bestIndex);\n  }\n\n  return { colors: order.map((index) => shades[index]), notes, pickNotes };\n}\n\n/**\n * Builds a chart palette from picked colors.\n * Series N gets color N, so the picks come first (adjusted when needed), then fill colors.\n * @param hexes 0-4 picked colors. None or one gives a monochrome palette.\n * @param count Palette size, a whole number in 0-64. Picks past the size are dropped.\n * @param names Display names for the picks used in notes. Defaults to \"Color 1\", \"Color 2\", ...\n *\n * Custom theme ids store only the picks, so this output is persisted behavior: changing it\n * restyles every saved custom theme. The \"palette output is stable\" tests pin it.\n */\nexport function generateColorPalette(\n  hexes: string[],\n  count = DEFAULT_PALETTE_SIZE,\n  names?: string[],\n): GeneratedColorPalette {\n  count = toPaletteSize(count);\n  hexes = hexes.slice(0, Math.min(MAX_SOURCE_COLORS, count));\n  if (!count) return { colors: [], notes: [], pickNotes: [] };\n  if (hexes.length < 2) return generateMonochromePalette(hexes[0] ?? TURQUOISE_PRIMARY, count, names?.[0]);\n\n  const { notes, pickNotes, add } = createNotes(hexes.length);\n  const nameOf = (index: number) => names?.[index] ?? `Color ${index + 1}`;\n  const picks = hexes.map((hex, index) =>\n    adjustPick(normalizeHex(hex) ?? TURQUOISE_PRIMARY, nameOf(index), (message) => add(message, index)),\n  );\n\n  const chromatic = picks.find((pick) => !pick.neutral);\n  if (chromatic) {\n    for (const pick of picks) {\n      if (pick.neutral) pick.lch.h = chromatic.lch.h;\n    }\n  } else {\n    picks.forEach((pick, index) => (pick.lch.h = GRAY_FALLBACK_HUES[index % GRAY_FALLBACK_HUES.length]));\n    add(\n      `${picks.length === 2 ? \"Both colors are\" : \"All colors are\"} gray, so the other series use a teal and orange family.`,\n    );\n  }\n\n  const nearestEarlierPick = (index: number) => {\n    let nearest = { index: -1, distance: Infinity };\n    for (let other = 0; other < index; other++) {\n      const distance = labDistance(oklchToOklab(picks[other].lch), oklchToOklab(picks[index].lch));\n      if (distance < nearest.distance) nearest = { index: other, distance };\n    }\n    return nearest;\n  };\n\n  const multi = picks.length >= 3;\n  const minDistance = multi ? MIN_DISTANCE_MULTI : MIN_DISTANCE_PAIR;\n  const hueRotateDistance = multi ? MIN_DISTANCE_BEFORE_HUE_ROTATE_MULTI : MIN_DISTANCE_PAIR;\n\n  // Push picks that are too close to an earlier pick apart: first by lightness, then by hue.\n  for (let index = 1; index < picks.length; index++) {\n    const pick = picks[index];\n    const nearest = nearestEarlierPick(index);\n    if (nearest.distance >= minDistance) continue;\n\n    const nearestLightness = picks[nearest.index].lch.l;\n    for (const step of [0.14, 0.2, 0.26]) {\n      pick.lch.l = clamp(pick.lch.l + (nearestLightness > 0.6 ? -step : step), minLightness(pick.lch.h), MAX_LIGHTNESS);\n      if (nearestEarlierPick(index).distance >= minDistance) break;\n    }\n    for (let attempt = 0; attempt < 5 && nearestEarlierPick(index).distance < hueRotateDistance; attempt++) {\n      pick.lch.h = wrapHue(pick.lch.h + 60);\n      pick.lch.c = Math.max(pick.lch.c, 0.12);\n    }\n    if (nearestEarlierPick(index).distance !== nearest.distance) {\n      pick.keep = undefined;\n      add(\n        `${nameOf(index)} was too similar to ${nameOf(nearest.index).toLowerCase()} to tell apart, so we changed ${nameOf(index).toLowerCase()}.`,\n        index,\n      );\n    }\n  }\n\n  const pickHues = picks.map((pick) => pick.lch.h);\n  const candidates: { hex: string; lab: Lab; hue: number }[] = [];\n  for (const family of buildHueFamilies(pickHues)) {\n    for (const offset of [-14, 0, 14]) {\n      const hue = wrapHue(family + offset);\n      for (const l of [0.46, 0.56, 0.66, 0.76]) {\n        if (l < minLightness(hue) || l > MAX_LIGHTNESS) continue;\n        for (const c of [0.1, 0.14, 0.18]) {\n          const hex = oklchToHex({ l, c, h: hue });\n          candidates.push({ hex, lab: hexToOklab(hex), hue });\n        }\n      }\n    }\n  }\n\n  const chosen = picks.map((pick) => {\n    const hex = pick.keep ?? oklchToHex(pick.lch);\n    return { hex, lab: hexToOklab(hex) };\n  });\n\n  // Farthest-point fill, favoring hues near the picks and lightly penalizing very saturated colors.\n  while (chosen.length < count) {\n    let best: (typeof candidates)[number] | undefined;\n    let bestScore = -1;\n    for (const candidate of candidates) {\n      let distance = Infinity;\n      for (const color of chosen) distance = Math.min(distance, labDistance(candidate.lab, color.lab));\n      const saturationPenalty = 1 - 0.25 * Math.max(0, candidate.lab[1] ** 2 + candidate.lab[2] ** 2 - 0.0144) ** 0.5;\n      const score = distance * saturationPenalty;\n      const offFamilyWeight = multi && chosen.length < 9 ? 0.2 : 0.45;\n      const weight = pickHues.some((hue) => hueDistance(hue, candidate.hue) <= 40) ? 1 : offFamilyWeight;\n      if (score * weight > bestScore) {\n        bestScore = score * weight;\n        best = candidate;\n      }\n    }\n    if (!best) break;\n    chosen.push(best);\n  }\n\n  return { colors: chosen.map((color) => color.hex), notes, pickNotes };\n}\n","import type { AgChartTheme } from \"ag-charts-enterprise\";\nimport { createPitViperAGChartsTheme, multicolorFills, PitViperAGChartsMulticolorTheme } from \"@charts/themes\";\nimport { DEFAULT_PALETTE_SIZE, generateColorPalette, MAX_SOURCE_COLORS, normalizeHex } from \"@/functions/colorPalette\";\n\n/** Ids of the built-in color themes. */\nexport type PvPresetColorThemeId = \"default\" | \"ocean\" | \"sunset\" | \"forest\";\n/** A custom theme id. Encodes its 1-4 key colors, e.g. `custom:04D7C6-EC5A62`. */\nexport type PvCustomColorThemeId = `custom:${string}`;\n/**\n * A color theme. This string is the whole theme: components take it and emit it, and it can be\n * stored as-is. Use `resolveColorTheme` or `useColorTheme` to get its colors.\n */\nexport type PvColorThemeId = PvPresetColorThemeId | PvCustomColorThemeId;\n\n/** A color theme resolved from its id. */\nexport interface PvColorTheme {\n  id: PvColorThemeId;\n  /** Display name, e.g. \"Ocean\". */\n  label: string;\n  /** The 1-4 key colors. PvColorPalette shows these; a custom theme is generated from them. */\n  colors: string[];\n  /** Full chart fills in series order. Series N uses `palette[N % palette.length]`. */\n  palette: string[];\n}\n\nexport const PV_DEFAULT_COLOR_THEME_ID = \"default\" satisfies PvColorThemeId;\nconst CUSTOM_PREFIX = \"custom:\";\nconst CUSTOM_LABEL = \"Custom theme\";\n\nconst preset = (id: PvPresetColorThemeId, label: string, palette: string[]): PvColorTheme => ({\n  id,\n  label,\n  colors: palette.slice(0, MAX_SOURCE_COLORS),\n  palette,\n});\n\nexport const PvDefaultColorTheme = preset(\"default\", \"Default\", [...multicolorFills]);\n\nexport const PvOceanColorTheme = preset(\"ocean\", \"Ocean\", [\n  \"#0B3C5D\",\n  \"#1CA7C7\",\n  \"#328CC1\",\n  \"#0F7A8A\",\n  \"#7FD1E0\",\n  \"#1D5C96\",\n  \"#2EC4B6\",\n  \"#3A5A8C\",\n  \"#5BC0EB\",\n  \"#14505C\",\n  \"#66A3C2\",\n  \"#1B998B\",\n  \"#09284A\",\n  \"#9AD9D0\",\n  \"#4A7FA7\",\n]);\n\nexport const PvSunsetColorTheme = preset(\"sunset\", \"Sunset\", [\n  \"#E4572E\",\n  \"#F3A712\",\n  \"#8C2F39\",\n  \"#FF8C61\",\n  \"#5E2750\",\n  \"#FFD166\",\n  \"#C0392B\",\n  \"#F7B267\",\n  \"#A63D72\",\n  \"#FFB4A2\",\n  \"#7A3E1D\",\n  \"#E5989B\",\n  \"#D9822B\",\n  \"#6D2E46\",\n  \"#FFE0A3\",\n]);\n\nexport const PvForestColorTheme = preset(\"forest\", \"Forest\", [\n  \"#2D6A4F\",\n  \"#BC6C25\",\n  \"#606C38\",\n  \"#DDA15E\",\n  \"#40916C\",\n  \"#6B4423\",\n  \"#95D5B2\",\n  \"#8A9A5B\",\n  \"#283618\",\n  \"#A98467\",\n  \"#B7B77A\",\n  \"#4F772D\",\n  \"#CB997E\",\n  \"#3E5C48\",\n  \"#E9D8A6\",\n]);\n\n/** Built-in themes, default first. */\nexport const PV_DEFAULT_COLOR_THEMES: PvColorTheme[] = [\n  PvDefaultColorTheme,\n  PvOceanColorTheme,\n  PvSunsetColorTheme,\n  PvForestColorTheme,\n];\n\n/** True for a custom theme id (`custom:...`). */\nexport const isCustomColorThemeId = (id?: string | null): id is PvCustomColorThemeId => !!id?.startsWith(CUSTOM_PREFIX);\n\nconst toValidColors = (colors: string[]) =>\n  colors\n    .map((color) => normalizeHex(color))\n    .filter((color): color is string => !!color)\n    .slice(0, MAX_SOURCE_COLORS);\n\n/**\n * Builds the custom theme id for 1-4 key colors, e.g. `[\"#04d7c6\", \"#EC5A62\"]` gives\n * `custom:04D7C6-EC5A62`. Invalid colors are dropped. Returns `undefined` when none are valid.\n */\nexport function toCustomColorThemeId(colors: string[]): PvCustomColorThemeId | undefined {\n  const valid = toValidColors(colors);\n  if (!valid.length) return undefined;\n  return `${CUSTOM_PREFIX}${valid.map((color) => color.slice(1)).join(\"-\")}`;\n}\n\n// `custom:` plus 1-4 six-digit hex colors joined by \"-\". Ids are often read from storage, so\n// anything else (bad or extra colors, other text) is rejected rather than partly read.\nconst CUSTOM_ID_PATTERN = new RegExp(`^${CUSTOM_PREFIX}[0-9a-f]{6}(?:-[0-9a-f]{6}){0,${MAX_SOURCE_COLORS - 1}}$`, \"i\");\n\n/** The key colors encoded in a custom theme id. Empty for presets and malformed ids. */\nexport function getCustomColorThemeColors(id?: string | null): string[] {\n  if (!isCustomColorThemeId(id) || !CUSTOM_ID_PATTERN.test(id)) return [];\n  return toValidColors(id.slice(CUSTOM_PREFIX.length).split(\"-\"));\n}\n\nexport interface CreateCustomColorThemeOptions {\n  /** Palette size. Defaults to 15. */\n  count?: number;\n  /** Names for the picks used in notes. Defaults to \"Color 1\", \"Color 2\", ... */\n  names?: string[];\n}\n\n/**\n * Generates a custom theme from 1-4 key colors.\n * Invalid hex values are dropped and colors past the fourth are ignored.\n * Returns the theme (or `undefined` when no color is valid) plus notes on any adjusted picks.\n * `pickNotes[i]` is about `theme.colors[i]`, so its indexes skip dropped colors.\n */\nexport function createCustomColorTheme(\n  colors: string[],\n  options: CreateCustomColorThemeOptions = {},\n): { theme: PvColorTheme | undefined; notes: string[]; pickNotes: string[][] } {\n  const id = toCustomColorThemeId(colors);\n  if (!id) return { theme: undefined, notes: [], pickNotes: [] };\n  const validColors = toValidColors(colors);\n  const {\n    colors: palette,\n    notes,\n    pickNotes,\n  } = generateColorPalette(validColors, options.count ?? DEFAULT_PALETTE_SIZE, options.names);\n  return { theme: { id, label: CUSTOM_LABEL, colors: validColors, palette }, notes, pickNotes };\n}\n\n/**\n * Resolves a theme id to its label and colors.\n * Presets resolve by id, so stored ids pick up preset updates. Custom ids rebuild their palette\n * from the encoded colors. Missing, unknown, or malformed ids fall back to Default.\n */\nexport function resolveColorTheme(id?: string | null): PvColorTheme {\n  if (isCustomColorThemeId(id)) {\n    return createCustomColorTheme(getCustomColorThemeColors(id)).theme ?? PvDefaultColorTheme;\n  }\n  return PV_DEFAULT_COLOR_THEMES.find((theme) => theme.id === id) ?? PvDefaultColorTheme;\n}\n\n/** The full chart fills for a theme id, in series order. */\nexport const getColorThemePalette = (id?: string | null): string[] => resolveColorTheme(id).palette;\n\n/**\n * The AG Charts theme for a theme id: its palette plus the rest of the Pit Viper chart styling.\n * Default (and any id that falls back to it) gives `PitViperAGChartsMulticolorTheme`.\n */\nexport function getColorThemeAGChartsTheme(id?: string | null): AgChartTheme {\n  const theme = resolveColorTheme(id);\n  return theme.id === PV_DEFAULT_COLOR_THEME_ID\n    ? PitViperAGChartsMulticolorTheme\n    : createPitViperAGChartsTheme(theme.palette);\n}\n","<script setup lang=\"ts\">\nimport { PvSpinnerSize, PvSpinnerVariant } from \"./types\";\n\ninterface PvSpinnerProps {\n  /** The size of the spinner. Controls the rendered diameter via a CSS custom property. */\n  size?: PvSpinnerSize;\n  /** The color variant of the spinner. Use \"white\" on dark backgrounds and \"dark\" on light backgrounds. */\n  variant?: PvSpinnerVariant;\n}\n\nconst mapSizeToPx: Record<PvSpinnerSize, string> = {\n  xs: \"0.75rem\",\n  sm: \"1rem\",\n  md: \"1.25rem\",\n  lg: \"1.5rem\",\n  xl: \"2rem\",\n};\n\nconst mapVariantToPvClass: Record<PvSpinnerVariant, string> = {\n  primary: \"pv-spinner\",\n  dark: \"pv-spinner-dark\",\n  white: \"pv-spinner-light\",\n};\n\nwithDefaults(defineProps<PvSpinnerProps>(), {\n  size: \"lg\",\n  variant: \"primary\",\n});\n</script>\n\n<template>\n  <div data-testid=\"pv-spinner\" :class=\"mapVariantToPvClass[variant]\" :style=\"{ '--size': mapSizeToPx[size] }\" />\n</template>\n","<script setup lang=\"ts\">\nimport { PvSpinnerSize, PvSpinnerVariant } from \"./types\";\n\ninterface PvSpinnerProps {\n  /** The size of the spinner. Controls the rendered diameter via a CSS custom property. */\n  size?: PvSpinnerSize;\n  /** The color variant of the spinner. Use \"white\" on dark backgrounds and \"dark\" on light backgrounds. */\n  variant?: PvSpinnerVariant;\n}\n\nconst mapSizeToPx: Record<PvSpinnerSize, string> = {\n  xs: \"0.75rem\",\n  sm: \"1rem\",\n  md: \"1.25rem\",\n  lg: \"1.5rem\",\n  xl: \"2rem\",\n};\n\nconst mapVariantToPvClass: Record<PvSpinnerVariant, string> = {\n  primary: \"pv-spinner\",\n  dark: \"pv-spinner-dark\",\n  white: \"pv-spinner-light\",\n};\n\nwithDefaults(defineProps<PvSpinnerProps>(), {\n  size: \"lg\",\n  variant: \"primary\",\n});\n</script>\n\n<template>\n  <div data-testid=\"pv-spinner\" :class=\"mapVariantToPvClass[variant]\" :style=\"{ '--size': mapSizeToPx[size] }\" />\n</template>\n","/**\n * Loads AG Charts dynamically so hosts only download the charting library when a chart\n * actually mounts. Without this, every app that imports from visualizations would ship\n * AG Charts as well, even if they only use a PvDataTable.\n */\nimport type { AgCharts } from \"ag-charts-vue3\";\n\nexport interface AgChartsRuntime {\n  AgCharts: typeof AgCharts;\n}\n\nconst AG_CHARTS_LICENSE_KEY =\n  \"Using_this_{AG_Charts}_Enterprise_key_{AG-087886}_in_excess_of_the_licence_granted_is_not_permitted___Please_report_misuse_to_legal@ag-grid.com___For_help_with_changing_this_key_please_contact_info@ag-grid.com___{Turquoise_Health}_is_granted_a_{Multiple_Applications}_Developer_License_for_{3}_Front-End_JavaScript_developers___All_Front-End_JavaScript_developers_need_to_be_licensed_in_addition_to_the_ones_working_with_{AG_Charts}_Enterprise___This_key_has_been_granted_a_Deployment_License_Add-on_for_{2}_Production_Environments___This_key_works_with_{AG_Charts}_Enterprise_versions_released_before_{9_May_2026}____[v3]_[02]_MTc3ODI4MTIwMDAwMA==b240799c3daa50107bb7f3adff911d8f\";\n\nlet runtimePromise: Promise<AgChartsRuntime> | undefined;\n\nasync function importAgCharts(): Promise<AgChartsRuntime> {\n  const [{ AgCharts }, { LicenseManager }] = await Promise.all([\n    import(\"ag-charts-vue3\"),\n    import(\"ag-charts-enterprise\"),\n  ]);\n  LicenseManager.setLicenseKey(AG_CHARTS_LICENSE_KEY);\n  return { AgCharts };\n}\n\nexport function loadAgCharts(): Promise<AgChartsRuntime> {\n  if (!runtimePromise) {\n    runtimePromise = importAgCharts().catch((error: unknown) => {\n      runtimePromise = undefined;\n      throw error;\n    });\n  }\n  return runtimePromise;\n}\n\n/**\n * Apps that know they will render charts can use this to eagerly load AG Charts, so the\n * first chart mounts without a spinner. Safe to fire and forget. A rejection only means\n * the download failed early, and the next chart mount retries it.\n */\nexport function preloadAgCharts(): Promise<void> {\n  return loadAgCharts().then(() => undefined);\n}\n","import { ValueFormatterParams } from \"ag-grid-enterprise\";\nimport type { AgAxisLabelFormatterParams } from \"ag-charts-enterprise\";\nimport { ColDefDataType } from \"@tables/PvDataTable/table-components/formatting\";\n\nfunction getValue(params: ValueFormatterParams | AgAxisLabelFormatterParams) {\n  // Aggregates arrive as { value, count }; unwrap them so an empty aggregate shows blank, not the object or 0.\n  const rawValue =\n    params.value && typeof params.value === \"object\" && \"value\" in params.value ? params.value.value : params.value;\n  if (rawValue === null || rawValue === undefined || rawValue === \"\") {\n    return \"\";\n  } else {\n    return rawValue;\n  }\n}\n\nfunction formatNumber(value: number | string, decimalPlaces: number): string {\n  // attempt to convert to a number, otherwise return as string\n  const numValue = Number(value);\n  if (!isFinite(numValue)) {\n    return String(value);\n  }\n  return numValue.toLocaleString(undefined, {\n    minimumFractionDigits: 0,\n    maximumFractionDigits: decimalPlaces,\n  });\n}\n\nfunction getFormatterPrecision(precision: number | undefined): number {\n  const defaultPrecision = 2;\n  if (typeof precision !== \"number\") {\n    return defaultPrecision;\n  }\n  return Math.min(Math.max(0, precision), 20);\n}\n\nexport function currencyFormatter(\n  params: ValueFormatterParams | AgAxisLabelFormatterParams,\n  precision: number | undefined,\n): string {\n  // the value might be nested for aggregations\n  const rawValue = getValue(params);\n  if (rawValue === \"\") {\n    return \"\";\n  }\n  // Chart labels render full currency with thousands grouping. (Previously 3 significant\n  // digits, which dropped cents and rounded dollars — wrong for currency anywhere it appears.)\n  // Point labels and tooltips force two decimals ($79.10); axis tick labels — their params\n  // carry an `index` — drop a forced \".00\" instead, since ticks land on whole values and the\n  // trailing zeros are clutter, while fractional ticks keep their cents.\n  if (!(\"node\" in params)) {\n    const isAxisLabel = \"index\" in params;\n    return `$${Number(rawValue).toLocaleString(\"en-US\", {\n      minimumFractionDigits: isAxisLabel ? 0 : 2,\n      maximumFractionDigits: 2,\n    })}`;\n  }\n  // In the table and everywhere else, precision is column-configurable\n  return \"$\" + formatNumber(rawValue, getFormatterPrecision(precision));\n}\n\nexport function percentageFormatter(\n  params: ValueFormatterParams | AgAxisLabelFormatterParams,\n  precision: number | undefined,\n): string {\n  const rawValue = getValue(params);\n  if (rawValue === \"\") {\n    return \"\";\n  }\n  return formatNumber(Number(rawValue) * 100, getFormatterPrecision(precision)) + \"%\";\n}\n\nexport function integerFormatter(params: ValueFormatterParams | AgAxisLabelFormatterParams): string {\n  const rawValue = getValue(params);\n  if (rawValue === \"\") {\n    return \"\";\n  }\n  return formatNumber(rawValue, 0);\n}\n\nexport function arrayValueFormatter(\n  params: ValueFormatterParams | AgAxisLabelFormatterParams,\n  dataType?: ColDefDataType,\n): string {\n  if (!dataType) {\n    return params.value;\n  }\n  //TODO - add logic\n  return params.value;\n}\n","// workaround for an AG Charts bug where null values in data causes tooltip errors\n// we use this value to avoid nulls in the data, while being able to identify it as a placeholder and not render it\n// in the tooltip or data labels\nexport const NULL_PLACEHOLDER_VALUE = 0.000123;\n\nexport const NO_DATA_OVERLAY_TEXT = \"No data available to chart.\";\n\nexport const MAX_LABEL_LENGTH = 50;\n","import type { AgChartOptions } from \"ag-charts-types\";\nimport type {\n  AgCartesianAxisOptions,\n  AgCartesianChartOptions,\n  AgCartesianSeriesOptions,\n  AgLogAxisOptions,\n  AgNumberAxisOptions,\n} from \"ag-charts-enterprise\";\n\ninterface AxisDomain {\n  min: number;\n  max: number;\n}\n\n/**\n * Calculate the absolute distance from center based on data range and scale type\n * @param data The data array from the series\n * @param key The key to extract values from data\n * @param centerCoord The coordinate to center on\n * @param scale The axis scale type (\"log\" or \"number\") (default: \"number\")\n * @returns The calculated absolute distance\n */\nexport function getAbsoluteDistance(\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  data: any[] | undefined,\n  key: string | undefined,\n  centerCoord: number,\n): number | null {\n  // get the max and min from the data for the given key\n  const values = data && key ? data.map((d) => d[key]).filter((v) => typeof v === \"number\" && !isNaN(v)) : [];\n  if (values.length > 0) {\n    const dataMin = Math.min(...values);\n    const dataMax = Math.max(...values);\n    const distanceToMin = Math.abs(centerCoord - dataMin);\n    const distanceToMax = Math.abs(dataMax - centerCoord);\n    return Math.max(distanceToMin, distanceToMax);\n  }\n  return null;\n}\n\n/**\n * Calculate the domain (min/max) for an axis based on the center coordinate and scale type\n * @param centerCoord The coordinate to center the axis on\n * @param scale The axis scale type (\"log\" or \"number\")\n * @param absoluteDistance The absolute distance from center on either side (used for linear scales)\n * @returns Object with min and max values for the axis domain\n */\nexport function calculateAxisDomain(\n  centerCoord: number,\n  scale: string,\n  absoluteDistance: number | null,\n): AxisDomain | null {\n  if (absoluteDistance === null || absoluteDistance <= 0) {\n    return null;\n  }\n  if (scale === \"log\") {\n    // For log scale, center around the coordinate using multiplicative distance\n    // Domain: [centerCoord / absoluteDistance, centerCoord * absoluteDistance]\n    // This ensures centerCoord is centered in log space\n    const min = centerCoord / absoluteDistance;\n    const max = centerCoord * absoluteDistance;\n\n    // Only clamp min to a small positive value if it goes below, maintaining the ratio\n    if (min < 0.001) {\n      const ratio = max / min;\n      return {\n        min: 0.001,\n        max: 0.001 * ratio,\n      };\n    }\n\n    return {\n      min,\n      max,\n    };\n  } else {\n    // For linear scale, use additive distance centered around the coordinate\n    // This ensures the center coordinate is equidistant from min and max\n    return {\n      min: centerCoord - absoluteDistance,\n      max: centerCoord + absoluteDistance,\n    };\n  }\n}\n\n/**\n * Add a cross line to an axis at the specified coordinate\n * @param axis The axis object to add the cross line to\n * @param value The coordinate value where the cross line should be placed\n */\nexport function addCrossLineToAxis(axis: AgNumberAxisOptions | AgLogAxisOptions, value: number): void {\n  const crossLines = axis.crossLines || [];\n  crossLines.push({\n    type: \"line\",\n    value,\n    strokeWidth: 2,\n    strokeOpacity: 0.25,\n    lineDash: [4, 4],\n    stroke: \"#b4b5b9\",\n  });\n  axis.crossLines = crossLines;\n}\n\n/**\n * Apply centering to an axis based on coordinate and position\n * @param options The chart options object\n * @param centerCoord The coordinate to center on\n * @param positions The axis position(s) to target ('bottom'|'top' for x-axis, 'left'|'right' for y-axis)\n * @param absoluteDistance The absolute distance from center on either side (default: 800)\n */\nfunction applyCenterOnAxis(\n  options: AgCartesianChartOptions,\n  centerCoord: number,\n  positions: string[],\n  absoluteDistance: number | null,\n): void {\n  const axes = (options.axes || []).filter((axis: AgCartesianAxisOptions) =>\n    positions.includes(((axis.type === \"number\" || axis.type === \"log\") && axis.position) || \"\"),\n  ) as (AgLogAxisOptions | AgNumberAxisOptions)[];\n\n  axes.forEach((axis) => {\n    const scale = axis.type || \"number\";\n    const domain = calculateAxisDomain(centerCoord, scale, absoluteDistance);\n    if (domain) {\n      axis.min = domain.min;\n      axis.max = domain.max;\n      axis.interval = {\n        values: [Math.ceil(domain.min), Math.floor(domain.max)],\n      };\n    }\n\n    addCrossLineToAxis(axis, centerCoord);\n  });\n}\n\n/**\n * Apply centering to x-axis based on centerOnCoords\n * @param options The chart options object\n * @param centerCoord The x coordinate to center on\n */\nexport function applyCenterOnXAxis(options: AgChartOptions, centerCoord: number): void {\n  if ((options as AgCartesianChartOptions).axes === undefined) {\n    return;\n  }\n  const opts = options as AgCartesianChartOptions;\n  const primaryScatterSeries = opts.series?.find((s: AgCartesianSeriesOptions) => s.type === \"scatter\");\n  const xKey = primaryScatterSeries && \"yKey\" in primaryScatterSeries ? primaryScatterSeries.xKey : \"\";\n  const data = opts.data || [];\n  const absoluteDistance = getAbsoluteDistance(data, xKey, centerCoord);\n  applyCenterOnAxis(opts, centerCoord, [\"bottom\", \"top\"], absoluteDistance);\n}\n\n/**\n * Apply centering to y-axis based on centerOnCoords\n * @param options The chart options object\n * @param centerCoord The y coordinate to center on\n */\nexport function applyCenterOnYAxis(options: AgChartOptions, centerCoord: number): void {\n  // skip if not a cartesian chart\n  if ((options as AgCartesianChartOptions).axes === undefined) {\n    return;\n  }\n  const opts = options as AgCartesianChartOptions;\n  const primaryScatterSeries = opts.series?.find((s: AgCartesianSeriesOptions) => s.type === \"scatter\");\n  const yKey = primaryScatterSeries && \"yKey\" in primaryScatterSeries ? primaryScatterSeries.yKey : \"\";\n  const data = opts.data || [];\n  const absoluteDistance = getAbsoluteDistance(data, yKey, centerCoord);\n  applyCenterOnAxis(opts, centerCoord, [\"left\", \"right\"], absoluteDistance);\n}\n","<script setup lang=\"ts\">\nimport type { AgCharts } from \"ag-charts-vue3\";\nimport { computed, ref, shallowRef, onMounted, onUnmounted } from \"vue\";\nimport { getColorThemeAGChartsTheme } from \"@/functions/colorThemes\";\nimport PvSpinner from \"@/components/base/PvSpinner/PvSpinner.vue\";\nimport type {\n  AgBarSeriesOptions,\n  AgBaseChartListeners,\n  AgCartesianSeriesOptions,\n  AgCartesianSeriesTooltipRendererParams,\n  AgChartClickEvent,\n  AgSeriesVisibilityChange,\n} from \"ag-charts-enterprise\";\nimport { loadAgCharts } from \"@/functions/loadAgCharts\";\nimport { currencyFormatter } from \"@/functions/formatting\";\nimport { NO_DATA_OVERLAY_TEXT, NULL_PLACEHOLDER_VALUE } from \"@charts/PvChart/constants\";\nimport { PvChartProps, PvScatterQuadrant } from \"@charts/PvChart/types\";\nimport { applyCenterOnXAxis, applyCenterOnYAxis } from \"@charts/PvChart/functions\";\nimport type { AgChartOptions } from \"ag-charts-types\";\n\nconst props = withDefaults(defineProps<PvChartProps>(), {\n  seriesFormatType: \"none\",\n  isLoading: false,\n  enableFocusView: false,\n  minHeight: 450,\n  translateNullValues: true,\n});\n\nconst emits = defineEmits<{\n  (e: \"series-visibility-change\", event: AgSeriesVisibilityChange): void;\n}>();\n\nconst agChartsComponent = shallowRef<typeof AgCharts | null>(null);\nconst chartRef = ref<InstanceType<typeof AgCharts> | null>(null);\nconst overlayStyle = ref<Record<string, string>>({});\n\nconst updateOverlayBounds = () => {\n  if (!chartRef.value || !props.customChartProps?.scatter?.quadrantRenderer) return;\n\n  // Find the AG Charts element in the DOM\n  const chartElement = chartRef.value.$el as HTMLElement;\n  if (!chartElement) return;\n\n  // Find the series area element which represents the actual plot area\n  const seriesArea = chartElement.querySelector(\".ag-charts-series-area\");\n  if (!seriesArea) return;\n\n  // Get the bounding rectangles\n  const seriesRect = seriesArea.getBoundingClientRect();\n  const containerRect = chartElement.getBoundingClientRect();\n\n  // Get padding from chart options (default to 0 if not specified)\n  const padding = props.options.seriesArea?.padding || { top: 0, right: 0, bottom: 0, left: 0 };\n  const paddingTop = typeof padding === \"number\" ? padding : padding.top || 0;\n  const paddingRight = typeof padding === \"number\" ? padding : padding.right || 0;\n  const paddingBottom = typeof padding === \"number\" ? padding : padding.bottom || 0;\n  const paddingLeft = typeof padding === \"number\" ? padding : padding.left || 0;\n\n  // Calculate position relative to the chart container, extending by padding amounts\n  overlayStyle.value = {\n    top: `${seriesRect.top - containerRect.top - paddingTop}px`,\n    left: `${seriesRect.left - containerRect.left - paddingLeft}px`,\n    width: `${seriesRect.width + paddingLeft + paddingRight}px`,\n    height: `${seriesRect.height + paddingTop + paddingBottom}px`,\n  };\n};\n\nconst baseChartListeners: AgBaseChartListeners<AgChartClickEvent> = {\n  seriesVisibilityChange: (event) => {\n    emits(\"series-visibility-change\", event);\n  },\n};\n\nlet overlayBoundsTimeout: ReturnType<typeof setTimeout> | undefined;\n\nonMounted(async () => {\n  agChartsComponent.value = (await loadAgCharts()).AgCharts;\n  // Update bounds after initial render\n  overlayBoundsTimeout = setTimeout(updateOverlayBounds, 100);\n});\n\nonUnmounted(() => {\n  clearTimeout(overlayBoundsTimeout);\n  overlayStyle.value = {};\n});\n\nconst isMapChart = computed(() => {\n  const series = chartOptions.value?.series || [];\n  return series.some((s) => s.type === \"map-shape\");\n});\n\nconst isHorizontalChart = computed(() => {\n  const series = chartOptions.value?.series || [];\n  let isHorizontal = false;\n  series.forEach((series) => {\n    if (series.type === \"bar\" && series.direction === \"horizontal\") {\n      isHorizontal = true;\n    }\n  });\n  return isHorizontal;\n});\n\nconst isScatterChart = computed(() => {\n  const series = chartOptions.value?.series || [];\n  return series.some((s) => s.type === \"scatter\");\n});\n\nconst defaultTooltipRenderer = (params: AgCartesianSeriesTooltipRendererParams) => {\n  /*\n\tDefault tooltip renderer that handles null values and formatting\n\t*/\n  const categoryKey = params.xKey || \"\";\n  // The tooltip heading is the per-datum category VALUE (\"Jan 2026\"), which only exists on\n  // the datum. `xName` is a series-level constant (an axis label like \"Month\", or in some\n  // callers the raw field key like \"ingest_date\"), so trusting it here rendered that same\n  // constant as the heading on every point.\n  const categoryValue = params.datum[categoryKey];\n  const seriesKey = params.yKey;\n  const seriesValue = params.datum[seriesKey];\n\n  let formattedCategoryValue = String(categoryValue) || \"\";\n  //@ts-expect-error axes should exist\n  const chartAxes = chartOptions.value?.axes || [];\n  //@ts-expect-error axes should exist\n  const categoryAxis = chartAxes.find((axis) => axis.type === \"category\");\n  if (categoryAxis && categoryAxis.label && categoryAxis.label.formatter) {\n    formattedCategoryValue =\n      categoryAxis.label.formatter({ value: categoryValue, datum: params.datum, context: { tooltip: true } }) ||\n      formattedCategoryValue;\n  }\n\n  // Skip rendering if there is no value or if it's the null placeholder\n  if (seriesValue == null || seriesValue === NULL_PLACEHOLDER_VALUE) {\n    return {\n      heading: formattedCategoryValue,\n      data: [],\n    };\n  }\n  // apply formatter if exists\n  let formattedSeriesValue = String(seriesValue) || \"\";\n  // find chart options series with yKey\n  const chartSeries = chartOptions.value?.series as AgBarSeriesOptions[] | undefined;\n  const currentSeries = chartSeries?.find((s) => s.yKey === seriesKey);\n  if (currentSeries && currentSeries?.label?.formatter) {\n    const formatter = currentSeries.label.formatter;\n    // @ts-expect-error allow calling formatter with value and datum\n    formattedSeriesValue = formatter({ value: seriesValue, datum: params.datum }) || formattedSeriesValue;\n  }\n  return {\n    heading: formattedCategoryValue,\n    data: [\n      {\n        label: params.yName,\n        value: formattedSeriesValue, // Must be a string per ag-charts API\n      },\n    ],\n  };\n};\n\nconst transformData = (data: AgChartOptions[\"data\"] | undefined, series: AgChartOptions[\"series\"] | undefined) => {\n  if (!data) return data;\n  if (!props.translateNullValues) return data;\n\n  // Collect all unique keys from all data objects\n  const allKeys = new Set<string>();\n  data.forEach((item) => {\n    Object.keys(item).forEach((key) => allKeys.add(key));\n  });\n\n  const yKeys: string[] = [];\n  // Line series render a gap instead of a placeholder: the placeholder is only\n  // invisible because of the `itemStyler` in `transformSeries`, which line series\n  // don't support, so a placeholder would draw a marker sitting at zero.\n  const gapKeys = new Set<string>();\n  series?.forEach((s) => {\n    if (\"yKey\" in s && s.yKey) {\n      yKeys.push(s.yKey);\n      if (s.type === \"line\") {\n        gapKeys.add(s.yKey);\n      }\n    }\n  });\n\n  // Ensure each data entry has all keys\n  const updatedData = data.map((item) => {\n    const newItem = { ...item };\n\n    // Add missing keys with NULL_PLACEHOLDER_VALUE\n    allKeys.forEach((key) => {\n      if (gapKeys.has(key)) {\n        return;\n      }\n      if (!(key in newItem)) {\n        newItem[key] = NULL_PLACEHOLDER_VALUE;\n      } else if (newItem[key] === null) {\n        // Replace null values with placeholder\n        newItem[key] = NULL_PLACEHOLDER_VALUE;\n      }\n    });\n\n    return newItem;\n  });\n\n  if (\n    yKeys.length > 0 &&\n    updatedData?.every((option) =>\n      yKeys.every((yKey) => !(yKey in option) || option[yKey] === NULL_PLACEHOLDER_VALUE || option[yKey] === null),\n    )\n  ) {\n    // In this case, we want to ensure that no data is displayed since it is all null.\n    return [];\n  }\n  return updatedData;\n};\n\ntype SeriesWithNullItemStyler = AgCartesianSeriesOptions & {\n  itemStyler?: (params: { yValue?: unknown }) => { fill: string; stroke: string } | undefined;\n};\n\nconst transformSeries = (series: AgChartOptions[\"series\"] | undefined) => {\n  if (!series) return series;\n  return series.map((s) => {\n    const newSeries = { ...s } as AgCartesianSeriesOptions;\n    if (!newSeries.tooltip) {\n      newSeries.tooltip = {};\n    }\n    if (!newSeries.tooltip.renderer) {\n      // @ts-expect-error allow setting renderer\n      newSeries.tooltip.renderer = defaultTooltipRenderer;\n    }\n\n    const stylableSeries = newSeries as SeriesWithNullItemStyler;\n    // Line series have no top-level `itemStyler` (AG Charts logs it as an unknown\n    // option) and never carry placeholder values - see `transformData`.\n    if (newSeries.type !== \"line\" && !stylableSeries.itemStyler) {\n      stylableSeries.itemStyler = (params: { yValue?: unknown }) => {\n        if (params.yValue === NULL_PLACEHOLDER_VALUE || params.yValue === null) {\n          return { fill: \"transparent\", stroke: \"transparent\" };\n        }\n      };\n    }\n    return newSeries;\n  });\n};\n\nconst seriesFormatter = computed(() => {\n  if (props.seriesFormatType === \"currency\") {\n    return currencyFormatter;\n  } else if (props.seriesFormatType === \"percent\") {\n    return 0;\n  }\n  return undefined;\n});\n\n// Its own computed so a custom palette is only rebuilt when the theme id changes.\nconst colorThemeChartTheme = computed(() => getColorThemeAGChartsTheme(props.colorTheme));\n\nconst chartOptions = computed(() => {\n  const currentOptions = { ...props.options };\n\n  if (!currentOptions.theme) {\n    currentOptions.theme = colorThemeChartTheme.value;\n  }\n  currentOptions.data = transformData(currentOptions.data, currentOptions.series);\n  currentOptions.series = transformSeries(currentOptions.series);\n\n  if (props.minHeight > 0 && !currentOptions.series?.some((series) => String(series.type) === \"map-shape\")) {\n    currentOptions.minHeight ??= props.minHeight;\n  }\n\n  if (!currentOptions.overlays) {\n    currentOptions.overlays = {\n      noData: {\n        text: NO_DATA_OVERLAY_TEXT,\n      },\n      noVisibleSeries: {\n        text: \"No visible series\",\n      },\n    };\n  }\n\n  //@ts-expect-error check type before setting\n  if (!currentOptions.axes) {\n    //@ts-expect-error check type before setting\n    currentOptions.axes = [\n      {\n        type: \"category\",\n        position: isHorizontalChart.value ? \"left\" : \"bottom\",\n      },\n      {\n        type: \"number\",\n        position: isHorizontalChart.value ? \"bottom\" : \"left\",\n        label: {\n          formatter: seriesFormatter.value,\n        },\n      },\n    ];\n  }\n\n  const series = currentOptions.series || [];\n  const scatterSeries = series.filter((s) => s.type === \"scatter\");\n  const centerOnCoords = props.customChartProps?.scatter?.centerOnCoords;\n  if (scatterSeries.length > 0 && centerOnCoords) {\n    if (centerOnCoords.x !== undefined && centerOnCoords.x !== null) {\n      applyCenterOnXAxis(currentOptions, centerOnCoords.x);\n    }\n    if (centerOnCoords.y !== undefined && centerOnCoords.y !== null) {\n      applyCenterOnYAxis(currentOptions, centerOnCoords.y);\n    }\n  }\n\n  if (!currentOptions.contextMenu) {\n    currentOptions.contextMenu = {\n      enabled: false,\n    };\n  }\n\n  currentOptions.listeners = {\n    ...(currentOptions.listeners || {}),\n    ...baseChartListeners,\n  };\n\n  return currentOptions;\n});\n\ndefineExpose({\n  getChartImageDataURL: (dimensions?: { width?: number; height?: number }): Promise<string> | undefined => {\n    const chart = chartRef.value?.chart;\n\n    return chart?.getImageDataURL({\n      width: dimensions?.width,\n      height: dimensions?.height,\n    });\n  },\n});\n</script>\n\n<template>\n  <div style=\"position: relative\">\n    <component\n      :is=\"agChartsComponent\"\n      v-if=\"agChartsComponent\"\n      ref=\"chartRef\"\n      style=\"height: 100%\"\n      :style=\"isMapChart ? '' : `min-height: ${minHeight}px`\"\n      :options=\"chartOptions\"\n    />\n    <div v-else style=\"height: 100%\" :style=\"isMapChart ? '' : `min-height: ${minHeight}px`\" />\n    <div v-if=\"isLoading || !agChartsComponent\" class=\"pv-flex pv-chart-loading\">\n      <PvSpinner size=\"xl\" />\n    </div>\n    <template v-if=\"isScatterChart && customChartProps?.scatter\">\n      <div v-if=\"customChartProps?.scatter?.quadrantRenderer\" class=\"pv-scatter-overlay\" :style=\"overlayStyle\">\n        <div class=\"pv-scatter-quadrant pv-scatter-quadrant-top-left\">\n          <div class=\"pv-scatter-quadrant-box\">\n            <component :is=\"customChartProps.scatter.quadrantRenderer\" :quadrant=\"'topLeft' as PvScatterQuadrant\" />\n          </div>\n        </div>\n        <div class=\"pv-scatter-quadrant pv-scatter-quadrant-top-right\">\n          <div class=\"pv-scatter-quadrant-box\">\n            <component :is=\"customChartProps.scatter.quadrantRenderer\" :quadrant=\"'topRight' as PvScatterQuadrant\" />\n          </div>\n        </div>\n        <div class=\"pv-scatter-quadrant pv-scatter-quadrant-bottom-left\">\n          <div class=\"pv-scatter-quadrant-box\">\n            <component :is=\"customChartProps.scatter.quadrantRenderer\" :quadrant=\"'bottomLeft' as PvScatterQuadrant\" />\n          </div>\n        </div>\n        <div class=\"pv-scatter-quadrant pv-scatter-quadrant-bottom-right\">\n          <div class=\"pv-scatter-quadrant-box\">\n            <component :is=\"customChartProps.scatter.quadrantRenderer\" :quadrant=\"'bottomRight' as PvScatterQuadrant\" />\n          </div>\n        </div>\n      </div>\n    </template>\n  </div>\n</template>\n\n<style scoped>\n.pv-scatter-overlay {\n  position: absolute;\n  top: 0;\n  left: 0;\n  width: 100%;\n  height: 100%;\n  pointer-events: none;\n  z-index: 2;\n  display: grid;\n  grid-template-columns: 1fr 1fr;\n  grid-template-rows: 1fr 1fr;\n}\n\n.pv-scatter-quadrant {\n  display: flex;\n  overflow: hidden;\n}\n\n.pv-scatter-quadrant-box {\n  background: rgba(128, 128, 128, 0.1);\n  padding: 8px;\n  border-radius: 4px;\n  font-size: 12px;\n  font-weight: 600;\n  color: #666;\n  pointer-events: all;\n  max-width: calc(100% - 10px);\n  max-height: calc(100% - 10px);\n  overflow: auto;\n}\n\n.pv-scatter-quadrant-top-left {\n  grid-column: 1;\n  grid-row: 1;\n  align-items: flex-start;\n  justify-content: flex-start;\n  padding: 5px;\n}\n\n.pv-scatter-quadrant-top-right {\n  grid-column: 2;\n  grid-row: 1;\n  align-items: flex-start;\n  justify-content: flex-end;\n  padding: 5px;\n}\n\n.pv-scatter-quadrant-bottom-left {\n  grid-column: 1;\n  grid-row: 2;\n  align-items: flex-end;\n  justify-content: flex-start;\n  padding: 5px;\n}\n\n.pv-scatter-quadrant-bottom-right {\n  grid-column: 2;\n  grid-row: 2;\n  align-items: flex-end;\n  justify-content: flex-end;\n  padding: 5px;\n}\n.pv-chart-loading {\n  position: absolute;\n  text-align: center;\n  justify-content: center;\n  align-items: center;\n  top: 0;\n  left: 0;\n  width: 100%;\n  height: 100%;\n  opacity: 1;\n  background-color: var(--color-background-body, white);\n  z-index: 4;\n}\n</style>\n","<script setup lang=\"ts\">\nimport type { AgCharts } from \"ag-charts-vue3\";\nimport { computed, ref, shallowRef, onMounted, onUnmounted } from \"vue\";\nimport { getColorThemeAGChartsTheme } from \"@/functions/colorThemes\";\nimport PvSpinner from \"@/components/base/PvSpinner/PvSpinner.vue\";\nimport type {\n  AgBarSeriesOptions,\n  AgBaseChartListeners,\n  AgCartesianSeriesOptions,\n  AgCartesianSeriesTooltipRendererParams,\n  AgChartClickEvent,\n  AgSeriesVisibilityChange,\n} from \"ag-charts-enterprise\";\nimport { loadAgCharts } from \"@/functions/loadAgCharts\";\nimport { currencyFormatter } from \"@/functions/formatting\";\nimport { NO_DATA_OVERLAY_TEXT, NULL_PLACEHOLDER_VALUE } from \"@charts/PvChart/constants\";\nimport { PvChartProps, PvScatterQuadrant } from \"@charts/PvChart/types\";\nimport { applyCenterOnXAxis, applyCenterOnYAxis } from \"@charts/PvChart/functions\";\nimport type { AgChartOptions } from \"ag-charts-types\";\n\nconst props = withDefaults(defineProps<PvChartProps>(), {\n  seriesFormatType: \"none\",\n  isLoading: false,\n  enableFocusView: false,\n  minHeight: 450,\n  translateNullValues: true,\n});\n\nconst emits = defineEmits<{\n  (e: \"series-visibility-change\", event: AgSeriesVisibilityChange): void;\n}>();\n\nconst agChartsComponent = shallowRef<typeof AgCharts | null>(null);\nconst chartRef = ref<InstanceType<typeof AgCharts> | null>(null);\nconst overlayStyle = ref<Record<string, string>>({});\n\nconst updateOverlayBounds = () => {\n  if (!chartRef.value || !props.customChartProps?.scatter?.quadrantRenderer) return;\n\n  // Find the AG Charts element in the DOM\n  const chartElement = chartRef.value.$el as HTMLElement;\n  if (!chartElement) return;\n\n  // Find the series area element which represents the actual plot area\n  const seriesArea = chartElement.querySelector(\".ag-charts-series-area\");\n  if (!seriesArea) return;\n\n  // Get the bounding rectangles\n  const seriesRect = seriesArea.getBoundingClientRect();\n  const containerRect = chartElement.getBoundingClientRect();\n\n  // Get padding from chart options (default to 0 if not specified)\n  const padding = props.options.seriesArea?.padding || { top: 0, right: 0, bottom: 0, left: 0 };\n  const paddingTop = typeof padding === \"number\" ? padding : padding.top || 0;\n  const paddingRight = typeof padding === \"number\" ? padding : padding.right || 0;\n  const paddingBottom = typeof padding === \"number\" ? padding : padding.bottom || 0;\n  const paddingLeft = typeof padding === \"number\" ? padding : padding.left || 0;\n\n  // Calculate position relative to the chart container, extending by padding amounts\n  overlayStyle.value = {\n    top: `${seriesRect.top - containerRect.top - paddingTop}px`,\n    left: `${seriesRect.left - containerRect.left - paddingLeft}px`,\n    width: `${seriesRect.width + paddingLeft + paddingRight}px`,\n    height: `${seriesRect.height + paddingTop + paddingBottom}px`,\n  };\n};\n\nconst baseChartListeners: AgBaseChartListeners<AgChartClickEvent> = {\n  seriesVisibilityChange: (event) => {\n    emits(\"series-visibility-change\", event);\n  },\n};\n\nlet overlayBoundsTimeout: ReturnType<typeof setTimeout> | undefined;\n\nonMounted(async () => {\n  agChartsComponent.value = (await loadAgCharts()).AgCharts;\n  // Update bounds after initial render\n  overlayBoundsTimeout = setTimeout(updateOverlayBounds, 100);\n});\n\nonUnmounted(() => {\n  clearTimeout(overlayBoundsTimeout);\n  overlayStyle.value = {};\n});\n\nconst isMapChart = computed(() => {\n  const series = chartOptions.value?.series || [];\n  return series.some((s) => s.type === \"map-shape\");\n});\n\nconst isHorizontalChart = computed(() => {\n  const series = chartOptions.value?.series || [];\n  let isHorizontal = false;\n  series.forEach((series) => {\n    if (series.type === \"bar\" && series.direction === \"horizontal\") {\n      isHorizontal = true;\n    }\n  });\n  return isHorizontal;\n});\n\nconst isScatterChart = computed(() => {\n  const series = chartOptions.value?.series || [];\n  return series.some((s) => s.type === \"scatter\");\n});\n\nconst defaultTooltipRenderer = (params: AgCartesianSeriesTooltipRendererParams) => {\n  /*\n\tDefault tooltip renderer that handles null values and formatting\n\t*/\n  const categoryKey = params.xKey || \"\";\n  // The tooltip heading is the per-datum category VALUE (\"Jan 2026\"), which only exists on\n  // the datum. `xName` is a series-level constant (an axis label like \"Month\", or in some\n  // callers the raw field key like \"ingest_date\"), so trusting it here rendered that same\n  // constant as the heading on every point.\n  const categoryValue = params.datum[categoryKey];\n  const seriesKey = params.yKey;\n  const seriesValue = params.datum[seriesKey];\n\n  let formattedCategoryValue = String(categoryValue) || \"\";\n  //@ts-expect-error axes should exist\n  const chartAxes = chartOptions.value?.axes || [];\n  //@ts-expect-error axes should exist\n  const categoryAxis = chartAxes.find((axis) => axis.type === \"category\");\n  if (categoryAxis && categoryAxis.label && categoryAxis.label.formatter) {\n    formattedCategoryValue =\n      categoryAxis.label.formatter({ value: categoryValue, datum: params.datum, context: { tooltip: true } }) ||\n      formattedCategoryValue;\n  }\n\n  // Skip rendering if there is no value or if it's the null placeholder\n  if (seriesValue == null || seriesValue === NULL_PLACEHOLDER_VALUE) {\n    return {\n      heading: formattedCategoryValue,\n      data: [],\n    };\n  }\n  // apply formatter if exists\n  let formattedSeriesValue = String(seriesValue) || \"\";\n  // find chart options series with yKey\n  const chartSeries = chartOptions.value?.series as AgBarSeriesOptions[] | undefined;\n  const currentSeries = chartSeries?.find((s) => s.yKey === seriesKey);\n  if (currentSeries && currentSeries?.label?.formatter) {\n    const formatter = currentSeries.label.formatter;\n    // @ts-expect-error allow calling formatter with value and datum\n    formattedSeriesValue = formatter({ value: seriesValue, datum: params.datum }) || formattedSeriesValue;\n  }\n  return {\n    heading: formattedCategoryValue,\n    data: [\n      {\n        label: params.yName,\n        value: formattedSeriesValue, // Must be a string per ag-charts API\n      },\n    ],\n  };\n};\n\nconst transformData = (data: AgChartOptions[\"data\"] | undefined, series: AgChartOptions[\"series\"] | undefined) => {\n  if (!data) return data;\n  if (!props.translateNullValues) return data;\n\n  // Collect all unique keys from all data objects\n  const allKeys = new Set<string>();\n  data.forEach((item) => {\n    Object.keys(item).forEach((key) => allKeys.add(key));\n  });\n\n  const yKeys: string[] = [];\n  // Line series render a gap instead of a placeholder: the placeholder is only\n  // invisible because of the `itemStyler` in `transformSeries`, which line series\n  // don't support, so a placeholder would draw a marker sitting at zero.\n  const gapKeys = new Set<string>();\n  series?.forEach((s) => {\n    if (\"yKey\" in s && s.yKey) {\n      yKeys.push(s.yKey);\n      if (s.type === \"line\") {\n        gapKeys.add(s.yKey);\n      }\n    }\n  });\n\n  // Ensure each data entry has all keys\n  const updatedData = data.map((item) => {\n    const newItem = { ...item };\n\n    // Add missing keys with NULL_PLACEHOLDER_VALUE\n    allKeys.forEach((key) => {\n      if (gapKeys.has(key)) {\n        return;\n      }\n      if (!(key in newItem)) {\n        newItem[key] = NULL_PLACEHOLDER_VALUE;\n      } else if (newItem[key] === null) {\n        // Replace null values with placeholder\n        newItem[key] = NULL_PLACEHOLDER_VALUE;\n      }\n    });\n\n    return newItem;\n  });\n\n  if (\n    yKeys.length > 0 &&\n    updatedData?.every((option) =>\n      yKeys.every((yKey) => !(yKey in option) || option[yKey] === NULL_PLACEHOLDER_VALUE || option[yKey] === null),\n    )\n  ) {\n    // In this case, we want to ensure that no data is displayed since it is all null.\n    return [];\n  }\n  return updatedData;\n};\n\ntype SeriesWithNullItemStyler = AgCartesianSeriesOptions & {\n  itemStyler?: (params: { yValue?: unknown }) => { fill: string; stroke: string } | undefined;\n};\n\nconst transformSeries = (series: AgChartOptions[\"series\"] | undefined) => {\n  if (!series) return series;\n  return series.map((s) => {\n    const newSeries = { ...s } as AgCartesianSeriesOptions;\n    if (!newSeries.tooltip) {\n      newSeries.tooltip = {};\n    }\n    if (!newSeries.tooltip.renderer) {\n      // @ts-expect-error allow setting renderer\n      newSeries.tooltip.renderer = defaultTooltipRenderer;\n    }\n\n    const stylableSeries = newSeries as SeriesWithNullItemStyler;\n    // Line series have no top-level `itemStyler` (AG Charts logs it as an unknown\n    // option) and never carry placeholder values - see `transformData`.\n    if (newSeries.type !== \"line\" && !stylableSeries.itemStyler) {\n      stylableSeries.itemStyler = (params: { yValue?: unknown }) => {\n        if (params.yValue === NULL_PLACEHOLDER_VALUE || params.yValue === null) {\n          return { fill: \"transparent\", stroke: \"transparent\" };\n        }\n      };\n    }\n    return newSeries;\n  });\n};\n\nconst seriesFormatter = computed(() => {\n  if (props.seriesFormatType === \"currency\") {\n    return currencyFormatter;\n  } else if (props.seriesFormatType === \"percent\") {\n    return 0;\n  }\n  return undefined;\n});\n\n// Its own computed so a custom palette is only rebuilt when the theme id changes.\nconst colorThemeChartTheme = computed(() => getColorThemeAGChartsTheme(props.colorTheme));\n\nconst chartOptions = computed(() => {\n  const currentOptions = { ...props.options };\n\n  if (!currentOptions.theme) {\n    currentOptions.theme = colorThemeChartTheme.value;\n  }\n  currentOptions.data = transformData(currentOptions.data, currentOptions.series);\n  currentOptions.series = transformSeries(currentOptions.series);\n\n  if (props.minHeight > 0 && !currentOptions.series?.some((series) => String(series.type) === \"map-shape\")) {\n    currentOptions.minHeight ??= props.minHeight;\n  }\n\n  if (!currentOptions.overlays) {\n    currentOptions.overlays = {\n      noData: {\n        text: NO_DATA_OVERLAY_TEXT,\n      },\n      noVisibleSeries: {\n        text: \"No visible series\",\n      },\n    };\n  }\n\n  //@ts-expect-error check type before setting\n  if (!currentOptions.axes) {\n    //@ts-expect-error check type before setting\n    currentOptions.axes = [\n      {\n        type: \"category\",\n        position: isHorizontalChart.value ? \"left\" : \"bottom\",\n      },\n      {\n        type: \"number\",\n        position: isHorizontalChart.value ? \"bottom\" : \"left\",\n        label: {\n          formatter: seriesFormatter.value,\n        },\n      },\n    ];\n  }\n\n  const series = currentOptions.series || [];\n  const scatterSeries = series.filter((s) => s.type === \"scatter\");\n  const centerOnCoords = props.customChartProps?.scatter?.centerOnCoords;\n  if (scatterSeries.length > 0 && centerOnCoords) {\n    if (centerOnCoords.x !== undefined && centerOnCoords.x !== null) {\n      applyCenterOnXAxis(currentOptions, centerOnCoords.x);\n    }\n    if (centerOnCoords.y !== undefined && centerOnCoords.y !== null) {\n      applyCenterOnYAxis(currentOptions, centerOnCoords.y);\n    }\n  }\n\n  if (!currentOptions.contextMenu) {\n    currentOptions.contextMenu = {\n      enabled: false,\n    };\n  }\n\n  currentOptions.listeners = {\n    ...(currentOptions.listeners || {}),\n    ...baseChartListeners,\n  };\n\n  return currentOptions;\n});\n\ndefineExpose({\n  getChartImageDataURL: (dimensions?: { width?: number; height?: number }): Promise<string> | undefined => {\n    const chart = chartRef.value?.chart;\n\n    return chart?.getImageDataURL({\n      width: dimensions?.width,\n      height: dimensions?.height,\n    });\n  },\n});\n</script>\n\n<template>\n  <div style=\"position: relative\">\n    <component\n      :is=\"agChartsComponent\"\n      v-if=\"agChartsComponent\"\n      ref=\"chartRef\"\n      style=\"height: 100%\"\n      :style=\"isMapChart ? '' : `min-height: ${minHeight}px`\"\n      :options=\"chartOptions\"\n    />\n    <div v-else style=\"height: 100%\" :style=\"isMapChart ? '' : `min-height: ${minHeight}px`\" />\n    <div v-if=\"isLoading || !agChartsComponent\" class=\"pv-flex pv-chart-loading\">\n      <PvSpinner size=\"xl\" />\n    </div>\n    <template v-if=\"isScatterChart && customChartProps?.scatter\">\n      <div v-if=\"customChartProps?.scatter?.quadrantRenderer\" class=\"pv-scatter-overlay\" :style=\"overlayStyle\">\n        <div class=\"pv-scatter-quadrant pv-scatter-quadrant-top-left\">\n          <div class=\"pv-scatter-quadrant-box\">\n            <component :is=\"customChartProps.scatter.quadrantRenderer\" :quadrant=\"'topLeft' as PvScatterQuadrant\" />\n          </div>\n        </div>\n        <div class=\"pv-scatter-quadrant pv-scatter-quadrant-top-right\">\n          <div class=\"pv-scatter-quadrant-box\">\n            <component :is=\"customChartProps.scatter.quadrantRenderer\" :quadrant=\"'topRight' as PvScatterQuadrant\" />\n          </div>\n        </div>\n        <div class=\"pv-scatter-quadrant pv-scatter-quadrant-bottom-left\">\n          <div class=\"pv-scatter-quadrant-box\">\n            <component :is=\"customChartProps.scatter.quadrantRenderer\" :quadrant=\"'bottomLeft' as PvScatterQuadrant\" />\n          </div>\n        </div>\n        <div class=\"pv-scatter-quadrant pv-scatter-quadrant-bottom-right\">\n          <div class=\"pv-scatter-quadrant-box\">\n            <component :is=\"customChartProps.scatter.quadrantRenderer\" :quadrant=\"'bottomRight' as PvScatterQuadrant\" />\n          </div>\n        </div>\n      </div>\n    </template>\n  </div>\n</template>\n\n<style scoped>\n.pv-scatter-overlay {\n  position: absolute;\n  top: 0;\n  left: 0;\n  width: 100%;\n  height: 100%;\n  pointer-events: none;\n  z-index: 2;\n  display: grid;\n  grid-template-columns: 1fr 1fr;\n  grid-template-rows: 1fr 1fr;\n}\n\n.pv-scatter-quadrant {\n  display: flex;\n  overflow: hidden;\n}\n\n.pv-scatter-quadrant-box {\n  background: rgba(128, 128, 128, 0.1);\n  padding: 8px;\n  border-radius: 4px;\n  font-size: 12px;\n  font-weight: 600;\n  color: #666;\n  pointer-events: all;\n  max-width: calc(100% - 10px);\n  max-height: calc(100% - 10px);\n  overflow: auto;\n}\n\n.pv-scatter-quadrant-top-left {\n  grid-column: 1;\n  grid-row: 1;\n  align-items: flex-start;\n  justify-content: flex-start;\n  padding: 5px;\n}\n\n.pv-scatter-quadrant-top-right {\n  grid-column: 2;\n  grid-row: 1;\n  align-items: flex-start;\n  justify-content: flex-end;\n  padding: 5px;\n}\n\n.pv-scatter-quadrant-bottom-left {\n  grid-column: 1;\n  grid-row: 2;\n  align-items: flex-end;\n  justify-content: flex-start;\n  padding: 5px;\n}\n\n.pv-scatter-quadrant-bottom-right {\n  grid-column: 2;\n  grid-row: 2;\n  align-items: flex-end;\n  justify-content: flex-end;\n  padding: 5px;\n}\n.pv-chart-loading {\n  position: absolute;\n  text-align: center;\n  justify-content: center;\n  align-items: center;\n  top: 0;\n  left: 0;\n  width: 100%;\n  height: 100%;\n  opacity: 1;\n  background-color: var(--color-background-body, white);\n  z-index: 4;\n}\n</style>\n","import type { AgChartOptions } from \"ag-charts-types\";\n\ntype ChartRecord = Record<string, unknown>;\n\n/** Pixels of horizontal width allotted per data point when a chart scrolls horizontally. */\nexport const CHART_SCROLL_ITEM_WIDTH_PX = 56;\n/** Pixels of vertical height allotted per data point when a horizontal-bar chart scrolls. */\nexport const CHART_SCROLL_ITEM_HEIGHT_PX = 32;\n/** Minimum canvas size for widget charts so they stay legible inside scroll containers. */\nconst WIDGET_CHART_MIN_SIZE_PX = 200;\n\n/** Coerce a numeric (pixel) or string CSS size into a CSS length, or `undefined` when unset. */\nexport const getCssSize = (value: number | string | undefined) => {\n  if (value === undefined) return undefined;\n\n  return typeof value === \"number\" ? `${value}px` : value;\n};\n\n/**\n * Build the explicit `height`/`width` (and matching `max-*`) style for a widget shell.\n * An explicit dimension also caps its `max-*` so the widget never grows past it.\n */\nexport const buildWidgetStyle = (dimensions: {\n  height?: number | string;\n  maxHeight?: number | string;\n  maxWidth?: number | string;\n  width?: number | string;\n}): Record<string, string> => {\n  const style: Record<string, string> = {};\n  const height = getCssSize(dimensions.height);\n  const maxHeight = getCssSize(dimensions.maxHeight);\n  const maxWidth = getCssSize(dimensions.maxWidth);\n  const width = getCssSize(dimensions.width);\n\n  if (height) {\n    style.height = height;\n    style.maxHeight = maxHeight ?? height;\n  } else if (maxHeight) {\n    style.maxHeight = maxHeight;\n  }\n\n  if (width) {\n    style.width = width;\n    style.maxWidth = maxWidth ?? width;\n  } else if (maxWidth) {\n    style.maxWidth = maxWidth;\n  }\n\n  return style;\n};\n\n/** Whether any explicit dimension bounds the widget shell (switching it to constrained flex layout). */\nexport const getIsWidgetConstrained = (dimensions: {\n  height?: number | string;\n  maxHeight?: number | string;\n  maxWidth?: number | string;\n  width?: number | string;\n}) => {\n  return Boolean(dimensions.height || dimensions.maxHeight || dimensions.maxWidth || dimensions.width);\n};\n\n/**\n * Minimum chart height for a widget: when a horizontal-bar chart scrolls vertically,\n * grow past the base height so every data point keeps its allotted row height.\n */\nexport const getScrollableChartMinHeight = (params: {\n  baseMinHeight: number;\n  dataCount: number;\n  enableChartScrolling: boolean;\n  isHorizontalScrollingChart: boolean;\n  itemHeight?: number;\n}) => {\n  if (!params.enableChartScrolling || !params.isHorizontalScrollingChart) return params.baseMinHeight;\n\n  return Math.max(params.baseMinHeight, params.dataCount * (params.itemHeight ?? CHART_SCROLL_ITEM_HEIGHT_PX));\n};\n\n/**\n * Overflow for a scrollable chart container, locked to the one axis the chart can grow\n * along: a horizontal-bar chart only ever grows taller, every other chart only ever\n * grows wider. Leaving both axes scrollable lets a chart that already fits scroll in the\n * direction it never overflows in, which reads as a stuck or jittery chart.\n *\n * Pair with the `pv-scrollbar-visible` utility - the platform's overlay scrollbars take\n * no layout space and stay hidden until a scroll gesture, so the affordance is invisible\n * without it. That utility also reserves a permanent scrollbar gutter, which is right for\n * a text panel but costs a chart 8px of dead plot area, so it is reset here: the chart\n * canvas resizes with the container anyway, so there is no layout shift to guard against.\n */\nexport const getChartScrollOverflowStyle = (params: {\n  enableChartScrolling: boolean;\n  isHorizontalScrollingChart: boolean;\n}): Record<string, string> | undefined => {\n  if (!params.enableChartScrolling) return undefined;\n\n  return params.isHorizontalScrollingChart\n    ? { overflowX: \"hidden\", overflowY: \"auto\", scrollbarGutter: \"auto\" }\n    : { overflowX: \"auto\", overflowY: \"hidden\", scrollbarGutter: \"auto\" };\n};\n\n/**\n * Inline style for the scrollable chart content: horizontal-bar charts grow vertically\n * per data point; all other charts grow horizontally, never below `minContentWidth`.\n */\nexport const getChartScrollContentStyle = (params: {\n  chartMinHeight: number;\n  dataCount: number;\n  enableChartScrolling: boolean;\n  isHorizontalScrollingChart: boolean;\n  minContentWidth: number;\n  // Width to subtract from the computed min-width, e.g. for a sidebar sharing the container.\n  reserveWidth?: number;\n}): Record<string, string> | undefined => {\n  if (!params.enableChartScrolling) return undefined;\n\n  if (params.isHorizontalScrollingChart) {\n    return { minHeight: `${params.chartMinHeight}px` };\n  }\n\n  const width =\n    Math.max(params.dataCount * CHART_SCROLL_ITEM_WIDTH_PX, params.minContentWidth) - (params.reserveWidth ?? 0);\n  return { minWidth: `${Math.max(width, 0)}px` };\n};\n\ntype ChartSeries = ChartRecord & {\n  direction?: string;\n  type?: string;\n};\n\nconst CARTESIAN_SERIES_TYPES = new Set([\"area\", \"bar\", \"histogram\", \"line\", \"scatter\"]);\n\n/** Coerce to a plain object record, or `undefined` when the value is not one. */\nexport const asObjectRecord = (value: unknown): ChartRecord | undefined => {\n  return value && typeof value === \"object\" && !Array.isArray(value) ? (value as ChartRecord) : undefined;\n};\n\nconst getResolvedDataLimit = (dataLimit: number | undefined) => {\n  if (dataLimit === undefined || !Number.isFinite(dataLimit) || dataLimit < 0) return undefined;\n\n  return Math.floor(dataLimit);\n};\n\nexport const limitDataRows = <T>(data: T[], dataLimit: number | undefined): T[] => {\n  const resolvedDataLimit = getResolvedDataLimit(dataLimit);\n\n  if (resolvedDataLimit === undefined) return data;\n\n  return data.slice(0, resolvedDataLimit);\n};\n\nconst getChartSeries = (options: AgChartOptions): ChartSeries[] => {\n  const series = (options as ChartRecord).series;\n\n  return Array.isArray(series) ? (series as ChartSeries[]) : [];\n};\n\nconst getHasCartesianSeries = (options: AgChartOptions) => {\n  return getChartSeries(options).some((seriesOption) => CARTESIAN_SERIES_TYPES.has(String(seriesOption.type)));\n};\n\nexport const getChartDataLength = (options: AgChartOptions) => {\n  const data = (options as ChartRecord).data;\n\n  return Array.isArray(data) ? data.length : 0;\n};\n\nexport const getIsHorizontalBarChart = (options: AgChartOptions) => {\n  return getChartSeries(options).some((seriesOption) => {\n    return seriesOption.type === \"bar\" && seriesOption.direction === \"horizontal\";\n  });\n};\n\nconst getDefaultCartesianAxes = (options: AgChartOptions) => {\n  const series = getChartSeries(options);\n\n  if (!getHasCartesianSeries(options)) return undefined;\n\n  const hasNumberXAxis = series.some((seriesOption) => {\n    const type = String(seriesOption.type);\n\n    return type === \"histogram\" || type === \"scatter\";\n  });\n\n  if (hasNumberXAxis) {\n    return [\n      { type: \"number\", position: \"bottom\" },\n      { type: \"number\", position: \"left\" },\n    ];\n  }\n\n  const isHorizontal = getIsHorizontalBarChart(options);\n\n  return [\n    { type: \"category\", position: isHorizontal ? \"left\" : \"bottom\" },\n    { type: \"number\", position: isHorizontal ? \"bottom\" : \"left\" },\n  ];\n};\n\nconst hideAxis = (axis: ChartRecord) => {\n  return {\n    ...axis,\n    gridLine: {\n      ...asObjectRecord(axis.gridLine),\n      enabled: false,\n    },\n    label: {\n      ...asObjectRecord(axis.label),\n      enabled: false,\n    },\n    line: {\n      ...asObjectRecord(axis.line),\n      enabled: false,\n    },\n    tick: {\n      ...asObjectRecord(axis.tick),\n      enabled: false,\n    },\n    title: {\n      ...asObjectRecord(axis.title),\n      enabled: false,\n    },\n  };\n};\n\nexport const applyChartWidgetOptions = (\n  options: AgChartOptions,\n  config: { dataLimit?: number; hideAxisTitles?: boolean; hideValueAxis?: boolean; showAxes?: boolean },\n): AgChartOptions => {\n  const output = { ...(options as ChartRecord) };\n  const chartData = output.data;\n\n  output.minWidth ??= WIDGET_CHART_MIN_SIZE_PX;\n  output.minHeight ??= WIDGET_CHART_MIN_SIZE_PX;\n\n  // AG Charts v12 does not support the v13 `scrollbar` option. Remove it here\n  // so callers can safely use widget-level scrolling without console warnings.\n  delete output.scrollbar;\n  const axes = Array.isArray(output.axes) ? (output.axes as ChartRecord[]) : getDefaultCartesianAxes(options);\n\n  if (Array.isArray(chartData)) {\n    output.data = limitDataRows(chartData, config.dataLimit);\n  }\n\n  const axesChanged = config.showAxes === false || Boolean(config.hideValueAxis) || Boolean(config.hideAxisTitles);\n\n  if (axes && axesChanged) {\n    const hideAllAxes = config.showAxes === false;\n    const valueAxisPosition = getIsHorizontalBarChart(options) ? \"bottom\" : \"left\";\n\n    output.axes = (axes as ChartRecord[]).map((axis) => {\n      let resolvedAxis = axis;\n\n      if (hideAllAxes || (config.hideValueAxis && axis.position === valueAxisPosition)) {\n        resolvedAxis = hideAxis(resolvedAxis);\n      }\n\n      if (config.hideAxisTitles) {\n        resolvedAxis = { ...resolvedAxis, title: { ...asObjectRecord(resolvedAxis.title), enabled: false } };\n      }\n\n      return resolvedAxis;\n    });\n  }\n\n  return output as AgChartOptions;\n};\n","<script setup lang=\"ts\">\nimport { computed, ref } from \"vue\";\nimport { useElementSize } from \"@vueuse/core\";\nimport PvChart from \"@charts/PvChart/PvChart.vue\";\nimport {\n  applyChartWidgetOptions,\n  buildWidgetStyle,\n  getChartDataLength,\n  getChartScrollContentStyle,\n  getChartScrollOverflowStyle,\n  getIsHorizontalBarChart,\n  getIsWidgetConstrained,\n  getScrollableChartMinHeight,\n} from \"@charts/widgetOptions\";\nimport type { AgSeriesVisibilityChange } from \"ag-charts-enterprise\";\nimport {\n  CHART_MIN_HEIGHT_PX,\n  DEFAULT_CONTAINER_WIDTH,\n  MINI_AUTO_BREAKPOINT_PX,\n  MINI_FORCED_BREAKPOINT_PX,\n} from \"./constants\";\nimport type { PvChartWidgetProps } from \"./types\";\n\nconst props = withDefaults(defineProps<PvChartWidgetProps>(), {\n  miniChart: \"disabled\",\n  seriesFormatType: \"none\",\n  isLoading: false,\n  enableChartScrolling: false,\n  enableFocusView: false,\n  showAxes: true,\n  translateNullValues: true,\n});\n\nconst emit = defineEmits<{\n  (e: \"series-visibility-change\", event: AgSeriesVisibilityChange): void;\n}>();\n\nconst widgetRef = ref<HTMLElement | null>(null);\nconst chartAreaRef = ref<HTMLElement | null>(null);\nconst pvChartRef = ref<InstanceType<typeof PvChart> | null>(null);\n\nconst { width: containerWidth } = useElementSize(widgetRef);\nconst { height: chartAreaHeight } = useElementSize(chartAreaRef);\n\nconst effectiveContainerWidth = computed(() => {\n  if (containerWidth.value > 0) return containerWidth.value;\n  if (typeof window !== \"undefined\" && window.innerWidth > 0) return window.innerWidth;\n  return DEFAULT_CONTAINER_WIDTH;\n});\n\nconst isMiniChart = computed(() => {\n  if (effectiveContainerWidth.value < MINI_FORCED_BREAKPOINT_PX) return true;\n  if (props.miniChart === \"always\") return true;\n\n  return props.miniChart === \"auto\" && effectiveContainerWidth.value < MINI_AUTO_BREAKPOINT_PX;\n});\n\n// PvChart's outer wrapper has no intrinsic height, so we drive its size by\n// passing the observed height as `minHeight`. ag-charts will render at exactly that\n// height, with CHART_MIN_HEIGHT_PX as a floor before measurement. The scroll container\n// is measured rather than the chart area so a horizontal scrollbar takes its space out\n// of the chart instead of clipping the category labels.\nconst effectiveMinHeight = computed(() => Math.max(chartAreaHeight.value, CHART_MIN_HEIGHT_PX));\n\nconst chartOptions = computed(() => {\n  return applyChartWidgetOptions(props.options, {\n    dataLimit: props.dataLimit,\n    showAxes: props.showAxes,\n  });\n});\n\nconst chartDataCount = computed(() => getChartDataLength(chartOptions.value));\nconst isHorizontalScrollingChart = computed(() => getIsHorizontalBarChart(chartOptions.value));\n\nconst effectiveChartMinHeight = computed(() =>\n  getScrollableChartMinHeight({\n    baseMinHeight: effectiveMinHeight.value,\n    dataCount: chartDataCount.value,\n    enableChartScrolling: props.enableChartScrolling,\n    isHorizontalScrollingChart: isHorizontalScrollingChart.value,\n  }),\n);\n\nconst isWidgetConstrained = computed(() => getIsWidgetConstrained(props));\n\nconst widgetStyle = computed(() => buildWidgetStyle(props));\n\nconst chartScrollStyle = computed(() =>\n  getChartScrollOverflowStyle({\n    enableChartScrolling: props.enableChartScrolling,\n    isHorizontalScrollingChart: isHorizontalScrollingChart.value,\n  }),\n);\n\nconst chartContentStyle = computed(() =>\n  getChartScrollContentStyle({\n    chartMinHeight: effectiveChartMinHeight.value,\n    dataCount: chartDataCount.value,\n    enableChartScrolling: props.enableChartScrolling,\n    isHorizontalScrollingChart: isHorizontalScrollingChart.value,\n    minContentWidth: effectiveContainerWidth.value,\n  }),\n);\n\ndefineExpose({\n  isMiniChart,\n  effectiveContainerWidth,\n  getChartImageDataURL: (dimensions?: { width?: number; height?: number }): Promise<string> | undefined => {\n    return pvChartRef.value?.getChartImageDataURL(dimensions);\n  },\n});\n</script>\n\n<template>\n  <div\n    ref=\"widgetRef\"\n    :class=\"[\n      'pv-chart-widget',\n      {\n        'pv-chart-widget--constrained': isWidgetConstrained,\n      },\n    ]\"\n    :style=\"widgetStyle\"\n  >\n    <div v-if=\"!isMiniChart && $slots.header\" class=\"pv-chart-widget__header\">\n      <slot name=\"header\" :isMiniChart=\"isMiniChart\" :effectiveContainerWidth=\"effectiveContainerWidth\" />\n    </div>\n    <div class=\"pv-chart-widget__chart-area\">\n      <div\n        ref=\"chartAreaRef\"\n        :class=\"[\n          'pv-chart-widget__chart-scroll',\n          {\n            'pv-chart-widget__chart-scroll--enabled pv-scrollbar-visible': enableChartScrolling,\n          },\n        ]\"\n        :style=\"chartScrollStyle\"\n      >\n        <div class=\"pv-chart-widget__chart-content\" :style=\"chartContentStyle\">\n          <PvChart\n            ref=\"pvChartRef\"\n            :options=\"chartOptions\"\n            :colorTheme=\"colorTheme\"\n            :seriesFormatType=\"seriesFormatType\"\n            :isLoading=\"isLoading\"\n            :enableFocusView=\"enableFocusView\"\n            :minHeight=\"effectiveChartMinHeight\"\n            :translateNullValues=\"translateNullValues\"\n            :customChartProps=\"customChartProps\"\n            @series-visibility-change=\"(e) => emit('series-visibility-change', e)\"\n          />\n        </div>\n      </div>\n    </div>\n    <slot name=\"footer\" :isMiniChart=\"isMiniChart\" :effectiveContainerWidth=\"effectiveContainerWidth\" />\n  </div>\n</template>\n\n<style scoped>\n.pv-chart-widget {\n  position: relative;\n  box-sizing: border-box;\n  display: flex;\n  flex-direction: column;\n  height: 100%;\n  min-height: 0;\n  min-width: 0;\n  width: 100%;\n}\n\n.pv-chart-widget--constrained {\n  overflow: hidden;\n}\n\n.pv-chart-widget__chart-area {\n  position: relative;\n  flex: 1 1 auto;\n  min-height: 0;\n  overflow: hidden;\n  width: 100%;\n}\n\n.pv-chart-widget__chart-scroll {\n  height: 100%;\n  min-height: 0;\n  width: 100%;\n}\n\n/* Overflow is set inline per chart orientation - see getChartScrollOverflowStyle. */\n\n.pv-chart-widget__chart-content {\n  height: 100%;\n  min-height: 100%;\n}\n</style>\n","<script setup lang=\"ts\">\nimport { computed, ref } from \"vue\";\nimport { useElementSize } from \"@vueuse/core\";\nimport PvChart from \"@charts/PvChart/PvChart.vue\";\nimport {\n  applyChartWidgetOptions,\n  buildWidgetStyle,\n  getChartDataLength,\n  getChartScrollContentStyle,\n  getChartScrollOverflowStyle,\n  getIsHorizontalBarChart,\n  getIsWidgetConstrained,\n  getScrollableChartMinHeight,\n} from \"@charts/widgetOptions\";\nimport type { AgSeriesVisibilityChange } from \"ag-charts-enterprise\";\nimport {\n  CHART_MIN_HEIGHT_PX,\n  DEFAULT_CONTAINER_WIDTH,\n  MINI_AUTO_BREAKPOINT_PX,\n  MINI_FORCED_BREAKPOINT_PX,\n} from \"./constants\";\nimport type { PvChartWidgetProps } from \"./types\";\n\nconst props = withDefaults(defineProps<PvChartWidgetProps>(), {\n  miniChart: \"disabled\",\n  seriesFormatType: \"none\",\n  isLoading: false,\n  enableChartScrolling: false,\n  enableFocusView: false,\n  showAxes: true,\n  translateNullValues: true,\n});\n\nconst emit = defineEmits<{\n  (e: \"series-visibility-change\", event: AgSeriesVisibilityChange): void;\n}>();\n\nconst widgetRef = ref<HTMLElement | null>(null);\nconst chartAreaRef = ref<HTMLElement | null>(null);\nconst pvChartRef = ref<InstanceType<typeof PvChart> | null>(null);\n\nconst { width: containerWidth } = useElementSize(widgetRef);\nconst { height: chartAreaHeight } = useElementSize(chartAreaRef);\n\nconst effectiveContainerWidth = computed(() => {\n  if (containerWidth.value > 0) return containerWidth.value;\n  if (typeof window !== \"undefined\" && window.innerWidth > 0) return window.innerWidth;\n  return DEFAULT_CONTAINER_WIDTH;\n});\n\nconst isMiniChart = computed(() => {\n  if (effectiveContainerWidth.value < MINI_FORCED_BREAKPOINT_PX) return true;\n  if (props.miniChart === \"always\") return true;\n\n  return props.miniChart === \"auto\" && effectiveContainerWidth.value < MINI_AUTO_BREAKPOINT_PX;\n});\n\n// PvChart's outer wrapper has no intrinsic height, so we drive its size by\n// passing the observed height as `minHeight`. ag-charts will render at exactly that\n// height, with CHART_MIN_HEIGHT_PX as a floor before measurement. The scroll container\n// is measured rather than the chart area so a horizontal scrollbar takes its space out\n// of the chart instead of clipping the category labels.\nconst effectiveMinHeight = computed(() => Math.max(chartAreaHeight.value, CHART_MIN_HEIGHT_PX));\n\nconst chartOptions = computed(() => {\n  return applyChartWidgetOptions(props.options, {\n    dataLimit: props.dataLimit,\n    showAxes: props.showAxes,\n  });\n});\n\nconst chartDataCount = computed(() => getChartDataLength(chartOptions.value));\nconst isHorizontalScrollingChart = computed(() => getIsHorizontalBarChart(chartOptions.value));\n\nconst effectiveChartMinHeight = computed(() =>\n  getScrollableChartMinHeight({\n    baseMinHeight: effectiveMinHeight.value,\n    dataCount: chartDataCount.value,\n    enableChartScrolling: props.enableChartScrolling,\n    isHorizontalScrollingChart: isHorizontalScrollingChart.value,\n  }),\n);\n\nconst isWidgetConstrained = computed(() => getIsWidgetConstrained(props));\n\nconst widgetStyle = computed(() => buildWidgetStyle(props));\n\nconst chartScrollStyle = computed(() =>\n  getChartScrollOverflowStyle({\n    enableChartScrolling: props.enableChartScrolling,\n    isHorizontalScrollingChart: isHorizontalScrollingChart.value,\n  }),\n);\n\nconst chartContentStyle = computed(() =>\n  getChartScrollContentStyle({\n    chartMinHeight: effectiveChartMinHeight.value,\n    dataCount: chartDataCount.value,\n    enableChartScrolling: props.enableChartScrolling,\n    isHorizontalScrollingChart: isHorizontalScrollingChart.value,\n    minContentWidth: effectiveContainerWidth.value,\n  }),\n);\n\ndefineExpose({\n  isMiniChart,\n  effectiveContainerWidth,\n  getChartImageDataURL: (dimensions?: { width?: number; height?: number }): Promise<string> | undefined => {\n    return pvChartRef.value?.getChartImageDataURL(dimensions);\n  },\n});\n</script>\n\n<template>\n  <div\n    ref=\"widgetRef\"\n    :class=\"[\n      'pv-chart-widget',\n      {\n        'pv-chart-widget--constrained': isWidgetConstrained,\n      },\n    ]\"\n    :style=\"widgetStyle\"\n  >\n    <div v-if=\"!isMiniChart && $slots.header\" class=\"pv-chart-widget__header\">\n      <slot name=\"header\" :isMiniChart=\"isMiniChart\" :effectiveContainerWidth=\"effectiveContainerWidth\" />\n    </div>\n    <div class=\"pv-chart-widget__chart-area\">\n      <div\n        ref=\"chartAreaRef\"\n        :class=\"[\n          'pv-chart-widget__chart-scroll',\n          {\n            'pv-chart-widget__chart-scroll--enabled pv-scrollbar-visible': enableChartScrolling,\n          },\n        ]\"\n        :style=\"chartScrollStyle\"\n      >\n        <div class=\"pv-chart-widget__chart-content\" :style=\"chartContentStyle\">\n          <PvChart\n            ref=\"pvChartRef\"\n            :options=\"chartOptions\"\n            :colorTheme=\"colorTheme\"\n            :seriesFormatType=\"seriesFormatType\"\n            :isLoading=\"isLoading\"\n            :enableFocusView=\"enableFocusView\"\n            :minHeight=\"effectiveChartMinHeight\"\n            :translateNullValues=\"translateNullValues\"\n            :customChartProps=\"customChartProps\"\n            @series-visibility-change=\"(e) => emit('series-visibility-change', e)\"\n          />\n        </div>\n      </div>\n    </div>\n    <slot name=\"footer\" :isMiniChart=\"isMiniChart\" :effectiveContainerWidth=\"effectiveContainerWidth\" />\n  </div>\n</template>\n\n<style scoped>\n.pv-chart-widget {\n  position: relative;\n  box-sizing: border-box;\n  display: flex;\n  flex-direction: column;\n  height: 100%;\n  min-height: 0;\n  min-width: 0;\n  width: 100%;\n}\n\n.pv-chart-widget--constrained {\n  overflow: hidden;\n}\n\n.pv-chart-widget__chart-area {\n  position: relative;\n  flex: 1 1 auto;\n  min-height: 0;\n  overflow: hidden;\n  width: 100%;\n}\n\n.pv-chart-widget__chart-scroll {\n  height: 100%;\n  min-height: 0;\n  width: 100%;\n}\n\n/* Overflow is set inline per chart orientation - see getChartScrollOverflowStyle. */\n\n.pv-chart-widget__chart-content {\n  height: 100%;\n  min-height: 100%;\n}\n</style>\n","<script setup lang=\"ts\">\nimport { computed } from \"vue\";\nimport { PvCardVariant } from \"./types\";\n\ninterface PvCardProps {\n  /** URL to navigate to when the card is clicked. Renders the card as an anchor element. */\n  href?: string;\n  /** Visual style variant of the card. */\n  variant?: PvCardVariant;\n  /** When true, renders the card as a button element with interactive styling. */\n  interactive?: boolean;\n  /**\n   * Renders the `header` slot as a hover-revealed-action row, paired with the\n   * `header-action` slot. Each row is opted into independently so an unused row\n   * doesn't render an empty slot and leave a gap. Slot presence can't be detected\n   * reliably for the web component build (native light-DOM slotting never\n   * populates Vue's `$slots`), so these are explicit props instead.\n   */\n  headerAction?: boolean;\n  /** Renders the `description` slot as a hover-revealed-action row, paired with the `description-action` slot. */\n  descriptionAction?: boolean;\n  /** Renders the `footer` slot as a hover-revealed-action row, paired with the `footer-action` slot. */\n  footerAction?: boolean;\n}\n\nconst props = withDefaults(defineProps<PvCardProps>(), {\n  variant: \"primary\",\n  interactive: false,\n  headerAction: false,\n  descriptionAction: false,\n  footerAction: false,\n});\n\nconst hasHoverActionRows = computed(() => props.headerAction || props.descriptionAction || props.footerAction);\n\nconst componentVariant = computed(() => {\n  return props.href ? \"a\" : props.interactive ? \"button\" : \"div\";\n});\n\n// Only set a `type` attribute when the card renders as a <button>. Anchors and\n// divs don't accept a meaningful `type`, and binding `type=\"div\"` to a <div>\n// produces invalid HTML.\nconst componentType = computed(() => {\n  return !props.href && props.interactive ? \"button\" : undefined;\n});\n\n// `pv-inline-block` shrink-wraps to content, which breaks `pv-truncate` (nowrap\n// text inflates the intrinsic width), so the hover-action layout needs a block\n// flex container instead.\nconst rootClasses = computed(\n  () => `pv-card pv-inset-square-8 ${hasHoverActionRows.value ? \"pv-flex-vertical\" : \"pv-inline-block\"}`,\n);\n</script>\n\n<template>\n  <component\n    :is=\"componentVariant\"\n    :href=\"href\"\n    :type=\"componentType\"\n    :class=\"[\n      rootClasses,\n      {\n        'pv-card-secondary': variant === 'secondary' && !hasHoverActionRows,\n        'pv-card-hover-action': hasHoverActionRows,\n        'pv-card-hover-action-secondary': hasHoverActionRows && variant === 'secondary',\n      },\n    ]\"\n    :style=\"hasHoverActionRows ? { '--flex-align': 'flex-start' } : undefined\"\n    data-testid=\"pv-card\"\n  >\n    <template v-if=\"hasHoverActionRows\">\n      <div v-if=\"headerAction\" class=\"pv-flex pv-full-width\">\n        <div class=\"pv-flex-item pv-truncate\">\n          <slot name=\"header\"></slot>\n        </div>\n        <div class=\"pv-card-hover-action__action pv-flex\">\n          <slot name=\"header-action\"></slot>\n        </div>\n      </div>\n      <div v-if=\"descriptionAction\" class=\"pv-flex pv-full-width\">\n        <div class=\"pv-flex-item pv-truncate\">\n          <slot name=\"description\"></slot>\n        </div>\n        <div class=\"pv-card-hover-action__action pv-flex\">\n          <slot name=\"description-action\"></slot>\n        </div>\n      </div>\n      <div v-if=\"footerAction\" class=\"pv-flex pv-full-width\">\n        <div class=\"pv-flex-item pv-truncate\">\n          <slot name=\"footer\"></slot>\n        </div>\n        <div class=\"pv-card-hover-action__action pv-flex\">\n          <slot name=\"footer-action\"></slot>\n        </div>\n      </div>\n    </template>\n    <slot v-else />\n  </component>\n</template>\n","<script setup lang=\"ts\">\nimport { computed } from \"vue\";\nimport { PvCardVariant } from \"./types\";\n\ninterface PvCardProps {\n  /** URL to navigate to when the card is clicked. Renders the card as an anchor element. */\n  href?: string;\n  /** Visual style variant of the card. */\n  variant?: PvCardVariant;\n  /** When true, renders the card as a button element with interactive styling. */\n  interactive?: boolean;\n  /**\n   * Renders the `header` slot as a hover-revealed-action row, paired with the\n   * `header-action` slot. Each row is opted into independently so an unused row\n   * doesn't render an empty slot and leave a gap. Slot presence can't be detected\n   * reliably for the web component build (native light-DOM slotting never\n   * populates Vue's `$slots`), so these are explicit props instead.\n   */\n  headerAction?: boolean;\n  /** Renders the `description` slot as a hover-revealed-action row, paired with the `description-action` slot. */\n  descriptionAction?: boolean;\n  /** Renders the `footer` slot as a hover-revealed-action row, paired with the `footer-action` slot. */\n  footerAction?: boolean;\n}\n\nconst props = withDefaults(defineProps<PvCardProps>(), {\n  variant: \"primary\",\n  interactive: false,\n  headerAction: false,\n  descriptionAction: false,\n  footerAction: false,\n});\n\nconst hasHoverActionRows = computed(() => props.headerAction || props.descriptionAction || props.footerAction);\n\nconst componentVariant = computed(() => {\n  return props.href ? \"a\" : props.interactive ? \"button\" : \"div\";\n});\n\n// Only set a `type` attribute when the card renders as a <button>. Anchors and\n// divs don't accept a meaningful `type`, and binding `type=\"div\"` to a <div>\n// produces invalid HTML.\nconst componentType = computed(() => {\n  return !props.href && props.interactive ? \"button\" : undefined;\n});\n\n// `pv-inline-block` shrink-wraps to content, which breaks `pv-truncate` (nowrap\n// text inflates the intrinsic width), so the hover-action layout needs a block\n// flex container instead.\nconst rootClasses = computed(\n  () => `pv-card pv-inset-square-8 ${hasHoverActionRows.value ? \"pv-flex-vertical\" : \"pv-inline-block\"}`,\n);\n</script>\n\n<template>\n  <component\n    :is=\"componentVariant\"\n    :href=\"href\"\n    :type=\"componentType\"\n    :class=\"[\n      rootClasses,\n      {\n        'pv-card-secondary': variant === 'secondary' && !hasHoverActionRows,\n        'pv-card-hover-action': hasHoverActionRows,\n        'pv-card-hover-action-secondary': hasHoverActionRows && variant === 'secondary',\n      },\n    ]\"\n    :style=\"hasHoverActionRows ? { '--flex-align': 'flex-start' } : undefined\"\n    data-testid=\"pv-card\"\n  >\n    <template v-if=\"hasHoverActionRows\">\n      <div v-if=\"headerAction\" class=\"pv-flex pv-full-width\">\n        <div class=\"pv-flex-item pv-truncate\">\n          <slot name=\"header\"></slot>\n        </div>\n        <div class=\"pv-card-hover-action__action pv-flex\">\n          <slot name=\"header-action\"></slot>\n        </div>\n      </div>\n      <div v-if=\"descriptionAction\" class=\"pv-flex pv-full-width\">\n        <div class=\"pv-flex-item pv-truncate\">\n          <slot name=\"description\"></slot>\n        </div>\n        <div class=\"pv-card-hover-action__action pv-flex\">\n          <slot name=\"description-action\"></slot>\n        </div>\n      </div>\n      <div v-if=\"footerAction\" class=\"pv-flex pv-full-width\">\n        <div class=\"pv-flex-item pv-truncate\">\n          <slot name=\"footer\"></slot>\n        </div>\n        <div class=\"pv-card-hover-action__action pv-flex\">\n          <slot name=\"footer-action\"></slot>\n        </div>\n      </div>\n    </template>\n    <slot v-else />\n  </component>\n</template>\n","import { PvButtonSize } from \"@/components/base/PvButton/types.ts\";\n\nexport const supportedInverseButtonVariants = [\"ghost\"];\n\nconst sizeToClassMap: Record<PvButtonSize, string | undefined> = {\n  md: \"pv-button-small\",\n  lg: undefined,\n  xl: \"pv-button-large\",\n};\n\nexport const pvButtonSizeToClass = (size: PvButtonSize | null | undefined): string | null => {\n  if (size == null || !sizeToClassMap.hasOwnProperty(size)) {\n    return null;\n  }\n  return sizeToClassMap[size] || null;\n};\n","/**\n * Utility functions for web components\n */\n\nimport { ref, getCurrentInstance } from \"vue\";\n\n/**\n * Composable to detect if a component is running as a web component\n * Returns a reactive ref that's set to true/false on mount\n *\n * @returns Reactive ref boolean indicating if running as web component\n *\n * @example\n * import { useIsWebComponent } from '@/web-components/utils';\n *\n * export default {\n *   setup() {\n *     const isWc = useIsWebComponent();\n *     // isWc.value is true if running as web component, false if Vue component\n *   }\n * }\n */\nexport function useIsWebComponent() {\n  const isWc = ref(false);\n  const instance = getCurrentInstance();\n  const root = instance?.root || {};\n  if (\"isCE\" in root && root.isCE === true) {\n    isWc.value = true;\n  }\n  return isWc;\n}\n","export const PvSizes = [\"xs\", \"sm\", \"md\", \"lg\", \"xl\", \"2x\"] as const;\nexport type PvSize = (typeof PvSizes)[number];\n\nexport const PvTheme = [\"white\", \"dark\"] as const;\nexport type PvThemes = (typeof PvTheme)[number];\n\nexport const PvVariants = [\"primary\", \"secondary\", \"tertiary\", \"ghost\", \"destructive\", \"transparent\"] as const;\nexport type PvVariants = (typeof PvVariants)[number];\n\nexport const PvColorVariants = [\"default\", \"success\", \"warning\", \"critical\", \"highlight\"] as const;\nexport type PvColorVariants = (typeof PvColorVariants)[number];\n\nexport const PvInputVariants = [\"h1\", \"h2\", \"h3\", \"h4\", \"text-md\", \"text-sm\", \"text-lg\", \"caption\"] as const;\nexport type PvInputVariants = (typeof PvInputVariants)[number];\n\nexport const PvTextInputColors = [\"white\", \"grey\"] as const;\nexport type PvTextInputColors = (typeof PvTextInputColors)[number];\n\nexport const PvOrientations = [\"vertical\", \"horizontal\"] as const;\nexport type PvOrientations = (typeof PvOrientations)[number];\n\nexport const sizeMap: Record<PvSize, string> = {\n  xs: \"12px\",\n  sm: \"16px\",\n  md: \"20px\",\n  lg: \"24px\",\n  xl: \"32px\",\n  \"2x\": \"40px\",\n};\n\nexport const PvIconSizes = [undefined, 10, 12, 16, 20, 24, 32, 64] as const;\nexport type PvIconSize = (typeof PvIconSizes)[number];\n\nexport type PvAlignmentPositions =\n  | \"bottom-left\"\n  | \"bottom-center\"\n  | \"bottom-right\"\n  | \"top-left\"\n  | \"top-center\"\n  | \"top-right\"\n  | \"center-left\"\n  | \"center-right\"\n  | \"right-top\"\n  | \"right-bottom\";\n","<script lang=\"ts\">\nimport { PvIconSizes } from \"../baseProps\";\n</script>\n<script setup lang=\"ts\">\nimport { computed, ref, Ref } from \"vue\";\nimport { useIsWebComponent } from \"@/web-components/utils\";\nimport type { PvIconProps } from \"./types\";\n\nconst props = defineProps<PvIconProps>();\nconst isWeb = useIsWebComponent();\n\nconst globalSpritePath: Ref<string | null> = ref(null);\n\nconst classes = computed(() => ({\n  \"pv-icon\": true,\n  [`pv-icon-${props.size}`]: props.size != null && PvIconSizes.includes(props.size),\n}));\n\nconst svgHref = computed(() => {\n  // If the global sprite path is set, use it\n  if (isWeb.value && globalSpritePath.value) {\n    return `${globalSpritePath.value}#${props.name}`;\n  }\n  return `#${props.name}`;\n});\n\n// @ts-expect-error ignore type error for globalThis\nif (globalThis.__PV_GLOBAL_SPRITE_PATH__) {\n  // We only want to use sprite paths for web components\n  // @ts-expect-error ignore type error for globalThis\n  globalSpritePath.value = globalThis.__PV_GLOBAL_SPRITE_PATH__;\n}\n</script>\n\n<template>\n  <svg data-testid=\"pv-icon\" aria-hidden=\"true\" :class=\"classes\">\n    <use :xlink:href=\"svgHref\"></use>\n  </svg>\n</template>\n","<script lang=\"ts\">\nimport { PvIconSizes } from \"../baseProps\";\n</script>\n<script setup lang=\"ts\">\nimport { computed, ref, Ref } from \"vue\";\nimport { useIsWebComponent } from \"@/web-components/utils\";\nimport type { PvIconProps } from \"./types\";\n\nconst props = defineProps<PvIconProps>();\nconst isWeb = useIsWebComponent();\n\nconst globalSpritePath: Ref<string | null> = ref(null);\n\nconst classes = computed(() => ({\n  \"pv-icon\": true,\n  [`pv-icon-${props.size}`]: props.size != null && PvIconSizes.includes(props.size),\n}));\n\nconst svgHref = computed(() => {\n  // If the global sprite path is set, use it\n  if (isWeb.value && globalSpritePath.value) {\n    return `${globalSpritePath.value}#${props.name}`;\n  }\n  return `#${props.name}`;\n});\n\n// @ts-expect-error ignore type error for globalThis\nif (globalThis.__PV_GLOBAL_SPRITE_PATH__) {\n  // We only want to use sprite paths for web components\n  // @ts-expect-error ignore type error for globalThis\n  globalSpritePath.value = globalThis.__PV_GLOBAL_SPRITE_PATH__;\n}\n</script>\n\n<template>\n  <svg data-testid=\"pv-icon\" aria-hidden=\"true\" :class=\"classes\">\n    <use :xlink:href=\"svgHref\"></use>\n  </svg>\n</template>\n","<script setup lang=\"ts\">\nimport { computed } from \"vue\";\nimport { PvCounterBadgeSize, PvCounterBadgeVariant } from \"./types\";\n\nexport interface PvCounterBadgeProps {\n  /** Maximum value before showing overflow indicator (e.g. \"99+\") */\n  maxValue?: number;\n  /** Text prefix displayed before the value */\n  prefix?: string;\n  /** Display size of the badge */\n  size?: PvCounterBadgeSize;\n  /** Numeric value to display */\n  value?: number;\n  /** Visual style variant */\n  variant?: PvCounterBadgeVariant;\n  /** Fully rounded */\n  rounded?: boolean;\n}\n\nconst props = withDefaults(defineProps<PvCounterBadgeProps>(), {\n  variant: \"primary\",\n  maxValue: 99,\n  size: \"sm\",\n  prefix: \"\",\n});\n\nconst displayValue = computed(() => {\n  if (props.maxValue && props.value && props.value > props.maxValue) {\n    return `${props.maxValue}+`;\n  }\n  if (props.value != null) {\n    return `${props.prefix}${props.value}`;\n  }\n  return \"-\";\n});\n\nconst classes = computed(() => ({\n  \"pv-inline-block pv-inset-square pv-radius pv-text-center\": true,\n  \"pv-badge-md pv-text-body-md\": props.size == \"md\",\n  \"pv-badge-sm pv-text-body-sm\": props.size == \"sm\",\n  \"pv-surface-brand-inverse pv-text-inverse\": props.variant == \"primary\",\n  \"pv-badge-secondary\": props.variant == \"secondary\",\n  \"pv-surface-lighten-5\": props.variant == \"tertiary\",\n  \"pv-text-subdued\": props.variant == \"ghost\" || props.variant == \"tertiary\",\n  \"pv-surface\": props.variant == \"ghost\",\n  \"pv-rounded\": props.rounded,\n}));\n</script>\n<template>\n  <div :class=\"classes\" data-testid=\"pv-counter-badge\">\n    {{ displayValue }}\n  </div>\n</template>\n\n<style scoped>\n.pv-badge-md {\n  --inset-size: 2px 2px;\n  min-height: 20px;\n  max-height: 20px;\n  min-width: 20px;\n  font-weight: 500;\n}\n.pv-badge-sm {\n  --inset-size: 0 2px;\n  min-height: 16px;\n  max-height: 16px;\n  min-width: 16px;\n  font-weight: 500;\n}\n.pv-rounded {\n  border-radius: 50%;\n}\n</style>\n","<script setup lang=\"ts\">\nimport { computed } from \"vue\";\nimport { PvCounterBadgeSize, PvCounterBadgeVariant } from \"./types\";\n\nexport interface PvCounterBadgeProps {\n  /** Maximum value before showing overflow indicator (e.g. \"99+\") */\n  maxValue?: number;\n  /** Text prefix displayed before the value */\n  prefix?: string;\n  /** Display size of the badge */\n  size?: PvCounterBadgeSize;\n  /** Numeric value to display */\n  value?: number;\n  /** Visual style variant */\n  variant?: PvCounterBadgeVariant;\n  /** Fully rounded */\n  rounded?: boolean;\n}\n\nconst props = withDefaults(defineProps<PvCounterBadgeProps>(), {\n  variant: \"primary\",\n  maxValue: 99,\n  size: \"sm\",\n  prefix: \"\",\n});\n\nconst displayValue = computed(() => {\n  if (props.maxValue && props.value && props.value > props.maxValue) {\n    return `${props.maxValue}+`;\n  }\n  if (props.value != null) {\n    return `${props.prefix}${props.value}`;\n  }\n  return \"-\";\n});\n\nconst classes = computed(() => ({\n  \"pv-inline-block pv-inset-square pv-radius pv-text-center\": true,\n  \"pv-badge-md pv-text-body-md\": props.size == \"md\",\n  \"pv-badge-sm pv-text-body-sm\": props.size == \"sm\",\n  \"pv-surface-brand-inverse pv-text-inverse\": props.variant == \"primary\",\n  \"pv-badge-secondary\": props.variant == \"secondary\",\n  \"pv-surface-lighten-5\": props.variant == \"tertiary\",\n  \"pv-text-subdued\": props.variant == \"ghost\" || props.variant == \"tertiary\",\n  \"pv-surface\": props.variant == \"ghost\",\n  \"pv-rounded\": props.rounded,\n}));\n</script>\n<template>\n  <div :class=\"classes\" data-testid=\"pv-counter-badge\">\n    {{ displayValue }}\n  </div>\n</template>\n\n<style scoped>\n.pv-badge-md {\n  --inset-size: 2px 2px;\n  min-height: 20px;\n  max-height: 20px;\n  min-width: 20px;\n  font-weight: 500;\n}\n.pv-badge-sm {\n  --inset-size: 0 2px;\n  min-height: 16px;\n  max-height: 16px;\n  min-width: 16px;\n  font-weight: 500;\n}\n.pv-rounded {\n  border-radius: 50%;\n}\n</style>\n","<script setup lang=\"ts\">\nimport { computed } from \"vue\";\nimport { PvButtonProps } from \"./types\";\nimport PvSpinner from \"../PvSpinner/PvSpinner.vue\";\nimport { pvButtonSizeToClass, supportedInverseButtonVariants } from \"@/components/base/PvButton/helpers.ts\";\nimport PvIcon from \"../PvIcon/PvIcon.vue\";\nimport PvCounterBadge from \"../PvCounterBadge/PvCounterBadge.vue\";\n\nconst props = withDefaults(defineProps<PvButtonProps>(), {\n  variant: \"primary\",\n  disabled: false,\n  size: \"lg\",\n  loading: false,\n  inverse: false,\n});\n\nconst computedAriaLabel = computed(() => (!props.label || props.loading ? props.label || props.ariaLabel : undefined));\n\nconst classes = computed(() => {\n  const output = [];\n  if (props.inverse && supportedInverseButtonVariants.includes(props.variant)) {\n    output.push(`pv-button-${props.variant}-inverse`);\n  } else {\n    output.push(`pv-button-${props.variant}`);\n  }\n  const sizeClass = pvButtonSizeToClass(props.size);\n  if (sizeClass) {\n    output.push(sizeClass);\n  }\n  return output;\n});\n</script>\n\n<template>\n  <button type=\"button\" :class=\"classes\" :disabled=\"disabled\" :aria-label=\"computedAriaLabel\" data-testid=\"pv-button\">\n    <PvSpinner v-if=\"loading\" size=\"sm\" />\n    <template v-else>\n      <PvCounterBadge v-if=\"leftCounterBadge\" :value=\"leftCounterBadge\" variant=\"tertiary\" />\n      <PvIcon v-if=\"leftIcon\" :name=\"leftIcon\" data-testid=\"pv-button-left-icon\" />\n      <span v-if=\"label\" data-testid=\"pv-button-label\">{{ label }}</span>\n      <PvCounterBadge v-if=\"rightCounterBadge\" :value=\"rightCounterBadge\" variant=\"tertiary\" />\n      <PvIcon v-if=\"rightIcon\" :name=\"rightIcon\" data-testid=\"pv-button-right-icon\" />\n    </template>\n  </button>\n</template>\n","<script setup lang=\"ts\">\nimport { computed } from \"vue\";\nimport { PvButtonProps } from \"./types\";\nimport PvSpinner from \"../PvSpinner/PvSpinner.vue\";\nimport { pvButtonSizeToClass, supportedInverseButtonVariants } from \"@/components/base/PvButton/helpers.ts\";\nimport PvIcon from \"../PvIcon/PvIcon.vue\";\nimport PvCounterBadge from \"../PvCounterBadge/PvCounterBadge.vue\";\n\nconst props = withDefaults(defineProps<PvButtonProps>(), {\n  variant: \"primary\",\n  disabled: false,\n  size: \"lg\",\n  loading: false,\n  inverse: false,\n});\n\nconst computedAriaLabel = computed(() => (!props.label || props.loading ? props.label || props.ariaLabel : undefined));\n\nconst classes = computed(() => {\n  const output = [];\n  if (props.inverse && supportedInverseButtonVariants.includes(props.variant)) {\n    output.push(`pv-button-${props.variant}-inverse`);\n  } else {\n    output.push(`pv-button-${props.variant}`);\n  }\n  const sizeClass = pvButtonSizeToClass(props.size);\n  if (sizeClass) {\n    output.push(sizeClass);\n  }\n  return output;\n});\n</script>\n\n<template>\n  <button type=\"button\" :class=\"classes\" :disabled=\"disabled\" :aria-label=\"computedAriaLabel\" data-testid=\"pv-button\">\n    <PvSpinner v-if=\"loading\" size=\"sm\" />\n    <template v-else>\n      <PvCounterBadge v-if=\"leftCounterBadge\" :value=\"leftCounterBadge\" variant=\"tertiary\" />\n      <PvIcon v-if=\"leftIcon\" :name=\"leftIcon\" data-testid=\"pv-button-left-icon\" />\n      <span v-if=\"label\" data-testid=\"pv-button-label\">{{ label }}</span>\n      <PvCounterBadge v-if=\"rightCounterBadge\" :value=\"rightCounterBadge\" variant=\"tertiary\" />\n      <PvIcon v-if=\"rightIcon\" :name=\"rightIcon\" data-testid=\"pv-button-right-icon\" />\n    </template>\n  </button>\n</template>\n","/**\n * Custom positioning reference element.\n * @see https://floating-ui.com/docs/virtual-elements\n */\n\nconst sides = ['top', 'right', 'bottom', 'left'];\nconst alignments = ['start', 'end'];\nconst placements = /*#__PURE__*/sides.reduce((acc, side) => acc.concat(side, side + \"-\" + alignments[0], side + \"-\" + alignments[1]), []);\nconst min = Math.min;\nconst max = Math.max;\nconst round = Math.round;\nconst floor = Math.floor;\nconst createCoords = v => ({\n  x: v,\n  y: v\n});\nconst oppositeSideMap = {\n  left: 'right',\n  right: 'left',\n  bottom: 'top',\n  top: 'bottom'\n};\nfunction clamp(start, value, end) {\n  return max(start, min(value, end));\n}\nfunction evaluate(value, param) {\n  return typeof value === 'function' ? value(param) : value;\n}\nfunction getSide(placement) {\n  return placement.split('-')[0];\n}\nfunction getAlignment(placement) {\n  return placement.split('-')[1];\n}\nfunction getOppositeAxis(axis) {\n  return axis === 'x' ? 'y' : 'x';\n}\nfunction getAxisLength(axis) {\n  return axis === 'y' ? 'height' : 'width';\n}\nfunction getSideAxis(placement) {\n  const firstChar = placement[0];\n  return firstChar === 't' || firstChar === 'b' ? 'y' : 'x';\n}\nfunction getAlignmentAxis(placement) {\n  return getOppositeAxis(getSideAxis(placement));\n}\nfunction getAlignmentSides(placement, rects, rtl) {\n  if (rtl === void 0) {\n    rtl = false;\n  }\n  const alignment = getAlignment(placement);\n  const alignmentAxis = getAlignmentAxis(placement);\n  const length = getAxisLength(alignmentAxis);\n  let mainAlignmentSide = alignmentAxis === 'x' ? alignment === (rtl ? 'end' : 'start') ? 'right' : 'left' : alignment === 'start' ? 'bottom' : 'top';\n  if (rects.reference[length] > rects.floating[length]) {\n    mainAlignmentSide = getOppositePlacement(mainAlignmentSide);\n  }\n  return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];\n}\nfunction getExpandedPlacements(placement) {\n  const oppositePlacement = getOppositePlacement(placement);\n  return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];\n}\nfunction getOppositeAlignmentPlacement(placement) {\n  return placement.includes('start') ? placement.replace('start', 'end') : placement.replace('end', 'start');\n}\nconst lrPlacement = ['left', 'right'];\nconst rlPlacement = ['right', 'left'];\nconst tbPlacement = ['top', 'bottom'];\nconst btPlacement = ['bottom', 'top'];\nfunction getSideList(side, isStart, rtl) {\n  switch (side) {\n    case 'top':\n    case 'bottom':\n      if (rtl) return isStart ? rlPlacement : lrPlacement;\n      return isStart ? lrPlacement : rlPlacement;\n    case 'left':\n    case 'right':\n      return isStart ? tbPlacement : btPlacement;\n    default:\n      return [];\n  }\n}\nfunction getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {\n  const alignment = getAlignment(placement);\n  let list = getSideList(getSide(placement), direction === 'start', rtl);\n  if (alignment) {\n    list = list.map(side => side + \"-\" + alignment);\n    if (flipAlignment) {\n      list = list.concat(list.map(getOppositeAlignmentPlacement));\n    }\n  }\n  return list;\n}\nfunction getOppositePlacement(placement) {\n  const side = getSide(placement);\n  return oppositeSideMap[side] + placement.slice(side.length);\n}\nfunction expandPaddingObject(padding) {\n  return {\n    top: 0,\n    right: 0,\n    bottom: 0,\n    left: 0,\n    ...padding\n  };\n}\nfunction getPaddingObject(padding) {\n  return typeof padding !== 'number' ? expandPaddingObject(padding) : {\n    top: padding,\n    right: padding,\n    bottom: padding,\n    left: padding\n  };\n}\nfunction rectToClientRect(rect) {\n  const {\n    x,\n    y,\n    width,\n    height\n  } = rect;\n  return {\n    width,\n    height,\n    top: y,\n    left: x,\n    right: x + width,\n    bottom: y + height,\n    x,\n    y\n  };\n}\n\nexport { alignments, clamp, createCoords, evaluate, expandPaddingObject, floor, getAlignment, getAlignmentAxis, getAlignmentSides, getAxisLength, getExpandedPlacements, getOppositeAlignmentPlacement, getOppositeAxis, getOppositeAxisPlacements, getOppositePlacement, getPaddingObject, getSide, getSideAxis, max, min, placements, rectToClientRect, round, sides };\n","import { getSideAxis, getAlignmentAxis, getAxisLength, getSide, getAlignment, evaluate, getPaddingObject, rectToClientRect, min, clamp, placements, getAlignmentSides, getOppositeAlignmentPlacement, getOppositePlacement, getExpandedPlacements, getOppositeAxisPlacements, sides, max, getOppositeAxis } from '@floating-ui/utils';\nexport { rectToClientRect } from '@floating-ui/utils';\n\nfunction computeCoordsFromPlacement(_ref, placement, rtl) {\n  let {\n    reference,\n    floating\n  } = _ref;\n  const sideAxis = getSideAxis(placement);\n  const alignmentAxis = getAlignmentAxis(placement);\n  const alignLength = getAxisLength(alignmentAxis);\n  const side = getSide(placement);\n  const isVertical = sideAxis === 'y';\n  const commonX = reference.x + reference.width / 2 - floating.width / 2;\n  const commonY = reference.y + reference.height / 2 - floating.height / 2;\n  const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;\n  let coords;\n  switch (side) {\n    case 'top':\n      coords = {\n        x: commonX,\n        y: reference.y - floating.height\n      };\n      break;\n    case 'bottom':\n      coords = {\n        x: commonX,\n        y: reference.y + reference.height\n      };\n      break;\n    case 'right':\n      coords = {\n        x: reference.x + reference.width,\n        y: commonY\n      };\n      break;\n    case 'left':\n      coords = {\n        x: reference.x - floating.width,\n        y: commonY\n      };\n      break;\n    default:\n      coords = {\n        x: reference.x,\n        y: reference.y\n      };\n  }\n  switch (getAlignment(placement)) {\n    case 'start':\n      coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);\n      break;\n    case 'end':\n      coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);\n      break;\n  }\n  return coords;\n}\n\n/**\n * Resolves with an object of overflow side offsets that determine how much the\n * element is overflowing a given clipping boundary on each side.\n * - positive = overflowing the boundary by that number of pixels\n * - negative = how many pixels left before it will overflow\n * - 0 = lies flush with the boundary\n * @see https://floating-ui.com/docs/detectOverflow\n */\nasync function detectOverflow(state, options) {\n  var _await$platform$isEle;\n  if (options === void 0) {\n    options = {};\n  }\n  const {\n    x,\n    y,\n    platform,\n    rects,\n    elements,\n    strategy\n  } = state;\n  const {\n    boundary = 'clippingAncestors',\n    rootBoundary = 'viewport',\n    elementContext = 'floating',\n    altBoundary = false,\n    padding = 0\n  } = evaluate(options, state);\n  const paddingObject = getPaddingObject(padding);\n  const altContext = elementContext === 'floating' ? 'reference' : 'floating';\n  const element = elements[altBoundary ? altContext : elementContext];\n  const clippingClientRect = rectToClientRect(await platform.getClippingRect({\n    element: ((_await$platform$isEle = await (platform.isElement == null ? void 0 : platform.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || (await (platform.getDocumentElement == null ? void 0 : platform.getDocumentElement(elements.floating))),\n    boundary,\n    rootBoundary,\n    strategy\n  }));\n  const rect = elementContext === 'floating' ? {\n    x,\n    y,\n    width: rects.floating.width,\n    height: rects.floating.height\n  } : rects.reference;\n  const offsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating));\n  const offsetScale = (await (platform.isElement == null ? void 0 : platform.isElement(offsetParent))) ? (await (platform.getScale == null ? void 0 : platform.getScale(offsetParent))) || {\n    x: 1,\n    y: 1\n  } : {\n    x: 1,\n    y: 1\n  };\n  const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({\n    elements,\n    rect,\n    offsetParent,\n    strategy\n  }) : rect);\n  return {\n    top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,\n    bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,\n    left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,\n    right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x\n  };\n}\n\n// Maximum number of resets that can occur before bailing to avoid infinite reset loops.\nconst MAX_RESET_COUNT = 50;\n\n/**\n * Computes the `x` and `y` coordinates that will place the floating element\n * next to a given reference element.\n *\n * This export does not have any `platform` interface logic. You will need to\n * write one for the platform you are using Floating UI with.\n */\nconst computePosition = async (reference, floating, config) => {\n  const {\n    placement = 'bottom',\n    strategy = 'absolute',\n    middleware = [],\n    platform\n  } = config;\n  const platformWithDetectOverflow = platform.detectOverflow ? platform : {\n    ...platform,\n    detectOverflow\n  };\n  const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));\n  let rects = await platform.getElementRects({\n    reference,\n    floating,\n    strategy\n  });\n  let {\n    x,\n    y\n  } = computeCoordsFromPlacement(rects, placement, rtl);\n  let statefulPlacement = placement;\n  let resetCount = 0;\n  const middlewareData = {};\n  for (let i = 0; i < middleware.length; i++) {\n    const currentMiddleware = middleware[i];\n    if (!currentMiddleware) {\n      continue;\n    }\n    const {\n      name,\n      fn\n    } = currentMiddleware;\n    const {\n      x: nextX,\n      y: nextY,\n      data,\n      reset\n    } = await fn({\n      x,\n      y,\n      initialPlacement: placement,\n      placement: statefulPlacement,\n      strategy,\n      middlewareData,\n      rects,\n      platform: platformWithDetectOverflow,\n      elements: {\n        reference,\n        floating\n      }\n    });\n    x = nextX != null ? nextX : x;\n    y = nextY != null ? nextY : y;\n    middlewareData[name] = {\n      ...middlewareData[name],\n      ...data\n    };\n    if (reset && resetCount < MAX_RESET_COUNT) {\n      resetCount++;\n      if (typeof reset === 'object') {\n        if (reset.placement) {\n          statefulPlacement = reset.placement;\n        }\n        if (reset.rects) {\n          rects = reset.rects === true ? await platform.getElementRects({\n            reference,\n            floating,\n            strategy\n          }) : reset.rects;\n        }\n        ({\n          x,\n          y\n        } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));\n      }\n      i = -1;\n    }\n  }\n  return {\n    x,\n    y,\n    placement: statefulPlacement,\n    strategy,\n    middlewareData\n  };\n};\n\n/**\n * Provides data to position an inner element of the floating element so that it\n * appears centered to the reference element.\n * @see https://floating-ui.com/docs/arrow\n */\nconst arrow = options => ({\n  name: 'arrow',\n  options,\n  async fn(state) {\n    const {\n      x,\n      y,\n      placement,\n      rects,\n      platform,\n      elements,\n      middlewareData\n    } = state;\n    // Since `element` is required, we don't Partial<> the type.\n    const {\n      element,\n      padding = 0\n    } = evaluate(options, state) || {};\n    if (element == null) {\n      return {};\n    }\n    const paddingObject = getPaddingObject(padding);\n    const coords = {\n      x,\n      y\n    };\n    const axis = getAlignmentAxis(placement);\n    const length = getAxisLength(axis);\n    const arrowDimensions = await platform.getDimensions(element);\n    const isYAxis = axis === 'y';\n    const minProp = isYAxis ? 'top' : 'left';\n    const maxProp = isYAxis ? 'bottom' : 'right';\n    const clientProp = isYAxis ? 'clientHeight' : 'clientWidth';\n    const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];\n    const startDiff = coords[axis] - rects.reference[axis];\n    const arrowOffsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(element));\n    let clientSize = arrowOffsetParent ? arrowOffsetParent[clientProp] : 0;\n\n    // DOM platform can return `window` as the `offsetParent`.\n    if (!clientSize || !(await (platform.isElement == null ? void 0 : platform.isElement(arrowOffsetParent)))) {\n      clientSize = elements.floating[clientProp] || rects.floating[length];\n    }\n    const centerToReference = endDiff / 2 - startDiff / 2;\n\n    // If the padding is large enough that it causes the arrow to no longer be\n    // centered, modify the padding so that it is centered.\n    const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;\n    const minPadding = min(paddingObject[minProp], largestPossiblePadding);\n    const maxPadding = min(paddingObject[maxProp], largestPossiblePadding);\n\n    // Make sure the arrow doesn't overflow the floating element if the center\n    // point is outside the floating element's bounds.\n    const min$1 = minPadding;\n    const max = clientSize - arrowDimensions[length] - maxPadding;\n    const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;\n    const offset = clamp(min$1, center, max);\n\n    // If the reference is small enough that the arrow's padding causes it to\n    // to point to nothing for an aligned placement, adjust the offset of the\n    // floating element itself. To ensure `shift()` continues to take action,\n    // a single reset is performed when this is true.\n    const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset && rects.reference[length] / 2 - (center < min$1 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;\n    const alignmentOffset = shouldAddOffset ? center < min$1 ? center - min$1 : center - max : 0;\n    return {\n      [axis]: coords[axis] + alignmentOffset,\n      data: {\n        [axis]: offset,\n        centerOffset: center - offset - alignmentOffset,\n        ...(shouldAddOffset && {\n          alignmentOffset\n        })\n      },\n      reset: shouldAddOffset\n    };\n  }\n});\n\nfunction getPlacementList(alignment, autoAlignment, allowedPlacements) {\n  const allowedPlacementsSortedByAlignment = alignment ? [...allowedPlacements.filter(placement => getAlignment(placement) === alignment), ...allowedPlacements.filter(placement => getAlignment(placement) !== alignment)] : allowedPlacements.filter(placement => getSide(placement) === placement);\n  return allowedPlacementsSortedByAlignment.filter(placement => {\n    if (alignment) {\n      return getAlignment(placement) === alignment || (autoAlignment ? getOppositeAlignmentPlacement(placement) !== placement : false);\n    }\n    return true;\n  });\n}\n/**\n * Optimizes the visibility of the floating element by choosing the placement\n * that has the most space available automatically, without needing to specify a\n * preferred placement. Alternative to `flip`.\n * @see https://floating-ui.com/docs/autoPlacement\n */\nconst autoPlacement = function (options) {\n  if (options === void 0) {\n    options = {};\n  }\n  return {\n    name: 'autoPlacement',\n    options,\n    async fn(state) {\n      var _middlewareData$autoP, _middlewareData$autoP2, _placementsThatFitOnE;\n      const {\n        rects,\n        middlewareData,\n        placement,\n        platform,\n        elements\n      } = state;\n      const {\n        crossAxis = false,\n        alignment,\n        allowedPlacements = placements,\n        autoAlignment = true,\n        ...detectOverflowOptions\n      } = evaluate(options, state);\n      const placements$1 = alignment !== undefined || allowedPlacements === placements ? getPlacementList(alignment || null, autoAlignment, allowedPlacements) : allowedPlacements;\n      const overflow = await platform.detectOverflow(state, detectOverflowOptions);\n      const currentIndex = ((_middlewareData$autoP = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP.index) || 0;\n      const currentPlacement = placements$1[currentIndex];\n      if (currentPlacement == null) {\n        return {};\n      }\n      const alignmentSides = getAlignmentSides(currentPlacement, rects, await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating)));\n\n      // Make `computeCoords` start from the right place.\n      if (placement !== currentPlacement) {\n        return {\n          reset: {\n            placement: placements$1[0]\n          }\n        };\n      }\n      const currentOverflows = [overflow[getSide(currentPlacement)], overflow[alignmentSides[0]], overflow[alignmentSides[1]]];\n      const allOverflows = [...(((_middlewareData$autoP2 = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP2.overflows) || []), {\n        placement: currentPlacement,\n        overflows: currentOverflows\n      }];\n      const nextPlacement = placements$1[currentIndex + 1];\n\n      // There are more placements to check.\n      if (nextPlacement) {\n        return {\n          data: {\n            index: currentIndex + 1,\n            overflows: allOverflows\n          },\n          reset: {\n            placement: nextPlacement\n          }\n        };\n      }\n      const placementsSortedByMostSpace = allOverflows.map(d => {\n        const alignment = getAlignment(d.placement);\n        return [d.placement, alignment && crossAxis ?\n        // Check along the mainAxis and main crossAxis side.\n        d.overflows.slice(0, 2).reduce((acc, v) => acc + v, 0) :\n        // Check only the mainAxis.\n        d.overflows[0], d.overflows];\n      }).sort((a, b) => a[1] - b[1]);\n      const placementsThatFitOnEachSide = placementsSortedByMostSpace.filter(d => d[2].slice(0,\n      // Aligned placements should not check their opposite crossAxis\n      // side.\n      getAlignment(d[0]) ? 2 : 3).every(v => v <= 0));\n      const resetPlacement = ((_placementsThatFitOnE = placementsThatFitOnEachSide[0]) == null ? void 0 : _placementsThatFitOnE[0]) || placementsSortedByMostSpace[0][0];\n      if (resetPlacement !== placement) {\n        return {\n          data: {\n            index: currentIndex + 1,\n            overflows: allOverflows\n          },\n          reset: {\n            placement: resetPlacement\n          }\n        };\n      }\n      return {};\n    }\n  };\n};\n\n/**\n * Optimizes the visibility of the floating element by flipping the `placement`\n * in order to keep it in view when the preferred placement(s) will overflow the\n * clipping boundary. Alternative to `autoPlacement`.\n * @see https://floating-ui.com/docs/flip\n */\nconst flip = function (options) {\n  if (options === void 0) {\n    options = {};\n  }\n  return {\n    name: 'flip',\n    options,\n    async fn(state) {\n      var _middlewareData$arrow, _middlewareData$flip;\n      const {\n        placement,\n        middlewareData,\n        rects,\n        initialPlacement,\n        platform,\n        elements\n      } = state;\n      const {\n        mainAxis: checkMainAxis = true,\n        crossAxis: checkCrossAxis = true,\n        fallbackPlacements: specifiedFallbackPlacements,\n        fallbackStrategy = 'bestFit',\n        fallbackAxisSideDirection = 'none',\n        flipAlignment = true,\n        ...detectOverflowOptions\n      } = evaluate(options, state);\n\n      // If a reset by the arrow was caused due to an alignment offset being\n      // added, we should skip any logic now since `flip()` has already done its\n      // work.\n      // https://github.com/floating-ui/floating-ui/issues/2549#issuecomment-1719601643\n      if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {\n        return {};\n      }\n      const side = getSide(placement);\n      const initialSideAxis = getSideAxis(initialPlacement);\n      const isBasePlacement = getSide(initialPlacement) === initialPlacement;\n      const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));\n      const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));\n      const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== 'none';\n      if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {\n        fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));\n      }\n      const placements = [initialPlacement, ...fallbackPlacements];\n      const overflow = await platform.detectOverflow(state, detectOverflowOptions);\n      const overflows = [];\n      let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];\n      if (checkMainAxis) {\n        overflows.push(overflow[side]);\n      }\n      if (checkCrossAxis) {\n        const sides = getAlignmentSides(placement, rects, rtl);\n        overflows.push(overflow[sides[0]], overflow[sides[1]]);\n      }\n      overflowsData = [...overflowsData, {\n        placement,\n        overflows\n      }];\n\n      // One or more sides is overflowing.\n      if (!overflows.every(side => side <= 0)) {\n        var _middlewareData$flip2, _overflowsData$filter;\n        const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;\n        const nextPlacement = placements[nextIndex];\n        if (nextPlacement) {\n          const ignoreCrossAxisOverflow = checkCrossAxis === 'alignment' ? initialSideAxis !== getSideAxis(nextPlacement) : false;\n          if (!ignoreCrossAxisOverflow ||\n          // We leave the current main axis only if every placement on that axis\n          // overflows the main axis.\n          overflowsData.every(d => getSideAxis(d.placement) === initialSideAxis ? d.overflows[0] > 0 : true)) {\n            // Try next placement and re-run the lifecycle.\n            return {\n              data: {\n                index: nextIndex,\n                overflows: overflowsData\n              },\n              reset: {\n                placement: nextPlacement\n              }\n            };\n          }\n        }\n\n        // First, find the candidates that fit on the mainAxis side of overflow,\n        // then find the placement that fits the best on the main crossAxis side.\n        let resetPlacement = (_overflowsData$filter = overflowsData.filter(d => d.overflows[0] <= 0).sort((a, b) => a.overflows[1] - b.overflows[1])[0]) == null ? void 0 : _overflowsData$filter.placement;\n\n        // Otherwise fallback.\n        if (!resetPlacement) {\n          switch (fallbackStrategy) {\n            case 'bestFit':\n              {\n                var _overflowsData$filter2;\n                const placement = (_overflowsData$filter2 = overflowsData.filter(d => {\n                  if (hasFallbackAxisSideDirection) {\n                    const currentSideAxis = getSideAxis(d.placement);\n                    return currentSideAxis === initialSideAxis ||\n                    // Create a bias to the `y` side axis due to horizontal\n                    // reading directions favoring greater width.\n                    currentSideAxis === 'y';\n                  }\n                  return true;\n                }).map(d => [d.placement, d.overflows.filter(overflow => overflow > 0).reduce((acc, overflow) => acc + overflow, 0)]).sort((a, b) => a[1] - b[1])[0]) == null ? void 0 : _overflowsData$filter2[0];\n                if (placement) {\n                  resetPlacement = placement;\n                }\n                break;\n              }\n            case 'initialPlacement':\n              resetPlacement = initialPlacement;\n              break;\n          }\n        }\n        if (placement !== resetPlacement) {\n          return {\n            reset: {\n              placement: resetPlacement\n            }\n          };\n        }\n      }\n      return {};\n    }\n  };\n};\n\nfunction getSideOffsets(overflow, rect) {\n  return {\n    top: overflow.top - rect.height,\n    right: overflow.right - rect.width,\n    bottom: overflow.bottom - rect.height,\n    left: overflow.left - rect.width\n  };\n}\nfunction isAnySideFullyClipped(overflow) {\n  return sides.some(side => overflow[side] >= 0);\n}\n/**\n * Provides data to hide the floating element in applicable situations, such as\n * when it is not in the same clipping context as the reference element.\n * @see https://floating-ui.com/docs/hide\n */\nconst hide = function (options) {\n  if (options === void 0) {\n    options = {};\n  }\n  return {\n    name: 'hide',\n    options,\n    async fn(state) {\n      const {\n        rects,\n        platform\n      } = state;\n      const {\n        strategy = 'referenceHidden',\n        ...detectOverflowOptions\n      } = evaluate(options, state);\n      switch (strategy) {\n        case 'referenceHidden':\n          {\n            const overflow = await platform.detectOverflow(state, {\n              ...detectOverflowOptions,\n              elementContext: 'reference'\n            });\n            const offsets = getSideOffsets(overflow, rects.reference);\n            return {\n              data: {\n                referenceHiddenOffsets: offsets,\n                referenceHidden: isAnySideFullyClipped(offsets)\n              }\n            };\n          }\n        case 'escaped':\n          {\n            const overflow = await platform.detectOverflow(state, {\n              ...detectOverflowOptions,\n              altBoundary: true\n            });\n            const offsets = getSideOffsets(overflow, rects.floating);\n            return {\n              data: {\n                escapedOffsets: offsets,\n                escaped: isAnySideFullyClipped(offsets)\n              }\n            };\n          }\n        default:\n          {\n            return {};\n          }\n      }\n    }\n  };\n};\n\nfunction getBoundingRect(rects) {\n  const minX = min(...rects.map(rect => rect.left));\n  const minY = min(...rects.map(rect => rect.top));\n  const maxX = max(...rects.map(rect => rect.right));\n  const maxY = max(...rects.map(rect => rect.bottom));\n  return {\n    x: minX,\n    y: minY,\n    width: maxX - minX,\n    height: maxY - minY\n  };\n}\nfunction getRectsByLine(rects) {\n  const sortedRects = rects.slice().sort((a, b) => a.y - b.y);\n  const groups = [];\n  let prevRect = null;\n  for (let i = 0; i < sortedRects.length; i++) {\n    const rect = sortedRects[i];\n    if (!prevRect || rect.y - prevRect.y > prevRect.height / 2) {\n      groups.push([rect]);\n    } else {\n      groups[groups.length - 1].push(rect);\n    }\n    prevRect = rect;\n  }\n  return groups.map(rect => rectToClientRect(getBoundingRect(rect)));\n}\n/**\n * Provides improved positioning for inline reference elements that can span\n * over multiple lines, such as hyperlinks or range selections.\n * @see https://floating-ui.com/docs/inline\n */\nconst inline = function (options) {\n  if (options === void 0) {\n    options = {};\n  }\n  return {\n    name: 'inline',\n    options,\n    async fn(state) {\n      const {\n        placement,\n        elements,\n        rects,\n        platform,\n        strategy\n      } = state;\n      // A MouseEvent's client{X,Y} coords can be up to 2 pixels off a\n      // ClientRect's bounds, despite the event listener being triggered. A\n      // padding of 2 seems to handle this issue.\n      const {\n        padding = 2,\n        x,\n        y\n      } = evaluate(options, state);\n      const nativeClientRects = Array.from((await (platform.getClientRects == null ? void 0 : platform.getClientRects(elements.reference))) || []);\n      const clientRects = getRectsByLine(nativeClientRects);\n      const fallback = rectToClientRect(getBoundingRect(nativeClientRects));\n      const paddingObject = getPaddingObject(padding);\n      function getBoundingClientRect() {\n        // There are two rects and they are disjoined.\n        if (clientRects.length === 2 && clientRects[0].left > clientRects[1].right && x != null && y != null) {\n          // Find the first rect in which the point is fully inside.\n          return clientRects.find(rect => x > rect.left - paddingObject.left && x < rect.right + paddingObject.right && y > rect.top - paddingObject.top && y < rect.bottom + paddingObject.bottom) || fallback;\n        }\n\n        // There are 2 or more connected rects.\n        if (clientRects.length >= 2) {\n          if (getSideAxis(placement) === 'y') {\n            const firstRect = clientRects[0];\n            const lastRect = clientRects[clientRects.length - 1];\n            const isTop = getSide(placement) === 'top';\n            const top = firstRect.top;\n            const bottom = lastRect.bottom;\n            const left = isTop ? firstRect.left : lastRect.left;\n            const right = isTop ? firstRect.right : lastRect.right;\n            const width = right - left;\n            const height = bottom - top;\n            return {\n              top,\n              bottom,\n              left,\n              right,\n              width,\n              height,\n              x: left,\n              y: top\n            };\n          }\n          const isLeftSide = getSide(placement) === 'left';\n          const maxRight = max(...clientRects.map(rect => rect.right));\n          const minLeft = min(...clientRects.map(rect => rect.left));\n          const measureRects = clientRects.filter(rect => isLeftSide ? rect.left === minLeft : rect.right === maxRight);\n          const top = measureRects[0].top;\n          const bottom = measureRects[measureRects.length - 1].bottom;\n          const left = minLeft;\n          const right = maxRight;\n          const width = right - left;\n          const height = bottom - top;\n          return {\n            top,\n            bottom,\n            left,\n            right,\n            width,\n            height,\n            x: left,\n            y: top\n          };\n        }\n        return fallback;\n      }\n      const resetRects = await platform.getElementRects({\n        reference: {\n          getBoundingClientRect\n        },\n        floating: elements.floating,\n        strategy\n      });\n      if (rects.reference.x !== resetRects.reference.x || rects.reference.y !== resetRects.reference.y || rects.reference.width !== resetRects.reference.width || rects.reference.height !== resetRects.reference.height) {\n        return {\n          reset: {\n            rects: resetRects\n          }\n        };\n      }\n      return {};\n    }\n  };\n};\n\nconst originSides = /*#__PURE__*/new Set(['left', 'top']);\n\n// For type backwards-compatibility, the `OffsetOptions` type was also\n// Derivable.\n\nasync function convertValueToCoords(state, options) {\n  const {\n    placement,\n    platform,\n    elements\n  } = state;\n  const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));\n  const side = getSide(placement);\n  const alignment = getAlignment(placement);\n  const isVertical = getSideAxis(placement) === 'y';\n  const mainAxisMulti = originSides.has(side) ? -1 : 1;\n  const crossAxisMulti = rtl && isVertical ? -1 : 1;\n  const rawValue = evaluate(options, state);\n\n  // eslint-disable-next-line prefer-const\n  let {\n    mainAxis,\n    crossAxis,\n    alignmentAxis\n  } = typeof rawValue === 'number' ? {\n    mainAxis: rawValue,\n    crossAxis: 0,\n    alignmentAxis: null\n  } : {\n    mainAxis: rawValue.mainAxis || 0,\n    crossAxis: rawValue.crossAxis || 0,\n    alignmentAxis: rawValue.alignmentAxis\n  };\n  if (alignment && typeof alignmentAxis === 'number') {\n    crossAxis = alignment === 'end' ? alignmentAxis * -1 : alignmentAxis;\n  }\n  return isVertical ? {\n    x: crossAxis * crossAxisMulti,\n    y: mainAxis * mainAxisMulti\n  } : {\n    x: mainAxis * mainAxisMulti,\n    y: crossAxis * crossAxisMulti\n  };\n}\n\n/**\n * Modifies the placement by translating the floating element along the\n * specified axes.\n * A number (shorthand for `mainAxis` or distance), or an axes configuration\n * object may be passed.\n * @see https://floating-ui.com/docs/offset\n */\nconst offset = function (options) {\n  if (options === void 0) {\n    options = 0;\n  }\n  return {\n    name: 'offset',\n    options,\n    async fn(state) {\n      var _middlewareData$offse, _middlewareData$arrow;\n      const {\n        x,\n        y,\n        placement,\n        middlewareData\n      } = state;\n      const diffCoords = await convertValueToCoords(state, options);\n\n      // If the placement is the same and the arrow caused an alignment offset\n      // then we don't need to change the positioning coordinates.\n      if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {\n        return {};\n      }\n      return {\n        x: x + diffCoords.x,\n        y: y + diffCoords.y,\n        data: {\n          ...diffCoords,\n          placement\n        }\n      };\n    }\n  };\n};\n\n/**\n * Optimizes the visibility of the floating element by shifting it in order to\n * keep it in view when it will overflow the clipping boundary.\n * @see https://floating-ui.com/docs/shift\n */\nconst shift = function (options) {\n  if (options === void 0) {\n    options = {};\n  }\n  return {\n    name: 'shift',\n    options,\n    async fn(state) {\n      const {\n        x,\n        y,\n        placement,\n        platform\n      } = state;\n      const {\n        mainAxis: checkMainAxis = true,\n        crossAxis: checkCrossAxis = false,\n        limiter = {\n          fn: _ref => {\n            let {\n              x,\n              y\n            } = _ref;\n            return {\n              x,\n              y\n            };\n          }\n        },\n        ...detectOverflowOptions\n      } = evaluate(options, state);\n      const coords = {\n        x,\n        y\n      };\n      const overflow = await platform.detectOverflow(state, detectOverflowOptions);\n      const crossAxis = getSideAxis(getSide(placement));\n      const mainAxis = getOppositeAxis(crossAxis);\n      let mainAxisCoord = coords[mainAxis];\n      let crossAxisCoord = coords[crossAxis];\n      if (checkMainAxis) {\n        const minSide = mainAxis === 'y' ? 'top' : 'left';\n        const maxSide = mainAxis === 'y' ? 'bottom' : 'right';\n        const min = mainAxisCoord + overflow[minSide];\n        const max = mainAxisCoord - overflow[maxSide];\n        mainAxisCoord = clamp(min, mainAxisCoord, max);\n      }\n      if (checkCrossAxis) {\n        const minSide = crossAxis === 'y' ? 'top' : 'left';\n        const maxSide = crossAxis === 'y' ? 'bottom' : 'right';\n        const min = crossAxisCoord + overflow[minSide];\n        const max = crossAxisCoord - overflow[maxSide];\n        crossAxisCoord = clamp(min, crossAxisCoord, max);\n      }\n      const limitedCoords = limiter.fn({\n        ...state,\n        [mainAxis]: mainAxisCoord,\n        [crossAxis]: crossAxisCoord\n      });\n      return {\n        ...limitedCoords,\n        data: {\n          x: limitedCoords.x - x,\n          y: limitedCoords.y - y,\n          enabled: {\n            [mainAxis]: checkMainAxis,\n            [crossAxis]: checkCrossAxis\n          }\n        }\n      };\n    }\n  };\n};\n/**\n * Built-in `limiter` that will stop `shift()` at a certain point.\n */\nconst limitShift = function (options) {\n  if (options === void 0) {\n    options = {};\n  }\n  return {\n    options,\n    fn(state) {\n      const {\n        x,\n        y,\n        placement,\n        rects,\n        middlewareData\n      } = state;\n      const {\n        offset = 0,\n        mainAxis: checkMainAxis = true,\n        crossAxis: checkCrossAxis = true\n      } = evaluate(options, state);\n      const coords = {\n        x,\n        y\n      };\n      const crossAxis = getSideAxis(placement);\n      const mainAxis = getOppositeAxis(crossAxis);\n      let mainAxisCoord = coords[mainAxis];\n      let crossAxisCoord = coords[crossAxis];\n      const rawOffset = evaluate(offset, state);\n      const computedOffset = typeof rawOffset === 'number' ? {\n        mainAxis: rawOffset,\n        crossAxis: 0\n      } : {\n        mainAxis: 0,\n        crossAxis: 0,\n        ...rawOffset\n      };\n      if (checkMainAxis) {\n        const len = mainAxis === 'y' ? 'height' : 'width';\n        const limitMin = rects.reference[mainAxis] - rects.floating[len] + computedOffset.mainAxis;\n        const limitMax = rects.reference[mainAxis] + rects.reference[len] - computedOffset.mainAxis;\n        if (mainAxisCoord < limitMin) {\n          mainAxisCoord = limitMin;\n        } else if (mainAxisCoord > limitMax) {\n          mainAxisCoord = limitMax;\n        }\n      }\n      if (checkCrossAxis) {\n        var _middlewareData$offse, _middlewareData$offse2;\n        const len = mainAxis === 'y' ? 'width' : 'height';\n        const isOriginSide = originSides.has(getSide(placement));\n        const limitMin = rects.reference[crossAxis] - rects.floating[len] + (isOriginSide ? ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse[crossAxis]) || 0 : 0) + (isOriginSide ? 0 : computedOffset.crossAxis);\n        const limitMax = rects.reference[crossAxis] + rects.reference[len] + (isOriginSide ? 0 : ((_middlewareData$offse2 = middlewareData.offset) == null ? void 0 : _middlewareData$offse2[crossAxis]) || 0) - (isOriginSide ? computedOffset.crossAxis : 0);\n        if (crossAxisCoord < limitMin) {\n          crossAxisCoord = limitMin;\n        } else if (crossAxisCoord > limitMax) {\n          crossAxisCoord = limitMax;\n        }\n      }\n      return {\n        [mainAxis]: mainAxisCoord,\n        [crossAxis]: crossAxisCoord\n      };\n    }\n  };\n};\n\n/**\n * Provides data that allows you to change the size of the floating element —\n * for instance, prevent it from overflowing the clipping boundary or match the\n * width of the reference element.\n * @see https://floating-ui.com/docs/size\n */\nconst size = function (options) {\n  if (options === void 0) {\n    options = {};\n  }\n  return {\n    name: 'size',\n    options,\n    async fn(state) {\n      var _state$middlewareData, _state$middlewareData2;\n      const {\n        placement,\n        rects,\n        platform,\n        elements\n      } = state;\n      const {\n        apply = () => {},\n        ...detectOverflowOptions\n      } = evaluate(options, state);\n      const overflow = await platform.detectOverflow(state, detectOverflowOptions);\n      const side = getSide(placement);\n      const alignment = getAlignment(placement);\n      const isYAxis = getSideAxis(placement) === 'y';\n      const {\n        width,\n        height\n      } = rects.floating;\n      let heightSide;\n      let widthSide;\n      if (side === 'top' || side === 'bottom') {\n        heightSide = side;\n        widthSide = alignment === ((await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating))) ? 'start' : 'end') ? 'left' : 'right';\n      } else {\n        widthSide = side;\n        heightSide = alignment === 'end' ? 'top' : 'bottom';\n      }\n      const maximumClippingHeight = height - overflow.top - overflow.bottom;\n      const maximumClippingWidth = width - overflow.left - overflow.right;\n      const overflowAvailableHeight = min(height - overflow[heightSide], maximumClippingHeight);\n      const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth);\n      const noShift = !state.middlewareData.shift;\n      let availableHeight = overflowAvailableHeight;\n      let availableWidth = overflowAvailableWidth;\n      if ((_state$middlewareData = state.middlewareData.shift) != null && _state$middlewareData.enabled.x) {\n        availableWidth = maximumClippingWidth;\n      }\n      if ((_state$middlewareData2 = state.middlewareData.shift) != null && _state$middlewareData2.enabled.y) {\n        availableHeight = maximumClippingHeight;\n      }\n      if (noShift && !alignment) {\n        const xMin = max(overflow.left, 0);\n        const xMax = max(overflow.right, 0);\n        const yMin = max(overflow.top, 0);\n        const yMax = max(overflow.bottom, 0);\n        if (isYAxis) {\n          availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right));\n        } else {\n          availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom));\n        }\n      }\n      await apply({\n        ...state,\n        availableWidth,\n        availableHeight\n      });\n      const nextDimensions = await platform.getDimensions(elements.floating);\n      if (width !== nextDimensions.width || height !== nextDimensions.height) {\n        return {\n          reset: {\n            rects: true\n          }\n        };\n      }\n      return {};\n    }\n  };\n};\n\nexport { arrow, autoPlacement, computePosition, detectOverflow, flip, hide, inline, limitShift, offset, shift, size };\n","function hasWindow() {\n  return typeof window !== 'undefined';\n}\nfunction getNodeName(node) {\n  if (isNode(node)) {\n    return (node.nodeName || '').toLowerCase();\n  }\n  // Mocked nodes in testing environments may not be instances of Node. By\n  // returning `#document` an infinite loop won't occur.\n  // https://github.com/floating-ui/floating-ui/issues/2317\n  return '#document';\n}\nfunction getWindow(node) {\n  var _node$ownerDocument;\n  return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;\n}\nfunction getDocumentElement(node) {\n  var _ref;\n  return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;\n}\nfunction isNode(value) {\n  if (!hasWindow()) {\n    return false;\n  }\n  return value instanceof Node || value instanceof getWindow(value).Node;\n}\nfunction isElement(value) {\n  if (!hasWindow()) {\n    return false;\n  }\n  return value instanceof Element || value instanceof getWindow(value).Element;\n}\nfunction isHTMLElement(value) {\n  if (!hasWindow()) {\n    return false;\n  }\n  return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;\n}\nfunction isShadowRoot(value) {\n  if (!hasWindow() || typeof ShadowRoot === 'undefined') {\n    return false;\n  }\n  return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;\n}\nfunction isOverflowElement(element) {\n  const {\n    overflow,\n    overflowX,\n    overflowY,\n    display\n  } = getComputedStyle(element);\n  return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && display !== 'inline' && display !== 'contents';\n}\nfunction isTableElement(element) {\n  return /^(table|td|th)$/.test(getNodeName(element));\n}\nfunction isTopLayer(element) {\n  try {\n    if (element.matches(':popover-open')) {\n      return true;\n    }\n  } catch (_e) {\n    // no-op\n  }\n  try {\n    return element.matches(':modal');\n  } catch (_e) {\n    return false;\n  }\n}\nconst willChangeRe = /transform|translate|scale|rotate|perspective|filter/;\nconst containRe = /paint|layout|strict|content/;\nconst isNotNone = value => !!value && value !== 'none';\nlet isWebKitValue;\nfunction isContainingBlock(elementOrCss) {\n  const css = isElement(elementOrCss) ? getComputedStyle(elementOrCss) : elementOrCss;\n\n  // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block\n  // https://drafts.csswg.org/css-transforms-2/#individual-transforms\n  return isNotNone(css.transform) || isNotNone(css.translate) || isNotNone(css.scale) || isNotNone(css.rotate) || isNotNone(css.perspective) || !isWebKit() && (isNotNone(css.backdropFilter) || isNotNone(css.filter)) || willChangeRe.test(css.willChange || '') || containRe.test(css.contain || '');\n}\nfunction getContainingBlock(element) {\n  let currentNode = getParentNode(element);\n  while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {\n    if (isContainingBlock(currentNode)) {\n      return currentNode;\n    } else if (isTopLayer(currentNode)) {\n      return null;\n    }\n    currentNode = getParentNode(currentNode);\n  }\n  return null;\n}\nfunction isWebKit() {\n  if (isWebKitValue == null) {\n    isWebKitValue = typeof CSS !== 'undefined' && CSS.supports && CSS.supports('-webkit-backdrop-filter', 'none');\n  }\n  return isWebKitValue;\n}\nfunction isLastTraversableNode(node) {\n  return /^(html|body|#document)$/.test(getNodeName(node));\n}\nfunction getComputedStyle(element) {\n  return getWindow(element).getComputedStyle(element);\n}\nfunction getNodeScroll(element) {\n  if (isElement(element)) {\n    return {\n      scrollLeft: element.scrollLeft,\n      scrollTop: element.scrollTop\n    };\n  }\n  return {\n    scrollLeft: element.scrollX,\n    scrollTop: element.scrollY\n  };\n}\nfunction getParentNode(node) {\n  if (getNodeName(node) === 'html') {\n    return node;\n  }\n  const result =\n  // Step into the shadow DOM of the parent of a slotted node.\n  node.assignedSlot ||\n  // DOM Element detected.\n  node.parentNode ||\n  // ShadowRoot detected.\n  isShadowRoot(node) && node.host ||\n  // Fallback.\n  getDocumentElement(node);\n  return isShadowRoot(result) ? result.host : result;\n}\nfunction getNearestOverflowAncestor(node) {\n  const parentNode = getParentNode(node);\n  if (isLastTraversableNode(parentNode)) {\n    return node.ownerDocument ? node.ownerDocument.body : node.body;\n  }\n  if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {\n    return parentNode;\n  }\n  return getNearestOverflowAncestor(parentNode);\n}\nfunction getOverflowAncestors(node, list, traverseIframes) {\n  var _node$ownerDocument2;\n  if (list === void 0) {\n    list = [];\n  }\n  if (traverseIframes === void 0) {\n    traverseIframes = true;\n  }\n  const scrollableAncestor = getNearestOverflowAncestor(node);\n  const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);\n  const win = getWindow(scrollableAncestor);\n  if (isBody) {\n    const frameElement = getFrameElement(win);\n    return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);\n  } else {\n    return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));\n  }\n}\nfunction getFrameElement(win) {\n  return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;\n}\n\nexport { getComputedStyle, getContainingBlock, getDocumentElement, getFrameElement, getNearestOverflowAncestor, getNodeName, getNodeScroll, getOverflowAncestors, getParentNode, getWindow, isContainingBlock, isElement, isHTMLElement, isLastTraversableNode, isNode, isOverflowElement, isShadowRoot, isTableElement, isTopLayer, isWebKit };\n","import { rectToClientRect, arrow as arrow$1, autoPlacement as autoPlacement$1, detectOverflow as detectOverflow$1, flip as flip$1, hide as hide$1, inline as inline$1, limitShift as limitShift$1, offset as offset$1, shift as shift$1, size as size$1, computePosition as computePosition$1 } from '@floating-ui/core';\nimport { round, createCoords, max, min, floor } from '@floating-ui/utils';\nimport { getComputedStyle as getComputedStyle$1, isHTMLElement, isElement, getWindow, isWebKit, getFrameElement, getNodeScroll, getDocumentElement, isTopLayer, getNodeName, isOverflowElement, getOverflowAncestors, getParentNode, isLastTraversableNode, isContainingBlock, isTableElement, getContainingBlock } from '@floating-ui/utils/dom';\nexport { getOverflowAncestors } from '@floating-ui/utils/dom';\n\nfunction getCssDimensions(element) {\n  const css = getComputedStyle$1(element);\n  // In testing environments, the `width` and `height` properties are empty\n  // strings for SVG elements, returning NaN. Fallback to `0` in this case.\n  let width = parseFloat(css.width) || 0;\n  let height = parseFloat(css.height) || 0;\n  const hasOffset = isHTMLElement(element);\n  const offsetWidth = hasOffset ? element.offsetWidth : width;\n  const offsetHeight = hasOffset ? element.offsetHeight : height;\n  const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;\n  if (shouldFallback) {\n    width = offsetWidth;\n    height = offsetHeight;\n  }\n  return {\n    width,\n    height,\n    $: shouldFallback\n  };\n}\n\nfunction unwrapElement(element) {\n  return !isElement(element) ? element.contextElement : element;\n}\n\nfunction getScale(element) {\n  const domElement = unwrapElement(element);\n  if (!isHTMLElement(domElement)) {\n    return createCoords(1);\n  }\n  const rect = domElement.getBoundingClientRect();\n  const {\n    width,\n    height,\n    $\n  } = getCssDimensions(domElement);\n  let x = ($ ? round(rect.width) : rect.width) / width;\n  let y = ($ ? round(rect.height) : rect.height) / height;\n\n  // 0, NaN, or Infinity should always fallback to 1.\n\n  if (!x || !Number.isFinite(x)) {\n    x = 1;\n  }\n  if (!y || !Number.isFinite(y)) {\n    y = 1;\n  }\n  return {\n    x,\n    y\n  };\n}\n\nconst noOffsets = /*#__PURE__*/createCoords(0);\nfunction getVisualOffsets(element) {\n  const win = getWindow(element);\n  if (!isWebKit() || !win.visualViewport) {\n    return noOffsets;\n  }\n  return {\n    x: win.visualViewport.offsetLeft,\n    y: win.visualViewport.offsetTop\n  };\n}\nfunction shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {\n  if (isFixed === void 0) {\n    isFixed = false;\n  }\n  if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {\n    return false;\n  }\n  return isFixed;\n}\n\nfunction getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {\n  if (includeScale === void 0) {\n    includeScale = false;\n  }\n  if (isFixedStrategy === void 0) {\n    isFixedStrategy = false;\n  }\n  const clientRect = element.getBoundingClientRect();\n  const domElement = unwrapElement(element);\n  let scale = createCoords(1);\n  if (includeScale) {\n    if (offsetParent) {\n      if (isElement(offsetParent)) {\n        scale = getScale(offsetParent);\n      }\n    } else {\n      scale = getScale(element);\n    }\n  }\n  const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);\n  let x = (clientRect.left + visualOffsets.x) / scale.x;\n  let y = (clientRect.top + visualOffsets.y) / scale.y;\n  let width = clientRect.width / scale.x;\n  let height = clientRect.height / scale.y;\n  if (domElement) {\n    const win = getWindow(domElement);\n    const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;\n    let currentWin = win;\n    let currentIFrame = getFrameElement(currentWin);\n    while (currentIFrame && offsetParent && offsetWin !== currentWin) {\n      const iframeScale = getScale(currentIFrame);\n      const iframeRect = currentIFrame.getBoundingClientRect();\n      const css = getComputedStyle$1(currentIFrame);\n      const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;\n      const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;\n      x *= iframeScale.x;\n      y *= iframeScale.y;\n      width *= iframeScale.x;\n      height *= iframeScale.y;\n      x += left;\n      y += top;\n      currentWin = getWindow(currentIFrame);\n      currentIFrame = getFrameElement(currentWin);\n    }\n  }\n  return rectToClientRect({\n    width,\n    height,\n    x,\n    y\n  });\n}\n\n// If <html> has a CSS width greater than the viewport, then this will be\n// incorrect for RTL.\nfunction getWindowScrollBarX(element, rect) {\n  const leftScroll = getNodeScroll(element).scrollLeft;\n  if (!rect) {\n    return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;\n  }\n  return rect.left + leftScroll;\n}\n\nfunction getHTMLOffset(documentElement, scroll) {\n  const htmlRect = documentElement.getBoundingClientRect();\n  const x = htmlRect.left + scroll.scrollLeft - getWindowScrollBarX(documentElement, htmlRect);\n  const y = htmlRect.top + scroll.scrollTop;\n  return {\n    x,\n    y\n  };\n}\n\nfunction convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {\n  let {\n    elements,\n    rect,\n    offsetParent,\n    strategy\n  } = _ref;\n  const isFixed = strategy === 'fixed';\n  const documentElement = getDocumentElement(offsetParent);\n  const topLayer = elements ? isTopLayer(elements.floating) : false;\n  if (offsetParent === documentElement || topLayer && isFixed) {\n    return rect;\n  }\n  let scroll = {\n    scrollLeft: 0,\n    scrollTop: 0\n  };\n  let scale = createCoords(1);\n  const offsets = createCoords(0);\n  const isOffsetParentAnElement = isHTMLElement(offsetParent);\n  if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {\n    if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {\n      scroll = getNodeScroll(offsetParent);\n    }\n    if (isOffsetParentAnElement) {\n      const offsetRect = getBoundingClientRect(offsetParent);\n      scale = getScale(offsetParent);\n      offsets.x = offsetRect.x + offsetParent.clientLeft;\n      offsets.y = offsetRect.y + offsetParent.clientTop;\n    }\n  }\n  const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);\n  return {\n    width: rect.width * scale.x,\n    height: rect.height * scale.y,\n    x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,\n    y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y\n  };\n}\n\nfunction getClientRects(element) {\n  return Array.from(element.getClientRects());\n}\n\n// Gets the entire size of the scrollable document area, even extending outside\n// of the `<html>` and `<body>` rect bounds if horizontally scrollable.\nfunction getDocumentRect(element) {\n  const html = getDocumentElement(element);\n  const scroll = getNodeScroll(element);\n  const body = element.ownerDocument.body;\n  const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);\n  const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);\n  let x = -scroll.scrollLeft + getWindowScrollBarX(element);\n  const y = -scroll.scrollTop;\n  if (getComputedStyle$1(body).direction === 'rtl') {\n    x += max(html.clientWidth, body.clientWidth) - width;\n  }\n  return {\n    width,\n    height,\n    x,\n    y\n  };\n}\n\n// Safety check: ensure the scrollbar space is reasonable in case this\n// calculation is affected by unusual styles.\n// Most scrollbars leave 15-18px of space.\nconst SCROLLBAR_MAX = 25;\nfunction getViewportRect(element, strategy) {\n  const win = getWindow(element);\n  const html = getDocumentElement(element);\n  const visualViewport = win.visualViewport;\n  let width = html.clientWidth;\n  let height = html.clientHeight;\n  let x = 0;\n  let y = 0;\n  if (visualViewport) {\n    width = visualViewport.width;\n    height = visualViewport.height;\n    const visualViewportBased = isWebKit();\n    if (!visualViewportBased || visualViewportBased && strategy === 'fixed') {\n      x = visualViewport.offsetLeft;\n      y = visualViewport.offsetTop;\n    }\n  }\n  const windowScrollbarX = getWindowScrollBarX(html);\n  // <html> `overflow: hidden` + `scrollbar-gutter: stable` reduces the\n  // visual width of the <html> but this is not considered in the size\n  // of `html.clientWidth`.\n  if (windowScrollbarX <= 0) {\n    const doc = html.ownerDocument;\n    const body = doc.body;\n    const bodyStyles = getComputedStyle(body);\n    const bodyMarginInline = doc.compatMode === 'CSS1Compat' ? parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight) || 0 : 0;\n    const clippingStableScrollbarWidth = Math.abs(html.clientWidth - body.clientWidth - bodyMarginInline);\n    if (clippingStableScrollbarWidth <= SCROLLBAR_MAX) {\n      width -= clippingStableScrollbarWidth;\n    }\n  } else if (windowScrollbarX <= SCROLLBAR_MAX) {\n    // If the <body> scrollbar is on the left, the width needs to be extended\n    // by the scrollbar amount so there isn't extra space on the right.\n    width += windowScrollbarX;\n  }\n  return {\n    width,\n    height,\n    x,\n    y\n  };\n}\n\n// Returns the inner client rect, subtracting scrollbars if present.\nfunction getInnerBoundingClientRect(element, strategy) {\n  const clientRect = getBoundingClientRect(element, true, strategy === 'fixed');\n  const top = clientRect.top + element.clientTop;\n  const left = clientRect.left + element.clientLeft;\n  const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);\n  const width = element.clientWidth * scale.x;\n  const height = element.clientHeight * scale.y;\n  const x = left * scale.x;\n  const y = top * scale.y;\n  return {\n    width,\n    height,\n    x,\n    y\n  };\n}\nfunction getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {\n  let rect;\n  if (clippingAncestor === 'viewport') {\n    rect = getViewportRect(element, strategy);\n  } else if (clippingAncestor === 'document') {\n    rect = getDocumentRect(getDocumentElement(element));\n  } else if (isElement(clippingAncestor)) {\n    rect = getInnerBoundingClientRect(clippingAncestor, strategy);\n  } else {\n    const visualOffsets = getVisualOffsets(element);\n    rect = {\n      x: clippingAncestor.x - visualOffsets.x,\n      y: clippingAncestor.y - visualOffsets.y,\n      width: clippingAncestor.width,\n      height: clippingAncestor.height\n    };\n  }\n  return rectToClientRect(rect);\n}\nfunction hasFixedPositionAncestor(element, stopNode) {\n  const parentNode = getParentNode(element);\n  if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {\n    return false;\n  }\n  return getComputedStyle$1(parentNode).position === 'fixed' || hasFixedPositionAncestor(parentNode, stopNode);\n}\n\n// A \"clipping ancestor\" is an `overflow` element with the characteristic of\n// clipping (or hiding) child elements. This returns all clipping ancestors\n// of the given element up the tree.\nfunction getClippingElementAncestors(element, cache) {\n  const cachedResult = cache.get(element);\n  if (cachedResult) {\n    return cachedResult;\n  }\n  let result = getOverflowAncestors(element, [], false).filter(el => isElement(el) && getNodeName(el) !== 'body');\n  let currentContainingBlockComputedStyle = null;\n  const elementIsFixed = getComputedStyle$1(element).position === 'fixed';\n  let currentNode = elementIsFixed ? getParentNode(element) : element;\n\n  // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block\n  while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {\n    const computedStyle = getComputedStyle$1(currentNode);\n    const currentNodeIsContaining = isContainingBlock(currentNode);\n    if (!currentNodeIsContaining && computedStyle.position === 'fixed') {\n      currentContainingBlockComputedStyle = null;\n    }\n    const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === 'static' && !!currentContainingBlockComputedStyle && (currentContainingBlockComputedStyle.position === 'absolute' || currentContainingBlockComputedStyle.position === 'fixed') || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);\n    if (shouldDropCurrentNode) {\n      // Drop non-containing blocks.\n      result = result.filter(ancestor => ancestor !== currentNode);\n    } else {\n      // Record last containing block for next iteration.\n      currentContainingBlockComputedStyle = computedStyle;\n    }\n    currentNode = getParentNode(currentNode);\n  }\n  cache.set(element, result);\n  return result;\n}\n\n// Gets the maximum area that the element is visible in due to any number of\n// clipping ancestors.\nfunction getClippingRect(_ref) {\n  let {\n    element,\n    boundary,\n    rootBoundary,\n    strategy\n  } = _ref;\n  const elementClippingAncestors = boundary === 'clippingAncestors' ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);\n  const clippingAncestors = [...elementClippingAncestors, rootBoundary];\n  const firstRect = getClientRectFromClippingAncestor(element, clippingAncestors[0], strategy);\n  let top = firstRect.top;\n  let right = firstRect.right;\n  let bottom = firstRect.bottom;\n  let left = firstRect.left;\n  for (let i = 1; i < clippingAncestors.length; i++) {\n    const rect = getClientRectFromClippingAncestor(element, clippingAncestors[i], strategy);\n    top = max(rect.top, top);\n    right = min(rect.right, right);\n    bottom = min(rect.bottom, bottom);\n    left = max(rect.left, left);\n  }\n  return {\n    width: right - left,\n    height: bottom - top,\n    x: left,\n    y: top\n  };\n}\n\nfunction getDimensions(element) {\n  const {\n    width,\n    height\n  } = getCssDimensions(element);\n  return {\n    width,\n    height\n  };\n}\n\nfunction getRectRelativeToOffsetParent(element, offsetParent, strategy) {\n  const isOffsetParentAnElement = isHTMLElement(offsetParent);\n  const documentElement = getDocumentElement(offsetParent);\n  const isFixed = strategy === 'fixed';\n  const rect = getBoundingClientRect(element, true, isFixed, offsetParent);\n  let scroll = {\n    scrollLeft: 0,\n    scrollTop: 0\n  };\n  const offsets = createCoords(0);\n\n  // If the <body> scrollbar appears on the left (e.g. RTL systems). Use\n  // Firefox with layout.scrollbar.side = 3 in about:config to test this.\n  function setLeftRTLScrollbarOffset() {\n    offsets.x = getWindowScrollBarX(documentElement);\n  }\n  if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {\n    if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {\n      scroll = getNodeScroll(offsetParent);\n    }\n    if (isOffsetParentAnElement) {\n      const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);\n      offsets.x = offsetRect.x + offsetParent.clientLeft;\n      offsets.y = offsetRect.y + offsetParent.clientTop;\n    } else if (documentElement) {\n      setLeftRTLScrollbarOffset();\n    }\n  }\n  if (isFixed && !isOffsetParentAnElement && documentElement) {\n    setLeftRTLScrollbarOffset();\n  }\n  const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);\n  const x = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;\n  const y = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;\n  return {\n    x,\n    y,\n    width: rect.width,\n    height: rect.height\n  };\n}\n\nfunction isStaticPositioned(element) {\n  return getComputedStyle$1(element).position === 'static';\n}\n\nfunction getTrueOffsetParent(element, polyfill) {\n  if (!isHTMLElement(element) || getComputedStyle$1(element).position === 'fixed') {\n    return null;\n  }\n  if (polyfill) {\n    return polyfill(element);\n  }\n  let rawOffsetParent = element.offsetParent;\n\n  // Firefox returns the <html> element as the offsetParent if it's non-static,\n  // while Chrome and Safari return the <body> element. The <body> element must\n  // be used to perform the correct calculations even if the <html> element is\n  // non-static.\n  if (getDocumentElement(element) === rawOffsetParent) {\n    rawOffsetParent = rawOffsetParent.ownerDocument.body;\n  }\n  return rawOffsetParent;\n}\n\n// Gets the closest ancestor positioned element. Handles some edge cases,\n// such as table ancestors and cross browser bugs.\nfunction getOffsetParent(element, polyfill) {\n  const win = getWindow(element);\n  if (isTopLayer(element)) {\n    return win;\n  }\n  if (!isHTMLElement(element)) {\n    let svgOffsetParent = getParentNode(element);\n    while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {\n      if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {\n        return svgOffsetParent;\n      }\n      svgOffsetParent = getParentNode(svgOffsetParent);\n    }\n    return win;\n  }\n  let offsetParent = getTrueOffsetParent(element, polyfill);\n  while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {\n    offsetParent = getTrueOffsetParent(offsetParent, polyfill);\n  }\n  if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {\n    return win;\n  }\n  return offsetParent || getContainingBlock(element) || win;\n}\n\nconst getElementRects = async function (data) {\n  const getOffsetParentFn = this.getOffsetParent || getOffsetParent;\n  const getDimensionsFn = this.getDimensions;\n  const floatingDimensions = await getDimensionsFn(data.floating);\n  return {\n    reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),\n    floating: {\n      x: 0,\n      y: 0,\n      width: floatingDimensions.width,\n      height: floatingDimensions.height\n    }\n  };\n};\n\nfunction isRTL(element) {\n  return getComputedStyle$1(element).direction === 'rtl';\n}\n\nconst platform = {\n  convertOffsetParentRelativeRectToViewportRelativeRect,\n  getDocumentElement,\n  getClippingRect,\n  getOffsetParent,\n  getElementRects,\n  getClientRects,\n  getDimensions,\n  getScale,\n  isElement,\n  isRTL\n};\n\nfunction rectsAreEqual(a, b) {\n  return a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height;\n}\n\n// https://samthor.au/2021/observing-dom/\nfunction observeMove(element, onMove) {\n  let io = null;\n  let timeoutId;\n  const root = getDocumentElement(element);\n  function cleanup() {\n    var _io;\n    clearTimeout(timeoutId);\n    (_io = io) == null || _io.disconnect();\n    io = null;\n  }\n  function refresh(skip, threshold) {\n    if (skip === void 0) {\n      skip = false;\n    }\n    if (threshold === void 0) {\n      threshold = 1;\n    }\n    cleanup();\n    const elementRectForRootMargin = element.getBoundingClientRect();\n    const {\n      left,\n      top,\n      width,\n      height\n    } = elementRectForRootMargin;\n    if (!skip) {\n      onMove();\n    }\n    if (!width || !height) {\n      return;\n    }\n    const insetTop = floor(top);\n    const insetRight = floor(root.clientWidth - (left + width));\n    const insetBottom = floor(root.clientHeight - (top + height));\n    const insetLeft = floor(left);\n    const rootMargin = -insetTop + \"px \" + -insetRight + \"px \" + -insetBottom + \"px \" + -insetLeft + \"px\";\n    const options = {\n      rootMargin,\n      threshold: max(0, min(1, threshold)) || 1\n    };\n    let isFirstUpdate = true;\n    function handleObserve(entries) {\n      const ratio = entries[0].intersectionRatio;\n      if (ratio !== threshold) {\n        if (!isFirstUpdate) {\n          return refresh();\n        }\n        if (!ratio) {\n          // If the reference is clipped, the ratio is 0. Throttle the refresh\n          // to prevent an infinite loop of updates.\n          timeoutId = setTimeout(() => {\n            refresh(false, 1e-7);\n          }, 1000);\n        } else {\n          refresh(false, ratio);\n        }\n      }\n      if (ratio === 1 && !rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) {\n        // It's possible that even though the ratio is reported as 1, the\n        // element is not actually fully within the IntersectionObserver's root\n        // area anymore. This can happen under performance constraints. This may\n        // be a bug in the browser's IntersectionObserver implementation. To\n        // work around this, we compare the element's bounding rect now with\n        // what it was at the time we created the IntersectionObserver. If they\n        // are not equal then the element moved, so we refresh.\n        refresh();\n      }\n      isFirstUpdate = false;\n    }\n\n    // Older browsers don't support a `document` as the root and will throw an\n    // error.\n    try {\n      io = new IntersectionObserver(handleObserve, {\n        ...options,\n        // Handle <iframe>s\n        root: root.ownerDocument\n      });\n    } catch (_e) {\n      io = new IntersectionObserver(handleObserve, options);\n    }\n    io.observe(element);\n  }\n  refresh(true);\n  return cleanup;\n}\n\n/**\n * Automatically updates the position of the floating element when necessary.\n * Should only be called when the floating element is mounted on the DOM or\n * visible on the screen.\n * @returns cleanup function that should be invoked when the floating element is\n * removed from the DOM or hidden from the screen.\n * @see https://floating-ui.com/docs/autoUpdate\n */\nfunction autoUpdate(reference, floating, update, options) {\n  if (options === void 0) {\n    options = {};\n  }\n  const {\n    ancestorScroll = true,\n    ancestorResize = true,\n    elementResize = typeof ResizeObserver === 'function',\n    layoutShift = typeof IntersectionObserver === 'function',\n    animationFrame = false\n  } = options;\n  const referenceEl = unwrapElement(reference);\n  const ancestors = ancestorScroll || ancestorResize ? [...(referenceEl ? getOverflowAncestors(referenceEl) : []), ...(floating ? getOverflowAncestors(floating) : [])] : [];\n  ancestors.forEach(ancestor => {\n    ancestorScroll && ancestor.addEventListener('scroll', update, {\n      passive: true\n    });\n    ancestorResize && ancestor.addEventListener('resize', update);\n  });\n  const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update) : null;\n  let reobserveFrame = -1;\n  let resizeObserver = null;\n  if (elementResize) {\n    resizeObserver = new ResizeObserver(_ref => {\n      let [firstEntry] = _ref;\n      if (firstEntry && firstEntry.target === referenceEl && resizeObserver && floating) {\n        // Prevent update loops when using the `size` middleware.\n        // https://github.com/floating-ui/floating-ui/issues/1740\n        resizeObserver.unobserve(floating);\n        cancelAnimationFrame(reobserveFrame);\n        reobserveFrame = requestAnimationFrame(() => {\n          var _resizeObserver;\n          (_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);\n        });\n      }\n      update();\n    });\n    if (referenceEl && !animationFrame) {\n      resizeObserver.observe(referenceEl);\n    }\n    if (floating) {\n      resizeObserver.observe(floating);\n    }\n  }\n  let frameId;\n  let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;\n  if (animationFrame) {\n    frameLoop();\n  }\n  function frameLoop() {\n    const nextRefRect = getBoundingClientRect(reference);\n    if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) {\n      update();\n    }\n    prevRefRect = nextRefRect;\n    frameId = requestAnimationFrame(frameLoop);\n  }\n  update();\n  return () => {\n    var _resizeObserver2;\n    ancestors.forEach(ancestor => {\n      ancestorScroll && ancestor.removeEventListener('scroll', update);\n      ancestorResize && ancestor.removeEventListener('resize', update);\n    });\n    cleanupIo == null || cleanupIo();\n    (_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();\n    resizeObserver = null;\n    if (animationFrame) {\n      cancelAnimationFrame(frameId);\n    }\n  };\n}\n\n/**\n * Resolves with an object of overflow side offsets that determine how much the\n * element is overflowing a given clipping boundary on each side.\n * - positive = overflowing the boundary by that number of pixels\n * - negative = how many pixels left before it will overflow\n * - 0 = lies flush with the boundary\n * @see https://floating-ui.com/docs/detectOverflow\n */\nconst detectOverflow = detectOverflow$1;\n\n/**\n * Modifies the placement by translating the floating element along the\n * specified axes.\n * A number (shorthand for `mainAxis` or distance), or an axes configuration\n * object may be passed.\n * @see https://floating-ui.com/docs/offset\n */\nconst offset = offset$1;\n\n/**\n * Optimizes the visibility of the floating element by choosing the placement\n * that has the most space available automatically, without needing to specify a\n * preferred placement. Alternative to `flip`.\n * @see https://floating-ui.com/docs/autoPlacement\n */\nconst autoPlacement = autoPlacement$1;\n\n/**\n * Optimizes the visibility of the floating element by shifting it in order to\n * keep it in view when it will overflow the clipping boundary.\n * @see https://floating-ui.com/docs/shift\n */\nconst shift = shift$1;\n\n/**\n * Optimizes the visibility of the floating element by flipping the `placement`\n * in order to keep it in view when the preferred placement(s) will overflow the\n * clipping boundary. Alternative to `autoPlacement`.\n * @see https://floating-ui.com/docs/flip\n */\nconst flip = flip$1;\n\n/**\n * Provides data that allows you to change the size of the floating element —\n * for instance, prevent it from overflowing the clipping boundary or match the\n * width of the reference element.\n * @see https://floating-ui.com/docs/size\n */\nconst size = size$1;\n\n/**\n * Provides data to hide the floating element in applicable situations, such as\n * when it is not in the same clipping context as the reference element.\n * @see https://floating-ui.com/docs/hide\n */\nconst hide = hide$1;\n\n/**\n * Provides data to position an inner element of the floating element so that it\n * appears centered to the reference element.\n * @see https://floating-ui.com/docs/arrow\n */\nconst arrow = arrow$1;\n\n/**\n * Provides improved positioning for inline reference elements that can span\n * over multiple lines, such as hyperlinks or range selections.\n * @see https://floating-ui.com/docs/inline\n */\nconst inline = inline$1;\n\n/**\n * Built-in `limiter` that will stop `shift()` at a certain point.\n */\nconst limitShift = limitShift$1;\n\n/**\n * Computes the `x` and `y` coordinates that will place the floating element\n * next to a given reference element.\n */\nconst computePosition = (reference, floating, options) => {\n  // This caches the expensive `getClippingElementAncestors` function so that\n  // multiple lifecycle resets re-use the same result. It only lives for a\n  // single call. If other functions become expensive, we can add them as well.\n  const cache = new Map();\n  const mergedOptions = {\n    platform,\n    ...options\n  };\n  const platformWithCache = {\n    ...mergedOptions.platform,\n    _c: cache\n  };\n  return computePosition$1(reference, floating, {\n    ...mergedOptions,\n    platform: platformWithCache\n  });\n};\n\nexport { arrow, autoPlacement, autoUpdate, computePosition, detectOverflow, flip, hide, inline, limitShift, offset, platform, shift, size };\n","import * as Vue from 'vue'\n\nvar isVue2 = false\nvar isVue3 = true\nvar Vue2 = undefined\n\nfunction install() {}\n\nexport function set(target, key, val) {\n  if (Array.isArray(target)) {\n    target.length = Math.max(target.length, key)\n    target.splice(key, 1, val)\n    return val\n  }\n  target[key] = val\n  return val\n}\n\nexport function del(target, key) {\n  if (Array.isArray(target)) {\n    target.splice(key, 1)\n    return\n  }\n  delete target[key]\n}\n\nexport * from 'vue'\nexport {\n  Vue,\n  Vue2,\n  isVue2,\n  isVue3,\n  install,\n}\n","import { arrow as arrow$1, computePosition } from '@floating-ui/dom';\nexport { autoPlacement, autoUpdate, computePosition, detectOverflow, flip, getOverflowAncestors, hide, inline, limitShift, offset, platform, shift, size } from '@floating-ui/dom';\nimport { isNode, getNodeName } from '@floating-ui/utils/dom';\nimport { unref, computed, ref, shallowRef, watch, getCurrentScope, onScopeDispose, shallowReadonly } from 'vue-demi';\n\nfunction isComponentPublicInstance(target) {\n  return target != null && typeof target === 'object' && '$el' in target;\n}\nfunction unwrapElement(target) {\n  if (isComponentPublicInstance(target)) {\n    const element = target.$el;\n    return isNode(element) && getNodeName(element) === '#comment' ? null : element;\n  }\n  return target;\n}\n\nfunction toValue(source) {\n  return typeof source === 'function' ? source() : unref(source);\n}\n\n/**\n * Positions an inner element of the floating element such that it is centered to the reference element.\n * @param options The arrow options.\n * @see https://floating-ui.com/docs/arrow\n */\nfunction arrow(options) {\n  return {\n    name: 'arrow',\n    options,\n    fn(args) {\n      const element = unwrapElement(toValue(options.element));\n      if (element == null) {\n        return {};\n      }\n      return arrow$1({\n        element,\n        padding: options.padding\n      }).fn(args);\n    }\n  };\n}\n\nfunction getDPR(element) {\n  if (typeof window === 'undefined') {\n    return 1;\n  }\n  const win = element.ownerDocument.defaultView || window;\n  return win.devicePixelRatio || 1;\n}\n\nfunction roundByDPR(element, value) {\n  const dpr = getDPR(element);\n  return Math.round(value * dpr) / dpr;\n}\n\n/**\n * Computes the `x` and `y` coordinates that will place the floating element next to a reference element when it is given a certain CSS positioning strategy.\n * @param reference The reference template ref.\n * @param floating The floating template ref.\n * @param options The floating options.\n * @see https://floating-ui.com/docs/vue\n */\nfunction useFloating(reference, floating, options) {\n  if (options === void 0) {\n    options = {};\n  }\n  const whileElementsMountedOption = options.whileElementsMounted;\n  const openOption = computed(() => {\n    var _toValue;\n    return (_toValue = toValue(options.open)) != null ? _toValue : true;\n  });\n  const middlewareOption = computed(() => toValue(options.middleware));\n  const placementOption = computed(() => {\n    var _toValue2;\n    return (_toValue2 = toValue(options.placement)) != null ? _toValue2 : 'bottom';\n  });\n  const strategyOption = computed(() => {\n    var _toValue3;\n    return (_toValue3 = toValue(options.strategy)) != null ? _toValue3 : 'absolute';\n  });\n  const transformOption = computed(() => {\n    var _toValue4;\n    return (_toValue4 = toValue(options.transform)) != null ? _toValue4 : true;\n  });\n  const referenceElement = computed(() => unwrapElement(reference.value));\n  const floatingElement = computed(() => unwrapElement(floating.value));\n  const x = ref(0);\n  const y = ref(0);\n  const strategy = ref(strategyOption.value);\n  const placement = ref(placementOption.value);\n  const middlewareData = shallowRef({});\n  const isPositioned = ref(false);\n  const floatingStyles = computed(() => {\n    const initialStyles = {\n      position: strategy.value,\n      left: '0',\n      top: '0'\n    };\n    if (!floatingElement.value) {\n      return initialStyles;\n    }\n    const xVal = roundByDPR(floatingElement.value, x.value);\n    const yVal = roundByDPR(floatingElement.value, y.value);\n    if (transformOption.value) {\n      return {\n        ...initialStyles,\n        transform: \"translate(\" + xVal + \"px, \" + yVal + \"px)\",\n        ...(getDPR(floatingElement.value) >= 1.5 && {\n          willChange: 'transform'\n        })\n      };\n    }\n    return {\n      position: strategy.value,\n      left: xVal + \"px\",\n      top: yVal + \"px\"\n    };\n  });\n  let whileElementsMountedCleanup;\n  function update() {\n    if (referenceElement.value == null || floatingElement.value == null) {\n      return;\n    }\n    const open = openOption.value;\n    computePosition(referenceElement.value, floatingElement.value, {\n      middleware: middlewareOption.value,\n      placement: placementOption.value,\n      strategy: strategyOption.value\n    }).then(position => {\n      x.value = position.x;\n      y.value = position.y;\n      strategy.value = position.strategy;\n      placement.value = position.placement;\n      middlewareData.value = position.middlewareData;\n      /**\n       * The floating element's position may be recomputed while it's closed\n       * but still mounted (such as when transitioning out). To ensure\n       * `isPositioned` will be `false` initially on the next open, avoid\n       * setting it to `true` when `open === false` (must be specified).\n       */\n      isPositioned.value = open !== false;\n    });\n  }\n  function cleanup() {\n    if (typeof whileElementsMountedCleanup === 'function') {\n      whileElementsMountedCleanup();\n      whileElementsMountedCleanup = undefined;\n    }\n  }\n  function attach() {\n    cleanup();\n    if (whileElementsMountedOption === undefined) {\n      update();\n      return;\n    }\n    if (referenceElement.value != null && floatingElement.value != null) {\n      whileElementsMountedCleanup = whileElementsMountedOption(referenceElement.value, floatingElement.value, update);\n      return;\n    }\n  }\n  function reset() {\n    if (!openOption.value) {\n      isPositioned.value = false;\n    }\n  }\n  watch([middlewareOption, placementOption, strategyOption, openOption], update, {\n    flush: 'sync'\n  });\n  watch([referenceElement, floatingElement], attach, {\n    flush: 'sync'\n  });\n  watch(openOption, reset, {\n    flush: 'sync'\n  });\n  if (getCurrentScope()) {\n    onScopeDispose(cleanup);\n  }\n  return {\n    x: shallowReadonly(x),\n    y: shallowReadonly(y),\n    strategy: shallowReadonly(strategy),\n    placement: shallowReadonly(placement),\n    middlewareData: shallowReadonly(middlewareData),\n    isPositioned: shallowReadonly(isPositioned),\n    floatingStyles,\n    update\n  };\n}\n\nexport { arrow, useFloating };\n","import { computed, onBeforeUnmount, onBeforeUpdate, onMounted, ref, unref, useSlots, watch } from \"vue\";\nimport type { Ref } from \"vue\";\nimport { useIsWebComponent } from \"@/web-components/utils\";\n\ntype MaybeRef<T> = T | Ref<T>;\n\nexport type UseSlotPresenceOptions = {\n  /**\n   * Host element for native slot detection (required for web components).\n   * When running as a web component, light DOM children of this element are inspected.\n   */\n  host?: MaybeRef<HTMLElement | null | undefined>;\n\n  /**\n   * A slots object (useful for tests or to override `useSlots()`).\n   * Only used when running as a Vue component (not a web component).\n   */\n  vueSlots?: Record<string, unknown> | null | undefined;\n\n  /**\n   * Watch light DOM changes so presence updates if children are added/removed.\n   * Only applies to web component mode. Defaults to true.\n   */\n  observe?: boolean;\n\n  /**\n   * Listen to slotchange events on shadow DOM slots.\n   * Only applies to web component mode. Defaults to true.\n   */\n  listenSlotChange?: boolean;\n\n  /**\n   * If true, whitespace-only text nodes count as content in the default slot.\n   * Only applies to web component mode. Defaults to false.\n   */\n  countWhitespaceTextInDefaultSlot?: boolean;\n};\n\nfunction isMeaningfulTextNode(node: Node, countWhitespace: boolean) {\n  if (node.nodeType !== Node.TEXT_NODE) return false;\n  const txt = node.textContent ?? \"\";\n  return countWhitespace ? txt.length > 0 : txt.trim().length > 0;\n}\n\nfunction hasNativeSlottedContent(host: HTMLElement, name: string, countWhitespaceTextInDefaultSlot: boolean): boolean {\n  const slotName = name === \"default\" ? \"\" : name;\n  const nodes = Array.from(host.childNodes);\n\n  if (slotName === \"\") {\n    // Default slot: nodes without a `slot` attribute\n    return nodes.some((n) => {\n      if (n.nodeType === Node.ELEMENT_NODE) {\n        const el = n as Element;\n        return !el.hasAttribute(\"slot\");\n      }\n      return isMeaningfulTextNode(n, countWhitespaceTextInDefaultSlot);\n    });\n  }\n\n  // Named slot: element children with slot=\"name\"\n  return nodes.some((n) => {\n    if (n.nodeType !== Node.ELEMENT_NODE) return false;\n    const el = n as Element;\n    return el.getAttribute(\"slot\") === slotName;\n  });\n}\n\n/**\n * Vue's light DOM custom elements (`shadowRoot: false`) move every child off the\n * host into an internal map during `connectedCallback`, before the component\n * renders, and splice them back in wherever a `<slot>` outlet appears. The host\n * is therefore empty by the time we can inspect it, and this map is the only\n * surviving record of what was slotted. Vue populates it before `setup()` runs\n * and keeps it as the source `_renderSlots()` reads on every update, so it is a\n * stable answer for a slot outlet that is itself gated on slot presence.\n */\ntype LightDomSlotHost = HTMLElement & { _slots?: Record<string, Node[]> };\n\nfunction getParsedLightDomSlots(host: HTMLElement): Record<string, Node[]> | null {\n  if (host.shadowRoot) return null;\n  const slots = (host as LightDomSlotHost)._slots;\n  if (!slots || typeof slots !== \"object\") return null;\n  return slots;\n}\n\nfunction hasParsedSlotContent(\n  slots: Record<string, Node[]>,\n  name: string,\n  countWhitespaceTextInDefaultSlot: boolean,\n): boolean {\n  // Vue keys the default slot as \"default\" and named slots by their `slot` attribute.\n  const nodes = slots[name === \"\" ? \"default\" : name];\n  if (!nodes) return false;\n  return nodes.some((n) => {\n    if (n.nodeType === Node.ELEMENT_NODE) return true;\n    return isMeaningfulTextNode(n, countWhitespaceTextInDefaultSlot);\n  });\n}\n\nfunction getShadowSlotEl(host: HTMLElement, name: string): HTMLSlotElement | null {\n  const sr = host.shadowRoot;\n  if (!sr) return null;\n  if (name === \"default\" || name === \"\") {\n    return sr.querySelector(\"slot:not([name])\");\n  }\n  return sr.querySelector(`slot[name=\"${CSS.escape(name)}\"]`);\n}\n\n/**\n * Reports whether a custom element host has content for `name`, across all three\n * ways slotted content can be held: assigned to a shadow `<slot>`, parsed off the\n * host by Vue in light DOM, or still sitting as a light DOM child.\n *\n * Exported so callers that resolve a slot name dynamically (and so cannot hold a\n * `useSlotPresence` instance per slot) resolve it the same way.\n */\nexport function hasHostSlotContent(\n  host: HTMLElement,\n  name: string,\n  { useShadowSlot = true, countWhitespaceTextInDefaultSlot = false } = {},\n): boolean {\n  const slotEl = useShadowSlot ? getShadowSlotEl(host, name) : null;\n  if (slotEl) {\n    return slotEl.assignedNodes({ flatten: true }).some((n) => {\n      if (n.nodeType === Node.ELEMENT_NODE) return true;\n      return isMeaningfulTextNode(n, countWhitespaceTextInDefaultSlot);\n    });\n  }\n\n  // Light DOM custom element: the host has been drained, so read the slots Vue\n  // parsed off it. Note that Vue only parses on first connect, so children added\n  // to the host later are never rendered either way.\n  const parsedSlots = getParsedLightDomSlots(host);\n  if (parsedSlots) return hasParsedSlotContent(parsedSlots, name, countWhitespaceTextInDefaultSlot);\n\n  return hasNativeSlottedContent(host, name, countWhitespaceTextInDefaultSlot);\n}\n\n/**\n * Returns a computed boolean indicating if a slot has content.\n *\n * Automatically detects if running as a Vue component or web component:\n * - Vue component: checks Vue's slot system via useSlots()\n * - Web component: inspects light DOM children of the host element\n */\nexport function useSlotPresence(slotName: string, options: UseSlotPresenceOptions = {}) {\n  const { host, vueSlots, observe = true, listenSlotChange = true, countWhitespaceTextInDefaultSlot = false } = options;\n\n  const isWebComponent = useIsWebComponent();\n  const slots = vueSlots ?? useSlots();\n\n  // Vue's slots object is updated in place and is not reactive, so a computed\n  // would cache the initial slot table forever. Refresh before each component\n  // update so conditional named slots can appear and disappear at runtime.\n  const vueSlotKey = slotName === \"default\" || slotName === \"\" ? \"default\" : slotName;\n  const readVueSlot = () => !!slots && !!(slots as Record<string, unknown>)[vueSlotKey];\n  const hasVueSlot = ref(readVueSlot());\n  onBeforeUpdate(() => {\n    hasVueSlot.value = readVueSlot();\n  });\n\n  // Native/web-component slot presence\n  const hasNativeSlot = ref(false);\n\n  let mo: MutationObserver | null = null;\n  let shadowRoot: ShadowRoot | null = null;\n\n  const cleanup = () => {\n    if (mo) {\n      mo.disconnect();\n      mo = null;\n    }\n    if (shadowRoot) {\n      shadowRoot.removeEventListener(\"slotchange\", updateNative);\n      shadowRoot = null;\n    }\n  };\n\n  const updateNative = () => {\n    if (!isWebComponent.value) {\n      hasNativeSlot.value = false;\n      return;\n    }\n\n    const el = unref(host);\n    if (!el) {\n      hasNativeSlot.value = false;\n      return;\n    }\n\n    hasNativeSlot.value = hasHostSlotContent(el, slotName, {\n      // Prefer assignedNodes when we can reach the <slot> element in an open shadowRoot\n      useShadowSlot: listenSlotChange,\n      countWhitespaceTextInDefaultSlot,\n    });\n  };\n\n  const attach = () => {\n    if (!isWebComponent.value) return;\n\n    cleanup();\n\n    const el = unref(host);\n    if (!el) {\n      hasNativeSlot.value = false;\n      return;\n    }\n\n    updateNative();\n\n    if (listenSlotChange) {\n      // Listen on the stable root so outlets added by a later render are covered too.\n      shadowRoot = el.shadowRoot;\n      shadowRoot?.addEventListener(\"slotchange\", updateNative);\n    }\n\n    if (observe) {\n      mo = new MutationObserver(() => updateNative());\n      mo.observe(el, {\n        childList: true,\n        subtree: false,\n        attributes: true,\n        attributeFilter: [\"slot\"],\n        characterData: true,\n      });\n    }\n  };\n\n  onMounted(attach);\n  onBeforeUnmount(cleanup);\n\n  // If host ref changes, reattach\n  watch(\n    () => unref(host),\n    () => {\n      if (isWebComponent.value) attach();\n    },\n  );\n\n  // Select presence based on component type\n  const present = computed(() => (isWebComponent.value ? hasNativeSlot.value : hasVueSlot.value));\n\n  return {\n    present,\n    hasVueSlot,\n    hasNativeSlot,\n    refresh: updateNative,\n  };\n}\n","import { onUnmounted, type Ref } from \"vue\";\n\nexport type HoverPopover = {\n  root: Ref<HTMLElement | null>;\n  /** The surface, which may be teleported out of `root`, so popovers nested in it still count as descendants. */\n  floating?: Ref<HTMLElement | null>;\n  /** The `hoverTarget` ancestor, when set: popovers opening inside it are within this one's hover area too. */\n  hoverArea?: Ref<HTMLElement | null>;\n  /** Attempts to close the popover. Returns false if it refused (e.g. disableClickOutsideToClose). */\n  close: () => boolean;\n};\n\nconst onScreen = new Set<HoverPopover>();\n\nconst isAncestorOf = (outer: HoverPopover, inner: HoverPopover) => {\n  const innerRoot = inner.root.value;\n  if (!innerRoot) return false;\n  return Boolean(\n    outer.root.value?.contains(innerRoot) ||\n      outer.floating?.value?.contains(innerRoot) ||\n      outer.hoverArea?.value?.contains(innerRoot),\n  );\n};\n\n/**\n * Keeps at most one dismissible hover popover on screen at a time. Uncoordinated, a sweep\n * across a list of triggers paints a trail: each popover the pointer left is still counting\n * down its `closeDelay` bridge while the next one opens instantly. Ancestors are spared — a\n * nested popover opening means the pointer is still inside the outer one. That includes one opening\n * anywhere in the outer's `hoverTarget` area (e.g. a tooltip on a button in the same row). A popover that\n * refuses to close (disableClickOutsideToClose) stays on screen alongside newly opened ones.\n *\n * Returns a setter for this popover's on-screen state.\n */\nexport const useHoverPopoverGroup = (popover: HoverPopover) => {\n  onUnmounted(() => onScreen.delete(popover));\n\n  return (isOpen: boolean) => {\n    if (!isOpen) {\n      onScreen.delete(popover);\n      return;\n    }\n    for (const other of [...onScreen]) {\n      if (other !== popover && !isAncestorOf(other, popover) && other.close()) onScreen.delete(other);\n    }\n    onScreen.add(popover);\n  };\n};\n","<script lang=\"ts\">\n/**\n * Every popover uses this same `anchor-name`. That is safe — and deliberate —\n * because each instance also declares `anchor-scope` for this name on its root,\n * which confines the name to that subtree. Two instances therefore cannot see\n * each other's anchor, so no per-instance identifier has to be generated (and\n * there is nothing for instances to collide on, including copies of this module\n * loaded from different bundles).\n *\n * Scoping just this name, rather than `anchor-scope: all`, leaves any other\n * anchor-positioned content inside the popover (e.g. charts) untouched.\n */\nconst PV_POPOVER_V2_ANCHOR = \"--pv-popover-v2-anchor\";\n</script>\n\n<script setup lang=\"ts\">\nimport { computed, getCurrentInstance, nextTick, onMounted, onUnmounted, ref, watch, type CSSProperties } from \"vue\";\nimport { AlignedPlacement, flip, offset, Placement, useFloating, type Middleware } from \"@floating-ui/vue\";\nimport { onClickOutside, useDebounceFn, useElementBounding, useElementHover } from \"@vueuse/core\";\nimport { PvPopoverV2Props } from \"@/components/base/PvPopoverV2/types.ts\";\nimport { PvAlignmentPositions } from \"@/components/base/baseProps.ts\";\nimport { useSlotPresence } from \"@/composables/useSlotPresence.ts\";\nimport { useHoverPopoverGroup } from \"@/components/base/PvPopoverV2/useHoverPopoverGroup.ts\";\n\nconst props = withDefaults(defineProps<PvPopoverV2Props>(), {\n  disableAutoPlacement: false,\n  position: \"bottom-left\",\n  positioningStrategy: \"absolute\",\n  disableInteractive: false,\n  enableClickToggle: false,\n  enableGroupSync: false,\n  useTeleport: false,\n  disableClickOutsideToClose: false,\n  showOnHover: false,\n  delay: 25,\n  closeDelay: 200,\n  zIndex: 10,\n  teleportLocation: \"body\",\n  disabled: false,\n  cssCustomProperties: () => ({}),\n});\n\nconst isOpen = defineModel<boolean>();\nconst instance = getCurrentInstance();\nconst customElementHost =\n  typeof HTMLElement !== \"undefined\" && instance && \"ce\" in instance && instance.ce instanceof HTMLElement\n    ? instance.ce\n    : undefined;\nconst { hasVueSlot, hasNativeSlot } = useSlotPresence(\"content\", { host: customElementHost });\nconst hasContent = computed(() => (customElementHost ? hasNativeSlot.value : hasVueSlot.value));\n\n// This is the clipping-safe path used by more than 99% of observed customer\n// sessions. Older browsers keep the existing Floating UI behavior below.\nconst useNativePopover =\n  typeof HTMLElement !== \"undefined\" &&\n  typeof HTMLElement.prototype.showPopover === \"function\" &&\n  typeof CSS !== \"undefined\" &&\n  typeof CSS.supports === \"function\" &&\n  [\n    \"anchor-name: --pv-anchor\",\n    \"position-area: bottom\",\n    \"position-try-fallbacks: flip-block\",\n    \"position-visibility: anchors-visible\",\n    // Required: the shared anchor name is only collision-free because each\n    // instance scopes it. Without `anchor-scope` every popover would resolve to\n    // the last same-named anchor in the document, so such browsers must keep the\n    // Floating UI path below instead.\n    `anchor-scope: ${PV_POPOVER_V2_ANCHOR}`,\n  ].every((query) => CSS.supports(query));\n\nconst isMounted = ref(false);\nconst root = ref<HTMLElement | null>(null);\nconst triggerWrapper = ref<HTMLElement | null>(null);\nconst reference = ref<HTMLElement | null>(null);\nconst floating = ref<HTMLElement | null>(null);\n\n// `hoverTarget` widens the hover area to an ancestor of the trigger; the trigger still anchors.\nconst hoverElement = computed(\n  () => (props.hoverTarget && triggerWrapper.value?.closest<HTMLElement>(props.hoverTarget)) || triggerWrapper.value,\n);\nconst triggerHovered = useElementHover(hoverElement);\nconst floatingHovered = useElementHover(floating);\nconst triggerFocused = ref(false);\nconst floatingFocused = ref(false);\nconst hoverLatchedOff = ref(false);\n\nconst syncHoverGroup = useHoverPopoverGroup({\n  root,\n  floating,\n  hoverArea: computed(() => (props.hoverTarget ? hoverElement.value : null)),\n  close: () => {\n    if (props.disableClickOutsideToClose) return false;\n    closeNow();\n    return true;\n  },\n});\n\nconst placementMapping: Record<PvAlignmentPositions, AlignedPlacement | Placement> = {\n  \"top-center\": \"top\",\n  \"bottom-center\": \"bottom\",\n  \"center-left\": \"left\",\n  \"center-right\": \"right\",\n  \"right-top\": \"right-start\",\n  \"right-bottom\": \"right-end\",\n  \"top-left\": \"top-start\",\n  \"top-right\": \"top-end\",\n  \"bottom-left\": \"bottom-start\",\n  \"bottom-right\": \"bottom-end\",\n};\n\nconst nativePlacementMapping: Record<PvAlignmentPositions, { area: string; margin: string }> = {\n  \"top-center\": { area: \"top\", margin: \"margin-block-end\" },\n  \"bottom-center\": { area: \"bottom\", margin: \"margin-block-start\" },\n  \"center-left\": { area: \"left\", margin: \"margin-inline-end\" },\n  \"center-right\": { area: \"right\", margin: \"margin-inline-start\" },\n  \"right-top\": { area: \"span-bottom right\", margin: \"margin-inline-start\" },\n  \"right-bottom\": { area: \"span-top right\", margin: \"margin-inline-start\" },\n  \"top-left\": { area: \"top span-right\", margin: \"margin-block-end\" },\n  \"top-right\": { area: \"top span-left\", margin: \"margin-block-end\" },\n  \"bottom-left\": { area: \"bottom span-right\", margin: \"margin-block-start\" },\n  \"bottom-right\": { area: \"bottom span-left\", margin: \"margin-block-start\" },\n};\n\nconst popoverType = computed(() => (props.showOnHover || props.disableClickOutsideToClose ? \"manual\" : \"auto\"));\n// Confine this instance's anchor name to its own subtree, so every popover can\n// share one constant name without their anchors resolving to each other.\nconst rootStyle = computed(() => ({\n  width: \"fit-content\",\n  ...(useNativePopover ? { \"anchor-scope\": PV_POPOVER_V2_ANCHOR } : undefined),\n  ...props.cssCustomProperties,\n}));\nconst triggerStyle = computed(() => (useNativePopover ? { \"anchor-name\": PV_POPOVER_V2_ANCHOR } : undefined));\nconst nativePopoverStyles = computed(() => {\n  const placement = nativePlacementMapping[props.position];\n  return {\n    \"position-anchor\": PV_POPOVER_V2_ANCHOR,\n    \"position-area\": placement.area,\n    \"position-try-fallbacks\": props.disableAutoPlacement\n      ? undefined\n      : \"flip-block, flip-inline, flip-block flip-inline\",\n    [placement.margin]: `${props.offset ?? 0}px`,\n  };\n});\n\nlet updateLegacyPosition = () => {};\nlet getLegacyFloatingStyles: () => CSSProperties = () => ({});\n\nif (!useNativePopover) {\n  const middleware: Middleware[] = [];\n  if (!props.disableAutoPlacement) {\n    middleware.push(flip({ fallbackStrategy: \"initialPlacement\" }));\n  }\n  if (props.offset) {\n    middleware.push(offset(props.offset));\n  }\n\n  const legacyFloating = useFloating(reference, floating, {\n    placement: placementMapping[props.position],\n    strategy: props.positioningStrategy,\n    middleware,\n  });\n  updateLegacyPosition = legacyFloating.update;\n  getLegacyFloatingStyles = () => legacyFloating.floatingStyles.value;\n\n  const elementBounds = useElementBounding(reference);\n  const handleBoundsChange = useDebounceFn(() => {\n    if (isOpen.value) updateLegacyPosition();\n  }, 5);\n  watch([elementBounds.top, elementBounds.left, elementBounds.width, elementBounds.height], handleBoundsChange);\n\n  const ignoreForClickOutside = computed(() => [\n    floating.value,\n    \".p-datepicker-panel\",\n    ...(props.ignoreClickOutsideClasses?.map((className) => `.${className}`) ?? []),\n  ]);\n  onClickOutside(\n    root,\n    () => {\n      if (!props.disableClickOutsideToClose) setPopoverState(false);\n    },\n    { ignore: ignoreForClickOutside },\n  );\n}\n\nconst legacyPopoverStyles = computed(() => ({\n  ...getLegacyFloatingStyles(),\n  zIndex: props.zIndex,\n}));\n\nlet openDelayTimeout: ReturnType<typeof setTimeout> | undefined;\nlet closeDelayTimeout: ReturnType<typeof setTimeout> | undefined;\n\nconst clearOpenDelayTimeout = () => {\n  if (openDelayTimeout) clearTimeout(openDelayTimeout);\n  openDelayTimeout = undefined;\n};\n\nconst clearCloseDelayTimeout = () => {\n  if (closeDelayTimeout) clearTimeout(closeDelayTimeout);\n  closeDelayTimeout = undefined;\n};\n\nconst setPopoverState = (state: boolean) => {\n  clearOpenDelayTimeout();\n  clearCloseDelayTimeout();\n  if (state && (props.disabled || !hasContent.value)) return;\n  if (state && props.delay > 0 && (props.showOnHover || !useNativePopover)) {\n    openDelayTimeout = setTimeout(() => {\n      isOpen.value = true;\n      openDelayTimeout = undefined;\n    }, props.delay);\n  } else {\n    isOpen.value = state;\n  }\n};\n\nconst closeNow = () => {\n  clearOpenDelayTimeout();\n  clearCloseDelayTimeout();\n  isOpen.value = false;\n};\n\nconst syncNativeSurface = () => {\n  const surface = floating.value;\n  if (!surface || !isMounted.value || !hasContent.value) return;\n  if (isOpen.value) surface.showPopover();\n  else surface.hidePopover();\n};\n\n// A surface hidden under the pointer does not reliably get a `mouseleave` -\n// WebKit keeps reporting the stale hover until the pointer moves again - so the\n// surface only counts while it is actually showing. Otherwise closing from\n// inside the popover (a close button, Escape) would immediately reopen it.\nconst surfaceEngaged = computed(() => Boolean(isOpen.value) && (floatingHovered.value || floatingFocused.value));\n\nconst isHovered = computed(() => {\n  if (!props.showOnHover || hoverLatchedOff.value) return false;\n  return props.disableInteractive\n    ? triggerHovered.value || triggerFocused.value\n    : triggerHovered.value || triggerFocused.value || surfaceEngaged.value;\n});\n\nwatch([triggerHovered, triggerFocused, floatingFocused], ([hovered, focused, floatingFocusedValue]) => {\n  if (!hovered && !focused && !floatingFocusedValue) hoverLatchedOff.value = false;\n});\n\n// A mouse click leaves the trigger focused after the pointer has moved on, so only\n// keyboard focus (`:focus-visible`) should hold a hover popover open.\nconst handleTriggerFocusIn = ({ target }: FocusEvent) => {\n  triggerFocused.value = !props.disabled && target instanceof HTMLElement && target.matches(\":focus-visible\");\n};\n\n// Tabbing from the trigger into the content blurs the trigger, so the content\n// itself must also be tracked or the popover would close mid-tab.\nconst handleFloatingFocusIn = ({ target }: FocusEvent) => {\n  floatingFocused.value = !props.disabled && target instanceof HTMLElement && target.matches(\":focus-visible\");\n};\n\nconst handleFloatingFocusOut = () => {\n  floatingFocused.value = false;\n};\n\nconst handleTriggerClick = () => {\n  if (props.showOnHover) {\n    if (props.disableClickOutsideToClose) return;\n    // A pending open still counts as showing, so clicking through it dismisses.\n    if (!isOpen.value && !openDelayTimeout && props.enableClickToggle) {\n      // The pointer never left, so no fresh hover event will clear the latch.\n      hoverLatchedOff.value = false;\n      setPopoverState(true);\n      return;\n    }\n    hoverLatchedOff.value = true;\n    closeNow();\n    return;\n  }\n  setPopoverState(openDelayTimeout ? false : !isOpen.value);\n};\n\nconst handleToggle = (event: Event) => {\n  const open = (event as ToggleEvent).newState === \"open\";\n  if (isOpen.value !== open) isOpen.value = open;\n};\n\nconst handleKeydown = (event: KeyboardEvent) => {\n  if (useNativePopover && popoverType.value === \"manual\" && event.key === \"Escape\" && isOpen.value) {\n    event.preventDefault();\n    event.stopPropagation();\n    setPopoverState(false);\n  }\n};\n\nconst FOCUSABLE_SELECTOR =\n  'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex=\"-1\"])';\nconst focusableWithin = (element: HTMLElement | null) =>\n  element ? Array.from(element.querySelectorAll<HTMLElement>(FOCUSABLE_SELECTOR)) : [];\n\n// A teleported surface sits away from the trigger in the DOM, so Tab from the trigger would skip its content.\nconst bridgesKeyboardFocus = computed(\n  () => props.useTeleport && !useNativePopover && props.showOnHover && !props.disabled,\n);\n\nconst handleTriggerKeydown = (event: KeyboardEvent) => {\n  if (!bridgesKeyboardFocus.value || event.key !== \"Tab\" || event.shiftKey || !isOpen.value) return;\n  const [first] = focusableWithin(floating.value);\n  if (!first) return;\n  event.preventDefault();\n  // Set before focusing: the trigger's focusout would otherwise close the popover before this focus lands.\n  floatingFocused.value = true;\n  first.focus();\n};\n\nconst handleFloatingKeydown = (event: KeyboardEvent) => {\n  if (!bridgesKeyboardFocus.value) return;\n  const [trigger] = focusableWithin(triggerWrapper.value);\n  if (event.key === \"Escape\") {\n    event.preventDefault();\n    event.stopPropagation();\n    hoverLatchedOff.value = true;\n    closeNow();\n    trigger?.focus();\n    return;\n  }\n  if (event.key !== \"Tab\") return;\n  const items = focusableWithin(floating.value);\n  if (event.shiftKey && document.activeElement === items[0]) {\n    event.preventDefault();\n    trigger?.focus();\n  } else if (!event.shiftKey && document.activeElement === items[items.length - 1]) {\n    // Not prevented: focus moves on from the trigger, so leaving the popover forwards never traps the user.\n    hoverLatchedOff.value = true;\n    closeNow();\n    trigger?.focus();\n  }\n};\n\nwatch(isOpen, async (open) => {\n  if (props.showOnHover && props.enableGroupSync) syncHoverGroup(Boolean(open));\n  if (!useNativePopover) {\n    if (open) updateLegacyPosition();\n    return;\n  }\n  await nextTick();\n  syncNativeSurface();\n});\n\nwatch(isHovered, (hovered) => {\n  if (!props.showOnHover) return;\n  if (hovered) {\n    // Opening (or the pointer re-entered the trigger/popover): cancel any\n    // pending close so the bridge holds the popover open.\n    setPopoverState(true);\n    return;\n  }\n  // The pointer left both the trigger and the popover. Cancel any pending\n  // delayed open so the popover can't flash open after the pointer is gone.\n  clearOpenDelayTimeout();\n  if (props.closeDelay > 0) {\n    // Defer the close so the pointer can bridge the gap from the trigger to the\n    // popover. If it lands on either, `isHovered` flips back to true and the\n    // branch above cancels this timeout.\n    clearCloseDelayTimeout();\n    closeDelayTimeout = setTimeout(() => {\n      closeDelayTimeout = undefined;\n      if (!isHovered.value) setPopoverState(false);\n    }, props.closeDelay);\n  } else {\n    setPopoverState(false);\n  }\n});\n\nwatch(hasContent, (present) => {\n  if (!present) {\n    closeNow();\n  } else if (useNativePopover && isOpen.value) {\n    nextTick(syncNativeSurface);\n  }\n});\n\nonMounted(() => {\n  reference.value = triggerWrapper.value;\n  isMounted.value = true;\n  if (isOpen.value) nextTick(() => (useNativePopover ? syncNativeSurface() : updateLegacyPosition()));\n});\n\nonUnmounted(() => {\n  clearOpenDelayTimeout();\n  clearCloseDelayTimeout();\n});\n\nwatch(\n  () => props.disabled,\n  (disabled) => {\n    if (!disabled) {\n      if (isHovered.value) setPopoverState(true);\n      return;\n    }\n    if (triggerFocused.value) triggerFocused.value = false;\n    if (floatingFocused.value) floatingFocused.value = false;\n    setPopoverState(false);\n  },\n);\n</script>\n\n<template>\n  <div ref=\"root\" :style=\"rootStyle\" @keydown=\"handleKeydown\">\n    <div\n      ref=\"triggerWrapper\"\n      :style=\"triggerStyle\"\n      @click=\"handleTriggerClick\"\n      @focusin=\"handleTriggerFocusIn\"\n      @focusout=\"triggerFocused = false\"\n      @keydown=\"handleTriggerKeydown\"\n    >\n      <slot name=\"trigger\"> </slot>\n    </div>\n\n    <div\n      v-if=\"isMounted && useNativePopover && hasContent\"\n      ref=\"floating\"\n      class=\"pv-floating pv-floating-native\"\n      :popover=\"popoverType\"\n      :style=\"nativePopoverStyles\"\n      @toggle=\"handleToggle\"\n      @focusin=\"handleFloatingFocusIn\"\n      @focusout=\"handleFloatingFocusOut\"\n    >\n      <slot name=\"content\" v-if=\"!disabled\"></slot>\n    </div>\n\n    <Teleport v-else-if=\"hasContent\" :to=\"teleportLocation\" :disabled=\"!props.useTeleport || disabled\">\n      <div\n        ref=\"floating\"\n        class=\"pv-floating\"\n        v-show=\"isOpen\"\n        :style=\"legacyPopoverStyles\"\n        @focusin=\"handleFloatingFocusIn\"\n        @focusout=\"handleFloatingFocusOut\"\n        @keydown=\"handleFloatingKeydown\"\n      >\n        <slot name=\"content\"></slot>\n      </div>\n    </Teleport>\n  </div>\n</template>\n","<script lang=\"ts\">\n/**\n * Every popover uses this same `anchor-name`. That is safe — and deliberate —\n * because each instance also declares `anchor-scope` for this name on its root,\n * which confines the name to that subtree. Two instances therefore cannot see\n * each other's anchor, so no per-instance identifier has to be generated (and\n * there is nothing for instances to collide on, including copies of this module\n * loaded from different bundles).\n *\n * Scoping just this name, rather than `anchor-scope: all`, leaves any other\n * anchor-positioned content inside the popover (e.g. charts) untouched.\n */\nconst PV_POPOVER_V2_ANCHOR = \"--pv-popover-v2-anchor\";\n</script>\n\n<script setup lang=\"ts\">\nimport { computed, getCurrentInstance, nextTick, onMounted, onUnmounted, ref, watch, type CSSProperties } from \"vue\";\nimport { AlignedPlacement, flip, offset, Placement, useFloating, type Middleware } from \"@floating-ui/vue\";\nimport { onClickOutside, useDebounceFn, useElementBounding, useElementHover } from \"@vueuse/core\";\nimport { PvPopoverV2Props } from \"@/components/base/PvPopoverV2/types.ts\";\nimport { PvAlignmentPositions } from \"@/components/base/baseProps.ts\";\nimport { useSlotPresence } from \"@/composables/useSlotPresence.ts\";\nimport { useHoverPopoverGroup } from \"@/components/base/PvPopoverV2/useHoverPopoverGroup.ts\";\n\nconst props = withDefaults(defineProps<PvPopoverV2Props>(), {\n  disableAutoPlacement: false,\n  position: \"bottom-left\",\n  positioningStrategy: \"absolute\",\n  disableInteractive: false,\n  enableClickToggle: false,\n  enableGroupSync: false,\n  useTeleport: false,\n  disableClickOutsideToClose: false,\n  showOnHover: false,\n  delay: 25,\n  closeDelay: 200,\n  zIndex: 10,\n  teleportLocation: \"body\",\n  disabled: false,\n  cssCustomProperties: () => ({}),\n});\n\nconst isOpen = defineModel<boolean>();\nconst instance = getCurrentInstance();\nconst customElementHost =\n  typeof HTMLElement !== \"undefined\" && instance && \"ce\" in instance && instance.ce instanceof HTMLElement\n    ? instance.ce\n    : undefined;\nconst { hasVueSlot, hasNativeSlot } = useSlotPresence(\"content\", { host: customElementHost });\nconst hasContent = computed(() => (customElementHost ? hasNativeSlot.value : hasVueSlot.value));\n\n// This is the clipping-safe path used by more than 99% of observed customer\n// sessions. Older browsers keep the existing Floating UI behavior below.\nconst useNativePopover =\n  typeof HTMLElement !== \"undefined\" &&\n  typeof HTMLElement.prototype.showPopover === \"function\" &&\n  typeof CSS !== \"undefined\" &&\n  typeof CSS.supports === \"function\" &&\n  [\n    \"anchor-name: --pv-anchor\",\n    \"position-area: bottom\",\n    \"position-try-fallbacks: flip-block\",\n    \"position-visibility: anchors-visible\",\n    // Required: the shared anchor name is only collision-free because each\n    // instance scopes it. Without `anchor-scope` every popover would resolve to\n    // the last same-named anchor in the document, so such browsers must keep the\n    // Floating UI path below instead.\n    `anchor-scope: ${PV_POPOVER_V2_ANCHOR}`,\n  ].every((query) => CSS.supports(query));\n\nconst isMounted = ref(false);\nconst root = ref<HTMLElement | null>(null);\nconst triggerWrapper = ref<HTMLElement | null>(null);\nconst reference = ref<HTMLElement | null>(null);\nconst floating = ref<HTMLElement | null>(null);\n\n// `hoverTarget` widens the hover area to an ancestor of the trigger; the trigger still anchors.\nconst hoverElement = computed(\n  () => (props.hoverTarget && triggerWrapper.value?.closest<HTMLElement>(props.hoverTarget)) || triggerWrapper.value,\n);\nconst triggerHovered = useElementHover(hoverElement);\nconst floatingHovered = useElementHover(floating);\nconst triggerFocused = ref(false);\nconst floatingFocused = ref(false);\nconst hoverLatchedOff = ref(false);\n\nconst syncHoverGroup = useHoverPopoverGroup({\n  root,\n  floating,\n  hoverArea: computed(() => (props.hoverTarget ? hoverElement.value : null)),\n  close: () => {\n    if (props.disableClickOutsideToClose) return false;\n    closeNow();\n    return true;\n  },\n});\n\nconst placementMapping: Record<PvAlignmentPositions, AlignedPlacement | Placement> = {\n  \"top-center\": \"top\",\n  \"bottom-center\": \"bottom\",\n  \"center-left\": \"left\",\n  \"center-right\": \"right\",\n  \"right-top\": \"right-start\",\n  \"right-bottom\": \"right-end\",\n  \"top-left\": \"top-start\",\n  \"top-right\": \"top-end\",\n  \"bottom-left\": \"bottom-start\",\n  \"bottom-right\": \"bottom-end\",\n};\n\nconst nativePlacementMapping: Record<PvAlignmentPositions, { area: string; margin: string }> = {\n  \"top-center\": { area: \"top\", margin: \"margin-block-end\" },\n  \"bottom-center\": { area: \"bottom\", margin: \"margin-block-start\" },\n  \"center-left\": { area: \"left\", margin: \"margin-inline-end\" },\n  \"center-right\": { area: \"right\", margin: \"margin-inline-start\" },\n  \"right-top\": { area: \"span-bottom right\", margin: \"margin-inline-start\" },\n  \"right-bottom\": { area: \"span-top right\", margin: \"margin-inline-start\" },\n  \"top-left\": { area: \"top span-right\", margin: \"margin-block-end\" },\n  \"top-right\": { area: \"top span-left\", margin: \"margin-block-end\" },\n  \"bottom-left\": { area: \"bottom span-right\", margin: \"margin-block-start\" },\n  \"bottom-right\": { area: \"bottom span-left\", margin: \"margin-block-start\" },\n};\n\nconst popoverType = computed(() => (props.showOnHover || props.disableClickOutsideToClose ? \"manual\" : \"auto\"));\n// Confine this instance's anchor name to its own subtree, so every popover can\n// share one constant name without their anchors resolving to each other.\nconst rootStyle = computed(() => ({\n  width: \"fit-content\",\n  ...(useNativePopover ? { \"anchor-scope\": PV_POPOVER_V2_ANCHOR } : undefined),\n  ...props.cssCustomProperties,\n}));\nconst triggerStyle = computed(() => (useNativePopover ? { \"anchor-name\": PV_POPOVER_V2_ANCHOR } : undefined));\nconst nativePopoverStyles = computed(() => {\n  const placement = nativePlacementMapping[props.position];\n  return {\n    \"position-anchor\": PV_POPOVER_V2_ANCHOR,\n    \"position-area\": placement.area,\n    \"position-try-fallbacks\": props.disableAutoPlacement\n      ? undefined\n      : \"flip-block, flip-inline, flip-block flip-inline\",\n    [placement.margin]: `${props.offset ?? 0}px`,\n  };\n});\n\nlet updateLegacyPosition = () => {};\nlet getLegacyFloatingStyles: () => CSSProperties = () => ({});\n\nif (!useNativePopover) {\n  const middleware: Middleware[] = [];\n  if (!props.disableAutoPlacement) {\n    middleware.push(flip({ fallbackStrategy: \"initialPlacement\" }));\n  }\n  if (props.offset) {\n    middleware.push(offset(props.offset));\n  }\n\n  const legacyFloating = useFloating(reference, floating, {\n    placement: placementMapping[props.position],\n    strategy: props.positioningStrategy,\n    middleware,\n  });\n  updateLegacyPosition = legacyFloating.update;\n  getLegacyFloatingStyles = () => legacyFloating.floatingStyles.value;\n\n  const elementBounds = useElementBounding(reference);\n  const handleBoundsChange = useDebounceFn(() => {\n    if (isOpen.value) updateLegacyPosition();\n  }, 5);\n  watch([elementBounds.top, elementBounds.left, elementBounds.width, elementBounds.height], handleBoundsChange);\n\n  const ignoreForClickOutside = computed(() => [\n    floating.value,\n    \".p-datepicker-panel\",\n    ...(props.ignoreClickOutsideClasses?.map((className) => `.${className}`) ?? []),\n  ]);\n  onClickOutside(\n    root,\n    () => {\n      if (!props.disableClickOutsideToClose) setPopoverState(false);\n    },\n    { ignore: ignoreForClickOutside },\n  );\n}\n\nconst legacyPopoverStyles = computed(() => ({\n  ...getLegacyFloatingStyles(),\n  zIndex: props.zIndex,\n}));\n\nlet openDelayTimeout: ReturnType<typeof setTimeout> | undefined;\nlet closeDelayTimeout: ReturnType<typeof setTimeout> | undefined;\n\nconst clearOpenDelayTimeout = () => {\n  if (openDelayTimeout) clearTimeout(openDelayTimeout);\n  openDelayTimeout = undefined;\n};\n\nconst clearCloseDelayTimeout = () => {\n  if (closeDelayTimeout) clearTimeout(closeDelayTimeout);\n  closeDelayTimeout = undefined;\n};\n\nconst setPopoverState = (state: boolean) => {\n  clearOpenDelayTimeout();\n  clearCloseDelayTimeout();\n  if (state && (props.disabled || !hasContent.value)) return;\n  if (state && props.delay > 0 && (props.showOnHover || !useNativePopover)) {\n    openDelayTimeout = setTimeout(() => {\n      isOpen.value = true;\n      openDelayTimeout = undefined;\n    }, props.delay);\n  } else {\n    isOpen.value = state;\n  }\n};\n\nconst closeNow = () => {\n  clearOpenDelayTimeout();\n  clearCloseDelayTimeout();\n  isOpen.value = false;\n};\n\nconst syncNativeSurface = () => {\n  const surface = floating.value;\n  if (!surface || !isMounted.value || !hasContent.value) return;\n  if (isOpen.value) surface.showPopover();\n  else surface.hidePopover();\n};\n\n// A surface hidden under the pointer does not reliably get a `mouseleave` -\n// WebKit keeps reporting the stale hover until the pointer moves again - so the\n// surface only counts while it is actually showing. Otherwise closing from\n// inside the popover (a close button, Escape) would immediately reopen it.\nconst surfaceEngaged = computed(() => Boolean(isOpen.value) && (floatingHovered.value || floatingFocused.value));\n\nconst isHovered = computed(() => {\n  if (!props.showOnHover || hoverLatchedOff.value) return false;\n  return props.disableInteractive\n    ? triggerHovered.value || triggerFocused.value\n    : triggerHovered.value || triggerFocused.value || surfaceEngaged.value;\n});\n\nwatch([triggerHovered, triggerFocused, floatingFocused], ([hovered, focused, floatingFocusedValue]) => {\n  if (!hovered && !focused && !floatingFocusedValue) hoverLatchedOff.value = false;\n});\n\n// A mouse click leaves the trigger focused after the pointer has moved on, so only\n// keyboard focus (`:focus-visible`) should hold a hover popover open.\nconst handleTriggerFocusIn = ({ target }: FocusEvent) => {\n  triggerFocused.value = !props.disabled && target instanceof HTMLElement && target.matches(\":focus-visible\");\n};\n\n// Tabbing from the trigger into the content blurs the trigger, so the content\n// itself must also be tracked or the popover would close mid-tab.\nconst handleFloatingFocusIn = ({ target }: FocusEvent) => {\n  floatingFocused.value = !props.disabled && target instanceof HTMLElement && target.matches(\":focus-visible\");\n};\n\nconst handleFloatingFocusOut = () => {\n  floatingFocused.value = false;\n};\n\nconst handleTriggerClick = () => {\n  if (props.showOnHover) {\n    if (props.disableClickOutsideToClose) return;\n    // A pending open still counts as showing, so clicking through it dismisses.\n    if (!isOpen.value && !openDelayTimeout && props.enableClickToggle) {\n      // The pointer never left, so no fresh hover event will clear the latch.\n      hoverLatchedOff.value = false;\n      setPopoverState(true);\n      return;\n    }\n    hoverLatchedOff.value = true;\n    closeNow();\n    return;\n  }\n  setPopoverState(openDelayTimeout ? false : !isOpen.value);\n};\n\nconst handleToggle = (event: Event) => {\n  const open = (event as ToggleEvent).newState === \"open\";\n  if (isOpen.value !== open) isOpen.value = open;\n};\n\nconst handleKeydown = (event: KeyboardEvent) => {\n  if (useNativePopover && popoverType.value === \"manual\" && event.key === \"Escape\" && isOpen.value) {\n    event.preventDefault();\n    event.stopPropagation();\n    setPopoverState(false);\n  }\n};\n\nconst FOCUSABLE_SELECTOR =\n  'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex=\"-1\"])';\nconst focusableWithin = (element: HTMLElement | null) =>\n  element ? Array.from(element.querySelectorAll<HTMLElement>(FOCUSABLE_SELECTOR)) : [];\n\n// A teleported surface sits away from the trigger in the DOM, so Tab from the trigger would skip its content.\nconst bridgesKeyboardFocus = computed(\n  () => props.useTeleport && !useNativePopover && props.showOnHover && !props.disabled,\n);\n\nconst handleTriggerKeydown = (event: KeyboardEvent) => {\n  if (!bridgesKeyboardFocus.value || event.key !== \"Tab\" || event.shiftKey || !isOpen.value) return;\n  const [first] = focusableWithin(floating.value);\n  if (!first) return;\n  event.preventDefault();\n  // Set before focusing: the trigger's focusout would otherwise close the popover before this focus lands.\n  floatingFocused.value = true;\n  first.focus();\n};\n\nconst handleFloatingKeydown = (event: KeyboardEvent) => {\n  if (!bridgesKeyboardFocus.value) return;\n  const [trigger] = focusableWithin(triggerWrapper.value);\n  if (event.key === \"Escape\") {\n    event.preventDefault();\n    event.stopPropagation();\n    hoverLatchedOff.value = true;\n    closeNow();\n    trigger?.focus();\n    return;\n  }\n  if (event.key !== \"Tab\") return;\n  const items = focusableWithin(floating.value);\n  if (event.shiftKey && document.activeElement === items[0]) {\n    event.preventDefault();\n    trigger?.focus();\n  } else if (!event.shiftKey && document.activeElement === items[items.length - 1]) {\n    // Not prevented: focus moves on from the trigger, so leaving the popover forwards never traps the user.\n    hoverLatchedOff.value = true;\n    closeNow();\n    trigger?.focus();\n  }\n};\n\nwatch(isOpen, async (open) => {\n  if (props.showOnHover && props.enableGroupSync) syncHoverGroup(Boolean(open));\n  if (!useNativePopover) {\n    if (open) updateLegacyPosition();\n    return;\n  }\n  await nextTick();\n  syncNativeSurface();\n});\n\nwatch(isHovered, (hovered) => {\n  if (!props.showOnHover) return;\n  if (hovered) {\n    // Opening (or the pointer re-entered the trigger/popover): cancel any\n    // pending close so the bridge holds the popover open.\n    setPopoverState(true);\n    return;\n  }\n  // The pointer left both the trigger and the popover. Cancel any pending\n  // delayed open so the popover can't flash open after the pointer is gone.\n  clearOpenDelayTimeout();\n  if (props.closeDelay > 0) {\n    // Defer the close so the pointer can bridge the gap from the trigger to the\n    // popover. If it lands on either, `isHovered` flips back to true and the\n    // branch above cancels this timeout.\n    clearCloseDelayTimeout();\n    closeDelayTimeout = setTimeout(() => {\n      closeDelayTimeout = undefined;\n      if (!isHovered.value) setPopoverState(false);\n    }, props.closeDelay);\n  } else {\n    setPopoverState(false);\n  }\n});\n\nwatch(hasContent, (present) => {\n  if (!present) {\n    closeNow();\n  } else if (useNativePopover && isOpen.value) {\n    nextTick(syncNativeSurface);\n  }\n});\n\nonMounted(() => {\n  reference.value = triggerWrapper.value;\n  isMounted.value = true;\n  if (isOpen.value) nextTick(() => (useNativePopover ? syncNativeSurface() : updateLegacyPosition()));\n});\n\nonUnmounted(() => {\n  clearOpenDelayTimeout();\n  clearCloseDelayTimeout();\n});\n\nwatch(\n  () => props.disabled,\n  (disabled) => {\n    if (!disabled) {\n      if (isHovered.value) setPopoverState(true);\n      return;\n    }\n    if (triggerFocused.value) triggerFocused.value = false;\n    if (floatingFocused.value) floatingFocused.value = false;\n    setPopoverState(false);\n  },\n);\n</script>\n\n<template>\n  <div ref=\"root\" :style=\"rootStyle\" @keydown=\"handleKeydown\">\n    <div\n      ref=\"triggerWrapper\"\n      :style=\"triggerStyle\"\n      @click=\"handleTriggerClick\"\n      @focusin=\"handleTriggerFocusIn\"\n      @focusout=\"triggerFocused = false\"\n      @keydown=\"handleTriggerKeydown\"\n    >\n      <slot name=\"trigger\"> </slot>\n    </div>\n\n    <div\n      v-if=\"isMounted && useNativePopover && hasContent\"\n      ref=\"floating\"\n      class=\"pv-floating pv-floating-native\"\n      :popover=\"popoverType\"\n      :style=\"nativePopoverStyles\"\n      @toggle=\"handleToggle\"\n      @focusin=\"handleFloatingFocusIn\"\n      @focusout=\"handleFloatingFocusOut\"\n    >\n      <slot name=\"content\" v-if=\"!disabled\"></slot>\n    </div>\n\n    <Teleport v-else-if=\"hasContent\" :to=\"teleportLocation\" :disabled=\"!props.useTeleport || disabled\">\n      <div\n        ref=\"floating\"\n        class=\"pv-floating\"\n        v-show=\"isOpen\"\n        :style=\"legacyPopoverStyles\"\n        @focusin=\"handleFloatingFocusIn\"\n        @focusout=\"handleFloatingFocusOut\"\n        @keydown=\"handleFloatingKeydown\"\n      >\n        <slot name=\"content\"></slot>\n      </div>\n    </Teleport>\n  </div>\n</template>\n","<script setup lang=\"ts\">\nimport { computed, getCurrentInstance } from \"vue\";\nimport { PvTooltipV2Props } from \"./types\";\nimport PvPopoverV2 from \"@/components/base/PvPopoverV2/PvPopoverV2.vue\";\nimport { useSlotPresence } from \"@/composables/useSlotPresence.ts\";\n\nconst props = withDefaults(defineProps<PvTooltipV2Props>(), {\n  variant: \"dark\",\n  position: \"top-center\",\n  size: \"md\",\n  disableInteractive: false,\n  delay: 0,\n  showOnHover: true,\n});\n\nconst instance = getCurrentInstance();\nconst customElementHost =\n  typeof HTMLElement !== \"undefined\" && instance && \"ce\" in instance && instance.ce instanceof HTMLElement\n    ? instance.ce\n    : undefined;\nconst { hasVueSlot: hasVueContent, hasNativeSlot: hasCustomElementContent } = useSlotPresence(\"content\", {\n  host: customElementHost,\n});\nconst hasContentSlot = computed(() => (customElementHost ? hasCustomElementContent.value : hasVueContent.value));\nconst hasTooltipContent = computed(() => !!props.description || hasContentSlot.value);\n</script>\n\n<template>\n  <PvPopoverV2 v-bind=\"$props\">\n    <template #trigger>\n      <slot name=\"trigger\">\n        <p>{{ label }}</p>\n      </slot>\n    </template>\n    <template v-if=\"hasTooltipContent\" #content>\n      <div\n        class=\"pv-tooltip-v2-content\"\n        role=\"tooltip\"\n        :data-variant=\"variant\"\n        :class=\"{ 'pv-tooltip-v2-content-small': size === 'sm' }\"\n      >\n        <slot name=\"content\">\n          {{ description }}\n        </slot>\n      </div>\n    </template>\n  </PvPopoverV2>\n</template>\n","<script setup lang=\"ts\">\nimport { computed, getCurrentInstance } from \"vue\";\nimport { PvTooltipV2Props } from \"./types\";\nimport PvPopoverV2 from \"@/components/base/PvPopoverV2/PvPopoverV2.vue\";\nimport { useSlotPresence } from \"@/composables/useSlotPresence.ts\";\n\nconst props = withDefaults(defineProps<PvTooltipV2Props>(), {\n  variant: \"dark\",\n  position: \"top-center\",\n  size: \"md\",\n  disableInteractive: false,\n  delay: 0,\n  showOnHover: true,\n});\n\nconst instance = getCurrentInstance();\nconst customElementHost =\n  typeof HTMLElement !== \"undefined\" && instance && \"ce\" in instance && instance.ce instanceof HTMLElement\n    ? instance.ce\n    : undefined;\nconst { hasVueSlot: hasVueContent, hasNativeSlot: hasCustomElementContent } = useSlotPresence(\"content\", {\n  host: customElementHost,\n});\nconst hasContentSlot = computed(() => (customElementHost ? hasCustomElementContent.value : hasVueContent.value));\nconst hasTooltipContent = computed(() => !!props.description || hasContentSlot.value);\n</script>\n\n<template>\n  <PvPopoverV2 v-bind=\"$props\">\n    <template #trigger>\n      <slot name=\"trigger\">\n        <p>{{ label }}</p>\n      </slot>\n    </template>\n    <template v-if=\"hasTooltipContent\" #content>\n      <div\n        class=\"pv-tooltip-v2-content\"\n        role=\"tooltip\"\n        :data-variant=\"variant\"\n        :class=\"{ 'pv-tooltip-v2-content-small': size === 'sm' }\"\n      >\n        <slot name=\"content\">\n          {{ description }}\n        </slot>\n      </div>\n    </template>\n  </PvPopoverV2>\n</template>\n","<script setup lang=\"ts\">\nimport PvButton from \"@/components/base/PvButton/PvButton.vue\";\nimport PvTooltipV2 from \"@/components/base/PvTooltipV2/PvTooltipV2.vue\";\nimport { PvSegmentControlSize, PvSegmentedControlOption } from \"./types\";\n\ninterface PvSegmentControlProps {\n  /** The list of options rendered as segments. Each option can have a label, icon, or both. */\n  options: PvSegmentedControlOption[];\n  /**\n   * Controls the overall height of the segmented control.\n   */\n  size?: PvSegmentControlSize;\n}\n\nwithDefaults(defineProps<PvSegmentControlProps>(), {\n  size: \"lg\",\n  options: () => [],\n});\n\nconst modelValue = defineModel<string>({ required: true });\n\nconst selectOption = (option: PvSegmentedControlOption) => {\n  if (option.disabled) return;\n  modelValue.value = option.value;\n};\n</script>\n\n<template>\n  <div\n    :class=\"[\n      'pv-segmented-control',\n      {\n        'pv-segmented-control-large': size === 'xl',\n      },\n    ]\"\n  >\n    <PvTooltipV2\n      v-for=\"option in options\"\n      :key=\"option.value\"\n      variant=\"dark\"\n      position=\"bottom-right\"\n      style=\"width: 100%\"\n    >\n      <template #trigger>\n        <PvButton\n          class=\"pv-full-width\"\n          variant=\"ghost\"\n          :label=\"option.label\"\n          :ariaLabel=\"option.ariaLabel\"\n          :left-icon=\"option.iconPosition === 'left' ? option.icon : undefined\"\n          :right-icon=\"option.iconPosition === 'right' ? option.icon : undefined\"\n          :disabled=\"option.disabled\"\n          :class=\"{ 'pv-disabled': option.disabled }\"\n          :data-active=\"modelValue === option.value ? true : null\"\n          @click=\"selectOption(option)\"\n        />\n      </template>\n      <template v-if=\"option.disabledReason\" #content>\n        {{ option.disabledReason }}\n      </template>\n    </PvTooltipV2>\n  </div>\n</template>\n","<script setup lang=\"ts\">\nimport PvButton from \"@/components/base/PvButton/PvButton.vue\";\nimport PvTooltipV2 from \"@/components/base/PvTooltipV2/PvTooltipV2.vue\";\nimport { PvSegmentControlSize, PvSegmentedControlOption } from \"./types\";\n\ninterface PvSegmentControlProps {\n  /** The list of options rendered as segments. Each option can have a label, icon, or both. */\n  options: PvSegmentedControlOption[];\n  /**\n   * Controls the overall height of the segmented control.\n   */\n  size?: PvSegmentControlSize;\n}\n\nwithDefaults(defineProps<PvSegmentControlProps>(), {\n  size: \"lg\",\n  options: () => [],\n});\n\nconst modelValue = defineModel<string>({ required: true });\n\nconst selectOption = (option: PvSegmentedControlOption) => {\n  if (option.disabled) return;\n  modelValue.value = option.value;\n};\n</script>\n\n<template>\n  <div\n    :class=\"[\n      'pv-segmented-control',\n      {\n        'pv-segmented-control-large': size === 'xl',\n      },\n    ]\"\n  >\n    <PvTooltipV2\n      v-for=\"option in options\"\n      :key=\"option.value\"\n      variant=\"dark\"\n      position=\"bottom-right\"\n      style=\"width: 100%\"\n    >\n      <template #trigger>\n        <PvButton\n          class=\"pv-full-width\"\n          variant=\"ghost\"\n          :label=\"option.label\"\n          :ariaLabel=\"option.ariaLabel\"\n          :left-icon=\"option.iconPosition === 'left' ? option.icon : undefined\"\n          :right-icon=\"option.iconPosition === 'right' ? option.icon : undefined\"\n          :disabled=\"option.disabled\"\n          :class=\"{ 'pv-disabled': option.disabled }\"\n          :data-active=\"modelValue === option.value ? true : null\"\n          @click=\"selectOption(option)\"\n        />\n      </template>\n      <template v-if=\"option.disabledReason\" #content>\n        {{ option.disabledReason }}\n      </template>\n    </PvTooltipV2>\n  </div>\n</template>\n","export const processedHawaiiTopology = {\n  type: \"Feature\",\n  properties: {\n    name: \"Hawaii\",\n  },\n  geometry: {\n    type: \"MultiPolygon\",\n    coordinates: [\n      [\n        [\n          [-105.70409839588592, 25.25161631830986],\n          [-105.74881952767498, 25.17708731830985],\n          [-105.7324578028169, 25.056085318309865],\n          [-105.68895681047411, 25.045162318309856],\n          [-105.67536932349577, 24.993176818309855],\n          [-105.68981478149271, 24.810911818309865],\n          [-105.66432618951364, 24.761803318309862],\n          [-105.65719536478286, 24.60298481830986],\n          [-105.80352494114891, 24.229658818309865],\n          [-105.78141417789311, 24.13590431830986],\n          [-105.5774075760354, 24.035093818309853],\n          [-105.51858474640801, 23.957137318309865],\n          [-105.40936139329716, 24.036536818309862],\n          [-105.17504886992111, 24.287800318309863],\n          [-105.09153381173394, 24.308866318309853],\n          [-104.75568134783998, 24.492257818309863],\n          [-104.67362977026619, 24.472298818309863],\n          [-104.60114321656317, 24.483500818309864],\n          [-104.36533065836738, 24.577913818309863],\n          [-104.10476925447796, 24.730772818309866],\n          [-103.98390683066299, 24.831910318309863],\n          [-103.96829885998909, 24.87607331830986],\n          [-104.16112558606994, 25.03073981830986],\n          [-104.14508660820235, 25.11696881830986],\n          [-104.16077636759547, 25.189867318309854],\n          [-104.28677083656623, 25.17295781830986],\n          [-104.22696065992807, 25.364036818309863],\n          [-104.30886391690893, 25.487773318309863],\n          [-104.42831881051, 25.602725818309867],\n          [-104.7292827123988, 25.752170818309864],\n          [-104.80549464909689, 25.778293318309863],\n          [-104.86740887482102, 25.767746818309853],\n          [-105.02892662902929, 25.915097818309864],\n          [-105.179856822999, 25.98826031830986],\n          [-105.2436709875459, 25.963798318309863],\n          [-105.29910352520284, 25.84654781830986],\n          [-105.30628052032404, 25.76630231830986],\n          [-105.25460778276909, 25.619854318309862],\n          [-105.28450376869205, 25.555100818309864],\n          [-105.39882655591924, 25.479181318309866],\n          [-105.45434726738569, 25.411627318309854],\n          [-105.70409839588592, 25.25161631830986],\n        ],\n      ],\n      [\n        [\n          [-106.12948574382648, 26.96188181830986],\n          [-106.07741473079159, 26.812798318309866],\n          [-105.95781505204707, 26.748550318309867],\n          [-105.89969049073602, 26.780132818309863],\n          [-105.85535948600159, 26.76707231830986],\n          [-105.88848007156639, 26.478152818309866],\n          [-105.81685446816806, 26.448578818309862],\n          [-105.54119874286357, 26.523715318309865],\n          [-105.42119221780342, 26.522222818309864],\n          [-105.19421119770203, 26.628034318309858],\n          [-105.1464927521539, 26.697305818309857],\n          [-105.1479655567631, 26.774255818309854],\n          [-105.22481097438867, 26.796748318309856],\n          [-105.38612834141509, 26.91890081830986],\n          [-105.43465475582002, 26.98769531830986],\n          [-105.56569637466987, 27.000613318309856],\n          [-105.81253870992253, 26.92823681830987],\n          [-105.87520235947693, 27.105188818309866],\n          [-105.95450182345559, 27.122627818309862],\n          [-106.07074763534115, 27.051331318309856],\n          [-106.12948574382648, 26.96188181830986],\n        ],\n      ],\n      [\n        [\n          [-106.26500385364164, 26.420801818309865],\n          [-106.32611361105057, 26.379614818309857],\n          [-106.2894856754333, 26.338045318309863],\n          [-106.08465366443977, 26.37240431830985],\n          [-106.0640210422522, 26.45111081830986],\n          [-106.08797909227519, 26.488280818309867],\n          [-106.26500385364164, 26.420801818309865],\n        ],\n      ],\n      [\n        [\n          [-106.67206650899425, 26.95104881830986],\n          [-106.6873714878177, 26.90788931830986],\n          [-106.61477297142841, 26.820842818309867],\n          [-106.6383870557139, 26.744791318309865],\n          [-106.62453700158454, 26.683558318309863],\n          [-106.41552673236328, 26.727800818309866],\n          [-106.34284288111968, 26.811532318309858],\n          [-106.40247833141177, 26.922956818309856],\n          [-106.48364519658372, 26.968849318309864],\n          [-106.5901027113996, 26.97557381830986],\n          [-106.67206650899425, 26.95104881830986],\n        ],\n      ],\n      [\n        [\n          [-106.8743512794174, 27.318584818309862],\n          [-106.95385906910991, 27.233378818309863],\n          [-106.87365102641508, 27.212443318309862],\n          [-106.60839510156171, 27.23390231830986],\n          [-106.329971986028, 27.154888318309858],\n          [-106.20841720535509, 27.18158081830986],\n          [-106.09137759463795, 27.247942318309864],\n          [-106.02160452204271, 27.31892081830987],\n          [-106.06224098311128, 27.34525931830986],\n          [-106.32955113075946, 27.334470268309868],\n          [-106.37476177712728, 27.39913481830986],\n          [-106.50153299140214, 27.367301818309862],\n          [-106.81478829708749, 27.41946431830987],\n          [-106.8196443467553, 27.357539818309863],\n          [-106.8743512794174, 27.318584818309862],\n        ],\n      ],\n      [\n        [\n          [-108.08537911421956, 27.956647318309855],\n          [-108.15636510038496, 27.949121818309855],\n          [-108.1156589928778, 27.866723818309865],\n          [-108.13756652906989, 27.81233831830986],\n          [-108.09224078139147, 27.726047818309866],\n          [-108.10058365361573, 27.68738831830986],\n          [-108.05814130288644, 27.64163831830986],\n          [-108.04214174918206, 27.527788318309856],\n          [-107.84997603965871, 27.554785318309857],\n          [-107.71746916811958, 27.540688318309865],\n          [-107.62212128030012, 27.467488318309854],\n          [-107.53293144170925, 27.497938318309867],\n          [-107.45448649656424, 27.476938318309855],\n          [-107.3634024933304, 27.54485876830986],\n          [-107.42101311573185, 27.618688318309857],\n          [-107.38596655759613, 27.76977581830987],\n          [-107.44801920449714, 27.772940818309863],\n          [-107.53317700821418, 27.74138831830986],\n          [-107.56667011614633, 27.781058818309862],\n          [-107.52039554540318, 27.87585581830987],\n          [-107.62047543510062, 28.149994318309865],\n          [-107.76605754930574, 28.087760818309864],\n          [-107.92373977521368, 27.96104681830986],\n          [-108.08537911421956, 27.956647318309855],\n        ],\n      ],\n      [\n        [\n          [-110.1564241170338, 28.67828381830987],\n          [-110.18617122941907, 28.60913981830986],\n          [-110.16065456471978, 28.547596318309864],\n          [-110.02674980080172, 28.481710318309865],\n          [-109.97949443038658, 28.419310318309854],\n          [-109.7542536177283, 28.383878818309864],\n          [-109.5482735829072, 28.507697818309857],\n          [-109.49386328381894, 28.64348531830986],\n          [-109.38664612754872, 28.765378318309864],\n          [-109.38223762993277, 28.855561318309856],\n          [-109.4901978226747, 28.92984281830987],\n          [-109.54119835349013, 28.910960818309853],\n          [-109.62045020399529, 28.925206318309865],\n          [-109.66924404207424, 28.886260318309873],\n          [-109.76383456845343, 28.916170318309863],\n          [-110.03502542064291, 28.790867818309852],\n          [-110.08058661800197, 28.727200318309865],\n          [-110.1564241170338, 28.67828381830987],\n        ],\n      ],\n      [\n        [\n          [-110.99232788883813, 28.30365581830986],\n          [-110.94569224533905, 28.25021531830986],\n          [-110.82337922274428, 28.38283331830986],\n          [-110.6924098319239, 28.425058318309862],\n          [-110.68559015283807, 28.471880818309852],\n          [-110.60424702528303, 28.55252831830987],\n          [-110.60703136258246, 28.57550831830986],\n          [-110.68912028625044, 28.573805818309864],\n          [-110.75104143207164, 28.503886318309867],\n          [-110.85081915407153, 28.46451731830986],\n          [-110.92144004514194, 28.414613818309856],\n          [-110.99232788883813, 28.30365581830986],\n        ],\n      ],\n    ],\n  },\n};\n\nexport const rawHawaiiTopology = {\n  type: \"Feature\",\n  properties: {\n    name: \"Hawaii\",\n  },\n  geometry: {\n    type: \"MultiPolygon\",\n    coordinates: [\n      [\n        [\n          [-156.049651, 19.780452],\n          [-156.064364, 19.730766],\n          [-156.033326, 19.66923],\n          [-156.028982, 19.650098],\n          [-155.997728, 19.642816],\n          [-155.978206, 19.608159],\n          [-155.96935, 19.555963],\n          [-155.95149, 19.486649],\n          [-155.924732, 19.45391],\n          [-155.909087, 19.415455],\n          [-155.888701, 19.348031],\n          [-155.890842, 19.298905],\n          [-155.902565, 19.258427],\n          [-155.912069, 19.179114],\n          [-155.914216, 19.099147],\n          [-155.88155, 19.036644],\n          [-155.806109, 19.013967],\n          [-155.726043, 18.969437],\n          [-155.672005, 18.917466],\n          [-155.638054, 18.941723],\n          [-155.613966, 18.970399],\n          [-155.590697, 19.007673],\n          [-155.555326, 19.069377],\n          [-155.505281, 19.137908],\n          [-155.453516, 19.151952],\n          [-155.390701, 19.201171],\n          [-155.360631, 19.20893],\n          [-155.31337, 19.250698],\n          [-155.264619, 19.274213],\n          [-155.205892, 19.260907],\n          [-155.159635, 19.268375],\n          [-155.113272, 19.290613],\n          [-155.020537, 19.331317],\n          [-154.944185, 19.381852],\n          [-154.876618, 19.433223],\n          [-154.816009, 19.500648],\n          [-154.814417, 19.53009],\n          [-154.852618, 19.549172],\n          [-154.947106, 19.604856],\n          [-154.974342, 19.633201],\n          [-154.981102, 19.690687],\n          [-155.006423, 19.739286],\n          [-155.045382, 19.739824],\n          [-155.087118, 19.728013],\n          [-155.091216, 19.776368],\n          [-155.086341, 19.855399],\n          [-155.124618, 19.897288],\n          [-155.166625, 19.93789],\n          [-155.270316, 20.014525],\n          [-155.387578, 20.067119],\n          [-155.502561, 20.114155],\n          [-155.558933, 20.13157],\n          [-155.598033, 20.124539],\n          [-155.637459, 20.153051],\n          [-155.704331, 20.191695],\n          [-155.737004, 20.222773],\n          [-155.798884, 20.254115],\n          [-155.853293, 20.271548],\n          [-155.890663, 20.25524],\n          [-155.90278, 20.177073],\n          [-155.890646, 20.123576],\n          [-155.850385, 20.062506],\n          [-155.825473, 20.025944],\n          [-155.831948, 19.982775],\n          [-155.856588, 19.968885],\n          [-155.892533, 19.932162],\n          [-155.915662, 19.887126],\n          [-155.949251, 19.857034],\n          [-155.976651, 19.85053],\n          [-156.006267, 19.81758],\n          [-156.049651, 19.780452],\n        ],\n      ],\n      [\n        [\n          [-156.69989, 20.920629],\n          [-156.687804, 20.89072],\n          [-156.631794, 20.82124],\n          [-156.554617, 20.786096],\n          [-156.537752, 20.778408],\n          [-156.506026, 20.799463],\n          [-156.473562, 20.790756],\n          [-156.462242, 20.753952],\n          [-156.458438, 20.736676],\n          [-156.443673, 20.656018],\n          [-156.431872, 20.598143],\n          [-156.377633, 20.578427],\n          [-156.284391, 20.596488],\n          [-156.210258, 20.628518],\n          [-156.129898, 20.627523],\n          [-156.043786, 20.664902],\n          [-156.00187, 20.698064],\n          [-155.985413, 20.744245],\n          [-156.003532, 20.795545],\n          [-156.059788, 20.81054],\n          [-156.132669, 20.861369],\n          [-156.19471, 20.891975],\n          [-156.242555, 20.937838],\n          [-156.332817, 20.94645],\n          [-156.403304, 20.915826],\n          [-156.481055, 20.898199],\n          [-156.518707, 20.954662],\n          [-156.562773, 21.016167],\n          [-156.619581, 21.027793],\n          [-156.680905, 20.980262],\n          [-156.69989, 20.920629],\n        ],\n      ],\n      [\n        [\n          [-156.670469, 20.559909],\n          [-156.702265, 20.532451],\n          [-156.668809, 20.504738],\n          [-156.586238, 20.511711],\n          [-156.539643, 20.527644],\n          [-156.543034, 20.580115],\n          [-156.56714, 20.604895],\n          [-156.610734, 20.59377],\n          [-156.670469, 20.559909],\n        ],\n      ],\n      [\n        [\n          [-157.05913, 20.913407],\n          [-157.059663, 20.884634],\n          [-157.010911, 20.854476],\n          [-156.991834, 20.826603],\n          [-156.990678, 20.775902],\n          [-156.96789, 20.73508],\n          [-156.909081, 20.739533],\n          [-156.890295, 20.744855],\n          [-156.838321, 20.764575],\n          [-156.808469, 20.820396],\n          [-156.837047, 20.863575],\n          [-156.873125, 20.894679],\n          [-156.937529, 20.925274],\n          [-157.010001, 20.929757],\n          [-157.05913, 20.913407],\n        ],\n      ],\n      [\n        [\n          [-157.27722, 21.158431],\n          [-157.310748, 21.101627],\n          [-157.252534, 21.08767],\n          [-157.171606, 21.090701],\n          [-157.08066, 21.101976],\n          [-157.02617, 21.089015],\n          [-156.953872, 21.066128],\n          [-156.877137, 21.0493],\n          [-156.8022, 21.067095],\n          [-156.739342, 21.111336],\n          [-156.709106, 21.158655],\n          [-156.742231, 21.176214],\n          [-156.841592, 21.167926],\n          [-156.9178596, 21.1690213],\n          [-156.921108, 21.169068],\n          [-156.962847, 21.212131],\n          [-156.984032, 21.212198],\n          [-157.0142679, 21.2006943],\n          [-157.039987, 21.190909],\n          [-157.128207, 21.201488],\n          [-157.202125, 21.219298],\n          [-157.26069, 21.225684],\n          [-157.249695, 21.184401],\n          [-157.27722, 21.158431],\n        ],\n      ],\n      [\n        [\n          [-158.232192, 21.583806],\n          [-158.277679, 21.578789],\n          [-158.231171, 21.523857],\n          [-158.233, 21.4876],\n          [-158.182648, 21.430073],\n          [-158.1792, 21.4043],\n          [-158.1403, 21.3738],\n          [-158.1309314, 21.3489558],\n          [-158.129371, 21.344818],\n          [-158.1033, 21.2979],\n          [-158.0883, 21.2988],\n          [-158.0245, 21.3093],\n          [-157.981525, 21.315898],\n          [-157.950736, 21.312509],\n          [-157.89, 21.3065],\n          [-157.851048, 21.28453],\n          [-157.8096, 21.2577],\n          [-157.779944, 21.265252],\n          [-157.7572, 21.278],\n          [-157.7001, 21.264],\n          [-157.673069, 21.284196],\n          [-157.6551079, 21.3092803],\n          [-157.6518, 21.3139],\n          [-157.7106, 21.3585],\n          [-157.724324, 21.403311],\n          [-157.722506, 21.459225],\n          [-157.764572, 21.461335],\n          [-157.8139, 21.4403],\n          [-157.84549, 21.466747],\n          [-157.836945, 21.529945],\n          [-157.87735, 21.575277],\n          [-157.924591, 21.651183],\n          [-157.968628, 21.712704],\n          [-157.9923, 21.708],\n          [-158.050692, 21.671215],\n          [-158.079895, 21.628101],\n          [-158.12561, 21.586739],\n          [-158.232192, 21.583806],\n        ],\n      ],\n      [\n        [\n          [-159.783746, 22.064897],\n          [-159.786702, 22.018801],\n          [-159.754795, 21.977772],\n          [-159.707795, 21.961229],\n          [-159.649766, 21.933848],\n          [-159.603279, 21.892248],\n          [-159.574521, 21.892806],\n          [-159.526918, 21.883886],\n          [-159.444868, 21.868627],\n          [-159.385271, 21.912439],\n          [-159.33768, 21.951173],\n          [-159.332564, 21.999352],\n          [-159.334489, 22.041698],\n          [-159.31828, 22.061417],\n          [-159.293013, 22.12296],\n          [-159.312293, 22.183082],\n          [-159.361507, 22.214092],\n          [-159.402466, 22.232603],\n          [-159.431707, 22.220015],\n          [-159.487939, 22.229512],\n          [-159.510756, 22.203548],\n          [-159.543924, 22.221695],\n          [-159.581058, 22.223488],\n          [-159.61165, 22.201388],\n          [-159.705531, 22.159321],\n          [-159.730544, 22.139953],\n          [-159.745247, 22.097508],\n          [-159.783746, 22.064897],\n        ],\n      ],\n      [\n        [\n          [-160.24961, 21.815145],\n          [-160.230373, 21.789675],\n          [-160.205851, 21.779518],\n          [-160.189782, 21.82245],\n          [-160.174796, 21.846923],\n          [-160.156092, 21.86793],\n          [-160.124283, 21.876789],\n          [-160.079065, 21.89608],\n          [-160.085787, 21.927295],\n          [-160.070292, 21.963951],\n          [-160.051128, 21.98106],\n          [-160.058543, 21.99638],\n          [-160.072123, 22.003334],\n          [-160.112746, 21.995245],\n          [-160.122262, 21.962881],\n          [-160.13705, 21.948632],\n          [-160.193959, 21.922386],\n          [-160.228965, 21.889117],\n          [-160.24961, 21.815145],\n        ],\n      ],\n    ],\n  },\n};\n","export const processedAlaskaTopology = {\n  type: \"Feature\",\n  properties: {\n    name: \"Alaska\",\n  },\n  geometry: {\n    type: \"MultiPolygon\",\n    coordinates: [\n      [\n        [\n          [-122.7926886429708, 20.148124827090204],\n          [-122.73342925165485, 20.131405920916723],\n          [-122.75745021977383, 20.17904909838047],\n          [-122.7926886429708, 20.148124827090204],\n        ],\n      ],\n      [\n        [\n          [-122.99250039142089, 19.956898993535294],\n          [-122.84420089151422, 19.841417459721914],\n          [-122.792609815177, 19.86484231387806],\n          [-122.99250039142089, 19.956898993535294],\n        ],\n      ],\n      [\n        [\n          [-123.02313421964743, 20.104441675096734],\n          [-123.0144348107421, 20.065435473881923],\n          [-122.994171978581, 20.0943529264347],\n          [-123.02313421964743, 20.104441675096734],\n        ],\n      ],\n      [\n        [\n          [-123.08206306798922, 20.01904215984973],\n          [-123.04374923122015, 19.988796096613253],\n          [-123.05367611453369, 20.027877316867272],\n          [-123.08206306798922, 20.01904215984973],\n        ],\n      ],\n      [\n        [\n          [-123.1066441957094, 20.117686532237585],\n          [-123.1006695175559, 20.082761999607442],\n          [-123.08253884015744, 20.093212148384506],\n          [-123.1066441957094, 20.117686532237585],\n        ],\n      ],\n      [\n        [\n          [-123.30632565438282, 20.012310506219837],\n          [-123.21850731989173, 20.032063172020475],\n          [-123.20101969494323, 20.114571229685644],\n          [-123.30632565438282, 20.012310506219837],\n        ],\n      ],\n      [\n        [\n          [-124.05573456261743, 20.255607538913612],\n          [-124.06620448573335, 20.23820251180781],\n          [-123.99047641535293, 20.229550472679545],\n          [-124.05573456261743, 20.255607538913612],\n        ],\n      ],\n      [\n        [\n          [-124.1548565212961, 20.084984103342343],\n          [-124.10816366370977, 20.04207946654677],\n          [-124.07924884087413, 20.119501945955527],\n          [-124.1548565212961, 20.084984103342343],\n        ],\n      ],\n      [\n        [\n          [-124.36952551514105, 20.263343147888445],\n          [-124.27207237164424, 20.194819909308453],\n          [-124.1543011003863, 20.251269599445543],\n          [-124.36952551514105, 20.263343147888445],\n        ],\n      ],\n      [\n        [\n          [-112.3998142680436, 24.17642325037664],\n          [-112.28211880509906, 23.878308324079025],\n          [-112.12118759458087, 23.729587212600244],\n          [-111.89635332782444, 23.721806399501364],\n          [-111.95483501009141, 23.979313440017748],\n          [-112.20075342784224, 24.357703769869165],\n          [-112.36118642705281, 24.371218694881772],\n          [-112.3998142680436, 24.17642325037664],\n        ],\n      ],\n      [\n        [\n          [-112.55666854674035, 24.57720663570464],\n          [-112.48018521665409, 24.162092674496744],\n          [-112.40192443002655, 24.392405479322985],\n          [-112.15365647813462, 24.51406159062138],\n          [-112.32512941577716, 24.689323363053543],\n          [-112.55666854674035, 24.57720663570464],\n        ],\n      ],\n      [\n        [\n          [-112.767715788028, 25.240640443244324],\n          [-112.62431793238392, 24.675906636708184],\n          [-112.49050057693404, 24.79263157018713],\n          [-112.52877771211763, 25.065874427029787],\n          [-112.767715788028, 25.240640443244324],\n        ],\n      ],\n      [\n        [\n          [-113.10159766297687, 25.001284278742233],\n          [-112.58112757954115, 24.333530907501512],\n          [-112.74569268283756, 25.07665641164485],\n          [-112.99738561343031, 25.134211464229484],\n          [-113.10159766297687, 25.001284278742233],\n        ],\n      ],\n      [\n        [\n          [-116.56777067266773, 25.372080578021556],\n          [-116.5310867438032, 25.390394584514176],\n          [-116.54560895752809, 25.4198290794845],\n          [-116.56777067266773, 25.372080578021556],\n        ],\n      ],\n      [\n        [\n          [-116.87873841076447, 24.83162771900214],\n          [-116.83191616629642, 24.815600858931923],\n          [-116.8391740527843, 24.85298490747943],\n          [-116.87873841076447, 24.83162771900214],\n        ],\n      ],\n      [\n        [\n          [-117.09432944180003, 23.854137592351588],\n          [-116.88612571458538, 23.623532196939735],\n          [-116.55224237749866, 23.957544127256632],\n          [-116.5395491515053, 24.167174266583483],\n          [-116.63577149336629, 24.20555744232377],\n          [-116.6167892923288, 24.290340138012848],\n          [-116.45895469929474, 24.37766471697998],\n          [-116.63628974580018, 24.528772429776815],\n          [-117.09432944180003, 23.854137592351588],\n        ],\n      ],\n      [\n        [\n          [-117.08524242962187, 23.419594244629103],\n          [-116.87678087225572, 23.51591594833026],\n          [-117.01745308870113, 23.518687247543326],\n          [-117.08524242962187, 23.419594244629103],\n        ],\n      ],\n      [\n        [\n          [-117.27259737622586, 23.10383247833345],\n          [-117.23566721895497, 23.08390471052284],\n          [-117.22598522279736, 23.15539289534735],\n          [-117.27259737622586, 23.10383247833345],\n        ],\n      ],\n      [\n        [\n          [-117.49754493618912, 23.174251075797056],\n          [-117.48412399643121, 23.138666680296176],\n          [-117.47083796073031, 23.174172709179633],\n          [-117.49754493618912, 23.174251075797056],\n        ],\n      ],\n      [\n        [\n          [-117.63127872796593, 23.37140265132634],\n          [-117.63870928052455, 23.350966653395954],\n          [-117.56138218321382, 23.374370774600976],\n          [-117.63127872796593, 23.37140265132634],\n        ],\n      ],\n      [\n        [\n          [-118.257551826542, 22.475628165371802],\n          [-118.04544648451815, 22.498745192648318],\n          [-118.09232796818412, 22.63793840524038],\n          [-118.257551826542, 22.475628165371802],\n        ],\n      ],\n      [\n        [\n          [-118.40025488177304, 22.632492074519472],\n          [-118.32273689272233, 22.561830815176457],\n          [-118.2446036969784, 22.692776046083477],\n          [-118.40025488177304, 22.632492074519472],\n        ],\n      ],\n      [\n        [\n          [-118.49429501567477, 24.144676712310247],\n          [-118.46805615064653, 24.11240574015076],\n          [-118.40871489637317, 24.229540183477578],\n          [-118.49429501567477, 24.144676712310247],\n        ],\n      ],\n      [\n        [\n          [-118.52550771892135, 22.558832377733975],\n          [-118.50620250443728, 22.536113013958833],\n          [-118.50409824091349, 22.564695608270146],\n          [-118.52550771892135, 22.558832377733975],\n        ],\n      ],\n      [\n        [\n          [-118.5865877585444, 22.56091811369411],\n          [-118.55530026859964, 22.548111661646573],\n          [-118.54821373449738, 22.579461946714055],\n          [-118.5865877585444, 22.56091811369411],\n        ],\n      ],\n      [\n        [\n          [-118.83051074575508, 22.16783075287409],\n          [-118.80922389593616, 22.108491705574245],\n          [-118.71653533280954, 22.141665316204325],\n          [-118.83051074575508, 22.16783075287409],\n        ],\n      ],\n      [\n        [\n          [-119.44206445249068, 21.822727471649866],\n          [-119.29714269336012, 21.860856792151097],\n          [-119.25640162320104, 21.944478224327707],\n          [-119.44206445249068, 21.822727471649866],\n        ],\n      ],\n      [\n        [\n          [-119.54714498632268, 21.86498061884192],\n          [-119.54183705052935, 21.800975583207443],\n          [-119.39517828687826, 21.90272162517402],\n          [-119.54714498632268, 21.86498061884192],\n        ],\n      ],\n      [\n        [\n          [-119.86848227420734, 24.576437704086796],\n          [-119.5814197084066, 24.442349510538047],\n          [-119.47292700533336, 24.52633699368084],\n          [-119.53574069829403, 24.714248964627757],\n          [-119.86848227420734, 24.576437704086796],\n        ],\n      ],\n      [\n        [\n          [-119.9249089967791, 21.391666302622973],\n          [-119.55026969386171, 21.698751009984207],\n          [-119.72823093613869, 21.735618507092127],\n          [-119.9249089967791, 21.391666302622973],\n        ],\n      ],\n      [\n        [\n          [-119.91265352240941, 27.09158174406807],\n          [-119.57775350009905, 27.005801622480348],\n          [-119.67386957674177, 26.9023702357688],\n          [-119.58870257341846, 26.69474725777626],\n          [-119.30227476181528, 26.654155412857207],\n          [-118.87522972766965, 26.793511069634953],\n          [-118.84261234648397, 26.703800834601836],\n          [-118.45847166181625, 27.00980727304337],\n          [-118.43133160427317, 26.92168214724123],\n          [-118.57200422780761, 26.84025343678672],\n          [-118.4326967056997, 26.556238708325786],\n          [-118.49876995517559, 26.41909909126295],\n          [-118.81363028942485, 26.38255339338515],\n          [-118.76630654961383, 26.31342647339211],\n          [-118.97174983930131, 26.078067637662794],\n          [-119.20543551378546, 26.105330309212384],\n          [-119.58389640364737, 25.244978458804407],\n          [-119.38586590563159, 25.118841139713663],\n          [-119.34697813152405, 24.93956318742995],\n          [-119.43558803922309, 24.831187395359425],\n          [-119.34286719887473, 24.846882062216245],\n          [-119.16112501948436, 24.563118976553568],\n          [-118.75126945449256, 24.746815529028115],\n          [-118.63568997334562, 24.50995781256225],\n          [-118.69771930379716, 24.426425942170454],\n          [-118.6516706209203, 24.100722576638425],\n          [-118.33276306481594, 24.3796056444448],\n          [-118.05268848005323, 24.13973077967251],\n          [-117.99398351606777, 24.145137335923728],\n          [-117.99379334114701, 24.355821700328217],\n          [-117.60731404776988, 24.42456243977783],\n          [-117.71962569453603, 24.188803199507518],\n          [-117.74466653671624, 23.851236383546595],\n          [-117.95773160693767, 23.408109787544547],\n          [-118.3122159530148, 23.095087152961394],\n          [-118.33248678223595, 22.901290881069833],\n          [-118.60058847530621, 22.86054943441951],\n          [-118.96871749095885, 22.34374965856158],\n          [-119.19313814304877, 22.286051845327382],\n          [-119.28475168495464, 22.121942084016336],\n          [-119.2545392277982, 22.023933408202453],\n          [-118.58211889524989, 22.483040434641772],\n          [-118.62397898565416, 22.561221965685096],\n          [-118.56824231016105, 22.736143628901683],\n          [-118.4895650455253, 22.630818262557117],\n          [-117.87314878544231, 23.05636233087007],\n          [-117.84135823658607, 23.28084278952079],\n          [-116.97374985457293, 24.269204824799758],\n          [-116.82537865111641, 24.641858729039694],\n          [-116.99083758819108, 24.762304144478485],\n          [-116.69518144491565, 25.116235235472708],\n          [-116.50359415211392, 25.610150487497098],\n          [-116.25722008839188, 25.830216920264416],\n          [-116.07628878908105, 25.748941131268385],\n          [-116.40232249010313, 25.56936203665847],\n          [-116.48378299211805, 25.052657628234066],\n          [-116.36518650655506, 25.051749798902115],\n          [-116.52300825273079, 24.88705143498417],\n          [-116.49553973413128, 24.800261991685314],\n          [-116.16304275689492, 24.999414502308714],\n          [-115.99650887957375, 25.255117878566796],\n          [-115.64699882025326, 25.26394442424025],\n          [-115.25738948043409, 25.632777124981775],\n          [-113.8542584416004, 25.665761176511907],\n          [-113.87474505125448, 25.570344932873],\n          [-113.79362400881877, 25.47499274376388],\n          [-113.11736529856114, 25.082053083178657],\n          [-112.59638111495718, 25.18153688381942],\n          [-112.36742132919011, 24.752466514459297],\n          [-112.14093538656965, 24.61513268686305],\n          [-112.10566958624861, 24.533779607601293],\n          [-112.23101958586017, 24.40743845548205],\n          [-112.00360782579776, 24.258896098372972],\n          [-111.81237609518018, 23.845092945708515],\n          [-111.58140576804607, 23.805519150148292],\n          [-111.47396461959875, 24.06930096812232],\n          [-111.55196208063421, 24.444293076324332],\n          [-111.9703728919057, 24.579472265161815],\n          [-112.50140661330033, 25.389838530563154],\n          [-112.95443390431916, 25.843309427485547],\n          [-113.34015164074606, 25.353495731980036],\n          [-113.73993627957441, 25.770728688816646],\n          [-113.76211319830429, 25.915877217149234],\n          [-114.17684125941025, 25.821157926221666],\n          [-114.4674954007902, 30.058603182302807],\n          [-114.92000596533842, 30.198494619521185],\n          [-115.2329101248647, 30.048472714348666],\n          [-116.11642404047836, 30.122319499829015],\n          [-116.55613179488483, 29.99422167628973],\n          [-116.68169464565437, 30.1632423042783],\n          [-117.00952268786364, 30.0587650795822],\n          [-117.15767550869339, 30.18892186883472],\n          [-117.31552630373727, 30.02034990423595],\n          [-117.36062246319005, 30.051390806535952],\n          [-117.2716808257232, 30.138483342089845],\n          [-117.50851485587941, 30.19098002268101],\n          [-117.70370029098274, 29.961162790596294],\n          [-118.51085523685276, 29.542565438282924],\n          [-118.74484072507744, 29.26143880726765],\n          [-118.88552489652596, 28.90838633225396],\n          [-119.4140220780115, 28.682999627104564],\n          [-119.55739985027878, 28.40546918539004],\n          [-119.07076292198656, 28.189576158340657],\n          [-118.98098101194222, 28.004103985279876],\n          [-118.46775239459947, 27.697365543116497],\n          [-119.00112904819855, 27.468300027762268],\n          [-119.04289473110691, 27.520114812560596],\n          [-118.97075062501915, 27.70499906028542],\n          [-119.12985936208906, 27.682577774435853],\n          [-119.91265352240941, 27.09158174406807],\n        ],\n      ],\n      [\n        [\n          [-120.25557893424866, 21.06635194893392],\n          [-119.93716549162576, 21.412618618081456],\n          [-120.02808637018944, 21.455835197045527],\n          [-120.25557893424866, 21.06635194893392],\n        ],\n      ],\n      [\n        [\n          [-120.40001478272552, 22.81584883029637],\n          [-120.37074114275748, 22.77863218954447],\n          [-120.3196203074649, 22.809874671989384],\n          [-120.40001478272552, 22.81584883029637],\n        ],\n      ],\n      [\n        [\n          [-120.45552486827194, 21.023698265833357],\n          [-120.34987457401189, 21.04267139342526],\n          [-120.34750233241823, 21.162492294968555],\n          [-120.45552486827194, 21.023698265833357],\n        ],\n      ],\n      [\n        [\n          [-120.53177137135572, 23.055872356615797],\n          [-120.50260334009988, 23.02285507770324],\n          [-120.46904320481201, 23.054570449073346],\n          [-120.53177137135572, 23.055872356615797],\n        ],\n      ],\n      [\n        [\n          [-120.60027369388712, 20.92398965613366],\n          [-120.59255031118278, 20.881214291887122],\n          [-120.53609425216723, 20.95792729751363],\n          [-120.60027369388712, 20.92398965613366],\n        ],\n      ],\n      [\n        [\n          [-120.71071841857571, 20.83431482126511],\n          [-120.69062311156301, 20.811209997474116],\n          [-120.68437756051367, 20.84300519896518],\n          [-120.71071841857571, 20.83431482126511],\n        ],\n      ],\n      [\n        [\n          [-120.73807825525381, 25.951492866015975],\n          [-120.28054924770879, 25.775464287051925],\n          [-120.10479060338628, 25.92386908651319],\n          [-120.40918321722211, 26.071826545487646],\n          [-120.71220585390631, 26.057850841335693],\n          [-120.73807825525381, 25.951492866015975],\n        ],\n      ],\n      [\n        [\n          [-121.00322948139103, 20.685340060512395],\n          [-120.93302174690507, 20.711069573167762],\n          [-120.96684507192828, 20.732281955195724],\n          [-121.00322948139103, 20.685340060512395],\n        ],\n      ],\n      [\n        [\n          [-121.06842057392294, 24.558128282376558],\n          [-121.06999794635101, 24.46426119094211],\n          [-120.89666016429408, 24.4240586570819],\n          [-121.06842057392294, 24.558128282376558],\n        ],\n      ],\n      [\n        [\n          [-121.61079858876042, 20.438903042940755],\n          [-121.07742940715599, 20.577150710815225],\n          [-121.29363684042534, 20.545914702843884],\n          [-121.33364920897407, 20.653233860276263],\n          [-121.61079858876042, 20.438903042940755],\n        ],\n      ],\n      [\n        [\n          [-121.98274780574764, 20.188330922775798],\n          [-121.63822800780474, 20.394472650016933],\n          [-121.78210767811049, 20.427116744825227],\n          [-121.98274780574764, 20.188330922775798],\n        ],\n      ],\n      [\n        [\n          [-122.14647603684779, 20.179431708097002],\n          [-122.01812324794764, 20.195841899922],\n          [-122.01777516696689, 20.29630573059612],\n          [-122.14647603684779, 20.179431708097002],\n        ],\n      ],\n      [\n        [\n          [-122.26657921071478, 20.228721883118705],\n          [-122.20015142291044, 20.099963943552723],\n          [-122.16586185174111, 20.18891127954657],\n          [-122.26657921071478, 20.228721883118705],\n        ],\n      ],\n      [\n        [\n          [-122.4226846062308, 20.03998756811677],\n          [-122.3534895953643, 20.051841253197676],\n          [-122.37489286016017, 20.0760321040194],\n          [-122.4226846062308, 20.03998756811677],\n        ],\n      ],\n      [\n        [\n          [-122.42053257814649, 20.16438847431099],\n          [-122.40116476293849, 20.126002905416286],\n          [-122.39852576241867, 20.175426473502977],\n          [-122.42053257814649, 20.16438847431099],\n        ],\n      ],\n      [\n        [\n          [-122.48650818616852, 19.891343872718856],\n          [-122.4263654792743, 19.932766028298474],\n          [-122.44633659142414, 19.962707388305827],\n          [-122.48650818616852, 19.891343872718856],\n        ],\n      ],\n    ],\n  },\n};\n\nexport const rawAlaskaTopology = {\n  type: \"Feature\",\n  properties: {\n    name: \"Alaska\",\n  },\n  geometry: {\n    type: \"MultiPolygon\",\n    coordinates: [\n      [\n        [\n          [179.481318, 51.975301],\n          [179.484634, 51.921268],\n          [179.543516, 51.890926],\n          [179.649484, 51.87367],\n          [179.743012, 51.911749],\n          [179.773922, 51.970693],\n          [179.636846, 52.025712],\n          [179.582857, 52.016841],\n          [179.481318, 51.975301],\n        ],\n      ],\n      [\n        [\n          [178.600493, 51.655256],\n          [178.604866, 51.616015],\n          [178.7724, 51.554119],\n          [178.869249, 51.556986],\n          [178.930219, 51.530089],\n          [179.031533, 51.449884],\n          [179.253271, 51.337239],\n          [179.480418, 51.36386],\n          [179.41824, 51.416195],\n          [179.295785, 51.419232],\n          [179.195247, 51.477871],\n          [178.92533, 51.623904],\n          [178.6606, 51.683065],\n          [178.600493, 51.655256],\n        ],\n      ],\n      [\n        [\n          [178.463385, 51.987849],\n          [178.432461, 51.965533],\n          [178.502493, 51.899644],\n          [178.539395, 51.903246],\n          [178.591597, 51.952652],\n          [178.552612, 51.973968],\n          [178.463385, 51.987849],\n        ],\n      ],\n      [\n        [\n          [178.204442, 51.83089],\n          [178.270955, 51.765186],\n          [178.374074, 51.747856],\n          [178.378009, 51.792626],\n          [178.329699, 51.836792],\n          [178.204442, 51.83089],\n        ],\n      ],\n      [\n        [\n          [178.093673, 52.055141],\n          [178.079214, 52.01896],\n          [178.120941, 51.977012],\n          [178.2009, 51.991156],\n          [178.201313, 52.031502],\n          [178.154769, 52.061421],\n          [178.093673, 52.055141],\n        ],\n      ],\n      [\n        [\n          [177.213086, 51.920358],\n          [177.178789, 51.879219],\n          [177.262195, 51.861891],\n          [177.311768, 51.825971],\n          [177.334229, 51.866769],\n          [177.371263, 51.901945],\n          [177.409536, 51.930821],\n          [177.49928, 51.922033],\n          [177.601005, 51.922254],\n          [177.611553, 51.950829],\n          [177.572068, 52.001812],\n          [177.609087, 52.028518],\n          [177.675952, 52.092167],\n          [177.648654, 52.1309],\n          [177.581271, 52.144927],\n          [177.521006, 52.063062],\n          [177.460539, 51.999751],\n          [177.367363, 51.968375],\n          [177.310827, 51.933273],\n          [177.213086, 51.920358],\n        ],\n      ],\n      [\n        [\n          [173.863992, 52.792483],\n          [173.819039, 52.759805],\n          [173.975116, 52.707459],\n          [174.158146, 52.706059],\n          [174.140115, 52.750737],\n          [174.067293, 52.757637],\n          [173.863992, 52.792483],\n        ],\n      ],\n      [\n        [\n          [173.439026, 52.470528],\n          [173.319948, 52.412058],\n          [173.48638, 52.368613],\n          [173.543778, 52.392666],\n          [173.651293, 52.35637],\n          [173.725696, 52.356579],\n          [173.748301, 52.392346],\n          [173.702252, 52.434804],\n          [173.772799, 52.509905],\n          [173.638061, 52.524209],\n          [173.555739, 52.479472],\n          [173.439026, 52.470528],\n        ],\n      ],\n      [\n        [\n          [172.458911, 52.954548],\n          [172.472857, 52.890234],\n          [172.585075, 52.921327],\n          [172.669943, 52.913011],\n          [172.754236, 52.87749],\n          [172.763366, 52.823656],\n          [172.809387, 52.78929],\n          [172.903628, 52.761667],\n          [172.9826, 52.79108],\n          [173.096237, 52.786782],\n          [173.166899, 52.795229],\n          [173.204948, 52.848911],\n          [173.284417, 52.827933],\n          [173.423819, 52.828799],\n          [173.425362, 52.868345],\n          [173.251326, 52.944362],\n          [173.121988, 52.990352],\n          [172.792872, 53.008568],\n          [172.643266, 53.004979],\n          [172.458911, 52.954548],\n        ],\n      ],\n      [\n        [\n          [-133.935016, 55.920689],\n          [-133.92025, 55.860295],\n          [-133.861039, 55.848844],\n          [-133.700468, 55.837421],\n          [-133.701152, 55.78516],\n          [-133.643324, 55.729037],\n          [-133.716665, 55.660223],\n          [-133.728549, 55.593128],\n          [-133.75287, 55.544282],\n          [-133.789055, 55.457892],\n          [-133.697898, 55.454759],\n          [-133.630945, 55.416114],\n          [-133.633006, 55.361299],\n          [-133.690174, 55.304409],\n          [-133.658359, 55.232674],\n          [-133.596762, 55.218233],\n          [-133.586605, 55.3088],\n          [-133.468217, 55.281678],\n          [-133.471938, 55.247527],\n          [-133.404497, 55.214992],\n          [-133.341259, 55.205701],\n          [-133.281979, 55.217117],\n          [-133.232491, 55.198828],\n          [-133.215086, 55.136876],\n          [-133.239695, 55.092415],\n          [-133.197719, 55.033404],\n          [-133.164788, 54.976909],\n          [-133.099047, 54.919007],\n          [-132.990589, 54.820994],\n          [-132.918751, 54.783253],\n          [-132.87721, 54.753772],\n          [-132.866355, 54.700386],\n          [-132.753019, 54.673244],\n          [-132.674324, 54.674652],\n          [-132.639032, 54.753251],\n          [-132.509371, 54.781258],\n          [-132.403533, 54.784596],\n          [-132.366389, 54.751197],\n          [-132.307943, 54.718714],\n          [-132.228223, 54.72517],\n          [-132.165182, 54.69405],\n          [-132.029747, 54.701189],\n          [-131.999591, 54.731975],\n          [-131.957914, 54.791239],\n          [-131.983324, 54.897813],\n          [-131.984592, 55.027978],\n          [-132.027513, 55.104675],\n          [-131.977397, 55.180949],\n          [-132.037122, 55.275144],\n          [-132.126398, 55.288418],\n          [-132.258056, 55.416142],\n          [-132.142945, 55.457941],\n          [-132.301119, 55.55096],\n          [-132.382505, 55.665336],\n          [-132.462531, 55.673854],\n          [-132.470697, 55.782162],\n          [-132.618464, 55.911476],\n          [-132.837592, 56.024327],\n          [-132.859783, 56.0527693],\n          [-132.896433, 56.099744],\n          [-132.833864, 56.103904],\n          [-132.887585, 56.172938],\n          [-132.966922, 56.224276],\n          [-133.0398774, 56.2390404],\n          [-133.07823, 56.246802],\n          [-133.158233, 56.314768],\n          [-133.197009, 56.333016],\n          [-133.41837, 56.332132],\n          [-133.582116, 56.352506],\n          [-133.656415, 56.326909],\n          [-133.656889, 56.281228],\n          [-133.6721, 56.222734],\n          [-133.643817, 56.127739],\n          [-133.659241, 56.083818],\n          [-133.7314, 56.028857],\n          [-133.816363, 55.964025],\n          [-133.935016, 55.920689],\n        ],\n      ],\n      [\n        [\n          [-134.392983, 56.864284],\n          [-134.418534, 56.822333],\n          [-134.376274, 56.668608],\n          [-134.30112, 56.620317],\n          [-134.320134, 56.554484],\n          [-134.241938, 56.555531],\n          [-134.197967, 56.531028],\n          [-134.25192, 56.44455],\n          [-134.243126, 56.395778],\n          [-134.294679, 56.335888],\n          [-134.282212, 56.254789],\n          [-134.259749, 56.13444],\n          [-134.202178, 56.035175],\n          [-134.291804, 55.926219],\n          [-134.374965, 55.928492],\n          [-134.344652, 55.846312],\n          [-134.311763, 55.812285],\n          [-134.255096, 55.844614],\n          [-134.208251, 55.876709],\n          [-134.118062, 55.914642],\n          [-134.099805, 55.98414],\n          [-134.121868, 56.029895],\n          [-134.087446, 56.094939],\n          [-134.018043, 56.088176],\n          [-133.960525, 56.091359],\n          [-133.927725, 56.145949],\n          [-133.941986, 56.180095],\n          [-133.88114, 56.223197],\n          [-133.876624, 56.275884],\n          [-133.834555, 56.319801],\n          [-133.821628, 56.391602],\n          [-133.655468, 56.442279],\n          [-133.460634, 56.45412],\n          [-133.4153789, 56.4564449],\n          [-133.300571, 56.462343],\n          [-133.183493, 56.454241],\n          [-133.041726, 56.518356],\n          [-132.933042, 56.5222],\n          [-132.806838, 56.505492],\n          [-132.671154, 56.543071],\n          [-132.611326, 56.599913],\n          [-132.619258, 56.660778],\n          [-132.743207, 56.71372],\n          [-132.796602, 56.776932],\n          [-132.903211, 56.80361],\n          [-132.98137, 56.92738],\n          [-133.104611, 57.005701],\n          [-133.317871, 57.0026747],\n          [-133.334272, 57.002442],\n          [-133.536258, 57.0387],\n          [-133.739433, 57.072184],\n          [-133.887957, 57.097744],\n          [-134.008856, 57.074578],\n          [-134.049218, 57.029203],\n          [-133.921451, 56.961511],\n          [-133.86904, 56.845938],\n          [-133.942936, 56.805551],\n          [-134.006635, 56.851587],\n          [-134.047753, 56.923],\n          [-134.147103, 56.95697],\n          [-134.193751, 56.933598],\n          [-134.270459, 56.93558],\n          [-134.392983, 56.864284],\n        ],\n      ],\n      [\n        [\n          [-134.960502, 58.403758],\n          [-134.958171, 58.322057],\n          [-134.864299, 58.180489],\n          [-134.783772, 58.082292],\n          [-134.752398, 57.938956],\n          [-134.709024, 57.780498],\n          [-134.695428, 57.685335],\n          [-134.607557, 57.513042],\n          [-134.55554, 57.407428],\n          [-134.640169, 57.239852],\n          [-134.634565, 57.109863],\n          [-134.565687, 57.023737],\n          [-134.497718, 57.031194],\n          [-134.443786, 57.062292],\n          [-134.386052, 57.087392],\n          [-134.378359, 57.115016],\n          [-134.302721, 57.136562],\n          [-134.193629, 57.184879],\n          [-134.100118, 57.266285],\n          [-133.983501, 57.302838],\n          [-133.875673, 57.267613],\n          [-133.840895, 57.271074],\n          [-133.786398, 57.311528],\n          [-133.866931, 57.367869],\n          [-133.871581, 57.484158],\n          [-133.8176, 57.568353],\n          [-133.808285, 57.609604],\n          [-133.896846, 57.685524],\n          [-133.904874, 57.807406],\n          [-133.999948, 57.91481],\n          [-134.087572, 57.996475],\n          [-134.138231, 58.047103],\n          [-134.183983, 58.077295],\n          [-134.174352, 58.125284],\n          [-134.2543861, 58.1443553],\n          [-134.256223, 58.144793],\n          [-134.329872, 58.13499],\n          [-134.46176, 58.159289],\n          [-134.608911, 58.171637],\n          [-134.699956, 58.161494],\n          [-134.7244778, 58.2114653],\n          [-134.735829, 58.234597],\n          [-134.788441, 58.28909],\n          [-134.865084, 58.357276],\n          [-134.960502, 58.403758],\n        ],\n      ],\n      [\n        [\n          [-136.563223, 58.035052],\n          [-136.573288, 57.926844],\n          [-136.484259, 57.89646],\n          [-136.458829, 57.853901],\n          [-136.372377, 57.832587],\n          [-136.3719865, 57.832232],\n          [-136.304684, 57.771051],\n          [-136.250818, 57.684831],\n          [-136.238166, 57.625991],\n          [-136.163059, 57.558861],\n          [-136.088071, 57.555291],\n          [-136.047547, 57.513762],\n          [-135.943766, 57.45878],\n          [-135.892131, 57.408048],\n          [-135.85816, 57.321358],\n          [-135.837719, 57.282068],\n          [-135.870519, 57.221639],\n          [-135.832253, 57.170647],\n          [-135.753581, 57.167168],\n          [-135.755007, 57.123972],\n          [-135.844612, 57.083568],\n          [-135.856021, 56.995636],\n          [-135.825598, 56.989032],\n          [-135.63688, 57.009874],\n          [-135.604555, 57.045834],\n          [-135.571504, 57.105697],\n          [-135.457907, 57.070165],\n          [-135.353447, 57.020905],\n          [-135.442339, 56.942355],\n          [-135.476817, 56.891232],\n          [-135.506869, 56.865978],\n          [-135.550718, 56.841228],\n          [-135.467177, 56.77141],\n          [-135.362241, 56.758742],\n          [-135.305077, 56.726382],\n          [-135.21583, 56.66534],\n          [-135.175826, 56.677876],\n          [-135.123389, 56.602823],\n          [-135.058238, 56.529453],\n          [-134.977082, 56.437294],\n          [-134.915911, 56.360555],\n          [-134.839411, 56.309403],\n          [-134.810171, 56.244987],\n          [-134.763535, 56.210363],\n          [-134.674028, 56.166925],\n          [-134.653827, 56.198385],\n          [-134.634668, 56.265832],\n          [-134.634828, 56.345297],\n          [-134.64177, 56.445479],\n          [-134.669778, 56.524129],\n          [-134.626943, 56.553868],\n          [-134.615955, 56.637289],\n          [-134.62967, 56.709596],\n          [-134.663434, 56.804687],\n          [-134.695735, 56.900791],\n          [-134.738223, 56.975741],\n          [-134.854948, 57.264766],\n          [-134.825579, 57.372143],\n          [-134.824891, 57.500067],\n          [-134.939924, 57.763612],\n          [-134.9494296, 57.7812593],\n          [-135.004952, 57.884338],\n          [-134.926395, 57.921919],\n          [-134.950844, 58.036993],\n          [-135.108896, 58.08827],\n          [-135.275797, 58.097024],\n          [-135.497911, 58.168882],\n          [-135.712398, 58.231892],\n          [-135.78338, 58.286709],\n          [-135.877468, 58.259852],\n          [-136.033678, 58.276728],\n          [-136.176442, 58.265111],\n          [-136.290349, 58.251761],\n          [-136.387113, 58.252414],\n          [-136.365544, 58.148854],\n          [-136.446286, 58.11334],\n          [-136.538708, 58.093482],\n          [-136.563223, 58.035052],\n        ],\n      ],\n      [\n        [\n          [-152.064099, 60.417137],\n          [-152.079995, 60.341191],\n          [-151.956263, 60.367841],\n          [-151.891542, 60.440177],\n          [-151.839194, 60.485862],\n          [-151.952456, 60.510609],\n          [-152.064099, 60.417137],\n        ],\n      ],\n      [\n        [\n          [-153.597411, 59.386827],\n          [-153.546695, 59.331348],\n          [-153.515286, 59.320878],\n          [-153.386898, 59.33075],\n          [-153.347772, 59.377985],\n          [-153.412493, 59.415105],\n          [-153.489005, 59.41523],\n          [-153.597411, 59.386827],\n        ],\n      ],\n      [\n        [\n          [-154.779663, 57.366335],\n          [-154.79384, 57.288862],\n          [-154.691855, 57.28411],\n          [-154.594977, 57.257161],\n          [-154.523432, 57.129106],\n          [-154.528538, 57.001892],\n          [-154.40749, 56.968334],\n          [-154.312888, 56.918673],\n          [-154.305713, 56.846871],\n          [-154.129017, 56.742168],\n          [-154.153147, 56.681697],\n          [-154.017042, 56.689311],\n          [-153.97178, 56.744861],\n          [-153.90215, 56.771208],\n          [-153.83964, 56.822099],\n          [-153.776468, 56.830315],\n          [-153.699409, 56.855382],\n          [-153.603624, 56.887336],\n          [-153.541492, 56.887875],\n          [-153.543429, 56.995245],\n          [-153.580831, 57.049048],\n          [-153.48652, 57.085915],\n          [-153.404263, 57.080511],\n          [-153.342018, 56.982825],\n          [-153.266822, 56.999643],\n          [-153.200217, 57.042039],\n          [-153.06433, 57.10379],\n          [-152.90054, 57.132076],\n          [-152.880321, 57.164798],\n          [-152.949333, 57.187346],\n          [-152.943463, 57.256956],\n          [-152.818187, 57.265368],\n          [-152.695698, 57.281318],\n          [-152.630441, 57.322668],\n          [-152.601148, 57.382165],\n          [-152.570527, 57.448909],\n          [-152.474883, 57.434204],\n          [-152.323687, 57.34266],\n          [-152.253603, 57.384019],\n          [-152.323683, 57.467861],\n          [-152.259641, 57.527156],\n          [-152.159677, 57.593614],\n          [-152.161617, 57.623287],\n          [-152.313974, 57.63642],\n          [-152.386805, 57.667923],\n          [-152.440182, 57.72664],\n          [-152.298762, 57.745925],\n          [-152.212247, 57.791433],\n          [-152.351152, 57.834768],\n          [-152.324103, 57.916604],\n          [-152.422573, 57.948662],\n          [-152.432608, 57.976029],\n          [-152.526283, 57.913266],\n          [-152.635378, 57.91861],\n          [-152.681204, 57.875675],\n          [-152.753437, 57.834452],\n          [-152.790211, 57.858058],\n          [-152.804807, 57.899175],\n          [-152.751978, 57.933466],\n          [-152.722524, 57.987364],\n          [-152.766673, 58.029887],\n          [-152.656801, 58.061049],\n          [-152.529036, 58.093779],\n          [-152.482674, 58.129813],\n          [-152.374399, 58.120014],\n          [-152.265111, 58.135732],\n          [-152.112205, 58.148559],\n          [-152.03412, 58.183737],\n          [-151.862321, 58.168265],\n          [-151.795696, 58.211096],\n          [-151.817111, 58.263444],\n          [-151.981781, 58.347971],\n          [-152.08925, 58.367644],\n          [-152.129257, 58.396414],\n          [-152.227835, 58.376424],\n          [-152.301713, 58.428697],\n          [-152.35609, 58.42347],\n          [-152.34486, 58.39163],\n          [-152.387343, 58.359499],\n          [-152.432235, 58.355221],\n          [-152.49848, 58.372351],\n          [-152.512483, 58.427349],\n          [-152.467197, 58.476609],\n          [-152.38761, 58.52287],\n          [-152.337212, 58.589095],\n          [-152.354709, 58.63828],\n          [-152.453817, 58.618515],\n          [-152.560171, 58.61968],\n          [-152.61613, 58.601852],\n          [-152.66622, 58.544087],\n          [-152.640313, 58.469868],\n          [-152.733845, 58.460662],\n          [-152.787776, 58.411313],\n          [-152.883107, 58.400443],\n          [-152.925586, 58.339686],\n          [-153.044316, 58.306336],\n          [-153.101841, 58.257938],\n          [-153.202801, 58.20808],\n          [-153.223709, 58.16212],\n          [-153.316127, 58.14039],\n          [-153.362281, 58.106786],\n          [-153.419783, 58.059638],\n          [-153.365574, 58.039052],\n          [-153.299009, 57.985626],\n          [-153.386422, 57.936526],\n          [-153.484603, 57.9765],\n          [-153.533204, 57.941117],\n          [-153.512024, 57.909156],\n          [-153.648798, 57.880103],\n          [-153.721176, 57.890615],\n          [-153.781408, 57.876417],\n          [-153.93522, 57.813047],\n          [-153.930279, 57.696791],\n          [-153.994572, 57.656905],\n          [-154.196959, 57.664639],\n          [-154.292471, 57.644223],\n          [-154.411385, 57.598452],\n          [-154.52206, 57.577786],\n          [-154.618704, 57.514972],\n          [-154.69331, 57.446085],\n          [-154.779663, 57.366335],\n        ],\n      ],\n      [\n        [\n          [-154.840415, 56.42032],\n          [-154.742887, 56.401678],\n          [-154.624282, 56.475181],\n          [-154.529507, 56.502655],\n          [-154.266332, 56.496366],\n          [-154.02093, 56.482025],\n          [-153.887678, 56.533637],\n          [-153.878764, 56.565925],\n          [-154.025041, 56.572517],\n          [-154.095833, 56.617786],\n          [-154.210336, 56.609684],\n          [-154.514078, 56.604059],\n          [-154.70614, 56.521273],\n          [-154.840415, 56.42032],\n        ],\n      ],\n      [\n        [\n          [-155.750002, 55.821849],\n          [-155.718593, 55.772356],\n          [-155.591002, 55.761725],\n          [-155.566307, 55.789488],\n          [-155.554245, 55.84646],\n          [-155.530591, 55.912213],\n          [-155.605373, 55.928826],\n          [-155.688098, 55.864886],\n          [-155.750002, 55.821849],\n        ],\n      ],\n      [\n        [\n          [-156.733628, 56.077593],\n          [-156.735292, 56.02264],\n          [-156.681814, 55.994337],\n          [-156.618202, 56.017802],\n          [-156.614757, 56.065178],\n          [-156.683003, 56.09881],\n          [-156.733628, 56.077593],\n        ],\n      ],\n      [\n        [\n          [-157.288702, 56.566039],\n          [-157.326059, 56.525169],\n          [-157.168777, 56.53021],\n          [-157.047173, 56.519931],\n          [-156.975549, 56.540446],\n          [-157.091146, 56.581134],\n          [-157.172027, 56.598039],\n          [-157.288702, 56.566039],\n        ],\n      ],\n      [\n        [\n          [-160.252749, 54.913251],\n          [-160.226967, 54.864075],\n          [-160.099295, 54.962853],\n          [-160.027035, 55.02091],\n          [-159.813625, 55.027467],\n          [-159.752779, 55.066139],\n          [-159.635226, 55.037294],\n          [-159.504434, 55.027316],\n          [-159.447982, 54.941374],\n          [-159.309681, 54.865813],\n          [-159.272354, 54.864204],\n          [-159.203228, 54.914842],\n          [-159.33847, 55.046683],\n          [-159.488766, 55.188812],\n          [-159.521096, 55.253393],\n          [-159.670305, 55.182337],\n          [-159.816419, 55.178051],\n          [-159.843859, 55.249367],\n          [-159.870591, 55.284889],\n          [-160.025257, 55.203914],\n          [-160.137102, 55.171565],\n          [-160.187261, 55.118376],\n          [-160.192058, 55.038157],\n          [-160.252749, 54.913251],\n        ],\n      ],\n      [\n        [\n          [-160.856621, 55.318488],\n          [-160.841917, 55.20444],\n          [-160.821381, 55.117851],\n          [-160.734942, 55.151311],\n          [-160.655577, 55.160261],\n          [-160.525226, 55.129871],\n          [-160.486511, 55.181951],\n          [-160.527617, 55.256374],\n          [-160.468262, 55.288925],\n          [-160.341217, 55.251799],\n          [-160.30655, 55.303275],\n          [-160.154038, 55.377518],\n          [-160.137032, 55.450709],\n          [-160.260565, 55.463674],\n          [-160.333421, 55.436928],\n          [-160.517513, 55.379378],\n          [-160.687442, 55.402198],\n          [-160.808929, 55.370122],\n          [-160.856621, 55.318488],\n        ],\n      ],\n      [\n        [\n          [-161.078486, 58.635577],\n          [-161.07563, 58.549916],\n          [-160.961416, 58.553723],\n          [-160.880515, 58.581325],\n          [-160.679309, 58.780226],\n          [-160.700627, 58.817368],\n          [-160.918586, 58.746935],\n          [-161.056595, 58.702202],\n          [-161.078486, 58.635577],\n        ],\n      ],\n      [\n        [\n          [-161.426005, 55.216563],\n          [-161.451286, 55.178027],\n          [-161.344152, 55.158504],\n          [-161.329875, 55.219418],\n          [-161.356726, 55.221262],\n          [-161.426005, 55.216563],\n        ],\n      ],\n      [\n        [\n          [-161.697129, 55.249148],\n          [-161.691553, 55.198479],\n          [-161.560207, 55.207045],\n          [-161.523434, 55.271659],\n          [-161.697129, 55.249148],\n        ],\n      ],\n      [\n        [\n          [-162.844362, 54.510428],\n          [-162.861736, 54.424771],\n          [-162.760247, 54.372193],\n          [-162.608608, 54.369147],\n          [-162.46695, 54.342692],\n          [-162.388754, 54.367623],\n          [-162.34484, 54.401336],\n          [-162.585315, 54.447995],\n          [-162.844362, 54.510428],\n        ],\n      ],\n      [\n        [\n          [-165.602225, 54.045267],\n          [-165.555768, 54.023551],\n          [-165.287665, 54.038349],\n          [-165.088283, 54.072491],\n          [-164.956139, 54.060988],\n          [-164.816166, 54.158754],\n          [-164.7637, 54.223153],\n          [-164.824183, 54.225527],\n          [-164.883134, 54.196187],\n          [-165.00791, 54.134934],\n          [-165.140978, 54.131079],\n          [-165.28077, 54.115625],\n          [-165.468221, 54.079641],\n          [-165.602225, 54.045267],\n        ],\n      ],\n      [\n        [\n          [-166.06155, 54.185092],\n          [-166.112242, 54.122528],\n          [-166.046438, 54.044186],\n          [-165.901649, 54.06287],\n          [-165.875129, 54.03642],\n          [-165.784434, 54.069435],\n          [-165.549217, 54.112196],\n          [-165.383719, 54.196731],\n          [-165.478452, 54.295333],\n          [-165.62555, 54.298964],\n          [-165.868192, 54.214884],\n          [-165.959751, 54.220982],\n          [-166.06155, 54.185092],\n        ],\n      ],\n      [\n        [\n          [-167.430619, 60.197006],\n          [-167.343509, 60.126287],\n          [-167.333289, 60.066626],\n          [-167.225739, 60.04088],\n          [-167.06578, 59.98796],\n          [-166.939572, 59.965483],\n          [-166.795194, 59.913185],\n          [-166.665528, 59.878168],\n          [-166.512819, 59.846425],\n          [-166.36213, 59.838604],\n          [-166.272168, 59.811455],\n          [-166.190406, 59.750206],\n          [-166.084282, 59.776059],\n          [-166.084995, 59.839649],\n          [-165.982317, 59.871637],\n          [-165.856822, 59.869728],\n          [-165.769832, 59.900495],\n          [-165.706609, 59.883564],\n          [-165.582302, 59.908242],\n          [-165.532633, 59.953425],\n          [-165.633879, 60.019597],\n          [-165.709223, 60.066003],\n          [-165.666679, 60.124304],\n          [-165.723484, 60.163824],\n          [-165.683554, 60.198335],\n          [-165.722533, 60.236468],\n          [-165.67987, 60.292435],\n          [-165.883086, 60.343368],\n          [-166.03734, 60.319456],\n          [-166.103296, 60.367321],\n          [-166.149763, 60.4367],\n          [-166.241032, 60.38882],\n          [-166.371874, 60.355156],\n          [-166.490358, 60.389466],\n          [-166.548589, 60.361856],\n          [-166.616566, 60.319221],\n          [-166.713539, 60.327341],\n          [-166.835825, 60.268751],\n          [-166.813127, 60.249768],\n          [-166.842599, 60.21047],\n          [-166.93866, 60.214704],\n          [-167.112841, 60.231482],\n          [-167.317602, 60.231541],\n          [-167.430619, 60.197006],\n        ],\n      ],\n      [\n        [\n          [-167.790928, 53.33552],\n          [-167.851511, 53.308668],\n          [-167.747754, 53.273564],\n          [-167.622173, 53.250362],\n          [-167.539247, 53.277864],\n          [-167.488215, 53.269121],\n          [-167.417713, 53.329856],\n          [-167.308126, 53.33433],\n          [-167.291831, 53.364102],\n          [-167.166348, 53.412793],\n          [-167.075386, 53.424979],\n          [-166.994329, 53.429201],\n          [-166.878087, 53.429884],\n          [-166.749158, 53.440944],\n          [-166.656234, 53.487119],\n          [-166.581011, 53.530449],\n          [-166.508982, 53.5838],\n          [-166.444909, 53.640646],\n          [-166.320262, 53.674276],\n          [-166.244056, 53.710708],\n          [-166.138657, 53.731082],\n          [-166.09753, 53.826933],\n          [-166.113037, 53.853716],\n          [-166.198751, 53.8361],\n          [-166.336768, 53.78709],\n          [-166.404896, 53.809345],\n          [-166.320004, 53.869527],\n          [-166.250935, 53.876851],\n          [-166.210685, 53.915922],\n          [-166.1609247, 53.9356381],\n          [-166.075283, 53.969571],\n          [-166.172365, 53.998124],\n          [-166.225644, 53.9862291],\n          [-166.264519, 53.97755],\n          [-166.357117, 54.002343],\n          [-166.437083, 53.955644],\n          [-166.508388, 53.923949],\n          [-166.587393, 53.959831],\n          [-166.644627, 54.014495],\n          [-166.742587, 54.015501],\n          [-166.879488, 53.988716],\n          [-167.031252, 53.945204],\n          [-167.140992, 53.866774],\n          [-167.141966, 53.826932],\n          [-167.098135, 53.799987],\n          [-167.005778, 53.755446],\n          [-167.041245, 53.707929],\n          [-167.071823, 53.66556],\n          [-167.107836, 53.633056],\n          [-167.16164, 53.605909],\n          [-167.135695, 53.551227],\n          [-167.188033, 53.524073],\n          [-167.278827, 53.478565],\n          [-167.369791, 53.450646],\n          [-167.457366, 53.442793],\n          [-167.591219, 53.393346],\n          [-167.694484, 53.388034],\n          [-167.790928, 53.33552],\n        ],\n      ],\n      [\n        [\n          [-168.12893, 65.655744],\n          [-168.04762, 65.569149],\n          [-167.851234, 65.538181],\n          [-167.684378, 65.489079],\n          [-167.474024, 65.412744],\n          [-167.348739, 65.397891],\n          [-167.067707, 65.385117],\n          [-166.899681, 65.360642],\n          [-166.750702, 65.333172],\n          [-166.596964, 65.336246],\n          [-166.439404, 65.319058],\n          [-166.347189, 65.276341],\n          [-166.451711, 65.236178],\n          [-166.479913, 65.167249],\n          [-166.634449, 65.125873],\n          [-166.886677, 65.138763],\n          [-166.911922, 65.125965],\n          [-166.73725, 65.027526],\n          [-166.697808, 64.991201],\n          [-166.586066, 64.955712],\n          [-166.432246, 64.88316],\n          [-166.407315, 64.852281],\n          [-166.478978, 64.797036],\n          [-166.482682, 64.755101],\n          [-166.413926, 64.651229],\n          [-166.236939, 64.583558],\n          [-165.819595, 64.540171],\n          [-165.291644, 64.480731],\n          [-165.001961, 64.433917],\n          [-164.807747, 64.449432],\n          [-164.548298, 64.516738],\n          [-164.307273, 64.561488],\n          [-164.147059, 64.564552],\n          [-163.974352, 64.55137],\n          [-163.829739, 64.574965],\n          [-163.686337, 64.568798],\n          [-163.4129, 64.524986],\n          [-163.249092, 64.456223],\n          [-163.133172, 64.381844],\n          [-163.091486, 64.437736],\n          [-163.027158, 64.477945],\n          [-163.033231, 64.519314],\n          [-162.940776, 64.542417],\n          [-162.857562, 64.49978],\n          [-162.83654, 64.436702],\n          [-162.768424, 64.333516],\n          [-162.632242, 64.385734],\n          [-162.603236, 64.479904],\n          [-162.539996, 64.530931],\n          [-162.234477, 64.619336],\n          [-162.188146, 64.672395],\n          [-162.060291, 64.692872],\n          [-161.878363, 64.709476],\n          [-161.772978, 64.749258],\n          [-161.64552, 64.776452],\n          [-161.518211, 64.75325],\n          [-161.376985, 64.773036],\n          [-161.327848, 64.829836],\n          [-161.213756, 64.883324],\n          [-161.133062, 64.898219],\n          [-161.079718, 64.869549],\n          [-160.935974, 64.82237],\n          [-160.783398, 64.71716],\n          [-160.793356, 64.619317],\n          [-160.992894, 64.541295],\n          [-161.198029, 64.496626],\n          [-161.389879, 64.547833],\n          [-161.469046, 64.506575],\n          [-161.504903, 64.423074],\n          [-161.263519, 64.398166],\n          [-161.177712, 64.343541],\n          [-160.962007, 64.220575],\n          [-160.941096, 64.066319],\n          [-160.900464, 63.99834],\n          [-160.76562, 63.828714],\n          [-160.783304, 63.752893],\n          [-161.073573, 63.5617],\n          [-161.191163, 63.490072],\n          [-161.421085, 63.46015],\n          [-161.676526, 63.465003],\n          [-161.982168, 63.446313],\n          [-162.073156, 63.513768],\n          [-162.252411, 63.541753],\n          [-162.401203, 63.634367],\n          [-162.587527, 63.625115],\n          [-162.707559, 63.577607],\n          [-162.562007, 63.537105],\n          [-162.352274, 63.454069],\n          [-162.42153, 63.409014],\n          [-162.526588, 63.316551],\n          [-162.602861, 63.2771825],\n          [-162.72408, 63.214615],\n          [-162.821122, 63.205596],\n          [-162.844559, 63.154191],\n          [-162.919727, 63.120153],\n          [-163.053996, 63.058334],\n          [-163.316203, 63.037763],\n          [-163.529938, 63.1354],\n          [-163.616272, 63.141213],\n          [-163.73265, 63.213257],\n          [-163.885059, 63.222308],\n          [-164.066991, 63.262276],\n          [-164.209475, 63.251472],\n          [-164.442368, 63.202672],\n          [-164.607425, 63.112899],\n          [-164.685213, 63.022191],\n          [-164.813007, 62.903919],\n          [-164.87564, 62.806254],\n          [-164.864367, 62.752042],\n          [-164.837703, 62.685267],\n          [-164.962432, 62.658246],\n          [-165.052202, 62.598217],\n          [-165.096155, 62.522452],\n          [-165.26927, 62.427352],\n          [-165.458499, 62.282847],\n          [-165.672037, 62.13989],\n          [-165.754295, 62.055955],\n          [-165.743528, 61.962533],\n          [-165.650103, 61.874153],\n          [-165.639516, 61.847006],\n          [-165.803979, 61.825685],\n          [-165.940864, 61.84908],\n          [-166.094312, 61.813859],\n          [-166.050997, 61.766689],\n          [-166.143757, 61.724352],\n          [-166.211787, 61.608373],\n          [-166.149577, 61.513288],\n          [-166.075398, 61.49298],\n          [-165.999535, 61.53972],\n          [-165.912496, 61.5562],\n          [-165.865668, 61.535046],\n          [-165.746352, 61.489304],\n          [-165.791085, 61.449852],\n          [-165.877104, 61.431149],\n          [-165.921194, 61.40308],\n          [-165.831365, 61.306719],\n          [-165.787442, 61.310063],\n          [-165.623317, 61.278431],\n          [-165.63288, 61.227965],\n          [-165.640289, 61.138066],\n          [-165.55514, 61.092674],\n          [-165.459236, 61.083424],\n          [-165.385437, 61.079574],\n          [-165.325552, 61.169306],\n          [-165.203757, 61.150341],\n          [-165.139403, 61.092946],\n          [-165.057842, 61.059746],\n          [-165.133937, 61.01125],\n          [-165.194945, 60.9739],\n          [-165.108495, 60.9265754],\n          [-165.08509, 60.913763],\n          [-165.030183, 60.83805],\n          [-165.040843, 60.77266],\n          [-165.010452, 60.744789],\n          [-164.991665, 60.69884],\n          [-165.073091, 60.684217],\n          [-165.206433, 60.610227],\n          [-165.367676, 60.581158],\n          [-165.420349, 60.550692],\n          [-165.362975, 60.506866],\n          [-165.274867, 60.499021],\n          [-165.190449, 60.498001],\n          [-165.093939, 60.531862],\n          [-164.986952, 60.542406],\n          [-164.956788, 60.527837],\n          [-165.015155, 60.471414],\n          [-165.069693, 60.460893],\n          [-165.129403, 60.433707],\n          [-164.984527, 60.349929],\n          [-164.777233, 60.293833],\n          [-164.698889, 60.296298],\n          [-164.619501, 60.234938],\n          [-164.517647, 60.199493],\n          [-164.411016, 60.097675],\n          [-164.272808, 60.046194],\n          [-164.13181, 59.991177],\n          [-164.178705, 59.96181],\n          [-164.208475, 59.934461],\n          [-164.133393, 59.845612],\n          [-163.930798, 59.803853],\n          [-163.772229, 59.795624],\n          [-163.458092, 59.809958],\n          [-163.172633, 59.845058],\n          [-162.929135, 59.908054],\n          [-162.808513, 59.933933],\n          [-162.737447, 59.972254],\n          [-162.622569, 59.971809],\n          [-162.515276, 59.976183],\n          [-162.487649, 60.028082],\n          [-162.495608, 60.078949],\n          [-162.49418, 60.130271],\n          [-162.45128, 60.174367],\n          [-162.37224, 60.167009],\n          [-162.228371, 60.056313],\n          [-162.143049, 59.967506],\n          [-162.108772, 59.920107],\n          [-162.046547, 59.849688],\n          [-161.88552, 59.69839],\n          [-161.873944, 59.649487],\n          [-161.772979, 59.566243],\n          [-161.70253, 59.490906],\n          [-161.790375, 59.468197],\n          [-161.848988, 59.432494],\n          [-161.992903, 59.338385],\n          [-162.048584, 59.254177],\n          [-161.996859, 59.174126],\n          [-161.910267, 59.093503],\n          [-161.804034, 58.991717],\n          [-161.764791, 58.846235],\n          [-161.824107, 58.734549],\n          [-161.994644, 58.688828],\n          [-162.171722, 58.648441],\n          [-162.027363, 58.60705],\n          [-161.802156, 58.612318],\n          [-161.751999, 58.551842],\n          [-161.550537, 58.61116],\n          [-161.372314, 58.666172],\n          [-161.3395807, 58.7393386],\n          [-161.337982, 58.742912],\n          [-161.221942, 58.777741],\n          [-161.0737484, 58.8260238],\n          [-161.031441, 58.839808],\n          [-161.001101, 58.849693],\n          [-160.872003, 58.878472],\n          [-160.823489, 58.829136],\n          [-160.730971, 58.921186],\n          [-160.516426, 59.01124],\n          [-160.31778, 59.070477],\n          [-160.256592, 58.99448],\n          [-160.322922, 58.953953],\n          [-160.232788, 58.901127],\n          [-160.150528, 58.866062],\n          [-159.979344, 58.835535],\n          [-159.908386, 58.779903],\n          [-159.792923, 58.823971],\n          [-159.748183, 58.875827],\n          [-159.712114, 58.929468],\n          [-159.61612, 58.931601],\n          [-159.601899, 58.884671],\n          [-159.643549, 58.845063],\n          [-159.532347, 58.833609],\n          [-159.409779, 58.773611],\n          [-159.228398, 58.603047],\n          [-159.063346, 58.423139],\n          [-158.880927, 58.39067],\n          [-158.795316, 58.408032],\n          [-158.704052, 58.482759],\n          [-158.827852, 58.626432],\n          [-158.861207, 58.69558],\n          [-158.780136, 58.75379],\n          [-158.790378, 58.804712],\n          [-158.767748, 58.864264],\n          [-158.619684, 58.911048],\n          [-158.520327, 58.857105],\n          [-158.564833, 58.802715],\n          [-158.423828, 58.769847],\n          [-158.376873, 58.748043],\n          [-158.332093, 58.665313],\n          [-158.232276, 58.619902],\n          [-158.140307, 58.61502],\n          [-157.777937, 58.703288],\n          [-157.572524, 58.750839],\n          [-157.388651, 58.805346],\n          [-157.1962921, 58.8493595],\n          [-157.116866, 58.867533],\n          [-157.0953723, 58.8666707],\n          [-157.016088, 58.86349],\n          [-156.993548, 58.836798],\n          [-157.06223, 58.740187],\n          [-157.135927, 58.680731],\n          [-157.2343006, 58.616667],\n          [-157.313572, 58.565043],\n          [-157.481487, 58.480771],\n          [-157.541041, 58.377302],\n          [-157.547209, 58.277535],\n          [-157.48013, 58.217354],\n          [-157.556556, 58.148445],\n          [-157.596601, 58.08867],\n          [-157.642226, 57.868777],\n          [-157.683349, 57.753695],\n          [-157.709179, 57.657459],\n          [-157.684282, 57.609974],\n          [-157.678891, 57.563888],\n          [-157.772496, 57.547055],\n          [-157.931624, 57.476208],\n          [-158.083785, 57.357181],\n          [-158.229883, 57.321534],\n          [-158.32018, 57.281558],\n          [-158.531328, 57.132156],\n          [-158.679293, 56.988625],\n          [-158.686184, 56.911555],\n          [-158.646812, 56.846992],\n          [-158.656355, 56.810012],\n          [-158.744534, 56.795112],\n          [-158.853294, 56.79262],\n          [-158.893548, 56.8093085],\n          [-158.972735, 56.842138],\n          [-159.219956, 56.73953],\n          [-159.534961, 56.626529],\n          [-159.828049, 56.543935],\n          [-159.985615, 56.449743],\n          [-160.146252, 56.400176],\n          [-160.222878, 56.346868],\n          [-160.385922, 56.279706],\n          [-160.405869, 56.207938],\n          [-160.488708, 56.077214],\n          [-160.589569, 55.983048],\n          [-160.533685, 55.95995],\n          [-160.457194, 55.917233],\n          [-160.508433, 55.869379],\n          [-160.564014, 55.863719],\n          [-160.793215, 55.88596],\n          [-160.811041, 55.94723],\n          [-160.807119, 56.02398],\n          [-160.964744, 56.023754],\n          [-161.15687, 56.012216],\n          [-161.450442, 55.954485],\n          [-161.712283, 55.904232],\n          [-161.807833, 55.891954],\n          [-161.898956, 55.833464],\n          [-162.05063, 55.790897],\n          [-162.120886, 55.749089],\n          [-162.219551, 55.710867],\n          [-162.365467, 55.604586],\n          [-162.565411, 55.466849],\n          [-162.64165, 55.392576],\n          [-162.813255, 55.299458],\n          [-162.900027, 55.252466],\n          [-162.86152, 55.198339],\n          [-163.032256, 55.172147],\n          [-163.132007, 55.179629],\n          [-163.314652, 55.126312],\n          [-163.280771, 55.032959],\n          [-163.343768, 54.974439],\n          [-163.429548, 54.954759],\n          [-163.527109, 55.040871],\n          [-163.774093, 55.05578],\n          [-163.894695, 55.039115],\n          [-163.994179, 54.983315],\n          [-164.119196, 54.969416],\n          [-164.204897, 54.93124],\n          [-164.343534, 54.894139],\n          [-164.43528, 54.933126],\n          [-164.57626, 54.895342],\n          [-164.576896, 54.824564],\n          [-164.674836, 54.702596],\n          [-164.741815, 54.645441],\n          [-164.864333, 54.620188],\n          [-164.948789, 54.579877],\n          [-164.944636, 54.532903],\n          [-164.904077, 54.499195],\n          [-164.861475, 54.431353],\n          [-164.743977, 54.394216],\n          [-164.640457, 54.391166],\n          [-164.456554, 54.419856],\n          [-164.352704, 54.465023],\n          [-164.337538, 54.524259],\n          [-164.257585, 54.572722],\n          [-164.03827, 54.624688],\n          [-163.80359, 54.636498],\n          [-163.572383, 54.623211],\n          [-163.392198, 54.658496],\n          [-163.223179, 54.676895],\n          [-163.037788, 54.646995],\n          [-163.068952, 54.712605],\n          [-163.184295, 54.774912],\n          [-163.281379, 54.77673],\n          [-163.352997, 54.810174],\n          [-163.254588, 54.838907],\n          [-163.14958, 54.885906],\n          [-163.065602, 54.926172],\n          [-162.962205, 54.993538],\n          [-162.913684, 54.950273],\n          [-162.834245, 54.926851],\n          [-162.708453, 54.95848],\n          [-162.587967, 54.97201],\n          [-162.569291, 55.004599],\n          [-162.471364, 55.051932],\n          [-162.41351, 55.03656],\n          [-162.435473, 54.929249],\n          [-162.428237, 54.895434],\n          [-162.349315, 54.836049],\n          [-162.282944, 54.841216],\n          [-162.236806, 54.88163],\n          [-162.235675, 54.962601],\n          [-162.219326, 55.028975],\n          [-162.190348, 55.066981],\n          [-162.11874, 55.102911],\n          [-162.053281, 55.074212],\n          [-161.956595, 55.112174],\n          [-161.906434, 55.10032],\n          [-161.792297, 55.052278],\n          [-161.690346, 55.0785],\n          [-161.550357, 55.065734],\n          [-161.576643, 55.103831],\n          [-161.718614, 55.154166],\n          [-161.817232, 55.176529],\n          [-161.863339, 55.266989],\n          [-161.777414, 55.329377],\n          [-161.686495, 55.408041],\n          [-161.700069, 55.51439],\n          [-161.658262, 55.560447],\n          [-161.587047, 55.62006],\n          [-161.482064, 55.633979],\n          [-161.392613, 55.628221],\n          [-161.376102, 55.569794],\n          [-161.469271, 55.49683],\n          [-161.478303, 55.4406],\n          [-161.514211, 55.385254],\n          [-161.486114, 55.359322],\n          [-161.253977, 55.355896],\n          [-161.080549, 55.408498],\n          [-160.976551, 55.472736],\n          [-160.836725, 55.473135],\n          [-160.781401, 55.45178],\n          [-160.666917, 55.459776],\n          [-160.654117, 55.512596],\n          [-160.521335, 55.47442],\n          [-160.462745, 55.506654],\n          [-160.464301, 55.533243],\n          [-160.392587, 55.602771],\n          [-160.279827, 55.641384],\n          [-160.130445, 55.681419],\n          [-160.058443, 55.721734],\n          [-160.026282, 55.792295],\n          [-159.937089, 55.803306],\n          [-159.847359, 55.80253],\n          [-159.770298, 55.852357],\n          [-159.679792, 55.838765],\n          [-159.627482, 55.803248],\n          [-159.673191, 55.750961],\n          [-159.679201, 55.655895],\n          [-159.760365, 55.615203],\n          [-159.733899, 55.569985],\n          [-159.696713, 55.573306],\n          [-159.572125, 55.627684],\n          [-159.5614383, 55.6409138],\n          [-159.532754, 55.676424],\n          [-159.394595, 55.714944],\n          [-159.086217, 55.834869],\n          [-159.096187, 55.91475],\n          [-158.898116, 55.951041],\n          [-158.74856, 55.959365],\n          [-158.653214, 55.958615],\n          [-158.638211, 55.994743],\n          [-158.50984, 55.979617],\n          [-158.431471, 55.994452],\n          [-158.394922, 56.064721],\n          [-158.374324, 56.134522],\n          [-158.283191, 56.173212],\n          [-158.117797, 56.230742],\n          [-158.207387, 56.294354],\n          [-158.288369, 56.316089],\n          [-158.415095, 56.336228],\n          [-158.489546, 56.341865],\n          [-158.438414, 56.427471],\n          [-158.371953, 56.467334],\n          [-158.284699, 56.481089],\n          [-158.246144, 56.466124],\n          [-158.12744, 56.460805],\n          [-157.971711, 56.476737],\n          [-157.869124, 56.456612],\n          [-157.817826, 56.51421],\n          [-157.869897, 56.566837],\n          [-157.918541, 56.643137],\n          [-157.791844, 56.670692],\n          [-157.719048, 56.653084],\n          [-157.674587, 56.609507],\n          [-157.605231, 56.621315],\n          [-157.496523, 56.616897],\n          [-157.45216, 56.64322],\n          [-157.563802, 56.703426],\n          [-157.530765, 56.753775],\n          [-157.411488, 56.778351],\n          [-157.290511, 56.804713],\n          [-157.183636, 56.769079],\n          [-157.073453, 56.838345],\n          [-157.034624, 56.884487],\n          [-156.935629, 56.920087],\n          [-156.825982, 56.897667],\n          [-156.704216, 56.987079],\n          [-156.63784, 56.993905],\n          [-156.55052, 56.98461],\n          [-156.479111, 57.068395],\n          [-156.44301, 57.119533],\n          [-156.3742873, 57.1592501],\n          [-156.334404, 57.1823],\n          [-156.342943, 57.248056],\n          [-156.336427, 57.336081],\n          [-156.362039, 57.400474],\n          [-156.220105, 57.445295],\n          [-156.091668, 57.439829],\n          [-156.012841, 57.451394],\n          [-156.046804, 57.525724],\n          [-155.915261, 57.535331],\n          [-155.732779, 57.549732],\n          [-155.724167, 57.633445],\n          [-155.629912, 57.656376],\n          [-155.615203, 57.688074],\n          [-155.609353, 57.777699],\n          [-155.506533, 57.76097],\n          [-155.354011, 57.715261],\n          [-155.285339, 57.758726],\n          [-155.272917, 57.823981],\n          [-155.097095, 57.865356],\n          [-155.061806, 57.90433],\n          [-155.118648, 57.953925],\n          [-155.026275, 57.999302],\n          [-154.876559, 58.027722],\n          [-154.765287, 58.00371],\n          [-154.581547, 58.019285],\n          [-154.477979, 58.052379],\n          [-154.340449, 58.090921],\n          [-154.222465, 58.132566],\n          [-154.145277, 58.210931],\n          [-154.103412, 58.280161],\n          [-154.074145, 58.352661],\n          [-153.985416, 58.390877],\n          [-154.07066, 58.440018],\n          [-154.001918, 58.492346],\n          [-153.930473, 58.497482],\n          [-153.909994, 58.561213],\n          [-153.851432, 58.611872],\n          [-153.731019, 58.608224],\n          [-153.591635, 58.640084],\n          [-153.55265, 58.687176],\n          [-153.445002, 58.70931],\n          [-153.402472, 58.742607],\n          [-153.369389, 58.821255],\n          [-153.2944362, 58.855036],\n          [-153.267407, 58.867218],\n          [-153.322843, 58.907849],\n          [-153.393101, 58.951097],\n          [-153.479939, 58.995286],\n          [-153.596489, 59.000192],\n          [-153.695664, 59.073994],\n          [-153.793972, 59.071416],\n          [-153.932824, 59.062677],\n          [-154.063489, 59.07214],\n          [-154.180691, 59.123235],\n          [-154.172944, 59.172496],\n          [-154.141192, 59.216598],\n          [-154.122681, 59.287622],\n          [-154.030807, 59.32704],\n          [-153.998506, 59.384723],\n          [-153.925307, 59.405254],\n          [-153.862199, 59.424124],\n          [-153.747201, 59.429657],\n          [-153.699025, 59.463603],\n          [-153.76148, 59.543411],\n          [-153.684925, 59.552865],\n          [-153.577828, 59.555991],\n          [-153.553163, 59.597046],\n          [-153.542466, 59.630236],\n          [-153.409422, 59.636328],\n          [-153.308837, 59.625706],\n          [-153.240018, 59.632426],\n          [-153.155019, 59.654344],\n          [-153.051559, 59.691562],\n          [-153.016353, 59.751127],\n          [-153.009084, 59.830643],\n          [-152.967267, 59.881494],\n          [-152.860867, 59.875033],\n          [-152.700822, 59.920309],\n          [-152.679402, 59.968054],\n          [-152.575153, 60.04826],\n          [-152.550177, 60.113715],\n          [-152.57873, 60.16987],\n          [-152.574938, 60.206451],\n          [-152.539843, 60.241644],\n          [-152.411281, 60.287864],\n          [-152.376743, 60.345613],\n          [-152.234199, 60.393888],\n          [-152.30195, 60.414328],\n          [-152.331365, 60.473525],\n          [-152.261497, 60.538237],\n          [-152.13616, 60.578475],\n          [-152.039381, 60.660517],\n          [-151.89792, 60.72175],\n          [-151.716379, 60.710415],\n          [-151.703802, 60.732376],\n          [-151.77731, 60.810461],\n          [-151.800264, 60.853672],\n          [-151.720815, 60.904257],\n          [-151.600126, 60.965589],\n          [-151.4803, 61.010902],\n          [-151.349004, 61.010004],\n          [-151.252384, 61.039968],\n          [-151.166606, 61.046404],\n          [-151.121692, 61.083574],\n          [-151.047736, 61.16089],\n          [-150.9740119, 61.1944673],\n          [-150.939251, 61.210299],\n          [-150.827295, 61.22839],\n          [-150.679902, 61.265888],\n          [-150.535997, 61.269724],\n          [-150.425, 61.245552],\n          [-150.204894, 61.259548],\n          [-150.2212407, 61.1931708],\n          [-150.228774, 61.162581],\n          [-150.265894, 61.127365],\n          [-150.065646, 61.151079],\n          [-150.005041, 61.138556],\n          [-149.831922, 61.076197],\n          [-149.717167, 61.011303],\n          [-149.7484638, 61.0012377],\n          [-149.853693, 60.967395],\n          [-149.900135, 60.940043],\n          [-149.985374, 60.879033],\n          [-150.109276, 60.890357],\n          [-150.194128, 60.90134],\n          [-150.341709, 61.024201],\n          [-150.401859, 61.036227],\n          [-150.501923, 61.007957],\n          [-150.705812, 60.937792],\n          [-150.895508, 60.853166],\n          [-151.062558, 60.787429],\n          [-151.261319, 60.769801],\n          [-151.370515, 60.733572],\n          [-151.410273, 60.711023],\n          [-151.350154, 60.63466],\n          [-151.303125, 60.561326],\n          [-151.28181, 60.496034],\n          [-151.30609, 60.387257],\n          [-151.366874, 60.372655],\n          [-151.381959, 60.296951],\n          [-151.421702, 60.212931],\n          [-151.606881, 60.099558],\n          [-151.71801, 60.009473],\n          [-151.757693, 59.917637],\n          [-151.813619, 59.844297],\n          [-151.869468, 59.769159],\n          [-151.746815, 59.686234],\n          [-151.643061, 59.646966],\n          [-151.448669, 59.648171],\n          [-151.296895, 59.696861],\n          [-151.205459, 59.630284],\n          [-151.327803, 59.573047],\n          [-151.516339, 59.52352],\n          [-151.742915, 59.468286],\n          [-151.886513, 59.421033],\n          [-151.96313, 59.344958],\n          [-151.984101, 59.278696],\n          [-151.915684, 59.227522],\n          [-151.858124, 59.144234],\n          [-151.662368, 59.089735],\n          [-151.43339, 59.135517],\n          [-151.470623, 59.242621],\n          [-151.341601, 59.222231],\n          [-151.287771, 59.219417],\n          [-151.126247, 59.209923],\n          [-151.001196, 59.224149],\n          [-150.942212, 59.233136],\n          [-150.887821, 59.26792],\n          [-150.912817, 59.305214],\n          [-150.822768, 59.330763],\n          [-150.721799, 59.292087],\n          [-150.680872, 59.305412],\n          [-150.609488, 59.386314],\n          [-150.581182, 59.445233],\n          [-150.4989, 59.456298],\n          [-150.477717, 59.422111],\n          [-150.430144, 59.343357],\n          [-150.385341, 59.341963],\n          [-150.358992, 59.399684],\n          [-150.297108, 59.424747],\n          [-150.280838, 59.466833],\n          [-150.133747, 59.556786],\n          [-150.002337, 59.630563],\n          [-149.919444, 59.691836],\n          [-149.842672, 59.7013],\n          [-149.74622, 59.637585],\n          [-149.731966, 59.706783],\n          [-149.626311, 59.73441],\n          [-149.527793, 59.706846],\n          [-149.506758, 59.770927],\n          [-149.595531, 59.79772],\n          [-149.572714, 59.852317],\n          [-149.472227, 59.903693],\n          [-149.376593, 59.835879],\n          [-149.270623, 59.872067],\n          [-149.221067, 59.938748],\n          [-149.123262, 59.968559],\n          [-149.036467, 59.942137],\n          [-148.936406, 59.953429],\n          [-148.859556, 59.924398],\n          [-148.801325, 59.952794],\n          [-148.689496, 59.944701],\n          [-148.6495296, 59.9235532],\n          [-148.634777, 59.915747],\n          [-148.478881, 59.935806],\n          [-148.401666, 59.977836],\n          [-148.313962, 60.033859],\n          [-148.220554, 59.97635],\n          [-148.25406, 59.932357],\n          [-148.101239, 59.952794],\n          [-147.956775, 59.9594],\n          [-147.855084, 59.871915],\n          [-147.913316, 59.837181],\n          [-147.92924, 59.783875],\n          [-147.876475, 59.763893],\n          [-147.765122, 59.795954],\n          [-147.646045, 59.817828],\n          [-147.508309, 59.841957],\n          [-147.391846, 59.87776],\n          [-147.470281, 59.906732],\n          [-147.452217, 59.954011],\n          [-147.339794, 59.962102],\n          [-147.376397, 60.016192],\n          [-147.257795, 60.107883],\n          [-147.145205, 60.171321],\n          [-146.993353, 60.24008],\n          [-146.916487, 60.290973],\n          [-146.694034, 60.279608],\n          [-146.650852, 60.242982],\n          [-146.607692, 60.241182],\n          [-146.490804, 60.294939],\n          [-146.393256, 60.327476],\n          [-146.232681, 60.338851],\n          [-146.197229, 60.348294],\n          [-146.088134, 60.364987],\n          [-145.988546, 60.387427],\n          [-145.831202, 60.350293],\n          [-145.639204, 60.301971],\n          [-145.51081, 60.318296],\n          [-145.380064, 60.352829],\n          [-145.254749, 60.311448],\n          [-145.136728, 60.296219],\n          [-145.089139, 60.320014],\n          [-144.957848, 60.288152],\n          [-144.929327, 60.228253],\n          [-144.654899, 60.204882],\n          [-144.555093, 60.178485],\n          [-144.429249, 60.14802],\n          [-144.348913, 60.091184],\n          [-144.186745, 60.116967],\n          [-144.1103, 60.098939],\n          [-144.052539, 60.041759],\n          [-144.005879, 60.012981],\n          [-143.897029, 59.985938],\n          [-143.893326, 59.9867216],\n          [-143.781649, 60.010354],\n          [-143.624152, 60.037257],\n          [-143.267818, 60.058655],\n          [-143.0687, 60.068603],\n          [-142.908859, 60.090328],\n          [-142.744868, 60.09413],\n          [-142.426572, 60.071066],\n          [-142.062454, 60.023781],\n          [-141.912218, 60.009779],\n          [-141.73624, 59.961905],\n          [-141.595376, 59.961905],\n          [-141.485207, 59.925024],\n          [-141.392811, 59.870028],\n          [-141.156497, 59.813582],\n          [-140.922635, 59.751687],\n          [-140.792511, 59.728573],\n          [-140.4119, 59.699649],\n          [-140.242577, 59.687888],\n          [-140.176224, 59.735965],\n          [-140.080423, 59.756299],\n          [-139.871222, 59.802611],\n          [-139.776836, 59.833835],\n          [-139.608545, 59.821961],\n          [-139.588777, 59.708968],\n          [-139.585789, 59.642765],\n          [-139.74266, 59.623871],\n          [-139.861306, 59.546678],\n          [-139.632896, 59.459906],\n          [-139.420168, 59.37976],\n          [-139.271031, 59.337421],\n          [-139.07148, 59.28715],\n          [-138.919749, 59.248531],\n          [-138.807186, 59.208772],\n          [-138.636702, 59.130585],\n          [-138.357909, 59.069394],\n          [-138.224323, 59.032216],\n          [-138.066332, 58.957126],\n          [-137.951995, 58.886029],\n          [-137.924608, 58.843928],\n          [-137.9361599, 58.8106502],\n          [-137.941828, 58.794322],\n          [-137.836448, 58.741563],\n          [-137.681633, 58.656452],\n          [-137.653709, 58.608324],\n          [-137.568216, 58.587989],\n          [-137.355328, 58.492374],\n          [-137.239366, 58.453159],\n          [-137.078109, 58.397474],\n          [-136.986384, 58.404043],\n          [-136.911713, 58.370252],\n          [-136.857605, 58.31636],\n          [-136.717093, 58.273508],\n          [-136.70125, 58.219416],\n          [-136.591924, 58.217886],\n          [-136.567956, 58.245153],\n          [-136.576799, 58.277951],\n          [-136.544776, 58.316665],\n          [-136.437152, 58.302417],\n          [-136.265906, 58.314499],\n          [-136.11193, 58.34253],\n          [-136.041818, 58.380161],\n          [-135.917917, 58.381237],\n          [-135.728054, 58.397067],\n          [-135.649861, 58.324517],\n          [-135.544213, 58.330228],\n          [-135.4499662, 58.3390682],\n          [-135.408059, 58.342999],\n          [-135.306507, 58.242916],\n          [-135.227736, 58.2369],\n          [-135.087872, 58.200073],\n          [-135.10121, 58.292607],\n          [-135.049062, 58.309295],\n          [-135.068437, 58.374157],\n          [-135.104413, 58.449263],\n          [-135.0617691, 58.4513532],\n          [-134.936897, 58.457474],\n          [-134.750586, 58.391533],\n          [-134.631203, 58.247446],\n          [-134.464635, 58.227388],\n          [-134.375579, 58.208705],\n          [-134.234572, 58.197234],\n          [-134.146685, 58.199084],\n          [-134.078155, 58.152046],\n          [-134.049603, 58.062027],\n          [-133.848776, 57.93544],\n          [-133.703097, 57.792152],\n          [-133.7030254, 57.7920363],\n          [-133.65453, 57.713689],\n          [-133.676449, 57.625192],\n          [-133.62076, 57.578919],\n          [-133.519598, 57.530705],\n          [-133.514964, 57.473345],\n          [-133.472039, 57.368651],\n          [-133.489738, 57.305192],\n          [-133.544817, 57.24257],\n          [-133.466932, 57.159356],\n          [-133.322359, 57.112727],\n          [-133.247414, 57.136802],\n          [-133.161448, 57.086264],\n          [-132.93752, 57.048321],\n          [-132.892388, 56.993016],\n          [-132.792089, 56.856152],\n          [-132.556758, 56.757242],\n          [-132.5458223, 56.7136212],\n          [-132.542885, 56.701905],\n          [-132.529037, 56.63797],\n          [-132.45079, 56.564098],\n          [-132.528637, 56.529269],\n          [-132.627544, 56.46287],\n          [-132.791872, 56.449169],\n          [-132.896342, 56.457978],\n          [-132.977163, 56.439673],\n          [-133.060361, 56.358378],\n          [-133.0696, 56.346323],\n          [-133.070056, 56.330951],\n          [-133.029712, 56.3157],\n          [-132.961082, 56.296167],\n          [-132.926759, 56.266188],\n          [-132.877582, 56.240322],\n          [-132.843716, 56.238933],\n          [-132.718342, 56.217704],\n          [-132.708697, 56.112124],\n          [-132.594235, 56.021858],\n          [-132.492795, 56.066436],\n          [-132.449834, 55.956186],\n          [-132.397304, 55.878867],\n          [-132.323242, 55.851878],\n          [-132.279962, 55.924839],\n          [-132.170198, 55.919231],\n          [-132.067412, 55.875078],\n          [-132.130413, 55.811419],\n          [-132.265071, 55.762174],\n          [-132.224167, 55.701766],\n          [-132.1996814, 55.633834],\n          [-132.183207, 55.588128],\n          [-132.114654, 55.550623],\n          [-131.971792, 55.498279],\n          [-131.844157, 55.456742],\n          [-131.854297, 55.421074],\n          [-131.862162, 55.289284],\n          [-131.828395, 55.198482],\n          [-131.748334, 55.128588],\n          [-131.684132, 55.1190936],\n          [-131.605302, 55.107436],\n          [-131.589387, 55.08894],\n          [-131.646276, 55.035579],\n          [-131.605661, 55.004403],\n          [-131.6118897, 54.9822706],\n          [-131.621948, 54.946531],\n          [-131.594567, 54.93113],\n          [-131.491504, 54.930392],\n          [-131.433473, 54.896535],\n          [-131.327624, 54.859122],\n          [-131.253671, 54.866779],\n          [-131.195197, 54.919767],\n          [-131.245988, 54.940491],\n          [-131.246018, 54.989555],\n          [-131.190033, 55.043173],\n          [-131.190628, 55.108013],\n          [-131.160492, 55.197481],\n          [-131.093806, 55.191335],\n          [-131.087497, 55.163036],\n          [-131.052298, 55.11816],\n          [-131.013215, 55.090069],\n          [-130.997057, 55.044256],\n          [-131.012061, 54.996238],\n          [-130.97503, 54.974853],\n          [-130.9604, 54.933685],\n          [-130.947338, 54.886733],\n          [-130.932454, 54.806938],\n          [-130.866866, 54.769068],\n          [-130.844145, 54.765801],\n          [-130.792122, 54.784784],\n          [-130.737423, 54.753545],\n          [-130.686192, 54.71691],\n          [-130.62807, 54.739341],\n          [-130.636745, 54.778456],\n          [-130.529228, 54.8109],\n          [-130.339504, 54.921376],\n          [-130.221512, 55.02599],\n          [-130.169294, 55.105424],\n          [-130.104749, 55.188975],\n          [-130.001735, 55.264557],\n          [-129.982348, 55.302079],\n          [-130.023558, 55.338259],\n          [-130.039928, 55.429422],\n          [-130.085413, 55.491517],\n          [-130.120132, 55.563919],\n          [-130.111677, 55.682051],\n          [-130.150061, 55.727099],\n          [-130.1382223, 55.7630276],\n          [-130.12372, 55.80704],\n          [-130.08451, 55.823997],\n          [-130.013198, 55.916382],\n          [-130.00426, 55.993379],\n          [-130.102761, 56.116696],\n          [-130.24554, 56.096876],\n          [-130.2465773, 56.097196],\n          [-130.343716, 56.127162],\n          [-130.425575, 56.140676],\n          [-130.466874, 56.239789],\n          [-130.622482, 56.267939],\n          [-130.740619, 56.342953],\n          [-130.810707, 56.371063],\n          [-131.085704, 56.40654],\n          [-131.0867947, 56.4070948],\n          [-131.167925, 56.448361],\n          [-131.461806, 56.547904],\n          [-131.581221, 56.613275],\n          [-131.835133, 56.601849],\n          [-131.90176, 56.753158],\n          [-131.871725, 56.804965],\n          [-132.125934, 56.874698],\n          [-132.1189179, 56.8912294],\n          [-132.051044, 57.051155],\n          [-132.371312, 57.095229],\n          [-132.252187, 57.215655],\n          [-132.367984, 57.348685],\n          [-132.559178, 57.503927],\n          [-132.6552787, 57.6017446],\n          [-132.756813, 57.705093],\n          [-132.869318, 57.842941],\n          [-133.076421, 57.999762],\n          [-133.176444, 58.150151],\n          [-133.1769796, 58.1505377],\n          [-133.343725, 58.270915],\n          [-133.461475, 58.385526],\n          [-133.379908, 58.427909],\n          [-133.699835, 58.60729],\n          [-133.840392, 58.727991],\n          [-134.250526, 58.858046],\n          [-134.328964, 58.919593],\n          [-134.3279923, 58.9629722],\n          [-134.327982, 58.963431],\n          [-134.401042, 58.976221],\n          [-134.379771, 59.034961],\n          [-134.481241, 59.128071],\n          [-134.566689, 59.128278],\n          [-134.66407, 59.181172],\n          [-134.702383, 59.247836],\n          [-134.961972, 59.280376],\n          [-135.029245, 59.345364],\n          [-135.0291205, 59.3455969],\n          [-135.010033, 59.381288],\n          [-135.067356, 59.421855],\n          [-135.026328, 59.474658],\n          [-135.027456, 59.563692],\n          [-135.114588, 59.623415],\n          [-135.214344, 59.664343],\n          [-135.231148, 59.697176],\n          [-135.477436, 59.799626],\n          [-135.7173168, 59.7300769],\n          [-135.945905, 59.663802],\n          [-136.190352, 59.639854],\n          [-136.350622, 59.599326],\n          [-136.23734, 59.558734],\n          [-136.234229, 59.524731],\n          [-136.358141, 59.449799],\n          [-136.474326, 59.464194],\n          [-136.466815, 59.284252],\n          [-136.4896522, 59.2604916],\n          [-136.581521, 59.164909],\n          [-136.826633, 59.158389],\n          [-136.863896, 59.138472],\n          [-137.264752, 59.002352],\n          [-137.447383, 58.909513],\n          [-137.526424, 58.906834],\n          [-137.5256771, 58.9089745],\n          [-137.498558, 58.986694],\n          [-137.604277, 59.243057],\n          [-138.584819, 59.752453],\n          [-138.643422, 59.792502],\n          [-138.702053, 59.910245],\n          [-139.046426, 59.998235],\n          [-139.200346, 60.090701],\n          [-139.082246, 60.323825],\n          [-139.086669, 60.357654],\n          [-139.698361, 60.340421],\n          [-139.989142, 60.18524],\n          [-140.472292, 60.31059],\n          [-140.53509, 60.224224],\n          [-141.00184, 60.306105],\n          [-141.0018497, 60.391688],\n          [-141.0020205, 61.904047],\n          [-141.0024649, 65.839421],\n          [-141.002465, 65.840075],\n          [-141.0026096, 68.498364],\n          [-141.002672, 69.645609],\n          [-141.210456, 69.68419],\n          [-141.43084, 69.695144],\n          [-141.713369, 69.789497],\n          [-142.015641, 69.837976],\n          [-142.239873, 69.896598],\n          [-142.404366, 69.916511],\n          [-142.452927, 69.958125],\n          [-142.746807, 70.042531],\n          [-142.99979, 70.088305],\n          [-143.281878, 70.151052],\n          [-143.425199, 70.124928],\n          [-143.5173, 70.138418],\n          [-143.914244, 70.115696],\n          [-144.274904, 70.048711],\n          [-144.455421, 70.035244],\n          [-144.672305, 69.966876],\n          [-144.792614, 69.979796],\n          [-144.902304, 69.96451],\n          [-145.175073, 69.991707],\n          [-145.43483, 70.036994],\n          [-145.623306, 70.084375],\n          [-145.858297, 70.165996],\n          [-146.006411, 70.140402],\n          [-146.129579, 70.158948],\n          [-146.508133, 70.186044],\n          [-146.885771, 70.185917],\n          [-146.991109, 70.14761],\n          [-147.161601, 70.155612],\n          [-147.233327, 70.207553],\n          [-147.431532, 70.188826],\n          [-147.765104, 70.219806],\n          [-147.863719, 70.293317],\n          [-147.9615, 70.314201],\n          [-148.203477, 70.348188],\n          [-148.351437, 70.304453],\n          [-148.46615, 70.313609],\n          [-148.477044, 70.359068],\n          [-148.667017, 70.430084],\n          [-148.928979, 70.426835],\n          [-149.179148, 70.4857],\n          [-149.461755, 70.518271],\n          [-149.740188, 70.498151],\n          [-149.866698, 70.510769],\n          [-150.074461, 70.439333],\n          [-150.301516, 70.418392],\n          [-150.414358, 70.459694],\n          [-150.557415, 70.481643],\n          [-150.786327, 70.463271],\n          [-150.903765, 70.46091],\n          [-151.020441, 70.433841],\n          [-151.175187, 70.375558],\n          [-151.297598, 70.400748],\n          [-151.504417, 70.431103],\n          [-151.739862, 70.436207],\n          [-151.734287, 70.503492],\n          [-151.697258, 70.547741],\n          [-151.975785, 70.563215],\n          [-152.078663, 70.584504],\n          [-152.29669, 70.602287],\n          [-152.433781, 70.616926],\n          [-152.473348, 70.683669],\n          [-152.352196, 70.697802],\n          [-152.348417, 70.744382],\n          [-152.19246, 70.795294],\n          [-152.223053, 70.824594],\n          [-152.423534, 70.858708],\n          [-152.696868, 70.882086],\n          [-152.904243, 70.883877],\n          [-153.049207, 70.913102],\n          [-153.23848, 70.922467],\n          [-153.426265, 70.890131],\n          [-153.666363, 70.883448],\n          [-153.89048, 70.885719],\n          [-154.127487, 70.778133],\n          [-154.290317, 70.821495],\n          [-154.430229, 70.831258],\n          [-154.572458, 70.82594],\n          [-154.608314, 70.942405],\n          [-154.581129, 71.007321],\n          [-154.942864, 71.126264],\n          [-155.060764, 71.145422],\n          [-155.262602, 71.079149],\n          [-155.36416, 70.994195],\n          [-155.513293, 70.940579],\n          [-155.485915, 70.885905],\n          [-155.543031, 70.847175],\n          [-155.731842, 70.83116],\n          [-155.924955, 70.85272],\n          [-155.979264, 70.918524],\n          [-155.95205, 70.964831],\n          [-155.762068, 70.985644],\n          [-155.705487, 71.020153],\n          [-155.533347, 71.067683],\n          [-155.520737, 71.102476],\n          [-155.587702, 71.17256],\n          [-155.895105, 71.193899],\n          [-156.044615, 71.184701],\n          [-156.074411, 71.242489],\n          [-156.309908, 71.259881],\n          [-156.531124, 71.296338],\n          [-156.56865, 71.352561],\n          [-156.809653, 71.286886],\n          [-156.906165, 71.239616],\n          [-157.176077, 71.095549],\n          [-157.421001, 70.976805],\n          [-157.768452, 70.875842],\n          [-158.032397, 70.832263],\n          [-158.366302, 70.819712],\n          [-158.573913, 70.79495],\n          [-158.85342, 70.792352],\n          [-159.114972, 70.817402],\n          [-159.17181, 70.875103],\n          [-159.648383, 70.794368],\n          [-159.869172, 70.706397],\n          [-160.214828, 70.559087],\n          [-160.81279, 70.376696],\n          [-161.288197, 70.296772],\n          [-161.581911, 70.302877],\n          [-161.879266, 70.329269],\n          [-162.302314, 70.204227],\n          [-162.503572, 70.100393],\n          [-162.78808, 69.929097],\n          [-162.989084, 69.82525],\n          [-163.071903, 69.737605],\n          [-163.151261, 69.61263],\n          [-163.151351, 69.430262],\n          [-163.244656, 69.306081],\n          [-163.574034, 69.124077],\n          [-163.926999, 69.000802],\n          [-164.253157, 68.930938],\n          [-164.526887, 68.917909],\n          [-164.967542, 68.88303],\n          [-165.522358, 68.855839],\n          [-165.923734, 68.868432],\n          [-166.224187, 68.873175],\n          [-166.193421, 68.726649],\n          [-166.229761, 68.613771],\n          [-166.28312, 68.521247],\n          [-166.328459, 68.442261],\n          [-166.591802, 68.405551],\n          [-166.838969, 68.337186],\n          [-166.60089, 68.333637],\n          [-166.313138, 68.289164],\n          [-166.089453, 68.221299],\n          [-165.97497, 68.14091],\n          [-165.872088, 68.110047],\n          [-165.688137, 68.090396],\n          [-165.3965203, 68.0347305],\n          [-165.35005, 68.02586],\n          [-165.094228, 67.931963],\n          [-164.533937, 67.725606],\n          [-164.256634, 67.651651],\n          [-164.051288, 67.566351],\n          [-163.878781, 67.416125],\n          [-163.74082, 67.20996],\n          [-163.702045, 67.109375],\n          [-163.591216, 67.092373],\n          [-163.299266, 67.060748],\n          [-163.011676, 67.029538],\n          [-162.842979, 66.991177],\n          [-162.63547, 66.998434],\n          [-162.468441, 66.980604],\n          [-162.466702, 66.950998],\n          [-162.582856, 66.904292],\n          [-162.626696, 66.859572],\n          [-162.501415, 66.742503],\n          [-162.349774, 66.726713],\n          [-162.175398, 66.687789],\n          [-162.105641, 66.622584],\n          [-161.87488, 66.511446],\n          [-161.86369, 66.459487],\n          [-161.916309, 66.349481],\n          [-161.694404, 66.396174],\n          [-161.575413, 66.396806],\n          [-161.322126, 66.368554],\n          [-161.089161, 66.31514],\n          [-160.993965, 66.234444],\n          [-161.198971, 66.210949],\n          [-161.320778, 66.223591],\n          [-161.341189, 66.2551],\n          [-161.484539, 66.262426],\n          [-161.548429, 66.239912],\n          [-161.613943, 66.176693],\n          [-161.775537, 66.073732],\n          [-161.838018, 66.022582],\n          [-162.137424, 66.078547],\n          [-162.331284, 66.031403],\n          [-162.423726, 66.048984],\n          [-162.622284, 66.039526],\n          [-162.750705, 66.09016],\n          [-162.997473, 66.076845],\n          [-163.146726, 66.059487],\n          [-163.372072, 66.085029],\n          [-163.495845, 66.085388],\n          [-163.695394, 66.059552],\n          [-163.80358, 66.100059],\n          [-163.916551, 66.190494],\n          [-163.925152, 66.225078],\n          [-163.843108, 66.259869],\n          [-163.849163, 66.307639],\n          [-163.873106, 66.389015],\n          [-163.798687, 66.436875],\n          [-163.728308, 66.498552],\n          [-163.603956, 66.558089],\n          [-163.824166, 66.59168],\n          [-164.3959436, 66.5811976],\n          [-164.400724, 66.58111],\n          [-164.816093, 66.525025],\n          [-165.407204, 66.420441],\n          [-166.038082, 66.269512],\n          [-166.768944, 66.068582],\n          [-167.282753, 65.897386],\n          [-167.650051, 65.795703],\n          [-167.979889, 65.727972],\n          [-168.12893, 65.655744],\n        ],\n      ],\n      [\n        [\n          [-169.28652, 52.784747],\n          [-169.261765, 52.754897],\n          [-169.170371, 52.776663],\n          [-169.005038, 52.829992],\n          [-168.851017, 52.90804],\n          [-168.755531, 52.907507],\n          [-168.688468, 52.9664],\n          [-168.613964, 53.008776],\n          [-168.457103, 53.055839],\n          [-168.412522, 53.110683],\n          [-168.343075, 53.170553],\n          [-168.296229, 53.227235],\n          [-168.092011, 53.28827],\n          [-167.959096, 53.341788],\n          [-167.842328, 53.386489],\n          [-167.856837, 53.428609],\n          [-167.808117, 53.473861],\n          [-167.789164, 53.519329],\n          [-167.914669, 53.522716],\n          [-168.027006, 53.562755],\n          [-168.238321, 53.521902],\n          [-168.342127, 53.475992],\n          [-168.395355, 53.397776],\n          [-168.420521, 53.322743],\n          [-168.445083, 53.26533],\n          [-168.581891, 53.286521],\n          [-168.763331, 53.182812],\n          [-168.804901, 53.120015],\n          [-168.785236, 53.045038],\n          [-168.861061, 53.016384],\n          [-168.95946, 52.936739],\n          [-169.044466, 52.893927],\n          [-169.28652, 52.784747],\n        ],\n      ],\n      [\n        [\n          [-169.81831, 56.633612],\n          [-169.685825, 56.539717],\n          [-169.582624, 56.536939],\n          [-169.453786, 56.583786],\n          [-169.474322, 56.625183],\n          [-169.613691, 56.622761],\n          [-169.81831, 56.633612],\n        ],\n      ],\n      [\n        [\n          [-170.170683, 52.784918],\n          [-170.207887, 52.708899],\n          [-170.077734, 52.720416],\n          [-169.951498, 52.788615],\n          [-169.818548, 52.791577],\n          [-169.703873, 52.777117],\n          [-169.666512, 52.864349],\n          [-169.662385, 52.951752],\n          [-169.680033, 53.035075],\n          [-169.747457, 53.0932],\n          [-169.820198, 53.06679],\n          [-169.76274, 52.97805],\n          [-169.857567, 52.908533],\n          [-170.026342, 52.944912],\n          [-170.092221, 52.919387],\n          [-170.170683, 52.784918],\n        ],\n      ],\n      [\n        [\n          [-170.420047, 57.212917],\n          [-170.421867, 57.161202],\n          [-170.286318, 57.128169],\n          [-170.133884, 57.181329],\n          [-170.143996, 57.242804],\n          [-170.303091, 57.238029],\n          [-170.420047, 57.212917],\n        ],\n      ],\n      [\n        [\n          [-170.817943, 52.636275],\n          [-170.841936, 52.558171],\n          [-170.788495, 52.54024],\n          [-170.685914, 52.581228],\n          [-170.58496, 52.587186],\n          [-170.532144, 52.679971],\n          [-170.671545, 52.698082],\n          [-170.817943, 52.636275],\n        ],\n      ],\n      [\n        [\n          [-171.312658, 52.493502],\n          [-171.30417, 52.449952],\n          [-171.226729, 52.434269],\n          [-171.196013, 52.500106],\n          [-171.256768, 52.52858],\n          [-171.312658, 52.493502],\n        ],\n      ],\n      [\n        [\n          [-171.83683, 63.564883],\n          [-171.849984, 63.485039],\n          [-171.760112, 63.381633],\n          [-171.667115, 63.356166],\n          [-171.528084, 63.324933],\n          [-171.433319, 63.307578],\n          [-171.285411, 63.366464],\n          [-171.226326, 63.395108],\n          [-171.067663, 63.424579],\n          [-170.896167, 63.417745],\n          [-170.663536, 63.376109],\n          [-170.430656, 63.314284],\n          [-170.30363, 63.238692],\n          [-170.263032, 63.179147],\n          [-170.186485, 63.181618],\n          [-170.049622, 63.163377],\n          [-169.88123, 63.105848],\n          [-169.788466, 63.043015],\n          [-169.757249, 62.960087],\n          [-169.638309, 62.937527],\n          [-169.568016, 62.976879],\n          [-169.576965, 63.027025],\n          [-169.534984, 63.074355],\n          [-169.436748, 63.113579],\n          [-169.230523, 63.172948],\n          [-169.07503, 63.177689],\n          [-168.93915, 63.137653],\n          [-168.841654, 63.153844],\n          [-168.751537, 63.217962],\n          [-168.685145, 63.296427],\n          [-168.937385, 63.333789],\n          [-169.087914, 63.340937],\n          [-169.462733, 63.360458],\n          [-169.566562, 63.388725],\n          [-169.656474, 63.429929],\n          [-169.857078, 63.441975],\n          [-170.007943, 63.475428],\n          [-170.048963, 63.537958],\n          [-170.095833, 63.612701],\n          [-170.176413, 63.625489],\n          [-170.26748, 63.675816],\n          [-170.344855, 63.694225],\n          [-170.488192, 63.696723],\n          [-170.606282, 63.672732],\n          [-170.859032, 63.587503],\n          [-170.950817, 63.570127],\n          [-171.309333, 63.621085],\n          [-171.552856, 63.666251],\n          [-171.58305, 63.715557],\n          [-171.613182, 63.785065],\n          [-171.743398, 63.782971],\n          [-171.802824, 63.716391],\n          [-171.791881, 63.620625],\n          [-171.83683, 63.564883],\n        ],\n      ],\n      [\n        [\n          [-172.612274, 52.306828],\n          [-172.639992, 52.244765],\n          [-172.528095, 52.254336],\n          [-172.414419, 52.27674],\n          [-172.301445, 52.329951],\n          [-172.326444, 52.366472],\n          [-172.448182, 52.391439],\n          [-172.545116, 52.357863],\n          [-172.612274, 52.306828],\n        ],\n      ],\n      [\n        [\n          [-173.074642, 60.704657],\n          [-173.115569, 60.658971],\n          [-173.0638, 60.502589],\n          [-172.895998, 60.450587],\n          [-172.630272, 60.334922],\n          [-172.416534, 60.314347],\n          [-172.254263, 60.297375],\n          [-172.238862, 60.336642],\n          [-172.380946, 60.382764],\n          [-172.545912, 60.412225],\n          [-172.847344, 60.516742],\n          [-172.912636, 60.604129],\n          [-173.074642, 60.704657],\n        ],\n      ],\n      [\n        [\n          [-175.301556, 52.055602],\n          [-175.323322, 52.007488],\n          [-175.155673, 52.011512],\n          [-175.014807, 52.007],\n          [-174.892306, 52.019687],\n          [-174.736592, 52.007308],\n          [-174.556278, 52.036733],\n          [-174.408693, 52.012811],\n          [-174.382661, 52.081658],\n          [-174.278279, 52.089489],\n          [-174.099836, 52.072078],\n          [-173.901075, 52.049435],\n          [-173.820692, 52.043312],\n          [-173.695316, 52.055319],\n          [-173.513047, 52.02531],\n          [-173.39397, 52.028674],\n          [-173.169557, 52.04385],\n          [-172.980222, 52.064049],\n          [-172.947811, 52.107371],\n          [-173.174403, 52.126278],\n          [-173.375229, 52.108228],\n          [-173.529923, 52.159364],\n          [-173.654404, 52.146192],\n          [-173.899966, 52.139949],\n          [-174.022638, 52.133713],\n          [-174.046994, 52.236262],\n          [-173.985203, 52.3176],\n          [-174.068248, 52.390331],\n          [-174.185347, 52.417788],\n          [-174.329818, 52.373548],\n          [-174.455979, 52.31369],\n          [-174.462962, 52.213031],\n          [-174.55467, 52.160405],\n          [-174.715205, 52.127375],\n          [-174.887242, 52.128602],\n          [-175.031213, 52.092109],\n          [-175.301556, 52.055602],\n        ],\n      ],\n      [\n        [\n          [-176.950128, 51.686719],\n          [-176.987383, 51.606872],\n          [-176.938917, 51.590982],\n          [-176.809, 51.616235],\n          [-176.715424, 51.620422],\n          [-176.656005, 51.658306],\n          [-176.543948, 51.698719],\n          [-176.46705, 51.726668],\n          [-176.289921, 51.741678],\n          [-176.158185, 51.768901],\n          [-175.998464, 51.801542],\n          [-175.963041, 51.846253],\n          [-175.789118, 51.919323],\n          [-175.639739, 51.933645],\n          [-175.424859, 51.972332],\n          [-175.45047, 52.012742],\n          [-175.664274, 51.993862],\n          [-175.807848, 51.989665],\n          [-175.887514, 51.995142],\n          [-176.007589, 52.066228],\n          [-176.055983, 52.109469],\n          [-176.14951, 52.11757],\n          [-176.211188, 52.064706],\n          [-176.183023, 51.998904],\n          [-176.168643, 51.948025],\n          [-176.173871, 51.882449],\n          [-176.311573, 51.872463],\n          [-176.431673, 51.861169],\n          [-176.576381, 51.842275],\n          [-176.554661, 51.909834],\n          [-176.549119, 51.955561],\n          [-176.579975, 52.003238],\n          [-176.698771, 51.964454],\n          [-176.774023, 51.965895],\n          [-176.810433, 51.927089],\n          [-176.762478, 51.867878],\n          [-176.781889, 51.832373],\n          [-176.917088, 51.797016],\n          [-176.950128, 51.686719],\n        ],\n      ],\n      [\n        [\n          [-177.670119, 51.743381],\n          [-177.707802, 51.703268],\n          [-177.651386, 51.653604],\n          [-177.483959, 51.682278],\n          [-177.34801, 51.696513],\n          [-177.275121, 51.68051],\n          [-177.18994, 51.697217],\n          [-177.105188, 51.719333],\n          [-177.098661, 51.829647],\n          [-177.04509, 51.898605],\n          [-177.099266, 51.936119],\n          [-177.181271, 51.943167],\n          [-177.199539, 51.910239],\n          [-177.228177, 51.803783],\n          [-177.313149, 51.778223],\n          [-177.492124, 51.770306],\n          [-177.670119, 51.743381],\n        ],\n      ],\n      [\n        [\n          [-178.19709, 51.905464],\n          [-178.224129, 51.864881],\n          [-178.086074, 51.808047],\n          [-177.995272, 51.781535],\n          [-177.98163, 51.715617],\n          [-178.054798, 51.704768],\n          [-178.117864, 51.677831],\n          [-178.04566, 51.630062],\n          [-177.909185, 51.596671],\n          [-177.86796, 51.679374],\n          [-177.827524, 51.712086],\n          [-177.755022, 51.772834],\n          [-177.649278, 51.801851],\n          [-177.615311, 51.85508],\n          [-177.757429, 51.847042],\n          [-177.887423, 51.85089],\n          [-177.952094, 51.915348],\n          [-178.090632, 51.919399],\n          [-178.19709, 51.905464],\n        ],\n      ],\n      [\n        [\n          [-178.889347, 51.570352],\n          [-178.825956, 51.547085],\n          [-178.734585, 51.542326],\n          [-178.584789, 51.56386],\n          [-178.551475, 51.610175],\n          [-178.678149, 51.62601],\n          [-178.889347, 51.570352],\n        ],\n      ],\n      [\n        [\n          [-178.876843, 51.837917],\n          [-178.895958, 51.779219],\n          [-178.792409, 51.746071],\n          [-178.733355, 51.783947],\n          [-178.779657, 51.851547],\n          [-178.876843, 51.837917],\n        ],\n      ],\n      [\n        [\n          [-179.174265, 51.279057],\n          [-179.126856, 51.219862],\n          [-179.07232, 51.250963],\n          [-178.908883, 51.340582],\n          [-178.926874, 51.38364],\n          [-178.995591, 51.414484],\n          [-179.174265, 51.279057],\n        ],\n      ],\n    ],\n  },\n};\n","import { processedHawaiiTopology } from \"@charts/chart-components/maps/topologies/hawaiiStateTopology\";\nimport { processedAlaskaTopology } from \"@charts/chart-components/maps/topologies/alaskaStateTopology\";\n\nexport const minFeatureName = \"_FeatureMin\";\nexport const maxFeatureName = \"_FeatureMax\";\n\nexport const stateCodeToName = (stateCode: string) => {\n  return stateMappings[stateCode] || stateCode;\n};\n\nconst transformedAlaskaTopology = processedAlaskaTopology;\nconst transformedHawaiiTopology = processedHawaiiTopology;\n\nexport const stateMappings: { [key: string]: string } = {\n  AL: \"Alabama\",\n  AK: \"Alaska\",\n  AZ: \"Arizona\",\n  AR: \"Arkansas\",\n  CA: \"California\",\n  CO: \"Colorado\",\n  CT: \"Connecticut\",\n  DE: \"Delaware\",\n  FL: \"Florida\",\n  GA: \"Georgia\",\n  HI: \"Hawaii\",\n  ID: \"Idaho\",\n  IL: \"Illinois\",\n  IN: \"Indiana\",\n  IA: \"Iowa\",\n  KS: \"Kansas\",\n  KY: \"Kentucky\",\n  LA: \"Louisiana\",\n  ME: \"Maine\",\n  MD: \"Maryland\",\n  MA: \"Massachusetts\",\n  MI: \"Michigan\",\n  MN: \"Minnesota\",\n  MS: \"Mississippi\",\n  MO: \"Missouri\",\n  MT: \"Montana\",\n  NE: \"Nebraska\",\n  NV: \"Nevada\",\n  NH: \"New Hampshire\",\n  NJ: \"New Jersey\",\n  NM: \"New Mexico\",\n  NY: \"New York\",\n  NC: \"North Carolina\",\n  ND: \"North Dakota\",\n  OH: \"Ohio\",\n  OK: \"Oklahoma\",\n  OR: \"Oregon\",\n  PA: \"Pennsylvania\",\n  RI: \"Rhode Island\",\n  SC: \"South Carolina\",\n  SD: \"South Dakota\",\n  TN: \"Tennessee\",\n  TX: \"Texas\",\n  UT: \"Utah\",\n  VT: \"Vermont\",\n  VA: \"Virginia\",\n  WA: \"Washington\",\n  WV: \"West Virginia\",\n  WI: \"Wisconsin\",\n  WY: \"Wyoming\",\n};\n\nexport const usStateTopology = {\n  type: \"FeatureCollection\",\n  features: [\n    {\n      type: \"Feature\",\n      geometry: {\n        type: \"Polygon\",\n        coordinates: [\n          [\n            [-79.477, 39.721],\n            [-79.477, 39.721],\n          ],\n        ],\n      },\n      properties: { name: minFeatureName },\n    },\n    {\n      type: \"Feature\",\n      geometry: {\n        type: \"Polygon\",\n        coordinates: [\n          [\n            [-79.477, 39.721],\n            [-79.477, 39.721],\n          ],\n        ],\n      },\n      properties: { name: maxFeatureName },\n    },\n    {\n      type: \"Feature\",\n      geometry: {\n        type: \"Polygon\",\n        coordinates: [\n          [\n            [-79.477, 39.721],\n            [-79.487, 39.206],\n            [-79.091, 39.472],\n            [-78.707, 39.556],\n            [-78.461, 39.526],\n            [-78.383, 39.622],\n            [-78.082, 39.671],\n            [-77.83, 39.587],\n            [-77.72, 39.321],\n            [-77.46, 39.219],\n            [-77.463, 39.076],\n            [-77.12, 38.934],\n            [-77.039, 38.792],\n            [-77.13, 38.635],\n            [-76.864, 38.269],\n            [-76.591, 38.214],\n            [-76.393, 38.24],\n            [-76.393, 38.389],\n            [-76.518, 38.539],\n            [-76.559, 38.756],\n            [-76.45, 38.941],\n            [-76.425, 39.206],\n            [-76.233, 39.091],\n            [-76.362, 38.939],\n            [-76.336, 38.492],\n            [-76.218, 38.306],\n            [-75.889, 38.241],\n            [-75.899, 37.975],\n            [-75.67, 37.951],\n            [-75.242, 38.027],\n            [-75.049, 38.451],\n            [-75.694, 38.46],\n            [-75.789, 39.722],\n            [-77.469, 39.72],\n            [-79.477, 39.721],\n          ],\n        ],\n      },\n      properties: { name: \"Maryland\" },\n    },\n    {\n      type: \"Feature\",\n      geometry: {\n        type: \"Polygon\",\n        coordinates: [\n          [\n            [-96.453, 43.5],\n            [-96.522, 43.221],\n            [-96.439, 43.114],\n            [-96.622, 42.779],\n            [-96.446, 42.491],\n            [-96.348, 42.167],\n            [-96.065, 41.793],\n            [-96.118, 41.613],\n            [-95.923, 41.456],\n            [-95.811, 40.887],\n            [-95.889, 40.736],\n            [-95.766, 40.585],\n            [-94.534, 40.571],\n            [-93.136, 40.583],\n            [-91.729, 40.614],\n            [-91.419, 40.378],\n            [-91.34, 40.613],\n            [-91.121, 40.673],\n            [-90.952, 40.954],\n            [-90.957, 41.111],\n            [-91.114, 41.25],\n            [-91.028, 41.424],\n            [-90.701, 41.455],\n            [-90.34, 41.599],\n            [-90.181, 41.812],\n            [-90.161, 42.106],\n            [-90.431, 42.278],\n            [-90.643, 42.508],\n            [-90.701, 42.626],\n            [-90.942, 42.684],\n            [-91.138, 42.904],\n            [-91.175, 43.135],\n            [-91.058, 43.254],\n            [-91.218, 43.501],\n            [-92.449, 43.5],\n            [-93.971, 43.5],\n            [-94.855, 43.501],\n            [-96.453, 43.5],\n          ],\n        ],\n      },\n      properties: { name: \"Iowa\" },\n    },\n    {\n      type: \"Feature\",\n      geometry: {\n        type: \"Polygon\",\n        coordinates: [\n          [\n            [-75.415, 39.802],\n            [-75.57, 39.839],\n            [-75.789, 39.722],\n            [-75.694, 38.46],\n            [-75.049, 38.451],\n            [-75.089, 38.797],\n            [-75.304, 38.913],\n            [-75.408, 39.265],\n            [-75.528, 39.498],\n            [-75.559, 39.63],\n            [-75.415, 39.802],\n          ],\n        ],\n      },\n      properties: { name: \"Delaware\" },\n    },\n    {\n      type: \"Feature\",\n      geometry: {\n        type: \"Polygon\",\n        coordinates: [\n          [\n            [-84.806, 41.696],\n            [-84.804, 40.353],\n            [-84.82, 39.105],\n            [-84.462, 39.122],\n            [-84.327, 39.027],\n            [-84.213, 38.806],\n            [-83.852, 38.751],\n            [-83.679, 38.63],\n            [-83.533, 38.702],\n            [-83.287, 38.599],\n            [-82.889, 38.756],\n            [-82.851, 38.604],\n            [-82.594, 38.422],\n            [-82.324, 38.449],\n            [-82.175, 38.608],\n            [-82.209, 38.803],\n            [-82.007, 39.03],\n            [-81.898, 38.93],\n            [-81.678, 39.274],\n            [-81.456, 39.409],\n            [-81.348, 39.346],\n            [-81.129, 39.449],\n            [-80.83, 39.712],\n            [-80.803, 39.919],\n            [-80.607, 40.304],\n            [-80.668, 40.582],\n            [-80.519, 40.639],\n            [-80.519, 41.978],\n            [-81.287, 41.76],\n            [-81.739, 41.489],\n            [-81.995, 41.514],\n            [-82.461, 41.386],\n            [-82.834, 41.588],\n            [-83.067, 41.595],\n            [-83.454, 41.733],\n            [-84.806, 41.696],\n          ],\n        ],\n      },\n      properties: { name: \"Ohio\" },\n    },\n    {\n      type: \"Feature\",\n      geometry: {\n        type: \"Polygon\",\n        coordinates: [\n          [\n            [-80.519, 41.978],\n            [-80.519, 40.639],\n            [-80.519, 39.721],\n            [-79.477, 39.721],\n            [-77.469, 39.72],\n            [-75.789, 39.722],\n            [-75.57, 39.839],\n            [-75.415, 39.802],\n            [-74.722, 40.154],\n            [-75.187, 40.569],\n            [-75.133, 40.98],\n            [-74.695, 41.357],\n            [-74.982, 41.496],\n            [-75.113, 41.841],\n            [-75.341, 41.993],\n            [-76.462, 41.999],\n            [-77.832, 41.999],\n            [-79.761, 41.999],\n            [-79.762, 42.27],\n            [-80.519, 41.978],\n          ],\n        ],\n      },\n      properties: { name: \"Pennsylvania\" },\n    },\n    {\n      type: \"Feature\",\n      geometry: {\n        type: \"Polygon\",\n        coordinates: [\n          [\n            [-104.053, 43.001],\n            [-104.053, 42.25],\n            [-104.053, 41.001],\n            [-102.052, 41.002],\n            [-102.052, 40.003],\n            [-101.06, 40.002],\n            [-99.813, 40.001],\n            [-98.076, 40.002],\n            [-96.47, 40.001],\n            [-95.308, 40],\n            [-95.473, 40.236],\n            [-95.654, 40.323],\n            [-95.766, 40.585],\n            [-95.889, 40.736],\n            [-95.811, 40.887],\n            [-95.923, 41.456],\n            [-96.118, 41.613],\n            [-96.065, 41.793],\n            [-96.348, 42.167],\n            [-96.446, 42.491],\n            [-96.611, 42.506],\n            [-96.698, 42.659],\n            [-97.131, 42.772],\n            [-97.238, 42.853],\n            [-97.858, 42.865],\n            [-97.95, 42.77],\n            [-98.435, 42.929],\n            [-98.499, 42.999],\n            [-100.198, 42.998],\n            [-102.082, 42.999],\n            [-104.053, 43.001],\n          ],\n        ],\n      },\n      properties: { name: \"Nebraska\" },\n    },\n    {\n      type: \"Feature\",\n      geometry: {\n        type: \"MultiPolygon\",\n        coordinates: [\n          [\n            [\n              [-123.237, 48.683],\n              [-123.141, 48.505],\n              [-122.874, 48.418],\n              [-122.743, 48.662],\n              [-122.938, 48.79],\n              [-123.237, 48.683],\n            ],\n          ],\n          [\n            [\n              [-117.032, 48.999],\n              [-118.837, 49],\n              [-120.001, 48.999],\n              [-121.751, 48.997],\n              [-122.758, 49.002],\n              [-122.643, 48.588],\n              [-122.76, 48.143],\n              [-123.004, 48.091],\n              [-124.051, 48.178],\n              [-124.653, 48.391],\n              [-124.722, 48.153],\n              [-124.672, 47.964],\n              [-124.412, 47.691],\n              [-124.319, 47.356],\n              [-124.236, 47.287],\n              [-124.081, 46.735],\n              [-124.081, 46.267],\n              [-123.548, 46.259],\n              [-123.28, 46.145],\n              [-123.116, 46.185],\n              [-122.814, 45.961],\n              [-122.775, 45.68],\n              [-122.263, 45.544],\n              [-121.811, 45.707],\n              [-121.533, 45.727],\n              [-121.085, 45.648],\n              [-120.591, 45.747],\n              [-120.211, 45.726],\n              [-119.966, 45.824],\n              [-119.126, 45.933],\n              [-118.987, 46],\n              [-116.916, 45.995],\n              [-117.036, 46.41],\n              [-117.042, 47.735],\n              [-117.032, 48.999],\n            ],\n          ],\n        ],\n      },\n      properties: { name: \"Washington\" },\n    },\n    {\n      type: \"Feature\",\n      geometry: {\n        type: \"Polygon\",\n        coordinates: [\n          [\n            [-88.2, 34.996],\n            [-88.098, 34.892],\n            [-88.317, 33.184],\n            [-88.469, 31.933],\n            [-88.395, 30.369],\n            [-88.136, 30.321],\n            [-88.062, 30.645],\n            [-87.797, 30.324],\n            [-87.518, 30.28],\n            [-87.452, 30.344],\n            [-87.4, 30.657],\n            [-87.635, 30.866],\n            [-87.599, 30.997],\n            [-85.894, 30.993],\n            [-85.002, 31.001],\n            [-85.108, 31.186],\n            [-85.042, 31.545],\n            [-85.142, 31.839],\n            [-85.059, 32.136],\n            [-84.892, 32.263],\n            [-85.184, 32.861],\n            [-85.429, 34.125],\n            [-85.605, 34.985],\n            [-86.784, 34.992],\n            [-88.2, 34.996],\n          ],\n        ],\n      },\n      properties: { name: \"Alabama\" },\n    },\n    {\n      type: \"Feature\",\n      geometry: {\n        type: \"Polygon\",\n        coordinates: [\n          [\n            [-94.618, 36.499],\n            [-94.432, 35.37],\n            [-94.486, 33.638],\n            [-94.354, 33.556],\n            [-94.043, 33.551],\n            [-94.043, 33.019],\n            [-92.223, 33.009],\n            [-91.166, 33.004],\n            [-91.069, 33.233],\n            [-91.216, 33.529],\n            [-91.027, 33.764],\n            [-91.061, 33.878],\n            [-90.895, 34.224],\n            [-90.575, 34.415],\n            [-90.587, 34.616],\n            [-90.474, 34.789],\n            [-90.25, 34.907],\n            [-90.309, 34.996],\n            [-90.091, 35.118],\n            [-90.122, 35.305],\n            [-89.958, 35.542],\n            [-89.957, 35.695],\n            [-89.723, 35.809],\n            [-89.733, 36.001],\n            [-90.369, 35.996],\n            [-90.064, 36.303],\n            [-90.154, 36.495],\n            [-91.127, 36.498],\n            [-92.35, 36.498],\n            [-93.959, 36.499],\n            [-94.618, 36.499],\n          ],\n        ],\n      },\n      properties: { name: \"Arkansas\" },\n    },\n    {\n      type: \"Feature\",\n      geometry: {\n        type: \"Polygon\",\n        coordinates: [\n          [\n            [-109.045, 36.999],\n            [-109.046, 36.117],\n            [-109.046, 34.96],\n            [-109.046, 33.875],\n            [-109.047, 32.778],\n            [-109.05, 31.333],\n            [-108.209, 31.333],\n            [-108.208, 31.784],\n            [-106.528, 31.783],\n            [-106.618, 32],\n            [-104.644, 32],\n            [-103.064, 32.001],\n            [-103.065, 32.849],\n            [-103.044, 34.079],\n            [-103.043, 35.183],\n            [-103.042, 36.5],\n            [-103.002, 36.5],\n            [-103.002, 37],\n            [-104.732, 36.993],\n            [-106.006, 36.995],\n            [-108.001, 37],\n            [-109.045, 36.999],\n          ],\n        ],\n      },\n      properties: { name: \"New Mexico\" },\n    },\n    {\n      type: \"Feature\",\n      geometry: {\n        type: \"Polygon\",\n        coordinates: [\n          [\n            [-103.002, 36.5],\n            [-103.042, 36.5],\n            [-103.043, 35.183],\n            [-103.044, 34.079],\n            [-103.065, 32.849],\n            [-103.064, 32.001],\n            [-104.644, 32],\n            [-106.618, 32],\n            [-106.528, 31.783],\n            [-106.418, 31.752],\n            [-106.176, 31.456],\n            [-105.954, 31.365],\n            [-105.773, 31.167],\n            [-105.315, 30.817],\n            [-105.001, 30.673],\n            [-104.86, 30.39],\n            [-104.703, 30.212],\n            [-104.672, 29.911],\n            [-104.54, 29.676],\n            [-104.144, 29.383],\n            [-103.789, 29.258],\n            [-103.281, 28.982],\n            [-102.871, 29.242],\n            [-102.809, 29.522],\n            [-102.677, 29.738],\n            [-102.393, 29.766],\n            [-102.301, 29.878],\n            [-101.966, 29.807],\n            [-101.401, 29.738],\n            [-101.255, 29.52],\n            [-101.06, 29.459],\n            [-100.675, 29.1],\n            [-100.5, 28.662],\n            [-100.397, 28.576],\n            [-100.268, 28.25],\n            [-99.932, 27.968],\n            [-99.845, 27.779],\n            [-99.557, 27.614],\n            [-99.43, 27.159],\n            [-99.447, 27.026],\n            [-99.269, 26.843],\n            [-99.111, 26.426],\n            [-98.807, 26.369],\n            [-98.654, 26.236],\n            [-98.443, 26.199],\n            [-98.197, 26.056],\n            [-97.795, 26.055],\n            [-97.423, 25.84],\n            [-97.146, 25.971],\n            [-97.197, 26.306],\n            [-97.323, 26.702],\n            [-97.379, 27.06],\n            [-97.296, 27.427],\n            [-97.141, 27.717],\n            [-96.886, 28.031],\n            [-96.194, 28.502],\n            [-95.382, 28.866],\n            [-95.026, 29.148],\n            [-94.723, 29.331],\n            [-94.595, 29.468],\n            [-94.057, 29.671],\n            [-93.838, 29.691],\n            [-93.929, 29.803],\n            [-93.704, 30.054],\n            [-93.729, 30.545],\n            [-93.531, 30.925],\n            [-93.535, 31.186],\n            [-93.835, 31.586],\n            [-93.803, 31.701],\n            [-94.042, 31.992],\n            [-94.043, 33.019],\n            [-94.043, 33.551],\n            [-94.354, 33.556],\n            [-94.486, 33.638],\n            [-94.842, 33.739],\n            [-95.226, 33.962],\n            [-95.283, 33.878],\n            [-95.557, 33.927],\n            [-96.152, 33.832],\n            [-96.363, 33.694],\n            [-96.593, 33.831],\n            [-96.851, 33.847],\n            [-96.952, 33.945],\n            [-97.206, 33.81],\n            [-97.444, 33.824],\n            [-97.672, 33.991],\n            [-97.866, 33.849],\n            [-98.099, 34.104],\n            [-98.364, 34.157],\n            [-98.737, 34.131],\n            [-99.19, 34.214],\n            [-99.275, 34.387],\n            [-99.696, 34.381],\n            [-100, 34.561],\n            [-100, 35.619],\n            [-100, 36.5],\n            [-101.624, 36.5],\n            [-103.002, 36.5],\n          ],\n        ],\n      },\n      properties: { name: \"Texas\" },\n    },\n    {\n      type: \"Feature\",\n      geometry: {\n        type: \"MultiPolygon\",\n        coordinates: [\n          [\n            [\n              [-120.368, 34.076],\n              [-120.122, 33.896],\n              [-120.055, 34.038],\n              [-120.368, 34.076],\n            ],\n          ],\n          [\n            [\n              [-124.212, 41.998],\n              [-124.063, 41.44],\n              [-124.164, 41.139],\n              [-124.118, 40.989],\n              [-124.41, 40.438],\n              [-124.363, 40.261],\n              [-124.087, 40.078],\n              [-123.852, 39.832],\n              [-123.766, 39.553],\n              [-123.825, 39.361],\n              [-123.691, 39.021],\n              [-123.711, 38.913],\n              [-123.166, 38.475],\n              [-123.004, 38.297],\n              [-122.94, 38.032],\n              [-122.537, 37.83],\n              [-122.394, 38.143],\n              [-122.263, 38.051],\n              [-122.313, 37.777],\n              [-122.163, 37.668],\n              [-122.517, 37.521],\n              [-122.397, 37.187],\n              [-122.106, 36.956],\n              [-121.906, 36.969],\n              [-121.792, 36.815],\n              [-121.97, 36.583],\n              [-121.888, 36.303],\n              [-121.68, 36.166],\n              [-121.272, 35.667],\n              [-121.003, 35.461],\n              [-120.897, 35.248],\n              [-120.636, 35.124],\n              [-120.61, 34.858],\n              [-120.646, 34.581],\n              [-120.451, 34.447],\n              [-120.141, 34.473],\n              [-119.874, 34.409],\n              [-119.617, 34.421],\n              [-119.27, 34.253],\n              [-119.11, 34.095],\n              [-118.805, 34.001],\n              [-118.52, 34.028],\n              [-118.397, 33.736],\n              [-118.133, 33.753],\n              [-117.646, 33.441],\n              [-117.446, 33.269],\n              [-117.281, 33.012],\n              [-117.282, 32.84],\n              [-117.125, 32.534],\n              [-115.465, 32.667],\n              [-114.72, 32.719],\n              [-114.469, 32.845],\n              [-114.511, 33.023],\n              [-114.671, 33.038],\n              [-114.707, 33.377],\n              [-114.525, 33.552],\n              [-114.535, 33.928],\n              [-114.428, 34.093],\n              [-114.139, 34.26],\n              [-114.335, 34.45],\n              [-114.465, 34.691],\n              [-114.634, 34.873],\n              [-114.633, 35.002],\n              [-115.648, 35.809],\n              [-116.488, 36.459],\n              [-117.681, 37.353],\n              [-118.95, 38.269],\n              [-120.001, 39],\n              [-119.998, 39.957],\n              [-120, 41.184],\n              [-119.999, 41.995],\n              [-121.035, 41.993],\n              [-122.501, 42.008],\n              [-124.212, 41.998],\n            ],\n          ],\n        ],\n      },\n      properties: { name: \"California\" },\n    },\n    {\n      type: \"Feature\",\n      geometry: {\n        type: \"Polygon\",\n        coordinates: [\n          [\n            [-89.133, 36.982],\n            [-89.165, 36.662],\n            [-89.539, 36.498],\n            [-88.05, 36.5],\n            [-88.071, 36.678],\n            [-87.853, 36.633],\n            [-86.508, 36.652],\n            [-85.874, 36.624],\n            [-84.785, 36.603],\n            [-83.675, 36.601],\n            [-83.136, 36.743],\n            [-82.895, 36.882],\n            [-82.726, 37.112],\n            [-82.355, 37.265],\n            [-81.968, 37.538],\n            [-82.296, 37.686],\n            [-82.626, 38.135],\n            [-82.594, 38.422],\n            [-82.851, 38.604],\n            [-82.889, 38.756],\n            [-83.287, 38.599],\n            [-83.533, 38.702],\n            [-83.679, 38.63],\n            [-83.852, 38.751],\n            [-84.213, 38.806],\n            [-84.327, 39.027],\n            [-84.462, 39.122],\n            [-84.82, 39.105],\n            [-84.786, 38.882],\n            [-85.187, 38.688],\n            [-85.449, 38.713],\n            [-85.416, 38.546],\n            [-85.816, 38.283],\n            [-85.922, 38.029],\n            [-86.206, 38.022],\n            [-86.321, 38.147],\n            [-86.722, 37.893],\n            [-86.811, 37.997],\n            [-87.18, 37.841],\n            [-87.419, 37.945],\n            [-87.626, 37.852],\n            [-87.873, 37.921],\n            [-88.028, 37.799],\n            [-88.16, 37.654],\n            [-88.062, 37.488],\n            [-88.466, 37.401],\n            [-88.476, 37.068],\n            [-88.932, 37.228],\n            [-89.168, 37.074],\n            [-89.133, 36.982],\n          ],\n        ],\n      },\n      properties: { name: \"Kentucky\" },\n    },\n    {\n      type: \"Feature\",\n      geometry: {\n        type: \"Polygon\",\n        coordinates: [\n          [\n            [-85.605, 34.985],\n            [-85.429, 34.125],\n            [-85.184, 32.861],\n            [-84.892, 32.263],\n            [-85.059, 32.136],\n            [-85.142, 31.839],\n            [-85.042, 31.545],\n            [-85.108, 31.186],\n            [-85.002, 31.001],\n            [-84.865, 30.712],\n            [-83.131, 30.624],\n            [-82.219, 30.564],\n            [-82.18, 30.369],\n            [-82.041, 30.37],\n            [-82.033, 30.751],\n            [-81.943, 30.827],\n            [-81.444, 30.71],\n            [-81.402, 31.125],\n            [-81.305, 31.206],\n            [-81.131, 31.723],\n            [-80.886, 32.035],\n            [-81.113, 32.113],\n            [-81.195, 32.465],\n            [-81.397, 32.606],\n            [-81.502, 33.015],\n            [-81.755, 33.152],\n            [-81.933, 33.344],\n            [-81.926, 33.463],\n            [-82.162, 33.611],\n            [-82.324, 33.82],\n            [-82.557, 33.945],\n            [-82.715, 34.148],\n            [-82.874, 34.472],\n            [-83.048, 34.493],\n            [-83.339, 34.682],\n            [-83.324, 34.79],\n            [-83.109, 35.001],\n            [-84.322, 34.988],\n            [-85.605, 34.985],\n          ],\n        ],\n      },\n      properties: { name: \"Georgia\" },\n    },\n    {\n      type: \"Feature\",\n      geometry: {\n        type: \"Polygon\",\n        coordinates: [\n          [\n            [-92.015, 46.706],\n            [-92.292, 46.663],\n            [-92.294, 46.074],\n            [-92.721, 45.884],\n            [-92.87, 45.715],\n            [-92.647, 45.438],\n            [-92.762, 45.285],\n            [-92.751, 44.942],\n            [-92.805, 44.768],\n            [-92.549, 44.578],\n            [-91.964, 44.362],\n            [-91.893, 44.231],\n            [-91.441, 44.002],\n            [-91.244, 43.773],\n            [-91.218, 43.501],\n            [-91.058, 43.254],\n            [-91.175, 43.135],\n            [-91.138, 42.904],\n            [-90.942, 42.684],\n            [-90.701, 42.626],\n            [-90.643, 42.508],\n            [-88.707, 42.494],\n            [-87.8, 42.492],\n            [-87.767, 42.785],\n            [-87.896, 43.016],\n            [-87.889, 43.308],\n            [-87.706, 43.68],\n            [-87.736, 43.874],\n            [-87.447, 44.586],\n            [-87.063, 45.079],\n            [-87.265, 45.081],\n            [-87.581, 44.852],\n            [-87.775, 44.639],\n            [-87.983, 44.72],\n            [-87.813, 44.954],\n            [-87.59, 45.095],\n            [-87.863, 45.353],\n            [-87.781, 45.674],\n            [-88.135, 45.822],\n            [-88.115, 45.922],\n            [-88.527, 46.021],\n            [-88.812, 46.022],\n            [-89.092, 46.139],\n            [-90.12, 46.337],\n            [-90.215, 46.5],\n            [-90.418, 46.566],\n            [-90.755, 46.646],\n            [-90.881, 46.74],\n            [-90.745, 46.894],\n            [-90.924, 47.002],\n            [-91.168, 46.845],\n            [-91.82, 46.69],\n            [-92.015, 46.706],\n          ],\n        ],\n      },\n      properties: { name: \"Wisconsin\" },\n    },\n    {\n      type: \"Feature\",\n      geometry: {\n        type: \"Polygon\",\n        coordinates: [\n          [\n            [-123.548, 46.259],\n            [-123.959, 46.142],\n            [-123.939, 45.709],\n            [-123.975, 45.145],\n            [-124.074, 44.798],\n            [-124.065, 44.633],\n            [-124.15, 43.911],\n            [-124.234, 43.557],\n            [-124.552, 42.841],\n            [-124.413, 42.658],\n            [-124.411, 42.251],\n            [-124.212, 41.998],\n            [-122.501, 42.008],\n            [-121.035, 41.993],\n            [-119.999, 41.995],\n            [-118.776, 41.993],\n            [-117.026, 42],\n            [-117.024, 43.824],\n            [-116.896, 44.154],\n            [-117.243, 44.391],\n            [-117.062, 44.727],\n            [-116.834, 44.929],\n            [-116.675, 45.314],\n            [-116.464, 45.616],\n            [-116.593, 45.779],\n            [-116.788, 45.84],\n            [-116.916, 45.995],\n            [-118.987, 46],\n            [-119.126, 45.933],\n            [-119.966, 45.824],\n            [-120.211, 45.726],\n            [-120.591, 45.747],\n            [-121.085, 45.648],\n            [-121.533, 45.727],\n            [-121.811, 45.707],\n            [-122.263, 45.544],\n            [-122.775, 45.68],\n            [-122.814, 45.961],\n            [-123.116, 46.185],\n            [-123.28, 46.145],\n            [-123.548, 46.259],\n          ],\n        ],\n      },\n      properties: { name: \"Oregon\" },\n    },\n    {\n      type: \"Feature\",\n      geometry: {\n        type: \"Polygon\",\n        coordinates: [\n          [\n            [-95.766, 40.585],\n            [-95.654, 40.323],\n            [-95.473, 40.236],\n            [-95.308, 40],\n            [-94.86, 39.75],\n            [-95.114, 39.554],\n            [-94.8, 39.206],\n            [-94.607, 39.113],\n            [-94.613, 38.238],\n            [-94.618, 36.999],\n            [-94.618, 36.499],\n            [-93.959, 36.499],\n            [-92.35, 36.498],\n            [-91.127, 36.498],\n            [-90.154, 36.495],\n            [-90.064, 36.303],\n            [-90.369, 35.996],\n            [-89.733, 36.001],\n            [-89.523, 36.345],\n            [-89.539, 36.498],\n            [-89.165, 36.662],\n            [-89.133, 36.982],\n            [-89.359, 37.043],\n            [-89.495, 37.325],\n            [-89.522, 37.696],\n            [-90.219, 38.094],\n            [-90.373, 38.323],\n            [-90.185, 38.612],\n            [-90.113, 38.849],\n            [-90.468, 38.962],\n            [-90.657, 38.92],\n            [-90.73, 39.256],\n            [-91.038, 39.448],\n            [-91.368, 39.729],\n            [-91.512, 40.17],\n            [-91.419, 40.378],\n            [-91.729, 40.614],\n            [-93.136, 40.583],\n            [-94.534, 40.571],\n            [-95.766, 40.585],\n          ],\n        ],\n      },\n      properties: { name: \"Missouri\" },\n    },\n    {\n      type: \"Feature\",\n      geometry: {\n        type: \"MultiPolygon\",\n        coordinates: [\n          [\n            [\n              [-75.67, 37.951],\n              [-75.941, 37.564],\n              [-76.023, 37.289],\n              [-75.817, 37.193],\n              [-75.658, 37.452],\n              [-75.552, 37.748],\n              [-75.242, 38.027],\n              [-75.67, 37.951],\n            ],\n          ],\n          [\n            [\n              [-81.968, 37.538],\n              [-82.355, 37.265],\n              [-82.726, 37.112],\n              [-82.895, 36.882],\n              [-83.136, 36.743],\n              [-83.675, 36.601],\n              [-81.678, 36.588],\n              [-80.295, 36.544],\n              [-78.51, 36.541],\n              [-76.917, 36.546],\n              [-75.867, 36.551],\n              [-75.996, 36.922],\n              [-76.268, 36.965],\n              [-76.394, 37.225],\n              [-76.25, 37.422],\n              [-76.329, 37.671],\n              [-76.237, 37.889],\n              [-76.614, 38.149],\n              [-76.962, 38.214],\n              [-77.048, 38.36],\n              [-77.265, 38.333],\n              [-77.323, 38.467],\n              [-77.13, 38.635],\n              [-77.039, 38.792],\n              [-77.12, 38.934],\n              [-77.463, 39.076],\n              [-77.46, 39.219],\n              [-77.72, 39.321],\n              [-77.828, 39.132],\n              [-78.347, 39.466],\n              [-78.414, 39.158],\n              [-78.773, 38.894],\n              [-78.999, 38.84],\n              [-79.298, 38.416],\n              [-79.649, 38.592],\n              [-79.788, 38.273],\n              [-80.292, 37.684],\n              [-80.292, 37.537],\n              [-80.545, 37.475],\n              [-80.919, 37.306],\n              [-81.225, 37.235],\n              [-81.362, 37.338],\n              [-81.561, 37.207],\n              [-81.85, 37.285],\n              [-81.968, 37.538],\n            ],\n          ],\n        ],\n      },\n      properties: { name: \"Virginia\" },\n    },\n    {\n      type: \"Feature\",\n      geometry: {\n        type: \"Polygon\",\n        coordinates: [\n          [\n            [-89.733, 36.001],\n            [-89.723, 35.809],\n            [-89.957, 35.695],\n            [-89.958, 35.542],\n            [-90.122, 35.305],\n            [-90.091, 35.118],\n            [-90.309, 34.996],\n            [-89.435, 34.994],\n            [-88.2, 34.996],\n            [-86.784, 34.992],\n            [-85.605, 34.985],\n            [-84.322, 34.988],\n            [-84.283, 35.227],\n            [-84.098, 35.247],\n            [-84.022, 35.407],\n            [-83.772, 35.562],\n            [-83.498, 35.563],\n            [-83.162, 35.763],\n            [-82.978, 35.783],\n            [-82.779, 35.993],\n            [-82.211, 36.159],\n            [-82.029, 36.124],\n            [-81.908, 36.302],\n            [-81.734, 36.413],\n            [-81.678, 36.588],\n            [-83.675, 36.601],\n            [-84.785, 36.603],\n            [-85.874, 36.624],\n            [-86.508, 36.652],\n            [-87.853, 36.633],\n            [-88.071, 36.678],\n            [-88.05, 36.5],\n            [-89.539, 36.498],\n            [-89.523, 36.345],\n            [-89.733, 36.001],\n          ],\n        ],\n      },\n      properties: { name: \"Tennessee\" },\n    },\n    {\n      type: \"Feature\",\n      geometry: {\n        type: \"Polygon\",\n        coordinates: [\n          [\n            [-94.043, 33.019],\n            [-94.042, 31.992],\n            [-93.803, 31.701],\n            [-93.835, 31.586],\n            [-93.535, 31.186],\n            [-93.531, 30.925],\n            [-93.729, 30.545],\n            [-93.704, 30.054],\n            [-93.929, 29.803],\n            [-93.838, 29.691],\n            [-93.538, 29.763],\n            [-93.177, 29.77],\n            [-92.684, 29.605],\n            [-92.323, 29.531],\n            [-92.065, 29.586],\n            [-91.822, 29.474],\n            [-91.711, 29.569],\n            [-91.394, 29.497],\n            [-91.279, 29.248],\n            [-90.942, 29.162],\n            [-90.868, 29.056],\n            [-90.224, 29.085],\n            [-89.843, 29.319],\n            [-89.483, 29.215],\n            [-89.361, 29.072],\n            [-89.149, 29.03],\n            [-89.014, 29.167],\n            [-89.2, 29.344],\n            [-89.482, 29.406],\n            [-89.602, 29.61],\n            [-89.404, 29.682],\n            [-89.236, 29.877],\n            [-89.186, 30.064],\n            [-89.445, 30.061],\n            [-89.702, 29.874],\n            [-89.845, 30.018],\n            [-89.525, 30.181],\n            [-89.608, 30.217],\n            [-89.836, 30.727],\n            [-89.728, 31.002],\n            [-90.759, 31],\n            [-91.56, 31.05],\n            [-91.644, 31.234],\n            [-91.536, 31.338],\n            [-91.36, 31.799],\n            [-91.035, 32.101],\n            [-90.921, 32.342],\n            [-91.053, 32.438],\n            [-91.114, 32.74],\n            [-91.072, 32.938],\n            [-91.166, 33.004],\n            [-92.223, 33.009],\n            [-94.043, 33.019],\n          ],\n        ],\n      },\n      properties: { name: \"Louisiana\" },\n    },\n    {\n      type: \"Feature\",\n      geometry: {\n        type: \"Polygon\",\n        coordinates: [\n          [\n            [-79.762, 42.27],\n            [-79.761, 41.999],\n            [-77.832, 41.999],\n            [-76.462, 41.999],\n            [-75.341, 41.993],\n            [-75.113, 41.841],\n            [-74.982, 41.496],\n            [-74.695, 41.357],\n            [-73.894, 40.997],\n            [-74.087, 40.652],\n            [-74.261, 40.502],\n            [-73.013, 40.68],\n            [-71.937, 41.006],\n            [-72.283, 41.068],\n            [-72.585, 40.998],\n            [-73.11, 40.972],\n            [-73.229, 40.905],\n            [-73.657, 40.985],\n            [-73.728, 41.101],\n            [-73.551, 41.295],\n            [-73.487, 42.05],\n            [-73.508, 42.086],\n            [-73.265, 42.746],\n            [-73.242, 43.535],\n            [-73.415, 43.658],\n            [-73.351, 43.77],\n            [-73.437, 44.043],\n            [-73.294, 44.441],\n            [-73.39, 44.62],\n            [-73.343, 45.011],\n            [-74.234, 44.992],\n            [-74.835, 45.015],\n            [-75.256, 44.858],\n            [-75.766, 44.516],\n            [-75.95, 44.349],\n            [-76.287, 44.204],\n            [-76.412, 43.926],\n            [-76.229, 43.804],\n            [-76.236, 43.529],\n            [-76.418, 43.521],\n            [-76.685, 43.353],\n            [-76.952, 43.271],\n            [-77.341, 43.281],\n            [-77.551, 43.236],\n            [-77.76, 43.341],\n            [-78.547, 43.37],\n            [-79.07, 43.262],\n            [-79.074, 43.078],\n            [-78.851, 42.792],\n            [-79.139, 42.564],\n            [-79.762, 42.27],\n          ],\n        ],\n      },\n      properties: { name: \"New York\" },\n    },\n    {\n      type: \"Feature\",\n      geometry: {\n        type: \"MultiPolygon\",\n        coordinates: [\n          [\n            [\n              [-83.454, 41.733],\n              [-83.442, 41.809],\n              [-83.134, 42.088],\n              [-83.097, 42.29],\n              [-82.924, 42.352],\n              [-82.859, 42.542],\n              [-82.679, 42.522],\n              [-82.51, 42.637],\n              [-82.416, 43.006],\n              [-82.523, 43.225],\n              [-82.634, 43.831],\n              [-82.929, 44.069],\n              [-83.407, 43.92],\n              [-83.683, 43.591],\n              [-83.948, 43.735],\n              [-83.869, 43.961],\n              [-83.584, 44.057],\n              [-83.525, 44.262],\n              [-83.337, 44.333],\n              [-83.266, 45.027],\n              [-83.385, 45.274],\n              [-84.196, 45.621],\n              [-84.462, 45.652],\n              [-84.719, 45.778],\n              [-84.867, 45.752],\n              [-85.12, 45.569],\n              [-85.041, 45.437],\n              [-85.372, 45.271],\n              [-85.381, 45.046],\n              [-86.059, 44.911],\n              [-86.089, 44.741],\n              [-86.248, 44.699],\n              [-86.269, 44.345],\n              [-86.515, 44.058],\n              [-86.431, 43.841],\n              [-86.541, 43.645],\n              [-86.255, 43.083],\n              [-86.208, 42.763],\n              [-86.356, 42.254],\n              [-86.598, 41.918],\n              [-86.825, 41.76],\n              [-84.806, 41.76],\n              [-84.806, 41.696],\n              [-83.454, 41.733],\n            ],\n          ],\n          [\n            [\n              [-89.221, 47.908],\n              [-89.158, 47.824],\n              [-88.579, 48.041],\n              [-88.632, 48.148],\n              [-89.221, 47.908],\n            ],\n          ],\n          [\n            [\n              [-90.418, 46.566],\n              [-90.215, 46.5],\n              [-90.12, 46.337],\n              [-89.092, 46.139],\n              [-88.812, 46.022],\n              [-88.527, 46.021],\n              [-88.115, 45.922],\n              [-88.135, 45.822],\n              [-87.781, 45.674],\n              [-87.863, 45.353],\n              [-87.59, 45.095],\n              [-87.172, 45.662],\n              [-86.964, 45.673],\n              [-86.773, 45.811],\n              [-86.541, 45.708],\n              [-86.278, 45.942],\n              [-85.914, 45.919],\n              [-85.541, 46.08],\n              [-85.152, 46.051],\n              [-84.793, 45.859],\n              [-84.633, 45.951],\n              [-84.08, 45.971],\n              [-83.526, 45.919],\n              [-83.599, 46.09],\n              [-83.882, 46.042],\n              [-84.115, 46.174],\n              [-84.118, 46.518],\n              [-84.969, 46.476],\n              [-85.028, 46.675],\n              [-85.257, 46.753],\n              [-85.482, 46.68],\n              [-86.138, 46.673],\n              [-86.558, 46.487],\n              [-86.811, 46.45],\n              [-86.977, 46.527],\n              [-87.367, 46.507],\n              [-87.595, 46.783],\n              [-88.144, 46.967],\n              [-88.455, 46.923],\n              [-88.194, 47.209],\n              [-87.943, 47.336],\n              [-87.929, 47.479],\n              [-88.218, 47.449],\n              [-89.415, 46.844],\n              [-89.832, 46.804],\n              [-90.045, 46.668],\n              [-90.418, 46.566],\n            ],\n          ],\n        ],\n      },\n      properties: { name: \"Michigan\" },\n    },\n    transformedHawaiiTopology,\n    {\n      type: \"Feature\",\n      geometry: {\n        type: \"Polygon\",\n        coordinates: [\n          [\n            [-116.916, 45.995],\n            [-116.788, 45.84],\n            [-116.593, 45.779],\n            [-116.464, 45.616],\n            [-116.675, 45.314],\n            [-116.834, 44.929],\n            [-117.062, 44.727],\n            [-117.243, 44.391],\n            [-116.896, 44.154],\n            [-117.024, 43.824],\n            [-117.026, 42],\n            [-115.87, 41.997],\n            [-114.042, 41.994],\n            [-112.11, 41.998],\n            [-111.047, 42.002],\n            [-111.045, 43.316],\n            [-111.049, 44.474],\n            [-111.324, 44.724],\n            [-111.563, 44.555],\n            [-112.473, 44.48],\n            [-113.007, 44.472],\n            [-113.131, 44.765],\n            [-113.422, 44.843],\n            [-113.452, 45.059],\n            [-113.736, 45.325],\n            [-113.807, 45.602],\n            [-113.972, 45.701],\n            [-114.279, 45.481],\n            [-114.506, 45.559],\n            [-114.402, 45.961],\n            [-114.48, 46.03],\n            [-114.422, 46.387],\n            [-114.321, 46.647],\n            [-114.547, 46.644],\n            [-114.943, 46.868],\n            [-115.327, 47.256],\n            [-115.71, 47.418],\n            [-115.724, 47.697],\n            [-116.049, 48],\n            [-116.049, 49.001],\n            [-117.032, 48.999],\n            [-117.042, 47.735],\n            [-117.036, 46.41],\n            [-116.916, 45.995],\n          ],\n        ],\n      },\n      properties: { name: \"Idaho\" },\n    },\n    {\n      type: \"Feature\",\n      geometry: {\n        type: \"MultiPolygon\",\n        coordinates: [\n          [\n            [\n              [-81.812, 24.569],\n              [-81.685, 24.559],\n              [-81.243, 24.674],\n              [-81.444, 24.813],\n              [-81.751, 24.654],\n              [-81.812, 24.569],\n            ],\n          ],\n          [\n            [\n              [-85.002, 31.001],\n              [-85.894, 30.993],\n              [-87.599, 30.997],\n              [-87.635, 30.866],\n              [-87.4, 30.657],\n              [-87.452, 30.344],\n              [-87.518, 30.28],\n              [-86.633, 30.396],\n              [-86.223, 30.344],\n              [-86, 30.271],\n              [-85.385, 29.921],\n              [-85.353, 29.66],\n              [-85.045, 29.587],\n              [-84.565, 29.81],\n              [-84.29, 30.057],\n              [-84.063, 30.101],\n              [-83.679, 29.919],\n              [-83.402, 29.523],\n              [-83.17, 29.29],\n              [-82.824, 29.099],\n              [-82.657, 28.545],\n              [-82.764, 28.244],\n              [-82.86, 28.174],\n              [-82.847, 27.854],\n              [-82.705, 27.625],\n              [-82.692, 27.437],\n              [-82.54, 27.254],\n              [-82.265, 26.757],\n              [-82.181, 26.476],\n              [-81.924, 26.437],\n              [-81.845, 26.328],\n              [-81.727, 25.907],\n              [-81.384, 25.777],\n              [-81.147, 25.408],\n              [-81.171, 25.246],\n              [-81.08, 25.119],\n              [-80.812, 25.186],\n              [-80.495, 25.2],\n              [-80.358, 25.153],\n              [-80.301, 25.613],\n              [-80.11, 25.818],\n              [-80.11, 26.087],\n              [-80.039, 26.569],\n              [-80.046, 26.859],\n              [-80.384, 27.74],\n              [-80.548, 28.049],\n              [-80.607, 28.336],\n              [-80.525, 28.459],\n              [-80.584, 28.598],\n              [-80.966, 29.148],\n              [-81.257, 29.785],\n              [-81.396, 30.34],\n              [-81.444, 30.71],\n              [-81.943, 30.827],\n              [-82.033, 30.751],\n              [-82.041, 30.37],\n              [-82.18, 30.369],\n              [-82.219, 30.564],\n              [-83.131, 30.624],\n              [-84.865, 30.712],\n              [-85.002, 31.001],\n            ],\n          ],\n        ],\n      },\n      properties: { name: \"Florida\" },\n    },\n    {\n      type: \"Feature\",\n      geometry: {\n        type: \"Polygon\",\n        coordinates: [\n          [\n            [-91.419, 40.378],\n            [-91.512, 40.17],\n            [-91.368, 39.729],\n            [-91.038, 39.448],\n            [-90.73, 39.256],\n            [-90.657, 38.92],\n            [-90.468, 38.962],\n            [-90.113, 38.849],\n            [-90.185, 38.612],\n            [-90.373, 38.323],\n            [-90.219, 38.094],\n            [-89.522, 37.696],\n            [-89.495, 37.325],\n            [-89.359, 37.043],\n            [-89.133, 36.982],\n            [-89.168, 37.074],\n            [-88.932, 37.228],\n            [-88.476, 37.068],\n            [-88.466, 37.401],\n            [-88.062, 37.488],\n            [-88.16, 37.654],\n            [-88.028, 37.799],\n            [-88.031, 38.031],\n            [-87.499, 38.758],\n            [-87.625, 39.102],\n            [-87.532, 39.348],\n            [-87.526, 40.535],\n            [-87.524, 41.708],\n            [-87.682, 42.076],\n            [-87.835, 42.302],\n            [-87.8, 42.492],\n            [-88.707, 42.494],\n            [-90.643, 42.508],\n            [-90.431, 42.278],\n            [-90.161, 42.106],\n            [-90.181, 41.812],\n            [-90.34, 41.599],\n            [-90.701, 41.455],\n            [-91.028, 41.424],\n            [-91.114, 41.25],\n            [-90.957, 41.111],\n            [-90.952, 40.954],\n            [-91.121, 40.673],\n            [-91.34, 40.613],\n            [-91.419, 40.378],\n          ],\n        ],\n      },\n      properties: { name: \"Illinois\" },\n    },\n    {\n      type: \"Feature\",\n      geometry: {\n        type: \"Polygon\",\n        coordinates: [\n          [\n            [-116.049, 49.001],\n            [-116.049, 48],\n            [-115.724, 47.697],\n            [-115.71, 47.418],\n            [-115.327, 47.256],\n            [-114.943, 46.868],\n            [-114.547, 46.644],\n            [-114.321, 46.647],\n            [-114.422, 46.387],\n            [-114.48, 46.03],\n            [-114.402, 45.961],\n            [-114.506, 45.559],\n            [-114.279, 45.481],\n            [-113.972, 45.701],\n            [-113.807, 45.602],\n            [-113.736, 45.325],\n            [-113.452, 45.059],\n            [-113.422, 44.843],\n            [-113.131, 44.765],\n            [-113.007, 44.472],\n            [-112.473, 44.48],\n            [-111.563, 44.555],\n            [-111.324, 44.724],\n            [-111.049, 44.474],\n            [-111.044, 45.001],\n            [-108.621, 45],\n            [-106.264, 44.994],\n            [-104.058, 44.997],\n            [-104.045, 45.945],\n            [-104.042, 47.803],\n            [-104.049, 49],\n            [-106.051, 48.999],\n            [-107.441, 48.999],\n            [-109.001, 48.999],\n            [-111.501, 48.997],\n            [-113.693, 48.998],\n            [-116.049, 49.001],\n          ],\n        ],\n      },\n      properties: { name: \"Montana\" },\n    },\n    {\n      type: \"Feature\",\n      geometry: {\n        type: \"Polygon\",\n        coordinates: [\n          [\n            [-97.229, 49.001],\n            [-97.1, 48.668],\n            [-97.147, 48.169],\n            [-96.854, 47.572],\n            [-96.791, 46.637],\n            [-96.601, 46.32],\n            [-96.564, 45.935],\n            [-96.587, 45.816],\n            [-96.826, 45.654],\n            [-96.711, 45.437],\n            [-96.458, 45.308],\n            [-96.453, 43.5],\n            [-94.855, 43.501],\n            [-93.971, 43.5],\n            [-92.449, 43.5],\n            [-91.218, 43.501],\n            [-91.244, 43.773],\n            [-91.441, 44.002],\n            [-91.893, 44.231],\n            [-91.964, 44.362],\n            [-92.549, 44.578],\n            [-92.805, 44.768],\n            [-92.751, 44.942],\n            [-92.762, 45.285],\n            [-92.647, 45.438],\n            [-92.87, 45.715],\n            [-92.721, 45.884],\n            [-92.294, 46.074],\n            [-92.292, 46.663],\n            [-92.015, 46.706],\n            [-92.062, 46.804],\n            [-91.457, 47.139],\n            [-90.868, 47.557],\n            [-90.537, 47.703],\n            [-89.974, 47.831],\n            [-89.868, 47.99],\n            [-90.136, 48.112],\n            [-90.704, 48.096],\n            [-90.844, 48.244],\n            [-91.25, 48.084],\n            [-91.543, 48.053],\n            [-91.715, 48.199],\n            [-91.981, 48.248],\n            [-92.955, 48.631],\n            [-93.207, 48.642],\n            [-93.468, 48.546],\n            [-93.815, 48.527],\n            [-93.844, 48.629],\n            [-94.447, 48.693],\n            [-94.694, 48.789],\n            [-94.816, 49.321],\n            [-95.153, 49.384],\n            [-95.154, 48.999],\n            [-97.229, 49.001],\n          ],\n        ],\n      },\n      properties: { name: \"Minnesota\" },\n    },\n    {\n      type: \"Feature\",\n      geometry: {\n        type: \"Polygon\",\n        coordinates: [\n          [\n            [-87.524, 41.708],\n            [-87.526, 40.535],\n            [-87.532, 39.348],\n            [-87.625, 39.102],\n            [-87.499, 38.758],\n            [-88.031, 38.031],\n            [-88.028, 37.799],\n            [-87.873, 37.921],\n            [-87.626, 37.852],\n            [-87.419, 37.945],\n            [-87.18, 37.841],\n            [-86.811, 37.997],\n            [-86.722, 37.893],\n            [-86.321, 38.147],\n            [-86.206, 38.022],\n            [-85.922, 38.029],\n            [-85.816, 38.283],\n            [-85.416, 38.546],\n            [-85.449, 38.713],\n            [-85.187, 38.688],\n            [-84.786, 38.882],\n            [-84.82, 39.105],\n            [-84.804, 40.353],\n            [-84.806, 41.696],\n            [-84.806, 41.76],\n            [-86.825, 41.76],\n            [-87.262, 41.62],\n            [-87.524, 41.708],\n          ],\n        ],\n      },\n      properties: { name: \"Indiana\" },\n    },\n    {\n      type: \"Feature\",\n      geometry: {\n        type: \"Polygon\",\n        coordinates: [\n          [\n            [-73.265, 42.746],\n            [-73.508, 42.086],\n            [-73.487, 42.05],\n            [-71.799, 42.008],\n            [-71.381, 42.019],\n            [-71.329, 41.783],\n            [-71.133, 41.66],\n            [-71.121, 41.497],\n            [-70.91, 41.577],\n            [-70.734, 41.486],\n            [-70.322, 41.631],\n            [-70.662, 41.961],\n            [-70.731, 42.211],\n            [-70.975, 42.356],\n            [-70.655, 42.582],\n            [-70.817, 42.872],\n            [-71.15, 42.815],\n            [-71.294, 42.697],\n            [-72.459, 42.727],\n            [-73.265, 42.746],\n          ],\n        ],\n      },\n      properties: { name: \"Massachusetts\" },\n    },\n    {\n      type: \"Feature\",\n      geometry: {\n        type: \"Polygon\",\n        coordinates: [\n          [\n            [-102.052, 40.003],\n            [-102.046, 38.698],\n            [-102.042, 36.993],\n            [-100.856, 36.999],\n            [-99.129, 36.999],\n            [-97.462, 36.999],\n            [-95.787, 36.999],\n            [-94.618, 36.999],\n            [-94.613, 38.238],\n            [-94.607, 39.113],\n            [-94.8, 39.206],\n            [-95.114, 39.554],\n            [-94.86, 39.75],\n            [-95.308, 40],\n            [-96.47, 40.001],\n            [-98.076, 40.002],\n            [-99.813, 40.001],\n            [-101.06, 40.002],\n            [-102.052, 40.003],\n          ],\n        ],\n      },\n      properties: { name: \"Kansas\" },\n    },\n    {\n      type: \"Feature\",\n      geometry: {\n        type: \"Polygon\",\n        coordinates: [\n          [\n            [-119.999, 41.995],\n            [-120, 41.184],\n            [-119.998, 39.957],\n            [-120.001, 39],\n            [-118.95, 38.269],\n            [-117.681, 37.353],\n            [-116.488, 36.459],\n            [-115.648, 35.809],\n            [-114.633, 35.002],\n            [-114.573, 35.139],\n            [-114.664, 35.449],\n            [-114.736, 36.104],\n            [-114.372, 36.143],\n            [-114.152, 36.025],\n            [-114.047, 36.194],\n            [-114.051, 37],\n            [-114.05, 37.881],\n            [-114.049, 39.006],\n            [-114.046, 40.398],\n            [-114.042, 41.994],\n            [-115.87, 41.997],\n            [-117.026, 42],\n            [-118.776, 41.993],\n            [-119.999, 41.995],\n          ],\n        ],\n      },\n      properties: { name: \"Nevada\" },\n    },\n    {\n      type: \"Feature\",\n      geometry: {\n        type: \"Polygon\",\n        coordinates: [\n          [\n            [-73.343, 45.011],\n            [-73.39, 44.62],\n            [-73.294, 44.441],\n            [-73.437, 44.043],\n            [-73.351, 43.77],\n            [-73.415, 43.658],\n            [-73.242, 43.535],\n            [-73.265, 42.746],\n            [-72.459, 42.727],\n            [-72.54, 42.805],\n            [-72.445, 43.004],\n            [-72.379, 43.574],\n            [-72.183, 43.808],\n            [-72.037, 44.103],\n            [-72.046, 44.292],\n            [-71.819, 44.353],\n            [-71.58, 44.502],\n            [-71.627, 44.747],\n            [-71.501, 45.013],\n            [-72.349, 45.006],\n            [-73.343, 45.011],\n          ],\n        ],\n      },\n      properties: { name: \"Vermont\" },\n    },\n    {\n      type: \"Feature\",\n      geometry: {\n        type: \"Polygon\",\n        coordinates: [\n          [\n            [-73.487, 42.05],\n            [-73.551, 41.295],\n            [-73.728, 41.101],\n            [-73.657, 40.985],\n            [-73.422, 41.048],\n            [-72.936, 41.258],\n            [-72.547, 41.25],\n            [-71.861, 41.32],\n            [-71.798, 41.417],\n            [-71.799, 42.008],\n            [-73.487, 42.05],\n          ],\n        ],\n      },\n      properties: { name: \"Connecticut\" },\n    },\n    {\n      type: \"Feature\",\n      geometry: {\n        type: \"Polygon\",\n        coordinates: [\n          [\n            [-75.415, 39.802],\n            [-75.559, 39.63],\n            [-75.528, 39.498],\n            [-75.244, 39.286],\n            [-74.886, 39.144],\n            [-74.647, 39.212],\n            [-74.413, 39.361],\n            [-74.101, 39.756],\n            [-73.971, 40.348],\n            [-74.261, 40.502],\n            [-74.087, 40.652],\n            [-73.894, 40.997],\n            [-74.695, 41.357],\n            [-75.133, 40.98],\n            [-75.187, 40.569],\n            [-74.722, 40.154],\n            [-75.415, 39.802],\n          ],\n        ],\n      },\n      properties: { name: \"New Jersey\" },\n    },\n    {\n      type: \"Feature\",\n      geometry: {\n        type: \"Polygon\",\n        coordinates: [\n          [\n            [-81.678, 36.588],\n            [-81.734, 36.413],\n            [-81.908, 36.302],\n            [-82.029, 36.124],\n            [-82.211, 36.159],\n            [-82.779, 35.993],\n            [-82.978, 35.783],\n            [-83.162, 35.763],\n            [-83.498, 35.563],\n            [-83.772, 35.562],\n            [-84.022, 35.407],\n            [-84.098, 35.247],\n            [-84.283, 35.227],\n            [-84.322, 34.988],\n            [-83.109, 35.001],\n            [-82.411, 35.202],\n            [-81.043, 35.149],\n            [-80.782, 34.936],\n            [-80.797, 34.824],\n            [-79.675, 34.805],\n            [-78.541, 33.851],\n            [-78.137, 33.912],\n            [-77.96, 33.853],\n            [-77.829, 34.163],\n            [-77.635, 34.36],\n            [-77.137, 34.633],\n            [-76.727, 34.697],\n            [-76.536, 34.589],\n            [-76.137, 34.988],\n            [-75.913, 35.12],\n            [-75.534, 35.226],\n            [-75.459, 35.597],\n            [-75.718, 36.114],\n            [-75.867, 36.551],\n            [-76.917, 36.546],\n            [-78.51, 36.541],\n            [-80.295, 36.544],\n            [-81.678, 36.588],\n          ],\n        ],\n      },\n      properties: { name: \"North Carolina\" },\n    },\n    {\n      type: \"Feature\",\n      geometry: {\n        type: \"Polygon\",\n        coordinates: [\n          [\n            [-114.042, 41.994],\n            [-114.046, 40.398],\n            [-114.049, 39.006],\n            [-114.05, 37.881],\n            [-114.051, 37],\n            [-112.966, 37],\n            [-111.278, 37],\n            [-110.001, 36.998],\n            [-109.045, 36.999],\n            [-109.042, 38.165],\n            [-109.06, 38.275],\n            [-109.051, 39.875],\n            [-109.05, 41.001],\n            [-111.047, 40.998],\n            [-111.047, 42.002],\n            [-112.11, 41.998],\n            [-114.042, 41.994],\n          ],\n        ],\n      },\n      properties: { name: \"Utah\" },\n    },\n    {\n      type: \"Feature\",\n      geometry: {\n        type: \"Polygon\",\n        coordinates: [\n          [\n            [-104.049, 49],\n            [-104.042, 47.803],\n            [-104.045, 45.945],\n            [-102.088, 45.945],\n            [-100.762, 45.944],\n            [-99.49, 45.94],\n            [-97.777, 45.935],\n            [-96.564, 45.935],\n            [-96.601, 46.32],\n            [-96.791, 46.637],\n            [-96.854, 47.572],\n            [-97.147, 48.169],\n            [-97.1, 48.668],\n            [-97.229, 49.001],\n            [-98.869, 49],\n            [-99.914, 48.999],\n            [-102.217, 48.999],\n            [-104.049, 49],\n          ],\n        ],\n      },\n      properties: { name: \"North Dakota\" },\n    },\n    {\n      type: \"Feature\",\n      geometry: {\n        type: \"Polygon\",\n        coordinates: [\n          [\n            [-83.109, 35.001],\n            [-83.324, 34.79],\n            [-83.339, 34.682],\n            [-83.048, 34.493],\n            [-82.874, 34.472],\n            [-82.715, 34.148],\n            [-82.557, 33.945],\n            [-82.324, 33.82],\n            [-82.162, 33.611],\n            [-81.926, 33.463],\n            [-81.933, 33.344],\n            [-81.755, 33.152],\n            [-81.502, 33.015],\n            [-81.397, 32.606],\n            [-81.195, 32.465],\n            [-81.113, 32.113],\n            [-80.886, 32.035],\n            [-80.338, 32.479],\n            [-80.001, 32.606],\n            [-79.57, 32.927],\n            [-79.36, 33.007],\n            [-79.215, 33.156],\n            [-79.135, 33.404],\n            [-78.773, 33.769],\n            [-78.541, 33.851],\n            [-79.675, 34.805],\n            [-80.797, 34.824],\n            [-80.782, 34.936],\n            [-81.043, 35.149],\n            [-82.411, 35.202],\n            [-83.109, 35.001],\n          ],\n        ],\n      },\n      properties: { name: \"South Carolina\" },\n    },\n    {\n      type: \"Feature\",\n      geometry: {\n        type: \"Polygon\",\n        coordinates: [\n          [\n            [-91.166, 33.004],\n            [-91.072, 32.938],\n            [-91.114, 32.74],\n            [-91.053, 32.438],\n            [-90.921, 32.342],\n            [-91.035, 32.101],\n            [-91.36, 31.799],\n            [-91.536, 31.338],\n            [-91.644, 31.234],\n            [-91.56, 31.05],\n            [-90.759, 31],\n            [-89.728, 31.002],\n            [-89.836, 30.727],\n            [-89.608, 30.217],\n            [-89.525, 30.181],\n            [-89.345, 30.293],\n            [-88.894, 30.393],\n            [-88.472, 30.32],\n            [-88.395, 30.369],\n            [-88.469, 31.933],\n            [-88.317, 33.184],\n            [-88.098, 34.892],\n            [-88.2, 34.996],\n            [-89.435, 34.994],\n            [-90.309, 34.996],\n            [-90.25, 34.907],\n            [-90.474, 34.789],\n            [-90.587, 34.616],\n            [-90.575, 34.415],\n            [-90.895, 34.224],\n            [-91.061, 33.878],\n            [-91.027, 33.764],\n            [-91.216, 33.529],\n            [-91.069, 33.233],\n            [-91.166, 33.004],\n          ],\n        ],\n      },\n      properties: { name: \"Mississippi\" },\n    },\n    {\n      type: \"Feature\",\n      geometry: {\n        type: \"Polygon\",\n        coordinates: [\n          [\n            [-109.05, 41.001],\n            [-109.051, 39.875],\n            [-109.06, 38.275],\n            [-109.042, 38.165],\n            [-109.045, 36.999],\n            [-108.001, 37],\n            [-106.006, 36.995],\n            [-104.732, 36.993],\n            [-103.002, 37],\n            [-102.042, 36.993],\n            [-102.046, 38.698],\n            [-102.052, 40.003],\n            [-102.052, 41.002],\n            [-104.053, 41.001],\n            [-104.855, 40.998],\n            [-106.191, 40.998],\n            [-107.367, 41.003],\n            [-109.05, 41.001],\n          ],\n        ],\n      },\n      properties: { name: \"Colorado\" },\n    },\n    {\n      type: \"Feature\",\n      geometry: {\n        type: \"Polygon\",\n        coordinates: [\n          [\n            [-104.058, 44.997],\n            [-104.055, 44.25],\n            [-104.053, 43.001],\n            [-102.082, 42.999],\n            [-100.198, 42.998],\n            [-98.499, 42.999],\n            [-98.435, 42.929],\n            [-97.95, 42.77],\n            [-97.858, 42.865],\n            [-97.238, 42.853],\n            [-97.131, 42.772],\n            [-96.698, 42.659],\n            [-96.611, 42.506],\n            [-96.446, 42.491],\n            [-96.622, 42.779],\n            [-96.439, 43.114],\n            [-96.522, 43.221],\n            [-96.453, 43.5],\n            [-96.458, 45.308],\n            [-96.711, 45.437],\n            [-96.826, 45.654],\n            [-96.587, 45.816],\n            [-96.564, 45.935],\n            [-97.777, 45.935],\n            [-99.49, 45.94],\n            [-100.762, 45.944],\n            [-102.088, 45.945],\n            [-104.045, 45.945],\n            [-104.058, 44.997],\n          ],\n        ],\n      },\n      properties: { name: \"South Dakota\" },\n    },\n    {\n      type: \"Feature\",\n      geometry: {\n        type: \"Polygon\",\n        coordinates: [\n          [\n            [-103.002, 37],\n            [-103.002, 36.5],\n            [-101.624, 36.5],\n            [-100, 36.5],\n            [-100, 35.619],\n            [-100, 34.561],\n            [-99.696, 34.381],\n            [-99.275, 34.387],\n            [-99.19, 34.214],\n            [-98.737, 34.131],\n            [-98.364, 34.157],\n            [-98.099, 34.104],\n            [-97.866, 33.849],\n            [-97.672, 33.991],\n            [-97.444, 33.824],\n            [-97.206, 33.81],\n            [-96.952, 33.945],\n            [-96.851, 33.847],\n            [-96.593, 33.831],\n            [-96.363, 33.694],\n            [-96.152, 33.832],\n            [-95.557, 33.927],\n            [-95.283, 33.878],\n            [-95.226, 33.962],\n            [-94.842, 33.739],\n            [-94.486, 33.638],\n            [-94.432, 35.37],\n            [-94.618, 36.499],\n            [-94.618, 36.999],\n            [-95.787, 36.999],\n            [-97.462, 36.999],\n            [-99.129, 36.999],\n            [-100.856, 36.999],\n            [-102.042, 36.993],\n            [-103.002, 37],\n          ],\n        ],\n      },\n      properties: { name: \"Oklahoma\" },\n    },\n    {\n      type: \"Feature\",\n      geometry: {\n        type: \"Polygon\",\n        coordinates: [\n          [\n            [-104.058, 44.997],\n            [-106.264, 44.994],\n            [-108.621, 45],\n            [-111.044, 45.001],\n            [-111.049, 44.474],\n            [-111.045, 43.316],\n            [-111.047, 42.002],\n            [-111.047, 40.998],\n            [-109.05, 41.001],\n            [-107.367, 41.003],\n            [-106.191, 40.998],\n            [-104.855, 40.998],\n            [-104.053, 41.001],\n            [-104.053, 42.25],\n            [-104.053, 43.001],\n            [-104.055, 44.25],\n            [-104.058, 44.997],\n          ],\n        ],\n      },\n      properties: { name: \"Wyoming\" },\n    },\n    {\n      type: \"Feature\",\n      geometry: {\n        type: \"Polygon\",\n        coordinates: [\n          [\n            [-82.594, 38.422],\n            [-82.626, 38.135],\n            [-82.296, 37.686],\n            [-81.968, 37.538],\n            [-81.85, 37.285],\n            [-81.561, 37.207],\n            [-81.362, 37.338],\n            [-81.225, 37.235],\n            [-80.919, 37.306],\n            [-80.545, 37.475],\n            [-80.292, 37.537],\n            [-80.292, 37.684],\n            [-79.788, 38.273],\n            [-79.649, 38.592],\n            [-79.298, 38.416],\n            [-78.999, 38.84],\n            [-78.773, 38.894],\n            [-78.414, 39.158],\n            [-78.347, 39.466],\n            [-77.828, 39.132],\n            [-77.72, 39.321],\n            [-77.83, 39.587],\n            [-78.082, 39.671],\n            [-78.383, 39.622],\n            [-78.461, 39.526],\n            [-78.707, 39.556],\n            [-79.091, 39.472],\n            [-79.487, 39.206],\n            [-79.477, 39.721],\n            [-80.519, 39.721],\n            [-80.519, 40.639],\n            [-80.668, 40.582],\n            [-80.607, 40.304],\n            [-80.803, 39.919],\n            [-80.83, 39.712],\n            [-81.129, 39.449],\n            [-81.348, 39.346],\n            [-81.456, 39.409],\n            [-81.678, 39.274],\n            [-81.898, 38.93],\n            [-82.007, 39.03],\n            [-82.209, 38.803],\n            [-82.175, 38.608],\n            [-82.324, 38.449],\n            [-82.594, 38.422],\n          ],\n        ],\n      },\n      properties: { name: \"West Virginia\" },\n    },\n    {\n      type: \"Feature\",\n      geometry: {\n        type: \"Polygon\",\n        coordinates: [\n          [\n            [-71.084, 45.305],\n            [-71.037, 44.736],\n            [-70.973, 43.57],\n            [-70.984, 43.376],\n            [-70.704, 43.06],\n            [-70.554, 43.322],\n            [-70.416, 43.361],\n            [-70.168, 43.675],\n            [-69.916, 43.775],\n            [-69.321, 43.857],\n            [-69.077, 43.974],\n            [-68.439, 44.116],\n            [-68.126, 44.387],\n            [-67.855, 44.419],\n            [-67.449, 44.6],\n            [-67.293, 44.599],\n            [-66.95, 44.817],\n            [-67.112, 45.112],\n            [-67.48, 45.268],\n            [-67.417, 45.502],\n            [-67.803, 45.678],\n            [-67.78, 45.938],\n            [-67.79, 47.066],\n            [-68.204, 47.34],\n            [-68.362, 47.356],\n            [-68.901, 47.179],\n            [-69.04, 47.245],\n            [-69.039, 47.422],\n            [-69.22, 47.457],\n            [-69.997, 46.695],\n            [-70.054, 46.429],\n            [-70.291, 46.186],\n            [-70.259, 45.891],\n            [-70.781, 45.431],\n            [-71.084, 45.305],\n          ],\n        ],\n      },\n      properties: { name: \"Maine\" },\n    },\n    {\n      type: \"Feature\",\n      geometry: {\n        type: \"Polygon\",\n        coordinates: [\n          [\n            [-71.501, 45.013],\n            [-71.627, 44.747],\n            [-71.58, 44.502],\n            [-71.819, 44.353],\n            [-72.046, 44.292],\n            [-72.037, 44.103],\n            [-72.183, 43.808],\n            [-72.379, 43.574],\n            [-72.445, 43.004],\n            [-72.54, 42.805],\n            [-72.459, 42.727],\n            [-71.294, 42.697],\n            [-71.15, 42.815],\n            [-70.817, 42.872],\n            [-70.704, 43.06],\n            [-70.984, 43.376],\n            [-70.973, 43.57],\n            [-71.037, 44.736],\n            [-71.084, 45.305],\n            [-71.284, 45.302],\n            [-71.501, 45.013],\n          ],\n        ],\n      },\n      properties: { name: \"New Hampshire\" },\n    },\n    transformedAlaskaTopology,\n    {\n      type: \"Feature\",\n      geometry: {\n        type: \"Polygon\",\n        coordinates: [\n          [\n            [-114.72, 32.719],\n            [-114.814, 32.494],\n            [-113.751, 32.169],\n            [-112.365, 31.741],\n            [-111.075, 31.332],\n            [-109.05, 31.333],\n            [-109.047, 32.778],\n            [-109.046, 33.875],\n            [-109.046, 34.96],\n            [-109.046, 36.117],\n            [-109.045, 36.999],\n            [-110.001, 36.998],\n            [-111.278, 37],\n            [-112.966, 37],\n            [-114.051, 37],\n            [-114.047, 36.194],\n            [-114.152, 36.025],\n            [-114.372, 36.143],\n            [-114.736, 36.104],\n            [-114.664, 35.449],\n            [-114.573, 35.139],\n            [-114.633, 35.002],\n            [-114.634, 34.873],\n            [-114.465, 34.691],\n            [-114.335, 34.45],\n            [-114.139, 34.26],\n            [-114.428, 34.093],\n            [-114.535, 33.928],\n            [-114.525, 33.552],\n            [-114.707, 33.377],\n            [-114.671, 33.038],\n            [-114.511, 33.023],\n            [-114.469, 32.845],\n            [-114.72, 32.719],\n          ],\n        ],\n      },\n      properties: { name: \"Arizona\" },\n    },\n    {\n      type: \"Feature\",\n      geometry: {\n        type: \"Polygon\",\n        coordinates: [\n          [\n            [-71.861, 41.32],\n            [-71.483, 41.372],\n            [-71.429, 41.454],\n            [-71.121, 41.497],\n            [-71.133, 41.66],\n            [-71.329, 41.783],\n            [-71.381, 42.019],\n            [-71.799, 42.008],\n            [-71.798, 41.417],\n            [-71.861, 41.32],\n          ],\n        ],\n      },\n      properties: { name: \"Rhode Island\" },\n    },\n  ],\n};\n","import {\n  maxFeatureName,\n  minFeatureName,\n  stateCodeToName,\n  usStateTopology,\n} from \"@charts/chart-components/maps/topologies/usStateTopology\";\nimport { PvMapChartData } from \"@charts/PvMapChart/PvMapChart.vue\";\n\nexport type MapTopologyType = \"state\" | \"city\" | \"county\" | \"cbsa\" | \"zip_code\";\n\n// dict of topology types to the topology object we use to render the map\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst topologyObjectMap: { [key: string]: any } = {\n  state: usStateTopology,\n};\n\nconst buildMapData = (\n  inputData: PvMapChartData[],\n  topologyType: MapTopologyType,\n  seriesKey: string,\n  scaleMin: number,\n  scaleMax: number,\n): { [key: string]: string | number }[] => {\n  if (inputData.length === 0) {\n    return [];\n  }\n  // right now, we only support us_states topology\n  if (topologyType !== \"state\") {\n    throw new Error(`Unsupported topology type: ${topologyType}`);\n  }\n  // check that inputData contains the expected field based on the topology type\n  const hasExpectedField = inputData.every((item) => item.hasOwnProperty(topologyType));\n  if (!hasExpectedField) {\n    throw new Error(`Input data must contain the field: ${topologyType}`);\n  }\n  const mappedData = inputData.map((item) => {\n    const stateName = stateCodeToName(item[topologyType] as string);\n    return {\n      ...item,\n      [topologyType]: item[topologyType],\n      name: stateName,\n    };\n  });\n  mappedData.push({\n    [topologyType]: minFeatureName,\n    [seriesKey]: scaleMin,\n    name: minFeatureName,\n  });\n  mappedData.push({\n    [topologyType]: maxFeatureName,\n    [seriesKey]: scaleMax,\n    name: maxFeatureName,\n  });\n  return mappedData;\n};\n\nconst getTopologyObject = (topologyType: MapTopologyType) => {\n  const topologyObject = topologyObjectMap[topologyType];\n  if (!topologyObject) {\n    throw new Error(`No topology object found for type: ${topologyType}`);\n  }\n  return topologyObject;\n};\n\nexport const useTopology = () => {\n  return {\n    getTopologyObject,\n    buildMapData,\n  };\n};\n","<script setup lang=\"ts\">\ntype ChartGradientProps = {\n  min?: number;\n  max?: number;\n  valueFormatter?: (value: number) => string;\n};\n\nconst props = withDefaults(defineProps<ChartGradientProps>(), {\n  min: 0,\n  max: 100,\n});\n\nconst legendFormatter = (value: number) => {\n  if (props.valueFormatter) {\n    return props.valueFormatter(value);\n  } else {\n    return value.toLocaleString(\"en-US\");\n  }\n};\n</script>\n\n<template>\n  <div data-testid=\"pv-map-gradient\" style=\"width: 30%\">\n    <div\n      :min=\"min\"\n      :max=\"max\"\n      aria-hidden=\"true\"\n      class=\"pv-full-width pv-stack-4\"\n      style=\"\n        appearance: none;\n        background: rgb(226, 247, 245);\n        background: linear-gradient(\n          90deg,\n          rgba(226, 247, 245, 1) 0%,\n          rgba(168, 230, 225, 1) 10%,\n          rgba(111, 214, 206, 1) 20%,\n          rgba(54, 197, 186, 1) 30%,\n          rgba(44, 168, 161, 1) 40%,\n          rgba(33, 140, 136, 1) 50%,\n          rgba(23, 111, 111, 1) 60%,\n          rgba(13, 82, 86, 1) 70%,\n          rgba(2, 54, 61, 1) 80%,\n          rgba(1, 18, 20, 1) 90%\n        );\n        border: 0;\n        border-radius: 1rem;\n        height: 0.5rem;\n      \"\n    ></div>\n    <div class=\"pv-flex pv-space-between pv-text-body-xxs pv-text-subdued\">\n      <p>{{ legendFormatter(min) }}</p>\n      <p>{{ legendFormatter(max) }}</p>\n    </div>\n  </div>\n</template>\n","<script setup lang=\"ts\">\ntype ChartGradientProps = {\n  min?: number;\n  max?: number;\n  valueFormatter?: (value: number) => string;\n};\n\nconst props = withDefaults(defineProps<ChartGradientProps>(), {\n  min: 0,\n  max: 100,\n});\n\nconst legendFormatter = (value: number) => {\n  if (props.valueFormatter) {\n    return props.valueFormatter(value);\n  } else {\n    return value.toLocaleString(\"en-US\");\n  }\n};\n</script>\n\n<template>\n  <div data-testid=\"pv-map-gradient\" style=\"width: 30%\">\n    <div\n      :min=\"min\"\n      :max=\"max\"\n      aria-hidden=\"true\"\n      class=\"pv-full-width pv-stack-4\"\n      style=\"\n        appearance: none;\n        background: rgb(226, 247, 245);\n        background: linear-gradient(\n          90deg,\n          rgba(226, 247, 245, 1) 0%,\n          rgba(168, 230, 225, 1) 10%,\n          rgba(111, 214, 206, 1) 20%,\n          rgba(54, 197, 186, 1) 30%,\n          rgba(44, 168, 161, 1) 40%,\n          rgba(33, 140, 136, 1) 50%,\n          rgba(23, 111, 111, 1) 60%,\n          rgba(13, 82, 86, 1) 70%,\n          rgba(2, 54, 61, 1) 80%,\n          rgba(1, 18, 20, 1) 90%\n        );\n        border: 0;\n        border-radius: 1rem;\n        height: 0.5rem;\n      \"\n    ></div>\n    <div class=\"pv-flex pv-space-between pv-text-body-xxs pv-text-subdued\">\n      <p>{{ legendFormatter(min) }}</p>\n      <p>{{ legendFormatter(max) }}</p>\n    </div>\n  </div>\n</template>\n","<script setup lang=\"ts\">\nimport { computed, useTemplateRef, onMounted } from \"vue\";\nimport { onKeyStroke } from \"@vueuse/core\";\nimport type { PvSize } from \"@/components/base/baseProps\";\n\nexport interface PvSearchInputProps {\n  /**\n   * When true, the input is non-interactive and visually dimmed.\n   */\n  disabled?: boolean;\n  /** When true, displays a keyboard shortcut badge (\"/\" key) and registers the hotkey to focus the input. */\n  displayShortcut?: boolean;\n  /**\n   * Placeholder text shown when the input is empty.\n   */\n  placeholder?: string;\n  size?: Extract<PvSize, \"lg\" | \"xl\">;\n}\n\nexport interface PvSearchInputExposed {\n  input: HTMLInputElement | null;\n}\n\nconst props = withDefaults(defineProps<PvSearchInputProps>(), {\n  disabled: false,\n  placeholder: \"Search\",\n  size: \"xl\",\n});\n\nconst SHORTCUT = \"/\";\n\nconst input = useTemplateRef<HTMLInputElement | null>(\"search-input\");\nconst modelValue = defineModel<string>({ required: false, default: \"\" });\n\nconst pvSearchInputClasses = computed(() => {\n  return {\n    \"pv-input-search\": true,\n    \"pv-full-width\": true,\n    \"pv-input-padded-end\": true,\n    \"pv-input-small\": props.size === \"lg\",\n  };\n});\n\nonMounted(() => {\n  if (!props.displayShortcut) return;\n\n  onKeyStroke(SHORTCUT, (e) => {\n    const target = e.target as HTMLElement | null;\n\n    const isTyping =\n      target instanceof HTMLInputElement ||\n      target instanceof HTMLTextAreaElement ||\n      (target?.isContentEditable ?? false);\n\n    const isCurrentInputFocused = document.activeElement === input.value;\n\n    if (!isTyping || isCurrentInputFocused) {\n      if (!isCurrentInputFocused) {\n        e.preventDefault();\n        input.value?.focus();\n      }\n    }\n  });\n});\n\ndefineExpose({ input });\n</script>\n\n<template>\n  <div class=\"pv-relative\">\n    <input\n      ref=\"search-input\"\n      v-model=\"modelValue\"\n      data-testid=\"pv-search-input\"\n      type=\"text\"\n      :disabled=\"disabled\"\n      :class=\"pvSearchInputClasses\"\n      :placeholder=\"placeholder\"\n    />\n    <kbd v-if=\"displayShortcut\" data-testid=\"pv-search-input-shortcut\" class=\"pv-kbd\">\n      {{ SHORTCUT }}\n    </kbd>\n  </div>\n</template>\n\n<style scoped>\n.pv-input-search {\n  display: block;\n}\n</style>\n","<script setup lang=\"ts\">\nimport { computed, useTemplateRef, onMounted } from \"vue\";\nimport { onKeyStroke } from \"@vueuse/core\";\nimport type { PvSize } from \"@/components/base/baseProps\";\n\nexport interface PvSearchInputProps {\n  /**\n   * When true, the input is non-interactive and visually dimmed.\n   */\n  disabled?: boolean;\n  /** When true, displays a keyboard shortcut badge (\"/\" key) and registers the hotkey to focus the input. */\n  displayShortcut?: boolean;\n  /**\n   * Placeholder text shown when the input is empty.\n   */\n  placeholder?: string;\n  size?: Extract<PvSize, \"lg\" | \"xl\">;\n}\n\nexport interface PvSearchInputExposed {\n  input: HTMLInputElement | null;\n}\n\nconst props = withDefaults(defineProps<PvSearchInputProps>(), {\n  disabled: false,\n  placeholder: \"Search\",\n  size: \"xl\",\n});\n\nconst SHORTCUT = \"/\";\n\nconst input = useTemplateRef<HTMLInputElement | null>(\"search-input\");\nconst modelValue = defineModel<string>({ required: false, default: \"\" });\n\nconst pvSearchInputClasses = computed(() => {\n  return {\n    \"pv-input-search\": true,\n    \"pv-full-width\": true,\n    \"pv-input-padded-end\": true,\n    \"pv-input-small\": props.size === \"lg\",\n  };\n});\n\nonMounted(() => {\n  if (!props.displayShortcut) return;\n\n  onKeyStroke(SHORTCUT, (e) => {\n    const target = e.target as HTMLElement | null;\n\n    const isTyping =\n      target instanceof HTMLInputElement ||\n      target instanceof HTMLTextAreaElement ||\n      (target?.isContentEditable ?? false);\n\n    const isCurrentInputFocused = document.activeElement === input.value;\n\n    if (!isTyping || isCurrentInputFocused) {\n      if (!isCurrentInputFocused) {\n        e.preventDefault();\n        input.value?.focus();\n      }\n    }\n  });\n});\n\ndefineExpose({ input });\n</script>\n\n<template>\n  <div class=\"pv-relative\">\n    <input\n      ref=\"search-input\"\n      v-model=\"modelValue\"\n      data-testid=\"pv-search-input\"\n      type=\"text\"\n      :disabled=\"disabled\"\n      :class=\"pvSearchInputClasses\"\n      :placeholder=\"placeholder\"\n    />\n    <kbd v-if=\"displayShortcut\" data-testid=\"pv-search-input-shortcut\" class=\"pv-kbd\">\n      {{ SHORTCUT }}\n    </kbd>\n  </div>\n</template>\n\n<style scoped>\n.pv-input-search {\n  display: block;\n}\n</style>\n","<script setup lang=\"ts\">\nimport { computed, ref, watch } from \"vue\";\nimport { sizeMap } from \"@/components/base/baseProps\";\nimport { PvCompanyLogoSize } from \"./types\";\n\ntype PvCompanyLogoProps = {\n  /** Base URL path where company logo SVGs are hosted. */\n  basePath?: string;\n  /** Company name used to resolve the logo filename. */\n  name: string;\n  /** Display size of the logo. Maps to a fixed pixel width. */\n  size?: PvCompanyLogoSize;\n  /** When provided, overrides the computed image URL entirely (ignores `name` and `basePath`). */\n  srcPathOverride?: string;\n};\n\nconst props = withDefaults(defineProps<PvCompanyLogoProps>(), {\n  basePath: \"https://static-assets.turquoise.health/shared-logos/prd/payers\",\n  size: \"md\",\n});\n\nconst isValidSrc = ref(true);\n\nconst iconSize = computed(() => {\n  return sizeMap[props.size] || \"32px\"; // Default to md size if not found\n});\n\nconst styles = computed(() => ({\n  width: iconSize.value,\n}));\n\nconst modifiedName = computed((): string => {\n  const snakeCaseName = props.name\n    .toLowerCase()\n    .replace(/[^a-z\\s]/g, \"\")\n    .trim()\n    .replace(/\\s+/g, \"_\");\n  return `${snakeCaseName}.svg`;\n});\n\nconst imageSource = computed(() => {\n  if (props.srcPathOverride) {\n    return props.srcPathOverride;\n  }\n  return `${props.basePath}/${modifiedName.value}`;\n});\n\n// reset the isValidSrc when the name changes, and let @error handler set it to false if the image fails to load\nwatch(imageSource, () => {\n  isValidSrc.value = true;\n});\n</script>\n\n<template>\n  <div class=\"pv-flex\" data-testid=\"pv-company-logo\">\n    <div :class=\"`pv-company-${props.size}`\" :style=\"styles\">\n      <img v-if=\"isValidSrc\" :src=\"imageSource\" alt=\"\" @error=\"isValidSrc = false\" />\n    </div>\n  </div>\n</template>\n","<script setup lang=\"ts\">\nimport { computed, ref, watch } from \"vue\";\nimport { sizeMap } from \"@/components/base/baseProps\";\nimport { PvCompanyLogoSize } from \"./types\";\n\ntype PvCompanyLogoProps = {\n  /** Base URL path where company logo SVGs are hosted. */\n  basePath?: string;\n  /** Company name used to resolve the logo filename. */\n  name: string;\n  /** Display size of the logo. Maps to a fixed pixel width. */\n  size?: PvCompanyLogoSize;\n  /** When provided, overrides the computed image URL entirely (ignores `name` and `basePath`). */\n  srcPathOverride?: string;\n};\n\nconst props = withDefaults(defineProps<PvCompanyLogoProps>(), {\n  basePath: \"https://static-assets.turquoise.health/shared-logos/prd/payers\",\n  size: \"md\",\n});\n\nconst isValidSrc = ref(true);\n\nconst iconSize = computed(() => {\n  return sizeMap[props.size] || \"32px\"; // Default to md size if not found\n});\n\nconst styles = computed(() => ({\n  width: iconSize.value,\n}));\n\nconst modifiedName = computed((): string => {\n  const snakeCaseName = props.name\n    .toLowerCase()\n    .replace(/[^a-z\\s]/g, \"\")\n    .trim()\n    .replace(/\\s+/g, \"_\");\n  return `${snakeCaseName}.svg`;\n});\n\nconst imageSource = computed(() => {\n  if (props.srcPathOverride) {\n    return props.srcPathOverride;\n  }\n  return `${props.basePath}/${modifiedName.value}`;\n});\n\n// reset the isValidSrc when the name changes, and let @error handler set it to false if the image fails to load\nwatch(imageSource, () => {\n  isValidSrc.value = true;\n});\n</script>\n\n<template>\n  <div class=\"pv-flex\" data-testid=\"pv-company-logo\">\n    <div :class=\"`pv-company-${props.size}`\" :style=\"styles\">\n      <img v-if=\"isValidSrc\" :src=\"imageSource\" alt=\"\" @error=\"isValidSrc = false\" />\n    </div>\n  </div>\n</template>\n","<script setup lang=\"ts\">\nimport type { PvIconSize } from \"../baseProps\";\nimport PvIcon from \"../PvIcon/PvIcon.vue\";\nimport type { PvAvatarProps, PvAvatarSize } from \"./types\";\n\nconst avatarSizeToClass: Record<PvAvatarSize, string> = {\n  sm: \"pv-avatar-16\",\n  md: \"pv-avatar-20\",\n  lg: \"pv-avatar-xs\",\n  xl: \"pv-avatar-sm\",\n  \"2x\": \"pv-avatar-md\",\n};\n\nconst iconSizeToAvatarSize: Partial<Record<PvAvatarSize, PvIconSize>> = {\n  sm: 10,\n  md: 12,\n  lg: undefined,\n  xl: 20,\n  \"2x\": 20,\n};\n\nwithDefaults(defineProps<PvAvatarProps>(), {\n  shape: \"circle\",\n  size: \"lg\",\n});\n</script>\n\n<template>\n  <div :class=\"avatarSizeToClass[size]\" data-testid=\"pv-avatar\" :data-style=\"variant\" :data-shape=\"shape\">\n    <PvIcon v-if=\"icon\" :name=\"icon\" :size=\"iconSizeToAvatarSize[size]\" />\n    <template v-else-if=\"initials\">{{ initials }}</template>\n    <template v-else-if=\"image\">\n      <img :src=\"image\" :alt=\"alt ?? ''\" />\n    </template>\n  </div>\n</template>\n","<script setup lang=\"ts\">\nimport type { PvIconSize } from \"../baseProps\";\nimport PvIcon from \"../PvIcon/PvIcon.vue\";\nimport type { PvAvatarProps, PvAvatarSize } from \"./types\";\n\nconst avatarSizeToClass: Record<PvAvatarSize, string> = {\n  sm: \"pv-avatar-16\",\n  md: \"pv-avatar-20\",\n  lg: \"pv-avatar-xs\",\n  xl: \"pv-avatar-sm\",\n  \"2x\": \"pv-avatar-md\",\n};\n\nconst iconSizeToAvatarSize: Partial<Record<PvAvatarSize, PvIconSize>> = {\n  sm: 10,\n  md: 12,\n  lg: undefined,\n  xl: 20,\n  \"2x\": 20,\n};\n\nwithDefaults(defineProps<PvAvatarProps>(), {\n  shape: \"circle\",\n  size: \"lg\",\n});\n</script>\n\n<template>\n  <div :class=\"avatarSizeToClass[size]\" data-testid=\"pv-avatar\" :data-style=\"variant\" :data-shape=\"shape\">\n    <PvIcon v-if=\"icon\" :name=\"icon\" :size=\"iconSizeToAvatarSize[size]\" />\n    <template v-else-if=\"initials\">{{ initials }}</template>\n    <template v-else-if=\"image\">\n      <img :src=\"image\" :alt=\"alt ?? ''\" />\n    </template>\n  </div>\n</template>\n","<script setup lang=\"ts\">\nimport { computed, onBeforeUnmount, ref, useTemplateRef } from \"vue\";\nimport { PvTooltipPositions, PvTooltipVariants, PvTooltipSize } from \"./types\";\nimport { useSlotPresence } from \"@/composables/useSlotPresence\";\n\ninterface PvTooltipProps {\n  /** Color theme variant */\n  variant?: PvTooltipVariants;\n  /** Position of the tooltip relative to the trigger element */\n  tooltipPosition?: PvTooltipPositions;\n  /** Accessibility label reference ID linking trigger to tooltip content */\n  ariaLabelledBy?: string;\n  /** Size of the tooltip content area */\n  size?: PvTooltipSize;\n  /** When true, tooltip hides immediately when cursor leaves the trigger */\n  disableInteractive?: boolean;\n  /** Delay in milliseconds before showing the tooltip on hover. Keyboard focus is never delayed. */\n  delay?: number;\n}\n\nconst props = withDefaults(defineProps<PvTooltipProps>(), {\n  variant: \"white\",\n  ariaLabelledBy: \"ariaLabelledById\",\n  tooltipPosition: \"top-right\",\n  size: \"md\",\n  disableInteractive: false,\n  delay: 0,\n});\n\nconst rootRef = useTemplateRef<HTMLElement | null>(\"rootRef\");\n// `useSlotPresence` needs the host to see light DOM children as a web component.\nconst slotHost = computed(() => {\n  const rootNode = rootRef.value?.getRootNode();\n  return rootNode instanceof ShadowRoot ? (rootNode.host as HTMLElement) : null;\n});\n\nconst { present: hasTooltip } = useSlotPresence(\"tooltip-content\", { host: slotHost });\n\n// Visibility stays in CSS (`.pv-tooltip:hover > [role=\"tooltip\"]`). A pending\n// delay only suppresses it with an inline `display: none`, which outranks the\n// stylesheet; dropping that style hands control back to the `:hover` rule.\nconst isDelayed = computed(() => props.delay > 0);\n\n// Keyboard focus is deliberately not delayed: the delay exists to stop tooltips\n// flashing open as a pointer transits, and a tabbed-to element is already committed.\nconst focused = ref(false);\nconst openDelayElapsed = ref(false);\n\nlet openDelayTimeout: ReturnType<typeof setTimeout> | undefined;\n\nconst clearOpenDelayTimeout = () => {\n  if (openDelayTimeout) clearTimeout(openDelayTimeout);\n  openDelayTimeout = undefined;\n};\n\nconst tooltipVisible = computed(() => !isDelayed.value || focused.value || openDelayElapsed.value);\n\nconst handleMouseEnter = () => {\n  if (!isDelayed.value) return;\n  clearOpenDelayTimeout();\n  openDelayTimeout = setTimeout(() => {\n    openDelayTimeout = undefined;\n    openDelayElapsed.value = true;\n  }, props.delay);\n};\n\nconst handleMouseLeave = () => {\n  if (!isDelayed.value) return;\n  clearOpenDelayTimeout();\n  openDelayElapsed.value = false;\n};\n\nconst handleFocusIn = () => {\n  if (isDelayed.value) focused.value = true;\n};\n\nconst handleFocusOut = () => {\n  if (isDelayed.value) focused.value = false;\n};\n\nonBeforeUnmount(clearOpenDelayTimeout);\n</script>\n\n<template>\n  <div\n    ref=\"rootRef\"\n    data-testid=\"pv-tooltip\"\n    :class=\"[\n      {\n        'pv-tooltip': hasTooltip,\n        'pv-tooltip-small': hasTooltip && size === 'sm',\n      },\n    ]\"\n    :data-position=\"tooltipPosition\"\n    :data-style=\"variant === 'white' ? 'white' : 'dark'\"\n    :data-static=\"disableInteractive ? true : undefined\"\n    :aria-labelledby=\"hasTooltip ? ariaLabelledBy : undefined\"\n    @mouseenter=\"handleMouseEnter\"\n    @mouseleave=\"handleMouseLeave\"\n    @focusin=\"handleFocusIn\"\n    @focusout=\"handleFocusOut\"\n  >\n    <slot name=\"label\" />\n    <div v-if=\"hasTooltip\" v-show=\"tooltipVisible\" role=\"tooltip\" :id=\"ariaLabelledBy\" data-testid=\"pv-tooltip-content\">\n      <slot name=\"tooltip-content\" />\n    </div>\n  </div>\n</template>\n","<script setup lang=\"ts\">\nimport { computed, onBeforeUnmount, ref, useTemplateRef } from \"vue\";\nimport { PvTooltipPositions, PvTooltipVariants, PvTooltipSize } from \"./types\";\nimport { useSlotPresence } from \"@/composables/useSlotPresence\";\n\ninterface PvTooltipProps {\n  /** Color theme variant */\n  variant?: PvTooltipVariants;\n  /** Position of the tooltip relative to the trigger element */\n  tooltipPosition?: PvTooltipPositions;\n  /** Accessibility label reference ID linking trigger to tooltip content */\n  ariaLabelledBy?: string;\n  /** Size of the tooltip content area */\n  size?: PvTooltipSize;\n  /** When true, tooltip hides immediately when cursor leaves the trigger */\n  disableInteractive?: boolean;\n  /** Delay in milliseconds before showing the tooltip on hover. Keyboard focus is never delayed. */\n  delay?: number;\n}\n\nconst props = withDefaults(defineProps<PvTooltipProps>(), {\n  variant: \"white\",\n  ariaLabelledBy: \"ariaLabelledById\",\n  tooltipPosition: \"top-right\",\n  size: \"md\",\n  disableInteractive: false,\n  delay: 0,\n});\n\nconst rootRef = useTemplateRef<HTMLElement | null>(\"rootRef\");\n// `useSlotPresence` needs the host to see light DOM children as a web component.\nconst slotHost = computed(() => {\n  const rootNode = rootRef.value?.getRootNode();\n  return rootNode instanceof ShadowRoot ? (rootNode.host as HTMLElement) : null;\n});\n\nconst { present: hasTooltip } = useSlotPresence(\"tooltip-content\", { host: slotHost });\n\n// Visibility stays in CSS (`.pv-tooltip:hover > [role=\"tooltip\"]`). A pending\n// delay only suppresses it with an inline `display: none`, which outranks the\n// stylesheet; dropping that style hands control back to the `:hover` rule.\nconst isDelayed = computed(() => props.delay > 0);\n\n// Keyboard focus is deliberately not delayed: the delay exists to stop tooltips\n// flashing open as a pointer transits, and a tabbed-to element is already committed.\nconst focused = ref(false);\nconst openDelayElapsed = ref(false);\n\nlet openDelayTimeout: ReturnType<typeof setTimeout> | undefined;\n\nconst clearOpenDelayTimeout = () => {\n  if (openDelayTimeout) clearTimeout(openDelayTimeout);\n  openDelayTimeout = undefined;\n};\n\nconst tooltipVisible = computed(() => !isDelayed.value || focused.value || openDelayElapsed.value);\n\nconst handleMouseEnter = () => {\n  if (!isDelayed.value) return;\n  clearOpenDelayTimeout();\n  openDelayTimeout = setTimeout(() => {\n    openDelayTimeout = undefined;\n    openDelayElapsed.value = true;\n  }, props.delay);\n};\n\nconst handleMouseLeave = () => {\n  if (!isDelayed.value) return;\n  clearOpenDelayTimeout();\n  openDelayElapsed.value = false;\n};\n\nconst handleFocusIn = () => {\n  if (isDelayed.value) focused.value = true;\n};\n\nconst handleFocusOut = () => {\n  if (isDelayed.value) focused.value = false;\n};\n\nonBeforeUnmount(clearOpenDelayTimeout);\n</script>\n\n<template>\n  <div\n    ref=\"rootRef\"\n    data-testid=\"pv-tooltip\"\n    :class=\"[\n      {\n        'pv-tooltip': hasTooltip,\n        'pv-tooltip-small': hasTooltip && size === 'sm',\n      },\n    ]\"\n    :data-position=\"tooltipPosition\"\n    :data-style=\"variant === 'white' ? 'white' : 'dark'\"\n    :data-static=\"disableInteractive ? true : undefined\"\n    :aria-labelledby=\"hasTooltip ? ariaLabelledBy : undefined\"\n    @mouseenter=\"handleMouseEnter\"\n    @mouseleave=\"handleMouseLeave\"\n    @focusin=\"handleFocusIn\"\n    @focusout=\"handleFocusOut\"\n  >\n    <slot name=\"label\" />\n    <div v-if=\"hasTooltip\" v-show=\"tooltipVisible\" role=\"tooltip\" :id=\"ariaLabelledBy\" data-testid=\"pv-tooltip-content\">\n      <slot name=\"tooltip-content\" />\n    </div>\n  </div>\n</template>\n","<script setup lang=\"ts\">\nimport PvIcon from \"../../PvIcon/PvIcon.vue\";\nimport PvCounterBadge from \"../../PvCounterBadge/PvCounterBadge.vue\";\nimport PvCompanyLogo from \"../../PvCompanyLogo/PvCompanyLogo.vue\";\nimport PvAvatar from \"../../PvAvatar/PvAvatar.vue\";\nimport PvTooltip from \"../../PvTooltip/PvTooltip.vue\";\nimport { computed } from \"vue\";\nimport type { PvAvatarSize } from \"@/components/base/PvAvatar/types\";\nimport type { PvIconSize } from \"@/components/base/baseProps\";\nimport { pvButtonSizeToClass, supportedInverseButtonVariants } from \"@/components/base/PvButton/helpers.ts\";\nimport type { PvSelectButtonTriggerProps } from \"./types\";\n\nconst props = withDefaults(defineProps<PvSelectButtonTriggerProps>(), {\n  size: \"lg\",\n  variant: \"secondary\",\n  showDropdown: true,\n  counterStyle: \"primary\",\n});\n\ndefineEmits<{\n  (e: \"handle-clear\"): void;\n}>();\n\nconst classes = computed(() => {\n  const output = [\"pv-select-button-trigger\", \"pv-flex\", \"pv-space-between\", \"pv-full-width\"];\n  if (props.inverse && supportedInverseButtonVariants.includes(props.variant)) {\n    output.push(`pv-button-${props.variant}-inverse`);\n  } else {\n    output.push(`pv-button-${props.variant}`);\n  }\n  const sizeClass = pvButtonSizeToClass(props.size);\n  if (sizeClass) {\n    output.push(sizeClass);\n  }\n  return output;\n});\n\nconst avatarSize = computed<PvAvatarSize>(() => (props.size === \"xl\" ? \"lg\" : \"sm\"));\nconst iconSize = computed<PvIconSize>(() => (props.size === \"xl\" ? 20 : undefined));\n\nconst labelValue = computed(() => {\n  if (props.isLoading) {\n    return \"Loading...\";\n  }\n\n  if (props.selectedItems && props.selectedItems.length > 0 && props.counterStyle === \"secondary\") {\n    return props.selectedItems[0].text;\n  }\n\n  return props.label;\n});\n\nconst rendererProps = computed(() => {\n  if (!props.selectedOption) return undefined;\n\n  return {\n    ...props.selectedOption,\n    menuOptionConfig: props.menuOptionConfig,\n    queryText: null,\n    selected: true,\n  };\n});\n</script>\n\n<template>\n  <button\n    data-testid=\"pv-multi-select-button-trigger\"\n    :class=\"classes\"\n    style=\"--flex-gap: 0.25rem\"\n    :disabled=\"disabled || isLoading\"\n  >\n    <div class=\"pv-flex pv-select-button-trigger-content\">\n      <p\n        data-testid=\"pv-select-prefix-label\"\n        v-if=\"prefixLabel\"\n        class=\"pv-border-right pv-text-quaternary\"\n        style=\"padding-right: 4px\"\n      >\n        {{ prefixLabel }}\n      </p>\n      <PvCounterBadge\n        v-if=\"counterPosition === 'left' && counterValue && counterStyle === 'primary'\"\n        data-testid=\"pv-multi-select-left-counter-badge\"\n        :value=\"counterValue\"\n        :variant=\"counterBadgeVariant\"\n        size=\"sm\"\n      />\n      <template v-if=\"!isLoading && renderer && rendererProps\">\n        <component :is=\"renderer\" v-bind=\"rendererProps\" />\n      </template>\n      <template v-else>\n        <PvIcon v-if=\"icon\" data-testid=\"pv-multi-select-button-icon\" :name=\"icon\" :size=\"iconSize\" />\n        <PvCompanyLogo v-if=\"companyLogo\" :name=\"companyLogo\" size=\"sm\" />\n        <PvAvatar\n          v-if=\"avatar\"\n          class=\"pv-select-button-trigger-avatar\"\n          data-testid=\"pv-multi-select-button-avatar\"\n          :initials=\"avatar.initials\"\n          :image=\"avatar.image\"\n          :variant=\"avatar.variant\"\n          :shape=\"avatar.shape\"\n          :size=\"avatarSize\"\n        />\n        <span\n          v-if=\"isLoading || label\"\n          class=\"pv-text-body-md pv-text-regular pv-truncate pv-select-button-trigger-label\"\n          :title=\"labelValue\"\n        >\n          {{ labelValue }}\n        </span>\n      </template>\n      <PvCounterBadge\n        v-if=\"counterPosition === 'right' && counterValue && counterStyle === 'primary'\"\n        data-testid=\"pv-multi-select-right-counter-badge\"\n        :value=\"counterValue\"\n        :variant=\"counterBadgeVariant\"\n        size=\"sm\"\n      />\n      <PvCounterBadge\n        v-if=\"counterStyle === 'secondary' && (counterValue ?? 0) >= 2\"\n        data-testid=\"pv-multi-select-secondary-counter-badge\"\n        prefix=\"+\"\n        :value=\"(counterValue ?? 0) - 1\"\n        variant=\"tertiary\"\n        size=\"sm\"\n      />\n    </div>\n\n    <PvIcon v-if=\"showDropdown\" :name=\"open ? 'chevron-up' : 'chevron-down'\" />\n    <PvTooltip v-if=\"showClear\" size=\"sm\" variant=\"dark\" tooltip-position=\"top-left\">\n      <template #label>\n        <PvIcon name=\"close\" @click.stop=\"$emit('handle-clear')\" />\n      </template>\n      <template #tooltip-content> Clear Selections </template>\n    </PvTooltip>\n  </button>\n</template>\n\n<style scoped>\n/* Allow the label to truncate with an ellipsis instead of overflowing the\n   trigger when the selected option's text is wider than the button. The flex\n   wrapper and label both need min-width: 0 so the label can shrink below its\n   intrinsic content width. */\n.pv-select-button-trigger-content {\n  min-width: 0;\n}\n\n.pv-select-button-trigger {\n  height: 1.5rem;\n  padding-block: 0;\n}\n\n.pv-select-button-trigger.pv-button-large {\n  height: 2rem;\n}\n\n.pv-select-button-trigger-label {\n  min-width: 0;\n  flex: 1 1 auto;\n}\n</style>\n","<script setup lang=\"ts\">\nimport PvIcon from \"../../PvIcon/PvIcon.vue\";\nimport PvCounterBadge from \"../../PvCounterBadge/PvCounterBadge.vue\";\nimport PvCompanyLogo from \"../../PvCompanyLogo/PvCompanyLogo.vue\";\nimport PvAvatar from \"../../PvAvatar/PvAvatar.vue\";\nimport PvTooltip from \"../../PvTooltip/PvTooltip.vue\";\nimport { computed } from \"vue\";\nimport type { PvAvatarSize } from \"@/components/base/PvAvatar/types\";\nimport type { PvIconSize } from \"@/components/base/baseProps\";\nimport { pvButtonSizeToClass, supportedInverseButtonVariants } from \"@/components/base/PvButton/helpers.ts\";\nimport type { PvSelectButtonTriggerProps } from \"./types\";\n\nconst props = withDefaults(defineProps<PvSelectButtonTriggerProps>(), {\n  size: \"lg\",\n  variant: \"secondary\",\n  showDropdown: true,\n  counterStyle: \"primary\",\n});\n\ndefineEmits<{\n  (e: \"handle-clear\"): void;\n}>();\n\nconst classes = computed(() => {\n  const output = [\"pv-select-button-trigger\", \"pv-flex\", \"pv-space-between\", \"pv-full-width\"];\n  if (props.inverse && supportedInverseButtonVariants.includes(props.variant)) {\n    output.push(`pv-button-${props.variant}-inverse`);\n  } else {\n    output.push(`pv-button-${props.variant}`);\n  }\n  const sizeClass = pvButtonSizeToClass(props.size);\n  if (sizeClass) {\n    output.push(sizeClass);\n  }\n  return output;\n});\n\nconst avatarSize = computed<PvAvatarSize>(() => (props.size === \"xl\" ? \"lg\" : \"sm\"));\nconst iconSize = computed<PvIconSize>(() => (props.size === \"xl\" ? 20 : undefined));\n\nconst labelValue = computed(() => {\n  if (props.isLoading) {\n    return \"Loading...\";\n  }\n\n  if (props.selectedItems && props.selectedItems.length > 0 && props.counterStyle === \"secondary\") {\n    return props.selectedItems[0].text;\n  }\n\n  return props.label;\n});\n\nconst rendererProps = computed(() => {\n  if (!props.selectedOption) return undefined;\n\n  return {\n    ...props.selectedOption,\n    menuOptionConfig: props.menuOptionConfig,\n    queryText: null,\n    selected: true,\n  };\n});\n</script>\n\n<template>\n  <button\n    data-testid=\"pv-multi-select-button-trigger\"\n    :class=\"classes\"\n    style=\"--flex-gap: 0.25rem\"\n    :disabled=\"disabled || isLoading\"\n  >\n    <div class=\"pv-flex pv-select-button-trigger-content\">\n      <p\n        data-testid=\"pv-select-prefix-label\"\n        v-if=\"prefixLabel\"\n        class=\"pv-border-right pv-text-quaternary\"\n        style=\"padding-right: 4px\"\n      >\n        {{ prefixLabel }}\n      </p>\n      <PvCounterBadge\n        v-if=\"counterPosition === 'left' && counterValue && counterStyle === 'primary'\"\n        data-testid=\"pv-multi-select-left-counter-badge\"\n        :value=\"counterValue\"\n        :variant=\"counterBadgeVariant\"\n        size=\"sm\"\n      />\n      <template v-if=\"!isLoading && renderer && rendererProps\">\n        <component :is=\"renderer\" v-bind=\"rendererProps\" />\n      </template>\n      <template v-else>\n        <PvIcon v-if=\"icon\" data-testid=\"pv-multi-select-button-icon\" :name=\"icon\" :size=\"iconSize\" />\n        <PvCompanyLogo v-if=\"companyLogo\" :name=\"companyLogo\" size=\"sm\" />\n        <PvAvatar\n          v-if=\"avatar\"\n          class=\"pv-select-button-trigger-avatar\"\n          data-testid=\"pv-multi-select-button-avatar\"\n          :initials=\"avatar.initials\"\n          :image=\"avatar.image\"\n          :variant=\"avatar.variant\"\n          :shape=\"avatar.shape\"\n          :size=\"avatarSize\"\n        />\n        <span\n          v-if=\"isLoading || label\"\n          class=\"pv-text-body-md pv-text-regular pv-truncate pv-select-button-trigger-label\"\n          :title=\"labelValue\"\n        >\n          {{ labelValue }}\n        </span>\n      </template>\n      <PvCounterBadge\n        v-if=\"counterPosition === 'right' && counterValue && counterStyle === 'primary'\"\n        data-testid=\"pv-multi-select-right-counter-badge\"\n        :value=\"counterValue\"\n        :variant=\"counterBadgeVariant\"\n        size=\"sm\"\n      />\n      <PvCounterBadge\n        v-if=\"counterStyle === 'secondary' && (counterValue ?? 0) >= 2\"\n        data-testid=\"pv-multi-select-secondary-counter-badge\"\n        prefix=\"+\"\n        :value=\"(counterValue ?? 0) - 1\"\n        variant=\"tertiary\"\n        size=\"sm\"\n      />\n    </div>\n\n    <PvIcon v-if=\"showDropdown\" :name=\"open ? 'chevron-up' : 'chevron-down'\" />\n    <PvTooltip v-if=\"showClear\" size=\"sm\" variant=\"dark\" tooltip-position=\"top-left\">\n      <template #label>\n        <PvIcon name=\"close\" @click.stop=\"$emit('handle-clear')\" />\n      </template>\n      <template #tooltip-content> Clear Selections </template>\n    </PvTooltip>\n  </button>\n</template>\n\n<style scoped>\n/* Allow the label to truncate with an ellipsis instead of overflowing the\n   trigger when the selected option's text is wider than the button. The flex\n   wrapper and label both need min-width: 0 so the label can shrink below its\n   intrinsic content width. */\n.pv-select-button-trigger-content {\n  min-width: 0;\n}\n\n.pv-select-button-trigger {\n  height: 1.5rem;\n  padding-block: 0;\n}\n\n.pv-select-button-trigger.pv-button-large {\n  height: 2rem;\n}\n\n.pv-select-button-trigger-label {\n  min-width: 0;\n  flex: 1 1 auto;\n}\n</style>\n","<template>\n  <div class=\"pv-text-subdued pv-text-center pv-text-body-md pv-inset-square-12\">No Results Found</div>\n</template>\n","import type { MenuOption, MultiSelectState } from \"@/types\";\n\n/**\n * Returns true when an option has children, whether they are already loaded or\n * only represented by the server-provided `totalChildCount` for lazy-loading.\n * Fully loaded children still count as cascade children — this helper answers\n * \"is this a parent?\", not \"are there more children to load?\".\n */\nexport function hasCascadeChildren<T>(option: MenuOption<T>): boolean {\n  return !!option.children?.length || (option.totalChildCount ?? 0) > 0;\n}\n\n/** Recursively collect all leaf (childless) options from a tree. */\nexport function collectLeafOptions<T>(options: MenuOption<T>[]): MenuOption<T>[] {\n  return options.flatMap((option) => {\n    if (option.children?.length) return collectLeafOptions(option.children);\n    return (option.totalChildCount ?? 0) > 0 ? [] : [option];\n  });\n}\n\n/**\n * Merge two sets of leaf options, deduplicating by ID.\n *\n * Returns a single array containing every leaf from `base`, plus any leaves\n * from `overlay` whose ID doesn't already appear in `base`. This is used to\n * combine original (unfiltered) leaves with dynamically loaded (see-more)\n * leaves so that the full set is available for selection / checked-state logic.\n */\nexport function mergeLeafOptions<T>(base: MenuOption<T>[], overlay: MenuOption<T>[]): MenuOption<T>[] {\n  const seenIds = new Set(base.map((l) => l.id));\n  const extras = overlay.filter((l) => !seenIds.has(l.id));\n  return extras.length > 0 ? [...base, ...extras] : base;\n}\n\n/**\n * Count selected items, collapsing fully-selected parents to 1.\n *\n * Walks the option tree bottom-up. A parent whose leaf descendants are ALL\n * selected counts as 1 (replacing the individual counts of its sub-tree).\n * Selected leaves not under a fully-selected parent each count as 1.\n *\n * This is order-independent — it walks the tree structure directly and does\n * not depend on Map iteration order.\n */\nexport function countWithCollapsedParents<T>(options: MenuOption<T>[], selectedIds: Set<string>): number {\n  const walk = (nodes: MenuOption<T>[]): { leafCount: number; selectedLeafCount: number; displayCount: number } => {\n    let leafCount = 0;\n    let selectedLeafCount = 0;\n    let displayCount = 0;\n\n    for (const node of nodes) {\n      if (node.children?.length) {\n        const sub = walk(node.children);\n        leafCount += sub.leafCount;\n        selectedLeafCount += sub.selectedLeafCount;\n        if (sub.leafCount > 0 && sub.leafCount === sub.selectedLeafCount) {\n          displayCount += 1;\n        } else {\n          displayCount += sub.displayCount;\n        }\n      } else {\n        leafCount += 1;\n        if (selectedIds.has(node.id)) {\n          selectedLeafCount += 1;\n          displayCount += 1;\n        }\n      }\n    }\n\n    return { leafCount, selectedLeafCount, displayCount };\n  };\n\n  return walk(options).displayCount;\n}\n\nexport function countFromSelectionState(state: MultiSelectState): number {\n  return state.filter((node) => node.state === \"selected\").length;\n}\n\n/**\n * Recursively filter a tree for a search value.\n *\n * - If a node's own text matches, it is kept with all its children intact.\n * - If a node's own text does NOT match but one or more of its descendants do,\n *   the node is kept as a container showing only the matching descendants.\n *   This means a search term that matches a child will surface that child even\n *   when the parent label itself doesn't contain the search term.\n * - Nodes with no match anywhere in their subtree are removed entirely.\n */\nexport function filterOptionsRecursive<T>(\n  options: MenuOption<T>[],\n  searchValue: string,\n  showParentOnChildQueryMatch = true,\n): MenuOption<T>[] {\n  return options.flatMap((option) => {\n    const selfMatches =\n      option.text.toLocaleLowerCase().includes(searchValue) ||\n      option.searchText?.toLocaleLowerCase().includes(searchValue);\n\n    if (selfMatches) return [option]; // keep with all children intact\n\n    if (option.children?.length) {\n      const filteredChildren = filterOptionsRecursive(option.children, searchValue, showParentOnChildQueryMatch);\n      if (filteredChildren.length) {\n        return showParentOnChildQueryMatch ? [{ ...option, children: filteredChildren }] : filteredChildren;\n      }\n    }\n\n    return [];\n  });\n}\n","<script setup lang=\"ts\">\nimport PvCompanyLogo from \"@/components/base/PvCompanyLogo/PvCompanyLogo.vue\";\nimport PvIcon from \"@/components/base/PvIcon/PvIcon.vue\";\nimport PvAvatar from \"@/components/base/PvAvatar/PvAvatar.vue\";\nimport PvCounterBadge from \"@/components/base/PvCounterBadge/PvCounterBadge.vue\";\nimport PvSpinner from \"@/components/base/PvSpinner/PvSpinner.vue\";\nimport PvTooltipV2 from \"@/components/base/PvTooltipV2/PvTooltipV2.vue\";\nimport type { PvAvatarSize } from \"@/components/base/PvAvatar/types\";\nimport type { PvIconSize } from \"@/components/base/baseProps\";\nimport type { MenuOption, MenuOptionConfig } from \"@/types.ts\";\nimport { computed, onMounted, ref, watch, type CSSProperties } from \"vue\";\n\ndefineOptions({\n  inheritAttrs: false,\n});\n\ninterface PvMenuBaseItemProps extends MenuOption {\n  menuOptionConfig?: MenuOptionConfig;\n  queryText?: string | null;\n}\n\nconst props = defineProps<PvMenuBaseItemProps>();\n\nconst mainText = ref<HTMLElement | null>(null);\nconst subText = ref<HTMLElement | null>(null);\n\nconst avatarSize = computed<PvAvatarSize>(() => (props.menuOptionConfig?.size === \"lg\" ? \"sm\" : \"lg\"));\nconst iconSize = computed<PvIconSize>(() => (props.menuOptionConfig?.size === \"xl\" ? 20 : undefined));\nconst renderedSubText = computed(() => {\n  return props.subText || null;\n});\n// Wrapped text is fully visible, so it needs no hover title unless the consumer set one.\n// `anywhere` over `break-word`: both break a word only when it cannot fit, but only `anywhere` lets\n// this flex item shrink, so one long unbroken token wraps instead of widening the menu.\nconst WRAP_TEXT_STYLE: CSSProperties = { whiteSpace: \"normal\", overflowWrap: \"anywhere\" };\nconst wrapText = computed(() => !!props.menuOptionConfig?.wrapText);\nconst textStyle = computed<CSSProperties | undefined>(() => (wrapText.value ? WRAP_TEXT_STYLE : undefined));\n\nconst escapeRegex = (str: string): string => {\n  return str.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n};\n\nconst getHighlightRanges = (originalText: string, searchQuery: string, explicitRanges?: [number, number][]) => {\n  let candidates = explicitRanges;\n  if (candidates === undefined) {\n    if (!searchQuery) return [];\n    const regex = new RegExp(escapeRegex(searchQuery), \"gi\");\n    candidates = Array.from(originalText.matchAll(regex), (match) => [match.index, match.index + match[0].length]);\n  }\n  if (!Array.isArray(candidates)) return [];\n\n  const splitsSurrogate = (index: number) =>\n    /[\\uD800-\\uDBFF]/.test(originalText[index - 1] ?? \"\") && /[\\uDC00-\\uDFFF]/.test(originalText[index] ?? \"\");\n  const ranges: [number, number][] = [];\n  const valid = candidates\n    .filter(\n      (range) =>\n        Array.isArray(range) &&\n        range.length === 2 &&\n        Number.isInteger(range[0]) &&\n        Number.isInteger(range[1]) &&\n        range[0] >= 0 &&\n        range[1] <= originalText.length &&\n        range[0] < range[1] &&\n        !splitsSurrogate(range[0]) &&\n        !splitsSurrogate(range[1]),\n    )\n    .sort((a, b) => a[0] - b[0]);\n  for (const [start, end] of valid) {\n    const previous = ranges[ranges.length - 1];\n    if (previous && start <= previous[1]) previous[1] = Math.max(previous[1], end);\n    else ranges.push([start, end]);\n  }\n  return ranges;\n};\n\n// Render consumer labels as text, never HTML.\nconst highlightText = (\n  element: HTMLElement,\n  originalText: string,\n  searchQuery: string,\n  explicitRanges?: [number, number][],\n) => {\n  const ranges = getHighlightRanges(originalText, searchQuery, explicitRanges);\n  const nodes: Node[] = [];\n  let lastIndex = 0;\n  for (const [start, end] of ranges) {\n    if (start > lastIndex) {\n      nodes.push(document.createTextNode(originalText.slice(lastIndex, start)));\n    }\n    const highlight = document.createElement(\"span\");\n    highlight.dataset.testId = \"pv-matched-text\";\n    highlight.style.fontWeight = \"bold\";\n    highlight.textContent = originalText.slice(start, end);\n    nodes.push(highlight);\n    lastIndex = end;\n  }\n  if (lastIndex < originalText.length) {\n    nodes.push(document.createTextNode(originalText.slice(lastIndex)));\n  }\n  element.replaceChildren(...nodes);\n};\n\nconst applyHighlight = () => {\n  const query = props.queryText ?? \"\";\n  const mainTextMatches = query && new RegExp(escapeRegex(query), \"gi\").test(props.text);\n  if (mainText.value) {\n    highlightText(mainText.value, props.text, query, props.textMatchRanges);\n  }\n  if (subText.value && renderedSubText.value) {\n    // Each line owns its explicit ranges; unset subtext ranges keep the main-text-first fallback.\n    highlightText(subText.value, renderedSubText.value, mainTextMatches ? \"\" : query, props.subTextMatchRanges);\n  }\n};\n\nonMounted(() => {\n  applyHighlight();\n});\n\n// text and subText are watched alongside queryText: the highlight is written into the DOM\n// imperatively, so a text change that reuses the same component instance would otherwise\n// leave Vue's plain interpolation in place with no highlight. flush: \"post\" runs this after\n// that interpolation has been patched in, rather than before it overwrites the highlight.\nwatch(\n  () => [props.queryText, props.text, props.subText, props.textMatchRanges, props.subTextMatchRanges],\n  () => {\n    applyHighlight();\n  },\n  { flush: \"post\", deep: true },\n);\n</script>\n\n<template>\n  <PvAvatar\n    v-if=\"avatar\"\n    :initials=\"avatar.initials\"\n    :image=\"avatar.image\"\n    :variant=\"avatar.variant\"\n    :shape=\"avatar.shape\"\n    :size=\"avatarSize\"\n  />\n  <PvIcon :class=\"{ 'pv-text-subdued': !disabled }\" v-if=\"icon\" :name=\"icon\" :size=\"iconSize\" />\n  <PvCompanyLogo v-if=\"companyName\" :name=\"companyName\" size=\"sm\" />\n  <div\n    :class=\"['pv-full-width', 'pv-flex-vertical', { 'pv-truncate': !wrapText }]\"\n    style=\"align-items: flex-start; --flex-gap: 0\"\n  >\n    <span\n      :class=\"['pv-text-body-md', 'pv-full-width', { 'pv-truncate': !wrapText }]\"\n      :style=\"textStyle\"\n      :title=\"hoverTitle ?? (wrapText ? undefined : text)\"\n    >\n      <span ref=\"mainText\">{{ text }}</span>\n      <span v-if=\"subduedText\" :class=\"{ 'pv-text-subdued': !disabled }\" style=\"padding-left: 4px\">\n        {{ subduedText }}\n      </span>\n    </span>\n    <span\n      ref=\"subText\"\n      v-if=\"renderedSubText\"\n      :class=\"['pv-text-body-xs', 'pv-full-width', { 'pv-truncate': !wrapText, 'pv-text-subdued': !disabled }]\"\n      :style=\"textStyle\"\n      :title=\"hoverTitle ?? (wrapText ? undefined : renderedSubText)\"\n    >\n      {{ renderedSubText }}\n    </span>\n  </div>\n  <PvSpinner v-if=\"secondaryLoading\" size=\"xs\" variant=\"dark\" />\n  <PvIcon v-else-if=\"secondaryIcon\" :class=\"{ 'pv-text-subdued': !disabled }\" :name=\"secondaryIcon\" :size=\"iconSize\" />\n  <PvTooltipV2\n    v-else-if=\"description\"\n    variant=\"dark\"\n    position=\"top-center\"\n    :useTeleport=\"true\"\n    :showOnHover=\"true\"\n    :disableInteractive=\"true\"\n    style=\"pointer-events: auto\"\n  >\n    <template #trigger>\n      <!-- stop the click so reading the description doesn't also toggle the option -->\n      <PvIcon :size=\"12\" name=\"info-circle\" class=\"pv-text-subdued\" @click.stop.prevent />\n    </template>\n    <template #content>\n      <div style=\"max-width: 220px; white-space: normal; overflow-wrap: break-word\">{{ description }}</div>\n    </template>\n  </PvTooltipV2>\n  <PvCounterBadge\n    v-else-if=\"secondaryText && typeof secondaryText === 'number'\"\n    :value=\"secondaryText\"\n    :variant=\"menuOptionConfig?.counterBadgeVariant\"\n  />\n  <span v-else-if=\"secondaryText && typeof secondaryText === 'string'\" class=\"pv-text-subdued pv-text-body-xs\">{{\n    secondaryText\n  }}</span>\n</template>\n","<script setup lang=\"ts\">\nimport PvCompanyLogo from \"@/components/base/PvCompanyLogo/PvCompanyLogo.vue\";\nimport PvIcon from \"@/components/base/PvIcon/PvIcon.vue\";\nimport PvAvatar from \"@/components/base/PvAvatar/PvAvatar.vue\";\nimport PvCounterBadge from \"@/components/base/PvCounterBadge/PvCounterBadge.vue\";\nimport PvSpinner from \"@/components/base/PvSpinner/PvSpinner.vue\";\nimport PvTooltipV2 from \"@/components/base/PvTooltipV2/PvTooltipV2.vue\";\nimport type { PvAvatarSize } from \"@/components/base/PvAvatar/types\";\nimport type { PvIconSize } from \"@/components/base/baseProps\";\nimport type { MenuOption, MenuOptionConfig } from \"@/types.ts\";\nimport { computed, onMounted, ref, watch, type CSSProperties } from \"vue\";\n\ndefineOptions({\n  inheritAttrs: false,\n});\n\ninterface PvMenuBaseItemProps extends MenuOption {\n  menuOptionConfig?: MenuOptionConfig;\n  queryText?: string | null;\n}\n\nconst props = defineProps<PvMenuBaseItemProps>();\n\nconst mainText = ref<HTMLElement | null>(null);\nconst subText = ref<HTMLElement | null>(null);\n\nconst avatarSize = computed<PvAvatarSize>(() => (props.menuOptionConfig?.size === \"lg\" ? \"sm\" : \"lg\"));\nconst iconSize = computed<PvIconSize>(() => (props.menuOptionConfig?.size === \"xl\" ? 20 : undefined));\nconst renderedSubText = computed(() => {\n  return props.subText || null;\n});\n// Wrapped text is fully visible, so it needs no hover title unless the consumer set one.\n// `anywhere` over `break-word`: both break a word only when it cannot fit, but only `anywhere` lets\n// this flex item shrink, so one long unbroken token wraps instead of widening the menu.\nconst WRAP_TEXT_STYLE: CSSProperties = { whiteSpace: \"normal\", overflowWrap: \"anywhere\" };\nconst wrapText = computed(() => !!props.menuOptionConfig?.wrapText);\nconst textStyle = computed<CSSProperties | undefined>(() => (wrapText.value ? WRAP_TEXT_STYLE : undefined));\n\nconst escapeRegex = (str: string): string => {\n  return str.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n};\n\nconst getHighlightRanges = (originalText: string, searchQuery: string, explicitRanges?: [number, number][]) => {\n  let candidates = explicitRanges;\n  if (candidates === undefined) {\n    if (!searchQuery) return [];\n    const regex = new RegExp(escapeRegex(searchQuery), \"gi\");\n    candidates = Array.from(originalText.matchAll(regex), (match) => [match.index, match.index + match[0].length]);\n  }\n  if (!Array.isArray(candidates)) return [];\n\n  const splitsSurrogate = (index: number) =>\n    /[\\uD800-\\uDBFF]/.test(originalText[index - 1] ?? \"\") && /[\\uDC00-\\uDFFF]/.test(originalText[index] ?? \"\");\n  const ranges: [number, number][] = [];\n  const valid = candidates\n    .filter(\n      (range) =>\n        Array.isArray(range) &&\n        range.length === 2 &&\n        Number.isInteger(range[0]) &&\n        Number.isInteger(range[1]) &&\n        range[0] >= 0 &&\n        range[1] <= originalText.length &&\n        range[0] < range[1] &&\n        !splitsSurrogate(range[0]) &&\n        !splitsSurrogate(range[1]),\n    )\n    .sort((a, b) => a[0] - b[0]);\n  for (const [start, end] of valid) {\n    const previous = ranges[ranges.length - 1];\n    if (previous && start <= previous[1]) previous[1] = Math.max(previous[1], end);\n    else ranges.push([start, end]);\n  }\n  return ranges;\n};\n\n// Render consumer labels as text, never HTML.\nconst highlightText = (\n  element: HTMLElement,\n  originalText: string,\n  searchQuery: string,\n  explicitRanges?: [number, number][],\n) => {\n  const ranges = getHighlightRanges(originalText, searchQuery, explicitRanges);\n  const nodes: Node[] = [];\n  let lastIndex = 0;\n  for (const [start, end] of ranges) {\n    if (start > lastIndex) {\n      nodes.push(document.createTextNode(originalText.slice(lastIndex, start)));\n    }\n    const highlight = document.createElement(\"span\");\n    highlight.dataset.testId = \"pv-matched-text\";\n    highlight.style.fontWeight = \"bold\";\n    highlight.textContent = originalText.slice(start, end);\n    nodes.push(highlight);\n    lastIndex = end;\n  }\n  if (lastIndex < originalText.length) {\n    nodes.push(document.createTextNode(originalText.slice(lastIndex)));\n  }\n  element.replaceChildren(...nodes);\n};\n\nconst applyHighlight = () => {\n  const query = props.queryText ?? \"\";\n  const mainTextMatches = query && new RegExp(escapeRegex(query), \"gi\").test(props.text);\n  if (mainText.value) {\n    highlightText(mainText.value, props.text, query, props.textMatchRanges);\n  }\n  if (subText.value && renderedSubText.value) {\n    // Each line owns its explicit ranges; unset subtext ranges keep the main-text-first fallback.\n    highlightText(subText.value, renderedSubText.value, mainTextMatches ? \"\" : query, props.subTextMatchRanges);\n  }\n};\n\nonMounted(() => {\n  applyHighlight();\n});\n\n// text and subText are watched alongside queryText: the highlight is written into the DOM\n// imperatively, so a text change that reuses the same component instance would otherwise\n// leave Vue's plain interpolation in place with no highlight. flush: \"post\" runs this after\n// that interpolation has been patched in, rather than before it overwrites the highlight.\nwatch(\n  () => [props.queryText, props.text, props.subText, props.textMatchRanges, props.subTextMatchRanges],\n  () => {\n    applyHighlight();\n  },\n  { flush: \"post\", deep: true },\n);\n</script>\n\n<template>\n  <PvAvatar\n    v-if=\"avatar\"\n    :initials=\"avatar.initials\"\n    :image=\"avatar.image\"\n    :variant=\"avatar.variant\"\n    :shape=\"avatar.shape\"\n    :size=\"avatarSize\"\n  />\n  <PvIcon :class=\"{ 'pv-text-subdued': !disabled }\" v-if=\"icon\" :name=\"icon\" :size=\"iconSize\" />\n  <PvCompanyLogo v-if=\"companyName\" :name=\"companyName\" size=\"sm\" />\n  <div\n    :class=\"['pv-full-width', 'pv-flex-vertical', { 'pv-truncate': !wrapText }]\"\n    style=\"align-items: flex-start; --flex-gap: 0\"\n  >\n    <span\n      :class=\"['pv-text-body-md', 'pv-full-width', { 'pv-truncate': !wrapText }]\"\n      :style=\"textStyle\"\n      :title=\"hoverTitle ?? (wrapText ? undefined : text)\"\n    >\n      <span ref=\"mainText\">{{ text }}</span>\n      <span v-if=\"subduedText\" :class=\"{ 'pv-text-subdued': !disabled }\" style=\"padding-left: 4px\">\n        {{ subduedText }}\n      </span>\n    </span>\n    <span\n      ref=\"subText\"\n      v-if=\"renderedSubText\"\n      :class=\"['pv-text-body-xs', 'pv-full-width', { 'pv-truncate': !wrapText, 'pv-text-subdued': !disabled }]\"\n      :style=\"textStyle\"\n      :title=\"hoverTitle ?? (wrapText ? undefined : renderedSubText)\"\n    >\n      {{ renderedSubText }}\n    </span>\n  </div>\n  <PvSpinner v-if=\"secondaryLoading\" size=\"xs\" variant=\"dark\" />\n  <PvIcon v-else-if=\"secondaryIcon\" :class=\"{ 'pv-text-subdued': !disabled }\" :name=\"secondaryIcon\" :size=\"iconSize\" />\n  <PvTooltipV2\n    v-else-if=\"description\"\n    variant=\"dark\"\n    position=\"top-center\"\n    :useTeleport=\"true\"\n    :showOnHover=\"true\"\n    :disableInteractive=\"true\"\n    style=\"pointer-events: auto\"\n  >\n    <template #trigger>\n      <!-- stop the click so reading the description doesn't also toggle the option -->\n      <PvIcon :size=\"12\" name=\"info-circle\" class=\"pv-text-subdued\" @click.stop.prevent />\n    </template>\n    <template #content>\n      <div style=\"max-width: 220px; white-space: normal; overflow-wrap: break-word\">{{ description }}</div>\n    </template>\n  </PvTooltipV2>\n  <PvCounterBadge\n    v-else-if=\"secondaryText && typeof secondaryText === 'number'\"\n    :value=\"secondaryText\"\n    :variant=\"menuOptionConfig?.counterBadgeVariant\"\n  />\n  <span v-else-if=\"secondaryText && typeof secondaryText === 'string'\" class=\"pv-text-subdued pv-text-body-xs\">{{\n    secondaryText\n  }}</span>\n</template>\n","<script setup lang=\"ts\">\nimport { useId } from \"vue\";\nimport { PvSwitchSize } from \"./types\";\n\ninterface PvSwitchProps {\n  /**\n   * The visual size of the switch track and thumb.\n   */\n  size?: PvSwitchSize;\n  /** Optional text label displayed next to the switch. */\n  label?: string;\n  /** Accessible name for the switch when no visible label is provided. */\n  ariaLabel?: string;\n  /** When true, the switch is non-interactive and visually dimmed. */\n  disabled?: boolean;\n  /** HTML id for the underlying checkbox input. Auto-generated when omitted. */\n  id?: string;\n  /**\n   * When true, hides the checkmark icon inside the switch thumb.\n   */\n  hideCheckIcon?: boolean;\n}\n\nconst props = withDefaults(defineProps<PvSwitchProps>(), {\n  size: \"md\",\n  disabled: false,\n  hideCheckIcon: false,\n});\n\nconst inputId = props.id ?? useId();\n\nconst value = defineModel<boolean>({ required: true });\n</script>\n\n<template>\n  <label\n    :for=\"inputId\"\n    :class=\"[\n      'pv-label pv-switch pv-label-hover',\n      {\n        'pv-input-small': size === 'md',\n        'pv-input-xsmall': size === 'sm',\n        'pv-switch-hide-check': hideCheckIcon,\n      },\n    ]\"\n  >\n    <span v-if=\"label\">{{ label }}</span>\n    <input v-model=\"value\" :disabled=\"disabled\" :aria-label=\"ariaLabel\" type=\"checkbox\" role=\"switch\" :id=\"inputId\" />\n  </label>\n</template>\n","<script setup lang=\"ts\">\nimport { useId } from \"vue\";\nimport { PvSwitchSize } from \"./types\";\n\ninterface PvSwitchProps {\n  /**\n   * The visual size of the switch track and thumb.\n   */\n  size?: PvSwitchSize;\n  /** Optional text label displayed next to the switch. */\n  label?: string;\n  /** Accessible name for the switch when no visible label is provided. */\n  ariaLabel?: string;\n  /** When true, the switch is non-interactive and visually dimmed. */\n  disabled?: boolean;\n  /** HTML id for the underlying checkbox input. Auto-generated when omitted. */\n  id?: string;\n  /**\n   * When true, hides the checkmark icon inside the switch thumb.\n   */\n  hideCheckIcon?: boolean;\n}\n\nconst props = withDefaults(defineProps<PvSwitchProps>(), {\n  size: \"md\",\n  disabled: false,\n  hideCheckIcon: false,\n});\n\nconst inputId = props.id ?? useId();\n\nconst value = defineModel<boolean>({ required: true });\n</script>\n\n<template>\n  <label\n    :for=\"inputId\"\n    :class=\"[\n      'pv-label pv-switch pv-label-hover',\n      {\n        'pv-input-small': size === 'md',\n        'pv-input-xsmall': size === 'sm',\n        'pv-switch-hide-check': hideCheckIcon,\n      },\n    ]\"\n  >\n    <span v-if=\"label\">{{ label }}</span>\n    <input v-model=\"value\" :disabled=\"disabled\" :aria-label=\"ariaLabel\" type=\"checkbox\" role=\"switch\" :id=\"inputId\" />\n  </label>\n</template>\n","<script setup lang=\"ts\">\nimport PvIcon from \"../PvIcon/PvIcon.vue\";\nimport PvTooltipV2 from \"../PvTooltipV2/PvTooltipV2.vue\";\nimport { PvAlignmentPositions, PvIconSize, PvSize } from \"../baseProps\";\n\nconst props = withDefaults(\n  defineProps<{\n    icon: string;\n    disabled?: boolean;\n    size?: Extract<PvSize, \"xs\" | \"sm\" | \"md\" | \"lg\">;\n    tooltipText: string;\n    tooltipPosition?: PvAlignmentPositions;\n    /** When false, the button is hidden until a `.pv-label` ancestor is hovered (used by menu actions). */\n    alwaysShow?: boolean;\n  }>(),\n  {\n    disabled: false,\n    size: \"md\",\n    tooltipPosition: \"top-center\",\n    alwaysShow: true,\n  },\n);\n\nconst emit = defineEmits<{ click: [MouseEvent] }>();\n\nconst mapToIconSize: Record<string, PvIconSize> = {\n  xs: 12,\n  sm: undefined,\n  md: 20,\n  lg: 24,\n};\n\nconst handleClick = (event: MouseEvent) => {\n  if (!props.disabled) {\n    emit(\"click\", event);\n  }\n};\n</script>\n\n<template>\n  <PvTooltipV2 :position=\"tooltipPosition\" :disable-interactive=\"true\" :use-teleport=\"true\">\n    <template #trigger>\n      <button\n        type=\"button\"\n        class=\"pv-button-link-tertiary\"\n        :class=\"{ 'pv-action-button-reveal-on-hover': !alwaysShow }\"\n        style=\"--button-icon-only-padding: 0px\"\n        :aria-label=\"tooltipText\"\n        :disabled=\"disabled\"\n        @click.stop=\"handleClick\"\n      >\n        <PvIcon :name=\"icon\" :size=\"mapToIconSize[size]\" />\n      </button>\n    </template>\n    <template #content v-if=\"tooltipText\">\n      {{ tooltipText }}\n    </template>\n  </PvTooltipV2>\n</template>\n","<script setup lang=\"ts\">\nimport PvIcon from \"../PvIcon/PvIcon.vue\";\nimport PvTooltipV2 from \"../PvTooltipV2/PvTooltipV2.vue\";\nimport { PvAlignmentPositions, PvIconSize, PvSize } from \"../baseProps\";\n\nconst props = withDefaults(\n  defineProps<{\n    icon: string;\n    disabled?: boolean;\n    size?: Extract<PvSize, \"xs\" | \"sm\" | \"md\" | \"lg\">;\n    tooltipText: string;\n    tooltipPosition?: PvAlignmentPositions;\n    /** When false, the button is hidden until a `.pv-label` ancestor is hovered (used by menu actions). */\n    alwaysShow?: boolean;\n  }>(),\n  {\n    disabled: false,\n    size: \"md\",\n    tooltipPosition: \"top-center\",\n    alwaysShow: true,\n  },\n);\n\nconst emit = defineEmits<{ click: [MouseEvent] }>();\n\nconst mapToIconSize: Record<string, PvIconSize> = {\n  xs: 12,\n  sm: undefined,\n  md: 20,\n  lg: 24,\n};\n\nconst handleClick = (event: MouseEvent) => {\n  if (!props.disabled) {\n    emit(\"click\", event);\n  }\n};\n</script>\n\n<template>\n  <PvTooltipV2 :position=\"tooltipPosition\" :disable-interactive=\"true\" :use-teleport=\"true\">\n    <template #trigger>\n      <button\n        type=\"button\"\n        class=\"pv-button-link-tertiary\"\n        :class=\"{ 'pv-action-button-reveal-on-hover': !alwaysShow }\"\n        style=\"--button-icon-only-padding: 0px\"\n        :aria-label=\"tooltipText\"\n        :disabled=\"disabled\"\n        @click.stop=\"handleClick\"\n      >\n        <PvIcon :name=\"icon\" :size=\"mapToIconSize[size]\" />\n      </button>\n    </template>\n    <template #content v-if=\"tooltipText\">\n      {{ tooltipText }}\n    </template>\n  </PvTooltipV2>\n</template>\n","<script setup lang=\"ts\">\nimport { computed } from \"vue\";\nimport { MenuAction, MenuOption } from \"@/types\";\nimport PvActionButton from \"@/components/base/PvActionButton/PvActionButton.vue\";\nimport PvIcon from \"@/components/base/PvIcon/PvIcon.vue\";\nimport PvTooltipV2 from \"@/components/base/PvTooltipV2/PvTooltipV2.vue\";\n\ninterface PvMenuItemActionProps {\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  action: MenuAction<any>;\n  option: MenuOption;\n  disabled?: boolean;\n}\n\nconst props = defineProps<PvMenuItemActionProps>();\n\nconst actionIcon = computed(() => {\n  return typeof props.action.icon === \"function\" ? props.action.icon(props.option) : props.action.icon;\n});\n\nconst actionDisabled = computed(() => {\n  const disabled =\n    typeof props.action.isDisabled === \"function\" ? props.action.isDisabled(props.option) : props.action.isDisabled;\n  return props.disabled || (disabled ?? false) || !props.action.action;\n});\n\nconst actionTooltip = computed(() => {\n  return typeof props.action.tooltipText === \"function\"\n    ? props.action.tooltipText(props.option)\n    : props.action.tooltipText;\n});\n\nconst actionInteractive = computed(() => {\n  const interactive =\n    typeof props.action.interactive === \"function\" ? props.action.interactive(props.option) : props.action.interactive;\n  return interactive ?? true;\n});\n\nconst alwaysShow = computed(() => {\n  return typeof props.action.alwaysShow === \"function\"\n    ? props.action.alwaysShow(props.option)\n    : props.action.alwaysShow;\n});\n\nconst handleActionClick = () => {\n  if (actionInteractive.value && !actionDisabled.value) {\n    props.action.action?.(props.option);\n  }\n};\n</script>\n\n<template>\n  <PvActionButton\n    v-if=\"actionInteractive\"\n    :icon=\"actionIcon\"\n    :tooltip-text=\"actionTooltip ?? ''\"\n    :disabled=\"actionDisabled\"\n    :always-show=\"!!alwaysShow\"\n    @click=\"handleActionClick\"\n    size=\"sm\"\n  />\n  <!-- Non-interactive actions render as an informational icon rather than a button. -->\n  <PvTooltipV2 v-else :disable-interactive=\"true\" :use-teleport=\"true\">\n    <template #trigger>\n      <!-- Stop propagation so the icon does not toggle the surrounding menu item's selection. -->\n      <span\n        class=\"pv-text-brand\"\n        :class=\"{ 'pv-action-button-reveal-on-hover': !alwaysShow }\"\n        role=\"img\"\n        :aria-label=\"actionTooltip\"\n        @click.stop\n      >\n        <PvIcon :name=\"actionIcon\" />\n      </span>\n    </template>\n    <template #content v-if=\"actionTooltip\">\n      {{ actionTooltip }}\n    </template>\n  </PvTooltipV2>\n</template>\n\n<!-- Not scoped: the reveal class lives on PvActionButton's inner button, which is outside this component's style scope. -->\n<style>\n.pv-action-button-reveal-on-hover {\n  opacity: 0;\n  transition: opacity 0.2s ease;\n}\n\n.pv-label:hover .pv-action-button-reveal-on-hover {\n  opacity: 1;\n}\n</style>\n","<script setup lang=\"ts\">\nimport { computed } from \"vue\";\nimport { MenuAction, MenuOption } from \"@/types\";\nimport PvActionButton from \"@/components/base/PvActionButton/PvActionButton.vue\";\nimport PvIcon from \"@/components/base/PvIcon/PvIcon.vue\";\nimport PvTooltipV2 from \"@/components/base/PvTooltipV2/PvTooltipV2.vue\";\n\ninterface PvMenuItemActionProps {\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  action: MenuAction<any>;\n  option: MenuOption;\n  disabled?: boolean;\n}\n\nconst props = defineProps<PvMenuItemActionProps>();\n\nconst actionIcon = computed(() => {\n  return typeof props.action.icon === \"function\" ? props.action.icon(props.option) : props.action.icon;\n});\n\nconst actionDisabled = computed(() => {\n  const disabled =\n    typeof props.action.isDisabled === \"function\" ? props.action.isDisabled(props.option) : props.action.isDisabled;\n  return props.disabled || (disabled ?? false) || !props.action.action;\n});\n\nconst actionTooltip = computed(() => {\n  return typeof props.action.tooltipText === \"function\"\n    ? props.action.tooltipText(props.option)\n    : props.action.tooltipText;\n});\n\nconst actionInteractive = computed(() => {\n  const interactive =\n    typeof props.action.interactive === \"function\" ? props.action.interactive(props.option) : props.action.interactive;\n  return interactive ?? true;\n});\n\nconst alwaysShow = computed(() => {\n  return typeof props.action.alwaysShow === \"function\"\n    ? props.action.alwaysShow(props.option)\n    : props.action.alwaysShow;\n});\n\nconst handleActionClick = () => {\n  if (actionInteractive.value && !actionDisabled.value) {\n    props.action.action?.(props.option);\n  }\n};\n</script>\n\n<template>\n  <PvActionButton\n    v-if=\"actionInteractive\"\n    :icon=\"actionIcon\"\n    :tooltip-text=\"actionTooltip ?? ''\"\n    :disabled=\"actionDisabled\"\n    :always-show=\"!!alwaysShow\"\n    @click=\"handleActionClick\"\n    size=\"sm\"\n  />\n  <!-- Non-interactive actions render as an informational icon rather than a button. -->\n  <PvTooltipV2 v-else :disable-interactive=\"true\" :use-teleport=\"true\">\n    <template #trigger>\n      <!-- Stop propagation so the icon does not toggle the surrounding menu item's selection. -->\n      <span\n        class=\"pv-text-brand\"\n        :class=\"{ 'pv-action-button-reveal-on-hover': !alwaysShow }\"\n        role=\"img\"\n        :aria-label=\"actionTooltip\"\n        @click.stop\n      >\n        <PvIcon :name=\"actionIcon\" />\n      </span>\n    </template>\n    <template #content v-if=\"actionTooltip\">\n      {{ actionTooltip }}\n    </template>\n  </PvTooltipV2>\n</template>\n\n<!-- Not scoped: the reveal class lives on PvActionButton's inner button, which is outside this component's style scope. -->\n<style>\n.pv-action-button-reveal-on-hover {\n  opacity: 0;\n  transition: opacity 0.2s ease;\n}\n\n.pv-label:hover .pv-action-button-reveal-on-hover {\n  opacity: 1;\n}\n</style>\n","import type { ComputedRef, InjectionKey, Ref } from \"vue\";\nimport type { MenuOption } from \"@/types\";\n\nexport const SelectedItemsKey: InjectionKey<Ref<MenuOption[]>> = Symbol(\"SelectedItemsKey\");\nexport const EnableCascadeSelectionKey: InjectionKey<ComputedRef<boolean>> = Symbol(\"EnableCascadeSelectionKey\");\nexport const MenuInteractionModeKey: InjectionKey<ComputedRef<boolean>> = Symbol(\"MenuInteractionModeKey\");\nexport const MenuAncestorIdsKey: InjectionKey<string[]> = Symbol(\"MenuAncestorIdsKey\");\nexport const OriginalOptionsMapKey: InjectionKey<ComputedRef<Map<string, MenuOption>>> =\n  Symbol(\"OriginalOptionsMapKey\");\nexport const CascadeSelectedParentIdsKey: InjectionKey<Ref<Set<string>>> = Symbol(\"CascadeSelectedParentIdsKey\");\nexport const CascadeDeselectedChildIdsKey: InjectionKey<Ref<Map<string, Set<string>>>> =\n  Symbol(\"CascadeDeselectedChildIdsKey\");\nexport const ParentSelectsAllChildrenKey: InjectionKey<ComputedRef<boolean>> = Symbol(\"ParentSelectsAllChildrenKey\");\nexport const EnableChildExpansionKey: InjectionKey<ComputedRef<boolean>> = Symbol(\"EnableChildExpansionKey\");\n","<script lang=\"ts\" setup>\nimport { computed, getCurrentInstance, inject, nextTick, ref, useTemplateRef } from \"vue\";\n\nimport PvMenuBaseItem from \"@/components/base/PvMenu/items/PvMenuBaseItem.vue\";\nimport PvSwitch from \"@/components/base/PvSwitch/PvSwitch.vue\";\nimport { MenuOption, MenuOptionConfig, MenuOptionSelectedEvent } from \"@/types.ts\";\nimport PvMenuItemAction from \"@/components/base/PvMenu/items/PvMenuItemAction.vue\";\nimport PvIcon from \"@/components/base/PvIcon/PvIcon.vue\";\nimport { collectLeafOptions, hasCascadeChildren, mergeLeafOptions } from \"@/components/base/PvMenu/cascadeUtils\";\nimport {\n  SelectedItemsKey,\n  EnableCascadeSelectionKey,\n  OriginalOptionsMapKey,\n  CascadeSelectedParentIdsKey,\n  MenuInteractionModeKey,\n} from \"@/components/base/PvMenu/symbols\";\n\ndefineOptions({\n  inheritAttrs: false,\n});\n\nexport interface PvMenuItemVariantProps extends MenuOption {\n  selected?: boolean;\n  indeterminate?: boolean;\n  queryText?: string | null;\n  highlightSearchText?: boolean;\n  menuOptionConfig?: MenuOptionConfig;\n  showChevron?: boolean;\n  chevronIcon?: string;\n  expanded?: boolean;\n}\n\nconst props = defineProps<PvMenuItemVariantProps>();\n\nconst inputRef = useTemplateRef<HTMLInputElement>(\"inputRef\");\n\nconst selectedItems = inject(SelectedItemsKey, undefined);\nconst enableCascadeSelection = inject(EnableCascadeSelectionKey, ref(false));\nconst originalOptionsMap = inject(OriginalOptionsMapKey, undefined);\nconst cascadeSelectedParentIds = inject(CascadeSelectedParentIdsKey, undefined);\nconst menuInteractionMode = inject(\n  MenuInteractionModeKey,\n  computed(() => false),\n);\n\n// Resolve the effective leaf options for this parent node. Always use original\n// (unfiltered) children so the checked/indeterminate state reflects all children.\n// When children have been dynamically loaded (see-more), props.children may have\n// more entries than the original snapshot — use whichever is larger.\nconst effectiveLeafOptions = computed(() => {\n  if (!enableCascadeSelection.value || !hasCascadeChildren(props)) return [];\n  const currentLeaves = props.children ? collectLeafOptions(props.children) : [];\n  if (originalOptionsMap?.value) {\n    const originalOption = originalOptionsMap.value.get(props.id);\n    const originalLeaves = originalOption?.children ? collectLeafOptions(originalOption.children) : [];\n    return mergeLeafOptions(originalLeaves, currentLeaves);\n  }\n  return currentLeaves;\n});\n\nconst isChecked = computed(() => {\n  if (!selectedItems?.value) return props.selected ?? false;\n  if (enableCascadeSelection.value && hasCascadeChildren(props)) {\n    const leafOptions = effectiveLeafOptions.value;\n    const originalLeafCount = leafOptions.length;\n    const selectedCount = leafOptions.filter((lo) => selectedItems.value.some((item) => item.id === lo.id)).length;\n    // Parent was explicitly clicked and all loaded children are selected → checked\n    if (cascadeSelectedParentIds?.value?.has(props.id) && selectedCount >= originalLeafCount) {\n      return true;\n    }\n    const totalCount = props.totalChildCount ?? originalLeafCount;\n    return totalCount > 0 && selectedCount >= totalCount;\n  }\n  return selectedItems.value.some((item) => item.id === props.id);\n});\n\nconst isIndeterminate = computed(() => {\n  if (!selectedItems?.value || !enableCascadeSelection.value || !hasCascadeChildren(props)) {\n    return props.indeterminate ?? false;\n  }\n  const leafOptions = effectiveLeafOptions.value;\n  const originalLeafCount = leafOptions.length;\n  const selectedCount = leafOptions.filter((lo) => selectedItems.value.some((item) => item.id === lo.id)).length;\n  // Parent was explicitly clicked and all loaded children are selected → not indeterminate\n  if (cascadeSelectedParentIds?.value?.has(props.id) && selectedCount >= originalLeafCount) {\n    return false;\n  }\n  const totalCount = props.totalChildCount ?? originalLeafCount;\n  return selectedCount > 0 && selectedCount < totalCount;\n});\n\nconst computedClassList = computed(() => {\n  const classes = props.classList ? [...props.classList] : [];\n  if (props.disabled) {\n    classes.push(\"pv-menu-item-disabled\");\n  } else {\n    classes.push(\"pv-menu-item\");\n  }\n  return classes;\n});\n\nconst disabledStyle = computed(() => {\n  if (props.disabled && props.menuOptionConfig?.disabledVariant !== \"ghost\") {\n    return { background: \"var(--color-background-disabled, #ececec)\" };\n  }\n  return {};\n});\n\nconst computedOption = computed(() => {\n  // Exclude classList: Vue maps it to the `class` attr on fallthrough, overriding\n  // child components' own root classes.\n  // eslint-disable-next-line @typescript-eslint/no-unused-vars\n  const { classList: _classList, ...rest } = props;\n  const option: MenuOption = {\n    ...rest,\n    avatar: props.menuOptionConfig?.variant === \"avatar\" ? props.avatar : undefined,\n    icon: props.menuOptionConfig?.variant === \"icon\" ? props.icon : undefined,\n    companyName: props.menuOptionConfig?.variant === \"company\" ? props.companyName || props.text : undefined,\n  };\n  return option;\n});\n\nconst effectiveAction = computed(() => props.action ?? props.menuOptionConfig?.action);\n\nconst inputHidden = computed(() => {\n  const variant = props.menuOptionConfig?.variant;\n  return variant !== \"checkbox\" && variant !== \"radio\";\n});\n\n// we only show the input for checkbox and radio variants\nconst inputType = computed(() => {\n  return props.menuOptionConfig?.variant === \"radio\" ? \"radio\" : \"checkbox\";\n});\n\nconst inputName = `${inputType.value}-${getCurrentInstance()?.uid}`;\n\nconst inputClass = computed(() => {\n  return props.menuOptionConfig?.variant === \"checkbox\" ? \"pv-checkbox\" : \"pv-radio\";\n});\n\nconst dataTestId = computed(() => {\n  const type =\n    props.menuOptionConfig?.variant === \"checkbox\"\n      ? \"-checkbox\"\n      : props.menuOptionConfig?.variant === \"radio\"\n        ? \"-radio\"\n        : \"\";\n  return `pv-menu${type}-item`;\n});\n\nconst emits = defineEmits<{\n  (e: \"handle-selected\", payload: MenuOptionSelectedEvent): void;\n  (e: \"toggle-expanded\"): void;\n}>();\n\nconst handleSelected = (event: Event) => {\n  if (props.disabled) {\n    return;\n  }\n  const option: MenuOption = {\n    ...props,\n  };\n  emits(\"handle-selected\", {\n    option,\n    event,\n  });\n  // After the reactive state settles, force-sync the DOM checked/indeterminate\n  // properties. Vue skips patching when the computed value doesn't change (e.g.\n  // indeterminate parent: isChecked was false before and is still false after\n  // deselecting all children), leaving the browser-toggled state stale.\n  nextTick(() => {\n    if (inputRef.value) {\n      inputRef.value.checked = isChecked.value;\n      inputRef.value.indeterminate = isIndeterminate.value;\n    }\n  });\n};\n\nconst handleMenuItemClick = (event: MouseEvent) => {\n  if (!menuInteractionMode.value) return;\n  const target = event.target as Element;\n  const interactiveTarget = target.closest(\n    \"a, button, input, select, textarea, [contenteditable], [role='button'], [role='checkbox'], [role='link'], [role='radio'], [role='switch']\",\n  );\n  if (interactiveTarget && interactiveTarget !== event.currentTarget && interactiveTarget !== inputRef.value) return;\n  event.preventDefault();\n  handleSelected(event);\n};\n</script>\n\n<template>\n  <label\n    v-bind=\"$attrs\"\n    class=\"pv-label pv-label-hover pv-flex pv-full-width pv-stack-4 pv-inset-square-8\"\n    :class=\"computedClassList\"\n    :style=\"[\n      disabledStyle,\n      { cursor: 'pointer', paddingTop: subText ? '4px' : undefined, paddingBottom: subText ? '4px' : undefined },\n    ]\"\n    :data-testid=\"dataTestId\"\n    @click=\"handleMenuItemClick\"\n  >\n    <input\n      ref=\"inputRef\"\n      :hidden=\"inputHidden\"\n      :type=\"inputType\"\n      :name=\"inputName\"\n      :checked=\"isChecked\"\n      :indeterminate=\"isIndeterminate\"\n      :class=\"inputClass\"\n      :tabindex=\"menuInteractionMode ? -1 : undefined\"\n      :aria-hidden=\"menuInteractionMode ? true : undefined\"\n      :disabled=\"disabled\"\n      @change=\"menuInteractionMode ? undefined : handleSelected($event)\"\n    />\n    <template v-if=\"menuOptionConfig?.renderer\">\n      <component :is=\"menuOptionConfig?.renderer\" v-bind=\"computedOption\" :selected=\"isChecked\" />\n    </template>\n    <template v-else>\n      <PvMenuBaseItem\n        v-bind=\"computedOption\"\n        :menuOptionConfig=\"menuOptionConfig\"\n        :queryText=\"queryText\"\n        :highlightSearchText=\"highlightSearchText\"\n      />\n    </template>\n    <PvIcon v-if=\"menuOptionConfig?.variant === 'checkmark' && isChecked\" name=\"check\" class=\"pv-text-success\" />\n    <PvSwitch\n      v-if=\"menuOptionConfig?.variant === 'toggle'\"\n      :modelValue=\"isChecked\"\n      :ariaLabel=\"props.text || 'Toggle'\"\n      size=\"sm\"\n      hideCheckIcon\n      style=\"pointer-events: none\"\n    />\n    <span v-if=\"effectiveAction\" class=\"pv-menu-item-action\">\n      <PvMenuItemAction :action=\"effectiveAction\" :option=\"props\" :disabled=\"disabled\" />\n    </span>\n    <button\n      v-if=\"showChevron\"\n      type=\"button\"\n      class=\"pv-button-ghost pv-menu-item-expand-chevron\"\n      :aria-label=\"props.text ? `Toggle children for ${props.text}` : 'Toggle children'\"\n      :aria-expanded=\"expanded\"\n      @click.prevent.stop=\"emits('toggle-expanded')\"\n    >\n      <PvIcon :name=\"chevronIcon ?? 'chevron-right'\" :size=\"12\" />\n    </button>\n  </label>\n</template>\n","<script lang=\"ts\" setup>\nimport { computed, getCurrentInstance, inject, nextTick, ref, useTemplateRef } from \"vue\";\n\nimport PvMenuBaseItem from \"@/components/base/PvMenu/items/PvMenuBaseItem.vue\";\nimport PvSwitch from \"@/components/base/PvSwitch/PvSwitch.vue\";\nimport { MenuOption, MenuOptionConfig, MenuOptionSelectedEvent } from \"@/types.ts\";\nimport PvMenuItemAction from \"@/components/base/PvMenu/items/PvMenuItemAction.vue\";\nimport PvIcon from \"@/components/base/PvIcon/PvIcon.vue\";\nimport { collectLeafOptions, hasCascadeChildren, mergeLeafOptions } from \"@/components/base/PvMenu/cascadeUtils\";\nimport {\n  SelectedItemsKey,\n  EnableCascadeSelectionKey,\n  OriginalOptionsMapKey,\n  CascadeSelectedParentIdsKey,\n  MenuInteractionModeKey,\n} from \"@/components/base/PvMenu/symbols\";\n\ndefineOptions({\n  inheritAttrs: false,\n});\n\nexport interface PvMenuItemVariantProps extends MenuOption {\n  selected?: boolean;\n  indeterminate?: boolean;\n  queryText?: string | null;\n  highlightSearchText?: boolean;\n  menuOptionConfig?: MenuOptionConfig;\n  showChevron?: boolean;\n  chevronIcon?: string;\n  expanded?: boolean;\n}\n\nconst props = defineProps<PvMenuItemVariantProps>();\n\nconst inputRef = useTemplateRef<HTMLInputElement>(\"inputRef\");\n\nconst selectedItems = inject(SelectedItemsKey, undefined);\nconst enableCascadeSelection = inject(EnableCascadeSelectionKey, ref(false));\nconst originalOptionsMap = inject(OriginalOptionsMapKey, undefined);\nconst cascadeSelectedParentIds = inject(CascadeSelectedParentIdsKey, undefined);\nconst menuInteractionMode = inject(\n  MenuInteractionModeKey,\n  computed(() => false),\n);\n\n// Resolve the effective leaf options for this parent node. Always use original\n// (unfiltered) children so the checked/indeterminate state reflects all children.\n// When children have been dynamically loaded (see-more), props.children may have\n// more entries than the original snapshot — use whichever is larger.\nconst effectiveLeafOptions = computed(() => {\n  if (!enableCascadeSelection.value || !hasCascadeChildren(props)) return [];\n  const currentLeaves = props.children ? collectLeafOptions(props.children) : [];\n  if (originalOptionsMap?.value) {\n    const originalOption = originalOptionsMap.value.get(props.id);\n    const originalLeaves = originalOption?.children ? collectLeafOptions(originalOption.children) : [];\n    return mergeLeafOptions(originalLeaves, currentLeaves);\n  }\n  return currentLeaves;\n});\n\nconst isChecked = computed(() => {\n  if (!selectedItems?.value) return props.selected ?? false;\n  if (enableCascadeSelection.value && hasCascadeChildren(props)) {\n    const leafOptions = effectiveLeafOptions.value;\n    const originalLeafCount = leafOptions.length;\n    const selectedCount = leafOptions.filter((lo) => selectedItems.value.some((item) => item.id === lo.id)).length;\n    // Parent was explicitly clicked and all loaded children are selected → checked\n    if (cascadeSelectedParentIds?.value?.has(props.id) && selectedCount >= originalLeafCount) {\n      return true;\n    }\n    const totalCount = props.totalChildCount ?? originalLeafCount;\n    return totalCount > 0 && selectedCount >= totalCount;\n  }\n  return selectedItems.value.some((item) => item.id === props.id);\n});\n\nconst isIndeterminate = computed(() => {\n  if (!selectedItems?.value || !enableCascadeSelection.value || !hasCascadeChildren(props)) {\n    return props.indeterminate ?? false;\n  }\n  const leafOptions = effectiveLeafOptions.value;\n  const originalLeafCount = leafOptions.length;\n  const selectedCount = leafOptions.filter((lo) => selectedItems.value.some((item) => item.id === lo.id)).length;\n  // Parent was explicitly clicked and all loaded children are selected → not indeterminate\n  if (cascadeSelectedParentIds?.value?.has(props.id) && selectedCount >= originalLeafCount) {\n    return false;\n  }\n  const totalCount = props.totalChildCount ?? originalLeafCount;\n  return selectedCount > 0 && selectedCount < totalCount;\n});\n\nconst computedClassList = computed(() => {\n  const classes = props.classList ? [...props.classList] : [];\n  if (props.disabled) {\n    classes.push(\"pv-menu-item-disabled\");\n  } else {\n    classes.push(\"pv-menu-item\");\n  }\n  return classes;\n});\n\nconst disabledStyle = computed(() => {\n  if (props.disabled && props.menuOptionConfig?.disabledVariant !== \"ghost\") {\n    return { background: \"var(--color-background-disabled, #ececec)\" };\n  }\n  return {};\n});\n\nconst computedOption = computed(() => {\n  // Exclude classList: Vue maps it to the `class` attr on fallthrough, overriding\n  // child components' own root classes.\n  // eslint-disable-next-line @typescript-eslint/no-unused-vars\n  const { classList: _classList, ...rest } = props;\n  const option: MenuOption = {\n    ...rest,\n    avatar: props.menuOptionConfig?.variant === \"avatar\" ? props.avatar : undefined,\n    icon: props.menuOptionConfig?.variant === \"icon\" ? props.icon : undefined,\n    companyName: props.menuOptionConfig?.variant === \"company\" ? props.companyName || props.text : undefined,\n  };\n  return option;\n});\n\nconst effectiveAction = computed(() => props.action ?? props.menuOptionConfig?.action);\n\nconst inputHidden = computed(() => {\n  const variant = props.menuOptionConfig?.variant;\n  return variant !== \"checkbox\" && variant !== \"radio\";\n});\n\n// we only show the input for checkbox and radio variants\nconst inputType = computed(() => {\n  return props.menuOptionConfig?.variant === \"radio\" ? \"radio\" : \"checkbox\";\n});\n\nconst inputName = `${inputType.value}-${getCurrentInstance()?.uid}`;\n\nconst inputClass = computed(() => {\n  return props.menuOptionConfig?.variant === \"checkbox\" ? \"pv-checkbox\" : \"pv-radio\";\n});\n\nconst dataTestId = computed(() => {\n  const type =\n    props.menuOptionConfig?.variant === \"checkbox\"\n      ? \"-checkbox\"\n      : props.menuOptionConfig?.variant === \"radio\"\n        ? \"-radio\"\n        : \"\";\n  return `pv-menu${type}-item`;\n});\n\nconst emits = defineEmits<{\n  (e: \"handle-selected\", payload: MenuOptionSelectedEvent): void;\n  (e: \"toggle-expanded\"): void;\n}>();\n\nconst handleSelected = (event: Event) => {\n  if (props.disabled) {\n    return;\n  }\n  const option: MenuOption = {\n    ...props,\n  };\n  emits(\"handle-selected\", {\n    option,\n    event,\n  });\n  // After the reactive state settles, force-sync the DOM checked/indeterminate\n  // properties. Vue skips patching when the computed value doesn't change (e.g.\n  // indeterminate parent: isChecked was false before and is still false after\n  // deselecting all children), leaving the browser-toggled state stale.\n  nextTick(() => {\n    if (inputRef.value) {\n      inputRef.value.checked = isChecked.value;\n      inputRef.value.indeterminate = isIndeterminate.value;\n    }\n  });\n};\n\nconst handleMenuItemClick = (event: MouseEvent) => {\n  if (!menuInteractionMode.value) return;\n  const target = event.target as Element;\n  const interactiveTarget = target.closest(\n    \"a, button, input, select, textarea, [contenteditable], [role='button'], [role='checkbox'], [role='link'], [role='radio'], [role='switch']\",\n  );\n  if (interactiveTarget && interactiveTarget !== event.currentTarget && interactiveTarget !== inputRef.value) return;\n  event.preventDefault();\n  handleSelected(event);\n};\n</script>\n\n<template>\n  <label\n    v-bind=\"$attrs\"\n    class=\"pv-label pv-label-hover pv-flex pv-full-width pv-stack-4 pv-inset-square-8\"\n    :class=\"computedClassList\"\n    :style=\"[\n      disabledStyle,\n      { cursor: 'pointer', paddingTop: subText ? '4px' : undefined, paddingBottom: subText ? '4px' : undefined },\n    ]\"\n    :data-testid=\"dataTestId\"\n    @click=\"handleMenuItemClick\"\n  >\n    <input\n      ref=\"inputRef\"\n      :hidden=\"inputHidden\"\n      :type=\"inputType\"\n      :name=\"inputName\"\n      :checked=\"isChecked\"\n      :indeterminate=\"isIndeterminate\"\n      :class=\"inputClass\"\n      :tabindex=\"menuInteractionMode ? -1 : undefined\"\n      :aria-hidden=\"menuInteractionMode ? true : undefined\"\n      :disabled=\"disabled\"\n      @change=\"menuInteractionMode ? undefined : handleSelected($event)\"\n    />\n    <template v-if=\"menuOptionConfig?.renderer\">\n      <component :is=\"menuOptionConfig?.renderer\" v-bind=\"computedOption\" :selected=\"isChecked\" />\n    </template>\n    <template v-else>\n      <PvMenuBaseItem\n        v-bind=\"computedOption\"\n        :menuOptionConfig=\"menuOptionConfig\"\n        :queryText=\"queryText\"\n        :highlightSearchText=\"highlightSearchText\"\n      />\n    </template>\n    <PvIcon v-if=\"menuOptionConfig?.variant === 'checkmark' && isChecked\" name=\"check\" class=\"pv-text-success\" />\n    <PvSwitch\n      v-if=\"menuOptionConfig?.variant === 'toggle'\"\n      :modelValue=\"isChecked\"\n      :ariaLabel=\"props.text || 'Toggle'\"\n      size=\"sm\"\n      hideCheckIcon\n      style=\"pointer-events: none\"\n    />\n    <span v-if=\"effectiveAction\" class=\"pv-menu-item-action\">\n      <PvMenuItemAction :action=\"effectiveAction\" :option=\"props\" :disabled=\"disabled\" />\n    </span>\n    <button\n      v-if=\"showChevron\"\n      type=\"button\"\n      class=\"pv-button-ghost pv-menu-item-expand-chevron\"\n      :aria-label=\"props.text ? `Toggle children for ${props.text}` : 'Toggle children'\"\n      :aria-expanded=\"expanded\"\n      @click.prevent.stop=\"emits('toggle-expanded')\"\n    >\n      <PvIcon :name=\"chevronIcon ?? 'chevron-right'\" :size=\"12\" />\n    </button>\n  </label>\n</template>\n","<script lang=\"ts\" setup>\nimport { computed, inject, ref, useAttrs, watch } from \"vue\";\n\nimport { MenuOption, MenuOptionConfig, MenuOptionSelectedEvent, SeeMoreEvent } from \"@/types.ts\";\nimport { hasCascadeChildren } from \"@/components/base/PvMenu/cascadeUtils\";\nimport PvMenuItemVariant from \"@/components/base/PvMenu/items/PvMenuItemVariant.vue\";\nimport PvButton from \"@/components/base/PvButton/PvButton.vue\";\nimport {\n  SelectedItemsKey,\n  EnableChildExpansionKey,\n  CascadeSelectedParentIdsKey,\n  CascadeDeselectedChildIdsKey,\n  ParentSelectsAllChildrenKey,\n  MenuInteractionModeKey,\n} from \"@/components/base/PvMenu/symbols\";\n\ndefineOptions({\n  inheritAttrs: false,\n});\n\nconst MAX_LEVEL_DEPTH = 4;\n\ninterface PvMenuItemProps extends MenuOption {\n  level?: number;\n  config?: MenuOptionConfig;\n  queryText?: string | null;\n  highlightSearchText?: boolean;\n  itemClass?: string;\n}\n\nconst props = withDefaults(defineProps<PvMenuItemProps>(), {\n  level: 0,\n});\nconst injectedSelectedItems = inject(SelectedItemsKey, undefined);\nconst modelSelectedIds = defineModel<string[]>(\"selectedIds\", { default: () => [] });\n\nconst enableChildExpansion = inject(EnableChildExpansionKey, ref(false));\nconst parentSelectsAllChildren = inject(ParentSelectsAllChildrenKey, ref(false));\nconst menuInteractionMode = inject(\n  MenuInteractionModeKey,\n  computed(() => false),\n);\nconst attrs = useAttrs();\nconst menuItemAttrs = computed(() => {\n  if (!menuInteractionMode.value) return {};\n  const allowedAttrs = new Set([\n    \"aria-checked\",\n    \"aria-controls\",\n    \"aria-disabled\",\n    \"aria-expanded\",\n    \"aria-haspopup\",\n    \"data-active\",\n    \"data-dd-action-name\",\n    \"data-option-id\",\n    \"onFocus\",\n    \"onKeydown\",\n    \"role\",\n    \"tabindex\",\n  ]);\n  return Object.fromEntries(Object.entries(attrs).filter(([key]) => allowedAttrs.has(key)));\n});\nconst cascadeSelectedParentIds = inject(CascadeSelectedParentIdsKey, undefined);\nconst cascadeDeselectedChildIds = inject(CascadeDeselectedChildIdsKey, undefined);\n\nconst isExpanded = ref(props.defaultExpanded ?? false);\n\n// Honor a later flip of `defaultExpanded` (e.g. selection resolving after an async\n// rebuild that reuses this instance). Only forces open, never overrides a manual collapse.\nwatch(\n  () => props.defaultExpanded,\n  (val) => {\n    if (val) isExpanded.value = true;\n  },\n);\n\nconst isSeeMoreLoading = ref(false);\nconst hasExhaustedChildren = ref(false);\nconst childOptions = ref<MenuOption[]>(props.children ?? []);\nconst lazyLoadedChildIds = ref<Set<string>>(new Set());\n\nwatch(\n  () => props.children,\n  (newChildren) => {\n    if (!newChildren) {\n      childOptions.value = [];\n      return;\n    }\n    // Preserve lazily loaded children (from handleSeeMore) that aren't in the\n    // new prop value, but drop any original children that were filtered out.\n    const lazyChildren = childOptions.value.filter((c) => lazyLoadedChildIds.value.has(c.id));\n    const newChildIds = new Set(newChildren.map((c) => c.id));\n    const extras = lazyChildren.filter((c) => !newChildIds.has(c.id));\n    childOptions.value = [...newChildren, ...extras];\n    hasExhaustedChildren.value = false;\n  },\n);\n\nconst toggleExpanded = () => {\n  isExpanded.value = !isExpanded.value;\n};\n\nconst paddingLeft = computed(() => ({ paddingLeft: `${props.level * 12 + 12}px` }));\n\n// Omit PvMenuItem-only props so v-bind doesn't leak them as DOM attributes\n// on PvMenuItemVariant (which doesn't declare them).\nconst variantProps = computed(() => {\n  // eslint-disable-next-line @typescript-eslint/no-unused-vars\n  const { level, config, itemClass, ...rest } = props;\n  if (menuInteractionMode.value) delete (rest as Record<string, unknown>).selectedIds;\n  return rest;\n});\n\nconst hasChildren = computed(() => {\n  return hasCascadeChildren({ ...props, children: childOptions.value }) && props.level < MAX_LEVEL_DEPTH;\n});\n\nconst showSubMenu = computed(() => {\n  if (!hasChildren.value) return false;\n  if (enableChildExpansion.value) return isExpanded.value;\n  return true;\n});\n\nconst chevronIcon = computed(() => {\n  return isExpanded.value ? \"chevron-down\" : \"chevron-right\";\n});\n\nconst optionIsSelected = (option: PvMenuItemProps): boolean => {\n  if (injectedSelectedItems && Array.isArray(injectedSelectedItems.value)) {\n    return injectedSelectedItems.value.some((item) => item.id === option.id);\n  }\n  return modelSelectedIds.value.includes(option.id);\n};\n\nconst emits = defineEmits<{\n  (e: \"handle-selected\", payload: MenuOptionSelectedEvent): void;\n  (e: \"see-more\", payload: SeeMoreEvent): void;\n}>();\n\nconst hasMoreChildren = computed(() => {\n  if (hasExhaustedChildren.value) return false;\n  if (props.totalChildCount == null) return false;\n  return props.totalChildCount > childOptions.value.length;\n});\n\nconst handleSeeMoreClick = async () => {\n  if (isSeeMoreLoading.value) return;\n\n  if (!props.handleSeeMore) {\n    emits(\"see-more\", { parentId: props.id, offset: childOptions.value.length });\n    return;\n  }\n\n  const parentIsSelected = cascadeSelectedParentIds?.value?.has(props.id) ?? false;\n\n  isSeeMoreLoading.value = true;\n  try {\n    const newChildren = await props.handleSeeMore({ parentId: props.id, offset: childOptions.value.length });\n    if (Array.isArray(newChildren) && newChildren.length > 0) {\n      const existingIds = new Set(childOptions.value.map((c) => c.id));\n      const uniqueNewChildren = newChildren.filter((c) => !existingIds.has(c.id));\n      if (uniqueNewChildren.length === 0) {\n        hasExhaustedChildren.value = true;\n        return;\n      }\n      const nextLazy = new Set(lazyLoadedChildIds.value);\n      for (const c of uniqueNewChildren) nextLazy.add(c.id);\n      lazyLoadedChildIds.value = nextLazy;\n      childOptions.value = [...childOptions.value, ...uniqueNewChildren];\n      // If the parent was selected, auto-select newly loaded children\n      // (excluding any that were explicitly deselected by the user)\n      if (parentIsSelected && injectedSelectedItems?.value) {\n        const deselected = cascadeDeselectedChildIds?.value?.get(props.id);\n        const candidates = deselected ? uniqueNewChildren.filter((c) => !deselected.has(c.id)) : uniqueNewChildren;\n        if (candidates.length > 0) {\n          const existingSelectedIds = new Set(injectedSelectedItems.value.map((item) => item.id));\n          const toSelect = candidates.filter((c) => !existingSelectedIds.has(c.id));\n          if (toSelect.length > 0) {\n            injectedSelectedItems.value = [...injectedSelectedItems.value, ...toSelect];\n          }\n        }\n      }\n    } else if (Array.isArray(newChildren)) {\n      hasExhaustedChildren.value = true;\n    }\n  } finally {\n    isSeeMoreLoading.value = false;\n  }\n};\n\nconst handleSelected = (event: MenuOptionSelectedEvent) => {\n  // If this item is expandable and has children, clicking it toggles expansion\n  // rather than selection — unless parentSelectsAllChildren is enabled, in which\n  // case the parent click should cascade-select all children (expansion stays\n  // available via the chevron button).\n  if (\n    enableChildExpansion.value &&\n    hasChildren.value &&\n    event.option.id === props.id &&\n    !parentSelectsAllChildren.value\n  ) {\n    toggleExpanded();\n    return;\n  }\n  if (!injectedSelectedItems) {\n    const index = modelSelectedIds.value.indexOf(event.option.id);\n    if (index > -1) {\n      modelSelectedIds.value = [...modelSelectedIds.value.slice(0, index), ...modelSelectedIds.value.slice(index + 1)];\n    } else {\n      modelSelectedIds.value = [...modelSelectedIds.value, event.option.id];\n    }\n  }\n  emits(\"handle-selected\", event);\n};\n\n// Bubble child handle-selected events without toggling modelSelectedIds again\n// (the child PvMenuItem already updated the shared modelSelectedIds via v-model).\nconst handleChildSelected = (event: MenuOptionSelectedEvent) => {\n  emits(\"handle-selected\", event);\n};\n</script>\n\n<template v-if=\"level < MAX_LEVEL_DEPTH\">\n  <PvMenuItemVariant\n    v-bind=\"{ ...variantProps, ...menuItemAttrs }\"\n    :children=\"childOptions\"\n    :menuOptionConfig=\"config\"\n    :queryText=\"queryText\"\n    :highlightSearchText=\"highlightSearchText\"\n    :showChevron=\"enableChildExpansion && hasChildren\"\n    :chevronIcon=\"chevronIcon\"\n    :expanded=\"isExpanded\"\n    @handle-selected=\"handleSelected\"\n    @toggle-expanded=\"toggleExpanded\"\n    :selected=\"optionIsSelected(props)\"\n  />\n  <ul v-if=\"showSubMenu\" role=\"list\" :style=\"paddingLeft\">\n    <li\n      v-for=\"childOption in childOptions\"\n      :key=\"childOption.id\"\n      :data-active=\"optionIsSelected(childOption) ? 'true' : null\"\n      :class=\"itemClass\"\n    >\n      <PvMenuItem\n        v-bind=\"childOption\"\n        :disabled=\"props.disabled || childOption.disabled\"\n        v-model:selectedIds=\"modelSelectedIds\"\n        :config=\"childOption.config ?? config\"\n        :queryText=\"queryText\"\n        :highlightSearchText=\"highlightSearchText\"\n        :level=\"level + 1\"\n        @handle-selected=\"handleChildSelected\"\n        @see-more=\"emits('see-more', $event)\"\n      />\n    </li>\n    <li v-if=\"hasMoreChildren\">\n      <PvButton\n        class=\"pv-text-brand\"\n        variant=\"ghost\"\n        label=\"See more\"\n        :loading=\"isSeeMoreLoading\"\n        data-testid=\"pv-menu-item-see-more\"\n        @click=\"handleSeeMoreClick\"\n      />\n    </li>\n  </ul>\n</template>\n","<script lang=\"ts\" setup>\nimport { computed, inject, ref, useAttrs, watch } from \"vue\";\n\nimport { MenuOption, MenuOptionConfig, MenuOptionSelectedEvent, SeeMoreEvent } from \"@/types.ts\";\nimport { hasCascadeChildren } from \"@/components/base/PvMenu/cascadeUtils\";\nimport PvMenuItemVariant from \"@/components/base/PvMenu/items/PvMenuItemVariant.vue\";\nimport PvButton from \"@/components/base/PvButton/PvButton.vue\";\nimport {\n  SelectedItemsKey,\n  EnableChildExpansionKey,\n  CascadeSelectedParentIdsKey,\n  CascadeDeselectedChildIdsKey,\n  ParentSelectsAllChildrenKey,\n  MenuInteractionModeKey,\n} from \"@/components/base/PvMenu/symbols\";\n\ndefineOptions({\n  inheritAttrs: false,\n});\n\nconst MAX_LEVEL_DEPTH = 4;\n\ninterface PvMenuItemProps extends MenuOption {\n  level?: number;\n  config?: MenuOptionConfig;\n  queryText?: string | null;\n  highlightSearchText?: boolean;\n  itemClass?: string;\n}\n\nconst props = withDefaults(defineProps<PvMenuItemProps>(), {\n  level: 0,\n});\nconst injectedSelectedItems = inject(SelectedItemsKey, undefined);\nconst modelSelectedIds = defineModel<string[]>(\"selectedIds\", { default: () => [] });\n\nconst enableChildExpansion = inject(EnableChildExpansionKey, ref(false));\nconst parentSelectsAllChildren = inject(ParentSelectsAllChildrenKey, ref(false));\nconst menuInteractionMode = inject(\n  MenuInteractionModeKey,\n  computed(() => false),\n);\nconst attrs = useAttrs();\nconst menuItemAttrs = computed(() => {\n  if (!menuInteractionMode.value) return {};\n  const allowedAttrs = new Set([\n    \"aria-checked\",\n    \"aria-controls\",\n    \"aria-disabled\",\n    \"aria-expanded\",\n    \"aria-haspopup\",\n    \"data-active\",\n    \"data-dd-action-name\",\n    \"data-option-id\",\n    \"onFocus\",\n    \"onKeydown\",\n    \"role\",\n    \"tabindex\",\n  ]);\n  return Object.fromEntries(Object.entries(attrs).filter(([key]) => allowedAttrs.has(key)));\n});\nconst cascadeSelectedParentIds = inject(CascadeSelectedParentIdsKey, undefined);\nconst cascadeDeselectedChildIds = inject(CascadeDeselectedChildIdsKey, undefined);\n\nconst isExpanded = ref(props.defaultExpanded ?? false);\n\n// Honor a later flip of `defaultExpanded` (e.g. selection resolving after an async\n// rebuild that reuses this instance). Only forces open, never overrides a manual collapse.\nwatch(\n  () => props.defaultExpanded,\n  (val) => {\n    if (val) isExpanded.value = true;\n  },\n);\n\nconst isSeeMoreLoading = ref(false);\nconst hasExhaustedChildren = ref(false);\nconst childOptions = ref<MenuOption[]>(props.children ?? []);\nconst lazyLoadedChildIds = ref<Set<string>>(new Set());\n\nwatch(\n  () => props.children,\n  (newChildren) => {\n    if (!newChildren) {\n      childOptions.value = [];\n      return;\n    }\n    // Preserve lazily loaded children (from handleSeeMore) that aren't in the\n    // new prop value, but drop any original children that were filtered out.\n    const lazyChildren = childOptions.value.filter((c) => lazyLoadedChildIds.value.has(c.id));\n    const newChildIds = new Set(newChildren.map((c) => c.id));\n    const extras = lazyChildren.filter((c) => !newChildIds.has(c.id));\n    childOptions.value = [...newChildren, ...extras];\n    hasExhaustedChildren.value = false;\n  },\n);\n\nconst toggleExpanded = () => {\n  isExpanded.value = !isExpanded.value;\n};\n\nconst paddingLeft = computed(() => ({ paddingLeft: `${props.level * 12 + 12}px` }));\n\n// Omit PvMenuItem-only props so v-bind doesn't leak them as DOM attributes\n// on PvMenuItemVariant (which doesn't declare them).\nconst variantProps = computed(() => {\n  // eslint-disable-next-line @typescript-eslint/no-unused-vars\n  const { level, config, itemClass, ...rest } = props;\n  if (menuInteractionMode.value) delete (rest as Record<string, unknown>).selectedIds;\n  return rest;\n});\n\nconst hasChildren = computed(() => {\n  return hasCascadeChildren({ ...props, children: childOptions.value }) && props.level < MAX_LEVEL_DEPTH;\n});\n\nconst showSubMenu = computed(() => {\n  if (!hasChildren.value) return false;\n  if (enableChildExpansion.value) return isExpanded.value;\n  return true;\n});\n\nconst chevronIcon = computed(() => {\n  return isExpanded.value ? \"chevron-down\" : \"chevron-right\";\n});\n\nconst optionIsSelected = (option: PvMenuItemProps): boolean => {\n  if (injectedSelectedItems && Array.isArray(injectedSelectedItems.value)) {\n    return injectedSelectedItems.value.some((item) => item.id === option.id);\n  }\n  return modelSelectedIds.value.includes(option.id);\n};\n\nconst emits = defineEmits<{\n  (e: \"handle-selected\", payload: MenuOptionSelectedEvent): void;\n  (e: \"see-more\", payload: SeeMoreEvent): void;\n}>();\n\nconst hasMoreChildren = computed(() => {\n  if (hasExhaustedChildren.value) return false;\n  if (props.totalChildCount == null) return false;\n  return props.totalChildCount > childOptions.value.length;\n});\n\nconst handleSeeMoreClick = async () => {\n  if (isSeeMoreLoading.value) return;\n\n  if (!props.handleSeeMore) {\n    emits(\"see-more\", { parentId: props.id, offset: childOptions.value.length });\n    return;\n  }\n\n  const parentIsSelected = cascadeSelectedParentIds?.value?.has(props.id) ?? false;\n\n  isSeeMoreLoading.value = true;\n  try {\n    const newChildren = await props.handleSeeMore({ parentId: props.id, offset: childOptions.value.length });\n    if (Array.isArray(newChildren) && newChildren.length > 0) {\n      const existingIds = new Set(childOptions.value.map((c) => c.id));\n      const uniqueNewChildren = newChildren.filter((c) => !existingIds.has(c.id));\n      if (uniqueNewChildren.length === 0) {\n        hasExhaustedChildren.value = true;\n        return;\n      }\n      const nextLazy = new Set(lazyLoadedChildIds.value);\n      for (const c of uniqueNewChildren) nextLazy.add(c.id);\n      lazyLoadedChildIds.value = nextLazy;\n      childOptions.value = [...childOptions.value, ...uniqueNewChildren];\n      // If the parent was selected, auto-select newly loaded children\n      // (excluding any that were explicitly deselected by the user)\n      if (parentIsSelected && injectedSelectedItems?.value) {\n        const deselected = cascadeDeselectedChildIds?.value?.get(props.id);\n        const candidates = deselected ? uniqueNewChildren.filter((c) => !deselected.has(c.id)) : uniqueNewChildren;\n        if (candidates.length > 0) {\n          const existingSelectedIds = new Set(injectedSelectedItems.value.map((item) => item.id));\n          const toSelect = candidates.filter((c) => !existingSelectedIds.has(c.id));\n          if (toSelect.length > 0) {\n            injectedSelectedItems.value = [...injectedSelectedItems.value, ...toSelect];\n          }\n        }\n      }\n    } else if (Array.isArray(newChildren)) {\n      hasExhaustedChildren.value = true;\n    }\n  } finally {\n    isSeeMoreLoading.value = false;\n  }\n};\n\nconst handleSelected = (event: MenuOptionSelectedEvent) => {\n  // If this item is expandable and has children, clicking it toggles expansion\n  // rather than selection — unless parentSelectsAllChildren is enabled, in which\n  // case the parent click should cascade-select all children (expansion stays\n  // available via the chevron button).\n  if (\n    enableChildExpansion.value &&\n    hasChildren.value &&\n    event.option.id === props.id &&\n    !parentSelectsAllChildren.value\n  ) {\n    toggleExpanded();\n    return;\n  }\n  if (!injectedSelectedItems) {\n    const index = modelSelectedIds.value.indexOf(event.option.id);\n    if (index > -1) {\n      modelSelectedIds.value = [...modelSelectedIds.value.slice(0, index), ...modelSelectedIds.value.slice(index + 1)];\n    } else {\n      modelSelectedIds.value = [...modelSelectedIds.value, event.option.id];\n    }\n  }\n  emits(\"handle-selected\", event);\n};\n\n// Bubble child handle-selected events without toggling modelSelectedIds again\n// (the child PvMenuItem already updated the shared modelSelectedIds via v-model).\nconst handleChildSelected = (event: MenuOptionSelectedEvent) => {\n  emits(\"handle-selected\", event);\n};\n</script>\n\n<template v-if=\"level < MAX_LEVEL_DEPTH\">\n  <PvMenuItemVariant\n    v-bind=\"{ ...variantProps, ...menuItemAttrs }\"\n    :children=\"childOptions\"\n    :menuOptionConfig=\"config\"\n    :queryText=\"queryText\"\n    :highlightSearchText=\"highlightSearchText\"\n    :showChevron=\"enableChildExpansion && hasChildren\"\n    :chevronIcon=\"chevronIcon\"\n    :expanded=\"isExpanded\"\n    @handle-selected=\"handleSelected\"\n    @toggle-expanded=\"toggleExpanded\"\n    :selected=\"optionIsSelected(props)\"\n  />\n  <ul v-if=\"showSubMenu\" role=\"list\" :style=\"paddingLeft\">\n    <li\n      v-for=\"childOption in childOptions\"\n      :key=\"childOption.id\"\n      :data-active=\"optionIsSelected(childOption) ? 'true' : null\"\n      :class=\"itemClass\"\n    >\n      <PvMenuItem\n        v-bind=\"childOption\"\n        :disabled=\"props.disabled || childOption.disabled\"\n        v-model:selectedIds=\"modelSelectedIds\"\n        :config=\"childOption.config ?? config\"\n        :queryText=\"queryText\"\n        :highlightSearchText=\"highlightSearchText\"\n        :level=\"level + 1\"\n        @handle-selected=\"handleChildSelected\"\n        @see-more=\"emits('see-more', $event)\"\n      />\n    </li>\n    <li v-if=\"hasMoreChildren\">\n      <PvButton\n        class=\"pv-text-brand\"\n        variant=\"ghost\"\n        label=\"See more\"\n        :loading=\"isSeeMoreLoading\"\n        data-testid=\"pv-menu-item-see-more\"\n        @click=\"handleSeeMoreClick\"\n      />\n    </li>\n  </ul>\n</template>\n","<script lang=\"ts\">\nimport { CSSProperties } from \"vue\";\n\nexport interface PvPopoverProps {\n  /** Alignment of the popover relative to its trigger. */\n  alignment?: \"top\" | \"right\" | \"top right\" | undefined;\n  /** Custom CSS properties applied to the inner list element (when isList is true). */\n  cssCustomListProperties?: CSSProperties;\n  /** Custom CSS properties applied to the popover root element. */\n  cssCustomProperties?: CSSProperties;\n  /** When true, renders the content inside a `<ul>` list element. */\n  isList?: boolean;\n  /** When true and isList is true, enables drag-and-drop reordering of list items. */\n  isSortable?: boolean;\n  /** Classes applied to the inner list element (when isList is true). */\n  listClass?: string;\n  /** id applied to the inner list element, so a trigger can reference it via aria-controls. */\n  listId?: string;\n  /** ARIA role for the inner list element. Defaults to `list`. */\n  listRole?: string;\n}\n</script>\n<script setup lang=\"ts\">\nimport { useSortable } from \"@vueuse/integrations/useSortable.mjs\";\nimport { computed, useSlots, useTemplateRef, ref } from \"vue\";\n\nconst popoverRoot = ref<HTMLElement | null>(null);\nconst el = useTemplateRef<HTMLElement>(\"popoverList\");\n\nconst props = withDefaults(defineProps<PvPopoverProps>(), {\n  alignment: undefined,\n  cssCustomProperties: () => ({}),\n  isList: false,\n  isSortable: false,\n  listClass: undefined,\n  listId: undefined,\n  listRole: \"list\",\n});\n\nconst emit = defineEmits<{\n  (e: \"list-order-updated\", value: string[]): void;\n}>();\n\nif (props.isSortable && props.isList) {\n  useSortable(el, [], {\n    animation: 150,\n    onUpdate: () => {\n      const newIds = Array.from(el.value?.children || []).map((child) => (child as HTMLElement).id);\n      emit(\"list-order-updated\", newIds);\n    },\n  });\n}\n\nconst slots = useSlots();\n// Header/footer stay pinned while the list scrolls, so the root becomes the flex\n// container and the list takes over the scrolling. Only applied when a section is\n// actually provided, leaving the default popover layout untouched.\nconst hasPinnedSections = computed(() => Boolean(slots.header || slots.footer));\n\ndefineExpose({ popoverRoot });\n</script>\n<template>\n  <div\n    ref=\"popoverRoot\"\n    class=\"pv-popover\"\n    :class=\"{ 'pv-popover-pinned-sections': isList && hasPinnedSections }\"\n    data-testid=\"pv-popover\"\n    :data-align=\"alignment\"\n    :style=\"cssCustomProperties\"\n  >\n    <template v-if=\"isList\">\n      <slot name=\"header\"></slot>\n      <ul\n        :id=\"listId\"\n        ref=\"popoverList\"\n        :role=\"listRole\"\n        class=\"pv-popover-list\"\n        :class=\"listClass\"\n        :style=\"cssCustomListProperties\"\n      >\n        <slot></slot>\n      </ul>\n      <slot name=\"footer\"></slot>\n    </template>\n    <slot v-else></slot>\n  </div>\n</template>\n\n<style scoped>\n.pv-popover-list {\n  font-size: 14px;\n}\n\n.pv-popover-pinned-sections {\n  display: flex;\n  flex-direction: column;\n  overflow: hidden;\n}\n\n.pv-popover-pinned-sections .pv-popover-list {\n  overflow-y: auto;\n}\n</style>\n","<script lang=\"ts\">\nimport { CSSProperties } from \"vue\";\n\nexport interface PvPopoverProps {\n  /** Alignment of the popover relative to its trigger. */\n  alignment?: \"top\" | \"right\" | \"top right\" | undefined;\n  /** Custom CSS properties applied to the inner list element (when isList is true). */\n  cssCustomListProperties?: CSSProperties;\n  /** Custom CSS properties applied to the popover root element. */\n  cssCustomProperties?: CSSProperties;\n  /** When true, renders the content inside a `<ul>` list element. */\n  isList?: boolean;\n  /** When true and isList is true, enables drag-and-drop reordering of list items. */\n  isSortable?: boolean;\n  /** Classes applied to the inner list element (when isList is true). */\n  listClass?: string;\n  /** id applied to the inner list element, so a trigger can reference it via aria-controls. */\n  listId?: string;\n  /** ARIA role for the inner list element. Defaults to `list`. */\n  listRole?: string;\n}\n</script>\n<script setup lang=\"ts\">\nimport { useSortable } from \"@vueuse/integrations/useSortable.mjs\";\nimport { computed, useSlots, useTemplateRef, ref } from \"vue\";\n\nconst popoverRoot = ref<HTMLElement | null>(null);\nconst el = useTemplateRef<HTMLElement>(\"popoverList\");\n\nconst props = withDefaults(defineProps<PvPopoverProps>(), {\n  alignment: undefined,\n  cssCustomProperties: () => ({}),\n  isList: false,\n  isSortable: false,\n  listClass: undefined,\n  listId: undefined,\n  listRole: \"list\",\n});\n\nconst emit = defineEmits<{\n  (e: \"list-order-updated\", value: string[]): void;\n}>();\n\nif (props.isSortable && props.isList) {\n  useSortable(el, [], {\n    animation: 150,\n    onUpdate: () => {\n      const newIds = Array.from(el.value?.children || []).map((child) => (child as HTMLElement).id);\n      emit(\"list-order-updated\", newIds);\n    },\n  });\n}\n\nconst slots = useSlots();\n// Header/footer stay pinned while the list scrolls, so the root becomes the flex\n// container and the list takes over the scrolling. Only applied when a section is\n// actually provided, leaving the default popover layout untouched.\nconst hasPinnedSections = computed(() => Boolean(slots.header || slots.footer));\n\ndefineExpose({ popoverRoot });\n</script>\n<template>\n  <div\n    ref=\"popoverRoot\"\n    class=\"pv-popover\"\n    :class=\"{ 'pv-popover-pinned-sections': isList && hasPinnedSections }\"\n    data-testid=\"pv-popover\"\n    :data-align=\"alignment\"\n    :style=\"cssCustomProperties\"\n  >\n    <template v-if=\"isList\">\n      <slot name=\"header\"></slot>\n      <ul\n        :id=\"listId\"\n        ref=\"popoverList\"\n        :role=\"listRole\"\n        class=\"pv-popover-list\"\n        :class=\"listClass\"\n        :style=\"cssCustomListProperties\"\n      >\n        <slot></slot>\n      </ul>\n      <slot name=\"footer\"></slot>\n    </template>\n    <slot v-else></slot>\n  </div>\n</template>\n\n<style scoped>\n.pv-popover-list {\n  font-size: 14px;\n}\n\n.pv-popover-pinned-sections {\n  display: flex;\n  flex-direction: column;\n  overflow: hidden;\n}\n\n.pv-popover-pinned-sections .pv-popover-list {\n  overflow-y: auto;\n}\n</style>\n","<script setup lang=\"ts\">\nimport { computed, inject, nextTick, provide, ref, shallowRef, useId, watch } from \"vue\";\nimport type { VNodeChild } from \"vue\";\nimport { autoUpdate, flip, offset, shift, useFloating } from \"@floating-ui/vue\";\nimport { onClickOutside } from \"@vueuse/core\";\n\nimport { MenuOption, MenuOptionSelectedEvent, SeeMoreEvent } from \"@/types\";\nimport PvMenuItem from \"@/components/base/PvMenu/items/PvMenuItem.vue\";\nimport PvButton from \"@/components/base/PvButton/PvButton.vue\";\nimport PvPopover from \"@/components/base/PvPopover/PvPopover.vue\";\nimport { PvMenuProps } from \"./types\";\nimport { collectLeafOptions, hasCascadeChildren, mergeLeafOptions } from \"./cascadeUtils\";\nimport {\n  SelectedItemsKey,\n  EnableCascadeSelectionKey,\n  MenuInteractionModeKey,\n  MenuAncestorIdsKey,\n  OriginalOptionsMapKey,\n  ParentSelectsAllChildrenKey,\n  CascadeSelectedParentIdsKey,\n  CascadeDeselectedChildIdsKey,\n} from \"./symbols\";\n\ndefineOptions({\n  inheritAttrs: false,\n});\n\nconst props = withDefaults(defineProps<PvMenuProps>(), {\n  childrenDisplay: \"inline\",\n  highlightParentItems: true,\n});\n\nconst emit = defineEmits<{\n  (e: \"handle-selected\", payload: MenuOptionSelectedEvent): void;\n  (e: \"see-more\", payload: SeeMoreEvent): void;\n}>();\n\ndefineSlots<{\n  popover?(props: { option: MenuOption; popoverId: string; close: () => void }): VNodeChild;\n}>();\n\nconst selectedItems = defineModel<MenuOption[]>(\"selectedItems\", { default: () => [] });\nconst expandedOptionId = defineModel<string | undefined>(\"expandedOptionId\");\n\nconst nestedMenuId = useId();\nconst rootMenuRef = ref<HTMLElement | null>(null);\nconst nestedMenuRef = ref<HTMLElement | null>(null);\nconst nestedMenuPopoverRef = ref<HTMLElement | null>(null);\nconst nestedMenuTriggerRef = ref<HTMLElement | null>(null);\n\nconst { floatingStyles, update: updateNestedMenuPosition } = useFloating(nestedMenuTriggerRef, nestedMenuPopoverRef, {\n  middleware: [offset(4), flip(), shift({ padding: 8 })],\n  placement: \"right-start\",\n  strategy: \"fixed\",\n  whileElementsMounted: autoUpdate,\n});\n\nconst closeNestedMenu = () => {\n  if (expandedOptionId.value !== undefined) expandedOptionId.value = undefined;\n};\n\nconst closeNestedMenuAndRestoreFocus = () => {\n  const parentId = expandedOptionId.value;\n  closeNestedMenu();\n  if (parentId) nextTick(() => focusParentOption(parentId));\n};\n\nconst ancestorMenuIds = inject(MenuAncestorIdsKey, []);\nconst menuHierarchyIds = [...ancestorMenuIds, nestedMenuId];\nprovide(MenuAncestorIdsKey, menuHierarchyIds);\n\nonClickOutside(\n  rootMenuRef,\n  (event) => {\n    const ancestorIds =\n      event.target instanceof Element\n        ? event.target.closest<HTMLElement>(\"[data-pv-menu-ancestors]\")?.dataset.pvMenuAncestors?.split(\" \")\n        : undefined;\n    if (!ancestorIds?.includes(nestedMenuId)) closeNestedMenu();\n  },\n  { ignore: [nestedMenuPopoverRef] },\n);\n\n// Vue 3.5 defineModel doesn't update local value synchronously when the prop\n// is passed by a parent (it only emits and waits for the parent to re-render).\n// This local ref is updated immediately so consecutive selections read correct state.\nconst localSelectedItems = shallowRef<MenuOption[]>(selectedItems.value);\n\nwatch(selectedItems, (newVal) => {\n  localSelectedItems.value = newVal;\n});\n\n// The last value this component itself pushed into the model. The sync-back watcher below must\n// skip own writes: because defineModel doesn't reflect a set until the parent re-renders,\n// comparing newVal against selectedItems.value alone mistakes every own write for a descendant\n// mutation and pushes it again — emitting update:selectedItems twice per selection (and, through\n// PvSelectButton, a doubled update:modelValue).\nlet lastModelWrite: MenuOption[] | undefined;\nconst writeSelectedItems = (value: MenuOption[]) => {\n  lastModelWrite = value;\n  selectedItems.value = value;\n};\n\n// Sync back to the model when descendants mutate localSelectedItems directly\n// (e.g. auto-selecting lazy-loaded children in PvMenuItem.handleSeeMoreClick).\nwatch(localSelectedItems, (newVal) => {\n  if (newVal !== lastModelWrite && newVal !== selectedItems.value) {\n    writeSelectedItems(newVal);\n  }\n});\n\nprovide(SelectedItemsKey, localSelectedItems);\nprovide(\n  MenuInteractionModeKey,\n  computed(() => props.childrenDisplay === \"popover\"),\n);\nconst cascadeSelectionEnabled = computed(() => props.childrenDisplay === \"inline\" && !!props.enableCascadeSelection);\nprovide(EnableCascadeSelectionKey, cascadeSelectionEnabled);\n\nconst originalOptionsMap = inject(OriginalOptionsMapKey, undefined);\nconst parentSelectsAllChildren = inject(ParentSelectsAllChildrenKey, ref(false));\nconst cascadeSelectedParentIds = inject(CascadeSelectedParentIdsKey, undefined);\nconst cascadeDeselectedChildIds = inject(CascadeDeselectedChildIdsKey, undefined);\n\nconst isSingleSelect = computed(() => props.singleSelect || props.config?.variant === \"radio\");\nconst expandedOption = computed(() =>\n  props.options.find((option) => option.id === expandedOptionId.value && option.children?.length),\n);\n\nconst openNestedMenu = (option: MenuOption, target: HTMLElement, focusFirstItem = false, toggle = true) => {\n  const shouldOpen = !toggle || expandedOptionId.value !== option.id;\n  expandedOptionId.value = shouldOpen ? option.id : undefined;\n  if (!shouldOpen) return;\n\n  nestedMenuTriggerRef.value = target;\n  nextTick(() => {\n    updateNestedMenuPosition();\n    if (focusFirstItem) {\n      focusMenuItem(nestedMenuRef.value ?? document.getElementById(nestedMenuId), 0);\n    }\n  });\n};\n\nconst handleItemSelected = (event: MenuOptionSelectedEvent, nested = false) => {\n  if (props.readOnly) return;\n  const option =\n    (!nested && props.childrenDisplay === \"popover\"\n      ? props.options.find((candidate) => candidate.id === event.option.id)\n      : undefined) ?? event.option;\n  if (props.childrenDisplay === \"popover\" && !nested && option.children?.length) {\n    const target = (event.event.currentTarget as HTMLElement | null)?.closest<HTMLElement>(\"li\");\n    if (target) openNestedMenu(option, target);\n    return;\n  }\n  let newSelection: MenuOption[];\n\n  if (cascadeSelectionEnabled.value && hasCascadeChildren(option)) {\n    // Only leaf options are added to the selection — the parent itself is never\n    // included because it is purely an organisational node, not a selectable value.\n    // When parentSelectsAllChildren is true, use the original (unfiltered)\n    // children so clicking a parent selects all children regardless of search query.\n    let leafOptions: MenuOption[];\n    if (parentSelectsAllChildren.value && originalOptionsMap?.value) {\n      const originalOption = originalOptionsMap.value.get(option.id);\n      const originalLeaves = originalOption?.children ? collectLeafOptions(originalOption.children) : [];\n      const currentLeaves = option.children ? collectLeafOptions(option.children) : [];\n      leafOptions = mergeLeafOptions(originalLeaves, currentLeaves);\n    } else {\n      leafOptions = option.children ? collectLeafOptions(option.children) : [];\n    }\n    const leafIds = leafOptions.map((o) => o.id);\n    const current = localSelectedItems.value;\n    const parentSelected = cascadeSelectedParentIds?.value?.has(option.id) ?? false;\n    const anySelected = parentSelected || leafIds.some((id) => current.some((item) => item.id === id));\n    newSelection = anySelected ? current.filter((item) => !leafIds.includes(item.id)) : [...current, ...leafOptions];\n\n    // Track whether this parent was explicitly clicked for cascade selection\n    if (cascadeSelectedParentIds?.value) {\n      const next = new Set(cascadeSelectedParentIds.value);\n      if (anySelected) {\n        next.delete(option.id);\n      } else {\n        next.add(option.id);\n      }\n      cascadeSelectedParentIds.value = next;\n    }\n    // Clear deselected children tracking when parent is explicitly toggled\n    if (cascadeDeselectedChildIds?.value?.has(option.id)) {\n      const next = new Map(cascadeDeselectedChildIds.value);\n      next.delete(option.id);\n      cascadeDeselectedChildIds.value = next;\n    }\n  } else if (isSingleSelect.value) {\n    if (localSelectedItems.value.length === 1 && localSelectedItems.value[0].id === option.id) {\n      newSelection = props.disableDeselect ? localSelectedItems.value : [];\n    } else {\n      newSelection = [option];\n    }\n  } else {\n    const index = localSelectedItems.value.findIndex((item) => item.id === option.id);\n    if (index > -1) {\n      newSelection = [...localSelectedItems.value.slice(0, index), ...localSelectedItems.value.slice(index + 1)];\n    } else {\n      newSelection = [...localSelectedItems.value, option];\n    }\n\n    // Track individually deselected/re-selected children under selected parents\n    // so dynamically loaded children (see-more) can inherit the correct state.\n    if (cascadeSelectionEnabled.value && cascadeSelectedParentIds?.value && cascadeDeselectedChildIds?.value) {\n      const isDeselecting = index > -1;\n      for (const parentId of cascadeSelectedParentIds.value) {\n        // Find if this child belongs to this parent\n        const parentOption = originalOptionsMap?.value?.get(parentId);\n        const parentChildren = parentOption?.children ?? props.options.find((o) => o.id === parentId)?.children;\n        if (!parentChildren) continue;\n        const leaves = collectLeafOptions(parentChildren);\n        // Also check the option itself as it may have been dynamically loaded\n        const isChildOfParent =\n          leaves.some((l) => l.id === option.id) ||\n          props.options.find((o) => o.id === parentId)?.children?.some((c) => c.id === option.id);\n        if (!isChildOfParent) continue;\n\n        const next = new Map(cascadeDeselectedChildIds.value);\n        const deselected = new Set(next.get(parentId) ?? []);\n        if (isDeselecting) {\n          deselected.add(option.id);\n        } else {\n          deselected.delete(option.id);\n        }\n        if (deselected.size > 0) {\n          next.set(parentId, deselected);\n        } else {\n          next.delete(parentId);\n        }\n        cascadeDeselectedChildIds.value = next;\n        break;\n      }\n    }\n  }\n\n  localSelectedItems.value = newSelection;\n  writeSelectedItems(newSelection);\n\n  if (!nested && props.childrenDisplay === \"popover\") expandedOptionId.value = undefined;\n  emit(\"handle-selected\", props.childrenDisplay === \"popover\" ? { ...event, option } : event);\n};\n\nconst handleNestedItemSelected = (event: MenuOptionSelectedEvent) => {\n  const parentOption = expandedOption.value;\n  if (!parentOption) return;\n  const option = parentOption.children?.find((child) => child.id === event.option.id) ?? event.option;\n  handleItemSelected({ ...event, option }, true);\n  expandedOptionId.value = undefined;\n  nextTick(() => focusParentOption(parentOption.id));\n};\n\nconst selectedIds = computed(() => new Set(localSelectedItems.value.map((item) => item.id)));\n\nconst findSelectedDescendant = (children: MenuOption[]): MenuOption | undefined => {\n  for (const child of children) {\n    if (selectedIds.value.has(child.id)) return child;\n    const selectedChild = child.children?.length ? findSelectedDescendant(child.children) : undefined;\n    if (selectedChild) return selectedChild;\n  }\n  return undefined;\n};\n\nconst menuItemOption = (option: MenuOption): MenuOption => {\n  if (props.childrenDisplay !== \"popover\" || !option.children?.length) return option;\n  const selectedChild = findSelectedDescendant(option.children);\n  return {\n    ...option,\n    children: undefined,\n    classList: [...(option.classList ?? []), \"pv-menu-nested\"],\n    subText: selectedChild?.text ?? option.subText,\n    totalChildCount: undefined,\n  };\n};\n\nconst directChildMenuItemOption = (option: MenuOption): MenuOption => ({\n  ...option,\n  children: undefined,\n  totalChildCount: undefined,\n});\n\nconst menuItemConfig = (option: MenuOption) =>\n  props.childrenDisplay === \"popover\" ? (option.config ?? props.config) : props.config;\n\nconst isActive = (option: MenuOption): true | null => {\n  if (selectedIds.value.has(option.id)) {\n    return true;\n  }\n  if (cascadeSelectionEnabled.value && cascadeSelectedParentIds?.value?.has(option.id)) {\n    return true;\n  }\n  if (\n    (cascadeSelectionEnabled.value || props.childrenDisplay === \"popover\") &&\n    option.children?.length &&\n    findSelectedDescendant(option.children)\n  ) {\n    return true;\n  }\n  return null;\n};\n\nconst menuItemRole = (option: MenuOption): \"menuitem\" | \"menuitemcheckbox\" | \"menuitemradio\" => {\n  const variant = option.config?.variant ?? props.config?.variant;\n  if (isSingleSelect.value || variant === \"radio\") return \"menuitemradio\";\n  if (variant === \"checkbox\") return \"menuitemcheckbox\";\n  return \"menuitem\";\n};\n\nconst menuItemChecked = (option: MenuOption): boolean | undefined =>\n  menuItemRole(option) === \"menuitem\" ? undefined : !!isActive(option);\n\nconst itemDataActive = (option: MenuOption): true | null => {\n  if (option.children?.length && !props.highlightParentItems) return null;\n  return (menuItemRole(option) !== \"menuitemcheckbox\" && isActive(option)) || expandedOptionId.value === option.id\n    ? true\n    : null;\n};\n\nconst nestedItemDataActive = (option: MenuOption): true | null =>\n  menuItemRole(option) !== \"menuitemcheckbox\" && selectedIds.value.has(option.id) ? true : null;\n\nconst isVisible = (option: MenuOption, isLoading?: boolean): boolean => {\n  if (!isLoading) return true;\n  if (selectedIds.value.has(option.id)) return true;\n  if (cascadeSelectedParentIds?.value?.has(option.id)) return true;\n  if (option.children?.length && findSelectedDescendant(option.children)) return true;\n  return false;\n};\n\nconst SEE_MORE_OPTION_ID = \"__pv-menu-see-more__\";\nconst focusedTopLevelOptionId = ref<string>();\nconst focusedNestedOptionId = ref<string>();\n\nconst topLevelTabStopId = computed(() => {\n  const focusableOptionIds = props.options\n    .filter((option) => !props.readOnly && !option.disabled && isVisible(option, props.isLoading))\n    .map((option) => option.id);\n  if (props.hasMoreOptions && !props.isSeeMoreLoading) focusableOptionIds.push(SEE_MORE_OPTION_ID);\n  return focusedTopLevelOptionId.value && focusableOptionIds.includes(focusedTopLevelOptionId.value)\n    ? focusedTopLevelOptionId.value\n    : focusableOptionIds[0];\n});\n\nconst nestedTabStopId = computed(() => {\n  const focusableOptions =\n    expandedOption.value?.children?.filter((option) => !props.readOnly && !option.disabled) ?? [];\n  return focusableOptions.some((option) => option.id === focusedNestedOptionId.value)\n    ? focusedNestedOptionId.value\n    : focusableOptions[0]?.id;\n});\n\nconst menuItems = (menu: HTMLElement | null): HTMLElement[] => {\n  const roleItems = Array.from(\n    menu?.querySelectorAll<HTMLElement>(\"li[role='none'] > [role^='menuitem']:not([aria-disabled='true'])\") ?? [],\n  ).filter((item) => !item.hidden && item.style.display !== \"none\");\n  if (roleItems.length) return roleItems;\n\n  return Array.from(\n    menu?.querySelectorAll<HTMLElement>(\n      \"button:not(:disabled), [href], input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex='-1'])\",\n    ) ?? [],\n  ).filter((item) => !item.hidden && item.style.display !== \"none\");\n};\n\nconst focusMenuItem = (menu: HTMLElement | null, index: number) => {\n  const items = menuItems(menu);\n  if (!items.length) return;\n  items[(index + items.length) % items.length]?.focus();\n};\n\nconst focusRelativeMenuItem = (menu: HTMLElement | null, current: HTMLElement, offset: number) => {\n  const items = menuItems(menu);\n  const currentIndex = items.indexOf(current);\n  if (!items.length || currentIndex < 0) return;\n  items[(currentIndex + offset + items.length) % items.length]?.focus();\n};\n\nconst focusParentOption = (optionId: string) => {\n  menuItems(rootMenuRef.value)\n    .find((item) => item.dataset.optionId === optionId)\n    ?.focus();\n};\n\nwatch(\n  // Also re-sync when the row leaves and re-enters `options`, since its <li> is re-created.\n  [expandedOptionId, () => !!expandedOption.value],\n  ([optionId]) => {\n    focusedNestedOptionId.value = undefined;\n    if (!optionId) return;\n    nextTick(() => {\n      const target = Array.from(rootMenuRef.value?.children ?? []).find(\n        (item) => (item as HTMLElement).dataset.optionId === optionId,\n      ) as HTMLElement | undefined;\n      if (!target) return;\n      nestedMenuTriggerRef.value = target;\n      updateNestedMenuPosition();\n    });\n  },\n  { immediate: true },\n);\n\nconst handleMenuNavigation = (event: KeyboardEvent, menu: HTMLElement | null): boolean => {\n  switch (event.key) {\n    case \"ArrowDown\":\n      event.preventDefault();\n      focusRelativeMenuItem(menu, event.currentTarget as HTMLElement, 1);\n      return true;\n    case \"ArrowUp\":\n      event.preventDefault();\n      focusRelativeMenuItem(menu, event.currentTarget as HTMLElement, -1);\n      return true;\n    case \"Home\":\n      event.preventDefault();\n      focusMenuItem(menu, 0);\n      return true;\n    case \"End\":\n      event.preventDefault();\n      focusMenuItem(menu, -1);\n      return true;\n    default:\n      return false;\n  }\n};\n\nconst handleTopLevelKeydown = (event: KeyboardEvent, option: MenuOption) => {\n  if (event.target !== event.currentTarget || handleMenuNavigation(event, rootMenuRef.value)) return;\n  switch (event.key) {\n    case \"ArrowRight\":\n      if (!option.children?.length) break;\n      event.preventDefault();\n      openNestedMenu(option, event.currentTarget as HTMLElement, true, false);\n      break;\n    case \"Enter\":\n    case \" \":\n      event.preventDefault();\n      if (option.children?.length) {\n        openNestedMenu(option, event.currentTarget as HTMLElement, true, false);\n      } else {\n        handleItemSelected({ event, option });\n      }\n      break;\n    case \"Escape\":\n      if (!expandedOptionId.value) break;\n      event.preventDefault();\n      event.stopPropagation();\n      expandedOptionId.value = undefined;\n      break;\n    case \"Tab\":\n      expandedOptionId.value = undefined;\n      break;\n  }\n};\n\nconst handleSeeMoreKeydown = (event: KeyboardEvent) => {\n  if (handleMenuNavigation(event, rootMenuRef.value)) return;\n  switch (event.key) {\n    case \"Enter\":\n    case \" \":\n      event.preventDefault();\n      emit(\"see-more\", { parentId: undefined });\n      break;\n    case \"Escape\":\n    case \"Tab\":\n      closeNestedMenu();\n      break;\n  }\n};\n\nconst handleNestedKeydown = (event: KeyboardEvent, option: MenuOption) => {\n  if (event.target !== event.currentTarget || handleMenuNavigation(event, nestedMenuRef.value)) return;\n  switch (event.key) {\n    case \"ArrowLeft\":\n    case \"Escape\": {\n      event.preventDefault();\n      if (event.key === \"Escape\") event.stopPropagation();\n      const parentId = expandedOptionId.value;\n      expandedOptionId.value = undefined;\n      if (parentId) nextTick(() => focusParentOption(parentId));\n      break;\n    }\n    case \"Enter\":\n    case \" \":\n      event.preventDefault();\n      handleNestedItemSelected({ event, option });\n      break;\n    case \"Tab\":\n      expandedOptionId.value = undefined;\n      break;\n  }\n};\n</script>\n\n<template>\n  <ul ref=\"rootMenuRef\" :role=\"childrenDisplay === 'popover' ? 'menu' : 'list'\" class=\"pv-popover-list\" v-bind=\"$attrs\">\n    <li\n      v-for=\"option in options\"\n      v-show=\"isVisible(option, isLoading)\"\n      :key=\"option.id\"\n      :data-active=\"itemDataActive(option)\"\n      :data-option-id=\"option.id\"\n      :data-testid=\"itemTestId\"\n      :class=\"itemClass\"\n      :role=\"childrenDisplay === 'popover' ? 'none' : undefined\"\n    >\n      <PvMenuItem\n        v-bind=\"menuItemOption(option)\"\n        :aria-checked=\"childrenDisplay === 'popover' ? menuItemChecked(option) : undefined\"\n        :aria-controls=\"childrenDisplay === 'popover' && option.children?.length ? nestedMenuId : undefined\"\n        :aria-disabled=\"childrenDisplay === 'popover' && (props.readOnly || option.disabled) ? 'true' : undefined\"\n        :aria-expanded=\"\n          childrenDisplay === 'popover' && option.children?.length ? expandedOptionId === option.id : undefined\n        \"\n        :aria-haspopup=\"\n          childrenDisplay === 'popover' && option.children?.length ? (option.popoverRole ?? 'menu') : undefined\n        \"\n        :data-active=\"itemDataActive(option)\"\n        :data-dd-action-name=\"option.rumActionName\"\n        :data-option-id=\"option.id\"\n        :disabled=\"props.readOnly || option.disabled\"\n        :config=\"menuItemConfig(option)\"\n        :itemClass=\"itemClass\"\n        :queryText=\"queryText\"\n        :role=\"childrenDisplay === 'popover' ? menuItemRole(option) : undefined\"\n        :tabindex=\"childrenDisplay === 'popover' ? (topLevelTabStopId === option.id ? 0 : -1) : undefined\"\n        @focus=\"focusedTopLevelOptionId = option.id\"\n        @keydown=\"childrenDisplay === 'popover' ? handleTopLevelKeydown($event, option) : undefined\"\n        @handle-selected=\"handleItemSelected\"\n        @see-more=\"emit('see-more', $event)\"\n      />\n    </li>\n    <li v-if=\"hasMoreOptions\" :role=\"childrenDisplay === 'popover' ? 'none' : undefined\">\n      <PvButton\n        class=\"pv-text-brand\"\n        variant=\"ghost\"\n        label=\"See more\"\n        :loading=\"isSeeMoreLoading\"\n        :disabled=\"isSeeMoreLoading\"\n        :role=\"childrenDisplay === 'popover' ? 'menuitem' : undefined\"\n        :tabindex=\"childrenDisplay === 'popover' ? (topLevelTabStopId === SEE_MORE_OPTION_ID ? 0 : -1) : undefined\"\n        data-testid=\"pv-menu-see-more\"\n        @focus=\"focusedTopLevelOptionId = SEE_MORE_OPTION_ID\"\n        @keydown=\"childrenDisplay === 'popover' ? handleSeeMoreKeydown($event) : undefined\"\n        @click=\"emit('see-more', { parentId: undefined })\"\n      />\n    </li>\n  </ul>\n\n  <Teleport v-if=\"childrenDisplay === 'popover' && expandedOption\" to=\"body\">\n    <div\n      ref=\"nestedMenuPopoverRef\"\n      class=\"pv-menu-popover\"\n      :data-pv-menu-ancestors=\"menuHierarchyIds.join(' ')\"\n      :style=\"floatingStyles\"\n    >\n      <PvPopover\n        class=\"pv-scrollbar-visible\"\n        :css-custom-properties=\"{ position: 'static', width: 'max-content', maxWidth: 'calc(100vw - 16px)' }\"\n      >\n        <slot\n          name=\"popover\"\n          :option=\"expandedOption\"\n          :popover-id=\"nestedMenuId\"\n          :close=\"closeNestedMenuAndRestoreFocus\"\n        >\n          <ul\n            :id=\"nestedMenuId\"\n            ref=\"nestedMenuRef\"\n            :aria-label=\"`${expandedOption.text} options`\"\n            class=\"pv-popover-list\"\n            role=\"menu\"\n          >\n            <li\n              v-for=\"option in expandedOption.children\"\n              :key=\"option.id\"\n              :data-active=\"nestedItemDataActive(option)\"\n              :data-option-id=\"option.id\"\n              :class=\"itemClass\"\n              role=\"none\"\n            >\n              <PvMenuItem\n                v-bind=\"directChildMenuItemOption(option)\"\n                :aria-checked=\"menuItemChecked(option)\"\n                :aria-disabled=\"props.readOnly || option.disabled ? 'true' : undefined\"\n                :data-active=\"nestedItemDataActive(option)\"\n                :data-dd-action-name=\"option.rumActionName\"\n                :data-option-id=\"option.id\"\n                :disabled=\"props.readOnly || option.disabled\"\n                :config=\"menuItemConfig(option)\"\n                :itemClass=\"itemClass\"\n                :queryText=\"queryText\"\n                :role=\"menuItemRole(option)\"\n                :tabindex=\"nestedTabStopId === option.id ? 0 : -1\"\n                @focus=\"focusedNestedOptionId = option.id\"\n                @keydown=\"handleNestedKeydown($event, option)\"\n                @handle-selected=\"handleNestedItemSelected\"\n                @see-more=\"emit('see-more', $event)\"\n              />\n            </li>\n          </ul>\n        </slot>\n      </PvPopover>\n    </div>\n  </Teleport>\n</template>\n\n<style scoped>\n.pv-menu-popover {\n  z-index: 50;\n}\n\n.pv-popover-list > li:last-child > :deep(.pv-label) {\n  margin-block-end: 0;\n}\n\n:deep(.pv-menu-nested)::after {\n  content: \"\";\n  width: 0.4rem;\n  height: 0.4rem;\n  margin-right: 0.2rem;\n  margin-left: auto;\n  flex-shrink: 0;\n  border-top: 1.5px solid currentColor;\n  border-right: 1.5px solid currentColor;\n  transform: rotate(45deg);\n}\n</style>\n","<script setup lang=\"ts\">\nimport { computed, inject, nextTick, provide, ref, shallowRef, useId, watch } from \"vue\";\nimport type { VNodeChild } from \"vue\";\nimport { autoUpdate, flip, offset, shift, useFloating } from \"@floating-ui/vue\";\nimport { onClickOutside } from \"@vueuse/core\";\n\nimport { MenuOption, MenuOptionSelectedEvent, SeeMoreEvent } from \"@/types\";\nimport PvMenuItem from \"@/components/base/PvMenu/items/PvMenuItem.vue\";\nimport PvButton from \"@/components/base/PvButton/PvButton.vue\";\nimport PvPopover from \"@/components/base/PvPopover/PvPopover.vue\";\nimport { PvMenuProps } from \"./types\";\nimport { collectLeafOptions, hasCascadeChildren, mergeLeafOptions } from \"./cascadeUtils\";\nimport {\n  SelectedItemsKey,\n  EnableCascadeSelectionKey,\n  MenuInteractionModeKey,\n  MenuAncestorIdsKey,\n  OriginalOptionsMapKey,\n  ParentSelectsAllChildrenKey,\n  CascadeSelectedParentIdsKey,\n  CascadeDeselectedChildIdsKey,\n} from \"./symbols\";\n\ndefineOptions({\n  inheritAttrs: false,\n});\n\nconst props = withDefaults(defineProps<PvMenuProps>(), {\n  childrenDisplay: \"inline\",\n  highlightParentItems: true,\n});\n\nconst emit = defineEmits<{\n  (e: \"handle-selected\", payload: MenuOptionSelectedEvent): void;\n  (e: \"see-more\", payload: SeeMoreEvent): void;\n}>();\n\ndefineSlots<{\n  popover?(props: { option: MenuOption; popoverId: string; close: () => void }): VNodeChild;\n}>();\n\nconst selectedItems = defineModel<MenuOption[]>(\"selectedItems\", { default: () => [] });\nconst expandedOptionId = defineModel<string | undefined>(\"expandedOptionId\");\n\nconst nestedMenuId = useId();\nconst rootMenuRef = ref<HTMLElement | null>(null);\nconst nestedMenuRef = ref<HTMLElement | null>(null);\nconst nestedMenuPopoverRef = ref<HTMLElement | null>(null);\nconst nestedMenuTriggerRef = ref<HTMLElement | null>(null);\n\nconst { floatingStyles, update: updateNestedMenuPosition } = useFloating(nestedMenuTriggerRef, nestedMenuPopoverRef, {\n  middleware: [offset(4), flip(), shift({ padding: 8 })],\n  placement: \"right-start\",\n  strategy: \"fixed\",\n  whileElementsMounted: autoUpdate,\n});\n\nconst closeNestedMenu = () => {\n  if (expandedOptionId.value !== undefined) expandedOptionId.value = undefined;\n};\n\nconst closeNestedMenuAndRestoreFocus = () => {\n  const parentId = expandedOptionId.value;\n  closeNestedMenu();\n  if (parentId) nextTick(() => focusParentOption(parentId));\n};\n\nconst ancestorMenuIds = inject(MenuAncestorIdsKey, []);\nconst menuHierarchyIds = [...ancestorMenuIds, nestedMenuId];\nprovide(MenuAncestorIdsKey, menuHierarchyIds);\n\nonClickOutside(\n  rootMenuRef,\n  (event) => {\n    const ancestorIds =\n      event.target instanceof Element\n        ? event.target.closest<HTMLElement>(\"[data-pv-menu-ancestors]\")?.dataset.pvMenuAncestors?.split(\" \")\n        : undefined;\n    if (!ancestorIds?.includes(nestedMenuId)) closeNestedMenu();\n  },\n  { ignore: [nestedMenuPopoverRef] },\n);\n\n// Vue 3.5 defineModel doesn't update local value synchronously when the prop\n// is passed by a parent (it only emits and waits for the parent to re-render).\n// This local ref is updated immediately so consecutive selections read correct state.\nconst localSelectedItems = shallowRef<MenuOption[]>(selectedItems.value);\n\nwatch(selectedItems, (newVal) => {\n  localSelectedItems.value = newVal;\n});\n\n// The last value this component itself pushed into the model. The sync-back watcher below must\n// skip own writes: because defineModel doesn't reflect a set until the parent re-renders,\n// comparing newVal against selectedItems.value alone mistakes every own write for a descendant\n// mutation and pushes it again — emitting update:selectedItems twice per selection (and, through\n// PvSelectButton, a doubled update:modelValue).\nlet lastModelWrite: MenuOption[] | undefined;\nconst writeSelectedItems = (value: MenuOption[]) => {\n  lastModelWrite = value;\n  selectedItems.value = value;\n};\n\n// Sync back to the model when descendants mutate localSelectedItems directly\n// (e.g. auto-selecting lazy-loaded children in PvMenuItem.handleSeeMoreClick).\nwatch(localSelectedItems, (newVal) => {\n  if (newVal !== lastModelWrite && newVal !== selectedItems.value) {\n    writeSelectedItems(newVal);\n  }\n});\n\nprovide(SelectedItemsKey, localSelectedItems);\nprovide(\n  MenuInteractionModeKey,\n  computed(() => props.childrenDisplay === \"popover\"),\n);\nconst cascadeSelectionEnabled = computed(() => props.childrenDisplay === \"inline\" && !!props.enableCascadeSelection);\nprovide(EnableCascadeSelectionKey, cascadeSelectionEnabled);\n\nconst originalOptionsMap = inject(OriginalOptionsMapKey, undefined);\nconst parentSelectsAllChildren = inject(ParentSelectsAllChildrenKey, ref(false));\nconst cascadeSelectedParentIds = inject(CascadeSelectedParentIdsKey, undefined);\nconst cascadeDeselectedChildIds = inject(CascadeDeselectedChildIdsKey, undefined);\n\nconst isSingleSelect = computed(() => props.singleSelect || props.config?.variant === \"radio\");\nconst expandedOption = computed(() =>\n  props.options.find((option) => option.id === expandedOptionId.value && option.children?.length),\n);\n\nconst openNestedMenu = (option: MenuOption, target: HTMLElement, focusFirstItem = false, toggle = true) => {\n  const shouldOpen = !toggle || expandedOptionId.value !== option.id;\n  expandedOptionId.value = shouldOpen ? option.id : undefined;\n  if (!shouldOpen) return;\n\n  nestedMenuTriggerRef.value = target;\n  nextTick(() => {\n    updateNestedMenuPosition();\n    if (focusFirstItem) {\n      focusMenuItem(nestedMenuRef.value ?? document.getElementById(nestedMenuId), 0);\n    }\n  });\n};\n\nconst handleItemSelected = (event: MenuOptionSelectedEvent, nested = false) => {\n  if (props.readOnly) return;\n  const option =\n    (!nested && props.childrenDisplay === \"popover\"\n      ? props.options.find((candidate) => candidate.id === event.option.id)\n      : undefined) ?? event.option;\n  if (props.childrenDisplay === \"popover\" && !nested && option.children?.length) {\n    const target = (event.event.currentTarget as HTMLElement | null)?.closest<HTMLElement>(\"li\");\n    if (target) openNestedMenu(option, target);\n    return;\n  }\n  let newSelection: MenuOption[];\n\n  if (cascadeSelectionEnabled.value && hasCascadeChildren(option)) {\n    // Only leaf options are added to the selection — the parent itself is never\n    // included because it is purely an organisational node, not a selectable value.\n    // When parentSelectsAllChildren is true, use the original (unfiltered)\n    // children so clicking a parent selects all children regardless of search query.\n    let leafOptions: MenuOption[];\n    if (parentSelectsAllChildren.value && originalOptionsMap?.value) {\n      const originalOption = originalOptionsMap.value.get(option.id);\n      const originalLeaves = originalOption?.children ? collectLeafOptions(originalOption.children) : [];\n      const currentLeaves = option.children ? collectLeafOptions(option.children) : [];\n      leafOptions = mergeLeafOptions(originalLeaves, currentLeaves);\n    } else {\n      leafOptions = option.children ? collectLeafOptions(option.children) : [];\n    }\n    const leafIds = leafOptions.map((o) => o.id);\n    const current = localSelectedItems.value;\n    const parentSelected = cascadeSelectedParentIds?.value?.has(option.id) ?? false;\n    const anySelected = parentSelected || leafIds.some((id) => current.some((item) => item.id === id));\n    newSelection = anySelected ? current.filter((item) => !leafIds.includes(item.id)) : [...current, ...leafOptions];\n\n    // Track whether this parent was explicitly clicked for cascade selection\n    if (cascadeSelectedParentIds?.value) {\n      const next = new Set(cascadeSelectedParentIds.value);\n      if (anySelected) {\n        next.delete(option.id);\n      } else {\n        next.add(option.id);\n      }\n      cascadeSelectedParentIds.value = next;\n    }\n    // Clear deselected children tracking when parent is explicitly toggled\n    if (cascadeDeselectedChildIds?.value?.has(option.id)) {\n      const next = new Map(cascadeDeselectedChildIds.value);\n      next.delete(option.id);\n      cascadeDeselectedChildIds.value = next;\n    }\n  } else if (isSingleSelect.value) {\n    if (localSelectedItems.value.length === 1 && localSelectedItems.value[0].id === option.id) {\n      newSelection = props.disableDeselect ? localSelectedItems.value : [];\n    } else {\n      newSelection = [option];\n    }\n  } else {\n    const index = localSelectedItems.value.findIndex((item) => item.id === option.id);\n    if (index > -1) {\n      newSelection = [...localSelectedItems.value.slice(0, index), ...localSelectedItems.value.slice(index + 1)];\n    } else {\n      newSelection = [...localSelectedItems.value, option];\n    }\n\n    // Track individually deselected/re-selected children under selected parents\n    // so dynamically loaded children (see-more) can inherit the correct state.\n    if (cascadeSelectionEnabled.value && cascadeSelectedParentIds?.value && cascadeDeselectedChildIds?.value) {\n      const isDeselecting = index > -1;\n      for (const parentId of cascadeSelectedParentIds.value) {\n        // Find if this child belongs to this parent\n        const parentOption = originalOptionsMap?.value?.get(parentId);\n        const parentChildren = parentOption?.children ?? props.options.find((o) => o.id === parentId)?.children;\n        if (!parentChildren) continue;\n        const leaves = collectLeafOptions(parentChildren);\n        // Also check the option itself as it may have been dynamically loaded\n        const isChildOfParent =\n          leaves.some((l) => l.id === option.id) ||\n          props.options.find((o) => o.id === parentId)?.children?.some((c) => c.id === option.id);\n        if (!isChildOfParent) continue;\n\n        const next = new Map(cascadeDeselectedChildIds.value);\n        const deselected = new Set(next.get(parentId) ?? []);\n        if (isDeselecting) {\n          deselected.add(option.id);\n        } else {\n          deselected.delete(option.id);\n        }\n        if (deselected.size > 0) {\n          next.set(parentId, deselected);\n        } else {\n          next.delete(parentId);\n        }\n        cascadeDeselectedChildIds.value = next;\n        break;\n      }\n    }\n  }\n\n  localSelectedItems.value = newSelection;\n  writeSelectedItems(newSelection);\n\n  if (!nested && props.childrenDisplay === \"popover\") expandedOptionId.value = undefined;\n  emit(\"handle-selected\", props.childrenDisplay === \"popover\" ? { ...event, option } : event);\n};\n\nconst handleNestedItemSelected = (event: MenuOptionSelectedEvent) => {\n  const parentOption = expandedOption.value;\n  if (!parentOption) return;\n  const option = parentOption.children?.find((child) => child.id === event.option.id) ?? event.option;\n  handleItemSelected({ ...event, option }, true);\n  expandedOptionId.value = undefined;\n  nextTick(() => focusParentOption(parentOption.id));\n};\n\nconst selectedIds = computed(() => new Set(localSelectedItems.value.map((item) => item.id)));\n\nconst findSelectedDescendant = (children: MenuOption[]): MenuOption | undefined => {\n  for (const child of children) {\n    if (selectedIds.value.has(child.id)) return child;\n    const selectedChild = child.children?.length ? findSelectedDescendant(child.children) : undefined;\n    if (selectedChild) return selectedChild;\n  }\n  return undefined;\n};\n\nconst menuItemOption = (option: MenuOption): MenuOption => {\n  if (props.childrenDisplay !== \"popover\" || !option.children?.length) return option;\n  const selectedChild = findSelectedDescendant(option.children);\n  return {\n    ...option,\n    children: undefined,\n    classList: [...(option.classList ?? []), \"pv-menu-nested\"],\n    subText: selectedChild?.text ?? option.subText,\n    totalChildCount: undefined,\n  };\n};\n\nconst directChildMenuItemOption = (option: MenuOption): MenuOption => ({\n  ...option,\n  children: undefined,\n  totalChildCount: undefined,\n});\n\nconst menuItemConfig = (option: MenuOption) =>\n  props.childrenDisplay === \"popover\" ? (option.config ?? props.config) : props.config;\n\nconst isActive = (option: MenuOption): true | null => {\n  if (selectedIds.value.has(option.id)) {\n    return true;\n  }\n  if (cascadeSelectionEnabled.value && cascadeSelectedParentIds?.value?.has(option.id)) {\n    return true;\n  }\n  if (\n    (cascadeSelectionEnabled.value || props.childrenDisplay === \"popover\") &&\n    option.children?.length &&\n    findSelectedDescendant(option.children)\n  ) {\n    return true;\n  }\n  return null;\n};\n\nconst menuItemRole = (option: MenuOption): \"menuitem\" | \"menuitemcheckbox\" | \"menuitemradio\" => {\n  const variant = option.config?.variant ?? props.config?.variant;\n  if (isSingleSelect.value || variant === \"radio\") return \"menuitemradio\";\n  if (variant === \"checkbox\") return \"menuitemcheckbox\";\n  return \"menuitem\";\n};\n\nconst menuItemChecked = (option: MenuOption): boolean | undefined =>\n  menuItemRole(option) === \"menuitem\" ? undefined : !!isActive(option);\n\nconst itemDataActive = (option: MenuOption): true | null => {\n  if (option.children?.length && !props.highlightParentItems) return null;\n  return (menuItemRole(option) !== \"menuitemcheckbox\" && isActive(option)) || expandedOptionId.value === option.id\n    ? true\n    : null;\n};\n\nconst nestedItemDataActive = (option: MenuOption): true | null =>\n  menuItemRole(option) !== \"menuitemcheckbox\" && selectedIds.value.has(option.id) ? true : null;\n\nconst isVisible = (option: MenuOption, isLoading?: boolean): boolean => {\n  if (!isLoading) return true;\n  if (selectedIds.value.has(option.id)) return true;\n  if (cascadeSelectedParentIds?.value?.has(option.id)) return true;\n  if (option.children?.length && findSelectedDescendant(option.children)) return true;\n  return false;\n};\n\nconst SEE_MORE_OPTION_ID = \"__pv-menu-see-more__\";\nconst focusedTopLevelOptionId = ref<string>();\nconst focusedNestedOptionId = ref<string>();\n\nconst topLevelTabStopId = computed(() => {\n  const focusableOptionIds = props.options\n    .filter((option) => !props.readOnly && !option.disabled && isVisible(option, props.isLoading))\n    .map((option) => option.id);\n  if (props.hasMoreOptions && !props.isSeeMoreLoading) focusableOptionIds.push(SEE_MORE_OPTION_ID);\n  return focusedTopLevelOptionId.value && focusableOptionIds.includes(focusedTopLevelOptionId.value)\n    ? focusedTopLevelOptionId.value\n    : focusableOptionIds[0];\n});\n\nconst nestedTabStopId = computed(() => {\n  const focusableOptions =\n    expandedOption.value?.children?.filter((option) => !props.readOnly && !option.disabled) ?? [];\n  return focusableOptions.some((option) => option.id === focusedNestedOptionId.value)\n    ? focusedNestedOptionId.value\n    : focusableOptions[0]?.id;\n});\n\nconst menuItems = (menu: HTMLElement | null): HTMLElement[] => {\n  const roleItems = Array.from(\n    menu?.querySelectorAll<HTMLElement>(\"li[role='none'] > [role^='menuitem']:not([aria-disabled='true'])\") ?? [],\n  ).filter((item) => !item.hidden && item.style.display !== \"none\");\n  if (roleItems.length) return roleItems;\n\n  return Array.from(\n    menu?.querySelectorAll<HTMLElement>(\n      \"button:not(:disabled), [href], input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex='-1'])\",\n    ) ?? [],\n  ).filter((item) => !item.hidden && item.style.display !== \"none\");\n};\n\nconst focusMenuItem = (menu: HTMLElement | null, index: number) => {\n  const items = menuItems(menu);\n  if (!items.length) return;\n  items[(index + items.length) % items.length]?.focus();\n};\n\nconst focusRelativeMenuItem = (menu: HTMLElement | null, current: HTMLElement, offset: number) => {\n  const items = menuItems(menu);\n  const currentIndex = items.indexOf(current);\n  if (!items.length || currentIndex < 0) return;\n  items[(currentIndex + offset + items.length) % items.length]?.focus();\n};\n\nconst focusParentOption = (optionId: string) => {\n  menuItems(rootMenuRef.value)\n    .find((item) => item.dataset.optionId === optionId)\n    ?.focus();\n};\n\nwatch(\n  // Also re-sync when the row leaves and re-enters `options`, since its <li> is re-created.\n  [expandedOptionId, () => !!expandedOption.value],\n  ([optionId]) => {\n    focusedNestedOptionId.value = undefined;\n    if (!optionId) return;\n    nextTick(() => {\n      const target = Array.from(rootMenuRef.value?.children ?? []).find(\n        (item) => (item as HTMLElement).dataset.optionId === optionId,\n      ) as HTMLElement | undefined;\n      if (!target) return;\n      nestedMenuTriggerRef.value = target;\n      updateNestedMenuPosition();\n    });\n  },\n  { immediate: true },\n);\n\nconst handleMenuNavigation = (event: KeyboardEvent, menu: HTMLElement | null): boolean => {\n  switch (event.key) {\n    case \"ArrowDown\":\n      event.preventDefault();\n      focusRelativeMenuItem(menu, event.currentTarget as HTMLElement, 1);\n      return true;\n    case \"ArrowUp\":\n      event.preventDefault();\n      focusRelativeMenuItem(menu, event.currentTarget as HTMLElement, -1);\n      return true;\n    case \"Home\":\n      event.preventDefault();\n      focusMenuItem(menu, 0);\n      return true;\n    case \"End\":\n      event.preventDefault();\n      focusMenuItem(menu, -1);\n      return true;\n    default:\n      return false;\n  }\n};\n\nconst handleTopLevelKeydown = (event: KeyboardEvent, option: MenuOption) => {\n  if (event.target !== event.currentTarget || handleMenuNavigation(event, rootMenuRef.value)) return;\n  switch (event.key) {\n    case \"ArrowRight\":\n      if (!option.children?.length) break;\n      event.preventDefault();\n      openNestedMenu(option, event.currentTarget as HTMLElement, true, false);\n      break;\n    case \"Enter\":\n    case \" \":\n      event.preventDefault();\n      if (option.children?.length) {\n        openNestedMenu(option, event.currentTarget as HTMLElement, true, false);\n      } else {\n        handleItemSelected({ event, option });\n      }\n      break;\n    case \"Escape\":\n      if (!expandedOptionId.value) break;\n      event.preventDefault();\n      event.stopPropagation();\n      expandedOptionId.value = undefined;\n      break;\n    case \"Tab\":\n      expandedOptionId.value = undefined;\n      break;\n  }\n};\n\nconst handleSeeMoreKeydown = (event: KeyboardEvent) => {\n  if (handleMenuNavigation(event, rootMenuRef.value)) return;\n  switch (event.key) {\n    case \"Enter\":\n    case \" \":\n      event.preventDefault();\n      emit(\"see-more\", { parentId: undefined });\n      break;\n    case \"Escape\":\n    case \"Tab\":\n      closeNestedMenu();\n      break;\n  }\n};\n\nconst handleNestedKeydown = (event: KeyboardEvent, option: MenuOption) => {\n  if (event.target !== event.currentTarget || handleMenuNavigation(event, nestedMenuRef.value)) return;\n  switch (event.key) {\n    case \"ArrowLeft\":\n    case \"Escape\": {\n      event.preventDefault();\n      if (event.key === \"Escape\") event.stopPropagation();\n      const parentId = expandedOptionId.value;\n      expandedOptionId.value = undefined;\n      if (parentId) nextTick(() => focusParentOption(parentId));\n      break;\n    }\n    case \"Enter\":\n    case \" \":\n      event.preventDefault();\n      handleNestedItemSelected({ event, option });\n      break;\n    case \"Tab\":\n      expandedOptionId.value = undefined;\n      break;\n  }\n};\n</script>\n\n<template>\n  <ul ref=\"rootMenuRef\" :role=\"childrenDisplay === 'popover' ? 'menu' : 'list'\" class=\"pv-popover-list\" v-bind=\"$attrs\">\n    <li\n      v-for=\"option in options\"\n      v-show=\"isVisible(option, isLoading)\"\n      :key=\"option.id\"\n      :data-active=\"itemDataActive(option)\"\n      :data-option-id=\"option.id\"\n      :data-testid=\"itemTestId\"\n      :class=\"itemClass\"\n      :role=\"childrenDisplay === 'popover' ? 'none' : undefined\"\n    >\n      <PvMenuItem\n        v-bind=\"menuItemOption(option)\"\n        :aria-checked=\"childrenDisplay === 'popover' ? menuItemChecked(option) : undefined\"\n        :aria-controls=\"childrenDisplay === 'popover' && option.children?.length ? nestedMenuId : undefined\"\n        :aria-disabled=\"childrenDisplay === 'popover' && (props.readOnly || option.disabled) ? 'true' : undefined\"\n        :aria-expanded=\"\n          childrenDisplay === 'popover' && option.children?.length ? expandedOptionId === option.id : undefined\n        \"\n        :aria-haspopup=\"\n          childrenDisplay === 'popover' && option.children?.length ? (option.popoverRole ?? 'menu') : undefined\n        \"\n        :data-active=\"itemDataActive(option)\"\n        :data-dd-action-name=\"option.rumActionName\"\n        :data-option-id=\"option.id\"\n        :disabled=\"props.readOnly || option.disabled\"\n        :config=\"menuItemConfig(option)\"\n        :itemClass=\"itemClass\"\n        :queryText=\"queryText\"\n        :role=\"childrenDisplay === 'popover' ? menuItemRole(option) : undefined\"\n        :tabindex=\"childrenDisplay === 'popover' ? (topLevelTabStopId === option.id ? 0 : -1) : undefined\"\n        @focus=\"focusedTopLevelOptionId = option.id\"\n        @keydown=\"childrenDisplay === 'popover' ? handleTopLevelKeydown($event, option) : undefined\"\n        @handle-selected=\"handleItemSelected\"\n        @see-more=\"emit('see-more', $event)\"\n      />\n    </li>\n    <li v-if=\"hasMoreOptions\" :role=\"childrenDisplay === 'popover' ? 'none' : undefined\">\n      <PvButton\n        class=\"pv-text-brand\"\n        variant=\"ghost\"\n        label=\"See more\"\n        :loading=\"isSeeMoreLoading\"\n        :disabled=\"isSeeMoreLoading\"\n        :role=\"childrenDisplay === 'popover' ? 'menuitem' : undefined\"\n        :tabindex=\"childrenDisplay === 'popover' ? (topLevelTabStopId === SEE_MORE_OPTION_ID ? 0 : -1) : undefined\"\n        data-testid=\"pv-menu-see-more\"\n        @focus=\"focusedTopLevelOptionId = SEE_MORE_OPTION_ID\"\n        @keydown=\"childrenDisplay === 'popover' ? handleSeeMoreKeydown($event) : undefined\"\n        @click=\"emit('see-more', { parentId: undefined })\"\n      />\n    </li>\n  </ul>\n\n  <Teleport v-if=\"childrenDisplay === 'popover' && expandedOption\" to=\"body\">\n    <div\n      ref=\"nestedMenuPopoverRef\"\n      class=\"pv-menu-popover\"\n      :data-pv-menu-ancestors=\"menuHierarchyIds.join(' ')\"\n      :style=\"floatingStyles\"\n    >\n      <PvPopover\n        class=\"pv-scrollbar-visible\"\n        :css-custom-properties=\"{ position: 'static', width: 'max-content', maxWidth: 'calc(100vw - 16px)' }\"\n      >\n        <slot\n          name=\"popover\"\n          :option=\"expandedOption\"\n          :popover-id=\"nestedMenuId\"\n          :close=\"closeNestedMenuAndRestoreFocus\"\n        >\n          <ul\n            :id=\"nestedMenuId\"\n            ref=\"nestedMenuRef\"\n            :aria-label=\"`${expandedOption.text} options`\"\n            class=\"pv-popover-list\"\n            role=\"menu\"\n          >\n            <li\n              v-for=\"option in expandedOption.children\"\n              :key=\"option.id\"\n              :data-active=\"nestedItemDataActive(option)\"\n              :data-option-id=\"option.id\"\n              :class=\"itemClass\"\n              role=\"none\"\n            >\n              <PvMenuItem\n                v-bind=\"directChildMenuItemOption(option)\"\n                :aria-checked=\"menuItemChecked(option)\"\n                :aria-disabled=\"props.readOnly || option.disabled ? 'true' : undefined\"\n                :data-active=\"nestedItemDataActive(option)\"\n                :data-dd-action-name=\"option.rumActionName\"\n                :data-option-id=\"option.id\"\n                :disabled=\"props.readOnly || option.disabled\"\n                :config=\"menuItemConfig(option)\"\n                :itemClass=\"itemClass\"\n                :queryText=\"queryText\"\n                :role=\"menuItemRole(option)\"\n                :tabindex=\"nestedTabStopId === option.id ? 0 : -1\"\n                @focus=\"focusedNestedOptionId = option.id\"\n                @keydown=\"handleNestedKeydown($event, option)\"\n                @handle-selected=\"handleNestedItemSelected\"\n                @see-more=\"emit('see-more', $event)\"\n              />\n            </li>\n          </ul>\n        </slot>\n      </PvPopover>\n    </div>\n  </Teleport>\n</template>\n\n<style scoped>\n.pv-menu-popover {\n  z-index: 50;\n}\n\n.pv-popover-list > li:last-child > :deep(.pv-label) {\n  margin-block-end: 0;\n}\n\n:deep(.pv-menu-nested)::after {\n  content: \"\";\n  width: 0.4rem;\n  height: 0.4rem;\n  margin-right: 0.2rem;\n  margin-left: auto;\n  flex-shrink: 0;\n  border-top: 1.5px solid currentColor;\n  border-right: 1.5px solid currentColor;\n  transform: rotate(45deg);\n}\n</style>\n","<script setup lang=\"ts\" generic=\"T\">\nimport { watch, computed } from \"vue\";\nimport type { CSSProperties, Component } from \"vue\";\n\nimport { useToggle, onKeyStroke } from \"@vueuse/core\";\n\nimport PvSearchInput from \"../PvSearchInput/PvSearchInput.vue\";\nimport PvSelectButtonTrigger from \"@/components/base/PvSelectButton/PvSelectButtonTrigger/PvSelectButtonTrigger.vue\";\nimport PvMenuEmptyState from \"../PvMenu/PvMenuEmptyState.vue\";\n\nimport type { PvSelectButtonSize, PvSelectButtonVariant } from \"./types\";\nimport type { MenuAction, MenuOption, MenuOptionConfig, MenuOptionsVariant } from \"@/types\";\nimport type { PvCounterBadgeVariant } from \"../PvCounterBadge/types\";\nimport type { PvPopoverV2Props } from \"@/components/base/PvPopoverV2/types.ts\";\nimport PvPopoverV2 from \"@/components/base/PvPopoverV2/PvPopoverV2.vue\";\nimport PvMenu from \"@/components/base/PvMenu/PvMenu.vue\";\nimport type { PvMenuChildrenDisplay } from \"@/components/base/PvMenu/types\";\n\nexport interface PvSelectButtonProps<T = unknown> {\n  /** Whether the dropdown is open on initial render */\n  defaultOpen?: boolean;\n  /** Prevent the button from being clicked */\n  disabled?: boolean;\n  /** Show a loading state on the trigger button */\n  isLoading?: boolean;\n  /** Visual style of the trigger button */\n  variant?: PvSelectButtonVariant;\n  /** Inverse button colors for dark backgrounds */\n  inverse?: boolean;\n  /** Size of the trigger button */\n  size?: PvSelectButtonSize;\n  /** Configuration passed to the underlying PvPopoverV2 */\n  popoverProperties?: PvPopoverV2Props;\n  /** Custom CSS properties applied to the popover container */\n  popoverCssProperties?: CSSProperties;\n  /** Static text shown before the label on the trigger button */\n  prefixLabel?: string;\n  /** Text label on the trigger button; updates to the selected option's text when an item is chosen */\n  label?: string;\n  /** Icon shown before the trigger label when the selected option does not provide one */\n  icon?: string;\n  /**\n   * Keep the trigger showing `label` even after an option is selected, instead of\n   * swapping to the selected option's text. Use when the label is a fixed title\n   * (e.g. a column name) and the current selection is surfaced only inside the dropdown.\n   */\n  staticLabel?: boolean;\n  /** Hide the search input inside the dropdown */\n  disableSearchInput?: boolean;\n  /** Placeholder text for the search input */\n  searchPlaceholder?: string;\n  /** Visual style of menu options (simple, icon, company, avatar, radio) */\n  optionsVariant?: Exclude<MenuOptionsVariant, \"checkbox\">;\n  /** The list of selectable options */\n  options?: MenuOption<T>[];\n  /** Render nested options inline or in click-opened popovers. */\n  childrenDisplay?: PvMenuChildrenDisplay;\n  /** Custom Vue component used to render each option */\n  optionsRenderer?: Component;\n  /** Action configuration for per-option action buttons */\n  optionsAction?: MenuAction<T>;\n  /** Prevent deselecting the currently selected item */\n  disableDeselect?: boolean;\n  /** Where to place the counter badge on the trigger */\n  counterPosition?: \"left\" | \"right\";\n  /** Variant of the counter badge which appears on the button and menu items */\n  counterBadgeVariant?: PvCounterBadgeVariant;\n  /** Whether to highlight the search text in the options list */\n  highlightSearchText?: boolean;\n  /**\n   * `data-dd-action-name` attached to the trigger button so Datadog RUM\n   * resolves the click to a named action. Leave unset to skip.\n   */\n  rumActionName?: string;\n}\n\nconst props = withDefaults(defineProps<PvSelectButtonProps<T>>(), {\n  variant: \"secondary\",\n  size: \"lg\",\n  label: \"Select an option\",\n  disableDeselect: false,\n  disableSearchInput: false,\n  optionsVariant: \"simple\",\n  options: () => [] as MenuOption<T>[],\n  highlightSearchText: false,\n});\n\nconst resolvedPopoverProperties = computed<PvPopoverV2Props | undefined>(() => {\n  if (props.childrenDisplay !== \"popover\") return props.popoverProperties;\n  const ignoredClasses = props.popoverProperties?.ignoreClickOutsideClasses ?? [];\n  return {\n    ...props.popoverProperties,\n    ignoreClickOutsideClasses: ignoredClasses.includes(\"pv-menu-popover\")\n      ? ignoredClasses\n      : [...ignoredClasses, \"pv-menu-popover\"],\n  };\n});\n\nconst optionConfig = computed(() => {\n  const config: MenuOptionConfig = {\n    renderer: props.optionsRenderer,\n    action: props.optionsAction,\n    variant: props.optionsVariant,\n    counterBadgeVariant: props.counterBadgeVariant,\n    size: props.size,\n  };\n  return config;\n});\n\nconst emits = defineEmits<{\n  (e: \"dropdown-open\"): void;\n  (e: \"dropdown-closed\"): void;\n}>();\n\nconst [open] = useToggle<boolean>(props.defaultOpen);\nconst selectedItem = defineModel<MenuOption>({ required: false });\nconst searchInput = defineModel<string>(\"searchInput\", {\n  required: false,\n  default: \"\",\n});\n\nwatch(open, (newValue) => {\n  if (newValue) {\n    emits(\"dropdown-open\");\n  } else {\n    emits(\"dropdown-closed\");\n  }\n});\n\nconst buttonDisplayLabel = computed(() => {\n  if (!props.staticLabel && selectedItem.value && selectedItem.value.text) {\n    return selectedItem.value.text;\n  }\n  return props.label;\n});\n\nconst buttonIcon = computed(() => selectedItem.value?.icon || props.icon);\n\nconst buttonCompanyLogo = computed(() => {\n  if (selectedItem.value && selectedItem.value.companyName) {\n    return selectedItem.value.companyName;\n  }\n  return undefined;\n});\n\nconst buttonAvatar = computed(() => selectedItem.value?.avatar);\n\nconst filteredOptions = computed(() => {\n  const searchValue = searchInput.value.trim().toLowerCase();\n  if (!searchValue) return props.options;\n\n  const searchRecursive = (options: MenuOption[]): MenuOption[] => {\n    const result: MenuOption[] = [];\n\n    for (const option of options) {\n      const matches =\n        option.text.toLowerCase().includes(searchValue) || option.searchText?.toLowerCase().includes(searchValue);\n      const filteredChildren = searchRecursive(option.children || []);\n\n      if (matches) {\n        // Parent matches → keep parent, with filtered children\n        result.push({\n          ...option,\n          searchText: searchValue,\n          children: filteredChildren,\n        });\n      } else {\n        // Parent does NOT match:\n        result.push(...filteredChildren);\n      }\n    }\n\n    return result;\n  };\n\n  return searchRecursive(props.options);\n});\n\nconst menuSelectedItems = computed({\n  get: () => (selectedItem.value ? [selectedItem.value] : []),\n  set: (items: MenuOption[]) => {\n    if (props.optionsVariant === \"radio\" || props.disableDeselect) {\n      if (items.length > 0) {\n        selectedItem.value = items[0];\n      }\n    } else {\n      selectedItem.value = items.length > 0 ? items[0] : undefined;\n    }\n  },\n});\n\nconst handleSelectItem = () => {\n  closeDropdown();\n};\n\nconst handleClear = () => {\n  selectedItem.value = undefined;\n};\n\nconst closeDropdown = () => {\n  open.value = false;\n  searchInput.value = \"\";\n};\n\nonKeyStroke(\"Escape\", () => {\n  if (!open.value) return;\n\n  closeDropdown();\n});\n</script>\n\n<template>\n  <PvPopoverV2 v-model=\"open\" v-bind=\"resolvedPopoverProperties\">\n    <template #trigger>\n      <PvSelectButtonTrigger\n        class=\"pv-full-width\"\n        ref=\"select-button-trigger-ref\"\n        :variant=\"variant\"\n        :inverse=\"inverse\"\n        :size=\"size\"\n        :disabled=\"disabled\"\n        :prefixLabel=\"prefixLabel\"\n        :label=\"buttonDisplayLabel\"\n        :icon=\"buttonIcon\"\n        :companyLogo=\"buttonCompanyLogo\"\n        :avatar=\"buttonAvatar\"\n        :showClear=\"false\"\n        :showDropdown=\"true\"\n        :open=\"open\"\n        :data-dd-action-name=\"rumActionName\"\n        :counter-position=\"counterPosition\"\n        :counter-value=\"\n          selectedItem?.secondaryText && typeof selectedItem.secondaryText === 'number'\n            ? selectedItem.secondaryText\n            : undefined\n        \"\n        :counter-badge-variant=\"counterBadgeVariant\"\n        :isLoading=\"isLoading\"\n        :menuOptionConfig=\"optionConfig\"\n        :renderer=\"optionsRenderer\"\n        :selectedOption=\"selectedItem\"\n        @handle-clear=\"handleClear\"\n      />\n    </template>\n    <template #content>\n      <div\n        class=\"pv-popover pv-popover-scrollable\"\n        data-test-id=\"pv-popover\"\n        :style=\"popoverCssProperties\"\n        style=\"position: unset\"\n      >\n        <div class=\"pv-popover-scroll\">\n          <template v-if=\"!disableSearchInput\">\n            <div class=\"pv-inset-square-8 pv-border-bottom\">\n              <PvSearchInput v-model:model-value=\"searchInput\" class=\"pv-stack-4\" :placeholder=\"searchPlaceholder\" />\n            </div>\n          </template>\n          <template v-if=\"filteredOptions.length > 0\">\n            <PvMenu\n              v-model:selectedItems=\"menuSelectedItems\"\n              :options=\"filteredOptions\"\n              :config=\"optionConfig\"\n              :queryText=\"highlightSearchText ? searchInput : null\"\n              :singleSelect=\"true\"\n              :disableDeselect=\"disableDeselect\"\n              :childrenDisplay=\"childrenDisplay\"\n              @handle-selected=\"handleSelectItem\"\n            />\n          </template>\n          <PvMenuEmptyState v-else />\n          <slot name=\"footer\" />\n        </div>\n      </div>\n    </template>\n  </PvPopoverV2>\n</template>\n","<script setup lang=\"ts\" generic=\"T\">\nimport { watch, computed } from \"vue\";\nimport type { CSSProperties, Component } from \"vue\";\n\nimport { useToggle, onKeyStroke } from \"@vueuse/core\";\n\nimport PvSearchInput from \"../PvSearchInput/PvSearchInput.vue\";\nimport PvSelectButtonTrigger from \"@/components/base/PvSelectButton/PvSelectButtonTrigger/PvSelectButtonTrigger.vue\";\nimport PvMenuEmptyState from \"../PvMenu/PvMenuEmptyState.vue\";\n\nimport type { PvSelectButtonSize, PvSelectButtonVariant } from \"./types\";\nimport type { MenuAction, MenuOption, MenuOptionConfig, MenuOptionsVariant } from \"@/types\";\nimport type { PvCounterBadgeVariant } from \"../PvCounterBadge/types\";\nimport type { PvPopoverV2Props } from \"@/components/base/PvPopoverV2/types.ts\";\nimport PvPopoverV2 from \"@/components/base/PvPopoverV2/PvPopoverV2.vue\";\nimport PvMenu from \"@/components/base/PvMenu/PvMenu.vue\";\nimport type { PvMenuChildrenDisplay } from \"@/components/base/PvMenu/types\";\n\nexport interface PvSelectButtonProps<T = unknown> {\n  /** Whether the dropdown is open on initial render */\n  defaultOpen?: boolean;\n  /** Prevent the button from being clicked */\n  disabled?: boolean;\n  /** Show a loading state on the trigger button */\n  isLoading?: boolean;\n  /** Visual style of the trigger button */\n  variant?: PvSelectButtonVariant;\n  /** Inverse button colors for dark backgrounds */\n  inverse?: boolean;\n  /** Size of the trigger button */\n  size?: PvSelectButtonSize;\n  /** Configuration passed to the underlying PvPopoverV2 */\n  popoverProperties?: PvPopoverV2Props;\n  /** Custom CSS properties applied to the popover container */\n  popoverCssProperties?: CSSProperties;\n  /** Static text shown before the label on the trigger button */\n  prefixLabel?: string;\n  /** Text label on the trigger button; updates to the selected option's text when an item is chosen */\n  label?: string;\n  /** Icon shown before the trigger label when the selected option does not provide one */\n  icon?: string;\n  /**\n   * Keep the trigger showing `label` even after an option is selected, instead of\n   * swapping to the selected option's text. Use when the label is a fixed title\n   * (e.g. a column name) and the current selection is surfaced only inside the dropdown.\n   */\n  staticLabel?: boolean;\n  /** Hide the search input inside the dropdown */\n  disableSearchInput?: boolean;\n  /** Placeholder text for the search input */\n  searchPlaceholder?: string;\n  /** Visual style of menu options (simple, icon, company, avatar, radio) */\n  optionsVariant?: Exclude<MenuOptionsVariant, \"checkbox\">;\n  /** The list of selectable options */\n  options?: MenuOption<T>[];\n  /** Render nested options inline or in click-opened popovers. */\n  childrenDisplay?: PvMenuChildrenDisplay;\n  /** Custom Vue component used to render each option */\n  optionsRenderer?: Component;\n  /** Action configuration for per-option action buttons */\n  optionsAction?: MenuAction<T>;\n  /** Prevent deselecting the currently selected item */\n  disableDeselect?: boolean;\n  /** Where to place the counter badge on the trigger */\n  counterPosition?: \"left\" | \"right\";\n  /** Variant of the counter badge which appears on the button and menu items */\n  counterBadgeVariant?: PvCounterBadgeVariant;\n  /** Whether to highlight the search text in the options list */\n  highlightSearchText?: boolean;\n  /**\n   * `data-dd-action-name` attached to the trigger button so Datadog RUM\n   * resolves the click to a named action. Leave unset to skip.\n   */\n  rumActionName?: string;\n}\n\nconst props = withDefaults(defineProps<PvSelectButtonProps<T>>(), {\n  variant: \"secondary\",\n  size: \"lg\",\n  label: \"Select an option\",\n  disableDeselect: false,\n  disableSearchInput: false,\n  optionsVariant: \"simple\",\n  options: () => [] as MenuOption<T>[],\n  highlightSearchText: false,\n});\n\nconst resolvedPopoverProperties = computed<PvPopoverV2Props | undefined>(() => {\n  if (props.childrenDisplay !== \"popover\") return props.popoverProperties;\n  const ignoredClasses = props.popoverProperties?.ignoreClickOutsideClasses ?? [];\n  return {\n    ...props.popoverProperties,\n    ignoreClickOutsideClasses: ignoredClasses.includes(\"pv-menu-popover\")\n      ? ignoredClasses\n      : [...ignoredClasses, \"pv-menu-popover\"],\n  };\n});\n\nconst optionConfig = computed(() => {\n  const config: MenuOptionConfig = {\n    renderer: props.optionsRenderer,\n    action: props.optionsAction,\n    variant: props.optionsVariant,\n    counterBadgeVariant: props.counterBadgeVariant,\n    size: props.size,\n  };\n  return config;\n});\n\nconst emits = defineEmits<{\n  (e: \"dropdown-open\"): void;\n  (e: \"dropdown-closed\"): void;\n}>();\n\nconst [open] = useToggle<boolean>(props.defaultOpen);\nconst selectedItem = defineModel<MenuOption>({ required: false });\nconst searchInput = defineModel<string>(\"searchInput\", {\n  required: false,\n  default: \"\",\n});\n\nwatch(open, (newValue) => {\n  if (newValue) {\n    emits(\"dropdown-open\");\n  } else {\n    emits(\"dropdown-closed\");\n  }\n});\n\nconst buttonDisplayLabel = computed(() => {\n  if (!props.staticLabel && selectedItem.value && selectedItem.value.text) {\n    return selectedItem.value.text;\n  }\n  return props.label;\n});\n\nconst buttonIcon = computed(() => selectedItem.value?.icon || props.icon);\n\nconst buttonCompanyLogo = computed(() => {\n  if (selectedItem.value && selectedItem.value.companyName) {\n    return selectedItem.value.companyName;\n  }\n  return undefined;\n});\n\nconst buttonAvatar = computed(() => selectedItem.value?.avatar);\n\nconst filteredOptions = computed(() => {\n  const searchValue = searchInput.value.trim().toLowerCase();\n  if (!searchValue) return props.options;\n\n  const searchRecursive = (options: MenuOption[]): MenuOption[] => {\n    const result: MenuOption[] = [];\n\n    for (const option of options) {\n      const matches =\n        option.text.toLowerCase().includes(searchValue) || option.searchText?.toLowerCase().includes(searchValue);\n      const filteredChildren = searchRecursive(option.children || []);\n\n      if (matches) {\n        // Parent matches → keep parent, with filtered children\n        result.push({\n          ...option,\n          searchText: searchValue,\n          children: filteredChildren,\n        });\n      } else {\n        // Parent does NOT match:\n        result.push(...filteredChildren);\n      }\n    }\n\n    return result;\n  };\n\n  return searchRecursive(props.options);\n});\n\nconst menuSelectedItems = computed({\n  get: () => (selectedItem.value ? [selectedItem.value] : []),\n  set: (items: MenuOption[]) => {\n    if (props.optionsVariant === \"radio\" || props.disableDeselect) {\n      if (items.length > 0) {\n        selectedItem.value = items[0];\n      }\n    } else {\n      selectedItem.value = items.length > 0 ? items[0] : undefined;\n    }\n  },\n});\n\nconst handleSelectItem = () => {\n  closeDropdown();\n};\n\nconst handleClear = () => {\n  selectedItem.value = undefined;\n};\n\nconst closeDropdown = () => {\n  open.value = false;\n  searchInput.value = \"\";\n};\n\nonKeyStroke(\"Escape\", () => {\n  if (!open.value) return;\n\n  closeDropdown();\n});\n</script>\n\n<template>\n  <PvPopoverV2 v-model=\"open\" v-bind=\"resolvedPopoverProperties\">\n    <template #trigger>\n      <PvSelectButtonTrigger\n        class=\"pv-full-width\"\n        ref=\"select-button-trigger-ref\"\n        :variant=\"variant\"\n        :inverse=\"inverse\"\n        :size=\"size\"\n        :disabled=\"disabled\"\n        :prefixLabel=\"prefixLabel\"\n        :label=\"buttonDisplayLabel\"\n        :icon=\"buttonIcon\"\n        :companyLogo=\"buttonCompanyLogo\"\n        :avatar=\"buttonAvatar\"\n        :showClear=\"false\"\n        :showDropdown=\"true\"\n        :open=\"open\"\n        :data-dd-action-name=\"rumActionName\"\n        :counter-position=\"counterPosition\"\n        :counter-value=\"\n          selectedItem?.secondaryText && typeof selectedItem.secondaryText === 'number'\n            ? selectedItem.secondaryText\n            : undefined\n        \"\n        :counter-badge-variant=\"counterBadgeVariant\"\n        :isLoading=\"isLoading\"\n        :menuOptionConfig=\"optionConfig\"\n        :renderer=\"optionsRenderer\"\n        :selectedOption=\"selectedItem\"\n        @handle-clear=\"handleClear\"\n      />\n    </template>\n    <template #content>\n      <div\n        class=\"pv-popover pv-popover-scrollable\"\n        data-test-id=\"pv-popover\"\n        :style=\"popoverCssProperties\"\n        style=\"position: unset\"\n      >\n        <div class=\"pv-popover-scroll\">\n          <template v-if=\"!disableSearchInput\">\n            <div class=\"pv-inset-square-8 pv-border-bottom\">\n              <PvSearchInput v-model:model-value=\"searchInput\" class=\"pv-stack-4\" :placeholder=\"searchPlaceholder\" />\n            </div>\n          </template>\n          <template v-if=\"filteredOptions.length > 0\">\n            <PvMenu\n              v-model:selectedItems=\"menuSelectedItems\"\n              :options=\"filteredOptions\"\n              :config=\"optionConfig\"\n              :queryText=\"highlightSearchText ? searchInput : null\"\n              :singleSelect=\"true\"\n              :disableDeselect=\"disableDeselect\"\n              :childrenDisplay=\"childrenDisplay\"\n              @handle-selected=\"handleSelectItem\"\n            />\n          </template>\n          <PvMenuEmptyState v-else />\n          <slot name=\"footer\" />\n        </div>\n      </div>\n    </template>\n  </PvPopoverV2>\n</template>\n","<script setup lang=\"ts\">\nimport { MapTopologyType } from \"@charts/chart-components/maps/useTopology\";\nimport { computed, ref, watch } from \"vue\";\nimport PvSelectButton from \"@/components/base/PvSelectButton/PvSelectButton.vue\";\nimport { MenuOption } from \"@/types\";\nimport { stateCodeToName, stateMappings } from \"@charts/chart-components/maps/topologies/usStateTopology\";\n\ntype ChartStateSelectorProps = {\n  topologyType: MapTopologyType;\n  selectableRegions?: string[];\n};\n\nconst selectedRegion = defineModel<string | undefined>({\n  type: String,\n  default: \"\",\n});\n\nconst selectedRegionOption = ref(undefined as MenuOption | undefined);\n\nconst props = defineProps<ChartStateSelectorProps>();\n\nconst availableRegionOptions = computed(() => {\n  // for now, only support US states\n  if (props.topologyType !== \"state\") {\n    throw new Error(`Unsupported topology type for state selector: ${props.topologyType}`);\n  }\n  const states = props.selectableRegions ? props.selectableRegions : Object.keys(stateMappings);\n  return states.map((state) => {\n    return {\n      text: stateCodeToName(state),\n      id: state,\n    } as MenuOption;\n  });\n});\n\nwatch(selectedRegionOption, (newOption) => {\n  if (newOption === selectedRegion.value || newOption?.id === selectedRegion.value) {\n    return;\n  }\n  selectedRegion.value = newOption?.id;\n});\n\nwatch(selectedRegion, (newRegion) => {\n  if (newRegion === selectedRegionOption.value || newRegion === selectedRegionOption.value?.id) {\n    return;\n  }\n  selectedRegionOption.value = availableRegionOptions.value.find((option) => option.id === newRegion);\n});\n</script>\n\n<template>\n  <PvSelectButton\n    style=\"width: 125px\"\n    :popoverCssProperties=\"{ 'max-width': '150px' }\"\n    :disabled=\"availableRegionOptions.length < 2\"\n    label=\"All\"\n    v-model=\"selectedRegionOption\"\n    :options=\"availableRegionOptions\"\n  ></PvSelectButton>\n</template>\n","<script setup lang=\"ts\">\nimport { MapTopologyType } from \"@charts/chart-components/maps/useTopology\";\nimport { computed, ref, watch } from \"vue\";\nimport PvSelectButton from \"@/components/base/PvSelectButton/PvSelectButton.vue\";\nimport { MenuOption } from \"@/types\";\nimport { stateCodeToName, stateMappings } from \"@charts/chart-components/maps/topologies/usStateTopology\";\n\ntype ChartStateSelectorProps = {\n  topologyType: MapTopologyType;\n  selectableRegions?: string[];\n};\n\nconst selectedRegion = defineModel<string | undefined>({\n  type: String,\n  default: \"\",\n});\n\nconst selectedRegionOption = ref(undefined as MenuOption | undefined);\n\nconst props = defineProps<ChartStateSelectorProps>();\n\nconst availableRegionOptions = computed(() => {\n  // for now, only support US states\n  if (props.topologyType !== \"state\") {\n    throw new Error(`Unsupported topology type for state selector: ${props.topologyType}`);\n  }\n  const states = props.selectableRegions ? props.selectableRegions : Object.keys(stateMappings);\n  return states.map((state) => {\n    return {\n      text: stateCodeToName(state),\n      id: state,\n    } as MenuOption;\n  });\n});\n\nwatch(selectedRegionOption, (newOption) => {\n  if (newOption === selectedRegion.value || newOption?.id === selectedRegion.value) {\n    return;\n  }\n  selectedRegion.value = newOption?.id;\n});\n\nwatch(selectedRegion, (newRegion) => {\n  if (newRegion === selectedRegionOption.value || newRegion === selectedRegionOption.value?.id) {\n    return;\n  }\n  selectedRegionOption.value = availableRegionOptions.value.find((option) => option.id === newRegion);\n});\n</script>\n\n<template>\n  <PvSelectButton\n    style=\"width: 125px\"\n    :popoverCssProperties=\"{ 'max-width': '150px' }\"\n    :disabled=\"availableRegionOptions.length < 2\"\n    label=\"All\"\n    v-model=\"selectedRegionOption\"\n    :options=\"availableRegionOptions\"\n  ></PvSelectButton>\n</template>\n","<script lang=\"ts\">\nimport { MapTopologyType } from \"@charts/chart-components/maps/useTopology\";\nimport type { AgMapLineSeriesTooltipRendererParams } from \"ag-charts-enterprise\";\n\n// the chart data must contain a key matching the topology type (e.g. a \"state\" key for the state)\nexport interface PvMapChartData {\n  [key: string]: string | number;\n}\n\nexport interface RegionSelectionChangedEvent {\n  region: string | null | undefined;\n}\n\nexport interface PvMapChartProps {\n  /** The data key whose values are mapped to the color gradient on the map. Must match a key in the chart data objects. */\n  seriesKey: string;\n  /** Human-friendly label shown for the value in the default tooltip. Falls back to `seriesKey` when omitted. */\n  seriesLabel?: string;\n  /** The geographic granularity of the map. Currently only `\"state\"` is fully supported. */\n  mapType?: MapTopologyType;\n  /** When true, renders the color gradient legend above the map. */\n  displayGradientLegend?: boolean;\n  /** When true, renders the region selector dropdown above the map. */\n  displayRegionSelector?: boolean;\n  /** Minimum value for the gradient legend scale. */\n  gradientLegendMin?: number;\n  /** Maximum value for the gradient legend scale. */\n  gradientLegendMax?: number;\n  /** Formatter function for values displayed in the gradient legend. Defaults to percent formatting. */\n  seriesValueFormatter?: (value: number) => string;\n  /** When true, displays a loading spinner overlay on the chart. */\n  isLoading?: boolean;\n  /** When true, clicking a region selects/deselects it. Set to false to render a non-interactive map. */\n  clickable?: boolean;\n  /** Custom message displayed when chart data is empty. */\n  noDataMessage?: string;\n  /** Custom tooltip renderer for map regions. Receives AG Charts tooltip params with the region datum. */\n  tooltipRenderer?: (params: AgMapLineSeriesTooltipRendererParams<PvMapChartData>) => string | HTMLElement;\n}\n</script>\n\n<script setup lang=\"ts\">\nimport PvChart from \"@charts/PvChart/PvChart.vue\";\nimport { useTopology } from \"@charts/chart-components/maps/useTopology\";\nimport type { AgChartOptions } from \"ag-charts-types\";\nimport { computed, ref, watch } from \"vue\";\nimport MapGradient from \"@charts/chart-components/maps/MapGradient.vue\";\nimport MapRegionSelector from \"@charts/chart-components/maps/MapRegionSelector.vue\";\nimport { maxFeatureName, minFeatureName } from \"@charts/chart-components/maps/topologies/usStateTopology\";\n\nconst props = withDefaults(defineProps<PvMapChartProps>(), {\n  mapType: \"state\",\n  gradientLegendMin: 0,\n  gradientLegendMax: 1,\n  displayGradientLegend: true,\n  displayRegionSelector: true,\n  clickable: true,\n  seriesValueFormatter: (value: number) => {\n    return value.toLocaleString(\"en-US\", {\n      style: \"percent\",\n      minimumFractionDigits: 0,\n      maximumFractionDigits: 0,\n    });\n  },\n  isLoading: false,\n});\n\n//define chartData and selectedRegion as model values\nconst chartData = defineModel<PvMapChartData[]>(\"chartData\", {\n  required: true,\n});\nconst selectedRegion = defineModel<string | undefined>(\"selectedRegion\", {\n  required: false,\n});\n\nconst emits = defineEmits<{\n  (e: \"region-selection-changed\", event: RegionSelectionChangedEvent): void;\n}>();\n\nconst pvChartRef = ref<InstanceType<typeof PvChart> | null>(null);\n\nconst { getTopologyObject, buildMapData } = useTopology();\n\nconst topologyObject = computed(() => {\n  return getTopologyObject(props.mapType);\n});\n\nconst mapData = computed(() => {\n  return buildMapData(\n    chartData.value,\n    props.mapType,\n    props.seriesKey,\n    props.gradientLegendMin,\n    props.gradientLegendMax,\n  );\n});\n\nconst selectableRegions = computed(() => {\n  return mapData.value\n    .filter((item) => {\n      // exclude min and max feature names from selectable regions\n      return item[props.mapType] !== minFeatureName && item[props.mapType] !== maxFeatureName;\n    })\n    .map((item) => {\n      // @ts-expect error data should be available\n      return item[props.mapType] as string;\n    });\n});\n\nwatch(selectedRegion, (newSelection) => {\n  // Emit the region selection change event\n  emits(\"region-selection-changed\", {\n    region: newSelection,\n  });\n});\n\nconst computedChartOptions = computed(() => {\n  // use this to update the options when the region changes\n  const _ = selectedRegion.value;\n  const options: AgChartOptions = {\n    data: mapData.value,\n    topology: topologyObject.value,\n    series: [\n      {\n        type: \"map-shape\",\n        idKey: \"name\",\n        colorKey: props.seriesKey,\n        colorRange: [\"#CCF5F1\", \"#B0E8E4\", \"#6FD6CE\", \"#36C5BA\", \"#218C88\", \"#16696D\", \"#02363D\"],\n        cursor: props.clickable ? \"pointer\" : \"default\",\n        tooltip: {\n          renderer: props.tooltipRenderer\n            ? props.tooltipRenderer\n            : ({ datum }) => ({\n                data: [\n                  {\n                    label: props.seriesLabel || props.seriesKey,\n                    value: props.seriesValueFormatter(datum[props.seriesKey]),\n                  },\n                ],\n              }),\n        },\n        // Only wire up click selection when the map is interactive.\n        listeners: props.clickable\n          ? {\n              seriesNodeClick: (event) => {\n                const newSelection = event.datum[props.mapType];\n                // If the same region is clicked, deselect it\n                if (selectedRegion.value === newSelection) {\n                  selectedRegion.value = \"\";\n                } else {\n                  selectedRegion.value = newSelection;\n                }\n              },\n            }\n          : undefined,\n        itemStyler: (params) => {\n          // Reduce opacity of regions that are not selected\n          if (selectedRegion.value == null || selectedRegion.value === \"\") {\n            return {};\n          }\n          const isSelected = params.datum[props.mapType] === selectedRegion.value;\n          if (!isSelected) {\n            return { fillOpacity: 0.25, strokeOpacity: 0.1 };\n          }\n          return { stroke: \"#4B595C\", strokeWidth: 2, strokeOpacity: 1 };\n        },\n      },\n      {\n        type: \"map-shape-background\",\n      },\n    ],\n    overlays: {\n      noData: {\n        text: props.noDataMessage || \"No data to display\",\n      },\n    },\n    gradientLegend: {\n      enabled: false,\n    },\n  };\n\n  return options;\n});\n\ndefineExpose({\n  getChartImageDataURL: (dimensions?: { width?: number; height?: number }): Promise<string> | undefined => {\n    return pvChartRef.value?.getChartImageDataURL(dimensions);\n  },\n});\n</script>\n\n<template>\n  <div class=\"pv-map-chart\">\n    <div\n      v-if=\"displayRegionSelector || displayGradientLegend\"\n      class=\"pv-map-chart__header pv-flex pv-space-between pv-stack-20\"\n      style=\"width: 100%\"\n    >\n      <MapRegionSelector\n        v-if=\"displayRegionSelector\"\n        v-model=\"selectedRegion\"\n        :selectable-regions=\"selectableRegions\"\n        :topology-type=\"mapType\"\n      ></MapRegionSelector>\n      <MapGradient\n        v-if=\"displayGradientLegend\"\n        :min=\"gradientLegendMin\"\n        :max=\"gradientLegendMax\"\n        :value-formatter=\"seriesValueFormatter\"\n      ></MapGradient>\n    </div>\n    <PvChart\n      ref=\"pvChartRef\"\n      class=\"pv-map-chart__chart\"\n      :translateNullValues=\"false\"\n      :options=\"computedChartOptions\"\n      :isLoading=\"isLoading\"\n    ></PvChart>\n  </div>\n</template>\n\n<style scoped>\n/* Fill the parent container - the consumer sizes the map by sizing its wrapper. */\n.pv-map-chart {\n  display: flex;\n  flex-direction: column;\n  width: 100%;\n  height: 100%;\n}\n\n.pv-map-chart__header {\n  flex: 0 0 auto;\n}\n\n/* Let the chart consume all remaining vertical space so the map renders as large\n   as possible without introducing zoom/pan. */\n.pv-map-chart__chart {\n  flex: 1 1 auto;\n  min-height: 0;\n}\n</style>\n","<script lang=\"ts\">\nimport { MapTopologyType } from \"@charts/chart-components/maps/useTopology\";\nimport type { AgMapLineSeriesTooltipRendererParams } from \"ag-charts-enterprise\";\n\n// the chart data must contain a key matching the topology type (e.g. a \"state\" key for the state)\nexport interface PvMapChartData {\n  [key: string]: string | number;\n}\n\nexport interface RegionSelectionChangedEvent {\n  region: string | null | undefined;\n}\n\nexport interface PvMapChartProps {\n  /** The data key whose values are mapped to the color gradient on the map. Must match a key in the chart data objects. */\n  seriesKey: string;\n  /** Human-friendly label shown for the value in the default tooltip. Falls back to `seriesKey` when omitted. */\n  seriesLabel?: string;\n  /** The geographic granularity of the map. Currently only `\"state\"` is fully supported. */\n  mapType?: MapTopologyType;\n  /** When true, renders the color gradient legend above the map. */\n  displayGradientLegend?: boolean;\n  /** When true, renders the region selector dropdown above the map. */\n  displayRegionSelector?: boolean;\n  /** Minimum value for the gradient legend scale. */\n  gradientLegendMin?: number;\n  /** Maximum value for the gradient legend scale. */\n  gradientLegendMax?: number;\n  /** Formatter function for values displayed in the gradient legend. Defaults to percent formatting. */\n  seriesValueFormatter?: (value: number) => string;\n  /** When true, displays a loading spinner overlay on the chart. */\n  isLoading?: boolean;\n  /** When true, clicking a region selects/deselects it. Set to false to render a non-interactive map. */\n  clickable?: boolean;\n  /** Custom message displayed when chart data is empty. */\n  noDataMessage?: string;\n  /** Custom tooltip renderer for map regions. Receives AG Charts tooltip params with the region datum. */\n  tooltipRenderer?: (params: AgMapLineSeriesTooltipRendererParams<PvMapChartData>) => string | HTMLElement;\n}\n</script>\n\n<script setup lang=\"ts\">\nimport PvChart from \"@charts/PvChart/PvChart.vue\";\nimport { useTopology } from \"@charts/chart-components/maps/useTopology\";\nimport type { AgChartOptions } from \"ag-charts-types\";\nimport { computed, ref, watch } from \"vue\";\nimport MapGradient from \"@charts/chart-components/maps/MapGradient.vue\";\nimport MapRegionSelector from \"@charts/chart-components/maps/MapRegionSelector.vue\";\nimport { maxFeatureName, minFeatureName } from \"@charts/chart-components/maps/topologies/usStateTopology\";\n\nconst props = withDefaults(defineProps<PvMapChartProps>(), {\n  mapType: \"state\",\n  gradientLegendMin: 0,\n  gradientLegendMax: 1,\n  displayGradientLegend: true,\n  displayRegionSelector: true,\n  clickable: true,\n  seriesValueFormatter: (value: number) => {\n    return value.toLocaleString(\"en-US\", {\n      style: \"percent\",\n      minimumFractionDigits: 0,\n      maximumFractionDigits: 0,\n    });\n  },\n  isLoading: false,\n});\n\n//define chartData and selectedRegion as model values\nconst chartData = defineModel<PvMapChartData[]>(\"chartData\", {\n  required: true,\n});\nconst selectedRegion = defineModel<string | undefined>(\"selectedRegion\", {\n  required: false,\n});\n\nconst emits = defineEmits<{\n  (e: \"region-selection-changed\", event: RegionSelectionChangedEvent): void;\n}>();\n\nconst pvChartRef = ref<InstanceType<typeof PvChart> | null>(null);\n\nconst { getTopologyObject, buildMapData } = useTopology();\n\nconst topologyObject = computed(() => {\n  return getTopologyObject(props.mapType);\n});\n\nconst mapData = computed(() => {\n  return buildMapData(\n    chartData.value,\n    props.mapType,\n    props.seriesKey,\n    props.gradientLegendMin,\n    props.gradientLegendMax,\n  );\n});\n\nconst selectableRegions = computed(() => {\n  return mapData.value\n    .filter((item) => {\n      // exclude min and max feature names from selectable regions\n      return item[props.mapType] !== minFeatureName && item[props.mapType] !== maxFeatureName;\n    })\n    .map((item) => {\n      // @ts-expect error data should be available\n      return item[props.mapType] as string;\n    });\n});\n\nwatch(selectedRegion, (newSelection) => {\n  // Emit the region selection change event\n  emits(\"region-selection-changed\", {\n    region: newSelection,\n  });\n});\n\nconst computedChartOptions = computed(() => {\n  // use this to update the options when the region changes\n  const _ = selectedRegion.value;\n  const options: AgChartOptions = {\n    data: mapData.value,\n    topology: topologyObject.value,\n    series: [\n      {\n        type: \"map-shape\",\n        idKey: \"name\",\n        colorKey: props.seriesKey,\n        colorRange: [\"#CCF5F1\", \"#B0E8E4\", \"#6FD6CE\", \"#36C5BA\", \"#218C88\", \"#16696D\", \"#02363D\"],\n        cursor: props.clickable ? \"pointer\" : \"default\",\n        tooltip: {\n          renderer: props.tooltipRenderer\n            ? props.tooltipRenderer\n            : ({ datum }) => ({\n                data: [\n                  {\n                    label: props.seriesLabel || props.seriesKey,\n                    value: props.seriesValueFormatter(datum[props.seriesKey]),\n                  },\n                ],\n              }),\n        },\n        // Only wire up click selection when the map is interactive.\n        listeners: props.clickable\n          ? {\n              seriesNodeClick: (event) => {\n                const newSelection = event.datum[props.mapType];\n                // If the same region is clicked, deselect it\n                if (selectedRegion.value === newSelection) {\n                  selectedRegion.value = \"\";\n                } else {\n                  selectedRegion.value = newSelection;\n                }\n              },\n            }\n          : undefined,\n        itemStyler: (params) => {\n          // Reduce opacity of regions that are not selected\n          if (selectedRegion.value == null || selectedRegion.value === \"\") {\n            return {};\n          }\n          const isSelected = params.datum[props.mapType] === selectedRegion.value;\n          if (!isSelected) {\n            return { fillOpacity: 0.25, strokeOpacity: 0.1 };\n          }\n          return { stroke: \"#4B595C\", strokeWidth: 2, strokeOpacity: 1 };\n        },\n      },\n      {\n        type: \"map-shape-background\",\n      },\n    ],\n    overlays: {\n      noData: {\n        text: props.noDataMessage || \"No data to display\",\n      },\n    },\n    gradientLegend: {\n      enabled: false,\n    },\n  };\n\n  return options;\n});\n\ndefineExpose({\n  getChartImageDataURL: (dimensions?: { width?: number; height?: number }): Promise<string> | undefined => {\n    return pvChartRef.value?.getChartImageDataURL(dimensions);\n  },\n});\n</script>\n\n<template>\n  <div class=\"pv-map-chart\">\n    <div\n      v-if=\"displayRegionSelector || displayGradientLegend\"\n      class=\"pv-map-chart__header pv-flex pv-space-between pv-stack-20\"\n      style=\"width: 100%\"\n    >\n      <MapRegionSelector\n        v-if=\"displayRegionSelector\"\n        v-model=\"selectedRegion\"\n        :selectable-regions=\"selectableRegions\"\n        :topology-type=\"mapType\"\n      ></MapRegionSelector>\n      <MapGradient\n        v-if=\"displayGradientLegend\"\n        :min=\"gradientLegendMin\"\n        :max=\"gradientLegendMax\"\n        :value-formatter=\"seriesValueFormatter\"\n      ></MapGradient>\n    </div>\n    <PvChart\n      ref=\"pvChartRef\"\n      class=\"pv-map-chart__chart\"\n      :translateNullValues=\"false\"\n      :options=\"computedChartOptions\"\n      :isLoading=\"isLoading\"\n    ></PvChart>\n  </div>\n</template>\n\n<style scoped>\n/* Fill the parent container - the consumer sizes the map by sizing its wrapper. */\n.pv-map-chart {\n  display: flex;\n  flex-direction: column;\n  width: 100%;\n  height: 100%;\n}\n\n.pv-map-chart__header {\n  flex: 0 0 auto;\n}\n\n/* Let the chart consume all remaining vertical space so the map renders as large\n   as possible without introducing zoom/pan. */\n.pv-map-chart__chart {\n  flex: 1 1 auto;\n  min-height: 0;\n}\n</style>\n","<script setup lang=\"ts\">\nimport type { PvDataWidgetTableProps } from \"./types\";\n\ndefineProps<PvDataWidgetTableProps>();\n</script>\n\n<template>\n  <table class=\"pv-table pv-full-width\">\n    <thead>\n      <tr>\n        <th v-for=\"header in headers\" :key=\"header.field\" scope=\"col\">\n          {{ header.label }}\n        </th>\n      </tr>\n    </thead>\n    <tbody>\n      <tr v-for=\"(row, rowIndex) in rows\" :key=\"rowIndex\">\n        <td v-for=\"(cell, cellIndex) in row\" :key=\"cellIndex\">\n          {{ cell }}\n        </td>\n      </tr>\n    </tbody>\n  </table>\n</template>\n","<script setup lang=\"ts\">\nimport type { PvDataWidgetTableProps } from \"./types\";\n\ndefineProps<PvDataWidgetTableProps>();\n</script>\n\n<template>\n  <table class=\"pv-table pv-full-width\">\n    <thead>\n      <tr>\n        <th v-for=\"header in headers\" :key=\"header.field\" scope=\"col\">\n          {{ header.label }}\n        </th>\n      </tr>\n    </thead>\n    <tbody>\n      <tr v-for=\"(row, rowIndex) in rows\" :key=\"rowIndex\">\n        <td v-for=\"(cell, cellIndex) in row\" :key=\"cellIndex\">\n          {{ cell }}\n        </td>\n      </tr>\n    </tbody>\n  </table>\n</template>\n","import type { PvDataWidgetChartTypeOption, PvDataWidgetViewType } from \"./types\";\n\nexport const DEFAULT_CHART_TYPE_OPTIONS: Required<Pick<PvDataWidgetChartTypeOption, \"icon\" | \"label\" | \"value\">>[] = [\n  { value: \"column\", label: \"Column\", icon: \"chart-column\" },\n  { value: \"bar\", label: \"Bar\", icon: \"chart-bar\" },\n  { value: \"line\", label: \"Line\", icon: \"chart-line\" },\n  { value: \"area\", label: \"Area\", icon: \"chart-area\" },\n  { value: \"scatter\", label: \"Scatter\", icon: \"chart-line\" },\n  { value: \"pie\", label: \"Pie\", icon: \"chart-pie\" },\n  { value: \"histogram\", label: \"Histogram\", icon: \"chart-column\" },\n  { value: \"map\", label: \"Map\", icon: \"map\" },\n  { value: \"table\", label: \"Table\", icon: \"table\" },\n];\n\nexport const DEFAULT_ENABLED_CHART_TYPES: PvDataWidgetViewType[] = [\"column\", \"bar\", \"line\", \"area\", \"table\"];\nexport const DEFAULT_FALLBACK_CHART_TYPE: PvDataWidgetViewType = \"column\";\nexport const TABLE_VIEW_TYPE: PvDataWidgetViewType = \"table\";\nexport const NUMERIC_DATA_TYPES = new Set([\"currency\", \"number\", \"numeric\", \"percent\", \"percentage\"]);\nexport const DEFAULT_MAP_REGION_FIELD = \"state\";\nexport const DEFAULT_MIN_HEIGHT_PX = 320;\n// Minimum width a horizontally-scrolling chart's content occupies before its data points\n// would otherwise force it wider. Unlike PvChartWidget, this widget does not measure its\n// container, so it uses a fixed floor rather than the observed container width.\nexport const CHART_SCROLL_MIN_WIDTH_PX = 320;\nexport const DEFAULT_LOADING_TEXT = \"Building a preview of your request\";\n// Descending bar heights (px) for the loading-state chart thumbnail, drawn in a 40px-tall tile.\nexport const LOADING_THUMBNAIL_BAR_HEIGHTS_PX = [34, 27, 23, 21, 17, 14];\n","import { MenuOption } from \"@/types\";\n\nexport const BUCKET_AGG_FUNC_NAME = \"bucketCount\";\nexport const BUCKET_AGG_COUNT_VALUE_NAME = \"groupedRecordCount\";\n\nexport const singleGroupChartTypeConfigs: MenuOption[] = [\n  {\n    text: \"Column\",\n    id: \"column\",\n    icon: \"chart-column\",\n  },\n  {\n    text: \"Bar\",\n    id: \"bar\",\n    icon: \"chart-bar\",\n  },\n  {\n    text: \"Line\",\n    id: \"line\",\n    icon: \"chart-line\",\n  },\n  {\n    text: \"Area\",\n    id: \"area\",\n    icon: \"chart-area\",\n  },\n  {\n    text: \"Pie\",\n    id: \"pie\",\n    icon: \"chart-pie\",\n  },\n];\n\nexport const multiGroupChartTypeConfigs: MenuOption[] = [\n  {\n    text: \"Grouped Column\",\n    id: \"column\",\n    icon: \"chart-column-big\",\n  },\n  {\n    text: \"Stacked Column\",\n    id: \"column_stacked\",\n    icon: \"chart-column-stacked\",\n  },\n  {\n    text: \"Grouped Bar\",\n    id: \"bar\",\n    icon: \"chart-bar-big\",\n  },\n  {\n    text: \"Stacked Bar\",\n    id: \"bar_stacked\",\n    icon: \"chart-bar-stacked\",\n  },\n  // Renders one line per secondary group value rather than a single aggregate line.\n  {\n    text: \"Line\",\n    id: \"line\",\n    icon: \"chart-line\",\n  },\n];\n\nexport const histogramChartTypeConfig: MenuOption = {\n  text: \"Histogram\",\n  id: \"histogram\",\n  icon: \"chart-column\",\n};\n\nexport const mapChartTypeConfig: MenuOption = {\n  text: \"Map\",\n  id: \"map\",\n  icon: \"map\",\n};\n\n// Field name (or \"location\" data type) that the chart treats as a geographic\n// region. When this field is the active x-axis, the \"map\" chart type becomes\n// available and switches the chart to PvMapChart.\nexport const MAP_REGION_FIELD = \"state\";\n\nexport const separatorValue = \"--SEPARATOR--\";\n\n// Blank categories appended before/after a histogram's real buckets so the\n// overall min/max notation can render further out from the first/last bar\n// instead of centered on it.\nexport const distributionRangeMinCategory = \"--DISTRIBUTION-RANGE-MIN--\";\nexport const distributionRangeMaxCategory = \"--DISTRIBUTION-RANGE-MAX--\";\n\n// Sentinel categories used to pad a single-bar chart on either side so the lone\n// bar isn't rendered full-width. They must never equal a real category value -\n// otherwise a genuinely blank (\"(Blanks)\") category collides with a pad and the\n// pad's transparent, valueless bar overwrites the real one, making it invisible.\n// Like separatorValue, these are hidden by the category-axis label formatter and\n// filtered out of map/scatter data.\nexport const padStartValue = \"--PAD-START--\";\nexport const padEndValue = \"--PAD-END--\";\n\nexport const sortTotalSuffix = \"_sort_total\";\n\n// Number of equal intervals (gridline gaps) both y-axes are divided into when a\n// secondary axis is displayed. 5 intervals => 6 horizontal lines incl. the zero\n// baseline, shared by the primary and secondary axes so their lines coincide.\nexport const SECONDARY_AXIS_INTERVAL_COUNT = 5;\n","export enum ColDefDataType {\n  String = \"string\",\n  Number = \"number\",\n  Boolean = \"boolean\",\n  Date = \"date\",\n  Currency = \"currency\",\n  Formula = \"formula\",\n  Select = \"select\",\n  Percent = \"percent\",\n  Entity = \"entity\",\n  Id = \"id\",\n  Integer = \"integer\",\n  User = \"user\",\n  Link = \"link\",\n  Location = \"location\",\n  Status = \"status\",\n  Tag = \"tag\",\n  File = \"file\",\n  None = \"none\",\n}\n\nexport const mapEntityTypeToHeaderIcon = (entityType: ColDefDataType | null) => {\n  switch (entityType) {\n    case ColDefDataType.String:\n      return \"fonts\";\n    case ColDefDataType.Number:\n      return \"hash\";\n    case ColDefDataType.Boolean:\n      return \"list\";\n    case ColDefDataType.Date:\n      return \"calendar\";\n    case ColDefDataType.Currency:\n      return \"currency-dollar\";\n    case ColDefDataType.Formula:\n      return \"formula\";\n    case ColDefDataType.Select:\n      return \"list\";\n    case ColDefDataType.Percent:\n      return \"percent\";\n    case ColDefDataType.Entity:\n      return \"building\";\n    case ColDefDataType.Id:\n      return \"id-2\";\n    case ColDefDataType.Link:\n      return \"link\";\n    case ColDefDataType.Location:\n      return \"location\";\n    case ColDefDataType.Integer:\n      return \"hash\";\n    case ColDefDataType.User:\n      return \"user\";\n    case ColDefDataType.Status:\n      return \"circle-chevron-down\";\n    case ColDefDataType.Tag:\n      return \"circle-chevron-down\";\n    case ColDefDataType.File:\n      return \"file\";\n    case ColDefDataType.None:\n      return null;\n    default:\n      return null;\n  }\n};\n\n/**\n * Remove unnecessary chars from table header displayNames\n */\nexport const updateDisplayNameForDataType = (displayName: string, entityType: ColDefDataType | null) => {\n  if (!displayName) return displayName;\n\n  switch (entityType) {\n    case ColDefDataType.Percent:\n      // The table will already display a % icon in the header\n      // so we can remove any leading % chars in the displayName\n      return displayName.replace(/^%+/, \"\").trim();\n    default:\n      return displayName;\n  }\n};\n\nconst stripDecimalZeros = (numStr: string) => (numStr.includes(\".\") ? numStr.replace(/\\.?0+$/, \"\") : numStr);\n\nexport const truncateValue = (\n  value: number,\n  isPercent: boolean = false,\n  maxChartValue: number = 0,\n): { newValue: string; newSuffix: string } => {\n  const suffixes = [\"\", \"K\", \"M\", \"B\", \"T\"];\n  const absValue = Math.abs(value);\n  const absChartScaleValue = Math.abs(maxChartValue);\n  let decimalPlaces = isPercent ? 2 : 0;\n  const tier = Math.floor(Math.log10(absValue) / 3);\n  const chartTier = Math.floor(Math.log10(absChartScaleValue) / 3);\n  // for non-percent values, allow up to 2 decimals depending on the current chart scale and the tier\n  if (chartTier >= tier || tier > 3) {\n    decimalPlaces = 2;\n  }\n  if (absValue < 1000) {\n    return {\n      newValue: stripDecimalZeros(value.toFixed(decimalPlaces)),\n      newSuffix: \"\",\n    };\n  }\n  const suffix = suffixes[tier] || `e${tier * 3}`;\n  const scaled = value / Math.pow(10, tier * 3);\n  const newValue = stripDecimalZeros(scaled.toFixed(decimalPlaces));\n  return { newValue, newSuffix: suffix };\n};\n","import { Column, ColumnVO, ICellRendererParams, ValueFormatterFunc } from \"ag-grid-enterprise\";\nimport { ColDef } from \"ag-grid-community\";\nimport { AggregateFieldHierarchy, ColDefContextProps } from \"@tables/PvDataTable/types\";\nimport { ColDefDataType } from \"@tables/PvDataTable/table-components/formatting\";\nimport { BUCKET_AGG_FUNC_NAME } from \"@charts/PvDataTableWithChart/constants.ts\";\n\n/**\n * Returns row data for a cell renderer. For leaf rows, returns `params.data` directly.\n * For group rows (where `params.data` is null), falls back to the first child row's data.\n * Useful in custom cell renderers that need to display field values on grouped rows.\n */\nexport const getFirstRowData = (params: ICellRendererParams): Record<string, unknown> | null => {\n  if (params.data) return params.data;\n  const children = params.node?.childrenAfterGroup;\n  if (children && children.length > 0) return children[0].data;\n  return null;\n};\n\nexport const liftFocusedOptions = <T>(\n  currentOptions: T[] | undefined,\n  key: keyof T,\n  currentFocuses: string[],\n): T[] | undefined => {\n  if (!currentOptions || currentOptions.length === 0) {\n    return currentOptions;\n  }\n\n  return currentOptions.slice().sort((a, b) => {\n    const aPriority = currentFocuses.includes(a[key] as string) ? 0 : 1;\n    const bPriority = currentFocuses.includes(b[key] as string) ? 0 : 1;\n    return aPriority - bPriority;\n  });\n};\n\nexport const colDefContext = <T>(colDef: ColDef<T> | null | undefined): ColDefContextProps<T> => {\n  if (!colDef) return {};\n  const context = colDef.context as ColDefContextProps<T>;\n  return context || {};\n};\n\nexport const colDefValueFormatter = <T>(colDef: ColDef<T>): ValueFormatterFunc<T> | null => {\n  const context = colDefContext(colDef);\n  if (context.filterValueFormatter && typeof context.filterValueFormatter === \"function\") {\n    return context.filterValueFormatter;\n  } else if (typeof colDef.valueFormatter === \"function\") {\n    return colDef.valueFormatter;\n  }\n  return null;\n};\n\nexport const colDefMaxSelectableValues = <T>(colDef: ColDef<T>): number | null => {\n  const context = colDefContext(colDef);\n  return context.filterSelectMax || null;\n};\n\nexport const isColDefSingleSelect = <T>(colDef: ColDef<T>): boolean => {\n  const context = colDefContext(colDef);\n  return context.filterSelectMin === 1 && colDefMaxSelectableValues(colDef) === 1;\n};\n\nexport const isColDefNumericDataType = <T>(colDef: ColDef<T>): boolean => {\n  const dataType = colDefContext(colDef).dataType;\n  if (!dataType) return false;\n  return [\n    ColDefDataType.Currency,\n    ColDefDataType.Percent,\n    ColDefDataType.Number,\n    ColDefDataType.Integer,\n    ColDefDataType.Formula,\n  ].includes(dataType);\n};\n\n/**\n * Whether a column's header should sit on the right edge. Numeric data types\n * right-align by convention, and so does AG Grid's own `rightAligned` type.\n */\nexport const isColDefRightAligned = <T>(colDef: ColDef<T>): boolean => {\n  if (isColDefNumericDataType(colDef)) return true;\n  const type = colDef.type;\n  if (!type) return false;\n  return (Array.isArray(type) ? type : [type]).includes(\"rightAligned\");\n};\n\nexport const flattenAggregateFieldHierarchy = (hierarchy: AggregateFieldHierarchy | undefined): string[] => {\n  if (!hierarchy) return [];\n  return [hierarchy.field, ...(hierarchy.children || []).flatMap(flattenAggregateFieldHierarchy)];\n};\n\nexport const getAggregateFields = <T>(colDef: ColDef<T>): string[] => {\n  const context = colDefContext(colDef);\n  return context.aggregateFieldHierarchy\n    ? flattenAggregateFieldHierarchy(context.aggregateFieldHierarchy)\n    : context.aggregateFields || [];\n};\n\nexport const getAggregateLeafFields = (hierarchy: AggregateFieldHierarchy | undefined): string[] => {\n  if (!hierarchy) return [];\n  if (!hierarchy.children?.length) return [hierarchy.field];\n  return hierarchy.children.flatMap(getAggregateLeafFields);\n};\n\nexport const getAggregateRootField = <T>(colDef: ColDef<T>): string | undefined => {\n  const context = colDefContext(colDef);\n  if (context.aggregateFieldHierarchy) return context.aggregateFieldHierarchy.field;\n  return context.aggregateFields?.[context.aggregateFields.length - 1];\n};\n\nexport const isAggregateColDef = <T>(colDef: ColDef<T>): boolean => getAggregateFields(colDef).length > 0;\n\nexport const processRowGroupCols = (\n  rowGroupCols: ColumnVO[],\n  colDefs: (ColDef | null | undefined)[] | undefined,\n): ColumnVO[] => {\n  if (!rowGroupCols || !colDefs) return rowGroupCols || [];\n  return rowGroupCols.map((col) => {\n    const colDef = colDefs.find((cd) => cd?.field === col.field);\n    if (colDef && isColDefNumericDataType(colDef)) {\n      return { ...col, aggFunc: BUCKET_AGG_FUNC_NAME };\n    }\n    // Strip aggFunc — row group cols are dimensions, not aggregations.\n    return { ...col, aggFunc: undefined };\n  });\n};\n\nexport const mapColsToColumnV0 = (columns: Column[]): ColumnVO[] => {\n  return columns.map((col) => {\n    return {\n      id: col.getColId(),\n      displayName: col.getColDef().headerName || \"\",\n      field: col.getColDef().field || \"\",\n      aggFunc: col.getAggFunc() || undefined,\n    } as ColumnVO;\n  });\n};\n","//key generator to create unique combinations for a given series and group type, when using stacking\nimport type { AgAxisLabelFormatterParams, AgChartOptions, Formatter } from \"ag-charts-enterprise\";\nimport { ColDef } from \"ag-grid-community\";\nimport { LabelFormatterContext, OptionWithFormatterAndDataType } from \"@charts/PvDataTableWithChart/types\";\nimport {\n  distributionRangeMaxCategory,\n  distributionRangeMinCategory,\n  padEndValue,\n  padStartValue,\n  separatorValue,\n  sortTotalSuffix,\n} from \"@charts/PvDataTableWithChart/constants\";\nimport { MAX_LABEL_LENGTH, NO_DATA_OVERLAY_TEXT } from \"@charts/PvChart/constants\";\nimport { colDefContext } from \"@tables/PvDataTable/helpers\";\nimport { ColDefDataType } from \"@tables/PvDataTable/table-components/formatting\";\n\n// True when a column should appear as a metric overlay option.\nexport const isAvailableSecondarySeriesColDef = (colDef: ColDef): boolean => {\n  const context = colDefContext(colDef);\n  return context.chartOnSecondaryAxes === true && !context.hideFromCharting;\n};\n\n// Returns field_aggFunc (e.g. \"billing_code_full_count\") when the field is also a row group\n// dimension, so the backend can send it as an explicit value col id and avoid the SQL name\n// collision. The chart request handler must apply the same convention.\nexport const getSecondarySeriesKey = (\n  field: string,\n  aggFunc: string | null | undefined,\n  rowGroupFields: Set<string>,\n): string => {\n  if (rowGroupFields.has(field) && typeof aggFunc === \"string\") {\n    return `${field}_${aggFunc}`;\n  }\n  return field;\n};\n\n/**\n * Rounds `rawMax` up to a \"nice\" ceiling that divides into `intervals` equal,\n * human-friendly steps (multiples of 1, 2, 2.5, or 5 × a power of ten).\n *\n * Used to give the primary and secondary y-axes the same number of intervals\n * from a shared zero baseline, so their gridlines coincide as one set of\n * horizontal lines instead of two misaligned sets. e.g. a raw max of 9.3 over\n * 5 intervals rounds to 10 (steps of 2); a raw max of 100 stays 100 (steps of 20).\n *\n * Returns 0 for non-positive or non-finite input, signalling the caller to fall\n * back to AG Charts' automatic scaling rather than building a degenerate axis.\n */\nexport const niceAxisCeiling = (rawMax: number, intervals: number): number => {\n  if (!Number.isFinite(rawMax) || rawMax <= 0 || intervals <= 0) {\n    return 0;\n  }\n  const rawStep = rawMax / intervals;\n  const magnitude = 10 ** Math.floor(Math.log10(rawStep));\n  const normalizedStep = rawStep / magnitude; // in [1, 10)\n  const niceNormalizedStep =\n    normalizedStep <= 1 ? 1 : normalizedStep <= 2 ? 2 : normalizedStep <= 2.5 ? 2.5 : normalizedStep <= 5 ? 5 : 10;\n  return niceNormalizedStep * magnitude * intervals;\n};\n\n/** Round a raw step up to a \"nice\" value (1 / 2 / 2.5 / 5 x 10^k). */\nconst niceStep = (rawStep: number): number => {\n  const magnitude = 10 ** Math.floor(Math.log10(rawStep));\n  const normalized = rawStep / magnitude; // in [1, 10)\n  const nice = normalized <= 1 ? 1 : normalized <= 2 ? 2 : normalized <= 2.5 ? 2.5 : normalized <= 5 ? 5 : 10;\n  return nice * magnitude;\n};\n\n/**\n * A \"nice\" fitted axis window: floor and ceiling on multiples of a nice step\n * (1 / 2 / 2.5 / 5 x 10^k) spanning exactly `intervals` equal steps, with\n * floor <= rawMin and ceiling >= rawMax.\n *\n * Used for a line chart's primary value axis when it is grid-aligned against a\n * secondary axis: lines don't encode value by length from a baseline, so the\n * axis can hug the data (e.g. percentages clustered around 100%) instead of\n * stretching to zero — and because the window keeps the shared interval count,\n * both axes' gridlines still coincide. Data near zero floors to zero naturally.\n *\n * Returns null for non-finite, negative-min, or degenerate (max <= min) input,\n * signalling the caller to fall back to the zero-based window.\n */\nexport const niceAxisRange = (\n  rawMin: number,\n  rawMax: number,\n  intervals: number,\n): { min: number; max: number; step: number } | null => {\n  if (!Number.isFinite(rawMin) || !Number.isFinite(rawMax) || rawMin < 0 || rawMax <= rawMin || intervals <= 0) {\n    return null;\n  }\n  let step = niceStep((rawMax - rawMin) / intervals);\n  // Flooring the window start to a step multiple can drop the ceiling below rawMax;\n  // widen to the next nice step until the window covers the data. The step grows\n  // geometrically, so a handful of iterations always suffices.\n  for (let attempt = 0; attempt < 8; attempt++) {\n    const min = step * Math.floor(rawMin / step);\n    const max = min + step * intervals;\n    if (max >= rawMax) {\n      return { min, max, step };\n    }\n    step = niceStep(step * 1.2);\n  }\n  return null;\n};\n\nexport const computeNoDataOverlayText = ({\n  currentRowGroupColumnsLength,\n  shouldShowFocusOverlayText,\n  chartDataEmpty,\n  missingFocusText,\n  yAxisName,\n  yAxisOptionCount,\n}: {\n  currentRowGroupColumnsLength: number;\n  shouldShowFocusOverlayText: boolean;\n  chartDataEmpty: boolean;\n  missingFocusText: string | undefined | null;\n  /** Display name of the currently selected y-axis. */\n  yAxisName?: string;\n  /**\n   * Number of selectable y-axis options. Prompting the user to \"select a different one\"\n   * only makes sense when there's more than one to choose from.\n   */\n  yAxisOptionCount?: number;\n}): string => {\n  if (currentRowGroupColumnsLength === 0) {\n    return \"No groups selected. Select at least one group to display data.\";\n  }\n  // A required-but-unselected focus hides the chart data even when data exists - it's\n  // held back until the user picks a focus. So the focus prompt must show whenever the\n  // focus overlay is active, independent of whether the underlying series is empty;\n  // otherwise the chart goes completely blank with no explanation (e.g. switching the\n  // x-axis away from the focused dimension clears the focus while a percent-of-focus\n  // y-axis stays selected).\n  if (shouldShowFocusOverlayText) {\n    // When no override is given, the default message is rendered by the template so it can\n    // include the focus icon inline; an empty string here signals the template to do that.\n    return missingFocusText ?? \"\";\n  }\n  if (chartDataEmpty) {\n    // When there are multiple y-axis options, name the empty one and nudge the user to switch.\n    // With a single y-axis there's nothing to switch to, so keep the generic overlay text.\n    if (yAxisName && (yAxisOptionCount ?? 0) > 1) {\n      return `No data available for ${yAxisName}, please select a different one.`;\n    }\n    return NO_DATA_OVERLAY_TEXT;\n  }\n  return \"\";\n};\n\n/**\n * True when a column represents a point in time. A date column on the x-axis is\n * always plotted chronologically (see `sortChartDataChronologically`) - ordering\n * dates by their series value would make the chart unreadable.\n */\nexport const isChronologicalColDef = (colDef: ColDef | null | undefined): boolean => {\n  if (!colDef) {\n    return false;\n  }\n  return colDefContext(colDef).dataType === ColDefDataType.Date;\n};\n\n/**\n * Parses a chart category value into a timestamp. Handles the shapes a date\n * column can reach the chart as: a Date, an epoch number, an ISO string, or an\n * M/D/YYYY string. Returns null when the value isn't a supported date.\n */\nconst toTimestamp = (value: unknown): number | null => {\n  if (value instanceof Date) {\n    const time = value.getTime();\n    return Number.isNaN(time) ? null : time;\n  }\n  if (typeof value === \"number\") {\n    return Number.isFinite(value) ? value : null;\n  }\n  if (typeof value !== \"string\" || value.trim() === \"\") {\n    return null;\n  }\n\n  const date = value.trim();\n  const iso = /^(\\d{4})-(\\d{2})-(\\d{2})(?:T.*)?$/.exec(date);\n  const us = /^(\\d{1,2})\\/(\\d{1,2})\\/(\\d{4})$/.exec(date);\n  if (!iso && !us) return null;\n\n  const [year, month, day] = iso\n    ? [Number(iso[1]), Number(iso[2]), Number(iso[3])]\n    : [Number(us![3]), Number(us![1]), Number(us![2])];\n  const calendarDate = new Date(Date.UTC(year, month - 1, day));\n  if (\n    calendarDate.getUTCFullYear() !== year ||\n    calendarDate.getUTCMonth() !== month - 1 ||\n    calendarDate.getUTCDate() !== day\n  ) {\n    return null;\n  }\n\n  if (!iso || !date.includes(\"T\")) return calendarDate.getTime();\n  const parsed = Date.parse(date);\n  return Number.isNaN(parsed) ? null : parsed;\n};\n\n/**\n * Orders chart data oldest to newest by its category (x-axis) field. Used when the\n * x-axis column has the `date` data type, where chronological order is the only\n * meaningful order regardless of the user's chart sort selection.\n *\n * Values that can't be parsed as dates sink to the end (ordered by their raw string\n * value) so an unexpected category never displaces the real timeline.\n */\nexport const sortChartDataChronologically = (\n  data: AgChartOptions[\"data\"],\n  categoryField: string,\n): AgChartOptions[\"data\"] => {\n  if (!data || data.length === 0 || !categoryField) {\n    return data;\n  }\n  return [...data].sort((a, b) => {\n    const aTime = toTimestamp(a[categoryField]);\n    const bTime = toTimestamp(b[categoryField]);\n    if (aTime === null && bTime === null) {\n      return String(a[categoryField] ?? \"\").localeCompare(String(b[categoryField] ?? \"\"));\n    }\n    if (aTime === null) return 1;\n    if (bTime === null) return -1;\n    return aTime - bTime;\n  });\n};\n\nexport const generateStackSeriesKey = (seriesField: string, stackField: string) => {\n  return `${seriesField}_${stackField}`; // e.g. \"rate_inpatient\" for series \"rate\" and stack \"inpatient\"\n};\n\nexport const generateStackSecondaryCategoryKey = (stackField: string) => {\n  return `secondaryCategory_${stackField}`;\n};\n\nexport interface StackValuesPage {\n  data: AgChartOptions[\"data\"];\n  /** Total distinct stack values across all pages. */\n  total: number;\n  pageCount: number;\n  /** The page actually returned — clamped into range if the requested one was out of bounds. */\n  pageIndex: number;\n  /** This page's stack values, ordered by total contribution to the primary series,\n   * descending (highest cost first) — the render order, not just the selection. */\n  orderedLabels: string[];\n}\n\n/**\n * Ranks stack-field values (e.g. cities, providers) by their total contribution to the\n * primary series across all categories, and returns only the requested `pageSize`-sized page\n * of them, highest-total first. Without this, a high-cardinality stack field turns into one\n * series per value and the chart becomes an unreadable crunch of overlapping bars. Paging\n * (rather than a hard cap) keeps every value reachable — see PvDataTableWithChart's\n * stackValuesPageSize prop and page navigation. The returned `orderedLabels` must drive the\n * actual render order (not just which values are kept) or \"sort by highest cost\" only holds\n * for the page cutoff, not what the user sees rendered.\n *\n * Ranking only happens when paging is actually enabled (a positive `pageSize`). Without it,\n * every existing multi-group chart — even ones well under any reasonable cap — would get a\n * different render order than before, which is a visible change nobody opted into. With\n * `pageSize` falsy (paging off, the default), this returns stack values in their original\n * encounter order, unchanged from before this feature existed.\n */\nconst paginateStackValuesByTotal = (\n  data: AgChartOptions[\"data\"],\n  stackField: string,\n  primaryField: string | undefined,\n  pageSize: number | undefined,\n  pageIndex: number,\n): StackValuesPage => {\n  if (!data) {\n    return { data: [], total: 0, pageCount: 1, pageIndex: 0, orderedLabels: [] };\n  }\n  // Paging is off by default: no ranking pass or sort when disabled\n  if (!pageSize || pageSize <= 0) {\n    const encounterOrderLabels: string[] = [];\n    const seenLabels = new Set<string>();\n    data.forEach((row) => {\n      const label = String(row[stackField] ?? \"\");\n      if (!seenLabels.has(label)) {\n        seenLabels.add(label);\n        encounterOrderLabels.push(label);\n      }\n    });\n    return {\n      data,\n      total: encounterOrderLabels.length,\n      pageCount: 1,\n      pageIndex: 0,\n      orderedLabels: encounterOrderLabels,\n    };\n  }\n  const totalsByStackValue = new Map<string, number>();\n  data.forEach((row) => {\n    const label = String(row[stackField] ?? \"\");\n    const rawValue = primaryField ? row[primaryField] : undefined;\n    const value = typeof rawValue === \"number\" ? rawValue : 0;\n    totalsByStackValue.set(label, (totalsByStackValue.get(label) ?? 0) + value);\n  });\n  const total = totalsByStackValue.size;\n  const sortedLabels = Array.from(totalsByStackValue.entries())\n    .sort((a, b) => b[1] - a[1])\n    .map(([label]) => label);\n  if (total <= pageSize) {\n    return { data, total, pageCount: 1, pageIndex: 0, orderedLabels: sortedLabels };\n  }\n  const pageCount = Math.ceil(total / pageSize);\n  const clampedPageIndex = Math.min(Math.max(pageIndex, 0), pageCount - 1);\n  const orderedLabels = sortedLabels.slice(clampedPageIndex * pageSize, (clampedPageIndex + 1) * pageSize);\n  const pageLabels = new Set(orderedLabels);\n  return {\n    data: data.filter((row) => pageLabels.has(String(row[stackField] ?? \"\"))),\n    total,\n    pageCount,\n    pageIndex: clampedPageIndex,\n    orderedLabels,\n  };\n};\n\n/**\n * Same idea as paginateStackValuesByTotal, but for the client-side grouping path: rows are\n * already pivoted one-per-category (each stack value lives in its own `field_stackValue`\n * sub-key via generateStackSeriesKey — see getStackedChartDataFromRowNodes), rather than one\n * row per raw record. Ranks stack values by total contribution to the primary series across\n * all category rows, keeps only the requested page, and recomputes each series' `_sort_total`\n * to reflect only the kept values (so axis scaling and label-suppression thresholds match what\n * actually renders — otherwise they'd stay based on every value, page or no page).\n *\n * Ranking (and the `_sort_total` recompute) only happens when paging is actually enabled (a\n * positive `pageSize`) — see paginateStackValuesByTotal for why that matters. With `pageSize`\n * falsy (paging off, the default), `fieldValues` and each row's existing sort totals pass\n * through unchanged.\n */\nexport const paginatePivotedStackValuesByTotal = (\n  rows: AgChartOptions[\"data\"],\n  fieldValues: string[],\n  seriesColumns: OptionWithFormatterAndDataType[],\n  primaryField: string | undefined,\n  pageSize: number | undefined,\n  pageIndex: number,\n): StackValuesPage => {\n  const total = fieldValues.length;\n  if (!rows || total === 0) {\n    return { data: rows ?? [], total: 0, pageCount: 1, pageIndex: 0, orderedLabels: [] };\n  }\n  if (!pageSize || pageSize <= 0) {\n    return { data: rows, total, pageCount: 1, pageIndex: 0, orderedLabels: fieldValues };\n  }\n  const totalsByLabel = new Map<string, number>();\n  fieldValues.forEach((label) => {\n    let sum = 0;\n    if (primaryField) {\n      const seriesKey = generateStackSeriesKey(primaryField, label);\n      rows.forEach((row) => {\n        const value = row[seriesKey];\n        if (typeof value === \"number\") sum += value;\n      });\n    }\n    totalsByLabel.set(label, sum);\n  });\n  const sortedLabels = Array.from(totalsByLabel.entries())\n    .sort((a, b) => b[1] - a[1])\n    .map(([label]) => label);\n\n  const recomputeSortTotals = (orderedLabels: string[]) =>\n    rows.map((row) => {\n      const newRow = { ...row };\n      seriesColumns.forEach((field) => {\n        let sortTotal = 0;\n        orderedLabels.forEach((label) => {\n          const value = row[generateStackSeriesKey(field.value, label)];\n          if (typeof value === \"number\") sortTotal += value;\n        });\n        newRow[`${field.value}${sortTotalSuffix}`] = sortTotal;\n      });\n      return newRow;\n    });\n\n  if (total <= pageSize) {\n    return { data: recomputeSortTotals(sortedLabels), total, pageCount: 1, pageIndex: 0, orderedLabels: sortedLabels };\n  }\n  const pageCount = Math.ceil(total / pageSize);\n  const clampedPageIndex = Math.min(Math.max(pageIndex, 0), pageCount - 1);\n  const orderedLabels = sortedLabels.slice(clampedPageIndex * pageSize, (clampedPageIndex + 1) * pageSize);\n  return {\n    data: recomputeSortTotals(orderedLabels),\n    total,\n    pageCount,\n    pageIndex: clampedPageIndex,\n    orderedLabels,\n  };\n};\n\nexport const buildStackedChartData = (\n  data: AgChartOptions[\"data\"],\n  categoryField: string,\n  stackField: string,\n  seriesColumns: OptionWithFormatterAndDataType[],\n  supplementaryChartingColumns: OptionWithFormatterAndDataType[] = [],\n  primarySeriesField?: string,\n  stackValuesPageSize?: number,\n  stackValuesPageIndex: number = 0,\n) => {\n  if (!data || data.length === 0) {\n    return {\n      data: [],\n      uniqueFieldValues: [],\n      totalStackValueCount: 0,\n      stackValuesPageCount: 1,\n      stackValuesPageIndex: 0,\n    };\n  }\n  const page = paginateStackValuesByTotal(\n    data,\n    stackField,\n    primarySeriesField,\n    stackValuesPageSize,\n    stackValuesPageIndex,\n  );\n  const pagedData = page.data ?? [];\n  const groupedData = pagedData.reduce(\n    (acc, row) => {\n      const categoryFieldValue = row[categoryField];\n      if (!acc[categoryFieldValue]) {\n        acc[categoryFieldValue] = {};\n      }\n      // Must match the same normalization paginateStackValuesByTotal uses to build\n      // orderedLabels — otherwise a null/undefined stack value produces a \"rate_null\" key\n      // here but an empty-string \"rate_\" key there, and the series can't find its data.\n      const stackFieldLabel = String(row[stackField] ?? \"\");\n      const secondaryCategoryKey = generateStackSecondaryCategoryKey(stackFieldLabel);\n      acc[categoryFieldValue][secondaryCategoryKey] = `${categoryFieldValue}-${stackFieldLabel}`;\n      for (const field of seriesColumns) {\n        const fieldValue = field.value;\n        let sortTotal = 0;\n        if (categoryFieldValue in acc && `${fieldValue}_sort_total` in acc[categoryFieldValue]) {\n          sortTotal = acc[categoryFieldValue][`${fieldValue}_sort_total`] as number;\n        }\n        const stackFieldSeriesValue = row[fieldValue];\n        if (stackField && stackFieldSeriesValue) {\n          const value = stackFieldSeriesValue ?? 0;\n          acc[categoryFieldValue][generateStackSeriesKey(fieldValue, stackFieldLabel)] = value;\n          sortTotal = sortTotal + value;\n        }\n        acc[categoryFieldValue][`${fieldValue}${sortTotalSuffix}`] = sortTotal;\n      }\n      // Right now, our only use case of this is the total codes data which we make available in the chart data\n      // for use in the metric overlay tooltip.\n      for (const field of supplementaryChartingColumns) {\n        acc[categoryFieldValue][field.value] = row[field.value];\n      }\n      return acc;\n    },\n    {} as Record<string, AgChartOptions[\"data\"]>,\n  );\n  const stackedData = Object.keys(groupedData).map((key) => {\n    return {\n      [categoryField]: key,\n      ...groupedData[key],\n    };\n  });\n  return {\n    stackedData,\n    // Ranked order, not just selection — see paginateStackValuesByTotal's orderedLabels.\n    uniqueFieldValues: page.orderedLabels,\n    totalStackValueCount: page.total,\n    stackValuesPageCount: page.pageCount,\n    stackValuesPageIndex: page.pageIndex,\n  };\n};\n\n/**\n * A lone bar in a category (\"bar\"-type) chart would otherwise stretch full-width.\n * Flank the single row with two sentinel blank categories so it renders at a\n * natural width instead.\n *\n * The sentinels are dedicated values that can never equal a real category. This\n * matters when the single real category is itself blank (a \"(Blanks)\" group,\n * whose key is \"\"): a naive \"\" pad would collide with the real category, and the\n * pad's transparent, valueless bar would overwrite the real one - rendering it\n * invisible. Both sentinels are hidden by the category-axis label formatter and\n * filtered out of map/scatter data.\n */\nexport const padSingleCategoryBarData = (\n  data: AgChartOptions[\"data\"],\n  categoryField: string,\n): AgChartOptions[\"data\"] => {\n  if (!data || data.length !== 1) {\n    return data;\n  }\n  return [{ [categoryField]: padStartValue }, data[0], { [categoryField]: padEndValue }];\n};\n\n// track the largest value on the chart, useful for determining scale of bars relative to the current axis\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const calculateMaxChartSeriesValue = (data: any[] | undefined, seriesField: string, isStacked: boolean) => {\n  let max = -Infinity;\n  if (!data || data.length === 0) {\n    return max;\n  }\n  if (!isStacked) {\n    data.forEach((item) => {\n      const value = item[seriesField];\n      if (typeof value === \"number\" && value > max) {\n        max = value;\n      }\n    });\n  } else {\n    data.forEach((item) => {\n      const sortTotalField = seriesField + sortTotalSuffix;\n      const value = item[sortTotalField];\n      if (typeof value === \"number\" && value > max) {\n        max = value;\n      }\n    });\n  }\n  return max;\n};\n\n// track the smallest value on the chart — used to detect negative data, which\n// means the two y-axes can't share a zero-based grid (see niceAxisCeiling usage)\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const calculateMinChartSeriesValue = (data: any[] | undefined, seriesField: string, isStacked: boolean) => {\n  let min = Infinity;\n  if (!data || data.length === 0) {\n    return min;\n  }\n  const field = isStacked ? seriesField + sortTotalSuffix : seriesField;\n  data.forEach((item) => {\n    const value = item[field];\n    if (typeof value === \"number\" && value < min) {\n      min = value;\n    }\n  });\n  return min;\n};\n\n/**\n * Builds the category axis's label formatter. Exactly one of three behaviors applies:\n * - `hideLabel`: every label is blank (e.g. a chart type that doesn't show x-axis labels).\n * - `showDistributionRangeLabels`: only the two blank pad categories flanking a histogram's\n *   real buckets are labeled, with the overall lowest min / highest max bucket boundary;\n *   every other category (including the real buckets themselves) is blank.\n * - Otherwise: normal category labels, formatted via `columnValueFormatter`, with the\n *   separator/single-bar-padding sentinel categories hidden, a focus suffix appended, and\n *   the result truncated to `MAX_LABEL_LENGTH`.\n */\nexport const buildCategoryAxisLabelFormatter = ({\n  hideLabel,\n  showDistributionRangeLabels,\n  chartData,\n  formatBucketBoundary,\n  columnValueFormatter,\n  enableFocusView,\n  focuses,\n  focusText,\n}: {\n  hideLabel: boolean;\n  showDistributionRangeLabels: boolean;\n  chartData: AgChartOptions[\"data\"];\n  formatBucketBoundary: (value: number) => string;\n  columnValueFormatter: Formatter<AgAxisLabelFormatterParams> | undefined;\n  enableFocusView: boolean;\n  focuses: string[];\n  focusText: string;\n}): ((params: AgAxisLabelFormatterParams) => string) => {\n  if (hideLabel) {\n    return () => \"\";\n  }\n\n  if (showDistributionRangeLabels) {\n    return (params: AgAxisLabelFormatterParams) => {\n      if (!chartData || chartData.length === 0) {\n        return \"\";\n      }\n      if (params.value === distributionRangeMinCategory) {\n        return formatBucketBoundary(chartData[0].bucketMin);\n      }\n      if (params.value === distributionRangeMaxCategory) {\n        return formatBucketBoundary(chartData[chartData.length - 1].bucketMax);\n      }\n      return \"\";\n    };\n  }\n\n  return (params: AgAxisLabelFormatterParams) => {\n    // Hide the label for the separator and single-bar padding sentinels\n    if (params.value === separatorValue || params.value === padStartValue || params.value === padEndValue) {\n      return \"\";\n    }\n\n    let valueToDisplay = params.value; // Start with the raw value from AG Charts\n\n    if (typeof columnValueFormatter === \"function\") {\n      valueToDisplay = columnValueFormatter(params);\n    }\n\n    // Append focus/incumbent label if this item is in the focuses list\n    const focusSuffix = enableFocusView && focuses.includes(params.value) ? ` (${focusText})` : \"\";\n\n    // Apply truncation to the (potentially formatted) string, reserving space for the focus suffix\n    if (\n      typeof valueToDisplay === \"string\" &&\n      valueToDisplay.length + focusSuffix.length > MAX_LABEL_LENGTH &&\n      !(params.context as LabelFormatterContext)?.tooltip\n    ) {\n      const maxNameLength = MAX_LABEL_LENGTH - focusSuffix.length - 3; // 3 for \"...\"\n      return valueToDisplay.substring(0, maxNameLength) + \"...\" + focusSuffix;\n    }\n\n    return valueToDisplay + focusSuffix;\n  };\n};\n","import type { PvSegmentedControlOption } from \"@/components/base/PvSegmentedControl/types\";\nimport { generateStackSeriesKey } from \"@charts/PvDataTableWithChart/helpers\";\nimport { applyChartWidgetOptions, asObjectRecord } from \"@charts/widgetOptions\";\nimport type { AgChartOptions } from \"ag-charts-types\";\nimport {\n  DEFAULT_CHART_TYPE_OPTIONS,\n  DEFAULT_ENABLED_CHART_TYPES,\n  DEFAULT_FALLBACK_CHART_TYPE,\n  DEFAULT_MAP_REGION_FIELD,\n  NUMERIC_DATA_TYPES,\n  TABLE_VIEW_TYPE,\n} from \"./constants\";\nimport type {\n  PvDataWidgetChartTypeOption,\n  PvDataWidgetColumnDefinition,\n  PvDataWidgetDataRow,\n  PvDataWidgetViewType,\n} from \"./types\";\n\ntype ChartRecord = Record<string, unknown>;\n\nexport interface DataWidgetChartOptionConfig {\n  dataLimit?: number;\n  hideAxes?: boolean;\n  hideAxisTitles?: boolean;\n  hideLegend?: boolean;\n  hideValueAxis?: boolean;\n  noDataOverlayText?: string;\n}\n\nexport interface PvDataWidgetStackedChartData {\n  data: PvDataWidgetDataRow[];\n  stackValues: string[];\n}\n\nexport interface GenerateDataWidgetChartOptionsParams extends DataWidgetChartOptionConfig {\n  aggregatedCategoryChartData: PvDataWidgetDataRow[];\n  categoryColumn?: PvDataWidgetColumnDefinition;\n  displayDataRows: PvDataWidgetDataRow[];\n  numericColumns: PvDataWidgetColumnDefinition[];\n  providedChartOptions?: AgChartOptions;\n  secondarySeriesColumn?: PvDataWidgetColumnDefinition;\n  selectedChartType: PvDataWidgetViewType;\n  seriesColumn?: PvDataWidgetColumnDefinition;\n  showSeriesLabels?: boolean;\n  stackColumn?: PvDataWidgetColumnDefinition;\n  stackedChartData: PvDataWidgetStackedChartData;\n  /** Use the widget-resolved rows instead of providedChartOptions.data. */\n  useDisplayDataRows?: boolean;\n  xKey?: string;\n  yKey?: string;\n}\n\nconst optionByValue = new Map(DEFAULT_CHART_TYPE_OPTIONS.map((option) => [option.value, option]));\n\nconst isSegmentedControlOption = (option: PvSegmentedControlOption | null): option is PvSegmentedControlOption => {\n  return option !== null;\n};\n\nconst getSafeNumber = (value: unknown) => {\n  const numericValue = Number(value ?? 0);\n\n  return Number.isFinite(numericValue) ? numericValue : 0;\n};\n\nexport const normalizeChartTypeOption = (\n  option: PvDataWidgetViewType | PvDataWidgetChartTypeOption,\n): PvSegmentedControlOption | null => {\n  const resolved = typeof option === \"string\" ? { value: option } : option;\n  const value = resolved.value;\n  if (!value) return null;\n\n  const fallback = optionByValue.get(value);\n  const label = resolved.label ?? fallback?.label ?? value;\n\n  return {\n    ariaLabel: resolved.ariaLabel ?? label,\n    icon: resolved.icon ?? fallback?.icon,\n    iconPosition: \"left\",\n    label,\n    value,\n  };\n};\n\nexport const buildChartTypeOptions = (\n  chartTypes: (PvDataWidgetViewType | PvDataWidgetChartTypeOption)[] = [],\n  optionsConfig: { useDefaultChartTypesWhenEmpty?: boolean } = {},\n): PvSegmentedControlOption[] => {\n  const useDefaultChartTypesWhenEmpty = optionsConfig.useDefaultChartTypesWhenEmpty ?? true;\n  const definedChartTypes =\n    chartTypes.length > 0 || !useDefaultChartTypesWhenEmpty ? chartTypes : DEFAULT_ENABLED_CHART_TYPES;\n  let options = definedChartTypes.map(normalizeChartTypeOption).filter(isSegmentedControlOption);\n\n  // The widget is always chart-driven: guarantee at least one non-table chart type.\n  if (!options.some((option) => option.value !== TABLE_VIEW_TYPE)) {\n    const fallbackChartOption = normalizeChartTypeOption(DEFAULT_FALLBACK_CHART_TYPE);\n    if (fallbackChartOption) options = [fallbackChartOption, ...options];\n  }\n\n  // \"Custom\" chart types are option objects (which carry explicit labels/icons);\n  // bare string entries stay eligible for the generic single-type \"Chart\" label.\n  const hasCustomChartTypes = chartTypes.some((type) => type !== null && typeof type === \"object\");\n\n  // With a single chart type and no custom labels, present it generically as \"Chart\".\n  if (!hasCustomChartTypes) {\n    const chartOnlyOptions = options.filter((option) => option.value !== TABLE_VIEW_TYPE);\n    if (chartOnlyOptions.length === 1) {\n      const soleChartTypeValue = chartOnlyOptions[0]?.value;\n      options = options.map((option) =>\n        option.value === soleChartTypeValue ? { ...option, ariaLabel: \"Chart\", label: \"Chart\" } : option,\n      );\n    }\n  }\n\n  return options;\n};\n\nexport const getSelectedChartType = (\n  requestedChartType: PvDataWidgetViewType | undefined,\n  chartTypeOptions: PvSegmentedControlOption[],\n): PvDataWidgetViewType => {\n  const requestedOption = chartTypeOptions.find((option) => option.value === requestedChartType);\n\n  return (requestedOption?.value ?? chartTypeOptions[0]?.value ?? TABLE_VIEW_TYPE) as PvDataWidgetViewType;\n};\n\nexport const getInferredColumns = (\n  dataRows: PvDataWidgetDataRow[],\n  colDefs: PvDataWidgetColumnDefinition[] = [],\n): PvDataWidgetColumnDefinition[] => {\n  if (colDefs.length > 0) {\n    return colDefs.filter((column) => !column.hide);\n  }\n\n  const firstRow = dataRows[0];\n  if (!firstRow) return [];\n\n  return Object.keys(firstRow).map((field) => ({\n    field,\n    headerName: field,\n  }));\n};\n\nexport const getColumnLabel = (column: PvDataWidgetColumnDefinition | undefined, fallback = \"\") => {\n  return column?.context?.chartSeriesDisplayName ?? column?.headerName ?? column?.field ?? fallback;\n};\n\nexport const getColumnDataType = (column: PvDataWidgetColumnDefinition | undefined) => {\n  return String(column?.context?.dataType ?? column?.dataType ?? column?.type ?? \"\").toLowerCase();\n};\n\nexport const getIsNumericColumn = (\n  column: PvDataWidgetColumnDefinition | undefined,\n  dataRows: PvDataWidgetDataRow[],\n) => {\n  if (!column) return false;\n  const dataType = getColumnDataType(column);\n  if (NUMERIC_DATA_TYPES.has(dataType)) return true;\n\n  return dataRows.some((row) => typeof row[column.field] === \"number\");\n};\n\nexport const getTableCellValue = (row: PvDataWidgetDataRow, field: string) => {\n  const value = row[field];\n\n  return value == null ? \"\" : String(value);\n};\n\nexport const applyDataWidgetChartOptions = (\n  options: AgChartOptions,\n  config: DataWidgetChartOptionConfig,\n): AgChartOptions => {\n  const configurableOptions = options as ChartRecord;\n  const output = { ...configurableOptions };\n\n  if (config.noDataOverlayText) {\n    const overlays = asObjectRecord(configurableOptions.overlays);\n    const noData = asObjectRecord(overlays?.noData);\n\n    output.overlays = {\n      ...overlays,\n      noData: {\n        ...noData,\n        text: config.noDataOverlayText,\n      },\n    };\n  }\n\n  if (config.hideLegend) {\n    output.legend = {\n      ...asObjectRecord(configurableOptions.legend),\n      enabled: false,\n    };\n  }\n\n  return applyChartWidgetOptions(output as unknown as AgChartOptions, {\n    dataLimit: config.dataLimit,\n    hideAxisTitles: config.hideAxisTitles,\n    hideValueAxis: config.hideValueAxis,\n    showAxes: !config.hideAxes,\n  });\n};\n\nexport const getStackedChartData = ({\n  dataRows,\n  categoryColumn,\n  seriesColumn,\n  stackColumn,\n}: {\n  dataRows: PvDataWidgetDataRow[];\n  categoryColumn?: PvDataWidgetColumnDefinition;\n  seriesColumn?: PvDataWidgetColumnDefinition;\n  stackColumn?: PvDataWidgetColumnDefinition;\n}): PvDataWidgetStackedChartData => {\n  if (!categoryColumn || !seriesColumn || !stackColumn) {\n    return {\n      data: dataRows,\n      stackValues: [],\n    };\n  }\n\n  const groupedRows = new Map<string, PvDataWidgetDataRow>();\n  const stackValues = new Set<string>();\n\n  dataRows.forEach((row) => {\n    const categoryValue = String(row[categoryColumn.field] ?? \"\");\n    const stackValue = String(row[stackColumn.field] ?? \"\");\n    const stackSeriesKey = generateStackSeriesKey(seriesColumn.field, stackValue);\n\n    stackValues.add(stackValue);\n\n    const groupedRow = groupedRows.get(categoryValue) ?? { [categoryColumn.field]: categoryValue };\n    groupedRow[stackSeriesKey] = Number(groupedRow[stackSeriesKey] ?? 0) + getSafeNumber(row[seriesColumn.field]);\n    groupedRows.set(categoryValue, groupedRow);\n  });\n\n  return {\n    data: Array.from(groupedRows.values()),\n    stackValues: Array.from(stackValues),\n  };\n};\n\nexport const getAggregatedCategoryChartData = ({\n  dataRows,\n  categoryColumn,\n  seriesColumn,\n}: {\n  dataRows: PvDataWidgetDataRow[];\n  categoryColumn?: PvDataWidgetColumnDefinition;\n  seriesColumn?: PvDataWidgetColumnDefinition;\n}) => {\n  if (!categoryColumn || !seriesColumn) return dataRows;\n\n  const groupedRows = new Map<string, PvDataWidgetDataRow>();\n\n  dataRows.forEach((row) => {\n    const categoryValue = row[categoryColumn.field] ?? \"\";\n    const categoryKey = String(categoryValue);\n    const safeNumericValue = getSafeNumber(row[seriesColumn.field]);\n    const groupedRow = groupedRows.get(categoryKey);\n\n    if (groupedRow) {\n      groupedRow[seriesColumn.field] = Number(groupedRow[seriesColumn.field] ?? 0) + safeNumericValue;\n      return;\n    }\n\n    groupedRows.set(categoryKey, {\n      ...row,\n      [categoryColumn.field]: categoryValue,\n      [seriesColumn.field]: safeNumericValue,\n    });\n  });\n\n  return Array.from(groupedRows.values());\n};\n\n// PvMapChart expects each region under the `state` key, so regions are remapped to\n// `state` here regardless of the source column (`mapKey`/`mapColumn.field`).\nexport const getMapChartData = ({\n  dataRows,\n  mapColumn,\n  seriesColumn,\n}: {\n  dataRows: PvDataWidgetDataRow[];\n  mapColumn?: PvDataWidgetColumnDefinition;\n  seriesColumn?: PvDataWidgetColumnDefinition;\n}) => {\n  if (!mapColumn || !seriesColumn) return [];\n\n  const groupedRows = new Map<string, PvDataWidgetDataRow>();\n\n  dataRows.forEach((row) => {\n    const region = String(row[mapColumn.field] ?? \"\");\n    if (!region) return;\n\n    const groupedRow = groupedRows.get(region) ?? { [DEFAULT_MAP_REGION_FIELD]: region };\n    groupedRow[seriesColumn.field] =\n      Number(groupedRow[seriesColumn.field] ?? 0) + getSafeNumber(row[seriesColumn.field]);\n    groupedRows.set(region, groupedRow);\n  });\n\n  return Array.from(groupedRows.values()) as Record<string, string | number>[];\n};\n\nexport const getMapGradientRange = (mapData: Record<string, string | number>[], seriesField: string | undefined) => {\n  if (!seriesField || mapData.length === 0) return { min: 0, max: 0 };\n\n  let hasValue = false;\n  let min = Infinity;\n  let max = -Infinity;\n\n  mapData.forEach((row) => {\n    const value = Number(row[seriesField]);\n    if (!Number.isFinite(value)) return;\n\n    hasValue = true;\n    min = Math.min(min, value);\n    max = Math.max(max, value);\n  });\n\n  return hasValue ? { min, max } : { min: 0, max: 0 };\n};\n\nexport const getMapSeriesValueFormatter = (seriesColumn: PvDataWidgetColumnDefinition | undefined) => {\n  const dataType = getColumnDataType(seriesColumn);\n\n  if (dataType === \"currency\") {\n    return (value: number) =>\n      value.toLocaleString(\"en-US\", {\n        currency: \"USD\",\n        maximumFractionDigits: 0,\n        style: \"currency\",\n      });\n  }\n\n  if (dataType === \"percent\" || dataType === \"percentage\") {\n    return (value: number) =>\n      value.toLocaleString(\"en-US\", {\n        maximumFractionDigits: 0,\n        style: \"percent\",\n      });\n  }\n\n  return (value: number) => value.toLocaleString(\"en-US\");\n};\n\nexport const generateDataWidgetChartOptions = ({\n  aggregatedCategoryChartData,\n  categoryColumn,\n  dataLimit,\n  displayDataRows,\n  hideAxes,\n  hideAxisTitles,\n  hideLegend,\n  hideValueAxis,\n  noDataOverlayText,\n  numericColumns,\n  providedChartOptions,\n  secondarySeriesColumn,\n  selectedChartType,\n  seriesColumn,\n  showSeriesLabels,\n  stackColumn,\n  stackedChartData,\n  useDisplayDataRows,\n  xKey: explicitXKey,\n  yKey: explicitYKey,\n}: GenerateDataWidgetChartOptionsParams): AgChartOptions => {\n  const commonConfig = {\n    dataLimit,\n    hideAxes,\n    hideAxisTitles,\n    hideLegend,\n    hideValueAxis,\n    noDataOverlayText,\n  };\n\n  if (providedChartOptions) {\n    return applyDataWidgetChartOptions(\n      {\n        ...providedChartOptions,\n        data: useDisplayDataRows ? displayDataRows : (providedChartOptions.data ?? displayDataRows),\n      } as AgChartOptions,\n      commonConfig,\n    );\n  }\n\n  const activeType = selectedChartType === \"map\" ? \"column\" : selectedChartType;\n  const xKey = categoryColumn?.field ?? \"category\";\n  const yKey = seriesColumn?.field ?? \"value\";\n  const xName = getColumnLabel(categoryColumn, xKey);\n  const yName = getColumnLabel(seriesColumn, yKey);\n\n  if (activeType === \"pie\") {\n    return applyDataWidgetChartOptions(\n      {\n        data: aggregatedCategoryChartData,\n        series: [\n          {\n            type: \"pie\",\n            angleKey: yKey,\n            angleName: yName,\n            calloutLabelKey: xKey,\n            calloutLabelName: xName,\n          },\n        ],\n      } as AgChartOptions,\n      commonConfig,\n    );\n  }\n\n  if (activeType === \"scatter\") {\n    const scatterXColumn = explicitXKey !== undefined ? categoryColumn : (numericColumns[0] ?? categoryColumn);\n    const scatterYColumn =\n      explicitYKey !== undefined\n        ? seriesColumn\n        : (numericColumns.find((column) => column.field !== scatterXColumn?.field) ??\n          secondarySeriesColumn ??\n          seriesColumn);\n    const scatterXKey = scatterXColumn?.field ?? xKey;\n    const scatterYKey = scatterYColumn?.field ?? yKey;\n\n    return applyDataWidgetChartOptions(\n      {\n        data: displayDataRows,\n        series: [\n          {\n            type: \"scatter\",\n            xKey: scatterXKey,\n            xName: getColumnLabel(scatterXColumn, scatterXKey),\n            yKey: scatterYKey,\n            yName: getColumnLabel(scatterYColumn, scatterYKey),\n          },\n        ],\n        axes: [\n          { type: \"number\", position: \"bottom\", title: { text: getColumnLabel(scatterXColumn, scatterXKey) } },\n          { type: \"number\", position: \"left\", title: { text: getColumnLabel(scatterYColumn, scatterYKey) } },\n        ],\n      } as AgChartOptions,\n      commonConfig,\n    );\n  }\n\n  if (activeType === \"histogram\") {\n    const histogramColumn =\n      explicitXKey !== undefined ? categoryColumn : (numericColumns[0] ?? seriesColumn ?? categoryColumn);\n    const histogramKey = histogramColumn?.field ?? yKey;\n\n    return applyDataWidgetChartOptions(\n      {\n        data: displayDataRows,\n        series: [\n          {\n            type: \"histogram\",\n            xKey: histogramKey,\n            xName: getColumnLabel(histogramColumn, histogramKey),\n          },\n        ],\n      } as AgChartOptions,\n      commonConfig,\n    );\n  }\n\n  const baseType = activeType.replace(\"_stacked\", \"\");\n  const primarySeriesType = baseType === \"line\" || baseType === \"area\" ? baseType : \"bar\";\n  const isHorizontal = baseType === \"bar\";\n  // Bar/column labels default to `inside-end`; place them outside the bar end (above for columns).\n  const seriesLabel = showSeriesLabels\n    ? { label: { enabled: true, ...(primarySeriesType === \"bar\" ? { placement: \"outside-end\" } : {}) } }\n    : {};\n  const isStacked = activeType.endsWith(\"_stacked\") && Boolean(stackColumn);\n  const shouldSplitByStack = Boolean(stackColumn) && (isStacked || stackedChartData.stackValues.length > 1);\n  const data = shouldSplitByStack ? stackedChartData.data : aggregatedCategoryChartData;\n\n  const series = shouldSplitByStack\n    ? stackedChartData.stackValues.map((stackValue) => ({\n        type: primarySeriesType,\n        xKey,\n        xName,\n        yKey: generateStackSeriesKey(yKey, stackValue),\n        yName: stackValue,\n        ...(primarySeriesType === \"bar\" ? { direction: isHorizontal ? \"horizontal\" : \"vertical\" } : {}),\n        ...(isStacked ? { stacked: true } : {}),\n        ...seriesLabel,\n      }))\n    : [\n        {\n          type: primarySeriesType,\n          xKey,\n          xName,\n          yKey,\n          yName,\n          ...(primarySeriesType === \"bar\" ? { direction: isHorizontal ? \"horizontal\" : \"vertical\" } : {}),\n          ...seriesLabel,\n        },\n      ];\n\n  return applyDataWidgetChartOptions(\n    {\n      data,\n      series,\n      axes: [\n        { type: \"category\", position: isHorizontal ? \"left\" : \"bottom\", title: { text: xName } },\n        { type: \"number\", position: isHorizontal ? \"bottom\" : \"left\", title: { text: yName } },\n      ],\n    } as AgChartOptions,\n    commonConfig,\n  );\n};\n","<script setup lang=\"ts\">\nimport { computed, ref } from \"vue\";\nimport PvCard from \"@/components/base/PvCard/PvCard.vue\";\nimport PvSegmentedControl from \"@/components/base/PvSegmentedControl/PvSegmentedControl.vue\";\nimport PvSpinner from \"@/components/base/PvSpinner/PvSpinner.vue\";\nimport PvChart from \"@charts/PvChart/PvChart.vue\";\nimport PvMapChart from \"@charts/PvMapChart/PvMapChart.vue\";\nimport PvDataWidgetTable from \"./PvDataWidgetTable.vue\";\nimport {\n  buildWidgetStyle,\n  getChartDataLength,\n  getChartScrollContentStyle,\n  getChartScrollOverflowStyle,\n  getCssSize,\n  getIsHorizontalBarChart,\n  getIsWidgetConstrained,\n  getScrollableChartMinHeight,\n  limitDataRows,\n} from \"@charts/widgetOptions\";\nimport {\n  CHART_SCROLL_MIN_WIDTH_PX,\n  DEFAULT_LOADING_TEXT,\n  DEFAULT_MAP_REGION_FIELD,\n  DEFAULT_MIN_HEIGHT_PX,\n  LOADING_THUMBNAIL_BAR_HEIGHTS_PX,\n  TABLE_VIEW_TYPE,\n} from \"./constants\";\nimport {\n  buildChartTypeOptions,\n  generateDataWidgetChartOptions,\n  getAggregatedCategoryChartData,\n  getColumnDataType,\n  getColumnLabel,\n  getInferredColumns,\n  getIsNumericColumn,\n  getMapChartData,\n  getMapGradientRange,\n  getMapSeriesValueFormatter,\n  getSelectedChartType,\n  getStackedChartData,\n  getTableCellValue,\n} from \"./helpers\";\nimport type {\n  PvDataWidgetChartTypeOption,\n  PvDataWidgetColumnDefinition,\n  PvDataWidgetDataRow,\n  PvDataWidgetProps,\n  PvDataWidgetViewType,\n} from \"./types\";\nimport type { AgChartOptions } from \"ag-charts-types\";\n\nconst props = withDefaults(defineProps<PvDataWidgetProps>(), {\n  appliedFilters: () => [],\n  chartLoading: false,\n  chartTypes: () => [],\n  colDefs: () => [],\n  enableChartScrolling: false,\n  enableTableScrolling: false,\n  hideAxes: false,\n  hideAxisTitles: false,\n  hideLegend: false,\n  hideValueAxis: false,\n  loading: false,\n  loadingText: DEFAULT_LOADING_TEXT,\n  minHeight: DEFAULT_MIN_HEIGHT_PX,\n  showSeriesLabels: false,\n  showTableBelowChart: false,\n  showWidgetTypeToggle: true,\n});\n\n/** Selected chart/view type. Bind `v-model:chartType` for controlled selection. */\nconst chartType = defineModel<PvDataWidgetViewType>(\"chartType\");\n\nconst getProvidedChartDataRows = (chartOptions: AgChartOptions | undefined): PvDataWidgetDataRow[] => {\n  const chartOptionData = chartOptions?.data;\n\n  return Array.isArray(chartOptionData) ? (chartOptionData as PvDataWidgetDataRow[]) : [];\n};\n\nconst isMapChartType = (chartType: PvDataWidgetViewType | PvDataWidgetChartTypeOption) => {\n  return typeof chartType === \"string\" ? chartType === \"map\" : chartType.value === \"map\";\n};\n\n// The map view is only offered when the state/region column is the active x-axis\n// (category). When it isn't, remove the map type before building options so the\n// helper can preserve its guarantee that widgets always have a non-table chart\n// fallback (e.g. `chartTypes: [\"map\", \"table\"]` becomes `[\"column\", \"table\"]`).\nconst chartTypeOptions = computed(() => {\n  const availableChartTypes = stateIsOnXAxis.value\n    ? props.chartTypes\n    : props.chartTypes.filter((type) => !isMapChartType(type));\n\n  return buildChartTypeOptions(availableChartTypes, {\n    useDefaultChartTypesWhenEmpty: props.chartTypes.length === 0,\n  });\n});\n\nconst selectedChartType = computed({\n  get: () => getSelectedChartType(chartType.value, chartTypeOptions.value),\n  set: (value: string) => {\n    chartType.value = value;\n  },\n});\n\nconst showChartTypeToggle = computed(() => props.showWidgetTypeToggle && chartTypeOptions.value.length > 1);\nconst showHeader = computed(() => Boolean(props.title) || showChartTypeToggle.value);\nconst hasAppliedFilters = computed(() => props.appliedFilters.length > 0);\n\n// Fall back to chartOptions.data when chartData is omitted, but keep an explicitly\n// supplied empty chartData array as an intentional override.\nconst dataRows = computed<PvDataWidgetDataRow[]>(() => {\n  if (props.chartData !== undefined) {\n    return props.chartData ?? [];\n  }\n\n  return getProvidedChartDataRows(props.chartOptions);\n});\nconst displayDataRows = computed(() => limitDataRows(dataRows.value, props.dataLimit));\n\nconst inferredColumns = computed<PvDataWidgetColumnDefinition[]>(() =>\n  getInferredColumns(dataRows.value, props.colDefs),\n);\n\nconst isNumericColumn = (column: PvDataWidgetColumnDefinition | undefined) => {\n  return getIsNumericColumn(column, dataRows.value);\n};\n\nconst chartableColumns = computed(() => {\n  return inferredColumns.value.filter((column) => !column.context?.hideFromCharting);\n});\n\nconst numericColumns = computed(() => chartableColumns.value.filter(isNumericColumn));\n\nconst categoryColumn = computed(() => {\n  if (props.xKey !== undefined) {\n    const xKey = props.xKey;\n    return chartableColumns.value.find((column) => column.field === xKey) ?? { field: xKey };\n  }\n\n  return chartableColumns.value.find((column) => !isNumericColumn(column)) ?? chartableColumns.value[0];\n});\n\nconst seriesColumn = computed(() => {\n  if (props.yKey !== undefined) {\n    const yKey = props.yKey;\n    return chartableColumns.value.find((column) => column.field === yKey) ?? { field: yKey };\n  }\n\n  return numericColumns.value.find((column) => column.field !== categoryColumn.value?.field) ?? numericColumns.value[0];\n});\n\nconst secondarySeriesColumn = computed(() => {\n  return numericColumns.value.find(\n    (column) => column.field !== seriesColumn.value?.field && column.field !== categoryColumn.value?.field,\n  );\n});\n\nconst stackColumn = computed(() => {\n  if (props.stackKey !== undefined) {\n    const stackKey = props.stackKey;\n    return chartableColumns.value.find((column) => column.field === stackKey) ?? { field: stackKey };\n  }\n\n  return chartableColumns.value.find(\n    (column) => column.field !== categoryColumn.value?.field && !isNumericColumn(column),\n  );\n});\n\nconst mapColumn = computed(() => {\n  if (props.mapKey !== undefined) {\n    const mapKey = props.mapKey;\n    return chartableColumns.value.find((column) => column.field === mapKey) ?? { field: mapKey };\n  }\n\n  return (\n    chartableColumns.value.find((column) => column.field === DEFAULT_MAP_REGION_FIELD) ??\n    chartableColumns.value.find((column) => getColumnDataType(column) === \"location\")\n  );\n});\n\n// True when the resolved map/region column is also the active category (x-axis).\nconst stateIsOnXAxis = computed(() => {\n  const mapField = mapColumn.value?.field;\n  return Boolean(mapField && categoryColumn.value?.field === mapField);\n});\n\nconst hasGeneratedBody = computed(() => {\n  return Boolean(props.chartOptions) || dataRows.value.length > 0 || inferredColumns.value.length > 0;\n});\n\nconst isTableView = computed(() => selectedChartType.value === TABLE_VIEW_TYPE);\nconst isMapView = computed(() => selectedChartType.value === \"map\" && stateIsOnXAxis.value);\nconst selectedMapRegion = ref<string | undefined>();\n\nconst tableHeaderCells = computed(() =>\n  inferredColumns.value.map((column) => ({ field: column.field, label: getColumnLabel(column, column.field) })),\n);\n\nconst tableBodyRows = computed(() =>\n  displayDataRows.value.map((row) => inferredColumns.value.map((column) => getTableCellValue(row, column.field))),\n);\n\n// A table is never stacked beneath a table, so the below-table only renders for\n// non-table view types and is independent of whether `table` is in the toggle.\nconst isBelowTableVisible = computed(\n  () => props.showTableBelowChart && !isTableView.value && inferredColumns.value.length > 0,\n);\n\nconst isWidgetConstrained = computed(() => {\n  return getIsWidgetConstrained(props) || Boolean(props.enableTableScrolling && props.tableMaxHeight);\n});\n\nconst widgetStyle = computed(() => buildWidgetStyle(props));\n// The loading card keeps its compact height, so only the width constraints carry over.\nconst loadingWidgetStyle = computed(() => buildWidgetStyle({ maxWidth: props.maxWidth, width: props.width }));\n\nconst tableContainerStyle = computed(() => {\n  if (!props.enableTableScrolling) return undefined;\n\n  const style: Record<string, string> = {\n    overflowX: \"auto\",\n    overflowY: \"auto\",\n  };\n  // Scrolling otherwise relies on the constrained flex layout (a bounded widget height).\n  const maxHeight = getCssSize(props.tableMaxHeight);\n\n  if (maxHeight) {\n    style.maxHeight = maxHeight;\n  }\n\n  return style;\n});\n\nconst stackedChartData = computed(() =>\n  getStackedChartData({\n    dataRows: displayDataRows.value,\n    categoryColumn: categoryColumn.value,\n    seriesColumn: seriesColumn.value,\n    stackColumn: stackColumn.value,\n  }),\n);\n\nconst aggregatedCategoryChartData = computed(() =>\n  getAggregatedCategoryChartData({\n    dataRows: displayDataRows.value,\n    categoryColumn: categoryColumn.value,\n    seriesColumn: seriesColumn.value,\n  }),\n);\n\nconst mapChartData = computed(() =>\n  getMapChartData({\n    dataRows: displayDataRows.value,\n    mapColumn: mapColumn.value,\n    seriesColumn: seriesColumn.value,\n  }),\n);\n\nconst mapGradientRange = computed(() => getMapGradientRange(mapChartData.value, seriesColumn.value?.field));\nconst mapSeriesValueFormatter = computed(() => getMapSeriesValueFormatter(seriesColumn.value));\n\nconst generatedChartOptions = computed<AgChartOptions>(() =>\n  generateDataWidgetChartOptions({\n    aggregatedCategoryChartData: aggregatedCategoryChartData.value,\n    categoryColumn: categoryColumn.value,\n    dataLimit: props.dataLimit,\n    displayDataRows: displayDataRows.value,\n    hideAxes: props.hideAxes,\n    hideAxisTitles: props.hideAxisTitles,\n    hideLegend: props.hideLegend,\n    hideValueAxis: props.hideValueAxis,\n    noDataOverlayText: props.noDataOverlayText,\n    numericColumns: numericColumns.value,\n    providedChartOptions: props.chartOptions,\n    secondarySeriesColumn: secondarySeriesColumn.value,\n    selectedChartType: selectedChartType.value,\n    seriesColumn: seriesColumn.value,\n    showSeriesLabels: props.showSeriesLabels,\n    stackColumn: stackColumn.value,\n    stackedChartData: stackedChartData.value,\n    useDisplayDataRows: props.chartData !== undefined,\n    xKey: props.xKey,\n    yKey: props.yKey,\n  }),\n);\n\nconst generatedChartDataCount = computed(() => getChartDataLength(generatedChartOptions.value));\nconst isGeneratedHorizontalScrollingChart = computed(() => getIsHorizontalBarChart(generatedChartOptions.value));\n\nconst effectiveChartMinHeight = computed(() =>\n  getScrollableChartMinHeight({\n    baseMinHeight: props.minHeight,\n    dataCount: generatedChartDataCount.value,\n    enableChartScrolling: props.enableChartScrolling,\n    isHorizontalScrollingChart: isGeneratedHorizontalScrollingChart.value,\n  }),\n);\n\nconst chartScrollContainerStyle = computed(() => {\n  const overflow = getChartScrollOverflowStyle({\n    enableChartScrolling: props.enableChartScrolling,\n    isHorizontalScrollingChart: isGeneratedHorizontalScrollingChart.value,\n  });\n\n  if (!overflow) return undefined;\n  if (!isGeneratedHorizontalScrollingChart.value) return overflow;\n\n  return { ...overflow, maxHeight: `${props.minHeight}px` };\n});\n\nconst chartContentStyle = computed(() =>\n  getChartScrollContentStyle({\n    chartMinHeight: effectiveChartMinHeight.value,\n    dataCount: generatedChartDataCount.value,\n    enableChartScrolling: props.enableChartScrolling,\n    isHorizontalScrollingChart: isGeneratedHorizontalScrollingChart.value,\n    minContentWidth: CHART_SCROLL_MIN_WIDTH_PX,\n  }),\n);\n</script>\n\n<template>\n  <PvCard\n    v-if=\"loading\"\n    class=\"pv-data-widget pv-data-widget--loading pv-inset-squish-12\"\n    :style=\"loadingWidgetStyle\"\n    role=\"status\"\n    aria-live=\"polite\"\n    aria-busy=\"true\"\n  >\n    <div class=\"pv-flex\" style=\"--flex-gap: 0.75rem\">\n      <div class=\"pv-data-widget__loading-thumbnail pv-flex pv-surface-neutral-warm pv-radius-lg\" aria-hidden=\"true\">\n        <span\n          v-for=\"(barHeight, index) in LOADING_THUMBNAIL_BAR_HEIGHTS_PX\"\n          :key=\"index\"\n          :class=\"[\n            'pv-data-widget__loading-bar pv-radius-sm-top',\n            index % 3 === 1 ? 'pv-data-surface-visualization-2' : 'pv-data-surface-visualization-1',\n            { 'pv-data-widget__loading-bar--light': index % 3 === 2 },\n          ]\"\n          :style=\"{ height: `${barHeight}px` }\"\n        />\n      </div>\n      <p class=\"pv-flex-item pv-text-body-lg pv-text-default\">{{ loadingText }}</p>\n      <PvSpinner size=\"md\" variant=\"primary\" aria-hidden=\"true\" />\n    </div>\n  </PvCard>\n  <PvCard\n    v-else\n    :class=\"[\n      'pv-data-widget pv-inset-square-16',\n      {\n        'pv-data-widget--constrained': isWidgetConstrained,\n      },\n    ]\"\n    :style=\"widgetStyle\"\n  >\n    <div v-if=\"showHeader\" class=\"pv-flex pv-space-between pv-stack-12\">\n      <div>\n        <span v-if=\"title\" class=\"pv-heading-2\">{{ title }}</span>\n      </div>\n      <div>\n        <PvSegmentedControl\n          v-if=\"showChartTypeToggle\"\n          v-model=\"selectedChartType\"\n          :options=\"chartTypeOptions\"\n          size=\"lg\"\n        />\n      </div>\n    </div>\n\n    <div v-if=\"hasAppliedFilters\" class=\"pv-stack-12\">\n      <span v-for=\"filter in appliedFilters\" :key=\"filter\">\n        {{ filter }}\n      </span>\n    </div>\n\n    <div class=\"pv-data-widget__body\">\n      <slot />\n      <template v-if=\"hasGeneratedBody\">\n        <div\n          v-if=\"isTableView\"\n          :class=\"[\n            'pv-data-widget__table-container',\n            {\n              'pv-scroll': enableTableScrolling,\n            },\n          ]\"\n          :style=\"tableContainerStyle\"\n        >\n          <PvDataWidgetTable :headers=\"tableHeaderCells\" :rows=\"tableBodyRows\" />\n        </div>\n        <div v-else-if=\"isMapView\" :style=\"{ minHeight: `${minHeight}px` }\">\n          <PvMapChart\n            v-model:selectedRegion=\"selectedMapRegion\"\n            :chartData=\"mapChartData\"\n            :displayRegionSelector=\"false\"\n            :gradientLegendMin=\"mapGradientRange.min\"\n            :gradientLegendMax=\"mapGradientRange.max\"\n            :isLoading=\"chartLoading\"\n            :noDataMessage=\"noDataOverlayText\"\n            :seriesKey=\"seriesColumn?.field ?? 'value'\"\n            :seriesValueFormatter=\"mapSeriesValueFormatter\"\n          />\n        </div>\n        <div\n          v-else\n          :class=\"[\n            'pv-data-widget__chart-scroll',\n            {\n              'pv-data-widget__chart-scroll--enabled pv-scrollbar-visible': enableChartScrolling,\n            },\n          ]\"\n          :style=\"chartScrollContainerStyle\"\n        >\n          <div class=\"pv-data-widget__chart-content\" :style=\"chartContentStyle\">\n            <PvChart\n              :options=\"generatedChartOptions\"\n              :colorTheme=\"colorTheme\"\n              :isLoading=\"chartLoading\"\n              :minHeight=\"effectiveChartMinHeight\"\n            />\n          </div>\n        </div>\n\n        <div\n          v-if=\"isBelowTableVisible\"\n          :class=\"[\n            'pv-data-widget__below-table pv-data-widget__table-container',\n            {\n              'pv-scroll': enableTableScrolling,\n            },\n          ]\"\n          :style=\"tableContainerStyle\"\n        >\n          <PvDataWidgetTable :headers=\"tableHeaderCells\" :rows=\"tableBodyRows\" />\n        </div>\n      </template>\n    </div>\n\n    <slot name=\"footer\" />\n  </PvCard>\n</template>\n\n<style scoped>\n.pv-data-widget {\n  box-sizing: border-box;\n  min-height: 0;\n  min-width: 0;\n  width: 100%;\n}\n\n.pv-data-widget--constrained {\n  display: flex;\n  flex-direction: column;\n  overflow: hidden;\n}\n\n.pv-data-widget--constrained .pv-data-widget__body {\n  display: flex;\n  flex: 1 1 auto;\n  flex-direction: column;\n  min-height: 0;\n  overflow: hidden;\n}\n\n.pv-data-widget__table-container {\n  min-height: 0;\n}\n\n.pv-data-widget__below-table {\n  margin-top: 16px;\n}\n\n.pv-data-widget--constrained .pv-data-widget__table-container {\n  flex: 1 1 auto;\n}\n\n.pv-data-widget--constrained .pv-data-widget__below-table {\n  flex: 0 0 auto;\n}\n\n.pv-data-widget__chart-scroll {\n  min-height: 0;\n  overflow: hidden;\n  width: 100%;\n}\n\n.pv-data-widget--constrained .pv-data-widget__chart-scroll {\n  flex: 1 1 auto;\n}\n\n/* Overflow is set inline per chart orientation - see getChartScrollOverflowStyle. */\n\n.pv-data-widget__loading-thumbnail {\n  --flex-align: flex-end;\n  --flex-gap: 2px;\n  --flex-justify: center;\n  flex: 0 0 auto;\n  height: 40px;\n  width: 48px;\n}\n\n.pv-data-widget__loading-bar {\n  flex: 0 0 auto;\n  width: 4px;\n}\n\n.pv-data-widget__loading-bar--light {\n  opacity: 0.4;\n}\n\n.pv-data-widget__chart-content {\n  min-height: 100%;\n}\n</style>\n","<script setup lang=\"ts\">\nimport { computed, ref } from \"vue\";\nimport PvCard from \"@/components/base/PvCard/PvCard.vue\";\nimport PvSegmentedControl from \"@/components/base/PvSegmentedControl/PvSegmentedControl.vue\";\nimport PvSpinner from \"@/components/base/PvSpinner/PvSpinner.vue\";\nimport PvChart from \"@charts/PvChart/PvChart.vue\";\nimport PvMapChart from \"@charts/PvMapChart/PvMapChart.vue\";\nimport PvDataWidgetTable from \"./PvDataWidgetTable.vue\";\nimport {\n  buildWidgetStyle,\n  getChartDataLength,\n  getChartScrollContentStyle,\n  getChartScrollOverflowStyle,\n  getCssSize,\n  getIsHorizontalBarChart,\n  getIsWidgetConstrained,\n  getScrollableChartMinHeight,\n  limitDataRows,\n} from \"@charts/widgetOptions\";\nimport {\n  CHART_SCROLL_MIN_WIDTH_PX,\n  DEFAULT_LOADING_TEXT,\n  DEFAULT_MAP_REGION_FIELD,\n  DEFAULT_MIN_HEIGHT_PX,\n  LOADING_THUMBNAIL_BAR_HEIGHTS_PX,\n  TABLE_VIEW_TYPE,\n} from \"./constants\";\nimport {\n  buildChartTypeOptions,\n  generateDataWidgetChartOptions,\n  getAggregatedCategoryChartData,\n  getColumnDataType,\n  getColumnLabel,\n  getInferredColumns,\n  getIsNumericColumn,\n  getMapChartData,\n  getMapGradientRange,\n  getMapSeriesValueFormatter,\n  getSelectedChartType,\n  getStackedChartData,\n  getTableCellValue,\n} from \"./helpers\";\nimport type {\n  PvDataWidgetChartTypeOption,\n  PvDataWidgetColumnDefinition,\n  PvDataWidgetDataRow,\n  PvDataWidgetProps,\n  PvDataWidgetViewType,\n} from \"./types\";\nimport type { AgChartOptions } from \"ag-charts-types\";\n\nconst props = withDefaults(defineProps<PvDataWidgetProps>(), {\n  appliedFilters: () => [],\n  chartLoading: false,\n  chartTypes: () => [],\n  colDefs: () => [],\n  enableChartScrolling: false,\n  enableTableScrolling: false,\n  hideAxes: false,\n  hideAxisTitles: false,\n  hideLegend: false,\n  hideValueAxis: false,\n  loading: false,\n  loadingText: DEFAULT_LOADING_TEXT,\n  minHeight: DEFAULT_MIN_HEIGHT_PX,\n  showSeriesLabels: false,\n  showTableBelowChart: false,\n  showWidgetTypeToggle: true,\n});\n\n/** Selected chart/view type. Bind `v-model:chartType` for controlled selection. */\nconst chartType = defineModel<PvDataWidgetViewType>(\"chartType\");\n\nconst getProvidedChartDataRows = (chartOptions: AgChartOptions | undefined): PvDataWidgetDataRow[] => {\n  const chartOptionData = chartOptions?.data;\n\n  return Array.isArray(chartOptionData) ? (chartOptionData as PvDataWidgetDataRow[]) : [];\n};\n\nconst isMapChartType = (chartType: PvDataWidgetViewType | PvDataWidgetChartTypeOption) => {\n  return typeof chartType === \"string\" ? chartType === \"map\" : chartType.value === \"map\";\n};\n\n// The map view is only offered when the state/region column is the active x-axis\n// (category). When it isn't, remove the map type before building options so the\n// helper can preserve its guarantee that widgets always have a non-table chart\n// fallback (e.g. `chartTypes: [\"map\", \"table\"]` becomes `[\"column\", \"table\"]`).\nconst chartTypeOptions = computed(() => {\n  const availableChartTypes = stateIsOnXAxis.value\n    ? props.chartTypes\n    : props.chartTypes.filter((type) => !isMapChartType(type));\n\n  return buildChartTypeOptions(availableChartTypes, {\n    useDefaultChartTypesWhenEmpty: props.chartTypes.length === 0,\n  });\n});\n\nconst selectedChartType = computed({\n  get: () => getSelectedChartType(chartType.value, chartTypeOptions.value),\n  set: (value: string) => {\n    chartType.value = value;\n  },\n});\n\nconst showChartTypeToggle = computed(() => props.showWidgetTypeToggle && chartTypeOptions.value.length > 1);\nconst showHeader = computed(() => Boolean(props.title) || showChartTypeToggle.value);\nconst hasAppliedFilters = computed(() => props.appliedFilters.length > 0);\n\n// Fall back to chartOptions.data when chartData is omitted, but keep an explicitly\n// supplied empty chartData array as an intentional override.\nconst dataRows = computed<PvDataWidgetDataRow[]>(() => {\n  if (props.chartData !== undefined) {\n    return props.chartData ?? [];\n  }\n\n  return getProvidedChartDataRows(props.chartOptions);\n});\nconst displayDataRows = computed(() => limitDataRows(dataRows.value, props.dataLimit));\n\nconst inferredColumns = computed<PvDataWidgetColumnDefinition[]>(() =>\n  getInferredColumns(dataRows.value, props.colDefs),\n);\n\nconst isNumericColumn = (column: PvDataWidgetColumnDefinition | undefined) => {\n  return getIsNumericColumn(column, dataRows.value);\n};\n\nconst chartableColumns = computed(() => {\n  return inferredColumns.value.filter((column) => !column.context?.hideFromCharting);\n});\n\nconst numericColumns = computed(() => chartableColumns.value.filter(isNumericColumn));\n\nconst categoryColumn = computed(() => {\n  if (props.xKey !== undefined) {\n    const xKey = props.xKey;\n    return chartableColumns.value.find((column) => column.field === xKey) ?? { field: xKey };\n  }\n\n  return chartableColumns.value.find((column) => !isNumericColumn(column)) ?? chartableColumns.value[0];\n});\n\nconst seriesColumn = computed(() => {\n  if (props.yKey !== undefined) {\n    const yKey = props.yKey;\n    return chartableColumns.value.find((column) => column.field === yKey) ?? { field: yKey };\n  }\n\n  return numericColumns.value.find((column) => column.field !== categoryColumn.value?.field) ?? numericColumns.value[0];\n});\n\nconst secondarySeriesColumn = computed(() => {\n  return numericColumns.value.find(\n    (column) => column.field !== seriesColumn.value?.field && column.field !== categoryColumn.value?.field,\n  );\n});\n\nconst stackColumn = computed(() => {\n  if (props.stackKey !== undefined) {\n    const stackKey = props.stackKey;\n    return chartableColumns.value.find((column) => column.field === stackKey) ?? { field: stackKey };\n  }\n\n  return chartableColumns.value.find(\n    (column) => column.field !== categoryColumn.value?.field && !isNumericColumn(column),\n  );\n});\n\nconst mapColumn = computed(() => {\n  if (props.mapKey !== undefined) {\n    const mapKey = props.mapKey;\n    return chartableColumns.value.find((column) => column.field === mapKey) ?? { field: mapKey };\n  }\n\n  return (\n    chartableColumns.value.find((column) => column.field === DEFAULT_MAP_REGION_FIELD) ??\n    chartableColumns.value.find((column) => getColumnDataType(column) === \"location\")\n  );\n});\n\n// True when the resolved map/region column is also the active category (x-axis).\nconst stateIsOnXAxis = computed(() => {\n  const mapField = mapColumn.value?.field;\n  return Boolean(mapField && categoryColumn.value?.field === mapField);\n});\n\nconst hasGeneratedBody = computed(() => {\n  return Boolean(props.chartOptions) || dataRows.value.length > 0 || inferredColumns.value.length > 0;\n});\n\nconst isTableView = computed(() => selectedChartType.value === TABLE_VIEW_TYPE);\nconst isMapView = computed(() => selectedChartType.value === \"map\" && stateIsOnXAxis.value);\nconst selectedMapRegion = ref<string | undefined>();\n\nconst tableHeaderCells = computed(() =>\n  inferredColumns.value.map((column) => ({ field: column.field, label: getColumnLabel(column, column.field) })),\n);\n\nconst tableBodyRows = computed(() =>\n  displayDataRows.value.map((row) => inferredColumns.value.map((column) => getTableCellValue(row, column.field))),\n);\n\n// A table is never stacked beneath a table, so the below-table only renders for\n// non-table view types and is independent of whether `table` is in the toggle.\nconst isBelowTableVisible = computed(\n  () => props.showTableBelowChart && !isTableView.value && inferredColumns.value.length > 0,\n);\n\nconst isWidgetConstrained = computed(() => {\n  return getIsWidgetConstrained(props) || Boolean(props.enableTableScrolling && props.tableMaxHeight);\n});\n\nconst widgetStyle = computed(() => buildWidgetStyle(props));\n// The loading card keeps its compact height, so only the width constraints carry over.\nconst loadingWidgetStyle = computed(() => buildWidgetStyle({ maxWidth: props.maxWidth, width: props.width }));\n\nconst tableContainerStyle = computed(() => {\n  if (!props.enableTableScrolling) return undefined;\n\n  const style: Record<string, string> = {\n    overflowX: \"auto\",\n    overflowY: \"auto\",\n  };\n  // Scrolling otherwise relies on the constrained flex layout (a bounded widget height).\n  const maxHeight = getCssSize(props.tableMaxHeight);\n\n  if (maxHeight) {\n    style.maxHeight = maxHeight;\n  }\n\n  return style;\n});\n\nconst stackedChartData = computed(() =>\n  getStackedChartData({\n    dataRows: displayDataRows.value,\n    categoryColumn: categoryColumn.value,\n    seriesColumn: seriesColumn.value,\n    stackColumn: stackColumn.value,\n  }),\n);\n\nconst aggregatedCategoryChartData = computed(() =>\n  getAggregatedCategoryChartData({\n    dataRows: displayDataRows.value,\n    categoryColumn: categoryColumn.value,\n    seriesColumn: seriesColumn.value,\n  }),\n);\n\nconst mapChartData = computed(() =>\n  getMapChartData({\n    dataRows: displayDataRows.value,\n    mapColumn: mapColumn.value,\n    seriesColumn: seriesColumn.value,\n  }),\n);\n\nconst mapGradientRange = computed(() => getMapGradientRange(mapChartData.value, seriesColumn.value?.field));\nconst mapSeriesValueFormatter = computed(() => getMapSeriesValueFormatter(seriesColumn.value));\n\nconst generatedChartOptions = computed<AgChartOptions>(() =>\n  generateDataWidgetChartOptions({\n    aggregatedCategoryChartData: aggregatedCategoryChartData.value,\n    categoryColumn: categoryColumn.value,\n    dataLimit: props.dataLimit,\n    displayDataRows: displayDataRows.value,\n    hideAxes: props.hideAxes,\n    hideAxisTitles: props.hideAxisTitles,\n    hideLegend: props.hideLegend,\n    hideValueAxis: props.hideValueAxis,\n    noDataOverlayText: props.noDataOverlayText,\n    numericColumns: numericColumns.value,\n    providedChartOptions: props.chartOptions,\n    secondarySeriesColumn: secondarySeriesColumn.value,\n    selectedChartType: selectedChartType.value,\n    seriesColumn: seriesColumn.value,\n    showSeriesLabels: props.showSeriesLabels,\n    stackColumn: stackColumn.value,\n    stackedChartData: stackedChartData.value,\n    useDisplayDataRows: props.chartData !== undefined,\n    xKey: props.xKey,\n    yKey: props.yKey,\n  }),\n);\n\nconst generatedChartDataCount = computed(() => getChartDataLength(generatedChartOptions.value));\nconst isGeneratedHorizontalScrollingChart = computed(() => getIsHorizontalBarChart(generatedChartOptions.value));\n\nconst effectiveChartMinHeight = computed(() =>\n  getScrollableChartMinHeight({\n    baseMinHeight: props.minHeight,\n    dataCount: generatedChartDataCount.value,\n    enableChartScrolling: props.enableChartScrolling,\n    isHorizontalScrollingChart: isGeneratedHorizontalScrollingChart.value,\n  }),\n);\n\nconst chartScrollContainerStyle = computed(() => {\n  const overflow = getChartScrollOverflowStyle({\n    enableChartScrolling: props.enableChartScrolling,\n    isHorizontalScrollingChart: isGeneratedHorizontalScrollingChart.value,\n  });\n\n  if (!overflow) return undefined;\n  if (!isGeneratedHorizontalScrollingChart.value) return overflow;\n\n  return { ...overflow, maxHeight: `${props.minHeight}px` };\n});\n\nconst chartContentStyle = computed(() =>\n  getChartScrollContentStyle({\n    chartMinHeight: effectiveChartMinHeight.value,\n    dataCount: generatedChartDataCount.value,\n    enableChartScrolling: props.enableChartScrolling,\n    isHorizontalScrollingChart: isGeneratedHorizontalScrollingChart.value,\n    minContentWidth: CHART_SCROLL_MIN_WIDTH_PX,\n  }),\n);\n</script>\n\n<template>\n  <PvCard\n    v-if=\"loading\"\n    class=\"pv-data-widget pv-data-widget--loading pv-inset-squish-12\"\n    :style=\"loadingWidgetStyle\"\n    role=\"status\"\n    aria-live=\"polite\"\n    aria-busy=\"true\"\n  >\n    <div class=\"pv-flex\" style=\"--flex-gap: 0.75rem\">\n      <div class=\"pv-data-widget__loading-thumbnail pv-flex pv-surface-neutral-warm pv-radius-lg\" aria-hidden=\"true\">\n        <span\n          v-for=\"(barHeight, index) in LOADING_THUMBNAIL_BAR_HEIGHTS_PX\"\n          :key=\"index\"\n          :class=\"[\n            'pv-data-widget__loading-bar pv-radius-sm-top',\n            index % 3 === 1 ? 'pv-data-surface-visualization-2' : 'pv-data-surface-visualization-1',\n            { 'pv-data-widget__loading-bar--light': index % 3 === 2 },\n          ]\"\n          :style=\"{ height: `${barHeight}px` }\"\n        />\n      </div>\n      <p class=\"pv-flex-item pv-text-body-lg pv-text-default\">{{ loadingText }}</p>\n      <PvSpinner size=\"md\" variant=\"primary\" aria-hidden=\"true\" />\n    </div>\n  </PvCard>\n  <PvCard\n    v-else\n    :class=\"[\n      'pv-data-widget pv-inset-square-16',\n      {\n        'pv-data-widget--constrained': isWidgetConstrained,\n      },\n    ]\"\n    :style=\"widgetStyle\"\n  >\n    <div v-if=\"showHeader\" class=\"pv-flex pv-space-between pv-stack-12\">\n      <div>\n        <span v-if=\"title\" class=\"pv-heading-2\">{{ title }}</span>\n      </div>\n      <div>\n        <PvSegmentedControl\n          v-if=\"showChartTypeToggle\"\n          v-model=\"selectedChartType\"\n          :options=\"chartTypeOptions\"\n          size=\"lg\"\n        />\n      </div>\n    </div>\n\n    <div v-if=\"hasAppliedFilters\" class=\"pv-stack-12\">\n      <span v-for=\"filter in appliedFilters\" :key=\"filter\">\n        {{ filter }}\n      </span>\n    </div>\n\n    <div class=\"pv-data-widget__body\">\n      <slot />\n      <template v-if=\"hasGeneratedBody\">\n        <div\n          v-if=\"isTableView\"\n          :class=\"[\n            'pv-data-widget__table-container',\n            {\n              'pv-scroll': enableTableScrolling,\n            },\n          ]\"\n          :style=\"tableContainerStyle\"\n        >\n          <PvDataWidgetTable :headers=\"tableHeaderCells\" :rows=\"tableBodyRows\" />\n        </div>\n        <div v-else-if=\"isMapView\" :style=\"{ minHeight: `${minHeight}px` }\">\n          <PvMapChart\n            v-model:selectedRegion=\"selectedMapRegion\"\n            :chartData=\"mapChartData\"\n            :displayRegionSelector=\"false\"\n            :gradientLegendMin=\"mapGradientRange.min\"\n            :gradientLegendMax=\"mapGradientRange.max\"\n            :isLoading=\"chartLoading\"\n            :noDataMessage=\"noDataOverlayText\"\n            :seriesKey=\"seriesColumn?.field ?? 'value'\"\n            :seriesValueFormatter=\"mapSeriesValueFormatter\"\n          />\n        </div>\n        <div\n          v-else\n          :class=\"[\n            'pv-data-widget__chart-scroll',\n            {\n              'pv-data-widget__chart-scroll--enabled pv-scrollbar-visible': enableChartScrolling,\n            },\n          ]\"\n          :style=\"chartScrollContainerStyle\"\n        >\n          <div class=\"pv-data-widget__chart-content\" :style=\"chartContentStyle\">\n            <PvChart\n              :options=\"generatedChartOptions\"\n              :colorTheme=\"colorTheme\"\n              :isLoading=\"chartLoading\"\n              :minHeight=\"effectiveChartMinHeight\"\n            />\n          </div>\n        </div>\n\n        <div\n          v-if=\"isBelowTableVisible\"\n          :class=\"[\n            'pv-data-widget__below-table pv-data-widget__table-container',\n            {\n              'pv-scroll': enableTableScrolling,\n            },\n          ]\"\n          :style=\"tableContainerStyle\"\n        >\n          <PvDataWidgetTable :headers=\"tableHeaderCells\" :rows=\"tableBodyRows\" />\n        </div>\n      </template>\n    </div>\n\n    <slot name=\"footer\" />\n  </PvCard>\n</template>\n\n<style scoped>\n.pv-data-widget {\n  box-sizing: border-box;\n  min-height: 0;\n  min-width: 0;\n  width: 100%;\n}\n\n.pv-data-widget--constrained {\n  display: flex;\n  flex-direction: column;\n  overflow: hidden;\n}\n\n.pv-data-widget--constrained .pv-data-widget__body {\n  display: flex;\n  flex: 1 1 auto;\n  flex-direction: column;\n  min-height: 0;\n  overflow: hidden;\n}\n\n.pv-data-widget__table-container {\n  min-height: 0;\n}\n\n.pv-data-widget__below-table {\n  margin-top: 16px;\n}\n\n.pv-data-widget--constrained .pv-data-widget__table-container {\n  flex: 1 1 auto;\n}\n\n.pv-data-widget--constrained .pv-data-widget__below-table {\n  flex: 0 0 auto;\n}\n\n.pv-data-widget__chart-scroll {\n  min-height: 0;\n  overflow: hidden;\n  width: 100%;\n}\n\n.pv-data-widget--constrained .pv-data-widget__chart-scroll {\n  flex: 1 1 auto;\n}\n\n/* Overflow is set inline per chart orientation - see getChartScrollOverflowStyle. */\n\n.pv-data-widget__loading-thumbnail {\n  --flex-align: flex-end;\n  --flex-gap: 2px;\n  --flex-justify: center;\n  flex: 0 0 auto;\n  height: 40px;\n  width: 48px;\n}\n\n.pv-data-widget__loading-bar {\n  flex: 0 0 auto;\n  width: 4px;\n}\n\n.pv-data-widget__loading-bar--light {\n  opacity: 0.4;\n}\n\n.pv-data-widget__chart-content {\n  min-height: 100%;\n}\n</style>\n","<script lang=\"ts\">\nimport type { CSSProperties } from \"vue\";\n\nexport interface PvDropdownProps {\n  /**\n   * Accessible name for the trigger button, exposed as `aria-label`. Required\n   * for icon-only triggers (e.g. a report-actions menu) so the button is named\n   * in the accessibility tree; optional when the trigger slot already has text.\n   */\n  ariaLabel?: string;\n  defaultOpen?: boolean;\n  popoverCssProperties?: CSSProperties;\n  alignment?: \"top\" | \"right\" | \"top right\" | undefined;\n  isList?: boolean;\n  isSortable?: boolean;\n  icon?: boolean;\n  disabled?: boolean;\n  isLoading?: boolean;\n  useTeleport?: boolean;\n  teleportLocation?: string;\n  /** Custom CSS styles applied to the trigger button, e.g. { width: \"100%\" } to stretch it to its container. */\n  triggerCssProperties?: CSSProperties;\n}\n</script>\n<script setup lang=\"ts\">\nimport { computed, ref, watch, nextTick, useId } from \"vue\";\nimport PvPopover from \"../PvPopover/PvPopover.vue\";\nimport { vOnClickOutside } from \"@vueuse/components\";\nconst props = withDefaults(defineProps<PvDropdownProps>(), {\n  alignment: undefined,\n  isList: false,\n  defaultOpen: false,\n  disabled: false,\n  isLoading: false,\n  useTeleport: false,\n  teleportLocation: \"body\",\n});\nconst emits = defineEmits<{\n  (e: \"dropdown-open\"): void;\n  (e: \"dropdown-closed\"): void;\n  (e: \"list-order-updated\", value: string[]): void;\n}>();\nconst open = ref<boolean>(props.defaultOpen);\n\n// Stable id linking the trigger to its popover via aria-controls.\nconst popoverId = useId();\n\nconst triggerRef = ref<HTMLElement | null>(null);\nconst popoverRef = ref<{ popoverRoot: HTMLElement | null } | null>(null);\nconst triggerRect = ref<DOMRect | null>(null);\nconst popoverRect = ref<DOMRect | null>(null);\n\nconst updateRects = () => {\n  if (triggerRef.value) {\n    triggerRect.value = triggerRef.value.getBoundingClientRect();\n  }\n  if (popoverRef.value?.popoverRoot) {\n    popoverRect.value = popoverRef.value.popoverRoot.getBoundingClientRect();\n  }\n};\n\nconst popoverClasses = computed(() => {\n  const classes = {\n    \"pv-hide\": !open.value,\n  };\n  return classes;\n});\nconst handleClickTrigger = () => {\n  open.value = !open.value;\n};\n\nconst closeDropdown = () => {\n  open.value = false;\n};\n\n// Escape dismisses the open menu and returns focus to the trigger, per the\n// WAI-ARIA menu button pattern. Handled where the keydown bubbles up from the\n// focused trigger; stop propagation only when we consume it so a parent (e.g. a\n// modal) does not also close on the same Escape.\nconst handleEscape = (event: KeyboardEvent) => {\n  if (!open.value) return;\n  event.stopPropagation();\n  open.value = false;\n  triggerRef.value?.focus();\n};\n\ndefineExpose({\n  closeDropdown,\n});\n\nwatch(open, (newValue) => {\n  if (newValue) {\n    nextTick(() => {\n      updateRects();\n      emits(\"dropdown-open\");\n    });\n  } else {\n    emits(\"dropdown-closed\");\n  }\n});\n\nconst leftOffset = computed(() => {\n  if (!triggerRect.value || !popoverRect.value) return 0;\n\n  if (props.alignment === \"right\" || props.alignment === \"top right\") {\n    return triggerRect.value.left + triggerRect.value.width - popoverRect.value.width;\n  }\n  return triggerRect.value.left;\n});\n\nconst topOffset = computed(() => {\n  if (!triggerRect.value || !popoverRect.value) return 0;\n\n  if (props.alignment === \"top\" || props.alignment === \"top right\") {\n    return triggerRect.value.top - popoverRect.value.height;\n  }\n\n  return triggerRect.value.top + window.scrollY + triggerRect.value.height;\n});\n\nconst popoverPositionStyle = computed(() => {\n  if (!props.useTeleport) {\n    return props.popoverCssProperties;\n  }\n  const teleportStyles = {\n    position: \"absolute\",\n    left: `${leftOffset.value}px`,\n    top: `${topOffset.value}px`,\n    zIndex: 10,\n  } as CSSProperties;\n  return {\n    ...teleportStyles,\n    ...props.popoverCssProperties,\n  };\n});\n</script>\n<template>\n  <div\n    class=\"pv-dropdown-component pv-relative\"\n    v-on-click-outside=\"closeDropdown\"\n    style=\"width: fit-content\"\n    @keydown.esc=\"handleEscape\"\n  >\n    <button\n      ref=\"triggerRef\"\n      type=\"button\"\n      :class=\"{ 'pv-select': !icon, 'pv-button-icon': icon }\"\n      :style=\"{ width: 'auto', ...triggerCssProperties }\"\n      :aria-label=\"ariaLabel\"\n      :aria-haspopup=\"true\"\n      :aria-expanded=\"open\"\n      :aria-controls=\"popoverId\"\n      @click=\"handleClickTrigger\"\n      :disabled=\"disabled\"\n    >\n      <slot name=\"trigger\">Open</slot>\n    </button>\n    <Teleport :to=\"teleportLocation\" :disabled=\"!useTeleport\">\n      <PvPopover\n        ref=\"popoverRef\"\n        :id=\"popoverId\"\n        :class=\"popoverClasses\"\n        :css-custom-properties=\"popoverPositionStyle\"\n        :alignment=\"alignment\"\n        :isList=\"isList\"\n        :isSortable=\"isSortable\"\n        @list-order-updated=\"$emit('list-order-updated', $event)\"\n        ><slot><span v-if=\"isLoading\" class=\"pv-shimmer\">Loading...</span></slot></PvPopover\n      >\n    </Teleport>\n  </div>\n</template>\n\n<style scoped>\n.pv-select {\n  padding-top: 4px;\n  padding-bottom: 4px;\n}\n</style>\n","<script lang=\"ts\">\nimport type { CSSProperties } from \"vue\";\n\nexport interface PvDropdownProps {\n  /**\n   * Accessible name for the trigger button, exposed as `aria-label`. Required\n   * for icon-only triggers (e.g. a report-actions menu) so the button is named\n   * in the accessibility tree; optional when the trigger slot already has text.\n   */\n  ariaLabel?: string;\n  defaultOpen?: boolean;\n  popoverCssProperties?: CSSProperties;\n  alignment?: \"top\" | \"right\" | \"top right\" | undefined;\n  isList?: boolean;\n  isSortable?: boolean;\n  icon?: boolean;\n  disabled?: boolean;\n  isLoading?: boolean;\n  useTeleport?: boolean;\n  teleportLocation?: string;\n  /** Custom CSS styles applied to the trigger button, e.g. { width: \"100%\" } to stretch it to its container. */\n  triggerCssProperties?: CSSProperties;\n}\n</script>\n<script setup lang=\"ts\">\nimport { computed, ref, watch, nextTick, useId } from \"vue\";\nimport PvPopover from \"../PvPopover/PvPopover.vue\";\nimport { vOnClickOutside } from \"@vueuse/components\";\nconst props = withDefaults(defineProps<PvDropdownProps>(), {\n  alignment: undefined,\n  isList: false,\n  defaultOpen: false,\n  disabled: false,\n  isLoading: false,\n  useTeleport: false,\n  teleportLocation: \"body\",\n});\nconst emits = defineEmits<{\n  (e: \"dropdown-open\"): void;\n  (e: \"dropdown-closed\"): void;\n  (e: \"list-order-updated\", value: string[]): void;\n}>();\nconst open = ref<boolean>(props.defaultOpen);\n\n// Stable id linking the trigger to its popover via aria-controls.\nconst popoverId = useId();\n\nconst triggerRef = ref<HTMLElement | null>(null);\nconst popoverRef = ref<{ popoverRoot: HTMLElement | null } | null>(null);\nconst triggerRect = ref<DOMRect | null>(null);\nconst popoverRect = ref<DOMRect | null>(null);\n\nconst updateRects = () => {\n  if (triggerRef.value) {\n    triggerRect.value = triggerRef.value.getBoundingClientRect();\n  }\n  if (popoverRef.value?.popoverRoot) {\n    popoverRect.value = popoverRef.value.popoverRoot.getBoundingClientRect();\n  }\n};\n\nconst popoverClasses = computed(() => {\n  const classes = {\n    \"pv-hide\": !open.value,\n  };\n  return classes;\n});\nconst handleClickTrigger = () => {\n  open.value = !open.value;\n};\n\nconst closeDropdown = () => {\n  open.value = false;\n};\n\n// Escape dismisses the open menu and returns focus to the trigger, per the\n// WAI-ARIA menu button pattern. Handled where the keydown bubbles up from the\n// focused trigger; stop propagation only when we consume it so a parent (e.g. a\n// modal) does not also close on the same Escape.\nconst handleEscape = (event: KeyboardEvent) => {\n  if (!open.value) return;\n  event.stopPropagation();\n  open.value = false;\n  triggerRef.value?.focus();\n};\n\ndefineExpose({\n  closeDropdown,\n});\n\nwatch(open, (newValue) => {\n  if (newValue) {\n    nextTick(() => {\n      updateRects();\n      emits(\"dropdown-open\");\n    });\n  } else {\n    emits(\"dropdown-closed\");\n  }\n});\n\nconst leftOffset = computed(() => {\n  if (!triggerRect.value || !popoverRect.value) return 0;\n\n  if (props.alignment === \"right\" || props.alignment === \"top right\") {\n    return triggerRect.value.left + triggerRect.value.width - popoverRect.value.width;\n  }\n  return triggerRect.value.left;\n});\n\nconst topOffset = computed(() => {\n  if (!triggerRect.value || !popoverRect.value) return 0;\n\n  if (props.alignment === \"top\" || props.alignment === \"top right\") {\n    return triggerRect.value.top - popoverRect.value.height;\n  }\n\n  return triggerRect.value.top + window.scrollY + triggerRect.value.height;\n});\n\nconst popoverPositionStyle = computed(() => {\n  if (!props.useTeleport) {\n    return props.popoverCssProperties;\n  }\n  const teleportStyles = {\n    position: \"absolute\",\n    left: `${leftOffset.value}px`,\n    top: `${topOffset.value}px`,\n    zIndex: 10,\n  } as CSSProperties;\n  return {\n    ...teleportStyles,\n    ...props.popoverCssProperties,\n  };\n});\n</script>\n<template>\n  <div\n    class=\"pv-dropdown-component pv-relative\"\n    v-on-click-outside=\"closeDropdown\"\n    style=\"width: fit-content\"\n    @keydown.esc=\"handleEscape\"\n  >\n    <button\n      ref=\"triggerRef\"\n      type=\"button\"\n      :class=\"{ 'pv-select': !icon, 'pv-button-icon': icon }\"\n      :style=\"{ width: 'auto', ...triggerCssProperties }\"\n      :aria-label=\"ariaLabel\"\n      :aria-haspopup=\"true\"\n      :aria-expanded=\"open\"\n      :aria-controls=\"popoverId\"\n      @click=\"handleClickTrigger\"\n      :disabled=\"disabled\"\n    >\n      <slot name=\"trigger\">Open</slot>\n    </button>\n    <Teleport :to=\"teleportLocation\" :disabled=\"!useTeleport\">\n      <PvPopover\n        ref=\"popoverRef\"\n        :id=\"popoverId\"\n        :class=\"popoverClasses\"\n        :css-custom-properties=\"popoverPositionStyle\"\n        :alignment=\"alignment\"\n        :isList=\"isList\"\n        :isSortable=\"isSortable\"\n        @list-order-updated=\"$emit('list-order-updated', $event)\"\n        ><slot><span v-if=\"isLoading\" class=\"pv-shimmer\">Loading...</span></slot></PvPopover\n      >\n    </Teleport>\n  </div>\n</template>\n\n<style scoped>\n.pv-select {\n  padding-top: 4px;\n  padding-bottom: 4px;\n}\n</style>\n","<script setup lang=\"ts\">\nimport { computed, CSSProperties } from \"vue\";\nimport PvIcon from \"../PvIcon/PvIcon.vue\";\nimport { TagSize, TagVariant } from \"./types\";\n\nexport interface PvTagProps {\n  /**\n   * Tag size\n   */\n  size?: TagSize;\n  /**\n   * Tag visual variant\n   */\n  variant?: TagVariant;\n  /**\n   * Tag Icon\n   */\n  icon?: string;\n  /**\n   * Icon class\n   */\n  iconClasses?: string[];\n  /**\n   * Tag Label\n   */\n  label: string;\n  /**\n   * Show left clear icon\n   */\n  showClear?: boolean;\n  /**\n   * Show rounded state\n   */\n  rounded?: boolean;\n  /**\n   * Spine - dotted state\n   */\n  spine?: boolean;\n  /**\n   * Optional `data-dd-action-name` attached to the close (×) icon so Datadog\n   * RUM resolves the click to a named action instead of the tag label.\n   * Leave unset to fall back to Datadog's default text resolution.\n   */\n  rumRemoveActionName?: string;\n}\n\nconst props = withDefaults(defineProps<PvTagProps>(), {\n  size: \"md\",\n  variant: \"tertiary\",\n});\n\ndefineEmits<{\n  (e: \"handle-close\", payload: string): void;\n  (e: \"handle-click\", payload: string): void;\n}>();\n\nconst tagSizeClass = computed(() => {\n  switch (props.size) {\n    case \"lg\": {\n      return \"pv-tag-lg\";\n    }\n    case \"xl\": {\n      return \"pv-tag-xl\";\n    }\n    case \"sm\": {\n      return \"pv-tag-sm\";\n    }\n    default: {\n      return \"\";\n    }\n  }\n});\n\n// XL pairs its 12px label with 16px icons; smaller sizes keep 12px icons.\nconst iconSize = computed(() => (props.size === \"xl\" ? 16 : 12));\n\nconst tagVariantClass = computed(() => {\n  switch (props.variant) {\n    case \"primary\": {\n      return \"pv-tag-primary\";\n    }\n    case \"secondary\": {\n      return \"pv-tag-secondary\";\n    }\n    case \"tertiary\": {\n      return \"pv-tag-tertiary\";\n    }\n    case \"transparent\": {\n      return \"pv-tag-tertiary\";\n    }\n    default: {\n      return \"\";\n    }\n  }\n});\n\nconst pvTagStyles = computed(() => {\n  const baseStyles: CSSProperties = {\n    \"max-width\": \"100%\",\n    \"--flex-gap\": \"4px\",\n  };\n\n  if (props.variant === \"transparent\") {\n    baseStyles[\"--tag-background-color\"] = \"transparent\";\n  }\n\n  return baseStyles;\n});\n</script>\n\n<template>\n  <button\n    :class=\"[tagVariantClass, tagSizeClass, 'pv-flex']\"\n    @click=\"$emit('handle-click', label)\"\n    :style=\"pvTagStyles\"\n    data-testid=\"pv-tag\"\n    :data-style=\"rounded ? 'rounded' : undefined\"\n  >\n    <PvIcon data-testid=\"pv-tag-icon\" v-if=\"icon\" :class=\"iconClasses\" :name=\"icon\" :size=\"iconSize\" />\n    <span\n      :class=\"[\n        'pv-truncate',\n        {\n          'pv-underline-dotted': spine,\n        },\n      ]\"\n    >\n      {{ label }}\n    </span>\n    <PvIcon\n      data-testid=\"pv-tag-close-icon\"\n      :size=\"iconSize\"\n      name=\"close\"\n      v-if=\"showClear\"\n      :data-dd-action-name=\"rumRemoveActionName\"\n      @click.stop=\"$emit('handle-close', label)\"\n    />\n  </button>\n</template>\n","<script setup lang=\"ts\">\nimport { computed, CSSProperties } from \"vue\";\nimport PvIcon from \"../PvIcon/PvIcon.vue\";\nimport { TagSize, TagVariant } from \"./types\";\n\nexport interface PvTagProps {\n  /**\n   * Tag size\n   */\n  size?: TagSize;\n  /**\n   * Tag visual variant\n   */\n  variant?: TagVariant;\n  /**\n   * Tag Icon\n   */\n  icon?: string;\n  /**\n   * Icon class\n   */\n  iconClasses?: string[];\n  /**\n   * Tag Label\n   */\n  label: string;\n  /**\n   * Show left clear icon\n   */\n  showClear?: boolean;\n  /**\n   * Show rounded state\n   */\n  rounded?: boolean;\n  /**\n   * Spine - dotted state\n   */\n  spine?: boolean;\n  /**\n   * Optional `data-dd-action-name` attached to the close (×) icon so Datadog\n   * RUM resolves the click to a named action instead of the tag label.\n   * Leave unset to fall back to Datadog's default text resolution.\n   */\n  rumRemoveActionName?: string;\n}\n\nconst props = withDefaults(defineProps<PvTagProps>(), {\n  size: \"md\",\n  variant: \"tertiary\",\n});\n\ndefineEmits<{\n  (e: \"handle-close\", payload: string): void;\n  (e: \"handle-click\", payload: string): void;\n}>();\n\nconst tagSizeClass = computed(() => {\n  switch (props.size) {\n    case \"lg\": {\n      return \"pv-tag-lg\";\n    }\n    case \"xl\": {\n      return \"pv-tag-xl\";\n    }\n    case \"sm\": {\n      return \"pv-tag-sm\";\n    }\n    default: {\n      return \"\";\n    }\n  }\n});\n\n// XL pairs its 12px label with 16px icons; smaller sizes keep 12px icons.\nconst iconSize = computed(() => (props.size === \"xl\" ? 16 : 12));\n\nconst tagVariantClass = computed(() => {\n  switch (props.variant) {\n    case \"primary\": {\n      return \"pv-tag-primary\";\n    }\n    case \"secondary\": {\n      return \"pv-tag-secondary\";\n    }\n    case \"tertiary\": {\n      return \"pv-tag-tertiary\";\n    }\n    case \"transparent\": {\n      return \"pv-tag-tertiary\";\n    }\n    default: {\n      return \"\";\n    }\n  }\n});\n\nconst pvTagStyles = computed(() => {\n  const baseStyles: CSSProperties = {\n    \"max-width\": \"100%\",\n    \"--flex-gap\": \"4px\",\n  };\n\n  if (props.variant === \"transparent\") {\n    baseStyles[\"--tag-background-color\"] = \"transparent\";\n  }\n\n  return baseStyles;\n});\n</script>\n\n<template>\n  <button\n    :class=\"[tagVariantClass, tagSizeClass, 'pv-flex']\"\n    @click=\"$emit('handle-click', label)\"\n    :style=\"pvTagStyles\"\n    data-testid=\"pv-tag\"\n    :data-style=\"rounded ? 'rounded' : undefined\"\n  >\n    <PvIcon data-testid=\"pv-tag-icon\" v-if=\"icon\" :class=\"iconClasses\" :name=\"icon\" :size=\"iconSize\" />\n    <span\n      :class=\"[\n        'pv-truncate',\n        {\n          'pv-underline-dotted': spine,\n        },\n      ]\"\n    >\n      {{ label }}\n    </span>\n    <PvIcon\n      data-testid=\"pv-tag-close-icon\"\n      :size=\"iconSize\"\n      name=\"close\"\n      v-if=\"showClear\"\n      :data-dd-action-name=\"rumRemoveActionName\"\n      @click.stop=\"$emit('handle-close', label)\"\n    />\n  </button>\n</template>\n","<script lang=\"ts\">\nimport { computed, watch, useTemplateRef } from \"vue\";\n</script>\n\n<script setup lang=\"ts\">\nexport interface ModalProps {\n  header: string;\n  subheader?: string;\n  disableCloseOnClickOutside?: boolean;\n  hideFooter?: boolean;\n  hideHeader?: boolean;\n  /** Vertical placement in the viewport. \"center\" centers the modal, \"top\" anchors it near the top. */\n  position?: \"center\" | \"top\";\n}\n\nconst props = withDefaults(defineProps<ModalProps>(), {\n  disableCloseOnClickOutside: false,\n  hideFooter: false,\n  position: \"center\",\n});\n\n// \"top\" leans on the framework's default `--top` offset; centering needs the dialog\n// positioned against the viewport so auto block margins can split the leftover space.\nconst positionStyle = computed(() =>\n  props.position === \"center\" ? \"position: fixed; inset-block: 0; height: fit-content; margin-block: auto\" : undefined,\n);\n\nconst dialogRef = useTemplateRef<HTMLDialogElement | null>(\"dialog\");\nconst showModal = defineModel<boolean>({\n  required: true,\n});\n\nwatch(\n  () => showModal.value,\n  () => {\n    if (showModal.value) {\n      dialogRef.value?.showModal();\n    } else {\n      dialogRef.value?.close();\n    }\n  },\n);\n\nconst handleClose = () => {\n  showModal.value = false;\n};\n\nconst handleBackdropClick = (e: MouseEvent) => {\n  if (!props.disableCloseOnClickOutside && e.target === dialogRef.value) {\n    handleClose();\n  }\n};\n</script>\n\n<template>\n  <dialog\n    class=\"pv-modal-sm\"\n    ref=\"dialog\"\n    :style=\"positionStyle\"\n    v-on:close=\"handleClose\"\n    v-on:click=\"handleBackdropClick\"\n  >\n    <div class=\"pv-inset-squish-12\">\n      <div v-if=\"!hideHeader\" class=\"pv-flex pv-flex-vertical pv-stack-16\" style=\"--flex-align: flex-start\">\n        <span class=\"pv-heading-3\">{{ header }}</span>\n        <span v-if=\"subheader\" class=\"pv-text-body-md\">{{ subheader }}</span>\n      </div>\n      <slot name=\"body\" />\n    </div>\n    <div\n      v-if=\"!hideFooter\"\n      class=\"pv-inset-squish-12 pv-border-top\"\n      style=\"--color-border: var(--modal-footer-border-color, #d2d8dc)\"\n    >\n      <slot name=\"footer\" />\n    </div>\n  </dialog>\n</template>\n","<script lang=\"ts\">\nimport { computed, watch, useTemplateRef } from \"vue\";\n</script>\n\n<script setup lang=\"ts\">\nexport interface ModalProps {\n  header: string;\n  subheader?: string;\n  disableCloseOnClickOutside?: boolean;\n  hideFooter?: boolean;\n  hideHeader?: boolean;\n  /** Vertical placement in the viewport. \"center\" centers the modal, \"top\" anchors it near the top. */\n  position?: \"center\" | \"top\";\n}\n\nconst props = withDefaults(defineProps<ModalProps>(), {\n  disableCloseOnClickOutside: false,\n  hideFooter: false,\n  position: \"center\",\n});\n\n// \"top\" leans on the framework's default `--top` offset; centering needs the dialog\n// positioned against the viewport so auto block margins can split the leftover space.\nconst positionStyle = computed(() =>\n  props.position === \"center\" ? \"position: fixed; inset-block: 0; height: fit-content; margin-block: auto\" : undefined,\n);\n\nconst dialogRef = useTemplateRef<HTMLDialogElement | null>(\"dialog\");\nconst showModal = defineModel<boolean>({\n  required: true,\n});\n\nwatch(\n  () => showModal.value,\n  () => {\n    if (showModal.value) {\n      dialogRef.value?.showModal();\n    } else {\n      dialogRef.value?.close();\n    }\n  },\n);\n\nconst handleClose = () => {\n  showModal.value = false;\n};\n\nconst handleBackdropClick = (e: MouseEvent) => {\n  if (!props.disableCloseOnClickOutside && e.target === dialogRef.value) {\n    handleClose();\n  }\n};\n</script>\n\n<template>\n  <dialog\n    class=\"pv-modal-sm\"\n    ref=\"dialog\"\n    :style=\"positionStyle\"\n    v-on:close=\"handleClose\"\n    v-on:click=\"handleBackdropClick\"\n  >\n    <div class=\"pv-inset-squish-12\">\n      <div v-if=\"!hideHeader\" class=\"pv-flex pv-flex-vertical pv-stack-16\" style=\"--flex-align: flex-start\">\n        <span class=\"pv-heading-3\">{{ header }}</span>\n        <span v-if=\"subheader\" class=\"pv-text-body-md\">{{ subheader }}</span>\n      </div>\n      <slot name=\"body\" />\n    </div>\n    <div\n      v-if=\"!hideFooter\"\n      class=\"pv-inset-squish-12 pv-border-top\"\n      style=\"--color-border: var(--modal-footer-border-color, #d2d8dc)\"\n    >\n      <slot name=\"footer\" />\n    </div>\n  </dialog>\n</template>\n","export enum BannerOrientationsEnum {\n  Vertical = \"Vertical\",\n  Horizontal = \"Horizontal\",\n}\n\nexport enum BannerVariantsEnum {\n  Primary = \"Primary\",\n  Secondary = \"Secondary\",\n  Tertiary = \"Tertiary\",\n  Universal = \"Universal\",\n  AI = \"AI\",\n  Marketing = \"Marketing\",\n}\n\nexport enum BannerAccentColorsEnum {\n  Blue = \"Blue\",\n  Purple = \"Purple\",\n  Red = \"Red\",\n  Yellow = \"Yellow\",\n  Green = \"Green\",\n}\n\nexport type BannerOrientations = `${BannerOrientationsEnum}`;\nexport type BannerVariants = `${BannerVariantsEnum}`;\nexport type BannerAccentColors = `${BannerAccentColorsEnum}`;\n","<script setup lang=\"ts\">\nimport PvIcon from \"../PvIcon/PvIcon.vue\";\nimport {\n  BannerAccentColors,\n  BannerAccentColorsEnum,\n  BannerOrientations,\n  BannerVariants,\n  BannerVariantsEnum,\n  BannerOrientationsEnum,\n} from \"./types\";\n\nexport interface PvBannerProps {\n  /** Primary text displayed in the banner */\n  label?: string;\n  /** Secondary descriptive text displayed below the label */\n  description?: string;\n  /** Icon name to display alongside the banner content */\n  icon?: string;\n  /** Visual style variant of the banner */\n  variant?: BannerVariants;\n  /** Layout orientation of the banner */\n  orientation?: BannerOrientations;\n  /** Color of the left accent bar, only applies to the Universal variant */\n  accentColor?: BannerAccentColors;\n}\n\nwithDefaults(defineProps<PvBannerProps>(), {\n  orientation: BannerOrientationsEnum.Horizontal,\n  variant: BannerVariantsEnum.Primary,\n  accentColor: BannerAccentColorsEnum.Blue,\n});\n</script>\n\n<template>\n  <div\n    data-testid=\"pv-banner\"\n    :class=\"[\n      {\n        'pv-banner-primary': variant === BannerVariantsEnum.Primary,\n        'pv-banner-secondary': variant === BannerVariantsEnum.Secondary,\n        'pv-banner-tertiary': variant === BannerVariantsEnum.Tertiary,\n        'pv-banner-universal': variant === BannerVariantsEnum.Universal,\n        'pv-banner-ai': variant === BannerVariantsEnum.AI,\n        'pv-banner-marketing': variant === BannerVariantsEnum.Marketing,\n        'pv-flex pv-space-between': orientation === BannerOrientationsEnum.Horizontal,\n      },\n      variant === BannerVariantsEnum.Universal && `pv-banner-accent-${accentColor.toLowerCase()}`,\n    ]\"\n  >\n    <div\n      :class=\"[\n        'pv-flex',\n        {\n          'pv-stack-16': orientation === BannerOrientationsEnum.Vertical && $slots.action,\n        },\n      ]\"\n    >\n      <slot name=\"left\"></slot>\n      <PvIcon v-if=\"icon\" data-testid=\"pv-banner-icon\" class=\"pv-text-brand\" :name=\"icon\" />\n      <div\n        :class=\"[\n          {\n            'pv-flex': orientation === BannerOrientationsEnum.Horizontal,\n          },\n        ]\"\n      >\n        <p\n          v-if=\"label\"\n          :class=\"[\n            'pv-text-title-md pv-line-clamp',\n            {\n              'pv-stack-4': description && orientation === BannerOrientationsEnum.Vertical,\n            },\n          ]\"\n          style=\"--lines: 2; font-weight: 500\"\n          :title=\"label\"\n          v-html=\"label\"\n        ></p>\n        <p\n          v-if=\"description\"\n          class=\"pv-text-body-sm pv-line-clamp\"\n          style=\"--lines: 2\"\n          :title=\"description\"\n          v-html=\"description\"\n        ></p>\n      </div>\n    </div>\n    <div class=\"pv-flex\">\n      <slot name=\"action\" />\n    </div>\n  </div>\n</template>\n","<script setup lang=\"ts\">\nimport { computed } from \"vue\";\nimport PvIcon from \"@/components/base/PvIcon/PvIcon.vue\";\nimport { TagSize } from \"@/components/base/PvTag/types\";\n\nexport interface PvSuggestionTag {\n  /**\n   * Tag size\n   */\n  size?: TagSize;\n  /**\n   * Tag Label\n   */\n  label: string;\n  /**\n   * Tag Icon\n   */\n  icon?: string;\n  /**\n   * Icon class\n   */\n  iconClasses?: string[];\n  /**\n   * Show rounded state\n   */\n  rounded?: boolean;\n  /**\n   * Disable the tag, preventing interaction\n   */\n  disabled?: boolean;\n  /**\n   * Wrap a long label onto several lines instead of truncating it to one\n   */\n  wrap?: boolean;\n}\n\nconst props = withDefaults(defineProps<PvSuggestionTag>(), {\n  size: \"md\",\n  disabled: false,\n  wrap: false,\n});\n\ndefineEmits<{\n  (e: \"handle-click\", label: string): void;\n}>();\n\nconst tagSizeClass = computed(() => {\n  switch (props.size) {\n    case \"lg\": {\n      return \"pv-tag-lg\";\n    }\n    case \"sm\": {\n      return \"pv-tag-sm\";\n    }\n    default: {\n      return \"\";\n    }\n  }\n});\n</script>\n\n<template>\n  <button\n    :class=\"['pv-suggestion-tag pv-border-dashed pv-tag-secondary', tagSizeClass]\"\n    @click=\"$emit('handle-click', label)\"\n    data-testid=\"pv-suggestion-tag\"\n    style=\"max-width: 100%\"\n    :data-style=\"rounded ? 'rounded' : undefined\"\n    :data-wrap=\"wrap ? 'true' : undefined\"\n    :disabled=\"disabled\"\n    :title=\"label\"\n  >\n    <PvIcon data-testid=\"pv-suggestion-tag-icon\" v-if=\"icon\" :name=\"icon\" :size=\"12\" :class=\"iconClasses\" />\n    <span :class=\"{ 'pv-truncate': !wrap }\">\n      {{ label }}\n    </span>\n  </button>\n</template>\n","<script setup lang=\"ts\">\nimport { computed } from \"vue\";\nimport PvIcon from \"@/components/base/PvIcon/PvIcon.vue\";\nimport { TagSize } from \"@/components/base/PvTag/types\";\n\nexport interface PvSuggestionTag {\n  /**\n   * Tag size\n   */\n  size?: TagSize;\n  /**\n   * Tag Label\n   */\n  label: string;\n  /**\n   * Tag Icon\n   */\n  icon?: string;\n  /**\n   * Icon class\n   */\n  iconClasses?: string[];\n  /**\n   * Show rounded state\n   */\n  rounded?: boolean;\n  /**\n   * Disable the tag, preventing interaction\n   */\n  disabled?: boolean;\n  /**\n   * Wrap a long label onto several lines instead of truncating it to one\n   */\n  wrap?: boolean;\n}\n\nconst props = withDefaults(defineProps<PvSuggestionTag>(), {\n  size: \"md\",\n  disabled: false,\n  wrap: false,\n});\n\ndefineEmits<{\n  (e: \"handle-click\", label: string): void;\n}>();\n\nconst tagSizeClass = computed(() => {\n  switch (props.size) {\n    case \"lg\": {\n      return \"pv-tag-lg\";\n    }\n    case \"sm\": {\n      return \"pv-tag-sm\";\n    }\n    default: {\n      return \"\";\n    }\n  }\n});\n</script>\n\n<template>\n  <button\n    :class=\"['pv-suggestion-tag pv-border-dashed pv-tag-secondary', tagSizeClass]\"\n    @click=\"$emit('handle-click', label)\"\n    data-testid=\"pv-suggestion-tag\"\n    style=\"max-width: 100%\"\n    :data-style=\"rounded ? 'rounded' : undefined\"\n    :data-wrap=\"wrap ? 'true' : undefined\"\n    :disabled=\"disabled\"\n    :title=\"label\"\n  >\n    <PvIcon data-testid=\"pv-suggestion-tag-icon\" v-if=\"icon\" :name=\"icon\" :size=\"12\" :class=\"iconClasses\" />\n    <span :class=\"{ 'pv-truncate': !wrap }\">\n      {{ label }}\n    </span>\n  </button>\n</template>\n","import dayjs from \"dayjs\";\nimport utc from \"dayjs/plugin/utc\";\nimport timezone from \"dayjs/plugin/timezone\";\n// advancedFormat adds the \"z\" token used to render the timezone abbreviation.\nimport advancedFormat from \"dayjs/plugin/advancedFormat\";\n\ndayjs.extend(advancedFormat);\ndayjs.extend(utc);\ndayjs.extend(timezone);\n\nexport const useDateTime = () => {\n  const getCondensedDate = ({ date }: { date: Date }) => {\n    return dayjs(date).format(\"MM/DD/YYYY\");\n  };\n\n  const getTime = ({ date, timezone }: { date: Date; timezone?: string }) => {\n    if (timezone === undefined) {\n      return dayjs(date).format(\"h:mm A\");\n    } else {\n      return dayjs(date).tz(timezone).format(\"h:mm A z\");\n    }\n  };\n\n  return {\n    getCondensedDate,\n    getTime,\n  };\n};\n","import { computed, ref, toValue, type ComputedRef, type MaybeRefOrGetter, type Ref } from \"vue\";\n\n/** Which edge of the resized element the handle sits on. */\nexport type PvResizeEdge = \"bottom\" | \"left\" | \"right\" | \"top\";\n\nexport type PvResizeAxis = \"horizontal\" | \"vertical\";\n\n/** A px number, a px string (\"320px\"), or a percentage of the containing block (\"30%\"). */\nexport type PvResizeSize = number | string;\n\n/** Handles on the left/right edges change width; handles on the top/bottom edges change height. */\nexport const pvResizeAxisFor = (edge: PvResizeEdge): PvResizeAxis =>\n  edge === \"left\" || edge === \"right\" ? \"horizontal\" : \"vertical\";\n\n/**\n * Resolve a `PvResizeSize` to pixels. Percentages resolve against `containerSize`,\n * which is the inner size of the resized element's containing block.\n *\n * Returns undefined for values that cannot be resolved, so callers can fall back\n * rather than silently treating a typo as 0.\n */\nexport const resolvePvResizeSize = (value: PvResizeSize | undefined, containerSize: number): number | undefined => {\n  if (value === undefined || value === null || value === \"\") return undefined;\n  if (typeof value === \"number\") return Number.isFinite(value) ? value : undefined;\n\n  const trimmed = value.trim();\n  if (trimmed.endsWith(\"%\")) {\n    const percent = Number.parseFloat(trimmed);\n    return Number.isFinite(percent) ? (percent / 100) * containerSize : undefined;\n  }\n\n  const parsed = Number.parseFloat(trimmed);\n  return Number.isFinite(parsed) ? parsed : undefined;\n};\n\nexport interface UseResizableOptions {\n  /** Size the element snaps to when collapsed. Only used when `collapsible` is true. */\n  collapsedSize?: MaybeRefOrGetter<number>;\n  /** Allow dragging past `min` to collapse, and toggling collapse from the keyboard. */\n  collapsible?: MaybeRefOrGetter<boolean>;\n  /** Expanded size to restore when no previous interaction has recorded one. */\n  defaultSize?: MaybeRefOrGetter<number>;\n  disabled?: MaybeRefOrGetter<boolean>;\n  edge?: MaybeRefOrGetter<PvResizeEdge>;\n  /** Pixels moved per arrow key press. Shift multiplies it. */\n  keyboardStep?: MaybeRefOrGetter<number>;\n  /** Accessible name for the separator. */\n  label?: MaybeRefOrGetter<string>;\n  max: MaybeRefOrGetter<number>;\n  min: MaybeRefOrGetter<number>;\n  /** Fired for every intermediate size during a drag. */\n  onResize?: (size: number) => void;\n  /** Fired once when an interaction settles. This is the hook to persist from. */\n  onResizeEnd?: (size: number) => void;\n  onResizeStart?: (size: number) => void;\n  /** Reads the element's current size in pixels at the moment an interaction starts. */\n  readSize: () => number;\n  /** How far past `min` a drag has to travel before it snaps to `collapsedSize`. */\n  snapThreshold?: MaybeRefOrGetter<number>;\n}\n\nexport interface UseResizableReturn {\n  handleProps: ComputedRef<Record<string, unknown>>;\n  isCollapsed: ComputedRef<boolean>;\n  isResizing: Readonly<Ref<boolean>>;\n  /** The size this composable last committed, in pixels. */\n  size: Readonly<Ref<number>>;\n  /**\n   * Point the composable at the element's current size, e.g. after the container\n   * resized underneath it. Pass the value when the caller already knows it: a\n   * `v-model` write only reads back on the next tick, so re-measuring here would\n   * pick up the size the element had before the write.\n   */\n  syncSize: (value?: number) => void;\n  toggleCollapsed: () => void;\n}\n\nconst SHIFT_STEP_MULTIPLIER = 4;\n\n/**\n * Drag, keyboard, and ARIA behavior for a single resize handle.\n *\n * The composable owns no DOM. It reads the current size through `readSize` and\n * reports new ones through the callbacks, so the same logic drives a controlled\n * `v-model:size` binding, a CSS custom property written straight onto an\n * element, or anything else a consumer wants to do with the number.\n *\n * Dragging uses Pointer Events with pointer capture rather than document-level\n * mouse listeners. That gives touch and pen support for free, keeps the drag\n * alive over iframes and cross-origin embeds, scopes the resize cursor to the\n * captured element instead of mutating document.body, and tears the listeners\n * down automatically when the pointer is lost.\n */\nexport const useResizable = (options: UseResizableOptions): UseResizableReturn => {\n  const isResizing = ref(false);\n  const size = ref(0);\n\n  let activePointerId: number | null = null;\n  let startCoordinate = 0;\n  let startSize = 0;\n  let lastExpandedSize: number | null = null;\n\n  const edge = computed<PvResizeEdge>(() => toValue(options.edge) ?? \"right\");\n  const axis = computed(() => pvResizeAxisFor(edge.value));\n  const isDisabled = computed(() => toValue(options.disabled) ?? false);\n  const isCollapsible = computed(() => toValue(options.collapsible) ?? false);\n  const collapsedSize = computed(() => toValue(options.collapsedSize) ?? 0);\n  const snapThreshold = computed(() => toValue(options.snapThreshold) ?? 0);\n  const keyboardStep = computed(() => toValue(options.keyboardStep) ?? 16);\n  const min = computed(() => toValue(options.min));\n  // A max below min would make the clamp order-dependent, so min always wins.\n  const max = computed(() => Math.max(min.value, toValue(options.max)));\n\n  // Dragging toward the bottom-right grows an element whose handle is on its\n  // right or bottom edge, and shrinks one whose handle is on the opposite side.\n  const directionSign = computed(() => (edge.value === \"right\" || edge.value === \"bottom\" ? 1 : -1));\n\n  const isCollapsed = computed(() => isCollapsible.value && size.value <= collapsedSize.value);\n\n  const constrain = (raw: number): number => {\n    if (isCollapsible.value && raw < min.value - snapThreshold.value) return collapsedSize.value;\n    return Math.min(max.value, Math.max(min.value, raw));\n  };\n\n  const commit = (next: number) => {\n    // Mid-drag sizes are pointer-sampling noise. Remembering one of them would\n    // make the size a collapsed element reopens to depend on where the pointer\n    // happened to be sampled on its way past `min`, so the drag path records its\n    // starting size on pointerdown instead.\n    if (!isResizing.value && next > collapsedSize.value) lastExpandedSize = next;\n    size.value = next;\n    options.onResize?.(next);\n  };\n\n  const syncSize = (value?: number) => {\n    size.value = value ?? options.readSize();\n  };\n\n  const toggleCollapsed = () => {\n    if (!isCollapsible.value) return;\n\n    // Read through rather than trusting the cached size: a toggle can be the\n    // very first interaction, before anything has been committed.\n    const current = options.readSize();\n    const collapsed = current <= collapsedSize.value;\n    if (!collapsed) lastExpandedSize = current;\n\n    const expanded = lastExpandedSize ?? toValue(options.defaultSize) ?? min.value;\n    const restored = expanded > collapsedSize.value ? expanded : collapsedSize.value + Math.max(1, keyboardStep.value);\n    const next = collapsed ? Math.min(max.value, Math.max(min.value, restored)) : collapsedSize.value;\n    commit(next);\n    options.onResizeEnd?.(next);\n  };\n\n  const onPointerdown = (event: PointerEvent) => {\n    // Secondary buttons open context menus; starting a drag from them strands\n    // the handle in a captured state the user never asked for.\n    if (isDisabled.value || event.button !== 0) return;\n\n    // Suppresses the text selection and native image drag that a mousedown\n    // would otherwise kick off underneath the handle.\n    event.preventDefault();\n\n    const target = event.currentTarget as HTMLElement;\n    activePointerId = event.pointerId;\n    target.setPointerCapture?.(event.pointerId);\n\n    startCoordinate = axis.value === \"horizontal\" ? event.clientX : event.clientY;\n    startSize = options.readSize();\n    size.value = startSize;\n    if (startSize > collapsedSize.value) lastExpandedSize = startSize;\n    isResizing.value = true;\n    options.onResizeStart?.(startSize);\n  };\n\n  const onPointermove = (event: PointerEvent) => {\n    if (!isResizing.value || event.pointerId !== activePointerId) return;\n    const coordinate = axis.value === \"horizontal\" ? event.clientX : event.clientY;\n    commit(constrain(startSize + (coordinate - startCoordinate) * directionSign.value));\n  };\n\n  const endDrag = (event: PointerEvent) => {\n    if (!isResizing.value || event.pointerId !== activePointerId) return;\n    const target = event.currentTarget as HTMLElement;\n    if (target.hasPointerCapture?.(event.pointerId)) target.releasePointerCapture(event.pointerId);\n    activePointerId = null;\n    isResizing.value = false;\n    options.onResizeEnd?.(size.value);\n  };\n\n  const onKeydown = (event: KeyboardEvent) => {\n    if (isDisabled.value) return;\n\n    if ((event.key === \"Enter\" || event.key === \" \") && isCollapsible.value) {\n      event.preventDefault();\n      toggleCollapsed();\n      return;\n    }\n\n    const horizontal = axis.value === \"horizontal\";\n    const step =\n      (event.shiftKey ? keyboardStep.value * SHIFT_STEP_MULTIPLIER : keyboardStep.value) * directionSign.value;\n    const current = options.readSize();\n    let next: number | undefined;\n\n    switch (event.key) {\n      case \"ArrowLeft\":\n        if (horizontal) next = current - step;\n        break;\n      case \"ArrowRight\":\n        if (horizontal) next = current + step;\n        break;\n      case \"ArrowUp\":\n        if (!horizontal) next = current - step;\n        break;\n      case \"ArrowDown\":\n        if (!horizontal) next = current + step;\n        break;\n      case \"Home\":\n        next = min.value;\n        break;\n      case \"End\":\n        next = max.value;\n        break;\n    }\n\n    if (next === undefined) return;\n\n    event.preventDefault();\n    // Home/End are absolute, so they must not be re-collapsed by the snap rule.\n    const resolved = event.key === \"Home\" || event.key === \"End\" ? next : constrain(next);\n    commit(resolved);\n    // Each keypress is a complete interaction, so consumers persisting on\n    // resize-end get one write per press rather than one per drag.\n    options.onResizeEnd?.(resolved);\n  };\n\n  const handleProps = computed<Record<string, unknown>>(() => ({\n    \"aria-disabled\": isDisabled.value || undefined,\n    \"aria-label\": toValue(options.label),\n    // A handle that moves along the horizontal axis draws a vertical separator.\n    \"aria-orientation\": axis.value === \"horizontal\" ? \"vertical\" : \"horizontal\",\n    \"aria-valuemax\": Math.round(max.value),\n    \"aria-valuemin\": Math.round(isCollapsible.value ? Math.min(min.value, collapsedSize.value) : min.value),\n    \"aria-valuenow\": Math.round(size.value),\n    \"aria-valuetext\": isCollapsed.value ? \"Collapsed\" : undefined,\n    \"data-pv-collapsed\": isCollapsed.value || undefined,\n    \"data-pv-resize-axis\": axis.value,\n    \"data-pv-resize-edge\": edge.value,\n    \"data-pv-resizing\": isResizing.value || undefined,\n    onKeydown,\n    onLostpointercapture: endDrag,\n    onPointercancel: endDrag,\n    onPointerdown,\n    onPointermove,\n    onPointerup: endDrag,\n    role: \"separator\",\n    tabindex: isDisabled.value ? -1 : 0,\n  }));\n\n  return {\n    handleProps,\n    isCollapsed,\n    isResizing,\n    size,\n    syncSize,\n    toggleCollapsed,\n  };\n};\n","<script setup lang=\"ts\">\nimport { computed, nextTick, onMounted, ref, useTemplateRef, watch } from \"vue\";\nimport { useElementSize, useWindowSize } from \"@vueuse/core\";\n\nimport { pvResizeAxisFor, resolvePvResizeSize, useResizable } from \"@/composables/useResizable\";\nimport type { PvResizeEvent, PvResizeHandleProps } from \"./types\";\n\nconst props = withDefaults(defineProps<PvResizeHandleProps>(), {\n  ariaLabel: \"Resize\",\n  collapsedSize: 0,\n  collapsible: false,\n  controlled: false,\n  disabled: false,\n  edge: \"right\",\n  keyboardStep: 16,\n  minSize: 0,\n  snapThreshold: 0,\n});\n\n/** The resolved size in pixels. Optional: bind it only if you want to drive the size yourself. */\nconst size = defineModel<number>(\"size\");\n\nconst emit = defineEmits<{\n  (e: \"resize\", event: PvResizeEvent): void;\n  (e: \"resize-end\", event: PvResizeEvent): void;\n  (e: \"resize-start\", event: PvResizeEvent): void;\n}>();\n\nconst handle = useTemplateRef<HTMLElement>(\"handle\");\nconst target = ref<HTMLElement | null>(null);\n// Initial bounds must not turn the natural content width into a model value\n// before the explicit, persisted, or default size has been resolved.\nlet initialized = false;\n\nconst axis = computed(() => pvResizeAxisFor(props.edge));\n\n/**\n * The element the handle resizes is simply its parent. In the web component\n * build the handle renders inside a shadow root, so the walk has to hop from\n * the root to its host before it lands back in the light DOM.\n */\nconst findTarget = (element: HTMLElement | null): HTMLElement | null => {\n  let node = (element?.parentNode ?? null) as (Node & { host?: Element }) | null;\n  while (node) {\n    if (node.nodeType === 1) return node as HTMLElement;\n    node = (node.host ? node.host.parentNode : node.parentNode) as (Node & { host?: Element }) | null;\n  }\n  return null;\n};\n\nconst container = computed(() => target.value?.parentElement ?? null);\nconst { height: containerHeight, width: containerWidth } = useElementSize(container);\nconst { height: viewportHeight, width: viewportWidth } = useWindowSize({ initialWidth: 0, initialHeight: 0 });\n\nconst measureContainer = () => {\n  const element = container.value;\n  if (!element) return 0;\n  const rect = element.getBoundingClientRect();\n  return axis.value === \"horizontal\" ? rect.width : rect.height;\n};\n\n/**\n * ResizeObserver reports asynchronously, so on the first frame the observed\n * size is still zero. A percentage default resolved against zero would pin the\n * element to its minimum before the user ever saw the intended layout, so fall\n * back to reading the box directly until the observer catches up.\n */\nconst containerSize = computed(() => {\n  const observed = axis.value === \"horizontal\" ? containerWidth.value : containerHeight.value;\n  return observed > 0 ? observed : measureContainer();\n});\n\nconst minPx = computed(() => resolvePvResizeSize(props.minSize, containerSize.value) ?? 0);\nconst collapsedPx = computed(() => resolvePvResizeSize(props.collapsedSize, containerSize.value) ?? 0);\n\n/**\n * With no `maxSize` the natural ceiling is the container. Before the container\n * has been measured, use the viewport rather than exposing an unbounded End key\n * and ARIA range. Percentage defaults still wait for the actual container.\n */\nconst maxPx = computed(() => {\n  const resolved = resolvePvResizeSize(props.maxSize, containerSize.value);\n  if (resolved !== undefined && resolved > 0) return resolved;\n  return containerSize.value > 0\n    ? containerSize.value\n    : axis.value === \"horizontal\"\n      ? viewportWidth.value\n      : viewportHeight.value;\n});\n\nconst clamp = (value: number) =>\n  props.collapsible && value === collapsedPx.value ? value : Math.max(minPx.value, Math.min(maxPx.value, value));\n\nconst measureTarget = () => {\n  const element = target.value;\n  if (!element) return 0;\n  const rect = element.getBoundingClientRect();\n  return axis.value === \"horizontal\" ? rect.width : rect.height;\n};\n\nconst readSize = () => size.value ?? measureTarget();\n\nconst applyToTarget = (next: number) => {\n  if (props.controlled) return;\n  target.value?.style.setProperty(\"--pv-resize-size\", `${next}px`);\n};\n\nconst toEvent = (value: number): PvResizeEvent => ({\n  collapsed: props.collapsible && value <= collapsedPx.value,\n  edge: props.edge,\n  size: value,\n});\n\n// Safari's private mode and hardened browser profiles throw on storage access,\n// which must never take the handle down with it.\nconst readStoredSize = (): Pick<PvResizeEvent, \"size\" | \"collapsed\"> | undefined => {\n  if (!props.storageKey || typeof window === \"undefined\") return undefined;\n  try {\n    const raw = window.localStorage.getItem(props.storageKey);\n    if (raw === null) return undefined;\n    const parsed: unknown = JSON.parse(raw);\n    // Keep accepting the original numeric storage format.\n    if (typeof parsed === \"number\" && Number.isFinite(parsed)) return { size: parsed, collapsed: false };\n    if (\n      parsed &&\n      typeof parsed === \"object\" &&\n      \"size\" in parsed &&\n      typeof parsed.size === \"number\" &&\n      Number.isFinite(parsed.size)\n    ) {\n      return { size: parsed.size, collapsed: \"collapsed\" in parsed && parsed.collapsed === true };\n    }\n    return undefined;\n  } catch {\n    return undefined;\n  }\n};\n\nconst persistSize = (value: number) => {\n  if (!props.storageKey || typeof window === \"undefined\") return;\n  try {\n    // Persist intent as well as pixels: a percentage collapse changes with the container.\n    const { size, collapsed } = toEvent(value);\n    window.localStorage.setItem(props.storageKey, JSON.stringify({ size, collapsed }));\n  } catch {\n    // Storage is unavailable; the size still applies for this session.\n  }\n};\n\nconst commitSize = (next: number) => {\n  applyToTarget(next);\n  size.value = next;\n};\n\nconst { handleProps, isResizing, syncSize } = useResizable({\n  collapsedSize: collapsedPx,\n  collapsible: () => props.collapsible,\n  defaultSize: () => resolvePvResizeSize(props.defaultSize, containerSize.value) ?? minPx.value,\n  disabled: () => props.disabled,\n  edge: () => props.edge,\n  keyboardStep: () => props.keyboardStep,\n  label: () => props.ariaLabel,\n  max: maxPx,\n  min: minPx,\n  onResize: (next) => {\n    commitSize(next);\n    emit(\"resize\", toEvent(next));\n  },\n  onResizeEnd: (next) => {\n    persistSize(next);\n    emit(\"resize-end\", toEvent(next));\n  },\n  onResizeStart: (next) => emit(\"resize-start\", toEvent(next)),\n  readSize,\n  snapThreshold: () => props.snapThreshold,\n});\n\n// Model writes can originate in the consumer, not just our interaction handlers.\n// Synchronize without emitting another resize or persisting an unfinished change.\nwatch(size, (next) => {\n  if (!initialized) {\n    initializeSize();\n    return;\n  }\n  if (next === undefined) return;\n  const clamped = clamp(next);\n  commitSize(clamped);\n  syncSize(clamped);\n});\n\n// `.pv-resizable` needs to know which dimension `--pv-resize-size` feeds.\nwatch([target, axis], ([element, currentAxis]) => element?.setAttribute(\"data-pv-resize-axis\", currentAxis), {\n  immediate: true,\n});\n\n// Suppresses width/height transitions on the target for the length of the drag,\n// so the element tracks the pointer instead of easing along behind it.\nwatch(isResizing, (resizing) => {\n  const element = target.value;\n  if (!element) return;\n  if (resizing) element.setAttribute(\"data-pv-resizing\", \"\");\n  else element.removeAttribute(\"data-pv-resizing\");\n});\n\n// The container can change size underneath a percentage bound, which moves the\n// clamp without anything having been dragged.\nwatch([minPx, maxPx, collapsedPx], ([, , collapsed], [, , previousCollapsed]) => {\n  if (!initialized || isResizing.value) return;\n  const current = readSize();\n  // Compare with the old threshold, before a percentage change can make an\n  // already-collapsed panel appear expanded.\n  const wasCollapsed = props.collapsible && current <= previousCollapsed;\n  if (current === 0 && !wasCollapsed) return;\n  const clamped = wasCollapsed ? collapsed : clamp(current);\n  if (clamped !== current) commitSize(clamped);\n  syncSize(clamped);\n});\n\nconst initializeSize = () => {\n  if (initialized || !target.value) return;\n  const stored = size.value === undefined ? readStoredSize() : undefined;\n  const source =\n    size.value ?? (stored?.collapsed && props.collapsible ? props.collapsedSize : stored?.size) ?? props.defaultSize;\n  if (typeof source === \"string\" && source.trim().endsWith(\"%\") && containerSize.value <= 0) return;\n  initialized = true;\n\n  const initial = resolvePvResizeSize(source, containerSize.value);\n  if (initial === undefined) {\n    const current = readSize();\n    const clamped = current === 0 ? 0 : clamp(current);\n    if (clamped !== current) commitSize(clamped);\n    syncSize(clamped);\n    return;\n  }\n\n  const clamped = clamp(initial);\n  commitSize(clamped);\n  syncSize(clamped);\n};\n\nwatch(containerSize, initializeSize);\nonMounted(async () => {\n  target.value = findTarget(handle.value);\n  await nextTick();\n  initializeSize();\n});\n</script>\n\n<template>\n  <div ref=\"handle\" class=\"pv-resize-handle\" data-testid=\"pv-resize-handle\" v-bind=\"handleProps\" />\n</template>\n","<script setup lang=\"ts\">\nimport { computed, nextTick, onMounted, ref, useTemplateRef, watch } from \"vue\";\nimport { useElementSize, useWindowSize } from \"@vueuse/core\";\n\nimport { pvResizeAxisFor, resolvePvResizeSize, useResizable } from \"@/composables/useResizable\";\nimport type { PvResizeEvent, PvResizeHandleProps } from \"./types\";\n\nconst props = withDefaults(defineProps<PvResizeHandleProps>(), {\n  ariaLabel: \"Resize\",\n  collapsedSize: 0,\n  collapsible: false,\n  controlled: false,\n  disabled: false,\n  edge: \"right\",\n  keyboardStep: 16,\n  minSize: 0,\n  snapThreshold: 0,\n});\n\n/** The resolved size in pixels. Optional: bind it only if you want to drive the size yourself. */\nconst size = defineModel<number>(\"size\");\n\nconst emit = defineEmits<{\n  (e: \"resize\", event: PvResizeEvent): void;\n  (e: \"resize-end\", event: PvResizeEvent): void;\n  (e: \"resize-start\", event: PvResizeEvent): void;\n}>();\n\nconst handle = useTemplateRef<HTMLElement>(\"handle\");\nconst target = ref<HTMLElement | null>(null);\n// Initial bounds must not turn the natural content width into a model value\n// before the explicit, persisted, or default size has been resolved.\nlet initialized = false;\n\nconst axis = computed(() => pvResizeAxisFor(props.edge));\n\n/**\n * The element the handle resizes is simply its parent. In the web component\n * build the handle renders inside a shadow root, so the walk has to hop from\n * the root to its host before it lands back in the light DOM.\n */\nconst findTarget = (element: HTMLElement | null): HTMLElement | null => {\n  let node = (element?.parentNode ?? null) as (Node & { host?: Element }) | null;\n  while (node) {\n    if (node.nodeType === 1) return node as HTMLElement;\n    node = (node.host ? node.host.parentNode : node.parentNode) as (Node & { host?: Element }) | null;\n  }\n  return null;\n};\n\nconst container = computed(() => target.value?.parentElement ?? null);\nconst { height: containerHeight, width: containerWidth } = useElementSize(container);\nconst { height: viewportHeight, width: viewportWidth } = useWindowSize({ initialWidth: 0, initialHeight: 0 });\n\nconst measureContainer = () => {\n  const element = container.value;\n  if (!element) return 0;\n  const rect = element.getBoundingClientRect();\n  return axis.value === \"horizontal\" ? rect.width : rect.height;\n};\n\n/**\n * ResizeObserver reports asynchronously, so on the first frame the observed\n * size is still zero. A percentage default resolved against zero would pin the\n * element to its minimum before the user ever saw the intended layout, so fall\n * back to reading the box directly until the observer catches up.\n */\nconst containerSize = computed(() => {\n  const observed = axis.value === \"horizontal\" ? containerWidth.value : containerHeight.value;\n  return observed > 0 ? observed : measureContainer();\n});\n\nconst minPx = computed(() => resolvePvResizeSize(props.minSize, containerSize.value) ?? 0);\nconst collapsedPx = computed(() => resolvePvResizeSize(props.collapsedSize, containerSize.value) ?? 0);\n\n/**\n * With no `maxSize` the natural ceiling is the container. Before the container\n * has been measured, use the viewport rather than exposing an unbounded End key\n * and ARIA range. Percentage defaults still wait for the actual container.\n */\nconst maxPx = computed(() => {\n  const resolved = resolvePvResizeSize(props.maxSize, containerSize.value);\n  if (resolved !== undefined && resolved > 0) return resolved;\n  return containerSize.value > 0\n    ? containerSize.value\n    : axis.value === \"horizontal\"\n      ? viewportWidth.value\n      : viewportHeight.value;\n});\n\nconst clamp = (value: number) =>\n  props.collapsible && value === collapsedPx.value ? value : Math.max(minPx.value, Math.min(maxPx.value, value));\n\nconst measureTarget = () => {\n  const element = target.value;\n  if (!element) return 0;\n  const rect = element.getBoundingClientRect();\n  return axis.value === \"horizontal\" ? rect.width : rect.height;\n};\n\nconst readSize = () => size.value ?? measureTarget();\n\nconst applyToTarget = (next: number) => {\n  if (props.controlled) return;\n  target.value?.style.setProperty(\"--pv-resize-size\", `${next}px`);\n};\n\nconst toEvent = (value: number): PvResizeEvent => ({\n  collapsed: props.collapsible && value <= collapsedPx.value,\n  edge: props.edge,\n  size: value,\n});\n\n// Safari's private mode and hardened browser profiles throw on storage access,\n// which must never take the handle down with it.\nconst readStoredSize = (): Pick<PvResizeEvent, \"size\" | \"collapsed\"> | undefined => {\n  if (!props.storageKey || typeof window === \"undefined\") return undefined;\n  try {\n    const raw = window.localStorage.getItem(props.storageKey);\n    if (raw === null) return undefined;\n    const parsed: unknown = JSON.parse(raw);\n    // Keep accepting the original numeric storage format.\n    if (typeof parsed === \"number\" && Number.isFinite(parsed)) return { size: parsed, collapsed: false };\n    if (\n      parsed &&\n      typeof parsed === \"object\" &&\n      \"size\" in parsed &&\n      typeof parsed.size === \"number\" &&\n      Number.isFinite(parsed.size)\n    ) {\n      return { size: parsed.size, collapsed: \"collapsed\" in parsed && parsed.collapsed === true };\n    }\n    return undefined;\n  } catch {\n    return undefined;\n  }\n};\n\nconst persistSize = (value: number) => {\n  if (!props.storageKey || typeof window === \"undefined\") return;\n  try {\n    // Persist intent as well as pixels: a percentage collapse changes with the container.\n    const { size, collapsed } = toEvent(value);\n    window.localStorage.setItem(props.storageKey, JSON.stringify({ size, collapsed }));\n  } catch {\n    // Storage is unavailable; the size still applies for this session.\n  }\n};\n\nconst commitSize = (next: number) => {\n  applyToTarget(next);\n  size.value = next;\n};\n\nconst { handleProps, isResizing, syncSize } = useResizable({\n  collapsedSize: collapsedPx,\n  collapsible: () => props.collapsible,\n  defaultSize: () => resolvePvResizeSize(props.defaultSize, containerSize.value) ?? minPx.value,\n  disabled: () => props.disabled,\n  edge: () => props.edge,\n  keyboardStep: () => props.keyboardStep,\n  label: () => props.ariaLabel,\n  max: maxPx,\n  min: minPx,\n  onResize: (next) => {\n    commitSize(next);\n    emit(\"resize\", toEvent(next));\n  },\n  onResizeEnd: (next) => {\n    persistSize(next);\n    emit(\"resize-end\", toEvent(next));\n  },\n  onResizeStart: (next) => emit(\"resize-start\", toEvent(next)),\n  readSize,\n  snapThreshold: () => props.snapThreshold,\n});\n\n// Model writes can originate in the consumer, not just our interaction handlers.\n// Synchronize without emitting another resize or persisting an unfinished change.\nwatch(size, (next) => {\n  if (!initialized) {\n    initializeSize();\n    return;\n  }\n  if (next === undefined) return;\n  const clamped = clamp(next);\n  commitSize(clamped);\n  syncSize(clamped);\n});\n\n// `.pv-resizable` needs to know which dimension `--pv-resize-size` feeds.\nwatch([target, axis], ([element, currentAxis]) => element?.setAttribute(\"data-pv-resize-axis\", currentAxis), {\n  immediate: true,\n});\n\n// Suppresses width/height transitions on the target for the length of the drag,\n// so the element tracks the pointer instead of easing along behind it.\nwatch(isResizing, (resizing) => {\n  const element = target.value;\n  if (!element) return;\n  if (resizing) element.setAttribute(\"data-pv-resizing\", \"\");\n  else element.removeAttribute(\"data-pv-resizing\");\n});\n\n// The container can change size underneath a percentage bound, which moves the\n// clamp without anything having been dragged.\nwatch([minPx, maxPx, collapsedPx], ([, , collapsed], [, , previousCollapsed]) => {\n  if (!initialized || isResizing.value) return;\n  const current = readSize();\n  // Compare with the old threshold, before a percentage change can make an\n  // already-collapsed panel appear expanded.\n  const wasCollapsed = props.collapsible && current <= previousCollapsed;\n  if (current === 0 && !wasCollapsed) return;\n  const clamped = wasCollapsed ? collapsed : clamp(current);\n  if (clamped !== current) commitSize(clamped);\n  syncSize(clamped);\n});\n\nconst initializeSize = () => {\n  if (initialized || !target.value) return;\n  const stored = size.value === undefined ? readStoredSize() : undefined;\n  const source =\n    size.value ?? (stored?.collapsed && props.collapsible ? props.collapsedSize : stored?.size) ?? props.defaultSize;\n  if (typeof source === \"string\" && source.trim().endsWith(\"%\") && containerSize.value <= 0) return;\n  initialized = true;\n\n  const initial = resolvePvResizeSize(source, containerSize.value);\n  if (initial === undefined) {\n    const current = readSize();\n    const clamped = current === 0 ? 0 : clamp(current);\n    if (clamped !== current) commitSize(clamped);\n    syncSize(clamped);\n    return;\n  }\n\n  const clamped = clamp(initial);\n  commitSize(clamped);\n  syncSize(clamped);\n};\n\nwatch(containerSize, initializeSize);\nonMounted(async () => {\n  target.value = findTarget(handle.value);\n  await nextTick();\n  initializeSize();\n});\n</script>\n\n<template>\n  <div ref=\"handle\" class=\"pv-resize-handle\" data-testid=\"pv-resize-handle\" v-bind=\"handleProps\" />\n</template>\n","<script setup lang=\"ts\">\nimport { watch, useTemplateRef, onMounted } from \"vue\";\nimport { onKeyStroke, onClickOutside, useWindowSize } from \"@vueuse/core\";\n\nimport PvSearchInput, { PvSearchInputProps } from \"../PvSearchInput/PvSearchInput.vue\";\nimport PvButton from \"../PvButton/PvButton.vue\";\nimport PvResizeHandle from \"../PvResizeHandle/PvResizeHandle.vue\";\nimport { resolvePvResizeSize, type PvResizeSize } from \"@/composables/useResizable\";\n\nexport interface PvDrawerProps {\n  closeOnClickOutside?: boolean;\n  /** Initial resizable width. Defaults to 600px, capped by the viewport. */\n  defaultWidth?: PvResizeSize;\n  header?: string;\n  /** Omit the built-in header when the drawer content provides its own. */\n  hideHeader?: boolean;\n  /** Defaults to the viewport width. Percentages resolve against the viewport. */\n  maxWidth?: PvResizeSize;\n  /** Only used when `resizable` is set. */\n  minWidth?: PvResizeSize;\n  /** Show a drag handle that resizes the drawer horizontally. */\n  resizable?: boolean;\n  /**\n   * Which edge carries the drag handle. A drawer docked on the right of the\n   * page is resized from its left edge, and vice versa.\n   */\n  resizeEdge?: \"left\" | \"right\";\n  /** When set, the drawer's width is persisted to localStorage under this key. */\n  resizeStorageKey?: string;\n  searchInputProps?: PvSearchInputProps;\n  showSearchbar?: boolean;\n  subheader?: string;\n}\n\n/**\n * @deprecated Use `PvDrawerProps` instead. Retained as an alias for backwards\n * compatibility with any existing imports of the props interface.\n */\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport interface PvDrawer extends PvDrawerProps {}\n\nconst props = withDefaults(defineProps<PvDrawerProps>(), {\n  closeOnClickOutside: false,\n  minWidth: 240,\n  resizable: false,\n  resizeEdge: \"left\",\n});\n\nconst emit = defineEmits<{\n  (e: \"click-outside\"): void;\n}>();\n\nconst sidePanel = useTemplateRef(\"sidePanel\");\nconst { width: viewportWidth } = useWindowSize({ initialWidth: 0 });\nconst searchInput = defineModel<string>(\"searchInput\", {\n  required: false,\n});\n/** The drawer's current width in pixels. Only meaningful when `resizable` is set. */\nconst width = defineModel<number>(\"width\", {\n  required: false,\n});\nconst showDrawer = defineModel<boolean>({\n  required: true,\n});\n\nconst handleClose = () => {\n  sidePanel?.value?.removeAttribute(\"open\");\n  showDrawer.value = false;\n};\n\nconst attachClickOutsideHandler = () => {\n  if (!sidePanel.value) return;\n\n  onClickOutside(\n    sidePanel.value,\n    () => {\n      if (showDrawer.value) {\n        emit(\"click-outside\");\n        handleClose();\n      }\n    },\n    { ignore: [\".pv-click-outside-ignore\"] },\n  );\n};\n\nonMounted(() => {\n  if (showDrawer.value) {\n    sidePanel?.value?.setAttribute(\"open\", \"true\");\n  }\n\n  if (props.closeOnClickOutside) {\n    attachClickOutsideHandler();\n  }\n});\n\nwatch(\n  () => showDrawer.value,\n  () => {\n    if (showDrawer.value) {\n      sidePanel?.value?.setAttribute(\"open\", \"true\");\n    } else {\n      sidePanel?.value?.removeAttribute(\"open\");\n    }\n  },\n);\n\nonKeyStroke(\"Escape\", () => {\n  if (sidePanel.value && showDrawer.value) {\n    handleClose();\n  }\n});\n</script>\n\n<template>\n  <div\n    class=\"pv-drawer pv-surface\"\n    :class=\"{ 'pv-resizable': resizable }\"\n    ref=\"sidePanel\"\n    data-testid=\"pv-drawer\"\n    style=\"display: flex; flex-direction: column; height: 100%\"\n  >\n    <PvResizeHandle\n      v-if=\"resizable\"\n      v-model:size=\"width\"\n      ariaLabel=\"Resize drawer\"\n      :defaultSize=\"resolvePvResizeSize(defaultWidth, viewportWidth) ?? Math.min(600, viewportWidth)\"\n      :edge=\"resizeEdge\"\n      :maxSize=\"resolvePvResizeSize(maxWidth, viewportWidth) ?? viewportWidth\"\n      :minSize=\"resolvePvResizeSize(minWidth, viewportWidth)\"\n      :storageKey=\"resizeStorageKey\"\n    />\n    <!-- Header Section (Fixed) -->\n    <div v-if=\"!hideHeader\" class=\"pv-inset-squish-12 pv-border-bottom\" style=\"flex-shrink: 0\">\n      <slot v-if=\"$slots.header\" name=\"header\" />\n      <template v-else>\n        <div class=\"pv-flex-vertical pv-stack-16\" style=\"--flex-align: flex-start\">\n          <div class=\"pv-flex pv-full-width\">\n            <span class=\"pv-full-width pv-heading-3\">{{ header }}</span>\n            <PvButton\n              left-icon=\"close\"\n              ariaLabel=\"Close\"\n              size=\"md\"\n              @click=\"handleClose\"\n              data-testid=\"pv-side-panel-close-button\"\n              variant=\"ghost\"\n            />\n          </div>\n          <span v-if=\"subheader\" class=\"pv-text-body-md\">{{ subheader }}</span>\n        </div>\n        <div v-if=\"showSearchbar && searchInput !== undefined\" class=\"pv-inset-inline-16\">\n          <PvSearchInput\n            data-testid=\"pv-side-panel-input-search\"\n            v-model=\"searchInput\"\n            v-bind=\"props.searchInputProps\"\n          />\n        </div>\n      </template>\n    </div>\n\n    <!-- Main Content Section (Scrollable) -->\n    <div class=\"pv-inset-inline-16\" style=\"flex: 1; overflow-y: auto; min-height: 0\">\n      <slot />\n    </div>\n\n    <!-- Footer Section (Fixed) -->\n    <div v-if=\"$slots.footer\" class=\"pv-inset-squish-12 pv-border-top\" style=\"flex-shrink: 0\">\n      <slot name=\"footer\" />\n    </div>\n  </div>\n</template>\n","<script setup lang=\"ts\">\nimport { watch, useTemplateRef, onMounted } from \"vue\";\nimport { onKeyStroke, onClickOutside, useWindowSize } from \"@vueuse/core\";\n\nimport PvSearchInput, { PvSearchInputProps } from \"../PvSearchInput/PvSearchInput.vue\";\nimport PvButton from \"../PvButton/PvButton.vue\";\nimport PvResizeHandle from \"../PvResizeHandle/PvResizeHandle.vue\";\nimport { resolvePvResizeSize, type PvResizeSize } from \"@/composables/useResizable\";\n\nexport interface PvDrawerProps {\n  closeOnClickOutside?: boolean;\n  /** Initial resizable width. Defaults to 600px, capped by the viewport. */\n  defaultWidth?: PvResizeSize;\n  header?: string;\n  /** Omit the built-in header when the drawer content provides its own. */\n  hideHeader?: boolean;\n  /** Defaults to the viewport width. Percentages resolve against the viewport. */\n  maxWidth?: PvResizeSize;\n  /** Only used when `resizable` is set. */\n  minWidth?: PvResizeSize;\n  /** Show a drag handle that resizes the drawer horizontally. */\n  resizable?: boolean;\n  /**\n   * Which edge carries the drag handle. A drawer docked on the right of the\n   * page is resized from its left edge, and vice versa.\n   */\n  resizeEdge?: \"left\" | \"right\";\n  /** When set, the drawer's width is persisted to localStorage under this key. */\n  resizeStorageKey?: string;\n  searchInputProps?: PvSearchInputProps;\n  showSearchbar?: boolean;\n  subheader?: string;\n}\n\n/**\n * @deprecated Use `PvDrawerProps` instead. Retained as an alias for backwards\n * compatibility with any existing imports of the props interface.\n */\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport interface PvDrawer extends PvDrawerProps {}\n\nconst props = withDefaults(defineProps<PvDrawerProps>(), {\n  closeOnClickOutside: false,\n  minWidth: 240,\n  resizable: false,\n  resizeEdge: \"left\",\n});\n\nconst emit = defineEmits<{\n  (e: \"click-outside\"): void;\n}>();\n\nconst sidePanel = useTemplateRef(\"sidePanel\");\nconst { width: viewportWidth } = useWindowSize({ initialWidth: 0 });\nconst searchInput = defineModel<string>(\"searchInput\", {\n  required: false,\n});\n/** The drawer's current width in pixels. Only meaningful when `resizable` is set. */\nconst width = defineModel<number>(\"width\", {\n  required: false,\n});\nconst showDrawer = defineModel<boolean>({\n  required: true,\n});\n\nconst handleClose = () => {\n  sidePanel?.value?.removeAttribute(\"open\");\n  showDrawer.value = false;\n};\n\nconst attachClickOutsideHandler = () => {\n  if (!sidePanel.value) return;\n\n  onClickOutside(\n    sidePanel.value,\n    () => {\n      if (showDrawer.value) {\n        emit(\"click-outside\");\n        handleClose();\n      }\n    },\n    { ignore: [\".pv-click-outside-ignore\"] },\n  );\n};\n\nonMounted(() => {\n  if (showDrawer.value) {\n    sidePanel?.value?.setAttribute(\"open\", \"true\");\n  }\n\n  if (props.closeOnClickOutside) {\n    attachClickOutsideHandler();\n  }\n});\n\nwatch(\n  () => showDrawer.value,\n  () => {\n    if (showDrawer.value) {\n      sidePanel?.value?.setAttribute(\"open\", \"true\");\n    } else {\n      sidePanel?.value?.removeAttribute(\"open\");\n    }\n  },\n);\n\nonKeyStroke(\"Escape\", () => {\n  if (sidePanel.value && showDrawer.value) {\n    handleClose();\n  }\n});\n</script>\n\n<template>\n  <div\n    class=\"pv-drawer pv-surface\"\n    :class=\"{ 'pv-resizable': resizable }\"\n    ref=\"sidePanel\"\n    data-testid=\"pv-drawer\"\n    style=\"display: flex; flex-direction: column; height: 100%\"\n  >\n    <PvResizeHandle\n      v-if=\"resizable\"\n      v-model:size=\"width\"\n      ariaLabel=\"Resize drawer\"\n      :defaultSize=\"resolvePvResizeSize(defaultWidth, viewportWidth) ?? Math.min(600, viewportWidth)\"\n      :edge=\"resizeEdge\"\n      :maxSize=\"resolvePvResizeSize(maxWidth, viewportWidth) ?? viewportWidth\"\n      :minSize=\"resolvePvResizeSize(minWidth, viewportWidth)\"\n      :storageKey=\"resizeStorageKey\"\n    />\n    <!-- Header Section (Fixed) -->\n    <div v-if=\"!hideHeader\" class=\"pv-inset-squish-12 pv-border-bottom\" style=\"flex-shrink: 0\">\n      <slot v-if=\"$slots.header\" name=\"header\" />\n      <template v-else>\n        <div class=\"pv-flex-vertical pv-stack-16\" style=\"--flex-align: flex-start\">\n          <div class=\"pv-flex pv-full-width\">\n            <span class=\"pv-full-width pv-heading-3\">{{ header }}</span>\n            <PvButton\n              left-icon=\"close\"\n              ariaLabel=\"Close\"\n              size=\"md\"\n              @click=\"handleClose\"\n              data-testid=\"pv-side-panel-close-button\"\n              variant=\"ghost\"\n            />\n          </div>\n          <span v-if=\"subheader\" class=\"pv-text-body-md\">{{ subheader }}</span>\n        </div>\n        <div v-if=\"showSearchbar && searchInput !== undefined\" class=\"pv-inset-inline-16\">\n          <PvSearchInput\n            data-testid=\"pv-side-panel-input-search\"\n            v-model=\"searchInput\"\n            v-bind=\"props.searchInputProps\"\n          />\n        </div>\n      </template>\n    </div>\n\n    <!-- Main Content Section (Scrollable) -->\n    <div class=\"pv-inset-inline-16\" style=\"flex: 1; overflow-y: auto; min-height: 0\">\n      <slot />\n    </div>\n\n    <!-- Footer Section (Fixed) -->\n    <div v-if=\"$slots.footer\" class=\"pv-inset-squish-12 pv-border-top\" style=\"flex-shrink: 0\">\n      <slot name=\"footer\" />\n    </div>\n  </div>\n</template>\n","<script setup lang=\"ts\">\nimport { PvTextAreaVariant } from \"./types\";\n\ninterface PvTextareaProps {\n  /** When true, applies invalid/error styling to the textarea and lower label. */\n  error?: boolean;\n  /** When true, the textarea is non-interactive and visually dimmed. */\n  disabled?: boolean;\n  /** Placeholder text shown when the textarea is empty. */\n  placeholder?: string;\n  /** HTML id for the textarea element. Auto-generated when omitted. */\n  id?: string;\n  /** Helper or validation text displayed below the textarea. Turns red when error is true. */\n  lowerLabel?: string;\n  /**\n   * Background color variant of the textarea.\n   */\n  variant?: PvTextAreaVariant;\n  /**\n   * Number of visible text rows.\n   */\n  rows?: number;\n}\n\nwithDefaults(defineProps<PvTextareaProps>(), {\n  id: Math.random().toString(),\n  variant: \"white\",\n  rows: 4,\n});\n\nconst value = defineModel<string>();\n</script>\n\n<template>\n  <div class=\"pv-flex-vertical\" style=\"--flex-align: flex-start\">\n    <label v-if=\"$slots.label\" class=\"pv-label\" :for=\"id\">\n      <slot name=\"label\" />\n    </label>\n    <textarea\n      v-bind=\"$attrs\"\n      v-model=\"value\"\n      :class=\"[\n        'pv-textarea',\n        {\n          'pv-surface-accent': variant === 'grey',\n        },\n      ]\"\n      :rows=\"rows\"\n      :disabled=\"disabled\"\n      :placeholder=\"placeholder\"\n      :id=\"id\"\n      :data-invalid=\"error ? true : undefined\"\n    />\n    <p\n      v-if=\"lowerLabel\"\n      style=\"margin-left: 12px\"\n      :class=\"[\n        'pv-text-body-xs',\n        {\n          'pv-text-red': error,\n          'pv-text-subdued': !error,\n        },\n      ]\"\n    >\n      {{ lowerLabel }}\n    </p>\n  </div>\n</template>\n","<script setup lang=\"ts\">\nimport { computed } from \"vue\";\nimport PvButton from \"../PvButton/PvButton.vue\";\nimport { MenuActionsVariant } from \"@/components/base/PvMultiSelectButton/types.ts\";\n\nconst props = defineProps<{\n  variant?: MenuActionsVariant;\n  disabled?: boolean;\n  /**\n   * Human-readable filter name used to derive `data-dd-action-name` on the\n   * Select All and Clear All buttons (e.g. \"Select all Payer Network options\",\n   * \"Clear Payer Network selections\"). Leave unset to skip the attributes.\n   * Cancel/Confirm intentionally don't get derived labels — the cancel-confirm\n   * variant has no production consumers today.\n   */\n  rumFilterName?: string;\n}>();\n\nconst rumSelectAllActionName = computed(() =>\n  props.rumFilterName ? `Select all ${props.rumFilterName} options` : undefined,\n);\nconst rumClearAllActionName = computed(() =>\n  props.rumFilterName ? `Clear ${props.rumFilterName} selections` : undefined,\n);\n\ndefineEmits<{\n  (e: \"handle-select-all\"): void;\n  (e: \"handle-clear-all\"): void;\n  (e: \"handle-cancel\"): void;\n  (e: \"handle-confirm\"): void;\n}>();\n</script>\n\n<template>\n  <div data-testid=\"pv-select-menu-control-panel\" class=\"pv-flex pv-space-between\">\n    <template v-if=\"variant === 'select-clear'\">\n      <PvButton\n        variant=\"ghost\"\n        data-testid=\"pv-select-menu-item-select-all\"\n        :data-dd-action-name=\"rumSelectAllActionName\"\n        @click=\"$emit('handle-select-all')\"\n        label=\"Select All\"\n        :disabled=\"disabled\"\n      />\n      <PvButton\n        label=\"Clear All\"\n        variant=\"ghost\"\n        data-testid=\"pv-select-menu-item-clear-all\"\n        :data-dd-action-name=\"rumClearAllActionName\"\n        @click=\"$emit('handle-clear-all')\"\n        :disabled=\"disabled\"\n      />\n    </template>\n    <template v-else-if=\"variant === 'cancel-confirm'\">\n      <PvButton\n        label=\"Cancel\"\n        variant=\"ghost\"\n        data-testid=\"pv-select-menu-item-cancel\"\n        @click=\"$emit('handle-cancel')\"\n        :disabled=\"disabled\"\n      />\n      <PvButton\n        label=\"Confirm\"\n        data-testid=\"pv-select-menu-item-confirm\"\n        @click=\"$emit('handle-confirm')\"\n        :disabled=\"disabled\"\n      />\n    </template>\n  </div>\n</template>\n","<script setup lang=\"ts\">\nimport { computed } from \"vue\";\nimport PvButton from \"../PvButton/PvButton.vue\";\nimport { MenuActionsVariant } from \"@/components/base/PvMultiSelectButton/types.ts\";\n\nconst props = defineProps<{\n  variant?: MenuActionsVariant;\n  disabled?: boolean;\n  /**\n   * Human-readable filter name used to derive `data-dd-action-name` on the\n   * Select All and Clear All buttons (e.g. \"Select all Payer Network options\",\n   * \"Clear Payer Network selections\"). Leave unset to skip the attributes.\n   * Cancel/Confirm intentionally don't get derived labels — the cancel-confirm\n   * variant has no production consumers today.\n   */\n  rumFilterName?: string;\n}>();\n\nconst rumSelectAllActionName = computed(() =>\n  props.rumFilterName ? `Select all ${props.rumFilterName} options` : undefined,\n);\nconst rumClearAllActionName = computed(() =>\n  props.rumFilterName ? `Clear ${props.rumFilterName} selections` : undefined,\n);\n\ndefineEmits<{\n  (e: \"handle-select-all\"): void;\n  (e: \"handle-clear-all\"): void;\n  (e: \"handle-cancel\"): void;\n  (e: \"handle-confirm\"): void;\n}>();\n</script>\n\n<template>\n  <div data-testid=\"pv-select-menu-control-panel\" class=\"pv-flex pv-space-between\">\n    <template v-if=\"variant === 'select-clear'\">\n      <PvButton\n        variant=\"ghost\"\n        data-testid=\"pv-select-menu-item-select-all\"\n        :data-dd-action-name=\"rumSelectAllActionName\"\n        @click=\"$emit('handle-select-all')\"\n        label=\"Select All\"\n        :disabled=\"disabled\"\n      />\n      <PvButton\n        label=\"Clear All\"\n        variant=\"ghost\"\n        data-testid=\"pv-select-menu-item-clear-all\"\n        :data-dd-action-name=\"rumClearAllActionName\"\n        @click=\"$emit('handle-clear-all')\"\n        :disabled=\"disabled\"\n      />\n    </template>\n    <template v-else-if=\"variant === 'cancel-confirm'\">\n      <PvButton\n        label=\"Cancel\"\n        variant=\"ghost\"\n        data-testid=\"pv-select-menu-item-cancel\"\n        @click=\"$emit('handle-cancel')\"\n        :disabled=\"disabled\"\n      />\n      <PvButton\n        label=\"Confirm\"\n        data-testid=\"pv-select-menu-item-confirm\"\n        @click=\"$emit('handle-confirm')\"\n        :disabled=\"disabled\"\n      />\n    </template>\n  </div>\n</template>\n","<script setup lang=\"ts\" generic=\"T\">\nimport { watch, useTemplateRef, computed, nextTick, shallowRef, provide } from \"vue\";\nimport { useToggle, onKeyStroke } from \"@vueuse/core\";\n\nimport { PvSearchInputExposed } from \"@/components/base/PvSearchInput/PvSearchInput.vue\";\nimport PvSelectControlPanel from \"../PvMenu/PvMenuControlPanel.vue\";\nimport PvSearchInput from \"../PvSearchInput/PvSearchInput.vue\";\nimport PvSelectButtonTrigger from \"@/components/base/PvSelectButton/PvSelectButtonTrigger/PvSelectButtonTrigger.vue\";\nimport PvMenuEmptyState from \"../PvMenu/PvMenuEmptyState.vue\";\nimport PvMenu from \"../PvMenu/PvMenu.vue\";\nimport PvSpinner from \"@/components/base/PvSpinner/PvSpinner.vue\";\n\nimport { PvMultiSelectButtonProps } from \"./types\";\nimport { MenuOption, MenuOptionConfig, MultiSelectState, SelectionNode, SeeMoreEvent } from \"@/types\";\nimport {\n  collectLeafOptions,\n  countFromSelectionState,\n  countWithCollapsedParents,\n  filterOptionsRecursive,\n  hasCascadeChildren,\n} from \"../PvMenu/cascadeUtils\";\nimport {\n  OriginalOptionsMapKey,\n  CascadeSelectedParentIdsKey,\n  CascadeDeselectedChildIdsKey,\n  ParentSelectsAllChildrenKey,\n  EnableChildExpansionKey,\n} from \"../PvMenu/symbols\";\nimport PvPopoverV2 from \"@/components/base/PvPopoverV2/PvPopoverV2.vue\";\nimport { useSlotPresence } from \"@/composables/useSlotPresence\";\n\nconst props = withDefaults(defineProps<PvMultiSelectButtonProps<T>>(), {\n  counterPosition: \"left\",\n  variant: \"secondary\",\n  size: \"lg\",\n  label: \"Select\",\n  disableDropdownIcon: false,\n  disableClearIcon: false,\n  disableSearchInput: false,\n  disabled: false,\n  optionsVariant: \"checkbox\",\n  options: () => [] as MenuOption<T>[],\n  menuActionsVariant: \"select-clear\",\n  footerPosition: \"above-actions\",\n  singleSelect: false,\n  highlightSearchText: false,\n  enableCascadeSelection: false,\n  counterStyle: \"primary\",\n});\n\nconst optionConfig = computed(() => {\n  const config: MenuOptionConfig = {\n    renderer: props.optionsRenderer,\n    action: props.optionsAction,\n    variant: props.optionsVariant,\n    counterBadgeVariant: props.counterBadgeVariant,\n    size: props.size,\n  };\n  return config;\n});\n\n// Build a map from option id → original (unfiltered) option so that descendants\n// can look up the full children list when parentSelectsAllChildren is true.\nconst originalOptionsMap = computed(() => {\n  const map = new Map<string, MenuOption<T>>();\n  const buildMap = (options: MenuOption<T>[]) => {\n    for (const option of options) {\n      map.set(option.id, option);\n      if (option.children?.length) buildMap(option.children);\n    }\n  };\n  buildMap(props.options);\n  return map;\n});\n\nconst cascadeSelectedParentIds = shallowRef<Set<string>>(new Set());\nconst cascadeDeselectedChildIds = shallowRef<Map<string, Set<string>>>(new Map());\n\nprovide(OriginalOptionsMapKey, originalOptionsMap);\nprovide(CascadeSelectedParentIdsKey, cascadeSelectedParentIds);\nprovide(CascadeDeselectedChildIdsKey, cascadeDeselectedChildIds);\nprovide(\n  ParentSelectsAllChildrenKey,\n  computed(() => props.parentSelectsAllChildren),\n);\nprovide(\n  EnableChildExpansionKey,\n  computed(() => !!props.enableChildExpansion),\n);\n\nconst emits = defineEmits<{\n  (e: \"dropdown-open\"): void;\n  (e: \"dropdown-closed\"): void;\n  (e: \"see-more\", payload: SeeMoreEvent): void;\n  (e: \"select-all\", valueCount: number): void;\n  (e: \"clear-all\", valueCount: number): void;\n}>();\n\n/** Pre-computed mapping of parent option ID → its leaf descendant options. */\nconst parentLeafMap = computed(() => {\n  const map = new Map<string, MenuOption<T>[]>();\n  for (const [id, option] of originalOptionsMap.value) {\n    if (hasCascadeChildren(option)) {\n      map.set(id, option.children ? collectLeafOptions(option.children) : []);\n    }\n  }\n  return map;\n});\n\nconst getSelectionState = (): MultiSelectState => {\n  const parentLeafIds = new Set<string>();\n  if (cascadeSelectedParentIds.value.size > 0) {\n    for (const parentId of cascadeSelectedParentIds.value) {\n      const leaves = parentLeafMap.value.get(parentId);\n      if (leaves) {\n        for (const leaf of leaves) parentLeafIds.add(leaf.id);\n      }\n    }\n  }\n\n  const nodes: SelectionNode[] = [];\n\n  for (const parentId of cascadeSelectedParentIds.value) {\n    const deselected = cascadeDeselectedChildIds.value.get(parentId);\n    const node: SelectionNode = { id: parentId, state: \"selected\" };\n    if (deselected?.size) {\n      node.children = [...deselected].map((childId) => ({\n        id: childId,\n        state: \"deselected\" as const,\n      }));\n    }\n    nodes.push(node);\n  }\n\n  for (const item of selectedItems.value) {\n    if (!parentLeafIds.has(item.id)) {\n      nodes.push({ id: item.id, state: \"selected\" });\n    }\n  }\n\n  return nodes;\n};\n\nconst hasMoreOptions = computed(() => {\n  if (props.hasMoreOptions != null) return props.hasMoreOptions;\n  if (props.totalOptionCount == null) return false;\n  return props.totalOptionCount > props.options.length;\n});\n\nconst counterValue = computed(() => {\n  const additional = props.additionalCounter ?? 0;\n  if (props.enableCascadeSelection && props.countSelectedParents && modelSelectionState.value?.length) {\n    return countFromSelectionState(modelSelectionState.value) + additional;\n  }\n  if (!props.countSelectedParents || !props.enableCascadeSelection) {\n    return selectedItems.value.length + additional;\n  }\n  const selectedIds = new Set(selectedItems.value.map((item) => item.id));\n  return countWithCollapsedParents(props.options, selectedIds) + additional;\n});\n\nconst hasSelection = computed(() => {\n  if (selectedItems.value.length > 0) return true;\n  if (props.enableCascadeSelection && modelSelectionState.value?.length) {\n    return modelSelectionState.value.some((node) => node.state === \"selected\");\n  }\n  return false;\n});\n\nconst handleSeeMore = (payload?: SeeMoreEvent) => {\n  emits(\"see-more\", payload ?? {});\n};\n\nconst searchInputComponentRef = useTemplateRef<PvSearchInputExposed | null>(\"searchInputRef\");\n\nconst [open, handleOpen] = useToggle<boolean>(props.defaultOpen);\nconst modelSelectedItems = defineModel<MenuOption<T>[]>({\n  required: false,\n  default: () => [],\n});\nconst modelSelectionState = defineModel<MultiSelectState>(\"selectionState\");\nconst searchInput = defineModel<string>(\"searchInput\", {\n  required: false,\n  default: \"\",\n});\n\nconst suppressChangesUntilConfirmed = computed(() => {\n  return props.menuActionsVariant === \"cancel-confirm\";\n});\n\nconst storeSelectedItems = (newSelection: MenuOption<T>[]) => {\n  selectedItems.value = newSelection;\n  if (!suppressChangesUntilConfirmed.value) {\n    modelSelectedItems.value = newSelection;\n    modelSelectionState.value = getSelectionState();\n  }\n};\n\nconst applyPendingSelection = () => {\n  if (suppressChangesUntilConfirmed.value) {\n    modelSelectedItems.value = selectedItems.value;\n    modelSelectionState.value = getSelectionState();\n  }\n};\n\nconst resetPendingSelection = () => {\n  if (suppressChangesUntilConfirmed.value) {\n    selectedItems.value = modelSelectedItems.value;\n  }\n};\n\n// with cancel-confirm, we hold changes until confirmed\nconst selectedItems = shallowRef<MenuOption<T>[]>(modelSelectedItems.value);\n\nconst findOptionById = (id: string): MenuOption<T> | undefined => originalOptionsMap.value.get(id);\n\nconst syncFromSelectionState = (state: MultiSelectState | undefined) => {\n  if (!props.enableCascadeSelection || !state) return;\n\n  const nextSelectedParents = new Set<string>();\n  const nextDeselectedChildren = new Map<string, Set<string>>();\n  const nextSelectedItems: MenuOption<T>[] = [];\n  const selectedIds = new Set<string>();\n\n  const addSelectedItem = (option: MenuOption<T> | undefined, id: string) => {\n    if (selectedIds.has(id)) return;\n    selectedIds.add(id);\n    // Placeholder for unresolved nodes — the trigger badge prefers `…` over the\n    // raw scoped token (e.g. `__provider_id__PV_1004__health_system__Kaiser`)\n    // until the props.options watcher re-runs this sync with metadata loaded.\n    nextSelectedItems.push(option ?? ({ id, text: \"…\" } as MenuOption<T>));\n  };\n\n  for (const node of state) {\n    if (node.state !== \"selected\") continue;\n\n    const deselectedIds = new Set(\n      (node.children || []).filter((child) => child.state === \"deselected\").map((child) => child.id),\n    );\n    const leafOptions = parentLeafMap.value.get(node.id);\n\n    if (leafOptions) {\n      nextSelectedParents.add(node.id);\n      if (deselectedIds.size > 0) {\n        nextDeselectedChildren.set(node.id, deselectedIds);\n      }\n      for (const leaf of leafOptions) {\n        if (!deselectedIds.has(leaf.id)) {\n          addSelectedItem(leaf, leaf.id);\n        }\n      }\n      continue;\n    }\n\n    addSelectedItem(findOptionById(node.id), node.id);\n  }\n\n  cascadeSelectedParentIds.value = nextSelectedParents;\n  cascadeDeselectedChildIds.value = nextDeselectedChildren;\n  selectedItems.value = nextSelectedItems;\n};\n\nconst menuSelectedItems = computed({\n  get: () => selectedItems.value,\n  set: (newValue: MenuOption<T>[]) => {\n    storeSelectedItems(newValue);\n  },\n});\n\nconst closeDropdown = () => {\n  searchInput.value = \"\";\n  open.value = false;\n};\n\nconst popoverOffset = computed(() => {\n  // get width of trigger element to offset popover correctly when overlay trigger is enabled\n  const size = props.size === \"lg\" ? 24 : 30;\n  return props.overlayTrigger ? -size : undefined;\n});\n\n// sync when parent updates modelSelectedItems directly\nwatch(\n  () => modelSelectedItems.value,\n  (newValue) => {\n    if (props.enableCascadeSelection && modelSelectionState.value?.length && newValue.length === 0) {\n      syncFromSelectionState(modelSelectionState.value);\n      return;\n    }\n    selectedItems.value = newValue;\n  },\n);\n\nwatch(\n  () => [modelSelectionState.value, props.options] as const,\n  () => {\n    syncFromSelectionState(modelSelectionState.value);\n  },\n  { deep: true, immediate: true },\n);\n\nwatch(open, (newValue) => {\n  if (newValue) {\n    resetPendingSelection();\n    nextTick(() => {\n      // if overlay trigger is enabled and search input exists, auto-target the search input\n      if (props.overlayTrigger && !props.disableSearchInput) {\n        searchInputComponentRef.value?.input?.focus();\n      }\n      emits(\"dropdown-open\");\n    });\n  } else {\n    // on close, discard pending changes\n    resetPendingSelection();\n    emits(\"dropdown-closed\");\n  }\n});\n\nconst filteredOptions = computed(() => {\n  if (searchInput.value === \"\") return props.options;\n  const searchValue = searchInput.value.toLocaleLowerCase();\n\n  if (props.enableCascadeSelection) {\n    return filterOptionsRecursive(props.options, searchValue, !props.hideParentOnChildQueryMatch);\n  }\n\n  return props.options.filter(\n    (option) =>\n      option.text.toLocaleLowerCase().includes(searchValue) ||\n      option.searchText?.toLocaleLowerCase().includes(searchValue),\n  );\n});\n\nconst handleSelectAll = () => {\n  // Mark all parents as cascade-selected (select-all intent) before\n  // storing so the selection state snapshot is accurate.\n  if (props.enableCascadeSelection) {\n    const parentIds = new Set<string>();\n    const collectParentIds = (options: MenuOption<T>[]) => {\n      for (const option of options) {\n        if (hasCascadeChildren(option)) {\n          parentIds.add(option.id);\n          if (option.children?.length) collectParentIds(option.children);\n        }\n      }\n    };\n    collectParentIds(filteredOptions.value as MenuOption<T>[]);\n    cascadeSelectedParentIds.value = parentIds;\n    cascadeDeselectedChildIds.value = new Map();\n  }\n\n  // select all visible item values (excluded ones filtered out by search)\n  const toSelect = props.enableCascadeSelection\n    ? collectLeafOptions(filteredOptions.value as MenuOption<T>[])\n    : filteredOptions.value;\n  emits(\"select-all\", toSelect.length);\n  storeSelectedItems(toSelect);\n};\n\nconst handleClearAll = () => {\n  emits(\"clear-all\", selectedItems.value.length);\n  cascadeSelectedParentIds.value = new Set();\n  cascadeDeselectedChildIds.value = new Map();\n  storeSelectedItems([]);\n};\n\nconst handleCancelSelection = () => {\n  resetPendingSelection();\n  closeDropdown();\n};\n\nconst handleConfirmSelection = () => {\n  applyPendingSelection();\n  closeDropdown();\n};\n\nconst groupingOptions = computed(() => {\n  if (!props.groupings) return;\n\n  const groupingMap = new Map<string, MenuOption[]>();\n\n  props.groupings.forEach((group) => {\n    groupingMap.set(group, []);\n  });\n\n  groupingMap.set(\"other\", []);\n\n  for (const option of props.options) {\n    const groupKey = option.groupingLabel;\n    const targetGroup = groupKey && groupingMap.has(groupKey) ? groupKey : \"other\";\n    groupingMap.get(targetGroup)!.push(option);\n  }\n\n  for (const [key, options] of groupingMap) {\n    if (options.length === 0) {\n      groupingMap.delete(key);\n    }\n  }\n\n  return Array.from(groupingMap.entries());\n});\n\nconst showGroupings = computed(() => {\n  return props.groupings && searchInput.value === \"\";\n});\n\nconst allSlotProps = computed(() => ({\n  ...props,\n  selectedItems: modelSelectedItems.value,\n  searchInput: searchInput.value,\n  slotContext: props.slotContext,\n  isOpen: open.value,\n  isLoading: props.isLoading,\n  filteredOptionCount: filteredOptions.value.length,\n}));\n\n// Derive a distinct name for this RUM action. Leave undefined to suppress.\nconst rumTriggerActionName = computed(() => {\n  if (props.rumActionName) return props.rumActionName;\n  return props.rumFilterName ? `Open ${props.rumFilterName} filter` : undefined;\n});\nconst rumSearchActionName = computed(() => (props.rumFilterName ? `Search ${props.rumFilterName} options` : undefined));\n\nconst popoverContentRef = useTemplateRef<HTMLElement | null>(\"popoverContentRef\");\nconst slotHost = computed(() => {\n  const rootNode = popoverContentRef.value?.getRootNode();\n  return rootNode instanceof ShadowRoot ? (rootNode.host as HTMLElement) : null;\n});\nconst { present: hasHeaderSlot } = useSlotPresence(\"header\", { host: slotHost });\nconst { present: hasNoResultsSlot } = useSlotPresence(\"no-results\", { host: slotHost });\nconst { present: hasFooterSlot } = useSlotPresence(\"footer\", { host: slotHost });\n\nonKeyStroke(\"Escape\", () => {\n  if (!open.value) return;\n\n  closeDropdown();\n});\n</script>\n\n<template>\n  <PvPopoverV2 v-model=\"open\" v-bind=\"popoverProperties\" :offset=\"popoverOffset\">\n    <template #trigger>\n      <PvSelectButtonTrigger\n        ref=\"select-button-trigger-ref\"\n        :variant=\"variant\"\n        :size=\"size\"\n        :disabled=\"disabled\"\n        :counterPosition=\"counterPosition\"\n        :prefixLabel=\"prefixLabel\"\n        :label=\"label\"\n        :icon=\"icon\"\n        :companyLogo=\"companyLogo\"\n        :showClear=\"!disableClearIcon && hasSelection && !disabled\"\n        :showDropdown=\"!disableDropdownIcon && (disabled || !(hasSelection && !disableClearIcon))\"\n        :open=\"open\"\n        :counter-value=\"counterValue\"\n        :counter-style=\"counterStyle\"\n        :selected-items=\"selectedItems\"\n        :data-dd-action-name=\"rumTriggerActionName\"\n        @handle-clear=\"handleClearAll\"\n        @handle-toggle-dropdown=\"handleOpen()\"\n      />\n    </template>\n    <template #content>\n      <div\n        ref=\"popoverContentRef\"\n        class=\"pv-popover\"\n        data-test-id=\"pv-popover\"\n        :style=\"{ '--position': 'unset', ...popoverCssProperties }\"\n      >\n        <template v-if=\"!disableSearchInput\">\n          <div class=\"pv-inset-square-8 pv-border-bottom\" :data-dd-action-name=\"rumSearchActionName\">\n            <PvSearchInput\n              ref=\"searchInputRef\"\n              v-model:model-value=\"searchInput\"\n              class=\"pv-stack-4\"\n              :placeholder=\"searchPlaceholder\"\n            />\n          </div>\n        </template>\n        <div v-if=\"$slots.header || hasHeaderSlot\" class=\"pv-inset-square-8\">\n          <slot name=\"header\" v-bind=\"allSlotProps\" />\n        </div>\n        <template v-if=\"filteredOptions.length > 0\">\n          <template v-if=\"showGroupings\">\n            <div v-for=\"([label, options], index) in groupingOptions\" :key=\"label\">\n              <slot v-if=\"$slots[label]\" :name=\"label\" />\n              <span\n                class=\"pv-text-body-sm pv-inset-inline\"\n                style=\"color: var(--color-text-quaternary, #89989b); --inset-size: 8px\"\n                v-else-if=\"label !== 'other'\"\n                >{{ label }}</span\n              >\n              <PvMenu\n                v-model:selectedItems=\"menuSelectedItems\"\n                :options=\"options\"\n                :config=\"optionConfig\"\n                :singleSelect=\"singleSelect\"\n                :queryText=\"highlightSearchText ? searchInput : null\"\n                :itemTestId=\"`pv-multiselect-${label}-item`\"\n                itemClass=\"pv-stack-4\"\n                :isLoading=\"isLoading\"\n                :isSeeMoreLoading=\"isSeeMoreLoading\"\n                :enableCascadeSelection=\"enableCascadeSelection\"\n                :hasMoreOptions=\"index === groupingOptions!.length - 1 && hasMoreOptions && !isLoading\"\n                @see-more=\"handleSeeMore\"\n              />\n              <div\n                v-if=\"groupingOptions && index !== groupingOptions.length - 1\"\n                class=\"pv-border-top\"\n                style=\"margin: 8px 0\"\n              />\n            </div>\n          </template>\n          <template v-else>\n            <PvMenu\n              v-model:selectedItems=\"menuSelectedItems\"\n              :options=\"filteredOptions\"\n              :config=\"optionConfig\"\n              :singleSelect=\"singleSelect\"\n              :queryText=\"highlightSearchText ? searchInput : null\"\n              :itemTestId=\"`pv-multiselect-${label}-item`\"\n              itemClass=\"pv-stack-4\"\n              :enableCascadeSelection=\"enableCascadeSelection\"\n              :isSeeMoreLoading=\"isSeeMoreLoading\"\n              :hasMoreOptions=\"hasMoreOptions && !isLoading\"\n              @see-more=\"handleSeeMore\"\n            />\n          </template>\n        </template>\n        <div\n          v-if=\"isLoading\"\n          class=\"pv-flex pv-inset-square-8 pv-text-body-sm pv-text-subdued\"\n          style=\"justify-content: center\"\n        >\n          <PvSpinner variant=\"dark\" />\n          <span v-if=\"loadingText\">{{ loadingText }}</span>\n        </div>\n        <template v-else-if=\"filteredOptions.length === 0\">\n          <slot v-if=\"hasNoResultsSlot\" name=\"no-results\" v-bind=\"allSlotProps\" />\n          <PvMenuEmptyState v-else />\n        </template>\n        <!-- Only when there is something to put in it, or a bordered empty bar is left behind. -->\n        <div\n          v-if=\"hasFooterSlot || menuActionsVariant\"\n          class=\"pv-sticky pv-surface pv-border-top pv-inset-square-8\"\n          :class=\"{ 'pv-flow-8': footerPosition === 'below-actions' }\"\n          style=\"--flex-justify: space-between; --bottom: 0\"\n        >\n          <slot v-if=\"hasFooterSlot && footerPosition === 'above-actions'\" name=\"footer\" v-bind=\"allSlotProps\" />\n          <PvSelectControlPanel\n            v-if=\"menuActionsVariant\"\n            :variant=\"menuActionsVariant\"\n            :disabled=\"isLoading\"\n            :rumFilterName=\"rumFilterName\"\n            @handle-clear-all=\"handleClearAll\"\n            @handle-select-all=\"handleSelectAll\"\n            @handle-cancel=\"handleCancelSelection\"\n            @handle-confirm=\"handleConfirmSelection\"\n          />\n          <slot v-if=\"hasFooterSlot && footerPosition === 'below-actions'\" name=\"footer\" v-bind=\"allSlotProps\" />\n        </div>\n      </div>\n    </template>\n  </PvPopoverV2>\n</template>\n","<script setup lang=\"ts\" generic=\"T\">\nimport { watch, useTemplateRef, computed, nextTick, shallowRef, provide } from \"vue\";\nimport { useToggle, onKeyStroke } from \"@vueuse/core\";\n\nimport { PvSearchInputExposed } from \"@/components/base/PvSearchInput/PvSearchInput.vue\";\nimport PvSelectControlPanel from \"../PvMenu/PvMenuControlPanel.vue\";\nimport PvSearchInput from \"../PvSearchInput/PvSearchInput.vue\";\nimport PvSelectButtonTrigger from \"@/components/base/PvSelectButton/PvSelectButtonTrigger/PvSelectButtonTrigger.vue\";\nimport PvMenuEmptyState from \"../PvMenu/PvMenuEmptyState.vue\";\nimport PvMenu from \"../PvMenu/PvMenu.vue\";\nimport PvSpinner from \"@/components/base/PvSpinner/PvSpinner.vue\";\n\nimport { PvMultiSelectButtonProps } from \"./types\";\nimport { MenuOption, MenuOptionConfig, MultiSelectState, SelectionNode, SeeMoreEvent } from \"@/types\";\nimport {\n  collectLeafOptions,\n  countFromSelectionState,\n  countWithCollapsedParents,\n  filterOptionsRecursive,\n  hasCascadeChildren,\n} from \"../PvMenu/cascadeUtils\";\nimport {\n  OriginalOptionsMapKey,\n  CascadeSelectedParentIdsKey,\n  CascadeDeselectedChildIdsKey,\n  ParentSelectsAllChildrenKey,\n  EnableChildExpansionKey,\n} from \"../PvMenu/symbols\";\nimport PvPopoverV2 from \"@/components/base/PvPopoverV2/PvPopoverV2.vue\";\nimport { useSlotPresence } from \"@/composables/useSlotPresence\";\n\nconst props = withDefaults(defineProps<PvMultiSelectButtonProps<T>>(), {\n  counterPosition: \"left\",\n  variant: \"secondary\",\n  size: \"lg\",\n  label: \"Select\",\n  disableDropdownIcon: false,\n  disableClearIcon: false,\n  disableSearchInput: false,\n  disabled: false,\n  optionsVariant: \"checkbox\",\n  options: () => [] as MenuOption<T>[],\n  menuActionsVariant: \"select-clear\",\n  footerPosition: \"above-actions\",\n  singleSelect: false,\n  highlightSearchText: false,\n  enableCascadeSelection: false,\n  counterStyle: \"primary\",\n});\n\nconst optionConfig = computed(() => {\n  const config: MenuOptionConfig = {\n    renderer: props.optionsRenderer,\n    action: props.optionsAction,\n    variant: props.optionsVariant,\n    counterBadgeVariant: props.counterBadgeVariant,\n    size: props.size,\n  };\n  return config;\n});\n\n// Build a map from option id → original (unfiltered) option so that descendants\n// can look up the full children list when parentSelectsAllChildren is true.\nconst originalOptionsMap = computed(() => {\n  const map = new Map<string, MenuOption<T>>();\n  const buildMap = (options: MenuOption<T>[]) => {\n    for (const option of options) {\n      map.set(option.id, option);\n      if (option.children?.length) buildMap(option.children);\n    }\n  };\n  buildMap(props.options);\n  return map;\n});\n\nconst cascadeSelectedParentIds = shallowRef<Set<string>>(new Set());\nconst cascadeDeselectedChildIds = shallowRef<Map<string, Set<string>>>(new Map());\n\nprovide(OriginalOptionsMapKey, originalOptionsMap);\nprovide(CascadeSelectedParentIdsKey, cascadeSelectedParentIds);\nprovide(CascadeDeselectedChildIdsKey, cascadeDeselectedChildIds);\nprovide(\n  ParentSelectsAllChildrenKey,\n  computed(() => props.parentSelectsAllChildren),\n);\nprovide(\n  EnableChildExpansionKey,\n  computed(() => !!props.enableChildExpansion),\n);\n\nconst emits = defineEmits<{\n  (e: \"dropdown-open\"): void;\n  (e: \"dropdown-closed\"): void;\n  (e: \"see-more\", payload: SeeMoreEvent): void;\n  (e: \"select-all\", valueCount: number): void;\n  (e: \"clear-all\", valueCount: number): void;\n}>();\n\n/** Pre-computed mapping of parent option ID → its leaf descendant options. */\nconst parentLeafMap = computed(() => {\n  const map = new Map<string, MenuOption<T>[]>();\n  for (const [id, option] of originalOptionsMap.value) {\n    if (hasCascadeChildren(option)) {\n      map.set(id, option.children ? collectLeafOptions(option.children) : []);\n    }\n  }\n  return map;\n});\n\nconst getSelectionState = (): MultiSelectState => {\n  const parentLeafIds = new Set<string>();\n  if (cascadeSelectedParentIds.value.size > 0) {\n    for (const parentId of cascadeSelectedParentIds.value) {\n      const leaves = parentLeafMap.value.get(parentId);\n      if (leaves) {\n        for (const leaf of leaves) parentLeafIds.add(leaf.id);\n      }\n    }\n  }\n\n  const nodes: SelectionNode[] = [];\n\n  for (const parentId of cascadeSelectedParentIds.value) {\n    const deselected = cascadeDeselectedChildIds.value.get(parentId);\n    const node: SelectionNode = { id: parentId, state: \"selected\" };\n    if (deselected?.size) {\n      node.children = [...deselected].map((childId) => ({\n        id: childId,\n        state: \"deselected\" as const,\n      }));\n    }\n    nodes.push(node);\n  }\n\n  for (const item of selectedItems.value) {\n    if (!parentLeafIds.has(item.id)) {\n      nodes.push({ id: item.id, state: \"selected\" });\n    }\n  }\n\n  return nodes;\n};\n\nconst hasMoreOptions = computed(() => {\n  if (props.hasMoreOptions != null) return props.hasMoreOptions;\n  if (props.totalOptionCount == null) return false;\n  return props.totalOptionCount > props.options.length;\n});\n\nconst counterValue = computed(() => {\n  const additional = props.additionalCounter ?? 0;\n  if (props.enableCascadeSelection && props.countSelectedParents && modelSelectionState.value?.length) {\n    return countFromSelectionState(modelSelectionState.value) + additional;\n  }\n  if (!props.countSelectedParents || !props.enableCascadeSelection) {\n    return selectedItems.value.length + additional;\n  }\n  const selectedIds = new Set(selectedItems.value.map((item) => item.id));\n  return countWithCollapsedParents(props.options, selectedIds) + additional;\n});\n\nconst hasSelection = computed(() => {\n  if (selectedItems.value.length > 0) return true;\n  if (props.enableCascadeSelection && modelSelectionState.value?.length) {\n    return modelSelectionState.value.some((node) => node.state === \"selected\");\n  }\n  return false;\n});\n\nconst handleSeeMore = (payload?: SeeMoreEvent) => {\n  emits(\"see-more\", payload ?? {});\n};\n\nconst searchInputComponentRef = useTemplateRef<PvSearchInputExposed | null>(\"searchInputRef\");\n\nconst [open, handleOpen] = useToggle<boolean>(props.defaultOpen);\nconst modelSelectedItems = defineModel<MenuOption<T>[]>({\n  required: false,\n  default: () => [],\n});\nconst modelSelectionState = defineModel<MultiSelectState>(\"selectionState\");\nconst searchInput = defineModel<string>(\"searchInput\", {\n  required: false,\n  default: \"\",\n});\n\nconst suppressChangesUntilConfirmed = computed(() => {\n  return props.menuActionsVariant === \"cancel-confirm\";\n});\n\nconst storeSelectedItems = (newSelection: MenuOption<T>[]) => {\n  selectedItems.value = newSelection;\n  if (!suppressChangesUntilConfirmed.value) {\n    modelSelectedItems.value = newSelection;\n    modelSelectionState.value = getSelectionState();\n  }\n};\n\nconst applyPendingSelection = () => {\n  if (suppressChangesUntilConfirmed.value) {\n    modelSelectedItems.value = selectedItems.value;\n    modelSelectionState.value = getSelectionState();\n  }\n};\n\nconst resetPendingSelection = () => {\n  if (suppressChangesUntilConfirmed.value) {\n    selectedItems.value = modelSelectedItems.value;\n  }\n};\n\n// with cancel-confirm, we hold changes until confirmed\nconst selectedItems = shallowRef<MenuOption<T>[]>(modelSelectedItems.value);\n\nconst findOptionById = (id: string): MenuOption<T> | undefined => originalOptionsMap.value.get(id);\n\nconst syncFromSelectionState = (state: MultiSelectState | undefined) => {\n  if (!props.enableCascadeSelection || !state) return;\n\n  const nextSelectedParents = new Set<string>();\n  const nextDeselectedChildren = new Map<string, Set<string>>();\n  const nextSelectedItems: MenuOption<T>[] = [];\n  const selectedIds = new Set<string>();\n\n  const addSelectedItem = (option: MenuOption<T> | undefined, id: string) => {\n    if (selectedIds.has(id)) return;\n    selectedIds.add(id);\n    // Placeholder for unresolved nodes — the trigger badge prefers `…` over the\n    // raw scoped token (e.g. `__provider_id__PV_1004__health_system__Kaiser`)\n    // until the props.options watcher re-runs this sync with metadata loaded.\n    nextSelectedItems.push(option ?? ({ id, text: \"…\" } as MenuOption<T>));\n  };\n\n  for (const node of state) {\n    if (node.state !== \"selected\") continue;\n\n    const deselectedIds = new Set(\n      (node.children || []).filter((child) => child.state === \"deselected\").map((child) => child.id),\n    );\n    const leafOptions = parentLeafMap.value.get(node.id);\n\n    if (leafOptions) {\n      nextSelectedParents.add(node.id);\n      if (deselectedIds.size > 0) {\n        nextDeselectedChildren.set(node.id, deselectedIds);\n      }\n      for (const leaf of leafOptions) {\n        if (!deselectedIds.has(leaf.id)) {\n          addSelectedItem(leaf, leaf.id);\n        }\n      }\n      continue;\n    }\n\n    addSelectedItem(findOptionById(node.id), node.id);\n  }\n\n  cascadeSelectedParentIds.value = nextSelectedParents;\n  cascadeDeselectedChildIds.value = nextDeselectedChildren;\n  selectedItems.value = nextSelectedItems;\n};\n\nconst menuSelectedItems = computed({\n  get: () => selectedItems.value,\n  set: (newValue: MenuOption<T>[]) => {\n    storeSelectedItems(newValue);\n  },\n});\n\nconst closeDropdown = () => {\n  searchInput.value = \"\";\n  open.value = false;\n};\n\nconst popoverOffset = computed(() => {\n  // get width of trigger element to offset popover correctly when overlay trigger is enabled\n  const size = props.size === \"lg\" ? 24 : 30;\n  return props.overlayTrigger ? -size : undefined;\n});\n\n// sync when parent updates modelSelectedItems directly\nwatch(\n  () => modelSelectedItems.value,\n  (newValue) => {\n    if (props.enableCascadeSelection && modelSelectionState.value?.length && newValue.length === 0) {\n      syncFromSelectionState(modelSelectionState.value);\n      return;\n    }\n    selectedItems.value = newValue;\n  },\n);\n\nwatch(\n  () => [modelSelectionState.value, props.options] as const,\n  () => {\n    syncFromSelectionState(modelSelectionState.value);\n  },\n  { deep: true, immediate: true },\n);\n\nwatch(open, (newValue) => {\n  if (newValue) {\n    resetPendingSelection();\n    nextTick(() => {\n      // if overlay trigger is enabled and search input exists, auto-target the search input\n      if (props.overlayTrigger && !props.disableSearchInput) {\n        searchInputComponentRef.value?.input?.focus();\n      }\n      emits(\"dropdown-open\");\n    });\n  } else {\n    // on close, discard pending changes\n    resetPendingSelection();\n    emits(\"dropdown-closed\");\n  }\n});\n\nconst filteredOptions = computed(() => {\n  if (searchInput.value === \"\") return props.options;\n  const searchValue = searchInput.value.toLocaleLowerCase();\n\n  if (props.enableCascadeSelection) {\n    return filterOptionsRecursive(props.options, searchValue, !props.hideParentOnChildQueryMatch);\n  }\n\n  return props.options.filter(\n    (option) =>\n      option.text.toLocaleLowerCase().includes(searchValue) ||\n      option.searchText?.toLocaleLowerCase().includes(searchValue),\n  );\n});\n\nconst handleSelectAll = () => {\n  // Mark all parents as cascade-selected (select-all intent) before\n  // storing so the selection state snapshot is accurate.\n  if (props.enableCascadeSelection) {\n    const parentIds = new Set<string>();\n    const collectParentIds = (options: MenuOption<T>[]) => {\n      for (const option of options) {\n        if (hasCascadeChildren(option)) {\n          parentIds.add(option.id);\n          if (option.children?.length) collectParentIds(option.children);\n        }\n      }\n    };\n    collectParentIds(filteredOptions.value as MenuOption<T>[]);\n    cascadeSelectedParentIds.value = parentIds;\n    cascadeDeselectedChildIds.value = new Map();\n  }\n\n  // select all visible item values (excluded ones filtered out by search)\n  const toSelect = props.enableCascadeSelection\n    ? collectLeafOptions(filteredOptions.value as MenuOption<T>[])\n    : filteredOptions.value;\n  emits(\"select-all\", toSelect.length);\n  storeSelectedItems(toSelect);\n};\n\nconst handleClearAll = () => {\n  emits(\"clear-all\", selectedItems.value.length);\n  cascadeSelectedParentIds.value = new Set();\n  cascadeDeselectedChildIds.value = new Map();\n  storeSelectedItems([]);\n};\n\nconst handleCancelSelection = () => {\n  resetPendingSelection();\n  closeDropdown();\n};\n\nconst handleConfirmSelection = () => {\n  applyPendingSelection();\n  closeDropdown();\n};\n\nconst groupingOptions = computed(() => {\n  if (!props.groupings) return;\n\n  const groupingMap = new Map<string, MenuOption[]>();\n\n  props.groupings.forEach((group) => {\n    groupingMap.set(group, []);\n  });\n\n  groupingMap.set(\"other\", []);\n\n  for (const option of props.options) {\n    const groupKey = option.groupingLabel;\n    const targetGroup = groupKey && groupingMap.has(groupKey) ? groupKey : \"other\";\n    groupingMap.get(targetGroup)!.push(option);\n  }\n\n  for (const [key, options] of groupingMap) {\n    if (options.length === 0) {\n      groupingMap.delete(key);\n    }\n  }\n\n  return Array.from(groupingMap.entries());\n});\n\nconst showGroupings = computed(() => {\n  return props.groupings && searchInput.value === \"\";\n});\n\nconst allSlotProps = computed(() => ({\n  ...props,\n  selectedItems: modelSelectedItems.value,\n  searchInput: searchInput.value,\n  slotContext: props.slotContext,\n  isOpen: open.value,\n  isLoading: props.isLoading,\n  filteredOptionCount: filteredOptions.value.length,\n}));\n\n// Derive a distinct name for this RUM action. Leave undefined to suppress.\nconst rumTriggerActionName = computed(() => {\n  if (props.rumActionName) return props.rumActionName;\n  return props.rumFilterName ? `Open ${props.rumFilterName} filter` : undefined;\n});\nconst rumSearchActionName = computed(() => (props.rumFilterName ? `Search ${props.rumFilterName} options` : undefined));\n\nconst popoverContentRef = useTemplateRef<HTMLElement | null>(\"popoverContentRef\");\nconst slotHost = computed(() => {\n  const rootNode = popoverContentRef.value?.getRootNode();\n  return rootNode instanceof ShadowRoot ? (rootNode.host as HTMLElement) : null;\n});\nconst { present: hasHeaderSlot } = useSlotPresence(\"header\", { host: slotHost });\nconst { present: hasNoResultsSlot } = useSlotPresence(\"no-results\", { host: slotHost });\nconst { present: hasFooterSlot } = useSlotPresence(\"footer\", { host: slotHost });\n\nonKeyStroke(\"Escape\", () => {\n  if (!open.value) return;\n\n  closeDropdown();\n});\n</script>\n\n<template>\n  <PvPopoverV2 v-model=\"open\" v-bind=\"popoverProperties\" :offset=\"popoverOffset\">\n    <template #trigger>\n      <PvSelectButtonTrigger\n        ref=\"select-button-trigger-ref\"\n        :variant=\"variant\"\n        :size=\"size\"\n        :disabled=\"disabled\"\n        :counterPosition=\"counterPosition\"\n        :prefixLabel=\"prefixLabel\"\n        :label=\"label\"\n        :icon=\"icon\"\n        :companyLogo=\"companyLogo\"\n        :showClear=\"!disableClearIcon && hasSelection && !disabled\"\n        :showDropdown=\"!disableDropdownIcon && (disabled || !(hasSelection && !disableClearIcon))\"\n        :open=\"open\"\n        :counter-value=\"counterValue\"\n        :counter-style=\"counterStyle\"\n        :selected-items=\"selectedItems\"\n        :data-dd-action-name=\"rumTriggerActionName\"\n        @handle-clear=\"handleClearAll\"\n        @handle-toggle-dropdown=\"handleOpen()\"\n      />\n    </template>\n    <template #content>\n      <div\n        ref=\"popoverContentRef\"\n        class=\"pv-popover\"\n        data-test-id=\"pv-popover\"\n        :style=\"{ '--position': 'unset', ...popoverCssProperties }\"\n      >\n        <template v-if=\"!disableSearchInput\">\n          <div class=\"pv-inset-square-8 pv-border-bottom\" :data-dd-action-name=\"rumSearchActionName\">\n            <PvSearchInput\n              ref=\"searchInputRef\"\n              v-model:model-value=\"searchInput\"\n              class=\"pv-stack-4\"\n              :placeholder=\"searchPlaceholder\"\n            />\n          </div>\n        </template>\n        <div v-if=\"$slots.header || hasHeaderSlot\" class=\"pv-inset-square-8\">\n          <slot name=\"header\" v-bind=\"allSlotProps\" />\n        </div>\n        <template v-if=\"filteredOptions.length > 0\">\n          <template v-if=\"showGroupings\">\n            <div v-for=\"([label, options], index) in groupingOptions\" :key=\"label\">\n              <slot v-if=\"$slots[label]\" :name=\"label\" />\n              <span\n                class=\"pv-text-body-sm pv-inset-inline\"\n                style=\"color: var(--color-text-quaternary, #89989b); --inset-size: 8px\"\n                v-else-if=\"label !== 'other'\"\n                >{{ label }}</span\n              >\n              <PvMenu\n                v-model:selectedItems=\"menuSelectedItems\"\n                :options=\"options\"\n                :config=\"optionConfig\"\n                :singleSelect=\"singleSelect\"\n                :queryText=\"highlightSearchText ? searchInput : null\"\n                :itemTestId=\"`pv-multiselect-${label}-item`\"\n                itemClass=\"pv-stack-4\"\n                :isLoading=\"isLoading\"\n                :isSeeMoreLoading=\"isSeeMoreLoading\"\n                :enableCascadeSelection=\"enableCascadeSelection\"\n                :hasMoreOptions=\"index === groupingOptions!.length - 1 && hasMoreOptions && !isLoading\"\n                @see-more=\"handleSeeMore\"\n              />\n              <div\n                v-if=\"groupingOptions && index !== groupingOptions.length - 1\"\n                class=\"pv-border-top\"\n                style=\"margin: 8px 0\"\n              />\n            </div>\n          </template>\n          <template v-else>\n            <PvMenu\n              v-model:selectedItems=\"menuSelectedItems\"\n              :options=\"filteredOptions\"\n              :config=\"optionConfig\"\n              :singleSelect=\"singleSelect\"\n              :queryText=\"highlightSearchText ? searchInput : null\"\n              :itemTestId=\"`pv-multiselect-${label}-item`\"\n              itemClass=\"pv-stack-4\"\n              :enableCascadeSelection=\"enableCascadeSelection\"\n              :isSeeMoreLoading=\"isSeeMoreLoading\"\n              :hasMoreOptions=\"hasMoreOptions && !isLoading\"\n              @see-more=\"handleSeeMore\"\n            />\n          </template>\n        </template>\n        <div\n          v-if=\"isLoading\"\n          class=\"pv-flex pv-inset-square-8 pv-text-body-sm pv-text-subdued\"\n          style=\"justify-content: center\"\n        >\n          <PvSpinner variant=\"dark\" />\n          <span v-if=\"loadingText\">{{ loadingText }}</span>\n        </div>\n        <template v-else-if=\"filteredOptions.length === 0\">\n          <slot v-if=\"hasNoResultsSlot\" name=\"no-results\" v-bind=\"allSlotProps\" />\n          <PvMenuEmptyState v-else />\n        </template>\n        <!-- Only when there is something to put in it, or a bordered empty bar is left behind. -->\n        <div\n          v-if=\"hasFooterSlot || menuActionsVariant\"\n          class=\"pv-sticky pv-surface pv-border-top pv-inset-square-8\"\n          :class=\"{ 'pv-flow-8': footerPosition === 'below-actions' }\"\n          style=\"--flex-justify: space-between; --bottom: 0\"\n        >\n          <slot v-if=\"hasFooterSlot && footerPosition === 'above-actions'\" name=\"footer\" v-bind=\"allSlotProps\" />\n          <PvSelectControlPanel\n            v-if=\"menuActionsVariant\"\n            :variant=\"menuActionsVariant\"\n            :disabled=\"isLoading\"\n            :rumFilterName=\"rumFilterName\"\n            @handle-clear-all=\"handleClearAll\"\n            @handle-select-all=\"handleSelectAll\"\n            @handle-cancel=\"handleCancelSelection\"\n            @handle-confirm=\"handleConfirmSelection\"\n          />\n          <slot v-if=\"hasFooterSlot && footerPosition === 'below-actions'\" name=\"footer\" v-bind=\"allSlotProps\" />\n        </div>\n      </div>\n    </template>\n  </PvPopoverV2>\n</template>\n","<script setup lang=\"ts\">\nimport { computed } from \"vue\";\nimport { PvInputType, PvInputVariant } from \"./types\";\nimport PvIcon from \"../PvIcon/PvIcon.vue\";\ninterface PvInputProps {\n  /** When true, upper label is visible */\n  showLabel?: boolean;\n  /** When true, applies invalid/error styling to the input and lower label. */\n  error?: boolean;\n  /** When true, the input is non-interactive and visually dimmed. */\n  disabled?: boolean;\n  /** Placeholder text shown when the input is empty. */\n  placeholder?: string;\n  /**\n   * The HTML input type.\n   */\n  type?: PvInputType;\n  /** HTML id for the input element. Auto-generated when omitted. */\n  id?: string;\n  /** Helper or validation text displayed below the input. Turns red when error is true. */\n  lowerLabel?: string;\n  /**\n   * Background color variant of the input field.\n   */\n  variant?: PvInputVariant;\n  /** The step attribute for number inputs (e.g. '0.01' for currency). */\n  step?: string;\n  /** Static text shown before the Input */\n  prefixLabel?: string;\n  /** Optional Icon on the left of the Input */\n  inputIcon?: string;\n}\n\nconst props = withDefaults(defineProps<PvInputProps>(), {\n  id: Math.random().toString(),\n  type: \"text\",\n  variant: \"white\",\n});\n\nconst value = defineModel<string>();\n\nconst inputPadding = computed(() => {\n  if (props.inputIcon) {\n    return {\n      \"--inset-size\": \"8px 12px 6px 36px\",\n    };\n  }\n\n  return {};\n});\n</script>\n\n<template>\n  <label v-if=\"$slots.label || showLabel\" data-testid=\"pv-input-label\" class=\"pv-label pv-stack-8\" :for=\"id\">\n    <slot name=\"label\" />\n  </label>\n  <div\n    class=\"pv-flex pv-flex-item\"\n    :class=\"{\n      'pv-stack-8': lowerLabel,\n    }\"\n  >\n    <div\n      v-if=\"prefixLabel\"\n      class=\"pv-surface-accent pv-inset-square pv-text-body-md pv-radius pv-bordered\"\n      style=\"--inset-size: 6px 10px\"\n    >\n      {{ prefixLabel }}\n    </div>\n    <div class=\"pv-relative pv-flex-item\">\n      <PvIcon class=\"pv-absolute input-icon-position\" v-if=\"inputIcon\" :name=\"inputIcon\" />\n      <input\n        v-bind=\"$attrs\"\n        v-model=\"value\"\n        data-testid=\"pv-input\"\n        :class=\"[\n          'pv-input-text',\n          {\n            'pv-inset-square': inputIcon,\n            'pv-surface-accent': variant === 'grey',\n          },\n        ]\"\n        :style=\"[inputPadding, { width: '100%' }]\"\n        :disabled=\"disabled\"\n        :type=\"type\"\n        :placeholder=\"placeholder\"\n        :id=\"id\"\n        :data-invalid=\"error ? true : undefined\"\n        :step=\"step\"\n      />\n    </div>\n  </div>\n  <p\n    v-if=\"lowerLabel\"\n    data-testid=\"pv-input-lower-label\"\n    style=\"margin-left: 12px\"\n    :class=\"[\n      'pv-text-body-xs',\n      {\n        'pv-text-red': error,\n        'pv-text-subdued': !error,\n      },\n    ]\"\n  >\n    {{ lowerLabel }}\n  </p>\n</template>\n\n<style>\n.input-icon-position {\n  position: absolute;\n  left: 12px;\n  top: 8px;\n  pointer-events: none;\n}\n</style>\n","<script setup lang=\"ts\">\nimport { computed, CSSProperties, useTemplateRef, onMounted, onUnmounted } from \"vue\";\nimport Sortable from \"sortablejs\";\nimport PvIcon from \"../PvIcon/PvIcon.vue\";\nimport type { MenuOption } from \"@/types\";\nimport PvButton from \"@/components/base/PvButton/PvButton.vue\";\nimport PvTooltipV2 from \"@/components/base/PvTooltipV2/PvTooltipV2.vue\";\nimport type { LockedOption } from \"./types\";\n\nconst DIVIDER_ID = \"--divider--\";\nconst PLACEHOLDER_ID = \"placeholder-\";\n\nexport type PvSortableMenuListProps = {\n  /** The full set of available options to choose from and reorder. */\n  options: MenuOption[];\n  /** Maximum number of options that can be active (above the divider) at once. */\n  activeOptionLimit?: number;\n  /**\n   * Text displayed inside empty placeholder drop zones.\n   */\n  placeholderText?: string;\n  /**\n   * Whether to render placeholder drop zones for unfilled active slots.\n   */\n  showPlaceholders?: boolean;\n  /**\n   * Options that cannot be removed or reordered: they render with a lock icon and grayed\n   * text, stay pinned at the top of the active list, and every mutation (click, drag,\n   * placeholder drop) re-asserts them. Ids must refer to options that are already active.\n   * An entry's optional `tooltip` explains WHY it is locked, rendered as an info icon\n   * (e.g. \"Select a single drug to unlock\").\n   */\n  lockedOptions?: LockedOption[];\n};\n\nconst props = withDefaults(defineProps<PvSortableMenuListProps>(), {\n  options: () => [],\n  placeholderText: \"Add option\",\n  showPlaceholders: true,\n  lockedOptions: () => [],\n});\n\nconst activeOptions = defineModel<MenuOption[]>({\n  required: false,\n  default: () => [],\n});\n\nconst isOptionLocked = (option: MenuOption) => props.lockedOptions.some((locked) => locked.id === option.id);\nconst lockedOptionTooltip = (option: MenuOption) =>\n  props.lockedOptions.find((locked) => locked.id === option.id)?.tooltip;\n\n// Re-assert the locked invariant on a proposed active list: every currently-active locked\n// option survives the mutation and sits first (in its existing relative order), then the\n// proposal's other options, capped at the limit. Locked options sit first, so the cap can\n// never slice them away.\nconst withLockedOptions = (proposed: MenuOption[]): MenuOption[] => {\n  if (props.lockedOptions.length === 0) {\n    return proposed;\n  }\n  const lockedActive = activeOptions.value.filter(isOptionLocked);\n  const rest = proposed.filter((option) => !isOptionLocked(option));\n  return [...lockedActive, ...rest].slice(0, props.activeOptionLimit || Infinity);\n};\n\nconst dividingLineOption: MenuOption = {\n  id: DIVIDER_ID,\n  text: \"\",\n  disabled: true,\n};\n\nconst placeholderCount = computed(() => {\n  return props.activeOptionLimit ? Math.max(0, props.activeOptionLimit - activeOptions.value.length) : 0;\n});\n\nconst placeholderOptions = computed(() => {\n  if (!props.showPlaceholders || placeholderCount.value === 0) return [];\n  return Array.from({ length: placeholderCount.value }, (_, index) => ({\n    id: `${PLACEHOLDER_ID}${index}`,\n    text: \"\",\n    disabled: true,\n    isPlaceholder: true,\n  }));\n});\n\nconst optionDisplayOrder = computed(() => {\n  // prioritize active options first, then placeholders, then divider, then the rest\n  const activeOptionIds = new Set(activeOptions.value.map((opt) => opt.id));\n  return [\n    ...activeOptions.value,\n    ...placeholderOptions.value,\n    dividingLineOption,\n    ...props.options.filter((option) => !activeOptionIds.has(option.id)),\n  ] as MenuOption[];\n});\n\nconst sortableListRef = useTemplateRef<HTMLElement>(\"sortableListRef\");\nconst containerRef = useTemplateRef<HTMLElement>(\"containerRef\");\n\nlet sortableInstance: Sortable | null = null;\nlet currentDraggedElement: HTMLElement | null = null;\nlet placeholderDropHandled = false;\n\nconst readActiveOptionsFromDOM = (): MenuOption[] => {\n  if (!sortableListRef.value) return activeOptions.value;\n\n  let newIds = Array.from(sortableListRef.value.children).map((child) => (child as HTMLElement).id);\n  // get all the options above the dividing line\n  const dividerIndex = newIds.findIndex((id) => id === DIVIDER_ID);\n  if (dividerIndex !== -1) {\n    newIds = newIds.slice(0, dividerIndex);\n  }\n  // filter out placeholder items\n  newIds = newIds.filter((id) => !id.startsWith(PLACEHOLDER_ID));\n\n  const newOptionOrder = newIds\n    .map((id) => {\n      return props.options.find((item) => item.id === id) || null;\n    })\n    .filter(Boolean) as MenuOption[];\n  // slice based on activeOptionLimit\n  return newOptionOrder.slice(0, props.activeOptionLimit || Infinity);\n};\n\nonMounted(() => {\n  if (sortableListRef.value) {\n    sortableInstance = new Sortable(sortableListRef.value, {\n      animation: 200,\n      filter: `#${DIVIDER_ID}, [id^=\"placeholder-\"], .pv-sortable-locked`,\n      dragoverBubble: true,\n      onStart: (evt) => {\n        currentDraggedElement = evt.item;\n        placeholderDropHandled = false;\n      },\n      onMove: (evt) => {\n        const relatedElement = evt.related;\n        // Placeholder zones handle their own native dragover/drop events\n        if (relatedElement?.id?.startsWith(PLACEHOLDER_ID)) {\n          return false;\n        }\n        const fromOption = props.options.find((opt) => opt.id === evt.dragged.id);\n        if (!fromOption) {\n          return false;\n        }\n        // Nothing may displace a locked option's pinned slot.\n        const relatedLocked = props.options.find((opt) => opt.id === relatedElement?.id && isOptionLocked(opt));\n        if (relatedLocked) {\n          return false;\n        }\n        // Active options move freely: reorder within the active zone or cross the\n        // divider into the inactive zone. The divider is a valid swap target so\n        // items can cross it even when the zone on the other side is empty.\n        if (isOptionActive(fromOption)) {\n          return true;\n        }\n        // Inactive options may only move toward the active zone, and only when\n        // there is room under the active limit\n        if (activeLimitReached.value) {\n          return false;\n        }\n        if (relatedElement?.id === DIVIDER_ID) {\n          return true;\n        }\n        const relatedOption = props.options.find((opt) => opt.id === relatedElement?.id);\n        return !!relatedOption && isOptionActive(relatedOption);\n      },\n      onEnd: (evt) => {\n        currentDraggedElement = null;\n        // A drop on a placeholder zone was already committed by handlePlaceholderDrop\n        if (placeholderDropHandled) {\n          placeholderDropHandled = false;\n          return;\n        }\n        const list = sortableListRef.value;\n        if (!list || !evt.item || !list.contains(evt.item)) return;\n\n        const newActiveOptions = withLockedOptions(readActiveOptionsFromDOM());\n\n        // Put the dragged element back where the last render left it, so the real\n        // DOM matches Vue's virtual DOM before the commit triggers a re-render.\n        // Otherwise Vue's keyed diff moves nodes based on stale positions and can\n        // strand items on the wrong side of the divider.\n        list.removeChild(evt.item);\n        list.insertBefore(evt.item, list.children[evt.oldIndex ?? list.children.length] ?? null);\n\n        const currentIds = activeOptions.value.map((opt) => opt.id);\n        const unchanged =\n          newActiveOptions.length === currentIds.length &&\n          newActiveOptions.every((opt, index) => opt.id === currentIds[index]);\n        if (!unchanged) {\n          activeOptions.value = newActiveOptions;\n        }\n      },\n    });\n  }\n});\n\nonUnmounted(() => {\n  if (sortableInstance) {\n    sortableInstance.destroy();\n    sortableInstance = null;\n  }\n});\n\n// Handle dragover events on placeholder zones\nconst handlePlaceholderDragOver = (evt: DragEvent) => {\n  evt.preventDefault();\n  if (currentDraggedElement) {\n    const placeholderZone = evt.currentTarget as HTMLElement;\n    placeholderZone.classList.add(\"pv-sortable-list-placeholder-drag-over\");\n  }\n};\n\nconst handlePlaceholderDragLeave = (evt: DragEvent) => {\n  const placeholderZone = evt.currentTarget as HTMLElement;\n  placeholderZone.classList.remove(\"pv-sortable-list-placeholder-drag-over\");\n};\n\nconst handlePlaceholderDrop = (evt: DragEvent, index: number) => {\n  evt.preventDefault();\n  const placeholderZone = evt.currentTarget as HTMLElement;\n  placeholderZone.classList.remove(\"pv-sortable-list-placeholder-drag-over\");\n\n  if (currentDraggedElement) {\n    const draggedId = currentDraggedElement.id;\n    const draggedOption = props.options.find((opt) => opt.id === draggedId);\n\n    if (draggedOption && !isOptionActive(draggedOption)) {\n      // Add this option to active options at the specified index\n      const newActiveOptions = [...activeOptions.value];\n      newActiveOptions.splice(index - 1, 0, draggedOption);\n      activeOptions.value = withLockedOptions(newActiveOptions);\n\n      // Remove the element from its current position in the DOM\n      if (currentDraggedElement.parentNode) {\n        currentDraggedElement.parentNode.removeChild(currentDraggedElement);\n      }\n      // Tell onEnd this drop is already committed\n      placeholderDropHandled = true;\n    }\n  }\n};\n\nconst isOptionActive = (option: MenuOption) => {\n  return activeOptions.value.some((activeOption) => activeOption.id === option.id);\n};\n\nconst activeLimitReached = computed(() => {\n  return props.activeOptionLimit ? activeOptions.value.length >= props.activeOptionLimit : false;\n});\n\nconst handleOptionClick = (option: MenuOption) => {\n  if (isOptionLocked(option)) {\n    return;\n  }\n  if (isOptionActive(option)) {\n    // remove option\n    activeOptions.value = activeOptions.value.filter((activeOption) => activeOption.id !== option.id);\n  } else {\n    // only add if we're below activeOptionLimit\n    if (props.activeOptionLimit && activeOptions.value.length >= props.activeOptionLimit) {\n      return;\n    }\n    activeOptions.value = activeOptions.value.concat([option]);\n  }\n};\n\nconst optionDisabled = (option: MenuOption) => {\n  // disable if the option is already active and we reached the limit\n  return (\n    (!isOptionActive(option) && props.activeOptionLimit && activeOptions.value.length >= props.activeOptionLimit) ||\n    option.disabled\n  );\n};\n\nconst sortableListOptionStyles = (option: MenuOption) => {\n  const styles: CSSProperties = {\n    padding: \"4px 8px\",\n  };\n  if (isOptionActive(option)) {\n    if (isOptionLocked(option)) {\n      // Locked entries stay active but read as fixed: neutral pill with the default border\n      // instead of the brand highlight.\n      styles.backgroundColor = \"var(--color-background-accent, #f7f8f8)\";\n    } else {\n      styles.backgroundColor = \"var(--color-background-highlight, #E4F8F6)\";\n      styles.borderColor = \"var(--color-border-brand, #16696D)\";\n    }\n  }\n  return styles;\n};\n\nconst sortableListButtonStyles = (option: MenuOption) => {\n  const styles: CSSProperties = {};\n\n  if (optionDisabled(option)) {\n    styles.backgroundColor = \"transparent\";\n  }\n  return styles;\n};\n\nconst sortableListButtonClasses = (option: MenuOption) => {\n  if (!isOptionActive(option) && !optionDisabled(option)) {\n    return \"pv-text-tertiary\";\n  } else {\n    return \"pv-text-brand\";\n  }\n};\n</script>\n\n<template>\n  <div ref=\"containerRef\">\n    <!-- Main sortable list -->\n    <ul ref=\"sortableListRef\" role=\"list\">\n      <li v-for=\"option in optionDisplayOrder\" :key=\"option.id\" :id=\"option.id\" class=\"pv-stack-4\">\n        <div v-if=\"option.id === DIVIDER_ID\" class=\"pv-sortable-list-divider-container\">\n          <div\n            class=\"pv-sortable-list-divider pv-text-default pv-text-body-xs pv-text-tertiary\"\n            :data-label=\"activeLimitReached ? `Maximum of ${props.activeOptionLimit}` : ''\"\n          ></div>\n        </div>\n        <div\n          v-else-if=\"option.id.includes(PLACEHOLDER_ID)\"\n          class=\"pv-sortable-list-placeholder-zone\"\n          @dragover=\"handlePlaceholderDragOver($event)\"\n          @dragleave=\"handlePlaceholderDragLeave($event)\"\n          @drop=\"handlePlaceholderDrop($event, parseInt(option.id.split('-')[1]) + 1)\"\n        >\n          <div\n            class=\"pv-full-width pv-bordered pv-radius-md pv-flex pv-sortable-list-placeholder-dropzone\"\n            style=\"--flex-justify: center\"\n          >\n            <span class=\"pv-text-body-sm pv-text-tertiary\">{{ props.placeholderText }}</span>\n          </div>\n        </div>\n        <div\n          v-else\n          class=\"pv-full-width pv-bordered pv-radius-md pv-flex pv-space-between\"\n          :class=\"[\n            !isOptionActive(option) && activeLimitReached ? 'pv-sortable-list-option-disabled' : '',\n            isOptionLocked(option) ? 'pv-sortable-locked' : '',\n          ]\"\n          :style=\"sortableListOptionStyles(option)\"\n        >\n          <div\n            class=\"pv-flex pv-full-width pv-sortable-list-option\"\n            :class=\"{ 'pv-sortable-list-option-locked': isOptionLocked(option) }\"\n          >\n            <!-- Locked entries gray their icons and text so they read as immovable at a\n                 glance; unlocked active entries keep the brand color. -->\n            <PvIcon class=\"pv-text-tertiary\" :name=\"isOptionLocked(option) ? 'lock' : 'reorder'\" />\n            <PvIcon v-if=\"option.icon\" class=\"pv-text-tertiary\" :name=\"option.icon\" />\n            <span class=\"pv-text-body-sm\" :class=\"{ 'pv-text-tertiary': isOptionLocked(option) }\">\n              {{ option.text }}\n            </span>\n            <!-- Teleported so the tooltip escapes the picker's scroll container; dark variant\n                 matches the panel's other info tips. -->\n            <PvTooltipV2\n              v-if=\"isOptionLocked(option) && lockedOptionTooltip(option)\"\n              variant=\"dark\"\n              size=\"sm\"\n              :useTeleport=\"true\"\n              :disableInteractive=\"true\"\n            >\n              <template #trigger>\n                <PvIcon class=\"pv-text-tertiary\" name=\"info-circle\" />\n              </template>\n              <template #content>\n                <div style=\"max-width: 220px\">{{ lockedOptionTooltip(option) }}</div>\n              </template>\n            </PvTooltipV2>\n          </div>\n          <PvButton\n            v-if=\"!optionDisabled(option) && !isOptionLocked(option)\"\n            :left-icon=\"isOptionActive(option) ? 'remove-circle' : 'add-circle'\"\n            :ariaLabel=\"isOptionActive(option) ? `Remove ${option.text}` : `Add ${option.text}`\"\n            variant=\"ghost\"\n            :style=\"sortableListButtonStyles(option)\"\n            :class=\"sortableListButtonClasses(option)\"\n            @click=\"handleOptionClick(option)\"\n          ></PvButton>\n          <div v-else class=\"pv-sortable-list-button-placeholder\"></div>\n        </div>\n      </li>\n    </ul>\n  </div>\n</template>\n","<script setup lang=\"ts\">\nimport { computed, CSSProperties, useTemplateRef, onMounted, onUnmounted } from \"vue\";\nimport Sortable from \"sortablejs\";\nimport PvIcon from \"../PvIcon/PvIcon.vue\";\nimport type { MenuOption } from \"@/types\";\nimport PvButton from \"@/components/base/PvButton/PvButton.vue\";\nimport PvTooltipV2 from \"@/components/base/PvTooltipV2/PvTooltipV2.vue\";\nimport type { LockedOption } from \"./types\";\n\nconst DIVIDER_ID = \"--divider--\";\nconst PLACEHOLDER_ID = \"placeholder-\";\n\nexport type PvSortableMenuListProps = {\n  /** The full set of available options to choose from and reorder. */\n  options: MenuOption[];\n  /** Maximum number of options that can be active (above the divider) at once. */\n  activeOptionLimit?: number;\n  /**\n   * Text displayed inside empty placeholder drop zones.\n   */\n  placeholderText?: string;\n  /**\n   * Whether to render placeholder drop zones for unfilled active slots.\n   */\n  showPlaceholders?: boolean;\n  /**\n   * Options that cannot be removed or reordered: they render with a lock icon and grayed\n   * text, stay pinned at the top of the active list, and every mutation (click, drag,\n   * placeholder drop) re-asserts them. Ids must refer to options that are already active.\n   * An entry's optional `tooltip` explains WHY it is locked, rendered as an info icon\n   * (e.g. \"Select a single drug to unlock\").\n   */\n  lockedOptions?: LockedOption[];\n};\n\nconst props = withDefaults(defineProps<PvSortableMenuListProps>(), {\n  options: () => [],\n  placeholderText: \"Add option\",\n  showPlaceholders: true,\n  lockedOptions: () => [],\n});\n\nconst activeOptions = defineModel<MenuOption[]>({\n  required: false,\n  default: () => [],\n});\n\nconst isOptionLocked = (option: MenuOption) => props.lockedOptions.some((locked) => locked.id === option.id);\nconst lockedOptionTooltip = (option: MenuOption) =>\n  props.lockedOptions.find((locked) => locked.id === option.id)?.tooltip;\n\n// Re-assert the locked invariant on a proposed active list: every currently-active locked\n// option survives the mutation and sits first (in its existing relative order), then the\n// proposal's other options, capped at the limit. Locked options sit first, so the cap can\n// never slice them away.\nconst withLockedOptions = (proposed: MenuOption[]): MenuOption[] => {\n  if (props.lockedOptions.length === 0) {\n    return proposed;\n  }\n  const lockedActive = activeOptions.value.filter(isOptionLocked);\n  const rest = proposed.filter((option) => !isOptionLocked(option));\n  return [...lockedActive, ...rest].slice(0, props.activeOptionLimit || Infinity);\n};\n\nconst dividingLineOption: MenuOption = {\n  id: DIVIDER_ID,\n  text: \"\",\n  disabled: true,\n};\n\nconst placeholderCount = computed(() => {\n  return props.activeOptionLimit ? Math.max(0, props.activeOptionLimit - activeOptions.value.length) : 0;\n});\n\nconst placeholderOptions = computed(() => {\n  if (!props.showPlaceholders || placeholderCount.value === 0) return [];\n  return Array.from({ length: placeholderCount.value }, (_, index) => ({\n    id: `${PLACEHOLDER_ID}${index}`,\n    text: \"\",\n    disabled: true,\n    isPlaceholder: true,\n  }));\n});\n\nconst optionDisplayOrder = computed(() => {\n  // prioritize active options first, then placeholders, then divider, then the rest\n  const activeOptionIds = new Set(activeOptions.value.map((opt) => opt.id));\n  return [\n    ...activeOptions.value,\n    ...placeholderOptions.value,\n    dividingLineOption,\n    ...props.options.filter((option) => !activeOptionIds.has(option.id)),\n  ] as MenuOption[];\n});\n\nconst sortableListRef = useTemplateRef<HTMLElement>(\"sortableListRef\");\nconst containerRef = useTemplateRef<HTMLElement>(\"containerRef\");\n\nlet sortableInstance: Sortable | null = null;\nlet currentDraggedElement: HTMLElement | null = null;\nlet placeholderDropHandled = false;\n\nconst readActiveOptionsFromDOM = (): MenuOption[] => {\n  if (!sortableListRef.value) return activeOptions.value;\n\n  let newIds = Array.from(sortableListRef.value.children).map((child) => (child as HTMLElement).id);\n  // get all the options above the dividing line\n  const dividerIndex = newIds.findIndex((id) => id === DIVIDER_ID);\n  if (dividerIndex !== -1) {\n    newIds = newIds.slice(0, dividerIndex);\n  }\n  // filter out placeholder items\n  newIds = newIds.filter((id) => !id.startsWith(PLACEHOLDER_ID));\n\n  const newOptionOrder = newIds\n    .map((id) => {\n      return props.options.find((item) => item.id === id) || null;\n    })\n    .filter(Boolean) as MenuOption[];\n  // slice based on activeOptionLimit\n  return newOptionOrder.slice(0, props.activeOptionLimit || Infinity);\n};\n\nonMounted(() => {\n  if (sortableListRef.value) {\n    sortableInstance = new Sortable(sortableListRef.value, {\n      animation: 200,\n      filter: `#${DIVIDER_ID}, [id^=\"placeholder-\"], .pv-sortable-locked`,\n      dragoverBubble: true,\n      onStart: (evt) => {\n        currentDraggedElement = evt.item;\n        placeholderDropHandled = false;\n      },\n      onMove: (evt) => {\n        const relatedElement = evt.related;\n        // Placeholder zones handle their own native dragover/drop events\n        if (relatedElement?.id?.startsWith(PLACEHOLDER_ID)) {\n          return false;\n        }\n        const fromOption = props.options.find((opt) => opt.id === evt.dragged.id);\n        if (!fromOption) {\n          return false;\n        }\n        // Nothing may displace a locked option's pinned slot.\n        const relatedLocked = props.options.find((opt) => opt.id === relatedElement?.id && isOptionLocked(opt));\n        if (relatedLocked) {\n          return false;\n        }\n        // Active options move freely: reorder within the active zone or cross the\n        // divider into the inactive zone. The divider is a valid swap target so\n        // items can cross it even when the zone on the other side is empty.\n        if (isOptionActive(fromOption)) {\n          return true;\n        }\n        // Inactive options may only move toward the active zone, and only when\n        // there is room under the active limit\n        if (activeLimitReached.value) {\n          return false;\n        }\n        if (relatedElement?.id === DIVIDER_ID) {\n          return true;\n        }\n        const relatedOption = props.options.find((opt) => opt.id === relatedElement?.id);\n        return !!relatedOption && isOptionActive(relatedOption);\n      },\n      onEnd: (evt) => {\n        currentDraggedElement = null;\n        // A drop on a placeholder zone was already committed by handlePlaceholderDrop\n        if (placeholderDropHandled) {\n          placeholderDropHandled = false;\n          return;\n        }\n        const list = sortableListRef.value;\n        if (!list || !evt.item || !list.contains(evt.item)) return;\n\n        const newActiveOptions = withLockedOptions(readActiveOptionsFromDOM());\n\n        // Put the dragged element back where the last render left it, so the real\n        // DOM matches Vue's virtual DOM before the commit triggers a re-render.\n        // Otherwise Vue's keyed diff moves nodes based on stale positions and can\n        // strand items on the wrong side of the divider.\n        list.removeChild(evt.item);\n        list.insertBefore(evt.item, list.children[evt.oldIndex ?? list.children.length] ?? null);\n\n        const currentIds = activeOptions.value.map((opt) => opt.id);\n        const unchanged =\n          newActiveOptions.length === currentIds.length &&\n          newActiveOptions.every((opt, index) => opt.id === currentIds[index]);\n        if (!unchanged) {\n          activeOptions.value = newActiveOptions;\n        }\n      },\n    });\n  }\n});\n\nonUnmounted(() => {\n  if (sortableInstance) {\n    sortableInstance.destroy();\n    sortableInstance = null;\n  }\n});\n\n// Handle dragover events on placeholder zones\nconst handlePlaceholderDragOver = (evt: DragEvent) => {\n  evt.preventDefault();\n  if (currentDraggedElement) {\n    const placeholderZone = evt.currentTarget as HTMLElement;\n    placeholderZone.classList.add(\"pv-sortable-list-placeholder-drag-over\");\n  }\n};\n\nconst handlePlaceholderDragLeave = (evt: DragEvent) => {\n  const placeholderZone = evt.currentTarget as HTMLElement;\n  placeholderZone.classList.remove(\"pv-sortable-list-placeholder-drag-over\");\n};\n\nconst handlePlaceholderDrop = (evt: DragEvent, index: number) => {\n  evt.preventDefault();\n  const placeholderZone = evt.currentTarget as HTMLElement;\n  placeholderZone.classList.remove(\"pv-sortable-list-placeholder-drag-over\");\n\n  if (currentDraggedElement) {\n    const draggedId = currentDraggedElement.id;\n    const draggedOption = props.options.find((opt) => opt.id === draggedId);\n\n    if (draggedOption && !isOptionActive(draggedOption)) {\n      // Add this option to active options at the specified index\n      const newActiveOptions = [...activeOptions.value];\n      newActiveOptions.splice(index - 1, 0, draggedOption);\n      activeOptions.value = withLockedOptions(newActiveOptions);\n\n      // Remove the element from its current position in the DOM\n      if (currentDraggedElement.parentNode) {\n        currentDraggedElement.parentNode.removeChild(currentDraggedElement);\n      }\n      // Tell onEnd this drop is already committed\n      placeholderDropHandled = true;\n    }\n  }\n};\n\nconst isOptionActive = (option: MenuOption) => {\n  return activeOptions.value.some((activeOption) => activeOption.id === option.id);\n};\n\nconst activeLimitReached = computed(() => {\n  return props.activeOptionLimit ? activeOptions.value.length >= props.activeOptionLimit : false;\n});\n\nconst handleOptionClick = (option: MenuOption) => {\n  if (isOptionLocked(option)) {\n    return;\n  }\n  if (isOptionActive(option)) {\n    // remove option\n    activeOptions.value = activeOptions.value.filter((activeOption) => activeOption.id !== option.id);\n  } else {\n    // only add if we're below activeOptionLimit\n    if (props.activeOptionLimit && activeOptions.value.length >= props.activeOptionLimit) {\n      return;\n    }\n    activeOptions.value = activeOptions.value.concat([option]);\n  }\n};\n\nconst optionDisabled = (option: MenuOption) => {\n  // disable if the option is already active and we reached the limit\n  return (\n    (!isOptionActive(option) && props.activeOptionLimit && activeOptions.value.length >= props.activeOptionLimit) ||\n    option.disabled\n  );\n};\n\nconst sortableListOptionStyles = (option: MenuOption) => {\n  const styles: CSSProperties = {\n    padding: \"4px 8px\",\n  };\n  if (isOptionActive(option)) {\n    if (isOptionLocked(option)) {\n      // Locked entries stay active but read as fixed: neutral pill with the default border\n      // instead of the brand highlight.\n      styles.backgroundColor = \"var(--color-background-accent, #f7f8f8)\";\n    } else {\n      styles.backgroundColor = \"var(--color-background-highlight, #E4F8F6)\";\n      styles.borderColor = \"var(--color-border-brand, #16696D)\";\n    }\n  }\n  return styles;\n};\n\nconst sortableListButtonStyles = (option: MenuOption) => {\n  const styles: CSSProperties = {};\n\n  if (optionDisabled(option)) {\n    styles.backgroundColor = \"transparent\";\n  }\n  return styles;\n};\n\nconst sortableListButtonClasses = (option: MenuOption) => {\n  if (!isOptionActive(option) && !optionDisabled(option)) {\n    return \"pv-text-tertiary\";\n  } else {\n    return \"pv-text-brand\";\n  }\n};\n</script>\n\n<template>\n  <div ref=\"containerRef\">\n    <!-- Main sortable list -->\n    <ul ref=\"sortableListRef\" role=\"list\">\n      <li v-for=\"option in optionDisplayOrder\" :key=\"option.id\" :id=\"option.id\" class=\"pv-stack-4\">\n        <div v-if=\"option.id === DIVIDER_ID\" class=\"pv-sortable-list-divider-container\">\n          <div\n            class=\"pv-sortable-list-divider pv-text-default pv-text-body-xs pv-text-tertiary\"\n            :data-label=\"activeLimitReached ? `Maximum of ${props.activeOptionLimit}` : ''\"\n          ></div>\n        </div>\n        <div\n          v-else-if=\"option.id.includes(PLACEHOLDER_ID)\"\n          class=\"pv-sortable-list-placeholder-zone\"\n          @dragover=\"handlePlaceholderDragOver($event)\"\n          @dragleave=\"handlePlaceholderDragLeave($event)\"\n          @drop=\"handlePlaceholderDrop($event, parseInt(option.id.split('-')[1]) + 1)\"\n        >\n          <div\n            class=\"pv-full-width pv-bordered pv-radius-md pv-flex pv-sortable-list-placeholder-dropzone\"\n            style=\"--flex-justify: center\"\n          >\n            <span class=\"pv-text-body-sm pv-text-tertiary\">{{ props.placeholderText }}</span>\n          </div>\n        </div>\n        <div\n          v-else\n          class=\"pv-full-width pv-bordered pv-radius-md pv-flex pv-space-between\"\n          :class=\"[\n            !isOptionActive(option) && activeLimitReached ? 'pv-sortable-list-option-disabled' : '',\n            isOptionLocked(option) ? 'pv-sortable-locked' : '',\n          ]\"\n          :style=\"sortableListOptionStyles(option)\"\n        >\n          <div\n            class=\"pv-flex pv-full-width pv-sortable-list-option\"\n            :class=\"{ 'pv-sortable-list-option-locked': isOptionLocked(option) }\"\n          >\n            <!-- Locked entries gray their icons and text so they read as immovable at a\n                 glance; unlocked active entries keep the brand color. -->\n            <PvIcon class=\"pv-text-tertiary\" :name=\"isOptionLocked(option) ? 'lock' : 'reorder'\" />\n            <PvIcon v-if=\"option.icon\" class=\"pv-text-tertiary\" :name=\"option.icon\" />\n            <span class=\"pv-text-body-sm\" :class=\"{ 'pv-text-tertiary': isOptionLocked(option) }\">\n              {{ option.text }}\n            </span>\n            <!-- Teleported so the tooltip escapes the picker's scroll container; dark variant\n                 matches the panel's other info tips. -->\n            <PvTooltipV2\n              v-if=\"isOptionLocked(option) && lockedOptionTooltip(option)\"\n              variant=\"dark\"\n              size=\"sm\"\n              :useTeleport=\"true\"\n              :disableInteractive=\"true\"\n            >\n              <template #trigger>\n                <PvIcon class=\"pv-text-tertiary\" name=\"info-circle\" />\n              </template>\n              <template #content>\n                <div style=\"max-width: 220px\">{{ lockedOptionTooltip(option) }}</div>\n              </template>\n            </PvTooltipV2>\n          </div>\n          <PvButton\n            v-if=\"!optionDisabled(option) && !isOptionLocked(option)\"\n            :left-icon=\"isOptionActive(option) ? 'remove-circle' : 'add-circle'\"\n            :ariaLabel=\"isOptionActive(option) ? `Remove ${option.text}` : `Add ${option.text}`\"\n            variant=\"ghost\"\n            :style=\"sortableListButtonStyles(option)\"\n            :class=\"sortableListButtonClasses(option)\"\n            @click=\"handleOptionClick(option)\"\n          ></PvButton>\n          <div v-else class=\"pv-sortable-list-button-placeholder\"></div>\n        </div>\n      </li>\n    </ul>\n  </div>\n</template>\n","import { PvPaginationVariant } from \"./types\";\n\nconst variantToNumber: Record<PvPaginationVariant, number> = {\n  short: 5,\n  long: 7,\n};\n\nexport const usePagination = ({\n  variant = \"long\",\n}: {\n  variant?: PvPaginationVariant;\n} = {}) => {\n  /**\n   * Number of reserved pagination slots for:\n   * - First page\n   * - Last page\n   * - Ellipsis (\"...\") indicators\n   * These help keep the pagination compact and readable.\n   */\n  const FIRST_LAST_DOTS = 3;\n\n  const getPaginations = ({\n    currentPage,\n    pages,\n  }: {\n    currentPage: number;\n    pages: number;\n  }) => {\n    if (pages <= variantToNumber[variant]) {\n      return Array.from({ length: pages }, (_, i) => ({\n        page: i + 1,\n        label: (i + 1).toString(),\n      }));\n    }\n\n    const pagination: {\n      page: number;\n      label: string;\n    }[] = [\n      {\n        page: 1,\n        label: \"1\",\n      },\n    ];\n\n    const recalculatedMaxNumberToShow =\n      variantToNumber[variant] - FIRST_LAST_DOTS;\n\n    const halfPagesAhead = Math.floor(recalculatedMaxNumberToShow / 2);\n\n    let start = currentPage - halfPagesAhead;\n    let end = currentPage + halfPagesAhead;\n\n    const showFirstDots = start > 2;\n    const showSecondDots = end < pages - 1;\n\n    if (start <= 2) {\n      start = 2;\n      end = start + recalculatedMaxNumberToShow - 1;\n    }\n\n    if (end >= pages - 1) {\n      end = pages - 1;\n      start = end - recalculatedMaxNumberToShow + 1;\n    }\n\n    if (showFirstDots) {\n      pagination.push({\n        page: 0,\n        label: \"...\",\n      });\n    }\n\n    if (showFirstDots && showSecondDots) {\n      for (let i = start + 1; i <= end - 1; i++) {\n        pagination.push({ page: i, label: i.toString() });\n      }\n    } else {\n      for (let i = start; i <= end; i++) {\n        pagination.push({ page: i, label: i.toString() });\n      }\n    }\n\n    if (showSecondDots) {\n      pagination.push({\n        page: 0,\n        label: \"...\",\n      });\n    }\n\n    if (pages > 1) {\n      pagination.push({ page: pages, label: pages.toString() });\n    }\n\n    return pagination;\n  };\n\n  return {\n    getPaginations,\n  };\n};\n","<script setup lang=\"ts\">\nimport PvButton from \"../PvButton/PvButton.vue\";\nimport { usePagination } from \"./usePagination\";\nimport { PvPaginationSize, PvPaginationVariant } from \"./types\";\n\ninterface PvPaginationProps {\n  /** Size of the pagination buttons */\n  size?: PvPaginationSize;\n  /** Total number of pages available */\n  maxPages: number;\n  maxNumberToShow?: number;\n  /** Display variant controlling the number of visible page buttons (\"short\" shows fewer) */\n  variant?: PvPaginationVariant;\n}\n\nconst props = withDefaults(defineProps<PvPaginationProps>(), {\n  size: \"lg\",\n  variant: \"long\",\n});\n\nconst { getPaginations } = usePagination({\n  variant: props.variant,\n});\n\nconst currentPage = defineModel<number>({ required: true });\n</script>\n\n<template>\n  <ol role=\"list\" class=\"pv-pagination\" data-testid=\"pv-pagination\" :data-style=\"size === 'lg' ? 'small' : undefined\">\n    <li>\n      <PvButton\n        data-testid=\"pagination-left-arrow-icon\"\n        :disabled=\"currentPage === 1\"\n        left-icon=\"chevron-left\"\n        ariaLabel=\"Previous page\"\n        variant=\"ghost\"\n        @click=\"$emit('update:modelValue', currentPage - 1)\"\n      />\n    </li>\n    <li\n      v-for=\"page in getPaginations({\n        currentPage,\n        pages: maxPages,\n      })\"\n      :key=\"page.page\"\n      :data-testid=\"`pagination-button-${page.page}`\"\n      :aria-current=\"page.page === currentPage ? 'page' : undefined\"\n    >\n      <button v-if=\"page.label === '...'\" class=\"dots-button pv-text-subdued\" disabled>\n        {{ page.label }}\n      </button>\n      <button v-else @click=\"$emit('update:modelValue', page.page)\">\n        {{ page.label }}\n      </button>\n    </li>\n    <li>\n      <PvButton\n        data-testid=\"pagination-right-arrow-icon\"\n        :disabled=\"currentPage === maxPages\"\n        left-icon=\"chevron-right\"\n        ariaLabel=\"Next page\"\n        variant=\"ghost\"\n        @click=\"$emit('update:modelValue', currentPage + 1)\"\n      />\n    </li>\n  </ol>\n</template>\n\n<style scoped>\n.dots-button {\n  background-color: transparent;\n}\n</style>\n","<script setup lang=\"ts\">\nimport PvButton from \"../PvButton/PvButton.vue\";\nimport { usePagination } from \"./usePagination\";\nimport { PvPaginationSize, PvPaginationVariant } from \"./types\";\n\ninterface PvPaginationProps {\n  /** Size of the pagination buttons */\n  size?: PvPaginationSize;\n  /** Total number of pages available */\n  maxPages: number;\n  maxNumberToShow?: number;\n  /** Display variant controlling the number of visible page buttons (\"short\" shows fewer) */\n  variant?: PvPaginationVariant;\n}\n\nconst props = withDefaults(defineProps<PvPaginationProps>(), {\n  size: \"lg\",\n  variant: \"long\",\n});\n\nconst { getPaginations } = usePagination({\n  variant: props.variant,\n});\n\nconst currentPage = defineModel<number>({ required: true });\n</script>\n\n<template>\n  <ol role=\"list\" class=\"pv-pagination\" data-testid=\"pv-pagination\" :data-style=\"size === 'lg' ? 'small' : undefined\">\n    <li>\n      <PvButton\n        data-testid=\"pagination-left-arrow-icon\"\n        :disabled=\"currentPage === 1\"\n        left-icon=\"chevron-left\"\n        ariaLabel=\"Previous page\"\n        variant=\"ghost\"\n        @click=\"$emit('update:modelValue', currentPage - 1)\"\n      />\n    </li>\n    <li\n      v-for=\"page in getPaginations({\n        currentPage,\n        pages: maxPages,\n      })\"\n      :key=\"page.page\"\n      :data-testid=\"`pagination-button-${page.page}`\"\n      :aria-current=\"page.page === currentPage ? 'page' : undefined\"\n    >\n      <button v-if=\"page.label === '...'\" class=\"dots-button pv-text-subdued\" disabled>\n        {{ page.label }}\n      </button>\n      <button v-else @click=\"$emit('update:modelValue', page.page)\">\n        {{ page.label }}\n      </button>\n    </li>\n    <li>\n      <PvButton\n        data-testid=\"pagination-right-arrow-icon\"\n        :disabled=\"currentPage === maxPages\"\n        left-icon=\"chevron-right\"\n        ariaLabel=\"Next page\"\n        variant=\"ghost\"\n        @click=\"$emit('update:modelValue', currentPage + 1)\"\n      />\n    </li>\n  </ol>\n</template>\n\n<style scoped>\n.dots-button {\n  background-color: transparent;\n}\n</style>\n","<script setup lang=\"ts\">\nimport { computed } from \"vue\";\nimport { Skeleton } from \"primevue\";\nimport { PvSkeletonSize, PvSkeletonVariant } from \"./types\";\n\nconst mapSizeToPx: Record<PvSkeletonSize, string> = {\n  xs: \"0.75rem\",\n  sm: \"1rem\",\n  md: \"1.25rem\",\n  lg: \"1.5rem\",\n  xl: \"2rem\",\n};\n\ninterface PvSkeletonProps {\n  /** The size of the skeleton placeholder. Sets the height, and the width for the \"square\" and \"circle\" variants. Overridden by `width`/`height` when provided. */\n  size?: PvSkeletonSize;\n  /** The shape variant. \"rectangle\" fills available width; \"square\" and \"circle\" use equal height and width. */\n  variant?: PvSkeletonVariant;\n  /** Optional explicit width (any CSS length, e.g. \"45%\" or \"48px\"). Overrides the width derived from `size`/`variant`. */\n  width?: string;\n  /** Optional explicit height (any CSS length, e.g. \"8px\"). Overrides the height derived from `size`. */\n  height?: string;\n}\n\nconst props = withDefaults(defineProps<PvSkeletonProps>(), {\n  size: \"md\",\n  variant: \"rectangle\",\n});\n\n// \"square\" and \"circle\" are equal-sided unless an explicit width/height is given.\nconst isFixedAspect = computed(() => props.variant === \"square\" || props.variant === \"circle\");\n\nconst resolvedHeight = computed(() => props.height ?? mapSizeToPx[props.size]);\n\nconst resolvedWidth = computed(() => props.width ?? (isFixedAspect.value ? mapSizeToPx[props.size] : \"100%\"));\n\nconst resolvedShape = computed(() => (props.variant === \"circle\" ? \"circle\" : \"rectangle\"));\n</script>\n\n<template>\n  <Skeleton data-testid=\"pv-skeleton\" :shape=\"resolvedShape\" :height=\"resolvedHeight\" :width=\"resolvedWidth\" />\n</template>\n","<script setup lang=\"ts\">\nimport { computed } from \"vue\";\nimport { Skeleton } from \"primevue\";\nimport { PvSkeletonSize, PvSkeletonVariant } from \"./types\";\n\nconst mapSizeToPx: Record<PvSkeletonSize, string> = {\n  xs: \"0.75rem\",\n  sm: \"1rem\",\n  md: \"1.25rem\",\n  lg: \"1.5rem\",\n  xl: \"2rem\",\n};\n\ninterface PvSkeletonProps {\n  /** The size of the skeleton placeholder. Sets the height, and the width for the \"square\" and \"circle\" variants. Overridden by `width`/`height` when provided. */\n  size?: PvSkeletonSize;\n  /** The shape variant. \"rectangle\" fills available width; \"square\" and \"circle\" use equal height and width. */\n  variant?: PvSkeletonVariant;\n  /** Optional explicit width (any CSS length, e.g. \"45%\" or \"48px\"). Overrides the width derived from `size`/`variant`. */\n  width?: string;\n  /** Optional explicit height (any CSS length, e.g. \"8px\"). Overrides the height derived from `size`. */\n  height?: string;\n}\n\nconst props = withDefaults(defineProps<PvSkeletonProps>(), {\n  size: \"md\",\n  variant: \"rectangle\",\n});\n\n// \"square\" and \"circle\" are equal-sided unless an explicit width/height is given.\nconst isFixedAspect = computed(() => props.variant === \"square\" || props.variant === \"circle\");\n\nconst resolvedHeight = computed(() => props.height ?? mapSizeToPx[props.size]);\n\nconst resolvedWidth = computed(() => props.width ?? (isFixedAspect.value ? mapSizeToPx[props.size] : \"100%\"));\n\nconst resolvedShape = computed(() => (props.variant === \"circle\" ? \"circle\" : \"rectangle\"));\n</script>\n\n<template>\n  <Skeleton data-testid=\"pv-skeleton\" :shape=\"resolvedShape\" :height=\"resolvedHeight\" :width=\"resolvedWidth\" />\n</template>\n","// Finer than {1, 2, 5, 10} so a rounded axis bound leaves at most ~25% empty space past the data.\nconst NICE_STEPS = [1, 1.5, 2, 3, 4, 5, 6, 8, 10];\n\nconst roundUpToNice = (value: number): number => {\n  const pow = Math.pow(10, Math.floor(Math.log10(value)));\n  const step = NICE_STEPS.find((s) => value / pow <= s) ?? 10;\n  return step * pow;\n};\n\n/** Rounds `value` up to a clean axis bound. Returns 100 for zero or negative input so an empty axis still has a scale. */\nexport const niceCeiling = (value: number): number => (value > 0 ? roundUpToNice(value) : 100);\n\n/** Tick interval that gives about five ticks on an axis from 0 to `max`. */\nexport const niceStep = (max: number): number => (max > 0 ? roundUpToNice(max / 5) : 10);\n\n/** Tick positions from 0 to `max`, inclusive. */\nexport const axisTicks = (max: number): number[] => {\n  const step = niceStep(max);\n  const ticks: number[] = [];\n  // Rounding keeps float steps like 1.5 from drifting (e.g. 4.5000000001).\n  for (let i = 0; i * step <= max + 1e-6; i++) ticks.push(Number((i * step).toPrecision(12)));\n  return ticks;\n};\n\nconst usd = new Intl.NumberFormat(\"en-US\", { style: \"currency\", currency: \"USD\", maximumFractionDigits: 0 });\n\nexport const formatWholeDollars = (value: number): string => usd.format(value);\n","import type { PvFilterPanelOption } from \"./types\";\n\nexport interface PvFilterPanelScopedValue {\n  field?: string;\n  pairs: Array<{ field: string; value: string }>;\n  value: string;\n}\n\nconst FILTER_PANEL_SCOPED_VALUE_PREFIX = \"__pv_filter_panel_scoped_value__\";\n\nconst isRecord = (value: unknown): value is Record<string, unknown> => {\n  return typeof value === \"object\" && value !== null;\n};\n\nconst parseScopedPayload = (payload: string): Array<{ field: string; value: string }> => {\n  try {\n    const parsed = JSON.parse(decodeURIComponent(payload)) as unknown;\n    if (!Array.isArray(parsed)) return [];\n    return parsed.flatMap((entry) => {\n      if (!Array.isArray(entry) || entry.length < 2) return [];\n      const [field, fieldValue] = entry;\n      return typeof field === \"string\" && typeof fieldValue === \"string\" ? [{ field, value: fieldValue }] : [];\n    });\n  } catch {\n    return [];\n  }\n};\n\nconst parseLegacyScopedValue = (value: string): PvFilterPanelScopedValue | null => {\n  if (!value.startsWith(\"__\")) return null;\n  const parts = value.slice(2).split(\"__\");\n  if (parts.length < 2 || !parts[0] || !parts[1]) return null;\n  const pairs = [{ field: parts[0], value: parts[1] }];\n  return { field: pairs[0].field, pairs, value: pairs[0].value };\n};\n\nexport const parseFilterPanelScopedValue = (value: string | null | undefined): PvFilterPanelScopedValue | null => {\n  if (value == null) return null;\n  if (!value.startsWith(FILTER_PANEL_SCOPED_VALUE_PREFIX)) return parseLegacyScopedValue(value) ?? { pairs: [], value };\n\n  const pairs = parseScopedPayload(value.slice(FILTER_PANEL_SCOPED_VALUE_PREFIX.length));\n\n  return {\n    field: pairs[0]?.field,\n    pairs,\n    value: pairs[0]?.value ?? value,\n  };\n};\n\nexport const createFilterPanelScopedValue = (field: string, value: string): string =>\n  `${FILTER_PANEL_SCOPED_VALUE_PREFIX}${encodeURIComponent(JSON.stringify([[field, value]]))}`;\n\nexport const getFilterPanelOptionRawValue = (option: PvFilterPanelOption | null | undefined): string | null => {\n  if (!option) return null;\n  if (option.rawValue !== null && option.rawValue !== undefined) return String(option.rawValue);\n  if (isRecord(option.metadata) && option.metadata.rawValue !== null && option.metadata.rawValue !== undefined) {\n    return String(option.metadata.rawValue);\n  }\n  if (option.matchedValue !== null && option.matchedValue !== undefined) return String(option.matchedValue);\n  return parseFilterPanelScopedValue(option.value)?.value ?? option.value;\n};\n\nexport const getFilterPanelOptionField = (\n  option: PvFilterPanelOption | null | undefined,\n  fallbackField: string,\n): string => {\n  if (option?.field) return option.field;\n  if (option?.colField) return option.colField;\n  return parseFilterPanelScopedValue(option?.value)?.field ?? fallbackField;\n};\n\nexport const flattenFilterPanelOptions = (options: PvFilterPanelOption[]): PvFilterPanelOption[] => {\n  return options.flatMap((option) => [\n    option,\n    ...(option.children?.length ? flattenFilterPanelOptions(option.children) : []),\n  ]);\n};\n\nexport const filterPanelOptionMatchesRawValue = (\n  option: PvFilterPanelOption,\n  field: string,\n  rawValue: string,\n  fallbackField: string,\n): boolean => {\n  return (\n    getFilterPanelOptionField(option, fallbackField) === field && getFilterPanelOptionRawValue(option) === rawValue\n  );\n};\n","import { parseFilterPanelScopedValue } from \"./filterOptionValue\";\nimport type { PvFilterPanelOption } from \"./types\";\n\nexport type PvFilterPanelDisplayResultCount = number | string;\nexport type FilterPanelDisplayResultCount = PvFilterPanelDisplayResultCount;\n\ninterface FilterOptionDisplaySource {\n  label?: string;\n  metadata?: unknown;\n  rawValue?: boolean | number | string | null;\n  resultCount?: unknown;\n  totalChildCount?: unknown;\n  value: string;\n}\n\ninterface FilterOptionColDefLike {\n  context?: {\n    filterValueFormatter?: ((params: never) => string) | string | null;\n    metadataDisplayFields?: string[];\n  } | null;\n  valueFormatter?: ((params: never) => string) | string | null;\n}\n\nconst RESULT_COUNT_METADATA_KEYS = [\"totalCount\", \"total_count\", \"resultCount\", \"result_count\", \"row_count\", \"count\"];\n\nconst compactNumberFormatter = new Intl.NumberFormat(\"en-US\", {\n  maximumFractionDigits: 1,\n  notation: \"compact\",\n});\n\nconst isRecord = (value: unknown): value is Record<string, unknown> => {\n  return typeof value === \"object\" && value !== null;\n};\n\nconst formatResultCount = (value: unknown): PvFilterPanelDisplayResultCount | undefined => {\n  if (typeof value === \"number\" && Number.isFinite(value)) {\n    return compactNumberFormatter.format(value);\n  }\n\n  if (typeof value === \"string\") {\n    const trimmedValue = value.trim();\n    if (!trimmedValue) return undefined;\n\n    const parsed = Number(trimmedValue);\n    if (Number.isFinite(parsed)) return compactNumberFormatter.format(parsed);\n    return value;\n  }\n\n  return undefined;\n};\n\nconst getFractionDigits = (dataType?: string | null, valueDecimals?: number | null): number => {\n  if (valueDecimals !== null && valueDecimals !== undefined) return valueDecimals;\n  if (dataType === \"currency\" || dataType === \"integer\" || dataType === \"percent\") return 0;\n  return 2;\n};\n\nexport const formatFilterPanelScalarValue = (\n  value: number,\n  options: { dataType?: string | null; valueDecimals?: number | null } = {},\n): string => {\n  const fractionDigits = getFractionDigits(options.dataType, options.valueDecimals);\n\n  if (options.dataType === \"currency\") {\n    return new Intl.NumberFormat(\"en-US\", {\n      currency: \"USD\",\n      maximumFractionDigits: fractionDigits,\n      minimumFractionDigits: fractionDigits,\n      style: \"currency\",\n    }).format(value);\n  }\n\n  const formattedNumber = new Intl.NumberFormat(\"en-US\", {\n    maximumFractionDigits: fractionDigits,\n    minimumFractionDigits: fractionDigits,\n  }).format(value);\n\n  return options.dataType === \"percent\" ? `${formattedNumber}%` : formattedNumber;\n};\n\nexport const formatFilterPanelRangeValue = (\n  min: number | null,\n  max: number | null,\n  options: { dataType?: string | null; valueDecimals?: number | null } = {},\n): string => {\n  if (min !== null && max !== null) {\n    return `${formatFilterPanelScalarValue(min, options)}–${formatFilterPanelScalarValue(max, options)}`;\n  }\n\n  if (min !== null) return `${formatFilterPanelScalarValue(min, options)}+`;\n  if (max !== null) return `≤ ${formatFilterPanelScalarValue(max, options)}`;\n  return \"\";\n};\n\nconst getFormatterValue = (option: FilterOptionDisplaySource) => {\n  if (option.rawValue !== null && option.rawValue !== undefined) return option.rawValue;\n  if (isRecord(option.metadata) && option.metadata.rawValue !== null && option.metadata.rawValue !== undefined) {\n    return option.metadata.rawValue;\n  }\n  return option.value;\n};\n\nconst getMetadataLabel = (option: FilterOptionDisplaySource, colDef?: FilterOptionColDefLike) => {\n  const metadata = option.metadata;\n  if (!isRecord(metadata)) return null;\n\n  for (const field of colDef?.context?.metadataDisplayFields ?? []) {\n    const value = metadata[field];\n    if (value !== null && value !== undefined && String(value).trim()) return String(value);\n  }\n\n  return null;\n};\n\nconst callFormatter = (formatter: (params: never) => string, params: { context: unknown; value: unknown }) => {\n  try {\n    return formatter(params as never) || null;\n  } catch {\n    return null;\n  }\n};\n\n// Same params PvDataTable's set filter passes: the option is the context, with a metadata label\n// standing in unless the option already carries a label for a non-id value.\nconst formatWithFilterValueFormatter = (option: FilterOptionDisplaySource, colDef?: FilterOptionColDefLike) => {\n  const formatter = colDef?.context?.filterValueFormatter;\n  if (typeof formatter !== \"function\") return null;\n\n  const hasRawValue =\n    (option.rawValue !== null && option.rawValue !== undefined) ||\n    (isRecord(option.metadata) && option.metadata.rawValue !== null && option.metadata.rawValue !== undefined);\n  const label = option.label && !hasRawValue ? option.label : (getMetadataLabel(option, colDef) ?? option.label);\n  return callFormatter(formatter, { context: { ...option, label }, value: getFormatterValue(option) });\n};\n\nconst formatWithValueFormatter = (option: FilterOptionDisplaySource, colDef?: FilterOptionColDefLike) => {\n  if (typeof colDef?.valueFormatter !== \"function\") return null;\n  return callFormatter(colDef.valueFormatter, { context: option.metadata, value: getFormatterValue(option) });\n};\n\nexport const getFilterOptionLabel = (option: FilterOptionDisplaySource, colDef?: FilterOptionColDefLike) => {\n  return (\n    formatWithFilterValueFormatter(option, colDef) ||\n    option.label ||\n    getMetadataLabel(option, colDef) ||\n    formatWithValueFormatter(option, colDef) ||\n    option.value\n  );\n};\n\nconst getOptionIds = (option: PvFilterPanelOption) => {\n  const metadataRawValue = isRecord(option.metadata) ? option.metadata.rawValue : undefined;\n  return Array.from(\n    new Set(\n      [option.value, option.rawValue, metadataRawValue, parseFilterPanelScopedValue(option.value)?.value]\n        .filter((value) => value !== null && value !== undefined)\n        .map(String),\n    ),\n  );\n};\n\nconst isUnresolvedFilterOption = (option: PvFilterPanelOption, colDef?: FilterOptionColDefLike) => {\n  if (!colDef?.context?.metadataDisplayFields?.length) return false;\n  if (getMetadataLabel(option, colDef)) return false;\n  const label = option.label?.trim();\n  return !label || getOptionIds(option).includes(label);\n};\n\nconst indexKnownOptions = (options: PvFilterPanelOption[], colDef?: FilterOptionColDefLike) => {\n  const optionById = new Map<string, PvFilterPanelOption>();\n\n  const visit = (option: PvFilterPanelOption) => {\n    const unresolved = isUnresolvedFilterOption(option, colDef);\n    for (const id of getOptionIds(option)) {\n      const existing = optionById.get(id);\n      // The first named copy wins: callers list current options before cached ones.\n      if (!existing || (isUnresolvedFilterOption(existing, colDef) && !unresolved)) optionById.set(id, option);\n    }\n    option.children?.forEach(visit);\n  };\n\n  options.forEach(visit);\n  return optionById;\n};\n\nconst resolveOptionName = (\n  option: PvFilterPanelOption,\n  optionById: Map<string, PvFilterPanelOption>,\n  colDef?: FilterOptionColDefLike,\n) => {\n  const metadataLabel = getMetadataLabel(option, colDef);\n  const label = option.label?.trim();\n  if (metadataLabel && (!label || getOptionIds(option).includes(label))) return { ...option, label: metadataLabel };\n  if (!isUnresolvedFilterOption(option, colDef)) return option;\n\n  const named = getOptionIds(option)\n    .map((id) => optionById.get(id))\n    .find((candidate) => candidate && !isUnresolvedFilterOption(candidate, colDef));\n  if (!named) return null;\n\n  const namedLabel = getMetadataLabel(named, colDef) ?? named.label;\n  if (!namedLabel) return null;\n\n  // Keep all the named copy's metadata for formatters, with the row's own non-empty fields on top.\n  const ownMetadata = Object.entries(isRecord(option.metadata) ? option.metadata : {}).filter(\n    ([, value]) => value !== null && value !== undefined && value !== \"\",\n  );\n  const metadata = { ...(isRecord(named.metadata) ? named.metadata : {}), ...Object.fromEntries(ownMetadata) };\n\n  return { ...option, label: namedLabel, ...(Object.keys(metadata).length ? { metadata } : {}) };\n};\n\nexport const resolveFilterPanelOptions = (\n  options: PvFilterPanelOption[],\n  knownOptions: PvFilterPanelOption[],\n  colDef?: FilterOptionColDefLike,\n): PvFilterPanelOption[] => {\n  if (!colDef?.context?.metadataDisplayFields?.length) return options;\n  const optionById = indexKnownOptions(knownOptions, colDef);\n\n  const resolve = (rawOptions: PvFilterPanelOption[]): PvFilterPanelOption[] => {\n    return rawOptions.flatMap((rawOption) => {\n      const option = resolveOptionName(rawOption, optionById, colDef);\n      if (!option) return [];\n      if (!option.children?.length) return [option];\n\n      const children = resolve(option.children);\n      const totalChildCount =\n        option.totalChildCount !== undefined && option.children.length >= option.totalChildCount\n          ? children.length\n          : option.totalChildCount;\n      return [{ ...option, children, totalChildCount }];\n    });\n  };\n\n  return resolve(options);\n};\n\nexport const getFilterOptionResultCount = (option: FilterOptionDisplaySource | null | undefined) => {\n  const directResultCount = formatResultCount(option?.resultCount);\n  if (directResultCount !== undefined) return directResultCount;\n\n  const metadata = option?.metadata;\n  if (isRecord(metadata)) {\n    for (const key of RESULT_COUNT_METADATA_KEYS) {\n      const resultCount = formatResultCount(metadata[key]);\n      if (resultCount !== undefined) return resultCount;\n    }\n  }\n\n  return formatResultCount(option?.totalChildCount);\n};\n","import type { AdvancedFilterModel } from \"ag-grid-enterprise\";\nimport type { MultiSelectState, SelectionNode } from \"@/types\";\nimport {\n  createFilterPanelScopedValue,\n  getFilterPanelOptionField,\n  getFilterPanelOptionRawValue,\n  parseFilterPanelScopedValue,\n} from \"./filterOptionValue\";\nimport type { PvFilterPanelAggregateFieldHierarchy, PvFilterPanelColDef, PvFilterPanelOption } from \"./types\";\n\ninterface LooseAdvancedFilterNode {\n  colId?: string;\n  conditions?: AdvancedFilterModel[];\n  filter?: boolean | number | string | null;\n  filterType?: string;\n  type?: string;\n}\n\nexport interface PvFilterPanelAggregateSelectionStatus {\n  indeterminate: boolean;\n  selected: boolean;\n}\n\nexport interface PvFilterPanelAggregateFieldValue {\n  field?: string;\n  value: string;\n}\n\nconst isAdvancedFilterJoin = (model: AdvancedFilterModel | null | undefined): model is AdvancedFilterModel => {\n  const node = model as LooseAdvancedFilterNode | null | undefined;\n  return node?.filterType === \"join\" && Array.isArray(node.conditions);\n};\n\nconst cloneAdvancedFilterNode = (model: AdvancedFilterModel): AdvancedFilterModel => {\n  const node = model as LooseAdvancedFilterNode;\n  if (!isAdvancedFilterJoin(model)) return { ...node } as AdvancedFilterModel;\n\n  return {\n    ...node,\n    conditions: (node.conditions ?? []).map(cloneAdvancedFilterNode),\n  } as AdvancedFilterModel;\n};\n\nexport const removeFilterPanelAggregateFieldsFromModel = (\n  model: AdvancedFilterModel | null | undefined,\n  fields: string[] | Set<string>,\n): AdvancedFilterModel | null => {\n  if (!model) return null;\n  const fieldSet = fields instanceof Set ? fields : new Set(fields);\n  if (!fieldSet.size) return cloneAdvancedFilterNode(model);\n\n  if (!isAdvancedFilterJoin(model)) {\n    const node = model as LooseAdvancedFilterNode;\n    return typeof node.colId === \"string\" && fieldSet.has(node.colId) ? null : cloneAdvancedFilterNode(model);\n  }\n\n  const node = model as LooseAdvancedFilterNode;\n  const conditions = (node.conditions ?? [])\n    .map((condition) => removeFilterPanelAggregateFieldsFromModel(condition, fieldSet))\n    .filter((condition): condition is AdvancedFilterModel => Boolean(condition));\n\n  if (!conditions.length) return null;\n  if (conditions.length === 1) return conditions[0];\n\n  return {\n    ...node,\n    conditions,\n  } as AdvancedFilterModel;\n};\n\nexport const flattenFilterPanelAggregateFieldHierarchy = (\n  hierarchy: PvFilterPanelAggregateFieldHierarchy | undefined,\n): string[] => {\n  if (!hierarchy) return [];\n  return [hierarchy.field, ...(hierarchy.children ?? []).flatMap(flattenFilterPanelAggregateFieldHierarchy)];\n};\n\nexport const getFilterPanelAggregateLeafFields = (\n  hierarchy: PvFilterPanelAggregateFieldHierarchy | undefined,\n): string[] => {\n  if (!hierarchy) return [];\n  if (!hierarchy.children?.length) return [hierarchy.field];\n  return hierarchy.children.flatMap(getFilterPanelAggregateLeafFields);\n};\n\nexport const getFilterPanelAggregateFields = (colDef: PvFilterPanelColDef | null | undefined): string[] => {\n  const context = colDef?.context ?? {};\n  return context.aggregateFieldHierarchy\n    ? flattenFilterPanelAggregateFieldHierarchy(context.aggregateFieldHierarchy)\n    : (context.aggregateFields ?? []);\n};\n\nexport const getFilterPanelAggregateRootField = (\n  colDef: PvFilterPanelColDef | null | undefined,\n): string | undefined => {\n  const context = colDef?.context ?? {};\n  if (context.aggregateFieldHierarchy) return context.aggregateFieldHierarchy.field;\n  return context.aggregateFields?.[context.aggregateFields.length - 1];\n};\n\nexport const isFilterPanelAggregateColDef = (colDef: PvFilterPanelColDef | null | undefined): boolean => {\n  return getFilterPanelAggregateFields(colDef).length > 0;\n};\n\nexport const findFilterPanelOptionByValue = (\n  options: (PvFilterPanelOption | null)[] | undefined,\n  value: string,\n): PvFilterPanelOption | undefined => {\n  for (const option of options ?? []) {\n    if (!option) continue;\n    if (option.value === value) return option;\n    const childMatch = findFilterPanelOptionByValue(option.children, value);\n    if (childMatch) return childMatch;\n  }\n  return undefined;\n};\n\nconst findFilterPanelOptionPathByValue = (\n  options: (PvFilterPanelOption | null)[] | undefined,\n  value: string,\n  path: PvFilterPanelOption[] = [],\n): PvFilterPanelOption[] | undefined => {\n  for (const option of options ?? []) {\n    if (!option) continue;\n    const nextPath = [...path, option];\n    if (option.value === value) return nextPath;\n    const childPath = findFilterPanelOptionPathByValue(option.children, value, nextPath);\n    if (childPath) return childPath;\n  }\n  return undefined;\n};\n\nexport const getFilterPanelAggregateFieldValue = (\n  optionId: string,\n  options?: (PvFilterPanelOption | null)[],\n): PvFilterPanelAggregateFieldValue => {\n  const option = findFilterPanelOptionByValue(options, optionId);\n  const optionField = option ? getFilterPanelOptionField(option, \"\") : undefined;\n  const optionRawValue = option ? getFilterPanelOptionRawValue(option) : null;\n  if (optionField && optionRawValue !== null) return { field: optionField, value: optionRawValue };\n\n  const parsed = parseFilterPanelScopedValue(optionId);\n  return {\n    field: parsed?.field,\n    value: parsed?.value ?? optionId,\n  };\n};\n\nexport const findFilterPanelAggregateOptionId = (\n  options: (PvFilterPanelOption | null)[] | undefined,\n  field: string,\n  rawValue: string,\n): string => {\n  const matches = (option: PvFilterPanelOption | null): string | undefined => {\n    if (!option) return undefined;\n    const optionField = getFilterPanelOptionField(option, \"\");\n    const optionRawValue = getFilterPanelOptionRawValue(option);\n    if (optionField === field && optionRawValue === rawValue) return option.value;\n\n    for (const child of option.children ?? []) {\n      const childMatch = matches(child);\n      if (childMatch) return childMatch;\n    }\n    return undefined;\n  };\n\n  for (const option of options ?? []) {\n    const match = matches(option);\n    if (match) return match;\n  }\n\n  return `__${field}__${rawValue}`;\n};\n\nconst collectDeselectedSelectionNodes = (nodes: SelectionNode[] | undefined): SelectionNode[] => {\n  return (nodes ?? []).flatMap((node) => [\n    ...(node.state === \"deselected\" ? [node] : []),\n    ...collectDeselectedSelectionNodes(node.children),\n  ]);\n};\n\nconst buildFilterPanelAggregateNodeCondition = (\n  node: SelectionNode,\n  options?: (PvFilterPanelOption | null)[],\n): AdvancedFilterModel | null => {\n  if (node.state !== \"selected\") return null;\n\n  const { field, value } = getFilterPanelAggregateFieldValue(node.id, options);\n  if (!field) return null;\n\n  const conditions: AdvancedFilterModel[] = [\n    {\n      colId: field,\n      filter: value,\n      filterType: \"text\",\n      type: \"equals\",\n    } as AdvancedFilterModel,\n  ];\n\n  for (const child of collectDeselectedSelectionNodes(node.children)) {\n    const childValue = getFilterPanelAggregateFieldValue(child.id, options);\n    if (!childValue.field) continue;\n    conditions.push({\n      colId: childValue.field,\n      filter: childValue.value,\n      filterType: \"text\",\n      type: \"notEqual\",\n    } as AdvancedFilterModel);\n  }\n\n  return conditions.length === 1\n    ? conditions[0]\n    : ({ conditions, filterType: \"join\", type: \"AND\" } as AdvancedFilterModel);\n};\n\nexport const buildFilterPanelAggregateModelFromSelectionState = (params: {\n  baseModel: AdvancedFilterModel | null | undefined;\n  colDef: PvFilterPanelColDef;\n  options?: (PvFilterPanelOption | null)[];\n  state: MultiSelectState;\n}): AdvancedFilterModel | null => {\n  const aggregateFields = getFilterPanelAggregateFields(params.colDef);\n  const baseModel = removeFilterPanelAggregateFieldsFromModel(params.baseModel, aggregateFields);\n  if (!aggregateFields.length) return baseModel;\n\n  const conditions = params.state\n    .map((node) => buildFilterPanelAggregateNodeCondition(node, params.options))\n    .filter((condition): condition is AdvancedFilterModel => Boolean(condition));\n\n  if (!conditions.length) return baseModel;\n\n  const aggregateCondition: AdvancedFilterModel =\n    conditions.length === 1 ? conditions[0] : ({ conditions, filterType: \"join\", type: \"OR\" } as AdvancedFilterModel);\n\n  if (!baseModel) return aggregateCondition;\n  return { conditions: [baseModel, aggregateCondition], filterType: \"join\", type: \"AND\" } as AdvancedFilterModel;\n};\n\nconst getFilterPanelAggregateColumnConditions = (\n  model: AdvancedFilterModel | null | undefined,\n  fields: Set<string>,\n  leafFields: Set<string>,\n): Array<{ colId: string; filter?: string; parentEquals?: { colId: string; filter?: string }; type?: string }> => {\n  if (!model) return [];\n  const node = model as LooseAdvancedFilterNode;\n\n  if (isAdvancedFilterJoin(model)) {\n    const conditions = node.conditions ?? [];\n    if (node.type === \"AND\") {\n      const directEquals = conditions.find((condition) => {\n        const conditionNode = condition as LooseAdvancedFilterNode;\n        return (\n          conditionNode.filterType !== \"join\" &&\n          typeof conditionNode.colId === \"string\" &&\n          fields.has(conditionNode.colId) &&\n          conditionNode.type === \"equals\" &&\n          !leafFields.has(conditionNode.colId)\n        );\n      }) as LooseAdvancedFilterNode | undefined;\n\n      return conditions.flatMap((condition) =>\n        getFilterPanelAggregateColumnConditions(condition, fields, leafFields).map((childCondition) => ({\n          ...childCondition,\n          parentEquals:\n            childCondition.parentEquals ||\n            (directEquals?.colId\n              ? {\n                  colId: directEquals.colId,\n                  filter: directEquals.filter == null ? undefined : String(directEquals.filter),\n                }\n              : undefined),\n        })),\n      );\n    }\n\n    return conditions.flatMap((condition) => getFilterPanelAggregateColumnConditions(condition, fields, leafFields));\n  }\n\n  if (node.colId && fields.has(node.colId)) {\n    return [\n      {\n        colId: node.colId,\n        filter: node.filter == null ? undefined : String(node.filter),\n        type: node.type,\n      },\n    ];\n  }\n\n  return [];\n};\n\nexport const seedFilterPanelAggregateSelectionState = (params: {\n  colDef: PvFilterPanelColDef;\n  model: AdvancedFilterModel | null | undefined;\n  options?: (PvFilterPanelOption | null)[];\n}): MultiSelectState => {\n  const aggregateFields = getFilterPanelAggregateFields(params.colDef);\n  if (!aggregateFields.length) return [];\n\n  const leafFields = new Set(getFilterPanelAggregateLeafFields(params.colDef.context?.aggregateFieldHierarchy));\n  const rootField = getFilterPanelAggregateRootField(params.colDef);\n  const conditions = getFilterPanelAggregateColumnConditions(params.model, new Set(aggregateFields), leafFields);\n  const nodeMap = new Map<string, SelectionNode>();\n\n  for (const condition of conditions) {\n    if (!condition.filter) continue;\n    const optionId = findFilterPanelAggregateOptionId(params.options, condition.colId, String(condition.filter));\n\n    if (condition.type === \"equals\") {\n      const existing = nodeMap.get(optionId);\n      nodeMap.set(optionId, { id: optionId, state: \"selected\", children: existing?.children });\n      continue;\n    }\n\n    if (condition.type === \"notEqual\" && condition.parentEquals?.filter && rootField) {\n      const parentId = findFilterPanelAggregateOptionId(\n        params.options,\n        condition.parentEquals.colId,\n        String(condition.parentEquals.filter),\n      );\n      const existing = nodeMap.get(parentId) ?? { children: [], id: parentId, state: \"selected\" as const };\n      existing.children = [...(existing.children ?? []), { id: optionId, state: \"deselected\" as const }];\n      nodeMap.set(parentId, existing);\n    }\n  }\n\n  return [...nodeMap.values()];\n};\n\nexport const getFilterPanelAggregateSelectedValuesByField = (params: {\n  colDef: PvFilterPanelColDef;\n  model: AdvancedFilterModel | null | undefined;\n  options?: (PvFilterPanelOption | null)[];\n}): Map<string, string[]> => {\n  const selectedValuesByField = new Map<string, string[]>();\n  const aggregateFields = getFilterPanelAggregateFields(params.colDef);\n  if (!aggregateFields.length) return selectedValuesByField;\n\n  const conditions = getFilterPanelAggregateColumnConditions(\n    params.model,\n    new Set(aggregateFields),\n    new Set(getFilterPanelAggregateLeafFields(params.colDef.context?.aggregateFieldHierarchy)),\n  );\n\n  for (const condition of conditions) {\n    if (condition.type !== \"equals\" || !condition.filter) continue;\n    const values = selectedValuesByField.get(condition.colId) ?? [];\n    if (!values.includes(condition.filter)) values.push(condition.filter);\n    selectedValuesByField.set(condition.colId, values);\n  }\n\n  return selectedValuesByField;\n};\n\nconst cloneSelectionState = (state: MultiSelectState): MultiSelectState =>\n  state.map((node) => ({\n    ...node,\n    children: node.children?.map((child) => ({\n      ...child,\n      children: child.children ? cloneSelectionState(child.children) : undefined,\n    })),\n  }));\n\nconst removeSelectionNodeById = (state: MultiSelectState, id: string): MultiSelectState => {\n  return state.flatMap((node) => {\n    if (node.id === id) return [];\n    const children = node.children ? removeSelectionNodeById(node.children, id) : undefined;\n    return [{ ...node, children: children?.length ? children : undefined }];\n  });\n};\n\nconst getSelectionNode = (state: MultiSelectState, id: string): SelectionNode | undefined => {\n  for (const node of state) {\n    if (node.id === id) return node;\n    const childMatch = node.children ? getSelectionNode(node.children, id) : undefined;\n    if (childMatch) return childMatch;\n  }\n  return undefined;\n};\n\nconst hasAggregateChildren = (option: PvFilterPanelOption) => {\n  return Boolean(option.children?.length) || (option.totalChildCount ?? 0) > 0;\n};\n\nconst upsertSelectionNode = (state: MultiSelectState, node: SelectionNode): MultiSelectState => {\n  const withoutExisting = removeSelectionNodeById(state, node.id);\n  return [...withoutExisting, node];\n};\n\nconst collectDescendantOptionIds = (option: PvFilterPanelOption): string[] => {\n  return (option.children ?? []).flatMap((child) => [child.value, ...collectDescendantOptionIds(child)]);\n};\n\nconst removeDescendantSelectionNodes = (state: MultiSelectState, option: PvFilterPanelOption): MultiSelectState => {\n  return collectDescendantOptionIds(option).reduce(\n    (nextState, descendantId) => removeSelectionNodeById(nextState, descendantId),\n    state,\n  );\n};\n\nconst removeSelectionNodeAndDescendants = (state: MultiSelectState, option: PvFilterPanelOption): MultiSelectState => {\n  return [option.value, ...collectDescendantOptionIds(option)].reduce(\n    (nextState, descendantId) => removeSelectionNodeById(nextState, descendantId),\n    state,\n  );\n};\n\nconst getNearestSelectedAncestor = (\n  state: MultiSelectState,\n  option: PvFilterPanelOption,\n  options?: (PvFilterPanelOption | null)[],\n): SelectionNode | undefined => {\n  const path = findFilterPanelOptionPathByValue(options, option.value) ?? [];\n  const ancestors = path.slice(0, -1).reverse();\n\n  for (const ancestor of ancestors) {\n    const selectedAncestor = getSelectionNode(state, ancestor.value);\n    if (selectedAncestor?.state === \"selected\") return selectedAncestor;\n  }\n\n  return undefined;\n};\n\nexport const updateFilterPanelAggregateSelectionState = (params: {\n  checked: boolean;\n  option: PvFilterPanelOption;\n  options?: (PvFilterPanelOption | null)[];\n  state: MultiSelectState;\n}): MultiSelectState => {\n  const nextState = cloneSelectionState(params.state);\n  const selectedAncestor = getNearestSelectedAncestor(nextState, params.option, params.options);\n\n  if (selectedAncestor) {\n    const existingDeselectedChildren = selectedAncestor.children ?? [];\n    selectedAncestor.children = params.checked\n      ? removeSelectionNodeAndDescendants(existingDeselectedChildren, params.option)\n      : [\n          ...removeSelectionNodeAndDescendants(existingDeselectedChildren, params.option),\n          { id: params.option.value, state: \"deselected\" as const },\n        ];\n    if (!selectedAncestor.children.length) delete selectedAncestor.children;\n    return nextState;\n  }\n\n  if (hasAggregateChildren(params.option)) {\n    return params.checked\n      ? upsertSelectionNode(removeDescendantSelectionNodes(nextState, params.option), {\n          id: params.option.value,\n          state: \"selected\",\n        })\n      : removeSelectionNodeById(nextState, params.option.value);\n  }\n\n  return params.checked\n    ? upsertSelectionNode(nextState, { id: params.option.value, state: \"selected\" })\n    : removeSelectionNodeById(nextState, params.option.value);\n};\n\nconst createSelectionNodeMap = (state: MultiSelectState) => {\n  const nodeMap = new Map<string, SelectionNode>();\n\n  const addNodes = (nodes: SelectionNode[] | undefined) => {\n    for (const node of nodes ?? []) {\n      nodeMap.set(node.id, node);\n      addNodes(node.children);\n    }\n  };\n\n  addNodes(state);\n  return nodeMap;\n};\n\nexport const createFilterPanelAggregateSelectionStatusMap = (params: {\n  options?: (PvFilterPanelOption | null)[];\n  state: MultiSelectState;\n}): Map<string, PvFilterPanelAggregateSelectionStatus> => {\n  const nodeMap = createSelectionNodeMap(params.state);\n  const statusMap = new Map<string, PvFilterPanelAggregateSelectionStatus>();\n\n  const visitOption = (\n    option: PvFilterPanelOption,\n    inheritedSelected: boolean,\n  ): PvFilterPanelAggregateSelectionStatus => {\n    const directNode = nodeMap.get(option.value);\n    const selected = directNode?.state === \"selected\" || (inheritedSelected && directNode?.state !== \"deselected\");\n\n    const childStatuses: PvFilterPanelAggregateSelectionStatus[] = (option.children ?? []).map((child) =>\n      visitOption(child, selected),\n    );\n    const hasSelectedChild = childStatuses.some((status) => status.selected || status.indeterminate);\n    const hasUnselectedChild = childStatuses.some((status) => !status.selected || status.indeterminate);\n    const hasDeselectedChildren = collectDeselectedSelectionNodes(directNode?.children).length > 0;\n    const status: PvFilterPanelAggregateSelectionStatus = {\n      indeterminate: hasDeselectedChildren || (!selected && hasSelectedChild) || (selected && hasUnselectedChild),\n      selected,\n    };\n\n    statusMap.set(option.value, status);\n    return status;\n  };\n\n  for (const option of params.options ?? []) {\n    if (option) visitOption(option, false);\n  }\n\n  return statusMap;\n};\n\nexport const getFilterPanelAggregateOptionSelectionStatus = (params: {\n  option: PvFilterPanelOption;\n  options?: (PvFilterPanelOption | null)[];\n  state: MultiSelectState;\n}): PvFilterPanelAggregateSelectionStatus => {\n  return (\n    createFilterPanelAggregateSelectionStatusMap(params).get(params.option.value) ??\n    createFilterPanelAggregateSelectionStatusMap({ options: [params.option], state: params.state }).get(\n      params.option.value,\n    ) ?? {\n      indeterminate: false,\n      selected: false,\n    }\n  );\n};\n\nexport const getFilterPanelAggregateSelectionOptions = (params: {\n  options?: (PvFilterPanelOption | null)[];\n  state: MultiSelectState;\n}): PvFilterPanelOption[] => {\n  return params.state.flatMap((node) => {\n    if (node.state !== \"selected\") return [];\n    const option = findFilterPanelOptionByValue(params.options, node.id);\n    if (option) return [option];\n\n    const { field, value } = getFilterPanelAggregateFieldValue(node.id, params.options);\n    return [\n      {\n        colField: field,\n        label: value,\n        metadata: { rawValue: value },\n        value: field ? createFilterPanelScopedValue(field, value) : node.id,\n      },\n    ];\n  });\n};\n\nexport const getFilterPanelAggregateSelectionCount = (state: MultiSelectState): number => {\n  return state.filter((node) => node.state === \"selected\").length;\n};\n","export const buildFilterSearchPlaceholder = (\n  currentField: string | undefined,\n  queryColIds: (string | null | undefined)[] | undefined,\n  getDisplayName: (field: string) => string | null | undefined,\n) => {\n  const searchableFields = [currentField, ...(queryColIds ?? [])].filter((field): field is string => Boolean(field));\n  if (searchableFields.length <= 1) return \"Search\";\n\n  const seenFields = new Set<string>();\n  const labels = searchableFields.flatMap((field) => {\n    if (seenFields.has(field)) return [];\n    seenFields.add(field);\n    return [getDisplayName(field) || field];\n  });\n\n  return labels.length ? `Search ${labels.join(\", \")}` : \"Search\";\n};\n\nconst normalizeFilterSearchText = (value: string | null | undefined) =>\n  String(value ?? \"\")\n    .trim()\n    .replace(/\\s+/g, \" \")\n    .toLocaleLowerCase();\n\nexport const formatSearchMatchSubText = ({\n  fallbackSubText,\n  getDisplayName,\n  matchedField,\n  matchedValue,\n  primaryText,\n  showPrefix = true,\n}: {\n  fallbackSubText?: string;\n  getDisplayName: (field: string) => string | null | undefined;\n  matchedField?: string;\n  matchedValue?: string;\n  primaryText?: string | null;\n  showPrefix?: boolean;\n}) => {\n  if (!matchedValue) return fallbackSubText;\n  if (normalizeFilterSearchText(primaryText) === normalizeFilterSearchText(matchedValue)) return fallbackSubText;\n  if (!showPrefix || !matchedField) return matchedValue;\n\n  const matchedFieldLabel = getDisplayName(matchedField);\n  return matchedFieldLabel ? `${matchedFieldLabel}: ${matchedValue}` : matchedValue;\n};\n","import { inject, provide, ref, type InjectionKey } from \"vue\";\n\nimport { filterPanelOptionMatchesRawValue, getFilterPanelOptionRawValue } from \"./filterOptionValue\";\nimport type {\n  PvFilterPanelOption,\n  PvFilterPanelOptionsHandler,\n  PvFilterPanelOptionsResponse,\n  PvFilterStore,\n  PvFilterStoreFetchOptionsParams,\n} from \"./types\";\n\nconst PvFilterStoreKey: InjectionKey<PvFilterStore> = Symbol(\"PvFilterStore\");\n\nconst normalizeOptionsResponse = (\n  response: PvFilterPanelOptionsResponse | (PvFilterPanelOption | null)[] | undefined,\n) => {\n  if (!response) return { values: [] } satisfies PvFilterPanelOptionsResponse;\n  return Array.isArray(response) ? ({ values: response } satisfies PvFilterPanelOptionsResponse) : response;\n};\n\nconst mergeTotalChildCount = (existing?: number, incoming?: number) => incoming ?? existing;\n\nconst cloneOptionMap = <T>(map: Record<string, T[]>) => {\n  return Object.fromEntries(Object.entries(map).map(([field, values]) => [field, [...values]]));\n};\n\nconst mergeOptions = (options: (PvFilterPanelOption | null)[]) => {\n  const optionsByValue = new Map<string, PvFilterPanelOption>();\n\n  for (const option of options) {\n    if (!option) continue;\n    const existing = optionsByValue.get(option.value);\n    if (!existing) {\n      optionsByValue.set(option.value, option);\n      continue;\n    }\n\n    optionsByValue.set(option.value, {\n      ...existing,\n      ...option,\n      children: mergeOptions([...(existing.children ?? []), ...(option.children ?? [])]),\n      totalChildCount: mergeTotalChildCount(existing.totalChildCount, option.totalChildCount),\n    });\n  }\n\n  return [...optionsByValue.values()];\n};\n\nconst findOptionByValue = (\n  options: (PvFilterPanelOption | null)[] | undefined,\n  value: string,\n): PvFilterPanelOption | undefined => {\n  for (const option of options ?? []) {\n    if (!option) continue;\n    if (option.value === value) return option;\n    const childMatch = findOptionByValue(option.children, value);\n    if (childMatch) return childMatch;\n  }\n  return undefined;\n};\n\nconst optionMatchesSelectedValue = (\n  option: PvFilterPanelOption | null | undefined,\n  selectedValue: string | null,\n  fallbackField: string,\n): boolean => {\n  if (!option || selectedValue === null) return false;\n  if (option.value === selectedValue) return true;\n  const rawValue = getFilterPanelOptionRawValue(option);\n  if (rawValue !== null && rawValue === selectedValue) return true;\n  if (filterPanelOptionMatchesRawValue(option, option.colField ?? fallbackField, selectedValue, fallbackField))\n    return true;\n  return option.children?.some((child) => optionMatchesSelectedValue(child, selectedValue, fallbackField)) ?? false;\n};\n\nconst mergeChildOptions = (\n  options: (PvFilterPanelOption | null)[],\n  parentId: string,\n  incomingOptions: (PvFilterPanelOption | null)[],\n): (PvFilterPanelOption | null)[] => {\n  const incomingParent = findOptionByValue(incomingOptions, parentId) ?? null;\n  const incomingChildren = incomingParent?.children ?? incomingOptions.filter(Boolean);\n\n  return options.map((option) => {\n    if (!option) return option;\n\n    if (option.value === parentId) {\n      return {\n        ...option,\n        children: mergeOptions([...(option.children ?? []), ...incomingChildren]),\n        totalChildCount: mergeTotalChildCount(option.totalChildCount, incomingParent?.totalChildCount),\n      };\n    }\n\n    if (!option.children?.length) return option;\n\n    return {\n      ...option,\n      children: mergeChildOptions(option.children, parentId, incomingOptions).filter(\n        (child): child is PvFilterPanelOption => Boolean(child),\n      ),\n    };\n  });\n};\n\nconst getChildPaginationKey = (field: string, parentId: string) => `${field}::${parentId}`;\n\nexport const createPvFilterStore = (): PvFilterStore => {\n  const filterModel = ref<PvFilterStore[\"filterModel\"][\"value\"]>(null);\n  const stagedFilterModel = ref<PvFilterStore[\"stagedFilterModel\"][\"value\"]>(null);\n  const filterModelType = ref<PvFilterStore[\"filterModelType\"][\"value\"]>();\n  const filterOptionsMap = ref<Record<string, (PvFilterPanelOption | null)[]>>({});\n  const filterSelectedValueMap = ref<Record<string, (string | null)[]>>({});\n  const filterSelectedMetadataMap = ref<Record<string, (PvFilterPanelOption | null)[]>>({});\n  const stagedFilterSelectedValueMap = ref<Record<string, (string | null)[]>>({});\n  const stagedFilterSelectedMetadataMap = ref<Record<string, (PvFilterPanelOption | null)[]>>({});\n  const filterSearchQueries = ref<Record<string, string | null | undefined>>({});\n  const filterFacetSelectionMap = ref<Record<string, Record<string, string[]>>>({});\n  const filterLoadingMap = ref<Record<string, boolean | undefined>>({});\n  const filterLoadingMoreMap = ref<Record<string, boolean | undefined>>({});\n  const filterHasMoreMap = ref<Record<string, boolean | undefined>>({});\n  const filterTotalCountMap = ref<Record<string, number | undefined>>({});\n  const filterChildHasMoreMap = ref<Record<string, boolean | undefined>>({});\n  const filterChildTotalCountMap = ref<Record<string, number | undefined>>({});\n  const filterRequestIdMap = ref<Record<string, number | undefined>>({});\n  const filterStaleMap = ref<Record<string, boolean | undefined>>({});\n  const filterOptionsHandler = ref<PvFilterPanelOptionsHandler | undefined>();\n  const loadingRequestCountMap = ref<Record<string, number | undefined>>({});\n\n  const setFilterOptionsHandler = (handler?: PvFilterPanelOptionsHandler) => {\n    filterOptionsHandler.value = handler;\n  };\n\n  const getFilterOptions = (field: string) => filterOptionsMap.value[field] ?? [];\n\n  const setFilterOptions = (field: string, options: (PvFilterPanelOption | null)[]) => {\n    filterOptionsMap.value[field] = options;\n  };\n\n  const getFilterSelectedValues = (field: string, staged = false) => {\n    const selectedValueMap = staged ? stagedFilterSelectedValueMap : filterSelectedValueMap;\n    return selectedValueMap.value[field] ?? [];\n  };\n\n  const setFilterSelectedValues = (field: string, values: (string | null)[], staged = false) => {\n    const selectedValueMap = staged ? stagedFilterSelectedValueMap : filterSelectedValueMap;\n    selectedValueMap.value[field] = values;\n  };\n\n  const initStagedFilterSelections = () => {\n    stagedFilterSelectedValueMap.value = cloneOptionMap(filterSelectedValueMap.value);\n    stagedFilterSelectedMetadataMap.value = cloneOptionMap(filterSelectedMetadataMap.value);\n  };\n\n  const clearStagedFilterSelections = () => {\n    stagedFilterSelectedValueMap.value = {};\n    stagedFilterSelectedMetadataMap.value = {};\n  };\n\n  const commitStagedFilterSelections = () => {\n    filterSelectedValueMap.value = cloneOptionMap(stagedFilterSelectedValueMap.value);\n    filterSelectedMetadataMap.value = cloneOptionMap(stagedFilterSelectedMetadataMap.value);\n    clearStagedFilterSelections();\n  };\n\n  const setFilterSearchQuery = (field: string, query: string | null | undefined) => {\n    filterSearchQueries.value[field] = query;\n  };\n\n  const setFilterFacetSelections = (field: string, facets: Record<string, string[]>) => {\n    filterFacetSelectionMap.value[field] = facets;\n  };\n\n  const getLoadingRequestCountKey = (field: string, isAppend: boolean) =>\n    `${isAppend ? \"append\" : \"initial\"}::${field}`;\n\n  const startLoading = (field: string, isAppend: boolean) => {\n    const loadingMap = isAppend ? filterLoadingMoreMap : filterLoadingMap;\n    const loadingKey = getLoadingRequestCountKey(field, isAppend);\n    loadingRequestCountMap.value[loadingKey] = (loadingRequestCountMap.value[loadingKey] ?? 0) + 1;\n    loadingMap.value[field] = true;\n    return loadingKey;\n  };\n\n  const stopLoading = (field: string, isAppend: boolean, loadingKey: string) => {\n    const loadingMap = isAppend ? filterLoadingMoreMap : filterLoadingMap;\n    const nextCount = Math.max(0, (loadingRequestCountMap.value[loadingKey] ?? 1) - 1);\n    if (nextCount > 0) {\n      loadingRequestCountMap.value[loadingKey] = nextCount;\n      return;\n    }\n\n    delete loadingRequestCountMap.value[loadingKey];\n    loadingMap.value[field] = false;\n  };\n\n  const fetchFilterOptions = async (params: PvFilterStoreFetchOptionsParams) => {\n    const handler = filterOptionsHandler.value;\n    if (!handler) return [];\n\n    const query = params.query ?? filterSearchQueries.value[params.field] ?? undefined;\n    filterSearchQueries.value[params.field] = query;\n\n    const parentOption = params.parentId\n      ? findOptionByValue(filterOptionsMap.value[params.field], params.parentId)\n      : undefined;\n    const offset =\n      params.offset ??\n      (params.parentId\n        ? (parentOption?.children?.length ?? 0)\n        : params.reason === \"load-more\"\n          ? (filterOptionsMap.value[params.field] ?? []).filter(Boolean).length\n          : 0);\n    const isAppend = params.reason === \"load-more\" || params.reason === \"child-load-more\";\n    const loadingKey = startLoading(params.field, isAppend);\n    const requestKey = params.parentId ? getChildPaginationKey(params.field, params.parentId) : params.field;\n    const requestId = (filterRequestIdMap.value[requestKey] ?? 0) + 1;\n    filterRequestIdMap.value[requestKey] = requestId;\n\n    try {\n      const rawResponse = await handler({\n        ...params,\n        facets: params.facets ?? filterFacetSelectionMap.value[params.field],\n        filterModel: params.filterModel ?? stagedFilterModel.value ?? filterModel.value,\n        offset,\n        query,\n        selectedValues: params.selectedValues ?? filterSelectedValueMap.value[params.field] ?? [],\n      });\n\n      if (filterRequestIdMap.value[requestKey] !== requestId) return [];\n\n      const response = normalizeOptionsResponse(rawResponse);\n      if (params.parentId) {\n        const childPaginationKey = getChildPaginationKey(params.field, params.parentId);\n        filterChildHasMoreMap.value[childPaginationKey] = response.hasMore;\n        filterChildTotalCountMap.value[childPaginationKey] = response.totalCount;\n      } else {\n        filterHasMoreMap.value[params.field] = response.hasMore;\n        filterTotalCountMap.value[params.field] = response.totalCount;\n      }\n\n      const selectedMetadata = filterSelectedMetadataMap.value[params.field] ?? [];\n      let nextOptions: (PvFilterPanelOption | null)[];\n\n      if (params.parentId) {\n        nextOptions = mergeChildOptions(filterOptionsMap.value[params.field] ?? [], params.parentId, response.values);\n      } else if (isAppend) {\n        nextOptions = mergeOptions([...(filterOptionsMap.value[params.field] ?? []), ...response.values]);\n      } else {\n        nextOptions = response.values;\n      }\n\n      for (const selectedOption of selectedMetadata) {\n        if (!selectedOption) continue;\n        const selectedValue = getFilterPanelOptionRawValue(selectedOption) ?? selectedOption.value;\n        const alreadyPresent = nextOptions.some((option) =>\n          optionMatchesSelectedValue(option, selectedValue, params.field),\n        );\n        if (!alreadyPresent) nextOptions.push(selectedOption);\n      }\n\n      filterOptionsMap.value[params.field] = nextOptions;\n      filterStaleMap.value[params.field] = false;\n      return nextOptions\n        .filter((option): option is PvFilterPanelOption => Boolean(option))\n        .map((option) => option.value);\n    } finally {\n      stopLoading(params.field, isAppend, loadingKey);\n    }\n  };\n\n  return {\n    clearStagedFilterSelections,\n    commitStagedFilterSelections,\n    fetchFilterOptions,\n    filterChildHasMoreMap,\n    filterChildTotalCountMap,\n    filterFacetSelectionMap,\n    filterHasMoreMap,\n    filterLoadingMap,\n    filterLoadingMoreMap,\n    filterModel,\n    filterModelType,\n    filterOptionsHandler,\n    filterOptionsMap,\n    filterRequestIdMap,\n    filterSearchQueries,\n    filterSelectedMetadataMap,\n    filterSelectedValueMap,\n    filterStaleMap,\n    filterTotalCountMap,\n    getFilterOptions,\n    getFilterSelectedValues,\n    initStagedFilterSelections,\n    setFilterFacetSelections,\n    setFilterOptions,\n    setFilterOptionsHandler,\n    setFilterSearchQuery,\n    setFilterSelectedValues,\n    stagedFilterModel,\n    stagedFilterSelectedMetadataMap,\n    stagedFilterSelectedValueMap,\n  };\n};\n\nexport const providePvFilterStore = (filterStore: PvFilterStore) => {\n  provide(PvFilterStoreKey, filterStore);\n};\n\nexport const useOptionalPvFilterStore = () => {\n  return inject(PvFilterStoreKey, null);\n};\n\nexport const usePvFilterStore = () => {\n  return useOptionalPvFilterStore() ?? createPvFilterStore();\n};\n","import { MenuOption } from \"@/types\";\n\n// The query builder can be used in two modes:\n// 1. Full - the query is parsed and populates both the filter model and free text terms.\n// 2. Field-only - the query is parsed to extract only the filter model, treating free-text terms as invalid\nexport type QueryBuilderProcessor = \"full\" | \"field-only\";\n\nexport interface QueryBuilderOutput {\n  queryTerms: QueryTerm[];\n  freeTextTerms?: string[];\n}\n\nexport interface QueryTerm {\n  queryField?: string;\n  queryDisplayField?: string;\n  exactMatch?: boolean;\n  matchMode?: \"words\";\n  queryText?: string;\n}\n\nexport interface QueryBuilderSuggestionMenuOption extends MenuOption<QueryTerm> {\n  queryTerm?: QueryTerm;\n}\n\n/**\n * The filter model is structured as follows:\n * For single conditions\n * {\n *     [field]: {\n *      filterType: \"text\",\n *      type: \"equals\" | \"contains\",\n *      filter: string,\n *     },\n * }\n * For multiple conditions on the same field, it will be structured as:\n * {\n *    [field]: {\n *     filterType: \"text\",\n *     operator: 'OR',\n *     conditions: [\n *         {\n *         type: \"equals\" | \"contains\",\n *         filter: string,\n *         }\n *     ]\n *    },\n * }\n */\n\nexport const useQueryBuilder = () => {\n  const addQueryOption = (\n    query: QueryBuilderOutput | null,\n    option: QueryBuilderSuggestionMenuOption,\n  ): QueryBuilderOutput | null => {\n    const updatedQuery = query || { queryTerms: [] };\n    const newQueryTerm = option.queryTerm || {};\n    if (isValidQueryTerm(option) && !containsQueryOption(query, option)) {\n      updatedQuery.queryTerms.push(newQueryTerm);\n    }\n    return updatedQuery;\n  };\n  const isValidQueryTerm = (option: QueryBuilderSuggestionMenuOption): boolean => {\n    // don't allow blank query terms\n    if (!option.queryTerm) return false;\n    return option.queryTerm.queryText !== undefined && option.queryTerm.queryText.trim() !== \"\";\n  };\n  const queryTermEquals = (a: QueryTerm, b: QueryTerm): boolean => {\n    return (\n      a.queryField === b.queryField &&\n      a.exactMatch === b.exactMatch &&\n      a.matchMode === b.matchMode &&\n      a.queryText === b.queryText &&\n      a.queryDisplayField === b.queryDisplayField\n    );\n  };\n  const containsQueryOption = (query: QueryBuilderOutput | null, option: QueryBuilderSuggestionMenuOption): boolean => {\n    return !!query && query.queryTerms.some((term) => queryTermEquals(term, option.queryTerm || {}));\n  };\n  const removeQueryOption = (\n    query: QueryBuilderOutput | null,\n    option: QueryBuilderSuggestionMenuOption,\n  ): QueryBuilderOutput | null => {\n    if (!query) return null;\n\n    return {\n      ...query,\n      queryTerms: query.queryTerms.filter((term) => !queryTermEquals(term, option.queryTerm || {})),\n    };\n  };\n  return {\n    addQueryOption,\n    containsQueryOption,\n    removeQueryOption,\n  };\n};\n","<script setup lang=\"ts\">\nimport {\n  QueryBuilderOutput,\n  QueryBuilderSuggestionMenuOption,\n  QueryTerm,\n  useQueryBuilder,\n} from \"@/components/base/PvQueryBuilderInput/useQueryBuilder\";\nimport PvTag from \"@/components/base/PvTag/PvTag.vue\";\nimport { computed } from \"vue\";\nimport { TagVariant } from \"@/components/base/PvTag/types\";\n\ninterface QueryFormatterProps {\n  queryTermDisplayLimit?: number;\n}\n\nconst props = withDefaults(defineProps<QueryFormatterProps>(), {\n  queryTermDisplayLimit: 3,\n});\n\nconst parsedQuery = defineModel<QueryBuilderOutput | null>({ required: true });\nconst wrapContent = defineModel<boolean>(\"wrap-content\", { required: false, default: false });\nconst { removeQueryOption } = useQueryBuilder();\n\nconst displayedQueryTerms = computed(() => {\n  // extract filter terms from parsedQuery\n  // if enableItemWrap is true, show all terms\n  const terms = parsedQuery.value?.queryTerms || [];\n  return wrapContent.value ? terms : terms.slice(0, props.queryTermDisplayLimit);\n});\n\nconst overflowQueryTermCount = computed(() => {\n  const availableQueryTermCount = parsedQuery.value?.queryTerms.length || 0;\n  const currentDisplayCount = displayedQueryTerms.value.length;\n  return availableQueryTermCount - currentDisplayCount;\n});\n\nconst tagLabelForQueryTerm = (term: QueryTerm) => {\n  // Free text has no column to name, so it stands alone. Anything scoped to a column\n  // is prefixed with that column, because the same value can appear under several of\n  // them. Quotes mark a substring match; an exact match is a literal value.\n  if (!term.queryField) return term.queryText || \"\";\n  const displayField = term.queryDisplayField || term.queryField;\n  return term.exactMatch ? `${displayField}: ${term.queryText}` : `${displayField}: '${term.queryText}'`;\n};\n\nconst tagVariantForQueryTerm = (term: QueryTerm): TagVariant => {\n  // return variant based on term type\n  return term.exactMatch ? \"primary\" : \"tertiary\";\n};\n\nconst handleTagClick = (term: QueryTerm) => {\n  const queryOption: QueryBuilderSuggestionMenuOption = {\n    id: \"id\",\n    text: term.queryText || \"\",\n    queryTerm: term,\n  };\n  parsedQuery.value = removeQueryOption(parsedQuery.value, queryOption);\n};\n</script>\n\n<template>\n  <PvTag\n    v-for=\"(queryTerm, index) in displayedQueryTerms\"\n    :key=\"`${index}-${queryTerm.queryText}`\"\n    :variant=\"tagVariantForQueryTerm(queryTerm)\"\n    :label=\"tagLabelForQueryTerm(queryTerm)\"\n    :show-clear=\"true\"\n    @handle-close=\"handleTagClick(queryTerm)\"\n  />\n  <PvTag v-if=\"overflowQueryTermCount > 0\" :label=\"`+${overflowQueryTermCount}`\" @handle-click=\"wrapContent = true\" />\n</template>\n","<script setup lang=\"ts\">\nimport {\n  QueryBuilderOutput,\n  QueryBuilderSuggestionMenuOption,\n  QueryTerm,\n  useQueryBuilder,\n} from \"@/components/base/PvQueryBuilderInput/useQueryBuilder\";\nimport PvTag from \"@/components/base/PvTag/PvTag.vue\";\nimport { computed } from \"vue\";\nimport { TagVariant } from \"@/components/base/PvTag/types\";\n\ninterface QueryFormatterProps {\n  queryTermDisplayLimit?: number;\n}\n\nconst props = withDefaults(defineProps<QueryFormatterProps>(), {\n  queryTermDisplayLimit: 3,\n});\n\nconst parsedQuery = defineModel<QueryBuilderOutput | null>({ required: true });\nconst wrapContent = defineModel<boolean>(\"wrap-content\", { required: false, default: false });\nconst { removeQueryOption } = useQueryBuilder();\n\nconst displayedQueryTerms = computed(() => {\n  // extract filter terms from parsedQuery\n  // if enableItemWrap is true, show all terms\n  const terms = parsedQuery.value?.queryTerms || [];\n  return wrapContent.value ? terms : terms.slice(0, props.queryTermDisplayLimit);\n});\n\nconst overflowQueryTermCount = computed(() => {\n  const availableQueryTermCount = parsedQuery.value?.queryTerms.length || 0;\n  const currentDisplayCount = displayedQueryTerms.value.length;\n  return availableQueryTermCount - currentDisplayCount;\n});\n\nconst tagLabelForQueryTerm = (term: QueryTerm) => {\n  // Free text has no column to name, so it stands alone. Anything scoped to a column\n  // is prefixed with that column, because the same value can appear under several of\n  // them. Quotes mark a substring match; an exact match is a literal value.\n  if (!term.queryField) return term.queryText || \"\";\n  const displayField = term.queryDisplayField || term.queryField;\n  return term.exactMatch ? `${displayField}: ${term.queryText}` : `${displayField}: '${term.queryText}'`;\n};\n\nconst tagVariantForQueryTerm = (term: QueryTerm): TagVariant => {\n  // return variant based on term type\n  return term.exactMatch ? \"primary\" : \"tertiary\";\n};\n\nconst handleTagClick = (term: QueryTerm) => {\n  const queryOption: QueryBuilderSuggestionMenuOption = {\n    id: \"id\",\n    text: term.queryText || \"\",\n    queryTerm: term,\n  };\n  parsedQuery.value = removeQueryOption(parsedQuery.value, queryOption);\n};\n</script>\n\n<template>\n  <PvTag\n    v-for=\"(queryTerm, index) in displayedQueryTerms\"\n    :key=\"`${index}-${queryTerm.queryText}`\"\n    :variant=\"tagVariantForQueryTerm(queryTerm)\"\n    :label=\"tagLabelForQueryTerm(queryTerm)\"\n    :show-clear=\"true\"\n    @handle-close=\"handleTagClick(queryTerm)\"\n  />\n  <PvTag v-if=\"overflowQueryTermCount > 0\" :label=\"`+${overflowQueryTermCount}`\" @handle-click=\"wrapContent = true\" />\n</template>\n","<script setup lang=\"ts\">\nimport { computed, ComputedRef, nextTick, ref, useId, useSlots, useTemplateRef, watch } from \"vue\";\nimport {\n  QueryBuilderOutput,\n  QueryBuilderProcessor,\n  QueryBuilderSuggestionMenuOption,\n  QueryTerm,\n  useQueryBuilder,\n} from \"@/components/base/PvQueryBuilderInput/useQueryBuilder\";\nimport PvPopover from \"@/components/base/PvPopover/PvPopover.vue\";\nimport PvIcon from \"@/components/base/PvIcon/PvIcon.vue\";\nimport PvMenuItem from \"@/components/base/PvMenu/items/PvMenuItem.vue\";\nimport { vOnClickOutside } from \"@vueuse/components\";\nimport QueryFormatter from \"@/components/base/PvQueryBuilderInput/QueryFormatter.vue\";\nimport type { MenuOption, MenuOptionConfig } from \"@/types\";\nimport type { PvSize } from \"@/components/base/baseProps\";\nimport PvButton from \"@/components/base/PvButton/PvButton.vue\";\nimport PvSpinner from \"@/components/base/PvSpinner/PvSpinner.vue\";\nimport { onKeyStroke } from \"@vueuse/core\";\n\nexport interface PvQueryBuilderInputProps {\n  /**\n   * Placeholder text shown in the input when no query is active.\n   */\n  placeholder?: string;\n  /**\n   * When true, the input is non-interactive and visually dimmed.\n   */\n  disabled?: boolean;\n  /** When true, displays a keyboard shortcut badge next to the input. */\n  displayShortcut?: boolean;\n  /**\n   * Determines how user input is parsed into structured query terms.\n   * - `'full'`: free-text and field-based queries.\n   * - `'field-only'`: only options with a queryField are shown.\n   */\n  processor?: QueryBuilderProcessor;\n  /**\n   * When true, shows a loading spinner in the suggestion dropdown.\n   */\n  optionsLoading?: boolean;\n  /** Matches PvSearchInput sizing. */\n  size?: Extract<PvSize, \"lg\" | \"xl\">;\n  /**\n   * When true, users can press Enter to add free-text terms without selecting a suggestion.\n   */\n  enableCustomOptionsInput?: boolean;\n  /**\n   * When true, hides the search icon on the left side of the input.\n   */\n  hideSearchIcon?: boolean;\n  /**\n   * When true, hides the clear button that resets the query.\n   */\n  hideClearButton?: boolean;\n  /**\n   * Maximum number of query term pills to display before collapsing.\n   */\n  queryTermDisplayLimit?: number;\n  /**\n   * When true, query term pills wrap to the next line instead of scrolling horizontally.\n   */\n  enableWrapQueryTerms?: boolean;\n}\n\nconst props = withDefaults(defineProps<PvQueryBuilderInputProps>(), {\n  placeholder: \"Search\",\n  disabled: false,\n  processor: \"full\",\n  optionsLoading: false,\n  enableCustomOptionsInput: false,\n  hideSearchIcon: false,\n  hideClearButton: false,\n  queryTermDisplayLimit: 3,\n  enableWrapQueryTerms: false,\n  size: \"xl\",\n});\n\n// \"icon\" keeps PvMenuBaseItem's opt-in row icon; options without an icon render without one.\nconst menuOptionConfig: MenuOptionConfig = {\n  variant: \"icon\",\n};\n\n// Figma's Surface/card-hover, scoped to this popover so other menus keep the default hover.\nconst popoverCssProperties = {\n  width: \"100%\",\n  maxWidth: \"100%\",\n  \"--popover-list-item-hover-background-color\": \"var(--surface-card-hover, #ece8e2)\",\n};\n\nconst input = useTemplateRef<HTMLInputElement | null>(\"search-input\");\nconst inputText = defineModel<string>(\"searchText\", { required: false, default: \"\" });\nconst parsedQuery = defineModel<QueryBuilderOutput | null>(\"query\", { required: true });\nconst queryOptions = defineModel<QueryBuilderSuggestionMenuOption[]>(\"options\", {\n  required: false,\n});\nconst { addQueryOption, containsQueryOption, removeQueryOption } = useQueryBuilder();\nconst displayOptions = ref(false);\nconst isCurrentInputFocused = ref(false);\nconst wrapContent = ref(false);\n\nconst slots = useSlots();\n// The popover used to exist only when there were options to list. Consumers that supply\n// their own sections still need it, so a header, footer, or empty slot keeps it mounted.\n// With no slots supplied this stays false and the menu behaves exactly as it did before.\nconst hasPopoverSlots = computed(() => Boolean(slots.header || slots.footer || slots.empty));\n\nconst componentId = useId();\nconst optionListId = `${componentId}-options`;\n// Positional ids: a consumer repeating an option id would otherwise produce duplicate DOM\n// ids and break aria-activedescendant.\nconst optionDomId = (index: number) => `${componentId}-option-${index}`;\nconst groupLabelId = (groupIndex: number) => `${componentId}-group-${groupIndex}`;\nconst showPopover = computed(() => availableOptions.value.length > 0 || props.optionsLoading || hasPopoverSlots.value);\n\nconst computedPlaceholder = computed(() => {\n  return parsedQuery.value !== null ? \"\" : props.placeholder;\n});\n\nconst invalidQueryReason = ref<string | null>(null);\nconst displayInvalidQuery = computed(() => {\n  return invalidQueryReason.value !== null && invalidQueryReason.value !== \"\" && !isCurrentInputFocused.value;\n});\n\nconst clearQuery = () => {\n  parsedQuery.value = null;\n  inputText.value = \"\";\n  invalidQueryReason.value = null;\n  wrapContent.value = false;\n};\n\nonKeyStroke(\n  \"Enter\",\n  (event) => {\n    const active = activeOption.value;\n    if (active) {\n      event.preventDefault();\n      handleOptionSelected(active);\n      return;\n    }\n    if (props.enableCustomOptionsInput && inputText.value.trim()) {\n      handleAddSelfAddedOption();\n    }\n  },\n  { target: input },\n);\n\nonKeyStroke(\n  [\"ArrowDown\", \"ArrowUp\"],\n  (event) => {\n    if (flattenedOptions.value.length === 0) return;\n    event.preventDefault();\n    displayOptions.value = true;\n    moveActiveOption(event.key === \"ArrowDown\" ? 1 : -1);\n  },\n  { target: input },\n);\n\n// Escape dismisses the menu but leaves what has been typed alone, so a stray keypress\n// never costs the user their query.\nonKeyStroke(\n  \"Escape\",\n  () => {\n    if (!displayOptions.value) return;\n    displayOptions.value = false;\n    activeOptionIndex.value = -1;\n  },\n  { target: input },\n);\n\n// when the input is empty, backspace removes the most recently added query term\nonKeyStroke(\n  \"Backspace\",\n  () => {\n    if (inputText.value !== \"\") return;\n    const queryTerms = parsedQuery.value?.queryTerms;\n    if (!queryTerms || queryTerms.length === 0) return;\n    const lastTerm = queryTerms[queryTerms.length - 1];\n    parsedQuery.value = removeQueryOption(parsedQuery.value, {\n      id: lastTerm.queryText || \"\",\n      text: lastTerm.queryText || \"\",\n      queryTerm: lastTerm,\n    });\n    if (parsedQuery.value?.queryTerms.length === 0) {\n      parsedQuery.value = null;\n    }\n  },\n  { target: input },\n);\n\nconst handleAddSelfAddedOption = () => {\n  if (inputText.value.trim()) {\n    parsedQuery.value = addQueryOption(parsedQuery.value, {\n      id: inputText.value.trim(),\n      text: inputText.value,\n      queryTerm: {\n        queryText: inputText.value,\n      },\n    });\n    clearInputText();\n  }\n};\n\n// A suggestion's text is the matched value, and the same value turns up under several\n// columns, so a list of them reads as one value repeated. The column is what tells the\n// rows apart: a partial match searches within it, an exact match is a value from it.\n// Free text has no column, and a consumer's own subText wins over this.\nconst columnSubText = (queryTerm?: QueryTerm): string | undefined => {\n  const displayField = queryTerm?.queryDisplayField || queryTerm?.queryField;\n  if (!displayField) return undefined;\n  return queryTerm?.exactMatch ? displayField : `Search in ${displayField}`;\n};\n\nconst availableOptions: ComputedRef<MenuOption<QueryTerm>[]> = computed(() => {\n  if (!queryOptions.value || queryOptions.value.length === 0) {\n    return [];\n  }\n  let filteredOptions = queryOptions.value;\n  // if the processor is field-only, filter out options without a queryField\n  if (props.processor === \"field-only\") {\n    filteredOptions = queryOptions.value.filter((option) => option.queryTerm?.queryField);\n  }\n  // filter out options that are already present in the current query\n  if (parsedQuery.value) {\n    filteredOptions = filteredOptions.filter((option) => !containsQueryOption(parsedQuery.value, option));\n  }\n  // append the input text to the option text for highlighting in the menu item\n  return filteredOptions.map((option) => {\n    const menuOption: MenuOption<QueryTerm> = {\n      ...option,\n      subText: option.subText ?? columnSubText(option.queryTerm),\n      searchText: inputText.value,\n      context: option.queryTerm,\n    };\n    return menuOption;\n  });\n});\n\n// Bucket options by groupingLabel, preserving the order each label first appears in.\n// Options without a label collect under an empty key and render without a section header.\nconst groupedOptions = computed<[string, MenuOption<QueryTerm>[]][]>(() => {\n  const groups = new Map<string, MenuOption<QueryTerm>[]>();\n  for (const option of availableOptions.value) {\n    const label = option.groupingLabel ?? \"\";\n    const group = groups.get(label);\n    if (group) {\n      group.push(option);\n    } else {\n      groups.set(label, [option]);\n    }\n  }\n  return Array.from(groups.entries());\n});\n\n// PvMenu drives its keyboard navigation with roving DOM focus, which assumes the menu\n// itself takes focus. Here focus has to stay in the text input, so this follows the\n// combobox pattern instead: a tracked active index published via aria-activedescendant.\n// Navigating the flattened list is also what skips the group headers for free.\nconst flattenedOptions = computed(() => groupedOptions.value.flatMap(([, options]) => options));\nconst optionPositions = computed(() => new Map(flattenedOptions.value.map((option, index) => [option, index])));\nconst activeOptionIndex = ref(-1);\n// A disabled row never becomes active: PvMenuItem refuses a click on one, so selecting it\n// with the keyboard has to be refused too. Resolving it here covers every caller at once.\nconst activeOption = computed(() => {\n  if (!displayOptions.value) return null;\n  const option = flattenedOptions.value[activeOptionIndex.value] ?? null;\n  return option?.disabled ? null : option;\n});\n\nconst activeOptionDomId = computed(() => (activeOption.value ? optionDomId(activeOptionIndex.value) : undefined));\n\nconst scrollActiveOptionIntoView = (index: number) => {\n  nextTick(() => {\n    // scrollIntoView is called optionally: jsdom does not implement it, and a throw inside\n    // nextTick surfaces as an unhandled rejection in consumer tests rather than a failure.\n    document.getElementById(optionDomId(index))?.scrollIntoView?.({ block: \"nearest\" });\n  });\n};\n\nconst moveActiveOption = (offset: number) => {\n  const options = flattenedOptions.value;\n  const count = options.length;\n  if (count === 0) return;\n  // From \"nothing active\", down lands on the first row and up wraps to the last.\n  const from = activeOptionIndex.value === -1 ? (offset > 0 ? -1 : 0) : activeOptionIndex.value;\n  // Step over disabled rows rather than stopping on one; gives up if every row is disabled.\n  for (let step = 1; step <= count; step++) {\n    const index = (((from + offset * step) % count) + count) % count;\n    if (!options[index].disabled) {\n      activeOptionIndex.value = index;\n      scrollActiveOptionIntoView(index);\n      return;\n    }\n  }\n};\n\n// Hovering takes over the active row so only one row is ever highlighted and Enter always\n// commits the row the user can see is highlighted.\nconst handleOptionHovered = (option: MenuOption<QueryTerm>) => {\n  if (option.disabled) return;\n  activeOptionIndex.value = optionPositions.value.get(option) ?? -1;\n};\n\n// A stale index would point at an unrelated row once the list changes underneath it.\nwatch([flattenedOptions, inputText], () => {\n  activeOptionIndex.value = -1;\n});\n\n// Watch for changes in available options, input text, or loading state to ensure menu is displayed when typing.\nwatch(\n  [availableOptions, inputText, () => props.optionsLoading],\n  ([newOptions, newInputText, isLoading]) => {\n    // If user is typing and there are options to show OR loading, display the menu\n    if (newInputText && newInputText.length > 0 && (newOptions.length > 0 || isLoading || hasPopoverSlots.value)) {\n      displayOptions.value = true;\n    } else if (!newInputText || newInputText.length === 0) {\n      // Clear the menu if no input text\n      displayOptions.value = false;\n    }\n  },\n  { immediate: true },\n);\n\nconst handleClickOutside = () => {\n  if (props.enableCustomOptionsInput) {\n    handleAddSelfAddedOption();\n  }\n\n  // Drop the highlight along with the menu: refocusing the input reopens it, and a stale\n  // active option would let the next Enter commit a row the user never highlighted.\n  activeOptionIndex.value = -1;\n  displayOptions.value = false;\n  isCurrentInputFocused.value = false;\n  wrapContent.value = false;\n};\n\nconst handleOptionSelected = (option: MenuOption<QueryTerm>) => {\n  try {\n    const queryOption: QueryBuilderSuggestionMenuOption = {\n      id: option.id,\n      text: option.text,\n      queryTerm: option.context,\n      icon: option.icon,\n    };\n    parsedQuery.value = addQueryOption(parsedQuery.value, queryOption);\n    //clear input text after adding option\n    clearInputText();\n  } catch (error) {\n    console.error(\"Error adding query option:\", error);\n  } finally {\n    displayOptions.value = false;\n    isCurrentInputFocused.value = false;\n  }\n};\n\nfunction handleWrapperClick(event: MouseEvent) {\n  const target = event.target as HTMLElement;\n\n  // Don't interfere if clicking on a contenteditable element (QueryTerm)\n  if (target.isContentEditable || target.closest('[contenteditable=\"true\"]')) {\n    return;\n  }\n\n  // Don't interfere if clicking on buttons or other interactive elements\n  if (target.tagName === \"BUTTON\" || target.tagName === \"SVG\" || target.closest(\"button\")) {\n    return;\n  }\n\n  // Focus the main input for everything else\n  input.value?.focus();\n}\n\nfunction checkWrapperFocus(event: FocusEvent) {\n  if (event.type === \"focus\") {\n    isCurrentInputFocused.value = true;\n    displayOptions.value = true;\n  }\n  // Blur is intentionally handled by the wrapper's v-on-click-outside directive\n  // (handleClickOutside) rather than the native blur event, so clicks on\n  // suggestion items inside the popover do not prematurely close the menu.\n}\n\nconst clearInputText = () => {\n  inputText.value = \"\";\n};\n</script>\n\n<template>\n  <div\n    ref=\"query-builder-input\"\n    class=\"pv-relative pv-query-builder-input-wrapper\"\n    :class=\"{ 'pv-query-builder-input-small': size === 'lg' }\"\n    @focus=\"checkWrapperFocus\"\n    @click=\"handleWrapperClick\"\n    v-on-click-outside=\"handleClickOutside\"\n  >\n    <PvIcon v-if=\"!hideSearchIcon\" name=\"search\" />\n    <div\n      class=\"pv-flex pv-full-width pv-inset-inline pv-query-builder-input\"\n      style=\"--inset-size: 4px; --flex-gap: 4px\"\n      :style=\"\n        enableWrapQueryTerms || wrapContent ? 'flex-wrap: wrap;' : 'flex-wrap: nowrap; justify-content: flex-end;'\n      \"\n    >\n      <QueryFormatter\n        v-model=\"parsedQuery\"\n        v-model:wrap-content=\"wrapContent\"\n        :query-term-display-limit=\"queryTermDisplayLimit\"\n      ></QueryFormatter>\n      <input\n        v-model=\"inputText\"\n        ref=\"search-input\"\n        data-testid=\"pv-search-input\"\n        type=\"text\"\n        role=\"combobox\"\n        aria-autocomplete=\"list\"\n        :aria-expanded=\"showPopover && displayOptions\"\n        :aria-controls=\"optionListId\"\n        :aria-activedescendant=\"activeOptionDomId\"\n        :disabled=\"disabled\"\n        :placeholder=\"computedPlaceholder\"\n        :data-invalid=\"displayInvalidQuery ? 'true' : undefined\"\n        :style=\"inputText ? 'min-width: 8rem;' : undefined\"\n        @focus=\"checkWrapperFocus\"\n        @blur=\"checkWrapperFocus\"\n      />\n    </div>\n    <PvButton v-if=\"parsedQuery && !hideClearButton\" variant=\"ghost\" leftIcon=\"close\" size=\"md\" @click=\"clearQuery\" />\n    <p v-if=\"displayInvalidQuery\" class=\"pv-text-red pv-text-body-xs\">\n      {{ invalidQueryReason }}\n    </p>\n    <!-- v-show, not a `pv-hide` class: PvPopover's scoped pinned-sections rule sets\n         `display: flex` at class+attribute specificity, which outranks the `.pv-hide`\n         utility. An inline display wins regardless of what the popover styles itself. -->\n    <!-- The thin scrollbar goes on both boxes: the popover root scrolls on its own, and\n         the list takes over as the scroller once a header or footer is pinned. -->\n    <PvPopover\n      v-if=\"showPopover\"\n      v-show=\"displayOptions\"\n      class=\"pv-scrollbar-visible\"\n      :css-custom-properties=\"popoverCssProperties\"\n      :isList=\"true\"\n      listClass=\"pv-scrollbar-visible\"\n      :listId=\"optionListId\"\n      listRole=\"listbox\"\n    >\n      <template v-if=\"$slots.header\" #header><slot name=\"header\"></slot></template>\n      <template v-if=\"$slots.footer\" #footer><slot name=\"footer\"></slot></template>\n      <template v-if=\"!optionsLoading\">\n        <template v-if=\"availableOptions.length > 0\">\n          <template v-for=\"([groupLabel, groupOptions], groupIndex) in groupedOptions\" :key=\"groupLabel\">\n            <li\n              v-if=\"groupLabel\"\n              :id=\"groupLabelId(groupIndex)\"\n              role=\"presentation\"\n              class=\"pv-query-builder-group-label pv-text-body-xs pv-text-subdued\"\n            >\n              {{ groupLabel }}\n            </li>\n            <li\n              v-for=\"option in groupOptions\"\n              :key=\"`${groupLabel}-${option.id}`\"\n              :id=\"optionDomId(optionPositions.get(option) ?? -1)\"\n              role=\"option\"\n              :aria-selected=\"option === activeOption\"\n              :aria-describedby=\"groupLabel ? groupLabelId(groupIndex) : undefined\"\n              :class=\"{ 'pv-query-builder-option-active': option === activeOption }\"\n              @mouseenter=\"handleOptionHovered(option)\"\n            >\n              <PvMenuItem\n                v-bind=\"option\"\n                :config=\"menuOptionConfig\"\n                :queryText=\"inputText\"\n                @handleSelected=\"handleOptionSelected(option)\"\n              />\n            </li>\n          </template>\n        </template>\n        <li v-else-if=\"$slots.empty\" role=\"presentation\">\n          <slot name=\"empty\"></slot>\n        </li>\n      </template>\n      <template v-else>\n        <div class=\"pv-text-center\">\n          <PvSpinner variant=\"dark\" />\n        </div>\n      </template>\n    </PvPopover>\n  </div>\n</template>\n","<script setup lang=\"ts\">\nimport { computed, ComputedRef, nextTick, ref, useId, useSlots, useTemplateRef, watch } from \"vue\";\nimport {\n  QueryBuilderOutput,\n  QueryBuilderProcessor,\n  QueryBuilderSuggestionMenuOption,\n  QueryTerm,\n  useQueryBuilder,\n} from \"@/components/base/PvQueryBuilderInput/useQueryBuilder\";\nimport PvPopover from \"@/components/base/PvPopover/PvPopover.vue\";\nimport PvIcon from \"@/components/base/PvIcon/PvIcon.vue\";\nimport PvMenuItem from \"@/components/base/PvMenu/items/PvMenuItem.vue\";\nimport { vOnClickOutside } from \"@vueuse/components\";\nimport QueryFormatter from \"@/components/base/PvQueryBuilderInput/QueryFormatter.vue\";\nimport type { MenuOption, MenuOptionConfig } from \"@/types\";\nimport type { PvSize } from \"@/components/base/baseProps\";\nimport PvButton from \"@/components/base/PvButton/PvButton.vue\";\nimport PvSpinner from \"@/components/base/PvSpinner/PvSpinner.vue\";\nimport { onKeyStroke } from \"@vueuse/core\";\n\nexport interface PvQueryBuilderInputProps {\n  /**\n   * Placeholder text shown in the input when no query is active.\n   */\n  placeholder?: string;\n  /**\n   * When true, the input is non-interactive and visually dimmed.\n   */\n  disabled?: boolean;\n  /** When true, displays a keyboard shortcut badge next to the input. */\n  displayShortcut?: boolean;\n  /**\n   * Determines how user input is parsed into structured query terms.\n   * - `'full'`: free-text and field-based queries.\n   * - `'field-only'`: only options with a queryField are shown.\n   */\n  processor?: QueryBuilderProcessor;\n  /**\n   * When true, shows a loading spinner in the suggestion dropdown.\n   */\n  optionsLoading?: boolean;\n  /** Matches PvSearchInput sizing. */\n  size?: Extract<PvSize, \"lg\" | \"xl\">;\n  /**\n   * When true, users can press Enter to add free-text terms without selecting a suggestion.\n   */\n  enableCustomOptionsInput?: boolean;\n  /**\n   * When true, hides the search icon on the left side of the input.\n   */\n  hideSearchIcon?: boolean;\n  /**\n   * When true, hides the clear button that resets the query.\n   */\n  hideClearButton?: boolean;\n  /**\n   * Maximum number of query term pills to display before collapsing.\n   */\n  queryTermDisplayLimit?: number;\n  /**\n   * When true, query term pills wrap to the next line instead of scrolling horizontally.\n   */\n  enableWrapQueryTerms?: boolean;\n}\n\nconst props = withDefaults(defineProps<PvQueryBuilderInputProps>(), {\n  placeholder: \"Search\",\n  disabled: false,\n  processor: \"full\",\n  optionsLoading: false,\n  enableCustomOptionsInput: false,\n  hideSearchIcon: false,\n  hideClearButton: false,\n  queryTermDisplayLimit: 3,\n  enableWrapQueryTerms: false,\n  size: \"xl\",\n});\n\n// \"icon\" keeps PvMenuBaseItem's opt-in row icon; options without an icon render without one.\nconst menuOptionConfig: MenuOptionConfig = {\n  variant: \"icon\",\n};\n\n// Figma's Surface/card-hover, scoped to this popover so other menus keep the default hover.\nconst popoverCssProperties = {\n  width: \"100%\",\n  maxWidth: \"100%\",\n  \"--popover-list-item-hover-background-color\": \"var(--surface-card-hover, #ece8e2)\",\n};\n\nconst input = useTemplateRef<HTMLInputElement | null>(\"search-input\");\nconst inputText = defineModel<string>(\"searchText\", { required: false, default: \"\" });\nconst parsedQuery = defineModel<QueryBuilderOutput | null>(\"query\", { required: true });\nconst queryOptions = defineModel<QueryBuilderSuggestionMenuOption[]>(\"options\", {\n  required: false,\n});\nconst { addQueryOption, containsQueryOption, removeQueryOption } = useQueryBuilder();\nconst displayOptions = ref(false);\nconst isCurrentInputFocused = ref(false);\nconst wrapContent = ref(false);\n\nconst slots = useSlots();\n// The popover used to exist only when there were options to list. Consumers that supply\n// their own sections still need it, so a header, footer, or empty slot keeps it mounted.\n// With no slots supplied this stays false and the menu behaves exactly as it did before.\nconst hasPopoverSlots = computed(() => Boolean(slots.header || slots.footer || slots.empty));\n\nconst componentId = useId();\nconst optionListId = `${componentId}-options`;\n// Positional ids: a consumer repeating an option id would otherwise produce duplicate DOM\n// ids and break aria-activedescendant.\nconst optionDomId = (index: number) => `${componentId}-option-${index}`;\nconst groupLabelId = (groupIndex: number) => `${componentId}-group-${groupIndex}`;\nconst showPopover = computed(() => availableOptions.value.length > 0 || props.optionsLoading || hasPopoverSlots.value);\n\nconst computedPlaceholder = computed(() => {\n  return parsedQuery.value !== null ? \"\" : props.placeholder;\n});\n\nconst invalidQueryReason = ref<string | null>(null);\nconst displayInvalidQuery = computed(() => {\n  return invalidQueryReason.value !== null && invalidQueryReason.value !== \"\" && !isCurrentInputFocused.value;\n});\n\nconst clearQuery = () => {\n  parsedQuery.value = null;\n  inputText.value = \"\";\n  invalidQueryReason.value = null;\n  wrapContent.value = false;\n};\n\nonKeyStroke(\n  \"Enter\",\n  (event) => {\n    const active = activeOption.value;\n    if (active) {\n      event.preventDefault();\n      handleOptionSelected(active);\n      return;\n    }\n    if (props.enableCustomOptionsInput && inputText.value.trim()) {\n      handleAddSelfAddedOption();\n    }\n  },\n  { target: input },\n);\n\nonKeyStroke(\n  [\"ArrowDown\", \"ArrowUp\"],\n  (event) => {\n    if (flattenedOptions.value.length === 0) return;\n    event.preventDefault();\n    displayOptions.value = true;\n    moveActiveOption(event.key === \"ArrowDown\" ? 1 : -1);\n  },\n  { target: input },\n);\n\n// Escape dismisses the menu but leaves what has been typed alone, so a stray keypress\n// never costs the user their query.\nonKeyStroke(\n  \"Escape\",\n  () => {\n    if (!displayOptions.value) return;\n    displayOptions.value = false;\n    activeOptionIndex.value = -1;\n  },\n  { target: input },\n);\n\n// when the input is empty, backspace removes the most recently added query term\nonKeyStroke(\n  \"Backspace\",\n  () => {\n    if (inputText.value !== \"\") return;\n    const queryTerms = parsedQuery.value?.queryTerms;\n    if (!queryTerms || queryTerms.length === 0) return;\n    const lastTerm = queryTerms[queryTerms.length - 1];\n    parsedQuery.value = removeQueryOption(parsedQuery.value, {\n      id: lastTerm.queryText || \"\",\n      text: lastTerm.queryText || \"\",\n      queryTerm: lastTerm,\n    });\n    if (parsedQuery.value?.queryTerms.length === 0) {\n      parsedQuery.value = null;\n    }\n  },\n  { target: input },\n);\n\nconst handleAddSelfAddedOption = () => {\n  if (inputText.value.trim()) {\n    parsedQuery.value = addQueryOption(parsedQuery.value, {\n      id: inputText.value.trim(),\n      text: inputText.value,\n      queryTerm: {\n        queryText: inputText.value,\n      },\n    });\n    clearInputText();\n  }\n};\n\n// A suggestion's text is the matched value, and the same value turns up under several\n// columns, so a list of them reads as one value repeated. The column is what tells the\n// rows apart: a partial match searches within it, an exact match is a value from it.\n// Free text has no column, and a consumer's own subText wins over this.\nconst columnSubText = (queryTerm?: QueryTerm): string | undefined => {\n  const displayField = queryTerm?.queryDisplayField || queryTerm?.queryField;\n  if (!displayField) return undefined;\n  return queryTerm?.exactMatch ? displayField : `Search in ${displayField}`;\n};\n\nconst availableOptions: ComputedRef<MenuOption<QueryTerm>[]> = computed(() => {\n  if (!queryOptions.value || queryOptions.value.length === 0) {\n    return [];\n  }\n  let filteredOptions = queryOptions.value;\n  // if the processor is field-only, filter out options without a queryField\n  if (props.processor === \"field-only\") {\n    filteredOptions = queryOptions.value.filter((option) => option.queryTerm?.queryField);\n  }\n  // filter out options that are already present in the current query\n  if (parsedQuery.value) {\n    filteredOptions = filteredOptions.filter((option) => !containsQueryOption(parsedQuery.value, option));\n  }\n  // append the input text to the option text for highlighting in the menu item\n  return filteredOptions.map((option) => {\n    const menuOption: MenuOption<QueryTerm> = {\n      ...option,\n      subText: option.subText ?? columnSubText(option.queryTerm),\n      searchText: inputText.value,\n      context: option.queryTerm,\n    };\n    return menuOption;\n  });\n});\n\n// Bucket options by groupingLabel, preserving the order each label first appears in.\n// Options without a label collect under an empty key and render without a section header.\nconst groupedOptions = computed<[string, MenuOption<QueryTerm>[]][]>(() => {\n  const groups = new Map<string, MenuOption<QueryTerm>[]>();\n  for (const option of availableOptions.value) {\n    const label = option.groupingLabel ?? \"\";\n    const group = groups.get(label);\n    if (group) {\n      group.push(option);\n    } else {\n      groups.set(label, [option]);\n    }\n  }\n  return Array.from(groups.entries());\n});\n\n// PvMenu drives its keyboard navigation with roving DOM focus, which assumes the menu\n// itself takes focus. Here focus has to stay in the text input, so this follows the\n// combobox pattern instead: a tracked active index published via aria-activedescendant.\n// Navigating the flattened list is also what skips the group headers for free.\nconst flattenedOptions = computed(() => groupedOptions.value.flatMap(([, options]) => options));\nconst optionPositions = computed(() => new Map(flattenedOptions.value.map((option, index) => [option, index])));\nconst activeOptionIndex = ref(-1);\n// A disabled row never becomes active: PvMenuItem refuses a click on one, so selecting it\n// with the keyboard has to be refused too. Resolving it here covers every caller at once.\nconst activeOption = computed(() => {\n  if (!displayOptions.value) return null;\n  const option = flattenedOptions.value[activeOptionIndex.value] ?? null;\n  return option?.disabled ? null : option;\n});\n\nconst activeOptionDomId = computed(() => (activeOption.value ? optionDomId(activeOptionIndex.value) : undefined));\n\nconst scrollActiveOptionIntoView = (index: number) => {\n  nextTick(() => {\n    // scrollIntoView is called optionally: jsdom does not implement it, and a throw inside\n    // nextTick surfaces as an unhandled rejection in consumer tests rather than a failure.\n    document.getElementById(optionDomId(index))?.scrollIntoView?.({ block: \"nearest\" });\n  });\n};\n\nconst moveActiveOption = (offset: number) => {\n  const options = flattenedOptions.value;\n  const count = options.length;\n  if (count === 0) return;\n  // From \"nothing active\", down lands on the first row and up wraps to the last.\n  const from = activeOptionIndex.value === -1 ? (offset > 0 ? -1 : 0) : activeOptionIndex.value;\n  // Step over disabled rows rather than stopping on one; gives up if every row is disabled.\n  for (let step = 1; step <= count; step++) {\n    const index = (((from + offset * step) % count) + count) % count;\n    if (!options[index].disabled) {\n      activeOptionIndex.value = index;\n      scrollActiveOptionIntoView(index);\n      return;\n    }\n  }\n};\n\n// Hovering takes over the active row so only one row is ever highlighted and Enter always\n// commits the row the user can see is highlighted.\nconst handleOptionHovered = (option: MenuOption<QueryTerm>) => {\n  if (option.disabled) return;\n  activeOptionIndex.value = optionPositions.value.get(option) ?? -1;\n};\n\n// A stale index would point at an unrelated row once the list changes underneath it.\nwatch([flattenedOptions, inputText], () => {\n  activeOptionIndex.value = -1;\n});\n\n// Watch for changes in available options, input text, or loading state to ensure menu is displayed when typing.\nwatch(\n  [availableOptions, inputText, () => props.optionsLoading],\n  ([newOptions, newInputText, isLoading]) => {\n    // If user is typing and there are options to show OR loading, display the menu\n    if (newInputText && newInputText.length > 0 && (newOptions.length > 0 || isLoading || hasPopoverSlots.value)) {\n      displayOptions.value = true;\n    } else if (!newInputText || newInputText.length === 0) {\n      // Clear the menu if no input text\n      displayOptions.value = false;\n    }\n  },\n  { immediate: true },\n);\n\nconst handleClickOutside = () => {\n  if (props.enableCustomOptionsInput) {\n    handleAddSelfAddedOption();\n  }\n\n  // Drop the highlight along with the menu: refocusing the input reopens it, and a stale\n  // active option would let the next Enter commit a row the user never highlighted.\n  activeOptionIndex.value = -1;\n  displayOptions.value = false;\n  isCurrentInputFocused.value = false;\n  wrapContent.value = false;\n};\n\nconst handleOptionSelected = (option: MenuOption<QueryTerm>) => {\n  try {\n    const queryOption: QueryBuilderSuggestionMenuOption = {\n      id: option.id,\n      text: option.text,\n      queryTerm: option.context,\n      icon: option.icon,\n    };\n    parsedQuery.value = addQueryOption(parsedQuery.value, queryOption);\n    //clear input text after adding option\n    clearInputText();\n  } catch (error) {\n    console.error(\"Error adding query option:\", error);\n  } finally {\n    displayOptions.value = false;\n    isCurrentInputFocused.value = false;\n  }\n};\n\nfunction handleWrapperClick(event: MouseEvent) {\n  const target = event.target as HTMLElement;\n\n  // Don't interfere if clicking on a contenteditable element (QueryTerm)\n  if (target.isContentEditable || target.closest('[contenteditable=\"true\"]')) {\n    return;\n  }\n\n  // Don't interfere if clicking on buttons or other interactive elements\n  if (target.tagName === \"BUTTON\" || target.tagName === \"SVG\" || target.closest(\"button\")) {\n    return;\n  }\n\n  // Focus the main input for everything else\n  input.value?.focus();\n}\n\nfunction checkWrapperFocus(event: FocusEvent) {\n  if (event.type === \"focus\") {\n    isCurrentInputFocused.value = true;\n    displayOptions.value = true;\n  }\n  // Blur is intentionally handled by the wrapper's v-on-click-outside directive\n  // (handleClickOutside) rather than the native blur event, so clicks on\n  // suggestion items inside the popover do not prematurely close the menu.\n}\n\nconst clearInputText = () => {\n  inputText.value = \"\";\n};\n</script>\n\n<template>\n  <div\n    ref=\"query-builder-input\"\n    class=\"pv-relative pv-query-builder-input-wrapper\"\n    :class=\"{ 'pv-query-builder-input-small': size === 'lg' }\"\n    @focus=\"checkWrapperFocus\"\n    @click=\"handleWrapperClick\"\n    v-on-click-outside=\"handleClickOutside\"\n  >\n    <PvIcon v-if=\"!hideSearchIcon\" name=\"search\" />\n    <div\n      class=\"pv-flex pv-full-width pv-inset-inline pv-query-builder-input\"\n      style=\"--inset-size: 4px; --flex-gap: 4px\"\n      :style=\"\n        enableWrapQueryTerms || wrapContent ? 'flex-wrap: wrap;' : 'flex-wrap: nowrap; justify-content: flex-end;'\n      \"\n    >\n      <QueryFormatter\n        v-model=\"parsedQuery\"\n        v-model:wrap-content=\"wrapContent\"\n        :query-term-display-limit=\"queryTermDisplayLimit\"\n      ></QueryFormatter>\n      <input\n        v-model=\"inputText\"\n        ref=\"search-input\"\n        data-testid=\"pv-search-input\"\n        type=\"text\"\n        role=\"combobox\"\n        aria-autocomplete=\"list\"\n        :aria-expanded=\"showPopover && displayOptions\"\n        :aria-controls=\"optionListId\"\n        :aria-activedescendant=\"activeOptionDomId\"\n        :disabled=\"disabled\"\n        :placeholder=\"computedPlaceholder\"\n        :data-invalid=\"displayInvalidQuery ? 'true' : undefined\"\n        :style=\"inputText ? 'min-width: 8rem;' : undefined\"\n        @focus=\"checkWrapperFocus\"\n        @blur=\"checkWrapperFocus\"\n      />\n    </div>\n    <PvButton v-if=\"parsedQuery && !hideClearButton\" variant=\"ghost\" leftIcon=\"close\" size=\"md\" @click=\"clearQuery\" />\n    <p v-if=\"displayInvalidQuery\" class=\"pv-text-red pv-text-body-xs\">\n      {{ invalidQueryReason }}\n    </p>\n    <!-- v-show, not a `pv-hide` class: PvPopover's scoped pinned-sections rule sets\n         `display: flex` at class+attribute specificity, which outranks the `.pv-hide`\n         utility. An inline display wins regardless of what the popover styles itself. -->\n    <!-- The thin scrollbar goes on both boxes: the popover root scrolls on its own, and\n         the list takes over as the scroller once a header or footer is pinned. -->\n    <PvPopover\n      v-if=\"showPopover\"\n      v-show=\"displayOptions\"\n      class=\"pv-scrollbar-visible\"\n      :css-custom-properties=\"popoverCssProperties\"\n      :isList=\"true\"\n      listClass=\"pv-scrollbar-visible\"\n      :listId=\"optionListId\"\n      listRole=\"listbox\"\n    >\n      <template v-if=\"$slots.header\" #header><slot name=\"header\"></slot></template>\n      <template v-if=\"$slots.footer\" #footer><slot name=\"footer\"></slot></template>\n      <template v-if=\"!optionsLoading\">\n        <template v-if=\"availableOptions.length > 0\">\n          <template v-for=\"([groupLabel, groupOptions], groupIndex) in groupedOptions\" :key=\"groupLabel\">\n            <li\n              v-if=\"groupLabel\"\n              :id=\"groupLabelId(groupIndex)\"\n              role=\"presentation\"\n              class=\"pv-query-builder-group-label pv-text-body-xs pv-text-subdued\"\n            >\n              {{ groupLabel }}\n            </li>\n            <li\n              v-for=\"option in groupOptions\"\n              :key=\"`${groupLabel}-${option.id}`\"\n              :id=\"optionDomId(optionPositions.get(option) ?? -1)\"\n              role=\"option\"\n              :aria-selected=\"option === activeOption\"\n              :aria-describedby=\"groupLabel ? groupLabelId(groupIndex) : undefined\"\n              :class=\"{ 'pv-query-builder-option-active': option === activeOption }\"\n              @mouseenter=\"handleOptionHovered(option)\"\n            >\n              <PvMenuItem\n                v-bind=\"option\"\n                :config=\"menuOptionConfig\"\n                :queryText=\"inputText\"\n                @handleSelected=\"handleOptionSelected(option)\"\n              />\n            </li>\n          </template>\n        </template>\n        <li v-else-if=\"$slots.empty\" role=\"presentation\">\n          <slot name=\"empty\"></slot>\n        </li>\n      </template>\n      <template v-else>\n        <div class=\"pv-text-center\">\n          <PvSpinner variant=\"dark\" />\n        </div>\n      </template>\n    </PvPopover>\n  </div>\n</template>\n","import { ref, computed, CSSProperties } from \"vue\";\n\nexport interface PopoverComponent {\n  popoverRef: PopoverRefElement;\n}\n\nexport interface TriggerComponent {\n  triggerRef: HTMLElement | null;\n}\n\nexport interface PopoverRefElement {\n  popoverRoot: HTMLElement | null;\n}\n\nexport const useMenuPosition = ({\n  alignment,\n  useTeleport = true,\n  popoverCssProperties,\n}: {\n  alignment?: \"top\" | \"right\" | \"top right\";\n  useTeleport?: boolean;\n  popoverCssProperties?: CSSProperties;\n} = {}) => {\n  const triggerRect = ref<DOMRect | null>(null);\n  const popoverRect = ref<DOMRect | null>(null);\n  const triggerRef = ref<HTMLElement | null>(null);\n  const popoverRef = ref<PopoverRefElement | null>(null);\n\n  const getPositionedAncestor = (element: HTMLElement): HTMLElement | null => {\n    let parent = element.parentElement;\n    while (parent && parent !== document.body) {\n      const computedStyle = window.getComputedStyle(parent);\n      if (computedStyle.position !== \"static\") {\n        return parent;\n      }\n      parent = parent.parentElement;\n    }\n    return null;\n  };\n\n  const leftOffset = computed(() => {\n    if (!triggerRect.value || !popoverRect.value || !popoverRef.value?.popoverRoot) return 0;\n\n    let left = triggerRect.value.left + window.scrollX;\n    if (alignment === \"right\" || alignment === \"top right\") {\n      left = triggerRect.value.left + triggerRect.value.width + window.scrollX;\n    }\n\n    const positionedAncestor = getPositionedAncestor(popoverRef.value.popoverRoot);\n    if (positionedAncestor) {\n      const ancestorRect = positionedAncestor.getBoundingClientRect();\n      left -= ancestorRect.left + window.scrollX - positionedAncestor.scrollLeft;\n    }\n\n    return left;\n  });\n\n  const topOffset = computed(() => {\n    if (!triggerRect.value || !popoverRect.value || !popoverRef.value?.popoverRoot) return 0;\n\n    let top = triggerRect.value.top + window.scrollY;\n    if (!(alignment === \"top\" || alignment === \"top right\")) {\n      top += triggerRect.value.height;\n    }\n\n    const positionedAncestor = getPositionedAncestor(popoverRef.value.popoverRoot);\n    if (positionedAncestor) {\n      const ancestorRect = positionedAncestor.getBoundingClientRect();\n      top -= ancestorRect.top + window.scrollY - positionedAncestor.scrollTop;\n    }\n\n    return top;\n  });\n\n  const popoverPositionStyle = computed(() => {\n    if (!useTeleport) {\n      return popoverCssProperties;\n    }\n\n    const teleportStyles = {\n      position: \"absolute\",\n      left: `${leftOffset.value}px`,\n      top: `${topOffset.value}px`,\n      zIndex: 10,\n    } as CSSProperties;\n    // combine styles, prioritize teleportStyles\n    const combinedStyles: CSSProperties = {\n      ...popoverCssProperties,\n      ...teleportStyles,\n    };\n    return combinedStyles;\n  });\n\n  const updateRects = () => {\n    if (triggerRef.value) {\n      triggerRect.value = triggerRef.value.getBoundingClientRect();\n    }\n    if (popoverRef.value?.popoverRoot) {\n      popoverRect.value = popoverRef.value.popoverRoot.getBoundingClientRect();\n    }\n  };\n\n  return {\n    triggerRef,\n    popoverRef,\n    triggerRect,\n    popoverRect,\n    popoverPositionStyle,\n    updateRects,\n  };\n};\n","import { computed, toValue, type ComputedRef, type MaybeRefOrGetter } from \"vue\";\nimport { resolveColorTheme, type PvColorTheme } from \"@/functions/colorThemes\";\n\n/**\n * Reactively resolves a color theme id (for example a stored selection) to its label, key colors\n * and full chart palette. Unknown or malformed ids resolve to Turquoise.\n */\nexport function useColorTheme(id: MaybeRefOrGetter<string | null | undefined>): ComputedRef<PvColorTheme> {\n  return computed(() => resolveColorTheme(toValue(id)));\n}\n","import { computed, toValue, type ComputedRef, type MaybeRefOrGetter } from \"vue\";\nimport {\n  createCustomColorTheme,\n  getCustomColorThemeColors,\n  isCustomColorThemeId,\n  type PvColorTheme,\n  type PvCustomColorThemeId,\n} from \"@/functions/colorThemes\";\n\n/** 1-4 key colors (`#RRGGBB`, `#RGB`, with or without `#`), one color, or a custom theme id. */\nexport type PvCustomColorThemeSource = readonly string[] | string | null | undefined;\n\nexport interface UseCustomColorThemeReturn {\n  /** The generated theme, or `undefined` when no color is valid. */\n  theme: ComputedRef<PvColorTheme | undefined>;\n  /** The theme id to store or pass to a `theme`/`colorTheme` prop, e.g. `custom:04D7C6-EC5A62`. */\n  id: ComputedRef<PvCustomColorThemeId | undefined>;\n  /** The full 15-color chart palette, in series order. Empty when no color is valid. */\n  palette: ComputedRef<string[]>;\n  /** Notes on key colors that were adjusted for contrast or to stay distinct. */\n  notes: ComputedRef<string[]>;\n  /** The same notes grouped by key color: `pickNotes[i]` is about `theme.colors[i]`. */\n  pickNotes: ComputedRef<string[][]>;\n}\n\nconst toColors = (source: PvCustomColorThemeSource): string[] => {\n  if (!source) return [];\n  if (typeof source !== \"string\") return [...source];\n  return isCustomColorThemeId(source) ? getCustomColorThemeColors(source) : [source];\n};\n\n/**\n * Reactively builds a 15-color custom theme from 1-4 key colors or a custom theme id.\n * Invalid colors are dropped and colors past the fourth are ignored.\n */\nexport function useCustomColorTheme(source: MaybeRefOrGetter<PvCustomColorThemeSource>): UseCustomColorThemeReturn {\n  const generated = computed(() => createCustomColorTheme(toColors(toValue(source))));\n  const theme = computed(() => generated.value.theme);\n  return {\n    theme,\n    id: computed(() => theme.value?.id as PvCustomColorThemeId | undefined),\n    palette: computed(() => theme.value?.palette ?? []),\n    notes: computed(() => generated.value.notes),\n    pickNotes: computed(() => generated.value.pickNotes),\n  };\n}\n","import { colorDistance } from \"@/functions/colorPalette\";\n\nexport interface ExtractImageColorsOptions {\n  /** How many colors to return at most: 1 or 2. Defaults to 2. */\n  maxColors?: number;\n}\n\n/** An image to read colors from: a file or blob (e.g. an upload), or an image URL. */\nexport type PvImageColorSource = Blob | string;\n\nexport interface ExtractColorsFromImageOptions extends ExtractImageColorsOptions {\n  /** Stops loading the image; the promise then rejects with the signal's reason. */\n  signal?: AbortSignal;\n  /** Largest file or blob accepted, in bytes. Defaults to 10 MB. */\n  maxBytes?: number;\n}\n\n/** Largest file or blob read by default, in bytes. Bounds decode memory for user uploads. */\nexport const MAX_IMAGE_COLOR_BYTES = 10 * 1024 * 1024;\n\n// Pixels lighter than this on every channel count as background (white or near-white).\nconst BACKGROUND_MIN_CHANNEL = 235;\nconst MIN_ALPHA = 128;\n// Below this chroma (max channel minus min channel, 0-1), a pixel counts as gray.\nconst MIN_CHROMA = 0.18;\n// Colors share a cluster when they are closer than this (OKLab distance).\nconst CLUSTER_DISTANCE = 0.08;\n// The second color must differ this much from the first (OKLab distance).\nconst MIN_SECOND_COLOR_DISTANCE = 0.15;\n// The second color must cover at least this share of the counted pixels. Filters anti-aliasing.\nconst MIN_SECOND_COLOR_SHARE = 0.08;\n// Gray pixels only count when the image has almost no color.\nconst MIN_CHROMATIC_SHARE = 0.03;\n/** Longest side, in pixels, an image is scaled down to before its colors are read. */\nconst SAMPLE_SIZE = 96;\n\ninterface Cluster {\n  count: number;\n  r: number;\n  g: number;\n  b: number;\n  hex: string;\n}\n\nconst toHex = (r: number, g: number, b: number) =>\n  \"#\" +\n  [r, g, b]\n    .map((channel) => Math.round(channel).toString(16).padStart(2, \"0\"))\n    .join(\"\")\n    .toUpperCase();\n\nconst addBucket = (buckets: Map<number, Cluster>, r: number, g: number, b: number) => {\n  const key = ((r >> 4) << 8) | ((g >> 4) << 4) | (b >> 4);\n  const bucket = buckets.get(key);\n  if (bucket) {\n    bucket.count += 1;\n    bucket.r += r;\n    bucket.g += g;\n    bucket.b += b;\n  } else {\n    buckets.set(key, { count: 1, r, g, b, hex: \"\" });\n  }\n};\n\n// Merges near-identical buckets, largest first, so one logo color split across buckets counts once.\nconst toClusters = (buckets: Map<number, Cluster>): Cluster[] => {\n  const clusters: Cluster[] = [];\n  const sorted = [...buckets.values()].sort((a, b) => b.count - a.count);\n  for (const bucket of sorted) {\n    const hex = toHex(bucket.r / bucket.count, bucket.g / bucket.count, bucket.b / bucket.count);\n    const match = clusters.find((cluster) => colorDistance(cluster.hex, hex) < CLUSTER_DISTANCE);\n    if (match) {\n      match.count += bucket.count;\n      match.r += bucket.r;\n      match.g += bucket.g;\n      match.b += bucket.b;\n    } else {\n      clusters.push({ ...bucket, hex });\n    }\n  }\n  return clusters\n    .map((cluster) => ({\n      ...cluster,\n      hex: toHex(cluster.r / cluster.count, cluster.g / cluster.count, cluster.b / cluster.count),\n    }))\n    .sort((a, b) => b.count - a.count);\n};\n\n/**\n * Picks the 1-2 dominant brand colors from RGBA pixel data, e.g. a logo's `ImageData.data`.\n * Transparent and near-white (background) pixels are ignored. Gray pixels only count when the\n * image has almost no color, so a black-and-teal logo gives teal. A second color is only returned\n * when it is clearly different from the first and covers a real share of the image.\n * Returns `#RRGGBB` colors, most dominant first, or `[]` when every pixel is background.\n */\nexport function extractImageColors(\n  pixels: ArrayLike<number>,\n  { maxColors = 2 }: ExtractImageColorsOptions = {},\n): string[] {\n  const limit = Math.min(2, Math.max(1, Math.floor(maxColors)));\n  const chromatic = new Map<number, Cluster>();\n  const neutral = new Map<number, Cluster>();\n  let chromaticCount = 0;\n  let neutralCount = 0;\n\n  for (let index = 0; index + 3 < pixels.length; index += 4) {\n    const r = pixels[index];\n    const g = pixels[index + 1];\n    const b = pixels[index + 2];\n    if (pixels[index + 3] < MIN_ALPHA) continue;\n    const min = Math.min(r, g, b);\n    if (min > BACKGROUND_MIN_CHANNEL) continue;\n    if ((Math.max(r, g, b) - min) / 255 >= MIN_CHROMA) {\n      addBucket(chromatic, r, g, b);\n      chromaticCount += 1;\n    } else {\n      addBucket(neutral, r, g, b);\n      neutralCount += 1;\n    }\n  }\n\n  const useChromatic = chromaticCount > 0 && chromaticCount >= (chromaticCount + neutralCount) * MIN_CHROMATIC_SHARE;\n  const total = useChromatic ? chromaticCount : neutralCount;\n  if (!total) return [];\n  const [first, ...rest] = toClusters(useChromatic ? chromatic : neutral);\n  const second = rest.find(\n    (cluster) =>\n      cluster.count >= total * MIN_SECOND_COLOR_SHARE &&\n      colorDistance(cluster.hex, first.hex) >= MIN_SECOND_COLOR_DISTANCE,\n  );\n  return [first, second]\n    .filter((cluster): cluster is Cluster => !!cluster)\n    .slice(0, limit)\n    .map((cluster) => cluster.hex);\n}\n\nconst loadImage = (src: string, signal?: AbortSignal) =>\n  new Promise<HTMLImageElement>((resolve, reject) => {\n    const image = new Image();\n    const onAbort = () => {\n      // Clearing the source stops the download and decode.\n      image.removeAttribute(\"src\");\n      reject(signal?.reason);\n    };\n    image.crossOrigin = \"anonymous\";\n    image.decoding = \"async\";\n    image.onload = () => {\n      signal?.removeEventListener(\"abort\", onAbort);\n      resolve(image);\n    };\n    image.onerror = () => {\n      signal?.removeEventListener(\"abort\", onAbort);\n      reject(new Error(\"The image could not be loaded.\"));\n    };\n    signal?.addEventListener(\"abort\", onAbort, { once: true });\n    image.src = src;\n  });\n\n/**\n * Loads an image (a file, blob or URL) in the browser and picks its 1-2 dominant brand colors.\n * See `extractImageColors`. URLs on other origins must allow CORS, or reading the pixels fails.\n * Files and blobs must be images no larger than `maxBytes`.\n */\nexport async function extractColorsFromImage(\n  source: PvImageColorSource,\n  { signal, maxBytes = MAX_IMAGE_COLOR_BYTES, ...options }: ExtractColorsFromImageOptions = {},\n): Promise<string[]> {\n  signal?.throwIfAborted();\n  if (typeof source !== \"string\") {\n    if (source.type && !source.type.startsWith(\"image/\")) throw new Error(\"The file is not an image.\");\n    if (source.size > maxBytes) throw new Error(\"The image file is too large.\");\n  }\n  const url = typeof source === \"string\" ? source : URL.createObjectURL(source);\n  try {\n    const image = await loadImage(url, signal);\n    signal?.throwIfAborted();\n    // SVGs without a width or height report 0; draw them at the sample size.\n    const width = image.naturalWidth || SAMPLE_SIZE;\n    const height = image.naturalHeight || SAMPLE_SIZE;\n    const scale = Math.min(1, SAMPLE_SIZE / Math.max(width, height));\n    const canvas = document.createElement(\"canvas\");\n    canvas.width = Math.max(1, Math.round(width * scale));\n    canvas.height = Math.max(1, Math.round(height * scale));\n    const context = canvas.getContext(\"2d\", { willReadFrequently: true });\n    if (!context) throw new Error(\"Canvas is not available.\");\n    context.drawImage(image, 0, 0, canvas.width, canvas.height);\n    return extractImageColors(context.getImageData(0, 0, canvas.width, canvas.height).data, options);\n  } finally {\n    if (typeof source !== \"string\") URL.revokeObjectURL(url);\n  }\n}\n","import { ref, toValue, watch, type MaybeRefOrGetter, type Ref } from \"vue\";\nimport { extractColorsFromImage, type PvImageColorSource } from \"@/functions/imageColors\";\n\nexport interface UseImageColorsOptions {\n  /** How many colors to return at most: 1 or 2. Defaults to 2. */\n  maxColors?: MaybeRefOrGetter<number | undefined>;\n}\n\nexport interface UseImageColorsReturn {\n  /** The image's dominant colors as `#RRGGBB`, most dominant first. Empty until loaded. */\n  colors: Readonly<Ref<string[]>>;\n  /** True while the image loads. */\n  loading: Readonly<Ref<boolean>>;\n  /** Set when the image cannot be loaded or read. */\n  error: Readonly<Ref<Error | undefined>>;\n}\n\n/**\n * Reactively picks the 1-2 dominant brand colors from an image, e.g. an uploaded logo.\n * Accepts a `File`/`Blob` (an image up to 10 MB) or an image URL (other origins must allow CORS).\n * Changing the source cancels the previous load, as does unmounting. Pass the colors to\n * `useCustomColorTheme` to build a full palette.\n */\nexport function useImageColors(\n  source: MaybeRefOrGetter<PvImageColorSource | null | undefined>,\n  options: UseImageColorsOptions = {},\n): UseImageColorsReturn {\n  const colors = ref<string[]>([]);\n  const loading = ref(false);\n  const error = ref<Error | undefined>();\n\n  // Each change aborts the previous load, so a stale image stops downloading and never writes.\n  watch(\n    () => [toValue(source), toValue(options.maxColors) ?? 2] as const,\n    async ([image, maxColors], _, onCleanup) => {\n      const controller = new AbortController();\n      onCleanup(() => controller.abort());\n      error.value = undefined;\n      if (!image) {\n        colors.value = [];\n        loading.value = false;\n        return;\n      }\n      loading.value = true;\n      try {\n        const extracted = await extractColorsFromImage(image, { maxColors, signal: controller.signal });\n        if (!controller.signal.aborted) colors.value = extracted;\n      } catch (cause) {\n        if (controller.signal.aborted) return;\n        colors.value = [];\n        error.value = cause instanceof Error ? cause : new Error(String(cause));\n      } finally {\n        if (!controller.signal.aborted) loading.value = false;\n      }\n    },\n    { immediate: true },\n  );\n\n  return { colors, loading, error };\n}\n","/**\n * Thin runtime-optional wrapper around Datadog Browser RUM's `addAction`.\n *\n * The SDK is loaded by the host application (e.g. via a CDN snippet) and is\n * not a dependency of this library. If `window.DD_RUM` is unavailable, calls\n * are no-ops so component code can emit telemetry unconditionally.\n *\n * Hosts configure emission through the `RumContextKey` provide/inject pair\n * (see `useRumContext`) rather than props:\n *\n * - `consumer` tags every event so the same shared component can produce\n *   events differentiated by host app (e.g. \"Analyze\", \"Contracting\"),\n *   filterable in Datadog as `@action.context.consumer:Analyze`.\n * - `enabled: false` suppresses every RUM custom action emitted by\n *   pv-components — for hosts that run the Datadog SDK site-wide (views,\n *   errors, replays) but don't want component-level telemetry. Defaults to\n *   enabled. The `data-dd-action-name` attributes are inert markup and are\n *   not affected; disable Datadog's `trackUserInteractions` to silence those.\n */\n\nimport { inject, type InjectionKey, type Ref } from \"vue\";\n\n/**\n * Host-provided configuration for pv-components' RUM emission. A plain\n * string is shorthand for `{ consumer: <string> }`.\n */\nexport type PvRumContext = {\n  /** Tag merged into every event as the `consumer` property. */\n  consumer?: string;\n  /** Set false to suppress all pv-components RUM custom actions. Default: enabled. */\n  enabled?: boolean;\n};\n\ntype DatadogRumLike = {\n  addAction: (name: string, context?: Record<string, unknown>) => void;\n};\n\ndeclare global {\n  interface Window {\n    DD_RUM?: DatadogRumLike;\n  }\n}\n\n/**\n * Provide this from a host (typically once at the top of a page/view) to\n * configure the Datadog RUM custom actions emitted by pv-components rendered\n * beneath it. Examples:\n *\n *   provide(RumContextKey, ref(\"Analyze\"));                          // tag only\n *   provide(RumContextKey, ref({ consumer: \"Analyze\" }));            // same\n *   provide(RumContextKey, ref({ enabled: false }));                 // opt out\n *\n * The value is a `Ref` and is read at emit time, so hosts can change the\n * consumer or flip `enabled` at runtime.\n */\n// Symbol.for (global registry) rather than Symbol(): the library ships as\n// separate base and visualizations bundles that each include a copy of this\n// module, and host apps import from one of them. A plain Symbol would have a\n// different identity per copy, silently breaking provide/inject across\n// bundle boundaries.\nexport const RumContextKey: InjectionKey<Ref<string | PvRumContext | undefined>> = Symbol.for(\"pv.rum-context\");\n\n/**\n * Resolve the host-provided RUM context at a call site. Returns a resolver\n * function rather than a snapshot: call it at emit time so runtime changes\n * to the provided ref (consumer switch, enabled toggle) take effect.\n * Resolves to an empty context when no host provided one.\n */\nexport const useRumContext = (): (() => PvRumContext) => {\n  const injected = inject(RumContextKey, undefined);\n  return () => {\n    const raw = injected?.value;\n    if (typeof raw === \"string\") return { consumer: raw };\n    return raw ?? {};\n  };\n};\n\nexport const addRumAction = (\n  name: string,\n  properties: Record<string, unknown> = {},\n  context: PvRumContext = {},\n): void => {\n  try {\n    if (context.enabled === false) {\n      return;\n    }\n    if (typeof window === \"undefined\" || !window.DD_RUM?.addAction) {\n      return;\n    }\n\n    const payload: Record<string, unknown> =\n      context.consumer != null ? { ...properties, consumer: context.consumer } : properties;\n\n    window.DD_RUM.addAction(name, payload);\n  } catch {\n    // Telemetry must never break the app — swallow anything the RUM SDK throws.\n  }\n};\n\n/**\n * Run a telemetry block on a microtask, isolated from the calling code path.\n *\n * Call sites snapshot whatever state they need synchronously, then hand the\n * diff/format/emit work to this helper. The surrounding handler (filter\n * flush, chart option update, ...) finishes first, and an exception inside\n * the task stops here instead of unwinding app code — so a bug in event\n * assembly can never affect the interaction being measured.\n */\nexport const deferRumTask = (task: () => void): void => {\n  queueMicrotask(() => {\n    try {\n      task();\n    } catch {\n      // Swallow: RUM telemetry must never affect app behavior.\n    }\n  });\n};\n","import { InjectionKey, Ref, ShallowRef } from \"vue\";\nimport { Column, GridApi, SortModelItem, ColDef } from \"ag-grid-community\";\nimport { MenuOption } from \"@/types\";\nimport type { PvDataTableFilterStore } from \"@tables/PvDataTable/useFilterStore\";\nimport { OptionWithFormatterAndDataType, CrosslineOverlayGroup } from \"@charts/PvDataTableWithChart/types\";\nimport { createFocusStore } from \"@tables/PvDataTable/useFocus\";\n\nexport const FilterStoreKey: InjectionKey<PvDataTableFilterStore> = Symbol(\"FilterStoreKey\");\n\nexport const FocusStoreKey: InjectionKey<ReturnType<typeof createFocusStore>> = Symbol(\"FocusStoreKey\");\n\nexport type SortState = Ref<SortModelItem[]>;\nexport const SortStateKey: InjectionKey<SortState> = Symbol(\"SortStateKey\");\n\nexport type GridApiState = ShallowRef<GridApi | null>;\nexport const GridApiKey: InjectionKey<GridApiState> = Symbol(\"GridApiKey\");\n\nexport type ColumnDisplayOrderState = Ref<Column[] | null>;\nexport const ColumnDisplayOrderKey: InjectionKey<ColumnDisplayOrderState> = Symbol(\"ColumnDisplayOrderKey\");\n\nexport type CurrentlyActiveFilterState = Ref<ColDef | null>;\nexport const CurrentlyActiveFilterKey: InjectionKey<CurrentlyActiveFilterState> = Symbol(\"currentlyActiveFilterKey\");\n\nexport type AvailableFilterColumnsState = Ref<ColDef[]>;\nexport const AvailableFilterColumnsKey: InjectionKey<AvailableFilterColumnsState> = Symbol(\"AvailableFilterColumnsKey\");\n\nexport type AvailableRowGroupColumnsState = Ref<ColDef[]>;\nexport const AvailableRowGroupColumnsKey: InjectionKey<AvailableRowGroupColumnsState> =\n  Symbol(\"AvailableRowGroupColumnsKey\");\n\nexport type RowGroupColumnFieldsState = Ref<string[]>;\nexport const RowGroupColumnFieldsKey: InjectionKey<RowGroupColumnFieldsState> = Symbol(\"RowGroupColumnFieldsKey\");\n\nexport type GroupColumnCellValueColumnState = Ref<Column | null>;\nexport const GroupColumnCellValueColumnKey: InjectionKey<GroupColumnCellValueColumnState> = Symbol(\n  \"GroupColumnCellValueColumnKey\",\n);\n\nexport type ExpandedRowsState = Ref<Record<number, boolean>>;\nexport const ExpandedRowsKey: InjectionKey<ExpandedRowsState> = Symbol(\"ExpandedRowsKey\");\n\nexport type FirstDataRenderedState = Ref<boolean>;\nexport const FirstDataRenderedKey: InjectionKey<FirstDataRenderedState> = Symbol(\"FirstDataRenderedKey\");\n\nexport type RowsLoadingState = Ref<boolean>;\nexport const RowsLoadingKey: InjectionKey<RowsLoadingState> = Symbol(\"RowsLoadingKey\");\n\nexport type CurrentPageState = Ref<number>;\nexport const CurrentPageKey: InjectionKey<CurrentPageState> = Symbol(\"CurrentPageKey\");\n\nexport type TotalPageState = Ref<number>;\nexport const TotalPageKey: InjectionKey<TotalPageState> = Symbol(\"TotalPageKey\");\n\nexport type ActiveChartFilterOptionState = Ref<string>;\nexport const ActiveChartFilterOptionKey: InjectionKey<ActiveChartFilterOptionState> =\n  Symbol(\"ActiveChartFilterOptionKey\");\n\nexport type RowGroupColumnsState = Ref<string[]>;\nexport const RowGroupColumnsKey: InjectionKey<RowGroupColumnsState> = Symbol(\"RowGroupColumnsKey\");\n\nexport type ChartTypesState = Ref<MenuOption[]>;\nexport const ChartTypeKey: InjectionKey<ChartTypesState> = Symbol(\"ChartTypeKey\");\n\nexport type SortTypesState = Ref<MenuOption[]>;\nexport const SortTypesKey: InjectionKey<SortTypesState> = Symbol(\"SortTypesKey\");\n\nexport type ActiveChartState = Ref<MenuOption | undefined>;\nexport const ActiveChartKey: InjectionKey<ActiveChartState> = Symbol(\"ActiveChartKey\");\n\nexport type ActiveSortState = Ref<MenuOption | undefined>;\nexport const ActiveSortKey: InjectionKey<ActiveSortState> = Symbol(\"ActiveSortKey\");\n\nexport type ActiveSeriesKey = Ref<string | undefined>;\nexport const ActiveSeriesKey: InjectionKey<ActiveSeriesKey> = Symbol(\"ActiveSeriesKey\");\n\nexport type AvailableSeriesKey = Ref<OptionWithFormatterAndDataType[]>;\nexport const AvailableSeriesKey: InjectionKey<AvailableSeriesKey> = Symbol(\"AvailableSeriesKey\");\n\nexport type ActiveSecondarySeriesKey = Ref<string | undefined>;\nexport const ActiveSecondarySeriesKey: InjectionKey<ActiveSecondarySeriesKey> = Symbol(\"ActiveSecondarySeriesKey\");\n\nexport type AvailableSecondarySeriesKey = Ref<OptionWithFormatterAndDataType[]>;\nexport const AvailableSecondarySeriesKey: InjectionKey<AvailableSecondarySeriesKey> =\n  Symbol(\"AvailableSecondarySeriesKey\");\n\n// Multi-select metric overlay mode (PvDataTableWithChart `multiSelectMetricOverlay` prop):\n// the active overlay selections live in a list instead of ActiveSecondarySeriesKey.\nexport type ActiveSecondarySeriesListKey = Ref<string[]>;\nexport const ActiveSecondarySeriesListKey: InjectionKey<ActiveSecondarySeriesListKey> =\n  Symbol(\"ActiveSecondarySeriesListKey\");\n\nexport type MetricOverlayMultiSelectKey = Ref<boolean>;\nexport const MetricOverlayMultiSelectKey: InjectionKey<MetricOverlayMultiSelectKey> =\n  Symbol(\"MetricOverlayMultiSelectKey\");\n\nexport type EnableAdvancedFilterState = Ref<boolean>;\nexport const EnableAdvancedFilterKey: InjectionKey<EnableAdvancedFilterState> = Symbol(\"EnableAdvancedFilterKey\");\n\nexport type ActiveCrosslineOverlayGroupsState = Ref<Set<string>>;\nexport const ActiveCrosslineOverlayGroupsKey: InjectionKey<ActiveCrosslineOverlayGroupsState> = Symbol(\n  \"ActiveCrosslineOverlayGroupsKey\",\n);\n\nexport type AvailableCrosslineOverlayGroupsState = Ref<CrosslineOverlayGroup[]>;\nexport const AvailableCrosslineOverlayGroupsKey: InjectionKey<AvailableCrosslineOverlayGroupsState> = Symbol(\n  \"AvailableCrosslineOverlayGroupsKey\",\n);\n","<script setup lang=\"ts\" generic=\"T\">\nimport PvDropdown from \"@/components/base/PvDropdown/PvDropdown.vue\";\nimport PvIcon from \"@/components/base/PvIcon/PvIcon.vue\";\nimport { computed, inject, watch, ref } from \"vue\";\nimport { ColDef } from \"ag-grid-enterprise\";\nimport { PvCounterBadge } from \"@/components/base\";\nimport { Option } from \"@/types\";\nimport { GridApiKey, AvailableRowGroupColumnsKey, RowGroupColumnFieldsKey } from \"@/components/tables/symbols\";\n\nconst gridApi = inject(GridApiKey, ref(null));\nconst availableRowGroupColumns = inject(AvailableRowGroupColumnsKey, ref([]));\nconst rowGroupColumnFields = inject(RowGroupColumnFieldsKey, ref([]));\n\nconst props = defineProps<{\n  rowGroupLimit?: number;\n  enableFocusView?: boolean;\n}>();\n\nwatch(\n  rowGroupColumnFields, // Directly watch the ref\n  () => {},\n  { deep: true }, // Enables deep watching\n);\n\nconst rowGroupActive = (colId: string | undefined) => {\n  return rowGroupColumnFields.value.includes(colId || \"\");\n};\n\nconst handleRowGroupChange = (colField: string, isChecked: boolean) => {\n  if (!gridApi.value) return;\n\n  if (isChecked) {\n    gridApi.value.addRowGroupColumns([colField]);\n  } else {\n    gridApi.value.removeRowGroupColumns([colField]);\n  }\n};\n\nconst dropdownClasses = computed(() => {\n  return {\n    \"pv-hide\": availableRowGroupColumns.value.length === 0,\n  };\n});\n\nconst maxGroupByLimitReached = computed(() => {\n  if (!props.rowGroupLimit) return false;\n  return rowGroupColumnFields.value.length >= props.rowGroupLimit;\n});\n\nconst selectedRowGroupColumns = computed(() => {\n  return rowGroupColumnFields.value\n    .map((field) => availableRowGroupColumns.value.find((col) => col.field === field))\n    .filter((col) => col !== undefined) as ColDef<T>[];\n});\nconst unselectedRowGroupColumns = computed(() => {\n  return availableRowGroupColumns.value.filter((col) => !rowGroupColumnFields.value.includes(col.field as string));\n});\n\nconst rowGroupColumnDisplayOrder = computed(() => {\n  const dividerOption: Option = {\n    label: \"\",\n    value: \"divider\",\n  };\n  const selectedOptions: Option[] = selectedRowGroupColumns.value.map(\n    (col) =>\n      ({\n        label: col.headerName,\n        value: col.field,\n      }) as Option,\n  );\n  const unselectedOptions: Option[] = unselectedRowGroupColumns.value.map(\n    (col) =>\n      ({\n        label: col.headerName,\n        value: col.field,\n      }) as Option,\n  );\n  return [...selectedOptions, dividerOption, ...unselectedOptions];\n});\n\nconst listItemId = (field: string) => {\n  return `group-by-list-item-${field}`;\n};\n\nconst handleGroupByOrderChange = (newOrder: string[]) => {\n  //get the items above the divider and below\n  const dividerIndex = newOrder.findIndex((col) => col === \"divider\");\n  // get the elements above the divider, limited to the rowGroupLimit\n  const elementsAboveDivider = newOrder.slice(0, dividerIndex).slice(0, props.rowGroupLimit);\n  // map to columns and set the group by, clearing the rest\n  const newGroupByColumns = elementsAboveDivider.map((value) => value.replace(\"group-by-list-item-\", \"\"));\n\n  if (!gridApi.value) return;\n\n  gridApi.value.setRowGroupColumns(newGroupByColumns);\n};\n</script>\n\n<template>\n  <PvDropdown\n    :isList=\"true\"\n    :isSortable=\"true\"\n    :popoverCssProperties=\"{ width: 'auto' }\"\n    :alignment=\"'right'\"\n    :class=\"dropdownClasses\"\n    @list-order-updated=\"handleGroupByOrderChange\"\n  >\n    <template #trigger>\n      <div class=\"pv-flex\" style=\"--flex-wrap: nowrap\">\n        <p class=\"pv-truncate pv-text-body-md\">Compare</p>\n        <PvCounterBadge\n          v-if=\"rowGroupColumnFields.length > 0\"\n          :value=\"rowGroupColumnFields.length\"\n          variant=\"tertiary\"\n        />\n      </div>\n    </template>\n    <template v-for=\"(option, index) in rowGroupColumnDisplayOrder\" :key=\"option.value\">\n      <li v-if=\"option.value !== 'divider'\" :id=\"listItemId(option.value as string)\">\n        <label\n          class=\"pv-flex\"\n          :class=\"{\n            'pv-border-bottom': index + 1 === rowGroupColumnFields.length,\n          }\"\n        >\n          <PvIcon v-if=\"rowGroupActive(option.value)\" name=\"reorder\" class=\"pv-text-subdued\"></PvIcon>\n          <span style=\"padding-left: 16px\" v-else></span>\n          <input\n            type=\"checkbox\"\n            class=\"pv-checkbox\"\n            :checked=\"rowGroupActive(option.value)\"\n            :disabled=\"!rowGroupActive(option.value) && maxGroupByLimitReached\"\n            @change=\"(event: Event) => handleRowGroupChange(option.value, (event.target as HTMLInputElement).checked)\"\n          />\n          <span class=\"pv-text-body-md\">{{ option.label }}</span>\n          <sup v-if=\"rowGroupActive(option.value)\">{{ index + 1 }}</sup>\n        </label>\n      </li>\n    </template>\n    <p v-if=\"maxGroupByLimitReached\" class=\"pv-text-subdued pv-text-body-xxs\">\n      Supports {{ rowGroupLimit }} compare levels\n    </p>\n  </PvDropdown>\n</template>\n","<script setup lang=\"ts\" generic=\"T\">\nimport PvDropdown from \"@/components/base/PvDropdown/PvDropdown.vue\";\nimport PvIcon from \"@/components/base/PvIcon/PvIcon.vue\";\nimport { computed, inject, watch, ref } from \"vue\";\nimport { ColDef } from \"ag-grid-enterprise\";\nimport { PvCounterBadge } from \"@/components/base\";\nimport { Option } from \"@/types\";\nimport { GridApiKey, AvailableRowGroupColumnsKey, RowGroupColumnFieldsKey } from \"@/components/tables/symbols\";\n\nconst gridApi = inject(GridApiKey, ref(null));\nconst availableRowGroupColumns = inject(AvailableRowGroupColumnsKey, ref([]));\nconst rowGroupColumnFields = inject(RowGroupColumnFieldsKey, ref([]));\n\nconst props = defineProps<{\n  rowGroupLimit?: number;\n  enableFocusView?: boolean;\n}>();\n\nwatch(\n  rowGroupColumnFields, // Directly watch the ref\n  () => {},\n  { deep: true }, // Enables deep watching\n);\n\nconst rowGroupActive = (colId: string | undefined) => {\n  return rowGroupColumnFields.value.includes(colId || \"\");\n};\n\nconst handleRowGroupChange = (colField: string, isChecked: boolean) => {\n  if (!gridApi.value) return;\n\n  if (isChecked) {\n    gridApi.value.addRowGroupColumns([colField]);\n  } else {\n    gridApi.value.removeRowGroupColumns([colField]);\n  }\n};\n\nconst dropdownClasses = computed(() => {\n  return {\n    \"pv-hide\": availableRowGroupColumns.value.length === 0,\n  };\n});\n\nconst maxGroupByLimitReached = computed(() => {\n  if (!props.rowGroupLimit) return false;\n  return rowGroupColumnFields.value.length >= props.rowGroupLimit;\n});\n\nconst selectedRowGroupColumns = computed(() => {\n  return rowGroupColumnFields.value\n    .map((field) => availableRowGroupColumns.value.find((col) => col.field === field))\n    .filter((col) => col !== undefined) as ColDef<T>[];\n});\nconst unselectedRowGroupColumns = computed(() => {\n  return availableRowGroupColumns.value.filter((col) => !rowGroupColumnFields.value.includes(col.field as string));\n});\n\nconst rowGroupColumnDisplayOrder = computed(() => {\n  const dividerOption: Option = {\n    label: \"\",\n    value: \"divider\",\n  };\n  const selectedOptions: Option[] = selectedRowGroupColumns.value.map(\n    (col) =>\n      ({\n        label: col.headerName,\n        value: col.field,\n      }) as Option,\n  );\n  const unselectedOptions: Option[] = unselectedRowGroupColumns.value.map(\n    (col) =>\n      ({\n        label: col.headerName,\n        value: col.field,\n      }) as Option,\n  );\n  return [...selectedOptions, dividerOption, ...unselectedOptions];\n});\n\nconst listItemId = (field: string) => {\n  return `group-by-list-item-${field}`;\n};\n\nconst handleGroupByOrderChange = (newOrder: string[]) => {\n  //get the items above the divider and below\n  const dividerIndex = newOrder.findIndex((col) => col === \"divider\");\n  // get the elements above the divider, limited to the rowGroupLimit\n  const elementsAboveDivider = newOrder.slice(0, dividerIndex).slice(0, props.rowGroupLimit);\n  // map to columns and set the group by, clearing the rest\n  const newGroupByColumns = elementsAboveDivider.map((value) => value.replace(\"group-by-list-item-\", \"\"));\n\n  if (!gridApi.value) return;\n\n  gridApi.value.setRowGroupColumns(newGroupByColumns);\n};\n</script>\n\n<template>\n  <PvDropdown\n    :isList=\"true\"\n    :isSortable=\"true\"\n    :popoverCssProperties=\"{ width: 'auto' }\"\n    :alignment=\"'right'\"\n    :class=\"dropdownClasses\"\n    @list-order-updated=\"handleGroupByOrderChange\"\n  >\n    <template #trigger>\n      <div class=\"pv-flex\" style=\"--flex-wrap: nowrap\">\n        <p class=\"pv-truncate pv-text-body-md\">Compare</p>\n        <PvCounterBadge\n          v-if=\"rowGroupColumnFields.length > 0\"\n          :value=\"rowGroupColumnFields.length\"\n          variant=\"tertiary\"\n        />\n      </div>\n    </template>\n    <template v-for=\"(option, index) in rowGroupColumnDisplayOrder\" :key=\"option.value\">\n      <li v-if=\"option.value !== 'divider'\" :id=\"listItemId(option.value as string)\">\n        <label\n          class=\"pv-flex\"\n          :class=\"{\n            'pv-border-bottom': index + 1 === rowGroupColumnFields.length,\n          }\"\n        >\n          <PvIcon v-if=\"rowGroupActive(option.value)\" name=\"reorder\" class=\"pv-text-subdued\"></PvIcon>\n          <span style=\"padding-left: 16px\" v-else></span>\n          <input\n            type=\"checkbox\"\n            class=\"pv-checkbox\"\n            :checked=\"rowGroupActive(option.value)\"\n            :disabled=\"!rowGroupActive(option.value) && maxGroupByLimitReached\"\n            @change=\"(event: Event) => handleRowGroupChange(option.value, (event.target as HTMLInputElement).checked)\"\n          />\n          <span class=\"pv-text-body-md\">{{ option.label }}</span>\n          <sup v-if=\"rowGroupActive(option.value)\">{{ index + 1 }}</sup>\n        </label>\n      </li>\n    </template>\n    <p v-if=\"maxGroupByLimitReached\" class=\"pv-text-subdued pv-text-body-xxs\">\n      Supports {{ rowGroupLimit }} compare levels\n    </p>\n  </PvDropdown>\n</template>\n","<template>\n  <div class=\"ag-custom-loading-cell pv-shimmer\"></div>\n</template>\n","<script setup lang=\"ts\">\nimport { computed } from \"vue\";\nimport { ColDef } from \"ag-grid-community\";\nimport { ICellRendererParams } from \"ag-grid-enterprise\";\n\ntype RendererType = \"string\" | \"function\" | \"component\";\n\nconst props = defineProps<{\n  colDef: ColDef | null | undefined;\n  cellParams: ICellRendererParams;\n}>();\n\nconst renderer = computed(() => props.colDef?.cellRenderer ?? null);\n\nconst rendererType = computed((): RendererType | null => {\n  if (!renderer.value) return null;\n  if (typeof renderer.value === \"string\") return \"string\";\n  if (typeof renderer.value === \"function\") return \"function\";\n  return \"component\";\n});\n\nconst displayValue = computed(() => props.cellParams.valueFormatted ?? props.cellParams.value ?? \"\");\n\nconst functionResult = computed(() => {\n  if (rendererType.value !== \"function\") return null;\n  return (renderer.value as (params: ICellRendererParams) => string | HTMLElement)(props.cellParams);\n});\n</script>\n\n<template>\n  <component v-if=\"rendererType === 'component'\" :is=\"renderer\" :params=\"cellParams\" />\n  <span v-else-if=\"rendererType === 'function' && typeof functionResult === 'string'\" v-html=\"functionResult\" />\n  <span v-else-if=\"rendererType === 'string'\">{{ displayValue }}</span>\n  <slot v-else />\n</template>\n","<script setup lang=\"ts\">\nimport { computed } from \"vue\";\nimport { ColDef } from \"ag-grid-community\";\nimport { ICellRendererParams } from \"ag-grid-enterprise\";\n\ntype RendererType = \"string\" | \"function\" | \"component\";\n\nconst props = defineProps<{\n  colDef: ColDef | null | undefined;\n  cellParams: ICellRendererParams;\n}>();\n\nconst renderer = computed(() => props.colDef?.cellRenderer ?? null);\n\nconst rendererType = computed((): RendererType | null => {\n  if (!renderer.value) return null;\n  if (typeof renderer.value === \"string\") return \"string\";\n  if (typeof renderer.value === \"function\") return \"function\";\n  return \"component\";\n});\n\nconst displayValue = computed(() => props.cellParams.valueFormatted ?? props.cellParams.value ?? \"\");\n\nconst functionResult = computed(() => {\n  if (rendererType.value !== \"function\") return null;\n  return (renderer.value as (params: ICellRendererParams) => string | HTMLElement)(props.cellParams);\n});\n</script>\n\n<template>\n  <component v-if=\"rendererType === 'component'\" :is=\"renderer\" :params=\"cellParams\" />\n  <span v-else-if=\"rendererType === 'function' && typeof functionResult === 'string'\" v-html=\"functionResult\" />\n  <span v-else-if=\"rendererType === 'string'\">{{ displayValue }}</span>\n  <slot v-else />\n</template>\n","import { computed, inject, Ref, ref } from \"vue\";\nimport { FocusStoreKey } from \"../symbols\";\n\nexport interface FocusData {\n  focuses?: string[] | undefined;\n  focusType?: string | null | undefined;\n  focusRequired?: boolean;\n}\n\nexport const createFocusStore = (initialFocusData: FocusData | null = null, allFieldsAreFocusable: boolean = false) => {\n  const focuses: Ref<string[]> = ref(initialFocusData?.focuses || []);\n  const focusType: Ref<string | null> = ref(initialFocusData?.focusType || null);\n  const focusRequired = initialFocusData?.focusRequired ?? false;\n  const computedFocuses = computed(() => focuses.value);\n  const computedFocusType = computed(() => focusType.value);\n  const setFocusType = (newFocusType: string | null | undefined) => {\n    if (newFocusType === focusType.value) {\n      return;\n    }\n    focusType.value = newFocusType || null;\n    focuses.value = [];\n  };\n\n  const setFocuses = (newFocuses: string[]) => {\n    focuses.value = newFocuses;\n  };\n\n  const isFocusable = (filterFields: string[]) => {\n    if (allFieldsAreFocusable) {\n      return true;\n    }\n    return focusType.value !== null && filterFields.includes(focusType.value);\n  };\n\n  const isFocused = (option: string | null, filterField: string | null) => {\n    if (!option || !filterField) {\n      return false;\n    }\n    return focuses.value.includes(option) && focusType.value === filterField;\n  };\n\n  const removeFocus = (option: string | null) => {\n    // Don't allow removing focus if focus is required and we only have one focus\n    if (focusRequired && focuses.value.length <= 1) {\n      return;\n    }\n    focuses.value = focuses.value.filter((o) => o !== option);\n  };\n\n  const handleFocusUpdate = (option: string | null, field?: string | null) => {\n    if (!option) {\n      return;\n    }\n\n    // Update focusType when switching fields (only if allFieldsAreFocusable)\n    if (field && field !== focusType.value && allFieldsAreFocusable) {\n      setFocusType(field);\n    }\n\n    // Do nothing if focusType is still null\n    if (!focusType.value) {\n      return;\n    }\n\n    if (!focuses.value.includes(option)) {\n      // swap out focus if it is not already focused\n      // TODO: will need to update this to allow for multiple focuses\n      focuses.value = [option];\n    } else {\n      if (!focusRequired || focuses.value.length > 1) {\n        removeFocus(option);\n      }\n    }\n  };\n\n  const clearAllFocuses = () => {\n    if (!focusRequired) {\n      focuses.value = [];\n      focusType.value = null;\n    }\n  };\n\n  const canRemoveFocus = () => {\n    if (!focusRequired) return true;\n    return focuses.value.length > 1;\n  };\n\n  return {\n    computedFocuses,\n    computedFocusType,\n    clearAllFocuses,\n    handleFocusUpdate,\n    isFocused,\n    removeFocus,\n    isFocusable,\n    setFocusType,\n    setFocuses,\n    canRemoveFocus,\n  };\n};\n\n// Helper function for child components to access the injected focus store\nexport const useFocusStore = () => {\n  const focusStore = inject(FocusStoreKey, null);\n  if (!focusStore) {\n    return createFocusStore();\n  }\n  return focusStore;\n};\n","<script setup lang=\"ts\">\nimport { computed, inject, onMounted, onBeforeUnmount, ref } from \"vue\";\nimport { toRef } from \"@vueuse/core\";\nimport { GridApi, ValueFormatterParams } from \"ag-grid-community\";\nimport { ExpandedChangedEvent, RowNode } from \"ag-grid-enterprise\";\nimport { RowGroupColumnFieldsKey, GroupColumnCellValueColumnKey, ExpandedRowsKey } from \"@/components/tables/symbols\";\nimport { useFocusStore } from \"@tables/PvDataTable/useFocus\";\nimport PvButton from \"@/components/base/PvButton/PvButton.vue\";\nimport PvTooltip from \"@/components/base/PvTooltip/PvTooltip.vue\";\n\ninterface GroupCellRendererParams {\n  displayBaseAggregationsOnly: boolean;\n  displayCount: boolean;\n  displayRowNumber: boolean;\n  formattedValue: string;\n  rowNode: RowNode;\n  api: GridApi;\n  focusText?: string;\n  focusRequired?: boolean;\n}\n\nconst props = defineProps<{ params: GroupCellRendererParams }>();\n\nconst rowGroupColumnFields = inject(RowGroupColumnFieldsKey, ref([]));\nconst groupColumnCellValueColumn = inject(GroupColumnCellValueColumnKey, ref(null));\nconst expandedRows = inject(ExpandedRowsKey, ref<Record<number, boolean>>({}));\n\nconst rowNode = toRef(props.params, \"rowNode\");\n\n// disable aggregations at higher levels in the table\nconst displayAggDataAtLevel = computed(() => {\n  return !props.params.displayBaseAggregationsOnly || rowNode.value.level === rowGroupColumnFields.value.length - 1;\n});\nconst isGroupCell = computed(() => {\n  return props.params.rowNode.group;\n});\n\n// Format bucket group rows using the column's valueFormatter on bucketMin/bucketMax\n// Must check bucket data first — AG Grid's formattedValue applies the column formatter\n// to the raw range string (e.g. \"5000-14500\") which produces \"$NaN\"\nconst formattedGroupValue = computed(() => {\n  const data = rowNode.value.data;\n  if (data?.bucketMin !== undefined && data?.bucketMax !== undefined) {\n    const groupColumn = rowNode.value.rowGroupColumn;\n    const valueFormatter = groupColumn?.getColDef()?.valueFormatter;\n    if (typeof valueFormatter === \"function\") {\n      const minStr = valueFormatter({ value: data.bucketMin } as unknown as ValueFormatterParams);\n      const maxStr = valueFormatter({ value: data.bucketMax } as unknown as ValueFormatterParams);\n      return `${minStr} - ${maxStr}`;\n    }\n    return `${data.bucketMin} - ${data.bucketMax}`;\n  }\n  if (props.params.formattedValue) return props.params.formattedValue;\n  return props.params.rowNode.key;\n});\n\nconst formatCellValue = (\n  //TODO -update types\n  //eslint-disable-next-line @typescript-eslint/no-explicit-any\n  valueFormatter: any,\n  //eslint-disable-next-line @typescript-eslint/no-explicit-any\n  value: any,\n): string => {\n  if (valueFormatter) {\n    return valueFormatter({\n      value,\n      data: rowNode.value.data,\n      node: rowNode.value,\n      api: props.params.api,\n    });\n  }\n  return value;\n};\n\n// this is the first column value (we hide the column itself to stack it under the group column)\nconst groupColumnCellValue = computed(() => {\n  if (!groupColumnCellValueColumn.value) return \"\";\n  const groupField = groupColumnCellValueColumn.value.getColId() || \"\";\n  const valueFormatter = groupColumnCellValueColumn.value.getColDef().valueFormatter;\n  const currentNode = rowNode.value;\n  if (groupField && currentNode && currentNode.data && groupField in currentNode.data) {\n    return formatCellValue(valueFormatter, currentNode.data[groupField]);\n  }\n  return \"\";\n});\n\nconst rowChildCount = computed(() => {\n  if (rowNode.value.data && rowNode.value.data.groupedRecordCount) {\n    return rowNode.value.data.groupedRecordCount || 0;\n  }\n  return rowNode.value.allChildrenCount || 0;\n});\n\nconst cellRowNumber = computed(() => {\n  const cellRowIndex = rowNode.value.rowIndex;\n  const parentRowIndex = rowNode.value.parent?.rowIndex;\n  if (cellRowIndex != null && parentRowIndex != null) {\n    return cellRowIndex - parentRowIndex;\n  }\n  return null;\n});\n\nconst handleExpandedChanged = (event: ExpandedChangedEvent) => {\n  const newExpandedState = event.node.expanded;\n  const index = event.node.rowIndex;\n  if (index != null) {\n    expandedRows.value[index] = newExpandedState;\n  }\n};\n\n// Focus Tracking\n\nconst { isFocused, computedFocuses, removeFocus, canRemoveFocus } = useFocusStore();\n\nconst focusButtonClasses = computed(() => (isFocused(rowNode.value.key, rowNode.value.field) ? \"pv-flex\" : \"\"));\n\nconst isCurrentRowFocused = computed(() => {\n  // Access focuses.value to ensure reactivity tracking\n  const currentFocuses = computedFocuses.value;\n  return rowNode.value.key && currentFocuses.includes(rowNode.value.key);\n});\n\n// Lifecycle\n\nonMounted(() => {\n  const node = rowNode.value;\n  const index = node.rowIndex;\n  const expanded = node.expanded;\n  if (index != null) {\n    expandedRows.value[index] = expanded;\n  }\n  rowNode.value.addEventListener(\"expandedChanged\", handleExpandedChanged);\n});\n\nonBeforeUnmount(() => {\n  const node = rowNode.value;\n  rowNode.value.removeEventListener(\"expandedChanged\", handleExpandedChanged);\n  const index = node.rowIndex;\n  if (index != null) {\n    expandedRows.value[index] = false;\n  }\n});\n</script>\n\n<template>\n  <div v-if=\"isGroupCell\" :class=\"focusButtonClasses\">\n    <div class=\"pv-table-group-cell\">\n      <p class=\"pv-text-body-xxs pv-text-subdued\">\n        {{ rowNode.rowGroupColumn?.getColDef().headerName }}\n        <span v-if=\"params.displayCount && displayAggDataAtLevel && rowChildCount > 0\">\n          ({{ rowChildCount.toLocaleString() }})\n        </span>\n      </p>\n      <div style=\"line-height: 20px\">\n        <p class=\"pv-text-title-md\">\n          {{ formattedGroupValue }}\n        </p>\n      </div>\n    </div>\n    <div v-if=\"isCurrentRowFocused && canRemoveFocus()\" class=\"pv-flex\" style=\"flex: 1; --flex-justify: flex-end\">\n      <PvTooltip variant=\"dark\" tooltipPosition=\"center-left\" size=\"sm\">\n        <template #label>\n          <PvButton\n            :class=\"focusButtonClasses + ' pv-text-brand'\"\n            variant=\"ghost\"\n            left-icon=\"focus\"\n            ariaLabel=\"Remove focus\"\n            @click=\"removeFocus(rowNode.key)\"\n          />\n        </template>\n        <template #tooltip-content>\n          <span> Remove {{ params.focusText || \"Focus\" }} </span>\n        </template>\n      </PvTooltip>\n    </div>\n  </div>\n  <div>\n    <p>\n      <span class=\"pv-table-row-number pv-text-quaternary\" v-if=\"params.displayRowNumber && cellRowNumber\">{{\n        cellRowNumber\n      }}</span>\n      {{ groupColumnCellValue }}\n    </p>\n  </div>\n</template>\n\n<style>\n.pv-table-row-number {\n  padding: 8px 12px 8px 0;\n  text-align: center;\n}\n</style>\n","<script setup lang=\"ts\">\nimport { computed, inject, onMounted, onBeforeUnmount, ref } from \"vue\";\nimport { toRef } from \"@vueuse/core\";\nimport { GridApi, ValueFormatterParams } from \"ag-grid-community\";\nimport { ExpandedChangedEvent, RowNode } from \"ag-grid-enterprise\";\nimport { RowGroupColumnFieldsKey, GroupColumnCellValueColumnKey, ExpandedRowsKey } from \"@/components/tables/symbols\";\nimport { useFocusStore } from \"@tables/PvDataTable/useFocus\";\nimport PvButton from \"@/components/base/PvButton/PvButton.vue\";\nimport PvTooltip from \"@/components/base/PvTooltip/PvTooltip.vue\";\n\ninterface GroupCellRendererParams {\n  displayBaseAggregationsOnly: boolean;\n  displayCount: boolean;\n  displayRowNumber: boolean;\n  formattedValue: string;\n  rowNode: RowNode;\n  api: GridApi;\n  focusText?: string;\n  focusRequired?: boolean;\n}\n\nconst props = defineProps<{ params: GroupCellRendererParams }>();\n\nconst rowGroupColumnFields = inject(RowGroupColumnFieldsKey, ref([]));\nconst groupColumnCellValueColumn = inject(GroupColumnCellValueColumnKey, ref(null));\nconst expandedRows = inject(ExpandedRowsKey, ref<Record<number, boolean>>({}));\n\nconst rowNode = toRef(props.params, \"rowNode\");\n\n// disable aggregations at higher levels in the table\nconst displayAggDataAtLevel = computed(() => {\n  return !props.params.displayBaseAggregationsOnly || rowNode.value.level === rowGroupColumnFields.value.length - 1;\n});\nconst isGroupCell = computed(() => {\n  return props.params.rowNode.group;\n});\n\n// Format bucket group rows using the column's valueFormatter on bucketMin/bucketMax\n// Must check bucket data first — AG Grid's formattedValue applies the column formatter\n// to the raw range string (e.g. \"5000-14500\") which produces \"$NaN\"\nconst formattedGroupValue = computed(() => {\n  const data = rowNode.value.data;\n  if (data?.bucketMin !== undefined && data?.bucketMax !== undefined) {\n    const groupColumn = rowNode.value.rowGroupColumn;\n    const valueFormatter = groupColumn?.getColDef()?.valueFormatter;\n    if (typeof valueFormatter === \"function\") {\n      const minStr = valueFormatter({ value: data.bucketMin } as unknown as ValueFormatterParams);\n      const maxStr = valueFormatter({ value: data.bucketMax } as unknown as ValueFormatterParams);\n      return `${minStr} - ${maxStr}`;\n    }\n    return `${data.bucketMin} - ${data.bucketMax}`;\n  }\n  if (props.params.formattedValue) return props.params.formattedValue;\n  return props.params.rowNode.key;\n});\n\nconst formatCellValue = (\n  //TODO -update types\n  //eslint-disable-next-line @typescript-eslint/no-explicit-any\n  valueFormatter: any,\n  //eslint-disable-next-line @typescript-eslint/no-explicit-any\n  value: any,\n): string => {\n  if (valueFormatter) {\n    return valueFormatter({\n      value,\n      data: rowNode.value.data,\n      node: rowNode.value,\n      api: props.params.api,\n    });\n  }\n  return value;\n};\n\n// this is the first column value (we hide the column itself to stack it under the group column)\nconst groupColumnCellValue = computed(() => {\n  if (!groupColumnCellValueColumn.value) return \"\";\n  const groupField = groupColumnCellValueColumn.value.getColId() || \"\";\n  const valueFormatter = groupColumnCellValueColumn.value.getColDef().valueFormatter;\n  const currentNode = rowNode.value;\n  if (groupField && currentNode && currentNode.data && groupField in currentNode.data) {\n    return formatCellValue(valueFormatter, currentNode.data[groupField]);\n  }\n  return \"\";\n});\n\nconst rowChildCount = computed(() => {\n  if (rowNode.value.data && rowNode.value.data.groupedRecordCount) {\n    return rowNode.value.data.groupedRecordCount || 0;\n  }\n  return rowNode.value.allChildrenCount || 0;\n});\n\nconst cellRowNumber = computed(() => {\n  const cellRowIndex = rowNode.value.rowIndex;\n  const parentRowIndex = rowNode.value.parent?.rowIndex;\n  if (cellRowIndex != null && parentRowIndex != null) {\n    return cellRowIndex - parentRowIndex;\n  }\n  return null;\n});\n\nconst handleExpandedChanged = (event: ExpandedChangedEvent) => {\n  const newExpandedState = event.node.expanded;\n  const index = event.node.rowIndex;\n  if (index != null) {\n    expandedRows.value[index] = newExpandedState;\n  }\n};\n\n// Focus Tracking\n\nconst { isFocused, computedFocuses, removeFocus, canRemoveFocus } = useFocusStore();\n\nconst focusButtonClasses = computed(() => (isFocused(rowNode.value.key, rowNode.value.field) ? \"pv-flex\" : \"\"));\n\nconst isCurrentRowFocused = computed(() => {\n  // Access focuses.value to ensure reactivity tracking\n  const currentFocuses = computedFocuses.value;\n  return rowNode.value.key && currentFocuses.includes(rowNode.value.key);\n});\n\n// Lifecycle\n\nonMounted(() => {\n  const node = rowNode.value;\n  const index = node.rowIndex;\n  const expanded = node.expanded;\n  if (index != null) {\n    expandedRows.value[index] = expanded;\n  }\n  rowNode.value.addEventListener(\"expandedChanged\", handleExpandedChanged);\n});\n\nonBeforeUnmount(() => {\n  const node = rowNode.value;\n  rowNode.value.removeEventListener(\"expandedChanged\", handleExpandedChanged);\n  const index = node.rowIndex;\n  if (index != null) {\n    expandedRows.value[index] = false;\n  }\n});\n</script>\n\n<template>\n  <div v-if=\"isGroupCell\" :class=\"focusButtonClasses\">\n    <div class=\"pv-table-group-cell\">\n      <p class=\"pv-text-body-xxs pv-text-subdued\">\n        {{ rowNode.rowGroupColumn?.getColDef().headerName }}\n        <span v-if=\"params.displayCount && displayAggDataAtLevel && rowChildCount > 0\">\n          ({{ rowChildCount.toLocaleString() }})\n        </span>\n      </p>\n      <div style=\"line-height: 20px\">\n        <p class=\"pv-text-title-md\">\n          {{ formattedGroupValue }}\n        </p>\n      </div>\n    </div>\n    <div v-if=\"isCurrentRowFocused && canRemoveFocus()\" class=\"pv-flex\" style=\"flex: 1; --flex-justify: flex-end\">\n      <PvTooltip variant=\"dark\" tooltipPosition=\"center-left\" size=\"sm\">\n        <template #label>\n          <PvButton\n            :class=\"focusButtonClasses + ' pv-text-brand'\"\n            variant=\"ghost\"\n            left-icon=\"focus\"\n            ariaLabel=\"Remove focus\"\n            @click=\"removeFocus(rowNode.key)\"\n          />\n        </template>\n        <template #tooltip-content>\n          <span> Remove {{ params.focusText || \"Focus\" }} </span>\n        </template>\n      </PvTooltip>\n    </div>\n  </div>\n  <div>\n    <p>\n      <span class=\"pv-table-row-number pv-text-quaternary\" v-if=\"params.displayRowNumber && cellRowNumber\">{{\n        cellRowNumber\n      }}</span>\n      {{ groupColumnCellValue }}\n    </p>\n  </div>\n</template>\n\n<style>\n.pv-table-row-number {\n  padding: 8px 12px 8px 0;\n  text-align: center;\n}\n</style>\n","<script setup lang=\"ts\">\nimport { computed, inject, ref } from \"vue\";\nimport { GridApi, ValueFormatterParams } from \"ag-grid-community\";\nimport { ICellRendererParams, RowNode } from \"ag-grid-enterprise\";\nimport { GroupColumnCellValueColumnKey } from \"@/components/tables/symbols\";\nimport ColDefCellRenderer from \"./ColDefCellRenderer.vue\";\nimport GroupedCellRenderer from \"@tables/PvDataTable/table-components/GroupedCellRenderer.vue\";\n\ninterface AutoGroupColDefRendererParams {\n  /** Pivot tables show row labels as plain text, without the grouped-row chrome. */\n  plainLabel?: boolean;\n  /** Bolds the plain label, e.g. the \"Total\" row of a pivot with no row groups. */\n  boldLabel?: boolean;\n  displayBaseAggregationsOnly: boolean;\n  displayCount: boolean;\n  displayRowNumber: boolean;\n  formattedValue: string;\n  rowNode: RowNode;\n  api: GridApi;\n  focusText?: string;\n  focusRequired?: boolean;\n  cellParams: ICellRendererParams;\n}\n\nconst props = defineProps<{ params: AutoGroupColDefRendererParams }>();\n\nconst groupColumnCellValueColumn = inject(GroupColumnCellValueColumnKey, ref(null));\n\nconst isGroupRow = computed(() => props.params.rowNode.group);\n\nconst childRowNumber = computed(() => {\n  const rowIndex = props.params.rowNode.rowIndex;\n  const parentRowIndex = props.params.rowNode.parent?.rowIndex;\n  if (rowIndex != null && parentRowIndex != null) return rowIndex - parentRowIndex;\n  return null;\n});\n\nconst childRendererParams = computed(() => ({\n  ...props.params,\n  displayRowNumber: false,\n}));\n\n// Resolve the colDef for the row group column (for group rows)\nconst groupColDef = computed(() => {\n  if (!isGroupRow.value) return null;\n  return props.params.cellParams.node?.rowGroupColumn?.getColDef() ?? null;\n});\n\n// Resolve the colDef from the leftmost (hidden) column (for child rows)\nconst childColDef = computed(() => {\n  if (isGroupRow.value) return null;\n  return groupColumnCellValueColumn.value?.getColDef() ?? null;\n});\n\n// Build params that reflect the leftmost column instead of the auto-group column\nconst childCellParams = computed(() => {\n  const col = groupColumnCellValueColumn.value;\n  if (!col) return props.params.cellParams;\n  const colDef = col.getColDef();\n  const field = col.getColId();\n  const data = props.params.cellParams.data;\n  const rawValue = data?.[field] ?? null;\n  const valueFormatter = colDef.valueFormatter;\n  let formatted: string | null = null;\n  if (typeof valueFormatter === \"function\") {\n    formatted = valueFormatter({\n      value: rawValue,\n      data,\n      node: props.params.cellParams.node,\n      api: props.params.cellParams.api,\n      column: col,\n      colDef,\n    } as unknown as ValueFormatterParams);\n  }\n  return {\n    ...props.params.cellParams,\n    column: col,\n    colDef,\n    value: rawValue,\n    valueFormatted: formatted,\n  };\n});\n</script>\n\n<template>\n  <!-- Pivot rows -->\n  <span v-if=\"params.plainLabel\" :class=\"['pv-text-body-md', { 'pv-text-bold': params.boldLabel }]\">{{\n    params.formattedValue ?? params.rowNode.key\n  }}</span>\n  <!-- Group rows -->\n  <ColDefCellRenderer v-else-if=\"isGroupRow\" :col-def=\"groupColDef\" :cell-params=\"params.cellParams\">\n    <GroupedCellRenderer :params=\"params\" />\n  </ColDefCellRenderer>\n  <!-- Child rows -->\n  <div v-else class=\"pv-table-child-cell\" style=\"display: flex; align-items: center; width: 100%; height: 100%\">\n    <span\n      class=\"pv-table-row-number\"\n      style=\"padding: 8px 12px 8px 0; text-align: center; color: var(--color-text-quaternary, #89989b)\"\n      v-if=\"params.displayRowNumber && childRowNumber\"\n      >{{ childRowNumber }}</span\n    >\n    <ColDefCellRenderer :col-def=\"childColDef\" :cell-params=\"childCellParams\">\n      <GroupedCellRenderer :params=\"childRendererParams\" />\n    </ColDefCellRenderer>\n  </div>\n</template>\n","<script setup lang=\"ts\">\nimport { computed, inject, ref } from \"vue\";\nimport { GridApi, ValueFormatterParams } from \"ag-grid-community\";\nimport { ICellRendererParams, RowNode } from \"ag-grid-enterprise\";\nimport { GroupColumnCellValueColumnKey } from \"@/components/tables/symbols\";\nimport ColDefCellRenderer from \"./ColDefCellRenderer.vue\";\nimport GroupedCellRenderer from \"@tables/PvDataTable/table-components/GroupedCellRenderer.vue\";\n\ninterface AutoGroupColDefRendererParams {\n  /** Pivot tables show row labels as plain text, without the grouped-row chrome. */\n  plainLabel?: boolean;\n  /** Bolds the plain label, e.g. the \"Total\" row of a pivot with no row groups. */\n  boldLabel?: boolean;\n  displayBaseAggregationsOnly: boolean;\n  displayCount: boolean;\n  displayRowNumber: boolean;\n  formattedValue: string;\n  rowNode: RowNode;\n  api: GridApi;\n  focusText?: string;\n  focusRequired?: boolean;\n  cellParams: ICellRendererParams;\n}\n\nconst props = defineProps<{ params: AutoGroupColDefRendererParams }>();\n\nconst groupColumnCellValueColumn = inject(GroupColumnCellValueColumnKey, ref(null));\n\nconst isGroupRow = computed(() => props.params.rowNode.group);\n\nconst childRowNumber = computed(() => {\n  const rowIndex = props.params.rowNode.rowIndex;\n  const parentRowIndex = props.params.rowNode.parent?.rowIndex;\n  if (rowIndex != null && parentRowIndex != null) return rowIndex - parentRowIndex;\n  return null;\n});\n\nconst childRendererParams = computed(() => ({\n  ...props.params,\n  displayRowNumber: false,\n}));\n\n// Resolve the colDef for the row group column (for group rows)\nconst groupColDef = computed(() => {\n  if (!isGroupRow.value) return null;\n  return props.params.cellParams.node?.rowGroupColumn?.getColDef() ?? null;\n});\n\n// Resolve the colDef from the leftmost (hidden) column (for child rows)\nconst childColDef = computed(() => {\n  if (isGroupRow.value) return null;\n  return groupColumnCellValueColumn.value?.getColDef() ?? null;\n});\n\n// Build params that reflect the leftmost column instead of the auto-group column\nconst childCellParams = computed(() => {\n  const col = groupColumnCellValueColumn.value;\n  if (!col) return props.params.cellParams;\n  const colDef = col.getColDef();\n  const field = col.getColId();\n  const data = props.params.cellParams.data;\n  const rawValue = data?.[field] ?? null;\n  const valueFormatter = colDef.valueFormatter;\n  let formatted: string | null = null;\n  if (typeof valueFormatter === \"function\") {\n    formatted = valueFormatter({\n      value: rawValue,\n      data,\n      node: props.params.cellParams.node,\n      api: props.params.cellParams.api,\n      column: col,\n      colDef,\n    } as unknown as ValueFormatterParams);\n  }\n  return {\n    ...props.params.cellParams,\n    column: col,\n    colDef,\n    value: rawValue,\n    valueFormatted: formatted,\n  };\n});\n</script>\n\n<template>\n  <!-- Pivot rows -->\n  <span v-if=\"params.plainLabel\" :class=\"['pv-text-body-md', { 'pv-text-bold': params.boldLabel }]\">{{\n    params.formattedValue ?? params.rowNode.key\n  }}</span>\n  <!-- Group rows -->\n  <ColDefCellRenderer v-else-if=\"isGroupRow\" :col-def=\"groupColDef\" :cell-params=\"params.cellParams\">\n    <GroupedCellRenderer :params=\"params\" />\n  </ColDefCellRenderer>\n  <!-- Child rows -->\n  <div v-else class=\"pv-table-child-cell\" style=\"display: flex; align-items: center; width: 100%; height: 100%\">\n    <span\n      class=\"pv-table-row-number\"\n      style=\"padding: 8px 12px 8px 0; text-align: center; color: var(--color-text-quaternary, #89989b)\"\n      v-if=\"params.displayRowNumber && childRowNumber\"\n      >{{ childRowNumber }}</span\n    >\n    <ColDefCellRenderer :col-def=\"childColDef\" :cell-params=\"childCellParams\">\n      <GroupedCellRenderer :params=\"childRendererParams\" />\n    </ColDefCellRenderer>\n  </div>\n</template>\n","export function calculateHighMedian(values: number[]) {\n  const sortedValues = values.filter((v) => v != null && !isNaN(v)).sort((a, b) => a - b);\n  const len = sortedValues.length;\n  if (len === 0) return null;\n\n  // Return the upper middle (high median)\n  return sortedValues[Math.floor(len / 2)];\n}\n","<script setup lang=\"ts\" generic=\"T\">\nimport { ICellRendererParams } from \"ag-grid-enterprise\";\nimport { ColDef } from \"ag-grid-community\";\nimport { computed, inject, onMounted, ref } from \"vue\";\nimport { ExpandedRowsKey } from \"@/components/tables/symbols\";\nimport { colDefContext, isColDefNumericDataType } from \"@tables/PvDataTable/helpers\";\n\nconst props = defineProps<{ params: ICellRendererParams }>();\n\nconst expandedRows = inject(ExpandedRowsKey, ref<Record<number, boolean>>({}));\n\nconst aggFuncDisplayName = computed(() => {\n  const colDef = props.params.column?.getColDef();\n  const context = colDefContext(colDef);\n  if (context.aggFuncDisplayName) {\n    return context.aggFuncDisplayName;\n  }\n  const aggFunc = (props.params.column?.getAggFunc() as string) || \"agg\";\n  if (context.aggFuncDisplayNameMap?.[aggFunc]) {\n    return context.aggFuncDisplayNameMap[aggFunc];\n  }\n  return aggFunc.toLowerCase();\n});\n\nconst handleAggCellClick = () => {\n  const api = props.params.api;\n  if (api) {\n    const newState = !expandState.value;\n    api.setRowNodeExpanded(props.params.node, newState);\n    if (rowIndex.value) {\n      expandedRows.value[rowIndex.value] = newState;\n    }\n  }\n};\n\nconst rowIndex = computed(() => {\n  return props.params.node?.rowIndex;\n});\n\nconst expandState = computed(() => {\n  let result = false;\n  if (rowIndex.value != null) {\n    result = rowIndex.value in expandedRows.value ? expandedRows.value[rowIndex.value] : false;\n  }\n  return result;\n});\n\nconst isNumericColumn = computed(() => {\n  return isColDefNumericDataType(props.params.column?.getColDef() as ColDef<T>);\n});\n\nconst formattedValue = computed(() => {\n  const colDef = props.params.column?.getColDef();\n  const value = props.params.valueFormatted || props.params.value || \"\";\n  if (colDef && isColDefNumericDataType(colDef)) {\n    return value.toLocaleString();\n  }\n  return value;\n});\n\nconst headerCellStyle = computed(() => {\n  return {\n    \"flex-direction\": isNumericColumn.value ? \"row-reverse\" : \"row\",\n    \"--flex-justify\": \"space-between\",\n  } as Record<string, string>;\n});\n\nonMounted(() => {\n  if (props.params.node.expanded && rowIndex.value) {\n    expandedRows.value[rowIndex.value] = true;\n  }\n});\n</script>\n\n<template>\n  <div :style=\"headerCellStyle\" class=\"pv-flex\" :ondblclick=\"handleAggCellClick\">\n    <div style=\"line-height: 20px\">\n      <p>{{ formattedValue }}</p>\n      <p class=\"pv-text-subdued pv-text-body-xxs pv-relative\">\n        {{ aggFuncDisplayName }}\n      </p>\n    </div>\n  </div>\n</template>\n","<script setup lang=\"ts\" generic=\"T\">\nimport { ICellRendererParams } from \"ag-grid-enterprise\";\nimport { ColDef } from \"ag-grid-community\";\nimport { computed, inject, onMounted, ref } from \"vue\";\nimport { ExpandedRowsKey } from \"@/components/tables/symbols\";\nimport { colDefContext, isColDefNumericDataType } from \"@tables/PvDataTable/helpers\";\n\nconst props = defineProps<{ params: ICellRendererParams }>();\n\nconst expandedRows = inject(ExpandedRowsKey, ref<Record<number, boolean>>({}));\n\nconst aggFuncDisplayName = computed(() => {\n  const colDef = props.params.column?.getColDef();\n  const context = colDefContext(colDef);\n  if (context.aggFuncDisplayName) {\n    return context.aggFuncDisplayName;\n  }\n  const aggFunc = (props.params.column?.getAggFunc() as string) || \"agg\";\n  if (context.aggFuncDisplayNameMap?.[aggFunc]) {\n    return context.aggFuncDisplayNameMap[aggFunc];\n  }\n  return aggFunc.toLowerCase();\n});\n\nconst handleAggCellClick = () => {\n  const api = props.params.api;\n  if (api) {\n    const newState = !expandState.value;\n    api.setRowNodeExpanded(props.params.node, newState);\n    if (rowIndex.value) {\n      expandedRows.value[rowIndex.value] = newState;\n    }\n  }\n};\n\nconst rowIndex = computed(() => {\n  return props.params.node?.rowIndex;\n});\n\nconst expandState = computed(() => {\n  let result = false;\n  if (rowIndex.value != null) {\n    result = rowIndex.value in expandedRows.value ? expandedRows.value[rowIndex.value] : false;\n  }\n  return result;\n});\n\nconst isNumericColumn = computed(() => {\n  return isColDefNumericDataType(props.params.column?.getColDef() as ColDef<T>);\n});\n\nconst formattedValue = computed(() => {\n  const colDef = props.params.column?.getColDef();\n  const value = props.params.valueFormatted || props.params.value || \"\";\n  if (colDef && isColDefNumericDataType(colDef)) {\n    return value.toLocaleString();\n  }\n  return value;\n});\n\nconst headerCellStyle = computed(() => {\n  return {\n    \"flex-direction\": isNumericColumn.value ? \"row-reverse\" : \"row\",\n    \"--flex-justify\": \"space-between\",\n  } as Record<string, string>;\n});\n\nonMounted(() => {\n  if (props.params.node.expanded && rowIndex.value) {\n    expandedRows.value[rowIndex.value] = true;\n  }\n});\n</script>\n\n<template>\n  <div :style=\"headerCellStyle\" class=\"pv-flex\" :ondblclick=\"handleAggCellClick\">\n    <div style=\"line-height: 20px\">\n      <p>{{ formattedValue }}</p>\n      <p class=\"pv-text-subdued pv-text-body-xxs pv-relative\">\n        {{ aggFuncDisplayName }}\n      </p>\n    </div>\n  </div>\n</template>\n","import {\n  AdvancedFilterModel,\n  ColumnAdvancedFilterModel,\n  FilterModel,\n  GridState,\n  IMultiFilterDef,\n  IMultiFilterParams,\n  JoinAdvancedFilterModel,\n  MultiFilter,\n  SetFilter,\n  SetFilterModel,\n  SetFilterParams,\n  SetFilterValuesFuncParams,\n  TextFilterModel,\n} from \"ag-grid-enterprise\";\nimport { QueryBuilderOutput } from \"@/components/base/PvQueryBuilderInput/useQueryBuilder\";\nimport { ColDef, GridApi, IMultiFilterModel } from \"ag-grid-community\";\nimport { FilterValueResponseOption } from \"@tables/PvDataTable/types\";\nimport { isEqual } from \"es-toolkit\";\n\nexport type AnyFilterModel = FilterModel | AdvancedFilterModel | null | undefined;\n\nconst filterNameTypeMap: Record<string, string> = {\n  agSetColumnFilter: \"set\",\n  agMultiColumnFilter: \"multi\",\n  agTextColumnFilter: \"text\",\n};\n\nconst getFilterTypeFromColDef = (colDef: ColDef | undefined): string | null => {\n  if (!colDef || !colDef.filter) return null;\n  return colDef.filter in filterNameTypeMap ? filterNameTypeMap[colDef.filter] : null;\n};\n\nconst getColDefSetFilterIndex = (colDef: ColDef) => {\n  return colDef.filterParams?.filters?.findIndex((item: IMultiFilterDef) => item.filter === \"agSetColumnFilter\");\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const mapFilterBasedOnColDef = (filter: any, colDef: ColDef | undefined | null) => {\n  if (!colDef || !colDef.field) return filter;\n  if (!filter || Object.keys(filter).length === 0) return filter;\n  const filterType = filter?.filterType || null;\n  const colDefFilterType = getFilterTypeFromColDef(colDef);\n  if (!colDefFilterType) return filter;\n\n  // if the filter types match, we're good\n  if (colDefFilterType === filterType) {\n    return filter;\n  }\n  // we can only \"upgrade\" a filter if going from a lower level to multi\n  if (colDefFilterType !== \"multi\") {\n    console.warn(`Cannot map filter for column ${colDef.field} with type ${filterType} to col def ${colDefFilterType}`);\n    return {};\n  }\n\n  const multiFilterLength = colDef.filterParams?.filters?.length;\n  const filterModels = Array(multiFilterLength).fill(null);\n  // now we take the existing filter and map it into a multi filter\n  if (filter.filterType == \"set\") {\n    const values = filter.values || [];\n    const setFilterIndex = getColDefSetFilterIndex(colDef);\n    if (setFilterIndex > -1 && setFilterIndex < filterModels.length) {\n      filterModels[setFilterIndex] = {\n        filterType: \"set\",\n        values,\n      } as SetFilterModel;\n    }\n  } else {\n    console.warn(`Cannot map filter for column ${colDef.field} with type ${filterType} to col def ${colDefFilterType}`);\n  }\n  return {\n    filterType: \"multi\",\n    filterModels,\n  };\n};\n\n/**\n * Constructs an advanced filter model condition for a single column with text equals filter.\n * Used when advanced filter is enabled and SetFilter selections need to be converted to text equals conditions.\n */\nexport const constructAdvancedFilterCondition = (\n  colId: string,\n  values: (string | null)[],\n): AdvancedFilterModel | null => {\n  // Filter out null values\n  const validValues = values.filter((v): v is string => v !== null && v !== \"\");\n\n  if (validValues.length === 0) {\n    return null;\n  }\n\n  if (validValues.length === 1) {\n    // Single value - return a simple text equals condition\n    return {\n      filterType: \"text\",\n      colId,\n      type: \"equals\",\n      filter: validValues[0],\n    } as ColumnAdvancedFilterModel;\n  }\n\n  // Multiple values - wrap in a join with OR\n  const conditions: ColumnAdvancedFilterModel[] = validValues.map((value) => ({\n    filterType: \"text\",\n    colId,\n    type: \"equals\",\n    filter: value,\n  }));\n\n  return {\n    filterType: \"join\",\n    type: \"OR\",\n    conditions,\n  } as JoinAdvancedFilterModel;\n};\n\n/**\n * Converts a regular FilterModel to an AdvancedFilterModel.\n * Used when initializing with a regular filter model but the table has advanced filter enabled.\n */\nexport const convertFilterModelToAdvanced = (filterModel: FilterModel): AdvancedFilterModel | null => {\n  const conditions: AdvancedFilterModel[] = [];\n\n  Object.keys(filterModel).forEach((field) => {\n    const filter = filterModel[field];\n    if (!filter) return;\n\n    // Handle set filter\n    if (filter.filterType === \"set\" && filter.values) {\n      const condition = constructAdvancedFilterCondition(field, filter.values);\n      if (condition) {\n        conditions.push(condition);\n      }\n    }\n    // Handle multi filter\n    else if (filter.filterType === \"multi\" && filter.filterModels) {\n      const setFilter = filter.filterModels.find((m: { filterType?: string }) => m && m.filterType === \"set\");\n      if (setFilter?.values) {\n        const condition = constructAdvancedFilterCondition(field, setFilter.values);\n        if (condition) {\n          conditions.push(condition);\n        }\n      }\n    }\n  });\n\n  if (conditions.length === 0) {\n    return null;\n  }\n\n  if (conditions.length === 1) {\n    return conditions[0];\n  }\n\n  return {\n    filterType: \"join\",\n    type: \"AND\",\n    conditions,\n  } as JoinAdvancedFilterModel;\n};\n\n// evaluates the state filter model against the column definitions to avoid mismatches between filter types\n// AG Grid doesn't support passing a set filter state into a multi filter (even if the multi filter supports a set filter option)\nexport const cleanInitialGridState = (\n  state: GridState | null | undefined,\n  colDefs: ColDef[],\n  enableAdvancedFilter: boolean = false,\n): GridState | null | undefined => {\n  if (!state) return state;\n  const newState = { ...state };\n\n  const filterModel = newState.filter?.filterModel || {};\n\n  if (enableAdvancedFilter) {\n    // If advanced filter is enabled, convert regular filter model to advanced filter model.\n    // When both are supplied, merge them so callers can seed regular filters and\n    // aggregate advanced filters in the same initial state.\n    const advancedFilterModelRaw = state?.filter?.advancedFilterModel;\n    const convertedFilterModel = convertFilterModelToAdvanced(filterModel);\n    const providedAdvancedFilterModel = advancedFilterModelRaw ? (advancedFilterModelRaw as AdvancedFilterModel) : null;\n    let advancedFilterModel: AdvancedFilterModel | null = null;\n\n    if (providedAdvancedFilterModel && convertedFilterModel) {\n      advancedFilterModel = {\n        filterType: \"join\",\n        type: \"AND\",\n        conditions: [convertedFilterModel, providedAdvancedFilterModel],\n      } as JoinAdvancedFilterModel;\n    } else {\n      advancedFilterModel = providedAdvancedFilterModel || convertedFilterModel;\n    }\n\n    newState.filter = {\n      ...newState.filter,\n      advancedFilterModel: advancedFilterModel ?? undefined,\n      filterModel: undefined, // Clear regular filter model\n    };\n    return newState;\n  }\n\n  // translate all filters to multi filters if necessary\n  const newModel: FilterModel = {};\n  Object.keys(filterModel).forEach((field) => {\n    const existingFilter = filterModel[field] || {};\n    const colDefForFilter = colDefs.find((col) => col.field === field);\n    newModel[field] = mapFilterBasedOnColDef(existingFilter, colDefForFilter);\n  });\n\n  newState.filter = {\n    ...newState.filter,\n    filterModel: newModel,\n  };\n\n  return newState;\n};\n\nexport const mapQueryToFilterModel = (query: QueryBuilderOutput | null): FilterModel => {\n  if (!query || query.queryTerms.length === 0) {\n    return {};\n  }\n  const filterModel: FilterModel = {};\n  query.queryTerms.forEach((term) => {\n    const field = term.queryField || \"\";\n    const filterAlreadyExists = filterModel[field];\n    if (!filterAlreadyExists) {\n      filterModel[field] = {\n        filterType: \"text\",\n        type: term.exactMatch ? \"equals\" : \"contains\",\n        filter: term.queryText || \"\",\n      };\n    } else {\n      const existingFilter = filterModel[field];\n      // If the existing filter already has conditions, append to them\n      if (existingFilter.conditions) {\n        filterModel[field] = {\n          filterType: \"text\",\n          operator: \"OR\",\n          conditions: [\n            ...existingFilter.conditions,\n            {\n              type: term.exactMatch ? \"equals\" : \"contains\",\n              filter: term.queryText || \"\",\n            },\n          ],\n        };\n      } else {\n        // Convert the existing simple filter into a multi-condition filter\n        filterModel[field] = {\n          filterType: \"text\",\n          operator: \"OR\",\n          conditions: [\n            {\n              type: existingFilter.type,\n              filter: existingFilter.filter,\n            },\n            {\n              type: term.exactMatch ? \"equals\" : \"contains\",\n              filter: term.queryText || \"\",\n            },\n          ],\n        };\n      }\n    }\n  });\n  return filterModel;\n};\n\n/**\n * Maps a QueryBuilderOutput to an AdvancedFilterModel.\n * Multiple terms for the same field are combined with OR logic.\n * Different fields are combined with AND logic at the top level.\n */\nexport const mapQueryToAdvancedFilterModel = (query: QueryBuilderOutput | null): AdvancedFilterModel | null => {\n  if (!query || query.queryTerms.length === 0) {\n    return null;\n  }\n\n  // Group terms by field\n  const termsByField = new Map<string, typeof query.queryTerms>();\n  query.queryTerms.forEach((term) => {\n    const field = term.queryField || \"\";\n    if (!termsByField.has(field)) {\n      termsByField.set(field, []);\n    }\n    termsByField.get(field)!.push(term);\n  });\n\n  // Build conditions for each field\n  const fieldConditions: AdvancedFilterModel[] = [];\n\n  termsByField.forEach((terms, field) => {\n    if (terms.length === 1) {\n      // Single term for this field - create a simple column condition\n      const term = terms[0];\n      fieldConditions.push({\n        filterType: \"text\",\n        colId: field,\n        type: term.exactMatch ? \"equals\" : \"contains\",\n        filter: term.queryText || \"\",\n      } as ColumnAdvancedFilterModel);\n    } else {\n      // Multiple terms for this field - wrap in OR join\n      const orConditions: ColumnAdvancedFilterModel[] = terms.map((term) => ({\n        filterType: \"text\",\n        colId: field,\n        type: term.exactMatch ? \"equals\" : \"contains\",\n        filter: term.queryText || \"\",\n      }));\n      fieldConditions.push({\n        filterType: \"join\",\n        type: \"OR\",\n        conditions: orConditions,\n      } as JoinAdvancedFilterModel);\n    }\n  });\n\n  // If only one field, return its condition directly\n  if (fieldConditions.length === 1) {\n    return fieldConditions[0];\n  }\n\n  // Multiple fields - wrap in AND join\n  return {\n    filterType: \"join\",\n    type: \"AND\",\n    conditions: fieldConditions,\n  } as JoinAdvancedFilterModel;\n};\n\ntype SupportedFilterType = TextFilterModel | SetFilterModel | IMultiFilterModel;\n\nconst constructFilterFromColDef = (colDef: ColDef | undefined, filter: SupportedFilterType): SupportedFilterType => {\n  // if we don't have a colDef, just return the filter\n  if (!colDef) return filter;\n  // based on the colDef filter type, construct the appropriate filter\n  if (\n    (colDef.filter == \"agTextColumnFilter\" && filter.filterType == \"text\") ||\n    (colDef.filter == \"agSetColumnFilter\" && filter.filterType == \"set\") ||\n    (colDef.filter == \"agMultiColumnFilter\" && filter.filterType == \"multi\")\n  ) {\n    return filter;\n  }\n  if (colDef.filter != \"agMultiColumnFilter\") {\n    console.error(\"Unsupported filter type for column\", colDef, filter);\n    return filter;\n  }\n  //If we have a multi filter but the filter is not multi, we need to wrap it in a multi filter\n  // create an array of nulls the length of the multi filter\n  const multiFilterParams = colDef.filterParams as IMultiFilterParams | undefined;\n  const filters = multiFilterParams?.filters || [];\n  const filterModels = Array(filters.length).fill(null) as SupportedFilterType[];\n  // get the index of the appropriate filter type\n  const filterIndex = filters.findIndex((f) => {\n    if (f.filter == \"agTextColumnFilter\" && filter.filterType == \"text\") return true;\n    return f.filter == \"agSetColumnFilter\" && filter.filterType == \"set\";\n  });\n  // place the filter in the correct index\n  if (filterIndex > -1) {\n    filterModels[filterIndex] = filter;\n  } else {\n    console.warn(\"Could not find matching filter type for column\", colDef, filter);\n  }\n  return {\n    filterType: \"multi\",\n    filterModels,\n  } as IMultiFilterModel;\n};\n\nconst combineFilters = (\n  primaryFilter: SupportedFilterType,\n  secondaryFilter: SupportedFilterType,\n): SupportedFilterType => {\n  // if primary is null or undefined, return the secondary filter\n  if (!primaryFilter || Object.keys(primaryFilter).length === 0) return secondaryFilter;\n  // if the filter types don't match, return the primary filter, and don't override the primary filter if it's not multi\n  if (primaryFilter.filterType != secondaryFilter.filterType || primaryFilter.filterType != \"multi\") {\n    // if the filter types don't match, return the primary filter\n    return primaryFilter;\n  }\n  // now we have 2 multi filters, so we need to merge them\n  const mergedFilter = { ...primaryFilter } as IMultiFilterModel;\n  const secondaryMultiFilter = secondaryFilter as IMultiFilterModel;\n  secondaryMultiFilter.filterModels?.forEach((secFilter, index) => {\n    // if mergedFilter is not null at index, skip\n    if (!mergedFilter.filterModels) {\n      mergedFilter.filterModels = [];\n    }\n    if (!mergedFilter.filterModels[index]) {\n      mergedFilter.filterModels[index] = secFilter;\n    }\n  });\n  return mergedFilter;\n};\n\nexport const filterModelContainsColId = (\n  filterModel: FilterModel | AdvancedFilterModel | null | undefined,\n  colId: string,\n): boolean => {\n  if (!filterModel) return false;\n  // AdvancedFilterModel has filterType at the root level; regular FilterModel does not\n  if (!(\"filterType\" in filterModel)) {\n    // Regular FilterModel: keys are column IDs\n    return colId in filterModel;\n  }\n  // AdvancedFilterModel: check column conditions recursively\n  if (filterModel.filterType === \"join\") {\n    const joinModel = filterModel as JoinAdvancedFilterModel;\n    return joinModel.conditions.some((condition) => filterModelContainsColId(condition, colId));\n  }\n  // Column-level filter\n  const columnModel = filterModel as ColumnAdvancedFilterModel;\n  return columnModel.colId === colId;\n};\n\nexport const mergeFilterModels = (\n  colDefs: ColDef[],\n  primaryModel: FilterModel | null | undefined,\n  secondaryModel: FilterModel | null | undefined,\n): FilterModel => {\n  const outputModel: FilterModel = { ...primaryModel };\n  if (!primaryModel || Object.keys(primaryModel).length === 0) return secondaryModel || {};\n  if (!secondaryModel || Object.keys(secondaryModel).length === 0) return outputModel;\n  Object.keys(secondaryModel).forEach((key) => {\n    // from the secondaryModel, adjust the filter as needed based on the colDef\n    const colDef = colDefs.find((col) => col.field === key);\n    const secondaryFilter = constructFilterFromColDef(colDef, secondaryModel[key]);\n    // check if the primary model already has this key\n    const existingFilter = outputModel[key];\n    // build the new filter\n    outputModel[key] = combineFilters(existingFilter, secondaryFilter);\n  });\n  return outputModel;\n};\n\nexport const hasSetFilter = (colDef: ColDef): boolean => {\n  // for multi, need to check the filterParams\n  if (colDef.filter == \"agSetColumnFilter\") return true;\n  if (colDef.filter == \"agMultiColumnFilter\") {\n    return getColDefSetFilterIndex(colDef) !== undefined && getColDefSetFilterIndex(colDef) > -1;\n  }\n  return false;\n};\n\nexport const addHandlerToSetFilter = <T>(\n  colDef: ColDef,\n  handler: (params: SetFilterValuesFuncParams<T, FilterValueResponseOption>) => void,\n): ColDef<T> => {\n  const updatedColDef = { ...colDef } as ColDef<T>;\n  // if multi filter, add to the correct filterParams\n  if (updatedColDef.filter == \"agSetColumnFilter\") {\n    const existingParams = updatedColDef.filterParams as SetFilterParams | undefined;\n    updatedColDef.filterParams = {\n      ...existingParams,\n      values: handler,\n    };\n    return updatedColDef;\n  }\n  // if multi filter, find the set filter and add the handler\n  const setFilterIndex = getColDefSetFilterIndex(colDef);\n  if (setFilterIndex !== undefined && setFilterIndex > -1) {\n    const existingParams = (updatedColDef.filterParams as IMultiFilterParams) || {};\n    const existingFilters = existingParams.filters || [];\n    const setFilter = existingFilters[setFilterIndex] as IMultiFilterDef;\n    const existingSetFilterParams = setFilter?.filterParams;\n    setFilter.filterParams = {\n      ...existingSetFilterParams,\n      values: handler,\n    };\n    const updatedFilters = [...existingFilters];\n    updatedFilters[setFilterIndex] = setFilter;\n    updatedColDef.filterParams = {\n      ...existingParams,\n      filters: updatedFilters,\n    };\n  }\n  return updatedColDef;\n};\n\nexport const getSetFilter = async (gridApi: GridApi, colDef: ColDef): Promise<SetFilter | null> => {\n  const colField = colDef.field || \"\";\n  // the filter may be multi, so check and then grab the inner set filter if needed\n  const filter = (await gridApi.getColumnFilterInstance(colField)) as MultiFilter | SetFilter;\n  // if we have a set filter at root, return it\n  if (filter?.filterType == \"set\") {\n    return filter;\n  }\n  // at this point, we can't use any other filter than multi, so return null if it's not multi\n  if (!(filter?.filterType == \"multi\")) return null;\n  // check the column def and fetch the index of \"agSetColumnFilter\" if it exists in filterParams\n  const setFilterIndex = getColDefSetFilterIndex(colDef);\n  if (setFilterIndex !== undefined && setFilterIndex > -1) {\n    return filter.getChildFilterInstance(setFilterIndex) as SetFilter;\n  }\n  return null;\n};\n\nexport const updateColumnSetFilterModel = async (\n  gridApi: GridApi,\n  colDef: ColDef,\n  newValues: (string | null)[] | null,\n) => {\n  const colField = colDef.field || \"\";\n  // for a set filter, we can just return the new values\n  const filter = (await gridApi.getColumnFilterInstance(colField)) as SetFilter | MultiFilter;\n  if (filter?.filterType == \"set\") {\n    // When clearing (null or empty array), return null to remove the filter entirely.\n    // AG Grid's validateModel expects values to be an array, not null.\n    if (!newValues || newValues.length === 0) {\n      return null;\n    }\n    return {\n      values: newValues,\n    };\n  }\n  if (!(filter?.filterType == \"multi\")) return null;\n  // for multi filter, get the current model and update the set filter values\n  let filterModel: IMultiFilterModel | null = filter.getModel() as IMultiFilterModel | null;\n  // if the filterModel is null, create an array that equals the length of the multi, with all null values\n  if (!filterModel) {\n    filterModel = {\n      filterType: \"multi\",\n      filterModels: Array(colDef.filterParams?.filters?.length).fill(null),\n    };\n  }\n  // get the index of the set filter\n  const setFilterIndex = getColDefSetFilterIndex(colDef);\n  // When clearing (null or empty array), set the filter slot to null rather than\n  // { filterType: \"set\", values: null } which AG Grid can't iterate over.\n  const updatedSetFilter =\n    !newValues || newValues.length === 0\n      ? null\n      : {\n          filterType: \"set\",\n          values: newValues,\n        };\n  if (setFilterIndex !== undefined && setFilterIndex > -1 && filterModel && filterModel.filterModels) {\n    filterModel.filterModels[setFilterIndex] = updatedSetFilter;\n  }\n  return filterModel;\n};\n\nexport const getSelectedValuesFromFilterModel = (colDef: ColDef, filterModel: FilterModel | null) => {\n  if (!colDef.field || !filterModel || Object.entries(filterModel).length === 0) return [];\n  // return if the filter model does not have the colDef field\n  const filter = filterModel[colDef.field];\n  if (!filter) return [];\n  if (filter.filterType === \"set\" && \"values\" in filter) return filter.values || [];\n  if (filter.filterType === \"multi\") {\n    const setFilterIndex = getColDefSetFilterIndex(colDef);\n    if (setFilterIndex !== undefined && setFilterIndex > -1) {\n      const setFilter = filter.filterModels[setFilterIndex];\n      if (setFilter && setFilter.filterType === \"set\" && \"values\" in setFilter) {\n        return setFilter.values || [];\n      }\n    }\n  }\n  return [];\n};\n\nexport const isAdvancedFilterModel = (\n  model: FilterModel | AdvancedFilterModel | null | undefined,\n): model is AdvancedFilterModel => {\n  return !!model && \"filterType\" in model;\n};\n\nexport const advancedFilterHasConditions = (model: AdvancedFilterModel): boolean => {\n  if (model.filterType === \"join\") {\n    return (model as JoinAdvancedFilterModel).conditions.some(advancedFilterHasConditions);\n  }\n  return \"colId\" in model;\n};\n\nexport const isFilterModelEmpty = (model: FilterModel | AdvancedFilterModel | null | undefined): boolean => {\n  if (!model) return true;\n  if (isAdvancedFilterModel(model)) return !advancedFilterHasConditions(model);\n  return Object.keys(model).length === 0;\n};\n\nconst stableStringify = (value: unknown): string => {\n  if (value === undefined) return \"undefined\";\n  if (value === null || typeof value !== \"object\") return JSON.stringify(value) ?? String(value);\n  if (Array.isArray(value)) return `[${value.map(stableStringify).join(\",\")}]`;\n\n  const record = value as Record<string, unknown>;\n  return `{${Object.keys(record)\n    .sort()\n    .map((key) => `${JSON.stringify(key)}:${stableStringify(record[key])}`)\n    .join(\",\")}}`;\n};\n\nconst normalizeAdvancedFilterModelForComparison = (model: AdvancedFilterModel): AdvancedFilterModel => {\n  if (model.filterType !== \"join\") return model;\n\n  const joinModel = model as JoinAdvancedFilterModel;\n  const conditions = [...(joinModel.conditions ?? [])]\n    .map(normalizeAdvancedFilterModelForComparison)\n    .sort((a, b) => stableStringify(a).localeCompare(stableStringify(b)));\n\n  return { ...joinModel, conditions };\n};\n\nexport const filterModelsEqual = (\n  modelA: FilterModel | AdvancedFilterModel | null | undefined,\n  modelB: FilterModel | AdvancedFilterModel | null | undefined,\n): boolean => {\n  if (isFilterModelEmpty(modelA) && isFilterModelEmpty(modelB)) {\n    return true;\n  }\n\n  // If one is AdvancedFilterModel and the other isn't, they are different model types\n  const aIsAdvanced = isAdvancedFilterModel(modelA);\n  const bIsAdvanced = isAdvancedFilterModel(modelB);\n  if (aIsAdvanced !== bIsAdvanced) {\n    return false;\n  }\n\n  // For AdvancedFilterModel, compare with normalized join condition order.\n  if (aIsAdvanced) {\n    return isEqual(\n      normalizeAdvancedFilterModelForComparison(modelA as AdvancedFilterModel),\n      normalizeAdvancedFilterModelForComparison(modelB as AdvancedFilterModel),\n    );\n  }\n\n  // For regular FilterModel, compare by keys\n  const regularA = modelA as FilterModel | null | undefined;\n  const regularB = modelB as FilterModel | null | undefined;\n  const modelAKeys = regularA ? Object.keys(regularA) : [];\n  const modelBKeys = regularB ? Object.keys(regularB) : [];\n  if (modelAKeys.length !== modelBKeys.length) {\n    return false;\n  }\n  for (const key of modelAKeys) {\n    if (!isEqual(regularA?.[key], regularB?.[key])) {\n      return false;\n    }\n  }\n  return true;\n};\n\n/**\n * Merges a new filter condition into an existing advanced filter model.\n * If the existing model is null, returns the new condition.\n * If both exist, combines them with AND logic at the top level.\n */\nexport const mergeAdvancedFilterCondition = (\n  existingModel: AdvancedFilterModel | null,\n  newCondition: AdvancedFilterModel | null,\n  colId: string,\n): AdvancedFilterModel | null => {\n  // If new condition is null, we need to remove this column's filter from the model\n  if (!newCondition) {\n    return removeColumnFromAdvancedFilter(existingModel, colId);\n  }\n\n  // If no existing model, just return the new condition\n  if (!existingModel) {\n    return newCondition;\n  }\n\n  // Remove any existing conditions for this column first\n  const cleanedModel = removeColumnFromAdvancedFilter(existingModel, colId);\n\n  // If cleaned model is null, just return the new condition\n  if (!cleanedModel) {\n    return newCondition;\n  }\n\n  // Combine with AND at the top level\n  // If the cleaned model is already a join with AND, add to its conditions\n  if (cleanedModel.filterType === \"join\" && cleanedModel.type === \"AND\") {\n    return {\n      filterType: \"join\",\n      type: \"AND\",\n      conditions: [...cleanedModel.conditions, newCondition],\n    } as JoinAdvancedFilterModel;\n  }\n\n  // Otherwise wrap both in a new AND join\n  return {\n    filterType: \"join\",\n    type: \"AND\",\n    conditions: [cleanedModel, newCondition],\n  } as JoinAdvancedFilterModel;\n};\n\n/**\n * Removes all conditions for a specific column from an advanced filter model.\n */\nexport const removeColumnFromAdvancedFilter = (\n  model: AdvancedFilterModel | null,\n  colId: string,\n): AdvancedFilterModel | null => {\n  if (!model) return null;\n\n  // If it's a column filter for this column, remove it entirely\n  if (model.filterType !== \"join\") {\n    const columnModel = model as ColumnAdvancedFilterModel;\n    return columnModel.colId === colId ? null : model;\n  }\n\n  // It's a join filter - recursively remove conditions for this column\n  const joinModel = model as JoinAdvancedFilterModel;\n  const filteredConditions = joinModel.conditions\n    .map((condition) => removeColumnFromAdvancedFilter(condition, colId))\n    .filter((condition): condition is AdvancedFilterModel => condition !== null);\n\n  // If no conditions left, return null\n  if (filteredConditions.length === 0) {\n    return null;\n  }\n\n  // If only one condition left, return it directly (unwrap the join)\n  if (filteredConditions.length === 1) {\n    return filteredConditions[0];\n  }\n\n  return {\n    filterType: \"join\",\n    type: joinModel.type,\n    conditions: filteredConditions,\n  } as JoinAdvancedFilterModel;\n};\n\n/**\n * Extracts selected values for a specific column from an advanced filter model.\n * Only extracts values from text equals conditions.\n */\nexport const getSelectedValuesFromAdvancedFilterModel = (\n  colId: string,\n  model: AdvancedFilterModel | null,\n): string[] => {\n  if (!model) return [];\n\n  // If it's a column filter\n  if (model.filterType !== \"join\") {\n    const columnModel = model as ColumnAdvancedFilterModel;\n    if (columnModel.colId === colId && columnModel.type === \"equals\" && columnModel.filter) {\n      return [String(columnModel.filter)];\n    }\n    return [];\n  }\n\n  // It's a join filter - collect values from matching conditions\n  const joinModel = model as JoinAdvancedFilterModel;\n  const values: string[] = [];\n\n  for (const condition of joinModel.conditions) {\n    values.push(...getSelectedValuesFromAdvancedFilterModel(colId, condition));\n  }\n\n  return values;\n};\n\n// ─── Unified Filter Helpers ──────────────────────────────────────────────────\n// These functions auto-detect the model type (regular vs advanced) and dispatch\n// to the appropriate underlying helper. The optional `advanced` parameter is only\n// consulted when the model is null/undefined to decide which type to create.\n\n/**\n * Like `getSelectedValuesFromFilterModel` but takes a `colId` string instead of\n * a `ColDef`. For multi-filters, finds the set filter by scanning filterModels\n * for `filterType === \"set\"` rather than relying on colDef index.\n */\nexport const getSelectedValuesFromFilterModelByColId = (colId: string, filterModel: FilterModel | null): string[] => {\n  if (!colId || !filterModel || Object.keys(filterModel).length === 0) return [];\n  const filter = filterModel[colId];\n  if (!filter) return [];\n  if (filter.filterType === \"set\" && \"values\" in filter) return filter.values || [];\n  if (filter.filterType === \"multi\" && filter.filterModels) {\n    const setFilter = filter.filterModels.find((m: { filterType?: string }) => m?.filterType === \"set\");\n    return setFilter?.values ?? [];\n  }\n  return [];\n};\n\n/**\n * Unified getter: extracts set-filter values for a column from either a regular\n * or advanced filter model. Returns null when no filter exists for the column.\n */\nexport const getSelectedValues = (model: AnyFilterModel, colId: string): string[] | null => {\n  if (!model) return null;\n  if (isAdvancedFilterModel(model)) {\n    const values = getSelectedValuesFromAdvancedFilterModel(colId, model);\n    return values.length > 0 ? values : null;\n  }\n  const values = getSelectedValuesFromFilterModelByColId(colId, model as FilterModel);\n  return values.length > 0 ? values : null;\n};\n\n/**\n * Unified remove: returns a new model with the given column's filter removed.\n */\nexport const removeColumnFilter = (model: AnyFilterModel, colId: string): AnyFilterModel => {\n  if (!model) return model;\n  if (isAdvancedFilterModel(model)) {\n    return removeColumnFromAdvancedFilter(model, colId);\n  }\n  const regular = { ...(model as FilterModel) };\n  delete regular[colId];\n  return regular;\n};\n\n/**\n * Unified set-filter update: returns a new model with the column's set-filter\n * values replaced. For advanced models, constructs an equals condition tree.\n * The `advanced` flag is only consulted when `model` is null.\n */\nexport const updateSetFilter = (\n  model: AnyFilterModel,\n  colId: string,\n  values: string[],\n  advanced?: boolean,\n): AnyFilterModel => {\n  if (isAdvancedFilterModel(model) || (!model && advanced)) {\n    const condition = constructAdvancedFilterCondition(colId, values);\n    return mergeAdvancedFilterCondition((model as AdvancedFilterModel) ?? null, condition, colId);\n  }\n  const regular = { ...((model as FilterModel) || {}) };\n  regular[colId] = { filterType: \"set\", values };\n  return regular;\n};\n\n/**\n * Like `updateSetFilter` but preserves multi-filter structure for regular models.\n * If the existing column filter is a multi-filter, only the nested set filter is\n * updated; other filter models (e.g. text) are preserved.\n */\nexport const updateMultiOrSetFilter = (\n  model: AnyFilterModel,\n  colId: string,\n  values: string[],\n  advanced?: boolean,\n): AnyFilterModel => {\n  if (isAdvancedFilterModel(model) || (!model && advanced)) {\n    return updateSetFilter(model, colId, values, advanced);\n  }\n  const regular = { ...((model as FilterModel) || {}) };\n  const existingFilter = regular[colId];\n  const isMulti = existingFilter?.filterType === \"multi\" && existingFilter?.filterModels;\n  if (isMulti) {\n    const updatedFilterModels = existingFilter.filterModels.map((m: FilterModel) =>\n      m?.filterType === \"set\" ? { ...m, values } : m,\n    );\n    regular[colId] = {\n      ...existingFilter,\n      filterModels: updatedFilterModels,\n    };\n  } else {\n    regular[colId] = { filterType: \"set\", values };\n  }\n  return regular;\n};\n\n/**\n * Unified exclude: removes a single value from a column's set filter.\n * If removing the value leaves no values, the column filter is removed entirely.\n */\nexport const excludeValueFromSetFilter = (\n  model: AnyFilterModel,\n  colId: string,\n  valueToExclude: string,\n  advanced?: boolean,\n): AnyFilterModel => {\n  const currentValues = getSelectedValues(model, colId) ?? [];\n  const remaining = currentValues.filter((v) => v !== valueToExclude);\n  if (remaining.length === 0) {\n    return removeColumnFilter(model, colId);\n  }\n  return updateMultiOrSetFilter(model, colId, remaining, advanced);\n};\n","import { AdvancedFilterModel, FilterModel } from \"ag-grid-enterprise\";\nimport { ColDef, GridApi, RefreshServerSideParams } from \"ag-grid-community\";\nimport { Ref, computed, inject, provide, ref, shallowRef } from \"vue\";\n\nimport { FilterStoreKey } from \"@tables/symbols\";\nimport type {\n  FilterValueMatchResult,\n  FilterValueResponseOption,\n  FilterValuesResponse,\n  FilterValuesSetHandlerParams,\n  TableSearchHandlerParams,\n} from \"@tables/PvDataTable/types\";\nimport type { QueryTerm } from \"@/components/base/PvQueryBuilderInput/useQueryBuilder\";\nimport { watchDebounced } from \"@vueuse/core\";\nimport { colDefContext } from \"@tables/PvDataTable/helpers.ts\";\nimport { advancedFilterHasConditions, getSelectedValues } from \"@tables/PvDataTable/filters/filterHelpers.ts\";\nimport { createPvFilterStore } from \"@/components/base/PvFilterPanel/usePvFilterStore\";\nimport type { PvFilterPanelFilterModel } from \"@/components/base/PvFilterPanel/types\";\n\nexport type PvDataTableFilterModel = PvFilterPanelFilterModel;\n\ntype RegularFilterValueModel = Record<string, { values?: (string | null)[] } | undefined>;\n\n/**\n * Type guard to check if a filter model is an AdvancedFilterModel.\n */\nexport const isAdvancedFilterModel = (model: PvDataTableFilterModel): model is AdvancedFilterModel => {\n  return Boolean(model && \"filterType\" in model);\n};\n\n/**\n * Type guard to check if a filter model is a regular FilterModel (not AdvancedFilterModel)\n */\nexport const isRegularFilterModel = (model: PvDataTableFilterModel): model is FilterModel => {\n  return Boolean(model && !isAdvancedFilterModel(model));\n};\n\nconst isRegularFilterValueModel = (model: PvDataTableFilterModel): model is RegularFilterValueModel => {\n  return Boolean(model && !isAdvancedFilterModel(model));\n};\n\nexport interface PvDataTableFilterController {\n  getFilterModel: () => PvDataTableFilterModel;\n  refreshData: (params?: RefreshServerSideParams | null) => Promise<void> | void;\n  setFilterModel: (model: PvDataTableFilterModel) => boolean | void;\n  setTableSearchFilterModel: (model: PvDataTableFilterModel) => boolean | void;\n}\n\nexport const createFilterStore = () => {\n  const pvFilterStore = createPvFilterStore();\n  const filterController = shallowRef<PvDataTableFilterController | null>(null);\n  // the filter model tracks the current applied filter (can be regular or advanced)\n  const filterModel = pvFilterStore.filterModel;\n  // the staged filter model is where we can hold filter changes that are not yet applied, like in the drawer\n  const stagedFilterModel = pvFilterStore.stagedFilterModel;\n  // the table search filter model is used to filter tabular results, and stays separate from the column filters\n  const tableSearchFilterModel: Ref<PvDataTableFilterModel> = ref(null);\n  // tracks which columns were updated\n  const filterLastUpdatedMap: Ref<Record<string, number>> = ref({});\n  // track the last time a fetch was made for a specific column\n  const filterLastFetchTimeMap: Ref<Record<string, number>> = ref({});\n  // track request IDs for each column to handle race conditions\n  const filterRequestIdMap = pvFilterStore.filterRequestIdMap as Ref<Record<string, number>>;\n  const filterModelCleared = ref(0);\n  const filterValuesLoadingStatus = pvFilterStore.filterLoadingMap as Ref<Record<string, boolean>>;\n  const filterStoreHandler = ref<\n    | ((\n        params: FilterValuesSetHandlerParams<unknown>,\n      ) => Promise<FilterValuesResponse | (FilterValueResponseOption | null)[]>)\n    | undefined\n  >(undefined);\n\n  // Track pagination state per field from FilterValuesResponse\n  const filterValuesHasMoreMap = pvFilterStore.filterHasMoreMap;\n  const filterValuesTotalCountMap = pvFilterStore.filterTotalCountMap;\n  const tableSearchHandler = ref<\n    ((params: TableSearchHandlerParams<unknown>) => Promise<(QueryTerm | null)[]>) | undefined\n  >(undefined);\n\n  const currentFilterOptionsResponse = (field: string): FilterValuesResponse => ({\n    hasMore: pvFilterStore.filterHasMoreMap.value[field],\n    totalCount: pvFilterStore.filterTotalCountMap.value[field],\n    values: pvFilterStore.filterOptionsMap.value[field] ?? [],\n  });\n\n  pvFilterStore.setFilterOptionsHandler(async (params) => {\n    const handler = filterStoreHandler.value;\n    if (!handler) return currentFilterOptionsResponse(params.field);\n\n    const response = await handler({\n      ...params,\n      colDef: params.colDef as ColDef<unknown>,\n      filterModel: params.filterModel,\n    });\n    return response ?? currentFilterOptionsResponse(params.field);\n  });\n\n  const isServerSideFilter = computed(() => {\n    return filterStoreHandler.value != null;\n  });\n\n  const filterModelEmpty = computed(() => {\n    const currentFilterModel = filterModel.value;\n    if (!currentFilterModel) return true;\n    // AdvancedFilterModel has filterType at the root level; empty if no conditions\n    if (isAdvancedFilterModel(currentFilterModel)) {\n      return !advancedFilterHasConditions(currentFilterModel);\n    }\n    return Object.keys(currentFilterModel).length === 0;\n  });\n\n  const tableSearchFilterModelEmpty = computed(() => {\n    const currentFilterModel = tableSearchFilterModel.value || {};\n    return Object.keys(currentFilterModel).length === 0;\n  });\n\n  // Store all metadata for every filter value returned from the API\n  const filterValueMap = pvFilterStore.filterOptionsMap as Ref<Record<string, (FilterValueResponseOption | null)[]>>;\n\n  // This list is eventually the same as selectedValues list that is needed by AgGrid,\n  // we just persist this to show the selected values faster.\n  const filterValueSelectedMap = pvFilterStore.filterSelectedValueMap;\n\n  // Keep track of metadata for selected values in order to show\n  // the correct display name for the selected values\n  const filterValueSelectedMetadataMap = pvFilterStore.filterSelectedMetadataMap as Ref<\n    Record<string, (FilterValueResponseOption | null)[]>\n  >;\n\n  const filterValueSearchTextMap = pvFilterStore.filterSearchQueries as Ref<Record<string, string | null>>;\n\n  // Sorted filter values available for display (centralized, shared across SetFilter instances)\n  const filterValuesMap: Ref<Record<string, (string | null)[]>> = ref({});\n\n  // Staleness flag per field — set when OTHER filters change, cleared on fetch\n  const filterStaleMap: Ref<Record<string, boolean>> = ref({});\n\n  const fetchPvFilterOptions = async (params: Parameters<typeof pvFilterStore.fetchFilterOptions>[0]) => {\n    const results = await pvFilterStore.fetchFilterOptions(params);\n    filterValuesMap.value[params.field] = results;\n    filterStaleMap.value[params.field] = false;\n    filterLastFetchTimeMap.value[params.field] = Date.now();\n    return results;\n  };\n\n  // When false (default), filters don't fetch on model changes until opened\n  const refreshFiltersInBackground: Ref<boolean> = ref(false);\n\n  // When true, filter selections are buffered until the filter dropdown closes\n  const stageFilterChangesUntilDropdownCloses: Ref<boolean> = ref(false);\n\n  // See pv-components/src/components/tables/PvDataTable/types.ts\n  // Defaults to undefined, aka no limit.\n  const filterSearchMinLength: Ref<number | undefined> = ref(undefined);\n\n  // Aggregate field registry: e.g. { \"provider_combined\": [\"provider_name\", \"health_system\"] }\n  const aggregateFieldMap: Ref<Record<string, string[]>> = ref({});\n\n  // Registry of all filter fields with active useSetFilter instances\n  // Used by markOtherFieldsStale to notify ALL filters, not just those that have fetched values\n  const registeredFilterFields: Ref<Set<string>> = ref(new Set());\n\n  // Track registration counts because multiple instances for the same field can be mounted\n  // concurrently (e.g., horizontal filters plus a vertical drawer copy)\n  const registeredFilterFieldCounts: Ref<Record<string, number>> = ref({});\n\n  // Staged selected values — vertical drawer writes here; horizontal reads from filterValueSelectedMap\n  const stagedSelectedValuesMap = pvFilterStore.stagedFilterSelectedValueMap;\n\n  // manually build the filter model from selected values, if we want filter data before onFilterChanged() is called\n  // this is needed for the vertical filter drawing filtering to work (before hitting Apply)\n  const constructTempFilterModel = (baseFilterModel?: FilterModel): FilterModel => {\n    const tempFilterModel: FilterModel = {};\n\n    // Start with base filter model if provided (e.g., passed filterModel or filterModel.value)\n    if (baseFilterModel) {\n      Object.entries(baseFilterModel).forEach(([colId, filter]) => {\n        tempFilterModel[colId] = filter;\n      });\n    }\n\n    // Layer applied selections from filterValueSelectedMap\n    Object.entries(filterValueSelectedMap.value).forEach(([colId, values]) => {\n      const validValues = values.filter((v): v is string => !!v);\n      if (validValues.length > 0) {\n        tempFilterModel[colId] = {\n          filterType: \"set\",\n          values: validValues,\n        };\n      }\n    });\n\n    // Overlay staged selections ONLY when staging is active (drawer is open).\n    // Without this guard, stale staged values (from a previous drawer session)\n    // would incorrectly override or delete current filterValueSelectedMap entries.\n    if (stagedFilterModel.value != null) {\n      Object.entries(stagedSelectedValuesMap.value).forEach(([colId, values]) => {\n        const validValues = values.filter((v): v is string => !!v);\n        if (validValues.length > 0) {\n          tempFilterModel[colId] = {\n            filterType: \"set\",\n            values: validValues,\n          };\n        } else {\n          // If staged values are explicitly empty, remove the field (user cleared the filter in drawer)\n          delete tempFilterModel[colId];\n        }\n      });\n    }\n\n    return tempFilterModel;\n  };\n\n  const OPTION_MATCH_MAX_DEPTH = 25;\n\n  const parseScopedOptionRawValue = (value: string | null | undefined): string | null => {\n    if (!value) return value ?? null;\n    if (!value.startsWith(\"__\")) return value;\n    const parts = value.slice(2).split(\"__\");\n    return parts.length >= 2 ? parts[1] : value;\n  };\n\n  /**\n   * Extracts the raw value from an option, checking explicit rawValue first,\n   * then metadata.rawValue, then the scoped token format (`__field__value__...`).\n   *\n   * @returns The raw value string, or null if the option is nullish.\n   */\n  const optionRawValue = (option: FilterValueResponseOption | null | undefined): string | null => {\n    if (!option) return null;\n    if (option.rawValue != null) return String(option.rawValue);\n    if (option.metadata?.rawValue != null) return String(option.metadata.rawValue);\n    return parseScopedOptionRawValue(option.value);\n  };\n\n  /**\n   * Returns true when a response option represents the selected item, even if one\n   * side is a raw selected value (for example `PV_1001`) and the other is a nested\n   * aggregate child token (for example `__provider_id__PV_1001__health_system__Banner`).\n   * Recurses through children so selected aggregate children are recognized inside\n   * their parent instead of being re-injected as raw top-level options.\n   */\n  const optionMatchesSelectedItem = (\n    option: FilterValueResponseOption | null | undefined,\n    selectedItem: FilterValueResponseOption,\n    depth = 0,\n  ): boolean => {\n    if (!option || depth > OPTION_MATCH_MAX_DEPTH) return false;\n    if (option.value === selectedItem.value) return true;\n\n    const optionRaw = optionRawValue(option);\n    const selectedRaw = optionRawValue(selectedItem);\n    if (optionRaw != null && selectedRaw != null && optionRaw === selectedRaw) return true;\n\n    return option.children?.some((child) => optionMatchesSelectedItem(child, selectedItem, depth + 1)) ?? false;\n  };\n\n  // Bumps the request ID for a column so any in-flight fetchFilterValues response\n  // fails its identity check on return and is discarded. Use when a caller decides\n  // not to fire a new fetch (e.g. search query dropped below filterSearchMinLength)\n  // but an earlier in-flight request would otherwise land and stale the cache.\n  const invalidateFilterRequest = (colField: string) => {\n    filterRequestIdMap.value[colField] = (filterRequestIdMap.value[colField] || 0) + 1;\n  };\n\n  const fetchFilterValues = async (\n    colDef: ColDef,\n    options?: {\n      api?: GridApi;\n      filterModel?: FilterModel | AdvancedFilterModel;\n      offset?: number;\n      parentId?: string;\n      useStaged?: boolean;\n    },\n  ): Promise<(string | null)[]> => {\n    const query = filterValueSearchTextMap.value[colDef.field as string] || undefined;\n    const selectedValues = filterValueSelectedMap.value[colDef.field as string] || [];\n    let requestFilterModel: FilterModel | AdvancedFilterModel | undefined = options?.filterModel;\n\n    // When drawer is open (staging active) AND the caller wants staged behavior,\n    // merge staged selections with the filter model. Horizontal filters pass\n    // useStaged: false to bypass this and use the passed filterModel directly.\n    if (options?.useStaged !== false && stagedFilterModel.value != null) {\n      if (isRegularFilterModel(stagedFilterModel.value)) {\n        // Build regular FilterModel from staged + applied selections\n        const candidateBase = options?.filterModel ?? filterModel.value ?? undefined;\n        const baseModel = candidateBase && isRegularFilterModel(candidateBase) ? candidateBase : undefined;\n        requestFilterModel = constructTempFilterModel(baseModel);\n      } else {\n        // Advanced-filter drawer stages the full AdvancedFilterModel directly.\n        // Preserve aggregate/cascade conditions instead of rebuilding a regular\n        // FilterModel from flat selected values (which cannot represent parent /\n        // child notEqual branches).\n        requestFilterModel = stagedFilterModel.value;\n      }\n    }\n    // call the provided handler to fetch values\n    const handlerParams: FilterValuesSetHandlerParams<unknown> = {\n      api: options?.api,\n      colDef: colDef,\n      field: colDef.field as string,\n      filterModel: requestFilterModel,\n      offset: options?.offset,\n      parentId: options?.parentId,\n      query: query,\n      reason: options?.parentId ? \"child-load-more\" : options?.offset ? \"load-more\" : query ? \"search\" : \"open\",\n      selectedValues: selectedValues,\n    };\n    const colField = colDef.field as string;\n    // When appending (see-more), don't flip the loading state — otherwise the dropdown\n    // shows a full-reload shimmer. The existing items stay visible; new items append in place.\n    const isAppendRequest = (options?.offset ?? 0) > 0;\n    if (!isAppendRequest) {\n      filterValuesLoadingStatus.value[colField] = true;\n    }\n\n    // Increment request ID for this column to handle race conditions\n    const currentRequestId = (filterRequestIdMap.value[colField] || 0) + 1;\n    filterRequestIdMap.value[colField] = currentRequestId;\n\n    const currentSelectedValues = selectedValues.map((item) => {\n      const mappedItem = filterValueContext(colField, item);\n      if (mappedItem) {\n        return mappedItem;\n      }\n      return { value: item, label: String(item) } as FilterValueResponseOption;\n    });\n\n    // TODO - scrub the column id we're filtering on from the filter model\n\n    // fetch the actual filter values from the store handler\n    const rawResponse = await filterStoreHandler.value?.(handlerParams);\n\n    // Normalize: handler can return an array or a FilterValuesResponse wrapper\n    let response: (FilterValueResponseOption | null)[] | undefined;\n    if (rawResponse && !Array.isArray(rawResponse)) {\n      response = rawResponse.values;\n      filterValuesHasMoreMap.value[colField] = rawResponse.hasMore;\n      filterValuesTotalCountMap.value[colField] = rawResponse.totalCount;\n    } else {\n      response = rawResponse;\n      filterValuesHasMoreMap.value[colField] = undefined;\n      filterValuesTotalCountMap.value[colField] = undefined;\n    }\n\n    // if a query is present, inject matched fields/values if they are missing\n    if (query && response) {\n      response = response.map((option) => {\n        const matchData = getSearchMatchDataFromFilterContext(colDef, option);\n        if (option && matchData) {\n          option.matchedField = option.matchedField ?? matchData.matchedField;\n          option.matchedValue = option.matchedValue ?? matchData.matchedValue;\n        }\n        return option;\n      });\n    }\n\n    // Only process the response if this is still the latest request for this column\n    if (currentRequestId === filterRequestIdMap.value[colField]) {\n      const isAppend = (options?.offset ?? 0) > 0;\n      const isChildLoad = !!options?.parentId;\n\n      if (isAppend && !isChildLoad && response) {\n        // For top-level \"see more\" (offset > 0), append to existing values\n        const existing = filterValueMap.value[colField] || [];\n        response = [...existing, ...response.filter((r) => !existing.some((e) => e?.value === r?.value))];\n      } else if (isChildLoad && response) {\n        // For child-level \"see more\", merge new children into the matching existing parent.\n        // parentId is the parent's canonical `value` (scoped token) — match exactly.\n        const existing = filterValueMap.value[colField] || [];\n        const incomingParent = response.find((r) => r?.value === options!.parentId);\n        if (incomingParent) {\n          response = existing.map((parent) => {\n            if (!parent || parent.value !== incomingParent.value) return parent;\n            const existingChildren = parent.children || [];\n            const newChildren =\n              incomingParent.children?.filter((c) => !existingChildren.some((ec) => ec.value === c.value)) || [];\n            return {\n              ...parent,\n              children: [...existingChildren, ...newChildren],\n            };\n          });\n        } else {\n          response = existing;\n        }\n      }\n\n      currentSelectedValues.forEach((item) => {\n        // Add selected values only if the response doesn't already represent them.\n        // Aggregate filters often store raw IDs in the filter model (e.g. `PV_1001`)\n        // while the API returns scoped nested child tokens\n        // (e.g. `__provider_id__PV_1001__health_system__Banner`). Without raw/scoped\n        // matching here, we'd push a top-level raw-ID orphan beside the real child.\n        const isPresent = response?.some((r) => optionMatchesSelectedItem(r, item));\n        if (!isPresent) {\n          response?.push(item);\n        }\n      });\n      if (response) {\n        filterValueMap.value[colField] = response;\n      }\n      const results = response?.filter((item) => item != null).map((item) => item.value) || [];\n      const dedupedResults = results.filter((item, index) => results.indexOf(item) === index);\n      // Update centralized filter values so the UI reflects results immediately\n      filterValuesMap.value[colField] = dedupedResults;\n      filterStaleMap.value[colField] = false;\n      filterLastFetchTimeMap.value[colField] = Date.now();\n      if (!isAppendRequest) {\n        filterValuesLoadingStatus.value[colField] = false;\n      }\n      return dedupedResults;\n    } else {\n      // This request has been superseded by a newer one, ignore the response\n      return [];\n    }\n  };\n\n  const filterValueContext = (colField: string, value: string | null) => {\n    const filterValues = [\n      ...(filterValueMap.value[colField] || []),\n      ...(filterValueSelectedMetadataMap.value[colField] || []),\n    ];\n\n    const mergeOptions = (base: FilterValueResponseOption, overlay: FilterValueResponseOption) => {\n      const childrenByValue = new Map<string, FilterValueResponseOption>();\n      for (const child of base.children || []) childrenByValue.set(child.value, child);\n      for (const child of overlay.children || []) childrenByValue.set(child.value, child);\n      return {\n        ...base,\n        children: childrenByValue.size > 0 ? [...childrenByValue.values()] : base.children,\n        totalChildCount: Math.max(base.totalChildCount ?? 0, overlay.totalChildCount ?? 0) || base.totalChildCount,\n      };\n    };\n\n    const exactMatches = filterValues.filter((item): item is FilterValueResponseOption => item?.value === value);\n    if (exactMatches.length > 0) {\n      return exactMatches.reduce(mergeOptions);\n    }\n\n    const requestedRawValue = parseScopedOptionRawValue(value);\n    const findRecursive = (\n      options: (FilterValueResponseOption | null)[],\n    ): FilterValueResponseOption | null | undefined => {\n      for (const item of options) {\n        if (!item) continue;\n        if (item.value === value) return item;\n        if (requestedRawValue != null && optionRawValue(item) === requestedRawValue) return item;\n        const childMatch = item.children ? findRecursive(item.children) : undefined;\n        if (childMatch) return childMatch;\n      }\n      return undefined;\n    };\n    return findRecursive(filterValues);\n  };\n\n  const getSearchMatchDataFromFilterContext = (\n    colDef: ColDef,\n    option: FilterValueResponseOption | null | undefined,\n  ): FilterValueMatchResult => {\n    /*\n    Given a filter value option and colDef, check the colDef context for queryColIds\n    and see if any of those IDs exist in the option metadata. If so, return the matched\n    field and value.\n     */\n    if (!option) return {};\n    const context = colDefContext(colDef);\n    const queryColIds = context?.queryColIds || [];\n    if (queryColIds.length === 0) return {};\n\n    for (const queryColId of queryColIds) {\n      // exclude the main value field\n      if (queryColId === colDef.field) continue;\n      const metadataValue = option.metadata ? option.metadata[queryColId] : undefined;\n      if (metadataValue !== undefined) {\n        return {\n          matchedField: queryColId,\n          matchedValue: String(metadataValue),\n        };\n      }\n    }\n    return {};\n  };\n\n  // Selected Values\n\n  const setFilterSelectedValues = (colField: string, selectedValues: (string | null)[]) => {\n    filterValueSelectedMap.value[colField] = selectedValues;\n\n    // Combine current selected values with new selected values\n    const newSelectedValues: (string | null)[] = [];\n    const currentModel = filterModel.value;\n    if (isRegularFilterValueModel(currentModel)) {\n      const colFilter = currentModel[colField];\n      if (colFilter?.values) {\n        const currentSelectedValues = colFilter.values || [];\n        newSelectedValues.push(...currentSelectedValues);\n      }\n    }\n    newSelectedValues.push(...selectedValues);\n\n    // Update filterValueSelectedMetadataMap with new selected values\n    const newSelectedValueMap: FilterValueResponseOption[] = [];\n    selectedValues.forEach((item) => {\n      const mappedItem = filterValueContext(colField, item);\n      if (mappedItem) {\n        newSelectedValueMap.push(mappedItem);\n      }\n    });\n    filterValueSelectedMetadataMap.value[colField] = newSelectedValueMap;\n\n    // Return the unique selected values\n    return newSelectedValues.filter((item, index) => newSelectedValues.indexOf(item) === index);\n  };\n\n  const getFilterSelectedValues = (colField: string): (string | null)[] => {\n    return filterValueSelectedMap.value[colField] || [];\n  };\n\n  // Populate filterValueSelectedMetadataMap for every passed column with a selection in the\n  // applied model, not just the ones touched this session. Lets consumers persist the full map\n  // (e.g. for a public view where the viewer can't fetch options). Reuses already-loaded options\n  // and only fetches for columns whose selected values aren't already cached.\n  const hydrateSelectedFilterMetadata = async (\n    colDefs: ColDef[],\n  ): Promise<Record<string, (FilterValueResponseOption | null)[]>> => {\n    const model = filterModel.value;\n    if (!model) return filterValueSelectedMetadataMap.value;\n\n    const columnsToHydrate = colDefs\n      .map((colDef) => {\n        const colId = (colDef.field ?? colDef.colId ?? \"\") as string;\n        const selectedValues = colId ? getSelectedValues(model, colId) : null;\n        return selectedValues && selectedValues.length > 0 ? { colDef, colId, selectedValues } : null;\n      })\n      .filter((entry): entry is { colDef: ColDef; colId: string; selectedValues: string[] } => entry != null);\n\n    // Sequential to avoid flooding the filter-values endpoint when many filters are active.\n    for (const { colDef, colId, selectedValues } of columnsToHydrate) {\n      const cached = selectedValues.every((value) => filterValueContext(colId, value) != null);\n      if (!cached) {\n        await fetchFilterValues(colDef, { filterModel: model, useStaged: false });\n      }\n      setFilterSelectedValues(colId, selectedValues);\n    }\n\n    return filterValueSelectedMetadataMap.value;\n  };\n\n  // Search Query\n\n  const setFilterValueSearchText = (colField: string, searchText: string | null) => {\n    filterValueSearchTextMap.value[colField] = searchText;\n  };\n\n  // Filter values (centralized, replaces local filterValues in useSetFilter)\n\n  const getFilterValues = (colField: string): (string | null)[] => {\n    return filterValuesMap.value[colField] || [];\n  };\n\n  const setFilterValues = (colField: string, values: (string | null)[]) => {\n    filterValuesMap.value[colField] = values;\n  };\n\n  // Aggregate field registration\n\n  const registerAggregateField = (parent: string, children: string[]) => {\n    aggregateFieldMap.value[parent] = children;\n  };\n\n  // Filter field registration — useSetFilter instances register on mount so that\n  // markOtherFieldsStale can notify ALL filters, not just those that have fetched values.\n  // Uses ref-counting because multiple instances for the same field can be mounted\n  // concurrently (e.g., horizontal filters plus a vertical drawer copy).\n\n  const registerFilterField = (field: string) => {\n    const currentCount = registeredFilterFieldCounts.value[field] ?? 0;\n    registeredFilterFieldCounts.value[field] = currentCount + 1;\n    registeredFilterFields.value.add(field);\n  };\n\n  const unregisterFilterField = (field: string) => {\n    const currentCount = registeredFilterFieldCounts.value[field] ?? 0;\n    if (currentCount <= 1) {\n      delete registeredFilterFieldCounts.value[field];\n      registeredFilterFields.value.delete(field);\n      return;\n    }\n    registeredFilterFieldCounts.value[field] = currentCount - 1;\n  };\n\n  // Staleness\n\n  // Component-driven model writes record their logical source here. The committed-model\n  // watcher consumes the set once, so staged edits can accumulate without invalidating\n  // dependent dropdowns until the final model is applied.\n  const pendingFilterModelChangedFields = new Set<string>();\n  const stagedFilterModelChangedFields = new Set<string>();\n\n  const noteFilterModelChange = (changedFields: Set<string>, staged = false) => {\n    const target = staged ? stagedFilterModelChangedFields : pendingFilterModelChangedFields;\n    changedFields.forEach((field) => target.add(field));\n  };\n\n  const commitStagedFilterModelChanges = () => {\n    stagedFilterModelChangedFields.forEach((field) => pendingFilterModelChangedFields.add(field));\n    stagedFilterModelChangedFields.clear();\n  };\n\n  const clearStagedFilterModelChanges = () => {\n    stagedFilterModelChangedFields.clear();\n  };\n\n  const markOtherFieldsStale = (changedFields: Set<string>) => {\n    const excludeFields = new Set(changedFields);\n\n    // When the aggregate filter itself is the field being edited, its backing\n    // fields represent the same committed change and should not immediately\n    // stale themselves. When only a backing field changes, do NOT exclude the\n    // aggregate parent — its dropdown needs to refetch against the new filter\n    // model the next time it opens.\n    for (const field of changedFields) {\n      const aggregateChildren = aggregateFieldMap.value[field] || [];\n      for (const childField of aggregateChildren) {\n        excludeFields.add(childField);\n      }\n    }\n\n    // A field can already be stale from initialization or an older dependency change.\n    // Clear every field represented by this edit before notifying dependents so its own\n    // model update can never trigger a background reload of the edited dropdown.\n    for (const field of excludeFields) {\n      filterStaleMap.value[field] = false;\n    }\n\n    // Iterate over all registered filter fields, not just those in filterValuesMap\n    for (const existingField of registeredFilterFields.value) {\n      if (!excludeFields.has(existingField)) {\n        filterStaleMap.value[existingField] = true;\n      }\n    }\n  };\n\n  // Staged selected values (vertical drawer isolation)\n\n  const initStagedSelectedValues = pvFilterStore.initStagedFilterSelections;\n\n  const clearStagedSelectedValues = pvFilterStore.clearStagedFilterSelections;\n\n  const getStagedSelectedValues = (colField: string): (string | null)[] => {\n    return stagedSelectedValuesMap.value[colField] || [];\n  };\n\n  const setStagedSelectedValues = (colField: string, selectedValues: (string | null)[]) => {\n    stagedSelectedValuesMap.value[colField] = selectedValues;\n  };\n\n  // External controller hooks\n\n  const registerFilterController = (controller: PvDataTableFilterController) => {\n    filterController.value = controller;\n  };\n\n  const unregisterFilterController = (controller?: PvDataTableFilterController) => {\n    if (!controller || filterController.value === controller) {\n      filterController.value = null;\n    }\n  };\n\n  const getFilterModel = (): PvDataTableFilterModel => {\n    return filterController.value?.getFilterModel() ?? filterModel.value;\n  };\n\n  const applyFilterModel = (model: PvDataTableFilterModel) => {\n    const applied = filterController.value?.setFilterModel(model);\n    if (!filterController.value || applied === false) {\n      filterModel.value = model;\n    }\n  };\n\n  const applyTableSearchFilterModel = (model: PvDataTableFilterModel) => {\n    const applied = filterController.value?.setTableSearchFilterModel(model);\n    if (!filterController.value || applied === false) {\n      tableSearchFilterModel.value = model;\n    }\n  };\n\n  const refreshData = (params?: RefreshServerSideParams | null) => {\n    return filterController.value?.refreshData(params);\n  };\n\n  const modelEntriesByField = (model: PvDataTableFilterModel): Map<string, string[]> => {\n    const entries = new Map<string, string[]>();\n    if (!model) return entries;\n\n    if (isAdvancedFilterModel(model)) {\n      const visit = (node: AdvancedFilterModel) => {\n        if (node.filterType === \"join\") {\n          node.conditions.forEach(visit);\n          return;\n        }\n        const field = \"colId\" in node ? node.colId : undefined;\n        if (!field) return;\n        const fieldEntries = entries.get(field) ?? [];\n        fieldEntries.push(JSON.stringify(node));\n        entries.set(field, fieldEntries);\n      };\n      visit(model);\n      entries.forEach((fieldEntries) => fieldEntries.sort());\n      return entries;\n    }\n\n    Object.entries(model).forEach(([field, value]) => entries.set(field, [JSON.stringify(value)]));\n    return entries;\n  };\n\n  // Determine which real column fields changed in regular or advanced models.\n  // Advanced models store column IDs in leaf nodes, not in root object keys.\n  const trackFilterUpdates = (newVal: PvDataTableFilterModel, oldVal: PvDataTableFilterModel): Set<string> => {\n    const fieldsToUpdate = new Set<string>();\n    const newEntries = modelEntriesByField(newVal);\n    const oldEntries = modelEntriesByField(oldVal);\n    const fields = new Set([...newEntries.keys(), ...oldEntries.keys()]);\n\n    for (const field of fields) {\n      if (JSON.stringify(newEntries.get(field) ?? []) !== JSON.stringify(oldEntries.get(field) ?? [])) {\n        fieldsToUpdate.add(field);\n      }\n    }\n\n    // A changed join structure can alter semantics without changing its leaf nodes.\n    // Conservatively invalidate dependents of every represented field in that rare case.\n    if (fieldsToUpdate.size === 0 && JSON.stringify(newVal) !== JSON.stringify(oldVal)) {\n      fields.forEach((field) => fieldsToUpdate.add(field));\n    }\n\n    const currentTimestamp = Date.now();\n    for (const field of fieldsToUpdate) {\n      filterLastUpdatedMap.value[field] = currentTimestamp;\n    }\n    return fieldsToUpdate;\n  };\n\n  // Staged models are intentionally not workload triggers. One logical edit may\n  // mutate them many times; only the final committed model starts one refresh wave.\n  watchDebounced(\n    filterModel,\n    (newFilter, oldFilter) => {\n      const changedFields = trackFilterUpdates(newFilter, oldFilter);\n      pendingFilterModelChangedFields.forEach((field) => changedFields.add(field));\n      pendingFilterModelChangedFields.clear();\n      if (changedFields.size > 0) {\n        markOtherFieldsStale(changedFields);\n      }\n    },\n    {\n      deep: true,\n      debounce: 200,\n      maxWait: 1000,\n      immediate: false,\n    },\n  );\n\n  return {\n    ...pvFilterStore,\n    fetchFilterOptions: fetchPvFilterOptions,\n    hasFilterOptionsSource: isServerSideFilter,\n    filterController,\n    filterModel,\n    filterLastUpdatedMap,\n    filterLastFetchTimeMap,\n    filterModelCleared,\n    filterValuesLoadingStatus,\n    filterValueMap,\n    filterValueSelectedMetadataMap,\n    filterStoreHandler,\n    fetchFilterValues,\n    invalidateFilterRequest,\n    filterValueContext,\n    filterModelEmpty,\n    getFilterSelectedValues,\n    getSearchMatchDataFromFilterContext,\n    isServerSideFilter,\n    stagedFilterModel,\n    setFilterSelectedValues,\n    hydrateSelectedFilterMetadata,\n    setFilterValueSearchText,\n    tableSearchFilterModel,\n    tableSearchFilterModelEmpty,\n    tableSearchHandler,\n    // New: centralized filter values\n    filterValuesMap,\n    getFilterValues,\n    setFilterValues,\n    // New: staleness system\n    filterStaleMap,\n    refreshFiltersInBackground,\n    stageFilterChangesUntilDropdownCloses,\n    filterSearchMinLength,\n    markOtherFieldsStale,\n    noteFilterModelChange,\n    commitStagedFilterModelChanges,\n    clearStagedFilterModelChanges,\n    // New: aggregate field registry\n    aggregateFieldMap,\n    registerAggregateField,\n    // New: filter field registration for staleness tracking\n    registeredFilterFields,\n    registerFilterField,\n    unregisterFilterField,\n    // New: staged selected values (vertical drawer isolation)\n    stagedSelectedValuesMap,\n    initStagedSelectedValues,\n    clearStagedSelectedValues,\n    getStagedSelectedValues,\n    setStagedSelectedValues,\n    // External controller hooks\n    registerFilterController,\n    unregisterFilterController,\n    getFilterModel,\n    applyFilterModel,\n    applyTableSearchFilterModel,\n    refreshData,\n    // Existing but newly exposed\n    filterValueSearchTextMap,\n    // Response metadata\n    filterValuesHasMoreMap,\n    filterValuesTotalCountMap,\n  };\n};\n\nexport type PvDataTableFilterStore = ReturnType<typeof createFilterStore>;\n\nexport const createPvDataTableFilterStore = createFilterStore;\n\nexport const providePvDataTableFilterStore = (filterStore: PvDataTableFilterStore) => {\n  provide(FilterStoreKey, filterStore);\n};\n\n// Helper function for child components to access the injected filter store\nexport const useFilterStore = () => {\n  const filterStore = inject(FilterStoreKey, null);\n  if (!filterStore) {\n    return createFilterStore();\n  }\n  return filterStore;\n};\n\nexport const usePvDataTableFilterStore = () => {\n  const filterStore = inject(FilterStoreKey, null);\n  if (!filterStore) {\n    throw new Error(\n      \"No PvDataTable filter store was provided. Create one with createPvDataTableFilterStore() and pass it to PvDataTable/PvDataTableWithChart or provide it with providePvDataTableFilterStore().\",\n    );\n  }\n  return filterStore;\n};\n","import { ColDef, GridApi } from \"ag-grid-community\";\nimport { AdvancedFilterModel, ValueFormatterParams } from \"ag-grid-enterprise\";\nimport { computed, inject, nextTick, onMounted, onUnmounted, Ref, ref, watch } from \"vue\";\nimport { watchDebounced } from \"@vueuse/core\";\nimport { buildFilterSearchPlaceholder, formatSearchMatchSubText } from \"@/functions/filterSearchDisplay\";\nimport { useFilterStore } from \"@tables/PvDataTable/useFilterStore\";\nimport { useFocusStore } from \"@tables/PvDataTable/useFocus\";\nimport { MenuOption, MultiSelectState, SeeMoreEvent, SelectionNode } from \"@/types\";\nimport { EnableAdvancedFilterKey, FirstDataRenderedKey, GridApiKey, RowsLoadingKey } from \"@/components/tables/symbols\";\nimport {\n  colDefContext,\n  colDefMaxSelectableValues,\n  colDefValueFormatter,\n  getAggregateFields,\n  getAggregateRootField,\n  isAggregateColDef,\n  isColDefSingleSelect,\n} from \"@tables/PvDataTable/helpers\";\nimport {\n  constructAdvancedFilterCondition,\n  filterModelsEqual,\n  getSelectedValuesFromAdvancedFilterModel,\n  getSelectedValuesFromFilterModel,\n  getSetFilter,\n  mergeAdvancedFilterCondition,\n  updateColumnSetFilterModel,\n} from \"@tables/PvDataTable/filters/filterHelpers\";\nimport { FilterValueResponseOption } from \"@tables/PvDataTable/types\";\nimport { ColDefDataType } from \"@tables/PvDataTable/table-components/formatting\";\nimport {\n  buildFilterPanelAggregateModelFromSelectionState,\n  findFilterPanelAggregateOptionId,\n  getFilterPanelAggregateFieldValue,\n  seedFilterPanelAggregateSelectionState,\n} from \"@/components/base/PvFilterPanel/aggregateFilterModel\";\nimport { addRumAction, deferRumTask, useRumContext } from \"@/functions/rum\";\nimport { countFromSelectionState, filterOptionsRecursive } from \"@/components/base/PvMenu/cascadeUtils\";\n\n/**\n * Source qualifier on the `filter_option_selected` RUM action.\n *\n * - `click` — option row click in the dropdown, suggested-tag click, focus\n *   button, or any other per-value click affordance.\n * - `remove_chip` — the per-value `×` in the vertical filter drawer.\n *\n * Bulk operations (Select All / Clear All) intentionally do NOT emit\n * per-value events — they'd poison \"most desired value\" aggregations and\n * flood RUM. They emit a single `filter_bulk_action` instead (see\n * `recordBulkAction`).\n */\nexport type FilterOptionSelectionSource = \"click\" | \"remove_chip\";\n\n/** Action qualifier on the `filter_bulk_action` RUM action. */\nexport type FilterBulkActionType = \"select_all\" | \"clear_all\";\n\n/**\n * Where the interaction happened: the horizontal filter bar above the table,\n * or the vertical \"All Filters\" drawer. Lets analysts measure per-filter\n * drawer traffic (candidates for promotion out of the drawer).\n */\nexport type FilterRumLocation = \"horizontal\" | \"all_filters_drawer\";\n\nexport interface UseSetFilterOptions<T> {\n  filterColDef: Ref<ColDef<T>>;\n  filterStyle?: Ref<\"horizontal\" | \"vertical\">;\n  onSelectionChanged?: () => void;\n  // Staged filterGroup selections from FilterGroupMenu, keyed by field name.\n  // Provided by SetFilter so useSetFilter can include them in the dropdown-close commit\n  // without FilterGroupMenu needing to write to the grid itself.\n  filterGroupStagedFields?: Ref<Set<string>>;\n  readOnly?: Ref<boolean>;\n  // When true (with readOnly), unselected filters are non-interactive (e.g. public reports).\n  // Used to skip background prefetch of filter values the viewer can never open.\n  disableUnselected?: Ref<boolean>;\n}\n\ninterface UpdateFilterModelOptions {\n  skipIfUnchanged?: boolean;\n}\n\nexport const useSetFilter = <T>(options: UseSetFilterOptions<T>) => {\n  const { filterColDef, filterStyle, onSelectionChanged, filterGroupStagedFields, readOnly, disableUnselected } =\n    options;\n\n  // Host-provided RUM context (consumer tag + enabled switch). A resolver,\n  // not a snapshot: called at emit time so hosts can reconfigure at runtime.\n  const rumContext = useRumContext();\n\n  const gridApi = inject(GridApiKey, ref(null)) as Ref<GridApi<T> | null>;\n\n  const filterStore = useFilterStore();\n  const {\n    fetchFilterValues,\n    invalidateFilterRequest,\n    filterModel,\n    stagedFilterModel,\n    filterModelCleared,\n    filterValuesLoadingStatus,\n    filterValueContext,\n    getFilterSelectedValues,\n    isServerSideFilter,\n    setFilterValueSearchText,\n    setFilterSelectedValues,\n    // New centralized state\n    getFilterValues,\n    setFilterValues,\n    filterStaleMap,\n    refreshFiltersInBackground,\n    stageFilterChangesUntilDropdownCloses,\n    filterSearchMinLength: tableFilterSearchMinLength,\n    noteFilterModelChange,\n    registerAggregateField,\n    registerFilterField,\n    unregisterFilterField,\n    getStagedSelectedValues,\n    setStagedSelectedValues,\n    filterValueSearchTextMap,\n    // Response metadata\n    filterValuesHasMoreMap,\n    filterValuesTotalCountMap,\n  } = filterStore;\n\n  const { computedFocuses, removeFocus, computedFocusType } = useFocusStore();\n\n  const rowsLoading = inject(RowsLoadingKey, ref(false));\n  const firstDataRendered = inject(FirstDataRenderedKey, ref(false));\n  const enableAdvancedFilter = inject(EnableAdvancedFilterKey, ref(false));\n\n  // State — backed by the centralized filter store\n  const selectedValues = computed({\n    get: () =>\n      isInFilterPanel.value ? getStagedSelectedValues(filterField.value) : getFilterSelectedValues(filterField.value),\n    set: (val) => {\n      if (isInFilterPanel.value) {\n        setStagedSelectedValues(filterField.value, val);\n      } else {\n        setFilterSelectedValues(filterField.value, val);\n      }\n    },\n  });\n  const filterValues = computed(() => {\n    const raw = getFilterValues(filterField.value);\n    // While dropdown is open, use cached order to prevent items moving during selection\n    if (isDropdownOpen.value && cachedHoistedOrder.value.length > 0) {\n      // Filter to only include values still in raw, preserving cached order\n      const rawSet = new Set(raw);\n      const cached = cachedHoistedOrder.value.filter((v) => rawSet.has(v));\n      // Append any new values not in cache\n      const cachedSet = new Set(cachedHoistedOrder.value);\n      const newValues = raw.filter((v) => !cachedSet.has(v));\n      return [...cached, ...newValues];\n    }\n    return sortFilterValues(raw);\n  });\n  const isLoading = computed(() => filterValuesLoadingStatus.value[filterField.value] ?? false);\n  const shouldRefreshFilterInBackground = computed(\n    () => refreshFiltersInBackground.value || colDefContext(filterColDef.value).prefetchFilterValues === true,\n  );\n  // In read-only views that disable unselected filters (e.g. public reports), a filter with no\n  // selections can never be opened, so skip background prefetch of its values to avoid wasted\n  // (and, for public reports, live-data) filter-values requests.\n  //\n  // Both emptiness checks are required — they cover mutually exclusive column types, not the same\n  // thing twice: regular set filters track selection in `selectedValues` (cascadeSelectionState is\n  // always []), while aggregate/cascade filters track it in `cascadeSelectionState` (selectedValues\n  // stays [] because updateSelectedValues early-returns for aggregates). Dropping either check would\n  // wrongly skip a filter of the other type that does have selections.\n  const skipUnselectedReadOnlyFetch = computed(\n    () =>\n      (readOnly?.value ?? false) &&\n      (disableUnselected?.value ?? false) &&\n      selectedValues.value.length === 0 &&\n      cascadeSelectionState.value.length === 0,\n  );\n\n  // `hideUnselected` = show only selected options; otherwise all options show (greyed by readOnly).\n  const isReadOnly = computed(() => readOnly?.value ?? false);\n  const hideUnselected = computed(() => isReadOnly.value && (disableUnselected?.value ?? false));\n  const filterSearchText = computed({\n    get: () => filterValueSearchTextMap.value[filterField.value] ?? \"\",\n    set: (val) => setFilterValueSearchText(filterField.value, val),\n  });\n  // True when the user has typed at least one character but hasn't reached the\n  // configured minimum. Decides if we make the backend call and if we show the\n  // dropdown's \"type at least N characters\" notice. False when the input is\n  // empty (length 0) so clearing the search hides the notice and restores the\n  // unfiltered fetch.\n  const filterSearchMinLength = computed(\n    () => colDefContext(filterColDef.value).filterSearchMinLength ?? tableFilterSearchMinLength.value,\n  );\n  const belowFilterSearchMinLength = computed(() => {\n    const min = filterSearchMinLength.value ?? 0;\n    const len = filterSearchText.value?.length ?? 0;\n    return min > 0 && len > 0 && len < min;\n  });\n\n  // Computed\n  const filterField = computed(() => filterColDef.value.field || \"\");\n  const filterType = computed(() => filterColDef.value.filter || \"\");\n  const filterDisplayName = computed(() => filterColDef.value.headerName || \"\");\n\n  const isInFilterPanel = computed(() => {\n    return filterStyle?.value === \"vertical\";\n  });\n\n  // Track dropdown open state to distinguish between clear-from-button-face vs clear-from-within-dropdown\n  const isDropdownOpen = ref(false);\n  const isSeeMoreLoading = ref(false);\n  // Cache hoisted order while dropdown is open to prevent items moving during selection\n  const cachedHoistedOrder = ref<(string | null)[]>([]);\n\n  const valueFormatter = computed(() => {\n    return colDefValueFormatter(filterColDef.value);\n  });\n\n  const maxSelectableValues = computed(() => colDefMaxSelectableValues(filterColDef.value));\n  const isSingleSelect = computed(() => isColDefSingleSelect(filterColDef.value));\n  const filterOptionsSortDescription = computed(() => colDefContext(filterColDef.value).filterOptionsSortDescription);\n  const filterOptionsSortTooltip = computed(() => colDefContext(filterColDef.value).filterOptionsSortTooltip);\n  // filterSearch overrides when set. Otherwise booleans get no search box: every option\n  // is already visible, and search matches raw values while the list shows formatted labels.\n  const showSearchBar = computed(() => {\n    const explicit = colDefContext(filterColDef.value).filterSearch;\n    if (typeof explicit === \"boolean\") return explicit;\n    return colDefContext(filterColDef.value).dataType !== ColDefDataType.Boolean;\n  });\n  const emptyFilterResultsRenderer = computed(() => colDefContext(filterColDef.value).emptyFilterResultsRenderer);\n  const filterOptionsLoadingText = computed(() => colDefContext(filterColDef.value).filterOptionsLoadingText);\n  const filterOptionsRenderer = computed(() => colDefContext(filterColDef.value).filterOptionsRenderer);\n  const filterHeaderRenderer = computed(() => colDefContext(filterColDef.value).filterHeaderRenderer);\n  const filterFooterRenderer = computed(() => colDefContext(filterColDef.value).filterFooterRenderer);\n  const filterFooterPosition = computed(() => colDefContext(filterColDef.value).filterFooterPosition);\n\n  const selectionLimitReached = computed(() => {\n    if (!maxSelectableValues.value) return false;\n    return selectedValues.value.length >= maxSelectableValues.value;\n  });\n\n  const suggestedValues = computed(() => {\n    return filterValues.value.filter((value) => value != null && !selectedValues.value.includes(value));\n  });\n\n  // Read-only shows a fixed snapshot, so suppress the top-level \"See more\".\n  const totalOptionCount = computed(() =>\n    isReadOnly.value ? undefined : filterValuesTotalCountMap.value[filterField.value],\n  );\n  const hasMoreOptions = computed(() => (isReadOnly.value ? false : filterValuesHasMoreMap.value[filterField.value]));\n\n  const isAggregate = computed(() => isAggregateColDef(filterColDef.value));\n\n  // Returns the field set considered changed when this aggregate commits: the\n  // aggregate parent plus every backing field represented by the aggregate.\n  const aggregateChangedFields = (): Set<string> =>\n    new Set([filterField.value, ...getAggregateFields(filterColDef.value)]);\n\n  const selectedValueSetsEqual = (currentValues: (string | null)[], committedValues: (string | null)[]): boolean => {\n    const currentSet = new Set(currentValues);\n    const committedSet = new Set(committedValues);\n    if (currentSet.size !== committedSet.size) return false;\n    return [...currentSet].every((value) => committedSet.has(value));\n  };\n\n  // Cascade selection state for aggregate columns — tracks parent/child selection\n  // instead of a flat list of selected values\n  const cascadeSelectionState = ref<MultiSelectState>([]);\n\n  // Snapshot of cascade state at last successful commit. Used by\n  // handleCascadeSelectionState's skipIfUnchanged path to detect dropdown-close\n  // no-ops without depending on filter-model structural equality, which can\n  // diverge after rebuild even when selections are identical.\n  const lastCommittedCascadeState = ref<string>(\"[]\");\n\n  const forceCheckSelection = computed(() => {\n    return filterValues.value.length === 1 && filterValues.value[0] === null && selectedValues.value.length === 0;\n  });\n\n  // Methods\n  const updateSelectedValues = (forceUpdate: boolean = false) => {\n    // For aggregate columns, cascade selection state is the sole source of truth.\n    // Don't extract flat values from the filter model.\n    if (isAggregate.value) return;\n\n    let valuesFromFilterModel: string[] = [];\n\n    if (enableAdvancedFilter.value && gridApi.value) {\n      const advancedModel = gridApi.value.getAdvancedFilterModel();\n      valuesFromFilterModel = getSelectedValuesFromAdvancedFilterModel(filterField.value, advancedModel);\n    } else {\n      valuesFromFilterModel = getSelectedValuesFromFilterModel(filterColDef.value, filterModel.value);\n    }\n\n    if (forceUpdate) {\n      selectedValues.value = valuesFromFilterModel;\n    } else {\n      selectedValues.value = Array.from(\n        new Set([...getFilterSelectedValues(filterField.value), ...valuesFromFilterModel]),\n      );\n    }\n  };\n\n  const isValueSelectedInCascade = (value: string | null): boolean => {\n    const findNode = (nodes: SelectionNode[]): boolean => {\n      for (const node of nodes) {\n        if (node.id === String(value) && node.state === \"selected\") return true;\n        if (node.children && findNode(node.children)) return true;\n      }\n      return false;\n    };\n    return findNode(cascadeSelectionState.value);\n  };\n\n  // A fully-selected parent selects every child except those listed \"deselected\";\n  // otherwise a child is selected only if it's its own \"selected\" node.\n  const isChildEffectivelySelected = (parentId: string, childId: string): boolean => {\n    const parentNode = cascadeSelectionState.value.find((n) => n.id === String(parentId));\n    if (parentNode?.state === \"selected\") {\n      const deselected = parentNode.children?.some((c) => c.id === String(childId) && c.state === \"deselected\");\n      return !deselected;\n    }\n    return isValueSelectedInCascade(childId);\n  };\n\n  // Whether an option or any descendant is selected. `parentId` is null at top level.\n  const nodeContainsSelection = (option: MenuOption<FilterValueResponseOption>, parentId: string | null): boolean => {\n    const selfSelected =\n      parentId == null ? isValueSelectedInCascade(option.id) : isChildEffectivelySelected(parentId, option.id);\n    if (selfSelected) return true;\n    return (option.children ?? []).some((child) => nodeContainsSelection(child, option.id));\n  };\n\n  const sortFilterValues = (values: (string | null)[]) => {\n    return [...values].sort((a, b) => {\n      const aSelected = selectedValues.value.includes(a) || isValueSelectedInCascade(a);\n      const bSelected = selectedValues.value.includes(b) || isValueSelectedInCascade(b);\n      if (aSelected && !bSelected) return -1;\n      if (!aSelected && bSelected) return 1;\n      return 0;\n    });\n  };\n\n  const getLatestFilterValues = async (\n    fetchNewValues: boolean = false,\n    forceFetchValues: boolean = false,\n  ): Promise<void> => {\n    if (!gridApi.value) return;\n\n    const isStale = filterStaleMap.value[filterField.value] ?? false;\n    const notLoading = filterValuesLoadingStatus.value[filterField.value] !== true;\n    const hasNoValues = (getFilterValues(filterField.value) || []).length === 0;\n    // Also fetch if we have no cached values and new values are requested\n    const shouldRefresh = fetchNewValues && notLoading && (isStale || forceFetchValues || hasNoValues);\n\n    if (enableAdvancedFilter.value) {\n      if (isServerSideFilter.value && shouldRefresh) {\n        const results = await fetchFilterValues(filterColDef.value, {\n          api: gridApi.value,\n          filterModel: filterModel.value ?? undefined,\n          useStaged: isInFilterPanel.value,\n        });\n        setFilterValues(filterField.value, results);\n        filterStaleMap.value[filterField.value] = false;\n        reconcileCascadeSelectionStateFromMetadata();\n      }\n      return;\n    }\n\n    const filter = await getSetFilter(gridApi.value, filterColDef.value);\n    if (!filter) return;\n\n    if (isServerSideFilter.value && shouldRefresh) {\n      // refreshFilterValues triggers an async fetch via the store's fetchFilterValues,\n      // which writes results to filterValuesMap when complete. Don't overwrite with\n      // stale getFilterValues() data here.\n      filter.refreshFilterValues();\n      return;\n    }\n\n    // Client-side: read values synchronously from the ag-grid filter instance\n    setFilterValues(filterField.value, filter.getFilterValues());\n    filterStaleMap.value[filterField.value] = false;\n  };\n\n  const resolvedFilterValueContext = (input: string | null): FilterValueResponseOption | null | undefined => {\n    // get the context for the base field (for aggregate columns, the context will include info about which specific field the value is from)\n    let context = filterValueContext(filterField.value, input);\n    // For aggregate columns, raw IDs from advanced filter conditions (e.g. \"PV_1000\")\n    // do not key the provider_combined filter map (which holds full scoped tokens),\n    // so fall back to walking nested aggregate metadata for an option whose\n    // metadata.rawValue matches.\n    if (!context && isAggregate.value && input) {\n      context = findAggregateOptionByRawValue(input);\n    }\n    return context;\n  };\n\n  const getOptionField = (option?: FilterValueResponseOption | null) => option?.field ?? option?.colField;\n\n  const getOptionRawValue = (option?: FilterValueResponseOption | null): unknown => {\n    if (option?.rawValue != null) return option.rawValue;\n    if (option?.metadata?.rawValue != null) return option.metadata.rawValue;\n    return option ? parseFieldToken(option.value).value : null;\n  };\n\n  const getFormatterValue = (input: string | null, context?: FilterValueResponseOption | null) => {\n    if (context?.rawValue != null) return context.rawValue;\n    if (context?.metadata?.rawValue != null) return context.metadata.rawValue;\n    return input;\n  };\n\n  const getFormatterContext = (\n    context?: FilterValueResponseOption | null,\n    colDef?: ColDef,\n  ): FilterValueResponseOption | null | undefined => {\n    if (!context || !colDef) return context;\n    // Aggregate container options already have an authoritative API-provided\n    // label. Only synthesize a formatter label from metadata for unresolved\n    // options, or for raw ID-backed child options where formatters expect the\n    // primary display label separate from secondary metadata.\n    if (context.label && context.rawValue == null && context.metadata?.rawValue == null) return context;\n\n    const metadataDisplayFields = colDefContext(colDef).metadataDisplayFields || [];\n    const displayField = metadataDisplayFields.find((field) => context.metadata?.[field] != null);\n    if (!displayField) return context;\n    return { ...context, label: String(context.metadata?.[displayField]) };\n  };\n\n  const formatDisplayValueWithContext = (\n    input: string | null,\n    context?: FilterValueResponseOption | null,\n  ): string | null => {\n    let formatter = valueFormatter.value;\n    let formatterContext = context;\n    // if the option is for a specific field in an aggregate column, we want to use that field's formatter if it exists\n    const contextField = getOptionField(context);\n    if (contextField && isAggregate.value) {\n      const colDefForField = gridApi.value?.getColumnDef(contextField);\n      formatter = colDefForField ? (colDefValueFormatter(colDefForField) ?? formatter) : formatter;\n      formatterContext = getFormatterContext(context, colDefForField ?? undefined);\n    }\n    if (formatter) {\n      return formatter({\n        value: getFormatterValue(input, formatterContext),\n        context: formatterContext,\n      } as ValueFormatterParams);\n    }\n    return formatterContext?.label || input;\n  };\n\n  const formatDisplayValue = (input: string | null) => {\n    const context = resolvedFilterValueContext(input);\n    return formatDisplayValueWithContext(input, context);\n  };\n\n  // True when a value can't resolve to a real display name (ID→name resolution columns) and so\n  // would render as a raw id. Used to hide it from the dropdown and selected chips entirely.\n  //\n  // Two cases:\n  //  - Plain metadataDisplayFields columns: the value isn't in the store yet (label unresolved).\n  //  - Aggregate columns: ID→name resolution lives on the child-field colDef, not the aggregate\n  //    parent, and the backend falls a missing name back to the raw id — so an id-only value sits\n  //    in the store with label === its raw id. Resolve the value's own field and treat it as\n  //    unresolved when that field does name resolution but none of those metadata fields landed.\n  const isUnresolvedMetadataValue = (value: string | null, context?: FilterValueResponseOption | null) => {\n    if (value == null) return false;\n    if (isAggregate.value) {\n      const ctx = context ?? resolvedFilterValueContext(value);\n      // ID→name resolution lives on the value's own field colDef, not the aggregate parent.\n      const field = getOptionField(ctx) ?? parseFieldToken(value).field;\n      const fieldColDef = field ? gridApi.value?.getColumnDef(field) : undefined;\n      const metadataDisplayFields = colDefContext(fieldColDef).metadataDisplayFields;\n      // Fields whose id IS the display value (no name resolution) are always formattable.\n      if (!metadataDisplayFields?.length) return false;\n      if (ctx == null) return true;\n      // Resolved only when the metadata that drives the display has actually landed; otherwise\n      // the label is just the backend's raw-id fallback (an unformattable id-only value).\n      return !metadataDisplayFields.some((displayField) => ctx.metadata?.[displayField] != null);\n    }\n    const metadataDisplayFields = colDefContext(filterColDef.value).metadataDisplayFields;\n    if (!metadataDisplayFields?.length) return false;\n    const ctx = filterValueContext(filterField.value, value);\n    return ctx == null || ctx.label == null;\n  };\n\n  const disableFilterValue = (value: string | null) => {\n    if (forceCheckSelection.value) {\n      return true;\n    }\n    if (filterValueContext(filterField.value, value)?.isSelectable === false) {\n      return true;\n    }\n    if (isSingleSelect.value) {\n      return false;\n    }\n    return selectionLimitReached.value && !selectedValues.value.includes(value);\n  };\n\n  const getColDisplayNameForField = (field?: string) => {\n    if (!field) return \"\";\n    if (!gridApi.value) return field;\n    const colDef = gridApi.value.getColumnDef(field);\n    return colDef?.headerName || field;\n  };\n\n  const getSearchMatchSubText = (\n    option: FilterValueResponseOption | null | undefined,\n    fallbackSubText?: string,\n    primaryText?: string | null,\n  ): string | undefined =>\n    formatSearchMatchSubText({\n      fallbackSubText,\n      getDisplayName: getColDisplayNameForField,\n      matchedField: option?.matchedField,\n      matchedValue: option?.matchedValue ?? option?.menuOption?.searchText,\n      primaryText,\n      showPrefix: colDefContext(filterColDef.value).showSearchMatchSubTextPrefix !== false,\n    });\n\n  const filterSearchPlaceholder = computed(() =>\n    buildFilterSearchPlaceholder(filterField.value, colDefContext(filterColDef.value).queryColIds, (field) => {\n      if (field === filterField.value) return filterDisplayName.value || getColDisplayNameForField(field);\n      return getColDisplayNameForField(field);\n    }),\n  );\n\n  const parseFieldToken = (id: string): { field?: string; value: string } => {\n    if (!id.startsWith(\"__\")) return { value: id };\n    // Parse scoped tokens like __provider_id__PV_1001__health_system__Banner Health\n    // Format: __field1__value1[__field2__value2...]\n    // We want to extract the first field/value pair\n    const rest = id.slice(2);\n    const parts = rest.split(\"__\");\n    if (parts.length < 2) return { value: id };\n    // First part is the field, second part is the value\n    // For scoped child tokens, there may be additional parent scope parts which we ignore\n    return {\n      field: parts[0],\n      value: parts[1],\n    };\n  };\n\n  const rawValueForOptionId = (id: string): { field?: string; value: string } => {\n    return getFilterPanelAggregateFieldValue(id, allAggregateMetadataOptions());\n  };\n\n  const normalizeAggregateOptionIdentity = (option: FilterValueResponseOption): FilterValueResponseOption => {\n    const parsedValue = parseFieldToken(option.value);\n    const normalizedOption = { ...option };\n\n    if (!normalizedOption.field && !normalizedOption.colField && parsedValue.field) {\n      normalizedOption.field = parsedValue.field;\n    }\n\n    if (normalizedOption.rawValue == null && normalizedOption.metadata?.rawValue == null && parsedValue.field) {\n      normalizedOption.rawValue = parsedValue.value;\n    }\n\n    if (option.children?.length) {\n      normalizedOption.children = option.children.map(normalizeAggregateOptionIdentity);\n    }\n\n    return normalizedOption;\n  };\n\n  const aggregateMetadataOptions = computed(() =>\n    [\n      ...(filterStore.filterValueMap.value[filterField.value] || []),\n      ...(filterStore.filterValueSelectedMetadataMap.value[filterField.value] || []),\n    ].map((option) => (option ? normalizeAggregateOptionIdentity(option) : option)),\n  );\n\n  const allAggregateMetadataOptions = () => aggregateMetadataOptions.value;\n\n  const findAggregateOption = (\n    options: (FilterValueResponseOption | null)[],\n    predicate: (option: FilterValueResponseOption) => boolean,\n  ): FilterValueResponseOption | undefined => {\n    for (const option of options) {\n      if (!option) continue;\n      if (predicate(option)) return option;\n      const childMatch = option.children ? findAggregateOption(option.children, predicate) : undefined;\n      if (childMatch) return childMatch;\n    }\n    return undefined;\n  };\n\n  const findAggregateParentForChild = (\n    options: (FilterValueResponseOption | null)[],\n    childId: string,\n  ): FilterValueResponseOption | undefined => {\n    for (const option of options) {\n      if (!option) continue;\n      if (option.children?.some((child) => child.value === childId)) return option;\n      const nestedParent = option.children ? findAggregateParentForChild(option.children, childId) : undefined;\n      if (nestedParent) return nestedParent;\n    }\n    return undefined;\n  };\n\n  const findAggregateOptionId = (field: string, rawValue: string): string => {\n    return findFilterPanelAggregateOptionId(allAggregateMetadataOptions(), field, rawValue);\n  };\n\n  const findAggregateOptionByRawValue = (rawValue: string): FilterValueResponseOption | undefined => {\n    const matches = (option: FilterValueResponseOption | null): FilterValueResponseOption | undefined => {\n      if (!option) return undefined;\n      const optionRaw = String(getOptionRawValue(option) ?? parseFieldToken(option.value).value);\n      if (optionRaw === rawValue) return option;\n      for (const child of option.children || []) {\n        const childMatch = matches(child);\n        if (childMatch) return childMatch;\n      }\n      return undefined;\n    };\n    for (const option of allAggregateMetadataOptions()) {\n      const match = matches(option);\n      if (match) return match;\n    }\n    return undefined;\n  };\n\n  const scopedParentFromChildId = (childId: string): FilterValueResponseOption | undefined => {\n    const parts = childId.startsWith(\"__\") ? childId.slice(2).split(\"__\") : [];\n    if (parts.length < 4) return undefined;\n    const childField = parts[0];\n    const childValue = parts[1];\n    const parentField = parts[2];\n    const parentValue = parts.slice(3).join(\"__\");\n    if (!childField || !childValue || !parentField || !parentValue) return undefined;\n\n    return {\n      value: `__${parentField}__${parentValue}`,\n      label: parentValue,\n      colField: parentField,\n      children: [\n        {\n          value: childId,\n          label: childValue,\n          colField: childField,\n          metadata: { [parentField]: parentValue, rawValue: childValue },\n        },\n      ],\n      totalChildCount: 1,\n    };\n  };\n\n  const aggregateTopLevelOptionForNode = (node: SelectionNode): FilterValueResponseOption | undefined => {\n    const metadataOptions = allAggregateMetadataOptions();\n    const directOption = findAggregateOption(metadataOptions, (option) => option.value === node.id);\n    if (directOption?.children?.length) return directOption;\n\n    const parentOption = findAggregateParentForChild(metadataOptions, node.id);\n    if (parentOption) return parentOption;\n\n    if (directOption && getOptionField(directOption) === getAggregateRootField(filterColDef.value)) return directOption;\n\n    return scopedParentFromChildId(node.id) || directOption;\n  };\n\n  const persistAggregateSelectionMetadata = (state: MultiSelectState) => {\n    if (!isAggregate.value) return;\n\n    const existing = filterStore.filterValueSelectedMetadataMap.value[filterField.value] || [];\n    const selectedOptions = new Map<string, FilterValueResponseOption>();\n    for (const option of existing) {\n      if (option) selectedOptions.set(option.value, option);\n    }\n\n    for (const node of state) {\n      if (node.state !== \"selected\") continue;\n      const topLevelOption = aggregateTopLevelOptionForNode(node);\n      if (topLevelOption) selectedOptions.set(topLevelOption.value, topLevelOption);\n    }\n\n    filterStore.filterValueSelectedMetadataMap.value[filterField.value] = [...selectedOptions.values()];\n  };\n\n  const aggregateSelectedNotInList = () => {\n    const selectedTopLevelIds = new Set<string>();\n    for (const node of cascadeSelectionState.value) {\n      if (node.state !== \"selected\") continue;\n      const topLevelOption = aggregateTopLevelOptionForNode(node);\n      if (topLevelOption) selectedTopLevelIds.add(topLevelOption.value);\n    }\n    return [...selectedTopLevelIds].filter((id) => !filterValues.value.includes(id));\n  };\n\n  const mapFilterValueToMenuOption = (filterValue: string | null): MenuOption<FilterValueResponseOption> => {\n    const context = filterValueContext(filterField.value, filterValue);\n    const loadedChildCount = context?.children?.length ?? 0;\n    const hasChildren = loadedChildCount > 0 || (context?.totalChildCount ?? 0) > 0;\n    let groupLabel = filterOptionsSortDescription.value ? \"suggestions\" : null;\n    if (context?.isPreference) {\n      groupLabel = \"preferences\";\n    }\n    let subText = null;\n    const displayText = formatDisplayValue(filterValue) || \"\";\n    const searchText = context?.matchedValue;\n    if (searchText) {\n      subText = getSearchMatchSubText(context, context?.subText, displayText);\n    } else if (context?.subText) {\n      // Use response-provided subText (e.g., \"10 options\" for aggregate parents)\n      subText = context.subText;\n    } else if (getOptionField(context) && isAggregate.value && !hasChildren) {\n      // For flat aggregate child options (non-hierarchical), show the field name\n      subText = getColDisplayNameForField(getOptionField(context));\n    }\n\n    // Map children from response into MenuOption children (for cascade/hierarchical display)\n    let children: MenuOption<FilterValueResponseOption>[] | undefined;\n    let totalChildCount: number | undefined;\n    let childSeeMore: MenuOption<FilterValueResponseOption>[\"handleSeeMore\"];\n\n    if (hasChildren) {\n      const mapChildToMenuOption = (child: FilterValueResponseOption) => {\n        const childSearchText = child.matchedValue ?? child.menuOption?.searchText;\n        const childText = formatDisplayValueWithContext(child.value, child) || \"\";\n        const childSubText = getSearchMatchSubText(child, child.subText, childText);\n        return {\n          ...child.menuOption,\n          id: child.value,\n          text: childText,\n          searchText: childSearchText,\n          subText: childSubText,\n          // Filter options combine both lines in the hover tooltip (e.g. \"99213: Office visit\")\n          hoverTitle: child.menuOption?.hoverTitle ?? (childSubText ? `${childText}: ${childSubText}` : undefined),\n          subduedText: child.subduedText,\n          disabled: child.menuOption?.disabled ?? disableFilterValue(child.value),\n          context: child,\n          classList: child.menuOption?.classList ?? [\"option-label\"],\n        };\n      };\n      const loadedChildren = context!.children ?? [];\n      children = loadedChildren\n        .filter((child) => !isUnresolvedMetadataValue(child.value, child))\n        .map(mapChildToMenuOption);\n      totalChildCount =\n        context!.totalChildCount != null && loadedChildren.length >= context!.totalChildCount\n          ? children.length\n          : context!.totalChildCount;\n\n      // Provide handleSeeMore for child-level pagination when not all children are loaded.\n      // Fetches directly from the handler and returns new children without updating the\n      // store, so the dropdown doesn't re-render. The parentId is the parent option's\n      // canonical `value` (scoped token) so the store's child-merge match is exact.\n      if (context!.totalChildCount && context!.totalChildCount > loadedChildren.length && context!.value != null) {\n        const parentId = context!.value;\n        let fetchedChildCount = loadedChildren.length;\n        childSeeMore = async (event?: SeeMoreEvent): Promise<MenuOption<FilterValueResponseOption>[] | void> => {\n          if (!gridApi.value || !filterStore.filterStoreHandler.value) return;\n          const currentChildCount = Math.max(event?.offset ?? 0, fetchedChildCount);\n          const rawResponse = await filterStore.filterStoreHandler.value({\n            api: gridApi.value as GridApi,\n            colDef: filterColDef.value as ColDef,\n            field: filterField.value,\n            filterModel: filterModel.value ?? undefined,\n            query: filterSearchText.value || undefined,\n            offset: currentChildCount,\n            parentId,\n            reason: \"child-load-more\",\n          });\n          // Extract children from the hierarchical response, matching parent by exact value\n          const response = rawResponse && !Array.isArray(rawResponse) ? rawResponse.values : rawResponse;\n          const parentEntry = (response || []).find((r) => r?.value === parentId);\n          const newChildren = parentEntry?.children || [];\n          fetchedChildCount = Math.max(fetchedChildCount, currentChildCount + newChildren.length);\n          return newChildren\n            .filter((child) => !isUnresolvedMetadataValue(child.value, child))\n            .map(mapChildToMenuOption);\n        };\n      }\n    }\n\n    return {\n      ...context?.menuOption,\n      id: filterValue || \"\",\n      text: displayText,\n      searchText: searchText,\n      subduedText: context?.subduedText,\n      subText: subText || undefined,\n      // Filter options combine both lines in the hover tooltip (e.g. \"99213: Office visit\")\n      hoverTitle: context?.menuOption?.hoverTitle ?? (subText ? `${displayText}: ${subText}` : undefined),\n      groupingLabel: groupLabel || \"\",\n      // Parents with children should not be disabled (cascade selection handles them)\n      disabled: context?.menuOption?.disabled ?? (hasChildren ? false : disableFilterValue(filterValue)),\n      context: context || { value: filterValue || \"\" },\n      classList: context?.menuOption?.classList ?? [\"option-label\"],\n      children,\n      totalChildCount,\n      handleSeeMore: childSeeMore,\n    };\n  };\n\n  const baseDisplayedFilterValues = computed(() => {\n    // Aggregate columns inject missing selected top-level parents from cascade\n    // metadata, rather than injecting selected children as standalone options.\n    const selectedNotInList = isAggregate.value\n      ? aggregateSelectedNotInList()\n      : selectedValues.value.filter((v) => v != null && v !== \"\" && !filterValues.value.includes(v));\n\n    const allValues = [...selectedNotInList, ...filterValues.value];\n    const cleanedFilterValues = allValues\n      .filter((item, index) => allValues.indexOf(item) === index)\n      .filter((item) => item != null && item !== \"\")\n      // For colDefs with metadataDisplayFields (ID → name resolution), hide any\n      // value whose label hasn't resolved yet — including selected ones. The\n      // chip and the dropdown option should simply not render until the fetch\n      // populates the label (no raw-id leak, no placeholder).\n      .filter((item) => !isUnresolvedMetadataValue(item));\n\n    return cleanedFilterValues.map(mapFilterValueToMenuOption);\n  });\n\n  // Per-option read-only transform: prune unselected children (hide mode), drop the\n  // child \"See more\", and auto-expand parents whose selection is in their children.\n  const transformReadOnlyOption = (\n    option: MenuOption<FilterValueResponseOption>,\n  ): MenuOption<FilterValueResponseOption> => {\n    let children = option.children;\n    if (children?.length) {\n      children = children\n        .filter((child) => !hideUnselected.value || nodeContainsSelection(child, option.id))\n        .map((child) => transformReadOnlyOption(child));\n    }\n    const hasSelectedChild = (option.children ?? []).some((child) => nodeContainsSelection(child, option.id));\n    return {\n      ...option,\n      // Read-only options are non-interactive: disabling each one prevents selection\n      // changes while the dropdown can still be opened to inspect the current values.\n      disabled: true,\n      children,\n      totalChildCount: undefined,\n      handleSeeMore: undefined,\n      ...(hasSelectedChild ? { defaultExpanded: true } : {}),\n    };\n  };\n\n  const topLevelKeep = (option: MenuOption<FilterValueResponseOption>): boolean => {\n    if (!isAggregate.value) return selectedValues.value.includes(option.id);\n    return nodeContainsSelection(option, null);\n  };\n\n  const displayedFilterValues = computed(() => {\n    const options = baseDisplayedFilterValues.value;\n    if (!isReadOnly.value) return options;\n    return options\n      .filter((option) => !hideUnselected.value || topLevelKeep(option))\n      .map((option) => transformReadOnlyOption(option));\n  });\n\n  const selectedFilterValues = computed({\n    get: () => {\n      // Aggregate filters are driven by cascadeSelectionState. Returning flat\n      // selected values here causes PvMultiSelectButton/PvDataTable to inject\n      // selected children as top-level options on the next fetch.\n      if (isAggregate.value) return [];\n\n      // Include unresolved ID-based selections so PvMultiSelectButton's internal\n      // counter (selectedItems.length) reflects the initial filter model while\n      // metadata is still loading. The dropdown won't render them (filtered out\n      // of displayedFilterValues), and the horizontal button face only shows a\n      // numeric badge — no per-item chip labels — so no raw id leak. Vertical\n      // drawer chip list guards separately via isUnresolvedMetadataValue.\n      return selectedValues.value.map((value) => {\n        const context = filterValueContext(filterField.value, value);\n        const contextField = getOptionField(context);\n        const subText = contextField ? getColDisplayNameForField(contextField) : undefined;\n        return {\n          id: value,\n          text: formatDisplayValue(value),\n          subText: subText,\n          context: context || { value: value || \"\" },\n        } as MenuOption<FilterValueResponseOption>;\n      });\n    },\n    set: (newValues) => {\n      // For aggregates, filter model and counter state are built from\n      // cascadeSelectionState, not this flat v-model.\n      if (isAggregate.value) {\n        // When staging is enabled, normal aggregate changes are committed on dropdown close.\n        // The trigger-face clear button does not open/close the dropdown, so apply an empty\n        // cascade immediately or the grid model (and chart data) stays filtered.\n        const isClearFromButtonFace = newValues.length === 0 && !isDropdownOpen.value;\n        if (isClearFromButtonFace && stageFilterChangesUntilDropdownCloses.value && !isInFilterPanel.value) {\n          handleCascadeSelectionState([]);\n          return;\n        }\n        onSelectionChanged?.();\n        return;\n      }\n\n      // RUM: snapshot the before/after selection synchronously, then diff and\n      // emit on a deferred, error-isolated task (deferRumTask) so telemetry\n      // can never delay or break the filter flush below. Bulk flushes\n      // (Select All / Clear All) are suppressed here — recordBulkAction\n      // already emitted a single aggregate event for them, and per-value\n      // events would poison \"most desired value\" aggregations.\n      const previousSelection = selectedValues.value.slice();\n      let nextSelection = newValues.map((value) => value.id);\n      // Single-select columns can only ever hold one value. The radio UI (PvMenu) already\n      // replaces the selection, but this v-model flush is also reachable via bulk paths, so\n      // enforce here too: keep the newly added value (fall back to the last one).\n      if (isSingleSelect.value && nextSelection.length > 1) {\n        const previousIdSet = new Set<string | null>(previousSelection);\n        const added = nextSelection.filter((id) => !previousIdSet.has(id));\n        nextSelection = [added.length > 0 ? added[added.length - 1] : nextSelection[nextSelection.length - 1]];\n      }\n      const isBulkFlush = pendingBulkFlush;\n      pendingBulkFlush = false;\n      if (!isBulkFlush) {\n        deferRumTask(() => {\n          const previousIds = new Set<string | null>(previousSelection);\n          const nextIds = new Set<string | null>(nextSelection);\n          for (const id of nextIds) {\n            if (!previousIds.has(id)) emitFilterOptionSelected(id, \"select\", \"click\", nextIds.size);\n          }\n          for (const id of previousIds) {\n            if (!nextIds.has(id)) emitFilterOptionSelected(id, \"deselect\", \"click\", nextIds.size);\n          }\n        });\n      }\n\n      selectedValues.value = nextSelection;\n      // The vertical panel (isInFilterPanel) has its own Apply button — staging does not apply there.\n      // Exception: when staging is enabled but the dropdown is NOT open (e.g., clicking Clear on\n      // the button face), apply immediately since there's no dropdown-close event coming.\n      const isClearFromButtonFace = newValues.length === 0 && !isDropdownOpen.value;\n      const shouldApplyImmediately =\n        isClearFromButtonFace || !stageFilterChangesUntilDropdownCloses.value || isInFilterPanel.value;\n      if (shouldApplyImmediately) {\n        updateFilterModelWithSelectedValues();\n        computedFocuses.value.forEach((focus) => {\n          if (!selectedValues.value.includes(focus) && computedFocusType.value === filterField.value) {\n            removeFocus(focus);\n          }\n        });\n      }\n      onSelectionChanged?.();\n    },\n  });\n\n  // Group selected values by their actual field (for aggregate columns)\n  const groupValuesByField = (values: (string | null)[]): Record<string, string[]> => {\n    const grouped: Record<string, string[]> = {};\n    for (const value of values) {\n      if (value === null) continue;\n      const context = filterValueContext(filterField.value, value);\n      const field = getOptionField(context) || filterField.value;\n      if (!grouped[field]) {\n        grouped[field] = [];\n      }\n      grouped[field].push(value);\n    }\n    return grouped;\n  };\n\n  const updateFilterModelWithSelectedValues = async (\n    field?: string,\n    values?: (string | null)[] | null,\n    options?: UpdateFilterModelOptions,\n  ) => {\n    if (!gridApi.value) return;\n\n    // If specific field and values are provided, use them directly\n    if (field !== undefined && values !== undefined) {\n      const targetField = field || filterField.value;\n      const changedFields = new Set([filterField.value, targetField]);\n      const newValues = values;\n\n      if (enableAdvancedFilter.value) {\n        const newCondition = constructAdvancedFilterCondition(targetField, newValues || []);\n\n        if (isInFilterPanel.value) {\n          const existingModel = stagedFilterModel.value as AdvancedFilterModel | null;\n          const mergedModel = mergeAdvancedFilterCondition(existingModel, newCondition, targetField);\n          noteFilterModelChange(changedFields, true);\n          stagedFilterModel.value = mergedModel;\n          return;\n        }\n\n        const existingModel = gridApi.value.getAdvancedFilterModel();\n        const mergedModel = mergeAdvancedFilterCondition(existingModel, newCondition, targetField);\n        noteFilterModelChange(changedFields);\n\n        // Defer to avoid AG Grid error #252 (setAdvancedFilterModel during render cycle).\n        // Fires if the grid is still in onPageLoaded / redrawAfterModelUpdate when this runs.\n        nextTick(() => {\n          gridApi.value?.setAdvancedFilterModel(mergedModel);\n        });\n        return;\n      }\n\n      if (isInFilterPanel.value) {\n        const newColFilter = await updateColumnSetFilterModel(gridApi.value, filterColDef.value, newValues);\n        noteFilterModelChange(changedFields, true);\n        stagedFilterModel.value = {\n          ...stagedFilterModel.value,\n          [targetField]: newColFilter,\n        };\n        return;\n      }\n\n      const colFilterModel = await updateColumnSetFilterModel(gridApi.value, filterColDef.value, newValues);\n      noteFilterModelChange(changedFields);\n      gridApi.value.setColumnFilterModel(targetField, colFilterModel).then(() => {\n        if (!gridApi.value) return;\n        gridApi.value.onFilterChanged();\n      });\n      return;\n    }\n\n    // No specific field provided - group values by their actual fields\n    const valuesByField = groupValuesByField(selectedValues.value);\n    const context = colDefContext(filterColDef.value);\n\n    if (enableAdvancedFilter.value) {\n      const committedModel = isInFilterPanel.value\n        ? (stagedFilterModel.value as AdvancedFilterModel | null)\n        : gridApi.value.getAdvancedFilterModel();\n      let mergedModel = committedModel;\n      const changedGroupFields = new Set<string>();\n\n      if (isAggregate.value) {\n        // For aggregate columns: OR all field conditions together, then AND with the rest\n        const allFields = getAggregateFields(filterColDef.value);\n        const fieldConditions: AdvancedFilterModel[] = [];\n\n        // Build conditions for each field that has values\n        for (const f of allFields) {\n          const fieldValues = valuesByField[f] || [];\n          if (fieldValues.length > 0) {\n            const condition = constructAdvancedFilterCondition(f, fieldValues);\n            if (condition) {\n              fieldConditions.push(condition);\n            }\n          }\n        }\n\n        // Remove all aggregate field conditions from the existing model first\n        for (const f of allFields) {\n          mergedModel = mergeAdvancedFilterCondition(mergedModel, null, f);\n        }\n\n        // Create combined OR condition if there are any values\n        if (fieldConditions.length > 0) {\n          const combinedCondition: AdvancedFilterModel =\n            fieldConditions.length === 1\n              ? fieldConditions[0]\n              : {\n                  filterType: \"join\",\n                  type: \"OR\",\n                  conditions: fieldConditions,\n                };\n\n          // AND the combined condition with the rest of the filter\n          if (mergedModel) {\n            mergedModel = {\n              filterType: \"join\",\n              type: \"AND\",\n              conditions: [mergedModel, combinedCondition],\n            };\n          } else {\n            mergedModel = combinedCondition;\n          }\n        }\n      } else {\n        // Non-aggregate column - use the filter field directly\n        const newValues = selectedValues.value.length > 0 ? selectedValues.value : null;\n        const newCondition = constructAdvancedFilterCondition(filterField.value, newValues || []);\n        mergedModel = mergeAdvancedFilterCondition(mergedModel, newCondition, filterField.value);\n\n        // Overlay any filterGroup field intent staged by FilterGroupMenu. FilterGroupMenu\n        // no longer writes to the grid itself — we carry its selections here so the entire\n        // filter state lands in a single setAdvancedFilterModel call, avoiding the\n        // synchronous read-after-write race against AG Grid.\n        let groupChanged = false;\n        if (filterGroupStagedFields?.value) {\n          const groupFields = context.filterGroup?.fields ?? [];\n          for (const field of groupFields) {\n            const wantsActive = filterGroupStagedFields.value.has(field);\n            const committedValues = getSelectedValuesFromAdvancedFilterModel(field, mergedModel);\n            const isCommittedActive = committedValues.includes(\"true\");\n            if (wantsActive === isCommittedActive) continue;\n            groupChanged = true;\n            changedGroupFields.add(field);\n            const newGroupCondition = wantsActive ? constructAdvancedFilterCondition(field, [\"true\"]) : null;\n            mergedModel = mergeAdvancedFilterCondition(mergedModel, newGroupCondition, field);\n          }\n        }\n\n        // If neither the primary column nor any group field changed, skip the write entirely\n        // to avoid triggering unnecessary data fetches on innocent open/close.\n        const primaryColumnValues = selectedValues.value.filter((v) => v !== null);\n        const committedPrimaryValues = getSelectedValuesFromAdvancedFilterModel(filterField.value, committedModel);\n        const committedSet = new Set(committedPrimaryValues);\n        const selectedSet = new Set(primaryColumnValues);\n        const primaryChanged =\n          committedSet.size !== selectedSet.size || primaryColumnValues.some((v) => !committedSet.has(v));\n        if (!primaryChanged && !groupChanged) return;\n      }\n\n      if (options?.skipIfUnchanged && filterModelsEqual(committedModel, mergedModel)) {\n        return;\n      }\n\n      const changedFields = isAggregate.value\n        ? aggregateChangedFields()\n        : new Set([filterField.value, ...changedGroupFields]);\n      noteFilterModelChange(changedFields, isInFilterPanel.value);\n\n      if (isInFilterPanel.value) {\n        stagedFilterModel.value = mergedModel;\n      } else {\n        // Defer to avoid AG Grid error #252 (setAdvancedFilterModel during render cycle).\n        // Fires if the grid is still in onPageLoaded / redrawAfterModelUpdate when this runs.\n        const model = mergedModel;\n        nextTick(() => {\n          gridApi.value?.setAdvancedFilterModel(model);\n        });\n      }\n      return;\n    }\n\n    // Non-advanced filter - use the filter field directly\n    const newValues = selectedValues.value.length > 0 ? selectedValues.value : null;\n\n    if (options?.skipIfUnchanged) {\n      const committedValues = getSelectedValuesFromFilterModel(filterColDef.value, gridApi.value.getFilterModel());\n      if (selectedValueSetsEqual(selectedValues.value, committedValues)) {\n        return;\n      }\n    }\n\n    if (isInFilterPanel.value) {\n      const newColFilter = await updateColumnSetFilterModel(gridApi.value, filterColDef.value, newValues);\n      noteFilterModelChange(new Set([filterField.value]), true);\n      stagedFilterModel.value = {\n        ...stagedFilterModel.value,\n        [filterField.value]: newColFilter,\n      };\n      return;\n    }\n\n    const colFilterModel = await updateColumnSetFilterModel(gridApi.value, filterColDef.value, newValues);\n    noteFilterModelChange(new Set([filterField.value]));\n    gridApi.value.setColumnFilterModel(filterField.value, colFilterModel).then(() => {\n      if (!gridApi.value) return;\n      gridApi.value.onFilterChanged();\n    });\n  };\n\n  /**\n   * Where this filter instance lives, for RUM event attribution.\n   * \"all_filters_drawer\" is the vertical All Filters panel; \"horizontal\"\n   * is the filter bar above the table.\n   */\n  const rumLocation = computed<FilterRumLocation>(() => (isInFilterPanel.value ? \"all_filters_drawer\" : \"horizontal\"));\n\n  /**\n   * One-shot flag: the next selectedFilterValues v-model flush came from a\n   * bulk action (Select All / Clear All), so the setter must NOT emit\n   * per-value RUM events for it — recordBulkAction already emitted a single\n   * aggregate event. Set by recordBulkAction right before PvMultiSelectButton\n   * flushes the change through the v-model; consumed (reset) on the next\n   * setter run, and defensively cleared on dropdown close in case a flush\n   * never arrives.\n   */\n  let pendingBulkFlush = false;\n\n  /**\n   * Record a Select All / Clear All as a single `filter_bulk_action` RUM\n   * event and suppress per-value events for the flush it triggers. Called by\n   * SetFilter's `select-all` / `clear-all` listeners on PvMultiSelectButton,\n   * which pass the number of affected values.\n   */\n  const recordBulkAction = (action: FilterBulkActionType, valueCount: number) => {\n    pendingBulkFlush = true;\n    const searchQuery = filterSearchText.value || \"\";\n    deferRumTask(() => {\n      addRumAction(\n        \"filter_bulk_action\",\n        {\n          filter_name: filterDisplayName.value,\n          filter_field: filterField.value,\n          action,\n          value_count: valueCount,\n          location: rumLocation.value,\n          // Select All after a search means \"select everything matching X\" —\n          // worth distinguishing from a blanket select-all.\n          search_query: searchQuery,\n        },\n        rumContext(),\n      );\n    });\n  };\n\n  /**\n   * The technical column id a selected value belongs to. For plain filters\n   * this is just the filter's field. For aggregate columns (one dropdown\n   * spanning several backing fields, e.g. provider + health system) it's the\n   * sub-field the value resolves to — so \"Banner Health\" picked as a health\n   * system is distinguishable from \"Banner Health\" picked as a provider.\n   * Falls back to parsing the scoped token, then to the aggregate root field.\n   */\n  const rumFilterFieldForValue = (value: string | null): string => {\n    if (!isAggregate.value || value == null) return filterField.value;\n    const context = resolvedFilterValueContext(value);\n    const contextField = getOptionField(context);\n    if (contextField) return contextField;\n    return parseFieldToken(value).field ?? filterField.value;\n  };\n\n  /**\n   * Emit a `filter_option_selected` RUM custom action. No-ops when DD_RUM\n   * isn't loaded. The raw value passed to add/removeSelectedValue is treated\n   * as the stable ID (NPI / payer ID / code root / state code / etc.) — the\n   * human-readable label is computed via formatDisplayValue.\n   *\n   * Only ever called from inside a deferRumTask block: formatDisplayValue\n   * walks store metadata and must stay off the interaction's critical path.\n   */\n  const emitFilterOptionSelected = (\n    value: string | null,\n    action: \"select\" | \"deselect\",\n    source: FilterOptionSelectionSource,\n    nextSelectionCount: number,\n  ) => {\n    addRumAction(\n      \"filter_option_selected\",\n      {\n        filter_name: filterDisplayName.value,\n        filter_field: rumFilterFieldForValue(value),\n        selected_value: formatDisplayValue(value),\n        selected_value_id: value,\n        action,\n        source,\n        current_selection_count: nextSelectionCount,\n        location: rumLocation.value,\n        // Search query active at the moment of selection (empty string when\n        // the user picked from the unfiltered list). Lets analysts answer\n        // \"users searched for X then picked Y.\"\n        search_query: filterSearchText.value || \"\",\n      },\n      rumContext(),\n    );\n  };\n\n  /**\n   * Compact view of a cascade selection state for RUM diffing: which node\n   * ids are selected (parents or standalone leaves), and which child ids are\n   * explicitly deselected under a selected parent (child id → parent id).\n   */\n  const snapshotCascadeSelection = (state: MultiSelectState) => {\n    const selected = new Set<string>();\n    const deselectedChildren = new Map<string, string>();\n    for (const node of state) {\n      if (node.state === \"selected\") selected.add(node.id);\n      for (const child of node.children ?? []) {\n        if (child.state === \"deselected\") deselectedChildren.set(child.id, node.id);\n      }\n    }\n    return { selected, deselectedChildren };\n  };\n\n  /**\n   * Emit `filter_option_selected` events for a user-driven cascade selection\n   * change (aggregate dropdown clicks). Snapshots are taken synchronously;\n   * the diff and emission run deferred and error-isolated.\n   *\n   * Emission is per node the user acted on, not per affected leaf: selecting\n   * a parent (\"Banner Health\" health system) is ONE select event for the\n   * parent — its sub-field comes out via filter_field — and un-ticking one\n   * of its children is one deselect for that child. This keeps the events\n   * 1:1 with clicks and avoids re-creating the bulk-skew problem through\n   * parent selection.\n   */\n  const recordCascadeSelectionDiff = (previousState: MultiSelectState, nextState: MultiSelectState) => {\n    const previous = snapshotCascadeSelection(previousState);\n    const next = snapshotCascadeSelection(nextState);\n    deferRumTask(() => {\n      const nextCount = countFromSelectionState(nextState);\n      for (const id of next.selected) {\n        if (!previous.selected.has(id)) emitFilterOptionSelected(id, \"select\", \"click\", nextCount);\n      }\n      for (const id of previous.selected) {\n        if (!next.selected.has(id)) emitFilterOptionSelected(id, \"deselect\", \"click\", nextCount);\n      }\n      for (const [childId] of next.deselectedChildren) {\n        if (!previous.deselectedChildren.has(childId)) {\n          emitFilterOptionSelected(childId, \"deselect\", \"click\", nextCount);\n        }\n      }\n      // A child exclusion disappearing only counts as a re-select if its\n      // parent is still selected — if the whole parent was deselected, the\n      // exclusions vanish with it and the parent's deselect event covers it.\n      for (const [childId, parentId] of previous.deselectedChildren) {\n        if (!next.deselectedChildren.has(childId) && next.selected.has(parentId)) {\n          emitFilterOptionSelected(childId, \"select\", \"click\", nextCount);\n        }\n      }\n    });\n  };\n\n  /**\n   * RUM-instrumented v-model boundary for cascadeSelectionState. SetFilter\n   * binds `v-model:selectionState` to THIS computed so aggregate dropdown\n   * interactions (which flow through PvMultiSelectButton's selectionState\n   * model, not the flat selectedFilterValues v-model) emit selection events.\n   * Internal/programmatic writes (seeding from the filter model, clear-all\n   * from the grid, add/removeSelectedValue mirroring) go to the raw\n   * `cascadeSelectionState` ref directly and are intentionally silent.\n   *\n   * Consumes the pendingBulkFlush flag only for aggregates: PvMultiSelect-\n   * Button writes the flat v-model first, whose setter early-returns for\n   * aggregates without touching the flag; for non-aggregates the flat setter\n   * already consumed it and this setter just forwards.\n   */\n  const cascadeSelectionStateModel = computed<MultiSelectState>({\n    get: () => cascadeSelectionState.value,\n    set: (nextState) => {\n      if (isAggregate.value) {\n        const isBulkFlush = pendingBulkFlush;\n        pendingBulkFlush = false;\n        if (!isBulkFlush) {\n          recordCascadeSelectionDiff(cascadeSelectionState.value, nextState);\n        }\n      }\n      cascadeSelectionState.value = nextState;\n    },\n  });\n\n  /**\n   * Add a value to this filter's selection.\n   *\n   * Externally called from SetFilter for paths that bypass the dropdown's\n   * v-model: the focus-action button, the suggested-entry tags, and any\n   * future programmatic selection. The dropdown's option-row clicks and\n   * Select All do NOT call this — they flow through `selectedFilterValues`'s\n   * v-model setter (see ~line 710).\n   *\n   * The function does five things in order:\n   *   1. Update `selectedValues` — replacing existing values in single-select\n   *      mode, appending in multi-select.\n   *   2. Emit `filter_option_selected` RUM events: a `select` for the new\n   *      value, plus `deselect` events for any value that got replaced in\n   *      single-select mode.\n   *   3. Mirror the change into `cascadeSelectionState` for aggregate\n   *      columns (multi-field filters where the option id is a scoped token).\n   *   4. Apply the change to the underlying grid filter model immediately —\n   *      unless `stageFilterChangesUntilDropdownCloses` is on (which defers\n   *      the write until the dropdown closes) and we're in the horizontal\n   *      layout. The vertical filter panel has its own Apply button, so it\n   *      always commits immediately to the staged model.\n   *   5. Notify the consumer via the optional onSelectionChanged callback.\n   *\n   * @param value     The value to add. May be a raw value or, for aggregate\n   *                  columns, a scoped token like\n   *                  `\"__provider_id__PV_1001__health_system__Banner Health\"`.\n   *                  null values are tolerated (no-op for selection state)\n   *                  but RUM events are skipped.\n   * @param field     For aggregate columns, the sub-field this value belongs\n   *                  to (e.g. \"provider_id\"). Omit for non-aggregate columns.\n   * @param source    Tags the emitted RUM event so analysts can distinguish\n   *                  intentional clicks from bulk operations like select_all.\n   *                  Defaults to \"click\".\n   */\n  const addSelectedValue = (value: string | null, field?: string, source: FilterOptionSelectionSource = \"click\") => {\n    // Resolve the aggregate-scoped token up front — both the already-selected check and the\n    // cascade mirror (step 3) key cascade state by it. Callers may pass either a raw value\n    // (e.g. \"PV_1001\") or an already-scoped token\n    // (e.g. \"__provider_id__PV_1001__health_system__Banner Health\"). findAggregateOptionId only\n    // matches raw values, so scoped tokens would bounce off it and produce a corrupted\n    // \"__field__<scopedToken>\" id. null for non-aggregate columns.\n    let aggregateScopedId: string | null = null;\n    if (isAggregate.value && value) {\n      const targetField = field || getAggregateFields(filterColDef.value)[0] || filterField.value;\n      aggregateScopedId = value.startsWith(\"__\") ? value : findAggregateOptionId(targetField, value) || value;\n    }\n\n    // Aggregate columns track selection in cascadeSelectionState, not selectedValues (the flat\n    // v-model early-returns for them), so a flat-only check would treat every aggregate value as\n    // new — re-emitting a RUM select for options the user already ticked in the dropdown (e.g.\n    // clicking \"Select as focus\" on an already-selected provider). Explicit cascade nodes are\n    // checked here; a child only implicitly selected via its selected parent is still treated as\n    // new, since cascade state records exceptions rather than materializing every child.\n    const alreadySelected =\n      value != null &&\n      (selectedValues.value.includes(value) ||\n        (aggregateScopedId != null && isValueSelectedInCascade(aggregateScopedId)));\n    const previouslySelected = selectedValues.value.slice();\n\n    // Step 1: update the selectedValues array.\n    if (value && isSingleSelect.value) {\n      // Single-select replaces the entire array.\n      selectedValues.value = [value];\n    } else if (value && !alreadySelected) {\n      // Multi-select appends, but only if not already selected.\n      selectedValues.value = [...selectedValues.value, value];\n    }\n\n    // Step 2: emit RUM events for the change, deferred and error-isolated so\n    // telemetry can never affect steps 3–5. If we're in single-select mode\n    // and the new value replaced existing ones, emit a deselect for each old\n    // value first so analysts can correlate add/remove pairs.\n    if (value != null && !alreadySelected) {\n      const nextCount = selectedValues.value.length;\n      const replacedSingleSelect = isSingleSelect.value;\n      deferRumTask(() => {\n        if (replacedSingleSelect) {\n          for (const prior of previouslySelected) {\n            if (prior !== value) emitFilterOptionSelected(prior, \"deselect\", source, nextCount);\n          }\n        }\n        emitFilterOptionSelected(value, \"select\", source, nextCount);\n      });\n    }\n\n    // Step 3: For aggregate columns, mirror the change into cascade state\n    // (the dropdown-close commit reads cascadeSelectionState to build the\n    // grid's multi-field filter model).\n    if (aggregateScopedId != null) {\n      const existingNode = cascadeSelectionState.value.find((n) => n.id === aggregateScopedId);\n      if (!existingNode) {\n        cascadeSelectionState.value = [...cascadeSelectionState.value, { id: aggregateScopedId, state: \"selected\" }];\n      }\n    }\n\n    // Step 4: apply to the grid filter model immediately, unless we're\n    // staging changes for the horizontal dropdown (in which case the\n    // commit happens on dropdown close). The vertical panel always\n    // commits to the staged model immediately because it has its own\n    // Apply button.\n    if (!stageFilterChangesUntilDropdownCloses.value || isInFilterPanel.value) {\n      if (isAggregate.value && value) {\n        // Aggregates rebuild the whole filter model from cascade state.\n        handleCascadeSelectionState(cascadeSelectionState.value);\n      } else if (field && field !== filterField.value) {\n        // Aggregate column writing into a specific sub-field.\n        updateFilterModelWithSelectedValues(field, [value]);\n      } else {\n        // Plain set filter.\n        updateFilterModelWithSelectedValues();\n      }\n    }\n\n    // Step 5: let SetFilter mark the panel as dirty (drives the Apply\n    // button's enabled state in the vertical drawer).\n    onSelectionChanged?.();\n  };\n\n  /**\n   * Remove a value from this filter's selection.\n   *\n   * Externally called from SetFilter for paths that bypass the dropdown's\n   * v-model: the per-value `×` chip remove in the vertical drawer (source\n   * \"remove_chip\"), and the focus button when unfocusing. The dropdown's\n   * option-row click and Clear All do NOT call this — they flow through\n   * the v-model setter (see ~line 710).\n   *\n   * Mirrors `addSelectedValue`'s five-step structure: update selection,\n   * emit RUM, mirror cascade state, apply filter model (respecting\n   * staging), notify consumer.\n   *\n   * @param value     The value to remove. Same encoding rules as\n   *                  addSelectedValue. No-op if not currently selected.\n   * @param field     For aggregate columns, the sub-field this value\n   *                  belongs to. Omit for non-aggregate columns.\n   * @param source    Tags the emitted RUM event. Defaults to \"click\";\n   *                  SetFilter passes \"remove_chip\" for the per-value `×`\n   *                  affordance in the vertical drawer.\n   */\n  const removeSelectedValue = (value: string | null, field?: string, source: FilterOptionSelectionSource = \"click\") => {\n    const wasSelected = selectedValues.value.includes(value as string);\n\n    // Step 1: drop the value from the selection.\n    selectedValues.value = selectedValues.value.filter((v) => v !== value);\n\n    // Step 2: emit a deselect RUM event (deferred + error-isolated) if the\n    // value was actually selected (guards against a stale chip click after\n    // the value was already removed by another path).\n    if (value != null && wasSelected) {\n      const nextCount = selectedValues.value.length;\n      deferRumTask(() => {\n        emitFilterOptionSelected(value, \"deselect\", source, nextCount);\n      });\n    }\n\n    // Step 3: for aggregate columns, drop the corresponding cascade node.\n    if (isAggregate.value && value) {\n      const targetField = field || getAggregateFields(filterColDef.value)[0] || filterField.value;\n      const scopedId = value.startsWith(\"__\") ? value : findAggregateOptionId(targetField, value) || value;\n      cascadeSelectionState.value = cascadeSelectionState.value.filter((n) => n.id !== scopedId);\n    }\n\n    // The vertical panel (isInFilterPanel) has its own Apply button — staging does not apply there.\n    if (!stageFilterChangesUntilDropdownCloses.value || isInFilterPanel.value) {\n      // For aggregate columns, rebuild filter model from cascade state\n      if (isAggregate.value && value) {\n        handleCascadeSelectionState(cascadeSelectionState.value);\n      } else if (field && field !== filterField.value) {\n        // For aggregate columns, update the specific field's filter model\n        updateFilterModelWithSelectedValues(field, null);\n      } else {\n        updateFilterModelWithSelectedValues();\n      }\n    }\n    onSelectionChanged?.();\n  };\n\n  const handleDropdownOpen = () => {\n    // Cache the current sorted order so items don't move while selecting\n    const raw = getFilterValues(filterField.value);\n    cachedHoistedOrder.value = sortFilterValues(raw);\n    isDropdownOpen.value = true;\n  };\n\n  const handleDropdownClosed = () => {\n    isDropdownOpen.value = false;\n    cachedHoistedOrder.value = [];\n    filterSearchText.value = \"\";\n    // Defensive reset: if a bulk action somehow never flushed through the\n    // v-model, don't let the stale flag suppress the next legitimate flush.\n    pendingBulkFlush = false;\n    if (readOnly?.value) return;\n    // When stageFilterChangesUntilDropdownCloses is true, selections were buffered —\n    // apply them to the grid now that the filter is closing.\n    if (stageFilterChangesUntilDropdownCloses.value && !isInFilterPanel.value) {\n      // cascadeSelectionState stays current even while buffering — the cascade watcher\n      // was suppressed but the ref itself is still updated by PvMultiSelectButton's binding.\n      if (isAggregate.value) {\n        handleCascadeSelectionState(cascadeSelectionState.value, { skipIfUnchanged: true });\n      } else {\n        updateFilterModelWithSelectedValues(undefined, undefined, { skipIfUnchanged: true });\n      }\n    }\n  };\n\n  const handleSeeMore = async (event: SeeMoreEvent) => {\n    if (!gridApi.value) return;\n    // Load more values by fetching with offset = current options count\n    const currentCount = filterValues.value.length;\n    const isTopLevelAppend = !event.parentId;\n    if (isTopLevelAppend) {\n      isSeeMoreLoading.value = true;\n    }\n    try {\n      await fetchFilterValues(filterColDef.value, {\n        api: gridApi.value,\n        filterModel: filterModel.value ?? undefined,\n        offset: event.offset ?? currentCount,\n        parentId: event.parentId,\n        useStaged: isInFilterPanel.value,\n      });\n    } finally {\n      if (isTopLevelAppend) {\n        isSeeMoreLoading.value = false;\n      }\n    }\n  };\n\n  const buildAggregateModelFromCascadeState = (\n    state: MultiSelectState,\n    baseModel: AdvancedFilterModel | null,\n  ): AdvancedFilterModel | null => {\n    return buildFilterPanelAggregateModelFromSelectionState({\n      baseModel,\n      colDef: filterColDef.value,\n      options: allAggregateMetadataOptions(),\n      state,\n    });\n  };\n\n  /**\n   * Handle cascade selection state changes for aggregate columns.\n   * Builds an advanced filter model that preserves explicit parent/child intent:\n   * selected parents become parent-field equals conditions; individually selected\n   * children become child-field equals conditions; deselected children under a\n   * selected parent become child-field notEqual exclusions within that parent branch.\n   */\n  const handleCascadeSelectionState = (state: MultiSelectState, options?: { skipIfUnchanged?: boolean }): boolean => {\n    if (!gridApi.value || !isAggregate.value) return false;\n\n    // Compare cascade state (source of truth for aggregate selection) against\n    // the last committed snapshot. Filter-model structural equality is unreliable\n    // here because buildAggregateModelFromCascadeState rebuilds nodes and join\n    // wrappers each call, so semantically-equal models can serialize differently.\n    const serializedState = JSON.stringify(state);\n    if (options?.skipIfUnchanged && serializedState === lastCommittedCascadeState.value) {\n      cascadeSelectionState.value = state;\n      return false;\n    }\n\n    cascadeSelectionState.value = state;\n    persistAggregateSelectionMetadata(state);\n\n    const aggregateFields = getAggregateFields(filterColDef.value);\n    if (aggregateFields.length === 0) return false;\n\n    const committedModel = isInFilterPanel.value\n      ? (stagedFilterModel.value as AdvancedFilterModel | null)\n      : gridApi.value.getAdvancedFilterModel();\n    const mergedModel = buildAggregateModelFromCascadeState(state, committedModel);\n\n    if (options?.skipIfUnchanged && filterModelsEqual(committedModel, mergedModel)) {\n      lastCommittedCascadeState.value = serializedState;\n      return false;\n    }\n\n    if (isInFilterPanel.value) {\n      stagedFilterModel.value = mergedModel;\n    } else {\n      const model = mergedModel;\n      nextTick(() => {\n        gridApi.value?.setAdvancedFilterModel(model);\n      });\n    }\n\n    lastCommittedCascadeState.value = serializedState;\n    noteFilterModelChange(aggregateChangedFields(), isInFilterPanel.value);\n    onSelectionChanged?.();\n    return true;\n  };\n\n  const seedCascadeSelectionStateFromAdvancedModel = (model: AdvancedFilterModel | null | undefined) => {\n    if (!isAggregate.value) return;\n    const aggregateFields = getAggregateFields(filterColDef.value);\n    if (!aggregateFields.length) return;\n\n    const nextState = seedFilterPanelAggregateSelectionState({\n      colDef: filterColDef.value,\n      model,\n      options: allAggregateMetadataOptions(),\n    });\n    const nextSerialized = JSON.stringify(nextState);\n    if (JSON.stringify(cascadeSelectionState.value) !== nextSerialized) {\n      cascadeSelectionState.value = nextState;\n    }\n    lastCommittedCascadeState.value = nextSerialized;\n    persistAggregateSelectionMetadata(nextState);\n  };\n\n  const hasUncanonicalAggregateSelectionState = () => {\n    if (!isAggregate.value) return false;\n    return cascadeSelectionState.value.some((node) => {\n      const { field, value } = rawValueForOptionId(node.id);\n      if (!field) return false;\n      return findAggregateOptionId(field, value) !== node.id;\n    });\n  };\n\n  const reconcileCascadeSelectionStateFromMetadata = () => {\n    if (!isAggregate.value || !enableAdvancedFilter.value) return;\n    if (!hasUncanonicalAggregateSelectionState()) return;\n    seedCascadeSelectionStateFromAdvancedModel(filterModel.value as AdvancedFilterModel | null);\n  };\n\n  // Watchers\n\n  // Cascade selection state watcher: when the selection state changes for aggregate columns,\n  // build the advanced filter model from the parent/child selection state\n  watch(\n    cascadeSelectionState,\n    (state) => {\n      if (!isAggregate.value) return;\n      persistAggregateSelectionMetadata(state);\n      // When stageFilterChangesUntilDropdownCloses is true, defer until the dropdown closes.\n      // isInFilterPanel bypasses this: the vertical panel has its own Apply button.\n      if (stageFilterChangesUntilDropdownCloses.value && !isInFilterPanel.value) return;\n      handleCascadeSelectionState(state);\n    },\n    { deep: true },\n  );\n\n  // Staleness watcher: fetch eagerly on stale when table-level background refresh\n  // is enabled or the column opts into prefetching filter values.\n  watch(\n    () => filterStaleMap.value[filterField.value],\n    (isStale) => {\n      if (!isStale || isDropdownOpen.value) return;\n      if (skipUnselectedReadOnlyFetch.value) return;\n      if (shouldRefreshFilterInBackground.value) {\n        getLatestFilterValues(true);\n      }\n    },\n  );\n\n  watch(\n    () => stagedFilterModel.value,\n    () => {\n      if (!isInFilterPanel.value) return;\n\n      if (enableAdvancedFilter.value) {\n        let valuesFromModel: string[] = [];\n        const stagedAdvModel = stagedFilterModel.value as AdvancedFilterModel | null;\n\n        if (isAggregate.value) {\n          // For aggregate columns, get selected values from all aggregate fields\n          const aggregateFields = getAggregateFields(filterColDef.value);\n          for (const field of aggregateFields) {\n            const fieldValues = getSelectedValuesFromAdvancedFilterModel(field, stagedAdvModel);\n            valuesFromModel.push(...fieldValues);\n          }\n        } else {\n          valuesFromModel = getSelectedValuesFromAdvancedFilterModel(filterField.value, stagedAdvModel);\n        }\n\n        selectedValues.value = valuesFromModel;\n        return;\n      }\n\n      // Regular filter model handling\n      if (filterType.value === \"agSetColumnFilter\") {\n        const stagedRegularModel = stagedFilterModel.value as Record<string, { values?: string[] }> | null;\n        selectedValues.value = stagedRegularModel?.[filterField.value]?.values || [];\n      } else if (filterType.value === \"agMultiColumnFilter\") {\n        const stagedRegularModel = stagedFilterModel.value as Record<\n          string,\n          { filterModels?: Array<{ filterType?: string; values?: string[] }> }\n        > | null;\n        const setFilter = stagedRegularModel?.[filterField.value]?.filterModels?.find(\n          (m) => m && m.filterType === \"set\",\n        );\n        selectedValues.value = setFilter?.values || [];\n      } else {\n        console.error(`Staged filter model update for filter type ${filterType.value} is not yet supported.`);\n      }\n    },\n  );\n\n  watch(\n    () => filterModel.value,\n    () => {\n      if (isInFilterPanel.value) return;\n      // Aggregate columns track selection via cascadeSelectionState, not a flat list.\n      if (isAggregate.value) {\n        if (enableAdvancedFilter.value) {\n          seedCascadeSelectionStateFromAdvancedModel(filterModel.value as AdvancedFilterModel | null);\n        }\n        return;\n      }\n\n      if (enableAdvancedFilter.value) {\n        const advModel = filterModel.value as AdvancedFilterModel | null;\n        const valuesFromFilterModel = getSelectedValuesFromAdvancedFilterModel(filterField.value, advModel);\n        const hasExternalRemoval = selectedValues.value.some((v) => v !== null && !valuesFromFilterModel.includes(v));\n        updateSelectedValues(hasExternalRemoval);\n        return;\n      }\n\n      // Regular filter model handling\n      const valuesFromFilterModel = getSelectedValuesFromFilterModel(filterColDef.value, filterModel.value);\n      const hasExternalRemoval = selectedValues.value.some((v) => !valuesFromFilterModel.includes(v));\n      updateSelectedValues(hasExternalRemoval);\n    },\n    { deep: true },\n  );\n\n  watch(\n    () => filterModelCleared.value,\n    () => {\n      selectedValues.value = [];\n      cascadeSelectionState.value = [];\n      lastCommittedCascadeState.value = \"[]\";\n    },\n  );\n\n  // Mark filters stale as soon as gridApi is available so they can be fetched\n  // on-demand (dropdown open) without waiting for grid rows to render.\n  watch(\n    () => gridApi.value,\n    (api) => {\n      if (api && isServerSideFilter.value && !isDropdownOpen.value) {\n        filterStaleMap.value[filterField.value] = true;\n      }\n    },\n    { immediate: true },\n  );\n\n  watch(\n    () => firstDataRendered.value,\n    async () => {\n      if (shouldRefreshFilterInBackground.value && !skipUnselectedReadOnlyFetch.value && !isDropdownOpen.value) {\n        // Eager: fetch immediately (current behavior)\n        if (!isInFilterPanel.value) {\n          await getLatestFilterValues(true);\n        } else {\n          setTimeout(async () => {\n            if (!isDropdownOpen.value) {\n              await getLatestFilterValues(true);\n            }\n          }, 2000);\n        }\n      }\n      updateSelectedValues();\n    },\n  );\n\n  watchDebounced(\n    () => filterSearchText.value,\n    async () => {\n      // Closing the dropdown clears its search text. Do not turn that cleanup\n      // into a forced reload of the dropdown that just finished editing.\n      if (!isDropdownOpen.value) return;\n      if (belowFilterSearchMinLength.value) {\n        // Invalidate any in-flight fetch from a prior above-min-length query so its\n        // response doesn't land in the cache while we're below the threshold.\n        invalidateFilterRequest(filterField.value);\n        return;\n      }\n      await getLatestFilterValues(true, true);\n    },\n    { debounce: 300 },\n  );\n\n  /**\n   * Number of options the user actually sees for a search query. Mirrors\n   * PvMultiSelectButton's `filteredOptions` narrowing: the dropdown always\n   * applies this client-side text match to `displayedFilterValues`, whether\n   * the options came from a server-side query fetch or a client-side list.\n   * `result_count: 0` in RUM is the \"users want values we don't have\" signal.\n   */\n  const searchResultCount = (query: string): number => {\n    const searchValue = query.toLocaleLowerCase();\n    const options = displayedFilterValues.value;\n    if (isAggregate.value) {\n      return filterOptionsRecursive(options, searchValue, true).length;\n    }\n    return options.filter(\n      (option) =>\n        option.text.toLocaleLowerCase().includes(searchValue) ||\n        option.searchText?.toLocaleLowerCase().includes(searchValue),\n    ).length;\n  };\n\n  const emitFilterSearch = (query: string) => {\n    deferRumTask(() => {\n      addRumAction(\n        \"filter_search\",\n        {\n          filter_name: filterDisplayName.value,\n          filter_field: filterField.value,\n          query,\n          result_count: searchResultCount(query),\n          location: rumLocation.value,\n        },\n        rumContext(),\n      );\n    });\n  };\n\n  /**\n   * Query waiting on an in-flight option fetch before its `filter_search`\n   * RUM event can report an accurate result_count. Consumed by the isLoading\n   * watcher below; discarded if the search text changes in the meantime.\n   */\n  let pendingSearchQuery: string | null = null;\n\n  // Debounced `filter_search` RUM custom action. Fires once the user has\n  // stopped typing for 500ms, with the settled query and the number of\n  // options they saw. Skips empty queries (a typing → backspace round trip\n  // shouldn't show up as a search event) and queries below\n  // filterSearchMinLength (the user sees a \"type N or more characters\"\n  // notice, not results — it's an incomplete keystroke, not a search). If\n  // the server-side value fetch is still in flight, the emit is parked until\n  // loading settles so result_count reflects what actually rendered.\n  watchDebounced(\n    () => filterSearchText.value,\n    (query) => {\n      if (!query || filterSearchText.value !== query || belowFilterSearchMinLength.value) {\n        pendingSearchQuery = null;\n        return;\n      }\n      if (isLoading.value) {\n        pendingSearchQuery = query;\n        return;\n      }\n      emitFilterSearch(query);\n    },\n    { debounce: 500 },\n  );\n\n  watch(\n    () => isLoading.value,\n    (loading) => {\n      if (loading || pendingSearchQuery == null) return;\n      const query = pendingSearchQuery;\n      pendingSearchQuery = null;\n      // Only emit if the user hasn't typed something else while loading.\n      if (filterSearchText.value === query) emitFilterSearch(query);\n    },\n  );\n\n  onMounted(() => {\n    // Register this filter field so markOtherFieldsStale can notify it\n    registerFilterField(filterField.value);\n\n    // Register aggregate field mappings for staleness exclusion\n    const aggregateFields = getAggregateFields(filterColDef.value);\n    if (aggregateFields.length) {\n      registerAggregateField(filterField.value, aggregateFields);\n    }\n\n    updateSelectedValues();\n    if (isAggregate.value && enableAdvancedFilter.value) {\n      seedCascadeSelectionStateFromAdvancedModel(filterModel.value as AdvancedFilterModel | null);\n    }\n\n    // Read-only filters skip the dropdown's full fetch, but selected-value labels\n    // still need to resolve or chips/buttons render raw IDs. Only columns with\n    // metadataDisplayFields or aggregate columns need this — plain string-valued\n    // filters render the raw value as the display. The handler decides what to\n    // fetch (it has the filterModel and selectedValues to introspect).\n    if (readOnly?.value && isServerSideFilter.value && gridApi.value) {\n      const needsMetadata =\n        isAggregate.value || (colDefContext(filterColDef.value).metadataDisplayFields?.length ?? 0) > 0;\n      const hasSelected =\n        isAggregate.value && enableAdvancedFilter.value\n          ? getAggregateFields(filterColDef.value).some(\n              (f) =>\n                getSelectedValuesFromAdvancedFilterModel(f, filterModel.value as AdvancedFilterModel | null).length > 0,\n            )\n          : selectedValues.value.length > 0;\n      if (needsMetadata && hasSelected) {\n        fetchFilterValues(filterColDef.value, {\n          api: gridApi.value,\n          filterModel: filterModel.value ?? undefined,\n        });\n      }\n    }\n\n    // For non-aggregate ID columns (metadataDisplayFields configured), if the\n    // initial filter model includes selected ids whose labels haven't resolved\n    // yet, eager-fetch the filter values once so the store populates their\n    // labels. Without this, selectedFilterValues stays empty (because unresolved\n    // ids are filtered out of the chips), and PvMultiSelectButton's counter\n    // badge never renders until the user manually opens the dropdown.\n    if (!isAggregate.value) {\n      const metadataDisplayFields = colDefContext(filterColDef.value).metadataDisplayFields;\n      if (metadataDisplayFields?.length && selectedValues.value.some((v) => isUnresolvedMetadataValue(v))) {\n        getLatestFilterValues(true, true);\n      }\n    }\n  });\n\n  // Flush staged selections if the component unmounts while a filter dropdown is open\n  // (e.g., the user navigates away mid-selection). Without this, buffered changes would\n  // be silently dropped. gridApi null-guards inside both methods handle a torn-down grid.\n  onUnmounted(() => {\n    // Unregister this filter field from staleness tracking\n    unregisterFilterField(filterField.value);\n\n    if (stageFilterChangesUntilDropdownCloses.value && !isInFilterPanel.value) {\n      if (isAggregate.value) {\n        handleCascadeSelectionState(cascadeSelectionState.value, { skipIfUnchanged: true });\n      } else {\n        updateFilterModelWithSelectedValues(undefined, undefined, { skipIfUnchanged: true });\n      }\n    }\n  });\n\n  return {\n    // State\n    selectedValues,\n    filterValues,\n    isLoading,\n    isSeeMoreLoading,\n    filterSearchText,\n    filterSearchMinLength,\n    belowFilterSearchMinLength,\n    rowsLoading,\n    gridApi,\n\n    // Computed\n    filterField,\n    filterType,\n    filterDisplayName,\n    isInFilterPanel,\n    maxSelectableValues,\n    isSingleSelect,\n    selectionLimitReached,\n    suggestedValues,\n    displayedFilterValues,\n    selectedFilterValues,\n    showSearchBar,\n    filterSearchPlaceholder,\n    emptyFilterResultsRenderer,\n    filterOptionsLoadingText,\n    filterOptionsRenderer,\n    filterHeaderRenderer,\n    filterFooterRenderer,\n    filterFooterPosition,\n    filterOptionsSortDescription,\n    filterOptionsSortTooltip,\n    totalOptionCount,\n    hasMoreOptions,\n    isAggregate,\n    cascadeSelectionState,\n    cascadeSelectionStateModel,\n\n    // Methods\n    filterValueContext,\n    formatDisplayValue,\n    resolvedFilterValueContext,\n    isUnresolvedMetadataValue,\n    getLatestFilterValues,\n    addSelectedValue,\n    removeSelectedValue,\n    recordBulkAction,\n    rumLocation,\n    handleDropdownOpen,\n    handleDropdownClosed,\n    handleSeeMore,\n    handleCascadeSelectionState,\n    getColDisplayNameForField,\n    disableFilterValue,\n    updateFilterModelWithSelectedValues,\n  };\n};\n","<script setup lang=\"ts\">\nimport { ColDef } from \"ag-grid-community\";\nimport type { AdvancedFilterModel } from \"ag-grid-enterprise\";\nimport { computed, inject, nextTick, onUnmounted, ref, watch } from \"vue\";\nimport PvPopover from \"@/components/base/PvPopover/PvPopover.vue\";\nimport PvTooltip from \"@/components/base/PvTooltip/PvTooltip.vue\";\nimport { vOnClickOutside } from \"@vueuse/components\";\nimport {\n  constructAdvancedFilterCondition,\n  getSelectedValues,\n  mergeAdvancedFilterCondition,\n  removeColumnFromAdvancedFilter,\n} from \"@tables/PvDataTable/filters/filterHelpers\";\nimport PvMenuItem from \"../../../base/PvMenu/items/PvMenuItem.vue\";\nimport PvSelectControlPanel from \"@/components/base/PvMenu/PvMenuControlPanel.vue\";\nimport PvSpinner from \"@/components/base/PvSpinner/PvSpinner.vue\";\nimport { GridApiKey, RowsLoadingKey } from \"@/components/tables/symbols\";\nimport { colDefContext } from \"@tables/PvDataTable/helpers.ts\";\nimport { useFilterStore } from \"@tables/PvDataTable/useFilterStore.ts\";\nimport { useMenuPosition } from \"@/components/base/PvMenu/useMenuPosition\";\n\nexport interface FilterGroupMenuProps {\n  filterColDef: ColDef;\n}\n\nconst props = defineProps<FilterGroupMenuProps>();\n\nconst gridApi = inject(GridApiKey, ref(null));\nconst rowsLoading = inject(RowsLoadingKey, ref(false));\n\nconst { filterModel, filterStoreHandler, noteFilterModelChange, stageFilterChangesUntilDropdownCloses } =\n  useFilterStore();\n\n// Track which sub-fields are currently selected.\nconst selectedValues = ref<Set<string>>(new Set());\n\n// Track which sub-fields have no available data (empty handler response → disabled).\nconst disabledFields = ref<Set<string>>(new Set());\n\nconst isOpen = ref(false);\nconst triggerWrapper = ref<HTMLElement | null>(null);\n\nconst filterGroup = computed(() => colDefContext(props.filterColDef).filterGroup!);\n\nconst noteChangedFields = (fields: Set<string>) => {\n  const changedFields = new Set(fields);\n  if (props.filterColDef.field) changedFields.add(props.filterColDef.field);\n  noteFilterModelChange(changedFields);\n};\n\nconst { popoverPositionStyle, updateRects, triggerRef, popoverRef } = useMenuPosition({\n  alignment: \"top right\",\n  useTeleport: true,\n});\n\n// Checks whether the committed advanced filter model contains a `field = \"true\"` condition.\nconst isValueSelected = (field: string): boolean => {\n  const values = getSelectedValues(filterModel.value, field);\n  return values !== null && values.length > 0 && values.includes(\"true\");\n};\n\nconst getFieldDisplayName = (field: string): string => {\n  return gridApi.value?.getColumnDef(field)?.headerName ?? field;\n};\n\n// Calls filterStoreHandler for each group field to determine which have available data.\n// A field is disabled when the handler returns an empty response.\n// Falls back to all-enabled when no handler is configured (e.g. client-side row data).\nconst refreshAvailability = async () => {\n  if (!filterStoreHandler.value || !gridApi.value) return;\n\n  const fields = filterGroup.value.fields;\n  const results = await Promise.all(\n    fields.map(async (field) => {\n      const colDef = gridApi.value!.getColumnDef(field) ?? { field };\n      const response = await filterStoreHandler.value!({\n        api: gridApi.value!,\n        colDef,\n        field,\n        filterModel: filterModel.value,\n        reason: \"open\",\n      });\n      const values = Array.isArray(response) ? response : response.values;\n      const hasTrue = values.some((v) => v !== null && v.value === \"true\");\n      return { field, hasData: hasTrue };\n    }),\n  );\n\n  disabledFields.value = new Set(results.filter((r) => !r.hasData).map((r) => r.field));\n};\n\nconst handleItemClick = (field: string) => {\n  if (!gridApi.value) return;\n  const isSelected = selectedValues.value.has(field);\n  if (isSelected) {\n    selectedValues.value.delete(field);\n  } else {\n    selectedValues.value.add(field);\n  }\n\n  // If we're staging the changes, then we're done after updating our selected filter values.\n  if (stageFilterChangesUntilDropdownCloses.value) return;\n\n  // Otherwise, we need to update the filter model immediately.\n  const existingModel = gridApi.value.getAdvancedFilterModel() as AdvancedFilterModel | null;\n  const newCondition = isSelected ? null : constructAdvancedFilterCondition(field, [\"true\"]);\n  const merged = mergeAdvancedFilterCondition(existingModel, newCondition, field);\n  noteChangedFields(new Set([field]));\n  nextTick(() => {\n    gridApi.value?.setAdvancedFilterModel(merged as AdvancedFilterModel | null);\n  });\n};\n\nconst handleSelectAll = () => {\n  /**  Select all filter group fields. */\n  if (!gridApi.value) return;\n  const enabledFields = filterGroup.value.fields.filter((f) => !disabledFields.value.has(f));\n\n  // If we're staging the filter changes, then just mark all values as selected and then exit.\n  if (stageFilterChangesUntilDropdownCloses.value) {\n    for (const field of enabledFields) {\n      selectedValues.value.add(field);\n    }\n    return;\n  }\n\n  // Otherwise, select all values and update the filter model immediately.\n  let model = gridApi.value.getAdvancedFilterModel() as AdvancedFilterModel | null;\n  const changed = new Set<string>();\n  for (const field of enabledFields) {\n    if (!selectedValues.value.has(field)) {\n      model = mergeAdvancedFilterCondition(model, constructAdvancedFilterCondition(field, [\"true\"]), field);\n      selectedValues.value.add(field);\n      changed.add(field);\n    }\n  }\n  if (changed.size > 0) {\n    noteChangedFields(changed);\n    nextTick(() => {\n      gridApi.value?.setAdvancedFilterModel(model as AdvancedFilterModel | null);\n    });\n  }\n};\n\nconst handleClearAll = () => {\n  if (!gridApi.value) return;\n\n  // If we're staging the filter changes, then just uncheck all values and then exit.\n  if (stageFilterChangesUntilDropdownCloses.value) {\n    for (const field of filterGroup.value.fields) {\n      selectedValues.value.delete(field);\n    }\n    return;\n  }\n\n  // If not staging, deselect all options and execute filter model.\n  let model = gridApi.value.getAdvancedFilterModel() as AdvancedFilterModel | null;\n  const changed = new Set<string>();\n  for (const field of filterGroup.value.fields) {\n    model = removeColumnFromAdvancedFilter(model, field);\n    selectedValues.value.delete(field);\n    changed.add(field);\n  }\n  noteChangedFields(changed);\n  nextTick(() => {\n    gridApi.value?.setAdvancedFilterModel(model as AdvancedFilterModel | null);\n  });\n};\n\nconst closeMenu = () => {\n  isOpen.value = false;\n};\n\nconst toggleMenu = () => {\n  if (isOpen.value) {\n    closeMenu();\n    return;\n  }\n  triggerRef.value = triggerWrapper.value;\n  updateRects();\n  refreshAvailability();\n  isOpen.value = true;\n};\n\nwatch(\n  filterModel,\n  () => {\n    // While staging is on, selectedValues holds uncommitted edits — don't overwrite from\n    // the committed filterModel. We seed once on mount via { immediate: true } so the\n    // initial committed state is reflected. When the menu is closed (popover not open),\n    // it's safe to re-sync because there can be no pending uncommitted edits in that state.\n    if (stageFilterChangesUntilDropdownCloses.value && isOpen.value) {\n      return;\n    }\n    selectedValues.value.clear();\n    for (const field of filterGroup.value.fields) {\n      if (isValueSelected(field)) selectedValues.value.add(field);\n    }\n  },\n  { immediate: true },\n);\n\nconst isLoading = computed(() => rowsLoading.value);\n\nconst menuItems = computed(() =>\n  filterGroup.value.fields.map((field) => ({\n    field,\n    label: getFieldDisplayName(field),\n    isSelected: selectedValues.value.has(field),\n    isAvailable: !disabledFields.value.has(field),\n  })),\n);\n\n// While loading, only render selected items so they float to the top with the spinner below.\nconst visibleMenuItems = computed(() =>\n  isLoading.value ? menuItems.value.filter((item) => item.isSelected) : menuItems.value,\n);\n\nonUnmounted(() => {\n  isOpen.value = false;\n  selectedValues.value.clear();\n  disabledFields.value.clear();\n});\n\nconst selectedCount = computed(() => selectedValues.value.size);\n\n// Exposed for tests so they can open the menu without simulating a click event.\n// Otherwise ran into errors attempting to write the tests using DOM events like mouseenter, etc.\nconst openForTest = () => {\n  refreshAvailability();\n  isOpen.value = true;\n};\ndefineExpose({ openForTest, selectedValues });\n</script>\n\n<template>\n  <div\n    ref=\"triggerWrapper\"\n    v-on-click-outside=\"[closeMenu, { ignore: ['.pv-popover'] }]\"\n    style=\"padding-bottom: 4px\"\n    class=\"pv-border-bottom\"\n  >\n    <PvMenuItem\n      :config=\"{ variant: 'icon', counterBadgeVariant: 'tertiary' }\"\n      :id=\"filterGroup.label\"\n      :text=\"filterGroup.label\"\n      :class-list=\"['pv-menu-nested']\"\n      :secondary-text=\"selectedCount || undefined\"\n      @handle-selected=\"toggleMenu\"\n    />\n    <PvPopover\n      ref=\"popoverRef\"\n      :class=\"{ 'pv-hide': !isOpen }\"\n      :css-custom-properties=\"{ width: 'max-content', ...popoverPositionStyle }\"\n    >\n      <ul v-if=\"isOpen && visibleMenuItems.length > 0\" role=\"list\" class=\"pv-popover-list\">\n        <template v-for=\"item in visibleMenuItems\" :key=\"item.field\">\n          <li v-if=\"item.isAvailable\" :data-active=\"item.isSelected ? 'true' : null\">\n            <PvMenuItem\n              :config=\"{ variant: 'checkbox' }\"\n              :id=\"item.field\"\n              :text=\"item.label\"\n              :class-list=\"['pv-chart-option pv-flex']\"\n              :selectedIds=\"item.isSelected ? [item.field] : []\"\n              @handle-selected=\"handleItemClick(item.field)\"\n            />\n          </li>\n          <li v-else>\n            <PvTooltip\n              variant=\"dark\"\n              size=\"sm\"\n              tooltip-position=\"bottom-right\"\n              :disable-interactive=\"true\"\n              style=\"width: 100%\"\n            >\n              <template #label>\n                <PvMenuItem\n                  :config=\"{ variant: 'checkbox' }\"\n                  :id=\"item.field\"\n                  :text=\"item.label\"\n                  :disabled=\"true\"\n                  :class-list=\"['pv-chart-option pv-flex']\"\n                />\n              </template>\n              <template #tooltip-content>No entries in the result set</template>\n            </PvTooltip>\n          </li>\n        </template>\n      </ul>\n      <div v-if=\"isOpen && isLoading\" class=\"pv-flex pv-inset-square-8\" style=\"justify-content: center\">\n        <PvSpinner variant=\"dark\" />\n      </div>\n      <PvSelectControlPanel\n        v-if=\"isOpen\"\n        class=\"pv-border-top pv-inset-square-8\"\n        style=\"padding-top: 8px\"\n        variant=\"select-clear\"\n        :disabled=\"isLoading\"\n        @handle-select-all=\"handleSelectAll\"\n        @handle-clear-all=\"handleClearAll\"\n      />\n    </PvPopover>\n  </div>\n</template>\n","<script setup lang=\"ts\">\nimport { ColDef } from \"ag-grid-community\";\nimport type { AdvancedFilterModel } from \"ag-grid-enterprise\";\nimport { computed, inject, nextTick, onUnmounted, ref, watch } from \"vue\";\nimport PvPopover from \"@/components/base/PvPopover/PvPopover.vue\";\nimport PvTooltip from \"@/components/base/PvTooltip/PvTooltip.vue\";\nimport { vOnClickOutside } from \"@vueuse/components\";\nimport {\n  constructAdvancedFilterCondition,\n  getSelectedValues,\n  mergeAdvancedFilterCondition,\n  removeColumnFromAdvancedFilter,\n} from \"@tables/PvDataTable/filters/filterHelpers\";\nimport PvMenuItem from \"../../../base/PvMenu/items/PvMenuItem.vue\";\nimport PvSelectControlPanel from \"@/components/base/PvMenu/PvMenuControlPanel.vue\";\nimport PvSpinner from \"@/components/base/PvSpinner/PvSpinner.vue\";\nimport { GridApiKey, RowsLoadingKey } from \"@/components/tables/symbols\";\nimport { colDefContext } from \"@tables/PvDataTable/helpers.ts\";\nimport { useFilterStore } from \"@tables/PvDataTable/useFilterStore.ts\";\nimport { useMenuPosition } from \"@/components/base/PvMenu/useMenuPosition\";\n\nexport interface FilterGroupMenuProps {\n  filterColDef: ColDef;\n}\n\nconst props = defineProps<FilterGroupMenuProps>();\n\nconst gridApi = inject(GridApiKey, ref(null));\nconst rowsLoading = inject(RowsLoadingKey, ref(false));\n\nconst { filterModel, filterStoreHandler, noteFilterModelChange, stageFilterChangesUntilDropdownCloses } =\n  useFilterStore();\n\n// Track which sub-fields are currently selected.\nconst selectedValues = ref<Set<string>>(new Set());\n\n// Track which sub-fields have no available data (empty handler response → disabled).\nconst disabledFields = ref<Set<string>>(new Set());\n\nconst isOpen = ref(false);\nconst triggerWrapper = ref<HTMLElement | null>(null);\n\nconst filterGroup = computed(() => colDefContext(props.filterColDef).filterGroup!);\n\nconst noteChangedFields = (fields: Set<string>) => {\n  const changedFields = new Set(fields);\n  if (props.filterColDef.field) changedFields.add(props.filterColDef.field);\n  noteFilterModelChange(changedFields);\n};\n\nconst { popoverPositionStyle, updateRects, triggerRef, popoverRef } = useMenuPosition({\n  alignment: \"top right\",\n  useTeleport: true,\n});\n\n// Checks whether the committed advanced filter model contains a `field = \"true\"` condition.\nconst isValueSelected = (field: string): boolean => {\n  const values = getSelectedValues(filterModel.value, field);\n  return values !== null && values.length > 0 && values.includes(\"true\");\n};\n\nconst getFieldDisplayName = (field: string): string => {\n  return gridApi.value?.getColumnDef(field)?.headerName ?? field;\n};\n\n// Calls filterStoreHandler for each group field to determine which have available data.\n// A field is disabled when the handler returns an empty response.\n// Falls back to all-enabled when no handler is configured (e.g. client-side row data).\nconst refreshAvailability = async () => {\n  if (!filterStoreHandler.value || !gridApi.value) return;\n\n  const fields = filterGroup.value.fields;\n  const results = await Promise.all(\n    fields.map(async (field) => {\n      const colDef = gridApi.value!.getColumnDef(field) ?? { field };\n      const response = await filterStoreHandler.value!({\n        api: gridApi.value!,\n        colDef,\n        field,\n        filterModel: filterModel.value,\n        reason: \"open\",\n      });\n      const values = Array.isArray(response) ? response : response.values;\n      const hasTrue = values.some((v) => v !== null && v.value === \"true\");\n      return { field, hasData: hasTrue };\n    }),\n  );\n\n  disabledFields.value = new Set(results.filter((r) => !r.hasData).map((r) => r.field));\n};\n\nconst handleItemClick = (field: string) => {\n  if (!gridApi.value) return;\n  const isSelected = selectedValues.value.has(field);\n  if (isSelected) {\n    selectedValues.value.delete(field);\n  } else {\n    selectedValues.value.add(field);\n  }\n\n  // If we're staging the changes, then we're done after updating our selected filter values.\n  if (stageFilterChangesUntilDropdownCloses.value) return;\n\n  // Otherwise, we need to update the filter model immediately.\n  const existingModel = gridApi.value.getAdvancedFilterModel() as AdvancedFilterModel | null;\n  const newCondition = isSelected ? null : constructAdvancedFilterCondition(field, [\"true\"]);\n  const merged = mergeAdvancedFilterCondition(existingModel, newCondition, field);\n  noteChangedFields(new Set([field]));\n  nextTick(() => {\n    gridApi.value?.setAdvancedFilterModel(merged as AdvancedFilterModel | null);\n  });\n};\n\nconst handleSelectAll = () => {\n  /**  Select all filter group fields. */\n  if (!gridApi.value) return;\n  const enabledFields = filterGroup.value.fields.filter((f) => !disabledFields.value.has(f));\n\n  // If we're staging the filter changes, then just mark all values as selected and then exit.\n  if (stageFilterChangesUntilDropdownCloses.value) {\n    for (const field of enabledFields) {\n      selectedValues.value.add(field);\n    }\n    return;\n  }\n\n  // Otherwise, select all values and update the filter model immediately.\n  let model = gridApi.value.getAdvancedFilterModel() as AdvancedFilterModel | null;\n  const changed = new Set<string>();\n  for (const field of enabledFields) {\n    if (!selectedValues.value.has(field)) {\n      model = mergeAdvancedFilterCondition(model, constructAdvancedFilterCondition(field, [\"true\"]), field);\n      selectedValues.value.add(field);\n      changed.add(field);\n    }\n  }\n  if (changed.size > 0) {\n    noteChangedFields(changed);\n    nextTick(() => {\n      gridApi.value?.setAdvancedFilterModel(model as AdvancedFilterModel | null);\n    });\n  }\n};\n\nconst handleClearAll = () => {\n  if (!gridApi.value) return;\n\n  // If we're staging the filter changes, then just uncheck all values and then exit.\n  if (stageFilterChangesUntilDropdownCloses.value) {\n    for (const field of filterGroup.value.fields) {\n      selectedValues.value.delete(field);\n    }\n    return;\n  }\n\n  // If not staging, deselect all options and execute filter model.\n  let model = gridApi.value.getAdvancedFilterModel() as AdvancedFilterModel | null;\n  const changed = new Set<string>();\n  for (const field of filterGroup.value.fields) {\n    model = removeColumnFromAdvancedFilter(model, field);\n    selectedValues.value.delete(field);\n    changed.add(field);\n  }\n  noteChangedFields(changed);\n  nextTick(() => {\n    gridApi.value?.setAdvancedFilterModel(model as AdvancedFilterModel | null);\n  });\n};\n\nconst closeMenu = () => {\n  isOpen.value = false;\n};\n\nconst toggleMenu = () => {\n  if (isOpen.value) {\n    closeMenu();\n    return;\n  }\n  triggerRef.value = triggerWrapper.value;\n  updateRects();\n  refreshAvailability();\n  isOpen.value = true;\n};\n\nwatch(\n  filterModel,\n  () => {\n    // While staging is on, selectedValues holds uncommitted edits — don't overwrite from\n    // the committed filterModel. We seed once on mount via { immediate: true } so the\n    // initial committed state is reflected. When the menu is closed (popover not open),\n    // it's safe to re-sync because there can be no pending uncommitted edits in that state.\n    if (stageFilterChangesUntilDropdownCloses.value && isOpen.value) {\n      return;\n    }\n    selectedValues.value.clear();\n    for (const field of filterGroup.value.fields) {\n      if (isValueSelected(field)) selectedValues.value.add(field);\n    }\n  },\n  { immediate: true },\n);\n\nconst isLoading = computed(() => rowsLoading.value);\n\nconst menuItems = computed(() =>\n  filterGroup.value.fields.map((field) => ({\n    field,\n    label: getFieldDisplayName(field),\n    isSelected: selectedValues.value.has(field),\n    isAvailable: !disabledFields.value.has(field),\n  })),\n);\n\n// While loading, only render selected items so they float to the top with the spinner below.\nconst visibleMenuItems = computed(() =>\n  isLoading.value ? menuItems.value.filter((item) => item.isSelected) : menuItems.value,\n);\n\nonUnmounted(() => {\n  isOpen.value = false;\n  selectedValues.value.clear();\n  disabledFields.value.clear();\n});\n\nconst selectedCount = computed(() => selectedValues.value.size);\n\n// Exposed for tests so they can open the menu without simulating a click event.\n// Otherwise ran into errors attempting to write the tests using DOM events like mouseenter, etc.\nconst openForTest = () => {\n  refreshAvailability();\n  isOpen.value = true;\n};\ndefineExpose({ openForTest, selectedValues });\n</script>\n\n<template>\n  <div\n    ref=\"triggerWrapper\"\n    v-on-click-outside=\"[closeMenu, { ignore: ['.pv-popover'] }]\"\n    style=\"padding-bottom: 4px\"\n    class=\"pv-border-bottom\"\n  >\n    <PvMenuItem\n      :config=\"{ variant: 'icon', counterBadgeVariant: 'tertiary' }\"\n      :id=\"filterGroup.label\"\n      :text=\"filterGroup.label\"\n      :class-list=\"['pv-menu-nested']\"\n      :secondary-text=\"selectedCount || undefined\"\n      @handle-selected=\"toggleMenu\"\n    />\n    <PvPopover\n      ref=\"popoverRef\"\n      :class=\"{ 'pv-hide': !isOpen }\"\n      :css-custom-properties=\"{ width: 'max-content', ...popoverPositionStyle }\"\n    >\n      <ul v-if=\"isOpen && visibleMenuItems.length > 0\" role=\"list\" class=\"pv-popover-list\">\n        <template v-for=\"item in visibleMenuItems\" :key=\"item.field\">\n          <li v-if=\"item.isAvailable\" :data-active=\"item.isSelected ? 'true' : null\">\n            <PvMenuItem\n              :config=\"{ variant: 'checkbox' }\"\n              :id=\"item.field\"\n              :text=\"item.label\"\n              :class-list=\"['pv-chart-option pv-flex']\"\n              :selectedIds=\"item.isSelected ? [item.field] : []\"\n              @handle-selected=\"handleItemClick(item.field)\"\n            />\n          </li>\n          <li v-else>\n            <PvTooltip\n              variant=\"dark\"\n              size=\"sm\"\n              tooltip-position=\"bottom-right\"\n              :disable-interactive=\"true\"\n              style=\"width: 100%\"\n            >\n              <template #label>\n                <PvMenuItem\n                  :config=\"{ variant: 'checkbox' }\"\n                  :id=\"item.field\"\n                  :text=\"item.label\"\n                  :disabled=\"true\"\n                  :class-list=\"['pv-chart-option pv-flex']\"\n                />\n              </template>\n              <template #tooltip-content>No entries in the result set</template>\n            </PvTooltip>\n          </li>\n        </template>\n      </ul>\n      <div v-if=\"isOpen && isLoading\" class=\"pv-flex pv-inset-square-8\" style=\"justify-content: center\">\n        <PvSpinner variant=\"dark\" />\n      </div>\n      <PvSelectControlPanel\n        v-if=\"isOpen\"\n        class=\"pv-border-top pv-inset-square-8\"\n        style=\"padding-top: 8px\"\n        variant=\"select-clear\"\n        :disabled=\"isLoading\"\n        @handle-select-all=\"handleSelectAll\"\n        @handle-clear-all=\"handleClearAll\"\n      />\n    </PvPopover>\n  </div>\n</template>\n","<script setup lang=\"ts\" generic=\"T\">\nimport { ColDef } from \"ag-grid-community\";\nimport { computed, inject, nextTick, ref, toRef } from \"vue\";\nimport PvButton from \"@/components/base/PvButton/PvButton.vue\";\nimport { PvMultiSelectButton, PvSuggestionTag, PvTooltipV2 } from \"@/components/base\";\nimport PvTag from \"@/components/base/PvTag/PvTag.vue\";\nimport { useFocusStore } from \"@tables/PvDataTable/useFocus\";\nimport { MenuAction } from \"@/types\";\nimport { colDefContext, getAggregateFields, isAggregateColDef } from \"@tables/PvDataTable/helpers\";\nimport { FilterValueResponseOption } from \"@tables/PvDataTable/types.ts\";\nimport { useSetFilter } from \"@tables/PvDataTable/useSetFilter\";\nimport FilterGroupMenu from \"@tables/PvDataTable/table-components/FilterGroupMenu.vue\";\nimport { EnableAdvancedFilterKey } from \"@/components/tables/symbols\";\nimport { addRumAction, deferRumTask, useRumContext } from \"@/functions/rum\";\n\nexport interface SetFilterMenuOptionProps {\n  filterField?: string;\n  filterContext?: FilterValueResponseOption | null;\n}\n\nexport interface SetFilterProps<T> {\n  enableFocusView?: boolean;\n  filterColDef: ColDef<T>;\n  filterStyle?: \"horizontal\" | \"vertical\";\n  displayPreferencesIcon?: boolean;\n  focusText?: string;\n  readOnly?: boolean;\n  /** When true (with readOnly), filters with no selections are disabled. */\n  disableUnselected?: boolean;\n}\n\nconst props = withDefaults(defineProps<SetFilterProps<T>>(), {\n  enableFocusView: false,\n  displayPreferencesIcon: false,\n  filterStyle: \"horizontal\",\n  focusText: \"focus\",\n  readOnly: false,\n  disableUnselected: false,\n});\n\nconst emits = defineEmits<{\n  (e: \"filter-selection-changed\"): void;\n  (e: \"filter-closed\"): void;\n  (e: \"handle-settings-icon\", value: string): void;\n}>();\n\nconst maxSuggestionValueCount = 4;\n\n// Reference to the optional FilterGroupMenu — used to read its staged selectedValues\n// so useSetFilter can include filterGroup field changes in its own commit.\nconst filterGroupMenuRef = ref<{ selectedValues: Set<string> } | null>(null);\nconst filterGroupStagedFields = computed(() => filterGroupMenuRef.value?.selectedValues ?? new Set<string>());\nconst filterGroupSelectedCount = computed(() => filterGroupMenuRef.value?.selectedValues.size ?? 0);\n\nconst {\n  // State\n  selectedValues,\n  isLoading,\n  isSeeMoreLoading,\n  filterSearchText,\n  filterSearchMinLength,\n  belowFilterSearchMinLength,\n  rowsLoading,\n  gridApi,\n\n  // Computed\n  filterField,\n  filterDisplayName,\n  isInFilterPanel,\n  isSingleSelect,\n  suggestedValues,\n  displayedFilterValues,\n  selectedFilterValues,\n  showSearchBar,\n  filterSearchPlaceholder,\n  emptyFilterResultsRenderer,\n  filterOptionsLoadingText,\n  filterOptionsRenderer,\n  filterHeaderRenderer,\n  filterFooterRenderer,\n  filterFooterPosition,\n  filterOptionsSortDescription,\n  filterOptionsSortTooltip,\n\n  // Methods\n  filterValueContext,\n  formatDisplayValue,\n  resolvedFilterValueContext,\n  isUnresolvedMetadataValue,\n  getLatestFilterValues,\n  addSelectedValue,\n  removeSelectedValue,\n  recordBulkAction,\n  rumLocation,\n  handleDropdownOpen: baseHandleDropdownOpen,\n  handleDropdownClosed: baseHandleDropdownClosed,\n  handleSeeMore,\n  getColDisplayNameForField,\n  hasMoreOptions,\n  totalOptionCount,\n  isAggregate,\n  cascadeSelectionState,\n  cascadeSelectionStateModel,\n} = useSetFilter<T>({\n  filterColDef: toRef(props, \"filterColDef\"),\n  filterStyle: toRef(props, \"filterStyle\"),\n  onSelectionChanged: () => emits(\"filter-selection-changed\"),\n  filterGroupStagedFields,\n  readOnly: toRef(props, \"readOnly\"),\n  disableUnselected: toRef(props, \"disableUnselected\"),\n});\n\nconst rumContext = useRumContext();\n\nconst { handleFocusUpdate, isFocused, removeFocus, isFocusable, canRemoveFocus } = useFocusStore();\n\n// Extract raw value from aggregate option for focus comparison and storage\n// For aggregate columns, option.id is a scoped token like \"__health_system__Banner Health\"\n// but focus needs the raw value \"Banner Health\" to match chart data\nconst getRawFocusValue = (option: { id: string; context?: FilterValueResponseOption | null }): string => {\n  // Use metadata rawValue if available\n  if (option.context?.metadata?.rawValue != null) {\n    return String(option.context.metadata.rawValue);\n  }\n  // Parse scoped token format: __field__value[__parentField__parentValue...]\n  if (option.id.startsWith(\"__\")) {\n    const rest = option.id.slice(2);\n    const parts = rest.split(\"__\");\n    if (parts.length >= 2) {\n      return parts[1]; // Return the value portion\n    }\n  }\n  // Fallback to option.id for non-aggregate columns\n  return option.id;\n};\n\nconst optionsAction = computed(() => {\n  const filterFields = isAggregateColDef(props.filterColDef)\n    ? getAggregateFields(props.filterColDef)\n    : [filterField.value];\n  if (!isFocusable(filterFields)) {\n    return undefined;\n  }\n  const action: MenuAction<FilterValueResponseOption> = {\n    icon: \"focus\",\n    isDisabled: (option) => {\n      const optionField = option.context?.colField || filterField.value;\n      return !isFocusable([optionField]);\n    },\n    tooltipText: (option) => {\n      const optionField = option.context?.colField || filterField.value;\n      if (!isFocusable([optionField])) {\n        const focusColName = getColDisplayNameForField(optionField);\n        return `Group by ${focusColName} to enable ${props.focusText}`;\n      }\n      // For aggregate columns, use raw value for focus comparison\n      const focusValue = isAggregate.value ? getRawFocusValue(option) : option.id;\n      const isFocusedOption = isFocused(focusValue, optionField);\n      if (isFocusedOption && !canRemoveFocus()) {\n        return `${props.focusText} (required)`;\n      }\n      return isFocusedOption ? `Remove ${props.focusText}` : `Select as ${props.focusText}`;\n    },\n    action: (option) => {\n      if (option && !selectedValues.value.includes(option.id)) {\n        addSelectedValue(option.id, option.context?.colField);\n      }\n      const fieldToFocus = option.context?.colField || filterField.value;\n      // For aggregate columns, store raw value in focus for chart comparison\n      const focusValue = isAggregate.value ? getRawFocusValue(option) : option.id;\n      handleFocusUpdate(focusValue, fieldToFocus);\n    },\n    alwaysShow: (option) => {\n      const optionField = option.context?.colField || filterField.value;\n      // For aggregate columns, use raw value for focus comparison\n      const focusValue = isAggregate.value ? getRawFocusValue(option) : option.id;\n      return isFocused(focusValue, optionField);\n    },\n  };\n  return action;\n});\n\n// Extract raw focus value from a value string (for non-option contexts)\nconst getRawFocusValueFromString = (value: string | null): string | null => {\n  if (!value) return null;\n  if (!isAggregate.value) return value;\n  const context = resolvedFilterValueContext(value);\n  if (context?.metadata?.rawValue != null) {\n    return String(context.metadata.rawValue);\n  }\n  if (value.startsWith(\"__\")) {\n    const rest = value.slice(2);\n    const parts = rest.split(\"__\");\n    if (parts.length >= 2) return parts[1];\n  }\n  return value;\n};\n\nconst handleRemoveSelectedValue = (value: string | null) => {\n  removeSelectedValue(value, undefined, \"remove_chip\");\n  const context = resolvedFilterValueContext(value);\n  const fieldToCheck = context?.colField || filterField.value;\n  const focusValue = getRawFocusValueFromString(value);\n  if (isFocused(focusValue, fieldToCheck) && canRemoveFocus()) {\n    removeFocus(focusValue);\n  }\n};\n\n// FilterGroupMenu only operates against the advanced filter model — gate its render\n// on this so we don't have to support the regular-filter path inside the component.\nconst enableAdvancedFilter = inject(EnableAdvancedFilterKey, ref(false));\n\nconst showFilterGroupMenu = computed(\n  () => !!colDefContext(props.filterColDef).filterGroup && enableAdvancedFilter.value,\n);\n\n// Timestamp captured when the dropdown opens; powers `dwell_ms` in the\n// filter_dropdown_closed RUM action. Reset to null when not open.\nlet openedAtMs: number | null = null;\n// Selection snapshot at open; compared at close for `selection_changed`\n// (opened-browsed-abandoned is a per-filter UX smell worth measuring).\nlet selectionAtOpen: string | null = null;\n\n// Serialize the current selection for change detection across open/close.\n// Aggregates track selection in cascadeSelectionState, not flat values.\n// Returns null (treated as \"unknown, assume unchanged\") on any error so\n// snapshotting can never break the dropdown lifecycle.\nconst selectionSnapshot = (): string | null => {\n  try {\n    return isAggregate.value\n      ? JSON.stringify(cascadeSelectionState.value)\n      : JSON.stringify([...selectedValues.value].sort());\n  } catch {\n    return null;\n  }\n};\n\nconst handleDropdownOpen = () => {\n  openedAtMs = Date.now();\n  selectionAtOpen = selectionSnapshot();\n  baseHandleDropdownOpen();\n  getLatestFilterValues(true);\n};\n\nconst handleDropdownClosed = () => {\n  // Capture everything synchronously, then emit on a deferred, error-isolated\n  // task so RUM can never interfere with the close/commit flow below.\n  const dwellMs = openedAtMs != null ? Date.now() - openedAtMs : 0;\n  openedAtMs = null;\n  const selectionAtClose = selectionSnapshot();\n  const selectionChanged = selectionAtOpen != null && selectionAtClose != null && selectionAtOpen !== selectionAtClose;\n  selectionAtOpen = null;\n  const selectionCount = selectedValues.value.length;\n  deferRumTask(() => {\n    addRumAction(\n      \"filter_dropdown_closed\",\n      {\n        filter_name: filterDisplayName.value,\n        filter_field: filterField.value,\n        selection_count: selectionCount,\n        selection_changed: selectionChanged,\n        dwell_ms: dwellMs,\n        location: rumLocation.value,\n      },\n      rumContext(),\n    );\n  });\n  nextTick(() => {\n    baseHandleDropdownClosed();\n    emits(\"filter-closed\");\n  });\n};\n\nconst isValueFocused = (value: string | null) => {\n  const context = resolvedFilterValueContext(value);\n  const fieldToCheck = context?.colField || filterField.value;\n  const focusValue = getRawFocusValueFromString(value);\n  return isFocused(focusValue, fieldToCheck);\n};\n\nconst hasSelectedFilterValues = computed(() => {\n  // If sub-filters in the filter group are applied, then those count as selected values and we return true.\n  if (filterGroupSelectedCount.value > 0) {\n    return true;\n  }\n\n  // If this is an aggregate filter, return true if at least 1 cascading selection has been made.\n  if (isAggregate.value) {\n    return cascadeSelectionState.value.length > 0;\n  }\n\n  // Otherwise, just check whether there are any plain old selectedValues.\n  return selectedValues.value.length > 0;\n});\n</script>\n\n<template>\n  <div>\n    <ul\n      v-if=\"isInFilterPanel && selectedValues.length > 0\"\n      role=\"list\"\n      class=\"pv-flex pv-stack-4\"\n      style=\"--flex-wrap: wrap; max-width: 100%\"\n    >\n      <template v-for=\"value in selectedValues\" :key=\"`${filterDisplayName}-${value}`\">\n        <li v-if=\"!isUnresolvedMetadataValue(value)\" style=\"max-width: 100%; line-height: 1rem\">\n          <PvTag\n            :label=\"formatDisplayValue(value) || ''\"\n            :showClear=\"!readOnly && (!isValueFocused(value) || canRemoveFocus())\"\n            :disabled=\"readOnly\"\n            @handle-close=\"handleRemoveSelectedValue(value)\"\n          />\n        </li>\n      </template>\n    </ul>\n    <PvMultiSelectButton\n      v-model=\"selectedFilterValues\"\n      :disabled=\"!isInFilterPanel && readOnly && disableUnselected && !hasSelectedFilterValues\"\n      v-model:searchInput=\"filterSearchText\"\n      v-model:selectionState=\"cascadeSelectionStateModel\"\n      :data-horizontal-filter-field=\"!isInFilterPanel ? filterField : undefined\"\n      :label=\"!isInFilterPanel ? filterDisplayName : ''\"\n      :rumFilterName=\"filterDisplayName\"\n      :highlightSearchText=\"true\"\n      :icon=\"isInFilterPanel && !readOnly ? 'add-circle' : undefined\"\n      :variant=\"isInFilterPanel ? 'ghost' : 'secondary'\"\n      :counterPosition=\"!isInFilterPanel && hasSelectedFilterValues ? undefined : 'none'\"\n      :singleSelect=\"isSingleSelect\"\n      :menuActionsVariant=\"readOnly || isSingleSelect ? null : 'select-clear'\"\n      :footerPosition=\"filterFooterPosition\"\n      :disableSearchInput=\"readOnly || !showSearchBar\"\n      :searchPlaceholder=\"filterSearchPlaceholder\"\n      :overlayTrigger=\"isInFilterPanel\"\n      :options=\"displayedFilterValues\"\n      :optionsRenderer=\"filterOptionsRenderer\"\n      :optionsAction=\"optionsAction\"\n      :popoverCssProperties=\"{\n        maxHeight: '400px',\n        maxWidth: isInFilterPanel ? '300px' : '400px',\n        overflowX: 'auto',\n        width: 'auto',\n      }\"\n      :disableClearIcon=\"!!isInFilterPanel || readOnly\"\n      :disableDropdownIcon=\"!!isInFilterPanel\"\n      :groupings=\"['preferences', 'suggestions']\"\n      :isLoading=\"isLoading\"\n      :loadingText=\"filterOptionsLoadingText\"\n      :isSeeMoreLoading=\"isSeeMoreLoading\"\n      :hasMoreOptions=\"hasMoreOptions\"\n      :totalOptionCount=\"totalOptionCount\"\n      :enableCascadeSelection=\"isAggregate\"\n      :enableChildExpansion=\"isAggregate\"\n      :parentSelectsAllChildren=\"isAggregate\"\n      :countSelectedParents=\"isAggregate\"\n      :additionalCounter=\"filterGroupSelectedCount\"\n      :slotContext=\"{ gridApi, filterColDef, rowsLoading }\"\n      @dropdown-open=\"handleDropdownOpen\"\n      @dropdown-closed=\"handleDropdownClosed\"\n      @see-more=\"handleSeeMore\"\n      @select-all=\"recordBulkAction('select_all', $event)\"\n      @clear-all=\"recordBulkAction('clear_all', $event)\"\n    >\n      <template v-if=\"filterHeaderRenderer || showFilterGroupMenu || belowFilterSearchMinLength\" #header=\"slotProps\">\n        <p\n          v-if=\"belowFilterSearchMinLength\"\n          class=\"pv-text-subdued pv-text-body-xxs pv-inset-inline\"\n          style=\"--inset-size: 4px\"\n        >\n          Type {{ filterSearchMinLength }} or more characters to search\n        </p>\n        <FilterGroupMenu\n          ref=\"filterGroupMenuRef\"\n          class=\"pv-stack-8\"\n          v-if=\"showFilterGroupMenu\"\n          :filter-col-def=\"filterColDef\"\n        />\n        <component v-if=\"filterHeaderRenderer\" :is=\"filterHeaderRenderer\" v-bind=\"slotProps\"></component>\n      </template>\n      <template #preferences>\n        <div class=\"pv-full-width pv-flex pv-space-between pv-inset-inline\" style=\"--inset-size: 8px\">\n          <p class=\"pv-text-subdued pv-text-body-xxs\">Your Preferences</p>\n          <PvTooltipV2 variant=\"dark\" size=\"sm\" :use-teleport=\"true\">\n            <template #trigger>\n              <PvButton\n                size=\"md\"\n                variant=\"ghost\"\n                @click=\"$emit('handle-settings-icon', filterDisplayName)\"\n                right-icon=\"sliders-horizontal\"\n              />\n            </template>\n            <template #content> Open Preferences </template>\n          </PvTooltipV2>\n        </div>\n      </template>\n      <template #suggestions>\n        <div class=\"pv-inset-inline\" style=\"--inset-size: 8px\">\n          <PvTooltipV2\n            variant=\"dark\"\n            :disableInteractive=\"true\"\n            position=\"top-left\"\n            size=\"sm\"\n            :use-teleport=\"true\"\n            style=\"--max-width: 200px\"\n          >\n            <template #trigger>\n              <p\n                class=\"pv-text-subdued pv-text-body-xxs\"\n                :class=\"filterOptionsSortTooltip ? 'pv-set-filter-suggested-title-label' : ''\"\n              >\n                {{ filterOptionsSortDescription }}\n              </p>\n            </template>\n            <template v-if=\"filterOptionsSortTooltip\" #content>\n              {{ filterOptionsSortTooltip }}\n            </template>\n          </PvTooltipV2>\n        </div>\n      </template>\n      <template v-if=\"emptyFilterResultsRenderer\" #no-results=\"slotProps\">\n        <component :is=\"emptyFilterResultsRenderer\" v-bind=\"slotProps\"></component>\n      </template>\n      <template v-if=\"filterFooterRenderer\" #footer=\"slotProps\">\n        <component :is=\"filterFooterRenderer\" v-bind=\"slotProps\"></component>\n      </template>\n    </PvMultiSelectButton>\n  </div>\n  <div v-if=\"isInFilterPanel && !readOnly\" class=\"pv-full-width\">\n    <div class=\"pv-flex-inline\" v-if=\"suggestedValues.length > 0\" style=\"max-width: 100%\">\n      <ul role=\"list\" class=\"pv-flex\" style=\"--flex-wrap: wrap; max-width: 100%\">\n        <PvTooltipV2\n          variant=\"dark\"\n          :disableInteractive=\"true\"\n          position=\"bottom-left\"\n          size=\"sm\"\n          :use-teleport=\"true\"\n          style=\"--max-width: 200px\"\n        >\n          <template #trigger>\n            <li class=\"pv-text-subdued pv-text-body-xxs\">\n              <p\n                class=\"pv-text-subdued pv-text-body-md\"\n                :class=\"filterOptionsSortTooltip ? 'pv-set-filter-suggested-title-label' : ''\"\n              >\n                Suggested:\n              </p>\n            </li>\n          </template>\n          <template v-if=\"filterOptionsSortTooltip\" #content>\n            {{ filterOptionsSortTooltip }}\n          </template>\n        </PvTooltipV2>\n        <li\n          v-for=\"value in suggestedValues.filter((v) => v !== '' && v != null).slice(0, maxSuggestionValueCount)\"\n          :key=\"`${filterDisplayName}-${value}-suggest`\"\n          :class=\"isLoading ? 'pv-shimmer' : ''\"\n          style=\"max-width: 100%; line-height: 1rem\"\n        >\n          <PvSuggestionTag\n            :disabled=\"isLoading\"\n            :label=\"formatDisplayValue(value) || ''\"\n            @handle-click=\"addSelectedValue(value, filterValueContext(filterField, value)?.colField)\"\n          />\n        </li>\n      </ul>\n    </div>\n  </div>\n</template>\n","<script setup lang=\"ts\" generic=\"T\">\nimport { ColDef } from \"ag-grid-community\";\nimport { computed, inject, nextTick, ref, toRef } from \"vue\";\nimport PvButton from \"@/components/base/PvButton/PvButton.vue\";\nimport { PvMultiSelectButton, PvSuggestionTag, PvTooltipV2 } from \"@/components/base\";\nimport PvTag from \"@/components/base/PvTag/PvTag.vue\";\nimport { useFocusStore } from \"@tables/PvDataTable/useFocus\";\nimport { MenuAction } from \"@/types\";\nimport { colDefContext, getAggregateFields, isAggregateColDef } from \"@tables/PvDataTable/helpers\";\nimport { FilterValueResponseOption } from \"@tables/PvDataTable/types.ts\";\nimport { useSetFilter } from \"@tables/PvDataTable/useSetFilter\";\nimport FilterGroupMenu from \"@tables/PvDataTable/table-components/FilterGroupMenu.vue\";\nimport { EnableAdvancedFilterKey } from \"@/components/tables/symbols\";\nimport { addRumAction, deferRumTask, useRumContext } from \"@/functions/rum\";\n\nexport interface SetFilterMenuOptionProps {\n  filterField?: string;\n  filterContext?: FilterValueResponseOption | null;\n}\n\nexport interface SetFilterProps<T> {\n  enableFocusView?: boolean;\n  filterColDef: ColDef<T>;\n  filterStyle?: \"horizontal\" | \"vertical\";\n  displayPreferencesIcon?: boolean;\n  focusText?: string;\n  readOnly?: boolean;\n  /** When true (with readOnly), filters with no selections are disabled. */\n  disableUnselected?: boolean;\n}\n\nconst props = withDefaults(defineProps<SetFilterProps<T>>(), {\n  enableFocusView: false,\n  displayPreferencesIcon: false,\n  filterStyle: \"horizontal\",\n  focusText: \"focus\",\n  readOnly: false,\n  disableUnselected: false,\n});\n\nconst emits = defineEmits<{\n  (e: \"filter-selection-changed\"): void;\n  (e: \"filter-closed\"): void;\n  (e: \"handle-settings-icon\", value: string): void;\n}>();\n\nconst maxSuggestionValueCount = 4;\n\n// Reference to the optional FilterGroupMenu — used to read its staged selectedValues\n// so useSetFilter can include filterGroup field changes in its own commit.\nconst filterGroupMenuRef = ref<{ selectedValues: Set<string> } | null>(null);\nconst filterGroupStagedFields = computed(() => filterGroupMenuRef.value?.selectedValues ?? new Set<string>());\nconst filterGroupSelectedCount = computed(() => filterGroupMenuRef.value?.selectedValues.size ?? 0);\n\nconst {\n  // State\n  selectedValues,\n  isLoading,\n  isSeeMoreLoading,\n  filterSearchText,\n  filterSearchMinLength,\n  belowFilterSearchMinLength,\n  rowsLoading,\n  gridApi,\n\n  // Computed\n  filterField,\n  filterDisplayName,\n  isInFilterPanel,\n  isSingleSelect,\n  suggestedValues,\n  displayedFilterValues,\n  selectedFilterValues,\n  showSearchBar,\n  filterSearchPlaceholder,\n  emptyFilterResultsRenderer,\n  filterOptionsLoadingText,\n  filterOptionsRenderer,\n  filterHeaderRenderer,\n  filterFooterRenderer,\n  filterFooterPosition,\n  filterOptionsSortDescription,\n  filterOptionsSortTooltip,\n\n  // Methods\n  filterValueContext,\n  formatDisplayValue,\n  resolvedFilterValueContext,\n  isUnresolvedMetadataValue,\n  getLatestFilterValues,\n  addSelectedValue,\n  removeSelectedValue,\n  recordBulkAction,\n  rumLocation,\n  handleDropdownOpen: baseHandleDropdownOpen,\n  handleDropdownClosed: baseHandleDropdownClosed,\n  handleSeeMore,\n  getColDisplayNameForField,\n  hasMoreOptions,\n  totalOptionCount,\n  isAggregate,\n  cascadeSelectionState,\n  cascadeSelectionStateModel,\n} = useSetFilter<T>({\n  filterColDef: toRef(props, \"filterColDef\"),\n  filterStyle: toRef(props, \"filterStyle\"),\n  onSelectionChanged: () => emits(\"filter-selection-changed\"),\n  filterGroupStagedFields,\n  readOnly: toRef(props, \"readOnly\"),\n  disableUnselected: toRef(props, \"disableUnselected\"),\n});\n\nconst rumContext = useRumContext();\n\nconst { handleFocusUpdate, isFocused, removeFocus, isFocusable, canRemoveFocus } = useFocusStore();\n\n// Extract raw value from aggregate option for focus comparison and storage\n// For aggregate columns, option.id is a scoped token like \"__health_system__Banner Health\"\n// but focus needs the raw value \"Banner Health\" to match chart data\nconst getRawFocusValue = (option: { id: string; context?: FilterValueResponseOption | null }): string => {\n  // Use metadata rawValue if available\n  if (option.context?.metadata?.rawValue != null) {\n    return String(option.context.metadata.rawValue);\n  }\n  // Parse scoped token format: __field__value[__parentField__parentValue...]\n  if (option.id.startsWith(\"__\")) {\n    const rest = option.id.slice(2);\n    const parts = rest.split(\"__\");\n    if (parts.length >= 2) {\n      return parts[1]; // Return the value portion\n    }\n  }\n  // Fallback to option.id for non-aggregate columns\n  return option.id;\n};\n\nconst optionsAction = computed(() => {\n  const filterFields = isAggregateColDef(props.filterColDef)\n    ? getAggregateFields(props.filterColDef)\n    : [filterField.value];\n  if (!isFocusable(filterFields)) {\n    return undefined;\n  }\n  const action: MenuAction<FilterValueResponseOption> = {\n    icon: \"focus\",\n    isDisabled: (option) => {\n      const optionField = option.context?.colField || filterField.value;\n      return !isFocusable([optionField]);\n    },\n    tooltipText: (option) => {\n      const optionField = option.context?.colField || filterField.value;\n      if (!isFocusable([optionField])) {\n        const focusColName = getColDisplayNameForField(optionField);\n        return `Group by ${focusColName} to enable ${props.focusText}`;\n      }\n      // For aggregate columns, use raw value for focus comparison\n      const focusValue = isAggregate.value ? getRawFocusValue(option) : option.id;\n      const isFocusedOption = isFocused(focusValue, optionField);\n      if (isFocusedOption && !canRemoveFocus()) {\n        return `${props.focusText} (required)`;\n      }\n      return isFocusedOption ? `Remove ${props.focusText}` : `Select as ${props.focusText}`;\n    },\n    action: (option) => {\n      if (option && !selectedValues.value.includes(option.id)) {\n        addSelectedValue(option.id, option.context?.colField);\n      }\n      const fieldToFocus = option.context?.colField || filterField.value;\n      // For aggregate columns, store raw value in focus for chart comparison\n      const focusValue = isAggregate.value ? getRawFocusValue(option) : option.id;\n      handleFocusUpdate(focusValue, fieldToFocus);\n    },\n    alwaysShow: (option) => {\n      const optionField = option.context?.colField || filterField.value;\n      // For aggregate columns, use raw value for focus comparison\n      const focusValue = isAggregate.value ? getRawFocusValue(option) : option.id;\n      return isFocused(focusValue, optionField);\n    },\n  };\n  return action;\n});\n\n// Extract raw focus value from a value string (for non-option contexts)\nconst getRawFocusValueFromString = (value: string | null): string | null => {\n  if (!value) return null;\n  if (!isAggregate.value) return value;\n  const context = resolvedFilterValueContext(value);\n  if (context?.metadata?.rawValue != null) {\n    return String(context.metadata.rawValue);\n  }\n  if (value.startsWith(\"__\")) {\n    const rest = value.slice(2);\n    const parts = rest.split(\"__\");\n    if (parts.length >= 2) return parts[1];\n  }\n  return value;\n};\n\nconst handleRemoveSelectedValue = (value: string | null) => {\n  removeSelectedValue(value, undefined, \"remove_chip\");\n  const context = resolvedFilterValueContext(value);\n  const fieldToCheck = context?.colField || filterField.value;\n  const focusValue = getRawFocusValueFromString(value);\n  if (isFocused(focusValue, fieldToCheck) && canRemoveFocus()) {\n    removeFocus(focusValue);\n  }\n};\n\n// FilterGroupMenu only operates against the advanced filter model — gate its render\n// on this so we don't have to support the regular-filter path inside the component.\nconst enableAdvancedFilter = inject(EnableAdvancedFilterKey, ref(false));\n\nconst showFilterGroupMenu = computed(\n  () => !!colDefContext(props.filterColDef).filterGroup && enableAdvancedFilter.value,\n);\n\n// Timestamp captured when the dropdown opens; powers `dwell_ms` in the\n// filter_dropdown_closed RUM action. Reset to null when not open.\nlet openedAtMs: number | null = null;\n// Selection snapshot at open; compared at close for `selection_changed`\n// (opened-browsed-abandoned is a per-filter UX smell worth measuring).\nlet selectionAtOpen: string | null = null;\n\n// Serialize the current selection for change detection across open/close.\n// Aggregates track selection in cascadeSelectionState, not flat values.\n// Returns null (treated as \"unknown, assume unchanged\") on any error so\n// snapshotting can never break the dropdown lifecycle.\nconst selectionSnapshot = (): string | null => {\n  try {\n    return isAggregate.value\n      ? JSON.stringify(cascadeSelectionState.value)\n      : JSON.stringify([...selectedValues.value].sort());\n  } catch {\n    return null;\n  }\n};\n\nconst handleDropdownOpen = () => {\n  openedAtMs = Date.now();\n  selectionAtOpen = selectionSnapshot();\n  baseHandleDropdownOpen();\n  getLatestFilterValues(true);\n};\n\nconst handleDropdownClosed = () => {\n  // Capture everything synchronously, then emit on a deferred, error-isolated\n  // task so RUM can never interfere with the close/commit flow below.\n  const dwellMs = openedAtMs != null ? Date.now() - openedAtMs : 0;\n  openedAtMs = null;\n  const selectionAtClose = selectionSnapshot();\n  const selectionChanged = selectionAtOpen != null && selectionAtClose != null && selectionAtOpen !== selectionAtClose;\n  selectionAtOpen = null;\n  const selectionCount = selectedValues.value.length;\n  deferRumTask(() => {\n    addRumAction(\n      \"filter_dropdown_closed\",\n      {\n        filter_name: filterDisplayName.value,\n        filter_field: filterField.value,\n        selection_count: selectionCount,\n        selection_changed: selectionChanged,\n        dwell_ms: dwellMs,\n        location: rumLocation.value,\n      },\n      rumContext(),\n    );\n  });\n  nextTick(() => {\n    baseHandleDropdownClosed();\n    emits(\"filter-closed\");\n  });\n};\n\nconst isValueFocused = (value: string | null) => {\n  const context = resolvedFilterValueContext(value);\n  const fieldToCheck = context?.colField || filterField.value;\n  const focusValue = getRawFocusValueFromString(value);\n  return isFocused(focusValue, fieldToCheck);\n};\n\nconst hasSelectedFilterValues = computed(() => {\n  // If sub-filters in the filter group are applied, then those count as selected values and we return true.\n  if (filterGroupSelectedCount.value > 0) {\n    return true;\n  }\n\n  // If this is an aggregate filter, return true if at least 1 cascading selection has been made.\n  if (isAggregate.value) {\n    return cascadeSelectionState.value.length > 0;\n  }\n\n  // Otherwise, just check whether there are any plain old selectedValues.\n  return selectedValues.value.length > 0;\n});\n</script>\n\n<template>\n  <div>\n    <ul\n      v-if=\"isInFilterPanel && selectedValues.length > 0\"\n      role=\"list\"\n      class=\"pv-flex pv-stack-4\"\n      style=\"--flex-wrap: wrap; max-width: 100%\"\n    >\n      <template v-for=\"value in selectedValues\" :key=\"`${filterDisplayName}-${value}`\">\n        <li v-if=\"!isUnresolvedMetadataValue(value)\" style=\"max-width: 100%; line-height: 1rem\">\n          <PvTag\n            :label=\"formatDisplayValue(value) || ''\"\n            :showClear=\"!readOnly && (!isValueFocused(value) || canRemoveFocus())\"\n            :disabled=\"readOnly\"\n            @handle-close=\"handleRemoveSelectedValue(value)\"\n          />\n        </li>\n      </template>\n    </ul>\n    <PvMultiSelectButton\n      v-model=\"selectedFilterValues\"\n      :disabled=\"!isInFilterPanel && readOnly && disableUnselected && !hasSelectedFilterValues\"\n      v-model:searchInput=\"filterSearchText\"\n      v-model:selectionState=\"cascadeSelectionStateModel\"\n      :data-horizontal-filter-field=\"!isInFilterPanel ? filterField : undefined\"\n      :label=\"!isInFilterPanel ? filterDisplayName : ''\"\n      :rumFilterName=\"filterDisplayName\"\n      :highlightSearchText=\"true\"\n      :icon=\"isInFilterPanel && !readOnly ? 'add-circle' : undefined\"\n      :variant=\"isInFilterPanel ? 'ghost' : 'secondary'\"\n      :counterPosition=\"!isInFilterPanel && hasSelectedFilterValues ? undefined : 'none'\"\n      :singleSelect=\"isSingleSelect\"\n      :menuActionsVariant=\"readOnly || isSingleSelect ? null : 'select-clear'\"\n      :footerPosition=\"filterFooterPosition\"\n      :disableSearchInput=\"readOnly || !showSearchBar\"\n      :searchPlaceholder=\"filterSearchPlaceholder\"\n      :overlayTrigger=\"isInFilterPanel\"\n      :options=\"displayedFilterValues\"\n      :optionsRenderer=\"filterOptionsRenderer\"\n      :optionsAction=\"optionsAction\"\n      :popoverCssProperties=\"{\n        maxHeight: '400px',\n        maxWidth: isInFilterPanel ? '300px' : '400px',\n        overflowX: 'auto',\n        width: 'auto',\n      }\"\n      :disableClearIcon=\"!!isInFilterPanel || readOnly\"\n      :disableDropdownIcon=\"!!isInFilterPanel\"\n      :groupings=\"['preferences', 'suggestions']\"\n      :isLoading=\"isLoading\"\n      :loadingText=\"filterOptionsLoadingText\"\n      :isSeeMoreLoading=\"isSeeMoreLoading\"\n      :hasMoreOptions=\"hasMoreOptions\"\n      :totalOptionCount=\"totalOptionCount\"\n      :enableCascadeSelection=\"isAggregate\"\n      :enableChildExpansion=\"isAggregate\"\n      :parentSelectsAllChildren=\"isAggregate\"\n      :countSelectedParents=\"isAggregate\"\n      :additionalCounter=\"filterGroupSelectedCount\"\n      :slotContext=\"{ gridApi, filterColDef, rowsLoading }\"\n      @dropdown-open=\"handleDropdownOpen\"\n      @dropdown-closed=\"handleDropdownClosed\"\n      @see-more=\"handleSeeMore\"\n      @select-all=\"recordBulkAction('select_all', $event)\"\n      @clear-all=\"recordBulkAction('clear_all', $event)\"\n    >\n      <template v-if=\"filterHeaderRenderer || showFilterGroupMenu || belowFilterSearchMinLength\" #header=\"slotProps\">\n        <p\n          v-if=\"belowFilterSearchMinLength\"\n          class=\"pv-text-subdued pv-text-body-xxs pv-inset-inline\"\n          style=\"--inset-size: 4px\"\n        >\n          Type {{ filterSearchMinLength }} or more characters to search\n        </p>\n        <FilterGroupMenu\n          ref=\"filterGroupMenuRef\"\n          class=\"pv-stack-8\"\n          v-if=\"showFilterGroupMenu\"\n          :filter-col-def=\"filterColDef\"\n        />\n        <component v-if=\"filterHeaderRenderer\" :is=\"filterHeaderRenderer\" v-bind=\"slotProps\"></component>\n      </template>\n      <template #preferences>\n        <div class=\"pv-full-width pv-flex pv-space-between pv-inset-inline\" style=\"--inset-size: 8px\">\n          <p class=\"pv-text-subdued pv-text-body-xxs\">Your Preferences</p>\n          <PvTooltipV2 variant=\"dark\" size=\"sm\" :use-teleport=\"true\">\n            <template #trigger>\n              <PvButton\n                size=\"md\"\n                variant=\"ghost\"\n                @click=\"$emit('handle-settings-icon', filterDisplayName)\"\n                right-icon=\"sliders-horizontal\"\n              />\n            </template>\n            <template #content> Open Preferences </template>\n          </PvTooltipV2>\n        </div>\n      </template>\n      <template #suggestions>\n        <div class=\"pv-inset-inline\" style=\"--inset-size: 8px\">\n          <PvTooltipV2\n            variant=\"dark\"\n            :disableInteractive=\"true\"\n            position=\"top-left\"\n            size=\"sm\"\n            :use-teleport=\"true\"\n            style=\"--max-width: 200px\"\n          >\n            <template #trigger>\n              <p\n                class=\"pv-text-subdued pv-text-body-xxs\"\n                :class=\"filterOptionsSortTooltip ? 'pv-set-filter-suggested-title-label' : ''\"\n              >\n                {{ filterOptionsSortDescription }}\n              </p>\n            </template>\n            <template v-if=\"filterOptionsSortTooltip\" #content>\n              {{ filterOptionsSortTooltip }}\n            </template>\n          </PvTooltipV2>\n        </div>\n      </template>\n      <template v-if=\"emptyFilterResultsRenderer\" #no-results=\"slotProps\">\n        <component :is=\"emptyFilterResultsRenderer\" v-bind=\"slotProps\"></component>\n      </template>\n      <template v-if=\"filterFooterRenderer\" #footer=\"slotProps\">\n        <component :is=\"filterFooterRenderer\" v-bind=\"slotProps\"></component>\n      </template>\n    </PvMultiSelectButton>\n  </div>\n  <div v-if=\"isInFilterPanel && !readOnly\" class=\"pv-full-width\">\n    <div class=\"pv-flex-inline\" v-if=\"suggestedValues.length > 0\" style=\"max-width: 100%\">\n      <ul role=\"list\" class=\"pv-flex\" style=\"--flex-wrap: wrap; max-width: 100%\">\n        <PvTooltipV2\n          variant=\"dark\"\n          :disableInteractive=\"true\"\n          position=\"bottom-left\"\n          size=\"sm\"\n          :use-teleport=\"true\"\n          style=\"--max-width: 200px\"\n        >\n          <template #trigger>\n            <li class=\"pv-text-subdued pv-text-body-xxs\">\n              <p\n                class=\"pv-text-subdued pv-text-body-md\"\n                :class=\"filterOptionsSortTooltip ? 'pv-set-filter-suggested-title-label' : ''\"\n              >\n                Suggested:\n              </p>\n            </li>\n          </template>\n          <template v-if=\"filterOptionsSortTooltip\" #content>\n            {{ filterOptionsSortTooltip }}\n          </template>\n        </PvTooltipV2>\n        <li\n          v-for=\"value in suggestedValues.filter((v) => v !== '' && v != null).slice(0, maxSuggestionValueCount)\"\n          :key=\"`${filterDisplayName}-${value}-suggest`\"\n          :class=\"isLoading ? 'pv-shimmer' : ''\"\n          style=\"max-width: 100%; line-height: 1rem\"\n        >\n          <PvSuggestionTag\n            :disabled=\"isLoading\"\n            :label=\"formatDisplayValue(value) || ''\"\n            @handle-click=\"addSelectedValue(value, filterValueContext(filterField, value)?.colField)\"\n          />\n        </li>\n      </ul>\n    </div>\n  </div>\n</template>\n","export interface HorizontalFilterFitOptions {\n  /** Rendered width of each filter control, in display order. */\n  itemWidths: number[];\n  /** Width available to the filter row. */\n  containerWidth: number;\n  /** Width of the always-visible actions that follow the filters (0 if none). */\n  trailingWidth: number;\n  /** Flex gap between row children. */\n  gap: number;\n  /** Index of a filter that must stay visible when it fits (e.g. opened from a column menu). */\n  pinnedIndex?: number;\n}\n\n// Absorbs subpixel rounding between measured widths and the container width.\nconst FIT_TOLERANCE = 0.5;\n\n/**\n * Returns the indexes of the filters that fit on a single row alongside the trailing actions.\n * Filters collapse one at a time from the end; the pinned filter is kept ahead of the others.\n */\nexport const getVisibleFilterIndexes = ({\n  itemWidths,\n  containerWidth,\n  trailingWidth,\n  gap,\n  pinnedIndex,\n}: HorizontalFilterFitOptions): Set<number> => {\n  const visible = new Set<number>();\n  let usedWidth = trailingWidth;\n  let childCount = trailingWidth > 0 ? 1 : 0;\n\n  const tryAdd = (index: number) => {\n    const nextWidth = usedWidth + itemWidths[index] + (childCount > 0 ? gap : 0);\n    if (nextWidth > containerWidth + FIT_TOLERANCE) return false;\n    usedWidth = nextWidth;\n    childCount += 1;\n    visible.add(index);\n    return true;\n  };\n\n  const hasPinned = pinnedIndex !== undefined && pinnedIndex >= 0 && pinnedIndex < itemWidths.length;\n  if (hasPinned) tryAdd(pinnedIndex);\n\n  for (let index = 0; index < itemWidths.length; index++) {\n    if (hasPinned && index === pinnedIndex) continue;\n    if (!tryAdd(index)) break;\n  }\n\n  return visible;\n};\n","<script setup lang=\"ts\" generic=\"T\">\nimport SetFilter from \"@tables/PvDataTable/table-components/SetFilter.vue\";\nimport { computed, inject, onBeforeUnmount, onMounted, ref, type ComponentPublicInstance } from \"vue\";\nimport { AdvancedFilterModel } from \"ag-grid-enterprise\";\nimport { PvCounterBadge, PvDrawer, PvIcon, PvButton, PvModal, PvSearchInput } from \"@/components/base\";\nimport { useFilterStore } from \"@tables/PvDataTable/useFilterStore\";\nimport {\n  CurrentlyActiveFilterKey,\n  EnableAdvancedFilterKey,\n  GridApiKey,\n  AvailableFilterColumnsKey,\n} from \"@/components/tables/symbols\";\nimport { colDefContext, getAggregateFields, isAggregateColDef } from \"@tables/PvDataTable/helpers\";\nimport { hasSetFilter } from \"@tables/PvDataTable/filters/filterHelpers\";\nimport { useFocusStore } from \"@tables/PvDataTable/useFocus\";\nimport { getVisibleFilterIndexes } from \"@tables/PvDataTable/table-components/horizontalFilterFit\";\n\nexport interface FilterPanelProps {\n  enableFocusView?: boolean;\n  enableVerticalPanel?: boolean;\n  displayPreferencesIcon?: boolean;\n  focusableColumns?: string[];\n  focusText?: string;\n  maxHorizontalFilters: number;\n  readOnly?: boolean;\n  disableUnselectedFilters?: boolean;\n  wrapHorizontalFilters?: boolean;\n}\n\nconst gridApi = inject(GridApiKey, ref(null));\nconst availableFilterColumns = inject(AvailableFilterColumnsKey, ref([]));\nconst currentlyActiveFilter = inject(CurrentlyActiveFilterKey, ref(null));\nconst enableAdvancedFilter = inject(EnableAdvancedFilterKey, ref(false));\n\ndefineEmits<{\n  (e: \"handle-settings-icon\", value: string): void;\n}>();\n\nconst props = withDefaults(defineProps<FilterPanelProps>(), {\n  enableFocusView: false,\n  enableVerticalPanel: true,\n  displayPreferencesIcon: false,\n  focusableColumns: () => [],\n  focusText: \"Focus\",\n  maxHorizontalFilters: 5,\n  readOnly: false,\n  disableUnselectedFilters: false,\n  wrapHorizontalFilters: false,\n});\nconst filterStore = useFilterStore();\nconst {\n  filterModelCleared,\n  stagedFilterModel,\n  filterModel,\n  initStagedSelectedValues,\n  clearStagedSelectedValues,\n  commitStagedFilterModelChanges,\n  clearStagedFilterModelChanges,\n  filterValuesMap,\n  fetchFilterValues,\n  filterValuesLoadingStatus,\n} = filterStore;\nconst filterDrawerOpen = ref(false);\nconst showClearModal = ref(false);\nconst filterPanelSearchText = ref(\"\");\n\nconst aggregateFilterColIds = computed(() => {\n  return availableFilterColumns.value.flatMap((col) => getAggregateFields(col));\n});\n\n// If any of our available filter columns has a filter group, then return the list of that filter group's col ids.\nconst filterGroupColIds = computed(() => {\n  return availableFilterColumns.value.flatMap((col) => colDefContext(col).filterGroup?.fields ?? []);\n});\n\n// Checks whether a column has an active filter selection (used to hide the\n// expand carat for empty filters in read-only mode).\nconst colHasActiveFilter = (col: (typeof availableFilterColumns.value)[number]): boolean => {\n  const model = filterModel.value;\n  if (!model) return false;\n  const fields = isAggregateColDef(col) ? getAggregateFields(col) : [col.field || \"\"];\n  if (enableAdvancedFilter.value) {\n    const colIds = new Set<string>();\n    collectAdvancedFilterColIds(model, colIds);\n    return fields.some((f) => colIds.has(f));\n  }\n  const regularModel = model as Record<string, unknown>;\n  return fields.some((f) => !!regularModel[f]);\n};\n\n// In read-only mode, empty filters are shown but are not expandable (their\n// carat is hidden). This is independent of `disableUnselectedFilters`, which\n// only controls whether the dropdown-bar buttons are disabled.\nconst isEmptyReadOnlyFilter = (col: (typeof availableFilterColumns.value)[number]): boolean => {\n  return props.readOnly && !colHasActiveFilter(col);\n};\n\nconst filtersToDisplay = computed(() => {\n  const filters = availableFilterColumns.value.filter((col) => {\n    return (\n      hasSetFilter(col) &&\n      !aggregateFilterColIds.value.includes(col.field || \"\") &&\n      !filterGroupColIds.value.includes(col.field || \"\")\n    );\n  });\n  // Place aggregate filters at the front\n  return filters.sort((a, b) => {\n    const aIsAggregate = isAggregateColDef(a);\n    const bIsAggregate = isAggregateColDef(b);\n    if (aIsAggregate && !bIsAggregate) return -1;\n    if (!aIsAggregate && bIsAggregate) return 1;\n    return 0;\n  });\n});\n\nconst verticalPanelFilters = computed(() => {\n  return filtersToDisplay.value;\n});\n\nconst filteredVerticalPanelFilters = computed(() => {\n  const queryText = filterPanelSearchText.value?.trim().toLowerCase() || \"\";\n  if (!queryText || queryText === \"\") return verticalPanelFilters.value;\n  return availableFilterColumns.value.filter((col) => {\n    const colName = col.headerName?.toLowerCase() || col.field?.toLowerCase();\n    if (!colName) return false;\n    return colName.includes(queryText);\n  });\n});\n\nconst horizontalFilterFields = computed(() => {\n  // restrict to set filters for now\n  const availableSetFilterColumns = filtersToDisplay.value;\n  const limit = Math.max(0, props.maxHorizontalFilters);\n  const defaultFilters = availableSetFilterColumns.slice(0, limit);\n  // an active filter outside the default set takes the last slot, up to max horizontal filter limit\n  const activeFilter = currentlyActiveFilter.value;\n  if (!activeFilter || defaultFilters.some((col) => col.field === activeFilter.field)) return defaultFilters;\n  const otherFilters = availableSetFilterColumns.filter((col) => col.field !== activeFilter.field);\n  return [...otherFilters.slice(0, Math.max(0, limit - 1)), activeFilter];\n});\n\n// Unless wrapping is requested, horizontal filters stay on one row and collapse\n// from the end as the row narrows; collapsed filters remain in the All Filters drawer,\n// so collapsing needs the drawer. Without it the row wraps instead.\n// Collapsed filters stay mounted (hidden and out of flow) so their widths stay measurable.\nconst collapseHorizontalFilters = computed(() => !props.wrapHorizontalFilters && props.enableVerticalPanel);\nconst filterRowRef = ref<HTMLElement | null>(null);\nconst filterActionsRef = ref<HTMLElement | null>(null);\nconst filterItemElements = new Map<string, HTMLElement>();\nconst filterRowMeasured = ref(false);\nconst filterRowWidth = ref(0);\nconst filterRowGap = ref(0);\nconst filterActionsWidth = ref(0);\nconst filterItemWidths = ref<Record<string, number>>({});\nlet filterRowObserver: ResizeObserver | null = null;\nlet measureFrame: number | null = null;\n\nconst measureFilterRow = () => {\n  const row = filterRowRef.value;\n  if (!row) return;\n  // A row without layout boxes (display: none, or no layout engine) has nothing meaningful to fit.\n  filterRowMeasured.value = row.getClientRects().length > 0;\n  filterRowWidth.value = row.clientWidth;\n  filterRowGap.value = parseFloat(getComputedStyle(row).columnGap) || 0;\n  filterActionsWidth.value = filterActionsRef.value?.getBoundingClientRect().width ?? 0;\n  const widths: Record<string, number> = {};\n  filterItemElements.forEach((element, field) => {\n    widths[field] = element.getBoundingClientRect().width;\n  });\n  filterItemWidths.value = widths;\n};\n\n// Collapsing changes the size of observed elements, so measure on the next frame\n// instead of inside the observer callback to avoid a ResizeObserver loop.\nconst scheduleFilterRowMeasure = () => {\n  if (measureFrame !== null) return;\n  measureFrame = requestAnimationFrame(() => {\n    measureFrame = null;\n    measureFilterRow();\n  });\n};\n\nconst setFilterItemRef = (field: string, element: Element | ComponentPublicInstance | null) => {\n  const previous = filterItemElements.get(field);\n  if (previous === element) return;\n  if (previous) {\n    filterRowObserver?.unobserve(previous);\n    filterItemElements.delete(field);\n  }\n  if (element instanceof HTMLElement) {\n    filterItemElements.set(field, element);\n    filterRowObserver?.observe(element);\n  }\n};\n\nonMounted(() => {\n  if (typeof ResizeObserver === \"undefined\") return;\n  filterRowObserver = new ResizeObserver(scheduleFilterRowMeasure);\n  if (filterRowRef.value) filterRowObserver.observe(filterRowRef.value);\n  if (filterActionsRef.value) filterRowObserver.observe(filterActionsRef.value);\n  filterItemElements.forEach((element) => filterRowObserver?.observe(element));\n});\n\nonBeforeUnmount(() => {\n  filterRowObserver?.disconnect();\n  filterRowObserver = null;\n  if (measureFrame !== null) cancelAnimationFrame(measureFrame);\n  measureFrame = null;\n});\n\nconst visibleHorizontalFilterFields = computed(() => {\n  const fields = horizontalFilterFields.value.map((col) => col.field || \"\");\n  const activeIndex = currentlyActiveFilter.value ? fields.indexOf(currentlyActiveFilter.value.field || \"\") : -1;\n  // Before layout (or without layout, e.g. jsdom), show everything rather than collapsing to nothing.\n  if (!collapseHorizontalFilters.value || !filterRowMeasured.value) return new Set(fields);\n  const visibleIndexes = getVisibleFilterIndexes({\n    itemWidths: fields.map((field) => filterItemWidths.value[field] ?? 0),\n    containerWidth: filterRowWidth.value,\n    trailingWidth: filterActionsWidth.value,\n    gap: filterRowGap.value,\n    pinnedIndex: activeIndex >= 0 ? activeIndex : undefined,\n  });\n  return new Set(fields.filter((_, index) => visibleIndexes.has(index)));\n});\n\nconst collectAdvancedFilterColIds = (model: unknown, colIds: Set<string>): void => {\n  if (!model || typeof model !== \"object\") return;\n  const filterModel = model as { filterType?: string; conditions?: unknown[]; colId?: string };\n\n  // If it's a column condition (has colId), add to set\n  if (filterModel.filterType && filterModel.filterType !== \"join\" && filterModel.colId) {\n    colIds.add(filterModel.colId);\n    return;\n  }\n\n  // If it's a join condition, recursively collect from all conditions\n  if (filterModel.filterType === \"join\" && Array.isArray(filterModel.conditions)) {\n    filterModel.conditions.forEach((condition) => collectAdvancedFilterColIds(condition, colIds));\n  }\n};\n\nconst activeFilterCount = computed(() => {\n  const model = filterModel.value;\n  if (enableAdvancedFilter.value && gridApi.value) {\n    const colIds = new Set<string>();\n    collectAdvancedFilterColIds(model, colIds);\n    return colIds.size;\n  }\n  const filters = filterModel.value || {};\n  return Object.keys(filters).length;\n});\n\nconst filterPanelChanged = ref(false);\n\nconst handleFilterSelectionChanged = () => {\n  filterPanelChanged.value = true;\n};\n\nconst openVerticalDrawer = () => {\n  if (!gridApi.value) return;\n  filterPanelChanged.value = false;\n  clearStagedFilterModelChanges();\n  initStagedSelectedValues();\n  if (enableAdvancedFilter.value) {\n    stagedFilterModel.value = gridApi.value.getAdvancedFilterModel();\n  } else {\n    stagedFilterModel.value = gridApi.value.getFilterModel();\n  }\n  filterDrawerOpen.value = true;\n\n  // Seed missing filter values for all vertical panel filters\n  for (const col of verticalPanelFilters.value) {\n    const field = col.field;\n    if (!field) continue;\n    const hasValues = (filterValuesMap.value[field] || []).length > 0;\n    const isLoading = filterValuesLoadingStatus.value[field] === true;\n    if (!hasValues && !isLoading) {\n      fetchFilterValues(col, { api: gridApi.value, filterModel: filterModel.value ?? undefined, useStaged: true });\n    }\n  }\n};\n\nconst { clearAllFocuses } = useFocusStore();\n\nconst clearAllFilters = () => {\n  if (!gridApi.value) return;\n  clearStagedFilterModelChanges();\n  stagedFilterModel.value = null;\n  if (enableAdvancedFilter.value) {\n    gridApi.value.setAdvancedFilterModel(null);\n  } else {\n    gridApi.value.setFilterModel(null);\n    gridApi.value.onFilterChanged();\n  }\n  filterModelCleared.value += 1;\n  clearAllFocuses();\n  showClearModal.value = false;\n};\n\nconst closeFilterDrawer = () => {\n  filterDrawerOpen.value = false;\n  filterPanelSearchText.value = \"\";\n};\n\nconst cancelModifiedFilters = () => {\n  clearStagedSelectedValues();\n  clearStagedFilterModelChanges();\n  stagedFilterModel.value = null;\n  closeFilterDrawer();\n};\n\nconst applyModifiedFilters = () => {\n  clearStagedSelectedValues();\n  if (filterPanelChanged.value && gridApi.value) {\n    commitStagedFilterModelChanges();\n    if (enableAdvancedFilter.value) {\n      gridApi.value.setAdvancedFilterModel(stagedFilterModel.value as AdvancedFilterModel | null);\n    } else {\n      gridApi.value.setFilterModel(stagedFilterModel.value);\n      gridApi.value.onFilterChanged();\n    }\n  }\n  stagedFilterModel.value = null;\n  closeFilterDrawer();\n};\n// Lookups are scoped to this panel's row so filters from other tables on the page never match.\nconst findHorizontalFilter = (field: string) =>\n  filterRowRef.value?.querySelector(`[data-horizontal-filter-field=\"${field}\"]`) ?? null;\n\n// Opens the horizontal filter for `field`. Returns false when it is missing or collapsed.\nconst openHorizontalFilter = (field: string) => {\n  const filterElement = findHorizontalFilter(field);\n  // Collapsed filters are inert; pinning them as the active filter brings them back.\n  const button = filterElement?.closest(\"[inert]\") ? null : filterElement?.querySelector(\"button\");\n  button?.click();\n  return !!button;\n};\n\nconst isHorizontalFilterCollapsed = (field: string) => !!findHorizontalFilter(field)?.closest(\"[inert]\");\n\ndefineExpose({ openVerticalDrawer, openHorizontalFilter, isHorizontalFilterCollapsed });\n</script>\n\n<template>\n  <div\n    ref=\"filterRowRef\"\n    class=\"pv-flex\"\n    :class=\"{ 'pv-filter-panel-collapsible': collapseHorizontalFilters }\"\n    :style=\"\n      collapseHorizontalFilters ? { minWidth: `${filterActionsWidth}px` } : { '--flex-wrap': 'wrap', maxWidth: '100%' }\n    \"\n  >\n    <template v-for=\"filterCol in horizontalFilterFields\" :key=\"filterCol.field\">\n      <div\n        v-if=\"gridApi\"\n        :ref=\"(element) => setFilterItemRef(filterCol.field || '', element)\"\n        class=\"pv-filter-panel-item\"\n        :class=\"{ 'pv-filter-panel-item-collapsed': !visibleHorizontalFilterFields.has(filterCol.field || '') }\"\n        :inert=\"!visibleHorizontalFilterFields.has(filterCol.field || '') || undefined\"\n      >\n        <SetFilter\n          :enable-focus-view=\"props.enableFocusView\"\n          :display-preferences-icon=\"props.displayPreferencesIcon\"\n          :focus-text=\"props.focusText\"\n          :filterColDef=\"filterCol\"\n          :read-only=\"props.readOnly\"\n          :disable-unselected=\"props.disableUnselectedFilters\"\n          @handle-settings-icon=\"$emit('handle-settings-icon', $event)\"\n        ></SetFilter>\n      </div>\n    </template>\n    <div ref=\"filterActionsRef\" class=\"pv-flex\" style=\"flex-shrink: 0\">\n      <PvButton\n        v-if=\"props.enableVerticalPanel\"\n        label=\"All Filters\"\n        @click=\"openVerticalDrawer\"\n        variant=\"ghost\"\n        left-icon=\"filter\"\n        data-dd-action-name=\"Open All Filters drawer\"\n        :right-counter-badge=\"props.readOnly && activeFilterCount > 0 ? activeFilterCount : undefined\"\n      />\n      <button\n        v-if=\"activeFilterCount > 0 && !props.readOnly\"\n        class=\"pv-button-ghost\"\n        data-dd-action-name=\"Clear all page filters\"\n        @click=\"showClearModal = true\"\n      >\n        <PvIcon name=\"close\"></PvIcon> Clear All Filters\n        <PvCounterBadge v-if=\"activeFilterCount > 0\" :value=\"activeFilterCount\" variant=\"tertiary\" />\n      </button>\n    </div>\n    <PvDrawer\n      v-if=\"props.enableVerticalPanel\"\n      v-model=\"filterDrawerOpen\"\n      class=\"pv-drawer pv-surface\"\n      :close-on-click-outside=\"true\"\n      @click-outside=\"applyModifiedFilters()\"\n      style=\"max-width: 450px; z-index: 10\"\n    >\n      <template #header>\n        <div class=\"pv-flex pv-space-between pv-stack-8\">\n          <p class=\"pv-text-title-lg\">All Filters ({{ verticalPanelFilters.length }})</p>\n          <button class=\"pv-button-ghost\" aria-label=\"Close\" @click=\"cancelModifiedFilters()\">\n            <PvIcon name=\"close\"></PvIcon>\n          </button>\n        </div>\n        <PvSearchInput v-model=\"filterPanelSearchText\" placeholder=\"Search Filters\" />\n      </template>\n      <div\n        id=\"filter-vertical-drawer\"\n        class=\"pv-flex-vertical pv-space-between pv-full-width pv-inset-block-16\"\n        style=\"height: 100%\"\n      >\n        <div class=\"pv-full-width\">\n          <div\n            v-for=\"(filterCol, index) in filteredVerticalPanelFilters\"\n            :key=\"filterCol.field\"\n            :class=\"{\n              'pv-border-bottom': index < filteredVerticalPanelFilters.length - 1,\n            }\"\n            class=\"pv-stack-12\"\n          >\n            <details\n              class=\"pv-details pv-stack-12\"\n              :class=\"{ 'pv-details-no-carat': isEmptyReadOnlyFilter(filterCol) }\"\n              :open=\"!isEmptyReadOnlyFilter(filterCol)\"\n            >\n              <summary\n                class=\"pv-flex pv-full-width\"\n                :data-dd-action-name=\"`Expand ${filterCol.headerName} section`\"\n                @click=\"isEmptyReadOnlyFilter(filterCol) && $event.preventDefault()\"\n              >\n                <span class=\"pv-text-title-lg\">\n                  {{ filterCol.headerName }}\n                </span>\n              </summary>\n              <div>\n                <SetFilter\n                  v-if=\"gridApi\"\n                  filter-style=\"vertical\"\n                  :enable-focus-view=\"props.enableFocusView\"\n                  :filterColDef=\"filterCol\"\n                  :display-preferences-icon=\"props.displayPreferencesIcon\"\n                  :focus-text=\"props.focusText\"\n                  :read-only=\"props.readOnly\"\n                  :disable-unselected=\"props.disableUnselectedFilters\"\n                  @filter-selection-changed=\"handleFilterSelectionChanged\"\n                  @handle-settings-icon=\"$emit('handle-settings-icon', $event)\"\n                />\n              </div>\n            </details>\n          </div>\n        </div>\n      </div>\n      <template #footer>\n        <div class=\"pv-flex pv-space-between\">\n          <template v-if=\"!props.readOnly\">\n            <button class=\"pv-button-ghost\" data-dd-action-name=\"Clear all page filters\" @click=\"clearAllFilters()\">\n              Clear All\n            </button>\n            <div class=\"pv-flex\">\n              <PvButton\n                variant=\"ghost\"\n                label=\"Cancel\"\n                data-dd-action-name=\"Cancel filter changes\"\n                @click=\"cancelModifiedFilters()\"\n              />\n              <PvButton\n                v-if=\"filterPanelChanged\"\n                variant=\"primary\"\n                label=\"Apply\"\n                data-dd-action-name=\"Apply filters\"\n                @click=\"applyModifiedFilters()\"\n              />\n              <PvButton v-else variant=\"primary\" label=\"No Changes\" disabled />\n            </div>\n          </template>\n          <template v-else>\n            <PvButton variant=\"ghost\" label=\"Close\" @click=\"cancelModifiedFilters()\" />\n          </template>\n        </div>\n      </template>\n    </PvDrawer>\n  </div>\n  <PvModal v-model=\"showClearModal\" header=\"Clear All Filters\">\n    <template #body>\n      <p class=\"pv-text-body-lg\">This action will remove all currently applied filters. Would you like to continue?</p>\n    </template>\n    <template #footer>\n      <div class=\"pv-flex\" style=\"--flex-justify: end; --flex-gap: 8px; margin-top: auto\">\n        <PvButton\n          label=\"Cancel\"\n          variant=\"secondary\"\n          size=\"lg\"\n          data-dd-action-name=\"Cancel clear all filters\"\n          @click=\"showClearModal = false\"\n        />\n        <PvButton\n          label=\"Clear All Filters\"\n          variant=\"primary\"\n          size=\"lg\"\n          data-dd-action-name=\"Confirm clear all filters\"\n          @click=\"clearAllFilters\"\n        />\n      </div>\n    </template>\n  </PvModal>\n</template>\n\n<style scoped>\n.pv-filter-panel-collapsible {\n  /* Fill the space the surrounding row leaves over; min-width (inline) keeps the actions visible. */\n  flex: 1 1 0;\n  position: relative;\n  /* Size from the parent, not the filters, so a parent with an auto min-width shrinks only to min-width. */\n  contain: inline-size;\n}\n\n.pv-filter-panel-item {\n  flex-shrink: 0;\n}\n\n.pv-filter-panel-item-collapsed {\n  left: 0;\n  pointer-events: none;\n  position: absolute;\n  top: 0;\n  visibility: hidden;\n  width: max-content;\n}\n\n.pv-details-no-carat > summary {\n  background-image: none;\n  cursor: default;\n}\n</style>\n","<script setup lang=\"ts\" generic=\"T\">\nimport SetFilter from \"@tables/PvDataTable/table-components/SetFilter.vue\";\nimport { computed, inject, onBeforeUnmount, onMounted, ref, type ComponentPublicInstance } from \"vue\";\nimport { AdvancedFilterModel } from \"ag-grid-enterprise\";\nimport { PvCounterBadge, PvDrawer, PvIcon, PvButton, PvModal, PvSearchInput } from \"@/components/base\";\nimport { useFilterStore } from \"@tables/PvDataTable/useFilterStore\";\nimport {\n  CurrentlyActiveFilterKey,\n  EnableAdvancedFilterKey,\n  GridApiKey,\n  AvailableFilterColumnsKey,\n} from \"@/components/tables/symbols\";\nimport { colDefContext, getAggregateFields, isAggregateColDef } from \"@tables/PvDataTable/helpers\";\nimport { hasSetFilter } from \"@tables/PvDataTable/filters/filterHelpers\";\nimport { useFocusStore } from \"@tables/PvDataTable/useFocus\";\nimport { getVisibleFilterIndexes } from \"@tables/PvDataTable/table-components/horizontalFilterFit\";\n\nexport interface FilterPanelProps {\n  enableFocusView?: boolean;\n  enableVerticalPanel?: boolean;\n  displayPreferencesIcon?: boolean;\n  focusableColumns?: string[];\n  focusText?: string;\n  maxHorizontalFilters: number;\n  readOnly?: boolean;\n  disableUnselectedFilters?: boolean;\n  wrapHorizontalFilters?: boolean;\n}\n\nconst gridApi = inject(GridApiKey, ref(null));\nconst availableFilterColumns = inject(AvailableFilterColumnsKey, ref([]));\nconst currentlyActiveFilter = inject(CurrentlyActiveFilterKey, ref(null));\nconst enableAdvancedFilter = inject(EnableAdvancedFilterKey, ref(false));\n\ndefineEmits<{\n  (e: \"handle-settings-icon\", value: string): void;\n}>();\n\nconst props = withDefaults(defineProps<FilterPanelProps>(), {\n  enableFocusView: false,\n  enableVerticalPanel: true,\n  displayPreferencesIcon: false,\n  focusableColumns: () => [],\n  focusText: \"Focus\",\n  maxHorizontalFilters: 5,\n  readOnly: false,\n  disableUnselectedFilters: false,\n  wrapHorizontalFilters: false,\n});\nconst filterStore = useFilterStore();\nconst {\n  filterModelCleared,\n  stagedFilterModel,\n  filterModel,\n  initStagedSelectedValues,\n  clearStagedSelectedValues,\n  commitStagedFilterModelChanges,\n  clearStagedFilterModelChanges,\n  filterValuesMap,\n  fetchFilterValues,\n  filterValuesLoadingStatus,\n} = filterStore;\nconst filterDrawerOpen = ref(false);\nconst showClearModal = ref(false);\nconst filterPanelSearchText = ref(\"\");\n\nconst aggregateFilterColIds = computed(() => {\n  return availableFilterColumns.value.flatMap((col) => getAggregateFields(col));\n});\n\n// If any of our available filter columns has a filter group, then return the list of that filter group's col ids.\nconst filterGroupColIds = computed(() => {\n  return availableFilterColumns.value.flatMap((col) => colDefContext(col).filterGroup?.fields ?? []);\n});\n\n// Checks whether a column has an active filter selection (used to hide the\n// expand carat for empty filters in read-only mode).\nconst colHasActiveFilter = (col: (typeof availableFilterColumns.value)[number]): boolean => {\n  const model = filterModel.value;\n  if (!model) return false;\n  const fields = isAggregateColDef(col) ? getAggregateFields(col) : [col.field || \"\"];\n  if (enableAdvancedFilter.value) {\n    const colIds = new Set<string>();\n    collectAdvancedFilterColIds(model, colIds);\n    return fields.some((f) => colIds.has(f));\n  }\n  const regularModel = model as Record<string, unknown>;\n  return fields.some((f) => !!regularModel[f]);\n};\n\n// In read-only mode, empty filters are shown but are not expandable (their\n// carat is hidden). This is independent of `disableUnselectedFilters`, which\n// only controls whether the dropdown-bar buttons are disabled.\nconst isEmptyReadOnlyFilter = (col: (typeof availableFilterColumns.value)[number]): boolean => {\n  return props.readOnly && !colHasActiveFilter(col);\n};\n\nconst filtersToDisplay = computed(() => {\n  const filters = availableFilterColumns.value.filter((col) => {\n    return (\n      hasSetFilter(col) &&\n      !aggregateFilterColIds.value.includes(col.field || \"\") &&\n      !filterGroupColIds.value.includes(col.field || \"\")\n    );\n  });\n  // Place aggregate filters at the front\n  return filters.sort((a, b) => {\n    const aIsAggregate = isAggregateColDef(a);\n    const bIsAggregate = isAggregateColDef(b);\n    if (aIsAggregate && !bIsAggregate) return -1;\n    if (!aIsAggregate && bIsAggregate) return 1;\n    return 0;\n  });\n});\n\nconst verticalPanelFilters = computed(() => {\n  return filtersToDisplay.value;\n});\n\nconst filteredVerticalPanelFilters = computed(() => {\n  const queryText = filterPanelSearchText.value?.trim().toLowerCase() || \"\";\n  if (!queryText || queryText === \"\") return verticalPanelFilters.value;\n  return availableFilterColumns.value.filter((col) => {\n    const colName = col.headerName?.toLowerCase() || col.field?.toLowerCase();\n    if (!colName) return false;\n    return colName.includes(queryText);\n  });\n});\n\nconst horizontalFilterFields = computed(() => {\n  // restrict to set filters for now\n  const availableSetFilterColumns = filtersToDisplay.value;\n  const limit = Math.max(0, props.maxHorizontalFilters);\n  const defaultFilters = availableSetFilterColumns.slice(0, limit);\n  // an active filter outside the default set takes the last slot, up to max horizontal filter limit\n  const activeFilter = currentlyActiveFilter.value;\n  if (!activeFilter || defaultFilters.some((col) => col.field === activeFilter.field)) return defaultFilters;\n  const otherFilters = availableSetFilterColumns.filter((col) => col.field !== activeFilter.field);\n  return [...otherFilters.slice(0, Math.max(0, limit - 1)), activeFilter];\n});\n\n// Unless wrapping is requested, horizontal filters stay on one row and collapse\n// from the end as the row narrows; collapsed filters remain in the All Filters drawer,\n// so collapsing needs the drawer. Without it the row wraps instead.\n// Collapsed filters stay mounted (hidden and out of flow) so their widths stay measurable.\nconst collapseHorizontalFilters = computed(() => !props.wrapHorizontalFilters && props.enableVerticalPanel);\nconst filterRowRef = ref<HTMLElement | null>(null);\nconst filterActionsRef = ref<HTMLElement | null>(null);\nconst filterItemElements = new Map<string, HTMLElement>();\nconst filterRowMeasured = ref(false);\nconst filterRowWidth = ref(0);\nconst filterRowGap = ref(0);\nconst filterActionsWidth = ref(0);\nconst filterItemWidths = ref<Record<string, number>>({});\nlet filterRowObserver: ResizeObserver | null = null;\nlet measureFrame: number | null = null;\n\nconst measureFilterRow = () => {\n  const row = filterRowRef.value;\n  if (!row) return;\n  // A row without layout boxes (display: none, or no layout engine) has nothing meaningful to fit.\n  filterRowMeasured.value = row.getClientRects().length > 0;\n  filterRowWidth.value = row.clientWidth;\n  filterRowGap.value = parseFloat(getComputedStyle(row).columnGap) || 0;\n  filterActionsWidth.value = filterActionsRef.value?.getBoundingClientRect().width ?? 0;\n  const widths: Record<string, number> = {};\n  filterItemElements.forEach((element, field) => {\n    widths[field] = element.getBoundingClientRect().width;\n  });\n  filterItemWidths.value = widths;\n};\n\n// Collapsing changes the size of observed elements, so measure on the next frame\n// instead of inside the observer callback to avoid a ResizeObserver loop.\nconst scheduleFilterRowMeasure = () => {\n  if (measureFrame !== null) return;\n  measureFrame = requestAnimationFrame(() => {\n    measureFrame = null;\n    measureFilterRow();\n  });\n};\n\nconst setFilterItemRef = (field: string, element: Element | ComponentPublicInstance | null) => {\n  const previous = filterItemElements.get(field);\n  if (previous === element) return;\n  if (previous) {\n    filterRowObserver?.unobserve(previous);\n    filterItemElements.delete(field);\n  }\n  if (element instanceof HTMLElement) {\n    filterItemElements.set(field, element);\n    filterRowObserver?.observe(element);\n  }\n};\n\nonMounted(() => {\n  if (typeof ResizeObserver === \"undefined\") return;\n  filterRowObserver = new ResizeObserver(scheduleFilterRowMeasure);\n  if (filterRowRef.value) filterRowObserver.observe(filterRowRef.value);\n  if (filterActionsRef.value) filterRowObserver.observe(filterActionsRef.value);\n  filterItemElements.forEach((element) => filterRowObserver?.observe(element));\n});\n\nonBeforeUnmount(() => {\n  filterRowObserver?.disconnect();\n  filterRowObserver = null;\n  if (measureFrame !== null) cancelAnimationFrame(measureFrame);\n  measureFrame = null;\n});\n\nconst visibleHorizontalFilterFields = computed(() => {\n  const fields = horizontalFilterFields.value.map((col) => col.field || \"\");\n  const activeIndex = currentlyActiveFilter.value ? fields.indexOf(currentlyActiveFilter.value.field || \"\") : -1;\n  // Before layout (or without layout, e.g. jsdom), show everything rather than collapsing to nothing.\n  if (!collapseHorizontalFilters.value || !filterRowMeasured.value) return new Set(fields);\n  const visibleIndexes = getVisibleFilterIndexes({\n    itemWidths: fields.map((field) => filterItemWidths.value[field] ?? 0),\n    containerWidth: filterRowWidth.value,\n    trailingWidth: filterActionsWidth.value,\n    gap: filterRowGap.value,\n    pinnedIndex: activeIndex >= 0 ? activeIndex : undefined,\n  });\n  return new Set(fields.filter((_, index) => visibleIndexes.has(index)));\n});\n\nconst collectAdvancedFilterColIds = (model: unknown, colIds: Set<string>): void => {\n  if (!model || typeof model !== \"object\") return;\n  const filterModel = model as { filterType?: string; conditions?: unknown[]; colId?: string };\n\n  // If it's a column condition (has colId), add to set\n  if (filterModel.filterType && filterModel.filterType !== \"join\" && filterModel.colId) {\n    colIds.add(filterModel.colId);\n    return;\n  }\n\n  // If it's a join condition, recursively collect from all conditions\n  if (filterModel.filterType === \"join\" && Array.isArray(filterModel.conditions)) {\n    filterModel.conditions.forEach((condition) => collectAdvancedFilterColIds(condition, colIds));\n  }\n};\n\nconst activeFilterCount = computed(() => {\n  const model = filterModel.value;\n  if (enableAdvancedFilter.value && gridApi.value) {\n    const colIds = new Set<string>();\n    collectAdvancedFilterColIds(model, colIds);\n    return colIds.size;\n  }\n  const filters = filterModel.value || {};\n  return Object.keys(filters).length;\n});\n\nconst filterPanelChanged = ref(false);\n\nconst handleFilterSelectionChanged = () => {\n  filterPanelChanged.value = true;\n};\n\nconst openVerticalDrawer = () => {\n  if (!gridApi.value) return;\n  filterPanelChanged.value = false;\n  clearStagedFilterModelChanges();\n  initStagedSelectedValues();\n  if (enableAdvancedFilter.value) {\n    stagedFilterModel.value = gridApi.value.getAdvancedFilterModel();\n  } else {\n    stagedFilterModel.value = gridApi.value.getFilterModel();\n  }\n  filterDrawerOpen.value = true;\n\n  // Seed missing filter values for all vertical panel filters\n  for (const col of verticalPanelFilters.value) {\n    const field = col.field;\n    if (!field) continue;\n    const hasValues = (filterValuesMap.value[field] || []).length > 0;\n    const isLoading = filterValuesLoadingStatus.value[field] === true;\n    if (!hasValues && !isLoading) {\n      fetchFilterValues(col, { api: gridApi.value, filterModel: filterModel.value ?? undefined, useStaged: true });\n    }\n  }\n};\n\nconst { clearAllFocuses } = useFocusStore();\n\nconst clearAllFilters = () => {\n  if (!gridApi.value) return;\n  clearStagedFilterModelChanges();\n  stagedFilterModel.value = null;\n  if (enableAdvancedFilter.value) {\n    gridApi.value.setAdvancedFilterModel(null);\n  } else {\n    gridApi.value.setFilterModel(null);\n    gridApi.value.onFilterChanged();\n  }\n  filterModelCleared.value += 1;\n  clearAllFocuses();\n  showClearModal.value = false;\n};\n\nconst closeFilterDrawer = () => {\n  filterDrawerOpen.value = false;\n  filterPanelSearchText.value = \"\";\n};\n\nconst cancelModifiedFilters = () => {\n  clearStagedSelectedValues();\n  clearStagedFilterModelChanges();\n  stagedFilterModel.value = null;\n  closeFilterDrawer();\n};\n\nconst applyModifiedFilters = () => {\n  clearStagedSelectedValues();\n  if (filterPanelChanged.value && gridApi.value) {\n    commitStagedFilterModelChanges();\n    if (enableAdvancedFilter.value) {\n      gridApi.value.setAdvancedFilterModel(stagedFilterModel.value as AdvancedFilterModel | null);\n    } else {\n      gridApi.value.setFilterModel(stagedFilterModel.value);\n      gridApi.value.onFilterChanged();\n    }\n  }\n  stagedFilterModel.value = null;\n  closeFilterDrawer();\n};\n// Lookups are scoped to this panel's row so filters from other tables on the page never match.\nconst findHorizontalFilter = (field: string) =>\n  filterRowRef.value?.querySelector(`[data-horizontal-filter-field=\"${field}\"]`) ?? null;\n\n// Opens the horizontal filter for `field`. Returns false when it is missing or collapsed.\nconst openHorizontalFilter = (field: string) => {\n  const filterElement = findHorizontalFilter(field);\n  // Collapsed filters are inert; pinning them as the active filter brings them back.\n  const button = filterElement?.closest(\"[inert]\") ? null : filterElement?.querySelector(\"button\");\n  button?.click();\n  return !!button;\n};\n\nconst isHorizontalFilterCollapsed = (field: string) => !!findHorizontalFilter(field)?.closest(\"[inert]\");\n\ndefineExpose({ openVerticalDrawer, openHorizontalFilter, isHorizontalFilterCollapsed });\n</script>\n\n<template>\n  <div\n    ref=\"filterRowRef\"\n    class=\"pv-flex\"\n    :class=\"{ 'pv-filter-panel-collapsible': collapseHorizontalFilters }\"\n    :style=\"\n      collapseHorizontalFilters ? { minWidth: `${filterActionsWidth}px` } : { '--flex-wrap': 'wrap', maxWidth: '100%' }\n    \"\n  >\n    <template v-for=\"filterCol in horizontalFilterFields\" :key=\"filterCol.field\">\n      <div\n        v-if=\"gridApi\"\n        :ref=\"(element) => setFilterItemRef(filterCol.field || '', element)\"\n        class=\"pv-filter-panel-item\"\n        :class=\"{ 'pv-filter-panel-item-collapsed': !visibleHorizontalFilterFields.has(filterCol.field || '') }\"\n        :inert=\"!visibleHorizontalFilterFields.has(filterCol.field || '') || undefined\"\n      >\n        <SetFilter\n          :enable-focus-view=\"props.enableFocusView\"\n          :display-preferences-icon=\"props.displayPreferencesIcon\"\n          :focus-text=\"props.focusText\"\n          :filterColDef=\"filterCol\"\n          :read-only=\"props.readOnly\"\n          :disable-unselected=\"props.disableUnselectedFilters\"\n          @handle-settings-icon=\"$emit('handle-settings-icon', $event)\"\n        ></SetFilter>\n      </div>\n    </template>\n    <div ref=\"filterActionsRef\" class=\"pv-flex\" style=\"flex-shrink: 0\">\n      <PvButton\n        v-if=\"props.enableVerticalPanel\"\n        label=\"All Filters\"\n        @click=\"openVerticalDrawer\"\n        variant=\"ghost\"\n        left-icon=\"filter\"\n        data-dd-action-name=\"Open All Filters drawer\"\n        :right-counter-badge=\"props.readOnly && activeFilterCount > 0 ? activeFilterCount : undefined\"\n      />\n      <button\n        v-if=\"activeFilterCount > 0 && !props.readOnly\"\n        class=\"pv-button-ghost\"\n        data-dd-action-name=\"Clear all page filters\"\n        @click=\"showClearModal = true\"\n      >\n        <PvIcon name=\"close\"></PvIcon> Clear All Filters\n        <PvCounterBadge v-if=\"activeFilterCount > 0\" :value=\"activeFilterCount\" variant=\"tertiary\" />\n      </button>\n    </div>\n    <PvDrawer\n      v-if=\"props.enableVerticalPanel\"\n      v-model=\"filterDrawerOpen\"\n      class=\"pv-drawer pv-surface\"\n      :close-on-click-outside=\"true\"\n      @click-outside=\"applyModifiedFilters()\"\n      style=\"max-width: 450px; z-index: 10\"\n    >\n      <template #header>\n        <div class=\"pv-flex pv-space-between pv-stack-8\">\n          <p class=\"pv-text-title-lg\">All Filters ({{ verticalPanelFilters.length }})</p>\n          <button class=\"pv-button-ghost\" aria-label=\"Close\" @click=\"cancelModifiedFilters()\">\n            <PvIcon name=\"close\"></PvIcon>\n          </button>\n        </div>\n        <PvSearchInput v-model=\"filterPanelSearchText\" placeholder=\"Search Filters\" />\n      </template>\n      <div\n        id=\"filter-vertical-drawer\"\n        class=\"pv-flex-vertical pv-space-between pv-full-width pv-inset-block-16\"\n        style=\"height: 100%\"\n      >\n        <div class=\"pv-full-width\">\n          <div\n            v-for=\"(filterCol, index) in filteredVerticalPanelFilters\"\n            :key=\"filterCol.field\"\n            :class=\"{\n              'pv-border-bottom': index < filteredVerticalPanelFilters.length - 1,\n            }\"\n            class=\"pv-stack-12\"\n          >\n            <details\n              class=\"pv-details pv-stack-12\"\n              :class=\"{ 'pv-details-no-carat': isEmptyReadOnlyFilter(filterCol) }\"\n              :open=\"!isEmptyReadOnlyFilter(filterCol)\"\n            >\n              <summary\n                class=\"pv-flex pv-full-width\"\n                :data-dd-action-name=\"`Expand ${filterCol.headerName} section`\"\n                @click=\"isEmptyReadOnlyFilter(filterCol) && $event.preventDefault()\"\n              >\n                <span class=\"pv-text-title-lg\">\n                  {{ filterCol.headerName }}\n                </span>\n              </summary>\n              <div>\n                <SetFilter\n                  v-if=\"gridApi\"\n                  filter-style=\"vertical\"\n                  :enable-focus-view=\"props.enableFocusView\"\n                  :filterColDef=\"filterCol\"\n                  :display-preferences-icon=\"props.displayPreferencesIcon\"\n                  :focus-text=\"props.focusText\"\n                  :read-only=\"props.readOnly\"\n                  :disable-unselected=\"props.disableUnselectedFilters\"\n                  @filter-selection-changed=\"handleFilterSelectionChanged\"\n                  @handle-settings-icon=\"$emit('handle-settings-icon', $event)\"\n                />\n              </div>\n            </details>\n          </div>\n        </div>\n      </div>\n      <template #footer>\n        <div class=\"pv-flex pv-space-between\">\n          <template v-if=\"!props.readOnly\">\n            <button class=\"pv-button-ghost\" data-dd-action-name=\"Clear all page filters\" @click=\"clearAllFilters()\">\n              Clear All\n            </button>\n            <div class=\"pv-flex\">\n              <PvButton\n                variant=\"ghost\"\n                label=\"Cancel\"\n                data-dd-action-name=\"Cancel filter changes\"\n                @click=\"cancelModifiedFilters()\"\n              />\n              <PvButton\n                v-if=\"filterPanelChanged\"\n                variant=\"primary\"\n                label=\"Apply\"\n                data-dd-action-name=\"Apply filters\"\n                @click=\"applyModifiedFilters()\"\n              />\n              <PvButton v-else variant=\"primary\" label=\"No Changes\" disabled />\n            </div>\n          </template>\n          <template v-else>\n            <PvButton variant=\"ghost\" label=\"Close\" @click=\"cancelModifiedFilters()\" />\n          </template>\n        </div>\n      </template>\n    </PvDrawer>\n  </div>\n  <PvModal v-model=\"showClearModal\" header=\"Clear All Filters\">\n    <template #body>\n      <p class=\"pv-text-body-lg\">This action will remove all currently applied filters. Would you like to continue?</p>\n    </template>\n    <template #footer>\n      <div class=\"pv-flex\" style=\"--flex-justify: end; --flex-gap: 8px; margin-top: auto\">\n        <PvButton\n          label=\"Cancel\"\n          variant=\"secondary\"\n          size=\"lg\"\n          data-dd-action-name=\"Cancel clear all filters\"\n          @click=\"showClearModal = false\"\n        />\n        <PvButton\n          label=\"Clear All Filters\"\n          variant=\"primary\"\n          size=\"lg\"\n          data-dd-action-name=\"Confirm clear all filters\"\n          @click=\"clearAllFilters\"\n        />\n      </div>\n    </template>\n  </PvModal>\n</template>\n\n<style scoped>\n.pv-filter-panel-collapsible {\n  /* Fill the space the surrounding row leaves over; min-width (inline) keeps the actions visible. */\n  flex: 1 1 0;\n  position: relative;\n  /* Size from the parent, not the filters, so a parent with an auto min-width shrinks only to min-width. */\n  contain: inline-size;\n}\n\n.pv-filter-panel-item {\n  flex-shrink: 0;\n}\n\n.pv-filter-panel-item-collapsed {\n  left: 0;\n  pointer-events: none;\n  position: absolute;\n  top: 0;\n  visibility: hidden;\n  width: max-content;\n}\n\n.pv-details-no-carat > summary {\n  background-image: none;\n  cursor: default;\n}\n</style>\n","<script setup lang=\"ts\">\nimport { computed, inject, onBeforeMount, ref, watch } from \"vue\";\nimport { IHeaderParams } from \"ag-grid-enterprise\";\nimport PvIcon from \"@/components/base/PvIcon/PvIcon.vue\";\nimport PvButton from \"@/components/base/PvButton/PvButton.vue\";\nimport PvSelectButton from \"@/components/base/PvSelectButton/PvSelectButton.vue\";\nimport PvTooltipV2 from \"@/components/base/PvTooltipV2/PvTooltipV2.vue\";\nimport type { PvPopoverV2Props } from \"@/components/base/PvPopoverV2/types\";\nimport {\n  ColDefDataType,\n  mapEntityTypeToHeaderIcon,\n  updateDisplayNameForDataType,\n} from \"@tables/PvDataTable/table-components/formatting\";\nimport { RowGroupColumnFieldsKey, SortStateKey } from \"@/components/tables/symbols\";\nimport { isColDefRightAligned, colDefContext } from \"@/components/tables/PvDataTable/helpers\";\nimport type { MenuOption } from \"@/types\";\n\nconst sortState = inject(SortStateKey, ref([]));\nconst rowGroupColumns = inject(RowGroupColumnFieldsKey, ref([]));\n\n// These will be injected by ag-Grid\nconst props = defineProps<{\n  params: IHeaderParams;\n}>();\n\nconst enableFilterButton = ref(false);\nconst enableSorting = ref(false);\nconst displayName = ref<string | null>(null);\nconst headerIcon = ref<string | null>(null);\nconst headerTooltip = ref<string | null>(null);\nconst headerTooltipLink = ref<{ label: string; onClick: () => void } | null>(null);\n// \"{link}\" in the tooltip text marks where the link renders; without it the link follows the text.\nconst headerTooltipParts = computed(() => {\n  const [before, after] = (headerTooltip.value ?? \"\").split(\"{link}\");\n  return after === undefined ? { before: `${before} `, after: \"\" } : { before, after };\n});\nconst menuButton = ref<HTMLElement | null>(null);\nconst showMenuButton = ref(false);\nconst displayMenuButton = computed(() => {\n  const colDef = props.params.column.getColDef();\n  return colDef.sortable || colDef.filter || colDef.enableRowGroup;\n});\n\nconst sortIcon = computed(() => {\n  if (!sortState.value || sortState.value.length === 0) {\n    return \"\";\n  }\n  const sortForField = sortState.value.find((item) => item.colId === props.params.column.getColId());\n  const sortValue = sortForField ? sortForField.sort : \"\";\n  return sortValue === \"asc\" ? \"arrow-up\" : sortValue === \"desc\" ? \"arrow-down\" : \"\";\n});\n\nconst isRightAligned = computed(() => {\n  return isColDefRightAligned(props.params.column.getColDef());\n});\n\n// Agg func selector\nconst aggFuncOptions = computed<MenuOption[]>(() => {\n  const colDef = props.params.column.getColDef();\n  const allowedAggFuncs = colDef.allowedAggFuncs;\n  if (!allowedAggFuncs || allowedAggFuncs.length <= 1) return [];\n  const context = colDefContext(colDef);\n  const displayNameMap = context.aggFuncDisplayNameMap || {};\n  const descriptionMap = context.aggFuncDescriptionMap || {};\n  return allowedAggFuncs.map((func) => ({\n    id: func,\n    text: displayNameMap[func] || func,\n    description: descriptionMap[func],\n  }));\n});\n\nconst hasAggFuncSelector = computed(() => aggFuncOptions.value.length > 1);\n\nconst selectedAggFunc = ref<MenuOption | undefined>();\n\nconst syncSelectedAggFunc = (params: IHeaderParams) => {\n  const currentAggFunc = params.column.getAggFunc();\n  selectedAggFunc.value =\n    aggFuncOptions.value.find((option) => option.id === currentAggFunc) || aggFuncOptions.value[0];\n};\n\nconst headerCellClasses = computed(() => [\n  \"ag-custom-header-cell pv-flex pv-full-width pv-space-between\",\n  { \"ag-custom-header-cell-with-agg-selector\": displayAggFuncSelector.value },\n]);\n\nconst aggFuncPopoverProperties = computed<PvPopoverV2Props>(() => ({\n  useTeleport: true,\n  position: isRightAligned.value ? \"bottom-right\" : \"bottom-left\",\n  cssCustomProperties: { width: \"100%\", height: \"100%\" },\n}));\n\nconst headerCellStyle = computed(() => {\n  const baseStyle: Record<string, string> = {};\n\n  if (enableSorting.value) {\n    baseStyle.cursor = \"pointer\";\n    baseStyle[\"flex-direction\"] = isRightAligned.value ? \"row-reverse\" : \"row\";\n  }\n\n  if (isRightAligned.value) {\n    baseStyle[\"--flex-justify\"] = \"flex-end\";\n  }\n\n  return baseStyle;\n});\nconst menuButtonStyle = computed(() => {\n  return showMenuButton.value ? { opacity: 1 } : {};\n});\n\nconst displayAggFuncSelector = computed(() => {\n  // display if the selector is available and we are grouped; pivot measures always show the server's value\n  if (props.params.column.getColDef().pivotValueColumn) return false;\n  return hasAggFuncSelector.value && rowGroupColumns.value.length > 0;\n});\n\nconst onMenuClosed = () => {\n  showMenuButton.value = false;\n};\nconst onMenuClicked = () => {\n  showMenuButton.value = true;\n  if (!menuButton.value) return;\n  props.params.showColumnMenu(menuButton.value, onMenuClosed);\n};\n\nconst updateHeaderCell = (params: IHeaderParams) => {\n  enableFilterButton.value = params.enableFilterButton;\n  enableSorting.value = params.enableSorting || false;\n  displayName.value = params.displayName;\n  const dataType = params.column.getColDef().context?.dataType;\n  if (params.api?.isPivotMode?.()) {\n    // Pivot headers are plain labels: the unit goes in the name instead of a data type icon.\n    headerIcon.value = null;\n    if (dataType === ColDefDataType.Currency && !displayName.value.includes(\"$\")) {\n      displayName.value = `${displayName.value} ($)`;\n    }\n  } else {\n    // set the header icon based on the column data type\n    headerIcon.value = mapEntityTypeToHeaderIcon(dataType);\n    displayName.value = updateDisplayNameForDataType(displayName.value, dataType);\n  }\n  headerTooltip.value = params.column.getColDef().context?.headerTooltip ?? null;\n  headerTooltipLink.value = params.column.getColDef().context?.headerTooltipLink ?? null;\n};\n\n// the event type received is event: MouseEvent\n// we can enable multi-sorting by passing `event.shiftKey` to the sort method - for now just support single sort\nconst onSortClicked = () => {\n  if (enableSorting.value) {\n    props.params.progressSort(false);\n  }\n};\n\nwatch(selectedAggFunc, (newVal) => {\n  if (!newVal) return;\n  const currentAggFunc = props.params.column.getAggFunc();\n  if (newVal.id === currentAggFunc) return;\n  const api = props.params.api;\n  const colId = props.params.column.getColId();\n  api.applyColumnState({\n    state: [{ colId, aggFunc: newVal.id }],\n  });\n});\n\nonBeforeMount(() => {\n  if (hasAggFuncSelector.value) syncSelectedAggFunc(props.params);\n  updateHeaderCell(props.params);\n});\n\n// Gets called when a new Column Definition has been set for this header.\n// If you handle the refresh of your header return true otherwise return false\n// and the grid will re-create your header from scratch.\nfunction refresh(params: IHeaderParams): boolean {\n  updateHeaderCell(params);\n  if (hasAggFuncSelector.value) syncSelectedAggFunc(params);\n  return true;\n}\n\n// expose refresh to AG Grid\ndefineExpose({ refresh });\n</script>\n\n<template>\n  <div :class=\"headerCellClasses\" :style=\"headerCellStyle\" @click=\"onSortClicked\">\n    <div\n      :class=\"['pv-flex pv-full-width', { 'pv-text-right': isRightAligned }]\"\n      :style=\"isRightAligned ? { '--flex-justify': 'flex-end' } : {}\"\n    >\n      <PvIcon v-if=\"headerIcon && !displayAggFuncSelector\" :name=\"headerIcon\" class=\"pv-text-tertiary\"></PvIcon>\n      <template v-if=\"displayAggFuncSelector\">\n        <PvSelectButton\n          v-model=\"selectedAggFunc\"\n          class=\"ag-header-agg-func-selector\"\n          :options=\"aggFuncOptions\"\n          :disableSearchInput=\"true\"\n          :disableDeselect=\"true\"\n          :popoverProperties=\"aggFuncPopoverProperties\"\n          :popoverCssProperties=\"{ width: 'auto' }\"\n          variant=\"ghost\"\n          size=\"lg\"\n          :icon=\"headerIcon || undefined\"\n          :label=\"displayName || ''\"\n          :staticLabel=\"true\"\n          @click.stop\n        />\n      </template>\n      <p v-else>{{ displayName }}</p>\n      <PvTooltipV2\n        v-if=\"headerTooltip\"\n        variant=\"white\"\n        position=\"top-center\"\n        :disableAutoPlacement=\"true\"\n        :useTeleport=\"true\"\n        :showOnHover=\"true\"\n        :disableInteractive=\"!headerTooltipLink\"\n        style=\"pointer-events: auto\"\n      >\n        <template #trigger>\n          <!-- With a link in the tooltip, keyboard users need a named tab stop to open it and reach the link. -->\n          <PvButton\n            v-if=\"headerTooltipLink\"\n            variant=\"ghost\"\n            size=\"md\"\n            left-icon=\"info-circle\"\n            :ariaLabel=\"`More information about ${displayName}`\"\n            @click.stop\n          />\n          <PvIcon v-else :size=\"12\" name=\"info-circle\" class=\"pv-text-subdued\" @click.stop />\n        </template>\n        <template #content>\n          <div style=\"max-width: 220px; white-space: normal; overflow-wrap: break-word; text-align: left\">\n            <template v-if=\"headerTooltipLink\">\n              {{ headerTooltipParts.before\n              }}<button\n                type=\"button\"\n                style=\"\n                  background: none;\n                  border: 0;\n                  padding: 0;\n                  cursor: pointer;\n                  text-decoration: underline;\n                  color: var(--color-background-brand, #36c5ba);\n                \"\n                @click.stop=\"headerTooltipLink.onClick()\"\n              >\n                {{ headerTooltipLink.label }}</button\n              >{{ headerTooltipParts.after }}\n            </template>\n            <template v-else>{{ headerTooltip }}</template>\n          </div>\n        </template>\n      </PvTooltipV2>\n      <PvIcon v-if=\"enableSorting && sortIcon !== ''\" :name=\"sortIcon\"></PvIcon>\n    </div>\n    <div v-if=\"displayMenuButton\" class=\"pv-flex ag-header-actions\">\n      <div ref=\"menuButton\" class=\"ag-header-cell-menu-button\" :style=\"menuButtonStyle\">\n        <PvButton\n          size=\"md\"\n          variant=\"ghost\"\n          left-icon=\"menu\"\n          ariaLabel=\"Column menu\"\n          @click.stop.prevent=\"onMenuClicked\"\n        />\n      </div>\n    </div>\n  </div>\n</template>\n","<script setup lang=\"ts\">\nimport { computed, inject, onBeforeMount, ref, watch } from \"vue\";\nimport { IHeaderParams } from \"ag-grid-enterprise\";\nimport PvIcon from \"@/components/base/PvIcon/PvIcon.vue\";\nimport PvButton from \"@/components/base/PvButton/PvButton.vue\";\nimport PvSelectButton from \"@/components/base/PvSelectButton/PvSelectButton.vue\";\nimport PvTooltipV2 from \"@/components/base/PvTooltipV2/PvTooltipV2.vue\";\nimport type { PvPopoverV2Props } from \"@/components/base/PvPopoverV2/types\";\nimport {\n  ColDefDataType,\n  mapEntityTypeToHeaderIcon,\n  updateDisplayNameForDataType,\n} from \"@tables/PvDataTable/table-components/formatting\";\nimport { RowGroupColumnFieldsKey, SortStateKey } from \"@/components/tables/symbols\";\nimport { isColDefRightAligned, colDefContext } from \"@/components/tables/PvDataTable/helpers\";\nimport type { MenuOption } from \"@/types\";\n\nconst sortState = inject(SortStateKey, ref([]));\nconst rowGroupColumns = inject(RowGroupColumnFieldsKey, ref([]));\n\n// These will be injected by ag-Grid\nconst props = defineProps<{\n  params: IHeaderParams;\n}>();\n\nconst enableFilterButton = ref(false);\nconst enableSorting = ref(false);\nconst displayName = ref<string | null>(null);\nconst headerIcon = ref<string | null>(null);\nconst headerTooltip = ref<string | null>(null);\nconst headerTooltipLink = ref<{ label: string; onClick: () => void } | null>(null);\n// \"{link}\" in the tooltip text marks where the link renders; without it the link follows the text.\nconst headerTooltipParts = computed(() => {\n  const [before, after] = (headerTooltip.value ?? \"\").split(\"{link}\");\n  return after === undefined ? { before: `${before} `, after: \"\" } : { before, after };\n});\nconst menuButton = ref<HTMLElement | null>(null);\nconst showMenuButton = ref(false);\nconst displayMenuButton = computed(() => {\n  const colDef = props.params.column.getColDef();\n  return colDef.sortable || colDef.filter || colDef.enableRowGroup;\n});\n\nconst sortIcon = computed(() => {\n  if (!sortState.value || sortState.value.length === 0) {\n    return \"\";\n  }\n  const sortForField = sortState.value.find((item) => item.colId === props.params.column.getColId());\n  const sortValue = sortForField ? sortForField.sort : \"\";\n  return sortValue === \"asc\" ? \"arrow-up\" : sortValue === \"desc\" ? \"arrow-down\" : \"\";\n});\n\nconst isRightAligned = computed(() => {\n  return isColDefRightAligned(props.params.column.getColDef());\n});\n\n// Agg func selector\nconst aggFuncOptions = computed<MenuOption[]>(() => {\n  const colDef = props.params.column.getColDef();\n  const allowedAggFuncs = colDef.allowedAggFuncs;\n  if (!allowedAggFuncs || allowedAggFuncs.length <= 1) return [];\n  const context = colDefContext(colDef);\n  const displayNameMap = context.aggFuncDisplayNameMap || {};\n  const descriptionMap = context.aggFuncDescriptionMap || {};\n  return allowedAggFuncs.map((func) => ({\n    id: func,\n    text: displayNameMap[func] || func,\n    description: descriptionMap[func],\n  }));\n});\n\nconst hasAggFuncSelector = computed(() => aggFuncOptions.value.length > 1);\n\nconst selectedAggFunc = ref<MenuOption | undefined>();\n\nconst syncSelectedAggFunc = (params: IHeaderParams) => {\n  const currentAggFunc = params.column.getAggFunc();\n  selectedAggFunc.value =\n    aggFuncOptions.value.find((option) => option.id === currentAggFunc) || aggFuncOptions.value[0];\n};\n\nconst headerCellClasses = computed(() => [\n  \"ag-custom-header-cell pv-flex pv-full-width pv-space-between\",\n  { \"ag-custom-header-cell-with-agg-selector\": displayAggFuncSelector.value },\n]);\n\nconst aggFuncPopoverProperties = computed<PvPopoverV2Props>(() => ({\n  useTeleport: true,\n  position: isRightAligned.value ? \"bottom-right\" : \"bottom-left\",\n  cssCustomProperties: { width: \"100%\", height: \"100%\" },\n}));\n\nconst headerCellStyle = computed(() => {\n  const baseStyle: Record<string, string> = {};\n\n  if (enableSorting.value) {\n    baseStyle.cursor = \"pointer\";\n    baseStyle[\"flex-direction\"] = isRightAligned.value ? \"row-reverse\" : \"row\";\n  }\n\n  if (isRightAligned.value) {\n    baseStyle[\"--flex-justify\"] = \"flex-end\";\n  }\n\n  return baseStyle;\n});\nconst menuButtonStyle = computed(() => {\n  return showMenuButton.value ? { opacity: 1 } : {};\n});\n\nconst displayAggFuncSelector = computed(() => {\n  // display if the selector is available and we are grouped; pivot measures always show the server's value\n  if (props.params.column.getColDef().pivotValueColumn) return false;\n  return hasAggFuncSelector.value && rowGroupColumns.value.length > 0;\n});\n\nconst onMenuClosed = () => {\n  showMenuButton.value = false;\n};\nconst onMenuClicked = () => {\n  showMenuButton.value = true;\n  if (!menuButton.value) return;\n  props.params.showColumnMenu(menuButton.value, onMenuClosed);\n};\n\nconst updateHeaderCell = (params: IHeaderParams) => {\n  enableFilterButton.value = params.enableFilterButton;\n  enableSorting.value = params.enableSorting || false;\n  displayName.value = params.displayName;\n  const dataType = params.column.getColDef().context?.dataType;\n  if (params.api?.isPivotMode?.()) {\n    // Pivot headers are plain labels: the unit goes in the name instead of a data type icon.\n    headerIcon.value = null;\n    if (dataType === ColDefDataType.Currency && !displayName.value.includes(\"$\")) {\n      displayName.value = `${displayName.value} ($)`;\n    }\n  } else {\n    // set the header icon based on the column data type\n    headerIcon.value = mapEntityTypeToHeaderIcon(dataType);\n    displayName.value = updateDisplayNameForDataType(displayName.value, dataType);\n  }\n  headerTooltip.value = params.column.getColDef().context?.headerTooltip ?? null;\n  headerTooltipLink.value = params.column.getColDef().context?.headerTooltipLink ?? null;\n};\n\n// the event type received is event: MouseEvent\n// we can enable multi-sorting by passing `event.shiftKey` to the sort method - for now just support single sort\nconst onSortClicked = () => {\n  if (enableSorting.value) {\n    props.params.progressSort(false);\n  }\n};\n\nwatch(selectedAggFunc, (newVal) => {\n  if (!newVal) return;\n  const currentAggFunc = props.params.column.getAggFunc();\n  if (newVal.id === currentAggFunc) return;\n  const api = props.params.api;\n  const colId = props.params.column.getColId();\n  api.applyColumnState({\n    state: [{ colId, aggFunc: newVal.id }],\n  });\n});\n\nonBeforeMount(() => {\n  if (hasAggFuncSelector.value) syncSelectedAggFunc(props.params);\n  updateHeaderCell(props.params);\n});\n\n// Gets called when a new Column Definition has been set for this header.\n// If you handle the refresh of your header return true otherwise return false\n// and the grid will re-create your header from scratch.\nfunction refresh(params: IHeaderParams): boolean {\n  updateHeaderCell(params);\n  if (hasAggFuncSelector.value) syncSelectedAggFunc(params);\n  return true;\n}\n\n// expose refresh to AG Grid\ndefineExpose({ refresh });\n</script>\n\n<template>\n  <div :class=\"headerCellClasses\" :style=\"headerCellStyle\" @click=\"onSortClicked\">\n    <div\n      :class=\"['pv-flex pv-full-width', { 'pv-text-right': isRightAligned }]\"\n      :style=\"isRightAligned ? { '--flex-justify': 'flex-end' } : {}\"\n    >\n      <PvIcon v-if=\"headerIcon && !displayAggFuncSelector\" :name=\"headerIcon\" class=\"pv-text-tertiary\"></PvIcon>\n      <template v-if=\"displayAggFuncSelector\">\n        <PvSelectButton\n          v-model=\"selectedAggFunc\"\n          class=\"ag-header-agg-func-selector\"\n          :options=\"aggFuncOptions\"\n          :disableSearchInput=\"true\"\n          :disableDeselect=\"true\"\n          :popoverProperties=\"aggFuncPopoverProperties\"\n          :popoverCssProperties=\"{ width: 'auto' }\"\n          variant=\"ghost\"\n          size=\"lg\"\n          :icon=\"headerIcon || undefined\"\n          :label=\"displayName || ''\"\n          :staticLabel=\"true\"\n          @click.stop\n        />\n      </template>\n      <p v-else>{{ displayName }}</p>\n      <PvTooltipV2\n        v-if=\"headerTooltip\"\n        variant=\"white\"\n        position=\"top-center\"\n        :disableAutoPlacement=\"true\"\n        :useTeleport=\"true\"\n        :showOnHover=\"true\"\n        :disableInteractive=\"!headerTooltipLink\"\n        style=\"pointer-events: auto\"\n      >\n        <template #trigger>\n          <!-- With a link in the tooltip, keyboard users need a named tab stop to open it and reach the link. -->\n          <PvButton\n            v-if=\"headerTooltipLink\"\n            variant=\"ghost\"\n            size=\"md\"\n            left-icon=\"info-circle\"\n            :ariaLabel=\"`More information about ${displayName}`\"\n            @click.stop\n          />\n          <PvIcon v-else :size=\"12\" name=\"info-circle\" class=\"pv-text-subdued\" @click.stop />\n        </template>\n        <template #content>\n          <div style=\"max-width: 220px; white-space: normal; overflow-wrap: break-word; text-align: left\">\n            <template v-if=\"headerTooltipLink\">\n              {{ headerTooltipParts.before\n              }}<button\n                type=\"button\"\n                style=\"\n                  background: none;\n                  border: 0;\n                  padding: 0;\n                  cursor: pointer;\n                  text-decoration: underline;\n                  color: var(--color-background-brand, #36c5ba);\n                \"\n                @click.stop=\"headerTooltipLink.onClick()\"\n              >\n                {{ headerTooltipLink.label }}</button\n              >{{ headerTooltipParts.after }}\n            </template>\n            <template v-else>{{ headerTooltip }}</template>\n          </div>\n        </template>\n      </PvTooltipV2>\n      <PvIcon v-if=\"enableSorting && sortIcon !== ''\" :name=\"sortIcon\"></PvIcon>\n    </div>\n    <div v-if=\"displayMenuButton\" class=\"pv-flex ag-header-actions\">\n      <div ref=\"menuButton\" class=\"ag-header-cell-menu-button\" :style=\"menuButtonStyle\">\n        <PvButton\n          size=\"md\"\n          variant=\"ghost\"\n          left-icon=\"menu\"\n          ariaLabel=\"Column menu\"\n          @click.stop.prevent=\"onMenuClicked\"\n        />\n      </div>\n    </div>\n  </div>\n</template>\n","import { Theme, themeQuartz } from \"ag-grid-community\";\n\nconst baseParams = {\n  backgroundColor: \"var(--color-background-body, white)\",\n  foregroundColor: \"var(--color-text-body, #121313)\",\n  headerHeight: \"30px\",\n  headerBackgroundColor: \"var(--color-background-body, white)\",\n  headerCellHoverBackgroundColor: \"var(--color-background-table-hover, #f7f8f8)\",\n  headerColumnResizeHandleHeight: \"50%\",\n  headerColumnResizeHandleWidth: \"3px\",\n  headerColumnBorder: \"none\",\n  headerFontWeight: \"bold\",\n  headerFontSize: \"12px\",\n  fontFamily: \"Inter, sans-serif\",\n  fontSize: 12,\n  rangeSelectionBorderColor: \"var(--color-border-brand, #36c5ba)\",\n  rangeSelectionBorderStyle: \"solid\",\n  menuBackgroundColor: \"var(--color-background-body, white)\",\n  accentColor: \"var(--color-background-brand, #36c5ba)\",\n};\n\nexport const PitViperAGGridBaseTheme: Theme = themeQuartz.withParams({\n  ...baseParams,\n  headerRowBorder: true,\n  rowHoverColor: \"var(--color-background-table-hover, #f7f8f8)\",\n  wrapperBorder: true,\n  wrapperBorderRadius: \"8px\",\n});\n\nexport const PitViperAGGridNoBordersTheme: Theme = themeQuartz.withParams({\n  ...baseParams,\n  headerRowBorder: false,\n  rowHoverColor: \"transparent\",\n  wrapperBorder: false,\n  wrapperBorderRadius: \"0px\",\n  cellHorizontalPadding: \"8px\",\n  rowBorder: false,\n  columnBorder: false,\n  rowHeight: \"50px\",\n});\n\nexport const PitViperAGGridGroupedTheme: Theme = themeQuartz.withParams({\n  ...baseParams,\n  headerRowBorder: true,\n  rowHoverColor: \"var(--color-background-table-hover, #f7f8f8)\",\n  wrapperBorder: true,\n  wrapperBorderRadius: \"8px\",\n});\n\n/**\n * Matches the `.pv-table` CSS framework styling used by components like\n * PvDataWidget: gray header, no wrapper border or radius, no row hover, and\n * a single hairline rule between rows.\n */\nexport const PitViperAGGridClassicTheme: Theme = themeQuartz.withParams({\n  ...baseParams,\n  borderColor: \"var(--color-border, #e3e7ea)\",\n  headerHeight: \"33px\",\n  headerBackgroundColor: \"var(--color-background-accent, #f7f8f8)\",\n  headerCellHoverBackgroundColor: \"var(--color-background-accent, #f7f8f8)\",\n  headerFontSize: \"12px\",\n  headerFontWeight: 600,\n  headerRowBorder: true,\n  cellHorizontalPadding: \"12px\",\n  rowHeight: \"33px\",\n  rowBorder: true,\n  rowHoverColor: \"transparent\",\n  columnBorder: false,\n  wrapperBorder: false,\n  wrapperBorderRadius: \"0px\",\n});\n\nexport type PvDataTableTheme =\n  | \"pv-data-table-base\"\n  | \"pv-data-table-grouped\"\n  | \"pv-data-table-grouped-card\"\n  | \"pv-data-table-classic\";\n\nexport const themeMap: Record<PvDataTableTheme, Theme> = {\n  \"pv-data-table-base\": PitViperAGGridBaseTheme,\n  \"pv-data-table-grouped\": PitViperAGGridGroupedTheme,\n  \"pv-data-table-grouped-card\": PitViperAGGridNoBordersTheme,\n  \"pv-data-table-classic\": PitViperAGGridClassicTheme,\n};\n","<script setup lang=\"ts\" generic=\"T\">\nimport { ref } from \"vue\";\n\nconst props = defineProps<{\n  getCsvData: () => Promise<string | null>;\n}>();\nconst isExporting = ref(false);\n\nasync function downloadCsv() {\n  isExporting.value = true;\n\n  const csvString = await props.getCsvData();\n  if (!csvString) {\n    isExporting.value = false;\n    return;\n  }\n\n  const blob = new Blob([csvString], { type: \"text/csv;charset=utf-8;\" });\n  const link = document.createElement(\"a\");\n  link.href = URL.createObjectURL(blob);\n  link.setAttribute(\"download\", \"datatable_export.csv\");\n  link.click();\n\n  isExporting.value = false;\n}\n</script>\n\n<template>\n  <nav class=\"pv-popover-menu\">\n    <button type=\"button\" class=\"pv-button-icon\">\n      <svg aria-hidden=\"true\" class=\"pv-icon-24\">\n        <title>ellipsis</title>\n        <use xlink:href=\"#ellipsis\"></use>\n      </svg>\n    </button>\n    <div class=\"pv-popover\" style=\"--height: auto\">\n      <button class=\"pv-button pv-text-body-sm pv-inset-square-8\" @click.prevent=\"downloadCsv\" :disabled=\"isExporting\">\n        <template v-if=\"isExporting\">Exporting...</template>\n        <template v-else>Download CSV</template>\n      </button>\n    </div>\n  </nav>\n</template>\n","<script setup lang=\"ts\" generic=\"T\">\nimport { ref } from \"vue\";\n\nconst props = defineProps<{\n  getCsvData: () => Promise<string | null>;\n}>();\nconst isExporting = ref(false);\n\nasync function downloadCsv() {\n  isExporting.value = true;\n\n  const csvString = await props.getCsvData();\n  if (!csvString) {\n    isExporting.value = false;\n    return;\n  }\n\n  const blob = new Blob([csvString], { type: \"text/csv;charset=utf-8;\" });\n  const link = document.createElement(\"a\");\n  link.href = URL.createObjectURL(blob);\n  link.setAttribute(\"download\", \"datatable_export.csv\");\n  link.click();\n\n  isExporting.value = false;\n}\n</script>\n\n<template>\n  <nav class=\"pv-popover-menu\">\n    <button type=\"button\" class=\"pv-button-icon\">\n      <svg aria-hidden=\"true\" class=\"pv-icon-24\">\n        <title>ellipsis</title>\n        <use xlink:href=\"#ellipsis\"></use>\n      </svg>\n    </button>\n    <div class=\"pv-popover\" style=\"--height: auto\">\n      <button class=\"pv-button pv-text-body-sm pv-inset-square-8\" @click.prevent=\"downloadCsv\" :disabled=\"isExporting\">\n        <template v-if=\"isExporting\">Exporting...</template>\n        <template v-else>Download CSV</template>\n      </button>\n    </div>\n  </nav>\n</template>\n","<script setup lang=\"ts\" generic=\"T\">\nimport { inject, ref } from \"vue\";\nimport PvPagination from \"@/components/base/PvPagination/PvPagination.vue\";\nimport { CurrentPageKey, GridApiKey, TotalPageKey } from \"@/components/tables/symbols\";\n\nconst gridApi = inject(GridApiKey, ref(null));\nconst currentPage = inject(CurrentPageKey, ref(1));\nconst totalPages = inject(TotalPageKey, ref(0));\n\nconst props = withDefaults(\n  defineProps<{\n    panelSize?: \"xl\" | \"l\";\n  }>(),\n  {\n    panelSize: \"xl\",\n  },\n);\n\nconst goToPage = (page: number) => {\n  if (page >= 1 && page <= totalPages.value && gridApi.value) {\n    gridApi?.value.paginationGoToPage(page - 1);\n  }\n};\n</script>\n\n<template>\n  <div :class=\"{ 'pv-hide': totalPages <= 1 }\">\n    <PvPagination\n      :model-value=\"currentPage\"\n      @update:model-value=\"goToPage\"\n      :max-pages=\"totalPages\"\n      :size=\"props.panelSize === 'l' ? 'lg' : 'xl'\"\n    />\n  </div>\n</template>\n","<script setup lang=\"ts\" generic=\"T\">\nimport { inject, ref } from \"vue\";\nimport PvPagination from \"@/components/base/PvPagination/PvPagination.vue\";\nimport { CurrentPageKey, GridApiKey, TotalPageKey } from \"@/components/tables/symbols\";\n\nconst gridApi = inject(GridApiKey, ref(null));\nconst currentPage = inject(CurrentPageKey, ref(1));\nconst totalPages = inject(TotalPageKey, ref(0));\n\nconst props = withDefaults(\n  defineProps<{\n    panelSize?: \"xl\" | \"l\";\n  }>(),\n  {\n    panelSize: \"xl\",\n  },\n);\n\nconst goToPage = (page: number) => {\n  if (page >= 1 && page <= totalPages.value && gridApi.value) {\n    gridApi?.value.paginationGoToPage(page - 1);\n  }\n};\n</script>\n\n<template>\n  <div :class=\"{ 'pv-hide': totalPages <= 1 }\">\n    <PvPagination\n      :model-value=\"currentPage\"\n      @update:model-value=\"goToPage\"\n      :max-pages=\"totalPages\"\n      :size=\"props.panelSize === 'l' ? 'lg' : 'xl'\"\n    />\n  </div>\n</template>\n","import { computed, nextTick, ref, shallowRef, type Ref } from \"vue\";\nimport { useElementSize, useResizeObserver } from \"@vueuse/core\";\n\nconst findIn = (wrapper: Ref<HTMLElement | null>, selector: string) =>\n  wrapper.value?.querySelector<HTMLElement>(selector) ?? null;\n\n/** The height of an AG Grid that fits its rows, summed from parts that keep their size however tall the grid is. */\nexport const useShrinkToContent = (wrapper: Ref<HTMLElement | null>) => {\n  const header = shallowRef<HTMLElement | null>(null);\n  const rows = shallowRef<HTMLElement | null>(null);\n  const hScroll = shallowRef<HTMLElement | null>(null);\n  const borders = ref(0);\n\n  const sizeOf = (el: Ref<HTMLElement | null>) => useElementSize(el, undefined, { box: \"border-box\" }).height;\n  const headerHeight = sizeOf(header);\n  const rowsHeight = sizeOf(rows);\n  const hScrollHeight = sizeOf(hScroll);\n\n  /** Starts tracking the grid's parts; call once it has rendered. */\n  const observe = () =>\n    nextTick(() => {\n      const root = findIn(wrapper, \".ag-root-wrapper\");\n      borders.value = root ? root.offsetHeight - root.clientHeight : 0;\n      header.value = findIn(wrapper, \".ag-header\");\n      rows.value = findIn(wrapper, \".ag-center-cols-container\");\n      hScroll.value = findIn(wrapper, \".ag-body-horizontal-scroll\");\n    });\n\n  // Undefined until the header has a size, so a hidden or unrendered grid keeps its default height. Undefined\n  // with no rows too, so the loading and \"no rows\" overlays get the default height instead of the header's.\n  const contentHeight = computed(() => {\n    if (!headerHeight.value || !rowsHeight.value) return undefined;\n    // Overlay scrollbars sit over the rows and take no space.\n    const inFlow = hScroll.value && getComputedStyle(hScroll.value).position !== \"absolute\";\n    return Math.ceil(borders.value + headerHeight.value + rowsHeight.value + (inFlow ? hScrollHeight.value : 0));\n  });\n\n  return { contentHeight, observe };\n};\n\n/** How far down the pivot's row label column starts, which is as tall as the network tabs above it. */\nexport const usePivotCornerHeight = (wrapper: Ref<HTMLElement | null>, initial: number) => {\n  const header = shallowRef<HTMLElement | null>(null);\n  const height = ref(initial);\n\n  useResizeObserver(header, () => {\n    const labelHeader = findIn(wrapper, \".ag-pinned-left-header .ag-header-cell\");\n    if (!labelHeader || !wrapper.value) return;\n    height.value = Math.round(labelHeader.getBoundingClientRect().top - wrapper.value.getBoundingClientRect().top);\n  });\n\n  /** Starts tracking the grid's header; call once it has rendered. */\n  const observe = () =>\n    nextTick(() => {\n      header.value = findIn(wrapper, \".ag-header\");\n    });\n\n  return { height, observe };\n};\n","<script setup lang=\"ts\">\nimport { multicolorFills } from \"@charts/themes\";\n\nconst GROUPS = 4;\nconst MEASURES_PER_GROUP = 2;\nconst ROWS = 8;\nconst MEASURES = GROUPS * MEASURES_PER_GROUP;\nconst rowStyle = { gridTemplateColumns: `minmax(160px, 1.5fr) repeat(${MEASURES}, minmax(0, 1fr))` };\nconst groupColor = (index: number) => multicolorFills[index % multicolorFills.length].slice(0, 7);\n// Column 0 is the row label; each group's first measure starts a divider.\nconst startsGroup = (column: number) => column > 0 && (column - 1) % MEASURES_PER_GROUP === 0;\n</script>\n\n<template>\n  <div\n    class=\"pv-pivot-skeleton\"\n    role=\"status\"\n    aria-busy=\"true\"\n    aria-label=\"Loading table\"\n    data-testid=\"pv-pivot-skeleton\"\n  >\n    <div class=\"pv-pivot-skeleton__row pv-pivot-skeleton__tabs\" :style=\"rowStyle\">\n      <div></div>\n      <div\n        v-for=\"group in GROUPS\"\n        :key=\"group\"\n        class=\"pv-pivot-group pv-relative pv-flex pv-flex-vertical pv-inset-squish-8\"\n        :style=\"{ gridColumn: `span ${MEASURES_PER_GROUP}`, '--pv-pivot-group-color': groupColor(group - 1) }\"\n      >\n        <div class=\"pv-shimmer pv-pivot-skeleton__bar\"></div>\n      </div>\n    </div>\n    <div class=\"pv-bordered-lg\">\n      <div\n        v-for=\"row in ROWS + 1\"\n        :key=\"row\"\n        class=\"pv-pivot-skeleton__row\"\n        :class=\"row === 1 ? 'pv-surface-accent pv-radius-lg-top' : 'pv-border-top'\"\n        :style=\"rowStyle\"\n      >\n        <div\n          v-for=\"column in MEASURES + 1\"\n          :key=\"column\"\n          class=\"pv-inset-squish-12\"\n          :class=\"{ 'pv-border-left': startsGroup(column - 1) }\"\n        >\n          <div class=\"pv-shimmer pv-pivot-skeleton__bar\"></div>\n        </div>\n      </div>\n    </div>\n  </div>\n</template>\n","<script setup lang=\"ts\">\nimport { multicolorFills } from \"@charts/themes\";\n\nconst GROUPS = 4;\nconst MEASURES_PER_GROUP = 2;\nconst ROWS = 8;\nconst MEASURES = GROUPS * MEASURES_PER_GROUP;\nconst rowStyle = { gridTemplateColumns: `minmax(160px, 1.5fr) repeat(${MEASURES}, minmax(0, 1fr))` };\nconst groupColor = (index: number) => multicolorFills[index % multicolorFills.length].slice(0, 7);\n// Column 0 is the row label; each group's first measure starts a divider.\nconst startsGroup = (column: number) => column > 0 && (column - 1) % MEASURES_PER_GROUP === 0;\n</script>\n\n<template>\n  <div\n    class=\"pv-pivot-skeleton\"\n    role=\"status\"\n    aria-busy=\"true\"\n    aria-label=\"Loading table\"\n    data-testid=\"pv-pivot-skeleton\"\n  >\n    <div class=\"pv-pivot-skeleton__row pv-pivot-skeleton__tabs\" :style=\"rowStyle\">\n      <div></div>\n      <div\n        v-for=\"group in GROUPS\"\n        :key=\"group\"\n        class=\"pv-pivot-group pv-relative pv-flex pv-flex-vertical pv-inset-squish-8\"\n        :style=\"{ gridColumn: `span ${MEASURES_PER_GROUP}`, '--pv-pivot-group-color': groupColor(group - 1) }\"\n      >\n        <div class=\"pv-shimmer pv-pivot-skeleton__bar\"></div>\n      </div>\n    </div>\n    <div class=\"pv-bordered-lg\">\n      <div\n        v-for=\"row in ROWS + 1\"\n        :key=\"row\"\n        class=\"pv-pivot-skeleton__row\"\n        :class=\"row === 1 ? 'pv-surface-accent pv-radius-lg-top' : 'pv-border-top'\"\n        :style=\"rowStyle\"\n      >\n        <div\n          v-for=\"column in MEASURES + 1\"\n          :key=\"column\"\n          class=\"pv-inset-squish-12\"\n          :class=\"{ 'pv-border-left': startsGroup(column - 1) }\"\n        >\n          <div class=\"pv-shimmer pv-pivot-skeleton__bar\"></div>\n        </div>\n      </div>\n    </div>\n  </div>\n</template>\n","<script setup lang=\"ts\">\nimport { ICellRendererParams } from \"ag-grid-enterprise\";\nimport { computed } from \"vue\";\n\nconst props = defineProps<{ params: ICellRendererParams }>();\n\nconst formattedValue = computed(() => {\n  const value = props.params.valueFormatted || props.params.value || \"\";\n  if (value.trim() === \"\") {\n    return null;\n  }\n  return value;\n});\n</script>\n\n<template>\n  <div v-if=\"formattedValue\" class=\"pv-tag\">{{ formattedValue }}</div>\n</template>\n","<script setup lang=\"ts\">\nimport { ICellRendererParams } from \"ag-grid-enterprise\";\nimport { computed } from \"vue\";\n\nconst props = defineProps<{ params: ICellRendererParams }>();\n\nconst formattedValue = computed(() => {\n  const value = props.params.valueFormatted || props.params.value || \"\";\n  if (value.trim() === \"\") {\n    return null;\n  }\n  return value;\n});\n</script>\n\n<template>\n  <div v-if=\"formattedValue\" class=\"pv-tag\">{{ formattedValue }}</div>\n</template>\n","<script setup lang=\"ts\" generic=\"T\">\nimport { ICellRendererParams } from \"ag-grid-enterprise\";\nimport { computed } from \"vue\";\nimport { isColDefNumericDataType } from \"@tables/PvDataTable/helpers\";\n\nconst props = defineProps<{ params: ICellRendererParams }>();\nconst rowIndex = computed(() => {\n  return (props.params.node?.rowIndex || 0) + 1;\n});\n\nconst formattedValue = computed(() => {\n  const colDef = props.params.column?.getColDef();\n  const value = props.params.valueFormatted || props.params.value;\n  if (colDef && isColDefNumericDataType(colDef)) {\n    return value.toLocaleString();\n  }\n  return value;\n});\n</script>\n\n<template>\n  <div>\n    <p>\n      <span class=\"pv-table-row-number pv-text-quaternary\" v-if=\"rowIndex\">{{ rowIndex }}</span>\n      {{ formattedValue }}\n    </p>\n  </div>\n</template>\n\n<style scoped>\n.pv-table-row-number {\n  padding: 8px 12px 8px 0;\n  text-align: center;\n}\n</style>\n","<script setup lang=\"ts\" generic=\"T\">\nimport { ICellRendererParams } from \"ag-grid-enterprise\";\nimport { computed } from \"vue\";\nimport { isColDefNumericDataType } from \"@tables/PvDataTable/helpers\";\n\nconst props = defineProps<{ params: ICellRendererParams }>();\nconst rowIndex = computed(() => {\n  return (props.params.node?.rowIndex || 0) + 1;\n});\n\nconst formattedValue = computed(() => {\n  const colDef = props.params.column?.getColDef();\n  const value = props.params.valueFormatted || props.params.value;\n  if (colDef && isColDefNumericDataType(colDef)) {\n    return value.toLocaleString();\n  }\n  return value;\n});\n</script>\n\n<template>\n  <div>\n    <p>\n      <span class=\"pv-table-row-number pv-text-quaternary\" v-if=\"rowIndex\">{{ rowIndex }}</span>\n      {{ formattedValue }}\n    </p>\n  </div>\n</template>\n\n<style scoped>\n.pv-table-row-number {\n  padding: 8px 12px 8px 0;\n  text-align: center;\n}\n</style>\n","<script setup lang=\"ts\">\nimport { watchDebounced } from \"@vueuse/core\";\nimport { inject, ref, Ref } from \"vue\";\nimport { useFilterStore } from \"@tables/PvDataTable/useFilterStore\";\nimport { EnableAdvancedFilterKey, GridApiKey } from \"@tables/symbols\";\nimport { PvSearchInput } from \"@/components/base\";\nimport PvQueryBuilderInput from \"@/components/base/PvQueryBuilderInput/PvQueryBuilderInput.vue\";\nimport {\n  QueryBuilderOutput,\n  QueryBuilderSuggestionMenuOption,\n  QueryTerm,\n} from \"@/components/base/PvQueryBuilderInput/useQueryBuilder\";\nimport { TableSearchHandlerParams, TableSearchStyle } from \"@tables/PvDataTable/types\";\nimport { mapQueryToAdvancedFilterModel, mapQueryToFilterModel } from \"@tables/PvDataTable/filters/filterHelpers\";\nimport { mapEntityTypeToHeaderIcon } from \"@tables/PvDataTable/table-components/formatting\";\nimport type { PvSize } from \"@/components/base/baseProps\";\n\nexport interface TableSearchProps {\n  placeholder: string;\n  searchStyle: TableSearchStyle;\n  size?: Extract<PvSize, \"lg\" | \"xl\">;\n}\n\nconst props = defineProps<TableSearchProps>();\nconst QUERY_TERM_DISPLAY_LIMIT = 4;\n\nconst tableQuery: Ref<QueryBuilderOutput | null> = ref(null);\nconst rawSearchText = ref<string>(\"\");\nconst queryOptions = ref<QueryBuilderSuggestionMenuOption[]>([]);\nconst queryOptionsLoading = ref(false);\nconst gridApi = inject(GridApiKey, ref(null));\nconst enableAdvancedFilter = inject(EnableAdvancedFilterKey, ref(false));\nconst { isServerSideFilter, filterModel, tableSearchHandler, applyTableSearchFilterModel } = useFilterStore();\n/*\n * Maps a query builder output to a filter model and pushes it into the server-side row request.\n */\nconst applyQueryAsFilterModel = (query: QueryBuilderOutput | null) => {\n  const nextFilterModel = enableAdvancedFilter.value\n    ? mapQueryToAdvancedFilterModel(query)\n    : mapQueryToFilterModel(query);\n  applyTableSearchFilterModel(nextFilterModel);\n};\n\n/*\n * Handling for free text search across all columns.\n *\n * Client-side tables use AG Grid's quick filter. Server-side tables have no quick-filter\n * equivalent, so the raw text is routed through the consumer's tableSearchHandler and the\n * returned terms are applied as a filter model - the same mapping the query builder uses, just\n * without the suggestion-picking step. This gives server-side tables an instant \"type to filter\"\n * search inline with their column filters.\n */\nconst handleFreeTextSearch = async (searchText: string) => {\n  if (!gridApi?.value || typeof gridApi.value.setGridOption !== \"function\") return;\n  if (!isServerSideFilter.value) {\n    gridApi.value.setGridOption(\"quickFilterText\", searchText);\n    return;\n  }\n  if (!tableSearchHandler?.value) {\n    console.error(\"Server-side free text search requires a tableSearchHandler to map the query to a filter model.\");\n    return;\n  }\n  const trimmedText = searchText.trim();\n  if (!trimmedText) {\n    applyQueryAsFilterModel(null);\n    return;\n  }\n  const params: TableSearchHandlerParams<unknown> = {\n    api: gridApi.value!,\n    query: trimmedText,\n    filterModel: filterModel.value,\n  };\n  const results = await tableSearchHandler.value(params);\n  const queryTerms = (results ?? []).filter((term): term is QueryTerm => term !== null);\n  applyQueryAsFilterModel({ queryTerms });\n};\n\n/*\n * Handling for filter model search bar (query builder)\n */\nconst handleFilterModelSearch = (query: QueryBuilderOutput | null) => {\n  if (!gridApi?.value) return;\n  if (!isServerSideFilter.value) {\n    console.error(\"Client-side filtering with query builder is not yet supported\");\n    return;\n  }\n  applyQueryAsFilterModel(query);\n};\n\nconst fetchQueryOptions = async (searchText: string) => {\n  if (!searchText || searchText.length < 2) {\n    queryOptions.value = [];\n    return;\n  }\n  if (!gridApi?.value || !tableSearchHandler?.value) return;\n  const params: TableSearchHandlerParams<unknown> = {\n    api: gridApi.value!,\n    query: searchText,\n    filterModel: filterModel.value,\n  };\n  queryOptionsLoading.value = true;\n  const results = await tableSearchHandler.value?.(params);\n  const queryTerms = results?.filter((item) => item !== null) || [];\n  // map to suggestion options\n  queryOptions.value = queryTerms.map((term: QueryTerm) => {\n    // fetch field icon based on col def\n    let fieldIcon = \"search\";\n    const fieldColDef = gridApi.value?.getColumnDef(term.queryField || \"\");\n    if (fieldColDef) {\n      fieldIcon = mapEntityTypeToHeaderIcon(fieldColDef.context?.dataType || null) || \"search\";\n    }\n    return {\n      id: `${term.queryField}-${term.queryText}`,\n      text: term.queryText,\n      icon: fieldIcon,\n      queryTerm: term,\n    } as QueryBuilderSuggestionMenuOption;\n  });\n  queryOptionsLoading.value = false;\n};\n\nwatchDebounced(\n  rawSearchText,\n  (newValue) => {\n    // ignore if using query builder\n    if (props.searchStyle === \"query-builder\") {\n      fetchQueryOptions(newValue);\n    } else if (props.searchStyle === \"text\") {\n      // client side supports quick filter, server side requires custom filtering\n      handleFreeTextSearch(newValue);\n    }\n  },\n  {\n    debounce: 300,\n    immediate: true,\n  },\n);\n\nwatchDebounced(\n  tableQuery,\n  (newValue) => {\n    if (props.searchStyle !== \"query-builder\") return;\n    handleFilterModelSearch(newValue);\n  },\n  {\n    debounce: 300,\n    immediate: true,\n    deep: true,\n  },\n);\n</script>\n\n<template>\n  <template v-if=\"searchStyle === 'query-builder'\">\n    <PvQueryBuilderInput\n      :placeholder=\"placeholder\"\n      v-model:search-text=\"rawSearchText\"\n      v-model:query=\"tableQuery\"\n      v-model:options=\"queryOptions\"\n      :options-loading=\"queryOptionsLoading\"\n      :query-term-display-limit=\"QUERY_TERM_DISPLAY_LIMIT\"\n      :size=\"size\"\n    />\n  </template>\n  <template v-else>\n    <PvSearchInput :placeholder=\"placeholder\" :size=\"size\" v-model=\"rawSearchText\" />\n  </template>\n</template>\n","<script setup lang=\"ts\">\nimport { watchDebounced } from \"@vueuse/core\";\nimport { inject, ref, Ref } from \"vue\";\nimport { useFilterStore } from \"@tables/PvDataTable/useFilterStore\";\nimport { EnableAdvancedFilterKey, GridApiKey } from \"@tables/symbols\";\nimport { PvSearchInput } from \"@/components/base\";\nimport PvQueryBuilderInput from \"@/components/base/PvQueryBuilderInput/PvQueryBuilderInput.vue\";\nimport {\n  QueryBuilderOutput,\n  QueryBuilderSuggestionMenuOption,\n  QueryTerm,\n} from \"@/components/base/PvQueryBuilderInput/useQueryBuilder\";\nimport { TableSearchHandlerParams, TableSearchStyle } from \"@tables/PvDataTable/types\";\nimport { mapQueryToAdvancedFilterModel, mapQueryToFilterModel } from \"@tables/PvDataTable/filters/filterHelpers\";\nimport { mapEntityTypeToHeaderIcon } from \"@tables/PvDataTable/table-components/formatting\";\nimport type { PvSize } from \"@/components/base/baseProps\";\n\nexport interface TableSearchProps {\n  placeholder: string;\n  searchStyle: TableSearchStyle;\n  size?: Extract<PvSize, \"lg\" | \"xl\">;\n}\n\nconst props = defineProps<TableSearchProps>();\nconst QUERY_TERM_DISPLAY_LIMIT = 4;\n\nconst tableQuery: Ref<QueryBuilderOutput | null> = ref(null);\nconst rawSearchText = ref<string>(\"\");\nconst queryOptions = ref<QueryBuilderSuggestionMenuOption[]>([]);\nconst queryOptionsLoading = ref(false);\nconst gridApi = inject(GridApiKey, ref(null));\nconst enableAdvancedFilter = inject(EnableAdvancedFilterKey, ref(false));\nconst { isServerSideFilter, filterModel, tableSearchHandler, applyTableSearchFilterModel } = useFilterStore();\n/*\n * Maps a query builder output to a filter model and pushes it into the server-side row request.\n */\nconst applyQueryAsFilterModel = (query: QueryBuilderOutput | null) => {\n  const nextFilterModel = enableAdvancedFilter.value\n    ? mapQueryToAdvancedFilterModel(query)\n    : mapQueryToFilterModel(query);\n  applyTableSearchFilterModel(nextFilterModel);\n};\n\n/*\n * Handling for free text search across all columns.\n *\n * Client-side tables use AG Grid's quick filter. Server-side tables have no quick-filter\n * equivalent, so the raw text is routed through the consumer's tableSearchHandler and the\n * returned terms are applied as a filter model - the same mapping the query builder uses, just\n * without the suggestion-picking step. This gives server-side tables an instant \"type to filter\"\n * search inline with their column filters.\n */\nconst handleFreeTextSearch = async (searchText: string) => {\n  if (!gridApi?.value || typeof gridApi.value.setGridOption !== \"function\") return;\n  if (!isServerSideFilter.value) {\n    gridApi.value.setGridOption(\"quickFilterText\", searchText);\n    return;\n  }\n  if (!tableSearchHandler?.value) {\n    console.error(\"Server-side free text search requires a tableSearchHandler to map the query to a filter model.\");\n    return;\n  }\n  const trimmedText = searchText.trim();\n  if (!trimmedText) {\n    applyQueryAsFilterModel(null);\n    return;\n  }\n  const params: TableSearchHandlerParams<unknown> = {\n    api: gridApi.value!,\n    query: trimmedText,\n    filterModel: filterModel.value,\n  };\n  const results = await tableSearchHandler.value(params);\n  const queryTerms = (results ?? []).filter((term): term is QueryTerm => term !== null);\n  applyQueryAsFilterModel({ queryTerms });\n};\n\n/*\n * Handling for filter model search bar (query builder)\n */\nconst handleFilterModelSearch = (query: QueryBuilderOutput | null) => {\n  if (!gridApi?.value) return;\n  if (!isServerSideFilter.value) {\n    console.error(\"Client-side filtering with query builder is not yet supported\");\n    return;\n  }\n  applyQueryAsFilterModel(query);\n};\n\nconst fetchQueryOptions = async (searchText: string) => {\n  if (!searchText || searchText.length < 2) {\n    queryOptions.value = [];\n    return;\n  }\n  if (!gridApi?.value || !tableSearchHandler?.value) return;\n  const params: TableSearchHandlerParams<unknown> = {\n    api: gridApi.value!,\n    query: searchText,\n    filterModel: filterModel.value,\n  };\n  queryOptionsLoading.value = true;\n  const results = await tableSearchHandler.value?.(params);\n  const queryTerms = results?.filter((item) => item !== null) || [];\n  // map to suggestion options\n  queryOptions.value = queryTerms.map((term: QueryTerm) => {\n    // fetch field icon based on col def\n    let fieldIcon = \"search\";\n    const fieldColDef = gridApi.value?.getColumnDef(term.queryField || \"\");\n    if (fieldColDef) {\n      fieldIcon = mapEntityTypeToHeaderIcon(fieldColDef.context?.dataType || null) || \"search\";\n    }\n    return {\n      id: `${term.queryField}-${term.queryText}`,\n      text: term.queryText,\n      icon: fieldIcon,\n      queryTerm: term,\n    } as QueryBuilderSuggestionMenuOption;\n  });\n  queryOptionsLoading.value = false;\n};\n\nwatchDebounced(\n  rawSearchText,\n  (newValue) => {\n    // ignore if using query builder\n    if (props.searchStyle === \"query-builder\") {\n      fetchQueryOptions(newValue);\n    } else if (props.searchStyle === \"text\") {\n      // client side supports quick filter, server side requires custom filtering\n      handleFreeTextSearch(newValue);\n    }\n  },\n  {\n    debounce: 300,\n    immediate: true,\n  },\n);\n\nwatchDebounced(\n  tableQuery,\n  (newValue) => {\n    if (props.searchStyle !== \"query-builder\") return;\n    handleFilterModelSearch(newValue);\n  },\n  {\n    debounce: 300,\n    immediate: true,\n    deep: true,\n  },\n);\n</script>\n\n<template>\n  <template v-if=\"searchStyle === 'query-builder'\">\n    <PvQueryBuilderInput\n      :placeholder=\"placeholder\"\n      v-model:search-text=\"rawSearchText\"\n      v-model:query=\"tableQuery\"\n      v-model:options=\"queryOptions\"\n      :options-loading=\"queryOptionsLoading\"\n      :query-term-display-limit=\"QUERY_TERM_DISPLAY_LIMIT\"\n      :size=\"size\"\n    />\n  </template>\n  <template v-else>\n    <PvSearchInput :placeholder=\"placeholder\" :size=\"size\" v-model=\"rawSearchText\" />\n  </template>\n</template>\n","<script setup lang=\"ts\">\nimport type { IHeaderGroupParams } from \"ag-grid-enterprise\";\n\nexport interface PvPivotGroupHeaderParams {\n  /** Secondary line under the group label, e.g. \"(Incumbent)\". */\n  subtitle?: string;\n  /** Hover text; defaults to the label. Useful when the label is shortened. */\n  tooltip?: string;\n  /** Position of the group, left to right; picks the bar color from the chart palette. */\n  colorIndex?: number;\n  /** Overrides the palette color for the bar. */\n  color?: string;\n  /** Shades the group header, e.g. for the incumbent. */\n  highlight?: boolean;\n}\n\n// Injected by AG Grid for pivot header groups. PvDataTable draws the color bar on the header cell itself.\ndefineProps<{\n  params: IHeaderGroupParams & PvPivotGroupHeaderParams;\n}>();\n</script>\n\n<template>\n  <div\n    class=\"pv-pivot-group-header pv-flex-vertical pv-full-width pv-text-center\"\n    data-testid=\"pv-pivot-group-header\"\n    :title=\"params.tooltip ?? params.displayName\"\n  >\n    <span class=\"pv-pivot-group-header__name pv-text-body-lg pv-text-medium\">{{ params.displayName }}</span>\n    <span v-if=\"params.subtitle\" class=\"pv-text-body-xs pv-text-subdued\">{{ params.subtitle }}</span>\n  </div>\n</template>\n\n<style>\n.pv-pivot-group-header {\n  --flex-gap: 0;\n  justify-content: center;\n  min-width: 0;\n  /* Keeps the text clear of the 4px color bar when a long name wraps and the header grows. */\n  padding-top: 4px;\n}\n\n/* Long names wrap onto a second line, then truncate; the full name is in the tooltip. */\n.pv-pivot-group-header__name {\n  display: -webkit-box;\n  -webkit-box-orient: vertical;\n  -webkit-line-clamp: 2;\n  line-clamp: 2;\n  overflow: hidden;\n  white-space: normal;\n  overflow-wrap: anywhere;\n  line-height: 1.25;\n}\n</style>\n","<script setup lang=\"ts\">\nimport type { IHeaderGroupParams } from \"ag-grid-enterprise\";\n\nexport interface PvPivotGroupHeaderParams {\n  /** Secondary line under the group label, e.g. \"(Incumbent)\". */\n  subtitle?: string;\n  /** Hover text; defaults to the label. Useful when the label is shortened. */\n  tooltip?: string;\n  /** Position of the group, left to right; picks the bar color from the chart palette. */\n  colorIndex?: number;\n  /** Overrides the palette color for the bar. */\n  color?: string;\n  /** Shades the group header, e.g. for the incumbent. */\n  highlight?: boolean;\n}\n\n// Injected by AG Grid for pivot header groups. PvDataTable draws the color bar on the header cell itself.\ndefineProps<{\n  params: IHeaderGroupParams & PvPivotGroupHeaderParams;\n}>();\n</script>\n\n<template>\n  <div\n    class=\"pv-pivot-group-header pv-flex-vertical pv-full-width pv-text-center\"\n    data-testid=\"pv-pivot-group-header\"\n    :title=\"params.tooltip ?? params.displayName\"\n  >\n    <span class=\"pv-pivot-group-header__name pv-text-body-lg pv-text-medium\">{{ params.displayName }}</span>\n    <span v-if=\"params.subtitle\" class=\"pv-text-body-xs pv-text-subdued\">{{ params.subtitle }}</span>\n  </div>\n</template>\n\n<style>\n.pv-pivot-group-header {\n  --flex-gap: 0;\n  justify-content: center;\n  min-width: 0;\n  /* Keeps the text clear of the 4px color bar when a long name wraps and the header grows. */\n  padding-top: 4px;\n}\n\n/* Long names wrap onto a second line, then truncate; the full name is in the tooltip. */\n.pv-pivot-group-header__name {\n  display: -webkit-box;\n  -webkit-box-orient: vertical;\n  -webkit-line-clamp: 2;\n  line-clamp: 2;\n  overflow: hidden;\n  white-space: normal;\n  overflow-wrap: anywhere;\n  line-height: 1.25;\n}\n</style>\n","<script setup lang=\"ts\">\nimport { ITooltipParams } from \"ag-grid-enterprise\";\n\ndefineProps<{\n  params: ITooltipParams;\n}>();\n</script>\n\n<template>\n  <div\n    style=\"background-color: var(--color-background-body, white); max-width: 300px\"\n    class=\"pv-inset-square-8 pv-bordered-md pv-text-md\"\n  >\n    <p style=\"color: var(--color-text-body, black)\">{{ params.value }}</p>\n  </div>\n</template>\n","<script setup lang=\"ts\">\nimport { ITooltipParams } from \"ag-grid-enterprise\";\n\ndefineProps<{\n  params: ITooltipParams;\n}>();\n</script>\n\n<template>\n  <div\n    style=\"background-color: var(--color-background-body, white); max-width: 300px\"\n    class=\"pv-inset-square-8 pv-bordered-md pv-text-md\"\n  >\n    <p style=\"color: var(--color-text-body, black)\">{{ params.value }}</p>\n  </div>\n</template>\n","<script lang=\"ts\">\nimport { ColDef, FirstDataRenderedEvent, GridApi, GridReadyEvent } from \"ag-grid-community\";\nimport {\n  Column,\n  FilterModel,\n  ICellRendererParams,\n  IServerSideGetRowsParams,\n  SetFilterValuesFuncParams,\n} from \"ag-grid-enterprise\";\nimport { ColDefDataType } from \"@tables/PvDataTable/table-components/formatting\";\nimport TableTooltip from \"./table-components/TableTooltip.vue\";\nimport { FocusUpdateEvent } from \"@/components/tables/PvDataTable/types\";\nimport {\n  AvailableFilterColumnsKey,\n  AvailableRowGroupColumnsKey,\n  ColumnDisplayOrderKey,\n  CurrentlyActiveFilterKey,\n  CurrentPageKey,\n  ExpandedRowsKey,\n  FirstDataRenderedKey,\n  GridApiKey,\n  GroupColumnCellValueColumnKey,\n  RowGroupColumnFieldsKey,\n  SortStateKey,\n  TotalPageKey,\n} from \"@/components/tables/symbols\";\nimport { liftFocusedOptions, isColDefNumericDataType } from \"@/components/tables/PvDataTable/helpers\";\n</script>\n\n<script setup lang=\"ts\" generic=\"T\">\nimport { AgGridVue } from \"ag-grid-vue3\";\nimport {\n  CellStyleModule,\n  ClientSideRowModelModule,\n  ColumnApiModule,\n  ColumnAutoSizeModule,\n  CustomFilterModule,\n  CsvExportModule,\n  EventApiModule,\n  GridStateModule,\n  IAggFuncParams,\n  IsServerSideGroupOpenByDefaultParams,\n  LoadSuccessParams,\n  MenuItemDef,\n  Module,\n  RowApiModule,\n  RowStyleModule,\n  PaginationModule,\n  RefreshServerSideParams,\n  PaginationChangedEvent,\n  SortChangedEvent,\n  SortModelItem,\n  QuickFilterModule,\n  TextFilterModule,\n  TextEditorModule,\n  CheckboxEditorModule,\n  UndoRedoEditModule,\n  SelectEditorModule,\n  LargeTextEditorModule,\n  NumberEditorModule,\n  DateEditorModule,\n  CustomEditorModule,\n  SelectionChangedEvent,\n  RowSelectedEvent,\n  RowDataUpdatedEvent,\n  CellValueChangedEvent,\n  ColumnValueChangedEvent,\n  UndoStartedEvent,\n  UndoEndedEvent,\n  RedoStartedEvent,\n  RedoEndedEvent,\n  ScrollApiModule,\n  RowClickedEvent,\n} from \"ag-grid-community\";\nimport {\n  AdvancedFilterModel,\n  AdvancedFilterModule,\n  ColumnAdvancedFilterModel,\n  JoinAdvancedFilterModel,\n  ClientSideRowModelApiModule,\n  ClipboardModule,\n  ColumnMenuModule,\n  ColumnMovedEvent,\n  ColumnResizedEvent,\n  ColumnRowGroupChangedEvent,\n  DefaultMenuItem,\n  FilterChangedEvent,\n  GetContextMenuItemsParams,\n  GetMainMenuItems,\n  GetMainMenuItemsParams,\n  GridState,\n  IMenuActionParams,\n  IRowNode,\n  IServerSideDatasource,\n  LicenseManager,\n  RichSelectModule,\n  RenderApiModule,\n  RowClassParams,\n  RowGroupingModule,\n  RowNode,\n  RowSelectionModule,\n  ServerSideRowModelApiModule,\n  ServerSideRowModelModule,\n  SetFilterModule,\n  ValidationModule,\n  TooltipModule,\n  MultiFilterModule,\n  CellSelectionModule,\n  ContextMenuModule,\n  PivotModule,\n  type ColGroupDef,\n  type PivotMaxColumnsExceededEvent,\n  type ValueFormatterParams,\n  type Theme,\n} from \"ag-grid-enterprise\";\nimport {\n  computed,\n  inject,\n  nextTick,\n  onBeforeMount,\n  onBeforeUnmount,\n  provide,\n  Ref,\n  ref,\n  shallowRef,\n  toRaw,\n  watch,\n} from \"vue\";\nimport { watchDebounced } from \"@vueuse/core\";\nimport Papa from \"papaparse\";\nimport GroupBySelector from \"@tables/PvDataTable/table-components/GroupBySelector.vue\";\nimport RowLoadingCellRenderer from \"@tables/PvDataTable/table-components/RowLoadingCellRenderer.vue\";\nimport AutoGroupColDefRenderer from \"@tables/PvDataTable/table-components/AutoGroupColDefRenderer.vue\";\nimport { calculateHighMedian } from \"@/functions/aggregations\";\nimport GroupAggCellRenderer from \"@tables/PvDataTable/table-components/GroupAggCellRenderer.vue\";\nimport FilterPanel from \"@tables/PvDataTable/table-components/FilterPanel.vue\";\nimport { arrayValueFormatter, currencyFormatter, integerFormatter, percentageFormatter } from \"@/functions/formatting\";\nimport HeaderCellRenderer from \"@tables/PvDataTable/table-components/HeaderCellRenderer.vue\";\nimport { themeMap, type PvDataTableTheme } from \"@tables/themes\";\nimport ExportMenu from \"@tables/PvDataTable/table-components/ExportMenu.vue\";\nimport PaginationPanel from \"@tables/PvDataTable/table-components/PaginationPanel.vue\";\nimport { useFilterStore, isRegularFilterModel } from \"@tables/PvDataTable/useFilterStore\";\nimport { usePivotCornerHeight, useShrinkToContent } from \"@tables/PvDataTable/useGridSizing\";\nimport PivotTableSkeleton from \"@tables/PvDataTable/table-components/PivotTableSkeleton.vue\";\nimport { useSlotPresence } from \"@/composables/useSlotPresence\";\nimport { isEqual } from \"es-toolkit\";\nimport TagCellRenderer from \"@tables/PvDataTable/table-components/TagCellRenderer.vue\";\nimport RowCountCellRenderer from \"@tables/PvDataTable/table-components/RowCountCellRenderer.vue\";\nimport { EnableAdvancedFilterKey, FilterStoreKey, FocusStoreKey, RowsLoadingKey } from \"@tables/symbols\";\nimport { createFocusStore } from \"@tables/PvDataTable/useFocus\";\nimport {\n  ColDefContextProps,\n  FilterValueResponseOption,\n  FilterValuesResponse,\n  FilterValuesSetHandlerParams,\n  PvDataTablePivot,\n  PvDataTableProps,\n  PvDataTablePublicInterface,\n  TableSearchHandlerParams,\n} from \"@tables/PvDataTable/types\";\nimport TableSearch from \"@tables/PvDataTable/table-components/TableSearch.vue\";\nimport { QueryTerm } from \"@/components/base/PvQueryBuilderInput/useQueryBuilder\";\nimport {\n  addHandlerToSetFilter,\n  cleanInitialGridState,\n  convertFilterModelToAdvanced,\n  filterModelContainsColId,\n  filterModelsEqual,\n  getSelectedValues,\n  hasSetFilter,\n  mergeAdvancedFilterCondition,\n  mergeFilterModels,\n} from \"@tables/PvDataTable/filters/filterHelpers\";\nimport { PvButton, PvTooltipV2 } from \"@/components/base\";\nimport { getAggregateFields, getAggregateRootField, processRowGroupCols } from \"@tables/PvDataTable/helpers.ts\";\nimport { BUCKET_AGG_FUNC_NAME } from \"@charts/PvDataTableWithChart/constants.ts\";\nimport PvPivotGroupHeader from \"@tables/PvDataTable/table-components/PvPivotGroupHeader.vue\";\nimport { multicolorFills } from \"@charts/themes\";\nconst modules: Module[] = [\n  AdvancedFilterModule,\n  CellSelectionModule,\n  CellStyleModule,\n  ClientSideRowModelApiModule,\n  ClientSideRowModelModule,\n  ClipboardModule,\n  ColumnApiModule,\n  ColumnAutoSizeModule,\n  ColumnMenuModule,\n  ContextMenuModule,\n  CsvExportModule,\n  CustomFilterModule,\n  EventApiModule,\n  GridStateModule,\n  MultiFilterModule,\n  ScrollApiModule,\n  ServerSideRowModelModule,\n  ServerSideRowModelApiModule,\n  SetFilterModule,\n  TextFilterModule,\n  RenderApiModule,\n  RowApiModule,\n  RowGroupingModule,\n  RowSelectionModule,\n  RowStyleModule,\n  PaginationModule,\n  PivotModule,\n  QuickFilterModule,\n  TooltipModule,\n  TextEditorModule,\n  UndoRedoEditModule,\n  CheckboxEditorModule,\n  SelectEditorModule,\n  LargeTextEditorModule,\n  NumberEditorModule,\n  DateEditorModule,\n  CustomEditorModule,\n  RichSelectModule,\n];\n\nconst AG_GRID_LICENSE_KEY =\n  \"Using_this_{AG_Grid}_Enterprise_key_{AG-084011}_in_excess_of_the_licence_granted_is_not_permitted___Please_report_misuse_to_legal@ag-grid.com___For_help_with_changing_this_key_please_contact_info@ag-grid.com___{Turquoise_Health}_is_granted_a_{Multiple_Applications}_Developer_License_for_{3}_Front-End_JavaScript_developers___All_Front-End_JavaScript_developers_need_to_be_licensed_in_addition_to_the_ones_working_with_{AG_Grid}_Enterprise___This_key_has_been_granted_a_Deployment_License_Add-on_for_{2}_Production_Environments___This_key_works_with_{AG_Grid}_Enterprise_versions_released_before_{16_August_2026}____[v3]_[01]_MTc4NjgzNDgwMDAwMA==3bfdb2557ede1aa3533ccbd05785addb\";\nLicenseManager.setLicenseKey(AG_GRID_LICENSE_KEY);\n\nconst props = withDefaults(defineProps<PvDataTableProps<T>>(), {\n  allFieldsAreFocusable: false,\n  displayBaseAggregationsOnly: false,\n  displayRowNumber: false,\n  displayGroupCount: true,\n  displayPreferencesIcon: false,\n  enableColumnVisibilitySelector: false,\n  enableCsvExport: false,\n  enableFocusView: false,\n  enableFullRowClick: false,\n  enableGroupBySelector: false,\n  enableVerticalFilterPanel: true,\n  enableInlineFilters: false,\n  hideAllRowGroupedColumns: false,\n  csvRowLimit: 20000,\n  requireFiltersToShowData: false,\n  debugMode: false,\n  containerHeight: \"500px\",\n  containerMinHeight: \"200px\",\n  layout: undefined,\n  shrinkToContent: false,\n  pagination: false,\n  paginationPageSize: 50,\n  tooltipShowDelay: 1000,\n  isTableGrouped: false,\n  groupDefaultExpanded: 1,\n  focusableColumns: () => [],\n  tableSearchPlaceholder: \"Search\",\n  tableSearchStyle: \"text\",\n  tableSearchSize: \"xl\",\n  tableSearchInline: false,\n  maxHorizontalFilters: 5,\n  wrapHorizontalFilters: false,\n  filterPanelReadOnly: false,\n  disableUnselectedReadOnlyFilters: false,\n  maintainColumnOrder: true,\n  copyHeadersToClipboard: false,\n  cellSelection: false,\n  suppressCutToClipboard: true,\n  suppressClipboardPaste: true,\n  undoRedoCellEditing: false,\n  undoRedoCellEditingLimit: 10,\n  enableAdvancedFilter: false,\n  refreshFiltersInBackground: false,\n  stageFilterChangesUntilDropdownCloses: false,\n  devMode: false,\n  pivotRowLimit: 200,\n  pivotMaxGeneratedColumns: 50,\n  pivotTotalLabel: \"Total\",\n});\n\n// only load validation module in dev mode\nif (props.debugMode) {\n  modules.push(ValidationModule);\n}\n\n// With `shrinkToContent`, `containerHeight` is a ceiling and the grid takes its rows' height up to it (fixed at mount).\nconst shrinkEnabled = props.shrinkToContent && !props.layout;\n\nconst containerCssProps = computed(() => {\n  if (props.layout) {\n    return {};\n  }\n  return {\n    [shrinkEnabled ? \"maxHeight\" : \"height\"]: props.containerHeight,\n    minHeight: props.containerMinHeight,\n  };\n});\n\nconst gridWrapperRef = ref<HTMLElement | null>(null);\nconst shrink = shrinkEnabled ? useShrinkToContent(gridWrapperRef) : undefined;\n\n// Percent heights don't resolve in a container that only has a ceiling, so the grid fills its wrapper directly.\nconst shrinkGridStyle = shrinkEnabled ? { position: \"absolute\" as const, top: 0, left: 0 } : undefined;\n\nconst isThemeObject = computed(() => props.theme != null && typeof props.theme !== \"string\");\n\nconst computedThemeName = computed<PvDataTableTheme>(() => {\n  if (props.theme && typeof props.theme === \"string\") {\n    return props.theme;\n  }\n  if (rowGroupColumnFields.value.length > 0) {\n    return \"pv-data-table-grouped\";\n  }\n  return \"pv-data-table-base\";\n});\n\nconst themeClass: PvDataTableTheme =\n  props.theme && typeof props.theme === \"string\" ? props.theme : \"pv-data-table-base\";\n\nconst computedTheme = computed<Theme>(() => {\n  const theme = isThemeObject.value ? (props.theme as Theme) : themeMap[computedThemeName.value];\n  // Pivot tables are dense: compact rows, medium weight headers, and no resize handle lines (the strokes are in CSS).\n  return pivotEnabled\n    ? theme.withParams({\n        rowHeight: \"36px\",\n        headerFontWeight: 500,\n        headerColumnResizeHandleColor: \"transparent\",\n      })\n    : theme;\n});\n\n// propagate grid events we want to the parent\nconst emit = defineEmits<{\n  (e: \"column-moved\", event: ColumnMovedEvent<T>): void;\n  (e: \"column-resized\", event: ColumnResizedEvent<T>): void;\n  (e: \"column-row-group-changed\", event: ColumnRowGroupChangedEvent<T>): void;\n  (e: \"column-value-changed\", event: ColumnValueChangedEvent<T>): void;\n  (e: \"grid-ready\", event: GridReadyEvent<T>): void;\n  (e: \"filter-changed\", event: FilterChangedEvent<T>): void;\n  (e: \"sort-changed\", event: SortChangedEvent<T>): void;\n  (e: \"filter-opened\", event: FilterChangedEvent<T>): void;\n  (e: \"first-data-rendered\", event: FirstDataRenderedEvent<T>): void;\n  (e: \"handle-settings-icon\", value: string): void;\n  (e: \"focus-update\", event: FocusUpdateEvent): void;\n  (e: \"selection-changed\", event: SelectionChangedEvent): void;\n  (e: \"row-selected\", event: RowSelectedEvent): void;\n  (e: \"row-data-updated\", event: RowDataUpdatedEvent): void;\n  (e: \"cell-value-changed\", event: CellValueChangedEvent): void;\n  (e: \"undo-started\", event: UndoStartedEvent): void;\n  (e: \"undo-ended\", event: UndoEndedEvent): void;\n  (e: \"redo-started\", event: RedoStartedEvent): void;\n  (e: \"redo-ended\", event: RedoEndedEvent): void;\n  (e: \"row-clicked\", event: RowClickedEvent<T>): void;\n  (e: \"pivot-max-columns-exceeded\", event: PivotMaxColumnsExceededEvent<T>): void;\n  (\n    e: \"filter-metadata-changed\",\n    payload: {\n      filterValueMap: Record<string, (FilterValueResponseOption | null)[]>;\n      filterValueSelectedMetadataMap: Record<string, (FilterValueResponseOption | null)[]>;\n    },\n  ): void;\n}>();\n\nconst devModeEnabled = ref(false);\n\nconst getAggregateSearchTargetFields = (aggregateColDef: ColDef<T>): string[] => {\n  const aggregateFields = getAggregateFields(aggregateColDef);\n  const aggregateContext = aggregateColDef.context as ColDefContextProps<T> | undefined;\n\n  return Array.from(\n    new Set([\n      ...aggregateFields,\n      ...(aggregateContext?.queryColIds || []),\n      ...aggregateFields.flatMap((field) => {\n        const backingColDef = updatedColDefs.find((colDef) => colDef.field === field || colDef.colId === field);\n        const backingContext = backingColDef?.context as ColDefContextProps<T> | undefined;\n        return backingContext?.queryColIds || [];\n      }),\n    ]),\n  );\n};\n\nconst tableSearchFilterTargetsTopLevelGroup = (\n  tableSearchFilter: FilterModel | AdvancedFilterModel | null | undefined,\n  topLevelGroup: string,\n): boolean => {\n  if (filterModelContainsColId(tableSearchFilter, topLevelGroup)) return true;\n\n  const aggregateColDef = updatedColDefs.find((colDef) => getAggregateRootField(colDef) === topLevelGroup);\n  return (\n    !!aggregateColDef &&\n    getAggregateSearchTargetFields(aggregateColDef).some((field) => filterModelContainsColId(tableSearchFilter, field))\n  );\n};\n\n/*\n * Server Side Grid Configuration\n */\n\n// Pivot mode pivots client-side rows, so it never uses the server-side row model. Fixed at mount.\nconst pivotEnabled = !!props.pivot;\n// Room for the color bar, a one line name, and a subtitle.\nconst PIVOT_GROUP_HEADER_HEIGHT = 48;\n// Measure columns repeat for every pivot value, so they start narrower than the regular 150px to keep the table\n// from running off the page.\nconst PIVOT_COLUMN_MIN_WIDTH = 100;\n\nconst pivotCorner = pivotEnabled ? usePivotCornerHeight(gridWrapperRef, PIVOT_GROUP_HEADER_HEIGHT) : undefined;\nconst pivotFrameStyle = computed(() =>\n  pivotCorner ? { \"--pv-pivot-corner-height\": `${pivotCorner.height.value}px` } : undefined,\n);\n\n// attach row handler if server side data source is provided\nconst serverSideDataSource: IServerSideDatasource | null =\n  !pivotEnabled && \"serverSideRowHandler\" in props && props.serverSideRowHandler\n    ? {\n        getRows: (params) => {\n          if (!displayUnfilteredTableData.value) {\n            params.success({ rowData: [] });\n            // set first data rendered to allow filter dropdowns to start fetching data\n            firstDataRendered.value = true;\n            return;\n          }\n\n          rowsLoading.value = true;\n          const originalSuccess = params.success;\n          const originalFail = params.fail;\n          /**\n           * If we are making a request for data, we only want to add the table filter in certain scenarios:\n           * 1. if the request is for child rows.\n           * \tThis allows grouped requests to return correct data for the primary filter model and not affect the\n           * \taggregations. The table filter is designed to only filter out child rows (visually).\n           * \tA child row request is when the request params groupKeys and rowGroupCols are the same length\n           * 2. If the table filter has a\n           */\n          const groupKeyLength = params.request.groupKeys?.length || 0;\n          const rowGroupColsLength = params.request.rowGroupCols?.length || 0;\n          const requestForChildRows = groupKeyLength === rowGroupColsLength;\n\n          let applyTableFilterToGroupRequest = false;\n          const tableSearchFilter = tableSearchFilterModel.value;\n          if (rowGroupColsLength > 0 && groupKeyLength === 0) {\n            const topLevelGroup = params.request.rowGroupCols[0].id;\n            // If the table filter includes the top-level group, apply it. For nested aggregate filters,\n            // also apply child-field searches to the parent group request so matching parent containers render.\n            applyTableFilterToGroupRequest = tableSearchFilterTargetsTopLevelGroup(tableSearchFilter, topLevelGroup);\n          }\n          params.request.rowGroupCols = processRowGroupCols(params.request.rowGroupCols, params.api.getColumnDefs?.());\n          // For bucket aggregation columns, inject range filters from bucketMin/bucketMax\n          // when expanding a group row (i.e. groupKeys has a value for a bucket column)\n          if ((params.request.groupKeys?.length || 0) > 0) {\n            const parentData = params.parentNode?.data;\n            if (parentData?.bucketMin != null && parentData?.bucketMax != null) {\n              if (props.enableAdvancedFilter) {\n                // Advanced filter mode: construct ColumnAdvancedFilterModel conditions with colId\n                let advFilterModel: AdvancedFilterModel | null =\n                  (params.request.filterModel as AdvancedFilterModel) || null;\n                params.request.rowGroupCols?.forEach((col, index) => {\n                  if (col.aggFunc === BUCKET_AGG_FUNC_NAME && index < params.request.groupKeys!.length) {\n                    const colKey = col.field || col.id;\n                    const rangeCondition: JoinAdvancedFilterModel = {\n                      filterType: \"join\",\n                      type: \"AND\",\n                      conditions: [\n                        {\n                          filterType: \"number\",\n                          colId: colKey,\n                          type: \"greaterThanOrEqual\",\n                          filter: parentData.bucketMin,\n                        } as ColumnAdvancedFilterModel,\n                        {\n                          filterType: \"number\",\n                          colId: colKey,\n                          type: \"lessThanOrEqual\",\n                          filter: parentData.bucketMax,\n                        } as ColumnAdvancedFilterModel,\n                      ],\n                    };\n                    advFilterModel = mergeAdvancedFilterCondition(advFilterModel, rangeCondition, colKey);\n                  }\n                });\n                if (advFilterModel) {\n                  params.request.filterModel = advFilterModel;\n                }\n              } else {\n                // Regular filter mode: construct number filter keyed by column ID\n                const filterModel = (params.request.filterModel || {}) as FilterModel;\n                params.request.rowGroupCols?.forEach((col, index) => {\n                  if (col.aggFunc === BUCKET_AGG_FUNC_NAME && index < params.request.groupKeys!.length) {\n                    const colKey = col.field || col.id;\n                    filterModel[colKey] = {\n                      filterType: \"number\",\n                      operator: \"AND\",\n                      conditions: [\n                        {\n                          filterType: \"number\",\n                          type: \"greaterThanOrEqual\",\n                          filter: parentData.bucketMin,\n                        },\n                        {\n                          filterType: \"number\",\n                          type: \"lessThanOrEqual\",\n                          filter: parentData.bucketMax,\n                        },\n                      ],\n                    };\n                  }\n                });\n                params.request.filterModel = filterModel;\n              }\n              // Strip bucket entries from groupKeys/rowGroupCols so the server\n              // returns leaf-level data filtered by the range instead\n              params.request.groupKeys = params.request.groupKeys!.filter(\n                (_, i) => params.request.rowGroupCols?.[i]?.aggFunc !== BUCKET_AGG_FUNC_NAME,\n              );\n              params.request.rowGroupCols = params.request.rowGroupCols!.filter(\n                (col) => col.aggFunc !== BUCKET_AGG_FUNC_NAME,\n              );\n            }\n          }\n          if (params.request.rowGroupCols?.length === 0) {\n            // if there are no row group cols, we don't aggregate on anything\n            params.request.valueCols = [];\n          } else {\n            // remove any grouping columns from the value cols\n            params.request.valueCols = params.request.valueCols?.filter(\n              (valueCol) => !params.request.rowGroupCols?.some((groupCol) => groupCol.id === valueCol.id),\n            );\n          }\n          const shouldApplyTableFilter =\n            (requestForChildRows || applyTableFilterToGroupRequest) && !filterStore.tableSearchFilterModelEmpty.value;\n          if (shouldApplyTableFilter) {\n            params.request.filterModel = withTableSearch(params.request.filterModel);\n          }\n          // Wrap the success callback to apply focus lifting\n          params.success = (result: LoadSuccessParams<T>) => {\n            rowsLoading.value = false;\n            // Apply focus lifting for server side data source\n            if (props.enableFocusView && focuses.value.length > 0 && focusType.value && result.rowData) {\n              const liftedData = liftFocusedOptions(result.rowData, focusType.value as keyof T, focuses.value);\n              if (liftedData) {\n                result.rowData = liftedData;\n                originalSuccess(result);\n                return;\n              }\n            }\n            originalSuccess(result);\n          };\n          // Wrap the fail callback to track loading state\n          params.fail = () => {\n            rowsLoading.value = false;\n            originalFail();\n          };\n          props.serverSideRowHandler?.(params);\n        },\n      }\n    : null;\n\n// attach filter values set handler if server side data source is provided, and trigger an event when new values\n// are set\nconst gridFilterValuesSetHandler: ((params: SetFilterValuesFuncParams<T, FilterValueResponseOption>) => void) | null =\n  \"filterValuesSetHandler\" in props && props.filterValuesSetHandler\n    ? async (params: SetFilterValuesFuncParams<T, FilterValueResponseOption>) => {\n        // if we haven't rendered data yet, and we have initial state, the filter model is not yet set\n        let results = [];\n        const copiedFilterModel = { ...filterModel.value };\n        if (!firstDataRendered.value && cleanedInitialGridState) {\n          // During initial grid setup, provide results immediately to avoid blocking the grid rendering.\n          // We need to populate selected values in here, or they will be deselected on initial load.\n          // Use getSelectedValues which handles both regular FilterModel and AdvancedFilterModel.\n          const colId = params.colDef.field ?? params.colDef.colId ?? \"\";\n          results = getSelectedValues(copiedFilterModel, colId) || [];\n        } else {\n          results = await fetchFilterValues(params.colDef, {\n            api: params.api,\n            filterModel: copiedFilterModel,\n            useStaged: false,\n          });\n        }\n        // We add an empty value (that gets filtered out before the dropdown is shown) to the list of values to fix\n        // an AG grid bug where returning results that match the current selections (or less than that) causes\n        // the entire filter to be cleared.\n        params.success([...results, \"\"] as unknown as FilterValueResponseOption[]);\n      }\n    : null;\n\nconst rowNodeContainsAggregateValue = (params: ICellRendererParams) => {\n  if (params.column?.getColDef().pivotValueColumn) return false;\n  const node = params.node as RowNode<T>;\n  const colField = params.column?.getColId();\n  // we only want to show the aggregate value if the node is a group node and is for a column with an agg function\n  if (!node.group || !colField) return false;\n  return availableAggFuncColumns.value.some((col) => {\n    if (col.field === colField) {\n      return true;\n    }\n  });\n};\n\n// define default column definitions (individual column definitions can override these)\nconst defaultColDef: ColDef<T> = (() => {\n  const colDef: ColDef<T> = {\n    suppressHeaderFilterButton: !props.enableInlineFilters,\n    editable: false,\n    sortable: true,\n    suppressHeaderMenuButton: true,\n    suppressColumnsToolPanel: true,\n    minWidth: 150,\n    flex: 1,\n    headerComponent: !props.enableInlineFilters ? HeaderCellRenderer : undefined,\n    cellDataType: false,\n    tooltipComponent: TableTooltip,\n    cellClass: (params) => {\n      // don't right align the group column\n      if (isAutoGroupCol(params.column)) {\n        return \"\";\n      }\n      if (isColDefNumericDataType(params.column?.getColDef())) {\n        return \"pv-text-right\";\n      }\n      return \"\";\n    },\n    cellRendererSelector: (params: ICellRendererParams) => {\n      // this cell renderer should override other cell renderers\n      if (rowNodeContainsAggregateValue(params)) {\n        // respect custom cellRenderer if defined on the colDef\n        if (params.column?.getColDef().cellRenderer) {\n          return undefined;\n        }\n        return {\n          component: GroupAggCellRenderer,\n          params: params,\n        };\n      }\n      // for other renderers don't override the cell renderer if one is already defined\n      if (params.column?.getColDef().cellRenderer) {\n        return undefined;\n      }\n      // we can display row numbers if the prop is true and we are not grouping\n      if (props.displayRowNumber && !pivotEnabled && rowGroupColumnFields.value.length === 0) {\n        const allCols = params.api.getAllDisplayedColumns() || [];\n        const currentCol = params.column;\n        const displayIndex = allCols.findIndex((c) => c === currentCol);\n        if (displayIndex === 0) {\n          return {\n            component: RowCountCellRenderer,\n            params: params,\n          };\n        }\n      }\n      return undefined;\n    },\n  };\n  if (props.defaultColDefOverrides) {\n    Object.assign(colDef, props.defaultColDefOverrides);\n  }\n  return colDef;\n})();\n\n/*\n * Header Menu Configuration\n */\nconst getMainMenuItems: Ref<GetMainMenuItems<T> | undefined> = ref(undefined);\n\nconst getContextMenuItems = computed(() => {\n  return (params: GetContextMenuItemsParams<T>) => {\n    // Use custom handler if provided\n    if (props.getContextMenuItems) {\n      return props.getContextMenuItems(params);\n    }\n\n    // Default: show cut, copy, paste (respecting suppressions)\n    const items = [];\n    items.push(\"copy\");\n    if (!props.suppressCutToClipboard) {\n      items.push(\"cut\");\n    }\n    if (!props.suppressClipboardPaste) {\n      items.push(\"paste\");\n    }\n    return items;\n  };\n});\n\nconst customFilterMenuItem: MenuItemDef = {\n  name: \"Column Filter\",\n  icon: '<span class=\"ag-icon ag-icon-filter\"></span>',\n  action: function (params: IMenuActionParams) {\n    let colId = params.column?.getColId() as string;\n    // strip 'ag-Grid-AutoColumn-' prefix if the column is auto-generated from grouping\n    if (params.column && isAutoGroupCol(params.column)) {\n      colId = groupColumnCellValueColumn.value?.getColId() || \"\";\n    }\n    // Pin the filter so it is created if missing and stays visible as the filter row narrows.\n    const filterColDef = params.api.getColumn(colId)?.getColDef();\n    if (filterColDef) currentlyActiveFilter.value = filterColDef;\n    if (filterPanelRef.value?.openHorizontalFilter(colId)) return;\n    nextTick(() => {\n      if (filterPanelRef.value?.openHorizontalFilter(colId)) return;\n      // Too narrow to show the filter even on its own: fall back to the All Filters drawer.\n      if (filterPanelRef.value?.isHorizontalFilterCollapsed(colId)) {\n        filterPanelRef.value.openVerticalDrawer();\n      }\n    });\n  },\n};\n\nconst isClickableCell = (params: { data?: T; node?: { group?: boolean }; value?: unknown }) =>\n  !params.node?.group && params.data != null && params.value != null && params.value !== \"\";\n\nconst updateColDefWithContext = (colDef: ColDef<T> | null, context: ColDefContextProps<T>) => {\n  if (!colDef) return null;\n  const updatedColDef = { ...colDef };\n  const updatedContext = context;\n  const aggregateFields = getAggregateFields(colDef);\n\n  if (updatedContext.devOnly) {\n    if (!props.devMode) {\n      return null;\n    } else {\n      updatedColDef.hide = true;\n    }\n  }\n  if (aggregateFields.length > 0) {\n    if (!props.enableAdvancedFilter) {\n      console.warn(\n        \"Aggregate fields are only supported with advanced filtering enabled. Please enable advanced filtering to use aggregate fields.\",\n      );\n      return null;\n    }\n    // we only use the filter ability for aggregate field col defs, we don't want to show the actual column\n    updatedColDef.hide = true;\n    updatedColDef.suppressColumnsToolPanel = true;\n    updatedColDef.lockVisible = true;\n  }\n  if (updatedContext.isCellClickable) {\n    updatedColDef.cellClassRules = {\n      ...updatedColDef.cellClassRules,\n      \"pv-data-table-cell-clickable\": isClickableCell,\n    };\n    if (!updatedColDef.tooltipField && !updatedColDef.tooltipValueGetter) {\n      updatedColDef.tooltipValueGetter = (params) => (isClickableCell(params) ? \"Click to view details\" : undefined);\n    }\n  }\n  if (props.enableAdvancedFilter) {\n    // we need unique ids for the advanced filter to work properly\n    const existingHeaderValueGetter = colDef.headerValueGetter;\n    updatedColDef.headerValueGetter = (params) => {\n      if (params.location === \"advancedFilter\") {\n        return updatedColDef.colId || updatedColDef.field || \"\";\n      }\n      if (existingHeaderValueGetter && typeof existingHeaderValueGetter === \"function\") {\n        return existingHeaderValueGetter(params);\n      } else if (existingHeaderValueGetter && typeof existingHeaderValueGetter === \"string\") {\n        return existingHeaderValueGetter;\n      }\n      return updatedColDef.headerName || updatedColDef.field || \"\";\n    };\n  }\n  if (updatedContext.isArrayField && !colDef.valueFormatter) {\n    updatedColDef.valueFormatter = (params) => {\n      return arrayValueFormatter(params, updatedContext.dataType);\n    };\n  } else if (updatedContext.dataType === ColDefDataType.Percent && !colDef.valueFormatter) {\n    updatedColDef.valueFormatter = (params) => percentageFormatter(params, updatedContext.valueDecimals || 0);\n  } else if (updatedContext.dataType === ColDefDataType.Currency && !colDef.valueFormatter) {\n    updatedColDef.valueFormatter = (params) => currencyFormatter(params, updatedContext.valueDecimals || 0);\n  } else if (updatedContext.dataType === ColDefDataType.Integer && !colDef.valueFormatter) {\n    updatedColDef.valueFormatter = integerFormatter;\n  } else if (updatedContext.dataType === ColDefDataType.Tag && !colDef.cellRenderer) {\n    updatedColDef.cellRenderer = TagCellRenderer;\n  }\n  return updatedColDef;\n};\n\n/*\n * Pivot Configuration\n */\n\nconst colDefField = (colDef: ColDef<T>) => colDef.colId || colDef.field || \"\";\n\n// The ids of the colDefs that match, by the given index and then colDef order.\nconst pivotFields = (\n  matches: (colDef: ColDef<T>) => boolean,\n  indexOf: (colDef: ColDef<T>) => number | null = () => null,\n) =>\n  (props.colDefs ?? [])\n    .map((colDef, index) => ({ colDef, index }))\n    .filter(({ colDef }) => matches(colDef))\n    .sort((a, b) => (indexOf(a.colDef) ?? a.index) - (indexOf(b.colDef) ?? b.index) || a.index - b.index)\n    .map(({ colDef }) => colDefField(colDef));\n\n// The layout comes from the colDefs' own AG Grid props: `rowGroup` down the side, `pivot` across the top, and the\n// columns with an `aggFunc` (unless `enableValue: false`) as the measures.\nconst pivotConfig: PvDataTablePivot | null = pivotEnabled\n  ? {\n      rowGroupCols: pivotFields(\n        (colDef) => !!colDef.rowGroup,\n        (colDef) => colDef.rowGroupIndex ?? null,\n      ),\n      pivotCols: pivotFields(\n        (colDef) => !!colDef.pivot && !colDef.rowGroup,\n        (colDef) => colDef.pivotIndex ?? null,\n      ),\n      valueCols: pivotFields(\n        (colDef) => !!colDef.aggFunc && !colDef.rowGroup && !colDef.pivot && colDef.enableValue !== false,\n      ),\n    }\n  : null;\n\nconst pivotSourceColDef = (colId: string | undefined) =>\n  colId ? props.colDefs?.find((colDef) => colDefField(colDef) === colId) : undefined;\nconst pivotContext = (colId: string | undefined) =>\n  pivotSourceColDef(colId)?.context as ColDefContextProps<T> | undefined;\n// The row field behind a column id.\nconst pivotDataField = (colId: string) => pivotSourceColDef(colId)?.field ?? colId;\n\n// Order for the first pivot column's values: `pivotValueOrder`, then focused values (e.g. the incumbent), then alphabetical.\nconst pivotGroupComparator = (valueA: string, valueB: string) => {\n  const focused = focusType.value === pivotConfig?.pivotCols[0] ? focuses.value : [];\n  const order = [...(props.pivotValueOrder ?? []), ...focused].map(String);\n  const rank = (value: string) => {\n    const index = order.indexOf(String(value));\n    return index === -1 ? order.length : index;\n  };\n  return rank(valueA) - rank(valueB) || String(valueA).localeCompare(String(valueB));\n};\n\n// Server rows are already aggregated, so a cell shows its one row. A cell built from several rows (a parent\n// subtotal, or duplicate rows) can't be worked out from them, so it's left blank. Raw rowData is aggregated with\n// the column's own function.\nconst singleRowAggFunc = (params: IAggFuncParams<T>) => (params.values.length === 1 ? params.values[0] : null);\n\n// Pivot group rows are built client-side and have no data of their own, so a row group column's formatter\n// gets the group's first row instead. Every row in the group shares the key, so its label fields match.\nconst withGroupRowData = (valueFormatter: ColDef<T>[\"valueFormatter\"]): ColDef<T>[\"valueFormatter\"] => {\n  if (typeof valueFormatter !== \"function\") return valueFormatter;\n  return (params) =>\n    valueFormatter(\n      params.data || !params.node?.group ? params : { ...params, data: params.node.allLeafChildren?.[0]?.data },\n    );\n};\n\nconst applyPivotRole = (colDef: ColDef<T>): ColDef<T> => {\n  const pivot = pivotConfig!;\n  const field = colDefField(colDef);\n  const rowGroupIndex = pivot.rowGroupCols.indexOf(field);\n  const pivotIndex = pivot.pivotCols.indexOf(field);\n  const isValue = pivot.valueCols.includes(field);\n  return {\n    ...colDef,\n    valueFormatter: rowGroupIndex !== -1 ? withGroupRowData(colDef.valueFormatter) : colDef.valueFormatter,\n    rowGroup: rowGroupIndex !== -1,\n    rowGroupIndex: rowGroupIndex !== -1 ? rowGroupIndex : null,\n    pivot: pivotIndex !== -1,\n    pivotIndex: pivotIndex !== -1 ? pivotIndex : null,\n    pivotComparator: pivotIndex === 0 ? pivotGroupComparator : colDef.pivotComparator,\n    aggFunc: isValue ? (props.serverSidePivotHandler ? singleRowAggFunc : colDef.aggFunc) : null,\n    enableValue: isValue,\n  };\n};\n\n// Column defs before pivot roles are applied.\nconst baseColDefs =\n  props.colDefs\n    ?.map((colDef) => {\n      let updatedColDef = { ...colDef } as ColDef<T> | null;\n      if ((serverSideDataSource || pivotEnabled) && gridFilterValuesSetHandler && hasSetFilter(colDef)) {\n        updatedColDef = addHandlerToSetFilter<T>(colDef, gridFilterValuesSetHandler);\n      }\n      const colDefContextProps = colDef.context as ColDefContextProps<T> | undefined;\n      // use the custom context to override definitions as needed\n      if (colDefContextProps) {\n        updatedColDef = updateColDefWithContext(updatedColDef, colDefContextProps);\n      }\n      return updatedColDef;\n    })\n    .filter((colDef): colDef is ColDef<T> => colDef != null) || [];\n// With no row groups, every row goes into one labeled group so the single row has a label column.\nconst PIVOT_TOTAL_COL_ID = \"__pv_pivot_total__\";\nconst pivotTotalColDef: ColDef<T> = {\n  colId: PIVOT_TOTAL_COL_ID,\n  headerName: \"\",\n  rowGroup: true,\n  rowGroupIndex: 0,\n  suppressColumnsToolPanel: true,\n  valueGetter: () => props.pivotTotalLabel,\n};\n\nconst updatedColDefs = pivotEnabled\n  ? [...baseColDefs.map(applyPivotRole), ...(pivotConfig?.rowGroupCols.length ? [] : [pivotTotalColDef])]\n  : baseColDefs;\n\n// Validate that aggregate field hierarchy entries reference existing colDefs\nconst allFieldIds = new Set(props.colDefs?.map((cd) => cd.field || cd.colId).filter(Boolean) || []);\nfor (const colDef of updatedColDefs) {\n  for (const aggregateField of getAggregateFields(colDef)) {\n    if (!allFieldIds.has(aggregateField)) {\n      console.warn(\n        `aggregate field hierarchy references \"${aggregateField}\" on column \"${colDef.field || colDef.colId}\", but no colDef with that field exists.`,\n      );\n    }\n  }\n}\n\n// A consumer marking any column with a visibilityState has opted into the column-configuration\n// semantics, which is the signal to restore column order from grid state.\nconst hasColumnConfigSemantics = updatedColDefs.some((colDef) => colDef.context?.visibilityState !== undefined);\n\n// In pivot mode the `pivot` prop owns row groups, pivots, and aggregation, so saved grid state can't override them.\nconst withoutPivotOwnedState = <S extends GridState | null | undefined>(state: S): S => {\n  if (!pivotEnabled || !state) return state;\n  const rest = { ...state };\n  delete rest.rowGroup;\n  delete rest.pivot;\n  delete rest.aggregation;\n  return rest;\n};\n\nconst cleanedInitialGridState = withoutPivotOwnedState(\n  cleanInitialGridState(props.initialGridState, updatedColDefs, props.enableAdvancedFilter),\n);\n\nconst currentlyActiveFilter: Ref<ColDef | null> = ref(null);\nconst rowGroupColumnFields: Ref<string[]> = ref([]);\nconst firstDataRendered: Ref<boolean> = inject(FirstDataRenderedKey, ref(false));\nconst rowsLoading: Ref<boolean> = ref(false);\n\nconst requiredGroupHeaderName = computed(() => {\n  if (rowGroupColumnFields.value.length > 0) {\n    // get first group only\n    const firstGroupField = rowGroupColumnFields.value[0];\n    const colDef = updatedColDefs.find((col) => col.field === firstGroupField);\n    // check if filter model has a filter for that column\n    const currentModel = filterModel.value;\n    let colFilterModelEmpty = !currentModel;\n    if (!colFilterModelEmpty && isRegularFilterModel(currentModel)) {\n      const regularModel = currentModel as FilterModel;\n      colFilterModelEmpty = !regularModel[firstGroupField];\n    }\n    // if filter is required to group and no filter is applied, don't show/fetch data\n    if (colFilterModelEmpty && colDef?.context?.filterRequiredToGroup) {\n      return colDef.headerName;\n    }\n  }\n  return null;\n});\n\nconst displayUnfilteredTableData = computed(() => {\n  //check if any filters required and if filter model is empty\n  const filterModelEmpty = filterStore.filterModelEmpty.value;\n  if (filterModelEmpty && props.requireFiltersToShowData) {\n    return false;\n  }\n  // otherwise, check if we have grouped rows and have restrictions on those columns\n  return requiredGroupHeaderName.value === null;\n});\n\nconst filterRestrictionMessage = computed(() => {\n  if (requiredGroupHeaderName.value) {\n    return `Select at least one value for \"${requiredGroupHeaderName.value}\" to view data.`;\n  }\n  return `Select a filter to view data.`;\n});\n\n// grid api/models that we track to make available to child components\nconst gridApi = shallowRef<GridApi<T> | null>(null);\nconst sortState = ref<SortModelItem[]>([]);\n// Use an explicitly provided filter store first, then injected context, then create a private store.\nconst filterStore = props.filterStore || useFilterStore();\nconst injectedFocusStore = inject(FocusStoreKey, null);\nconst focusStore = injectedFocusStore || createFocusStore(null, props.allFieldsAreFocusable);\n// Access store properties individually to avoid Vue production warning\nconst filterModel = filterStore.filterModel;\nconst tableSearchFilterModel = filterStore.tableSearchFilterModel;\nconst filterValueMap = filterStore.filterValueMap;\nconst filterValuesMap = filterStore.filterValuesMap;\nconst filterValueSelectedMetadataMap = filterStore.filterValueSelectedMetadataMap;\nconst fetchFilterValues = filterStore.fetchFilterValues;\nconst filterStoreHandler = filterStore.filterStoreHandler;\nconst tableSearchHandler = filterStore.tableSearchHandler;\n\nfilterStoreHandler.value = props.filterValuesSetHandler as\n  | ((\n      params: FilterValuesSetHandlerParams<unknown>,\n    ) => Promise<FilterValuesResponse | (FilterValueResponseOption | null)[]>)\n  | undefined;\nif (filterStoreHandler.value) {\n  const currentFilterOptionsResponse = (field: string): FilterValuesResponse => ({\n    hasMore: filterStore.filterHasMoreMap.value[field],\n    totalCount: filterStore.filterTotalCountMap.value[field],\n    values: filterStore.filterOptionsMap.value[field] ?? [],\n  });\n\n  filterStore.setFilterOptionsHandler(async (params) => {\n    const handler = filterStoreHandler.value;\n    if (!handler) return currentFilterOptionsResponse(params.field);\n\n    const response = await handler({\n      ...params,\n      api: (gridApi.value as unknown as GridApi<unknown> | null) ?? undefined,\n      colDef: params.colDef as ColDef<unknown>,\n      filterModel: params.filterModel as FilterModel | AdvancedFilterModel | null | undefined,\n    });\n    return response ?? currentFilterOptionsResponse(params.field);\n  });\n}\ntableSearchHandler.value = props.tableSearchHandler as\n  | ((params: TableSearchHandlerParams<unknown>) => Promise<(QueryTerm | null)[]>)\n  | undefined;\n\n// provide initial data for the filter values to format properly\nfilterValueMap.value = props.initialFilterValueMap || {};\nfilterValuesMap.value = Object.fromEntries(\n  Object.entries(props.initialFilterValueMap || {}).map(([field, values]) => [\n    field,\n    values.filter((item) => item != null).map((item) => item.value),\n  ]),\n);\nfilterValueSelectedMetadataMap.value = props.initialFilterValueSelectedMetadataMap || {};\nfilterStore.refreshFiltersInBackground.value = props.refreshFiltersInBackground ?? false;\nfilterStore.stageFilterChangesUntilDropdownCloses.value = props.stageFilterChangesUntilDropdownCloses ?? false;\nfilterStore.filterSearchMinLength.value = props.filterSearchMinLength;\nfilterStore.filterModelType.value = props.enableAdvancedFilter ? \"advanced\" : \"regular\";\n\nwatch(\n  () => props.enableAdvancedFilter,\n  (enableAdvancedFilter) => {\n    filterStore.filterModelType.value = enableAdvancedFilter ? \"advanced\" : \"regular\";\n  },\n);\n\n// Emit filter metadata changes so consumers can persist and re-seed on remount.\n// Debounced because the underlying maps mutate on every filter fetch, append,\n// and child-merge — a raw deep watch would fire dozens of times per user\n// interaction. 250ms coalesces bursts (initial fetch → metadata lands → see-more\n// → aggregate child merges) into a single emit per settled state.\nwatchDebounced(\n  [filterValueMap, filterValueSelectedMetadataMap],\n  () => {\n    emit(\"filter-metadata-changed\", {\n      filterValueMap: filterValueMap.value,\n      filterValueSelectedMetadataMap: filterValueSelectedMetadataMap.value,\n    });\n  },\n  { deep: true, debounce: 250 },\n);\nconst columnDisplayOrder = ref<Column[] | null>(null);\n\nconst focusType = computed(() => {\n  return focusStore?.computedFocusType.value || null;\n});\n\nconst focuses = computed(() => {\n  return focusStore?.computedFocuses.value || [];\n});\n\nconst availableFilterColumns = computed(() => {\n  return updatedColDefs.filter((col) => col.filter);\n});\nconst availableRowGroupColumns = computed(() => {\n  return updatedColDefs.filter((col) => col.enableRowGroup);\n});\n// Pivot roles rewrite aggFuncs, so the chart keeps reading the original defs.\nconst availableAggFuncColumns = computed(() => {\n  return baseColDefs.filter((col) => col.aggFunc);\n});\n\nconst groupColumnCellValueColumn: Ref<Column<T> | null> = ref(null);\nconst expandedRows: Ref<Record<number, boolean>> = ref({});\nconst currentPage = ref(1);\nconst totalPages = ref(0);\n\n// All provided values are reactive and can be accessed by child components via injection\nprovide(FilterStoreKey, filterStore);\nprovide(FocusStoreKey, focusStore);\nprovide(SortStateKey, sortState);\nprovide(GridApiKey, gridApi);\nprovide(ColumnDisplayOrderKey, columnDisplayOrder);\nprovide(CurrentlyActiveFilterKey, currentlyActiveFilter);\nprovide(AvailableFilterColumnsKey, availableFilterColumns);\nprovide(AvailableRowGroupColumnsKey, availableRowGroupColumns);\nprovide(RowGroupColumnFieldsKey, rowGroupColumnFields);\nprovide(GroupColumnCellValueColumnKey, groupColumnCellValueColumn);\nprovide(ExpandedRowsKey, expandedRows);\nprovide(FirstDataRenderedKey, firstDataRendered);\nprovide(RowsLoadingKey, rowsLoading);\nprovide(CurrentPageKey, currentPage);\nprovide(TotalPageKey, totalPages);\n\n// Provide advanced filter state as a computed ref for reactivity\nconst enableAdvancedFilterRef = computed(() => props.enableAdvancedFilter);\nprovide(EnableAdvancedFilterKey, enableAdvancedFilterRef);\n\nconst pivotRowData = shallowRef<T[] | undefined>(undefined);\n// Left-to-right position of each first-pivot-column value, used for header colors.\nconst pivotGroupIndex = computed(() => {\n  const colId = pivotConfig?.pivotCols[0];\n  const field = colId && pivotDataField(colId);\n  const rows = pivotRowData.value ?? props.rowData;\n  if (!field || !rows) return new Map<string, number>();\n  const values = Array.from(new Set(rows.map((row) => String((row as Record<string, unknown>)[field]))));\n  return new Map(values.sort(pivotGroupComparator).map((value, index) => [value, index]));\n});\n\nconst toColumnVO = (colId: string, withAggFunc: boolean) => {\n  const colDef = pivotSourceColDef(colId);\n  return {\n    id: colId,\n    field: colDef?.field ?? colId,\n    displayName: colDef?.headerName || colId,\n    // The server aggregates with the column's own function; the grid then just shows that value.\n    aggFunc: withAggFunc && typeof colDef?.aggFunc === \"string\" ? colDef.aggFunc : undefined,\n  };\n};\n\n// The table search isn't a grid filter, so server requests only see it merged into their filter model.\nconst withTableSearch = (filters: FilterModel | AdvancedFilterModel | null | undefined) => {\n  const search = tableSearchFilterModel.value;\n  if (filterStore.tableSearchFilterModelEmpty.value) return filters ?? null;\n  if (props.enableAdvancedFilter) {\n    return filters\n      ? ({ filterType: \"join\", type: \"AND\", conditions: [filters, search] } as AdvancedFilterModel)\n      : search;\n  }\n  return mergeFilterModels(updatedColDefs, filters as FilterModel | null, search as FilterModel);\n};\n\nlet pivotRequestId = 0;\nconst loadPivotRows = async () => {\n  if (!pivotConfig || !props.serverSidePivotHandler) return;\n  const requestId = ++pivotRequestId;\n  if (!displayUnfilteredTableData.value) {\n    pivotRowData.value = [];\n    firstDataRendered.value = true;\n    return;\n  }\n  rowsLoading.value = true;\n  try {\n    const response = await props.serverSidePivotHandler({\n      rowGroupCols: [...pivotConfig.rowGroupCols, ...pivotConfig.pivotCols].map((field) => toColumnVO(field, false)),\n      valueCols: pivotConfig.valueCols.map((field) => toColumnVO(field, true)),\n      filterModel: withTableSearch(filterModel.value),\n      endRow: props.pivotRowLimit,\n    });\n    // Ignore responses that a newer filter change has superseded.\n    if (requestId === pivotRequestId) pivotRowData.value = response.data as T[];\n  } catch (error) {\n    console.error(\"Failed to load pivot rows\", error);\n    if (requestId === pivotRequestId) pivotRowData.value = [];\n  } finally {\n    if (requestId === pivotRequestId) rowsLoading.value = false;\n  }\n};\n\n// A pivot has no columns until its rows arrive, so loading shows a skeleton instead of an empty grid.\nconst pivotLoading = computed(\n  () =>\n    pivotEnabled && (props.isLoading || (!!props.serverSidePivotHandler && (rowsLoading.value || !pivotRowData.value))),\n);\n\n// One style object, so the shrunk size can't lose to a static `flex: 1`; the skeleton sets its own height while it shows.\nconst gridWrapperStyle = computed(() => ({\n  width: \"100%\",\n  minHeight: 0,\n  overflowX: \"hidden\" as const,\n  ...(shrink?.contentHeight.value && !pivotLoading.value\n    ? { flex: \"0 1 auto\", height: `${shrink.contentHeight.value}px` }\n    : { flex: \"1\" }),\n}));\n\n// A loading pivot has no columns, so its grid steps aside and the skeleton sizes the wrapper.\nconst pivotLoadingGridStyle = computed(() =>\n  pivotLoading.value ? { position: \"absolute\" as const, top: 0, left: 0, visibility: \"hidden\" as const } : undefined,\n);\n\n// A row in a header group: every pivot value down to the group matches (nested pivots have one per level). All rows\n// in the group share those values, so any one has the group's label fields.\nconst pivotGroupData = (pivotKeys: string[]): Partial<T> | undefined =>\n  (pivotRowData.value ?? props.rowData)?.find((row) =>\n    pivotKeys.every(\n      (key, level) =>\n        String((row as Record<string, unknown>)[pivotDataField(pivotConfig!.pivotCols[level])]) === String(key),\n    ),\n  );\n\n// The group's label from the pivot column's own valueFormatter, given a row from the group as `data` (as row group\n// labels are), so a formatter that reads another field (e.g. a name for an id) works.\nconst formatPivotGroupLabel = (colId: string | undefined, value: string, data: Partial<T> | undefined) => {\n  const colDef = updatedColDefs.find((col) => colDefField(col) === colId);\n  if (typeof colDef?.valueFormatter !== \"function\") return undefined;\n  return colDef.valueFormatter({ value, data, colDef, node: null } as unknown as ValueFormatterParams<T>) || undefined;\n};\n\n// Adds the shared group header and its palette position, labeled by the pivot column's valueFormatter, then the\n// column's own header config (`pivotGroupHeader`).\nconst handleProcessPivotResultColGroupDef = (colGroupDef: ColGroupDef<T>) => {\n  const pivotKeys = colGroupDef.pivotKeys ?? [];\n  const key = pivotKeys.at(-1);\n  const colId = pivotConfig?.pivotCols[pivotKeys.length - 1];\n  const value = key == null ? undefined : String(key);\n  const data = pivotGroupData(pivotKeys);\n  const { headerName, ...headerParams } =\n    (value != null &&\n      pivotContext(colId)?.pivotGroupHeader?.({\n        value,\n        data,\n        focused: focusType.value === colId && focuses.value.map(String).includes(value),\n      })) ||\n    {};\n  colGroupDef.headerGroupComponent = PvPivotGroupHeader;\n  colGroupDef.marryChildren = true;\n  // Long names wrap instead of truncating, so the header row grows past PIVOT_GROUP_HEADER_HEIGHT to fit them.\n  colGroupDef.autoHeaderHeight = true;\n  const label = headerName ?? (value == null ? undefined : formatPivotGroupLabel(colId, value, data));\n  if (label) colGroupDef.headerName = label;\n  colGroupDef.headerGroupComponentParams = {\n    ...colGroupDef.headerGroupComponentParams,\n    // Only top-level groups get a color.\n    colorIndex: pivotKeys.length === 1 ? pivotGroupIndex.value.get(String(pivotKeys[0])) : undefined,\n    ...headerParams,\n  };\n\n  // The header cell draws the color tab (see .pv-pivot-group), so it sits at the very top of the group.\n  const { color, colorIndex, highlight } = colGroupDef.headerGroupComponentParams;\n  const barColor =\n    color ?? (colorIndex == null ? undefined : multicolorFills[colorIndex % multicolorFills.length].slice(0, 7));\n  colGroupDef.headerClass = [\"pv-pivot-group\", ...(highlight ? [\"pv-pivot-group--highlight\"] : [])];\n  if (barColor && typeof colGroupDef.headerStyle !== \"function\") {\n    colGroupDef.headerStyle = { ...colGroupDef.headerStyle, \"--pv-pivot-group-color\": barColor };\n  }\n};\n\n// Adds a class while keeping the column's own (e.g. right alignment), including computed (function) classes.\nconst toClassList = (value: unknown): string[] => (Array.isArray(value) ? value : value ? [String(value)] : []);\nconst withClass = (existing: unknown, className: string) => {\n  if (typeof existing === \"function\") {\n    return (params: unknown) => [...toClassList(existing(params)), className];\n  }\n  return [...toClassList(existing), className];\n};\n\n// Applies the measure's `pivotColDef` and styles its header.\nconst handleProcessPivotResultColDef = (colDef: ColDef<T>) => {\n  colDef.minWidth = PIVOT_COLUMN_MIN_WIDTH;\n  // At the narrower width, a long title wraps and the header row grows to fit it instead of clipping.\n  colDef.autoHeaderHeight = true;\n  Object.assign(colDef, pivotContext(colDef.pivotValueColumn?.getColId())?.pivotColDef);\n  colDef.headerClass = withClass(colDef.headerClass, \"pv-pivot-column-header\") as ColDef<T>[\"headerClass\"];\n};\n\n// Server rows are already filtered by the handler, so the grid keeps the filter model (for the filter UI and the\n// next request) without re-applying it to them.\nconst pivotAlwaysPassFilter = pivotEnabled && props.serverSidePivotHandler ? () => true : undefined;\n\nconst processedRowData = computed(() => {\n  if (pivotEnabled) {\n    return pivotRowData.value ?? props.rowData;\n  }\n  if (\n    (!props.enableFocusView && !props.rowData) ||\n    (props.enableFocusView && !focuses.value.length && !focusType.value)\n  ) {\n    return props.rowData;\n  }\n\n  return liftFocusedOptions(props.rowData, focusType.value as keyof T, focuses.value);\n});\n\n// Watching the request itself skips reloads where the search or filters changed to an equal request.\nwatch([() => JSON.stringify(withTableSearch(filterModel.value)), displayUnfilteredTableData], () => {\n  if (pivotEnabled && gridApi.value) void loadPivotRows();\n});\n\n// The comparator only runs when the grid builds the pivot columns, so a later order is applied by moving them.\nconst applyPivotValueOrder = () => {\n  const api = gridApi.value;\n  const pivotColumns = api?.getPivotResultColumns();\n  if (!api || !pivotColumns?.length) return;\n  const allColumns = api.getAllGridColumns();\n  const groupValue = (column: Column) => String(column.getColDef().pivotKeys?.[0]);\n  const ordered = [...pivotColumns].sort(\n    (a, b) => pivotGroupComparator(groupValue(a), groupValue(b)) || allColumns.indexOf(a) - allColumns.indexOf(b),\n  );\n  const start = Math.min(...ordered.map((column) => allColumns.indexOf(column)));\n  if (ordered.every((column, i) => allColumns[start + i] === column)) return;\n  api.moveColumns(ordered, start);\n};\n\nwatch(() => props.pivotValueOrder, applyPivotValueOrder);\n\nwatch(\n  () => focuses.value,\n  (newVal) => {\n    emit(\"focus-update\", { filterField: focusType.value, focuses: newVal });\n  },\n);\n\nwatch(devModeEnabled, (enabled) => {\n  if (!gridApi.value) return;\n  const devColIds = updatedColDefs\n    .filter((col) => (col.context as ColDefContextProps<T>)?.devOnly)\n    .map((col) => col.field!)\n    .filter(Boolean);\n  if (devColIds.length > 0) {\n    gridApi.value.setColumnsVisible(devColIds, enabled);\n  }\n});\n\n/*\n * Emit Handlers\n * These functions are called when the grid emits events\n * we perform any necessary logic and then emit the event to the parent\n */\nconst handleGridReady = (params: GridReadyEvent) => {\n  // set the grid api in the provide so that child components can access it\n  gridApi.value = params.api;\n  void shrink?.observe();\n  void pivotCorner?.observe();\n\n  // The leftmost column is either the specified left pinned column, the first visible row-grouped column,\n  // or the first visible column overall. Row group columns with hide: true are skipped.\n  const firstVisibleGroupField = rowGroupColumnFields.value.find((field) => {\n    const colDef = updatedColDefs.find((col) => col.field === field);\n    return !colDef?.hide;\n  });\n  const firstVisibleColField =\n    !firstVisibleGroupField && rowGroupColumnFields.value.length > 0\n      ? (updatedColDefs.find((col) => !col.hide && !col.rowGroup)?.field ?? null)\n      : null;\n  const leftmostColumn = props.leftPinnedColumnName ?? firstVisibleGroupField ?? firstVisibleColField;\n\n  // If specified, hide all row-grouped columns.\n  const colsToHide = [];\n  if (props.hideAllRowGroupedColumns) {\n    rowGroupColumnFields.value.forEach((field) => colsToHide.push(field));\n  }\n\n  // The first row group field will be either the pinned column property (if it's passed in) or the first row group column.\n  // We want to \"hide\" that column from the main table view because it will be redundant with being pinned to the left.\n  if (leftmostColumn) {\n    const leftmostCol = params.api.getColumn(leftmostColumn);\n    groupColumnCellValueColumn.value = leftmostCol;\n    colsToHide.push(leftmostColumn);\n    applyLeftmostColDefToAutoGroup(leftmostCol?.getColDef());\n  }\n  if (cleanedInitialGridState) {\n    updateGridState(cleanedInitialGridState);\n  } else if (filterModel.value) {\n    setPvFilterModel(filterModel.value);\n  }\n  if (tableSearchFilterModel.value) {\n    setTableSearchFilterModel(tableSearchFilterModel.value);\n  }\n  params.api.setColumnsVisible([...colsToHide], false);\n  if (pivotEnabled) void loadPivotRows();\n  columnDisplayOrder.value = [...params.api.getAllGridColumns()];\n  currentPage.value = params.api.paginationGetCurrentPage() + 1;\n  totalPages.value = params.api.paginationGetTotalPages();\n  emit(\"grid-ready\", params);\n};\n\n// keep track of the filter model for the custom filters\nconst handleFilterChanged = (params: FilterChangedEvent) => {\n  if (gridApi.value) {\n    const newModel = getPvFilterModel();\n    // only store/emit if the filter model is different from the current one\n    if (!filterModelsEqual(filterModel.value, newModel)) {\n      filterModel.value = newModel;\n      emit(\"filter-changed\", params);\n    }\n  }\n};\n\nconst handleSortChanged = (params: SortChangedEvent) => {\n  sortState.value = params.api?.getState()?.sort?.sortModel || [];\n  if (firstDataRendered.value) {\n    emit(\"sort-changed\", params);\n  }\n};\n\n// TODO - filter out columns in the current rowGroupColumnList (for initial state)\nconst isAutoGroupCol = (col: Column<T>) => {\n  return col.getColId() && col.getColId().includes(\"ag-Grid-AutoColumn\");\n};\n\n/*\n * CSV Logic\n */\n\nconst isExporting = ref(false);\n\nconst refreshData = async (params?: RefreshServerSideParams | null) => {\n  if (!gridApi.value) {\n    console.error(\"Grid API not available\");\n    return;\n  }\n  if (pivotEnabled) {\n    await loadPivotRows();\n    return;\n  }\n  // skip if we're in client side mode\n  if (!serverSideDataSource) {\n    return;\n  }\n  const refreshParams = params || { route: [], purge: true };\n  gridApi.value.refreshServerSide(refreshParams);\n};\n\n// Returns the selected-value metadata map. Pass `{ hydrate: true }` to first fetch options for any\n// active filter not already cached (e.g. to persist a complete map for a public view) — async in that case.\nfunction getFilterValueSelectedMetadataMap(): Record<string, (FilterValueResponseOption | null)[]>;\nfunction getFilterValueSelectedMetadataMap(options: {\n  hydrate: true;\n}): Promise<Record<string, (FilterValueResponseOption | null)[]>>;\nfunction getFilterValueSelectedMetadataMap(options?: { hydrate?: boolean }) {\n  if (options?.hydrate) return filterStore.hydrateSelectedFilterMetadata(updatedColDefs);\n  return filterValueSelectedMetadataMap.value;\n}\n\nconst getCsvData = async (): Promise<string | null> => {\n  isExporting.value = true;\n\n  if (!gridApi.value) {\n    console.error(\"Grid API not available\");\n    isExporting.value = false;\n    return null;\n  }\n\n  try {\n    if (pivotEnabled) {\n      // The grid's own export writes the pivot as displayed (group headers and measures).\n      gridApi.value.exportDataAsCsv();\n      isExporting.value = false;\n      return null;\n    }\n    const csvHandler = props.serverSideCsvHandler;\n    const gridState = gridApi.value?.getState();\n    const exportParamsRequest = {\n      rowGroupCols: [],\n      valueCols:\n        gridApi.value?.getValueColumns().map((col) => ({\n          id: col.getId(),\n          field: col.getColDef().field,\n          aggFunc: typeof col.getColDef().aggFunc === \"string\" ? (col.getColDef().aggFunc as string) : undefined,\n          displayName: col.getColDef().headerName || col.getColDef().field || \"\",\n        })) || [],\n      filterModel: getPvFilterModel(),\n      sortModel: gridState?.sort?.sortModel || [],\n      pivotCols: [],\n      pivotMode: false,\n      groupKeys: [],\n      startRow: 0,\n      endRow: props.csvRowLimit,\n    };\n\n    if (csvHandler) {\n      const exportParams: IServerSideGetRowsParams = {\n        request: exportParamsRequest,\n        parentNode: {} as IRowNode<T>,\n        api: gridApi.value!,\n        context: undefined,\n        success: () => {},\n        fail: () => {},\n      };\n\n      await props.serverSideCsvHandler(exportParams);\n      isExporting.value = false;\n      return null;\n    }\n\n    const rowHandler = props.serverSideRowHandler;\n    if (rowHandler) {\n      return await new Promise((resolve, reject) => {\n        const gridState = gridApi.value?.getState();\n        const exportParams: IServerSideGetRowsParams = {\n          request: exportParamsRequest,\n          parentNode: {} as IRowNode<T>,\n          api: gridApi.value!,\n          context: undefined,\n          success: (params: LoadSuccessParams<T>) => {\n            const groupColFields =\n              gridApi.value\n                ?.getRowGroupColumns()\n                .map((col) => col.getColDef().field)\n                .filter((field): field is string => !!field) || [];\n            const displayedColFields =\n              gridApi.value\n                ?.getAllDisplayedColumns()\n                .map((col) => col.getColDef().field)\n                .filter((field): field is string => !!field) || [];\n            const valueColFields =\n              gridApi.value\n                ?.getValueColumns()\n                .map((col) => col.getColDef().field)\n                .filter((field): field is string => !!field) || [];\n            const csvFields = Array.from(new Set([...groupColFields, ...displayedColFields, ...valueColFields]));\n\n            const filteredRows = params.rowData.map((row) => {\n              const filteredRow: Record<string, string | null> = {};\n              csvFields.forEach((field) => {\n                const value = (row as Record<string, unknown>)[field];\n                filteredRow[field] = value != null ? String(value) : null;\n              });\n              return filteredRow;\n            });\n\n            const csv = Papa.unparse(filteredRows);\n            isExporting.value = false;\n            resolve(csv);\n          },\n          fail: () => {\n            isExporting.value = false;\n            reject(\"CSV export failed.\");\n          },\n        };\n\n        rowHandler(exportParams, true);\n      });\n    } else {\n      // TODO: Handle client side expose\n      console.warn(\"Client-side export does not return CSV string\");\n      isExporting.value = false;\n      gridApi.value.exportDataAsCsv();\n      return null;\n    }\n  } catch (e) {\n    console.error(\"CSV export failed\", e);\n    isExporting.value = false;\n    return null;\n  }\n};\n\nconst getPvFilterModel = (): FilterModel | AdvancedFilterModel | null => {\n  if (!gridApi.value) {\n    return filterModel.value;\n  }\n  if (props.enableAdvancedFilter) {\n    return gridApi.value.getAdvancedFilterModel();\n  } else {\n    return gridApi.value.getFilterModel();\n  }\n};\n\nconst setPvFilterModel = (model: FilterModel | AdvancedFilterModel | null): boolean => {\n  if (!gridApi.value) {\n    return false;\n  }\n  if (props.enableAdvancedFilter) {\n    const convertedModel = model && isRegularFilterModel(model) ? convertFilterModelToAdvanced(model) : model;\n    gridApi.value.setAdvancedFilterModel(convertedModel);\n  } else {\n    if (model && !isRegularFilterModel(model)) {\n      console.warn(\n        \"Attempting to set a non-regular filter model while advanced filtering is disabled. The filter model was not applied. Consider enabling advanced filtering for full functionality.\",\n      );\n      return false;\n    }\n    gridApi.value.setFilterModel(model);\n  }\n  return true;\n};\n\nconst setTableSearchFilterModel = (model: FilterModel | AdvancedFilterModel | null): boolean => {\n  tableSearchFilterModel.value = model;\n  if (!gridApi.value) {\n    return false;\n  }\n  gridApi.value.onFilterChanged();\n  if (serverSideDataSource) {\n    gridApi.value.refreshServerSide({ purge: true });\n  }\n  return true;\n};\n\nconst externalFilterController = {\n  getFilterModel: getPvFilterModel,\n  refreshData,\n  setFilterModel: setPvFilterModel,\n  setTableSearchFilterModel,\n};\n\nfilterStore.registerFilterController(externalFilterController);\n\nonBeforeUnmount(() => {\n  filterStore.unregisterFilterController(externalFilterController);\n});\n\ndefineExpose<PvDataTablePublicInterface>({\n  getCsvData,\n  refreshData,\n  getFilterValueSelectedMetadataMap,\n  availableRowGroupColumns,\n  availableAggFuncColumns,\n  rowGroupColumnFields,\n  getPvFilterModel,\n  setPvFilterModel,\n});\n\nconst handleColumnValueChanged = (event: ColumnValueChangedEvent<T>) => {\n  event.api.refreshHeader();\n  emit(\"column-value-changed\", event);\n};\n\n// keep track of the row group columns for the group by selector\nconst handleColumnRowGroupChanged = (event: ColumnRowGroupChangedEvent<T>) => {\n  nextTick(() => {\n    const prevGroupColumnCellValueColumn = groupColumnCellValueColumn.value;\n    const newRowGroupColumns = event.api.getRowGroupColumns();\n    const groupingExists = newRowGroupColumns.length > 0;\n\n    // If a pinned column is specified, pin it to the left. Otherwise, pick the first visible row group column.\n    // Row group columns with hide: true in their colDef are skipped.\n    let leftmostColumn;\n    if (groupingExists && props.leftPinnedColumnName) {\n      leftmostColumn = event.api.getColumn(props.leftPinnedColumnName || \"\");\n    }\n    if (groupingExists && !props.leftPinnedColumnName) {\n      leftmostColumn = newRowGroupColumns.find((col) => !col.getColDef().hide);\n      // If all row group columns are hidden, fall back to the first visible non-group column\n      if (!leftmostColumn) {\n        const firstVisibleField = updatedColDefs.find((col) => !col.hide && !col.rowGroup)?.field;\n        if (firstVisibleField) {\n          leftmostColumn = event.api.getColumn(firstVisibleField);\n        }\n      }\n    }\n\n    if (leftmostColumn) {\n      groupColumnCellValueColumn.value = leftmostColumn;\n      applyLeftmostColDefToAutoGroup(leftmostColumn.getColDef());\n      event.api.setColumnsVisible([leftmostColumn.getColId()], false);\n    } else {\n      groupColumnCellValueColumn.value = null;\n      applyLeftmostColDefToAutoGroup(null);\n    }\n    const prevGroupColId = prevGroupColumnCellValueColumn?.getColId();\n    if (!leftmostColumn || prevGroupColId !== leftmostColumn.getColId()) {\n      // Only re-show the previous column if its colDef doesn't have hide: true\n      const prevColDef = prevGroupColumnCellValueColumn?.getColDef();\n      if (!prevColDef?.hide) {\n        event.api.setColumnsVisible([prevGroupColId || \"\"], true);\n      }\n    }\n    rowGroupColumnFields.value = [...newRowGroupColumns].map((col) => col.getColId());\n    // only handle focus events here if we have our own focus store\n    if (props.enableFocusView && !injectedFocusStore) {\n      const newFocusType = rowGroupColumnFields.value.length > 0 ? rowGroupColumnFields.value[0] : null;\n      focusStore.setFocusType(newFocusType);\n    }\n    if (firstDataRendered.value) {\n      emit(\"column-row-group-changed\", event);\n    }\n  });\n};\n\nconst handleColumnVisibleChanged = (event: ColumnResizedEvent<T>) => {\n  // prevent visibility of column if it patches the active groupColumnCellValueColumn\n  const colId = event.column?.getColId() || \"\";\n  if (colId === groupColumnCellValueColumn.value?.getColId()) {\n    event.api.setColumnsVisible([colId], false);\n    return;\n  }\n  //TODO - clear sort if column is hidden and has an active sort\n};\n\nconst handleRowClicked = (event: RowClickedEvent<T>) => {\n  if (props.enableExpandOnRowClick) {\n    // if we clicked a grouped row, toggle the expanded state of that row\n    if (event.node.group) {\n      event.node.setExpanded(!event.node.expanded);\n    }\n  }\n  emit(\"row-clicked\", event);\n};\n\n// keep track of column positions to disable resizing on the last column\nconst handleColumnMoved = (event: ColumnMovedEvent<T>) => {\n  if (event.finished) {\n    // getAllGridColumns returns AG Grid's internal array, which moves mutate in\n    // place — copy it so the ref assignment actually triggers reactivity.\n    columnDisplayOrder.value = [...event.api.getAllGridColumns()];\n  }\n  // A drag the consumer's order disagrees with (e.g. it keeps a focused value first) snaps back.\n  if (pivotEnabled && props.pivotValueOrder && event.finished && event.source === \"uiColumnMoved\") {\n    nextTick(applyPivotValueOrder);\n  }\n  if (firstDataRendered.value) {\n    emit(\"column-moved\", event);\n  }\n};\n\nconst handlePaginationChanged = (event: PaginationChangedEvent<T>) => {\n  if (event.api) {\n    currentPage.value = event.api.paginationGetCurrentPage() + 1;\n    totalPages.value = event.api.paginationGetTotalPages();\n  }\n};\n\n// will populate row counts if the SSRM handler returns row data with the allChildrenRowCount property\nconst handleGetChildCount = <T extends object>(data: T): number => {\n  if (\"allChildrenRowCount\" in data) {\n    return (data[\"allChildrenRowCount\"] as number) || 0;\n  }\n  return 0;\n};\n\n/*\n * Row Styling\n */\n\n// custom renderer for loading skeleton (when server-side data is loading)\nconst resolvedFullWidthCellRenderer = computed(() =>\n  props.fullWidthCellRenderer ? toRaw(props.fullWidthCellRenderer) : undefined,\n);\nconst resolvedLoadingCellRenderer = computed(() =>\n  props.loadingCellRenderer ? toRaw(props.loadingCellRenderer) : RowLoadingCellRenderer,\n);\nconst loadingCellRendererParams = {\n  loadingMessage: \"One moment please...\",\n};\n\nconst initialAutoGroupColumnDef: ColDef<T> = (() => {\n  const initialDef: ColDef<T> = {\n    headerName: \"\",\n    minWidth: 200,\n    suppressMovable: true,\n    sortable: false,\n    pinned: \"left\",\n    headerComponent: undefined,\n    cellRendererParams: {\n      suppressCount: true,\n      innerRenderer: AutoGroupColDefRenderer,\n      innerRendererParams: (params: ICellRendererParams) => {\n        return {\n          plainLabel: pivotEnabled,\n          boldLabel: pivotEnabled && !pivotConfig?.rowGroupCols.length,\n          displayBaseAggregationsOnly: props.displayBaseAggregationsOnly,\n          displayRowNumber: props.displayRowNumber,\n          displayCount: props.displayGroupCount,\n          formattedValue: params.valueFormatted,\n          rowNode: params.node,\n          api: gridApi.value,\n          focusText: props.focusText,\n          cellParams: params,\n        };\n      },\n    },\n  };\n  if (pivotEnabled) {\n    initialDef.suppressSpanHeaderHeight = true;\n    initialDef.headerClass = \"pv-pivot-column-header\";\n  }\n  // merge with autoGroupColumnDefOverrides, if provided\n  if (props.autoGroupColumnDefOverrides) {\n    Object.assign(initialDef, props.autoGroupColumnDefOverrides);\n  }\n  return initialDef;\n})();\n\n// custom renderer for displaying grouped row headers and aggregate data\nconst autoGroupColumnDef = ref(initialAutoGroupColumnDef) as Ref<ColDef<T>>;\n\n// Copies relevant properties from the leftmost column's colDef onto the auto-group column.\nconst applyLeftmostColDefToAutoGroup = (colDef: ColDef<T> | null | undefined) => {\n  if (!colDef) {\n    autoGroupColumnDef.value.headerName = \"\";\n    autoGroupColumnDef.value.headerComponent = undefined;\n    autoGroupColumnDef.value.context = null;\n    autoGroupColumnDef.value.sortable = false;\n    autoGroupColumnDef.value.filter = undefined;\n    autoGroupColumnDef.value.enableRowGroup = undefined;\n    return;\n  }\n  autoGroupColumnDef.value.field = colDef.field;\n  autoGroupColumnDef.value.headerName = colDef.headerName;\n  autoGroupColumnDef.value.headerComponent =\n    colDef.headerComponent ?? (!props.enableInlineFilters ? HeaderCellRenderer : undefined);\n  autoGroupColumnDef.value.context = {\n    dataType: colDef.context?.dataType || null,\n  } as ColDefContextProps<T>;\n  autoGroupColumnDef.value.sortable = colDef.sortable;\n  autoGroupColumnDef.value.filter = colDef.filter;\n  autoGroupColumnDef.value.enableRowGroup = colDef.enableRowGroup;\n  autoGroupColumnDef.value.onCellClicked = colDef.onCellClicked;\n};\n\n// sets the background color for grouped rows\nconst getRowStyle = (params: RowClassParams<T>) => {\n  if (params.node.group && !pivotEnabled) {\n    return {\n      backgroundColor: \"var(--color-background-accent, #f7f8f8)\",\n      ...(props.enableExpandOnRowClick ? { cursor: \"pointer\" } : {}),\n    };\n  }\n  return undefined;\n};\n\nconst getRowClass = (params: RowClassParams<T>) => {\n  const classes = props.enableFullRowClick && !params.node.group ? [\"pv-data-table-row-clickable\"] : [];\n  if (!params.node.group && params.node.lastChild && (params.node.parent?.level ?? -1) >= 0) {\n    classes.push(\"pv-data-table-group-last-child\");\n  }\n  return classes.length ? classes : undefined;\n};\n\n/*\n * Custom Aggregation Functions\n */\ninterface medianAgg {\n  values: number[];\n  value: number;\n}\nconst customAggFuncs = {\n  Median: (params: IAggFuncParams) => {\n    const values = params.values;\n\n    // Leaf level: calculate median of actual numeric values\n    if (params.rowNode.leafGroup) {\n      const median = calculateHighMedian(values);\n      return {\n        values: values,\n        value: median,\n      };\n    }\n    // Group level: calculate median of all values from child nodes\n    const groupedValues = params.values.flatMap((value: medianAgg) => value.values || []);\n    const groupMedian = calculateHighMedian(groupedValues);\n    return {\n      values: groupedValues,\n      value: groupMedian,\n    };\n  },\n};\n\nonBeforeMount(() => {\n  popupParentElement.value = document.querySelector(\"body\");\n\n  const hasRowData = Array.isArray(props.rowData) && props.rowData.length > 0;\n  const hasServerHandler = typeof props.serverSideRowHandler === \"function\";\n  const hasFilterValuesSetHandler = typeof props.filterValuesSetHandler === \"function\";\n  if ((hasRowData && hasServerHandler) || (hasRowData && hasFilterValuesSetHandler)) {\n    console.warn(\n      \"Only one of `rowData` or `serverSideRowHandler + hasFilterValuesSetHandler` params should be provided to PvDataTable, not both.\",\n    );\n  }\n\n  // set the available header menu items, filtering out any that are not in the default items or a custom filter menu item\n  getMainMenuItems.value = (params: GetMainMenuItemsParams<T>) => {\n    // this order is important, as it determines the order of the menu items\n    const menuItems: (DefaultMenuItem | MenuItemDef)[] = [\n      \"sortAscending\",\n      \"sortDescending\",\n      \"sortUnSort\",\n      // \"rowGroup\", - disabling this until we can figure out how to selectively disable it once max groups have been reached\n      \"rowUnGroup\",\n      // \"valueAggSubMenu\", - disabling this since we have our own header selector\n    ];\n    // add custom filter menu item after sortUnSort if filter is enabled\n    const col = params.column && isAutoGroupCol(params.column) ? groupColumnCellValueColumn.value : params.column;\n    if (!props.enableInlineFilters && col && col.getColDef().filter) {\n      menuItems.splice(2, 0, customFilterMenuItem);\n    }\n    return menuItems.filter((item) => {\n      if (typeof item === \"string\") {\n        return params.defaultItems.includes(item as DefaultMenuItem);\n      } else {\n        return true;\n      }\n    });\n  };\n\n  if (cleanedInitialGridState) {\n    filterModel.value =\n      (props.enableAdvancedFilter\n        ? cleanedInitialGridState.filter?.advancedFilterModel\n        : cleanedInitialGridState.filter?.filterModel) || null;\n    rowGroupColumnFields.value = cleanedInitialGridState.rowGroup?.groupColIds || [];\n  }\n});\n\nconst updateGridState = (gridState: GridState) => {\n  const api = gridApi.value;\n  if (!api) return;\n  const filterModel = gridState.filter?.filterModel || null;\n  const rowGroupColumns = gridState.rowGroup?.groupColIds || null;\n  const columnVisibility = gridState.columnVisibility || null;\n\n  if (filterModel && !filterModelsEqual(filterModel, api.getFilterModel())) {\n    api.setFilterModel(filterModel);\n  }\n  if (props.isTableGrouped && rowGroupColumns && !isEqual(rowGroupColumns, rowGroupColumnFields.value)) {\n    api.setRowGroupColumns(rowGroupColumns);\n  }\n  if (columnVisibility?.hiddenColIds) {\n    api.setColumnsVisible(columnVisibility.hiddenColIds, false);\n  }\n\n  const orderedColIds = gridState.columnOrder?.orderedColIds;\n  if (hasColumnConfigSemantics && orderedColIds?.length) {\n    const currentOrder = api.getAllGridColumns().map((col) => col.getColId());\n    if (!isEqual(orderedColIds, currentOrder)) {\n      api.applyColumnState({ state: orderedColIds.map((colId) => ({ colId })), applyOrder: true });\n    }\n  }\n};\n\n// the initial grid state used by AG Grid is only read once on creation. If we want to update it as the prop\n// changes, we need to update it manually\nwatch(\n  () => props.initialGridState,\n  () => {\n    if (props.initialGridState) {\n      const cleanedState = withoutPivotOwnedState(\n        cleanInitialGridState(props.initialGridState, updatedColDefs, props.enableAdvancedFilter),\n      );\n      if (cleanedState) {\n        updateGridState(cleanedState);\n      }\n    }\n  },\n  { deep: true },\n);\n\nconst handleFirstDataRendered = (event: FirstDataRenderedEvent<T>) => {\n  firstDataRendered.value = true;\n  emit(\"first-data-rendered\", event);\n};\n\nconst isServerSideGroupOpenByDefaultHandler = (params: IsServerSideGroupOpenByDefaultParams) => {\n  if (!serverSideDataSource) {\n    return false;\n  }\n\n  // If logic to open grouped rows by default is provided, use that.\n  if (props.isServerSideGroupOpenByDefault) {\n    return props.isServerSideGroupOpenByDefault(params);\n  }\n\n  // Otherwise, use default logic: only open the level 2 nodes up from the leaf nodes (child rows).\n  return params.rowNode.level === rowGroupColumnFields.value.length - 2;\n};\n\nconst computedGroupDefaultExpanded = computed(() => {\n  // for server side data source, we set to undefined\n  if (serverSideDataSource) {\n    return undefined;\n  }\n  return props.groupDefaultExpanded;\n});\n\nconst popupParentElement = ref<HTMLElement | null>(null);\nconst filterPanelRef = ref<{\n  openVerticalDrawer: () => void;\n  openHorizontalFilter: (field: string) => boolean;\n  isHorizontalFilterCollapsed: (field: string) => boolean;\n} | null>(null);\nconst advancedFilterParentElement = ref<HTMLElement | null>(null);\n\n// Single source of truth for the table search input, which renders in one of\n// two mutually-exclusive spots: inline with the filter row, or its own row\n// below it (see tableSearchInline). NB: a single teleported instance would be\n// cleaner, but teleporting a component inside this frequently-re-rendering\n// table trips a Vue core bug (vuejs/core#13077) — null component instance on\n// optimized block update. So we share props/style and render the tag twice.\nconst { present: hasTopSlot } = useSlotPresence(\"top-slot\");\nconst topSlotEnabled = computed(() => props.enableTopSlot && hasTopSlot.value);\nconst inlineTopSlotEnabled = computed(() => topSlotEnabled.value && props.tableSearchInline);\n// Match the 42px ExportMenu trigger so both header groups share a first-line center.\nconst inlineTopSlotControlHeight = \"42px\";\nconst tableSearchWrapperStyle = computed(() => [\n  // Inline sits in the filter flex row, so a percentage width resolves against\n  // that group (not the table) and overflows — use a fixed, shrinkable width.\n  // The standalone row spans the table, where a percentage width is fine.\n  props.tableSearchInline ? { width: \"360px\", maxWidth: \"100%\", minWidth: 0 } : { width: \"40%\", maxWidth: \"50%\" },\n  inlineTopSlotEnabled.value\n    ? { alignItems: \"center\", display: \"grid\", minHeight: inlineTopSlotControlHeight }\n    : undefined,\n  props.customCssProperties?.tableSearchWrapper,\n]);\nconst tableSearchAttrs = computed(() => ({\n  placeholder: props.tableSearchPlaceholder,\n  disabled: !displayUnfilteredTableData.value,\n  searchStyle: props.tableSearchStyle,\n  size: props.tableSearchSize,\n}));\n</script>\n\n<template>\n  <div class=\"pv-full-width\" :style=\"containerCssProps\" style=\"display: flex; flex-direction: column\">\n    <PvTooltipV2 v-if=\"devMode\" class=\"pv-flex\" style=\"width: 100%; --flex-justify: flex-end\">\n      <template #trigger>\n        <PvButton\n          left-icon=\"flask-conical\"\n          ariaLabel=\"Toggle dev mode\"\n          :variant=\"devModeEnabled ? 'primary' : 'secondary'\"\n          @click=\"devModeEnabled = !devModeEnabled\"\n        />\n      </template>\n      <template #content> Dev Mode </template>\n    </PvTooltipV2>\n    <div\n      class=\"pv-stack-16\"\n      v-show=\"\n        enableGroupBySelector ||\n        !filterTeleportLocation ||\n        (enableTableSearch && tableSearchInline) ||\n        inlineTopSlotEnabled\n      \"\n    >\n      <!-- One row: horizontal filters collapse as space runs out instead of pushing the trailing controls down. -->\n      <div class=\"pv-flex pv-space-between\">\n        <div class=\"pv-flex\" style=\"--flex-gap: 8px; flex: 1 1 0; min-width: 0\">\n          <div v-if=\"enableTableSearch && tableSearchInline\" :style=\"tableSearchWrapperStyle\">\n            <TableSearch v-bind=\"tableSearchAttrs\" />\n          </div>\n          <Teleport :to=\"filterTeleportLocation\" :disabled=\"!filterTeleportLocation\">\n            <FilterPanel\n              v-if=\"availableFilterColumns.length > 0 && !props.enableInlineFilters\"\n              ref=\"filterPanelRef\"\n              :enable-focus-view=\"enableFocusView\"\n              :enable-vertical-panel=\"enableVerticalFilterPanel\"\n              :display-preferences-icon=\"displayPreferencesIcon\"\n              :focusable-columns=\"focusableColumns\"\n              :focus-text=\"focusText\"\n              @handle-settings-icon=\"$emit('handle-settings-icon', $event)\"\n              :max-horizontal-filters=\"props.maxHorizontalFilters\"\n              :read-only=\"props.filterPanelReadOnly\"\n              :disable-unselected-filters=\"props.disableUnselectedReadOnlyFilters\"\n              :wrap-horizontal-filters=\"props.wrapHorizontalFilters\"\n            />\n          </Teleport>\n        </div>\n        <div\n          class=\"pv-flex\"\n          :style=\"[{ flexShrink: 0 }, inlineTopSlotEnabled ? { minHeight: inlineTopSlotControlHeight } : undefined]\"\n        >\n          <GroupBySelector\n            v-if=\"enableGroupBySelector && !(rowGroupLimit === 0)\"\n            :rowGroupLimit=\"rowGroupLimit\"\n            :enableFocusView=\"enableFocusView\"\n          />\n          <ExportMenu v-if=\"enableCsvExport\" :getCsvData=\"getCsvData\" />\n          <div v-if=\"inlineTopSlotEnabled\" :class=\"hideTable ? 'pv-hide' : ''\">\n            <slot name=\"top-slot\" />\n          </div>\n        </div>\n      </div>\n    </div>\n    <div\n      v-show=\"devModeEnabled && enableAdvancedFilter\"\n      ref=\"advancedFilterParentElement\"\n      class=\"pv-stack-8 pv-text-body-sm\"\n      :class=\"hideTable ? 'pv-hide' : ''\"\n    />\n    <div\n      v-if=\"!tableSearchInline && (enableTableSearch || topSlotEnabled)\"\n      class=\"pv-stack-8 pv-flex pv-space-between\"\n      :class=\"hideTable ? 'pv-hide' : ''\"\n    >\n      <div v-if=\"enableTableSearch && !tableSearchInline\" :style=\"tableSearchWrapperStyle\">\n        <TableSearch v-bind=\"tableSearchAttrs\" />\n      </div>\n      <slot v-if=\"topSlotEnabled\" name=\"top-slot\" />\n    </div>\n    <div\n      ref=\"gridWrapperRef\"\n      class=\"pv-relative pv-stack-8\"\n      :class=\"hideTable ? 'pv-hide' : ''\"\n      :style=\"gridWrapperStyle\"\n    >\n      <ag-grid-vue\n        ref=\"gridRef\"\n        :class=\"['pv-data-table', themeClass, { 'pv-data-table--pivot': pivotEnabled }]\"\n        :style=\"[\n          { width: '100%', height: layout === 'autoHeight' ? undefined : '100%' },\n          shrinkGridStyle,\n          pivotLoadingGridStyle,\n          pivotFrameStyle,\n          customCssProperties?.agGridWrapper,\n        ]\"\n        :domLayout=\"layout\"\n        v-bind=\"serverSideDataSource ? { serverSideDatasource: serverSideDataSource } : {}\"\n        @cell-value-changed=\"emit('cell-value-changed', $event)\"\n        @column-moved=\"handleColumnMoved\"\n        @column-row-group-changed=\"handleColumnRowGroupChanged\"\n        @column-value-changed=\"handleColumnValueChanged\"\n        @column-visible=\"handleColumnVisibleChanged\"\n        @filter-changed=\"handleFilterChanged\"\n        @filter-opened=\"emit('filter-opened', $event)\"\n        @first-data-rendered=\"handleFirstDataRendered\"\n        @grid-ready=\"handleGridReady\"\n        @pagination-changed=\"handlePaginationChanged\"\n        @redo-ended=\"emit('redo-ended', $event)\"\n        @redo-started=\"emit('redo-started', $event)\"\n        @row-data-updated=\"emit('row-data-updated', $event)\"\n        @rowClicked=\"handleRowClicked\"\n        @row-selected=\"emit('row-selected', $event)\"\n        @selection-changed=\"emit('selection-changed', $event)\"\n        @sort-changed=\"handleSortChanged\"\n        @undo-ended=\"emit('undo-ended', $event)\"\n        @undo-started=\"emit('undo-started', $event)\"\n        @pivot-max-columns-exceeded=\"emit('pivot-max-columns-exceeded', $event)\"\n        :aggFuncs=\"customAggFuncs\"\n        :autoGroupColumnDef=\"autoGroupColumnDef\"\n        :columnDefs=\"updatedColDefs\"\n        :debug=\"debugMode\"\n        :defaultColDef=\"defaultColDef\"\n        :fullWidthCellRenderer=\"resolvedFullWidthCellRenderer\"\n        :getChildCount=\"handleGetChildCount\"\n        :getContextMenuItems=\"getContextMenuItems\"\n        :getMainMenuItems=\"getMainMenuItems\"\n        :getRowClass=\"getRowClass\"\n        :getRowStyle=\"getRowStyle\"\n        :groupDefaultExpanded=\"computedGroupDefaultExpanded\"\n        :groupDisplayType=\"'singleColumn'\"\n        :initialState=\"cleanedInitialGridState || undefined\"\n        :isFullWidthRow=\"props.isFullWidthRow\"\n        :isGroupOpenByDefault=\"!serverSideDataSource ? props.isClientSideGroupOpenByDefault : undefined\"\n        :isServerSideGroupOpenByDefault=\"isServerSideGroupOpenByDefaultHandler\"\n        :includeHiddenColumnsInAdvancedFilter=\"true\"\n        :loading=\"!serverSideDataSource && !pivotEnabled ? isLoading : false\"\n        :loadingCellRenderer=\"resolvedLoadingCellRenderer\"\n        :loadingCellRendererParams=\"loadingCellRendererParams\"\n        :maxConcurrentDatasourceRequests=\"serverSideDataSource ? -1 : undefined\"\n        :maintainColumnOrder=\"maintainColumnOrder\"\n        :modules=\"modules\"\n        :popupParent=\"popupParentElement\"\n        :processCellForClipboard=\"processCellForClipboard\"\n        :processCellFromClipboard=\"processCellFromClipboard\"\n        :processDataFromClipboard=\"processDataFromClipboard\"\n        :pivotMode=\"pivotEnabled\"\n        :pivotMaxGeneratedColumns=\"pivotEnabled ? pivotMaxGeneratedColumns : undefined\"\n        :pivotGroupHeaderHeight=\"pivotEnabled ? PIVOT_GROUP_HEADER_HEIGHT : undefined\"\n        :processPivotResultColGroupDef=\"pivotEnabled ? handleProcessPivotResultColGroupDef : undefined\"\n        :processPivotResultColDef=\"pivotEnabled ? handleProcessPivotResultColDef : undefined\"\n        :alwaysPassFilter=\"pivotAlwaysPassFilter\"\n        :rowData=\"processedRowData\"\n        :rowHeight=\"rowHeight\"\n        :rowModelType=\"serverSideDataSource ? 'serverSide' : 'clientSide'\"\n        :rowSelection=\"rowSelection\"\n        :serverSideInitialRowCount=\"serverSideDataSource ? 1 : undefined\"\n        :showOpenedGroup=\"true\"\n        :suppressAggFuncInHeader=\"true\"\n        :suppressColumnMoveAnimation=\"true\"\n        :suppressDragLeaveHidesColumns=\"true\"\n        :serverSideSortAllLevels=\"false\"\n        :serverSideEnableClientSideSort=\"false\"\n        :theme=\"computedTheme\"\n        :pagination=\"pagination\"\n        :suppressPaginationPanel=\"true\"\n        :paginationPageSize=\"paginationPageSize\"\n        :suppressScrollOnNewData=\"true\"\n        :tooltip-show-delay=\"tooltipShowDelay\"\n        :tooltip-hide-delay=\"tooltipHideDelay\"\n        :cellSelection=\"cellSelection\"\n        :copyHeadersToClipboard=\"copyHeadersToClipboard\"\n        :suppressClipboardPaste=\"suppressClipboardPaste\"\n        :suppressCutToClipboard=\"suppressCutToClipboard\"\n        :undoRedoCellEditing=\"undoRedoCellEditing\"\n        :undoRedoCellEditingLimit=\"undoRedoCellEditingLimit\"\n        :enableAdvancedFilter=\"enableAdvancedFilter\"\n        :advancedFilterParent=\"advancedFilterParentElement\"\n      >\n      </ag-grid-vue>\n      <PivotTableSkeleton v-if=\"pivotLoading\" />\n      <div v-if=\"!isLoading && !displayUnfilteredTableData\" class=\"pv-table-overlay\">\n        <p class=\"pv-text-body-xs pv-text-center\" style=\"padding-top: 16px\">\n          {{ filterRestrictionMessage }}\n        </p>\n      </div>\n    </div>\n    <PaginationPanel v-if=\"pagination\" />\n  </div>\n</template>\n","<script lang=\"ts\">\nimport { ColDef, FirstDataRenderedEvent, GridApi, GridReadyEvent } from \"ag-grid-community\";\nimport {\n  Column,\n  FilterModel,\n  ICellRendererParams,\n  IServerSideGetRowsParams,\n  SetFilterValuesFuncParams,\n} from \"ag-grid-enterprise\";\nimport { ColDefDataType } from \"@tables/PvDataTable/table-components/formatting\";\nimport TableTooltip from \"./table-components/TableTooltip.vue\";\nimport { FocusUpdateEvent } from \"@/components/tables/PvDataTable/types\";\nimport {\n  AvailableFilterColumnsKey,\n  AvailableRowGroupColumnsKey,\n  ColumnDisplayOrderKey,\n  CurrentlyActiveFilterKey,\n  CurrentPageKey,\n  ExpandedRowsKey,\n  FirstDataRenderedKey,\n  GridApiKey,\n  GroupColumnCellValueColumnKey,\n  RowGroupColumnFieldsKey,\n  SortStateKey,\n  TotalPageKey,\n} from \"@/components/tables/symbols\";\nimport { liftFocusedOptions, isColDefNumericDataType } from \"@/components/tables/PvDataTable/helpers\";\n</script>\n\n<script setup lang=\"ts\" generic=\"T\">\nimport { AgGridVue } from \"ag-grid-vue3\";\nimport {\n  CellStyleModule,\n  ClientSideRowModelModule,\n  ColumnApiModule,\n  ColumnAutoSizeModule,\n  CustomFilterModule,\n  CsvExportModule,\n  EventApiModule,\n  GridStateModule,\n  IAggFuncParams,\n  IsServerSideGroupOpenByDefaultParams,\n  LoadSuccessParams,\n  MenuItemDef,\n  Module,\n  RowApiModule,\n  RowStyleModule,\n  PaginationModule,\n  RefreshServerSideParams,\n  PaginationChangedEvent,\n  SortChangedEvent,\n  SortModelItem,\n  QuickFilterModule,\n  TextFilterModule,\n  TextEditorModule,\n  CheckboxEditorModule,\n  UndoRedoEditModule,\n  SelectEditorModule,\n  LargeTextEditorModule,\n  NumberEditorModule,\n  DateEditorModule,\n  CustomEditorModule,\n  SelectionChangedEvent,\n  RowSelectedEvent,\n  RowDataUpdatedEvent,\n  CellValueChangedEvent,\n  ColumnValueChangedEvent,\n  UndoStartedEvent,\n  UndoEndedEvent,\n  RedoStartedEvent,\n  RedoEndedEvent,\n  ScrollApiModule,\n  RowClickedEvent,\n} from \"ag-grid-community\";\nimport {\n  AdvancedFilterModel,\n  AdvancedFilterModule,\n  ColumnAdvancedFilterModel,\n  JoinAdvancedFilterModel,\n  ClientSideRowModelApiModule,\n  ClipboardModule,\n  ColumnMenuModule,\n  ColumnMovedEvent,\n  ColumnResizedEvent,\n  ColumnRowGroupChangedEvent,\n  DefaultMenuItem,\n  FilterChangedEvent,\n  GetContextMenuItemsParams,\n  GetMainMenuItems,\n  GetMainMenuItemsParams,\n  GridState,\n  IMenuActionParams,\n  IRowNode,\n  IServerSideDatasource,\n  LicenseManager,\n  RichSelectModule,\n  RenderApiModule,\n  RowClassParams,\n  RowGroupingModule,\n  RowNode,\n  RowSelectionModule,\n  ServerSideRowModelApiModule,\n  ServerSideRowModelModule,\n  SetFilterModule,\n  ValidationModule,\n  TooltipModule,\n  MultiFilterModule,\n  CellSelectionModule,\n  ContextMenuModule,\n  PivotModule,\n  type ColGroupDef,\n  type PivotMaxColumnsExceededEvent,\n  type ValueFormatterParams,\n  type Theme,\n} from \"ag-grid-enterprise\";\nimport {\n  computed,\n  inject,\n  nextTick,\n  onBeforeMount,\n  onBeforeUnmount,\n  provide,\n  Ref,\n  ref,\n  shallowRef,\n  toRaw,\n  watch,\n} from \"vue\";\nimport { watchDebounced } from \"@vueuse/core\";\nimport Papa from \"papaparse\";\nimport GroupBySelector from \"@tables/PvDataTable/table-components/GroupBySelector.vue\";\nimport RowLoadingCellRenderer from \"@tables/PvDataTable/table-components/RowLoadingCellRenderer.vue\";\nimport AutoGroupColDefRenderer from \"@tables/PvDataTable/table-components/AutoGroupColDefRenderer.vue\";\nimport { calculateHighMedian } from \"@/functions/aggregations\";\nimport GroupAggCellRenderer from \"@tables/PvDataTable/table-components/GroupAggCellRenderer.vue\";\nimport FilterPanel from \"@tables/PvDataTable/table-components/FilterPanel.vue\";\nimport { arrayValueFormatter, currencyFormatter, integerFormatter, percentageFormatter } from \"@/functions/formatting\";\nimport HeaderCellRenderer from \"@tables/PvDataTable/table-components/HeaderCellRenderer.vue\";\nimport { themeMap, type PvDataTableTheme } from \"@tables/themes\";\nimport ExportMenu from \"@tables/PvDataTable/table-components/ExportMenu.vue\";\nimport PaginationPanel from \"@tables/PvDataTable/table-components/PaginationPanel.vue\";\nimport { useFilterStore, isRegularFilterModel } from \"@tables/PvDataTable/useFilterStore\";\nimport { usePivotCornerHeight, useShrinkToContent } from \"@tables/PvDataTable/useGridSizing\";\nimport PivotTableSkeleton from \"@tables/PvDataTable/table-components/PivotTableSkeleton.vue\";\nimport { useSlotPresence } from \"@/composables/useSlotPresence\";\nimport { isEqual } from \"es-toolkit\";\nimport TagCellRenderer from \"@tables/PvDataTable/table-components/TagCellRenderer.vue\";\nimport RowCountCellRenderer from \"@tables/PvDataTable/table-components/RowCountCellRenderer.vue\";\nimport { EnableAdvancedFilterKey, FilterStoreKey, FocusStoreKey, RowsLoadingKey } from \"@tables/symbols\";\nimport { createFocusStore } from \"@tables/PvDataTable/useFocus\";\nimport {\n  ColDefContextProps,\n  FilterValueResponseOption,\n  FilterValuesResponse,\n  FilterValuesSetHandlerParams,\n  PvDataTablePivot,\n  PvDataTableProps,\n  PvDataTablePublicInterface,\n  TableSearchHandlerParams,\n} from \"@tables/PvDataTable/types\";\nimport TableSearch from \"@tables/PvDataTable/table-components/TableSearch.vue\";\nimport { QueryTerm } from \"@/components/base/PvQueryBuilderInput/useQueryBuilder\";\nimport {\n  addHandlerToSetFilter,\n  cleanInitialGridState,\n  convertFilterModelToAdvanced,\n  filterModelContainsColId,\n  filterModelsEqual,\n  getSelectedValues,\n  hasSetFilter,\n  mergeAdvancedFilterCondition,\n  mergeFilterModels,\n} from \"@tables/PvDataTable/filters/filterHelpers\";\nimport { PvButton, PvTooltipV2 } from \"@/components/base\";\nimport { getAggregateFields, getAggregateRootField, processRowGroupCols } from \"@tables/PvDataTable/helpers.ts\";\nimport { BUCKET_AGG_FUNC_NAME } from \"@charts/PvDataTableWithChart/constants.ts\";\nimport PvPivotGroupHeader from \"@tables/PvDataTable/table-components/PvPivotGroupHeader.vue\";\nimport { multicolorFills } from \"@charts/themes\";\nconst modules: Module[] = [\n  AdvancedFilterModule,\n  CellSelectionModule,\n  CellStyleModule,\n  ClientSideRowModelApiModule,\n  ClientSideRowModelModule,\n  ClipboardModule,\n  ColumnApiModule,\n  ColumnAutoSizeModule,\n  ColumnMenuModule,\n  ContextMenuModule,\n  CsvExportModule,\n  CustomFilterModule,\n  EventApiModule,\n  GridStateModule,\n  MultiFilterModule,\n  ScrollApiModule,\n  ServerSideRowModelModule,\n  ServerSideRowModelApiModule,\n  SetFilterModule,\n  TextFilterModule,\n  RenderApiModule,\n  RowApiModule,\n  RowGroupingModule,\n  RowSelectionModule,\n  RowStyleModule,\n  PaginationModule,\n  PivotModule,\n  QuickFilterModule,\n  TooltipModule,\n  TextEditorModule,\n  UndoRedoEditModule,\n  CheckboxEditorModule,\n  SelectEditorModule,\n  LargeTextEditorModule,\n  NumberEditorModule,\n  DateEditorModule,\n  CustomEditorModule,\n  RichSelectModule,\n];\n\nconst AG_GRID_LICENSE_KEY =\n  \"Using_this_{AG_Grid}_Enterprise_key_{AG-084011}_in_excess_of_the_licence_granted_is_not_permitted___Please_report_misuse_to_legal@ag-grid.com___For_help_with_changing_this_key_please_contact_info@ag-grid.com___{Turquoise_Health}_is_granted_a_{Multiple_Applications}_Developer_License_for_{3}_Front-End_JavaScript_developers___All_Front-End_JavaScript_developers_need_to_be_licensed_in_addition_to_the_ones_working_with_{AG_Grid}_Enterprise___This_key_has_been_granted_a_Deployment_License_Add-on_for_{2}_Production_Environments___This_key_works_with_{AG_Grid}_Enterprise_versions_released_before_{16_August_2026}____[v3]_[01]_MTc4NjgzNDgwMDAwMA==3bfdb2557ede1aa3533ccbd05785addb\";\nLicenseManager.setLicenseKey(AG_GRID_LICENSE_KEY);\n\nconst props = withDefaults(defineProps<PvDataTableProps<T>>(), {\n  allFieldsAreFocusable: false,\n  displayBaseAggregationsOnly: false,\n  displayRowNumber: false,\n  displayGroupCount: true,\n  displayPreferencesIcon: false,\n  enableColumnVisibilitySelector: false,\n  enableCsvExport: false,\n  enableFocusView: false,\n  enableFullRowClick: false,\n  enableGroupBySelector: false,\n  enableVerticalFilterPanel: true,\n  enableInlineFilters: false,\n  hideAllRowGroupedColumns: false,\n  csvRowLimit: 20000,\n  requireFiltersToShowData: false,\n  debugMode: false,\n  containerHeight: \"500px\",\n  containerMinHeight: \"200px\",\n  layout: undefined,\n  shrinkToContent: false,\n  pagination: false,\n  paginationPageSize: 50,\n  tooltipShowDelay: 1000,\n  isTableGrouped: false,\n  groupDefaultExpanded: 1,\n  focusableColumns: () => [],\n  tableSearchPlaceholder: \"Search\",\n  tableSearchStyle: \"text\",\n  tableSearchSize: \"xl\",\n  tableSearchInline: false,\n  maxHorizontalFilters: 5,\n  wrapHorizontalFilters: false,\n  filterPanelReadOnly: false,\n  disableUnselectedReadOnlyFilters: false,\n  maintainColumnOrder: true,\n  copyHeadersToClipboard: false,\n  cellSelection: false,\n  suppressCutToClipboard: true,\n  suppressClipboardPaste: true,\n  undoRedoCellEditing: false,\n  undoRedoCellEditingLimit: 10,\n  enableAdvancedFilter: false,\n  refreshFiltersInBackground: false,\n  stageFilterChangesUntilDropdownCloses: false,\n  devMode: false,\n  pivotRowLimit: 200,\n  pivotMaxGeneratedColumns: 50,\n  pivotTotalLabel: \"Total\",\n});\n\n// only load validation module in dev mode\nif (props.debugMode) {\n  modules.push(ValidationModule);\n}\n\n// With `shrinkToContent`, `containerHeight` is a ceiling and the grid takes its rows' height up to it (fixed at mount).\nconst shrinkEnabled = props.shrinkToContent && !props.layout;\n\nconst containerCssProps = computed(() => {\n  if (props.layout) {\n    return {};\n  }\n  return {\n    [shrinkEnabled ? \"maxHeight\" : \"height\"]: props.containerHeight,\n    minHeight: props.containerMinHeight,\n  };\n});\n\nconst gridWrapperRef = ref<HTMLElement | null>(null);\nconst shrink = shrinkEnabled ? useShrinkToContent(gridWrapperRef) : undefined;\n\n// Percent heights don't resolve in a container that only has a ceiling, so the grid fills its wrapper directly.\nconst shrinkGridStyle = shrinkEnabled ? { position: \"absolute\" as const, top: 0, left: 0 } : undefined;\n\nconst isThemeObject = computed(() => props.theme != null && typeof props.theme !== \"string\");\n\nconst computedThemeName = computed<PvDataTableTheme>(() => {\n  if (props.theme && typeof props.theme === \"string\") {\n    return props.theme;\n  }\n  if (rowGroupColumnFields.value.length > 0) {\n    return \"pv-data-table-grouped\";\n  }\n  return \"pv-data-table-base\";\n});\n\nconst themeClass: PvDataTableTheme =\n  props.theme && typeof props.theme === \"string\" ? props.theme : \"pv-data-table-base\";\n\nconst computedTheme = computed<Theme>(() => {\n  const theme = isThemeObject.value ? (props.theme as Theme) : themeMap[computedThemeName.value];\n  // Pivot tables are dense: compact rows, medium weight headers, and no resize handle lines (the strokes are in CSS).\n  return pivotEnabled\n    ? theme.withParams({\n        rowHeight: \"36px\",\n        headerFontWeight: 500,\n        headerColumnResizeHandleColor: \"transparent\",\n      })\n    : theme;\n});\n\n// propagate grid events we want to the parent\nconst emit = defineEmits<{\n  (e: \"column-moved\", event: ColumnMovedEvent<T>): void;\n  (e: \"column-resized\", event: ColumnResizedEvent<T>): void;\n  (e: \"column-row-group-changed\", event: ColumnRowGroupChangedEvent<T>): void;\n  (e: \"column-value-changed\", event: ColumnValueChangedEvent<T>): void;\n  (e: \"grid-ready\", event: GridReadyEvent<T>): void;\n  (e: \"filter-changed\", event: FilterChangedEvent<T>): void;\n  (e: \"sort-changed\", event: SortChangedEvent<T>): void;\n  (e: \"filter-opened\", event: FilterChangedEvent<T>): void;\n  (e: \"first-data-rendered\", event: FirstDataRenderedEvent<T>): void;\n  (e: \"handle-settings-icon\", value: string): void;\n  (e: \"focus-update\", event: FocusUpdateEvent): void;\n  (e: \"selection-changed\", event: SelectionChangedEvent): void;\n  (e: \"row-selected\", event: RowSelectedEvent): void;\n  (e: \"row-data-updated\", event: RowDataUpdatedEvent): void;\n  (e: \"cell-value-changed\", event: CellValueChangedEvent): void;\n  (e: \"undo-started\", event: UndoStartedEvent): void;\n  (e: \"undo-ended\", event: UndoEndedEvent): void;\n  (e: \"redo-started\", event: RedoStartedEvent): void;\n  (e: \"redo-ended\", event: RedoEndedEvent): void;\n  (e: \"row-clicked\", event: RowClickedEvent<T>): void;\n  (e: \"pivot-max-columns-exceeded\", event: PivotMaxColumnsExceededEvent<T>): void;\n  (\n    e: \"filter-metadata-changed\",\n    payload: {\n      filterValueMap: Record<string, (FilterValueResponseOption | null)[]>;\n      filterValueSelectedMetadataMap: Record<string, (FilterValueResponseOption | null)[]>;\n    },\n  ): void;\n}>();\n\nconst devModeEnabled = ref(false);\n\nconst getAggregateSearchTargetFields = (aggregateColDef: ColDef<T>): string[] => {\n  const aggregateFields = getAggregateFields(aggregateColDef);\n  const aggregateContext = aggregateColDef.context as ColDefContextProps<T> | undefined;\n\n  return Array.from(\n    new Set([\n      ...aggregateFields,\n      ...(aggregateContext?.queryColIds || []),\n      ...aggregateFields.flatMap((field) => {\n        const backingColDef = updatedColDefs.find((colDef) => colDef.field === field || colDef.colId === field);\n        const backingContext = backingColDef?.context as ColDefContextProps<T> | undefined;\n        return backingContext?.queryColIds || [];\n      }),\n    ]),\n  );\n};\n\nconst tableSearchFilterTargetsTopLevelGroup = (\n  tableSearchFilter: FilterModel | AdvancedFilterModel | null | undefined,\n  topLevelGroup: string,\n): boolean => {\n  if (filterModelContainsColId(tableSearchFilter, topLevelGroup)) return true;\n\n  const aggregateColDef = updatedColDefs.find((colDef) => getAggregateRootField(colDef) === topLevelGroup);\n  return (\n    !!aggregateColDef &&\n    getAggregateSearchTargetFields(aggregateColDef).some((field) => filterModelContainsColId(tableSearchFilter, field))\n  );\n};\n\n/*\n * Server Side Grid Configuration\n */\n\n// Pivot mode pivots client-side rows, so it never uses the server-side row model. Fixed at mount.\nconst pivotEnabled = !!props.pivot;\n// Room for the color bar, a one line name, and a subtitle.\nconst PIVOT_GROUP_HEADER_HEIGHT = 48;\n// Measure columns repeat for every pivot value, so they start narrower than the regular 150px to keep the table\n// from running off the page.\nconst PIVOT_COLUMN_MIN_WIDTH = 100;\n\nconst pivotCorner = pivotEnabled ? usePivotCornerHeight(gridWrapperRef, PIVOT_GROUP_HEADER_HEIGHT) : undefined;\nconst pivotFrameStyle = computed(() =>\n  pivotCorner ? { \"--pv-pivot-corner-height\": `${pivotCorner.height.value}px` } : undefined,\n);\n\n// attach row handler if server side data source is provided\nconst serverSideDataSource: IServerSideDatasource | null =\n  !pivotEnabled && \"serverSideRowHandler\" in props && props.serverSideRowHandler\n    ? {\n        getRows: (params) => {\n          if (!displayUnfilteredTableData.value) {\n            params.success({ rowData: [] });\n            // set first data rendered to allow filter dropdowns to start fetching data\n            firstDataRendered.value = true;\n            return;\n          }\n\n          rowsLoading.value = true;\n          const originalSuccess = params.success;\n          const originalFail = params.fail;\n          /**\n           * If we are making a request for data, we only want to add the table filter in certain scenarios:\n           * 1. if the request is for child rows.\n           * \tThis allows grouped requests to return correct data for the primary filter model and not affect the\n           * \taggregations. The table filter is designed to only filter out child rows (visually).\n           * \tA child row request is when the request params groupKeys and rowGroupCols are the same length\n           * 2. If the table filter has a\n           */\n          const groupKeyLength = params.request.groupKeys?.length || 0;\n          const rowGroupColsLength = params.request.rowGroupCols?.length || 0;\n          const requestForChildRows = groupKeyLength === rowGroupColsLength;\n\n          let applyTableFilterToGroupRequest = false;\n          const tableSearchFilter = tableSearchFilterModel.value;\n          if (rowGroupColsLength > 0 && groupKeyLength === 0) {\n            const topLevelGroup = params.request.rowGroupCols[0].id;\n            // If the table filter includes the top-level group, apply it. For nested aggregate filters,\n            // also apply child-field searches to the parent group request so matching parent containers render.\n            applyTableFilterToGroupRequest = tableSearchFilterTargetsTopLevelGroup(tableSearchFilter, topLevelGroup);\n          }\n          params.request.rowGroupCols = processRowGroupCols(params.request.rowGroupCols, params.api.getColumnDefs?.());\n          // For bucket aggregation columns, inject range filters from bucketMin/bucketMax\n          // when expanding a group row (i.e. groupKeys has a value for a bucket column)\n          if ((params.request.groupKeys?.length || 0) > 0) {\n            const parentData = params.parentNode?.data;\n            if (parentData?.bucketMin != null && parentData?.bucketMax != null) {\n              if (props.enableAdvancedFilter) {\n                // Advanced filter mode: construct ColumnAdvancedFilterModel conditions with colId\n                let advFilterModel: AdvancedFilterModel | null =\n                  (params.request.filterModel as AdvancedFilterModel) || null;\n                params.request.rowGroupCols?.forEach((col, index) => {\n                  if (col.aggFunc === BUCKET_AGG_FUNC_NAME && index < params.request.groupKeys!.length) {\n                    const colKey = col.field || col.id;\n                    const rangeCondition: JoinAdvancedFilterModel = {\n                      filterType: \"join\",\n                      type: \"AND\",\n                      conditions: [\n                        {\n                          filterType: \"number\",\n                          colId: colKey,\n                          type: \"greaterThanOrEqual\",\n                          filter: parentData.bucketMin,\n                        } as ColumnAdvancedFilterModel,\n                        {\n                          filterType: \"number\",\n                          colId: colKey,\n                          type: \"lessThanOrEqual\",\n                          filter: parentData.bucketMax,\n                        } as ColumnAdvancedFilterModel,\n                      ],\n                    };\n                    advFilterModel = mergeAdvancedFilterCondition(advFilterModel, rangeCondition, colKey);\n                  }\n                });\n                if (advFilterModel) {\n                  params.request.filterModel = advFilterModel;\n                }\n              } else {\n                // Regular filter mode: construct number filter keyed by column ID\n                const filterModel = (params.request.filterModel || {}) as FilterModel;\n                params.request.rowGroupCols?.forEach((col, index) => {\n                  if (col.aggFunc === BUCKET_AGG_FUNC_NAME && index < params.request.groupKeys!.length) {\n                    const colKey = col.field || col.id;\n                    filterModel[colKey] = {\n                      filterType: \"number\",\n                      operator: \"AND\",\n                      conditions: [\n                        {\n                          filterType: \"number\",\n                          type: \"greaterThanOrEqual\",\n                          filter: parentData.bucketMin,\n                        },\n                        {\n                          filterType: \"number\",\n                          type: \"lessThanOrEqual\",\n                          filter: parentData.bucketMax,\n                        },\n                      ],\n                    };\n                  }\n                });\n                params.request.filterModel = filterModel;\n              }\n              // Strip bucket entries from groupKeys/rowGroupCols so the server\n              // returns leaf-level data filtered by the range instead\n              params.request.groupKeys = params.request.groupKeys!.filter(\n                (_, i) => params.request.rowGroupCols?.[i]?.aggFunc !== BUCKET_AGG_FUNC_NAME,\n              );\n              params.request.rowGroupCols = params.request.rowGroupCols!.filter(\n                (col) => col.aggFunc !== BUCKET_AGG_FUNC_NAME,\n              );\n            }\n          }\n          if (params.request.rowGroupCols?.length === 0) {\n            // if there are no row group cols, we don't aggregate on anything\n            params.request.valueCols = [];\n          } else {\n            // remove any grouping columns from the value cols\n            params.request.valueCols = params.request.valueCols?.filter(\n              (valueCol) => !params.request.rowGroupCols?.some((groupCol) => groupCol.id === valueCol.id),\n            );\n          }\n          const shouldApplyTableFilter =\n            (requestForChildRows || applyTableFilterToGroupRequest) && !filterStore.tableSearchFilterModelEmpty.value;\n          if (shouldApplyTableFilter) {\n            params.request.filterModel = withTableSearch(params.request.filterModel);\n          }\n          // Wrap the success callback to apply focus lifting\n          params.success = (result: LoadSuccessParams<T>) => {\n            rowsLoading.value = false;\n            // Apply focus lifting for server side data source\n            if (props.enableFocusView && focuses.value.length > 0 && focusType.value && result.rowData) {\n              const liftedData = liftFocusedOptions(result.rowData, focusType.value as keyof T, focuses.value);\n              if (liftedData) {\n                result.rowData = liftedData;\n                originalSuccess(result);\n                return;\n              }\n            }\n            originalSuccess(result);\n          };\n          // Wrap the fail callback to track loading state\n          params.fail = () => {\n            rowsLoading.value = false;\n            originalFail();\n          };\n          props.serverSideRowHandler?.(params);\n        },\n      }\n    : null;\n\n// attach filter values set handler if server side data source is provided, and trigger an event when new values\n// are set\nconst gridFilterValuesSetHandler: ((params: SetFilterValuesFuncParams<T, FilterValueResponseOption>) => void) | null =\n  \"filterValuesSetHandler\" in props && props.filterValuesSetHandler\n    ? async (params: SetFilterValuesFuncParams<T, FilterValueResponseOption>) => {\n        // if we haven't rendered data yet, and we have initial state, the filter model is not yet set\n        let results = [];\n        const copiedFilterModel = { ...filterModel.value };\n        if (!firstDataRendered.value && cleanedInitialGridState) {\n          // During initial grid setup, provide results immediately to avoid blocking the grid rendering.\n          // We need to populate selected values in here, or they will be deselected on initial load.\n          // Use getSelectedValues which handles both regular FilterModel and AdvancedFilterModel.\n          const colId = params.colDef.field ?? params.colDef.colId ?? \"\";\n          results = getSelectedValues(copiedFilterModel, colId) || [];\n        } else {\n          results = await fetchFilterValues(params.colDef, {\n            api: params.api,\n            filterModel: copiedFilterModel,\n            useStaged: false,\n          });\n        }\n        // We add an empty value (that gets filtered out before the dropdown is shown) to the list of values to fix\n        // an AG grid bug where returning results that match the current selections (or less than that) causes\n        // the entire filter to be cleared.\n        params.success([...results, \"\"] as unknown as FilterValueResponseOption[]);\n      }\n    : null;\n\nconst rowNodeContainsAggregateValue = (params: ICellRendererParams) => {\n  if (params.column?.getColDef().pivotValueColumn) return false;\n  const node = params.node as RowNode<T>;\n  const colField = params.column?.getColId();\n  // we only want to show the aggregate value if the node is a group node and is for a column with an agg function\n  if (!node.group || !colField) return false;\n  return availableAggFuncColumns.value.some((col) => {\n    if (col.field === colField) {\n      return true;\n    }\n  });\n};\n\n// define default column definitions (individual column definitions can override these)\nconst defaultColDef: ColDef<T> = (() => {\n  const colDef: ColDef<T> = {\n    suppressHeaderFilterButton: !props.enableInlineFilters,\n    editable: false,\n    sortable: true,\n    suppressHeaderMenuButton: true,\n    suppressColumnsToolPanel: true,\n    minWidth: 150,\n    flex: 1,\n    headerComponent: !props.enableInlineFilters ? HeaderCellRenderer : undefined,\n    cellDataType: false,\n    tooltipComponent: TableTooltip,\n    cellClass: (params) => {\n      // don't right align the group column\n      if (isAutoGroupCol(params.column)) {\n        return \"\";\n      }\n      if (isColDefNumericDataType(params.column?.getColDef())) {\n        return \"pv-text-right\";\n      }\n      return \"\";\n    },\n    cellRendererSelector: (params: ICellRendererParams) => {\n      // this cell renderer should override other cell renderers\n      if (rowNodeContainsAggregateValue(params)) {\n        // respect custom cellRenderer if defined on the colDef\n        if (params.column?.getColDef().cellRenderer) {\n          return undefined;\n        }\n        return {\n          component: GroupAggCellRenderer,\n          params: params,\n        };\n      }\n      // for other renderers don't override the cell renderer if one is already defined\n      if (params.column?.getColDef().cellRenderer) {\n        return undefined;\n      }\n      // we can display row numbers if the prop is true and we are not grouping\n      if (props.displayRowNumber && !pivotEnabled && rowGroupColumnFields.value.length === 0) {\n        const allCols = params.api.getAllDisplayedColumns() || [];\n        const currentCol = params.column;\n        const displayIndex = allCols.findIndex((c) => c === currentCol);\n        if (displayIndex === 0) {\n          return {\n            component: RowCountCellRenderer,\n            params: params,\n          };\n        }\n      }\n      return undefined;\n    },\n  };\n  if (props.defaultColDefOverrides) {\n    Object.assign(colDef, props.defaultColDefOverrides);\n  }\n  return colDef;\n})();\n\n/*\n * Header Menu Configuration\n */\nconst getMainMenuItems: Ref<GetMainMenuItems<T> | undefined> = ref(undefined);\n\nconst getContextMenuItems = computed(() => {\n  return (params: GetContextMenuItemsParams<T>) => {\n    // Use custom handler if provided\n    if (props.getContextMenuItems) {\n      return props.getContextMenuItems(params);\n    }\n\n    // Default: show cut, copy, paste (respecting suppressions)\n    const items = [];\n    items.push(\"copy\");\n    if (!props.suppressCutToClipboard) {\n      items.push(\"cut\");\n    }\n    if (!props.suppressClipboardPaste) {\n      items.push(\"paste\");\n    }\n    return items;\n  };\n});\n\nconst customFilterMenuItem: MenuItemDef = {\n  name: \"Column Filter\",\n  icon: '<span class=\"ag-icon ag-icon-filter\"></span>',\n  action: function (params: IMenuActionParams) {\n    let colId = params.column?.getColId() as string;\n    // strip 'ag-Grid-AutoColumn-' prefix if the column is auto-generated from grouping\n    if (params.column && isAutoGroupCol(params.column)) {\n      colId = groupColumnCellValueColumn.value?.getColId() || \"\";\n    }\n    // Pin the filter so it is created if missing and stays visible as the filter row narrows.\n    const filterColDef = params.api.getColumn(colId)?.getColDef();\n    if (filterColDef) currentlyActiveFilter.value = filterColDef;\n    if (filterPanelRef.value?.openHorizontalFilter(colId)) return;\n    nextTick(() => {\n      if (filterPanelRef.value?.openHorizontalFilter(colId)) return;\n      // Too narrow to show the filter even on its own: fall back to the All Filters drawer.\n      if (filterPanelRef.value?.isHorizontalFilterCollapsed(colId)) {\n        filterPanelRef.value.openVerticalDrawer();\n      }\n    });\n  },\n};\n\nconst isClickableCell = (params: { data?: T; node?: { group?: boolean }; value?: unknown }) =>\n  !params.node?.group && params.data != null && params.value != null && params.value !== \"\";\n\nconst updateColDefWithContext = (colDef: ColDef<T> | null, context: ColDefContextProps<T>) => {\n  if (!colDef) return null;\n  const updatedColDef = { ...colDef };\n  const updatedContext = context;\n  const aggregateFields = getAggregateFields(colDef);\n\n  if (updatedContext.devOnly) {\n    if (!props.devMode) {\n      return null;\n    } else {\n      updatedColDef.hide = true;\n    }\n  }\n  if (aggregateFields.length > 0) {\n    if (!props.enableAdvancedFilter) {\n      console.warn(\n        \"Aggregate fields are only supported with advanced filtering enabled. Please enable advanced filtering to use aggregate fields.\",\n      );\n      return null;\n    }\n    // we only use the filter ability for aggregate field col defs, we don't want to show the actual column\n    updatedColDef.hide = true;\n    updatedColDef.suppressColumnsToolPanel = true;\n    updatedColDef.lockVisible = true;\n  }\n  if (updatedContext.isCellClickable) {\n    updatedColDef.cellClassRules = {\n      ...updatedColDef.cellClassRules,\n      \"pv-data-table-cell-clickable\": isClickableCell,\n    };\n    if (!updatedColDef.tooltipField && !updatedColDef.tooltipValueGetter) {\n      updatedColDef.tooltipValueGetter = (params) => (isClickableCell(params) ? \"Click to view details\" : undefined);\n    }\n  }\n  if (props.enableAdvancedFilter) {\n    // we need unique ids for the advanced filter to work properly\n    const existingHeaderValueGetter = colDef.headerValueGetter;\n    updatedColDef.headerValueGetter = (params) => {\n      if (params.location === \"advancedFilter\") {\n        return updatedColDef.colId || updatedColDef.field || \"\";\n      }\n      if (existingHeaderValueGetter && typeof existingHeaderValueGetter === \"function\") {\n        return existingHeaderValueGetter(params);\n      } else if (existingHeaderValueGetter && typeof existingHeaderValueGetter === \"string\") {\n        return existingHeaderValueGetter;\n      }\n      return updatedColDef.headerName || updatedColDef.field || \"\";\n    };\n  }\n  if (updatedContext.isArrayField && !colDef.valueFormatter) {\n    updatedColDef.valueFormatter = (params) => {\n      return arrayValueFormatter(params, updatedContext.dataType);\n    };\n  } else if (updatedContext.dataType === ColDefDataType.Percent && !colDef.valueFormatter) {\n    updatedColDef.valueFormatter = (params) => percentageFormatter(params, updatedContext.valueDecimals || 0);\n  } else if (updatedContext.dataType === ColDefDataType.Currency && !colDef.valueFormatter) {\n    updatedColDef.valueFormatter = (params) => currencyFormatter(params, updatedContext.valueDecimals || 0);\n  } else if (updatedContext.dataType === ColDefDataType.Integer && !colDef.valueFormatter) {\n    updatedColDef.valueFormatter = integerFormatter;\n  } else if (updatedContext.dataType === ColDefDataType.Tag && !colDef.cellRenderer) {\n    updatedColDef.cellRenderer = TagCellRenderer;\n  }\n  return updatedColDef;\n};\n\n/*\n * Pivot Configuration\n */\n\nconst colDefField = (colDef: ColDef<T>) => colDef.colId || colDef.field || \"\";\n\n// The ids of the colDefs that match, by the given index and then colDef order.\nconst pivotFields = (\n  matches: (colDef: ColDef<T>) => boolean,\n  indexOf: (colDef: ColDef<T>) => number | null = () => null,\n) =>\n  (props.colDefs ?? [])\n    .map((colDef, index) => ({ colDef, index }))\n    .filter(({ colDef }) => matches(colDef))\n    .sort((a, b) => (indexOf(a.colDef) ?? a.index) - (indexOf(b.colDef) ?? b.index) || a.index - b.index)\n    .map(({ colDef }) => colDefField(colDef));\n\n// The layout comes from the colDefs' own AG Grid props: `rowGroup` down the side, `pivot` across the top, and the\n// columns with an `aggFunc` (unless `enableValue: false`) as the measures.\nconst pivotConfig: PvDataTablePivot | null = pivotEnabled\n  ? {\n      rowGroupCols: pivotFields(\n        (colDef) => !!colDef.rowGroup,\n        (colDef) => colDef.rowGroupIndex ?? null,\n      ),\n      pivotCols: pivotFields(\n        (colDef) => !!colDef.pivot && !colDef.rowGroup,\n        (colDef) => colDef.pivotIndex ?? null,\n      ),\n      valueCols: pivotFields(\n        (colDef) => !!colDef.aggFunc && !colDef.rowGroup && !colDef.pivot && colDef.enableValue !== false,\n      ),\n    }\n  : null;\n\nconst pivotSourceColDef = (colId: string | undefined) =>\n  colId ? props.colDefs?.find((colDef) => colDefField(colDef) === colId) : undefined;\nconst pivotContext = (colId: string | undefined) =>\n  pivotSourceColDef(colId)?.context as ColDefContextProps<T> | undefined;\n// The row field behind a column id.\nconst pivotDataField = (colId: string) => pivotSourceColDef(colId)?.field ?? colId;\n\n// Order for the first pivot column's values: `pivotValueOrder`, then focused values (e.g. the incumbent), then alphabetical.\nconst pivotGroupComparator = (valueA: string, valueB: string) => {\n  const focused = focusType.value === pivotConfig?.pivotCols[0] ? focuses.value : [];\n  const order = [...(props.pivotValueOrder ?? []), ...focused].map(String);\n  const rank = (value: string) => {\n    const index = order.indexOf(String(value));\n    return index === -1 ? order.length : index;\n  };\n  return rank(valueA) - rank(valueB) || String(valueA).localeCompare(String(valueB));\n};\n\n// Server rows are already aggregated, so a cell shows its one row. A cell built from several rows (a parent\n// subtotal, or duplicate rows) can't be worked out from them, so it's left blank. Raw rowData is aggregated with\n// the column's own function.\nconst singleRowAggFunc = (params: IAggFuncParams<T>) => (params.values.length === 1 ? params.values[0] : null);\n\n// Pivot group rows are built client-side and have no data of their own, so a row group column's formatter\n// gets the group's first row instead. Every row in the group shares the key, so its label fields match.\nconst withGroupRowData = (valueFormatter: ColDef<T>[\"valueFormatter\"]): ColDef<T>[\"valueFormatter\"] => {\n  if (typeof valueFormatter !== \"function\") return valueFormatter;\n  return (params) =>\n    valueFormatter(\n      params.data || !params.node?.group ? params : { ...params, data: params.node.allLeafChildren?.[0]?.data },\n    );\n};\n\nconst applyPivotRole = (colDef: ColDef<T>): ColDef<T> => {\n  const pivot = pivotConfig!;\n  const field = colDefField(colDef);\n  const rowGroupIndex = pivot.rowGroupCols.indexOf(field);\n  const pivotIndex = pivot.pivotCols.indexOf(field);\n  const isValue = pivot.valueCols.includes(field);\n  return {\n    ...colDef,\n    valueFormatter: rowGroupIndex !== -1 ? withGroupRowData(colDef.valueFormatter) : colDef.valueFormatter,\n    rowGroup: rowGroupIndex !== -1,\n    rowGroupIndex: rowGroupIndex !== -1 ? rowGroupIndex : null,\n    pivot: pivotIndex !== -1,\n    pivotIndex: pivotIndex !== -1 ? pivotIndex : null,\n    pivotComparator: pivotIndex === 0 ? pivotGroupComparator : colDef.pivotComparator,\n    aggFunc: isValue ? (props.serverSidePivotHandler ? singleRowAggFunc : colDef.aggFunc) : null,\n    enableValue: isValue,\n  };\n};\n\n// Column defs before pivot roles are applied.\nconst baseColDefs =\n  props.colDefs\n    ?.map((colDef) => {\n      let updatedColDef = { ...colDef } as ColDef<T> | null;\n      if ((serverSideDataSource || pivotEnabled) && gridFilterValuesSetHandler && hasSetFilter(colDef)) {\n        updatedColDef = addHandlerToSetFilter<T>(colDef, gridFilterValuesSetHandler);\n      }\n      const colDefContextProps = colDef.context as ColDefContextProps<T> | undefined;\n      // use the custom context to override definitions as needed\n      if (colDefContextProps) {\n        updatedColDef = updateColDefWithContext(updatedColDef, colDefContextProps);\n      }\n      return updatedColDef;\n    })\n    .filter((colDef): colDef is ColDef<T> => colDef != null) || [];\n// With no row groups, every row goes into one labeled group so the single row has a label column.\nconst PIVOT_TOTAL_COL_ID = \"__pv_pivot_total__\";\nconst pivotTotalColDef: ColDef<T> = {\n  colId: PIVOT_TOTAL_COL_ID,\n  headerName: \"\",\n  rowGroup: true,\n  rowGroupIndex: 0,\n  suppressColumnsToolPanel: true,\n  valueGetter: () => props.pivotTotalLabel,\n};\n\nconst updatedColDefs = pivotEnabled\n  ? [...baseColDefs.map(applyPivotRole), ...(pivotConfig?.rowGroupCols.length ? [] : [pivotTotalColDef])]\n  : baseColDefs;\n\n// Validate that aggregate field hierarchy entries reference existing colDefs\nconst allFieldIds = new Set(props.colDefs?.map((cd) => cd.field || cd.colId).filter(Boolean) || []);\nfor (const colDef of updatedColDefs) {\n  for (const aggregateField of getAggregateFields(colDef)) {\n    if (!allFieldIds.has(aggregateField)) {\n      console.warn(\n        `aggregate field hierarchy references \"${aggregateField}\" on column \"${colDef.field || colDef.colId}\", but no colDef with that field exists.`,\n      );\n    }\n  }\n}\n\n// A consumer marking any column with a visibilityState has opted into the column-configuration\n// semantics, which is the signal to restore column order from grid state.\nconst hasColumnConfigSemantics = updatedColDefs.some((colDef) => colDef.context?.visibilityState !== undefined);\n\n// In pivot mode the `pivot` prop owns row groups, pivots, and aggregation, so saved grid state can't override them.\nconst withoutPivotOwnedState = <S extends GridState | null | undefined>(state: S): S => {\n  if (!pivotEnabled || !state) return state;\n  const rest = { ...state };\n  delete rest.rowGroup;\n  delete rest.pivot;\n  delete rest.aggregation;\n  return rest;\n};\n\nconst cleanedInitialGridState = withoutPivotOwnedState(\n  cleanInitialGridState(props.initialGridState, updatedColDefs, props.enableAdvancedFilter),\n);\n\nconst currentlyActiveFilter: Ref<ColDef | null> = ref(null);\nconst rowGroupColumnFields: Ref<string[]> = ref([]);\nconst firstDataRendered: Ref<boolean> = inject(FirstDataRenderedKey, ref(false));\nconst rowsLoading: Ref<boolean> = ref(false);\n\nconst requiredGroupHeaderName = computed(() => {\n  if (rowGroupColumnFields.value.length > 0) {\n    // get first group only\n    const firstGroupField = rowGroupColumnFields.value[0];\n    const colDef = updatedColDefs.find((col) => col.field === firstGroupField);\n    // check if filter model has a filter for that column\n    const currentModel = filterModel.value;\n    let colFilterModelEmpty = !currentModel;\n    if (!colFilterModelEmpty && isRegularFilterModel(currentModel)) {\n      const regularModel = currentModel as FilterModel;\n      colFilterModelEmpty = !regularModel[firstGroupField];\n    }\n    // if filter is required to group and no filter is applied, don't show/fetch data\n    if (colFilterModelEmpty && colDef?.context?.filterRequiredToGroup) {\n      return colDef.headerName;\n    }\n  }\n  return null;\n});\n\nconst displayUnfilteredTableData = computed(() => {\n  //check if any filters required and if filter model is empty\n  const filterModelEmpty = filterStore.filterModelEmpty.value;\n  if (filterModelEmpty && props.requireFiltersToShowData) {\n    return false;\n  }\n  // otherwise, check if we have grouped rows and have restrictions on those columns\n  return requiredGroupHeaderName.value === null;\n});\n\nconst filterRestrictionMessage = computed(() => {\n  if (requiredGroupHeaderName.value) {\n    return `Select at least one value for \"${requiredGroupHeaderName.value}\" to view data.`;\n  }\n  return `Select a filter to view data.`;\n});\n\n// grid api/models that we track to make available to child components\nconst gridApi = shallowRef<GridApi<T> | null>(null);\nconst sortState = ref<SortModelItem[]>([]);\n// Use an explicitly provided filter store first, then injected context, then create a private store.\nconst filterStore = props.filterStore || useFilterStore();\nconst injectedFocusStore = inject(FocusStoreKey, null);\nconst focusStore = injectedFocusStore || createFocusStore(null, props.allFieldsAreFocusable);\n// Access store properties individually to avoid Vue production warning\nconst filterModel = filterStore.filterModel;\nconst tableSearchFilterModel = filterStore.tableSearchFilterModel;\nconst filterValueMap = filterStore.filterValueMap;\nconst filterValuesMap = filterStore.filterValuesMap;\nconst filterValueSelectedMetadataMap = filterStore.filterValueSelectedMetadataMap;\nconst fetchFilterValues = filterStore.fetchFilterValues;\nconst filterStoreHandler = filterStore.filterStoreHandler;\nconst tableSearchHandler = filterStore.tableSearchHandler;\n\nfilterStoreHandler.value = props.filterValuesSetHandler as\n  | ((\n      params: FilterValuesSetHandlerParams<unknown>,\n    ) => Promise<FilterValuesResponse | (FilterValueResponseOption | null)[]>)\n  | undefined;\nif (filterStoreHandler.value) {\n  const currentFilterOptionsResponse = (field: string): FilterValuesResponse => ({\n    hasMore: filterStore.filterHasMoreMap.value[field],\n    totalCount: filterStore.filterTotalCountMap.value[field],\n    values: filterStore.filterOptionsMap.value[field] ?? [],\n  });\n\n  filterStore.setFilterOptionsHandler(async (params) => {\n    const handler = filterStoreHandler.value;\n    if (!handler) return currentFilterOptionsResponse(params.field);\n\n    const response = await handler({\n      ...params,\n      api: (gridApi.value as unknown as GridApi<unknown> | null) ?? undefined,\n      colDef: params.colDef as ColDef<unknown>,\n      filterModel: params.filterModel as FilterModel | AdvancedFilterModel | null | undefined,\n    });\n    return response ?? currentFilterOptionsResponse(params.field);\n  });\n}\ntableSearchHandler.value = props.tableSearchHandler as\n  | ((params: TableSearchHandlerParams<unknown>) => Promise<(QueryTerm | null)[]>)\n  | undefined;\n\n// provide initial data for the filter values to format properly\nfilterValueMap.value = props.initialFilterValueMap || {};\nfilterValuesMap.value = Object.fromEntries(\n  Object.entries(props.initialFilterValueMap || {}).map(([field, values]) => [\n    field,\n    values.filter((item) => item != null).map((item) => item.value),\n  ]),\n);\nfilterValueSelectedMetadataMap.value = props.initialFilterValueSelectedMetadataMap || {};\nfilterStore.refreshFiltersInBackground.value = props.refreshFiltersInBackground ?? false;\nfilterStore.stageFilterChangesUntilDropdownCloses.value = props.stageFilterChangesUntilDropdownCloses ?? false;\nfilterStore.filterSearchMinLength.value = props.filterSearchMinLength;\nfilterStore.filterModelType.value = props.enableAdvancedFilter ? \"advanced\" : \"regular\";\n\nwatch(\n  () => props.enableAdvancedFilter,\n  (enableAdvancedFilter) => {\n    filterStore.filterModelType.value = enableAdvancedFilter ? \"advanced\" : \"regular\";\n  },\n);\n\n// Emit filter metadata changes so consumers can persist and re-seed on remount.\n// Debounced because the underlying maps mutate on every filter fetch, append,\n// and child-merge — a raw deep watch would fire dozens of times per user\n// interaction. 250ms coalesces bursts (initial fetch → metadata lands → see-more\n// → aggregate child merges) into a single emit per settled state.\nwatchDebounced(\n  [filterValueMap, filterValueSelectedMetadataMap],\n  () => {\n    emit(\"filter-metadata-changed\", {\n      filterValueMap: filterValueMap.value,\n      filterValueSelectedMetadataMap: filterValueSelectedMetadataMap.value,\n    });\n  },\n  { deep: true, debounce: 250 },\n);\nconst columnDisplayOrder = ref<Column[] | null>(null);\n\nconst focusType = computed(() => {\n  return focusStore?.computedFocusType.value || null;\n});\n\nconst focuses = computed(() => {\n  return focusStore?.computedFocuses.value || [];\n});\n\nconst availableFilterColumns = computed(() => {\n  return updatedColDefs.filter((col) => col.filter);\n});\nconst availableRowGroupColumns = computed(() => {\n  return updatedColDefs.filter((col) => col.enableRowGroup);\n});\n// Pivot roles rewrite aggFuncs, so the chart keeps reading the original defs.\nconst availableAggFuncColumns = computed(() => {\n  return baseColDefs.filter((col) => col.aggFunc);\n});\n\nconst groupColumnCellValueColumn: Ref<Column<T> | null> = ref(null);\nconst expandedRows: Ref<Record<number, boolean>> = ref({});\nconst currentPage = ref(1);\nconst totalPages = ref(0);\n\n// All provided values are reactive and can be accessed by child components via injection\nprovide(FilterStoreKey, filterStore);\nprovide(FocusStoreKey, focusStore);\nprovide(SortStateKey, sortState);\nprovide(GridApiKey, gridApi);\nprovide(ColumnDisplayOrderKey, columnDisplayOrder);\nprovide(CurrentlyActiveFilterKey, currentlyActiveFilter);\nprovide(AvailableFilterColumnsKey, availableFilterColumns);\nprovide(AvailableRowGroupColumnsKey, availableRowGroupColumns);\nprovide(RowGroupColumnFieldsKey, rowGroupColumnFields);\nprovide(GroupColumnCellValueColumnKey, groupColumnCellValueColumn);\nprovide(ExpandedRowsKey, expandedRows);\nprovide(FirstDataRenderedKey, firstDataRendered);\nprovide(RowsLoadingKey, rowsLoading);\nprovide(CurrentPageKey, currentPage);\nprovide(TotalPageKey, totalPages);\n\n// Provide advanced filter state as a computed ref for reactivity\nconst enableAdvancedFilterRef = computed(() => props.enableAdvancedFilter);\nprovide(EnableAdvancedFilterKey, enableAdvancedFilterRef);\n\nconst pivotRowData = shallowRef<T[] | undefined>(undefined);\n// Left-to-right position of each first-pivot-column value, used for header colors.\nconst pivotGroupIndex = computed(() => {\n  const colId = pivotConfig?.pivotCols[0];\n  const field = colId && pivotDataField(colId);\n  const rows = pivotRowData.value ?? props.rowData;\n  if (!field || !rows) return new Map<string, number>();\n  const values = Array.from(new Set(rows.map((row) => String((row as Record<string, unknown>)[field]))));\n  return new Map(values.sort(pivotGroupComparator).map((value, index) => [value, index]));\n});\n\nconst toColumnVO = (colId: string, withAggFunc: boolean) => {\n  const colDef = pivotSourceColDef(colId);\n  return {\n    id: colId,\n    field: colDef?.field ?? colId,\n    displayName: colDef?.headerName || colId,\n    // The server aggregates with the column's own function; the grid then just shows that value.\n    aggFunc: withAggFunc && typeof colDef?.aggFunc === \"string\" ? colDef.aggFunc : undefined,\n  };\n};\n\n// The table search isn't a grid filter, so server requests only see it merged into their filter model.\nconst withTableSearch = (filters: FilterModel | AdvancedFilterModel | null | undefined) => {\n  const search = tableSearchFilterModel.value;\n  if (filterStore.tableSearchFilterModelEmpty.value) return filters ?? null;\n  if (props.enableAdvancedFilter) {\n    return filters\n      ? ({ filterType: \"join\", type: \"AND\", conditions: [filters, search] } as AdvancedFilterModel)\n      : search;\n  }\n  return mergeFilterModels(updatedColDefs, filters as FilterModel | null, search as FilterModel);\n};\n\nlet pivotRequestId = 0;\nconst loadPivotRows = async () => {\n  if (!pivotConfig || !props.serverSidePivotHandler) return;\n  const requestId = ++pivotRequestId;\n  if (!displayUnfilteredTableData.value) {\n    pivotRowData.value = [];\n    firstDataRendered.value = true;\n    return;\n  }\n  rowsLoading.value = true;\n  try {\n    const response = await props.serverSidePivotHandler({\n      rowGroupCols: [...pivotConfig.rowGroupCols, ...pivotConfig.pivotCols].map((field) => toColumnVO(field, false)),\n      valueCols: pivotConfig.valueCols.map((field) => toColumnVO(field, true)),\n      filterModel: withTableSearch(filterModel.value),\n      endRow: props.pivotRowLimit,\n    });\n    // Ignore responses that a newer filter change has superseded.\n    if (requestId === pivotRequestId) pivotRowData.value = response.data as T[];\n  } catch (error) {\n    console.error(\"Failed to load pivot rows\", error);\n    if (requestId === pivotRequestId) pivotRowData.value = [];\n  } finally {\n    if (requestId === pivotRequestId) rowsLoading.value = false;\n  }\n};\n\n// A pivot has no columns until its rows arrive, so loading shows a skeleton instead of an empty grid.\nconst pivotLoading = computed(\n  () =>\n    pivotEnabled && (props.isLoading || (!!props.serverSidePivotHandler && (rowsLoading.value || !pivotRowData.value))),\n);\n\n// One style object, so the shrunk size can't lose to a static `flex: 1`; the skeleton sets its own height while it shows.\nconst gridWrapperStyle = computed(() => ({\n  width: \"100%\",\n  minHeight: 0,\n  overflowX: \"hidden\" as const,\n  ...(shrink?.contentHeight.value && !pivotLoading.value\n    ? { flex: \"0 1 auto\", height: `${shrink.contentHeight.value}px` }\n    : { flex: \"1\" }),\n}));\n\n// A loading pivot has no columns, so its grid steps aside and the skeleton sizes the wrapper.\nconst pivotLoadingGridStyle = computed(() =>\n  pivotLoading.value ? { position: \"absolute\" as const, top: 0, left: 0, visibility: \"hidden\" as const } : undefined,\n);\n\n// A row in a header group: every pivot value down to the group matches (nested pivots have one per level). All rows\n// in the group share those values, so any one has the group's label fields.\nconst pivotGroupData = (pivotKeys: string[]): Partial<T> | undefined =>\n  (pivotRowData.value ?? props.rowData)?.find((row) =>\n    pivotKeys.every(\n      (key, level) =>\n        String((row as Record<string, unknown>)[pivotDataField(pivotConfig!.pivotCols[level])]) === String(key),\n    ),\n  );\n\n// The group's label from the pivot column's own valueFormatter, given a row from the group as `data` (as row group\n// labels are), so a formatter that reads another field (e.g. a name for an id) works.\nconst formatPivotGroupLabel = (colId: string | undefined, value: string, data: Partial<T> | undefined) => {\n  const colDef = updatedColDefs.find((col) => colDefField(col) === colId);\n  if (typeof colDef?.valueFormatter !== \"function\") return undefined;\n  return colDef.valueFormatter({ value, data, colDef, node: null } as unknown as ValueFormatterParams<T>) || undefined;\n};\n\n// Adds the shared group header and its palette position, labeled by the pivot column's valueFormatter, then the\n// column's own header config (`pivotGroupHeader`).\nconst handleProcessPivotResultColGroupDef = (colGroupDef: ColGroupDef<T>) => {\n  const pivotKeys = colGroupDef.pivotKeys ?? [];\n  const key = pivotKeys.at(-1);\n  const colId = pivotConfig?.pivotCols[pivotKeys.length - 1];\n  const value = key == null ? undefined : String(key);\n  const data = pivotGroupData(pivotKeys);\n  const { headerName, ...headerParams } =\n    (value != null &&\n      pivotContext(colId)?.pivotGroupHeader?.({\n        value,\n        data,\n        focused: focusType.value === colId && focuses.value.map(String).includes(value),\n      })) ||\n    {};\n  colGroupDef.headerGroupComponent = PvPivotGroupHeader;\n  colGroupDef.marryChildren = true;\n  // Long names wrap instead of truncating, so the header row grows past PIVOT_GROUP_HEADER_HEIGHT to fit them.\n  colGroupDef.autoHeaderHeight = true;\n  const label = headerName ?? (value == null ? undefined : formatPivotGroupLabel(colId, value, data));\n  if (label) colGroupDef.headerName = label;\n  colGroupDef.headerGroupComponentParams = {\n    ...colGroupDef.headerGroupComponentParams,\n    // Only top-level groups get a color.\n    colorIndex: pivotKeys.length === 1 ? pivotGroupIndex.value.get(String(pivotKeys[0])) : undefined,\n    ...headerParams,\n  };\n\n  // The header cell draws the color tab (see .pv-pivot-group), so it sits at the very top of the group.\n  const { color, colorIndex, highlight } = colGroupDef.headerGroupComponentParams;\n  const barColor =\n    color ?? (colorIndex == null ? undefined : multicolorFills[colorIndex % multicolorFills.length].slice(0, 7));\n  colGroupDef.headerClass = [\"pv-pivot-group\", ...(highlight ? [\"pv-pivot-group--highlight\"] : [])];\n  if (barColor && typeof colGroupDef.headerStyle !== \"function\") {\n    colGroupDef.headerStyle = { ...colGroupDef.headerStyle, \"--pv-pivot-group-color\": barColor };\n  }\n};\n\n// Adds a class while keeping the column's own (e.g. right alignment), including computed (function) classes.\nconst toClassList = (value: unknown): string[] => (Array.isArray(value) ? value : value ? [String(value)] : []);\nconst withClass = (existing: unknown, className: string) => {\n  if (typeof existing === \"function\") {\n    return (params: unknown) => [...toClassList(existing(params)), className];\n  }\n  return [...toClassList(existing), className];\n};\n\n// Applies the measure's `pivotColDef` and styles its header.\nconst handleProcessPivotResultColDef = (colDef: ColDef<T>) => {\n  colDef.minWidth = PIVOT_COLUMN_MIN_WIDTH;\n  // At the narrower width, a long title wraps and the header row grows to fit it instead of clipping.\n  colDef.autoHeaderHeight = true;\n  Object.assign(colDef, pivotContext(colDef.pivotValueColumn?.getColId())?.pivotColDef);\n  colDef.headerClass = withClass(colDef.headerClass, \"pv-pivot-column-header\") as ColDef<T>[\"headerClass\"];\n};\n\n// Server rows are already filtered by the handler, so the grid keeps the filter model (for the filter UI and the\n// next request) without re-applying it to them.\nconst pivotAlwaysPassFilter = pivotEnabled && props.serverSidePivotHandler ? () => true : undefined;\n\nconst processedRowData = computed(() => {\n  if (pivotEnabled) {\n    return pivotRowData.value ?? props.rowData;\n  }\n  if (\n    (!props.enableFocusView && !props.rowData) ||\n    (props.enableFocusView && !focuses.value.length && !focusType.value)\n  ) {\n    return props.rowData;\n  }\n\n  return liftFocusedOptions(props.rowData, focusType.value as keyof T, focuses.value);\n});\n\n// Watching the request itself skips reloads where the search or filters changed to an equal request.\nwatch([() => JSON.stringify(withTableSearch(filterModel.value)), displayUnfilteredTableData], () => {\n  if (pivotEnabled && gridApi.value) void loadPivotRows();\n});\n\n// The comparator only runs when the grid builds the pivot columns, so a later order is applied by moving them.\nconst applyPivotValueOrder = () => {\n  const api = gridApi.value;\n  const pivotColumns = api?.getPivotResultColumns();\n  if (!api || !pivotColumns?.length) return;\n  const allColumns = api.getAllGridColumns();\n  const groupValue = (column: Column) => String(column.getColDef().pivotKeys?.[0]);\n  const ordered = [...pivotColumns].sort(\n    (a, b) => pivotGroupComparator(groupValue(a), groupValue(b)) || allColumns.indexOf(a) - allColumns.indexOf(b),\n  );\n  const start = Math.min(...ordered.map((column) => allColumns.indexOf(column)));\n  if (ordered.every((column, i) => allColumns[start + i] === column)) return;\n  api.moveColumns(ordered, start);\n};\n\nwatch(() => props.pivotValueOrder, applyPivotValueOrder);\n\nwatch(\n  () => focuses.value,\n  (newVal) => {\n    emit(\"focus-update\", { filterField: focusType.value, focuses: newVal });\n  },\n);\n\nwatch(devModeEnabled, (enabled) => {\n  if (!gridApi.value) return;\n  const devColIds = updatedColDefs\n    .filter((col) => (col.context as ColDefContextProps<T>)?.devOnly)\n    .map((col) => col.field!)\n    .filter(Boolean);\n  if (devColIds.length > 0) {\n    gridApi.value.setColumnsVisible(devColIds, enabled);\n  }\n});\n\n/*\n * Emit Handlers\n * These functions are called when the grid emits events\n * we perform any necessary logic and then emit the event to the parent\n */\nconst handleGridReady = (params: GridReadyEvent) => {\n  // set the grid api in the provide so that child components can access it\n  gridApi.value = params.api;\n  void shrink?.observe();\n  void pivotCorner?.observe();\n\n  // The leftmost column is either the specified left pinned column, the first visible row-grouped column,\n  // or the first visible column overall. Row group columns with hide: true are skipped.\n  const firstVisibleGroupField = rowGroupColumnFields.value.find((field) => {\n    const colDef = updatedColDefs.find((col) => col.field === field);\n    return !colDef?.hide;\n  });\n  const firstVisibleColField =\n    !firstVisibleGroupField && rowGroupColumnFields.value.length > 0\n      ? (updatedColDefs.find((col) => !col.hide && !col.rowGroup)?.field ?? null)\n      : null;\n  const leftmostColumn = props.leftPinnedColumnName ?? firstVisibleGroupField ?? firstVisibleColField;\n\n  // If specified, hide all row-grouped columns.\n  const colsToHide = [];\n  if (props.hideAllRowGroupedColumns) {\n    rowGroupColumnFields.value.forEach((field) => colsToHide.push(field));\n  }\n\n  // The first row group field will be either the pinned column property (if it's passed in) or the first row group column.\n  // We want to \"hide\" that column from the main table view because it will be redundant with being pinned to the left.\n  if (leftmostColumn) {\n    const leftmostCol = params.api.getColumn(leftmostColumn);\n    groupColumnCellValueColumn.value = leftmostCol;\n    colsToHide.push(leftmostColumn);\n    applyLeftmostColDefToAutoGroup(leftmostCol?.getColDef());\n  }\n  if (cleanedInitialGridState) {\n    updateGridState(cleanedInitialGridState);\n  } else if (filterModel.value) {\n    setPvFilterModel(filterModel.value);\n  }\n  if (tableSearchFilterModel.value) {\n    setTableSearchFilterModel(tableSearchFilterModel.value);\n  }\n  params.api.setColumnsVisible([...colsToHide], false);\n  if (pivotEnabled) void loadPivotRows();\n  columnDisplayOrder.value = [...params.api.getAllGridColumns()];\n  currentPage.value = params.api.paginationGetCurrentPage() + 1;\n  totalPages.value = params.api.paginationGetTotalPages();\n  emit(\"grid-ready\", params);\n};\n\n// keep track of the filter model for the custom filters\nconst handleFilterChanged = (params: FilterChangedEvent) => {\n  if (gridApi.value) {\n    const newModel = getPvFilterModel();\n    // only store/emit if the filter model is different from the current one\n    if (!filterModelsEqual(filterModel.value, newModel)) {\n      filterModel.value = newModel;\n      emit(\"filter-changed\", params);\n    }\n  }\n};\n\nconst handleSortChanged = (params: SortChangedEvent) => {\n  sortState.value = params.api?.getState()?.sort?.sortModel || [];\n  if (firstDataRendered.value) {\n    emit(\"sort-changed\", params);\n  }\n};\n\n// TODO - filter out columns in the current rowGroupColumnList (for initial state)\nconst isAutoGroupCol = (col: Column<T>) => {\n  return col.getColId() && col.getColId().includes(\"ag-Grid-AutoColumn\");\n};\n\n/*\n * CSV Logic\n */\n\nconst isExporting = ref(false);\n\nconst refreshData = async (params?: RefreshServerSideParams | null) => {\n  if (!gridApi.value) {\n    console.error(\"Grid API not available\");\n    return;\n  }\n  if (pivotEnabled) {\n    await loadPivotRows();\n    return;\n  }\n  // skip if we're in client side mode\n  if (!serverSideDataSource) {\n    return;\n  }\n  const refreshParams = params || { route: [], purge: true };\n  gridApi.value.refreshServerSide(refreshParams);\n};\n\n// Returns the selected-value metadata map. Pass `{ hydrate: true }` to first fetch options for any\n// active filter not already cached (e.g. to persist a complete map for a public view) — async in that case.\nfunction getFilterValueSelectedMetadataMap(): Record<string, (FilterValueResponseOption | null)[]>;\nfunction getFilterValueSelectedMetadataMap(options: {\n  hydrate: true;\n}): Promise<Record<string, (FilterValueResponseOption | null)[]>>;\nfunction getFilterValueSelectedMetadataMap(options?: { hydrate?: boolean }) {\n  if (options?.hydrate) return filterStore.hydrateSelectedFilterMetadata(updatedColDefs);\n  return filterValueSelectedMetadataMap.value;\n}\n\nconst getCsvData = async (): Promise<string | null> => {\n  isExporting.value = true;\n\n  if (!gridApi.value) {\n    console.error(\"Grid API not available\");\n    isExporting.value = false;\n    return null;\n  }\n\n  try {\n    if (pivotEnabled) {\n      // The grid's own export writes the pivot as displayed (group headers and measures).\n      gridApi.value.exportDataAsCsv();\n      isExporting.value = false;\n      return null;\n    }\n    const csvHandler = props.serverSideCsvHandler;\n    const gridState = gridApi.value?.getState();\n    const exportParamsRequest = {\n      rowGroupCols: [],\n      valueCols:\n        gridApi.value?.getValueColumns().map((col) => ({\n          id: col.getId(),\n          field: col.getColDef().field,\n          aggFunc: typeof col.getColDef().aggFunc === \"string\" ? (col.getColDef().aggFunc as string) : undefined,\n          displayName: col.getColDef().headerName || col.getColDef().field || \"\",\n        })) || [],\n      filterModel: getPvFilterModel(),\n      sortModel: gridState?.sort?.sortModel || [],\n      pivotCols: [],\n      pivotMode: false,\n      groupKeys: [],\n      startRow: 0,\n      endRow: props.csvRowLimit,\n    };\n\n    if (csvHandler) {\n      const exportParams: IServerSideGetRowsParams = {\n        request: exportParamsRequest,\n        parentNode: {} as IRowNode<T>,\n        api: gridApi.value!,\n        context: undefined,\n        success: () => {},\n        fail: () => {},\n      };\n\n      await props.serverSideCsvHandler(exportParams);\n      isExporting.value = false;\n      return null;\n    }\n\n    const rowHandler = props.serverSideRowHandler;\n    if (rowHandler) {\n      return await new Promise((resolve, reject) => {\n        const gridState = gridApi.value?.getState();\n        const exportParams: IServerSideGetRowsParams = {\n          request: exportParamsRequest,\n          parentNode: {} as IRowNode<T>,\n          api: gridApi.value!,\n          context: undefined,\n          success: (params: LoadSuccessParams<T>) => {\n            const groupColFields =\n              gridApi.value\n                ?.getRowGroupColumns()\n                .map((col) => col.getColDef().field)\n                .filter((field): field is string => !!field) || [];\n            const displayedColFields =\n              gridApi.value\n                ?.getAllDisplayedColumns()\n                .map((col) => col.getColDef().field)\n                .filter((field): field is string => !!field) || [];\n            const valueColFields =\n              gridApi.value\n                ?.getValueColumns()\n                .map((col) => col.getColDef().field)\n                .filter((field): field is string => !!field) || [];\n            const csvFields = Array.from(new Set([...groupColFields, ...displayedColFields, ...valueColFields]));\n\n            const filteredRows = params.rowData.map((row) => {\n              const filteredRow: Record<string, string | null> = {};\n              csvFields.forEach((field) => {\n                const value = (row as Record<string, unknown>)[field];\n                filteredRow[field] = value != null ? String(value) : null;\n              });\n              return filteredRow;\n            });\n\n            const csv = Papa.unparse(filteredRows);\n            isExporting.value = false;\n            resolve(csv);\n          },\n          fail: () => {\n            isExporting.value = false;\n            reject(\"CSV export failed.\");\n          },\n        };\n\n        rowHandler(exportParams, true);\n      });\n    } else {\n      // TODO: Handle client side expose\n      console.warn(\"Client-side export does not return CSV string\");\n      isExporting.value = false;\n      gridApi.value.exportDataAsCsv();\n      return null;\n    }\n  } catch (e) {\n    console.error(\"CSV export failed\", e);\n    isExporting.value = false;\n    return null;\n  }\n};\n\nconst getPvFilterModel = (): FilterModel | AdvancedFilterModel | null => {\n  if (!gridApi.value) {\n    return filterModel.value;\n  }\n  if (props.enableAdvancedFilter) {\n    return gridApi.value.getAdvancedFilterModel();\n  } else {\n    return gridApi.value.getFilterModel();\n  }\n};\n\nconst setPvFilterModel = (model: FilterModel | AdvancedFilterModel | null): boolean => {\n  if (!gridApi.value) {\n    return false;\n  }\n  if (props.enableAdvancedFilter) {\n    const convertedModel = model && isRegularFilterModel(model) ? convertFilterModelToAdvanced(model) : model;\n    gridApi.value.setAdvancedFilterModel(convertedModel);\n  } else {\n    if (model && !isRegularFilterModel(model)) {\n      console.warn(\n        \"Attempting to set a non-regular filter model while advanced filtering is disabled. The filter model was not applied. Consider enabling advanced filtering for full functionality.\",\n      );\n      return false;\n    }\n    gridApi.value.setFilterModel(model);\n  }\n  return true;\n};\n\nconst setTableSearchFilterModel = (model: FilterModel | AdvancedFilterModel | null): boolean => {\n  tableSearchFilterModel.value = model;\n  if (!gridApi.value) {\n    return false;\n  }\n  gridApi.value.onFilterChanged();\n  if (serverSideDataSource) {\n    gridApi.value.refreshServerSide({ purge: true });\n  }\n  return true;\n};\n\nconst externalFilterController = {\n  getFilterModel: getPvFilterModel,\n  refreshData,\n  setFilterModel: setPvFilterModel,\n  setTableSearchFilterModel,\n};\n\nfilterStore.registerFilterController(externalFilterController);\n\nonBeforeUnmount(() => {\n  filterStore.unregisterFilterController(externalFilterController);\n});\n\ndefineExpose<PvDataTablePublicInterface>({\n  getCsvData,\n  refreshData,\n  getFilterValueSelectedMetadataMap,\n  availableRowGroupColumns,\n  availableAggFuncColumns,\n  rowGroupColumnFields,\n  getPvFilterModel,\n  setPvFilterModel,\n});\n\nconst handleColumnValueChanged = (event: ColumnValueChangedEvent<T>) => {\n  event.api.refreshHeader();\n  emit(\"column-value-changed\", event);\n};\n\n// keep track of the row group columns for the group by selector\nconst handleColumnRowGroupChanged = (event: ColumnRowGroupChangedEvent<T>) => {\n  nextTick(() => {\n    const prevGroupColumnCellValueColumn = groupColumnCellValueColumn.value;\n    const newRowGroupColumns = event.api.getRowGroupColumns();\n    const groupingExists = newRowGroupColumns.length > 0;\n\n    // If a pinned column is specified, pin it to the left. Otherwise, pick the first visible row group column.\n    // Row group columns with hide: true in their colDef are skipped.\n    let leftmostColumn;\n    if (groupingExists && props.leftPinnedColumnName) {\n      leftmostColumn = event.api.getColumn(props.leftPinnedColumnName || \"\");\n    }\n    if (groupingExists && !props.leftPinnedColumnName) {\n      leftmostColumn = newRowGroupColumns.find((col) => !col.getColDef().hide);\n      // If all row group columns are hidden, fall back to the first visible non-group column\n      if (!leftmostColumn) {\n        const firstVisibleField = updatedColDefs.find((col) => !col.hide && !col.rowGroup)?.field;\n        if (firstVisibleField) {\n          leftmostColumn = event.api.getColumn(firstVisibleField);\n        }\n      }\n    }\n\n    if (leftmostColumn) {\n      groupColumnCellValueColumn.value = leftmostColumn;\n      applyLeftmostColDefToAutoGroup(leftmostColumn.getColDef());\n      event.api.setColumnsVisible([leftmostColumn.getColId()], false);\n    } else {\n      groupColumnCellValueColumn.value = null;\n      applyLeftmostColDefToAutoGroup(null);\n    }\n    const prevGroupColId = prevGroupColumnCellValueColumn?.getColId();\n    if (!leftmostColumn || prevGroupColId !== leftmostColumn.getColId()) {\n      // Only re-show the previous column if its colDef doesn't have hide: true\n      const prevColDef = prevGroupColumnCellValueColumn?.getColDef();\n      if (!prevColDef?.hide) {\n        event.api.setColumnsVisible([prevGroupColId || \"\"], true);\n      }\n    }\n    rowGroupColumnFields.value = [...newRowGroupColumns].map((col) => col.getColId());\n    // only handle focus events here if we have our own focus store\n    if (props.enableFocusView && !injectedFocusStore) {\n      const newFocusType = rowGroupColumnFields.value.length > 0 ? rowGroupColumnFields.value[0] : null;\n      focusStore.setFocusType(newFocusType);\n    }\n    if (firstDataRendered.value) {\n      emit(\"column-row-group-changed\", event);\n    }\n  });\n};\n\nconst handleColumnVisibleChanged = (event: ColumnResizedEvent<T>) => {\n  // prevent visibility of column if it patches the active groupColumnCellValueColumn\n  const colId = event.column?.getColId() || \"\";\n  if (colId === groupColumnCellValueColumn.value?.getColId()) {\n    event.api.setColumnsVisible([colId], false);\n    return;\n  }\n  //TODO - clear sort if column is hidden and has an active sort\n};\n\nconst handleRowClicked = (event: RowClickedEvent<T>) => {\n  if (props.enableExpandOnRowClick) {\n    // if we clicked a grouped row, toggle the expanded state of that row\n    if (event.node.group) {\n      event.node.setExpanded(!event.node.expanded);\n    }\n  }\n  emit(\"row-clicked\", event);\n};\n\n// keep track of column positions to disable resizing on the last column\nconst handleColumnMoved = (event: ColumnMovedEvent<T>) => {\n  if (event.finished) {\n    // getAllGridColumns returns AG Grid's internal array, which moves mutate in\n    // place — copy it so the ref assignment actually triggers reactivity.\n    columnDisplayOrder.value = [...event.api.getAllGridColumns()];\n  }\n  // A drag the consumer's order disagrees with (e.g. it keeps a focused value first) snaps back.\n  if (pivotEnabled && props.pivotValueOrder && event.finished && event.source === \"uiColumnMoved\") {\n    nextTick(applyPivotValueOrder);\n  }\n  if (firstDataRendered.value) {\n    emit(\"column-moved\", event);\n  }\n};\n\nconst handlePaginationChanged = (event: PaginationChangedEvent<T>) => {\n  if (event.api) {\n    currentPage.value = event.api.paginationGetCurrentPage() + 1;\n    totalPages.value = event.api.paginationGetTotalPages();\n  }\n};\n\n// will populate row counts if the SSRM handler returns row data with the allChildrenRowCount property\nconst handleGetChildCount = <T extends object>(data: T): number => {\n  if (\"allChildrenRowCount\" in data) {\n    return (data[\"allChildrenRowCount\"] as number) || 0;\n  }\n  return 0;\n};\n\n/*\n * Row Styling\n */\n\n// custom renderer for loading skeleton (when server-side data is loading)\nconst resolvedFullWidthCellRenderer = computed(() =>\n  props.fullWidthCellRenderer ? toRaw(props.fullWidthCellRenderer) : undefined,\n);\nconst resolvedLoadingCellRenderer = computed(() =>\n  props.loadingCellRenderer ? toRaw(props.loadingCellRenderer) : RowLoadingCellRenderer,\n);\nconst loadingCellRendererParams = {\n  loadingMessage: \"One moment please...\",\n};\n\nconst initialAutoGroupColumnDef: ColDef<T> = (() => {\n  const initialDef: ColDef<T> = {\n    headerName: \"\",\n    minWidth: 200,\n    suppressMovable: true,\n    sortable: false,\n    pinned: \"left\",\n    headerComponent: undefined,\n    cellRendererParams: {\n      suppressCount: true,\n      innerRenderer: AutoGroupColDefRenderer,\n      innerRendererParams: (params: ICellRendererParams) => {\n        return {\n          plainLabel: pivotEnabled,\n          boldLabel: pivotEnabled && !pivotConfig?.rowGroupCols.length,\n          displayBaseAggregationsOnly: props.displayBaseAggregationsOnly,\n          displayRowNumber: props.displayRowNumber,\n          displayCount: props.displayGroupCount,\n          formattedValue: params.valueFormatted,\n          rowNode: params.node,\n          api: gridApi.value,\n          focusText: props.focusText,\n          cellParams: params,\n        };\n      },\n    },\n  };\n  if (pivotEnabled) {\n    initialDef.suppressSpanHeaderHeight = true;\n    initialDef.headerClass = \"pv-pivot-column-header\";\n  }\n  // merge with autoGroupColumnDefOverrides, if provided\n  if (props.autoGroupColumnDefOverrides) {\n    Object.assign(initialDef, props.autoGroupColumnDefOverrides);\n  }\n  return initialDef;\n})();\n\n// custom renderer for displaying grouped row headers and aggregate data\nconst autoGroupColumnDef = ref(initialAutoGroupColumnDef) as Ref<ColDef<T>>;\n\n// Copies relevant properties from the leftmost column's colDef onto the auto-group column.\nconst applyLeftmostColDefToAutoGroup = (colDef: ColDef<T> | null | undefined) => {\n  if (!colDef) {\n    autoGroupColumnDef.value.headerName = \"\";\n    autoGroupColumnDef.value.headerComponent = undefined;\n    autoGroupColumnDef.value.context = null;\n    autoGroupColumnDef.value.sortable = false;\n    autoGroupColumnDef.value.filter = undefined;\n    autoGroupColumnDef.value.enableRowGroup = undefined;\n    return;\n  }\n  autoGroupColumnDef.value.field = colDef.field;\n  autoGroupColumnDef.value.headerName = colDef.headerName;\n  autoGroupColumnDef.value.headerComponent =\n    colDef.headerComponent ?? (!props.enableInlineFilters ? HeaderCellRenderer : undefined);\n  autoGroupColumnDef.value.context = {\n    dataType: colDef.context?.dataType || null,\n  } as ColDefContextProps<T>;\n  autoGroupColumnDef.value.sortable = colDef.sortable;\n  autoGroupColumnDef.value.filter = colDef.filter;\n  autoGroupColumnDef.value.enableRowGroup = colDef.enableRowGroup;\n  autoGroupColumnDef.value.onCellClicked = colDef.onCellClicked;\n};\n\n// sets the background color for grouped rows\nconst getRowStyle = (params: RowClassParams<T>) => {\n  if (params.node.group && !pivotEnabled) {\n    return {\n      backgroundColor: \"var(--color-background-accent, #f7f8f8)\",\n      ...(props.enableExpandOnRowClick ? { cursor: \"pointer\" } : {}),\n    };\n  }\n  return undefined;\n};\n\nconst getRowClass = (params: RowClassParams<T>) => {\n  const classes = props.enableFullRowClick && !params.node.group ? [\"pv-data-table-row-clickable\"] : [];\n  if (!params.node.group && params.node.lastChild && (params.node.parent?.level ?? -1) >= 0) {\n    classes.push(\"pv-data-table-group-last-child\");\n  }\n  return classes.length ? classes : undefined;\n};\n\n/*\n * Custom Aggregation Functions\n */\ninterface medianAgg {\n  values: number[];\n  value: number;\n}\nconst customAggFuncs = {\n  Median: (params: IAggFuncParams) => {\n    const values = params.values;\n\n    // Leaf level: calculate median of actual numeric values\n    if (params.rowNode.leafGroup) {\n      const median = calculateHighMedian(values);\n      return {\n        values: values,\n        value: median,\n      };\n    }\n    // Group level: calculate median of all values from child nodes\n    const groupedValues = params.values.flatMap((value: medianAgg) => value.values || []);\n    const groupMedian = calculateHighMedian(groupedValues);\n    return {\n      values: groupedValues,\n      value: groupMedian,\n    };\n  },\n};\n\nonBeforeMount(() => {\n  popupParentElement.value = document.querySelector(\"body\");\n\n  const hasRowData = Array.isArray(props.rowData) && props.rowData.length > 0;\n  const hasServerHandler = typeof props.serverSideRowHandler === \"function\";\n  const hasFilterValuesSetHandler = typeof props.filterValuesSetHandler === \"function\";\n  if ((hasRowData && hasServerHandler) || (hasRowData && hasFilterValuesSetHandler)) {\n    console.warn(\n      \"Only one of `rowData` or `serverSideRowHandler + hasFilterValuesSetHandler` params should be provided to PvDataTable, not both.\",\n    );\n  }\n\n  // set the available header menu items, filtering out any that are not in the default items or a custom filter menu item\n  getMainMenuItems.value = (params: GetMainMenuItemsParams<T>) => {\n    // this order is important, as it determines the order of the menu items\n    const menuItems: (DefaultMenuItem | MenuItemDef)[] = [\n      \"sortAscending\",\n      \"sortDescending\",\n      \"sortUnSort\",\n      // \"rowGroup\", - disabling this until we can figure out how to selectively disable it once max groups have been reached\n      \"rowUnGroup\",\n      // \"valueAggSubMenu\", - disabling this since we have our own header selector\n    ];\n    // add custom filter menu item after sortUnSort if filter is enabled\n    const col = params.column && isAutoGroupCol(params.column) ? groupColumnCellValueColumn.value : params.column;\n    if (!props.enableInlineFilters && col && col.getColDef().filter) {\n      menuItems.splice(2, 0, customFilterMenuItem);\n    }\n    return menuItems.filter((item) => {\n      if (typeof item === \"string\") {\n        return params.defaultItems.includes(item as DefaultMenuItem);\n      } else {\n        return true;\n      }\n    });\n  };\n\n  if (cleanedInitialGridState) {\n    filterModel.value =\n      (props.enableAdvancedFilter\n        ? cleanedInitialGridState.filter?.advancedFilterModel\n        : cleanedInitialGridState.filter?.filterModel) || null;\n    rowGroupColumnFields.value = cleanedInitialGridState.rowGroup?.groupColIds || [];\n  }\n});\n\nconst updateGridState = (gridState: GridState) => {\n  const api = gridApi.value;\n  if (!api) return;\n  const filterModel = gridState.filter?.filterModel || null;\n  const rowGroupColumns = gridState.rowGroup?.groupColIds || null;\n  const columnVisibility = gridState.columnVisibility || null;\n\n  if (filterModel && !filterModelsEqual(filterModel, api.getFilterModel())) {\n    api.setFilterModel(filterModel);\n  }\n  if (props.isTableGrouped && rowGroupColumns && !isEqual(rowGroupColumns, rowGroupColumnFields.value)) {\n    api.setRowGroupColumns(rowGroupColumns);\n  }\n  if (columnVisibility?.hiddenColIds) {\n    api.setColumnsVisible(columnVisibility.hiddenColIds, false);\n  }\n\n  const orderedColIds = gridState.columnOrder?.orderedColIds;\n  if (hasColumnConfigSemantics && orderedColIds?.length) {\n    const currentOrder = api.getAllGridColumns().map((col) => col.getColId());\n    if (!isEqual(orderedColIds, currentOrder)) {\n      api.applyColumnState({ state: orderedColIds.map((colId) => ({ colId })), applyOrder: true });\n    }\n  }\n};\n\n// the initial grid state used by AG Grid is only read once on creation. If we want to update it as the prop\n// changes, we need to update it manually\nwatch(\n  () => props.initialGridState,\n  () => {\n    if (props.initialGridState) {\n      const cleanedState = withoutPivotOwnedState(\n        cleanInitialGridState(props.initialGridState, updatedColDefs, props.enableAdvancedFilter),\n      );\n      if (cleanedState) {\n        updateGridState(cleanedState);\n      }\n    }\n  },\n  { deep: true },\n);\n\nconst handleFirstDataRendered = (event: FirstDataRenderedEvent<T>) => {\n  firstDataRendered.value = true;\n  emit(\"first-data-rendered\", event);\n};\n\nconst isServerSideGroupOpenByDefaultHandler = (params: IsServerSideGroupOpenByDefaultParams) => {\n  if (!serverSideDataSource) {\n    return false;\n  }\n\n  // If logic to open grouped rows by default is provided, use that.\n  if (props.isServerSideGroupOpenByDefault) {\n    return props.isServerSideGroupOpenByDefault(params);\n  }\n\n  // Otherwise, use default logic: only open the level 2 nodes up from the leaf nodes (child rows).\n  return params.rowNode.level === rowGroupColumnFields.value.length - 2;\n};\n\nconst computedGroupDefaultExpanded = computed(() => {\n  // for server side data source, we set to undefined\n  if (serverSideDataSource) {\n    return undefined;\n  }\n  return props.groupDefaultExpanded;\n});\n\nconst popupParentElement = ref<HTMLElement | null>(null);\nconst filterPanelRef = ref<{\n  openVerticalDrawer: () => void;\n  openHorizontalFilter: (field: string) => boolean;\n  isHorizontalFilterCollapsed: (field: string) => boolean;\n} | null>(null);\nconst advancedFilterParentElement = ref<HTMLElement | null>(null);\n\n// Single source of truth for the table search input, which renders in one of\n// two mutually-exclusive spots: inline with the filter row, or its own row\n// below it (see tableSearchInline). NB: a single teleported instance would be\n// cleaner, but teleporting a component inside this frequently-re-rendering\n// table trips a Vue core bug (vuejs/core#13077) — null component instance on\n// optimized block update. So we share props/style and render the tag twice.\nconst { present: hasTopSlot } = useSlotPresence(\"top-slot\");\nconst topSlotEnabled = computed(() => props.enableTopSlot && hasTopSlot.value);\nconst inlineTopSlotEnabled = computed(() => topSlotEnabled.value && props.tableSearchInline);\n// Match the 42px ExportMenu trigger so both header groups share a first-line center.\nconst inlineTopSlotControlHeight = \"42px\";\nconst tableSearchWrapperStyle = computed(() => [\n  // Inline sits in the filter flex row, so a percentage width resolves against\n  // that group (not the table) and overflows — use a fixed, shrinkable width.\n  // The standalone row spans the table, where a percentage width is fine.\n  props.tableSearchInline ? { width: \"360px\", maxWidth: \"100%\", minWidth: 0 } : { width: \"40%\", maxWidth: \"50%\" },\n  inlineTopSlotEnabled.value\n    ? { alignItems: \"center\", display: \"grid\", minHeight: inlineTopSlotControlHeight }\n    : undefined,\n  props.customCssProperties?.tableSearchWrapper,\n]);\nconst tableSearchAttrs = computed(() => ({\n  placeholder: props.tableSearchPlaceholder,\n  disabled: !displayUnfilteredTableData.value,\n  searchStyle: props.tableSearchStyle,\n  size: props.tableSearchSize,\n}));\n</script>\n\n<template>\n  <div class=\"pv-full-width\" :style=\"containerCssProps\" style=\"display: flex; flex-direction: column\">\n    <PvTooltipV2 v-if=\"devMode\" class=\"pv-flex\" style=\"width: 100%; --flex-justify: flex-end\">\n      <template #trigger>\n        <PvButton\n          left-icon=\"flask-conical\"\n          ariaLabel=\"Toggle dev mode\"\n          :variant=\"devModeEnabled ? 'primary' : 'secondary'\"\n          @click=\"devModeEnabled = !devModeEnabled\"\n        />\n      </template>\n      <template #content> Dev Mode </template>\n    </PvTooltipV2>\n    <div\n      class=\"pv-stack-16\"\n      v-show=\"\n        enableGroupBySelector ||\n        !filterTeleportLocation ||\n        (enableTableSearch && tableSearchInline) ||\n        inlineTopSlotEnabled\n      \"\n    >\n      <!-- One row: horizontal filters collapse as space runs out instead of pushing the trailing controls down. -->\n      <div class=\"pv-flex pv-space-between\">\n        <div class=\"pv-flex\" style=\"--flex-gap: 8px; flex: 1 1 0; min-width: 0\">\n          <div v-if=\"enableTableSearch && tableSearchInline\" :style=\"tableSearchWrapperStyle\">\n            <TableSearch v-bind=\"tableSearchAttrs\" />\n          </div>\n          <Teleport :to=\"filterTeleportLocation\" :disabled=\"!filterTeleportLocation\">\n            <FilterPanel\n              v-if=\"availableFilterColumns.length > 0 && !props.enableInlineFilters\"\n              ref=\"filterPanelRef\"\n              :enable-focus-view=\"enableFocusView\"\n              :enable-vertical-panel=\"enableVerticalFilterPanel\"\n              :display-preferences-icon=\"displayPreferencesIcon\"\n              :focusable-columns=\"focusableColumns\"\n              :focus-text=\"focusText\"\n              @handle-settings-icon=\"$emit('handle-settings-icon', $event)\"\n              :max-horizontal-filters=\"props.maxHorizontalFilters\"\n              :read-only=\"props.filterPanelReadOnly\"\n              :disable-unselected-filters=\"props.disableUnselectedReadOnlyFilters\"\n              :wrap-horizontal-filters=\"props.wrapHorizontalFilters\"\n            />\n          </Teleport>\n        </div>\n        <div\n          class=\"pv-flex\"\n          :style=\"[{ flexShrink: 0 }, inlineTopSlotEnabled ? { minHeight: inlineTopSlotControlHeight } : undefined]\"\n        >\n          <GroupBySelector\n            v-if=\"enableGroupBySelector && !(rowGroupLimit === 0)\"\n            :rowGroupLimit=\"rowGroupLimit\"\n            :enableFocusView=\"enableFocusView\"\n          />\n          <ExportMenu v-if=\"enableCsvExport\" :getCsvData=\"getCsvData\" />\n          <div v-if=\"inlineTopSlotEnabled\" :class=\"hideTable ? 'pv-hide' : ''\">\n            <slot name=\"top-slot\" />\n          </div>\n        </div>\n      </div>\n    </div>\n    <div\n      v-show=\"devModeEnabled && enableAdvancedFilter\"\n      ref=\"advancedFilterParentElement\"\n      class=\"pv-stack-8 pv-text-body-sm\"\n      :class=\"hideTable ? 'pv-hide' : ''\"\n    />\n    <div\n      v-if=\"!tableSearchInline && (enableTableSearch || topSlotEnabled)\"\n      class=\"pv-stack-8 pv-flex pv-space-between\"\n      :class=\"hideTable ? 'pv-hide' : ''\"\n    >\n      <div v-if=\"enableTableSearch && !tableSearchInline\" :style=\"tableSearchWrapperStyle\">\n        <TableSearch v-bind=\"tableSearchAttrs\" />\n      </div>\n      <slot v-if=\"topSlotEnabled\" name=\"top-slot\" />\n    </div>\n    <div\n      ref=\"gridWrapperRef\"\n      class=\"pv-relative pv-stack-8\"\n      :class=\"hideTable ? 'pv-hide' : ''\"\n      :style=\"gridWrapperStyle\"\n    >\n      <ag-grid-vue\n        ref=\"gridRef\"\n        :class=\"['pv-data-table', themeClass, { 'pv-data-table--pivot': pivotEnabled }]\"\n        :style=\"[\n          { width: '100%', height: layout === 'autoHeight' ? undefined : '100%' },\n          shrinkGridStyle,\n          pivotLoadingGridStyle,\n          pivotFrameStyle,\n          customCssProperties?.agGridWrapper,\n        ]\"\n        :domLayout=\"layout\"\n        v-bind=\"serverSideDataSource ? { serverSideDatasource: serverSideDataSource } : {}\"\n        @cell-value-changed=\"emit('cell-value-changed', $event)\"\n        @column-moved=\"handleColumnMoved\"\n        @column-row-group-changed=\"handleColumnRowGroupChanged\"\n        @column-value-changed=\"handleColumnValueChanged\"\n        @column-visible=\"handleColumnVisibleChanged\"\n        @filter-changed=\"handleFilterChanged\"\n        @filter-opened=\"emit('filter-opened', $event)\"\n        @first-data-rendered=\"handleFirstDataRendered\"\n        @grid-ready=\"handleGridReady\"\n        @pagination-changed=\"handlePaginationChanged\"\n        @redo-ended=\"emit('redo-ended', $event)\"\n        @redo-started=\"emit('redo-started', $event)\"\n        @row-data-updated=\"emit('row-data-updated', $event)\"\n        @rowClicked=\"handleRowClicked\"\n        @row-selected=\"emit('row-selected', $event)\"\n        @selection-changed=\"emit('selection-changed', $event)\"\n        @sort-changed=\"handleSortChanged\"\n        @undo-ended=\"emit('undo-ended', $event)\"\n        @undo-started=\"emit('undo-started', $event)\"\n        @pivot-max-columns-exceeded=\"emit('pivot-max-columns-exceeded', $event)\"\n        :aggFuncs=\"customAggFuncs\"\n        :autoGroupColumnDef=\"autoGroupColumnDef\"\n        :columnDefs=\"updatedColDefs\"\n        :debug=\"debugMode\"\n        :defaultColDef=\"defaultColDef\"\n        :fullWidthCellRenderer=\"resolvedFullWidthCellRenderer\"\n        :getChildCount=\"handleGetChildCount\"\n        :getContextMenuItems=\"getContextMenuItems\"\n        :getMainMenuItems=\"getMainMenuItems\"\n        :getRowClass=\"getRowClass\"\n        :getRowStyle=\"getRowStyle\"\n        :groupDefaultExpanded=\"computedGroupDefaultExpanded\"\n        :groupDisplayType=\"'singleColumn'\"\n        :initialState=\"cleanedInitialGridState || undefined\"\n        :isFullWidthRow=\"props.isFullWidthRow\"\n        :isGroupOpenByDefault=\"!serverSideDataSource ? props.isClientSideGroupOpenByDefault : undefined\"\n        :isServerSideGroupOpenByDefault=\"isServerSideGroupOpenByDefaultHandler\"\n        :includeHiddenColumnsInAdvancedFilter=\"true\"\n        :loading=\"!serverSideDataSource && !pivotEnabled ? isLoading : false\"\n        :loadingCellRenderer=\"resolvedLoadingCellRenderer\"\n        :loadingCellRendererParams=\"loadingCellRendererParams\"\n        :maxConcurrentDatasourceRequests=\"serverSideDataSource ? -1 : undefined\"\n        :maintainColumnOrder=\"maintainColumnOrder\"\n        :modules=\"modules\"\n        :popupParent=\"popupParentElement\"\n        :processCellForClipboard=\"processCellForClipboard\"\n        :processCellFromClipboard=\"processCellFromClipboard\"\n        :processDataFromClipboard=\"processDataFromClipboard\"\n        :pivotMode=\"pivotEnabled\"\n        :pivotMaxGeneratedColumns=\"pivotEnabled ? pivotMaxGeneratedColumns : undefined\"\n        :pivotGroupHeaderHeight=\"pivotEnabled ? PIVOT_GROUP_HEADER_HEIGHT : undefined\"\n        :processPivotResultColGroupDef=\"pivotEnabled ? handleProcessPivotResultColGroupDef : undefined\"\n        :processPivotResultColDef=\"pivotEnabled ? handleProcessPivotResultColDef : undefined\"\n        :alwaysPassFilter=\"pivotAlwaysPassFilter\"\n        :rowData=\"processedRowData\"\n        :rowHeight=\"rowHeight\"\n        :rowModelType=\"serverSideDataSource ? 'serverSide' : 'clientSide'\"\n        :rowSelection=\"rowSelection\"\n        :serverSideInitialRowCount=\"serverSideDataSource ? 1 : undefined\"\n        :showOpenedGroup=\"true\"\n        :suppressAggFuncInHeader=\"true\"\n        :suppressColumnMoveAnimation=\"true\"\n        :suppressDragLeaveHidesColumns=\"true\"\n        :serverSideSortAllLevels=\"false\"\n        :serverSideEnableClientSideSort=\"false\"\n        :theme=\"computedTheme\"\n        :pagination=\"pagination\"\n        :suppressPaginationPanel=\"true\"\n        :paginationPageSize=\"paginationPageSize\"\n        :suppressScrollOnNewData=\"true\"\n        :tooltip-show-delay=\"tooltipShowDelay\"\n        :tooltip-hide-delay=\"tooltipHideDelay\"\n        :cellSelection=\"cellSelection\"\n        :copyHeadersToClipboard=\"copyHeadersToClipboard\"\n        :suppressClipboardPaste=\"suppressClipboardPaste\"\n        :suppressCutToClipboard=\"suppressCutToClipboard\"\n        :undoRedoCellEditing=\"undoRedoCellEditing\"\n        :undoRedoCellEditingLimit=\"undoRedoCellEditingLimit\"\n        :enableAdvancedFilter=\"enableAdvancedFilter\"\n        :advancedFilterParent=\"advancedFilterParentElement\"\n      >\n      </ag-grid-vue>\n      <PivotTableSkeleton v-if=\"pivotLoading\" />\n      <div v-if=\"!isLoading && !displayUnfilteredTableData\" class=\"pv-table-overlay\">\n        <p class=\"pv-text-body-xs pv-text-center\" style=\"padding-top: 16px\">\n          {{ filterRestrictionMessage }}\n        </p>\n      </div>\n    </div>\n    <PaginationPanel v-if=\"pagination\" />\n  </div>\n</template>\n","<script setup lang=\"ts\">\nimport PvIcon from \"@/components/base/PvIcon/PvIcon.vue\";\n\ndefineOptions({\n  inheritAttrs: false,\n});\n\ninterface TableOverlayContext {\n  rightIcon?: string;\n}\n\ndefineProps<{\n  text: string;\n  disabled?: boolean;\n  context?: TableOverlayContext;\n}>();\n</script>\n\n<template>\n  <div class=\"pv-flex pv-full-width pv-space-between\" style=\"white-space: nowrap\">\n    <span class=\"pv-text-body-md\">{{ text }}</span>\n    <PvIcon v-if=\"context?.rightIcon\" :name=\"context.rightIcon\" class=\"pv-text-subdued\" />\n  </div>\n</template>\n","<script setup lang=\"ts\">\nimport PvIcon from \"@/components/base/PvIcon/PvIcon.vue\";\n\ndefineOptions({\n  inheritAttrs: false,\n});\n\ninterface TableOverlayContext {\n  rightIcon?: string;\n}\n\ndefineProps<{\n  text: string;\n  disabled?: boolean;\n  context?: TableOverlayContext;\n}>();\n</script>\n\n<template>\n  <div class=\"pv-flex pv-full-width pv-space-between\" style=\"white-space: nowrap\">\n    <span class=\"pv-text-body-md\">{{ text }}</span>\n    <PvIcon v-if=\"context?.rightIcon\" :name=\"context.rightIcon\" class=\"pv-text-subdued\" />\n  </div>\n</template>\n","<script setup lang=\"ts\">\nimport { computed, inject, ref, shallowRef, watch } from \"vue\";\nimport type { Column, GridApi } from \"ag-grid-community\";\nimport { isEqual } from \"es-toolkit\";\nimport PvSelectButtonTrigger from \"@/components/base/PvSelectButton/PvSelectButtonTrigger/PvSelectButtonTrigger.vue\";\nimport PvMenuItem from \"@/components/base/PvMenu/items/PvMenuItem.vue\";\nimport PvSortableList from \"@/components/base/PvSortableList/PvSortableList.vue\";\nimport PvTableOverlayMenuItemRenderer from \"./PvTableOverlayMenuItemRenderer.vue\";\nimport { MenuOption } from \"@/types\";\nimport { ColumnConfigurationChangeEvent, TableConfigOptions } from \"../types\";\nimport PvPopover from \"@/components/base/PvPopover/PvPopover.vue\";\nimport { PopoverRefElement, useMenuPosition } from \"@/components/base/PvMenu/useMenuPosition\";\nimport { mapEntityTypeToHeaderIcon } from \"@tables/PvDataTable/table-components/formatting\";\nimport { ColumnDisplayOrderKey, GridApiKey, GroupColumnCellValueColumnKey } from \"@tables/symbols\";\nimport { vOnClickOutside } from \"@vueuse/components\";\n\nconst props = defineProps<{\n  groupedModeEnabled: boolean;\n  tableConfigOptions?: TableConfigOptions;\n}>();\n\nconst emit = defineEmits<{\n  (e: \"toggle-group\", enableGrouping: boolean): void;\n  (e: \"table-overlay-change\", selectedIds: string[]): void;\n  (e: \"column-config-change\", event: ColumnConfigurationChangeEvent): void;\n}>();\n\nconst gridApi = inject(GridApiKey, shallowRef(null));\nconst columnDisplayOrder = inject(ColumnDisplayOrderKey, ref(null));\nconst groupColumnCellValueColumn = inject(GroupColumnCellValueColumnKey, ref(null));\n\nconst { popoverPositionStyle, updateRects, triggerRef, popoverRef } = useMenuPosition({\n  alignment: \"top\",\n  popoverCssProperties: {\n    maxWidth: \"300px\",\n    maxHeight: \"600px\",\n    transform: \"translateX(-100%)\",\n  },\n  useTeleport: true,\n});\n\nconst tableConfigOpen = ref(false);\nconst openDrawer = ref<\"overlay\" | \"columns\" | null>(null);\nconst nestedMenuPopoverRef = ref<PopoverRefElement | null>(null);\n\nwatch(nestedMenuPopoverRef, (newVal) => {\n  if (newVal) {\n    popoverRef.value = newVal;\n  }\n});\n\nconst tableOverlayMenuOptions = computed<MenuOption[]>(() =>\n  (props.tableConfigOptions?.tableOverlayOptions ?? []).map((opt) => ({\n    id: opt.field,\n    text: opt.title,\n    context: { rightIcon: opt.icon },\n  })),\n);\n\nconst hasOverlayOptions = computed(() => tableOverlayMenuOptions.value.length > 0);\n\nconst selectedTableOverlayFields = ref<string[]>(\n  (props.tableConfigOptions?.tableOverlayOptions ?? [])\n    .filter((opt) => opt.defaultSelected !== false)\n    .map((opt) => opt.field),\n);\n\nwatch(\n  selectedTableOverlayFields,\n  (newIds) => {\n    emit(\"table-overlay-change\", newIds);\n  },\n  { immediate: true },\n);\n\nconst closeTableConfig = () => {\n  tableConfigOpen.value = false;\n  openDrawer.value = null;\n};\n\nconst handleGroupToggleClick = () => {\n  emit(\"toggle-group\", !props.groupedModeEnabled);\n  closeTableConfig();\n};\n\nconst toggleTableConfig = () => {\n  tableConfigOpen.value = !tableConfigOpen.value;\n  openDrawer.value = null;\n};\n\nconst toggleDrawer = (drawer: \"overlay\" | \"columns\") => {\n  if (openDrawer.value === drawer) {\n    openDrawer.value = null;\n    return;\n  }\n  if (drawer === \"columns\") syncActiveColumnsFromGrid();\n  openDrawer.value = drawer;\n  triggerRef.value = document.getElementById(`table-config-${drawer}`);\n  updateRects();\n};\n\nconst groupColumnCellValueColId = computed(() => groupColumnCellValueColumn.value?.getColId() ?? null);\n\n// Columns are configurable unless locked out via context.visibilityState. The group cell-value\n// column's hide is internal grouped-mode presentation state managed by PvDataTable, so it is\n// excluded from configuration and from the emitted hiddenColIds.\nconst configurableColumns = computed<Column[]>(() =>\n  (columnDisplayOrder.value ?? []).filter(\n    (col) =>\n      col.getColDef().context?.visibilityState === undefined && col.getColId() !== groupColumnCellValueColId.value,\n  ),\n);\n\nconst showColumnConfiguration = computed(\n  () => !!props.tableConfigOptions?.enableColumnConfiguration && configurableColumns.value.length > 0,\n);\n\nconst showGroupToggle = computed(() => props.tableConfigOptions?.enableGroupTableToMatchChartToggle ?? true);\n\n// With the group toggle hidden every remaining item can be gated off (no overlays, columns\n// not yet available before grid-ready). Hide the trigger rather than opening an empty menu.\nconst hasMenuItems = computed(() => hasOverlayOptions.value || showColumnConfiguration.value || showGroupToggle.value);\n\nconst columnToMenuOption = (col: Column): MenuOption => {\n  const colDef = col.getColDef();\n  return {\n    id: col.getColId(),\n    text: colDef.headerName || col.getColId(),\n    icon: mapEntityTypeToHeaderIcon(colDef.context?.dataType || null) || \"circle-chevron-down\",\n  };\n};\n\nconst configurableColumnOptions = computed<MenuOption[]>(() => configurableColumns.value.map(columnToMenuOption));\n\n// Column visibility isn't reactive on columnDisplayOrder, so the active list is synced\n// from the grid when the drawer opens and after each apply.\nconst activeColumnOptions = ref<MenuOption[]>([]);\n\nconst syncActiveColumnsFromGrid = () => {\n  activeColumnOptions.value = configurableColumns.value.filter((col) => col.isVisible()).map(columnToMenuOption);\n};\n\n// Keep the active list in step with in-grid column moves (columnDisplayOrder refreshes on\n// every finished move, including header drags that happen while the drawer is open).\nwatch(configurableColumns, syncActiveColumnsFromGrid);\n\nconst readColumnConfigState = (api: GridApi) => {\n  const columns = api.getAllGridColumns();\n  return {\n    orderedColIds: columns.map((col) => col.getColId()),\n    hiddenColIds: columns\n      .filter((col) => !col.isVisible() && col.getColId() !== groupColumnCellValueColId.value)\n      .map((col) => col.getColId()),\n  };\n};\n\nconst handleColumnListUpdate = (next: MenuOption[]) => {\n  const api = gridApi.value;\n  if (!api) return;\n\n  const nextActiveIds = next.map((opt) => String(opt.id));\n  const previousActiveIds = activeColumnOptions.value.map((opt) => String(opt.id));\n  if (isEqual(nextActiveIds, previousActiveIds)) return;\n\n  const previousState = readColumnConfigState(api);\n\n  // Rebuild the full display order by refilling the slots occupied by configurable columns\n  // with the new active order followed by the hidden configurable columns, so\n  // non-configurable columns (pinned, row-number, auto-group) keep their positions.\n  const configurableIds = new Set(configurableColumns.value.map((col) => col.getColId()));\n  const activeIds = new Set(nextActiveIds);\n  const hiddenConfigurableIds = previousState.orderedColIds.filter(\n    (colId) => configurableIds.has(colId) && !activeIds.has(colId),\n  );\n  const hiddenIds = new Set(hiddenConfigurableIds);\n  const refill = [...nextActiveIds, ...hiddenConfigurableIds];\n  let slotIndex = 0;\n  const fullOrder = previousState.orderedColIds.map((colId) =>\n    configurableIds.has(colId) ? refill[slotIndex++] : colId,\n  );\n  // One applyColumnState carries both order and visibility (single grid refresh); colId-only\n  // entries leave non-configurable columns' visibility, pinning, width, and sort untouched.\n  api.applyColumnState({\n    state: fullOrder.map((colId) => (configurableIds.has(colId) ? { colId, hide: hiddenIds.has(colId) } : { colId })),\n    applyOrder: true,\n  });\n\n  syncActiveColumnsFromGrid();\n\n  emit(\"column-config-change\", {\n    ...readColumnConfigState(api),\n    previousOrderedColIds: previousState.orderedColIds,\n    previousHiddenColIds: previousState.hiddenColIds,\n  });\n};\n</script>\n\n<template>\n  <template v-if=\"hasMenuItems\">\n    <div\n      class=\"pv-relative\"\n      v-on-click-outside=\"[\n        closeTableConfig,\n        {\n          ignore: ['.pv-popover'],\n        },\n      ]\"\n    >\n      <PvSelectButtonTrigger\n        :open=\"tableConfigOpen\"\n        label=\"Table Configuration\"\n        icon=\"settings\"\n        @click=\"toggleTableConfig\"\n      />\n      <PvPopover\n        :class=\"{ 'pv-hide': !tableConfigOpen }\"\n        :css-custom-properties=\"{ minWidth: '240px', zIndex: 5 }\"\n        alignment=\"right\"\n        :isList=\"true\"\n      >\n        <div class=\"pv-border-bottom\">\n          <p class=\"pv-text-title-sm pv-inset-square-8\" style=\"padding-top: 4px; padding-bottom: 12px\">\n            Table Configuration\n          </p>\n        </div>\n        <ul role=\"list\" class=\"pv-relative\">\n          <li\n            v-if=\"hasOverlayOptions\"\n            id=\"table-config-overlay\"\n            :data-active=\"openDrawer === 'overlay' ? true : null\"\n            style=\"cursor: pointer\"\n          >\n            <PvMenuItem\n              :config=\"{ variant: 'icon' }\"\n              id=\"table-config-overlay-item\"\n              text=\"Table Overlay\"\n              icon=\"layers-2\"\n              :class-list=\"['pv-menu-nested', openDrawer === 'overlay' ? 'pv-menu-nested-active' : '']\"\n              @handle-selected=\"toggleDrawer('overlay')\"\n            />\n          </li>\n          <li\n            v-if=\"showColumnConfiguration\"\n            id=\"table-config-columns\"\n            :data-active=\"openDrawer === 'columns' ? true : null\"\n            style=\"cursor: pointer\"\n          >\n            <PvMenuItem\n              :config=\"{ variant: 'icon' }\"\n              id=\"table-config-columns-item\"\n              text=\"Columns\"\n              icon=\"columns-3\"\n              :class-list=\"['pv-menu-nested', openDrawer === 'columns' ? 'pv-menu-nested-active' : '']\"\n              @handle-selected=\"toggleDrawer('columns')\"\n            />\n          </li>\n          <li v-if=\"showGroupToggle\" style=\"cursor: pointer\">\n            <PvMenuItem\n              :config=\"{ variant: 'icon' }\"\n              id=\"table-config-group-toggle\"\n              class=\"pv-text-subdued\"\n              :text=\"!groupedModeEnabled ? 'Group Table to Match Chart' : 'Ungroup Table'\"\n              :icon=\"!groupedModeEnabled ? 'group' : 'ungroup'\"\n              @handle-selected=\"handleGroupToggleClick\"\n            />\n          </li>\n        </ul>\n      </PvPopover>\n    </div>\n    <PvPopover\n      ref=\"nestedMenuPopoverRef\"\n      :class=\"{ 'pv-hide': !(tableConfigOpen && openDrawer !== null) }\"\n      :css-custom-properties=\"{ width: 'auto', maxWidth: '260px', ...popoverPositionStyle }\"\n      :isList=\"openDrawer !== 'columns'\"\n    >\n      <ul v-if=\"openDrawer === 'overlay'\" role=\"list\">\n        <li v-for=\"option in tableOverlayMenuOptions\" :key=\"option.id\">\n          <PvMenuItem\n            :id=\"option.id\"\n            :config=\"{ variant: 'checkbox', renderer: PvTableOverlayMenuItemRenderer }\"\n            :text=\"option.text\"\n            :context=\"option.context\"\n            :selectedIds=\"selectedTableOverlayFields\"\n            @update:selectedIds=\"selectedTableOverlayFields = $event\"\n            :class-list=\"['pv-table-overlay-option']\"\n          />\n        </li>\n      </ul>\n      <div\n        v-else-if=\"openDrawer === 'columns'\"\n        class=\"pv-inset-square-8\"\n        role=\"dialog\"\n        aria-label=\"Column options\"\n        @keydown.esc.stop=\"openDrawer = null\"\n      >\n        <p class=\"pv-text-tertiary pv-text-body-sm pv-stack-4\" style=\"padding-left: 2px; padding-bottom: 6px\">\n          Currently Viewing\n        </p>\n        <PvSortableList\n          :modelValue=\"activeColumnOptions\"\n          :options=\"configurableColumnOptions\"\n          :showPlaceholders=\"false\"\n          @update:modelValue=\"handleColumnListUpdate\"\n        />\n      </div>\n    </PvPopover>\n  </template>\n</template>\n","<script setup lang=\"ts\">\nimport { computed, inject, ref, shallowRef, watch } from \"vue\";\nimport type { Column, GridApi } from \"ag-grid-community\";\nimport { isEqual } from \"es-toolkit\";\nimport PvSelectButtonTrigger from \"@/components/base/PvSelectButton/PvSelectButtonTrigger/PvSelectButtonTrigger.vue\";\nimport PvMenuItem from \"@/components/base/PvMenu/items/PvMenuItem.vue\";\nimport PvSortableList from \"@/components/base/PvSortableList/PvSortableList.vue\";\nimport PvTableOverlayMenuItemRenderer from \"./PvTableOverlayMenuItemRenderer.vue\";\nimport { MenuOption } from \"@/types\";\nimport { ColumnConfigurationChangeEvent, TableConfigOptions } from \"../types\";\nimport PvPopover from \"@/components/base/PvPopover/PvPopover.vue\";\nimport { PopoverRefElement, useMenuPosition } from \"@/components/base/PvMenu/useMenuPosition\";\nimport { mapEntityTypeToHeaderIcon } from \"@tables/PvDataTable/table-components/formatting\";\nimport { ColumnDisplayOrderKey, GridApiKey, GroupColumnCellValueColumnKey } from \"@tables/symbols\";\nimport { vOnClickOutside } from \"@vueuse/components\";\n\nconst props = defineProps<{\n  groupedModeEnabled: boolean;\n  tableConfigOptions?: TableConfigOptions;\n}>();\n\nconst emit = defineEmits<{\n  (e: \"toggle-group\", enableGrouping: boolean): void;\n  (e: \"table-overlay-change\", selectedIds: string[]): void;\n  (e: \"column-config-change\", event: ColumnConfigurationChangeEvent): void;\n}>();\n\nconst gridApi = inject(GridApiKey, shallowRef(null));\nconst columnDisplayOrder = inject(ColumnDisplayOrderKey, ref(null));\nconst groupColumnCellValueColumn = inject(GroupColumnCellValueColumnKey, ref(null));\n\nconst { popoverPositionStyle, updateRects, triggerRef, popoverRef } = useMenuPosition({\n  alignment: \"top\",\n  popoverCssProperties: {\n    maxWidth: \"300px\",\n    maxHeight: \"600px\",\n    transform: \"translateX(-100%)\",\n  },\n  useTeleport: true,\n});\n\nconst tableConfigOpen = ref(false);\nconst openDrawer = ref<\"overlay\" | \"columns\" | null>(null);\nconst nestedMenuPopoverRef = ref<PopoverRefElement | null>(null);\n\nwatch(nestedMenuPopoverRef, (newVal) => {\n  if (newVal) {\n    popoverRef.value = newVal;\n  }\n});\n\nconst tableOverlayMenuOptions = computed<MenuOption[]>(() =>\n  (props.tableConfigOptions?.tableOverlayOptions ?? []).map((opt) => ({\n    id: opt.field,\n    text: opt.title,\n    context: { rightIcon: opt.icon },\n  })),\n);\n\nconst hasOverlayOptions = computed(() => tableOverlayMenuOptions.value.length > 0);\n\nconst selectedTableOverlayFields = ref<string[]>(\n  (props.tableConfigOptions?.tableOverlayOptions ?? [])\n    .filter((opt) => opt.defaultSelected !== false)\n    .map((opt) => opt.field),\n);\n\nwatch(\n  selectedTableOverlayFields,\n  (newIds) => {\n    emit(\"table-overlay-change\", newIds);\n  },\n  { immediate: true },\n);\n\nconst closeTableConfig = () => {\n  tableConfigOpen.value = false;\n  openDrawer.value = null;\n};\n\nconst handleGroupToggleClick = () => {\n  emit(\"toggle-group\", !props.groupedModeEnabled);\n  closeTableConfig();\n};\n\nconst toggleTableConfig = () => {\n  tableConfigOpen.value = !tableConfigOpen.value;\n  openDrawer.value = null;\n};\n\nconst toggleDrawer = (drawer: \"overlay\" | \"columns\") => {\n  if (openDrawer.value === drawer) {\n    openDrawer.value = null;\n    return;\n  }\n  if (drawer === \"columns\") syncActiveColumnsFromGrid();\n  openDrawer.value = drawer;\n  triggerRef.value = document.getElementById(`table-config-${drawer}`);\n  updateRects();\n};\n\nconst groupColumnCellValueColId = computed(() => groupColumnCellValueColumn.value?.getColId() ?? null);\n\n// Columns are configurable unless locked out via context.visibilityState. The group cell-value\n// column's hide is internal grouped-mode presentation state managed by PvDataTable, so it is\n// excluded from configuration and from the emitted hiddenColIds.\nconst configurableColumns = computed<Column[]>(() =>\n  (columnDisplayOrder.value ?? []).filter(\n    (col) =>\n      col.getColDef().context?.visibilityState === undefined && col.getColId() !== groupColumnCellValueColId.value,\n  ),\n);\n\nconst showColumnConfiguration = computed(\n  () => !!props.tableConfigOptions?.enableColumnConfiguration && configurableColumns.value.length > 0,\n);\n\nconst showGroupToggle = computed(() => props.tableConfigOptions?.enableGroupTableToMatchChartToggle ?? true);\n\n// With the group toggle hidden every remaining item can be gated off (no overlays, columns\n// not yet available before grid-ready). Hide the trigger rather than opening an empty menu.\nconst hasMenuItems = computed(() => hasOverlayOptions.value || showColumnConfiguration.value || showGroupToggle.value);\n\nconst columnToMenuOption = (col: Column): MenuOption => {\n  const colDef = col.getColDef();\n  return {\n    id: col.getColId(),\n    text: colDef.headerName || col.getColId(),\n    icon: mapEntityTypeToHeaderIcon(colDef.context?.dataType || null) || \"circle-chevron-down\",\n  };\n};\n\nconst configurableColumnOptions = computed<MenuOption[]>(() => configurableColumns.value.map(columnToMenuOption));\n\n// Column visibility isn't reactive on columnDisplayOrder, so the active list is synced\n// from the grid when the drawer opens and after each apply.\nconst activeColumnOptions = ref<MenuOption[]>([]);\n\nconst syncActiveColumnsFromGrid = () => {\n  activeColumnOptions.value = configurableColumns.value.filter((col) => col.isVisible()).map(columnToMenuOption);\n};\n\n// Keep the active list in step with in-grid column moves (columnDisplayOrder refreshes on\n// every finished move, including header drags that happen while the drawer is open).\nwatch(configurableColumns, syncActiveColumnsFromGrid);\n\nconst readColumnConfigState = (api: GridApi) => {\n  const columns = api.getAllGridColumns();\n  return {\n    orderedColIds: columns.map((col) => col.getColId()),\n    hiddenColIds: columns\n      .filter((col) => !col.isVisible() && col.getColId() !== groupColumnCellValueColId.value)\n      .map((col) => col.getColId()),\n  };\n};\n\nconst handleColumnListUpdate = (next: MenuOption[]) => {\n  const api = gridApi.value;\n  if (!api) return;\n\n  const nextActiveIds = next.map((opt) => String(opt.id));\n  const previousActiveIds = activeColumnOptions.value.map((opt) => String(opt.id));\n  if (isEqual(nextActiveIds, previousActiveIds)) return;\n\n  const previousState = readColumnConfigState(api);\n\n  // Rebuild the full display order by refilling the slots occupied by configurable columns\n  // with the new active order followed by the hidden configurable columns, so\n  // non-configurable columns (pinned, row-number, auto-group) keep their positions.\n  const configurableIds = new Set(configurableColumns.value.map((col) => col.getColId()));\n  const activeIds = new Set(nextActiveIds);\n  const hiddenConfigurableIds = previousState.orderedColIds.filter(\n    (colId) => configurableIds.has(colId) && !activeIds.has(colId),\n  );\n  const hiddenIds = new Set(hiddenConfigurableIds);\n  const refill = [...nextActiveIds, ...hiddenConfigurableIds];\n  let slotIndex = 0;\n  const fullOrder = previousState.orderedColIds.map((colId) =>\n    configurableIds.has(colId) ? refill[slotIndex++] : colId,\n  );\n  // One applyColumnState carries both order and visibility (single grid refresh); colId-only\n  // entries leave non-configurable columns' visibility, pinning, width, and sort untouched.\n  api.applyColumnState({\n    state: fullOrder.map((colId) => (configurableIds.has(colId) ? { colId, hide: hiddenIds.has(colId) } : { colId })),\n    applyOrder: true,\n  });\n\n  syncActiveColumnsFromGrid();\n\n  emit(\"column-config-change\", {\n    ...readColumnConfigState(api),\n    previousOrderedColIds: previousState.orderedColIds,\n    previousHiddenColIds: previousState.hiddenColIds,\n  });\n};\n</script>\n\n<template>\n  <template v-if=\"hasMenuItems\">\n    <div\n      class=\"pv-relative\"\n      v-on-click-outside=\"[\n        closeTableConfig,\n        {\n          ignore: ['.pv-popover'],\n        },\n      ]\"\n    >\n      <PvSelectButtonTrigger\n        :open=\"tableConfigOpen\"\n        label=\"Table Configuration\"\n        icon=\"settings\"\n        @click=\"toggleTableConfig\"\n      />\n      <PvPopover\n        :class=\"{ 'pv-hide': !tableConfigOpen }\"\n        :css-custom-properties=\"{ minWidth: '240px', zIndex: 5 }\"\n        alignment=\"right\"\n        :isList=\"true\"\n      >\n        <div class=\"pv-border-bottom\">\n          <p class=\"pv-text-title-sm pv-inset-square-8\" style=\"padding-top: 4px; padding-bottom: 12px\">\n            Table Configuration\n          </p>\n        </div>\n        <ul role=\"list\" class=\"pv-relative\">\n          <li\n            v-if=\"hasOverlayOptions\"\n            id=\"table-config-overlay\"\n            :data-active=\"openDrawer === 'overlay' ? true : null\"\n            style=\"cursor: pointer\"\n          >\n            <PvMenuItem\n              :config=\"{ variant: 'icon' }\"\n              id=\"table-config-overlay-item\"\n              text=\"Table Overlay\"\n              icon=\"layers-2\"\n              :class-list=\"['pv-menu-nested', openDrawer === 'overlay' ? 'pv-menu-nested-active' : '']\"\n              @handle-selected=\"toggleDrawer('overlay')\"\n            />\n          </li>\n          <li\n            v-if=\"showColumnConfiguration\"\n            id=\"table-config-columns\"\n            :data-active=\"openDrawer === 'columns' ? true : null\"\n            style=\"cursor: pointer\"\n          >\n            <PvMenuItem\n              :config=\"{ variant: 'icon' }\"\n              id=\"table-config-columns-item\"\n              text=\"Columns\"\n              icon=\"columns-3\"\n              :class-list=\"['pv-menu-nested', openDrawer === 'columns' ? 'pv-menu-nested-active' : '']\"\n              @handle-selected=\"toggleDrawer('columns')\"\n            />\n          </li>\n          <li v-if=\"showGroupToggle\" style=\"cursor: pointer\">\n            <PvMenuItem\n              :config=\"{ variant: 'icon' }\"\n              id=\"table-config-group-toggle\"\n              class=\"pv-text-subdued\"\n              :text=\"!groupedModeEnabled ? 'Group Table to Match Chart' : 'Ungroup Table'\"\n              :icon=\"!groupedModeEnabled ? 'group' : 'ungroup'\"\n              @handle-selected=\"handleGroupToggleClick\"\n            />\n          </li>\n        </ul>\n      </PvPopover>\n    </div>\n    <PvPopover\n      ref=\"nestedMenuPopoverRef\"\n      :class=\"{ 'pv-hide': !(tableConfigOpen && openDrawer !== null) }\"\n      :css-custom-properties=\"{ width: 'auto', maxWidth: '260px', ...popoverPositionStyle }\"\n      :isList=\"openDrawer !== 'columns'\"\n    >\n      <ul v-if=\"openDrawer === 'overlay'\" role=\"list\">\n        <li v-for=\"option in tableOverlayMenuOptions\" :key=\"option.id\">\n          <PvMenuItem\n            :id=\"option.id\"\n            :config=\"{ variant: 'checkbox', renderer: PvTableOverlayMenuItemRenderer }\"\n            :text=\"option.text\"\n            :context=\"option.context\"\n            :selectedIds=\"selectedTableOverlayFields\"\n            @update:selectedIds=\"selectedTableOverlayFields = $event\"\n            :class-list=\"['pv-table-overlay-option']\"\n          />\n        </li>\n      </ul>\n      <div\n        v-else-if=\"openDrawer === 'columns'\"\n        class=\"pv-inset-square-8\"\n        role=\"dialog\"\n        aria-label=\"Column options\"\n        @keydown.esc.stop=\"openDrawer = null\"\n      >\n        <p class=\"pv-text-tertiary pv-text-body-sm pv-stack-4\" style=\"padding-left: 2px; padding-bottom: 6px\">\n          Currently Viewing\n        </p>\n        <PvSortableList\n          :modelValue=\"activeColumnOptions\"\n          :options=\"configurableColumnOptions\"\n          :showPlaceholders=\"false\"\n          @update:modelValue=\"handleColumnListUpdate\"\n        />\n      </div>\n    </PvPopover>\n  </template>\n</template>\n","<script setup lang=\"ts\">\nimport { PvIcon, PvTooltipV2 } from \"@/components/base\";\nimport PvSkeleton from \"@/components/base/PvSkeleton/PvSkeleton.vue\";\nimport type { ChipSection } from \"../types\";\n\ndefineProps<{\n  sections: ChipSection[];\n}>();\n\nconst emit = defineEmits<{\n  (e: \"chip-hover\", key: string | null): void;\n}>();\n</script>\n\n<template>\n  <div class=\"pv-chart-benchmark-chips pv-flex-vertical\">\n    <div\n      v-for=\"section in sections\"\n      :key=\"section.groupName\"\n      data-testid=\"chip-section\"\n      :data-group-name=\"section.groupName\"\n      class=\"pv-flex-vertical\"\n    >\n      <p class=\"pv-chart-chip-section-label pv-chart-benchmark-chip-section-label\">\n        {{ section.groupName }}\n      </p>\n      <div\n        v-for=\"chip in section.chips\"\n        :key=\"chip.key\"\n        data-testid=\"benchmark-chip\"\n        class=\"pv-chart-benchmark-chip pv-flex pv-bordered pv-inset-square-8\"\n        :data-loading=\"chip.loading || undefined\"\n        :style=\"{ '--radius': '4px', paddingLeft: chip.color ? '12px' : undefined }\"\n        v-on=\"\n          chip.loading || chip.excludeFromCrossline\n            ? {}\n            : { mouseenter: () => emit('chip-hover', chip.key), mouseleave: () => emit('chip-hover', null) }\n        \"\n      >\n        <template v-if=\"chip.loading\">\n          <PvSkeleton data-testid=\"benchmark-chip-skeleton\" size=\"sm\" width=\"60%\" />\n          <PvSkeleton data-testid=\"benchmark-chip-skeleton\" size=\"sm\" width=\"30%\" />\n        </template>\n        <template v-else>\n          <span\n            v-if=\"chip.color\"\n            data-testid=\"benchmark-chip-accent\"\n            class=\"pv-chart-benchmark-chip-accent\"\n            :style=\"{ backgroundColor: chip.color }\"\n          />\n          <span class=\"pv-chart-chip-label pv-flex-item\">\n            {{ chip.label }}\n          </span>\n          <span class=\"pv-chart-chip-value\">\n            {{ chip.formattedValue }}\n          </span>\n          <PvTooltipV2\n            v-if=\"chip.excludeFromCrossline\"\n            data-testid=\"benchmark-chip-unit-mismatch-tooltip\"\n            variant=\"dark\"\n            position=\"top-center\"\n            :useTeleport=\"true\"\n            :showOnHover=\"true\"\n            :disableInteractive=\"true\"\n            style=\"pointer-events: auto\"\n          >\n            <template #trigger>\n              <PvIcon :size=\"12\" name=\"info-circle\" class=\"pv-text-subdued\" />\n            </template>\n            <template #content>\n              <div style=\"max-width: 220px; white-space: normal; overflow-wrap: break-word\">\n                Shown in different units than the chart, so no line is drawn for this benchmark.\n              </div>\n            </template>\n          </PvTooltipV2>\n        </template>\n      </div>\n    </div>\n  </div>\n</template>\n","<script setup lang=\"ts\">\nimport { PvIcon, PvTooltipV2 } from \"@/components/base\";\nimport PvSkeleton from \"@/components/base/PvSkeleton/PvSkeleton.vue\";\nimport type { ChipSection } from \"../types\";\n\ndefineProps<{\n  sections: ChipSection[];\n}>();\n\nconst emit = defineEmits<{\n  (e: \"chip-hover\", key: string | null): void;\n}>();\n</script>\n\n<template>\n  <div class=\"pv-chart-benchmark-chips pv-flex-vertical\">\n    <div\n      v-for=\"section in sections\"\n      :key=\"section.groupName\"\n      data-testid=\"chip-section\"\n      :data-group-name=\"section.groupName\"\n      class=\"pv-flex-vertical\"\n    >\n      <p class=\"pv-chart-chip-section-label pv-chart-benchmark-chip-section-label\">\n        {{ section.groupName }}\n      </p>\n      <div\n        v-for=\"chip in section.chips\"\n        :key=\"chip.key\"\n        data-testid=\"benchmark-chip\"\n        class=\"pv-chart-benchmark-chip pv-flex pv-bordered pv-inset-square-8\"\n        :data-loading=\"chip.loading || undefined\"\n        :style=\"{ '--radius': '4px', paddingLeft: chip.color ? '12px' : undefined }\"\n        v-on=\"\n          chip.loading || chip.excludeFromCrossline\n            ? {}\n            : { mouseenter: () => emit('chip-hover', chip.key), mouseleave: () => emit('chip-hover', null) }\n        \"\n      >\n        <template v-if=\"chip.loading\">\n          <PvSkeleton data-testid=\"benchmark-chip-skeleton\" size=\"sm\" width=\"60%\" />\n          <PvSkeleton data-testid=\"benchmark-chip-skeleton\" size=\"sm\" width=\"30%\" />\n        </template>\n        <template v-else>\n          <span\n            v-if=\"chip.color\"\n            data-testid=\"benchmark-chip-accent\"\n            class=\"pv-chart-benchmark-chip-accent\"\n            :style=\"{ backgroundColor: chip.color }\"\n          />\n          <span class=\"pv-chart-chip-label pv-flex-item\">\n            {{ chip.label }}\n          </span>\n          <span class=\"pv-chart-chip-value\">\n            {{ chip.formattedValue }}\n          </span>\n          <PvTooltipV2\n            v-if=\"chip.excludeFromCrossline\"\n            data-testid=\"benchmark-chip-unit-mismatch-tooltip\"\n            variant=\"dark\"\n            position=\"top-center\"\n            :useTeleport=\"true\"\n            :showOnHover=\"true\"\n            :disableInteractive=\"true\"\n            style=\"pointer-events: auto\"\n          >\n            <template #trigger>\n              <PvIcon :size=\"12\" name=\"info-circle\" class=\"pv-text-subdued\" />\n            </template>\n            <template #content>\n              <div style=\"max-width: 220px; white-space: normal; overflow-wrap: break-word\">\n                Shown in different units than the chart, so no line is drawn for this benchmark.\n              </div>\n            </template>\n          </PvTooltipV2>\n        </template>\n      </div>\n    </div>\n  </div>\n</template>\n","import { ColDef } from \"ag-grid-community\";\nimport { colDefContext, isColDefNumericDataType } from \"@tables/PvDataTable/helpers\";\nimport { ColDefDataType } from \"@tables/PvDataTable/table-components/formatting\";\nimport { BUCKET_AGG_FUNC_NAME, MAP_REGION_FIELD } from \"./constants\";\n\n/** A column charts as a geographic region when it is named `state` or has the `location` data type. */\nexport const isMapRegionColDef = (colDef: ColDef): boolean => {\n  return colDef.field === MAP_REGION_FIELD || colDefContext(colDef).dataType === ColDefDataType.Location;\n};\n\n/** Keep only geographic region columns, so the map chart type forces a region x-axis. */\nconst filterRegionColumns = (columns: ColDef[]): ColDef[] => {\n  return columns.filter(isMapRegionColDef);\n};\n\n/**\n * Drop the row group (x-axis) fields that aren't valid under a chart type's x-axis\n * `filterColumns`. Used when switching chart families so a still-valid x-axis (e.g.\n * `state` moving into/out of the map type) is preserved instead of cleared. Returns\n * the input unchanged when the filter or the available columns aren't known yet, so\n * a valid initial selection isn't dropped before the grid is ready.\n */\nexport const retainValidXAxisFields = (\n  currentFields: string[],\n  availableColumns: ColDef[],\n  filterColumns: ((columns: ColDef[]) => ColDef[]) | undefined,\n): string[] => {\n  if (!filterColumns || availableColumns.length === 0) return currentFields;\n  const allowedFields = new Set(filterColumns(availableColumns).map((col) => col.field));\n  return currentFields.filter((field) => allowedFields.has(field));\n};\n\nexport interface ChartTypeConfig {\n  id: string;\n  text: string;\n  icon: string;\n\n  xAxis: {\n    selectMode: \"single\" | \"sortable\";\n    filterColumns?: (columns: ColDef[]) => ColDef[];\n    hideLabel?: boolean;\n  };\n  yAxis: {\n    hidden?: boolean;\n    defaultValue?: string;\n  };\n  secondaryYAxis: {\n    hidden?: boolean;\n  };\n  sort: {\n    enabled?: boolean;\n  };\n\n  agChartType: string;\n  seriesFamily: \"cartesian\" | \"pie\" | \"map\";\n  isHorizontal?: boolean;\n  rowGroupLimit: number;\n  supportsFocusView: boolean;\n  storeBeforeChange: boolean; // If true, remember chart type selections per grouping level and restore the remembered type when groupings change; if false, grouping changes tend to keep the current chart type instead.\n}\n\nconst filterNonNumericColumns = (columns: ColDef[]): ColDef[] => {\n  return columns.filter((col) => !isColDefNumericDataType(col));\n};\n\nconst filterNumericColumns = (columns: ColDef[]): ColDef[] => {\n  return columns.filter((col) => isColDefNumericDataType(col));\n};\n\nconst baseCartesianConfig: Omit<ChartTypeConfig, \"id\" | \"text\" | \"icon\" | \"agChartType\" | \"isHorizontal\"> = {\n  xAxis: {\n    selectMode: \"sortable\",\n    filterColumns: filterNonNumericColumns,\n  },\n  yAxis: {},\n  secondaryYAxis: {},\n  sort: {},\n  seriesFamily: \"cartesian\",\n  // rowGroupLimit is overridden by the component prop at runtime\n  rowGroupLimit: 2,\n  supportsFocusView: true,\n  storeBeforeChange: true,\n};\n\nconst chartTypeConfigs: ChartTypeConfig[] = [\n  {\n    ...baseCartesianConfig,\n    id: \"column\",\n    text: \"Column\",\n    icon: \"chart-column\",\n    agChartType: \"bar\",\n  },\n  {\n    ...baseCartesianConfig,\n    id: \"bar\",\n    text: \"Bar\",\n    icon: \"chart-bar\",\n    agChartType: \"bar\",\n    isHorizontal: true,\n  },\n  {\n    ...baseCartesianConfig,\n    id: \"line\",\n    text: \"Line\",\n    icon: \"chart-line\",\n    agChartType: \"line\",\n  },\n  {\n    ...baseCartesianConfig,\n    id: \"area\",\n    text: \"Area\",\n    icon: \"chart-area\",\n    agChartType: \"area\",\n  },\n  {\n    ...baseCartesianConfig,\n    id: \"column_stacked\",\n    text: \"Stacked Column\",\n    icon: \"chart-column-stacked\",\n    agChartType: \"bar\",\n  },\n  {\n    ...baseCartesianConfig,\n    id: \"bar_stacked\",\n    text: \"Stacked Bar\",\n    icon: \"chart-bar-stacked\",\n    agChartType: \"bar\",\n    isHorizontal: true,\n  },\n  {\n    ...baseCartesianConfig,\n    id: \"pie\",\n    text: \"Pie\",\n    icon: \"chart-pie\",\n    agChartType: \"pie\",\n    seriesFamily: \"pie\",\n    rowGroupLimit: 1,\n  },\n  {\n    id: \"histogram\",\n    text: \"Histogram\",\n    icon: \"chart-column\",\n    xAxis: {\n      selectMode: \"single\",\n      filterColumns: filterNumericColumns,\n      hideLabel: true,\n    },\n    yAxis: {\n      hidden: true,\n      defaultValue: BUCKET_AGG_FUNC_NAME,\n    },\n    secondaryYAxis: {\n      hidden: true,\n    },\n    sort: {},\n    agChartType: \"bar\",\n    seriesFamily: \"cartesian\",\n    rowGroupLimit: 1,\n    supportsFocusView: false,\n    storeBeforeChange: false,\n  },\n  {\n    id: \"map\",\n    text: \"Map\",\n    icon: \"map\",\n    xAxis: {\n      // Like the histogram (which forces a numeric x-axis), the map forces a\n      // region x-axis: selecting Map drops any non-region x-axis and the lone\n      // region column (e.g. State) is auto-selected so the map always renders.\n      selectMode: \"single\",\n      filterColumns: filterRegionColumns,\n      hideLabel: true,\n    },\n    yAxis: {},\n    secondaryYAxis: {\n      hidden: true,\n    },\n    sort: {},\n    agChartType: \"map-shape\",\n    seriesFamily: \"map\",\n    rowGroupLimit: 1,\n    supportsFocusView: false,\n    storeBeforeChange: false,\n  },\n];\n\nconst chartTypeConfigMap = new Map<string, ChartTypeConfig>(chartTypeConfigs.map((config) => [config.id, config]));\n\n// Default fallback is the column chart config\nconst defaultConfig = chartTypeConfigMap.get(\"column\")!;\n\nexport function getChartTypeConfig(id: string): ChartTypeConfig {\n  return chartTypeConfigMap.get(id) || defaultConfig;\n}\n","<script setup lang=\"ts\" generic=\"T\">\nimport PvSegmentedControl from \"@/components/base/PvSegmentedControl/PvSegmentedControl.vue\";\nimport { computed, ComputedRef, inject, Ref, ref, watch } from \"vue\";\nimport type { MenuOption, MenuOptionSelectedEvent, Option } from \"@/types\";\nimport type {\n  ChartConfigPanelType,\n  ChartFilter,\n  ChartSeriesAggFuncSelectedEvent,\n  OptionWithFormatterAndDataType,\n} from \"@charts/PvDataTableWithChart/types\";\nimport {\n  ActiveChartFilterOptionKey,\n  ActiveChartKey,\n  ActiveSeriesKey,\n  ActiveSecondarySeriesKey,\n  ActiveSecondarySeriesListKey,\n  ActiveSortKey,\n  ActiveCrosslineOverlayGroupsKey,\n  AvailableRowGroupColumnsKey,\n  AvailableSeriesKey,\n  AvailableSecondarySeriesKey,\n  AvailableCrosslineOverlayGroupsKey,\n  ChartTypeKey,\n  MetricOverlayMultiSelectKey,\n  RowGroupColumnsKey,\n  SortTypesKey,\n} from \"@/components/tables/symbols\";\nimport PvSelectButtonTrigger from \"@/components/base/PvSelectButton/PvSelectButtonTrigger/PvSelectButtonTrigger.vue\";\nimport PvPopover from \"@/components/base/PvPopover/PvPopover.vue\";\nimport PvMenu from \"@/components/base/PvMenu/PvMenu.vue\";\nimport PvMenuItem from \"@/components/base/PvMenu/items/PvMenuItem.vue\";\nimport PvSelectButton from \"@/components/base/PvSelectButton/PvSelectButton.vue\";\nimport PvMultiSelectButton from \"@/components/base/PvMultiSelectButton/PvMultiSelectButton.vue\";\nimport PvSortableList from \"@/components/base/PvSortableList/PvSortableList.vue\";\nimport type { LockedOption } from \"@/components/base/PvSortableList/types\";\nimport { useMenuPosition, type PopoverRefElement } from \"@/components/base/PvMenu/useMenuPosition\";\nimport { mapEntityTypeToHeaderIcon } from \"@tables/PvDataTable/table-components/formatting\";\nimport { getChartTypeConfig } from \"@charts/PvDataTableWithChart/chartTypeRegistry\";\nimport { isChronologicalColDef } from \"@charts/PvDataTableWithChart/helpers\";\nimport { vOnClickOutside } from \"@vueuse/components\";\nimport PvTooltipV2 from \"@/components/base/PvTooltipV2/PvTooltipV2.vue\";\nimport { addRumAction, deferRumTask, useRumContext } from \"@/functions/rum\";\n\nexport interface PvChartOptionsPanelProps {\n  enablePanel: boolean;\n  chartFilter?: ChartFilter;\n  rowGroupLimit?: number;\n  useCombinedButton?: boolean;\n  useNestedMenu?: boolean;\n  chartConfigOptions?: ChartConfigPanelType[];\n  /** Row-group columns pinned in the sortable X Axis list: locked options can't be removed or\n   *  reordered, and an entry's optional `tooltip` explains why (see PvSortableList's\n   *  lockedOptions). */\n  lockedRowGroupOptions?: LockedOption[];\n  /** Keep the Metric Overlay picker enabled when a secondary row group splits a non-stacked\n   *  chart into per-group series (see PvDataTableWithChart's metricOverlayWithRowGroups). */\n  metricOverlayWithRowGroups?: boolean;\n  /** When true, the panel's controls are visible but disabled (view-only). */\n  readOnly?: boolean;\n  /** Column field used for the \"% of focus\" chart view; its Y-axis option is disabled on line charts. */\n  percentOfFocusViewYKey?: string;\n}\n\nconst props = withDefaults(defineProps<PvChartOptionsPanelProps>(), {\n  useNestedMenu: false,\n});\n\ninterface ChartSeriesMenuOptionContext {\n  aggFunc?: string;\n  columnField?: string;\n  description?: string;\n  seriesValue?: string;\n}\n\nconst emit = defineEmits<{\n  (e: \"series-agg-func-selected\", event: ChartSeriesAggFuncSelectedEvent): void;\n}>();\n\nconst nestedMenuEnabled = computed(() => !!props.useCombinedButton && props.useNestedMenu);\n\nconst {\n  popoverPositionStyle: legacyPopoverPositionStyle,\n  updateRects: updateLegacyPopoverPosition,\n  triggerRef: legacyTriggerRef,\n  popoverRef: legacyPopoverRef,\n} = useMenuPosition({\n  alignment: \"top right\",\n  popoverCssProperties: {\n    maxWidth: \"500px\",\n    maxHeight: \"900px\",\n  },\n  useTeleport: true,\n});\n\n// refs to track drawer states\nconst configurationDrawerOpen = ref(false);\nconst nestedDrawerOpen: Ref<ChartConfigPanelType | undefined> = ref(undefined);\nconst legacyNestedMenuPopoverRef = ref<PopoverRefElement | null>(null);\n\n// chart type options\nconst activeChartType = inject(ActiveChartKey, ref(undefined));\nconst chartTypes = inject(ChartTypeKey, ref([]));\n\n// sort options\nconst activeSort = inject(ActiveSortKey, ref(undefined));\nconst sortTypes = inject(SortTypesKey, ref([]));\n\n// x axis options\nconst rowGroupColumns = inject(RowGroupColumnsKey, ref([]));\nconst availableRowGroupColumns = inject(AvailableRowGroupColumnsKey, ref([]));\n\nconst activeChartTypeConfig = computed(() => getChartTypeConfig(activeChartType.value?.id || \"\"));\n\nconst metricOverlayDisabled = computed(() => {\n  const id = activeChartType.value?.id ?? \"\";\n  return rowGroupColumns.value.length > 1 && !id.endsWith(\"_stacked\") && !props.metricOverlayWithRowGroups;\n});\n\n// y axis options\nconst activeSeries = inject(ActiveSeriesKey, ref(\"\"));\nconst availableSeries = inject(AvailableSeriesKey, ref([]));\nconst activeSecondarySeries = inject(ActiveSecondarySeriesKey, ref<string | undefined>(undefined));\nconst availableSecondarySeries = inject(AvailableSecondarySeriesKey, ref([]));\n// Multi-select metric overlay mode: selections live in a list; the picker renders checkboxes.\nconst metricOverlayMultiSelect = inject(MetricOverlayMultiSelectKey, ref(false));\nconst activeSecondarySeriesList = inject(ActiveSecondarySeriesListKey, ref<string[]>([]));\n\n// crossline overlay group options\nconst activeCrosslineOverlayGroups = inject(ActiveCrosslineOverlayGroupsKey, ref<Set<string>>(new Set()));\nconst availableCrosslineOverlayGroups = inject(AvailableCrosslineOverlayGroupsKey, ref([]));\n\n// ActiveCrosslineOverlayGroups shaped as MenuOption[] for PvMultiSelectButton's :modelValue.\nconst activeCrosslineOverlayOptions = computed<MenuOption[]>(() =>\n  availableCrosslineOverlayGroups.value\n    .filter((group) => activeCrosslineOverlayGroups.value.has(group.id))\n    .map((group) => ({\n      id: group.id,\n      text: group.label,\n      disabled: group.disabled,\n      description: group.disabledReason,\n    })),\n);\n\nconst setActiveCrosslineOverlaysFromOptions = (options: MenuOption[]) => {\n  activeCrosslineOverlayGroups.value = new Set(options.map((opt) => opt.id));\n};\n\nwatch(\n  metricOverlayDisabled,\n  (disabled) => {\n    if (disabled && activeSecondarySeries.value) {\n      activeSecondarySeries.value = undefined;\n    }\n    if (disabled && activeSecondarySeriesList.value.length > 0) {\n      activeSecondarySeriesList.value = [];\n    }\n  },\n  { immediate: true },\n);\n\n// chart filter options\nconst activeChartFilterOption = inject(ActiveChartFilterOptionKey, ref(\"\"));\n\nconst chartFilterOptions = computed(() => {\n  const chartFilterOptions: Option[] = [];\n  if (props.chartFilter && props.chartFilter.options) {\n    return props.chartFilter.options.map((option) => {\n      return {\n        label: option.label,\n        value: option.value,\n      };\n    });\n  }\n  return chartFilterOptions;\n});\n\n// A date x-axis is always plotted oldest to newest, so the sort control has\n// nothing left to choose - see `sortChartDataChronologically`.\nconst chronologicalXAxis = computed(() => {\n  const xAxisField = rowGroupColumns.value[0];\n  if (!xAxisField) return false;\n  return isChronologicalColDef(availableRowGroupColumns.value.find((col) => col.field === xAxisField));\n});\n\nconst isSortableChartType = computed(() => {\n  if (!activeChartType.value) return;\n  // if we have > 2 row groups, bar and column are grouped, and we don't want to enable sorting for them\n  const allowedTypes =\n    rowGroupColumns.value.length > 1\n      ? [\"bar_stacked\", \"line\", \"column_stacked\", \"area\"]\n      : [\"bar\", \"line\", \"column\", \"area\"];\n  return allowedTypes.includes(activeChartType.value?.id);\n});\n\nwatch(chartTypes, (newTypes) => {\n  if (!activeChartType.value) return;\n  // for stacked charts, reset to the base type if the current type is no longer available\n  const currentType = activeChartType.value;\n  const currentTypeIsStacked = currentType?.id.endsWith(\"_stacked\");\n  const matchedExistingType = newTypes.find((type) => type.id === currentType.id);\n  if (matchedExistingType) {\n    activeChartType.value = matchedExistingType;\n    return;\n  }\n  if (currentTypeIsStacked) {\n    const baseType = currentType?.id.replace(\"_stacked\", \"\");\n    const matchedBaseType = newTypes.find((type) => type.id === baseType);\n    if (matchedBaseType) {\n      activeChartType.value = matchedBaseType;\n      return;\n    }\n  }\n  // otherwise, set to the first available type\n  activeChartType.value = newTypes[0];\n});\n\ninterface ChartPanelOption {\n  value: string;\n  label: string;\n  prefixLabel?: string;\n  icon: string;\n  availableOptions?: MenuOption[];\n  currentOption?: MenuOption; // Used for single-select panels\n  activeOptionIds?: Set<string>; // Used for multi-select panels\n  updateSelectedOption?: (id: string) => void;\n  updateSelectedOptions?: (options: MenuOption[]) => void; // Updates for multi-select panels\n  disabled?: boolean;\n  disabledReason?: string;\n  allowDeselect?: boolean;\n\n  // for use with isSortableList, to track when the list order is updated and which options are active\n  isSortableList?: boolean;\n  activeOptions?: Ref<MenuOption[]>;\n  activeOptionLimit?: number;\n  lockedOptions?: LockedOption[];\n\n  // for use with isMultiSelect, to render a PvMultiSelectButton in the flat render path\n  isMultiSelect?: boolean;\n}\n\nconst findMenuOption = (options: MenuOption[], id: string): MenuOption | undefined => {\n  for (const option of options) {\n    if (option.id === id) return option;\n    const child = option.children ? findMenuOption(option.children, id) : undefined;\n    if (child) return child;\n  }\n  return undefined;\n};\n\nconst leafMenuOptions = (options: MenuOption[]): MenuOption[] =>\n  options.flatMap((option) => (option.children?.length ? leafMenuOptions(option.children) : option));\n\n// Datadog RUM action names for each chart-config panel selector. Hardcoded\n// because labels are 1:1 with the ChartConfigPanelType enum and don't vary\n// by consumer. Returning undefined for unknown values keeps the attribute\n// absent so Datadog falls back to its default text resolution.\nconst rumActionNameForPanelOption = (value: ChartConfigPanelType | undefined): string | undefined => {\n  switch (value) {\n    case \"y-axis\":\n      return \"Select Y Axis metric\";\n    case \"secondary-y-axis\":\n      return \"Select Metric Overlay\";\n    case \"x-axis\":\n      return \"Select X Axis dimension\";\n    case \"chart-type\":\n      return \"Select Chart Type\";\n    case \"sort\":\n      return \"Select Chart Sort\";\n    default:\n      return undefined;\n  }\n};\n\nconst rumContext = useRumContext();\n\n/**\n * Emit a `chart_option_selected` RUM custom action when a user picks a value\n * inside one of the chart-config sub-popovers (Y Axis, X Axis, Sort, etc.).\n * Mirrors the `filter_option_selected` schema so analysts can answer \"what\n * Y-Axis metrics do users actually pick?\" without inferring from the\n * `data-dd-action-name` trigger event.\n *\n * Fires only after a value is selected. Opening a parent popover does not\n * trigger this action.\n */\n// Map the internal panel id to a more user-facing label for the RUM event.\n// `secondary-y-axis` is internal jargon — the UI surfaces it as Metric Overlay.\nconst rumPanelName = (panel: ChartConfigPanelType): string => (panel === \"secondary-y-axis\" ? \"metric-overlay\" : panel);\n\nconst recordChartOptionSelected = (\n  panel: ChartConfigPanelType,\n  optionId: string | undefined,\n  action: \"select\" | \"deselect\" = \"select\",\n) => {\n  if (!optionId) return;\n  const panelOption = chartPanelOptions.value.find((o) => o.value === panel);\n  const selectedOption = panelOption?.availableOptions\n    ? findMenuOption(panelOption.availableOptions, optionId)\n    : undefined;\n  addRumAction(\n    \"chart_option_selected\",\n    {\n      panel: rumPanelName(panel),\n      selected_value: selectedOption?.text ?? optionId,\n      selected_value_id: optionId,\n      action,\n    },\n    rumContext(),\n  );\n};\n\n/** Flat-layout PvMultiSelectButton (crossline overlay groups). */\nconst handlePanelMultiSelectUpdate = (option: ChartPanelOption, selected: MenuOption[]) => {\n  // Copy before updating: updateSelectedOptions replaces the active-ids set.\n  const previousIds = new Set(option.activeOptionIds);\n  option.updateSelectedOptions?.(selected);\n  deferRumTask(() => {\n    for (const opt of selected) {\n      if (!previousIds.has(opt.id)) recordChartOptionSelected(option.value as ChartConfigPanelType, opt.id);\n    }\n  });\n};\n\n/** Flat-layout PvSelectButton (y-axis, x-axis, sort, chart type, overlay). */\nconst handlePanelSingleSelectUpdate = (option: ChartPanelOption, selected: MenuOption | undefined) => {\n  option.updateSelectedOption?.(selected?.id || \"\");\n  deferRumTask(() => recordChartOptionSelected(option.value as ChartConfigPanelType, selected?.id));\n};\n\n/** Apply a selection from the PvMenu rendered inside a combined-button panel. */\nconst handleCombinedMenuOptionSelected = (panel: ChartPanelOption, event: MenuOptionSelectedEvent) => {\n  const option = event.option;\n  if (panel.isMultiSelect) {\n    const previousIds = new Set(panel.activeOptionIds ?? []);\n    const nextIds = new Set(previousIds);\n    if (nextIds.has(option.id)) {\n      nextIds.delete(option.id);\n    } else {\n      nextIds.add(option.id);\n    }\n    panel.updateSelectedOptions?.(\n      leafMenuOptions(panel.availableOptions ?? []).filter((candidate) => nextIds.has(candidate.id)),\n    );\n    if (!previousIds.has(option.id)) {\n      deferRumTask(() => recordChartOptionSelected(panel.value as ChartConfigPanelType, option.id));\n    }\n    return;\n  }\n\n  panel.updateSelectedOption?.(option.id);\n  deferRumTask(() => recordChartOptionSelected(panel.value as ChartConfigPanelType, option.id));\n};\n\n/**\n * Combined-button nested drawer, sortable list (multi-dimension X axis on\n * cartesian charts). PvSortableList reports adds, removes, and drag reorders\n * as a whole new list — diff it into per-dimension select/deselect events,\n * plus a single \"reorder\" event when membership is unchanged but the order\n * moved (its selected_value carries the resulting dimension order, since a\n * drag can't be attributed to one item from a list diff).\n */\nconst handleNestedDrawerSortableListUpdate = (panel: ChartPanelOption, next: MenuOption[]) => {\n  const previous = panel.activeOptions?.value ?? [];\n  if (panel.activeOptions) panel.activeOptions.value = next;\n  deferRumTask(() => {\n    const previousIds = previous.map((option) => option.id);\n    const nextIds = next.map((option) => option.id);\n    const previousSet = new Set(previousIds);\n    const nextSet = new Set(nextIds);\n    for (const option of next) {\n      if (!previousSet.has(option.id)) {\n        recordChartOptionSelected(panel.value as ChartConfigPanelType, option.id, \"select\");\n      }\n    }\n    for (const option of previous) {\n      if (!nextSet.has(option.id)) {\n        recordChartOptionSelected(panel.value as ChartConfigPanelType, option.id, \"deselect\");\n      }\n    }\n    const membershipUnchanged = previousIds.length === nextIds.length && previousIds.every((id) => nextSet.has(id));\n    if (membershipUnchanged && previousIds.join(\" \") !== nextIds.join(\" \")) {\n      addRumAction(\n        \"chart_option_selected\",\n        {\n          panel: rumPanelName(panel.value as ChartConfigPanelType),\n          selected_value: next.map((option) => option.text).join(\", \"),\n          selected_value_id: nextIds.join(\",\"),\n          action: \"reorder\",\n        },\n        rumContext(),\n      );\n    }\n  });\n};\n\nconst seriesAggFuncOptionId = (columnField: string, aggFunc: string) =>\n  `chart-series-agg-func:${encodeURIComponent(columnField)}:${encodeURIComponent(aggFunc)}`;\n\nconst seriesAggFuncGroupOptionId = (aggFunc: string) => `chart-series-agg-func-group:${encodeURIComponent(aggFunc)}`;\n\n// The \"% of focus\" metric can't be plotted on line charts, so its Y-axis option\n// stays visible but is grayed out while a line chart type is active.\nconst percentOfFocusDisabledDescription = \"This metric isn’t available with the selected chart type.\";\n\nconst disabledPrimarySeriesValue = computed(() =>\n  activeChartType.value?.id === \"line\" ? props.percentOfFocusViewYKey : undefined,\n);\n\nconst seriesDisabledState = (\n  disabledSeriesValue: string | undefined,\n  seriesValue: string | undefined,\n  description?: string,\n) => {\n  const disabled = !!disabledSeriesValue && seriesValue === disabledSeriesValue;\n  return { disabled, description: disabled ? percentOfFocusDisabledDescription : description };\n};\n\nconst seriesMenuOptions = (\n  seriesOptions: OptionWithFormatterAndDataType[],\n  disabledSeriesValue?: string,\n): MenuOption[] => {\n  const menuOptions: MenuOption[] = [];\n  const aggFuncGroups = new Map<string, MenuOption>();\n  const aggFuncGroupOrders = new Map<string, number>();\n\n  for (const series of seriesOptions) {\n    const columnField = series.columnField;\n    if (!series.aggFuncOptions?.length || !columnField) {\n      const { disabled, description } = seriesDisabledState(disabledSeriesValue, series.value, series.description);\n      menuOptions.push({\n        id: series.value,\n        text: series.label,\n        disabled,\n        description,\n        config: { variant: \"icon\" as const },\n      });\n      continue;\n    }\n\n    for (const option of series.aggFuncOptions) {\n      let group = aggFuncGroups.get(option.aggFunc);\n      if (!group) {\n        group = {\n          id: seriesAggFuncGroupOptionId(option.aggFunc),\n          text: option.label,\n          description: option.description,\n          config: { variant: \"icon\" as const },\n          children: [],\n        };\n        aggFuncGroups.set(option.aggFunc, group);\n        menuOptions.push(group);\n      }\n      if (option.order !== undefined && !aggFuncGroupOrders.has(group.id)) {\n        aggFuncGroupOrders.set(group.id, option.order);\n      }\n      const { disabled, description } = seriesDisabledState(\n        disabledSeriesValue,\n        option.seriesValue ?? series.value,\n        series.description,\n      );\n      group.children?.push({\n        id: seriesAggFuncOptionId(columnField, option.aggFunc),\n        text: series.label,\n        disabled,\n        description,\n        context: {\n          aggFunc: option.aggFunc,\n          columnField,\n          description,\n          seriesValue: option.seriesValue,\n        } satisfies ChartSeriesMenuOptionContext,\n        config: { variant: \"icon\" as const },\n      });\n    }\n  }\n\n  return menuOptions.sort((left, right) => {\n    const leftOrder = aggFuncGroupOrders.get(left.id);\n    const rightOrder = aggFuncGroupOrders.get(right.id);\n    if (leftOrder === undefined) return rightOrder === undefined ? 0 : 1;\n    if (rightOrder === undefined) return -1;\n    return leftOrder - rightOrder;\n  });\n};\n\nconst flatSeriesMenuOptions = (\n  seriesOptions: OptionWithFormatterAndDataType[],\n  disabledSeriesValue?: string,\n): MenuOption[] =>\n  seriesOptions.map((series) => {\n    const { disabled, description } = seriesDisabledState(disabledSeriesValue, series.value, series.description);\n    return {\n      id: series.value,\n      text: series.label,\n      disabled,\n      description,\n    };\n  });\n\nconst activeSeriesMenuOption = (\n  menuOptions: MenuOption[],\n  seriesOptions: OptionWithFormatterAndDataType[],\n  activeValue: string | undefined,\n): MenuOption | undefined => {\n  if (!activeValue) return undefined;\n  const series = seriesOptions.find(\n    (option) =>\n      option.value === activeValue || option.aggFuncOptions?.some((aggFunc) => aggFunc.seriesValue === activeValue),\n  );\n  if (!series?.aggFuncOptions?.length || !series.columnField) return findMenuOption(menuOptions, activeValue);\n  const activeAggFunc =\n    series.aggFuncOptions.find((option) => option.aggFunc === series.activeAggFunc) ??\n    series.aggFuncOptions.find((option) => option.seriesValue === activeValue) ??\n    series.aggFuncOptions[0];\n  return activeAggFunc\n    ? findMenuOption(menuOptions, seriesAggFuncOptionId(series.columnField, activeAggFunc.aggFunc))\n    : undefined;\n};\n\nconst selectedSeriesMenuOption = (menuOptions: MenuOption[], id: string) => {\n  const option = findMenuOption(menuOptions, id);\n  const context = option?.context as ChartSeriesMenuOptionContext | undefined;\n  return {\n    aggFunc: context?.aggFunc,\n    columnField: context?.columnField,\n    seriesValue: context?.seriesValue ?? option?.id,\n  };\n};\n\nconst seriesSelectionCount = (seriesOptions: OptionWithFormatterAndDataType[]) =>\n  seriesOptions.reduce((count, series) => count + (series.aggFuncOptions?.length || 1), 0);\n\n// Multi-select metric overlay: the active series values shaped as menu options / option ids\n// for the checkbox picker, and the reverse mapping back onto the active list.\nconst activeSecondaryMenuOptions = computed<MenuOption[]>(() =>\n  activeSecondarySeriesList.value\n    .map((value) =>\n      activeSeriesMenuOption(availableSecondarySeriesMenuOptions.value, availableSecondarySeries.value, value),\n    )\n    .filter((option): option is MenuOption => option !== undefined),\n);\n\nconst activeSecondaryMenuOptionIds = computed<Set<string>>(\n  () => new Set(activeSecondaryMenuOptions.value.map((option) => option.id)),\n);\n\nconst setActiveSecondaryListFromOptions = (options: MenuOption[]) => {\n  const seenColumns = new Set<string>();\n  const values: string[] = [];\n  for (const option of options) {\n    const selection = selectedSeriesMenuOption(availableSecondarySeriesMenuOptions.value, option.id);\n    if (!selection.seriesValue) continue;\n    // Agg-func menus expose one entry per (column, aggFunc); a column can only be charted\n    // once, so keep the first selection per column.\n    const columnKey = selection.columnField ?? selection.seriesValue;\n    if (seenColumns.has(columnKey)) continue;\n    seenColumns.add(columnKey);\n    values.push(selection.seriesValue);\n    if (selection.aggFunc && selection.columnField) {\n      emit(\"series-agg-func-selected\", {\n        aggFunc: selection.aggFunc,\n        columnField: selection.columnField,\n      });\n    }\n  }\n  activeSecondarySeriesList.value = values;\n};\n\nconst availableSeriesMenuOptions = computed(() =>\n  nestedMenuEnabled.value\n    ? seriesMenuOptions(availableSeries.value, disabledPrimarySeriesValue.value)\n    : flatSeriesMenuOptions(availableSeries.value, disabledPrimarySeriesValue.value),\n);\n\nconst availableSecondarySeriesMenuOptions = computed(() =>\n  nestedMenuEnabled.value\n    ? seriesMenuOptions(availableSecondarySeries.value)\n    : flatSeriesMenuOptions(availableSecondarySeries.value),\n);\n\nconst availableSeriesSelectionCount = computed(() =>\n  nestedMenuEnabled.value ? seriesSelectionCount(availableSeries.value) : availableSeries.value.length,\n);\n\nconst availableRowGroupMenuOptions = computed(() => {\n  return availableRowGroupColumns.value.map((col) => ({\n    id: col.field || \"\",\n    text: col.headerName || col.field || \"\",\n    icon: mapEntityTypeToHeaderIcon(col.context?.dataType || null) || \"circle-chevron-down\",\n  }));\n});\n\nconst activeRowGroupMenuOptions = computed({\n  get: () =>\n    rowGroupColumns.value\n      .map((col) => availableRowGroupMenuOptions.value.find((opt) => opt.id === col))\n      .filter(Boolean) as MenuOption[],\n  set: (newOptions: MenuOption[]) => {\n    rowGroupColumns.value = newOptions.map((opt) => opt.id);\n  },\n});\n\nconst chartPanelOptions: ComputedRef<ChartPanelOption[]> = computed(() => {\n  const supportedOptions: ChartPanelOption[] = [];\n  const yAxisConfigOption = {\n    value: \"y-axis\",\n    label: \"Y Axis\",\n    prefixLabel: \"Y Axis\",\n    icon: \"chart-bar-decreasing\",\n    allowDeselect: false,\n    availableOptions: availableSeriesMenuOptions.value,\n    currentOption: activeSeriesMenuOption(availableSeriesMenuOptions.value, availableSeries.value, activeSeries.value),\n    updateSelectedOption: (id: string) => {\n      const selection = selectedSeriesMenuOption(availableSeriesMenuOptions.value, id);\n      if (!selection.seriesValue) return;\n      activeSeries.value = selection.seriesValue;\n      if (selection.aggFunc && selection.columnField) {\n        emit(\"series-agg-func-selected\", {\n          aggFunc: selection.aggFunc,\n          columnField: selection.columnField,\n        });\n      }\n    },\n  };\n\n  const config = activeChartTypeConfig.value;\n  const isSortableXAxis = config.xAxis.selectMode === \"sortable\";\n\n  const xAxisConfigOption: ChartPanelOption = {\n    isSortableList: isSortableXAxis,\n    value: \"x-axis\",\n    label: \"X Axis\",\n    icon: \"align-end-horizontal\",\n    allowDeselect: false,\n    availableOptions: availableRowGroupMenuOptions.value,\n    ...(isSortableXAxis\n      ? {\n          activeOptions: activeRowGroupMenuOptions,\n          activeOptionLimit: props.rowGroupLimit,\n          lockedOptions: props.lockedRowGroupOptions,\n        }\n      : {\n          currentOption: availableRowGroupMenuOptions.value.find((option) => option.id === rowGroupColumns.value[0]),\n          updateSelectedOption: (id: string) => {\n            rowGroupColumns.value = id ? [id] : [];\n          },\n        }),\n  };\n\n  const sortConfigOption = {\n    value: \"sort\",\n    label: \"Sort\",\n    icon: \"arrow-up-wide-narrow\",\n    allowDeselect: true,\n    availableOptions: sortTypes.value,\n    currentOption: sortTypes.value.find((sort) => sort.id === activeSort.value?.id),\n    disabled: chronologicalXAxis.value || !isSortableChartType.value,\n    disabledReason: chronologicalXAxis.value\n      ? \"Dates are always sorted oldest to newest\"\n      : \"Sorting is not available for this chart type\",\n    updateSelectedOption: (id: string) => {\n      const selectedSort = sortTypes.value.find((sort) => sort.id === id);\n      // if the same sort is selected, clear the sort\n      if (!selectedSort || !activeSort) {\n        activeSort.value = undefined;\n        return;\n      }\n      if (activeSort.value?.id === selectedSort.id) {\n        activeSort.value = undefined;\n      } else {\n        activeSort.value = selectedSort;\n      }\n    },\n  };\n\n  const chartTypeConfigOption = {\n    value: \"chart-type\",\n    label: \"Chart Type\",\n    icon: \"chart-column-stacked\",\n    allowDeselect: false,\n    availableOptions: chartTypes.value,\n    currentOption: chartTypes.value.find((type) => type.id === activeChartType.value?.id),\n    updateSelectedOption: (id: string) => {\n      const selectedType = chartTypes.value.find((type) => type.id === id);\n      if (selectedType && activeChartType) {\n        activeChartType.value = selectedType;\n      }\n    },\n  };\n  // add options if they are applicable\n  if (availableSeriesSelectionCount.value > 1) {\n    supportedOptions.push(yAxisConfigOption);\n  }\n  // \"Metric Overlay\" should show secondary series options if the secondary y-axis is NOT hidden and\n  // should show the crossline overlay groups if it is hidden.\n  if (!config.secondaryYAxis?.hidden && availableSecondarySeriesMenuOptions.value.length > 0) {\n    const metricOverlayOption = metricOverlayMultiSelect.value\n      ? {\n          value: \"secondary-y-axis\",\n          label: \"Metric Overlay\",\n          prefixLabel: \"Metric Overlay\",\n          icon: \"chart-line\",\n          allowDeselect: true,\n          isMultiSelect: true,\n          disabled: metricOverlayDisabled.value,\n          disabledReason: \"Metric overlay is not available for this chart type.\",\n          availableOptions: availableSecondarySeriesMenuOptions.value,\n          activeOptionIds: activeSecondaryMenuOptionIds.value,\n          activeOptions: activeSecondaryMenuOptions,\n          updateSelectedOptions: setActiveSecondaryListFromOptions,\n        }\n      : {\n          value: \"secondary-y-axis\",\n          label: \"Metric Overlay\",\n          prefixLabel: \"Metric Overlay\",\n          icon: \"chart-line\",\n          allowDeselect: true,\n          disabled: metricOverlayDisabled.value,\n          disabledReason: \"Metric overlay is not available for this chart type.\",\n          availableOptions: availableSecondarySeriesMenuOptions.value,\n          currentOption: activeSeriesMenuOption(\n            availableSecondarySeriesMenuOptions.value,\n            availableSecondarySeries.value,\n            activeSecondarySeries.value,\n          ),\n          updateSelectedOption: (id: string) => {\n            if (!activeSecondarySeries) return;\n            const currentOption = activeSeriesMenuOption(\n              availableSecondarySeriesMenuOptions.value,\n              availableSecondarySeries.value,\n              activeSecondarySeries.value,\n            );\n            if (!id || currentOption?.id === id) {\n              activeSecondarySeries.value = undefined;\n              return;\n            }\n            const selection = selectedSeriesMenuOption(availableSecondarySeriesMenuOptions.value, id);\n            activeSecondarySeries.value = selection.seriesValue;\n            if (selection.aggFunc && selection.columnField) {\n              emit(\"series-agg-func-selected\", {\n                aggFunc: selection.aggFunc,\n                columnField: selection.columnField,\n              });\n            }\n          },\n        };\n    if (metricOverlayOption) {\n      supportedOptions.push(metricOverlayOption);\n    }\n  } else if (availableCrosslineOverlayGroups.value.length > 0) {\n    const overlayGroupMenuOptions = availableCrosslineOverlayGroups.value.map((group) => ({\n      id: group.id,\n      text: group.label,\n      disabled: group.disabled,\n      description: group.disabledReason,\n    }));\n    const metricOverlayOption = {\n      value: \"secondary-y-axis\",\n      label: \"Metric Overlay\",\n      prefixLabel: \"Metric Overlay\",\n      icon: \"chart-line\",\n      allowDeselect: true,\n      isMultiSelect: true,\n      availableOptions: overlayGroupMenuOptions,\n      activeOptionIds: activeCrosslineOverlayGroups.value,\n      activeOptions: activeCrosslineOverlayOptions,\n      currentOption: overlayGroupMenuOptions.find((opt) => activeCrosslineOverlayGroups.value.has(opt.id)),\n      updateSelectedOptions: setActiveCrosslineOverlaysFromOptions,\n    };\n    if (metricOverlayOption) {\n      supportedOptions.push(metricOverlayOption);\n    }\n  }\n  const minXAxisOptions = isSortableXAxis ? 2 : 1;\n  if (availableRowGroupMenuOptions.value.length >= minXAxisOptions) {\n    supportedOptions.push(xAxisConfigOption);\n  }\n  if (chartTypes.value.length > 1) {\n    supportedOptions.push(chartTypeConfigOption);\n  }\n  if (sortTypes.value.length > 0) {\n    supportedOptions.push(sortConfigOption);\n  }\n  // filter out options if they are not in chartConfigPanelOptions\n  return supportedOptions.filter((option) => {\n    if (props.chartConfigOptions) {\n      return props.chartConfigOptions.includes(option.value as ChartConfigPanelType);\n    }\n    return true;\n  });\n});\n\nconst nestedDrawerPanelOption = computed(() => {\n  if (!nestedDrawerOpen.value) return null;\n  return chartPanelOptions.value.find((option) => option.value === nestedDrawerOpen.value) || null;\n});\n\nconst panelSelectedOptions = (panel: ChartPanelOption): MenuOption[] => {\n  if (panel.activeOptions) return panel.activeOptions.value;\n  return panel.currentOption ? [panel.currentOption] : [];\n};\n\nconst panelSelectionSummary = (panel: ChartPanelOption): string | undefined => {\n  const text = panelSelectedOptions(panel)\n    .map((option) => option.text)\n    .join(\", \");\n  return text || undefined;\n};\n\nconst chartPanelMenuOptions = computed<MenuOption[]>(() =>\n  chartPanelOptions.value.map((panel) => ({\n    id: panel.value,\n    text: panel.label,\n    subText: panelSelectionSummary(panel),\n    icon: panel.icon,\n    disabled: panel.disabled,\n    hoverTitle: panel.disabledReason,\n    rumActionName: rumActionNameForPanelOption(panel.value as ChartConfigPanelType),\n    popoverRole: panel.isSortableList ? \"dialog\" : \"menu\",\n    children: panel.availableOptions,\n    config: {\n      variant: \"icon\",\n      ...(panel.disabled && panel.disabledReason\n        ? {\n            action: {\n              icon: \"info-circle\",\n              tooltipText: panel.disabledReason,\n              interactive: false,\n              alwaysShow: true,\n            },\n          }\n        : {}),\n    },\n  })),\n);\n\nconst combinedPanelMenuConfig = (panel: ChartPanelOption) =>\n  panel.isMultiSelect ? { variant: \"checkbox\" as const } : { variant: \"icon\" as const };\n\nwatch(legacyNestedMenuPopoverRef, (popover) => {\n  if (popover) legacyPopoverRef.value = popover;\n});\n\nconst handleLegacySelectedIdsUpdate = (ids: string[]) => {\n  const panel = nestedDrawerPanelOption.value;\n  if (!panel?.isMultiSelect) return;\n  const previousIds = new Set(panel.activeOptionIds ?? []);\n  panel.updateSelectedOptions?.((panel.availableOptions ?? []).filter((option) => ids.includes(option.id)));\n  deferRumTask(() => {\n    for (const id of ids) {\n      if (!previousIds.has(id)) recordChartOptionSelected(panel.value as ChartConfigPanelType, id);\n    }\n  });\n};\n\nconst handleLegacyOptionSelected = (option: MenuOption) => {\n  const panel = nestedDrawerPanelOption.value;\n  if (!panel || panel.isMultiSelect) return;\n  panel.updateSelectedOption?.(option.id);\n  deferRumTask(() => recordChartOptionSelected(panel.value as ChartConfigPanelType, option.id));\n};\n\nconst legacyOptionActive = (option: MenuOption): true | null => {\n  const panel = nestedDrawerPanelOption.value;\n  if (!panel || panel.isMultiSelect) return null;\n  return panel.currentOption?.id === option.id ? true : null;\n};\n\nconst legacyMenuItemConfig = () => {\n  if (nestedDrawerPanelOption.value?.isMultiSelect) {\n    return { variant: \"checkbox\" as const };\n  }\n  return { variant: \"icon\" as const };\n};\n\nconst openLegacyNestedDrawer = (drawer: ChartConfigPanelType) => {\n  nestedDrawerOpen.value = drawer;\n  legacyTriggerRef.value = document.getElementById(`pv-chart-config-${drawer}`);\n  updateLegacyPopoverPosition();\n};\n\nconst closeDropdown = () => {\n  configurationDrawerOpen.value = false;\n  nestedDrawerOpen.value = undefined;\n};\n\nconst handleNestedDrawerClose = () => {\n  nestedDrawerOpen.value = undefined;\n};\n</script>\n\n<template>\n  <div class=\"pv-stack-16 pv-chart-options-panel\">\n    <div>\n      <div\n        class=\"pv-flex pv-space-between\"\n        :class=\"useCombinedButton ? 'pv-stack-8' : ''\"\n        v-on-click-outside=\"[\n          closeDropdown,\n          {\n            ignore: ['.pv-popover'],\n          },\n        ]\"\n      >\n        <div class=\"pv-flex pv-relative\">\n          <template v-if=\"useCombinedButton\">\n            <PvSelectButtonTrigger\n              :open=\"configurationDrawerOpen\"\n              label=\"Chart Configuration\"\n              icon=\"chart-area\"\n              data-dd-action-name=\"Toggle Chart Configuration panel\"\n              :disabled=\"readOnly\"\n              @click=\"readOnly ? null : (configurationDrawerOpen = !configurationDrawerOpen)\"\n              @handle-toggle-dropdown=\"handleNestedDrawerClose\"\n            />\n            <template v-if=\"nestedMenuEnabled\">\n              <PvPopover\n                :class=\"{ 'pv-hide': !configurationDrawerOpen }\"\n                :css-custom-properties=\"{ width: '220px', maxWidth: '260px', zIndex: 5 }\"\n              >\n                <div class=\"pv-border-bottom pv-inset-squish-12\">\n                  <p class=\"pv-text-title-sm\">Chart Configuration</p>\n                </div>\n                <PvMenu\n                  v-model:expandedOptionId=\"nestedDrawerOpen\"\n                  :options=\"chartPanelMenuOptions\"\n                  childrenDisplay=\"popover\"\n                  :readOnly=\"readOnly\"\n                >\n                  <template #popover=\"{ popoverId, close }\">\n                    <div\n                      v-if=\"nestedDrawerPanelOption?.isSortableList\"\n                      :id=\"popoverId\"\n                      :aria-label=\"`${nestedDrawerPanelOption.label} options`\"\n                      class=\"pv-chart-config-popover pv-inset-square-8\"\n                      role=\"dialog\"\n                      @keydown.esc.stop=\"close\"\n                    >\n                      <p\n                        class=\"pv-text-tertiary pv-text-body-sm pv-stack-4\"\n                        style=\"padding-left: 2px; padding-bottom: 6px\"\n                      >\n                        Viewing\n                      </p>\n                      <PvSortableList\n                        :modelValue=\"nestedDrawerPanelOption.activeOptions!.value\"\n                        @update:modelValue=\"handleNestedDrawerSortableListUpdate(nestedDrawerPanelOption, $event)\"\n                        :options=\"nestedDrawerPanelOption.availableOptions || []\"\n                        :activeOptionLimit=\"nestedDrawerPanelOption.activeOptionLimit\"\n                        :lockedOptions=\"nestedDrawerPanelOption.lockedOptions\"\n                        placeholderText=\"Add to X Axis\"\n                      />\n                    </div>\n                    <PvMenu\n                      v-else-if=\"nestedDrawerPanelOption\"\n                      :id=\"popoverId\"\n                      :aria-label=\"`${nestedDrawerPanelOption.label} options`\"\n                      class=\"pv-chart-config-popover\"\n                      :options=\"nestedDrawerPanelOption.availableOptions || []\"\n                      :selectedItems=\"panelSelectedOptions(nestedDrawerPanelOption)\"\n                      :config=\"combinedPanelMenuConfig(nestedDrawerPanelOption)\"\n                      :singleSelect=\"!nestedDrawerPanelOption.isMultiSelect\"\n                      :disableDeselect=\"!nestedDrawerPanelOption.allowDeselect\"\n                      :highlightParentItems=\"false\"\n                      :readOnly=\"readOnly\"\n                      childrenDisplay=\"popover\"\n                      itemClass=\"pv-chart-option pv-flex\"\n                      @keydown.esc.stop=\"close\"\n                      @handle-selected=\"handleCombinedMenuOptionSelected(nestedDrawerPanelOption, $event)\"\n                    />\n                  </template>\n                </PvMenu>\n              </PvPopover>\n            </template>\n            <PvPopover\n              v-else\n              :class=\"{ 'pv-hide': !configurationDrawerOpen }\"\n              :css-custom-properties=\"{ width: '171px', maxWidth: '260px', zIndex: 5 }\"\n            >\n              <div class=\"pv-border-bottom pv-inset-squish-12\">\n                <p class=\"pv-text-title-sm\">Chart Configuration</p>\n              </div>\n              <ul role=\"list\" class=\"pv-popover-list pv-relative\">\n                <li\n                  v-for=\"option in chartPanelOptions\"\n                  :id=\"`pv-chart-config-${option.value}`\"\n                  :key=\"option.value\"\n                  :data-active=\"nestedDrawerOpen === option.value ? true : null\"\n                  :data-dd-action-name=\"rumActionNameForPanelOption(option.value as ChartConfigPanelType)\"\n                  @mouseenter=\"option.disabled ? null : openLegacyNestedDrawer(option.value as ChartConfigPanelType)\"\n                  @click=\"option.disabled ? null : openLegacyNestedDrawer(option.value as ChartConfigPanelType)\"\n                >\n                  <PvTooltipV2\n                    :disableInteractive=\"true\"\n                    :useTeleport=\"true\"\n                    :delay=\"500\"\n                    style=\"width: 100%\"\n                    variant=\"white\"\n                  >\n                    <template #trigger>\n                      <PvMenuItem\n                        :config=\"{ variant: 'icon' }\"\n                        :disabled=\"option.disabled || readOnly\"\n                        :id=\"option.value\"\n                        :text=\"option.label\"\n                        :icon=\"option.icon\"\n                        :class-list=\"[\n                          'pv-legacy-chart-menu-nested',\n                          nestedDrawerOpen === option.value ? 'pv-legacy-chart-menu-nested-active' : '',\n                        ]\"\n                      />\n                    </template>\n                    <template v-if=\"option.disabled && option.disabledReason\" #content>\n                      <div style=\"max-width: 100px\">\n                        {{ option.disabledReason }}\n                      </div>\n                    </template>\n                  </PvTooltipV2>\n                </li>\n              </ul>\n            </PvPopover>\n          </template>\n        </div>\n      </div>\n      <div class=\"pv-flex pv-space-between\" :style=\"!chartFilter ? { justifyContent: 'flex-end' } : {}\">\n        <PvSegmentedControl v-if=\"chartFilter\" :options=\"chartFilterOptions\" v-model=\"activeChartFilterOption\" />\n        <div class=\"pv-flex\" v-if=\"!useCombinedButton\">\n          <template v-for=\"option in chartPanelOptions\" :key=\"option.value\">\n            <PvMultiSelectButton\n              v-if=\"option.isMultiSelect && option.activeOptions && option.activeOptionIds\"\n              :label=\"option.label\"\n              :prefixLabel=\"option.prefixLabel\"\n              :modelValue=\"option.availableOptions!.filter((o) => option.activeOptionIds!.has(o.id))\"\n              @update:modelValue=\"handlePanelMultiSelectUpdate(option, $event)\"\n              :options=\"option.availableOptions!!\"\n              :disableSearchInput=\"true\"\n              :disabled=\"option.disabled || readOnly\"\n              :optionsVariant=\"'checkbox'\"\n              :rumActionName=\"rumActionNameForPanelOption(option.value as ChartConfigPanelType)\"\n            ></PvMultiSelectButton>\n            <PvSelectButton\n              v-else-if=\"!option.isSortableList\"\n              :label=\"option.label\"\n              :prefixLabel=\"option.prefixLabel\"\n              v-model=\"option.currentOption\"\n              @update:modelValue=\"handlePanelSingleSelectUpdate(option, $event)\"\n              :options=\"option.availableOptions!!\"\n              :disableSearchInput=\"true\"\n              :disableDeselect=\"!option.allowDeselect\"\n              :disabled=\"option.disabled || readOnly\"\n              :optionsVariant=\"'icon'\"\n              :childrenDisplay=\"nestedMenuEnabled ? 'popover' : 'inline'\"\n              :rumActionName=\"rumActionNameForPanelOption(option.value as ChartConfigPanelType)\"\n            ></PvSelectButton>\n          </template>\n        </div>\n      </div>\n    </div>\n  </div>\n  <PvPopover\n    v-if=\"useCombinedButton && !nestedMenuEnabled\"\n    ref=\"legacyNestedMenuPopoverRef\"\n    :class=\"{ 'pv-hide': !(configurationDrawerOpen && nestedDrawerOpen !== undefined) }\"\n    :css-custom-properties=\"{ width: 'auto', maxWidth: '260px', ...legacyPopoverPositionStyle }\"\n  >\n    <template v-if=\"nestedDrawerPanelOption\">\n      <div v-if=\"nestedDrawerPanelOption.isSortableList\" class=\"pv-inset-square-8\">\n        <p class=\"pv-text-tertiary pv-text-body-sm pv-stack-4\" style=\"padding-left: 2px; padding-bottom: 6px\">\n          Viewing\n        </p>\n        <PvSortableList\n          :modelValue=\"nestedDrawerPanelOption.activeOptions!.value\"\n          @update:modelValue=\"handleNestedDrawerSortableListUpdate(nestedDrawerPanelOption, $event)\"\n          :options=\"nestedDrawerPanelOption.availableOptions || []\"\n          :activeOptionLimit=\"nestedDrawerPanelOption.activeOptionLimit\"\n          :lockedOptions=\"nestedDrawerPanelOption.lockedOptions\"\n          placeholderText=\"Add to X Axis\"\n        />\n      </div>\n      <ul v-else role=\"list\" class=\"pv-popover-list\">\n        <li\n          v-for=\"option in nestedDrawerPanelOption.availableOptions\"\n          :key=\"option.id\"\n          :data-active=\"legacyOptionActive(option)\"\n        >\n          <PvMenuItem\n            :id=\"option.id\"\n            :config=\"legacyMenuItemConfig()\"\n            :text=\"option.text\"\n            :icon=\"option.icon\"\n            :description=\"option.description\"\n            :context=\"option.context\"\n            :disabled=\"option.disabled || readOnly\"\n            :selectedIds=\"\n              nestedDrawerPanelOption.isMultiSelect ? [...(nestedDrawerPanelOption.activeOptionIds ?? [])] : []\n            \"\n            @update:selectedIds=\"handleLegacySelectedIdsUpdate\"\n            @handleSelected=\"handleLegacyOptionSelected(option)\"\n            :class-list=\"['pv-legacy-chart-option', 'pv-flex']\"\n          />\n        </li>\n      </ul>\n    </template>\n  </PvPopover>\n</template>\n\n<style scoped>\n:deep(.pv-legacy-chart-menu-nested)::after {\n  content: \"›\";\n  margin-left: auto;\n}\n\n:deep(.pv-legacy-chart-option) {\n  min-width: 150px;\n  max-width: 225px;\n}\n\n:global(.pv-chart-config-popover) {\n  width: max-content;\n  max-width: 500px;\n}\n</style>\n","<script setup lang=\"ts\" generic=\"T\">\nimport PvSegmentedControl from \"@/components/base/PvSegmentedControl/PvSegmentedControl.vue\";\nimport { computed, ComputedRef, inject, Ref, ref, watch } from \"vue\";\nimport type { MenuOption, MenuOptionSelectedEvent, Option } from \"@/types\";\nimport type {\n  ChartConfigPanelType,\n  ChartFilter,\n  ChartSeriesAggFuncSelectedEvent,\n  OptionWithFormatterAndDataType,\n} from \"@charts/PvDataTableWithChart/types\";\nimport {\n  ActiveChartFilterOptionKey,\n  ActiveChartKey,\n  ActiveSeriesKey,\n  ActiveSecondarySeriesKey,\n  ActiveSecondarySeriesListKey,\n  ActiveSortKey,\n  ActiveCrosslineOverlayGroupsKey,\n  AvailableRowGroupColumnsKey,\n  AvailableSeriesKey,\n  AvailableSecondarySeriesKey,\n  AvailableCrosslineOverlayGroupsKey,\n  ChartTypeKey,\n  MetricOverlayMultiSelectKey,\n  RowGroupColumnsKey,\n  SortTypesKey,\n} from \"@/components/tables/symbols\";\nimport PvSelectButtonTrigger from \"@/components/base/PvSelectButton/PvSelectButtonTrigger/PvSelectButtonTrigger.vue\";\nimport PvPopover from \"@/components/base/PvPopover/PvPopover.vue\";\nimport PvMenu from \"@/components/base/PvMenu/PvMenu.vue\";\nimport PvMenuItem from \"@/components/base/PvMenu/items/PvMenuItem.vue\";\nimport PvSelectButton from \"@/components/base/PvSelectButton/PvSelectButton.vue\";\nimport PvMultiSelectButton from \"@/components/base/PvMultiSelectButton/PvMultiSelectButton.vue\";\nimport PvSortableList from \"@/components/base/PvSortableList/PvSortableList.vue\";\nimport type { LockedOption } from \"@/components/base/PvSortableList/types\";\nimport { useMenuPosition, type PopoverRefElement } from \"@/components/base/PvMenu/useMenuPosition\";\nimport { mapEntityTypeToHeaderIcon } from \"@tables/PvDataTable/table-components/formatting\";\nimport { getChartTypeConfig } from \"@charts/PvDataTableWithChart/chartTypeRegistry\";\nimport { isChronologicalColDef } from \"@charts/PvDataTableWithChart/helpers\";\nimport { vOnClickOutside } from \"@vueuse/components\";\nimport PvTooltipV2 from \"@/components/base/PvTooltipV2/PvTooltipV2.vue\";\nimport { addRumAction, deferRumTask, useRumContext } from \"@/functions/rum\";\n\nexport interface PvChartOptionsPanelProps {\n  enablePanel: boolean;\n  chartFilter?: ChartFilter;\n  rowGroupLimit?: number;\n  useCombinedButton?: boolean;\n  useNestedMenu?: boolean;\n  chartConfigOptions?: ChartConfigPanelType[];\n  /** Row-group columns pinned in the sortable X Axis list: locked options can't be removed or\n   *  reordered, and an entry's optional `tooltip` explains why (see PvSortableList's\n   *  lockedOptions). */\n  lockedRowGroupOptions?: LockedOption[];\n  /** Keep the Metric Overlay picker enabled when a secondary row group splits a non-stacked\n   *  chart into per-group series (see PvDataTableWithChart's metricOverlayWithRowGroups). */\n  metricOverlayWithRowGroups?: boolean;\n  /** When true, the panel's controls are visible but disabled (view-only). */\n  readOnly?: boolean;\n  /** Column field used for the \"% of focus\" chart view; its Y-axis option is disabled on line charts. */\n  percentOfFocusViewYKey?: string;\n}\n\nconst props = withDefaults(defineProps<PvChartOptionsPanelProps>(), {\n  useNestedMenu: false,\n});\n\ninterface ChartSeriesMenuOptionContext {\n  aggFunc?: string;\n  columnField?: string;\n  description?: string;\n  seriesValue?: string;\n}\n\nconst emit = defineEmits<{\n  (e: \"series-agg-func-selected\", event: ChartSeriesAggFuncSelectedEvent): void;\n}>();\n\nconst nestedMenuEnabled = computed(() => !!props.useCombinedButton && props.useNestedMenu);\n\nconst {\n  popoverPositionStyle: legacyPopoverPositionStyle,\n  updateRects: updateLegacyPopoverPosition,\n  triggerRef: legacyTriggerRef,\n  popoverRef: legacyPopoverRef,\n} = useMenuPosition({\n  alignment: \"top right\",\n  popoverCssProperties: {\n    maxWidth: \"500px\",\n    maxHeight: \"900px\",\n  },\n  useTeleport: true,\n});\n\n// refs to track drawer states\nconst configurationDrawerOpen = ref(false);\nconst nestedDrawerOpen: Ref<ChartConfigPanelType | undefined> = ref(undefined);\nconst legacyNestedMenuPopoverRef = ref<PopoverRefElement | null>(null);\n\n// chart type options\nconst activeChartType = inject(ActiveChartKey, ref(undefined));\nconst chartTypes = inject(ChartTypeKey, ref([]));\n\n// sort options\nconst activeSort = inject(ActiveSortKey, ref(undefined));\nconst sortTypes = inject(SortTypesKey, ref([]));\n\n// x axis options\nconst rowGroupColumns = inject(RowGroupColumnsKey, ref([]));\nconst availableRowGroupColumns = inject(AvailableRowGroupColumnsKey, ref([]));\n\nconst activeChartTypeConfig = computed(() => getChartTypeConfig(activeChartType.value?.id || \"\"));\n\nconst metricOverlayDisabled = computed(() => {\n  const id = activeChartType.value?.id ?? \"\";\n  return rowGroupColumns.value.length > 1 && !id.endsWith(\"_stacked\") && !props.metricOverlayWithRowGroups;\n});\n\n// y axis options\nconst activeSeries = inject(ActiveSeriesKey, ref(\"\"));\nconst availableSeries = inject(AvailableSeriesKey, ref([]));\nconst activeSecondarySeries = inject(ActiveSecondarySeriesKey, ref<string | undefined>(undefined));\nconst availableSecondarySeries = inject(AvailableSecondarySeriesKey, ref([]));\n// Multi-select metric overlay mode: selections live in a list; the picker renders checkboxes.\nconst metricOverlayMultiSelect = inject(MetricOverlayMultiSelectKey, ref(false));\nconst activeSecondarySeriesList = inject(ActiveSecondarySeriesListKey, ref<string[]>([]));\n\n// crossline overlay group options\nconst activeCrosslineOverlayGroups = inject(ActiveCrosslineOverlayGroupsKey, ref<Set<string>>(new Set()));\nconst availableCrosslineOverlayGroups = inject(AvailableCrosslineOverlayGroupsKey, ref([]));\n\n// ActiveCrosslineOverlayGroups shaped as MenuOption[] for PvMultiSelectButton's :modelValue.\nconst activeCrosslineOverlayOptions = computed<MenuOption[]>(() =>\n  availableCrosslineOverlayGroups.value\n    .filter((group) => activeCrosslineOverlayGroups.value.has(group.id))\n    .map((group) => ({\n      id: group.id,\n      text: group.label,\n      disabled: group.disabled,\n      description: group.disabledReason,\n    })),\n);\n\nconst setActiveCrosslineOverlaysFromOptions = (options: MenuOption[]) => {\n  activeCrosslineOverlayGroups.value = new Set(options.map((opt) => opt.id));\n};\n\nwatch(\n  metricOverlayDisabled,\n  (disabled) => {\n    if (disabled && activeSecondarySeries.value) {\n      activeSecondarySeries.value = undefined;\n    }\n    if (disabled && activeSecondarySeriesList.value.length > 0) {\n      activeSecondarySeriesList.value = [];\n    }\n  },\n  { immediate: true },\n);\n\n// chart filter options\nconst activeChartFilterOption = inject(ActiveChartFilterOptionKey, ref(\"\"));\n\nconst chartFilterOptions = computed(() => {\n  const chartFilterOptions: Option[] = [];\n  if (props.chartFilter && props.chartFilter.options) {\n    return props.chartFilter.options.map((option) => {\n      return {\n        label: option.label,\n        value: option.value,\n      };\n    });\n  }\n  return chartFilterOptions;\n});\n\n// A date x-axis is always plotted oldest to newest, so the sort control has\n// nothing left to choose - see `sortChartDataChronologically`.\nconst chronologicalXAxis = computed(() => {\n  const xAxisField = rowGroupColumns.value[0];\n  if (!xAxisField) return false;\n  return isChronologicalColDef(availableRowGroupColumns.value.find((col) => col.field === xAxisField));\n});\n\nconst isSortableChartType = computed(() => {\n  if (!activeChartType.value) return;\n  // if we have > 2 row groups, bar and column are grouped, and we don't want to enable sorting for them\n  const allowedTypes =\n    rowGroupColumns.value.length > 1\n      ? [\"bar_stacked\", \"line\", \"column_stacked\", \"area\"]\n      : [\"bar\", \"line\", \"column\", \"area\"];\n  return allowedTypes.includes(activeChartType.value?.id);\n});\n\nwatch(chartTypes, (newTypes) => {\n  if (!activeChartType.value) return;\n  // for stacked charts, reset to the base type if the current type is no longer available\n  const currentType = activeChartType.value;\n  const currentTypeIsStacked = currentType?.id.endsWith(\"_stacked\");\n  const matchedExistingType = newTypes.find((type) => type.id === currentType.id);\n  if (matchedExistingType) {\n    activeChartType.value = matchedExistingType;\n    return;\n  }\n  if (currentTypeIsStacked) {\n    const baseType = currentType?.id.replace(\"_stacked\", \"\");\n    const matchedBaseType = newTypes.find((type) => type.id === baseType);\n    if (matchedBaseType) {\n      activeChartType.value = matchedBaseType;\n      return;\n    }\n  }\n  // otherwise, set to the first available type\n  activeChartType.value = newTypes[0];\n});\n\ninterface ChartPanelOption {\n  value: string;\n  label: string;\n  prefixLabel?: string;\n  icon: string;\n  availableOptions?: MenuOption[];\n  currentOption?: MenuOption; // Used for single-select panels\n  activeOptionIds?: Set<string>; // Used for multi-select panels\n  updateSelectedOption?: (id: string) => void;\n  updateSelectedOptions?: (options: MenuOption[]) => void; // Updates for multi-select panels\n  disabled?: boolean;\n  disabledReason?: string;\n  allowDeselect?: boolean;\n\n  // for use with isSortableList, to track when the list order is updated and which options are active\n  isSortableList?: boolean;\n  activeOptions?: Ref<MenuOption[]>;\n  activeOptionLimit?: number;\n  lockedOptions?: LockedOption[];\n\n  // for use with isMultiSelect, to render a PvMultiSelectButton in the flat render path\n  isMultiSelect?: boolean;\n}\n\nconst findMenuOption = (options: MenuOption[], id: string): MenuOption | undefined => {\n  for (const option of options) {\n    if (option.id === id) return option;\n    const child = option.children ? findMenuOption(option.children, id) : undefined;\n    if (child) return child;\n  }\n  return undefined;\n};\n\nconst leafMenuOptions = (options: MenuOption[]): MenuOption[] =>\n  options.flatMap((option) => (option.children?.length ? leafMenuOptions(option.children) : option));\n\n// Datadog RUM action names for each chart-config panel selector. Hardcoded\n// because labels are 1:1 with the ChartConfigPanelType enum and don't vary\n// by consumer. Returning undefined for unknown values keeps the attribute\n// absent so Datadog falls back to its default text resolution.\nconst rumActionNameForPanelOption = (value: ChartConfigPanelType | undefined): string | undefined => {\n  switch (value) {\n    case \"y-axis\":\n      return \"Select Y Axis metric\";\n    case \"secondary-y-axis\":\n      return \"Select Metric Overlay\";\n    case \"x-axis\":\n      return \"Select X Axis dimension\";\n    case \"chart-type\":\n      return \"Select Chart Type\";\n    case \"sort\":\n      return \"Select Chart Sort\";\n    default:\n      return undefined;\n  }\n};\n\nconst rumContext = useRumContext();\n\n/**\n * Emit a `chart_option_selected` RUM custom action when a user picks a value\n * inside one of the chart-config sub-popovers (Y Axis, X Axis, Sort, etc.).\n * Mirrors the `filter_option_selected` schema so analysts can answer \"what\n * Y-Axis metrics do users actually pick?\" without inferring from the\n * `data-dd-action-name` trigger event.\n *\n * Fires only after a value is selected. Opening a parent popover does not\n * trigger this action.\n */\n// Map the internal panel id to a more user-facing label for the RUM event.\n// `secondary-y-axis` is internal jargon — the UI surfaces it as Metric Overlay.\nconst rumPanelName = (panel: ChartConfigPanelType): string => (panel === \"secondary-y-axis\" ? \"metric-overlay\" : panel);\n\nconst recordChartOptionSelected = (\n  panel: ChartConfigPanelType,\n  optionId: string | undefined,\n  action: \"select\" | \"deselect\" = \"select\",\n) => {\n  if (!optionId) return;\n  const panelOption = chartPanelOptions.value.find((o) => o.value === panel);\n  const selectedOption = panelOption?.availableOptions\n    ? findMenuOption(panelOption.availableOptions, optionId)\n    : undefined;\n  addRumAction(\n    \"chart_option_selected\",\n    {\n      panel: rumPanelName(panel),\n      selected_value: selectedOption?.text ?? optionId,\n      selected_value_id: optionId,\n      action,\n    },\n    rumContext(),\n  );\n};\n\n/** Flat-layout PvMultiSelectButton (crossline overlay groups). */\nconst handlePanelMultiSelectUpdate = (option: ChartPanelOption, selected: MenuOption[]) => {\n  // Copy before updating: updateSelectedOptions replaces the active-ids set.\n  const previousIds = new Set(option.activeOptionIds);\n  option.updateSelectedOptions?.(selected);\n  deferRumTask(() => {\n    for (const opt of selected) {\n      if (!previousIds.has(opt.id)) recordChartOptionSelected(option.value as ChartConfigPanelType, opt.id);\n    }\n  });\n};\n\n/** Flat-layout PvSelectButton (y-axis, x-axis, sort, chart type, overlay). */\nconst handlePanelSingleSelectUpdate = (option: ChartPanelOption, selected: MenuOption | undefined) => {\n  option.updateSelectedOption?.(selected?.id || \"\");\n  deferRumTask(() => recordChartOptionSelected(option.value as ChartConfigPanelType, selected?.id));\n};\n\n/** Apply a selection from the PvMenu rendered inside a combined-button panel. */\nconst handleCombinedMenuOptionSelected = (panel: ChartPanelOption, event: MenuOptionSelectedEvent) => {\n  const option = event.option;\n  if (panel.isMultiSelect) {\n    const previousIds = new Set(panel.activeOptionIds ?? []);\n    const nextIds = new Set(previousIds);\n    if (nextIds.has(option.id)) {\n      nextIds.delete(option.id);\n    } else {\n      nextIds.add(option.id);\n    }\n    panel.updateSelectedOptions?.(\n      leafMenuOptions(panel.availableOptions ?? []).filter((candidate) => nextIds.has(candidate.id)),\n    );\n    if (!previousIds.has(option.id)) {\n      deferRumTask(() => recordChartOptionSelected(panel.value as ChartConfigPanelType, option.id));\n    }\n    return;\n  }\n\n  panel.updateSelectedOption?.(option.id);\n  deferRumTask(() => recordChartOptionSelected(panel.value as ChartConfigPanelType, option.id));\n};\n\n/**\n * Combined-button nested drawer, sortable list (multi-dimension X axis on\n * cartesian charts). PvSortableList reports adds, removes, and drag reorders\n * as a whole new list — diff it into per-dimension select/deselect events,\n * plus a single \"reorder\" event when membership is unchanged but the order\n * moved (its selected_value carries the resulting dimension order, since a\n * drag can't be attributed to one item from a list diff).\n */\nconst handleNestedDrawerSortableListUpdate = (panel: ChartPanelOption, next: MenuOption[]) => {\n  const previous = panel.activeOptions?.value ?? [];\n  if (panel.activeOptions) panel.activeOptions.value = next;\n  deferRumTask(() => {\n    const previousIds = previous.map((option) => option.id);\n    const nextIds = next.map((option) => option.id);\n    const previousSet = new Set(previousIds);\n    const nextSet = new Set(nextIds);\n    for (const option of next) {\n      if (!previousSet.has(option.id)) {\n        recordChartOptionSelected(panel.value as ChartConfigPanelType, option.id, \"select\");\n      }\n    }\n    for (const option of previous) {\n      if (!nextSet.has(option.id)) {\n        recordChartOptionSelected(panel.value as ChartConfigPanelType, option.id, \"deselect\");\n      }\n    }\n    const membershipUnchanged = previousIds.length === nextIds.length && previousIds.every((id) => nextSet.has(id));\n    if (membershipUnchanged && previousIds.join(\" \") !== nextIds.join(\" \")) {\n      addRumAction(\n        \"chart_option_selected\",\n        {\n          panel: rumPanelName(panel.value as ChartConfigPanelType),\n          selected_value: next.map((option) => option.text).join(\", \"),\n          selected_value_id: nextIds.join(\",\"),\n          action: \"reorder\",\n        },\n        rumContext(),\n      );\n    }\n  });\n};\n\nconst seriesAggFuncOptionId = (columnField: string, aggFunc: string) =>\n  `chart-series-agg-func:${encodeURIComponent(columnField)}:${encodeURIComponent(aggFunc)}`;\n\nconst seriesAggFuncGroupOptionId = (aggFunc: string) => `chart-series-agg-func-group:${encodeURIComponent(aggFunc)}`;\n\n// The \"% of focus\" metric can't be plotted on line charts, so its Y-axis option\n// stays visible but is grayed out while a line chart type is active.\nconst percentOfFocusDisabledDescription = \"This metric isn’t available with the selected chart type.\";\n\nconst disabledPrimarySeriesValue = computed(() =>\n  activeChartType.value?.id === \"line\" ? props.percentOfFocusViewYKey : undefined,\n);\n\nconst seriesDisabledState = (\n  disabledSeriesValue: string | undefined,\n  seriesValue: string | undefined,\n  description?: string,\n) => {\n  const disabled = !!disabledSeriesValue && seriesValue === disabledSeriesValue;\n  return { disabled, description: disabled ? percentOfFocusDisabledDescription : description };\n};\n\nconst seriesMenuOptions = (\n  seriesOptions: OptionWithFormatterAndDataType[],\n  disabledSeriesValue?: string,\n): MenuOption[] => {\n  const menuOptions: MenuOption[] = [];\n  const aggFuncGroups = new Map<string, MenuOption>();\n  const aggFuncGroupOrders = new Map<string, number>();\n\n  for (const series of seriesOptions) {\n    const columnField = series.columnField;\n    if (!series.aggFuncOptions?.length || !columnField) {\n      const { disabled, description } = seriesDisabledState(disabledSeriesValue, series.value, series.description);\n      menuOptions.push({\n        id: series.value,\n        text: series.label,\n        disabled,\n        description,\n        config: { variant: \"icon\" as const },\n      });\n      continue;\n    }\n\n    for (const option of series.aggFuncOptions) {\n      let group = aggFuncGroups.get(option.aggFunc);\n      if (!group) {\n        group = {\n          id: seriesAggFuncGroupOptionId(option.aggFunc),\n          text: option.label,\n          description: option.description,\n          config: { variant: \"icon\" as const },\n          children: [],\n        };\n        aggFuncGroups.set(option.aggFunc, group);\n        menuOptions.push(group);\n      }\n      if (option.order !== undefined && !aggFuncGroupOrders.has(group.id)) {\n        aggFuncGroupOrders.set(group.id, option.order);\n      }\n      const { disabled, description } = seriesDisabledState(\n        disabledSeriesValue,\n        option.seriesValue ?? series.value,\n        series.description,\n      );\n      group.children?.push({\n        id: seriesAggFuncOptionId(columnField, option.aggFunc),\n        text: series.label,\n        disabled,\n        description,\n        context: {\n          aggFunc: option.aggFunc,\n          columnField,\n          description,\n          seriesValue: option.seriesValue,\n        } satisfies ChartSeriesMenuOptionContext,\n        config: { variant: \"icon\" as const },\n      });\n    }\n  }\n\n  return menuOptions.sort((left, right) => {\n    const leftOrder = aggFuncGroupOrders.get(left.id);\n    const rightOrder = aggFuncGroupOrders.get(right.id);\n    if (leftOrder === undefined) return rightOrder === undefined ? 0 : 1;\n    if (rightOrder === undefined) return -1;\n    return leftOrder - rightOrder;\n  });\n};\n\nconst flatSeriesMenuOptions = (\n  seriesOptions: OptionWithFormatterAndDataType[],\n  disabledSeriesValue?: string,\n): MenuOption[] =>\n  seriesOptions.map((series) => {\n    const { disabled, description } = seriesDisabledState(disabledSeriesValue, series.value, series.description);\n    return {\n      id: series.value,\n      text: series.label,\n      disabled,\n      description,\n    };\n  });\n\nconst activeSeriesMenuOption = (\n  menuOptions: MenuOption[],\n  seriesOptions: OptionWithFormatterAndDataType[],\n  activeValue: string | undefined,\n): MenuOption | undefined => {\n  if (!activeValue) return undefined;\n  const series = seriesOptions.find(\n    (option) =>\n      option.value === activeValue || option.aggFuncOptions?.some((aggFunc) => aggFunc.seriesValue === activeValue),\n  );\n  if (!series?.aggFuncOptions?.length || !series.columnField) return findMenuOption(menuOptions, activeValue);\n  const activeAggFunc =\n    series.aggFuncOptions.find((option) => option.aggFunc === series.activeAggFunc) ??\n    series.aggFuncOptions.find((option) => option.seriesValue === activeValue) ??\n    series.aggFuncOptions[0];\n  return activeAggFunc\n    ? findMenuOption(menuOptions, seriesAggFuncOptionId(series.columnField, activeAggFunc.aggFunc))\n    : undefined;\n};\n\nconst selectedSeriesMenuOption = (menuOptions: MenuOption[], id: string) => {\n  const option = findMenuOption(menuOptions, id);\n  const context = option?.context as ChartSeriesMenuOptionContext | undefined;\n  return {\n    aggFunc: context?.aggFunc,\n    columnField: context?.columnField,\n    seriesValue: context?.seriesValue ?? option?.id,\n  };\n};\n\nconst seriesSelectionCount = (seriesOptions: OptionWithFormatterAndDataType[]) =>\n  seriesOptions.reduce((count, series) => count + (series.aggFuncOptions?.length || 1), 0);\n\n// Multi-select metric overlay: the active series values shaped as menu options / option ids\n// for the checkbox picker, and the reverse mapping back onto the active list.\nconst activeSecondaryMenuOptions = computed<MenuOption[]>(() =>\n  activeSecondarySeriesList.value\n    .map((value) =>\n      activeSeriesMenuOption(availableSecondarySeriesMenuOptions.value, availableSecondarySeries.value, value),\n    )\n    .filter((option): option is MenuOption => option !== undefined),\n);\n\nconst activeSecondaryMenuOptionIds = computed<Set<string>>(\n  () => new Set(activeSecondaryMenuOptions.value.map((option) => option.id)),\n);\n\nconst setActiveSecondaryListFromOptions = (options: MenuOption[]) => {\n  const seenColumns = new Set<string>();\n  const values: string[] = [];\n  for (const option of options) {\n    const selection = selectedSeriesMenuOption(availableSecondarySeriesMenuOptions.value, option.id);\n    if (!selection.seriesValue) continue;\n    // Agg-func menus expose one entry per (column, aggFunc); a column can only be charted\n    // once, so keep the first selection per column.\n    const columnKey = selection.columnField ?? selection.seriesValue;\n    if (seenColumns.has(columnKey)) continue;\n    seenColumns.add(columnKey);\n    values.push(selection.seriesValue);\n    if (selection.aggFunc && selection.columnField) {\n      emit(\"series-agg-func-selected\", {\n        aggFunc: selection.aggFunc,\n        columnField: selection.columnField,\n      });\n    }\n  }\n  activeSecondarySeriesList.value = values;\n};\n\nconst availableSeriesMenuOptions = computed(() =>\n  nestedMenuEnabled.value\n    ? seriesMenuOptions(availableSeries.value, disabledPrimarySeriesValue.value)\n    : flatSeriesMenuOptions(availableSeries.value, disabledPrimarySeriesValue.value),\n);\n\nconst availableSecondarySeriesMenuOptions = computed(() =>\n  nestedMenuEnabled.value\n    ? seriesMenuOptions(availableSecondarySeries.value)\n    : flatSeriesMenuOptions(availableSecondarySeries.value),\n);\n\nconst availableSeriesSelectionCount = computed(() =>\n  nestedMenuEnabled.value ? seriesSelectionCount(availableSeries.value) : availableSeries.value.length,\n);\n\nconst availableRowGroupMenuOptions = computed(() => {\n  return availableRowGroupColumns.value.map((col) => ({\n    id: col.field || \"\",\n    text: col.headerName || col.field || \"\",\n    icon: mapEntityTypeToHeaderIcon(col.context?.dataType || null) || \"circle-chevron-down\",\n  }));\n});\n\nconst activeRowGroupMenuOptions = computed({\n  get: () =>\n    rowGroupColumns.value\n      .map((col) => availableRowGroupMenuOptions.value.find((opt) => opt.id === col))\n      .filter(Boolean) as MenuOption[],\n  set: (newOptions: MenuOption[]) => {\n    rowGroupColumns.value = newOptions.map((opt) => opt.id);\n  },\n});\n\nconst chartPanelOptions: ComputedRef<ChartPanelOption[]> = computed(() => {\n  const supportedOptions: ChartPanelOption[] = [];\n  const yAxisConfigOption = {\n    value: \"y-axis\",\n    label: \"Y Axis\",\n    prefixLabel: \"Y Axis\",\n    icon: \"chart-bar-decreasing\",\n    allowDeselect: false,\n    availableOptions: availableSeriesMenuOptions.value,\n    currentOption: activeSeriesMenuOption(availableSeriesMenuOptions.value, availableSeries.value, activeSeries.value),\n    updateSelectedOption: (id: string) => {\n      const selection = selectedSeriesMenuOption(availableSeriesMenuOptions.value, id);\n      if (!selection.seriesValue) return;\n      activeSeries.value = selection.seriesValue;\n      if (selection.aggFunc && selection.columnField) {\n        emit(\"series-agg-func-selected\", {\n          aggFunc: selection.aggFunc,\n          columnField: selection.columnField,\n        });\n      }\n    },\n  };\n\n  const config = activeChartTypeConfig.value;\n  const isSortableXAxis = config.xAxis.selectMode === \"sortable\";\n\n  const xAxisConfigOption: ChartPanelOption = {\n    isSortableList: isSortableXAxis,\n    value: \"x-axis\",\n    label: \"X Axis\",\n    icon: \"align-end-horizontal\",\n    allowDeselect: false,\n    availableOptions: availableRowGroupMenuOptions.value,\n    ...(isSortableXAxis\n      ? {\n          activeOptions: activeRowGroupMenuOptions,\n          activeOptionLimit: props.rowGroupLimit,\n          lockedOptions: props.lockedRowGroupOptions,\n        }\n      : {\n          currentOption: availableRowGroupMenuOptions.value.find((option) => option.id === rowGroupColumns.value[0]),\n          updateSelectedOption: (id: string) => {\n            rowGroupColumns.value = id ? [id] : [];\n          },\n        }),\n  };\n\n  const sortConfigOption = {\n    value: \"sort\",\n    label: \"Sort\",\n    icon: \"arrow-up-wide-narrow\",\n    allowDeselect: true,\n    availableOptions: sortTypes.value,\n    currentOption: sortTypes.value.find((sort) => sort.id === activeSort.value?.id),\n    disabled: chronologicalXAxis.value || !isSortableChartType.value,\n    disabledReason: chronologicalXAxis.value\n      ? \"Dates are always sorted oldest to newest\"\n      : \"Sorting is not available for this chart type\",\n    updateSelectedOption: (id: string) => {\n      const selectedSort = sortTypes.value.find((sort) => sort.id === id);\n      // if the same sort is selected, clear the sort\n      if (!selectedSort || !activeSort) {\n        activeSort.value = undefined;\n        return;\n      }\n      if (activeSort.value?.id === selectedSort.id) {\n        activeSort.value = undefined;\n      } else {\n        activeSort.value = selectedSort;\n      }\n    },\n  };\n\n  const chartTypeConfigOption = {\n    value: \"chart-type\",\n    label: \"Chart Type\",\n    icon: \"chart-column-stacked\",\n    allowDeselect: false,\n    availableOptions: chartTypes.value,\n    currentOption: chartTypes.value.find((type) => type.id === activeChartType.value?.id),\n    updateSelectedOption: (id: string) => {\n      const selectedType = chartTypes.value.find((type) => type.id === id);\n      if (selectedType && activeChartType) {\n        activeChartType.value = selectedType;\n      }\n    },\n  };\n  // add options if they are applicable\n  if (availableSeriesSelectionCount.value > 1) {\n    supportedOptions.push(yAxisConfigOption);\n  }\n  // \"Metric Overlay\" should show secondary series options if the secondary y-axis is NOT hidden and\n  // should show the crossline overlay groups if it is hidden.\n  if (!config.secondaryYAxis?.hidden && availableSecondarySeriesMenuOptions.value.length > 0) {\n    const metricOverlayOption = metricOverlayMultiSelect.value\n      ? {\n          value: \"secondary-y-axis\",\n          label: \"Metric Overlay\",\n          prefixLabel: \"Metric Overlay\",\n          icon: \"chart-line\",\n          allowDeselect: true,\n          isMultiSelect: true,\n          disabled: metricOverlayDisabled.value,\n          disabledReason: \"Metric overlay is not available for this chart type.\",\n          availableOptions: availableSecondarySeriesMenuOptions.value,\n          activeOptionIds: activeSecondaryMenuOptionIds.value,\n          activeOptions: activeSecondaryMenuOptions,\n          updateSelectedOptions: setActiveSecondaryListFromOptions,\n        }\n      : {\n          value: \"secondary-y-axis\",\n          label: \"Metric Overlay\",\n          prefixLabel: \"Metric Overlay\",\n          icon: \"chart-line\",\n          allowDeselect: true,\n          disabled: metricOverlayDisabled.value,\n          disabledReason: \"Metric overlay is not available for this chart type.\",\n          availableOptions: availableSecondarySeriesMenuOptions.value,\n          currentOption: activeSeriesMenuOption(\n            availableSecondarySeriesMenuOptions.value,\n            availableSecondarySeries.value,\n            activeSecondarySeries.value,\n          ),\n          updateSelectedOption: (id: string) => {\n            if (!activeSecondarySeries) return;\n            const currentOption = activeSeriesMenuOption(\n              availableSecondarySeriesMenuOptions.value,\n              availableSecondarySeries.value,\n              activeSecondarySeries.value,\n            );\n            if (!id || currentOption?.id === id) {\n              activeSecondarySeries.value = undefined;\n              return;\n            }\n            const selection = selectedSeriesMenuOption(availableSecondarySeriesMenuOptions.value, id);\n            activeSecondarySeries.value = selection.seriesValue;\n            if (selection.aggFunc && selection.columnField) {\n              emit(\"series-agg-func-selected\", {\n                aggFunc: selection.aggFunc,\n                columnField: selection.columnField,\n              });\n            }\n          },\n        };\n    if (metricOverlayOption) {\n      supportedOptions.push(metricOverlayOption);\n    }\n  } else if (availableCrosslineOverlayGroups.value.length > 0) {\n    const overlayGroupMenuOptions = availableCrosslineOverlayGroups.value.map((group) => ({\n      id: group.id,\n      text: group.label,\n      disabled: group.disabled,\n      description: group.disabledReason,\n    }));\n    const metricOverlayOption = {\n      value: \"secondary-y-axis\",\n      label: \"Metric Overlay\",\n      prefixLabel: \"Metric Overlay\",\n      icon: \"chart-line\",\n      allowDeselect: true,\n      isMultiSelect: true,\n      availableOptions: overlayGroupMenuOptions,\n      activeOptionIds: activeCrosslineOverlayGroups.value,\n      activeOptions: activeCrosslineOverlayOptions,\n      currentOption: overlayGroupMenuOptions.find((opt) => activeCrosslineOverlayGroups.value.has(opt.id)),\n      updateSelectedOptions: setActiveCrosslineOverlaysFromOptions,\n    };\n    if (metricOverlayOption) {\n      supportedOptions.push(metricOverlayOption);\n    }\n  }\n  const minXAxisOptions = isSortableXAxis ? 2 : 1;\n  if (availableRowGroupMenuOptions.value.length >= minXAxisOptions) {\n    supportedOptions.push(xAxisConfigOption);\n  }\n  if (chartTypes.value.length > 1) {\n    supportedOptions.push(chartTypeConfigOption);\n  }\n  if (sortTypes.value.length > 0) {\n    supportedOptions.push(sortConfigOption);\n  }\n  // filter out options if they are not in chartConfigPanelOptions\n  return supportedOptions.filter((option) => {\n    if (props.chartConfigOptions) {\n      return props.chartConfigOptions.includes(option.value as ChartConfigPanelType);\n    }\n    return true;\n  });\n});\n\nconst nestedDrawerPanelOption = computed(() => {\n  if (!nestedDrawerOpen.value) return null;\n  return chartPanelOptions.value.find((option) => option.value === nestedDrawerOpen.value) || null;\n});\n\nconst panelSelectedOptions = (panel: ChartPanelOption): MenuOption[] => {\n  if (panel.activeOptions) return panel.activeOptions.value;\n  return panel.currentOption ? [panel.currentOption] : [];\n};\n\nconst panelSelectionSummary = (panel: ChartPanelOption): string | undefined => {\n  const text = panelSelectedOptions(panel)\n    .map((option) => option.text)\n    .join(\", \");\n  return text || undefined;\n};\n\nconst chartPanelMenuOptions = computed<MenuOption[]>(() =>\n  chartPanelOptions.value.map((panel) => ({\n    id: panel.value,\n    text: panel.label,\n    subText: panelSelectionSummary(panel),\n    icon: panel.icon,\n    disabled: panel.disabled,\n    hoverTitle: panel.disabledReason,\n    rumActionName: rumActionNameForPanelOption(panel.value as ChartConfigPanelType),\n    popoverRole: panel.isSortableList ? \"dialog\" : \"menu\",\n    children: panel.availableOptions,\n    config: {\n      variant: \"icon\",\n      ...(panel.disabled && panel.disabledReason\n        ? {\n            action: {\n              icon: \"info-circle\",\n              tooltipText: panel.disabledReason,\n              interactive: false,\n              alwaysShow: true,\n            },\n          }\n        : {}),\n    },\n  })),\n);\n\nconst combinedPanelMenuConfig = (panel: ChartPanelOption) =>\n  panel.isMultiSelect ? { variant: \"checkbox\" as const } : { variant: \"icon\" as const };\n\nwatch(legacyNestedMenuPopoverRef, (popover) => {\n  if (popover) legacyPopoverRef.value = popover;\n});\n\nconst handleLegacySelectedIdsUpdate = (ids: string[]) => {\n  const panel = nestedDrawerPanelOption.value;\n  if (!panel?.isMultiSelect) return;\n  const previousIds = new Set(panel.activeOptionIds ?? []);\n  panel.updateSelectedOptions?.((panel.availableOptions ?? []).filter((option) => ids.includes(option.id)));\n  deferRumTask(() => {\n    for (const id of ids) {\n      if (!previousIds.has(id)) recordChartOptionSelected(panel.value as ChartConfigPanelType, id);\n    }\n  });\n};\n\nconst handleLegacyOptionSelected = (option: MenuOption) => {\n  const panel = nestedDrawerPanelOption.value;\n  if (!panel || panel.isMultiSelect) return;\n  panel.updateSelectedOption?.(option.id);\n  deferRumTask(() => recordChartOptionSelected(panel.value as ChartConfigPanelType, option.id));\n};\n\nconst legacyOptionActive = (option: MenuOption): true | null => {\n  const panel = nestedDrawerPanelOption.value;\n  if (!panel || panel.isMultiSelect) return null;\n  return panel.currentOption?.id === option.id ? true : null;\n};\n\nconst legacyMenuItemConfig = () => {\n  if (nestedDrawerPanelOption.value?.isMultiSelect) {\n    return { variant: \"checkbox\" as const };\n  }\n  return { variant: \"icon\" as const };\n};\n\nconst openLegacyNestedDrawer = (drawer: ChartConfigPanelType) => {\n  nestedDrawerOpen.value = drawer;\n  legacyTriggerRef.value = document.getElementById(`pv-chart-config-${drawer}`);\n  updateLegacyPopoverPosition();\n};\n\nconst closeDropdown = () => {\n  configurationDrawerOpen.value = false;\n  nestedDrawerOpen.value = undefined;\n};\n\nconst handleNestedDrawerClose = () => {\n  nestedDrawerOpen.value = undefined;\n};\n</script>\n\n<template>\n  <div class=\"pv-stack-16 pv-chart-options-panel\">\n    <div>\n      <div\n        class=\"pv-flex pv-space-between\"\n        :class=\"useCombinedButton ? 'pv-stack-8' : ''\"\n        v-on-click-outside=\"[\n          closeDropdown,\n          {\n            ignore: ['.pv-popover'],\n          },\n        ]\"\n      >\n        <div class=\"pv-flex pv-relative\">\n          <template v-if=\"useCombinedButton\">\n            <PvSelectButtonTrigger\n              :open=\"configurationDrawerOpen\"\n              label=\"Chart Configuration\"\n              icon=\"chart-area\"\n              data-dd-action-name=\"Toggle Chart Configuration panel\"\n              :disabled=\"readOnly\"\n              @click=\"readOnly ? null : (configurationDrawerOpen = !configurationDrawerOpen)\"\n              @handle-toggle-dropdown=\"handleNestedDrawerClose\"\n            />\n            <template v-if=\"nestedMenuEnabled\">\n              <PvPopover\n                :class=\"{ 'pv-hide': !configurationDrawerOpen }\"\n                :css-custom-properties=\"{ width: '220px', maxWidth: '260px', zIndex: 5 }\"\n              >\n                <div class=\"pv-border-bottom pv-inset-squish-12\">\n                  <p class=\"pv-text-title-sm\">Chart Configuration</p>\n                </div>\n                <PvMenu\n                  v-model:expandedOptionId=\"nestedDrawerOpen\"\n                  :options=\"chartPanelMenuOptions\"\n                  childrenDisplay=\"popover\"\n                  :readOnly=\"readOnly\"\n                >\n                  <template #popover=\"{ popoverId, close }\">\n                    <div\n                      v-if=\"nestedDrawerPanelOption?.isSortableList\"\n                      :id=\"popoverId\"\n                      :aria-label=\"`${nestedDrawerPanelOption.label} options`\"\n                      class=\"pv-chart-config-popover pv-inset-square-8\"\n                      role=\"dialog\"\n                      @keydown.esc.stop=\"close\"\n                    >\n                      <p\n                        class=\"pv-text-tertiary pv-text-body-sm pv-stack-4\"\n                        style=\"padding-left: 2px; padding-bottom: 6px\"\n                      >\n                        Viewing\n                      </p>\n                      <PvSortableList\n                        :modelValue=\"nestedDrawerPanelOption.activeOptions!.value\"\n                        @update:modelValue=\"handleNestedDrawerSortableListUpdate(nestedDrawerPanelOption, $event)\"\n                        :options=\"nestedDrawerPanelOption.availableOptions || []\"\n                        :activeOptionLimit=\"nestedDrawerPanelOption.activeOptionLimit\"\n                        :lockedOptions=\"nestedDrawerPanelOption.lockedOptions\"\n                        placeholderText=\"Add to X Axis\"\n                      />\n                    </div>\n                    <PvMenu\n                      v-else-if=\"nestedDrawerPanelOption\"\n                      :id=\"popoverId\"\n                      :aria-label=\"`${nestedDrawerPanelOption.label} options`\"\n                      class=\"pv-chart-config-popover\"\n                      :options=\"nestedDrawerPanelOption.availableOptions || []\"\n                      :selectedItems=\"panelSelectedOptions(nestedDrawerPanelOption)\"\n                      :config=\"combinedPanelMenuConfig(nestedDrawerPanelOption)\"\n                      :singleSelect=\"!nestedDrawerPanelOption.isMultiSelect\"\n                      :disableDeselect=\"!nestedDrawerPanelOption.allowDeselect\"\n                      :highlightParentItems=\"false\"\n                      :readOnly=\"readOnly\"\n                      childrenDisplay=\"popover\"\n                      itemClass=\"pv-chart-option pv-flex\"\n                      @keydown.esc.stop=\"close\"\n                      @handle-selected=\"handleCombinedMenuOptionSelected(nestedDrawerPanelOption, $event)\"\n                    />\n                  </template>\n                </PvMenu>\n              </PvPopover>\n            </template>\n            <PvPopover\n              v-else\n              :class=\"{ 'pv-hide': !configurationDrawerOpen }\"\n              :css-custom-properties=\"{ width: '171px', maxWidth: '260px', zIndex: 5 }\"\n            >\n              <div class=\"pv-border-bottom pv-inset-squish-12\">\n                <p class=\"pv-text-title-sm\">Chart Configuration</p>\n              </div>\n              <ul role=\"list\" class=\"pv-popover-list pv-relative\">\n                <li\n                  v-for=\"option in chartPanelOptions\"\n                  :id=\"`pv-chart-config-${option.value}`\"\n                  :key=\"option.value\"\n                  :data-active=\"nestedDrawerOpen === option.value ? true : null\"\n                  :data-dd-action-name=\"rumActionNameForPanelOption(option.value as ChartConfigPanelType)\"\n                  @mouseenter=\"option.disabled ? null : openLegacyNestedDrawer(option.value as ChartConfigPanelType)\"\n                  @click=\"option.disabled ? null : openLegacyNestedDrawer(option.value as ChartConfigPanelType)\"\n                >\n                  <PvTooltipV2\n                    :disableInteractive=\"true\"\n                    :useTeleport=\"true\"\n                    :delay=\"500\"\n                    style=\"width: 100%\"\n                    variant=\"white\"\n                  >\n                    <template #trigger>\n                      <PvMenuItem\n                        :config=\"{ variant: 'icon' }\"\n                        :disabled=\"option.disabled || readOnly\"\n                        :id=\"option.value\"\n                        :text=\"option.label\"\n                        :icon=\"option.icon\"\n                        :class-list=\"[\n                          'pv-legacy-chart-menu-nested',\n                          nestedDrawerOpen === option.value ? 'pv-legacy-chart-menu-nested-active' : '',\n                        ]\"\n                      />\n                    </template>\n                    <template v-if=\"option.disabled && option.disabledReason\" #content>\n                      <div style=\"max-width: 100px\">\n                        {{ option.disabledReason }}\n                      </div>\n                    </template>\n                  </PvTooltipV2>\n                </li>\n              </ul>\n            </PvPopover>\n          </template>\n        </div>\n      </div>\n      <div class=\"pv-flex pv-space-between\" :style=\"!chartFilter ? { justifyContent: 'flex-end' } : {}\">\n        <PvSegmentedControl v-if=\"chartFilter\" :options=\"chartFilterOptions\" v-model=\"activeChartFilterOption\" />\n        <div class=\"pv-flex\" v-if=\"!useCombinedButton\">\n          <template v-for=\"option in chartPanelOptions\" :key=\"option.value\">\n            <PvMultiSelectButton\n              v-if=\"option.isMultiSelect && option.activeOptions && option.activeOptionIds\"\n              :label=\"option.label\"\n              :prefixLabel=\"option.prefixLabel\"\n              :modelValue=\"option.availableOptions!.filter((o) => option.activeOptionIds!.has(o.id))\"\n              @update:modelValue=\"handlePanelMultiSelectUpdate(option, $event)\"\n              :options=\"option.availableOptions!!\"\n              :disableSearchInput=\"true\"\n              :disabled=\"option.disabled || readOnly\"\n              :optionsVariant=\"'checkbox'\"\n              :rumActionName=\"rumActionNameForPanelOption(option.value as ChartConfigPanelType)\"\n            ></PvMultiSelectButton>\n            <PvSelectButton\n              v-else-if=\"!option.isSortableList\"\n              :label=\"option.label\"\n              :prefixLabel=\"option.prefixLabel\"\n              v-model=\"option.currentOption\"\n              @update:modelValue=\"handlePanelSingleSelectUpdate(option, $event)\"\n              :options=\"option.availableOptions!!\"\n              :disableSearchInput=\"true\"\n              :disableDeselect=\"!option.allowDeselect\"\n              :disabled=\"option.disabled || readOnly\"\n              :optionsVariant=\"'icon'\"\n              :childrenDisplay=\"nestedMenuEnabled ? 'popover' : 'inline'\"\n              :rumActionName=\"rumActionNameForPanelOption(option.value as ChartConfigPanelType)\"\n            ></PvSelectButton>\n          </template>\n        </div>\n      </div>\n    </div>\n  </div>\n  <PvPopover\n    v-if=\"useCombinedButton && !nestedMenuEnabled\"\n    ref=\"legacyNestedMenuPopoverRef\"\n    :class=\"{ 'pv-hide': !(configurationDrawerOpen && nestedDrawerOpen !== undefined) }\"\n    :css-custom-properties=\"{ width: 'auto', maxWidth: '260px', ...legacyPopoverPositionStyle }\"\n  >\n    <template v-if=\"nestedDrawerPanelOption\">\n      <div v-if=\"nestedDrawerPanelOption.isSortableList\" class=\"pv-inset-square-8\">\n        <p class=\"pv-text-tertiary pv-text-body-sm pv-stack-4\" style=\"padding-left: 2px; padding-bottom: 6px\">\n          Viewing\n        </p>\n        <PvSortableList\n          :modelValue=\"nestedDrawerPanelOption.activeOptions!.value\"\n          @update:modelValue=\"handleNestedDrawerSortableListUpdate(nestedDrawerPanelOption, $event)\"\n          :options=\"nestedDrawerPanelOption.availableOptions || []\"\n          :activeOptionLimit=\"nestedDrawerPanelOption.activeOptionLimit\"\n          :lockedOptions=\"nestedDrawerPanelOption.lockedOptions\"\n          placeholderText=\"Add to X Axis\"\n        />\n      </div>\n      <ul v-else role=\"list\" class=\"pv-popover-list\">\n        <li\n          v-for=\"option in nestedDrawerPanelOption.availableOptions\"\n          :key=\"option.id\"\n          :data-active=\"legacyOptionActive(option)\"\n        >\n          <PvMenuItem\n            :id=\"option.id\"\n            :config=\"legacyMenuItemConfig()\"\n            :text=\"option.text\"\n            :icon=\"option.icon\"\n            :description=\"option.description\"\n            :context=\"option.context\"\n            :disabled=\"option.disabled || readOnly\"\n            :selectedIds=\"\n              nestedDrawerPanelOption.isMultiSelect ? [...(nestedDrawerPanelOption.activeOptionIds ?? [])] : []\n            \"\n            @update:selectedIds=\"handleLegacySelectedIdsUpdate\"\n            @handleSelected=\"handleLegacyOptionSelected(option)\"\n            :class-list=\"['pv-legacy-chart-option', 'pv-flex']\"\n          />\n        </li>\n      </ul>\n    </template>\n  </PvPopover>\n</template>\n\n<style scoped>\n:deep(.pv-legacy-chart-menu-nested)::after {\n  content: \"›\";\n  margin-left: auto;\n}\n\n:deep(.pv-legacy-chart-option) {\n  min-width: 150px;\n  max-width: 225px;\n}\n\n:global(.pv-chart-config-popover) {\n  width: max-content;\n  max-width: 500px;\n}\n</style>\n","export interface ScatterAxes {\n  xKey: string;\n  xName: string;\n  yKey: string;\n  yName: string;\n}\n\n/**\n * Returns the correct axis key/name assignments for a scatter overlay series.\n *\n * Bar series use `direction: \"horizontal\"` which lets AG Charts handle the\n * axis swap internally — xKey=category and yKey=metric work regardless of\n * orientation. Scatter series have no `direction` property: xKey always maps\n * to the physical horizontal axis and yKey to the vertical axis. On a\n * horizontal bar chart the category axis is vertical and the metric axis is\n * horizontal, so the keys must be explicitly swapped.\n */\nexport function buildScatterAxes(\n  categoryKey: string,\n  categoryName: string,\n  metricKey: string,\n  metricName: string,\n  isHorizontal: boolean,\n): ScatterAxes {\n  return isHorizontal\n    ? { xKey: metricKey, xName: metricName, yKey: categoryKey, yName: categoryName }\n    : { xKey: categoryKey, xName: categoryName, yKey: metricKey, yName: metricName };\n}\n","import type { ChipSection, CrosslineOverlayGroup, VerticalLineOverlay } from \"@charts/PvDataTableWithChart/types\";\n\n// Default crossline color when neither an overlay nor its group specifies one.\nexport const DEFAULT_CROSSLINE_OVERLAY_COLOR = \"#E7E2D9\";\n\n// Scale a numeric value into the bucket index range [0, numBuckets] or null if out of bounds.\n//\n// `buckets` reflects the chart's current render order, which callers may have sorted by value/count\n// (see PvDataTableWithChart's \"Sort\" option) rather than by bucketMin - so this can't assume ascending\n// bucketMin order and must find whichever bucket actually contains `value`, using its array position\n// (the bar's current on-screen index) for the returned index.\nexport const scaleValueToIndex = (\n  value: number,\n  buckets: { bucketMin: number; bucketMax: number; count: number }[],\n): number | null => {\n  if (buckets.length === 0) {\n    return null;\n  }\n\n  // Buckets are half-open [min, max) except the overall last one, which includes its max.\n  const globalMax = Math.max(...buckets.map((bucket) => bucket.bucketMax));\n\n  for (let i = 0; i < buckets.length; i++) {\n    const bucket = buckets[i];\n    const withinUpperBound = value < bucket.bucketMax || (bucket.bucketMax === globalMax && value === globalMax);\n    if (value >= bucket.bucketMin && withinUpperBound) {\n      const range = bucket.bucketMax - bucket.bucketMin;\n      const fraction = range > 0 ? (value - bucket.bucketMin) / range : 0;\n      return i + fraction;\n    }\n  }\n\n  // Value doesn't fall within any bucket\n  return null;\n};\n\nexport interface CrosslineAxisDomain {\n  categoryPadOffset: number;\n  axisMin: number;\n  axisMax: number;\n}\n\n// Shared padding math for the crossLine axis, its hit-target scatter series, and any external\n// pixel math (e.g. tooltip positioning) - all must agree or overlays drift off their bars.\n//\n// The `-1`/`+1` outer margin below mirrors the real category axis's `paddingOuter`, which is 1\n// full band on each side EXCEPT when the histogram has real bucket data, where the two blank\n// min/max-label categories already provide that outward spacing and `paddingOuter` is set to 0\n// (see PvDataTableWithChart.vue's category axis). Applying that margin unconditionally makes this\n// number axis a full band wider than the real one, shifting every crossline toward the next bucket.\nexport const getCrosslineAxisDomain = (\n  numCategories: number,\n  isHistogramWithBuckets: boolean | undefined,\n): CrosslineAxisDomain => {\n  const categoryPadOffset = isHistogramWithBuckets ? 1 : 0;\n  const totalCategories = numCategories + categoryPadOffset * 2;\n  const outerMargin = isHistogramWithBuckets ? 0 : 1;\n  return { categoryPadOffset, axisMin: 0 - outerMargin, axisMax: totalCategories + outerMargin };\n};\n\n// Converts a scaled bucket index to a 0..1 fraction along the axis, for pixel positioning.\nexport const scaledIndexToAxisFraction = (scaledValue: number, domain: CrosslineAxisDomain): number => {\n  const { categoryPadOffset, axisMin, axisMax } = domain;\n  return (scaledValue + categoryPadOffset - axisMin) / (axisMax - axisMin);\n};\n\n// Flattens the toggled-on crossline overlay groups into their overlays, falling back to\n// each group's `color` when an overlay doesn't set its own, so a benchmark's chip and its\n// crossline can share one color source. Overlays marked `excludeFromCrossline` are skipped\n// here but still reach `computeChipSections`, so they render as a chip without a crossline.\nexport const resolveCrosslineOverlays = (\n  groups: CrosslineOverlayGroup[],\n  activeGroupIds: Set<string>,\n): VerticalLineOverlay[] => {\n  return groups\n    .filter((group) => activeGroupIds.has(group.id))\n    .flatMap((group) =>\n      group.overlays\n        .filter((overlay) => !overlay.excludeFromCrossline)\n        .map((overlay) => ({\n          ...overlay,\n          color: overlay.color ?? group.color,\n          formatValue: overlay.formatValue ?? group.formatValue,\n          key: `${group.id}-${overlay.label}`,\n        })),\n    );\n};\n\n// Groups active crossline overlay groups that have a `groupName` into chip sections\n// rendered beside the chart, one section per unique `groupName`, in order of that\n// name's first appearance in `groups`. Groups without a `groupName` aren't chipped. A\n// `loading` group contributes a single skeleton-placeholder chip, regardless of its\n// (likely still-empty) `overlays`.\nexport const computeChipSections = (\n  groups: CrosslineOverlayGroup[],\n  activeGroupIds: Set<string>,\n  formatValue: (value: number) => string | number,\n): ChipSection[] => {\n  const sectionsByName = new Map<string, ChipSection>();\n\n  groups\n    .filter((group): group is CrosslineOverlayGroup & { groupName: string } =>\n      Boolean(group.groupName && activeGroupIds.has(group.id)),\n    )\n    .forEach((group) => {\n      const section = sectionsByName.get(group.groupName) ?? { groupName: group.groupName, chips: [] };\n      if (group.loading) {\n        section.chips.push({ key: group.id, loading: true });\n      } else {\n        group.overlays.forEach((overlay) => {\n          const format = overlay.formatValue ?? group.formatValue ?? formatValue;\n          section.chips.push({\n            key: `${group.id}-${overlay.label}`,\n            loading: false,\n            label: overlay.label,\n            color: overlay.color ?? group.color,\n            excludeFromCrossline: overlay.excludeFromCrossline,\n            formattedValue: format(overlay.value),\n          });\n        });\n      }\n      sectionsByName.set(group.groupName, section);\n    });\n\n  return [...sectionsByName.values()];\n};\n","import { computed, ref, watch, type ComputedRef, type CSSProperties, type Ref } from \"vue\";\nimport type PvChart from \"@charts/PvChart/PvChart.vue\";\nimport type { ChipSection, CrosslineOverlayGroup } from \"./types\";\nimport {\n  computeChipSections,\n  getCrosslineAxisDomain,\n  resolveCrosslineOverlays,\n  scaledIndexToAxisFraction,\n  scaleValueToIndex,\n} from \"./crosslineHelpers\";\n\nexport interface CrosslineTooltip {\n  label: string;\n  value: string | number;\n  arrowClass: string;\n  style: CSSProperties;\n}\n\ninterface UseBenchmarkOverlaysOptions {\n  crosslineOverlayGroups: ComputedRef<CrosslineOverlayGroup[]>;\n  isHistogramWithBuckets: ComputedRef<boolean | undefined>;\n  isHorizontalBarChart: ComputedRef<boolean>;\n  computedChartData: ComputedRef<{ bucketMin: number; bucketMax: number; count: number }[] | undefined>;\n  pvChartRef: Ref<InstanceType<typeof PvChart> | null>;\n  formatValue: (value: number) => string | number;\n  /**\n   * Seeds the active set on first render, overriding each group's own `visible` flag. Use this to\n   * restore a consumer-persisted toggle selection (e.g. from a saved report).\n   */\n  initialActiveOverlayGroupIds?: ComputedRef<string[] | undefined>;\n}\n\nconst isGroupEnabled = (group: CrosslineOverlayGroup) => Boolean(group.visible && !group.disabled);\n\n// Owns the benchmark-chip / crossLine-overlay hover feature end to end: which overlay groups\n// are toggled on, the chips rendered beside the chart, and - since AG Charts has no API to show\n// its tooltip programmatically for an arbitrary datum - a lookalike tooltip positioned via\n// getBoundingClientRect() when a chip is hovered.\nexport function useBenchmarkOverlays(options: UseBenchmarkOverlaysOptions) {\n  const {\n    crosslineOverlayGroups,\n    isHistogramWithBuckets,\n    isHorizontalBarChart,\n    computedChartData,\n    pvChartRef,\n    formatValue,\n    initialActiveOverlayGroupIds,\n  } = options;\n\n  const activeCrosslineOverlayGroups = ref<Set<string>>(\n    new Set(\n      initialActiveOverlayGroupIds?.value ??\n        crosslineOverlayGroups.value.filter((g) => isGroupEnabled(g)).map((g) => g.id),\n    ),\n  );\n\n  // A group can flip from disabled/hidden to enabled after mount (e.g. a \"Focus\" group becomes\n  // available once the consumer applies a focus org). When that happens, turn it on automatically. Groups the viewer has\n  // manually toggled off are left alone otherwise - this only reacts to newly-enabled groups.\n  //\n  // Groups that load in async (e.g. custom-metric benchmarks) can appear here for the first time\n  // post-mount, indistinguishable from a real eligibility change. If a persisted selection exists,\n  // treat newly-appearing groups as excluded rather than auto-enabling them.\n  let previousEnabledById = new Map(crosslineOverlayGroups.value.map((g) => [g.id, isGroupEnabled(g)]));\n  watch(crosslineOverlayGroups, (groups) => {\n    const nextActive = new Set(activeCrosslineOverlayGroups.value);\n    let changed = false;\n    const hasPersistedSelection = initialActiveOverlayGroupIds?.value !== undefined;\n    for (const group of groups) {\n      const enabled = isGroupEnabled(group);\n      const wasKnown = previousEnabledById.has(group.id);\n      const shouldAutoEnable = wasKnown ? !previousEnabledById.get(group.id) : !hasPersistedSelection;\n      if (enabled && shouldAutoEnable) {\n        nextActive.add(group.id);\n        changed = true;\n      } else if (!enabled && previousEnabledById.get(group.id)) {\n        nextActive.delete(group.id);\n        changed = true;\n      }\n    }\n    previousEnabledById = new Map(groups.map((g) => [g.id, isGroupEnabled(g)]));\n    if (changed) {\n      activeCrosslineOverlayGroups.value = nextActive;\n    }\n  });\n\n  const resolvedCrosslineOverlays = computed(() =>\n    resolveCrosslineOverlays(crosslineOverlayGroups.value, activeCrosslineOverlayGroups.value),\n  );\n\n  const chipSections = computed<ChipSection[]>(() =>\n    computeChipSections(crosslineOverlayGroups.value, activeCrosslineOverlayGroups.value, formatValue),\n  );\n\n  // Set on chip hover; highlights that benchmark's crossLine and dims the rest of the chart.\n  const hoveredBenchmarkKey = ref<string | null>(null);\n\n  const hoveredCrosslineTooltip = computed<CrosslineTooltip | null>(() => {\n    if (!hoveredBenchmarkKey.value || !computedChartData.value) {\n      return null;\n    }\n    const overlay = resolvedCrosslineOverlays.value.find((o) => o.key === hoveredBenchmarkKey.value);\n    if (!overlay) {\n      return null;\n    }\n    const scaledValue = scaleValueToIndex(overlay.value, computedChartData.value);\n    if (scaledValue == null) {\n      return null;\n    }\n\n    const chartEl = pvChartRef.value?.$el as HTMLElement | undefined;\n    const seriesRect = chartEl?.querySelector(\".ag-charts-series-area\")?.getBoundingClientRect();\n    if (!seriesRect) {\n      return null;\n    }\n\n    const numCategories = computedChartData.value.length || 1;\n    const axisDomain = getCrosslineAxisDomain(numCategories, isHistogramWithBuckets.value);\n    const fraction = scaledIndexToAxisFraction(scaledValue, axisDomain);\n\n    const formattedValue = overlay.formatValue ? overlay.formatValue(overlay.value) : formatValue(overlay.value);\n\n    const ARROW_GAP = 8;\n    if (isHorizontalBarChart.value) {\n      return {\n        label: overlay.label,\n        value: formattedValue,\n        arrowClass: \"ag-charts-tooltip--arrow-left\",\n        style: {\n          \"--left\": `${seriesRect.left + ARROW_GAP}px`,\n          \"--top\": `${seriesRect.top + (1 - fraction) * seriesRect.height}px`,\n          transform: \"translateY(-50%)\",\n          pointerEvents: \"none\",\n        } as CSSProperties,\n      };\n    }\n    return {\n      label: overlay.label,\n      value: formattedValue,\n      arrowClass: \"ag-charts-tooltip--arrow-bottom\",\n      style: {\n        \"--left\": `${seriesRect.left + fraction * seriesRect.width}px`,\n        \"--top\": `${seriesRect.top - ARROW_GAP}px`,\n        transform: \"translate(-50%, -100%)\",\n        pointerEvents: \"none\",\n      } as CSSProperties,\n    };\n  });\n\n  return {\n    activeCrosslineOverlayGroups,\n    resolvedCrosslineOverlays,\n    chipSections,\n    hoveredBenchmarkKey,\n    hoveredCrosslineTooltip,\n  };\n}\n","<!--\n  @deprecated This component has moved to tq-site as a local component\n  (src/common/components/DataTableWithChart) and is no longer maintained here. It will be\n  removed from Pit Viper in a future release - migrate any remaining usage to the tq-site\n  component.\n-->\n<script lang=\"ts\">\nimport type { AgChartOptions } from \"ag-charts-types\";\nimport {\n  ChartSeriesAggFuncOption,\n  ChartSeriesAggFuncSelectedEvent,\n  ColumnConfigurationChangeEvent,\n  OptionWithFormatterAndDataType,\n  PvDataTableWithChartProps,\n  StackField,\n  supportedChartType,\n} from \"./types\";\nimport {\n  histogramChartTypeConfig,\n  mapChartTypeConfig,\n  MAP_REGION_FIELD,\n  multiGroupChartTypeConfigs,\n  singleGroupChartTypeConfigs,\n} from \"./constants\";\nimport { getChartTypeConfig, retainValidXAxisFields } from \"./chartTypeRegistry\";\nimport { FocusUpdateEvent } from \"@/components/tables/PvDataTable/types\";\nimport {\n  ActiveChartFilterOptionKey,\n  ActiveChartKey,\n  ChartTypeKey,\n  FirstDataRenderedKey,\n  RowGroupColumnsKey,\n  SortTypesKey,\n} from \"@/components/tables/symbols\";\n</script>\n\n<script setup lang=\"ts\" generic=\"T\">\nimport PvDataTable from \"@tables/PvDataTable/PvDataTable.vue\";\nimport PvButton from \"@/components/base/PvButton/PvButton.vue\";\nimport PvIcon from \"@/components/base/PvIcon/PvIcon.vue\";\nimport PvPagination from \"@/components/base/PvPagination/PvPagination.vue\";\nimport PvChart from \"@charts/PvChart/PvChart.vue\";\nimport PvMapChart, { type PvMapChartData } from \"@charts/PvMapChart/PvMapChart.vue\";\nimport PvTableOptionsPanel from \"@charts/PvDataTableWithChart/table-chart-components/PvTableOptionsPanel.vue\";\nimport PvBenchmarkChips from \"@charts/PvDataTableWithChart/table-chart-components/PvBenchmarkChips.vue\";\nimport { computed, getCurrentInstance, nextTick, onBeforeMount, onMounted, provide, Ref, ref, watch } from \"vue\";\nimport {\n  AdvancedFilterModel,\n  Column,\n  ColumnMovedEvent,\n  ColumnResizedEvent,\n  ColumnRowGroupChangedEvent,\n  FilterChangedEvent,\n  FilterModel,\n  IRowNode,\n  ValueFormatterFunc,\n  ValueFormatterParams,\n} from \"ag-grid-enterprise\";\nimport {\n  ColDef,\n  ColumnValueChangedEvent,\n  ColumnVO,\n  FirstDataRenderedEvent,\n  GridApi,\n  GridReadyEvent,\n  RefreshServerSideParams,\n  SortChangedEvent,\n} from \"ag-grid-community\";\nimport PvChartOptionsPanel from \"@charts/PvDataTableWithChart/table-chart-components/PvChartOptionsPanel.vue\";\nimport { MenuOption } from \"@/types\";\nimport type {\n  AgAreaSeriesOptions,\n  AgAxisLabelFormatterParams,\n  AgBarSeriesOptions,\n  AgCartesianAxisPosition,\n  AgCartesianChartOptions,\n  AgCartesianSeriesOptions,\n  AgLineSeriesOptions,\n  AgPieSeriesOptions,\n  AgSeriesTooltipRendererParams,\n  Formatter,\n} from \"ag-charts-enterprise\";\nimport { multicolorFills, SCATTER_MARKER_STROKE } from \"@charts/themes\";\nimport { buildScatterAxes } from \"./scatterAxisUtils\";\nimport { ColDefDataType, truncateValue } from \"@tables/PvDataTable/table-components/formatting\";\nimport {\n  BUCKET_AGG_COUNT_VALUE_NAME,\n  distributionRangeMaxCategory,\n  distributionRangeMinCategory,\n  SECONDARY_AXIS_INTERVAL_COUNT,\n  padEndValue,\n  padStartValue,\n  separatorValue,\n  sortTotalSuffix,\n} from \"@charts/PvDataTableWithChart/constants\";\nimport {\n  ActiveSeriesKey,\n  ActiveSecondarySeriesKey,\n  ActiveSecondarySeriesListKey,\n  ActiveSortKey,\n  ActiveCrosslineOverlayGroupsKey,\n  AvailableRowGroupColumnsKey,\n  AvailableSeriesKey,\n  AvailableSecondarySeriesKey,\n  AvailableCrosslineOverlayGroupsKey,\n  FilterStoreKey,\n  FocusStoreKey,\n  GridApiKey,\n  MetricOverlayMultiSelectKey,\n} from \"@/components/tables/symbols\";\nimport { useFilterStore } from \"@tables/PvDataTable/useFilterStore\";\nimport {\n  colDefContext,\n  isColDefNumericDataType,\n  mapColsToColumnV0,\n  processRowGroupCols,\n} from \"@/components/tables/PvDataTable/helpers\";\nimport { cleanInitialGridState, mapFilterBasedOnColDef } from \"@/components/tables/PvDataTable/filters/filterHelpers\";\nimport {\n  ChartStateChangedEvent,\n  FilterValueResponseOption,\n  PvDataTablePivot,\n  PvDataTablePublicInterface,\n} from \"@tables/PvDataTable/types\";\nimport { ServerSideChartDataHandlerParams } from \"@charts/PvDataTableWithChart/types\";\nimport { createFocusStore } from \"@tables/PvDataTable/useFocus\";\nimport {\n  buildCategoryAxisLabelFormatter,\n  buildStackedChartData,\n  calculateMaxChartSeriesValue,\n  calculateMinChartSeriesValue,\n  generateStackSecondaryCategoryKey,\n  generateStackSeriesKey,\n  computeNoDataOverlayText,\n  isAvailableSecondarySeriesColDef,\n  isChronologicalColDef,\n  getSecondarySeriesKey,\n  niceAxisCeiling,\n  niceAxisRange,\n  padSingleCategoryBarData,\n  paginatePivotedStackValuesByTotal,\n  sortChartDataChronologically,\n} from \"@charts/PvDataTableWithChart/helpers\";\nimport {\n  DEFAULT_CROSSLINE_OVERLAY_COLOR,\n  getCrosslineAxisDomain,\n  scaleValueToIndex,\n} from \"@charts/PvDataTableWithChart/crosslineHelpers\";\nimport { useBenchmarkOverlays } from \"@charts/PvDataTableWithChart/useBenchmarkOverlays\";\nimport { useSlotPresence } from \"@/composables/useSlotPresence\";\nimport { NULL_PLACEHOLDER_VALUE } from \"@charts/PvChart/constants\";\nimport {\n  getChartScrollContentStyle,\n  getChartScrollOverflowStyle,\n  getScrollableChartMinHeight,\n} from \"@charts/widgetOptions\";\nimport { isEqual } from \"es-toolkit\";\n\nconst props = withDefaults(defineProps<PvDataTableWithChartProps<T>>(), {\n  initialGridState: () => ({}),\n  displayBaseAggregationsOnly: false,\n  displayRowNumber: true,\n  displayGroupCount: true,\n  displayPreferencesIcon: false,\n  enableColumnVisibilitySelector: true,\n  enableCsvExport: false,\n  enableFocusView: false,\n  enableGroupBySelector: (p) => !p.filterPanelAboveChart,\n  enableVerticalFilterPanel: true,\n  showSeriesLabels: true,\n  truncateLabelValues: true,\n  requireFiltersToShowData: false,\n  rowGroupLimit: 2,\n  maxHorizontalFilters: 6,\n  initialChartCollapsed: false,\n  filterPanelAboveChart: false,\n  filterPanelReadOnly: false,\n  disableUnselectedReadOnlyFilters: false,\n  chartConfigPanelReadOnly: false,\n  enableChartScrolling: true,\n  enableTopSlot: true,\n  enabledChartTypes: () => [\"column\", \"bar\", \"column_stacked\", \"bar_stacked\", \"line\", \"area\"],\n  initialStackValuesPageIndex: 0,\n  chartType: \"column\" as supportedChartType,\n  secondaryChartType: \"scatter\" as supportedChartType,\n  metricOverlayWithRowGroups: false,\n  lockedRowGroupOptions: () => [],\n  suppressMetricOverlays: false,\n  fitPrimaryAxisToLineData: false,\n  yKey: \"\",\n  percentOfFocusViewYKey: \"\",\n  enableCombinedChartConfigPanel: false,\n  enableNestedChartConfigPanel: false,\n  chartConfigPanelOptions: () => [\"sort\", \"chart-type\"],\n  maintainColumnOrder: true,\n  enableAdvancedFilter: false,\n  displayAdvancedFilterQueryBuilder: false,\n  refreshFiltersInBackground: false,\n  stageFilterChangesUntilDropdownCloses: false,\n  focusText: \"Focus\",\n  focusRequired: false,\n});\n\nconst emit = defineEmits<{\n  (e: \"chart-state-changed\", event: ChartStateChangedEvent): void;\n  (e: \"column-moved\", event: ColumnMovedEvent<T>): void;\n  (e: \"column-resized\", event: ColumnResizedEvent<T>): void;\n  (e: \"column-row-group-changed\", event: ColumnRowGroupChangedEvent<T>): void;\n  (e: \"column-value-changed\", event: ColumnValueChangedEvent<T>): void;\n  (e: \"grid-ready\", event: GridReadyEvent<T>): void;\n  (e: \"filter-changed\", event: FilterChangedEvent<T>): void;\n  (e: \"sort-changed\", event: SortChangedEvent<T>): void;\n  (e: \"filter-opened\", event: FilterChangedEvent<T>): void;\n  (e: \"first-data-rendered\", event: FirstDataRenderedEvent<T>): void;\n  (e: \"handle-settings-icon\", value: string): void;\n  (e: \"focus-update\", event: FocusUpdateEvent): void;\n  (e: \"chart-collapsed\", collapsed: boolean): void;\n  (e: \"table-overlay-change\", selectedIds: string[]): void;\n  (e: \"active-overlay-group-ids-change\", ids: string[]): void;\n  /** Fired when the user navigates to a different page of stack values (see stackValuesPageSize). */\n  (e: \"stack-values-page-changed\", pageIndex: number): void;\n}>();\n\nconst gridApi = ref(null as GridApi | null);\nconst pvDataTableRef = ref<PvDataTablePublicInterface | null>(null);\nconst pvChartRef = ref<InstanceType<typeof PvChart> | null>(null);\nconst pvMapChartRef = ref<InstanceType<typeof PvMapChart> | null>(null);\nconst chartCollapsed = ref<boolean>(props.initialChartCollapsed ?? false);\nconst filterPanelLocationId = \"filter-panel-\" + getCurrentInstance()?.uid;\nconst shouldTeleportFilterPanel = ref(false);\nconst { present: hasFilterPanelActions } = useSlotPresence(\"filter-panel-actions\");\nconst filterPanelActionsEnabled = computed(() => props.filterPanelAboveChart && hasFilterPanelActions.value);\nconst displayChartLoading = ref(false);\nconst chartRequestId = ref(0);\nconst DATA_TABLE_CHART_MIN_HEIGHT_PX = 450;\nconst DATA_TABLE_CHART_SCROLL_ITEM_HEIGHT_PX = 64;\n// Maps read best with more vertical room than the cartesian charts, so give the\n// map view a taller fixed height (no zoom/pan - it just renders larger).\nconst DATA_TABLE_MAP_CHART_HEIGHT_PX = 600;\n// Approximate width of the PvBenchmarkChips column, reserved from the chart's min-width.\nconst BENCHMARK_CHIPS_RESERVED_WIDTH_PX = 255;\n\nconst availableRowGroupColumns = computed(() => {\n  const colDefs = pvDataTableRef.value?.availableRowGroupColumns || [];\n  return colDefs;\n});\n\n// the row group columns we're currently charting against\nconst currentRowGroupColumns = ref<string[]>([]);\n\nconst activeCategory = computed(() => {\n  return currentRowGroupColumns.value.length > 0 ? currentRowGroupColumns.value[0] : \"\";\n});\n\nconst getSeriesDisplayNameFromColDef = (colDef: ColDef) => {\n  const context = colDefContext(colDef);\n  return context.chartSeriesDisplayName || colDef.headerName || colDef.field || \"\";\n};\n\nconst activeSeriesAggFuncs = ref<Record<string, string>>({});\n\nconst activeAggFuncForColDef = (colDef: ColDef): string | undefined => {\n  const field = colDef.field;\n  if (!field) return undefined;\n  return activeSeriesAggFuncs.value[field] ?? (typeof colDef.aggFunc === \"string\" ? colDef.aggFunc : undefined);\n};\n\nconst chartSeriesAggFuncOptions = (\n  colDef: ColDef,\n  seriesValue: (aggFunc: string) => string,\n): ChartSeriesAggFuncOption[] | undefined => {\n  if (!colDef.allowedAggFuncs?.length) return undefined;\n  const context = colDefContext(colDef);\n  return colDef.allowedAggFuncs.map((aggFunc) => ({\n    aggFunc,\n    description: context.aggFuncDescriptionMap?.[aggFunc],\n    label: context.aggFuncDisplayNameMap?.[aggFunc] ?? aggFunc,\n    order: context.aggFuncOrderMap?.[aggFunc],\n    seriesValue: seriesValue(aggFunc),\n  }));\n};\n\n// With `pivot` on, the table follows the chart: if the x-axis leads with an `enablePivot` column, it pivots across\n// the top, the rest of the x-axis goes down the side, and the measures are the y-axis plus any `pivotValue` columns.\n// Otherwise it's the regular table.\nconst tablePivot = computed<PvDataTablePivot | null>(() => {\n  if (!props.pivot) return null;\n  const [pivotField, ...rowGroupFields] = currentRowGroupColumns.value;\n  const pivotColDef = props.colDefs?.find((colDef) => colDef.field === pivotField);\n  if (!pivotField || !pivotColDef?.enablePivot) return null;\n  const seriesField =\n    availableSeriesColumns.value.find((series) => series.value === activeSeries.value)?.columnField ??\n    activeSeries.value;\n  // Even when hidden from the regular table: the pivot builds its own columns.\n  const pivotValueFields = (props.colDefs ?? [])\n    .filter((colDef) => colDefContext(colDef).pivotValue && colDef.field)\n    .map((colDef) => colDef.field as string);\n  return {\n    rowGroupCols: rowGroupFields,\n    pivotCols: [pivotField],\n    valueCols: [...new Set([seriesField, ...pivotValueFields].filter((field): field is string => Boolean(field)))],\n  };\n});\nconst pivotActive = computed(() => tablePivot.value !== null);\n\n// The inner table's colDefs, with the current pivot set on AG Grid's own props. Other aggFunc columns keep their\n// aggFunc (the chart's y-axis options read it) but are left out of the pivot with `enableValue: false`. Measures\n// come first, in order, since the table shows them in colDef order.\nconst tableColDefs = computed(() => {\n  const pivot = tablePivot.value;\n  if (!pivot || !props.colDefs) return props.colDefs;\n  const indexIn = (fields: string[], field: string | undefined) => (field ? fields.indexOf(field) : -1);\n  const colDefs = props.colDefs.map((colDef) => {\n    const rowGroupIndex = indexIn(pivot.rowGroupCols, colDef.field);\n    const pivotIndex = indexIn(pivot.pivotCols, colDef.field);\n    const isValue = indexIn(pivot.valueCols, colDef.field) !== -1;\n    return {\n      ...colDef,\n      rowGroup: rowGroupIndex !== -1,\n      rowGroupIndex: rowGroupIndex !== -1 ? rowGroupIndex : null,\n      pivot: pivotIndex !== -1,\n      pivotIndex: pivotIndex !== -1 ? pivotIndex : null,\n      aggFunc: isValue ? (colDef.aggFunc ?? \"first\") : colDef.aggFunc,\n      enableValue: isValue,\n    };\n  });\n  const valueOrder = (colDef: ColDef<T>) => {\n    const index = indexIn(pivot.valueCols, colDef.field);\n    return index === -1 ? pivot.valueCols.length : index;\n  };\n  return [...colDefs].sort((a, b) => valueOrder(a) - valueOrder(b));\n});\n\n// The pivot layout is fixed when the grid mounts, so a new layout remounts the table.\nconst pivotKey = computed(() => JSON.stringify(tablePivot.value));\n\nconst availableSeriesColumns = computed(() => {\n  const config = activeChartTypeConfig.value;\n  if (config.yAxis.hidden && config.yAxis.defaultValue) {\n    return [{ label: \"Count\", value: config.yAxis.defaultValue }] as OptionWithFormatterAndDataType[];\n  }\n  const colDefs = pvDataTableRef.value?.availableAggFuncColumns || [];\n  return colDefs\n    .filter((colDef) => {\n      const context = colDefContext(colDef);\n      return !context.hideFromCharting && !context.chartOnSecondaryAxes;\n    })\n    .map((colDef) => {\n      const columnField = colDef.field || \"\";\n      return {\n        activeAggFunc: activeAggFuncForColDef(colDef),\n        aggFuncOptions: chartSeriesAggFuncOptions(colDef, () => columnField),\n        columnField,\n        dataType: colDef.context?.dataType,\n        description: colDef.context?.chartSeriesDescription,\n        formatter: colDef.valueFormatter,\n        label: getSeriesDisplayNameFromColDef(colDef),\n        value: columnField,\n      };\n    }) as OptionWithFormatterAndDataType[];\n});\n\nconst availableSeriesSelectionCount = computed(() =>\n  props.enableCombinedChartConfigPanel && props.enableNestedChartConfigPanel\n    ? availableSeriesColumns.value.reduce((count, series) => count + (series.aggFuncOptions?.length || 1), 0)\n    : availableSeriesColumns.value.length,\n);\n\nconst availableSecondarySeriesColumns = computed(() => {\n  const colDefs = pvDataTableRef.value?.availableAggFuncColumns || [];\n  const rowGroupFields = new Set(currentRowGroupColumns.value);\n  return colDefs\n    .filter((colDef) => isAvailableSecondarySeriesColDef(colDef))\n    .map((colDef) => {\n      const activeAggFunc = activeAggFuncForColDef(colDef);\n      const columnField = colDef.field || \"\";\n      return {\n        activeAggFunc,\n        aggFuncOptions: chartSeriesAggFuncOptions(colDef, (aggFunc) =>\n          getSecondarySeriesKey(columnField, aggFunc, rowGroupFields),\n        ),\n        columnField,\n        dataType: colDef.context?.dataType,\n        description: colDef.context?.chartSeriesDescription,\n        formatter: colDef.valueFormatter,\n        label: getSeriesDisplayNameFromColDef(colDef),\n        secondaryAxisMax: colDef.context?.secondaryAxisMax,\n        tooltipRenderer: colDef.context?.customTooltipRenderer,\n        value: getSecondarySeriesKey(columnField, activeAggFunc, rowGroupFields),\n      };\n    }) as OptionWithFormatterAndDataType[];\n});\n\nconst findSeriesColumn = (seriesOptions: OptionWithFormatterAndDataType[], value: string | undefined) =>\n  seriesOptions.find(\n    (series) => series.value === value || series.aggFuncOptions?.some((option) => option.seriesValue === value),\n  );\n\nconst supplementaryChartingColumns = computed(() => {\n  const colDefs = pvDataTableRef.value?.availableAggFuncColumns || [];\n  return colDefs\n    .filter((colDef) => {\n      const context = colDefContext(colDef);\n      return context.chartOnSecondaryAxes === true && context.hideFromCharting === true;\n    })\n    .map((col) => {\n      const colId = col.field;\n      const colDef = col;\n      return {\n        label: getSeriesDisplayNameFromColDef(colDef),\n        value: colId || \"\",\n        formatter: colDef.valueFormatter,\n        dataType: colDef.context?.dataType,\n      };\n    }) as OptionWithFormatterAndDataType[];\n});\n\n// Use an explicitly provided filter store first, then injected context, then create a private store.\nconst chartFilterStore = props.filterStore || useFilterStore();\nprovide(FilterStoreKey, chartFilterStore);\n\nconst chartFocusStore = createFocusStore(\n  {\n    focusType: props.initialFocusData?.focusType,\n    focuses: props.initialFocusData?.focuses || [],\n    focusRequired: props.focusRequired,\n  },\n  props.allFieldsAreFocusable,\n);\nprovide(FocusStoreKey, chartFocusStore);\nconst { setFilterSelectedValues } = chartFilterStore;\nconst firstDataRendered = ref(false);\nprovide(FirstDataRenderedKey, firstDataRendered);\nconst groupedModeEnabled = ref(props.isTableGrouped);\n\nconst handleTableOverlayChange = (selectedIds: string[]) => {\n  emit(\"table-overlay-change\", selectedIds);\n};\n\nconst shouldShowEmptyChartFilterRenderer = computed(() => {\n  if (shouldShowFocusOverlayText.value) {\n    return false;\n  }\n  return Boolean(\n    props.emptyChartFilterRenderer && props.requireFiltersToShowData && chartFilterStore.filterModelEmpty.value,\n  );\n});\n\nconst focusType = computed(() => {\n  return chartFocusStore?.computedFocusType.value || null;\n});\n\nconst focuses = computed(() => {\n  return chartFocusStore?.computedFocuses.value || [];\n});\n\nconst syncActiveSeriesAggFuncs = (api: GridApi) => {\n  // Pivot grids hold display-only aggFuncs; chart agg funcs are tracked locally.\n  if (pivotActive.value) return;\n  activeSeriesAggFuncs.value = Object.fromEntries(\n    api\n      .getValueColumns()\n      .map((column) => [column.getColId(), column.getAggFunc()])\n      .filter((entry): entry is [string, string] => typeof entry[1] === \"string\"),\n  );\n};\n\n// Display order as of the last column-state emission, so drag-driven chart-state-changed\n// events can report the order they replaced. Only tracked when column configuration is on.\nconst lastOrderedColIds = ref<string[] | null>(null);\n\nconst handleGridReady = (params: GridReadyEvent) => {\n  // set the grid api in the provide so that child components can access it\n  gridApi.value = params.api;\n  syncActiveSeriesAggFuncs(params.api);\n  if (!groupedModeEnabled.value && !pivotActive.value) {\n    gridApi.value?.setRowGroupColumns([]);\n  }\n  if (props.tableConfigOptions?.enableColumnConfiguration) {\n    lastOrderedColIds.value = params.api.getAllGridColumns().map((col) => col.getColId());\n  }\n  processChartData(params.api);\n  emit(\"grid-ready\", params);\n};\n\nconst handleColumnConfigChange = (event: ColumnConfigurationChangeEvent) => {\n  lastOrderedColIds.value = event.orderedColIds;\n  emit(\"chart-state-changed\", {\n    api: gridApi.value,\n    newState: {\n      orderedColIds: event.orderedColIds,\n      hiddenColIds: event.hiddenColIds,\n    },\n    oldState: {\n      orderedColIds: event.previousOrderedColIds,\n      hiddenColIds: event.previousHiddenColIds,\n    },\n  });\n};\n\nconst handleColumnMoved = (event: ColumnMovedEvent<T>) => {\n  emit(\"column-moved\", event);\n  // Finished header drags also flow into chart-state-changed so consumers can persist them;\n  // api-sourced moves (the Columns panel, updateGridState re-applies) are excluded because\n  // their state changes are already emitted through handleColumnConfigChange.\n  if (!props.tableConfigOptions?.enableColumnConfiguration || !event.finished || event.source !== \"uiColumnMoved\") {\n    return;\n  }\n  const orderedColIds = event.api.getAllGridColumns().map((col) => col.getColId());\n  emit(\"chart-state-changed\", {\n    api: gridApi.value,\n    newState: { orderedColIds },\n    oldState: { orderedColIds: lastOrderedColIds.value },\n  });\n  lastOrderedColIds.value = orderedColIds;\n};\n\nconst handleColumnValueChanged = (event: ColumnValueChangedEvent<T>) => {\n  // Overlay selection values embed the active agg func (see getSecondarySeriesKey), so an\n  // agg-func change invalidates them. Capture the selections' column fields before syncing,\n  // then re-resolve each to its new value.\n  const selectedSecondarySeries = findSeriesColumn(availableSecondarySeriesColumns.value, activeSecondarySeries.value);\n  const selectedSecondaryColumnFields = activeSecondarySeriesList.value\n    .map((value) => findSeriesColumn(availableSecondarySeriesColumns.value, value)?.columnField)\n    .filter((columnField): columnField is string => Boolean(columnField));\n  syncActiveSeriesAggFuncs(event.api);\n  if (selectedSecondarySeries?.columnField && activeSecondarySeries.value) {\n    activeSecondarySeries.value = availableSecondarySeriesColumns.value.find(\n      (series) => series.columnField === selectedSecondarySeries.columnField,\n    )?.value;\n  }\n  if (selectedSecondaryColumnFields.length > 0) {\n    activeSecondarySeriesList.value = selectedSecondaryColumnFields\n      .map(\n        (columnField) =>\n          availableSecondarySeriesColumns.value.find((series) => series.columnField === columnField)?.value,\n      )\n      .filter((value): value is string => Boolean(value));\n  }\n  stackValuesPageIndex.value = 0;\n  processChartData(event.api);\n  emit(\"column-value-changed\", event);\n};\n\nconst handleSeriesAggFuncSelected = (event: ChartSeriesAggFuncSelectedEvent) => {\n  const api = gridApi.value;\n  if (pivotActive.value) {\n    activeSeriesAggFuncs.value = { ...activeSeriesAggFuncs.value, [event.columnField]: event.aggFunc };\n    if (api) processChartData(api);\n    return;\n  }\n  if (!api || api.getColumn(event.columnField)?.getAggFunc() === event.aggFunc) return;\n  api.applyColumnState({\n    state: [{ colId: event.columnField, aggFunc: event.aggFunc }],\n  });\n};\n\nconst handleFirstDataRendered = (params: FirstDataRenderedEvent<T>) => {\n  emit(\"first-data-rendered\", params);\n};\n\nconst handleRowGroupChanged = (event: ColumnRowGroupChangedEvent<T>) => {\n  // pivot row groups aren't chart state\n  if (pivotActive.value) return;\n  // if grouped mode is enabled and the row group columns have changed, update the currentRowGroupColumns\n  const currentRowGroupCols = currentRowGroupColumns.value;\n  const newRowGroupCols = event.api.getRowGroupColumns().map((col) => col.getColId());\n  if (groupedModeEnabled.value && JSON.stringify(currentRowGroupCols) !== JSON.stringify(newRowGroupCols)) {\n    const config = activeChartTypeConfig.value;\n    if (newRowGroupCols.length > effectiveRowGroupLimit.value) {\n      const limited = newRowGroupCols.slice(0, effectiveRowGroupLimit.value);\n      currentRowGroupColumns.value = limited;\n      event.api.setRowGroupColumns(limited);\n    } else {\n      currentRowGroupColumns.value = newRowGroupCols;\n    }\n    // if this chart type has a default y-axis value, set it\n    if (config.yAxis.defaultValue) {\n      activeSeries.value = config.yAxis.defaultValue;\n    }\n  }\n\n  emit(\"column-row-group-changed\", event);\n};\n\nconst handleFilterChanged = async (params: FilterChangedEvent<T>) => {\n  stackValuesPageIndex.value = 0;\n  processChartData(params.api);\n  if (firstDataRendered.value) {\n    emit(\"filter-changed\", params);\n  }\n};\n\nwatch(\n  () => currentRowGroupColumns.value,\n  () => {\n    // if the table is in grouped mode, update the groupings\n    // Defer grid API calls to next tick to avoid AG Grid error #252 (calling API during render)\n    if (pivotActive.value) {\n      // the pivot owns the grid's row groups\n    } else if (groupedModeEnabled.value) {\n      if (!gridApi.value) return;\n      // skip if the rows are already set\n      const currentCols = gridApi.value.getRowGroupColumns().map((col) => col.getColId());\n      if (JSON.stringify(currentCols) !== JSON.stringify(currentRowGroupColumns.value)) {\n        nextTick(() => {\n          gridApi.value?.setRowGroupColumns(currentRowGroupColumns.value);\n        });\n      }\n    } else {\n      nextTick(() => {\n        gridApi?.value?.setRowGroupColumns([]);\n      });\n    }\n    // if we don't want all columns to be focusable, update the focus type to match the first grouping column, if any\n    // chart types that don't support focus view should not set a focus type\n    if (!props.allFieldsAreFocusable) {\n      const newFocusType = !activeChartTypeConfig.value.supportsFocusView ? null : activeCategory.value || null;\n      chartFocusStore.setFocusType(newFocusType);\n    }\n\n    if (gridApi.value) {\n      stackValuesPageIndex.value = 0;\n      processChartData(gridApi.value);\n    }\n  },\n);\n\nfunction wrapValueFormatter(\n  field: string,\n  originalFormatter: ValueFormatterFunc | null,\n  truncateValues: boolean = true,\n) {\n  return (params: ValueFormatterParams) => {\n    //inject data into the params object by matching against the field name and value\n    params.data = chartData.value?.find((item) => item[field] === params.value);\n    // skip if null placeholder value\n    if (params.value === NULL_PLACEHOLDER_VALUE) {\n      return \"\";\n    }\n    let suffix = \"\";\n    const colDef = getColDefForField(field);\n    // only truncate if we're requesting it, the param is true, and the data type is numeric\n    const shouldTruncate = props.truncateLabelValues && truncateValues && colDef && isColDefNumericDataType(colDef);\n    if (shouldTruncate && !isNaN(Number(params.value))) {\n      // if stacked, calculate ratio of value relative to other sections, to determine if we need to hide the label\n      if (isStackedChart.value) {\n        // @ts-expect-error datum is not defined in ValueFormatterParams, but is available in the context of the chart\n        const currentCategory = params.datum?.[activeCategory.value];\n        const data = stackedChartData.value?.find((item) => item[activeCategory.value] === currentCategory);\n        // get ratio relative to the sort total, and don't display a label if it's less than 5% of the total\n        const sortTotal = data?.[`${activeSeries.value}${sortTotalSuffix}`] || Infinity;\n        const currentValueRatio = params.value / sortTotal;\n        if (currentValueRatio < 0.05) {\n          return \"\";\n        }\n      }\n      const { newValue, newSuffix } = truncateValue(\n        params.value,\n        ColDefDataType.Percent === colDefContext(colDef).dataType,\n        maxChartSeriesValue.value,\n      );\n      params.value = newValue;\n      suffix = newSuffix;\n    }\n    let result = params.value;\n    if (originalFormatter) {\n      result = originalFormatter(params);\n    }\n    return result + suffix;\n  };\n}\n\nconst getFormatterForColField = (field: string | undefined, truncateValues: boolean = false) => {\n  if (!field) return undefined;\n  const col = getColDefForField(field);\n  if (col && typeof col.valueFormatter === \"function\") {\n    return wrapValueFormatter(field, col.valueFormatter, truncateValues);\n  }\n  return wrapValueFormatter(field, null, truncateValues);\n};\n\nconst getColDefForField = (field: string | undefined): ColDef<T> | null => {\n  if (!field || !gridApi.value) {\n    return null;\n  }\n  return gridApi.value?.getColumnDef(field);\n};\n\n// AG Charts' default tooltip prints raw numbers (7576.98 — no grouping, no currency), so series\n// without a custom renderer format their value through the same column formatter the table uses\n// (pass-through when the column has none), with the category label formatted like the axis.\n// `valueKey` is the datum key holding the series value (differs from `formatterField` for\n// stacked/grouped series).\nconst defaultSeriesTooltip = (valueKey: string, formatterField: string) => {\n  const valueFormatter = getFormatterForColField(formatterField);\n  if (typeof valueFormatter !== \"function\") return undefined;\n  return {\n    renderer: (params: { datum?: Record<string, unknown> }) => {\n      const datum = params.datum ?? {};\n      const rawValue = datum[valueKey];\n      if (rawValue == null) {\n        return { content: \"\" };\n      }\n      const categoryFormatter = getFormatterForColField(activeCategory.value);\n      const rawCategory = datum[activeCategory.value];\n      const categoryLabel =\n        typeof categoryFormatter === \"function\"\n          ? categoryFormatter({ value: rawCategory } as ValueFormatterParams)\n          : String(rawCategory ?? \"\");\n      return { content: `${categoryLabel}: ${valueFormatter({ value: rawValue } as ValueFormatterParams)}` };\n    },\n  } as NonNullable<AgCartesianSeriesOptions[\"tooltip\"]>;\n};\n\n// A date column on the x-axis is always plotted oldest to newest - ordering a\n// timeline by its series value would make the chart unreadable - so the chart\n// sort selection is ignored (and cleared, below) while one is active.\nconst isChronologicalCategoryAxis = computed(() => {\n  return isChronologicalColDef(getColDefForField(activeCategory.value));\n});\n\nconst formatBucketRange = (bucketMin: number, bucketMax: number): string => {\n  const col = getColDefForField(activeCategory.value);\n  if (col && typeof col.valueFormatter === \"function\") {\n    const minStr = col.valueFormatter({ value: bucketMin } as ValueFormatterParams);\n    const maxStr = col.valueFormatter({ value: bucketMax } as ValueFormatterParams);\n    return `${minStr} - ${maxStr}`;\n  }\n  return `${bucketMin} - ${bucketMax}`;\n};\n\nconst formatBucketBoundary = (value: number): string => {\n  const col = getColDefForField(activeCategory.value);\n  if (col && typeof col.valueFormatter === \"function\") {\n    return col.valueFormatter({ value } as ValueFormatterParams);\n  }\n  return `${value}`;\n};\n\nconst chartTypes = computed(() => {\n  const configs = currentRowGroupColumns.value.length > 1 ? multiGroupChartTypeConfigs : singleGroupChartTypeConfigs;\n  // Histogram and Map are always offered (subject to `enabledChartTypes`), the\n  // same way the histogram is: selecting Map forces a region x-axis instead of\n  // the option only appearing once a region column is already the x-axis.\n  const allConfigs = [...configs, histogramChartTypeConfig, mapChartTypeConfig];\n  return allConfigs.filter((chartType) => props.enabledChartTypes?.includes(chartType.id as supportedChartType));\n});\n\nconst activeChartType = ref<MenuOption | undefined>(undefined);\n\n// Memory refs to track last used chart type for each grouping level\nconst lastSingleGroupChartType = ref<string | undefined>(undefined);\nconst lastMultiGroupChartType = ref<string | undefined>(undefined);\n// Track previous grouping level so the chartTypes watcher can detect transitions from single <--> multi.\nlet prevIsMultiGroup = false;\n\nconst activeChartTypeConfig = computed(() => getChartTypeConfig(activeChartType.value?.id || \"\"));\n\nconst effectiveRowGroupLimit = computed(() => {\n  return Math.min(activeChartTypeConfig.value.rowGroupLimit, props.rowGroupLimit);\n});\n\nconst chartTypeFilteredRowGroupColumns = computed(() => {\n  const filterFn = activeChartTypeConfig.value.xAxis.filterColumns;\n  const columns = filterFn ? filterFn(availableRowGroupColumns.value) : availableRowGroupColumns.value;\n  const order = props.rowGroupOptionOrder;\n  if (!order || order.length === 0) {\n    return columns;\n  }\n  // Stable sort: listed colIds take their list position, unlisted ones keep their existing\n  // relative order after the listed block.\n  const rank = (field: string | undefined) => {\n    const index = field ? order.indexOf(field) : -1;\n    return index === -1 ? Number.MAX_SAFE_INTEGER : index;\n  };\n  return [...columns].sort((a, b) => rank(a.field) - rank(b.field));\n});\n\nconst sortTypes: Ref<MenuOption[]> = ref([\n  {\n    text: \"Ascending\",\n    id: \"asc\",\n    icon: \"arrow-up-wide-narrow\",\n  },\n  {\n    text: \"Descending\",\n    id: \"desc\",\n    icon: \"arrow-down-narrow-wide\",\n  },\n]);\n\nconst chartData: Ref<AgChartOptions[\"data\"]> = ref([]);\nconst stackedChartData: Ref<AgChartOptions[\"data\"]> = ref([]);\nconst activeSeries = ref(props.yKey);\nconst activeSecondarySeries = ref<string | undefined>(availableSecondarySeriesColumns.value[0]?.value);\n// Multi-select metric overlay mode: selections live in this list instead of activeSecondarySeries.\nconst activeSecondarySeriesList = ref<string[]>([]);\nconst metricOverlayMultiSelect = computed(() => props.multiSelectMetricOverlay === true);\n\n// The overlay series values currently charted, regardless of picker mode. All series/axis\n// logic below is driven off this list; single-select mode is just a 0-or-1 entry list.\n// suppressMetricOverlays empties it without touching the picker state, so overlays come\n// back with their previous selections once the caller drops the flag.\nconst activeSecondarySeriesFields = computed<string[]>(() => {\n  if (props.suppressMetricOverlays) {\n    return [];\n  }\n  if (metricOverlayMultiSelect.value) {\n    return activeSecondarySeriesList.value;\n  }\n  return activeSecondarySeries.value ? [activeSecondarySeries.value] : [];\n});\n\n// Locked row-group colIds are enforced as active: prepend any locked id missing from the\n// current groups (in locked order), so a caller can drive a structural breakout reactively.\n// The currentRowGroupColumns watcher below emits chart-state-changed, so the enforced\n// grouping persists exactly like a picker change.\nwatch(\n  () => props.lockedRowGroupOptions.map((option) => option.id),\n  (lockedIds, previousLockedIds) => {\n    const locked = lockedIds ?? [];\n    // Symmetric enforcement: an id the caller stops locking also leaves the grouping — it was\n    // forced in, so it's forced out (e.g. the Drug breakout while 2+ drugs are selected). If\n    // the user manually re-adds it afterwards it stays, since it's no longer locked.\n    const unlocked = (previousLockedIds ?? []).filter((id) => !locked.includes(id));\n    const current = currentRowGroupColumns.value.filter((id) => !unlocked.includes(id));\n    if (locked.every((id) => current.includes(id)) && current.length === currentRowGroupColumns.value.length) {\n      return;\n    }\n    // Runtime-only (no immediate): the initial grouping comes from initialGridState in\n    // onBeforeMount, and an emit here before the grid mounts would hand consumers a\n    // chart-state-changed event with no grid API.\n    // Locked ids take the front of the list; unlocked ids keep whatever room the row-group\n    // limit leaves. Without the slice, enforcing a new locked id on top of an existing\n    // breakout pushes the grouping past the limit (e.g. Month + Drug + Provider), which the\n    // chart pivot can't render.\n    const merged = [...locked, ...current.filter((id) => !locked.includes(id))];\n    currentRowGroupColumns.value = merged.slice(0, Math.max(effectiveRowGroupLimit.value, locked.length));\n  },\n);\n\n// Preselect initialSecondaryYKeys (multi-select mode) once overlay columns first resolve —\n// they aren't available at setup because the grid hasn't mounted yet.\nlet initialSecondaryYKeysApplied = false;\nwatch(\n  availableSecondarySeriesColumns,\n  (columns) => {\n    if (\n      initialSecondaryYKeysApplied ||\n      !metricOverlayMultiSelect.value ||\n      !props.initialSecondaryYKeys?.length ||\n      columns.length === 0\n    ) {\n      return;\n    }\n    initialSecondaryYKeysApplied = true;\n    const wanted = new Set(props.initialSecondaryYKeys);\n    activeSecondarySeriesList.value = columns\n      .filter((column) => wanted.has(column.columnField ?? \"\") || wanted.has(column.value))\n      .map((column) => column.value);\n  },\n  { immediate: true },\n);\n\n// Crossline overlay groups: track which are toggled on. The rest of the benchmark-chip /\n// crossLine-overlay hover feature (active groups, resolved overlays, chips, hover tooltip) is\n// wired up by useBenchmarkOverlays() once its dependencies further down are ready - see below.\nconst crosslineOverlayGroups = computed(() => props.crosslineOverlayGroups ?? []);\nconst activeStackField = ref<StackField | null>(null); // used for stacked charts, if applicable\n// Which page of stack values (see stackValuesPageSize) is currently shown, when a\n// high-cardinality stack field is paged rather than rendered all at once.\nconst stackValuesPageIndex = ref(props.initialStackValuesPageIndex ?? 0);\n// Pagination summary for the current stack field, so the UI can show \"showing N-M of X\"\n// and page controls instead of silently only rendering some values (see helpers.ts\n// paginateStackValuesByTotal). Null when the stack field isn't paginated.\nconst stackValuesPagination = ref<{ total: number; pageCount: number } | null>(null);\nconst activeSort = ref<MenuOption | undefined>(sortTypes.value.find((type) => type.id === props.initialSort || \"\"));\nconst activeChartFilterOption = ref<string>(\"\");\n\nprovide(GridApiKey, gridApi);\nprovide(ActiveChartFilterOptionKey, activeChartFilterOption);\nprovide(AvailableRowGroupColumnsKey, chartTypeFilteredRowGroupColumns);\nprovide(RowGroupColumnsKey, currentRowGroupColumns);\nprovide(ChartTypeKey, chartTypes);\nprovide(SortTypesKey, sortTypes);\nprovide(ActiveChartKey, activeChartType);\nprovide(ActiveSortKey, activeSort);\nprovide(ActiveSeriesKey, activeSeries);\nprovide(AvailableSeriesKey, availableSeriesColumns);\nprovide(ActiveSecondarySeriesKey, activeSecondarySeries);\nprovide(ActiveSecondarySeriesListKey, activeSecondarySeriesList);\nprovide(AvailableSecondarySeriesKey, availableSecondarySeriesColumns);\nprovide(MetricOverlayMultiSelectKey, metricOverlayMultiSelect);\nprovide(AvailableCrosslineOverlayGroupsKey, crosslineOverlayGroups);\n\n// A chronological x-axis owns the ordering outright, so drop any sort selection\n// that would otherwise reappear when the user moves back to a non-date x-axis.\nwatch(\n  isChronologicalCategoryAxis,\n  (chronological) => {\n    if (chronological && activeSort.value) {\n      activeSort.value = undefined;\n    }\n  },\n  { immediate: true },\n);\n\nconst setActiveChartType = (newValue: string) => {\n  const chartTypeOption = chartTypes.value.find((type) => type.id === newValue);\n  activeChartType.value = chartTypeOption ?? chartTypes.value[0];\n};\n\nconst getCompatibleChartTypeId = (preferredTypeId?: string) => {\n  const rowGroupCount = currentRowGroupColumns.value.length;\n  const supportsCurrentRowGroupCount = (type: MenuOption) => {\n    const config = getChartTypeConfig(type.id);\n    return rowGroupCount <= Math.min(config.rowGroupLimit, props.rowGroupLimit);\n  };\n  const preferredType = chartTypes.value.find((type) => type.id === preferredTypeId);\n  if (preferredType && supportsCurrentRowGroupCount(preferredType)) {\n    return preferredType.id;\n  }\n  return chartTypes.value.find(supportsCurrentRowGroupCount)?.id ?? chartTypes.value[0]?.id;\n};\n\nwatch(\n  () => chartTypes.value,\n  () => {\n    const isMulti = isMultiGroupChart.value;\n    const groupLevelChanged = isMulti !== prevIsMultiGroup;\n    const currentConfig = getChartTypeConfig(activeChartType.value?.id || \"\");\n    const currentStillValid = chartTypes.value.some((t) => t.id === activeChartType.value?.id);\n    const currentExceedsRowGroupLimit =\n      currentRowGroupColumns.value.length > Math.min(currentConfig.rowGroupLimit, props.rowGroupLimit);\n\n    prevIsMultiGroup = isMulti;\n\n    // If the current type is still valid in the new list, keep it UNLESS the grouping\n    // level changed AND this is a storable chart type. Also fall back when the\n    // current type can't support the selected number of x-axes (e.g. active Map\n    // while adding Provider as a second x-axis after State), so we don't truncate\n    // the new x-axis just because Map remains selectable.\n    if (currentStillValid && !currentExceedsRowGroupLimit && (!groupLevelChanged || !currentConfig.storeBeforeChange)) {\n      return;\n    }\n\n    // Grouping level changed (for a normal chart type) or current type is no longer valid.\n    const lastSelectedChartType = isMulti ? lastMultiGroupChartType?.value : lastSingleGroupChartType?.value;\n    const fallbackChartType = getCompatibleChartTypeId(lastSelectedChartType ?? props.chartType);\n    if (fallbackChartType) {\n      setActiveChartType(fallbackChartType);\n    }\n  },\n);\n\nwatch(\n  () => props.chartType,\n  (newValue) => setActiveChartType(newValue),\n);\n\nwatch(\n  () => props.yKey,\n  (newValue) => {\n    if (newValue === activeSeries.value) {\n      return;\n    }\n    activeSeries.value = newValue;\n  },\n);\n\n// A changed page size invalidates the current page (e.g. 20 -> 10 shifts what page 1\n// even means), so reset to page 0 rather than recompute all pages.\nwatch(\n  () => props.stackValuesPageSize,\n  () => {\n    stackValuesPageIndex.value = 0;\n    if (gridApi.value) {\n      processChartData(gridApi.value);\n    }\n  },\n);\n\nwatch(activeChartFilterOption, (newValue) => {\n  if (props.chartFilter && gridApi.value) {\n    const colId = props.chartFilter.colId;\n    let filterValues = props.chartFilter.options.find((option) => option.value === newValue)?.filterValues || null;\n    if (filterValues && filterValues.length === 0) {\n      filterValues = null;\n    }\n    setFilterSelectedValues(colId, filterValues || []);\n    // TODO - update this to account for the potential that the filter is NOT a set filter\n    const setFilter = {\n      filterType: \"set\",\n      values: filterValues,\n    };\n    const newFilter = mapFilterBasedOnColDef(setFilter, getColDefForField(colId));\n    gridApi.value.setColumnFilterModel(colId, newFilter).then(() => {\n      gridApi.value?.onFilterChanged();\n    });\n  }\n});\n\nconst seriesDisplayName = (series: OptionWithFormatterAndDataType | undefined) => series?.label ?? \"\";\n\nconst activeSeriesDisplayName = computed(() =>\n  seriesDisplayName(findSeriesColumn(availableSeriesColumns.value, activeSeries.value)),\n);\n\n// Explicit note for when stackValuesPageSize is paging the stack field, so it's clear why\n// only some values are on the chart at once — see stackValuesPagination.\nconst stackValuesCapMessage = computed(() => {\n  const pagination = stackValuesPagination.value;\n  if (!pagination) return null;\n  const stackFieldLabel = getColDefForField(activeStackField.value?.fieldName)?.headerName || \"values\";\n  const seriesLabel = activeSeriesDisplayName.value || \"value\";\n  const pageSize = props.stackValuesPageSize || pagination.total;\n  const startIndex = stackValuesPageIndex.value * pageSize + 1;\n  const endIndex = Math.min(startIndex + pageSize - 1, pagination.total);\n  return `Showing ${startIndex}–${endIndex} of ${pagination.total} ${stackFieldLabel} by ${seriesLabel}.`;\n});\n\n// Stand-in legend for the currently paginated stack values, since AG Charts' own legend is\n// hidden while paginated (see options.legend.enabled) - matches series color by array\n// position the same way AG Charts' theme palette does (see cartesianSeries).\nconst paginatedStackValuesLegend = computed(() => {\n  if (!stackValuesPagination.value) return [];\n  const formatter = getFormatterForColField(activeStackField.value?.fieldName, true);\n  return (activeStackField.value?.fieldValues ?? []).map((fieldValue, index) => ({\n    key: fieldValue,\n    label:\n      typeof formatter === \"function\" ? String(formatter({ value: fieldValue } as ValueFormatterParams)) : fieldValue,\n    color: multicolorFills[index % multicolorFills.length],\n  }));\n});\n\nconst goToStackValuesPage = (newIndex: number) => {\n  if (!gridApi.value || newIndex === stackValuesPageIndex.value) return;\n  stackValuesPageIndex.value = newIndex;\n  emit(\"stack-values-page-changed\", newIndex);\n  processChartData(gridApi.value);\n};\n\n// Overlays whose colDef context sets `chartOverlayOnPrimaryAxis` bind to the primary (left)\n// y-axis instead of the shared secondary axis — but only while their dataType matches the\n// active primary metric's. Same-unit overlays (e.g. dollar benchmarks over a dollar rate)\n// then read on one honest scale; when the primary metric switches to a different unit\n// (e.g. a percentage), the overlay falls back to the secondary benchmark axis automatically.\nconst isPrimaryAxisOverlayField = (field: string): boolean => {\n  const overlayColumn = findSeriesColumn(availableSecondarySeriesColumns.value, field);\n  const columnField = overlayColumn?.columnField ?? field;\n  if (getColDefForField(columnField)?.context?.chartOverlayOnPrimaryAxis !== true) return false;\n  const primaryColumn = findSeriesColumn(availableSeriesColumns.value, activeSeries.value);\n  return overlayColumn?.dataType != null && overlayColumn.dataType === primaryColumn?.dataType;\n};\nconst secondaryOnlyOverlayFields = computed(() =>\n  activeSecondarySeriesFields.value.filter((field) => !isPrimaryAxisOverlayField(field)),\n);\nconst primaryAxisOverlayFields = computed(() =>\n  activeSecondarySeriesFields.value.filter((field) => isPrimaryAxisOverlayField(field)),\n);\n\n// One secondary axis serves all active overlays; its title lists their names.\nconst secondaryAxisTitle = computed(() =>\n  secondaryOnlyOverlayFields.value\n    .map((field) => seriesDisplayName(findSeriesColumn(availableSecondarySeriesColumns.value, field)))\n    .filter(Boolean)\n    .join(\", \"),\n);\n\nconst isHorizontalBarChart = computed(() => {\n  return activeChartTypeConfig.value.isHorizontal === true;\n});\n\n// Overlay series type. `secondaryChartType: \"line\"` is honored on vertical charts only:\n// scatter handles horizontal orientation via explicit x/y key swapping (see buildScatterAxes),\n// which line series don't support, so horizontal charts always fall back to scatter.\nconst secondaryOverlayChartType = computed<\"scatter\" | \"line\">(() =>\n  props.secondaryChartType === \"line\" && !isHorizontalBarChart.value ? \"line\" : \"scatter\",\n);\n\nconst stackedChartEnabled = computed(() => {\n  return currentRowGroupColumns.value.length > 1;\n});\n\nconst chartSeries = computed(() => {\n  if (!activeChartType.value) {\n    return [];\n  }\n  if (availableSeriesColumns.value.length === 0) {\n    return [];\n  }\n  const config = activeChartTypeConfig.value;\n  if (config.seriesFamily === \"pie\") {\n    return pieSeries.value;\n  }\n  // cartesian family (bar, line, area, histogram, etc.)\n  return cartesianSeries.value;\n});\n\nconst displaySeriesLabels = computed(() => {\n  // Histogram bars never show their count label; the bucket counts are on the y-axis.\n  if (activeChartType.value?.id === \"histogram\") {\n    return false;\n  }\n  return props.showSeriesLabels;\n});\n\nconst isStackedChart = computed(() => {\n  return activeChartType.value?.id.includes(\"stacked\");\n});\n\nconst isMultiGroupChart = computed(() => currentRowGroupColumns.value.length > 1);\n\n// Check if we're in histogram mode with numeric buckets\nconst isHistogramWithBuckets = computed(() => {\n  return (\n    activeChartType.value?.id === \"histogram\" &&\n    computedChartData.value &&\n    computedChartData.value.length > 0 &&\n    typeof computedChartData.value[0]?.bucketMin === \"number\" &&\n    typeof computedChartData.value[0]?.bucketMax === \"number\"\n  );\n});\n\n// Stable series id for the primary metric. AG Charts' LegendManager keys legend entries by\n// series id and only clears stale entries when the series count or types change. A y-axis\n// switch swaps one same-type series for another (same count), so without a stable id the\n// replacement gets a fresh generated id and the old entry is orphaned — the legend then\n// accumulates one stale item per switch. A stable id makes the replacement overwrite it.\n// For the stacked case, ids are keyed by stack position (index), not by the stack field's\n// value: if the composition of stack values changes but the count doesn't (e.g. a filter\n// swaps in a different top-N group), AG Charts still sees a same-count/same-type series set\n// and won't clear stale legend entries, so a value-keyed id would reproduce the same orphaned-\n// entry bug this fix targets. Position-keyed ids stay stable across that case too — only the\n// series' yName (the visible legend label) changes.\nconst PRIMARY_SERIES_ID = \"primary-series\";\n\n// The stable-id fix above covers a same-count series swap, but AG Charts' legend also fails to\n// clear when the primary-series COUNT itself changes (e.g. toggling a row-group breakout):\n// ids shift between \"primary-series\" and \"primary-series-0..N\", and the stale entries are\n// never dropped from LegendManager's map. Remounting on count change resets AG's internal\n// state instead of relying on its own clearing heuristic.\nconst chartInstanceKey = computed(() => {\n  const groupCount = stackedChartEnabled.value ? (activeStackField.value?.fieldValues.length ?? 0) : 1;\n  // The mode rides along because a flat chart and a one-group breakout share groupCount 1,\n  // yet swap the whole series id/yKey scheme (PRIMARY_SERIES_ID vs -0..N, plain metric key vs\n  // generateStackSeriesKey) — without a remount, AG Charts' stale legend/series state renders\n  // an empty chart on that transition.\n  const mode = stackedChartEnabled.value ? \"grouped\" : \"flat\";\n  return `${activeChartType.value?.id ?? \"chart\"}-${mode}-${groupCount}`;\n});\n\nconst cartesianSeries = computed(() => {\n  const isStacked = isStackedChart.value;\n  const chartType = activeChartTypeConfig.value.agChartType;\n  let series: AgCartesianSeriesOptions[] = [];\n  const seriesFormatter = getFormatterForColField(activeSeries.value, true);\n  const stackFieldFormatter = getFormatterForColField(activeStackField.value?.fieldName, true);\n  // Line series labels have no placement option - AG Charts warns and ignores it.\n  const labelPlacement = (placement: \"inside-end\" | \"outside-end\") => (chartType === \"line\" ? {} : { placement });\n  if (stackedChartEnabled.value) {\n    const stackField = activeStackField.value;\n    stackField?.fieldValues.forEach((fieldValue: string, index: number) => {\n      const newSeries = {\n        type: chartType,\n        id: `${PRIMARY_SERIES_ID}-${index}`,\n        xKey: activeCategory.value,\n        yKey: generateStackSeriesKey(activeSeries.value, fieldValue),\n        yName:\n          typeof stackFieldFormatter === \"function\"\n            ? stackFieldFormatter({ value: fieldValue } as ValueFormatterParams)\n            : fieldValue,\n        // Line series have no stacking concept - a secondary group renders as one\n        // line per group value, never as a stack.\n        ...(chartType === \"line\" ? {} : { stacked: isStacked }),\n        label: {\n          // A secondary group splits the chart into one line per group value, where a\n          // label on every point of every line is unreadable.\n          enabled: displaySeriesLabels.value && chartType !== \"line\",\n          color: isStacked ? \"white\" : \"black\",\n          fontFamily: \"Inter\",\n          padding: 5,\n          fontSize: 11,\n          ...labelPlacement(isStacked ? \"inside-end\" : \"outside-end\"),\n          formatter: seriesFormatter,\n        },\n        tooltip: defaultSeriesTooltip(generateStackSeriesKey(activeSeries.value, fieldValue), activeSeries.value),\n      } as AgBarSeriesOptions;\n      series.push(newSeries);\n    });\n  } else {\n    const newSeries = {\n      type: chartType,\n      id: PRIMARY_SERIES_ID,\n      xKey: activeCategory.value,\n      yKey: activeSeries.value,\n      yName: activeSeriesDisplayName.value,\n      label: {\n        enabled: displaySeriesLabels.value,\n        color: \"black\",\n        fontFamily: \"Inter\",\n        padding: 5,\n        fontSize: 11,\n        ...labelPlacement(\"outside-end\"),\n        formatter: seriesFormatter,\n      },\n      tooltip: defaultSeriesTooltip(activeSeries.value, activeSeries.value),\n    } as AgBarSeriesOptions;\n    series.push(newSeries);\n  }\n  // options specific to the chart type\n  let extraChartOptions = {} as AgCartesianSeriesOptions;\n  if (chartType === \"bar\") {\n    const options = extraChartOptions as AgBarSeriesOptions;\n    options.direction = isHorizontalBarChart.value ? \"horizontal\" : \"vertical\";\n    extraChartOptions = options;\n  } else if (chartType === \"line\" || chartType === \"area\") {\n    const options = extraChartOptions as AgLineSeriesOptions | AgAreaSeriesOptions;\n    options.connectMissingData = true;\n    extraChartOptions = options;\n  }\n  // Dim the bar series while a benchmark chip is hovered, so its crossLine stands out.\n  const barDimOpacity = hoveredBenchmarkKey.value != null ? { fillOpacity: 0.3, strokeOpacity: 0.3 } : {};\n  series = series.map((item) => {\n    return {\n      ...item,\n      ...extraChartOptions,\n      ...barDimOpacity,\n    } as AgCartesianSeriesOptions;\n  });\n\n  // For histogram-like data with bucket ranges, add tooltip formatting\n  if (activeChartTypeConfig.value.yAxis.defaultValue === BUCKET_AGG_COUNT_VALUE_NAME) {\n    series = series.map(\n      (item) =>\n        ({\n          ...item,\n          tooltip: {\n            renderer: (\n              params: AgSeriesTooltipRendererParams<Record<string, string>> & { xKey: string; yKey: string },\n            ) => {\n              let title = String(params.datum[params.xKey] ?? \"\");\n              const min = params.datum.bucketMin;\n              const max = params.datum.bucketMax;\n              if (typeof min === \"number\" && typeof max === \"number\") {\n                title = formatBucketRange(min, max);\n              }\n              return { title, content: `Count: ${params.datum[params.yKey]}` };\n            },\n          },\n        }) as AgCartesianSeriesOptions,\n    );\n  }\n\n  if (activeSecondarySeriesFields.value.length > 0) {\n    const xCol = getColDefForField(activeCategory.value);\n    const xName = xCol?.context?.metadataDisplayFields?.[0] || activeCategory.value;\n    const overlayType = secondaryOverlayChartType.value;\n\n    for (const overlayField of activeSecondarySeriesFields.value) {\n      const overlayColumn = findSeriesColumn(availableSecondarySeriesColumns.value, overlayField);\n      const overlayDisplayName = seriesDisplayName(overlayColumn);\n      const overlayYKey = !isStacked ? overlayField : `${overlayField}${sortTotalSuffix}`;\n\n      const scatterAxes = buildScatterAxes(\n        activeCategory.value,\n        xName,\n        overlayYKey,\n        overlayDisplayName,\n        isHorizontalBarChart.value,\n      );\n\n      // A line needs two points to draw a segment, so an overlay with a single plottable\n      // value (e.g. the report filtered down to one month) would render nothing with markers\n      // off — show the marker in that case so the benchmark stays visible.\n      const overlayPointCount = (scatterChartData.value ?? []).filter((row) => row[overlayYKey] != null).length;\n\n      const secondarySeriesOptions = {\n        type: overlayType,\n        // Keep the historical id for the single-select overlay; multi-select overlays need\n        // one id per series.\n        id: metricOverlayMultiSelect.value ? `metric-overlay-${overlayField}` : \"metric-overlay\",\n        data: scatterChartData.value,\n        ...scatterAxes,\n        label: {\n          enabled: false,\n        },\n        // Line overlays render as dashed benchmark lines: no point markers (single-point case\n        // aside), and gaps in the benchmark don't break the line.\n        ...(overlayType === \"line\"\n          ? {\n              lineDash: [4, 4],\n              strokeWidth: 2,\n              marker: { enabled: overlayPointCount < 2 },\n              connectMissingData: true,\n            }\n          : {}),\n      } as AgCartesianSeriesOptions;\n\n      if (overlayColumn?.tooltipRenderer) {\n        const originalRenderer = overlayColumn.tooltipRenderer;\n        secondarySeriesOptions[\"tooltip\"] = {\n          // Always call the renderer with canonical keys (category→xKey, metric→yKey)\n          // regardless of chart orientation.\n          renderer: isHorizontalBarChart.value\n            ? (params: Parameters<typeof originalRenderer>[0]) =>\n                originalRenderer({\n                  ...params,\n                  xKey: activeCategory.value,\n                  xName,\n                  yKey: overlayYKey,\n                  yName: overlayDisplayName,\n                })\n            : originalRenderer,\n        };\n      } else {\n        // No custom renderer: fall back to the column-formatter tooltip so benchmark values\n        // render like their table column (currency grouping and precision included).\n        const fallbackTooltip = defaultSeriesTooltip(overlayYKey, overlayField);\n        if (fallbackTooltip) {\n          secondarySeriesOptions[\"tooltip\"] = fallbackTooltip;\n        }\n      }\n\n      series = [...series, secondarySeriesOptions];\n    }\n  }\n\n  // Add invisible scatter series to support numeric x-axis for vertical lines in histogram mode\n  if (isHistogramWithBuckets.value && resolvedCrosslineOverlays.value.length > 0 && computedChartData.value) {\n    const numCategories = computedChartData.value.length;\n    const maxY = Number.isFinite(maxChartSeriesValue.value) ? maxChartSeriesValue.value : 0;\n\n    // Dummy series with data points to establish the numeric axis scale\n    const dummySeries = {\n      type: \"scatter\" as const,\n      xKey: \"__dummy_x__\",\n      yKey: \"__dummy_y__\",\n      data: [\n        { __dummy_x__: -1, __dummy_y__: 0 },\n        { __dummy_x__: numCategories + 1, __dummy_y__: maxY },\n      ],\n      label: {\n        enabled: false,\n      },\n      tooltip: {\n        enabled: false,\n      },\n      visible: false,\n    } as AgCartesianSeriesOptions;\n\n    const OVERLAY_POINTS_PER_LINE = 30;\n\n    // Must match the offset applied to the visible crossLines in computedChartOptions,\n    // or the invisible hover hit-target drifts away from the line.\n    const { categoryPadOffset } = getCrosslineAxisDomain(numCategories, true);\n\n    const verticalOverlaySeries = {\n      type: \"scatter\" as const,\n      xKey: \"__dummy_x__\",\n      yKey: \"__dummy_y__\",\n      data: resolvedCrosslineOverlays.value.flatMap((overlay) => {\n        const scaled = scaleValueToIndex(overlay.value, computedChartData.value || []);\n        if (scaled === null) {\n          return [];\n        }\n        const scaledWithOffset = scaled + categoryPadOffset;\n        const maxY = Number.isFinite(maxChartSeriesValue.value) ? maxChartSeriesValue.value : 0;\n        const formatter = getFormatterForColField(currentRowGroupColumns.value?.[0]);\n        const formattedValue =\n          typeof formatter === \"function\" ? formatter({ value: overlay.value } as ValueFormatterParams) : overlay.value;\n\n        return Array.from({ length: OVERLAY_POINTS_PER_LINE }, (_, i) => ({\n          value: formattedValue,\n          __dummy_x__: scaledWithOffset,\n          __dummy_y__: (maxY / (OVERLAY_POINTS_PER_LINE - 1)) * i,\n          __dummy_overlay_label__: overlay.label,\n          [activeSeries.value]: maxY,\n        }));\n      }),\n      size: 15,\n      fill: \"transparent\",\n      stroke: \"transparent\",\n      strokeWidth: 0,\n      marker: {\n        enabled: false,\n      },\n      itemStyler: () => ({\n        size: 15,\n        fill: \"transparent\",\n        stroke: \"transparent\",\n        strokeWidth: 0,\n      }),\n      label: {\n        enabled: false,\n      },\n      tooltip: {\n        range: 1,\n        renderer: (params: AgSeriesTooltipRendererParams<Record<string, number | string>>) => {\n          const label = String(params.datum.__dummy_overlay_label__ ?? \"\");\n          const value = params.datum.value;\n          return `<div class=\"pv-flex pv-space-between\" style=\"padding: 8px\">\n            <div class=\"pv-chart-tooltip-label\">${label}</div>\n            <div class=\"pv-chart-tooltip-value\">${value}</div>\n          </div>`;\n        },\n      },\n    } as AgCartesianSeriesOptions;\n\n    series = [...series, dummySeries, verticalOverlaySeries];\n  }\n\n  return series;\n});\n\nconst pieSeries = computed(() => {\n  // Pie charts only support a single series\n  if (availableSeriesColumns.value.length === 0) {\n    return [];\n  }\n  const newSeries = {\n    type: \"pie\",\n    legendItemKey: activeCategory.value,\n    angleKey: activeSeries.value,\n  } as AgPieSeriesOptions;\n  return [newSeries];\n});\n\nwatch(activeSeries, (newValue, oldValue) => {\n  emit(\"chart-state-changed\", {\n    api: gridApi.value,\n    newState: {\n      seriesField: newValue,\n    },\n    oldState: {\n      seriesField: oldValue,\n    },\n  });\n});\n\nwatch(activeSecondarySeries, (newValue, oldValue) => {\n  emit(\"chart-state-changed\", {\n    api: gridApi.value,\n    newState: {\n      secondarySeriesField: newValue,\n    },\n    oldState: {\n      secondarySeriesField: oldValue,\n    },\n  });\n});\n\nwatch(activeSecondarySeriesList, (newValue, oldValue) => {\n  emit(\"chart-state-changed\", {\n    api: gridApi.value,\n    newState: {\n      secondarySeriesField: newValue.join(\",\") || undefined,\n    },\n    oldState: {\n      secondarySeriesField: oldValue?.join(\",\") || undefined,\n    },\n  });\n});\n\nwatch(activeChartType, (newValue, oldValue) => {\n  // Keep memory up to date on every chart type change (panel selection, restore, etc.).\n  // Skip memory for chart types that don't have storeBeforeChange (e.g. histogram).\n  if (newValue?.id) {\n    const cfg = getChartTypeConfig(newValue.id);\n    if (cfg.storeBeforeChange) {\n      if (isMultiGroupChart.value) {\n        lastMultiGroupChartType.value = newValue.id;\n      } else {\n        lastSingleGroupChartType.value = newValue.id;\n      }\n    }\n  }\n\n  const newConfig = getChartTypeConfig(newValue?.id || \"\");\n  const oldConfig = getChartTypeConfig(oldValue?.id || \"\");\n\n  // If the x-axis column filter changed (different chart family), drop only the row\n  // group columns that aren't valid under the new chart type's x-axis filter. This\n  // keeps a still-valid x-axis (e.g. `state` when switching into/out of the map\n  // chart type) instead of clearing it and losing the selection. Always enforce\n  // the new chart type's row group limit too, since map/histogram only support a\n  // single x-axis even when switching from a multi-group chart.\n  const retainedRowGroupColumns =\n    newConfig.xAxis.filterColumns !== oldConfig.xAxis.filterColumns\n      ? retainValidXAxisFields(\n          currentRowGroupColumns.value,\n          availableRowGroupColumns.value,\n          newConfig.xAxis.filterColumns,\n        )\n      : currentRowGroupColumns.value;\n  const limitedRowGroupColumns = retainedRowGroupColumns.slice(\n    0,\n    Math.min(newConfig.rowGroupLimit, props.rowGroupLimit),\n  );\n  // The map has nothing to plot without a region x-axis, so default to `state` when none carried over.\n  if (\n    newConfig.seriesFamily === \"map\" &&\n    limitedRowGroupColumns.length === 0 &&\n    chartTypeFilteredRowGroupColumns.value.some((col) => col.field === MAP_REGION_FIELD)\n  ) {\n    limitedRowGroupColumns.push(MAP_REGION_FIELD);\n  }\n  if (!isEqual(limitedRowGroupColumns, currentRowGroupColumns.value)) {\n    currentRowGroupColumns.value = limitedRowGroupColumns;\n  }\n\n  // If new config has a default y-axis value, set activeSeries to it\n  if (newConfig.yAxis.defaultValue) {\n    activeSeries.value = newConfig.yAxis.defaultValue;\n  } else if (oldConfig.yAxis.defaultValue && !newConfig.yAxis.defaultValue) {\n    // Transitioning away from a type with default y-axis: reset to props.yKey or first available\n    nextTick(() => {\n      if (props.yKey) {\n        activeSeries.value = props.yKey;\n      } else if (availableSeriesColumns.value.length > 0) {\n        activeSeries.value = availableSeriesColumns.value[0].value;\n      }\n    });\n  }\n\n  emit(\"chart-state-changed\", {\n    api: gridApi.value,\n    newState: {\n      chartType: newValue?.id,\n    },\n    oldState: {\n      chartType: oldValue?.id,\n    },\n  });\n});\n\n// Auto-select x-axis when only one option is available and none currently selected\nwatch(chartTypeFilteredRowGroupColumns, (newColumns) => {\n  if (newColumns.length === 1 && currentRowGroupColumns.value.length === 0) {\n    const field = newColumns[0].field;\n    if (field) {\n      currentRowGroupColumns.value = [field];\n    }\n  }\n});\n\n// Auto-select y-axis when only one option is available and none currently selected\nwatch(availableSeriesColumns, (newColumns) => {\n  if (newColumns.length === 1 && !activeSeries.value) {\n    activeSeries.value = newColumns[0].value;\n  }\n});\n\nwatch(activeSort, (newValue, oldValue) => {\n  emit(\"chart-state-changed\", {\n    api: gridApi.value,\n    newState: {\n      chartSort: newValue?.id,\n    },\n    oldState: {\n      chartSort: oldValue?.id,\n    },\n  });\n});\n\nwatch(currentRowGroupColumns, (newValue, oldValue) => {\n  emit(\"chart-state-changed\", {\n    api: gridApi.value,\n    newState: {\n      chartCategoryFields: newValue,\n    },\n    oldState: {\n      chartCategoryFields: oldValue,\n    },\n  });\n});\n\nwatch(groupedModeEnabled, (newValue, oldValue) => {\n  emit(\"chart-state-changed\", {\n    api: gridApi.value,\n    newState: {\n      tableGrouped: newValue,\n    },\n    oldState: {\n      tableGrouped: oldValue,\n    },\n  });\n});\n\n/*\n * Need this watcher in case the table grouping changes outside of the \"toggle\" button.\n */\nwatch(\n  () => props.isTableGrouped,\n  (newVal, oldVal) => {\n    if (!gridApi.value || newVal === oldVal || !props.enableGroupingToggle) {\n      return;\n    }\n\n    // Toggle the grouping based on the new value.\n    toggleGroupState(newVal);\n  },\n);\n\nwatch(\n  () => props.initialFocusData,\n  (newVal, oldVal) => {\n    // If the old and new focuses/focus types are the same skip——nothing's changed.\n    if (isEqual(newVal?.focuses, oldVal?.focuses) && newVal?.focusType == oldVal?.focusType) {\n      return;\n    }\n\n    // If there's no focusType (e.g. navigating to a page in browser history with no focuses), clear our focuses and\n    // end early.\n    if (!newVal?.focusType) {\n      chartFocusStore.setFocuses([]);\n      return;\n    }\n\n    chartFocusStore.setFocusType(newVal?.focusType);\n    chartFocusStore.setFocuses(newVal?.focuses ?? []);\n  },\n  { deep: true },\n);\n\nconst clearChartData = () => {\n  chartData.value = [];\n  stackedChartData.value = [];\n  activeStackField.value = null;\n  stackValuesPagination.value = null;\n};\n\nconst processServerSideData = (data: AgChartOptions[\"data\"], stackField: string) => {\n  if (!data || data.length === 0) {\n    clearChartData();\n    return;\n  }\n  if (stackField) {\n    // metricOverlayWithRowGroups: carry the overlay columns' plain per-category values through\n    // the pivot (the supplementary pass-through copies row[field] as-is), so overlay series can\n    // chart them alongside the per-group series keys.\n    const supplementaryColumns = props.metricOverlayWithRowGroups\n      ? [...supplementaryChartingColumns.value, ...availableSecondarySeriesColumns.value]\n      : supplementaryChartingColumns.value;\n    const {\n      stackedData,\n      uniqueFieldValues,\n      totalStackValueCount,\n      stackValuesPageCount,\n      stackValuesPageIndex: clampedPageIndex,\n    } = buildStackedChartData(\n      data,\n      activeCategory.value,\n      stackField,\n      allSeriesColumns.value,\n      supplementaryColumns,\n      activeSeries.value,\n      props.stackValuesPageSize,\n      stackValuesPageIndex.value,\n    );\n    stackedChartData.value = stackedData;\n    activeStackField.value = {\n      fieldName: stackField,\n      fieldValues: uniqueFieldValues,\n    };\n    // Sync back if the requested page was out of range (e.g. the data shrank).\n    if (clampedPageIndex !== stackValuesPageIndex.value) {\n      stackValuesPageIndex.value = clampedPageIndex;\n    }\n    stackValuesPagination.value =\n      stackValuesPageCount > 1 ? { total: totalStackValueCount, pageCount: stackValuesPageCount } : null;\n  } else {\n    stackedChartData.value = [];\n    activeStackField.value = null;\n    stackValuesPagination.value = null;\n  }\n  chartData.value = data;\n};\n\nconst processChartData = (api: GridApi) => {\n  const currentRequestId = ++chartRequestId.value;\n  const groupLevels = currentRowGroupColumns.value.length;\n  // clear chart data to avoid overlapping data in visualizations\n  clearChartData();\n  displayChartLoading.value = false;\n  if (groupLevels === 0 || availableSeriesColumns.value.length === 0) {\n    // if no groups, collect no data\n    return;\n  }\n  // if no filters and we require filters to show data, don't collect any data\n  if (props.requireFiltersToShowData && chartFilterStore.filterModelEmpty.value) {\n    return;\n  }\n  if (props.serverSideChartHandler) {\n    // Use the filter store as the source of truth — PvDataTable always updates it\n    // before emitting filter-changed. When the store is null (handleGridReady, before\n    // any filter change), fall back to the initial grid state's filter model.\n    let filterModel = chartFilterStore.filterModel.value;\n    const colDefs = gridApi.value?.getColumnDefs() || [];\n    if (filterModel === null && props.initialGridState) {\n      const cleanedState = cleanInitialGridState(props.initialGridState, colDefs, props.enableAdvancedFilter);\n      filterModel =\n        (props.enableAdvancedFilter ? cleanedState?.filter?.advancedFilterModel : cleanedState?.filter?.filterModel) ||\n        {};\n    }\n    filterModel = filterModel || {};\n    // use the currentRowGroupColumns since the table may not be in grouped mode\n    const rowGroupCols = mapColsToColumnV0(\n      currentRowGroupColumns.value\n        .map((colId) => {\n          return gridApi.value?.getColumn(colId);\n        })\n        .filter((colDef) => colDef !== undefined) as Column[],\n    );\n    const processedRowGroupCols = processRowGroupCols(rowGroupCols, colDefs);\n    // only send the value cols that are actually being used in the chart, to avoid unnecessary processing in the handler\n    // always include all secondary axis columns (including hideFromCharting ones like total_codes)\n    // so switching overlay doesn't require a re-fetch\n    const secondaryColIds = new Set(\n      colDefs\n        .filter((cd) => colDefContext(cd).chartOnSecondaryAxes === true)\n        .map((cd) => (cd as ColDef).field)\n        .filter(Boolean),\n    );\n    const isActiveValueCol = (colId: string) => colId === activeSeries.value || secondaryColIds.has(colId);\n    const valueCols: ColumnVO[] = pivotActive.value\n      ? (pvDataTableRef.value?.availableAggFuncColumns || [])\n          .filter((colDef) => colDef.field && isActiveValueCol(colDef.field))\n          .map((colDef) => ({\n            id: colDef.field!,\n            field: colDef.field!,\n            displayName: colDef.headerName || \"\",\n            aggFunc: activeAggFuncForColDef(colDef),\n          }))\n      : mapColsToColumnV0(gridApi.value?.getValueColumns().filter((col) => isActiveValueCol(col.getColId())) || []);\n    const chartHandlerParams: ServerSideChartDataHandlerParams = {\n      rowGroupCols: processedRowGroupCols || [],\n      valueCols,\n      filterModel: filterModel,\n    };\n    displayChartLoading.value = true;\n    props\n      .serverSideChartHandler(chartHandlerParams)\n      .then((result) => {\n        // Only process the result if this is still the latest request\n        if (currentRequestId === chartRequestId.value) {\n          processServerSideData(result.data, result.stackField);\n          displayChartLoading.value = false;\n        }\n      })\n      .catch((error) => {\n        // Only handle errors for the latest request\n        if (currentRequestId === chartRequestId.value) {\n          console.error(\"Chart handler error:\", error);\n          displayChartLoading.value = false;\n        }\n      });\n    return;\n  }\n  if (props.serverSideRowHandler) return;\n  const data = [] as AgChartOptions[\"data\"];\n  const stackData = [] as AgChartOptions[\"data\"];\n  let uniqueFieldValues = new Set<string>();\n  // get grouped row data\n  api.forEachNodeAfterFilterAndSort((rowNode: IRowNode<T>) => {\n    if (rowNode.group && rowNode.level === 0) {\n      if (currentRowGroupColumns.value.length > 1) {\n        // for stacked charts, we need to aggregate the sub-fields separately\n        const childNodes =\n          rowNode.childrenAfterFilter?.filter((childNode: IRowNode<T>) => childNode.level === 1 && childNode.aggData) ||\n          [];\n        const { rowData, fieldValues } = getStackedChartDataFromRowNodes(rowNode, childNodes);\n        uniqueFieldValues = uniqueFieldValues.union(fieldValues);\n        stackData?.push(rowData);\n      }\n      // always collect the base aggregate info\n      const rowData = getChartDataFromRowNode(rowNode) as Record<string, string | number | null>;\n      data?.push(rowData);\n    }\n  });\n  chartData.value = data;\n  if (currentRowGroupColumns.value.length > 1 && stackData && stackData.length > 0) {\n    const stackField = currentRowGroupColumns.value[1] || \"\";\n    const page = paginatePivotedStackValuesByTotal(\n      stackData,\n      Array.from(uniqueFieldValues),\n      allSeriesColumns.value,\n      activeSeries.value,\n      props.stackValuesPageSize,\n      stackValuesPageIndex.value,\n    );\n    stackedChartData.value = page.data;\n    activeStackField.value = {\n      fieldName: stackField,\n      fieldValues: page.orderedLabels,\n    };\n    // Sync back if the requested page was out of range (e.g. the data shrank).\n    if (page.pageIndex !== stackValuesPageIndex.value) {\n      stackValuesPageIndex.value = page.pageIndex;\n    }\n    stackValuesPagination.value = page.pageCount > 1 ? { total: page.total, pageCount: page.pageCount } : null;\n  } else {\n    stackedChartData.value = [];\n    activeStackField.value = null;\n    stackValuesPagination.value = null;\n  }\n};\n\nconst allSeriesColumns = computed(() => {\n  const primary = availableSeriesColumns.value;\n  const secondary = availableSecondarySeriesColumns.value;\n\n  return [...new Map([...secondary, ...primary].map((col) => [col.value, col])).values()];\n});\n\n// the aggregate chart data for all series fields, not separated by any secondary groupings\nconst getChartDataFromRowNode = (rowNode: IRowNode<T>) => {\n  const rowData: Record<string, string | number | null> = {\n    [rowNode.field as string]: rowNode.key,\n  };\n  for (const field of allSeriesColumns.value) {\n    if (!rowNode.aggData || !rowNode.aggData[field.value]) {\n      // If there is no aggregated data for this field, skip it\n      continue;\n    }\n    rowData[field.value] = rowNode.aggData[field.value]?.value ?? rowNode.aggData[field.value];\n  }\n  return rowData;\n};\n\nconst getStackedChartDataFromRowNodes = (parentNode: IRowNode<T>, rowNodes: IRowNode<T>[]) => {\n  const uniqueFieldValues = new Set<string>();\n  const rowData: Record<string, string | number | null> = {\n    [parentNode.field as string]: parentNode.key,\n  };\n  let sortTotal = 0;\n  for (const field of availableSeriesColumns.value) {\n    rowNodes.forEach((childNode) => {\n      const stackField = childNode.key;\n      uniqueFieldValues.add(stackField as string);\n      const stackValueAggData = childNode.aggData;\n      if (stackField && stackValueAggData) {\n        const stackFieldKey = String(stackField);\n        const secondaryCategoryKey = generateStackSecondaryCategoryKey(stackFieldKey);\n        rowData[secondaryCategoryKey] = `${parentNode.key}-${stackFieldKey}`;\n        const aggValue = childNode.aggData[field.value]?.value ?? childNode.aggData[field.value];\n        rowData[generateStackSeriesKey(field.value, stackFieldKey)] = aggValue;\n        sortTotal = sortTotal + aggValue;\n      }\n    });\n    rowData[`${field.value}${sortTotalSuffix}`] = sortTotal;\n  }\n  return {\n    rowData: rowData,\n    fieldValues: uniqueFieldValues,\n  };\n};\n\nconst computedChartData = computed(() => {\n  // if stacked chart is enabled, return the stacked chart data\n  let outputData = stackedChartEnabled.value ? stackedChartData.value : chartData.value;\n  let sortField = null;\n\n  if (activeSort.value) {\n    sortField = stackedChartEnabled.value ? `${activeSeries.value}${sortTotalSuffix}` : activeSeries.value;\n  }\n  // a date x-axis is always ordered oldest to newest, whatever the chart sort says\n  if (isChronologicalCategoryAxis.value) {\n    outputData = sortChartDataChronologically(outputData, activeCategory.value);\n  } else if (sortField && outputData && activeSort.value) {\n    const direction = activeSort.value?.id.includes(\"desc\") ? -1 : 1;\n    outputData = [...outputData].sort((a, b) => {\n      const aValue = a[sortField] || 0;\n      const bValue = b[sortField] || 0;\n      return (aValue - bValue) * direction;\n    });\n  }\n  // Pad single-category bar charts so the lone bar isn't full-width. Uses sentinel\n  // categories that never collide with a real (possibly blank) category - see\n  // padSingleCategoryBarData.\n  if (activeChartTypeConfig.value.agChartType === \"bar\") {\n    outputData = padSingleCategoryBarData(outputData, activeCategory.value);\n  }\n  // for focus data, prioritize the focus element to the front and add a separator after the focused items\n  // Explicitly track focus changes to ensure this computed runs when focuses are updated\n  if (props.enableFocusView && outputData && focuses.value.length > 0 && focusType.value) {\n    const focusedItems = outputData?.filter((item) => focuses.value.includes(item[activeCategory.value] as string));\n    const nonFocusedItems = outputData?.filter((item) => !focuses.value.includes(item[activeCategory.value] as string));\n    // add focus-separator-category to the data to create a visual separator between focused and non-focused items\n    outputData = [...(focusedItems || []), { [activeCategory.value]: separatorValue }, ...(nonFocusedItems || [])];\n  }\n  return outputData;\n});\n\n// Benchmark-chip / crossLine-overlay hover feature: active groups, resolved overlays, the\n// chips rendered beside the chart, and the chip-hover tooltip lookalike.\nconst {\n  activeCrosslineOverlayGroups,\n  resolvedCrosslineOverlays,\n  chipSections,\n  hoveredBenchmarkKey,\n  hoveredCrosslineTooltip,\n} = useBenchmarkOverlays({\n  crosslineOverlayGroups,\n  isHistogramWithBuckets,\n  isHorizontalBarChart,\n  computedChartData,\n  pvChartRef,\n  formatValue: (value: number) => {\n    const formatter = getFormatterForColField(currentRowGroupColumns.value?.[0]);\n    return typeof formatter === \"function\" ? formatter({ value } as ValueFormatterParams) : value;\n  },\n  initialActiveOverlayGroupIds: computed(() => props.initialActiveOverlayGroupIds),\n});\nprovide(ActiveCrosslineOverlayGroupsKey, activeCrosslineOverlayGroups);\nwatch(activeCrosslineOverlayGroups, (ids) => emit(\"active-overlay-group-ids-change\", [...ids]), { deep: true });\n\nconst PAD_CATEGORIES = new Set([padStartValue, padEndValue]);\n\n// --- Map chart support -----------------------------------------------------\n// When the \"map\" chart type is active (only possible while a state/region column\n// is the x-axis), the chart renders PvMapChart instead of PvChart.\nconst selectedMapRegion = ref<string | undefined>(undefined);\n\n// Map is its own rendering mode: whenever the Map type is active we render\n// PvMapChart, never PvChart. Gating on the x-axis (e.g. requiring a single region\n// column) would let an empty or multi-column x-axis fall through to PvChart with\n// the map's `map-shape` series in cartesian options, which is invalid. When the\n// x-axis isn't a single region column the map just renders empty instead.\nconst isMapView = computed(() => activeChartType.value?.id === \"map\");\n\nconst mapSeriesKey = computed(() => activeSeries.value || availableSeriesColumns.value[0]?.value || \"value\");\n\nconst mapChartHeight = computed(() => `${DATA_TABLE_MAP_CHART_HEIGHT_PX}px`);\n\n// Reshape the charted rows into the { state, [series]: value } shape PvMapChart\n// expects, dropping the padding/separator categories used by the cartesian charts.\nconst mapChartData = computed<PvMapChartData[]>(() => {\n  const category = activeCategory.value;\n  const seriesField = mapSeriesKey.value;\n  if (!category || !seriesField) return [];\n  return (computedChartData.value ?? [])\n    .filter((row) => {\n      const region = String(row?.[category] ?? \"\");\n      return !PAD_CATEGORIES.has(region) && region !== separatorValue;\n    })\n    .map((row) => ({\n      [MAP_REGION_FIELD]: String(row[category] ?? \"\"),\n      [seriesField]: Number(row[seriesField] ?? 0),\n    })) as PvMapChartData[];\n});\n\nconst mapGradientRange = computed(() => {\n  const seriesField = mapSeriesKey.value;\n  if (!seriesField) return { min: 0, max: 0 };\n  let hasValue = false;\n  let min = Infinity;\n  let max = -Infinity;\n  mapChartData.value.forEach((row) => {\n    const value = Number(row[seriesField]);\n    if (!Number.isFinite(value)) return;\n    hasValue = true;\n    min = Math.min(min, value);\n    max = Math.max(max, value);\n  });\n  return hasValue ? { min, max } : { min: 0, max: 0 };\n});\n\nconst mapSeriesValueFormatter = computed<(value: number) => string>(() => {\n  const colDef = getColDefForField(mapSeriesKey.value);\n  const formatter = colDef?.valueFormatter;\n  if (typeof formatter === \"function\") {\n    return (value: number) => String(formatter({ value } as ValueFormatterParams) ?? value);\n  }\n  return (value: number) => value.toLocaleString(\"en-US\");\n});\n\nconst scatterChartData = computed(() => {\n  const data = computedChartData.value ?? [];\n  const filtered = data.filter((row) => {\n    const x = row?.[activeCategory.value];\n    return !PAD_CATEGORIES.has(String(x));\n  });\n\n  // For stacked charts, _sort_total sums values across stack segments. This is\n  // correct for SUM metrics (e.g. utilization) but wrong for AVG metrics (e.g.\n  // rate score) where we need the average across segments, not the sum.\n  if (!stackedChartEnabled.value || activeSecondarySeriesFields.value.length === 0 || !activeStackField.value) {\n    return filtered;\n  }\n  const fieldsNeedingAverage = activeSecondarySeriesFields.value.filter((secondaryField) => {\n    const colDef = getColDefForField(secondaryField);\n    const aggFunc = typeof colDef?.aggFunc === \"string\" ? colDef.aggFunc : \"\";\n    return aggFunc !== \"sum\";\n  });\n  if (fieldsNeedingAverage.length === 0) {\n    return filtered;\n  }\n  const fieldValues = activeStackField.value.fieldValues;\n  return filtered.map((row) => {\n    const corrected = { ...row };\n    for (const secondaryField of fieldsNeedingAverage) {\n      const sortTotalKey = `${secondaryField}${sortTotalSuffix}`;\n      const total = row[sortTotalKey];\n      if (typeof total !== \"number\") continue;\n      let count = 0;\n      for (const fv of fieldValues) {\n        if (typeof row[generateStackSeriesKey(secondaryField, String(fv))] === \"number\") {\n          count++;\n        }\n      }\n      corrected[sortTotalKey] = count > 0 ? total / count : null;\n    }\n    return corrected;\n  });\n});\n\nconst categoryCount = computed(() => {\n  return computedChartData.value?.length || 0;\n});\n\nconst chartScrollingEnabled = computed(() => props.enableChartScrolling);\n\nconst effectiveChartMinHeight = computed(() =>\n  getScrollableChartMinHeight({\n    baseMinHeight: DATA_TABLE_CHART_MIN_HEIGHT_PX,\n    dataCount: categoryCount.value,\n    enableChartScrolling: chartScrollingEnabled.value,\n    isHorizontalScrollingChart: isHorizontalBarChart.value,\n    itemHeight: DATA_TABLE_CHART_SCROLL_ITEM_HEIGHT_PX,\n  }),\n);\n\nconst chartScrollContainerStyle = computed(() => {\n  const overflow = getChartScrollOverflowStyle({\n    enableChartScrolling: chartScrollingEnabled.value,\n    isHorizontalScrollingChart: isHorizontalBarChart.value,\n  });\n\n  if (!overflow) return undefined;\n  if (!isHorizontalBarChart.value) return overflow;\n\n  return { ...overflow, maxHeight: `${DATA_TABLE_CHART_MIN_HEIGHT_PX}px` };\n});\n\nconst chartContentStyle = computed(() =>\n  getChartScrollContentStyle({\n    chartMinHeight: effectiveChartMinHeight.value,\n    dataCount: categoryCount.value,\n    enableChartScrolling: chartScrollingEnabled.value,\n    isHorizontalScrollingChart: isHorizontalBarChart.value,\n    minContentWidth: 0,\n    reserveWidth: chipSections.value.length > 0 ? BENCHMARK_CHIPS_RESERVED_WIDTH_PX : 0,\n  }),\n);\n\n// stacked charts sum series per category, so max/min calculations need the\n// pre-stacked totals rather than the raw per-row data\nconst effectiveChartSeriesData = computed(() => {\n  return stackedChartEnabled.value ? stackedChartData.value : computedChartData.value;\n});\n\n// track the largest value on the chart, useful for determining scale of bars relative to the current axis\nconst maxChartSeriesValue = computed(() => {\n  return calculateMaxChartSeriesValue(effectiveChartSeriesData.value, activeSeries.value, stackedChartEnabled.value);\n});\n\n// largest value on the secondary series — used to derive a shared interval count\n// so the secondary y-axis gridlines align with the primary axis. All active\n// overlays share the one secondary axis, so this is the max across all of them.\nconst maxSecondarySeriesValue = computed(() => {\n  return secondaryOnlyOverlayFields.value.reduce(\n    (max, field) =>\n      Math.max(max, calculateMaxChartSeriesValue(effectiveChartSeriesData.value, field, stackedChartEnabled.value)),\n    -Infinity,\n  );\n});\n\n// Largest value among overlays pinned to the primary axis — folded into the primary axis\n// ceiling so an overlay spike (e.g. a raw-rate outlier exceeding the smoothed series' max)\n// isn't clipped when the axes are grid-aligned against a secondary axis.\nconst maxPrimaryOverlayValue = computed(() => {\n  return primaryAxisOverlayFields.value.reduce(\n    (max, field) =>\n      Math.max(max, calculateMaxChartSeriesValue(effectiveChartSeriesData.value, field, stackedChartEnabled.value)),\n    -Infinity,\n  );\n});\n\n// Smallest value among overlays pinned to the primary axis — folded into the primary axis's\n// fitted floor (see niceAxisRange below) so an overlay dipping under the main series (e.g. a\n// raw-rate outlier below the smoothed line) isn't clipped.\nconst minPrimaryOverlayValue = computed(() => {\n  return primaryAxisOverlayFields.value.reduce(\n    (min, field) =>\n      Math.min(min, calculateMinChartSeriesValue(effectiveChartSeriesData.value, field, stackedChartEnabled.value)),\n    Infinity,\n  );\n});\n\n// Min/max across the primary axis's INDIVIDUAL series values. The stacked-mode calculators\n// above measure the per-category sortTotal SUM — correct for stacked bars (the axis must fit\n// the stack height) but wrong for a row-group breakout line chart, whose lines are the\n// individual group values: fitting the axis to the sum floats every line below the floor.\nconst primaryLineSeriesExtent = computed(() => {\n  const data = effectiveChartSeriesData.value ?? [];\n  // Stacked rows key each group's value as `<metric>_<groupValue>` (generateStackSeriesKey),\n  // matching the per-group series yKeys — the plain group value is not a row key.\n  const keys = stackedChartEnabled.value\n    ? (activeStackField.value?.fieldValues ?? []).map((fieldValue) =>\n        generateStackSeriesKey(activeSeries.value, fieldValue),\n      )\n    : [activeSeries.value];\n  let min = Infinity;\n  let max = -Infinity;\n  for (const row of data) {\n    for (const key of keys) {\n      const value = row?.[key];\n      if (typeof value === \"number\") {\n        if (value < min) min = value;\n        if (value > max) max = value;\n      }\n    }\n  }\n  return { min, max };\n});\n\n// smallest values on each series — negative data on either axis means we can't\n// share a zero-based grid, so we fall back to independent scales + hidden\n// secondary gridlines instead of forcing the axes to misalign\nconst minChartSeriesValue = computed(() => {\n  return calculateMinChartSeriesValue(effectiveChartSeriesData.value, activeSeries.value, stackedChartEnabled.value);\n});\n\nconst minSecondarySeriesValue = computed(() => {\n  return secondaryOnlyOverlayFields.value.reduce(\n    (min, field) =>\n      Math.min(min, calculateMinChartSeriesValue(effectiveChartSeriesData.value, field, stackedChartEnabled.value)),\n    Infinity,\n  );\n});\n\nconst barCount = computed(() => {\n  return activeStackField.value?.fieldValues?.length || 0;\n});\n\nconst categoryAxesPaddingInner = computed(() => {\n  const minPadding = 0.05;\n  const maxPadding = 0.75;\n  const A = 0.25;\n  const B = -0.12;\n  const paddingValue = A * Math.exp(B * categoryCount.value);\n  return Math.min(Math.max(paddingValue, minPadding), maxPadding);\n});\n\nconst categoryAxesPaddingOuter = computed(() => {\n  return barCount.value > 5 ? 0.5 : 1;\n});\n\nconst categoryAxesGroupPaddingInner = computed(() => {\n  return barCount.value > 5 ? 0.25 : 0.1;\n});\n\nconst chartDataEmpty = computed(() => {\n  if (!computedChartData.value || computedChartData.value?.length === 0) {\n    return true;\n  }\n  return (\n    maxChartSeriesValue.value === -Infinity || (stackedChartEnabled.value === true && maxChartSeriesValue.value === 0)\n  );\n});\n\nconst shouldShowFocusOverlayText = computed(() => {\n  return !!(\n    props.enableFocusView &&\n    focusType.value &&\n    focuses.value.length === 0 &&\n    props.percentOfFocusViewYKey &&\n    activeSeries.value &&\n    activeSeries.value === props.percentOfFocusViewYKey\n  );\n});\n\nconst displayGroupByName = computed(() => {\n  const colDef = getColDefForField(focusType.value || \"\");\n  return colDef?.headerName || colDef?.field || \"Compare Field\";\n});\n\nconst noDataOverlayText = computed(() => {\n  return computeNoDataOverlayText({\n    currentRowGroupColumnsLength: currentRowGroupColumns.value.length,\n    shouldShowFocusOverlayText: shouldShowFocusOverlayText.value || (props.focusRequired && focuses.value.length === 0),\n    chartDataEmpty: chartDataEmpty.value,\n    missingFocusText: props.missingFocusText,\n    yAxisName: activeSeriesDisplayName.value,\n    yAxisOptionCount: availableSeriesSelectionCount.value,\n  });\n});\n\n// True when the default \"select a focus\" message (with the inline focus icon) should render,\n// i.e. the focus overlay applies and the caller didn't supply its own missingFocusText. Not\n// gated on chartDataEmpty: a required-but-unselected focus hides the chart data even when data\n// exists, so the prompt must show independent of it (see computeNoDataOverlayText).\nconst showDefaultMissingFocusMessage = computed(() => {\n  return (\n    currentRowGroupColumns.value.length > 0 &&\n    (shouldShowFocusOverlayText.value || (props.focusRequired && focuses.value.length === 0)) &&\n    !props.missingFocusText\n  );\n});\n\nconst shouldHideChartDataForOverlay = computed(() => {\n  return (\n    shouldShowFocusOverlayText.value ||\n    shouldShowEmptyChartFilterRenderer.value ||\n    (!props.isLoading && noDataOverlayText.value !== \"\")\n  );\n});\n\nconst computedChartOptions = computed(() => {\n  const options: AgCartesianChartOptions = {};\n  options.overlays = {\n    noData: {\n      text: \"\",\n    },\n  };\n  // Histogram charts notate the x-axis with the overall lowest min (left) and\n  // highest max (right) bucket bounds. Those are rendered on two blank\n  // categories appended outside the real buckets (rather than on the first/last\n  // bar) so they sit further out from the bars instead of centered on them.\n  const chartData = isHistogramWithBuckets.value\n    ? [\n        { [activeCategory.value]: distributionRangeMinCategory },\n        ...(computedChartData.value ?? []),\n        { [activeCategory.value]: distributionRangeMaxCategory },\n      ]\n    : computedChartData.value;\n\n  options.data = shouldHideChartDataForOverlay.value ? [] : chartData;\n\n  options.legend = {\n    toggleSeries: false,\n    preventHidingAll: true,\n    // Multi-select overlays take per-series palette colors, so the legend is the only\n    // way to tell them (and the primary series) apart on a single-group chart.\n    // When stack values are paginated, AG Charts' own legend would paginate independently\n    // of our page control, producing two disconnected pagers - hide it so ours is the\n    // only navigation for which stack values are showing (see stackValuesCapMessage).\n    enabled:\n      !stackValuesPagination.value &&\n      (currentRowGroupColumns.value.length > 1 ||\n        (metricOverlayMultiSelect.value && activeSecondarySeriesFields.value.length > 0)),\n  };\n\n  const overlayFieldKeys = (overlayField: string): string[] => {\n    if (isStackedChart.value) {\n      return [`${overlayField}${sortTotalSuffix}`];\n    }\n    // metricOverlayWithRowGroups: the overlay charts the field's plain per-category value\n    // (carried through the pivot as a supplementary column), not per-group series keys.\n    if (stackedChartEnabled.value && props.metricOverlayWithRowGroups) {\n      return [overlayField];\n    }\n    if (stackedChartEnabled.value) {\n      return (\n        activeStackField.value?.fieldValues.map((fieldValue) =>\n          generateStackSeriesKey(overlayField, String(fieldValue)),\n        ) || []\n      );\n    }\n    return [overlayField];\n  };\n\n  const primaryAxisKeys = [\n    ...(stackedChartEnabled.value\n      ? activeStackField.value?.fieldValues.map((fieldValue) =>\n          generateStackSeriesKey(activeSeries.value, fieldValue),\n        ) || []\n      : activeSeries.value\n        ? [activeSeries.value]\n        : []),\n    // Overlays pinned to the primary axis share its keys (and thus its scale).\n    ...primaryAxisOverlayFields.value.flatMap(overlayFieldKeys),\n  ];\n\n  const secondaryAxisKeys = secondaryOnlyOverlayFields.value.flatMap(overlayFieldKeys);\n\n  const hideXAxisLabel = activeChartTypeConfig.value.xAxis.hideLabel === true && !isHistogramWithBuckets.value;\n\n  const axes: NonNullable<AgCartesianChartOptions[\"axes\"]> = [];\n\n  // Add categorical x-axis\n  axes.push({\n    type: \"category\",\n    keys: [activeCategory.value],\n    position: isHorizontalBarChart.value ? \"left\" : \"bottom\",\n    crossLines: [\n      {\n        type: \"line\",\n        value: separatorValue,\n        stroke: \"#666666\",\n        strokeWidth: 1,\n        lineDash: [4, 4],\n        strokeOpacity: hoveredBenchmarkKey.value != null ? 0.15 : 0.7,\n      },\n    ],\n    line: { enabled: !isHistogramWithBuckets.value },\n    label: {\n      minSpacing: 10,\n      autoRotate: true,\n      truncate: false,\n      wrapping: \"never\",\n      // Pull the min/max notation in closer to the axis than the default label spacing.\n      ...(isHistogramWithBuckets.value ? { spacing: 2 } : {}),\n      formatter: buildCategoryAxisLabelFormatter({\n        hideLabel: hideXAxisLabel,\n        showDistributionRangeLabels: Boolean(isHistogramWithBuckets.value),\n        chartData: computedChartData.value,\n        formatBucketBoundary,\n        columnValueFormatter: getFormatterForColField(activeCategory.value) as\n          | Formatter<AgAxisLabelFormatterParams>\n          | undefined,\n        enableFocusView: props.enableFocusView,\n        focuses: focuses.value,\n        focusText: props.focusText,\n      }),\n    },\n    paddingInner: categoryAxesPaddingInner.value,\n    // The blank min/max pad categories already add a band's worth of outward\n    // space; drop the axis's own outer margin so there isn't a second, empty\n    // band beyond them.\n    paddingOuter: isHistogramWithBuckets.value ? 0 : categoryAxesPaddingOuter.value,\n    groupPaddingInner: categoryAxesGroupPaddingInner.value,\n  });\n\n  // Add numeric x-axis for vertical line overlays if needed\n  if (isHistogramWithBuckets.value && resolvedCrosslineOverlays.value.length > 0) {\n    const numCategories = computedChartData.value?.length || 1;\n    // The distribution-range padding above adds one blank category before the\n    // real buckets, shifting every real bucket's position by 1 on the shared\n    // category axis. Offset the dummy axis's domain and crossline positions to\n    // match so overlay lines still land on the correct bars.\n    const { categoryPadOffset, axisMin, axisMax } = getCrosslineAxisDomain(numCategories, true);\n    axes.push({\n      type: \"number\" as const,\n      keys: [\"__dummy_x__\"],\n      position: (isHorizontalBarChart.value ? \"left\" : \"bottom\") as AgCartesianAxisPosition,\n      crosshair: { enabled: false },\n      min: axisMin,\n      max: axisMax,\n      nice: false,\n      label: { enabled: false },\n      tick: { enabled: false },\n      line: { enabled: false },\n      gridLine: { enabled: false },\n      crossLines: resolvedCrosslineOverlays.value\n        .map((overlay) => {\n          if (!computedChartData.value) {\n            return null;\n          }\n          const scaledValue = scaleValueToIndex(overlay.value, computedChartData.value);\n          if (scaledValue == null) {\n            return null;\n          }\n          const isHovered = hoveredBenchmarkKey.value != null && overlay.key === hoveredBenchmarkKey.value;\n          const isDimmed = hoveredBenchmarkKey.value != null && !isHovered;\n          return {\n            type: \"line\" as const,\n            value: scaledValue + categoryPadOffset,\n            stroke: overlay.color || DEFAULT_CROSSLINE_OVERLAY_COLOR,\n            strokeWidth: isHovered ? 3 : 2,\n            strokeOpacity: isDimmed ? 0.2 : isHovered ? 1 : 0.8,\n            lineDash: [6, 3],\n          };\n        })\n        .filter((line) => line !== null),\n    });\n  }\n\n  // When a secondary y-axis is shown, pin BOTH axes to the same number of equal\n  // intervals from a shared zero baseline so their gridlines coincide as one set\n  // of horizontal lines instead of two misaligned sets. Each axis runs 0 -> a\n  // \"nice\" ceiling (or the explicit secondaryAxisMax) in SECONDARY_AXIS_INTERVAL_COUNT\n  // steps, with `nice: false` so AG Charts doesn't re-round the bounds.\n  //\n  // A shared zero-based grid is only possible when neither series has negative\n  // data. If either axis goes negative (or no positive ceiling exists), we let\n  // each axis scale independently and hide the SECONDARY axis's gridlines — so\n  // the chart still shows a single set of horizontal lines (the primary's) and\n  // each axis keeps an honest scale, rather than two crossing sets of lines.\n  const intervals = SECONDARY_AXIS_INTERVAL_COUNT;\n  // Primary-axis-pinned overlays don't count: with only those active there is no right axis.\n  const hasSecondaryAxis = secondaryOnlyOverlayFields.value.length > 0;\n  // All overlays share the one secondary axis: an explicit cap must cover every\n  // active overlay, so take the largest of the configured maxes (if any).\n  const explicitSecondaryMaxes = secondaryOnlyOverlayFields.value\n    .map((field) => findSeriesColumn(availableSecondarySeriesColumns.value, field)?.secondaryAxisMax)\n    .filter((max): max is number => typeof max === \"number\");\n  const explicitSecondaryMax =\n    hasSecondaryAxis && explicitSecondaryMaxes.length > 0 ? Math.max(...explicitSecondaryMaxes) : undefined;\n  const primaryHasNegative =\n    hasSecondaryAxis && Number.isFinite(minChartSeriesValue.value) && minChartSeriesValue.value < 0;\n  const secondaryHasNegative =\n    hasSecondaryAxis && Number.isFinite(minSecondarySeriesValue.value) && minSecondarySeriesValue.value < 0;\n  const anyAxisHasNegative = primaryHasNegative || secondaryHasNegative;\n\n  // Primary-axis overlays share the left axis, so its aligned ceiling must cover their\n  // spikes too (raw-rate outliers routinely exceed the smoothed series' max).\n  const primaryAxisCeiling = hasSecondaryAxis\n    ? niceAxisCeiling(Math.max(maxChartSeriesValue.value, maxPrimaryOverlayValue.value), intervals)\n    : 0;\n  const secondaryAxisCeiling = hasSecondaryAxis\n    ? (explicitSecondaryMax ?? niceAxisCeiling(maxSecondarySeriesValue.value, intervals))\n    : 0;\n  const alignAxes = hasSecondaryAxis && !anyAxisHasNegative && primaryAxisCeiling > 0 && secondaryAxisCeiling > 0;\n\n  // Line charts don't encode value by length from a baseline, so a grid-aligned primary axis\n  // can hug its data with a nice fitted window instead of stretching to zero (percentage\n  // metrics clustered around 100% were unreadable on a 0-based axis). The window keeps the\n  // shared interval count, so both axes' gridlines still coincide; bar charts keep the zero\n  // baseline, and a null range (degenerate data) falls back to the zero-based window.\n  const primaryFittedRange =\n    alignAxes && props.fitPrimaryAxisToLineData && activeChartType.value?.id === \"line\"\n      ? niceAxisRange(\n          Math.min(primaryLineSeriesExtent.value.min, minPrimaryOverlayValue.value),\n          Math.max(primaryLineSeriesExtent.value.max, maxPrimaryOverlayValue.value),\n          intervals,\n        )\n      : null;\n\n  // Add primary y-axis\n  axes.push({\n    type: \"number\",\n    keys: primaryAxisKeys,\n    position: (isHorizontalBarChart.value ? \"bottom\" : \"left\") as AgCartesianAxisPosition,\n    ...(alignAxes\n      ? primaryFittedRange\n        ? {\n            min: primaryFittedRange.min,\n            max: primaryFittedRange.max,\n            nice: false,\n            interval: { step: primaryFittedRange.step },\n          }\n        : { min: 0, max: primaryAxisCeiling, nice: false, interval: { step: primaryAxisCeiling / intervals } }\n      : {}),\n    label: {\n      formatter: getFormatterForColField(activeSeries.value) as Formatter<AgAxisLabelFormatterParams> | undefined,\n    },\n    title: {\n      enabled: true,\n      text: activeSeriesDisplayName.value,\n    },\n  });\n\n  if (hasSecondaryAxis) {\n    axes.push({\n      type: \"number\",\n      keys: secondaryAxisKeys,\n      position: isHorizontalBarChart.value ? \"top\" : \"right\",\n      crosshair: {\n        enabled: false,\n      },\n      ...(alignAxes\n        ? // Matched interval count + nice:false keeps these gridlines aligned with\n          // the primary axis.\n          { min: 0, max: secondaryAxisCeiling, nice: false, interval: { step: secondaryAxisCeiling / intervals } }\n        : {\n            // Independent scale: only pin a zero baseline when this axis has no\n            // negatives, still honor an explicit cap (nice:false so it doesn't\n            // overshoot), and hide gridlines whenever negative data is present so\n            // only the primary axis draws horizontal lines.\n            ...(secondaryHasNegative ? {} : { min: 0 }),\n            ...(explicitSecondaryMax !== undefined ? { max: explicitSecondaryMax, nice: false } : {}),\n            ...(anyAxisHasNegative ? { gridLine: { enabled: false } } : {}),\n          }),\n      // Scatter overlays render in the theme's fixed marker color, so the axis text matches\n      // it. Line overlays take per-series palette colors, so the axis keeps default text.\n      label: {\n        ...(secondaryOverlayChartType.value === \"scatter\" ? { color: SCATTER_MARKER_STROKE } : {}),\n      },\n      title: {\n        enabled: true,\n        text: secondaryAxisTitle.value,\n        ...(secondaryOverlayChartType.value === \"scatter\" ? { color: SCATTER_MARKER_STROKE } : {}),\n      },\n    });\n  }\n\n  // Declares an invisible x-axis for the vertical line overlays to adhere to.\n  if (isHistogramWithBuckets.value && resolvedCrosslineOverlays.value.length > 0) {\n    const maxY = Number.isFinite(maxChartSeriesValue.value) ? maxChartSeriesValue.value : 0;\n    axes.push({\n      type: \"number\" as const,\n      keys: [\"__dummy_y__\"],\n      position: \"left\",\n      min: 0,\n      max: maxY,\n      nice: false,\n      crosshair: {\n        enabled: false,\n      },\n      label: { enabled: false },\n      tick: { enabled: false },\n      line: { enabled: false },\n      gridLine: { enabled: false },\n    });\n  }\n\n  options.axes = axes;\n\n  options.series = chartSeries.value as AgCartesianSeriesOptions[];\n  return options;\n});\n\nconst chartLoading = computed(() => {\n  return (\n    displayChartLoading.value || (props.isLoading && (!computedChartData.value || computedChartData.value.length === 0))\n  );\n});\n\nconst shouldDisplayNoDataOverlayText = computed(() => {\n  return (\n    shouldShowFocusOverlayText.value ||\n    (!shouldShowEmptyChartFilterRenderer.value && !props.isLoading && noDataOverlayText.value !== \"\")\n  );\n});\n\nconst updateChartCollapsed = (newCollapsedValue: boolean) => {\n  chartCollapsed.value = newCollapsedValue;\n  emit(\"chart-collapsed\", newCollapsedValue);\n};\n\nconst toggleGroupState = (enableGrouping: boolean) => {\n  if (pivotActive.value) return;\n  if (!gridApi.value) {\n    return;\n  }\n  gridApi.value.setRowGroupColumns(enableGrouping ? currentRowGroupColumns.value : []);\n  groupedModeEnabled.value = enableGrouping;\n};\n\n// Declared as overloads (not an inline arrow) so consumers see the sync vs. `{ hydrate: true }` async\n// signatures, matching PvDataTable's exposed method.\nfunction getFilterValueSelectedMetadataMap(): Record<string, (FilterValueResponseOption | null)[]> | undefined;\nfunction getFilterValueSelectedMetadataMap(options: {\n  hydrate: true;\n}): Promise<Record<string, (FilterValueResponseOption | null)[]>> | undefined;\nfunction getFilterValueSelectedMetadataMap(options?: { hydrate?: boolean }) {\n  return options?.hydrate\n    ? pvDataTableRef.value?.getFilterValueSelectedMetadataMap({ hydrate: true })\n    : pvDataTableRef.value?.getFilterValueSelectedMetadataMap();\n}\n\ndefineExpose({\n  getChartImageDataURL: (dimensions?: { width?: number; height?: number }): Promise<string> | undefined => {\n    return isMapView.value\n      ? pvMapChartRef.value?.getChartImageDataURL(dimensions)\n      : pvChartRef.value?.getChartImageDataURL(dimensions);\n  },\n  getCsvData: () => {\n    return pvDataTableRef.value?.getCsvData();\n  },\n  refreshData: (params?: RefreshServerSideParams | null) => {\n    if (gridApi.value) {\n      processChartData(gridApi.value);\n    }\n    return pvDataTableRef.value?.refreshData(params);\n  },\n  getFilterValueSelectedMetadataMap,\n  getPvFilterModel: () => {\n    return pvDataTableRef.value?.getPvFilterModel();\n  },\n  setPvFilterModel: (model: FilterModel | AdvancedFilterModel | null) => {\n    return pvDataTableRef.value?.setPvFilterModel(model);\n  },\n  getChipSections: () => chipSections.value,\n});\n\nonBeforeMount(() => {\n  if (props.initialGridState) {\n    const rowGroupColIds = props.initialGridState.rowGroup?.groupColIds || [];\n    currentRowGroupColumns.value = rowGroupColIds;\n\n    // If not all fields are focusable (in the case of a histogram), then we assume the focus type will be the first row\n    // group column. However, we may need to revisit this logic in case these assumptions change (i.e. allowing a\n    // grouped bar chart to become a histogram).\n    if (!props.allFieldsAreFocusable && rowGroupColIds.length > 0) {\n      chartFocusStore.setFocusType(rowGroupColIds[0]);\n    }\n  }\n});\n\nonMounted(async () => {\n  // Ensure the filter panel element is in the DOM before allowing teleport\n  await nextTick();\n  shouldTeleportFilterPanel.value = props.filterPanelAboveChart;\n});\n</script>\n\n<template>\n  <div style=\"height: 100%; width: 100%\">\n    <!--\n      One row: the filter panel takes the space the actions leave over, and its\n      horizontal filters collapse into the All Filters drawer as that space runs out.\n    -->\n    <div class=\"pv-stack-16\" :class=\"{ 'pv-flex': filterPanelActionsEnabled }\">\n      <div :id=\"filterPanelLocationId\" :style=\"filterPanelActionsEnabled ? 'flex: 1 1 0' : undefined\"></div>\n      <div\n        v-if=\"filterPanelActionsEnabled\"\n        class=\"pv-flex\"\n        style=\"--flex-wrap: wrap; flex: 0 1 auto\"\n        data-testid=\"pv-data-table-with-chart-filter-panel-actions\"\n      >\n        <slot name=\"filter-panel-actions\" />\n      </div>\n    </div>\n    <slot name=\"above-chart\" />\n    <div v-if=\"!hideChart\" class=\"pv-bordered pv-radius-lg pv-inset-square-12 pv-stack-16\">\n      <PvButton\n        rightIcon=\"chevrons-down-up\"\n        label=\"Collapse\"\n        style=\"float: right; margin-left: 0.5rem\"\n        variant=\"secondary\"\n        @click=\"updateChartCollapsed(!chartCollapsed)\"\n        :class=\"hideChart || chartCollapsed ? 'pv-hide' : ''\"\n      />\n      <div :class=\"hideChart || !chartCollapsed ? 'pv-hide' : 'pv-space-between'\">\n        <div class=\"pv-flex\">\n          <PvIcon name=\"chart-line\" :size=\"20\" class=\"pv-text-subdued\" />\n          <p class=\"pv-text-body-md pv-text-primary\" style=\"font-weight: 500\">Expand to see chart</p>\n        </div>\n        <PvButton\n          rightIcon=\"chevron-selector\"\n          label=\"Expand\"\n          variant=\"secondary\"\n          @click=\"updateChartCollapsed(!chartCollapsed)\"\n        />\n      </div>\n      <div :class=\"hideChart || chartCollapsed ? 'pv-hide' : ''\">\n        <PvChartOptionsPanel\n          :enablePanel=\"computedChartData != null && computedChartData.length > 0\"\n          :chartFilter=\"chartFilter\"\n          :rowGroupLimit=\"effectiveRowGroupLimit\"\n          :use-combined-button=\"props.enableCombinedChartConfigPanel\"\n          :use-nested-menu=\"props.enableNestedChartConfigPanel\"\n          :chart-config-options=\"props.chartConfigPanelOptions\"\n          :locked-row-group-options=\"props.lockedRowGroupOptions\"\n          :metric-overlay-with-row-groups=\"props.metricOverlayWithRowGroups\"\n          :read-only=\"props.chartConfigPanelReadOnly\"\n          :percent-of-focus-view-y-key=\"props.percentOfFocusViewYKey\"\n          @series-agg-func-selected=\"handleSeriesAggFuncSelected\"\n        />\n        <div class=\"pv-flex\" style=\"align-items: stretch\">\n          <PvBenchmarkChips\n            v-if=\"chipSections.length > 0\"\n            :sections=\"chipSections\"\n            @chip-hover=\"hoveredBenchmarkKey = $event\"\n          />\n          <div\n            class=\"pv-relative pv-margin-auto pv-flex-item\"\n            :style=\"isMapView ? { height: mapChartHeight } : undefined\"\n          >\n            <PvMapChart\n              v-if=\"isMapView\"\n              ref=\"pvMapChartRef\"\n              v-model:selectedRegion=\"selectedMapRegion\"\n              :chartData=\"mapChartData\"\n              :seriesKey=\"mapSeriesKey\"\n              :seriesLabel=\"activeSeriesDisplayName\"\n              :clickable=\"false\"\n              :displayRegionSelector=\"false\"\n              :gradientLegendMin=\"mapGradientRange.min\"\n              :gradientLegendMax=\"mapGradientRange.max\"\n              :seriesValueFormatter=\"mapSeriesValueFormatter\"\n              :isLoading=\"chartLoading\"\n              :noDataMessage=\"noDataOverlayText\"\n            />\n            <div\n              v-else\n              :class=\"[\n                'pv-data-table-with-chart__chart-scroll',\n                {\n                  'pv-data-table-with-chart__chart-scroll--enabled pv-scrollbar-visible': chartScrollingEnabled,\n                },\n              ]\"\n              :style=\"chartScrollContainerStyle\"\n            >\n              <div class=\"pv-data-table-with-chart__chart-content\" :style=\"chartContentStyle\">\n                <PvChart\n                  ref=\"pvChartRef\"\n                  :key=\"chartInstanceKey\"\n                  :isLoading=\"chartLoading\"\n                  :options=\"computedChartOptions\"\n                  :enableFocusView=\"enableFocusView\"\n                  :minHeight=\"effectiveChartMinHeight\"\n                />\n                <!-- Crossline Tooltip when Benchmark Chip is hovered over-->\n                <div\n                  v-if=\"hoveredCrosslineTooltip\"\n                  class=\"ag-charts-tooltip pv-data-table-with-chart__crossline-tooltip pv-tooltip-v2-content\"\n                  data-variant=\"white\"\n                  :class=\"hoveredCrosslineTooltip.arrowClass\"\n                  :style=\"hoveredCrosslineTooltip.style\"\n                >\n                  <div class=\"pv-flex pv-space-between\">\n                    <div class=\"pv-chart-tooltip-label\">\n                      {{ hoveredCrosslineTooltip.label }}\n                    </div>\n                    <div class=\"pv-chart-tooltip-value\">\n                      {{ hoveredCrosslineTooltip.value }}\n                    </div>\n                  </div>\n                </div>\n              </div>\n            </div>\n            <div v-if=\"!isMapView\" class=\"pv-chart-overlay pv-flex pv-align-center\">\n              <div v-if=\"shouldShowEmptyChartFilterRenderer\">\n                <component :is=\"emptyChartFilterRenderer\" />\n              </div>\n              <div v-else-if=\"showDefaultMissingFocusMessage\" class=\"pv-text-body-xs\" style=\"text-align: center\">\n                <span\n                  >Select focus {{ displayGroupByName }} to view Visualization. You can select a focus\n                  {{ displayGroupByName }} by</span\n                >\n                <span class=\"pv-flex\" style=\"text-wrap: nowrap\">\n                  opening the filter dropdown and clicking on the focus icon\n                  <PvIcon name=\"focus\" :size=\"12\" class=\"pv-text-subdued\" style=\"vertical-align: middle\" /> on the right\n                  hand side.\n                </span>\n              </div>\n              <p v-else-if=\"shouldDisplayNoDataOverlayText\" class=\"pv-text-body-xs\">\n                {{ noDataOverlayText }}\n              </p>\n            </div>\n          </div>\n        </div>\n        <div\n          v-if=\"paginatedStackValuesLegend.length > 0\"\n          class=\"pv-stack-8\"\n          style=\"\n            display: grid;\n            grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));\n            row-gap: 8px;\n            column-gap: 4px;\n          \"\n          data-testid=\"pv-data-table-with-chart-stack-values-legend\"\n        >\n          <div\n            v-for=\"item in paginatedStackValuesLegend\"\n            :key=\"item.key\"\n            class=\"pv-flex\"\n            style=\"align-items: center; gap: 4px\"\n          >\n            <span style=\"width: 10px; height: 10px; flex-shrink: 0\" :style=\"{ backgroundColor: item.color }\" />\n            <span\n              class=\"pv-text-body-xs\"\n              :title=\"item.label\"\n              style=\"white-space: nowrap; overflow: hidden; text-overflow: ellipsis\"\n              >{{ item.label }}</span\n            >\n          </div>\n        </div>\n        <div\n          v-if=\"stackValuesCapMessage\"\n          class=\"pv-flex pv-space-between\"\n          style=\"align-items: center\"\n          data-testid=\"pv-data-table-with-chart-stack-values-pagination\"\n        >\n          <p class=\"pv-text-body-xs pv-text-subdued\" data-testid=\"pv-data-table-with-chart-stack-values-cap-message\">\n            {{ stackValuesCapMessage }}\n          </p>\n          <PvPagination\n            variant=\"short\"\n            :maxPages=\"stackValuesPagination?.pageCount ?? 1\"\n            :modelValue=\"stackValuesPageIndex + 1\"\n            @update:modelValue=\"(page) => goToStackValuesPage(page - 1)\"\n          />\n        </div>\n      </div>\n    </div>\n    <PvDataTable\n      ref=\"pvDataTableRef\"\n      :key=\"pivotKey\"\n      v-bind=\"$props\"\n      :colDefs=\"tableColDefs\"\n      :pivot=\"pivotActive\"\n      :filterTeleportLocation=\"shouldTeleportFilterPanel ? `#${filterPanelLocationId}` : undefined\"\n      :wrapHorizontalFilters=\"props.wrapHorizontalFilters\"\n      :pagination=\"pagination || !groupedModeEnabled\"\n      @column-row-group-changed=\"handleRowGroupChanged\"\n      @column-value-changed=\"handleColumnValueChanged\"\n      @grid-ready=\"handleGridReady\"\n      @filter-changed=\"handleFilterChanged\"\n      @sort-changed=\"emit('sort-changed', $event)\"\n      @filter-opened=\"emit('filter-opened', $event)\"\n      @first-data-rendered=\"handleFirstDataRendered\"\n      @column-moved=\"handleColumnMoved\"\n      @column-resized=\"emit('column-resized', $event)\"\n      @handle-settings-icon=\"emit('handle-settings-icon', $event)\"\n      @focus-update=\"emit('focus-update', $event)\"\n    >\n      <template #top-slot>\n        <template v-if=\"enableGroupingToggle && !pivotActive\">\n          <PvTableOptionsPanel\n            v-if=\"tableConfigOptions\"\n            :groupedModeEnabled=\"groupedModeEnabled\"\n            :tableConfigOptions=\"props.tableConfigOptions\"\n            @toggle-group=\"toggleGroupState\"\n            @table-overlay-change=\"handleTableOverlayChange\"\n            @column-config-change=\"handleColumnConfigChange\"\n          />\n          <PvButton\n            v-else\n            :leftIcon=\"!groupedModeEnabled ? 'group' : 'ungroup'\"\n            :label=\"!groupedModeEnabled ? 'Group Table to Match Chart' : 'Ungroup Table'\"\n            @click=\"toggleGroupState(!groupedModeEnabled)\"\n            variant=\"secondary\"\n            size=\"lg\"\n          />\n        </template>\n        <slot name=\"top-slot\" />\n      </template>\n    </PvDataTable>\n  </div>\n</template>\n\n<style>\n.pv-data-table-with-chart__chart-scroll {\n  contain: inline-size;\n  min-height: 0;\n  overflow: hidden;\n  width: 100%;\n}\n\n/* Overflow is set inline per chart orientation - see getChartScrollOverflowStyle. */\n\n.pv-data-table-with-chart__chart-content {\n  min-height: 100%;\n}\n\n.pv-chart-overlay {\n  position: absolute;\n  top: 50%;\n  left: 50%;\n  transform: translate(-50%, -50%);\n  pointer-events: none;\n}\n.ag-charts-tooltip {\n  background-color: rgba(255, 255, 255, 0.95);\n}\n\n/* Compound selector to beat .ag-charts-tooltip's own border-radius/box-shadow on specificity. */\n.pv-data-table-with-chart__crossline-tooltip.ag-charts-tooltip {\n  border-radius: 4px;\n  box-shadow: 0 0 8px 0 rgba(0, 0, 0, 0.12);\n}\n\n.ag-charts-floating-toolbar {\n  display: none !important;\n}\n</style>\n","<!--\n  @deprecated This component has moved to tq-site as a local component\n  (src/common/components/DataTableWithChart) and is no longer maintained here. It will be\n  removed from Pit Viper in a future release - migrate any remaining usage to the tq-site\n  component.\n-->\n<script lang=\"ts\">\nimport type { AgChartOptions } from \"ag-charts-types\";\nimport {\n  ChartSeriesAggFuncOption,\n  ChartSeriesAggFuncSelectedEvent,\n  ColumnConfigurationChangeEvent,\n  OptionWithFormatterAndDataType,\n  PvDataTableWithChartProps,\n  StackField,\n  supportedChartType,\n} from \"./types\";\nimport {\n  histogramChartTypeConfig,\n  mapChartTypeConfig,\n  MAP_REGION_FIELD,\n  multiGroupChartTypeConfigs,\n  singleGroupChartTypeConfigs,\n} from \"./constants\";\nimport { getChartTypeConfig, retainValidXAxisFields } from \"./chartTypeRegistry\";\nimport { FocusUpdateEvent } from \"@/components/tables/PvDataTable/types\";\nimport {\n  ActiveChartFilterOptionKey,\n  ActiveChartKey,\n  ChartTypeKey,\n  FirstDataRenderedKey,\n  RowGroupColumnsKey,\n  SortTypesKey,\n} from \"@/components/tables/symbols\";\n</script>\n\n<script setup lang=\"ts\" generic=\"T\">\nimport PvDataTable from \"@tables/PvDataTable/PvDataTable.vue\";\nimport PvButton from \"@/components/base/PvButton/PvButton.vue\";\nimport PvIcon from \"@/components/base/PvIcon/PvIcon.vue\";\nimport PvPagination from \"@/components/base/PvPagination/PvPagination.vue\";\nimport PvChart from \"@charts/PvChart/PvChart.vue\";\nimport PvMapChart, { type PvMapChartData } from \"@charts/PvMapChart/PvMapChart.vue\";\nimport PvTableOptionsPanel from \"@charts/PvDataTableWithChart/table-chart-components/PvTableOptionsPanel.vue\";\nimport PvBenchmarkChips from \"@charts/PvDataTableWithChart/table-chart-components/PvBenchmarkChips.vue\";\nimport { computed, getCurrentInstance, nextTick, onBeforeMount, onMounted, provide, Ref, ref, watch } from \"vue\";\nimport {\n  AdvancedFilterModel,\n  Column,\n  ColumnMovedEvent,\n  ColumnResizedEvent,\n  ColumnRowGroupChangedEvent,\n  FilterChangedEvent,\n  FilterModel,\n  IRowNode,\n  ValueFormatterFunc,\n  ValueFormatterParams,\n} from \"ag-grid-enterprise\";\nimport {\n  ColDef,\n  ColumnValueChangedEvent,\n  ColumnVO,\n  FirstDataRenderedEvent,\n  GridApi,\n  GridReadyEvent,\n  RefreshServerSideParams,\n  SortChangedEvent,\n} from \"ag-grid-community\";\nimport PvChartOptionsPanel from \"@charts/PvDataTableWithChart/table-chart-components/PvChartOptionsPanel.vue\";\nimport { MenuOption } from \"@/types\";\nimport type {\n  AgAreaSeriesOptions,\n  AgAxisLabelFormatterParams,\n  AgBarSeriesOptions,\n  AgCartesianAxisPosition,\n  AgCartesianChartOptions,\n  AgCartesianSeriesOptions,\n  AgLineSeriesOptions,\n  AgPieSeriesOptions,\n  AgSeriesTooltipRendererParams,\n  Formatter,\n} from \"ag-charts-enterprise\";\nimport { multicolorFills, SCATTER_MARKER_STROKE } from \"@charts/themes\";\nimport { buildScatterAxes } from \"./scatterAxisUtils\";\nimport { ColDefDataType, truncateValue } from \"@tables/PvDataTable/table-components/formatting\";\nimport {\n  BUCKET_AGG_COUNT_VALUE_NAME,\n  distributionRangeMaxCategory,\n  distributionRangeMinCategory,\n  SECONDARY_AXIS_INTERVAL_COUNT,\n  padEndValue,\n  padStartValue,\n  separatorValue,\n  sortTotalSuffix,\n} from \"@charts/PvDataTableWithChart/constants\";\nimport {\n  ActiveSeriesKey,\n  ActiveSecondarySeriesKey,\n  ActiveSecondarySeriesListKey,\n  ActiveSortKey,\n  ActiveCrosslineOverlayGroupsKey,\n  AvailableRowGroupColumnsKey,\n  AvailableSeriesKey,\n  AvailableSecondarySeriesKey,\n  AvailableCrosslineOverlayGroupsKey,\n  FilterStoreKey,\n  FocusStoreKey,\n  GridApiKey,\n  MetricOverlayMultiSelectKey,\n} from \"@/components/tables/symbols\";\nimport { useFilterStore } from \"@tables/PvDataTable/useFilterStore\";\nimport {\n  colDefContext,\n  isColDefNumericDataType,\n  mapColsToColumnV0,\n  processRowGroupCols,\n} from \"@/components/tables/PvDataTable/helpers\";\nimport { cleanInitialGridState, mapFilterBasedOnColDef } from \"@/components/tables/PvDataTable/filters/filterHelpers\";\nimport {\n  ChartStateChangedEvent,\n  FilterValueResponseOption,\n  PvDataTablePivot,\n  PvDataTablePublicInterface,\n} from \"@tables/PvDataTable/types\";\nimport { ServerSideChartDataHandlerParams } from \"@charts/PvDataTableWithChart/types\";\nimport { createFocusStore } from \"@tables/PvDataTable/useFocus\";\nimport {\n  buildCategoryAxisLabelFormatter,\n  buildStackedChartData,\n  calculateMaxChartSeriesValue,\n  calculateMinChartSeriesValue,\n  generateStackSecondaryCategoryKey,\n  generateStackSeriesKey,\n  computeNoDataOverlayText,\n  isAvailableSecondarySeriesColDef,\n  isChronologicalColDef,\n  getSecondarySeriesKey,\n  niceAxisCeiling,\n  niceAxisRange,\n  padSingleCategoryBarData,\n  paginatePivotedStackValuesByTotal,\n  sortChartDataChronologically,\n} from \"@charts/PvDataTableWithChart/helpers\";\nimport {\n  DEFAULT_CROSSLINE_OVERLAY_COLOR,\n  getCrosslineAxisDomain,\n  scaleValueToIndex,\n} from \"@charts/PvDataTableWithChart/crosslineHelpers\";\nimport { useBenchmarkOverlays } from \"@charts/PvDataTableWithChart/useBenchmarkOverlays\";\nimport { useSlotPresence } from \"@/composables/useSlotPresence\";\nimport { NULL_PLACEHOLDER_VALUE } from \"@charts/PvChart/constants\";\nimport {\n  getChartScrollContentStyle,\n  getChartScrollOverflowStyle,\n  getScrollableChartMinHeight,\n} from \"@charts/widgetOptions\";\nimport { isEqual } from \"es-toolkit\";\n\nconst props = withDefaults(defineProps<PvDataTableWithChartProps<T>>(), {\n  initialGridState: () => ({}),\n  displayBaseAggregationsOnly: false,\n  displayRowNumber: true,\n  displayGroupCount: true,\n  displayPreferencesIcon: false,\n  enableColumnVisibilitySelector: true,\n  enableCsvExport: false,\n  enableFocusView: false,\n  enableGroupBySelector: (p) => !p.filterPanelAboveChart,\n  enableVerticalFilterPanel: true,\n  showSeriesLabels: true,\n  truncateLabelValues: true,\n  requireFiltersToShowData: false,\n  rowGroupLimit: 2,\n  maxHorizontalFilters: 6,\n  initialChartCollapsed: false,\n  filterPanelAboveChart: false,\n  filterPanelReadOnly: false,\n  disableUnselectedReadOnlyFilters: false,\n  chartConfigPanelReadOnly: false,\n  enableChartScrolling: true,\n  enableTopSlot: true,\n  enabledChartTypes: () => [\"column\", \"bar\", \"column_stacked\", \"bar_stacked\", \"line\", \"area\"],\n  initialStackValuesPageIndex: 0,\n  chartType: \"column\" as supportedChartType,\n  secondaryChartType: \"scatter\" as supportedChartType,\n  metricOverlayWithRowGroups: false,\n  lockedRowGroupOptions: () => [],\n  suppressMetricOverlays: false,\n  fitPrimaryAxisToLineData: false,\n  yKey: \"\",\n  percentOfFocusViewYKey: \"\",\n  enableCombinedChartConfigPanel: false,\n  enableNestedChartConfigPanel: false,\n  chartConfigPanelOptions: () => [\"sort\", \"chart-type\"],\n  maintainColumnOrder: true,\n  enableAdvancedFilter: false,\n  displayAdvancedFilterQueryBuilder: false,\n  refreshFiltersInBackground: false,\n  stageFilterChangesUntilDropdownCloses: false,\n  focusText: \"Focus\",\n  focusRequired: false,\n});\n\nconst emit = defineEmits<{\n  (e: \"chart-state-changed\", event: ChartStateChangedEvent): void;\n  (e: \"column-moved\", event: ColumnMovedEvent<T>): void;\n  (e: \"column-resized\", event: ColumnResizedEvent<T>): void;\n  (e: \"column-row-group-changed\", event: ColumnRowGroupChangedEvent<T>): void;\n  (e: \"column-value-changed\", event: ColumnValueChangedEvent<T>): void;\n  (e: \"grid-ready\", event: GridReadyEvent<T>): void;\n  (e: \"filter-changed\", event: FilterChangedEvent<T>): void;\n  (e: \"sort-changed\", event: SortChangedEvent<T>): void;\n  (e: \"filter-opened\", event: FilterChangedEvent<T>): void;\n  (e: \"first-data-rendered\", event: FirstDataRenderedEvent<T>): void;\n  (e: \"handle-settings-icon\", value: string): void;\n  (e: \"focus-update\", event: FocusUpdateEvent): void;\n  (e: \"chart-collapsed\", collapsed: boolean): void;\n  (e: \"table-overlay-change\", selectedIds: string[]): void;\n  (e: \"active-overlay-group-ids-change\", ids: string[]): void;\n  /** Fired when the user navigates to a different page of stack values (see stackValuesPageSize). */\n  (e: \"stack-values-page-changed\", pageIndex: number): void;\n}>();\n\nconst gridApi = ref(null as GridApi | null);\nconst pvDataTableRef = ref<PvDataTablePublicInterface | null>(null);\nconst pvChartRef = ref<InstanceType<typeof PvChart> | null>(null);\nconst pvMapChartRef = ref<InstanceType<typeof PvMapChart> | null>(null);\nconst chartCollapsed = ref<boolean>(props.initialChartCollapsed ?? false);\nconst filterPanelLocationId = \"filter-panel-\" + getCurrentInstance()?.uid;\nconst shouldTeleportFilterPanel = ref(false);\nconst { present: hasFilterPanelActions } = useSlotPresence(\"filter-panel-actions\");\nconst filterPanelActionsEnabled = computed(() => props.filterPanelAboveChart && hasFilterPanelActions.value);\nconst displayChartLoading = ref(false);\nconst chartRequestId = ref(0);\nconst DATA_TABLE_CHART_MIN_HEIGHT_PX = 450;\nconst DATA_TABLE_CHART_SCROLL_ITEM_HEIGHT_PX = 64;\n// Maps read best with more vertical room than the cartesian charts, so give the\n// map view a taller fixed height (no zoom/pan - it just renders larger).\nconst DATA_TABLE_MAP_CHART_HEIGHT_PX = 600;\n// Approximate width of the PvBenchmarkChips column, reserved from the chart's min-width.\nconst BENCHMARK_CHIPS_RESERVED_WIDTH_PX = 255;\n\nconst availableRowGroupColumns = computed(() => {\n  const colDefs = pvDataTableRef.value?.availableRowGroupColumns || [];\n  return colDefs;\n});\n\n// the row group columns we're currently charting against\nconst currentRowGroupColumns = ref<string[]>([]);\n\nconst activeCategory = computed(() => {\n  return currentRowGroupColumns.value.length > 0 ? currentRowGroupColumns.value[0] : \"\";\n});\n\nconst getSeriesDisplayNameFromColDef = (colDef: ColDef) => {\n  const context = colDefContext(colDef);\n  return context.chartSeriesDisplayName || colDef.headerName || colDef.field || \"\";\n};\n\nconst activeSeriesAggFuncs = ref<Record<string, string>>({});\n\nconst activeAggFuncForColDef = (colDef: ColDef): string | undefined => {\n  const field = colDef.field;\n  if (!field) return undefined;\n  return activeSeriesAggFuncs.value[field] ?? (typeof colDef.aggFunc === \"string\" ? colDef.aggFunc : undefined);\n};\n\nconst chartSeriesAggFuncOptions = (\n  colDef: ColDef,\n  seriesValue: (aggFunc: string) => string,\n): ChartSeriesAggFuncOption[] | undefined => {\n  if (!colDef.allowedAggFuncs?.length) return undefined;\n  const context = colDefContext(colDef);\n  return colDef.allowedAggFuncs.map((aggFunc) => ({\n    aggFunc,\n    description: context.aggFuncDescriptionMap?.[aggFunc],\n    label: context.aggFuncDisplayNameMap?.[aggFunc] ?? aggFunc,\n    order: context.aggFuncOrderMap?.[aggFunc],\n    seriesValue: seriesValue(aggFunc),\n  }));\n};\n\n// With `pivot` on, the table follows the chart: if the x-axis leads with an `enablePivot` column, it pivots across\n// the top, the rest of the x-axis goes down the side, and the measures are the y-axis plus any `pivotValue` columns.\n// Otherwise it's the regular table.\nconst tablePivot = computed<PvDataTablePivot | null>(() => {\n  if (!props.pivot) return null;\n  const [pivotField, ...rowGroupFields] = currentRowGroupColumns.value;\n  const pivotColDef = props.colDefs?.find((colDef) => colDef.field === pivotField);\n  if (!pivotField || !pivotColDef?.enablePivot) return null;\n  const seriesField =\n    availableSeriesColumns.value.find((series) => series.value === activeSeries.value)?.columnField ??\n    activeSeries.value;\n  // Even when hidden from the regular table: the pivot builds its own columns.\n  const pivotValueFields = (props.colDefs ?? [])\n    .filter((colDef) => colDefContext(colDef).pivotValue && colDef.field)\n    .map((colDef) => colDef.field as string);\n  return {\n    rowGroupCols: rowGroupFields,\n    pivotCols: [pivotField],\n    valueCols: [...new Set([seriesField, ...pivotValueFields].filter((field): field is string => Boolean(field)))],\n  };\n});\nconst pivotActive = computed(() => tablePivot.value !== null);\n\n// The inner table's colDefs, with the current pivot set on AG Grid's own props. Other aggFunc columns keep their\n// aggFunc (the chart's y-axis options read it) but are left out of the pivot with `enableValue: false`. Measures\n// come first, in order, since the table shows them in colDef order.\nconst tableColDefs = computed(() => {\n  const pivot = tablePivot.value;\n  if (!pivot || !props.colDefs) return props.colDefs;\n  const indexIn = (fields: string[], field: string | undefined) => (field ? fields.indexOf(field) : -1);\n  const colDefs = props.colDefs.map((colDef) => {\n    const rowGroupIndex = indexIn(pivot.rowGroupCols, colDef.field);\n    const pivotIndex = indexIn(pivot.pivotCols, colDef.field);\n    const isValue = indexIn(pivot.valueCols, colDef.field) !== -1;\n    return {\n      ...colDef,\n      rowGroup: rowGroupIndex !== -1,\n      rowGroupIndex: rowGroupIndex !== -1 ? rowGroupIndex : null,\n      pivot: pivotIndex !== -1,\n      pivotIndex: pivotIndex !== -1 ? pivotIndex : null,\n      aggFunc: isValue ? (colDef.aggFunc ?? \"first\") : colDef.aggFunc,\n      enableValue: isValue,\n    };\n  });\n  const valueOrder = (colDef: ColDef<T>) => {\n    const index = indexIn(pivot.valueCols, colDef.field);\n    return index === -1 ? pivot.valueCols.length : index;\n  };\n  return [...colDefs].sort((a, b) => valueOrder(a) - valueOrder(b));\n});\n\n// The pivot layout is fixed when the grid mounts, so a new layout remounts the table.\nconst pivotKey = computed(() => JSON.stringify(tablePivot.value));\n\nconst availableSeriesColumns = computed(() => {\n  const config = activeChartTypeConfig.value;\n  if (config.yAxis.hidden && config.yAxis.defaultValue) {\n    return [{ label: \"Count\", value: config.yAxis.defaultValue }] as OptionWithFormatterAndDataType[];\n  }\n  const colDefs = pvDataTableRef.value?.availableAggFuncColumns || [];\n  return colDefs\n    .filter((colDef) => {\n      const context = colDefContext(colDef);\n      return !context.hideFromCharting && !context.chartOnSecondaryAxes;\n    })\n    .map((colDef) => {\n      const columnField = colDef.field || \"\";\n      return {\n        activeAggFunc: activeAggFuncForColDef(colDef),\n        aggFuncOptions: chartSeriesAggFuncOptions(colDef, () => columnField),\n        columnField,\n        dataType: colDef.context?.dataType,\n        description: colDef.context?.chartSeriesDescription,\n        formatter: colDef.valueFormatter,\n        label: getSeriesDisplayNameFromColDef(colDef),\n        value: columnField,\n      };\n    }) as OptionWithFormatterAndDataType[];\n});\n\nconst availableSeriesSelectionCount = computed(() =>\n  props.enableCombinedChartConfigPanel && props.enableNestedChartConfigPanel\n    ? availableSeriesColumns.value.reduce((count, series) => count + (series.aggFuncOptions?.length || 1), 0)\n    : availableSeriesColumns.value.length,\n);\n\nconst availableSecondarySeriesColumns = computed(() => {\n  const colDefs = pvDataTableRef.value?.availableAggFuncColumns || [];\n  const rowGroupFields = new Set(currentRowGroupColumns.value);\n  return colDefs\n    .filter((colDef) => isAvailableSecondarySeriesColDef(colDef))\n    .map((colDef) => {\n      const activeAggFunc = activeAggFuncForColDef(colDef);\n      const columnField = colDef.field || \"\";\n      return {\n        activeAggFunc,\n        aggFuncOptions: chartSeriesAggFuncOptions(colDef, (aggFunc) =>\n          getSecondarySeriesKey(columnField, aggFunc, rowGroupFields),\n        ),\n        columnField,\n        dataType: colDef.context?.dataType,\n        description: colDef.context?.chartSeriesDescription,\n        formatter: colDef.valueFormatter,\n        label: getSeriesDisplayNameFromColDef(colDef),\n        secondaryAxisMax: colDef.context?.secondaryAxisMax,\n        tooltipRenderer: colDef.context?.customTooltipRenderer,\n        value: getSecondarySeriesKey(columnField, activeAggFunc, rowGroupFields),\n      };\n    }) as OptionWithFormatterAndDataType[];\n});\n\nconst findSeriesColumn = (seriesOptions: OptionWithFormatterAndDataType[], value: string | undefined) =>\n  seriesOptions.find(\n    (series) => series.value === value || series.aggFuncOptions?.some((option) => option.seriesValue === value),\n  );\n\nconst supplementaryChartingColumns = computed(() => {\n  const colDefs = pvDataTableRef.value?.availableAggFuncColumns || [];\n  return colDefs\n    .filter((colDef) => {\n      const context = colDefContext(colDef);\n      return context.chartOnSecondaryAxes === true && context.hideFromCharting === true;\n    })\n    .map((col) => {\n      const colId = col.field;\n      const colDef = col;\n      return {\n        label: getSeriesDisplayNameFromColDef(colDef),\n        value: colId || \"\",\n        formatter: colDef.valueFormatter,\n        dataType: colDef.context?.dataType,\n      };\n    }) as OptionWithFormatterAndDataType[];\n});\n\n// Use an explicitly provided filter store first, then injected context, then create a private store.\nconst chartFilterStore = props.filterStore || useFilterStore();\nprovide(FilterStoreKey, chartFilterStore);\n\nconst chartFocusStore = createFocusStore(\n  {\n    focusType: props.initialFocusData?.focusType,\n    focuses: props.initialFocusData?.focuses || [],\n    focusRequired: props.focusRequired,\n  },\n  props.allFieldsAreFocusable,\n);\nprovide(FocusStoreKey, chartFocusStore);\nconst { setFilterSelectedValues } = chartFilterStore;\nconst firstDataRendered = ref(false);\nprovide(FirstDataRenderedKey, firstDataRendered);\nconst groupedModeEnabled = ref(props.isTableGrouped);\n\nconst handleTableOverlayChange = (selectedIds: string[]) => {\n  emit(\"table-overlay-change\", selectedIds);\n};\n\nconst shouldShowEmptyChartFilterRenderer = computed(() => {\n  if (shouldShowFocusOverlayText.value) {\n    return false;\n  }\n  return Boolean(\n    props.emptyChartFilterRenderer && props.requireFiltersToShowData && chartFilterStore.filterModelEmpty.value,\n  );\n});\n\nconst focusType = computed(() => {\n  return chartFocusStore?.computedFocusType.value || null;\n});\n\nconst focuses = computed(() => {\n  return chartFocusStore?.computedFocuses.value || [];\n});\n\nconst syncActiveSeriesAggFuncs = (api: GridApi) => {\n  // Pivot grids hold display-only aggFuncs; chart agg funcs are tracked locally.\n  if (pivotActive.value) return;\n  activeSeriesAggFuncs.value = Object.fromEntries(\n    api\n      .getValueColumns()\n      .map((column) => [column.getColId(), column.getAggFunc()])\n      .filter((entry): entry is [string, string] => typeof entry[1] === \"string\"),\n  );\n};\n\n// Display order as of the last column-state emission, so drag-driven chart-state-changed\n// events can report the order they replaced. Only tracked when column configuration is on.\nconst lastOrderedColIds = ref<string[] | null>(null);\n\nconst handleGridReady = (params: GridReadyEvent) => {\n  // set the grid api in the provide so that child components can access it\n  gridApi.value = params.api;\n  syncActiveSeriesAggFuncs(params.api);\n  if (!groupedModeEnabled.value && !pivotActive.value) {\n    gridApi.value?.setRowGroupColumns([]);\n  }\n  if (props.tableConfigOptions?.enableColumnConfiguration) {\n    lastOrderedColIds.value = params.api.getAllGridColumns().map((col) => col.getColId());\n  }\n  processChartData(params.api);\n  emit(\"grid-ready\", params);\n};\n\nconst handleColumnConfigChange = (event: ColumnConfigurationChangeEvent) => {\n  lastOrderedColIds.value = event.orderedColIds;\n  emit(\"chart-state-changed\", {\n    api: gridApi.value,\n    newState: {\n      orderedColIds: event.orderedColIds,\n      hiddenColIds: event.hiddenColIds,\n    },\n    oldState: {\n      orderedColIds: event.previousOrderedColIds,\n      hiddenColIds: event.previousHiddenColIds,\n    },\n  });\n};\n\nconst handleColumnMoved = (event: ColumnMovedEvent<T>) => {\n  emit(\"column-moved\", event);\n  // Finished header drags also flow into chart-state-changed so consumers can persist them;\n  // api-sourced moves (the Columns panel, updateGridState re-applies) are excluded because\n  // their state changes are already emitted through handleColumnConfigChange.\n  if (!props.tableConfigOptions?.enableColumnConfiguration || !event.finished || event.source !== \"uiColumnMoved\") {\n    return;\n  }\n  const orderedColIds = event.api.getAllGridColumns().map((col) => col.getColId());\n  emit(\"chart-state-changed\", {\n    api: gridApi.value,\n    newState: { orderedColIds },\n    oldState: { orderedColIds: lastOrderedColIds.value },\n  });\n  lastOrderedColIds.value = orderedColIds;\n};\n\nconst handleColumnValueChanged = (event: ColumnValueChangedEvent<T>) => {\n  // Overlay selection values embed the active agg func (see getSecondarySeriesKey), so an\n  // agg-func change invalidates them. Capture the selections' column fields before syncing,\n  // then re-resolve each to its new value.\n  const selectedSecondarySeries = findSeriesColumn(availableSecondarySeriesColumns.value, activeSecondarySeries.value);\n  const selectedSecondaryColumnFields = activeSecondarySeriesList.value\n    .map((value) => findSeriesColumn(availableSecondarySeriesColumns.value, value)?.columnField)\n    .filter((columnField): columnField is string => Boolean(columnField));\n  syncActiveSeriesAggFuncs(event.api);\n  if (selectedSecondarySeries?.columnField && activeSecondarySeries.value) {\n    activeSecondarySeries.value = availableSecondarySeriesColumns.value.find(\n      (series) => series.columnField === selectedSecondarySeries.columnField,\n    )?.value;\n  }\n  if (selectedSecondaryColumnFields.length > 0) {\n    activeSecondarySeriesList.value = selectedSecondaryColumnFields\n      .map(\n        (columnField) =>\n          availableSecondarySeriesColumns.value.find((series) => series.columnField === columnField)?.value,\n      )\n      .filter((value): value is string => Boolean(value));\n  }\n  stackValuesPageIndex.value = 0;\n  processChartData(event.api);\n  emit(\"column-value-changed\", event);\n};\n\nconst handleSeriesAggFuncSelected = (event: ChartSeriesAggFuncSelectedEvent) => {\n  const api = gridApi.value;\n  if (pivotActive.value) {\n    activeSeriesAggFuncs.value = { ...activeSeriesAggFuncs.value, [event.columnField]: event.aggFunc };\n    if (api) processChartData(api);\n    return;\n  }\n  if (!api || api.getColumn(event.columnField)?.getAggFunc() === event.aggFunc) return;\n  api.applyColumnState({\n    state: [{ colId: event.columnField, aggFunc: event.aggFunc }],\n  });\n};\n\nconst handleFirstDataRendered = (params: FirstDataRenderedEvent<T>) => {\n  emit(\"first-data-rendered\", params);\n};\n\nconst handleRowGroupChanged = (event: ColumnRowGroupChangedEvent<T>) => {\n  // pivot row groups aren't chart state\n  if (pivotActive.value) return;\n  // if grouped mode is enabled and the row group columns have changed, update the currentRowGroupColumns\n  const currentRowGroupCols = currentRowGroupColumns.value;\n  const newRowGroupCols = event.api.getRowGroupColumns().map((col) => col.getColId());\n  if (groupedModeEnabled.value && JSON.stringify(currentRowGroupCols) !== JSON.stringify(newRowGroupCols)) {\n    const config = activeChartTypeConfig.value;\n    if (newRowGroupCols.length > effectiveRowGroupLimit.value) {\n      const limited = newRowGroupCols.slice(0, effectiveRowGroupLimit.value);\n      currentRowGroupColumns.value = limited;\n      event.api.setRowGroupColumns(limited);\n    } else {\n      currentRowGroupColumns.value = newRowGroupCols;\n    }\n    // if this chart type has a default y-axis value, set it\n    if (config.yAxis.defaultValue) {\n      activeSeries.value = config.yAxis.defaultValue;\n    }\n  }\n\n  emit(\"column-row-group-changed\", event);\n};\n\nconst handleFilterChanged = async (params: FilterChangedEvent<T>) => {\n  stackValuesPageIndex.value = 0;\n  processChartData(params.api);\n  if (firstDataRendered.value) {\n    emit(\"filter-changed\", params);\n  }\n};\n\nwatch(\n  () => currentRowGroupColumns.value,\n  () => {\n    // if the table is in grouped mode, update the groupings\n    // Defer grid API calls to next tick to avoid AG Grid error #252 (calling API during render)\n    if (pivotActive.value) {\n      // the pivot owns the grid's row groups\n    } else if (groupedModeEnabled.value) {\n      if (!gridApi.value) return;\n      // skip if the rows are already set\n      const currentCols = gridApi.value.getRowGroupColumns().map((col) => col.getColId());\n      if (JSON.stringify(currentCols) !== JSON.stringify(currentRowGroupColumns.value)) {\n        nextTick(() => {\n          gridApi.value?.setRowGroupColumns(currentRowGroupColumns.value);\n        });\n      }\n    } else {\n      nextTick(() => {\n        gridApi?.value?.setRowGroupColumns([]);\n      });\n    }\n    // if we don't want all columns to be focusable, update the focus type to match the first grouping column, if any\n    // chart types that don't support focus view should not set a focus type\n    if (!props.allFieldsAreFocusable) {\n      const newFocusType = !activeChartTypeConfig.value.supportsFocusView ? null : activeCategory.value || null;\n      chartFocusStore.setFocusType(newFocusType);\n    }\n\n    if (gridApi.value) {\n      stackValuesPageIndex.value = 0;\n      processChartData(gridApi.value);\n    }\n  },\n);\n\nfunction wrapValueFormatter(\n  field: string,\n  originalFormatter: ValueFormatterFunc | null,\n  truncateValues: boolean = true,\n) {\n  return (params: ValueFormatterParams) => {\n    //inject data into the params object by matching against the field name and value\n    params.data = chartData.value?.find((item) => item[field] === params.value);\n    // skip if null placeholder value\n    if (params.value === NULL_PLACEHOLDER_VALUE) {\n      return \"\";\n    }\n    let suffix = \"\";\n    const colDef = getColDefForField(field);\n    // only truncate if we're requesting it, the param is true, and the data type is numeric\n    const shouldTruncate = props.truncateLabelValues && truncateValues && colDef && isColDefNumericDataType(colDef);\n    if (shouldTruncate && !isNaN(Number(params.value))) {\n      // if stacked, calculate ratio of value relative to other sections, to determine if we need to hide the label\n      if (isStackedChart.value) {\n        // @ts-expect-error datum is not defined in ValueFormatterParams, but is available in the context of the chart\n        const currentCategory = params.datum?.[activeCategory.value];\n        const data = stackedChartData.value?.find((item) => item[activeCategory.value] === currentCategory);\n        // get ratio relative to the sort total, and don't display a label if it's less than 5% of the total\n        const sortTotal = data?.[`${activeSeries.value}${sortTotalSuffix}`] || Infinity;\n        const currentValueRatio = params.value / sortTotal;\n        if (currentValueRatio < 0.05) {\n          return \"\";\n        }\n      }\n      const { newValue, newSuffix } = truncateValue(\n        params.value,\n        ColDefDataType.Percent === colDefContext(colDef).dataType,\n        maxChartSeriesValue.value,\n      );\n      params.value = newValue;\n      suffix = newSuffix;\n    }\n    let result = params.value;\n    if (originalFormatter) {\n      result = originalFormatter(params);\n    }\n    return result + suffix;\n  };\n}\n\nconst getFormatterForColField = (field: string | undefined, truncateValues: boolean = false) => {\n  if (!field) return undefined;\n  const col = getColDefForField(field);\n  if (col && typeof col.valueFormatter === \"function\") {\n    return wrapValueFormatter(field, col.valueFormatter, truncateValues);\n  }\n  return wrapValueFormatter(field, null, truncateValues);\n};\n\nconst getColDefForField = (field: string | undefined): ColDef<T> | null => {\n  if (!field || !gridApi.value) {\n    return null;\n  }\n  return gridApi.value?.getColumnDef(field);\n};\n\n// AG Charts' default tooltip prints raw numbers (7576.98 — no grouping, no currency), so series\n// without a custom renderer format their value through the same column formatter the table uses\n// (pass-through when the column has none), with the category label formatted like the axis.\n// `valueKey` is the datum key holding the series value (differs from `formatterField` for\n// stacked/grouped series).\nconst defaultSeriesTooltip = (valueKey: string, formatterField: string) => {\n  const valueFormatter = getFormatterForColField(formatterField);\n  if (typeof valueFormatter !== \"function\") return undefined;\n  return {\n    renderer: (params: { datum?: Record<string, unknown> }) => {\n      const datum = params.datum ?? {};\n      const rawValue = datum[valueKey];\n      if (rawValue == null) {\n        return { content: \"\" };\n      }\n      const categoryFormatter = getFormatterForColField(activeCategory.value);\n      const rawCategory = datum[activeCategory.value];\n      const categoryLabel =\n        typeof categoryFormatter === \"function\"\n          ? categoryFormatter({ value: rawCategory } as ValueFormatterParams)\n          : String(rawCategory ?? \"\");\n      return { content: `${categoryLabel}: ${valueFormatter({ value: rawValue } as ValueFormatterParams)}` };\n    },\n  } as NonNullable<AgCartesianSeriesOptions[\"tooltip\"]>;\n};\n\n// A date column on the x-axis is always plotted oldest to newest - ordering a\n// timeline by its series value would make the chart unreadable - so the chart\n// sort selection is ignored (and cleared, below) while one is active.\nconst isChronologicalCategoryAxis = computed(() => {\n  return isChronologicalColDef(getColDefForField(activeCategory.value));\n});\n\nconst formatBucketRange = (bucketMin: number, bucketMax: number): string => {\n  const col = getColDefForField(activeCategory.value);\n  if (col && typeof col.valueFormatter === \"function\") {\n    const minStr = col.valueFormatter({ value: bucketMin } as ValueFormatterParams);\n    const maxStr = col.valueFormatter({ value: bucketMax } as ValueFormatterParams);\n    return `${minStr} - ${maxStr}`;\n  }\n  return `${bucketMin} - ${bucketMax}`;\n};\n\nconst formatBucketBoundary = (value: number): string => {\n  const col = getColDefForField(activeCategory.value);\n  if (col && typeof col.valueFormatter === \"function\") {\n    return col.valueFormatter({ value } as ValueFormatterParams);\n  }\n  return `${value}`;\n};\n\nconst chartTypes = computed(() => {\n  const configs = currentRowGroupColumns.value.length > 1 ? multiGroupChartTypeConfigs : singleGroupChartTypeConfigs;\n  // Histogram and Map are always offered (subject to `enabledChartTypes`), the\n  // same way the histogram is: selecting Map forces a region x-axis instead of\n  // the option only appearing once a region column is already the x-axis.\n  const allConfigs = [...configs, histogramChartTypeConfig, mapChartTypeConfig];\n  return allConfigs.filter((chartType) => props.enabledChartTypes?.includes(chartType.id as supportedChartType));\n});\n\nconst activeChartType = ref<MenuOption | undefined>(undefined);\n\n// Memory refs to track last used chart type for each grouping level\nconst lastSingleGroupChartType = ref<string | undefined>(undefined);\nconst lastMultiGroupChartType = ref<string | undefined>(undefined);\n// Track previous grouping level so the chartTypes watcher can detect transitions from single <--> multi.\nlet prevIsMultiGroup = false;\n\nconst activeChartTypeConfig = computed(() => getChartTypeConfig(activeChartType.value?.id || \"\"));\n\nconst effectiveRowGroupLimit = computed(() => {\n  return Math.min(activeChartTypeConfig.value.rowGroupLimit, props.rowGroupLimit);\n});\n\nconst chartTypeFilteredRowGroupColumns = computed(() => {\n  const filterFn = activeChartTypeConfig.value.xAxis.filterColumns;\n  const columns = filterFn ? filterFn(availableRowGroupColumns.value) : availableRowGroupColumns.value;\n  const order = props.rowGroupOptionOrder;\n  if (!order || order.length === 0) {\n    return columns;\n  }\n  // Stable sort: listed colIds take their list position, unlisted ones keep their existing\n  // relative order after the listed block.\n  const rank = (field: string | undefined) => {\n    const index = field ? order.indexOf(field) : -1;\n    return index === -1 ? Number.MAX_SAFE_INTEGER : index;\n  };\n  return [...columns].sort((a, b) => rank(a.field) - rank(b.field));\n});\n\nconst sortTypes: Ref<MenuOption[]> = ref([\n  {\n    text: \"Ascending\",\n    id: \"asc\",\n    icon: \"arrow-up-wide-narrow\",\n  },\n  {\n    text: \"Descending\",\n    id: \"desc\",\n    icon: \"arrow-down-narrow-wide\",\n  },\n]);\n\nconst chartData: Ref<AgChartOptions[\"data\"]> = ref([]);\nconst stackedChartData: Ref<AgChartOptions[\"data\"]> = ref([]);\nconst activeSeries = ref(props.yKey);\nconst activeSecondarySeries = ref<string | undefined>(availableSecondarySeriesColumns.value[0]?.value);\n// Multi-select metric overlay mode: selections live in this list instead of activeSecondarySeries.\nconst activeSecondarySeriesList = ref<string[]>([]);\nconst metricOverlayMultiSelect = computed(() => props.multiSelectMetricOverlay === true);\n\n// The overlay series values currently charted, regardless of picker mode. All series/axis\n// logic below is driven off this list; single-select mode is just a 0-or-1 entry list.\n// suppressMetricOverlays empties it without touching the picker state, so overlays come\n// back with their previous selections once the caller drops the flag.\nconst activeSecondarySeriesFields = computed<string[]>(() => {\n  if (props.suppressMetricOverlays) {\n    return [];\n  }\n  if (metricOverlayMultiSelect.value) {\n    return activeSecondarySeriesList.value;\n  }\n  return activeSecondarySeries.value ? [activeSecondarySeries.value] : [];\n});\n\n// Locked row-group colIds are enforced as active: prepend any locked id missing from the\n// current groups (in locked order), so a caller can drive a structural breakout reactively.\n// The currentRowGroupColumns watcher below emits chart-state-changed, so the enforced\n// grouping persists exactly like a picker change.\nwatch(\n  () => props.lockedRowGroupOptions.map((option) => option.id),\n  (lockedIds, previousLockedIds) => {\n    const locked = lockedIds ?? [];\n    // Symmetric enforcement: an id the caller stops locking also leaves the grouping — it was\n    // forced in, so it's forced out (e.g. the Drug breakout while 2+ drugs are selected). If\n    // the user manually re-adds it afterwards it stays, since it's no longer locked.\n    const unlocked = (previousLockedIds ?? []).filter((id) => !locked.includes(id));\n    const current = currentRowGroupColumns.value.filter((id) => !unlocked.includes(id));\n    if (locked.every((id) => current.includes(id)) && current.length === currentRowGroupColumns.value.length) {\n      return;\n    }\n    // Runtime-only (no immediate): the initial grouping comes from initialGridState in\n    // onBeforeMount, and an emit here before the grid mounts would hand consumers a\n    // chart-state-changed event with no grid API.\n    // Locked ids take the front of the list; unlocked ids keep whatever room the row-group\n    // limit leaves. Without the slice, enforcing a new locked id on top of an existing\n    // breakout pushes the grouping past the limit (e.g. Month + Drug + Provider), which the\n    // chart pivot can't render.\n    const merged = [...locked, ...current.filter((id) => !locked.includes(id))];\n    currentRowGroupColumns.value = merged.slice(0, Math.max(effectiveRowGroupLimit.value, locked.length));\n  },\n);\n\n// Preselect initialSecondaryYKeys (multi-select mode) once overlay columns first resolve —\n// they aren't available at setup because the grid hasn't mounted yet.\nlet initialSecondaryYKeysApplied = false;\nwatch(\n  availableSecondarySeriesColumns,\n  (columns) => {\n    if (\n      initialSecondaryYKeysApplied ||\n      !metricOverlayMultiSelect.value ||\n      !props.initialSecondaryYKeys?.length ||\n      columns.length === 0\n    ) {\n      return;\n    }\n    initialSecondaryYKeysApplied = true;\n    const wanted = new Set(props.initialSecondaryYKeys);\n    activeSecondarySeriesList.value = columns\n      .filter((column) => wanted.has(column.columnField ?? \"\") || wanted.has(column.value))\n      .map((column) => column.value);\n  },\n  { immediate: true },\n);\n\n// Crossline overlay groups: track which are toggled on. The rest of the benchmark-chip /\n// crossLine-overlay hover feature (active groups, resolved overlays, chips, hover tooltip) is\n// wired up by useBenchmarkOverlays() once its dependencies further down are ready - see below.\nconst crosslineOverlayGroups = computed(() => props.crosslineOverlayGroups ?? []);\nconst activeStackField = ref<StackField | null>(null); // used for stacked charts, if applicable\n// Which page of stack values (see stackValuesPageSize) is currently shown, when a\n// high-cardinality stack field is paged rather than rendered all at once.\nconst stackValuesPageIndex = ref(props.initialStackValuesPageIndex ?? 0);\n// Pagination summary for the current stack field, so the UI can show \"showing N-M of X\"\n// and page controls instead of silently only rendering some values (see helpers.ts\n// paginateStackValuesByTotal). Null when the stack field isn't paginated.\nconst stackValuesPagination = ref<{ total: number; pageCount: number } | null>(null);\nconst activeSort = ref<MenuOption | undefined>(sortTypes.value.find((type) => type.id === props.initialSort || \"\"));\nconst activeChartFilterOption = ref<string>(\"\");\n\nprovide(GridApiKey, gridApi);\nprovide(ActiveChartFilterOptionKey, activeChartFilterOption);\nprovide(AvailableRowGroupColumnsKey, chartTypeFilteredRowGroupColumns);\nprovide(RowGroupColumnsKey, currentRowGroupColumns);\nprovide(ChartTypeKey, chartTypes);\nprovide(SortTypesKey, sortTypes);\nprovide(ActiveChartKey, activeChartType);\nprovide(ActiveSortKey, activeSort);\nprovide(ActiveSeriesKey, activeSeries);\nprovide(AvailableSeriesKey, availableSeriesColumns);\nprovide(ActiveSecondarySeriesKey, activeSecondarySeries);\nprovide(ActiveSecondarySeriesListKey, activeSecondarySeriesList);\nprovide(AvailableSecondarySeriesKey, availableSecondarySeriesColumns);\nprovide(MetricOverlayMultiSelectKey, metricOverlayMultiSelect);\nprovide(AvailableCrosslineOverlayGroupsKey, crosslineOverlayGroups);\n\n// A chronological x-axis owns the ordering outright, so drop any sort selection\n// that would otherwise reappear when the user moves back to a non-date x-axis.\nwatch(\n  isChronologicalCategoryAxis,\n  (chronological) => {\n    if (chronological && activeSort.value) {\n      activeSort.value = undefined;\n    }\n  },\n  { immediate: true },\n);\n\nconst setActiveChartType = (newValue: string) => {\n  const chartTypeOption = chartTypes.value.find((type) => type.id === newValue);\n  activeChartType.value = chartTypeOption ?? chartTypes.value[0];\n};\n\nconst getCompatibleChartTypeId = (preferredTypeId?: string) => {\n  const rowGroupCount = currentRowGroupColumns.value.length;\n  const supportsCurrentRowGroupCount = (type: MenuOption) => {\n    const config = getChartTypeConfig(type.id);\n    return rowGroupCount <= Math.min(config.rowGroupLimit, props.rowGroupLimit);\n  };\n  const preferredType = chartTypes.value.find((type) => type.id === preferredTypeId);\n  if (preferredType && supportsCurrentRowGroupCount(preferredType)) {\n    return preferredType.id;\n  }\n  return chartTypes.value.find(supportsCurrentRowGroupCount)?.id ?? chartTypes.value[0]?.id;\n};\n\nwatch(\n  () => chartTypes.value,\n  () => {\n    const isMulti = isMultiGroupChart.value;\n    const groupLevelChanged = isMulti !== prevIsMultiGroup;\n    const currentConfig = getChartTypeConfig(activeChartType.value?.id || \"\");\n    const currentStillValid = chartTypes.value.some((t) => t.id === activeChartType.value?.id);\n    const currentExceedsRowGroupLimit =\n      currentRowGroupColumns.value.length > Math.min(currentConfig.rowGroupLimit, props.rowGroupLimit);\n\n    prevIsMultiGroup = isMulti;\n\n    // If the current type is still valid in the new list, keep it UNLESS the grouping\n    // level changed AND this is a storable chart type. Also fall back when the\n    // current type can't support the selected number of x-axes (e.g. active Map\n    // while adding Provider as a second x-axis after State), so we don't truncate\n    // the new x-axis just because Map remains selectable.\n    if (currentStillValid && !currentExceedsRowGroupLimit && (!groupLevelChanged || !currentConfig.storeBeforeChange)) {\n      return;\n    }\n\n    // Grouping level changed (for a normal chart type) or current type is no longer valid.\n    const lastSelectedChartType = isMulti ? lastMultiGroupChartType?.value : lastSingleGroupChartType?.value;\n    const fallbackChartType = getCompatibleChartTypeId(lastSelectedChartType ?? props.chartType);\n    if (fallbackChartType) {\n      setActiveChartType(fallbackChartType);\n    }\n  },\n);\n\nwatch(\n  () => props.chartType,\n  (newValue) => setActiveChartType(newValue),\n);\n\nwatch(\n  () => props.yKey,\n  (newValue) => {\n    if (newValue === activeSeries.value) {\n      return;\n    }\n    activeSeries.value = newValue;\n  },\n);\n\n// A changed page size invalidates the current page (e.g. 20 -> 10 shifts what page 1\n// even means), so reset to page 0 rather than recompute all pages.\nwatch(\n  () => props.stackValuesPageSize,\n  () => {\n    stackValuesPageIndex.value = 0;\n    if (gridApi.value) {\n      processChartData(gridApi.value);\n    }\n  },\n);\n\nwatch(activeChartFilterOption, (newValue) => {\n  if (props.chartFilter && gridApi.value) {\n    const colId = props.chartFilter.colId;\n    let filterValues = props.chartFilter.options.find((option) => option.value === newValue)?.filterValues || null;\n    if (filterValues && filterValues.length === 0) {\n      filterValues = null;\n    }\n    setFilterSelectedValues(colId, filterValues || []);\n    // TODO - update this to account for the potential that the filter is NOT a set filter\n    const setFilter = {\n      filterType: \"set\",\n      values: filterValues,\n    };\n    const newFilter = mapFilterBasedOnColDef(setFilter, getColDefForField(colId));\n    gridApi.value.setColumnFilterModel(colId, newFilter).then(() => {\n      gridApi.value?.onFilterChanged();\n    });\n  }\n});\n\nconst seriesDisplayName = (series: OptionWithFormatterAndDataType | undefined) => series?.label ?? \"\";\n\nconst activeSeriesDisplayName = computed(() =>\n  seriesDisplayName(findSeriesColumn(availableSeriesColumns.value, activeSeries.value)),\n);\n\n// Explicit note for when stackValuesPageSize is paging the stack field, so it's clear why\n// only some values are on the chart at once — see stackValuesPagination.\nconst stackValuesCapMessage = computed(() => {\n  const pagination = stackValuesPagination.value;\n  if (!pagination) return null;\n  const stackFieldLabel = getColDefForField(activeStackField.value?.fieldName)?.headerName || \"values\";\n  const seriesLabel = activeSeriesDisplayName.value || \"value\";\n  const pageSize = props.stackValuesPageSize || pagination.total;\n  const startIndex = stackValuesPageIndex.value * pageSize + 1;\n  const endIndex = Math.min(startIndex + pageSize - 1, pagination.total);\n  return `Showing ${startIndex}–${endIndex} of ${pagination.total} ${stackFieldLabel} by ${seriesLabel}.`;\n});\n\n// Stand-in legend for the currently paginated stack values, since AG Charts' own legend is\n// hidden while paginated (see options.legend.enabled) - matches series color by array\n// position the same way AG Charts' theme palette does (see cartesianSeries).\nconst paginatedStackValuesLegend = computed(() => {\n  if (!stackValuesPagination.value) return [];\n  const formatter = getFormatterForColField(activeStackField.value?.fieldName, true);\n  return (activeStackField.value?.fieldValues ?? []).map((fieldValue, index) => ({\n    key: fieldValue,\n    label:\n      typeof formatter === \"function\" ? String(formatter({ value: fieldValue } as ValueFormatterParams)) : fieldValue,\n    color: multicolorFills[index % multicolorFills.length],\n  }));\n});\n\nconst goToStackValuesPage = (newIndex: number) => {\n  if (!gridApi.value || newIndex === stackValuesPageIndex.value) return;\n  stackValuesPageIndex.value = newIndex;\n  emit(\"stack-values-page-changed\", newIndex);\n  processChartData(gridApi.value);\n};\n\n// Overlays whose colDef context sets `chartOverlayOnPrimaryAxis` bind to the primary (left)\n// y-axis instead of the shared secondary axis — but only while their dataType matches the\n// active primary metric's. Same-unit overlays (e.g. dollar benchmarks over a dollar rate)\n// then read on one honest scale; when the primary metric switches to a different unit\n// (e.g. a percentage), the overlay falls back to the secondary benchmark axis automatically.\nconst isPrimaryAxisOverlayField = (field: string): boolean => {\n  const overlayColumn = findSeriesColumn(availableSecondarySeriesColumns.value, field);\n  const columnField = overlayColumn?.columnField ?? field;\n  if (getColDefForField(columnField)?.context?.chartOverlayOnPrimaryAxis !== true) return false;\n  const primaryColumn = findSeriesColumn(availableSeriesColumns.value, activeSeries.value);\n  return overlayColumn?.dataType != null && overlayColumn.dataType === primaryColumn?.dataType;\n};\nconst secondaryOnlyOverlayFields = computed(() =>\n  activeSecondarySeriesFields.value.filter((field) => !isPrimaryAxisOverlayField(field)),\n);\nconst primaryAxisOverlayFields = computed(() =>\n  activeSecondarySeriesFields.value.filter((field) => isPrimaryAxisOverlayField(field)),\n);\n\n// One secondary axis serves all active overlays; its title lists their names.\nconst secondaryAxisTitle = computed(() =>\n  secondaryOnlyOverlayFields.value\n    .map((field) => seriesDisplayName(findSeriesColumn(availableSecondarySeriesColumns.value, field)))\n    .filter(Boolean)\n    .join(\", \"),\n);\n\nconst isHorizontalBarChart = computed(() => {\n  return activeChartTypeConfig.value.isHorizontal === true;\n});\n\n// Overlay series type. `secondaryChartType: \"line\"` is honored on vertical charts only:\n// scatter handles horizontal orientation via explicit x/y key swapping (see buildScatterAxes),\n// which line series don't support, so horizontal charts always fall back to scatter.\nconst secondaryOverlayChartType = computed<\"scatter\" | \"line\">(() =>\n  props.secondaryChartType === \"line\" && !isHorizontalBarChart.value ? \"line\" : \"scatter\",\n);\n\nconst stackedChartEnabled = computed(() => {\n  return currentRowGroupColumns.value.length > 1;\n});\n\nconst chartSeries = computed(() => {\n  if (!activeChartType.value) {\n    return [];\n  }\n  if (availableSeriesColumns.value.length === 0) {\n    return [];\n  }\n  const config = activeChartTypeConfig.value;\n  if (config.seriesFamily === \"pie\") {\n    return pieSeries.value;\n  }\n  // cartesian family (bar, line, area, histogram, etc.)\n  return cartesianSeries.value;\n});\n\nconst displaySeriesLabels = computed(() => {\n  // Histogram bars never show their count label; the bucket counts are on the y-axis.\n  if (activeChartType.value?.id === \"histogram\") {\n    return false;\n  }\n  return props.showSeriesLabels;\n});\n\nconst isStackedChart = computed(() => {\n  return activeChartType.value?.id.includes(\"stacked\");\n});\n\nconst isMultiGroupChart = computed(() => currentRowGroupColumns.value.length > 1);\n\n// Check if we're in histogram mode with numeric buckets\nconst isHistogramWithBuckets = computed(() => {\n  return (\n    activeChartType.value?.id === \"histogram\" &&\n    computedChartData.value &&\n    computedChartData.value.length > 0 &&\n    typeof computedChartData.value[0]?.bucketMin === \"number\" &&\n    typeof computedChartData.value[0]?.bucketMax === \"number\"\n  );\n});\n\n// Stable series id for the primary metric. AG Charts' LegendManager keys legend entries by\n// series id and only clears stale entries when the series count or types change. A y-axis\n// switch swaps one same-type series for another (same count), so without a stable id the\n// replacement gets a fresh generated id and the old entry is orphaned — the legend then\n// accumulates one stale item per switch. A stable id makes the replacement overwrite it.\n// For the stacked case, ids are keyed by stack position (index), not by the stack field's\n// value: if the composition of stack values changes but the count doesn't (e.g. a filter\n// swaps in a different top-N group), AG Charts still sees a same-count/same-type series set\n// and won't clear stale legend entries, so a value-keyed id would reproduce the same orphaned-\n// entry bug this fix targets. Position-keyed ids stay stable across that case too — only the\n// series' yName (the visible legend label) changes.\nconst PRIMARY_SERIES_ID = \"primary-series\";\n\n// The stable-id fix above covers a same-count series swap, but AG Charts' legend also fails to\n// clear when the primary-series COUNT itself changes (e.g. toggling a row-group breakout):\n// ids shift between \"primary-series\" and \"primary-series-0..N\", and the stale entries are\n// never dropped from LegendManager's map. Remounting on count change resets AG's internal\n// state instead of relying on its own clearing heuristic.\nconst chartInstanceKey = computed(() => {\n  const groupCount = stackedChartEnabled.value ? (activeStackField.value?.fieldValues.length ?? 0) : 1;\n  // The mode rides along because a flat chart and a one-group breakout share groupCount 1,\n  // yet swap the whole series id/yKey scheme (PRIMARY_SERIES_ID vs -0..N, plain metric key vs\n  // generateStackSeriesKey) — without a remount, AG Charts' stale legend/series state renders\n  // an empty chart on that transition.\n  const mode = stackedChartEnabled.value ? \"grouped\" : \"flat\";\n  return `${activeChartType.value?.id ?? \"chart\"}-${mode}-${groupCount}`;\n});\n\nconst cartesianSeries = computed(() => {\n  const isStacked = isStackedChart.value;\n  const chartType = activeChartTypeConfig.value.agChartType;\n  let series: AgCartesianSeriesOptions[] = [];\n  const seriesFormatter = getFormatterForColField(activeSeries.value, true);\n  const stackFieldFormatter = getFormatterForColField(activeStackField.value?.fieldName, true);\n  // Line series labels have no placement option - AG Charts warns and ignores it.\n  const labelPlacement = (placement: \"inside-end\" | \"outside-end\") => (chartType === \"line\" ? {} : { placement });\n  if (stackedChartEnabled.value) {\n    const stackField = activeStackField.value;\n    stackField?.fieldValues.forEach((fieldValue: string, index: number) => {\n      const newSeries = {\n        type: chartType,\n        id: `${PRIMARY_SERIES_ID}-${index}`,\n        xKey: activeCategory.value,\n        yKey: generateStackSeriesKey(activeSeries.value, fieldValue),\n        yName:\n          typeof stackFieldFormatter === \"function\"\n            ? stackFieldFormatter({ value: fieldValue } as ValueFormatterParams)\n            : fieldValue,\n        // Line series have no stacking concept - a secondary group renders as one\n        // line per group value, never as a stack.\n        ...(chartType === \"line\" ? {} : { stacked: isStacked }),\n        label: {\n          // A secondary group splits the chart into one line per group value, where a\n          // label on every point of every line is unreadable.\n          enabled: displaySeriesLabels.value && chartType !== \"line\",\n          color: isStacked ? \"white\" : \"black\",\n          fontFamily: \"Inter\",\n          padding: 5,\n          fontSize: 11,\n          ...labelPlacement(isStacked ? \"inside-end\" : \"outside-end\"),\n          formatter: seriesFormatter,\n        },\n        tooltip: defaultSeriesTooltip(generateStackSeriesKey(activeSeries.value, fieldValue), activeSeries.value),\n      } as AgBarSeriesOptions;\n      series.push(newSeries);\n    });\n  } else {\n    const newSeries = {\n      type: chartType,\n      id: PRIMARY_SERIES_ID,\n      xKey: activeCategory.value,\n      yKey: activeSeries.value,\n      yName: activeSeriesDisplayName.value,\n      label: {\n        enabled: displaySeriesLabels.value,\n        color: \"black\",\n        fontFamily: \"Inter\",\n        padding: 5,\n        fontSize: 11,\n        ...labelPlacement(\"outside-end\"),\n        formatter: seriesFormatter,\n      },\n      tooltip: defaultSeriesTooltip(activeSeries.value, activeSeries.value),\n    } as AgBarSeriesOptions;\n    series.push(newSeries);\n  }\n  // options specific to the chart type\n  let extraChartOptions = {} as AgCartesianSeriesOptions;\n  if (chartType === \"bar\") {\n    const options = extraChartOptions as AgBarSeriesOptions;\n    options.direction = isHorizontalBarChart.value ? \"horizontal\" : \"vertical\";\n    extraChartOptions = options;\n  } else if (chartType === \"line\" || chartType === \"area\") {\n    const options = extraChartOptions as AgLineSeriesOptions | AgAreaSeriesOptions;\n    options.connectMissingData = true;\n    extraChartOptions = options;\n  }\n  // Dim the bar series while a benchmark chip is hovered, so its crossLine stands out.\n  const barDimOpacity = hoveredBenchmarkKey.value != null ? { fillOpacity: 0.3, strokeOpacity: 0.3 } : {};\n  series = series.map((item) => {\n    return {\n      ...item,\n      ...extraChartOptions,\n      ...barDimOpacity,\n    } as AgCartesianSeriesOptions;\n  });\n\n  // For histogram-like data with bucket ranges, add tooltip formatting\n  if (activeChartTypeConfig.value.yAxis.defaultValue === BUCKET_AGG_COUNT_VALUE_NAME) {\n    series = series.map(\n      (item) =>\n        ({\n          ...item,\n          tooltip: {\n            renderer: (\n              params: AgSeriesTooltipRendererParams<Record<string, string>> & { xKey: string; yKey: string },\n            ) => {\n              let title = String(params.datum[params.xKey] ?? \"\");\n              const min = params.datum.bucketMin;\n              const max = params.datum.bucketMax;\n              if (typeof min === \"number\" && typeof max === \"number\") {\n                title = formatBucketRange(min, max);\n              }\n              return { title, content: `Count: ${params.datum[params.yKey]}` };\n            },\n          },\n        }) as AgCartesianSeriesOptions,\n    );\n  }\n\n  if (activeSecondarySeriesFields.value.length > 0) {\n    const xCol = getColDefForField(activeCategory.value);\n    const xName = xCol?.context?.metadataDisplayFields?.[0] || activeCategory.value;\n    const overlayType = secondaryOverlayChartType.value;\n\n    for (const overlayField of activeSecondarySeriesFields.value) {\n      const overlayColumn = findSeriesColumn(availableSecondarySeriesColumns.value, overlayField);\n      const overlayDisplayName = seriesDisplayName(overlayColumn);\n      const overlayYKey = !isStacked ? overlayField : `${overlayField}${sortTotalSuffix}`;\n\n      const scatterAxes = buildScatterAxes(\n        activeCategory.value,\n        xName,\n        overlayYKey,\n        overlayDisplayName,\n        isHorizontalBarChart.value,\n      );\n\n      // A line needs two points to draw a segment, so an overlay with a single plottable\n      // value (e.g. the report filtered down to one month) would render nothing with markers\n      // off — show the marker in that case so the benchmark stays visible.\n      const overlayPointCount = (scatterChartData.value ?? []).filter((row) => row[overlayYKey] != null).length;\n\n      const secondarySeriesOptions = {\n        type: overlayType,\n        // Keep the historical id for the single-select overlay; multi-select overlays need\n        // one id per series.\n        id: metricOverlayMultiSelect.value ? `metric-overlay-${overlayField}` : \"metric-overlay\",\n        data: scatterChartData.value,\n        ...scatterAxes,\n        label: {\n          enabled: false,\n        },\n        // Line overlays render as dashed benchmark lines: no point markers (single-point case\n        // aside), and gaps in the benchmark don't break the line.\n        ...(overlayType === \"line\"\n          ? {\n              lineDash: [4, 4],\n              strokeWidth: 2,\n              marker: { enabled: overlayPointCount < 2 },\n              connectMissingData: true,\n            }\n          : {}),\n      } as AgCartesianSeriesOptions;\n\n      if (overlayColumn?.tooltipRenderer) {\n        const originalRenderer = overlayColumn.tooltipRenderer;\n        secondarySeriesOptions[\"tooltip\"] = {\n          // Always call the renderer with canonical keys (category→xKey, metric→yKey)\n          // regardless of chart orientation.\n          renderer: isHorizontalBarChart.value\n            ? (params: Parameters<typeof originalRenderer>[0]) =>\n                originalRenderer({\n                  ...params,\n                  xKey: activeCategory.value,\n                  xName,\n                  yKey: overlayYKey,\n                  yName: overlayDisplayName,\n                })\n            : originalRenderer,\n        };\n      } else {\n        // No custom renderer: fall back to the column-formatter tooltip so benchmark values\n        // render like their table column (currency grouping and precision included).\n        const fallbackTooltip = defaultSeriesTooltip(overlayYKey, overlayField);\n        if (fallbackTooltip) {\n          secondarySeriesOptions[\"tooltip\"] = fallbackTooltip;\n        }\n      }\n\n      series = [...series, secondarySeriesOptions];\n    }\n  }\n\n  // Add invisible scatter series to support numeric x-axis for vertical lines in histogram mode\n  if (isHistogramWithBuckets.value && resolvedCrosslineOverlays.value.length > 0 && computedChartData.value) {\n    const numCategories = computedChartData.value.length;\n    const maxY = Number.isFinite(maxChartSeriesValue.value) ? maxChartSeriesValue.value : 0;\n\n    // Dummy series with data points to establish the numeric axis scale\n    const dummySeries = {\n      type: \"scatter\" as const,\n      xKey: \"__dummy_x__\",\n      yKey: \"__dummy_y__\",\n      data: [\n        { __dummy_x__: -1, __dummy_y__: 0 },\n        { __dummy_x__: numCategories + 1, __dummy_y__: maxY },\n      ],\n      label: {\n        enabled: false,\n      },\n      tooltip: {\n        enabled: false,\n      },\n      visible: false,\n    } as AgCartesianSeriesOptions;\n\n    const OVERLAY_POINTS_PER_LINE = 30;\n\n    // Must match the offset applied to the visible crossLines in computedChartOptions,\n    // or the invisible hover hit-target drifts away from the line.\n    const { categoryPadOffset } = getCrosslineAxisDomain(numCategories, true);\n\n    const verticalOverlaySeries = {\n      type: \"scatter\" as const,\n      xKey: \"__dummy_x__\",\n      yKey: \"__dummy_y__\",\n      data: resolvedCrosslineOverlays.value.flatMap((overlay) => {\n        const scaled = scaleValueToIndex(overlay.value, computedChartData.value || []);\n        if (scaled === null) {\n          return [];\n        }\n        const scaledWithOffset = scaled + categoryPadOffset;\n        const maxY = Number.isFinite(maxChartSeriesValue.value) ? maxChartSeriesValue.value : 0;\n        const formatter = getFormatterForColField(currentRowGroupColumns.value?.[0]);\n        const formattedValue =\n          typeof formatter === \"function\" ? formatter({ value: overlay.value } as ValueFormatterParams) : overlay.value;\n\n        return Array.from({ length: OVERLAY_POINTS_PER_LINE }, (_, i) => ({\n          value: formattedValue,\n          __dummy_x__: scaledWithOffset,\n          __dummy_y__: (maxY / (OVERLAY_POINTS_PER_LINE - 1)) * i,\n          __dummy_overlay_label__: overlay.label,\n          [activeSeries.value]: maxY,\n        }));\n      }),\n      size: 15,\n      fill: \"transparent\",\n      stroke: \"transparent\",\n      strokeWidth: 0,\n      marker: {\n        enabled: false,\n      },\n      itemStyler: () => ({\n        size: 15,\n        fill: \"transparent\",\n        stroke: \"transparent\",\n        strokeWidth: 0,\n      }),\n      label: {\n        enabled: false,\n      },\n      tooltip: {\n        range: 1,\n        renderer: (params: AgSeriesTooltipRendererParams<Record<string, number | string>>) => {\n          const label = String(params.datum.__dummy_overlay_label__ ?? \"\");\n          const value = params.datum.value;\n          return `<div class=\"pv-flex pv-space-between\" style=\"padding: 8px\">\n            <div class=\"pv-chart-tooltip-label\">${label}</div>\n            <div class=\"pv-chart-tooltip-value\">${value}</div>\n          </div>`;\n        },\n      },\n    } as AgCartesianSeriesOptions;\n\n    series = [...series, dummySeries, verticalOverlaySeries];\n  }\n\n  return series;\n});\n\nconst pieSeries = computed(() => {\n  // Pie charts only support a single series\n  if (availableSeriesColumns.value.length === 0) {\n    return [];\n  }\n  const newSeries = {\n    type: \"pie\",\n    legendItemKey: activeCategory.value,\n    angleKey: activeSeries.value,\n  } as AgPieSeriesOptions;\n  return [newSeries];\n});\n\nwatch(activeSeries, (newValue, oldValue) => {\n  emit(\"chart-state-changed\", {\n    api: gridApi.value,\n    newState: {\n      seriesField: newValue,\n    },\n    oldState: {\n      seriesField: oldValue,\n    },\n  });\n});\n\nwatch(activeSecondarySeries, (newValue, oldValue) => {\n  emit(\"chart-state-changed\", {\n    api: gridApi.value,\n    newState: {\n      secondarySeriesField: newValue,\n    },\n    oldState: {\n      secondarySeriesField: oldValue,\n    },\n  });\n});\n\nwatch(activeSecondarySeriesList, (newValue, oldValue) => {\n  emit(\"chart-state-changed\", {\n    api: gridApi.value,\n    newState: {\n      secondarySeriesField: newValue.join(\",\") || undefined,\n    },\n    oldState: {\n      secondarySeriesField: oldValue?.join(\",\") || undefined,\n    },\n  });\n});\n\nwatch(activeChartType, (newValue, oldValue) => {\n  // Keep memory up to date on every chart type change (panel selection, restore, etc.).\n  // Skip memory for chart types that don't have storeBeforeChange (e.g. histogram).\n  if (newValue?.id) {\n    const cfg = getChartTypeConfig(newValue.id);\n    if (cfg.storeBeforeChange) {\n      if (isMultiGroupChart.value) {\n        lastMultiGroupChartType.value = newValue.id;\n      } else {\n        lastSingleGroupChartType.value = newValue.id;\n      }\n    }\n  }\n\n  const newConfig = getChartTypeConfig(newValue?.id || \"\");\n  const oldConfig = getChartTypeConfig(oldValue?.id || \"\");\n\n  // If the x-axis column filter changed (different chart family), drop only the row\n  // group columns that aren't valid under the new chart type's x-axis filter. This\n  // keeps a still-valid x-axis (e.g. `state` when switching into/out of the map\n  // chart type) instead of clearing it and losing the selection. Always enforce\n  // the new chart type's row group limit too, since map/histogram only support a\n  // single x-axis even when switching from a multi-group chart.\n  const retainedRowGroupColumns =\n    newConfig.xAxis.filterColumns !== oldConfig.xAxis.filterColumns\n      ? retainValidXAxisFields(\n          currentRowGroupColumns.value,\n          availableRowGroupColumns.value,\n          newConfig.xAxis.filterColumns,\n        )\n      : currentRowGroupColumns.value;\n  const limitedRowGroupColumns = retainedRowGroupColumns.slice(\n    0,\n    Math.min(newConfig.rowGroupLimit, props.rowGroupLimit),\n  );\n  // The map has nothing to plot without a region x-axis, so default to `state` when none carried over.\n  if (\n    newConfig.seriesFamily === \"map\" &&\n    limitedRowGroupColumns.length === 0 &&\n    chartTypeFilteredRowGroupColumns.value.some((col) => col.field === MAP_REGION_FIELD)\n  ) {\n    limitedRowGroupColumns.push(MAP_REGION_FIELD);\n  }\n  if (!isEqual(limitedRowGroupColumns, currentRowGroupColumns.value)) {\n    currentRowGroupColumns.value = limitedRowGroupColumns;\n  }\n\n  // If new config has a default y-axis value, set activeSeries to it\n  if (newConfig.yAxis.defaultValue) {\n    activeSeries.value = newConfig.yAxis.defaultValue;\n  } else if (oldConfig.yAxis.defaultValue && !newConfig.yAxis.defaultValue) {\n    // Transitioning away from a type with default y-axis: reset to props.yKey or first available\n    nextTick(() => {\n      if (props.yKey) {\n        activeSeries.value = props.yKey;\n      } else if (availableSeriesColumns.value.length > 0) {\n        activeSeries.value = availableSeriesColumns.value[0].value;\n      }\n    });\n  }\n\n  emit(\"chart-state-changed\", {\n    api: gridApi.value,\n    newState: {\n      chartType: newValue?.id,\n    },\n    oldState: {\n      chartType: oldValue?.id,\n    },\n  });\n});\n\n// Auto-select x-axis when only one option is available and none currently selected\nwatch(chartTypeFilteredRowGroupColumns, (newColumns) => {\n  if (newColumns.length === 1 && currentRowGroupColumns.value.length === 0) {\n    const field = newColumns[0].field;\n    if (field) {\n      currentRowGroupColumns.value = [field];\n    }\n  }\n});\n\n// Auto-select y-axis when only one option is available and none currently selected\nwatch(availableSeriesColumns, (newColumns) => {\n  if (newColumns.length === 1 && !activeSeries.value) {\n    activeSeries.value = newColumns[0].value;\n  }\n});\n\nwatch(activeSort, (newValue, oldValue) => {\n  emit(\"chart-state-changed\", {\n    api: gridApi.value,\n    newState: {\n      chartSort: newValue?.id,\n    },\n    oldState: {\n      chartSort: oldValue?.id,\n    },\n  });\n});\n\nwatch(currentRowGroupColumns, (newValue, oldValue) => {\n  emit(\"chart-state-changed\", {\n    api: gridApi.value,\n    newState: {\n      chartCategoryFields: newValue,\n    },\n    oldState: {\n      chartCategoryFields: oldValue,\n    },\n  });\n});\n\nwatch(groupedModeEnabled, (newValue, oldValue) => {\n  emit(\"chart-state-changed\", {\n    api: gridApi.value,\n    newState: {\n      tableGrouped: newValue,\n    },\n    oldState: {\n      tableGrouped: oldValue,\n    },\n  });\n});\n\n/*\n * Need this watcher in case the table grouping changes outside of the \"toggle\" button.\n */\nwatch(\n  () => props.isTableGrouped,\n  (newVal, oldVal) => {\n    if (!gridApi.value || newVal === oldVal || !props.enableGroupingToggle) {\n      return;\n    }\n\n    // Toggle the grouping based on the new value.\n    toggleGroupState(newVal);\n  },\n);\n\nwatch(\n  () => props.initialFocusData,\n  (newVal, oldVal) => {\n    // If the old and new focuses/focus types are the same skip——nothing's changed.\n    if (isEqual(newVal?.focuses, oldVal?.focuses) && newVal?.focusType == oldVal?.focusType) {\n      return;\n    }\n\n    // If there's no focusType (e.g. navigating to a page in browser history with no focuses), clear our focuses and\n    // end early.\n    if (!newVal?.focusType) {\n      chartFocusStore.setFocuses([]);\n      return;\n    }\n\n    chartFocusStore.setFocusType(newVal?.focusType);\n    chartFocusStore.setFocuses(newVal?.focuses ?? []);\n  },\n  { deep: true },\n);\n\nconst clearChartData = () => {\n  chartData.value = [];\n  stackedChartData.value = [];\n  activeStackField.value = null;\n  stackValuesPagination.value = null;\n};\n\nconst processServerSideData = (data: AgChartOptions[\"data\"], stackField: string) => {\n  if (!data || data.length === 0) {\n    clearChartData();\n    return;\n  }\n  if (stackField) {\n    // metricOverlayWithRowGroups: carry the overlay columns' plain per-category values through\n    // the pivot (the supplementary pass-through copies row[field] as-is), so overlay series can\n    // chart them alongside the per-group series keys.\n    const supplementaryColumns = props.metricOverlayWithRowGroups\n      ? [...supplementaryChartingColumns.value, ...availableSecondarySeriesColumns.value]\n      : supplementaryChartingColumns.value;\n    const {\n      stackedData,\n      uniqueFieldValues,\n      totalStackValueCount,\n      stackValuesPageCount,\n      stackValuesPageIndex: clampedPageIndex,\n    } = buildStackedChartData(\n      data,\n      activeCategory.value,\n      stackField,\n      allSeriesColumns.value,\n      supplementaryColumns,\n      activeSeries.value,\n      props.stackValuesPageSize,\n      stackValuesPageIndex.value,\n    );\n    stackedChartData.value = stackedData;\n    activeStackField.value = {\n      fieldName: stackField,\n      fieldValues: uniqueFieldValues,\n    };\n    // Sync back if the requested page was out of range (e.g. the data shrank).\n    if (clampedPageIndex !== stackValuesPageIndex.value) {\n      stackValuesPageIndex.value = clampedPageIndex;\n    }\n    stackValuesPagination.value =\n      stackValuesPageCount > 1 ? { total: totalStackValueCount, pageCount: stackValuesPageCount } : null;\n  } else {\n    stackedChartData.value = [];\n    activeStackField.value = null;\n    stackValuesPagination.value = null;\n  }\n  chartData.value = data;\n};\n\nconst processChartData = (api: GridApi) => {\n  const currentRequestId = ++chartRequestId.value;\n  const groupLevels = currentRowGroupColumns.value.length;\n  // clear chart data to avoid overlapping data in visualizations\n  clearChartData();\n  displayChartLoading.value = false;\n  if (groupLevels === 0 || availableSeriesColumns.value.length === 0) {\n    // if no groups, collect no data\n    return;\n  }\n  // if no filters and we require filters to show data, don't collect any data\n  if (props.requireFiltersToShowData && chartFilterStore.filterModelEmpty.value) {\n    return;\n  }\n  if (props.serverSideChartHandler) {\n    // Use the filter store as the source of truth — PvDataTable always updates it\n    // before emitting filter-changed. When the store is null (handleGridReady, before\n    // any filter change), fall back to the initial grid state's filter model.\n    let filterModel = chartFilterStore.filterModel.value;\n    const colDefs = gridApi.value?.getColumnDefs() || [];\n    if (filterModel === null && props.initialGridState) {\n      const cleanedState = cleanInitialGridState(props.initialGridState, colDefs, props.enableAdvancedFilter);\n      filterModel =\n        (props.enableAdvancedFilter ? cleanedState?.filter?.advancedFilterModel : cleanedState?.filter?.filterModel) ||\n        {};\n    }\n    filterModel = filterModel || {};\n    // use the currentRowGroupColumns since the table may not be in grouped mode\n    const rowGroupCols = mapColsToColumnV0(\n      currentRowGroupColumns.value\n        .map((colId) => {\n          return gridApi.value?.getColumn(colId);\n        })\n        .filter((colDef) => colDef !== undefined) as Column[],\n    );\n    const processedRowGroupCols = processRowGroupCols(rowGroupCols, colDefs);\n    // only send the value cols that are actually being used in the chart, to avoid unnecessary processing in the handler\n    // always include all secondary axis columns (including hideFromCharting ones like total_codes)\n    // so switching overlay doesn't require a re-fetch\n    const secondaryColIds = new Set(\n      colDefs\n        .filter((cd) => colDefContext(cd).chartOnSecondaryAxes === true)\n        .map((cd) => (cd as ColDef).field)\n        .filter(Boolean),\n    );\n    const isActiveValueCol = (colId: string) => colId === activeSeries.value || secondaryColIds.has(colId);\n    const valueCols: ColumnVO[] = pivotActive.value\n      ? (pvDataTableRef.value?.availableAggFuncColumns || [])\n          .filter((colDef) => colDef.field && isActiveValueCol(colDef.field))\n          .map((colDef) => ({\n            id: colDef.field!,\n            field: colDef.field!,\n            displayName: colDef.headerName || \"\",\n            aggFunc: activeAggFuncForColDef(colDef),\n          }))\n      : mapColsToColumnV0(gridApi.value?.getValueColumns().filter((col) => isActiveValueCol(col.getColId())) || []);\n    const chartHandlerParams: ServerSideChartDataHandlerParams = {\n      rowGroupCols: processedRowGroupCols || [],\n      valueCols,\n      filterModel: filterModel,\n    };\n    displayChartLoading.value = true;\n    props\n      .serverSideChartHandler(chartHandlerParams)\n      .then((result) => {\n        // Only process the result if this is still the latest request\n        if (currentRequestId === chartRequestId.value) {\n          processServerSideData(result.data, result.stackField);\n          displayChartLoading.value = false;\n        }\n      })\n      .catch((error) => {\n        // Only handle errors for the latest request\n        if (currentRequestId === chartRequestId.value) {\n          console.error(\"Chart handler error:\", error);\n          displayChartLoading.value = false;\n        }\n      });\n    return;\n  }\n  if (props.serverSideRowHandler) return;\n  const data = [] as AgChartOptions[\"data\"];\n  const stackData = [] as AgChartOptions[\"data\"];\n  let uniqueFieldValues = new Set<string>();\n  // get grouped row data\n  api.forEachNodeAfterFilterAndSort((rowNode: IRowNode<T>) => {\n    if (rowNode.group && rowNode.level === 0) {\n      if (currentRowGroupColumns.value.length > 1) {\n        // for stacked charts, we need to aggregate the sub-fields separately\n        const childNodes =\n          rowNode.childrenAfterFilter?.filter((childNode: IRowNode<T>) => childNode.level === 1 && childNode.aggData) ||\n          [];\n        const { rowData, fieldValues } = getStackedChartDataFromRowNodes(rowNode, childNodes);\n        uniqueFieldValues = uniqueFieldValues.union(fieldValues);\n        stackData?.push(rowData);\n      }\n      // always collect the base aggregate info\n      const rowData = getChartDataFromRowNode(rowNode) as Record<string, string | number | null>;\n      data?.push(rowData);\n    }\n  });\n  chartData.value = data;\n  if (currentRowGroupColumns.value.length > 1 && stackData && stackData.length > 0) {\n    const stackField = currentRowGroupColumns.value[1] || \"\";\n    const page = paginatePivotedStackValuesByTotal(\n      stackData,\n      Array.from(uniqueFieldValues),\n      allSeriesColumns.value,\n      activeSeries.value,\n      props.stackValuesPageSize,\n      stackValuesPageIndex.value,\n    );\n    stackedChartData.value = page.data;\n    activeStackField.value = {\n      fieldName: stackField,\n      fieldValues: page.orderedLabels,\n    };\n    // Sync back if the requested page was out of range (e.g. the data shrank).\n    if (page.pageIndex !== stackValuesPageIndex.value) {\n      stackValuesPageIndex.value = page.pageIndex;\n    }\n    stackValuesPagination.value = page.pageCount > 1 ? { total: page.total, pageCount: page.pageCount } : null;\n  } else {\n    stackedChartData.value = [];\n    activeStackField.value = null;\n    stackValuesPagination.value = null;\n  }\n};\n\nconst allSeriesColumns = computed(() => {\n  const primary = availableSeriesColumns.value;\n  const secondary = availableSecondarySeriesColumns.value;\n\n  return [...new Map([...secondary, ...primary].map((col) => [col.value, col])).values()];\n});\n\n// the aggregate chart data for all series fields, not separated by any secondary groupings\nconst getChartDataFromRowNode = (rowNode: IRowNode<T>) => {\n  const rowData: Record<string, string | number | null> = {\n    [rowNode.field as string]: rowNode.key,\n  };\n  for (const field of allSeriesColumns.value) {\n    if (!rowNode.aggData || !rowNode.aggData[field.value]) {\n      // If there is no aggregated data for this field, skip it\n      continue;\n    }\n    rowData[field.value] = rowNode.aggData[field.value]?.value ?? rowNode.aggData[field.value];\n  }\n  return rowData;\n};\n\nconst getStackedChartDataFromRowNodes = (parentNode: IRowNode<T>, rowNodes: IRowNode<T>[]) => {\n  const uniqueFieldValues = new Set<string>();\n  const rowData: Record<string, string | number | null> = {\n    [parentNode.field as string]: parentNode.key,\n  };\n  let sortTotal = 0;\n  for (const field of availableSeriesColumns.value) {\n    rowNodes.forEach((childNode) => {\n      const stackField = childNode.key;\n      uniqueFieldValues.add(stackField as string);\n      const stackValueAggData = childNode.aggData;\n      if (stackField && stackValueAggData) {\n        const stackFieldKey = String(stackField);\n        const secondaryCategoryKey = generateStackSecondaryCategoryKey(stackFieldKey);\n        rowData[secondaryCategoryKey] = `${parentNode.key}-${stackFieldKey}`;\n        const aggValue = childNode.aggData[field.value]?.value ?? childNode.aggData[field.value];\n        rowData[generateStackSeriesKey(field.value, stackFieldKey)] = aggValue;\n        sortTotal = sortTotal + aggValue;\n      }\n    });\n    rowData[`${field.value}${sortTotalSuffix}`] = sortTotal;\n  }\n  return {\n    rowData: rowData,\n    fieldValues: uniqueFieldValues,\n  };\n};\n\nconst computedChartData = computed(() => {\n  // if stacked chart is enabled, return the stacked chart data\n  let outputData = stackedChartEnabled.value ? stackedChartData.value : chartData.value;\n  let sortField = null;\n\n  if (activeSort.value) {\n    sortField = stackedChartEnabled.value ? `${activeSeries.value}${sortTotalSuffix}` : activeSeries.value;\n  }\n  // a date x-axis is always ordered oldest to newest, whatever the chart sort says\n  if (isChronologicalCategoryAxis.value) {\n    outputData = sortChartDataChronologically(outputData, activeCategory.value);\n  } else if (sortField && outputData && activeSort.value) {\n    const direction = activeSort.value?.id.includes(\"desc\") ? -1 : 1;\n    outputData = [...outputData].sort((a, b) => {\n      const aValue = a[sortField] || 0;\n      const bValue = b[sortField] || 0;\n      return (aValue - bValue) * direction;\n    });\n  }\n  // Pad single-category bar charts so the lone bar isn't full-width. Uses sentinel\n  // categories that never collide with a real (possibly blank) category - see\n  // padSingleCategoryBarData.\n  if (activeChartTypeConfig.value.agChartType === \"bar\") {\n    outputData = padSingleCategoryBarData(outputData, activeCategory.value);\n  }\n  // for focus data, prioritize the focus element to the front and add a separator after the focused items\n  // Explicitly track focus changes to ensure this computed runs when focuses are updated\n  if (props.enableFocusView && outputData && focuses.value.length > 0 && focusType.value) {\n    const focusedItems = outputData?.filter((item) => focuses.value.includes(item[activeCategory.value] as string));\n    const nonFocusedItems = outputData?.filter((item) => !focuses.value.includes(item[activeCategory.value] as string));\n    // add focus-separator-category to the data to create a visual separator between focused and non-focused items\n    outputData = [...(focusedItems || []), { [activeCategory.value]: separatorValue }, ...(nonFocusedItems || [])];\n  }\n  return outputData;\n});\n\n// Benchmark-chip / crossLine-overlay hover feature: active groups, resolved overlays, the\n// chips rendered beside the chart, and the chip-hover tooltip lookalike.\nconst {\n  activeCrosslineOverlayGroups,\n  resolvedCrosslineOverlays,\n  chipSections,\n  hoveredBenchmarkKey,\n  hoveredCrosslineTooltip,\n} = useBenchmarkOverlays({\n  crosslineOverlayGroups,\n  isHistogramWithBuckets,\n  isHorizontalBarChart,\n  computedChartData,\n  pvChartRef,\n  formatValue: (value: number) => {\n    const formatter = getFormatterForColField(currentRowGroupColumns.value?.[0]);\n    return typeof formatter === \"function\" ? formatter({ value } as ValueFormatterParams) : value;\n  },\n  initialActiveOverlayGroupIds: computed(() => props.initialActiveOverlayGroupIds),\n});\nprovide(ActiveCrosslineOverlayGroupsKey, activeCrosslineOverlayGroups);\nwatch(activeCrosslineOverlayGroups, (ids) => emit(\"active-overlay-group-ids-change\", [...ids]), { deep: true });\n\nconst PAD_CATEGORIES = new Set([padStartValue, padEndValue]);\n\n// --- Map chart support -----------------------------------------------------\n// When the \"map\" chart type is active (only possible while a state/region column\n// is the x-axis), the chart renders PvMapChart instead of PvChart.\nconst selectedMapRegion = ref<string | undefined>(undefined);\n\n// Map is its own rendering mode: whenever the Map type is active we render\n// PvMapChart, never PvChart. Gating on the x-axis (e.g. requiring a single region\n// column) would let an empty or multi-column x-axis fall through to PvChart with\n// the map's `map-shape` series in cartesian options, which is invalid. When the\n// x-axis isn't a single region column the map just renders empty instead.\nconst isMapView = computed(() => activeChartType.value?.id === \"map\");\n\nconst mapSeriesKey = computed(() => activeSeries.value || availableSeriesColumns.value[0]?.value || \"value\");\n\nconst mapChartHeight = computed(() => `${DATA_TABLE_MAP_CHART_HEIGHT_PX}px`);\n\n// Reshape the charted rows into the { state, [series]: value } shape PvMapChart\n// expects, dropping the padding/separator categories used by the cartesian charts.\nconst mapChartData = computed<PvMapChartData[]>(() => {\n  const category = activeCategory.value;\n  const seriesField = mapSeriesKey.value;\n  if (!category || !seriesField) return [];\n  return (computedChartData.value ?? [])\n    .filter((row) => {\n      const region = String(row?.[category] ?? \"\");\n      return !PAD_CATEGORIES.has(region) && region !== separatorValue;\n    })\n    .map((row) => ({\n      [MAP_REGION_FIELD]: String(row[category] ?? \"\"),\n      [seriesField]: Number(row[seriesField] ?? 0),\n    })) as PvMapChartData[];\n});\n\nconst mapGradientRange = computed(() => {\n  const seriesField = mapSeriesKey.value;\n  if (!seriesField) return { min: 0, max: 0 };\n  let hasValue = false;\n  let min = Infinity;\n  let max = -Infinity;\n  mapChartData.value.forEach((row) => {\n    const value = Number(row[seriesField]);\n    if (!Number.isFinite(value)) return;\n    hasValue = true;\n    min = Math.min(min, value);\n    max = Math.max(max, value);\n  });\n  return hasValue ? { min, max } : { min: 0, max: 0 };\n});\n\nconst mapSeriesValueFormatter = computed<(value: number) => string>(() => {\n  const colDef = getColDefForField(mapSeriesKey.value);\n  const formatter = colDef?.valueFormatter;\n  if (typeof formatter === \"function\") {\n    return (value: number) => String(formatter({ value } as ValueFormatterParams) ?? value);\n  }\n  return (value: number) => value.toLocaleString(\"en-US\");\n});\n\nconst scatterChartData = computed(() => {\n  const data = computedChartData.value ?? [];\n  const filtered = data.filter((row) => {\n    const x = row?.[activeCategory.value];\n    return !PAD_CATEGORIES.has(String(x));\n  });\n\n  // For stacked charts, _sort_total sums values across stack segments. This is\n  // correct for SUM metrics (e.g. utilization) but wrong for AVG metrics (e.g.\n  // rate score) where we need the average across segments, not the sum.\n  if (!stackedChartEnabled.value || activeSecondarySeriesFields.value.length === 0 || !activeStackField.value) {\n    return filtered;\n  }\n  const fieldsNeedingAverage = activeSecondarySeriesFields.value.filter((secondaryField) => {\n    const colDef = getColDefForField(secondaryField);\n    const aggFunc = typeof colDef?.aggFunc === \"string\" ? colDef.aggFunc : \"\";\n    return aggFunc !== \"sum\";\n  });\n  if (fieldsNeedingAverage.length === 0) {\n    return filtered;\n  }\n  const fieldValues = activeStackField.value.fieldValues;\n  return filtered.map((row) => {\n    const corrected = { ...row };\n    for (const secondaryField of fieldsNeedingAverage) {\n      const sortTotalKey = `${secondaryField}${sortTotalSuffix}`;\n      const total = row[sortTotalKey];\n      if (typeof total !== \"number\") continue;\n      let count = 0;\n      for (const fv of fieldValues) {\n        if (typeof row[generateStackSeriesKey(secondaryField, String(fv))] === \"number\") {\n          count++;\n        }\n      }\n      corrected[sortTotalKey] = count > 0 ? total / count : null;\n    }\n    return corrected;\n  });\n});\n\nconst categoryCount = computed(() => {\n  return computedChartData.value?.length || 0;\n});\n\nconst chartScrollingEnabled = computed(() => props.enableChartScrolling);\n\nconst effectiveChartMinHeight = computed(() =>\n  getScrollableChartMinHeight({\n    baseMinHeight: DATA_TABLE_CHART_MIN_HEIGHT_PX,\n    dataCount: categoryCount.value,\n    enableChartScrolling: chartScrollingEnabled.value,\n    isHorizontalScrollingChart: isHorizontalBarChart.value,\n    itemHeight: DATA_TABLE_CHART_SCROLL_ITEM_HEIGHT_PX,\n  }),\n);\n\nconst chartScrollContainerStyle = computed(() => {\n  const overflow = getChartScrollOverflowStyle({\n    enableChartScrolling: chartScrollingEnabled.value,\n    isHorizontalScrollingChart: isHorizontalBarChart.value,\n  });\n\n  if (!overflow) return undefined;\n  if (!isHorizontalBarChart.value) return overflow;\n\n  return { ...overflow, maxHeight: `${DATA_TABLE_CHART_MIN_HEIGHT_PX}px` };\n});\n\nconst chartContentStyle = computed(() =>\n  getChartScrollContentStyle({\n    chartMinHeight: effectiveChartMinHeight.value,\n    dataCount: categoryCount.value,\n    enableChartScrolling: chartScrollingEnabled.value,\n    isHorizontalScrollingChart: isHorizontalBarChart.value,\n    minContentWidth: 0,\n    reserveWidth: chipSections.value.length > 0 ? BENCHMARK_CHIPS_RESERVED_WIDTH_PX : 0,\n  }),\n);\n\n// stacked charts sum series per category, so max/min calculations need the\n// pre-stacked totals rather than the raw per-row data\nconst effectiveChartSeriesData = computed(() => {\n  return stackedChartEnabled.value ? stackedChartData.value : computedChartData.value;\n});\n\n// track the largest value on the chart, useful for determining scale of bars relative to the current axis\nconst maxChartSeriesValue = computed(() => {\n  return calculateMaxChartSeriesValue(effectiveChartSeriesData.value, activeSeries.value, stackedChartEnabled.value);\n});\n\n// largest value on the secondary series — used to derive a shared interval count\n// so the secondary y-axis gridlines align with the primary axis. All active\n// overlays share the one secondary axis, so this is the max across all of them.\nconst maxSecondarySeriesValue = computed(() => {\n  return secondaryOnlyOverlayFields.value.reduce(\n    (max, field) =>\n      Math.max(max, calculateMaxChartSeriesValue(effectiveChartSeriesData.value, field, stackedChartEnabled.value)),\n    -Infinity,\n  );\n});\n\n// Largest value among overlays pinned to the primary axis — folded into the primary axis\n// ceiling so an overlay spike (e.g. a raw-rate outlier exceeding the smoothed series' max)\n// isn't clipped when the axes are grid-aligned against a secondary axis.\nconst maxPrimaryOverlayValue = computed(() => {\n  return primaryAxisOverlayFields.value.reduce(\n    (max, field) =>\n      Math.max(max, calculateMaxChartSeriesValue(effectiveChartSeriesData.value, field, stackedChartEnabled.value)),\n    -Infinity,\n  );\n});\n\n// Smallest value among overlays pinned to the primary axis — folded into the primary axis's\n// fitted floor (see niceAxisRange below) so an overlay dipping under the main series (e.g. a\n// raw-rate outlier below the smoothed line) isn't clipped.\nconst minPrimaryOverlayValue = computed(() => {\n  return primaryAxisOverlayFields.value.reduce(\n    (min, field) =>\n      Math.min(min, calculateMinChartSeriesValue(effectiveChartSeriesData.value, field, stackedChartEnabled.value)),\n    Infinity,\n  );\n});\n\n// Min/max across the primary axis's INDIVIDUAL series values. The stacked-mode calculators\n// above measure the per-category sortTotal SUM — correct for stacked bars (the axis must fit\n// the stack height) but wrong for a row-group breakout line chart, whose lines are the\n// individual group values: fitting the axis to the sum floats every line below the floor.\nconst primaryLineSeriesExtent = computed(() => {\n  const data = effectiveChartSeriesData.value ?? [];\n  // Stacked rows key each group's value as `<metric>_<groupValue>` (generateStackSeriesKey),\n  // matching the per-group series yKeys — the plain group value is not a row key.\n  const keys = stackedChartEnabled.value\n    ? (activeStackField.value?.fieldValues ?? []).map((fieldValue) =>\n        generateStackSeriesKey(activeSeries.value, fieldValue),\n      )\n    : [activeSeries.value];\n  let min = Infinity;\n  let max = -Infinity;\n  for (const row of data) {\n    for (const key of keys) {\n      const value = row?.[key];\n      if (typeof value === \"number\") {\n        if (value < min) min = value;\n        if (value > max) max = value;\n      }\n    }\n  }\n  return { min, max };\n});\n\n// smallest values on each series — negative data on either axis means we can't\n// share a zero-based grid, so we fall back to independent scales + hidden\n// secondary gridlines instead of forcing the axes to misalign\nconst minChartSeriesValue = computed(() => {\n  return calculateMinChartSeriesValue(effectiveChartSeriesData.value, activeSeries.value, stackedChartEnabled.value);\n});\n\nconst minSecondarySeriesValue = computed(() => {\n  return secondaryOnlyOverlayFields.value.reduce(\n    (min, field) =>\n      Math.min(min, calculateMinChartSeriesValue(effectiveChartSeriesData.value, field, stackedChartEnabled.value)),\n    Infinity,\n  );\n});\n\nconst barCount = computed(() => {\n  return activeStackField.value?.fieldValues?.length || 0;\n});\n\nconst categoryAxesPaddingInner = computed(() => {\n  const minPadding = 0.05;\n  const maxPadding = 0.75;\n  const A = 0.25;\n  const B = -0.12;\n  const paddingValue = A * Math.exp(B * categoryCount.value);\n  return Math.min(Math.max(paddingValue, minPadding), maxPadding);\n});\n\nconst categoryAxesPaddingOuter = computed(() => {\n  return barCount.value > 5 ? 0.5 : 1;\n});\n\nconst categoryAxesGroupPaddingInner = computed(() => {\n  return barCount.value > 5 ? 0.25 : 0.1;\n});\n\nconst chartDataEmpty = computed(() => {\n  if (!computedChartData.value || computedChartData.value?.length === 0) {\n    return true;\n  }\n  return (\n    maxChartSeriesValue.value === -Infinity || (stackedChartEnabled.value === true && maxChartSeriesValue.value === 0)\n  );\n});\n\nconst shouldShowFocusOverlayText = computed(() => {\n  return !!(\n    props.enableFocusView &&\n    focusType.value &&\n    focuses.value.length === 0 &&\n    props.percentOfFocusViewYKey &&\n    activeSeries.value &&\n    activeSeries.value === props.percentOfFocusViewYKey\n  );\n});\n\nconst displayGroupByName = computed(() => {\n  const colDef = getColDefForField(focusType.value || \"\");\n  return colDef?.headerName || colDef?.field || \"Compare Field\";\n});\n\nconst noDataOverlayText = computed(() => {\n  return computeNoDataOverlayText({\n    currentRowGroupColumnsLength: currentRowGroupColumns.value.length,\n    shouldShowFocusOverlayText: shouldShowFocusOverlayText.value || (props.focusRequired && focuses.value.length === 0),\n    chartDataEmpty: chartDataEmpty.value,\n    missingFocusText: props.missingFocusText,\n    yAxisName: activeSeriesDisplayName.value,\n    yAxisOptionCount: availableSeriesSelectionCount.value,\n  });\n});\n\n// True when the default \"select a focus\" message (with the inline focus icon) should render,\n// i.e. the focus overlay applies and the caller didn't supply its own missingFocusText. Not\n// gated on chartDataEmpty: a required-but-unselected focus hides the chart data even when data\n// exists, so the prompt must show independent of it (see computeNoDataOverlayText).\nconst showDefaultMissingFocusMessage = computed(() => {\n  return (\n    currentRowGroupColumns.value.length > 0 &&\n    (shouldShowFocusOverlayText.value || (props.focusRequired && focuses.value.length === 0)) &&\n    !props.missingFocusText\n  );\n});\n\nconst shouldHideChartDataForOverlay = computed(() => {\n  return (\n    shouldShowFocusOverlayText.value ||\n    shouldShowEmptyChartFilterRenderer.value ||\n    (!props.isLoading && noDataOverlayText.value !== \"\")\n  );\n});\n\nconst computedChartOptions = computed(() => {\n  const options: AgCartesianChartOptions = {};\n  options.overlays = {\n    noData: {\n      text: \"\",\n    },\n  };\n  // Histogram charts notate the x-axis with the overall lowest min (left) and\n  // highest max (right) bucket bounds. Those are rendered on two blank\n  // categories appended outside the real buckets (rather than on the first/last\n  // bar) so they sit further out from the bars instead of centered on them.\n  const chartData = isHistogramWithBuckets.value\n    ? [\n        { [activeCategory.value]: distributionRangeMinCategory },\n        ...(computedChartData.value ?? []),\n        { [activeCategory.value]: distributionRangeMaxCategory },\n      ]\n    : computedChartData.value;\n\n  options.data = shouldHideChartDataForOverlay.value ? [] : chartData;\n\n  options.legend = {\n    toggleSeries: false,\n    preventHidingAll: true,\n    // Multi-select overlays take per-series palette colors, so the legend is the only\n    // way to tell them (and the primary series) apart on a single-group chart.\n    // When stack values are paginated, AG Charts' own legend would paginate independently\n    // of our page control, producing two disconnected pagers - hide it so ours is the\n    // only navigation for which stack values are showing (see stackValuesCapMessage).\n    enabled:\n      !stackValuesPagination.value &&\n      (currentRowGroupColumns.value.length > 1 ||\n        (metricOverlayMultiSelect.value && activeSecondarySeriesFields.value.length > 0)),\n  };\n\n  const overlayFieldKeys = (overlayField: string): string[] => {\n    if (isStackedChart.value) {\n      return [`${overlayField}${sortTotalSuffix}`];\n    }\n    // metricOverlayWithRowGroups: the overlay charts the field's plain per-category value\n    // (carried through the pivot as a supplementary column), not per-group series keys.\n    if (stackedChartEnabled.value && props.metricOverlayWithRowGroups) {\n      return [overlayField];\n    }\n    if (stackedChartEnabled.value) {\n      return (\n        activeStackField.value?.fieldValues.map((fieldValue) =>\n          generateStackSeriesKey(overlayField, String(fieldValue)),\n        ) || []\n      );\n    }\n    return [overlayField];\n  };\n\n  const primaryAxisKeys = [\n    ...(stackedChartEnabled.value\n      ? activeStackField.value?.fieldValues.map((fieldValue) =>\n          generateStackSeriesKey(activeSeries.value, fieldValue),\n        ) || []\n      : activeSeries.value\n        ? [activeSeries.value]\n        : []),\n    // Overlays pinned to the primary axis share its keys (and thus its scale).\n    ...primaryAxisOverlayFields.value.flatMap(overlayFieldKeys),\n  ];\n\n  const secondaryAxisKeys = secondaryOnlyOverlayFields.value.flatMap(overlayFieldKeys);\n\n  const hideXAxisLabel = activeChartTypeConfig.value.xAxis.hideLabel === true && !isHistogramWithBuckets.value;\n\n  const axes: NonNullable<AgCartesianChartOptions[\"axes\"]> = [];\n\n  // Add categorical x-axis\n  axes.push({\n    type: \"category\",\n    keys: [activeCategory.value],\n    position: isHorizontalBarChart.value ? \"left\" : \"bottom\",\n    crossLines: [\n      {\n        type: \"line\",\n        value: separatorValue,\n        stroke: \"#666666\",\n        strokeWidth: 1,\n        lineDash: [4, 4],\n        strokeOpacity: hoveredBenchmarkKey.value != null ? 0.15 : 0.7,\n      },\n    ],\n    line: { enabled: !isHistogramWithBuckets.value },\n    label: {\n      minSpacing: 10,\n      autoRotate: true,\n      truncate: false,\n      wrapping: \"never\",\n      // Pull the min/max notation in closer to the axis than the default label spacing.\n      ...(isHistogramWithBuckets.value ? { spacing: 2 } : {}),\n      formatter: buildCategoryAxisLabelFormatter({\n        hideLabel: hideXAxisLabel,\n        showDistributionRangeLabels: Boolean(isHistogramWithBuckets.value),\n        chartData: computedChartData.value,\n        formatBucketBoundary,\n        columnValueFormatter: getFormatterForColField(activeCategory.value) as\n          | Formatter<AgAxisLabelFormatterParams>\n          | undefined,\n        enableFocusView: props.enableFocusView,\n        focuses: focuses.value,\n        focusText: props.focusText,\n      }),\n    },\n    paddingInner: categoryAxesPaddingInner.value,\n    // The blank min/max pad categories already add a band's worth of outward\n    // space; drop the axis's own outer margin so there isn't a second, empty\n    // band beyond them.\n    paddingOuter: isHistogramWithBuckets.value ? 0 : categoryAxesPaddingOuter.value,\n    groupPaddingInner: categoryAxesGroupPaddingInner.value,\n  });\n\n  // Add numeric x-axis for vertical line overlays if needed\n  if (isHistogramWithBuckets.value && resolvedCrosslineOverlays.value.length > 0) {\n    const numCategories = computedChartData.value?.length || 1;\n    // The distribution-range padding above adds one blank category before the\n    // real buckets, shifting every real bucket's position by 1 on the shared\n    // category axis. Offset the dummy axis's domain and crossline positions to\n    // match so overlay lines still land on the correct bars.\n    const { categoryPadOffset, axisMin, axisMax } = getCrosslineAxisDomain(numCategories, true);\n    axes.push({\n      type: \"number\" as const,\n      keys: [\"__dummy_x__\"],\n      position: (isHorizontalBarChart.value ? \"left\" : \"bottom\") as AgCartesianAxisPosition,\n      crosshair: { enabled: false },\n      min: axisMin,\n      max: axisMax,\n      nice: false,\n      label: { enabled: false },\n      tick: { enabled: false },\n      line: { enabled: false },\n      gridLine: { enabled: false },\n      crossLines: resolvedCrosslineOverlays.value\n        .map((overlay) => {\n          if (!computedChartData.value) {\n            return null;\n          }\n          const scaledValue = scaleValueToIndex(overlay.value, computedChartData.value);\n          if (scaledValue == null) {\n            return null;\n          }\n          const isHovered = hoveredBenchmarkKey.value != null && overlay.key === hoveredBenchmarkKey.value;\n          const isDimmed = hoveredBenchmarkKey.value != null && !isHovered;\n          return {\n            type: \"line\" as const,\n            value: scaledValue + categoryPadOffset,\n            stroke: overlay.color || DEFAULT_CROSSLINE_OVERLAY_COLOR,\n            strokeWidth: isHovered ? 3 : 2,\n            strokeOpacity: isDimmed ? 0.2 : isHovered ? 1 : 0.8,\n            lineDash: [6, 3],\n          };\n        })\n        .filter((line) => line !== null),\n    });\n  }\n\n  // When a secondary y-axis is shown, pin BOTH axes to the same number of equal\n  // intervals from a shared zero baseline so their gridlines coincide as one set\n  // of horizontal lines instead of two misaligned sets. Each axis runs 0 -> a\n  // \"nice\" ceiling (or the explicit secondaryAxisMax) in SECONDARY_AXIS_INTERVAL_COUNT\n  // steps, with `nice: false` so AG Charts doesn't re-round the bounds.\n  //\n  // A shared zero-based grid is only possible when neither series has negative\n  // data. If either axis goes negative (or no positive ceiling exists), we let\n  // each axis scale independently and hide the SECONDARY axis's gridlines — so\n  // the chart still shows a single set of horizontal lines (the primary's) and\n  // each axis keeps an honest scale, rather than two crossing sets of lines.\n  const intervals = SECONDARY_AXIS_INTERVAL_COUNT;\n  // Primary-axis-pinned overlays don't count: with only those active there is no right axis.\n  const hasSecondaryAxis = secondaryOnlyOverlayFields.value.length > 0;\n  // All overlays share the one secondary axis: an explicit cap must cover every\n  // active overlay, so take the largest of the configured maxes (if any).\n  const explicitSecondaryMaxes = secondaryOnlyOverlayFields.value\n    .map((field) => findSeriesColumn(availableSecondarySeriesColumns.value, field)?.secondaryAxisMax)\n    .filter((max): max is number => typeof max === \"number\");\n  const explicitSecondaryMax =\n    hasSecondaryAxis && explicitSecondaryMaxes.length > 0 ? Math.max(...explicitSecondaryMaxes) : undefined;\n  const primaryHasNegative =\n    hasSecondaryAxis && Number.isFinite(minChartSeriesValue.value) && minChartSeriesValue.value < 0;\n  const secondaryHasNegative =\n    hasSecondaryAxis && Number.isFinite(minSecondarySeriesValue.value) && minSecondarySeriesValue.value < 0;\n  const anyAxisHasNegative = primaryHasNegative || secondaryHasNegative;\n\n  // Primary-axis overlays share the left axis, so its aligned ceiling must cover their\n  // spikes too (raw-rate outliers routinely exceed the smoothed series' max).\n  const primaryAxisCeiling = hasSecondaryAxis\n    ? niceAxisCeiling(Math.max(maxChartSeriesValue.value, maxPrimaryOverlayValue.value), intervals)\n    : 0;\n  const secondaryAxisCeiling = hasSecondaryAxis\n    ? (explicitSecondaryMax ?? niceAxisCeiling(maxSecondarySeriesValue.value, intervals))\n    : 0;\n  const alignAxes = hasSecondaryAxis && !anyAxisHasNegative && primaryAxisCeiling > 0 && secondaryAxisCeiling > 0;\n\n  // Line charts don't encode value by length from a baseline, so a grid-aligned primary axis\n  // can hug its data with a nice fitted window instead of stretching to zero (percentage\n  // metrics clustered around 100% were unreadable on a 0-based axis). The window keeps the\n  // shared interval count, so both axes' gridlines still coincide; bar charts keep the zero\n  // baseline, and a null range (degenerate data) falls back to the zero-based window.\n  const primaryFittedRange =\n    alignAxes && props.fitPrimaryAxisToLineData && activeChartType.value?.id === \"line\"\n      ? niceAxisRange(\n          Math.min(primaryLineSeriesExtent.value.min, minPrimaryOverlayValue.value),\n          Math.max(primaryLineSeriesExtent.value.max, maxPrimaryOverlayValue.value),\n          intervals,\n        )\n      : null;\n\n  // Add primary y-axis\n  axes.push({\n    type: \"number\",\n    keys: primaryAxisKeys,\n    position: (isHorizontalBarChart.value ? \"bottom\" : \"left\") as AgCartesianAxisPosition,\n    ...(alignAxes\n      ? primaryFittedRange\n        ? {\n            min: primaryFittedRange.min,\n            max: primaryFittedRange.max,\n            nice: false,\n            interval: { step: primaryFittedRange.step },\n          }\n        : { min: 0, max: primaryAxisCeiling, nice: false, interval: { step: primaryAxisCeiling / intervals } }\n      : {}),\n    label: {\n      formatter: getFormatterForColField(activeSeries.value) as Formatter<AgAxisLabelFormatterParams> | undefined,\n    },\n    title: {\n      enabled: true,\n      text: activeSeriesDisplayName.value,\n    },\n  });\n\n  if (hasSecondaryAxis) {\n    axes.push({\n      type: \"number\",\n      keys: secondaryAxisKeys,\n      position: isHorizontalBarChart.value ? \"top\" : \"right\",\n      crosshair: {\n        enabled: false,\n      },\n      ...(alignAxes\n        ? // Matched interval count + nice:false keeps these gridlines aligned with\n          // the primary axis.\n          { min: 0, max: secondaryAxisCeiling, nice: false, interval: { step: secondaryAxisCeiling / intervals } }\n        : {\n            // Independent scale: only pin a zero baseline when this axis has no\n            // negatives, still honor an explicit cap (nice:false so it doesn't\n            // overshoot), and hide gridlines whenever negative data is present so\n            // only the primary axis draws horizontal lines.\n            ...(secondaryHasNegative ? {} : { min: 0 }),\n            ...(explicitSecondaryMax !== undefined ? { max: explicitSecondaryMax, nice: false } : {}),\n            ...(anyAxisHasNegative ? { gridLine: { enabled: false } } : {}),\n          }),\n      // Scatter overlays render in the theme's fixed marker color, so the axis text matches\n      // it. Line overlays take per-series palette colors, so the axis keeps default text.\n      label: {\n        ...(secondaryOverlayChartType.value === \"scatter\" ? { color: SCATTER_MARKER_STROKE } : {}),\n      },\n      title: {\n        enabled: true,\n        text: secondaryAxisTitle.value,\n        ...(secondaryOverlayChartType.value === \"scatter\" ? { color: SCATTER_MARKER_STROKE } : {}),\n      },\n    });\n  }\n\n  // Declares an invisible x-axis for the vertical line overlays to adhere to.\n  if (isHistogramWithBuckets.value && resolvedCrosslineOverlays.value.length > 0) {\n    const maxY = Number.isFinite(maxChartSeriesValue.value) ? maxChartSeriesValue.value : 0;\n    axes.push({\n      type: \"number\" as const,\n      keys: [\"__dummy_y__\"],\n      position: \"left\",\n      min: 0,\n      max: maxY,\n      nice: false,\n      crosshair: {\n        enabled: false,\n      },\n      label: { enabled: false },\n      tick: { enabled: false },\n      line: { enabled: false },\n      gridLine: { enabled: false },\n    });\n  }\n\n  options.axes = axes;\n\n  options.series = chartSeries.value as AgCartesianSeriesOptions[];\n  return options;\n});\n\nconst chartLoading = computed(() => {\n  return (\n    displayChartLoading.value || (props.isLoading && (!computedChartData.value || computedChartData.value.length === 0))\n  );\n});\n\nconst shouldDisplayNoDataOverlayText = computed(() => {\n  return (\n    shouldShowFocusOverlayText.value ||\n    (!shouldShowEmptyChartFilterRenderer.value && !props.isLoading && noDataOverlayText.value !== \"\")\n  );\n});\n\nconst updateChartCollapsed = (newCollapsedValue: boolean) => {\n  chartCollapsed.value = newCollapsedValue;\n  emit(\"chart-collapsed\", newCollapsedValue);\n};\n\nconst toggleGroupState = (enableGrouping: boolean) => {\n  if (pivotActive.value) return;\n  if (!gridApi.value) {\n    return;\n  }\n  gridApi.value.setRowGroupColumns(enableGrouping ? currentRowGroupColumns.value : []);\n  groupedModeEnabled.value = enableGrouping;\n};\n\n// Declared as overloads (not an inline arrow) so consumers see the sync vs. `{ hydrate: true }` async\n// signatures, matching PvDataTable's exposed method.\nfunction getFilterValueSelectedMetadataMap(): Record<string, (FilterValueResponseOption | null)[]> | undefined;\nfunction getFilterValueSelectedMetadataMap(options: {\n  hydrate: true;\n}): Promise<Record<string, (FilterValueResponseOption | null)[]>> | undefined;\nfunction getFilterValueSelectedMetadataMap(options?: { hydrate?: boolean }) {\n  return options?.hydrate\n    ? pvDataTableRef.value?.getFilterValueSelectedMetadataMap({ hydrate: true })\n    : pvDataTableRef.value?.getFilterValueSelectedMetadataMap();\n}\n\ndefineExpose({\n  getChartImageDataURL: (dimensions?: { width?: number; height?: number }): Promise<string> | undefined => {\n    return isMapView.value\n      ? pvMapChartRef.value?.getChartImageDataURL(dimensions)\n      : pvChartRef.value?.getChartImageDataURL(dimensions);\n  },\n  getCsvData: () => {\n    return pvDataTableRef.value?.getCsvData();\n  },\n  refreshData: (params?: RefreshServerSideParams | null) => {\n    if (gridApi.value) {\n      processChartData(gridApi.value);\n    }\n    return pvDataTableRef.value?.refreshData(params);\n  },\n  getFilterValueSelectedMetadataMap,\n  getPvFilterModel: () => {\n    return pvDataTableRef.value?.getPvFilterModel();\n  },\n  setPvFilterModel: (model: FilterModel | AdvancedFilterModel | null) => {\n    return pvDataTableRef.value?.setPvFilterModel(model);\n  },\n  getChipSections: () => chipSections.value,\n});\n\nonBeforeMount(() => {\n  if (props.initialGridState) {\n    const rowGroupColIds = props.initialGridState.rowGroup?.groupColIds || [];\n    currentRowGroupColumns.value = rowGroupColIds;\n\n    // If not all fields are focusable (in the case of a histogram), then we assume the focus type will be the first row\n    // group column. However, we may need to revisit this logic in case these assumptions change (i.e. allowing a\n    // grouped bar chart to become a histogram).\n    if (!props.allFieldsAreFocusable && rowGroupColIds.length > 0) {\n      chartFocusStore.setFocusType(rowGroupColIds[0]);\n    }\n  }\n});\n\nonMounted(async () => {\n  // Ensure the filter panel element is in the DOM before allowing teleport\n  await nextTick();\n  shouldTeleportFilterPanel.value = props.filterPanelAboveChart;\n});\n</script>\n\n<template>\n  <div style=\"height: 100%; width: 100%\">\n    <!--\n      One row: the filter panel takes the space the actions leave over, and its\n      horizontal filters collapse into the All Filters drawer as that space runs out.\n    -->\n    <div class=\"pv-stack-16\" :class=\"{ 'pv-flex': filterPanelActionsEnabled }\">\n      <div :id=\"filterPanelLocationId\" :style=\"filterPanelActionsEnabled ? 'flex: 1 1 0' : undefined\"></div>\n      <div\n        v-if=\"filterPanelActionsEnabled\"\n        class=\"pv-flex\"\n        style=\"--flex-wrap: wrap; flex: 0 1 auto\"\n        data-testid=\"pv-data-table-with-chart-filter-panel-actions\"\n      >\n        <slot name=\"filter-panel-actions\" />\n      </div>\n    </div>\n    <slot name=\"above-chart\" />\n    <div v-if=\"!hideChart\" class=\"pv-bordered pv-radius-lg pv-inset-square-12 pv-stack-16\">\n      <PvButton\n        rightIcon=\"chevrons-down-up\"\n        label=\"Collapse\"\n        style=\"float: right; margin-left: 0.5rem\"\n        variant=\"secondary\"\n        @click=\"updateChartCollapsed(!chartCollapsed)\"\n        :class=\"hideChart || chartCollapsed ? 'pv-hide' : ''\"\n      />\n      <div :class=\"hideChart || !chartCollapsed ? 'pv-hide' : 'pv-space-between'\">\n        <div class=\"pv-flex\">\n          <PvIcon name=\"chart-line\" :size=\"20\" class=\"pv-text-subdued\" />\n          <p class=\"pv-text-body-md pv-text-primary\" style=\"font-weight: 500\">Expand to see chart</p>\n        </div>\n        <PvButton\n          rightIcon=\"chevron-selector\"\n          label=\"Expand\"\n          variant=\"secondary\"\n          @click=\"updateChartCollapsed(!chartCollapsed)\"\n        />\n      </div>\n      <div :class=\"hideChart || chartCollapsed ? 'pv-hide' : ''\">\n        <PvChartOptionsPanel\n          :enablePanel=\"computedChartData != null && computedChartData.length > 0\"\n          :chartFilter=\"chartFilter\"\n          :rowGroupLimit=\"effectiveRowGroupLimit\"\n          :use-combined-button=\"props.enableCombinedChartConfigPanel\"\n          :use-nested-menu=\"props.enableNestedChartConfigPanel\"\n          :chart-config-options=\"props.chartConfigPanelOptions\"\n          :locked-row-group-options=\"props.lockedRowGroupOptions\"\n          :metric-overlay-with-row-groups=\"props.metricOverlayWithRowGroups\"\n          :read-only=\"props.chartConfigPanelReadOnly\"\n          :percent-of-focus-view-y-key=\"props.percentOfFocusViewYKey\"\n          @series-agg-func-selected=\"handleSeriesAggFuncSelected\"\n        />\n        <div class=\"pv-flex\" style=\"align-items: stretch\">\n          <PvBenchmarkChips\n            v-if=\"chipSections.length > 0\"\n            :sections=\"chipSections\"\n            @chip-hover=\"hoveredBenchmarkKey = $event\"\n          />\n          <div\n            class=\"pv-relative pv-margin-auto pv-flex-item\"\n            :style=\"isMapView ? { height: mapChartHeight } : undefined\"\n          >\n            <PvMapChart\n              v-if=\"isMapView\"\n              ref=\"pvMapChartRef\"\n              v-model:selectedRegion=\"selectedMapRegion\"\n              :chartData=\"mapChartData\"\n              :seriesKey=\"mapSeriesKey\"\n              :seriesLabel=\"activeSeriesDisplayName\"\n              :clickable=\"false\"\n              :displayRegionSelector=\"false\"\n              :gradientLegendMin=\"mapGradientRange.min\"\n              :gradientLegendMax=\"mapGradientRange.max\"\n              :seriesValueFormatter=\"mapSeriesValueFormatter\"\n              :isLoading=\"chartLoading\"\n              :noDataMessage=\"noDataOverlayText\"\n            />\n            <div\n              v-else\n              :class=\"[\n                'pv-data-table-with-chart__chart-scroll',\n                {\n                  'pv-data-table-with-chart__chart-scroll--enabled pv-scrollbar-visible': chartScrollingEnabled,\n                },\n              ]\"\n              :style=\"chartScrollContainerStyle\"\n            >\n              <div class=\"pv-data-table-with-chart__chart-content\" :style=\"chartContentStyle\">\n                <PvChart\n                  ref=\"pvChartRef\"\n                  :key=\"chartInstanceKey\"\n                  :isLoading=\"chartLoading\"\n                  :options=\"computedChartOptions\"\n                  :enableFocusView=\"enableFocusView\"\n                  :minHeight=\"effectiveChartMinHeight\"\n                />\n                <!-- Crossline Tooltip when Benchmark Chip is hovered over-->\n                <div\n                  v-if=\"hoveredCrosslineTooltip\"\n                  class=\"ag-charts-tooltip pv-data-table-with-chart__crossline-tooltip pv-tooltip-v2-content\"\n                  data-variant=\"white\"\n                  :class=\"hoveredCrosslineTooltip.arrowClass\"\n                  :style=\"hoveredCrosslineTooltip.style\"\n                >\n                  <div class=\"pv-flex pv-space-between\">\n                    <div class=\"pv-chart-tooltip-label\">\n                      {{ hoveredCrosslineTooltip.label }}\n                    </div>\n                    <div class=\"pv-chart-tooltip-value\">\n                      {{ hoveredCrosslineTooltip.value }}\n                    </div>\n                  </div>\n                </div>\n              </div>\n            </div>\n            <div v-if=\"!isMapView\" class=\"pv-chart-overlay pv-flex pv-align-center\">\n              <div v-if=\"shouldShowEmptyChartFilterRenderer\">\n                <component :is=\"emptyChartFilterRenderer\" />\n              </div>\n              <div v-else-if=\"showDefaultMissingFocusMessage\" class=\"pv-text-body-xs\" style=\"text-align: center\">\n                <span\n                  >Select focus {{ displayGroupByName }} to view Visualization. You can select a focus\n                  {{ displayGroupByName }} by</span\n                >\n                <span class=\"pv-flex\" style=\"text-wrap: nowrap\">\n                  opening the filter dropdown and clicking on the focus icon\n                  <PvIcon name=\"focus\" :size=\"12\" class=\"pv-text-subdued\" style=\"vertical-align: middle\" /> on the right\n                  hand side.\n                </span>\n              </div>\n              <p v-else-if=\"shouldDisplayNoDataOverlayText\" class=\"pv-text-body-xs\">\n                {{ noDataOverlayText }}\n              </p>\n            </div>\n          </div>\n        </div>\n        <div\n          v-if=\"paginatedStackValuesLegend.length > 0\"\n          class=\"pv-stack-8\"\n          style=\"\n            display: grid;\n            grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));\n            row-gap: 8px;\n            column-gap: 4px;\n          \"\n          data-testid=\"pv-data-table-with-chart-stack-values-legend\"\n        >\n          <div\n            v-for=\"item in paginatedStackValuesLegend\"\n            :key=\"item.key\"\n            class=\"pv-flex\"\n            style=\"align-items: center; gap: 4px\"\n          >\n            <span style=\"width: 10px; height: 10px; flex-shrink: 0\" :style=\"{ backgroundColor: item.color }\" />\n            <span\n              class=\"pv-text-body-xs\"\n              :title=\"item.label\"\n              style=\"white-space: nowrap; overflow: hidden; text-overflow: ellipsis\"\n              >{{ item.label }}</span\n            >\n          </div>\n        </div>\n        <div\n          v-if=\"stackValuesCapMessage\"\n          class=\"pv-flex pv-space-between\"\n          style=\"align-items: center\"\n          data-testid=\"pv-data-table-with-chart-stack-values-pagination\"\n        >\n          <p class=\"pv-text-body-xs pv-text-subdued\" data-testid=\"pv-data-table-with-chart-stack-values-cap-message\">\n            {{ stackValuesCapMessage }}\n          </p>\n          <PvPagination\n            variant=\"short\"\n            :maxPages=\"stackValuesPagination?.pageCount ?? 1\"\n            :modelValue=\"stackValuesPageIndex + 1\"\n            @update:modelValue=\"(page) => goToStackValuesPage(page - 1)\"\n          />\n        </div>\n      </div>\n    </div>\n    <PvDataTable\n      ref=\"pvDataTableRef\"\n      :key=\"pivotKey\"\n      v-bind=\"$props\"\n      :colDefs=\"tableColDefs\"\n      :pivot=\"pivotActive\"\n      :filterTeleportLocation=\"shouldTeleportFilterPanel ? `#${filterPanelLocationId}` : undefined\"\n      :wrapHorizontalFilters=\"props.wrapHorizontalFilters\"\n      :pagination=\"pagination || !groupedModeEnabled\"\n      @column-row-group-changed=\"handleRowGroupChanged\"\n      @column-value-changed=\"handleColumnValueChanged\"\n      @grid-ready=\"handleGridReady\"\n      @filter-changed=\"handleFilterChanged\"\n      @sort-changed=\"emit('sort-changed', $event)\"\n      @filter-opened=\"emit('filter-opened', $event)\"\n      @first-data-rendered=\"handleFirstDataRendered\"\n      @column-moved=\"handleColumnMoved\"\n      @column-resized=\"emit('column-resized', $event)\"\n      @handle-settings-icon=\"emit('handle-settings-icon', $event)\"\n      @focus-update=\"emit('focus-update', $event)\"\n    >\n      <template #top-slot>\n        <template v-if=\"enableGroupingToggle && !pivotActive\">\n          <PvTableOptionsPanel\n            v-if=\"tableConfigOptions\"\n            :groupedModeEnabled=\"groupedModeEnabled\"\n            :tableConfigOptions=\"props.tableConfigOptions\"\n            @toggle-group=\"toggleGroupState\"\n            @table-overlay-change=\"handleTableOverlayChange\"\n            @column-config-change=\"handleColumnConfigChange\"\n          />\n          <PvButton\n            v-else\n            :leftIcon=\"!groupedModeEnabled ? 'group' : 'ungroup'\"\n            :label=\"!groupedModeEnabled ? 'Group Table to Match Chart' : 'Ungroup Table'\"\n            @click=\"toggleGroupState(!groupedModeEnabled)\"\n            variant=\"secondary\"\n            size=\"lg\"\n          />\n        </template>\n        <slot name=\"top-slot\" />\n      </template>\n    </PvDataTable>\n  </div>\n</template>\n\n<style>\n.pv-data-table-with-chart__chart-scroll {\n  contain: inline-size;\n  min-height: 0;\n  overflow: hidden;\n  width: 100%;\n}\n\n/* Overflow is set inline per chart orientation - see getChartScrollOverflowStyle. */\n\n.pv-data-table-with-chart__chart-content {\n  min-height: 100%;\n}\n\n.pv-chart-overlay {\n  position: absolute;\n  top: 50%;\n  left: 50%;\n  transform: translate(-50%, -50%);\n  pointer-events: none;\n}\n.ag-charts-tooltip {\n  background-color: rgba(255, 255, 255, 0.95);\n}\n\n/* Compound selector to beat .ag-charts-tooltip's own border-radius/box-shadow on specificity. */\n.pv-data-table-with-chart__crossline-tooltip.ag-charts-tooltip {\n  border-radius: 4px;\n  box-shadow: 0 0 8px 0 rgba(0, 0, 0, 0.12);\n}\n\n.ag-charts-floating-toolbar {\n  display: none !important;\n}\n</style>\n","import { computed, ref, watch } from \"vue\";\nimport type { ComputedRef, Ref, WatchSource } from \"vue\";\nimport type { PvDataWidgetDataRow, PvDataWidgetProps } from \"./types\";\n\n/** Overlay text shown when a data handler fails and no `errorText` option is provided. */\nexport const DEFAULT_DATA_WIDGET_ERROR_TEXT = \"Unable to load data\";\n\n/** Fetches the data rows for a PvDataWidget, e.g. from an API. */\nexport type PvDataWidgetDataHandler = () => PvDataWidgetDataRow[] | Promise<PvDataWidgetDataRow[]>;\n\nexport interface UsePvDataWidgetDataOptions {\n  /** Overlay text shown on the widget when the handler fails. */\n  errorText?: string;\n  /** When false, data is not fetched until `refresh` is called. Defaults to true. */\n  immediate?: boolean;\n  /** Reactive sources (e.g. filter state) that trigger a refetch when changed. */\n  watch?: WatchSource | WatchSource[];\n}\n\nexport interface UsePvDataWidgetDataReturn {\n  /** Rows returned by the most recent successful handler call. */\n  chartData: Ref<PvDataWidgetDataRow[]>;\n  /** True while a handler call is pending. */\n  chartLoading: Ref<boolean>;\n  /** Error from the most recent handler call, cleared on the next successful call. */\n  error: Ref<Error | undefined>;\n  /** Re-invokes the handler. Resolves when the call settles. */\n  refresh: () => Promise<void>;\n  /**\n   * Spreadable PvDataWidget props: `chartData`, `chartLoading`, and — only while in an\n   * error state — `noDataOverlayText`. Place `v-bind=\"widgetProps\"` after your own\n   * bindings: your `noDataOverlayText` then applies to genuinely empty data, while the\n   * error text takes precedence when a fetch fails.\n   */\n  widgetProps: ComputedRef<Pick<PvDataWidgetProps, \"chartData\" | \"chartLoading\" | \"noDataOverlayText\">>;\n}\n\n/**\n * Manages the fetch lifecycle for a PvDataWidget whose rows come from an async\n * source: loading state, error-to-overlay mapping, stale-response protection,\n * and refetching on demand or when watched sources change.\n *\n * Entirely optional — PvDataWidget itself stays a pure presentational component\n * and can be fed `chartData` directly.\n */\nexport const usePvDataWidgetData = (\n  handler: PvDataWidgetDataHandler,\n  options: UsePvDataWidgetDataOptions = {},\n): UsePvDataWidgetDataReturn => {\n  const chartData = ref<PvDataWidgetDataRow[]>([]);\n  const chartLoading = ref(false);\n  const error = ref<Error | undefined>();\n  // Identifies the latest request so a slower, superseded response can never\n  // overwrite the data, error, or loading state owned by a newer one.\n  let requestId = 0;\n\n  const refresh = async () => {\n    const id = ++requestId;\n    chartLoading.value = true;\n\n    try {\n      const rows = await handler();\n\n      if (id !== requestId) return;\n      chartData.value = rows;\n      error.value = undefined;\n    } catch (caught) {\n      if (id !== requestId) return;\n      chartData.value = [];\n      error.value = caught instanceof Error ? caught : new Error(String(caught));\n    } finally {\n      if (id === requestId) chartLoading.value = false;\n    }\n  };\n\n  if (options.watch) {\n    const sources = Array.isArray(options.watch) ? options.watch : [options.watch];\n    watch(sources, () => {\n      void refresh();\n    });\n  }\n\n  if (options.immediate !== false) void refresh();\n\n  const widgetProps = computed(() => ({\n    chartData: chartData.value,\n    chartLoading: chartLoading.value,\n    ...(error.value ? { noDataOverlayText: options.errorText ?? DEFAULT_DATA_WIDGET_ERROR_TEXT } : {}),\n  }));\n\n  return { chartData, chartLoading, error, refresh, widgetProps };\n};\n"],"x_google_ignoreList":[25,26,27,28,29,30],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sEAEM,KAA8B;CAClC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD,EAEY,KAA8B;CACzC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD,EAEY,KAAwB,WAC/B,KAAsB,WACtB,KAAsB,IACtB,KAA8B;AAIpC,SAAS,GAAuB,GAA6C;AAC3E,QAAO,EACL,QAAQ;EACN,MAAM;EACN,MAAM;EACN,aAAa;EACb,GAAI,KAAS;GACX,QAAQ;GACR,gBAAgB,EACd,MAAM;IACJ,MAAM;IACN,QAAQ;IACR,aAAa;IACd,EACF;GACF;EACF,EACF;;AAGH,IAAM,KAAkC;CACtC,QAAQ;EACN,OAAO,EACL,SAAS,IACV;EACD,MAAM,EACJ,SAAS,IACV;EACD,YAAY,EACV,SAAS,EACP,QAAQ,IACT,EACF;EACD,MAAM;GACJ,QAAQ;IACN,WAAW,EACT,SAAS,IACV;IACD,OAAO,EACL,SAAS,IACV;IACF;GACD,UAAU;IACR,WAAW,EACT,SAAS,IACV;IACD,OAAO,EACL,YAAY,IACb;IACF;GACF;EACD,QAAQ;GACN,cAAc;GACd,kBAAkB;GACnB;EACF;CACD,KAAK,EACH,QAAQ;EACN,cAAc;EACd,WAAW;GACT,iBAAiB,EACf,aAAa,GACd;GACD,qBAAqB,EACnB,SAAS,IACV;GACF;EACF,EACF;CACD,SAAS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