export type Json =
  | string
  | number
  | boolean
  | null
  | { [key: string]: Json | undefined }
  | Json[]

export type Database = {
  // Allows to automatically instantiate createClient with right options
  // instead of createClient<Database, { PostgrestVersion: 'XX' }>(URL, KEY)
  __InternalSupabase: {
    PostgrestVersion: "14.5"
  }
  public: {
    Tables: {
      appointments: {
        Row: {
          appointment_date: string
          appointment_time: string | null
          baby_id: string
          created_at: string | null
          id: string
          is_notified: boolean | null
          location: string | null
          notes: string | null
          parent_id: string
          title: string
          type: string | null
        }
        Insert: {
          appointment_date: string
          appointment_time?: string | null
          baby_id: string
          created_at?: string | null
          id?: string
          is_notified?: boolean | null
          location?: string | null
          notes?: string | null
          parent_id: string
          title: string
          type?: string | null
        }
        Update: {
          appointment_date?: string
          appointment_time?: string | null
          baby_id?: string
          created_at?: string | null
          id?: string
          is_notified?: boolean | null
          location?: string | null
          notes?: string | null
          parent_id?: string
          title?: string
          type?: string | null
        }
        Relationships: [
          {
            foreignKeyName: "appointments_baby_id_fkey"
            columns: ["baby_id"]
            isOneToOne: false
            referencedRelation: "babies"
            referencedColumns: ["id"]
          },
        ]
      }
      babies: {
        Row: {
          birthday: string | null
          blood_group: string | null
          created_at: string | null
          family_id: string
          gender: string | null
          id: string
          name: string
        }
        Insert: {
          birthday?: string | null
          blood_group?: string | null
          created_at?: string | null
          family_id: string
          gender?: string | null
          id?: string
          name: string
        }
        Update: {
          birthday?: string | null
          blood_group?: string | null
          created_at?: string | null
          family_id?: string
          gender?: string | null
          id?: string
          name?: string
        }
        Relationships: [
          {
            foreignKeyName: "babies_family_id_fkey"
            columns: ["family_id"]
            isOneToOne: false
            referencedRelation: "families"
            referencedColumns: ["id"]
          },
        ]
      }
      baby_care_reminders: {
        Row: {
          baby_id: string
          diaper_reminders_on: boolean | null
          feeding_reminders_on: boolean | null
          id: string
          parent_id: string
          updated_at: string | null
        }
        Insert: {
          baby_id: string
          diaper_reminders_on?: boolean | null
          feeding_reminders_on?: boolean | null
          id?: string
          parent_id: string
          updated_at?: string | null
        }
        Update: {
          baby_id?: string
          diaper_reminders_on?: boolean | null
          feeding_reminders_on?: boolean | null
          id?: string
          parent_id?: string
          updated_at?: string | null
        }
        Relationships: [
          {
            foreignKeyName: "baby_care_reminders_baby_id_fkey"
            columns: ["baby_id"]
            isOneToOne: true
            referencedRelation: "babies"
            referencedColumns: ["id"]
          },
        ]
      }
      care_settings: {
        Row: {
          created_at: string | null
          feeding_interval_hours: number | null
          feeding_reminders_on: boolean | null
          id: string
          medication_reminders_on: boolean | null
          night_sleep_end: string | null
          night_sleep_start: string | null
          push_notifications_on: boolean | null
          user_id: string
        }
        Insert: {
          created_at?: string | null
          feeding_interval_hours?: number | null
          feeding_reminders_on?: boolean | null
          id?: string
          medication_reminders_on?: boolean | null
          night_sleep_end?: string | null
          night_sleep_start?: string | null
          push_notifications_on?: boolean | null
          user_id: string
        }
        Update: {
          created_at?: string | null
          feeding_interval_hours?: number | null
          feeding_reminders_on?: boolean | null
          id?: string
          medication_reminders_on?: boolean | null
          night_sleep_end?: string | null
          night_sleep_start?: string | null
          push_notifications_on?: boolean | null
          user_id?: string
        }
        Relationships: []
      }
      diapers: {
        Row: {
          baby_id: string | null
          color: string | null
          id: string
          note: string | null
          parent_id: string | null
          status: string | null
          timestamp: string | null
          type: string
        }
        Insert: {
          baby_id?: string | null
          color?: string | null
          id?: string
          note?: string | null
          parent_id?: string | null
          status?: string | null
          timestamp?: string | null
          type: string
        }
        Update: {
          baby_id?: string | null
          color?: string | null
          id?: string
          note?: string | null
          parent_id?: string | null
          status?: string | null
          timestamp?: string | null
          type?: string
        }
        Relationships: [
          {
            foreignKeyName: "diapers_baby_id_fkey"
            columns: ["baby_id"]
            isOneToOne: false
            referencedRelation: "babies"
            referencedColumns: ["id"]
          },
        ]
      }
      families: {
        Row: {
          created_at: string | null
          current_plan: string | null
          family_name: string
          id: string
          owner_id: string
          plan_tier: string | null
        }
        Insert: {
          created_at?: string | null
          current_plan?: string | null
          family_name: string
          id?: string
          owner_id: string
          plan_tier?: string | null
        }
        Update: {
          created_at?: string | null
          current_plan?: string | null
          family_name?: string
          id?: string
          owner_id?: string
          plan_tier?: string | null
        }
        Relationships: []
      }
      family_members: {
        Row: {
          family_id: string | null
          id: string
          joined_at: string | null
          role: string | null
          user_id: string | null
        }
        Insert: {
          family_id?: string | null
          id?: string
          joined_at?: string | null
          role?: string | null
          user_id?: string | null
        }
        Update: {
          family_id?: string | null
          id?: string
          joined_at?: string | null
          role?: string | null
          user_id?: string | null
        }
        Relationships: [
          {
            foreignKeyName: "family_members_family_id_fkey"
            columns: ["family_id"]
            isOneToOne: false
            referencedRelation: "families"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "family_members_user_id_fkey"
            columns: ["user_id"]
            isOneToOne: false
            referencedRelation: "profiles"
            referencedColumns: ["id"]
          },
        ]
      }
      feeding_logs: {
        Row: {
          amount: number | null
          baby_id: string | null
          duration: number | null
          id: string
          notes: string | null
          parent_id: string | null
          side: string | null
          timestamp: string | null
          type: string
        }
        Insert: {
          amount?: number | null
          baby_id?: string | null
          duration?: number | null
          id?: string
          notes?: string | null
          parent_id?: string | null
          side?: string | null
          timestamp?: string | null
          type: string
        }
        Update: {
          amount?: number | null
          baby_id?: string | null
          duration?: number | null
          id?: string
          notes?: string | null
          parent_id?: string | null
          side?: string | null
          timestamp?: string | null
          type?: string
        }
        Relationships: [
          {
            foreignKeyName: "feeding_logs_baby_id_fkey"
            columns: ["baby_id"]
            isOneToOne: false
            referencedRelation: "babies"
            referencedColumns: ["id"]
          },
        ]
      }
      growth_logs: {
        Row: {
          baby_id: string | null
          created_at: string | null
          entry_date: string
          head: number | null
          height: number | null
          id: string
          notes: string | null
          parent_id: string | null
          weight: number | null
        }
        Insert: {
          baby_id?: string | null
          created_at?: string | null
          entry_date?: string
          head?: number | null
          height?: number | null
          id?: string
          notes?: string | null
          parent_id?: string | null
          weight?: number | null
        }
        Update: {
          baby_id?: string | null
          created_at?: string | null
          entry_date?: string
          head?: number | null
          height?: number | null
          id?: string
          notes?: string | null
          parent_id?: string | null
          weight?: number | null
        }
        Relationships: [
          {
            foreignKeyName: "growth_logs_baby_id_fkey"
            columns: ["baby_id"]
            isOneToOne: false
            referencedRelation: "babies"
            referencedColumns: ["id"]
          },
        ]
      }
      health_logs: {
        Row: {
          baby_id: string | null
          dosage: string | null
          id: string
          medication_name: string | null
          note: string | null
          parent_id: string | null
          timestamp: string | null
          type: string
          unit: string | null
          value: string | null
        }
        Insert: {
          baby_id?: string | null
          dosage?: string | null
          id?: string
          medication_name?: string | null
          note?: string | null
          parent_id?: string | null
          timestamp?: string | null
          type: string
          unit?: string | null
          value?: string | null
        }
        Update: {
          baby_id?: string | null
          dosage?: string | null
          id?: string
          medication_name?: string | null
          note?: string | null
          parent_id?: string | null
          timestamp?: string | null
          type?: string
          unit?: string | null
          value?: string | null
        }
        Relationships: [
          {
            foreignKeyName: "health_logs_baby_id_fkey"
            columns: ["baby_id"]
            isOneToOne: false
            referencedRelation: "babies"
            referencedColumns: ["id"]
          },
        ]
      }
      invitations: {
        Row: {
          created_at: string | null
          email: string
          family_id: string | null
          id: string
          invited_by: string | null
        }
        Insert: {
          created_at?: string | null
          email: string
          family_id?: string | null
          id?: string
          invited_by?: string | null
        }
        Update: {
          created_at?: string | null
          email?: string
          family_id?: string | null
          id?: string
          invited_by?: string | null
        }
        Relationships: [
          {
            foreignKeyName: "invitations_family_id_fkey"
            columns: ["family_id"]
            isOneToOne: false
            referencedRelation: "families"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "invitations_invited_by_fkey"
            columns: ["invited_by"]
            isOneToOne: false
            referencedRelation: "profiles"
            referencedColumns: ["id"]
          },
        ]
      }
      medication_reminders: {
        Row: {
          baby_id: string
          created_at: string | null
          id: string
          interval_hours: number | null
          is_active: boolean | null
          medication_name: string
          parent_id: string
          reminder_time: string
        }
        Insert: {
          baby_id: string
          created_at?: string | null
          id?: string
          interval_hours?: number | null
          is_active?: boolean | null
          medication_name: string
          parent_id: string
          reminder_time: string
        }
        Update: {
          baby_id?: string
          created_at?: string | null
          id?: string
          interval_hours?: number | null
          is_active?: boolean | null
          medication_name?: string
          parent_id?: string
          reminder_time?: string
        }
        Relationships: [
          {
            foreignKeyName: "medication_reminders_baby_id_fkey"
            columns: ["baby_id"]
            isOneToOne: false
            referencedRelation: "babies"
            referencedColumns: ["id"]
          },
        ]
      }
      milestones: {
        Row: {
          achievement_date: string
          baby_id: string | null
          category: string
          created_at: string | null
          id: string
          notes: string | null
          parent_id: string | null
          title: string
        }
        Insert: {
          achievement_date: string
          baby_id?: string | null
          category: string
          created_at?: string | null
          id?: string
          notes?: string | null
          parent_id?: string | null
          title: string
        }
        Update: {
          achievement_date?: string
          baby_id?: string | null
          category?: string
          created_at?: string | null
          id?: string
          notes?: string | null
          parent_id?: string | null
          title?: string
        }
        Relationships: [
          {
            foreignKeyName: "milestones_baby_id_fkey"
            columns: ["baby_id"]
            isOneToOne: false
            referencedRelation: "babies"
            referencedColumns: ["id"]
          },
        ]
      }
      notifications: {
        Row: {
          created_at: string | null
          data: Json | null
          id: string
          is_read: boolean | null
          message: string
          title: string
          type: string
          user_id: string
        }
        Insert: {
          created_at?: string | null
          data?: Json | null
          id?: string
          is_read?: boolean | null
          message: string
          title: string
          type: string
          user_id: string
        }
        Update: {
          created_at?: string | null
          data?: Json | null
          id?: string
          is_read?: boolean | null
          message?: string
          title?: string
          type?: string
          user_id?: string
        }
        Relationships: []
      }
      profiles: {
        Row: {
          address: string | null
          avatar_url: string | null
          biometrics_enabled: boolean | null
          current_plan: string | null
          daily_nap_count: string | null
          email: string | null
          emotional_state_description: string | null
          emotional_state_status: string | null
          feeding_knowledge_level: string | null
          full_name: string | null
          id: string
          is_admin: boolean | null
          last_location: Json | null
          last_sleep_observation: string | null
          onboarding_complete: boolean | null
          onboarding_interests: string[] | null
          onboarding_mood: string | null
          parent_appetite_status: string | null
          phone_number: string | null
          preferred_language: string | null
          self_care_habits: string[] | null
          sleep_attempts_history: string[] | null
          stripe_customer_id: string | null
          updated_at: string | null
        }
        Insert: {
          address?: string | null
          avatar_url?: string | null
          biometrics_enabled?: boolean | null
          current_plan?: string | null
          daily_nap_count?: string | null
          email?: string | null
          emotional_state_description?: string | null
          emotional_state_status?: string | null
          feeding_knowledge_level?: string | null
          full_name?: string | null
          id: string
          is_admin?: boolean | null
          last_location?: Json | null
          last_sleep_observation?: string | null
          onboarding_complete?: boolean | null
          onboarding_interests?: string[] | null
          onboarding_mood?: string | null
          parent_appetite_status?: string | null
          phone_number?: string | null
          preferred_language?: string | null
          self_care_habits?: string[] | null
          sleep_attempts_history?: string[] | null
          stripe_customer_id?: string | null
          updated_at?: string | null
        }
        Update: {
          address?: string | null
          avatar_url?: string | null
          biometrics_enabled?: boolean | null
          current_plan?: string | null
          daily_nap_count?: string | null
          email?: string | null
          emotional_state_description?: string | null
          emotional_state_status?: string | null
          feeding_knowledge_level?: string | null
          full_name?: string | null
          id?: string
          is_admin?: boolean | null
          last_location?: Json | null
          last_sleep_observation?: string | null
          onboarding_complete?: boolean | null
          onboarding_interests?: string[] | null
          onboarding_mood?: string | null
          parent_appetite_status?: string | null
          phone_number?: string | null
          preferred_language?: string | null
          self_care_habits?: string[] | null
          sleep_attempts_history?: string[] | null
          stripe_customer_id?: string | null
          updated_at?: string | null
        }
        Relationships: []
      }
      sleep_logs: {
        Row: {
          baby_id: string | null
          created_at: string | null
          end_time: string | null
          id: string
          note: string | null
          parent_id: string | null
          start_time: string
        }
        Insert: {
          baby_id?: string | null
          created_at?: string | null
          end_time?: string | null
          id?: string
          note?: string | null
          parent_id?: string | null
          start_time: string
        }
        Update: {
          baby_id?: string | null
          created_at?: string | null
          end_time?: string | null
          id?: string
          note?: string | null
          parent_id?: string | null
          start_time?: string
        }
        Relationships: [
          {
            foreignKeyName: "sleep_logs_baby_id_fkey"
            columns: ["baby_id"]
            isOneToOne: false
            referencedRelation: "babies"
            referencedColumns: ["id"]
          },
        ]
      }
      sleep_reminders: {
        Row: {
          baby_id: string
          id: string
          is_enabled: boolean | null
          parent_id: string
          updated_at: string | null
          wake_window_minutes: number | null
        }
        Insert: {
          baby_id: string
          id?: string
          is_enabled?: boolean | null
          parent_id: string
          updated_at?: string | null
          wake_window_minutes?: number | null
        }
        Update: {
          baby_id?: string
          id?: string
          is_enabled?: boolean | null
          parent_id?: string
          updated_at?: string | null
          wake_window_minutes?: number | null
        }
        Relationships: [
          {
            foreignKeyName: "sleep_reminders_baby_id_fkey"
            columns: ["baby_id"]
            isOneToOne: true
            referencedRelation: "babies"
            referencedColumns: ["id"]
          },
        ]
      }
      subscriptions: {
        Row: {
          created_at: string | null
          current_period_end: string | null
          family_id: string | null
          id: string
          plan_interval: string | null
          price_id: string | null
          status: string | null
          stripe_customer_id: string | null
          stripe_subscription_id: string | null
          user_id: string
        }
        Insert: {
          created_at?: string | null
          current_period_end?: string | null
          family_id?: string | null
          id?: string
          plan_interval?: string | null
          price_id?: string | null
          status?: string | null
          stripe_customer_id?: string | null
          stripe_subscription_id?: string | null
          user_id: string
        }
        Update: {
          created_at?: string | null
          current_period_end?: string | null
          family_id?: string | null
          id?: string
          plan_interval?: string | null
          price_id?: string | null
          status?: string | null
          stripe_customer_id?: string | null
          stripe_subscription_id?: string | null
          user_id?: string
        }
        Relationships: [
          {
            foreignKeyName: "subscriptions_family_id_fkey"
            columns: ["family_id"]
            isOneToOne: true
            referencedRelation: "families"
            referencedColumns: ["id"]
          },
        ]
      }
      support_tickets: {
        Row: {
          created_at: string | null
          id: string
          message: string
          priority: string | null
          status: string | null
          subject: string
          user_id: string
        }
        Insert: {
          created_at?: string | null
          id?: string
          message: string
          priority?: string | null
          status?: string | null
          subject: string
          user_id: string
        }
        Update: {
          created_at?: string | null
          id?: string
          message?: string
          priority?: string | null
          status?: string | null
          subject?: string
          user_id?: string
        }
        Relationships: []
      }
      vaccinations: {
        Row: {
          administered_date: string | null
          baby_id: string | null
          created_at: string | null
          due_date: string | null
          id: string
          status: string | null
          vaccine_name: string
        }
        Insert: {
          administered_date?: string | null
          baby_id?: string | null
          created_at?: string | null
          due_date?: string | null
          id?: string
          status?: string | null
          vaccine_name: string
        }
        Update: {
          administered_date?: string | null
          baby_id?: string | null
          created_at?: string | null
          due_date?: string | null
          id?: string
          status?: string | null
          vaccine_name?: string
        }
        Relationships: [
          {
            foreignKeyName: "vaccinations_baby_id_fkey"
            columns: ["baby_id"]
            isOneToOne: false
            referencedRelation: "babies"
            referencedColumns: ["id"]
          },
        ]
      }
    }
    Views: {
      [_ in never]: never
    }
    Functions: {
      [_ in never]: never
    }
    Enums: {
      [_ in never]: never
    }
    CompositeTypes: {
      [_ in never]: never
    }
  }
}

