@moonbase.sh/gorilla-engine 0.2.1 → 0.3.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.
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // src/moonbase.ts
2
- import { Buffer } from "buffer";
2
+ import { Buffer as Buffer2 } from "buffer";
3
3
  import { execFile, spawn } from "child_process";
4
4
  import fsSync from "fs";
5
5
  import fs2 from "fs/promises";
@@ -9,7 +9,7 @@ import process from "process";
9
9
  import { ActivationController, ActivationError, licensingVersion, MoonbaseError, ReleaseNotCoveredError } from "@moonbase.sh/licensing";
10
10
 
11
11
  // package.json
12
- var version = "0.2.1";
12
+ var version = "0.3.0";
13
13
 
14
14
  // src/download.ts
15
15
  import fs from "fs";
@@ -34,6 +34,296 @@ function uniquePath(dir, name) {
34
34
  }
35
35
  }
36
36
 
37
+ // src/icons.ts
38
+ import { Buffer } from "buffer";
39
+ import { deflateSync } from "zlib";
40
+ var ICON_PATHS = {
41
+ check: "M4.5 12.75l6 6 9-13.5",
42
+ cross: "M6 18 18 6M6 6l12 12",
43
+ lock: "M16.5 10.5V6.75a4.5 4.5 0 1 0-9 0v3.75m-.75 11.25h10.5a2.25 2.25 0 0 0 2.25-2.25v-6.75a2.25 2.25 0 0 0-2.25-2.25H6.75a2.25 2.25 0 0 0-2.25 2.25v6.75a2.25 2.25 0 0 0 2.25 2.25z",
44
+ back: "M15.75 19.5 8.25 12l7.5-7.5",
45
+ chevron: "m8.25 4.5 7.5 7.5-7.5 7.5",
46
+ signal: "M9.348 14.652a3.75 3.75 0 010-5.304m5.304 0a3.75 3.75 0 010 5.304m-7.425 2.121a6.75 6.75 0 010-9.546m9.546 0a6.75 6.75 0 010 9.546M5.106 18.894c-3.808-3.807-3.808-9.98 0-13.788m13.788 0c3.808 3.807 3.808 9.98 0 13.788M12 12h.008v.008H12V12z",
47
+ computer: "M9 17.25v1.007a3 3 0 0 1-.879 2.122L7.5 21h9l-.621-.621A3 3 0 0 1 15 18.257V17.25m6-12V15a2.25 2.25 0 0 1-2.25 2.25H5.25A2.25 2.25 0 0 1 3 15V5.25m18 0A2.25 2.25 0 0 0 18.75 3H5.25A2.25 2.25 0 0 0 3 5.25m18 0V12a2.25 2.25 0 0 1-2.25 2.25H5.25A2.25 2.25 0 0 1 3 12V5.25",
48
+ fileDown: "M19.5 14.25v-2.625a3.375 3.375 0 0 0-3.375-3.375h-1.5A1.125 1.125 0 0 1 13.5 7.125v-1.5a3.375 3.375 0 0 0-3.375-3.375H8.25m.75 12 3 3m0 0 3-3m-3 3v-6m-1.5-9H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 0 0-9-9z",
49
+ upload: "M7.5 7.5h-.75A2.25 2.25 0 0 0 4.5 9.75v7.5a2.25 2.25 0 0 0 2.25 2.25h7.5a2.25 2.25 0 0 0 2.25-2.25v-7.5a2.25 2.25 0 0 0-2.25-2.25h-.75m-6 3.75 3-3m0 0 3 3m-3-3v11.25m6-2.25h.75a2.25 2.25 0 0 0 2.25-2.25v-7.5a2.25 2.25 0 0 0-2.25-2.25h-.75",
50
+ okCircle: "M9 12.75 11.25 15 15 9.75M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0z",
51
+ warning: "M12 9v3.75m-9.303 3.376c-.866 1.5.217 3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898 0L2.697 16.126zM12 15.75h.007v.008H12v-.008z",
52
+ blocked: "M18.364 18.364A9 9 0 0 0 5.636 5.636m12.728 12.728A9 9 0 0 1 5.636 5.636m12.728 12.728L5.636 5.636",
53
+ copy: "M15.75 17.25v3.375c0 .621-.504 1.125-1.125 1.125h-9.75a1.125 1.125 0 0 1-1.125-1.125V7.875c0-.621.504-1.125 1.125-1.125H6.75a9.06 9.06 0 0 1 1.5.124m7.5 10.376h3.375c.621 0 1.125-.504 1.125-1.125V11.25c0-4.46-3.243-8.161-7.5-8.876a9.06 9.06 0 0 0-1.5-.124H9.375c-.621 0-1.125.504-1.125 1.125v3.5m7.5 10.375H9.375",
54
+ download: "M3 16.5v2.25A2.25 2.25 0 0 0 5.25 21h13.5A2.25 2.25 0 0 0 21 18.75V16.5M16.5 12 12 16.5m0 0L7.5 12m4.5 4.5V3",
55
+ puzzle: "M14.25 6.087c0-.355.186-.676.401-.959.221-.29.349-.634.349-1.003 0-1.036-1.007-1.875-2.25-1.875s-2.25.84-2.25 1.875c0 .369.128.713.349 1.003.215.283.401.604.401.959v0a.64.64 0 0 1-.657.643 48.4 48.4 0 0 1-4.163-.3c.186 1.613.293 3.25.315 4.907a.656.656 0 0 1-.658.663v0c-.355 0-.676-.186-.959-.401a1.647 1.647 0 0 0-1.003-.349c-1.036 0-1.875 1.007-1.875 2.25s.84 2.25 1.875 2.25c.369 0 .713-.128 1.003-.349.283-.215.604-.401.959-.401v0c.31 0 .555.26.532.57a48.04 48.04 0 0 1-.642 5.056c1.518.19 3.058.309 4.616.354a.64.64 0 0 0 .657-.643v0c0-.355-.186-.676-.401-.959a1.647 1.647 0 0 1-.349-1.003c0-1.035 1.008-1.875 2.25-1.875 1.243 0 2.25.84 2.25 1.875 0 .369-.128.713-.349 1.003-.215.283-.4.604-.4.959v0c0 .333.277.599.61.58a48.1 48.1 0 0 0 5.427-.63 48.05 48.05 0 0 0 .582-4.717.532.532 0 0 0-.533-.57v0c-.355 0-.676.186-.959.401-.29.221-.634.349-1.003.349-1.035 0-1.875-1.007-1.875-2.25s.84-2.25 1.875-2.25c.37 0 .713.128 1.003.349.283.215.604.401.96.401v0a.656.656 0 0 0 .658-.663 48.4 48.4 0 0 0-.37-5.36c-1.886.342-3.81.574-5.766.689a.578.578 0 0 1-.61-.58v0z",
56
+ external: "M13.5 6H5.25A2.25 2.25 0 0 0 3 8.25v10.5A2.25 2.25 0 0 0 5.25 21h10.5A2.25 2.25 0 0 0 18 18.75V10.5m-10.5 6L21 3m0 0h-5.25M21 3v5.25",
57
+ sparkles: "M9.813 15.904 9 18.75l-.813-2.846a4.5 4.5 0 0 0-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 0 0 3.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 0 0 3.09 3.09L15.75 12l-2.846.813a4.5 4.5 0 0 0-3.09 3.09Z"
58
+ };
59
+ function polylines(d) {
60
+ const lines = [];
61
+ let at = 0;
62
+ let command = "";
63
+ let x = 0;
64
+ let y = 0;
65
+ let startX = 0;
66
+ let startY = 0;
67
+ let control = null;
68
+ let line = [];
69
+ const skip = () => {
70
+ while (at < d.length && /[\s,]/.test(d[at]))
71
+ at++;
72
+ };
73
+ const isCommand = (character) => !!character && /[MLHVCSQTAZ]/i.test(character);
74
+ const number = () => {
75
+ skip();
76
+ const match = /^[-+]?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?/i.exec(d.slice(at));
77
+ if (!match)
78
+ throw new Error(`Expected a number at ${at} in ${d}`);
79
+ at += match[0].length;
80
+ return Number(match[0]);
81
+ };
82
+ const flag = () => {
83
+ skip();
84
+ const character = d[at++];
85
+ if (character !== "0" && character !== "1")
86
+ throw new Error(`Expected an arc flag at ${at - 1} in ${d}`);
87
+ return character === "1";
88
+ };
89
+ const to = (nextX, nextY) => {
90
+ x = nextX;
91
+ y = nextY;
92
+ line.push([x, y]);
93
+ };
94
+ const cubic = (x1, y1, x2, y2, endX, endY) => {
95
+ const [x0, y0] = [x, y];
96
+ for (let step = 1; step <= 16; step++) {
97
+ const t = step / 16;
98
+ const u = 1 - t;
99
+ line.push([
100
+ u * u * u * x0 + 3 * u * u * t * x1 + 3 * u * t * t * x2 + t * t * t * endX,
101
+ u * u * u * y0 + 3 * u * u * t * y1 + 3 * u * t * t * y2 + t * t * t * endY
102
+ ]);
103
+ }
104
+ x = endX;
105
+ y = endY;
106
+ control = [x2, y2];
107
+ };
108
+ for (; ; ) {
109
+ skip();
110
+ if (at >= d.length)
111
+ break;
112
+ if (isCommand(d[at]))
113
+ command = d[at++];
114
+ else if (!command)
115
+ throw new Error(`Expected a command at ${at} in ${d}`);
116
+ const relative = command === command.toLowerCase();
117
+ const ox = relative ? x : 0;
118
+ const oy = relative ? y : 0;
119
+ const smooth = control;
120
+ control = null;
121
+ switch (command.toUpperCase()) {
122
+ case "M": {
123
+ x = number() + ox;
124
+ y = number() + oy;
125
+ startX = x;
126
+ startY = y;
127
+ line = [[x, y]];
128
+ lines.push(line);
129
+ command = relative ? "l" : "L";
130
+ break;
131
+ }
132
+ case "L": {
133
+ const nextX = number() + ox;
134
+ to(nextX, number() + oy);
135
+ break;
136
+ }
137
+ case "H":
138
+ to(number() + ox, y);
139
+ break;
140
+ case "V":
141
+ to(x, number() + oy);
142
+ break;
143
+ case "C": {
144
+ const x1 = number() + ox;
145
+ const y1 = number() + oy;
146
+ const x2 = number() + ox;
147
+ const y2 = number() + oy;
148
+ const endX = number() + ox;
149
+ cubic(x1, y1, x2, y2, endX, number() + oy);
150
+ break;
151
+ }
152
+ case "S": {
153
+ const [x1, y1] = smooth ? [2 * x - smooth[0], 2 * y - smooth[1]] : [x, y];
154
+ const x2 = number() + ox;
155
+ const y2 = number() + oy;
156
+ const endX = number() + ox;
157
+ cubic(x1, y1, x2, y2, endX, number() + oy);
158
+ break;
159
+ }
160
+ case "Q": {
161
+ const qx = number() + ox;
162
+ const qy = number() + oy;
163
+ const endX = number() + ox;
164
+ const endY = number() + oy;
165
+ cubic(x + 2 / 3 * (qx - x), y + 2 / 3 * (qy - y), endX + 2 / 3 * (qx - endX), endY + 2 / 3 * (qy - endY), endX, endY);
166
+ break;
167
+ }
168
+ case "A": {
169
+ const rx = number();
170
+ const ry = number();
171
+ const rotation = number();
172
+ const large = flag();
173
+ const sweep = flag();
174
+ const endX = number() + ox;
175
+ const endY = number() + oy;
176
+ for (const point of arc(x, y, rx, ry, rotation, large, sweep, endX, endY))
177
+ line.push(point);
178
+ x = endX;
179
+ y = endY;
180
+ break;
181
+ }
182
+ case "Z":
183
+ to(startX, startY);
184
+ line = [[x, y]];
185
+ lines.push(line);
186
+ skip();
187
+ if (at < d.length && !isCommand(d[at]))
188
+ throw new Error(`Expected a command after Z at ${at} in ${d}`);
189
+ break;
190
+ default:
191
+ throw new Error(`Unsupported command ${command} in ${d}`);
192
+ }
193
+ }
194
+ return lines;
195
+ }
196
+ function arc(x1, y1, rx, ry, rotation, large, sweep, x2, y2) {
197
+ if (rx === 0 || ry === 0)
198
+ return [[x2, y2]];
199
+ rx = Math.abs(rx);
200
+ ry = Math.abs(ry);
201
+ const phi = rotation * Math.PI / 180;
202
+ const cos = Math.cos(phi);
203
+ const sin = Math.sin(phi);
204
+ const dx = (x1 - x2) / 2;
205
+ const dy = (y1 - y2) / 2;
206
+ const x1p = cos * dx + sin * dy;
207
+ const y1p = -sin * dx + cos * dy;
208
+ const lambda = x1p * x1p / (rx * rx) + y1p * y1p / (ry * ry);
209
+ if (lambda > 1) {
210
+ rx *= Math.sqrt(lambda);
211
+ ry *= Math.sqrt(lambda);
212
+ }
213
+ const numerator = rx * rx * ry * ry - rx * rx * y1p * y1p - ry * ry * x1p * x1p;
214
+ const denominator = rx * rx * y1p * y1p + ry * ry * x1p * x1p;
215
+ let coefficient = Math.sqrt(Math.max(0, numerator / denominator));
216
+ if (large === sweep)
217
+ coefficient = -coefficient;
218
+ const cxp = coefficient * rx * y1p / ry;
219
+ const cyp = -coefficient * ry * x1p / rx;
220
+ const cx = cos * cxp - sin * cyp + (x1 + x2) / 2;
221
+ const cy = sin * cxp + cos * cyp + (y1 + y2) / 2;
222
+ const angle = (ux, uy, vx, vy) => Math.atan2(ux * vy - uy * vx, ux * vx + uy * vy);
223
+ const start = angle(1, 0, (x1p - cxp) / rx, (y1p - cyp) / ry);
224
+ let delta = angle((x1p - cxp) / rx, (y1p - cyp) / ry, (-x1p - cxp) / rx, (-y1p - cyp) / ry);
225
+ if (!sweep && delta > 0)
226
+ delta -= 2 * Math.PI;
227
+ else if (sweep && delta < 0)
228
+ delta += 2 * Math.PI;
229
+ const steps = Math.max(2, Math.ceil(Math.abs(delta) / (Math.PI / 24)));
230
+ const points = [];
231
+ for (let step = 1; step <= steps; step++) {
232
+ const t = start + delta * step / steps;
233
+ points.push([cos * rx * Math.cos(t) - sin * ry * Math.sin(t) + cx, sin * rx * Math.cos(t) + cos * ry * Math.sin(t) + cy]);
234
+ }
235
+ return points;
236
+ }
237
+ function coverage(d, pixels, strokeWidth) {
238
+ const scale = pixels / 24;
239
+ const half = strokeWidth * scale / 2;
240
+ const segments = [];
241
+ for (const line of polylines(d)) {
242
+ const points = line.map(([px, py]) => [px * scale, py * scale]);
243
+ if (points.length === 1)
244
+ segments.push([points[0][0], points[0][1], points[0][0], points[0][1]]);
245
+ for (let index = 1; index < points.length; index++)
246
+ segments.push([points[index - 1][0], points[index - 1][1], points[index][0], points[index][1]]);
247
+ }
248
+ const reach = half + 1;
249
+ const out = new Float32Array(pixels * pixels);
250
+ for (const [ax, ay, bx, by] of segments) {
251
+ const left = Math.max(0, Math.floor(Math.min(ax, bx) - reach));
252
+ const right = Math.min(pixels - 1, Math.ceil(Math.max(ax, bx) + reach));
253
+ const top = Math.max(0, Math.floor(Math.min(ay, by) - reach));
254
+ const bottom = Math.min(pixels - 1, Math.ceil(Math.max(ay, by) + reach));
255
+ const vx = bx - ax;
256
+ const vy = by - ay;
257
+ const length = vx * vx + vy * vy;
258
+ for (let py = top; py <= bottom; py++) {
259
+ for (let px = left; px <= right; px++) {
260
+ const cx = px + 0.5;
261
+ const cy = py + 0.5;
262
+ const t = length === 0 ? 0 : Math.max(0, Math.min(1, ((cx - ax) * vx + (cy - ay) * vy) / length));
263
+ const distance = Math.hypot(cx - (ax + t * vx), cy - (ay + t * vy));
264
+ const value = Math.max(0, Math.min(1, half + 0.5 - distance));
265
+ const index = py * pixels + px;
266
+ if (value > out[index])
267
+ out[index] = value;
268
+ }
269
+ }
270
+ }
271
+ return out;
272
+ }
273
+ var CRC_TABLE = (() => {
274
+ const table = new Uint32Array(256);
275
+ for (let n = 0; n < 256; n++) {
276
+ let c = n;
277
+ for (let k = 0; k < 8; k++)
278
+ c = c & 1 ? 3988292384 ^ c >>> 1 : c >>> 1;
279
+ table[n] = c >>> 0;
280
+ }
281
+ return table;
282
+ })();
283
+ function crc32(bytes) {
284
+ let c = 4294967295;
285
+ for (const byte of bytes)
286
+ c = CRC_TABLE[(c ^ byte) & 255] ^ c >>> 8;
287
+ return (c ^ 4294967295) >>> 0;
288
+ }
289
+ function chunk(type, data) {
290
+ const length = Buffer.alloc(4);
291
+ length.writeUInt32BE(data.length);
292
+ const body = Buffer.concat([Buffer.from(type, "ascii"), data]);
293
+ const crc = Buffer.alloc(4);
294
+ crc.writeUInt32BE(crc32(body));
295
+ return Buffer.concat([length, body, crc]);
296
+ }
297
+ function encodePng(width, height, rgba) {
298
+ const header = Buffer.alloc(13);
299
+ header.writeUInt32BE(width, 0);
300
+ header.writeUInt32BE(height, 4);
301
+ header[8] = 8;
302
+ header[9] = 6;
303
+ const raw = Buffer.alloc((width * 4 + 1) * height);
304
+ for (let row = 0; row < height; row++)
305
+ Buffer.from(rgba.buffer, rgba.byteOffset + row * width * 4, width * 4).copy(raw, row * (width * 4 + 1) + 1);
306
+ return Buffer.concat([
307
+ Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]),
308
+ chunk("IHDR", header),
309
+ chunk("IDAT", deflateSync(raw)),
310
+ chunk("IEND", Buffer.alloc(0))
311
+ ]);
312
+ }
313
+ function iconPng(name, colour, pixels, strokeWidth) {
314
+ const argb = Number.parseInt(colour, 16);
315
+ const alpha = (argb >>> 24 & 255) / 255;
316
+ const cover = coverage(ICON_PATHS[name], pixels, strokeWidth);
317
+ const rgba = new Uint8Array(pixels * pixels * 4);
318
+ for (let index = 0; index < cover.length; index++) {
319
+ rgba[index * 4] = argb >>> 16 & 255;
320
+ rgba[index * 4 + 1] = argb >>> 8 & 255;
321
+ rgba[index * 4 + 2] = argb & 255;
322
+ rgba[index * 4 + 3] = Math.round(cover[index] * alpha * 255);
323
+ }
324
+ return encodePng(pixels, pixels, rgba);
325
+ }
326
+
37
327
  // src/mark.ts
