| 267 | // shared fallback lookups (Horizontal/Vertical/All/Start/End) and avoids |
| 268 | // allocating a fresh 4-array on every layoutNode() call. |
| 269 | function resolveEdges4Into( |
| 270 | edges: Value[], |
| 271 | ownerSize: number, |
| 272 | out: [number, number, number, number], |
| 273 | ): void { |
| 274 | // Hoist fallbacks once — the 4 per-edge chains share these reads. |
| 275 | const eH = edges[6]! // Edge.Horizontal |
| 276 | const eV = edges[7]! // Edge.Vertical |
| 277 | const eA = edges[8]! // Edge.All |
| 278 | const eS = edges[4]! // Edge.Start |
| 279 | const eE = edges[5]! // Edge.End |
| 280 | const pctDenom = isNaN(ownerSize) ? NaN : ownerSize / 100 |
| 281 | |
| 282 | // Left: edges[0] → Horizontal → All → Start |
| 283 | let v = edges[0]! |
| 284 | if (v.unit === 0) v = eH |
| 285 | if (v.unit === 0) v = eA |
| 286 | if (v.unit === 0) v = eS |
| 287 | out[0] = v.unit === 1 ? v.value : v.unit === 2 ? v.value * pctDenom : 0 |
| 288 | |
| 289 | // Top: edges[1] → Vertical → All |
| 290 | v = edges[1]! |
| 291 | if (v.unit === 0) v = eV |
| 292 | if (v.unit === 0) v = eA |
| 293 | out[1] = v.unit === 1 ? v.value : v.unit === 2 ? v.value * pctDenom : 0 |
| 294 | |
| 295 | // Right: edges[2] → Horizontal → All → End |
| 296 | v = edges[2]! |
| 297 | if (v.unit === 0) v = eH |
| 298 | if (v.unit === 0) v = eA |
| 299 | if (v.unit === 0) v = eE |
| 300 | out[2] = v.unit === 1 ? v.value : v.unit === 2 ? v.value * pctDenom : 0 |
| 301 | |
| 302 | // Bottom: edges[3] → Vertical → All |
| 303 | v = edges[3]! |
| 304 | if (v.unit === 0) v = eV |
| 305 | if (v.unit === 0) v = eA |
| 306 | out[3] = v.unit === 1 ? v.value : v.unit === 2 ? v.value * pctDenom : 0 |
| 307 | } |
| 308 | |
| 309 | // -- |
| 310 | // Axis helpers |