type DatabaseWithoutInternals = Omit<Database, "__InternalSupabase">

type DefaultSchema = DatabaseWithoutInternals[Extract<keyof Database, "public">]

export type Tables<
  DefaultSchemaTableNameOrOptions extends
    | keyof (DefaultSchema["Tables"] & DefaultSchema["Views"])
    | { schema: keyof DatabaseWithoutInternals },
  TableName extends DefaultSchemaTableNameOrOptions extends {
    schema: keyof DatabaseWithoutInternals
  }
    ? keyof (DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Tables"] &
        DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Views"])
    : never = never,
> = DefaultSchemaTableNameOrOptions extends {
  schema: keyof DatabaseWithoutInternals
}
  ? (DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Tables"] &
      DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Views"])[TableName] extends {
      Row: infer R
    }
    ? R
    : never
  : DefaultSchemaTableNameOrOptions extends keyof (DefaultSchema["Tables"] &
        DefaultSchema["Views"])
    ? (DefaultSchema["Tables"] &
        DefaultSchema["Views"])[DefaultSchemaTableNameOrOptions] extends {
        Row: infer R
      }
      ? R
      : never
    : never

export type TablesInsert<
  DefaultSchemaTableNameOrOptions extends
    | keyof DefaultSchema["Tables"]
    | { schema: keyof DatabaseWithoutInternals },
  TableName extends DefaultSchemaTableNameOrOptions extends {
    schema: keyof DatabaseWithoutInternals
  }
    ? keyof DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Tables"]
    : never = never,
> = DefaultSchemaTableNameOrOptions extends {
  schema: keyof DatabaseWithoutInternals
}
  ? DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Tables"][TableName] extends {
      Insert: infer I
    }
    ? I
    : never
  : DefaultSchemaTableNameOrOptions extends keyof DefaultSchema["Tables"]
    ? DefaultSchema["Tables"][DefaultSchemaTableNameOrOptions] extends {
        Insert: infer I
      }
      ? I
      : never
    : never

