import { z } from 'zod'
import { UuidSchema } from '../../platform/utils/validation'

export const PublicAgentChatSlugParamSchema = z
  .object({
    slug: z.string().min(1).max(120).regex(/^[a-zA-Z0-9._-]+$/)
  })
  .strict()

export const PublicAgentChatSessionParamSchema = z
  .object({
    sessionId: UuidSchema
  })
  .strict()

export const PublicAgentChatAuthorizeSchema = z
  .object({
    code: z.string().min(1).max(200).optional(),
    visitorId: z.string().min(1).max(120).optional()
  })
  .strict()

export const PublicAgentChatCreateSessionSchema = z
  .object({
    capabilityToken: z.string().min(32).optional(),
    metadata: z.record(z.string(), z.unknown()).optional()
  })
  .strict()

export const PublicAgentChatCapabilityQuerySchema = z
  .object({
    token: z.string().min(32)
  })
  .strict()

export type PublicAgentChatSlugParams = z.infer<typeof PublicAgentChatSlugParamSchema>
export type PublicAgentChatSessionParams = z.infer<typeof PublicAgentChatSessionParamSchema>
export type PublicAgentChatAuthorizeInput = z.infer<typeof PublicAgentChatAuthorizeSchema>
export type PublicAgentChatCreateSessionInput = z.infer<typeof PublicAgentChatCreateSessionSchema>
export type PublicAgentChatCapabilityQuery = z.infer<typeof PublicAgentChatCapabilityQuerySchema>
