import { z } from "zod";

export const pushSubscriptionSchema = z.object({
  endpoint: z.string().url(),
  keys: z.object({
    p256dh: z.string().min(1),
    auth: z.string().min(1)
  })
});

export const replaceablePushSubscriptionSchema = pushSubscriptionSchema.extend({
  previousEndpoint: z.string().url().optional()
});

export const anonymousPushSubscriptionSchema = pushSubscriptionSchema.extend({
  clientId: z.string().min(1).max(128).regex(/^[a-zA-Z0-9_-]+$/)
});

export const replaceableAnonymousPushSubscriptionSchema = anonymousPushSubscriptionSchema.extend({
  previousEndpoint: z.string().url().optional()
});

export const nativePushSubscriptionSchema = z.object({
  token: z.string().min(16),
  platform: z.enum(["android", "ios"]),
  deviceId: z.string().min(1).max(255).optional()
});

export const anonymousNativePushSubscriptionSchema = nativePushSubscriptionSchema.extend({
  clientId: z.string().min(1).max(128).regex(/^[a-zA-Z0-9_-]+$/)
});

export const notificationSettingsSchema = z.object({
  signalsPushEnabled: z.boolean(),
  resultsPushEnabled: z.boolean()
});

export const deactivatePushSubscriptionSchema = z.object({
  endpoint: z.string().url()
});

export const deactivateNativePushSubscriptionSchema = z.object({
  token: z.string().min(16)
});
