{"version":3,"file":"sortedLastIndex.cjs","names":["purry","binarySearchCutoffIndex"],"sources":["../src/sortedLastIndex.ts"],"sourcesContent":["import { purry } from \"./purry\";\nimport { binarySearchCutoffIndex } from \"./internal/binarySearchCutoffIndex\";\n\n/**\n * Find the insertion position (index) of an item in an array with items sorted\n * in ascending order; so that `splice(sortedIndex, 0, item)` would result in\n * maintaining the array's sort-ness. The array can contain duplicates.\n * If the item already exists in the array the index would be of the *last*\n * occurrence of the item.\n *\n * Runs in O(logN) time.\n *\n * @param data - The (ascending) sorted array.\n * @param item - The item to insert.\n * @returns Insertion index (In the range 0..data.length).\n * @signature\n *    sortedLastIndex(data, item)\n * @example\n *    sortedLastIndex(['a','a','b','c','c'], 'c') // => 5\n * @dataFirst\n * @category Array\n * @see sortedIndex, sortedIndexBy, sortedIndexWith, sortedLastIndexBy\n */\nexport function sortedLastIndex<T>(data: readonly T[], item: T): number;\n\n/**\n * Find the insertion position (index) of an item in an array with items sorted\n * in ascending order; so that `splice(sortedIndex, 0, item)` would result in\n * maintaining the array's sort-ness. The array can contain duplicates.\n * If the item already exists in the array the index would be of the *last*\n * occurrence of the item.\n *\n * Runs in O(logN) time.\n *\n * @param item - The item to insert.\n * @returns Insertion index (In the range 0..data.length).\n * @signature\n *    sortedLastIndex(item)(data)\n * @example\n *    pipe(['a','a','b','c','c'], sortedLastIndex('c')) // => 5\n * @dataLast\n * @category Array\n * @see sortedIndex, sortedIndexBy, sortedIndexWith, sortedLastIndexBy\n */\nexport function sortedLastIndex<T>(item: T): (data: readonly T[]) => number;\n\nexport function sortedLastIndex(...args: readonly unknown[]): unknown {\n  return purry(sortedLastIndexImplementation, args);\n}\n\nconst sortedLastIndexImplementation = <T>(\n  array: readonly T[],\n  item: T,\n): number =>\n  binarySearchCutoffIndex(\n    array,\n    // The only difference between the regular implementation and the \"last\"\n    // variation is that we consider the pivot with equality too, so that we\n    // skip all equal values in addition to the lower ones.\n    (pivot) => pivot <= item,\n  );\n"],"mappings":"sJA8CA,SAAgB,EAAgB,GAAG,EAAmC,CACpE,OAAOA,EAAAA,MAAM,EAA+B,EAAK,CAGnD,MAAM,GACJ,EACA,IAEAC,EAAAA,EACE,EAIC,GAAU,GAAS,EACrB"}