@wafertools/wafermap 0.37.1 → 0.38.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/CHANGELOG.md +53 -1
  2. package/README.md +20 -13
  3. package/dist/packages/canvas-adapter/chartPopulation.d.ts +8 -3
  4. package/dist/packages/canvas-adapter/chartPopulation.js +1 -1
  5. package/dist/packages/canvas-adapter/charts/chartShell.d.ts +27 -17
  6. package/dist/packages/canvas-adapter/charts/chartShell.js +1 -1
  7. package/dist/packages/canvas-adapter/charts/plotChart.d.ts +0 -7
  8. package/dist/packages/canvas-adapter/charts/plotChart.js +1 -1
  9. package/dist/packages/canvas-adapter/drilldown.d.ts +5 -0
  10. package/dist/packages/canvas-adapter/drilldown.js +1 -1
  11. package/dist/packages/canvas-adapter/index.d.ts +1 -0
  12. package/dist/packages/canvas-adapter/index.js +1 -1
  13. package/dist/packages/canvas-adapter/insightsTab.js +1 -1
  14. package/dist/packages/canvas-adapter/pinnedTests.d.ts +10 -0
  15. package/dist/packages/canvas-adapter/pinnedTests.js +1 -0
  16. package/dist/packages/canvas-adapter/plotCard.d.ts +1 -1
  17. package/dist/packages/canvas-adapter/plotCard.js +1 -1
  18. package/dist/packages/canvas-adapter/renderWaferGallery.js +1 -1
  19. package/dist/packages/canvas-adapter/renderWaferMap.js +1 -1
  20. package/dist/packages/canvas-adapter/summaryPanel.d.ts +3 -3
  21. package/dist/packages/canvas-adapter/summaryPanel.js +4 -4
  22. package/dist/packages/canvas-adapter/userGuideHtml.d.ts +1 -1
  23. package/dist/packages/canvas-adapter/userGuideHtml.js +32 -19
  24. package/dist/packages/canvas-adapter/version.d.ts +2 -2
  25. package/dist/packages/canvas-adapter/version.js +1 -1
  26. package/dist/packages/canvas-adapter/viewSwitch.js +1 -1
  27. package/dist/packages/renderer/buildWaferMap.js +1 -1
  28. package/dist/packages/renderer/derivedTests/apply.d.ts +10 -0
  29. package/dist/packages/renderer/derivedTests/apply.js +1 -1
  30. package/dist/packages/renderer/derivedTests/check.d.ts +35 -0
  31. package/dist/packages/renderer/derivedTests/check.js +1 -0
  32. package/dist/packages/renderer/fmt.d.ts +5 -0
  33. package/dist/packages/renderer/fmt.js +1 -1
  34. package/dist/packages/renderer/index.d.ts +2 -0
  35. package/dist/packages/renderer/index.js +1 -1
  36. package/dist/packages/stats/analyzeWaferLot.js +1 -1
  37. package/dist/packages/stats/analyzeWaferMap.js +1 -1
  38. package/dist/packages/stats/chartCatalogue.js +1 -1
  39. package/dist/packages/stats/clusterDetection.js +1 -1
  40. package/dist/packages/stats/plotData.d.ts +7 -0
  41. package/dist/packages/stats/plotData.js +1 -1
  42. package/dist/packages/stats/reportHtml.js +33 -29
  43. package/dist/packages/stats/synthesis.d.ts +1 -1
  44. package/dist/packages/stats/synthesis.js +1 -1
  45. package/package.json +8 -4
package/CHANGELOG.md CHANGED
@@ -22,7 +22,59 @@ under `### Breaking`.
22
22
 
23
23
  ---
24
24
 
