===== CHUNK 1 =====
// @ts-nocheck
// Sample TypeScript code for testing chunking behavior
// This is a test fixture representing typical code structure

export interface User {
	id: string;
	name: string;
	email: string;
	createdAt: Date;
	updatedAt: Date;
===== CHUNK 2 =====
}

export interface Post {
	id: string;
	title: string;
	content: string;
	authorId: string;
	tags: string[];
	published: boolean;
	publishedAt?: Date;
===== CHUNK 3 =====
	createdAt: Date;
	updatedAt: Date;
}

export class UserService {
	constructor(private readonly db: Database) {}

	async findById(id: string): Promise<User | null> {
		const user = await this.db.users.findUnique({
			where: { id },
===== CHUNK 4 =====
		});
		return user;
	}

	async findByEmail(email: string): Promise<User | null> {
		const user = await this.db.users.findUnique({
			where: { email },
		});
		return user;
	}
===== CHUNK 5 =====

	async create(data: CreateUserInput): Promise<User> {
		const user = await this.db.users.create({
			data: {
				...data,
				createdAt: new Date(),
				updatedAt: new Date(),
			},
		});
		return user;
===== CHUNK 6 =====
	}

	async update(id: string, data: UpdateUserInput): Promise<User> {
		const user = await this.db.users.update({
			where: { id },
			data: {
				...data,
				updatedAt: new Date(),
			},
		});
===== CHUNK 7 =====
		return user;
	}

	async delete(id: string): Promise<void> {
		await this.db.users.delete({
			where: { id },
		});
	}
}

===== CHUNK 8 =====
export class PostService {
	constructor(private readonly db: Database) {}

	async findById(id: string): Promise<Post | null> {
		const post = await this.db.posts.findUnique({
			where: { id },
			include: { author: true },
		});
		return post;
	}
===== CHUNK 9 =====

	async findByAuthor(authorId: string): Promise<Post[]> {
		const posts = await this.db.posts.findMany({
			where: { authorId },
			orderBy: { createdAt: "desc" },
		});
		return posts;
	}

	async findPublished(): Promise<Post[]> {
===== CHUNK 10 =====
		const posts = await this.db.posts.findMany({
			where: { published: true },
			orderBy: { publishedAt: "desc" },
		});
		return posts;
	}

	async create(data: CreatePostInput): Promise<Post> {
		const post = await this.db.posts.create({
			data: {
===== CHUNK 11 =====
				...data,
				createdAt: new Date(),
				updatedAt: new Date(),
			},
		});
		return post;
	}

	async publish(id: string): Promise<Post> {
		const post = await this.db.posts.update({
===== CHUNK 12 =====
			where: { id },
			data: {
				published: true,
				publishedAt: new Date(),
				updatedAt: new Date(),
			},
		});
		return post;
	}
}
===== CHUNK 13 =====

// Database interface
interface Database {
	users: unknown;
	posts: unknown;
}

// Input types
interface CreateUserInput {
	name: string;
===== CHUNK 14 =====
	email: string;
}

interface UpdateUserInput {
	name?: string;
	email?: string;
}

interface CreatePostInput {
	title: string;
===== CHUNK 15 =====
	content: string;
	authorId: string;
	tags: string[];
}