38
328
  var MARK_PNG = "iVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAYAAAAfSC3RAAAB8klEQVR4nIxSTUhUURQ+3503P07jrk1Bf7QIhsioqRCpiOiHcCIolIQKhvYFQa0Cly3atIgicJ5CGLUoZl5QRPBslfFeRVGbFjWBuFFReT4ddeYez3v6dBRED7z77rnn3O873znXoAYz7X8p9sbuKtBgpf3wx25A0zqGaNNbcto08CwGdfNG/tBn2sCMYOmznKOa6RNAVzZzKWS0bduoeJk/DFQL+VyWNmnqv5+5QMAeIh5sDLyyf2Ua/T7rW6tZdn8ULbeXmWFIiZfAPCNq/Sip33K3dpzaP9rNrHaX3VYdj43Xa/WXAHYQ88/i2+8HDDDtFcYmEO8yS84ZBqWNmbkPAUB24HfaB1qoVn8gqrwldQ5Yn1TCNB+4TDgLxIcF1fSbEtPFsuv5U1VP4o+laQPybWfiIdLJN3J2XEm575loWuaS1Ji/r0GXA1+C1ah0yTnBTJNQRp7U7ENhqahMc+qpbCbCIgidMUa2zjgt6ZYkDwvICIFfS0OOka7dE+YOhnoePgCz7LwTneeXGQJGoiehnkAKc5scXhXkbQL2onAx1xU+gCRwbZboq2x3LjJTWn53QgiOJh4i9hjJ+K1wjsHSlc+NJpA4GKCt6KIva2b+aEtz6vb1cy1+hLPKekrOPulsJ8Bqqds10dhfaD/ytzFvAQAA///wPXGEAAAABklEQVQDACqdwnQigg9+AAAAAElFTkSuQmCC";
39
329
  var MARK_PNG_2X = "iVBORw0KGgoAAAANSUhEUgAAABwAAAAcCAYAAAByDd+UAAAEk0lEQVR4nLRVbUybVRQ+977vgNJWIX47w2SG+AFztOuME2ZcIsaJLU6zojPTFVQSl2xG4x8z4+IPh8ZkiskiP2gpWdTxx9BC3aaOTP8Q+lJAmV/4MUOmzpHBRvnue8/OLbSjH5SFsSdp773n3vucc+75eFVYAvsReYFfq2bAygViw5DDNrifMQHLBMu06fYFn6PhHTo1y0B92mW3DMJVQk0nbPH1F+ps1kvTzYDYOKbk7d3zRNE0rABSPPR09Jai0I/Txk207HDZbU/CCiLBQ29bz/26rn/PGJgA4Q+jOedZWGHw2KTlWP/NOsdvo8oIgrE3nVtKwrDCiCuMzMw00DPeKOcIMBy5DdvhGiCq0B0I3UdpXx2XIjTX2WyzcA0QjSHTxWsLhYxjT6ZLzb7gMxfVvPZMmdvkD63nIHaT8RVC4dtrK61alNvT+VcOjg3/zxgzx08j2+RybOiCZaAhMJhtjozWA2NxJxBxh2nK1vrTdkAVx4fLpTIE/Iae9VF5gAP+cyXkjZq2Kutf/NRoMuyVCdbU9ouZR0a/ImVlCQcZF1LZnR0hC2fILVHZvDKJCKIhmVy2OG9b0LJQljV2g0LDkJwfDnRdx3m4ExlwREhofeTAyJqjfQUC8AHm9msfUna+kcDO2Vbj+PTJidysVyOqwfPS48XnIQPcPs3KGDaR2aW0PE5xe4Q8yIofUJVCFsG7BOpbKGkwO6Xh6GKz0/nQUY8vWK3MTLzv8WknSOoHhj/KbZwrn7V0r4hWxXR70wKOxxLpsNu11XKaOKrpqc0ySyeSLUbGnqdA7/P4tYMU389IVDH3m2NKNC9j/5dkh+cGfIW4mul52bnkM0Sxxtuh2WscGz+neCQ0AFpfIGOGUu6gWkK7fYnK4AfjVE5jc0foYcoRehE8w7nCu9MZJpDVt7YOZDFd2UkXT8eJmex6sCrVkUhgPoYxw+Qnbcd/pmwmdP0jKeOo/MwxN7+bSuLP5MwiL+8dN0wdcG2zjHKmlpNXvfNb+bR7axobCy47Bn8zUMp2OUpPmfXRQ/SUMrtHDJOWbq5fPH9HoSl8NyloSUPyOiXOQQERs2nK8CARHSDFY7AYECfp/2OTKafEOFUaokSpJ+Nq5o3wO51MZ0RApdFTRgpP0lPxdDwyPvQKuS6HJdjaOWAKhyd3UUyKiWZ1tBEinqHx1KwBvHUVtgtNbaHbORdfgPyAx8AVi6vS0hdPMaqlI6TQubjxFBMGhwRwT63d2p/ujLs9uJYD2yYEvE1nr798GT5xOWx7osbHZJ4ve/NA1QdouhqWxgj9+smKX6mEZAO3EpGMkzGNob8jmqy1VfeMJSic99JKQ1e6LFwOSFlYUdQNL1aW/haTJcSsxmELUYt6ip5gFK4SFPMPyPsXFipLUSjhsm8MkHA9mfcdLB/j9HZfRwCPJW8s2pdk9nrbtZ0IbB8tixL2AN6ii++l3pHFjm6Byru1Vda0n7glGuGcYuqpDiqD3VQf62TRk+wsFfMtMSXEcoKsCOiYfeTlqnVnM/EtqTAZjX4tVwVexEHPZ1wR00JodXbbxJXevwQAAP//kVVCeAAAAAZJREFUAwDo79Or7AZ5mAAAAABJRU5ErkJggg==";
