Problem statement
A stock panel with raw rows and no sense of what needs attention. A single transform must turn the stock array into a summary — total value, low-stock count, out-of-stock list, and top categories by value — so the panel can show what matters, and re-running with new data must replace the rendered summary rather than adding to it, using Vanilla TypeScript and standard DOM APIs.
Demo
The page, styles, mock stock data, panel markup, reshuffle button, and DOM rendering are already scaffolded and wired. Only the summarize function in src/js/summary.ts is missing — implement it so every test passes. Do not edit any other file.
What to implement
- Add up the value of every item to get the total value of the stock, where an item's value is its quantity times its price.
- Count the items that still have stock but are at or below the given threshold.
- Collect the items whose quantity is exactly zero and put them in alphabetical order by name.
- For each category that appears in the stock, add up the value of the items in that category, then keep the three highest categories by value, breaking ties by category name in alphabetical order.
- Return one summary object with the total value, the low-stock count, the out-of-stock list, and the top categories, so the panel can read every figure from that one object.
- Leave the stock array you were given unchanged.
- Everything shown must come from the stock you were given — nothing should be hardcoded.
