hunk.code_window:     @@map("file_conflict")
   }
   // keys allow us to know exactly which files can be decrypted with a given key
   // they can be "mounted" to a client, and then used to decrypt files automatically
   /// @shared(id: uuid)
  
hunk.labels: keep replace replace keep keep keep keep
hunk.after_edit: //     @@map("file_conflict")
   // }
  
hunk.file_path: core/prisma/schema.prisma
hunk.type: replace
file: import { Doc, DocumentTypes } from '@contentlayer/generated';
  import { Circle, Cube, Icon, Sparkle, Star } from 'phosphor-react';
  import { toTitleCase } from './util';
  
  type DocsCategory = {
  	title: string;
  	slug: string;
  	categoryIndex: number;
  	docs: CoreContent<Doc>[];
  };
  
  export type DocsNavigation = {
  	slug: string;
  	categories: DocsCategory[];
  }[];
  
  export function getDocsNavigation(docs: Doc[]): DocsNavigation {
  	const coreDocs = allCoreContent(docs);
  
  	const docsNavigation: DocsNavigation = [];
  
  	const docsBySection = coreDocs.reduce((acc, doc) => {
  		const section = doc.section;
  		acc[section] = acc[section] || [];
  		acc[section].push(doc);
  		return acc;
  	}, {} as Record<string, CoreContent<Doc>[]>);
  
  	// console.log('docsBySection', docsBySection);
  
  	for (const section in docsBySection) {
  		const docs = docsBySection[section];
  		const docsByCategory = docs.reduce((acc, doc) => {
  			const category = doc.category;
  			acc[category] = acc[category] || [];
  			acc[category].push(doc);
  			return acc;
  		}, {} as Record<string, CoreContent<Doc>[]>);
  
  		// console.log('docsByCategory', docsByCategory);
  
  		const sectionNavigation: DocsCategory[] = [];
  		for (const category in docsByCategory) {
  			const docs = docsByCategory[category];
  			docs.sort((a, b) => a.index - b.index);
  			const categoryIndex = docs[0].index;
  			sectionNavigation.push({
  				title: toTitleCase(category),
  				slug: category,
  				categoryIndex,
  				docs
  			});
  		}
  
  		sectionNavigation.sort((a, b) => a.categoryIndex - b.categoryIndex);
  
  		docsNavigation.push({
  			slug: section,
  			categories: sectionNavigation
  		});
  	}
  
  	// Sort the sections using the order on iconConfig
  	docsNavigation.sort((a, b) => {
  		const aIndex = Object.keys(iconConfig).indexOf(a.slug);
  		const bIndex = Object.keys(iconConfig).indexOf(b.slug);
  		return aIndex - bIndex;
  	});
  
  	return docsNavigation;
  }
  
  // Used to get the icon from section name and for sorting
  export const iconConfig: Record<string, Icon> = {
  	product: Sparkle,
  	developers: Cube,
  	company: Circle,
  	changelog: Star
  };
  
  export function getSortedDocs(docs: Doc[]) {
  	return docs.sort((a, b) => a.index - b.index);
  }
  
  // This function is used to omit the fields that are not needed in the sidebar navigation
  export const omit = <Obj, Keys extends keyof Obj>(obj: Obj, keys: Keys[]): Omit<Obj, Keys> => {
  	const result = Object.assign({}, obj);
  	keys.forEach((key) => {
  		delete result[key];
  	});
  	return result;
  };
  
  export type CoreContent<T> = Omit<T, 'body' | '_raw' | '_id'>;
  
  export function coreContent<T extends DocumentTypes>(content: T) {
  	return omit(content, ['body', '_raw', '_id']);
  }
  
  export function allCoreContent<T extends DocumentTypes>(contents: T[]) {
  	return contents.map((c) => coreContent(c));
  }
  