# Legacy calculator

Embed, validate, export, and render Legacy builds with their own point budget.

Source: https://warcraftforever.com/developers/legacy/

```html
<script src="https://warcraftforever.com/legacy/latest.js"></script>
<div id="legacy"></div>
<script>
  const calculator = WarcraftForever.Legacy.mount('#legacy', { locale: 'en' });
  calculator.on('submit', (state) => {
    const saved = { revision: state.revision, code: calculator.exportBuild('compact') };
    console.log(saved, calculator.exportBuild('structured'));
  });
</script>
```

Legacy uses the same mount lifecycle, layouts and interaction model as [Talents](https://warcraftforever.com/developers/talents/options/). It uses the definition's own point budget and spending gates. Do not pass `class` or `maxLevel`. Its state carries `id: 'legacy'` and `pointBudget` in place of a class and character level. The Save button appears when all points are spent.

Use `view: 'icons'` or `view: 'tree'` with `build: { code, revision }` for a saved display, and `exportBuild('structured')` for custom rendering. Unknown client effects remain explicitly unknown; locked nodes cannot be allocated.

Legacy exports default to `compact`; `structured` includes the calculator ID, revision, selected trees and spells. The headless result also reports `pointBudget`. The Blizzard-format Legacy serialization contract has not been verified, so `blizzard` rejects with `unsupported-format` instead of inventing an encoding. Existing Legacy URLs remain valid.

`/legacy/headless.mjs` exports `definition`, `decode`, `validate`, `encode`, `diff`, and `createClient`. Their [headless contracts](https://warcraftforever.com/developers/headless/) match Talents, with no class or maximum-level argument:

```js
import { validate, encode } from 'https://warcraftforever.com/legacy/headless.mjs';
const state = await validate({ allocation: { 'legacy-professions-working-overtime': 5 } });
const exported = await encode({ allocation: state.allocation, format: 'structured' });
console.log(exported.build);
```