@@ -149,6 +439,9 @@ var MoonbaseGorillaEngine = class extends ActivationController {
149
439
  this.stopFocus = null;
150
440
  /** Aborts the update download when the instance is disposed. */
151
441
  this.aborts = new AbortController();
442
+ /** Each icon's file, by name, colour, size and stroke; null when it couldn't be written. */
443
+ this.iconFiles = /* @__PURE__ */ new Map();
444
+ this.iconsFailed = false;
152
445
  this.ui = { ...ui, productName };
153
446
  this.endpoint = options.endpoint;
154
447
  this.host = host;
@@ -222,8 +515,8 @@ var MoonbaseGorillaEngine = class extends ActivationController {
222
515
  const file = path2.join(path2.dirname(this.licenseFile), "moonbase-mark.png");
223
516
  try {
224
517
  fsSync.mkdirSync(path2.dirname(file), { recursive: true });
225
- writeIfChanged(file, Buffer.from(MARK_PNG, "base64"));
226
- writeIfChanged(file.replace(/\.png$/, "@2x.png"), Buffer.from(MARK_PNG_2X, "base64"));
518
+ writeIfChanged(file, Buffer2.from(MARK_PNG, "base64"));
519
+ writeIfChanged(file.replace(/\.png$/, "@2x.png"), Buffer2.from(MARK_PNG_2X, "base64"));
227
520
  this.markFile = file;
228
521
  } catch (err) {
229
522
  this.reportError("moonbaseMark", err);
@@ -231,6 +524,33 @@ var MoonbaseGorillaEngine = class extends ActivationController {
231
524
  }
232
525
  return this.markFile;
233
526
  }
527
+ /**
528
+ * One of the overlay's icons, in a colour (`AARRGGBB`) and size (points), as
529
+ * an image file, with its `@2x`: drawn the first time it is asked for, into
530
+ * `moonbase-icons` beside the license, for the same reason as the mark. Null
531
+ * when it can't be written, and the overlay goes without it.
532
+ */
533
+ icon(name, colour, size, stroke = 1.8) {
534
+ const key = `${name}-${colour}-${size}-${stroke}`;
535
+ const known = this.iconFiles.get(key);
536
+ if (known !== void 0)
537
+ return known;
538
+ const file = path2.join(path2.dirname(this.licenseFile), "moonbase-icons", `${name}-${colour.toLowerCase()}-${size}-${Math.round(stroke * 10)}.png`);
539
+ let result = file;
540
+ try {
541
+ fsSync.mkdirSync(path2.dirname(file), { recursive: true });
542
+ writeIfChanged(file, iconPng(name, colour, Math.round(size), stroke));
543
+ writeIfChanged(file.replace(/\.png$/, "@2x.png"), iconPng(name, colour, Math.round(size * 2), stroke));
544
+ } catch (err) {
545
+ if (!this.iconsFailed) {
546
+ this.iconsFailed = true;
547
+ this.reportError("icons", err);
548
+ }
549
+ result = null;
550
+ }
551
+ this.iconFiles.set(key, result);
552
+ return result;
553
+ }
234
554
  /**
235
555
  * Hand a failure to `onError`: the overlay does with every action that
236
556
  * fails, and the module with the host's.
@@ -434,6 +754,7 @@ function createMoonbase(options) {
434
754
  }
435
755
 
436
756
  // src/MoonbaseActivation.ts
757
+ import os2 from "os";
437
758
  import process2 from "process";
438
759
  import * as React3 from "react";
439
760
 
@@ -591,6 +912,64 @@ function describeAddOn(entry, license, state) {
591
912
  // src/elements.ts
592
913
  import * as React2 from "react";
593
914
 
915
+ // src/metrics.ts
916
+ var SIZE = 500;
917
+ var CHARACTERS = (() => {
918
+ let characters = "";
919
+ for (let code = 32; code < 127; code++)
920
+ characters += String.fromCharCode(code);
921
+ for (let code = 160; code < 256; code++)
922
+ characters += String.fromCharCode(code);
923
+ return `${characters}\u2026\xB7\u2018\u2019\u201C\u201D\u2013\u20AC`;
924
+ })();
925
+ var advances = /* @__PURE__ */ new Map();
926
+ var measuring = /* @__PURE__ */ new Map();
927
+ function measurer() {
928
+ var _a;
929
+ return (_a = globalThis.GorillaEngine) != null ? _a : null;
930
+ }
931
+ function measureFont(font) {
932
+ var _a;
933
+ const existing = measuring.get(font);
934
+ if (existing)
935
+ return existing;
936
+ const measure = (_a = measurer()) == null ? void 0 : _a.calculateTextWidth;
937
+ if (typeof measure !== "function")
938
+ return Promise.resolve(false);
939
+ const promise = (async () => {
940
+ const table = /* @__PURE__ */ new Map();
941
+ const widths = await Promise.all([...CHARACTERS].map((character) => measure(character, font, SIZE, 0)));
942
+ widths.forEach((width, index) => {
943
+ if (typeof width === "number" && Number.isFinite(width))
944
+ table.set(CHARACTERS[index], width);
945
+ });
946
+ if (!table.has("n"))
947
+ return false;
948
+ advances.set(font, table);
949
+ return true;
950
+ })().catch(() => false);
951
+ measuring.set(font, promise);
952
+ return promise;
953
+ }
954
+ async function measureFonts(fonts) {
955
+ const results = await Promise.all([...new Set(fonts.map((font) => font != null ? font : ""))].map(measureFont));
956
+ return results.some(Boolean);
957
+ }
958
+ function measuredWidth(text2, font, size, kerning = 0) {
959
+ var _a;
960
+ const table = advances.get(font != null ? font : "");
961
+ if (!table)
962
+ return null;
963
+ const fallback = table.get("n");
964
+ let width = 0;
965
+ let count = 0;
966
+ for (const character of text2) {
967
+ width += (_a = table.get(character)) != null ? _a : fallback;
968
+ count++;
969
+ }
970
+ return width * size / SIZE + kerning * size * count;
971
+ }
972
+
594
973
  // src/motion.ts
595
974
  import * as React from "react";
596
975
  var FRAME = 16;
@@ -741,27 +1120,68 @@ function fontFor(theme, weight, mono = false) {
741
1120
  return medium != null ? medium : regular;
742
1121
  return regular;
743
1122
  }
744
- function textWidth(text2, size, weight = 400) {
745
- return Math.ceil(text2.length * size * (weight >= 600 ? 0.59 : weight === 500 ? 0.56 : 0.52));
1123
+ function textWidth(theme, text2, size, weight = 400, options = {}) {
1124
+ return Math.ceil(exactWidth(theme, text2, size, weight, options));
746
1125
  }
747
- function textHeight(text2, size, width, lineHeight = 1.5) {
1126
+ function exactWidth(theme, text2, size, weight, options = {}) {
1127
+ var _a;
1128
+ const measured = measuredWidth(text2, fontFor(theme, weight, options.mono), size, options.kerning);
1129
+ if (measured !== null)
1130
+ return measured * 1.03;
1131
+ return text2.length * size * ((weight >= 600 ? 0.59 : weight === 500 ? 0.56 : 0.52) + ((_a = options.kerning) != null ? _a : 0));
1132
+ }
1133
+ function lineCount(theme, text2, size, width, weight = 400, mono = false) {
1134
+ const space2 = exactWidth(theme, " ", size, weight, { mono });
748
1135
  let lines = 0;
749
1136
  for (const paragraph2 of text2.split("\n")) {
750
1137
  let line = 0;
751
1138
  lines++;
752
1139
  for (const word of paragraph2.split(" ")) {
753
- const length = textWidth(`${word} `, size);
754
- if (line > 0 && line + length > width) {
1140
+ const length = exactWidth(theme, word, size, weight, { mono });
1141
+ if (line > 0 && line + space2 + length > width) {
755
1142
  lines++;
756
- line = 0;
1143
+ line = length;
1144
+ } else {
1145
+ line += (line > 0 ? space2 : 0) + length;
757
1146
  }
758
- line += length;
759
1147
  }
760
1148
  }
761
- return Math.ceil(lines * size * lineHeight);
1149
+ return lines;
762
1150
  }
1151
+ function textHeight(theme, text2, size, width, lineHeight = 1.5, weight = 400, mono = false) {
1152
+ return Math.ceil(lineCount(theme, text2, size, width, weight, mono) * size * lineHeight);
1153
+ }
1154
+ function fitText(theme, text2, size, width, options = {}) {
1155
+ const fits = (value) => textWidth(theme, value, size, options.weight, { mono: options.mono }) <= width;
1156
+ if (fits(text2))
1157
+ return text2;
1158
+ const characters = [...text2];
1159
+ let keep = characters.length - 1;
1160
+ while (keep > 1) {
1161
+ const value = options.end ? `${characters.slice(0, keep).join("").trimEnd()}\u2026` : `${characters.slice(0, Math.ceil(keep / 2)).join("")}\u2026${characters.slice(characters.length - Math.floor(keep / 2)).join("")}`;
1162
+ if (fits(value))
1163
+ return value;
1164
+ keep--;
1165
+ }
1166
+ return "\u2026";
1167
+ }
1168
+ var BLANK = {
1169
+ text: "",
1170
+ backgroundColor: "00000000",
1171
+ cornerRadius: 0,
1172
+ border: { width: 0, color: "00000000" },
1173
+ alpha: 1,
1174
+ interceptsMouseClicks: false,
1175
+ mouseCursorType: "normal"
1176
+ };
763
1177
  function label(props, ...children) {
764
- return h("geLabel", { interceptsMouseClicks: false, ...props }, ...children);
1178
+ return h("geLabel", { ...BLANK, ...props }, ...children);
1179
+ }
1180
+ function icon(theme, name, x, y, size, colour, stroke = 1.8) {
1181
+ const file = theme.icon(name, colour, size, stroke);
1182
+ if (!file)
1183
+ return null;
1184
+ return h("geLabel", { ...BLANK, key: `icon-${name}`, x, y, width: size, height: size, backgroundImage: file });
765
1185
  }
766
1186
  function each(node) {
767
1187
  return Array.isArray(node) ? node : [node];
@@ -769,7 +1189,7 @@ function each(node) {
769
1189
  function text(theme, value, x, y, width, options = {}) {
770
1190
  var _a, _b, _c, _d, _e, _f;
771
1191
  const size = (_a = options.size) != null ? _a : 14;
772
- const height = textHeight(value, size, width, options.lineHeight);
1192
+ const height = textHeight(theme, value, size, width, options.lineHeight, options.weight, options.mono);
773
1193
  const multiLine = height > size * ((_b = options.lineHeight) != null ? _b : 1.5) * 1.2;
774
1194
  return label({
775
1195
  x,
@@ -803,7 +1223,7 @@ function paragraph(theme, value, width, options = {}) {
803
1223
  var _a, _b, _c;
804
1224
  const size = (_a = options.size) != null ? _a : 14;
805
1225
  const boxWidth = Math.min(width, (_b = options.maxWidth) != null ? _b : width);
806
- const height = Math.max(textHeight(value, size, boxWidth, options.lineHeight), Math.ceil(size * ((_c = options.lineHeight) != null ? _c : 1.5)));
1226
+ const height = Math.max(textHeight(theme, value, size, boxWidth, options.lineHeight, options.weight, options.mono), Math.ceil(size * ((_c = options.lineHeight) != null ? _c : 1.5)));
807
1227
  return {
808
1228
  height,
809
1229
  render: (x, y, available) => {
@@ -815,8 +1235,16 @@ function paragraph(theme, value, width, options = {}) {
815
1235
  function heading(theme, value, width, options = {}) {
816
1236
  return paragraph(theme, value, width, { size: options.large ? 27 : 24, weight: 600, textColor: palette.textPrimary, lineHeight: 1.25, align: options.align });
817
1237
  }
1238
+ function iconBeside(theme, value, size, weight, width, iconSize, gap) {
1239
+ if (iconSize === null)
1240
+ return { iconX: 0, margin: { left: 0, right: 0, top: 0, bottom: 0 } };
1241
+ if (!value)
1242
+ return { iconX: Math.round((width - iconSize) / 2), margin: { left: 0, right: 0, top: 0, bottom: 0 } };
1243
+ const shift = iconSize + gap;
1244
+ return { iconX: Math.round((width - textWidth(theme, value, size, weight) - shift) / 2), margin: { left: shift, right: 0, top: 0, bottom: 0 } };
1245
+ }
818
1246
  function Button(props) {
819
- var _a, _b, _c;
1247
+ var _a, _b, _c, _d;
820
1248
  const [hovered, setHovered] = React2.useState(false);
821
1249
  const kind = (_a = props.kind) != null ? _a : "primary";
822
1250
  const accent = props.theme.accent;
@@ -830,6 +1258,9 @@ function Button(props) {
830
1258
  };
831
1259
  const look = looks[kind];
832
1260
  const small = kind.startsWith("small") || kind === "danger" || kind === "quiet";
1261
+ const fontSize = (_b = props.size) != null ? _b : small ? 12.5 : 14;
1262
+ const iconSize = props.icon ? (_c = props.iconSize) != null ? _c : small ? 14 : 16 : null;
1263
+ const { iconX, margin } = iconBeside(props.theme, props.label, fontSize, look.weight, props.width, iconSize, small ? 6 : 8);
833
1264
  return label({
834
1265
  x: props.x,
835
1266
  y: props.y,
@@ -837,12 +1268,13 @@ function Button(props) {
837
1268
  height: props.height,
838
1269
  text: props.label,
839
1270
  font: fontFor(props.theme, look.weight),
840
- fontSize: (_b = props.size) != null ? _b : small ? 12.5 : 14,
1271
+ fontSize,
841
1272
  textColor: look.textColor,
842
1273
  textAlign: "center",
1274
+ margin,
843
1275
  backgroundColor: hovered && !props.disabled ? look.hover : look.background,
844
1276
  cornerRadius: small ? 8 : 9,
845
- border: { width: look.border ? 1 : 0, color: (_c = look.border) != null ? _c : palette.transparent },
1277
+ border: { width: look.border ? 1 : 0, color: (_d = look.border) != null ? _d : palette.transparent },
846
1278
  alpha: props.disabled ? 0.5 : 1,
847
1279
  interceptsMouseClicks: true,
848
1280
  mouseCursorType: props.disabled ? "normal" : "pointing hand",
@@ -852,7 +1284,7 @@ function Button(props) {
852
1284
  if (!props.disabled)
853
1285
  props.onClick();
854
1286
  }
855
- });
1287
+ }, props.icon && iconSize && icon(props.theme, props.icon, iconX, Math.round((props.height - iconSize) / 2), iconSize, look.textColor, 1.8));
856
1288
  }
857
1289
  function buttonBlock(theme, value, onClick, options = {}) {
858
1290
  var _a;
@@ -863,27 +1295,35 @@ function buttonBlock(theme, value, onClick, options = {}) {
863
1295
  var _a2;
864
1296
  const width = Math.min(available, (_a2 = options.width) != null ? _a2 : available);
865
1297
  const left = options.align === "center" ? x + (available - width) / 2 : x;
866
- return h(Button, { key: `button-${value}`, theme, x: left, y, width, height, label: value, kind: options.kind, disabled: options.disabled, onClick });
1298
+ return h(Button, { key: `button-${value}`, theme, x: left, y, width, height, label: value, kind: options.kind, disabled: options.disabled, icon: options.icon, onClick });
867
1299
  }
868
1300
  };
869
1301
  }
1302
+ var LINK_ICON = 14;
1303
+ var LINK_GAP = 6;
1304
+ function linkWidth(theme, value, size = 12.5, withIcon = false) {
1305
+ return textWidth(theme, value, size, 500) + 8 + (withIcon ? LINK_ICON + LINK_GAP : 0);
1306
+ }
870
1307
  function Link(props) {
871
- var _a, _b;
1308
+ var _a, _b, _c;
872
1309
  const [hovered, setHovered] = React2.useState(false);
873
1310
  const size = (_a = props.size) != null ? _a : 12.5;
874
- const width = (_b = props.width) != null ? _b : textWidth(props.label, size, 500) + 12;
1311
+ const width = (_b = props.width) != null ? _b : linkWidth(props.theme, props.label, size, !!props.icon);
1312
+ const height = Math.ceil(size * 1.6);
875
1313
  const base = props.link ? palette.link : palette.textSecondary;
876
1314
  const hover = props.link ? palette.linkHover : palette.textBright;
1315
+ const shown = hovered && !props.disabled ? hover : base;
877
1316
  return label({
878
1317
  x: props.x,
879
1318
  y: props.y,
880
1319
  width,
881
- height: Math.ceil(size * 1.6),
1320
+ height,
882
1321
  text: props.label,
883
1322
  font: fontFor(props.theme, 500),
884
1323
  fontSize: size,
885
- textColor: hovered && !props.disabled ? hover : base,
1324
+ textColor: shown,
886
1325
  textAlign: props.align === "center" ? "center" : "centered left",
1326
+ margin: { left: props.icon ? LINK_ICON + LINK_GAP : 0, right: 0, top: 0, bottom: 0 },
887
1327
  alpha: props.disabled ? 0.55 : 1,
888
1328
  interceptsMouseClicks: true,
889
1329
  mouseCursorType: props.disabled ? "normal" : "pointing hand",
@@ -893,7 +1333,7 @@ function Link(props) {
893
1333
  if (!props.disabled)
894
1334
  props.onClick();
895
1335
  }
896
- });
1336
+ }, props.icon && icon(props.theme, props.icon, 0, Math.round((height - LINK_ICON) / 2), LINK_ICON, (_c = props.iconColour) != null ? _c : shown, 1.7));
897
1337
  }
898
1338
  function linksBlock(theme, links, options = {}) {
899
1339
  var _a;
@@ -906,23 +1346,26 @@ function linksBlock(theme, links, options = {}) {
906
1346
  return {
907
1347
  height: marginTop + Math.ceil(size * 1.6),
908
1348
  render: (x, y, width) => {
909
- const widths = items.map((item) => textWidth(item.label, size, 500) + 12);
1349
+ const widths = items.map((item) => linkWidth(theme, item.label, size, !!item.icon));
910
1350
  const total = widths.reduce((sum, each2) => sum + each2, 0) + gap * (items.length - 1);
911
1351
  let left = options.align === "left" ? x : x + (width - total) / 2;
912
1352
  return items.map((item, index) => {
913
- const node = h(Link, { key: `link-${item.label}`, theme, x: left, y: y + marginTop, label: item.label, link: item.link, disabled: item.disabled, width: widths[index], onClick: item.onClick });
1353
+ const node = h(Link, { key: `link-${item.label}`, theme, x: left, y: y + marginTop, label: item.label, link: item.link, disabled: item.disabled, width: widths[index], icon: item.icon, iconColour: item.iconColour, onClick: item.onClick });
914
1354
  left += widths[index] + gap;
915
1355
  return node;
916
1356
  });
917
1357
  }
918
1358
  };
919
1359
  }
920
- function pill(theme, tone, value, x, y, onClick) {
1360
+ function pill(theme, tone, value, x, y, onClick, withIcon) {
921
1361
  const upper = tone === "trial" || tone === "expired" || tone === "upgrade";
922
1362
  const shown = upper ? value.toUpperCase() : value;
923
1363
  const size = upper ? 10.5 : 11.5;
1364
+ const kerning = upper ? 0.08 : 0.02;
924
1365
  const dot = tone === "expired" || tone === "upgrade" || tone === "active";
925
- const width = Math.ceil(textWidth(shown, size, 700) * (upper ? 1.18 : 1) + (upper ? shown.length * size * 0.08 : 0)) + 24 + (dot ? 12 : 0);
1366
+ const lead = dot ? 12 : withIcon ? 19 : 0;
1367
+ const textBox = textWidth(theme, shown, size, 700, { kerning }) + 4;
1368
+ const width = textBox + 22 + lead;
926
1369
  const height = 24;
927
1370
  const looks = {
928
1371
  trial: { background: color(palette.trial), border: palette.transparent, textColor: color("#131519") },
@@ -944,15 +1387,15 @@ function pill(theme, tone, value, x, y, onClick) {
944
1387
  interceptsMouseClicks: !!onClick,
945
1388
  mouseCursorType: onClick ? "pointing hand" : "normal",
946
1389
  ...onClick && { onClick }
947
- }, dot && label({ x: 11, y: height / 2 - 3, width: 6, height: 6, cornerRadius: 3, backgroundColor: look.textColor }), label({
948
- x: dot ? 22 : 10,
1390
+ }, dot && label({ x: 11, y: height / 2 - 3, width: 6, height: 6, cornerRadius: 3, backgroundColor: look.textColor }), withIcon && icon(theme, withIcon, 10, (height - 13) / 2, 13, color(theme.accent), 1.9), label({
1391
+ x: 11 + lead,
949
1392
  y: 0,
950
- width: width - (dot ? 32 : 20),
1393
+ width: textBox,
951
1394
  height,
952
1395
  text: shown,
953
1396
  font: fontFor(theme, 700),
954
1397
  fontSize: size,
955
- fontKerning: upper ? 0.08 : 0.02,
1398
+ fontKerning: kerning,
956
1399
  textColor: look.textColor,
957
1400
  textAlign: "center"
958
1401
  }));
@@ -960,6 +1403,8 @@ function pill(theme, tone, value, x, y, onClick) {
960
1403
  }
961
1404
  function card(props, ...children) {
962
1405
  var _a, _b, _c;
1406
+ if (props.onClick)
1407
+ return h(ClickableCard, { ...props, onClick: props.onClick }, ...children);
963
1408
  return label({
964
1409
  x: props.x,
965
1410
  y: props.y,
@@ -967,11 +1412,27 @@ function card(props, ...children) {
967
1412
  height: props.height,
968
1413
  backgroundColor: (_a = props.background) != null ? _a : palette.card,
969
1414
  cornerRadius: (_b = props.radius) != null ? _b : 12,
970
- border: { width: 1, color: (_c = props.border) != null ? _c : palette.cardBorder },
971
- interceptsMouseClicks: !!props.onClick,
972
- ...props.onClick && { onClick: props.onClick, mouseCursorType: "pointing hand" }
1415
+ border: { width: 1, color: (_c = props.border) != null ? _c : palette.cardBorder }
973
1416
  }, ...children);
974
1417
  }
1418
+ function ClickableCard(props) {
1419
+ var _a, _b, _c;
1420
+ const [hovered, setHovered] = React2.useState(false);
1421
+ return label({
1422
+ x: props.x,
1423
+ y: props.y,
1424
+ width: props.width,
1425
+ height: props.height,
1426
+ backgroundColor: hovered ? color("#ffffff", 0.05) : (_a = props.background) != null ? _a : palette.card,
1427
+ cornerRadius: (_b = props.radius) != null ? _b : 12,
1428
+ border: { width: 1, color: (_c = props.border) != null ? _c : palette.cardBorder },
1429
+ interceptsMouseClicks: true,
1430
+ mouseCursorType: "pointing hand",
1431
+ onMouseEnter: () => setHovered(true),
1432
+ onMouseExit: () => setHovered(false),
1433
+ onClick: props.onClick
1434
+ }, ...React2.Children.toArray(props.children));
1435
+ }
975
1436
  var SCROLLBAR = 6;
976
1437
  function scrollView(props, contentHeight, ...children) {
977
1438
  return h("geScrollView", {
@@ -1171,6 +1632,24 @@ function useUiState(moonbase) {
1171
1632
  }, [moonbase]);
1172
1633
  return ui;
1173
1634
  }
1635
+ function useFontMetrics(ui) {
1636
+ var _a;
1637
+ const [measured, setMeasured] = React3.useState(0);
1638
+ const { regular, medium, semibold, mono } = (_a = ui.fonts) != null ? _a : {};
1639
+ React3.useEffect(() => {
1640
+ var _a2;
1641
+ let live = true;
1642
+ measureFonts([regular, medium != null ? medium : regular, (_a2 = semibold != null ? semibold : medium) != null ? _a2 : regular, mono != null ? mono : regular]).then((known) => {
1643
+ if (live && known)
1644
+ setMeasured((count) => count + 1);
1645
+ }, () => {
1646
+ });
1647
+ return () => {
1648
+ live = false;
1649
+ };
1650
+ }, [regular, medium, semibold, mono]);
1651
+ return measured;
1652
+ }
1174
1653
  function statusView(state) {
1175
1654
  switch (state.status) {
1176
1655
  case "unlicensed":
@@ -1189,6 +1668,28 @@ function statusView(state) {
1189
1668
  return "loading";
1190
1669
  }
1191
1670
  }
1671
+ function requestedView(screen, state) {
1672
+ const next = screen === "license" ? "details" : screen;
1673
+ if ((next === "details" || next === "addons") && !state.license)
1674
+ return null;
1675
+ return next;
1676
+ }
1677
+ function followState(view, before, state) {
1678
+ var _a;
1679
+ let next = view;
1680
+ const activated = before.status === "activating" && !state.activation && !!state.license && state.license.activationId !== ((_a = before.license) == null ? void 0 : _a.activationId);
1681
+ if (activated)
1682
+ next = "success";
1683
+ if ((next === "details" || next === "addons" || next === "update") && !state.license)
1684
+ next = null;
1685
+ if (state.status === "activating")
1686
+ next = null;
1687
+ if (state.status === "notCovered" && before.status !== "notCovered")
1688
+ next = null;
1689
+ if (next === "success" && !state.license)
1690
+ next = null;
1691
+ return next;
1692
+ }
1192
1693
  function droppedFiles(dropped) {
1193
1694
  if (typeof dropped === "string")
1194
1695
  return [dropped];
@@ -1197,22 +1698,30 @@ function droppedFiles(dropped) {
1197
1698
  const files = dropped == null ? void 0 : dropped.files;
1198
1699
  return Array.isArray(files) ? files.filter((file) => typeof file === "string") : [];
1199
1700
  }
1701
+ function displayPath(file) {
1702
+ const home = os2.homedir();
1703
+ return home && file.startsWith(home) ? `~${file.slice(home.length)}` : file;
1704
+ }
1200
1705
  function Panel({ moonbase, state, screen, request, download, width: areaWidth, height: areaHeight }) {
1201
1706
  var _a, _b, _c, _d, _e;
1202
1707
  const ui = moonbase.ui;
1203
- const theme = { accent: (_a = ui.accent) != null ? _a : "#186cdc", fonts: (_b = ui.fonts) != null ? _b : {} };
1708
+ const theme = { accent: (_a = ui.accent) != null ? _a : "#186cdc", fonts: (_b = ui.fonts) != null ? _b : {}, icon: (name2, colour, size, stroke) => moonbase.icon(name2, colour, size, stroke) };
1204
1709
  const product = (_c = ui.productName) != null ? _c : "the plugin";
1205
1710
  const account = ui.manufacturerName || "Moonbase";
1206
1711
  const strings = (_d = ui.strings) != null ? _d : {};
1207
1712
  const cardWidth = Math.min(CARD_WIDTH, areaWidth - 32);
1208
1713
  const width = cardWidth - PAD_X * 2;
1209
1714
  const still = !!ui.reduceMotion;
1210
- const [view, setView] = React3.useState(null);
1715
+ const showBadge = (_e = ui.showMoonbaseBadge) != null ? _e : true;
1716
+ const footer = showBadge ? 30 + 18 + 18 : 8;
1717
+ const room = Math.max(120, areaHeight - 24 - PAD_TOP - footer - PAD_BOTTOM);
1718
+ const [view, setView] = React3.useState(() => requestedView(screen, state));
1211
1719
  const [update, setUpdate] = React3.useState(null);
1212
1720
  const [cameFromDetails, setCameFromDetails] = React3.useState(false);
1213
1721
  const [offline, setOffline] = React3.useState({ saved: null, file: null, busy: false, error: "" });
1214
1722
  const [copied, setCopied] = React3.useState(null);
1215
- const previous = React3.useRef(null);
1723
+ const [seen, setSeen] = React3.useState({ state, request });
1724
+ const previous = React3.useRef(state);
1216
1725
  const run2 = (name2, action) => {
1217
1726
  action().catch((err) => moonbase.reportError(name2, err));
1218
1727
  };
@@ -1235,38 +1744,38 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
1235
1744
  };
1236
1745
  const flashCopied = (what) => {
1237
1746
  setCopied(what);
1238
- setTimeout(() => setCopied((current) => current === what ? null : current), 2e3);
1747
+ setTimeout(() => setCopied((current2) => current2 === what ? null : current2), 2e3);
1239
1748
  };
1749
+ let current = view;
1750
+ if (seen.request !== request || seen.state !== state) {
1751
+ let next = view;
1752
+ if (seen.request !== request) {
1753
+ next = requestedView(screen, state);
1754
+ if (screen === "update") {
1755
+ setCameFromDetails(false);
1756
+ setUpdate(null);
1757
+ }
1758
+ }
1759
+ if (seen.state !== state)
1760
+ next = followState(next, seen.state, state);
1761
+ setSeen({ state, request });
1762
+ if (next !== view)
1763
+ setView(next);
1764
+ current = next;
1765
+ }
1240
1766
  React3.useEffect(() => {
1241
1767
  if (screen === "update")
1242
- return openUpdate(false);
1243
- let next = screen === "license" ? "details" : screen;
1244
- if ((next === "details" || next === "addons") && !moonbase.state().license)
1245
- next = null;
1246
- go(next);
1768
+ loadUpdate();
1769
+ else if (requestedView(screen, moonbase.state()) === "addons")
1770
+ run2("loadAddOns", () => moonbase.loadAddOns());
1247
1771
  }, [request]);
1248
1772
  React3.useEffect(() => {
1249
- var _a2;
1250
1773
  const before = previous.current;
1251
1774
  previous.current = state;
1252
- let next = view;
1253
- const activated = (before == null ? void 0 : before.status) === "activating" && !state.activation && !!state.license && state.license.activationId !== ((_a2 = before.license) == null ? void 0 : _a2.activationId);
1254
- if (activated)
1255
- next = "success";
1256
- if ((next === "details" || next === "addons" || next === "update") && !state.license)
1257
- next = null;
1258
- if (state.status === "activating")
1259
- next = null;
1260
- if (state.status === "notCovered" && (before == null ? void 0 : before.status) !== "notCovered")
1261
- next = null;
1262
- if (next === "success" && !state.license)
1263
- next = null;
1264
- if (next === "addons" && state.license && state.addOns.phase === "idle" && before && before.addOns.phase !== "idle")
1775
+ if (current === "addons" && state.license && state.addOns.phase === "idle" && before.addOns.phase !== "idle")
1265
1776
  run2("loadAddOns", () => moonbase.loadAddOns());
1266
- if (next !== view)
1267
- setView(next);
1268
1777
  }, [state]);
1269
- const name = view != null ? view : statusView(state);
1778
+ const name = current != null ? current : statusView(state);
1270
1779
  const lockup = (options = {}) => {
1271
1780
  const size = options.large ? 38 : 34;
1272
1781
  return {
@@ -1280,9 +1789,9 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
1280
1789
  const nodes = [lockup({ dim: options.dim }).render(x, y, available)];
1281
1790
  let right = x + available - (canClose ? 40 : 0);
1282
1791
  for (const each2 of [...pills].reverse()) {
1283
- const drawn = pill(theme, each2.tone, each2.text, 0, 0, each2.onClick);
1792
+ const drawn = pill(theme, each2.tone, each2.text, 0, 0, each2.onClick, each2.icon);
1284
1793
  right -= drawn.width;
1285
- nodes.push(pill(theme, each2.tone, each2.text, right, y + 5, each2.onClick).node);
1794
+ nodes.push(pill(theme, each2.tone, each2.text, right, y + 5, each2.onClick, each2.icon).node);
1286
1795
  right -= 8;
1287
1796
  }
1288
1797
  return nodes;
@@ -1291,12 +1800,15 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
1291
1800
  const errorLine = (message) => {
1292
1801
  if (!message)
1293
1802
  return null;
1294
- const body = paragraph(theme, `\u26A0 ${message}`, width, { size: 12.5, textColor: palette.warningText, lineHeight: 1.45 });
1295
- return { height: 14 + body.height, render: (x, y, available) => body.render(x, y + 14, available) };
1803
+ const body = paragraph(theme, message, width - 22, { size: 12.5, textColor: palette.warningText, lineHeight: 1.45 });
1804
+ return {
1805
+ height: 14 + body.height,
1806
+ render: (x, y, available) => [icon(theme, "warning", x, y + 16, 15, palette.warningText), body.render(x + 22, y + 14, available - 22)]
1807
+ };
1296
1808
  };
1297
1809
  const backLink = (value, onClick) => ({
1298
1810
  height: 20 + 12,
1299
- render: (x, y) => h(LinkNode, { key: "back", theme, x, y, value: `\u2039 ${value}`, onClick })
1811
+ render: (x, y) => h(Link, { key: "back", theme, x, y, label: value, icon: "back", onClick })
1300
1812
  });
1301
1813
  const notice = (value, tone) => {
1302
1814
  const body = paragraph(theme, value, width - 58, { size: 13, textColor: palette.textBody, lineHeight: 1.5 });
@@ -1304,7 +1816,7 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
1304
1816
  const tint = tone === "upgrade" ? palette.trial : palette.errorStrong;
1305
1817
  return {
1306
1818
  height: height + 24,
1307
- render: (x, y) => card({ x, y, width, height, background: color(tint, 0.07), border: color(tint, 0.22), radius: 10 }, text(theme, tone === "upgrade" ? "\u26A0" : "\u2298", 15, 12, 20, { size: 15, textColor: color(tone === "upgrade" ? palette.trial : palette.error) }), body.render(44, 13, width - 58))
1819
+ render: (x, y) => card({ x, y, width, height, background: color(tint, 0.07), border: color(tint, 0.22), radius: 10 }, icon(theme, tone === "upgrade" ? "warning" : "blocked", 15, 13, 18, color(tone === "upgrade" ? palette.trial : palette.error)), body.render(44, 13, width - 58))
1308
1820
  };
1309
1821
  };
1310
1822
  const features = () => {
@@ -1314,10 +1826,11 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
1314
1826
  return null;
1315
1827
  return {
1316
1828
  height: list.length * 30 - 11 + 26,
1317
- render: (x, y) => list.map((feature, index) => label({ key: `feature-${index}`, x, y: y + index * 30, width, height: 20 }, text(theme, feature.included ? "\u2713" : "\xD7", 0, 0, 20, { size: 14, weight: 700, textColor: feature.included ? color(palette.success) : palette.textMuted }), text(theme, feature.label, 28, 0, width - 28, { size: 13, textColor: feature.included ? palette.textBody : palette.textMuted })))
1829
+ render: (x, y) => list.map((feature, index) => label({ key: `feature-${index}`, x, y: y + index * 30, width, height: 20 }, icon(theme, feature.included ? "check" : "cross", 0, 1, 17, feature.included ? color(palette.success) : palette.textMuted, 2), text(theme, feature.label, 27, 0, width - 27, { size: 13, textColor: feature.included ? palette.textBody : palette.textMuted, height: 20 })))
1318
1830
  };
1319
1831
  };
1320
- const unlock = () => buttonBlock(theme, "Unlock full version", () => run2("activate", () => moonbase.activate()));
1832
+ const below = (top2, block) => ({ height: top2 + block.height, render: (x, y, available) => block.render(x, y + top2, available) });
1833
+ const unlock = () => buttonBlock(theme, "Unlock full version", () => run2("activate", () => moonbase.activate()), { icon: "lock" });
1321
1834
  const screens = {
1322
1835
  loading: () => [
1323
1836
  { height: 34, render: (x, y, available) => h(Spinner, { key: "spinner", x: x + available / 2 - 17, y, size: 34, tint: "#82cef1" }) },
@@ -1337,7 +1850,7 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
1337
1850
  space(28),
1338
1851
  buttonBlock(theme, strings.activateOnline || "Activate online", () => run2("activate", () => moonbase.activate()), { width: 340, height: 44 }),
1339
1852
  errorLine((_a2 = state.error) == null ? void 0 : _a2.message),
1340
- linksBlock(theme, [{ label: strings.activateOffline || "No internet? Activate offline", onClick: () => go("offline") }], { align: "left", marginTop: 24 })
1853
+ linksBlock(theme, [{ label: strings.activateOffline || "No internet? Activate offline", icon: "signal", onClick: () => go("offline") }], { align: "left", marginTop: 24 })
1341
1854
  ];
1342
1855
  },
1343
1856
  browser: () => {
@@ -1363,20 +1876,21 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
1363
1876
  space(8),
1364
1877
  paragraph(theme, body, width, { align: "center", maxWidth: 420 }),
1365
1878
  space(22),
1366
- failed && buttonBlock(theme, linkCopied ? "\u2713 Link copied" : "Copy activation link", copyLink, { width: 300, height: 44, align: "center" }),
1879
+ failed && buttonBlock(theme, linkCopied ? "Link copied" : "Copy activation link", copyLink, { width: 300, height: 44, align: "center", icon: linkCopied ? "check" : "copy" }),
1367
1880
  failed && space(18),
1368
1881
  !!url && {
1369
1882
  height: 50,
1370
1883
  render: (x, y, available) => {
1371
1884
  const value = `${moonbase.deviceName} \xB7 ${osLabel()}`;
1372
- const chipWidth = Math.min(available, textWidth(value, 12.5) + 30);
1373
- return card({ x: x + (available - chipWidth) / 2, y, width: chipWidth, height: 34, radius: 17, background: color("#ffffff", 0.04), border: color("#ffffff", 0.09) }, text(theme, value, 0, 0, chipWidth, { size: 12.5, textColor: palette.textBright, align: "center", height: 34 }));
1885
+ const textBox = Math.min(available - 54, textWidth(theme, value, 12.5));
1886
+ const chipWidth = textBox + 15 + 9 + 30;
1887
+ return card({ x: x + (available - chipWidth) / 2, y, width: chipWidth, height: 34, radius: 17, background: color("#ffffff", 0.04), border: color("#ffffff", 0.09) }, icon(theme, "computer", 15, 9, 15, palette.textSecondary, 1.6), text(theme, fitText(theme, value, 12.5, textBox, { end: true }), 39, 0, textBox, { size: 12.5, textColor: palette.textBright, height: 34 }));
1374
1888
  }
1375
1889
  },
1376
1890
  buttonBlock(theme, "Cancel activation", () => moonbase.cancelActivation(), { kind: "ghost", width: 300, height: 44, align: "center" }),
1377
1891
  !!url && !failed && linksBlock(theme, [
1378
1892
  { label: "Open the page again", onClick: () => run2("openLink", () => moonbase.openLink(url)) },
1379
- { label: linkCopied ? "\u2713 Link copied" : "Browser didn't open? Copy the link", link: true, onClick: copyLink }
1893
+ { label: linkCopied ? "Link copied" : "Browser didn't open? Copy the link", link: true, icon: linkCopied ? "check" : "copy", iconColour: linkCopied ? color(palette.success) : void 0, onClick: copyLink }
1380
1894
  ]),
1381
1895
  errorLine((_d2 = state.error) == null ? void 0 : _d2.message)
1382
1896
  ];
@@ -1385,7 +1899,7 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
1385
1899
  const license = state.license;
1386
1900
  if (!license)
1387
1901
  return screens[statusView(state)]();
1388
- const rows = [["Plan", planName(license)], ["Licensed to", license.issuedTo.email || license.issuedTo.name]];
1902
+ const rows = [["Plan", planName(license)], ["Licensed to", license.issuedTo.email || license.issuedTo.name]].filter(([, value]) => !!value);
1389
1903
  return [
1390
1904
  {
1391
1905
  height: 66 + 6,
@@ -1400,7 +1914,7 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
1400
1914
  height: rows.length * 34 + 32 + 26,
1401
1915
  render: (x, y, available) => {
1402
1916
  const cardWidth2 = Math.min(380, available);
1403
- return card({ x: x + (available - cardWidth2) / 2, y, width: cardWidth2, height: rows.length * 34 + 32 }, ...rows.map(([key, value], index) => label({ key, x: 18, y: 16 + index * 34, width: cardWidth2 - 36, height: 34 }, text(theme, key, 0, 0, 120, { size: 12.5, height: 34 }), text(theme, value, 120, 0, cardWidth2 - 156, { size: 13, weight: 500, textColor: palette.textPrimary, align: "right", height: 34 }))));
1917
+ return card({ x: x + (available - cardWidth2) / 2, y, width: cardWidth2, height: rows.length * 34 + 32 }, ...rows.map(([key, value], index) => label({ key, x: 18, y: 16 + index * 34, width: cardWidth2 - 36, height: 34 }, text(theme, key, 0, 0, 120, { size: 12.5, height: 34 }), text(theme, fitText(theme, value, 13, cardWidth2 - 156, { weight: 500, end: true }), 120, 0, cardWidth2 - 156, { size: 13, weight: 500, textColor: palette.textPrimary, align: "right", height: 34 }))));
1404
1918
  }
1405
1919
  },
1406
1920
  buttonBlock(theme, `Open ${product}`, close, { width: 380, align: "center" }),
@@ -1408,24 +1922,25 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
1408
1922
  ];
1409
1923
  },
1410
1924
  offline: () => {
1411
- const saveSub = offline.saved ? `Saved to ${offline.saved}` : "Choose where to save it";
1412
1925
  const requestFile = `${(product || "license").replace(/[\\/:*?"<>|]/g, "-")}.dt`;
1926
+ const textBox = width - 16 - 22 - 12 - 76;
1927
+ const saveSub = offline.saved ? fitText(theme, `Saved to ${displayPath(offline.saved)}`, 11.5, textBox) : "Choose where to save it";
1413
1928
  const saveRequest = () => {
1414
- setOffline((current) => ({ ...current, error: "" }));
1929
+ setOffline((current2) => ({ ...current2, error: "" }));
1415
1930
  moonbase.saveMachineFile().then(
1416
- (saved) => setOffline((current) => ({ ...current, saved: saved != null ? saved : current.saved })),
1931
+ (saved) => setOffline((current2) => ({ ...current2, saved: saved != null ? saved : current2.saved })),
1417
1932
  (err) => {
1418
1933
  moonbase.reportError("saveMachineFile", err);
1419
- setOffline((current) => ({ ...current, error: err instanceof Error ? err.message : String(err) }));
1934
+ setOffline((current2) => ({ ...current2, error: err instanceof Error ? err.message : String(err) }));
1420
1935
  }
1421
1936
  );
1422
1937
  };
1423
1938
  const useFile = (pick) => {
1424
1939
  pick.then(
1425
- (file) => file && setOffline((current) => ({ ...current, file, error: "" })),
1940
+ (file) => file && setOffline((current2) => ({ ...current2, file, error: "" })),
1426
1941
  (err) => {
1427
1942
  moonbase.reportError("readLicenseFile", err);
1428
- setOffline((current) => ({ ...current, error: "Couldn't read that file." }));
1943
+ setOffline((current2) => ({ ...current2, error: "Couldn't read that file." }));
1429
1944
  }
1430
1945
  );
1431
1946
  };
@@ -1433,24 +1948,28 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
1433
1948
  if (offline.busy)
1434
1949
  return;
1435
1950
  if (!offline.file) {
1436
- setOffline((current) => ({ ...current, error: `Add the license file from ${activationHost(moonbase)} to continue.` }));
1951
+ setOffline((current2) => ({ ...current2, error: `Add the license file from ${activationHost(moonbase)} to continue.` }));
1437
1952
  return;
1438
1953
  }
1439
- setOffline((current) => ({ ...current, busy: true, error: "" }));
1954
+ setOffline((current2) => ({ ...current2, busy: true, error: "" }));
1440
1955
  moonbase.activateOffline(offline.file.text).then(() => {
1441
1956
  setOffline({ saved: null, file: null, busy: false, error: "" });
1442
1957
  setView("success");
1443
1958
  }, () => {
1444
- setOffline((current) => {
1959
+ setOffline((current2) => {
1445
1960
  var _a2;
1446
- return { ...current, busy: false, error: ((_a2 = moonbase.state().error) == null ? void 0 : _a2.message) || "That license file isn't valid for this device." };
1961
+ return { ...current2, busy: false, error: ((_a2 = moonbase.state().error) == null ? void 0 : _a2.message) || "That license file isn't valid for this device." };
1447
1962
  });
1448
1963
  });
1449
1964
  };
1450
1965
  const step = (n, value) => ({
1451
1966
  height: 20 + 10,
1452
- render: (x, y) => label({ key: `step-${n}`, x, y, width, height: 20 }, label({ x: 0, y: 0, width: 20, height: 20, cornerRadius: 10, backgroundColor: color(theme.accent), text: n, fontSize: 11, textColor: palette.white, textAlign: "center" }), text(theme, value, 30, 0, width - 30, { size: 13, weight: 500, textColor: palette.textBody, height: 20 }))
1967
+ render: (x, y) => label({ key: `step-${n}`, x, y, width, height: 20 }, label({ x: 0, y: 0, width: 20, height: 20, cornerRadius: 10, backgroundColor: color(theme.accent), text: n, font: fontFor(theme, 600), fontSize: 11, textColor: palette.white, textAlign: "center" }), text(theme, value, 30, 0, width - 30, { size: 13, weight: 500, textColor: palette.textBody, height: 20 }))
1453
1968
  });
1969
+ const dropTitle = offline.file ? fitText(theme, offline.file.name, 13, width - 120, { mono: true }) : "Drop your license file here";
1970
+ const dropSub = offline.file ? "Click to choose a different file" : "or click to browse \xB7 .mb";
1971
+ const dropText = Math.max(textWidth(theme, dropTitle, 13, offline.file ? 400 : 500, { mono: !!offline.file }), textWidth(theme, dropSub, 11.5));
1972
+ const dropLeft = Math.round((width - 24 - 12 - dropText) / 2);
1454
1973
  return [
1455
1974
  backLink("Back", () => go(null)),
1456
1975
  heading(theme, "Offline activation", width),
@@ -1460,7 +1979,7 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
1460
1979
  step("1", "Save your request file"),
1461
1980
  {
1462
1981
  height: 52 + 16,
1463
- render: (x, y) => card({ x, y, width, height: 52, radius: 9, background: palette.ghost, border: color("#ffffff", 0.12), onClick: saveRequest }, text(theme, requestFile, 16, 7, width - 120, { size: 13, mono: true, textColor: palette.textPrimary }), text(theme, saveSub, 16, 27, width - 120, { size: 11.5, textColor: palette.textSecondary }), text(theme, offline.saved ? "\u2713" : "Save\u2026", width - 80, 0, 64, { size: offline.saved ? 18 : 12.5, weight: 600, textColor: offline.saved ? color(palette.success) : palette.link, align: "right", height: 52 }))
1982
+ render: (x, y) => card({ x, y, width, height: 52, radius: 9, background: palette.ghost, border: color("#ffffff", 0.12), onClick: saveRequest }, icon(theme, "fileDown", 16, 15, 22, palette.glow, 1.6), text(theme, requestFile, 50, 7, textBox, { size: 13, mono: true, textColor: palette.textPrimary }), text(theme, saveSub, 50, 27, textBox, { size: 11.5, textColor: palette.textSecondary, height: 18 }), offline.saved ? icon(theme, "check", width - 16 - 20, 16, 20, color(palette.success), 2) : text(theme, "Save\u2026", width - 80, 0, 64, { size: 12, weight: 500, textColor: palette.glow, align: "right", height: 52 }))
1464
1983
  },
1465
1984
  step("2", "Add the license file"),
1466
1985
  {
@@ -1476,7 +1995,7 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
1476
1995
  if (file)
1477
1996
  useFile(moonbase.readLicenseFile(file));
1478
1997
  }
1479
- }, card({ x: 0, y: 0, width, height: 72, radius: 10, background: color("#ffffff", 0.02), border: color("#ffffff", 0.16), onClick: () => useFile(moonbase.chooseLicenseFile()) }, text(theme, offline.file ? offline.file.name : "Drop your license file here", 0, 15, width, { size: 13, weight: 600, mono: !!offline.file, textColor: offline.file ? palette.textPrimary : palette.textBody, align: "center" }), text(theme, offline.file ? "Click to choose a different file" : "or click to browse \xB7 .mb", 0, 38, width, { size: 11.5, textColor: palette.textSecondary, align: "center" })))
1998
+ }, card({ x: 0, y: 0, width, height: 72, radius: 10, background: color("#ffffff", 0.02), border: color("#ffffff", 0.16), onClick: () => useFile(moonbase.chooseLicenseFile()) }, offline.file ? icon(theme, "okCircle", dropLeft, 24, 24, color(palette.success), 1.7) : icon(theme, "upload", dropLeft, 24, 24, palette.textSecondary, 1.6), text(theme, dropTitle, dropLeft + 36, 15, dropText + 4, { size: 13, weight: offline.file ? 400 : 500, mono: !!offline.file, textColor: offline.file ? palette.textPrimary : palette.textBody }), text(theme, dropSub, dropLeft + 36, 38, dropText + 4, { size: 11.5, textColor: palette.textSecondary })))
1480
1999
  },
1481
2000
  errorLine(offline.error),
1482
2001
  space(16),
@@ -1532,7 +2051,7 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
1532
2051
  paragraph(theme, body, width),
1533
2052
  space(22),
1534
2053
  notice(`${product} is locked. Your license still works with the versions it covers, so you can go back to one of those, or upgrade to use this one.`, "upgrade"),
1535
- buttonBlock(theme, upgradeLabel(access), () => run2("upgradeLicense", () => moonbase.upgradeLicense())),
2054
+ buttonBlock(theme, upgradeLabel(access), () => run2("upgradeLicense", () => moonbase.upgradeLicense()), { icon: "external" }),
1536
2055
  errorLine((_a2 = state.error) == null ? void 0 : _a2.message),
1537
2056
  linksBlock(theme, [offlineLicense ? { label: "Load an upgraded license file", onClick: () => go("offline") } : { label: state.refreshing ? "Checking your license\u2026" : renewal ? "Already renewed? Check again" : "Already upgraded? Check again", disabled: state.refreshing, onClick: () => run2("refresh", () => moonbase.refresh()) }])
1538
2057
  ];
@@ -1546,7 +2065,7 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
1546
2065
  ["Licensed to", license.issuedTo.name || license.issuedTo.email],
1547
2066
  ["Email", license.issuedTo.email],
1548
2067
  ["Plan", `${planName(license)} \xB7 ${license.expiresAt ? `until ${formatDate(license.expiresAt)}` : "perpetual"}`]
1549
- ];
2068
+ ].filter(([, value]) => !!value);
1550
2069
  const seatCount = license.seatCount;
1551
2070
  const used = license.seatsUsed;
1552
2071
  const pipCount = seatCount ? Math.min(seatCount, 8) : 0;
@@ -1554,14 +2073,15 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
1554
2073
  const seatsTitle = seatCount ? `Activations \xB7 ${used != null ? used : "?"} of ${seatCount} ${seatCount === 1 ? "device" : "devices"}` : license.activationMethod === "Offline" ? "Activated offline on this device" : "Activated on this device";
1555
2074
  const idCopied = copied === license.id;
1556
2075
  const rowHeight = 44;
2076
+ const valueWidth = width - 172;
1557
2077
  return [
1558
2078
  header([
1559
- ...state.update ? [{ tone: "update", text: "\u2193 Update", onClick: () => openUpdate(true) }] : [],
2079
+ ...state.update ? [{ tone: "update", text: "Update", icon: "download", onClick: () => openUpdate(true) }] : [],
1560
2080
  { tone: "active", text: license.trial ? "Trial" : "Active" }
1561
2081
  ]),
1562
2082
  {
1563
2083
  height: (rows.length + 1) * rowHeight + 2 + 18,
1564
- render: (x, y) => card({ x, y, width, height: (rows.length + 1) * rowHeight + 2 }, ...rows.map(([key, value], index) => label({ key, x: 16, y: 1 + index * rowHeight, width: width - 32, height: rowHeight }, text(theme, key, 0, 0, 140, { size: 12.5, height: rowHeight }), text(theme, value, 140, 0, width - 172, { size: 13, weight: 500, textColor: index === 1 ? palette.textBody : palette.textPrimary, align: "right", height: rowHeight }), label({ x: 0, y: rowHeight - 1, width: width - 32, height: 1, backgroundColor: palette.divider }))), label({ key: "id", x: 16, y: 1 + rows.length * rowHeight, width: width - 32, height: rowHeight }, text(theme, "License ID", 0, 0, 100, { size: 12.5, height: rowHeight }), text(theme, license.id, 100, 0, width - 32 - 100 - 84, { size: 12, mono: true, textColor: palette.glow, align: "right", height: rowHeight }), h(Button, { key: "copy", theme, x: width - 32 - 74, y: 7, width: 74, height: 30, label: idCopied ? "\u2713 Copied" : "Copy", kind: "quiet", size: 11.5, onClick: () => moonbase.copyText(license.id).then(() => flashCopied(license.id), (err) => moonbase.reportError("copyText", err)) })))
2084
+ render: (x, y) => card({ x, y, width, height: (rows.length + 1) * rowHeight + 2 }, ...rows.map(([key, value], index) => label({ key, x: 16, y: 1 + index * rowHeight, width: width - 32, height: rowHeight }, text(theme, key, 0, 0, 140, { size: 12.5, height: rowHeight }), text(theme, fitText(theme, value, 13, valueWidth, { weight: 500, end: key !== "Email" }), 140, 0, valueWidth, { size: 13, weight: 500, textColor: key === "Email" ? palette.textBody : palette.textPrimary, align: "right", height: rowHeight }), label({ x: 0, y: rowHeight - 1, width: width - 32, height: 1, backgroundColor: palette.divider }))), label({ key: "id", x: 16, y: 1 + rows.length * rowHeight, width: width - 32, height: rowHeight }, text(theme, "License ID", 0, 0, 100, { size: 12.5, height: rowHeight }), text(theme, license.id, 100, 0, width - 32 - 100 - 96, { size: 12, mono: true, textColor: palette.glow, align: "right", height: rowHeight }), h(Button, { key: "copy", theme, x: width - 32 - 86, y: 7, width: 86, height: 30, label: idCopied ? "Copied" : "Copy", icon: idCopied ? "check" : "copy", kind: "quiet", size: 11.5, onClick: () => moonbase.copyText(license.id).then(() => flashCopied(license.id), (err) => moonbase.reportError("copyText", err)) })))
1565
2085
  },
1566
2086
  {
1567
2087
  height: 64 + 22,
@@ -1581,7 +2101,7 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
1581
2101
  errorLine((_a2 = state.error) == null ? void 0 : _a2.message),
1582
2102
  ui.showAddOns && !license.trial && {
1583
2103
  height: 62 + (state.error ? 14 : 0),
1584
- render: (x, y) => card({ x, y: y + (state.error ? 14 : 0), width, height: 62, onClick: () => go("addons") }, text(theme, "Add-ons", 16, 12, width - 80, { size: 14, weight: 600, textColor: palette.textPrimary }), text(theme, state.activeSubProducts.length ? `${state.activeSubProducts.length} active on this computer` : "See what you can add", 16, 32, width - 80, { size: 12, textColor: palette.textSecondary }), text(theme, "\u203A", width - 36, 0, 20, { size: 22, textColor: palette.textSecondary, align: "center", height: 62 }))
2104
+ render: (x, y) => card({ x, y: y + (state.error ? 14 : 0), width, height: 62, onClick: () => go("addons") }, icon(theme, "puzzle", 16, 21, 20, color(theme.accent), 1.7), text(theme, "Add-ons", 49, 12, width - 100, { size: 14, weight: 600, textColor: palette.textPrimary }), text(theme, state.activeSubProducts.length ? `${state.activeSubProducts.length} active on this computer` : "See what you can add", 49, 32, width - 100, { size: 12, textColor: palette.textSecondary }), icon(theme, "chevron", width - 16 - 18, 22, 18, palette.textSecondary, 2))
1585
2105
  }
1586
2106
  ];
1587
2107
  },
@@ -1611,7 +2131,7 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
1611
2131
  }
1612
2132
  };
1613
2133
  } else if (info.phase !== "ready") {
1614
- list = { height: 3 * (rowHeight + 10) - 10, render: (x, y) => [0, 1, 2].map((index) => card({ x, y: y + index * (rowHeight + 10), width, height: rowHeight })) };
2134
+ list = { height: 3 * (rowHeight + 10) - 10, render: (x, y) => [0, 1, 2].map((index) => card({ x, y: y + index * (rowHeight + 10), width, height: rowHeight }, label({ x: 16, y: 13, width: 38, height: 38, cornerRadius: 10, backgroundColor: color("#ffffff", 0.05) }), label({ x: 68, y: 21, width: Math.round(width * 0.34), height: 10, cornerRadius: 5, backgroundColor: color("#ffffff", 0.07) }), label({ x: 68, y: 40, width: Math.round(width * 0.52), height: 8, cornerRadius: 4, backgroundColor: color("#ffffff", 0.07) }))) };
1615
2135
  } else if (failed) {
1616
2136
  list = (_a2 = errorLine(info.error)) != null ? _a2 : space(0);
1617
2137
  } else {
@@ -1630,7 +2150,7 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
1630
2150
  link: true,
1631
2151
  disabled: loading || waiting,
1632
2152
  onClick: () => run2(failed ? "loadAddOns" : "refreshAddOns", () => failed ? moonbase.loadAddOns() : moonbase.refreshAddOns())
1633
- }], { align: "left" })
2153
+ }], { align: "left", marginTop: 18 })
1634
2154
  ];
1635
2155
  },
1636
2156
  update: () => {
@@ -1658,41 +2178,30 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
1658
2178
  const notCovered = update.covered === false || download.phase === "notCovered";
1659
2179
  const access = (_a2 = download.releaseAccess) != null ? _a2 : update.releaseAccess;
1660
2180
  const upgradeUrl = (_b2 = download.upgradeUrl) != null ? _b2 : update.upgradeUrl;
1661
- const noteBlocks = notes.map((note) => paragraph(theme, note, width - 70, { size: 13, textColor: palette.textBody, lineHeight: 1.45 }));
1662
- const notesHeight = noteBlocks.reduce((sum, block) => sum + block.height + 8, 0) + 30 + 20;
1663
2181
  let action;
1664
2182
  if (download.phase === "done")
1665
- action = buttonBlock(theme, "Show in folder", () => run2("revealUpdate", () => moonbase.revealUpdate()));
2183
+ action = buttonBlock(theme, "Show in folder", () => run2("revealUpdate", () => moonbase.revealUpdate()), { icon: "download" });
1666
2184
  else if (notCovered)
1667
- action = upgradeUrl ? buttonBlock(theme, upgradeLabel(access), () => run2("upgradeLicense", () => moonbase.upgradeLicense())) : null;
2185
+ action = upgradeUrl ? buttonBlock(theme, upgradeLabel(access), () => run2("upgradeLicense", () => moonbase.upgradeLicense()), { icon: "external" }) : null;
1668
2186
  else if (update.canDownload)
1669
- action = buttonBlock(theme, downloading ? percent !== null ? `Downloading\u2026 ${percent}%` : "Downloading\u2026" : `Download ${update.latestVersion}`, () => run2("downloadUpdate", () => moonbase.downloadUpdate()), { disabled: downloading });
2187
+ action = buttonBlock(theme, downloading ? percent !== null ? `Downloading\u2026 ${percent}%` : "Downloading\u2026" : `Download ${update.latestVersion}`, () => run2("downloadUpdate", () => moonbase.downloadUpdate()), { disabled: downloading, icon: downloading ? void 0 : "download" });
1670
2188
  else
1671
2189
  action = update.hasDownloads ? unlock() : null;
1672
2190
  const standing = notCovered ? ", which your license doesn't cover." : !update.hasDownloads ? ", which has no download for this computer yet." : update.canDownload ? ", included in your license." : ", which your license doesn't include yet.";
1673
- return [
2191
+ const above = [
1674
2192
  lockup(),
1675
2193
  space(24),
1676
- { height: 24 + 14, render: (x, y) => pill(theme, "update", "\u2193 Update available", x, y).node },
2194
+ { height: 24 + 14, render: (x, y) => pill(theme, "update", "Update available", x, y, void 0, "download").node },
1677
2195
  heading(theme, `${product} ${update.latestVersion} is ready`, width),
1678
2196
  space(8),
1679
2197
  paragraph(theme, `You're on ${update.currentVersion || "an earlier version"}. The latest is ${update.latestVersion}${standing}`, width),
1680
- space(20),
1681
- notes.length > 0 && {
1682
- height: notesHeight + 20,
1683
- render: (x, y) => {
1684
- let top2 = 44;
1685
- return card({ x, y, width, height: notesHeight }, text(theme, "WHAT'S NEW", 18, 16, width - 36, { size: 11, weight: 600, kerning: 0.08, textColor: palette.textSecondary }), ...noteBlocks.map((block, index) => {
1686
- const node = label({ key: `note-${index}`, x: 18, y: top2, width: width - 36, height: block.height }, text(theme, "\u2713", 0, 0, 18, { size: 13, weight: 700, textColor: color(theme.accent) }), block.render(28, 0, width - 70));
1687
- top2 += block.height + 8;
1688
- return node;
1689
- }));
1690
- }
1691
- },
2198
+ space(20)
2199
+ ];
2200
+ const after = [
1692
2201
  downloading && barBlock(percent !== null ? percent / 100 : 0.08, color(theme.accent), { marginTop: 0, marginBottom: 14 }),
1693
2202
  action,
1694
- download.phase === "done" && !!download.path && { ...paragraph(theme, `Saved to ${download.path}`, width, { size: 12.5, align: "center" }), height: 12 + 20 },
1695
- notCovered && paragraph(theme, [`Version ${update.latestVersion} needs an upgrade.`, releaseAccessText(access)].filter(Boolean).join(" "), width, { size: 12, textColor: palette.textMuted }),
2203
+ download.phase === "done" && !!download.path && below(12, paragraph(theme, fitText(theme, `Saved to ${displayPath(download.path)}`, 12.5, width), width, { size: 12.5, align: "center" })),
2204
+ notCovered && below(16, paragraph(theme, [`Version ${update.latestVersion} needs an upgrade.`, releaseAccessText(access)].filter(Boolean).join(" "), width, { size: 12, textColor: palette.textMuted })),
1696
2205
  errorLine(download.phase === "failed" ? download.error : null),
1697
2206
  linksBlock(theme, [
1698
2207
  { label: "Remind me later", onClick: back },
@@ -1702,6 +2211,27 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
1702
2211
  } }
1703
2212
  ])
1704
2213
  ];
2214
+ const noteWidth = width - 36 - 26 - SCROLLBAR - 4;
2215
+ const noteBlocks = notes.map((note) => paragraph(theme, note, noteWidth, { size: 13, textColor: palette.textBody, lineHeight: 1.45 }));
2216
+ const listNatural = noteBlocks.reduce((sum, block) => sum + block.height, 0) + Math.max(0, noteBlocks.length - 1) * 10;
2217
+ const chrome = 16 + 17 + 12 + 16 + 22;
2218
+ const taken = [...above, ...after].reduce((sum, block) => sum + (block ? block.height : 0), 0);
2219
+ const listHeight = Math.min(listNatural, 190, Math.max(Math.min(listNatural, 40), room - taken - chrome));
2220
+ const listScrolls = listHeight < listNatural;
2221
+ const notesBlock = notes.length > 0 && {
2222
+ height: listHeight + chrome,
2223
+ render: (x, y) => {
2224
+ let top2 = 0;
2225
+ const rowWidth = width - 36 - (listScrolls ? SCROLLBAR + 4 : 0);
2226
+ const rows = noteBlocks.map((block, index) => {
2227
+ const node = label({ key: `note-${index}`, x: 0, y: top2, width: rowWidth, height: block.height }, icon(theme, "check", 0, 2, 16, color(theme.accent), 2), block.render(26, 0, rowWidth - 26));
2228
+ top2 += block.height + 10;
2229
+ return node;
2230
+ });
2231
+ return card({ x, y, width, height: listHeight + chrome - 22 }, text(theme, "WHAT'S NEW", 18, 16, width - 36, { size: 11, weight: 600, kerning: 0.08, textColor: palette.textSecondary }), listScrolls ? scrollView({ key: "notes", x: 18, y: 45, width: width - 36, height: listHeight }, listNatural, ...rows) : label({ key: "notes", x: 18, y: 45, width: width - 36, height: listHeight }, ...rows));
2232
+ }
2233
+ };
2234
+ return [...above, notesBlock, ...after];
1705
2235
  }
1706
2236
  };
1707
2237
  const addOnActions = {
@@ -1718,19 +2248,16 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
1718
2248
  const buttons = actions.reverse().map((action) => {
1719
2249
  const primary = action === row.primary;
1720
2250
  const value = primary && busyId === row.id ? "\u2026" : addOnActions[action].label;
1721
- const buttonWidth = Math.max(76, textWidth(value, 13, 600) + 32);
2251
+ const buttonWidth = Math.max(76, textWidth(theme, value, 13, 600) + 32);
1722
2252
  right -= buttonWidth;
1723
2253
  const node = h(Button, { key: action, theme, x: right, y: (rowHeight - 34) / 2, width: buttonWidth, height: 34, size: 13, label: value, kind: primary ? "small-primary" : "small-ghost", disabled: anyBusy, onClick: () => run2(action, () => addOnActions[action].run(row.id)) });
1724
2254
  right -= 8;
1725
2255
  return node;
1726
2256
  });
1727
- return card({ x, y, width: rowWidth, height: rowHeight, background: tint ? color(tint, 0.04) : palette.card, border: tint ? color(tint, 0.25) : palette.cardBorder }, label({ x: 16, y: (rowHeight - 38) / 2, width: 38, height: 38, cornerRadius: 10, backgroundColor: tint ? color(tint, 0.12) : color("#ffffff", 0.05), text: row.tone === "success" ? "\u2713" : "\u2726", fontSize: 16, textColor: tint ? color(tint) : palette.textSecondary, textAlign: "center" }), text(theme, row.name, 68, 12, right - 76, { size: 14, weight: 600, textColor: palette.textPrimary }), row.status && text(theme, row.status, 68, 33, right - 76, { size: 12.5, textColor: tint ? color(tint) : palette.textSecondary }), ...buttons);
2257
+ return card({ x, y, width: rowWidth, height: rowHeight, background: tint ? color(tint, 0.04) : palette.card, border: tint ? color(tint, 0.25) : palette.cardBorder }, label({ x: 16, y: (rowHeight - 38) / 2, width: 38, height: 38, cornerRadius: 10, backgroundColor: tint ? color(tint, 0.12) : color("#ffffff", 0.05) }, icon(theme, row.tone === "success" ? "check" : "sparkles", 9, 9, 20, tint ? color(tint) : palette.textSecondary, 1.7)), text(theme, fitText(theme, row.name, 14, right - 76, { weight: 600, end: true }), 68, 12, right - 76, { size: 14, weight: 600, textColor: palette.textPrimary }), row.status && text(theme, fitText(theme, row.status, 12.5, right - 76, { end: true }), 68, 33, right - 76, { size: 12.5, textColor: tint ? color(tint) : palette.textSecondary }), ...buttons);
1728
2258
  }
1729
2259
  const blocks = screens[name]();
1730
- const showBadge = (_e = ui.showMoonbaseBadge) != null ? _e : true;
1731
- const footer = showBadge ? 30 + 18 + 18 : 8;
1732
2260
  const screenHeight = blocks.reduce((sum, block) => sum + (block ? block.height : 0), 0);
1733
- const room = Math.max(120, areaHeight - 24 - PAD_TOP - footer - PAD_BOTTOM);
1734
2261
  const scrolls = screenHeight > room;
1735
2262
  let content;
1736
2263
  if (scrolls) {
@@ -1751,7 +2278,7 @@ function Panel({ moonbase, state, screen, request, download, width: areaWidth, h
1751
2278
  screen: name,
1752
2279
  contentHeight: content.height,
1753
2280
  content: content.nodes,
1754
- closeButton: canClose && h(Button, { key: "close", theme, x: cardWidth - 46, y: 14, width: 32, height: 32, label: "\xD7", size: 20, kind: "quiet", onClick: close }),
2281
+ closeButton: canClose && h(Button, { key: "close", theme, x: cardWidth - 46, y: 14, width: 32, height: 32, label: "", icon: "cross", iconSize: 18, kind: "quiet", onClick: close }),
1755
2282
  // Kept to the card's bottom edge as it resizes.
1756
2283
  footer: showBadge ? (height) => {
1757
2284
  const divider = height - footer - PAD_BOTTOM + 30;
@@ -1775,39 +2302,23 @@ function PanelCard(props) {
1775
2302
  return card(
1776
2303
  { x: props.left, y: Math.round(top), width: props.width, height: cardHeight, background: palette.panel, border: color("#ffffff", 0.08), radius: 16 },
1777
2304
  h(Glow, { key: "glow", width: props.width, still: props.still }),
1778
- label({ key: "screen", x: 0, y: Math.round(8 * (1 - entered)), width: props.width, height: PAD_TOP + props.contentHeight, alpha: entered }, ...props.content),
2305
+ label({ key: `screen-${props.screen}`, x: 0, y: Math.round(8 * (1 - entered)), width: props.width, height: PAD_TOP + props.contentHeight, alpha: entered }, ...props.content),
1779
2306
  props.closeButton,
1780
2307
  ...(_b = (_a = props.footer) == null ? void 0 : _a.call(props, cardHeight)) != null ? _b : []
1781
2308
  );
1782
2309
  }
1783
- function LinkNode(props) {
1784
- const [hovered, setHovered] = React3.useState(false);
1785
- return label({
1786
- x: props.x,
1787
- y: props.y,
1788
- width: textWidth(props.value, 12.5, 500) + 8,
1789
- height: 20,
1790
- text: props.value,
1791
- fontSize: 12.5,
1792
- textColor: hovered ? palette.textBright : palette.textSecondary,
1793
- textAlign: "centered left",
1794
- interceptsMouseClicks: true,
1795
- mouseCursorType: "pointing hand",
1796
- onMouseEnter: () => setHovered(true),
1797
- onMouseExit: () => setHovered(false),
1798
- onClick: props.onClick
1799
- });
1800
- }
1801
2310
  function Badge(props) {
1802
2311
  const [hovered, setHovered] = React3.useState(false);
1803
2312
  const lead = "Licensing secured by";
1804
2313
  const gap = 7;
1805
2314
  const size = props.mark ? 14 : 0;
1806
2315
  const markGap = props.mark ? gap : 0;
1807
- const wordmark = textWidth("moonbase", 12, 500) + 16;
1808
- const start = Math.round((props.width - (textWidth(lead, 11) + gap + size + markGap + wordmark)) / 2);
1809
- const linkX = start + textWidth(lead, 11) + gap;
1810
- return label({ x: props.x, y: props.y, width: props.width, height: 20 }, text(props.theme, lead, 0, 0, linkX - gap, { size: 11, textColor: palette.textMuted, align: "right", height: 20 }), label({
2316
+ const lock = 14;
2317
+ const leadWidth = textWidth(props.theme, lead, 11);
2318
+ const wordmark = textWidth(props.theme, "moonbase", 12, 500, { kerning: 0.06 }) + 4;
2319
+ const start = Math.round((props.width - (lock + gap + leadWidth + gap + size + markGap + wordmark)) / 2);
2320
+ const linkX = start + lock + gap + leadWidth + gap;
2321
+ return label({ x: props.x, y: props.y, width: props.width, height: 20 }, icon(props.theme, "lock", start, 3, lock, palette.textMuted, 1.5), text(props.theme, lead, start + lock + gap, 0, leadWidth + 2, { size: 11, textColor: palette.textMuted, height: 20 }), label({
1811
2322
  x: linkX,
1812
2323
  y: 0,
1813
2324
  width: size + markGap + wordmark,
@@ -1843,6 +2354,7 @@ function MoonbaseActivation(props) {
1843
2354
  const { moonbase, width, height } = props;
1844
2355
  const state = useMoonbaseState(moonbase);
1845
2356
  const ui = useUiState(moonbase);
2357
+ const metrics = useFontMetrics(moonbase.ui);
1846
2358
  const shown = ui.visible ? 1 : 0;
1847
2359
  const [scrim, rise] = useTween([
1848
2360
  { to: shown, duration: 250, ease: EASE_CSS },
@@ -1865,7 +2377,7 @@ function MoonbaseActivation(props) {
1865
2377
  // the front, after the customer bought an add-on in the browser.
1866
2378
  onMouseEnter: () => moonbase.onFocusChanged(true),
1867
2379
  onMouseExit: () => moonbase.onFocusChanged(false)
1868
- }, label({ key: "rise", x: 0, y: Math.round(12 * (1 - rise)), width, height, alpha: rise }, h(PanelView, { moonbase, state, screen: ui.screen, request: ui.request, download: ui.download, width, height })));
2380
+ }, label({ key: "rise", x: 0, y: Math.round(12 * (1 - rise)), width, height, alpha: rise }, h(PanelView, { moonbase, state, screen: ui.screen, request: ui.request, download: ui.download, width, height, metrics })));
1869
2381
  }
1870
2382
 
1871
2383
  // src/index.ts