import {z} from "zod";
import {PlayerSchema} from "./data.ts";

export const SchematicSchema = z.object({
    name: z.string(),
    id: z.number(),
    type: z.string().nullable(),
    owner: z.number(),
    item: z.string(),
    lastUpdate: z.number().positive(),
    rank: z.number(),
    replaceColor: z.boolean(),
    allowReplay: z.boolean()
})

export type Schematic = z.infer<typeof SchematicSchema>

export const SchematicListSchema = z.object({
    breadcrumbs: z.array(z.object({
        name: z.string(),
        id: z.number()
    })),
    schematics: z.array(SchematicSchema),
    players: z.record(z.string(), PlayerSchema)
})

export type SchematicList = z.infer<typeof SchematicListSchema>

export const SchematicInfoSchema = z.object({
    members: z.array(PlayerSchema),
    path: z.string(),
    schem: SchematicSchema
})

export type SchematicInfo = z.infer<typeof SchematicInfoSchema>

export const SchematicCodeSchema = z.object({
    id: z.number().gte(0),
    code: z.string(),
    expires: z.number().positive()
})

export type SchematicCode = z.infer<typeof SchematicCodeSchema>