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