@wafertools/wafermap 0.36.0 → 0.37.1

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 (158) hide show
  1. package/AGENTS.md +2 -2
  2. package/CHANGELOG.md +385 -0
  3. package/README.md +7 -7
  4. package/dist/packages/canvas-adapter/charts/capability.js +1 -1
  5. package/dist/packages/canvas-adapter/charts/cardAbout.d.ts +21 -0
  6. package/dist/packages/canvas-adapter/charts/cardAbout.js +1 -0
  7. package/dist/packages/canvas-adapter/charts/chartShell.d.ts +65 -12
  8. package/dist/packages/canvas-adapter/charts/chartShell.js +1 -1
  9. package/dist/packages/canvas-adapter/charts/commonality.d.ts +18 -0
  10. package/dist/packages/canvas-adapter/charts/commonality.js +1 -0
  11. package/dist/packages/canvas-adapter/charts/correlation.js +1 -1
  12. package/dist/packages/canvas-adapter/charts/groupComparison.d.ts +31 -0
  13. package/dist/packages/canvas-adapter/charts/groupComparison.js +1 -0
  14. package/dist/packages/canvas-adapter/charts/index.d.ts +0 -10
  15. package/dist/packages/canvas-adapter/charts/index.js +1 -1
  16. package/dist/packages/canvas-adapter/charts/patCard.d.ts +23 -0
  17. package/dist/packages/canvas-adapter/charts/patCard.js +1 -0
  18. package/dist/packages/canvas-adapter/charts/plotChart.d.ts +56 -2
  19. package/dist/packages/canvas-adapter/charts/plotChart.js +1 -1
  20. package/dist/packages/canvas-adapter/charts/pointInteractions.d.ts +2 -0
  21. package/dist/packages/canvas-adapter/charts/pointInteractions.js +1 -1
  22. package/dist/packages/canvas-adapter/charts/regionYieldDiagram.js +1 -1
  23. package/dist/packages/canvas-adapter/charts/sweep.js +1 -1
  24. package/dist/packages/canvas-adapter/dataTab.d.ts +3 -0
  25. package/dist/packages/canvas-adapter/dataTab.js +1 -1
  26. package/dist/packages/canvas-adapter/dieList.d.ts +12 -0
  27. package/dist/packages/canvas-adapter/dieList.js +2 -2
  28. package/dist/packages/canvas-adapter/differenceMapPanel.d.ts +26 -0
  29. package/dist/packages/canvas-adapter/differenceMapPanel.js +1 -0
  30. package/dist/packages/canvas-adapter/drilldown.d.ts +3 -0
  31. package/dist/packages/canvas-adapter/drilldown.js +1 -1
  32. package/dist/packages/canvas-adapter/filterButton.d.ts +3 -0
  33. package/dist/packages/canvas-adapter/filterButton.js +1 -0
  34. package/dist/packages/canvas-adapter/filterEditor.d.ts +53 -0
  35. package/dist/packages/canvas-adapter/filterEditor.js +1 -0
  36. package/dist/packages/canvas-adapter/guideWindow.d.ts +9 -1
  37. package/dist/packages/canvas-adapter/guideWindow.js +1 -1
  38. package/dist/packages/canvas-adapter/icons.js +1 -1
  39. package/dist/packages/canvas-adapter/insightsTab.d.ts +52 -2
  40. package/dist/packages/canvas-adapter/insightsTab.js +1 -1
  41. package/dist/packages/canvas-adapter/pageFilter.d.ts +84 -0
  42. package/dist/packages/canvas-adapter/pageFilter.js +2 -0
  43. package/dist/packages/canvas-adapter/patMode.d.ts +27 -0
  44. package/dist/packages/canvas-adapter/patMode.js +1 -0
  45. package/dist/packages/canvas-adapter/plotCard.d.ts +67 -0
  46. package/dist/packages/canvas-adapter/plotCard.js +1 -0
  47. package/dist/packages/canvas-adapter/plotEditor.d.ts +13 -2
  48. package/dist/packages/canvas-adapter/plotEditor.js +1 -1
  49. package/dist/packages/canvas-adapter/plotModal.js +1 -1
  50. package/dist/packages/canvas-adapter/plotStore.js +1 -1
  51. package/dist/packages/canvas-adapter/plotTab.d.ts +6 -0
  52. package/dist/packages/canvas-adapter/plotTab.js +1 -1
  53. package/dist/packages/canvas-adapter/renderWaferGallery.js +1 -1
  54. package/dist/packages/canvas-adapter/renderWaferMap.js +1 -1
  55. package/dist/packages/canvas-adapter/summaryPanel.d.ts +15 -5
  56. package/dist/packages/canvas-adapter/summaryPanel.js +4 -4
  57. package/dist/packages/canvas-adapter/toolbar.d.ts +17 -2
  58. package/dist/packages/canvas-adapter/toolbar.js +2 -2
  59. package/dist/packages/canvas-adapter/userGuideHtml.d.ts +1 -1
  60. package/dist/packages/canvas-adapter/userGuideHtml.js +590 -140
  61. package/dist/packages/canvas-adapter/version.d.ts +2 -2
  62. package/dist/packages/canvas-adapter/version.js +1 -1
  63. package/dist/packages/core/classify.d.ts +11 -0
  64. package/dist/packages/core/classify.js +1 -1
  65. package/dist/packages/core/dies.d.ts +2 -0
  66. package/dist/packages/core/dies.js +1 -1
  67. package/dist/packages/core/wafer.d.ts +2 -2
  68. package/dist/packages/renderer/buildView.js +1 -1
  69. package/dist/packages/renderer/buildWaferMap.d.ts +2 -0
  70. package/dist/packages/renderer/buildWaferMap.js +1 -1
  71. package/dist/packages/renderer/deprecate.d.ts +2 -8
  72. package/dist/packages/renderer/deprecate.js +1 -1
  73. package/dist/packages/renderer/fmt.js +1 -1
  74. package/dist/packages/renderer/testLabel.d.ts +0 -11
  75. package/dist/packages/renderer/testLabel.js +1 -1
  76. package/dist/packages/stats/analyzeWaferLot.d.ts +6 -0
  77. package/dist/packages/stats/analyzeWaferLot.js +1 -1
  78. package/dist/packages/stats/analyzeWaferMap.d.ts +8 -0
  79. package/dist/packages/stats/analyzeWaferMap.js +1 -1
  80. package/dist/packages/stats/binPareto.d.ts +2 -54
  81. package/dist/packages/stats/binPareto.js +1 -1
  82. package/dist/packages/stats/binRows.js +1 -1
  83. package/dist/packages/stats/capability.d.ts +10 -0
  84. package/dist/packages/stats/capability.js +1 -1
  85. package/dist/packages/stats/cardSpec.d.ts +53 -0
  86. package/dist/packages/stats/cardSpec.js +1 -0
  87. package/dist/packages/stats/chartCatalogue.d.ts +37 -0
  88. package/dist/packages/stats/chartCatalogue.js +1 -0
  89. package/dist/packages/stats/clusterDetection.d.ts +9 -0
  90. package/dist/packages/stats/clusterDetection.js +1 -1
  91. package/dist/packages/stats/commonality.d.ts +62 -0
  92. package/dist/packages/stats/commonality.js +1 -0
  93. package/dist/packages/stats/control.d.ts +21 -0
  94. package/dist/packages/stats/control.js +1 -0
  95. package/dist/packages/stats/correlation.d.ts +9 -3
  96. package/dist/packages/stats/correlation.js +1 -1
  97. package/dist/packages/stats/dieRegions.d.ts +4 -1
  98. package/dist/packages/stats/dieRegions.js +1 -1
  99. package/dist/packages/stats/differenceMap.d.ts +22 -0
  100. package/dist/packages/stats/differenceMap.js +1 -0
  101. package/dist/packages/stats/examplePicks.d.ts +22 -0
  102. package/dist/packages/stats/examplePicks.js +1 -0
  103. package/dist/packages/stats/filterFile.d.ts +41 -0
  104. package/dist/packages/stats/filterFile.js +2 -0
  105. package/dist/packages/stats/filterFindings.d.ts +20 -5
  106. package/dist/packages/stats/filterFindings.js +1 -1
  107. package/dist/packages/stats/groupCompare.d.ts +87 -0
  108. package/dist/packages/stats/groupCompare.js +1 -0
  109. package/dist/packages/stats/guideSections.d.ts +55 -0
  110. package/dist/packages/stats/guideSections.js +1 -0
  111. package/dist/packages/stats/index.d.ts +3 -1
  112. package/dist/packages/stats/index.js +1 -1
  113. package/dist/packages/stats/math.d.ts +29 -4
  114. package/dist/packages/stats/math.js +1 -1
  115. package/dist/packages/stats/metadataColumns.d.ts +3 -0
  116. package/dist/packages/stats/metadataColumns.js +1 -1
  117. package/dist/packages/stats/pat.d.ts +58 -0
  118. package/dist/packages/stats/pat.js +1 -0
  119. package/dist/packages/stats/patSummary.d.ts +45 -0
  120. package/dist/packages/stats/patSummary.js +1 -0
  121. package/dist/packages/stats/patternClassification.d.ts +3 -3
  122. package/dist/packages/stats/patternClassification.js +1 -1
  123. package/dist/packages/stats/plotData.d.ts +294 -17
  124. package/dist/packages/stats/plotData.js +1 -1
  125. package/dist/packages/stats/plotId.d.ts +2 -0
  126. package/dist/packages/stats/plotId.js +1 -1
  127. package/dist/packages/stats/plotReferences.d.ts +17 -0
  128. package/dist/packages/stats/plotReferences.js +1 -0
  129. package/dist/packages/stats/plotSpec.d.ts +239 -3
  130. package/dist/packages/stats/plotSpec.js +4 -4
  131. package/dist/packages/stats/regions.js +1 -1
  132. package/dist/packages/stats/renderSummaryReport.js +31 -31
  133. package/dist/packages/stats/reportHtml.js +9 -13
  134. package/dist/packages/stats/synthesis.d.ts +44 -16
  135. package/dist/packages/stats/synthesis.js +1 -1
  136. package/dist/packages/stats/testPassRate.d.ts +7 -0
  137. package/dist/packages/stats/testPassRate.js +1 -1
  138. package/dist/packages/stats/types.d.ts +13 -8
  139. package/dist/packages/stats/yield.d.ts +3 -11
  140. package/dist/packages/stats/yield.js +1 -1
  141. package/llms.txt +1 -1
  142. package/package.json +10 -2
  143. package/dist/packages/canvas-adapter/charts/barPanel.d.ts +0 -83
  144. package/dist/packages/canvas-adapter/charts/barPanel.js +0 -1
  145. package/dist/packages/canvas-adapter/charts/binCluster.d.ts +0 -27
  146. package/dist/packages/canvas-adapter/charts/binCluster.js +0 -1
  147. package/dist/packages/canvas-adapter/charts/boxplot.d.ts +0 -72
  148. package/dist/packages/canvas-adapter/charts/boxplot.js +0 -1
  149. package/dist/packages/canvas-adapter/charts/groupedBarPlot.d.ts +0 -53
  150. package/dist/packages/canvas-adapter/charts/groupedBarPlot.js +0 -1
  151. package/dist/packages/canvas-adapter/charts/histogram.d.ts +0 -61
  152. package/dist/packages/canvas-adapter/charts/histogram.js +0 -1
  153. package/dist/packages/canvas-adapter/charts/scatter.d.ts +0 -80
  154. package/dist/packages/canvas-adapter/charts/scatter.js +0 -1
  155. package/dist/packages/canvas-adapter/charts/testPassRate.d.ts +0 -27
  156. package/dist/packages/canvas-adapter/charts/testPassRate.js +0 -1
  157. package/dist/packages/canvas-adapter/charts/trend.d.ts +0 -50
  158. package/dist/packages/canvas-adapter/charts/trend.js +0 -1
