a429-flight-display
Version:
React components for ARINC 429 Flight Display with primary flight instruments
1,172 lines (1,171 loc) • 49.6 kB
JavaScript
var Q = Object.defineProperty;
var D = (e, t, o) => t in e ? Q(e, t, { enumerable: !0, configurable: !0, writable: !0, value: o }) : e[t] = o;
var w = (e, t, o) => D(e, typeof t != "symbol" ? t + "" : t, o);
import { jsxs as s, jsx as r, Fragment as K } from "react/jsx-runtime";
import { useState as P, useRef as j, useEffect as H } from "react";
let R = class {
constructor(t, o, l, a) {
w(this, "label");
w(this, "sdi");
w(this, "data");
w(this, "ssm");
w(this, "parity");
this.label = t, this.sdi = o, this.data = l, this.ssm = a, this.parity = this.calculateParity();
}
calculateParity() {
const t = this.label << 24 | this.sdi << 22 | this.data << 3 | this.ssm << 1;
let o = 0;
for (let l = 0; l < 31; l++)
t & 1 << l && o++;
return o % 2 === 0 ? 1 : 0;
}
};
const _ = {
ALTITUDE: 131,
AIRSPEED: 134,
MACH: 135,
HEADING: 146,
VERTICAL_SPEED: 245,
PITCH: 212,
ROLL: 213,
TEMPERATURE: 137
}, C = {
NORMAL_OPERATION: 3
};
function S(e, t = 1, o, l = 0) {
const a = Math.round(e * t) & 524287;
return new R(o, l, a, C.NORMAL_OPERATION);
}
const ee = ({ flightData: e }) => {
const t = () => [
new R(_.ALTITUDE, 0, Math.round(e.altitude), C.NORMAL_OPERATION),
new R(_.AIRSPEED, 0, Math.round(e.airspeed), C.NORMAL_OPERATION),
new R(_.MACH, 0, Math.round(e.mach * 1e5), C.NORMAL_OPERATION),
new R(_.HEADING, 0, Math.round(e.true_heading), C.NORMAL_OPERATION),
new R(_.VERTICAL_SPEED, 0, Math.round(e.vertical_speed), C.NORMAL_OPERATION),
new R(_.PITCH, 0, Math.round(e.pitch_angle * 100), C.NORMAL_OPERATION),
new R(_.ROLL, 0, Math.round(e.roll_angle * 100), C.NORMAL_OPERATION)
];
return /* @__PURE__ */ s("div", { className: "bg-gray-900 rounded-xl p-6 shadow-2xl", children: [
/* @__PURE__ */ s("div", { className: "flex justify-between items-center mb-4", children: [
/* @__PURE__ */ r("h2", { className: "text-xl font-bold text-white", children: "Live ARINC 429 Data Bus" }),
/* @__PURE__ */ r("div", { className: "text-green-400 font-mono text-sm", children: e.timestamp.toLocaleTimeString() })
] }),
/* @__PURE__ */ r("div", { className: "grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4", children: t().map((o, l) => {
const a = Object.keys(_).find(
(n) => _[n] === o.label
), i = "0x" + (o.label << 24 | o.sdi << 22 | o.data << 3 | o.ssm << 1 | o.parity).toString(16).toUpperCase().padStart(8, "0");
return /* @__PURE__ */ s("div", { className: "bg-gray-800 rounded-lg p-4 border border-gray-600", children: [
/* @__PURE__ */ r("div", { className: "text-yellow-400 font-semibold text-sm mb-2", children: a }),
/* @__PURE__ */ s("div", { className: "text-white font-mono text-xs space-y-1", children: [
/* @__PURE__ */ s("div", { children: [
"Label: ",
o.label.toString(8).padStart(3, "0")
] }),
/* @__PURE__ */ s("div", { children: [
"Data: ",
o.data
] }),
/* @__PURE__ */ s("div", { children: [
"Hex: ",
i
] })
] }),
/* @__PURE__ */ r("div", { className: "text-green-400 text-xs mt-2", children: "● NORMAL" })
] }, l);
}) }),
/* @__PURE__ */ r("div", { className: "mt-6 text-center", children: /* @__PURE__ */ s("div", { className: "inline-flex items-center space-x-4 bg-gray-800 px-6 py-3 rounded-lg", children: [
/* @__PURE__ */ r("div", { className: "w-3 h-3 bg-green-400 rounded-full animate-pulse" }),
/* @__PURE__ */ r("span", { className: "text-white font-semibold", children: "ARINC 429 Bus Active" }),
/* @__PURE__ */ r("span", { className: "text-gray-400 font-mono text-sm", children: "12.5 kHz" })
] }) })
] });
}, te = ({ pitch: e, roll: t }) => {
const l = () => {
const i = [];
for (let n = -30; n <= 30; n += 5) {
if (n === 0) continue;
const d = n % 10 === 0;
i.push(
/* @__PURE__ */ r("div", { className: "absolute flex items-center justify-center w-full", children: /* @__PURE__ */ s(
"div",
{
className: "flex items-center justify-center",
style: {
transform: `translateY(${-n * 3}px)`
},
children: [
/* @__PURE__ */ r(
"div",
{
className: `bg-white ${d ? "h-0.5 w-16" : "h-0.5 w-8"}`
}
),
d && /* @__PURE__ */ s(K, { children: [
/* @__PURE__ */ r("span", { className: "text-white text-xs font-mono ml-2 select-none", children: Math.abs(n) }),
/* @__PURE__ */ r("div", { className: "bg-white h-0.5 w-16 ml-2" }),
/* @__PURE__ */ r("span", { className: "text-white text-xs font-mono ml-2 select-none", children: Math.abs(n) })
] })
]
}
) }, n)
);
}
return i;
}, a = () => {
const i = [];
return [-60, -45, -30, -20, -10, 0, 10, 20, 30, 45, 60].forEach((d) => {
const c = [0, -30, 30, -60, 60].includes(d), m = [-10, -20, 10, 20, -45, 45].includes(d);
i.push(
/* @__PURE__ */ s(
"div",
{
className: "absolute top-1 left-1/2 origin-bottom transform -translate-x-1/2",
style: {
transform: `translateX(-50%) rotate(${d}deg)`,
transformOrigin: "center 92px"
},
children: [
/* @__PURE__ */ r(
"div",
{
className: `bg-white ${c ? "w-0.5 h-4" : m ? "w-0.5 h-3" : "w-0.5 h-2"}`
}
),
(d === -30 || d === 30 || d === -60 || d === 60) && /* @__PURE__ */ r("div", { className: "text-white text-xs font-mono text-center mt-1 select-none", children: Math.abs(d) })
]
},
d
)
);
}), i;
};
return /* @__PURE__ */ s("div", { className: "relative w-48 h-48 rounded-full overflow-hidden border-4 border-gray-600 shadow-2xl bg-gray-900", children: [
/* @__PURE__ */ s(
"div",
{
className: "absolute inset-0 bg-gradient-to-b from-sky-400 via-sky-300 to-amber-500",
style: {
transform: `rotate(${t}deg) translateY(${e * 3}px)`,
transformOrigin: "center center",
width: "200%",
height: "200%",
left: "-50%",
top: "-50%"
},
children: [
/* @__PURE__ */ r(
"div",
{
className: "absolute left-0 right-0 h-1 bg-white",
style: { top: "50%", transform: "translateY(-50%)" }
}
),
/* @__PURE__ */ r(
"div",
{
className: "absolute inset-0 flex justify-center items-center",
style: { top: "50%", left: "50%", transform: "translate(-50%, -50%)" },
children: l()
}
)
]
}
),
/* @__PURE__ */ r("div", { className: "absolute inset-0", children: a() }),
/* @__PURE__ */ r(
"div",
{
className: "absolute top-1 left-1/2 w-0 h-0 border-l-3 border-r-3 border-b-6 border-transparent border-b-yellow-400 transform -translate-x-1/2 z-20",
style: {
transform: `translateX(-50%) rotate(${t}deg)`,
transformOrigin: "center 92px"
}
}
),
/* @__PURE__ */ r("div", { className: "absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 z-30", children: /* @__PURE__ */ s("div", { className: "relative flex items-center justify-center", children: [
/* @__PURE__ */ r("div", { className: "w-12 h-1 bg-yellow-400" }),
/* @__PURE__ */ r("div", { className: "absolute w-1 h-6 bg-yellow-400" }),
/* @__PURE__ */ r("div", { className: "absolute w-2 h-2 bg-yellow-400 rounded-full" })
] }) }),
/* @__PURE__ */ r("div", { className: "absolute top-2 left-1/2 w-0 h-0 border-l-2 border-r-2 border-b-4 border-transparent border-b-white transform -translate-x-1/2 z-10" })
] });
}, X = ({
value: e,
title: t,
unit: o,
unitTooltip: l,
generateMarks: a,
getValueColor: i = () => "text-white",
isMajorTick: n = (p) => p % 20 === 0,
formatValue: d = (p) => p.toString(),
formatCurrentValue: c = (p) => Math.round(p).toString(),
pixelsPerUnit: m = 2,
pointerSide: b = "right",
className: g = ""
}) => {
const p = a(e), N = b === "left";
return console.log(), /* @__PURE__ */ s("div", { className: `bg-gray-900 text-white rounded-lg w-32 h-64 relative overflow-hidden border-2 border-gray-600 flex flex-col ${g}`, children: [
/* @__PURE__ */ r("div", { className: "text-center text-xs font-bold text-gray-300 py-1 border-b border-gray-600", children: t }),
/* @__PURE__ */ s("div", { className: "flex-1 relative overflow-hidden", children: [
/* @__PURE__ */ r("div", { className: "absolute inset-0 flex flex-col justify-center", children: /* @__PURE__ */ r("div", { className: "relative h-48 mx-2", children: p.map((f) => {
const x = (e - f) * m, M = 96 + x;
if (Math.abs(x) > 90 || M < 0 || M > 202)
return null;
const v = n(f);
return /* @__PURE__ */ s(
"div",
{
className: "absolute flex items-center w-full",
style: {
top: `${M}px`,
transform: "translateY(-50%)",
flexDirection: N ? "row-reverse" : "row"
},
children: [
v && /* @__PURE__ */ r(
"div",
{
className: `text-xs font-mono w-8 ${N ? "text-left" : "text-right"} ${i(f)}`,
children: d(f)
}
),
/* @__PURE__ */ r(
"div",
{
className: `${N ? "mr-1" : "ml-1"} bg-white ${v ? "h-0.5 w-4" : "h-0.5 w-2"}`
}
)
]
},
f
);
}) }) }),
/* @__PURE__ */ r(
"div",
{
className: `absolute ${N ? "left-2" : "right-2"} top-1/2 w-0 h-0 ${N ? "border-t-4 border-b-4 border-r-6 border-transparent border-r-yellow-400" : "border-t-4 border-b-4 border-l-6 border-transparent border-l-yellow-400"} transform -translate-y-1/2 z-20`
}
),
/* @__PURE__ */ r(
"div",
{
className: `absolute top-1/2 ${N ? "left-8" : "right-8"} bg-black px-2 py-1 border border-white text-yellow-400 font-bold text-sm transform -translate-y-1/2 z-10 min-w-[3rem] text-center`,
children: c(e)
}
)
] }),
/* @__PURE__ */ s("div", { className: "relative group text-center text-xs text-gray-300 py-1 border-t border-gray-600", children: [
/* @__PURE__ */ r("span", { className: "cursor-help", children: o }),
l && /* @__PURE__ */ s("div", { className: "absolute bottom-full left-1/2 transform -translate-x-1/2 mb-2 px-2 py-1 bg-gray-800 text-white text-xs rounded shadow-lg opacity-0 group-hover:opacity-100 transition-opacity duration-200 z-50 pointer-events-none max-w-32 text-center whitespace-normal", children: [
l,
/* @__PURE__ */ r("div", { className: "absolute top-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-l-2 border-r-2 border-t-2 border-transparent border-t-gray-800" })
] })
] })
] });
}, ae = ({ airspeed: e, options: t }) => /* @__PURE__ */ r(
X,
{
value: e,
title: "AIRSPEED",
unit: "KTS",
unitTooltip: "Knots (nautical mph)",
generateMarks: (i) => {
const n = [], m = Math.max(
0,
Math.floor((i - 100) / 10) * 10
), b = Math.ceil((i + 100) / 10) * 10;
for (let g = m; g <= b; g += 10)
n.push(g);
return n;
},
getValueColor: (i) => {
const n = [
{ min: 40, max: 100, color: "text-white" },
{ min: 100, max: 180, color: "text-green-400" },
{ min: 180, max: 220, color: "text-yellow-400" },
{ min: 220, max: 1 / 0, color: "text-red-400" }
], d = (t == null ? void 0 : t.speedColorRanges) || n;
for (const c of d)
if (i >= c.min && i <= c.max)
return c.color;
return "text-gray-400";
},
isMajorTick: (i) => i % 20 === 0,
pixelsPerUnit: 2,
pointerSide: "right"
}
), re = ({ altitude: e }) => /* @__PURE__ */ r(
X,
{
value: e,
title: "ALTITUDE",
unit: "FT",
unitTooltip: "Feet above sea level",
generateMarks: (i) => {
const n = [], m = Math.max(
0,
Math.floor((i - 5e3) / 100) * 100
), b = Math.ceil((i + 5e3) / 100) * 100;
for (let g = m; g <= b; g += 100)
n.push(g);
return n;
},
getValueColor: (i) => i < 1e3 ? "text-red-400" : i >= 1e3 && i <= 1e4 ? "text-white" : i > 1e4 && i <= 4e4 ? "text-green-400" : i > 4e4 ? "text-yellow-400" : "text-gray-400",
isMajorTick: (i) => i % 500 === 0,
formatValue: (i) => i.toString(),
pixelsPerUnit: 0.1,
pointerSide: "left"
}
), ne = ({ heading: e }) => {
const o = (() => {
const n = [];
for (let d = 0; d < 72; d++) {
const c = d * 5, m = c % 90 === 0, b = c % 30 === 0, g = c % 10 === 0;
let p = "";
c === 0 ? p = "N" : c === 90 ? p = "E" : c === 180 ? p = "S" : c === 270 ? p = "W" : b && (p = (c / 10).toString().padStart(2, "0")), n.push({
angle: c,
label: p,
isCardinal: m,
isMajor: b,
isMinor: g,
x: d * 4
});
}
return n;
})(), l = (e % 360 + 360) % 360, i = 96 - l * 4;
return /* @__PURE__ */ s("div", { className: "bg-gray-900 text-white rounded-lg w-48 h-16 relative overflow-hidden border-2 border-gray-600 shadow-lg", children: [
/* @__PURE__ */ r("div", { className: "absolute top-0 left-1/2 w-0 h-0 border-l-3 border-r-3 border-b-6 border-transparent border-b-yellow-400 transform -translate-x-1/2 z-10" }),
/* @__PURE__ */ r(
"div",
{
className: "absolute top-1 flex transition-transform duration-200 ease-out",
style: { transform: `translateX(${i}px)` },
children: o.concat(o).concat(o).map((n, d) => /* @__PURE__ */ s("div", { className: "relative flex flex-col items-center", style: { width: "4px" }, children: [
/* @__PURE__ */ r("div", { className: `bg-white ${n.isCardinal ? "w-0.5 h-4" : n.isMajor ? "w-0.5 h-3" : n.isMinor ? "w-px h-2" : "w-px h-1"}` }),
n.label && /* @__PURE__ */ r("div", { className: `mt-0.5 text-xs font-mono whitespace-nowrap ${n.isCardinal ? "text-yellow-400 font-bold" : "text-white"}`, style: { fontSize: "10px" }, children: n.label })
] }, d))
}
),
/* @__PURE__ */ s("div", { className: "absolute bottom-1 left-1/2 bg-black px-2 py-0.5 border border-gray-400 text-green-400 font-bold text-xs transform -translate-x-1/2 rounded whitespace-nowrap", children: [
"HDG ",
Math.round(l).toString().padStart(3, "0"),
"°"
] }),
/* @__PURE__ */ r("div", { className: "absolute top-0 left-0 w-4 h-full bg-gradient-to-r from-gray-900 to-transparent pointer-events-none z-20" }),
/* @__PURE__ */ r("div", { className: "absolute top-0 right-0 w-4 h-full bg-gradient-to-l from-gray-900 to-transparent pointer-events-none z-20" })
] });
}, oe = ({ verticalSpeed: e }) => {
const o = (() => {
const n = [];
for (let m = -3e3; m <= 3e3; m += 200) {
const b = 50 - m / 3e3 * 40, g = m % 1e3 === 0, p = g;
n.push({
value: m,
yPercent: b,
isMajor: g,
showLabel: p,
label: p ? (m / 1e3).toString() : ""
});
}
return n;
})(), a = 50 - Math.max(-3e3, Math.min(3e3, e)) / 3e3 * 40, i = () => {
const n = Math.abs(e);
return n < 50 ? "00" : Math.floor(n / 100).toString().padStart(2, "0");
};
return /* @__PURE__ */ s("div", { className: "bg-gray-900 text-white rounded-lg w-20 h-64 relative border-2 border-gray-600 shadow-lg overflow-hidden", children: [
/* @__PURE__ */ r("div", { className: "absolute top-1 left-1/2 transform -translate-x-1/2 text-xs font-mono text-gray-300 font-semibold", children: "V/S" }),
/* @__PURE__ */ r("div", { className: "absolute right-1 top-8 bottom-8 w-16", children: o.map((n, d) => /* @__PURE__ */ s(
"div",
{
className: "absolute w-full flex items-center justify-end",
style: { top: `${n.yPercent}%` },
children: [
n.showLabel && /* @__PURE__ */ r("div", { className: "mr-1 text-xs font-mono text-white", children: n.label }),
/* @__PURE__ */ r("div", { className: `bg-white h-0.5 ${n.isMajor ? "w-4" : "w-2"} ${n.value === 0 ? "bg-yellow-400 w-6" : "bg-white"}` })
]
},
d
)) }),
/* @__PURE__ */ r(
"div",
{
className: "absolute left-2 top-1/2 w-0 h-0 border-t-2 border-b-2 border-r-4 border-transparent border-r-yellow-400 transform -translate-y-1/2 z-10"
}
),
/* @__PURE__ */ r(
"div",
{
className: "absolute left-8 w-6 h-0.5 bg-cyan-400 transform -translate-y-1/2 transition-all duration-300 z-20",
style: { top: `${a}%` }
}
),
/* @__PURE__ */ s("div", { className: "absolute left-1/2 top-1/2 transform -translate-x-1/2 -translate-y-1/2 bg-black px-2 py-1 border border-gray-400 rounded z-30", children: [
/* @__PURE__ */ r("div", { className: "text-cyan-400 font-bold text-lg font-mono", children: i() }),
/* @__PURE__ */ r("div", { className: "text-gray-400 text-xs text-center", children: e >= 0 ? "▲" : "▼" })
] }),
/* @__PURE__ */ r("div", { className: "absolute bottom-1 left-1/2 transform -translate-x-1/2 text-xs text-gray-400 font-mono", children: "FPM" }),
/* @__PURE__ */ r("div", { className: "absolute top-0 left-0 w-full h-8 bg-gradient-to-b from-gray-900 to-transparent pointer-events-none z-40" }),
/* @__PURE__ */ r("div", { className: "absolute bottom-0 left-0 w-full h-8 bg-gradient-to-t from-gray-900 to-transparent pointer-events-none z-40" })
] });
};
function se({ flightData: e }) {
return /* @__PURE__ */ r(K, { children: /* @__PURE__ */ s("div", { className: "bg-black rounded-xl p-8 shadow-2xl mb-6", children: [
/* @__PURE__ */ s("div", { className: "flex justify-center items-center space-x-8", children: [
/* @__PURE__ */ r("p", { children: "AirSpeed" }),
/* @__PURE__ */ r(ae, { airspeed: e.airspeed }),
/* @__PURE__ */ s("div", { className: "flex flex-col items-center space-y-4", children: [
/* @__PURE__ */ r(
te,
{
pitch: e.pitch_angle,
roll: e.roll_angle
}
),
/* @__PURE__ */ r(ne, { heading: e.true_heading })
] }),
/* @__PURE__ */ r(re, { altitude: e.altitude }),
/* @__PURE__ */ r(oe, { verticalSpeed: e.vertical_speed })
] }),
/* @__PURE__ */ s("div", { className: "flex justify-center space-x-8 mt-6 text-white", children: [
/* @__PURE__ */ s("div", { className: "bg-gray-800 px-4 py-2 rounded border", children: [
/* @__PURE__ */ r("span", { className: "text-gray-400", children: "MACH:" }),
/* @__PURE__ */ r("span", { className: "text-cyan-400 ml-2 font-mono", children: e.mach.toFixed(3) })
] }),
/* @__PURE__ */ s("div", { className: "bg-gray-800 px-4 py-2 rounded border", children: [
/* @__PURE__ */ r("span", { className: "text-gray-400", children: "OAT:" }),
/* @__PURE__ */ s("span", { className: "text-blue-300 ml-2 font-mono", children: [
Math.round(e.total_air_temperature),
"°C"
] })
] }),
/* @__PURE__ */ s("div", { className: "bg-gray-800 px-4 py-2 rounded border", children: [
/* @__PURE__ */ r("span", { className: "text-gray-400", children: "GS:" }),
/* @__PURE__ */ s("span", { className: "text-green-400 ml-2 font-mono", children: [
Math.round(e.groundspeed),
" KT"
] })
] })
] })
] }) });
}
const be = ({ flightData: e }) => /* @__PURE__ */ r("div", { className: "min-h-screen bg-gray-800 p-6", children: /* @__PURE__ */ s("div", { className: "max-w-7xl mx-auto", children: [
/* @__PURE__ */ r("div", { className: "mb-6 text-center", children: /* @__PURE__ */ r("div", { className: "bg-gray-900 rounded-lg p-4 inline-block", children: /* @__PURE__ */ s("div", { className: "text-green-400 font-mono text-lg", children: [
e.timestamp.toLocaleDateString(),
" - ",
e.timestamp.toLocaleTimeString()
] }) }) }),
/* @__PURE__ */ r(se, { flightData: e }),
/* @__PURE__ */ r(ee, { flightData: e })
] }) }), B = {
DEFAULT_ZOOM: 4,
GOOGLE_MAPS_ZOOM: 6,
MAX_FLIGHT_PATH_POINTS: 100,
AIRCRAFT_MARKER_SCALE: 1,
FLIGHT_PATH_STROKE_WIDTH: 4,
SIMULATED_MAP_STROKE_WIDTH: 3,
UPDATE_TIMEOUT: 5e3
// 5 seconds
}, le = [
{ name: "New York", position: { top: "25%", left: "33%" } },
{ name: "Chicago", position: { top: "50%", left: "25%" } },
{ name: "Dallas", position: { bottom: "33%", right: "25%" } },
{ name: "Denver", position: { top: "33%", left: "16%" } },
{ name: "Los Angeles", position: { bottom: "25%", left: "12%" } }
], ie = [
{
className: "absolute top-1/4 left-1/4 w-1/3 h-1/2 bg-green-800 opacity-40 rounded-full transform rotate-12"
},
{
className: "absolute top-1/3 right-1/4 w-1/4 h-1/3 bg-green-700 opacity-30 rounded-lg"
},
{
className: "absolute bottom-1/4 left-1/3 w-1/2 h-1/4 bg-green-800 opacity-35 rounded-full"
}
], de = [
{
elementType: "geometry",
stylers: [{ color: "#1d2c4d" }]
},
{
elementType: "labels.text.fill",
stylers: [{ color: "#8ec3b9" }]
},
{
elementType: "labels.text.stroke",
stylers: [{ color: "#1a3646" }]
},
{
featureType: "administrative.country",
elementType: "geometry.stroke",
stylers: [{ color: "#4b6878" }]
},
{
featureType: "water",
elementType: "geometry",
stylers: [{ color: "#0e1626" }]
},
{
featureType: "landscape.natural",
elementType: "geometry",
stylers: [{ color: "#023e58" }]
}
], G = {
/**
* Convert lat/lng coordinates to screen coordinates using Mercator projection
*/
latLngToScreen: (e, t, o, l, a, i) => {
const n = o.lat, d = o.lng, c = Math.pow(2, l) / 360, m = a / 2 + (t - d) * c * a / 360, b = i / 2 - (e - n) * c * i / 180;
return { x: m, y: b };
},
/**
* Generate SVG path for flight path visualization
*/
generateFlightPathSVG: (e, t, o, l, a) => e.length < 2 ? "" : e.map((n, d) => {
const { x: c, y: m } = G.latLngToScreen(n.lat, n.lng, t, o, l, a);
return d === 0 ? `M ${c} ${m}` : `L ${c} ${m}`;
}).join(" ")
}, xe = ({
flightData: e,
width: t = 800,
height: o = 600,
apiKey: l
}) => {
const [a, i] = P([]), [n, d] = P({ lat: 40.7128, lng: -74.006 }), [c, m] = P(B.DEFAULT_ZOOM), [b, g] = P(!1), [p, N] = P(null), [f, x] = P(!1), O = j(null), M = j(null), v = j(null), k = j(null);
H(() => {
if (!l || l === "YOUR_GOOGLE_MAPS_API_KEY") {
x(!0), g(!0);
return;
}
if (window.google && window.google.maps) {
g(!0), x(!1);
return;
}
if (document.querySelector('script[src*="maps.googleapis.com"]')) {
const y = setInterval(() => {
window.google && window.google.maps && (clearInterval(y), g(!0), x(!1));
}, 100);
setTimeout(() => {
clearInterval(y), (!window.google || !window.google.maps) && (N("Google Maps failed to load"), x(!0), g(!0));
}, 1e4);
return;
}
const u = document.createElement("script");
return u.src = `https://maps.googleapis.com/maps/api/js?key=${l}&libraries=geometry`, u.async = !0, u.defer = !0, u.onload = () => {
window.google && window.google.maps ? (g(!0), x(!1), N(null)) : (N("Google Maps API failed to initialize"), x(!0), g(!0));
}, u.onerror = () => {
N("Failed to load Google Maps script"), x(!0), g(!0);
}, window.gm_authFailure = () => {
N("Google Maps authentication failed"), x(!0), g(!0);
}, document.head.appendChild(u), () => {
window.gm_authFailure && delete window.gm_authFailure;
};
}, [l]), H(() => {
if (!(!b || f || !O.current || M.current)) {
if (!window.google || !window.google.maps) {
N("Google Maps not available"), x(!0);
return;
}
try {
const h = new window.google.maps.Map(O.current, {
center: {
lat: e.latitude || 40.7128,
lng: e.longitude || -74.006
},
zoom: B.GOOGLE_MAPS_ZOOM,
mapTypeId: window.google.maps.MapTypeId.TERRAIN,
styles: de
});
M.current = h;
const u = {
path: "M 0,-18 L -6,-6 L -18,-4 L -18,0 L -6,2 L -3,10 L -6,12 L -3,14 L 0,12 L 4,14 L 6,12 L 3,10 L 6,2 L 18,0 L 18,-4 L 6,-6 Z",
fillColor: "#fbbf24",
fillOpacity: 1,
strokeColor: "#f59e0b",
strokeWeight: 1,
scale: 1,
rotation: e.true_track_angle || 0,
anchor: new window.google.maps.Point(0, 0)
};
v.current = new window.google.maps.Marker({
position: { lat: e.latitude, lng: e.longitude },
map: h,
icon: u,
title: `Altitude: ${Math.round(e.altitude)} ft, Speed: ${Math.round(e.groundspeed)} mph`
}), k.current = new window.google.maps.Polyline({
path: [],
geodesic: !0,
strokeColor: "#10b981",
strokeOpacity: 1,
strokeWeight: 3,
map: h
});
} catch (h) {
console.error("Failed to initialize Google Maps:", h), N("Failed to initialize Google Maps"), x(!0);
}
}
}, [b, f, e.latitude, e.longitude]);
const z = (h) => {
if (!(!M.current || !v.current || !k.current || f))
try {
const u = {
path: "M 0,-18 L -6,-6 L -18,-4 L -18,0 L -6,2 L -3,10 L -6,12 L -3,14 L 0,12 L 4,14 L 6,12 L 3,10 L 6,2 L 18,0 L 18,-4 L 6,-6 Z",
fillColor: "#fbbf24",
fillOpacity: 1,
strokeColor: "#f59e0b",
strokeWeight: 1,
scale: 1,
rotation: e.true_track_angle || 0,
anchor: new window.google.maps.Point(0, 0)
};
v.current.setPosition({
lat: e.latitude,
lng: e.longitude
}), v.current.setIcon(u), v.current.setTitle(
`Altitude: ${Math.round(e.altitude)} ft, Speed: ${Math.round(e.groundspeed)} mph`
);
const y = h.map((L) => ({
lat: L.lat,
lng: L.lng
}));
k.current.setPath(y), M.current.setCenter({
lat: e.latitude,
lng: e.longitude
});
} catch (u) {
console.warn("Google Maps update failed:", u);
}
};
H(() => {
const h = {
lat: e.latitude,
lng: e.longitude,
timestamp: e.timestamp,
altitude: e.altitude,
speed: e.groundspeed
};
i((u) => {
const y = [...u.slice(-99), h];
return !f && b && z(y), y;
}), f && d({ lat: e.latitude, lng: e.longitude });
}, [
e.latitude,
e.longitude,
e.timestamp,
e.altitude,
e.groundspeed,
f,
b
]);
const W = () => {
f ? m((h) => Math.min(10, h + 1)) : M.current && M.current.setZoom(M.current.getZoom() + 1);
}, A = () => {
f ? m((h) => Math.max(1, h - 1)) : M.current && M.current.setZoom(M.current.getZoom() - 1);
}, U = () => {
f ? d({
lat: e.latitude,
lng: e.longitude
}) : M.current && M.current.setCenter({
lat: e.latitude,
lng: e.longitude
});
};
return /* @__PURE__ */ s("div", { className: "bg-gray-900 rounded-xl p-4 shadow-2xl", children: [
/* @__PURE__ */ s("div", { className: "mb-4", children: [
/* @__PURE__ */ r("h2", { className: "text-white text-xl font-bold mb-2", children: "Flight Tracking" }),
/* @__PURE__ */ s("div", { className: "flex space-x-4 text-sm", children: [
/* @__PURE__ */ s("div", { className: "text-gray-400", children: [
"Position:",
" ",
/* @__PURE__ */ s("span", { className: "text-cyan-400", children: [
e.latitude.toFixed(4),
"°,",
" ",
e.longitude.toFixed(4),
"°"
] })
] }),
/* @__PURE__ */ s("div", { className: "text-gray-400", children: [
"Track:",
" ",
/* @__PURE__ */ s("span", { className: "text-green-400", children: [
Math.round(e.true_track_angle),
"°"
] })
] })
] })
] }),
/* @__PURE__ */ s("div", { className: "relative rounded-lg overflow-hidden", style: { width: t, height: o }, children: [
!b && /* @__PURE__ */ r("div", { className: "absolute inset-0 bg-gray-800 flex items-center justify-center", children: /* @__PURE__ */ r("div", { className: "text-white", children: "Loading map..." }) }),
p && /* @__PURE__ */ s("div", { className: "absolute top-2 left-2 bg-yellow-600 text-white px-2 py-1 rounded text-xs z-10", children: [
p,
" - Using simulated map"
] }),
f ? (
// Simulated Map Display
/* @__PURE__ */ s("div", { className: "relative bg-blue-950 rounded-lg overflow-hidden", style: { width: t, height: o }, children: [
/* @__PURE__ */ r("div", { className: "absolute inset-0 bg-gradient-to-b from-blue-900 to-blue-950", children: ie.map((h, u) => /* @__PURE__ */ r("div", { className: h.className }, u)) }),
/* @__PURE__ */ s("svg", { className: "absolute inset-0", width: t, height: o, children: [
/* @__PURE__ */ r("defs", { children: /* @__PURE__ */ r(
"pattern",
{
id: "grid",
width: "50",
height: "50",
patternUnits: "userSpaceOnUse",
children: /* @__PURE__ */ r(
"path",
{
d: "M 50 0 L 0 0 0 50",
fill: "none",
stroke: "rgba(255,255,255,0.1)",
strokeWidth: "1"
}
)
}
) }),
/* @__PURE__ */ r("rect", { width: t, height: o, fill: "url(#grid)" })
] }),
/* @__PURE__ */ r("div", { className: "absolute inset-0 text-white text-xs", children: le.map((h, u) => /* @__PURE__ */ s("div", { className: "absolute flex items-center", style: h.position, children: [
/* @__PURE__ */ r("div", { className: "w-2 h-2 bg-yellow-400 rounded-full mr-1" }),
/* @__PURE__ */ r("span", { children: h.name })
] }, u)) }),
/* @__PURE__ */ s("svg", { className: "absolute inset-0", width: t, height: o, children: [
a.length > 1 && /* @__PURE__ */ r(
"path",
{
d: G.generateFlightPathSVG(a, n, c, t, o),
fill: "none",
stroke: "#10b981",
strokeWidth: "3",
strokeDasharray: "6,3",
opacity: "1.0"
}
),
a.slice(0, -1).map((h, u) => {
const { x: y, y: L } = G.latLngToScreen(h.lat, h.lng, n, c, t, o), F = Math.max(0.3, (u + 1) / a.length), Z = Math.max(1.5, 3 * ((u + 1) / a.length));
return /* @__PURE__ */ r(
"circle",
{
cx: y,
cy: L,
r: Z,
fill: "#10b981",
opacity: F,
stroke: "#059669",
strokeWidth: "0.5"
},
u
);
}),
a.length > 0 && /* @__PURE__ */ r(
"g",
{
transform: `translate(${G.latLngToScreen(e.latitude, e.longitude, n, c, t, o).x}, ${G.latLngToScreen(e.latitude, e.longitude, n, c, t, o).y}) rotate(${e.true_track_angle})`,
children: /* @__PURE__ */ r(
"path",
{
d: "M 0,-18 L -6,-6 L -18,-4 L -18,0 L -6,2 L -3,10 L -6,12 L -3,14 L 0,12 L 4,14 L 6,12 L 3,10 L 6,2 L 18,0 L 18,-4 L 6,-6 Z",
fill: "#fbbf24",
stroke: "#f59e0b",
strokeWidth: "1"
}
)
}
)
] })
] })
) : (
// Google Maps Display
/* @__PURE__ */ r("div", { ref: O, className: "w-full h-full", style: { width: t, height: o } })
),
/* @__PURE__ */ s("div", { className: "absolute top-4 right-4 flex flex-col space-y-2", children: [
/* @__PURE__ */ r(
"button",
{
onClick: W,
className: "bg-gray-700 hover:bg-gray-600 text-white p-2 rounded text-xs transition-colors",
title: "Zoom In",
children: "+"
}
),
/* @__PURE__ */ r(
"button",
{
onClick: A,
className: "bg-gray-700 hover:bg-gray-600 text-white p-2 rounded text-xs transition-colors",
title: "Zoom Out",
children: "-"
}
),
/* @__PURE__ */ r(
"button",
{
onClick: U,
className: "bg-gray-700 hover:bg-gray-600 text-white p-2 rounded text-xs transition-colors",
title: "Center on Aircraft",
children: "📍"
}
)
] })
] }),
/* @__PURE__ */ s("div", { className: "mt-4 grid grid-cols-2 md:grid-cols-4 gap-4 text-sm", children: [
/* @__PURE__ */ s("div", { className: "bg-gray-800 p-3 rounded border", children: [
/* @__PURE__ */ r("div", { className: "text-gray-400 text-xs", children: "Ground Speed" }),
/* @__PURE__ */ s("div", { className: "text-green-400 font-mono text-lg", children: [
Math.round(e.groundspeed),
" mph"
] })
] }),
/* @__PURE__ */ s("div", { className: "bg-gray-800 p-3 rounded border", children: [
/* @__PURE__ */ r("div", { className: "text-gray-400 text-xs", children: "True Airspeed" }),
/* @__PURE__ */ s("div", { className: "text-cyan-400 font-mono text-lg", children: [
Math.round(e.airspeed),
" mph"
] })
] }),
/* @__PURE__ */ s("div", { className: "bg-gray-800 p-3 rounded border", children: [
/* @__PURE__ */ r("div", { className: "text-gray-400 text-xs", children: "Altitude" }),
/* @__PURE__ */ s("div", { className: "text-blue-300 font-mono text-lg", children: [
Math.round(e.altitude).toLocaleString(),
" ft"
] })
] }),
/* @__PURE__ */ s("div", { className: "bg-gray-800 p-3 rounded border", children: [
/* @__PURE__ */ r("div", { className: "text-gray-400 text-xs", children: "To Arrival" }),
/* @__PURE__ */ r("div", { className: "text-white font-mono text-lg", children: "5:18" })
] })
] })
] });
}, ce = (e) => {
const [t, o] = P(e || q);
return H(() => {
const l = setInterval(() => {
o((a) => {
const i = /* @__PURE__ */ new Date();
let n = a.flight_phase;
a.altitude < 1e3 ? a.groundspeed < 50 ? n = "GROUND" : a.vertical_speed > 500 ? n = "TAKEOFF" : a.vertical_speed < -500 ? n = "LANDING" : n = "APPROACH" : a.altitude < 1e4 ? a.vertical_speed > 1e3 ? n = "CLIMB" : a.vertical_speed < -1e3 ? n = "DESCENT" : n = "CRUISE" : a.altitude > 3e4 ? a.vertical_speed > 500 ? n = "CLIMB" : a.vertical_speed < -500 ? n = "DESCENT" : n = "CRUISE" : a.vertical_speed > 800 ? n = "CLIMB" : a.vertical_speed < -800 ? n = "DESCENT" : n = "CRUISE";
const d = a.airspeed / (661.5 * Math.sqrt(288.15 / (a.static_air_temperature + 273.15))), m = ((A) => {
switch (A) {
case "TAKEOFF":
return { altitudeRate: 2500, speedChange: 15, powerSetting: 0.95, stabilityFactor: 0.3 };
case "CLIMB":
return { altitudeRate: 1500, speedChange: 5, powerSetting: 0.82, stabilityFactor: 0.7 };
case "CRUISE":
return { altitudeRate: 25, speedChange: 1.5, powerSetting: 0.78, stabilityFactor: 0.95 };
case "DESCENT":
return { altitudeRate: -1e3, speedChange: 4, powerSetting: 0.45, stabilityFactor: 0.8 };
case "APPROACH":
return { altitudeRate: -600, speedChange: 6, powerSetting: 0.55, stabilityFactor: 0.6 };
case "LANDING":
return { altitudeRate: -200, speedChange: 8, powerSetting: 0.35, stabilityFactor: 0.4 };
default:
return { altitudeRate: 0, speedChange: 1, powerSetting: 0.25, stabilityFactor: 0.9 };
}
})(n), b = n === "CRUISE" ? 0.3 : 1, g = (Math.random() - 0.5) * 1.5 * b, p = (Math.random() - 0.5) * 0.5, f = (m.powerSetting * 100 - a.n1_rpm) * 0.02 + (Math.random() - 0.5) * 0.3 * b, x = Math.max(20, Math.min(100, a.n1_rpm + f)), O = Math.max(30, Math.min(105, x * 1.18 + (Math.random() - 0.5) * 0.8)), M = 300 + x / 100 * 350 - a.altitude / 1e3 * 6, v = Math.max(200, Math.min(950, M + (Math.random() - 0.5) * 8)), k = Math.max(0.6, 1 - a.altitude / 12e4), z = x / 100 * 2200 * k, W = Math.max(300, z + (Math.random() - 0.5) * 40);
return {
// Primary Flight Data with realistic constraints
airspeed: Math.max(0, Math.min(
400,
a.airspeed + (Math.random() - 0.5) * m.speedChange
)),
altitude: Math.max(0, a.altitude + a.vertical_speed / 60 + (Math.random() - 0.5) * 20),
groundspeed: Math.max(0, a.airspeed + a.wind_speed * Math.cos((a.wind_direction - a.true_heading) * Math.PI / 180)),
mach: Math.max(0, Math.min(0.95, d + (Math.random() - 0.5) * 0.01)),
// Attitude with realistic flight envelope limits
pitch_angle: Math.max(-20, Math.min(
25,
a.pitch_angle + a.pitch_rate * 0.02 + (Math.random() - 0.5) * 0.5
)),
roll_angle: Math.max(-45, Math.min(
45,
a.roll_angle + a.roll_rate * 0.02 + (Math.random() - 0.5) * 0.8
)),
true_heading: (() => {
const h = (-123.1207 - a.longitude) * Math.PI / 180, u = a.latitude * Math.PI / 180, y = 49.2827 * Math.PI / 180, L = Math.sin(h) * Math.cos(y), F = Math.cos(u) * Math.sin(y) - Math.sin(u) * Math.cos(y) * Math.cos(h);
let $ = (Math.atan2(L, F) * 180 / Math.PI + 360) % 360 - a.true_heading;
$ > 180 && ($ -= 360), $ < -180 && ($ += 360);
const J = Math.max(-1, Math.min(1, $ * 0.1));
return (a.true_heading + J + a.true_heading_rate * 0.02 + (Math.random() - 0.5) * 0.2 + 360) % 360;
})(),
magnetic_heading: (a.true_heading - 12 + 360) % 360,
// Magnetic variation for Western Canada
// Flight Dynamics
pitch_rate: Math.max(-10, Math.min(10, (Math.random() - 0.5) * 2)),
roll_rate: Math.max(-15, Math.min(15, (Math.random() - 0.5) * 3)),
true_heading_rate: Math.max(-5, Math.min(5, (Math.random() - 0.5) * 1)),
vertical_speed: Math.max(-4e3, Math.min(
4e3,
m.altitudeRate + (Math.random() - 0.5) * 300
)),
true_track_angle: (a.true_heading + (Math.random() - 0.5) * 2 + 360) % 360,
// Accelerations (realistic g-force ranges)
body_lateral_accel: Math.max(-2, Math.min(2, a.roll_angle * 0.02 + (Math.random() - 0.5) * 0.1)),
body_long_accel: Math.max(-1, Math.min(1, (x - a.n1_rpm) * 0.01 + (Math.random() - 0.5) * 0.05)),
body_normal_accel: Math.max(-1, Math.min(3, 1 + a.pitch_angle * 0.015 + (Math.random() - 0.5) * 0.08)),
// Navigation (realistic cruise navigation towards Vancouver)
// Vancouver coordinates: 49.2827, -123.1207
// Calculate distance and bearing to Vancouver
latitude: (() => {
const A = a.true_track_angle * Math.PI / 180;
return a.latitude + a.groundspeed * Math.cos(A) / 364e3;
})(),
longitude: (() => {
const A = a.true_track_angle * Math.PI / 180;
return a.longitude + a.groundspeed * Math.sin(A) / (364e3 * Math.cos(a.latitude * Math.PI / 180));
})(),
// Environmental Data (high altitude conditions)
total_air_temperature: Math.max(-70, Math.min(
50,
15 - a.altitude / 1e3 * 2 + p
)),
static_air_temperature: Math.max(-70, Math.min(
50,
15 - a.altitude / 1e3 * 2 + p - 2
)),
wind_speed: Math.max(0, Math.min(150, a.wind_speed + g)),
wind_direction: (a.wind_direction + (Math.random() - 0.5) * 2 + 360) % 360,
static_pressure: Math.max(100, 1013.25 * Math.pow(1 - 65e-4 * a.altitude / 288.15, 5.255)),
// Engine Parameters (realistic turbofan correlations)
n1_rpm: x,
n2_rpm: O,
egt: v,
fuel_flow: W,
oil_pressure: Math.max(20, Math.min(100, 45 + x / 100 * 35 + (Math.random() - 0.5) * 3)),
oil_temperature: Math.max(-40, Math.min(150, 60 + x / 100 * 40 + (Math.random() - 0.5) * 5)),
// Aircraft Configuration (cruise configuration)
flap_position: n === "TAKEOFF" || n === "APPROACH" || n === "LANDING" ? Math.max(0, Math.min(40, 20 + (Math.random() - 0.5) * 3)) : 0,
gear_position: a.altitude < 2500 && (n === "TAKEOFF" || n === "APPROACH" || n === "LANDING" || n === "GROUND"),
// System Status (pressurized cruise cabin)
cabin_altitude: Math.min(8e3, Math.max(0, a.altitude * 0.2 + 6e3 + (Math.random() - 0.5) * 50)),
cabin_pressure_diff: Math.max(0, Math.min(9.5, (a.altitude - 6e3) / 5e3 * 8 + (Math.random() - 0.5) * 0.05)),
// Navigation Aids (Vancouver destination)
ils_deviation: n === "APPROACH" ? (Math.random() - 0.5) * 1.5 : 0,
glideslope_deviation: n === "APPROACH" ? (Math.random() - 0.5) * 1.2 : 0,
dme_distance: (() => {
const U = -123.1207, h = 3440.065, u = (49.2827 - a.latitude) * Math.PI / 180, y = (U - a.longitude) * Math.PI / 180, L = Math.sin(u / 2) * Math.sin(u / 2) + Math.cos(a.latitude * Math.PI / 180) * Math.cos(49.2827 * Math.PI / 180) * Math.sin(y / 2) * Math.sin(y / 2), F = 2 * Math.atan2(Math.sqrt(L), Math.sqrt(1 - L));
return Math.max(0, h * F);
})(),
// Time & Date
date: i.toLocaleDateString("en-GB"),
time: i.toTimeString().split(" ")[0],
timestamp: i,
// Flight Phase
flight_phase: n
};
});
}, 2e3);
return () => clearInterval(l);
}, []), t;
}, q = {
// Cruise flight at FL350 (35,000 ft)
airspeed: 285,
// Typical cruise IAS (knots)
altitude: 35e3,
// Flight Level 350
groundspeed: 465,
// TAS + wind component
mach: 0.82,
// Typical commercial cruise Mach
// Stable cruise attitude
pitch_angle: 2.5,
// Slight nose-up attitude in cruise
roll_angle: -1.2,
// Minor bank correction
true_heading: 285,
// Westbound heading to Vancouver
magnetic_heading: 277,
// Accounting for magnetic variation
// Minimal rates in stable cruise
pitch_rate: 0.1,
roll_rate: -0.2,
true_heading_rate: 0.05,
vertical_speed: 50,
// Slight climb (step climb scenario)
true_track_angle: 287,
// Slightly different from heading due to wind
// Cruise flight accelerations
body_lateral_accel: -0.02,
// Minimal lateral G
body_long_accel: 0.01,
// Slight acceleration
body_normal_accel: 1.01,
// Just over 1G in level flight
// Position over Ontario, Canada
latitude: 43.6532,
// Toronto, Ontario area
longitude: -79.3832,
// High altitude environment
total_air_temperature: -54,
// ISA at FL350
static_air_temperature: -56,
wind_speed: 45,
// Typical jetstream winds
wind_direction: 285,
// Westerly jetstream
static_pressure: 238,
// Pressure at FL350 (millibars)
// Cruise engine settings (Boeing 737/A320 class)
n1_rpm: 78.5,
// Cruise thrust setting
n2_rpm: 94.2,
// High-pressure spool
egt: 485,
// Exhaust gas temp (°C)
fuel_flow: 1650,
// Per engine fuel flow (lbs/hr)
oil_pressure: 62,
// Normal cruise oil pressure
oil_temperature: 88,
// Oil temp in cruise
// Clean configuration for cruise
flap_position: 0,
// Flaps up
gear_position: !1,
// Gear retracted
// Pressurized cabin
cabin_altitude: 6800,
// Typical cruise cabin altitude
cabin_pressure_diff: 8.1,
// Differential pressure (PSI)
// Navigation aids (Vancouver destination)
ils_deviation: 0,
glideslope_deviation: 0,
dme_distance: 2200,
// Distance to Vancouver in nautical miles
// Current date/time
date: (/* @__PURE__ */ new Date()).toLocaleDateString("en-GB"),
time: (/* @__PURE__ */ new Date()).toTimeString().split(" ")[0],
timestamp: /* @__PURE__ */ new Date(),
flight_phase: "CRUISE"
};
function Y(e) {
return {
altitude: S(e.altitude, 1, _.ALTITUDE),
airspeed: S(e.airspeed, 128, _.AIRSPEED),
mach: S(e.mach, 8192, _.MACH),
heading: S(e.true_heading, 182.0444, _.HEADING),
vertical_speed: S(e.vertical_speed, 32, _.VERTICAL_SPEED),
pitch: S(e.pitch_angle, 4096, _.PITCH),
roll: S(e.roll_angle, 4096, _.ROLL),
temperature: S(e.static_air_temperature, 256, _.TEMPERATURE)
};
}
function fe(e) {
const t = (o, l) => o.data / l;
return {
altitude: e.altitude ? t(e.altitude, 1) : void 0,
airspeed: e.airspeed ? t(e.airspeed, 128) : void 0,
mach: e.mach ? t(e.mach, 8192) : void 0,
true_heading: e.heading ? t(e.heading, 182.0444) : void 0,
vertical_speed: e.vertical_speed ? t(e.vertical_speed, 32) : void 0,
pitch_angle: e.pitch ? t(e.pitch, 4096) : void 0,
roll_angle: e.roll ? t(e.roll, 4096) : void 0,
static_air_temperature: e.temperature ? t(e.temperature, 256) : void 0
};
}
const Me = (e) => {
const [t, o] = P(
() => Y(e || q)
), l = ce(e);
return H(() => {
const a = setInterval(() => {
o(Y(l));
}, 2e3);
return () => clearInterval(a);
}, [l]), { rawData: t, flightData: l };
};
class V {
constructor(t, o, l, a) {
w(this, "label");
w(this, "sdi");
w(this, "data");
w(this, "ssm");
w(this, "parity");
this.label = t, this.sdi = o, this.data = l, this.ssm = a, this.parity = this.calculateParity();
}
calculateParity() {
const t = this.label << 24 | this.sdi << 22 | this.data << 3 | this.ssm << 1;
let o = 0;
for (let l = 0; l < 31; l++)
t & 1 << l && o++;
return o % 2 === 0 ? 1 : 0;
}
// Convert to 32-bit integer representation
toInt32() {
return this.label << 24 | this.sdi << 22 | this.data << 3 | this.ssm << 1 | this.parity;
}
// Create from 32-bit integer
static fromInt32(t) {
const o = t >> 24 & 255, l = t >> 22 & 3, a = t >> 3 & 524287, i = t >> 1 & 3;
return new V(o, l, a, i);
}
}
const T = {
ALTITUDE: 131,
AIRSPEED: 134,
MACH: 135,
HEADING: 146,
VERTICAL_SPEED: 245,
PITCH: 212,
ROLL: 213,
TEMPERATURE: 137
}, me = {
NORMAL_OPERATION: 3
};
function I(e, t = 1, o, l = 0) {
const a = Math.round(e * t) & 524287;
return new V(o, l, a, me.NORMAL_OPERATION);
}
function E(e, t) {
return e.data / t;
}
function _e(e) {
const t = {};
return e.altitude !== void 0 && (t.altitude = I(e.altitude, 1, T.ALTITUDE)), e.airspeed !== void 0 && (t.airspeed = I(e.airspeed, 128, T.AIRSPEED)), e.mach !== void 0 && (t.mach = I(e.mach, 8192, T.MACH)), e.heading !== void 0 && (t.heading = I(e.heading, 182.0444, T.HEADING)), e.vertical_speed !== void 0 && (t.vertical_speed = I(e.vertical_speed, 32, T.VERTICAL_SPEED)), e.pitch_angle !== void 0 && (t.pitch = I(e.pitch_angle, 4096, T.PITCH)), e.roll_angle !== void 0 && (t.roll = I(e.roll_angle, 4096, T.ROLL)), e.temperature !== void 0 && (t.temperature = I(e.temperature, 256, T.TEMPERATURE)), t;
}
function ye(e) {
const t = {};
return e.altitude && (t.altitude = E(e.altitude, 1)), e.airspeed && (t.airspeed = E(e.airspeed, 128)), e.mach && (t.mach = E(e.mach, 8192)), e.heading && (t.heading = E(e.heading, 182.0444)), e.vertical_speed && (t.vertical_speed = E(e.vertical_speed, 32)), e.pitch && (t.pitch_angle = E(e.pitch, 4096)), e.roll && (t.roll_angle = E(e.roll, 4096)), e.temperature && (t.temperature = E(e.temperature, 256)), t;
}
function Ne(e) {
return Object.values(e).map((t) => t.toInt32());
}
function we(e, t) {
const o = {};
return e.forEach((l, a) => {
t[a] && (o[t[a]] = V.fromInt32(l));
}), o;
}
function ve(e) {
return e.calculateParity() === e.parity;
}
function Ae(e) {
const t = Object.entries(T).find(([, o]) => o === e);
return t ? t[0] : void 0;
}
export {
ee as ARINC429DataBus,
R as ARINC429Word,
_ as ARINC429_LABELS,
be as AircraftPFD,
ae as AirspeedIndicator,
re as AltitudeIndicator,
te as AttitudeIndicator,
xe as FlightTracking,
ne as HeadingIndicator,
C as SSM,
oe as VerticalSpeedIndicator,
ye as convertA429ToFlightParams,
_e as convertFlightParamsToA429,
fe as convertFromA429RawData,
Y as convertToA429RawData,
q as defaultFlightData,
S as encodeA429Value,
Ae as getLabelName,
Ne as rawDataToWords,
Me as useA429RawDataSimulator,
ce as useA429ValuesSimulator,
ve as validateA429Word,
we as wordsToRawData
};