import { z } from 'zod'

const planEnum          = z.enum(['STARTER', 'GROWTH', 'PRO'])
const billingPeriodEnum = z.enum(['MONTHLY', 'ANNUAL'])
const providerEnum      = z.enum(['AMANPAY', 'PAYPAL'])
const currencyEnum      = z.enum(['MAD', 'EUR', 'USD'])

export const checkoutSchema = z.object({
  plan:          planEnum,
  billingPeriod: billingPeriodEnum,
  currency:      z.literal('MAD'),
  provider:      providerEnum,
  successUrl:    z.string().url(),
  failureUrl:    z.string().url(),
})

export const changePlanSchema = z.object({
  plan:          planEnum,
  billingPeriod: billingPeriodEnum,
  currency:      currencyEnum,
})

export const capturePaypalSchema = z.object({
  paypalOrderId: z.string(),
})

export const startTrialSchema = z.object({
  plan:          planEnum,
  billingPeriod: billingPeriodEnum,
  currency:      z.literal('MAD').default('MAD'),
})

export const cancelSchema = z.object({
  mode:   z.enum(['period_end', 'immediate']).default('period_end'),
  reason: z.string().max(500).optional(),
})

export const reactivateSchema = z.object({
  plan:          planEnum,
  billingPeriod: billingPeriodEnum,
  currency:      z.literal('MAD'),
  provider:      providerEnum,
  successUrl:    z.string().url(),
  failureUrl:    z.string().url(),
})
