import { z } from "zod"

import { sysAssetSchema } from "./sysAsset"

import { BlocksEnums } from "@/types/enums/blocks"

export const textContentSchema = z.object({
  typename: z
    .literal(BlocksEnums.block.TextContent)
    .optional()
    .default(BlocksEnums.block.TextContent),
  text_content: z.object({
    content: z.object({
      json: z.any(),
      embedded_itemsConnection: z.object({
        edges: z.array(
          z.object({
            node: z.discriminatedUnion("__typename", [sysAssetSchema]),
          })
        ),
        totalCount: z.number(),
      }),
    }),
  }),
})