@@ -1 +1 @@
1
- import{isYieldEligibleDie as P}from"../core/dies.js";import{testValue as k}from"../core/dieTable.js";import{isParametricTest as C}from"../renderer/buildWaferMap.js";import{buildSweepData as L}from"../stats/sweep.js";import{plotToSweep as x}from"../stats/plotSpec.js";import{renderHistogramPanel as O}from"./charts/histogram.js";import{renderCapabilityPanel as W}from"./charts/capability.js";import{openChartExpandModal as A,populationPhrase as D}from"./charts/chartShell.js";import{buildCheckMenuEl as F,createToolbarHelpers as V,getTooltip as H,menuLayerFor as j,wireMenuA11y as q,CLR as z,FONT as B,SPACE as M,openReparentedModal as _,controlStyle as K,wireControlHover as U}from"./toolbar.js";import{requireRingCount as Y}from"../core/ringCount.js";import{defaultPlot as G,defaultSweep as J,fieldCatalogue as Q,plotTitle as X,resolvePlot as Z}from"../stats/plotData.js";import{newPlotId as y}from"../stats/plotSpec.js";import{sourceFromPoints as ee,toPlotItems as S}from"./plotItems.js";const E=30,g=e=>e.items.flatMap(t=>t.dies);function te(e){return e.items.map(t=>({...t,dies:t.dies.filter(n=>P(n))}))}function N(e,t,n){return(e.testDefs??[]).filter(C).map(a=>a.testNumber).filter(a=>{let o=0;for(const s of t){const d=k(s,a);if(d!==void 0&&Number.isFinite(d)&&++o>=n)return!0}return!1})}function $(e,t,n,a,o,s){const d=e.ownerDocument,l=d.createElement("div"),f=d.createElement("span");f.textContent=n,f.dataset.wmapPopulation="1",Object.assign(l.style,{color:z.label,fontSize:B.body,marginBottom:M.sm,display:"flex",alignItems:"center",gap:M.lg,flexWrap:"wrap"}),l.appendChild(f);let h=null;if(s){const c=d.createElement("button");c.type="button",c.textContent=s.label,c.dataset[s.hook]="1",Object.assign(c.style,K("outlined")),U(c),c.addEventListener("click",()=>s.run(()=>h?.close())),l.appendChild(c)}const i=e.querySelector("[data-wmap-chart-expand]")?.parentElement;i?.parentElement===e?i.after(l):e.prepend(l),h=A(e,t,{anchor:a,onClosed:o})}function ne(e,t){const n=g(t);return t.notMeasuredReason?t.notMeasuredReason:n.some(o=>P(o))?L(n,t.testDefs,e).series.some(o=>o.points.some(s=>s.count>0))?null:"These dies have no values for this sweep\u2019s tests":"These dies are all partial or edge-excluded, which charts leave out"}function oe(e,t,n){const a=te(e),o=g(e).length,s=a.flatMap(r=>r.dies),d=D(s.length,o,e.population),l=(e.testDefs??[]).filter(C),f=n.ownerDocument,h=(r,p)=>e.notMeasuredReason?e.notMeasuredReason:s.length===0?"These dies are all partial or edge-excluded, which charts leave out":N(e,s,r).length>0?null:p,i={section:"Distributions",label:"Value histogram",unavailable:h(1,"These dies have no parametric test values"),open:()=>{let r=e.activeTest??l[0]?.testNumber;const p=O({title:"Value histogram",items:a,testDefs:l,selectedTestNumber:e.activeTest,onTestChange:m=>{r=m},onSaveImage:t.onSaveImage,ownerDocument:f}),u=I(e,t,n),b=u&&r!==void 0?{label:"Edit as new plot",hook:"wmapEditAsPlot",run:m=>{const w=l.find(v=>v.testNumber===r);m(),u({id:y(),chart:"histogram",fields:{y:{test:r,...w?.name?{name:w.name}:{}},color:{none:!0}}},!0)()}}:void 0;$(p.card,`Value histogram \u2014 ${d}`,`Population: ${d}`,n,()=>p.destroy(),b)}},c={section:"Distributions",label:"Process capability",unavailable:h(2,"Needs at least 2 of these dies with values for one test"),open:()=>{const r=W({title:"Process capability",items:a,testDefs:l,selectedTestNumber:e.activeTest,onSaveImage:t.onSaveImage,ownerDocument:f}),p=s.length<E?` \xB7 fewer than ${E} dies, so each Ppk is a rough estimate`:"";$(r.card,`Process capability \u2014 ${d}`,`Population: ${d}${p}`,n,()=>r.destroy())}};return[i,c]}function I(e,t,n){const a=t.plots;if(!a)return null;const o=n.ownerDocument,s=S(e.items),d={testDefs:e.testDefs,curation:t.attributes},l=g(e),f=D(l.length,l.length,e.population),h=D(l.filter(i=>P(i)).length,l.length,e.population);return(i,c)=>()=>{const r=i.chart==="sweep",p=r?h:f;import("./plotModal.js").then(({openPlotEditor:u})=>u({doc:o,anchor:n,store:a,plot:i,draft:c,items:s,ctx:d,population:p,rawPopulation:e.population,title:`${c?r?"New sweep":"New plot":r?"Sweep":"Plot"} \u2014 ${p}`,chart:{onSaveImage:t.onSaveImage,onSelectPoints:(b,m,w)=>{const v=ee(b,s,e.testDefs);v&&openDrilldownMenu(m,w,v,t)}}}))}}function se(e,t,n){const a=t.plots,o=I(e,t,n);if(!a||!o)return[];const s=S(e.items),d={testDefs:e.testDefs,curation:t.attributes},l=g(e),f=e.notMeasuredReason??(l.length===0?"Nothing is selected":null),h=a.get().map(p=>{const u=x(p);if(u)return{section:"Plots",label:u.title,unavailable:ne(u,e),open:o(p,!1)};const b=Z(p,s,d);return{section:"Plots",label:X(b)||"Plot",unavailable:f??b.issues[0]??(b.plotted===0?"No die here has the values this plot needs":null),open:o(p,!1)}}),i=Q(s,d),c=i.some(p=>p.group==="Tests");h.push({section:"Plots",label:"New plot\u2026",unavailable:f??(c?null:"These dies have no parametric test values"),open:o(G(i,y()),!0)});const r=(e.testDefs??[]).filter(p=>C(p));return h.push({section:"Plots",label:"New sweep\u2026",unavailable:f??(r.length>0?null:"These dies have no parametric test values"),open:o(J(e.testDefs??[],y()),!0)}),h}function ae(e,t,n){const a=g(e),o=e.notMeasuredReason??(a.length===0?"Nothing is selected":null),s=a.length,d=D(s,s,e.population),l=(f,h)=>()=>{import("./dataTab.js").then(({renderSelectionTables:i})=>{const c=n.ownerDocument;let r;const p=i({doc:c,ringCount:Y(e.items[0],"the drilldown tables"),items:e.items,testDefs:e.testDefs,population:e.population,view:f,onSaveText:t.onSaveText,onLocateDie:t.onLocateDie?(b,m)=>{r?.(),t.onLocateDie(b,m)}:void 0}),u=_([p.el],{title:`${h} \u2014 ${d}`,anchor:n,ownerDocument:c,boxSize:{width:"min(96vw, 1200px)",height:"min(92vh, 780px)"},onClosed:p.destroy});u?r=()=>u.close():p.destroy()})};return[{section:"Tables",label:"Test statistics",unavailable:o??(N(e,a,1).length>0?null:"These dies have no parametric test values"),open:l("statistics","Test statistics")},...e.items.length>1?[{section:"Tables",label:"Wafers",unavailable:o,open:l("wafers","Wafers")}]:[],{section:"Tables",label:"Dies",unavailable:o,open:l("dies","Dies")}]}function le(e,t,n){return[...oe(e,t,n),...se(e,t,n),...ae(e,t,n)]}const T=new WeakMap;export function openDrilldownMenu(e,t,n,a){const o=t.ownerDocument,s=o.defaultView??window;T.get(o)?.();const d=le(n,a,t),l=[];if(a.narrower){const{label:m,source:w,ctx:v}=a.narrower,R={label:`${a.narrower.backLabel??"All selected"} \u2014 ${D(g(n).length,g(n).length,n.population)}`,source:n,ctx:a};l.push({section:"Dies"}),l.push({label:m,active:!1,action:!0,enabled:!0,onClick:()=>{u(),openDrilldownMenu(e,t,w,{...v??a,narrower:R})}})}let f;for(const m of d)m.section!==f&&(l.push({section:m.section}),f=m.section),l.push({label:m.label,active:!1,action:!0,enabled:m.unavailable===null,disabledHint:m.unavailable??void 0,onClick:()=>{u(),m.open()}});const{makeMenuSection:h}=V(H(o)),i=F(new DOMRect(e.x,e.y-4,0,0),l,{makeMenuSection:h},s),c=g(n).length;i.setAttribute("role","menu"),i.setAttribute("aria-label",`Open a chart or table of ${D(c,c,n.population)}`),i.dataset.wmapDrilldownMenu="1",j(t).appendChild(i);const r=i.getBoundingClientRect();r.bottom>s.innerHeight-4&&(i.style.top=`${Math.max(4,e.y-r.height)}px`),r.right>s.innerWidth-4&&(i.style.left=`${Math.max(4,s.innerWidth-r.width-4)}px`);let p=!1;function u(){p||(p=!0,i.remove(),o.removeEventListener("pointerdown",b,!0),s.removeEventListener("blur",u),T.get(o)===u&&T.delete(o))}function b(m){i.contains(m.target)||u()}return o.addEventListener("pointerdown",b,!0),s.addEventListener("blur",u),q(i,t,u),T.set(o,u),u}
1
+ import{isYieldEligibleDie as T}from"../core/dies.js";import{testValue as R}from"../core/dieTable.js";import{isParametricTest as C}from"../renderer/buildWaferMap.js";import{buildSweepData as k}from"../stats/sweep.js";import{plotToSweep as E}from"../stats/plotSpec.js";import{renderPlotCard as F}from"./plotCard.js";import{renderCapabilityPanel as L}from"./charts/capability.js";import{makeTestSelect as O,openChartExpandModal as V,populationPhrase as v}from"./charts/chartShell.js";import{openCommandMenu as W,CLR as A,FONT as B,SPACE as q,openReparentedModal as z}from"./toolbar.js";import{requireRingCount as _}from"../core/ringCount.js";import{defaultPlot as j,defaultSweep as H,fieldCatalogue as K,plotTitle as U,resolvePlot as Y}from"../stats/plotData.js";import{newPlotId as M}from"../stats/plotSpec.js";import{sourceFromPoints as G,toPlotItems as S}from"./plotItems.js";const N=30,b=e=>e.items.flatMap(t=>t.dies);function J(e){return e.items.map(t=>({...t,dies:t.dies.filter(n=>T(n))}))}function y(e,t,n){return(e.testDefs??[]).filter(C).map(s=>s.testNumber).filter(s=>{let l=0;for(const o of t){const r=R(o,s);if(r!==void 0&&Number.isFinite(r)&&++l>=n)return!0}return!1})}function $(e,t,n,s,l){const o=e.ownerDocument.createElement("div");o.textContent=n,o.dataset.wmapPopulation="1",Object.assign(o.style,{color:A.label,fontSize:B.body,marginBottom:q.sm});const r=e.querySelector("[data-wmap-card-menu]")?.parentElement;r?.parentElement===e?r.after(o):e.prepend(o);const p=V(e,t,{anchor:s,onClosed:l});return()=>p?.close()}function Q(e,t){const n=b(t);return t.notMeasuredReason?t.notMeasuredReason:n.some(l=>T(l))?k(n,t.testDefs,e).series.some(l=>l.points.some(o=>o.count>0))?null:"These dies have no values for this sweep\u2019s tests":"These dies are all partial or edge-excluded, which charts leave out"}function X(e,t,n){const s=J(e),l=b(e).length,o=s.flatMap(a=>a.dies),r=v(o.length,l,e.population),p=(e.testDefs??[]).filter(C),c=n.ownerDocument,u=(a,i)=>e.notMeasuredReason?e.notMeasuredReason:o.length===0?"These dies are all partial or edge-excluded, which charts leave out":y(e,o,a).length>0?null:i,d={section:"Distributions",label:"Value histogram",unavailable:u(1,"These dies have no parametric test values"),open:()=>{let a=e.activeTest??p[0]?.testNumber;const i=p.filter(D=>D.testNumber!==void 0),f=O(i,a??null,D=>{a=D,w.refresh()},{ownerDocument:c}),h=S(s),g=I(e,t,n);let P;const w=F({doc:c,items:h,ctx:{testDefs:p,curation:t.attributes},extras:[f],spec:{choices:[],build:()=>({id:"drill-histogram",title:"Value histogram",chart:"histogram",fields:{y:{slot:"test"},color:{none:!0}}})},slots:()=>({test:a}),chart:{onSaveImage:t.onSaveImage,binColors:t.getBinColors?.()},editAsPlot:g?D=>{P?.(),g(D,!0)()}:void 0});P=$(w.card,`Value histogram \u2014 ${r}`,`Population: ${r}`,n,()=>w.destroy())}},m={section:"Distributions",label:"Process capability",unavailable:u(2,"Needs at least 2 of these dies with values for one test"),open:()=>{const a=L({title:"Process capability",items:s,testDefs:p,selectedTestNumber:e.activeTest,onSaveImage:t.onSaveImage,ownerDocument:c}),i=o.length<N?` \xB7 fewer than ${N} dies, so each Ppk is a rough estimate`:"";$(a.card,`Process capability \u2014 ${r}`,`Population: ${r}${i}`,n,()=>a.destroy())}};return[d,m]}function I(e,t,n){const s=t.plots;if(!s)return null;const l=n.ownerDocument,o=S(e.items),r={testDefs:e.testDefs,curation:t.attributes},p=b(e),c=v(p.length,p.length,e.population),u=v(p.filter(d=>T(d)).length,p.length,e.population);return(d,m)=>()=>{const a=d.chart==="sweep",i=a?u:c;import("./plotModal.js").then(({openPlotEditor:f})=>f({doc:l,anchor:n,store:s,plot:d,draft:m,items:o,ctx:r,population:i,rawPopulation:e.population,title:`${m?a?"New sweep":"New plot":a?"Sweep":"Plot"} \u2014 ${i}`,chart:{onSaveImage:t.onSaveImage,binColors:t.getBinColors?.(),onSelectPoints:(h,g,P)=>{const w=G(h,o,e.testDefs);w&&openDrilldownMenu(g,P,w,t)}}}))}}function Z(e,t,n){const s=t.plots,l=I(e,t,n);if(!s||!l)return[];const o=S(e.items),r={testDefs:e.testDefs,curation:t.attributes},p=b(e),c=e.notMeasuredReason??(p.length===0?"Nothing is selected":null),u=s.get().map(i=>{const f=E(i);if(f)return{section:"Plots",label:f.title,unavailable:Q(f,e),open:l(i,!1)};const h=Y(i,o,r);return{section:"Plots",label:U(h)||"Plot",unavailable:c??h.issues[0]??(h.plotted===0?"No die here has the values this plot needs":null),open:l(i,!1)}}),d=K(o,r),m=d.some(i=>i.group==="Tests");u.push({section:"Plots",label:"New plot\u2026",unavailable:c??(m?null:"These dies have no parametric test values"),open:l(j(d,M()),!0)});const a=(e.testDefs??[]).filter(i=>C(i));return u.push({section:"Plots",label:"New sweep\u2026",unavailable:c??(a.length>0?null:"These dies have no parametric test values"),open:l(H(e.testDefs??[],M()),!0)}),u}function x(e,t,n){const s=b(e),l=e.notMeasuredReason??(s.length===0?"Nothing is selected":null),o=s.length,r=v(o,o,e.population),p=(c,u)=>()=>{import("./dataTab.js").then(({renderSelectionTables:d})=>{const m=n.ownerDocument;let a;const i=d({doc:m,ringCount:_(e.items[0],"the drilldown tables"),items:e.items,testDefs:e.testDefs,population:e.population,view:c,onSaveText:t.onSaveText,onLocateDie:t.onLocateDie?(h,g)=>{a?.(),t.onLocateDie(h,g)}:void 0}),f=z([i.el],{title:`${u} \u2014 ${r}`,anchor:n,ownerDocument:m,boxSize:{width:"min(96vw, 1200px)",height:"min(92vh, 780px)"},onClosed:i.destroy});f?a=()=>f.close():i.destroy()})};return[{section:"Tables",label:"Test statistics",unavailable:l??(y(e,s,1).length>0?null:"These dies have no parametric test values"),open:p("statistics","Test statistics")},...e.items.length>1?[{section:"Tables",label:"Wafers",unavailable:l,open:p("wafers","Wafers")}]:[],{section:"Tables",label:"Dies",unavailable:l,open:p("dies","Dies")}]}function ee(e,t,n){return[...X(e,t,n),...Z(e,t,n),...x(e,t,n)]}export function openDrilldownMenu(e,t,n,s){const l=ee(n,s,t),o=[];if(s.narrower){const{label:u,source:d,ctx:m}=s.narrower,a={label:`${s.narrower.backLabel??"All selected"} \u2014 ${v(b(n).length,b(n).length,n.population)}`,source:n,ctx:s};o.push({section:"Dies"}),o.push({label:u,active:!1,action:!0,enabled:!0,onClick:()=>{c(),openDrilldownMenu(e,t,d,{...m??s,narrower:a})}})}let r;for(const u of l)u.section!==r&&(o.push({section:u.section}),r=u.section),o.push({label:u.label,active:!1,action:!0,enabled:u.unavailable===null,disabledHint:u.unavailable??void 0,onClick:()=>{c(),u.open()}});const p=b(n).length,c=W(new DOMRect(e.x,e.y-4,0,0),t,o,`Open a chart or table of ${v(p,p,n.population)}`,{hook:"wmapDrilldownMenu"});return c}
@@ -0,0 +1,3 @@
1
+ /** The small outlined button the band, the editor and each view's Filter button share. */
2
+ export declare function bandButton(doc: Document, text: string, hook: string, hint: string, onClick: () => void): HTMLButtonElement;
3
+ //# sourceMappingURL=filterButton.d.ts.map
@@ -0,0 +1 @@
1
+ import{FONT as d,SPACE as l,controlStyle as a,wireControlHover as c,wireTooltip as b}from"./toolbar.js";export function bandButton(e,n,o,r,i){const t=e.createElement("button");return t.type="button",t.textContent=n,t.dataset[o]="1",Object.assign(t.style,{...a("outlined"),fontSize:d.body,padding:`0 ${l.md}`}),c(t),b(t,r),t.addEventListener("click",i),t}
@@ -0,0 +1,53 @@
1
+ import { type FieldOption } from '../stats/plotData.js';
2
+ import { type PlotField, type PlotFilter } from '../stats/plotSpec.js';
3
+ import type { TestDef } from '../renderer/buildWaferMap.js';
4
+ import type { FacetCuration } from '../stats/facets.js';
5
+ export interface FilterEditorOptions {
6
+ doc: Document;
7
+ /** The population's fields; those a condition can be on are taken from it (`filterFields`). */
8
+ catalogue: readonly FieldOption[];
9
+ filter: PlotFilter | undefined;
10
+ /** Called with the filter after every change; `undefined` once the last condition is removed. */
11
+ onChange: (next: PlotFilter | undefined) => void;
12
+ /** The values a category field takes on the population, in order. */
13
+ valuesOf: (field: PlotField) => string[];
14
+ /** The range a number field spans on the population. */
15
+ extentOf: (field: PlotField) => [number, number] | undefined;
16
+ testDefs?: readonly TestDef[];
17
+ /** The host's names for wafer attributes, so a condition names a field as Group by and the plots do. */
18
+ attributes?: Record<string, FacetCuration>;
19
+ /** The switch's text: what is filtered ("Filter this plot", "Filter Insights"). */
20
+ switchLabel: string;
21
+ }
22
+ export interface FilterEditorHandle {
23
+ el: HTMLElement;
24
+ /** The filter changed elsewhere (the card's switch, Clear): show it. */
25
+ set(filter: PlotFilter | undefined): void;
26
+ }
27
+ /**
28
+ * The fields a condition can be on: every category and number in the catalogue except Test, which divides a set of
29
+ * tests rather than the dies, and the pass-rate columns, which are 100 or 0 per die (a verdict is under Verdicts).
30
+ */
31
+ export declare function filterFields(catalogue: readonly FieldOption[]): FieldOption[];
32
+ export declare function buildFilterEditor(o: FilterEditorOptions): FilterEditorHandle;
33
+ export interface FilterStripOptions {
34
+ doc: Document;
35
+ filter: PlotFilter;
36
+ testDefs?: readonly TestDef[];
37
+ attributes?: Record<string, FacetCuration>;
38
+ /** What the switch names ("Filter", "Insights filter"). */
39
+ label: string;
40
+ /** The switch was flipped: `on` true applies the conditions again. */
41
+ onToggle: (on: boolean) => void;
42
+ /** Said after the conditions while the filter is on: what it kept ("18 of 25 wafers"). */
43
+ kept?: string;
44
+ /** Buttons at the end of the line (Edit, Clear). */
45
+ actions?: HTMLElement[];
46
+ }
47
+ /**
48
+ * A filter as one line wherever its result is shown: a switch, each condition in words, and while on what it kept.
49
+ * Filtering is never hidden, so the line stays while the filter is off, muted and saying so, until the filter is
50
+ * removed. The same line on a plot card and above every Insights tab.
51
+ */
52
+ export declare function buildFilterStrip(o: FilterStripOptions): HTMLElement;
53
+ //# sourceMappingURL=filterEditor.d.ts.map
@@ -0,0 +1 @@
1
+ import{conditionText as E,conditionUnit as J,fieldKey as T}from"../stats/plotData.js";import{sameField as M}from"../stats/plotSpec.js";import{CLR as C,FONT as F,RADIUS as I,SPACE as r,controlStyle as P,wireControlHover as H,wireTooltip as K}from"./toolbar.js";import{inputStyle as U,makeListSelect as V,makeSegmented as Y,makeToggle as D}from"./charts/chartShell.js";export function filterFields(n){return n.filter(o=>o.group!=="Pass rates"&&!("builtin"in o.field&&o.field.builtin==="test"))}const G=n=>!n.categorical,L=n=>String(Number(n.toPrecision(6)));export function buildFilterEditor(n){const{doc:o}=n,S=filterFields(n.catalogue),u=e=>S.find(s=>M(s.field,e)),m=e=>e?JSON.parse(JSON.stringify(e)):void 0;let i=m(n.filter),y=!1;const h=o.createElement("div");h.dataset.wmapFilterEditor="1",Object.assign(h.style,{display:"flex",flexDirection:"column",gap:r.md});const d=e=>{i&&i.conditions.length===0&&(i=void 0),n.onChange(m(i)),e&&k()};function B(e){if(G(e)){const t=n.extentOf(e.field);return t?{field:e.field,min:t[0],max:t[1]}:void 0}const s=n.valuesOf(e.field);return s.length?{field:e.field,values:s}:void 0}function N(e,s){const t=S.map(l=>({value:T(l.field),label:l.label,group:l.group})),f=V(t,e?T(e):"",l=>{const b=S.find(p=>T(p.field)===l);b&&s(b)},{maxWidth:"100%",ownerDocument:o,ariaLabel:"Condition field",searchPlaceholder:"Filter fields\u2026",hook:"filter-field",emptyText:"Choose a field\u2026"});return Object.assign(f.style,{flex:"1 1 auto",minWidth:"0"}),f}function W(e,s){const t=o.createElement("button");return t.type="button",t.textContent="\u2715",t.setAttribute("aria-label",e),t.dataset.wmapFilterRemove="1",Object.assign(t.style,{...P("bare"),fontSize:F.body,padding:`0 ${r.sm}`,flexShrink:"0"}),H(t,"bare"),K(t,e),t.addEventListener("click",s),t}function z(e,s,t,f){const l=o.createElement("input");return l.type="text",l.inputMode="decimal",l.value=e===void 0?"":L(e),l.placeholder=s,l.setAttribute("aria-label",t),Object.assign(l.style,U(),{width:"9em"}),l.addEventListener("change",()=>{const b=l.value.trim(),p=b===""?void 0:Number(b);if(p!==void 0&&!Number.isFinite(p)){l.setAttribute("aria-invalid","true"),l.style.borderColor=C.errBorder;return}l.removeAttribute("aria-invalid"),l.style.borderColor="",f(p)}),l}function q(e,s){const t=o.createElement("div");t.dataset.wmapFilterCondition=String(s),t.setAttribute("role","group"),t.setAttribute("aria-label",`Condition ${s+1}`),Object.assign(t.style,{display:"flex",flexDirection:"column",gap:r.sm,padding:r.md,border:`1px solid ${C.menuBorder}`,borderRadius:I.control});const f=u(e.field),l=e.values===void 0,b=o.createElement("div");if(Object.assign(b.style,{display:"flex",alignItems:"center",gap:r.sm,flexWrap:"wrap"}),b.appendChild(N(e.field,c=>{const g=B(c);!g||!i||(i.conditions[s]=g,d(!0))})),b.appendChild(Y(l?[["in","from\u2013to"],["not","outside"]]:[["in","is"],["not","is not"]],e.not?"not":"in",c=>{i&&(c==="not"?i.conditions[s].not=!0:delete i.conditions[s].not,d(!1),p.textContent=E(i.conditions[s],n.testDefs,n.attributes))},o,!0)),b.appendChild(W(`Remove the condition: ${E(e,n.testDefs,n.attributes)}`,()=>{i&&(i.conditions.splice(s,1),d(!0))})),t.appendChild(b),f)if(l){const c=o.createElement("div");Object.assign(c.style,{display:"flex",alignItems:"center",gap:r.sm,flexWrap:"wrap",fontSize:F.body,color:C.label});const g=w=>O=>{if(!i)return;const a=i.conditions[s];if(O===void 0?delete a[w]:a[w]=O,a.min===void 0&&a.max===void 0){const A=n.extentOf(a.field);A&&(a[w]=w==="min"?A[0]:A[1])}const j=a.min!==void 0&&a.max!==void 0&&a.min>a.max;j&&([a.min,a.max]=[a.max,a.min]);const R=a[w]===O&&!j;d(!R),R&&(p.textContent=E(a,n.testDefs,n.attributes))},x=J(e.field,n.testDefs),v=x?` ${x}`:"";c.append(z(e.min,"no minimum",`${f.name}: lowest value kept${x?`, in ${x}`:""}`,g("min")),o.createTextNode("to"),z(e.max,"no maximum",`${f.name}: highest value kept${x?`, in ${x}`:""}`,g("max"))),x&&c.appendChild(o.createTextNode(x));const $=n.extentOf(e.field);if($){const w=o.createElement("span");w.textContent=`(values here: ${L($[0])} to ${L($[1])}${v})`,c.appendChild(w)}t.appendChild(c)}else{const c=n.valuesOf(e.field),g=o.createElement("div");g.setAttribute("role","group"),g.setAttribute("aria-label",`${f.name}: values`),Object.assign(g.style,{display:"flex",flexWrap:"wrap",gap:`${r.xs} ${r.md}`,maxHeight:"120px",overflowY:"auto"});const x=[...c,...(e.values??[]).filter(v=>!c.includes(v))];for(const v of x){const $=D(v,(e.values??[]).includes(v),w=>{if(!i)return;const O=i.conditions[s],a=new Set(O.values??[]);if(w?a.add(v):a.delete(v),a.size===0){$.querySelector("input").checked=!0;return}O.values=x.filter(j=>a.has(j)),d(!1),p.textContent=E(O,n.testDefs,n.attributes)},o);$.dataset.wmapFilterValue=v,g.appendChild($)}t.appendChild(g)}else{const c=o.createElement("div");c.textContent="This field is not in the wafers in view: the condition keeps nothing until it is changed or removed.",Object.assign(c.style,{color:C.warnText,fontSize:F.body}),t.appendChild(c)}const p=o.createElement("div");return p.dataset.wmapFilterSummary="1",p.textContent=E(e,n.testDefs,n.attributes),Object.assign(p.style,{color:C.label,fontSize:F.meta}),t.appendChild(p),t}function k(){if(h.innerHTML="",i&&i.conditions.length){const t=D(n.switchLabel,!i.off,f=>{i&&(f?delete i.off:i.off=!0,d(!1),e.style.opacity=i.off?"0.6":"1")},o,"Off keeps the conditions and applies none, so the filter can be switched back on as it was");t.dataset.wmapFilterSwitch="1",h.appendChild(t)}const e=o.createElement("div");if(Object.assign(e.style,{display:"flex",flexDirection:"column",gap:r.sm,opacity:i?.off?"0.6":"1"}),i?.conditions.forEach((t,f)=>e.appendChild(q(t,f))),y){const t=o.createElement("div");t.dataset.wmapFilterPending="1",Object.assign(t.style,{display:"flex",alignItems:"center",gap:r.sm}),t.appendChild(N(void 0,f=>{const l=B(f);l&&(y=!1,i??={conditions:[]},i.conditions.push(l),d(!0))})),t.appendChild(W("Cancel the new condition",()=>{y=!1,k()})),e.appendChild(t)}h.appendChild(e);const s=o.createElement("button");s.type="button",s.textContent=i?.conditions.length?"+ Add condition":"+ Add a condition",s.dataset.wmapFilterAdd="1",s.disabled=y||S.length===0,Object.assign(s.style,{...P("outlined"),fontSize:F.body,padding:`${r.xs} ${r.md}`,alignSelf:"flex-start"}),H(s),K(s,"Keep only what meets this condition as well as the others"),s.addEventListener("click",()=>{y=!0,k(),h.querySelector("[data-wmap-filter-pending] button")?.focus()}),h.appendChild(s)}return k(),{el:h,set:e=>{i=m(e),y=!1,k()}}}export function buildFilterStrip(n){const{doc:o,filter:S}=n,u=!S.off,m=o.createElement("div");m.dataset.wmapFilterStrip=u?"on":"off",m.setAttribute("role","status"),Object.assign(m.style,{display:"flex",flexWrap:"wrap",alignItems:"center",gap:`${r.xs} ${r.md}`,flexBasis:"100%",padding:`${r.xs} ${r.md}`,borderRadius:I.control,fontSize:F.body,background:u?C.infoBg:"transparent",color:u?C.infoText:C.label,border:`1px ${u?"solid":"dashed"} ${u?C.iconActive:C.menuBorder}`});const i=D(u?`${n.label} on:`:`${n.label} off`,u,n.onToggle,o,u?"Switch the filter off: its conditions are kept, and nothing is filtered until it is switched back on":"Switch the filter back on, with the conditions below");i.dataset.wmapFilterStripSwitch="1",i.style.fontWeight="600",i.style.color="inherit",m.appendChild(i);const y=o.createElement("span");y.dataset.wmapFilterStripText="1";const h=S.conditions.map(d=>E(d,n.testDefs,n.attributes)).join(" \xB7 ");if(y.textContent=u?h:`(would keep only: ${h})`,m.appendChild(y),u&&n.kept){const d=o.createElement("span");d.dataset.wmapFilterStripKept="1",d.textContent=`\u2014 ${n.kept}`,d.style.fontWeight="600",m.appendChild(d)}if(n.actions?.length){const d=o.createElement("span");Object.assign(d.style,{display:"inline-flex",gap:r.sm,marginLeft:"auto"}),d.append(...n.actions),m.appendChild(d)}return m}
@@ -1,4 +1,9 @@
1
1
  import { type OverlayHandle } from './toolbar.js';
