import {
	Post,
	Department,
	Staff,
	Enrollment,
	Taxonomy,
	Term,
} from "@prisma/client";
import { StaffDto } from "./staff";
import { TermDto } from "./term";
import { ResourceDto } from "./resource";
import { DepartmentDto } from "./department";

export type PostComment = {
	id: string;
	type: string;
	title: string;
	content: string;
	authorId: string;
	domainId: string;
	referenceId: string;
	resources: string[];
	createdAt: Date;
	updatedAt: Date;
	parentId: string;
	author: {
		id: string;
		showname: string;
		username: string;
		avatar: string;
	};
};
export type PostDto = Post & {
	readed: boolean;
	readedCount: number;
	author: StaffDto;
	limitedComments: PostComment[];
	commentsCount: number;
	perms?: {
		delete: boolean;
		// edit: boolean;
	};
	meta?: PostMeta;
	watchableDepts: Department[];
	watchableStaffs: Staff[];
	terms: TermDto[];
	depts: DepartmentDto[];
	studentIds?: string[];
};
export type PostMeta = {
	thumbnail?: string;
	views?: number;
	likes?: number;
	hates?: number;
};
export type LectureMeta = PostMeta & {
	type?: string;

	videoUrl?: string;
	videoThumbnail?: string;
	videoIds?: string[];
	videoThumbnailIds?: string[];
};

export type Lecture = Post & {
	courseId?: string;
	resources?: ResourceDto[];
	meta?: LectureMeta;
};

export type SectionMeta = PostMeta & {
	objectives?: string[];
};
export type Section = Post & {
	courseId?: string;
	meta?: SectionMeta;
};
export type SectionDto = Section & {
	lectures: Lecture[];
};
export type CourseMeta = PostMeta & {
	objectives?: string[];
};
export type Course = PostDto & {
	meta?: CourseMeta;
};
export type CourseDto = Course & {
	enrollments?: Enrollment[];
	sections?: SectionDto[];
	terms: TermDto[];
	lectureCount?: number;
	depts: Department[];
	studentIds: string[];
};

export type Summary = {
	id: string;
	text: string;
	parent: string;
	start: number;
	end: number;
};
export type NodeObj = {
	topic: string;
	id: string;
	style?: {
		fontSize?: string;
		color?: string;
		background?: string;
		fontWeight?: string;
	};
	children?: NodeObj[];
};
export type Arrow = {
	id: string;
	label: string;
	from: string;
	to: string;
	delta1: {
		x: number;
		y: number;
	};
	delta2: {
		x: number;
		y: number;
	};
};
export type PathMeta = PostMeta & {
	nodeData: NodeObj;
	arrows?: Arrow[];
	summaries?: Summary[];
	direction?: number;
};
export type PathDto = PostDto & {
	meta: PathMeta;
};
