import { OrderRule } from "../node_modules/.pnpm/remeda@2.39.0_patch_hash_e9e98c19bf4c5844450bf78de4493bf242de2fdb7c7ecf7ee2313945578d9b68/node_modules/remeda/dist/index.mjs"; //#region src/array/array-first-by.d.ts /** * Returns the first element of `array` according to one or more ordering * `rules`, computed in O(n) **without** fully sorting the array. With a single * ascending rule this is the minimum; with `'desc'` it is the maximum. Extra * rules act as tie-breakers, applied left to right. * * Each rule is either a projection `(item) => comparable` (ascending), or a * `[projection, 'asc' | 'desc']` pair to choose the direction. The return type * is the element type, plus `undefined` only when the input could be empty (a * non-empty tuple never yields `undefined`). * @param array - The array (or tuple) to search. Not mutated. * @param rules - One or more ordering rules; later rules break ties of earlier ones. * @returns The first element by the given ordering, or `undefined` when the array is empty. * @example * // Minimum (single ascending rule) * arrayFirstBy([3, 1, 2], (value) => value); * // 1 * @example * // Maximum (descending) * arrayFirstBy([3, 1, 2], [(value) => value, 'desc']); * // 3 * @example * // Shortest word, breaking ties alphabetically * arrayFirstBy(['bb', 'a', 'cc', 'b'], (word) => word.length, (word) => word); * // 'a' * @example * // Empty array yields `undefined` * arrayFirstBy([], (value) => value); * // undefined */ declare const arrayFirstBy: (array: T, ...rules: [OrderRule, ...OrderRule[]]) => T[number] | (T extends readonly [unknown, ...unknown[]] ? never : T extends readonly [...unknown[], unknown] ? never : undefined); //#endregion export { arrayFirstBy };