export type TablesUpdate<
  DefaultSchemaTableNameOrOptions extends
    | keyof DefaultSchema["Tables"]
    | { schema: keyof DatabaseWithoutInternals },
  TableName extends DefaultSchemaTableNameOrOptions extends {
    schema: keyof DatabaseWithoutInternals
  }
    ? keyof DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Tables"]
    : never = never,
> = DefaultSchemaTableNameOrOptions extends {
  schema: keyof DatabaseWithoutInternals
}
  ? DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Tables"][TableName] extends {
      Update: infer U
    }
    ? U
    : never
  : DefaultSchemaTableNameOrOptions extends keyof DefaultSchema["Tables"]
    ? DefaultSchema["Tables"][DefaultSchemaTableNameOrOptions] extends {
        Update: infer U
      }
      ? U
      : never
    : never

export type Enums<
  DefaultSchemaEnumNameOrOptions extends
    | keyof DefaultSchema["Enums"]
    | { schema: keyof DatabaseWithoutInternals },
  EnumName extends DefaultSchemaEnumNameOrOptions extends {
    schema: keyof DatabaseWithoutInternals
  }
    ? keyof DatabaseWithoutInternals[DefaultSchemaEnumNameOrOptions["schema"]]["Enums"]
    : never = never,
> = DefaultSchemaEnumNameOrOptions extends {
  schema: keyof DatabaseWithoutInternals
}
  ? DatabaseWithoutInternals[DefaultSchemaEnumNameOrOptions["schema"]]["Enums"][EnumName]
  : DefaultSchemaEnumNameOrOptions extends keyof DefaultSchema["Enums"]
    ? DefaultSchema["Enums"][DefaultSchemaEnumNameOrOptions]
    : never

export type CompositeTypes<
  PublicCompositeTypeNameOrOptions extends
    | keyof DefaultSchema["CompositeTypes"]
    | { schema: keyof DatabaseWithoutInternals },
  CompositeTypeName extends PublicCompositeTypeNameOrOptions extends {
    schema: keyof DatabaseWithoutInternals
  }
    ? keyof DatabaseWithoutInternals[PublicCompositeTypeNameOrOptions["schema"]]["CompositeTypes"]
    : never = never,
> = PublicCompositeTypeNameOrOptions extends {
  schema: keyof DatabaseWithoutInternals
}
  ? DatabaseWithoutInternals[PublicCompositeTypeNameOrOptions["schema"]]["CompositeTypes"][CompositeTypeName]
  : PublicCompositeTypeNameOrOptions extends keyof DefaultSchema["CompositeTypes"]
    ? DefaultSchema["CompositeTypes"][PublicCompositeTypeNameOrOptions]
    : never

export const Constants = {
  public: {
    Enums: {},
  },
} as const
