{"version":3,"file":"convertArrayToObject.cjs","sources":["../../../../src/components/lib/convertArrayToObject.ts"],"sourcesContent":["// Define the shape of each category item\ntype Category = {\n  id: string;\n  title: string;\n  status: boolean;\n};\n\n// Define the shape of the final object where keys are strings (the ids)\ntype CategoriesObject = {\n  [key: string]: Category;\n};\n\n/**\n * Converts an array of category objects into an object\n * where each key is the `id` of the category.\n * @example\n * ```ts\n * const categories = [\n *   { id: \"1\", title: \"Category 1\", status: true },\n *   { id: \"2\", title: \"Category 2\", status: false },\n * ];\n * const categoriesObject = convertArrayToObject(categories);\n * console.log(categoriesObject);\n * // Output:\n * {\n *   \"1\": { id: \"1\", title: \"Category 1\", status: true },\n *   \"2\": { id: \"2\", title: \"Category 2\", status: false },\n * }\n * ```\n * @param arr - Array of Category items\n * @returns An object with category ids as keys and category objects as values\n */\nexport default function convertArrayToObject(\n  arr: Category[]\n): CategoriesObject {\n  return arr.reduce((acc: CategoriesObject, item: Category) => {\n    acc[item.id] = item; // Use the item's id as the key\n    return acc;\n  }, {}); // Start with an empty object\n}\n"],"names":["arr","reduce","acc","item","id"],"mappings":"oFAgCwB,SACtBA,GAEA,OAAOA,EAAIC,OAAO,SAACC,EAAuBC,GAExC,OADAD,EAAIC,EAAKC,IAAMD,EACRD,CACR,EAAE,CAAE,EACP"}