#!/usr/bin/env node
// Draws the app icon — a leadlight window, cobalt-led, with a gold disc
// carrying a lead pen stroke — as an SVG, rasterises it with macOS's own
// tools (qlmanage, sips), and writes app/icons/icon.png (the app icon) and
// app/icons/icon.svg (the page's favicon).
import { execFileSync } from 'node:child_process';
import { copyFileSync, existsSync, mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';
import { tmpdir } from 'node:os';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
const iconsDir = path.join(root, 'icons');
mkdirSync(iconsDir, { recursive: true });
// Empyrean, from supram/css/tokens.css.
const HUE = { ruby: '#fb5664', amber: '#f5991c', gold: '#f4cf24', emerald: '#22d08f', cobalt: '#6e9bfb', teal: '#21c4ed', cobaltInk: '#1b3f9c', goldInk: '#75620a' };
const LEAD = '#121212';
const S = 1024, INSET = 100, SIZE = 824, R = 185;
const CAME = 18, N = 4;
const M = (SIZE - (N + 1) * CAME) / N;
// Mostly cobalt: the room this app lives in is blue.
const panes = [
[0, 0, 2, 1, 'cobalt'], [2, 0, 1, 1, 'teal'], [3, 0, 1, 2, 'cobalt'],
[0, 1, 1, 2, 'cobaltInk'], [1, 1, 2, 1, 'cobalt'],
[1, 2, 1, 1, 'emerald'], [2, 2, 2, 1, 'cobalt'],
[0, 3, 1, 1, 'cobalt'], [1, 3, 2, 1, 'cobaltInk'], [3, 3, 1, 1, 'teal'],
];
function pane ([c, r, cs, rs, hue]) {
const x = INSET + CAME + c * (M + CAME);
const y = INSET + CAME + r * (M + CAME);
const w = cs * M + (cs - 1) * CAME;
const h = rs * M + (rs - 1) * CAME;
return `