25
- ## [Unreleased]
25
+ ## [0.38.0] — 2026-10-28
26
+
27
+ ### Breaking
28
+
29
+ - **The Summary panel docks on the `right` or the `left`.** `SummaryPanelOptions.placement` no longer accepts `'top'` or `'bottom'`: the panel's stat tiles, tables and findings list are laid out for a narrow, tall panel. A value other than `'left'` docks the panel on the right.
30
+
31
+ ### Added
32
+
33
+ - **Ring yield by wafer and Quadrant yield by wafer.** Heatmaps on **Insights ▸ Overview**, beside the ring and quadrant diagrams: each region's yield on each wafer (or group), so a pattern on every wafer reads differently from one on a single wafer. Each is a plot, so **Edit as plot** opens it.
34
+ - **Views on the Insights cards.** With **Group by** on, *Yield by group* offers **Group, then wafer** (each group's wafers inside it), *Test value distribution* offers the same nesting coloured by group, the bin pareto offers **Bin mix** (a bar per group split into its bins), and *Pass rate by test* offers a **Grid** of the worst 25 tests by group. *Wafer-to-wafer trend* offers a **Control chart** from three wafers. The pass-rate bars and the soft-bin pareto keep the worst 25 and the largest 15, and the card's note says how many were left out.
35
+ - **A fitted line on the Insights test scatter** for each group when **Group by** is on.
36
+ - **The Plot tab's examples.** The histogram is coloured and normalised by the split, the yield bar carries its values and the median, the tests with limits are drawn as one box each placed between their limits, a pass-rate grid shows which tests fail in which split, and the probability plot is coloured by the split.
37
+
38
+ - **`checkDerivedExpression(input, testDefs, otherDerived?)`.** Checks one derived test's expression without building a map, for a host's own editor: it returns `{ ok: true, produces, reads, warnings }` (a number or a verdict, every test read and how, and advice such as units combined by `+`) or `{ ok: false, message, position }`. It runs the same parser, namespace, kind rule and test-number rules as `buildWaferMap` (a whole STDF number, not a measured test's and not another derived test's), so the editor and the build agree. A cycle between derived tests is still reported by the build as `derived-test-invalid`.
39
+ - **The number keys set the columns of cards.** Over a gallery (or with focus in it, so no click is needed first), on the Insights tab and over a plot of panels, **1** to **5** set that many columns
40
+ and **0** returns to Auto. The gallery's Columns control shows each choice's key, and the Insights tab has a **Columns** control of its
41
+ own beside Group by and Show, which sets every chart grid in the tab. A plot of panels has a **Columns** control above its panels, and the
42
+ keys set its columns while the pointer is over it; an expanded plot of panels scrolls when its panels are taller than the window. The keys do nothing in a text box, a menu or a window, or with Ctrl, Cmd, Alt or Shift
43
+ held.
44
+ - **A selection charted against the rest of its wafer.** The right-click menu of a single map with a selection adds a **Selection vs the rest of the wafer** section: a **Value histogram** with one colour per side, and a **Box plot** of the two. The sides are named in the title, the legend and the footnote ("661 dies · selection vs the rest of W01") with their die counts, so neither can be mistaken for the whole wafer. A plot's footnote can now say what its items are when they are not wafers (`PlotContext.populationLabel`).
45
+ - **Pinned tests.** Each row of the Insights test pickers (and of the test pickers in the charts opened from a map) has a ☆ (or **P** on the focused row) that pins the test. Pinned tests are listed first under a "Pinned" heading, in every picker at once. `getPinnedTests`, `setPinnedTests` and `onPinnedTestsChange` (from `@wafertools/wafermap/render`) let a host keep the set between sessions.
46
+ - **Invert selection.** Right-clicking a single map that has a selection offers **Invert selection** as the first row of the menu: the selection becomes the dies it did not hold.
47
+ - **Hover hints on the Insights tabs and controls.** Each tab, and the Group by, Show and Columns controls, says what it does (Correlation: "How tests move together"), and a hovered tab's tint stays inside the tab bar's outline.
48
+ - **A `funding` link.** `package.json` names the project's [support page](https://wafertools.github.io/support/), so `npm fund` lists it.
49
+
50
+ ### Changed
51
+
52
+ - **Value histogram over groups shows each group as a share of its own dies** (a **Counts** choice keeps the numbers), so groups of different sizes compare by shape.
53
+ - **Group-shift charts in Worth a look draw each wafer once.** The box of a split's shift is drawn over wafer means, the figure the comparison counts, and a field that moves several tests draws them together, each rescaled. A test's mean off the median is drawn against the median of the plot.
54
+ - **Worth a look charts of a lot's losses show where.** A region's loss is a region-by-wafer grid, a failing test is its pass rate by wafer, and an outlier wafer is its yield against control limits in wafer order.
55
+ - **A plot of a set of tests at wafer level** draws one value per wafer for each test.
56
+ - **The probability plot keeps its selection and has the wafer menu.** A box dragged over a probability plot stays marked until a click on empty space clears it, as on the scatter, and right-clicking a point that is one wafer opens that wafer's menu.
57
+ - **A group's box on the Insights box plot drills only that card.** Clicking it shows that group's wafers in the box plot, with **Back**, as on Yield by group; **Show** is the one control that narrows the whole tab.
58
+ - **A legend click filters only its own plot.** On the Insights value histogram, clicking a group in the legend shows just that group in that plot, as on every other plot; **Show** (and the box plot's drill-down) still narrow the whole tab.
59
+ - **"What stands out" is built once for a lot.** The summary panel, Insights and the report share one result for the same lot and pass bins, so a plot-mode switch or opening Insights after the lot has loaded no longer rebuilds it (about a second saved on a 266,000-die lot, in Chrome). The result is read-only.
60
+ - **The Maps | Insights switch shows its whole focus ring.** The ring round the focused tab is drawn in full, on every side, following the switch's rounded corners.
61
+ - **The Insights tab bar stays in view.** The Overview / Distributions / Correlation tabs and their Group-by controls stick beneath the gallery header while the charts scroll, as the bin legend does in the maps view.
62
+ - **A demo lot cut at its own wafer size keeps its pattern.** `docs/examples/data/generate-demos.js --geometry` places each lot's patterns by where its outermost reachable die sits and scales the edge-ring failure rate so the expected share of failing dies is the default wafer's. A coarse wafer (300 mm with 10×8 mm dies) had lost about a third of the edge-ring lot's failures, so its pattern was no longer found. The default geometry is unchanged, byte for byte.
63
+ - **A gallery card is sized for dies of 6 px.** Auto layout sizes cards so each die is at least 6 px across (it was 4 px), so on a dense wafer
64
+ (about 1,000 dies and up) a die is wide enough to aim a pointer at and the kerf between dies stays a clear single line. A card is wider than
65
+ before at the same density, and a window that cannot hold another column at that width keeps the columns it has: the cards then fill the row.
66
+ The compact layout keeps its own 4 px cell.
67
+ - **The summary report prints at paper size.** Printing or saving a report as a PDF scales the whole document up by a quarter, so the 12 px body text is about 11 pt on paper instead of 9 pt. The on-screen report is unchanged.
68
+ - **A reticle cell's repeated failures do not turn an edge arc into a scratch.** When a wafer's pattern reads as a scratch and a reticle cell has a finding of its own, the wafer is classified again with that cell's failing dies set aside. If the line goes, the pattern is what remains (an edge pattern, say) and its note names the cell. A scratch that is still a scratch without those dies stays one, and wafers with no reticle-cell finding are unchanged.
69
+ - **Reticle fields over supplied dies take the dies' own size.** With `dies` passed to `buildWaferMap`, field boundaries are drawn at the dies' width and height, so a field of 3 × 2 dies over 10 × 8 mm dies is 30 × 16 mm.
70
+ - **Cluster detection reads the die size from a sample of the dies.** The neighbourhood it searches is sized from the median die width and height over an even sample, not from the first die, so a layout whose dies differ in size is treated alike wherever its first die sits.
71
+ - **"Seen on N/M wafers" counts the wafers that can show the pattern.** A lot's spatial-pattern and regional findings take M from the wafers that have at least one positioned die, and say so when the lot has others ("2/2 wafers with positions, 1 without"). The share that grades the finding's severity uses the same count, so a lot with unpositioned wafers is graded on the wafers that can carry a pattern.
72
+ - **A test whose name states its unit keeps it on the colour bar and chart axes.** `fmax_MHz` is titled "fmax_MHz" with ticks in MHz, not "fmax_MHz (GHz)"; a name with a base unit and very small or large values (`Idsat_A`) keeps its name and takes an exponent note ("Idsat_A (×10E-6)"); a name without its unit is still rescaled and given the scaled unit.
73
+ - **Limit labels on a narrow chart stay on their own side of the line.** A vertical limit's label is shortened ("Hi 380 mV", then "Hi") before it flips towards the other limit, and never runs across another limit's line.
74
+ - **The Test Value range control is "Colour bar range".** The toolbar button, its tooltip and the guides use the same spelling as the rest of the interface. The `colorbarRangeMode` option keeps its name.
75
+ - **The wafer-centre advisory is worded for the reader.** The "Wafer centre ignored" message says what was ignored and why; the advice to supply `waferConfig.diameter` is in the console warning.
76
+ - **The build uses TypeScript 6.** The package is compiled and type-checked with TypeScript 6 and current development dependencies; the published API and behaviour are unchanged.
77
+ - **Opening the dies of a histogram bin works for a bin of any size.** The point list is built with a loop rather than a spread, which has an argument limit near 125,000.
26
78
 
27
79
  ## [0.37.1] — 2026-10-22
28
80
 
package/README.md CHANGED
@@ -5,15 +5,16 @@
5
5
  [![CI and deploy](https://github.com/wafertools/wafermap/actions/workflows/deploy.yml/badge.svg)](https://github.com/wafertools/wafermap/actions/workflows/deploy.yml)
6
6
  [![npm](https://img.shields.io/npm/v/@wafertools/wafermap.svg)](https://www.npmjs.com/package/@wafertools/wafermap)
7
7
  ![runtime deps](https://img.shields.io/badge/runtime%20deps-0-brightgreen)
8
- ![bundle](https://img.shields.io/badge/data%20layer%20min%2Bgz-~81%20kB-blue)
8
+ ![bundle](https://img.shields.io/badge/data%20layer%20min%2Bgz-~82%20kB-blue)
9
9
  [![license: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE)
10
+ [![support](https://img.shields.io/badge/support-wafertools-ff5e5b)](https://wafertools.github.io/support/)
10
11
 
11
12
  <img src="docs/images/hero-test-values.png" alt="wafermap demo" style="max-width:640px; display:block; margin:8px 0;" />
12
13
 
13
- Browser-first wafer map visualization for semiconductor test data.
14
+ Browser-first wafer map visualisation for semiconductor test data.
14
15
 
15
16
  **Zero runtime dependencies.** Pure ES modules with TypeScript types — works in React,
16
- Svelte, Vue, plain HTML, or a Web Worker. The DOM-free data-and-stats layer is ~81 kB
17
+ Svelte, Vue, plain HTML, or a Web Worker. The DOM-free data-and-stats layer is ~82 kB
17
18
  min+gz; the interactive renderer is larger, and its chart suite and in-app guide are
18
19
  loaded on demand rather than shipped up front — [measured sizes](docs/performance.md).
19
20
 
@@ -21,7 +22,7 @@ loaded on demand rather than shipped up front — [measured sizes](docs/performa
21
22
 
22
23
  ## Community
23
24
 
24
- Questions, ideas, or want to show off a wafer map you built? Use [GitHub
25
+ Questions or ideas? Use [GitHub
25
26
  Discussions](https://github.com/wafertools/.github/discussions).
26
27
 
27
28
  ## Overview
@@ -45,7 +46,7 @@ wafermap renders interactive wafer maps from semiconductor prober output. Hard b
45
46
 
46
47
  **[tsmap](https://github.com/wafertools/tsmap)** is a finished, free, MIT-licensed
47
48
  application built on this library. It opens STDF, ATDF, CSV, JSON and Parquet (plus
48
- `.gz` and `.zip`), runs on Linux, macOS and Windows, and also runs
49
+ `.gz`, `.bz2` and `.zip`), runs on Linux, macOS and Windows, and also runs
49
50
  [in the browser](https://wafertools.github.io/tsmap/app/) with no install — files are
50
51
  parsed locally and never uploaded. Plot modes, findings, the Insights charts, lot
51
52
  galleries, splits and reports, without writing any code.
@@ -78,7 +79,7 @@ export. Add `analyzeWaferMap` for the findings and summary panel, swap in
78
79
 
79
80
  The API reference is long because it documents every option, not because you need
80
81
  them: [tsmap](https://github.com/wafertools/tsmap), a complete cross-platform desktop
81
- application built on this library, imports **22** of its ~100 exports. Read the
82
+ application built on this library, imports **26** of its ~100 exports. Read the
82
83
  [Quick Start](https://wafertools.github.io/wafermap/quickstart/) first and treat the
83
84
  [API reference](https://wafertools.github.io/wafermap/api/) as something to search,
84
85
  not to read.
@@ -122,15 +123,21 @@ example pages under `docs/examples/`.
122
123
 
123
124
  ## Author and licence
124
125
 
125
- Written by **Paul Robins**, after nearly four decades in semiconductor test — most
126
- of it building test data analysis tools: wafer map and chart viewers, and the
127
- platforms they were built on.
126
+ Written by **Paul Robins**, who has spent over 30 years building test data analysis
127
+ software: wafer map and chart viewers, and the platforms they were built on.
128
128
 
129
- That work leaned on free software throughout — zlib, Tcl/Tk, SQLite, GCC — and it
130
- was a good deal. wafermap is some of it going back the other way, prompted by
131
- finding out that engineers doing this job today still have no decent free option
132
- for wafer map analysis.
129
+ A lot of that work leaned on free software, and it was a good deal. wafermap is some
130
+ of it going back the other way, prompted by finding out that engineers doing this job
131
+ today still have no decent free option for wafer test map analysis.
133
132
 
134
133
  [MIT](LICENSE): free to use, modify and redistribute, including in commercial and
135
134
  closed-source products. The only condition is that the copyright notice travels
136
135
  with it.
136
+
137
+ ## Support
138
+
139
+ wafermap is free, open-source and MIT-licensed, and will stay that way. If it saves you
140
+ time, you can support it on [Ko-fi](https://ko-fi.com/wafertools). If your company relies
141
+ on it, please consider sponsoring it monthly:
142
+ [how to support wafertools](https://wafertools.github.io/support/). Bug reports and sample
143
+ files help just as much.
@@ -1,4 +1,4 @@
1
- import type { Die } from '../core/dies.js';
1
+ import { type Die } from '../core/dies.js';
2
2
  import type { Wafer } from '../core/wafer.js';
3
3
  import type { TestDef } from '../renderer/buildWaferMap.js';
4
4
  /** One wafer's share of a population. */
@@ -29,6 +29,11 @@ export interface DrilldownSource {
29
29
  /** Set when the dies are not measured dies (a lot stack's per-position
30
30
  * aggregates): every chart is then unavailable, with this as the reason. */
31
31
  notMeasuredReason?: string;
32
+ /**
33
+ * For a selection on one wafer: that wafer's other dies, so the selection can be charted against them. Absent for
34
+ * anything else (a whole wafer, several wafers, a bin). Like `items`, a snapshot.
35
+ */
36
+ rest?: DrilldownItem;
32
37
  }
33
38
  export declare const LOT_STACK_REASON = "This map stacks a lot: its dies are per-position aggregates, not measured dies";
34
39
  interface WaferFacts {
@@ -45,8 +50,8 @@ interface WaferFacts {
45
50
  /** The wafer's ring count, from its built result. */
46
51
  ringCount: number;
47
52
  }
48
- /** Dies the user selected on one wafer's map. */
49
- export declare function selectionPopulation(selected: Die[], f: WaferFacts): DrilldownSource;
53
+ /** Dies the user selected on one wafer's map, with the wafer's other dies (`all` less the selection) as `rest`. */
54
+ export declare function selectionPopulation(selected: Die[], f: WaferFacts, all?: readonly Die[]): DrilldownSource;
50
55
  /** Every die of one wafer. */
51
56
  export declare function waferPopulation(dies: Die[], f: WaferFacts): DrilldownSource;
52
57
  export {};
@@ -1 +1 @@
1
- export const LOT_STACK_REASON="This map stacks a lot: its dies are per-position aggregates, not measured dies";function s(a,e,t){return{items:[{label:t.waferLabel??"this wafer",dies:a,waferIndex:t.waferIndex,wafer:t.wafer,passBins:t.passBins,ringCount:t.ringCount}],population:e,testDefs:t.testDefs,activeTest:t.activeTest,notMeasuredReason:t.isLotStack?LOT_STACK_REASON:void 0}}export function selectionPopulation(a,e){return s(a,e.waferLabel?`selected on ${e.waferLabel}`:"selected",e)}export function waferPopulation(a,e){return s(a,e.waferLabel?`on ${e.waferLabel}`:"on this wafer",e)}
1
+ import{getDieKey as o}from"../core/dies.js";export const LOT_STACK_REASON="This map stacks a lot: its dies are per-position aggregates, not measured dies";function i(s,t,e){return{items:[{label:e.waferLabel??"this wafer",dies:s,waferIndex:e.waferIndex,wafer:e.wafer,passBins:e.passBins,ringCount:e.ringCount}],population:t,testDefs:e.testDefs,activeTest:e.activeTest,notMeasuredReason:e.isLotStack?LOT_STACK_REASON:void 0}}export function selectionPopulation(s,t,e){const n=i(s,t.waferLabel?`selected on ${t.waferLabel}`:"selected",t);if(!e||t.isLotStack)return n;const c=new Set(s.map(r=>o(r))),a=e.filter(r=>!c.has(o(r)));if(a.length===0)return n;const u=n.items[0];return{...n,rest:{...u,dies:a}}}export function waferPopulation(s,t){return i(s,t.waferLabel?`on ${t.waferLabel}`:"on this wafer",t)}
@@ -206,21 +206,7 @@ export declare function applyCanvasFlow(canvas: HTMLCanvasElement, above?: HTMLE
206
206
  * `3.33e-11`) to a misleading "0.00".
207
207
  */
208
208
  export declare function formatValue(v: number): string;
209
- /**
210
- * Shared axis formatter for a numeric chart axis: one SI scale chosen from
211
- * the largest-magnitude endpoint, applied to every tick, with the scaled
212
- * unit returned once as the axis label (e.g. ticks "861 · 1040 · 1220"
213
- * with label "(µA)") — the same `fmtColorbarAxis` contract the map's
214
- * colorbar uses, so axes never show raw exponent soup like "861E-6" next
215
- * to a tooltip that says "861 µA". Falls back to `formatValue` ticks and
216
- * no label when the test has no unit.
217
- *
218
- * Pass `step` — the tick spacing from `fitTicks` (`renderer/axisTicks.ts`) —
219
- * and every label carries exactly the decimals that step needs. `tickWithUnit`
220
- * is the same label with the scaled unit appended, for an axis with no
221
- * separate unit label.
222
- */
223
- export declare function makeAxisFormat(vRef: number, unit: string | undefined, step?: number): {
209
+ export declare function makeAxisFormat(vRef: number, unit: string | undefined, step?: number, name?: string): {
224
210
  tick: (v: number) => string;
225
211
  tickWithUnit: (v: number) => string;
226
212
  unitLabel: string;
@@ -398,6 +384,11 @@ export interface ListSelectOption {
398
384
  group?: string;
399
385
  /** Why this option cannot be chosen now. It stays in the list, dimmed, with the reason after it, and does nothing when picked. */
400
386
  disabled?: string;
387
+ /** A pin toggle at the end of the row: whether it is pinned, and the reader's pin or unpin. The list is rebuilt after it. */
388
+ pin?: {
389
+ pinned: boolean;
390
+ toggle: () => void;
391
+ };
401
392
  }
402
393
  /**
403
394
  * A themed single-select picker: a trigger button plus an on-demand popup
@@ -410,7 +401,7 @@ export interface ListSelectOption {
410
401
  * sync from an external click-through (the correlation matrix picking a cell)
411
402
  * without re-entering their own change handler.
412
403
  */
413
- export declare function makeListSelect(options: readonly ListSelectOption[], selected: string, onChange: (value: string) => void, opts?: {
404
+ export declare function makeListSelect(optionsOrGetter: readonly ListSelectOption[] | (() => readonly ListSelectOption[]), selected: string, onChange: (value: string) => void, opts?: {
414
405
  maxWidth?: string;
415
406
  ownerDocument?: Document;
416
407
  ariaLabel?: string;
@@ -540,6 +531,7 @@ export interface LinkedGroupSelect {
540
531
  export declare function makeLinkedGroupSelect(groupKeys: readonly string[], labelText: string, initial: string | null, onUserChange: (key: string | null) => void, opts?: {
541
532
  maxWidth?: string;
542
533
  ownerDocument?: Document;
534
+ hint?: string;
543
535
  }): LinkedGroupSelect;
544
536
  export interface WaferSelectItem {
545
537
  label?: string;
@@ -555,11 +547,18 @@ export declare function makeToggle(labelText: string, checked: boolean, onChange
555
547
  export declare function makeLabeledSelect(labelText: string, options: readonly {
556
548
  value: string;
557
549
  label: string;
558
- }[], selected: string, onChange: (value: string) => void, opts?: {
550
+ }[], selected: string, onChange: (value: string) => void,
551
+ /** `hint` is the hover tooltip over the label and its trigger, for a control whose name alone does not say what it does. */
552
+ opts?: {
559
553
  maxWidth?: string;
560
554
  hook?: string;
561
555
  ownerDocument?: Document;
556
+ hint?: string;
562
557
  }): HTMLLabelElement;
558
+ /**
559
+ * A grid of chart cards. Its tracks are as many 420 px-or-wider columns as fit, unless an ancestor sets `--wmap-insights-cols` (a
560
+ * count) and `--wmap-insights-min` (`0px`), as the Insights tab does when the reader picks a number of columns.
561
+ */
563
562
  export declare function makeChartGridWrap(ownerDocument?: Document): HTMLDivElement;
564
563
  /** Small positioned hover tooltip, matching the pattern each ported panel builds for itself. */
565
564
  export declare function makeTooltip(card: HTMLElement): HTMLElement;
@@ -762,6 +761,17 @@ export declare function resolveAxisRange(opts: {
762
761
  * +1 to draw left-aligned right of it.
763
762
  */
764
763
  export declare function limitLabelSide(x: number, textWidth: number, plotLeft: number, plotRight: number, isLowLimit: boolean, pad?: number): -1 | 1;
764
+ /**
765
+ * Text and side for a vertical limit line's label. The label stays on its semantic side (outside the in-spec region)
766
+ * and never runs across another limit's line: when the full text does not fit there it is shortened first
767
+ * ("Hi limit 380 mV" → "Hi 380 mV" → "Hi"), and only when no variant fits on that side does it flip, again
768
+ * preferring the longest variant that clears every line. `otherXs` are the other limit lines' x positions.
769
+ * If nothing clears them, the full text goes on the side `limitLabelSide` picks.
770
+ */
771
+ export declare function limitLabelPlacement(x: number, variants: readonly string[], measure: (text: string) => number, plotLeft: number, plotRight: number, isLowLimit: boolean, otherXs?: readonly number[], pad?: number): {
772
+ text: string;
773
+ side: -1 | 1;
774
+ };
765
775
  export declare function drawOffAxisLimits(ctx: CanvasRenderingContext2D, offAxis: AxisRange['offAxis'], axis: {
766
776
  left: number;
767
777
  right: number;
@@ -1 +1 @@
1
- import{SHADOW as G,LEADING as re,wireTooltip as U,wireControlHover as O,controlStyle as _,SPACE as v,RADIUS as $,fontPx as D,FONT as A,CLR as g,Z_BASE as le,menuLayerFor as se,wireListNavigation as ae,MENU_SEARCH_THRESHOLD as X,makeMenuSearchBox as ce,markMenuTrigger as W,markNoPrint as j,openCommandMenu as de,saveImageBlob as ue,openReparentedModal as pe}from"../toolbar.js";import{ICONS as Y}from"../icons.js";import{openGuideAt as fe}from"../guideWindow.js";import{minOf as me,maxOf as he}from"../../core/utils.js";import{robustFence as K}from"../../stats/math.js";import{fmt as ge,fmtColorbarAxis as xe}from"../../renderer/fmt.js";import{markedTestLabel as be,DERIVED_LANE_PAD as ye}from"../../renderer/testLabel.js";export function openChartExpandModal(e,o,t={}){for(const a of e.querySelectorAll('div[style*="position: absolute"]'))a.style.display==="block"&&a.style.pointerEvents==="none"&&(a.style.display="none");const i=e.getAttribute("style")??"",n=e.dataset.wmapChartGrow??"plot";Object.assign(e.style,{flex:"1",minHeight:"0",alignSelf:"stretch",border:"none",borderRadius:"0"}),e.dataset.wmapExpanded="1";const r=e.querySelector(":scope > div > [data-wmap-card-expand]"),l=a=>{r&&(r.style.display=a?"flex":"none")};l(!1);const s=pe([e],{title:o,anchor:t.anchor,ownerDocument:e.ownerDocument,boxSize:we[n],onClosed:()=>{delete e.dataset.wmapExpanded,e.setAttribute("style",i),l(!0),t.onClosed?.()}});if(!s)return delete e.dataset.wmapExpanded,e.setAttribute("style",i),l(!0),null;if(n==="rows"){const a=()=>{const d=Number(e.dataset.wmapChartFullH);if(!d)return;const c=s.box.offsetHeight-s.contentWrap.clientHeight;s.setNaturalHeight(`min(90vh, ${Math.ceil(c+d)}px)`)};a(),(e.ownerDocument.defaultView??window).requestAnimationFrame(a)}return s}const we={plot:{width:"min(94vw, 1100px)",height:"min(90vh, 760px)"},rows:{width:"min(94vw, 960px)",height:"min(90vh, 700px)"},square:{width:"min(94vw, 820px)",height:"min(90vh, 860px)"}};export const GRID_ALPHA=.4;export function withAlpha(e,o){const t=e.trim();let i,n,r,l=1;const s=t.match(/^#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i),a=t.match(/^rgba?\(\s*([\d.]+)[\s,]+([\d.]+)[\s,]+([\d.]+)(?:\s*[,/]\s*([\d.]+%?))?\s*\)$/i);if(s){const d=s[1].length===3?s[1].split("").map(c=>c+c).join(""):s[1];[i,n,r]=[0,2,4].map(c=>parseInt(d.slice(c,c+2),16)),d.length===8&&(l=parseInt(d.slice(6,8),16)/255)}else if(a)[i,n,r]=[a[1],a[2],a[3]].map(Number),a[4]!==void 0&&(l=a[4].endsWith("%")?parseFloat(a[4])/100:Number(a[4]));else return e;return`rgba(${i}, ${n}, ${r}, ${+(l*o).toFixed(3)})`}const Ce={text:"#333",textMuted:"#66788a",border:"rgba(0,0,0,0.12)",bg:"#fff",bgHover:"#edf0f8",track:"#fafbfc",warnBorder:"#f0c040",accent:"#1a66cc",limitLine:"#b45309",alert:"#7a1c1c"},Z={text:"text",textMuted:"text-muted",border:"border",bg:"surface",bgHover:"bg-hover",track:"panel-bg",warnBorder:"warn-border",accent:"icon-active",limitLine:"warn-text",alert:"err-text"};export function resolveChartCanvasColors(e){const o=getComputedStyle(e),t={};for(const i of Object.keys(Z)){const n=o.getPropertyValue(`--wmap-${Z[i]}`).trim();t[i]=n||Ce[i]}return t.grid=withAlpha(t.border,GRID_ALPHA),t}export const PADDING=12,VALUE_WIDTH=100;export function observeResize(e,o){const t=e.ownerDocument.defaultView??window;let i=0;const n=new t.ResizeObserver(()=>{i||(i=t.requestAnimationFrame(()=>{i=0,o()}))});return n.observe(e),{disconnect:()=>{i&&t.cancelAnimationFrame(i),i=0,n.disconnect()}}}export function growCardToFitContent(e,o,t){const i=`${z(e,o)+t}px`;e.style.minHeight!==i&&(e.style.minHeight=i)}function z(e,o){const t=e.ownerDocument.defaultView??window,i=t.getComputedStyle(e);let n=0;for(const r of Array.from(e.children)){if(r===o)continue;const l=r,s=t.getComputedStyle(l);s.display==="none"||s.position==="absolute"||s.position==="fixed"||(n+=l.offsetHeight+(parseFloat(s.marginTop)||0)+(parseFloat(s.marginBottom)||0))}return i.boxSizing==="border-box"&&(n+=(parseFloat(i.paddingTop)||0)+(parseFloat(i.paddingBottom)||0)+(parseFloat(i.borderTopWidth)||0)+(parseFloat(i.borderBottomWidth)||0)),n}function J(e,o){const t=e.ownerDocument.defaultView??window;let i=0;for(const n of Array.from(e.children)){if(n===o)continue;const r=n,l=t.getComputedStyle(r);l.display==="none"||l.position==="absolute"||l.position==="fixed"||(i+=r.offsetHeight+(parseFloat(l.marginTop)||0)+(parseFloat(l.marginBottom)||0))}return i}export const WAFER_MENU_HINT="<br><em>right-click to chart this wafer</em>";export function populationPhrase(e,o,t){const i=e.toLocaleString(),n=e===1?"die":"dies";return t?e===o?`${i} ${n} ${t}`:`${i} of ${o.toLocaleString()} dies ${t} (partial and edge-excluded dies left out)`:`${i} ${n}`}export function setChartGrow(e,o){e.dataset.wmapChartGrow=o}export function isExpandedCard(e){return e.dataset.wmapExpanded==="1"}export function bodyRoom(e,o,t){const n=(e.ownerDocument.defaultView??window).getComputedStyle(e),r=e.clientHeight-(parseFloat(n.paddingTop)||0)-(parseFloat(n.paddingBottom)||0),l=n.boxSizing==="border-box"?(parseFloat(n.paddingTop)||0)+(parseFloat(n.paddingBottom)||0)+(parseFloat(n.borderTopWidth)||0)+(parseFloat(n.borderBottomWidth)||0):0;return r-(z(e,o)-l)-(t?J(o,t):0)}export function fitRowsHeight(e,o,t,i,n=0){if(growCardToFitContent(e,o,n+t),e.dataset.wmapChartFullH=String(Math.ceil(z(e,o)+n+i)),!isExpandedCard(e))return t;const r=bodyRoom(e,o)-n;return Math.max(t,Math.min(i,Math.floor(r)))}export function chartFillHeight(e,o,t,i){const n=J(o,t);return growCardToFitContent(e,o,n+i),Math.max(i,o.clientHeight-n)}export function chartDpr(e){return(e.ownerDocument.defaultView??window).devicePixelRatio||1}export function prepareCanvas(e,o,t,i){const n=chartDpr(e);e.width=Math.max(1,Math.floor(t*n)),e.height=Math.max(1,Math.floor(i*n)),e.style.width=`${t}px`,e.style.height=`${i}px`;const r=e.getContext("2d");return r?(r.setTransform(n,0,0,n,0,0),r.clearRect(0,0,t,i),r.font=`${D(-1)}px system-ui, sans-serif`,r.textBaseline="middle",{ctx:r,theme:resolveChartCanvasColors(o)}):null}export function applyCanvasFlow(e,o=0){let t;if(typeof o=="number")t=o;else{const i=(o.ownerDocument.defaultView??window).getComputedStyle(o);t=o.offsetTop+o.offsetHeight+(parseFloat(i.marginBottom)||0)}e.style.position="absolute",e.style.left="0",e.style.right="0",e.style.top=`${t}px`,e.style.bottom="0"}export function formatValue(e){return Number.isFinite(e)?Number.isInteger(e)?`${e}`:ge(e,void 0,"engineering"):"\u2014"}export function makeAxisFormat(e,o,t){if(!o&&t===void 0)return{tick:formatValue,tickWithUnit:formatValue,unitLabel:""};const{tickFmt:i,axisLabel:n,scaledUnit:r}=xe(e,null,o,"engineering",t);return{tick:i,tickWithUnit:r?l=>`${i(l)} ${r}`:i,unitLabel:n}}const ve=8;export const VERTICAL_TICK_SPACING_PX=28;export function horizontalTickSpacing(e,o,t){return(i,n)=>{const r=makeAxisFormat(o,t,i).tick;return n.reduce((l,s)=>Math.max(l,e.measureText(r(s)).width),0)+ve}}export function drawAxisUnit(e,o,t,i,n){const r={textAlign:e.textAlign,textBaseline:e.textBaseline,fillStyle:e.fillStyle,font:e.font};e.font=`${D(-1)}px system-ui, sans-serif`,e.textAlign="left",e.textBaseline="middle",e.fillStyle=n,e.fillText(`(${o})`,t,i),Object.assign(e,r)}export function captionText(e){return e.split(" \xB7 ").map(o=>o.replace(/[\s·]+$/,"").trim()).filter(o=>o&&!/\b(click|clicks|drag|hover|right-click)\b/i.test(o)&&!/\(.*(click|drag).*\)/i.test(o)).join(" \xB7 ")}const P=(e,o)=>{for(let t=e;t&&t!==o.parentElement;t=t.parentElement)if(t.style.display==="none")return!1;return!0},Se=/\s*[▾▼]\s*$/,q=new WeakMap;export function describeCard(e){const o=[],t=e.querySelector("[data-wmap-controls]");if(t){for(const l of t.querySelectorAll("button[aria-haspopup]")){if(!P(l,t))continue;const s=(l.textContent??"").replace(Se,"").trim();if(!s)continue;const a=l.closest("label"),c=(a?(a.textContent??"").replace(l.textContent??"","").replace(/[:\s]+$/,"").trim():"")||l.getAttribute("aria-label")||"";o.push(c&&c!==s?`${c}: ${s}`:s)}for(const l of t.querySelectorAll('[role="radiogroup"]')){if(!P(l,t))continue;const a=l.querySelector("input:checked")?.closest("label")?.textContent?.trim();a&&o.push(a)}for(const l of t.querySelectorAll('input[type="checkbox"]:checked')){if(!P(l,t))continue;const s=l.closest("label")?.textContent?.trim();s&&o.push(s)}}const i=[];for(const l of e.querySelectorAll("[data-wmap-caption]")){if(!P(l,e))continue;const s=captionText((l.textContent??"").replace(/\s+/g," ").trim());s&&i.push(s)}const n=[];for(const l of e.querySelectorAll("button[aria-pressed]")){const s=l.querySelector("span"),a=s?.style.backgroundColor||s?.style.borderColor,d=(l.textContent??"").trim();d&&a&&a!=="transparent"&&n.push({label:d,color:a})}for(const l of e.querySelectorAll("[data-wmap-legend] > span")){const s=l.firstElementChild,a=s?.style.backgroundColor||s?.style.borderColor,d=(l.textContent??"").trim();d&&a&&a!=="transparent"&&n.push({label:d,color:a})}const r=q.get(e)?.();return r&&(r.controls&&o.push(...r.controls),r.caption!==void 0&&(i.length=0,i.push(...typeof r.caption=="string"?[r.caption]:r.caption)),r.legend&&(n.length=0,n.push(...r.legend))),{controls:o,captions:i,legend:n}}function ke(e){const o=describeCard(e),t=q.get(e)?.();return{controls:o.controls,caption:o.captions,legend:o.legend.length?o.legend:void 0,colorbar:t?.colorbar}}function Q(e){for(const o of e.querySelectorAll("[data-wmap-chart-card]")){const t=o.querySelector(":scope > [data-wmap-print-only]");if(!t)continue;const i=describeCard(o);t.replaceChildren();const n=[i.controls.length?i.controls.join(" \xB7 "):"",...i.captions].filter(Boolean);for(const r of n){const l=e.createElement("div");l.textContent=r,t.appendChild(l)}for(const r of o.querySelectorAll("[data-wmap-caption]"))r.setAttribute("data-wmap-noprint","1")}}const ee=new WeakSet;function Le(e){if(ee.has(e))return;ee.add(e);const o=e.createElement("style");o.textContent="@media print{[data-wmap-print-only]{display:block!important}}",e.head.appendChild(o);const t=e.defaultView;t?.addEventListener("beforeprint",()=>Q(e));try{t?.matchMedia?.("print").addEventListener?.("change",i=>{i.matches&&Q(e)})}catch{}}function Ae(e){const o=e.ownerDocument.defaultView;for(let t=e;t&&o;t=t.parentElement){const i=o.getComputedStyle(t).backgroundColor;if(i&&i!=="transparent"&&!/^rgba\(.*,\s*0\)$/.test(i))return i}return"#ffffff"}export function composeChartPng(e,o){const t=e.ownerDocument,i=t.createElement("canvas"),n=Math.max(1,e.width/(e.clientWidth||e.width)),r=e.width,l=t.createElement("canvas").getContext("2d"),s=12*n,a=(f,x="400")=>`${x} ${f*n}px system-ui, -apple-system, "Segoe UI", sans-serif`,d=(f,x)=>l?(l.font=x,l.measureText(f).width):f.length*7*n,c=[];let u=0;if(o){u=s,c.push({kind:"text",text:o.title,x:s,y:u+14*n,font:a(16,"600"),alpha:1}),u+=24*n;const f=o.decor,x=[];f?.controls?.length&&x.push({text:f.controls.join(" \xB7 "),alpha:1});for(const m of f?.caption===void 0?[]:typeof f.caption=="string"?[f.caption]:f.caption)x.push({text:m,alpha:.75});const b=a(12);for(const{text:m,alpha:C}of x){let y="";for(const S of m.split(" ")){const T=y?`${y} ${S}`:S;y&&d(T,b)>r-2*s?(c.push({kind:"text",text:y,x:s,y:u+11*n,font:b,alpha:C}),u+=17*n,y=S):y=T}y&&(c.push({kind:"text",text:y,x:s,y:u+11*n,font:b,alpha:C}),u+=17*n)}if(f?.legend?.length){u+=4*n;const m=a(12);let C=s;for(const y of f.legend){const S=14*n+d(y.label,m)+14*n;C>s&&C+S>r-s&&(C=s,u+=18*n),c.push({kind:"dot",x:C+5*n,y:u+7*n,r:5*n,color:y.color}),c.push({kind:"text",text:y.label,x:C+14*n,y:u+11*n,font:m,alpha:1}),C+=S}u+=20*n}if(f?.colorbar){u+=4*n;const m=a(12),C=f.colorbar;let y=s;c.push({kind:"text",text:C.label,x:y,y:u+10*n,font:m,alpha:1}),y+=d(C.label,m)+10*n,c.push({kind:"text",text:C.lo,x:y,y:u+10*n,font:m,alpha:.75}),y+=d(C.lo,m)+6*n,c.push({kind:"strip",x:y,y:u+1*n,w:200*n,h:10*n,color:C.color}),y+=206*n,c.push({kind:"text",text:C.hi,x:y,y:u+10*n,font:m,alpha:.75}),u+=20*n}u+=6*n}i.width=r,i.height=Math.ceil(e.height+u);const p=i.getContext("2d");if(p.fillStyle=o?Ae(o.card):"#ffffff",p.fillRect(0,0,i.width,i.height),o){const f=t.defaultView,x=f&&f.getComputedStyle(o.card).color||"#222222";p.textBaseline="alphabetic";for(const b of c)if(b.kind==="text")p.font=b.font,p.fillStyle=x,p.globalAlpha=b.alpha,p.fillText(b.text,b.x,b.y),p.globalAlpha=1;else if(b.kind==="dot")p.fillStyle=b.color,p.beginPath(),p.arc(b.x,b.y,b.r,0,Math.PI*2),p.fill();else for(let m=0;m<b.w;m++)p.fillStyle=b.color(m/Math.max(1,b.w-1)),p.fillRect(b.x+m,b.y,1,b.h)}return p.drawImage(e,0,u),i}export function saveCanvasPng(e,o,t,i){composeChartPng(e,i).toBlob(n=>{n&&ue(n,o,t)},"image/png")}const te="10px";export function chartSwatchCss(e,o="solid"){return["display:inline-block",`width:${te}`,`height:${te}`,`border-radius:${$.pill}`,`background:${o==="outline"?"transparent":e}`,`border:1px ${o==="outline"?"dashed":"solid"} ${e}`,"box-sizing:border-box","flex-shrink:0"].join(";")}const Ee="0.35";export function makeSeriesLegendItem(e,o,t=document){const i=t.createElement("button");i.type="button",Object.assign(i.style,{display:"inline-flex",alignItems:"center",gap:v.xs,padding:`${v.xs} ${v.md}`,borderRadius:$.pill,border:`1px solid ${g.menuBorder}`,background:"none",cursor:"pointer",fontSize:A.body,color:g.text,whiteSpace:"nowrap"}),O(i,"bare");const n=t.createElement("span");return n.style.cssText=chartSwatchCss(o),i.append(n,t.createTextNode(e)),{el:i,setState({selected:r,dimmed:l}){i.style.borderColor=r?g.iconActive:g.menuBorder,i.style.fontWeight=r?"600":"400",i.style.opacity=l?Ee:"1",i.setAttribute("aria-pressed",r?"true":"false")}}}export function cardFrameStyle(){return{background:g.menuBg,border:`1px solid ${g.menuBorder}`,borderRadius:$.container,padding:v.xl,fontVariantNumeric:"tabular-nums"}}function ne(e){Object.assign(e.style,{..._("outlined"),color:g.label,padding:"0",width:"22px",height:"22px",lineHeight:re.none,flexShrink:"0",display:"flex",alignItems:"center",justifyContent:"center"}),O(e)}export function cardShell(e,o,t=document,i={}){const n=t.createElement("div");n.dataset.wmapChartCard="1",n.dataset.wmapChartTitle=e,Object.assign(n.style,{display:"flex",flexDirection:"column",...cardFrameStyle(),minWidth:"0",minHeight:"0",flex:"1 1 0",position:"relative"});const r=n.ownerDocument.createElement("div");Object.assign(r.style,{display:"flex",alignItems:"center",gap:v.sm,paddingBottom:"6px",marginBottom:v.md,borderBottom:`1px solid ${g.menuBorder}`});const l=n.ownerDocument.createElement("div");l.textContent=e,Object.assign(l.style,{color:g.value,fontSize:A.heading,fontWeight:"600",flex:"1"}),r.appendChild(l);const s=makeTooltip(n),a=n.ownerDocument.createElement("button");a.type="button",a.setAttribute("aria-label","Expand"),a.innerHTML=Y.expand,a.dataset.wmapCardExpand="1",ne(a),attachChartTip(a,n,s,"Expand"),j(a),a.addEventListener("click",()=>{isExpandedCard(n)||openChartExpandModal(n,l.textContent??e)}),r.appendChild(a);const d=n.ownerDocument.createElement("button");d.type="button",d.setAttribute("aria-label","Chart actions"),d.innerHTML=Y.more,d.dataset.wmapCardMenu="1",ne(d),attachChartTip(d,n,s,"Chart actions"),W(d,!1),j(d),r.appendChild(d);const c=n.ownerDocument.createElement("div");c.dataset.wmapCardAbout="1",c.setAttribute("role","note"),Object.assign(c.style,{display:"none",color:g.label,fontSize:A.body,marginBottom:v.md}),j(c);let u;const p=h=>{c.textContent=h?u?.text??"":"",c.style.display=h?"":"none"};let f,x;const b=()=>{const h=f?f():n.querySelector("canvas");h&&saveCanvasPng(h,l.textContent||e,o,{card:n,title:l.textContent||e,decor:ke(n)})},m=()=>{const h=[],M=(E,N,B)=>({label:E,active:!1,action:!0,enabled:!B,disabledHint:B,onClick:()=>{C?.(),N()}});i.png!==!1&&(f||n.querySelector("canvas"))&&h.push(M("Save as PNG",b));for(const E of x?.()??[])h.push(M(E.label,E.onClick,E.disabledHint));if(u){const E=c.style.display!=="none";h.push({label:`About this ${u.noun}`,active:E,onClick:()=>{C?.(),p(!E)}})}return h};let C;d.addEventListener("click",()=>{if(d.getAttribute("aria-expanded")==="true"){C?.();return}const h=m();h.length!==0&&(C=de(d.getBoundingClientRect(),d,h,`${l.textContent||e}: chart actions`,{trigger:d,hook:"wmapCardMenuList"}))}),n.appendChild(r),n.appendChild(c);const y=n.ownerDocument.createElement("div");y.dataset.wmapPrintOnly="1",Object.assign(y.style,{display:"none",color:g.label,fontSize:A.body,marginBottom:v.sm}),n.appendChild(y),Le(n.ownerDocument);const S=n.ownerDocument.createElement("div");S.dataset.wmapControls="1",Object.assign(S.style,{display:"flex",gap:v.sm,marginBottom:v.md,flexWrap:"wrap",alignItems:"center"}),j(S),n.appendChild(S);const T=n.ownerDocument.createElement("div");return Object.assign(T.style,{overflowX:"hidden",overflowY:"hidden",minHeight:"0",flex:"1",position:"relative"}),n.appendChild(T),{card:n,heading:l,controlsRow:S,body:T,setPngDecor:h=>{q.set(n,h)},setPngCanvas:h=>{f=h},setAbout:h=>{u=h,p(!!h&&c.style.display!=="none")},setMenuRows:h=>{x=h}}}export function guideCite(e,o,t="How to read this"){const i=e.createElement("span");return i.append(`${t}: `,oe(e,o)," in the user guide"),i}function oe(e,o){const t=e.createElement("button");return t.type="button",t.textContent=o.title,t.dataset.wmapGuideLink=o.id,Object.assign(t.style,{border:"none",background:"none",padding:"0",font:"inherit",color:g.iconActive,textDecoration:"underline",cursor:"pointer"}),O(t),t.addEventListener("click",()=>fe(o.id,t)),t}export function appendGuideCites(e,o){if(o.length===0)return;const t=e.ownerDocument;e.append(" \xB7 how to read this: "),o.forEach((i,n)=>{n>0&&e.append(n===o.length-1?" and ":", "),e.append(oe(t,i))}),e.append(" in the user guide")}export function inputStyle(){return{background:g.menuBg,color:g.text,border:`1px solid ${g.menuBorder}`,borderRadius:$.control,padding:`${v.xs} ${v.sm}`,fontSize:A.body,fontFamily:A.family,boxSizing:"border-box",minWidth:"0"}}export function makeSegmented(e,o,t,i=document,n=!1){const r=i.createElement("div");r.setAttribute("role","radiogroup"),Object.assign(r.style,{display:"inline-flex",flexWrap:"wrap",maxWidth:"100%",padding:"1px 0 0 1px"});const l=e.length-1,s=`seg-${Math.random().toString(36).slice(2,9)}`,a=[];return e.forEach(([d,c,u],p)=>{const f=i.createElement("label");u&&U(f,u),Object.assign(f.style,{display:"inline-flex",alignItems:"center",fontSize:A.body,padding:n?"1px 6px":"3px 10px",cursor:"pointer",userSelect:"none",border:`1px solid ${g.menuBorder}`,margin:"-1px 0 0 -1px",borderTopLeftRadius:p===0?$.control:"0",borderBottomLeftRadius:p===0?$.control:"0",borderTopRightRadius:p===l?$.control:"0",borderBottomRightRadius:p===l?$.control:"0"}),O(f,"bare");const x=i.createElement("input");x.type="radio",x.name=s,x.value=d,x.checked=d===o,Object.assign(x.style,{position:"absolute",opacity:"0",width:"0",height:"0"});const b=()=>{f.style.background=x.checked?g.bgActive:g.menuBg,f.style.color=x.checked?g.iconActive:g.text,f.dataset.on=x.checked?"true":"false"};a.push(b),b(),x.addEventListener("change",()=>{if(x.checked){for(const m of a)m();t(d)}}),f.append(x,i.createTextNode(c)),r.appendChild(f)}),r}const $e=360;export function firstRowsToggle(e,o){let t=!1;const i=e.createElement("button");i.type="button",Object.assign(i.style,{..._("outlined"),marginTop:v.sm}),O(i);const n=()=>{o.fill(t),Object.assign(o.scroller.style,{maxHeight:t?`${$e}px`:"",overflowY:t?"auto":""}),i.textContent=t?`Show the first ${o.noun}`:`Show all ${o.total} ${o.noun}`,i.style.display=o.total>o.first?"":"none"};return i.addEventListener("click",()=>{t=!t,n()}),n(),i}export function makeBackButton(e,o=document){const t=o.createElement("button");return t.type="button",t.textContent="\u2190 Back",Object.assign(t.style,{..._("outlined"),background:g.menuBg,color:g.label}),O(t),t.addEventListener("click",e),t}export function renderEmptyState(e,o,t){const i=e.ownerDocument.createElement("div");i.textContent=o,Object.assign(i.style,{color:g.label,fontSize:A.body,padding:"8px 0"}),t&&Object.assign(i.style,t),e.appendChild(i)}export function makeListSelect(e,o,t,i={}){const{maxWidth:n="200px",ownerDocument:r=document,ariaLabel:l,emptyText:s,searchPlaceholder:a="Filter\u2026",hook:d}=i;let c=o;const u=h=>e.find(M=>M.value===h)?.label??"",p=r.createElement("button");p.type="button",d&&(p.dataset.wmapSelect=d),l&&p.setAttribute("aria-label",l),Object.assign(p.style,{fontSize:A.body,padding:`${v.xxs} ${v.sm}`,background:g.menuBg,color:g.text,border:`1px solid ${g.menuBorder}`,borderRadius:$.control,maxWidth:n,textAlign:"left",cursor:"pointer",display:"inline-flex",alignItems:"center",gap:v.sm,justifyContent:"space-between"}),O(p),W(p,!1);const f=r.createElement("span");Object.assign(f.style,{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"});const x=r.createElement("span");x.textContent="\u25BE",x.style.flex="0 0 auto",p.append(f,x);const b=()=>{f.textContent=e.length===0?s??"(none)":u(c)||s||"(none)"};if(b(),e.length===0)return p.disabled=!0,p.style.opacity="0.6",p.style.cursor="default",Object.defineProperty(p,"value",{get:()=>c,set:h=>{c=h,b()}});let m=null;const C=()=>{m&&(m.remove(),m=null,W(p,!1))},y=()=>{C(),p.focus()};function S(){const h=p.getBoundingClientRect(),M=r.defaultView??window,E=Math.max(h.width,220),N=Math.min(h.left,Math.max(4,(M.innerWidth??1/0)-E-4));m=r.createElement("div"),m.setAttribute("role","listbox"),m.setAttribute("aria-label",l??"Options"),Object.assign(m.style,{position:"fixed",top:`${h.bottom+4}px`,left:`${N}px`,background:g.menuBg,border:`1px solid ${g.menuBorder}`,borderRadius:$.control,boxShadow:G.menu,zIndex:le,minWidth:`${E}px`,maxHeight:"320px",overflowY:"auto",padding:"4px 0",pointerEvents:"auto"});const B=[],H=()=>B.filter(w=>w.row.style.display!=="none").map(w=>w.row),F=[],ie=()=>{for(const w of F)w.el.style.display=B.slice(w.first,w.last+1).some(k=>k.row.style.display!=="none")?"":"none"};if(e.length>X){const w=ce(k=>{for(const L of B)L.row.style.display=L.label.includes(k)?"":"none";ie()},a,r,H);Object.assign(w.style,{position:"sticky",top:"0",zIndex:"1",background:g.menuBg}),w.addEventListener("keydown",k=>{if(k.key==="Escape"){k.preventDefault(),y();return}k.key==="ArrowDown"&&(k.preventDefault(),H()[0]?.focus())}),m.appendChild(w)}let V;for(const w of e){if(w.group!==void 0&&w.group!==V){const R=r.createElement("div");R.textContent=w.group,R.setAttribute("role","presentation"),Object.assign(R.style,{padding:`${v.sm} ${v.xl} ${v.xxs}`,fontSize:A.sub,color:g.label,fontWeight:"600"}),m.appendChild(R),F.push({el:R,first:B.length,last:B.length})}V=w.group;const k=w.value===c,L=r.createElement("div");L.textContent=w.disabled?`${w.label} \u2014 ${w.disabled}`:w.label,L.setAttribute("role","option"),L.setAttribute("aria-selected",k?"true":"false"),w.disabled&&L.setAttribute("aria-disabled","true"),L.tabIndex=-1,Object.assign(L.style,{padding:`${v.sm} ${v.xl}`,fontSize:A.body,cursor:w.disabled?"default":"pointer",color:w.disabled?g.label:k?g.iconActive:g.text,fontWeight:k?"700":"400",opacity:w.disabled?"0.7":"",background:k?g.menuActive:"transparent",whiteSpace:"nowrap"}),L.addEventListener("mouseenter",()=>{!k&&!w.disabled&&(L.style.background=g.menuHover)}),L.addEventListener("mouseleave",()=>{k||(L.style.background="transparent")}),L.addEventListener("click",R=>{R.stopPropagation(),!w.disabled&&(c=w.value,b(),y(),t(w.value))}),m.appendChild(L),B.push({row:L,label:w.label.toLowerCase()}),F.length&&(F[F.length-1].last=B.length-1)}if(ae(m,H,y),se(p).appendChild(m),W(p,!0),e.length<=X){const w=e.findIndex(k=>k.value===c);H()[w>=0?w:0]?.focus()}}p.addEventListener("click",h=>{if(h.stopPropagation(),m){C();return}S()});const T=h=>{if(!p.isConnected){r.removeEventListener("click",T);return}m&&!m.contains(h.target)&&!p.contains(h.target)&&C()};return r.addEventListener("click",T),Object.defineProperty(p,"value",{get:()=>c,set:h=>{c=h,b()}})}export function testOptionLabels(e){const o=e.some(t=>t.derived);return e.map(t=>(o&&!t.derived?ye:"")+be(t,t.testNumber))}export function makeTestSelect(e,o,t,i={}){const{maxWidth:n="200px",emptyText:r="No parametric tests",ownerDocument:l=document}=i;return makeListSelect(testOptionLabels(e).map((s,a)=>({value:String(e[a].testNumber),label:s})),o!==null?String(o):"",s=>t(Number(s)),{maxWidth:n,ownerDocument:l,ariaLabel:"Test",emptyText:r,searchPlaceholder:"Filter tests\u2026"})}export function makeLinkedAxisPrefs(e,o,t,i=document){let n=o?.includeLimits,r=o?.clipOutliers??!1,l=o?.limits??"both";const s=()=>t({includeLimits:n,clipOutliers:r,limits:l});return{get:()=>({includeLimits:n,clipOutliers:r,limits:l}),sync(a,d,c=!1){e.innerHTML="",c&&e.appendChild(makeLimitsSelect(l,u=>{l=u,s()},i)),d&&e.appendChild(makeToggle("Axis includes limits",a,u=>{n=u,s()},i,"Widen the axis to show every limit, even where the data sits well clear of them")),e.appendChild(makeToggle("Clip outliers",r,u=>{r=u,s()},i,"Narrow the axis so a few extreme values do not flatten the rest. Statistics still use every value"))},set(a){const d=a.limits??"both";return a.includeLimits===n&&a.clipOutliers===r&&d===l?!1:(n=a.includeLimits,r=a.clipOutliers,l=d,!0)}}}export function makeLinkedTestSelect(e,o,t,i={}){let n=o;const r=makeTestSelect(e,n,l=>{l!==n&&(n=l,t(l))},i);return{el:r,get:()=>n,set(l){return n===l||!e.some(s=>s.testNumber===l)?!1:(n=l,r.value=String(l),!0)}}}export const ALL_GROUPS="\0all";export function makeLinkedGroupSelect(e,o,t,i,n={}){let r=t;const l=c=>c??ALL_GROUPS,s=c=>c===ALL_GROUPS?null:c,a=makeLabeledSelect(o,[{value:ALL_GROUPS,label:"All groups"},...e.map(c=>({value:c,label:c}))],l(r),c=>{const u=s(c);u!==r&&(r=u,i(u))},{...n,hook:"group-scope"}),d=a.querySelector('[data-wmap-select="group-scope"]');return{el:a,get:()=>r,set(c){return r===c||c!==null&&!e.includes(c)?!1:(r=c,d&&(d.value=l(c)),!0)}}}export function makeWaferSelect(e,o,t,i={}){const{maxWidth:n="160px",allLabel:r="All wafers",ownerDocument:l=document}=i,s="\0all";return makeListSelect([{value:s,label:r},...e.map((a,d)=>({value:String(d),label:a.label??`#${d}`}))],o===null?s:String(o),a=>t(a===s?null:Number(a)),{maxWidth:n,ownerDocument:l,ariaLabel:"Wafer",searchPlaceholder:"Filter wafers\u2026"})}export function makeToggle(e,o,t,i=document,n){const r=i.createElement("label");Object.assign(r.style,{display:"inline-flex",alignItems:"center",gap:v.xs,fontSize:A.body,color:g.label,cursor:"pointer",userSelect:"none"}),O(r,"bare");const l=i.createElement("input");return l.type="checkbox",l.checked=o,l.style.cssText="margin:0;cursor:pointer;",l.addEventListener("change",()=>t(l.checked)),r.append(l,i.createTextNode(e)),n&&U(r,n),r}export function makeLabeledSelect(e,o,t,i,n={}){const{maxWidth:r="160px",hook:l,ownerDocument:s=document}=n,a=s.createElement("label");a.textContent=e,Object.assign(a.style,{color:g.label,fontSize:A.body,display:"flex",alignItems:"center",gap:v.xs});const d=makeListSelect(o,t,i,{maxWidth:r,ownerDocument:s,hook:l,ariaLabel:e.replace(/:\s*$/,"")});return a.appendChild(d),a}export function makeChartGridWrap(e=document){const o=e.createElement("div");return o.dataset.wmapChartGrid="1",Object.assign(o.style,{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(420px, 1fr))",gap:v.lg,flex:"0 0 auto"}),o}export function makeTooltip(e){const o=e.ownerDocument.createElement("div");return Object.assign(o.style,{position:"absolute",display:"none",pointerEvents:"none",zIndex:"50",background:"rgba(30, 32, 40, 0.93)",color:"#f0f0f2",border:"1px solid rgba(255,255,255,0.10)",borderRadius:$.control,padding:`${v.sm} ${v.xl}`,fontSize:A.sub,fontFamily:A.family,maxWidth:"320px",whiteSpace:"normal",overflowWrap:"break-word",boxShadow:G.menu}),e.appendChild(o),o}export function attachChartTip(e,o,t,i){e.removeAttribute("title"),e.textContent?.trim()||(e.ariaLabel=i),e.addEventListener("mouseenter",n=>{t.textContent=i,t.style.display="block",positionChartTooltip(t,o,n.clientX,n.clientY)}),e.addEventListener("mousemove",n=>{t.style.display==="block"&&positionChartTooltip(t,o,n.clientX,n.clientY)}),e.addEventListener("mouseleave",()=>{t.style.display="none"}),e.addEventListener("click",()=>{t.style.display="none"}),e.addEventListener("focus",()=>{t.textContent=i,t.style.display="block";const n=e.getBoundingClientRect();positionChartTooltip(t,o,n.left+n.width/2,n.bottom)}),e.addEventListener("blur",()=>{t.style.display="none"})}export function positionChartTooltip(e,o,t,i){const n=o.getBoundingClientRect(),r=14,l=4;e.style.left="0",e.style.top="0";const s=e.offsetWidth,a=e.offsetHeight;let d=t-n.left+r,c=i-n.top+r;d+s+l>n.width&&(d=t-n.left-r-s),c+a+l>n.height&&(c=i-n.top-r-a),d=Math.max(l,d),c=Math.max(l,c),e.style.left=`${d}px`,e.style.top=`${c}px`}export const LIMIT_LABEL={test:{lo:"Lo limit",hi:"Hi limit"},spec:{lo:"LSL",hi:"USL"},pat:{lo:"PAT lo",hi:"PAT hi"},whatif:{lo:"What-if lo",hi:"What-if hi"},ref:{lo:"",hi:""}},LIMIT_DASH={test:[3,3],spec:[10,4],pat:[1,3],whatif:[8,3,2,3],ref:[6,2,1,2]},LIMITS_SHOWN_OPTIONS=[{value:"both",label:"Test + spec"},{value:"test",label:"Test limits"},{value:"spec",label:"Spec limits (LSL/USL)"},{value:"none",label:"None"}];function I(e,o){const[t,i]=o==="test"?[e?.limitLow,e?.limitHigh]:o==="spec"?[e?.specLow,e?.specHigh]:o==="pat"?[e?.patLow,e?.patHigh]:o==="whatif"?[e?.whatIfLow,e?.whatIfHigh]:[void 0,void 0],n=[];return t!==void 0&&Number.isFinite(t)&&n.push({value:t,kind:o,end:"lo",label:LIMIT_LABEL[o].lo}),i!==void 0&&Number.isFinite(i)&&n.push({value:i,kind:o,end:"hi",label:LIMIT_LABEL[o].hi}),n}export function hasBothLimitKinds(e){return I(e,"test").length>0&&I(e,"spec").length>0}export function limitLines(e,o="both"){if(o==="none")return[];const t=I(e,"test"),i=I(e,"spec"),n=o==="test"?t:o==="spec"?i:[...t,...i];return[...n.length?n:[...t,...i],...I(e,"pat"),...I(e,"whatif")]}export function limitExtent(e){if(!e.length)return{};const o=e.map(t=>t.value);return{lo:me(o),hi:he(o)}}export function placeClearOf(e,o,t,i=6){const n=l=>e.some(s=>l.x0<s.x1&&l.x1>s.x0&&l.y0<s.y1&&l.y1>s.y0);let r=o;for(let l=0;l<i&&n(r);l++)r={x0:r.x0,x1:r.x1,y0:r.y0+t,y1:r.y1+t};return e.push(r),r}export function stackLabelRows(e,o=4){const t=e.map((r,l)=>({...r,i:l})).sort((r,l)=>r.start-l.start),i=[],n=new Array(e.length).fill(0);for(const r of t){let l=i.findIndex(s=>r.start>=s+o);l===-1?(l=i.length,i.push(r.end)):i[l]=r.end,n[r.i]=l}return n}export function fillTextOnHalo(e,o,t,i,n){if(n){const r=e.measureText(o),l=2,s=e.fillStyle;e.fillStyle=n,e.fillRect(t-r.actualBoundingBoxLeft-l,i-r.actualBoundingBoxAscent-l,r.actualBoundingBoxLeft+r.actualBoundingBoxRight+2*l,r.actualBoundingBoxAscent+r.actualBoundingBoxDescent+2*l),e.fillStyle=s}e.fillText(o,t,i)}export function strokeLimitLine(e,o,t,i,n,r,l){e.save(),e.strokeStyle=t,e.lineWidth=1,e.setLineDash(LIMIT_DASH[o.kind]),e.beginPath(),e.moveTo(i,n),e.lineTo(r,l),e.stroke(),e.restore()}export function makeLimitsSelect(e,o,t=document){return makeLabeledSelect("Limits:",LIMITS_SHOWN_OPTIONS,e,i=>o(i),{maxWidth:"170px",hook:"limits-shown",ownerDocument:t})}export{K as robustFence};export function shouldIncludeLimitsByDefault(e,o,t,i,n=1/3){if(t===void 0&&i===void 0||!Number.isFinite(e)||!Number.isFinite(o))return!1;const r=Math.min(e,t??e),s=Math.max(o,i??o)-r;if(s<=0)return!0;const a=o-e;return a===0?!0:a/s>=n}export function resolveAxisRange(e){const{dataMin:o,dataMax:t,limits:i=[],includeLimits:n,clipOutliers:r,values:l}=e;let s=o,a=t,d=0;if(r&&l?.length){const u=K(l);if(u){const p=Math.max(s,u.lo),f=Math.min(a,u.hi);f>p&&(d=l.filter(x=>Number.isFinite(x)&&(x<p||x>f)).length,s=p,a=f)}}if(n)for(const u of i)s=Math.min(s,u.value),a=Math.max(a,u.value);s===a&&(s-=1,a+=1);const c=[];for(const u of i)u.value<s?c.push({value:u.value,label:u.label,side:"lo"}):u.value>a&&c.push({value:u.value,label:u.label,side:"hi"});return{lo:s,hi:a,offAxis:c,clippedCount:d}}export function limitLabelSide(e,o,t,i,n,r=3){const l=n?-1:1;return(l<0?e-r-o>=t:e+r+o<=i)?l:-l}export function drawOffAxisLimits(e,o,t,i,n,r,l,s){if(!o.length)return;e.save(),e.fillStyle=n,e.font=`${D(-1)}px system-ui, sans-serif`;const a={lo:0,hi:0},d=D(-1)+2;for(const{value:c,label:u,side:p}of o){const f=a[p]++*d,x=i==="horizontal"?p==="lo"?"\u2190":"\u2192":p==="lo"?"\u2193":"\u2191",b=p==="lo"?`${x} ${u} ${r(c)}`:`${u} ${r(c)} ${x}`,m=e.measureText(b).width;if(i==="horizontal"){const C=p==="lo"?t.left+2:t.right-2-m,y={x0:C,x1:C+m,y0:t.top+2+f,y1:t.top+2+f+d},S=s?placeClearOf(s,y,d):y;e.textBaseline="top",e.textAlign=p==="lo"?"left":"right",fillTextOnHalo(e,b,p==="lo"?t.left+2:t.right-2,S.y0,l)}else{const C=p==="lo"?t.bottom-2-f-d:t.top+2+f,y={x0:t.left+4,x1:t.left+4+m,y0:C,y1:C+d},S=s?placeClearOf(s,y,p==="lo"?-d:d):y;e.textBaseline="top",e.textAlign="left",fillTextOnHalo(e,b,t.left+4,S.y0,l)}}e.restore()}
1
+ import{SHADOW as te,LEADING as me,wireTooltip as z,wireControlHover as P,controlStyle as X,SPACE as C,RADIUS as B,fontPx as q,FONT as E,CLR as g,Z_BASE as he,menuLayerFor as ge,wireListNavigation as be,MENU_SEARCH_THRESHOLD as ne,makeMenuSearchBox as xe,markMenuTrigger as V,markNoPrint as G,openCommandMenu as ye,saveImageBlob as we,openReparentedModal as Ce}from"../toolbar.js";import{ICONS as oe}from"../icons.js";import{openGuideAt as ve}from"../guideWindow.js";import{minOf as Se,maxOf as ke}from"../../core/utils.js";import{robustFence as ie}from"../../stats/math.js";import{fmt as Ae,fmtColorbarAxis as Le,nameStatesUnit as Ee}from"../../renderer/fmt.js";import{isTestPinned as $e,toggleTestPinned as Be}from"../pinnedTests.js";import{markedTestLabel as Te,DERIVED_LANE_PAD as Oe}from"../../renderer/testLabel.js";export function openChartExpandModal(e,o,t={}){for(const a of e.querySelectorAll('div[style*="position: absolute"]'))a.style.display==="block"&&a.style.pointerEvents==="none"&&(a.style.display="none");const i=e.getAttribute("style")??"",n=e.dataset.wmapChartGrow??"plot";Object.assign(e.style,{flex:"1",minHeight:"0",alignSelf:"stretch",border:"none",borderRadius:"0"}),e.dataset.wmapExpanded="1";const r=e.querySelector(":scope > div > [data-wmap-card-expand]"),l=a=>{r&&(r.style.display=a?"flex":"none")};l(!1);const s=Ce([e],{title:o,anchor:t.anchor,ownerDocument:e.ownerDocument,boxSize:Re[n],onClosed:()=>{delete e.dataset.wmapExpanded,e.setAttribute("style",i),l(!0),t.onClosed?.()}});if(!s)return delete e.dataset.wmapExpanded,e.setAttribute("style",i),l(!0),null;if(n==="rows"){const a=()=>{const c=Number(e.dataset.wmapChartFullH);if(!c)return;const d=s.box.offsetHeight-s.contentWrap.clientHeight;s.setNaturalHeight(`min(90vh, ${Math.ceil(d+c)}px)`)};a(),(e.ownerDocument.defaultView??window).requestAnimationFrame(a)}return s}const Re={plot:{width:"min(94vw, 1100px)",height:"min(90vh, 760px)"},rows:{width:"min(94vw, 960px)",height:"min(90vh, 700px)"},square:{width:"min(94vw, 820px)",height:"min(90vh, 860px)"}};export const GRID_ALPHA=.4;export function withAlpha(e,o){const t=e.trim();let i,n,r,l=1;const s=t.match(/^#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i),a=t.match(/^rgba?\(\s*([\d.]+)[\s,]+([\d.]+)[\s,]+([\d.]+)(?:\s*[,/]\s*([\d.]+%?))?\s*\)$/i);if(s){const c=s[1].length===3?s[1].split("").map(d=>d+d).join(""):s[1];[i,n,r]=[0,2,4].map(d=>parseInt(c.slice(d,d+2),16)),c.length===8&&(l=parseInt(c.slice(6,8),16)/255)}else if(a)[i,n,r]=[a[1],a[2],a[3]].map(Number),a[4]!==void 0&&(l=a[4].endsWith("%")?parseFloat(a[4])/100:Number(a[4]));else return e;return`rgba(${i}, ${n}, ${r}, ${+(l*o).toFixed(3)})`}const Pe={text:"#333",textMuted:"#66788a",border:"rgba(0,0,0,0.12)",bg:"#fff",bgHover:"#edf0f8",track:"#fafbfc",warnBorder:"#f0c040",accent:"#1a66cc",limitLine:"#b45309",alert:"#7a1c1c"},re={text:"text",textMuted:"text-muted",border:"border",bg:"surface",bgHover:"bg-hover",track:"panel-bg",warnBorder:"warn-border",accent:"icon-active",limitLine:"warn-text",alert:"err-text"};export function resolveChartCanvasColors(e){const o=getComputedStyle(e),t={};for(const i of Object.keys(re)){const n=o.getPropertyValue(`--wmap-${re[i]}`).trim();t[i]=n||Pe[i]}return t.grid=withAlpha(t.border,GRID_ALPHA),t}export const PADDING=12,VALUE_WIDTH=100;export function observeResize(e,o){const t=e.ownerDocument.defaultView??window;let i=0;const n=new t.ResizeObserver(()=>{i||(i=t.requestAnimationFrame(()=>{i=0,o()}))});return n.observe(e),{disconnect:()=>{i&&t.cancelAnimationFrame(i),i=0,n.disconnect()}}}export function growCardToFitContent(e,o,t){const i=`${K(e,o)+t}px`;e.style.minHeight!==i&&(e.style.minHeight=i)}function K(e,o){const t=e.ownerDocument.defaultView??window,i=t.getComputedStyle(e);let n=0;for(const r of Array.from(e.children)){if(r===o)continue;const l=r,s=t.getComputedStyle(l);s.display==="none"||s.position==="absolute"||s.position==="fixed"||(n+=l.offsetHeight+(parseFloat(s.marginTop)||0)+(parseFloat(s.marginBottom)||0))}return i.boxSizing==="border-box"&&(n+=(parseFloat(i.paddingTop)||0)+(parseFloat(i.paddingBottom)||0)+(parseFloat(i.borderTopWidth)||0)+(parseFloat(i.borderBottomWidth)||0)),n}function le(e,o){const t=e.ownerDocument.defaultView??window;let i=0;for(const n of Array.from(e.children)){if(n===o)continue;const r=n,l=t.getComputedStyle(r);l.display==="none"||l.position==="absolute"||l.position==="fixed"||(i+=r.offsetHeight+(parseFloat(l.marginTop)||0)+(parseFloat(l.marginBottom)||0))}return i}export const WAFER_MENU_HINT="<br><em>right-click to chart this wafer</em>";export function populationPhrase(e,o,t){const i=e.toLocaleString(),n=e===1?"die":"dies";return t?e===o?`${i} ${n} ${t}`:`${i} of ${o.toLocaleString()} dies ${t} (partial and edge-excluded dies left out)`:`${i} ${n}`}export function setChartGrow(e,o){e.dataset.wmapChartGrow=o}export function isExpandedCard(e){return e.dataset.wmapExpanded==="1"}export function bodyRoom(e,o,t){const n=(e.ownerDocument.defaultView??window).getComputedStyle(e),r=e.clientHeight-(parseFloat(n.paddingTop)||0)-(parseFloat(n.paddingBottom)||0),l=n.boxSizing==="border-box"?(parseFloat(n.paddingTop)||0)+(parseFloat(n.paddingBottom)||0)+(parseFloat(n.borderTopWidth)||0)+(parseFloat(n.borderBottomWidth)||0):0;return r-(K(e,o)-l)-(t?le(o,t):0)}export function fitRowsHeight(e,o,t,i,n=0){if(growCardToFitContent(e,o,n+t),e.dataset.wmapChartFullH=String(Math.ceil(K(e,o)+n+i)),!isExpandedCard(e))return t;const r=bodyRoom(e,o)-n;return Math.max(t,Math.min(i,Math.floor(r)))}export function chartFillHeight(e,o,t,i){const n=le(o,t);return growCardToFitContent(e,o,n+i),Math.max(i,o.clientHeight-n)}export function chartDpr(e){return(e.ownerDocument.defaultView??window).devicePixelRatio||1}export function prepareCanvas(e,o,t,i){const n=chartDpr(e);e.width=Math.max(1,Math.floor(t*n)),e.height=Math.max(1,Math.floor(i*n)),e.style.width=`${t}px`,e.style.height=`${i}px`;const r=e.getContext("2d");return r?(r.setTransform(n,0,0,n,0,0),r.clearRect(0,0,t,i),r.font=`${q(-1)}px system-ui, sans-serif`,r.textBaseline="middle",{ctx:r,theme:resolveChartCanvasColors(o)}):null}export function applyCanvasFlow(e,o=0){let t;if(typeof o=="number")t=o;else{const i=(o.ownerDocument.defaultView??window).getComputedStyle(o);t=o.offsetTop+o.offsetHeight+(parseFloat(i.marginBottom)||0)}e.style.position="absolute",e.style.left="0",e.style.right="0",e.style.top=`${t}px`,e.style.bottom="0"}export function formatValue(e){return Number.isFinite(e)?Number.isInteger(e)?`${e}`:Ae(e,void 0,"engineering"):"\u2014"}function Me(e,o){const t=`${o} (`;return e.startsWith(t)&&e.endsWith(")")?e.slice(t.length,-1):""}export function makeAxisFormat(e,o,t,i){if(!o&&t===void 0)return{tick:formatValue,tickWithUnit:formatValue,unitLabel:""};const n=Ee(i,o),{tickFmt:r,axisLabel:l,scaledUnit:s}=Le(e,n?i:null,o,"engineering",t);return{tick:r,tickWithUnit:s?a=>`${r(a)} ${s}`:r,unitLabel:n?Me(l,i):l}}const Ie=8;export const VERTICAL_TICK_SPACING_PX=28;export function horizontalTickSpacing(e,o,t){return(i,n)=>{const r=makeAxisFormat(o,t,i).tick;return n.reduce((l,s)=>Math.max(l,e.measureText(r(s)).width),0)+Ie}}export function drawAxisUnit(e,o,t,i,n){const r={textAlign:e.textAlign,textBaseline:e.textBaseline,fillStyle:e.fillStyle,font:e.font};e.font=`${q(-1)}px system-ui, sans-serif`,e.textAlign="left",e.textBaseline="middle",e.fillStyle=n,e.fillText(`(${o})`,t,i),Object.assign(e,r)}export function captionText(e){return e.split(" \xB7 ").map(o=>o.replace(/[\s·]+$/,"").trim()).filter(o=>o&&!/\b(click|clicks|drag|hover|right-click)\b/i.test(o)&&!/\(.*(click|drag).*\)/i.test(o)).join(" \xB7 ")}const U=(e,o)=>{for(let t=e;t&&t!==o.parentElement;t=t.parentElement)if(t.style.display==="none")return!1;return!0},Fe=/\s*[▾▼]\s*$/,Y=new WeakMap;export function describeCard(e){const o=[],t=e.querySelector("[data-wmap-controls]");if(t){for(const l of t.querySelectorAll("button[aria-haspopup]")){if(!U(l,t))continue;const s=(l.textContent??"").replace(Fe,"").trim();if(!s)continue;const a=l.closest("label"),d=(a?(a.textContent??"").replace(l.textContent??"","").replace(/[:\s]+$/,"").trim():"")||l.getAttribute("aria-label")||"";o.push(d&&d!==s?`${d}: ${s}`:s)}for(const l of t.querySelectorAll('[role="radiogroup"]')){if(!U(l,t))continue;const a=l.querySelector("input:checked")?.closest("label")?.textContent?.trim();a&&o.push(a)}for(const l of t.querySelectorAll('input[type="checkbox"]:checked')){if(!U(l,t))continue;const s=l.closest("label")?.textContent?.trim();s&&o.push(s)}}const i=[];for(const l of e.querySelectorAll("[data-wmap-caption]")){if(!U(l,e))continue;const s=captionText((l.textContent??"").replace(/\s+/g," ").trim());s&&i.push(s)}const n=[];for(const l of e.querySelectorAll("button[aria-pressed]")){const s=l.querySelector("span"),a=s?.style.backgroundColor||s?.style.borderColor,c=(l.textContent??"").trim();c&&a&&a!=="transparent"&&n.push({label:c,color:a})}for(const l of e.querySelectorAll("[data-wmap-legend] > span")){const s=l.firstElementChild,a=s?.style.backgroundColor||s?.style.borderColor,c=(l.textContent??"").trim();c&&a&&a!=="transparent"&&n.push({label:c,color:a})}const r=Y.get(e)?.();return r&&(r.controls&&o.push(...r.controls),r.caption!==void 0&&(i.length=0,i.push(...typeof r.caption=="string"?[r.caption]:r.caption)),r.legend&&(n.length=0,n.push(...r.legend))),{controls:o,captions:i,legend:n}}function De(e){const o=describeCard(e),t=Y.get(e)?.();return{controls:o.controls,caption:o.captions,legend:o.legend.length?o.legend:void 0,colorbar:t?.colorbar}}function se(e){for(const o of e.querySelectorAll("[data-wmap-chart-card]")){const t=o.querySelector(":scope > [data-wmap-print-only]");if(!t)continue;const i=describeCard(o);t.replaceChildren();const n=[i.controls.length?i.controls.join(" \xB7 "):"",...i.captions].filter(Boolean);for(const r of n){const l=e.createElement("div");l.textContent=r,t.appendChild(l)}for(const r of o.querySelectorAll("[data-wmap-caption]"))r.setAttribute("data-wmap-noprint","1")}}const ae=new WeakSet;function He(e){if(ae.has(e))return;ae.add(e);const o=e.createElement("style");o.textContent="@media print{[data-wmap-print-only]{display:block!important}}",e.head.appendChild(o);const t=e.defaultView;t?.addEventListener("beforeprint",()=>se(e));try{t?.matchMedia?.("print").addEventListener?.("change",i=>{i.matches&&se(e)})}catch{}}function je(e){const o=e.ownerDocument.defaultView;for(let t=e;t&&o;t=t.parentElement){const i=o.getComputedStyle(t).backgroundColor;if(i&&i!=="transparent"&&!/^rgba\(.*,\s*0\)$/.test(i))return i}return"#ffffff"}export function composeChartPng(e,o){const t=e.ownerDocument,i=t.createElement("canvas"),n=Math.max(1,e.width/(e.clientWidth||e.width)),r=e.width,l=t.createElement("canvas").getContext("2d"),s=12*n,a=(m,f="400")=>`${f} ${m*n}px system-ui, -apple-system, "Segoe UI", sans-serif`,c=(m,f)=>l?(l.font=f,l.measureText(m).width):m.length*7*n,d=[];let p=0;if(o){p=s,d.push({kind:"text",text:o.title,x:s,y:p+14*n,font:a(16,"600"),alpha:1}),p+=24*n;const m=o.decor,f=[];m?.controls?.length&&f.push({text:m.controls.join(" \xB7 "),alpha:1});for(const w of m?.caption===void 0?[]:typeof m.caption=="string"?[m.caption]:m.caption)f.push({text:w,alpha:.75});const x=a(12);for(const{text:w,alpha:y}of f){let h="";for(const k of w.split(" ")){const T=h?`${h} ${k}`:k;h&&c(T,x)>r-2*s?(d.push({kind:"text",text:h,x:s,y:p+11*n,font:x,alpha:y}),p+=17*n,h=k):h=T}h&&(d.push({kind:"text",text:h,x:s,y:p+11*n,font:x,alpha:y}),p+=17*n)}if(m?.legend?.length){p+=4*n;const w=a(12);let y=s;for(const h of m.legend){const k=14*n+c(h.label,w)+14*n;y>s&&y+k>r-s&&(y=s,p+=18*n),d.push({kind:"dot",x:y+5*n,y:p+7*n,r:5*n,color:h.color}),d.push({kind:"text",text:h.label,x:y+14*n,y:p+11*n,font:w,alpha:1}),y+=k}p+=20*n}if(m?.colorbar){p+=4*n;const w=a(12),y=m.colorbar;let h=s;d.push({kind:"text",text:y.label,x:h,y:p+10*n,font:w,alpha:1}),h+=c(y.label,w)+10*n,d.push({kind:"text",text:y.lo,x:h,y:p+10*n,font:w,alpha:.75}),h+=c(y.lo,w)+6*n,d.push({kind:"strip",x:h,y:p+1*n,w:200*n,h:10*n,color:y.color}),h+=206*n,d.push({kind:"text",text:y.hi,x:h,y:p+10*n,font:w,alpha:.75}),p+=20*n}p+=6*n}i.width=r,i.height=Math.ceil(e.height+p);const u=i.getContext("2d");if(u.fillStyle=o?je(o.card):"#ffffff",u.fillRect(0,0,i.width,i.height),o){const m=t.defaultView,f=m&&m.getComputedStyle(o.card).color||"#222222";u.textBaseline="alphabetic";for(const x of d)if(x.kind==="text")u.font=x.font,u.fillStyle=f,u.globalAlpha=x.alpha,u.fillText(x.text,x.x,x.y),u.globalAlpha=1;else if(x.kind==="dot")u.fillStyle=x.color,u.beginPath(),u.arc(x.x,x.y,x.r,0,Math.PI*2),u.fill();else for(let w=0;w<x.w;w++)u.fillStyle=x.color(w/Math.max(1,x.w-1)),u.fillRect(x.x+w,x.y,1,x.h)}return u.drawImage(e,0,p),i}export function saveCanvasPng(e,o,t,i){composeChartPng(e,i).toBlob(n=>{n&&we(n,o,t)},"image/png")}const ce="10px";export function chartSwatchCss(e,o="solid"){return["display:inline-block",`width:${ce}`,`height:${ce}`,`border-radius:${B.pill}`,`background:${o==="outline"?"transparent":e}`,`border:1px ${o==="outline"?"dashed":"solid"} ${e}`,"box-sizing:border-box","flex-shrink:0"].join(";")}const Ne="0.35";export function makeSeriesLegendItem(e,o,t=document){const i=t.createElement("button");i.type="button",Object.assign(i.style,{display:"inline-flex",alignItems:"center",gap:C.xs,padding:`${C.xs} ${C.md}`,borderRadius:B.pill,border:`1px solid ${g.menuBorder}`,background:"none",cursor:"pointer",fontSize:E.body,color:g.text,whiteSpace:"nowrap"}),P(i,"bare");const n=t.createElement("span");return n.style.cssText=chartSwatchCss(o),i.append(n,t.createTextNode(e)),{el:i,setState({selected:r,dimmed:l}){i.style.borderColor=r?g.iconActive:g.menuBorder,i.style.fontWeight=r?"600":"400",i.style.opacity=l?Ne:"1",i.setAttribute("aria-pressed",r?"true":"false")}}}export function cardFrameStyle(){return{background:g.menuBg,border:`1px solid ${g.menuBorder}`,borderRadius:B.container,padding:C.xl,fontVariantNumeric:"tabular-nums"}}function de(e){Object.assign(e.style,{...X("outlined"),color:g.label,padding:"0",width:"22px",height:"22px",lineHeight:me.none,flexShrink:"0",display:"flex",alignItems:"center",justifyContent:"center"}),P(e)}export function cardShell(e,o,t=document,i={}){const n=t.createElement("div");n.dataset.wmapChartCard="1",n.dataset.wmapChartTitle=e,Object.assign(n.style,{display:"flex",flexDirection:"column",...cardFrameStyle(),minWidth:"0",minHeight:"0",flex:"1 1 0",position:"relative"});const r=n.ownerDocument.createElement("div");Object.assign(r.style,{display:"flex",alignItems:"center",gap:C.sm,paddingBottom:"6px",marginBottom:C.md,borderBottom:`1px solid ${g.menuBorder}`});const l=n.ownerDocument.createElement("div");l.textContent=e,Object.assign(l.style,{color:g.value,fontSize:E.heading,fontWeight:"600",flex:"1"}),r.appendChild(l);const s=makeTooltip(n),a=n.ownerDocument.createElement("button");a.type="button",a.setAttribute("aria-label","Expand"),a.innerHTML=oe.expand,a.dataset.wmapCardExpand="1",de(a),attachChartTip(a,n,s,"Expand"),G(a),a.addEventListener("click",()=>{isExpandedCard(n)||openChartExpandModal(n,l.textContent??e)}),r.appendChild(a);const c=n.ownerDocument.createElement("button");c.type="button",c.setAttribute("aria-label","Chart actions"),c.innerHTML=oe.more,c.dataset.wmapCardMenu="1",de(c),attachChartTip(c,n,s,"Chart actions"),V(c,!1),G(c),r.appendChild(c);const d=n.ownerDocument.createElement("div");d.dataset.wmapCardAbout="1",d.setAttribute("role","note"),Object.assign(d.style,{display:"none",color:g.label,fontSize:E.body,marginBottom:C.md}),G(d);let p;const u=v=>{d.textContent=v?p?.text??"":"",d.style.display=v?"":"none"};let m,f;const x=()=>{const v=m?m():n.querySelector("canvas");v&&saveCanvasPng(v,l.textContent||e,o,{card:n,title:l.textContent||e,decor:De(n)})},w=()=>{const v=[],H=(S,j,N)=>({label:S,active:!1,action:!0,enabled:!N,disabledHint:N,onClick:()=>{y?.(),j()}});i.png!==!1&&(m||n.querySelector("canvas"))&&v.push(H("Save as PNG",x));for(const S of f?.()??[])v.push(H(S.label,S.onClick,S.disabledHint));if(p){const S=d.style.display!=="none";v.push({label:`About this ${p.noun}`,active:S,onClick:()=>{y?.(),u(!S)}})}return v};let y;c.addEventListener("click",()=>{if(c.getAttribute("aria-expanded")==="true"){y?.();return}const v=w();v.length!==0&&(y=ye(c.getBoundingClientRect(),c,v,`${l.textContent||e}: chart actions`,{trigger:c,hook:"wmapCardMenuList"}))}),n.appendChild(r),n.appendChild(d);const h=n.ownerDocument.createElement("div");h.dataset.wmapPrintOnly="1",Object.assign(h.style,{display:"none",color:g.label,fontSize:E.body,marginBottom:C.sm}),n.appendChild(h),He(n.ownerDocument);const k=n.ownerDocument.createElement("div");k.dataset.wmapControls="1",Object.assign(k.style,{display:"flex",gap:C.sm,marginBottom:C.md,flexWrap:"wrap",alignItems:"center"}),G(k),n.appendChild(k);const T=n.ownerDocument.createElement("div");return Object.assign(T.style,{overflowX:"hidden",overflowY:"hidden",minHeight:"0",flex:"1",position:"relative"}),n.appendChild(T),{card:n,heading:l,controlsRow:k,body:T,setPngDecor:v=>{Y.set(n,v)},setPngCanvas:v=>{m=v},setAbout:v=>{p=v,u(!!v&&d.style.display!=="none")},setMenuRows:v=>{f=v}}}export function guideCite(e,o,t="How to read this"){const i=e.createElement("span");return i.append(`${t}: `,pe(e,o)," in the user guide"),i}function pe(e,o){const t=e.createElement("button");return t.type="button",t.textContent=o.title,t.dataset.wmapGuideLink=o.id,Object.assign(t.style,{border:"none",background:"none",padding:"0",font:"inherit",color:g.iconActive,textDecoration:"underline",cursor:"pointer"}),P(t),t.addEventListener("click",()=>ve(o.id,t)),t}export function appendGuideCites(e,o){if(o.length===0)return;const t=e.ownerDocument;e.append(" \xB7 how to read this: "),o.forEach((i,n)=>{n>0&&e.append(n===o.length-1?" and ":", "),e.append(pe(t,i))}),e.append(" in the user guide")}export function inputStyle(){return{background:g.menuBg,color:g.text,border:`1px solid ${g.menuBorder}`,borderRadius:B.control,padding:`${C.xs} ${C.sm}`,fontSize:E.body,fontFamily:E.family,boxSizing:"border-box",minWidth:"0"}}export function makeSegmented(e,o,t,i=document,n=!1){const r=i.createElement("div");r.setAttribute("role","radiogroup"),Object.assign(r.style,{display:"inline-flex",flexWrap:"wrap",maxWidth:"100%",padding:"1px 0 0 1px"});const l=e.length-1,s=`seg-${Math.random().toString(36).slice(2,9)}`,a=[];return e.forEach(([c,d,p],u)=>{const m=i.createElement("label");p&&z(m,p),Object.assign(m.style,{display:"inline-flex",alignItems:"center",fontSize:E.body,padding:n?"1px 6px":"3px 10px",cursor:"pointer",userSelect:"none",border:`1px solid ${g.menuBorder}`,margin:"-1px 0 0 -1px",borderTopLeftRadius:u===0?B.control:"0",borderBottomLeftRadius:u===0?B.control:"0",borderTopRightRadius:u===l?B.control:"0",borderBottomRightRadius:u===l?B.control:"0"}),P(m,"bare");const f=i.createElement("input");f.type="radio",f.name=s,f.value=c,f.checked=c===o,Object.assign(f.style,{position:"absolute",opacity:"0",width:"0",height:"0"});const x=()=>{m.style.background=f.checked?g.bgActive:g.menuBg,m.style.color=f.checked?g.iconActive:g.text,m.dataset.on=f.checked?"true":"false"};a.push(x),x(),f.addEventListener("change",()=>{if(f.checked){for(const w of a)w();t(c)}}),m.append(f,i.createTextNode(d)),r.appendChild(m)}),r}const We=360;export function firstRowsToggle(e,o){let t=!1;const i=e.createElement("button");i.type="button",Object.assign(i.style,{...X("outlined"),marginTop:C.sm}),P(i);const n=()=>{o.fill(t),Object.assign(o.scroller.style,{maxHeight:t?`${We}px`:"",overflowY:t?"auto":""}),i.textContent=t?`Show the first ${o.noun}`:`Show all ${o.total} ${o.noun}`,i.style.display=o.total>o.first?"":"none"};return i.addEventListener("click",()=>{t=!t,n()}),n(),i}export function makeBackButton(e,o=document){const t=o.createElement("button");return t.type="button",t.textContent="\u2190 Back",Object.assign(t.style,{...X("outlined"),background:g.menuBg,color:g.label}),P(t),t.addEventListener("click",e),t}export function renderEmptyState(e,o,t){const i=e.ownerDocument.createElement("div");i.textContent=o,Object.assign(i.style,{color:g.label,fontSize:E.body,padding:"8px 0"}),t&&Object.assign(i.style,t),e.appendChild(i)}export function makeListSelect(e,o,t,i={}){const{maxWidth:n="200px",ownerDocument:r=document,ariaLabel:l,emptyText:s,searchPlaceholder:a="Filter\u2026",hook:c}=i,d=()=>typeof e=="function"?e():e;let p=d(),u=o;const m=S=>p.find(j=>j.value===S)?.label??"",f=r.createElement("button");f.type="button",c&&(f.dataset.wmapSelect=c),l&&f.setAttribute("aria-label",l),Object.assign(f.style,{fontSize:E.body,padding:`${C.xxs} ${C.sm}`,background:g.menuBg,color:g.text,border:`1px solid ${g.menuBorder}`,borderRadius:B.control,maxWidth:n,textAlign:"left",cursor:"pointer",display:"inline-flex",alignItems:"center",gap:C.sm,justifyContent:"space-between"}),P(f),V(f,!1);const x=r.createElement("span");Object.assign(x.style,{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"});const w=r.createElement("span");w.textContent="\u25BE",w.style.flex="0 0 auto",f.append(x,w);const y=()=>{x.textContent=p.length===0?s??"(none)":m(u)||s||"(none)"};if(y(),p.length===0)return f.disabled=!0,f.style.opacity="0.6",f.style.cursor="default",Object.defineProperty(f,"value",{get:()=>u,set:S=>{u=S,y()}});let h=null;const k=()=>{h&&(h.remove(),h=null,V(f,!1))},T=()=>{k(),f.focus()};function v(){p=d();const S=f.getBoundingClientRect(),j=r.defaultView??window,N=Math.max(S.width,220),ue=Math.min(S.left,Math.max(4,(j.innerWidth??1/0)-N-4));h=r.createElement("div"),h.setAttribute("role","listbox"),h.setAttribute("aria-label",l??"Options"),Object.assign(h.style,{position:"fixed",top:`${S.bottom+4}px`,left:`${ue}px`,background:g.menuBg,border:`1px solid ${g.menuBorder}`,borderRadius:B.control,boxShadow:te.menu,zIndex:he,minWidth:`${N}px`,maxHeight:"320px",overflowY:"auto",padding:"4px 0",pointerEvents:"auto"});const M=[],_=()=>M.filter(b=>b.row.style.display!=="none").map(b=>b.row),W=[],fe=()=>{for(const b of W)b.el.style.display=M.slice(b.first,b.last+1).some(L=>L.row.style.display!=="none")?"":"none"};if(p.length>ne){const b=xe(L=>{for(const A of M)A.row.style.display=A.label.includes(L)?"":"none";fe()},a,r,_);Object.assign(b.style,{position:"sticky",top:"0",zIndex:"1",background:g.menuBg}),b.addEventListener("keydown",L=>{if(L.key==="Escape"){L.preventDefault(),T();return}L.key==="ArrowDown"&&(L.preventDefault(),_()[0]?.focus())}),h.appendChild(b)}let Z;for(const b of p){if(b.group!==void 0&&b.group!==Z){const $=r.createElement("div");$.textContent=b.group,$.setAttribute("role","presentation"),Object.assign($.style,{padding:`${C.sm} ${C.xl} ${C.xxs}`,fontSize:E.sub,color:g.label,fontWeight:"600"}),h.appendChild($),W.push({el:$,first:M.length,last:M.length})}Z=b.group;const L=b.value===u,A=r.createElement("div"),J=r.createElement("span");if(J.textContent=b.disabled?`${b.label} \u2014 ${b.disabled}`:b.label,A.appendChild(J),A.setAttribute("role","option"),A.setAttribute("aria-selected",L?"true":"false"),b.disabled&&A.setAttribute("aria-disabled","true"),A.tabIndex=-1,Object.assign(A.style,{padding:`${C.sm} ${C.xl}`,fontSize:E.body,cursor:b.disabled?"default":"pointer",color:b.disabled?g.label:L?g.iconActive:g.text,fontWeight:L?"700":"400",opacity:b.disabled?"0.7":"",background:L?g.menuActive:"transparent",whiteSpace:"nowrap",...b.pin?{display:"flex",alignItems:"center",justifyContent:"space-between",gap:C.xl}:{}}),b.pin){const $=b.pin;A.setAttribute("aria-keyshortcuts","P");const O=r.createElement("span"),Q="http://www.w3.org/2000/svg",I=r.createElementNS(Q,"svg");I.setAttribute("viewBox","0 0 24 24"),I.setAttribute("width","14"),I.setAttribute("height","14"),I.setAttribute("aria-hidden","true");const F=r.createElementNS(Q,"path");F.setAttribute("d","M12 2.5l2.9 6.2 6.8.8-5 4.7 1.3 6.7L12 17.5 6 20.9l1.3-6.7-5-4.7 6.8-.8z"),F.setAttribute("fill",$.pinned?"currentColor":"none"),F.setAttribute("stroke","currentColor"),F.setAttribute("stroke-width","2"),F.setAttribute("stroke-linejoin","round"),I.appendChild(F),O.appendChild(I),O.dataset.wmapPin=$.pinned?"pinned":"unpinned",O.setAttribute("role","button"),O.setAttribute("aria-label",`${$.pinned?"Unpin":"Pin"} ${b.label} (or press P on the row)`),Object.assign(O.style,{cursor:"pointer",color:$.pinned?g.iconActive:g.label,flex:"0 0 auto",padding:`0 ${C.xs}`,display:"inline-flex",alignItems:"center"}),P(O,"bare"),z(O,$.pinned?"Unpin this test":"Pin this test to the top of every test list");const ee=R=>{R.preventDefault(),R.stopPropagation(),k(),$.toggle(),v()};O.addEventListener("click",ee),A.addEventListener("keydown",R=>{(R.key==="p"||R.key==="P")&&!R.ctrlKey&&!R.metaKey&&!R.altKey&&ee(R)}),A.appendChild(O)}A.addEventListener("mouseenter",()=>{!L&&!b.disabled&&(A.style.background=g.menuHover)}),A.addEventListener("mouseleave",()=>{L||(A.style.background="transparent")}),A.addEventListener("click",$=>{$.stopPropagation(),!b.disabled&&(u=b.value,y(),T(),t(b.value))}),h.appendChild(A),M.push({row:A,label:b.label.toLowerCase()}),W.length&&(W[W.length-1].last=M.length-1)}if(be(h,_,T),ge(f).appendChild(h),V(f,!0),p.length<=ne){const b=p.findIndex(L=>L.value===u);_()[b>=0?b:0]?.focus()}}f.addEventListener("click",S=>{if(S.stopPropagation(),h){k();return}v()});const H=S=>{if(!f.isConnected){r.removeEventListener("click",H);return}h&&!h.contains(S.target)&&!f.contains(S.target)&&k()};return r.addEventListener("click",H),Object.defineProperty(f,"value",{get:()=>u,set:S=>{u=S,y()}})}export function testOptionLabels(e){const o=e.some(t=>t.derived);return e.map(t=>(o&&!t.derived?Oe:"")+Te(t,t.testNumber))}export function makeTestSelect(e,o,t,i={}){const{maxWidth:n="200px",emptyText:r="No parametric tests",ownerDocument:l=document}=i,s=testOptionLabels(e);return makeListSelect(()=>{const c=e.map((u,m)=>({item:u,label:s[m],pinned:$e(u.testNumber)})),d=c.some(u=>u.pinned),p=(u,m)=>({value:String(u.item.testNumber),label:u.label,...m?{group:m}:{},pin:{pinned:u.pinned,toggle:()=>Be(u.item.testNumber)}});return d?[...c.filter(u=>u.pinned).map(u=>p(u,"Pinned")),...c.filter(u=>!u.pinned).map(u=>p(u,"All tests"))]:c.map(u=>p(u))},o!==null?String(o):"",c=>t(Number(c)),{maxWidth:n,ownerDocument:l,ariaLabel:"Test",emptyText:r,searchPlaceholder:"Filter tests\u2026"})}export function makeLinkedAxisPrefs(e,o,t,i=document){let n=o?.includeLimits,r=o?.clipOutliers??!1,l=o?.limits??"both";const s=()=>t({includeLimits:n,clipOutliers:r,limits:l});return{get:()=>({includeLimits:n,clipOutliers:r,limits:l}),sync(a,c,d=!1){e.innerHTML="",d&&e.appendChild(makeLimitsSelect(l,p=>{l=p,s()},i)),c&&e.appendChild(makeToggle("Axis includes limits",a,p=>{n=p,s()},i,"Widen the axis to show every limit, even where the data sits well clear of them")),e.appendChild(makeToggle("Clip outliers",r,p=>{r=p,s()},i,"Narrow the axis so a few extreme values do not flatten the rest. Statistics still use every value"))},set(a){const c=a.limits??"both";return a.includeLimits===n&&a.clipOutliers===r&&c===l?!1:(n=a.includeLimits,r=a.clipOutliers,l=c,!0)}}}export function makeLinkedTestSelect(e,o,t,i={}){let n=o;const r=makeTestSelect(e,n,l=>{l!==n&&(n=l,t(l))},i);return{el:r,get:()=>n,set(l){return n===l||!e.some(s=>s.testNumber===l)?!1:(n=l,r.value=String(l),!0)}}}export const ALL_GROUPS="\0all";export function makeLinkedGroupSelect(e,o,t,i,n={}){let r=t;const l=d=>d??ALL_GROUPS,s=d=>d===ALL_GROUPS?null:d,a=makeLabeledSelect(o,[{value:ALL_GROUPS,label:"All groups"},...e.map(d=>({value:d,label:d}))],l(r),d=>{const p=s(d);p!==r&&(r=p,i(p))},{...n,hook:"group-scope"}),c=a.querySelector('[data-wmap-select="group-scope"]');return{el:a,get:()=>r,set(d){return r===d||d!==null&&!e.includes(d)?!1:(r=d,c&&(c.value=l(d)),!0)}}}export function makeWaferSelect(e,o,t,i={}){const{maxWidth:n="160px",allLabel:r="All wafers",ownerDocument:l=document}=i,s="\0all";return makeListSelect([{value:s,label:r},...e.map((a,c)=>({value:String(c),label:a.label??`#${c}`}))],o===null?s:String(o),a=>t(a===s?null:Number(a)),{maxWidth:n,ownerDocument:l,ariaLabel:"Wafer",searchPlaceholder:"Filter wafers\u2026"})}export function makeToggle(e,o,t,i=document,n){const r=i.createElement("label");Object.assign(r.style,{display:"inline-flex",alignItems:"center",gap:C.xs,fontSize:E.body,color:g.label,cursor:"pointer",userSelect:"none"}),P(r,"bare");const l=i.createElement("input");return l.type="checkbox",l.checked=o,l.style.cssText="margin:0;cursor:pointer;",l.addEventListener("change",()=>t(l.checked)),r.append(l,i.createTextNode(e)),n&&z(r,n),r}export function makeLabeledSelect(e,o,t,i,n={}){const{maxWidth:r="160px",hook:l,ownerDocument:s=document,hint:a}=n,c=s.createElement("label");c.textContent=e,Object.assign(c.style,{color:g.label,fontSize:E.body,display:"flex",alignItems:"center",gap:C.xs});const d=makeListSelect(o,t,i,{maxWidth:r,ownerDocument:s,hook:l,ariaLabel:e.replace(/:\s*$/,"")});return c.appendChild(d),a&&z(c,a),c}export function makeChartGridWrap(e=document){const o=e.createElement("div");return o.dataset.wmapChartGrid="1",Object.assign(o.style,{display:"grid",gridTemplateColumns:"repeat(var(--wmap-insights-cols, auto-fit), minmax(var(--wmap-insights-min, 420px), 1fr))",gap:C.lg,flex:"0 0 auto"}),o}export function makeTooltip(e){const o=e.ownerDocument.createElement("div");return Object.assign(o.style,{position:"absolute",display:"none",pointerEvents:"none",zIndex:"50",background:"rgba(30, 32, 40, 0.93)",color:"#f0f0f2",border:"1px solid rgba(255,255,255,0.10)",borderRadius:B.control,padding:`${C.sm} ${C.xl}`,fontSize:E.sub,fontFamily:E.family,maxWidth:"320px",whiteSpace:"normal",overflowWrap:"break-word",boxShadow:te.menu}),e.appendChild(o),o}export function attachChartTip(e,o,t,i){e.removeAttribute("title"),e.textContent?.trim()||(e.ariaLabel=i),e.addEventListener("mouseenter",n=>{t.textContent=i,t.style.display="block",positionChartTooltip(t,o,n.clientX,n.clientY)}),e.addEventListener("mousemove",n=>{t.style.display==="block"&&positionChartTooltip(t,o,n.clientX,n.clientY)}),e.addEventListener("mouseleave",()=>{t.style.display="none"}),e.addEventListener("click",()=>{t.style.display="none"}),e.addEventListener("focus",()=>{t.textContent=i,t.style.display="block";const n=e.getBoundingClientRect();positionChartTooltip(t,o,n.left+n.width/2,n.bottom)}),e.addEventListener("blur",()=>{t.style.display="none"})}export function positionChartTooltip(e,o,t,i){const n=o.getBoundingClientRect(),r=14,l=4;e.style.left="0",e.style.top="0";const s=e.offsetWidth,a=e.offsetHeight;let c=t-n.left+r,d=i-n.top+r;c+s+l>n.width&&(c=t-n.left-r-s),d+a+l>n.height&&(d=i-n.top-r-a),c=Math.max(l,c),d=Math.max(l,d),e.style.left=`${c}px`,e.style.top=`${d}px`}export const LIMIT_LABEL={test:{lo:"Lo limit",hi:"Hi limit"},spec:{lo:"LSL",hi:"USL"},pat:{lo:"PAT lo",hi:"PAT hi"},whatif:{lo:"What-if lo",hi:"What-if hi"},ref:{lo:"",hi:""}},LIMIT_DASH={test:[3,3],spec:[10,4],pat:[1,3],whatif:[8,3,2,3],ref:[6,2,1,2]},LIMITS_SHOWN_OPTIONS=[{value:"both",label:"Test + spec"},{value:"test",label:"Test limits"},{value:"spec",label:"Spec limits (LSL/USL)"},{value:"none",label:"None"}];function D(e,o){const[t,i]=o==="test"?[e?.limitLow,e?.limitHigh]:o==="spec"?[e?.specLow,e?.specHigh]:o==="pat"?[e?.patLow,e?.patHigh]:o==="whatif"?[e?.whatIfLow,e?.whatIfHigh]:[void 0,void 0],n=[];return t!==void 0&&Number.isFinite(t)&&n.push({value:t,kind:o,end:"lo",label:LIMIT_LABEL[o].lo}),i!==void 0&&Number.isFinite(i)&&n.push({value:i,kind:o,end:"hi",label:LIMIT_LABEL[o].hi}),n}export function hasBothLimitKinds(e){return D(e,"test").length>0&&D(e,"spec").length>0}export function limitLines(e,o="both"){if(o==="none")return[];const t=D(e,"test"),i=D(e,"spec"),n=o==="test"?t:o==="spec"?i:[...t,...i];return[...n.length?n:[...t,...i],...D(e,"pat"),...D(e,"whatif")]}export function limitExtent(e){if(!e.length)return{};const o=e.map(t=>t.value);return{lo:Se(o),hi:ke(o)}}export function placeClearOf(e,o,t,i=6){const n=l=>e.some(s=>l.x0<s.x1&&l.x1>s.x0&&l.y0<s.y1&&l.y1>s.y0);let r=o;for(let l=0;l<i&&n(r);l++)r={x0:r.x0,x1:r.x1,y0:r.y0+t,y1:r.y1+t};return e.push(r),r}export function stackLabelRows(e,o=4){const t=e.map((r,l)=>({...r,i:l})).sort((r,l)=>r.start-l.start),i=[],n=new Array(e.length).fill(0);for(const r of t){let l=i.findIndex(s=>r.start>=s+o);l===-1?(l=i.length,i.push(r.end)):i[l]=r.end,n[r.i]=l}return n}export function fillTextOnHalo(e,o,t,i,n){if(n){const r=e.measureText(o),l=2,s=e.fillStyle;e.fillStyle=n,e.fillRect(t-r.actualBoundingBoxLeft-l,i-r.actualBoundingBoxAscent-l,r.actualBoundingBoxLeft+r.actualBoundingBoxRight+2*l,r.actualBoundingBoxAscent+r.actualBoundingBoxDescent+2*l),e.fillStyle=s}e.fillText(o,t,i)}export function strokeLimitLine(e,o,t,i,n,r,l){e.save(),e.strokeStyle=t,e.lineWidth=1,e.setLineDash(LIMIT_DASH[o.kind]),e.beginPath(),e.moveTo(i,n),e.lineTo(r,l),e.stroke(),e.restore()}export function makeLimitsSelect(e,o,t=document){return makeLabeledSelect("Limits:",LIMITS_SHOWN_OPTIONS,e,i=>o(i),{maxWidth:"170px",hook:"limits-shown",ownerDocument:t})}export{ie as robustFence};export function shouldIncludeLimitsByDefault(e,o,t,i,n=1/3){if(t===void 0&&i===void 0||!Number.isFinite(e)||!Number.isFinite(o))return!1;const r=Math.min(e,t??e),s=Math.max(o,i??o)-r;if(s<=0)return!0;const a=o-e;return a===0?!0:a/s>=n}export function resolveAxisRange(e){const{dataMin:o,dataMax:t,limits:i=[],includeLimits:n,clipOutliers:r,values:l}=e;let s=o,a=t,c=0;if(r&&l?.length){const p=ie(l);if(p){const u=Math.max(s,p.lo),m=Math.min(a,p.hi);m>u&&(c=l.filter(f=>Number.isFinite(f)&&(f<u||f>m)).length,s=u,a=m)}}if(n)for(const p of i)s=Math.min(s,p.value),a=Math.max(a,p.value);s===a&&(s-=1,a+=1);const d=[];for(const p of i)p.value<s?d.push({value:p.value,label:p.label,side:"lo"}):p.value>a&&d.push({value:p.value,label:p.label,side:"hi"});return{lo:s,hi:a,offAxis:d,clippedCount:c}}export function limitLabelSide(e,o,t,i,n,r=3){const l=n?-1:1;return(l<0?e-r-o>=t:e+r+o<=i)?l:-l}export function limitLabelPlacement(e,o,t,i,n,r,l=[],s=3){const a=r?-1:1;for(const c of[a,-a])for(const d of o){const p=t(d),u=c<0?e-s-p:e+s,m=c<0?e-s:e+s+p;if(!(u<i||m>n)&&!l.some(f=>f>u&&f<m))return{text:d,side:c}}return{text:o[0],side:limitLabelSide(e,t(o[0]),i,n,r,s)}}export function drawOffAxisLimits(e,o,t,i,n,r,l,s){if(!o.length)return;e.save(),e.fillStyle=n,e.font=`${q(-1)}px system-ui, sans-serif`;const a={lo:0,hi:0},c=q(-1)+2;for(const{value:d,label:p,side:u}of o){const m=a[u]++*c,f=i==="horizontal"?u==="lo"?"\u2190":"\u2192":u==="lo"?"\u2193":"\u2191",x=u==="lo"?`${f} ${p} ${r(d)}`:`${p} ${r(d)} ${f}`,w=e.measureText(x).width;if(i==="horizontal"){const y=u==="lo"?t.left+2:t.right-2-w,h={x0:y,x1:y+w,y0:t.top+2+m,y1:t.top+2+m+c},k=s?placeClearOf(s,h,c):h;e.textBaseline="top",e.textAlign=u==="lo"?"left":"right",fillTextOnHalo(e,x,u==="lo"?t.left+2:t.right-2,k.y0,l)}else{const y=u==="lo"?t.bottom-2-m-c:t.top+2+m,h={x0:t.left+4,x1:t.left+4+w,y0:y,y1:y+c},k=s?placeClearOf(s,h,u==="lo"?-c:c):h;e.textBaseline="top",e.textAlign="left",fillTextOnHalo(e,x,t.left+4,k.y0,l)}}e.restore()}
@@ -24,13 +24,6 @@ export interface PlotChartOptions {
24
24
  binColors?: BinColors;
25
25
  /** Right-click a mark that is one wafer (a wafer's bar or box, a point per wafer): that wafer's menu, as on the maps. */
26
26
  onWaferMenu?: WaferContextMenuHandler;
27
- /**
28
- * A legend click picks a group for the host to narrow to (an Insights section's group), in place of filtering this
29
- * plot alone: called with the group clicked, or null when it is `legendPicked` already (show every group again).
30
- */
31
- onLegendPick?: (group: string | null) => void;
32
- /** The group the host has narrowed to, shown selected in the legend. */
33
- legendPicked?: string | null;
34
27
  /** Click a point: open its wafer, on `testNumber` (the plot's own measurement) when it has one. Omit where there is no wafer to open. */
35
28
  onOpenWafer?: (item: number, testNumber?: number) => void;
36
29
  /** What a click on a bar or box that is not one wafer (or on a line's point) does, in the reader's words. Default `chart