2
+ type GuideOpener = (section?: string) => void;
3
+ /** A renderer's guide opener, used by links while it is mounted. Returns the unregister function (call on destroy). */
4
+ export declare function registerGuideOpener(open: GuideOpener): () => void;
5
+ /** Opens the user guide at a section (a heading id, `GUIDE_SECTIONS`), or moves an open guide to it. */
6
+ export declare function openGuideAt(section: string, anchor?: Element): void;
2
7
  type GuideApi = {
3
8
  buildWaferMap: unknown;
4
9
  renderWaferMap: unknown;
@@ -46,7 +51,10 @@ export interface UserGuideExtension {
46
51
  * content, and reusing it silently for the guide would broaden it without
47
52
  * documentation.
48
53
  */
49
- export declare function openUserGuideWindow(api: GuideApi, html: string, extension?: UserGuideExtension, anchor?: Element): void;
54
+ export declare function openUserGuideWindow(api: GuideApi, html: string, extension?: UserGuideExtension, anchor?: Element,
55
+ /** A heading id to open at (`GUIDE_SECTIONS`). An open guide is brought forward and moved there, not reopened, so
56
+ * the reader keeps the window where they put it, beside the app. */
57
+ section?: string): void;
50
58
  /**
51
59
  * Opens wmap's own guide window with no live `WaferMapController`/
52
60
  * `GalleryController` required — `WaferMapController.openUserGuide()`/
@@ -1 +1 @@
1
- import{openHtmlReport as N}from"../stats/renderFindingsReport.js";import{buildWaferMap as G}from"../renderer/buildWaferMap.js";import{analyzeWaferMap as M}from"../stats/analyzeWaferMap.js";import{CLR as f,FONT as $,RADIUS as k,MOTION as O,wireControlHover as H,copyWmapThemeTokens as B,syncWmapPopupTheme as F,openModal as R,openFloatingWindow as z,wireExpandToggle as P}from"./toolbar.js";let y=null;const S=40,j=S+8;function U(e,i){const s=e.createElement("div");s.classList.add("wmap-guide-search"),s.style.cssText="display:flex;align-items:center;gap:2px;margin-left:10px;flex:1;min-width:80px;max-width:260px;";const t=e.createElement("input");t.type="text",t.placeholder="Search guide\u2026",t.setAttribute("aria-label","Search guide"),t.style.cssText=`flex:1;min-width:0;padding:4px 8px;font-size:12px;background:${f.menuBg};color:${f.text};border:1px solid ${f.menuBorder};border-radius:${k.control};outline:none;`,t.addEventListener("focus",()=>{t.style.borderColor=f.iconActive}),t.addEventListener("blur",()=>{t.style.borderColor=f.menuBorder});const n=e.createElement("span");n.setAttribute("role","status"),n.setAttribute("aria-live","polite"),n.style.cssText=`font-size:12px;color:${f.label};min-width:44px;text-align:center;flex-shrink:0;white-space:nowrap;`;function r(u,m){const d=e.createElement("button");return d.type="button",d.textContent=u,d.setAttribute("aria-label",m),d.disabled=!0,d.style.cssText=`border:none;background:none;cursor:pointer;padding:4px 6px;border-radius:${k.control};font-size:12px;color:${f.label};flex-shrink:0;opacity:0.4;`,d.addEventListener("mouseenter",()=>{d.disabled||(d.style.background=f.bgHover)}),d.addEventListener("mouseleave",()=>{d.style.background="none"}),d}const a=r("\u25B2","Previous match"),o=r("\u25BC","Next match");let l=[],c=-1;function p(){const u=l.length===0;a.disabled=u,o.disabled=u,a.style.opacity=u?"0.4":"",o.style.opacity=u?"0.4":""}function g(){for(const u of l)u.parentNode?.replaceChild(e.createTextNode(u.textContent??""),u);i.normalize(),l=[],c=-1}function h(u){if(l.length===0)return;c>=0&&(l[c].style.outline="none"),c=(u%l.length+l.length)%l.length;const m=l[c];m.style.outline=`2px solid ${f.iconActive}`,m.style.outlineOffset="1px",m.scrollIntoView({behavior:"smooth",block:"center"}),n.textContent=`${c+1}/${l.length}`}function w(u){g();const m=u.trim();if(!m){n.textContent="",p();return}const d=m.toLowerCase(),x=e.createTreeWalker(i,NodeFilter.SHOW_TEXT,{acceptNode(C){const b=C.parentElement;return!b||b.closest("script,style,.wmap-guide-toc")?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}}),T=[];let _;for(;_=x.nextNode();)T.push(_);for(const C of T){const b=C.textContent??"",A=b.toLowerCase();if(!A.includes(d))continue;const L=e.createDocumentFragment();let E=0,v=A.indexOf(d);for(;v!==-1;){v>E&&L.appendChild(e.createTextNode(b.slice(E,v)));const D=e.createElement("mark");D.textContent=b.slice(v,v+m.length),L.appendChild(D),l.push(D),E=v+m.length,v=A.indexOf(d,E)}E<b.length&&L.appendChild(e.createTextNode(b.slice(E))),C.parentNode?.replaceChild(L,C)}p(),l.length===0?n.textContent="No matches":h(0)}return t.addEventListener("input",()=>w(t.value)),t.addEventListener("keydown",u=>{u.key==="Enter"?(u.preventDefault(),h(c+(u.shiftKey?-1:1))):u.key==="Escape"&&(t.value?(t.value="",w("")):t.blur())}),a.addEventListener("click",()=>h(c-1)),o.addEventListener("click",()=>h(c+1)),s.append(t,n,a,o),s}function q(e,i,s){const t=[...i.querySelectorAll("h2[id]")];if(t.length<2)return;for(const m of i.querySelectorAll("h1[id],h2[id],h3[id],h4[id]"))m.style.scrollMarginTop=`${j}px`;const n=e.createElement("div");n.classList.add("wmap-guide-toc"),n.style.cssText=`position:sticky;top:0;z-index:2;background:${f.menuBg};border-bottom:1px solid ${f.menuBorder};font-family:system-ui,-apple-system,"Segoe UI",sans-serif;`;const r=e.createElement("div");r.style.cssText=`display:flex;align-items:center;gap:4px;height:${S}px;padding:0 12px;box-sizing:border-box;`;const a=e.createElement("span");a.innerHTML='<svg viewBox="0 0 24 24" width="12" height="12" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m6 9 6 6 6-6"/></svg>',a.style.cssText=`display:inline-flex;transition:transform ${O.base};flex-shrink:0;`;const o=e.createElement("button");o.type="button";const l="wmap-guide-toc-panel";o.setAttribute("aria-expanded","false"),o.setAttribute("aria-controls",l),o.style.cssText=`display:flex;align-items:center;gap:6px;border:none;background:none;cursor:pointer;padding:6px 8px;margin:0 -8px 0 -8px;border-radius:${k.control};font-size:13px;font-weight:600;color:${f.text};`;const c=e.createElement("span");c.textContent=`Contents (${t.length})`,o.append(a,c),o.addEventListener("mouseenter",()=>{o.style.background=f.bgHover}),o.addEventListener("mouseleave",()=>{o.style.background="none"});const p=e.createElement("button");p.type="button",p.textContent="\u2191 Top",p.style.cssText=`margin-left:auto;border:none;background:none;cursor:pointer;padding:6px 8px;border-radius:${k.control};font-size:12px;color:${f.label};`,p.addEventListener("mouseenter",()=>{p.style.background=f.bgHover}),p.addEventListener("mouseleave",()=>{p.style.background="none"}),p.addEventListener("click",()=>{u.close(),i.scrollTo({top:0,behavior:"smooth"})}),s?r.append(o,U(e,i),p):r.append(o,p);const g=e.createElement("div");g.id=l,g.hidden=!0,g.style.cssText="padding:2px 12px 12px;max-height:min(60vh,440px);overflow-y:auto;";const h=/^\s*\d+(?:\.\d+)*\.\s+/;for(const m of i.querySelectorAll("h2[id],h3[id],h4[id]")){const d=m.firstChild;d?.nodeType===Node.TEXT_NODE&&(d.textContent=(d.textContent??"").replace(h,""))}const w=e.createElement("ul");w.setAttribute("role","list"),w.style.cssText="list-style:none;margin:0;padding:0;columns:200px;column-gap:24px;";for(const m of t){const d=e.createElement("li");d.style.cssText="break-inside:avoid;";const x=e.createElement("a");x.href=`#${m.id}`,x.textContent=m.textContent??"",x.style.cssText=`display:block;padding:4px 6px;margin:0 -6px;border-radius:${k.control};font-size:12.5px;color:${f.iconActive};text-decoration:none;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;`,x.addEventListener("mouseenter",()=>{x.style.background=f.bgHover}),x.addEventListener("mouseleave",()=>{x.style.background="none"}),x.addEventListener("click",T=>{T.preventDefault(),u.close(),m.scrollIntoView({behavior:"smooth",block:"start"})}),d.appendChild(x),w.appendChild(d)}g.appendChild(w);const u=P(o,m=>{g.hidden=!m,o.setAttribute("aria-expanded",String(m)),a.style.transform=m?"rotate(180deg)":"none"});n.append(r,g),i.prepend(n)}function W(e,i,s,t,n){const r=i,a=r.__wmapDemoApi;r.__wmapDemoApi=t;const o=e.createElement("div");return o.classList.add("wmap-guide-content"),o.innerHTML=s,q(e,o,n),{content:o,restoreApi:()=>{r.__wmapDemoApi===t&&(r.__wmapDemoApi=a)}}}function I(e,i){const s=i,t=e.querySelector("script");if(t){const n=e.ownerDocument.createElement("script");n.textContent=t.textContent,e.appendChild(n);const r=e.querySelector(".wmap-guide");return r&&s.__wmapPopulateGuideDemos?.(r),s.__wmapDestroyGuideDemos}}function V(e,i,s,t){const n=t?.ownerDocument??document,r=n.defaultView??window,{content:a,restoreApi:o}=W(n,r,i,s,!0);Object.assign(a.style,{flex:"1",overflow:"auto",minHeight:"0",minWidth:"0"});let l;const c=z({title:e,anchor:t,ownerDocument:n,printable:!0,onMaximizeChange:p=>{a.style.setProperty("--wmap-guide-reading-width",p?"1000px":"720px")},onClose:()=>{y===c&&(y=null),l?.(),o()}});return c.contentWrap.appendChild(a),l=I(a,r),c}function X(e,i,s,t){const n=e.document;n.title=i,Object.assign(n.documentElement.style,{height:"100%"}),Object.assign(n.body.style,{margin:"0",height:"100vh",overflow:"hidden",display:"flex",flexDirection:"column",fontFamily:$.family}),B(document.documentElement,n.documentElement);const r=F(document.documentElement,n.documentElement),{content:a,restoreApi:o}=W(n,e,s,t,!1);Object.assign(a.style,{flex:"1",overflow:"auto",minHeight:"0",minWidth:"0"}),n.body.appendChild(a);const l=I(a,e);let c=!1;const p=()=>{if(!c){c=!0,clearInterval(g),r();try{l?.()}catch{}o(),y===h&&(y=null)}},g=setInterval(()=>{e.closed&&p()},400);e.addEventListener("pagehide",p);const h={close:()=>{e.closed||e.close(),p()}};return h}export function openUserGuideWindow(e,i,s,t){y&&(y.close(),y=null);const n=s?.title??"Wafer Map \u2014 User Guide",r=(s?.html??"")+i,o=(t?.ownerDocument.defaultView??window).open("","_blank","width=800,height=820");y=o?X(o,n,r,e):V(n,r,e,t)}export function openWaferMapGuide(e,i){Promise.all([import("./userGuideHtml.js"),import("./renderWaferMap.js"),import("./renderWaferGallery.js")]).then(([s,t,n])=>{openUserGuideWindow({buildWaferMap:G,renderWaferMap:t.renderWaferMap,renderWaferGallery:n.renderWaferGallery,analyzeWaferMap:M},s.USER_GUIDE_HTML,e,i)})}export function openReportModal(e,i){const s=i?.ownerDocument??document,t=s.createElement("iframe");t.srcdoc=e,t.title="Summary report",Object.assign(t.style,{border:"0",width:"100%",flex:"1",minHeight:"0",background:"#fff"});const n=s.createElement("div");Object.assign(n.style,{display:"flex",justifyContent:"flex-end",padding:"6px 14px",borderBottom:`1px solid ${f.menuBorder}`,flexShrink:"0"});const r=s.createElement("button");r.type="button",H(r,"bare"),r.textContent="Open as full page \u2197",Object.assign(r.style,{border:"none",background:"none",color:f.iconActive,cursor:"pointer",fontSize:$.body,textDecoration:"underline",padding:"0"}),r.addEventListener("click",()=>N(e)),n.appendChild(r);const a=s.defaultView??window,o=c=>{if(c.source!==t.contentWindow)return;const p=c.data?.wmapFinding;typeof p=="string"&&i?.onFinding?.(p,l)};i?.onFinding&&a.addEventListener("message",o);const l=R({title:"Summary report",anchor:i?.anchor,ownerDocument:s,printable:()=>t.contentWindow?.print(),onClose:()=>a.removeEventListener("message",o)});return l.contentWrap.style.flexDirection="column",l.contentWrap.appendChild(n),l.contentWrap.appendChild(t),l}
1
+ import{openHtmlReport as W}from"../stats/renderFindingsReport.js";import{buildWaferMap as F}from"../renderer/buildWaferMap.js";import{analyzeWaferMap as H}from"../stats/analyzeWaferMap.js";import{CLR as f,FONT as S,RADIUS as k,MOTION as B,wireControlHover as R,copyWmapThemeTokens as z,syncWmapPopupTheme as q,openModal as P,openFloatingWindow as j,wireExpandToggle as U}from"./toolbar.js";let y=null;function D(e,r,s=!1){if(!r)return;const t=e.querySelector(`[id="${r}"]`);if(!t)return;const i=e.ownerDocument.defaultView,n=()=>t.scrollIntoView({block:"start"});s||!i?.requestAnimationFrame?n():i.requestAnimationFrame(()=>i.requestAnimationFrame(n))}const T=[];export function registerGuideOpener(e){return T.push(e),()=>{const r=T.lastIndexOf(e);r>=0&&T.splice(r,1)}}export function openGuideAt(e,r){const s=T[T.length-1];s?s(e):N(void 0,r,e)}const I=40,V=I+8;function X(e,r){const s=e.createElement("div");s.classList.add("wmap-guide-search"),s.style.cssText="display:flex;align-items:center;gap:2px;margin-left:10px;flex:1;min-width:80px;max-width:260px;";const t=e.createElement("input");t.type="text",t.placeholder="Search guide\u2026",t.setAttribute("aria-label","Search guide"),t.style.cssText=`flex:1;min-width:0;padding:4px 8px;font-size:12px;background:${f.menuBg};color:${f.text};border:1px solid ${f.menuBorder};border-radius:${k.control};outline:none;`,t.addEventListener("focus",()=>{t.style.borderColor=f.iconActive}),t.addEventListener("blur",()=>{t.style.borderColor=f.menuBorder});const i=e.createElement("span");i.setAttribute("role","status"),i.setAttribute("aria-live","polite"),i.style.cssText=`font-size:12px;color:${f.label};min-width:44px;text-align:center;flex-shrink:0;white-space:nowrap;`;function n(a,u){const d=e.createElement("button");return d.type="button",d.textContent=a,d.setAttribute("aria-label",u),d.disabled=!0,d.style.cssText=`border:none;background:none;cursor:pointer;padding:4px 6px;border-radius:${k.control};font-size:12px;color:${f.label};flex-shrink:0;opacity:0.4;`,d.addEventListener("mouseenter",()=>{d.disabled||(d.style.background=f.bgHover)}),d.addEventListener("mouseleave",()=>{d.style.background="none"}),d}const c=n("\u25B2","Previous match"),o=n("\u25BC","Next match");let l=[],m=-1;function p(){const a=l.length===0;c.disabled=a,o.disabled=a,c.style.opacity=a?"0.4":"",o.style.opacity=a?"0.4":""}function x(){for(const a of l)a.parentNode?.replaceChild(e.createTextNode(a.textContent??""),a);r.normalize(),l=[],m=-1}function g(a){if(l.length===0)return;m>=0&&(l[m].style.outline="none"),m=(a%l.length+l.length)%l.length;const u=l[m];u.style.outline=`2px solid ${f.iconActive}`,u.style.outlineOffset="1px",u.scrollIntoView({behavior:"smooth",block:"center"}),i.textContent=`${m+1}/${l.length}`}function b(a){x();const u=a.trim();if(!u){i.textContent="",p();return}const d=u.toLowerCase(),h=e.createTreeWalker(r,NodeFilter.SHOW_TEXT,{acceptNode(C){const w=C.parentElement;return!w||w.closest("script,style,.wmap-guide-toc")?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}}),L=[];let G;for(;G=h.nextNode();)L.push(G);for(const C of L){const w=C.textContent??"",_=w.toLowerCase();if(!_.includes(d))continue;const A=e.createDocumentFragment();let E=0,v=_.indexOf(d);for(;v!==-1;){v>E&&A.appendChild(e.createTextNode(w.slice(E,v)));const $=e.createElement("mark");$.textContent=w.slice(v,v+u.length),A.appendChild($),l.push($),E=v+u.length,v=_.indexOf(d,E)}E<w.length&&A.appendChild(e.createTextNode(w.slice(E))),C.parentNode?.replaceChild(A,C)}p(),l.length===0?i.textContent="No matches":g(0)}return t.addEventListener("input",()=>b(t.value)),t.addEventListener("keydown",a=>{a.key==="Enter"?(a.preventDefault(),g(m+(a.shiftKey?-1:1))):a.key==="Escape"&&(t.value?(t.value="",b("")):t.blur())}),c.addEventListener("click",()=>g(m-1)),o.addEventListener("click",()=>g(m+1)),s.append(t,i,c,o),s}function J(e,r,s){const t=[...r.querySelectorAll("h2[id]")];if(t.length<2)return;for(const u of r.querySelectorAll("h1[id],h2[id],h3[id],h4[id]"))u.style.scrollMarginTop=`${V}px`;const i=e.createElement("div");i.classList.add("wmap-guide-toc"),i.style.cssText=`position:sticky;top:0;z-index:2;background:${f.menuBg};border-bottom:1px solid ${f.menuBorder};font-family:system-ui,-apple-system,"Segoe UI",sans-serif;`;const n=e.createElement("div");n.style.cssText=`display:flex;align-items:center;gap:4px;height:${I}px;padding:0 12px;box-sizing:border-box;`;const c=e.createElement("span");c.innerHTML='<svg viewBox="0 0 24 24" width="12" height="12" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m6 9 6 6 6-6"/></svg>',c.style.cssText=`display:inline-flex;transition:transform ${B.base};flex-shrink:0;`;const o=e.createElement("button");o.type="button";const l="wmap-guide-toc-panel";o.setAttribute("aria-expanded","false"),o.setAttribute("aria-controls",l),o.style.cssText=`display:flex;align-items:center;gap:6px;border:none;background:none;cursor:pointer;padding:6px 8px;margin:0 -8px 0 -8px;border-radius:${k.control};font-size:13px;font-weight:600;color:${f.text};`;const m=e.createElement("span");m.textContent=`Contents (${t.length})`,o.append(c,m),o.addEventListener("mouseenter",()=>{o.style.background=f.bgHover}),o.addEventListener("mouseleave",()=>{o.style.background="none"});const p=e.createElement("button");p.type="button",p.textContent="\u2191 Top",p.style.cssText=`margin-left:auto;border:none;background:none;cursor:pointer;padding:6px 8px;border-radius:${k.control};font-size:12px;color:${f.label};`,p.addEventListener("mouseenter",()=>{p.style.background=f.bgHover}),p.addEventListener("mouseleave",()=>{p.style.background="none"}),p.addEventListener("click",()=>{a.close(),r.scrollTo({top:0,behavior:"smooth"})}),s?n.append(o,X(e,r),p):n.append(o,p);const x=e.createElement("div");x.id=l,x.hidden=!0,x.style.cssText="padding:2px 12px 12px;max-height:min(60vh,440px);overflow-y:auto;";const g=/^\s*\d+(?:\.\d+)*\.?\s+/;for(const u of r.querySelectorAll("h2[id],h3[id],h4[id]")){const d=u.firstChild;d?.nodeType===Node.TEXT_NODE&&(d.textContent=(d.textContent??"").replace(g,""))}const b=e.createElement("ul");b.setAttribute("role","list"),b.style.cssText="list-style:none;margin:0;padding:0;columns:200px;column-gap:24px;";for(const u of t){const d=e.createElement("li");d.style.cssText="break-inside:avoid;";const h=e.createElement("a");h.href=`#${u.id}`,h.textContent=u.textContent??"",h.style.cssText=`display:block;padding:4px 6px;margin:0 -6px;border-radius:${k.control};font-size:12.5px;color:${f.iconActive};text-decoration:none;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;`,h.addEventListener("mouseenter",()=>{h.style.background=f.bgHover}),h.addEventListener("mouseleave",()=>{h.style.background="none"}),h.addEventListener("click",L=>{L.preventDefault(),a.close(),u.scrollIntoView({behavior:"smooth",block:"start"})}),d.appendChild(h),b.appendChild(d)}x.appendChild(b);const a=U(o,u=>{x.hidden=!u,o.setAttribute("aria-expanded",String(u)),c.style.transform=u?"rotate(180deg)":"none"});i.append(n,x),r.prepend(i)}function O(e,r,s,t,i){const n=r,c=n.__wmapDemoApi;n.__wmapDemoApi=t;const o=e.createElement("div");return o.classList.add("wmap-guide-content"),o.innerHTML=s,J(e,o,i),{content:o,restoreApi:()=>{n.__wmapDemoApi===t&&(n.__wmapDemoApi=c)}}}function M(e,r){const s=r,t=e.querySelector("script");if(t){const i=e.ownerDocument.createElement("script");i.textContent=t.textContent,e.appendChild(i);const n=e.querySelector(".wmap-guide");return n&&s.__wmapPopulateGuideDemos?.(n),s.__wmapDestroyGuideDemos}}function K(e,r,s,t,i){const n=t?.ownerDocument??document,c=n.defaultView??window,{content:o,restoreApi:l}=O(n,c,r,s,!0);Object.assign(o.style,{flex:"1",overflow:"auto",minHeight:"0",minWidth:"0"});let m,p;const x=j({title:e,anchor:t,ownerDocument:n,printable:!0,onMaximizeChange:g=>{o.style.setProperty("--wmap-guide-reading-width",g?"1000px":"720px")},onClose:()=>{y===p&&(y=null),m?.(),l()}});return x.contentWrap.appendChild(o),m=M(o,c),D(o,i),p={close:x.close,show:g=>x.box.isConnected?(x.bringToFront(),D(o,g,!0),!0):!1}}function Q(e,r,s,t,i){const n=e.document;n.title=r,Object.assign(n.documentElement.style,{height:"100%"}),Object.assign(n.body.style,{margin:"0",height:"100vh",overflow:"hidden",display:"flex",flexDirection:"column",fontFamily:S.family}),z(document.documentElement,n.documentElement);const c=q(document.documentElement,n.documentElement),{content:o,restoreApi:l}=O(n,e,s,t,!1);Object.assign(o.style,{flex:"1",overflow:"auto",minHeight:"0",minWidth:"0"}),n.body.appendChild(o);const m=M(o,e);D(o,i);let p=!1;const x=()=>{if(!p){p=!0,clearInterval(g),c();try{m?.()}catch{}l(),y===b&&(y=null)}},g=setInterval(()=>{e.closed&&x()},400);e.addEventListener("pagehide",x);const b={close:()=>{e.closed||e.close(),x()},show:a=>e.closed?(x(),!1):(e.focus(),D(o,a,!0),!0)};return b}export function openUserGuideWindow(e,r,s,t,i){if(y&&i&&y.show(i))return;y&&(y.close(),y=null);const n=s?.title??"Wafer Map \u2014 User Guide",c=(s?.html??"")+r,l=(t?.ownerDocument.defaultView??window).open("","_blank","width=800,height=820");y=l?Q(l,n,c,e,i):K(n,c,e,t,i)}export function openWaferMapGuide(e,r){N(e,r)}function N(e,r,s){Promise.all([import("./userGuideHtml.js"),import("./renderWaferMap.js"),import("./renderWaferGallery.js")]).then(([t,i,n])=>{openUserGuideWindow({buildWaferMap:F,renderWaferMap:i.renderWaferMap,renderWaferGallery:n.renderWaferGallery,analyzeWaferMap:H},t.USER_GUIDE_HTML,e,r,s)})}export function openReportModal(e,r){const s=r?.ownerDocument??document,t=s.createElement("iframe");t.srcdoc=e,t.title="Summary report",Object.assign(t.style,{border:"0",width:"100%",flex:"1",minHeight:"0",background:"#fff"});const i=s.createElement("div");Object.assign(i.style,{display:"flex",justifyContent:"flex-end",padding:"6px 14px",borderBottom:`1px solid ${f.menuBorder}`,flexShrink:"0"});const n=s.createElement("button");n.type="button",R(n,"bare"),n.textContent="Open as full page \u2197",Object.assign(n.style,{border:"none",background:"none",color:f.iconActive,cursor:"pointer",fontSize:S.body,textDecoration:"underline",padding:"0"}),n.addEventListener("click",()=>W(e)),i.appendChild(n);const c=s.defaultView??window,o=m=>{if(m.source!==t.contentWindow)return;const p=m.data?.wmapFinding;typeof p=="string"&&r?.onFinding?.(p,l)};r?.onFinding&&c.addEventListener("message",o);const l=P({title:"Summary report",anchor:r?.anchor,ownerDocument:s,printable:()=>t.contentWindow?.print(),onClose:()=>c.removeEventListener("message",o)});return l.contentWrap.style.flexDirection="column",l.contentWrap.appendChild(i),l.contentWrap.appendChild(t),l}
@@ -13,7 +13,7 @@ export const ICONS={aggr:'<svg viewBox="0 0 24 24" width="16" height="16" fill="
13
13
  <path d="M3 12 c0 2.5 4 4 9 4 s9-1.5 9-4" />
14
14
 
15
15
  <path d="M3 17 c0 2.5 4 4 9 4 s9-1.5 9-4" />
16
- </svg>`,orient:'<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><polygon points="16.24 7.76 14.12 14.12 7.76 16.24 9.88 9.88 16.24 7.76" fill="currentColor" stroke="none"/></svg>',overlays:'<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M2 12s3.6-7 10-7 10 7 10 7-3.6 7-10 7-10-7-10-7z"/><circle cx="12" cy="12" r="3"/></svg>',palette:'<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="m14.622 17.897-10.68-2.913"/><path d="M18.376 2.622a1 1 0 1 1 3.002 3.002L17.36 9.643a.5.5 0 0 0 0 .707l.944.944a2.41 2.41 0 0 1 0 3.408l-.944.944a.5.5 0 0 1-.707 0L8.354 7.348a.5.5 0 0 1 0-.707l.944-.944a2.41 2.41 0 0 1 3.408 0l.944.944a.5.5 0 0 0 .707 0z"/><path d="M9 8c-1.804 2.71-3.97 3.46-6.583 3.948a.507.507 0 0 0-.302.819l7.32 8.883a1 1 0 0 0 1.185.204C12.735 20.405 16 16.792 16 15"/></svg>',pan:'<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M12 2v20"/><path d="m15 19-3 3-3-3"/><path d="m19 9 3 3-3 3"/><path d="M2 12h20"/><path d="m5 9-3 3 3 3"/><path d="m9 5 3-3 3 3"/></svg>',print:'<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2"/><path d="M6 9V3a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v6"/><rect x="6" y="14" width="12" height="8" rx="1"/></svg>',quadrants:'<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"><circle cx="12" cy="12" r="9"/><line x1="12" y1="3" x2="12" y2="21"/><line x1="3" y1="12" x2="21" y2="12"/></svg>',reset:'<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8"/><path d="M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"/></svg>',reticle:'<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="8" height="6" rx="0.5"/><rect x="13" y="3" width="8" height="6" rx="0.5"/><rect x="3" y="11" width="8" height="6" rx="0.5"/><rect x="13" y="11" width="8" height="6" rx="0.5"/><rect x="3" y="19" width="8" height="2" rx="0.5" stroke-dasharray="2 1"/><rect x="13" y="19" width="8" height="2" rx="0.5" stroke-dasharray="2 1"/></svg>',rings:'<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"><circle cx="12" cy="12" r="9"/><circle cx="12" cy="12" r="5.5"/><circle cx="12" cy="12" r="2" fill="currentColor" stroke="none"/></svg>',rotateCW:'<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8"/><path d="M21 3v5h-5"/></svg>',specRange:'<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M5 4 L5 20"/><path d="M5 4 L8 4"/><path d="M5 20 L8 20"/><path d="M19 4 L19 20"/><path d="M19 4 L16 4"/><path d="M19 20 L16 20"/><path d="M5 12 L19 12" stroke-dasharray="3 2"/></svg>',uncollapse:'<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="m7 15 5 5 5-5"/><path d="m7 9 5-5 5 5"/></svg>',wafer:`<svg
16
+ </svg>`,more:'<svg viewBox="0 0 24 24" width="16" height="16" fill="currentColor" stroke="none"><circle cx="5" cy="12" r="1.9"/><circle cx="12" cy="12" r="1.9"/><circle cx="19" cy="12" r="1.9"/></svg>',orient:'<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><polygon points="16.24 7.76 14.12 14.12 7.76 16.24 9.88 9.88 16.24 7.76" fill="currentColor" stroke="none"/></svg>',overlays:'<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M2 12s3.6-7 10-7 10 7 10 7-3.6 7-10 7-10-7-10-7z"/><circle cx="12" cy="12" r="3"/></svg>',palette:'<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="m14.622 17.897-10.68-2.913"/><path d="M18.376 2.622a1 1 0 1 1 3.002 3.002L17.36 9.643a.5.5 0 0 0 0 .707l.944.944a2.41 2.41 0 0 1 0 3.408l-.944.944a.5.5 0 0 1-.707 0L8.354 7.348a.5.5 0 0 1 0-.707l.944-.944a2.41 2.41 0 0 1 3.408 0l.944.944a.5.5 0 0 0 .707 0z"/><path d="M9 8c-1.804 2.71-3.97 3.46-6.583 3.948a.507.507 0 0 0-.302.819l7.32 8.883a1 1 0 0 0 1.185.204C12.735 20.405 16 16.792 16 15"/></svg>',pan:'<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M12 2v20"/><path d="m15 19-3 3-3-3"/><path d="m19 9 3 3-3 3"/><path d="M2 12h20"/><path d="m5 9-3 3 3 3"/><path d="m9 5 3-3 3 3"/></svg>',print:'<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2"/><path d="M6 9V3a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v6"/><rect x="6" y="14" width="12" height="8" rx="1"/></svg>',quadrants:'<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"><circle cx="12" cy="12" r="9"/><line x1="12" y1="3" x2="12" y2="21"/><line x1="3" y1="12" x2="21" y2="12"/></svg>',reset:'<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8"/><path d="M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"/></svg>',reticle:'<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="8" height="6" rx="0.5"/><rect x="13" y="3" width="8" height="6" rx="0.5"/><rect x="3" y="11" width="8" height="6" rx="0.5"/><rect x="13" y="11" width="8" height="6" rx="0.5"/><rect x="3" y="19" width="8" height="2" rx="0.5" stroke-dasharray="2 1"/><rect x="13" y="19" width="8" height="2" rx="0.5" stroke-dasharray="2 1"/></svg>',rings:'<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"><circle cx="12" cy="12" r="9"/><circle cx="12" cy="12" r="5.5"/><circle cx="12" cy="12" r="2" fill="currentColor" stroke="none"/></svg>',rotateCW:'<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8"/><path d="M21 3v5h-5"/></svg>',specRange:'<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M5 4 L5 20"/><path d="M5 4 L8 4"/><path d="M5 20 L8 20"/><path d="M19 4 L19 20"/><path d="M19 4 L16 4"/><path d="M19 20 L16 20"/><path d="M5 12 L19 12" stroke-dasharray="3 2"/></svg>',uncollapse:'<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="m7 15 5 5 5-5"/><path d="m7 9 5-5 5 5"/></svg>',wafer:`<svg
17
17
  viewBox="0 0 24 24"
18
18
  width="16"
19
19
  height="16"
@@ -5,11 +5,15 @@ import { type FacetCuration, type FacetItem } from '../stats/facets.js';
5
5
  import { type TestDef } from '../renderer/buildWaferMap.js';
6
6
  import type { WaferMapDisplayItem } from './renderWaferGallery.js';
7
7
  import { type PlotStore } from './plotStore.js';
8
- import type { PlotSpec } from '../stats/plotSpec.js';
8
+ import type { PlotFilter, PlotSpec } from '../stats/plotSpec.js';
9
+ import type { SavedFilter } from '../stats/filterFile.js';
10
+ import { type PageFilterController } from './pageFilter.js';
9
11
  import type { BinColors } from '../renderer/binColors.js';
10
12
  import { type SaveImageHandler, type SaveTextHandler } from './toolbar.js';
13
+ import type { RenderableWaferMap } from './renderWaferMap.js';
11
14
  import type { SweepSpec } from '../stats/sweep.js';
12
15
  import { type AxisPrefs } from './charts/chartShell.js';
16
+ import { type SynthesisTarget } from '../stats/synthesis.js';
13
17
  export type InsightsView = 'overview' | 'distributions' | 'correlation' | 'sweeps' | 'data' | 'plot';
14
18
  /** Public option shape for `RenderOptions.insights`/`GalleryOptions.insights`. */
15
19
  export interface InsightsOptions {
@@ -23,7 +27,7 @@ export interface InsightsOptions {
23
27
  * (a gallery always has one); `false` opts out.
24
28
  */
25
29
  enabled?: boolean;
26
- /** Which sub-tab is shown first. Default 'overview'. `'sweeps'` opens the Plot tab, where sweeps are drawn. */
30
+ /** Which sub-tab is shown first. Default 'overview'. `'sweeps'` opens the My plots tab, where sweeps are drawn. */
27
31
  defaultView?: InsightsView;
28
32
  /**
29
33
  * @deprecated Sweeps are plots now: give them in `plots` as sweep plots, or read a sweeps file with
@@ -71,6 +75,30 @@ export interface InsightsOptions {
71
75
  * the browser's own file input; a desktop host passes its native dialog.
72
76
  */
73
77
  onPickPlotsFile?: () => Promise<string | null>;
78
+ /**
79
+ * The page filter to start with: conditions the wafers and dies of the gallery, the map and every Insights tab must
80
+ * meet (one split, the edge ring, a range of a test), with `off` to keep them unapplied. It is one filter for all of
81
+ * them: a wafer condition removes a wafer's card, a die condition draws the dies it drops dimmed on a map. It is view
82
+ * state, like Group by: the reader edits it from the Filter button, it is shown above the view whenever it exists, and
83
+ * it is never written into a plots file. Keep it from `onFilterChange` to restore it.
84
+ */
85
+ filter?: PlotFilter;
86
+ /** Called with the filter after the reader applies, switches, or removes it (`undefined` once removed). */
87
+ onFilterChange?: (filter: PlotFilter | undefined) => void;
88
+ /**
89
+ * Filters the reader has saved under a name, to start with (`SavedFilter`: `id`, `name`, `conditions`). The Filter
90
+ * window lists them to load into the editor, and Export… / Import… move them as a `wafermap-filters` file
91
+ * (`readFiltersFile` / `writeFiltersFile`). Read leniently, like a plots file: one that cannot be read is left out and
92
+ * logged. Keep them from `onSavedFiltersChange`.
93
+ */
94
+ savedFilters?: SavedFilter[];
95
+ /** Called with the whole list after the reader saves, deletes or imports a filter. */
96
+ onSavedFiltersChange?: (filters: SavedFilter[]) => void;
97
+ /**
98
+ * Choose a filters file to import, resolving to its text, or `null` when cancelled. Without it the browser's own file
99
+ * input is used; a desktop host passes its native dialog, as with `onPickPlotsFile`.
100
+ */
101
+ onPickFiltersFile?: () => Promise<string | null>;
74
102
  /**
75
103
  * Open the Insights view on mount instead of starting on the map/grid.
76
104
  * Default false — the tab is offered, the map is what you see first.
@@ -150,6 +178,20 @@ export interface InsightsTabDeps {
150
178
  plots?: PlotSpec[];
151
179
  onPlotsChange?: (plots: PlotSpec[]) => void;
152
180
  onPickPlotsFile?: () => Promise<string | null>;
181
+ /**
182
+ * Leaves Insights and shows a "What stands out" item on the map, as its row in the Summary panel does: a finding's dies,
183
+ * or a test's value map with the dies it fails. Omitted ⇒ the Worth a look cards offer no Show on map.
184
+ */
185
+ showOnMap?: (target: SynthesisTarget) => void;
186
+ /** The PAT card's Map the verdicts: back to the maps, coloured by PAT verdict. */
187
+ showPatMap?: () => void;
188
+ /** See `InsightsOptions.filter` and `onFilterChange`. */
189
+ filter?: PlotFilter;
190
+ onFilterChange?: (filter: PlotFilter | undefined) => void;
191
+ /** Whether the tab row carries its own Filter button. A host whose chrome already has one (the gallery, the map) turns it off, so the button keeps one place. Default true. */
192
+ showFilterButton?: boolean;
193
+ /** The page filter the maps and the gallery share; created from `filter` and `onFilterChange` when omitted. */
194
+ pageFilter?: PageFilterController;
153
195
  /** Opens the user guide. Rendered as an icon at the end of the tab row —
154
196
  * while Insights is showing, the map toolbar is hidden (it held only a
155
197
  * back-to-gallery button, which the back tab already provides, and this
@@ -192,6 +234,11 @@ export interface InsightsTabHandle {
192
234
  destroy: () => void;
193
235
  /** Adopt axis settings set from outside (the host's `setOptions`), in every chart. */
194
236
  setAxisPrefs: (prefs: AxisPrefs) => void;
237
+ /**
238
+ * Opens the Overview at the Worth a look card of the item `key` names (`synthesisKey`), scrolled into view: the Summary
239
+ * panel's Chart link. False when there is no such card (the item has none, or the list is hidden while narrowed).
240
+ */
241
+ showWorthCard: (key: string) => boolean;
195
242
  }
196
243
  type Item = FacetItem & {
197
244
  dies: Die[];
@@ -208,6 +255,9 @@ type Item = FacetItem & {
208
255
  * "Wafer N (no ID)" that `label` falls back to, which in a chart title would
209
256
  * read as an ID. */
210
257
  identity?: string;
258
+ /** The wafer's own result as the host handed it in: what a map drawn from this wafer's dies (a difference map) is
259
+ * rendered on, so it keeps the wafer's geometry and orientation. */
260
+ source?: RenderableWaferMap;
211
261
  };
212
262
  /** One wafer (or the lot's single stand-in) as the Insights views see it. */
213
263
  export type InsightsItem = Item;
@@ -1 +1 @@
1
- import{MEAN_WAFER_YIELD_LABEL as qe}from"../stats/presentation.js";import{buildFacetTable as Ke,facetValueOf as Qe,FACET_NONE_VALUE as Xe,DEFAULT_FACET_CURATION as Je}from"../stats/facets.js";import{mergeTestDefs as Se}from"../stats/mergeTestDefs.js";import{isParametricTest as xe}from"../renderer/buildWaferMap.js";import{dieFailsTest as Ze}from"../stats/testPassRate.js";import{fmt as ke}from"../renderer/fmt.js";import{testLabel as et}from"../renderer/testLabel.js";import{waferDisplayLabel as tt,waferIdentityLabel as nt}from"../core/waferLabel.js";import{waferPopulation as ot}from"./chartPopulation.js";import{openDrilldownMenu as le}from"./drilldown.js";import{plotStoreFor as it}from"./plotStore.js";import{itemPassBins as rt,passBinsLabel as Te}from"../core/passBins.js";import{NO_DATA_FILL as ve}from"../renderer/colorMap.js";import{describeWaferPopulation as at,populationStat as st}from"../stats/population.js";import{LEADING as lt,ALPHA as dt,SPACE as T,EDGE_GUTTER as de,FONT as F,CLR as $,RADIUS as ct,SHADOW as ut,controlStyle as pt,wireControlHover as ce,wireTooltip as ft}from"./toolbar.js";import{ICONS as mt}from"./icons.js";import{renderCapabilityPanel as bt}from"./charts/capability.js";import{renderBoxplotPanel as ht}from"./charts/boxplot.js";import{renderTrendPanel as gt}from"./charts/trend.js";import{renderHistogramPanel as yt}from"./charts/histogram.js";import{renderCorrelationPanel as wt}from"./charts/correlation.js";import{renderScatterPanel as Ct}from"./charts/scatter.js";import{renderBarPanel as De}from"./charts/barPanel.js";import{renderBinClusterPanel as St}from"./charts/binCluster.js";import{renderTestPassRatePanel as xt}from"./charts/testPassRate.js";import{QUANTITY as kt}from"./charts/palette.js";import{cardFrameStyle as Tt,makeChartGridWrap as ue,makeLabeledSelect as vt,makeLinkedGroupSelect as Dt}from"./charts/chartShell.js";import{buildYieldData as J,buildYieldDataCombined as Be}from"../stats/yield.js";import{buildBinParetoData as Bt}from"../stats/binPareto.js";import{buildLotTestSectionSteps as $t,buildLotFunctionalSection as Lt,buildMetadataStripBox as Pt}from"./summaryPanel.js";import{runChunked as At}from"./chunked.js";import{buildRegionYieldData as pe,buildRingRegions as $e,buildQuadrantRegions as Le,buildReticlePositionRegions as It,diesInRegion as Et}from"../stats/regions.js";import{renderDataSection as Ot}from"./dataTab.js";import{sourceFromDies as Rt}from"./plotItems.js";import{renderRegionYieldDiagram as fe}from"./charts/regionYieldDiagram.js";const Wt=[{key:"overview",label:"Overview"},{key:"distributions",label:"Distributions"},{key:"correlation",label:"Correlation"}],Mt={key:"data",label:"Data"},Ft={key:"plot",label:"Plot"};export function createInsightsTab(v){const{getItems:Pe,getLotStats:me,getBinColors:be,getRingCount:N,onSaveImage:k,onSaveText:O,openWafer:R,focusTest:Z,locateDie:V}=v,he={...Je,...v.attributes},Ae=v.showMetadataStrip??!0,z=v.contentInset??de,f=v.ownerDocument??document,Y=f.createElement("div");Object.assign(Y.style,{display:"none",flexDirection:"column",width:"100%",paddingTop:"0"});const Ie=de,j=f.createElement("div");Object.assign(j.style,{paddingLeft:Ie});const A=f.createElement("div");Object.assign(A.style,{display:"flex",gap:T.xs,alignItems:"center",background:$.menuBg,border:`1px solid ${$.menuBorder}`,borderRadius:ct.container,boxShadow:ut.panel,padding:`0 ${T.lg}`,marginBottom:T.lg,marginLeft:z,marginRight:z}),A.setAttribute("role","tablist"),A.addEventListener("keydown",e=>{if(e.key!=="ArrowLeft"&&e.key!=="ArrowRight")return;const n=Array.from(A.querySelectorAll('[role="tab"]')),r=n.indexOf(f.activeElement);if(r===-1)return;e.preventDefault();const l=n[(r+(e.key==="ArrowRight"?1:-1)+n.length)%n.length];l.focus(),l.click()});const U=f.createElement("div");Object.assign(U.style,{display:"flex",flexDirection:"column",gap:T.lg,marginTop:"0",paddingLeft:z,paddingRight:z}),Y.appendChild(j),Y.appendChild(A),Y.appendChild(U);const Ee=[...Wt,Mt,Ft],q=v.plotStore??it(v);let L=v.defaultView==="sweeps"?"plot":v.defaultView??"overview",M,ge="statistics",ye="wide",I=null,E=null,K=v.initialAxisPrefs??{includeLimits:void 0,clipOutliers:!1,limits:"both"};const ee=new Map,te=(e,n,r=!1)=>{K=e;for(const l of ee.values())for(const i of l)i!==n&&i.setAxisPrefs(e);r||v.onAxisPrefsChange?.(e)},ne=e=>{E!==e&&(E=e,H())};let G=new Map;function we(){for(const e of G.values())e.destroy();G=new Map}function oe(e,n,r){R?.(e,n,r)}function ie(e){return(n,r,l)=>{const i=e.find(c=>c.waferIndex===n);if(!i)return;l.preventDefault();const u=ot(i.dies,{waferLabel:i.identity,testDefs:i.testDefs,activeTest:r??I??void 0,waferIndex:n,wafer:i.wafer,passBins:i.passBins,ringCount:N()});le({x:l.clientX,y:l.clientY},l.target,u,{plots:q,onSaveImage:k,onSaveText:O,onLocateDie:V})}}function Q(e,n,r,l,i){Ce({x:e.clientX,y:e.clientY},e.target,n,r,l,i)}function Ce(e,n,r,l,i,u){const c=Rt(r.map(s=>({label:s.identity??s.label,dies:s.dies,waferIndex:s.waferIndex,wafer:s.wafer,passBins:s.passBins,ringCount:N()})),l,i,Se(r).defs,u);c&&le(e,n,c,{plots:q,onSaveImage:k,onSaveText:O,onLocateDie:V})}function re(e){return R?{open:(n,r)=>oe(n,`Wafer ${e.find(l=>l.waferIndex===n)?.label??n}`,r)}:Z&&e.length===1?{open:(n,r)=>Z(r),label:"show this test on the map"}:null}function Oe(){return Pe().map((e,n)=>e==null?null:{metadata:e.wafer.metadata??void 0,dies:e.dies,wafer:e.wafer,label:tt(e,n),identity:nt(e),waferIndex:n,passBins:rt(e),statsSummary:e.statsSummary,testDefs:e.testDefs}).filter(e=>e!=null)}function Re(e,n){Object.assign(e.style,{background:"none",border:"none",borderBottom:n?`2px solid ${$.iconActive}`:"2px solid transparent",color:n?$.iconActive:$.label,fontWeight:n?"700":"500",fontSize:F.body,padding:`${T.sm} ${de} ${T.md}`,cursor:"pointer",marginBottom:"-1px"})}function We(e,n){const r=f.createElement("button");r.type="button",r.textContent=n;const l=e===L;return Re(r,l),r.dataset.on=l?"true":"false",ce(r,"bare"),r.dataset.wmapInsightsTab=e,r.setAttribute("role","tab"),r.setAttribute("aria-selected",l?"true":"false"),r.tabIndex=l?0:-1,r.addEventListener("click",()=>{L!==e&&(L=e,H({keepSections:!0}))}),r}function Me(e,n,r,l=!0){const i=ue(f),u=be();let c="label";const s=r??"group",h=Te(e.map(p=>p.passBins)),d=me?.(),m=new Map(d?.lotYieldSeries.map(p=>[p.waferIndex,p.yieldPercent])),a=p=>({...p,label:p.label.replace(/\s*·\s*\d+(\.\d+)?%$/,""),yieldPercent:m.get(p.waferIndex),key:p.waferIndex}),b=e.map(a),y=n?.map(p=>({key:p.key,items:p.items.map(a)})),w=()=>y?Be(y,c):J(b,c),t={title:n?`Yield by ${s} (pass: ${h})`:`Yield by wafer (pass: ${h})`,data:w(),selfControl:{current:c,options:[["yield","Sort: yield"],["label",n?`Sort: ${s}`:"Sort: wafer ID"]],onChange:p=>(c=p,{data:w()})},barColor:()=>kt,valueLabel:p=>`${p.percent.toFixed(1)}%`,reference:p=>{if(p.length<3)return null;const S=p.map(P=>P.percent).sort((P,_)=>P-_),B=S.length%2?S[(S.length-1)/2]:(S[S.length/2-1]+S[S.length/2])/2;return{value:B,label:`median ${B.toFixed(1)}%`}},drill:y?{onOpenGroup:p=>{const S=y.find(B=>B.key===p.label)?.items??[];return{data:J(S,c),title:`Yield by wafer \u2014 ${s}: ${p.label} (pass: ${h})`}},onBack:()=>({data:w(),title:`Yield by ${s} (pass: ${h})`}),groupLabelText:s}:void 0,onOpen:R?p=>{typeof p.key=="number"&&oe(p.key,`Wafer ${p.label}`)}:void 0,onWaferContextMenu:ie(e),ownerDocument:f};let o=null;if(l&&(o=De(t,k),o.card.style.minHeight="360px",i.appendChild(o.card)),n){const p=St({title:"Hard bin pareto",groups:n.map(S=>({key:S.key,items:S.items.map(B=>({dies:B.dies,hardBinCounts:B.statsSummary?.stats.hardBinCounts,softBinCounts:B.statsSummary?.stats.softBinCounts}))})),onSelectBin:(S,B)=>{const P=n.find(X=>X.key===S.groupKey);if(!P)return;const _=S.binType==="hbin"?"hard":"soft";Q(B,P.items,`in ${_} bin ${S.bin} of ${S.groupKey}`,X=>(S.binType==="hbin"?X.hbin:X.sbin)===S.bin)},onSaveImage:k,ownerDocument:f});return p.card.style.minHeight="360px",i.appendChild(p.card),{card:i,destroy:()=>{o?.destroy(),p.destroy()}}}let g="hbin";const C=p=>p===void 0?ve:(g==="hbin"?u.hard:u.soft).get(p)??ve,x=e.map(p=>({dies:p.dies,hardBinCounts:p.statsSummary?.stats.hardBinCounts,softBinCounts:p.statsSummary?.stats.softBinCounts})),W=()=>Bt(x,g),se={title:"Hard bin pareto",data:W(),selfControl:{current:g,options:[["hbin","Hard bins","The physical sort result: where the part goes on the handler"],["sbin","Soft bins","The test program\u2019s failure category: many soft bins can map to one hard bin"]],onChange:p=>(g=p,{data:W(),title:`${g==="hbin"?"Hard":"Soft"} bin pareto`})},barColor:p=>C(p.binCode),onSelectBar:(p,S)=>{const B=g==="hbin"?"hard":"soft",P=p.binCode;Q(S,e,P===void 0?`with no ${B} bin recorded`:`in ${B} bin ${P}`,_=>(g==="hbin"?_.hbin:_.sbin)===P)},selectLabel:"chart or tabulate its dies",ownerDocument:f},D=De(se,k);return D.card.style.minHeight="360px",i.appendChild(D.card),{card:i,destroy:()=>{o?.destroy(),D.destroy()}}}function ae(){const e=f.createElement("div");return e.dataset.wmapChartCard="1",Object.assign(e.style,{...Tt(),display:"flex",flexDirection:"column",gap:T.lg,minWidth:"0"}),e}function Fe(e){if(j.innerHTML="",j.style.marginBottom="0",!Ae)return;const n=Pt(e.map(r=>({metadata:r.metadata})),void 0,{facetableOnly:!1});n&&(n.style.marginBottom="0",j.appendChild(n),j.style.marginBottom=T.xs)}function Ne(e,n,r,l){if(!e.length)return{elements:[],destroy:()=>{}};const i=e.map(t=>t.wafer),u=e.map(t=>t.dies),c=N(),s=[],h=[],m=xt({groups:(l??[{key:"",items:e}]).map(t=>({key:t.key,items:t.items.map(o=>({dies:o.dies,testSpecYield:o.statsSummary?.stats.testSpecYield,functionalYield:o.statsSummary?.stats.functionalYield}))})),testDefs:r,onSaveImage:k,onSelectTest:(t,o)=>{const g=r.find(C=>C.testNumber===t.testNumber);g&&Q(o,e,`failing ${t.label}`,C=>Ze(C,g,t.kind)===!0,xe(g)?t.testNumber:void 0)},ownerDocument:f});m.card.style.minHeight="300px",s.push(m.card),h.push(m.destroy);const a=t=>(o,g)=>{const C=new Set;for(const x of e)for(const W of Et(x.dies,x.wafer,c,o.key,t))C.add(W);Q(g,e,`in ${o.label}`,x=>C.has(x))},b=pe(u,i,c,t=>e[t].passBins,$e);if(b.length){const t=fe({title:"Ring yield",mode:"ring",rows:b,onSelectRegion:a($e),onSaveImage:k,ownerDocument:f});s.push(t.card),h.push(t.destroy)}const y=pe(u,i,c,t=>e[t].passBins,Le);if(y.length){const t=fe({title:"Quadrant yield",mode:"quadrant",rows:y,onSelectRegion:a(Le),onSaveImage:k,ownerDocument:f});s.push(t.card),h.push(t.destroy)}const w=i.find(t=>t.reticle!==void 0)?.reticle;if(w){const t=(g,C)=>It(g,C.reticle),o=pe(u,i,c,g=>e[g].passBins,t);if(o.length){const g=fe({title:"Reticle cell yield",mode:"reticleCell",rows:o,grid:{width:Math.max(1,Math.floor(w.width)),height:Math.max(1,Math.floor(w.height))},onSelectRegion:a(t),onSaveImage:k,ownerDocument:f});s.push(g.card),h.push(g.destroy)}}return{elements:s,destroy:()=>{for(const t of h)t()}}}function Ye(e,n,r){if(!e.length)return{cards:[],destroy:()=>{}};const l=e.map(a=>a.dies),i=e.flatMap(a=>a.dies),u=e.map(a=>a.statsSummary),c=u.every(a=>a!==void 0)?u:void 0,s=[],h=[];let d=null;if(n.length){const a=ae();let b=null;const y=At($t(i,n,void 0,c,O,l.map(w=>({dies:w})),void 0,"full"),{onDone:w=>{b=w,a.removeAttribute("aria-busy"),w?a.replaceChildren(w):a.remove()}});if(y.done)b&&(d=a);else{const w=f.createElement("div");w.textContent="Computing test statistics\u2026",Object.assign(w.style,{color:$.label,fontSize:F.body}),a.setAttribute("aria-busy","true"),a.appendChild(w),d=a,s.push(()=>y.cancel())}}let m=null;if(r.length){const a=Lt(i,r,c,O);if(a){const b=ae();b.appendChild(a),m=b}}return d&&h.push(d),m&&h.push(m),{cards:h,destroy:()=>{for(const a of s)a()}}}function je(e){const n=Te(e.map(d=>d.passBins)),r=e.length===1,l=e[0],i=ae();Object.assign(i.style,{flexDirection:"row",flexWrap:"wrap",gap:T.md});const u=d=>{const m=d.lastElementChild;return m&&Object.assign(m.style,{borderRight:"none",paddingRight:"0",marginRight:"0"}),d};function c(d,m,a){const b=f.createElement("div");Object.assign(b.style,{display:"flex",alignItems:"baseline",gap:T.sm,paddingRight:T.xxl,marginRight:T.md,borderRight:`1px solid ${$.menuBorder}`});const y=f.createElement("div");y.textContent=d,Object.assign(y.style,{fontSize:F.heading,fontWeight:"700",color:$.value,lineHeight:lt.tight});const w=f.createElement("div");if(w.textContent=m,Object.assign(w.style,{fontSize:F.body,color:$.label}),b.append(y,w),a){const t=f.createElement("div");t.textContent=a,Object.assign(t.style,{fontSize:F.meta,color:$.label,opacity:dt.muted}),b.appendChild(t)}return b}if(r){const d=J([{...l,key:l.waferIndex}])[0]?.percent;return d!==void 0&&i.appendChild(c(`${d.toFixed(1)}%`,`Yield \xB7 pass: ${n}`)),i.appendChild(c(String(l.dies.length),"Total dies")),u(i)}i.appendChild(c(String(e.length),"Wafers"));const s=J(e.map(d=>({...d,key:d.waferIndex}))).map(d=>d.percent).filter(d=>Number.isFinite(d));if(s.length){const d=s.reduce((b,y)=>b+y,0)/s.length,m=Be([{key:"all",items:e.map(b=>({...b,key:b.waferIndex}))}])[0]?.percent,a=m!==void 0&&m.toFixed(1)!==d.toFixed(1);i.appendChild(c(`${d.toFixed(1)}%`,`${qe} \xB7 pass: ${n}`,a?`${m.toFixed(1)}% by dies`:void 0))}const h=e.map(d=>d.statsSummary);if(h.every(d=>d!==void 0)){const d=h.reduce((a,b)=>a+b.stats.analyzedDies,0),m=h.reduce((a,b)=>a+b.stats.excludedDies,0);i.appendChild(c(d.toLocaleString(),"Dies analysed",m?`${m.toLocaleString()} excluded`:void 0))}else i.appendChild(c(e.reduce((d,m)=>d+m.dies.length,0).toLocaleString(),"Total dies"));return u(i)}function Ge(e,n,r,l,i){const u=f.createElement("div");Object.assign(u.style,{display:"flex",flexDirection:"column",gap:T.lg});const c=e.length===1&&!l;e.length&&!l&&u.appendChild(je(e));const s=Me(e,l,i,!c);u.appendChild(s.card);const h=Ne(e,n,r,l);for(const d of h.elements)s.card.appendChild(d);return u.appendChild(He()),{card:u,destroy:()=>{s.destroy(),h.destroy()}}}function He(){const e=f.createElement("div");Object.assign(e.style,{fontSize:F.body,color:$.label});const n=f.createElement("button");return n.type="button",n.textContent="Data tab",n.dataset.wmapOpenDataTab="1",Object.assign(n.style,{border:"none",background:"none",padding:"0",cursor:"pointer",font:"inherit",color:$.iconActive,textDecoration:"underline"}),ce(n,"bare"),n.addEventListener("click",()=>{L="data",H({keepSections:!0})}),e.append("Test statistics, every die and every wafer as tables, with CSV export: see the ",n,"."),e}function _e(e,n,r,l){const i=f.createElement("div");i.style.width="100%";let u,c=!1;return import("./plotTab.js").then(({createPlotSection:s})=>{if(c)return;const h=s({doc:f,store:q,items:e,testDefs:n,ringCount:N(),attributes:v.attributes,groupBy:r,groupLabel:l,onSaveImage:k,onSaveText:O,openWafer:R?(d,m,a)=>R(d,m,a):void 0,focusTest:Z,locateDie:V,pickPlotsFile:v.onPickPlotsFile});i.appendChild(h.card),u=h}),{card:i,destroy:()=>{c=!0,u?.destroy()}}}function Ve(e,n,r,l,i){const u=me?.(),c=()=>{G.get("data")?.destroy(),G.delete("data"),H({keepSections:!0})};return Ot({doc:f,items:e,testDefs:n,allTestDefs:r,groups:l,groupLabelText:i,ringCount:N(),attributes:v.attributes,yieldByWaferIndex:new Map(u?.lotYieldSeries.map(s=>[s.waferIndex,s.yieldPercent])),onSaveText:O,onLocateDie:V,onOpenWafer:R?(s,h)=>R(s,h):void 0,buildStatistics:s=>Ye(s,n,r),view:ge,onViewChange:s=>{ge=s,c()},diesLayout:ye,onDiesLayoutChange:s=>{ye=s}})}function ze(e,n,r,l){const i=ue(f),u=re(e),c=t=>o=>te(o,t()),s=t=>({...t,testStats:t.statsSummary?.stats.perTestStats}),h=e.map(s),d=r?.map(t=>({key:t.key,items:t.items.map(s)})),m=ht({title:"Test value distribution",axisPrefs:K,onAxisPrefsChange:c(()=>m),onTestChange:t=>y(t),selectedTestNumber:I??void 0,items:h,testDefs:n,groups:d,groupLabelText:l,onSaveImage:k,onGroupChange:t=>ne(t),onOpen:u?.open,openActionLabel:u?.label,onWaferContextMenu:ie(e),ownerDocument:f}),a=yt({title:"Value histogram",axisPrefs:K,onAxisPrefsChange:c(()=>a),onTestChange:t=>y(t),selectedTestNumber:I??void 0,items:e,testDefs:n,groups:r,onGroupChange:t=>ne(t),onSaveImage:k,onSelectBucket:(t,o)=>{const g=n.find(D=>D.testNumber===t.testNumber),C=new Set(t.items.map(D=>D.item)),x=new Set(t.items.flatMap(D=>D.dies)),W=ke(t.low,g?.unit,"engineering"),se=ke(t.high,g?.unit,"engineering");Q(o,e.filter(D=>C.has(D)),`with ${g?et(g,g.testNumber):`test ${t.testNumber}`} from ${W} to ${se}${t.group?` in ${t.group}`:""}`,D=>x.has(D),t.testNumber)},ownerDocument:f}),b=gt({title:"Wafer-to-wafer trend",axisPrefs:K,onAxisPrefsChange:c(()=>b),onTestChange:t=>y(t),selectedTestNumber:I??void 0,items:e.map(t=>({label:t.label,key:t.waferIndex,dies:t.dies,testStats:t.statsSummary?.stats.perTestStats})),testDefs:n,onSaveImage:k,centreLabel:st(at(e.map(t=>t.wafer.metadata)),"mean"),onOpen:R?(t,o)=>oe(t,`Wafer ${e.find(g=>g.waferIndex===t)?.label??t}`,o):void 0,onSelectWafers:(t,o,g)=>{const C=new Set(t.keys);Ce(o,g,e.filter(x=>C.has(x.waferIndex)),"selected in the trend",()=>!0,t.testNumber)},onWaferContextMenu:ie(e),ownerDocument:f}),y=t=>{I=t,m.setTest(t),a.setTest(t),b.setTest(t),w.setTest(t)};ee.set("distribution",[m,a,b]);const w=bt({title:"Process capability",items:e,testDefs:n,onSaveImage:k,selectedTestNumber:I??void 0,onSelectTest:t=>y(t),ownerDocument:f});return i.append(w.card,m.card,a.card,b.card),{card:i,destroy:()=>{w.destroy(),m.destroy(),a.destroy(),b.destroy()}}}function Ue(e,n,r){const l=ue(f),i=Ct({title:"Test scatter",items:e,testDefs:n,groups:r,binColors:be().hard,onSaveImage:k,axisPrefs:K,onAxisPrefsChange:c=>te(c,i),onOpen:re(e)?.open,openActionLabel:re(e)?.label,onSelect:(c,s,h,d)=>{const m=new Map;for(const y of c){if(y.waferIndex===void 0||!y.die)continue;const w=m.get(y.waferIndex);w?w.push(y.die):m.set(y.waferIndex,[y.die])}const a=[...m].flatMap(([y,w])=>{const t=e.find(o=>o.waferIndex===y);return t?[{label:t.identity??t.label,dies:w,waferIndex:y,wafer:t.wafer,passBins:t.passBins,ringCount:N()}]:[]});if(a.length===0)return;const b=a.length===1?`selected on ${a[0].label} in the scatter`:`selected in the scatter, across ${a.length} wafers`;le(s,h,{items:a,population:b,testDefs:n,activeTest:d},{plots:q,onSaveImage:k,onSaveText:O,onLocateDie:V})},ownerDocument:f});ee.set("correlation",[i]);const u=wt({title:"Test correlation matrix",items:e,testDefs:n,onSaveImage:k,onSaveText:O,onSelectPair:(c,s)=>i.setXY(c,s),ownerDocument:f});return l.append(u.card,i.card),{card:l,destroy:()=>{u.destroy(),i.destroy()}}}function H(e){e?.keepSections||we(),U.innerHTML="",A.innerHTML="";for(const o of Ee)A.appendChild(We(o.key,o.label));const n=Oe();Fe(n);const r=Ke(n,{facetableOnly:!0,curation:he}).filter(o=>o.splittable),l=f.createElement("div");Object.assign(l.style,{display:"flex",gap:T.md,alignItems:"center",marginLeft:T.xxl,paddingBottom:T.xs});let i;r.length>0?(l.appendChild(vt("Group by:",[{value:"",label:"None"},...r.map(o=>({value:o.key,label:`${o.label} (${o.values.length})`}))],M??"",o=>{M=o||void 0,E=null,H()},{hook:"group-by",ownerDocument:f})),i=r.find(o=>o.key===M)?.label):M=void 0;let u;if(M){const o=new Map,g=[];for(const C of n){const x=Qe(C.metadata,M,he)??Xe;o.has(x)||(o.set(x,[]),g.push(x)),o.get(x).push(C)}u=g.map(C=>({key:C,items:o.get(C)}))}E!==null&&!u?.some(o=>o.key===E)&&(E=null),u&&u.length>0&&l.appendChild(Dt(u.map(o=>o.key),"Show:",E,o=>ne(o),{ownerDocument:f}).el);let c=null;if(v.onOpenGuide){const o=f.createElement("button");o.type="button",o.innerHTML=mt.help,o.setAttribute("aria-label","User guide"),Object.assign(o.style,{...pt("bare"),display:"inline-flex",alignItems:"center",justifyContent:"center",width:"24px",height:"24px",flexShrink:"0"}),ce(o,"bare"),ft(o,"User guide"),o.addEventListener("click",()=>v.onOpenGuide()),Object.assign(o.style,{marginLeft:"auto"}),c=o}A.appendChild(l),c&&A.appendChild(c);const s=E!==null?u?.find(o=>o.key===E):void 0,h=s?.items??n,d=s?void 0:u,m=Se(h),a=m.defs,b=a.filter(xe);I!==null&&!b.some(o=>o.testNumber===I)&&(I=null);const y=e?.keepSections?G.get(L):void 0,w=y??(L==="overview"?Ge(h,b,a,d,i):L==="distributions"?ze(h,b,d,i):L==="data"?Ve(h,b,a,d,i):L==="plot"?_e(h,a,s?void 0:M,s?void 0:i):Ue(h,b,d));y||G.set(L,w);const t=m.conflicts.filter(o=>o.excluded);if(t.length>0){const o=f.createElement("div");Object.assign(o.style,{color:$.label,fontSize:F.body,padding:`0 ${z} ${T.sm}`});const g=t.slice(0,6).map(W=>W.testNumber).join(", "),C=t.length>6?`, and ${t.length-6} more`:"",x=t.length===1?"it":"them";o.textContent=`${t.length} test ${t.length===1?"number is":"numbers are"} hidden (${g}${C}) \u2014 the wafers in view describe ${x} differently, so their values cannot be pooled. `+(u&&u.length>0?`Pick one ${i??"group"} under "Show:" to analyse ${x}.`:"Load one test program at a time to analyse them."),o.dataset.wmapWithheldTests=String(t.length),U.appendChild(o)}U.appendChild(w.card)}return{el:Y,render:H,destroy:()=>{we(),q.flush(),Y.remove()},setAxisPrefs:e=>te(e,null,!0)}}
1
+ import{MEAN_WAFER_YIELD_LABEL as Lt}from"../stats/presentation.js";import{buildFacetTable as Et,facetValueOf as Be,FACET_NONE_VALUE as Tt,DEFAULT_FACET_CURATION as $t}from"../stats/facets.js";import{mergeTestDefs as ke}from"../stats/mergeTestDefs.js";import{isParametricTest as Le}from"../renderer/buildWaferMap.js";import{dieFailsTest as It,hasJudgeableTests as Dt,testsForPassKind as Ot,buildTestPassRateData as At}from"../stats/testPassRate.js";import{fmt as Ve}from"../renderer/fmt.js";import{testLabel as Ye}from"../renderer/testLabel.js";import{waferDisplayLabel as Wt,waferIdentityLabel as Pt}from"../core/waferLabel.js";import{waferPopulation as Rt}from"./chartPopulation.js";import{openDrilldownMenu as Ee}from"./drilldown.js";import{plotStoreFor as Ft}from"./plotStore.js";import{createPageFilter as Mt}from"./pageFilter.js";import{bandButton as Nt}from"./filterButton.js";import{itemPassBins as jt,passBinsLabel as Ge}from"../core/passBins.js";import{describeWaferPopulation as zt,populationStat as Ht}from"../stats/population.js";import{LEADING as Te,ALPHA as Vt,SPACE as O,EDGE_GUTTER as $e,FONT as N,CLR as W,RADIUS as Yt,SHADOW as Gt,controlStyle as _e,wireControlHover as fe,wireTooltip as Ie}from"./toolbar.js";import{ICONS as _t}from"./icons.js";import{renderCapabilityPanel as qt}from"./charts/capability.js";import{renderGroupComparisonPanel as Kt}from"./charts/groupComparison.js";import{renderCommonalityPanel as Ut}from"./charts/commonality.js";import{renderPatCard as Xt}from"./charts/patCard.js";import{renderDifferenceMapPanel as Jt}from"./differenceMapPanel.js";import{renderCorrelationPanel as Qt}from"./charts/correlation.js";import{cardFrameStyle as Zt,makeChartGridWrap as pe,makeLabeledSelect as en,makeLinkedGroupSelect as tn,makeLinkedTestSelect as nn,makeWaferSelect as qe,makeTestSelect as Ke,makeLimitsSelect as an,makeLinkedAxisPrefs as sn,makeToggle as on,limitLines as Ue,limitExtent as rn,shouldIncludeLimitsByDefault as ln,hasBothLimitKinds as Xe}from"./charts/chartShell.js";import{maxOf as dn,minOf as cn}from"../core/utils.js";import{buildYieldData as Je,buildYieldDataCombined as un}from"../stats/yield.js";import{buildLotTestSectionSteps as fn,buildLotFunctionalSection as pn,buildMetadataStripBox as mn}from"./summaryPanel.js";import{runChunked as hn}from"./chunked.js";import{buildRegionYieldData as De,buildRingRegions as Qe,buildQuadrantRegions as Ze,buildReticlePositionRegions as bn,diesInRegion as gn}from"../stats/regions.js";import{renderDataSection as yn}from"./dataTab.js";import{sourceFromDies as wn,toPlotItems as le}from"./plotItems.js";import{isYieldEligibleDie as xn}from"../core/dies.js";import{renderPlotCard as ae}from"./plotCard.js";import{orderFieldValues as Cn,axisValues as Sn}from"../stats/plotData.js";import{buildSynthesis as vn,synthesisKey as Bn}from"../stats/synthesis.js";import{commonPassBins as kn}from"../core/passBins.js";import{renderRegionYieldDiagram as Oe}from"./charts/regionYieldDiagram.js";const Ln=[{key:"overview",label:"Overview"},{key:"distributions",label:"Distributions"},{key:"correlation",label:"Correlation"}],En={key:"data",label:"Data"},Tn={key:"plot",label:"My plots"};export function createInsightsTab(B){const{getItems:et,getLotStats:Ae,getBinColors:U,getRingCount:V,onSaveImage:P,onSaveText:Y,openWafer:X,focusTest:me,locateDie:se}=B,de={...$t,...B.attributes},tt=B.showMetadataStrip??!0,J=B.contentInset??$e,c=B.ownerDocument??document,G=c.createElement("div");Object.assign(G.style,{display:"none",flexDirection:"column",width:"100%",paddingTop:"0"});const nt=$e,Z=c.createElement("div");Object.assign(Z.style,{paddingLeft:nt});const _=c.createElement("div");Object.assign(_.style,{display:"flex",gap:O.xs,alignItems:"center",background:W.menuBg,border:`1px solid ${W.menuBorder}`,borderRadius:Yt.container,boxShadow:Gt.panel,padding:`0 ${O.lg}`,marginBottom:O.lg,marginLeft:J,marginRight:J}),_.setAttribute("role","tablist"),_.addEventListener("keydown",e=>{if(e.key!=="ArrowLeft"&&e.key!=="ArrowRight")return;const t=Array.from(_.querySelectorAll('[role="tab"]')),n=t.indexOf(c.activeElement);if(n===-1)return;e.preventDefault();const d=t[(n+(e.key==="ArrowRight"?1:-1)+t.length)%t.length];d.focus(),d.click()});const Q=c.createElement("div");Object.assign(Q.style,{display:"flex",flexDirection:"column",gap:O.lg,marginTop:"0",paddingLeft:J,paddingRight:J});const ce=B.pageFilter??Mt({doc:c,initial:B.filter,onChange:B.onFilterChange,attributes:B.attributes,getRingCount:B.getRingCount}),We=ce.createBand(()=>xe(),{marginLeft:J,marginRight:J,marginBottom:O.lg}),at=We.el;G.appendChild(Z),G.appendChild(_),G.appendChild(at),G.appendChild(Q);const st=[...Ln,En,Tn],ee=B.plotStore??Ft(B),te=(e,t)=>{import("./plotModal.js").then(({openPlotEditor:n})=>n({doc:c,anchor:G,store:ee,plot:e,draft:!0,items:[...t.items],ctx:t.ctx,title:e.title?`New plot from \u201C${e.title}\u201D`:"New plot",chart:{onSaveImage:P,binColors:U()}}))};let z=B.defaultView==="sweeps"?"plot":B.defaultView??"overview",F,he=!1;ce.subscribe(()=>q());let Pe="statistics",Re="wide",H=null,Fe=null,be=[],R=null,ge=B.initialAxisPrefs??{includeLimits:void 0,clipOutliers:!1,limits:"both"};const ye=new Map,we=(e,t,n=!1)=>{ge=e;for(const d of ye.values())for(const u of d)u!==t&&u.setAxisPrefs(e);n||B.onAxisPrefsChange?.(e)},ie=e=>{R!==e&&(R=e,q())};let ne=new Map;function Me(){for(const e of ne.values())e.destroy();ne=new Map}function Ne(e,t,n){X?.(e,t,n)}function ue(e){return(t,n,d)=>{const u=e.find(f=>f.waferIndex===t);if(!u)return;d.preventDefault();const h=Rt(u.dies,{waferLabel:u.identity,testDefs:u.testDefs,activeTest:n??H??void 0,waferIndex:t,wafer:u.wafer,passBins:u.passBins,ringCount:V()});Ee({x:d.clientX,y:d.clientY},d.target,h,{plots:ee,getBinColors:U,onSaveImage:P,onSaveText:Y,onLocateDie:se})}}function it(e,t,n,d,u){oe({x:e.clientX,y:e.clientY},e.target,t,n,d,u)}function oe(e,t,n,d,u,h){const f=wn(n.map(r=>({label:r.identity??r.label,dies:r.dies,waferIndex:r.waferIndex,wafer:r.wafer,passBins:r.passBins,ringCount:V()})),d,u,ke(n).defs,h);f&&Ee(e,t,f,{plots:ee,getBinColors:U,onSaveImage:P,onSaveText:Y,onLocateDie:se})}function je(e){return X?{open:(t,n)=>Ne(t,`Wafer ${e.find(d=>d.waferIndex===t)?.label??t}`,n)}:me&&e.length===1?{open:(t,n)=>me(n),label:"show this test on the map"}:null}function xe(){return et().map((e,t)=>e==null?null:{metadata:e.wafer.metadata??void 0,dies:e.dies,wafer:e.wafer,label:Wt(e,t),identity:Pt(e),waferIndex:t,passBins:jt(e),statsSummary:e.statsSummary,testDefs:e.testDefs,source:e}).filter(e=>e!=null)}function ot(e,t){Object.assign(e.style,{background:"none",border:"none",borderBottom:t?`2px solid ${W.iconActive}`:"2px solid transparent",color:t?W.iconActive:W.label,fontWeight:t?"700":"500",fontSize:N.body,padding:`${O.sm} ${$e} ${O.md}`,cursor:"pointer",marginBottom:"-1px"})}function rt(e,t){const n=c.createElement("button");n.type="button",n.textContent=t;const d=e===z;return ot(n,d),n.dataset.on=d?"true":"false",fe(n,"bare"),n.dataset.wmapInsightsTab=e,n.setAttribute("role","tab"),n.setAttribute("aria-selected",d?"true":"false"),n.tabIndex=d?0:-1,n.addEventListener("click",()=>{z!==e&&(z=e,q({keepSections:!0}))}),n}function lt(e,t,n,d=!0){const u=pe(c),h=U(),f=n??"group",r=Ge(e.map(m=>m.passBins)),g=le(e.map(m=>({label:m.identity??m.label.replace(/\s*·\s*\d+(\.\d+)?%$/,""),dies:m.dies,waferIndex:m.waferIndex,wafer:m.wafer,passBins:m.passBins,ringCount:V()}))),p=ke(e).defs,o=t?F:void 0,l={testDefs:p,groupBy:o,curation:B.attributes},b=(m,x)=>({id:"card-yield",title:t?`Yield by ${f} (pass: ${r})`:`Yield by wafer (pass: ${r})`,chart:"bar",fields:{x:{slot:"groupBy"},y:{builtin:"yield"},color:{none:!0}},valueLabels:!0,...m?{sort:"value"}:{},...x>=3?{axes:{y:{references:[{stat:"median"}]}}}:{}}),k=t?t.length:e.length;let C=null;d&&(C=ae({doc:c,editAsPlot:te,items:g,ctx:l,spec:{choices:[{current:"natural",options:m=>[["value","Sort: yield"],["natural",t&&!m?`Sort: ${f}`:"Sort: wafer"]]}],build:([m])=>b(m==="value",k)},drill:t&&o?m=>{const x=Be(g[m[0]?.item]?.metadata,o,B.attributes);if(x===void 0)return null;const E=t.find(i=>i.key===x)?.items.length??0;return i=>({...i,title:`Yield by wafer \u2014 ${f}: ${x} (pass: ${r})`,fields:{...i.fields,x:{builtin:"wafer"}},where:{conditions:[{field:{meta:o},values:[x]}]},axes:E>=3?{y:{references:[{stat:"median"}]}}:void 0})}:void 0,drillLabel:"see its wafers",chart:{onSaveImage:P,onOpenWafer:X?m=>Ne(g[m].waferIndex??m,`Wafer ${g[m].label}`):void 0,onWaferMenu:ue(e)}}),C.card.style.minHeight="360px",u.appendChild(C.card));const L={current:"hbin",options:[["hbin","Hard bins","The physical sort result: where the part goes on the handler"],["sbin","Soft bins","The test program\u2019s failure category: many soft bins can map to one hard bin"]]},w={current:"share",options:[["count","Counts"],["share",`Share of ${f}`,`Each ${f}\u2019s dies in a bin as a share of all its dies, so ${f} values of different sizes compare`]]},S=(m,x)=>({id:"card-bin-pareto",title:`${m==="sbin"?"Soft":"Hard"} bin pareto`,chart:"bar",sort:"value",fields:{x:{builtin:m==="sbin"?"sbin":"hbin"},color:t?{follow:"groupBy"}:{builtin:m==="sbin"?"sbin":"hbin"}},...t?x==="share"?{barNorm:"percent"}:{}:{cumulative:!0}}),s=ae({doc:c,editAsPlot:te,items:g,ctx:l,spec:t?{choices:[L,w],build:([m,x])=>S(m,x)}:{choices:[L],build:([m])=>S(m,void 0)},chart:{onSaveImage:P,binColors:h,onSelectPoints:(m,x,E,i)=>{const v=s.current().fields.x,a=v&&!Array.isArray(v)&&"builtin"in v&&v.builtin==="sbin"?"sbin":"hbin",y=new Set(m.map(T=>a==="hbin"?T.die?.hbin:T.die?.sbin));if(y.size!==1)return;const $=[...y][0],A=t?i?.group:void 0,I=A!==void 0?t?.find(T=>T.key===A)?.items??[]:e;oe(x,E,I,`in ${a==="hbin"?"hard":"soft"} bin ${$}${A!==void 0?` of ${A}`:""}`,T=>xn(T)&&(a==="hbin"?T.hbin:T.sbin)===$)}}});return s.card.style.minHeight="360px",u.appendChild(s.card),{card:u,destroy:()=>{C?.destroy(),s.destroy()}}}function Ce(){const e=c.createElement("div");return e.dataset.wmapChartCard="1",Object.assign(e.style,{...Zt(),display:"flex",flexDirection:"column",gap:O.lg,minWidth:"0"}),e}function dt(e){if(Z.innerHTML="",Z.style.marginBottom="0",!tt)return;const t=mn(e.map(n=>({metadata:n.metadata})),void 0,{facetableOnly:!1});t&&(t.style.marginBottom="0",Z.appendChild(t),Z.style.marginBottom=O.xs)}function ct(e,t,n,d){if(!e.length)return{elements:[],destroy:()=>{}};const u=e.map(w=>w.wafer),h=e.map(w=>w.dies),f=V(),r=[],g=[],p=d??[{key:"",items:e}],o=e.flatMap(w=>w.dies),l=["spec","testFlag","functional"].filter(w=>Dt(n,w,o));if(l.length){const w={spec:{label:"Test limits",hint:"Judged from each die\u2019s measured value against the test\u2019s limits",title:"Parametric pass rate \xB7 test limits"},testFlag:{label:"Tester flag",hint:"The pass or fail the tester recorded for each die",title:"Parametric pass rate \xB7 tester flag"},functional:{label:"Functional",hint:"Tests that only pass or fail and have no measured value",title:"Functional test pass rate"}},S=!!d,s=le(e.map(i=>({label:i.identity??i.label,dies:i.dies,waferIndex:i.waferIndex,wafer:i.wafer,passBins:i.passBins,ringCount:f}))),m=i=>({id:`card-pass-rate-${i}`,title:w[i].title,chart:"bar",orientation:"horizontal",sort:"ascending",fields:{x:{builtin:"test"},y:{tests:Ot(n,i).map(v=>v.testNumber),passRate:!0,...i==="testFlag"?{judge:"flag"}:{}},color:S?{follow:"groupBy"}:{none:!0}},...S?{}:{valueLabels:!0},axes:{y:{min:0,max:100}}}),x=i=>i.id.slice(15),E=ae({doc:c,editAsPlot:te,items:s,ctx:{testDefs:n,groupBy:S?F:void 0,curation:B.attributes},spec:l.length>1?{choices:[{current:l[0],options:l.map(i=>[i,w[i].label,w[i].hint])}],build:([i])=>m(i)}:m(l[0]),notes:i=>{const v=x(i);if(v==="functional")return[];const a=At(p.map(y=>({key:y.key,items:y.items.map($=>({dies:$.dies}))})),n,v).disagreementDies;return a?[`${a.toLocaleString("en-GB")} die${a===1?"":"s"} judged differently by test limits and the tester flag`]:[]},chart:{onSaveImage:P,selectActionLabel:"chart or tabulate the dies that fail its test",onSelectPoints:(i,v,a,y)=>{const $=n.find(T=>T.testNumber===y?.test);if(!$)return;const A=x(E.current()),I=y?.group!==void 0?p.find(T=>T.key===y.group)?.items??e:e;oe(v,a,I,`failing ${Ye($,$.testNumber)}${y?.group!==void 0?` in ${y.group}`:""}`,T=>It(T,$,A)===!0,Le($)?$.testNumber:void 0)}}});E.card.style.minHeight="300px",r.push(E.card),g.push(E.destroy)}const b=w=>(S,s)=>{const m=new Set;for(const x of e)for(const E of gn(x.dies,x.wafer,f,S.key,w))m.add(E);it(s,e,`in ${S.label}`,x=>m.has(x))},k=De(h,u,f,w=>e[w].passBins,Qe);if(k.length){const w=Oe({title:"Ring yield",mode:"ring",rows:k,onSelectRegion:b(Qe),onSaveImage:P,ownerDocument:c});r.push(w.card),g.push(w.destroy)}const C=De(h,u,f,w=>e[w].passBins,Ze);if(C.length){const w=Oe({title:"Quadrant yield",mode:"quadrant",rows:C,onSelectRegion:b(Ze),onSaveImage:P,ownerDocument:c});r.push(w.card),g.push(w.destroy)}const L=u.find(w=>w.reticle!==void 0)?.reticle;if(L){const w=(s,m)=>bn(s,m.reticle),S=De(h,u,f,s=>e[s].passBins,w);if(S.length){const s=Oe({title:"Reticle cell yield",mode:"reticleCell",rows:S,grid:{width:Math.max(1,Math.floor(L.width)),height:Math.max(1,Math.floor(L.height))},onSelectRegion:b(w),onSaveImage:P,ownerDocument:c});r.push(s.card),g.push(s.destroy)}}return{elements:r,destroy:()=>{for(const w of g)w()}}}function ut(e,t,n){if(!e.length)return{cards:[],destroy:()=>{}};const d=e.map(l=>l.dies),u=e.flatMap(l=>l.dies),h=e.map(l=>l.statsSummary),f=h.every(l=>l!==void 0)?h:void 0,r=[],g=[];let p=null;if(t.length){const l=Ce();let b=null;const k=hn(fn(u,t,void 0,f,Y,d.map(C=>({dies:C})),void 0,"full"),{onDone:C=>{b=C,l.removeAttribute("aria-busy"),C?l.replaceChildren(C):l.remove()}});if(k.done)b&&(p=l);else{const C=c.createElement("div");C.textContent="Computing test statistics\u2026",Object.assign(C.style,{color:W.label,fontSize:N.body}),l.setAttribute("aria-busy","true"),l.appendChild(C),p=l,r.push(()=>k.cancel())}}let o=null;if(n.length){const l=pn(u,n,f,Y);if(l){const b=Ce();b.appendChild(l),o=b}}return p&&g.push(p),o&&g.push(o),{cards:g,destroy:()=>{for(const l of r)l()}}}function ft(e){const t=Ge(e.map(p=>p.passBins)),n=e.length===1,d=e[0],u=Ce();Object.assign(u.style,{flexDirection:"row",flexWrap:"wrap",gap:O.md});const h=p=>{const o=p.lastElementChild;return o&&Object.assign(o.style,{borderRight:"none",paddingRight:"0",marginRight:"0"}),p};function f(p,o,l){const b=c.createElement("div");Object.assign(b.style,{display:"flex",alignItems:"baseline",gap:O.sm,paddingRight:O.xxl,marginRight:O.md,borderRight:`1px solid ${W.menuBorder}`});const k=c.createElement("div");k.textContent=p,Object.assign(k.style,{fontSize:N.heading,fontWeight:"700",color:W.value,lineHeight:Te.tight});const C=c.createElement("div");if(C.textContent=o,Object.assign(C.style,{fontSize:N.body,color:W.label}),b.append(k,C),l){const L=c.createElement("div");L.textContent=l,Object.assign(L.style,{fontSize:N.meta,color:W.label,opacity:Vt.muted}),b.appendChild(L)}return b}if(n){const p=Je([{...d,key:d.waferIndex}])[0]?.percent;return p!==void 0&&u.appendChild(f(`${p.toFixed(1)}%`,`Yield \xB7 pass: ${t}`)),u.appendChild(f(String(d.dies.length),"Total dies")),h(u)}u.appendChild(f(String(e.length),"Wafers"));const r=Je(e.map(p=>({...p,key:p.waferIndex}))).map(p=>p.percent).filter(p=>Number.isFinite(p));if(r.length){const p=r.reduce((b,k)=>b+k,0)/r.length,o=un([{key:"all",items:e.map(b=>({...b,key:b.waferIndex}))}])[0]?.percent,l=o!==void 0&&o.toFixed(1)!==p.toFixed(1);u.appendChild(f(`${p.toFixed(1)}%`,`${Lt} \xB7 pass: ${t}`,l?`${o.toFixed(1)}% by dies`:void 0))}const g=e.map(p=>p.statsSummary);if(g.every(p=>p!==void 0)){const p=g.reduce((l,b)=>l+b.stats.analyzedDies,0),o=g.reduce((l,b)=>l+b.stats.excludedDies,0);u.appendChild(f(p.toLocaleString(),"Dies analysed",o?`${o.toLocaleString()} excluded`:void 0))}else u.appendChild(f(e.reduce((p,o)=>p+o.dies.length,0).toLocaleString(),"Total dies"));return h(u)}function pt(e,t,n,d,u){const h=c.createElement("div");Object.assign(h.style,{display:"flex",flexDirection:"column",gap:O.lg});const f=e.length===1&&!d;e.length&&!d&&h.appendChild(ft(e));const r=lt(e,d,u,!f);h.appendChild(r.card);const g=ct(e,t,n,d);for(const l of g.elements)r.card.appendChild(l);const p=mt(e,n);if(p&&h.appendChild(p.el),e.length>=4&&be.length){const l=Ut({wafers:e,fields:be,curation:de,groupedBy:F,onGroupBy:b=>{F=b,R=null,q()},ownerDocument:c});h.appendChild(l.card)}const o=Xt({items:e.map(l=>({...l,ringCount:V()})),testDefs:n,ownerDocument:c,showMap:B.showPatMap});return o&&h.appendChild(o.card),h.appendChild(ht()),{card:h,destroy:()=>{r.destroy(),g.destroy(),p?.destroy()}}}function mt(e,t){const n=Ae?.()??(e.length===1?e[0].statsSummary:void 0);if(!n)return null;const d=c.createElement("section");d.dataset.wmapWorthALook="1",Object.assign(d.style,{display:"flex",flexDirection:"column",gap:O.md});const u=c.createElement("h3");u.textContent="Worth a look",Object.assign(u.style,{margin:"0",fontSize:N.heading,fontWeight:"600",color:W.value}),d.appendChild(u);const h=(o,l)=>{const b=c.createElement("p");b.textContent=o,l&&(b.dataset[l]="1"),Object.assign(b.style,{margin:"0",fontSize:N.body,color:W.label,lineHeight:Te.base}),d.appendChild(b)};if(he||R!==null)return h("Worth a look describes the whole lot, as What stands out beside the map does. Switch the filter off, or Show all groups, to see it here.","wmapWorthNarrowed"),{el:d,destroy:()=>{}};const f=vn(n,{passBins:kn(e.map(o=>o.passBins)),attributes:B.attributes});if(f.items.length===0)return h(f.nothing??"Nothing stands out.","wmapWorthNothing"),{el:d,destroy:()=>{}};const r=pe(c);d.appendChild(r);const g=le(e.map(o=>({label:o.identity??o.label,dies:o.dies,waferIndex:o.waferIndex,wafer:o.wafer,passBins:o.passBins,ringCount:V()}))),p=[];if(f.items.forEach((o,l)=>{const b=c.createElement("div");b.dataset.wmapWorthWhy="1",b.textContent=`Shown because: ${o.reason}`,o.text!==o.reason&&Ie(b,o.text),Object.assign(b.style,{flexBasis:"100%",fontSize:N.body,color:W.text,lineHeight:Te.base});const k=[b];if(B.showOnMap){const L=c.createElement("button");L.type="button",L.textContent="Show on map",L.dataset.wmapWorthShowOnMap="1",Object.assign(L.style,{..._e("outlined"),fontSize:N.body,padding:`0 ${O.md}`}),fe(L),Ie(L,"Leave Insights and show this on the map, as its row in What stands out does"),L.addEventListener("click",()=>B.showOnMap(o.target)),k.push(L)}const C=ae({doc:c,items:g,ctx:{testDefs:t,curation:de},spec:{id:`worth-${l}`,...o.chart},extras:k,editAsPlot:te,chart:{onSaveImage:P}});C.card.dataset.wmapWorthKey=Bn(o),r.appendChild(C.card),p.push(C.destroy)}),f.also){const o=f.also.items.map(l=>l.brief).join("; ");h(`Also: ${o}${f.also.more?`; and ${f.also.more} more`:""}. Their rows in What stands out show them on the map.`,"wmapWorthAlso")}return{el:d,destroy:()=>p.forEach(o=>o())}}function ht(){const e=c.createElement("div");Object.assign(e.style,{fontSize:N.body,color:W.label});const t=c.createElement("button");return t.type="button",t.textContent="Data tab",t.dataset.wmapOpenDataTab="1",Object.assign(t.style,{border:"none",background:"none",padding:"0",cursor:"pointer",font:"inherit",color:W.iconActive,textDecoration:"underline"}),fe(t,"bare"),t.addEventListener("click",()=>{z="data",q({keepSections:!0})}),e.append("Test statistics, every die and every wafer as tables, with CSV export: see the ",t,"."),e}function bt(e,t,n,d){const u=c.createElement("div");u.style.width="100%";let h,f=!1;return import("./plotTab.js").then(({createPlotSection:r})=>{if(f)return;const g=r({doc:c,store:ee,items:e,testDefs:t,ringCount:V(),attributes:B.attributes,groupBy:n,groupLabel:d,onSaveImage:P,onSaveText:Y,getBinColors:U,waferMenu:ue(e),openWafer:X?(p,o,l)=>X(p,o,l):void 0,focusTest:me,locateDie:se,pickPlotsFile:B.onPickPlotsFile});u.appendChild(g.card),h=g}),{card:u,destroy:()=>{f=!0,h?.destroy()}}}function gt(e,t,n,d,u){const h=he?void 0:Ae?.(),f=()=>{ne.get("data")?.destroy(),ne.delete("data"),q({keepSections:!0})};return yn({doc:c,items:e,testDefs:t,allTestDefs:n,groups:d,groupLabelText:u,ringCount:V(),attributes:B.attributes,yieldByWaferIndex:new Map(h?.lotYieldSeries.map(r=>[r.waferIndex,r.yieldPercent])),onSaveText:Y,onLocateDie:se,onOpenWafer:X?(r,g)=>X(r,g):void 0,buildStatistics:r=>ut(r,t,n),view:Pe,onViewChange:r=>{Pe=r,f()},diesLayout:Re,onDiesLayoutChange:r=>{Re=r}})}function ze(e,t){const n=c.createElement("h3");return n.textContent=e,n.dataset.wmapRowHeading=t,Object.assign(n.style,{gridColumn:"1 / -1",margin:`${O.md} 0 0`,color:W.value,fontSize:N.heading,fontWeight:"600"}),n}function yt(e,t,n,d){const u=pe(c),h=je(e),f=le(e.map(a=>({label:a.identity??a.label,dies:a.dies,waferIndex:a.waferIndex,wafer:a.wafer,passBins:a.passBins,ringCount:V()}))),r=t.filter(a=>a.testNumber!==void 0),g=!!n&&!!F,p=g&&R!==null,o={testDefs:t,groupBy:g?F:void 0,curation:B.attributes},l=(a,y,$)=>({limits:y.limits??"both",axes:{[a]:{...y.includeLimits!==void 0?{includeLimits:y.includeLimits}:{},...y.clipOutliers?{clip:!0}:{},...$?{scale:"log"}:{}}}});function b(a){let y=ge,$=!1,A;const I=nn(r,H??r[0]?.testNumber??null,j=>{A?.refresh(),m(j)},{ownerDocument:c}),T=c.createElement("span");Object.assign(T.style,{display:"inline-flex",flexWrap:"wrap",gap:O.sm,alignItems:"center"});const D={setAxisPrefs:j=>{K.set(j)&&(y=j,A?.refresh())}},K=sn(T,y,j=>{y=j,A?.refresh(),we(j,D)},c),re=[I.el,T];a.logToggle&&re.push(on("Log scale",$,j=>{$=j,A?.refresh()},c,"Draw the value axis on a logarithmic scale")),re.push(...a.extras??[]),A=ae({doc:c,editAsPlot:te,items:f,ctx:o,...a.card,spec:{choices:[],build:()=>a.build(y,$)},slots:()=>({test:I.get()??void 0}),extras:re,onResolved:j=>{const Se=t.find(kt=>kt.testNumber===I.get()),He=Ue(Se,y.limits),ve=Sn(j,a.valueRole),{lo:St,hi:vt}=rn(He),Bt=ve.length>0&&He.length>0&&ln(cn(ve),dn(ve),St,vt);K.sync(y.includeLimits??Bt,Ue(Se).length>0,Xe(Se))},chart:a.chart});const M=A;return{card:M.card,setTest:j=>{I.set(j)&&M.refresh()},refresh:()=>M.refresh(),setAxisPrefs:D.setAxisPrefs,destroy:()=>M.destroy()}}const k=h?(a,y)=>h.open(f[a]?.waferIndex??a,y??H??r[0]?.testNumber??0):void 0,C=b({valueRole:"y",logToggle:!0,build:(a,y)=>({id:"card-box",title:"Test value distribution",chart:"box",orientation:"horizontal",fields:{x:g&&!p?{slot:"groupBy"}:{builtin:"wafer"},y:{slot:"test"},color:{none:!0}},...p?{where:{conditions:[{field:{meta:F},values:[R]}]}}:{},...l("y",a,y)}),card:{...g&&!p?{drill:a=>{const y=Be(f[a[0]?.item]?.metadata,F,B.attributes);return y!==void 0&&ie(y),null},drillLabel:"see its wafers"}:{},...R!==null?{externalBack:{shown:()=>R!==null,onBack:()=>ie(null)}}:{}},chart:{onSaveImage:P,onOpenWafer:k,openActionLabel:h?.label,onWaferMenu:ue(e)}});let L=null;const w=g?[]:[qe(f.map(a=>({label:a.label})),null,a=>{L=a,S.refresh()},{ownerDocument:c})],S=b({valueRole:"x",extras:w,card:R!==null?{externalBack:{shown:()=>R!==null,onBack:()=>ie(null)}}:{},build:a=>({id:"card-histogram",title:"Value histogram",chart:"histogram",fields:{y:{slot:"test"},color:g?{follow:"groupBy"}:{none:!0}},...L!==null?{where:{conditions:[{field:{builtin:"wafer"},values:[f[L].label]}]}}:{},...l("x",a,!1)}),chart:{onSaveImage:P,...g?{onLegendPick:a=>ie(a),legendPicked:R}:{},onSelectPoints:(a,y,$,A)=>{const I=t.find(M=>M.testNumber===(H??r[0]?.testNumber)),T=new Set(a.map(M=>M.die).filter(M=>!!M)),D=new Set(a.map(M=>f[M.item]?.waferIndex)),K=A?.range,re=I&&K?`with ${Ye(I,I.testNumber)} from ${Ve(K.lo,I.unit,"engineering")} to ${Ve(K.hi,I.unit,"engineering")}${A?.group?` in ${A.group}`:""}`:"selected in the histogram";oe(y,$,e.filter(M=>D.has(M.waferIndex)),re,M=>T.has(M),I?.testNumber)}}}),s=b({valueRole:"y",build:a=>({id:"card-trend",title:"Wafer-to-wafer trend",chart:"line",aggregate:"mean",spread:"sd",fields:{x:{builtin:"waferOrder"},y:{slot:"test"},color:{none:!0}},...l("y",a,!1),axes:{...l("y",a,!1).axes,y:{...l("y",a,!1).axes.y,references:[{stat:"mean",label:Ht(zt(e.map(y=>y.wafer.metadata)),"mean")}]}}}),card:{ctx:{...o,groupBy:void 0},...e.length<2?{unavailable:"A trend needs at least two wafers"}:{}},chart:{onSaveImage:P,onWaferMenu:ue(e),selectActionLabel:k?"open that wafer":"chart or tabulate its dies",selectRangeLabel:"wafers",onSelectPoints:(a,y,$)=>{const A=new Set(a.map(D=>D.item));if(A.size===1&&k){k([...A][0]);return}const I=new Set(a.map(D=>D.die).filter(D=>!!D)),T=new Set(a.map(D=>f[D.item]?.waferIndex));oe(y,$,e.filter(D=>T.has(D.waferIndex)),"selected in the trend",D=>I.has(D),H??void 0)}}}),m=a=>{H=a,C.setTest(a),S.setTest(a),s.setTest(a),v.setTest(a),E?.setTest(a),i?.setTest(a)},x=()=>Kt({groups:n,testDefs:t,groupLabelText:d,control:Fe,onControlChange:a=>{Fe=a;const y=x();E.card.replaceWith(y.card),E=y},selectedTestNumber:H??void 0,onSelectTest:a=>m(a),onSaveText:Y,ownerDocument:c});let E=n&&n.length>=2?x():void 0;const i=n&&n.length>=2?Jt({groups:n,testDefs:t,groupLabelText:d,selectedTestNumber:H??void 0,onSaveImage:P,ownerDocument:c}):void 0;ye.set("distribution",[C,S,s]);const v=qt({title:"Process capability",items:e,testDefs:t,onSaveImage:P,selectedTestNumber:H??void 0,onSelectTest:a=>m(a),ownerDocument:c});return(E||i)&&(u.append(ze(`Comparing ${d??"groups"}`,"comparing")),E&&u.append(E.card),i&&u.append(i.card),u.append(ze("Test by test","tests"))),u.append(v.card,C.card,S.card,s.card),{card:u,destroy:()=>{v.destroy(),C.destroy(),S.destroy(),s.destroy(),E?.destroy(),i?.destroy()}}}function wt(e,t,n){const d=pe(c),u=je(e),h=le(e.map(i=>({label:i.identity??i.label,dies:i.dies,waferIndex:i.waferIndex,wafer:i.wafer,passBins:i.passBins,ringCount:V()}))),f=t.filter(i=>i.testNumber!==void 0&&Le(i));let r=f[0]?.testNumber,g=f[1]?.testNumber??r,p=null,o=ge;const l=!!n&&!!F,b=(i,v)=>{const a=c.createElement("label");Object.assign(a.style,{display:"inline-flex",alignItems:"center",gap:O.xs,fontSize:N.body,color:W.label});const y=c.createElement("span");return y.textContent=i,a.append(y,v),a},k=Ke(f,r??null,i=>{r=i,S(),x.refresh()},{maxWidth:"180px",emptyText:"No tests",ownerDocument:c}),C=Ke(f,g??null,i=>{g=i,S(),x.refresh()},{maxWidth:"180px",emptyText:"No tests",ownerDocument:c}),L=c.createElement("span"),w={setXY:(i,v)=>{r=i,g=v,k.value=String(i),C.value=String(v),S(),x.refresh()},setAxisPrefs:i=>{o=i,S(),x.refresh()},destroy:()=>x.destroy()};function S(){const i=[r,g].map(v=>t.find(a=>a.testNumber===v));L.replaceChildren(...i.some(Xe)?[an(o.limits??"both",v=>{o={...o,limits:v},x.refresh(),we(o,w)},c)]:[])}const s=i=>{const v=t.find(a=>a.testNumber===i);return v?.name?{test:i??0,name:v.name}:{test:i??0}},m=[b("X:",k),b("Y:",C),L];!l&&e.length>1&&m.push(qe(h.map(i=>({label:i.label})),null,i=>{p=i,x.refresh()},{ownerDocument:c}));const x=ae({doc:c,editAsPlot:te,items:h,ctx:{testDefs:t,groupBy:l?F:void 0,curation:B.attributes},extras:m,spec:{choices:[],build:()=>({id:"card-scatter",title:"Test scatter",chart:"scatter",limits:o.limits??"both",fields:{x:s(r),y:s(g),color:l?{follow:"groupBy"}:{builtin:"hbin"}},...p!==null?{where:{conditions:[{field:{builtin:"wafer"},values:[h[p].label]}]}}:{}})},...r===void 0?{unavailable:"No parametric test has values to plot"}:{},chart:{onSaveImage:P,binColors:U(),onOpenWafer:u?(i,v)=>u.open(h[i]?.waferIndex??i,v??r??0):void 0,openActionLabel:u?.label,onSelectPoints:(i,v,a)=>{const y=new Map;for(const I of i){const T=h[I.item]?.waferIndex;if(T===void 0||!I.die)continue;const D=y.get(T);D?D.push(I.die):y.set(T,[I.die])}const $=[...y].flatMap(([I,T])=>{const D=e.find(K=>K.waferIndex===I);return D?[{label:D.identity??D.label,dies:T,waferIndex:I,wafer:D.wafer,passBins:D.passBins,ringCount:V()}]:[]});if($.length===0)return;const A=$.length===1?`selected on ${$[0].label} in the scatter`:`selected in the scatter, across ${$.length} wafers`;Ee(v,a,{items:$,population:A,testDefs:t,activeTest:r},{plots:ee,getBinColors:U,onSaveImage:P,onSaveText:Y,onLocateDie:se})}}});S(),ye.set("correlation",[w]);const E=Qt({title:"Test correlation matrix",items:e,testDefs:t,onSaveImage:P,onSaveText:Y,onSelectPair:(i,v)=>w.setXY(i,v),ownerDocument:c});return d.append(E.card,x.card),{card:d,destroy:()=>{E.destroy(),w.destroy()}}}const xt=(e,t,n,d)=>Nt(c,e,t,n,d),Ct=()=>ce.openEditor(G,xe());function q(e){e?.keepSections||Me(),Q.innerHTML="",_.innerHTML="";for(const s of st)_.appendChild(rt(s.key,s.label));const t=xe(),n=ce.keep(t),d=n.items;he=n.narrowing,We.refresh(n.result,t),dt(d);const u=Et(d,{facetableOnly:!0,curation:de}).filter(s=>s.splittable);be=u.map(s=>({key:s.key,label:s.label}));const h=c.createElement("div");Object.assign(h.style,{display:"flex",gap:O.md,alignItems:"center",marginLeft:O.xxl,paddingBottom:O.xs}),B.showFilterButton!==!1&&h.appendChild(xt("Filter\u2026","wmapInsightsFilterOpen","Show only the wafers and dies that meet conditions you set, on the maps, the gallery and every Insights tab",()=>Ct()));let f;u.length>0?(h.appendChild(en("Group by:",[{value:"",label:"None"},...u.map(s=>({value:s.key,label:`${s.label} (${s.values.length})`}))],F??"",s=>{F=s||void 0,R=null,q()},{hook:"group-by",ownerDocument:c})),f=u.find(s=>s.key===F)?.label):F=void 0;let r;if(F){const s=new Map,m=[];for(const x of d){const E=Be(x.metadata,F,de)??Tt;s.has(E)||(s.set(E,[]),m.push(E)),s.get(E).push(x)}r=Cn(m).map(x=>({key:x,items:s.get(x)}))}R!==null&&!r?.some(s=>s.key===R)&&(R=null),r&&r.length>0&&h.appendChild(tn(r.map(s=>s.key),"Show:",R,s=>ie(s),{ownerDocument:c}).el);let g=null;if(B.onOpenGuide){const s=c.createElement("button");s.type="button",s.innerHTML=_t.help,s.setAttribute("aria-label","User guide"),Object.assign(s.style,{..._e("bare"),display:"inline-flex",alignItems:"center",justifyContent:"center",width:"24px",height:"24px",flexShrink:"0"}),fe(s,"bare"),Ie(s,"User guide"),s.addEventListener("click",()=>B.onOpenGuide()),Object.assign(s.style,{marginLeft:"auto"}),g=s}_.appendChild(h),g&&_.appendChild(g);const p=R!==null?r?.find(s=>s.key===R):void 0,o=p?.items??d,l=p?void 0:r,b=ke(o),k=b.defs,C=k.filter(Le);if(H!==null&&!C.some(s=>s.testNumber===H)&&(H=null),d.length===0){const s=c.createElement("div");s.dataset.wmapInsightsFilterEmpty="1",s.textContent="The filter keeps no wafer and no die. Edit the filter or switch it off to see the data.",Object.assign(s.style,{color:W.label,fontSize:N.body,padding:O.xl}),Q.appendChild(s);return}const L=e?.keepSections?ne.get(z):void 0,w=L??(z==="overview"?pt(o,C,k,l,f):z==="distributions"?yt(o,C,l,f):z==="data"?gt(o,C,k,l,f):z==="plot"?bt(o,k,p?void 0:F,p?void 0:f):wt(o,C,l));L||ne.set(z,w);const S=b.conflicts.filter(s=>s.excluded);if(S.length>0){const s=c.createElement("div");Object.assign(s.style,{color:W.label,fontSize:N.body,padding:`0 ${J} ${O.sm}`});const m=S.slice(0,6).map(i=>i.testNumber).join(", "),x=S.length>6?`, and ${S.length-6} more`:"",E=S.length===1?"it":"them";s.textContent=`${S.length} test ${S.length===1?"number is":"numbers are"} hidden (${m}${x}) \u2014 the wafers in view describe ${E} differently, so their values cannot be pooled. `+(r&&r.length>0?`Pick one ${f??"group"} under "Show:" to analyse ${E}.`:"Load one test program at a time to analyse them."),s.dataset.wmapWithheldTests=String(S.length),Q.appendChild(s)}Q.appendChild(w.card)}return{el:G,render:q,destroy:()=>{Me(),ee.flush(),G.remove()},setAxisPrefs:e=>we(e,null,!0),showWorthCard:e=>{z!=="overview"&&(z="overview",q({keepSections:!0}));const t=[...Q.querySelectorAll("[data-wmap-worth-key]")].find(u=>u.dataset.wmapWorthKey===e);if(!t)return!1;const n=c.defaultView,d=()=>t.scrollIntoView({block:"center"});return n?.requestAnimationFrame?n.requestAnimationFrame(()=>n.requestAnimationFrame(d)):d(),t.style.outline=`2px solid ${W.iconActive}`,t.style.outlineOffset="2px",setTimeout(()=>{t.style.outline="",t.style.outlineOffset=""},1600),!0}}}
@@ -0,0 +1,84 @@
1
+ import type { Die } from '../core/dies.js';
2
+ import type { Wafer } from '../core/wafer.js';
3
+ import type { TestDef } from '../renderer/buildWaferMap.js';
4
+ import type { StatsSummary } from '../stats/types.js';
5
+ import { type FacetCuration } from '../stats/facets.js';
6
+ import { type PlotFilter } from '../stats/plotSpec.js';
7
+ import { type SavedFilter } from '../stats/filterFile.js';
8
+ import { type ConditionsApplied } from '../stats/plotData.js';
9
+ import { type SaveTextHandler } from './toolbar.js';
10
+ /** What the filter reads of a wafer. Insights' items and the gallery's cards both have this shape. */
11
+ export interface FilterSource {
12
+ dies: Die[];
13
+ wafer: Wafer;
14
+ /** Shown in a plot's title; the wafer's identity when it has one. */
15
+ label: string;
16
+ identity?: string;
17
+ waferIndex: number;
18
+ passBins: readonly number[];
19
+ testDefs?: TestDef[];
20
+ statsSummary?: StatsSummary;
21
+ }
22
+ export interface PageFilterOptions {
23
+ /** The filter to start with, as the host stored it (read like a plots file, so a stale one is tolerated). */
24
+ initial?: unknown;
25
+ /** Called with the filter after the reader applies, switches or removes it. */
26
+ onChange?: (filter: PlotFilter | undefined) => void;
27
+ attributes?: Record<string, FacetCuration>;
28
+ getRingCount: () => number;
29
+ doc: Document;
30
+ /** The host's saved filters to start with, read as a filters file's are: one it cannot read is left out and logged. */
31
+ savedFilters?: readonly unknown[];
32
+ /** Called with the whole list after the reader saves, deletes or imports a filter. */
33
+ onSavedFiltersChange?: (filters: SavedFilter[]) => void;
34
+ /** Choose a filters file to import, resolving to its text, or `null` when cancelled. Without it the browser's own file input is used. */
35
+ pickFiltersFile?: () => Promise<string | null>;
36
+ onSaveText?: SaveTextHandler;
37
+ }
38
+ export interface PageFilterBand {
39
+ el: HTMLElement;
40
+ /** Show the filter and what it kept; hides the band when there is no filter. */
41
+ refresh(result: ConditionsApplied | undefined, sources: readonly FilterSource[]): void;
42
+ }
43
+ export interface PageFilterController {
44
+ get(): PlotFilter | undefined;
45
+ /** Set (or with `undefined` remove) the filter: the host is told and every subscribed view re-renders. */
46
+ set(filter: PlotFilter | undefined): void;
47
+ /** Called after every change; returns the unsubscribe. */
48
+ subscribe(fn: () => void): () => void;
49
+ /** The wafers and dies the filter keeps; the rest are gone. `result` is undefined with no filter in force. */
50
+ keep<T extends FilterSource>(sources: readonly T[]): {
51
+ items: T[];
52
+ result?: ConditionsApplied;
53
+ narrowing: boolean;
54
+ };
55
+ /**
56
+ * Every wafer, in place: dies the filter drops are copies flagged `filteredOut`, a narrowed wafer loses its summary
57
+ * (it describes every die), and `hidden` holds the positions of wafers dropped whole.
58
+ */
59
+ mark<T extends FilterSource>(sources: readonly T[]): {
60
+ items: T[];
61
+ hidden: Set<number>;
62
+ result?: ConditionsApplied;
63
+ narrowing: boolean;
64
+ };
65
+ createBand(sources: () => readonly FilterSource[], inset?: {
66
+ marginLeft: string;
67
+ marginRight: string;
68
+ marginBottom: string;
69
+ }): PageFilterBand;
70
+ /** The saved filters, in the order they were kept. */
71
+ saved(): readonly SavedFilter[];
72
+ /** Replace the list (the host is told). */
73
+ setSaved(filters: readonly SavedFilter[]): void;
74
+ /** The editor window, over the population given. */
75
+ openEditor(anchor: HTMLElement, sources: readonly FilterSource[]): void;
76
+ }
77
+ /**
78
+ * A filter as the host gave it, read by the plots file's own reader: a host restores it from storage, where it may be
79
+ * malformed or written by another version. A condition that cannot be read is left out and the problem logged; the band
80
+ * then states the filter that is applied, so nothing is filtered unseen.
81
+ */
82
+ export declare function readFilterOption(raw: unknown): PlotFilter | undefined;
83
+ export declare function createPageFilter(o: PageFilterOptions): PageFilterController;
84
+ //# sourceMappingURL=pageFilter.d.ts.map