/** * Interface for weighted elements with metadata. */ export interface WeightedElement { /** The value of the element */ value: T; /** The weight/probability for selection (must be positive) */ weight: number; /** Optional metadata about the element */ metadata?: Record; } /** * Picks a random element from an array of weighted elements with metadata. * * @template T - The type of element values. * @param elements - Array of weighted elements. * @returns The selected weighted element. * * @throws {Error} If elements is empty, has invalid structure, or invalid weights. * * @example * const items = [ * { value: 'common', weight: 70, metadata: { rarity: 'common' } }, * { value: 'rare', weight: 25, metadata: { rarity: 'rare' } }, * { value: 'legendary', weight: 5, metadata: { rarity: 'legendary' } } * ]; * randomElement(items); // { value: 'common', weight: 70, metadata: {...} } * * @complexity Time: O(n), Space: O(1) where n is number of elements */ export declare function randomElement(elements: WeightedElement[]): WeightedElement; //# sourceMappingURL=randomElement.d.ts.map