flight-indicators 1.2.3 → 1.2.4

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.cjs CHANGED
@@ -16,39 +16,63 @@ var __copyProps = (to, from, except, desc) => {
16
16
  }
17
17
  return to;
18
18
  };
19
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var __toCommonJS = (mod2) => __copyProps(__defProp({}, "__esModule", { value: true }), mod2);
20
20
 
21
21
  // src/index.ts
22
22
  var index_exports = {};
23
23
  __export(index_exports, {
24
+ AMMETER_SCALE: () => AMMETER_SCALE,
24
25
  AdfIndicator: () => AdfIndicator,
25
26
  Airspeed: () => Airspeed,
26
27
  Altimeter: () => Altimeter,
28
+ AnnunciatorPanel: () => AnnunciatorPanel,
27
29
  AoaIndicator: () => AoaIndicator,
28
30
  AttitudeIndicator: () => AttitudeIndicator,
31
+ DEFAULT_ANNUNCIATORS: () => DEFAULT_ANNUNCIATORS,
29
32
  DEFAULT_BAR_GAUGES: () => DEFAULT_BAR_GAUGES,
30
33
  DEFAULT_MANIFOLD: () => DEFAULT_MANIFOLD,
31
34
  DEFAULT_RPM: () => DEFAULT_RPM,
32
35
  DataPanel: () => DataPanel,
36
+ DigitalClock: () => DigitalClock,
37
+ DualGauge: () => DualGauge,
38
+ EGT_SCALE: () => EGT_SCALE,
39
+ EgtFuelFlowGauge: () => EgtFuelFlowGauge,
33
40
  EngineIndicator: () => EngineIndicator,
41
+ FUEL_FLOW_SCALE: () => FUEL_FLOW_SCALE,
42
+ FUEL_QUANTITY_SCALE: () => FUEL_QUANTITY_SCALE,
34
43
  FlapIndicator: () => FlapIndicator,
35
44
  FuelIndicator: () => FuelIndicator,
45
+ FuelQuantityGauge: () => FuelQuantityGauge,
46
+ HOLD_TIME: () => HOLD_TIME,
36
47
  HeadingIndicator: () => HeadingIndicator,
48
+ HobbsMeter: () => HobbsMeter,
37
49
  HsiIndicator: () => HsiIndicator,
38
50
  IlsIndicator: () => IlsIndicator,
51
+ MANIFOLD_SCALE: () => MANIFOLD_SCALE,
39
52
  MAX_BAR_GAUGES: () => MAX_BAR_GAUGES,
40
53
  MAX_CYLINDERS: () => MAX_CYLINDERS,
41
54
  MAX_FIELDS: () => MAX_FIELDS,
42
55
  MAX_TANKS: () => MAX_TANKS,
56
+ MagneticCompass: () => MagneticCompass,
57
+ ManifoldFuelFlowGauge: () => ManifoldFuelFlowGauge,
58
+ OIL_PRESSURE_SCALE: () => OIL_PRESSURE_SCALE,
59
+ OIL_TEMPERATURE_SCALE: () => OIL_TEMPERATURE_SCALE,
60
+ OilGauge: () => OilGauge,
43
61
  RadioPanel: () => RadioPanel,
44
62
  RadioStack: () => RadioStack,
63
+ Tachometer: () => Tachometer,
64
+ TrimIndicator: () => TrimIndicator,
45
65
  TurnCoordinator: () => TurnCoordinator,
66
+ VACUUM_SCALE: () => VACUUM_SCALE,
67
+ VacuumAmmeterGauge: () => VacuumAmmeterGauge,
46
68
  VerticalSpeed: () => VerticalSpeed,
47
69
  VorIndicator: () => VorIndicator,
48
70
  WindIndicator: () => WindIndicator,
71
+ drumPositions: () => drumPositions,
49
72
  formatAdf: () => formatAdf,
50
73
  formatDme: () => formatDme,
51
74
  formatNav: () => formatNav,
75
+ formatTimer: () => formatTimer,
52
76
  formatValue: () => formatValue,
53
77
  parseAdf: () => parseAdf,
54
78
  parseNav: () => parseNav,
@@ -68,16 +92,16 @@ function polar(r, deg2, cx = CENTER, cy = CENTER) {
68
92
  const a = deg2 * Math.PI / 180;
69
93
  return [round(cx + r * Math.sin(a)), round(cy - r * Math.cos(a))];
70
94
  }
71
- function arcPath(r, startDeg, endDeg) {
72
- const [x1, y1] = polar(r, startDeg);
73
- const [x2, y2] = polar(r, endDeg);
95
+ function arcPath(r, startDeg, endDeg, cx = CENTER, cy = CENTER) {
96
+ const [x1, y1] = polar(r, startDeg, cx, cy);
97
+ const [x2, y2] = polar(r, endDeg, cx, cy);
74
98
  const largeArc = Math.abs(endDeg - startDeg) > 180 ? 1 : 0;
75
99
  const sweep = endDeg >= startDeg ? 1 : 0;
76
100
  return `M ${x1} ${y1} A ${r} ${r} 0 ${largeArc} ${sweep} ${x2} ${y2}`;
77
101
  }
78
- function tickPath(r1, r2, deg2) {
79
- const [x1, y1] = polar(r1, deg2);
80
- const [x2, y2] = polar(r2, deg2);
102
+ function tickPath(r1, r2, deg2, cx = CENTER, cy = CENTER) {
103
+ const [x1, y1] = polar(r1, deg2, cx, cy);
104
+ const [x2, y2] = polar(r2, deg2, cx, cy);
81
105
  return `M ${x1} ${y1} L ${x2} ${y2}`;
82
106
  }
83
107
  function range(start, end, step) {
@@ -168,6 +192,7 @@ function InstrumentFrame({
168
192
  style,
169
193
  title,
170
194
  label: label2,
195
+ role = "img",
171
196
  children
172
197
  }) {
173
198
  const titleId = useSvgId("fi-title");
@@ -179,7 +204,7 @@ function InstrumentFrame({
179
204
  viewBox: "0 0 400 400",
180
205
  width: size,
181
206
  height: size,
182
- role: "img",
207
+ role,
183
208
  "aria-labelledby": titleId,
184
209
  className,
185
210
  style: { display: "inline-block", userSelect: "none", ...style },
@@ -208,6 +233,34 @@ function InstrumentFrame({
208
233
  function Hub({ r = 14 }) {
209
234
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: CENTER, cy: CENTER, r, fill: "#2a2a2a", stroke: "#555", strokeWidth: "2" });
210
235
  }
236
+ function PanelFrame({ size = 200, showBox = true, className, style, title, label: label2, width, height, children }) {
237
+ const titleId = useSvgId("fi-title");
238
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
239
+ "svg",
240
+ {
241
+ xmlns: "http://www.w3.org/2000/svg",
242
+ viewBox: `0 0 ${width} ${height}`,
243
+ width: size,
244
+ height: typeof size === "number" ? Math.round(size * height / width * 100) / 100 : void 0,
245
+ role: "img",
246
+ "aria-labelledby": titleId,
247
+ className,
248
+ style: { display: "inline-block", userSelect: "none", aspectRatio: `${width} / ${height}`, ...style },
249
+ fontFamily: "'Helvetica Neue', Arial, sans-serif",
250
+ children: [
251
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("title", { id: titleId, children: title ?? label2 }),
252
+ showBox && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("g", { children: [
253
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("rect", { x: "2", y: "2", width: width - 4, height: height - 4, rx: "14", fill: "#232323", stroke: "#0d0d0d", strokeWidth: "4" }),
254
+ [22, width - 22].map((x) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("g", { children: [
255
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: x, cy: height / 2, r: "9", fill: "#3a3a3a", stroke: "#111", strokeWidth: "2" }),
256
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: `M ${x - 6} ${height / 2 + 2} L ${x + 6} ${height / 2 - 2}`, stroke: "#111", strokeWidth: "2.5" })
257
+ ] }, x))
258
+ ] }),
259
+ children
260
+ ]
261
+ }
262
+ );
263
+ }
211
264
 
212
265
  // src/components/AttitudeIndicator.tsx
213
266
  var import_jsx_runtime2 = require("react/jsx-runtime");
@@ -2053,36 +2106,909 @@ function AoaIndicator({ aoa = 0, min = 0, optimum, max = 20, showValue = false,
2053
2106
  /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("text", { x: CENTER, y: showValue ? 362 : 345, fill: "#ccc", fontSize: "16", textAnchor: "middle", children: label2.toUpperCase() })
2054
2107
  ] });
2055
2108
  }
2109
+
2110
+ // src/components/DigitalClock.tsx
2111
+ var import_react3 = require("react");
2112
+ var import_jsx_runtime20 = require("react/jsx-runtime");
2113
+ var MIN = 6e4;
2114
+ var HOUR = 60 * MIN;
2115
+ var DAY = 24 * HOUR;
2116
+ var HOLD_TIME = 2e3;
2117
+ var MODES = ["UT", "LT", "FT", "ET"];
2118
+ var UPPER = ["volts", "F", "C"];
2119
+ var pad2 = (n) => String(n).padStart(2, "0");
2120
+ var mod = (n, m) => (n % m + m) % m;
2121
+ var readWatch = (w, t) => w.acc + (w.since === null ? 0 : Math.max(0, t - w.since));
2122
+ var startWatch = (w, t) => w.since === null ? { acc: w.acc, since: t } : w;
2123
+ var stopWatch = (w, t) => w.since === null ? w : { acc: readWatch(w, t), since: null };
2124
+ function timerDigits(ms) {
2125
+ const s = Math.max(0, Math.floor(ms / 1e3));
2126
+ if (s < 3600) return pad2(Math.floor(s / 60)) + pad2(s % 60);
2127
+ return pad2(Math.floor(s / 3600) % 100) + pad2(Math.floor(s / 60) % 60);
2128
+ }
2129
+ function formatTimer(seconds) {
2130
+ const d = timerDigits(finite(seconds) * 1e3);
2131
+ return `${d.slice(0, 2)}:${d.slice(2)}`;
2132
+ }
2133
+ function upperText(display2, oat, volts) {
2134
+ if (display2 === "volts") {
2135
+ if (Number.isNaN(volts)) return ["---", "V"];
2136
+ const v = clamp(volts, 0, 99.9);
2137
+ return [v.toFixed(1).padStart(4, " "), "V"];
2138
+ }
2139
+ if (Number.isNaN(oat)) return ["---", `\xB0${display2}`];
2140
+ const t = display2 === "F" ? oat * 9 / 5 + 32 : oat;
2141
+ return [String(Math.round(clamp(t, -99, 999))).padStart(3, " "), `\xB0${display2}`];
2142
+ }
2143
+ var GLYPHS = {
2144
+ "0": "abcdef",
2145
+ "1": "bc",
2146
+ "2": "abdeg",
2147
+ "3": "abcdg",
2148
+ "4": "bcfg",
2149
+ "5": "acdfg",
2150
+ "6": "acdefg",
2151
+ "7": "abc",
2152
+ "8": "abcdefg",
2153
+ "9": "abcdfg",
2154
+ "-": "g",
2155
+ " ": ""
2156
+ };
2157
+ function segmentPaths(w, h) {
2158
+ const t = w * 0.2;
2159
+ const half = t / 2;
2160
+ const gap = t * 0.2;
2161
+ const pts = (p) => p.map(([x, y]) => `${Math.round(x * 10) / 10},${Math.round(y * 10) / 10}`).join(" ");
2162
+ const hs = (y) => {
2163
+ const x1 = half + gap;
2164
+ const x2 = w - half - gap;
2165
+ return pts([[x1, y], [x1 + half, y - half], [x2 - half, y - half], [x2, y], [x2 - half, y + half], [x1 + half, y + half]]);
2166
+ };
2167
+ const vs = (x, y1, y2) => pts([[x, y1], [x + half, y1 + half], [x + half, y2 - half], [x, y2], [x - half, y2 - half], [x - half, y1 + half]]);
2168
+ return {
2169
+ a: hs(half),
2170
+ g: hs(h / 2),
2171
+ d: hs(h - half),
2172
+ f: vs(half, half + gap, h / 2 - gap),
2173
+ b: vs(w - half, half + gap, h / 2 - gap),
2174
+ e: vs(half, h / 2 + gap, h - half - gap),
2175
+ c: vs(w - half, h / 2 + gap, h - half - gap)
2176
+ };
2177
+ }
2178
+ function Cell({ x, y, w, h, char, dot, on, off, testId }) {
2179
+ const paths = segmentPaths(w, h);
2180
+ const lit = GLYPHS[char] ?? "";
2181
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("g", { transform: `translate(${x + h * 0.05} ${y}) skewX(-5)`, "data-testid": testId, "data-char": char, children: [
2182
+ Object.keys(paths).map((s) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("polygon", { points: paths[s], fill: lit.includes(s) ? on : off }, s)),
2183
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("circle", { cx: w + w * 0.2, cy: h - w * 0.1, r: w * 0.1, fill: dot ? on : off })
2184
+ ] });
2185
+ }
2186
+ function digitMax(target, digits, i) {
2187
+ if (target === "ET") return [5, 9, 5, 9][i] ?? 9;
2188
+ if (target === "FT") return [9, 9, 5, 9][i] ?? 9;
2189
+ if (i === 0) return 2;
2190
+ if (i === 1) return digits[0] === 2 ? 3 : 9;
2191
+ return [5, 9][i - 2] ?? 9;
2192
+ }
2193
+ var lastDigit = (target) => target === "LT" ? 1 : 3;
2194
+ var twoDigits = (d, i) => (d[i] ?? 0) * 10 + (d[i + 1] ?? 0);
2195
+ var LCD = "#9da793";
2196
+ var INK = "#1f241d";
2197
+ var GHOST = "rgba(31,36,29,0.07)";
2198
+ var FACE_TEXT = "#e6e6e6";
2199
+ var BUTTONS = {
2200
+ oatVolts: { cx: CENTER, cy: 56, name: "O.A.T / VOLTS" },
2201
+ select: { cx: 140, cy: 330, name: "SELECT" },
2202
+ control: { cx: 260, cy: 330, name: "CONTROL" }
2203
+ };
2204
+ function DigitalClock({
2205
+ oat,
2206
+ volts,
2207
+ upperDisplay,
2208
+ defaultUpperDisplay = "volts",
2209
+ onUpperDisplayChange,
2210
+ mode,
2211
+ defaultMode = "UT",
2212
+ onModeChange,
2213
+ now,
2214
+ localOffset,
2215
+ defaultLocalOffset,
2216
+ onLocalOffsetChange,
2217
+ onTimeSet,
2218
+ flightTimeRunning = true,
2219
+ defaultFlightTime = 0,
2220
+ defaultFlightTimeAlarm = 0,
2221
+ defaultCountdown = 0,
2222
+ lowVoltage,
2223
+ highVoltage,
2224
+ onAlarm,
2225
+ ...props
2226
+ }) {
2227
+ const lcdId = useSvgId("fi-lcd");
2228
+ const clockNow = now === void 0 ? Date.now() : finite(now instanceof Date ? now.getTime() : now, Date.now());
2229
+ const clockRef = (0, import_react3.useRef)(clockNow);
2230
+ clockRef.current = clockNow;
2231
+ const readClock = () => now === void 0 ? Date.now() : clockRef.current;
2232
+ const [, setTick] = (0, import_react3.useState)(0);
2233
+ (0, import_react3.useEffect)(() => {
2234
+ const id = setInterval(() => setTick((n) => n + 1), 250);
2235
+ return () => clearInterval(id);
2236
+ }, []);
2237
+ const blinkOn = Math.floor(Date.now() / 400) % 2 === 0;
2238
+ const [innerUpper, setInnerUpper] = (0, import_react3.useState)(defaultUpperDisplay);
2239
+ const upper = upperDisplay ?? innerUpper;
2240
+ const changeUpper = (next) => {
2241
+ if (upperDisplay === void 0) setInnerUpper(next);
2242
+ onUpperDisplayChange?.(next);
2243
+ };
2244
+ const [innerMode, setInnerMode] = (0, import_react3.useState)(defaultMode);
2245
+ const current = mode ?? innerMode;
2246
+ const changeMode = (next) => {
2247
+ if (mode === void 0) setInnerMode(next);
2248
+ onModeChange?.(next);
2249
+ };
2250
+ const [correction, setCorrection] = (0, import_react3.useState)(0);
2251
+ const [innerOffset, setInnerOffset] = (0, import_react3.useState)(() => finite(defaultLocalOffset, -(/* @__PURE__ */ new Date()).getTimezoneOffset()));
2252
+ const offset = finite(localOffset, innerOffset);
2253
+ const ut = clockNow + correction;
2254
+ const utDate = new Date(ut);
2255
+ const ltDate = new Date(ut + offset * MIN);
2256
+ const [ft, setFt] = (0, import_react3.useState)(() => ({
2257
+ acc: Math.max(0, finite(defaultFlightTime)) * 1e3,
2258
+ since: flightTimeRunning ? clockNow : null
2259
+ }));
2260
+ (0, import_react3.useEffect)(() => {
2261
+ setFt((w) => flightTimeRunning ? startWatch(w, clockRef.current) : stopWatch(w, clockRef.current));
2262
+ }, [flightTimeRunning]);
2263
+ const [ftAlarm, setFtAlarm] = (0, import_react3.useState)(() => Math.max(0, finite(defaultFlightTimeAlarm)) * 1e3);
2264
+ const ftMs = readWatch(ft, clockNow);
2265
+ const [et, setEt] = (0, import_react3.useState)({ acc: 0, since: null });
2266
+ const [countdown, setCountdown] = (0, import_react3.useState)(() => Math.max(0, finite(defaultCountdown)) * 1e3);
2267
+ const etMs = readWatch(et, clockNow);
2268
+ const countingDown = countdown > 0 && etMs < countdown;
2269
+ const etRunning = et.since !== null;
2270
+ const v = finite(volts, NaN);
2271
+ const system28 = Number.isNaN(v) || v > 18;
2272
+ const low = finite(lowVoltage, system28 ? 24.5 : 12.4);
2273
+ const high = finite(highVoltage, system28 ? 32 : 16);
2274
+ const voltsBad = !Number.isNaN(v) && (v < low || v > high);
2275
+ const [voltsAck, setVoltsAck] = (0, import_react3.useState)(false);
2276
+ const [lowerAlarm, setLowerAlarm] = (0, import_react3.useState)(null);
2277
+ const fired = (0, import_react3.useRef)({ voltage: false, flightTime: false, countdown: false });
2278
+ (0, import_react3.useEffect)(() => {
2279
+ const f = fired.current;
2280
+ if (voltsBad && !f.voltage) {
2281
+ f.voltage = true;
2282
+ onAlarm?.("voltage");
2283
+ } else if (!voltsBad && f.voltage) {
2284
+ f.voltage = false;
2285
+ setVoltsAck(false);
2286
+ }
2287
+ if (countdown > 0 && etMs >= countdown && !f.countdown) {
2288
+ f.countdown = true;
2289
+ setLowerAlarm("countdown");
2290
+ changeMode("ET");
2291
+ onAlarm?.("countdown");
2292
+ }
2293
+ if (ftAlarm > 0 && ftMs >= ftAlarm && !f.flightTime) {
2294
+ f.flightTime = true;
2295
+ setLowerAlarm("flightTime");
2296
+ changeMode("FT");
2297
+ onAlarm?.("flightTime");
2298
+ }
2299
+ });
2300
+ const voltsFlashing = voltsBad && !voltsAck;
2301
+ const alarmActive = voltsFlashing || lowerAlarm !== null;
2302
+ const [editing, setEditing] = (0, import_react3.useState)(null);
2303
+ const [lampTest, setLampTest] = (0, import_react3.useState)(false);
2304
+ const startEditing = () => {
2305
+ const d = (a, b) => [Math.floor(a / 10), a % 10, Math.floor(b / 10), b % 10];
2306
+ let digits;
2307
+ if (current === "UT") digits = d(utDate.getUTCHours(), utDate.getUTCMinutes());
2308
+ else if (current === "LT") digits = d(ltDate.getUTCHours(), ltDate.getUTCMinutes());
2309
+ else if (current === "ET") digits = d(Math.floor(countdown / MIN) % 60, Math.floor(countdown / 1e3) % 60);
2310
+ else digits = d(Math.min(99, Math.floor(ftAlarm / HOUR)), Math.floor(ftAlarm / MIN) % 60);
2311
+ setEditing({ target: current, digits, index: 0 });
2312
+ };
2313
+ const commit = (e) => {
2314
+ const { target, digits } = e;
2315
+ setEditing(null);
2316
+ if (target === "UT") {
2317
+ const wanted = twoDigits(digits, 0) * HOUR + twoDigits(digits, 2) * MIN;
2318
+ const delta = mod(wanted - mod(ut, DAY) + DAY / 2, DAY) - DAY / 2;
2319
+ setCorrection(correction + delta);
2320
+ onTimeSet?.(new Date(ut + delta));
2321
+ } else if (target === "LT") {
2322
+ let next = offset + (twoDigits(digits, 0) - ltDate.getUTCHours()) * 60;
2323
+ while (next > 14 * 60) next -= 24 * 60;
2324
+ while (next < -12 * 60) next += 24 * 60;
2325
+ if (localOffset === void 0) setInnerOffset(next);
2326
+ onLocalOffsetChange?.(next);
2327
+ } else if (target === "ET") {
2328
+ setCountdown((twoDigits(digits, 0) * 60 + twoDigits(digits, 2)) * 1e3);
2329
+ setEt({ acc: 0, since: null });
2330
+ fired.current.countdown = false;
2331
+ } else {
2332
+ setFtAlarm(twoDigits(digits, 0) * HOUR + twoDigits(digits, 2) * MIN);
2333
+ fired.current.flightTime = false;
2334
+ }
2335
+ };
2336
+ const resetEt = () => {
2337
+ setEt({ acc: 0, since: null });
2338
+ fired.current.countdown = false;
2339
+ };
2340
+ const resetFt = () => {
2341
+ setFt({ acc: 0, since: flightTimeRunning ? readClock() : null });
2342
+ fired.current.flightTime = false;
2343
+ };
2344
+ const click = (b) => {
2345
+ if (b === "oatVolts") return changeUpper(UPPER[(UPPER.indexOf(upper) + 1) % UPPER.length]);
2346
+ if (editing) {
2347
+ if (b === "control") {
2348
+ const digits = [...editing.digits];
2349
+ const i = editing.index;
2350
+ const d = digits[i] ?? 0;
2351
+ digits[i] = d >= digitMax(editing.target, digits, i) ? 0 : d + 1;
2352
+ if (i === 0 && editing.target !== "ET" && editing.target !== "FT") digits[1] = Math.min(digits[1] ?? 0, digitMax(editing.target, digits, 1));
2353
+ return setEditing({ ...editing, digits });
2354
+ }
2355
+ if (editing.index >= lastDigit(editing.target)) return commit(editing);
2356
+ return setEditing({ ...editing, index: editing.index + 1 });
2357
+ }
2358
+ if (b === "select") return changeMode(MODES[(MODES.indexOf(current) + 1) % MODES.length]);
2359
+ if (current === "ET") {
2360
+ if (etRunning) setEt(stopWatch(et, readClock()));
2361
+ else if (et.acc > 0) resetEt();
2362
+ else setEt(startWatch(et, readClock()));
2363
+ }
2364
+ };
2365
+ const hold = (b) => {
2366
+ if (b === "oatVolts") {
2367
+ setLampTest(true);
2368
+ return true;
2369
+ }
2370
+ if (b === "select") {
2371
+ if (editing) commit(editing);
2372
+ else startEditing();
2373
+ return true;
2374
+ }
2375
+ if (editing) return false;
2376
+ if (current === "FT") resetFt();
2377
+ else if (current === "ET") resetEt();
2378
+ else return false;
2379
+ return true;
2380
+ };
2381
+ const both = () => editing ? commit(editing) : startEditing();
2382
+ const acknowledge = () => {
2383
+ if (voltsBad) setVoltsAck(true);
2384
+ setLowerAlarm(null);
2385
+ };
2386
+ const actions = (0, import_react3.useRef)({ click, hold, both, acknowledge, alarmActive });
2387
+ actions.current = { click, hold, both, acknowledge, alarmActive };
2388
+ const presses = (0, import_react3.useRef)({
2389
+ oatVolts: { down: false, used: false },
2390
+ select: { down: false, used: false },
2391
+ control: { down: false, used: false }
2392
+ });
2393
+ const [pressed, setPressed] = (0, import_react3.useState)(null);
2394
+ (0, import_react3.useEffect)(() => () => Object.values(presses.current).forEach((p) => clearTimeout(p.timer)), []);
2395
+ const press = (b) => {
2396
+ const p = presses.current[b];
2397
+ if (p.down) return;
2398
+ p.down = true;
2399
+ p.used = false;
2400
+ setPressed(b);
2401
+ const a = actions.current;
2402
+ if (a.alarmActive) {
2403
+ a.acknowledge();
2404
+ p.used = true;
2405
+ return;
2406
+ }
2407
+ const other = b === "select" ? presses.current.control : b === "control" ? presses.current.select : null;
2408
+ if (other?.down) {
2409
+ clearTimeout(other.timer);
2410
+ other.used = true;
2411
+ p.used = true;
2412
+ a.both();
2413
+ return;
2414
+ }
2415
+ p.timer = setTimeout(() => {
2416
+ if (p.down && !p.used) p.used = actions.current.hold(b);
2417
+ }, HOLD_TIME);
2418
+ };
2419
+ const release = (b, cancel = false) => {
2420
+ const p = presses.current[b];
2421
+ if (!p.down) return;
2422
+ p.down = false;
2423
+ clearTimeout(p.timer);
2424
+ setPressed((x) => x === b ? null : x);
2425
+ if (b === "oatVolts") setLampTest(false);
2426
+ if (!p.used && !cancel) actions.current.click(b);
2427
+ };
2428
+ const oatC = finite(oat, NaN);
2429
+ const shownUpper = voltsFlashing ? "volts" : upper;
2430
+ const [upperDigits, unit] = lampTest ? ["88.8", "V"] : upperText(shownUpper, oatC, v);
2431
+ const upperCells = [];
2432
+ for (const ch of upperDigits) {
2433
+ const prev = upperCells[upperCells.length - 1];
2434
+ if (ch === "." && prev) prev.dot = true;
2435
+ else upperCells.push({ char: ch, dot: false });
2436
+ }
2437
+ while (upperCells.length < 3) upperCells.unshift({ char: " ", dot: false });
2438
+ const upperVisible = !voltsFlashing || blinkOn;
2439
+ let lowerDigits;
2440
+ if (lampTest) lowerDigits = "8888";
2441
+ else if (editing) {
2442
+ const d = editing.digits.join("");
2443
+ lowerDigits = editing.target === "LT" ? d.slice(0, 2) + pad2(ltDate.getUTCMinutes()) : d;
2444
+ } else if (current === "UT") lowerDigits = pad2(utDate.getUTCHours()) + pad2(utDate.getUTCMinutes());
2445
+ else if (current === "LT") lowerDigits = pad2(ltDate.getUTCHours()) + pad2(ltDate.getUTCMinutes());
2446
+ else if (current === "FT") lowerDigits = timerDigits(ftMs);
2447
+ else lowerDigits = timerDigits(countingDown ? Math.ceil((countdown - etMs) / 1e3) * 1e3 : countdown > 0 ? etMs - countdown : etMs);
2448
+ const lowerVisible = lowerAlarm === null || blinkOn;
2449
+ const shownMode = editing ? editing.target : current;
2450
+ const upperLabel = upperText(shownUpper, oatC, v);
2451
+ const lowerLabel = `${lowerDigits.slice(0, 2)}:${lowerDigits.slice(2)}`;
2452
+ const state = shownMode === "ET" ? etRunning ? countingDown ? " counting down" : " running" : et.acc > 0 ? " stopped" : "" : shownMode === "FT" && !flightTimeRunning ? " stopped" : "";
2453
+ const label2 = `Clock: ${shownUpper === "volts" ? `${upperLabel[0].trim()} volts` : `OAT ${upperLabel[0].trim()} ${upperLabel[1]}`}${voltsBad ? v < low ? " LOW" : " HIGH" : ""}, ${shownMode} ${lowerLabel}${state}${editing ? " (setting)" : ""}`;
2454
+ const labelPos = { UT: [86, 202], LT: [128, 202], FT: [86, 246], ET: [128, 246] };
2455
+ const DW = 32;
2456
+ const DH = 58;
2457
+ const lowerX = [166, 206, 262, 302];
2458
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(InstrumentFrame, { ...props, role: "group", label: label2, children: [
2459
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("linearGradient", { id: lcdId, x1: "0", y1: "0", x2: "0", y2: "1", children: [
2460
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("stop", { offset: "0", stopColor: "#7f8977" }),
2461
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("stop", { offset: "0.18", stopColor: LCD }),
2462
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("stop", { offset: "1", stopColor: "#a9b29f" })
2463
+ ] }) }),
2464
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("g", { fill: FACE_TEXT, fontSize: "16", fontWeight: "bold", textAnchor: "middle", dominantBaseline: "central", children: [
2465
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("text", { x: "148", y: "80", children: "O.A.T" }),
2466
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("text", { x: "256", y: "80", children: "VOLTS" }),
2467
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("text", { x: "140", y: "294", children: "SELECT" }),
2468
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("text", { x: "260", y: "294", children: "CONTROL" })
2469
+ ] }),
2470
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("rect", { x: "104", y: "94", width: "192", height: "66", rx: "4", fill: "#0b0b0b" }),
2471
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("rect", { x: "108", y: "98", width: "184", height: "58", rx: "2", fill: `url(#${lcdId})` }),
2472
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("g", { "data-testid": "clock-upper", "data-unit": unit, opacity: upperVisible ? 1 : 0, children: [
2473
+ upperCells.map((c, i) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Cell, { x: 132 + i * 36, y: 104, w: 26, h: 46, char: c.char, dot: c.dot, on: INK, off: GHOST, testId: `clock-upper-${i}` }, i)),
2474
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("text", { x: "244", y: "129", fill: INK, fontSize: "34", fontWeight: "bold", dominantBaseline: "central", children: unit })
2475
+ ] }),
2476
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("rect", { x: "56", y: "170", width: "288", height: "104", rx: "4", fill: "#0b0b0b" }),
2477
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("rect", { x: "60", y: "174", width: "280", height: "96", rx: "2", fill: `url(#${lcdId})` }),
2478
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("g", { fill: INK, fontSize: "17", fontWeight: "bold", textAnchor: "middle", dominantBaseline: "central", children: MODES.map((m) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("text", { x: labelPos[m][0], y: labelPos[m][1], children: m }, m)) }),
2479
+ MODES.map((m) => {
2480
+ const [x, y] = labelPos[m];
2481
+ const top = y < 224;
2482
+ const points = top ? `${x - 8},224 ${x + 8},224 ${x},215` : `${x - 8},220 ${x + 8},220 ${x},229`;
2483
+ const active = lampTest || m === shownMode;
2484
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("polygon", { "data-testid": `clock-mode-${m}`, "data-active": active, points, fill: active ? INK : GHOST }, m);
2485
+ }),
2486
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("g", { "data-testid": "clock-lower", opacity: lowerVisible ? 1 : 0, children: [
2487
+ lowerX.map((x, i) => {
2488
+ const blank = editing !== null && i === editing.index && !blinkOn;
2489
+ const ch = blank ? " " : lowerDigits[i] ?? " ";
2490
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Cell, { x, y: 193, w: DW, h: DH, char: ch, on: INK, off: GHOST, testId: `clock-lower-${i}` }, i);
2491
+ }),
2492
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("circle", { cx: "253", cy: "210", r: "4", fill: INK }),
2493
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("circle", { cx: "249", cy: "236", r: "4", fill: INK })
2494
+ ] }),
2495
+ Object.keys(BUTTONS).map((b) => {
2496
+ const { cx, cy, name } = BUTTONS[b];
2497
+ const down = pressed === b;
2498
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
2499
+ "g",
2500
+ {
2501
+ role: "button",
2502
+ tabIndex: 0,
2503
+ "aria-label": name,
2504
+ "data-testid": `clock-button-${b}`,
2505
+ style: { cursor: "pointer", outline: "none", touchAction: "none" },
2506
+ onPointerDown: (e) => {
2507
+ e.preventDefault();
2508
+ press(b);
2509
+ },
2510
+ onPointerUp: () => release(b),
2511
+ onPointerLeave: () => release(b, true),
2512
+ onPointerCancel: () => release(b, true),
2513
+ onKeyDown: (e) => {
2514
+ if (e.key !== "Enter" && e.key !== " ") return;
2515
+ e.preventDefault();
2516
+ if (!e.repeat) press(b);
2517
+ },
2518
+ onKeyUp: (e) => {
2519
+ if (e.key === "Enter" || e.key === " ") release(b);
2520
+ },
2521
+ onBlur: () => release(b, true),
2522
+ children: [
2523
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("circle", { cx, cy, r: "24", fill: "transparent" }),
2524
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("circle", { cx, cy: cy + 2, r: "17", fill: "#000", opacity: "0.6" }),
2525
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("circle", { cx, cy: cy + (down ? 1.5 : 0), r: "15", fill: down ? "#bdbdbd" : "#ececec", stroke: "#8a8a8a", strokeWidth: "1.5" })
2526
+ ]
2527
+ },
2528
+ b
2529
+ );
2530
+ })
2531
+ ] });
2532
+ }
2533
+
2534
+ // src/components/DualGauge.tsx
2535
+ var import_jsx_runtime21 = require("react/jsx-runtime");
2536
+ var GREEN6 = "#2fb54a";
2537
+ var YELLOW4 = "#f2c200";
2538
+ var RED5 = "#e02020";
2539
+ var SWEEP2 = 56;
2540
+ var PIVOT_OFFSET = 130;
2541
+ var R = 118;
2542
+ var pivotX = (side) => CENTER + side * PIVOT_OFFSET;
2543
+ var angleAt = (side, fraction) => side < 0 ? 90 + SWEEP2 - fraction * 2 * SWEEP2 : 270 - SWEEP2 + fraction * 2 * SWEEP2;
2544
+ var round24 = (n) => Math.round(n * 100) / 100;
2545
+ function resolve2(scale) {
2546
+ const min = finite(scale?.min, 0);
2547
+ const rawMax = finite(scale?.max, 100);
2548
+ const max = rawMax > min ? rawMax : min + 1;
2549
+ const value = clamp(finite(scale?.value, min), min, max);
2550
+ return { ...scale, min, max, value };
2551
+ }
2552
+ function Half({ side, scale, duration }) {
2553
+ const px = pivotX(side);
2554
+ const frac = (v) => (clamp(v, scale.min, scale.max) - scale.min) / (scale.max - scale.min);
2555
+ const deg2 = (v) => angleAt(side, frac(v));
2556
+ const band = (b, color, key) => {
2557
+ if (!b) return null;
2558
+ const a = Math.min(deg2(b[0]), deg2(b[1]));
2559
+ const c = Math.max(deg2(b[0]), deg2(b[1]));
2560
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("path", { d: arcPath(R - 5, a, c, px, CENTER), stroke: color, strokeWidth: "10", fill: "none" }, key);
2561
+ };
2562
+ const ticks = Math.max(1, Math.round(finite(scale.ticks, 10)));
2563
+ const marks = (scale.marks ?? [scale.min, scale.max]).map((m) => typeof m === "number" ? { value: m, text: String(m) } : m);
2564
+ const labelX = CENTER + side * 76;
2565
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("g", { "data-testid": `dual-${side < 0 ? "left" : "right"}`, children: [
2566
+ band(scale.green, GREEN6, "green"),
2567
+ band(scale.yellow, YELLOW4, "yellow"),
2568
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("g", { stroke: "#fff", strokeLinecap: "round", children: [
2569
+ Array.from({ length: ticks + 1 }, (_, i) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("path", { d: tickPath(R, R - 10, angleAt(side, i / ticks), px, CENTER), strokeWidth: "2" }, i)),
2570
+ marks.map(({ value }) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("path", { d: tickPath(R, R - 18, deg2(value), px, CENTER), strokeWidth: "3.5" }, value))
2571
+ ] }),
2572
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("g", { stroke: RED5, strokeWidth: "5", children: [scale.low, scale.high].map(
2573
+ (l, i) => typeof l === "number" && Number.isFinite(l) ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("path", { d: tickPath(R + 4, R - 20, deg2(l), px, CENTER) }, i) : null
2574
+ ) }),
2575
+ marks.map(({ value, text }) => {
2576
+ const [x, y] = polar(R - 36, deg2(value), px, CENTER);
2577
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("text", { x, y, fill: "#fff", fontSize: "19", fontWeight: "bold", textAnchor: "middle", dominantBaseline: "central", children: text }, `${value}-${text}`);
2578
+ }),
2579
+ scale.label && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("text", { x: labelX, y: CENTER - 116, fill: "#ddd", fontSize: scale.label.length > 3 ? 15 : 22, fontWeight: "bold", textAnchor: "middle", children: scale.label }),
2580
+ scale.unit && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("text", { x: labelX, y: CENTER + 128, fill: "#bbb", fontSize: "14", textAnchor: "middle", children: scale.unit }),
2581
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("g", { "data-testid": `dual-${side < 0 ? "left" : "right"}-needle`, style: motionStyle(`rotate(${round24(deg2(scale.value))}deg)`, duration, px, CENTER), children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("path", { d: `M ${px - 4} ${CENTER + 14} L ${px - 3} ${CENTER - R + 22} L ${px} ${CENTER - R + 6} L ${px + 3} ${CENTER - R + 22} L ${px + 4} ${CENTER + 14} Z`, fill: "#fff" }) }),
2582
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("circle", { cx: px, cy: CENTER, r: "11", fill: "#2a2a2a", stroke: "#555", strokeWidth: "2" })
2583
+ ] });
2584
+ }
2585
+ var describe = (s, fallback) => `${s.label ?? fallback} ${s.value.toFixed(Math.max(0, Math.floor(finite(s.decimals, 0))))}${s.unit ? ` ${s.unit}` : ""}`;
2586
+ function DualGauge({ left, right, label: label2, sublabel, ...props }) {
2587
+ const duration = props.animationDuration ?? DEFAULT_ANIMATION_MS;
2588
+ const l = resolve2(left);
2589
+ const r = resolve2(right);
2590
+ const title = `${label2 ?? "Gauge"}: ${describe(l, "left")}, ${describe(r, "right")}`;
2591
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(InstrumentFrame, { ...props, label: title, children: [
2592
+ label2 && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("text", { x: CENTER, y: CENTER - 146, fill: "#eee", fontSize: "17", fontWeight: "bold", textAnchor: "middle", letterSpacing: "1", children: label2 }),
2593
+ sublabel && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("text", { x: CENTER, y: CENTER + 158, fill: "#bbb", fontSize: "14", textAnchor: "middle", letterSpacing: "1", children: sublabel }),
2594
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Half, { side: -1, scale: l, duration }),
2595
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Half, { side: 1, scale: r, duration })
2596
+ ] });
2597
+ }
2598
+ var FUEL_QUANTITY_SCALE = { min: 0, max: 44, marks: [0, 10, 20, 30, { value: 44, text: "F" }], ticks: 11, yellow: [0, 5], low: 0, unit: "GAL" };
2599
+ var OIL_TEMPERATURE_SCALE = { label: "OIL TEMP", min: 75, max: 250, marks: [100, 150, 200, 250], ticks: 7, green: [100, 245], high: 245, unit: "\xB0F" };
2600
+ var OIL_PRESSURE_SCALE = { label: "OIL PRESS", min: 0, max: 115, marks: [0, 50, 100], ticks: 23, green: [50, 90], low: 20, high: 115, unit: "PSI" };
2601
+ var VACUUM_SCALE = { label: "VAC", min: 3, max: 7, marks: [3, 5, 7], ticks: 8, green: [4.5, 5.5], unit: "IN HG", decimals: 1 };
2602
+ var AMMETER_SCALE = { label: "AMP", min: -60, max: 60, marks: [{ value: -60, text: "\u2212" }, 0, { value: 60, text: "+" }], ticks: 12, unit: "AMPS" };
2603
+ var EGT_SCALE = { label: "EGT", min: 1250, max: 1650, marks: [], ticks: 8, unit: "\xB0F" };
2604
+ var FUEL_FLOW_SCALE = { label: "FUEL FLOW", min: 0, max: 20, marks: [0, 10, 20], ticks: 10, green: [0, 17], unit: "GAL/HR", decimals: 1 };
2605
+ var MANIFOLD_SCALE = { label: "MAN PRESS", min: 10, max: 35, marks: [10, 20, 30], ticks: 25, green: [15, 23], unit: "IN HG", decimals: 1 };
2606
+ function FuelQuantityGauge({ leftQuantity, rightQuantity, leftScale, rightScale, ...props }) {
2607
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
2608
+ DualGauge,
2609
+ {
2610
+ ...props,
2611
+ label: "FUEL QTY",
2612
+ left: { ...FUEL_QUANTITY_SCALE, label: "L", ...leftScale, value: leftQuantity },
2613
+ right: { ...FUEL_QUANTITY_SCALE, label: "R", ...rightScale, value: rightQuantity }
2614
+ }
2615
+ );
2616
+ }
2617
+ function OilGauge({ temperature, pressure, leftScale, rightScale, ...props }) {
2618
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
2619
+ DualGauge,
2620
+ {
2621
+ ...props,
2622
+ label: "OIL",
2623
+ left: { ...OIL_TEMPERATURE_SCALE, ...leftScale, value: temperature },
2624
+ right: { ...OIL_PRESSURE_SCALE, ...rightScale, value: pressure }
2625
+ }
2626
+ );
2627
+ }
2628
+ function VacuumAmmeterGauge({ vacuum, amps, leftScale, rightScale, ...props }) {
2629
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
2630
+ DualGauge,
2631
+ {
2632
+ ...props,
2633
+ label: "VAC / AMP",
2634
+ left: { ...VACUUM_SCALE, ...leftScale, value: vacuum },
2635
+ right: { ...AMMETER_SCALE, ...rightScale, value: amps }
2636
+ }
2637
+ );
2638
+ }
2639
+ function EgtFuelFlowGauge({ egt, fuelFlow, leftScale, rightScale, ...props }) {
2640
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
2641
+ DualGauge,
2642
+ {
2643
+ ...props,
2644
+ label: "EGT / FF",
2645
+ left: { ...EGT_SCALE, ...leftScale, value: egt },
2646
+ right: { ...FUEL_FLOW_SCALE, ...rightScale, value: fuelFlow }
2647
+ }
2648
+ );
2649
+ }
2650
+ function ManifoldFuelFlowGauge({ manifold, fuelFlow, leftScale, rightScale, ...props }) {
2651
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
2652
+ DualGauge,
2653
+ {
2654
+ ...props,
2655
+ label: "MAP / FF",
2656
+ left: { ...MANIFOLD_SCALE, ...leftScale, value: manifold },
2657
+ right: { ...FUEL_FLOW_SCALE, ...rightScale, value: fuelFlow }
2658
+ }
2659
+ );
2660
+ }
2661
+
2662
+ // src/components/Odometer.tsx
2663
+ var import_jsx_runtime22 = require("react/jsx-runtime");
2664
+ function drumPositions(value, digits) {
2665
+ const n = Math.max(1, Math.floor(digits));
2666
+ const span = 10 ** n;
2667
+ const tenths = (finite(value) * 10 % span + span) % span;
2668
+ return Array.from({ length: n }, (_, i) => {
2669
+ if (i === 0) return Math.round(tenths % 10 * 1e3) / 1e3;
2670
+ const unit = 10 ** i;
2671
+ const digit = Math.floor(tenths / unit) % 10;
2672
+ const below = tenths % unit;
2673
+ const carry = below > unit - 1 ? below - (unit - 1) : 0;
2674
+ return Math.round((digit + carry) * 1e3) / 1e3;
2675
+ });
2676
+ }
2677
+ function Odometer({ value, digits, x, y, digitWidth, height, clipId, testId = "odometer" }) {
2678
+ const positions = drumPositions(value, digits);
2679
+ const n = positions.length;
2680
+ const left = x - n * digitWidth / 2;
2681
+ const top = y - height / 2;
2682
+ const fontSize = height * 0.72;
2683
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("g", { "data-testid": testId, children: [
2684
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("clipPath", { id: clipId, children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("rect", { x: left, y: top, width: n * digitWidth, height }) }) }),
2685
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("rect", { x: left - 4, y: top - 4, width: n * digitWidth + 8, height: height + 8, rx: "3", fill: "#000", stroke: "#555", strokeWidth: "2" }),
2686
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("g", { clipPath: `url(#${clipId})`, children: positions.map((p, k) => {
2687
+ const i = n - 1 - k;
2688
+ const dx = left + i * digitWidth;
2689
+ const tenths = k === 0;
2690
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("g", { children: [
2691
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("rect", { x: dx + 1, y: top, width: digitWidth - 2, height, fill: tenths ? "#eee" : "#151515" }),
2692
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("g", { "data-testid": `${testId}-drum-${k}`, transform: `translate(0 ${Math.round(-p * height * 100) / 100})`, children: Array.from({ length: 11 }, (_, d) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
2693
+ "text",
2694
+ {
2695
+ x: dx + digitWidth / 2,
2696
+ y: top + height / 2 + d * height,
2697
+ fill: tenths ? "#111" : "#f2f2f2",
2698
+ fontSize,
2699
+ fontFamily: "monospace",
2700
+ fontWeight: "bold",
2701
+ textAnchor: "middle",
2702
+ dominantBaseline: "central",
2703
+ children: d % 10
2704
+ },
2705
+ d
2706
+ )) })
2707
+ ] }, k);
2708
+ }) }),
2709
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("rect", { x: left, y: top, width: n * digitWidth, height: height * 0.18, fill: "#000", opacity: "0.35", pointerEvents: "none" }),
2710
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("rect", { x: left, y: top + height * 0.82, width: n * digitWidth, height: height * 0.18, fill: "#000", opacity: "0.35", pointerEvents: "none" })
2711
+ ] });
2712
+ }
2713
+
2714
+ // src/components/Tachometer.tsx
2715
+ var import_jsx_runtime23 = require("react/jsx-runtime");
2716
+ var START = -135;
2717
+ var SWEEP3 = 270;
2718
+ function Tachometer({ rpm = 0, max = 3500, green = [2e3, 2400], redline = 2400, hours, ...props }) {
2719
+ const duration = props.animationDuration ?? DEFAULT_ANIMATION_MS;
2720
+ const clipId = useSvgId("fi-tach");
2721
+ const top = Math.max(500, finite(max, 3500));
2722
+ const value = clamp(finite(rpm), 0, top);
2723
+ const angle = (v) => START + clamp(v, 0, top) / top * SWEEP3;
2724
+ const showHours = typeof hours === "number" && Number.isFinite(hours);
2725
+ const engineHours = showHours ? Math.max(0, hours) : 0;
2726
+ return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(InstrumentFrame, { ...props, label: `Tachometer: ${Math.round(value)} RPM${showHours ? `, ${engineHours.toFixed(1)} hours` : ""}`, children: [
2727
+ green && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("path", { d: arcPath(166, angle(green[0]), angle(green[1])), stroke: "#2fb54a", strokeWidth: "12", fill: "none" }),
2728
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("g", { stroke: "#fff", strokeLinecap: "round", children: range(0, top, 100).map((v) => {
2729
+ const major = v % 500 === 0;
2730
+ return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("path", { d: tickPath(178, major ? 148 : 162, angle(v)), strokeWidth: major ? 3.5 : 2 }, v);
2731
+ }) }),
2732
+ typeof redline === "number" && Number.isFinite(redline) && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("path", { d: tickPath(180, 146, angle(redline)), stroke: "#e02020", strokeWidth: "6" }),
2733
+ range(0, top, 500).map((v) => {
2734
+ const [x, y] = polar(122, angle(v));
2735
+ return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("text", { x, y, fill: "#fff", fontSize: "26", fontWeight: "bold", textAnchor: "middle", dominantBaseline: "central", children: v / 100 }, v);
2736
+ }),
2737
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("text", { x: CENTER, y: CENTER - 50, fill: "#ddd", fontSize: "20", fontWeight: "bold", textAnchor: "middle", children: "RPM" }),
2738
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("text", { x: CENTER, y: CENTER - 28, fill: "#bbb", fontSize: "13", textAnchor: "middle", children: "\xD7 100" }),
2739
+ showHours && /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(import_jsx_runtime23.Fragment, { children: [
2740
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Odometer, { value: engineHours, digits: 6, x: CENTER, y: CENTER + 70, digitWidth: 20, height: 28, clipId, testId: "tach-hours" }),
2741
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("text", { x: CENTER, y: CENTER + 103, fill: "#bbb", fontSize: "11", textAnchor: "middle", letterSpacing: "2", children: "HOURS" })
2742
+ ] }),
2743
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("g", { "data-testid": "tach-needle", style: motionStyle(`rotate(${Math.round(angle(value) * 100) / 100}deg)`, duration), children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("path", { d: `M ${CENTER - 5} ${CENTER + 30} L ${CENTER - 4} ${CENTER - 140} L ${CENTER} ${CENTER - 165} L ${CENTER + 4} ${CENTER - 140} L ${CENTER + 5} ${CENTER + 30} Z`, fill: "#fff" }) }),
2744
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Hub, {})
2745
+ ] });
2746
+ }
2747
+
2748
+ // src/components/MagneticCompass.tsx
2749
+ var import_jsx_runtime24 = require("react/jsx-runtime");
2750
+ var CARDINALS7 = { 0: "N", 90: "E", 180: "S", 270: "W" };
2751
+ var PPD = 4;
2752
+ var WINDOW_W = 284;
2753
+ var WINDOW_H = 120;
2754
+ var WINDOW_Y = CENTER - 70;
2755
+ var SPAN = 90;
2756
+ var norm6 = (deg2) => (deg2 % 360 + 360) % 360;
2757
+ var cardLabel = (deg2) => CARDINALS7[Math.round(norm6(deg2)) % 360] ?? String(Math.round(norm6(deg2)));
2758
+ var pad33 = (deg2) => String(Math.round(norm6(deg2)) % 360 || 360).padStart(3, "0");
2759
+ function MagneticCompass({ heading = 0, deviationCard, ...props }) {
2760
+ const duration = props.animationDuration ?? DEFAULT_ANIMATION_MS;
2761
+ const hdg = finite(heading);
2762
+ const display2 = useContinuousAngle(hdg);
2763
+ const base = Math.round(display2 / 5) * 5;
2764
+ const cardX = (d) => CENTER - d * PPD;
2765
+ const left = CENTER - WINDOW_W / 2;
2766
+ const clipId = useSvgId("fi-compass-window");
2767
+ const shadeId = useSvgId("fi-compass-shade");
2768
+ const rows = (deviationCard ?? []).slice(0, 6);
2769
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(InstrumentFrame, { ...props, label: `Magnetic compass: ${pad33(hdg)}\xB0`, children: [
2770
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("defs", { children: [
2771
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("clipPath", { id: clipId, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("rect", { x: left, y: WINDOW_Y, width: WINDOW_W, height: WINDOW_H, rx: "16" }) }),
2772
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("linearGradient", { id: shadeId, x1: "0", y1: "0", x2: "1", y2: "0", children: [
2773
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("stop", { offset: "0", stopColor: "#000", stopOpacity: "0.85" }),
2774
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("stop", { offset: "0.22", stopColor: "#000", stopOpacity: "0" }),
2775
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("stop", { offset: "0.78", stopColor: "#000", stopOpacity: "0" }),
2776
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("stop", { offset: "1", stopColor: "#000", stopOpacity: "0.85" })
2777
+ ] })
2778
+ ] }),
2779
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("rect", { x: left - 6, y: WINDOW_Y - 6, width: WINDOW_W + 12, height: WINDOW_H + 12, rx: "20", fill: "#000", stroke: "#444", strokeWidth: "3" }),
2780
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("g", { clipPath: `url(#${clipId})`, children: [
2781
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("rect", { x: left, y: WINDOW_Y, width: WINDOW_W, height: WINDOW_H, fill: "#16181a" }),
2782
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("g", { "data-testid": "compass-card", style: motionStyle(`translate(${Math.round(display2 * PPD * 100) / 100}px, 0px)`, duration), children: range(base - SPAN, base + SPAN, 5).map((d) => {
2783
+ const x = cardX(d);
2784
+ const n = norm6(d);
2785
+ const label2 = n % 30 === 0 ? CARDINALS7[n] ?? String(n / 10) : null;
2786
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("g", { children: [
2787
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("path", { d: `M ${x} ${WINDOW_Y + 4} v ${n % 10 === 0 ? 26 : 16}`, stroke: "#eee", strokeWidth: n % 10 === 0 ? 3 : 2 }),
2788
+ label2 && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("text", { x, y: WINDOW_Y + 66, fill: CARDINALS7[n] ? "#fff" : "#e8e8e8", fontSize: CARDINALS7[n] ? 40 : 34, fontWeight: "bold", textAnchor: "middle", dominantBaseline: "central", children: label2 })
2789
+ ] }, d);
2790
+ }) }),
2791
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("rect", { x: left, y: WINDOW_Y, width: WINDOW_W, height: WINDOW_H, fill: `url(#${shadeId})`, pointerEvents: "none" })
2792
+ ] }),
2793
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("path", { d: `M ${CENTER} ${WINDOW_Y - 4} V ${WINDOW_Y + WINDOW_H + 4}`, stroke: "#ff5a2a", strokeWidth: "3" }),
2794
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("text", { x: CENTER, y: WINDOW_Y - 24, fill: "#ccc", fontSize: "16", textAnchor: "middle", letterSpacing: "3", children: "COMPASS" }),
2795
+ rows.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("g", { "data-testid": "compass-deviation-card", fontSize: "13", fill: "#222", textAnchor: "middle", dominantBaseline: "central", children: [
2796
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("rect", { x: CENTER - 136, y: CENTER + 70, width: "272", height: "64", rx: "4", fill: "#ececec" }),
2797
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("text", { x: CENTER - 110, y: CENTER + 86, fontWeight: "bold", children: "FOR" }),
2798
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("text", { x: CENTER - 110, y: CENTER + 116, fontWeight: "bold", children: "STEER" }),
2799
+ rows.map((r, i) => {
2800
+ const x = CENTER - 56 + i * (166 / Math.max(1, rows.length - 1));
2801
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("g", { children: [
2802
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("text", { x, y: CENTER + 86, children: cardLabel(finite(r.for)) }),
2803
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("text", { x, y: CENTER + 116, children: Math.round(norm6(finite(r.steer))) })
2804
+ ] }, i);
2805
+ })
2806
+ ] })
2807
+ ] });
2808
+ }
2809
+
2810
+ // src/components/TrimIndicator.tsx
2811
+ var import_jsx_runtime25 = require("react/jsx-runtime");
2812
+ var SLOT_X = 248;
2813
+ var TOP2 = 74;
2814
+ var BOTTOM2 = 326;
2815
+ var MID = (TOP2 + BOTTOM2) / 2;
2816
+ var HALF2 = (BOTTOM2 - TOP2) / 2;
2817
+ var WHEEL_X = 150;
2818
+ var WHEEL_W = 56;
2819
+ var WHEEL_TRAVEL = 140;
2820
+ var RIB = 14;
2821
+ var round25 = (n) => Math.round(n * 100) / 100;
2822
+ function TrimIndicator({ trim = 0, takeoff = [0.05, 0.35], ...props }) {
2823
+ const duration = props.animationDuration ?? DEFAULT_ANIMATION_MS;
2824
+ const clipId = useSvgId("fi-trim-wheel");
2825
+ const value = clamp(finite(trim), -1, 1);
2826
+ const yAt = (t) => round25(MID + clamp(t, -1, 1) * HALF2);
2827
+ const inTakeoff = takeoff ? value >= Math.min(...takeoff) && value <= Math.max(...takeoff) : false;
2828
+ const percent = Math.round(Math.abs(value) * 100);
2829
+ const describe2 = percent === 0 ? "neutral" : `${percent}% nose ${value > 0 ? "up" : "down"}`;
2830
+ const ribCount = Math.ceil((BOTTOM2 - TOP2 + 2 * WHEEL_TRAVEL) / RIB) + 1;
2831
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(InstrumentFrame, { ...props, label: `Elevator trim: ${describe2}${inTakeoff ? ", take-off range" : ""}`, children: [
2832
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("clipPath", { id: clipId, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("rect", { x: WHEEL_X - WHEEL_W / 2, y: TOP2, width: WHEEL_W, height: BOTTOM2 - TOP2, rx: "10" }) }) }),
2833
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("rect", { x: WHEEL_X - WHEEL_W / 2 - 6, y: TOP2 - 6, width: WHEEL_W + 12, height: BOTTOM2 - TOP2 + 12, rx: "14", fill: "#000", stroke: "#333", strokeWidth: "2" }),
2834
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("g", { clipPath: `url(#${clipId})`, children: [
2835
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("rect", { x: WHEEL_X - WHEEL_W / 2, y: TOP2, width: WHEEL_W, height: BOTTOM2 - TOP2, fill: "#2c2c2c" }),
2836
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("g", { "data-testid": "trim-wheel", style: motionStyle(`translate(0px, ${round25(value * WHEEL_TRAVEL)}px)`, duration), children: Array.from({ length: ribCount }, (_, i) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("rect", { x: WHEEL_X - WHEEL_W / 2, y: TOP2 - WHEEL_TRAVEL + i * RIB, width: WHEEL_W, height: RIB / 2, fill: "#121212" }, i)) }),
2837
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("rect", { x: WHEEL_X - WHEEL_W / 2, y: TOP2, width: WHEEL_W, height: "40", fill: "#000", opacity: "0.5" }),
2838
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("rect", { x: WHEEL_X - WHEEL_W / 2, y: BOTTOM2 - 40, width: WHEEL_W, height: "40", fill: "#000", opacity: "0.5" })
2839
+ ] }),
2840
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("rect", { x: SLOT_X - 7, y: TOP2, width: "14", height: BOTTOM2 - TOP2, rx: "7", fill: "#000", stroke: "#444", strokeWidth: "2" }),
2841
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("g", { stroke: "#ddd", strokeWidth: "2", children: Array.from({ length: 11 }, (_, i) => {
2842
+ const y = TOP2 + i * (BOTTOM2 - TOP2) / 10;
2843
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("path", { d: `M ${SLOT_X + 12} ${y} h ${i === 5 ? 20 : 12}` }, i);
2844
+ }) }),
2845
+ takeoff && /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("g", { "data-testid": "trim-takeoff", children: [
2846
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("rect", { x: SLOT_X - 20, y: yAt(Math.min(...takeoff)), width: "8", height: Math.max(2, yAt(Math.max(...takeoff)) - yAt(Math.min(...takeoff))), fill: "#fff" }),
2847
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
2848
+ "text",
2849
+ {
2850
+ x: SLOT_X - 30,
2851
+ y: (yAt(takeoff[0]) + yAt(takeoff[1])) / 2,
2852
+ fill: "#fff",
2853
+ fontSize: "12",
2854
+ fontWeight: "bold",
2855
+ textAnchor: "end",
2856
+ dominantBaseline: "central",
2857
+ children: "TAKE OFF"
2858
+ }
2859
+ )
2860
+ ] }),
2861
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("g", { "data-testid": "trim-pointer", style: motionStyle(`translate(0px, ${round25(value * HALF2)}px)`, duration), children: [
2862
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("path", { d: `M ${SLOT_X + 8} ${MID} l 26 -11 v 22 z`, fill: "#fff", stroke: "#000", strokeWidth: "1.5" }),
2863
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("rect", { x: SLOT_X - 5, y: MID - 4, width: "10", height: "8", rx: "2", fill: "#fff" })
2864
+ ] }),
2865
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("g", { fill: "#ddd", fontSize: "15", fontWeight: "bold", textAnchor: "middle", children: [
2866
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("text", { x: CENTER + 92, y: TOP2 - 14, children: "NOSE" }),
2867
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("text", { x: CENTER + 92, y: TOP2 + 2, children: "DOWN" }),
2868
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("text", { x: CENTER + 92, y: BOTTOM2 + 8, children: "NOSE" }),
2869
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("text", { x: CENTER + 92, y: BOTTOM2 + 24, children: "UP" })
2870
+ ] }),
2871
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("text", { x: WHEEL_X, y: BOTTOM2 + 32, fill: "#ccc", fontSize: "14", textAnchor: "middle", letterSpacing: "2", children: "TRIM" })
2872
+ ] });
2873
+ }
2874
+
2875
+ // src/components/HobbsMeter.tsx
2876
+ var import_jsx_runtime26 = require("react/jsx-runtime");
2877
+ var W = 400;
2878
+ var H = 170;
2879
+ function HobbsMeter({ hours = 0, digits = 6, running = false, label: label2 = "HOURS", ...props }) {
2880
+ const clipId = useSvgId("fi-hobbs");
2881
+ const value = Math.max(0, finite(hours));
2882
+ const n = Math.min(8, Math.max(2, Math.floor(finite(digits, 6))));
2883
+ const digitW = Math.min(40, 260 / n);
2884
+ const counterRight = W / 2 + 10 + n * digitW / 2;
2885
+ return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(PanelFrame, { ...props, width: W, height: H, label: `${label2}: ${value.toFixed(1)}${running ? ", running" : ""}`, children: [
2886
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("rect", { x: "44", y: "18", width: W - 88, height: H - 36, rx: "10", fill: "#111", stroke: "#000", strokeWidth: "3" }),
2887
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("text", { x: W / 2 + 10, y: "44", fill: "#ddd", fontSize: "15", fontWeight: "bold", textAnchor: "middle", letterSpacing: "3", children: label2 }),
2888
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Odometer, { value, digits: n, x: W / 2 + 10, y: 92, digitWidth: digitW, height: 52, clipId, testId: "hobbs" }),
2889
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("text", { x: counterRight - digitW / 2, y: "136", fill: "#999", fontSize: "11", textAnchor: "middle", children: "1/10" }),
2890
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("g", { "data-testid": "hobbs-running", "data-running": running ? "true" : "false", children: [
2891
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("circle", { cx: "66", cy: "92", r: "13", fill: "#000", stroke: "#555", strokeWidth: "2" }),
2892
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("g", { children: [
2893
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("path", { d: "M 66 92 L 66 80 A 12 12 0 0 1 76.4 86 Z", fill: running ? "#eee" : "#666" }),
2894
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("path", { d: "M 66 92 L 66 104 A 12 12 0 0 1 55.6 98 Z", fill: running ? "#eee" : "#666" }),
2895
+ running && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("animateTransform", { attributeName: "transform", type: "rotate", from: "0 66 92", to: "360 66 92", dur: "2s", repeatCount: "indefinite" })
2896
+ ] })
2897
+ ] })
2898
+ ] });
2899
+ }
2900
+
2901
+ // src/components/AnnunciatorPanel.tsx
2902
+ var import_jsx_runtime27 = require("react/jsx-runtime");
2903
+ var DEFAULT_ANNUNCIATORS = [
2904
+ { id: "fuel", label: "FUEL", level: "caution", split: true },
2905
+ { id: "oil", label: "OIL PRESS", level: "warning" },
2906
+ { id: "trim", label: "PITCH TRIM", level: "warning" },
2907
+ { id: "vac", label: "VAC", level: "caution", split: true },
2908
+ { id: "volts", label: "VOLTS", level: "warning" }
2909
+ ];
2910
+ var COLORS = { warning: "#ff2a2a", caution: "#ffb000", advisory: "#3ddc3d" };
2911
+ var OFF = "#3a3a3a";
2912
+ var W2 = 400;
2913
+ var PAD_X = 44;
2914
+ function litParts(state, split, test) {
2915
+ if (test) return { left: true, right: true, main: true };
2916
+ if (!split) return { left: false, right: false, main: !!state };
2917
+ const left = state === true || state === "left" || state === "both";
2918
+ const right = state === true || state === "right" || state === "both";
2919
+ return { left, right, main: left || right };
2920
+ }
2921
+ function AnnunciatorPanel({ annunciators = DEFAULT_ANNUNCIATORS, lights = {}, test = false, ...props }) {
2922
+ const items = annunciators.slice(0, 12);
2923
+ const rows = items.length > 3 ? 2 : 1;
2924
+ const cols = Math.max(1, Math.ceil(items.length / rows));
2925
+ const rowH = 34;
2926
+ const H2 = 28 + rows * rowH;
2927
+ const cellW = (W2 - 2 * PAD_X) / cols;
2928
+ const on = [];
2929
+ items.forEach((a) => {
2930
+ const p = litParts(lights[a.id], !!a.split, test);
2931
+ if (!p.main) return;
2932
+ if (a.split && !(p.left && p.right)) on.push(`${p.left ? "L" : "R"} ${a.label}`);
2933
+ else on.push(a.split ? `L ${a.label} R` : a.label);
2934
+ });
2935
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(PanelFrame, { ...props, width: W2, height: H2, label: `Annunciator: ${on.length ? on.join(", ") : "all clear"}`, children: [
2936
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("rect", { x: PAD_X - 6, y: "10", width: W2 - 2 * PAD_X + 12, height: H2 - 20, rx: "4", fill: "#0b0b0b", stroke: "#000", strokeWidth: "2" }),
2937
+ items.map((a, i) => {
2938
+ const row = Math.floor(i / cols);
2939
+ const col = i % cols;
2940
+ const cx = PAD_X + col * cellW + cellW / 2;
2941
+ const cy = 14 + row * rowH + rowH / 2;
2942
+ const color = COLORS[a.level ?? "caution"];
2943
+ const p = litParts(lights[a.id], !!a.split, test);
2944
+ const fill = (lit) => lit ? color : OFF;
2945
+ const glow = (lit) => lit ? { filter: `drop-shadow(0 0 3px ${color})` } : void 0;
2946
+ const fontSize = Math.min(15, (cellW - 10) / Math.max(4, (a.label.length + (a.split ? 4 : 0)) * 0.62));
2947
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("g", { "data-testid": `annunciator-${a.id}`, "data-lit": p.main ? "true" : "false", fontWeight: "bold", fontSize, dominantBaseline: "central", children: [
2948
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("rect", { x: cx - cellW / 2 + 3, y: cy - rowH / 2 + 3, width: cellW - 6, height: rowH - 6, rx: "2", fill: "#141414" }),
2949
+ a.split ? /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("text", { x: cx, y: cy, textAnchor: "middle", children: [
2950
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("tspan", { "data-testid": `annunciator-${a.id}-left`, fill: fill(p.left), style: glow(p.left), children: "L" }),
2951
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("tspan", { fill: fill(p.main), style: glow(p.main), children: ` ${a.label} ` }),
2952
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("tspan", { "data-testid": `annunciator-${a.id}-right`, fill: fill(p.right), style: glow(p.right), children: "R" })
2953
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("text", { x: cx, y: cy, textAnchor: "middle", fill: fill(p.main), style: glow(p.main), children: a.label })
2954
+ ] }, a.id);
2955
+ })
2956
+ ] });
2957
+ }
2056
2958
  // Annotate the CommonJS export names for ESM import in node:
2057
2959
  0 && (module.exports = {
2960
+ AMMETER_SCALE,
2058
2961
  AdfIndicator,
2059
2962
  Airspeed,
2060
2963
  Altimeter,
2964
+ AnnunciatorPanel,
2061
2965
  AoaIndicator,
2062
2966
  AttitudeIndicator,
2967
+ DEFAULT_ANNUNCIATORS,
2063
2968
  DEFAULT_BAR_GAUGES,
2064
2969
  DEFAULT_MANIFOLD,
2065
2970
  DEFAULT_RPM,
2066
2971
  DataPanel,
2972
+ DigitalClock,
2973
+ DualGauge,
2974
+ EGT_SCALE,
2975
+ EgtFuelFlowGauge,
2067
2976
  EngineIndicator,
2977
+ FUEL_FLOW_SCALE,
2978
+ FUEL_QUANTITY_SCALE,
2068
2979
  FlapIndicator,
2069
2980
  FuelIndicator,
2981
+ FuelQuantityGauge,
2982
+ HOLD_TIME,
2070
2983
  HeadingIndicator,
2984
+ HobbsMeter,
2071
2985
  HsiIndicator,
2072
2986
  IlsIndicator,
2987
+ MANIFOLD_SCALE,
2073
2988
  MAX_BAR_GAUGES,
2074
2989
  MAX_CYLINDERS,
2075
2990
  MAX_FIELDS,
2076
2991
  MAX_TANKS,
2992
+ MagneticCompass,
2993
+ ManifoldFuelFlowGauge,
2994
+ OIL_PRESSURE_SCALE,
2995
+ OIL_TEMPERATURE_SCALE,
2996
+ OilGauge,
2077
2997
  RadioPanel,
2078
2998
  RadioStack,
2999
+ Tachometer,
3000
+ TrimIndicator,
2079
3001
  TurnCoordinator,
3002
+ VACUUM_SCALE,
3003
+ VacuumAmmeterGauge,
2080
3004
  VerticalSpeed,
2081
3005
  VorIndicator,
2082
3006
  WindIndicator,
3007
+ drumPositions,
2083
3008
  formatAdf,
2084
3009
  formatDme,
2085
3010
  formatNav,
3011
+ formatTimer,
2086
3012
  formatValue,
2087
3013
  parseAdf,
2088
3014
  parseNav,