@wafertools/wafermap 0.40.0 → 0.41.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (220) hide show
  1. package/AGENTS.md +20 -21
  2. package/CHANGELOG.md +154 -0
  3. package/README.md +6 -6
  4. package/dist/packages/canvas-adapter/canvasTheme.d.ts +12 -0
  5. package/dist/packages/canvas-adapter/canvasTheme.js +1 -1
  6. package/dist/packages/canvas-adapter/cellShade.d.ts +2 -2
  7. package/dist/packages/canvas-adapter/cellShade.js +1 -1
  8. package/dist/packages/canvas-adapter/chartPopulation.d.ts +3 -0
  9. package/dist/packages/canvas-adapter/chartPopulation.js +1 -1
  10. package/dist/packages/canvas-adapter/charts/capability.d.ts +3 -0
  11. package/dist/packages/canvas-adapter/charts/capability.js +1 -1
  12. package/dist/packages/canvas-adapter/charts/cardAbout.d.ts +2 -1
  13. package/dist/packages/canvas-adapter/charts/cardAbout.js +1 -1
  14. package/dist/packages/canvas-adapter/charts/chartShell.d.ts +47 -27
  15. package/dist/packages/canvas-adapter/charts/chartShell.js +1 -1
  16. package/dist/packages/canvas-adapter/charts/commonality.js +4 -4
  17. package/dist/packages/canvas-adapter/charts/correlation.d.ts +6 -12
  18. package/dist/packages/canvas-adapter/charts/correlation.js +1 -1
  19. package/dist/packages/canvas-adapter/charts/divergingScale.d.ts +45 -15
  20. package/dist/packages/canvas-adapter/charts/divergingScale.js +1 -1
  21. package/dist/packages/canvas-adapter/charts/groupComparison.js +1 -1
  22. package/dist/packages/canvas-adapter/charts/palette.d.ts +16 -30
  23. package/dist/packages/canvas-adapter/charts/palette.js +1 -1
  24. package/dist/packages/canvas-adapter/charts/patCard.js +1 -1
  25. package/dist/packages/canvas-adapter/charts/plotChart.d.ts +29 -3
  26. package/dist/packages/canvas-adapter/charts/plotChart.js +1 -1
  27. package/dist/packages/canvas-adapter/charts/regionYieldDiagram.d.ts +3 -0
  28. package/dist/packages/canvas-adapter/charts/regionYieldDiagram.js +1 -1
  29. package/dist/packages/canvas-adapter/charts/sweep.d.ts +3 -0
  30. package/dist/packages/canvas-adapter/charts/sweep.js +1 -1
  31. package/dist/packages/canvas-adapter/chromeRow.d.ts +68 -0
  32. package/dist/packages/canvas-adapter/chromeRow.js +1 -0
  33. package/dist/packages/canvas-adapter/chunked.d.ts +6 -0
  34. package/dist/packages/canvas-adapter/chunked.js +1 -1
  35. package/dist/packages/canvas-adapter/columnFilterPopup.d.ts +25 -0
  36. package/dist/packages/canvas-adapter/columnFilterPopup.js +1 -0
  37. package/dist/packages/canvas-adapter/composePng.d.ts +37 -0
  38. package/dist/packages/canvas-adapter/composePng.js +1 -0
  39. package/dist/packages/canvas-adapter/dataTab.d.ts +39 -6
  40. package/dist/packages/canvas-adapter/dataTab.js +1 -1
  41. package/dist/packages/canvas-adapter/dieList.js +1 -1
  42. package/dist/packages/canvas-adapter/differenceMapPanel.d.ts +3 -1
  43. package/dist/packages/canvas-adapter/differenceMapPanel.js +1 -1
  44. package/dist/packages/canvas-adapter/drilldown.d.ts +20 -1
  45. package/dist/packages/canvas-adapter/drilldown.js +1 -1
  46. package/dist/packages/canvas-adapter/filterButton.d.ts +2 -0
  47. package/dist/packages/canvas-adapter/filterButton.js +1 -1
  48. package/dist/packages/canvas-adapter/filterEditor.d.ts +5 -0
  49. package/dist/packages/canvas-adapter/filterEditor.js +1 -1
  50. package/dist/packages/canvas-adapter/guideWindow.js +1 -1
  51. package/dist/packages/canvas-adapter/icons.js +1 -1
  52. package/dist/packages/canvas-adapter/identityHeader.d.ts +5 -0
  53. package/dist/packages/canvas-adapter/identityHeader.js +1 -1
  54. package/dist/packages/canvas-adapter/index.d.ts +7 -0
  55. package/dist/packages/canvas-adapter/index.js +1 -1
  56. package/dist/packages/canvas-adapter/insightsTab.d.ts +32 -9
  57. package/dist/packages/canvas-adapter/insightsTab.js +1 -1
  58. package/dist/packages/canvas-adapter/maplessSummary.d.ts +4 -2
  59. package/dist/packages/canvas-adapter/maplessSummary.js +1 -1
  60. package/dist/packages/canvas-adapter/openWaferMode.d.ts +7 -0
  61. package/dist/packages/canvas-adapter/openWaferMode.js +1 -0
  62. package/dist/packages/canvas-adapter/panelChart.d.ts +7 -0
  63. package/dist/packages/canvas-adapter/panelChart.js +1 -0
  64. package/dist/packages/canvas-adapter/panelTable.d.ts +50 -0
  65. package/dist/packages/canvas-adapter/panelTable.js +1 -0
  66. package/dist/packages/canvas-adapter/plotCard.js +1 -1
  67. package/dist/packages/canvas-adapter/plotEditor.d.ts +12 -0
  68. package/dist/packages/canvas-adapter/plotEditor.js +10 -10
  69. package/dist/packages/canvas-adapter/plotItems.d.ts +9 -4
  70. package/dist/packages/canvas-adapter/plotItems.js +1 -1
  71. package/dist/packages/canvas-adapter/plotJsonComplete.js +1 -1
  72. package/dist/packages/canvas-adapter/plotModal.d.ts +7 -0
  73. package/dist/packages/canvas-adapter/plotModal.js +1 -1
  74. package/dist/packages/canvas-adapter/plotStore.js +1 -1
  75. package/dist/packages/canvas-adapter/plotTab.d.ts +60 -2
  76. package/dist/packages/canvas-adapter/plotTab.js +1 -1
  77. package/dist/packages/canvas-adapter/renderWaferGallery.d.ts +7 -0
  78. package/dist/packages/canvas-adapter/renderWaferGallery.js +1 -1
  79. package/dist/packages/canvas-adapter/renderWaferMap.d.ts +41 -9
  80. package/dist/packages/canvas-adapter/renderWaferMap.js +1 -1
  81. package/dist/packages/canvas-adapter/reportCharts.d.ts +41 -0
  82. package/dist/packages/canvas-adapter/reportCharts.js +1 -0
  83. package/dist/packages/canvas-adapter/reportExport.d.ts +91 -0
  84. package/dist/packages/canvas-adapter/reportExport.js +1 -0
  85. package/dist/packages/canvas-adapter/reportFigures.d.ts +29 -0
  86. package/dist/packages/canvas-adapter/reportFigures.js +1 -0
  87. package/dist/packages/canvas-adapter/reportRun.d.ts +9 -0
  88. package/dist/packages/canvas-adapter/reportRun.js +1 -0
  89. package/dist/packages/canvas-adapter/selectionOverlay.d.ts +12 -0
  90. package/dist/packages/canvas-adapter/selectionOverlay.js +1 -0
  91. package/dist/packages/canvas-adapter/summaryPanel.d.ts +152 -111
  92. package/dist/packages/canvas-adapter/summaryPanel.js +7 -4
  93. package/dist/packages/canvas-adapter/summaryToggle.js +1 -1
  94. package/dist/packages/canvas-adapter/tableDrilldown.d.ts +48 -0
  95. package/dist/packages/canvas-adapter/tableDrilldown.js +1 -0
  96. package/dist/packages/canvas-adapter/tableFilter.d.ts +42 -0
  97. package/dist/packages/canvas-adapter/tableFilter.js +1 -0
  98. package/dist/packages/canvas-adapter/tablePlots.d.ts +85 -0
  99. package/dist/packages/canvas-adapter/tablePlots.js +1 -0
  100. package/dist/packages/canvas-adapter/themeWatch.d.ts +7 -0
  101. package/dist/packages/canvas-adapter/themeWatch.js +1 -0
  102. package/dist/packages/canvas-adapter/toCanvas.d.ts +3 -0
  103. package/dist/packages/canvas-adapter/toCanvas.js +1 -1
  104. package/dist/packages/canvas-adapter/toolbar.d.ts +125 -36
  105. package/dist/packages/canvas-adapter/toolbar.js +2 -2
  106. package/dist/packages/canvas-adapter/userGuideHtml.d.ts +1 -1
  107. package/dist/packages/canvas-adapter/userGuideHtml.js +530 -414
  108. package/dist/packages/canvas-adapter/version.d.ts +2 -2
  109. package/dist/packages/canvas-adapter/version.js +1 -1
  110. package/dist/packages/canvas-adapter/viewSwitch.js +1 -1
  111. package/dist/packages/canvas-adapter/virtualTable.d.ts +37 -7
  112. package/dist/packages/canvas-adapter/virtualTable.js +1 -1
  113. package/dist/packages/core/aggregates.d.ts +14 -0
  114. package/dist/packages/core/aggregates.js +1 -1
  115. package/dist/packages/core/dies.d.ts +7 -0
  116. package/dist/packages/core/dies.js +1 -1
  117. package/dist/packages/core/utils.d.ts +2 -0
  118. package/dist/packages/core/utils.js +1 -1
  119. package/dist/packages/experimental/charts.d.ts +4 -0
  120. package/dist/packages/experimental/charts.js +1 -0
  121. package/dist/packages/renderer/binColors.d.ts +6 -2
  122. package/dist/packages/renderer/binColors.js +1 -1
  123. package/dist/packages/renderer/buildView.d.ts +36 -14
  124. package/dist/packages/renderer/buildView.js +1 -1
  125. package/dist/packages/renderer/buildWaferMap.d.ts +8 -0
  126. package/dist/packages/renderer/buildWaferMap.js +1 -1
  127. package/dist/packages/renderer/categoryColors.d.ts +3 -0
  128. package/dist/packages/renderer/categoryColors.js +1 -0
  129. package/dist/packages/renderer/colorMap.d.ts +15 -16
  130. package/dist/packages/renderer/colorMap.js +1 -1
  131. package/dist/packages/renderer/colorSchemes.d.ts +34 -30
  132. package/dist/packages/renderer/colorSchemes.js +1 -1
  133. package/dist/packages/renderer/dataColors.d.ts +126 -0
  134. package/dist/packages/renderer/dataColors.js +1 -0
  135. package/dist/packages/renderer/deprecate.js +1 -1
  136. package/dist/packages/renderer/fmt.d.ts +16 -0
  137. package/dist/packages/renderer/fmt.js +1 -1
  138. package/dist/packages/renderer/index.d.ts +2 -0
  139. package/dist/packages/renderer/index.js +1 -1
  140. package/dist/packages/renderer/spec.d.ts +5 -0
  141. package/dist/packages/renderer/spec.js +1 -1
  142. package/dist/packages/renderer/stacks.d.ts +21 -0
  143. package/dist/packages/renderer/stacks.js +1 -0
  144. package/dist/packages/renderer/timeAxis.d.ts +19 -0
  145. package/dist/packages/renderer/timeAxis.js +1 -0
  146. package/dist/packages/stats/analyzeWaferLot.js +1 -1
  147. package/dist/packages/stats/analyzeWaferMap.d.ts +2 -4
  148. package/dist/packages/stats/analyzeWaferMap.js +1 -1
  149. package/dist/packages/stats/binRows.js +1 -1
  150. package/dist/packages/stats/binShifts.d.ts +59 -0
  151. package/dist/packages/stats/binShifts.js +1 -0
  152. package/dist/packages/stats/capability.d.ts +6 -1
  153. package/dist/packages/stats/capability.js +1 -1
  154. package/dist/packages/stats/chartCatalogue.d.ts +3 -0
  155. package/dist/packages/stats/chartCatalogue.js +1 -1
  156. package/dist/packages/stats/clusterDetection.js +1 -1
  157. package/dist/packages/stats/columnPlot.d.ts +38 -0
  158. package/dist/packages/stats/columnPlot.js +1 -0
  159. package/dist/packages/stats/commonality.d.ts +8 -1
  160. package/dist/packages/stats/commonality.js +1 -1
  161. package/dist/packages/stats/correlation.d.ts +7 -2
  162. package/dist/packages/stats/correlation.js +1 -1
  163. package/dist/packages/stats/dataTable.d.ts +44 -0
  164. package/dist/packages/stats/dataTable.js +1 -0
  165. package/dist/packages/stats/dieRegions.js +1 -1
  166. package/dist/packages/stats/examplePicks.js +1 -1
  167. package/dist/packages/stats/facets.d.ts +11 -0
  168. package/dist/packages/stats/facets.js +1 -1
  169. package/dist/packages/stats/filterFindings.d.ts +21 -0
  170. package/dist/packages/stats/filterFindings.js +1 -1
  171. package/dist/packages/stats/groupEffects.d.ts +8 -0
  172. package/dist/packages/stats/groupEffects.js +1 -1
  173. package/dist/packages/stats/math.d.ts +2 -0
  174. package/dist/packages/stats/math.js +1 -1
  175. package/dist/packages/stats/overview.d.ts +114 -0
  176. package/dist/packages/stats/overview.js +1 -0
  177. package/dist/packages/stats/pat.d.ts +0 -2
  178. package/dist/packages/stats/pat.js +1 -1
  179. package/dist/packages/stats/patternClassification.d.ts +20 -3
  180. package/dist/packages/stats/patternClassification.js +1 -1
  181. package/dist/packages/stats/permutationNull.d.ts +16 -0
  182. package/dist/packages/stats/permutationNull.js +1 -0
  183. package/dist/packages/stats/plotData.d.ts +138 -12
  184. package/dist/packages/stats/plotData.js +1 -1
  185. package/dist/packages/stats/plotSpec.d.ts +10 -1
  186. package/dist/packages/stats/plotSpec.js +3 -3
  187. package/dist/packages/stats/plotTable.js +1 -1
  188. package/dist/packages/stats/plotWords.d.ts +52 -0
  189. package/dist/packages/stats/plotWords.js +1 -0
  190. package/dist/packages/stats/presentation.d.ts +63 -14
  191. package/dist/packages/stats/presentation.js +1 -1
  192. package/dist/packages/stats/presentationPresets.d.ts +35 -0
  193. package/dist/packages/stats/presentationPresets.js +1 -0
  194. package/dist/packages/stats/presentationSections.d.ts +83 -0
  195. package/dist/packages/stats/presentationSections.js +1 -0
  196. package/dist/packages/stats/renderSummaryReport.d.ts +80 -2
  197. package/dist/packages/stats/renderSummaryReport.js +1 -67
  198. package/dist/packages/stats/reportBlocks.d.ts +249 -0
  199. package/dist/packages/stats/reportBlocks.js +1 -0
  200. package/dist/packages/stats/reportContents.d.ts +22 -0
  201. package/dist/packages/stats/reportContents.js +1 -0
  202. package/dist/packages/stats/reportDeck.d.ts +245 -0
  203. package/dist/packages/stats/reportDeck.js +212 -0
  204. package/dist/packages/stats/reportHtml.d.ts +44 -43
  205. package/dist/packages/stats/reportHtml.js +82 -46
  206. package/dist/packages/stats/reportMaps.d.ts +67 -0
  207. package/dist/packages/stats/reportMaps.js +1 -0
  208. package/dist/packages/stats/reportSections.d.ts +55 -0
  209. package/dist/packages/stats/reportSections.js +1 -0
  210. package/dist/packages/stats/sweep.d.ts +14 -6
  211. package/dist/packages/stats/sweep.js +1 -1
  212. package/dist/packages/stats/synthesis.d.ts +87 -10
  213. package/dist/packages/stats/synthesis.js +1 -1
  214. package/dist/packages/stats/types.d.ts +22 -0
  215. package/dist/packages/stats/worthItems.d.ts +15 -0
  216. package/dist/packages/stats/worthItems.js +1 -0
  217. package/dist/packages/stats/yield.d.ts +13 -0
  218. package/dist/packages/stats/yield.js +1 -1
  219. package/llms.txt +1 -1
  220. package/package.json +6 -1
