/** * Expo Router stores route params as strings, so a legacy advertisement's * `false` arrives as `"false"`. Missing means the scan did not say. */ export const parseOptionalBoolean = (value: unknown): boolean | undefined => { if (typeof value === "boolean") return value if (value === "true") return true if (value === "false") return false return undefined } /** * Prefer the device payload. JSON keeps the original boolean when the separate * route flag is dropped or stringified. */ export const advertisedSecurePairingCapable = (routeValue: unknown, deviceValue: unknown): boolean | undefined => parseOptionalBoolean(deviceValue) ?? parseOptionalBoolean(routeValue)