@@ -1,67 +1 @@
1
- import{waferDisplayLabel as k}from"../core/waferLabel.js";import{binPassSets as ke,binPassSetsByWafer as Ie,mergeBinDefs as ee,resolveBinColors as Ee,resolveBinColorsByWafer as He}from"../renderer/binColors.js";import{commonPassBins as Ae,itemPassBins as I,passBinsLabel as je}from"../core/passBins.js";import{itemRingCount as Ge}from"../core/ringCount.js";import{stackBinsAreData as qe}from"../core/aggregates.js";import{isParametricTest as E,isBuiltMap as te}from"../renderer/buildWaferMap.js";import{buildRingRegions as ne,buildQuadrantRegions as se,buildRegionYieldData as ze}from"./regions.js";import{openHtmlReport as Oe}from"./renderFindingsReport.js";import{analyzeWaferLot as _e}from"./analyzeWaferLot.js";import{computeFunctionalYield as Qe,analyzeWaferMap as Ve}from"./analyzeWaferMap.js";import{mergeTestDefs as Ue}from"./mergeTestDefs.js";import{buildFacetTable as Ke,facetValueOf as Je,FACET_NONE_VALUE as Xe}from"./facets.js";import{visibleFindings as H}from"./filterFindings.js";import{buildYieldDataCombined as Ze}from"./yield.js";import{describeWaferPopulation as ae,populationLabel as et}from"./population.js";import{buildTestPassRateData as tt,hasJudgeableTests as nt,poolFunctionalYield as st}from"./testPassRate.js";import{buildCapabilityData as at,pooledTestStatsSteps as it}from"./capability.js";import{buildSynthesis as ot}from"./synthesis.js";import{binBreakdownRows as rt,binBreakdownTitle as lt,binCountsFrom as ct,pooledBinCounts as dt,totalOf as ut}from"./binRows.js";import{MEAN_WAFER_YIELD_LABEL as ft,shortfallLegend as A}from"./presentation.js";import{regionYieldRows as ie,waferYieldRows as mt}from"./yieldRows.js";import{describeValues as pt}from"./math.js";import{fmt as N}from"../renderer/fmt.js";import{isYieldEligibleDie as j,getDieKey as gt,isPositionedDie as ht,diePassStatus as oe}from"../core/dies.js";import{excludedCounts as bt,testValue as yt}from"../core/dieTable.js";import{limitSetName as St}from"../renderer/valueFilter.js";import{findingsTableHtml as re,findingAnchor as wt,synthesisSectionHtml as $t,reportScripts as G,barCell as M,deltaCell as q,withSectionNav as le,renderMetadataSection as ce,renderMetricGrid as de,renderSection as x,renderTable as P,reportStyles as z}from"./reportHtml.js";import{escHtml as w,drain as vt}from"../core/utils.js";function O(e,i){return i===0?"\u2014":`${(e/i*100).toFixed(1)}%`}function Dt(e){if(!e)return"";const i=e.lot??e.lotId,o=e.wafer??e.waferId,s=[i,o].filter(Boolean).map(String);return s.length?` \u2014 ${s.map(w).join(" \xB7 ")}`:""}function ue(e,i,o,s,r){if(!e.size)return"";const t=rt(e,i,s).map(a=>{const l=a.passing?"muted-row":"",c=u=>({html:w(u),className:l});return[c(String(a.bin)),c(a.name??"\u2014"),c(String(a.count)),M(a.percent,`${a.percent.toFixed(1)}%`,l,r?.get(a.bin))]});return x(lt(o,ut(e)),P(["Bin","Name","Dies","Share"],t,{className:"compact"}))}function xt(e,i,o,s,r,t){const a=ke(e,r);return["hard","soft"].map(l=>ue(ct(e,l,l==="hard"?s.hard:s.soft),l==="hard"?i:o,l,a[l],t[l])).join(`
2
- `)}function fe(e,i,o,s){const r=new Set(s),t=new Map(o.map(n=>[gt(n),n]));if(!o.some(n=>n.hbin!=null||n.sbin!=null)||!i.length)return"";const l=[];for(const n of i){let m=0,y=0;for(const v of n.dieKeys){const S=t.get(v);if(!S||!j(S))continue;const p=oe(S,r);p!==void 0&&(y++,p&&m++)}y&&l.push({label:n.label,pass:m,total:y})}if(!l.length)return"";const{rows:c}=ie(l.map(n=>({key:n.label,label:n.label,n:n.total,passDies:n.pass,yieldPercent:n.pass/n.total*100}))),u=c.map(n=>[w(n.label),String(n.passDies),String(n.n),M(n.yieldPercent,O(n.passDies,n.n)),q(n.delta)]);return x(e,P(["Region","Pass","Total","Yield","vs wafer"],u,{className:"compact"})+`<p class="report-legend">${A("the wafer")}</p>`)}function Pt(e,i){const o=new Float64Array(e.length);let s=0;for(const y of e){const v=yt(y,i);v!==void 0&&Number.isFinite(v)&&(o[s++]=v)}if(s===0)return;const{count:r,min:t,mean:a,max:l,q1:c,median:u,q3:n,stddev:m}=pt(o.subarray(0,s));return{testNumber:i,count:r,min:t,mean:a,max:l,q1:c,median:u,q3:n,stddev:m}}function me(e,i,o,s,r,t){if(!i.length)return"";const a=e.filter(d=>j(d)),l=new Map((o??[]).map(d=>[d.testNumber,d])),c=new Map((s??[]).map(d=>[d.testNumber,d.yieldPercent])),u=[];for(const d of i.filter(E)){const f=l.get(d.testNumber)??Pt(a,d.testNumber);f&&u.push({name:d.name,unit:d.unit||void 0,stats:f,limitYield:c.get(d.testNumber)})}if(!u.length)return"";const n=d=>u.every(f=>f.stats[d]!==void 0),m=n("q1")&&n("median")&&n("q3"),y=n("stddev"),v=u.some(d=>d.limitYield!==void 0&&d.limitYield!==null),S=(d,f)=>d===void 0?"\u2014":N(d,f),p=bt(a),g=p?`${[...p.counts.values()].reduce((d,f)=>d+f,0).toLocaleString("en-GB")} values outside the ${St(p.by)} are excluded (not in N): `+[...p.counts].map(([d,f])=>`${w(i.find($=>$.testNumber===d)?.name??`test ${d}`)} ${f.toLocaleString("en-GB")}`).join(", ")+". ":"",b=["Test","N","Min",...m?["Q1","Median"]:[],"Mean",...m?["Q3"]:[],"Max",...y?["StdDev"]:[],...v?["Limit yield"]:[]],D=u.map(({name:d,unit:f,stats:$,limitYield:F})=>[w(d),{html:String($.count),className:"numeric"},S($.min,f),...m?[S($.q1,f),S($.median,f)]:[],S($.mean,f),...m?[S($.q3,f)]:[],S($.max,f),...y?[S($.stddev,f)]:[],...v?[F==null?"\u2014":`${F.toFixed(1)}%`]:[]]);return x("Test Values",P(b,D,{className:"compact"})+`<p class="report-legend">${y?"StdDev is the sample standard deviation (n\u22121). ":""}${g}${r??""}</p>`,"",t)}function pe(e,i,o,s){const r=o??Qe(e,i);if(!r?.length)return"";const t=r.map(a=>[w(a.label),String(a.totalDies),String(a.passDies),String(a.failDies),a.passRatePercent!==null?`${a.passRatePercent.toFixed(1)}%`:"\u2014"]);return x("Functional Tests",P(["Test","N","Pass","Fail","Pass Rate"],t,{className:"compact"}),"",s)}function ge(e,i){const o=at(e,i);if(!o.length)return"";const s=t=>t===null?"\u2014":t.toFixed(2),r=o.map(t=>[w(t.label),t.hasSpec?t.limitBasis==="spec"?`LSL ${N(t.lsl,t.unit)} \u2013 USL ${N(t.usl,t.unit)}`:`Lo limit ${N(t.lsl,t.unit)} \u2013 Hi limit ${N(t.usl,t.unit)}`:"\u2014",N(t.mean,t.unit),s(t.cp),s(t.cpk),s(t.pp),s(t.ppk)]);return x("Process Capability",P(["Test","Limits","Mean","Cp","Cpk","Pp","Ppk"],r,{className:"compact"}))}function he(e,i,o="",s=!1){const r=H(e);return r.length?x("Findings",re(r,i,o,s)):""}const _=e=>`report-tests-${e}`,Q=e=>`report-functional-${e}`;function be(e,i,o,s){const r=new Set(H(e.findings).map(a=>a.id)),t=a=>a.kind==="finding"?r.has(a.id)?wt(a.id,o):void 0:a.kind==="test"?s.get(a.testNumber):void 0;return $t(ot(e,{passBins:i?[...i]:void 0}),t)}function ye(e,i,o,s){const r=new Map;for(const t of e)(E(t)?o:s)&&r.set(t.testNumber,E(t)?_(i):Q(i));return r}export function renderSummaryReportHtml(e,i={}){const{wafer:o,dies:s,yieldSummary:r,dataCoverage:t,hbinDefs:a,sbinDefs:l,testDefs:c=[],statsSummary:u,passBins:n,ringCount:m}=e,y=e.binColors??Ee(s,{passBins:n,hbinDefs:a,sbinDefs:l}),v=o.metadata,S=Dt(v),p=i.title??`Wafer Summary${S}`,g=new Date().toLocaleString(),b=s.filter(ht),D=ne(b,o,m),d=se(b,o,m),f=qe(u?.stats.isLotStack,u?.stats.aggregationMethod),$=f?[{label:"Total dies",value:String(r.totalDies)},{label:"Filled dies",value:String(t.filledDies),hint:`${O(t.filledDies,t.totalDies)} fill`},{label:"Pass dies",value:String(r.passDies)},{label:"Fail dies",value:String(r.failDies)},...r.partialDies>0?[{label:"Partial",value:String(r.partialDies)}]:[],...r.yieldPercent!==null?[{label:`Yield (pass: ${je([n])})`,value:`${r.yieldPercent.toFixed(1)}%`}]:[],...r.edgeExcludedDies>0?[{label:"Edge excluded (outer zone)",value:String(r.edgeExcludedDies)}]:[]]:[{label:"Dies",value:String(s.length)},{label:"Filled dies",value:String(t.filledDies),hint:`${O(t.filledDies,t.totalDies)} fill`}],F=me(s,c,u?.stats.perTestStats,u?.stats.testSpecYield,void 0,_("")),B=pe(s,c,u?.stats.functionalYield,Q("")),C=[ce([{metadata:o.metadata}]),x("Summary",[de($)].filter(Boolean).join(`
3
- `)),u?be(u,n,"",ye(c,"",!!F,!!B)):"",f?xt(s,a,l,{hard:u?.stats.hardBinCounts,soft:u?.stats.softBinCounts},n,y):"",f?fe("Ring Yield",D,s,n):"",f?fe("Quadrant Yield",d,s,n):"",F,B,ge([{dies:s}],c),u?he(u.findings,void 0,"",e.live):""].filter(Boolean).join(`
4
- `);return`<!DOCTYPE html>
5
- <html lang="en">
6
- <head>
7
- <meta charset="UTF-8">
8
- <title>${w(p)}</title>
9
- <style>
10
- ${z()}
11
- </style>
12
- </head>
13
- <body>
14
- <main class="report">
15
- <header class="report-header">
16
- <h1>${w(p)}</h1>
17
- <p class="report-subtitle">Generated ${w(g)}</p>
18
- </header>
19
- ${le(C)}
20
- <p class="footer">Generated ${w(g)}</p>
21
- </main>
22
- ${G(e.live)}
23
- </body>
24
- </html>`}function Ft(e,i){const o=e.perWafer.flatMap(t=>{const a=t.summary.stats.yieldPercent;return a===null?[]:[{waferIndex:t.waferIndex,yieldPercent:a}]}),s=new Map(mt(o).rows.map(t=>[t.waferIndex,t])),r=e.perWafer.map(t=>{const a=w(k(i[t.waferIndex],t.waferIndex)),l=s.get(t.waferIndex);return l?[l.outlier?`${a} \xB7 ${l.outlier} outlier`:a,M(l.yieldPercent,`${l.yieldPercent.toFixed(1)}%`),q(l.delta)]:[a,"N/A",""]});return P(["Wafer","Yield","vs lot median"],r,{className:"compact"})+`<p class="report-legend">${A("the lot median")}</p>`}function Bt(e){const i=[];for(const t of e.perWafer){const a=H(t.summary.findings);if(!a.length)continue;const l=k({wafer:{metadata:t.summary.wafer}},t.waferIndex);i.push(`<h3 class="report-subheading">${w(l)}</h3>`+re(a))}if(!i.length)return"";const o=i.length,s=e.perWafer.length,r=`<p class="report-note">${o} of ${s} wafer${s===1?"":"s"} have per-wafer findings; the rest had none.</p>`;return x("Findings by Wafer",r+i.join(`
25
- `))}const Ct=3;function Tt(e,i,o){const s=e.map(c=>({metadata:c.wafer?.metadata})),r=Ke(s,{facetableOnly:!0}).filter(c=>c.splittable);if(!r.length)return"";const t=r.slice(0,Ct),a=[];for(const c of t){const u=new Map;e.forEach((g,b)=>{const D=Je(g.wafer?.metadata,c.key)??Xe;(u.get(D)??u.set(D,[]).get(D)).push(b)});const n=[...u.entries()].map(([g,b])=>({key:g,items:b.map(D=>e[D])}));if(n.length<2)continue;const m=n.map(g=>[w(g.key),w(g.items.map(b=>b.label).join(", "))]),y=Ze(n.map(g=>({key:g.key,items:g.items.map(b=>({label:b.label,dies:b.dies,passBins:I(b,o)}))}))).map(g=>[w(g.label),String(g.itemCount),`${g.percent.toFixed(1)}%`]),v=[P([c.label,"Wafers"],m,{className:"compact"}),P([c.label,"Wafers","Yield"],y,{className:"compact"})],S=e.flatMap(g=>g.dies??[]);let p=0;for(const g of["spec","testFlag","functional"]){if(!nt(i,g,S))continue;const b=tt(n.map(f=>({key:f.key,items:f.items.map($=>({dies:$.dies,testSpecYield:$.statsSummary?.stats.testSpecYield,functionalYield:$.statsSummary?.stats.functionalYield}))})),i,g);if(!b.rows.length)continue;const D=b.rows.map(f=>[w(f.label),...f.byGroup.map($=>$.passRatePercent===null?"\u2014":`${$.passRatePercent.toFixed(1)}%`),f.overall.passRatePercent===null?"\u2014":`${f.overall.passRatePercent.toFixed(1)}%`]),d=g==="spec"?"Pass rate \xB7 test limits":g==="testFlag"?"Pass rate \xB7 tester flag":"Pass rate \xB7 functional";b.disagreementDies&&(p=b.disagreementDies),v.push(`<h4 class="report-subheading">${w(d)}</h4>`+P(["Test",...b.groups,"All"],D,{className:"compact"}))}p&&v.push(`<p class="report-note">${p.toLocaleString()} dies judged differently by limits and tester flag.</p>`),a.push(`<h3 class="report-subheading">${w(c.label)}</h3>${v.join(`
26
- `)}`)}if(!a.length)return"";const l=r.length>t.length?`<p class="report-note">${r.length-t.length} further wafer field(s) not shown.</p>`:"";return x("Group Comparison",a.join(`
27
- `)+l)}function Yt(e,i,o,s,r,t){const a=Ie(r);return["hard","soft"].map(l=>ue(dt(s,e,l),l==="hard"?i:o,l,a[l],t[l])).join(`
28
- `)}function Se(e,i,o,s,r,t){const a=ze(o,s,r,c=>t[c],i);if(!a.length)return"";const l=ie(a).rows.map(c=>[w(c.label),M(c.yieldPercent,`${c.yieldPercent.toFixed(1)}%`),q(c.delta)]);return x(e,P(["Region","Yield","vs lot"],l,{className:"compact"})+`<p class="report-legend">${A("the lot")}</p>`)}function Nt(e,i,o,s,r,t){let a;if(s?.length&&s.every(c=>c.stats.perTestStats!==void 0)){const c=new Map;for(const u of s)for(const n of u.stats.perTestStats??[]){const m=c.get(n.testNumber)??{n:0,sum:0,min:1/0,max:-1/0,parts:[]};m.n+=n.count,m.sum+=n.mean*n.count,m.min=Math.min(m.min,n.min),m.max=Math.max(m.max,n.max),m.parts.push({n:n.count,mean:n.mean,sd:n.stddev}),c.set(n.testNumber,m)}a=[...c.entries()].map(([u,n])=>{const m=n.sum/n.n,y=n.parts.every(S=>S.sd!==void 0),v=y&&n.n>1?n.parts.reduce((S,p)=>S+Math.max(0,p.n-1)*p.sd**2+p.n*(p.mean-m)**2,0)/(n.n-1):y?0:void 0;return{testNumber:u,count:n.n,min:n.min,max:n.max,mean:m,...v!==void 0?{stddev:Math.sqrt(v)}:{}}})}const l=a?void 0:[...vt(it(e,o)).stats].map(([c,u])=>({testNumber:c,...u}));return me(i,o,a??l,r,a?"Quartiles are not shown for a lot: they cannot be combined from each wafer\u2019s own.":void 0,t)}function Mt(e,i,o,s){const r=st(o);return pe(e,i,r,s)}const V=["lot","product","testProgram","temperature"];function Rt(e){const i=new Map(V.map(t=>[t,new Set]));for(const t of e)for(const a of V){const l=t.wafer?.metadata?.[a];l!=null&&l!==""&&i.get(a).add(String(l))}const o=V.filter(t=>i.get(t).size>1);if(o.length===0)return[{label:"",items:e,varying:o}];const s=new Map,r=[];for(const t of e){const a=o.map(l=>String(t.wafer?.metadata?.[l]??"(none)")).join(" \xB7 ");s.has(a)||(s.set(a,[]),r.push(a)),s.get(a).push(t)}return r.map(t=>({label:t,items:s.get(t),varying:o}))}function we(e,i,o,s,r,t,a,l,c="",u=!1){const n=_e(e.map(h=>h.source??h),{perWaferSummaries:e.map(h=>h.statsSummary),...a}),m=[],y=[],v=[],S=[];for(const h of e){const T=h.dies??[];h.wafer&&(m.push(h.wafer),v.push(T),S.push(I(h,r)));for(const Y of T)y.push(Y)}const p=e.map(h=>({dies:h.dies??[],passBins:I(h,r)})),g=l??He(p,{hbinDefs:i,sbinDefs:o}).colors,b=y.some(h=>h.hbin!=null),D=y.some(h=>h.sbin!=null),d=b||D,f=n.perWafer.map(h=>h.summary.stats.yieldPercent).filter(h=>h!==null),$=f.length?f.reduce((h,T)=>h+T,0)/f.length:null;let F=0,B=0,C=0,R=0,W=0;for(const h of p){const T=new Set(h.passBins);for(const Y of h.dies){if(F++,Y.edgeExcluded&&R++,Y.partial&&W++,!j(Y))continue;const Z=oe(Y,T);Z!==void 0&&(B++,Z&&C++)}}const ve=B-C,U=B>0?C/B*100:null,De=[{label:"Wafers",value:String(n.stats.waferCount)},{label:"Total dies",value:String(F)},...d?[{label:"Good dies",value:String(C)},{label:"Bad dies",value:String(ve)}]:[],...R>0?[{label:"Edge excluded",value:String(R)}]:[],...W>0?[{label:"Partial dies",value:String(W)}]:[],...$!==null?[{label:ft,value:`${$.toFixed(1)}%`}]:[],...U!==null?[{label:"Total yield",value:`${U.toFixed(1)}%`}]:[]],xe=ae(n.perWafer.map(h=>h.summary.wafer)),Pe=x(xe.lotId!==void 0?"Lot Summary":"Summary",de(De)),Fe=ce(e.map(h=>({metadata:h.wafer?.metadata}))),Be=x("Per-Wafer Yield",Ft(n,e)),K=t??Ge(e[0]),Ce=Tt(e,s,r),L=n.perWafer.map(h=>h.summary),Te=d?Yt(y,i,o,L,p,g):"",Ye=d&&m.length?Se("Ring Yield (All Wafers)",ne,v,m,K,S):"",Ne=d&&m.length?Se("Quadrant Yield (All Wafers)",se,v,m,K,S):"",J=s.length?Nt(e,y,s,L,n.stats.testSpecYield,_(c)):"",X=s.length?Mt(y,s,L,Q(c)):"",Me=s.length?ge(e,s):"",Re=n.findings.length?he(n.findings,n.stats.waferCount,c,u):"",We=Bt(n),Le=[Pe,be(n,Ae(p.map(h=>h.passBins)),c,ye(s,c,!!J,!!X)),Fe,Be,Ce,Te,Ye,Ne,J,X,Me,Re,We].filter(Boolean).join(`
29
- `);return{lotSummary:n,sections:Le}}function $e(e,i,o,s=""){return`<main class="report">
30
- <header class="report-header">
31
- <h1>${w(e)}</h1>
32
- <p class="report-subtitle">Generated ${w(o)}</p>
33
- </header>
34
- ${le(i,s)}
35
- <p class="footer">Generated ${w(o)}</p>
36
- </main>`}export function renderLotSummaryReportHtml(e,i={}){const{items:o,hbinDefs:s,sbinDefs:r,testDefs:t=[],passBins:a,ringCount:l,analyzeOptions:c}=e,u=new Date().toLocaleString(),n=Rt(o);if(n.length===1){const{lotSummary:p,sections:g}=we(n[0].items,s,r,t,a,l,c,e.binColors,"",e.live),b=ae(p.perWafer.map(d=>d.summary.wafer)),D=i.title??(b.lotId!==void 0?`Lot Summary \u2014 ${b.lotId}`:`Summary \u2014 ${et(b)}`);return`<!DOCTYPE html>
37
- <html lang="en">
38
- <head>
39
- <meta charset="UTF-8">
40
- <title>${w(D)}</title>
41
- <style>
42
- ${z()}
43
- </style>
44
- </head>
45
- <body>
46
- ${$e(D,g,u)}
47
- ${G(e.live)}
48
- </body>
49
- </html>`}const m=i.title??"Summary",y=n.map((p,g)=>{const b=`g${g+1}-`,{lotSummary:D,sections:d}=we(p.items,s,r,t,a,l,c,e.binColors,b,e.live),f=p.varying.includes("lot")?void 0:D.lot?.lot??D.lot?.lotId,$=f?`${p.label} \xB7 Lot ${String(f)}`:p.label;return $e(`${m} \u2014 ${$}`,d,u,b)}),v=`<p style="max-width:1080px;margin:0 auto 8px;padding:8px 12px;background:var(--report-surface);border:1px solid var(--report-line);border-radius:4px;font-size:12px;color:var(--report-muted);">This load spans ${n.length} groups by identity \u2014 shown separately below so stats are never pooled across them.</p>`,S=y.map((p,g)=>`${g===0?"":'<hr style="max-width:1080px;margin:32px auto 0;border:none;border-top:3px solid var(--report-line-strong);">'}
50
- ${p}`).join(`
51
- `);return`<!DOCTYPE html>
52
- <html lang="en">
53
- <head>
54
- <meta charset="UTF-8">
55
- <title>${w(m)}</title>
56
- <style>
57
- ${z()}
58
- </style>
59
- </head>
60
- <body>
61
- <div class="report" style="padding-top:24px;">
62
- ${v}
63
- </div>
64
- ${S}
65
- ${G(e.live)}
66
- </body>
67
- </html>`}export{Oe as openHtmlReport};export function renderWaferReportHtml(e,i,o={}){return renderSummaryReportHtml({wafer:e.wafer,dies:e.dies,yieldSummary:e.yield,dataCoverage:e.dataCoverage,hbinDefs:e.hbinDefs,sbinDefs:e.sbinDefs,testDefs:e.testDefs,statsSummary:i??e.statsSummary??(te(e)?Ve(e):void 0),passBins:[...e.passBins],ringCount:e.ringCount,binColors:o.binColors,live:o.live},o)}export function renderLotReportHtml(e,i={}){const o=ee(e.map(t=>t.hbinDefs)),s=ee(e.map(t=>t.sbinDefs)),r=e.some(t=>t.testDefs?.length)?Ue([...e]).defs:void 0;return renderLotSummaryReportHtml({items:e.map((t,a)=>({label:k(t,a),wafer:t.wafer,dies:t.dies,passBins:[...t.passBins],statsSummary:t.statsSummary,source:te(t)?t:void 0})),hbinDefs:o.length?o:void 0,sbinDefs:s.length?s:void 0,testDefs:r,ringCount:e[0]?.ringCount,analyzeOptions:i.analyzeOptions,binColors:i.binColors,live:i.live},{title:i.title})}
1
+ import{waferDisplayLabel as W}from"../core/waferLabel.js";import{binPassSets as Se,binPassSetsByWafer as z,mergeBinDefs as ke,resolveBinColors as ft,resolveBinColorsByWafer as ut}from"../renderer/binColors.js";import{commonPassBins as mt,itemPassBins as I,passBinsLabel as ne}from"../core/passBins.js";import{itemRingCount as xe}from"../core/ringCount.js";import{stackBinsAreData as pt}from"../core/aggregates.js";import{defaultBinMode as ht,isParametricTest as G,isBuiltMap as se}from"../renderer/buildWaferMap.js";import{buildRingRegions as ve,buildQuadrantRegions as $e,buildRegionYieldData as gt}from"./regions.js";import{openHtmlReport as bt}from"./renderFindingsReport.js";import{analyzeWaferLot as wt}from"./analyzeWaferLot.js";import{computeFunctionalYield as yt,analyzeWaferMap as St}from"./analyzeWaferMap.js";import{mergeTestDefs as kt}from"./mergeTestDefs.js";import{attributeLabel as Me,buildFacetTable as ie,facetValueOf as _,FACET_NONE_VALUE as j}from"./facets.js";import{visibleFindings as H}from"./filterFindings.js";import{buildYieldDataCombined as De}from"./yield.js";import{describeWaferPopulation as Pe,populationLabel as xt}from"./population.js";import{buildTestPassRateData as vt,hasJudgeableTests as $t,poolFunctionalYield as Mt}from"./testPassRate.js";import{buildCapabilityData as Dt,pooledTestStatsSteps as Pt}from"./capability.js";import{buildSynthesis as Te,groupsDiffer as Tt}from"./synthesis.js";import{worthItems as q}from"./worthItems.js";import{comparableGrouping as Be}from"./groupEffects.js";import{binsByTestSection as Ce,comparedSection as Fe,dividesSection as Bt,finishSections as ae,itemsSections as Le,sitesSection as Re,synthesisForGroups as We}from"./presentationSections.js";import{binBreakdownRows as Ie,binBreakdownTitle as Ct,binCountsFrom as Ne,pooledBinCounts as V,totalOf as Ft}from"./binRows.js";import{SEVERITY_MARK as Lt,shortfallLegend as oe}from"./presentation.js";import{regionYieldRows as Ye,waferYieldRows as Rt}from"./yieldRows.js";import{describeValues as Wt}from"./math.js";import{fmt as Y}from"../renderer/fmt.js";import{isYieldEligibleDie as re,getDieKey as It,isPositionedDie as Nt,diePassStatus as Ee}from"../core/dies.js";import{excludedCounts as Yt,testValue as Et}from"../core/dieTable.js";import{limitSetName as Ot}from"../renderer/valueFilter.js";import{findingAnchor as At,buildMetadataRows as zt,renderReportHtml as Q}from"./reportHtml.js";import{compareTestsByGroup as Gt}from"./groupCompare.js";import{ONE_TEST_CHARTS as _t,REPORT_SECTIONS as Oe,chartSection as jt,sectionGroup as le,sectionLabel as Ae}from"./reportSections.js";import{binStackMaps as Ht,everyWaferValueMaps as qt,failStackMap as ze,mapOrder as Vt,presentationTests as Ge,stackedValueMap as Qt,valueMapSections as _e}from"./reportMaps.js";import{drain as Kt,listInWords as K}from"../core/utils.js";function de(e,t){return t===0?"\u2014":`${(e/t*100).toFixed(1)}%`}function Ut(e){if(!e)return"";const t=e.lot??e.lotId,s=e.wafer??e.waferId,n=[t,s].filter(Boolean).map(String);return n.length?` \u2014 ${n.join(" \xB7 ")}`:""}const je=e=>e.flat().filter(t=>t!==void 0),U=(e,t,s)=>{const n=new Set(Oe[s].filter(i=>i.presentation).map(i=>i.id)),r=t?[...new Set(t)].flatMap(i=>e.filter(a=>a.id===i)):e.filter(i=>!n.has(i.id));return r.some(i=>i.id==="findings")?r:r.map(i=>({...i,blocks:i.blocks.map(a=>a.kind==="synthesis"?{...a,findingsListed:!1}:a)}))};function He(e,t,s,n,r){if(!e.size)return;const i=Ie(e,t,n).map(a=>{const d=a.passing,l=f=>d?{text:f,muted:d}:f;return[l(String(a.bin)),l(a.name??"\u2014"),l(String(a.count)),{text:`${a.percent.toFixed(1)}%`,muted:d,bar:{percent:a.percent,color:r?.get(a.bin)}}]});return{id:"bins",title:Ct(s,Ft(e)),blocks:[{kind:"table",headers:["Bin","Name","Dies","Share"],rows:i,slide:{noun:"bins",describe:3}}]}}function Jt(e,t,s,n,r,i){const a=Se(e,r);return["hard","soft"].map(d=>He(Ne(e,d,d==="hard"?n.hard:n.soft),d==="hard"?t:s,d,a[d],i[d]))}function qe(e,t,s,n){const r=new Set(n),i=new Map(s.map(o=>[It(o),o]));if(!s.some(o=>o.hbin!=null||o.sbin!=null)||!t.length)return;const d=[];for(const o of t){let c=0,g=0;for(const u of o.dieKeys){const S=i.get(u);if(!S||!re(S))continue;const y=Ee(S,r);y!==void 0&&(g++,y&&c++)}g&&d.push({label:o.label,pass:c,total:g})}if(!d.length)return;const{rows:l}=Ye(d.map(o=>({key:o.label,label:o.label,n:o.total,passDies:o.pass,yieldPercent:o.pass/o.total*100}))),f=l.map(o=>[o.label,String(o.passDies),String(o.n),{text:de(o.passDies,o.n),bar:{percent:o.yieldPercent}},{delta:o.delta}]);return{id:"regions",title:e,blocks:[{kind:"table",headers:["Region","Pass","Total","Yield","vs wafer"],rows:f},{kind:"text",style:"legend",text:oe("the wafer")}]}}function Xt(e,t){const s=new Float64Array(e.length);let n=0;for(const g of e){const u=Et(g,t);u!==void 0&&Number.isFinite(u)&&(s[n++]=u)}if(n===0)return;const{count:r,min:i,mean:a,max:d,q1:l,median:f,q3:o,stddev:c}=Wt(s.subarray(0,n));return{testNumber:t,count:r,min:i,mean:a,max:d,q1:l,median:f,q3:o,stddev:c}}function Ve(e,t,s,n,r,i){if(!t.length)return;const a=e.filter(m=>re(m)),d=new Map((s??[]).map(m=>[m.testNumber,m])),l=new Map((n??[]).map(m=>[m.testNumber,m.yieldPercent])),f=[];for(const m of t.filter(G)){const b=d.get(m.testNumber)??Xt(a,m.testNumber);b&&f.push({name:m.name,unit:m.unit||void 0,stats:b,limitYield:l.get(m.testNumber)})}if(!f.length)return;const o=m=>f.every(b=>b.stats[m]!==void 0),c=o("q1")&&o("median")&&o("q3"),g=o("stddev"),u=f.some(m=>m.limitYield!==void 0&&m.limitYield!==null),S=(m,b)=>m===void 0?"\u2014":Y(m,b),y=Yt(a),k=y?`${[...y.counts.values()].reduce((m,b)=>m+b,0).toLocaleString("en-GB")} values outside the ${Ot(y.by)} are excluded (not in N): `+[...y.counts].map(([m,b])=>`${t.find(x=>x.testNumber===m)?.name??`test ${m}`} ${b.toLocaleString("en-GB")}`).join(", ")+". ":"",M=["Test","N","Min",...c?["Q1","Median"]:[],"Mean",...c?["Q3"]:[],"Max",...g?["StdDev"]:[],...u?["Limit yield"]:[]],$=f.map(({name:m,unit:b,stats:x,limitYield:P})=>[m,{text:String(x.count),numeric:!0},S(x.min,b),...c?[S(x.q1,b),S(x.median,b)]:[],S(x.mean,b),...c?[S(x.q3,b)]:[],S(x.max,b),...g?[S(x.stddev,b)]:[],...u?[P==null?"\u2014":`${P.toFixed(1)}%`]:[]]),h=`${g?"StdDev is the sample standard deviation (n\u22121). ":""}${k}${r??""}`,v=["Test","Min","Mean","Max","StdDev","Limit yield"].map(m=>M.indexOf(m)).filter(m=>m>=0),w=M.indexOf("Limit yield");return{id:"test-values",title:"Test values",anchor:i,blocks:[{kind:"table",headers:M,rows:$,slide:{columns:v,noun:"tests",...w>=0?{rank:{column:w,worst:"low"},describe:w}:{}}},...h?[{kind:"text",style:"legend",text:h}]:[]]}}function Qe(e,t,s,n){const r=s??yt(e,t);if(!r?.length)return;const i=r.map(a=>[a.label,String(a.totalDies),String(a.passDies),String(a.failDies),a.passRatePercent!==null?`${a.passRatePercent.toFixed(1)}%`:"\u2014"]);return{id:"functional-tests",title:"Functional tests",anchor:n,blocks:[{kind:"table",headers:["Test","N","Pass","Fail","Pass Rate"],slide:{columns:[0,3,4],rank:{column:4,worst:"low"},noun:"functional tests",describe:4},rows:i}]}}function Ke(e,t){const s=Dt(e,t);if(!s.length)return;const n=s.filter(l=>l.hasSpec),r=s.length-n.length,i=r?[{kind:"text",style:"note",text:`${r} test${r===1?"":"s"} without both limits ${r===1?"is":"are"} not shown: capability needs both limits.`}]:[];if(!n.length)return{id:"capability",title:"Process capability",blocks:i};const a=l=>l===null?"\u2014":l.toFixed(2),d=n.map(l=>[l.label,l.limitBasis==="spec"?`LSL ${Y(l.lsl,l.unit)} \u2013 USL ${Y(l.usl,l.unit)}`:`Lo limit ${Y(l.lsl,l.unit)} \u2013 Hi limit ${Y(l.usl,l.unit)}`,Y(l.mean,l.unit),a(l.cp),a(l.cpk),a(l.pp),a(l.ppk)]);return{id:"capability",title:"Process capability",blocks:[{kind:"table",headers:["Test","Limits","Mean","Cp","Cpk","Pp","Ppk"],rows:d,slide:{columns:[0,1,2,4,6],rank:{column:6,worst:"low"},noun:"tests",describe:6}},...i]}}function Ue(e,t,s="",n=!1){const r=H(e);if(r.length)return{id:"findings",title:"Findings",blocks:[{kind:"findings",findings:r,totalWafers:t,scope:s,live:n}]}}const ce=(e,t)=>t==="soft"&&e.some(s=>s.sbin!=null)?"softBin":t==="hard"&&e.some(s=>s.hbin!=null)?"hardBin":ht([e]),Je=(e,t)=>t?.length?e.filter(s=>t.includes(s.testNumber)):e,Zt=(e,t)=>t?.filter(s=>G(e.find(n=>n.testNumber===s)));function fe(e,t,s,n){return Ie(e,t,s).flatMap(r=>{const i=n?.get(r.bin);return i?[{color:i,label:`${r.bin}${r.name?` ${r.name}`:""}${r.passing?" (pass)":""}`}]:[]})}function Xe(e,t,s,n,r,i){const a=t==="hardBin"?"hard":"soft",d=Ne(e,a,a==="hard"?n?.stats.hardBinCounts:n?.stats.softBinCounts);return fe(d,s,Se(e,r)[a],i[a])}function ue(e,t,s,n){if(!t?.length)return e;const r=Oe[s].map(d=>d.id),i=new Map;for(const d of new Set(t)){const l=jt(d,s);(i.get(l)??i.set(l,[]).get(l)).push(d)}const a=[...e];for(const d of r){const l=i.get(d);if(!l)continue;const f=a.some(g=>g.id===d),o={id:d,title:f?`${Ae(d,s)}: charts`:Ae(d,s),blocks:[{kind:"charts",charts:l.flatMap(g=>n?.length&&_t.has(g)?n.map(u=>({kind:"chart",cardId:g,test:u})):[{kind:"chart",cardId:g}])}]};let c=-1;a.forEach((g,u)=>{(f?g.id===d:r.indexOf(g.id)<r.indexOf(d))&&(c=u)}),a.splice(c+1,0,o)}return a}const en=["lot","waferId","product","testProgram","temperature","testDate"];function Ze(e,t){const s=new Map(ie(e,{facetableOnly:!1,...t?{curation:t}:{}}).map(r=>[r.key,r])),n=[];for(const r of en){const i=s.get(r);if(!i?.values.length||r==="waferId"&&e.length>1)continue;const a=i.values.map(d=>d.value);n.push({label:Me(r,t),value:a.length<=3?a.join(", "):`${a.length} values`})}return e.length>1&&n.push({label:"Wafers",value:String(e.length)}),n}function et(e){const t=zt(e);return t.length?{id:"wafer-info",title:"Wafer information",blocks:[{kind:"definitions",entries:t}]}:void 0}const me=e=>`report-tests-${e}`,pe=e=>`report-functional-${e}`;function tt(e,t,s,n){const r=new Set(H(e.findings).map(a=>a.id));return{id:"highlights",title:"Worth a look",className:"synthesis",blocks:[{kind:"synthesis",synthesis:t,anchorFor:a=>a.kind==="finding"?r.has(a.id)?At(a.id,s):void 0:a.kind==="test"?n.get(a.testNumber):void 0}]}}function nt(e,t,s,n){const r=new Map;for(const i of e)(G(i)?s:n)&&r.set(i.testNumber,G(i)?me(t):pe(t));return r}export function renderSummaryReportHtml(e,t={}){return Q(buildWaferReport(e,t),new Date().toLocaleString())}export function buildWaferReport(e,t={}){const{wafer:s,dies:n,yieldSummary:r,dataCoverage:i,hbinDefs:a,sbinDefs:d,testDefs:l=[],statsSummary:f,passBins:o,ringCount:c}=e,g=e.binColors??ft(n,{passBins:o,hbinDefs:a,sbinDefs:d}),u=s.metadata,S=Ut(u),y=t.title??`Wafer Summary${S}`,k=n.filter(Nt),M=ve(k,s,c),$=$e(k,s,c),h=pt(f?.stats.isLotStack,f?.stats.aggregationMethod),v=h?[{label:"Total dies",value:String(r.totalDies)},{label:"Filled dies",value:String(i.filledDies),hint:`${de(i.filledDies,i.totalDies)} fill`},{label:"Pass dies",value:String(r.passDies)},{label:"Fail dies",value:String(r.failDies)},...r.partialDies>0?[{label:"Partial",value:String(r.partialDies)}]:[],...r.yieldPercent!==null?[{label:`Yield (pass: ${ne([o])})`,value:`${r.yieldPercent.toFixed(1)}%`}]:[],...r.edgeExcludedDies>0?[{label:"Edge excluded (outer zone)",value:String(r.edgeExcludedDies)}]:[]]:[{label:"Dies",value:String(n.length)},{label:"Filled dies",value:String(i.filledDies),hint:`${de(i.filledDies,i.totalDies)} fill`}],w=Je(l,t.tests),m=f?Te(f,{passBins:[...o]}):void 0,b=ce(n,t.maps?.bins),x=e.source||e.charts?.length?Ge(l,t.tests,m?q(m):[],f?.findings??[],[n]):[],P=e.source&&x.length?_e([e.source],[y.replace(/^Wafer Summary — /,"")],x,t.valueMaps??{}):[],L=Ve(n,w,f?.stats.perTestStats,f?.stats.testSpecYield,void 0,me("")),R=Qe(n,w,f?.stats.functionalYield,pe("")),C=m?We(m,t.topics):void 0,E=[{dies:n,passBins:o}],J=je([v.length?{id:"summary",title:"Summary",blocks:[...m?[{kind:"text",style:"headline",text:m.headline}]:[],{kind:"metrics",items:v}]}:void 0,f&&C?tt(f,C,"",nt(w,"",!!L,!!R)):void 0,...f&&C&&h?Le(C,f.findings,void 0,{maps:[e.source],labels:[""],yields:[r.yieldPercent],waferFindings:()=>f.findings,binMap:(T,F)=>e.source?{kind:"bin-map",map:e.source,mode:b,binColors:g,outline:F}:void 0,valueMap:T=>e.source?qt([e.source],l.find(F=>F.testNumber===T)??{testNumber:T,name:String(T)})[0]:void 0,legend:Xe(n,b,b==="hardBin"?a:d,f,o,g)},t.items??{},""):[],h&&e.source&&n.some(T=>T.hbin!=null||T.sbin!=null)?{id:"wafer-map",title:"Wafer map",blocks:[{kind:"figure",alt:`Bin map of ${y.replace(/^Wafer Summary — /,"")}`,figure:{kind:"bin-map",map:e.source,mode:b,binColors:g},legend:Xe(n,b,b==="hardBin"?a:d,f,o,g)}]}:void 0,h?Jt(n,a,d,{hard:f?.stats.hardBinCounts,soft:f?.stats.softBinCounts},o,g):void 0,h?Ce(E,w):void 0,L,...P,R,Ke([{dies:n}],w),h?qe("Ring yield",M,n,o):void 0,h?qe("Quadrant yield",$,n,o):void 0,h?Re(E,w):void 0,m?Fe(m):void 0,et([{metadata:s.metadata}]),f?Ue(f.findings,void 0,"",e.live):void 0]);return{title:y,live:!!e.live,parts:[{title:y,scope:"",sections:ae(U(ue(J,e.charts,"wafer",x.map(T=>T.testNumber)),e.sections,"wafer"),T=>le(T.id,"wafer"),{items:C?q(C):[],wafers:E,specYield:f?.stats.testSpecYield})}],facts:Ze([{metadata:s.metadata}]),details:[{label:"Pass bins",value:ne([o])},{label:"Ring count",value:String(c)},{label:"Dies",value:String(n.length)},...r.edgeExcludedDies>0?[{label:"Edge excluded (outer zone)",value:String(r.edgeExcludedDies)}]:[]]}}function tn(e,t,s=!1,n=!1){const r=e.perWafer.flatMap(d=>{const l=d.summary.stats.yieldPercent;return l===null?[]:[{waferIndex:d.waferIndex,yieldPercent:l}]}),i=new Map(Rt(r).rows.map(d=>[d.waferIndex,d])),a=e.perWafer.map(d=>{const l=W(t[d.waferIndex],d.waferIndex),f=i.get(d.waferIndex);return f?[f.outlier?`${l} \xB7 ${f.outlier} outlier`:l,{text:`${f.yieldPercent.toFixed(1)}%`,bar:{percent:f.yieldPercent}},{delta:f.delta}]:[l,"N/A",""]});if(s||n){const d=[...i.values()].filter(u=>u.outlier),l=u=>`${W(t[u.waferIndex],u.waferIndex)} (${u.yieldPercent.toFixed(1)}%)`,f=d.filter(u=>u.outlier==="low"),o=d.filter(u=>u.outlier==="high"),c=[f.length?`Low outliers: ${K(f.map(l))}.`:"",o.length?`High outliers: ${K(o.map(l))}.`:""].filter(Boolean).join(" ")||"No wafer is an outlier.";return{id:"wafer-yield",title:"Per-wafer yield",blocks:[...s?[]:[{kind:"plots",plots:[{kind:"plot",key:"wafer-yield",wide:!0,spec:{chart:"bar",fields:{x:{builtin:"wafer"},y:{builtin:"yield"},color:{none:!0}},valueLabels:!0,axes:{y:{references:[{stat:"median"}]}}}}]}],{kind:"text",style:"note",text:c}]}}return{id:"wafer-yield",title:"Per-wafer yield",blocks:[{kind:"table",headers:["Wafer","Yield","vs lot median"],rows:a,slide:{rank:{column:1,worst:"low"},noun:"wafers",describe:1}},{kind:"text",style:"legend",text:oe("the lot median")}]}}function nn(e){const t=r=>Lt[r.severity].tier,s=[];for(const r of e.perWafer){const i=H(r.summary.findings);if(!i.length)continue;const a=f=>({text:String(i.filter(o=>t(o)===f).length),numeric:!0}),d=[...i].sort((f,o)=>["high","medium","low"].indexOf(t(f))-["high","medium","low"].indexOf(t(o)))[0],l=W({wafer:{metadata:r.summary.wafer}},r.waferIndex);s.push([l,a("high"),a("medium"),a("low"),`${d.comparison.left}: ${d.variable.label}`])}if(!s.length)return;const n=e.perWafer.length;return{id:"findings-by-wafer",title:"Findings by wafer",blocks:[{kind:"text",style:"note",text:`${s.length} of ${n} wafer${n===1?"":"s"} have per-wafer findings; the rest had none.`},{kind:"table",headers:["Wafer","High","Medium","Low","Strongest"],rows:s,slide:{rank:{column:1,worst:"high"},noun:"wafers with findings",describe:1}}]}}function sn(e,t=!1){if(t)return nn(e);const s=[];let n=0;for(const a of e.perWafer){const d=H(a.summary.findings);if(!d.length)continue;n++;const l=W({wafer:{metadata:a.summary.wafer}},a.waferIndex);s.push({kind:"subheading",level:3,text:l},{kind:"findings",findings:d})}if(!n)return;const r=e.perWafer.length;return{id:"findings-by-wafer",title:"Findings by wafer",blocks:[{kind:"text",style:"note",text:`${n} of ${r} wafer${r===1?"":"s"} have per-wafer findings; the rest had none.`},...s]}}const st=3;function an(e,t,s,n){const r=e.map(c=>({metadata:c.wafer?.metadata})),i=n,a=ie(r,{facetableOnly:!0,...n?{curation:n}:{}}).filter(c=>c.splittable),d=a.filter(c=>!Be(e.map(g=>_(g.wafer?.metadata,c.key,i)??j))),l=a.filter(c=>!d.includes(c));if(!l.length)return;const f=l.slice(0,st),o=[];for(const c of f){const g=new Map;e.forEach((h,v)=>{const w=_(h.wafer?.metadata,c.key,i)??j;(g.get(w)??g.set(w,[]).get(w)).push(v)});const u=[...g.entries()].map(([h,v])=>({key:h,items:v.map(w=>e[w])}));if(u.length<2)continue;const S=u.map(h=>[h.key,h.items.map(v=>v.label).join(", ")]),y=De(u.map(h=>({key:h.key,items:h.items.map(v=>({label:v.label,dies:v.dies,passBins:I(v,s)}))}))).map(h=>[h.label,String(h.itemCount),`${h.percent.toFixed(1)}%`]),k=[{kind:"table",headers:[c.label,"Wafers"],rows:S},{kind:"table",headers:[c.label,"Wafers","Yield"],rows:y}],M=e.flatMap(h=>h.dies??[]);let $=0;for(const h of["spec","testFlag","functional"]){if(!$t(t,h,M))continue;const v=vt(u.map(b=>({key:b.key,items:b.items.map(x=>({dies:x.dies,testSpecYield:x.statsSummary?.stats.testSpecYield,functionalYield:x.statsSummary?.stats.functionalYield}))})),t,h);if(!v.rows.length)continue;const w=v.rows.map(b=>[b.label,...b.byGroup.map(x=>x.passRatePercent===null?"\u2014":`${x.passRatePercent.toFixed(1)}%`),b.overall.passRatePercent===null?"\u2014":`${b.overall.passRatePercent.toFixed(1)}%`]),m=h==="spec"?"Pass rate \xB7 test limits":h==="testFlag"?"Pass rate \xB7 tester flag":"Pass rate \xB7 functional";v.disagreementDies&&($=v.disagreementDies),k.push({kind:"subheading",level:4,text:m},{kind:"table",headers:["Test",...v.groups,"All"],rows:w})}$&&k.push({kind:"text",style:"note",text:`${$.toLocaleString()} dies judged differently by limits and tester flag.`}),o.push({kind:"subheading",level:3,text:c.label},...k)}if(o.length)return l.length>f.length&&o.push({kind:"text",style:"note",text:`${l.length-f.length} further wafer field(s) not shown.`}),d.length&&o.push({kind:"text",style:"note",text:`Not compared: ${d.map(c=>c.label).join(", ")}. ${d.length===1?"Its groups are":"Their groups are"} too small or too many to compare: it takes two groups of at least two wafers each.`}),{id:"group-comparison",title:"Group comparison",blocks:o}}const on=6;function rn(e,t,s,n){const r=e.map(o=>({metadata:o.wafer?.metadata})),i=ie(r,{facetableOnly:!0,...n?{curation:n}:{}}).filter(o=>o.splittable&&Be(e.map(c=>_(c.wafer?.metadata,o.key,n)??j))).slice(0,st);if(!i.length)return[];const a=[],d=[];for(const o of i){const c=e.map(w=>({dies:w.dies??[],group:_(w.wafer?.metadata,o.key,n)??j})),g=Gt(c,t),u=g.filter(w=>Tt(w.pAdjusted,w.effect)).sort((w,m)=>Math.abs(m.effect)-Math.abs(w.effect));if(!u.length){d.push(o.label);continue}const S=new Map;e.forEach((w,m)=>{const b=c[m].group;(S.get(b)??S.set(b,[]).get(b)).push(w)});const y=De([...S].map(([w,m])=>({key:w,items:m.map(b=>({label:b.label,dies:b.dies,passBins:I(b,s)}))}))).sort((w,m)=>m.percent-w.percent).map(w=>`${w.label} ${w.percent.toFixed(1)}%`),k=u.slice(0,on),M=k.slice(0,3).map(w=>w.test.name),$=`${u.length} of ${g.length} test${g.length===1?"":"s"} differ by ${o.label} more than wafer-to-wafer variation explains (q < 0.05)`+(u.length===1?`: ${M[0]}.`:`. The largest shifts: ${K(M)}.`),h=u.length===1?{chart:"box",level:"wafer",aggregate:"mean",fields:{x:{meta:o.key},y:{test:k[0].test.testNumber},color:{meta:o.key}}}:{chart:"heatmap",level:"wafer",aggregate:"mean",normalize:"zscore",fields:{x:{meta:o.key},y:{tests:k.map(w=>w.test.testNumber)}}},v=[{kind:"text",style:"headline",text:$},{kind:"text",style:"note",text:`Yield by ${o.label}: ${y.join(", ")}.`},{kind:"plots",plots:[{kind:"plot",key:`compare-tests-${o.key}`,spec:h}]}];u.length>k.length&&v.push({kind:"text",style:"note",text:`The ${k.length} with the largest shifts are shown; ${u.length-k.length} more differ.`}),a.push({id:"group-comparison",title:`Group comparison \u2014 ${o.label}`,blocks:v})}const l=d.length?[{kind:"text",style:"note",text:`No test differs by ${K(d)} more than wafer-to-wafer variation explains.`}]:[];if(!a.length)return l.length?[{id:"group-comparison",title:"Group comparison",blocks:l}]:[];const f=a[a.length-1];return a[a.length-1]={...f,blocks:[...f.blocks,...l]},a}function ln(e,t,s,n,r,i){const a=z(r);return["hard","soft"].map(d=>He(V(n,e,d),d==="hard"?t:s,d,a[d],i[d]))}function dn(e,t,s,n,r,i,a){if(!a||e.length<2)return;const d=z(n)[i],l=new Map((r[i]??[]).map(c=>[c.bin,c.name])),f=[...V(s,t,i)].filter(([c,g])=>g>0&&!d.has(c)).sort((c,g)=>g[1]-c[1]).slice(0,a).map(([c])=>({bin:c,name:l.get(c)})),o=Ht(e,f,i);if(o.length)return{id:"bins",title:"Largest fail bins \u2014 stacked maps",blocks:[{kind:"figures",figures:o,legend:[],perSlide:o.length},{kind:"text",style:"legend",text:`Each die position is coloured by the number of the ${e.length} wafers that had the bin there.`}]}}function cn(e,t,s,n,r,i,a,d,l){const f=ce(s,l.bins),o=f==="hardBin"?"hard":"soft",g=Vt(e.perWafer,k=>k.summary.stats.yieldPercent,l.order).flatMap(k=>{const M=t[k.waferIndex];if(!M?.source)return[];const $=k.summary.stats.yieldPercent;return[{label:`${W(M,k.waferIndex)}${$===null?"":` \xB7 ${$.toFixed(1)}%`}`,figure:{kind:"bin-map",map:M.source,mode:f,binColors:d}}]});if(!g.length)return;const u=fe(V(i,s,o),o==="hard"?n:r,z(a)[o],d[o]),S=[],y=l.stacked?ze(t.flatMap(k=>k.source?[k.source]:[])):void 0;return y&&S.push({kind:"figure",figure:y,alt:`The wafers failing at each die position, of ${y.lotSize}`,legend:[],caption:`Stacked fails \xB7 ${y.lotSize} wafers`},{kind:"text",style:"legend",text:`Each die position is coloured by the number of the ${y.lotSize} wafers on which it fails, whatever the fail bin, each wafer judged by its own pass bins.`}),(l.grid!==!1||!y)&&S.push({kind:"figures",figures:g,legend:u,...l.perSlide&&l.perSlide!=="auto"?{perSlide:l.perSlide}:{}}),{id:"gallery",title:"Wafer maps",blocks:S}}function it(e,t,s,n,r,i){const a=gt(s,n,r,l=>i[l],t);if(!a.length)return;const d=Ye(a).rows.map(l=>[l.label,{text:`${l.yieldPercent.toFixed(1)}%`,bar:{percent:l.yieldPercent}},{delta:l.delta}]);return{id:"regions",title:e,blocks:[{kind:"table",headers:["Region","Yield","vs lot"],rows:d},{kind:"text",style:"legend",text:oe("the lot")}]}}function fn(e,t,s,n,r,i){let a;if(n?.length&&n.every(l=>l.stats.perTestStats!==void 0)){const l=new Map;for(const f of n)for(const o of f.stats.perTestStats??[]){const c=l.get(o.testNumber)??{n:0,sum:0,min:1/0,max:-1/0,parts:[]};c.n+=o.count,c.sum+=o.mean*o.count,c.min=Math.min(c.min,o.min),c.max=Math.max(c.max,o.max),c.parts.push({n:o.count,mean:o.mean,sd:o.stddev}),l.set(o.testNumber,c)}a=[...l.entries()].map(([f,o])=>{const c=o.sum/o.n,g=o.parts.every(S=>S.sd!==void 0),u=g&&o.n>1?o.parts.reduce((S,y)=>S+Math.max(0,y.n-1)*y.sd**2+y.n*(y.mean-c)**2,0)/(o.n-1):g?0:void 0;return{testNumber:f,count:o.n,min:o.min,max:o.max,mean:c,...u!==void 0?{stddev:Math.sqrt(u)}:{}}})}const d=a?void 0:[...Kt(Pt(e,s)).stats].map(([l,f])=>({testNumber:l,...f}));return Ve(t,s,a??d,r,a?"Quartiles are not shown for a lot: they cannot be combined from each wafer\u2019s own.":void 0,i)}function un(e,t,s,n){const r=Mt(s);return Qe(e,t,r,n)}const he=["lot","product","testProgram","temperature"];function mn(e){const t=new Map(he.map(i=>[i,new Set]));for(const i of e)for(const a of he){const d=i.wafer?.metadata?.[a];d!=null&&d!==""&&t.get(a).add(String(d))}const s=he.filter(i=>t.get(i).size>1);if(s.length===0)return[{label:"",items:e,varying:s}];const n=new Map,r=[];for(const i of e){const a=s.map(d=>`${Me(d)} ${String(i.wafer?.metadata?.[d]??"(none)")}`).join(" \xB7 ");n.has(a)||(n.set(a,[]),r.push(a)),n.get(a).push(i)}return r.map(i=>({label:i,items:n.get(i),varying:s}))}function at(e,t,s,n,r,i,a,d,l="",f=!1,o,c={}){const g=n;n=Je(g,c.tests);const u=wt(e.map(p=>p.source??p),{perWaferSummaries:e.map(p=>p.statsSummary),...a}),S=[],y=[],k=[],M=[];for(const p of e){const D=p.dies??[];p.wafer&&(S.push(p.wafer),k.push(D),M.push(I(p,r)));for(const B of D)y.push(B)}const $=e.map(p=>({dies:p.dies??[],passBins:I(p,r)})),h=d??ut($,{hbinDefs:t,sbinDefs:s}).colors,v=y.some(p=>p.hbin!=null),w=y.some(p=>p.sbin!=null),m=v||w;let b=0,x=0,P=0,L=0,R=0;for(const p of $){const D=new Set(p.passBins);for(const B of p.dies){if(b++,B.edgeExcluded&&L++,B.partial&&R++,!re(B))continue;const ye=Ee(B,D);ye!==void 0&&(x++,ye&&P++)}}const C=x-P,E=[{label:"Wafers",value:String(u.stats.waferCount)},{label:"Total dies",value:String(b)},...m?[{label:"Good dies",value:String(P)},{label:"Bad dies",value:String(C)}]:[],...L>0?[{label:"Edge excluded",value:String(L)}]:[],...R>0?[{label:"Partial dies",value:String(R)}]:[],...u.stats.yield?[{label:"Yield",value:`${u.stats.yield.yieldPercent.toFixed(1)}%`}]:[]],J=Pe(u.perWafer.map(p=>p.summary.wafer)),T=i??xe(e[0]),F=u.perWafer.map(p=>p.summary),ge=n.length?fn(e,y,n,F,u.stats.testSpecYield,me(l)):void 0,be=n.length?un(y,n,F,pe(l)):void 0,we=m&&S.length,O=Te(u,{passBins:mt($.map(p=>p.passBins))??void 0,...o?{attributes:o}:{}}),N=e.flatMap(p=>p.source?[p.source]:[]),ot=e.flatMap(p=>p.source?[p.label]:[]),X=N.length||c.charts?.length?Ge(g,c.tests,q(O),u.findings,k):[],rt=N.length&&X.length?_e(N,ot,X,c.valueMaps??{}):[],Z=We(O,c.topics),ee=e.map(p=>({dies:p.dies??[],passBins:I(p,r)})),te=ce(y,c.maps?.bins),A=te==="hardBin"?"hard":"soft",lt=fe(V(F,y,A),A==="hard"?t:s,z($)[A],h[A]),dt=je([{id:"summary",title:J.lotId!==void 0?"Lot summary":"Summary",blocks:[{kind:"text",style:"headline",text:O.headline},{kind:"metrics",items:E}]},tt(u,Z,l,nt(n,l,!!ge,!!be)),...m?Le(Z,u.findings,u.stats.waferCount,{maps:e.map(p=>p.source),labels:e.map((p,D)=>W(p,D)),yields:e.map((p,D)=>u.perWafer.find(B=>B.waferIndex===D)?.summary.stats.yieldPercent??null),waferFindings:p=>u.perWafer.find(D=>D.waferIndex===p)?.summary.findings,binMap:(p,D)=>{const B=e[p]?.source;return B?{kind:"bin-map",map:B,mode:te,binColors:h,outline:D}:void 0},stackedFails:p=>{const D=ze(N);return D?{...D,outline:p}:void 0},valueMap:p=>{const D=g.find(B=>B.testNumber===p);return D?Qt(N,D,c.valueMaps?.method??"mean"):void 0},legend:lt},c.items??{},l):[],tn(u,e,!!c.presentation&&!!c.charts?.includes("card-yield"),!!c.presentation),m?cn(u,e,y,t,s,F,$,h,c.maps??{}):void 0,m?ln(y,t,s,F,$,h):void 0,m?dn(N,y,F,$,{hard:t,soft:s},te==="softBin"?"soft":"hard",c.maps?.binStacks??0):void 0,m?Ce(ee,n):void 0,ge,...rt,be,n.length?Ke(e,n):void 0,we?it("Ring yield \u2014 all wafers",ve,k,S,T,M):void 0,we?it("Quadrant yield \u2014 all wafers",$e,k,S,T,M):void 0,m?Re(ee,n):void 0,Bt(e.flatMap(p=>p.dies?[{metadata:p.wafer?.metadata,dies:p.dies,passBins:I(p,r)}]:[]),o),...c.presentation?rn(e,n,r,o):[an(e,n,r,o)],Fe(O),et(e.map(p=>({metadata:p.wafer?.metadata}))),u.findings.length?Ue(u.findings,u.stats.waferCount,l,f):void 0,sn(u,!!c.presentation)]),ct={items:q(Z),wafers:ee,specYield:u.stats.testSpecYield,yields:u.perWafer.flatMap(p=>p.summary.stats.yieldPercent===null?[]:[{label:W(e[p.waferIndex]??{},p.waferIndex),yieldPercent:p.summary.stats.yieldPercent}])};return{lotSummary:u,sections:pn(ue(dt,c.charts,"lot",X.map(p=>p.testNumber)),l,c.wafers),sentences:ct}}export function renderLotSummaryReportHtml(e,t={}){return Q(buildLotReport(e,t),new Date().toLocaleString())}export function buildLotReport(e,t={}){const s={maps:t.maps,tests:t.tests,valueMaps:t.valueMaps,topics:t.topics,items:t.items,presentation:t.presentation},{items:n,hbinDefs:r,sbinDefs:i,testDefs:a=[],passBins:d,ringCount:l,analyzeOptions:f}=e,o=!!e.live,c=Ze(n.map(h=>({metadata:h.wafer?.metadata})),e.attributes),g=[{label:"Pass bins",value:ne(n.map(h=>I(h,d)))},{label:"Ring count",value:String(l??xe(n[0]))},{label:"Wafers",value:String(n.length)}],u=mn(n);if(u.length===1){const{lotSummary:h,sections:v,sentences:w}=at(u[0].items,r,i,a,d,l,f,e.binColors,"",o,e.attributes,{...s,charts:e.charts}),m=Pe(h.perWafer.map(x=>x.summary.wafer)),b=t.title??(m.lotId!==void 0?`Lot summary \u2014 ${m.lotId}`:`Summary \u2014 ${xt(m)}`);return{title:b,live:o,parts:[{title:b,scope:"",sections:ae(U(v,e.sections,"lot"),x=>le(x.id,"lot"),w)}],facts:c,details:g}}const S=t.title??"Summary",y=u.map((h,v)=>{const w=`g${v+1}-`,{lotSummary:m,sections:b,sentences:x}=at(h.items,r,i,a,d,l,f,e.binColors,w,o,e.attributes,{...s,charts:void 0,wafers:h.items.map(C=>n.indexOf(C))}),P=h.varying.includes("lot")?void 0:m.lot?.lot??m.lot?.lotId,L=P?`${h.label} \xB7 Lot ${String(P)}`:h.label,R=[`${h.items.length} wafer${h.items.length===1?"":"s"}`,...P?[`Lot ${String(P)}`]:[]].join(" \xB7 ");return{title:`${S} \u2014 ${L}`,heading:h.label,note:R,scope:w,sections:ae(U(b,e.sections,"lot"),C=>le(C.id,"lot"),x)}}),k=U(ue([],e.charts,"lot",Zt(a,s.tests)),e.sections,"lot");k.length&&y.unshift({title:`${S} \u2014 all ${n.length} wafers`,heading:`All ${n.length} wafers`,note:"The charts, drawn over every wafer",scope:"all-",sections:k});const M=new Set(n.map(h=>h.wafer?.metadata?.lot??h.wafer?.metadata?.lotId)),$=M.size===1?[...M][0]:void 0;return{title:t.title??($?`Lot summary \u2014 ${String($)}`:S),live:o,parts:y,facts:c,details:g,banner:`This load spans ${u.length} groups by identity \u2014 shown separately below so stats are never combined across them.`}}export{bt as openHtmlReport};function pn(e,t,s){if(!t&&!s)return e;const n=r=>({...r,key:`${t}${r.key}`,...s?{wafers:s}:{}});return e.map(r=>({...r,blocks:r.blocks.map(i=>i.kind==="evidence"&&i.chart?{...i,chart:n(i.chart)}:i.kind==="plots"?{...i,plots:i.plots.map(n)}:i)}))}export function waferReportOf(e,t,s={}){return{...buildWaferReport({wafer:e.wafer,dies:e.dies,yieldSummary:e.yield,dataCoverage:e.dataCoverage,hbinDefs:e.hbinDefs,sbinDefs:e.sbinDefs,testDefs:e.testDefs,statsSummary:t??e.statsSummary??(se(e)?St(e):void 0),passBins:[...e.passBins],ringCount:e.ringCount,binColors:s.binColors,live:s.live,source:se(e)?e:void 0,sections:s.sections,charts:s.charts},{title:s.title,maps:s.maps,tests:s.tests,valueMaps:s.valueMaps,topics:s.topics,items:s.items,presentation:s.presentation}),dataColors:s.dataColors}}export function renderWaferReportHtml(e,t,s={}){return Q(waferReportOf(e,t,s),new Date().toLocaleString())}export function lotReportOf(e,t={}){const s=ke(e.map(i=>i.hbinDefs)),n=ke(e.map(i=>i.sbinDefs)),r=e.some(i=>i.testDefs?.length)?kt([...e]).defs:void 0;return{...buildLotReport({items:e.map((i,a)=>({label:W(i,a),wafer:i.wafer,dies:i.dies,passBins:[...i.passBins],statsSummary:i.statsSummary,source:se(i)?i:void 0})),hbinDefs:s.length?s:void 0,sbinDefs:n.length?n:void 0,testDefs:r,ringCount:e[0]?.ringCount,analyzeOptions:t.analyzeOptions,binColors:t.binColors,live:t.live,attributes:t.attributes,sections:t.sections,charts:t.charts},{title:t.title,maps:t.maps,tests:t.tests,valueMaps:t.valueMaps,topics:t.topics,items:t.items,presentation:t.presentation}),dataColors:t.dataColors}}export function renderLotReportHtml(e,t={}){return Q(lotReportOf(e,t),new Date().toLocaleString())}
@@ -0,0 +1,249 @@
1
+ import type { PlotSpec } from './plotSpec.js';
2
+ import type { StatsFinding } from './types.js';
3
+ import type { Synthesis, SynthesisTarget } from './synthesis.js';
4
+ import type { WaferMapResult } from '../renderer/buildWaferMap.js';
5
+ import type { BinColors } from '../renderer/binColors.js';
6
+ /**
7
+ * Stable ids of the report's sections. A saved choice of sections names them, so an id is never renamed;
8
+ * a section that splits keeps its id on each part (the hard and soft bin tables are both `bins`).
9
+ */
10
+ export type ReportSectionId = 'summary' | 'highlights' | 'wafer-yield' | 'wafer-map' | 'gallery' | 'value-maps' | 'items' | 'compared' | 'divides' | 'bins-by-test' | 'sites' | 'bins' | 'test-values' | 'functional-tests' | 'capability' | 'regions' | 'group-comparison' | 'correlation' | 'my-plots' | 'wafer-info' | 'findings' | 'findings-by-wafer';
11
+ /** One cell of a table. A string is plain text. */
12
+ export type ReportCell = string | {
13
+ text: string;
14
+ /** A right-aligned figure. */
15
+ numeric?: boolean;
16
+ /** Written in grey, so the rows that matter carry the weight (pass bins in a bin table). */
17
+ muted?: boolean;
18
+ /** A bar beside the figure, 0–100, in `color` when given. */
19
+ bar?: {
20
+ percent: number;
21
+ color?: string;
22
+ };
23
+ /** Stands out from the rest of its row (a site failing a test far more than the others): drawn as a warning. */
24
+ flag?: true;
25
+ }
26
+ /** A signed difference in yield points, tinted when it is a shortfall. */
27
+ | {
28
+ delta: number;
29
+ };
30
+ /**
31
+ * A picture the report asks for. The report builders (stats, no DOM) only say what to draw; a writer that shows
32
+ * pictures has them drawn (canvas-adapter/reportFigures.ts) and a writer that does not (the HTML report) leaves them out.
33
+ */
34
+ export interface ReportBinMap {
35
+ kind: 'bin-map';
36
+ /** The built map, drawn as the app draws it (its own orientation, axis flip and pass bins). */
37
+ map: WaferMapResult;
38
+ mode: 'hardBin' | 'softBin';
39
+ /** The colours every map of the report shares, so a bin is one colour throughout. */
40
+ binColors: BinColors;
41
+ /** Dies to outline, the others faded, as Show on map draws an item's dies (`getDieKey` keys). */
42
+ outline?: readonly string[];
43
+ }
44
+ /** What a value map is drawn from: a built map, or a stack of the wafers' dies in the first wafer's frame. */
45
+ export type ReportValueMapSource = Pick<WaferMapResult, 'wafer' | 'dies' | 'passBins' | 'ringCount'> & Partial<Pick<WaferMapResult, 'testDefs' | 'reticles' | 'dataAxisFlip' | 'hbinDefs' | 'sbinDefs'>>;
46
+ /**
47
+ * A map drawn by value with its colour bar, in the app's own plot mode: one wafer's test values (`value`), or a stack over
48
+ * the wafers (`stackedValues`, `stackedFails`, test 0) built as the gallery builds its stacked cards (renderer/stacks.ts).
49
+ */
50
+ export interface ReportValueMap {
51
+ kind: 'value-map';
52
+ mode: 'value' | 'stackedValues' | 'stackedFails' | 'stackedBins' | 'stackedSoftBins';
53
+ map: ReportValueMapSource;
54
+ /** The test number the map shows (`TestDef.testNumber` in `map.testDefs`). */
55
+ test: number;
56
+ /** For a stack: the wafers in it, and how they were combined (a value stack's method, `countBin` for fails). */
57
+ lotSize?: number;
58
+ aggrMethod?: string;
59
+ /** Dies to outline, the others faded (`getDieKey` keys). */
60
+ outline?: readonly string[];
61
+ }
62
+ /**
63
+ * A chart made for the report (a Worth a look item's own, `SynthesisItem.chart`; a group comparison's), drawn as the
64
+ * Summary panel's Chart window draws it.
65
+ */
66
+ export interface ReportPlot {
67
+ kind: 'plot';
68
+ /** Its name, unique in the report (an item's `synthesisKey`, after its part's scope): the picture's name and the chart's id. */
69
+ key: string;
70
+ spec: Omit<PlotSpec, 'id'>;
71
+ /** The wafers it is drawn over, by their place in the report's maps: a part's own in a load split in several. All when absent. */
72
+ wafers?: number[];
73
+ /** Drawn wide, across a slide (a bar per wafer), rather than half of one. */
74
+ wide?: boolean;
75
+ }
76
+ /** An Insights chart, by its card id: drawn by the Insights view itself (canvas-adapter/reportCharts.ts). */
77
+ export interface ReportChart {
78
+ kind: 'chart';
79
+ cardId: string;
80
+ /** The test a one-test chart shows, when the report names its tests; else the test Insights opens on. */
81
+ test?: number;
82
+ }
83
+ export type ReportFigure = ReportBinMap | ReportValueMap | ReportChart | ReportPlot;
84
+ /** A legend row: a colour and what it stands for. */
85
+ export interface ReportSwatch {
86
+ color: string;
87
+ label: string;
88
+ }
89
+ export interface ReportMetric {
90
+ label: string;
91
+ value: string;
92
+ hint?: string;
93
+ }
94
+ /**
95
+ * How a table is put on a slide, where it may show only some of its rows (`reportDeck.ts`): the column that ranks them,
96
+ * the worst first, so what is left out matters least; the columns a slide shows; and what the left-out rows are called
97
+ * and which column describes them ("18 more tests: limit yield 99.2%–100.0%"). Rows that carry a warning (a shortfall's
98
+ * tint, a flagged or High cell) always come first. The printed Summary report shows every row and column.
99
+ */
100
+ export interface SlideTable {
101
+ /** The column whose figure ranks the rows, and which end is the bad news: `low` (a yield, a Ppk) or `high` (a count). */
102
+ rank?: {
103
+ column: number;
104
+ worst: 'low' | 'high';
105
+ };
106
+ /** The columns a slide shows, by index, in order; all when absent. */
107
+ columns?: number[];
108
+ /** What a row is, in the plural ("tests", "bins", "wafers"). */
109
+ noun: string;
110
+ /** The column whose range describes the rows left out (its header names it). */
111
+ describe?: number;
112
+ }
113
+ export type ReportBlock = {
114
+ kind: 'metrics';
115
+ items: ReportMetric[];
116
+ } | {
117
+ kind: 'definitions';
118
+ entries: Array<{
119
+ label: string;
120
+ value: string;
121
+ }>;
122
+ } | {
123
+ kind: 'table';
124
+ headers: string[];
125
+ rows: ReportCell[][];
126
+ emptyMessage?: string;
127
+ slide?: SlideTable;
128
+ }
129
+ /** A line under a table: what a column or a tint means (`legend`), or what was left out (`note`). */
130
+ /** `headline`: the sentence a group opens with (the Overview's), above its tables. */
131
+ | {
132
+ kind: 'text';
133
+ text: string;
134
+ style: 'legend' | 'note' | 'headline';
135
+ } | {
136
+ kind: 'subheading';
137
+ text: string;
138
+ level: 3 | 4;
139
+ }
140
+ /**
141
+ * The findings table. `scope` gives each row an anchor for the synthesis to link to, kept apart when one
142
+ * document holds several reports; absent for a table that is not the summary's one table (a per-wafer
143
+ * table would repeat anchors another wafer's table carries). `totalWafers` makes it a lot's table.
144
+ */
145
+ | {
146
+ kind: 'findings';
147
+ findings: StatsFinding[];
148
+ totalWafers?: number;
149
+ scope?: string;
150
+ live?: boolean;
151
+ }
152
+ /** One picture, large, with its legend beside it. */
153
+ | {
154
+ kind: 'figure';
155
+ figure: ReportFigure;
156
+ alt: string;
157
+ legend: ReportSwatch[];
158
+ /** A name under the picture, for a picture that is one of several kinds in its section (the Stacked fails map). */
159
+ caption?: string;
160
+ }
161
+ /** Many small pictures in a grid, each with a label, and one legend for them all (a lot's wafers). */
162
+ | {
163
+ kind: 'figures';
164
+ figures: Array<{
165
+ figure: ReportFigure;
166
+ label: string;
167
+ }>;
168
+ legend: ReportSwatch[];
169
+ /** Pictures to a slide, for a writer with slides; as many as fit at a readable size when absent. 1: each large, alone. */
170
+ perSlide?: number;
171
+ }
172
+ /** Charts, in the order chosen, two to a slide where a writer has room; each picture carries its own title. */
173
+ | {
174
+ kind: 'charts';
175
+ charts: ReportChart[];
176
+ }
177
+ /** An item's evidence, side by side: its chart, and the maps that show its dies (up to six, each labelled). */
178
+ | {
179
+ kind: 'evidence';
180
+ chart?: ReportPlot;
181
+ maps: Array<{
182
+ figure: ReportFigure;
183
+ label: string;
184
+ }>;
185
+ legend: ReportSwatch[];
186
+ }
187
+ /** Charts made for the report (`ReportPlot`), side by side: a presentation's own, as a group comparison's. */
188
+ | {
189
+ kind: 'plots';
190
+ plots: ReportPlot[];
191
+ }
192
+ /** Short labels in a row, each in its level's colour: an item's importance, strength and reach. */
193
+ | {
194
+ kind: 'badges';
195
+ badges: ReportBadge[];
196
+ }
197
+ /** What stands out, with each item linked to its evidence where `anchorFor` finds it on the page. */
198
+ | {
199
+ kind: 'synthesis';
200
+ synthesis: Synthesis;
201
+ anchorFor: (target: SynthesisTarget) => string | undefined;
202
+ /** false when the report has the lot at a glance, which says the headline, and What was compared, which says what was checked. */
203
+ headline?: boolean;
204
+ checked?: boolean;
205
+ /** Each item by its short name alone, not its sentence (on a slide, when each has its own slide, or the Low ones). */
206
+ brief?: boolean;
207
+ /** false when the report has no Findings section: the text then does not point to a table that is not there. */
208
+ findingsListed?: boolean;
209
+ };
210
+ export interface ReportSection {
211
+ id: ReportSectionId;
212
+ title: string;
213
+ blocks: ReportBlock[];
214
+ /** A fixed anchor, for a section something links to (the synthesis links to the test tables). */
215
+ anchor?: string;
216
+ /** A style hook of the HTML writer. */
217
+ className?: string;
218
+ }
219
+ /** One report: a wafer, a lot, or one identity group of a load that spans several. */
220
+ /** A short label: its text, and the level its colour says (none: plain). */
221
+ export interface ReportBadge {
222
+ text: string;
223
+ tone?: 'high' | 'medium' | 'low';
224
+ }
225
+ export interface ReportPart {
226
+ title: string;
227
+ /** What sets the part apart, alone ("Temperature 25"): a presentation's divider slide shows it, and `note` under it. */
228
+ heading?: string;
229
+ /** A line under the heading ("19 wafers · Lot PVT-LOT-05"). */
230
+ note?: string;
231
+ /** Prefix for anchors, so several parts in one document cannot share one. */
232
+ scope: string;
233
+ sections: ReportSection[];
234
+ }
235
+ export interface ReportDocument {
236
+ title: string;
237
+ parts: ReportPart[];
238
+ /** Said above the parts when a load is split into several (why it is not one report). */
239
+ banner?: string;
240
+ /** Shown inside the app, where a finding's row selects it on the map. */
241
+ live: boolean;
242
+ /** What the report is about, for a title page: lot, product, program, wafers. */
243
+ facts?: ReportMetric[];
244
+ /** The settings that make its figures what they are (pass bins, ring count), so a reader can trace one back. */
245
+ details?: ReportMetric[];
246
+ /** The data colour scheme its tints and bars are drawn in (Classic when unnamed). */
247
+ dataColors?: string;
248
+ }
249
+ //# sourceMappingURL=reportBlocks.d.ts.map
@@ -0,0 +1 @@
1
+ export{};
@@ -0,0 +1,22 @@
1
+ import { type CatalogueTab } from './chartCatalogue.js';
2
+ import type { ReportDocument, ReportSectionId } from './reportBlocks.js';
3
+ import { REPORT_SECTIONS, type ReportScope, type ReportSectionInfo } from './reportSections.js';
4
+ export { REPORT_SECTIONS, type ReportScope, type ReportSectionInfo };
5
+ /** An Insights chart a report can include, by the id its card carries. */
6
+ export interface ReportChartInfo {
7
+ id: string;
8
+ title: string;
9
+ /** The Insights tab that draws it. */
10
+ tab: CatalogueTab;
11
+ /** The report section it belongs to: in a report it follows that section's tables, and it is in only when the section is. */
12
+ section: ReportSectionId;
13
+ }
14
+ /** The built-in Insights charts a report of this kind can include, in Insights' order: the catalogue's charts on the Overview, Distributions and Correlation tabs. */
15
+ export declare function reportChartsFor(scope: ReportScope): ReportChartInfo[];
16
+ /** The built-in charts of a lot report (`reportChartsFor('lot')`). */
17
+ export declare const REPORT_CHARTS: readonly ReportChartInfo[];
18
+ /** Each section of the report, and whether this report (built with every section) has it. */
19
+ export declare function reportSectionsOf(report: ReportDocument, scope: ReportScope): Array<ReportSectionInfo & {
20
+ available: boolean;
21
+ }>;
22
+ //# sourceMappingURL=reportContents.d.ts.map
@@ -0,0 +1 @@
1
+ import{CHART_CATALOGUE as e,cardKindId as c}from"./chartCatalogue.js";import{CHART_ONLY_SECTIONS as s,REPORT_SECTIONS as i,chartSection as d}from"./reportSections.js";export{i as REPORT_SECTIONS};export function reportChartsFor(o){return["overview","distributions","correlation"].flatMap(a=>e.flatMap(r=>{if(r.kind!=="chart"||r.tab!==a)return[];const t=r.cards?.[0]??(r.card?c(r.card):void 0);return t?[{id:t,title:r.title,tab:a,section:d(t,o)}]:[]}))}export const REPORT_CHARTS=reportChartsFor("lot");export function reportSectionsOf(o,a){const r=new Set(o.parts.flatMap(t=>t.sections.map(n=>n.id)));return i[a].map(t=>({...t,available:s.has(t.id)||r.has(t.id)}))}